From e3c5eac99c3b2be6929adfca455c1be87fab792b Mon Sep 17 00:00:00 2001 From: SheetJS Date: Wed, 4 Sep 2019 02:26:56 -0400 Subject: [PATCH] initial release of S [ci skip] --- packages/s/.gitignore | 1 + packages/s/.npmignore | 8 + packages/s/LICENSE | 201 +++++ packages/s/Makefile | 23 + packages/s/README.md | 12 + packages/s/dist/S.js | 11 + packages/s/dist/cjs/index.js | 10 + packages/s/dist/cjs/index.js.map | 1 + packages/s/dist/cjs/s/Range.js | 12 + packages/s/dist/cjs/s/Range.js.map | 1 + packages/s/dist/cjs/s/Workbook.js | 37 + packages/s/dist/cjs/s/Workbook.js.map | 1 + packages/s/dist/cjs/s/XLSXWrapper.js | 15 + packages/s/dist/cjs/s/XLSXWrapper.js.map | 1 + packages/s/dist/cjs/s/names/DefinedName.js | 21 + .../s/dist/cjs/s/names/DefinedName.js.map | 1 + .../dist/cjs/s/names/DefinedNameCollection.js | 6 + .../cjs/s/names/DefinedNameCollection.js.map | 1 + .../s/names/WorkbookDefinedNameCollection.js | 81 ++ .../WorkbookDefinedNameCollection.js.map | 1 + .../cjs/s/worksheet/WorksheetCollection.js | 15 + .../s/worksheet/WorksheetCollection.js.map | 1 + packages/s/dist/cjs/umd.js | 9 + packages/s/dist/cjs/umd.js.map | 1 + packages/s/dist/esm/index.js | 5 + packages/s/dist/esm/index.js.map | 1 + packages/s/dist/esm/s/Range.js | 6 + packages/s/dist/esm/s/Range.js.map | 1 + packages/s/dist/esm/s/Workbook.js | 21 + packages/s/dist/esm/s/Workbook.js.map | 1 + packages/s/dist/esm/s/XLSXWrapper.js | 11 + packages/s/dist/esm/s/XLSXWrapper.js.map | 1 + packages/s/dist/esm/s/names/DefinedName.js | 13 + .../s/dist/esm/s/names/DefinedName.js.map | 1 + .../dist/esm/s/names/DefinedNameCollection.js | 4 + .../esm/s/names/DefinedNameCollection.js.map | 1 + .../s/names/WorkbookDefinedNameCollection.js | 69 ++ .../WorkbookDefinedNameCollection.js.map | 1 + .../esm/s/worksheet/WorksheetCollection.js | 11 + .../s/worksheet/WorksheetCollection.js.map | 1 + packages/s/dist/esm/umd.js | 4 + packages/s/dist/esm/umd.js.map | 1 + packages/s/dist/mjs/index.js.map | 1 + packages/s/dist/mjs/index.mjs | 5 + packages/s/dist/mjs/s/Range.js.map | 1 + packages/s/dist/mjs/s/Range.mjs | 6 + packages/s/dist/mjs/s/Workbook.js.map | 1 + packages/s/dist/mjs/s/Workbook.mjs | 21 + packages/s/dist/mjs/s/XLSXWrapper.js.map | 1 + packages/s/dist/mjs/s/XLSXWrapper.mjs | 11 + .../s/dist/mjs/s/names/DefinedName.js.map | 1 + packages/s/dist/mjs/s/names/DefinedName.mjs | 13 + .../mjs/s/names/DefinedNameCollection.js.map | 1 + .../mjs/s/names/DefinedNameCollection.mjs | 4 + .../WorkbookDefinedNameCollection.js.map | 1 + .../s/names/WorkbookDefinedNameCollection.mjs | 69 ++ .../s/worksheet/WorksheetCollection.js.map | 1 + .../mjs/s/worksheet/WorksheetCollection.mjs | 11 + packages/s/dist/mjs/umd.js.map | 1 + packages/s/dist/mjs/umd.mjs | 4 + packages/s/dist/typings/index.d.ts | 3 + packages/s/dist/typings/s/Range.d.ts | 3 + packages/s/dist/typings/s/Workbook.d.ts | 13 + packages/s/dist/typings/s/XLSXWrapper.d.ts | 4 + .../s/dist/typings/s/names/DefinedName.d.ts | 7 + .../s/names/DefinedNameCollection.d.ts | 9 + .../names/WorkbookDefinedNameCollection.d.ts | 27 + .../s/worksheet/WorksheetCollection.d.ts | 6 + packages/s/dist/typings/umd.d.ts | 2 + packages/s/esm.mjs | 4 + packages/s/index.js | 4 + packages/s/misc/.gitignore | 2 + packages/s/misc/import_test.mjs | 15 + packages/s/misc/make_mjs.sh | 8 + packages/s/misc/parcel.js | 8 + packages/s/misc/puppetmjs.js | 15 + packages/s/misc/puppetpcl.js | 14 + packages/s/misc/puppetsta.js | 14 + packages/s/misc/require_test.njs | 11 + packages/s/misc/standalone.js | 2 + packages/s/misc/webpack.config.js | 10 + packages/s/misc/xlsx.mini.min.js | 1 + packages/s/package.json | 53 ++ packages/s/src/index.ts | 5 + packages/s/src/s/Range.ts | 5 + packages/s/src/s/Workbook.ts | 28 + packages/s/src/s/XLSXWrapper.ts | 10 + packages/s/src/s/names/DefinedName.ts | 15 + .../s/src/s/names/DefinedNameCollection.ts | 12 + .../s/names/WorkbookDefinedNameCollection.ts | 67 ++ packages/s/src/s/worksheet/Worksheet.ts | 5 + .../s/src/s/worksheet/WorksheetCollection.ts | 12 + packages/s/src/umd.ts | 4 + packages/s/src/xlsx.d.ts | 804 ++++++++++++++++++ packages/s/test.ts | 23 + packages/s/tsconfig.base.json | 10 + packages/s/tsconfig.json | 10 + packages/s/tsconfig.vscode.json | 13 + packages/s/tsconfig/tsconfig.base.json | 16 + packages/s/tsconfig/tsconfig.cjs.json | 8 + packages/s/tsconfig/tsconfig.esm.json | 10 + packages/s/tsconfig/tsconfig.types.json | 11 + 102 files changed, 2080 insertions(+) create mode 100644 packages/s/.gitignore create mode 100644 packages/s/.npmignore create mode 100644 packages/s/LICENSE create mode 100644 packages/s/Makefile create mode 100644 packages/s/README.md create mode 100644 packages/s/dist/S.js create mode 100644 packages/s/dist/cjs/index.js create mode 100644 packages/s/dist/cjs/index.js.map create mode 100644 packages/s/dist/cjs/s/Range.js create mode 100644 packages/s/dist/cjs/s/Range.js.map create mode 100644 packages/s/dist/cjs/s/Workbook.js create mode 100644 packages/s/dist/cjs/s/Workbook.js.map create mode 100644 packages/s/dist/cjs/s/XLSXWrapper.js create mode 100644 packages/s/dist/cjs/s/XLSXWrapper.js.map create mode 100644 packages/s/dist/cjs/s/names/DefinedName.js create mode 100644 packages/s/dist/cjs/s/names/DefinedName.js.map create mode 100644 packages/s/dist/cjs/s/names/DefinedNameCollection.js create mode 100644 packages/s/dist/cjs/s/names/DefinedNameCollection.js.map create mode 100644 packages/s/dist/cjs/s/names/WorkbookDefinedNameCollection.js create mode 100644 packages/s/dist/cjs/s/names/WorkbookDefinedNameCollection.js.map create mode 100644 packages/s/dist/cjs/s/worksheet/WorksheetCollection.js create mode 100644 packages/s/dist/cjs/s/worksheet/WorksheetCollection.js.map create mode 100644 packages/s/dist/cjs/umd.js create mode 100644 packages/s/dist/cjs/umd.js.map create mode 100644 packages/s/dist/esm/index.js create mode 100644 packages/s/dist/esm/index.js.map create mode 100644 packages/s/dist/esm/s/Range.js create mode 100644 packages/s/dist/esm/s/Range.js.map create mode 100644 packages/s/dist/esm/s/Workbook.js create mode 100644 packages/s/dist/esm/s/Workbook.js.map create mode 100644 packages/s/dist/esm/s/XLSXWrapper.js create mode 100644 packages/s/dist/esm/s/XLSXWrapper.js.map create mode 100644 packages/s/dist/esm/s/names/DefinedName.js create mode 100644 packages/s/dist/esm/s/names/DefinedName.js.map create mode 100644 packages/s/dist/esm/s/names/DefinedNameCollection.js create mode 100644 packages/s/dist/esm/s/names/DefinedNameCollection.js.map create mode 100644 packages/s/dist/esm/s/names/WorkbookDefinedNameCollection.js create mode 100644 packages/s/dist/esm/s/names/WorkbookDefinedNameCollection.js.map create mode 100644 packages/s/dist/esm/s/worksheet/WorksheetCollection.js create mode 100644 packages/s/dist/esm/s/worksheet/WorksheetCollection.js.map create mode 100644 packages/s/dist/esm/umd.js create mode 100644 packages/s/dist/esm/umd.js.map create mode 100644 packages/s/dist/mjs/index.js.map create mode 100644 packages/s/dist/mjs/index.mjs create mode 100644 packages/s/dist/mjs/s/Range.js.map create mode 100644 packages/s/dist/mjs/s/Range.mjs create mode 100644 packages/s/dist/mjs/s/Workbook.js.map create mode 100644 packages/s/dist/mjs/s/Workbook.mjs create mode 100644 packages/s/dist/mjs/s/XLSXWrapper.js.map create mode 100644 packages/s/dist/mjs/s/XLSXWrapper.mjs create mode 100644 packages/s/dist/mjs/s/names/DefinedName.js.map create mode 100644 packages/s/dist/mjs/s/names/DefinedName.mjs create mode 100644 packages/s/dist/mjs/s/names/DefinedNameCollection.js.map create mode 100644 packages/s/dist/mjs/s/names/DefinedNameCollection.mjs create mode 100644 packages/s/dist/mjs/s/names/WorkbookDefinedNameCollection.js.map create mode 100644 packages/s/dist/mjs/s/names/WorkbookDefinedNameCollection.mjs create mode 100644 packages/s/dist/mjs/s/worksheet/WorksheetCollection.js.map create mode 100644 packages/s/dist/mjs/s/worksheet/WorksheetCollection.mjs create mode 100644 packages/s/dist/mjs/umd.js.map create mode 100644 packages/s/dist/mjs/umd.mjs create mode 100644 packages/s/dist/typings/index.d.ts create mode 100644 packages/s/dist/typings/s/Range.d.ts create mode 100644 packages/s/dist/typings/s/Workbook.d.ts create mode 100644 packages/s/dist/typings/s/XLSXWrapper.d.ts create mode 100644 packages/s/dist/typings/s/names/DefinedName.d.ts create mode 100644 packages/s/dist/typings/s/names/DefinedNameCollection.d.ts create mode 100644 packages/s/dist/typings/s/names/WorkbookDefinedNameCollection.d.ts create mode 100644 packages/s/dist/typings/s/worksheet/WorksheetCollection.d.ts create mode 100644 packages/s/dist/typings/umd.d.ts create mode 100644 packages/s/esm.mjs create mode 100644 packages/s/index.js create mode 100644 packages/s/misc/.gitignore create mode 100644 packages/s/misc/import_test.mjs create mode 100755 packages/s/misc/make_mjs.sh create mode 100644 packages/s/misc/parcel.js create mode 100644 packages/s/misc/puppetmjs.js create mode 100644 packages/s/misc/puppetpcl.js create mode 100644 packages/s/misc/puppetsta.js create mode 100644 packages/s/misc/require_test.njs create mode 100644 packages/s/misc/standalone.js create mode 100644 packages/s/misc/webpack.config.js create mode 120000 packages/s/misc/xlsx.mini.min.js create mode 100644 packages/s/package.json create mode 100644 packages/s/src/index.ts create mode 100644 packages/s/src/s/Range.ts create mode 100644 packages/s/src/s/Workbook.ts create mode 100644 packages/s/src/s/XLSXWrapper.ts create mode 100644 packages/s/src/s/names/DefinedName.ts create mode 100644 packages/s/src/s/names/DefinedNameCollection.ts create mode 100644 packages/s/src/s/names/WorkbookDefinedNameCollection.ts create mode 100644 packages/s/src/s/worksheet/Worksheet.ts create mode 100644 packages/s/src/s/worksheet/WorksheetCollection.ts create mode 100644 packages/s/src/umd.ts create mode 100644 packages/s/src/xlsx.d.ts create mode 100644 packages/s/test.ts create mode 100644 packages/s/tsconfig.base.json create mode 100644 packages/s/tsconfig.json create mode 100644 packages/s/tsconfig.vscode.json create mode 100644 packages/s/tsconfig/tsconfig.base.json create mode 100644 packages/s/tsconfig/tsconfig.cjs.json create mode 100644 packages/s/tsconfig/tsconfig.esm.json create mode 100644 packages/s/tsconfig/tsconfig.types.json diff --git a/packages/s/.gitignore b/packages/s/.gitignore new file mode 100644 index 0000000..16d3c4d --- /dev/null +++ b/packages/s/.gitignore @@ -0,0 +1 @@ +.cache diff --git a/packages/s/.npmignore b/packages/s/.npmignore new file mode 100644 index 0000000..052e8e0 --- /dev/null +++ b/packages/s/.npmignore @@ -0,0 +1,8 @@ +.cache/ +src/ +misc/ +tsconfig/ +*.tgz +test.ts +Makefile +tsconfig.* diff --git a/packages/s/LICENSE b/packages/s/LICENSE new file mode 100644 index 0000000..ef1aae2 --- /dev/null +++ b/packages/s/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright (C) 2019-present SheetJS LLC + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/packages/s/Makefile b/packages/s/Makefile new file mode 100644 index 0000000..3114582 --- /dev/null +++ b/packages/s/Makefile @@ -0,0 +1,23 @@ +.PHONY: all +all: cjs esm mjs S types + +.PHONY: cjs esm types +cjs esm types: %: ./tsconfig/tsconfig.%.json ./src/ + @tsc -p ./tsconfig/tsconfig.$@.json + +.PHONY: mjs +mjs: esm + @./misc/make_mjs.sh + +.PHONY: S +S: cjs + @webpack-cli --config misc/webpack.config.js misc/standalone.js --output-filename S.js --display-modules --display-reasons --profile + +.PHONY: test +test: mjs cjs S + @node misc/require_test.njs + @node --experimental-modules --es-module-specifier-resolution=node misc/import_test.mjs + @cp dist/S.js misc && node misc/puppetsta.js + @concurrently --kill-others -s first "http-server -s -p 7262" "node misc/puppetmjs.js" + @parcel build misc/parcel.html -d misc/parcel -o parcelout.html --public-url "./" && node misc/puppetpcl.js + @mocha -r ts-node/register test.ts \ No newline at end of file diff --git a/packages/s/README.md b/packages/s/README.md new file mode 100644 index 0000000..952e3d7 --- /dev/null +++ b/packages/s/README.md @@ -0,0 +1,12 @@ +# s + +TypeScript/JavaScript wrapper closely aligned with the OfficeJS Excel API in the +MIT-licensed + +The `1.x.x` releases should not be treated as stable. `0.x.x` releases serve to +preserve the original use of the `S` module. + +## License + +Please consult the attached LICENSE file for details. All rights not explicitly +granted by the Apache 2.0 License are reserved by the Original Author. diff --git a/packages/s/dist/S.js b/packages/s/dist/S.js new file mode 100644 index 0000000..073826b --- /dev/null +++ b/packages/s/dist/S.js @@ -0,0 +1,11 @@ +var S=function(t){var e={};function r(o){if(e[o])return e[o].exports;var n=e[o]={i:o,l:!1,exports:{}};return t[o].call(n.exports,n,n.exports,r),n.l=!0,n.exports}return r.m=t,r.c=e,r.d=function(t,e,o){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:o})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(r.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)r.d(o,n,function(e){return t[e]}.bind(null,n));return o},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){var o=r(1);t.exports=o},function(t,e,r){"use strict"; +/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ +let o;function n(){return o}function s(t){o=t}r.r(e),"undefined"!=typeof XLSX&&(o=XLSX); +/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ +class i{constructor(t){this._wb=t}} +/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ +class u{constructor(t){this._name=t}get raw(){return this._name}} +/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ +class a{constructor(t){this._wb=t}get items(){return this._wb.Workbook&&this._wb.Workbook.Names?this._wb.Workbook.Names.filter(t=>{t.Sheet}).map(t=>new u(t)):[]}getName(t){if(this._wb.Workbook&&this._wb.Workbook.Names){const e=this._wb.Workbook.Names;for(let r=0;r{t.Sheet}).length:0}add(t,e,r){try{return this.getName(t)}catch(o){const n={Name:t,Ref:e.toString(),Comment:r||""};return this._wb.Workbook||(this._wb.Workbook={}),this._wb.Workbook.Names||(this._wb.Workbook.Names=[]),this._wb.Workbook.Names.push(n),new u(n)}}} +/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ +class b{constructor(t){this._wb=t||n().utils.book_new(),this._ws=new i(this._wb),this._names=new a(this._wb)}get wb(){return this._wb}get names(){return this._names}get worksheets(){return this._ws}}r.d(e,"Workbook",function(){return b}),r.d(e,"get_XLSX",function(){return n}),r.d(e,"set_XLSX",function(){return s})}]); \ No newline at end of file diff --git a/packages/s/dist/cjs/index.js b/packages/s/dist/cjs/index.js new file mode 100644 index 0000000..9394d8a --- /dev/null +++ b/packages/s/dist/cjs/index.js @@ -0,0 +1,10 @@ +"use strict"; +/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ +/* vim: set ts=2: */ +Object.defineProperty(exports, "__esModule", { value: true }); +var Workbook_1 = require("./s/Workbook"); +exports.Workbook = Workbook_1.Workbook; +var XLSXWrapper_1 = require("./s/XLSXWrapper"); +exports.get_XLSX = XLSXWrapper_1.get_XLSX; +exports.set_XLSX = XLSXWrapper_1.set_XLSX; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/packages/s/dist/cjs/index.js.map b/packages/s/dist/cjs/index.js.map new file mode 100644 index 0000000..5918f3c --- /dev/null +++ b/packages/s/dist/cjs/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"../src/","sources":["index.ts"],"names":[],"mappings":";AAAA,2DAA2D;AAC3D,oBAAoB;;AAEpB,yCAAwC;AAA/B,8BAAA,QAAQ,CAAA;AACjB,+CAAqD;AAA5C,iCAAA,QAAQ,CAAA;AAAE,iCAAA,QAAQ,CAAA"} \ No newline at end of file diff --git a/packages/s/dist/cjs/s/Range.js b/packages/s/dist/cjs/s/Range.js new file mode 100644 index 0000000..9532cf6 --- /dev/null +++ b/packages/s/dist/cjs/s/Range.js @@ -0,0 +1,12 @@ +"use strict"; +/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ +/* vim: set ts=2: */ +Object.defineProperty(exports, "__esModule", { value: true }); +var Range = /** @class */ (function () { + function Range() { + } + return Range; +}()); +exports.Range = Range; +; +//# sourceMappingURL=Range.js.map \ No newline at end of file diff --git a/packages/s/dist/cjs/s/Range.js.map b/packages/s/dist/cjs/s/Range.js.map new file mode 100644 index 0000000..a23b3c2 --- /dev/null +++ b/packages/s/dist/cjs/s/Range.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Range.js","sourceRoot":"../src/","sources":["s/Range.ts"],"names":[],"mappings":";AAAA,2DAA2D;AAC3D,oBAAoB;;AAEpB;IAAA;IACA,CAAC;IAAD,YAAC;AAAD,CAAC,AADD,IACC;AADY,sBAAK;AACjB,CAAC"} \ No newline at end of file diff --git a/packages/s/dist/cjs/s/Workbook.js b/packages/s/dist/cjs/s/Workbook.js new file mode 100644 index 0000000..c0c3a04 --- /dev/null +++ b/packages/s/dist/cjs/s/Workbook.js @@ -0,0 +1,37 @@ +"use strict"; +/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ +/* vim: set ts=2: */ +Object.defineProperty(exports, "__esModule", { value: true }); +/// +var XLSXWrapper_1 = require("./XLSXWrapper"); +var WorksheetCollection_1 = require("./worksheet/WorksheetCollection"); +var WorkbookDefinedNameCollection_1 = require("./names/WorkbookDefinedNameCollection"); +var Workbook = /** @class */ (function () { + function Workbook(wb) { + this._wb = wb || XLSXWrapper_1.get_XLSX().utils.book_new(); + this._ws = new WorksheetCollection_1.WorksheetCollection(this._wb); + this._names = new WorkbookDefinedNameCollection_1.WorkbookDefinedNameCollection(this._wb); + } + ; + Object.defineProperty(Workbook.prototype, "wb", { + get: function () { return this._wb; }, + enumerable: true, + configurable: true + }); + ; + Object.defineProperty(Workbook.prototype, "names", { + get: function () { return this._names; }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Workbook.prototype, "worksheets", { + get: function () { return this._ws; }, + enumerable: true, + configurable: true + }); + ; + return Workbook; +}()); +exports.Workbook = Workbook; +; +//# sourceMappingURL=Workbook.js.map \ No newline at end of file diff --git a/packages/s/dist/cjs/s/Workbook.js.map b/packages/s/dist/cjs/s/Workbook.js.map new file mode 100644 index 0000000..366b7ca --- /dev/null +++ b/packages/s/dist/cjs/s/Workbook.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Workbook.js","sourceRoot":"../src/","sources":["s/Workbook.ts"],"names":[],"mappings":";AAAA,2DAA2D;AAC3D,oBAAoB;;AAEpB,oCAAoC;AAEpC,6CAAyC;AACzC,uEAAsE;AAEtE,uFAAsF;AAEtF;IAKE,kBAAY,EAAkB;QAC5B,IAAI,CAAC,GAAG,GAAG,EAAE,IAAI,sBAAQ,EAAE,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;QAC7C,IAAI,CAAC,GAAG,GAAG,IAAI,yCAAmB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC7C,IAAI,CAAC,MAAM,GAAG,IAAI,6DAA6B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC5D,CAAC;IAAA,CAAC;IAEF,sBAAI,wBAAE;aAAN,cAA0B,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;;;OAAA;IAAA,CAAC;IAE7C,sBAAI,2BAAK;aAAT,cAAqC,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;;;OAAA;IAE1D,sBAAI,gCAAU;aAAd,cAAwC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;;;OAAA;IAAA,CAAC;IAE7D,eAAC;AAAD,CAAC,AAjBD,IAiBC;AAjBY,4BAAQ;AAiBpB,CAAC"} \ No newline at end of file diff --git a/packages/s/dist/cjs/s/XLSXWrapper.js b/packages/s/dist/cjs/s/XLSXWrapper.js new file mode 100644 index 0000000..8a3d500 --- /dev/null +++ b/packages/s/dist/cjs/s/XLSXWrapper.js @@ -0,0 +1,15 @@ +"use strict"; +/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ +/* vim: set ts=2: */ +Object.defineProperty(exports, "__esModule", { value: true }); +/// +var _XLSX; +if (typeof XLSX !== "undefined") + _XLSX = XLSX; +function get_XLSX() { return _XLSX; } +exports.get_XLSX = get_XLSX; +; +function set_XLSX(xlsx) { _XLSX = xlsx; } +exports.set_XLSX = set_XLSX; +; +//# sourceMappingURL=XLSXWrapper.js.map \ No newline at end of file diff --git a/packages/s/dist/cjs/s/XLSXWrapper.js.map b/packages/s/dist/cjs/s/XLSXWrapper.js.map new file mode 100644 index 0000000..d94e47e --- /dev/null +++ b/packages/s/dist/cjs/s/XLSXWrapper.js.map @@ -0,0 +1 @@ +{"version":3,"file":"XLSXWrapper.js","sourceRoot":"../src/","sources":["s/XLSXWrapper.ts"],"names":[],"mappings":";AAAA,2DAA2D;AAC3D,oBAAoB;;AAEpB,oCAAoC;AAEpC,IAAI,KAAkB,CAAC;AACvB,IAAG,OAAO,IAAI,KAAK,WAAW;IAAE,KAAK,GAAG,IAAI,CAAC;AAE7C,SAAgB,QAAQ,KAAK,OAAO,KAAK,CAAC,CAAC,CAAC;AAA5C,4BAA4C;AAAA,CAAC;AAC7C,SAAgB,QAAQ,CAAC,IAAiB,IAAI,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC;AAA7D,4BAA6D;AAAA,CAAC"} \ No newline at end of file diff --git a/packages/s/dist/cjs/s/names/DefinedName.js b/packages/s/dist/cjs/s/names/DefinedName.js new file mode 100644 index 0000000..c131b25 --- /dev/null +++ b/packages/s/dist/cjs/s/names/DefinedName.js @@ -0,0 +1,21 @@ +"use strict"; +/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ +/* vim: set ts=2: */ +Object.defineProperty(exports, "__esModule", { value: true }); +/// +var DefinedName = /** @class */ (function () { + function DefinedName(name) { + this._name = name; + } + ; + Object.defineProperty(DefinedName.prototype, "raw", { + get: function () { return this._name; }, + enumerable: true, + configurable: true + }); + ; + return DefinedName; +}()); +exports.DefinedName = DefinedName; +; +//# sourceMappingURL=DefinedName.js.map \ No newline at end of file diff --git a/packages/s/dist/cjs/s/names/DefinedName.js.map b/packages/s/dist/cjs/s/names/DefinedName.js.map new file mode 100644 index 0000000..8af5531 --- /dev/null +++ b/packages/s/dist/cjs/s/names/DefinedName.js.map @@ -0,0 +1 @@ +{"version":3,"file":"DefinedName.js","sourceRoot":"../src/","sources":["s/names/DefinedName.ts"],"names":[],"mappings":";AAAA,2DAA2D;AAC3D,oBAAoB;;AAEpB,uCAAuC;AAEvC;IAGE,qBAAY,IAAsB;QAChC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IAAA,CAAC;IAEF,sBAAI,4BAAG;aAAP,cAA8B,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;;;OAAA;IAAA,CAAC;IAErD,kBAAC;AAAD,CAAC,AATD,IASC;AATY,kCAAW;AASvB,CAAC"} \ No newline at end of file diff --git a/packages/s/dist/cjs/s/names/DefinedNameCollection.js b/packages/s/dist/cjs/s/names/DefinedNameCollection.js new file mode 100644 index 0000000..7b00b34 --- /dev/null +++ b/packages/s/dist/cjs/s/names/DefinedNameCollection.js @@ -0,0 +1,6 @@ +"use strict"; +/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ +/* vim: set ts=2: */ +Object.defineProperty(exports, "__esModule", { value: true }); +; +//# sourceMappingURL=DefinedNameCollection.js.map \ No newline at end of file diff --git a/packages/s/dist/cjs/s/names/DefinedNameCollection.js.map b/packages/s/dist/cjs/s/names/DefinedNameCollection.js.map new file mode 100644 index 0000000..f861d24 --- /dev/null +++ b/packages/s/dist/cjs/s/names/DefinedNameCollection.js.map @@ -0,0 +1 @@ +{"version":3,"file":"DefinedNameCollection.js","sourceRoot":"../src/","sources":["s/names/DefinedNameCollection.ts"],"names":[],"mappings":";AAAA,2DAA2D;AAC3D,oBAAoB;;AAUnB,CAAC"} \ No newline at end of file diff --git a/packages/s/dist/cjs/s/names/WorkbookDefinedNameCollection.js b/packages/s/dist/cjs/s/names/WorkbookDefinedNameCollection.js new file mode 100644 index 0000000..abef645 --- /dev/null +++ b/packages/s/dist/cjs/s/names/WorkbookDefinedNameCollection.js @@ -0,0 +1,81 @@ +"use strict"; +/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ +/* vim: set ts=2: */ +Object.defineProperty(exports, "__esModule", { value: true }); +var DefinedName_1 = require("./DefinedName"); +//import { Range } from "../Range"; +var WorkbookDefinedNameCollection = /** @class */ (function () { + function WorkbookDefinedNameCollection(wb) { + this._wb = wb; + } + ; + Object.defineProperty(WorkbookDefinedNameCollection.prototype, "items", { + /** + * Get read-only array of global defined names + */ + get: function () { + if (!this._wb.Workbook) + return []; + if (!this._wb.Workbook.Names) + return []; + return this._wb.Workbook.Names.filter(function (name) { name.Sheet == null; }).map(function (name) { return new DefinedName_1.DefinedName(name); }); + }, + enumerable: true, + configurable: true + }); + ; + /** + * Get defined name object + */ + WorkbookDefinedNameCollection.prototype.getName = function (name) { + if (this._wb.Workbook && this._wb.Workbook.Names) { + var names = this._wb.Workbook.Names; + for (var i = 0; i < names.length; ++i) { + if (names[i].Name.toLowerCase() != name.toLowerCase()) + continue; + if (names[i].Sheet != null) + continue; + return new DefinedName_1.DefinedName(names[i]); + } + } + throw new Error("Cannot find defined name |" + name + "|"); + }; + Object.defineProperty(WorkbookDefinedNameCollection.prototype, "count", { + /** + * Number of global defined names + */ + get: function () { + if (!this._wb.Workbook) + return 0; + if (!this._wb.Workbook.Names) + return 0; + return this._wb.Workbook.Names.filter(function (name) { typeof name.Sheet == "undefined"; }).length; + }, + enumerable: true, + configurable: true + }); + /** + * Add or update defined name + * @param name String name + * @param ref Range object or string range/formula + * @param comment Optional comment + */ + WorkbookDefinedNameCollection.prototype.add = function (name, ref /*TODO: | Range */, comment) { + try { + return this.getName(name); + } + catch (e) { + var nm = { Name: name, Ref: ref.toString(), Comment: comment || "" }; + if (!this._wb.Workbook) + this._wb.Workbook = {}; + if (!this._wb.Workbook.Names) + this._wb.Workbook.Names = []; + this._wb.Workbook.Names.push(nm); + return new DefinedName_1.DefinedName(nm); + } + }; + return WorkbookDefinedNameCollection; +}()); +exports.WorkbookDefinedNameCollection = WorkbookDefinedNameCollection; +; +//# sourceMappingURL=WorkbookDefinedNameCollection.js.map \ No newline at end of file diff --git a/packages/s/dist/cjs/s/names/WorkbookDefinedNameCollection.js.map b/packages/s/dist/cjs/s/names/WorkbookDefinedNameCollection.js.map new file mode 100644 index 0000000..3a25ad9 --- /dev/null +++ b/packages/s/dist/cjs/s/names/WorkbookDefinedNameCollection.js.map @@ -0,0 +1 @@ +{"version":3,"file":"WorkbookDefinedNameCollection.js","sourceRoot":"../src/","sources":["s/names/WorkbookDefinedNameCollection.ts"],"names":[],"mappings":";AAAA,2DAA2D;AAC3D,oBAAoB;;AAKpB,6CAA4C;AAC5C,mCAAmC;AAEnC;IAGE,uCAAY,EAAiB;QAC3B,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC;IAChB,CAAC;IAAA,CAAC;IAKF,sBAAI,gDAAK;QAHT;;WAEG;aACH;YACE,IAAG,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ;gBAAE,OAAO,EAAE,CAAC;YACjC,IAAG,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK;gBAAE,OAAO,EAAE,CAAC;YACvC,OAAO,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,UAAC,IAAI,IAAM,IAAI,CAAC,KAAK,IAAI,IAAI,CAAA,CAAA,CAAC,CAAC,CAAC,GAAG,CAAC,UAAC,IAAI,IAAK,OAAA,IAAI,yBAAW,CAAC,IAAI,CAAC,EAArB,CAAqB,CAAC,CAAC;QAC7G,CAAC;;;OAAA;IAAA,CAAC;IAEF;;OAEG;IACH,+CAAO,GAAP,UAAQ,IAAY;QAClB,IAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,IAAI,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,EAAE;YAC/C,IAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC;YACtC,KAAI,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE;gBACpC,IAAG,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,IAAI,CAAC,WAAW,EAAE;oBAAE,SAAS;gBAC/D,IAAG,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,IAAI;oBAAE,SAAS;gBACpC,OAAO,IAAI,yBAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;aAClC;SACF;QACD,MAAM,IAAI,KAAK,CAAC,+BAA6B,IAAI,MAAG,CAAC,CAAC;IACxD,CAAC;IAKD,sBAAI,gDAAK;QAHT;;WAEG;aACH;YACE,IAAG,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ;gBAAE,OAAO,CAAC,CAAC;YAChC,IAAG,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK;gBAAE,OAAO,CAAC,CAAC;YACtC,OAAO,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,UAAC,IAAI,IAAM,OAAO,IAAI,CAAC,KAAK,IAAI,WAAW,CAAA,CAAA,CAAC,CAAC,CAAC,MAAM,CAAC;QAC7F,CAAC;;;OAAA;IAED;;;;;OAKG;IACH,2CAAG,GAAH,UAAI,IAAY,EAAE,GAAW,CAAC,kBAAkB,EAAE,OAAgB;QAChE,IAAI;YACF,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;SAC3B;QAAC,OAAM,CAAC,EAAE;YACT,IAAM,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,OAAO,IAAI,EAAE,EAAE,CAAC;YACvE,IAAG,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ;gBAAE,IAAI,CAAC,GAAG,CAAC,QAAQ,GAAG,EAAE,CAAC;YAC9C,IAAG,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK;gBAAE,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,GAAG,EAAE,CAAC;YAC1D,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACjC,OAAO,IAAI,yBAAW,CAAC,EAAE,CAAC,CAAC;SAC5B;IACH,CAAC;IACH,oCAAC;AAAD,CAAC,AAzDD,IAyDC;AAzDY,sEAA6B;AAyDzC,CAAC"} \ No newline at end of file diff --git a/packages/s/dist/cjs/s/worksheet/WorksheetCollection.js b/packages/s/dist/cjs/s/worksheet/WorksheetCollection.js new file mode 100644 index 0000000..4f8a82a --- /dev/null +++ b/packages/s/dist/cjs/s/worksheet/WorksheetCollection.js @@ -0,0 +1,15 @@ +"use strict"; +/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ +/* vim: set ts=2: */ +Object.defineProperty(exports, "__esModule", { value: true }); +/// +var WorksheetCollection = /** @class */ (function () { + function WorksheetCollection(wb) { + this._wb = wb; + } + ; + return WorksheetCollection; +}()); +exports.WorksheetCollection = WorksheetCollection; +; +//# sourceMappingURL=WorksheetCollection.js.map \ No newline at end of file diff --git a/packages/s/dist/cjs/s/worksheet/WorksheetCollection.js.map b/packages/s/dist/cjs/s/worksheet/WorksheetCollection.js.map new file mode 100644 index 0000000..ef6507c --- /dev/null +++ b/packages/s/dist/cjs/s/worksheet/WorksheetCollection.js.map @@ -0,0 +1 @@ +{"version":3,"file":"WorksheetCollection.js","sourceRoot":"../src/","sources":["s/worksheet/WorksheetCollection.ts"],"names":[],"mappings":";AAAA,2DAA2D;AAC3D,oBAAoB;;AAEpB,uCAAuC;AAEvC;IAGE,6BAAY,EAAiB;QAC3B,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC;IAChB,CAAC;IAAA,CAAC;IACJ,0BAAC;AAAD,CAAC,AAND,IAMC;AANY,kDAAmB;AAM/B,CAAC"} \ No newline at end of file diff --git a/packages/s/dist/cjs/umd.js b/packages/s/dist/cjs/umd.js new file mode 100644 index 0000000..ce24f61 --- /dev/null +++ b/packages/s/dist/cjs/umd.js @@ -0,0 +1,9 @@ +"use strict"; +/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ +/* vim: set ts=2: */ +function __export(m) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; +} +Object.defineProperty(exports, "__esModule", { value: true }); +__export(require("./index")); +//# sourceMappingURL=umd.js.map \ No newline at end of file diff --git a/packages/s/dist/cjs/umd.js.map b/packages/s/dist/cjs/umd.js.map new file mode 100644 index 0000000..d15eb82 --- /dev/null +++ b/packages/s/dist/cjs/umd.js.map @@ -0,0 +1 @@ +{"version":3,"file":"umd.js","sourceRoot":"../src/","sources":["umd.ts"],"names":[],"mappings":";AAAA,2DAA2D;AAC3D,oBAAoB;;;;;AAEpB,6BAAwB"} \ No newline at end of file diff --git a/packages/s/dist/esm/index.js b/packages/s/dist/esm/index.js new file mode 100644 index 0000000..6ab2484 --- /dev/null +++ b/packages/s/dist/esm/index.js @@ -0,0 +1,5 @@ +/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ +/* vim: set ts=2: */ +export { Workbook } from "./s/Workbook"; +export { get_XLSX, set_XLSX } from "./s/XLSXWrapper"; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/packages/s/dist/esm/index.js.map b/packages/s/dist/esm/index.js.map new file mode 100644 index 0000000..6cd4817 --- /dev/null +++ b/packages/s/dist/esm/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"../src/","sources":["index.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,oBAAoB;AAEpB,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC"} \ No newline at end of file diff --git a/packages/s/dist/esm/s/Range.js b/packages/s/dist/esm/s/Range.js new file mode 100644 index 0000000..4b5ae66 --- /dev/null +++ b/packages/s/dist/esm/s/Range.js @@ -0,0 +1,6 @@ +/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ +/* vim: set ts=2: */ +export class Range { +} +; +//# sourceMappingURL=Range.js.map \ No newline at end of file diff --git a/packages/s/dist/esm/s/Range.js.map b/packages/s/dist/esm/s/Range.js.map new file mode 100644 index 0000000..95d5fb8 --- /dev/null +++ b/packages/s/dist/esm/s/Range.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Range.js","sourceRoot":"../src/","sources":["s/Range.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,oBAAoB;AAEpB,MAAM,OAAO,KAAK;CACjB;AAAA,CAAC"} \ No newline at end of file diff --git a/packages/s/dist/esm/s/Workbook.js b/packages/s/dist/esm/s/Workbook.js new file mode 100644 index 0000000..3532f0d --- /dev/null +++ b/packages/s/dist/esm/s/Workbook.js @@ -0,0 +1,21 @@ +/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ +/* vim: set ts=2: */ +/// +import { get_XLSX } from "./XLSXWrapper"; +import { WorksheetCollection } from "./worksheet/WorksheetCollection"; +import { WorkbookDefinedNameCollection } from "./names/WorkbookDefinedNameCollection"; +export class Workbook { + constructor(wb) { + this._wb = wb || get_XLSX().utils.book_new(); + this._ws = new WorksheetCollection(this._wb); + this._names = new WorkbookDefinedNameCollection(this._wb); + } + ; + get wb() { return this._wb; } + ; + get names() { return this._names; } + get worksheets() { return this._ws; } + ; +} +; +//# sourceMappingURL=Workbook.js.map \ No newline at end of file diff --git a/packages/s/dist/esm/s/Workbook.js.map b/packages/s/dist/esm/s/Workbook.js.map new file mode 100644 index 0000000..4f9eacc --- /dev/null +++ b/packages/s/dist/esm/s/Workbook.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Workbook.js","sourceRoot":"../src/","sources":["s/Workbook.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,oBAAoB;AAEpB,oCAAoC;AAEpC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAEtE,OAAO,EAAE,6BAA6B,EAAE,MAAM,uCAAuC,CAAC;AAEtF,MAAM,OAAO,QAAQ;IAKnB,YAAY,EAAkB;QAC5B,IAAI,CAAC,GAAG,GAAG,EAAE,IAAI,QAAQ,EAAE,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;QAC7C,IAAI,CAAC,GAAG,GAAG,IAAI,mBAAmB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC7C,IAAI,CAAC,MAAM,GAAG,IAAI,6BAA6B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC5D,CAAC;IAAA,CAAC;IAEF,IAAI,EAAE,KAAoB,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAAA,CAAC;IAE7C,IAAI,KAAK,KAA4B,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IAE1D,IAAI,UAAU,KAA0B,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAAA,CAAC;CAE5D;AAAA,CAAC"} \ No newline at end of file diff --git a/packages/s/dist/esm/s/XLSXWrapper.js b/packages/s/dist/esm/s/XLSXWrapper.js new file mode 100644 index 0000000..7d4affb --- /dev/null +++ b/packages/s/dist/esm/s/XLSXWrapper.js @@ -0,0 +1,11 @@ +/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ +/* vim: set ts=2: */ +/// +let _XLSX; +if (typeof XLSX !== "undefined") + _XLSX = XLSX; +export function get_XLSX() { return _XLSX; } +; +export function set_XLSX(xlsx) { _XLSX = xlsx; } +; +//# sourceMappingURL=XLSXWrapper.js.map \ No newline at end of file diff --git a/packages/s/dist/esm/s/XLSXWrapper.js.map b/packages/s/dist/esm/s/XLSXWrapper.js.map new file mode 100644 index 0000000..fee21e1 --- /dev/null +++ b/packages/s/dist/esm/s/XLSXWrapper.js.map @@ -0,0 +1 @@ +{"version":3,"file":"XLSXWrapper.js","sourceRoot":"../src/","sources":["s/XLSXWrapper.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,oBAAoB;AAEpB,oCAAoC;AAEpC,IAAI,KAAkB,CAAC;AACvB,IAAG,OAAO,IAAI,KAAK,WAAW;IAAE,KAAK,GAAG,IAAI,CAAC;AAE7C,MAAM,UAAU,QAAQ,KAAK,OAAO,KAAK,CAAC,CAAC,CAAC;AAAA,CAAC;AAC7C,MAAM,UAAU,QAAQ,CAAC,IAAiB,IAAI,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC;AAAA,CAAC"} \ No newline at end of file diff --git a/packages/s/dist/esm/s/names/DefinedName.js b/packages/s/dist/esm/s/names/DefinedName.js new file mode 100644 index 0000000..4b2bf65 --- /dev/null +++ b/packages/s/dist/esm/s/names/DefinedName.js @@ -0,0 +1,13 @@ +/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ +/* vim: set ts=2: */ +/// +export class DefinedName { + constructor(name) { + this._name = name; + } + ; + get raw() { return this._name; } + ; +} +; +//# sourceMappingURL=DefinedName.js.map \ No newline at end of file diff --git a/packages/s/dist/esm/s/names/DefinedName.js.map b/packages/s/dist/esm/s/names/DefinedName.js.map new file mode 100644 index 0000000..f4e38c9 --- /dev/null +++ b/packages/s/dist/esm/s/names/DefinedName.js.map @@ -0,0 +1 @@ +{"version":3,"file":"DefinedName.js","sourceRoot":"../src/","sources":["s/names/DefinedName.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,oBAAoB;AAEpB,uCAAuC;AAEvC,MAAM,OAAO,WAAW;IAGtB,YAAY,IAAsB;QAChC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IAAA,CAAC;IAEF,IAAI,GAAG,KAAuB,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAAA,CAAC;CAEpD;AAAA,CAAC"} \ No newline at end of file diff --git a/packages/s/dist/esm/s/names/DefinedNameCollection.js b/packages/s/dist/esm/s/names/DefinedNameCollection.js new file mode 100644 index 0000000..a60efad --- /dev/null +++ b/packages/s/dist/esm/s/names/DefinedNameCollection.js @@ -0,0 +1,4 @@ +/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ +/* vim: set ts=2: */ +; +//# sourceMappingURL=DefinedNameCollection.js.map \ No newline at end of file diff --git a/packages/s/dist/esm/s/names/DefinedNameCollection.js.map b/packages/s/dist/esm/s/names/DefinedNameCollection.js.map new file mode 100644 index 0000000..fb53a64 --- /dev/null +++ b/packages/s/dist/esm/s/names/DefinedNameCollection.js.map @@ -0,0 +1 @@ +{"version":3,"file":"DefinedNameCollection.js","sourceRoot":"../src/","sources":["s/names/DefinedNameCollection.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,oBAAoB;AAUnB,CAAC"} \ No newline at end of file diff --git a/packages/s/dist/esm/s/names/WorkbookDefinedNameCollection.js b/packages/s/dist/esm/s/names/WorkbookDefinedNameCollection.js new file mode 100644 index 0000000..3c1d687 --- /dev/null +++ b/packages/s/dist/esm/s/names/WorkbookDefinedNameCollection.js @@ -0,0 +1,69 @@ +/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ +/* vim: set ts=2: */ +import { DefinedName } from "./DefinedName"; +//import { Range } from "../Range"; +export class WorkbookDefinedNameCollection { + constructor(wb) { + this._wb = wb; + } + ; + /** + * Get read-only array of global defined names + */ + get items() { + if (!this._wb.Workbook) + return []; + if (!this._wb.Workbook.Names) + return []; + return this._wb.Workbook.Names.filter((name) => { name.Sheet == null; }).map((name) => new DefinedName(name)); + } + ; + /** + * Get defined name object + */ + getName(name) { + if (this._wb.Workbook && this._wb.Workbook.Names) { + const names = this._wb.Workbook.Names; + for (let i = 0; i < names.length; ++i) { + if (names[i].Name.toLowerCase() != name.toLowerCase()) + continue; + if (names[i].Sheet != null) + continue; + return new DefinedName(names[i]); + } + } + throw new Error(`Cannot find defined name |${name}|`); + } + /** + * Number of global defined names + */ + get count() { + if (!this._wb.Workbook) + return 0; + if (!this._wb.Workbook.Names) + return 0; + return this._wb.Workbook.Names.filter((name) => { typeof name.Sheet == "undefined"; }).length; + } + /** + * Add or update defined name + * @param name String name + * @param ref Range object or string range/formula + * @param comment Optional comment + */ + add(name, ref /*TODO: | Range */, comment) { + try { + return this.getName(name); + } + catch (e) { + const nm = { Name: name, Ref: ref.toString(), Comment: comment || "" }; + if (!this._wb.Workbook) + this._wb.Workbook = {}; + if (!this._wb.Workbook.Names) + this._wb.Workbook.Names = []; + this._wb.Workbook.Names.push(nm); + return new DefinedName(nm); + } + } +} +; +//# sourceMappingURL=WorkbookDefinedNameCollection.js.map \ No newline at end of file diff --git a/packages/s/dist/esm/s/names/WorkbookDefinedNameCollection.js.map b/packages/s/dist/esm/s/names/WorkbookDefinedNameCollection.js.map new file mode 100644 index 0000000..06aea38 --- /dev/null +++ b/packages/s/dist/esm/s/names/WorkbookDefinedNameCollection.js.map @@ -0,0 +1 @@ +{"version":3,"file":"WorkbookDefinedNameCollection.js","sourceRoot":"../src/","sources":["s/names/WorkbookDefinedNameCollection.ts"],"names":[],"mappings":"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"} \ No newline at end of file diff --git a/packages/s/dist/esm/s/worksheet/WorksheetCollection.js b/packages/s/dist/esm/s/worksheet/WorksheetCollection.js new file mode 100644 index 0000000..f2db43f --- /dev/null +++ b/packages/s/dist/esm/s/worksheet/WorksheetCollection.js @@ -0,0 +1,11 @@ +/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ +/* vim: set ts=2: */ +/// +export class WorksheetCollection { + constructor(wb) { + this._wb = wb; + } + ; +} +; +//# sourceMappingURL=WorksheetCollection.js.map \ No newline at end of file diff --git a/packages/s/dist/esm/s/worksheet/WorksheetCollection.js.map b/packages/s/dist/esm/s/worksheet/WorksheetCollection.js.map new file mode 100644 index 0000000..e209802 --- /dev/null +++ b/packages/s/dist/esm/s/worksheet/WorksheetCollection.js.map @@ -0,0 +1 @@ +{"version":3,"file":"WorksheetCollection.js","sourceRoot":"../src/","sources":["s/worksheet/WorksheetCollection.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,oBAAoB;AAEpB,uCAAuC;AAEvC,MAAM,OAAO,mBAAmB;IAG9B,YAAY,EAAiB;QAC3B,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC;IAChB,CAAC;IAAA,CAAC;CACH;AAAA,CAAC"} \ No newline at end of file diff --git a/packages/s/dist/esm/umd.js b/packages/s/dist/esm/umd.js new file mode 100644 index 0000000..ba5a141 --- /dev/null +++ b/packages/s/dist/esm/umd.js @@ -0,0 +1,4 @@ +/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ +/* vim: set ts=2: */ +export * from "./index"; +//# sourceMappingURL=umd.js.map \ No newline at end of file diff --git a/packages/s/dist/esm/umd.js.map b/packages/s/dist/esm/umd.js.map new file mode 100644 index 0000000..6f6908b --- /dev/null +++ b/packages/s/dist/esm/umd.js.map @@ -0,0 +1 @@ +{"version":3,"file":"umd.js","sourceRoot":"../src/","sources":["umd.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,oBAAoB;AAEpB,cAAc,SAAS,CAAC"} \ No newline at end of file diff --git a/packages/s/dist/mjs/index.js.map b/packages/s/dist/mjs/index.js.map new file mode 100644 index 0000000..6cd4817 --- /dev/null +++ b/packages/s/dist/mjs/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"../src/","sources":["index.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,oBAAoB;AAEpB,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC"} \ No newline at end of file diff --git a/packages/s/dist/mjs/index.mjs b/packages/s/dist/mjs/index.mjs new file mode 100644 index 0000000..0588fd4 --- /dev/null +++ b/packages/s/dist/mjs/index.mjs @@ -0,0 +1,5 @@ +/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ +/* vim: set ts=2: */ +export { Workbook } from "./s/Workbook.mjs"; +export { get_XLSX, set_XLSX } from "./s/XLSXWrapper.mjs"; +//# sourceMappingURL=index.js.map diff --git a/packages/s/dist/mjs/s/Range.js.map b/packages/s/dist/mjs/s/Range.js.map new file mode 100644 index 0000000..95d5fb8 --- /dev/null +++ b/packages/s/dist/mjs/s/Range.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Range.js","sourceRoot":"../src/","sources":["s/Range.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,oBAAoB;AAEpB,MAAM,OAAO,KAAK;CACjB;AAAA,CAAC"} \ No newline at end of file diff --git a/packages/s/dist/mjs/s/Range.mjs b/packages/s/dist/mjs/s/Range.mjs new file mode 100644 index 0000000..e234a4c --- /dev/null +++ b/packages/s/dist/mjs/s/Range.mjs @@ -0,0 +1,6 @@ +/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ +/* vim: set ts=2: */ +export class Range { +} +; +//# sourceMappingURL=Range.js.map diff --git a/packages/s/dist/mjs/s/Workbook.js.map b/packages/s/dist/mjs/s/Workbook.js.map new file mode 100644 index 0000000..4f9eacc --- /dev/null +++ b/packages/s/dist/mjs/s/Workbook.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Workbook.js","sourceRoot":"../src/","sources":["s/Workbook.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,oBAAoB;AAEpB,oCAAoC;AAEpC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAEtE,OAAO,EAAE,6BAA6B,EAAE,MAAM,uCAAuC,CAAC;AAEtF,MAAM,OAAO,QAAQ;IAKnB,YAAY,EAAkB;QAC5B,IAAI,CAAC,GAAG,GAAG,EAAE,IAAI,QAAQ,EAAE,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;QAC7C,IAAI,CAAC,GAAG,GAAG,IAAI,mBAAmB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC7C,IAAI,CAAC,MAAM,GAAG,IAAI,6BAA6B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC5D,CAAC;IAAA,CAAC;IAEF,IAAI,EAAE,KAAoB,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAAA,CAAC;IAE7C,IAAI,KAAK,KAA4B,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IAE1D,IAAI,UAAU,KAA0B,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAAA,CAAC;CAE5D;AAAA,CAAC"} \ No newline at end of file diff --git a/packages/s/dist/mjs/s/Workbook.mjs b/packages/s/dist/mjs/s/Workbook.mjs new file mode 100644 index 0000000..c09438f --- /dev/null +++ b/packages/s/dist/mjs/s/Workbook.mjs @@ -0,0 +1,21 @@ +/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ +/* vim: set ts=2: */ +/// +import { get_XLSX } from "./XLSXWrapper.mjs"; +import { WorksheetCollection } from "./worksheet/WorksheetCollection.mjs"; +import { WorkbookDefinedNameCollection } from "./names/WorkbookDefinedNameCollection.mjs"; +export class Workbook { + constructor(wb) { + this._wb = wb || get_XLSX().utils.book_new(); + this._ws = new WorksheetCollection(this._wb); + this._names = new WorkbookDefinedNameCollection(this._wb); + } + ; + get wb() { return this._wb; } + ; + get names() { return this._names; } + get worksheets() { return this._ws; } + ; +} +; +//# sourceMappingURL=Workbook.js.map diff --git a/packages/s/dist/mjs/s/XLSXWrapper.js.map b/packages/s/dist/mjs/s/XLSXWrapper.js.map new file mode 100644 index 0000000..fee21e1 --- /dev/null +++ b/packages/s/dist/mjs/s/XLSXWrapper.js.map @@ -0,0 +1 @@ +{"version":3,"file":"XLSXWrapper.js","sourceRoot":"../src/","sources":["s/XLSXWrapper.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,oBAAoB;AAEpB,oCAAoC;AAEpC,IAAI,KAAkB,CAAC;AACvB,IAAG,OAAO,IAAI,KAAK,WAAW;IAAE,KAAK,GAAG,IAAI,CAAC;AAE7C,MAAM,UAAU,QAAQ,KAAK,OAAO,KAAK,CAAC,CAAC,CAAC;AAAA,CAAC;AAC7C,MAAM,UAAU,QAAQ,CAAC,IAAiB,IAAI,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC;AAAA,CAAC"} \ No newline at end of file diff --git a/packages/s/dist/mjs/s/XLSXWrapper.mjs b/packages/s/dist/mjs/s/XLSXWrapper.mjs new file mode 100644 index 0000000..7431b0d --- /dev/null +++ b/packages/s/dist/mjs/s/XLSXWrapper.mjs @@ -0,0 +1,11 @@ +/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ +/* vim: set ts=2: */ +/// +let _XLSX; +if (typeof XLSX !== "undefined") + _XLSX = XLSX; +export function get_XLSX() { return _XLSX; } +; +export function set_XLSX(xlsx) { _XLSX = xlsx; } +; +//# sourceMappingURL=XLSXWrapper.js.map diff --git a/packages/s/dist/mjs/s/names/DefinedName.js.map b/packages/s/dist/mjs/s/names/DefinedName.js.map new file mode 100644 index 0000000..f4e38c9 --- /dev/null +++ b/packages/s/dist/mjs/s/names/DefinedName.js.map @@ -0,0 +1 @@ +{"version":3,"file":"DefinedName.js","sourceRoot":"../src/","sources":["s/names/DefinedName.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,oBAAoB;AAEpB,uCAAuC;AAEvC,MAAM,OAAO,WAAW;IAGtB,YAAY,IAAsB;QAChC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IAAA,CAAC;IAEF,IAAI,GAAG,KAAuB,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAAA,CAAC;CAEpD;AAAA,CAAC"} \ No newline at end of file diff --git a/packages/s/dist/mjs/s/names/DefinedName.mjs b/packages/s/dist/mjs/s/names/DefinedName.mjs new file mode 100644 index 0000000..1ffc797 --- /dev/null +++ b/packages/s/dist/mjs/s/names/DefinedName.mjs @@ -0,0 +1,13 @@ +/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ +/* vim: set ts=2: */ +/// +export class DefinedName { + constructor(name) { + this._name = name; + } + ; + get raw() { return this._name; } + ; +} +; +//# sourceMappingURL=DefinedName.js.map diff --git a/packages/s/dist/mjs/s/names/DefinedNameCollection.js.map b/packages/s/dist/mjs/s/names/DefinedNameCollection.js.map new file mode 100644 index 0000000..fb53a64 --- /dev/null +++ b/packages/s/dist/mjs/s/names/DefinedNameCollection.js.map @@ -0,0 +1 @@ +{"version":3,"file":"DefinedNameCollection.js","sourceRoot":"../src/","sources":["s/names/DefinedNameCollection.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,oBAAoB;AAUnB,CAAC"} \ No newline at end of file diff --git a/packages/s/dist/mjs/s/names/DefinedNameCollection.mjs b/packages/s/dist/mjs/s/names/DefinedNameCollection.mjs new file mode 100644 index 0000000..4ccf9c3 --- /dev/null +++ b/packages/s/dist/mjs/s/names/DefinedNameCollection.mjs @@ -0,0 +1,4 @@ +/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ +/* vim: set ts=2: */ +; +//# sourceMappingURL=DefinedNameCollection.js.map diff --git a/packages/s/dist/mjs/s/names/WorkbookDefinedNameCollection.js.map b/packages/s/dist/mjs/s/names/WorkbookDefinedNameCollection.js.map new file mode 100644 index 0000000..06aea38 --- /dev/null +++ b/packages/s/dist/mjs/s/names/WorkbookDefinedNameCollection.js.map @@ -0,0 +1 @@ +{"version":3,"file":"WorkbookDefinedNameCollection.js","sourceRoot":"../src/","sources":["s/names/WorkbookDefinedNameCollection.ts"],"names":[],"mappings":"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"} \ No newline at end of file diff --git a/packages/s/dist/mjs/s/names/WorkbookDefinedNameCollection.mjs b/packages/s/dist/mjs/s/names/WorkbookDefinedNameCollection.mjs new file mode 100644 index 0000000..bfef674 --- /dev/null +++ b/packages/s/dist/mjs/s/names/WorkbookDefinedNameCollection.mjs @@ -0,0 +1,69 @@ +/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ +/* vim: set ts=2: */ +import { DefinedName } from "./DefinedName.mjs"; +//import { Range } from "../Range.mjs"; +export class WorkbookDefinedNameCollection { + constructor(wb) { + this._wb = wb; + } + ; + /** + * Get read-only array of global defined names + */ + get items() { + if (!this._wb.Workbook) + return []; + if (!this._wb.Workbook.Names) + return []; + return this._wb.Workbook.Names.filter((name) => { name.Sheet == null; }).map((name) => new DefinedName(name)); + } + ; + /** + * Get defined name object + */ + getName(name) { + if (this._wb.Workbook && this._wb.Workbook.Names) { + const names = this._wb.Workbook.Names; + for (let i = 0; i < names.length; ++i) { + if (names[i].Name.toLowerCase() != name.toLowerCase()) + continue; + if (names[i].Sheet != null) + continue; + return new DefinedName(names[i]); + } + } + throw new Error(`Cannot find defined name |${name}|`); + } + /** + * Number of global defined names + */ + get count() { + if (!this._wb.Workbook) + return 0; + if (!this._wb.Workbook.Names) + return 0; + return this._wb.Workbook.Names.filter((name) => { typeof name.Sheet == "undefined"; }).length; + } + /** + * Add or update defined name + * @param name String name + * @param ref Range object or string range/formula + * @param comment Optional comment + */ + add(name, ref /*TODO: | Range */, comment) { + try { + return this.getName(name); + } + catch (e) { + const nm = { Name: name, Ref: ref.toString(), Comment: comment || "" }; + if (!this._wb.Workbook) + this._wb.Workbook = {}; + if (!this._wb.Workbook.Names) + this._wb.Workbook.Names = []; + this._wb.Workbook.Names.push(nm); + return new DefinedName(nm); + } + } +} +; +//# sourceMappingURL=WorkbookDefinedNameCollection.js.map diff --git a/packages/s/dist/mjs/s/worksheet/WorksheetCollection.js.map b/packages/s/dist/mjs/s/worksheet/WorksheetCollection.js.map new file mode 100644 index 0000000..e209802 --- /dev/null +++ b/packages/s/dist/mjs/s/worksheet/WorksheetCollection.js.map @@ -0,0 +1 @@ +{"version":3,"file":"WorksheetCollection.js","sourceRoot":"../src/","sources":["s/worksheet/WorksheetCollection.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,oBAAoB;AAEpB,uCAAuC;AAEvC,MAAM,OAAO,mBAAmB;IAG9B,YAAY,EAAiB;QAC3B,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC;IAChB,CAAC;IAAA,CAAC;CACH;AAAA,CAAC"} \ No newline at end of file diff --git a/packages/s/dist/mjs/s/worksheet/WorksheetCollection.mjs b/packages/s/dist/mjs/s/worksheet/WorksheetCollection.mjs new file mode 100644 index 0000000..3359a35 --- /dev/null +++ b/packages/s/dist/mjs/s/worksheet/WorksheetCollection.mjs @@ -0,0 +1,11 @@ +/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ +/* vim: set ts=2: */ +/// +export class WorksheetCollection { + constructor(wb) { + this._wb = wb; + } + ; +} +; +//# sourceMappingURL=WorksheetCollection.js.map diff --git a/packages/s/dist/mjs/umd.js.map b/packages/s/dist/mjs/umd.js.map new file mode 100644 index 0000000..6f6908b --- /dev/null +++ b/packages/s/dist/mjs/umd.js.map @@ -0,0 +1 @@ +{"version":3,"file":"umd.js","sourceRoot":"../src/","sources":["umd.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,oBAAoB;AAEpB,cAAc,SAAS,CAAC"} \ No newline at end of file diff --git a/packages/s/dist/mjs/umd.mjs b/packages/s/dist/mjs/umd.mjs new file mode 100644 index 0000000..64808a2 --- /dev/null +++ b/packages/s/dist/mjs/umd.mjs @@ -0,0 +1,4 @@ +/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ +/* vim: set ts=2: */ +export * from "./index.mjs"; +//# sourceMappingURL=umd.js.map diff --git a/packages/s/dist/typings/index.d.ts b/packages/s/dist/typings/index.d.ts new file mode 100644 index 0000000..4b1a2a4 --- /dev/null +++ b/packages/s/dist/typings/index.d.ts @@ -0,0 +1,3 @@ +/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ +export { Workbook } from "./s/Workbook"; +export { get_XLSX, set_XLSX } from "./s/XLSXWrapper"; diff --git a/packages/s/dist/typings/s/Range.d.ts b/packages/s/dist/typings/s/Range.d.ts new file mode 100644 index 0000000..5a0a0f1 --- /dev/null +++ b/packages/s/dist/typings/s/Range.d.ts @@ -0,0 +1,3 @@ +/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ +export declare class Range { +} diff --git a/packages/s/dist/typings/s/Workbook.d.ts b/packages/s/dist/typings/s/Workbook.d.ts new file mode 100644 index 0000000..7d44b6f --- /dev/null +++ b/packages/s/dist/typings/s/Workbook.d.ts @@ -0,0 +1,13 @@ +/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ +/// +import { WorksheetCollection } from "./worksheet/WorksheetCollection"; +import { DefinedNameCollection } from "./names/DefinedNameCollection"; +export declare class Workbook { + private readonly _wb; + private readonly _ws; + private readonly _names; + constructor(wb?: XLSX.WorkBook); + readonly wb: XLSX.WorkBook; + readonly names: DefinedNameCollection; + readonly worksheets: WorksheetCollection; +} diff --git a/packages/s/dist/typings/s/XLSXWrapper.d.ts b/packages/s/dist/typings/s/XLSXWrapper.d.ts new file mode 100644 index 0000000..38543d3 --- /dev/null +++ b/packages/s/dist/typings/s/XLSXWrapper.d.ts @@ -0,0 +1,4 @@ +/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ +/// +export declare function get_XLSX(): typeof XLSX; +export declare function set_XLSX(xlsx: typeof XLSX): void; diff --git a/packages/s/dist/typings/s/names/DefinedName.d.ts b/packages/s/dist/typings/s/names/DefinedName.d.ts new file mode 100644 index 0000000..0006aa9 --- /dev/null +++ b/packages/s/dist/typings/s/names/DefinedName.d.ts @@ -0,0 +1,7 @@ +/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ +/// +export declare class DefinedName { + readonly _name: XLSX.DefinedName; + constructor(name: XLSX.DefinedName); + readonly raw: XLSX.DefinedName; +} diff --git a/packages/s/dist/typings/s/names/DefinedNameCollection.d.ts b/packages/s/dist/typings/s/names/DefinedNameCollection.d.ts new file mode 100644 index 0000000..1856728 --- /dev/null +++ b/packages/s/dist/typings/s/names/DefinedNameCollection.d.ts @@ -0,0 +1,9 @@ +/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ +import { DefinedName } from "./DefinedName"; +import { Range } from "../Range"; +export interface DefinedNameCollection { + readonly items: DefinedName[]; + readonly count: number; + add(name: string, ref: string | Range, comment?: string): DefinedName; + getName(name: string): DefinedName; +} diff --git a/packages/s/dist/typings/s/names/WorkbookDefinedNameCollection.d.ts b/packages/s/dist/typings/s/names/WorkbookDefinedNameCollection.d.ts new file mode 100644 index 0000000..3c87200 --- /dev/null +++ b/packages/s/dist/typings/s/names/WorkbookDefinedNameCollection.d.ts @@ -0,0 +1,27 @@ +/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ +/// +import { DefinedNameCollection } from "./DefinedNameCollection"; +import { DefinedName } from "./DefinedName"; +export declare class WorkbookDefinedNameCollection implements DefinedNameCollection { + private readonly _wb; + constructor(wb: XLSX.WorkBook); + /** + * Get read-only array of global defined names + */ + readonly items: DefinedName[]; + /** + * Get defined name object + */ + getName(name: string): DefinedName; + /** + * Number of global defined names + */ + readonly count: number; + /** + * Add or update defined name + * @param name String name + * @param ref Range object or string range/formula + * @param comment Optional comment + */ + add(name: string, ref: string, comment?: string): DefinedName; +} diff --git a/packages/s/dist/typings/s/worksheet/WorksheetCollection.d.ts b/packages/s/dist/typings/s/worksheet/WorksheetCollection.d.ts new file mode 100644 index 0000000..007102f --- /dev/null +++ b/packages/s/dist/typings/s/worksheet/WorksheetCollection.d.ts @@ -0,0 +1,6 @@ +/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ +/// +export declare class WorksheetCollection { + private readonly _wb; + constructor(wb: XLSX.WorkBook); +} diff --git a/packages/s/dist/typings/umd.d.ts b/packages/s/dist/typings/umd.d.ts new file mode 100644 index 0000000..f045c57 --- /dev/null +++ b/packages/s/dist/typings/umd.d.ts @@ -0,0 +1,2 @@ +/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ +export * from "./index"; diff --git a/packages/s/esm.mjs b/packages/s/esm.mjs new file mode 100644 index 0000000..3ded3b0 --- /dev/null +++ b/packages/s/esm.mjs @@ -0,0 +1,4 @@ +/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ +/* vim: set ts=2: */ + +export * from "./dist/mjs/index.mjs"; \ No newline at end of file diff --git a/packages/s/index.js b/packages/s/index.js new file mode 100644 index 0000000..6841937 --- /dev/null +++ b/packages/s/index.js @@ -0,0 +1,4 @@ +/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ +/* vim: set ts=2: */ + +module.exports = require('./dist/cjs/'); \ No newline at end of file diff --git a/packages/s/misc/.gitignore b/packages/s/misc/.gitignore new file mode 100644 index 0000000..9cba5a3 --- /dev/null +++ b/packages/s/misc/.gitignore @@ -0,0 +1,2 @@ +S.js +parcel/ diff --git a/packages/s/misc/import_test.mjs b/packages/s/misc/import_test.mjs new file mode 100644 index 0000000..40bf0d9 --- /dev/null +++ b/packages/s/misc/import_test.mjs @@ -0,0 +1,15 @@ +/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ +/* vim: set ts=2: */ + +import assert from "assert"; +import * as S from "../esm"; + +/* song and dance for node 12 esm */ +import { createRequire } from 'module'; +const require = createRequire(import.meta.url); +const XLSX = require("../../../"); + +assert(S != null); +S.set_XLSX(XLSX); +assert(S.get_XLSX() == XLSX); +assert(S.get_XLSX().version); \ No newline at end of file diff --git a/packages/s/misc/make_mjs.sh b/packages/s/misc/make_mjs.sh new file mode 100755 index 0000000..8e4e90b --- /dev/null +++ b/packages/s/misc/make_mjs.sh @@ -0,0 +1,8 @@ +#!/bin/bash +rm -rf dist/mjs/ +cp -r dist/esm dist/mjs +find dist/mjs -name '*.js' | while read x; do + <"$x" awk '/(im|ex)port / { gsub(/";/, ".mjs\";"); } 1' > "${x%.js}.mjs" + rm -f "$x" +done + diff --git a/packages/s/misc/parcel.js b/packages/s/misc/parcel.js new file mode 100644 index 0000000..06044ec --- /dev/null +++ b/packages/s/misc/parcel.js @@ -0,0 +1,8 @@ +import * as S from "../esm"; +const XLSX = require("./xlsx.mini.min.js"); +function assert(x) { if(!x) throw "assert failed"; } + +assert(S != null); +S.set_XLSX(XLSX); +assert(S.get_XLSX() == XLSX); +assert(S.get_XLSX().version); \ No newline at end of file diff --git a/packages/s/misc/puppetmjs.js b/packages/s/misc/puppetmjs.js new file mode 100644 index 0000000..c10c6bc --- /dev/null +++ b/packages/s/misc/puppetmjs.js @@ -0,0 +1,15 @@ +const puppeteer = require("puppeteer"); +const path = require("path"); + +const target = "http://localhost:7262/misc/module.html"; +(async () => { + const browser = await puppeteer.launch(); + const page = await browser.newPage(); + await page.waitFor(1000); + console.log("page"); + page.on('console', msg => console.log('PAGE LOG:', msg.text())); + page.on('error', (err) => { console.error(err); process.exit(1); }); + page.on('pageerror', (err) => { console.error(err); process.exit(2); }); + await page.goto(target); + await browser.close(); +})(); \ No newline at end of file diff --git a/packages/s/misc/puppetpcl.js b/packages/s/misc/puppetpcl.js new file mode 100644 index 0000000..cc606f3 --- /dev/null +++ b/packages/s/misc/puppetpcl.js @@ -0,0 +1,14 @@ +const puppeteer = require("puppeteer"); +const path = require("path"); + +const target = `file://${path.resolve(`${__dirname}/parcel/parcelout.html`)}`; +console.log(target); +(async () => { + const browser = await puppeteer.launch(); + const page = await browser.newPage(); + page.on('console', msg => console.log('PAGE LOG:', msg.text())); + page.on('error', (err) => { console.error(err); process.exit(1); }); + page.on('pageerror', (err) => { console.error(err); process.exit(2); }); + await page.goto(target); + await browser.close(); +})(); \ No newline at end of file diff --git a/packages/s/misc/puppetsta.js b/packages/s/misc/puppetsta.js new file mode 100644 index 0000000..7a21257 --- /dev/null +++ b/packages/s/misc/puppetsta.js @@ -0,0 +1,14 @@ +const puppeteer = require("puppeteer"); +const path = require("path"); + +const target = `file://${path.resolve(`${__dirname}/standalone.html`)}`; +console.log(target); +(async () => { + const browser = await puppeteer.launch(); + const page = await browser.newPage(); + page.on('console', msg => console.log('PAGE LOG:', msg.text())); + page.on('error', (err) => { console.error(err); process.exit(1); }); + page.on('pageerror', (err) => { console.error(err); process.exit(2); }); + await page.goto(target); + await browser.close(); +})(); \ No newline at end of file diff --git a/packages/s/misc/require_test.njs b/packages/s/misc/require_test.njs new file mode 100644 index 0000000..d0e0125 --- /dev/null +++ b/packages/s/misc/require_test.njs @@ -0,0 +1,11 @@ +/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ +/* vim: set ts=2: */ + +var assert = require("assert"); +var XLSX = require("../../../"); +var S = require("../"); + +assert(S != null); +S.set_XLSX(XLSX); +assert(S.get_XLSX() == XLSX); +assert(S.get_XLSX().version); \ No newline at end of file diff --git a/packages/s/misc/standalone.js b/packages/s/misc/standalone.js new file mode 100644 index 0000000..86dd81d --- /dev/null +++ b/packages/s/misc/standalone.js @@ -0,0 +1,2 @@ +var S = require("../"); +module.exports = S; \ No newline at end of file diff --git a/packages/s/misc/webpack.config.js b/packages/s/misc/webpack.config.js new file mode 100644 index 0000000..c4b8e0d --- /dev/null +++ b/packages/s/misc/webpack.config.js @@ -0,0 +1,10 @@ +module.exports = { + output: { + libraryTarget: "var", + library: "S" + }, + node: { + process: false, + browser: false + } +} \ No newline at end of file diff --git a/packages/s/misc/xlsx.mini.min.js b/packages/s/misc/xlsx.mini.min.js new file mode 120000 index 0000000..c43fb79 --- /dev/null +++ b/packages/s/misc/xlsx.mini.min.js @@ -0,0 +1 @@ +../../../dist/xlsx.mini.min.js \ No newline at end of file diff --git a/packages/s/package.json b/packages/s/package.json new file mode 100644 index 0000000..2c3fc03 --- /dev/null +++ b/packages/s/package.json @@ -0,0 +1,53 @@ +{ + "name": "s", + "version": "1.0.0", + "author": "sheetjs", + "description": "SheetJS Spreadsheet Helper Library", + "keywords": [ + "excel", + "office", + "spreadsheet" + ], + "bin": {}, + "browser": { + "buffer": false, + "crypto": false, + "stream": false, + "process": false, + "fs": false + }, + "main": "./index.js", + "module": "./dist/esm/index.js", + "types": "./dist/typings/index.d.ts", + "dependencies": {}, + "devDependencies": { + "@types/mocha": "^5.2.7", + "mocha": "^6.2.0", + "ts-node": "^8.3.0" + }, + "repository": { + "type": "git", + "url": "git://github.com/SheetJS/js-xlsx.git" + }, + "scripts": {}, + "config": { + "blanket": { + "pattern": "xlsx.js" + } + }, + "alex": { + "allow": [ + "crash", + "wtf", + "holes" + ] + }, + "homepage": "http://sheetjs.com/opensource", + "bugs": { + "url": "https://github.com/SheetJS/js-xlsx/issues" + }, + "license": "Apache-2.0", + "engines": { + "node": ">=0.8" + } +} diff --git a/packages/s/src/index.ts b/packages/s/src/index.ts new file mode 100644 index 0000000..b83bef2 --- /dev/null +++ b/packages/s/src/index.ts @@ -0,0 +1,5 @@ +/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ +/* vim: set ts=2: */ + +export { Workbook } from "./s/Workbook"; +export { get_XLSX, set_XLSX } from "./s/XLSXWrapper"; \ No newline at end of file diff --git a/packages/s/src/s/Range.ts b/packages/s/src/s/Range.ts new file mode 100644 index 0000000..2fef5e7 --- /dev/null +++ b/packages/s/src/s/Range.ts @@ -0,0 +1,5 @@ +/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ +/* vim: set ts=2: */ + +export class Range { +}; \ No newline at end of file diff --git a/packages/s/src/s/Workbook.ts b/packages/s/src/s/Workbook.ts new file mode 100644 index 0000000..a32cbb3 --- /dev/null +++ b/packages/s/src/s/Workbook.ts @@ -0,0 +1,28 @@ +/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ +/* vim: set ts=2: */ + +/// + +import { get_XLSX } from "./XLSXWrapper"; +import { WorksheetCollection } from "./worksheet/WorksheetCollection"; +import { DefinedNameCollection } from "./names/DefinedNameCollection"; +import { WorkbookDefinedNameCollection } from "./names/WorkbookDefinedNameCollection"; + +export class Workbook { + private readonly _wb: XLSX.WorkBook; + private readonly _ws: WorksheetCollection; + private readonly _names: WorkbookDefinedNameCollection; + + constructor(wb?: XLSX.WorkBook) { + this._wb = wb || get_XLSX().utils.book_new(); + this._ws = new WorksheetCollection(this._wb); + this._names = new WorkbookDefinedNameCollection(this._wb); + }; + + get wb(): XLSX.WorkBook { return this._wb; }; + + get names(): DefinedNameCollection { return this._names; } + + get worksheets(): WorksheetCollection { return this._ws; }; + +}; \ No newline at end of file diff --git a/packages/s/src/s/XLSXWrapper.ts b/packages/s/src/s/XLSXWrapper.ts new file mode 100644 index 0000000..6626cc6 --- /dev/null +++ b/packages/s/src/s/XLSXWrapper.ts @@ -0,0 +1,10 @@ +/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ +/* vim: set ts=2: */ + +/// + +let _XLSX: typeof XLSX; +if(typeof XLSX !== "undefined") _XLSX = XLSX; + +export function get_XLSX() { return _XLSX; }; +export function set_XLSX(xlsx: typeof XLSX) { _XLSX = xlsx; }; \ No newline at end of file diff --git a/packages/s/src/s/names/DefinedName.ts b/packages/s/src/s/names/DefinedName.ts new file mode 100644 index 0000000..7cd76f3 --- /dev/null +++ b/packages/s/src/s/names/DefinedName.ts @@ -0,0 +1,15 @@ +/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ +/* vim: set ts=2: */ + +/// + +export class DefinedName { + readonly _name: XLSX.DefinedName; + + constructor(name: XLSX.DefinedName) { + this._name = name; + }; + + get raw(): XLSX.DefinedName { return this._name; }; + +}; \ No newline at end of file diff --git a/packages/s/src/s/names/DefinedNameCollection.ts b/packages/s/src/s/names/DefinedNameCollection.ts new file mode 100644 index 0000000..981d5fc --- /dev/null +++ b/packages/s/src/s/names/DefinedNameCollection.ts @@ -0,0 +1,12 @@ +/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ +/* vim: set ts=2: */ + +import { DefinedName } from "./DefinedName"; +import { Range } from "../Range"; + +export interface DefinedNameCollection { + readonly items: DefinedName[]; + readonly count: number; + add(name: string, ref: string | Range, comment?: string): DefinedName; + getName(name: string): DefinedName; +}; \ No newline at end of file diff --git a/packages/s/src/s/names/WorkbookDefinedNameCollection.ts b/packages/s/src/s/names/WorkbookDefinedNameCollection.ts new file mode 100644 index 0000000..ae5d3e5 --- /dev/null +++ b/packages/s/src/s/names/WorkbookDefinedNameCollection.ts @@ -0,0 +1,67 @@ +/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ +/* vim: set ts=2: */ + +/// + +import { DefinedNameCollection } from "./DefinedNameCollection"; +import { DefinedName } from "./DefinedName"; +//import { Range } from "../Range"; + +export class WorkbookDefinedNameCollection implements DefinedNameCollection { + private readonly _wb: XLSX.WorkBook; + + constructor(wb: XLSX.WorkBook) { + this._wb = wb; + }; + + /** + * Get read-only array of global defined names + */ + get items(): DefinedName[] { + if(!this._wb.Workbook) return []; + if(!this._wb.Workbook.Names) return []; + return this._wb.Workbook.Names.filter((name) => {name.Sheet == null}).map((name) => new DefinedName(name)); + }; + + /** + * Get defined name object + */ + getName(name: string): DefinedName { + if(this._wb.Workbook && this._wb.Workbook.Names) { + const names = this._wb.Workbook.Names; + for(let i = 0; i < names.length; ++i) { + if(names[i].Name.toLowerCase() != name.toLowerCase()) continue; + if(names[i].Sheet != null) continue; + return new DefinedName(names[i]); + } + } + throw new Error(`Cannot find defined name |${name}|`); + } + + /** + * Number of global defined names + */ + get count(): number { + if(!this._wb.Workbook) return 0; + if(!this._wb.Workbook.Names) return 0; + return this._wb.Workbook.Names.filter((name) => {typeof name.Sheet == "undefined"}).length; + } + + /** + * Add or update defined name + * @param name String name + * @param ref Range object or string range/formula + * @param comment Optional comment + */ + add(name: string, ref: string /*TODO: | Range */, comment?: string): DefinedName { + try { + return this.getName(name); + } catch(e) { + const nm = { Name: name, Ref: ref.toString(), Comment: comment || "" }; + if(!this._wb.Workbook) this._wb.Workbook = {}; + if(!this._wb.Workbook.Names) this._wb.Workbook.Names = []; + this._wb.Workbook.Names.push(nm); + return new DefinedName(nm); + } + } +}; \ No newline at end of file diff --git a/packages/s/src/s/worksheet/Worksheet.ts b/packages/s/src/s/worksheet/Worksheet.ts new file mode 100644 index 0000000..0e5ff92 --- /dev/null +++ b/packages/s/src/s/worksheet/Worksheet.ts @@ -0,0 +1,5 @@ +/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ +/* vim: set ts=2: */ + +export class Worksheet { +} \ No newline at end of file diff --git a/packages/s/src/s/worksheet/WorksheetCollection.ts b/packages/s/src/s/worksheet/WorksheetCollection.ts new file mode 100644 index 0000000..0588347 --- /dev/null +++ b/packages/s/src/s/worksheet/WorksheetCollection.ts @@ -0,0 +1,12 @@ +/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ +/* vim: set ts=2: */ + +/// + +export class WorksheetCollection { + private readonly _wb: XLSX.WorkBook; + + constructor(wb: XLSX.WorkBook) { + this._wb = wb; + }; +}; diff --git a/packages/s/src/umd.ts b/packages/s/src/umd.ts new file mode 100644 index 0000000..0f09247 --- /dev/null +++ b/packages/s/src/umd.ts @@ -0,0 +1,4 @@ +/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ +/* vim: set ts=2: */ + +export * from "./index"; \ No newline at end of file diff --git a/packages/s/src/xlsx.d.ts b/packages/s/src/xlsx.d.ts new file mode 100644 index 0000000..2a13f78 --- /dev/null +++ b/packages/s/src/xlsx.d.ts @@ -0,0 +1,804 @@ +/* index.d.ts (C) 2015-present SheetJS and contributors */ +// TypeScript Version: 2.2 +declare namespace XLSX { + +/** Version string */ +export const version: string; + +/** NODE ONLY! Attempts to read filename and parse */ +export function readFile(filename: string, opts?: ParsingOptions): WorkBook; +/** Attempts to parse data */ +export function read(data: any, opts?: ParsingOptions): WorkBook; +/** Attempts to write or download workbook data to file */ +export function writeFile(data: WorkBook, filename: string, opts?: WritingOptions): any; +/** Attempts to write the workbook data */ +export function write(data: WorkBook, opts?: WritingOptions): any; + +/** Utility Functions */ +export const utils: XLSX$Utils; +/** Stream Utility Functions */ +export const stream: StreamUtils; + +/** Number Format (either a string or an index to the format table) */ +export type NumberFormat = string | number; + +/** Basic File Properties */ +export interface Properties { + /** Summary tab "Title" */ + Title?: string; + /** Summary tab "Subject" */ + Subject?: string; + /** Summary tab "Author" */ + Author?: string; + /** Summary tab "Manager" */ + Manager?: string; + /** Summary tab "Company" */ + Company?: string; + /** Summary tab "Category" */ + Category?: string; + /** Summary tab "Keywords" */ + Keywords?: string; + /** Summary tab "Comments" */ + Comments?: string; + /** Statistics tab "Last saved by" */ + LastAuthor?: string; + /** Statistics tab "Created" */ + CreatedDate?: Date; +} + +/** Other supported properties */ +export interface FullProperties extends Properties { + ModifiedDate?: Date; + Application?: string; + AppVersion?: string; + DocSecurity?: string; + HyperlinksChanged?: boolean; + SharedDoc?: boolean; + LinksUpToDate?: boolean; + ScaleCrop?: boolean; + Worksheets?: number; + SheetNames?: string[]; + ContentStatus?: string; + LastPrinted?: string; + Revision?: string | number; + Version?: string; + Identifier?: string; + Language?: string; +} + +export interface CommonOptions { + /** + * If true, throw errors when features are not understood + * @default false + */ + WTF?: boolean; + + /** + * When reading a file with VBA macros, expose CFB blob to `vbaraw` field + * When writing BIFF8/XLSB/XLSM, reseat `vbaraw` and export to file + * @default false + */ + bookVBA?: boolean; + + /** + * When reading a file, store dates as type d (default is n) + * When writing XLSX/XLSM file, use native date (default uses date codes) + * @default false + */ + cellDates?: boolean; + + /** + * When reading a file, save style/theme info to the .s field + * When writing a file, export style/theme info + * @default false + */ + cellStyles?: boolean; +} + +export interface DateNFOption { + /** Use specified date format */ + dateNF?: NumberFormat; +} + +/** Options for read and readFile */ +export interface ParsingOptions extends CommonOptions { + /** Input data encoding */ + type?: 'base64' | 'binary' | 'buffer' | 'file' | 'array' | 'string'; + + /** Default codepage */ + codepage?: number; + + /** + * Save formulae to the .f field + * @default true + */ + cellFormula?: boolean; + + /** + * Parse rich text and save HTML to the .h field + * @default true + */ + cellHTML?: boolean; + + /** + * Save number format string to the .z field + * @default false + */ + cellNF?: boolean; + + /** + * Generate formatted text to the .w field + * @default true + */ + cellText?: boolean; + + /** Override default date format (code 14) */ + dateNF?: string; + + /** + * Create cell objects for stub cells + * @default false + */ + sheetStubs?: boolean; + + /** + * If >0, read the first sheetRows rows + * @default 0 + */ + sheetRows?: number; + + /** + * If true, parse calculation chains + * @default false + */ + bookDeps?: boolean; + + /** + * If true, add raw files to book object + * @default false + */ + bookFiles?: boolean; + + /** + * If true, only parse enough to get book metadata + * @default false + */ + bookProps?: boolean; + + /** + * If true, only parse enough to get the sheet names + * @default false + */ + bookSheets?: boolean; + + /** + * If defined and file is encrypted, use password + * @default '' + */ + password?: string; + + /* If true, plaintext parsing will not parse values */ + raw?: boolean; + + dense?: boolean; +} + +/** Options for write and writeFile */ +export interface WritingOptions extends CommonOptions { + /** Output data encoding */ + type?: 'base64' | 'binary' | 'buffer' | 'file' | 'array' | 'string'; + + /** + * Generate Shared String Table + * @default false + */ + bookSST?: boolean; + + /** + * File format of generated workbook + * @default 'xlsx' + */ + bookType?: BookType; + + /** + * Name of Worksheet (for single-sheet formats) + * @default '' + */ + sheet?: string; + + /** + * Use ZIP compression for ZIP-based formats + * @default false + */ + compression?: boolean; + + /** + * Suppress "number stored as text" errors in generated files + * @default true + */ + ignoreEC?: boolean; + + /** Override workbook properties on save */ + Props?: Properties; +} + +/** Workbook Object */ +export interface WorkBook { + /** + * A dictionary of the worksheets in the workbook. + * Use SheetNames to reference these. + */ + Sheets: { [sheet: string]: WorkSheet }; + + /** Ordered list of the sheet names in the workbook */ + SheetNames: string[]; + + /** Standard workbook Properties */ + Props?: FullProperties; + + /** Custom workbook Properties */ + Custprops?: object; + + Workbook?: WBProps; + + vbaraw?: any; +} + +export interface SheetProps { + /** Sheet Visibility (0=Visible 1=Hidden 2=VeryHidden) */ + Hidden?: 0 | 1 | 2; + + /** Name of Document Module in associated VBA Project */ + CodeName?: string; +} + +/** Defined Name Object */ +export interface DefinedName { + /** Name */ + Name: string; + + /** Reference */ + Ref: string; + + /** Scope (undefined for workbook scope) */ + Sheet?: number; + + /** Name comment */ + Comment?: string; +} + +/** Workbook-Level Attributes */ +export interface WBProps { + /** Sheet Properties */ + Sheets?: SheetProps[]; + + /** Defined Names */ + Names?: DefinedName[]; + + /** Workbook Views */ + Views?: WBView[]; + + /** Other Workbook Properties */ + WBProps?: WorkbookProperties; +} + +/** Workbook View */ +export interface WBView { + /** Right-to-left mode */ + RTL?: boolean; +} + +/** Other Workbook Properties */ +export interface WorkbookProperties { + /** Worksheet Epoch (1904 if true, 1900 if false) */ + date1904?: boolean; + + /** Warn or strip personally identifying info on save */ + filterPrivacy?: boolean; + + /** Name of Document Module in associated VBA Project */ + CodeName?: string; +} + +/** Column Properties Object */ +export interface ColInfo { + /* --- visibility --- */ + + /** if true, the column is hidden */ + hidden?: boolean; + + /* --- column width --- */ + + /** width in Excel's "Max Digit Width", width*256 is integral */ + width?: number; + + /** width in screen pixels */ + wpx?: number; + + /** width in "characters" */ + wch?: number; + + /** Excel's "Max Digit Width" unit, always integral */ + MDW?: number; +} + +/** Row Properties Object */ +export interface RowInfo { + /* --- visibility --- */ + + /** if true, the column is hidden */ + hidden?: boolean; + + /* --- row height --- */ + + /** height in screen pixels */ + hpx?: number; + + /** height in points */ + hpt?: number; + + /** outline / group level */ + level?: number; +} + +/** + * Write sheet protection properties. + */ +export interface ProtectInfo { + /** + * The password for formats that support password-protected sheets + * (XLSX/XLSB/XLS). The writer uses the XOR obfuscation method. + */ + password?: string; + /** + * Select locked cells + * @default: true + */ + selectLockedCells?: boolean; + /** + * Select unlocked cells + * @default: true + */ + selectUnlockedCells?: boolean; + /** + * Format cells + * @default: false + */ + formatCells?: boolean; + /** + * Format columns + * @default: false + */ + formatColumns?: boolean; + /** + * Format rows + * @default: false + */ + formatRows?: boolean; + /** + * Insert columns + * @default: false + */ + insertColumns?: boolean; + /** + * Insert rows + * @default: false + */ + insertRows?: boolean; + /** + * Insert hyperlinks + * @default: false + */ + insertHyperlinks?: boolean; + /** + * Delete columns + * @default: false + */ + deleteColumns?: boolean; + /** + * Delete rows + * @default: false + */ + deleteRows?: boolean; + /** + * Sort + * @default: false + */ + sort?: boolean; + /** + * Filter + * @default: false + */ + autoFilter?: boolean; + /** + * Use PivotTable reports + * @default: false + */ + pivotTables?: boolean; + /** + * Edit objects + * @default: true + */ + objects?: boolean; + /** + * Edit scenarios + * @default: true + */ + scenarios?: boolean; +} + +/** Page Margins -- see Excel Page Setup .. Margins diagram for explanation */ +export interface MarginInfo { + /** Left side margin (inches) */ + left?: number; + /** Right side margin (inches) */ + right?: number; + /** Top side margin (inches) */ + top?: number; + /** Bottom side margin (inches) */ + bottom?: number; + /** Header top margin (inches) */ + header?: number; + /** Footer bottom height (inches) */ + footer?: number; +} +export type SheetType = 'sheet' | 'chart'; +export type SheetKeys = string | MarginInfo | SheetType; +/** General object representing a Sheet (worksheet or chartsheet) */ +export interface Sheet { + /** + * Indexing with a cell address string maps to a cell object + * Special keys start with '!' + */ + [cell: string]: CellObject | SheetKeys | any; + + /** Sheet type */ + '!type'?: SheetType; + + /** Sheet Range */ + '!ref'?: string; + + /** Page Margins */ + '!margins'?: MarginInfo; +} + +/** AutoFilter properties */ +export interface AutoFilterInfo { + /** Range of the AutoFilter table */ + ref: string; +} +export type WSKeys = SheetKeys | ColInfo[] | RowInfo[] | Range[] | ProtectInfo | AutoFilterInfo; + +/** Worksheet Object */ +export interface WorkSheet extends Sheet { + /** + * Indexing with a cell address string maps to a cell object + * Special keys start with '!' + */ + [cell: string]: CellObject | WSKeys | any; + + /** Column Info */ + '!cols'?: ColInfo[]; + + /** Row Info */ + '!rows'?: RowInfo[]; + + /** Merge Ranges */ + '!merges'?: Range[]; + + /** Worksheet Protection info */ + '!protect'?: ProtectInfo; + + /** AutoFilter info */ + '!autofilter'?: AutoFilterInfo; +} + +/** + * The Excel data type for a cell. + * b Boolean, n Number, e error, s String, d Date, z Stub + */ +export type ExcelDataType = 'b' | 'n' | 'e' | 's' | 'd' | 'z'; + +/** + * Type of generated workbook + * @default 'xlsx' + */ +export type BookType = 'xlsx' | 'xlsm' | 'xlsb' | 'xls' | 'xla' | 'biff8' | 'biff5' | 'biff2' | 'xlml' | 'ods' | 'fods' | 'csv' | 'txt' | 'sylk' | 'html' | 'dif' | 'rtf' | 'prn' | 'eth'; + +/** Comment element */ +export interface Comment { + /** Author of the comment block */ + a?: string; + + /** Plaintext of the comment */ + t: string; +} + +/** Link object */ +export interface Hyperlink { + /** Target of the link (HREF) */ + Target: string; + + /** Plaintext tooltip to display when mouse is over cell */ + Tooltip?: string; +} + +/** Worksheet Cell Object */ +export interface CellObject { + /** The raw value of the cell. Can be omitted if a formula is specified */ + v?: string | number | boolean | Date; + + /** Formatted text (if applicable) */ + w?: string; + + /** + * The Excel Data Type of the cell. + * b Boolean, n Number, e Error, s String, d Date, z Empty + */ + t: ExcelDataType; + + /** Cell formula (if applicable) */ + f?: string; + + /** Range of enclosing array if formula is array formula (if applicable) */ + F?: string; + + /** Rich text encoding (if applicable) */ + r?: any; + + /** HTML rendering of the rich text (if applicable) */ + h?: string; + + /** Comments associated with the cell */ + c?: Comment[]; + + /** Number format string associated with the cell (if requested) */ + z?: NumberFormat; + + /** Cell hyperlink object (.Target holds link, .tooltip is tooltip) */ + l?: Hyperlink; + + /** The style/theme of the cell (if applicable) */ + s?: any; +} + +/** Simple Cell Address */ +export interface CellAddress { + /** Column number */ + c: number; + /** Row number */ + r: number; +} + +/** + * Range object (representing ranges like "A1:B2") + */ +export interface Range { + /** Starting cell */ + s: CellAddress; + /** Ending cell */ + e: CellAddress; +} + +export interface Sheet2CSVOpts extends DateNFOption { + /** Field Separator ("delimiter") */ + FS?: string; + + /** Record Separator ("row separator") */ + RS?: string; + + /** Remove trailing field separators in each record */ + strip?: boolean; + + /** Include blank lines in the CSV output */ + blankrows?: boolean; + + /** Skip hidden rows and columns in the CSV output */ + skipHidden?: boolean; +} + +export interface OriginOption { + /** Top-Left cell for operation (CellAddress or A1 string or row) */ + origin?: number | string | CellAddress; +} + +export interface Sheet2HTMLOpts { + /** TABLE element id attribute */ + id?: string; + + /** Add contenteditable to every cell */ + editable?: boolean; + + /** Header HTML */ + header?: string; + + /** Footer HTML */ + footer?: string; +} + +export interface Sheet2JSONOpts extends DateNFOption { + /** Output format */ + header?: "A"|number|string[]; + + /** Override worksheet range */ + range?: any; + + /** Include or omit blank lines in the output */ + blankrows?: boolean; + + /** Default value for null/undefined values */ + defval?: any; + + /** if true, return raw data; if false, return formatted text */ + raw?: boolean; +} + +export interface AOA2SheetOpts extends CommonOptions, DateNFOption { + /** + * Create cell objects for stub cells + * @default false + */ + sheetStubs?: boolean; +} + +export interface SheetAOAOpts extends AOA2SheetOpts, OriginOption {} + +export interface JSON2SheetOpts extends CommonOptions, DateNFOption { + /** Use specified column order */ + header?: string[]; + + /** Skip header row in generated sheet */ + skipHeader?: boolean; +} + +export interface SheetJSONOpts extends JSON2SheetOpts, OriginOption {} + +export interface Table2SheetOpts extends CommonOptions, DateNFOption { + /* If true, plaintext parsing will not parse values */ + raw?: boolean; + + /** + * If >0, read the first sheetRows rows + * @default 0 + */ + sheetRows?: number; + + /** If true, hidden rows and cells will not be parsed */ + display?: boolean; +} + +/** General utilities */ +export interface XLSX$Utils { + /* --- Import Functions --- */ + + /** Converts an array of arrays of JS data to a worksheet. */ + aoa_to_sheet(data: T[][], opts?: AOA2SheetOpts): WorkSheet; + aoa_to_sheet(data: any[][], opts?: AOA2SheetOpts): WorkSheet; + + /** Converts an array of JS objects to a worksheet. */ + json_to_sheet(data: T[], opts?: JSON2SheetOpts): WorkSheet; + json_to_sheet(data: any[], opts?: JSON2SheetOpts): WorkSheet; + + /** BROWSER ONLY! Converts a TABLE DOM element to a worksheet. */ + table_to_sheet(data: any, opts?: Table2SheetOpts): WorkSheet; + table_to_book(data: any, opts?: Table2SheetOpts): WorkBook; + + /* --- Export Functions --- */ + + /** Converts a worksheet object to an array of JSON objects */ + sheet_to_json(worksheet: WorkSheet, opts?: Sheet2JSONOpts): T[]; + sheet_to_json(worksheet: WorkSheet, opts?: Sheet2JSONOpts): any[][]; + sheet_to_json(worksheet: WorkSheet, opts?: Sheet2JSONOpts): any[]; + + /** Generates delimiter-separated-values output */ + sheet_to_csv(worksheet: WorkSheet, options?: Sheet2CSVOpts): string; + + /** Generates UTF16 Formatted Text */ + sheet_to_txt(worksheet: WorkSheet, options?: Sheet2CSVOpts): string; + + /** Generates HTML */ + sheet_to_html(worksheet: WorkSheet, options?: Sheet2HTMLOpts): string; + + /** Generates a list of the formulae (with value fallbacks) */ + sheet_to_formulae(worksheet: WorkSheet): string[]; + + /** Generates DIF */ + sheet_to_dif(worksheet: WorkSheet, options?: Sheet2HTMLOpts): string; + + /** Generates SYLK (Symbolic Link) */ + sheet_to_slk(worksheet: WorkSheet, options?: Sheet2HTMLOpts): string; + + /** Generates ETH */ + sheet_to_eth(worksheet: WorkSheet, options?: Sheet2HTMLOpts): string; + + /* --- Cell Address Utilities --- */ + + /** Converts 0-indexed cell address to A1 form */ + encode_cell(cell: CellAddress): string; + + /** Converts 0-indexed row to A1 form */ + encode_row(row: number): string; + + /** Converts 0-indexed column to A1 form */ + encode_col(col: number): string; + + /** Converts 0-indexed range to A1 form */ + encode_range(s: CellAddress, e: CellAddress): string; + encode_range(r: Range): string; + + /** Converts A1 cell address to 0-indexed form */ + decode_cell(address: string): CellAddress; + + /** Converts A1 row to 0-indexed form */ + decode_row(row: string): number; + + /** Converts A1 column to 0-indexed form */ + decode_col(col: string): number; + + /** Converts A1 range to 0-indexed form */ + decode_range(range: string): Range; + + /** Format cell */ + format_cell(cell: CellObject, v?: any, opts?: any): string; + + /* --- General Utilities --- */ + + /** Creates a new workbook */ + book_new(): WorkBook; + + /** Append a worksheet to a workbook */ + book_append_sheet(workbook: WorkBook, worksheet: WorkSheet, name?: string): void; + + /** Set sheet visibility (visible/hidden/very hidden) */ + book_set_sheet_visibility(workbook: WorkBook, sheet: number|string, visibility: number): void; + + /** Set number format for a cell */ + cell_set_number_format(cell: CellObject, fmt: string|number): CellObject; + + /** Set hyperlink for a cell */ + cell_set_hyperlink(cell: CellObject, target: string, tooltip?: string): CellObject; + + /** Set internal link for a cell */ + cell_set_internal_link(cell: CellObject, target: string, tooltip?: string): CellObject; + + /** Add comment to a cell */ + cell_add_comment(cell: CellObject, text: string, author?: string): void; + + /** Assign an Array Formula to a range */ + sheet_set_array_formula(ws: WorkSheet, range: Range|string, formula: string): WorkSheet; + + /** Add an array of arrays of JS data to a worksheet */ + sheet_add_aoa(ws: WorkSheet, data: T[][], opts?: SheetAOAOpts): WorkSheet; + sheet_add_aoa(ws: WorkSheet, data: any[][], opts?: SheetAOAOpts): WorkSheet; + + /** Add an array of JS objects to a worksheet */ + sheet_add_json(ws: WorkSheet, data: any[], opts?: SheetJSONOpts): WorkSheet; + sheet_add_json(ws: WorkSheet, data: T[], opts?: SheetJSONOpts): WorkSheet; + + + consts: XLSX$Consts; +} + +export interface XLSX$Consts { + /* --- Sheet Visibility --- */ + + /** Visibility: Visible */ + SHEET_VISIBLE: 0; + + /** Visibility: Hidden */ + SHEET_HIDDEN: 1; + + /** Visibility: Very Hidden */ + SHEET_VERYHIDDEN: 2; +} + +/** NODE ONLY! these return Readable Streams */ +export interface StreamUtils { + /** CSV output stream, generate one line at a time */ + to_csv(sheet: WorkSheet, opts?: Sheet2CSVOpts): any; + /** HTML output stream, generate one line at a time */ + to_html(sheet: WorkSheet, opts?: Sheet2HTMLOpts): any; + /** JSON object stream, generate one row at a time */ + to_json(sheet: WorkSheet, opts?: Sheet2JSONOpts): any; +} +} \ No newline at end of file diff --git a/packages/s/test.ts b/packages/s/test.ts new file mode 100644 index 0000000..47c65f0 --- /dev/null +++ b/packages/s/test.ts @@ -0,0 +1,23 @@ +/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ +/* vim: set ts=2: */ + +/// + +import { Workbook, set_XLSX, get_XLSX } from "./"; +import * as assert from 'assert'; +const XLSXLib: typeof XLSX = require("../../"); +set_XLSX(XLSXLib); + +import 'mocha'; + +describe('Defined Names', () => { + let wb = new Workbook(); + + it('should add names to blank workbook', () => { + let cnt = wb.names.count; + assert.equal(cnt, 0); + assert.throws(() => { const newname = wb.names.getName("wtf"); }); + wb.names.add("wtf", "Sheet1!A1:A3", "dafuq"); + assert.doesNotThrow(() => { const newname = wb.names.getName("wtf"); }); + }); +}); diff --git a/packages/s/tsconfig.base.json b/packages/s/tsconfig.base.json new file mode 100644 index 0000000..3d5aba8 --- /dev/null +++ b/packages/s/tsconfig.base.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "target": "es5", + "moduleResolution": "node", + "outDir": "./.out", + "lib": [ "es5" ], + "sourceMap": true, + "noImplicitReturns": true + } +} \ No newline at end of file diff --git a/packages/s/tsconfig.json b/packages/s/tsconfig.json new file mode 100644 index 0000000..76d8a84 --- /dev/null +++ b/packages/s/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "./tsconfig.base.json", + "compilerOptions": { + "baseUrl": ".", + "paths": { + "s": [ "./src/index" ] + } + }, + "exclude": [ "./dist" ] +} \ No newline at end of file diff --git a/packages/s/tsconfig.vscode.json b/packages/s/tsconfig.vscode.json new file mode 100644 index 0000000..968de1d --- /dev/null +++ b/packages/s/tsconfig.vscode.json @@ -0,0 +1,13 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "noEmit": true + }, + "exclude": [ + "dist" + ], + "formatCodeOptions": { + "indentSize": 2, + "tabSize": 2 + } +} \ No newline at end of file diff --git a/packages/s/tsconfig/tsconfig.base.json b/packages/s/tsconfig/tsconfig.base.json new file mode 100644 index 0000000..725cebd --- /dev/null +++ b/packages/s/tsconfig/tsconfig.base.json @@ -0,0 +1,16 @@ +{ + "extends": "../tsconfig.base.json", + "compilerOptions": { + "noEmit": false, + "baseUrl": "../src", + "sourceRoot": "../src", + "paths": { + "s": [ "./" ], + "s/*": [ "./*" ] + } + }, + "files": [ + "../src/index.ts", + "../src/umd.ts" + ] +} \ No newline at end of file diff --git a/packages/s/tsconfig/tsconfig.cjs.json b/packages/s/tsconfig/tsconfig.cjs.json new file mode 100644 index 0000000..8c6a8c2 --- /dev/null +++ b/packages/s/tsconfig/tsconfig.cjs.json @@ -0,0 +1,8 @@ +{ + "extends": "./tsconfig.base.json", + "compilerOptions": { + "module": "commonjs", + "target": "es5", + "outDir": "../dist/cjs" + } +} \ No newline at end of file diff --git a/packages/s/tsconfig/tsconfig.esm.json b/packages/s/tsconfig/tsconfig.esm.json new file mode 100644 index 0000000..4cefded --- /dev/null +++ b/packages/s/tsconfig/tsconfig.esm.json @@ -0,0 +1,10 @@ +{ + "extends": "./tsconfig.base.json", + "compilerOptions": { + "module": "es2015", + "importHelpers": true, + "moduleResolution": "node", + "target": "es2015", + "outDir": "../dist/esm" + } +} \ No newline at end of file diff --git a/packages/s/tsconfig/tsconfig.types.json b/packages/s/tsconfig/tsconfig.types.json new file mode 100644 index 0000000..ed802d1 --- /dev/null +++ b/packages/s/tsconfig/tsconfig.types.json @@ -0,0 +1,11 @@ +{ + "extends": "./tsconfig.base.json", + "compilerOptions": { + "module": "es2015", + "target": "esnext", + "removeComments": false, + "declaration": true, + "declarationDir": "../dist/typings", + "emitDeclarationOnly": true + } +} \ No newline at end of file