@loaders.gl/excel 4.0.0-beta.1 → 4.0.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/{dist.min.js → dist.dev.js} +1134 -170
  2. package/dist/{esm/excel-loader.js → excel-loader.js} +1 -1
  3. package/dist/excel-loader.js.map +1 -0
  4. package/dist/excel-worker.js +1099 -106
  5. package/dist/index.cjs +86 -0
  6. package/dist/{esm/index.js → index.js} +2 -2
  7. package/dist/index.js.map +1 -0
  8. package/dist/lib/encode-excel.js.map +1 -0
  9. package/dist/lib/parse-excel.js.map +1 -0
  10. package/dist/{esm/workers → workers}/excel-worker.js +1 -1
  11. package/dist/workers/excel-worker.js.map +1 -0
  12. package/package.json +16 -8
  13. package/dist/bundle.d.ts +0 -2
  14. package/dist/bundle.d.ts.map +0 -1
  15. package/dist/es5/bundle.js +0 -6
  16. package/dist/es5/bundle.js.map +0 -1
  17. package/dist/es5/excel-loader.js +0 -27
  18. package/dist/es5/excel-loader.js.map +0 -1
  19. package/dist/es5/index.js +0 -42
  20. package/dist/es5/index.js.map +0 -1
  21. package/dist/es5/lib/encode-excel.js +0 -2
  22. package/dist/es5/lib/encode-excel.js.map +0 -1
  23. package/dist/es5/lib/parse-excel.js +0 -31
  24. package/dist/es5/lib/parse-excel.js.map +0 -1
  25. package/dist/es5/workers/excel-worker.js +0 -6
  26. package/dist/es5/workers/excel-worker.js.map +0 -1
  27. package/dist/esm/bundle.js +0 -4
  28. package/dist/esm/bundle.js.map +0 -1
  29. package/dist/esm/excel-loader.js.map +0 -1
  30. package/dist/esm/index.js.map +0 -1
  31. package/dist/esm/lib/encode-excel.js.map +0 -1
  32. package/dist/esm/lib/parse-excel.js.map +0 -1
  33. package/dist/esm/workers/excel-worker.js.map +0 -1
  34. package/src/bundle.ts +0 -4
  35. /package/dist/{esm/lib → lib}/encode-excel.js +0 -0
  36. /package/dist/{esm/lib → lib}/parse-excel.js +0 -0
package/dist/index.cjs ADDED
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var src_exports = {};
22
+ __export(src_exports, {
23
+ ExcelLoader: () => ExcelLoader2,
24
+ ExcelWorkerLoader: () => ExcelLoader
25
+ });
26
+ module.exports = __toCommonJS(src_exports);
27
+
28
+ // src/excel-loader.ts
29
+ var VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
30
+ var DEFAULT_EXCEL_LOADER_OPTIONS = {
31
+ excel: {
32
+ shape: "object-row-table",
33
+ sheet: void 0
34
+ // Load default Sheet
35
+ }
36
+ };
37
+ var ExcelLoader = {
38
+ name: "Excel",
39
+ id: "excel",
40
+ module: "excel",
41
+ version: VERSION,
42
+ worker: true,
43
+ extensions: ["xls", "xlsb", "xlsm", "xlsx"],
44
+ mimeTypes: [
45
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
46
+ "application/vnd.ms-excel"
47
+ ],
48
+ category: "table",
49
+ binary: true,
50
+ options: DEFAULT_EXCEL_LOADER_OPTIONS
51
+ };
52
+
53
+ // src/lib/parse-excel.ts
54
+ var import_xlsx = require("xlsx");
55
+ var dataTableNamesMap = {};
56
+ function parseExcel(arrayBuffer, options) {
57
+ var _a, _b, _c;
58
+ const dataUrl = "dummy";
59
+ const workbook = (0, import_xlsx.read)(arrayBuffer, {
60
+ type: "array"
61
+ // cellDates: true
62
+ });
63
+ let dataRows = [];
64
+ dataTableNamesMap[dataUrl] = [];
65
+ if (workbook.SheetNames.length > 0) {
66
+ if (workbook.SheetNames.length > 1) {
67
+ dataTableNamesMap[dataUrl] = workbook.SheetNames;
68
+ }
69
+ let sheetName = workbook.SheetNames[0];
70
+ if (((_a = options == null ? void 0 : options.excel) == null ? void 0 : _a.sheet) && workbook.SheetNames.indexOf((_b = options == null ? void 0 : options.excel) == null ? void 0 : _b.sheet) >= 0) {
71
+ sheetName = (_c = options == null ? void 0 : options.excel) == null ? void 0 : _c.sheet;
72
+ }
73
+ const worksheet = workbook.Sheets[sheetName];
74
+ dataRows = import_xlsx.utils.sheet_to_json(worksheet);
75
+ }
76
+ return dataRows;
77
+ }
78
+
79
+ // src/index.ts
80
+ var ExcelLoader2 = {
81
+ ...ExcelLoader,
82
+ async parse(arrayBuffer, options) {
83
+ const data = parseExcel(arrayBuffer, options);
84
+ return { shape: "object-row-table", data };
85
+ }
86
+ };
@@ -1,5 +1,5 @@
1
- import { ExcelLoader as ExcelWorkerLoader } from './excel-loader';
2
- import { parseExcel } from './lib/parse-excel';
1
+ import { ExcelLoader as ExcelWorkerLoader } from "./excel-loader.js";
2
+ import { parseExcel } from "./lib/parse-excel.js";
3
3
  export { ExcelWorkerLoader };
