@loaders.gl/excel 3.2.12 → 3.3.0-alpha.10

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.
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  var moduleExports = require('./index');
4
-
5
4
  globalThis.loaders = globalThis.loaders || {};
6
5
  module.exports = Object.assign(globalThis.loaders, moduleExports);
7
6
  //# sourceMappingURL=bundle.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/bundle.ts"],"names":["moduleExports","require","globalThis","loaders","module","exports","Object","assign"],"mappings":";;AACA,IAAMA,aAAa,GAAGC,OAAO,CAAC,SAAD,CAA7B;;AACAC,UAAU,CAACC,OAAX,GAAqBD,UAAU,CAACC,OAAX,IAAsB,EAA3C;AACAC,MAAM,CAACC,OAAP,GAAiBC,MAAM,CAACC,MAAP,CAAcL,UAAU,CAACC,OAAzB,EAAkCH,aAAlC,CAAjB","sourcesContent":["// @ts-nocheck\nconst moduleExports = require('./index');\nglobalThis.loaders = globalThis.loaders || {};\nmodule.exports = Object.assign(globalThis.loaders, moduleExports);\n"],"file":"bundle.js"}
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"}
@@ -4,13 +4,14 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports._typecheckLoader = exports.ExcelLoader = void 0;
7
- var VERSION = typeof "3.2.12" !== 'undefined' ? "3.2.12" : 'latest';
7
+ var VERSION = typeof "3.3.0-alpha.10" !== 'undefined' ? "3.3.0-alpha.10" : 'latest';
8
8
  var DEFAULT_EXCEL_LOADER_OPTIONS = {
9
9
  excel: {
10
10
  shape: 'object-row-table',
11
11
  sheet: undefined
12
12
  }
13
13
  };
