ducjs 4.0.2 → 4.0.4

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.
@@ -1,649 +1,300 @@
1
- let wasm;
1
+ /* @ts-self-types="./ducjs_wasm.d.ts" */
2
2
 
3
- let cachedUint8ArrayMemory0 = null;
4
-
5
- function getUint8ArrayMemory0() {
6
- if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
7
- cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
8
- }
9
- return cachedUint8ArrayMemory0;
10
- }
11
-
12
- let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
13
-
14
- cachedTextDecoder.decode();
15
-
16
- const MAX_SAFARI_DECODE_BYTES = 2146435072;
17
- let numBytesDecoded = 0;
18
- function decodeText(ptr, len) {
19
- numBytesDecoded += len;
20
- if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
21
- cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
22
- cachedTextDecoder.decode();
23
- numBytesDecoded = len;
24
- }
25
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
26
- }
27
-
28
- function getStringFromWasm0(ptr, len) {
29
- ptr = ptr >>> 0;
30
- return decodeText(ptr, len);
31
- }
32
-
33
- let WASM_VECTOR_LEN = 0;
34
-
35
- const cachedTextEncoder = new TextEncoder();
36
-
37
- if (!('encodeInto' in cachedTextEncoder)) {
38
- cachedTextEncoder.encodeInto = function (arg, view) {
39
- const buf = cachedTextEncoder.encode(arg);
40
- view.set(buf);
41
- return {
42
- read: arg.length,
43
- written: buf.length
44
- };
3
+ export class DucOpfsDocument {
4
+ static __wrap(ptr) {
5
+ const obj = Object.create(DucOpfsDocument.prototype);
6
+ obj.__wbg_ptr = ptr;
7
+ DucOpfsDocumentFinalization.register(obj, obj.__wbg_ptr, obj);
8
+ return obj;
45
9
  }
46
- }
47
-
48
- function passStringToWasm0(arg, malloc, realloc) {
49
-
50
- if (realloc === undefined) {
51
- const buf = cachedTextEncoder.encode(arg);
52
- const ptr = malloc(buf.length, 1) >>> 0;
53
- getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
54
- WASM_VECTOR_LEN = buf.length;
10
+ __destroy_into_raw() {
11
+ const ptr = this.__wbg_ptr;
12
+ this.__wbg_ptr = 0;
13
+ DucOpfsDocumentFinalization.unregister(this);
55
14
  return ptr;
56
15
  }
57
-
58
- let len = arg.length;
59
- let ptr = malloc(len, 1) >>> 0;
60
-
61
- const mem = getUint8ArrayMemory0();
62
-
63
- let offset = 0;
64
-
65
- for (; offset < len; offset++) {
66
- const code = arg.charCodeAt(offset);
67
- if (code > 0x7F) break;
68
- mem[ptr + offset] = code;
16
+ free() {
17
+ const ptr = this.__destroy_into_raw();
18
+ wasm.__wbg_ducopfsdocument_free(ptr, 0);
69
19
  }
70
-
71
- if (offset !== len) {
72
- if (offset !== 0) {
73
- arg = arg.slice(offset);
20
+ /**
21
+ * Flush the WAL journal into the main database file.
22
+ *
23
+ * After calling this, the OPFS file backing this document contains
24
+ * all committed data. JavaScript can then read the file directly
25
+ * from OPFS in chunks and gzip-compress it.
26
+ */
27
+ checkpointWal() {
28
+ const ret = wasm.ducopfsdocument_checkpointWal(this.__wbg_ptr);
29
+ if (ret[1]) {
30
+ throw takeFromExternrefTable0(ret[0]);
74
31
  }
75
- ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
76
- const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
77
- const ret = cachedTextEncoder.encodeInto(arg, view);
78
-
79
- offset += ret.written;
80
- ptr = realloc(ptr, len, offset, 1) >>> 0;
81
- }
82
-
83
- WASM_VECTOR_LEN = offset;
84
- return ptr;
85
- }
86
-
87
- let cachedDataViewMemory0 = null;
88
-
89
- function getDataViewMemory0() {
90
- if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
91
- cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
92
- }
93
- return cachedDataViewMemory0;
94
- }
95
-
96
- function addToExternrefTable0(obj) {
97
- const idx = wasm.__externref_table_alloc();
98
- wasm.__wbindgen_export_4.set(idx, obj);
99
- return idx;
100
- }
101
-
102
- function handleError(f, args) {
103
- try {
104
- return f.apply(this, args);
105
- } catch (e) {
106
- const idx = addToExternrefTable0(e);
107
- wasm.__wbindgen_exn_store(idx);
108
- }
109
- }
110
-
111
- function getArrayU8FromWasm0(ptr, len) {
112
- ptr = ptr >>> 0;
113
- return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
114
- }
115
-
116
- function isLikeNone(x) {
117
- return x === undefined || x === null;
118
- }
119
-
120
- function debugString(val) {
121
- // primitive types
122
- const type = typeof val;
123
- if (type == 'number' || type == 'boolean' || val == null) {
124
- return `${val}`;
125
- }
126
- if (type == 'string') {
127
- return `"${val}"`;
128
32
  }
129
- if (type == 'symbol') {
130
- const description = val.description;
131
- if (description == null) {
132
- return 'Symbol';
133
- } else {
134
- return `Symbol(${description})`;
33
+ /**
34
+ * @param {string} checkpoint_id
35
+ */
36
+ clearCheckpointDataChunks(checkpoint_id) {
37
+ const ptr0 = passStringToWasm0(checkpoint_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
38
+ const len0 = WASM_VECTOR_LEN;
39
+ const ret = wasm.ducopfsdocument_clearCheckpointDataChunks(this.__wbg_ptr, ptr0, len0);
40
+ if (ret[1]) {
41
+ throw takeFromExternrefTable0(ret[0]);
135
42
  }
136
43
  }
137
- if (type == 'function') {
138
- const name = val.name;
139
- if (typeof name == 'string' && name.length > 0) {
140
- return `Function(${name})`;
141
- } else {
142
- return 'Function';
44
+ /**
45
+ * @param {string} delta_id
46
+ */
47
+ clearDeltaChangesetChunks(delta_id) {
48
+ const ptr0 = passStringToWasm0(delta_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
49
+ const len0 = WASM_VECTOR_LEN;
50
+ const ret = wasm.ducopfsdocument_clearDeltaChangesetChunks(this.__wbg_ptr, ptr0, len0);
51
+ if (ret[1]) {
52
+ throw takeFromExternrefTable0(ret[0]);
143
53
  }
144
54
  }
145
- // objects
146
- if (Array.isArray(val)) {
147
- const length = val.length;
148
- let debug = '[';
149
- if (length > 0) {
150
- debug += debugString(val[0]);
151
- }
152
- for(let i = 1; i < length; i++) {
153
- debug += ', ' + debugString(val[i]);
55
+ /**
56
+ * @param {string} revision_id
57
+ */
58
+ clearExternalFileRevisionChunks(revision_id) {
59
+ const ptr0 = passStringToWasm0(revision_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
60
+ const len0 = WASM_VECTOR_LEN;
61
+ const ret = wasm.ducopfsdocument_clearExternalFileRevisionChunks(this.__wbg_ptr, ptr0, len0);
62
+ if (ret[1]) {
63
+ throw takeFromExternrefTable0(ret[0]);
154
64
  }
155
- debug += ']';
156
- return debug;
157
65
  }
158
- // Test for built-in
159
- const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
160
- let className;
161
- if (builtInMatches && builtInMatches.length > 1) {
162
- className = builtInMatches[1];
163
- } else {
164
- // Failed to match the standard '[object ClassName]'
165
- return toString.call(val);
66
+ /**
67
+ * @param {string} name
68
+ * @returns {Promise<boolean>}
69
+ */
70
+ static deleteOpfsDatabase(name) {
71
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
72
+ const len0 = WASM_VECTOR_LEN;
73
+ const ret = wasm.ducopfsdocument_deleteOpfsDatabase(ptr0, len0);
74
+ return ret;
166
75
  }
167
- if (className == 'Object') {
168
- // we're a user defined class or Object
169
- // JSON.stringify avoids problems with cycles, and is generally much
170
- // easier than looping through ownProperties of `val`.
171
- try {
172
- return 'Object(' + JSON.stringify(val) + ')';
173
- } catch (_) {
174
- return 'Object';
76
+ /**
77
+ * @param {string} name
78
+ * @param {string} namespace
79
+ * @returns {Promise<boolean>}
80
+ */
81
+ static deleteOpfsDatabaseInPool(name, namespace) {
82
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
83
+ const len0 = WASM_VECTOR_LEN;
84
+ const ptr1 = passStringToWasm0(namespace, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
85
+ const len1 = WASM_VECTOR_LEN;
86
+ const ret = wasm.ducopfsdocument_deleteOpfsDatabaseInPool(ptr0, len0, ptr1, len1);
87
+ return ret;
88
+ }
89
+ /**
90
+ * Execute an arbitrary SQL batch (e.g. `VACUUM INTO 'export.sqlite'`).
91
+ * @param {string} sql
92
+ */
93
+ executeBatch(sql) {
94
+ const ptr0 = passStringToWasm0(sql, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
95
+ const len0 = WASM_VECTOR_LEN;
96
+ const ret = wasm.ducopfsdocument_executeBatch(this.__wbg_ptr, ptr0, len0);
97
+ if (ret[1]) {
98
+ throw takeFromExternrefTable0(ret[0]);
175
99
  }
176
100
  }
177
- // errors
178
- if (val instanceof Error) {
179
- return `${val.name}: ${val.message}\n${val.stack}`;
101
+ /**
102
+ * Read a chunk from the SQLite database backing this OPFS document.
103
+ *
104
+ * Call [`checkpointWal`] first so the main database file contains all
105
+ * committed data. JavaScript can gzip successive chunks without loading
106
+ * the whole database into WASM memory.
107
+ * @param {number} offset_bytes
108
+ * @param {number} length
109
+ * @returns {Promise<Uint8Array>}
110
+ */
111
+ exportDbChunk(offset_bytes, length) {
112
+ const ret = wasm.ducopfsdocument_exportDbChunk(this.__wbg_ptr, offset_bytes, length);
113
+ return ret;
180
114
  }
181
- // TODO we could test for more things here, like `Set`s and `Map`s.
182
- return className;
183
- }
184
-
185
- const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')
186
- ? { register: () => {}, unregister: () => {} }
187
- : new FinalizationRegistry(
188
- state => {
189
- wasm.__wbindgen_export_6.get(state.dtor)(state.a, state.b);
190
- }
191
- );
192
-
193
- function makeMutClosure(arg0, arg1, dtor, f) {
194
- const state = { a: arg0, b: arg1, cnt: 1, dtor };
195
- const real = (...args) => {
196
-
197
- // First up with a closure we increment the internal reference
198
- // count. This ensures that the Rust closure environment won't
199
- // be deallocated while we're invoking it.
200
- state.cnt++;
201
- const a = state.a;
202
- state.a = 0;
115
+ /**
116
+ * Return the estimated database file size in bytes
117
+ * (`page_count × page_size`). Call [`checkpoint_wal`] first for
118
+ * an accurate value.
119
+ * @returns {number}
120
+ */
121
+ getDbSizeBytes() {
122
+ const ret = wasm.ducopfsdocument_getDbSizeBytes(this.__wbg_ptr);
123
+ if (ret[2]) {
124
+ throw takeFromExternrefTable0(ret[1]);
125
+ }
126
+ return ret[0];
127
+ }
128
+ /**
129
+ * Return the filename used to open this document.
130
+ * @returns {string}
131
+ */
132
+ getFilename() {
133
+ let deferred1_0;
134
+ let deferred1_1;
203
135
  try {
204
- return f(a, state.b, ...args);
136
+ const ret = wasm.ducopfsdocument_getFilename(this.__wbg_ptr);
137
+ deferred1_0 = ret[0];
138
+ deferred1_1 = ret[1];
139
+ return getStringFromWasm0(ret[0], ret[1]);
205
140
  } finally {
206
- if (--state.cnt === 0) {
207
- wasm.__wbindgen_export_6.get(state.dtor)(a, state.b);
208
- CLOSURE_DTORS.unregister(state);
209
- } else {
210
- state.a = a;
211
- }
141
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
212
142
  }
213
- };
214
- real.original = state;
215
- CLOSURE_DTORS.register(real, state, state);
216
- return real;
217
- }
218
-
219
- function passArray8ToWasm0(arg, malloc) {
220
- const ptr = malloc(arg.length * 1, 1) >>> 0;
221
- getUint8ArrayMemory0().set(arg, ptr / 1);
222
- WASM_VECTOR_LEN = arg.length;
223
- return ptr;
224
- }
225
-
226
- function takeFromExternrefTable0(idx) {
227
- const value = wasm.__wbindgen_export_4.get(idx);
228
- wasm.__externref_table_dealloc(idx);
229
- return value;
230
- }
231
- /**
232
- * Parse a `.duc` file (Uint8Array) into a JS object (ExportedDataState).
233
- * @param {Uint8Array} buf
234
- * @returns {any}
235
- */
236
- export function parseDuc(buf) {
237
- const ptr0 = passArray8ToWasm0(buf, wasm.__wbindgen_malloc);
238
- const len0 = WASM_VECTOR_LEN;
239
- const ret = wasm.parseDuc(ptr0, len0);
240
- if (ret[2]) {
241
- throw takeFromExternrefTable0(ret[1]);
242
- }
243
- return takeFromExternrefTable0(ret[0]);
244
- }
245
-
246
- /**
247
- * Serialize a JS object (ExportedDataState) into `.duc` bytes (Uint8Array).
248
- * @param {any} data
249
- * @returns {Uint8Array}
250
- */
251
- export function serializeDuc(data) {
252
- const ret = wasm.serializeDuc(data);
253
- if (ret[3]) {
254
- throw takeFromExternrefTable0(ret[2]);
255
143
  }
256
- var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
257
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
258
- return v1;
259
- }
260
-
261
- /**
262
- * Restore the document state at `version_number` from a `.duc` file buffer.
263
- * @param {Uint8Array} duc_buf
264
- * @param {number} version_number
265
- * @returns {any}
266
- */
267
- export function restoreVersion(duc_buf, version_number) {
268
- const ptr0 = passArray8ToWasm0(duc_buf, wasm.__wbindgen_malloc);
269
- const len0 = WASM_VECTOR_LEN;
270
- const ret = wasm.restoreVersion(ptr0, len0, version_number);
271
- if (ret[2]) {
272
- throw takeFromExternrefTable0(ret[1]);
144
+ /**
145
+ * @returns {any}
146
+ */
147
+ listExternalFiles() {
148
+ const ret = wasm.ducopfsdocument_listExternalFiles(this.__wbg_ptr);
149
+ if (ret[2]) {
150
+ throw takeFromExternrefTable0(ret[1]);
151
+ }
152
+ return takeFromExternrefTable0(ret[0]);
273
153
  }
274
- return takeFromExternrefTable0(ret[0]);
275
- }
276
-
277
- /**
278
- * Restore a specific checkpoint by its ID from a `.duc` file buffer.
279
- * @param {Uint8Array} duc_buf
280
- * @param {string} checkpoint_id
281
- * @returns {any}
282
- */
283
- export function restoreCheckpoint(duc_buf, checkpoint_id) {
284
- const ptr0 = passArray8ToWasm0(duc_buf, wasm.__wbindgen_malloc);
285
- const len0 = WASM_VECTOR_LEN;
286
- const ptr1 = passStringToWasm0(checkpoint_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
287
- const len1 = WASM_VECTOR_LEN;
288
- const ret = wasm.restoreCheckpoint(ptr0, len0, ptr1, len1);
289
- if (ret[2]) {
290
- throw takeFromExternrefTable0(ret[1]);
154
+ /**
155
+ * @returns {Promise<any>}
156
+ */
157
+ static listOpfsDatabases() {
158
+ const ret = wasm.ducopfsdocument_listOpfsDatabases();
159
+ return ret;
291
160
  }
292
- return takeFromExternrefTable0(ret[0]);
293
- }
294
-
295
- /**
296
- * List all versions (checkpoints + deltas) from a `.duc` file buffer.
297
- * @param {Uint8Array} duc_buf
298
- * @returns {any}
299
- */
300
- export function listVersions(duc_buf) {
301
- const ptr0 = passArray8ToWasm0(duc_buf, wasm.__wbindgen_malloc);
302
- const len0 = WASM_VECTOR_LEN;
303
- const ret = wasm.listVersions(ptr0, len0);
304
- if (ret[2]) {
305
- throw takeFromExternrefTable0(ret[1]);
161
+ /**
162
+ * @param {string} namespace
163
+ * @returns {Promise<any>}
164
+ */
165
+ static listOpfsDatabasesInPool(namespace) {
166
+ const ptr0 = passStringToWasm0(namespace, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
167
+ const len0 = WASM_VECTOR_LEN;
168
+ const ret = wasm.ducopfsdocument_listOpfsDatabasesInPool(ptr0, len0);
169
+ return ret;
306
170
  }
307
- return takeFromExternrefTable0(ret[0]);
308
- }
309
-
310
- /**
311
- * Read the full VersionGraph from a `.duc` file buffer.
312
- * @param {Uint8Array} duc_buf
313
- * @returns {any}
314
- */
315
- export function readVersionGraph(duc_buf) {
316
- const ptr0 = passArray8ToWasm0(duc_buf, wasm.__wbindgen_malloc);
317
- const len0 = WASM_VECTOR_LEN;
318
- const ret = wasm.readVersionGraph(ptr0, len0);
319
- if (ret[2]) {
320
- throw takeFromExternrefTable0(ret[1]);
171
+ /**
172
+ * @returns {any}
173
+ */
174
+ listVersions() {
175
+ const ret = wasm.ducopfsdocument_listVersions(this.__wbg_ptr);
176
+ if (ret[2]) {
177
+ throw takeFromExternrefTable0(ret[1]);
178
+ }
179
+ return takeFromExternrefTable0(ret[0]);
321
180
  }
322
- return takeFromExternrefTable0(ret[0]);
323
- }
324
-
325
- /**
326
- * Revert the document to a specific version, removing all newer versions.
327
- * @param {Uint8Array} duc_buf
328
- * @param {number} target_version
329
- * @returns {any}
330
- */
331
- export function revertToVersion(duc_buf, target_version) {
332
- const ptr0 = passArray8ToWasm0(duc_buf, wasm.__wbindgen_malloc);
333
- const len0 = WASM_VECTOR_LEN;
334
- const ret = wasm.revertToVersion(ptr0, len0, target_version);
335
- if (ret[2]) {
336
- throw takeFromExternrefTable0(ret[1]);
181
+ /**
182
+ * Open or create a persistent OPFS-backed DUC SQLite document.
183
+ *
184
+ * This must run from a Dedicated Worker because the OPFS SAH-pool VFS uses
185
+ * FileSystemSyncAccessHandle.
186
+ * @param {string} name
187
+ * @returns {Promise<DucOpfsDocument>}
188
+ */
189
+ static open(name) {
190
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
191
+ const len0 = WASM_VECTOR_LEN;
192
+ const ret = wasm.ducopfsdocument_open(ptr0, len0);
193
+ return ret;
337
194
  }
338
- return takeFromExternrefTable0(ret[0]);
339
- }
340
-
341
- /**
342
- * Returns the current version-control schema version defined in Rust.
343
- *
344
- * TypeScript should use this as the source of truth instead of hardcoding
345
- * its own constant. When this value is bumped in Rust, the version control
346
- * system will automatically handle migration bookkeeping (closing old chains,
347
- * recording migrations) the next time a checkpoint or delta is created.
348
- * @returns {number}
349
- */
350
- export function getCurrentSchemaVersion() {
351
- return 4000000;
352
- }
353
-
354
- /**
355
- * Compute a checkpoint-relative binary diff changeset using bsdiff.
356
- *
357
- * `base_state` is the checkpoint's full data blob.
358
- * `current_state` is the full document state at the new version.
359
- *
360
- * Returns an encoded changeset (`Uint8Array`) ready for storage in a
361
- * `Delta.payload`. bsdiff finds matching blocks even when they shift
362
- * offsets, which is critical for SQLite databases.
363
- * @param {Uint8Array} base_state
364
- * @param {Uint8Array} current_state
365
- * @returns {Uint8Array}
366
- */
367
- export function createDeltaChangeset(base_state, current_state) {
368
- const ptr0 = passArray8ToWasm0(base_state, wasm.__wbindgen_malloc);
369
- const len0 = WASM_VECTOR_LEN;
370
- const ptr1 = passArray8ToWasm0(current_state, wasm.__wbindgen_malloc);
371
- const len1 = WASM_VECTOR_LEN;
372
- const ret = wasm.createDeltaChangeset(ptr0, len0, ptr1, len1);
373
- if (ret[3]) {
374
- throw takeFromExternrefTable0(ret[2]);
375
- }
376
- var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
377
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
378
- return v3;
379
- }
380
-
381
- /**
382
- * Apply a changeset to reconstruct document state.
383
- *
384
- * `base_state` must be the exact checkpoint data used when the changeset
385
- * was created. Returns the full document state as `Uint8Array`.
386
- *
387
- * Handles all changeset formats transparently:
388
- * - v3 (bsdiff), v2 (XOR diff), v1 (gzip full snapshot)
389
- * @param {Uint8Array} base_state
390
- * @param {Uint8Array} changeset
391
- * @returns {Uint8Array}
392
- */
393
- export function applyDeltaChangeset(base_state, changeset) {
394
- const ptr0 = passArray8ToWasm0(base_state, wasm.__wbindgen_malloc);
395
- const len0 = WASM_VECTOR_LEN;
396
- const ptr1 = passArray8ToWasm0(changeset, wasm.__wbindgen_malloc);
397
- const len1 = WASM_VECTOR_LEN;
398
- const ret = wasm.applyDeltaChangeset(ptr0, len0, ptr1, len1);
399
- if (ret[3]) {
400
- throw takeFromExternrefTable0(ret[2]);
401
- }
402
- var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
403
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
404
- return v3;
405
- }
406
-
407
- function __wbg_adapter_14(arg0, arg1, arg2) {
408
- wasm.closure101_externref_shim(arg0, arg1, arg2);
409
- }
410
-
411
- function __wbg_adapter_126(arg0, arg1, arg2, arg3) {
412
- wasm.closure82_externref_shim(arg0, arg1, arg2, arg3);
413
- }
414
-
415
- const DucOpfsDocumentFinalization = (typeof FinalizationRegistry === 'undefined')
416
- ? { register: () => {}, unregister: () => {} }
417
- : new FinalizationRegistry(ptr => wasm.__wbg_ducopfsdocument_free(ptr >>> 0, 1));
418
-
419
- export class DucOpfsDocument {
420
-
421
- static __wrap(ptr) {
422
- ptr = ptr >>> 0;
423
- const obj = Object.create(DucOpfsDocument.prototype);
424
- obj.__wbg_ptr = ptr;
425
- DucOpfsDocumentFinalization.register(obj, obj.__wbg_ptr, obj);
426
- return obj;
427
- }
428
-
429
- __destroy_into_raw() {
430
- const ptr = this.__wbg_ptr;
431
- this.__wbg_ptr = 0;
432
- DucOpfsDocumentFinalization.unregister(this);
433
- return ptr;
434
- }
435
-
436
- free() {
437
- const ptr = this.__destroy_into_raw();
438
- wasm.__wbg_ducopfsdocument_free(ptr, 0);
439
- }
440
- /**
441
- * @param {string} name
442
- * @param {string} namespace
443
- * @returns {Promise<DucOpfsDocument>}
444
- */
445
- static openInPool(name, namespace) {
446
- const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
447
- const len0 = WASM_VECTOR_LEN;
448
- const ptr1 = passStringToWasm0(namespace, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
449
- const len1 = WASM_VECTOR_LEN;
450
- const ret = wasm.ducopfsdocument_openInPool(ptr0, len0, ptr1, len1);
451
- return ret;
452
- }
453
- /**
454
- * Read a chunk from the SQLite database backing this OPFS document.
455
- *
456
- * Call [`checkpointWal`] first so the main database file contains all
457
- * committed data. JavaScript can gzip successive chunks without loading
458
- * the whole database into WASM memory.
459
- * @param {number} offset_bytes
460
- * @param {number} length
461
- * @returns {Promise<Uint8Array>}
462
- */
463
- exportDbChunk(offset_bytes, length) {
464
- const ret = wasm.ducopfsdocument_exportDbChunk(this.__wbg_ptr, offset_bytes, length);
465
- return ret;
466
- }
467
- /**
468
- * @returns {Promise<any>}
469
- */
470
- static listOpfsDatabases() {
471
- const ret = wasm.ducopfsdocument_listOpfsDatabases();
472
- return ret;
473
- }
474
- /**
475
- * @param {string} name
476
- * @returns {Promise<boolean>}
477
- */
478
- static deleteOpfsDatabase(name) {
479
- const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
480
- const len0 = WASM_VECTOR_LEN;
481
- const ret = wasm.ducopfsdocument_deleteOpfsDatabase(ptr0, len0);
482
- return ret;
483
- }
484
- /**
485
- * @param {string} namespace
486
- * @returns {Promise<any>}
487
- */
488
- static listOpfsDatabasesInPool(namespace) {
489
- const ptr0 = passStringToWasm0(namespace, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
490
- const len0 = WASM_VECTOR_LEN;
491
- const ret = wasm.ducopfsdocument_listOpfsDatabasesInPool(ptr0, len0);
492
- return ret;
493
- }
494
- /**
495
- * @param {string} name
496
- * @param {string} namespace
497
- * @returns {Promise<boolean>}
498
- */
499
- static deleteOpfsDatabaseInPool(name, namespace) {
500
- const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
501
- const len0 = WASM_VECTOR_LEN;
502
- const ptr1 = passStringToWasm0(namespace, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
503
- const len1 = WASM_VECTOR_LEN;
504
- const ret = wasm.ducopfsdocument_deleteOpfsDatabaseInPool(ptr0, len0, ptr1, len1);
505
- return ret;
506
- }
507
- /**
508
- * Open or create a persistent OPFS-backed DUC SQLite document.
509
- *
510
- * This must run from a Dedicated Worker because the OPFS SAH-pool VFS uses
511
- * FileSystemSyncAccessHandle.
512
- * @param {string} name
513
- * @returns {Promise<DucOpfsDocument>}
514
- */
515
- static open(name) {
516
- const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
517
- const len0 = WASM_VECTOR_LEN;
518
- const ret = wasm.ducopfsdocument_open(ptr0, len0);
519
- return ret;
520
- }
521
- /**
522
- * Return the filename used to open this document.
523
- * @returns {string}
524
- */
525
- getFilename() {
526
- let deferred1_0;
527
- let deferred1_1;
528
- try {
529
- const ret = wasm.ducopfsdocument_getFilename(this.__wbg_ptr);
530
- deferred1_0 = ret[0];
531
- deferred1_1 = ret[1];
532
- return getStringFromWasm0(ret[0], ret[1]);
533
- } finally {
534
- wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
535
- }
536
- }
537
- /**
538
- * Execute an arbitrary SQL batch (e.g. `VACUUM INTO 'export.sqlite'`).
539
- * @param {string} sql
540
- */
541
- executeBatch(sql) {
542
- const ptr0 = passStringToWasm0(sql, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
543
- const len0 = WASM_VECTOR_LEN;
544
- const ret = wasm.ducopfsdocument_executeBatch(this.__wbg_ptr, ptr0, len0);
545
- if (ret[1]) {
546
- throw takeFromExternrefTable0(ret[0]);
547
- }
195
+ /**
196
+ * @param {string} name
197
+ * @param {string} namespace
198
+ * @returns {Promise<DucOpfsDocument>}
199
+ */
200
+ static openInPool(name, namespace) {
201
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
202
+ const len0 = WASM_VECTOR_LEN;
203
+ const ptr1 = passStringToWasm0(namespace, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
204
+ const len1 = WASM_VECTOR_LEN;
205
+ const ret = wasm.ducopfsdocument_openInPool(ptr0, len0, ptr1, len1);
206
+ return ret;
548
207
  }
549
208
  /**
209
+ * @param {string} checkpoint_id
210
+ * @param {number} chunk_index
550
211
  * @returns {any}
551
212
  */
552
- listVersions() {
553
- const ret = wasm.ducopfsdocument_listVersions(this.__wbg_ptr);
213
+ readCheckpointDataChunk(checkpoint_id, chunk_index) {
214
+ const ptr0 = passStringToWasm0(checkpoint_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
215
+ const len0 = WASM_VECTOR_LEN;
216
+ const ret = wasm.ducopfsdocument_readCheckpointDataChunk(this.__wbg_ptr, ptr0, len0, chunk_index);
554
217
  if (ret[2]) {
555
218
  throw takeFromExternrefTable0(ret[1]);
556
219
  }
557
220
  return takeFromExternrefTable0(ret[0]);
558
221
  }
559
222
  /**
560
- * Flush the WAL journal into the main database file.
561
- *
562
- * After calling this, the OPFS file backing this document contains
563
- * all committed data. JavaScript can then read the file directly
564
- * from OPFS in chunks and gzip-compress it.
565
- */
566
- checkpointWal() {
567
- const ret = wasm.ducopfsdocument_checkpointWal(this.__wbg_ptr);
568
- if (ret[1]) {
569
- throw takeFromExternrefTable0(ret[0]);
570
- }
571
- }
572
- /**
573
- * Return the estimated database file size in bytes
574
- * (`page_count × page_size`). Call [`checkpoint_wal`] first for
575
- * an accurate value.
576
- * @returns {number}
223
+ * @param {string} delta_id
224
+ * @param {number} chunk_index
225
+ * @returns {any}
577
226
  */
578
- getDbSizeBytes() {
579
- const ret = wasm.ducopfsdocument_getDbSizeBytes(this.__wbg_ptr);
227
+ readDeltaChangesetChunk(delta_id, chunk_index) {
228
+ const ptr0 = passStringToWasm0(delta_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
229
+ const len0 = WASM_VECTOR_LEN;
230
+ const ret = wasm.ducopfsdocument_readDeltaChangesetChunk(this.__wbg_ptr, ptr0, len0, chunk_index);
580
231
  if (ret[2]) {
581
232
  throw takeFromExternrefTable0(ret[1]);
582
233
  }
583
- return ret[0];
234
+ return takeFromExternrefTable0(ret[0]);
584
235
  }
585
236
  /**
586
237
  * @returns {any}
587
238
  */
588
- readVersionGraph() {
589
- const ret = wasm.ducopfsdocument_readVersionGraph(this.__wbg_ptr);
239
+ readDocumentState() {
240
+ const ret = wasm.ducopfsdocument_readDocumentState(this.__wbg_ptr);
590
241
  if (ret[2]) {
591
242
  throw takeFromExternrefTable0(ret[1]);
592
243
  }
593
244
  return takeFromExternrefTable0(ret[0]);
594
245
  }
595
246
  /**
247
+ * @param {string} revision_id
248
+ * @param {number} chunk_index
596
249
  * @returns {any}
597
250
  */
598
- listExternalFiles() {
599
- const ret = wasm.ducopfsdocument_listExternalFiles(this.__wbg_ptr);
251
+ readExternalFileRevisionChunk(revision_id, chunk_index) {
252
+ const ptr0 = passStringToWasm0(revision_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
253
+ const len0 = WASM_VECTOR_LEN;
254
+ const ret = wasm.ducopfsdocument_readExternalFileRevisionChunk(this.__wbg_ptr, ptr0, len0, chunk_index);
600
255
  if (ret[2]) {
601
256
  throw takeFromExternrefTable0(ret[1]);
602
257
  }
603
258
  return takeFromExternrefTable0(ret[0]);
604
259
  }
605
260
  /**
606
- * @returns {any}
261
+ * Read a bounded batch of external-file chunks with one SQL query and one
262
+ * JS/WASM call. Batches are capped at 4 chunks to bound peak memory.
263
+ * @param {string} revision_id
264
+ * @param {number} start_chunk_index
265
+ * @param {number} max_chunks
266
+ * @returns {Array<any>}
607
267
  */
608
- readDocumentState() {
609
- const ret = wasm.ducopfsdocument_readDocumentState(this.__wbg_ptr);
268
+ readExternalFileRevisionChunks(revision_id, start_chunk_index, max_chunks) {
269
+ const ptr0 = passStringToWasm0(revision_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
270
+ const len0 = WASM_VECTOR_LEN;
271
+ const ret = wasm.ducopfsdocument_readExternalFileRevisionChunks(this.__wbg_ptr, ptr0, len0, start_chunk_index, max_chunks);
610
272
  if (ret[2]) {
611
273
  throw takeFromExternrefTable0(ret[1]);
612
274
  }
613
275
  return takeFromExternrefTable0(ret[0]);
614
276
  }
615
277
  /**
616
- * @param {any} data
617
- */
618
- writeDocumentState(data) {
619
- const ret = wasm.ducopfsdocument_writeDocumentState(this.__wbg_ptr, data);
620
- if (ret[1]) {
621
- throw takeFromExternrefTable0(ret[0]);
622
- }
623
- }
624
- /**
625
- * @param {string} checkpoint_id
626
- * @param {number} chunk_index
278
+ * Read a bounded byte range, including from legacy one-row BLOB revisions.
279
+ * @param {string} revision_id
280
+ * @param {number} offset_bytes
281
+ * @param {number} length_bytes
627
282
  * @returns {any}
628
283
  */
629
- readCheckpointDataChunk(checkpoint_id, chunk_index) {
630
- const ptr0 = passStringToWasm0(checkpoint_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
284
+ readExternalFileRevisionRange(revision_id, offset_bytes, length_bytes) {
285
+ const ptr0 = passStringToWasm0(revision_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
631
286
  const len0 = WASM_VECTOR_LEN;
632
- const ret = wasm.ducopfsdocument_readCheckpointDataChunk(this.__wbg_ptr, ptr0, len0, chunk_index);
287
+ const ret = wasm.ducopfsdocument_readExternalFileRevisionRange(this.__wbg_ptr, ptr0, len0, offset_bytes, length_bytes);
633
288
  if (ret[2]) {
634
289
  throw takeFromExternrefTable0(ret[1]);
635
290
  }
636
291
  return takeFromExternrefTable0(ret[0]);
637
292
  }
638
293
  /**
639
- * @param {string} delta_id
640
- * @param {number} chunk_index
641
294
  * @returns {any}
642
295
  */
643
- readDeltaChangesetChunk(delta_id, chunk_index) {
644
- const ptr0 = passStringToWasm0(delta_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
645
- const len0 = WASM_VECTOR_LEN;
646
- const ret = wasm.ducopfsdocument_readDeltaChangesetChunk(this.__wbg_ptr, ptr0, len0, chunk_index);
296
+ readVersionGraph() {
297
+ const ret = wasm.ducopfsdocument_readVersionGraph(this.__wbg_ptr);
647
298
  if (ret[2]) {
648
299
  throw takeFromExternrefTable0(ret[1]);
649
300
  }
@@ -682,779 +333,1114 @@ export class DucOpfsDocument {
682
333
  }
683
334
  }
684
335
  /**
685
- * @param {string} checkpoint_id
336
+ * @param {any} data
686
337
  */
687
- clearCheckpointDataChunks(checkpoint_id) {
688
- const ptr0 = passStringToWasm0(checkpoint_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
689
- const len0 = WASM_VECTOR_LEN;
690
- const ret = wasm.ducopfsdocument_clearCheckpointDataChunks(this.__wbg_ptr, ptr0, len0);
338
+ writeDocumentState(data) {
339
+ const ret = wasm.ducopfsdocument_writeDocumentState(this.__wbg_ptr, data);
691
340
  if (ret[1]) {
692
341
  throw takeFromExternrefTable0(ret[0]);
693
342
  }
694
343
  }
695
344
  /**
696
- * @param {string} delta_id
345
+ * @param {string} revision_id
346
+ * @param {number} chunk_index
347
+ * @param {number} offset_bytes
348
+ * @param {Uint8Array} data
697
349
  */
698
- clearDeltaChangesetChunks(delta_id) {
699
- const ptr0 = passStringToWasm0(delta_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
350
+ writeExternalFileRevisionChunk(revision_id, chunk_index, offset_bytes, data) {
351
+ const ptr0 = passStringToWasm0(revision_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
700
352
  const len0 = WASM_VECTOR_LEN;
701
- const ret = wasm.ducopfsdocument_clearDeltaChangesetChunks(this.__wbg_ptr, ptr0, len0);
353
+ const ptr1 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
354
+ const len1 = WASM_VECTOR_LEN;
355
+ const ret = wasm.ducopfsdocument_writeExternalFileRevisionChunk(this.__wbg_ptr, ptr0, len0, chunk_index, offset_bytes, ptr1, len1);
702
356
  if (ret[1]) {
703
357
  throw takeFromExternrefTable0(ret[0]);
704
358
  }
705
359
  }
360
+ }
361
+ if (Symbol.dispose) DucOpfsDocument.prototype[Symbol.dispose] = DucOpfsDocument.prototype.free;
362
+
363
+ /**
364
+ * Incrementally replaces one OPFS database without retaining the imported
365
+ * SQLite payload in WASM memory.
366
+ */
367
+ export class DucOpfsImporter {
368
+ static __wrap(ptr) {
369
+ const obj = Object.create(DucOpfsImporter.prototype);
370
+ obj.__wbg_ptr = ptr;
371
+ DucOpfsImporterFinalization.register(obj, obj.__wbg_ptr, obj);
372
+ return obj;
373
+ }
374
+ __destroy_into_raw() {
375
+ const ptr = this.__wbg_ptr;
376
+ this.__wbg_ptr = 0;
377
+ DucOpfsImporterFinalization.unregister(this);
378
+ return ptr;
379
+ }
380
+ free() {
381
+ const ptr = this.__destroy_into_raw();
382
+ wasm.__wbg_ducopfsimporter_free(ptr, 0);
383
+ }
706
384
  /**
707
- * @param {string} revision_id
708
- * @param {number} chunk_index
709
- * @returns {any}
385
+ * Delete a partial import. Safe to call after a failed stream read.
386
+ * @returns {boolean}
710
387
  */
711
- readExternalFileRevisionChunk(revision_id, chunk_index) {
712
- const ptr0 = passStringToWasm0(revision_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
713
- const len0 = WASM_VECTOR_LEN;
714
- const ret = wasm.ducopfsdocument_readExternalFileRevisionChunk(this.__wbg_ptr, ptr0, len0, chunk_index);
388
+ abort() {
389
+ const ret = wasm.ducopfsimporter_abort(this.__wbg_ptr);
715
390
  if (ret[2]) {
716
391
  throw takeFromExternrefTable0(ret[1]);
717
392
  }
718
- return takeFromExternrefTable0(ret[0]);
393
+ return ret[0] !== 0;
719
394
  }
720
395
  /**
721
- * Read a bounded byte range, including from legacy one-row BLOB revisions.
722
- * @param {string} revision_id
723
- * @param {number} offset_bytes
724
- * @param {number} length_bytes
725
- * @returns {any}
396
+ * Begin replacing `name`. Any prior database with the same closed name is
397
+ * released back to the SAH pool before the new import claims a slot.
398
+ * @param {string} name
399
+ * @returns {Promise<DucOpfsImporter>}
726
400
  */
727
- readExternalFileRevisionRange(revision_id, offset_bytes, length_bytes) {
728
- const ptr0 = passStringToWasm0(revision_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
401
+ static begin(name) {
402
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
729
403
  const len0 = WASM_VECTOR_LEN;
730
- const ret = wasm.ducopfsdocument_readExternalFileRevisionRange(this.__wbg_ptr, ptr0, len0, offset_bytes, length_bytes);
404
+ const ret = wasm.ducopfsimporter_begin(ptr0, len0);
405
+ return ret;
406
+ }
407
+ /**
408
+ * @param {string} name
409
+ * @param {string} namespace
410
+ * @returns {Promise<DucOpfsImporter>}
411
+ */
412
+ static beginInPool(name, namespace) {
413
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
414
+ const len0 = WASM_VECTOR_LEN;
415
+ const ptr1 = passStringToWasm0(namespace, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
416
+ const len1 = WASM_VECTOR_LEN;
417
+ const ret = wasm.ducopfsimporter_beginInPool(ptr0, len0, ptr1, len1);
418
+ return ret;
419
+ }
420
+ /**
421
+ * Flush the imported database and make it ready for SQLite to open.
422
+ * @returns {number}
423
+ */
424
+ finish() {
425
+ const ret = wasm.ducopfsimporter_finish(this.__wbg_ptr);
731
426
  if (ret[2]) {
732
427
  throw takeFromExternrefTable0(ret[1]);
733
428
  }
734
- return takeFromExternrefTable0(ret[0]);
429
+ return ret[0];
735
430
  }
736
431
  /**
737
- * Read a bounded batch of external-file chunks with one SQL query and one
738
- * JS/WASM call. Batches are capped at 4 chunks to bound peak memory.
739
- * @param {string} revision_id
740
- * @param {number} start_chunk_index
741
- * @param {number} max_chunks
742
- * @returns {Array<any>}
432
+ * @returns {number}
743
433
  */
744
- readExternalFileRevisionChunks(revision_id, start_chunk_index, max_chunks) {
745
- const ptr0 = passStringToWasm0(revision_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
434
+ getBytesWritten() {
435
+ const ret = wasm.ducopfsimporter_getBytesWritten(this.__wbg_ptr);
436
+ return ret;
437
+ }
438
+ /**
439
+ * Write the next decompressed SQLite chunk.
440
+ * @param {Uint8Array} data
441
+ */
442
+ writeChunk(data) {
443
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
746
444
  const len0 = WASM_VECTOR_LEN;
747
- const ret = wasm.ducopfsdocument_readExternalFileRevisionChunks(this.__wbg_ptr, ptr0, len0, start_chunk_index, max_chunks);
748
- if (ret[2]) {
749
- throw takeFromExternrefTable0(ret[1]);
445
+ const ret = wasm.ducopfsimporter_writeChunk(this.__wbg_ptr, ptr0, len0);
446
+ if (ret[1]) {
447
+ throw takeFromExternrefTable0(ret[0]);
448
+ }
449
+ }
450
+ }
451
+ if (Symbol.dispose) DucOpfsImporter.prototype[Symbol.dispose] = DucOpfsImporter.prototype.free;
452
+
453
+ /**
454
+ * Apply a changeset to reconstruct document state.
455
+ *
456
+ * `base_state` must be the exact checkpoint data used when the changeset
457
+ * was created. Returns the full document state as `Uint8Array`.
458
+ *
459
+ * Handles all changeset formats transparently:
460
+ * - v3 (bsdiff), v2 (XOR diff), v1 (gzip full snapshot)
461
+ * @param {Uint8Array} base_state
462
+ * @param {Uint8Array} changeset
463
+ * @returns {Uint8Array}
464
+ */
465
+ export function applyDeltaChangeset(base_state, changeset) {
466
+ const ptr0 = passArray8ToWasm0(base_state, wasm.__wbindgen_malloc);
467
+ const len0 = WASM_VECTOR_LEN;
468
+ const ptr1 = passArray8ToWasm0(changeset, wasm.__wbindgen_malloc);
469
+ const len1 = WASM_VECTOR_LEN;
470
+ const ret = wasm.applyDeltaChangeset(ptr0, len0, ptr1, len1);
471
+ if (ret[3]) {
472
+ throw takeFromExternrefTable0(ret[2]);
473
+ }
474
+ var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
475
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
476
+ return v3;
477
+ }
478
+
479
+ /**
480
+ * Compute a checkpoint-relative binary diff changeset using bsdiff.
481
+ *
482
+ * `base_state` is the checkpoint's full data blob.
483
+ * `current_state` is the full document state at the new version.
484
+ *
485
+ * Returns an encoded changeset (`Uint8Array`) ready for storage in a
486
+ * `Delta.payload`. bsdiff finds matching blocks even when they shift
487
+ * offsets, which is critical for SQLite databases.
488
+ * @param {Uint8Array} base_state
489
+ * @param {Uint8Array} current_state
490
+ * @returns {Uint8Array}
491
+ */
492
+ export function createDeltaChangeset(base_state, current_state) {
493
+ const ptr0 = passArray8ToWasm0(base_state, wasm.__wbindgen_malloc);
494
+ const len0 = WASM_VECTOR_LEN;
495
+ const ptr1 = passArray8ToWasm0(current_state, wasm.__wbindgen_malloc);
496
+ const len1 = WASM_VECTOR_LEN;
497
+ const ret = wasm.createDeltaChangeset(ptr0, len0, ptr1, len1);
498
+ if (ret[3]) {
499
+ throw takeFromExternrefTable0(ret[2]);
500
+ }
501
+ var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
502
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
503
+ return v3;
504
+ }
505
+
506
+ /**
507
+ * Returns the current version-control schema version defined in Rust.
508
+ *
509
+ * TypeScript should use this as the source of truth instead of hardcoding
510
+ * its own constant. When this value is bumped in Rust, the version control
511
+ * system will automatically handle migration bookkeeping (closing old chains,
512
+ * recording migrations) the next time a checkpoint or delta is created.
513
+ * @returns {number}
514
+ */
515
+ export function getCurrentSchemaVersion() {
516
+ return 4000000;
517
+ }
518
+
519
+ /**
520
+ * List all versions (checkpoints + deltas) from a `.duc` file buffer.
521
+ * @param {Uint8Array} duc_buf
522
+ * @returns {any}
523
+ */
524
+ export function listVersions(duc_buf) {
525
+ const ptr0 = passArray8ToWasm0(duc_buf, wasm.__wbindgen_malloc);
526
+ const len0 = WASM_VECTOR_LEN;
527
+ const ret = wasm.listVersions(ptr0, len0);
528
+ if (ret[2]) {
529
+ throw takeFromExternrefTable0(ret[1]);
530
+ }
531
+ return takeFromExternrefTable0(ret[0]);
532
+ }
533
+
534
+ /**
535
+ * Parse a `.duc` file (Uint8Array) into a JS object (ExportedDataState).
536
+ * @param {Uint8Array} buf
537
+ * @returns {any}
538
+ */
539
+ export function parseDuc(buf) {
540
+ const ptr0 = passArray8ToWasm0(buf, wasm.__wbindgen_malloc);
541
+ const len0 = WASM_VECTOR_LEN;
542
+ const ret = wasm.parseDuc(ptr0, len0);
543
+ if (ret[2]) {
544
+ throw takeFromExternrefTable0(ret[1]);
545
+ }
546
+ return takeFromExternrefTable0(ret[0]);
547
+ }
548
+
549
+ /**
550
+ * Read the full VersionGraph from a `.duc` file buffer.
551
+ * @param {Uint8Array} duc_buf
552
+ * @returns {any}
553
+ */
554
+ export function readVersionGraph(duc_buf) {
555
+ const ptr0 = passArray8ToWasm0(duc_buf, wasm.__wbindgen_malloc);
556
+ const len0 = WASM_VECTOR_LEN;
557
+ const ret = wasm.readVersionGraph(ptr0, len0);
558
+ if (ret[2]) {
559
+ throw takeFromExternrefTable0(ret[1]);
560
+ }
561
+ return takeFromExternrefTable0(ret[0]);
562
+ }
563
+
564
+ /**
565
+ * Restore a specific checkpoint by its ID from a `.duc` file buffer.
566
+ * @param {Uint8Array} duc_buf
567
+ * @param {string} checkpoint_id
568
+ * @returns {any}
569
+ */
570
+ export function restoreCheckpoint(duc_buf, checkpoint_id) {
571
+ const ptr0 = passArray8ToWasm0(duc_buf, wasm.__wbindgen_malloc);
572
+ const len0 = WASM_VECTOR_LEN;
573
+ const ptr1 = passStringToWasm0(checkpoint_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
574
+ const len1 = WASM_VECTOR_LEN;
575
+ const ret = wasm.restoreCheckpoint(ptr0, len0, ptr1, len1);
576
+ if (ret[2]) {
577
+ throw takeFromExternrefTable0(ret[1]);
578
+ }
579
+ return takeFromExternrefTable0(ret[0]);
580
+ }
581
+
582
+ /**
583
+ * Restore the document state at `version_number` from a `.duc` file buffer.
584
+ * @param {Uint8Array} duc_buf
585
+ * @param {number} version_number
586
+ * @returns {any}
587
+ */
588
+ export function restoreVersion(duc_buf, version_number) {
589
+ const ptr0 = passArray8ToWasm0(duc_buf, wasm.__wbindgen_malloc);
590
+ const len0 = WASM_VECTOR_LEN;
591
+ const ret = wasm.restoreVersion(ptr0, len0, version_number);
592
+ if (ret[2]) {
593
+ throw takeFromExternrefTable0(ret[1]);
594
+ }
595
+ return takeFromExternrefTable0(ret[0]);
596
+ }
597
+
598
+ /**
599
+ * Revert the document to a specific version, removing all newer versions.
600
+ * @param {Uint8Array} duc_buf
601
+ * @param {number} target_version
602
+ * @returns {any}
603
+ */
604
+ export function revertToVersion(duc_buf, target_version) {
605
+ const ptr0 = passArray8ToWasm0(duc_buf, wasm.__wbindgen_malloc);
606
+ const len0 = WASM_VECTOR_LEN;
607
+ const ret = wasm.revertToVersion(ptr0, len0, target_version);
608
+ if (ret[2]) {
609
+ throw takeFromExternrefTable0(ret[1]);
610
+ }
611
+ return takeFromExternrefTable0(ret[0]);
612
+ }
613
+
614
+ /**
615
+ * Serialize a JS object (ExportedDataState) into `.duc` bytes (Uint8Array).
616
+ * @param {any} data
617
+ * @returns {Uint8Array}
618
+ */
619
+ export function serializeDuc(data) {
620
+ const ret = wasm.serializeDuc(data);
621
+ if (ret[3]) {
622
+ throw takeFromExternrefTable0(ret[2]);
623
+ }
624
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
625
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
626
+ return v1;
627
+ }
628
+ function __wbg_get_imports() {
629
+ const import0 = {
630
+ __proto__: null,
631
+ __wbg_Error_408e67f47ca7b58b: function(arg0, arg1) {
632
+ const ret = Error(getStringFromWasm0(arg0, arg1));
633
+ return ret;
634
+ },
635
+ __wbg_Number_3890faa6d3ff057d: function(arg0) {
636
+ const ret = Number(arg0);
637
+ return ret;
638
+ },
639
+ __wbg_String_8564e559799eccda: function(arg0, arg1) {
640
+ const ret = String(arg1);
641
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
642
+ const len1 = WASM_VECTOR_LEN;
643
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
644
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
645
+ },
646
+ __wbg___wbindgen_bigint_get_as_i64_c4ecf48528083721: function(arg0, arg1) {
647
+ const v = arg1;
648
+ const ret = typeof(v) === 'bigint' ? v : undefined;
649
+ getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
650
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
651
+ },
652
+ __wbg___wbindgen_boolean_get_c9c83ebd41b34df3: function(arg0) {
653
+ const v = arg0;
654
+ const ret = typeof(v) === 'boolean' ? v : undefined;
655
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
656
+ },
657
+ __wbg___wbindgen_debug_string_a57024b9c6e4a48b: function(arg0, arg1) {
658
+ const ret = debugString(arg1);
659
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
660
+ const len1 = WASM_VECTOR_LEN;
661
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
662
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
663
+ },
664
+ __wbg___wbindgen_in_ac983077f137f2e6: function(arg0, arg1) {
665
+ const ret = arg0 in arg1;
666
+ return ret;
667
+ },
668
+ __wbg___wbindgen_is_bigint_8ffbbef442139384: function(arg0) {
669
+ const ret = typeof(arg0) === 'bigint';
670
+ return ret;
671
+ },
672
+ __wbg___wbindgen_is_function_5e4570eb24ffa122: function(arg0) {
673
+ const ret = typeof(arg0) === 'function';
674
+ return ret;
675
+ },
676
+ __wbg___wbindgen_is_object_a2790eb24c211ea0: function(arg0) {
677
+ const val = arg0;
678
+ const ret = typeof(val) === 'object' && val !== null;
679
+ return ret;
680
+ },
681
+ __wbg___wbindgen_is_string_e6f02f0ea5f20a32: function(arg0) {
682
+ const ret = typeof(arg0) === 'string';
683
+ return ret;
684
+ },
685
+ __wbg___wbindgen_is_undefined_6cff064c44e0d823: function(arg0) {
686
+ const ret = arg0 === undefined;
687
+ return ret;
688
+ },
689
+ __wbg___wbindgen_jsval_eq_0a18949a61670320: function(arg0, arg1) {
690
+ const ret = arg0 === arg1;
691
+ return ret;
692
+ },
693
+ __wbg___wbindgen_jsval_loose_eq_acf2776254a8d832: function(arg0, arg1) {
694
+ const ret = arg0 == arg1;
695
+ return ret;
696
+ },
697
+ __wbg___wbindgen_number_get_136b9679cab35cfb: function(arg0, arg1) {
698
+ const obj = arg1;
699
+ const ret = typeof(obj) === 'number' ? obj : undefined;
700
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
701
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
702
+ },
703
+ __wbg___wbindgen_string_get_d154f1e671052120: function(arg0, arg1) {
704
+ const obj = arg1;
705
+ const ret = typeof(obj) === 'string' ? obj : undefined;
706
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
707
+ var len1 = WASM_VECTOR_LEN;
708
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
709
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
710
+ },
711
+ __wbg___wbindgen_throw_bb96b2010945f0bc: function(arg0, arg1) {
712
+ throw new Error(getStringFromWasm0(arg0, arg1));
713
+ },
714
+ __wbg__wbg_cb_unref_be22cc64ae6946a0: function(arg0) {
715
+ arg0._wbg_cb_unref();
716
+ },
717
+ __wbg_buffer_78291c0e094ccf99: function(arg0) {
718
+ const ret = arg0.buffer;
719
+ return ret;
720
+ },
721
+ __wbg_byteLength_336bc7d303511ba0: function(arg0) {
722
+ const ret = arg0.byteLength;
723
+ return ret;
724
+ },
725
+ __wbg_byteOffset_2b1d5b10453ce198: function(arg0) {
726
+ const ret = arg0.byteOffset;
727
+ return ret;
728
+ },
729
+ __wbg_call_1c5886ab9c57d1c7: function() { return handleError(function (arg0, arg1) {
730
+ const ret = arg0.call(arg1);
731
+ return ret;
732
+ }, arguments); },
733
+ __wbg_call_35dba3c747ad7521: function() { return handleError(function (arg0, arg1, arg2) {
734
+ const ret = arg0.call(arg1, arg2);
735
+ return ret;
736
+ }, arguments); },
737
+ __wbg_createSyncAccessHandle_e383ed6b08d0e3ee: function(arg0) {
738
+ const ret = arg0.createSyncAccessHandle();
739
+ return ret;
740
+ },
741
+ __wbg_done_669171204c3dcae2: function(arg0) {
742
+ const ret = arg0.done;
743
+ return ret;
744
+ },
745
+ __wbg_ducopfsdocument_new: function(arg0) {
746
+ const ret = DucOpfsDocument.__wrap(arg0);
747
+ return ret;
748
+ },
749
+ __wbg_ducopfsimporter_new: function(arg0) {
750
+ const ret = DucOpfsImporter.__wrap(arg0);
751
+ return ret;
752
+ },
753
+ __wbg_entries_7774d489e1da5f4f: function(arg0) {
754
+ const ret = Object.entries(arg0);
755
+ return ret;
756
+ },
757
+ __wbg_entries_90a6ca372c867900: function(arg0) {
758
+ const ret = arg0.entries();
759
+ return ret;
760
+ },
761
+ __wbg_fill_36c70ae56a83e4f3: function(arg0, arg1, arg2, arg3) {
762
+ const ret = arg0.fill(arg1, arg2 >>> 0, arg3 >>> 0);
763
+ return ret;
764
+ },
765
+ __wbg_flush_fc67ba80dfb8083f: function() { return handleError(function (arg0) {
766
+ arg0.flush();
767
+ }, arguments); },
768
+ __wbg_from_74f3d90e0ff11240: function(arg0) {
769
+ const ret = Array.from(arg0);
770
+ return ret;
771
+ },
772
+ __wbg_getDate_b0ac858991e80b2e: function(arg0) {
773
+ const ret = arg0.getDate();
774
+ return ret;
775
+ },
776
+ __wbg_getDay_d65e35285ba489ae: function(arg0) {
777
+ const ret = arg0.getDay();
778
+ return ret;
779
+ },
780
+ __wbg_getDirectoryHandle_3b6e6ec9cd618b74: function(arg0, arg1, arg2, arg3) {
781
+ const ret = arg0.getDirectoryHandle(getStringFromWasm0(arg1, arg2), arg3);
782
+ return ret;
783
+ },
784
+ __wbg_getDirectory_2cc7169b6007ef84: function(arg0) {
785
+ const ret = arg0.getDirectory();
786
+ return ret;
787
+ },
788
+ __wbg_getFileHandle_ba98be7045eab758: function(arg0, arg1, arg2, arg3) {
789
+ const ret = arg0.getFileHandle(getStringFromWasm0(arg1, arg2), arg3);
790
+ return ret;
791
+ },
792
+ __wbg_getFullYear_d2ecaf3ecbfaddf9: function(arg0) {
793
+ const ret = arg0.getFullYear();
794
+ return ret;
795
+ },
796
+ __wbg_getHours_521ab343a38cb962: function(arg0) {
797
+ const ret = arg0.getHours();
798
+ return ret;
799
+ },
800
+ __wbg_getMinutes_27257e5640ea2e7c: function(arg0) {
801
+ const ret = arg0.getMinutes();
802
+ return ret;
803
+ },
804
+ __wbg_getMonth_9f2f20dab3150834: function(arg0) {
805
+ const ret = arg0.getMonth();
806
+ return ret;
807
+ },
808
+ __wbg_getRandomValues_896855b3a5f89999: function() { return handleError(function (arg0, arg1) {
809
+ globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
810
+ }, arguments); },
811
+ __wbg_getSeconds_0071b90906b363f2: function(arg0) {
812
+ const ret = arg0.getSeconds();
813
+ return ret;
814
+ },
815
+ __wbg_getSize_b36240c52be725fe: function() { return handleError(function (arg0) {
816
+ const ret = arg0.getSize();
817
+ return ret;
818
+ }, arguments); },
819
+ __wbg_getTime_63fb0332e6c4ec17: function(arg0) {
820
+ const ret = arg0.getTime();
821
+ return ret;
822
+ },
823
+ __wbg_getTimezoneOffset_4baa793e0d3962a8: function(arg0) {
824
+ const ret = arg0.getTimezoneOffset();
825
+ return ret;
826
+ },
827
+ __wbg_getUint32_1cfbc1285192d4d4: function(arg0, arg1) {
828
+ const ret = arg0.getUint32(arg1 >>> 0);
829
+ return ret;
830
+ },
831
+ __wbg_get_971a0c45d172643f: function() { return handleError(function (arg0, arg1) {
832
+ const ret = Reflect.get(arg0, arg1);
833
+ return ret;
834
+ }, arguments); },
835
+ __wbg_get_c0c8f8d7da0c03dd: function(arg0, arg1) {
836
+ const ret = arg0[arg1 >>> 0];
837
+ return ret;
838
+ },
839
+ __wbg_get_d173c0308df22d37: function() { return handleError(function (arg0, arg1) {
840
+ const ret = Reflect.get(arg0, arg1);
841
+ return ret;
842
+ }, arguments); },
843
+ __wbg_get_index_692b103434df899b: function(arg0, arg1) {
844
+ const ret = arg0[arg1 >>> 0];
845
+ return ret;
846
+ },
847
+ __wbg_get_unchecked_e20b893aeafc3fca: function(arg0, arg1) {
848
+ const ret = arg0[arg1 >>> 0];
849
+ return ret;
850
+ },
851
+ __wbg_get_with_ref_key_6412cf3094599694: function(arg0, arg1) {
852
+ const ret = arg0[arg1];
853
+ return ret;
854
+ },
855
+ __wbg_instanceof_ArrayBuffer_993d02d2d254cad1: function(arg0) {
856
+ let result;
857
+ try {
858
+ result = arg0 instanceof ArrayBuffer;
859
+ } catch (_) {
860
+ result = false;
861
+ }
862
+ const ret = result;
863
+ return ret;
864
+ },
865
+ __wbg_instanceof_Map_9a4d6ead180ae3a9: function(arg0) {
866
+ let result;
867
+ try {
868
+ result = arg0 instanceof Map;
869
+ } catch (_) {
870
+ result = false;
871
+ }
872
+ const ret = result;
873
+ return ret;
874
+ },
875
+ __wbg_instanceof_Uint8Array_f935dbb0aa7cdeed: function(arg0) {
876
+ let result;
877
+ try {
878
+ result = arg0 instanceof Uint8Array;
879
+ } catch (_) {
880
+ result = false;
881
+ }
882
+ const ret = result;
883
+ return ret;
884
+ },
885
+ __wbg_instanceof_WorkerGlobalScope_8c58a6d74926b578: function(arg0) {
886
+ let result;
887
+ try {
888
+ result = arg0 instanceof WorkerGlobalScope;
889
+ } catch (_) {
890
+ result = false;
891
+ }
892
+ const ret = result;
893
+ return ret;
894
+ },
895
+ __wbg_isArray_6339f732981044bf: function(arg0) {
896
+ const ret = Array.isArray(arg0);
897
+ return ret;
898
+ },
899
+ __wbg_isSafeInteger_f3d6cd19ccfe4512: function(arg0) {
900
+ const ret = Number.isSafeInteger(arg0);
901
+ return ret;
902
+ },
903
+ __wbg_iterator_5cebbb86e33c6dd6: function() {
904
+ const ret = Symbol.iterator;
905
+ return ret;
906
+ },
907
+ __wbg_length_36bd29c6848c2144: function(arg0) {
908
+ const ret = arg0.length;
909
+ return ret;
910
+ },
911
+ __wbg_length_ecfa2c63d3d0d82c: function(arg0) {
912
+ const ret = arg0.length;
913
+ return ret;
914
+ },
915
+ __wbg_navigator_e5c345298a9609cd: function(arg0) {
916
+ const ret = arg0.navigator;
917
+ return ret;
918
+ },
919
+ __wbg_new_0_f117d868b403dc07: function() {
920
+ const ret = new Date();
921
+ return ret;
922
+ },
923
+ __wbg_new_116be93542d39019: function() {
924
+ const ret = new Array();
925
+ return ret;
926
+ },
927
+ __wbg_new_13a20857fcf78d7a: function(arg0, arg1, arg2) {
928
+ const ret = new DataView(arg0, arg1 >>> 0, arg2 >>> 0);
929
+ return ret;
930
+ },
931
+ __wbg_new_77cc4f4f472aeb81: function(arg0) {
932
+ const ret = new Uint8Array(arg0);
933
+ return ret;
934
+ },
935
+ __wbg_new_cdf041679ded4c5f: function() {
936
+ const ret = new Map();
937
+ return ret;
938
+ },
939
+ __wbg_new_ebe3e0f6837f0879: function() {
940
+ const ret = new Object();
941
+ return ret;
942
+ },
943
+ __wbg_new_f9d6489212f3b2b3: function(arg0) {
944
+ const ret = new Date(arg0);
945
+ return ret;
946
+ },
947
+ __wbg_new_from_slice_3eea173078478cfe: function(arg0, arg1) {
948
+ const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
949
+ return ret;
950
+ },
951
+ __wbg_new_typed_cceaf62d8d95e9f2: function(arg0, arg1) {
952
+ try {
953
+ var state0 = {a: arg0, b: arg1};
954
+ var cb0 = (arg0, arg1) => {
955
+ const a = state0.a;
956
+ state0.a = 0;
957
+ try {
958
+ return wasm_bindgen_cbbfe5fbe5ccf11c___convert__closures_____invoke___js_sys_15501fc5a3580944___Function_fn_wasm_bindgen_cbbfe5fbe5ccf11c___JsValue_____wasm_bindgen_cbbfe5fbe5ccf11c___sys__Undefined___js_sys_15501fc5a3580944___Function_fn_wasm_bindgen_cbbfe5fbe5ccf11c___JsValue_____wasm_bindgen_cbbfe5fbe5ccf11c___sys__Undefined_______true_(a, state0.b, arg0, arg1);
959
+ } finally {
960
+ state0.a = a;
961
+ }
962
+ };
963
+ const ret = new Promise(cb0);
964
+ return ret;
965
+ } finally {
966
+ state0.a = 0;
967
+ }
968
+ },
969
+ __wbg_new_with_length_2ccc5dbfb4541247: function(arg0) {
970
+ const ret = new Array(arg0 >>> 0);
971
+ return ret;
972
+ },
973
+ __wbg_new_with_length_3ffc1c56427c525c: function(arg0) {
974
+ const ret = new Uint8Array(arg0 >>> 0);
975
+ return ret;
976
+ },
977
+ __wbg_new_with_year_month_day_cc812ef210488bf4: function(arg0, arg1, arg2) {
978
+ const ret = new Date(arg0 >>> 0, arg1, arg2);
979
+ return ret;
980
+ },
981
+ __wbg_next_42cf16ee0dafc9e2: function() { return handleError(function (arg0) {
982
+ const ret = arg0.next();
983
+ return ret;
984
+ }, arguments); },
985
+ __wbg_next_8f26b64fa5e9f64b: function(arg0) {
986
+ const ret = arg0.next;
987
+ return ret;
988
+ },
989
+ __wbg_next_ae072aa8ecb396cb: function() { return handleError(function (arg0) {
990
+ const ret = arg0.next();
991
+ return ret;
992
+ }, arguments); },
993
+ __wbg_prototypesetcall_de8e0d9553586985: function(arg0, arg1, arg2) {
994
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
995
+ },
996
+ __wbg_queueMicrotask_ac694eae12e92dfb: function(arg0) {
997
+ queueMicrotask(arg0);
998
+ },
999
+ __wbg_queueMicrotask_be5fe34a8f4cad4d: function(arg0) {
1000
+ const ret = arg0.queueMicrotask;
1001
+ return ret;
1002
+ },
1003
+ __wbg_random_b0d98802be10ff20: function() {
1004
+ const ret = Math.random();
1005
+ return ret;
1006
+ },
1007
+ __wbg_read_ab19cfc151f4bfb2: function() { return handleError(function (arg0, arg1, arg2, arg3) {
1008
+ const ret = arg0.read(getArrayU8FromWasm0(arg1, arg2), arg3);
1009
+ return ret;
1010
+ }, arguments); },
1011
+ __wbg_read_d33c5395752d9c02: function() { return handleError(function (arg0, arg1, arg2) {
1012
+ const ret = arg0.read(arg1, arg2);
1013
+ return ret;
1014
+ }, arguments); },
1015
+ __wbg_resolve_020f95d838c6ef25: function(arg0) {
1016
+ const ret = Promise.resolve(arg0);
1017
+ return ret;
1018
+ },
1019
+ __wbg_setUint32_6e4c7e967587027b: function(arg0, arg1, arg2) {
1020
+ arg0.setUint32(arg1 >>> 0, arg2 >>> 0);
1021
+ },
1022
+ __wbg_set_014226dfeca53178: function(arg0, arg1, arg2) {
1023
+ const ret = arg0.set(arg1, arg2);
1024
+ return ret;
1025
+ },
1026
+ __wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
1027
+ arg0[arg1] = arg2;
1028
+ },
1029
+ __wbg_set_8155bb79a948541b: function() { return handleError(function (arg0, arg1, arg2) {
1030
+ const ret = Reflect.set(arg0, arg1, arg2);
1031
+ return ret;
1032
+ }, arguments); },
1033
+ __wbg_set_a80955eb93b145c6: function(arg0, arg1, arg2) {
1034
+ arg0[arg1 >>> 0] = arg2;
1035
+ },
1036
+ __wbg_set_at_6f40905f0edc79cf: function(arg0, arg1) {
1037
+ arg0.at = arg1;
1038
+ },
1039
+ __wbg_set_b9b5b5cb7b495037: function(arg0, arg1, arg2) {
1040
+ arg0.set(getArrayU8FromWasm0(arg1, arg2));
1041
+ },
1042
+ __wbg_set_create_7df81b728041e33b: function(arg0, arg1) {
1043
+ arg0.create = arg1 !== 0;
1044
+ },
1045
+ __wbg_set_create_c415df73c1fec0ca: function(arg0, arg1) {
1046
+ arg0.create = arg1 !== 0;
1047
+ },
1048
+ __wbg_static_accessor_GLOBAL_THIS_466428f93b4eaa76: function() {
1049
+ const ret = typeof globalThis === 'undefined' ? null : globalThis;
1050
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
1051
+ },
1052
+ __wbg_static_accessor_GLOBAL_c7aea38d4de089bc: function() {
1053
+ const ret = typeof global === 'undefined' ? null : global;
1054
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
1055
+ },
1056
+ __wbg_static_accessor_SELF_42d4fae05e59267a: function() {
1057
+ const ret = typeof self === 'undefined' ? null : self;
1058
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
1059
+ },
1060
+ __wbg_static_accessor_WINDOW_e0db14a0eba6a812: function() {
1061
+ const ret = typeof window === 'undefined' ? null : window;
1062
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
1063
+ },
1064
+ __wbg_storage_8404e6f1c45baa97: function(arg0) {
1065
+ const ret = arg0.storage;
1066
+ return ret;
1067
+ },
1068
+ __wbg_subarray_a4cc58201c7359fd: function(arg0, arg1, arg2) {
1069
+ const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
1070
+ return ret;
1071
+ },
1072
+ __wbg_then_7026b513a94278a8: function(arg0, arg1) {
1073
+ const ret = arg0.then(arg1);
1074
+ return ret;
1075
+ },
1076
+ __wbg_then_72819b8d4e081fb5: function(arg0, arg1, arg2) {
1077
+ const ret = arg0.then(arg1, arg2);
1078
+ return ret;
1079
+ },
1080
+ __wbg_truncate_33e88a08aec84901: function() { return handleError(function (arg0, arg1) {
1081
+ arg0.truncate(arg1);
1082
+ }, arguments); },
1083
+ __wbg_truncate_d9bc4541b2289295: function() { return handleError(function (arg0, arg1) {
1084
+ arg0.truncate(arg1 >>> 0);
1085
+ }, arguments); },
1086
+ __wbg_value_1e2369fab29b420e: function(arg0) {
1087
+ const ret = arg0.value;
1088
+ return ret;
1089
+ },
1090
+ __wbg_write_c418a353f008965f: function() { return handleError(function (arg0, arg1, arg2) {
1091
+ const ret = arg0.write(arg1, arg2);
1092
+ return ret;
1093
+ }, arguments); },
1094
+ __wbg_write_cab998b888a6fc03: function() { return handleError(function (arg0, arg1, arg2, arg3) {
1095
+ const ret = arg0.write(getArrayU8FromWasm0(arg1, arg2), arg3);
1096
+ return ret;
1097
+ }, arguments); },
1098
+ __wbindgen_cast_0000000000000001: function(arg0, arg1) {
1099
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 98, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
1100
+ const ret = makeMutClosure(arg0, arg1, wasm_bindgen_cbbfe5fbe5ccf11c___convert__closures_____invoke___wasm_bindgen_cbbfe5fbe5ccf11c___JsValue__core_f0fd674eaa06beef___result__Result_____wasm_bindgen_cbbfe5fbe5ccf11c___JsError___true_);
1101
+ return ret;
1102
+ },
1103
+ __wbindgen_cast_0000000000000002: function(arg0) {
1104
+ // Cast intrinsic for `F64 -> Externref`.
1105
+ const ret = arg0;
1106
+ return ret;
1107
+ },
1108
+ __wbindgen_cast_0000000000000003: function(arg0) {
1109
+ // Cast intrinsic for `I64 -> Externref`.
1110
+ const ret = arg0;
1111
+ return ret;
1112
+ },
1113
+ __wbindgen_cast_0000000000000004: function(arg0, arg1) {
1114
+ // Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
1115
+ const ret = getArrayU8FromWasm0(arg0, arg1);
1116
+ return ret;
1117
+ },
1118
+ __wbindgen_cast_0000000000000005: function(arg0, arg1) {
1119
+ // Cast intrinsic for `Ref(String) -> Externref`.
1120
+ const ret = getStringFromWasm0(arg0, arg1);
1121
+ return ret;
1122
+ },
1123
+ __wbindgen_cast_0000000000000006: function(arg0) {
1124
+ // Cast intrinsic for `U64 -> Externref`.
1125
+ const ret = BigInt.asUintN(64, arg0);
1126
+ return ret;
1127
+ },
1128
+ __wbindgen_cast_0000000000000007: function(arg0, arg1) {
1129
+ var v0 = getArrayU8FromWasm0(arg0, arg1).slice();
1130
+ wasm.__wbindgen_free(arg0, arg1 * 1, 1);
1131
+ // Cast intrinsic for `Vector(U8) -> Externref`.
1132
+ const ret = v0;
1133
+ return ret;
1134
+ },
1135
+ __wbindgen_init_externref_table: function() {
1136
+ const table = wasm.__wbindgen_externrefs;
1137
+ const offset = table.grow(4);
1138
+ table.set(0, undefined);
1139
+ table.set(offset + 0, undefined);
1140
+ table.set(offset + 1, null);
1141
+ table.set(offset + 2, true);
1142
+ table.set(offset + 3, false);
1143
+ },
1144
+ };
1145
+ return {
1146
+ __proto__: null,
1147
+ "./ducjs_wasm_bg.js": import0,
1148
+ };
1149
+ }
1150
+
1151
+ function wasm_bindgen_cbbfe5fbe5ccf11c___convert__closures_____invoke___wasm_bindgen_cbbfe5fbe5ccf11c___JsValue__core_f0fd674eaa06beef___result__Result_____wasm_bindgen_cbbfe5fbe5ccf11c___JsError___true_(arg0, arg1, arg2) {
1152
+ const ret = wasm.wasm_bindgen_cbbfe5fbe5ccf11c___convert__closures_____invoke___wasm_bindgen_cbbfe5fbe5ccf11c___JsValue__core_f0fd674eaa06beef___result__Result_____wasm_bindgen_cbbfe5fbe5ccf11c___JsError___true_(arg0, arg1, arg2);
1153
+ if (ret[1]) {
1154
+ throw takeFromExternrefTable0(ret[0]);
1155
+ }
1156
+ }
1157
+
1158
+ function wasm_bindgen_cbbfe5fbe5ccf11c___convert__closures_____invoke___js_sys_15501fc5a3580944___Function_fn_wasm_bindgen_cbbfe5fbe5ccf11c___JsValue_____wasm_bindgen_cbbfe5fbe5ccf11c___sys__Undefined___js_sys_15501fc5a3580944___Function_fn_wasm_bindgen_cbbfe5fbe5ccf11c___JsValue_____wasm_bindgen_cbbfe5fbe5ccf11c___sys__Undefined_______true_(arg0, arg1, arg2, arg3) {
1159
+ wasm.wasm_bindgen_cbbfe5fbe5ccf11c___convert__closures_____invoke___js_sys_15501fc5a3580944___Function_fn_wasm_bindgen_cbbfe5fbe5ccf11c___JsValue_____wasm_bindgen_cbbfe5fbe5ccf11c___sys__Undefined___js_sys_15501fc5a3580944___Function_fn_wasm_bindgen_cbbfe5fbe5ccf11c___JsValue_____wasm_bindgen_cbbfe5fbe5ccf11c___sys__Undefined_______true_(arg0, arg1, arg2, arg3);
1160
+ }
1161
+
1162
+ const DucOpfsDocumentFinalization = (typeof FinalizationRegistry === 'undefined')
1163
+ ? { register: () => {}, unregister: () => {} }
1164
+ : new FinalizationRegistry(ptr => wasm.__wbg_ducopfsdocument_free(ptr, 1));
1165
+ const DucOpfsImporterFinalization = (typeof FinalizationRegistry === 'undefined')
1166
+ ? { register: () => {}, unregister: () => {} }
1167
+ : new FinalizationRegistry(ptr => wasm.__wbg_ducopfsimporter_free(ptr, 1));
1168
+
1169
+ function addToExternrefTable0(obj) {
1170
+ const idx = wasm.__externref_table_alloc();
1171
+ wasm.__wbindgen_externrefs.set(idx, obj);
1172
+ return idx;
1173
+ }
1174
+
1175
+ const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')
1176
+ ? { register: () => {}, unregister: () => {} }
1177
+ : new FinalizationRegistry(state => wasm.__wbindgen_destroy_closure(state.a, state.b));
1178
+
1179
+ function debugString(val) {
1180
+ // primitive types
1181
+ const type = typeof val;
1182
+ if (type == 'number' || type == 'boolean' || val == null) {
1183
+ return `${val}`;
1184
+ }
1185
+ if (type == 'string') {
1186
+ return `"${val}"`;
1187
+ }
1188
+ if (type == 'symbol') {
1189
+ const description = val.description;
1190
+ if (description == null) {
1191
+ return 'Symbol';
1192
+ } else {
1193
+ return `Symbol(${description})`;
750
1194
  }
751
- return takeFromExternrefTable0(ret[0]);
752
1195
  }
753
- /**
754
- * @param {string} revision_id
755
- * @param {number} chunk_index
756
- * @param {number} offset_bytes
757
- * @param {Uint8Array} data
758
- */
759
- writeExternalFileRevisionChunk(revision_id, chunk_index, offset_bytes, data) {
760
- const ptr0 = passStringToWasm0(revision_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
761
- const len0 = WASM_VECTOR_LEN;
762
- const ptr1 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
763
- const len1 = WASM_VECTOR_LEN;
764
- const ret = wasm.ducopfsdocument_writeExternalFileRevisionChunk(this.__wbg_ptr, ptr0, len0, chunk_index, offset_bytes, ptr1, len1);
765
- if (ret[1]) {
766
- throw takeFromExternrefTable0(ret[0]);
1196
+ if (type == 'function') {
1197
+ const name = val.name;
1198
+ if (typeof name == 'string' && name.length > 0) {
1199
+ return `Function(${name})`;
1200
+ } else {
1201
+ return 'Function';
767
1202
  }
768
1203
  }
769
- /**
770
- * @param {string} revision_id
771
- */
772
- clearExternalFileRevisionChunks(revision_id) {
773
- const ptr0 = passStringToWasm0(revision_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
774
- const len0 = WASM_VECTOR_LEN;
775
- const ret = wasm.ducopfsdocument_clearExternalFileRevisionChunks(this.__wbg_ptr, ptr0, len0);
776
- if (ret[1]) {
777
- throw takeFromExternrefTable0(ret[0]);
1204
+ // objects
1205
+ if (Array.isArray(val)) {
1206
+ const length = val.length;
1207
+ let debug = '[';
1208
+ if (length > 0) {
1209
+ debug += debugString(val[0]);
1210
+ }
1211
+ for(let i = 1; i < length; i++) {
1212
+ debug += ', ' + debugString(val[i]);
1213
+ }
1214
+ debug += ']';
1215
+ return debug;
1216
+ }
1217
+ // Test for built-in
1218
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
1219
+ let className;
1220
+ if (builtInMatches && builtInMatches.length > 1) {
1221
+ className = builtInMatches[1];
1222
+ } else {
1223
+ // Failed to match the standard '[object ClassName]'
1224
+ return toString.call(val);
1225
+ }
1226
+ if (className == 'Object') {
1227
+ // we're a user defined class or Object
1228
+ // JSON.stringify avoids problems with cycles, and is generally much
1229
+ // easier than looping through ownProperties of `val`.
1230
+ try {
1231
+ return 'Object(' + JSON.stringify(val) + ')';
1232
+ } catch (_) {
1233
+ return 'Object';
778
1234
  }
779
1235
  }
1236
+ // errors
1237
+ if (val instanceof Error) {
1238
+ return `${val.name}: ${val.message}\n${val.stack}`;
1239
+ }
1240
+ // TODO we could test for more things here, like `Set`s and `Map`s.
1241
+ return className;
780
1242
  }
781
- if (Symbol.dispose) DucOpfsDocument.prototype[Symbol.dispose] = DucOpfsDocument.prototype.free;
782
1243
 
783
- const DucOpfsImporterFinalization = (typeof FinalizationRegistry === 'undefined')
784
- ? { register: () => {}, unregister: () => {} }
785
- : new FinalizationRegistry(ptr => wasm.__wbg_ducopfsimporter_free(ptr >>> 0, 1));
786
- /**
787
- * Incrementally replaces one OPFS database without retaining the imported
788
- * SQLite payload in WASM memory.
789
- */
790
- export class DucOpfsImporter {
1244
+ function getArrayU8FromWasm0(ptr, len) {
1245
+ ptr = ptr >>> 0;
1246
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
1247
+ }
791
1248
 
792
- static __wrap(ptr) {
793
- ptr = ptr >>> 0;
794
- const obj = Object.create(DucOpfsImporter.prototype);
795
- obj.__wbg_ptr = ptr;
796
- DucOpfsImporterFinalization.register(obj, obj.__wbg_ptr, obj);
797
- return obj;
1249
+ let cachedDataViewMemory0 = null;
1250
+ function getDataViewMemory0() {
1251
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
1252
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
798
1253
  }
1254
+ return cachedDataViewMemory0;
1255
+ }
799
1256
 
800
- __destroy_into_raw() {
801
- const ptr = this.__wbg_ptr;
802
- this.__wbg_ptr = 0;
803
- DucOpfsImporterFinalization.unregister(this);
804
- return ptr;
805
- }
1257
+ function getStringFromWasm0(ptr, len) {
1258
+ return decodeText(ptr >>> 0, len);
1259
+ }
806
1260
 
807
- free() {
808
- const ptr = this.__destroy_into_raw();
809
- wasm.__wbg_ducopfsimporter_free(ptr, 0);
810
- }
811
- /**
812
- * @param {string} name
813
- * @param {string} namespace
814
- * @returns {Promise<DucOpfsImporter>}
815
- */
816
- static beginInPool(name, namespace) {
817
- const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
818
- const len0 = WASM_VECTOR_LEN;
819
- const ptr1 = passStringToWasm0(namespace, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
820
- const len1 = WASM_VECTOR_LEN;
821
- const ret = wasm.ducopfsimporter_beginInPool(ptr0, len0, ptr1, len1);
822
- return ret;
1261
+ let cachedUint8ArrayMemory0 = null;
1262
+ function getUint8ArrayMemory0() {
1263
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
1264
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
823
1265
  }
824
- /**
825
- * Begin replacing `name`. Any prior database with the same closed name is
826
- * released back to the SAH pool before the new import claims a slot.
827
- * @param {string} name
828
- * @returns {Promise<DucOpfsImporter>}
829
- */
830
- static begin(name) {
831
- const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
832
- const len0 = WASM_VECTOR_LEN;
833
- const ret = wasm.ducopfsimporter_begin(ptr0, len0);
834
- return ret;
1266
+ return cachedUint8ArrayMemory0;
1267
+ }
1268
+
1269
+ function handleError(f, args) {
1270
+ try {
1271
+ return f.apply(this, args);
1272
+ } catch (e) {
1273
+ const idx = addToExternrefTable0(e);
1274
+ wasm.__wbindgen_exn_store(idx);
835
1275
  }
836
- /**
837
- * Write the next decompressed SQLite chunk.
838
- * @param {Uint8Array} data
839
- */
840
- writeChunk(data) {
841
- const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
842
- const len0 = WASM_VECTOR_LEN;
843
- const ret = wasm.ducopfsimporter_writeChunk(this.__wbg_ptr, ptr0, len0);
844
- if (ret[1]) {
845
- throw takeFromExternrefTable0(ret[0]);
1276
+ }
1277
+
1278
+ function isLikeNone(x) {
1279
+ return x === undefined || x === null;
1280
+ }
1281
+
1282
+ function makeMutClosure(arg0, arg1, f) {
1283
+ const state = { a: arg0, b: arg1, cnt: 1 };
1284
+ const real = (...args) => {
1285
+
1286
+ // First up with a closure we increment the internal reference
1287
+ // count. This ensures that the Rust closure environment won't
1288
+ // be deallocated while we're invoking it.
1289
+ state.cnt++;
1290
+ const a = state.a;
1291
+ state.a = 0;
1292
+ try {
1293
+ return f(a, state.b, ...args);
1294
+ } finally {
1295
+ state.a = a;
1296
+ real._wbg_cb_unref();
846
1297
  }
1298
+ };
1299
+ real._wbg_cb_unref = () => {
1300
+ if (--state.cnt === 0) {
1301
+ wasm.__wbindgen_destroy_closure(state.a, state.b);
1302
+ state.a = 0;
1303
+ CLOSURE_DTORS.unregister(state);
1304
+ }
1305
+ };
1306
+ CLOSURE_DTORS.register(real, state, state);
1307
+ return real;
1308
+ }
1309
+
1310
+ function passArray8ToWasm0(arg, malloc) {
1311
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
1312
+ getUint8ArrayMemory0().set(arg, ptr / 1);
1313
+ WASM_VECTOR_LEN = arg.length;
1314
+ return ptr;
1315
+ }
1316
+
1317
+ function passStringToWasm0(arg, malloc, realloc) {
1318
+ if (realloc === undefined) {
1319
+ const buf = cachedTextEncoder.encode(arg);
1320
+ const ptr = malloc(buf.length, 1) >>> 0;
1321
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
1322
+ WASM_VECTOR_LEN = buf.length;
1323
+ return ptr;
847
1324
  }
848
- /**
849
- * @returns {number}
850
- */
851
- getBytesWritten() {
852
- const ret = wasm.ducopfsimporter_getBytesWritten(this.__wbg_ptr);
853
- return ret;
1325
+
1326
+ let len = arg.length;
1327
+ let ptr = malloc(len, 1) >>> 0;
1328
+
1329
+ const mem = getUint8ArrayMemory0();
1330
+
1331
+ let offset = 0;
1332
+
1333
+ for (; offset < len; offset++) {
1334
+ const code = arg.charCodeAt(offset);
1335
+ if (code > 0x7F) break;
1336
+ mem[ptr + offset] = code;
854
1337
  }
855
- /**
856
- * Delete a partial import. Safe to call after a failed stream read.
857
- * @returns {boolean}
858
- */
859
- abort() {
860
- const ret = wasm.ducopfsimporter_abort(this.__wbg_ptr);
861
- if (ret[2]) {
862
- throw takeFromExternrefTable0(ret[1]);
1338
+ if (offset !== len) {
1339
+ if (offset !== 0) {
1340
+ arg = arg.slice(offset);
863
1341
  }
864
- return ret[0] !== 0;
1342
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
1343
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
1344
+ const ret = cachedTextEncoder.encodeInto(arg, view);
1345
+
1346
+ offset += ret.written;
1347
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
865
1348
  }
866
- /**
867
- * Flush the imported database and make it ready for SQLite to open.
868
- * @returns {number}
869
- */
870
- finish() {
871
- const ret = wasm.ducopfsimporter_finish(this.__wbg_ptr);
872
- if (ret[2]) {
873
- throw takeFromExternrefTable0(ret[1]);
874
- }
875
- return ret[0];
1349
+
1350
+ WASM_VECTOR_LEN = offset;
1351
+ return ptr;
1352
+ }
1353
+
1354
+ function takeFromExternrefTable0(idx) {
1355
+ const value = wasm.__wbindgen_externrefs.get(idx);
1356
+ wasm.__externref_table_dealloc(idx);
1357
+ return value;
1358
+ }
1359
+
1360
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
1361
+ cachedTextDecoder.decode();
1362
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
1363
+ let numBytesDecoded = 0;
1364
+ function decodeText(ptr, len) {
1365
+ numBytesDecoded += len;
1366
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
1367
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
1368
+ cachedTextDecoder.decode();
1369
+ numBytesDecoded = len;
876
1370
  }
1371
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
877
1372
  }
878
- if (Symbol.dispose) DucOpfsImporter.prototype[Symbol.dispose] = DucOpfsImporter.prototype.free;
879
1373
 
880
- const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
1374
+ const cachedTextEncoder = new TextEncoder();
1375
+
1376
+ if (!('encodeInto' in cachedTextEncoder)) {
1377
+ cachedTextEncoder.encodeInto = function (arg, view) {
1378
+ const buf = cachedTextEncoder.encode(arg);
1379
+ view.set(buf);
1380
+ return {
1381
+ read: arg.length,
1382
+ written: buf.length
1383
+ };
1384
+ };
1385
+ }
1386
+
1387
+ let WASM_VECTOR_LEN = 0;
1388
+
1389
+ let wasmModule, wasmInstance, wasm;
1390
+ function __wbg_finalize_init(instance, module) {
1391
+ wasmInstance = instance;
1392
+ wasm = instance.exports;
1393
+ wasmModule = module;
1394
+ cachedDataViewMemory0 = null;
1395
+ cachedUint8ArrayMemory0 = null;
1396
+ wasm.__wbindgen_start();
1397
+ return wasm;
1398
+ }
881
1399
 
882
1400
  async function __wbg_load(module, imports) {
883
1401
  if (typeof Response === 'function' && module instanceof Response) {
1402
+ if (!module.ok) {
1403
+ throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
1404
+ }
1405
+
884
1406
  if (typeof WebAssembly.instantiateStreaming === 'function') {
885
1407
  try {
886
1408
  return await WebAssembly.instantiateStreaming(module, imports);
887
-
888
1409
  } catch (e) {
889
- const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
1410
+ const validResponse = expectedResponseType(module.type);
890
1411
 
891
1412
  if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
892
1413
  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);
893
1414
 
894
- } else {
895
- throw e;
896
- }
1415
+ } else { throw e; }
897
1416
  }
898
1417
  }
899
1418
 
900
1419
  const bytes = await module.arrayBuffer();
901
1420
  return await WebAssembly.instantiate(bytes, imports);
902
-
903
1421
  } else {
904
1422
  const instance = await WebAssembly.instantiate(module, imports);
905
1423
 
906
1424
  if (instance instanceof WebAssembly.Instance) {
907
1425
  return { instance, module };
908
-
909
1426
  } else {
910
1427
  return instance;
911
1428
  }
912
1429
  }
913
- }
914
1430
 
915
- function __wbg_get_imports() {
916
- const imports = {};
917
- imports.wbg = {};
918
- imports.wbg.__wbg_Error_e17e777aac105295 = function(arg0, arg1) {
919
- const ret = Error(getStringFromWasm0(arg0, arg1));
920
- return ret;
921
- };
922
- imports.wbg.__wbg_Number_998bea33bd87c3e0 = function(arg0) {
923
- const ret = Number(arg0);
924
- return ret;
925
- };
926
- imports.wbg.__wbg_String_8f0eb39a4a4c2f66 = function(arg0, arg1) {
927
- const ret = String(arg1);
928
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
929
- const len1 = WASM_VECTOR_LEN;
930
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
931
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
932
- };
933
- imports.wbg.__wbg_buffer_8d40b1d762fb3c66 = function(arg0) {
934
- const ret = arg0.buffer;
935
- return ret;
936
- };
937
- imports.wbg.__wbg_byteLength_331a6b5545834024 = function(arg0) {
938
- const ret = arg0.byteLength;
939
- return ret;
940
- };
941
- imports.wbg.__wbg_byteOffset_49a5b5608000358b = function(arg0) {
942
- const ret = arg0.byteOffset;
943
- return ret;
944
- };
945
- imports.wbg.__wbg_call_13410aac570ffff7 = function() { return handleError(function (arg0, arg1) {
946
- const ret = arg0.call(arg1);
947
- return ret;
948
- }, arguments) };
949
- imports.wbg.__wbg_call_a5400b25a865cfd8 = function() { return handleError(function (arg0, arg1, arg2) {
950
- const ret = arg0.call(arg1, arg2);
951
- return ret;
952
- }, arguments) };
953
- imports.wbg.__wbg_createSyncAccessHandle_d06aab2e41a339b2 = function(arg0) {
954
- const ret = arg0.createSyncAccessHandle();
955
- return ret;
956
- };
957
- imports.wbg.__wbg_done_75ed0ee6dd243d9d = function(arg0) {
958
- const ret = arg0.done;
959
- return ret;
960
- };
961
- imports.wbg.__wbg_ducopfsdocument_new = function(arg0) {
962
- const ret = DucOpfsDocument.__wrap(arg0);
963
- return ret;
964
- };
965
- imports.wbg.__wbg_ducopfsimporter_new = function(arg0) {
966
- const ret = DucOpfsImporter.__wrap(arg0);
967
- return ret;
968
- };
969
- imports.wbg.__wbg_entries_1a3c3b9544532397 = function(arg0) {
970
- const ret = arg0.entries();
971
- return ret;
972
- };
973
- imports.wbg.__wbg_entries_2be2f15bd5554996 = function(arg0) {
974
- const ret = Object.entries(arg0);
975
- return ret;
976
- };
977
- imports.wbg.__wbg_fill_c8751cf67b766c70 = function(arg0, arg1, arg2, arg3) {
978
- const ret = arg0.fill(arg1, arg2 >>> 0, arg3 >>> 0);
979
- return ret;
980
- };
981
- imports.wbg.__wbg_flush_d2487a24f3bc3cf4 = function() { return handleError(function (arg0) {
982
- arg0.flush();
983
- }, arguments) };
984
- imports.wbg.__wbg_from_88bc52ce20ba6318 = function(arg0) {
985
- const ret = Array.from(arg0);
986
- return ret;
987
- };
988
- imports.wbg.__wbg_getDate_9615e288fc892247 = function(arg0) {
989
- const ret = arg0.getDate();
990
- return ret;
991
- };
992
- imports.wbg.__wbg_getDay_c9c4f57fb4ef6fef = function(arg0) {
993
- const ret = arg0.getDay();
994
- return ret;
995
- };
996
- imports.wbg.__wbg_getDirectoryHandle_0fb26677897f1e21 = function(arg0, arg1, arg2, arg3) {
997
- const ret = arg0.getDirectoryHandle(getStringFromWasm0(arg1, arg2), arg3);
998
- return ret;
999
- };
1000
- imports.wbg.__wbg_getDirectory_8564f4b4ae7ee35c = function(arg0) {
1001
- const ret = arg0.getDirectory();
1002
- return ret;
1003
- };
1004
- imports.wbg.__wbg_getFileHandle_9f23d09c2497fa5f = function(arg0, arg1, arg2, arg3) {
1005
- const ret = arg0.getFileHandle(getStringFromWasm0(arg1, arg2), arg3);
1006
- return ret;
1007
- };
1008
- imports.wbg.__wbg_getFullYear_e351a9fa7d2fab83 = function(arg0) {
1009
- const ret = arg0.getFullYear();
1010
- return ret;
1011
- };
1012
- imports.wbg.__wbg_getHours_4cc14de357c9e723 = function(arg0) {
1013
- const ret = arg0.getHours();
1014
- return ret;
1015
- };
1016
- imports.wbg.__wbg_getMinutes_6cde8fdd08b0c2ec = function(arg0) {
1017
- const ret = arg0.getMinutes();
1018
- return ret;
1019
- };
1020
- imports.wbg.__wbg_getMonth_8cc234bce5c8bcac = function(arg0) {
1021
- const ret = arg0.getMonth();
1022
- return ret;
1023
- };
1024
- imports.wbg.__wbg_getRandomValues_933a06e2370405af = function() { return handleError(function (arg0, arg1) {
1025
- globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
1026
- }, arguments) };
1027
- imports.wbg.__wbg_getSeconds_c2f02452d804ece0 = function(arg0) {
1028
- const ret = arg0.getSeconds();
1029
- return ret;
1030
- };
1031
- imports.wbg.__wbg_getSize_56a06761973a6cd7 = function() { return handleError(function (arg0) {
1032
- const ret = arg0.getSize();
1033
- return ret;
1034
- }, arguments) };
1035
- imports.wbg.__wbg_getTime_6bb3f64e0f18f817 = function(arg0) {
1036
- const ret = arg0.getTime();
1037
- return ret;
1038
- };
1039
- imports.wbg.__wbg_getTimezoneOffset_1e3ddc1382e7c8b0 = function(arg0) {
1040
- const ret = arg0.getTimezoneOffset();
1041
- return ret;
1042
- };
1043
- imports.wbg.__wbg_getUint32_2dc0ed17b0324774 = function(arg0, arg1) {
1044
- const ret = arg0.getUint32(arg1 >>> 0);
1045
- return ret;
1046
- };
1047
- imports.wbg.__wbg_get_0da715ceaecea5c8 = function(arg0, arg1) {
1048
- const ret = arg0[arg1 >>> 0];
1049
- return ret;
1050
- };
1051
- imports.wbg.__wbg_get_458e874b43b18b25 = function() { return handleError(function (arg0, arg1) {
1052
- const ret = Reflect.get(arg0, arg1);
1053
- return ret;
1054
- }, arguments) };
1055
- imports.wbg.__wbg_getindex_61bb13d19869849b = function(arg0, arg1) {
1056
- const ret = arg0[arg1 >>> 0];
1057
- return ret;
1058
- };
1059
- imports.wbg.__wbg_getwithrefkey_1dc361bd10053bfe = function(arg0, arg1) {
1060
- const ret = arg0[arg1];
1061
- return ret;
1062
- };
1063
- imports.wbg.__wbg_instanceof_ArrayBuffer_67f3012529f6a2dd = function(arg0) {
1064
- let result;
1065
- try {
1066
- result = arg0 instanceof ArrayBuffer;
1067
- } catch (_) {
1068
- result = false;
1069
- }
1070
- const ret = result;
1071
- return ret;
1072
- };
1073
- imports.wbg.__wbg_instanceof_Map_ebb01a5b6b5ffd0b = function(arg0) {
1074
- let result;
1075
- try {
1076
- result = arg0 instanceof Map;
1077
- } catch (_) {
1078
- result = false;
1079
- }
1080
- const ret = result;
1081
- return ret;
1082
- };
1083
- imports.wbg.__wbg_instanceof_Uint8Array_9a8378d955933db7 = function(arg0) {
1084
- let result;
1085
- try {
1086
- result = arg0 instanceof Uint8Array;
1087
- } catch (_) {
1088
- result = false;
1089
- }
1090
- const ret = result;
1091
- return ret;
1092
- };
1093
- imports.wbg.__wbg_instanceof_WorkerGlobalScope_85d487cc157fd065 = function(arg0) {
1094
- let result;
1095
- try {
1096
- result = arg0 instanceof WorkerGlobalScope;
1097
- } catch (_) {
1098
- result = false;
1099
- }
1100
- const ret = result;
1101
- return ret;
1102
- };
1103
- imports.wbg.__wbg_isArray_030cce220591fb41 = function(arg0) {
1104
- const ret = Array.isArray(arg0);
1105
- return ret;
1106
- };
1107
- imports.wbg.__wbg_isSafeInteger_1c0d1af5542e102a = function(arg0) {
1108
- const ret = Number.isSafeInteger(arg0);
1109
- return ret;
1110
- };
1111
- imports.wbg.__wbg_iterator_f370b34483c71a1c = function() {
1112
- const ret = Symbol.iterator;
1113
- return ret;
1114
- };
1115
- imports.wbg.__wbg_length_186546c51cd61acd = function(arg0) {
1116
- const ret = arg0.length;
1117
- return ret;
1118
- };
1119
- imports.wbg.__wbg_length_6bb7e81f9d7713e4 = function(arg0) {
1120
- const ret = arg0.length;
1121
- return ret;
1122
- };
1123
- imports.wbg.__wbg_navigator_bfaf1b0b0eb48da2 = function(arg0) {
1124
- const ret = arg0.navigator;
1125
- return ret;
1126
- };
1127
- imports.wbg.__wbg_new0_b0a0a38c201e6df5 = function() {
1128
- const ret = new Date();
1129
- return ret;
1130
- };
1131
- imports.wbg.__wbg_new_19c25a3f2fa63a02 = function() {
1132
- const ret = new Object();
1133
- return ret;
1134
- };
1135
- imports.wbg.__wbg_new_1f3a344cf3123716 = function() {
1136
- const ret = new Array();
1137
- return ret;
1138
- };
1139
- imports.wbg.__wbg_new_2e3c58a15f39f5f9 = function(arg0, arg1) {
1140
- try {
1141
- var state0 = {a: arg0, b: arg1};
1142
- var cb0 = (arg0, arg1) => {
1143
- const a = state0.a;
1144
- state0.a = 0;
1145
- try {
1146
- return __wbg_adapter_126(a, state0.b, arg0, arg1);
1147
- } finally {
1148
- state0.a = a;
1149
- }
1150
- };
1151
- const ret = new Promise(cb0);
1152
- return ret;
1153
- } finally {
1154
- state0.a = state0.b = 0;
1155
- }
1156
- };
1157
- imports.wbg.__wbg_new_2ff1f68f3676ea53 = function() {
1158
- const ret = new Map();
1159
- return ret;
1160
- };
1161
- imports.wbg.__wbg_new_5a2ae4557f92b50e = function(arg0) {
1162
- const ret = new Date(arg0);
1163
- return ret;
1164
- };
1165
- imports.wbg.__wbg_new_638ebfaedbf32a5e = function(arg0) {
1166
- const ret = new Uint8Array(arg0);
1167
- return ret;
1168
- };
1169
- imports.wbg.__wbg_new_f60d6f09990bdb99 = function(arg0, arg1, arg2) {
1170
- const ret = new DataView(arg0, arg1 >>> 0, arg2 >>> 0);
1171
- return ret;
1172
- };
1173
- imports.wbg.__wbg_newfromslice_074c56947bd43469 = function(arg0, arg1) {
1174
- const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
1175
- return ret;
1176
- };
1177
- imports.wbg.__wbg_newnoargs_254190557c45b4ec = function(arg0, arg1) {
1178
- const ret = new Function(getStringFromWasm0(arg0, arg1));
1179
- return ret;
1180
- };
1181
- imports.wbg.__wbg_newwithlength_a167dcc7aaa3ba77 = function(arg0) {
1182
- const ret = new Uint8Array(arg0 >>> 0);
1183
- return ret;
1184
- };
1185
- imports.wbg.__wbg_newwithlength_c2868113efe93526 = function(arg0) {
1186
- const ret = new Array(arg0 >>> 0);
1187
- return ret;
1188
- };
1189
- imports.wbg.__wbg_newwithyearmonthday_9d5466a369f2521d = function(arg0, arg1, arg2) {
1190
- const ret = new Date(arg0 >>> 0, arg1, arg2);
1191
- return ret;
1192
- };
1193
- imports.wbg.__wbg_next_1142e1658f75ec63 = function() { return handleError(function (arg0) {
1194
- const ret = arg0.next();
1195
- return ret;
1196
- }, arguments) };
1197
- imports.wbg.__wbg_next_5b3530e612fde77d = function(arg0) {
1198
- const ret = arg0.next;
1199
- return ret;
1200
- };
1201
- imports.wbg.__wbg_next_692e82279131b03c = function() { return handleError(function (arg0) {
1202
- const ret = arg0.next();
1203
- return ret;
1204
- }, arguments) };
1205
- imports.wbg.__wbg_prototypesetcall_3d4a26c1ed734349 = function(arg0, arg1, arg2) {
1206
- Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
1207
- };
1208
- imports.wbg.__wbg_queueMicrotask_25d0739ac89e8c88 = function(arg0) {
1209
- queueMicrotask(arg0);
1210
- };
1211
- imports.wbg.__wbg_queueMicrotask_4488407636f5bf24 = function(arg0) {
1212
- const ret = arg0.queueMicrotask;
1213
- return ret;
1214
- };
1215
- imports.wbg.__wbg_random_7ed63a0b38ee3b75 = function() {
1216
- const ret = Math.random();
1217
- return ret;
1218
- };
1219
- imports.wbg.__wbg_read_a43bb46027f02ee9 = function() { return handleError(function (arg0, arg1, arg2, arg3) {
1220
- const ret = arg0.read(getArrayU8FromWasm0(arg1, arg2), arg3);
1221
- return ret;
1222
- }, arguments) };
1223
- imports.wbg.__wbg_read_e271e94623077591 = function() { return handleError(function (arg0, arg1, arg2) {
1224
- const ret = arg0.read(arg1, arg2);
1225
- return ret;
1226
- }, arguments) };
1227
- imports.wbg.__wbg_resolve_4055c623acdd6a1b = function(arg0) {
1228
- const ret = Promise.resolve(arg0);
1229
- return ret;
1230
- };
1231
- imports.wbg.__wbg_setUint32_8a9564ae127df4c5 = function(arg0, arg1, arg2) {
1232
- arg0.setUint32(arg1 >>> 0, arg2 >>> 0);
1233
- };
1234
- imports.wbg.__wbg_set_1353b2a5e96bc48c = function(arg0, arg1, arg2) {
1235
- arg0.set(getArrayU8FromWasm0(arg1, arg2));
1236
- };
1237
- imports.wbg.__wbg_set_3f1d0b984ed272ed = function(arg0, arg1, arg2) {
1238
- arg0[arg1] = arg2;
1239
- };
1240
- imports.wbg.__wbg_set_453345bcda80b89a = function() { return handleError(function (arg0, arg1, arg2) {
1241
- const ret = Reflect.set(arg0, arg1, arg2);
1242
- return ret;
1243
- }, arguments) };
1244
- imports.wbg.__wbg_set_90f6c0f7bd8c0415 = function(arg0, arg1, arg2) {
1245
- arg0[arg1 >>> 0] = arg2;
1246
- };
1247
- imports.wbg.__wbg_set_b7f1cf4fae26fe2a = function(arg0, arg1, arg2) {
1248
- const ret = arg0.set(arg1, arg2);
1249
- return ret;
1250
- };
1251
- imports.wbg.__wbg_setat_f8fc70f546036b10 = function(arg0, arg1) {
1252
- arg0.at = arg1;
1253
- };
1254
- imports.wbg.__wbg_setcreate_1eb73f4ea713c1ad = function(arg0, arg1) {
1255
- arg0.create = arg1 !== 0;
1256
- };
1257
- imports.wbg.__wbg_setcreate_2d32aa4bbcd1d7af = function(arg0, arg1) {
1258
- arg0.create = arg1 !== 0;
1259
- };
1260
- imports.wbg.__wbg_static_accessor_GLOBAL_8921f820c2ce3f12 = function() {
1261
- const ret = typeof global === 'undefined' ? null : global;
1262
- return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
1263
- };
1264
- imports.wbg.__wbg_static_accessor_GLOBAL_THIS_f0a4409105898184 = function() {
1265
- const ret = typeof globalThis === 'undefined' ? null : globalThis;
1266
- return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
1267
- };
1268
- imports.wbg.__wbg_static_accessor_SELF_995b214ae681ff99 = function() {
1269
- const ret = typeof self === 'undefined' ? null : self;
1270
- return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
1271
- };
1272
- imports.wbg.__wbg_static_accessor_WINDOW_cde3890479c675ea = function() {
1273
- const ret = typeof window === 'undefined' ? null : window;
1274
- return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
1275
- };
1276
- imports.wbg.__wbg_storage_32b4ac688c114c3d = function(arg0) {
1277
- const ret = arg0.storage;
1278
- return ret;
1279
- };
1280
- imports.wbg.__wbg_subarray_70fd07feefe14294 = function(arg0, arg1, arg2) {
1281
- const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
1282
- return ret;
1283
- };
1284
- imports.wbg.__wbg_then_b33a773d723afa3e = function(arg0, arg1, arg2) {
1285
- const ret = arg0.then(arg1, arg2);
1286
- return ret;
1287
- };
1288
- imports.wbg.__wbg_then_e22500defe16819f = function(arg0, arg1) {
1289
- const ret = arg0.then(arg1);
1290
- return ret;
1291
- };
1292
- imports.wbg.__wbg_truncate_0fe935591188a14c = function() { return handleError(function (arg0, arg1) {
1293
- arg0.truncate(arg1 >>> 0);
1294
- }, arguments) };
1295
- imports.wbg.__wbg_truncate_7cddd971e3cf0a8c = function() { return handleError(function (arg0, arg1) {
1296
- arg0.truncate(arg1);
1297
- }, arguments) };
1298
- imports.wbg.__wbg_value_dd9372230531eade = function(arg0) {
1299
- const ret = arg0.value;
1300
- return ret;
1301
- };
1302
- imports.wbg.__wbg_wbindgenbigintgetasi64_ac743ece6ab9bba1 = function(arg0, arg1) {
1303
- const v = arg1;
1304
- const ret = typeof(v) === 'bigint' ? v : undefined;
1305
- getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
1306
- getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
1307
- };
1308
- imports.wbg.__wbg_wbindgenbooleanget_3fe6f642c7d97746 = function(arg0) {
1309
- const v = arg0;
1310
- const ret = typeof(v) === 'boolean' ? v : undefined;
1311
- return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
1312
- };
1313
- imports.wbg.__wbg_wbindgencbdrop_eb10308566512b88 = function(arg0) {
1314
- const obj = arg0.original;
1315
- if (obj.cnt-- == 1) {
1316
- obj.a = 0;
1317
- return true;
1431
+ function expectedResponseType(type) {
1432
+ switch (type) {
1433
+ case 'basic': case 'cors': case 'default': return true;
1318
1434
  }
1319
- const ret = false;
1320
- return ret;
1321
- };
1322
- imports.wbg.__wbg_wbindgendebugstring_99ef257a3ddda34d = function(arg0, arg1) {
1323
- const ret = debugString(arg1);
1324
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1325
- const len1 = WASM_VECTOR_LEN;
1326
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1327
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1328
- };
1329
- imports.wbg.__wbg_wbindgenin_d7a1ee10933d2d55 = function(arg0, arg1) {
1330
- const ret = arg0 in arg1;
1331
- return ret;
1332
- };
1333
- imports.wbg.__wbg_wbindgenisbigint_ecb90cc08a5a9154 = function(arg0) {
1334
- const ret = typeof(arg0) === 'bigint';
1335
- return ret;
1336
- };
1337
- imports.wbg.__wbg_wbindgenisfunction_8cee7dce3725ae74 = function(arg0) {
1338
- const ret = typeof(arg0) === 'function';
1339
- return ret;
1340
- };
1341
- imports.wbg.__wbg_wbindgenisobject_307a53c6bd97fbf8 = function(arg0) {
1342
- const val = arg0;
1343
- const ret = typeof(val) === 'object' && val !== null;
1344
- return ret;
1345
- };
1346
- imports.wbg.__wbg_wbindgenisstring_d4fa939789f003b0 = function(arg0) {
1347
- const ret = typeof(arg0) === 'string';
1348
- return ret;
1349
- };
1350
- imports.wbg.__wbg_wbindgenisundefined_c4b71d073b92f3c5 = function(arg0) {
1351
- const ret = arg0 === undefined;
1352
- return ret;
1353
- };
1354
- imports.wbg.__wbg_wbindgenjsvaleq_e6f2ad59ccae1b58 = function(arg0, arg1) {
1355
- const ret = arg0 === arg1;
1356
- return ret;
1357
- };
1358
- imports.wbg.__wbg_wbindgenjsvallooseeq_9bec8c9be826bed1 = function(arg0, arg1) {
1359
- const ret = arg0 == arg1;
1360
- return ret;
1361
- };
1362
- imports.wbg.__wbg_wbindgennumberget_f74b4c7525ac05cb = function(arg0, arg1) {
1363
- const obj = arg1;
1364
- const ret = typeof(obj) === 'number' ? obj : undefined;
1365
- getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
1366
- getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
1367
- };
1368
- imports.wbg.__wbg_wbindgenstringget_0f16a6ddddef376f = function(arg0, arg1) {
1369
- const obj = arg1;
1370
- const ret = typeof(obj) === 'string' ? obj : undefined;
1371
- var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1372
- var len1 = WASM_VECTOR_LEN;
1373
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1374
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1375
- };
1376
- imports.wbg.__wbg_wbindgenthrow_451ec1a8469d7eb6 = function(arg0, arg1) {
1377
- throw new Error(getStringFromWasm0(arg0, arg1));
1378
- };
1379
- imports.wbg.__wbg_write_9ac6a5f58a8c835c = function() { return handleError(function (arg0, arg1, arg2, arg3) {
1380
- const ret = arg0.write(getArrayU8FromWasm0(arg1, arg2), arg3);
1381
- return ret;
1382
- }, arguments) };
1383
- imports.wbg.__wbg_write_c0e234eeb0039d0d = function() { return handleError(function (arg0, arg1, arg2) {
1384
- const ret = arg0.write(arg1, arg2);
1385
- return ret;
1386
- }, arguments) };
1387
- imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
1388
- // Cast intrinsic for `Ref(String) -> Externref`.
1389
- const ret = getStringFromWasm0(arg0, arg1);
1390
- return ret;
1391
- };
1392
- imports.wbg.__wbindgen_cast_4625c577ab2ec9ee = function(arg0) {
1393
- // Cast intrinsic for `U64 -> Externref`.
1394
- const ret = BigInt.asUintN(64, arg0);
1395
- return ret;
1396
- };
1397
- imports.wbg.__wbindgen_cast_77bc3e92745e9a35 = function(arg0, arg1) {
1398
- var v0 = getArrayU8FromWasm0(arg0, arg1).slice();
1399
- wasm.__wbindgen_free(arg0, arg1 * 1, 1);
1400
- // Cast intrinsic for `Vector(U8) -> Externref`.
1401
- const ret = v0;
1402
- return ret;
1403
- };
1404
- imports.wbg.__wbindgen_cast_9ae0607507abb057 = function(arg0) {
1405
- // Cast intrinsic for `I64 -> Externref`.
1406
- const ret = arg0;
1407
- return ret;
1408
- };
1409
- imports.wbg.__wbindgen_cast_9f0223d8557fdf20 = function(arg0, arg1) {
1410
- // Cast intrinsic for `Closure(Closure { dtor_idx: 100, function: Function { arguments: [Externref], shim_idx: 101, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1411
- const ret = makeMutClosure(arg0, arg1, 100, __wbg_adapter_14);
1412
- return ret;
1413
- };
1414
- imports.wbg.__wbindgen_cast_cb9088102bce6b30 = function(arg0, arg1) {
1415
- // Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
1416
- const ret = getArrayU8FromWasm0(arg0, arg1);
1417
- return ret;
1418
- };
1419
- imports.wbg.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
1420
- // Cast intrinsic for `F64 -> Externref`.
1421
- const ret = arg0;
1422
- return ret;
1423
- };
1424
- imports.wbg.__wbindgen_init_externref_table = function() {
1425
- const table = wasm.__wbindgen_export_4;
1426
- const offset = table.grow(4);
1427
- table.set(0, undefined);
1428
- table.set(offset + 0, undefined);
1429
- table.set(offset + 1, null);
1430
- table.set(offset + 2, true);
1431
- table.set(offset + 3, false);
1432
- ;
1433
- };
1434
-
1435
- return imports;
1436
- }
1437
-
1438
- function __wbg_init_memory(imports, memory) {
1439
-
1440
- }
1441
-
1442
- function __wbg_finalize_init(instance, module) {
1443
- wasm = instance.exports;
1444
- __wbg_init.__wbindgen_wasm_module = module;
1445
- cachedDataViewMemory0 = null;
1446
- cachedUint8ArrayMemory0 = null;
1447
-
1448
-
1449
- wasm.__wbindgen_start();
1450
- return wasm;
1435
+ return false;
1436
+ }
1451
1437
  }
1452
1438
 
1453
1439
  function initSync(module) {
1454
1440
  if (wasm !== undefined) return wasm;
1455
1441
 
1456
1442
 
1457
- if (typeof module !== 'undefined') {
1443
+ if (module !== undefined) {
1458
1444
  if (Object.getPrototypeOf(module) === Object.prototype) {
1459
1445
  ({module} = module)
1460
1446
  } else {
@@ -1463,15 +1449,10 @@ function initSync(module) {
1463
1449
  }
1464
1450
 
1465
1451
  const imports = __wbg_get_imports();
1466
-
1467
- __wbg_init_memory(imports);
1468
-
1469
1452
  if (!(module instanceof WebAssembly.Module)) {
1470
1453
  module = new WebAssembly.Module(module);
1471
1454
  }
1472
-
1473
1455
  const instance = new WebAssembly.Instance(module, imports);
1474
-
1475
1456
  return __wbg_finalize_init(instance, module);
1476
1457
  }
1477
1458
 
@@ -1479,7 +1460,7 @@ async function __wbg_init(module_or_path) {
1479
1460
  if (wasm !== undefined) return wasm;
1480
1461
 
1481
1462
 
1482
- if (typeof module_or_path !== 'undefined') {
1463
+ if (module_or_path !== undefined) {
1483
1464
  if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
1484
1465
  ({module_or_path} = module_or_path)
1485
1466
  } else {
@@ -1487,7 +1468,7 @@ async function __wbg_init(module_or_path) {
1487
1468
  }
1488
1469
  }
1489
1470
 
1490
- if (typeof module_or_path === 'undefined') {
1471
+ if (module_or_path === undefined) {
1491
1472
  module_or_path = new URL('ducjs_wasm_bg.wasm', import.meta.url);
1492
1473
  }
1493
1474
  const imports = __wbg_get_imports();
@@ -1496,12 +1477,9 @@ async function __wbg_init(module_or_path) {
1496
1477
  module_or_path = fetch(module_or_path);
1497
1478
  }
1498
1479
 
1499
- __wbg_init_memory(imports);
1500
-
1501
1480
  const { instance, module } = await __wbg_load(await module_or_path, imports);
1502
1481
 
1503
1482
  return __wbg_finalize_init(instance, module);
1504
1483
  }
1505
1484
 
1506
- export { initSync };
1507
- export default __wbg_init;
1485
+ export { initSync, __wbg_init as default };