4
4
  export const ExcelLoader = {
5
5
  ...ExcelWorkerLoader,
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["ExcelLoader","ExcelWorkerLoader","parseExcel","parse","arrayBuffer","options","data","shape"],"sources":["../src/index.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport type {LoaderWithParser} from '@loaders.gl/loader-utils';\nimport type {ObjectRowTable} from '@loaders.gl/schema';\nimport type {ExcelLoaderOptions} from './excel-loader';\nimport {ExcelLoader as ExcelWorkerLoader} from './excel-loader';\nimport {parseExcel} from './lib/parse-excel';\n\n// Excel Loader\n\nexport type {ExcelLoaderOptions};\nexport {ExcelWorkerLoader};\n\n/**\n * Loader for Excel files\n */\nexport const ExcelLoader: LoaderWithParser<ObjectRowTable, never, ExcelLoaderOptions> = {\n ...ExcelWorkerLoader,\n async parse(arrayBuffer: ArrayBuffer, options?: ExcelLoaderOptions): Promise<ObjectRowTable> {\n const data = parseExcel(arrayBuffer, options);\n return {shape: 'object-row-table', data};\n }\n};\n"],"mappings":"SAKQA,WAAW,IAAIC,iBAAiB;AAAA,SAChCC,UAAU;AAKlB,SAAQD,iBAAiB;AAKzB,OAAO,MAAMD,WAAwE,GAAG;EACtF,GAAGC,iBAAiB;EACpB,MAAME,KAAKA,CAACC,WAAwB,EAAEC,OAA4B,EAA2B;IAC3F,MAAMC,IAAI,GAAGJ,UAAU,CAACE,WAAW,EAAEC,OAAO,CAAC;IAC7C,OAAO;MAACE,KAAK,EAAE,kBAAkB;MAAED;IAAI,CAAC;EAC1C;AACF,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encode-excel.js","names":[],"sources":["../../src/lib/encode-excel.ts"],"sourcesContent":["// import * as xlsx from 'xlsx';\n\n/**\n * Saves JSON data in Excel format for html, ods, xml, xlsb and xlsx file types.\n * @param filePath Local data file path.\n * @param fileData Raw data to save.\n * @param tableName Table name for data files with multiple tables support.\n * @param showData Show saved data callback.\n *\n public saveData(filePath: string, fileData: any, tableName: string, showData?: Function): void {\n const fileType: string = filePath.substr(filePath.lastIndexOf('.'));\n fileData = this.jsonToExcelData(fileData, fileType, tableName);\n if ( fileData.length > 0) {\n // TODO: change this to async later\n fs.writeFile(filePath, fileData, (error) => showData(error));\n }\n }\n\n /**\n * Converts JSON data to Excel data formats.\n * @param jsonData Json data to convert.\n * @param bookType Excel data file/book type.\n *\n private jsonToExcelData(jsonData: any, fileType: string, tableName: string): any {\n console.debug('jsonToExcelData(): creating excel data:', fileType);\n\n // create new workbook\n const workbook = xlsx.utils.book_new();\n\n // convert json data to worksheet format\n const worksheet = xlsx.utils.json_to_sheet(jsonData, {\n //header: JSON.parse(this._viewConfig.columns)\n });\n\n // append worksheet to workbook\n xlsx.utils.book_append_sheet(workbook, worksheet, tableName);\n\n // get text data string or binary spreadsheet data buffer\n let data: any = '';\n if (fileType === 'html' || fileType === 'xml') {\n data = xlsx.write(workbook, {\n type: 'string',\n compression: false,\n bookType: getBookType(fileType)\n });\n } else {\n data = xlsx.write(workbook, {\n type: 'buffer',\n compression: true, // use zip compression for zip-based formats\n bookType: getBookType(fileType)\n });\n }\n return data;\n }\n\n\n}\n\n/**\n * Converts file type to Excel book type.\n * @param {string} fileType File type: .html, .ods, .xml, .xlsb, .xlsx, etc.\n * @returns {xlsx.BookType}\n *\nfunction getBookType(fileType) {\n // TODO: must be a better way to do this string to type conversion :)\n switch (fileType) {\n case '.html':\n return 'html';\n case '.ods':\n return 'ods';\n case '.xml':\n return 'xlml';\n case '.xlsb':\n return 'xlsb';\n case '.xlsx':\n return 'xlsx';\n default:\n return 'xlsb';\n }\n}\n*/\n"],"mappings":""}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse-excel.js","names":["utils","read","dataTableNamesMap","parseExcel","arrayBuffer","options","dataUrl","workbook","type","dataRows","SheetNames","length","_options$excel","_options$excel2","sheetName","excel","sheet","indexOf","_options$excel3","worksheet","Sheets","sheet_to_json"],"sources":["../../src/lib/parse-excel.ts"],"sourcesContent":["import type {ExcelLoaderOptions} from '../excel-loader';\nimport {utils, read} from 'xlsx';\n// import {convertToArrayRow} from '@loaders.gl/schema';\n\n// local table names cache with dataUrl/tableNames array key/values\nconst dataTableNamesMap = {};\n\n/**\n * Gets local or remote Excel file data.\n * @param arrayBuffer Loaded data\n * @param options Data parse options.\n */\nexport function parseExcel(\n arrayBuffer: ArrayBuffer,\n options?: ExcelLoaderOptions\n): {[key: string]: unknown}[] {\n const dataUrl = 'dummy';\n // const dataFileType: string = dataUrl.substr(dataUrl.lastIndexOf('.')); // file extension\n\n // create Excel 'workbook'\n const workbook = read(arrayBuffer, {\n type: 'array'\n // cellDates: true\n });\n\n // load data sheets\n let dataRows: {[key: string]: unknown}[] = [];\n dataTableNamesMap[dataUrl] = [];\n if (workbook.SheetNames.length > 0) {\n if (workbook.SheetNames.length > 1) {\n // cache sheet names\n dataTableNamesMap[dataUrl] = workbook.SheetNames;\n // eslint-ignore-next-line\n // console.debug(`getData(): file: sheetNames:`, workbook.SheetNames);\n }\n\n // determine spreadsheet to load\n let sheetName = workbook.SheetNames[0];\n if (options?.excel?.sheet && workbook.SheetNames.indexOf(options?.excel?.sheet) >= 0) {\n // reset to requested table name\n sheetName = options?.excel?.sheet;\n }\n\n // get worksheet data row objects array\n const worksheet = workbook.Sheets[sheetName];\n dataRows = utils.sheet_to_json(worksheet);\n\n // const headers = dataRows.length ? Object.keys(dataRows[0]) : [];\n // if (options?.excel?.type === 'array-row-table') {\n // dataRows = dataRows.map(row => convertToArrayRow(row, headers))\n // }\n }\n\n return dataRows;\n}\n"],"mappings":"AACA,SAAQA,KAAK,EAAEC,IAAI,QAAO,MAAM;AAIhC,MAAMC,iBAAiB,GAAG,CAAC,CAAC;AAO5B,OAAO,SAASC,UAAUA,CACxBC,WAAwB,EACxBC,OAA4B,EACA;EAC5B,MAAMC,OAAO,GAAG,OAAO;EAIvB,MAAMC,QAAQ,GAAGN,IAAI,CAACG,WAAW,EAAE;IACjCI,IAAI,EAAE;EAER,CAAC,CAAC;EAGF,IAAIC,QAAoC,GAAG,EAAE;EAC7CP,iBAAiB,CAACI,OAAO,CAAC,GAAG,EAAE;EAC/B,IAAIC,QAAQ,CAACG,UAAU,CAACC,MAAM,GAAG,CAAC,EAAE;IAAA,IAAAC,cAAA,EAAAC,eAAA;IAClC,IAAIN,QAAQ,CAACG,UAAU,CAACC,MAAM,GAAG,CAAC,EAAE;MAElCT,iBAAiB,CAACI,OAAO,CAAC,GAAGC,QAAQ,CAACG,UAAU;IAGlD;IAGA,IAAII,SAAS,GAAGP,QAAQ,CAACG,UAAU,CAAC,CAAC,CAAC;IACtC,IAAIL,OAAO,aAAPA,OAAO,gBAAAO,cAAA,GAAPP,OAAO,CAAEU,KAAK,cAAAH,cAAA,eAAdA,cAAA,CAAgBI,KAAK,IAAIT,QAAQ,CAACG,UAAU,CAACO,OAAO,CAACZ,OAAO,aAAPA,OAAO,wBAAAQ,eAAA,GAAPR,OAAO,CAAEU,KAAK,cAAAF,eAAA,uBAAdA,eAAA,CAAgBG,KAAK,CAAC,IAAI,CAAC,EAAE;MAAA,IAAAE,eAAA;MAEpFJ,SAAS,GAAGT,OAAO,aAAPA,OAAO,wBAAAa,eAAA,GAAPb,OAAO,CAAEU,KAAK,cAAAG,eAAA,uBAAdA,eAAA,CAAgBF,KAAK;IACnC;IAGA,MAAMG,SAAS,GAAGZ,QAAQ,CAACa,MAAM,CAACN,SAAS,CAAC;IAC5CL,QAAQ,GAAGT,KAAK,CAACqB,aAAa,CAACF,SAAS,CAAC;EAM3C;EAEA,OAAOV,QAAQ;AACjB"}
@@ -1,4 +1,4 @@
1
1
  import { createLoaderWorker } from '@loaders.gl/loader-utils';
