@loaders.gl/excel 3.4.6 → 4.0.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.
package/dist/dist.min.js CHANGED
@@ -35807,7 +35807,7 @@
35807
35807
  });
35808
35808
 
35809
35809
  // src/lib/parse-excel.ts
35810
- async function parseExcel(arrayBuffer, options) {
35810
+ function parseExcel(arrayBuffer, options) {
35811
35811
  const dataUrl = "dummy";
35812
35812
  const workbook = (0, import_xlsx.read)(arrayBuffer, {
35813
35813
  type: "array"
@@ -35839,19 +35839,20 @@
35839
35839
  var src_exports = {};
35840
35840
  __export(src_exports, {
35841
35841
  ExcelLoader: () => ExcelLoader2,
35842
- ExcelWorkerLoader: () => ExcelLoader,
35843
- _typecheckLoader: () => _typecheckLoader
35842
+ ExcelWorkerLoader: () => ExcelLoader
35844
35843
  });
35845
- var ExcelLoader2, _typecheckLoader;
35844
+ var ExcelLoader2;
35846
35845
  var init_src = __esm({
35847
35846
  "src/index.ts"() {
35848
35847
  init_excel_loader();
35849
35848
  init_parse_excel();
35850
35849
  ExcelLoader2 = {
35851
35850
  ...ExcelLoader,
35852
- parse: (arrayBuffer, options) => parseExcel(arrayBuffer, options)
35851
+ async parse(arrayBuffer, options) {
35852
+ const data = parseExcel(arrayBuffer, options);
35853
+ return { shape: "object-row-table", data };
35854
+ }
35853
35855
  };
35854
- _typecheckLoader = ExcelLoader2;
35855
35856
  }
35856
35857
  });
35857
35858
 
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports._typecheckLoader = exports.ExcelLoader = void 0;
7
- var VERSION = typeof "3.4.6" !== 'undefined' ? "3.4.6" : 'latest';
7
+ var VERSION = typeof "4.0.0-alpha.10" !== 'undefined' ? "4.0.0-alpha.10" : 'latest';
8
8
  var DEFAULT_EXCEL_LOADER_OPTIONS = {
9
9
  excel: {
10
10
  shape: 'object-row-table',
@@ -1 +1 @@
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","_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,cAAkB,KAAK,WAAW,aAAiB,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;AAACgB,OAAA,CAAAX,WAAA,GAAAA,WAAA;AAEK,IAAMY,gBAAwB,GAAGZ,WAAW;AAACW,OAAA,CAAAC,gBAAA,GAAAA,gBAAA"}
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","_typecheckLoader"],"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\nexport const _typecheckLoader: Loader = ExcelLoader;\n"],"mappings":";;;;;;AAOA,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,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;AAEK,IAAMY,gBAAwB,GAAGZ,WAAW;AAACW,OAAA,CAAAC,gBAAA,GAAAA,gBAAA"}
package/dist/es5/index.js CHANGED
@@ -11,7 +11,8 @@ Object.defineProperty(exports, "ExcelWorkerLoader", {
11
11
  return _excelLoader.ExcelLoader;
12
12
  }
13
13
  });
14
- exports._typecheckLoader = void 0;
14
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
15
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
15
16
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
16
17
  var _excelLoader = require("./excel-loader");
17
18
  var _parseExcel = require("./lib/parse-excel");
@@ -19,10 +20,23 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
19
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; }
20
21
  var ExcelLoader = _objectSpread(_objectSpread({}, _excelLoader.ExcelLoader), {}, {
21
22
  parse: function parse(arrayBuffer, options) {
22
- return (0, _parseExcel.parseExcel)(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
+ }))();
23
39
  }
24
40
  });
25
41
  exports.ExcelLoader = ExcelLoader;
26
- var _typecheckLoader = ExcelLoader;
27
- exports._typecheckLoader = _typecheckLoader;
28
42
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
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","parseExcel","exports","_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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,wBAAiB;EACpBC,KAAK,EAAE,SAAAA,MAACC,WAAwB,EAAEC,OAA4B;IAAA,OAC5D,IAAAC,sBAAU,EAACF,WAAW,EAAEC,OAAO,CAAC;EAAA;AAAA,EACnC;AAACE,OAAA,CAAAN,WAAA,GAAAA,WAAA;AAEK,IAAMO,gBAAkC,GAAGP,WAAW;AAACM,OAAA,CAAAC,gBAAA,GAAAA,gBAAA"}
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,IA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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,47 +1,31 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
6
  exports.parseExcel = parseExcel;
8
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
10
7
  var _xlsx = require("xlsx");
11
8
  var dataTableNamesMap = {};
12
- function parseExcel(_x, _x2) {
13
- return _parseExcel.apply(this, arguments);
14
- }
15
- function _parseExcel() {
16
- _parseExcel = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee(arrayBuffer, options) {
17
- var dataUrl, workbook, dataRows, _options$excel, _options$excel2, sheetName, _options$excel3, worksheet;
18
- return _regenerator.default.wrap(function _callee$(_context) {
19
- while (1) switch (_context.prev = _context.next) {
20
- case 0:
21
- dataUrl = 'dummy';
22
- workbook = (0, _xlsx.read)(arrayBuffer, {
23
- type: 'array'
24
- });
25
- dataRows = [];
26
- dataTableNamesMap[dataUrl] = [];
27
- if (workbook.SheetNames.length > 0) {
28
- if (workbook.SheetNames.length > 1) {
29
- dataTableNamesMap[dataUrl] = workbook.SheetNames;
30
- }
31
- sheetName = workbook.SheetNames[0];
32
- 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) {
33
- sheetName = options === null || options === void 0 ? void 0 : (_options$excel3 = options.excel) === null || _options$excel3 === void 0 ? void 0 : _options$excel3.sheet;
34
- }
35
- worksheet = workbook.Sheets[sheetName];
36
- dataRows = _xlsx.utils.sheet_to_json(worksheet);
37
- }
38
- return _context.abrupt("return", dataRows);
39
- case 6:
40
- case "end":
41
- return _context.stop();
42
- }
43
- }, _callee);
44
- }));
45
- return _parseExcel.apply(this, arguments);
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;
46
30
  }