14
+
14
15
  var ExcelLoader = {
15
16
  name: 'Excel',
16
17
  id: 'excel',
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/excel-loader.ts"],"names":["VERSION","DEFAULT_EXCEL_LOADER_OPTIONS","excel","shape","sheet","undefined","ExcelLoader","name","id","module","version","worker","extensions","mimeTypes","category","binary","options","_typecheckLoader"],"mappings":";;;;;;AAIA,IAAMA,OAAO,GAAG,oBAAuB,WAAvB,cAAmD,QAAnE;AASA,IAAMC,4BAAgD,GAAG;AACvDC,EAAAA,KAAK,EAAE;AACLC,IAAAA,KAAK,EAAE,kBADF;AAELC,IAAAA,KAAK,EAAEC;AAFF;AADgD,CAAzD;AAUO,IAAMC,WAAW,GAAG;AACzBC,EAAAA,IAAI,EAAE,OADmB;AAEzBC,EAAAA,EAAE,EAAE,OAFqB;AAGzBC,EAAAA,MAAM,EAAE,OAHiB;AAIzBC,EAAAA,OAAO,EAAEV,OAJgB;AAKzBW,EAAAA,MAAM,EAAE,IALiB;AAMzBC,EAAAA,UAAU,EAAE,CAAC,KAAD,EAAQ,MAAR,EAAgB,MAAhB,EAAwB,MAAxB,CANa;AAOzBC,EAAAA,SAAS,EAAE,CACT,mEADS,EAET,0BAFS,CAPc;AAWzBC,EAAAA,QAAQ,EAAE,OAXe;AAYzBC,EAAAA,MAAM,EAAE,IAZiB;AAazBC,EAAAA,OAAO,EAAEf;AAbgB,CAApB;;AAgBA,IAAMgB,gBAAwB,GAAGX,WAAjC","sourcesContent":["import type {Loader, LoaderOptions} from '@loaders.gl/loader-utils';\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 = {\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\nexport const _typecheckLoader: Loader = ExcelLoader;\n"],"file":"excel-loader.js"}
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","_typecheckLoader"],"sources":["../../src/excel-loader.ts"],"sourcesContent":["import type {Loader, LoaderOptions} from '@loaders.gl/loader-utils';\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 = {\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\nexport const _typecheckLoader: Loader = ExcelLoader;\n"],"mappings":";;;;;;AAIA,IAAMA,OAAO,GAAG,uBAAkB,KAAK,WAAW,sBAAiB,QAAQ;AAS3E,IAAMC,4BAAgD,GAAG;EACvDC,KAAK,EAAE;IACLC,KAAK,EAAE,kBAAkB;IACzBC,KAAK,EAAEC;EACT;AACF,CAAC;;AAKM,IAAMC,WAAW,GAAG;EACzBC,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;AAAC;AAEK,IAAMgB,gBAAwB,GAAGX,WAAW;AAAC"}
package/dist/es5/index.js CHANGED
@@ -1,34 +1,27 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
7
+ exports.ExcelLoader = void 0;
8
8
  Object.defineProperty(exports, "ExcelWorkerLoader", {
9
9
  enumerable: true,
10
10
  get: function get() {
11
11
  return _excelLoader.ExcelLoader;
12
12
  }
13
13
  });
14
- exports._typecheckLoader = exports.ExcelLoader = void 0;
15
-
14
+ exports._typecheckLoader = void 0;
16
15
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
17
-
18
16
  var _excelLoader = require("./excel-loader");
19
-
20
17
  var _parseExcel = require("./lib/parse-excel");
21
-
22
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
23
-
24
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
25
-
18
+ 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; }
19
+ 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; }
26
20
  var ExcelLoader = _objectSpread(_objectSpread({}, _excelLoader.ExcelLoader), {}, {
27
21
  parse: function parse(arrayBuffer, options) {
28
22
  return (0, _parseExcel.parseExcel)(arrayBuffer, options);
29
23
  }
30
24
  });
31
-
32
25
  exports.ExcelLoader = ExcelLoader;
33
26
  var _typecheckLoader = ExcelLoader;
34
27
  exports._typecheckLoader = _typecheckLoader;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"names":["ExcelLoader","ExcelWorkerLoader","parse","arrayBuffer","options","_typecheckLoader"],"mappings":";;;;;;;;;;;;;;;;;AACA;;AACA;;;;;;AAUO,IAAMA,WAAW,mCACnBC,wBADmB;AAEtBC,EAAAA,KAAK,EAAE,eAACC,WAAD,EAA2BC,OAA3B;AAAA,WACL,4BAAWD,WAAX,EAAwBC,OAAxB,CADK;AAAA;AAFe,EAAjB;;;AAMA,IAAMC,gBAAkC,GAAGL,WAA3C","sourcesContent":["import type {LoaderWithParser} from '@loaders.gl/loader-utils';\nimport {ExcelLoader as ExcelWorkerLoader, ExcelLoaderOptions} 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 = {\n ...ExcelWorkerLoader,\n parse: (arrayBuffer: ArrayBuffer, options?: ExcelLoaderOptions) =>\n parseExcel(arrayBuffer, options)\n};\n\nexport const _typecheckLoader: LoaderWithParser = ExcelLoader;\n"],"file":"index.js"}
1
+ {"version":3,"file":"index.js","names":["ExcelLoader","ExcelWorkerLoader","parse","arrayBuffer","options","parseExcel","_typecheckLoader"],"sources":["../../src/index.ts"],"sourcesContent":["import type {LoaderWithParser} from '@loaders.gl/loader-utils';\nimport {ExcelLoader as ExcelWorkerLoader, ExcelLoaderOptions} 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 = {\n ...ExcelWorkerLoader,\n parse: (arrayBuffer: ArrayBuffer, options?: ExcelLoaderOptions) =>\n parseExcel(arrayBuffer, options)\n};\n\nexport const _typecheckLoader: LoaderWithParser = ExcelLoader;\n"],"mappings":";;;;;;;;;;;;;;;AACA;AACA;AAA6C;AAAA;AAUtC,IAAMA,WAAW,mCACnBC,wBAAiB;EACpBC,KAAK,EAAE,eAACC,WAAwB,EAAEC,OAA4B;IAAA,OAC5D,IAAAC,sBAAU,EAACF,WAAW,EAAEC,OAAO,CAAC;EAAA;AAAA,EACnC;AAAC;AAEK,IAAME,gBAAkC,GAAGN,WAAW;AAAC"}
@@ -1,2 +1,4 @@
1
+
2
+
1
3
  "use strict";