2
- import { ExcelLoader } from '../index';
2
+ import { ExcelLoader } from "../index.js";
3
3
  createLoaderWorker(ExcelLoader);
4
4
  //# sourceMappingURL=excel-worker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"excel-worker.js","names":["createLoaderWorker","ExcelLoader"],"sources":["../../src/workers/excel-worker.ts"],"sourcesContent":["import {createLoaderWorker} from '@loaders.gl/loader-utils';\nimport {ExcelLoader} from '../index';\n\ncreateLoaderWorker(ExcelLoader);\n"],"mappings":"AAAA,SAAQA,kBAAkB,QAAO,0BAA0B;AAAC,SACpDC,WAAW;AAEnBD,kBAAkB,CAACC,WAAW,CAAC"}
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "@loaders.gl/excel",
3
- "version": "4.0.0-beta.1",
3
+ "version": "4.0.0-beta.3",
4
4
  "description": "Framework-independent loader for Excel files",
5
5
  "license": "MIT",
6
+ "type": "module",
6
7
  "publishConfig": {
7
8
  "access": "public"
8
9
  },
@@ -21,8 +22,15 @@
21
22
  "Spreadsheets"
22
23
  ],
23
24
  "types": "dist/index.d.ts",
24
- "main": "dist/es5/index.js",
25
- "module": "dist/esm/index.js",
25
+ "main": "dist/index.cjs",
26
+ "module": "dist/index.js",
27
+ "exports": {
28
+ ".": {
29
+ "import": "./dist/index.js",
30
+ "require": "./dist/index.cjs",
31
+ "types": "./dist/index.d.ts"
32
+ }
33
+ },
26
34
  "sideEffects": false,
27
35
  "files": [
28
36
  "src",
@@ -30,14 +38,14 @@
30
38
  "README.md"
31
39
  ],
32
40
  "scripts": {
33
- "pre-build": "npm run build-bundle && npm run build-worker",
34
- "build-bundle": "esbuild src/bundle.ts --bundle --outfile=dist/dist.min.js",
41
+ "pre-build": "npm run build-bundle && npm run build-bundle -- --env=dev && npm run build-worker",
42
+ "build-bundle": "ocular-bundle ./src/index.ts",
35
43
  "build-worker": "esbuild src/workers/excel-worker.ts --bundle --outfile=dist/excel-worker.js --define:__VERSION__=\\\"$npm_package_version\\\""
36
44
  },
37
45
  "dependencies": {
38
- "@loaders.gl/loader-utils": "4.0.0-beta.1",
39
- "@loaders.gl/schema": "4.0.0-beta.1",
46
+ "@loaders.gl/loader-utils": "4.0.0-beta.3",
47
+ "@loaders.gl/schema": "4.0.0-beta.3",
40
48
  "xlsx": "^0.17.0"
41
49
  },
42
- "gitHead": "35c625e67132b0784e597d9ddabae8aefea29ff2"
50
+ "gitHead": "7ba9621cc51c7a26c407086ac86171f35b8712af"
43
51
  }
