@moyodb/sdk 0.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/README.md +51 -0
  2. package/dist/assets/worker-CaOzbBz1.js +2351 -0
  3. package/dist/assets/worker-CaOzbBz1.js.map +1 -0
  4. package/dist/change-events.d.ts +29 -0
  5. package/dist/change-events.d.ts.map +1 -0
  6. package/dist/codec.d.ts +17 -0
  7. package/dist/codec.d.ts.map +1 -0
  8. package/dist/compression.d.ts +11 -0
  9. package/dist/compression.d.ts.map +1 -0
  10. package/dist/demo.d.ts +21 -0
  11. package/dist/demo.d.ts.map +1 -0
  12. package/dist/engine/README.md +56 -0
  13. package/dist/engine/moyodb_engine.d.ts +127 -0
  14. package/dist/engine/moyodb_engine.js +1193 -0
  15. package/dist/engine/moyodb_engine_bg.wasm +0 -0
  16. package/dist/engine/moyodb_engine_bg.wasm.d.ts +52 -0
  17. package/dist/engine/package.json +21 -0
  18. package/dist/engine/snippets/moyodb-engine-cff0a0e2441a7a8f/js/opfs_shim.js +402 -0
  19. package/dist/errors.d.ts +77 -0
  20. package/dist/errors.d.ts.map +1 -0
  21. package/dist/index.d.ts +9 -0
  22. package/dist/index.d.ts.map +1 -0
  23. package/dist/indexing.d.ts +33 -0
  24. package/dist/indexing.d.ts.map +1 -0
  25. package/dist/internal.d.ts +4 -0
  26. package/dist/internal.d.ts.map +1 -0
  27. package/dist/moyodb-sdk.js +1988 -0
  28. package/dist/moyodb-sdk.js.map +1 -0
  29. package/dist/moyodb-sdk.umd.cjs +2 -0
  30. package/dist/moyodb-sdk.umd.cjs.map +1 -0
  31. package/dist/registry.d.ts +33 -0
  32. package/dist/registry.d.ts.map +1 -0
  33. package/dist/subscriptions.d.ts +10 -0
  34. package/dist/subscriptions.d.ts.map +1 -0
  35. package/dist/types.d.ts +158 -0
  36. package/dist/types.d.ts.map +1 -0
  37. package/dist/worker-api.d.ts +51 -0
  38. package/dist/worker-api.d.ts.map +1 -0
  39. package/dist/worker-client.d.ts +67 -0
  40. package/dist/worker-client.d.ts.map +1 -0
  41. package/dist/worker-protocol.d.ts +86 -0
  42. package/dist/worker-protocol.d.ts.map +1 -0
  43. package/dist/worker-server.d.ts +6 -0
  44. package/dist/worker-server.d.ts.map +1 -0
  45. package/dist/worker.d.ts +2 -0
  46. package/dist/worker.d.ts.map +1 -0
  47. package/package.json +71 -0
