saurus-excel 0.1.0 → 0.1.1
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/package.json +2 -2
- package/pkg/excelsaurus.d.ts +66 -0
- package/pkg/excelsaurus.js +543 -0
- package/pkg/excelsaurus_bg.wasm +0 -0
- package/pkg/excelsaurus_bg.wasm.d.ts +11 -0
- package/pkg/package.json +31 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "saurus-excel",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "🦖 Blazingly fast Excel parser for the web - powered by Rust & WebAssembly",
|
|
5
5
|
"author": "trietcn <caonhattriet95@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"LICENSE"
|
|
47
47
|
],
|
|
48
48
|
"scripts": {
|
|
49
|
-
"build:wasm": "cd ../rust && wasm-pack build --target web --out-dir ../js/pkg",
|
|
49
|
+
"build:wasm": "cd ../rust && wasm-pack build --target web --out-dir ../js/pkg && rm -f ../js/pkg/.gitignore",
|
|
50
50
|
"build:ts": "tsup",
|
|
51
51
|
"build": "npm run build:wasm && npm run build:ts",
|
|
52
52
|
"dev": "tsup --watch",
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Get list of sheet names in the workbook
|
|
6
|
+
*
|
|
7
|
+
* # Arguments
|
|
8
|
+
* * `data` - Raw bytes of the Excel file
|
|
9
|
+
*
|
|
10
|
+
* # Returns
|
|
11
|
+
* * `Vec<String>` - List of sheet names
|
|
12
|
+
*/
|
|
13
|
+
export function getSheetNames(data: Uint8Array): any;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Initialize panic hook for better error messages in browser console
|
|
17
|
+
*/
|
|
18
|
+
export function init(): void;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Parse an Excel file from bytes
|
|
22
|
+
*
|
|
23
|
+
* # Arguments
|
|
24
|
+
* * `data` - Raw bytes of the Excel file
|
|
25
|
+
* * `options` - Parse options (optional)
|
|
26
|
+
*
|
|
27
|
+
* # Returns
|
|
28
|
+
* * `JsValue` - Parsed result as JavaScript object
|
|
29
|
+
*/
|
|
30
|
+
export function parseExcel(data: Uint8Array, options: any): any;
|
|
31
|
+
|
|
32
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
33
|
+
|
|
34
|
+
export interface InitOutput {
|
|
35
|
+
readonly memory: WebAssembly.Memory;
|
|
36
|
+
readonly getSheetNames: (a: number, b: number, c: number) => void;
|
|
37
|
+
readonly init: () => void;
|
|
38
|
+
readonly parseExcel: (a: number, b: number, c: number, d: number) => void;
|
|
39
|
+
readonly __wbindgen_export: (a: number, b: number) => number;
|
|
40
|
+
readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
41
|
+
readonly __wbindgen_export3: (a: number, b: number, c: number) => void;
|
|
42
|
+
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
43
|
+
readonly __wbindgen_start: () => void;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
50
|
+
* a precompiled `WebAssembly.Module`.
|
|
51
|
+
*
|
|
52
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
53
|
+
*
|
|
54
|
+
* @returns {InitOutput}
|
|
55
|
+
*/
|
|
56
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
60
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
61
|
+
*
|
|
62
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
63
|
+
*
|
|
64
|
+
* @returns {Promise<InitOutput>}
|
|
65
|
+
*/
|
|
66
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
|
@@ -0,0 +1,543 @@
|
|
|
1
|
+
/* @ts-self-types="./excelsaurus.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Get list of sheet names in the workbook
|
|
5
|
+
*
|
|
6
|
+
* # Arguments
|
|
7
|
+
* * `data` - Raw bytes of the Excel file
|
|
8
|
+
*
|
|
9
|
+
* # Returns
|
|
10
|
+
* * `Vec<String>` - List of sheet names
|
|
11
|
+
* @param {Uint8Array} data
|
|
12
|
+
* @returns {any}
|
|
13
|
+
*/
|
|
14
|
+
export function getSheetNames(data) {
|
|
15
|
+
try {
|
|
16
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
17
|
+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export);
|
|
18
|
+
const len0 = WASM_VECTOR_LEN;
|
|
19
|
+
wasm.getSheetNames(retptr, ptr0, len0);
|
|
20
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
21
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
22
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
23
|
+
if (r2) {
|
|
24
|
+
throw takeObject(r1);
|
|
25
|
+
}
|
|
26
|
+
return takeObject(r0);
|
|
27
|
+
} finally {
|
|
28
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Initialize panic hook for better error messages in browser console
|
|
34
|
+
*/
|
|
35
|
+
export function init() {
|
|
36
|
+
wasm.init();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Parse an Excel file from bytes
|
|
41
|
+
*
|
|
42
|
+
* # Arguments
|
|
43
|
+
* * `data` - Raw bytes of the Excel file
|
|
44
|
+
* * `options` - Parse options (optional)
|
|
45
|
+
*
|
|
46
|
+
* # Returns
|
|
47
|
+
* * `JsValue` - Parsed result as JavaScript object
|
|
48
|
+
* @param {Uint8Array} data
|
|
49
|
+
* @param {any} options
|
|
50
|
+
* @returns {any}
|
|
51
|
+
*/
|
|
52
|
+
export function parseExcel(data, options) {
|
|
53
|
+
try {
|
|
54
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
55
|
+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export);
|
|
56
|
+
const len0 = WASM_VECTOR_LEN;
|
|
57
|
+
wasm.parseExcel(retptr, ptr0, len0, addHeapObject(options));
|
|
58
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
59
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
60
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
61
|
+
if (r2) {
|
|
62
|
+
throw takeObject(r1);
|
|
63
|
+
}
|
|
64
|
+
return takeObject(r0);
|
|
65
|
+
} finally {
|
|
66
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function __wbg_get_imports() {
|
|
71
|
+
const import0 = {
|
|
72
|
+
__proto__: null,
|
|
73
|
+
__wbg_Error_8c4e43fe74559d73: function(arg0, arg1) {
|
|
74
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
75
|
+
return addHeapObject(ret);
|
|
76
|
+
},
|
|
77
|
+
__wbg_Number_04624de7d0e8332d: function(arg0) {
|
|
78
|
+
const ret = Number(getObject(arg0));
|
|
79
|
+
return ret;
|
|
80
|
+
},
|
|
81
|
+
__wbg_String_8f0eb39a4a4c2f66: function(arg0, arg1) {
|
|
82
|
+
const ret = String(getObject(arg1));
|
|
83
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
84
|
+
const len1 = WASM_VECTOR_LEN;
|
|
85
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
86
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
87
|
+
},
|
|
88
|
+
__wbg___wbindgen_bigint_get_as_i64_8fcf4ce7f1ca72a2: function(arg0, arg1) {
|
|
89
|
+
const v = getObject(arg1);
|
|
90
|
+
const ret = typeof(v) === 'bigint' ? v : undefined;
|
|
91
|
+
getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
|
|
92
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
93
|
+
},
|
|
94
|
+
__wbg___wbindgen_boolean_get_bbbb1c18aa2f5e25: function(arg0) {
|
|
95
|
+
const v = getObject(arg0);
|
|
96
|
+
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
97
|
+
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
98
|
+
},
|
|
99
|
+
__wbg___wbindgen_debug_string_0bc8482c6e3508ae: function(arg0, arg1) {
|
|
100
|
+
const ret = debugString(getObject(arg1));
|
|
101
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
102
|
+
const len1 = WASM_VECTOR_LEN;
|
|
103
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
104
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
105
|
+
},
|
|
106
|
+
__wbg___wbindgen_in_47fa6863be6f2f25: function(arg0, arg1) {
|
|
107
|
+
const ret = getObject(arg0) in getObject(arg1);
|
|
108
|
+
return ret;
|
|
109
|
+
},
|
|
110
|
+
__wbg___wbindgen_is_bigint_31b12575b56f32fc: function(arg0) {
|
|
111
|
+
const ret = typeof(getObject(arg0)) === 'bigint';
|
|
112
|
+
return ret;
|
|
113
|
+
},
|
|
114
|
+
__wbg___wbindgen_is_null_ac34f5003991759a: function(arg0) {
|
|
115
|
+
const ret = getObject(arg0) === null;
|
|
116
|
+
return ret;
|
|
117
|
+
},
|
|
118
|
+
__wbg___wbindgen_is_object_5ae8e5880f2c1fbd: function(arg0) {
|
|
119
|
+
const val = getObject(arg0);
|
|
120
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
121
|
+
return ret;
|
|
122
|
+
},
|
|
123
|
+
__wbg___wbindgen_is_undefined_9e4d92534c42d778: function(arg0) {
|
|
124
|
+
const ret = getObject(arg0) === undefined;
|
|
125
|
+
return ret;
|
|
126
|
+
},
|
|
127
|
+
__wbg___wbindgen_jsval_eq_11888390b0186270: function(arg0, arg1) {
|
|
128
|
+
const ret = getObject(arg0) === getObject(arg1);
|
|
129
|
+
return ret;
|
|
130
|
+
},
|
|
131
|
+
__wbg___wbindgen_jsval_loose_eq_9dd77d8cd6671811: function(arg0, arg1) {
|
|
132
|
+
const ret = getObject(arg0) == getObject(arg1);
|
|
133
|
+
return ret;
|
|
134
|
+
},
|
|
135
|
+
__wbg___wbindgen_number_get_8ff4255516ccad3e: function(arg0, arg1) {
|
|
136
|
+
const obj = getObject(arg1);
|
|
137
|
+
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
138
|
+
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
139
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
140
|
+
},
|
|
141
|
+
__wbg___wbindgen_string_get_72fb696202c56729: function(arg0, arg1) {
|
|
142
|
+
const obj = getObject(arg1);
|
|
143
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
144
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
145
|
+
var len1 = WASM_VECTOR_LEN;
|
|
146
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
147
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
148
|
+
},
|
|
149
|
+
__wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
|
|
150
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
151
|
+
},
|
|
152
|
+
__wbg_error_7534b8e9a36f1ab4: function(arg0, arg1) {
|
|
153
|
+
let deferred0_0;
|
|
154
|
+
let deferred0_1;
|
|
155
|
+
try {
|
|
156
|
+
deferred0_0 = arg0;
|
|
157
|
+
deferred0_1 = arg1;
|
|
158
|
+
console.error(getStringFromWasm0(arg0, arg1));
|
|
159
|
+
} finally {
|
|
160
|
+
wasm.__wbindgen_export3(deferred0_0, deferred0_1, 1);
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
__wbg_get_with_ref_key_1dc361bd10053bfe: function(arg0, arg1) {
|
|
164
|
+
const ret = getObject(arg0)[getObject(arg1)];
|
|
165
|
+
return addHeapObject(ret);
|
|
166
|
+
},
|
|
167
|
+
__wbg_instanceof_ArrayBuffer_c367199e2fa2aa04: function(arg0) {
|
|
168
|
+
let result;
|
|
169
|
+
try {
|
|
170
|
+
result = getObject(arg0) instanceof ArrayBuffer;
|
|
171
|
+
} catch (_) {
|
|
172
|
+
result = false;
|
|
173
|
+
}
|
|
174
|
+
const ret = result;
|
|
175
|
+
return ret;
|
|
176
|
+
},
|
|
177
|
+
__wbg_instanceof_Uint8Array_9b9075935c74707c: function(arg0) {
|
|
178
|
+
let result;
|
|
179
|
+
try {
|
|
180
|
+
result = getObject(arg0) instanceof Uint8Array;
|
|
181
|
+
} catch (_) {
|
|
182
|
+
result = false;
|
|
183
|
+
}
|
|
184
|
+
const ret = result;
|
|
185
|
+
return ret;
|
|
186
|
+
},
|
|
187
|
+
__wbg_isSafeInteger_bfbc7332a9768d2a: function(arg0) {
|
|
188
|
+
const ret = Number.isSafeInteger(getObject(arg0));
|
|
189
|
+
return ret;
|
|
190
|
+
},
|
|
191
|
+
__wbg_length_32ed9a279acd054c: function(arg0) {
|
|
192
|
+
const ret = getObject(arg0).length;
|
|
193
|
+
return ret;
|
|
194
|
+
},
|
|
195
|
+
__wbg_new_361308b2356cecd0: function() {
|
|
196
|
+
const ret = new Object();
|
|
197
|
+
return addHeapObject(ret);
|
|
198
|
+
},
|
|
199
|
+
__wbg_new_3eb36ae241fe6f44: function() {
|
|
200
|
+
const ret = new Array();
|
|
201
|
+
return addHeapObject(ret);
|
|
202
|
+
},
|
|
203
|
+
__wbg_new_8a6f238a6ece86ea: function() {
|
|
204
|
+
const ret = new Error();
|
|
205
|
+
return addHeapObject(ret);
|
|
206
|
+
},
|
|
207
|
+
__wbg_new_dd2b680c8bf6ae29: function(arg0) {
|
|
208
|
+
const ret = new Uint8Array(getObject(arg0));
|
|
209
|
+
return addHeapObject(ret);
|
|
210
|
+
},
|
|
211
|
+
__wbg_prototypesetcall_bdcdcc5842e4d77d: function(arg0, arg1, arg2) {
|
|
212
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
|
|
213
|
+
},
|
|
214
|
+
__wbg_set_3f1d0b984ed272ed: function(arg0, arg1, arg2) {
|
|
215
|
+
getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
|
|
216
|
+
},
|
|
217
|
+
__wbg_set_f43e577aea94465b: function(arg0, arg1, arg2) {
|
|
218
|
+
getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
|
|
219
|
+
},
|
|
220
|
+
__wbg_stack_0ed75d68575b0f3c: function(arg0, arg1) {
|
|
221
|
+
const ret = getObject(arg1).stack;
|
|
222
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
223
|
+
const len1 = WASM_VECTOR_LEN;
|
|
224
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
225
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
226
|
+
},
|
|
227
|
+
__wbindgen_cast_0000000000000001: function(arg0) {
|
|
228
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
229
|
+
const ret = arg0;
|
|
230
|
+
return addHeapObject(ret);
|
|
231
|
+
},
|
|
232
|
+
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
233
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
234
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
235
|
+
return addHeapObject(ret);
|
|
236
|
+
},
|
|
237
|
+
__wbindgen_cast_0000000000000003: function(arg0) {
|
|
238
|
+
// Cast intrinsic for `U64 -> Externref`.
|
|
239
|
+
const ret = BigInt.asUintN(64, arg0);
|
|
240
|
+
return addHeapObject(ret);
|
|
241
|
+
},
|
|
242
|
+
__wbindgen_object_clone_ref: function(arg0) {
|
|
243
|
+
const ret = getObject(arg0);
|
|
244
|
+
return addHeapObject(ret);
|
|
245
|
+
},
|
|
246
|
+
__wbindgen_object_drop_ref: function(arg0) {
|
|
247
|
+
takeObject(arg0);
|
|
248
|
+
},
|
|
249
|
+
};
|
|
250
|
+
return {
|
|
251
|
+
__proto__: null,
|
|
252
|
+
"./excelsaurus_bg.js": import0,
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
function addHeapObject(obj) {
|
|
257
|
+
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
258
|
+
const idx = heap_next;
|
|
259
|
+
heap_next = heap[idx];
|
|
260
|
+
|
|
261
|
+
heap[idx] = obj;
|
|
262
|
+
return idx;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
function debugString(val) {
|
|
266
|
+
// primitive types
|
|
267
|
+
const type = typeof val;
|
|
268
|
+
if (type == 'number' || type == 'boolean' || val == null) {
|
|
269
|
+
return `${val}`;
|
|
270
|
+
}
|
|
271
|
+
if (type == 'string') {
|
|
272
|
+
return `"${val}"`;
|
|
273
|
+
}
|
|
274
|
+
if (type == 'symbol') {
|
|
275
|
+
const description = val.description;
|
|
276
|
+
if (description == null) {
|
|
277
|
+
return 'Symbol';
|
|
278
|
+
} else {
|
|
279
|
+
return `Symbol(${description})`;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
if (type == 'function') {
|
|
283
|
+
const name = val.name;
|
|
284
|
+
if (typeof name == 'string' && name.length > 0) {
|
|
285
|
+
return `Function(${name})`;
|
|
286
|
+
} else {
|
|
287
|
+
return 'Function';
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
// objects
|
|
291
|
+
if (Array.isArray(val)) {
|
|
292
|
+
const length = val.length;
|
|
293
|
+
let debug = '[';
|
|
294
|
+
if (length > 0) {
|
|
295
|
+
debug += debugString(val[0]);
|
|
296
|
+
}
|
|
297
|
+
for(let i = 1; i < length; i++) {
|
|
298
|
+
debug += ', ' + debugString(val[i]);
|
|
299
|
+
}
|
|
300
|
+
debug += ']';
|
|
301
|
+
return debug;
|
|
302
|
+
}
|
|
303
|
+
// Test for built-in
|
|
304
|
+
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
305
|
+
let className;
|
|
306
|
+
if (builtInMatches && builtInMatches.length > 1) {
|
|
307
|
+
className = builtInMatches[1];
|
|
308
|
+
} else {
|
|
309
|
+
// Failed to match the standard '[object ClassName]'
|
|
310
|
+
return toString.call(val);
|
|
311
|
+
}
|
|
312
|
+
if (className == 'Object') {
|
|
313
|
+
// we're a user defined class or Object
|
|
314
|
+
// JSON.stringify avoids problems with cycles, and is generally much
|
|
315
|
+
// easier than looping through ownProperties of `val`.
|
|
316
|
+
try {
|
|
317
|
+
return 'Object(' + JSON.stringify(val) + ')';
|
|
318
|
+
} catch (_) {
|
|
319
|
+
return 'Object';
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
// errors
|
|
323
|
+
if (val instanceof Error) {
|
|
324
|
+
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
325
|
+
}
|
|
326
|
+
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
327
|
+
return className;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
function dropObject(idx) {
|
|
331
|
+
if (idx < 132) return;
|
|
332
|
+
heap[idx] = heap_next;
|
|
333
|
+
heap_next = idx;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
337
|
+
ptr = ptr >>> 0;
|
|
338
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
let cachedDataViewMemory0 = null;
|
|
342
|
+
function getDataViewMemory0() {
|
|
343
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
344
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
345
|
+
}
|
|
346
|
+
return cachedDataViewMemory0;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
function getStringFromWasm0(ptr, len) {
|
|
350
|
+
ptr = ptr >>> 0;
|
|
351
|
+
return decodeText(ptr, len);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
let cachedUint8ArrayMemory0 = null;
|
|
355
|
+
function getUint8ArrayMemory0() {
|
|
356
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
357
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
358
|
+
}
|
|
359
|
+
return cachedUint8ArrayMemory0;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
function getObject(idx) { return heap[idx]; }
|
|
363
|
+
|
|
364
|
+
let heap = new Array(128).fill(undefined);
|
|
365
|
+
heap.push(undefined, null, true, false);
|
|
366
|
+
|
|
367
|
+
let heap_next = heap.length;
|
|
368
|
+
|
|
369
|
+
function isLikeNone(x) {
|
|
370
|
+
return x === undefined || x === null;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
374
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
375
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
376
|
+
WASM_VECTOR_LEN = arg.length;
|
|
377
|
+
return ptr;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
381
|
+
if (realloc === undefined) {
|
|
382
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
383
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
384
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
385
|
+
WASM_VECTOR_LEN = buf.length;
|
|
386
|
+
return ptr;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
let len = arg.length;
|
|
390
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
391
|
+
|
|
392
|
+
const mem = getUint8ArrayMemory0();
|
|
393
|
+
|
|
394
|
+
let offset = 0;
|
|
395
|
+
|
|
396
|
+
for (; offset < len; offset++) {
|
|
397
|
+
const code = arg.charCodeAt(offset);
|
|
398
|
+
if (code > 0x7F) break;
|
|
399
|
+
mem[ptr + offset] = code;
|
|
400
|
+
}
|
|
401
|
+
if (offset !== len) {
|
|
402
|
+
if (offset !== 0) {
|
|
403
|
+
arg = arg.slice(offset);
|
|
404
|
+
}
|
|
405
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
406
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
407
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
408
|
+
|
|
409
|
+
offset += ret.written;
|
|
410
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
WASM_VECTOR_LEN = offset;
|
|
414
|
+
return ptr;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
function takeObject(idx) {
|
|
418
|
+
const ret = getObject(idx);
|
|
419
|
+
dropObject(idx);
|
|
420
|
+
return ret;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
424
|
+
cachedTextDecoder.decode();
|
|
425
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
426
|
+
let numBytesDecoded = 0;
|
|
427
|
+
function decodeText(ptr, len) {
|
|
428
|
+
numBytesDecoded += len;
|
|
429
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
430
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
431
|
+
cachedTextDecoder.decode();
|
|
432
|
+
numBytesDecoded = len;
|
|
433
|
+
}
|
|
434
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
const cachedTextEncoder = new TextEncoder();
|
|
438
|
+
|
|
439
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
440
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
441
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
442
|
+
view.set(buf);
|
|
443
|
+
return {
|
|
444
|
+
read: arg.length,
|
|
445
|
+
written: buf.length
|
|
446
|
+
};
|
|
447
|
+
};
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
let WASM_VECTOR_LEN = 0;
|
|
451
|
+
|
|
452
|
+
let wasmModule, wasm;
|
|
453
|
+
function __wbg_finalize_init(instance, module) {
|
|
454
|
+
wasm = instance.exports;
|
|
455
|
+
wasmModule = module;
|
|
456
|
+
cachedDataViewMemory0 = null;
|
|
457
|
+
cachedUint8ArrayMemory0 = null;
|
|
458
|
+
wasm.__wbindgen_start();
|
|
459
|
+
return wasm;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
async function __wbg_load(module, imports) {
|
|
463
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
464
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
465
|
+
try {
|
|
466
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
467
|
+
} catch (e) {
|
|
468
|
+
const validResponse = module.ok && expectedResponseType(module.type);
|
|
469
|
+
|
|
470
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
471
|
+
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
472
|
+
|
|
473
|
+
} else { throw e; }
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
const bytes = await module.arrayBuffer();
|
|
478
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
479
|
+
} else {
|
|
480
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
481
|
+
|
|
482
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
483
|
+
return { instance, module };
|
|
484
|
+
} else {
|
|
485
|
+
return instance;
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
function expectedResponseType(type) {
|
|
490
|
+
switch (type) {
|
|
491
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
492
|
+
}
|
|
493
|
+
return false;
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
function initSync(module) {
|
|
498
|
+
if (wasm !== undefined) return wasm;
|
|
499
|
+
|
|
500
|
+
|
|
501
|
+
if (module !== undefined) {
|
|
502
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
503
|
+
({module} = module)
|
|
504
|
+
} else {
|
|
505
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
const imports = __wbg_get_imports();
|
|
510
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
511
|
+
module = new WebAssembly.Module(module);
|
|
512
|
+
}
|
|
513
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
514
|
+
return __wbg_finalize_init(instance, module);
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
async function __wbg_init(module_or_path) {
|
|
518
|
+
if (wasm !== undefined) return wasm;
|
|
519
|
+
|
|
520
|
+
|
|
521
|
+
if (module_or_path !== undefined) {
|
|
522
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
523
|
+
({module_or_path} = module_or_path)
|
|
524
|
+
} else {
|
|
525
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
if (module_or_path === undefined) {
|
|
530
|
+
module_or_path = new URL('excelsaurus_bg.wasm', import.meta.url);
|
|
531
|
+
}
|
|
532
|
+
const imports = __wbg_get_imports();
|
|
533
|
+
|
|
534
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
535
|
+
module_or_path = fetch(module_or_path);
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
539
|
+
|
|
540
|
+
return __wbg_finalize_init(instance, module);
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
export { initSync, __wbg_init as default };
|
|
Binary file
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const getSheetNames: (a: number, b: number, c: number) => void;
|
|
5
|
+
export const init: () => void;
|
|
6
|
+
export const parseExcel: (a: number, b: number, c: number, d: number) => void;
|
|
7
|
+
export const __wbindgen_export: (a: number, b: number) => number;
|
|
8
|
+
export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
9
|
+
export const __wbindgen_export3: (a: number, b: number, c: number) => void;
|
|
10
|
+
export const __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
11
|
+
export const __wbindgen_start: () => void;
|
package/pkg/package.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "excelsaurus",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"collaborators": [
|
|
5
|
+
"Your Name <your.email@example.com>"
|
|
6
|
+
],
|
|
7
|
+
"description": "🦖 Blazingly fast Excel parser for the web - powered by Rust & WebAssembly",
|
|
8
|
+
"version": "0.1.0",
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/yourusername/excelsaurus"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"excelsaurus_bg.wasm",
|
|
16
|
+
"excelsaurus.js",
|
|
17
|
+
"excelsaurus.d.ts"
|
|
18
|
+
],
|
|
19
|
+
"main": "excelsaurus.js",
|
|
20
|
+
"types": "excelsaurus.d.ts",
|
|
21
|
+
"sideEffects": [
|
|
22
|
+
"./snippets/*"
|
|
23
|
+
],
|
|
24
|
+
"keywords": [
|
|
25
|
+
"excel",
|
|
26
|
+
"xlsx",
|
|
27
|
+
"wasm",
|
|
28
|
+
"parser",
|
|
29
|
+
"spreadsheet"
|
|
30
|
+
]
|
|
31
|
+
}
|