@rosperitus/excelerate 0.8.0
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/LICENSE +21 -0
- package/README.md +186 -0
- package/excelerate.d.ts +359 -0
- package/excelerate.js +1152 -0
- package/excelerate_bg.wasm +0 -0
- package/package.json +33 -0
package/excelerate.js
ADDED
|
@@ -0,0 +1,1152 @@
|
|
|
1
|
+
/* @ts-self-types="./excelerate.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A workbook.
|
|
5
|
+
*/
|
|
6
|
+
class Book {
|
|
7
|
+
static __wrap(ptr) {
|
|
8
|
+
const obj = Object.create(Book.prototype);
|
|
9
|
+
obj.__wbg_ptr = ptr;
|
|
10
|
+
BookFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
11
|
+
return obj;
|
|
12
|
+
}
|
|
13
|
+
__destroy_into_raw() {
|
|
14
|
+
const ptr = this.__wbg_ptr;
|
|
15
|
+
this.__wbg_ptr = 0;
|
|
16
|
+
BookFinalization.unregister(this);
|
|
17
|
+
return ptr;
|
|
18
|
+
}
|
|
19
|
+
free() {
|
|
20
|
+
const ptr = this.__destroy_into_raw();
|
|
21
|
+
wasm.__wbg_book_free(ptr, 0);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The tab a reader opens the workbook on.
|
|
25
|
+
* @returns {number}
|
|
26
|
+
*/
|
|
27
|
+
activeSheet() {
|
|
28
|
+
const ret = wasm.book_activeSheet(this.__wbg_ptr);
|
|
29
|
+
return ret >>> 0;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Appends a sheet and returns its index.
|
|
33
|
+
* @param {string} title
|
|
34
|
+
* @returns {number}
|
|
35
|
+
*/
|
|
36
|
+
addSheet(title) {
|
|
37
|
+
const ptr0 = passStringToWasm0(title, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
38
|
+
const len0 = WASM_VECTOR_LEN;
|
|
39
|
+
const ret = wasm.book_addSheet(this.__wbg_ptr, ptr0, len0);
|
|
40
|
+
if (ret[2]) {
|
|
41
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
42
|
+
}
|
|
43
|
+
return ret[0] >>> 0;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Whether a cell is bold.
|
|
47
|
+
*
|
|
48
|
+
* The one flag, without building the rest of the style: a parser that
|
|
49
|
+
* looks for a header row asks this of every cell, and `cellStyle` would
|
|
50
|
+
* make it pay for the font, fill and four borders it never reads.
|
|
51
|
+
* @param {number} sheet
|
|
52
|
+
* @param {string} address
|
|
53
|
+
* @returns {boolean}
|
|
54
|
+
*/
|
|
55
|
+
cellBold(sheet, address) {
|
|
56
|
+
const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
57
|
+
const len0 = WASM_VECTOR_LEN;
|
|
58
|
+
const ret = wasm.book_cellBold(this.__wbg_ptr, sheet, ptr0, len0);
|
|
59
|
+
if (ret[2]) {
|
|
60
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
61
|
+
}
|
|
62
|
+
return ret[0] !== 0;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* The same by 1-based row and column.
|
|
66
|
+
* @param {number} sheet
|
|
67
|
+
* @param {number} row
|
|
68
|
+
* @param {number} column
|
|
69
|
+
* @returns {boolean}
|
|
70
|
+
*/
|
|
71
|
+
cellBoldAt(sheet, row, column) {
|
|
72
|
+
const ret = wasm.book_cellBoldAt(this.__wbg_ptr, sheet, row, column);
|
|
73
|
+
if (ret[2]) {
|
|
74
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
75
|
+
}
|
|
76
|
+
return ret[0] !== 0;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* How many non-empty cells the workbook holds, or one sheet of it.
|
|
80
|
+
* @param {number | null} [sheet]
|
|
81
|
+
* @returns {number}
|
|
82
|
+
*/
|
|
83
|
+
cellCount(sheet) {
|
|
84
|
+
const ret = wasm.book_cellCount(this.__wbg_ptr, isLikeNone(sheet) ? Number.MAX_SAFE_INTEGER : (sheet) >>> 0);
|
|
85
|
+
return ret >>> 0;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* The indent of a cell, in Excel's indent steps (0 when it has none).
|
|
89
|
+
*
|
|
90
|
+
* Indent lives on the cell's style, and a spreadsheet only honours it for
|
|
91
|
+
* left, right and distributed alignment - but the number is returned as
|
|
92
|
+
* the file states it, whatever the alignment.
|
|
93
|
+
* @param {number} sheet
|
|
94
|
+
* @param {string} address
|
|
95
|
+
* @returns {number}
|
|
96
|
+
*/
|
|
97
|
+
cellIndent(sheet, address) {
|
|
98
|
+
const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
99
|
+
const len0 = WASM_VECTOR_LEN;
|
|
100
|
+
const ret = wasm.book_cellIndent(this.__wbg_ptr, sheet, ptr0, len0);
|
|
101
|
+
if (ret[2]) {
|
|
102
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
103
|
+
}
|
|
104
|
+
return ret[0] >>> 0;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* The same by 1-based row and column.
|
|
108
|
+
* @param {number} sheet
|
|
109
|
+
* @param {number} row
|
|
110
|
+
* @param {number} column
|
|
111
|
+
* @returns {number}
|
|
112
|
+
*/
|
|
113
|
+
cellIndentAt(sheet, row, column) {
|
|
114
|
+
const ret = wasm.book_cellIndentAt(this.__wbg_ptr, sheet, row, column);
|
|
115
|
+
if (ret[2]) {
|
|
116
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
117
|
+
}
|
|
118
|
+
return ret[0] >>> 0;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* How a cell is painted: number format, font, fill, borders and text
|
|
122
|
+
* placement, as the file states them.
|
|
123
|
+
*
|
|
124
|
+
* A cell the file says nothing about answers with Excel's defaults, which
|
|
125
|
+
* is what Excel itself shows for it.
|
|
126
|
+
* @param {number} sheet
|
|
127
|
+
* @param {string} address
|
|
128
|
+
* @returns {CellStyle}
|
|
129
|
+
*/
|
|
130
|
+
cellStyle(sheet, address) {
|
|
131
|
+
const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
132
|
+
const len0 = WASM_VECTOR_LEN;
|
|
133
|
+
const ret = wasm.book_cellStyle(this.__wbg_ptr, sheet, ptr0, len0);
|
|
134
|
+
if (ret[2]) {
|
|
135
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
136
|
+
}
|
|
137
|
+
return takeFromExternrefTable0(ret[0]);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* The same by 1-based row and column.
|
|
141
|
+
* @param {number} sheet
|
|
142
|
+
* @param {number} row
|
|
143
|
+
* @param {number} column
|
|
144
|
+
* @returns {CellStyle}
|
|
145
|
+
*/
|
|
146
|
+
cellStyleAt(sheet, row, column) {
|
|
147
|
+
const ret = wasm.book_cellStyleAt(this.__wbg_ptr, sheet, row, column);
|
|
148
|
+
if (ret[2]) {
|
|
149
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
150
|
+
}
|
|
151
|
+
return takeFromExternrefTable0(ret[0]);
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Empties a cell, style and all.
|
|
155
|
+
* @param {number} sheet
|
|
156
|
+
* @param {string} address
|
|
157
|
+
*/
|
|
158
|
+
clear(sheet, address) {
|
|
159
|
+
const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
160
|
+
const len0 = WASM_VECTOR_LEN;
|
|
161
|
+
const ret = wasm.book_clear(this.__wbg_ptr, sheet, ptr0, len0);
|
|
162
|
+
if (ret[1]) {
|
|
163
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* The same by 1-based row and column.
|
|
168
|
+
* @param {number} sheet
|
|
169
|
+
* @param {number} row
|
|
170
|
+
* @param {number} column
|
|
171
|
+
*/
|
|
172
|
+
clearAt(sheet, row, column) {
|
|
173
|
+
const ret = wasm.book_clearAt(this.__wbg_ptr, sheet, row, column);
|
|
174
|
+
if (ret[1]) {
|
|
175
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* The same for a column, named by its letters: `columnLevel(0, "C")`.
|
|
180
|
+
* @param {number} sheet
|
|
181
|
+
* @param {string} column
|
|
182
|
+
* @returns {number}
|
|
183
|
+
*/
|
|
184
|
+
columnLevel(sheet, column) {
|
|
185
|
+
const ptr0 = passStringToWasm0(column, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
186
|
+
const len0 = WASM_VECTOR_LEN;
|
|
187
|
+
const ret = wasm.book_columnLevel(this.__wbg_ptr, sheet, ptr0, len0);
|
|
188
|
+
if (ret[2]) {
|
|
189
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
190
|
+
}
|
|
191
|
+
return ret[0];
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Evaluates a formula (with or without the leading `=`) as if it sat in
|
|
195
|
+
* `address` of `sheet`, and returns its result.
|
|
196
|
+
* @param {number} sheet
|
|
197
|
+
* @param {string} address
|
|
198
|
+
* @param {string} formula
|
|
199
|
+
* @returns {CellValue}
|
|
200
|
+
*/
|
|
201
|
+
evaluate(sheet, address, formula) {
|
|
202
|
+
const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
203
|
+
const len0 = WASM_VECTOR_LEN;
|
|
204
|
+
const ptr1 = passStringToWasm0(formula, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
205
|
+
const len1 = WASM_VECTOR_LEN;
|
|
206
|
+
const ret = wasm.book_evaluate(this.__wbg_ptr, sheet, ptr0, len0, ptr1, len1);
|
|
207
|
+
if (ret[2]) {
|
|
208
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
209
|
+
}
|
|
210
|
+
return takeFromExternrefTable0(ret[0]);
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Reads an xlsx package from its bytes.
|
|
214
|
+
* @param {Uint8Array} bytes
|
|
215
|
+
* @returns {Book}
|
|
216
|
+
*/
|
|
217
|
+
static fromXlsx(bytes) {
|
|
218
|
+
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
219
|
+
const len0 = WASM_VECTOR_LEN;
|
|
220
|
+
const ret = wasm.book_fromXlsx(ptr0, len0);
|
|
221
|
+
if (ret[2]) {
|
|
222
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
223
|
+
}
|
|
224
|
+
return Book.__wrap(ret[0]);
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* The value at `address` on sheet `sheet`, as a JS number, string, boolean
|
|
228
|
+
* or `null`. A formula cell gives its cached result, not its text.
|
|
229
|
+
* @param {number} sheet
|
|
230
|
+
* @param {string} address
|
|
231
|
+
* @returns {CellValue}
|
|
232
|
+
*/
|
|
233
|
+
get(sheet, address) {
|
|
234
|
+
const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
235
|
+
const len0 = WASM_VECTOR_LEN;
|
|
236
|
+
const ret = wasm.book_get(this.__wbg_ptr, sheet, ptr0, len0);
|
|
237
|
+
if (ret[2]) {
|
|
238
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
239
|
+
}
|
|
240
|
+
return takeFromExternrefTable0(ret[0]);
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* The same by 1-based row and column, the numbers `ROW()` and `COLUMN()`
|
|
244
|
+
* return: `getAt(0, 4, 2)` is `B4`. Saves formatting an address only to
|
|
245
|
+
* parse it again.
|
|
246
|
+
* @param {number} sheet
|
|
247
|
+
* @param {number} row
|
|
248
|
+
* @param {number} column
|
|
249
|
+
* @returns {CellValue}
|
|
250
|
+
*/
|
|
251
|
+
getAt(sheet, row, column) {
|
|
252
|
+
const ret = wasm.book_getAt(this.__wbg_ptr, sheet, row, column);
|
|
253
|
+
if (ret[2]) {
|
|
254
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
255
|
+
}
|
|
256
|
+
return takeFromExternrefTable0(ret[0]);
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* The cell as a spreadsheet would display it: the value run through its
|
|
260
|
+
* number format, so `0.256` under `0.0%` reads `25.6%`.
|
|
261
|
+
* @param {number} sheet
|
|
262
|
+
* @param {string} address
|
|
263
|
+
* @returns {string}
|
|
264
|
+
*/
|
|
265
|
+
getFormatted(sheet, address) {
|
|
266
|
+
let deferred3_0;
|
|
267
|
+
let deferred3_1;
|
|
268
|
+
try {
|
|
269
|
+
const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
270
|
+
const len0 = WASM_VECTOR_LEN;
|
|
271
|
+
const ret = wasm.book_getFormatted(this.__wbg_ptr, sheet, ptr0, len0);
|
|
272
|
+
var ptr2 = ret[0];
|
|
273
|
+
var len2 = ret[1];
|
|
274
|
+
if (ret[3]) {
|
|
275
|
+
ptr2 = 0; len2 = 0;
|
|
276
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
277
|
+
}
|
|
278
|
+
deferred3_0 = ptr2;
|
|
279
|
+
deferred3_1 = len2;
|
|
280
|
+
return getStringFromWasm0(ptr2, len2);
|
|
281
|
+
} finally {
|
|
282
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* The same by 1-based row and column.
|
|
287
|
+
* @param {number} sheet
|
|
288
|
+
* @param {number} row
|
|
289
|
+
* @param {number} column
|
|
290
|
+
* @returns {string}
|
|
291
|
+
*/
|
|
292
|
+
getFormattedAt(sheet, row, column) {
|
|
293
|
+
let deferred2_0;
|
|
294
|
+
let deferred2_1;
|
|
295
|
+
try {
|
|
296
|
+
const ret = wasm.book_getFormattedAt(this.__wbg_ptr, sheet, row, column);
|
|
297
|
+
var ptr1 = ret[0];
|
|
298
|
+
var len1 = ret[1];
|
|
299
|
+
if (ret[3]) {
|
|
300
|
+
ptr1 = 0; len1 = 0;
|
|
301
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
302
|
+
}
|
|
303
|
+
deferred2_0 = ptr1;
|
|
304
|
+
deferred2_1 = len1;
|
|
305
|
+
return getStringFromWasm0(ptr1, len1);
|
|
306
|
+
} finally {
|
|
307
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* The formula text of a cell without its leading `=`, or `undefined` when
|
|
312
|
+
* the cell holds a plain value.
|
|
313
|
+
* @param {number} sheet
|
|
314
|
+
* @param {string} address
|
|
315
|
+
* @returns {string | undefined}
|
|
316
|
+
*/
|
|
317
|
+
getFormula(sheet, address) {
|
|
318
|
+
const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
319
|
+
const len0 = WASM_VECTOR_LEN;
|
|
320
|
+
const ret = wasm.book_getFormula(this.__wbg_ptr, sheet, ptr0, len0);
|
|
321
|
+
let v2;
|
|
322
|
+
if (ret[0] !== 0) {
|
|
323
|
+
v2 = getStringFromWasm0(ret[0], ret[1]);
|
|
324
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
325
|
+
}
|
|
326
|
+
return v2;
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* The same by 1-based row and column.
|
|
330
|
+
* @param {number} sheet
|
|
331
|
+
* @param {number} row
|
|
332
|
+
* @param {number} column
|
|
333
|
+
* @returns {string | undefined}
|
|
334
|
+
*/
|
|
335
|
+
getFormulaAt(sheet, row, column) {
|
|
336
|
+
const ret = wasm.book_getFormulaAt(this.__wbg_ptr, sheet, row, column);
|
|
337
|
+
let v1;
|
|
338
|
+
if (ret[0] !== 0) {
|
|
339
|
+
v1 = getStringFromWasm0(ret[0], ret[1]);
|
|
340
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
341
|
+
}
|
|
342
|
+
return v1;
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* A rectangle of cells, row by row. One call across the boundary instead
|
|
346
|
+
* of one per cell, which is what makes reading a sheet worth doing.
|
|
347
|
+
* @param {number} sheet
|
|
348
|
+
* @param {string} range
|
|
349
|
+
* @returns {CellGrid}
|
|
350
|
+
*/
|
|
351
|
+
getRange(sheet, range) {
|
|
352
|
+
const ptr0 = passStringToWasm0(range, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
353
|
+
const len0 = WASM_VECTOR_LEN;
|
|
354
|
+
const ret = wasm.book_getRange(this.__wbg_ptr, sheet, ptr0, len0);
|
|
355
|
+
if (ret[2]) {
|
|
356
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
357
|
+
}
|
|
358
|
+
return takeFromExternrefTable0(ret[0]);
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* The same by numbers: the top-left cell, then how many rows and columns
|
|
362
|
+
* to take. `getRangeAt(0, 1, 1, 3, 2)` is `A1:B3`.
|
|
363
|
+
* @param {number} sheet
|
|
364
|
+
* @param {number} row
|
|
365
|
+
* @param {number} column
|
|
366
|
+
* @param {number} rows
|
|
367
|
+
* @param {number} columns
|
|
368
|
+
* @returns {CellGrid}
|
|
369
|
+
*/
|
|
370
|
+
getRangeAt(sheet, row, column, rows, columns) {
|
|
371
|
+
const ret = wasm.book_getRangeAt(this.__wbg_ptr, sheet, row, column, rows, columns);
|
|
372
|
+
if (ret[2]) {
|
|
373
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
374
|
+
}
|
|
375
|
+
return takeFromExternrefTable0(ret[0]);
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* A whole row in one crossing of the boundary: values, displayed text,
|
|
379
|
+
* bold and indent, plus whether the row is hidden.
|
|
380
|
+
*
|
|
381
|
+
* The arrays run from column 1 to the last column this row has a cell in,
|
|
382
|
+
* so a row of ten cells costs one call rather than forty.
|
|
383
|
+
*
|
|
384
|
+
* `formatted` is what the number format makes of each value, and building
|
|
385
|
+
* it allocates a string per cell - which a caller reading values does not
|
|
386
|
+
* want to pay half a sheet over. Pass `false` and the field comes back
|
|
387
|
+
* `null`; `getFormattedAt` still answers for the cells that need it.
|
|
388
|
+
* @param {number} sheet
|
|
389
|
+
* @param {number} row
|
|
390
|
+
* @param {boolean | null} [formatted]
|
|
391
|
+
* @returns {SheetRow}
|
|
392
|
+
*/
|
|
393
|
+
getRowAt(sheet, row, formatted) {
|
|
394
|
+
const ret = wasm.book_getRowAt(this.__wbg_ptr, sheet, row, isLikeNone(formatted) ? 0xFFFFFF : formatted ? 1 : 0);
|
|
395
|
+
if (ret[2]) {
|
|
396
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
397
|
+
}
|
|
398
|
+
return takeFromExternrefTable0(ret[0]);
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* The merged areas of a sheet, as `"A1:C1"` strings in the order the file
|
|
402
|
+
* lists them.
|
|
403
|
+
* @param {number} sheet
|
|
404
|
+
* @returns {string[]}
|
|
405
|
+
*/
|
|
406
|
+
mergedRanges(sheet) {
|
|
407
|
+
const ret = wasm.book_mergedRanges(this.__wbg_ptr, sheet);
|
|
408
|
+
if (ret[3]) {
|
|
409
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
410
|
+
}
|
|
411
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]);
|
|
412
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
413
|
+
return v1;
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* The merged areas of a sheet as numbers: four per area, `[r1, c1, r2,
|
|
417
|
+
* c2]`, rows and columns 1-based.
|
|
418
|
+
*
|
|
419
|
+
* One typed array instead of a JS string per area, which is what a sheet
|
|
420
|
+
* carrying three hundred thousand of them needs.
|
|
421
|
+
* @param {number} sheet
|
|
422
|
+
* @returns {Uint32Array}
|
|
423
|
+
*/
|
|
424
|
+
mergedRangesAt(sheet) {
|
|
425
|
+
const ret = wasm.book_mergedRangesAt(this.__wbg_ptr, sheet);
|
|
426
|
+
if (ret[2]) {
|
|
427
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
428
|
+
}
|
|
429
|
+
return takeFromExternrefTable0(ret[0]);
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* A new workbook with one empty sheet.
|
|
433
|
+
*/
|
|
434
|
+
constructor() {
|
|
435
|
+
const ret = wasm.book_new();
|
|
436
|
+
this.__wbg_ptr = ret;
|
|
437
|
+
BookFinalization.register(this, this.__wbg_ptr, this);
|
|
438
|
+
return this;
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* Reads a workbook of any format this crate supports, working the format
|
|
442
|
+
* out from the bytes themselves.
|
|
443
|
+
*
|
|
444
|
+
* `name` is the file name they came from, if the caller has one: it
|
|
445
|
+
* settles what the bytes cannot say (a `.csv` against a `.html`) and names
|
|
446
|
+
* the sheet of a SYLK file.
|
|
447
|
+
* @param {Uint8Array} bytes
|
|
448
|
+
* @param {string | null} [name]
|
|
449
|
+
* @param {number | null} [max_expanded]
|
|
450
|
+
* @param {Function | null} [on_progress]
|
|
451
|
+
* @returns {Book}
|
|
452
|
+
*/
|
|
453
|
+
static read(bytes, name, max_expanded, on_progress) {
|
|
454
|
+
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
455
|
+
const len0 = WASM_VECTOR_LEN;
|
|
456
|
+
var ptr1 = isLikeNone(name) ? 0 : passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
457
|
+
var len1 = WASM_VECTOR_LEN;
|
|
458
|
+
const ret = wasm.book_read(ptr0, len0, ptr1, len1, !isLikeNone(max_expanded), isLikeNone(max_expanded) ? 0 : max_expanded, isLikeNone(on_progress) ? 0 : addToExternrefTable0(on_progress));
|
|
459
|
+
if (ret[2]) {
|
|
460
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
461
|
+
}
|
|
462
|
+
return Book.__wrap(ret[0]);
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* Recomputes every formula and stores the results beside them, so that
|
|
466
|
+
* `get` and `toCsv` show this engine's answers rather than the cache the
|
|
467
|
+
* file was saved with. Returns how many formulas were computed.
|
|
468
|
+
*
|
|
469
|
+
* With no argument the whole workbook is recomputed; with a sheet index,
|
|
470
|
+
* only that sheet's formulas are - though they still read the whole
|
|
471
|
+
* workbook, as a cross-sheet reference must.
|
|
472
|
+
* @param {number | null} [sheet]
|
|
473
|
+
* @param {Function | null} [on_progress]
|
|
474
|
+
* @returns {number}
|
|
475
|
+
*/
|
|
476
|
+
recalculate(sheet, on_progress) {
|
|
477
|
+
const ret = wasm.book_recalculate(this.__wbg_ptr, isLikeNone(sheet) ? Number.MAX_SAFE_INTEGER : (sheet) >>> 0, isLikeNone(on_progress) ? 0 : addToExternrefTable0(on_progress));
|
|
478
|
+
return ret >>> 0;
|
|
479
|
+
}
|
|
480
|
+
/**
|
|
481
|
+
* Recomputes the formula in one cell and stores its result. Returns
|
|
482
|
+
* whether there was a formula there.
|
|
483
|
+
*
|
|
484
|
+
* Not the same as `recalculateFrom`, which recomputes the formulas
|
|
485
|
+
* *reading* this cell and leaves the cell itself alone.
|
|
486
|
+
* @param {number} sheet
|
|
487
|
+
* @param {string} address
|
|
488
|
+
* @returns {boolean}
|
|
489
|
+
*/
|
|
490
|
+
recalculateCell(sheet, address) {
|
|
491
|
+
const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
492
|
+
const len0 = WASM_VECTOR_LEN;
|
|
493
|
+
const ret = wasm.book_recalculateCell(this.__wbg_ptr, sheet, ptr0, len0);
|
|
494
|
+
if (ret[2]) {
|
|
495
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
496
|
+
}
|
|
497
|
+
return ret[0] !== 0;
|
|
498
|
+
}
|
|
499
|
+
/**
|
|
500
|
+
* The same by 1-based row and column.
|
|
501
|
+
* @param {number} sheet
|
|
502
|
+
* @param {number} row
|
|
503
|
+
* @param {number} column
|
|
504
|
+
* @returns {boolean}
|
|
505
|
+
*/
|
|
506
|
+
recalculateCellAt(sheet, row, column) {
|
|
507
|
+
const ret = wasm.book_recalculateCellAt(this.__wbg_ptr, sheet, row, column);
|
|
508
|
+
if (ret[2]) {
|
|
509
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
510
|
+
}
|
|
511
|
+
return ret[0] !== 0;
|
|
512
|
+
}
|
|
513
|
+
/**
|
|
514
|
+
* Recomputes only what depends on one cell that changed - the formulas
|
|
515
|
+
* reading it, the formulas reading those, and so on. Returns how many were
|
|
516
|
+
* computed. This is the pass to run after `set`.
|
|
517
|
+
*
|
|
518
|
+
* For a batch of edits use `recalculateFromMany`, which answers them all
|
|
519
|
+
* in one pass.
|
|
520
|
+
* @param {number} sheet
|
|
521
|
+
* @param {string} address
|
|
522
|
+
* @returns {number}
|
|
523
|
+
*/
|
|
524
|
+
recalculateFrom(sheet, address) {
|
|
525
|
+
const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
526
|
+
const len0 = WASM_VECTOR_LEN;
|
|
527
|
+
const ret = wasm.book_recalculateFrom(this.__wbg_ptr, sheet, ptr0, len0);
|
|
528
|
+
if (ret[2]) {
|
|
529
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
530
|
+
}
|
|
531
|
+
return ret[0] >>> 0;
|
|
532
|
+
}
|
|
533
|
+
/**
|
|
534
|
+
* The same by 1-based row and column.
|
|
535
|
+
* @param {number} sheet
|
|
536
|
+
* @param {number} row
|
|
537
|
+
* @param {number} column
|
|
538
|
+
* @returns {number}
|
|
539
|
+
*/
|
|
540
|
+
recalculateFromAt(sheet, row, column) {
|
|
541
|
+
const ret = wasm.book_recalculateFromAt(this.__wbg_ptr, sheet, row, column);
|
|
542
|
+
if (ret[2]) {
|
|
543
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
544
|
+
}
|
|
545
|
+
return ret[0] >>> 0;
|
|
546
|
+
}
|
|
547
|
+
/**
|
|
548
|
+
* The same for a batch of cells, all on sheet `sheet`, answered in one
|
|
549
|
+
* pass: editing a hundred cells costs one walk of the workbook, not a
|
|
550
|
+
* hundred.
|
|
551
|
+
*
|
|
552
|
+
* The index of what reads what is built on the first call and kept, so a
|
|
553
|
+
* run of edits parses the formulas only once. `set` keeps it in step.
|
|
554
|
+
* @param {number} sheet
|
|
555
|
+
* @param {string[]} addresses
|
|
556
|
+
* @returns {number}
|
|
557
|
+
*/
|
|
558
|
+
recalculateFromMany(sheet, addresses) {
|
|
559
|
+
const ptr0 = passArrayJsValueToWasm0(addresses, wasm.__wbindgen_malloc);
|
|
560
|
+
const len0 = WASM_VECTOR_LEN;
|
|
561
|
+
const ret = wasm.book_recalculateFromMany(this.__wbg_ptr, sheet, ptr0, len0);
|
|
562
|
+
if (ret[2]) {
|
|
563
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
564
|
+
}
|
|
565
|
+
return ret[0] >>> 0;
|
|
566
|
+
}
|
|
567
|
+
/**
|
|
568
|
+
* Registers a function of your own, callable from any formula in the
|
|
569
|
+
* workbook by that name.
|
|
570
|
+
*
|
|
571
|
+
* The function is handed the arguments already computed - a range arrives
|
|
572
|
+
* as an array of arrays - and whatever it returns becomes the value. A
|
|
573
|
+
* name a built-in claims stays the built-in's: a workbook where `SUM`
|
|
574
|
+
* means something else is a workbook nobody else can read.
|
|
575
|
+
*
|
|
576
|
+
* ```js
|
|
577
|
+
* book.registerFunction("MYRATE", (base) => base * 1.5 + 0.5);
|
|
578
|
+
* book.evaluate(0, "A1", "=MYRATE(10)"); // 15.5
|
|
579
|
+
* ```
|
|
580
|
+
* @param {string} name
|
|
581
|
+
* @param {Function} _function
|
|
582
|
+
*/
|
|
583
|
+
registerFunction(name, _function) {
|
|
584
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
585
|
+
const len0 = WASM_VECTOR_LEN;
|
|
586
|
+
wasm.book_registerFunction(this.__wbg_ptr, ptr0, len0, _function);
|
|
587
|
+
}
|
|
588
|
+
/**
|
|
589
|
+
* The names registered, in no particular order.
|
|
590
|
+
* @returns {string[]}
|
|
591
|
+
*/
|
|
592
|
+
registeredFunctions() {
|
|
593
|
+
const ret = wasm.book_registeredFunctions(this.__wbg_ptr);
|
|
594
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]);
|
|
595
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
596
|
+
return v1;
|
|
597
|
+
}
|
|
598
|
+
/**
|
|
599
|
+
* Renames a sheet.
|
|
600
|
+
* @param {number} sheet
|
|
601
|
+
* @param {string} title
|
|
602
|
+
*/
|
|
603
|
+
renameSheet(sheet, title) {
|
|
604
|
+
const ptr0 = passStringToWasm0(title, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
605
|
+
const len0 = WASM_VECTOR_LEN;
|
|
606
|
+
const ret = wasm.book_renameSheet(this.__wbg_ptr, sheet, ptr0, len0);
|
|
607
|
+
if (ret[1]) {
|
|
608
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
/**
|
|
612
|
+
* Whether a row is hidden. `row` is the number a user sees.
|
|
613
|
+
* @param {number} sheet
|
|
614
|
+
* @param {number} row
|
|
615
|
+
* @returns {boolean}
|
|
616
|
+
*/
|
|
617
|
+
rowHidden(sheet, row) {
|
|
618
|
+
const ret = wasm.book_rowHidden(this.__wbg_ptr, sheet, row);
|
|
619
|
+
if (ret[2]) {
|
|
620
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
621
|
+
}
|
|
622
|
+
return ret[0] !== 0;
|
|
623
|
+
}
|
|
624
|
+
/**
|
|
625
|
+
* How deeply a row is grouped: 0 when it is not, 1 for the outermost
|
|
626
|
+
* group, and so on. `row` is the number a user sees.
|
|
627
|
+
* @param {number} sheet
|
|
628
|
+
* @param {number} row
|
|
629
|
+
* @returns {number}
|
|
630
|
+
*/
|
|
631
|
+
rowLevel(sheet, row) {
|
|
632
|
+
const ret = wasm.book_rowLevel(this.__wbg_ptr, sheet, row);
|
|
633
|
+
if (ret[2]) {
|
|
634
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
635
|
+
}
|
|
636
|
+
return ret[0];
|
|
637
|
+
}
|
|
638
|
+
/**
|
|
639
|
+
* Writes a value: a number, boolean, or string. A string starting with `=`
|
|
640
|
+
* becomes a formula.
|
|
641
|
+
* @param {number} index
|
|
642
|
+
* @param {string} address
|
|
643
|
+
* @param {CellValue} value
|
|
644
|
+
*/
|
|
645
|
+
set(index, address, value) {
|
|
646
|
+
const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
647
|
+
const len0 = WASM_VECTOR_LEN;
|
|
648
|
+
const ret = wasm.book_set(this.__wbg_ptr, index, ptr0, len0, value);
|
|
649
|
+
if (ret[1]) {
|
|
650
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
/**
|
|
654
|
+
* Sets that tab.
|
|
655
|
+
* @param {number} sheet
|
|
656
|
+
*/
|
|
657
|
+
setActiveSheet(sheet) {
|
|
658
|
+
const ret = wasm.book_setActiveSheet(this.__wbg_ptr, sheet);
|
|
659
|
+
if (ret[1]) {
|
|
660
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
/**
|
|
664
|
+
* The same by 1-based row and column.
|
|
665
|
+
* @param {number} sheet
|
|
666
|
+
* @param {number} row
|
|
667
|
+
* @param {number} column
|
|
668
|
+
* @param {CellValue} value
|
|
669
|
+
*/
|
|
670
|
+
setAt(sheet, row, column, value) {
|
|
671
|
+
const ret = wasm.book_setAt(this.__wbg_ptr, sheet, row, column, value);
|
|
672
|
+
if (ret[1]) {
|
|
673
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
/**
|
|
677
|
+
* Writes a rectangle of values with `at` as its top-left corner. Rows may
|
|
678
|
+
* differ in length; a `null` leaves its cell empty.
|
|
679
|
+
* @param {number} sheet
|
|
680
|
+
* @param {string} at
|
|
681
|
+
* @param {CellGrid} values
|
|
682
|
+
*/
|
|
683
|
+
setRange(sheet, at, values) {
|
|
684
|
+
const ptr0 = passStringToWasm0(at, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
685
|
+
const len0 = WASM_VECTOR_LEN;
|
|
686
|
+
const ret = wasm.book_setRange(this.__wbg_ptr, sheet, ptr0, len0, values);
|
|
687
|
+
if (ret[1]) {
|
|
688
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
/**
|
|
692
|
+
* The same with the corner given as 1-based row and column.
|
|
693
|
+
* @param {number} sheet
|
|
694
|
+
* @param {number} row
|
|
695
|
+
* @param {number} column
|
|
696
|
+
* @param {CellGrid} values
|
|
697
|
+
*/
|
|
698
|
+
setRangeAt(sheet, row, column, values) {
|
|
699
|
+
const ret = wasm.book_setRangeAt(this.__wbg_ptr, sheet, row, column, values);
|
|
700
|
+
if (ret[1]) {
|
|
701
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
/**
|
|
705
|
+
* The tab index of a sheet by name, or `undefined` when there is none.
|
|
706
|
+
* Names are compared the way Excel does, ignoring case.
|
|
707
|
+
* @param {string} name
|
|
708
|
+
* @returns {number | undefined}
|
|
709
|
+
*/
|
|
710
|
+
sheetIndex(name) {
|
|
711
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
712
|
+
const len0 = WASM_VECTOR_LEN;
|
|
713
|
+
const ret = wasm.book_sheetIndex(this.__wbg_ptr, ptr0, len0);
|
|
714
|
+
return ret === Number.MAX_SAFE_INTEGER ? undefined : ret;
|
|
715
|
+
}
|
|
716
|
+
/**
|
|
717
|
+
* Sheet titles, in tab order.
|
|
718
|
+
* @returns {string[]}
|
|
719
|
+
*/
|
|
720
|
+
sheetNames() {
|
|
721
|
+
const ret = wasm.book_sheetNames(this.__wbg_ptr);
|
|
722
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]);
|
|
723
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
724
|
+
return v1;
|
|
725
|
+
}
|
|
726
|
+
/**
|
|
727
|
+
* Whether a sheet has a tab: `"visible"`, `"hidden"` or `"veryHidden"`.
|
|
728
|
+
*
|
|
729
|
+
* `sheetNames` lists every sheet, hidden ones included, because that is
|
|
730
|
+
* what the index of every other call counts.
|
|
731
|
+
* @param {number} sheet
|
|
732
|
+
* @returns {string}
|
|
733
|
+
*/
|
|
734
|
+
sheetVisibility(sheet) {
|
|
735
|
+
let deferred2_0;
|
|
736
|
+
let deferred2_1;
|
|
737
|
+
try {
|
|
738
|
+
const ret = wasm.book_sheetVisibility(this.__wbg_ptr, sheet);
|
|
739
|
+
var ptr1 = ret[0];
|
|
740
|
+
var len1 = ret[1];
|
|
741
|
+
if (ret[3]) {
|
|
742
|
+
ptr1 = 0; len1 = 0;
|
|
743
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
744
|
+
}
|
|
745
|
+
deferred2_0 = ptr1;
|
|
746
|
+
deferred2_1 = len1;
|
|
747
|
+
return getStringFromWasm0(ptr1, len1);
|
|
748
|
+
} finally {
|
|
749
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
/**
|
|
753
|
+
* One sheet as CSV.
|
|
754
|
+
* @param {number} sheet
|
|
755
|
+
* @returns {string}
|
|
756
|
+
*/
|
|
757
|
+
toCsv(sheet) {
|
|
758
|
+
let deferred2_0;
|
|
759
|
+
let deferred2_1;
|
|
760
|
+
try {
|
|
761
|
+
const ret = wasm.book_toCsv(this.__wbg_ptr, sheet);
|
|
762
|
+
var ptr1 = ret[0];
|
|
763
|
+
var len1 = ret[1];
|
|
764
|
+
if (ret[3]) {
|
|
765
|
+
ptr1 = 0; len1 = 0;
|
|
766
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
767
|
+
}
|
|
768
|
+
deferred2_0 = ptr1;
|
|
769
|
+
deferred2_1 = len1;
|
|
770
|
+
return getStringFromWasm0(ptr1, len1);
|
|
771
|
+
} finally {
|
|
772
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
/**
|
|
776
|
+
* The workbook as an HTML page, or one sheet of it. `fragment` leaves out
|
|
777
|
+
* the `<html>` wrapper, for embedding in a page that already has one.
|
|
778
|
+
* @param {number | null} [sheet]
|
|
779
|
+
* @param {boolean | null} [fragment]
|
|
780
|
+
* @returns {string}
|
|
781
|
+
*/
|
|
782
|
+
toHtml(sheet, fragment) {
|
|
783
|
+
let deferred2_0;
|
|
784
|
+
let deferred2_1;
|
|
785
|
+
try {
|
|
786
|
+
const ret = wasm.book_toHtml(this.__wbg_ptr, isLikeNone(sheet) ? Number.MAX_SAFE_INTEGER : (sheet) >>> 0, isLikeNone(fragment) ? 0xFFFFFF : fragment ? 1 : 0);
|
|
787
|
+
var ptr1 = ret[0];
|
|
788
|
+
var len1 = ret[1];
|
|
789
|
+
if (ret[3]) {
|
|
790
|
+
ptr1 = 0; len1 = 0;
|
|
791
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
792
|
+
}
|
|
793
|
+
deferred2_0 = ptr1;
|
|
794
|
+
deferred2_1 = len1;
|
|
795
|
+
return getStringFromWasm0(ptr1, len1);
|
|
796
|
+
} finally {
|
|
797
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
/**
|
|
801
|
+
* The workbook as an `OpenDocument` spreadsheet.
|
|
802
|
+
* @returns {Uint8Array}
|
|
803
|
+
*/
|
|
804
|
+
toOds() {
|
|
805
|
+
const ret = wasm.book_toOds(this.__wbg_ptr);
|
|
806
|
+
if (ret[3]) {
|
|
807
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
808
|
+
}
|
|
809
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
810
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
811
|
+
return v1;
|
|
812
|
+
}
|
|
813
|
+
/**
|
|
814
|
+
* The workbook as a BIFF8 `.xls` file.
|
|
815
|
+
*
|
|
816
|
+
* The format cannot hold a formula as text, so every formula is written
|
|
817
|
+
* as its last computed value; call `recalculate` first if that matters.
|
|
818
|
+
* @returns {Uint8Array}
|
|
819
|
+
*/
|
|
820
|
+
toXls() {
|
|
821
|
+
const ret = wasm.book_toXls(this.__wbg_ptr);
|
|
822
|
+
if (ret[3]) {
|
|
823
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
824
|
+
}
|
|
825
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
826
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
827
|
+
return v1;
|
|
828
|
+
}
|
|
829
|
+
/**
|
|
830
|
+
* The workbook as an xlsx package.
|
|
831
|
+
* @param {Function | null} [on_progress]
|
|
832
|
+
* @returns {Uint8Array}
|
|
833
|
+
*/
|
|
834
|
+
toXlsx(on_progress) {
|
|
835
|
+
const ret = wasm.book_toXlsx(this.__wbg_ptr, isLikeNone(on_progress) ? 0 : addToExternrefTable0(on_progress));
|
|
836
|
+
if (ret[3]) {
|
|
837
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
838
|
+
}
|
|
839
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
840
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
841
|
+
return v1;
|
|
842
|
+
}
|
|
843
|
+
/**
|
|
844
|
+
* Forgets a function registered earlier; answers whether there was one.
|
|
845
|
+
* @param {string} name
|
|
846
|
+
* @returns {boolean}
|
|
847
|
+
*/
|
|
848
|
+
unregisterFunction(name) {
|
|
849
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
850
|
+
const len0 = WASM_VECTOR_LEN;
|
|
851
|
+
const ret = wasm.book_unregisterFunction(this.__wbg_ptr, ptr0, len0);
|
|
852
|
+
return ret !== 0;
|
|
853
|
+
}
|
|
854
|
+
/**
|
|
855
|
+
* The used range of a sheet as `A1:D9`, or `undefined` if it holds
|
|
856
|
+
* nothing. This is the rectangle to walk; the sheet itself is sparse.
|
|
857
|
+
* @param {number} sheet
|
|
858
|
+
* @returns {string | undefined}
|
|
859
|
+
*/
|
|
860
|
+
usedRange(sheet) {
|
|
861
|
+
const ret = wasm.book_usedRange(this.__wbg_ptr, sheet);
|
|
862
|
+
let v1;
|
|
863
|
+
if (ret[0] !== 0) {
|
|
864
|
+
v1 = getStringFromWasm0(ret[0], ret[1]);
|
|
865
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
866
|
+
}
|
|
867
|
+
return v1;
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
if (Symbol.dispose) Book.prototype[Symbol.dispose] = Book.prototype.free;
|
|
871
|
+
exports.Book = Book;
|
|
872
|
+
function __wbg_get_imports() {
|
|
873
|
+
const import0 = {
|
|
874
|
+
__proto__: null,
|
|
875
|
+
__wbg_Error_408e67f47ca7b58b: function(arg0, arg1) {
|
|
876
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
877
|
+
return ret;
|
|
878
|
+
},
|
|
879
|
+
__wbg___wbindgen_boolean_get_c9c83ebd41b34df3: function(arg0) {
|
|
880
|
+
const v = arg0;
|
|
881
|
+
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
882
|
+
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
883
|
+
},
|
|
884
|
+
__wbg___wbindgen_is_null_7d13f41e1a2d5140: function(arg0) {
|
|
885
|
+
const ret = arg0 === null;
|
|
886
|
+
return ret;
|
|
887
|
+
},
|
|
888
|
+
__wbg___wbindgen_is_undefined_6cff064c44e0d823: function(arg0) {
|
|
889
|
+
const ret = arg0 === undefined;
|
|
890
|
+
return ret;
|
|
891
|
+
},
|
|
892
|
+
__wbg___wbindgen_number_get_136b9679cab35cfb: function(arg0, arg1) {
|
|
893
|
+
const obj = arg1;
|
|
894
|
+
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
895
|
+
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
896
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
897
|
+
},
|
|
898
|
+
__wbg___wbindgen_string_get_d154f1e671052120: function(arg0, arg1) {
|
|
899
|
+
const obj = arg1;
|
|
900
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
901
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
902
|
+
var len1 = WASM_VECTOR_LEN;
|
|
903
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
904
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
905
|
+
},
|
|
906
|
+
__wbg___wbindgen_throw_bb96b2010945f0bc: function(arg0, arg1) {
|
|
907
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
908
|
+
},
|
|
909
|
+
__wbg_apply_6cd9daeacef161ce: function() { return handleError(function (arg0, arg1, arg2) {
|
|
910
|
+
const ret = Reflect.apply(arg0, arg1, arg2);
|
|
911
|
+
return ret;
|
|
912
|
+
}, arguments); },
|
|
913
|
+
__wbg_call_35dba3c747ad7521: function() { return handleError(function (arg0, arg1, arg2) {
|
|
914
|
+
const ret = arg0.call(arg1, arg2);
|
|
915
|
+
return ret;
|
|
916
|
+
}, arguments); },
|
|
917
|
+
__wbg_getRandomValues_436a51d0629d84e1: function() { return handleError(function (arg0, arg1) {
|
|
918
|
+
globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
|
|
919
|
+
}, arguments); },
|
|
920
|
+
__wbg_getTime_63fb0332e6c4ec17: function(arg0) {
|
|
921
|
+
const ret = arg0.getTime();
|
|
922
|
+
return ret;
|
|
923
|
+
},
|
|
924
|
+
__wbg_get_unchecked_e20b893aeafc3fca: function(arg0, arg1) {
|
|
925
|
+
const ret = arg0[arg1 >>> 0];
|
|
926
|
+
return ret;
|
|
927
|
+
},
|
|
928
|
+
__wbg_isArray_6339f732981044bf: function(arg0) {
|
|
929
|
+
const ret = Array.isArray(arg0);
|
|
930
|
+
return ret;
|
|
931
|
+
},
|
|
932
|
+
__wbg_length_ecfa2c63d3d0d82c: function(arg0) {
|
|
933
|
+
const ret = arg0.length;
|
|
934
|
+
return ret;
|
|
935
|
+
},
|
|
936
|
+
__wbg_new_0_f117d868b403dc07: function() {
|
|
937
|
+
const ret = new Date();
|
|
938
|
+
return ret;
|
|
939
|
+
},
|
|
940
|
+
__wbg_new_116be93542d39019: function() {
|
|
941
|
+
const ret = new Array();
|
|
942
|
+
return ret;
|
|
943
|
+
},
|
|
944
|
+
__wbg_new_ebe3e0f6837f0879: function() {
|
|
945
|
+
const ret = new Object();
|
|
946
|
+
return ret;
|
|
947
|
+
},
|
|
948
|
+
__wbg_new_from_slice_3eea173078478cfe: function(arg0, arg1) {
|
|
949
|
+
const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
|
|
950
|
+
return ret;
|
|
951
|
+
},
|
|
952
|
+
__wbg_new_from_slice_8aed4f0384605526: function(arg0, arg1) {
|
|
953
|
+
const ret = new Uint32Array(getArrayU32FromWasm0(arg0, arg1));
|
|
954
|
+
return ret;
|
|
955
|
+
},
|
|
956
|
+
__wbg_now_8b265300afd5f2b9: function() {
|
|
957
|
+
const ret = Date.now();
|
|
958
|
+
return ret;
|
|
959
|
+
},
|
|
960
|
+
__wbg_push_adb0107829f02d75: function(arg0, arg1) {
|
|
961
|
+
const ret = arg0.push(arg1);
|
|
962
|
+
return ret;
|
|
963
|
+
},
|
|
964
|
+
__wbg_set_8155bb79a948541b: function() { return handleError(function (arg0, arg1, arg2) {
|
|
965
|
+
const ret = Reflect.set(arg0, arg1, arg2);
|
|
966
|
+
return ret;
|
|
967
|
+
}, arguments); },
|
|
968
|
+
__wbindgen_cast_0000000000000001: function(arg0) {
|
|
969
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
970
|
+
const ret = arg0;
|
|
971
|
+
return ret;
|
|
972
|
+
},
|
|
973
|
+
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
974
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
975
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
976
|
+
return ret;
|
|
977
|
+
},
|
|
978
|
+
__wbindgen_init_externref_table: function() {
|
|
979
|
+
const table = wasm.__wbindgen_externrefs;
|
|
980
|
+
const offset = table.grow(4);
|
|
981
|
+
table.set(0, undefined);
|
|
982
|
+
table.set(offset + 0, undefined);
|
|
983
|
+
table.set(offset + 1, null);
|
|
984
|
+
table.set(offset + 2, true);
|
|
985
|
+
table.set(offset + 3, false);
|
|
986
|
+
},
|
|
987
|
+
};
|
|
988
|
+
return {
|
|
989
|
+
__proto__: null,
|
|
990
|
+
"./excelerate_bg.js": import0,
|
|
991
|
+
};
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
const BookFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
995
|
+
? { register: () => {}, unregister: () => {} }
|
|
996
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_book_free(ptr, 1));
|
|
997
|
+
|
|
998
|
+
function addToExternrefTable0(obj) {
|
|
999
|
+
const idx = wasm.__externref_table_alloc();
|
|
1000
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
1001
|
+
return idx;
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1004
|
+
function getArrayJsValueFromWasm0(ptr, len) {
|
|
1005
|
+
ptr = ptr >>> 0;
|
|
1006
|
+
const mem = getDataViewMemory0();
|
|
1007
|
+
const result = [];
|
|
1008
|
+
for (let i = ptr; i < ptr + 4 * len; i += 4) {
|
|
1009
|
+
result.push(wasm.__wbindgen_externrefs.get(mem.getUint32(i, true)));
|
|
1010
|
+
}
|
|
1011
|
+
wasm.__externref_drop_slice(ptr, len);
|
|
1012
|
+
return result;
|
|
1013
|
+
}
|
|
1014
|
+
|
|
1015
|
+
function getArrayU32FromWasm0(ptr, len) {
|
|
1016
|
+
ptr = ptr >>> 0;
|
|
1017
|
+
return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
|
1018
|
+
}
|
|
1019
|
+
|
|
1020
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
1021
|
+
ptr = ptr >>> 0;
|
|
1022
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
1023
|
+
}
|
|
1024
|
+
|
|
1025
|
+
let cachedDataViewMemory0 = null;
|
|
1026
|
+
function getDataViewMemory0() {
|
|
1027
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
1028
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
1029
|
+
}
|
|
1030
|
+
return cachedDataViewMemory0;
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1033
|
+
function getStringFromWasm0(ptr, len) {
|
|
1034
|
+
return decodeText(ptr >>> 0, len);
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
let cachedUint32ArrayMemory0 = null;
|
|
1038
|
+
function getUint32ArrayMemory0() {
|
|
1039
|
+
if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
|
|
1040
|
+
cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
|
|
1041
|
+
}
|
|
1042
|
+
return cachedUint32ArrayMemory0;
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
let cachedUint8ArrayMemory0 = null;
|
|
1046
|
+
function getUint8ArrayMemory0() {
|
|
1047
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
1048
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
1049
|
+
}
|
|
1050
|
+
return cachedUint8ArrayMemory0;
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
function handleError(f, args) {
|
|
1054
|
+
try {
|
|
1055
|
+
return f.apply(this, args);
|
|
1056
|
+
} catch (e) {
|
|
1057
|
+
const idx = addToExternrefTable0(e);
|
|
1058
|
+
wasm.__wbindgen_exn_store(idx);
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
function isLikeNone(x) {
|
|
1063
|
+
return x === undefined || x === null;
|
|
1064
|
+
}
|
|
1065
|
+
|
|
1066
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
1067
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
1068
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
1069
|
+
WASM_VECTOR_LEN = arg.length;
|
|
1070
|
+
return ptr;
|
|
1071
|
+
}
|
|
1072
|
+
|
|
1073
|
+
function passArrayJsValueToWasm0(array, malloc) {
|
|
1074
|
+
const ptr = malloc(array.length * 4, 4) >>> 0;
|
|
1075
|
+
for (let i = 0; i < array.length; i++) {
|
|
1076
|
+
const add = addToExternrefTable0(array[i]);
|
|
1077
|
+
getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
|
|
1078
|
+
}
|
|
1079
|
+
WASM_VECTOR_LEN = array.length;
|
|
1080
|
+
return ptr;
|
|
1081
|
+
}
|
|
1082
|
+
|
|
1083
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
1084
|
+
if (realloc === undefined) {
|
|
1085
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
1086
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
1087
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
1088
|
+
WASM_VECTOR_LEN = buf.length;
|
|
1089
|
+
return ptr;
|
|
1090
|
+
}
|
|
1091
|
+
|
|
1092
|
+
let len = arg.length;
|
|
1093
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
1094
|
+
|
|
1095
|
+
const mem = getUint8ArrayMemory0();
|
|
1096
|
+
|
|
1097
|
+
let offset = 0;
|
|
1098
|
+
|
|
1099
|
+
for (; offset < len; offset++) {
|
|
1100
|
+
const code = arg.charCodeAt(offset);
|
|
1101
|
+
if (code > 0x7F) break;
|
|
1102
|
+
mem[ptr + offset] = code;
|
|
1103
|
+
}
|
|
1104
|
+
if (offset !== len) {
|
|
1105
|
+
if (offset !== 0) {
|
|
1106
|
+
arg = arg.slice(offset);
|
|
1107
|
+
}
|
|
1108
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
1109
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
1110
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
1111
|
+
|
|
1112
|
+
offset += ret.written;
|
|
1113
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1116
|
+
WASM_VECTOR_LEN = offset;
|
|
1117
|
+
return ptr;
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1120
|
+
function takeFromExternrefTable0(idx) {
|
|
1121
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
1122
|
+
wasm.__externref_table_dealloc(idx);
|
|
1123
|
+
return value;
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1126
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
1127
|
+
cachedTextDecoder.decode();
|
|
1128
|
+
function decodeText(ptr, len) {
|
|
1129
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
1130
|
+
}
|
|
1131
|
+
|
|
1132
|
+
const cachedTextEncoder = new TextEncoder();
|
|
1133
|
+
|
|
1134
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
1135
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
1136
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
1137
|
+
view.set(buf);
|
|
1138
|
+
return {
|
|
1139
|
+
read: arg.length,
|
|
1140
|
+
written: buf.length
|
|
1141
|
+
};
|
|
1142
|
+
};
|
|
1143
|
+
}
|
|
1144
|
+
|
|
1145
|
+
let WASM_VECTOR_LEN = 0;
|
|
1146
|
+
|
|
1147
|
+
const wasmPath = `${__dirname}/excelerate_bg.wasm`;
|
|
1148
|
+
const wasmBytes = require('fs').readFileSync(wasmPath);
|
|
1149
|
+
const wasmModule = new WebAssembly.Module(wasmBytes);
|
|
1150
|
+
let wasmInstance = new WebAssembly.Instance(wasmModule, __wbg_get_imports());
|
|
1151
|
+
let wasm = wasmInstance.exports;
|
|
1152
|
+
wasm.__wbindgen_start();
|