@@ -0,0 +1,1193 @@
1
+ /* @ts-self-types="./moyodb_engine.d.ts" */
2
+ import { opfsCleanupInactiveEntries, opfsCloseSession, opfsDbDirectorySize, opfsFlush, opfsLen, opfsOpenActiveDb, opfsOpenGenerationDb, opfsPrepareRebuildTarget, opfsReadAt, opfsRemoveDb, opfsSwapActiveGeneration, opfsTruncate, opfsWriteAt } from './snippets/moyodb-engine-cff0a0e2441a7a8f/js/opfs_shim.js';
3
+
4
+
5
+ export class WasmEngine {
6
+ __destroy_into_raw() {
7
+ const ptr = this.__wbg_ptr;
8
+ this.__wbg_ptr = 0;
9
+ WasmEngineFinalization.unregister(this);
10
+ return ptr;
11
+ }
12
+ free() {
13
+ const ptr = this.__destroy_into_raw();
14
+ wasm.__wbg_wasmengine_free(ptr, 0);
15
+ }
16
+ /**
17
+ * @param {bigint} tx_id
18
+ * @param {string} store
19
+ * @param {any} ops
20
+ * @returns {any}
21
+ */
22
+ apply_batch(tx_id, store, ops) {
23
+ const ptr0 = passStringToWasm0(store, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
24
+ const len0 = WASM_VECTOR_LEN;
25
+ const ret = wasm.wasmengine_apply_batch(this.__wbg_ptr, tx_id, ptr0, len0, ops);
26
+ if (ret[2]) {
27
+ throw takeFromExternrefTable0(ret[1]);
28
+ }
29
+ return takeFromExternrefTable0(ret[0]);
30
+ }
31
+ /**
32
+ * @param {bigint} tx_id
33
+ * @param {string} store
34
+ * @param {Uint8Array} ops
35
+ * @returns {any}
36
+ */
37
+ apply_batch_packed(tx_id, store, ops) {
38
+ const ptr0 = passStringToWasm0(store, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
39
+ const len0 = WASM_VECTOR_LEN;
40
+ const ret = wasm.wasmengine_apply_batch_packed(this.__wbg_ptr, tx_id, ptr0, len0, ops);
41
+ if (ret[2]) {
42
+ throw takeFromExternrefTable0(ret[1]);
43
+ }
44
+ return takeFromExternrefTable0(ret[0]);
45
+ }
46
+ /**
47
+ * @param {string} mode
48
+ * @returns {bigint}
49
+ */
50
+ begin_tx(mode) {
51
+ const ptr0 = passStringToWasm0(mode, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
52
+ const len0 = WASM_VECTOR_LEN;
53
+ const ret = wasm.wasmengine_begin_tx(this.__wbg_ptr, ptr0, len0);
54
+ if (ret[2]) {
55
+ throw takeFromExternrefTable0(ret[1]);
56
+ }
57
+ return BigInt.asUintN(64, ret[0]);
58
+ }
59
+ /**
60
+ * @param {bigint} tx_id
61
+ * @param {any} options
62
+ * @returns {any}
63
+ */
64
+ changes_since(tx_id, options) {
65
+ const ret = wasm.wasmengine_changes_since(this.__wbg_ptr, tx_id, options);
66
+ if (ret[2]) {
67
+ throw takeFromExternrefTable0(ret[1]);
68
+ }
69
+ return takeFromExternrefTable0(ret[0]);
70
+ }
71
+ /**
72
+ * @param {bigint} tx_id
73
+ * @param {string} name
74
+ */
75
+ clear_store(tx_id, name) {
76
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
77
+ const len0 = WASM_VECTOR_LEN;
78
+ const ret = wasm.wasmengine_clear_store(this.__wbg_ptr, tx_id, ptr0, len0);
79
+ if (ret[1]) {
80
+ throw takeFromExternrefTable0(ret[0]);
81
+ }
82
+ }
83
+ close() {
84
+ const ret = wasm.wasmengine_close(this.__wbg_ptr);
85
+ if (ret[1]) {
86
+ throw takeFromExternrefTable0(ret[0]);
87
+ }
88
+ }
89
+ /**
90
+ * @param {bigint} tx_id
91
+ * @returns {bigint}
92
+ */
93
+ commit_tx(tx_id) {
94
+ const ret = wasm.wasmengine_commit_tx(this.__wbg_ptr, tx_id);
95
+ if (ret[2]) {
96
+ throw takeFromExternrefTable0(ret[1]);
97
+ }
98
+ return BigInt.asUintN(64, ret[0]);
99
+ }
100
+ /**
101
+ * @param {bigint} tx_id
102
+ * @param {string} name
103
+ * @param {any} options
104
+ */
105
+ create_store(tx_id, name, options) {
106
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
107
+ const len0 = WASM_VECTOR_LEN;
108
+ const ret = wasm.wasmengine_create_store(this.__wbg_ptr, tx_id, ptr0, len0, options);
109
+ if (ret[1]) {
110
+ throw takeFromExternrefTable0(ret[0]);
111
+ }
112
+ }
113
+ /**
114
+ * @param {bigint} tx_id
115
+ * @param {string} store
116
+ * @param {Uint8Array} key
117
+ * @returns {boolean}
118
+ */
119
+ delete(tx_id, store, key) {
120
+ const ptr0 = passStringToWasm0(store, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
121
+ const len0 = WASM_VECTOR_LEN;
122
+ const ptr1 = passArray8ToWasm0(key, wasm.__wbindgen_malloc);
123
+ const len1 = WASM_VECTOR_LEN;
124
+ const ret = wasm.wasmengine_delete(this.__wbg_ptr, tx_id, ptr0, len0, ptr1, len1);
125
+ if (ret[2]) {
126
+ throw takeFromExternrefTable0(ret[1]);
127
+ }
128
+ return ret[0] !== 0;
129
+ }
130
+ /**
131
+ * @param {bigint} tx_id
132
+ * @param {string} store
133
+ * @param {any} keys
134
+ * @returns {any}
135
+ */
136
+ delete_many(tx_id, store, keys) {
137
+ const ptr0 = passStringToWasm0(store, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
138
+ const len0 = WASM_VECTOR_LEN;
139
+ const ret = wasm.wasmengine_delete_many(this.__wbg_ptr, tx_id, ptr0, len0, keys);
140
+ if (ret[2]) {
141
+ throw takeFromExternrefTable0(ret[1]);
142
+ }
143
+ return takeFromExternrefTable0(ret[0]);
144
+ }
145
+ /**
146
+ * @param {bigint} tx_id
147
+ * @param {string} store
148
+ * @param {Uint8Array} keys
149
+ * @returns {any}
150
+ */
151
+ delete_many_packed(tx_id, store, keys) {
152
+ const ptr0 = passStringToWasm0(store, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
153
+ const len0 = WASM_VECTOR_LEN;
154
+ const ret = wasm.wasmengine_delete_many_packed(this.__wbg_ptr, tx_id, ptr0, len0, keys);
155
+ if (ret[2]) {
156
+ throw takeFromExternrefTable0(ret[1]);
157
+ }
158
+ return takeFromExternrefTable0(ret[0]);
159
+ }
160
+ /**
161
+ * @param {bigint} tx_id
162
+ * @param {string} name
163
+ */
164
+ drop_store(tx_id, name) {
165
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
166
+ const len0 = WASM_VECTOR_LEN;
167
+ const ret = wasm.wasmengine_drop_store(this.__wbg_ptr, tx_id, ptr0, len0);
168
+ if (ret[1]) {
169
+ throw takeFromExternrefTable0(ret[0]);
170
+ }
171
+ }
172
+ /**
173
+ * @returns {Uint8Array}
174
+ */
175
+ export_snapshot() {
176
+ const ret = wasm.wasmengine_export_snapshot(this.__wbg_ptr);
177
+ if (ret[2]) {
178
+ throw takeFromExternrefTable0(ret[1]);
179
+ }
180
+ return takeFromExternrefTable0(ret[0]);
181
+ }
182
+ /**
183
+ * @param {bigint} tx_id
184
+ * @param {string} store
185
+ * @param {Uint8Array} key
186
+ * @returns {any}
187
+ */
188
+ get(tx_id, store, key) {
189
+ const ptr0 = passStringToWasm0(store, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
190
+ const len0 = WASM_VECTOR_LEN;
191
+ const ptr1 = passArray8ToWasm0(key, wasm.__wbindgen_malloc);
192
+ const len1 = WASM_VECTOR_LEN;
193
+ const ret = wasm.wasmengine_get(this.__wbg_ptr, tx_id, ptr0, len0, ptr1, len1);
194
+ if (ret[2]) {
195
+ throw takeFromExternrefTable0(ret[1]);
196
+ }
197
+ return takeFromExternrefTable0(ret[0]);
198
+ }
199
+ /**
200
+ * @param {bigint} tx_id
201
+ * @param {string} store
202
+ * @param {any} keys
203
+ * @returns {any}
204
+ */
205
+ get_many(tx_id, store, keys) {
206
+ const ptr0 = passStringToWasm0(store, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
207
+ const len0 = WASM_VECTOR_LEN;
208
+ const ret = wasm.wasmengine_get_many(this.__wbg_ptr, tx_id, ptr0, len0, keys);
209
+ if (ret[2]) {
210
+ throw takeFromExternrefTable0(ret[1]);
211
+ }
212
+ return takeFromExternrefTable0(ret[0]);
213
+ }
214
+ /**
215
+ * @param {bigint} tx_id
216
+ * @param {string} store
217
+ * @param {Uint8Array} keys
218
+ * @returns {any}
219
+ */
220
+ get_many_packed(tx_id, store, keys) {
221
+ const ptr0 = passStringToWasm0(store, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
222
+ const len0 = WASM_VECTOR_LEN;
223
+ const ret = wasm.wasmengine_get_many_packed(this.__wbg_ptr, tx_id, ptr0, len0, keys);
224
+ if (ret[2]) {
225
+ throw takeFromExternrefTable0(ret[1]);
226
+ }
227
+ return takeFromExternrefTable0(ret[0]);
228
+ }
229
+ /**
230
+ * @returns {bigint}
231
+ */
232
+ get_schema_version() {
233
+ const ret = wasm.wasmengine_get_schema_version(this.__wbg_ptr);
234
+ if (ret[2]) {
235
+ throw takeFromExternrefTable0(ret[1]);
236
+ }
237
+ return BigInt.asUintN(64, ret[0]);
238
+ }
239
+ /**
240
+ * @param {bigint} tx_id
241
+ * @param {string} store
242
+ * @param {Uint8Array} key
243
+ * @returns {boolean}
244
+ */
245
+ has(tx_id, store, key) {
246
+ const ptr0 = passStringToWasm0(store, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
247
+ const len0 = WASM_VECTOR_LEN;
248
+ const ptr1 = passArray8ToWasm0(key, wasm.__wbindgen_malloc);
249
+ const len1 = WASM_VECTOR_LEN;
250
+ const ret = wasm.wasmengine_has(this.__wbg_ptr, tx_id, ptr0, len0, ptr1, len1);
251
+ if (ret[2]) {
252
+ throw takeFromExternrefTable0(ret[1]);
253
+ }
254
+ return ret[0] !== 0;
255
+ }
256
+ /**
257
+ * @param {Uint8Array} data
258
+ * @returns {bigint}
259
+ */
260
+ import_snapshot(data) {
261
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
262
+ const len0 = WASM_VECTOR_LEN;
263
+ const ret = wasm.wasmengine_import_snapshot(this.__wbg_ptr, ptr0, len0);
264
+ if (ret[2]) {
265
+ throw takeFromExternrefTable0(ret[1]);
266
+ }
267
+ return BigInt.asUintN(64, ret[0]);
268
+ }
269
+ /**
270
+ * @returns {any}
271
+ */
272
+ list_store_configs() {
273
+ const ret = wasm.wasmengine_list_store_configs(this.__wbg_ptr);
274
+ if (ret[2]) {
275
+ throw takeFromExternrefTable0(ret[1]);
276
+ }
277
+ return takeFromExternrefTable0(ret[0]);
278
+ }
279
+ /**
280
+ * @returns {any}
281
+ */
282
+ list_stores() {
283
+ const ret = wasm.wasmengine_list_stores(this.__wbg_ptr);
284
+ if (ret[2]) {
285
+ throw takeFromExternrefTable0(ret[1]);
286
+ }
287
+ return takeFromExternrefTable0(ret[0]);
288
+ }
289
+ constructor() {
290
+ const ret = wasm.wasmengine_new();
291
+ this.__wbg_ptr = ret;
292
+ WasmEngineFinalization.register(this, this.__wbg_ptr, this);
293
+ return this;
294
+ }
295
+ /**
296
+ * @param {string} name
297
+ * @param {any} options
298
+ * @returns {Promise<void>}
299
+ */
300
+ open(name, options) {
301
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
302
+ const len0 = WASM_VECTOR_LEN;
303
+ const ret = wasm.wasmengine_open(this.__wbg_ptr, ptr0, len0, options);
304
+ return ret;
305
+ }
306
+ /**
307
+ * @param {string} name
308
+ * @param {string} generation_name
309
+ * @param {any} options
310
+ * @returns {Promise<void>}
311
+ */
312
+ openGeneration(name, generation_name, options) {
313
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
314
+ const len0 = WASM_VECTOR_LEN;
315
+ const ptr1 = passStringToWasm0(generation_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
316
+ const len1 = WASM_VECTOR_LEN;
317
+ const ret = wasm.wasmengine_openGeneration(this.__wbg_ptr, ptr0, len0, ptr1, len1, options);
318
+ return ret;
319
+ }
320
+ /**
321
+ * @param {bigint} tx_id
322
+ * @param {string} store
323
+ * @param {Uint8Array} key
324
+ * @param {Uint8Array} value
325
+ * @param {any} options
326
+ */
327
+ put(tx_id, store, key, value, options) {
328
+ const ptr0 = passStringToWasm0(store, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
329
+ const len0 = WASM_VECTOR_LEN;
330
+ const ptr1 = passArray8ToWasm0(key, wasm.__wbindgen_malloc);
331
+ const len1 = WASM_VECTOR_LEN;
332
+ const ptr2 = passArray8ToWasm0(value, wasm.__wbindgen_malloc);
333
+ const len2 = WASM_VECTOR_LEN;
334
+ const ret = wasm.wasmengine_put(this.__wbg_ptr, tx_id, ptr0, len0, ptr1, len1, ptr2, len2, options);
335
+ if (ret[1]) {
336
+ throw takeFromExternrefTable0(ret[0]);
337
+ }
338
+ }
339
+ /**
340
+ * @param {bigint} tx_id
341
+ * @param {string} store
342
+ * @param {any} entries
343
+ * @param {any} options
344
+ * @returns {any}
345
+ */
346
+ put_many(tx_id, store, entries, options) {
347
+ const ptr0 = passStringToWasm0(store, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
348
+ const len0 = WASM_VECTOR_LEN;
349
+ const ret = wasm.wasmengine_put_many(this.__wbg_ptr, tx_id, ptr0, len0, entries, options);
350
+ if (ret[2]) {
351
+ throw takeFromExternrefTable0(ret[1]);
352
+ }
353
+ return takeFromExternrefTable0(ret[0]);
354
+ }
355
+ /**
356
+ * @param {bigint} tx_id
357
+ * @param {string} store
358
+ * @param {Uint8Array} entries
359
+ * @param {any} options
360
+ * @returns {any}
361
+ */
362
+ put_many_packed(tx_id, store, entries, options) {
363
+ const ptr0 = passStringToWasm0(store, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
364
+ const len0 = WASM_VECTOR_LEN;
365
+ const ret = wasm.wasmengine_put_many_packed(this.__wbg_ptr, tx_id, ptr0, len0, entries, options);
366
+ if (ret[2]) {
367
+ throw takeFromExternrefTable0(ret[1]);
368
+ }
369
+ return takeFromExternrefTable0(ret[0]);
370
+ }
371
+ /**
372
+ * @returns {bigint}
373
+ */
374
+ reset() {
375
+ const ret = wasm.wasmengine_reset(this.__wbg_ptr);
376
+ if (ret[2]) {
377
+ throw takeFromExternrefTable0(ret[1]);
378
+ }
379
+ return BigInt.asUintN(64, ret[0]);
380
+ }
381
+ /**
382
+ * @param {bigint} tx_id
383
+ */
384
+ rollback_tx(tx_id) {
385
+ const ret = wasm.wasmengine_rollback_tx(this.__wbg_ptr, tx_id);
386
+ if (ret[1]) {
387
+ throw takeFromExternrefTable0(ret[0]);
388
+ }
389
+ }
390
+ /**
391
+ * @param {bigint} tx_id
392
+ * @param {string} store
393
+ * @param {any} range
394
+ * @returns {any}
395
+ */
396
+ scan(tx_id, store, range) {
397
+ const ptr0 = passStringToWasm0(store, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
398
+ const len0 = WASM_VECTOR_LEN;
399
+ const ret = wasm.wasmengine_scan(this.__wbg_ptr, tx_id, ptr0, len0, range);
400
+ if (ret[2]) {
401
+ throw takeFromExternrefTable0(ret[1]);
402
+ }
403
+ return takeFromExternrefTable0(ret[0]);
404
+ }
405
+ /**
406
+ * @param {any} failpoint
407
+ */
408
+ set_failpoint(failpoint) {
409
+ const ret = wasm.wasmengine_set_failpoint(this.__wbg_ptr, failpoint);
410
+ if (ret[1]) {
411
+ throw takeFromExternrefTable0(ret[0]);
412
+ }
413
+ }
414
+ /**
415
+ * @param {bigint} tx_id
416
+ * @param {bigint} version
417
+ */
418
+ set_schema_version(tx_id, version) {
419
+ const ret = wasm.wasmengine_set_schema_version(this.__wbg_ptr, tx_id, version);
420
+ if (ret[1]) {
421
+ throw takeFromExternrefTable0(ret[0]);
422
+ }
423
+ }
424
+ /**
425
+ * @returns {any}
426
+ */
427
+ stats() {
428
+ const ret = wasm.wasmengine_stats(this.__wbg_ptr);
429
+ if (ret[2]) {
430
+ throw takeFromExternrefTable0(ret[1]);
431
+ }
432
+ return takeFromExternrefTable0(ret[0]);
433
+ }
434
+ }
435
+ if (Symbol.dispose) WasmEngine.prototype[Symbol.dispose] = WasmEngine.prototype.free;
436
+
437
+ /**
438
+ * @param {string} name
439
+ * @returns {Promise<void>}
440
+ */
441
+ export function cleanupInactiveEntries(name) {
442
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
443
+ const len0 = WASM_VECTOR_LEN;
444
+ const ret = wasm.cleanupInactiveEntries(ptr0, len0);
445
+ return ret;
446
+ }
447
+
448
+ /**
449
+ * @param {string} name
450
+ * @returns {Promise<number>}
451
+ */
452
+ export function dbDirectorySize(name) {
453
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
454
+ const len0 = WASM_VECTOR_LEN;
455
+ const ret = wasm.dbDirectorySize(ptr0, len0);
456
+ return ret;
457
+ }
458
+
459
+ /**
460
+ * @param {string} name
461
+ * @returns {Promise<void>}
462
+ */
463
+ export function deleteDB(name) {
464
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
465
+ const len0 = WASM_VECTOR_LEN;
466
+ const ret = wasm.deleteDB(ptr0, len0);
467
+ return ret;
468
+ }
469
+
470
+ /**
471
+ * @param {string} name
472
+ * @returns {Promise<any>}
473
+ */
474
+ export function prepareRebuildTarget(name) {
475
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
476
+ const len0 = WASM_VECTOR_LEN;
477
+ const ret = wasm.prepareRebuildTarget(ptr0, len0);
478
+ return ret;
479
+ }
480
+
481
+ /**
482
+ * @param {string} name
483
+ * @param {string} generation_name
484
+ * @returns {Promise<void>}
485
+ */
486
+ export function swapActiveGeneration(name, generation_name) {
487
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
488
+ const len0 = WASM_VECTOR_LEN;
489
+ const ptr1 = passStringToWasm0(generation_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
490
+ const len1 = WASM_VECTOR_LEN;
491
+ const ret = wasm.swapActiveGeneration(ptr0, len0, ptr1, len1);
492
+ return ret;
493
+ }
494
+ function __wbg_get_imports() {
495
+ const import0 = {
496
+ __proto__: null,
497
+ __wbg_Error_bce6d499ff0a4aff: function(arg0, arg1) {
498
+ const ret = Error(getStringFromWasm0(arg0, arg1));
499
+ return ret;
500
+ },
501
+ __wbg_Number_b7972a139bfbfdf0: function(arg0) {
502
+ const ret = Number(arg0);
503
+ return ret;
504
+ },
505
+ __wbg_String_8564e559799eccda: function(arg0, arg1) {
506
+ const ret = String(arg1);
507
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
508
+ const len1 = WASM_VECTOR_LEN;
509
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
510
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
511
+ },
512
+ __wbg___wbindgen_bigint_get_as_i64_410e28c7b761ad83: function(arg0, arg1) {
513
+ const v = arg1;
514
+ const ret = typeof(v) === 'bigint' ? v : undefined;
515
+ getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
516
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
517
+ },
518
+ __wbg___wbindgen_boolean_get_2304fb8c853028c8: function(arg0) {
519
+ const v = arg0;
520
+ const ret = typeof(v) === 'boolean' ? v : undefined;
521
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
522
+ },
523
+ __wbg___wbindgen_debug_string_edece8177ad01481: function(arg0, arg1) {
524
+ const ret = debugString(arg1);
525
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
526
+ const len1 = WASM_VECTOR_LEN;
527
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
528
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
529
+ },
530
+ __wbg___wbindgen_in_07056af4f902c445: function(arg0, arg1) {
531
+ const ret = arg0 in arg1;
532
+ return ret;
533
+ },
534
+ __wbg___wbindgen_is_bigint_aeae3893f30ed54e: function(arg0) {
535
+ const ret = typeof(arg0) === 'bigint';
536
+ return ret;
537
+ },
538
+ __wbg___wbindgen_is_function_5cd60d5cf78b4eef: function(arg0) {
539
+ const ret = typeof(arg0) === 'function';
540
+ return ret;
541
+ },
542
+ __wbg___wbindgen_is_null_2042690d351e14f0: function(arg0) {
543
+ const ret = arg0 === null;
544
+ return ret;
545
+ },
546
+ __wbg___wbindgen_is_object_b4593df85baada48: function(arg0) {
547
+ const val = arg0;
548
+ const ret = typeof(val) === 'object' && val !== null;
549
+ return ret;
550
+ },
551
+ __wbg___wbindgen_is_undefined_35bb9f4c7fd651d5: function(arg0) {
552
+ const ret = arg0 === undefined;
553
+ return ret;
554
+ },
555
+ __wbg___wbindgen_jsval_eq_c0ed08b3e0f393b9: function(arg0, arg1) {
556
+ const ret = arg0 === arg1;
557
+ return ret;
558
+ },
559
+ __wbg___wbindgen_jsval_loose_eq_0ad77b7717db155c: function(arg0, arg1) {
560
+ const ret = arg0 == arg1;
561
+ return ret;
562
+ },
563
+ __wbg___wbindgen_number_get_f73a1244370fcc2c: function(arg0, arg1) {
564
+ const obj = arg1;
565
+ const ret = typeof(obj) === 'number' ? obj : undefined;
566
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
567
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
568
+ },
569
+ __wbg___wbindgen_string_get_d109740c0d18f4d7: function(arg0, arg1) {
570
+ const obj = arg1;
571
+ const ret = typeof(obj) === 'string' ? obj : undefined;
572
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
573
+ var len1 = WASM_VECTOR_LEN;
574
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
575
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
576
+ },
577
+ __wbg___wbindgen_throw_9c31b086c2b26051: function(arg0, arg1) {
578
+ throw new Error(getStringFromWasm0(arg0, arg1));
579
+ },
580
+ __wbg__wbg_cb_unref_3fa391f3fcdb55f8: function(arg0) {
581
+ arg0._wbg_cb_unref();
582
+ },
583
+ __wbg_call_13665d9f14390edc: function() { return handleError(function (arg0, arg1) {
584
+ const ret = arg0.call(arg1);
585
+ return ret;
586
+ }, arguments); },
587
+ __wbg_call_dfde26266607c996: function() { return handleError(function (arg0, arg1, arg2) {
588
+ const ret = arg0.call(arg1, arg2);
589
+ return ret;
590
+ }, arguments); },
591
+ __wbg_done_54b8da57023b7ed2: function(arg0) {
592
+ const ret = arg0.done;
593
+ return ret;
594
+ },
595
+ __wbg_entries_564a7e8b1e54ede5: function(arg0) {
596
+ const ret = Object.entries(arg0);
597
+ return ret;
598
+ },
599
+ __wbg_from_fa561fa561dc8031: function(arg0) {
600
+ const ret = Array.from(arg0);
601
+ return ret;
602
+ },
603
+ __wbg_get_3e9a707ab7d352eb: function() { return handleError(function (arg0, arg1) {
604
+ const ret = Reflect.get(arg0, arg1);
605
+ return ret;
606
+ }, arguments); },
607
+ __wbg_get_98fdf51d029a75eb: function(arg0, arg1) {
608
+ const ret = arg0[arg1 >>> 0];
609
+ return ret;
610
+ },
611
+ __wbg_get_unchecked_1dfe6d05ad91d9b7: function(arg0, arg1) {
612
+ const ret = arg0[arg1 >>> 0];
613
+ return ret;
614
+ },
615
+ __wbg_get_with_ref_key_6412cf3094599694: function(arg0, arg1) {
616
+ const ret = arg0[arg1];
617
+ return ret;
618
+ },
619
+ __wbg_instanceof_ArrayBuffer_53db37b06f6b9afe: function(arg0) {
620
+ let result;
621
+ try {
622
+ result = arg0 instanceof ArrayBuffer;
623
+ } catch (_) {
624
+ result = false;
625
+ }
626
+ const ret = result;
627
+ return ret;
628
+ },
629
+ __wbg_instanceof_Map_16f217b9a2a08d8c: function(arg0) {
630
+ let result;
631
+ try {
632
+ result = arg0 instanceof Map;
633
+ } catch (_) {
634
+ result = false;
635
+ }
636
+ const ret = result;
637
+ return ret;
638
+ },
639
+ __wbg_instanceof_Uint8Array_abd07d4bd221d50b: function(arg0) {
640
+ let result;
641
+ try {
642
+ result = arg0 instanceof Uint8Array;
643
+ } catch (_) {
644
+ result = false;
645
+ }
646
+ const ret = result;
647
+ return ret;
648
+ },
649
+ __wbg_isArray_94898ed3aad6947b: function(arg0) {
650
+ const ret = Array.isArray(arg0);
651
+ return ret;
652
+ },
653
+ __wbg_isSafeInteger_01e964d144ad3a55: function(arg0) {
654
+ const ret = Number.isSafeInteger(arg0);
655
+ return ret;
656
+ },
657
+ __wbg_iterator_1441b47f341dc34f: function() {
658
+ const ret = Symbol.iterator;
659
+ return ret;
660
+ },
661
+ __wbg_length_2591a0f4f659a55c: function(arg0) {
662
+ const ret = arg0.length;
663
+ return ret;
664
+ },
665
+ __wbg_length_56fcd3e2b7e0299d: function(arg0) {
666
+ const ret = arg0.length;
667
+ return ret;
668
+ },
669
+ __wbg_new_02d162bc6cf02f60: function() {
670
+ const ret = new Object();
671
+ return ret;
672
+ },
673
+ __wbg_new_310879b66b6e95e1: function() {
674
+ const ret = new Array();
675
+ return ret;
676
+ },
677
+ __wbg_new_7ddec6de44ff8f5d: function(arg0) {
678
+ const ret = new Uint8Array(arg0);
679
+ return ret;
680
+ },
681
+ __wbg_new_from_slice_269e35316ed2d061: function(arg0, arg1) {
682
+ const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
683
+ return ret;
684
+ },
685
+ __wbg_new_typed_c072c4ce9a2a0cdf: function(arg0, arg1) {
686
+ try {
687
+ var state0 = {a: arg0, b: arg1};
688
+ var cb0 = (arg0, arg1) => {
689
+ const a = state0.a;
690
+ state0.a = 0;
691
+ try {
692
+ return wasm_bindgen__convert__closures_____invoke__h694ddb4a279886ac(a, state0.b, arg0, arg1);
693
+ } finally {
694
+ state0.a = a;
695
+ }
696
+ };
697
+ const ret = new Promise(cb0);
698
+ return ret;
699
+ } finally {
700
+ state0.a = 0;
701
+ }
702
+ },
703
+ __wbg_new_with_length_c2a8f9ac6aaaac03: function(arg0) {
704
+ const ret = new Array(arg0 >>> 0);
705
+ return ret;
706
+ },
707
+ __wbg_next_2a4e19f4f5083b0f: function(arg0) {
708
+ const ret = arg0.next;
709
+ return ret;
710
+ },
711
+ __wbg_next_6429a146bf756f93: function() { return handleError(function (arg0) {
712
+ const ret = arg0.next();
713
+ return ret;
714
+ }, arguments); },
715
+ __wbg_now_81363d44c96dd239: function() {
716
+ const ret = Date.now();
717
+ return ret;
718
+ },
719
+ __wbg_opfsCleanupInactiveEntries_9e173f8d6f154f39: function() { return handleError(function (arg0, arg1) {
720
+ const ret = opfsCleanupInactiveEntries(getStringFromWasm0(arg0, arg1));
721
+ return ret;
722
+ }, arguments); },
723
+ __wbg_opfsCloseSession_e2f051367bb99a5f: function(arg0) {
724
+ opfsCloseSession(arg0 >>> 0);
725
+ },
726
+ __wbg_opfsDbDirectorySize_529235b87778114e: function() { return handleError(function (arg0, arg1) {
727
+ const ret = opfsDbDirectorySize(getStringFromWasm0(arg0, arg1));
728
+ return ret;
729
+ }, arguments); },
730
+ __wbg_opfsFlush_d93e12f965d26393: function(arg0, arg1) {
731
+ opfsFlush(arg0 >>> 0, arg1 >>> 0);
732
+ },
733
+ __wbg_opfsLen_23d9b41c3ac8e741: function(arg0, arg1) {
734
+ const ret = opfsLen(arg0 >>> 0, arg1 >>> 0);
735
+ return ret;
736
+ },
737
+ __wbg_opfsOpenActiveDb_06c7ddc023785bf1: function() { return handleError(function (arg0, arg1, arg2) {
738
+ const ret = opfsOpenActiveDb(getStringFromWasm0(arg0, arg1), arg2 !== 0);
739
+ return ret;
740
+ }, arguments); },
741
+ __wbg_opfsOpenGenerationDb_001e4f1cec337f78: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
742
+ const ret = opfsOpenGenerationDb(getStringFromWasm0(arg0, arg1), getStringFromWasm0(arg2, arg3), arg4 !== 0);
743
+ return ret;
744
+ }, arguments); },
745
+ __wbg_opfsPrepareRebuildTarget_5f8e71fdf689398e: function() { return handleError(function (arg0, arg1) {
746
+ const ret = opfsPrepareRebuildTarget(getStringFromWasm0(arg0, arg1));
747
+ return ret;
748
+ }, arguments); },
749
+ __wbg_opfsReadAt_13df9f212f667746: function(arg0, arg1, arg2, arg3) {
750
+ const ret = opfsReadAt(arg0 >>> 0, arg1 >>> 0, BigInt.asUintN(64, arg2), arg3 >>> 0);
751
+ return ret;
752
+ },
753
+ __wbg_opfsRemoveDb_6c94f6709a115f7b: function() { return handleError(function (arg0, arg1) {
754
+ const ret = opfsRemoveDb(getStringFromWasm0(arg0, arg1));
755
+ return ret;
756
+ }, arguments); },
757
+ __wbg_opfsSwapActiveGeneration_1501d9d23ce6df41: function() { return handleError(function (arg0, arg1, arg2, arg3) {
758
+ const ret = opfsSwapActiveGeneration(getStringFromWasm0(arg0, arg1), getStringFromWasm0(arg2, arg3));
759
+ return ret;
760
+ }, arguments); },
761
+ __wbg_opfsTruncate_b6a2621ef30eb8e9: function(arg0, arg1, arg2) {
762
+ opfsTruncate(arg0 >>> 0, arg1 >>> 0, BigInt.asUintN(64, arg2));
763
+ },
764
+ __wbg_opfsWriteAt_4fd251d80cc08fb9: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
765
+ const ret = opfsWriteAt(arg0 >>> 0, arg1 >>> 0, BigInt.asUintN(64, arg2), getArrayU8FromWasm0(arg3, arg4));
766
+ return ret;
767
+ }, arguments); },
768
+ __wbg_prototypesetcall_5f9bdc8d75e07276: function(arg0, arg1, arg2) {
769
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
770
+ },
771
+ __wbg_queueMicrotask_78d584b53af520f5: function(arg0) {
772
+ const ret = arg0.queueMicrotask;
773
+ return ret;
774
+ },
775
+ __wbg_queueMicrotask_b39ea83c7f01971a: function(arg0) {
776
+ queueMicrotask(arg0);
777
+ },
778
+ __wbg_resolve_d17db9352f5a220e: function(arg0) {
779
+ const ret = Promise.resolve(arg0);
780
+ return ret;
781
+ },
782
+ __wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
783
+ arg0[arg1] = arg2;
784
+ },
785
+ __wbg_set_78ea6a19f4818587: function(arg0, arg1, arg2) {
786
+ arg0[arg1 >>> 0] = arg2;
787
+ },
788
+ __wbg_set_a0e911be3da02782: function() { return handleError(function (arg0, arg1, arg2) {
789
+ const ret = Reflect.set(arg0, arg1, arg2);
790
+ return ret;
791
+ }, arguments); },
792
+ __wbg_static_accessor_GLOBAL_THIS_02344c9b09eb08a9: function() {
793
+ const ret = typeof globalThis === 'undefined' ? null : globalThis;
794
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
795
+ },
796
+ __wbg_static_accessor_GLOBAL_ac6d4ac874d5cd54: function() {
797
+ const ret = typeof global === 'undefined' ? null : global;
798
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
799
+ },
800
+ __wbg_static_accessor_SELF_9b2406c23aeb2023: function() {
801
+ const ret = typeof self === 'undefined' ? null : self;
802
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
803
+ },
804
+ __wbg_static_accessor_WINDOW_b34d2126934e16ba: function() {
805
+ const ret = typeof window === 'undefined' ? null : window;
806
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
807
+ },
808
+ __wbg_then_837494e384b37459: function(arg0, arg1) {
809
+ const ret = arg0.then(arg1);
810
+ return ret;
811
+ },
812
+ __wbg_then_bd927500e8905df2: function(arg0, arg1, arg2) {
813
+ const ret = arg0.then(arg1, arg2);
814
+ return ret;
815
+ },
816
+ __wbg_value_9cc0518af87a489c: function(arg0) {
817
+ const ret = arg0.value;
818
+ return ret;
819
+ },
820
+ __wbindgen_cast_0000000000000001: function(arg0, arg1) {
821
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 114, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
822
+ const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h0b808fc55658bd50);
823
+ return ret;
824
+ },
825
+ __wbindgen_cast_0000000000000002: function(arg0) {
826
+ // Cast intrinsic for `F64 -> Externref`.
827
+ const ret = arg0;
828
+ return ret;
829
+ },
830
+ __wbindgen_cast_0000000000000003: function(arg0) {
831
+ // Cast intrinsic for `I64 -> Externref`.
832
+ const ret = arg0;
833
+ return ret;
834
+ },
835
+ __wbindgen_cast_0000000000000004: function(arg0, arg1) {
836
+ // Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
837
+ const ret = getArrayU8FromWasm0(arg0, arg1);
838
+ return ret;
839
+ },
840
+ __wbindgen_cast_0000000000000005: function(arg0, arg1) {
841
+ // Cast intrinsic for `Ref(String) -> Externref`.
842
+ const ret = getStringFromWasm0(arg0, arg1);
843
+ return ret;
844
+ },
845
+ __wbindgen_cast_0000000000000006: function(arg0) {
846
+ // Cast intrinsic for `U64 -> Externref`.
847
+ const ret = BigInt.asUintN(64, arg0);
848
+ return ret;
849
+ },
850
+ __wbindgen_init_externref_table: function() {
851
+ const table = wasm.__wbindgen_externrefs;
852
+ const offset = table.grow(4);
853
+ table.set(0, undefined);
854
+ table.set(offset + 0, undefined);
855
+ table.set(offset + 1, null);
856
+ table.set(offset + 2, true);
857
+ table.set(offset + 3, false);
858
+ },
859
+ };
860
+ return {
861
+ __proto__: null,
862
+ "./moyodb_engine_bg.js": import0,
863
+ };
864
+ }
865
+
866
+ function wasm_bindgen__convert__closures_____invoke__h0b808fc55658bd50(arg0, arg1, arg2) {
867
+ const ret = wasm.wasm_bindgen__convert__closures_____invoke__h0b808fc55658bd50(arg0, arg1, arg2);
868
+ if (ret[1]) {
869
+ throw takeFromExternrefTable0(ret[0]);
870
+ }
871
+ }
872
+
873
+ function wasm_bindgen__convert__closures_____invoke__h694ddb4a279886ac(arg0, arg1, arg2, arg3) {
874
+ wasm.wasm_bindgen__convert__closures_____invoke__h694ddb4a279886ac(arg0, arg1, arg2, arg3);
875
+ }
876
+
877
+ const WasmEngineFinalization = (typeof FinalizationRegistry === 'undefined')
878
+ ? { register: () => {}, unregister: () => {} }
879
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmengine_free(ptr, 1));
880
+
881
+ function addToExternrefTable0(obj) {
882
+ const idx = wasm.__externref_table_alloc();
883
+ wasm.__wbindgen_externrefs.set(idx, obj);
884
+ return idx;
885
+ }
886
+
887
+ const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')
888
+ ? { register: () => {}, unregister: () => {} }
889
+ : new FinalizationRegistry(state => wasm.__wbindgen_destroy_closure(state.a, state.b));
890
+
891
+ function debugString(val) {
892
+ // primitive types
893
+ const type = typeof val;
894
+ if (type == 'number' || type == 'boolean' || val == null) {
895
+ return `${val}`;
896
+ }
897
+ if (type == 'string') {
898
+ return `"${val}"`;
899
+ }
900
+ if (type == 'symbol') {
901
+ const description = val.description;
902
+ if (description == null) {
903
+ return 'Symbol';
904
+ } else {
905
+ return `Symbol(${description})`;
906
+ }
907
+ }
908
+ if (type == 'function') {
909
+ const name = val.name;
910
+ if (typeof name == 'string' && name.length > 0) {
911
+ return `Function(${name})`;
912
+ } else {
913
+ return 'Function';
914
+ }
915
+ }
916
+ // objects
917
+ if (Array.isArray(val)) {
918
+ const length = val.length;
919
+ let debug = '[';
920
+ if (length > 0) {
921
+ debug += debugString(val[0]);
922
+ }
923
+ for(let i = 1; i < length; i++) {
924
+ debug += ', ' + debugString(val[i]);
925
+ }
926
+ debug += ']';
927
+ return debug;
928
+ }
929
+ // Test for built-in
930
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
931
+ let className;
932
+ if (builtInMatches && builtInMatches.length > 1) {
933
+ className = builtInMatches[1];
934
+ } else {
935
+ // Failed to match the standard '[object ClassName]'
936
+ return toString.call(val);
937
+ }
938
+ if (className == 'Object') {
939
+ // we're a user defined class or Object
940
+ // JSON.stringify avoids problems with cycles, and is generally much
941
+ // easier than looping through ownProperties of `val`.
942
+ try {
943
+ return 'Object(' + JSON.stringify(val) + ')';
944
+ } catch (_) {
945
+ return 'Object';
946
+ }
947
+ }
948
+ // errors
949
+ if (val instanceof Error) {
950
+ return `${val.name}: ${val.message}\n${val.stack}`;
951
+ }
952
+ // TODO we could test for more things here, like `Set`s and `Map`s.
953
+ return className;
954
+ }
955
+
956
+ function getArrayU8FromWasm0(ptr, len) {
957
+ ptr = ptr >>> 0;
958
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
959
+ }
960
+
961
+ let cachedDataViewMemory0 = null;
962
+ function getDataViewMemory0() {
963
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
964
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
965
+ }
966
+ return cachedDataViewMemory0;
967
+ }
968
+
969
+ function getStringFromWasm0(ptr, len) {
970
+ return decodeText(ptr >>> 0, len);
971
+ }
972
+
973
+ let cachedUint8ArrayMemory0 = null;
974
+ function getUint8ArrayMemory0() {
975
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
976
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
977
+ }
978
+ return cachedUint8ArrayMemory0;
979
+ }
980
+
981
+ function handleError(f, args) {
982
+ try {
983
+ return f.apply(this, args);
984
+ } catch (e) {
985
+ const idx = addToExternrefTable0(e);
986
+ wasm.__wbindgen_exn_store(idx);
987
+ }
988
+ }
989
+
990
+ function isLikeNone(x) {
991
+ return x === undefined || x === null;
992
+ }
993
+
994
+ function makeMutClosure(arg0, arg1, f) {
995
+ const state = { a: arg0, b: arg1, cnt: 1 };
996
+ const real = (...args) => {
997
+
998
+ // First up with a closure we increment the internal reference
999
+ // count. This ensures that the Rust closure environment won't
1000
+ // be deallocated while we're invoking it.
1001
+ state.cnt++;
1002
+ const a = state.a;
1003
+ state.a = 0;
1004
+ try {
1005
+ return f(a, state.b, ...args);
1006
+ } finally {
1007
+ state.a = a;
1008
+ real._wbg_cb_unref();
1009
+ }
1010
+ };
1011
+ real._wbg_cb_unref = () => {
1012
+ if (--state.cnt === 0) {
1013
+ wasm.__wbindgen_destroy_closure(state.a, state.b);
1014
+ state.a = 0;
1015
+ CLOSURE_DTORS.unregister(state);
1016
+ }
1017
+ };
1018
+ CLOSURE_DTORS.register(real, state, state);
1019
+ return real;
1020
+ }
1021
+
1022
+ function passArray8ToWasm0(arg, malloc) {
1023
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
1024
+ getUint8ArrayMemory0().set(arg, ptr / 1);
1025
+ WASM_VECTOR_LEN = arg.length;
1026
+ return ptr;
1027
+ }
1028
+
1029
+ function passStringToWasm0(arg, malloc, realloc) {
1030
+ if (realloc === undefined) {
1031
+ const buf = cachedTextEncoder.encode(arg);
1032
+ const ptr = malloc(buf.length, 1) >>> 0;
1033
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
1034
+ WASM_VECTOR_LEN = buf.length;
1035
+ return ptr;
1036
+ }
1037
+
1038
+ let len = arg.length;
1039
+ let ptr = malloc(len, 1) >>> 0;
1040
+
1041
+ const mem = getUint8ArrayMemory0();
1042
+
1043
+ let offset = 0;
1044
+
1045
+ for (; offset < len; offset++) {
1046
+ const code = arg.charCodeAt(offset);
1047
+ if (code > 0x7F) break;
1048
+ mem[ptr + offset] = code;
1049
+ }
1050
+ if (offset !== len) {
1051
+ if (offset !== 0) {
1052
+ arg = arg.slice(offset);
1053
+ }
1054
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
1055
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
1056
+ const ret = cachedTextEncoder.encodeInto(arg, view);
1057
+
1058
+ offset += ret.written;
1059
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
1060
+ }
1061
+
1062
+ WASM_VECTOR_LEN = offset;
1063
+ return ptr;
1064
+ }
1065
+
1066
+ function takeFromExternrefTable0(idx) {
1067
+ const value = wasm.__wbindgen_externrefs.get(idx);
1068
+ wasm.__externref_table_dealloc(idx);
1069
+ return value;
1070
+ }
1071
+
1072
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
1073
+ cachedTextDecoder.decode();
1074
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
1075
+ let numBytesDecoded = 0;
1076
+ function decodeText(ptr, len) {
1077
+ numBytesDecoded += len;
1078
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
1079
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
1080
+ cachedTextDecoder.decode();
1081
+ numBytesDecoded = len;
1082
+ }
1083
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
1084
+ }
1085
+
1086
+ const cachedTextEncoder = new TextEncoder();
1087
+
1088
+ if (!('encodeInto' in cachedTextEncoder)) {
1089
+ cachedTextEncoder.encodeInto = function (arg, view) {
1090
+ const buf = cachedTextEncoder.encode(arg);
1091
+ view.set(buf);
1092
+ return {
1093
+ read: arg.length,
1094
+ written: buf.length
1095
+ };
1096
+ };
1097
+ }
1098
+
1099
+ let WASM_VECTOR_LEN = 0;
1100
+
1101
+ let wasmModule, wasmInstance, wasm;
1102
+ function __wbg_finalize_init(instance, module) {
1103
+ wasmInstance = instance;
1104
+ wasm = instance.exports;
1105
+ wasmModule = module;
1106
+ cachedDataViewMemory0 = null;
1107
+ cachedUint8ArrayMemory0 = null;
1108
+ wasm.__wbindgen_start();
1109
+ return wasm;
1110
+ }
1111
+
1112
+ async function __wbg_load(module, imports) {
1113
+ if (typeof Response === 'function' && module instanceof Response) {
1114
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
1115
+ try {
1116
+ return await WebAssembly.instantiateStreaming(module, imports);
1117
+ } catch (e) {
1118
+ const validResponse = module.ok && expectedResponseType(module.type);
1119
+
1120
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
1121
+ 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);
1122
+
1123
+ } else { throw e; }
1124
+ }
1125
+ }
1126
+
1127
+ const bytes = await module.arrayBuffer();
1128
+ return await WebAssembly.instantiate(bytes, imports);
1129
+ } else {
1130
+ const instance = await WebAssembly.instantiate(module, imports);
1131
+
1132
+ if (instance instanceof WebAssembly.Instance) {
1133
+ return { instance, module };
1134
+ } else {
1135
+ return instance;
1136
+ }
1137
+ }
1138
+
1139
+ function expectedResponseType(type) {
1140
+ switch (type) {
1141
+ case 'basic': case 'cors': case 'default': return true;
1142
+ }
1143
+ return false;
1144
+ }
1145
+ }
1146
+
1147
+ function initSync(module) {
1148
+ if (wasm !== undefined) return wasm;
1149
+
1150
+
1151
+ if (module !== undefined) {
1152
+ if (Object.getPrototypeOf(module) === Object.prototype) {
1153
+ ({module} = module)
1154
+ } else {
1155
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
1156
+ }
1157
+ }
1158
+
1159
+ const imports = __wbg_get_imports();
1160
+ if (!(module instanceof WebAssembly.Module)) {
1161
+ module = new WebAssembly.Module(module);
1162
+ }
1163
+ const instance = new WebAssembly.Instance(module, imports);
1164
+ return __wbg_finalize_init(instance, module);
1165
+ }
1166
+
1167
+ async function __wbg_init(module_or_path) {
1168
+ if (wasm !== undefined) return wasm;
1169
+
1170
+
1171
+ if (module_or_path !== undefined) {
1172
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
1173
+ ({module_or_path} = module_or_path)
1174
+ } else {
1175
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
1176
+ }
1177
+ }
1178
+
1179
+ if (module_or_path === undefined) {
1180
+ module_or_path = new URL('moyodb_engine_bg.wasm', import.meta.url);
1181
+ }
1182
+ const imports = __wbg_get_imports();
1183
+
1184
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
1185
+ module_or_path = fetch(module_or_path);
1186
+ }
1187
+
1188
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
1189
+
1190
+ return __wbg_finalize_init(instance, module);
1191
+ }
1192
+
1193
+ export { initSync, __wbg_init as default };