47
31
  //# sourceMappingURL=parse-excel.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"parse-excel.js","names":["_xlsx","require","dataTableNamesMap","parseExcel","_x","_x2","_parseExcel","apply","arguments","_asyncToGenerator2","default","_regenerator","mark","_callee","arrayBuffer","options","dataUrl","workbook","dataRows","_options$excel","_options$excel2","sheetName","_options$excel3","worksheet","wrap","_callee$","_context","prev","next","read","type","SheetNames","length","excel","sheet","indexOf","Sheets","utils","sheet_to_json","abrupt","stop"],"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,IAAAA,KAAA,GAAAC,OAAA;AAIA,IAAMC,iBAAiB,GAAG,CAAC,CAAC;AAAC,SAOPC,UAAUA,CAAAC,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A,OAAO,wBAAAO,eAAA,GAAPP,OAAO,CAAEkB,KAAK,cAAAX,eAAA,uBAAdA,eAAA,CAAgBY,KAAK;YACnC;YAGMX,SAAS,GAAGN,QAAQ,CAACmB,MAAM,CAACf,SAAS,CAAC;YAC5CH,QAAQ,GAAGmB,WAAK,CAACC,aAAa,CAACf,SAAS,CAAC;UAM3C;UAAC,OAAAG,QAAA,CAAAa,MAAA,WAEMrB,QAAQ;QAAA;QAAA;UAAA,OAAAQ,QAAA,CAAAc,IAAA;MAAA;IAAA,GAAA3B,OAAA;EAAA,CAChB;EAAA,OAAAP,WAAA,CAAAC,KAAA,OAAAC,SAAA;AAAA"}
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,4 +1,4 @@
1
- const VERSION = typeof "3.4.6" !== 'undefined' ? "3.4.6" : 'latest';
1
+ const VERSION = typeof "4.0.0-alpha.10" !== 'undefined' ? "4.0.0-alpha.10" : 'latest';
2
2
  const DEFAULT_EXCEL_LOADER_OPTIONS = {
3
3
  excel: {
4
4
  shape: 'object-row-table',
@@ -1 +1 @@
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,cAAkB,KAAK,WAAW,aAAiB,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"}
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":["// 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\nexport const _typecheckLoader: Loader = ExcelLoader;\n"],"mappings":"AAOA,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,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;AAED,OAAO,MAAMgB,gBAAwB,GAAGX,WAAW"}
package/dist/esm/index.js CHANGED
@@ -3,7 +3,12 @@ import { parseExcel } from './lib/parse-excel';
3
3
  export { ExcelWorkerLoader };
4
4
  export const ExcelLoader = {
5
5
  ...ExcelWorkerLoader,
6
- parse: (arrayBuffer, options) => parseExcel(arrayBuffer, options)
6
+ async parse(arrayBuffer, options) {
7
+ const data = parseExcel(arrayBuffer, options);
8
+ return {
9
+ shape: 'object-row-table',
10
+ data
11
+ };
12
+ }
7
13
  };
8
- export const _typecheckLoader = ExcelLoader;
9
14
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
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,EAAEA,CAACC,WAAwB,EAAEC,OAA4B,KAC5DH,UAAU,CAACE,WAAW,EAAEC,OAAO;AACnC,CAAC;AAED,OAAO,MAAMC,gBAAkC,GAAGN,WAAW"}
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,6 +1,6 @@
1
1
  import { utils, read } from 'xlsx';
2
2
  const dataTableNamesMap = {};
3
- export async function parseExcel(arrayBuffer, options) {
3
+ export function parseExcel(arrayBuffer, options) {
4
4
  const dataUrl = 'dummy';
5
5
  const workbook = read(arrayBuffer, {
6
6
  type: 'array'
@@ -1 +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 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,UAAUA,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,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
+ {"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,5 @@
1
1
  import type { Loader, LoaderOptions } from '@loaders.gl/loader-utils';
2
+ import type { ObjectRowTable } from '@loaders.gl/schema';
2
3
  export type ExcelLoaderOptions = LoaderOptions & {
3
4
  excel?: {
4
5
  shape: 'object-row-table';
@@ -8,17 +9,6 @@ export type ExcelLoaderOptions = LoaderOptions & {
8
9
  /**
9
10
  * Worker Loader for Excel files
10
11
  */
11
- export declare const ExcelLoader: {
12
- name: string;
13
- id: string;
14
- module: string;
15
- version: any;
16
- worker: boolean;
17
- extensions: string[];
18
- mimeTypes: string[];
19
- category: string;
20
- binary: boolean;
21
- options: ExcelLoaderOptions;
22
- };
12
+ export declare const ExcelLoader: Loader<ObjectRowTable, never, ExcelLoaderOptions>;
23
13
  export declare const _typecheckLoader: Loader;
24
14
  //# sourceMappingURL=excel-loader.d.ts.map
@@ -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,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"}
1
+ {"version":3,"file":"excel-loader.d.ts","sourceRoot":"","sources":["../src/excel-loader.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,MAAM,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAC;AACpE,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,oBAAoB,CAAC;AAMvD,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,EAAE,MAAM,CAAC,cAAc,EAAE,KAAK,EAAE,kBAAkB,CAczE,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,MAAoB,CAAC"}
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ // loaders.gl, MIT license
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
4
  exports._typecheckLoader = exports.ExcelLoader = void 0;
4
5
  // __VERSION__ is injected by babel-plugin-version-inline
@@ -35954,7 +35954,7 @@
35954
35954
  }
35955
35955
 
35956
35956
  // src/excel-loader.ts
35957
- var VERSION = true ? "3.4.6" : "latest";
35957
+ var VERSION = true ? "4.0.0-alpha.10" : "latest";
35958
35958
  var DEFAULT_EXCEL_LOADER_OPTIONS = {
35959
35959
  excel: {
35960
35960
  shape: "object-row-table",
@@ -35980,7 +35980,7 @@
35980
35980
  // src/lib/parse-excel.ts
35981
35981
  var import_xlsx = __toModule(require_xlsx());
35982
35982
  var dataTableNamesMap = {};
35983
- async function parseExcel(arrayBuffer, options) {
35983
+ function parseExcel(arrayBuffer, options) {
35984
35984
  const dataUrl = "dummy";
35985
35985
  const workbook = (0, import_xlsx.read)(arrayBuffer, {
35986
35986
  type: "array"
@@ -36004,7 +36004,10 @@
36004
36004
  // src/index.ts
36005
36005
  var ExcelLoader2 = {
36006
36006
  ...ExcelLoader,
36007
- parse: (arrayBuffer, options) => parseExcel(arrayBuffer, options)
36007
+ async parse(arrayBuffer, options) {
36008
+ const data = parseExcel(arrayBuffer, options);
36009
+ return { shape: "object-row-table", data };
36010
+ }
36008
36011
  };
36009
36012
 
36010
36013
  // src/workers/excel-worker.ts
package/dist/index.d.ts CHANGED
@@ -1,22 +1,11 @@
1
1
  import type { LoaderWithParser } from '@loaders.gl/loader-utils';
2
- import { ExcelLoader as ExcelWorkerLoader, ExcelLoaderOptions } from './excel-loader';
2
+ import type { ObjectRowTable } from '@loaders.gl/schema';
3
+ import type { ExcelLoaderOptions } from './excel-loader';
4
+ import { ExcelLoader as ExcelWorkerLoader } from './excel-loader';
3
5
  export type { ExcelLoaderOptions };
4
6
  export { ExcelWorkerLoader };
5
7
  /**
6
8
  * Loader for Excel files
7
9
  */
8
- export declare const ExcelLoader: {
9
- parse: (arrayBuffer: ArrayBuffer, options?: ExcelLoaderOptions) => Promise<never[]>;
10
- name: string;
11
- id: string;
12
- module: string;
13
- version: any;
14
- worker: boolean;
15
- extensions: string[];
16
- mimeTypes: string[];
17
- category: string;
18
- binary: boolean;
19
- options: ExcelLoaderOptions;
20
- };
21
- export declare const _typecheckLoader: LoaderWithParser;
10
+ export declare const ExcelLoader: LoaderWithParser<ObjectRowTable, never, ExcelLoaderOptions>;
22
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAC,WAAW,IAAI,iBAAiB,EAAE,kBAAkB,EAAC,MAAM,gBAAgB,CAAC;AAKpF,YAAY,EAAC,kBAAkB,EAAC,CAAC;AACjC,OAAO,EAAC,iBAAiB,EAAC,CAAC;AAE3B;;GAEG;AACH,eAAO,MAAM,WAAW;yBAED,WAAW,YAAY,kBAAkB;;;;;;;;;;;CAE/D,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,gBAA8B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAC/D,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAC,WAAW,IAAI,iBAAiB,EAAC,MAAM,gBAAgB,CAAC;AAKhE,YAAY,EAAC,kBAAkB,EAAC,CAAC;AACjC,OAAO,EAAC,iBAAiB,EAAC,CAAC;AAE3B;;GAEG;AACH,eAAO,MAAM,WAAW,EAAE,gBAAgB,CAAC,cAAc,EAAE,KAAK,EAAE,kBAAkB,CAMnF,CAAC"}
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
+ // loaders.gl, MIT license
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports._typecheckLoader = exports.ExcelLoader = exports.ExcelWorkerLoader = void 0;
4
+ exports.ExcelLoader = exports.ExcelWorkerLoader = void 0;
4
5
  const excel_loader_1 = require("./excel-loader");
5
6
  Object.defineProperty(exports, "ExcelWorkerLoader", { enumerable: true, get: function () { return excel_loader_1.ExcelLoader; } });
6
7
  const parse_excel_1 = require("./lib/parse-excel");
@@ -9,6 +10,8 @@ const parse_excel_1 = require("./lib/parse-excel");
9
10
  */
10
11
  exports.ExcelLoader = {
11
12
  ...excel_loader_1.ExcelLoader,
12
- parse: (arrayBuffer, options) => (0, parse_excel_1.parseExcel)(arrayBuffer, options)
13
+ async parse(arrayBuffer, options) {
14
+ const data = (0, parse_excel_1.parseExcel)(arrayBuffer, options);
15
+ return { shape: 'object-row-table', data };
16
+ }
13
17
  };
14
- exports._typecheckLoader = exports.ExcelLoader;
@@ -4,5 +4,7 @@ import type { ExcelLoaderOptions } from '../excel-loader';
4
4
  * @param arrayBuffer Loaded data
5
5
  * @param options Data parse options.
6
6
  */
7
- export declare function parseExcel(arrayBuffer: ArrayBuffer, options?: ExcelLoaderOptions): Promise<never[]>;
7
+ export declare function parseExcel(arrayBuffer: ArrayBuffer, options?: ExcelLoaderOptions): {
8
+ [key: string]: unknown;
9
+ }[];
8
10
  //# sourceMappingURL=parse-excel.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"parse-excel.d.ts","sourceRoot":"","sources":["../../src/lib/parse-excel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,iBAAiB,CAAC;AAOxD;;;;GAIG;AACH,wBAAsB,UAAU,CAAC,WAAW,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,kBAAkB,oBAuCtF"}
1
+ {"version":3,"file":"parse-excel.d.ts","sourceRoot":"","sources":["../../src/lib/parse-excel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,iBAAiB,CAAC;AAOxD;;;;GAIG;AACH,wBAAgB,UAAU,CACxB,WAAW,EAAE,WAAW,EACxB,OAAO,CAAC,EAAE,kBAAkB,GAC3B;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAC,EAAE,CAuC5B"}
@@ -10,7 +10,7 @@ const dataTableNamesMap = {};
10
10
  * @param arrayBuffer Loaded data
11
11
  * @param options Data parse options.
12
12
  */
13
- async function parseExcel(arrayBuffer, options) {
13
+ function parseExcel(arrayBuffer, options) {
14
14
  const dataUrl = 'dummy';
15
15
  // const dataFileType: string = dataUrl.substr(dataUrl.lastIndexOf('.')); // file extension
16
16
  // create Excel 'workbook'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loaders.gl/excel",
3
- "version": "3.4.6",
3
+ "version": "4.0.0-alpha.10",
4
4
  "description": "Framework-independent loader for Excel files",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -35,9 +35,9 @@
35
35
  "build-worker": "esbuild src/workers/excel-worker.ts --bundle --outfile=dist/excel-worker.js --define:__VERSION__=\\\"$npm_package_version\\\""
36
36
  },
37
37
  "dependencies": {
38
- "@loaders.gl/loader-utils": "3.4.6",
39
- "@loaders.gl/schema": "3.4.6",
38
+ "@loaders.gl/loader-utils": "4.0.0-alpha.10",
39
+ "@loaders.gl/schema": "4.0.0-alpha.10",
40
40
  "xlsx": "^0.17.0"
41
41
  },
42
- "gitHead": "f878cbf97013ab99866390ef58e6ca26717af6cb"
42
+ "gitHead": "7efdbe09e02098aad6d985e4d6465d08806e19a9"
43
43
  }
@@ -1,4 +1,7 @@
1
+ // loaders.gl, MIT license
2
+
1
3
  import type {Loader, LoaderOptions} from '@loaders.gl/loader-utils';
4
+ import type {ObjectRowTable} from '@loaders.gl/schema';
2
5
 
3
6
  // __VERSION__ is injected by babel-plugin-version-inline
4
7
  // @ts-ignore TS2304: Cannot find name '__VERSION__'.
@@ -21,7 +24,7 @@ const DEFAULT_EXCEL_LOADER_OPTIONS: ExcelLoaderOptions = {
21
24
  /**
22
25
  * Worker Loader for Excel files
23
26
  */
24
- export const ExcelLoader = {
27
+ export const ExcelLoader: Loader<ObjectRowTable, never, ExcelLoaderOptions> = {
25
28
  name: 'Excel',
26
29
  id: 'excel',
27
30
  module: 'excel',
package/src/index.ts CHANGED
@@ -1,5 +1,9 @@
1
+ // loaders.gl, MIT license
2
+
1
3
  import type {LoaderWithParser} from '@loaders.gl/loader-utils';
2
- import {ExcelLoader as ExcelWorkerLoader, ExcelLoaderOptions} from './excel-loader';
4
+ import type {ObjectRowTable} from '@loaders.gl/schema';
5
+ import type {ExcelLoaderOptions} from './excel-loader';
6
+ import {ExcelLoader as ExcelWorkerLoader} from './excel-loader';
3
7
  import {parseExcel} from './lib/parse-excel';
4
8
 
5
9
  // Excel Loader
@@ -10,10 +14,10 @@ export {ExcelWorkerLoader};
10
14
  /**
11
15
  * Loader for Excel files
12
16
  */
13
- export const ExcelLoader = {
17
+ export const ExcelLoader: LoaderWithParser<ObjectRowTable, never, ExcelLoaderOptions> = {
14
18
  ...ExcelWorkerLoader,
15
- parse: (arrayBuffer: ArrayBuffer, options?: ExcelLoaderOptions) =>
16
- parseExcel(arrayBuffer, options)
19
+ async parse(arrayBuffer: ArrayBuffer, options?: ExcelLoaderOptions): Promise<ObjectRowTable> {
20
+ const data = parseExcel(arrayBuffer, options);
21
+ return {shape: 'object-row-table', data};
22
+ }
17
23
  };
18
-
19
- export const _typecheckLoader: LoaderWithParser = ExcelLoader;
@@ -10,7 +10,10 @@ const dataTableNamesMap = {};
10
10
  * @param arrayBuffer Loaded data
11
11
  * @param options Data parse options.
12
12
  */
13
- export async function parseExcel(arrayBuffer: ArrayBuffer, options?: ExcelLoaderOptions) {
13
+ export function parseExcel(
14
+ arrayBuffer: ArrayBuffer,
15
+ options?: ExcelLoaderOptions
16
+ ): {[key: string]: unknown}[] {
14
17
  const dataUrl = 'dummy';
15
18
  // const dataFileType: string = dataUrl.substr(dataUrl.lastIndexOf('.')); // file extension
16
19
 
@@ -21,7 +24,7 @@ export async function parseExcel(arrayBuffer: ArrayBuffer, options?: ExcelLoader
21
24
  });
22
25
 
23
26
  // load data sheets
24
- let dataRows = [];
27
+ let dataRows: {[key: string]: unknown}[] = [];
25
28
  dataTableNamesMap[dataUrl] = [];
26
29
  if (workbook.SheetNames.length > 0) {
27
30
  if (workbook.SheetNames.length > 1) {