2
4
  //# sourceMappingURL=encode-excel.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[],"file":"encode-excel.js"}
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,16 +1,12 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.parseExcel = parseExcel;
9
-
10
8
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
-
12
9
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
13
-
14
10
  var _xlsx = require("xlsx");
15
11
 
16
12
  var dataTableNamesMap = {};
@@ -18,11 +14,9 @@ var dataTableNamesMap = {};
18
14
  function parseExcel(_x, _x2) {
19
15
  return _parseExcel.apply(this, arguments);
20
16
  }
21
-
22
17
  function _parseExcel() {
23
18
  _parseExcel = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee(arrayBuffer, options) {
24
19
  var dataUrl, workbook, dataRows, _options$excel, _options$excel2, sheetName, _options$excel3, worksheet;
25
-
26
20
  return _regenerator.default.wrap(function _callee$(_context) {
27
21
  while (1) {
28
22
  switch (_context.prev = _context.next) {
@@ -33,24 +27,21 @@ function _parseExcel() {
33
27
  });
34
28
  dataRows = [];
35
29
  dataTableNamesMap[dataUrl] = [];
36
-
37
30
  if (workbook.SheetNames.length > 0) {
38
31
  if (workbook.SheetNames.length > 1) {
39
32
  dataTableNamesMap[dataUrl] = workbook.SheetNames;
40
33
  }
41
34
 
42
35
  sheetName = workbook.SheetNames[0];
43
-
44
36
  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) {
45
37
  sheetName = options === null || options === void 0 ? void 0 : (_options$excel3 = options.excel) === null || _options$excel3 === void 0 ? void 0 : _options$excel3.sheet;
46
38
  }
47
39
 
48
40
  worksheet = workbook.Sheets[sheetName];
49
41
  dataRows = _xlsx.utils.sheet_to_json(worksheet);
50
- }
51
42
 
43
+ }
52
44
  return _context.abrupt("return", dataRows);
53
-
54
45
  case 6:
55
46
  case "end":
56
47
  return _context.stop();
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/lib/parse-excel.ts"],"names":["dataTableNamesMap","parseExcel","arrayBuffer","options","dataUrl","workbook","type","dataRows","SheetNames","length","sheetName","excel","sheet","indexOf","worksheet","Sheets","utils","sheet_to_json"],"mappings":";;;;;;;;;;;;;AACA;;AAIA,IAAMA,iBAAiB,GAAG,EAA1B;;SAOsBC,U;;;;;0EAAf,iBAA0BC,WAA1B,EAAoDC,OAApD;AAAA;;AAAA;AAAA;AAAA;AAAA;AACCC,YAAAA,OADD,GACW,OADX;AAKCC,YAAAA,QALD,GAKY,gBAAKH,WAAL,EAAkB;AACjCI,cAAAA,IAAI,EAAE;AAD2B,aAAlB,CALZ;AAWDC,YAAAA,QAXC,GAWU,EAXV;AAYLP,YAAAA,iBAAiB,CAACI,OAAD,CAAjB,GAA6B,EAA7B;;AACA,gBAAIC,QAAQ,CAACG,UAAT,CAAoBC,MAApB,GAA6B,CAAjC,EAAoC;AAClC,kBAAIJ,QAAQ,CAACG,UAAT,CAAoBC,MAApB,GAA6B,CAAjC,EAAoC;AAElCT,gBAAAA,iBAAiB,CAACI,OAAD,CAAjB,GAA6BC,QAAQ,CAACG,UAAtC;AAGD;;AAGGE,cAAAA,SAT8B,GASlBL,QAAQ,CAACG,UAAT,CAAoB,CAApB,CATkB;;AAUlC,kBAAIL,OAAO,SAAP,IAAAA,OAAO,WAAP,sBAAAA,OAAO,CAAEQ,KAAT,0DAAgBC,KAAhB,IAAyBP,QAAQ,CAACG,UAAT,CAAoBK,OAApB,CAA4BV,OAA5B,aAA4BA,OAA5B,0CAA4BA,OAAO,CAAEQ,KAArC,oDAA4B,gBAAgBC,KAA5C,KAAsD,CAAnF,EAAsF;AAEpFF,gBAAAA,SAAS,GAAGP,OAAH,aAAGA,OAAH,0CAAGA,OAAO,CAAEQ,KAAZ,oDAAG,gBAAgBC,KAA5B;AACD;;AAGKE,cAAAA,SAhB4B,GAgBhBT,QAAQ,CAACU,MAAT,CAAgBL,SAAhB,CAhBgB;AAiBlCH,cAAAA,QAAQ,GAAGS,YAAMC,aAAN,CAAoBH,SAApB,CAAX;AAMD;;AApCI,6CAsCEP,QAtCF;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,G","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 async function parseExcel(arrayBuffer: ArrayBuffer, options?: ExcelLoaderOptions) {\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 = [];\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"],"file":"parse-excel.js"}
1
+ {"version":3,"file":"parse-excel.js","names":["dataTableNamesMap","parseExcel","arrayBuffer","options","dataUrl","workbook","read","type","dataRows","SheetNames","length","sheetName","excel","sheet","indexOf","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 async function parseExcel(arrayBuffer: ArrayBuffer, options?: ExcelLoaderOptions) {\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 = [];\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;;AAIA,IAAMA,iBAAiB,GAAG,CAAC,CAAC;;AAAC,SAOPC,UAAU;EAAA;AAAA;AAAA;EAAA,wEAAzB,iBAA0BC,WAAwB,EAAEC,OAA4B;IAAA;IAAA;MAAA;QAAA;UAAA;YAC/EC,OAAO,GAAG,OAAO;YAIjBC,QAAQ,GAAG,IAAAC,UAAI,EAACJ,WAAW,EAAE;cACjCK,IAAI,EAAE;YAER,CAAC,CAAC;YAGEC,QAAQ,GAAG,EAAE;YACjBR,iBAAiB,CAACI,OAAO,CAAC,GAAG,EAAE;YAC/B,IAAIC,QAAQ,CAACI,UAAU,CAACC,MAAM,GAAG,CAAC,EAAE;cAClC,IAAIL,QAAQ,CAACI,UAAU,CAACC,MAAM,GAAG,CAAC,EAAE;gBAElCV,iBAAiB,CAACI,OAAO,CAAC,GAAGC,QAAQ,CAACI,UAAU;cAGlD;;cAGIE,SAAS,GAAGN,QAAQ,CAACI,UAAU,CAAC,CAAC,CAAC;cACtC,IAAIN,OAAO,aAAPA,OAAO,iCAAPA,OAAO,CAAES,KAAK,2CAAd,eAAgBC,KAAK,IAAIR,QAAQ,CAACI,UAAU,CAACK,OAAO,CAACX,OAAO,aAAPA,OAAO,0CAAPA,OAAO,CAAES,KAAK,oDAAd,gBAAgBC,KAAK,CAAC,IAAI,CAAC,EAAE;gBAEpFF,SAAS,GAAGR,OAAO,aAAPA,OAAO,0CAAPA,OAAO,CAAES,KAAK,oDAAd,gBAAgBC,KAAK;cACnC;;cAGME,SAAS,GAAGV,QAAQ,CAACW,MAAM,CAACL,SAAS,CAAC;cAC5CH,QAAQ,GAAGS,WAAK,CAACC,aAAa,CAACH,SAAS,CAAC;;YAM3C;YAAC,iCAEMP,QAAQ;UAAA;UAAA;YAAA;QAAA;MAAA;IAAA;EAAA,CAChB;EAAA;AAAA"}
@@ -1,8 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  var _loaderUtils = require("@loaders.gl/loader-utils");
4
-
5
4
  var _index = require("../index");
6
-
7
5
  (0, _loaderUtils.createLoaderWorker)(_index.ExcelLoader);
8
6
  //# sourceMappingURL=excel-worker.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/workers/excel-worker.ts"],"names":["ExcelLoader"],"mappings":";;AAAA;;AACA;;AAEA,qCAAmBA,kBAAnB","sourcesContent":["import {createLoaderWorker} from '@loaders.gl/loader-utils';\nimport {ExcelLoader} from '../index';\n\ncreateLoaderWorker(ExcelLoader);\n"],"file":"excel-worker.js"}
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;AACA;AAEA,IAAAA,+BAAkB,EAACC,kBAAW,CAAC"}
@@ -1,5 +1,5 @@
1
- const moduleExports = require('./index');
2
1
 
2
+ const moduleExports = require('./index');
3
3
  globalThis.loaders = globalThis.loaders || {};
4
4
  module.exports = Object.assign(globalThis.loaders, moduleExports);
5
5
  //# sourceMappingURL=bundle.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/bundle.ts"],"names":["moduleExports","require","globalThis","loaders","module","exports","Object","assign"],"mappings":"AACA,MAAMA,aAAa,GAAGC,OAAO,CAAC,SAAD,CAA7B;;AACAC,UAAU,CAACC,OAAX,GAAqBD,UAAU,CAACC,OAAX,IAAsB,EAA3C;AACAC,MAAM,CAACC,OAAP,GAAiBC,MAAM,CAACC,MAAP,CAAcL,UAAU,CAACC,OAAzB,EAAkCH,aAAlC,CAAjB","sourcesContent":["// @ts-nocheck\nconst moduleExports = require('./index');\nglobalThis.loaders = globalThis.loaders || {};\nmodule.exports = Object.assign(globalThis.loaders, moduleExports);\n"],"file":"bundle.js"}
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,10 +1,12 @@
1
- const VERSION = typeof "3.2.12" !== 'undefined' ? "3.2.12" : 'latest';
1
+
2
+ const VERSION = typeof "3.3.0-alpha.10" !== 'undefined' ? "3.3.0-alpha.10" : 'latest';
2
3
  const DEFAULT_EXCEL_LOADER_OPTIONS = {
3
4
  excel: {
4
5
  shape: 'object-row-table',
5
6
  sheet: undefined
6
7
  }
7
8
  };
9
+
8
10
  export const ExcelLoader = {
9
11
  name: 'Excel',
10
12
  id: 'excel',
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/excel-loader.ts"],"names":["VERSION","DEFAULT_EXCEL_LOADER_OPTIONS","excel","shape","sheet","undefined","ExcelLoader","name","id","module","version","worker","extensions","mimeTypes","category","binary","options","_typecheckLoader"],"mappings":"AAIA,MAAMA,OAAO,GAAG,oBAAuB,WAAvB,cAAmD,QAAnE;AASA,MAAMC,4BAAgD,GAAG;AACvDC,EAAAA,KAAK,EAAE;AACLC,IAAAA,KAAK,EAAE,kBADF;AAELC,IAAAA,KAAK,EAAEC;AAFF;AADgD,CAAzD;AAUA,OAAO,MAAMC,WAAW,GAAG;AACzBC,EAAAA,IAAI,EAAE,OADmB;AAEzBC,EAAAA,EAAE,EAAE,OAFqB;AAGzBC,EAAAA,MAAM,EAAE,OAHiB;AAIzBC,EAAAA,OAAO,EAAEV,OAJgB;AAKzBW,EAAAA,MAAM,EAAE,IALiB;AAMzBC,EAAAA,UAAU,EAAE,CAAC,KAAD,EAAQ,MAAR,EAAgB,MAAhB,EAAwB,MAAxB,CANa;AAOzBC,EAAAA,SAAS,EAAE,CACT,mEADS,EAET,0BAFS,CAPc;AAWzBC,EAAAA,QAAQ,EAAE,OAXe;AAYzBC,EAAAA,MAAM,EAAE,IAZiB;AAazBC,EAAAA,OAAO,EAAEf;AAbgB,CAApB;AAgBP,OAAO,MAAMgB,gBAAwB,GAAGX,WAAjC","sourcesContent":["import type {Loader, LoaderOptions} from '@loaders.gl/loader-utils';\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 = {\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\nexport const _typecheckLoader: Loader = ExcelLoader;\n"],"file":"excel-loader.js"}
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","_typecheckLoader"],"sources":["../../src/excel-loader.ts"],"sourcesContent":["import type {Loader, LoaderOptions} from '@loaders.gl/loader-utils';\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 = {\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\nexport const _typecheckLoader: Loader = ExcelLoader;\n"],"mappings":";AAIA,MAAMA,OAAO,GAAG,uBAAkB,KAAK,WAAW,sBAAiB,QAAQ;AAS3E,MAAMC,4BAAgD,GAAG;EACvDC,KAAK,EAAE;IACLC,KAAK,EAAE,kBAAkB;IACzBC,KAAK,EAAEC;EACT;AACF,CAAC;;AAKD,OAAO,MAAMC,WAAW,GAAG;EACzBC,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;AAED,OAAO,MAAMgB,gBAAwB,GAAGX,WAAW"}
package/dist/esm/index.js CHANGED
@@ -1,7 +1,10 @@
1
1
  import { ExcelLoader as ExcelWorkerLoader } from './excel-loader';
2
2
  import { parseExcel } from './lib/parse-excel';
3
+
3
4
  export { ExcelWorkerLoader };
4
- export const ExcelLoader = { ...ExcelWorkerLoader,
5
+
6
+ export const ExcelLoader = {
7
+ ...ExcelWorkerLoader,
5
8
  parse: (arrayBuffer, options) => parseExcel(arrayBuffer, options)
6
9
  };
7
10
  export const _typecheckLoader = ExcelLoader;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"names":["ExcelLoader","ExcelWorkerLoader","parseExcel","parse","arrayBuffer","options","_typecheckLoader"],"mappings":"AACA,SAAQA,WAAW,IAAIC,iBAAvB,QAAmE,gBAAnE;AACA,SAAQC,UAAR,QAAyB,mBAAzB;AAKA,SAAQD,iBAAR;AAKA,OAAO,MAAMD,WAAW,GAAG,EACzB,GAAGC,iBADsB;AAEzBE,EAAAA,KAAK,EAAE,CAACC,WAAD,EAA2BC,OAA3B,KACLH,UAAU,CAACE,WAAD,EAAcC,OAAd;AAHa,CAApB;AAMP,OAAO,MAAMC,gBAAkC,GAAGN,WAA3C","sourcesContent":["import type {LoaderWithParser} from '@loaders.gl/loader-utils';\nimport {ExcelLoader as ExcelWorkerLoader, ExcelLoaderOptions} 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 = {\n ...ExcelWorkerLoader,\n parse: (arrayBuffer: ArrayBuffer, options?: ExcelLoaderOptions) =>\n parseExcel(arrayBuffer, options)\n};\n\nexport const _typecheckLoader: LoaderWithParser = ExcelLoader;\n"],"file":"index.js"}
1
+ {"version":3,"file":"index.js","names":["ExcelLoader","ExcelWorkerLoader","parseExcel","parse","arrayBuffer","options","_typecheckLoader"],"sources":["../../src/index.ts"],"sourcesContent":["import type {LoaderWithParser} from '@loaders.gl/loader-utils';\nimport {ExcelLoader as ExcelWorkerLoader, ExcelLoaderOptions} 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 = {\n ...ExcelWorkerLoader,\n parse: (arrayBuffer: ArrayBuffer, options?: ExcelLoaderOptions) =>\n parseExcel(arrayBuffer, options)\n};\n\nexport const _typecheckLoader: LoaderWithParser = ExcelLoader;\n"],"mappings":"AACA,SAAQA,WAAW,IAAIC,iBAAiB,QAA2B,gBAAgB;AACnF,SAAQC,UAAU,QAAO,mBAAmB;;AAK5C,SAAQD,iBAAiB;;AAKzB,OAAO,MAAMD,WAAW,GAAG;EACzB,GAAGC,iBAAiB;EACpBE,KAAK,EAAE,CAACC,WAAwB,EAAEC,OAA4B,KAC5DH,UAAU,CAACE,WAAW,EAAEC,OAAO;AACnC,CAAC;AAED,OAAO,MAAMC,gBAAkC,GAAGN,WAAW"}
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[],"file":"encode-excel.js"}
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,30 +1,31 @@
1
1
  import { utils, read } from 'xlsx';
2
+
2
3
  const dataTableNamesMap = {};
4
+
3
5
  export async function parseExcel(arrayBuffer, options) {
4
6
  const dataUrl = 'dummy';
7
+
5
8
  const workbook = read(arrayBuffer, {
6
9
  type: 'array'
7
10
  });
11
+
8
12
  let dataRows = [];
9
13
  dataTableNamesMap[dataUrl] = [];
10
-
11
14
  if (workbook.SheetNames.length > 0) {
12
15
  var _options$excel, _options$excel2;
13
-
14
16
  if (workbook.SheetNames.length > 1) {
15
17
  dataTableNamesMap[dataUrl] = workbook.SheetNames;
16
18
  }
17
19
 
18
20
  let sheetName = workbook.SheetNames[0];
19
-
20
21
  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) {
21
22
  var _options$excel3;
22
-
23
23
  sheetName = options === null || options === void 0 ? void 0 : (_options$excel3 = options.excel) === null || _options$excel3 === void 0 ? void 0 : _options$excel3.sheet;
24
24
  }
25
25
 
26
26
  const worksheet = workbook.Sheets[sheetName];
27
27
  dataRows = utils.sheet_to_json(worksheet);
28
+
28
29
  }
29
30
 
30
31
  return dataRows;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/lib/parse-excel.ts"],"names":["utils","read","dataTableNamesMap","parseExcel","arrayBuffer","options","dataUrl","workbook","type","dataRows","SheetNames","length","sheetName","excel","sheet","indexOf","worksheet","Sheets","sheet_to_json"],"mappings":"AACA,SAAQA,KAAR,EAAeC,IAAf,QAA0B,MAA1B;AAIA,MAAMC,iBAAiB,GAAG,EAA1B;AAOA,OAAO,eAAeC,UAAf,CAA0BC,WAA1B,EAAoDC,OAApD,EAAkF;AACvF,QAAMC,OAAO,GAAG,OAAhB;AAIA,QAAMC,QAAQ,GAAGN,IAAI,CAACG,WAAD,EAAc;AACjCI,IAAAA,IAAI,EAAE;AAD2B,GAAd,CAArB;AAMA,MAAIC,QAAQ,GAAG,EAAf;AACAP,EAAAA,iBAAiB,CAACI,OAAD,CAAjB,GAA6B,EAA7B;;AACA,MAAIC,QAAQ,CAACG,UAAT,CAAoBC,MAApB,GAA6B,CAAjC,EAAoC;AAAA;;AAClC,QAAIJ,QAAQ,CAACG,UAAT,CAAoBC,MAApB,GAA6B,CAAjC,EAAoC;AAElCT,MAAAA,iBAAiB,CAACI,OAAD,CAAjB,GAA6BC,QAAQ,CAACG,UAAtC;AAGD;;AAGD,QAAIE,SAAS,GAAGL,QAAQ,CAACG,UAAT,CAAoB,CAApB,CAAhB;;AACA,QAAIL,OAAO,SAAP,IAAAA,OAAO,WAAP,sBAAAA,OAAO,CAAEQ,KAAT,0DAAgBC,KAAhB,IAAyBP,QAAQ,CAACG,UAAT,CAAoBK,OAApB,CAA4BV,OAA5B,aAA4BA,OAA5B,0CAA4BA,OAAO,CAAEQ,KAArC,oDAA4B,gBAAgBC,KAA5C,KAAsD,CAAnF,EAAsF;AAAA;;AAEpFF,MAAAA,SAAS,GAAGP,OAAH,aAAGA,OAAH,0CAAGA,OAAO,CAAEQ,KAAZ,oDAAG,gBAAgBC,KAA5B;AACD;;AAGD,UAAME,SAAS,GAAGT,QAAQ,CAACU,MAAT,CAAgBL,SAAhB,CAAlB;AACAH,IAAAA,QAAQ,GAAGT,KAAK,CAACkB,aAAN,CAAoBF,SAApB,CAAX;AAMD;;AAED,SAAOP,QAAP;AACD","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 async function parseExcel(arrayBuffer: ArrayBuffer, options?: ExcelLoaderOptions) {\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 = [];\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"],"file":"parse-excel.js"}
1
+ {"version":3,"file":"parse-excel.js","names":["utils","read","dataTableNamesMap","parseExcel","arrayBuffer","options","dataUrl","workbook","type","dataRows","SheetNames","length","sheetName","excel","sheet","indexOf","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 async function parseExcel(arrayBuffer: ArrayBuffer, options?: ExcelLoaderOptions) {\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 = [];\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,eAAeC,UAAU,CAACC,WAAwB,EAAEC,OAA4B,EAAE;EACvF,MAAMC,OAAO,GAAG,OAAO;;EAIvB,MAAMC,QAAQ,GAAGN,IAAI,CAACG,WAAW,EAAE;IACjCI,IAAI,EAAE;EAER,CAAC,CAAC;;EAGF,IAAIC,QAAQ,GAAG,EAAE;EACjBP,iBAAiB,CAACI,OAAO,CAAC,GAAG,EAAE;EAC/B,IAAIC,QAAQ,CAACG,UAAU,CAACC,MAAM,GAAG,CAAC,EAAE;IAAA;IAClC,IAAIJ,QAAQ,CAACG,UAAU,CAACC,MAAM,GAAG,CAAC,EAAE;MAElCT,iBAAiB,CAACI,OAAO,CAAC,GAAGC,QAAQ,CAACG,UAAU;IAGlD;;IAGA,IAAIE,SAAS,GAAGL,QAAQ,CAACG,UAAU,CAAC,CAAC,CAAC;IACtC,IAAIL,OAAO,aAAPA,OAAO,iCAAPA,OAAO,CAAEQ,KAAK,2CAAd,eAAgBC,KAAK,IAAIP,QAAQ,CAACG,UAAU,CAACK,OAAO,CAACV,OAAO,aAAPA,OAAO,0CAAPA,OAAO,CAAEQ,KAAK,oDAAd,gBAAgBC,KAAK,CAAC,IAAI,CAAC,EAAE;MAAA;MAEpFF,SAAS,GAAGP,OAAO,aAAPA,OAAO,0CAAPA,OAAO,CAAEQ,KAAK,oDAAd,gBAAgBC,KAAK;IACnC;;IAGA,MAAME,SAAS,GAAGT,QAAQ,CAACU,MAAM,CAACL,SAAS,CAAC;IAC5CH,QAAQ,GAAGT,KAAK,CAACkB,aAAa,CAACF,SAAS,CAAC;;EAM3C;;EAEA,OAAOP,QAAQ;AACjB"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/workers/excel-worker.ts"],"names":["createLoaderWorker","ExcelLoader"],"mappings":"AAAA,SAAQA,kBAAR,QAAiC,0BAAjC;AACA,SAAQC,WAAR,QAA0B,UAA1B;AAEAD,kBAAkB,CAACC,WAAD,CAAlB","sourcesContent":["import {createLoaderWorker} from '@loaders.gl/loader-utils';\nimport {ExcelLoader} from '../index';\n\ncreateLoaderWorker(ExcelLoader);\n"],"file":"excel-worker.js"}
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"}
@@ -1,5 +1,5 @@
1
1
  import type { Loader, LoaderOptions } from '@loaders.gl/loader-utils';
2
- export declare type ExcelLoaderOptions = LoaderOptions & {
2
+ export type ExcelLoaderOptions = LoaderOptions & {
3
3
  excel?: {
4
4
  shape: 'object-row-table';
5
5
  sheet?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"excel-loader.d.ts","sourceRoot":"","sources":["../src/excel-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,MAAM,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAMpE,oBAAY,kBAAkB,GAAG,aAAa,GAAG;IAC/C,KAAK,CAAC,EAAE;QACN,KAAK,EAA4B,kBAAkB,CAAC;QACpD,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;CACH,CAAC;AASF;;GAEG;AACH,eAAO,MAAM,WAAW;;;;;;;;;;;CAcvB,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,MAAoB,CAAC"}
1
+ {"version":3,"file":"excel-loader.d.ts","sourceRoot":"","sources":["../src/excel-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,MAAM,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAMpE,MAAM,MAAM,kBAAkB,GAAG,aAAa,GAAG;IAC/C,KAAK,CAAC,EAAE;QACN,KAAK,EAA4B,kBAAkB,CAAC;QACpD,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;CACH,CAAC;AASF;;GAEG;AACH,eAAO,MAAM,WAAW;;;;;;;;;;;CAcvB,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,MAAoB,CAAC"}