@rowsncolumns/rnc-yrs-store 0.8.138

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.
@@ -0,0 +1,1323 @@
1
+ /* @ts-self-types="./rnc_yrs_store.d.ts" */
2
+
3
+ /**
4
+ * Thin wasm-bindgen shell over [`YDocEngine`]. Bytes cross as `Uint8Array` (`Vec<u8>`/`&[u8]`),
5
+ * results as JSON strings — matching `YrsSheetDoc`, so it builds for both wasm and native.
6
+ */
7
+ export class SpreadsheetEngine {
8
+ __destroy_into_raw() {
9
+ const ptr = this.__wbg_ptr;
10
+ this.__wbg_ptr = 0;
11
+ SpreadsheetEngineFinalization.unregister(this);
12
+ return ptr;
13
+ }
14
+ free() {
15
+ const ptr = this.__destroy_into_raw();
16
+ wasm.__wbg_spreadsheetengine_free(ptr, 0);
17
+ }
18
+ /**
19
+ * @param {number} sheet_id
20
+ * @param {string} title
21
+ */
22
+ addSheet(sheet_id, title) {
23
+ const ptr0 = passStringToWasm0(title, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
24
+ const len0 = WASM_VECTOR_LEN;
25
+ wasm.spreadsheetengine_addSheet(this.__wbg_ptr, sheet_id, ptr0, len0);
26
+ }
27
+ /**
28
+ * @param {string} json
29
+ * @returns {string}
30
+ */
31
+ applyCommand(json) {
32
+ let deferred3_0;
33
+ let deferred3_1;
34
+ try {
35
+ const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
36
+ const len0 = WASM_VECTOR_LEN;
37
+ const ret = wasm.spreadsheetengine_applyCommand(this.__wbg_ptr, ptr0, len0);
38
+ var ptr2 = ret[0];
39
+ var len2 = ret[1];
40
+ if (ret[3]) {
41
+ ptr2 = 0; len2 = 0;
42
+ throw takeFromExternrefTable0(ret[2]);
43
+ }
44
+ deferred3_0 = ptr2;
45
+ deferred3_1 = len2;
46
+ return getStringFromWasm0(ptr2, len2);
47
+ } finally {
48
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
49
+ }
50
+ }
51
+ /**
52
+ * `applyCommand` without write recording, undo history, or a `CommitResult` diff — and with
53
+ * `change-batch` eligible for the dense bulk path (>500k cells on an empty sheet land as
54
+ * column blocks). For hosts that discard the result, e.g. backend bulk ingestion.
55
+ * @param {string} json
56
+ */
57
+ applyCommandQuiet(json) {
58
+ const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
59
+ const len0 = WASM_VECTOR_LEN;
60
+ const ret = wasm.spreadsheetengine_applyCommandQuiet(this.__wbg_ptr, ptr0, len0);
61
+ if (ret[1]) {
62
+ throw takeFromExternrefTable0(ret[0]);
63
+ }
64
+ }
65
+ /**
66
+ * Merge a remote v1 update into the CRDT doc (`CollabSync.applyUpdate`); follow with `syncRemote()`
67
+ * to project + render. Split out of the old apply+project+commit so `useSpreadsheetEngine`'s collab
68
+ * bridge can drive applyUpdate→syncRemote without projecting twice. (`apply_remote_update` on the
69
+ * inner engine still does both in one call for the older bespoke/worker path.)
70
+ * @param {Uint8Array} bytes
71
+ */
72
+ applyUpdate(bytes) {
73
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
74
+ const len0 = WASM_VECTOR_LEN;
75
+ const ret = wasm.spreadsheetengine_applyUpdate(this.__wbg_ptr, ptr0, len0);
76
+ if (ret[1]) {
77
+ throw takeFromExternrefTable0(ret[0]);
78
+ }
79
+ }
80
+ /**
81
+ * Cold-block body cache diagnostics as JSON `{"hits", "misses", "bytes"}`.
82
+ * @returns {string}
83
+ */
84
+ blockCacheStats() {
85
+ let deferred1_0;
86
+ let deferred1_1;
87
+ try {
88
+ const ret = wasm.spreadsheetengine_blockCacheStats(this.__wbg_ptr);
89
+ deferred1_0 = ret[0];
90
+ deferred1_1 = ret[1];
91
+ return getStringFromWasm0(ret[0], ret[1]);
92
+ } finally {
93
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
94
+ }
95
+ }
96
+ /**
97
+ * @returns {boolean}
98
+ */
99
+ canRedo() {
100
+ const ret = wasm.spreadsheetengine_canRedo(this.__wbg_ptr);
101
+ return ret !== 0;
102
+ }
103
+ /**
104
+ * @returns {boolean}
105
+ */
106
+ canUndo() {
107
+ const ret = wasm.spreadsheetengine_canUndo(this.__wbg_ptr);
108
+ return ret !== 0;
109
+ }
110
+ /**
111
+ * Drop the entire undo/redo history (`SpreadsheetEngineLike.clearHistory`).
112
+ */
113
+ clearHistory() {
114
+ wasm.spreadsheetengine_clearHistory(this.__wbg_ptr);
115
+ }
116
+ /**
117
+ * Parse CSV text into a row-major grid of cell strings using the fast Rust `csv` reader, returned
118
+ * as JSON `Vec<Vec<String>>`. The host writes the grid into the sheet via a `change-batch` command
119
+ * so the values compute, persist, and collaborate through the normal engine path. Quoting,
120
+ * embedded newlines, and ragged rows are handled by the `csv` crate.
121
+ * RFC 4180 CSV of one sheet's merged view (blocks + hot plane, geometry-aware). Formulas
122
+ * export their computed display value, like Excel/Sheets "Save as CSV". One streaming pass
123
+ * over the store — built to run in a Web Worker for million-row sheets.
124
+ * Excel-style Ctrl/Cmd+Arrow target. One of `d_row`/`d_col` is ±1, the other 0; returns
125
+ * the moved coordinate (row for vertical, column for horizontal), 1-based.
126
+ * @param {number} sheet_id
127
+ * @param {number} row
128
+ * @param {number} col
129
+ * @param {number} d_row
130
+ * @param {number} d_col
131
+ * @param {number} limit
132
+ * @returns {number}
133
+ */
134
+ dataEdge(sheet_id, row, col, d_row, d_col, limit) {
135
+ const ret = wasm.spreadsheetengine_dataEdge(this.__wbg_ptr, sheet_id, row, col, d_row, d_col, limit);
136
+ return ret >>> 0;
137
+ }
138
+ /**
139
+ * How many inbound updates are deferred on a causal gap (a dropped/reordered transport
140
+ * drain). Zero in a healthy stream; persistently non-zero means the host should run a
141
+ * state-vector diff exchange (`encodeStateVector`/`encodeDiffV1`) to fill the gap.
142
+ * @returns {number}
143
+ */
144
+ deferredRemoteUpdates() {
145
+ const ret = wasm.spreadsheetengine_deferredRemoteUpdates(this.__wbg_ptr);
146
+ return ret >>> 0;
147
+ }
148
+ /**
149
+ * DEPENDENTS of a cell as a coordinate-array JSON (`SpreadsheetEngineLike.dependents`).
150
+ * @param {number} sheet_id
151
+ * @param {number} row
152
+ * @param {number} col
153
+ * @returns {string}
154
+ */
155
+ dependents(sheet_id, row, col) {
156
+ let deferred1_0;
157
+ let deferred1_1;
158
+ try {
159
+ const ret = wasm.spreadsheetengine_dependents(this.__wbg_ptr, sheet_id, row, col);
160
+ deferred1_0 = ret[0];
161
+ deferred1_1 = ret[1];
162
+ return getStringFromWasm0(ret[0], ret[1]);
163
+ } finally {
164
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
165
+ }
166
+ }
167
+ /**
168
+ * Document-level facets JSON: basicFilters, conditionalFormats, dataValidations,
169
+ * citations, namedRanges, tables, embeds.
170
+ * @returns {string}
171
+ */
172
+ documentFacets() {
173
+ let deferred1_0;
174
+ let deferred1_1;
175
+ try {
176
+ const ret = wasm.spreadsheetengine_documentFacets(this.__wbg_ptr);
177
+ deferred1_0 = ret[0];
178
+ deferred1_1 = ret[1];
179
+ return getStringFromWasm0(ret[0], ret[1]);
180
+ } finally {
181
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
182
+ }
183
+ }
184
+ /**
185
+ * The v1 diff the remote (by its state vector) is missing (`CollabSync.encodeDiffV1`) — apply the
186
+ * result to the transport `Y.Doc` to propagate this peer's local edits.
187
+ * @param {Uint8Array} remote_state_vector
188
+ * @returns {Uint8Array}
189
+ */
190
+ encodeDiffV1(remote_state_vector) {
191
+ const ptr0 = passArray8ToWasm0(remote_state_vector, wasm.__wbindgen_malloc);
192
+ const len0 = WASM_VECTOR_LEN;
193
+ const ret = wasm.spreadsheetengine_encodeDiffV1(this.__wbg_ptr, ptr0, len0);
194
+ if (ret[3]) {
195
+ throw takeFromExternrefTable0(ret[2]);
196
+ }
197
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
198
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
199
+ return v2;
200
+ }
201
+ /**
202
+ * Full document state as a v1 update (`CollabSync.encodeStateAsUpdate`) — the same bytes as
203
+ * `stateAsUpdate`, under the name `useSpreadsheetEngine`'s collab bridge calls.
204
+ * @returns {Uint8Array}
205
+ */
206
+ encodeStateAsUpdate() {
207
+ const ret = wasm.spreadsheetengine_encodeStateAsUpdate(this.__wbg_ptr);
208
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
209
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
210
+ return v1;
211
+ }
212
+ /**
213
+ * This peer's Yjs state vector — what it has seen (`CollabSync.encodeStateVector`).
214
+ * @returns {Uint8Array}
215
+ */
216
+ encodeStateVector() {
217
+ const ret = wasm.spreadsheetengine_encodeStateVector(this.__wbg_ptr);
218
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
219
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
220
+ return v1;
221
+ }
222
+ /**
223
+ * Scratch-evaluate a formula at a cell — `ExtendedValue` JSON or `"null"`. Read-only; powers
224
+ * the cell editor's live result preview (`onRequestCalculate`).
225
+ * @param {number} sheet_id
226
+ * @param {number} row
227
+ * @param {number} col
228
+ * @param {string} formula
229
+ * @returns {string}
230
+ */
231
+ evalFormula(sheet_id, row, col, formula) {
232
+ let deferred2_0;
233
+ let deferred2_1;
234
+ try {
235
+ const ptr0 = passStringToWasm0(formula, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
236
+ const len0 = WASM_VECTOR_LEN;
237
+ const ret = wasm.spreadsheetengine_evalFormula(this.__wbg_ptr, sheet_id, row, col, ptr0, len0);
238
+ deferred2_0 = ret[0];
239
+ deferred2_1 = ret[1];
240
+ return getStringFromWasm0(ret[0], ret[1]);
241
+ } finally {
242
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
243
+ }
244
+ }
245
+ /**
246
+ * @param {number} sheet_id
247
+ * @returns {string}
248
+ */
249
+ exportCsv(sheet_id) {
250
+ let deferred1_0;
251
+ let deferred1_1;
252
+ try {
253
+ const ret = wasm.spreadsheetengine_exportCsv(this.__wbg_ptr, sheet_id);
254
+ deferred1_0 = ret[0];
255
+ deferred1_1 = ret[1];
256
+ return getStringFromWasm0(ret[0], ret[1]);
257
+ } finally {
258
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
259
+ }
260
+ }
261
+ /**
262
+ * Export the whole workbook to in-memory XLSX bytes (a JS `Uint8Array`). The merged block+hot
263
+ * view of every sheet via the `rnc-export` writer; read-only, no recompute.
264
+ * @returns {Uint8Array}
265
+ */
266
+ exportXlsx() {
267
+ const ret = wasm.spreadsheetengine_exportXlsx(this.__wbg_ptr);
268
+ if (ret[3]) {
269
+ throw takeFromExternrefTable0(ret[2]);
270
+ }
271
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
272
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
273
+ return v1;
274
+ }
275
+ /**
276
+ * [`exportXlsx`] with client export options JSON
277
+ * (`{"includeNotes":bool,"citationsAsNotes":bool}`, camelCase, fields optional).
278
+ * @param {string} options_json
279
+ * @returns {Uint8Array}
280
+ */
281
+ exportXlsxWithOptions(options_json) {
282
+ const ptr0 = passStringToWasm0(options_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
283
+ const len0 = WASM_VECTOR_LEN;
284
+ const ret = wasm.spreadsheetengine_exportXlsxWithOptions(this.__wbg_ptr, ptr0, len0);
285
+ if (ret[3]) {
286
+ throw takeFromExternrefTable0(ret[2]);
287
+ }
288
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
289
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
290
+ return v2;
291
+ }
292
+ /**
293
+ * Off-window search: coordinates of every matching cell on `sheet_id` (JSON `SheetCoordinate[]`,
294
+ * row-major). The windowed UI calls this so next/prev can navigate to matches outside the loaded
295
+ * viewport. `ranges_json` = JSON `SheetRange[]` (empty = whole sheet); match-case/whole-word/regex.
296
+ * Distinct fill/font colors + CF icons in one column's body rows — JSON
297
+ * `{cellColors, fontColors, icons}`; the "Filter by color" picker on windowed hosts.
298
+ * @param {number} sheet_id
299
+ * @param {number} col
300
+ * @param {number} start_row
301
+ * @param {number} end_row
302
+ * @returns {string}
303
+ */
304
+ filterColors(sheet_id, col, start_row, end_row) {
305
+ let deferred1_0;
306
+ let deferred1_1;
307
+ try {
308
+ const ret = wasm.spreadsheetengine_filterColors(this.__wbg_ptr, sheet_id, col, start_row, end_row);
309
+ deferred1_0 = ret[0];
310
+ deferred1_1 = ret[1];
311
+ return getStringFromWasm0(ret[0], ret[1]);
312
+ } finally {
313
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
314
+ }
315
+ }
316
+ /**
317
+ * @param {number} sheet_id
318
+ * @param {string} ranges_json
319
+ * @param {string} find
320
+ * @param {boolean} match_case
321
+ * @param {boolean} whole_word
322
+ * @param {boolean} use_regex
323
+ * @returns {string}
324
+ */
325
+ findAll(sheet_id, ranges_json, find, match_case, whole_word, use_regex) {
326
+ let deferred3_0;
327
+ let deferred3_1;
328
+ try {
329
+ const ptr0 = passStringToWasm0(ranges_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
330
+ const len0 = WASM_VECTOR_LEN;
331
+ const ptr1 = passStringToWasm0(find, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
332
+ const len1 = WASM_VECTOR_LEN;
333
+ const ret = wasm.spreadsheetengine_findAll(this.__wbg_ptr, sheet_id, ptr0, len0, ptr1, len1, match_case, whole_word, use_regex);
334
+ deferred3_0 = ret[0];
335
+ deferred3_1 = ret[1];
336
+ return getStringFromWasm0(ret[0], ret[1]);
337
+ } finally {
338
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
339
+ }
340
+ }
341
+ /**
342
+ * Stream CSV text into the sheet's dense column blocks anchored at `(start_row, start_col)`
343
+ * (1-based); returns the number of rows written. Designed to run in a Web Worker: one synchronous
344
+ * call ingests the whole file off the main thread, after which the host takes the pending update
345
+ * and applies it to the collaborative document.
346
+ *
347
+ * Unlike the prior path — which materialized the whole grid as a single `change-batch` `Value`
348
+ * (≈50M `Value` nodes for a 10M-row file, the wasm-heap OOM) — this routes each row straight into
349
+ * the dense bulk path (one block write per column·32k-row stripe), and SKIPS the calc engine for a
350
+ * literal-only CSV (no formulas), so a 10M-row import stays well under the wasm 4 GiB ceiling.
351
+ * @param {string} text
352
+ * @param {number} sheet_id
353
+ * @param {number} start_row
354
+ * @param {number} start_col
355
+ * @returns {number}
356
+ */
357
+ importCsv(text, sheet_id, start_row, start_col) {
358
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
359
+ const len0 = WASM_VECTOR_LEN;
360
+ const ret = wasm.spreadsheetengine_importCsv(this.__wbg_ptr, ptr0, len0, sheet_id, start_row, start_col);
361
+ if (ret[2]) {
362
+ throw takeFromExternrefTable0(ret[1]);
363
+ }
364
+ return ret[0] >>> 0;
365
+ }
366
+ /**
367
+ * Bulk-import an xlsx workbook; returns a JSON summary `[{sheetId, name, rows, cols}]`.
368
+ * @param {Uint8Array} bytes
369
+ * @returns {string}
370
+ */
371
+ importXlsx(bytes) {
372
+ let deferred3_0;
373
+ let deferred3_1;
374
+ try {
375
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
376
+ const len0 = WASM_VECTOR_LEN;
377
+ const ret = wasm.spreadsheetengine_importXlsx(this.__wbg_ptr, ptr0, len0);
378
+ var ptr2 = ret[0];
379
+ var len2 = ret[1];
380
+ if (ret[3]) {
381
+ ptr2 = 0; len2 = 0;
382
+ throw takeFromExternrefTable0(ret[2]);
383
+ }
384
+ deferred3_0 = ptr2;
385
+ deferred3_1 = len2;
386
+ return getStringFromWasm0(ptr2, len2);
387
+ } finally {
388
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
389
+ }
390
+ }
391
+ /**
392
+ * Import exactly ONE sheet of the workbook — `sheet_id` is the positional (1-based) `sheetId`
393
+ * from [`listXlsxSheets`](Self::list_xlsx_sheets). Pass `finalize: false` on every call but the
394
+ * sequence's last: intermediate calls skip the whole-document recalc and the workbook-level
395
+ * facets (named ranges, slicers, pivots, calcPr, Power Query), which land on the `finalize`
396
+ * call together with the engine rebuild + recalc (or its over-cap skip — check
397
+ * [`lastImportRecalcSkipped`](Self::last_import_recalc_skipped) after finalizing). For a
398
+ * single-call import pass `finalize: true`. Returns `[{"sheetId": …, "name": …}]` for the
399
+ * imported sheet. See [`YDocEngine::import_xlsx_sheet`] for the full contract.
400
+ * @param {Uint8Array} bytes
401
+ * @param {number} sheet_id
402
+ * @param {boolean} finalize
403
+ * @returns {string}
404
+ */
405
+ importXlsxSheet(bytes, sheet_id, finalize) {
406
+ let deferred3_0;
407
+ let deferred3_1;
408
+ try {
409
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
410
+ const len0 = WASM_VECTOR_LEN;
411
+ const ret = wasm.spreadsheetengine_importXlsxSheet(this.__wbg_ptr, ptr0, len0, sheet_id, finalize);
412
+ var ptr2 = ret[0];
413
+ var len2 = ret[1];
414
+ if (ret[3]) {
415
+ ptr2 = 0; len2 = 0;
416
+ throw takeFromExternrefTable0(ret[2]);
417
+ }
418
+ deferred3_0 = ptr2;
419
+ deferred3_1 = len2;
420
+ return getStringFromWasm0(ptr2, len2);
421
+ } finally {
422
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
423
+ }
424
+ }
425
+ /**
426
+ * [`importXlsxSheet`](Self::import_xlsx_sheet) selecting the sheet by its display name
427
+ * (matched exactly against the workbook's `<sheet name=…>`).
428
+ * @param {Uint8Array} bytes
429
+ * @param {string} sheet_name
430
+ * @param {boolean} finalize
431
+ * @returns {string}
432
+ */
433
+ importXlsxSheetByName(bytes, sheet_name, finalize) {
434
+ let deferred4_0;
435
+ let deferred4_1;
436
+ try {
437
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
438
+ const len0 = WASM_VECTOR_LEN;
439
+ const ptr1 = passStringToWasm0(sheet_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
440
+ const len1 = WASM_VECTOR_LEN;
441
+ const ret = wasm.spreadsheetengine_importXlsxSheetByName(this.__wbg_ptr, ptr0, len0, ptr1, len1, finalize);
442
+ var ptr3 = ret[0];
443
+ var len3 = ret[1];
444
+ if (ret[3]) {
445
+ ptr3 = 0; len3 = 0;
446
+ throw takeFromExternrefTable0(ret[2]);
447
+ }
448
+ deferred4_0 = ptr3;
449
+ deferred4_1 = len3;
450
+ return getStringFromWasm0(ptr3, len3);
451
+ } finally {
452
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
453
+ }
454
+ }
455
+ /**
456
+ * Like [`SpreadsheetEngine::import_xlsx`] but for password-protected workbooks (ECMA-376 agile,
457
+ * standard AES, or RC4 CryptoAPI):
458
+ * decrypts with `password`, then runs the identical streaming import on the plaintext. A
459
+ * non-encrypted file imports directly (password ignored); a wrong password rejects with an error
460
+ * the UI can re-prompt on.
461
+ * @param {Uint8Array} bytes
462
+ * @param {string} password
463
+ * @returns {string}
464
+ */
465
+ importXlsxWithPassword(bytes, password) {
466
+ let deferred4_0;
467
+ let deferred4_1;
468
+ try {
469
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
470
+ const len0 = WASM_VECTOR_LEN;
471
+ const ptr1 = passStringToWasm0(password, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
472
+ const len1 = WASM_VECTOR_LEN;
473
+ const ret = wasm.spreadsheetengine_importXlsxWithPassword(this.__wbg_ptr, ptr0, len0, ptr1, len1);
474
+ var ptr3 = ret[0];
475
+ var len3 = ret[1];
476
+ if (ret[3]) {
477
+ ptr3 = 0; len3 = 0;
478
+ throw takeFromExternrefTable0(ret[2]);
479
+ }
480
+ deferred4_0 = ptr3;
481
+ deferred4_1 = len3;
482
+ return getStringFromWasm0(ptr3, len3);
483
+ } finally {
484
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
485
+ }
486
+ }
487
+ /**
488
+ * Whether the bytes are an encrypted (OLE/CFB) workbook needing a password (vs a plain `.xlsx`).
489
+ * @param {Uint8Array} bytes
490
+ * @returns {boolean}
491
+ */
492
+ isEncryptedXlsx(bytes) {
493
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
494
+ const len0 = WASM_VECTOR_LEN;
495
+ const ret = wasm.spreadsheetengine_isEncryptedXlsx(this.__wbg_ptr, ptr0, len0);
496
+ return ret !== 0;
497
+ }
498
+ /**
499
+ * Whether the last `importXlsx` skipped its post-import recalc (workbook past the recalc
500
+ * caps). See [`YDocEngine::last_import_recalc_skipped`].
501
+ * @returns {boolean}
502
+ */
503
+ lastImportRecalcSkipped() {
504
+ const ret = wasm.spreadsheetengine_lastImportRecalcSkipped(this.__wbg_ptr);
505
+ return ret !== 0;
506
+ }
507
+ /**
508
+ * Catalog the workbook's sheets WITHOUT ingesting any cells — JSON
509
+ * `[{sheetId, index, name, hidden}]` in tab order. The first step of the sheet-scoped import
510
+ * flow: list, then [`importXlsxSheet`](Self::import_xlsx_sheet) per sheet (in workbook order),
511
+ * draining `encodeDiffV1` between calls so each delta carries one sheet, not the workbook.
512
+ * @param {Uint8Array} bytes
513
+ * @returns {string}
514
+ */
515
+ listXlsxSheets(bytes) {
516
+ let deferred3_0;
517
+ let deferred3_1;
518
+ try {
519
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
520
+ const len0 = WASM_VECTOR_LEN;
521
+ const ret = wasm.spreadsheetengine_listXlsxSheets(this.__wbg_ptr, ptr0, len0);
522
+ var ptr2 = ret[0];
523
+ var len2 = ret[1];
524
+ if (ret[3]) {
525
+ ptr2 = 0; len2 = 0;
526
+ throw takeFromExternrefTable0(ret[2]);
527
+ }
528
+ deferred3_0 = ptr2;
529
+ deferred3_1 = len2;
530
+ return getStringFromWasm0(ptr2, len2);
531
+ } finally {
532
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
533
+ }
534
+ }
535
+ /**
536
+ * Hydrate the engine from an initial document JSON (`{ sheets, sheetData, styles }`); returns the
537
+ * full `CommitResult` JSON (`SpreadsheetEngineLike.loadDocument`).
538
+ * @param {string} document_json
539
+ * @returns {string}
540
+ */
541
+ loadDocument(document_json) {
542
+ let deferred3_0;
543
+ let deferred3_1;
544
+ try {
545
+ const ptr0 = passStringToWasm0(document_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
546
+ const len0 = WASM_VECTOR_LEN;
547
+ const ret = wasm.spreadsheetengine_loadDocument(this.__wbg_ptr, ptr0, len0);
548
+ var ptr2 = ret[0];
549
+ var len2 = ret[1];
550
+ if (ret[3]) {
551
+ ptr2 = 0; len2 = 0;
552
+ throw takeFromExternrefTable0(ret[2]);
553
+ }
554
+ deferred3_0 = ptr2;
555
+ deferred3_1 = len2;
556
+ return getStringFromWasm0(ptr2, len2);
557
+ } finally {
558
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
559
+ }
560
+ }
561
+ /**
562
+ * Bulk-load a peer's full-state snapshot (`stateAsUpdate`) and rebuild the calc engine — the
563
+ * join/bootstrap path. Returns a `CommitResult` JSON of every loaded cell (render the restored
564
+ * document in one shot). Not echoed back to the transport.
565
+ * @param {Uint8Array} bytes
566
+ * @returns {string}
567
+ */
568
+ loadFromUpdate(bytes) {
569
+ let deferred3_0;
570
+ let deferred3_1;
571
+ try {
572
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
573
+ const len0 = WASM_VECTOR_LEN;
574
+ const ret = wasm.spreadsheetengine_loadFromUpdate(this.__wbg_ptr, ptr0, len0);
575
+ var ptr2 = ret[0];
576
+ var len2 = ret[1];
577
+ if (ret[3]) {
578
+ ptr2 = 0; len2 = 0;
579
+ throw takeFromExternrefTable0(ret[2]);
580
+ }
581
+ deferred3_0 = ptr2;
582
+ deferred3_1 = len2;
583
+ return getStringFromWasm0(ptr2, len2);
584
+ } finally {
585
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
586
+ }
587
+ }
588
+ /**
589
+ * Load a full-state snapshot WITHOUT building the render commit — for hosts that already have
590
+ * the render projection (engine hydration for editing, the bulk-import worker). Skipping the
591
+ * 500k-cell snapshot serialization saves seconds on huge documents.
592
+ * @param {Uint8Array} bytes
593
+ */
594
+ loadFromUpdateQuiet(bytes) {
595
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
596
+ const len0 = WASM_VECTOR_LEN;
597
+ const ret = wasm.spreadsheetengine_loadFromUpdateQuiet(this.__wbg_ptr, ptr0, len0);
598
+ if (ret[1]) {
599
+ throw takeFromExternrefTable0(ret[0]);
600
+ }
601
+ }
602
+ constructor() {
603
+ const ret = wasm.spreadsheetengine_new();
604
+ this.__wbg_ptr = ret;
605
+ SpreadsheetEngineFinalization.register(this, this.__wbg_ptr, this);
606
+ return this;
607
+ }
608
+ /**
609
+ * @param {string} text
610
+ * @returns {string}
611
+ */
612
+ parseCsv(text) {
613
+ let deferred3_0;
614
+ let deferred3_1;
615
+ try {
616
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
617
+ const len0 = WASM_VECTOR_LEN;
618
+ const ret = wasm.spreadsheetengine_parseCsv(this.__wbg_ptr, ptr0, len0);
619
+ var ptr2 = ret[0];
620
+ var len2 = ret[1];
621
+ if (ret[3]) {
622
+ ptr2 = 0; len2 = 0;
623
+ throw takeFromExternrefTable0(ret[2]);
624
+ }
625
+ deferred3_0 = ptr2;
626
+ deferred3_1 = len2;
627
+ return getStringFromWasm0(ptr2, len2);
628
+ } finally {
629
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
630
+ }
631
+ }
632
+ /**
633
+ * PRECEDENTS of a cell as `{cells, ranges}` JSON (`SpreadsheetEngineLike.precedents`).
634
+ * @param {number} sheet_id
635
+ * @param {number} row
636
+ * @param {number} col
637
+ * @returns {string}
638
+ */
639
+ precedents(sheet_id, row, col) {
640
+ let deferred1_0;
641
+ let deferred1_1;
642
+ try {
643
+ const ret = wasm.spreadsheetengine_precedents(this.__wbg_ptr, sheet_id, row, col);
644
+ deferred1_0 = ret[0];
645
+ deferred1_1 = ret[1];
646
+ return getStringFromWasm0(ret[0], ret[1]);
647
+ } finally {
648
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
649
+ }
650
+ }
651
+ /**
652
+ * Remove the host-seeded default `Sheet1` (sheetId 1) when a collab merge showed the
653
+ * workbook's real sheets live under other ids — see [`YDocEngine::prune_dangling_default_seed`]
654
+ * for the contract. Call right after merging the collab doc, and ONLY when the persisted doc's
655
+ * sheet registry is non-empty and contains no `sheetId: 1`. Returns `true` when pruned.
656
+ * @returns {boolean}
657
+ */
658
+ pruneDanglingDefaultSeed() {
659
+ const ret = wasm.spreadsheetengine_pruneDanglingDefaultSeed(this.__wbg_ptr);
660
+ return ret !== 0;
661
+ }
662
+ /**
663
+ * @param {number} sheet_id
664
+ * @param {number} start_row
665
+ * @param {number} start_col
666
+ * @param {number} end_row
667
+ * @param {number} end_col
668
+ * @returns {string}
669
+ */
670
+ readWindow(sheet_id, start_row, start_col, end_row, end_col) {
671
+ let deferred1_0;
672
+ let deferred1_1;
673
+ try {
674
+ const ret = wasm.spreadsheetengine_readWindow(this.__wbg_ptr, sheet_id, start_row, start_col, end_row, end_col);
675
+ deferred1_0 = ret[0];
676
+ deferred1_1 = ret[1];
677
+ return getStringFromWasm0(ret[0], ret[1]);
678
+ } finally {
679
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
680
+ }
681
+ }
682
+ /**
683
+ * A window's cells + effective styles as COMPACT JSON —
684
+ * `{"cells":[[row,col,cell],…],"styles":[[row,col,format],…]}` (1-based, inclusive). For
685
+ * snapshot/export tooling tiling a whole sheet: the same cell payload `readWindowCommit`
686
+ * carries, minus its render channels (per-tile filter-hidden derivation, row dims) and the
687
+ * per-cell change-wrapper objects — a fraction of the JSON to serialize and parse.
688
+ * @param {number} sheet_id
689
+ * @param {number} start_row
690
+ * @param {number} start_col
691
+ * @param {number} end_row
692
+ * @param {number} end_col
693
+ * @returns {string}
694
+ */
695
+ readWindowCells(sheet_id, start_row, start_col, end_row, end_col) {
696
+ let deferred1_0;
697
+ let deferred1_1;
698
+ try {
699
+ const ret = wasm.spreadsheetengine_readWindowCells(this.__wbg_ptr, sheet_id, start_row, start_col, end_row, end_col);
700
+ deferred1_0 = ret[0];
701
+ deferred1_1 = ret[1];
702
+ return getStringFromWasm0(ret[0], ret[1]);
703
+ } finally {
704
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
705
+ }
706
+ }
707
+ /**
708
+ * A rectangular window of FULL cells + styles as `CommitResult` JSON, for windowed rendering
709
+ * of huge sheets (fold each tile with the same machinery as any other commit).
710
+ * @param {number} sheet_id
711
+ * @param {number} start_row
712
+ * @param {number} start_col
713
+ * @param {number} end_row
714
+ * @param {number} end_col
715
+ * @returns {string}
716
+ */
717
+ readWindowCommit(sheet_id, start_row, start_col, end_row, end_col) {
718
+ let deferred1_0;
719
+ let deferred1_1;
720
+ try {
721
+ const ret = wasm.spreadsheetengine_readWindowCommit(this.__wbg_ptr, sheet_id, start_row, start_col, end_row, end_col);
722
+ deferred1_0 = ret[0];
723
+ deferred1_1 = ret[1];
724
+ return getStringFromWasm0(ret[0], ret[1]);
725
+ } finally {
726
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
727
+ }
728
+ }
729
+ /**
730
+ * Force the full engine rebuild + recalc a capped import skipped. Can run minutes / trap on
731
+ * monster workbooks — callers must encode the doc state they need BEFORE calling, in a heap
732
+ * they can discard on failure. See [`YDocEngine::rebuild_and_recalc`].
733
+ */
734
+ rebuildAndRecalc() {
735
+ wasm.spreadsheetengine_rebuildAndRecalc(this.__wbg_ptr);
736
+ }
737
+ /**
738
+ * @returns {string}
739
+ */
740
+ redo() {
741
+ let deferred1_0;
742
+ let deferred1_1;
743
+ try {
744
+ const ret = wasm.spreadsheetengine_redo(this.__wbg_ptr);
745
+ deferred1_0 = ret[0];
746
+ deferred1_1 = ret[1];
747
+ return getStringFromWasm0(ret[0], ret[1]);
748
+ } finally {
749
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
750
+ }
751
+ }
752
+ /**
753
+ * @returns {number}
754
+ */
755
+ redoDepth() {
756
+ const ret = wasm.spreadsheetengine_redoDepth(this.__wbg_ptr);
757
+ return ret >>> 0;
758
+ }
759
+ /**
760
+ * Register a host (JS) custom-function name (`SpreadsheetEngineLike.registerCustomFunction`).
761
+ * @param {string} name
762
+ */
763
+ registerCustomFunction(name) {
764
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
765
+ const len0 = WASM_VECTOR_LEN;
766
+ wasm.spreadsheetengine_registerCustomFunction(this.__wbg_ptr, ptr0, len0);
767
+ }
768
+ /**
769
+ * Per-sheet 1-based data extents as JSON `[{"sheetId", "maxRow", "maxCol"}]`.
770
+ * @returns {string}
771
+ */
772
+ sheetExtents() {
773
+ let deferred1_0;
774
+ let deferred1_1;
775
+ try {
776
+ const ret = wasm.spreadsheetengine_sheetExtents(this.__wbg_ptr);
777
+ deferred1_0 = ret[0];
778
+ deferred1_1 = ret[1];
779
+ return getStringFromWasm0(ret[0], ret[1]);
780
+ } finally {
781
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
782
+ }
783
+ }
784
+ /**
785
+ * The workbook's sheet ids in tab order (`SpreadsheetEngineLike.sheetIds()`).
786
+ * @returns {Int32Array}
787
+ */
788
+ sheetIds() {
789
+ const ret = wasm.spreadsheetengine_sheetIds(this.__wbg_ptr);
790
+ var v1 = getArrayI32FromWasm0(ret[0], ret[1]).slice();
791
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
792
+ return v1;
793
+ }
794
+ /**
795
+ * Per-sheet populated stats as JSON —
796
+ * `[{"sheetId","minRow","minCol","maxRow","maxCol","cellCount"}, …]`. `cellCount` counts
797
+ * POPULATED cells (not the dense extent product) and `minRow`/`minCol` complete the bounding
798
+ * box, so hosts can budget reads honestly on sparse sheets. Empty sheets report all-zeros.
799
+ * Presence-derived (block headers + hot-plane coords); cheap even on million-row sheets.
800
+ * @returns {string}
801
+ */
802
+ sheetStats() {
803
+ let deferred1_0;
804
+ let deferred1_1;
805
+ try {
806
+ const ret = wasm.spreadsheetengine_sheetStats(this.__wbg_ptr);
807
+ deferred1_0 = ret[0];
808
+ deferred1_1 = ret[1];
809
+ return getStringFromWasm0(ret[0], ret[1]);
810
+ } finally {
811
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
812
+ }
813
+ }
814
+ /**
815
+ * The workbook's sheets in tab order as JSON `[{sheetId, title, index, hidden?, tabColor?}]` —
816
+ * the engine's authoritative sheet identity/order/titles. Mirrors `SpreadsheetEngineLike.sheets()`
817
+ * (see `@rowsncolumns/rnc-engine`) so the Option-B chrome reconciles its tab list after each commit.
818
+ * @returns {string}
819
+ */
820
+ sheets() {
821
+ let deferred1_0;
822
+ let deferred1_1;
823
+ try {
824
+ const ret = wasm.spreadsheetengine_sheets(this.__wbg_ptr);
825
+ deferred1_0 = ret[0];
826
+ deferred1_1 = ret[1];
827
+ return getStringFromWasm0(ret[0], ret[1]);
828
+ } finally {
829
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
830
+ }
831
+ }
832
+ /**
833
+ * @returns {Uint8Array}
834
+ */
835
+ stateAsUpdate() {
836
+ const ret = wasm.spreadsheetengine_stateAsUpdate(this.__wbg_ptr);
837
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
838
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
839
+ return v1;
840
+ }
841
+ /**
842
+ * Project the cells touched by the preceding `applyUpdate` and return the `CommitResult` JSON
843
+ * (`CollabSync.syncRemote`).
844
+ * @returns {string}
845
+ */
846
+ syncRemote() {
847
+ let deferred1_0;
848
+ let deferred1_1;
849
+ try {
850
+ const ret = wasm.spreadsheetengine_syncRemote(this.__wbg_ptr);
851
+ deferred1_0 = ret[0];
852
+ deferred1_1 = ret[1];
853
+ return getStringFromWasm0(ret[0], ret[1]);
854
+ } finally {
855
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
856
+ }
857
+ }
858
+ /**
859
+ * Drain the row-capped dropped formulas accumulated by bulk ingests/imports, as a
860
+ * coordinate-array JSON. See [`CollabSpreadsheetEngine::take_capped_formulas_json`].
861
+ * @returns {string}
862
+ */
863
+ takeCappedFormulas() {
864
+ let deferred1_0;
865
+ let deferred1_1;
866
+ try {
867
+ const ret = wasm.spreadsheetengine_takeCappedFormulas(this.__wbg_ptr);
868
+ deferred1_0 = ret[0];
869
+ deferred1_1 = ret[1];
870
+ return getStringFromWasm0(ret[0], ret[1]);
871
+ } finally {
872
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
873
+ }
874
+ }
875
+ /**
876
+ * Drain the merged v1 update produced by local edits since the last call (empty = nothing).
877
+ * @returns {Uint8Array}
878
+ */
879
+ takePendingUpdates() {
880
+ const ret = wasm.spreadsheetengine_takePendingUpdates(this.__wbg_ptr);
881
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
882
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
883
+ return v1;
884
+ }
885
+ /**
886
+ * @returns {string}
887
+ */
888
+ undo() {
889
+ let deferred1_0;
890
+ let deferred1_1;
891
+ try {
892
+ const ret = wasm.spreadsheetengine_undo(this.__wbg_ptr);
893
+ deferred1_0 = ret[0];
894
+ deferred1_1 = ret[1];
895
+ return getStringFromWasm0(ret[0], ret[1]);
896
+ } finally {
897
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
898
+ }
899
+ }
900
+ /**
901
+ * Undo / redo stack depth (`SpreadsheetEngineLike.undoDepth` / `redoDepth`).
902
+ * @returns {number}
903
+ */
904
+ undoDepth() {
905
+ const ret = wasm.spreadsheetengine_undoDepth(this.__wbg_ptr);
906
+ return ret >>> 0;
907
+ }
908
+ }
909
+ if (Symbol.dispose) SpreadsheetEngine.prototype[Symbol.dispose] = SpreadsheetEngine.prototype.free;
910
+
911
+ /**
912
+ * Minimal yrs-backed sheet doc exposing the canonical `sheetDataV3` encoding + yjs v1 transport.
913
+ */
914
+ export class YrsSheetDoc {
915
+ __destroy_into_raw() {
916
+ const ptr = this.__wbg_ptr;
917
+ this.__wbg_ptr = 0;
918
+ YrsSheetDocFinalization.unregister(this);
919
+ return ptr;
920
+ }
921
+ free() {
922
+ const ptr = this.__destroy_into_raw();
923
+ wasm.__wbg_yrssheetdoc_free(ptr, 0);
924
+ }
925
+ /**
926
+ * @param {Uint8Array} update
927
+ */
928
+ applyUpdate(update) {
929
+ const ptr0 = passArray8ToWasm0(update, wasm.__wbindgen_malloc);
930
+ const len0 = WASM_VECTOR_LEN;
931
+ const ret = wasm.yrssheetdoc_applyUpdate(this.__wbg_ptr, ptr0, len0);
932
+ if (ret[1]) {
933
+ throw takeFromExternrefTable0(ret[0]);
934
+ }
935
+ }
936
+ /**
937
+ * @returns {Uint8Array}
938
+ */
939
+ encodeStateAsUpdate() {
940
+ const ret = wasm.yrssheetdoc_encodeStateAsUpdate(this.__wbg_ptr);
941
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
942
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
943
+ return v1;
944
+ }
945
+ /**
946
+ * @param {number} sheet_id
947
+ * @param {number} row
948
+ * @param {number} col
949
+ * @returns {string | undefined}
950
+ */
951
+ getCell(sheet_id, row, col) {
952
+ const ret = wasm.yrssheetdoc_getCell(this.__wbg_ptr, sheet_id, row, col);
953
+ let v1;
954
+ if (ret[0] !== 0) {
955
+ v1 = getStringFromWasm0(ret[0], ret[1]).slice();
956
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
957
+ }
958
+ return v1;
959
+ }
960
+ constructor() {
961
+ const ret = wasm.yrssheetdoc_new();
962
+ this.__wbg_ptr = ret;
963
+ YrsSheetDocFinalization.register(this, this.__wbg_ptr, this);
964
+ return this;
965
+ }
966
+ /**
967
+ * @param {number} sheet_id
968
+ * @param {number} row
969
+ * @param {number} col
970
+ * @param {string} cell_json
971
+ */
972
+ setCell(sheet_id, row, col, cell_json) {
973
+ const ptr0 = passStringToWasm0(cell_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
974
+ const len0 = WASM_VECTOR_LEN;
975
+ const ret = wasm.yrssheetdoc_setCell(this.__wbg_ptr, sheet_id, row, col, ptr0, len0);
976
+ if (ret[1]) {
977
+ throw takeFromExternrefTable0(ret[0]);
978
+ }
979
+ }
980
+ }
981
+ if (Symbol.dispose) YrsSheetDoc.prototype[Symbol.dispose] = YrsSheetDoc.prototype.free;
982
+ function __wbg_get_imports() {
983
+ const import0 = {
984
+ __proto__: null,
985
+ __wbg___wbindgen_is_undefined_67b456be8673d3d7: function(arg0) {
986
+ const ret = arg0 === undefined;
987
+ return ret;
988
+ },
989
+ __wbg___wbindgen_throw_1506f2235d1bdba0: function(arg0, arg1) {
990
+ throw new Error(getStringFromWasm0(arg0, arg1));
991
+ },
992
+ __wbg_error_a6fa202b58aa1cd3: function(arg0, arg1) {
993
+ let deferred0_0;
994
+ let deferred0_1;
995
+ try {
996
+ deferred0_0 = arg0;
997
+ deferred0_1 = arg1;
998
+ console.error(getStringFromWasm0(arg0, arg1));
999
+ } finally {
1000
+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
1001
+ }
1002
+ },
1003
+ __wbg_getRandomValues_3f44b700395062e5: function() { return handleError(function (arg0, arg1) {
1004
+ globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
1005
+ }, arguments); },
1006
+ __wbg_getTime_00b3f7db575e4ef5: function(arg0) {
1007
+ const ret = arg0.getTime();
1008
+ return ret;
1009
+ },
1010
+ __wbg_getTimezoneOffset_08e2892156231088: function(arg0) {
1011
+ const ret = arg0.getTimezoneOffset();
1012
+ return ret;
1013
+ },
1014
+ __wbg_new_0_445c13a750296eb6: function() {
1015
+ const ret = new Date();
1016
+ return ret;
1017
+ },
1018
+ __wbg_new_227d7c05414eb861: function() {
1019
+ const ret = new Error();
1020
+ return ret;
1021
+ },
1022
+ __wbg_new_6d75fd236f920a62: function(arg0) {
1023
+ const ret = new Date(arg0);
1024
+ return ret;
1025
+ },
1026
+ __wbg_now_190933fa139cc119: function() {
1027
+ const ret = Date.now();
1028
+ return ret;
1029
+ },
1030
+ __wbg_now_e7c6795a7f81e10f: function(arg0) {
1031
+ const ret = arg0.now();
1032
+ return ret;
1033
+ },
1034
+ __wbg_performance_3fcf6e32a7e1ed0a: function(arg0) {
1035
+ const ret = arg0.performance;
1036
+ return ret;
1037
+ },
1038
+ __wbg_stack_3b0d974bbf31e44f: function(arg0, arg1) {
1039
+ const ret = arg1.stack;
1040
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1041
+ const len1 = WASM_VECTOR_LEN;
1042
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1043
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1044
+ },
1045
+ __wbg_static_accessor_GLOBAL_9d53f2689e622ca1: function() {
1046
+ const ret = typeof global === 'undefined' ? null : global;
1047
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
1048
+ },
1049
+ __wbg_static_accessor_GLOBAL_THIS_a1a35cec07001a8a: function() {
1050
+ const ret = typeof globalThis === 'undefined' ? null : globalThis;
1051
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
1052
+ },
1053
+ __wbg_static_accessor_SELF_4c59f6c7ea29a144: function() {
1054
+ const ret = typeof self === 'undefined' ? null : self;
1055
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
1056
+ },
1057
+ __wbg_static_accessor_WINDOW_e70ae9f2eb052253: function() {
1058
+ const ret = typeof window === 'undefined' ? null : window;
1059
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
1060
+ },
1061
+ __wbindgen_cast_0000000000000001: function(arg0) {
1062
+ // Cast intrinsic for `F64 -> Externref`.
1063
+ const ret = arg0;
1064
+ return ret;
1065
+ },
1066
+ __wbindgen_cast_0000000000000002: function(arg0, arg1) {
1067
+ // Cast intrinsic for `Ref(String) -> Externref`.
1068
+ const ret = getStringFromWasm0(arg0, arg1);
1069
+ return ret;
1070
+ },
1071
+ __wbindgen_init_externref_table: function() {
1072
+ const table = wasm.__wbindgen_externrefs;
1073
+ const offset = table.grow(4);
1074
+ table.set(0, undefined);
1075
+ table.set(offset + 0, undefined);
1076
+ table.set(offset + 1, null);
1077
+ table.set(offset + 2, true);
1078
+ table.set(offset + 3, false);
1079
+ },
1080
+ };
1081
+ return {
1082
+ __proto__: null,
1083
+ "./rnc_yrs_store_bg.js": import0,
1084
+ };
1085
+ }
1086
+
1087
+ const SpreadsheetEngineFinalization = (typeof FinalizationRegistry === 'undefined')
1088
+ ? { register: () => {}, unregister: () => {} }
1089
+ : new FinalizationRegistry(ptr => wasm.__wbg_spreadsheetengine_free(ptr, 1));
1090
+ const YrsSheetDocFinalization = (typeof FinalizationRegistry === 'undefined')
1091
+ ? { register: () => {}, unregister: () => {} }
1092
+ : new FinalizationRegistry(ptr => wasm.__wbg_yrssheetdoc_free(ptr, 1));
1093
+
1094
+ function addToExternrefTable0(obj) {
1095
+ const idx = wasm.__externref_table_alloc();
1096
+ wasm.__wbindgen_externrefs.set(idx, obj);
1097
+ return idx;
1098
+ }
1099
+
1100
+ function getArrayI32FromWasm0(ptr, len) {
1101
+ ptr = ptr >>> 0;
1102
+ return getInt32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
1103
+ }
1104
+
1105
+ function getArrayU8FromWasm0(ptr, len) {
1106
+ ptr = ptr >>> 0;
1107
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
1108
+ }
1109
+
1110
+ let cachedDataViewMemory0 = null;
1111
+ function getDataViewMemory0() {
1112
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
1113
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
1114
+ }
1115
+ return cachedDataViewMemory0;
1116
+ }
1117
+
1118
+ let cachedInt32ArrayMemory0 = null;
1119
+ function getInt32ArrayMemory0() {
1120
+ if (cachedInt32ArrayMemory0 === null || cachedInt32ArrayMemory0.byteLength === 0) {
1121
+ cachedInt32ArrayMemory0 = new Int32Array(wasm.memory.buffer);
1122
+ }
1123
+ return cachedInt32ArrayMemory0;
1124
+ }
1125
+
1126
+ function getStringFromWasm0(ptr, len) {
1127
+ return decodeText(ptr >>> 0, len);
1128
+ }
1129
+
1130
+ let cachedUint8ArrayMemory0 = null;
1131
+ function getUint8ArrayMemory0() {
1132
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
1133
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
1134
+ }
1135
+ return cachedUint8ArrayMemory0;
1136
+ }
1137
+
1138
+ function handleError(f, args) {
1139
+ try {
1140
+ return f.apply(this, args);
1141
+ } catch (e) {
1142
+ const idx = addToExternrefTable0(e);
1143
+ wasm.__wbindgen_exn_store(idx);
1144
+ }
1145
+ }
1146
+
1147
+ function isLikeNone(x) {
1148
+ return x === undefined || x === null;
1149
+ }
1150
+
1151
+ function passArray8ToWasm0(arg, malloc) {
1152
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
1153
+ getUint8ArrayMemory0().set(arg, ptr / 1);
1154
+ WASM_VECTOR_LEN = arg.length;
1155
+ return ptr;
1156
+ }
1157
+
1158
+ function passStringToWasm0(arg, malloc, realloc) {
1159
+ if (realloc === undefined) {
1160
+ const buf = cachedTextEncoder.encode(arg);
1161
+ const ptr = malloc(buf.length, 1) >>> 0;
1162
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
1163
+ WASM_VECTOR_LEN = buf.length;
1164
+ return ptr;
1165
+ }
1166
+
1167
+ let len = arg.length;
1168
+ let ptr = malloc(len, 1) >>> 0;
1169
+
1170
+ const mem = getUint8ArrayMemory0();
1171
+
1172
+ let offset = 0;
1173
+
1174
+ for (; offset < len; offset++) {
1175
+ const code = arg.charCodeAt(offset);
1176
+ if (code > 0x7F) break;
1177
+ mem[ptr + offset] = code;
1178
+ }
1179
+ if (offset !== len) {
1180
+ if (offset !== 0) {
1181
+ arg = arg.slice(offset);
1182
+ }
1183
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
1184
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
1185
+ const ret = cachedTextEncoder.encodeInto(arg, view);
1186
+
1187
+ offset += ret.written;
1188
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
1189
+ }
1190
+
1191
+ WASM_VECTOR_LEN = offset;
1192
+ return ptr;
1193
+ }
1194
+
1195
+ function takeFromExternrefTable0(idx) {
1196
+ const value = wasm.__wbindgen_externrefs.get(idx);
1197
+ wasm.__externref_table_dealloc(idx);
1198
+ return value;
1199
+ }
1200
+
1201
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
1202
+ cachedTextDecoder.decode();
1203
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
1204
+ let numBytesDecoded = 0;
1205
+ function decodeText(ptr, len) {
1206
+ numBytesDecoded += len;
1207
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
1208
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
1209
+ cachedTextDecoder.decode();
1210
+ numBytesDecoded = len;
1211
+ }
1212
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
1213
+ }
1214
+
1215
+ const cachedTextEncoder = new TextEncoder();
1216
+
1217
+ if (!('encodeInto' in cachedTextEncoder)) {
1218
+ cachedTextEncoder.encodeInto = function (arg, view) {
1219
+ const buf = cachedTextEncoder.encode(arg);
1220
+ view.set(buf);
1221
+ return {
1222
+ read: arg.length,
1223
+ written: buf.length
1224
+ };
1225
+ };
1226
+ }
1227
+
1228
+ let WASM_VECTOR_LEN = 0;
1229
+
1230
+ let wasmModule, wasmInstance, wasm;
1231
+ function __wbg_finalize_init(instance, module) {
1232
+ wasmInstance = instance;
1233
+ wasm = instance.exports;
1234
+ wasmModule = module;
1235
+ cachedDataViewMemory0 = null;
1236
+ cachedInt32ArrayMemory0 = null;
1237
+ cachedUint8ArrayMemory0 = null;
1238
+ wasm.__wbindgen_start();
1239
+ return wasm;
1240
+ }
1241
+
1242
+ async function __wbg_load(module, imports) {
1243
+ if (typeof Response === 'function' && module instanceof Response) {
1244
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
1245
+ try {
1246
+ return await WebAssembly.instantiateStreaming(module, imports);
1247
+ } catch (e) {
1248
+ const validResponse = module.ok && expectedResponseType(module.type);
1249
+
1250
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
1251
+ 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);
1252
+
1253
+ } else { throw e; }
1254
+ }
1255
+ }
1256
+
1257
+ const bytes = await module.arrayBuffer();
1258
+ return await WebAssembly.instantiate(bytes, imports);
1259
+ } else {
1260
+ const instance = await WebAssembly.instantiate(module, imports);
1261
+
1262
+ if (instance instanceof WebAssembly.Instance) {
1263
+ return { instance, module };
1264
+ } else {
1265
+ return instance;
1266
+ }
1267
+ }
1268
+
1269
+ function expectedResponseType(type) {
1270
+ switch (type) {
1271
+ case 'basic': case 'cors': case 'default': return true;
1272
+ }
1273
+ return false;
1274
+ }
1275
+ }
1276
+
1277
+ function initSync(module) {
1278
+ if (wasm !== undefined) return wasm;
1279
+
1280
+
1281
+ if (module !== undefined) {
1282
+ if (Object.getPrototypeOf(module) === Object.prototype) {
1283
+ ({module} = module)
1284
+ } else {
1285
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
1286
+ }
1287
+ }
1288
+
1289
+ const imports = __wbg_get_imports();
1290
+ if (!(module instanceof WebAssembly.Module)) {
1291
+ module = new WebAssembly.Module(module);
1292
+ }
1293
+ const instance = new WebAssembly.Instance(module, imports);
1294
+ return __wbg_finalize_init(instance, module);
1295
+ }
1296
+
1297
+ async function __wbg_init(module_or_path) {
1298
+ if (wasm !== undefined) return wasm;
1299
+
1300
+
1301
+ if (module_or_path !== undefined) {
1302
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
1303
+ ({module_or_path} = module_or_path)
1304
+ } else {
1305
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
1306
+ }
1307
+ }
1308
+
1309
+ if (module_or_path === undefined) {
1310
+ module_or_path = new URL('rnc_yrs_store_bg.wasm', import.meta.url);
1311
+ }
1312
+ const imports = __wbg_get_imports();
1313
+
1314
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
1315
+ module_or_path = fetch(module_or_path);
1316
+ }
1317
+
1318
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
1319
+
1320
+ return __wbg_finalize_init(instance, module);
1321
+ }
1322
+
1323
+ export { initSync, __wbg_init as default };