@loaders.gl/excel 3.1.3 → 4.0.0-alpha.5
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/bundle.js +2 -2
- package/dist/bundle.js.map +1 -0
- package/dist/excel-loader.js +18 -28
- package/dist/excel-loader.js.map +1 -0
- package/dist/excel-worker.js +1 -1
- package/dist/index.js +7 -13
- package/dist/index.js.map +1 -0
- package/dist/lib/encode-excel.js +1 -80
- package/dist/{es5/lib → lib}/encode-excel.js.map +0 -0
- package/dist/lib/parse-excel.js +29 -44
- package/dist/lib/parse-excel.js.map +1 -0
- package/dist/workers/excel-worker.js +4 -5
- package/dist/workers/excel-worker.js.map +1 -0
- package/package.json +7 -7
- package/dist/es5/bundle.js +0 -7
- package/dist/es5/bundle.js.map +0 -1
- package/dist/es5/excel-loader.js +0 -29
- package/dist/es5/excel-loader.js.map +0 -1
- package/dist/es5/index.js +0 -35
- package/dist/es5/index.js.map +0 -1
- package/dist/es5/lib/encode-excel.js +0 -2
- package/dist/es5/lib/parse-excel.js +0 -63
- package/dist/es5/lib/parse-excel.js.map +0 -1
- package/dist/es5/workers/excel-worker.js +0 -8
- package/dist/es5/workers/excel-worker.js.map +0 -1
- package/dist/esm/bundle.js +0 -5
- package/dist/esm/bundle.js.map +0 -1
- package/dist/esm/excel-loader.js +0 -21
- package/dist/esm/excel-loader.js.map +0 -1
- package/dist/esm/index.js +0 -8
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/lib/encode-excel.js +0 -2
- package/dist/esm/lib/encode-excel.js.map +0 -1
- package/dist/esm/lib/parse-excel.js +0 -32
- package/dist/esm/lib/parse-excel.js.map +0 -1
- package/dist/esm/workers/excel-worker.js +0 -4
- package/dist/esm/workers/excel-worker.js.map +0 -1
package/dist/bundle.js
CHANGED
|
@@ -0,0 +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"}
|
package/dist/excel-loader.js
CHANGED
|
@@ -1,31 +1,21 @@
|
|
|
1
|
-
"
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports._typecheckLoader = exports.ExcelLoader = void 0;
|
|
4
|
-
// __VERSION__ is injected by babel-plugin-version-inline
|
|
5
|
-
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|
|
6
|
-
const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
|
|
1
|
+
const VERSION = typeof "4.0.0-alpha.5" !== 'undefined' ? "4.0.0-alpha.5" : 'latest';
|
|
7
2
|
const DEFAULT_EXCEL_LOADER_OPTIONS = {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
3
|
+
excel: {
|
|
4
|
+
shape: 'object-row-table',
|
|
5
|
+
sheet: undefined
|
|
6
|
+
}
|
|
12
7
|
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
25
|
-
'application/vnd.ms-excel'
|
|
26
|
-
],
|
|
27
|
-
category: 'table',
|
|
28
|
-
binary: true,
|
|
29
|
-
options: DEFAULT_EXCEL_LOADER_OPTIONS
|
|
8
|
+
export const ExcelLoader = {
|
|
9
|
+
name: 'Excel',
|
|
10
|
+
id: 'excel',
|
|
11
|
+
module: 'excel',
|
|
12
|
+
version: VERSION,
|
|
13
|
+
worker: true,
|
|
14
|
+
extensions: ['xls', 'xlsb', 'xlsm', 'xlsx'],
|
|
15
|
+
mimeTypes: ['application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/vnd.ms-excel'],
|
|
16
|
+
category: 'table',
|
|
17
|
+
binary: true,
|
|
18
|
+
options: DEFAULT_EXCEL_LOADER_OPTIONS
|
|
30
19
|
};
|
|
31
|
-
|
|
20
|
+
export const _typecheckLoader = ExcelLoader;
|
|
21
|
+
//# sourceMappingURL=excel-loader.js.map
|
|
@@ -0,0 +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,2BAAuB,WAAvB,qBAAmD,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"}
|
package/dist/excel-worker.js
CHANGED
|
@@ -34768,7 +34768,7 @@
|
|
|
34768
34768
|
}
|
|
34769
34769
|
|
|
34770
34770
|
// src/excel-loader.ts
|
|
34771
|
-
var VERSION =
|
|
34771
|
+
var VERSION = true ? "4.0.0-alpha.5" : "latest";
|
|
34772
34772
|
var DEFAULT_EXCEL_LOADER_OPTIONS = {
|
|
34773
34773
|
excel: {
|
|
34774
34774
|
shape: "object-row-table",
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
const parse_excel_1 = require("./lib/parse-excel");
|
|
7
|
-
/**
|
|
8
|
-
* Loader for Excel files
|
|
9
|
-
*/
|
|
10
|
-
exports.ExcelLoader = {
|
|
11
|
-
...excel_loader_1.ExcelLoader,
|
|
12
|
-
parse: (arrayBuffer, options) => (0, parse_excel_1.parseExcel)(arrayBuffer, options)
|
|
1
|
+
import { ExcelLoader as ExcelWorkerLoader } from './excel-loader';
|
|
2
|
+
import { parseExcel } from './lib/parse-excel';
|
|
3
|
+
export { ExcelWorkerLoader };
|
|
4
|
+
export const ExcelLoader = { ...ExcelWorkerLoader,
|
|
5
|
+
parse: (arrayBuffer, options) => parseExcel(arrayBuffer, options)
|
|
13
6
|
};
|
|
14
|
-
|
|
7
|
+
export const _typecheckLoader = ExcelLoader;
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +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"}
|
package/dist/lib/encode-excel.js
CHANGED
|
@@ -1,81 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// import * as xlsx from 'xlsx';
|
|
3
|
-
/**
|
|
4
|
-
* Saves JSON data in Excel format for html, ods, xml, xlsb and xlsx file types.
|
|
5
|
-
* @param filePath Local data file path.
|
|
6
|
-
* @param fileData Raw data to save.
|
|
7
|
-
* @param tableName Table name for data files with multiple tables support.
|
|
8
|
-
* @param showData Show saved data callback.
|
|
9
|
-
*
|
|
10
|
-
public saveData(filePath: string, fileData: any, tableName: string, showData?: Function): void {
|
|
11
|
-
const fileType: string = filePath.substr(filePath.lastIndexOf('.'));
|
|
12
|
-
fileData = this.jsonToExcelData(fileData, fileType, tableName);
|
|
13
|
-
if ( fileData.length > 0) {
|
|
14
|
-
// TODO: change this to async later
|
|
15
|
-
fs.writeFile(filePath, fileData, (error) => showData(error));
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
1
|
|
|
19
|
-
|
|
20
|
-
* Converts JSON data to Excel data formats.
|
|
21
|
-
* @param jsonData Json data to convert.
|
|
22
|
-
* @param bookType Excel data file/book type.
|
|
23
|
-
*
|
|
24
|
-
private jsonToExcelData(jsonData: any, fileType: string, tableName: string): any {
|
|
25
|
-
console.debug('jsonToExcelData(): creating excel data:', fileType);
|
|
26
|
-
|
|
27
|
-
// create new workbook
|
|
28
|
-
const workbook = xlsx.utils.book_new();
|
|
29
|
-
|
|
30
|
-
// convert json data to worksheet format
|
|
31
|
-
const worksheet = xlsx.utils.json_to_sheet(jsonData, {
|
|
32
|
-
//header: JSON.parse(this._viewConfig.columns)
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
// append worksheet to workbook
|
|
36
|
-
xlsx.utils.book_append_sheet(workbook, worksheet, tableName);
|
|
37
|
-
|
|
38
|
-
// get text data string or binary spreadsheet data buffer
|
|
39
|
-
let data: any = '';
|
|
40
|
-
if (fileType === 'html' || fileType === 'xml') {
|
|
41
|
-
data = xlsx.write(workbook, {
|
|
42
|
-
type: 'string',
|
|
43
|
-
compression: false,
|
|
44
|
-
bookType: getBookType(fileType)
|
|
45
|
-
});
|
|
46
|
-
} else {
|
|
47
|
-
data = xlsx.write(workbook, {
|
|
48
|
-
type: 'buffer',
|
|
49
|
-
compression: true, // use zip compression for zip-based formats
|
|
50
|
-
bookType: getBookType(fileType)
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
return data;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Converts file type to Excel book type.
|
|
61
|
-
* @param {string} fileType File type: .html, .ods, .xml, .xlsb, .xlsx, etc.
|
|
62
|
-
* @returns {xlsx.BookType}
|
|
63
|
-
*
|
|
64
|
-
function getBookType(fileType) {
|
|
65
|
-
// TODO: must be a better way to do this string to type conversion :)
|
|
66
|
-
switch (fileType) {
|
|
67
|
-
case '.html':
|
|
68
|
-
return 'html';
|
|
69
|
-
case '.ods':
|
|
70
|
-
return 'ods';
|
|
71
|
-
case '.xml':
|
|
72
|
-
return 'xlml';
|
|
73
|
-
case '.xlsb':
|
|
74
|
-
return 'xlsb';
|
|
75
|
-
case '.xlsx':
|
|
76
|
-
return 'xlsx';
|
|
77
|
-
default:
|
|
78
|
-
return 'xlsb';
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
*/
|
|
2
|
+
//# sourceMappingURL=encode-excel.js.map
|
|
File without changes
|
package/dist/lib/parse-excel.js
CHANGED
|
@@ -1,47 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseExcel = void 0;
|
|
4
|
-
const xlsx_1 = require("xlsx");
|
|
5
|
-
// import {convertToArrayRow} from '@loaders.gl/schema';
|
|
6
|
-
// local table names cache with dataUrl/tableNames array key/values
|
|
1
|
+
import { utils, read } from 'xlsx';
|
|
7
2
|
const dataTableNamesMap = {};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
// load data sheets
|
|
22
|
-
let dataRows = [];
|
|
23
|
-
dataTableNamesMap[dataUrl] = [];
|
|
24
|
-
if (workbook.SheetNames.length > 0) {
|
|
25
|
-
if (workbook.SheetNames.length > 1) {
|
|
26
|
-
// cache sheet names
|
|
27
|
-
dataTableNamesMap[dataUrl] = workbook.SheetNames;
|
|
28
|
-
// eslint-ignore-next-line
|
|
29
|
-
// console.debug(`getData(): file: sheetNames:`, workbook.SheetNames);
|
|
30
|
-
}
|
|
31
|
-
// determine spreadsheet to load
|
|
32
|
-
let sheetName = workbook.SheetNames[0];
|
|
33
|
-
if (options?.excel?.sheet && workbook.SheetNames.indexOf(options?.excel?.sheet) >= 0) {
|
|
34
|
-
// reset to requested table name
|
|
35
|
-
sheetName = options?.excel?.sheet;
|
|
36
|
-
}
|
|
37
|
-
// get worksheet data row objects array
|
|
38
|
-
const worksheet = workbook.Sheets[sheetName];
|
|
39
|
-
dataRows = xlsx_1.utils.sheet_to_json(worksheet);
|
|
40
|
-
// const headers = dataRows.length ? Object.keys(dataRows[0]) : [];
|
|
41
|
-
// if (options?.excel?.type === 'array-row-table') {
|
|
42
|
-
// dataRows = dataRows.map(row => convertToArrayRow(row, headers))
|
|
43
|
-
// }
|
|
3
|
+
export async function parseExcel(arrayBuffer, options) {
|
|
4
|
+
const dataUrl = 'dummy';
|
|
5
|
+
const workbook = read(arrayBuffer, {
|
|
6
|
+
type: 'array'
|
|
7
|
+
});
|
|
8
|
+
let dataRows = [];
|
|
9
|
+
dataTableNamesMap[dataUrl] = [];
|
|
10
|
+
|
|
11
|
+
if (workbook.SheetNames.length > 0) {
|
|
12
|
+
var _options$excel, _options$excel2;
|
|
13
|
+
|
|
14
|
+
if (workbook.SheetNames.length > 1) {
|
|
15
|
+
dataTableNamesMap[dataUrl] = workbook.SheetNames;
|
|
44
16
|
}
|
|
45
|
-
|
|
17
|
+
|
|
18
|
+
let sheetName = workbook.SheetNames[0];
|
|
19
|
+
|
|
20
|
+
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
|
+
var _options$excel3;
|
|
22
|
+
|
|
23
|
+
sheetName = options === null || options === void 0 ? void 0 : (_options$excel3 = options.excel) === null || _options$excel3 === void 0 ? void 0 : _options$excel3.sheet;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const worksheet = workbook.Sheets[sheetName];
|
|
27
|
+
dataRows = utils.sheet_to_json(worksheet);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return dataRows;
|
|
46
31
|
}
|
|
47
|
-
|
|
32
|
+
//# sourceMappingURL=parse-excel.js.map
|
|
@@ -0,0 +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,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
(0, loader_utils_1.createLoaderWorker)(index_1.ExcelLoader);
|
|
1
|
+
import { createLoaderWorker } from '@loaders.gl/loader-utils';
|
|
2
|
+
import { ExcelLoader } from '../index';
|
|
3
|
+
createLoaderWorker(ExcelLoader);
|
|
4
|
+
//# sourceMappingURL=excel-worker.js.map
|
|
@@ -0,0 +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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/excel",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-alpha.5",
|
|
4
4
|
"description": "Framework-independent loader for Excel files",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"Spreadsheets"
|
|
22
22
|
],
|
|
23
23
|
"types": "dist/index.d.ts",
|
|
24
|
-
"main": "dist/
|
|
25
|
-
"module": "dist/
|
|
24
|
+
"main": "dist/index.js",
|
|
25
|
+
"module": "dist/index.js",
|
|
26
26
|
"sideEffects": false,
|
|
27
27
|
"files": [
|
|
28
28
|
"src",
|
|
@@ -32,12 +32,12 @@
|
|
|
32
32
|
"scripts": {
|
|
33
33
|
"pre-build": "npm run build-bundle && npm run build-worker",
|
|
34
34
|
"build-bundle": "esbuild src/bundle.ts --bundle --outfile=dist/dist.min.js",
|
|
35
|
-
"build-worker": "esbuild src/workers/excel-worker.ts --bundle --outfile=dist/excel-worker.js"
|
|
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": "
|
|
39
|
-
"@loaders.gl/schema": "
|
|
38
|
+
"@loaders.gl/loader-utils": "4.0.0-alpha.5",
|
|
39
|
+
"@loaders.gl/schema": "4.0.0-alpha.5",
|
|
40
40
|
"xlsx": "^0.17.0"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "7a71a54bdf1ddf985cc3af3db90b82e7fa97d025"
|
|
43
43
|
}
|
package/dist/es5/bundle.js
DELETED
package/dist/es5/bundle.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/dist/es5/excel-loader.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports._typecheckLoader = exports.ExcelLoader = void 0;
|
|
7
|
-
var VERSION = typeof "3.1.3" !== 'undefined' ? "3.1.3" : '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
|
-
var _typecheckLoader = ExcelLoader;
|
|
28
|
-
exports._typecheckLoader = _typecheckLoader;
|
|
29
|
-
//# sourceMappingURL=excel-loader.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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,mBAAuB,WAAvB,aAAmD,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"}
|
package/dist/es5/index.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
Object.defineProperty(exports, "ExcelWorkerLoader", {
|
|
9
|
-
enumerable: true,
|
|
10
|
-
get: function get() {
|
|
11
|
-
return _excelLoader.ExcelLoader;
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
exports._typecheckLoader = exports.ExcelLoader = void 0;
|
|
15
|
-
|
|
16
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
17
|
-
|
|
18
|
-
var _excelLoader = require("./excel-loader");
|
|
19
|
-
|
|
20
|
-
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
|
-
|
|
26
|
-
var ExcelLoader = _objectSpread(_objectSpread({}, _excelLoader.ExcelLoader), {}, {
|
|
27
|
-
parse: function parse(arrayBuffer, options) {
|
|
28
|
-
return (0, _parseExcel.parseExcel)(arrayBuffer, options);
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
exports.ExcelLoader = ExcelLoader;
|
|
33
|
-
var _typecheckLoader = ExcelLoader;
|
|
34
|
-
exports._typecheckLoader = _typecheckLoader;
|
|
35
|
-
//# sourceMappingURL=index.js.map
|
package/dist/es5/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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,63 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.parseExcel = parseExcel;
|
|
9
|
-
|
|
10
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
|
-
|
|
12
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
13
|
-
|
|
14
|
-
var _xlsx = require("xlsx");
|
|
15
|
-
|
|
16
|
-
var dataTableNamesMap = {};
|
|
17
|
-
|
|
18
|
-
function parseExcel(_x, _x2) {
|
|
19
|
-
return _parseExcel.apply(this, arguments);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function _parseExcel() {
|
|
23
|
-
_parseExcel = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee(arrayBuffer, options) {
|
|
24
|
-
var dataUrl, workbook, dataRows, _options$excel, _options$excel2, sheetName, _options$excel3, worksheet;
|
|
25
|
-
|
|
26
|
-
return _regenerator.default.wrap(function _callee$(_context) {
|
|
27
|
-
while (1) {
|
|
28
|
-
switch (_context.prev = _context.next) {
|
|
29
|
-
case 0:
|
|
30
|
-
dataUrl = 'dummy';
|
|
31
|
-
workbook = (0, _xlsx.read)(arrayBuffer, {
|
|
32
|
-
type: 'array'
|
|
33
|
-
});
|
|
34
|
-
dataRows = [];
|
|
35
|
-
dataTableNamesMap[dataUrl] = [];
|
|
36
|
-
|
|
37
|
-
if (workbook.SheetNames.length > 0) {
|
|
38
|
-
if (workbook.SheetNames.length > 1) {
|
|
39
|
-
dataTableNamesMap[dataUrl] = workbook.SheetNames;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
sheetName = workbook.SheetNames[0];
|
|
43
|
-
|
|
44
|
-
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
|
-
sheetName = options === null || options === void 0 ? void 0 : (_options$excel3 = options.excel) === null || _options$excel3 === void 0 ? void 0 : _options$excel3.sheet;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
worksheet = workbook.Sheets[sheetName];
|
|
49
|
-
dataRows = _xlsx.utils.sheet_to_json(worksheet);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return _context.abrupt("return", dataRows);
|
|
53
|
-
|
|
54
|
-
case 6:
|
|
55
|
-
case "end":
|
|
56
|
-
return _context.stop();
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}, _callee);
|
|
60
|
-
}));
|
|
61
|
-
return _parseExcel.apply(this, arguments);
|
|
62
|
-
}
|
|
63
|
-
//# sourceMappingURL=parse-excel.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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 +0,0 @@
|
|
|
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"}
|
package/dist/esm/bundle.js
DELETED
package/dist/esm/bundle.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/dist/esm/excel-loader.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
const VERSION = typeof "3.1.3" !== 'undefined' ? "3.1.3" : 'latest';
|
|
2
|
-
const DEFAULT_EXCEL_LOADER_OPTIONS = {
|
|
3
|
-
excel: {
|
|
4
|
-
shape: 'object-row-table',
|
|
5
|
-
sheet: undefined
|
|
6
|
-
}
|
|
7
|
-
};
|
|
8
|
-
export const ExcelLoader = {
|
|
9
|
-
name: 'Excel',
|
|
10
|
-
id: 'excel',
|
|
11
|
-
module: 'excel',
|
|
12
|
-
version: VERSION,
|
|
13
|
-
worker: true,
|
|
14
|
-
extensions: ['xls', 'xlsb', 'xlsm', 'xlsx'],
|
|
15
|
-
mimeTypes: ['application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/vnd.ms-excel'],
|
|
16
|
-
category: 'table',
|
|
17
|
-
binary: true,
|
|
18
|
-
options: DEFAULT_EXCEL_LOADER_OPTIONS
|
|
19
|
-
};
|
|
20
|
-
export const _typecheckLoader = ExcelLoader;
|
|
21
|
-
//# sourceMappingURL=excel-loader.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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,mBAAuB,WAAvB,aAAmD,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"}
|
package/dist/esm/index.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ExcelLoader as ExcelWorkerLoader } from './excel-loader';
|
|
2
|
-
import { parseExcel } from './lib/parse-excel';
|
|
3
|
-
export { ExcelWorkerLoader };
|
|
4
|
-
export const ExcelLoader = { ...ExcelWorkerLoader,
|
|
5
|
-
parse: (arrayBuffer, options) => parseExcel(arrayBuffer, options)
|
|
6
|
-
};
|
|
7
|
-
export const _typecheckLoader = ExcelLoader;
|
|
8
|
-
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[],"file":"encode-excel.js"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { utils, read } from 'xlsx';
|
|
2
|
-
const dataTableNamesMap = {};
|
|
3
|
-
export async function parseExcel(arrayBuffer, options) {
|
|
4
|
-
const dataUrl = 'dummy';
|
|
5
|
-
const workbook = read(arrayBuffer, {
|
|
6
|
-
type: 'array'
|
|
7
|
-
});
|
|
8
|
-
let dataRows = [];
|
|
9
|
-
dataTableNamesMap[dataUrl] = [];
|
|
10
|
-
|
|
11
|
-
if (workbook.SheetNames.length > 0) {
|
|
12
|
-
var _options$excel, _options$excel2;
|
|
13
|
-
|
|
14
|
-
if (workbook.SheetNames.length > 1) {
|
|
15
|
-
dataTableNamesMap[dataUrl] = workbook.SheetNames;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
let sheetName = workbook.SheetNames[0];
|
|
19
|
-
|
|
20
|
-
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
|
-
var _options$excel3;
|
|
22
|
-
|
|
23
|
-
sheetName = options === null || options === void 0 ? void 0 : (_options$excel3 = options.excel) === null || _options$excel3 === void 0 ? void 0 : _options$excel3.sheet;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const worksheet = workbook.Sheets[sheetName];
|
|
27
|
-
dataRows = utils.sheet_to_json(worksheet);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return dataRows;
|
|
31
|
-
}
|
|
32
|
-
//# sourceMappingURL=parse-excel.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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 +0,0 @@
|
|
|
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"}
|