package/dist/bundle.d.ts DELETED
@@ -1,2 +0,0 @@
1
- declare const moduleExports: any;
2
- //# sourceMappingURL=bundle.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../src/bundle.ts"],"names":[],"mappings":"AACA,QAAA,MAAM,aAAa,KAAqB,CAAC"}
@@ -1,6 +0,0 @@
1
- "use strict";
2
-
3
- var moduleExports = require('./index');
4
- globalThis.loaders = globalThis.loaders || {};
5
- module.exports = Object.assign(globalThis.loaders, moduleExports);
6
- //# sourceMappingURL=bundle.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bundle.js","names":["moduleExports","require","globalThis","loaders","module","exports","Object","assign"],"sources":["../../src/bundle.ts"],"sourcesContent":["// @ts-nocheck\nconst moduleExports = require('./index');\nglobalThis.loaders = globalThis.loaders || {};\nmodule.exports = Object.assign(globalThis.loaders, moduleExports);\n"],"mappings":";;AACA,IAAMA,aAAa,GAAGC,OAAO,CAAC,SAAS,CAAC;AACxCC,UAAU,CAACC,OAAO,GAAGD,UAAU,CAACC,OAAO,IAAI,CAAC,CAAC;AAC7CC,MAAM,CAACC,OAAO,GAAGC,MAAM,CAACC,MAAM,CAACL,UAAU,CAACC,OAAO,EAAEH,aAAa,CAAC"}
@@ -1,27 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.ExcelLoader = void 0;
7
- var VERSION = typeof "4.0.0-beta.1" !== 'undefined' ? "4.0.0-beta.1" : 'latest';
8
- var DEFAULT_EXCEL_LOADER_OPTIONS = {
9
- excel: {
10
- shape: 'object-row-table',
11
- sheet: undefined
12
- }
13
- };
14
- var ExcelLoader = {
15
- name: 'Excel',
16
- id: 'excel',
17
- module: 'excel',
18
- version: VERSION,
19
- worker: true,
20
- extensions: ['xls', 'xlsb', 'xlsm', 'xlsx'],
21
- mimeTypes: ['application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/vnd.ms-excel'],
22
- category: 'table',
23
- binary: true,
24
- options: DEFAULT_EXCEL_LOADER_OPTIONS
25
- };
26
- exports.ExcelLoader = ExcelLoader;
27
- //# sourceMappingURL=excel-loader.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"excel-loader.js","names":["VERSION","DEFAULT_EXCEL_LOADER_OPTIONS","excel","shape","sheet","undefined","ExcelLoader","name","id","module","version","worker","extensions","mimeTypes","category","binary","options","exports"],"sources":["../../src/excel-loader.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport type {Loader, LoaderOptions} from '@loaders.gl/loader-utils';\nimport type {ObjectRowTable} from '@loaders.gl/schema';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\nexport type ExcelLoaderOptions = LoaderOptions & {\n excel?: {\n shape: /* 'array-row-table' | */ 'object-row-table';\n sheet?: string; // Load default Sheet\n };\n};\n\nconst DEFAULT_EXCEL_LOADER_OPTIONS: ExcelLoaderOptions = {\n excel: {\n shape: 'object-row-table',\n sheet: undefined // Load default Sheet\n }\n};\n\n/**\n * Worker Loader for Excel files\n */\nexport const ExcelLoader: Loader<ObjectRowTable, never, ExcelLoaderOptions> = {\n name: 'Excel',\n id: 'excel',\n module: 'excel',\n version: VERSION,\n worker: true,\n extensions: ['xls', 'xlsb', 'xlsm', 'xlsx'],\n mimeTypes: [\n 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',\n 'application/vnd.ms-excel'\n ],\n category: 'table',\n binary: true,\n options: DEFAULT_EXCEL_LOADER_OPTIONS\n};\n"],"mappings":";;;;;;AAOA,IAAMA,OAAO,GAAG,qBAAkB,KAAK,WAAW,oBAAiB,QAAQ;AAS3E,IAAMC,4BAAgD,GAAG;EACvDC,KAAK,EAAE;IACLC,KAAK,EAAE,kBAAkB;IACzBC,KAAK,EAAEC;EACT;AACF,CAAC;AAKM,IAAMC,WAA8D,GAAG;EAC5EC,IAAI,EAAE,OAAO;EACbC,EAAE,EAAE,OAAO;EACXC,MAAM,EAAE,OAAO;EACfC,OAAO,EAAEV,OAAO;EAChBW,MAAM,EAAE,IAAI;EACZC,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;EAC3CC,SAAS,EAAE,CACT,mEAAmE,EACnE,0BAA0B,CAC3B;EACDC,QAAQ,EAAE,OAAO;EACjBC,MAAM,EAAE,IAAI;EACZC,OAAO,EAAEf;AACX,CAAC;AAACgB,OAAA,CAAAX,WAAA,GAAAA,WAAA"}
package/dist/es5/index.js DELETED
@@ -1,42 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.ExcelLoader = void 0;
8
- Object.defineProperty(exports, "ExcelWorkerLoader", {
9
- enumerable: true,
10
- get: function get() {
11
- return _excelLoader.ExcelLoader;
12
- }
13
- });
14
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
15
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
16
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
17
- var _excelLoader = require("./excel-loader");
18
- var _parseExcel = require("./lib/parse-excel");
19
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
20
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
21
- var ExcelLoader = _objectSpread(_objectSpread({}, _excelLoader.ExcelLoader), {}, {
22
- parse: function parse(arrayBuffer, options) {
23
- return (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee() {
24
- var data;
25
- return _regenerator.default.wrap(function _callee$(_context) {
26
- while (1) switch (_context.prev = _context.next) {
27
- case 0:
28
- data = (0, _parseExcel.parseExcel)(arrayBuffer, options);
29
- return _context.abrupt("return", {
30
- shape: 'object-row-table',
31
- data: data
32
- });
33
- case 2:
34
- case "end":
35
- return _context.stop();
36
- }
37
- }, _callee);
38
- }))();
39
- }
40
- });
41
- exports.ExcelLoader = ExcelLoader;
42
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":["_excelLoader","require","_parseExcel","ownKeys","object","enumerableOnly","keys","Object","getOwnPropertySymbols","symbols","filter","sym","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","target","i","arguments","length","source","forEach","key","_defineProperty2","default","getOwnPropertyDescriptors","defineProperties","defineProperty","ExcelLoader","ExcelWorkerLoader","parse","arrayBuffer","options","_asyncToGenerator2","_regenerator","mark","_callee","data","wrap","_callee$","_context","prev","next","parseExcel","abrupt","shape","stop","exports"],"sources":["../../src/index.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport type {LoaderWithParser} from '@loaders.gl/loader-utils';\nimport type {ObjectRowTable} from '@loaders.gl/schema';\nimport type {ExcelLoaderOptions} from './excel-loader';\nimport {ExcelLoader as ExcelWorkerLoader} from './excel-loader';\nimport {parseExcel} from './lib/parse-excel';\n\n// Excel Loader\n\nexport type {ExcelLoaderOptions};\nexport {ExcelWorkerLoader};\n\n/**\n * Loader for Excel files\n */\nexport const ExcelLoader: LoaderWithParser<ObjectRowTable, never, ExcelLoaderOptions> = {\n ...ExcelWorkerLoader,\n async parse(arrayBuffer: ArrayBuffer, options?: ExcelLoaderOptions): Promise<ObjectRowTable> {\n const data = parseExcel(arrayBuffer, options);\n return {shape: 'object-row-table', data};\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAKA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAA6C,SAAAE,QAAAC,MAAA,EAAAC,cAAA,QAAAC,IAAA,GAAAC,MAAA,CAAAD,IAAA,CAAAF,MAAA,OAAAG,MAAA,CAAAC,qBAAA,QAAAC,OAAA,GAAAF,MAAA,CAAAC,qBAAA,CAAAJ,MAAA,GAAAC,cAAA,KAAAI,OAAA,GAAAA,OAAA,CAAAC,MAAA,WAAAC,GAAA,WAAAJ,MAAA,CAAAK,wBAAA,CAAAR,MAAA,EAAAO,GAAA,EAAAE,UAAA,OAAAP,IAAA,CAAAQ,IAAA,CAAAC,KAAA,CAAAT,IAAA,EAAAG,OAAA,YAAAH,IAAA;AAAA,SAAAU,cAAAC,MAAA,aAAAC,CAAA,MAAAA,CAAA,GAAAC,SAAA,CAAAC,MAAA,EAAAF,CAAA,UAAAG,MAAA,WAAAF,SAAA,CAAAD,CAAA,IAAAC,SAAA,CAAAD,CAAA,QAAAA,CAAA,OAAAf,OAAA,CAAAI,MAAA,CAAAc,MAAA,OAAAC,OAAA,WAAAC,GAAA,QAAAC,gBAAA,CAAAC,OAAA,EAAAR,MAAA,EAAAM,GAAA,EAAAF,MAAA,CAAAE,GAAA,SAAAhB,MAAA,CAAAmB,yBAAA,GAAAnB,MAAA,CAAAoB,gBAAA,CAAAV,MAAA,EAAAV,MAAA,CAAAmB,yBAAA,CAAAL,MAAA,KAAAlB,OAAA,CAAAI,MAAA,CAAAc,MAAA,GAAAC,OAAA,WAAAC,GAAA,IAAAhB,MAAA,CAAAqB,cAAA,CAAAX,MAAA,EAAAM,GAAA,EAAAhB,MAAA,CAAAK,wBAAA,CAAAS,MAAA,EAAAE,GAAA,iBAAAN,MAAA;AAUtC,IAAMY,WAAwE,GAAAb,aAAA,CAAAA,aAAA,KAChFc,wBAAiB;EACdC,KAAK,WAAAA,MAACC,WAAwB,EAAEC,OAA4B,EAA2B;IAAA,WAAAC,kBAAA,CAAAT,OAAA,EAAAU,YAAA,CAAAV,OAAA,CAAAW,IAAA,UAAAC,QAAA;MAAA,IAAAC,IAAA;MAAA,OAAAH,YAAA,CAAAV,OAAA,CAAAc,IAAA,UAAAC,SAAAC,QAAA;QAAA,kBAAAA,QAAA,CAAAC,IAAA,GAAAD,QAAA,CAAAE,IAAA;UAAA;YACrFL,IAAI,GAAG,IAAAM,sBAAU,EAACZ,WAAW,EAAEC,OAAO,CAAC;YAAA,OAAAQ,QAAA,CAAAI,MAAA,WACtC;cAACC,KAAK,EAAE,kBAAkB;cAAER,IAAI,EAAJA;YAAI,CAAC;UAAA;UAAA;YAAA,OAAAG,QAAA,CAAAM,IAAA;QAAA;MAAA,GAAAV,OAAA;IAAA;EAC1C;AAAC,EACF;AAACW,OAAA,CAAAnB,WAAA,GAAAA,WAAA"}
@@ -1,2 +0,0 @@
1
- "use strict";
2
- //# sourceMappingURL=encode-excel.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"encode-excel.js","names":[],"sources":["../../../src/lib/encode-excel.ts"],"sourcesContent":["// import * as xlsx from 'xlsx';\n\n/**\n * Saves JSON data in Excel format for html, ods, xml, xlsb and xlsx file types.\n * @param filePath Local data file path.\n * @param fileData Raw data to save.\n * @param tableName Table name for data files with multiple tables support.\n * @param showData Show saved data callback.\n *\n public saveData(filePath: string, fileData: any, tableName: string, showData?: Function): void {\n const fileType: string = filePath.substr(filePath.lastIndexOf('.'));\n fileData = this.jsonToExcelData(fileData, fileType, tableName);\n if ( fileData.length > 0) {\n // TODO: change this to async later\n fs.writeFile(filePath, fileData, (error) => showData(error));\n }\n }\n\n /**\n * Converts JSON data to Excel data formats.\n * @param jsonData Json data to convert.\n * @param bookType Excel data file/book type.\n *\n private jsonToExcelData(jsonData: any, fileType: string, tableName: string): any {\n console.debug('jsonToExcelData(): creating excel data:', fileType);\n\n // create new workbook\n const workbook = xlsx.utils.book_new();\n\n // convert json data to worksheet format\n const worksheet = xlsx.utils.json_to_sheet(jsonData, {\n //header: JSON.parse(this._viewConfig.columns)\n });\n\n // append worksheet to workbook\n xlsx.utils.book_append_sheet(workbook, worksheet, tableName);\n\n // get text data string or binary spreadsheet data buffer\n let data: any = '';\n if (fileType === 'html' || fileType === 'xml') {\n data = xlsx.write(workbook, {\n type: 'string',\n compression: false,\n bookType: getBookType(fileType)\n });\n } else {\n data = xlsx.write(workbook, {\n type: 'buffer',\n compression: true, // use zip compression for zip-based formats\n bookType: getBookType(fileType)\n });\n }\n return data;\n }\n\n\n}\n\n/**\n * Converts file type to Excel book type.\n * @param {string} fileType File type: .html, .ods, .xml, .xlsb, .xlsx, etc.\n * @returns {xlsx.BookType}\n *\nfunction getBookType(fileType) {\n // TODO: must be a better way to do this string to type conversion :)\n switch (fileType) {\n case '.html':\n return 'html';\n case '.ods':\n return 'ods';\n case '.xml':\n return 'xlml';\n case '.xlsb':\n return 'xlsb';\n case '.xlsx':\n return 'xlsx';\n default:\n return 'xlsb';\n }\n}\n*/\n"],"mappings":""}
@@ -1,31 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.parseExcel = parseExcel;
7
- var _xlsx = require("xlsx");
8
- var dataTableNamesMap = {};
9
- function parseExcel(arrayBuffer, options) {
10
- var dataUrl = 'dummy';
11
- var workbook = (0, _xlsx.read)(arrayBuffer, {
12
- type: 'array'
13
- });
14
- var dataRows = [];
15
- dataTableNamesMap[dataUrl] = [];
16
- if (workbook.SheetNames.length > 0) {
17
- var _options$excel, _options$excel2;
18
- if (workbook.SheetNames.length > 1) {
19
- dataTableNamesMap[dataUrl] = workbook.SheetNames;
20
- }
21
- var sheetName = workbook.SheetNames[0];
22
- if (options !== null && options !== void 0 && (_options$excel = options.excel) !== null && _options$excel !== void 0 && _options$excel.sheet && workbook.SheetNames.indexOf(options === null || options === void 0 ? void 0 : (_options$excel2 = options.excel) === null || _options$excel2 === void 0 ? void 0 : _options$excel2.sheet) >= 0) {
23
- var _options$excel3;
24
- sheetName = options === null || options === void 0 ? void 0 : (_options$excel3 = options.excel) === null || _options$excel3 === void 0 ? void 0 : _options$excel3.sheet;
25
- }
26
- var worksheet = workbook.Sheets[sheetName];
27
- dataRows = _xlsx.utils.sheet_to_json(worksheet);
28
- }
29
- return dataRows;
30
- }
31
- //# sourceMappingURL=parse-excel.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"parse-excel.js","names":["_xlsx","require","dataTableNamesMap","parseExcel","arrayBuffer","options","dataUrl","workbook","read","type","dataRows","SheetNames","length","_options$excel","_options$excel2","sheetName","excel","sheet","indexOf","_options$excel3","worksheet","Sheets","utils","sheet_to_json"],"sources":["../../../src/lib/parse-excel.ts"],"sourcesContent":["import type {ExcelLoaderOptions} from '../excel-loader';\nimport {utils, read} from 'xlsx';\n// import {convertToArrayRow} from '@loaders.gl/schema';\n\n// local table names cache with dataUrl/tableNames array key/values\nconst dataTableNamesMap = {};\n\n/**\n * Gets local or remote Excel file data.\n * @param arrayBuffer Loaded data\n * @param options Data parse options.\n */\nexport function parseExcel(\n arrayBuffer: ArrayBuffer,\n options?: ExcelLoaderOptions\n): {[key: string]: unknown}[] {\n const dataUrl = 'dummy';\n // const dataFileType: string = dataUrl.substr(dataUrl.lastIndexOf('.')); // file extension\n\n // create Excel 'workbook'\n const workbook = read(arrayBuffer, {\n type: 'array'\n // cellDates: true\n });\n\n // load data sheets\n let dataRows: {[key: string]: unknown}[] = [];\n dataTableNamesMap[dataUrl] = [];\n if (workbook.SheetNames.length > 0) {\n if (workbook.SheetNames.length > 1) {\n // cache sheet names\n dataTableNamesMap[dataUrl] = workbook.SheetNames;\n // eslint-ignore-next-line\n // console.debug(`getData(): file: sheetNames:`, workbook.SheetNames);\n }\n\n // determine spreadsheet to load\n let sheetName = workbook.SheetNames[0];\n if (options?.excel?.sheet && workbook.SheetNames.indexOf(options?.excel?.sheet) >= 0) {\n // reset to requested table name\n sheetName = options?.excel?.sheet;\n }\n\n // get worksheet data row objects array\n const worksheet = workbook.Sheets[sheetName];\n dataRows = utils.sheet_to_json(worksheet);\n\n // const headers = dataRows.length ? Object.keys(dataRows[0]) : [];\n // if (options?.excel?.type === 'array-row-table') {\n // dataRows = dataRows.map(row => convertToArrayRow(row, headers))\n // }\n }\n\n return dataRows;\n}\n"],"mappings":";;;;;;AACA,IAAAA,KAAA,GAAAC,OAAA;AAIA,IAAMC,iBAAiB,GAAG,CAAC,CAAC;AAOrB,SAASC,UAAUA,CACxBC,WAAwB,EACxBC,OAA4B,EACA;EAC5B,IAAMC,OAAO,GAAG,OAAO;EAIvB,IAAMC,QAAQ,GAAG,IAAAC,UAAI,EAACJ,WAAW,EAAE;IACjCK,IAAI,EAAE;EAER,CAAC,CAAC;EAGF,IAAIC,QAAoC,GAAG,EAAE;EAC7CR,iBAAiB,CAACI,OAAO,CAAC,GAAG,EAAE;EAC/B,IAAIC,QAAQ,CAACI,UAAU,CAACC,MAAM,GAAG,CAAC,EAAE;IAAA,IAAAC,cAAA,EAAAC,eAAA;IAClC,IAAIP,QAAQ,CAACI,UAAU,CAACC,MAAM,GAAG,CAAC,EAAE;MAElCV,iBAAiB,CAACI,OAAO,CAAC,GAAGC,QAAQ,CAACI,UAAU;IAGlD;IAGA,IAAII,SAAS,GAAGR,QAAQ,CAACI,UAAU,CAAC,CAAC,CAAC;IACtC,IAAIN,OAAO,aAAPA,OAAO,gBAAAQ,cAAA,GAAPR,OAAO,CAAEW,KAAK,cAAAH,cAAA,eAAdA,cAAA,CAAgBI,KAAK,IAAIV,QAAQ,CAACI,UAAU,CAACO,OAAO,CAACb,OAAO,aAAPA,OAAO,wBAAAS,eAAA,GAAPT,OAAO,CAAEW,KAAK,cAAAF,eAAA,uBAAdA,eAAA,CAAgBG,KAAK,CAAC,IAAI,CAAC,EAAE;MAAA,IAAAE,eAAA;MAEpFJ,SAAS,GAAGV,OAAO,aAAPA,OAAO,wBAAAc,eAAA,GAAPd,OAAO,CAAEW,KAAK,cAAAG,eAAA,uBAAdA,eAAA,CAAgBF,KAAK;IACnC;IAGA,IAAMG,SAAS,GAAGb,QAAQ,CAACc,MAAM,CAACN,SAAS,CAAC;IAC5CL,QAAQ,GAAGY,WAAK,CAACC,aAAa,CAACH,SAAS,CAAC;EAM3C;EAEA,OAAOV,QAAQ;AACjB"}
@@ -1,6 +0,0 @@
1
- "use strict";
2
-
3
- var _loaderUtils = require("@loaders.gl/loader-utils");
4
- var _index = require("../index");
5
- (0, _loaderUtils.createLoaderWorker)(_index.ExcelLoader);
6
- //# sourceMappingURL=excel-worker.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"excel-worker.js","names":["_loaderUtils","require","_index","createLoaderWorker","ExcelLoader"],"sources":["../../../src/workers/excel-worker.ts"],"sourcesContent":["import {createLoaderWorker} from '@loaders.gl/loader-utils';\nimport {ExcelLoader} from '../index';\n\ncreateLoaderWorker(ExcelLoader);\n"],"mappings":";;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAEA,IAAAE,+BAAkB,EAACC,kBAAW,CAAC"}
@@ -1,4 +0,0 @@
1
- const moduleExports = require('./index');
2
- globalThis.loaders = globalThis.loaders || {};
3
- module.exports = Object.assign(globalThis.loaders, moduleExports);
4
- //# sourceMappingURL=bundle.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bundle.js","names":["moduleExports","require","globalThis","loaders","module","exports","Object","assign"],"sources":["../../src/bundle.ts"],"sourcesContent":["// @ts-nocheck\nconst moduleExports = require('./index');\nglobalThis.loaders = globalThis.loaders || {};\nmodule.exports = Object.assign(globalThis.loaders, moduleExports);\n"],"mappings":"AACA,MAAMA,aAAa,GAAGC,OAAO,CAAC,SAAS,CAAC;AACxCC,UAAU,CAACC,OAAO,GAAGD,UAAU,CAACC,OAAO,IAAI,CAAC,CAAC;AAC7CC,MAAM,CAACC,OAAO,GAAGC,MAAM,CAACC,MAAM,CAACL,UAAU,CAACC,OAAO,EAAEH,aAAa,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"excel-loader.js","names":["VERSION","DEFAULT_EXCEL_LOADER_OPTIONS","excel","shape","sheet","undefined","ExcelLoader","name","id","module","version","worker","extensions","mimeTypes","category","binary","options"],"sources":["../../src/excel-loader.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport type {Loader, LoaderOptions} from '@loaders.gl/loader-utils';\nimport type {ObjectRowTable} from '@loaders.gl/schema';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\nexport type ExcelLoaderOptions = LoaderOptions & {\n excel?: {\n shape: /* 'array-row-table' | */ 'object-row-table';\n sheet?: string; // Load default Sheet\n };\n};\n\nconst DEFAULT_EXCEL_LOADER_OPTIONS: ExcelLoaderOptions = {\n excel: {\n shape: 'object-row-table',\n sheet: undefined // Load default Sheet\n }\n};\n\n/**\n * Worker Loader for Excel files\n */\nexport const ExcelLoader: Loader<ObjectRowTable, never, ExcelLoaderOptions> = {\n name: 'Excel',\n id: 'excel',\n module: 'excel',\n version: VERSION,\n worker: true,\n extensions: ['xls', 'xlsb', 'xlsm', 'xlsx'],\n mimeTypes: [\n 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',\n 'application/vnd.ms-excel'\n ],\n category: 'table',\n binary: true,\n options: DEFAULT_EXCEL_LOADER_OPTIONS\n};\n"],"mappings":"AAOA,MAAMA,OAAO,GAAG,qBAAkB,KAAK,WAAW,oBAAiB,QAAQ;AAS3E,MAAMC,4BAAgD,GAAG;EACvDC,KAAK,EAAE;IACLC,KAAK,EAAE,kBAAkB;IACzBC,KAAK,EAAEC;EACT;AACF,CAAC;AAKD,OAAO,MAAMC,WAA8D,GAAG;EAC5EC,IAAI,EAAE,OAAO;EACbC,EAAE,EAAE,OAAO;EACXC,MAAM,EAAE,OAAO;EACfC,OAAO,EAAEV,OAAO;EAChBW,MAAM,EAAE,IAAI;EACZC,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;EAC3CC,SAAS,EAAE,CACT,mEAAmE,EACnE,0BAA0B,CAC3B;EACDC,QAAQ,EAAE,OAAO;EACjBC,MAAM,EAAE,IAAI;EACZC,OAAO,EAAEf;AACX,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":["ExcelLoader","ExcelWorkerLoader","parseExcel","parse","arrayBuffer","options","data","shape"],"sources":["../../src/index.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport type {LoaderWithParser} from '@loaders.gl/loader-utils';\nimport type {ObjectRowTable} from '@loaders.gl/schema';\nimport type {ExcelLoaderOptions} from './excel-loader';\nimport {ExcelLoader as ExcelWorkerLoader} from './excel-loader';\nimport {parseExcel} from './lib/parse-excel';\n\n// Excel Loader\n\nexport type {ExcelLoaderOptions};\nexport {ExcelWorkerLoader};\n\n/**\n * Loader for Excel files\n */\nexport const ExcelLoader: LoaderWithParser<ObjectRowTable, never, ExcelLoaderOptions> = {\n ...ExcelWorkerLoader,\n async parse(arrayBuffer: ArrayBuffer, options?: ExcelLoaderOptions): Promise<ObjectRowTable> {\n const data = parseExcel(arrayBuffer, options);\n return {shape: 'object-row-table', data};\n }\n};\n"],"mappings":"AAKA,SAAQA,WAAW,IAAIC,iBAAiB,QAAO,gBAAgB;AAC/D,SAAQC,UAAU,QAAO,mBAAmB;AAK5C,SAAQD,iBAAiB;AAKzB,OAAO,MAAMD,WAAwE,GAAG;EACtF,GAAGC,iBAAiB;EACpB,MAAME,KAAKA,CAACC,WAAwB,EAAEC,OAA4B,EAA2B;IAC3F,MAAMC,IAAI,GAAGJ,UAAU,CAACE,WAAW,EAAEC,OAAO,CAAC;IAC7C,OAAO;MAACE,KAAK,EAAE,kBAAkB;MAAED;IAAI,CAAC;EAC1C;AACF,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"encode-excel.js","names":[],"sources":["../../../src/lib/encode-excel.ts"],"sourcesContent":["// import * as xlsx from 'xlsx';\n\n/**\n * Saves JSON data in Excel format for html, ods, xml, xlsb and xlsx file types.\n * @param filePath Local data file path.\n * @param fileData Raw data to save.\n * @param tableName Table name for data files with multiple tables support.\n * @param showData Show saved data callback.\n *\n public saveData(filePath: string, fileData: any, tableName: string, showData?: Function): void {\n const fileType: string = filePath.substr(filePath.lastIndexOf('.'));\n fileData = this.jsonToExcelData(fileData, fileType, tableName);\n if ( fileData.length > 0) {\n // TODO: change this to async later\n fs.writeFile(filePath, fileData, (error) => showData(error));\n }\n }\n\n /**\n * Converts JSON data to Excel data formats.\n * @param jsonData Json data to convert.\n * @param bookType Excel data file/book type.\n *\n private jsonToExcelData(jsonData: any, fileType: string, tableName: string): any {\n console.debug('jsonToExcelData(): creating excel data:', fileType);\n\n // create new workbook\n const workbook = xlsx.utils.book_new();\n\n // convert json data to worksheet format\n const worksheet = xlsx.utils.json_to_sheet(jsonData, {\n //header: JSON.parse(this._viewConfig.columns)\n });\n\n // append worksheet to workbook\n xlsx.utils.book_append_sheet(workbook, worksheet, tableName);\n\n // get text data string or binary spreadsheet data buffer\n let data: any = '';\n if (fileType === 'html' || fileType === 'xml') {\n data = xlsx.write(workbook, {\n type: 'string',\n compression: false,\n bookType: getBookType(fileType)\n });\n } else {\n data = xlsx.write(workbook, {\n type: 'buffer',\n compression: true, // use zip compression for zip-based formats\n bookType: getBookType(fileType)\n });\n }\n return data;\n }\n\n\n}\n\n/**\n * Converts file type to Excel book type.\n * @param {string} fileType File type: .html, .ods, .xml, .xlsb, .xlsx, etc.\n * @returns {xlsx.BookType}\n *\nfunction getBookType(fileType) {\n // TODO: must be a better way to do this string to type conversion :)\n switch (fileType) {\n case '.html':\n return 'html';\n case '.ods':\n return 'ods';\n case '.xml':\n return 'xlml';\n case '.xlsb':\n return 'xlsb';\n case '.xlsx':\n return 'xlsx';\n default:\n return 'xlsb';\n }\n}\n*/\n"],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"parse-excel.js","names":["utils","read","dataTableNamesMap","parseExcel","arrayBuffer","options","dataUrl","workbook","type","dataRows","SheetNames","length","_options$excel","_options$excel2","sheetName","excel","sheet","indexOf","_options$excel3","worksheet","Sheets","sheet_to_json"],"sources":["../../../src/lib/parse-excel.ts"],"sourcesContent":["import type {ExcelLoaderOptions} from '../excel-loader';\nimport {utils, read} from 'xlsx';\n// import {convertToArrayRow} from '@loaders.gl/schema';\n\n// local table names cache with dataUrl/tableNames array key/values\nconst dataTableNamesMap = {};\n\n/**\n * Gets local or remote Excel file data.\n * @param arrayBuffer Loaded data\n * @param options Data parse options.\n */\nexport function parseExcel(\n arrayBuffer: ArrayBuffer,\n options?: ExcelLoaderOptions\n): {[key: string]: unknown}[] {\n const dataUrl = 'dummy';\n // const dataFileType: string = dataUrl.substr(dataUrl.lastIndexOf('.')); // file extension\n\n // create Excel 'workbook'\n const workbook = read(arrayBuffer, {\n type: 'array'\n // cellDates: true\n });\n\n // load data sheets\n let dataRows: {[key: string]: unknown}[] = [];\n dataTableNamesMap[dataUrl] = [];\n if (workbook.SheetNames.length > 0) {\n if (workbook.SheetNames.length > 1) {\n // cache sheet names\n dataTableNamesMap[dataUrl] = workbook.SheetNames;\n // eslint-ignore-next-line\n // console.debug(`getData(): file: sheetNames:`, workbook.SheetNames);\n }\n\n // determine spreadsheet to load\n let sheetName = workbook.SheetNames[0];\n if (options?.excel?.sheet && workbook.SheetNames.indexOf(options?.excel?.sheet) >= 0) {\n // reset to requested table name\n sheetName = options?.excel?.sheet;\n }\n\n // get worksheet data row objects array\n const worksheet = workbook.Sheets[sheetName];\n dataRows = utils.sheet_to_json(worksheet);\n\n // const headers = dataRows.length ? Object.keys(dataRows[0]) : [];\n // if (options?.excel?.type === 'array-row-table') {\n // dataRows = dataRows.map(row => convertToArrayRow(row, headers))\n // }\n }\n\n return dataRows;\n}\n"],"mappings":"AACA,SAAQA,KAAK,EAAEC,IAAI,QAAO,MAAM;AAIhC,MAAMC,iBAAiB,GAAG,CAAC,CAAC;AAO5B,OAAO,SAASC,UAAUA,CACxBC,WAAwB,EACxBC,OAA4B,EACA;EAC5B,MAAMC,OAAO,GAAG,OAAO;EAIvB,MAAMC,QAAQ,GAAGN,IAAI,CAACG,WAAW,EAAE;IACjCI,IAAI,EAAE;EAER,CAAC,CAAC;EAGF,IAAIC,QAAoC,GAAG,EAAE;EAC7CP,iBAAiB,CAACI,OAAO,CAAC,GAAG,EAAE;EAC/B,IAAIC,QAAQ,CAACG,UAAU,CAACC,MAAM,GAAG,CAAC,EAAE;IAAA,IAAAC,cAAA,EAAAC,eAAA;IAClC,IAAIN,QAAQ,CAACG,UAAU,CAACC,MAAM,GAAG,CAAC,EAAE;MAElCT,iBAAiB,CAACI,OAAO,CAAC,GAAGC,QAAQ,CAACG,UAAU;IAGlD;IAGA,IAAII,SAAS,GAAGP,QAAQ,CAACG,UAAU,CAAC,CAAC,CAAC;IACtC,IAAIL,OAAO,aAAPA,OAAO,gBAAAO,cAAA,GAAPP,OAAO,CAAEU,KAAK,cAAAH,cAAA,eAAdA,cAAA,CAAgBI,KAAK,IAAIT,QAAQ,CAACG,UAAU,CAACO,OAAO,CAACZ,OAAO,aAAPA,OAAO,wBAAAQ,eAAA,GAAPR,OAAO,CAAEU,KAAK,cAAAF,eAAA,uBAAdA,eAAA,CAAgBG,KAAK,CAAC,IAAI,CAAC,EAAE;MAAA,IAAAE,eAAA;MAEpFJ,SAAS,GAAGT,OAAO,aAAPA,OAAO,wBAAAa,eAAA,GAAPb,OAAO,CAAEU,KAAK,cAAAG,eAAA,uBAAdA,eAAA,CAAgBF,KAAK;IACnC;IAGA,MAAMG,SAAS,GAAGZ,QAAQ,CAACa,MAAM,CAACN,SAAS,CAAC;IAC5CL,QAAQ,GAAGT,KAAK,CAACqB,aAAa,CAACF,SAAS,CAAC;EAM3C;EAEA,OAAOV,QAAQ;AACjB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"excel-worker.js","names":["createLoaderWorker","ExcelLoader"],"sources":["../../../src/workers/excel-worker.ts"],"sourcesContent":["import {createLoaderWorker} from '@loaders.gl/loader-utils';\nimport {ExcelLoader} from '../index';\n\ncreateLoaderWorker(ExcelLoader);\n"],"mappings":"AAAA,SAAQA,kBAAkB,QAAO,0BAA0B;AAC3D,SAAQC,WAAW,QAAO,UAAU;AAEpCD,kBAAkB,CAACC,WAAW,CAAC"}
package/src/bundle.ts DELETED
@@ -1,4 +0,0 @@
1
- // @ts-nocheck
2
- const moduleExports = require('./index');
3
- globalThis.loaders = globalThis.loaders || {};
4
- module.exports = Object.assign(globalThis.loaders, moduleExports);
File without changes
File without changes