@trust0/ridb-mongodb 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/index.js ADDED
@@ -0,0 +1,3368 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __commonJS = (cb, mod) => function __require() {
9
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
+ };
11
+ var __export = (target, all) => {
12
+ for (var name in all)
13
+ __defProp(target, name, { get: all[name], enumerable: true });
14
+ };
15
+ var __copyProps = (to, from, except, desc) => {
16
+ if (from && typeof from === "object" || typeof from === "function") {
17
+ for (let key of __getOwnPropNames(from))
18
+ if (!__hasOwnProp.call(to, key) && key !== except)
19
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
20
+ }
21
+ return to;
22
+ };
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
24
+ // If the importer is in node compatibility mode or this is not an ESM
25
+ // file that has been converted to a CommonJS file using a Babel-
26
+ // compatible transform (i.e. "__esModule" has not been set), then set
27
+ // "default" to the CommonJS "module.exports" for node compatibility.
28
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
29
+ mod
30
+ ));
31
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
+
33
+ // ../ridb-core/build/ridb_core.js
34
+ var require_ridb_core = __commonJS({
35
+ "../ridb-core/build/ridb_core.js"(exports2, module2) {
36
+ "use strict";
37
+ module2.exports.SchemaFieldType = {
38
+ /**
39
+ * String type for text data
40
+ */
41
+ string: "string",
42
+ /**
43
+ * Number type for numeric data (integers and floats)
44
+ */
45
+ number: "number",
46
+ /**
47
+ * Boolean type for true/false values
48
+ */
49
+ boolean: "boolean",
50
+ /**
51
+ * Array type for ordered collections of items
52
+ */
53
+ array: "array",
54
+ /**
55
+ * Object type for nested document structures
56
+ */
57
+ object: "object"
58
+ };
59
+ var __defProp2 = Object.defineProperty;
60
+ var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
61
+ var __getOwnPropNames2 = Object.getOwnPropertyNames;
62
+ var __hasOwnProp2 = Object.prototype.hasOwnProperty;
63
+ var __export2 = (target, all) => {
64
+ for (var name in all)
65
+ __defProp2(target, name, { get: all[name], enumerable: true });
66
+ };
67
+ var __copyProps2 = (to, from, except, desc) => {
68
+ if (from && typeof from === "object" || typeof from === "function") {
69
+ for (let key of __getOwnPropNames2(from))
70
+ if (!__hasOwnProp2.call(to, key) && key !== except)
71
+ __defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
72
+ }
73
+ return to;
74
+ };
75
+ var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
76
+ var ridb_core_exports = {};
77
+ __export2(ridb_core_exports, {
78
+ BasePlugin: () => BasePlugin,
79
+ BaseStorage: () => BaseStorage2,
80
+ Collection: () => Collection,
81
+ CoreStorage: () => CoreStorage,
82
+ Database: () => Database,
83
+ Errors: () => Errors,
84
+ InMemory: () => InMemory,
85
+ IndexDB: () => IndexDB,
86
+ OpType: () => OpType2,
87
+ Operation: () => Operation2,
88
+ Property: () => Property,
89
+ Query: () => Query,
90
+ QueryOptions: () => QueryOptions2,
91
+ RIDBError: () => RIDBError,
92
+ Schema: () => Schema,
93
+ WasmBindgenTestContext: () => WasmBindgenTestContext,
94
+ __wbgtest_console_debug: () => __wbgtest_console_debug,
95
+ __wbgtest_console_error: () => __wbgtest_console_error,
96
+ __wbgtest_console_info: () => __wbgtest_console_info,
97
+ __wbgtest_console_log: () => __wbgtest_console_log,
98
+ __wbgtest_console_warn: () => __wbgtest_console_warn,
99
+ default: () => ridb_core_default,
100
+ initSync: () => initSync,
101
+ is_debug_mode: () => is_debug_mode,
102
+ main_js: () => main_js
103
+ });
104
+ module2.exports = __toCommonJS2(ridb_core_exports);
105
+ var wasm;
106
+ var heap = new Array(128).fill(void 0);
107
+ heap.push(void 0, null, true, false);
108
+ function getObject(idx) {
109
+ return heap[idx];
110
+ }
111
+ var heap_next = heap.length;
112
+ function dropObject(idx) {
113
+ if (idx < 132) return;
114
+ heap[idx] = heap_next;
115
+ heap_next = idx;
116
+ }
117
+ function takeObject(idx) {
118
+ const ret = getObject(idx);
119
+ dropObject(idx);
120
+ return ret;
121
+ }
122
+ var cachedTextDecoder = typeof TextDecoder !== "undefined" ? new TextDecoder("utf-8", { ignoreBOM: true, fatal: true }) : { decode: () => {
123
+ throw Error("TextDecoder not available");
124
+ } };
125
+ if (typeof TextDecoder !== "undefined") {
126
+ cachedTextDecoder.decode();
127
+ }
128
+ var cachedUint8Memory0 = null;
129
+ function getUint8Memory0() {
130
+ if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
131
+ cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
132
+ }
133
+ return cachedUint8Memory0;
134
+ }
135
+ function getStringFromWasm0(ptr, len) {
136
+ ptr = ptr >>> 0;
137
+ return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
138
+ }
139
+ function addHeapObject(obj) {
140
+ if (heap_next === heap.length) heap.push(heap.length + 1);
141
+ const idx = heap_next;
142
+ heap_next = heap[idx];
143
+ heap[idx] = obj;
144
+ return idx;
145
+ }
146
+ var WASM_VECTOR_LEN = 0;
147
+ var cachedTextEncoder = typeof TextEncoder !== "undefined" ? new TextEncoder("utf-8") : { encode: () => {
148
+ throw Error("TextEncoder not available");
149
+ } };
150
+ var encodeString = typeof cachedTextEncoder.encodeInto === "function" ? function(arg, view) {
151
+ return cachedTextEncoder.encodeInto(arg, view);
152
+ } : function(arg, view) {
153
+ const buf = cachedTextEncoder.encode(arg);
154
+ view.set(buf);
155
+ return {
156
+ read: arg.length,
157
+ written: buf.length
158
+ };
159
+ };
160
+ function passStringToWasm0(arg, malloc, realloc) {
161
+ if (realloc === void 0) {
162
+ const buf = cachedTextEncoder.encode(arg);
163
+ const ptr2 = malloc(buf.length, 1) >>> 0;
164
+ getUint8Memory0().subarray(ptr2, ptr2 + buf.length).set(buf);
165
+ WASM_VECTOR_LEN = buf.length;
166
+ return ptr2;
167
+ }
168
+ let len = arg.length;
169
+ let ptr = malloc(len, 1) >>> 0;
170
+ const mem = getUint8Memory0();
171
+ let offset = 0;
172
+ for (; offset < len; offset++) {
173
+ const code = arg.charCodeAt(offset);
174
+ if (code > 127) break;
175
+ mem[ptr + offset] = code;
176
+ }
177
+ if (offset !== len) {
178
+ if (offset !== 0) {
179
+ arg = arg.slice(offset);
180
+ }
181
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
182
+ const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
183
+ const ret = encodeString(arg, view);
184
+ offset += ret.written;
185
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
186
+ }
187
+ WASM_VECTOR_LEN = offset;
188
+ return ptr;
189
+ }
190
+ function isLikeNone(x) {
191
+ return x === void 0 || x === null;
192
+ }
193
+ var cachedInt32Memory0 = null;
194
+ function getInt32Memory0() {
195
+ if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
196
+ cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
197
+ }
198
+ return cachedInt32Memory0;
199
+ }
200
+ var cachedFloat64Memory0 = null;
201
+ function getFloat64Memory0() {
202
+ if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) {
203
+ cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer);
204
+ }
205
+ return cachedFloat64Memory0;
206
+ }
207
+ var cachedBigInt64Memory0 = null;
208
+ function getBigInt64Memory0() {
209
+ if (cachedBigInt64Memory0 === null || cachedBigInt64Memory0.byteLength === 0) {
210
+ cachedBigInt64Memory0 = new BigInt64Array(wasm.memory.buffer);
211
+ }
212
+ return cachedBigInt64Memory0;
213
+ }
214
+ function debugString(val) {
215
+ const type = typeof val;
216
+ if (type == "number" || type == "boolean" || val == null) {
217
+ return `${val}`;
218
+ }
219
+ if (type == "string") {
220
+ return `"${val}"`;
221
+ }
222
+ if (type == "symbol") {
223
+ const description = val.description;
224
+ if (description == null) {
225
+ return "Symbol";
226
+ } else {
227
+ return `Symbol(${description})`;
228
+ }
229
+ }
230
+ if (type == "function") {
231
+ const name = val.name;
232
+ if (typeof name == "string" && name.length > 0) {
233
+ return `Function(${name})`;
234
+ } else {
235
+ return "Function";
236
+ }
237
+ }
238
+ if (Array.isArray(val)) {
239
+ const length = val.length;
240
+ let debug = "[";
241
+ if (length > 0) {
242
+ debug += debugString(val[0]);
243
+ }
244
+ for (let i = 1; i < length; i++) {
245
+ debug += ", " + debugString(val[i]);
246
+ }
247
+ debug += "]";
248
+ return debug;
249
+ }
250
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
251
+ let className;
252
+ if (builtInMatches.length > 1) {
253
+ className = builtInMatches[1];
254
+ } else {
255
+ return toString.call(val);
256
+ }
257
+ if (className == "Object") {
258
+ try {
259
+ return "Object(" + JSON.stringify(val) + ")";
260
+ } catch (_) {
261
+ return "Object";
262
+ }
263
+ }
264
+ if (val instanceof Error) {
265
+ return `${val.name}: ${val.message}
266
+ ${val.stack}`;
267
+ }
268
+ return className;
269
+ }
270
+ var CLOSURE_DTORS = typeof FinalizationRegistry === "undefined" ? { register: () => {
271
+ }, unregister: () => {
272
+ } } : new FinalizationRegistry((state) => {
273
+ wasm.__wbindgen_export_2.get(state.dtor)(state.a, state.b);
274
+ });
275
+ function makeClosure(arg0, arg1, dtor, f) {
276
+ const state = { a: arg0, b: arg1, cnt: 1, dtor };
277
+ const real = (...args) => {
278
+ state.cnt++;
279
+ try {
280
+ return f(state.a, state.b, ...args);
281
+ } finally {
282
+ if (--state.cnt === 0) {
283
+ wasm.__wbindgen_export_2.get(state.dtor)(state.a, state.b);
284
+ state.a = 0;
285
+ CLOSURE_DTORS.unregister(state);
286
+ }
287
+ }
288
+ };
289
+ real.original = state;
290
+ CLOSURE_DTORS.register(real, state, state);
291
+ return real;
292
+ }
293
+ function __wbg_adapter_56(arg0, arg1, arg2, arg3, arg4) {
294
+ try {
295
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
296
+ wasm._dyn_core__ops__function__Fn__A_B_C___Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h1d7727fe9471ac49(retptr, arg0, arg1, addHeapObject(arg2), addHeapObject(arg3), addHeapObject(arg4));
297
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
298
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
299
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
300
+ if (r2) {
301
+ throw takeObject(r1);
302
+ }
303
+ return takeObject(r0);
304
+ } finally {
305
+ wasm.__wbindgen_add_to_stack_pointer(16);
306
+ }
307
+ }
308
+ function makeMutClosure(arg0, arg1, dtor, f) {
309
+ const state = { a: arg0, b: arg1, cnt: 1, dtor };
310
+ const real = (...args) => {
311
+ state.cnt++;
312
+ const a = state.a;
313
+ state.a = 0;
314
+ try {
315
+ return f(a, state.b, ...args);
316
+ } finally {
317
+ if (--state.cnt === 0) {
318
+ wasm.__wbindgen_export_2.get(state.dtor)(a, state.b);
319
+ CLOSURE_DTORS.unregister(state);
320
+ } else {
321
+ state.a = a;
322
+ }
323
+ }
324
+ };
325
+ real.original = state;
326
+ CLOSURE_DTORS.register(real, state, state);
327
+ return real;
328
+ }
329
+ function __wbg_adapter_59(arg0, arg1, arg2) {
330
+ wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h4e550b82c2b30c7a(arg0, arg1, addHeapObject(arg2));
331
+ }
332
+ function __wbg_adapter_62(arg0, arg1) {
333
+ wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hec0cc069f718ed78(arg0, arg1);
334
+ }
335
+ function __wbg_adapter_65(arg0, arg1, arg2) {
336
+ wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hf401bdfdf8c9bdd9(arg0, arg1, addHeapObject(arg2));
337
+ }
338
+ var cachedUint32Memory0 = null;
339
+ function getUint32Memory0() {
340
+ if (cachedUint32Memory0 === null || cachedUint32Memory0.byteLength === 0) {
341
+ cachedUint32Memory0 = new Uint32Array(wasm.memory.buffer);
342
+ }
343
+ return cachedUint32Memory0;
344
+ }
345
+ function getArrayJsValueFromWasm0(ptr, len) {
346
+ ptr = ptr >>> 0;
347
+ const mem = getUint32Memory0();
348
+ const slice = mem.subarray(ptr / 4, ptr / 4 + len);
349
+ const result = [];
350
+ for (let i = 0; i < slice.length; i++) {
351
+ result.push(takeObject(slice[i]));
352
+ }
353
+ return result;
354
+ }
355
+ function _assertClass(instance, klass) {
356
+ if (!(instance instanceof klass)) {
357
+ throw new Error(`expected instance of ${klass.name}`);
358
+ }
359
+ return instance.ptr;
360
+ }
361
+ var stack_pointer = 128;
362
+ function addBorrowedObject(obj) {
363
+ if (stack_pointer == 1) throw new Error("out of js stack");
364
+ heap[--stack_pointer] = obj;
365
+ return stack_pointer;
366
+ }
367
+ function passArrayJsValueToWasm0(array, malloc) {
368
+ const ptr = malloc(array.length * 4, 4) >>> 0;
369
+ const mem = getUint32Memory0();
370
+ for (let i = 0; i < array.length; i++) {
371
+ mem[ptr / 4 + i] = addHeapObject(array[i]);
372
+ }
373
+ WASM_VECTOR_LEN = array.length;
374
+ return ptr;
375
+ }
376
+ function handleError(f, args) {
377
+ try {
378
+ return f.apply(this, args);
379
+ } catch (e) {
380
+ wasm.__wbindgen_exn_store(addHeapObject(e));
381
+ }
382
+ }
383
+ function main_js() {
384
+ wasm.main_js();
385
+ }
386
+ function is_debug_mode() {
387
+ const ret = wasm.is_debug_mode();
388
+ return ret !== 0;
389
+ }
390
+ function __wbgtest_console_log(args) {
391
+ try {
392
+ wasm.__wbgtest_console_log(addBorrowedObject(args));
393
+ } finally {
394
+ heap[stack_pointer++] = void 0;
395
+ }
396
+ }
397
+ function __wbgtest_console_debug(args) {
398
+ try {
399
+ wasm.__wbgtest_console_debug(addBorrowedObject(args));
400
+ } finally {
401
+ heap[stack_pointer++] = void 0;
402
+ }
403
+ }
404
+ function __wbgtest_console_info(args) {
405
+ try {
406
+ wasm.__wbgtest_console_info(addBorrowedObject(args));
407
+ } finally {
408
+ heap[stack_pointer++] = void 0;
409
+ }
410
+ }
411
+ function __wbgtest_console_warn(args) {
412
+ try {
413
+ wasm.__wbgtest_console_warn(addBorrowedObject(args));
414
+ } finally {
415
+ heap[stack_pointer++] = void 0;
416
+ }
417
+ }
418
+ function __wbgtest_console_error(args) {
419
+ try {
420
+ wasm.__wbgtest_console_error(addBorrowedObject(args));
421
+ } finally {
422
+ heap[stack_pointer++] = void 0;
423
+ }
424
+ }
425
+ function __wbg_adapter_292(arg0, arg1) {
426
+ wasm.wasm_bindgen__convert__closures__invoke0_mut__he68973678185bd11(arg0, arg1);
427
+ }
428
+ function __wbg_adapter_335(arg0, arg1, arg2, arg3, arg4) {
429
+ wasm.wasm_bindgen__convert__closures__invoke3_mut__h711940be5154e055(arg0, arg1, addHeapObject(arg2), arg3, addHeapObject(arg4));
430
+ }
431
+ function __wbg_adapter_392(arg0, arg1, arg2, arg3) {
432
+ wasm.wasm_bindgen__convert__closures__invoke2_mut__hdfe55fa2a247d1ac(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
433
+ }
434
+ var Errors = Object.freeze({ Error: 0, "0": "Error", HookError: 1, "1": "HookError", QueryError: 2, "2": "QueryError", SerializationError: 3, "3": "SerializationError", ValidationError: 4, "4": "ValidationError", AuthenticationError: 5, "5": "AuthenticationError" });
435
+ var OpType2 = Object.freeze({
436
+ /**
437
+ * Create operation.
438
+ */
439
+ CREATE: 0,
440
+ "0": "CREATE",
441
+ /**
442
+ * Update operation.
443
+ */
444
+ UPDATE: 1,
445
+ "1": "UPDATE",
446
+ /**
447
+ * Delete operation.
448
+ */
449
+ DELETE: 2,
450
+ "2": "DELETE",
451
+ /**
452
+ * Query Operation.
453
+ */
454
+ QUERY: 3,
455
+ "3": "QUERY",
456
+ /**
457
+ * Count Operation.
458
+ */
459
+ COUNT: 4,
460
+ "4": "COUNT"
461
+ });
462
+ var BasePluginFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
463
+ }, unregister: () => {
464
+ } } : new FinalizationRegistry((ptr) => wasm.__wbg_baseplugin_free(ptr >>> 0));
465
+ var BasePlugin = class {
466
+ __destroy_into_raw() {
467
+ const ptr = this.__wbg_ptr;
468
+ this.__wbg_ptr = 0;
469
+ BasePluginFinalization.unregister(this);
470
+ return ptr;
471
+ }
472
+ free() {
473
+ const ptr = this.__destroy_into_raw();
474
+ wasm.__wbg_baseplugin_free(ptr);
475
+ }
476
+ /**
477
+ * @param {string} name
478
+ */
479
+ constructor(name) {
480
+ try {
481
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
482
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
483
+ const len0 = WASM_VECTOR_LEN;
484
+ wasm.baseplugin_new(retptr, ptr0, len0);
485
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
486
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
487
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
488
+ if (r2) {
489
+ throw takeObject(r1);
490
+ }
491
+ this.__wbg_ptr = r0 >>> 0;
492
+ return this;
493
+ } finally {
494
+ wasm.__wbindgen_add_to_stack_pointer(16);
495
+ }
496
+ }
497
+ /**
498
+ * @returns {any}
499
+ */
500
+ get name() {
501
+ const ret = wasm.baseplugin_name(this.__wbg_ptr);
502
+ return takeObject(ret);
503
+ }
504
+ /**
505
+ * @returns {any}
506
+ */
507
+ get docCreateHook() {
508
+ const ret = wasm.baseplugin_get_doc_create_hook(this.__wbg_ptr);
509
+ return takeObject(ret);
510
+ }
511
+ /**
512
+ * @returns {any}
513
+ */
514
+ get docRecoverHook() {
515
+ const ret = wasm.baseplugin_get_doc_recover_hook(this.__wbg_ptr);
516
+ return takeObject(ret);
517
+ }
518
+ /**
519
+ * @param {any} hook
520
+ */
521
+ set docCreateHook(hook) {
522
+ wasm.baseplugin_set_doc_create_hook(this.__wbg_ptr, addHeapObject(hook));
523
+ }
524
+ /**
525
+ * @param {any} hook
526
+ */
527
+ set docRecoverHook(hook) {
528
+ wasm.baseplugin_set_doc_recover_hook(this.__wbg_ptr, addHeapObject(hook));
529
+ }
530
+ };
531
+ var BaseStorageFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
532
+ }, unregister: () => {
533
+ } } : new FinalizationRegistry((ptr) => wasm.__wbg_basestorage_free(ptr >>> 0));
534
+ var BaseStorage2 = class {
535
+ __destroy_into_raw() {
536
+ const ptr = this.__wbg_ptr;
537
+ this.__wbg_ptr = 0;
538
+ BaseStorageFinalization.unregister(this);
539
+ return ptr;
540
+ }
541
+ free() {
542
+ const ptr = this.__destroy_into_raw();
543
+ wasm.__wbg_basestorage_free(ptr);
544
+ }
545
+ /**
546
+ * Creates a new `BaseStorage` instance with the provided name and schema type.
547
+ *
548
+ * # Arguments
549
+ *
550
+ * * `name` - The name of the storage.
551
+ * * `schema_type` - The schema type in `JsValue` format.
552
+ *
553
+ * # Returns
554
+ *
555
+ * * `Result<BaseStorage, JsValue>` - A result containing the new `BaseStorage` instance or an error.
556
+ * @param {string} name
557
+ * @param {object} schemas_js
558
+ * @param {object | undefined} [options]
559
+ */
560
+ constructor(name, schemas_js, options) {
561
+ try {
562
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
563
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
564
+ const len0 = WASM_VECTOR_LEN;
565
+ wasm.basestorage_new(retptr, ptr0, len0, addHeapObject(schemas_js), isLikeNone(options) ? 0 : addHeapObject(options));
566
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
567
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
568
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
569
+ if (r2) {
570
+ throw takeObject(r1);
571
+ }
572
+ this.__wbg_ptr = r0 >>> 0;
573
+ return this;
574
+ } finally {
575
+ wasm.__wbindgen_add_to_stack_pointer(16);
576
+ }
577
+ }
578
+ /**
579
+ * @returns {any}
580
+ */
581
+ addIndexSchemas() {
582
+ try {
583
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
584
+ wasm.basestorage_addIndexSchemas(retptr, this.__wbg_ptr);
585
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
586
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
587
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
588
+ if (r2) {
589
+ throw takeObject(r1);
590
+ }
591
+ return takeObject(r0);
592
+ } finally {
593
+ wasm.__wbindgen_add_to_stack_pointer(16);
594
+ }
595
+ }
596
+ /**
597
+ * @param {string} name
598
+ * @returns {any}
599
+ */
600
+ getOption(name) {
601
+ try {
602
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
603
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
604
+ const len0 = WASM_VECTOR_LEN;
605
+ wasm.basestorage_getOption(retptr, this.__wbg_ptr, ptr0, len0);
606
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
607
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
608
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
609
+ if (r2) {
610
+ throw takeObject(r1);
611
+ }
612
+ return takeObject(r0);
613
+ } finally {
614
+ wasm.__wbindgen_add_to_stack_pointer(16);
615
+ }
616
+ }
617
+ /**
618
+ * @param {string} name
619
+ * @returns {Schema}
620
+ */
621
+ getSchema(name) {
622
+ try {
623
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
624
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
625
+ const len0 = WASM_VECTOR_LEN;
626
+ wasm.basestorage_getSchema(retptr, this.__wbg_ptr, ptr0, len0);
627
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
628
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
629
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
630
+ if (r2) {
631
+ throw takeObject(r1);
632
+ }
633
+ return Schema.__wrap(r0);
634
+ } finally {
635
+ wasm.__wbindgen_add_to_stack_pointer(16);
636
+ }
637
+ }
638
+ /**
639
+ * @returns {CoreStorage}
640
+ */
641
+ get core() {
642
+ try {
643
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
644
+ wasm.basestorage_core(retptr, this.__wbg_ptr);
645
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
646
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
647
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
648
+ if (r2) {
649
+ throw takeObject(r1);
650
+ }
651
+ return CoreStorage.__wrap(r0);
652
+ } finally {
653
+ wasm.__wbindgen_add_to_stack_pointer(16);
654
+ }
655
+ }
656
+ };
657
+ var CollectionFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
658
+ }, unregister: () => {
659
+ } } : new FinalizationRegistry((ptr) => wasm.__wbg_collection_free(ptr >>> 0));
660
+ var Collection = class _Collection {
661
+ static __wrap(ptr) {
662
+ ptr = ptr >>> 0;
663
+ const obj = Object.create(_Collection.prototype);
664
+ obj.__wbg_ptr = ptr;
665
+ CollectionFinalization.register(obj, obj.__wbg_ptr, obj);
666
+ return obj;
667
+ }
668
+ __destroy_into_raw() {
669
+ const ptr = this.__wbg_ptr;
670
+ this.__wbg_ptr = 0;
671
+ CollectionFinalization.unregister(this);
672
+ return ptr;
673
+ }
674
+ free() {
675
+ const ptr = this.__destroy_into_raw();
676
+ wasm.__wbg_collection_free(ptr);
677
+ }
678
+ /**
679
+ * @returns {string}
680
+ */
681
+ get name() {
682
+ let deferred1_0;
683
+ let deferred1_1;
684
+ try {
685
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
686
+ wasm.collection_name(retptr, this.__wbg_ptr);
687
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
688
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
689
+ deferred1_0 = r0;
690
+ deferred1_1 = r1;
691
+ return getStringFromWasm0(r0, r1);
692
+ } finally {
693
+ wasm.__wbindgen_add_to_stack_pointer(16);
694
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
695
+ }
696
+ }
697
+ /**
698
+ * @returns {Schema}
699
+ */
700
+ get schema() {
701
+ try {
702
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
703
+ wasm.collection_schema(retptr, this.__wbg_ptr);
704
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
705
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
706
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
707
+ if (r2) {
708
+ throw takeObject(r1);
709
+ }
710
+ return Schema.__wrap(r0);
711
+ } finally {
712
+ wasm.__wbindgen_add_to_stack_pointer(16);
713
+ }
714
+ }
715
+ /**
716
+ * Finds and returns all documents in the collection.
717
+ *
718
+ * This function is asynchronous and returns a `JsValue` representing
719
+ * the documents found in the collection.
720
+ * @param {any} query_js
721
+ * @param {any} options_js
722
+ * @returns {Promise<any>}
723
+ */
724
+ find(query_js, options_js) {
725
+ const ret = wasm.collection_find(this.__wbg_ptr, addHeapObject(query_js), addHeapObject(options_js));
726
+ return takeObject(ret);
727
+ }
728
+ /**
729
+ * @param {any} options
730
+ * @returns {QueryOptions}
731
+ */
732
+ parse_query_options(options) {
733
+ try {
734
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
735
+ wasm.collection_parse_query_options(retptr, this.__wbg_ptr, addHeapObject(options));
736
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
737
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
738
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
739
+ if (r2) {
740
+ throw takeObject(r1);
741
+ }
742
+ return QueryOptions2.__wrap(r0);
743
+ } finally {
744
+ wasm.__wbindgen_add_to_stack_pointer(16);
745
+ }
746
+ }
747
+ /**
748
+ * counts and returns all documents in the collection.
749
+ *
750
+ * This function is asynchronous and returns a `Schema` representing
751
+ * the documents found in the collection.
752
+ * @param {any} query_js
753
+ * @param {any} options_js
754
+ * @returns {Promise<any>}
755
+ */
756
+ count(query_js, options_js) {
757
+ const ret = wasm.collection_count(this.__wbg_ptr, addHeapObject(query_js), addHeapObject(options_js));
758
+ return takeObject(ret);
759
+ }
760
+ /**
761
+ * Finds and returns a single document in the collection by its ID.
762
+ *
763
+ * This function is asynchronous.
764
+ * @param {any} primary_key
765
+ * @returns {Promise<any>}
766
+ */
767
+ findById(primary_key) {
768
+ const ret = wasm.collection_findById(this.__wbg_ptr, addHeapObject(primary_key));
769
+ return takeObject(ret);
770
+ }
771
+ /**
772
+ * Updates a document in the collection with the given data.
773
+ *
774
+ * This function is asynchronous and returns a `Result` indicating success or failure.
775
+ *
776
+ * # Arguments
777
+ *
778
+ * * `document` - A `JsValue` representing the partial document to update.
779
+ * @param {any} document
780
+ * @returns {Promise<any>}
781
+ */
782
+ update(document2) {
783
+ const ret = wasm.collection_update(this.__wbg_ptr, addHeapObject(document2));
784
+ return takeObject(ret);
785
+ }
786
+ /**
787
+ * Creates a new document in the collection.
788
+ *
789
+ * This function is asynchronous and returns a `Result` indicating success or failure.
790
+ *
791
+ * # Arguments
792
+ *
793
+ * * `document` - A `JsValue` representing the document to create.
794
+ * @param {any} document
795
+ * @returns {Promise<any>}
796
+ */
797
+ create(document2) {
798
+ const ret = wasm.collection_create(this.__wbg_ptr, addHeapObject(document2));
799
+ return takeObject(ret);
800
+ }
801
+ /**
802
+ * Deletes a document from the collection by its ID.
803
+ *
804
+ * This function is asynchronous.
805
+ * @param {any} primary_key
806
+ * @returns {Promise<any>}
807
+ */
808
+ delete(primary_key) {
809
+ const ret = wasm.collection_delete(this.__wbg_ptr, addHeapObject(primary_key));
810
+ return takeObject(ret);
811
+ }
812
+ };
813
+ var CoreStorageFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
814
+ }, unregister: () => {
815
+ } } : new FinalizationRegistry((ptr) => wasm.__wbg_corestorage_free(ptr >>> 0));
816
+ var CoreStorage = class _CoreStorage {
817
+ static __wrap(ptr) {
818
+ ptr = ptr >>> 0;
819
+ const obj = Object.create(_CoreStorage.prototype);
820
+ obj.__wbg_ptr = ptr;
821
+ CoreStorageFinalization.register(obj, obj.__wbg_ptr, obj);
822
+ return obj;
823
+ }
824
+ __destroy_into_raw() {
825
+ const ptr = this.__wbg_ptr;
826
+ this.__wbg_ptr = 0;
827
+ CoreStorageFinalization.unregister(this);
828
+ return ptr;
829
+ }
830
+ free() {
831
+ const ptr = this.__destroy_into_raw();
832
+ wasm.__wbg_corestorage_free(ptr);
833
+ }
834
+ /**
835
+ */
836
+ constructor() {
837
+ const ret = wasm.corestorage_new();
838
+ this.__wbg_ptr = ret >>> 0;
839
+ return this;
840
+ }
841
+ /**
842
+ * @param {any} value
843
+ * @returns {string}
844
+ */
845
+ getPrimaryKeyTyped(value) {
846
+ let deferred2_0;
847
+ let deferred2_1;
848
+ try {
849
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
850
+ wasm.corestorage_getPrimaryKeyTyped(retptr, this.__wbg_ptr, addHeapObject(value));
851
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
852
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
853
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
854
+ var r3 = getInt32Memory0()[retptr / 4 + 3];
855
+ var ptr1 = r0;
856
+ var len1 = r1;
857
+ if (r3) {
858
+ ptr1 = 0;
859
+ len1 = 0;
860
+ throw takeObject(r2);
861
+ }
862
+ deferred2_0 = ptr1;
863
+ deferred2_1 = len1;
864
+ return getStringFromWasm0(ptr1, len1);
865
+ } finally {
866
+ wasm.__wbindgen_add_to_stack_pointer(16);
867
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
868
+ }
869
+ }
870
+ /**
871
+ * @param {Schema} schema
872
+ * @param {Operation} op
873
+ * @returns {(string)[]}
874
+ */
875
+ getIndexes(schema, op) {
876
+ try {
877
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
878
+ _assertClass(schema, Schema);
879
+ _assertClass(op, Operation2);
880
+ wasm.corestorage_getIndexes(retptr, this.__wbg_ptr, schema.__wbg_ptr, op.__wbg_ptr);
881
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
882
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
883
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
884
+ var r3 = getInt32Memory0()[retptr / 4 + 3];
885
+ if (r3) {
886
+ throw takeObject(r2);
887
+ }
888
+ var v1 = getArrayJsValueFromWasm0(r0, r1).slice();
889
+ wasm.__wbindgen_free(r0, r1 * 4, 4);
890
+ return v1;
891
+ } finally {
892
+ wasm.__wbindgen_add_to_stack_pointer(16);
893
+ }
894
+ }
895
+ /**
896
+ * @param {any} document
897
+ * @param {Query} query
898
+ * @returns {boolean}
899
+ */
900
+ matchesQuery(document2, query) {
901
+ try {
902
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
903
+ _assertClass(query, Query);
904
+ var ptr0 = query.__destroy_into_raw();
905
+ wasm.corestorage_matchesQuery(retptr, this.__wbg_ptr, addBorrowedObject(document2), ptr0);
906
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
907
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
908
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
909
+ if (r2) {
910
+ throw takeObject(r1);
911
+ }
912
+ return r0 !== 0;
913
+ } finally {
914
+ wasm.__wbindgen_add_to_stack_pointer(16);
915
+ heap[stack_pointer++] = void 0;
916
+ }
917
+ }
918
+ };
919
+ var DatabaseFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
920
+ }, unregister: () => {
921
+ } } : new FinalizationRegistry((ptr) => wasm.__wbg_database_free(ptr >>> 0));
922
+ var Database = class _Database {
923
+ static __wrap(ptr) {
924
+ ptr = ptr >>> 0;
925
+ const obj = Object.create(_Database.prototype);
926
+ obj.__wbg_ptr = ptr;
927
+ DatabaseFinalization.register(obj, obj.__wbg_ptr, obj);
928
+ return obj;
929
+ }
930
+ __destroy_into_raw() {
931
+ const ptr = this.__wbg_ptr;
932
+ this.__wbg_ptr = 0;
933
+ DatabaseFinalization.unregister(this);
934
+ return ptr;
935
+ }
936
+ free() {
937
+ const ptr = this.__destroy_into_raw();
938
+ wasm.__wbg_database_free(ptr);
939
+ }
940
+ /**
941
+ * @returns {Promise<any>}
942
+ */
943
+ start() {
944
+ const ret = wasm.database_start(this.__wbg_ptr);
945
+ return takeObject(ret);
946
+ }
947
+ /**
948
+ * @returns {Promise<any>}
949
+ */
950
+ close() {
951
+ const ptr = this.__destroy_into_raw();
952
+ const ret = wasm.database_close(ptr);
953
+ return takeObject(ret);
954
+ }
955
+ /**
956
+ * @returns {boolean}
957
+ */
958
+ get started() {
959
+ const ret = wasm.database_started(this.__wbg_ptr);
960
+ return ret !== 0;
961
+ }
962
+ /**
963
+ * @param {string} password
964
+ * @returns {Promise<boolean>}
965
+ */
966
+ authenticate(password) {
967
+ const ptr0 = passStringToWasm0(password, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
968
+ const len0 = WASM_VECTOR_LEN;
969
+ const ret = wasm.database_authenticate(this.__wbg_ptr, ptr0, len0);
970
+ return takeObject(ret);
971
+ }
972
+ /**
973
+ * Retrieves the collections in the database.
974
+ *
975
+ * This function returns an `Object` containing the collections.
976
+ *
977
+ * # Returns
978
+ *
979
+ * * `Result<Object, JsValue>` - A result containing an `Object` with the collections or an error.
980
+ * @returns {object}
981
+ */
982
+ get collections() {
983
+ try {
984
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
985
+ wasm.database_collections(retptr, this.__wbg_ptr);
986
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
987
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
988
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
989
+ if (r2) {
990
+ throw takeObject(r1);
991
+ }
992
+ return takeObject(r0);
993
+ } finally {
994
+ wasm.__wbindgen_add_to_stack_pointer(16);
995
+ }
996
+ }
997
+ /**
998
+ * @param {string} db_name
999
+ * @param {object} schemas_js
1000
+ * @param {object} migrations_js
1001
+ * @param {Array<any>} plugins
1002
+ * @param {any} module
1003
+ * @param {string | undefined} [password]
1004
+ * @param {any | undefined} [storage]
1005
+ * @returns {Promise<Database>}
1006
+ */
1007
+ static create(db_name, schemas_js, migrations_js, plugins, module22, password, storage) {
1008
+ const ptr0 = passStringToWasm0(db_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1009
+ const len0 = WASM_VECTOR_LEN;
1010
+ var ptr1 = isLikeNone(password) ? 0 : passStringToWasm0(password, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1011
+ var len1 = WASM_VECTOR_LEN;
1012
+ const ret = wasm.database_create(ptr0, len0, addHeapObject(schemas_js), addHeapObject(migrations_js), addHeapObject(plugins), addHeapObject(module22), ptr1, len1, isLikeNone(storage) ? 0 : addHeapObject(storage));
1013
+ return takeObject(ret);
1014
+ }
1015
+ };
1016
+ var InMemoryFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
1017
+ }, unregister: () => {
1018
+ } } : new FinalizationRegistry((ptr) => wasm.__wbg_inmemory_free(ptr >>> 0));
1019
+ var InMemory = class _InMemory {
1020
+ static __wrap(ptr) {
1021
+ ptr = ptr >>> 0;
1022
+ const obj = Object.create(_InMemory.prototype);
1023
+ obj.__wbg_ptr = ptr;
1024
+ InMemoryFinalization.register(obj, obj.__wbg_ptr, obj);
1025
+ return obj;
1026
+ }
1027
+ __destroy_into_raw() {
1028
+ const ptr = this.__wbg_ptr;
1029
+ this.__wbg_ptr = 0;
1030
+ InMemoryFinalization.unregister(this);
1031
+ return ptr;
1032
+ }
1033
+ free() {
1034
+ const ptr = this.__destroy_into_raw();
1035
+ wasm.__wbg_inmemory_free(ptr);
1036
+ }
1037
+ /**
1038
+ * @param {string} name
1039
+ * @param {object} schemas_js
1040
+ * @returns {Promise<InMemory>}
1041
+ */
1042
+ static create(name, schemas_js) {
1043
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1044
+ const len0 = WASM_VECTOR_LEN;
1045
+ const ret = wasm.inmemory_create(ptr0, len0, addHeapObject(schemas_js));
1046
+ return takeObject(ret);
1047
+ }
1048
+ /**
1049
+ * @param {Operation} op
1050
+ * @returns {Promise<any>}
1051
+ */
1052
+ write(op) {
1053
+ _assertClass(op, Operation2);
1054
+ var ptr0 = op.__destroy_into_raw();
1055
+ const ret = wasm.inmemory_write(this.__wbg_ptr, ptr0);
1056
+ return takeObject(ret);
1057
+ }
1058
+ /**
1059
+ * @param {string} collection_name
1060
+ * @param {any} query_js
1061
+ * @param {QueryOptions} options
1062
+ * @returns {Promise<any>}
1063
+ */
1064
+ find(collection_name, query_js, options) {
1065
+ const ptr0 = passStringToWasm0(collection_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1066
+ const len0 = WASM_VECTOR_LEN;
1067
+ _assertClass(options, QueryOptions2);
1068
+ var ptr1 = options.__destroy_into_raw();
1069
+ const ret = wasm.inmemory_find(this.__wbg_ptr, ptr0, len0, addHeapObject(query_js), ptr1);
1070
+ return takeObject(ret);
1071
+ }
1072
+ /**
1073
+ * @param {string} collection_name
1074
+ * @param {any} primary_key
1075
+ * @returns {Promise<any>}
1076
+ */
1077
+ findDocumentById(collection_name, primary_key) {
1078
+ const ptr0 = passStringToWasm0(collection_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1079
+ const len0 = WASM_VECTOR_LEN;
1080
+ const ret = wasm.inmemory_findDocumentById(this.__wbg_ptr, ptr0, len0, addHeapObject(primary_key));
1081
+ return takeObject(ret);
1082
+ }
1083
+ /**
1084
+ * @param {string} collection_name
1085
+ * @param {any} query_js
1086
+ * @param {QueryOptions} options
1087
+ * @returns {Promise<any>}
1088
+ */
1089
+ count(collection_name, query_js, options) {
1090
+ const ptr0 = passStringToWasm0(collection_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1091
+ const len0 = WASM_VECTOR_LEN;
1092
+ _assertClass(options, QueryOptions2);
1093
+ var ptr1 = options.__destroy_into_raw();
1094
+ const ret = wasm.inmemory_count(this.__wbg_ptr, ptr0, len0, addHeapObject(query_js), ptr1);
1095
+ return takeObject(ret);
1096
+ }
1097
+ /**
1098
+ * @returns {Promise<any>}
1099
+ */
1100
+ close() {
1101
+ const ret = wasm.inmemory_close(this.__wbg_ptr);
1102
+ return takeObject(ret);
1103
+ }
1104
+ /**
1105
+ * @returns {Promise<any>}
1106
+ */
1107
+ start() {
1108
+ const ret = wasm.inmemory_start(this.__wbg_ptr);
1109
+ return takeObject(ret);
1110
+ }
1111
+ };
1112
+ var IndexDBFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
1113
+ }, unregister: () => {
1114
+ } } : new FinalizationRegistry((ptr) => wasm.__wbg_indexdb_free(ptr >>> 0));
1115
+ var IndexDB = class _IndexDB {
1116
+ static __wrap(ptr) {
1117
+ ptr = ptr >>> 0;
1118
+ const obj = Object.create(_IndexDB.prototype);
1119
+ obj.__wbg_ptr = ptr;
1120
+ IndexDBFinalization.register(obj, obj.__wbg_ptr, obj);
1121
+ return obj;
1122
+ }
1123
+ __destroy_into_raw() {
1124
+ const ptr = this.__wbg_ptr;
1125
+ this.__wbg_ptr = 0;
1126
+ IndexDBFinalization.unregister(this);
1127
+ return ptr;
1128
+ }
1129
+ free() {
1130
+ const ptr = this.__destroy_into_raw();
1131
+ wasm.__wbg_indexdb_free(ptr);
1132
+ }
1133
+ /**
1134
+ * Fetch documents by opening an IndexedDB cursor (on an index or store),
1135
+ * then apply inline filtering and offset/limit constraints.
1136
+ * @returns {(string)[]}
1137
+ */
1138
+ get_stores() {
1139
+ try {
1140
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1141
+ wasm.indexdb_get_stores(retptr, this.__wbg_ptr);
1142
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1143
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1144
+ var v1 = getArrayJsValueFromWasm0(r0, r1).slice();
1145
+ wasm.__wbindgen_free(r0, r1 * 4, 4);
1146
+ return v1;
1147
+ } finally {
1148
+ wasm.__wbindgen_add_to_stack_pointer(16);
1149
+ }
1150
+ }
1151
+ /**
1152
+ * @param {string} store_name
1153
+ * @returns {IDBObjectStore}
1154
+ */
1155
+ get_store(store_name) {
1156
+ try {
1157
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1158
+ const ptr0 = passStringToWasm0(store_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1159
+ const len0 = WASM_VECTOR_LEN;
1160
+ wasm.indexdb_get_store(retptr, this.__wbg_ptr, ptr0, len0);
1161
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1162
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1163
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
1164
+ if (r2) {
1165
+ throw takeObject(r1);
1166
+ }
1167
+ return takeObject(r0);
1168
+ } finally {
1169
+ wasm.__wbindgen_add_to_stack_pointer(16);
1170
+ }
1171
+ }
1172
+ /**
1173
+ * @param {string} name
1174
+ * @param {object} schemas_js
1175
+ * @returns {Promise<IndexDB>}
1176
+ */
1177
+ static create(name, schemas_js) {
1178
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1179
+ const len0 = WASM_VECTOR_LEN;
1180
+ const ret = wasm.indexdb_create(ptr0, len0, addHeapObject(schemas_js));
1181
+ return takeObject(ret);
1182
+ }
1183
+ /**
1184
+ * @param {Operation} op
1185
+ * @returns {Promise<any>}
1186
+ */
1187
+ write(op) {
1188
+ _assertClass(op, Operation2);
1189
+ var ptr0 = op.__destroy_into_raw();
1190
+ const ret = wasm.indexdb_write(this.__wbg_ptr, ptr0);
1191
+ return takeObject(ret);
1192
+ }
1193
+ /**
1194
+ * @param {string} collection_name
1195
+ * @param {any} query
1196
+ * @param {QueryOptions} options
1197
+ * @returns {Promise<any>}
1198
+ */
1199
+ find(collection_name, query, options) {
1200
+ const ptr0 = passStringToWasm0(collection_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1201
+ const len0 = WASM_VECTOR_LEN;
1202
+ _assertClass(options, QueryOptions2);
1203
+ var ptr1 = options.__destroy_into_raw();
1204
+ const ret = wasm.indexdb_find(this.__wbg_ptr, ptr0, len0, addHeapObject(query), ptr1);
1205
+ return takeObject(ret);
1206
+ }
1207
+ /**
1208
+ * @param {string} collection_name
1209
+ * @param {any} primary_key
1210
+ * @returns {Promise<any>}
1211
+ */
1212
+ findDocumentById(collection_name, primary_key) {
1213
+ const ptr0 = passStringToWasm0(collection_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1214
+ const len0 = WASM_VECTOR_LEN;
1215
+ const ret = wasm.indexdb_findDocumentById(this.__wbg_ptr, ptr0, len0, addHeapObject(primary_key));
1216
+ return takeObject(ret);
1217
+ }
1218
+ /**
1219
+ * @param {string} collection_name
1220
+ * @param {any} query
1221
+ * @param {QueryOptions} options
1222
+ * @returns {Promise<any>}
1223
+ */
1224
+ count(collection_name, query, options) {
1225
+ const ptr0 = passStringToWasm0(collection_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1226
+ const len0 = WASM_VECTOR_LEN;
1227
+ _assertClass(options, QueryOptions2);
1228
+ var ptr1 = options.__destroy_into_raw();
1229
+ const ret = wasm.indexdb_count(this.__wbg_ptr, ptr0, len0, addHeapObject(query), ptr1);
1230
+ return takeObject(ret);
1231
+ }
1232
+ /**
1233
+ * @returns {Promise<any>}
1234
+ */
1235
+ close() {
1236
+ const ret = wasm.indexdb_close(this.__wbg_ptr);
1237
+ return takeObject(ret);
1238
+ }
1239
+ /**
1240
+ * @returns {Promise<any>}
1241
+ */
1242
+ start() {
1243
+ const ret = wasm.indexdb_start(this.__wbg_ptr);
1244
+ return takeObject(ret);
1245
+ }
1246
+ };
1247
+ var OperationFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
1248
+ }, unregister: () => {
1249
+ } } : new FinalizationRegistry((ptr) => wasm.__wbg_operation_free(ptr >>> 0));
1250
+ var Operation2 = class _Operation {
1251
+ static __wrap(ptr) {
1252
+ ptr = ptr >>> 0;
1253
+ const obj = Object.create(_Operation.prototype);
1254
+ obj.__wbg_ptr = ptr;
1255
+ OperationFinalization.register(obj, obj.__wbg_ptr, obj);
1256
+ return obj;
1257
+ }
1258
+ __destroy_into_raw() {
1259
+ const ptr = this.__wbg_ptr;
1260
+ this.__wbg_ptr = 0;
1261
+ OperationFinalization.unregister(this);
1262
+ return ptr;
1263
+ }
1264
+ free() {
1265
+ const ptr = this.__destroy_into_raw();
1266
+ wasm.__wbg_operation_free(ptr);
1267
+ }
1268
+ /**
1269
+ * Retrieves the name of the collection.
1270
+ *
1271
+ * # Returns
1272
+ *
1273
+ * * `String` - The name of the collection.
1274
+ * @returns {string}
1275
+ */
1276
+ get collection() {
1277
+ let deferred1_0;
1278
+ let deferred1_1;
1279
+ try {
1280
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1281
+ wasm.operation_collection(retptr, this.__wbg_ptr);
1282
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1283
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1284
+ deferred1_0 = r0;
1285
+ deferred1_1 = r1;
1286
+ return getStringFromWasm0(r0, r1);
1287
+ } finally {
1288
+ wasm.__wbindgen_add_to_stack_pointer(16);
1289
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1290
+ }
1291
+ }
1292
+ /**
1293
+ * Retrieves the type of operation.
1294
+ *
1295
+ * # Returns
1296
+ *
1297
+ * * `OpType` - The type of operation.
1298
+ * @returns {OpType}
1299
+ */
1300
+ get opType() {
1301
+ const ret = wasm.operation_opType(this.__wbg_ptr);
1302
+ return ret;
1303
+ }
1304
+ /**
1305
+ * Retrieves the data involved in the operation.
1306
+ *
1307
+ * # Returns
1308
+ *
1309
+ * * `JsValue` - The data involved in the operation.
1310
+ * @returns {any}
1311
+ */
1312
+ get data() {
1313
+ const ret = wasm.operation_data(this.__wbg_ptr);
1314
+ return takeObject(ret);
1315
+ }
1316
+ /**
1317
+ * Retrieves the primary key field of the current collection.
1318
+ *
1319
+ * # Returns
1320
+ *
1321
+ * * `Option<String>` - The primary key field of the current collection.
1322
+ * @returns {any}
1323
+ */
1324
+ get primaryKeyField() {
1325
+ const ret = wasm.operation_primaryKeyField(this.__wbg_ptr);
1326
+ return takeObject(ret);
1327
+ }
1328
+ /**
1329
+ * Retrieves the primary key value of the current data.
1330
+ *
1331
+ * # Returns
1332
+ *
1333
+ * * `Option<JsValue>` - The primary key value of the current data.
1334
+ * @returns {any}
1335
+ */
1336
+ get primaryKey() {
1337
+ const ret = wasm.operation_primaryKey(this.__wbg_ptr);
1338
+ return takeObject(ret);
1339
+ }
1340
+ /**
1341
+ * @returns {string}
1342
+ */
1343
+ get primaryKeyIndex() {
1344
+ let deferred2_0;
1345
+ let deferred2_1;
1346
+ try {
1347
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1348
+ wasm.operation_primaryKeyIndex(retptr, this.__wbg_ptr);
1349
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1350
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1351
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
1352
+ var r3 = getInt32Memory0()[retptr / 4 + 3];
1353
+ var ptr1 = r0;
1354
+ var len1 = r1;
1355
+ if (r3) {
1356
+ ptr1 = 0;
1357
+ len1 = 0;
1358
+ throw takeObject(r2);
1359
+ }
1360
+ deferred2_0 = ptr1;
1361
+ deferred2_1 = len1;
1362
+ return getStringFromWasm0(ptr1, len1);
1363
+ } finally {
1364
+ wasm.__wbindgen_add_to_stack_pointer(16);
1365
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
1366
+ }
1367
+ }
1368
+ };
1369
+ var PropertyFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
1370
+ }, unregister: () => {
1371
+ } } : new FinalizationRegistry((ptr) => wasm.__wbg_property_free(ptr >>> 0));
1372
+ var Property = class {
1373
+ __destroy_into_raw() {
1374
+ const ptr = this.__wbg_ptr;
1375
+ this.__wbg_ptr = 0;
1376
+ PropertyFinalization.unregister(this);
1377
+ return ptr;
1378
+ }
1379
+ free() {
1380
+ const ptr = this.__destroy_into_raw();
1381
+ wasm.__wbg_property_free(ptr);
1382
+ }
1383
+ /**
1384
+ * Checks is the schema is valid.
1385
+ *
1386
+ * # Returns
1387
+ *
1388
+ * Throws exception if not valid
1389
+ * @returns {boolean}
1390
+ */
1391
+ is_valid() {
1392
+ try {
1393
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1394
+ wasm.property_is_valid(retptr, this.__wbg_ptr);
1395
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1396
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1397
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
1398
+ if (r2) {
1399
+ throw takeObject(r1);
1400
+ }
1401
+ return r0 !== 0;
1402
+ } finally {
1403
+ wasm.__wbindgen_add_to_stack_pointer(16);
1404
+ }
1405
+ }
1406
+ /**
1407
+ * Retrieves the type of the property.
1408
+ *
1409
+ * # Returns
1410
+ *
1411
+ * * `PropertyType` - The type of the property.
1412
+ * @returns {any}
1413
+ */
1414
+ get type() {
1415
+ const ret = wasm.property_type(this.__wbg_ptr);
1416
+ return takeObject(ret);
1417
+ }
1418
+ /**
1419
+ * Retrieves the items of the property.
1420
+ *
1421
+ * # Returns
1422
+ *
1423
+ * * `Result<JsValue, JsValue>` - A result containing the items as a `JsValue` or an error.
1424
+ * @returns {any}
1425
+ */
1426
+ get items() {
1427
+ try {
1428
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1429
+ wasm.property_items(retptr, this.__wbg_ptr);
1430
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1431
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1432
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
1433
+ if (r2) {
1434
+ throw takeObject(r1);
1435
+ }
1436
+ return takeObject(r0);
1437
+ } finally {
1438
+ wasm.__wbindgen_add_to_stack_pointer(16);
1439
+ }
1440
+ }
1441
+ /**
1442
+ * Retrieves the maximum number of items of the property.
1443
+ *
1444
+ * # Returns
1445
+ *
1446
+ * * `Result<JsValue, JsValue>` - A result containing the maximum number of items as a `JsValue` or an error.
1447
+ * @returns {any}
1448
+ */
1449
+ get maxItems() {
1450
+ try {
1451
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1452
+ wasm.property_maxItems(retptr, this.__wbg_ptr);
1453
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1454
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1455
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
1456
+ if (r2) {
1457
+ throw takeObject(r1);
1458
+ }
1459
+ return takeObject(r0);
1460
+ } finally {
1461
+ wasm.__wbindgen_add_to_stack_pointer(16);
1462
+ }
1463
+ }
1464
+ /**
1465
+ * Retrieves the minimum number of items of the property.
1466
+ *
1467
+ * # Returns
1468
+ *
1469
+ * * `Result<JsValue, JsValue>` - A result containing the minimum number of items as a `JsValue` or an error.
1470
+ * @returns {any}
1471
+ */
1472
+ get minItems() {
1473
+ try {
1474
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1475
+ wasm.property_minItems(retptr, this.__wbg_ptr);
1476
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1477
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1478
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
1479
+ if (r2) {
1480
+ throw takeObject(r1);
1481
+ }
1482
+ return takeObject(r0);
1483
+ } finally {
1484
+ wasm.__wbindgen_add_to_stack_pointer(16);
1485
+ }
1486
+ }
1487
+ /**
1488
+ * Retrieves the maximum length of the property.
1489
+ *
1490
+ * # Returns
1491
+ *
1492
+ * * `Result<JsValue, JsValue>` - A result containing the maximum length as a `JsValue` or an error.
1493
+ * @returns {any}
1494
+ */
1495
+ get maxLength() {
1496
+ try {
1497
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1498
+ wasm.property_maxLength(retptr, this.__wbg_ptr);
1499
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1500
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1501
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
1502
+ if (r2) {
1503
+ throw takeObject(r1);
1504
+ }
1505
+ return takeObject(r0);
1506
+ } finally {
1507
+ wasm.__wbindgen_add_to_stack_pointer(16);
1508
+ }
1509
+ }
1510
+ /**
1511
+ * Retrieves the minimum length of the property.
1512
+ *
1513
+ * # Returns
1514
+ *
1515
+ * * `Result<JsValue, JsValue>` - A result containing the minimum length as a `JsValue` or an error.
1516
+ * @returns {any}
1517
+ */
1518
+ get minLength() {
1519
+ try {
1520
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1521
+ wasm.property_minLength(retptr, this.__wbg_ptr);
1522
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1523
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1524
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
1525
+ if (r2) {
1526
+ throw takeObject(r1);
1527
+ }
1528
+ return takeObject(r0);
1529
+ } finally {
1530
+ wasm.__wbindgen_add_to_stack_pointer(16);
1531
+ }
1532
+ }
1533
+ /**
1534
+ * Retrieves the nested properties of the property.
1535
+ *
1536
+ * # Returns
1537
+ *
1538
+ * * `Result<JsValue, JsValue>` - A result containing the nested properties as a `JsValue` or an error.
1539
+ * @returns {any}
1540
+ */
1541
+ get properties() {
1542
+ try {
1543
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1544
+ wasm.property_properties(retptr, this.__wbg_ptr);
1545
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1546
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1547
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
1548
+ if (r2) {
1549
+ throw takeObject(r1);
1550
+ }
1551
+ return takeObject(r0);
1552
+ } finally {
1553
+ wasm.__wbindgen_add_to_stack_pointer(16);
1554
+ }
1555
+ }
1556
+ };
1557
+ var QueryFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
1558
+ }, unregister: () => {
1559
+ } } : new FinalizationRegistry((ptr) => wasm.__wbg_query_free(ptr >>> 0));
1560
+ var Query = class {
1561
+ __destroy_into_raw() {
1562
+ const ptr = this.__wbg_ptr;
1563
+ this.__wbg_ptr = 0;
1564
+ QueryFinalization.unregister(this);
1565
+ return ptr;
1566
+ }
1567
+ free() {
1568
+ const ptr = this.__destroy_into_raw();
1569
+ wasm.__wbg_query_free(ptr);
1570
+ }
1571
+ /**
1572
+ * @param {any} query
1573
+ * @param {Schema} schema
1574
+ */
1575
+ constructor(query, schema) {
1576
+ try {
1577
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1578
+ _assertClass(schema, Schema);
1579
+ var ptr0 = schema.__destroy_into_raw();
1580
+ wasm.query_new(retptr, addHeapObject(query), ptr0);
1581
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1582
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1583
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
1584
+ if (r2) {
1585
+ throw takeObject(r1);
1586
+ }
1587
+ this.__wbg_ptr = r0 >>> 0;
1588
+ return this;
1589
+ } finally {
1590
+ wasm.__wbindgen_add_to_stack_pointer(16);
1591
+ }
1592
+ }
1593
+ /**
1594
+ * @returns {any}
1595
+ */
1596
+ get query() {
1597
+ try {
1598
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1599
+ wasm.query_query(retptr, this.__wbg_ptr);
1600
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1601
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1602
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
1603
+ if (r2) {
1604
+ throw takeObject(r1);
1605
+ }
1606
+ return takeObject(r0);
1607
+ } finally {
1608
+ wasm.__wbindgen_add_to_stack_pointer(16);
1609
+ }
1610
+ }
1611
+ /**
1612
+ * Returns the schema properties (fields) that are used in the query.
1613
+ * The query may contain operators like $and, $or, $gt, $lt, etc.
1614
+ * @returns {(string)[]}
1615
+ */
1616
+ get_properties() {
1617
+ try {
1618
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1619
+ wasm.query_get_properties(retptr, this.__wbg_ptr);
1620
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1621
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1622
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
1623
+ var r3 = getInt32Memory0()[retptr / 4 + 3];
1624
+ if (r3) {
1625
+ throw takeObject(r2);
1626
+ }
1627
+ var v1 = getArrayJsValueFromWasm0(r0, r1).slice();
1628
+ wasm.__wbindgen_free(r0, r1 * 4, 4);
1629
+ return v1;
1630
+ } finally {
1631
+ wasm.__wbindgen_add_to_stack_pointer(16);
1632
+ }
1633
+ }
1634
+ /**
1635
+ * @returns {any}
1636
+ */
1637
+ parse() {
1638
+ try {
1639
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1640
+ wasm.query_parse(retptr, this.__wbg_ptr);
1641
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1642
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1643
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
1644
+ if (r2) {
1645
+ throw takeObject(r1);
1646
+ }
1647
+ return takeObject(r0);
1648
+ } finally {
1649
+ wasm.__wbindgen_add_to_stack_pointer(16);
1650
+ }
1651
+ }
1652
+ /**
1653
+ * @param {any} query
1654
+ * @returns {any}
1655
+ */
1656
+ process_query(query) {
1657
+ try {
1658
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1659
+ wasm.query_process_query(retptr, this.__wbg_ptr, addBorrowedObject(query));
1660
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1661
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1662
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
1663
+ if (r2) {
1664
+ throw takeObject(r1);
1665
+ }
1666
+ return takeObject(r0);
1667
+ } finally {
1668
+ wasm.__wbindgen_add_to_stack_pointer(16);
1669
+ heap[stack_pointer++] = void 0;
1670
+ }
1671
+ }
1672
+ /**
1673
+ * Returns the value of a property from the (normalized) query by its name.
1674
+ * This will scan the normalized query structure (including arrays, $and/$or blocks, etc.)
1675
+ * to find the first occurrence of the given property name and return its corresponding value.
1676
+ *
1677
+ * If not found, an error is returned.
1678
+ *
1679
+ * Example:
1680
+ * let val = query.get("age")?;
1681
+ * // val is a JsValue that might be a number, string, boolean, array, or object (e.g., { "$gt": 30 })
1682
+ * @param {string} property_name
1683
+ * @returns {any}
1684
+ */
1685
+ get(property_name) {
1686
+ try {
1687
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1688
+ const ptr0 = passStringToWasm0(property_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1689
+ const len0 = WASM_VECTOR_LEN;
1690
+ wasm.query_get(retptr, this.__wbg_ptr, ptr0, len0);
1691
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1692
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1693
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
1694
+ if (r2) {
1695
+ throw takeObject(r1);
1696
+ }
1697
+ return takeObject(r0);
1698
+ } finally {
1699
+ wasm.__wbindgen_add_to_stack_pointer(16);
1700
+ }
1701
+ }
1702
+ };
1703
+ var QueryOptionsFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
1704
+ }, unregister: () => {
1705
+ } } : new FinalizationRegistry((ptr) => wasm.__wbg_queryoptions_free(ptr >>> 0));
1706
+ var QueryOptions2 = class _QueryOptions {
1707
+ static __wrap(ptr) {
1708
+ ptr = ptr >>> 0;
1709
+ const obj = Object.create(_QueryOptions.prototype);
1710
+ obj.__wbg_ptr = ptr;
1711
+ QueryOptionsFinalization.register(obj, obj.__wbg_ptr, obj);
1712
+ return obj;
1713
+ }
1714
+ __destroy_into_raw() {
1715
+ const ptr = this.__wbg_ptr;
1716
+ this.__wbg_ptr = 0;
1717
+ QueryOptionsFinalization.unregister(this);
1718
+ return ptr;
1719
+ }
1720
+ free() {
1721
+ const ptr = this.__destroy_into_raw();
1722
+ wasm.__wbg_queryoptions_free(ptr);
1723
+ }
1724
+ /**
1725
+ * @returns {any}
1726
+ */
1727
+ get limit() {
1728
+ try {
1729
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1730
+ wasm.queryoptions_limit(retptr, this.__wbg_ptr);
1731
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1732
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1733
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
1734
+ if (r2) {
1735
+ throw takeObject(r1);
1736
+ }
1737
+ return takeObject(r0);
1738
+ } finally {
1739
+ wasm.__wbindgen_add_to_stack_pointer(16);
1740
+ }
1741
+ }
1742
+ /**
1743
+ * @returns {any}
1744
+ */
1745
+ get offset() {
1746
+ try {
1747
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1748
+ wasm.queryoptions_offset(retptr, this.__wbg_ptr);
1749
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1750
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1751
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
1752
+ if (r2) {
1753
+ throw takeObject(r1);
1754
+ }
1755
+ return takeObject(r0);
1756
+ } finally {
1757
+ wasm.__wbindgen_add_to_stack_pointer(16);
1758
+ }
1759
+ }
1760
+ };
1761
+ var RIDBErrorFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
1762
+ }, unregister: () => {
1763
+ } } : new FinalizationRegistry((ptr) => wasm.__wbg_ridberror_free(ptr >>> 0));
1764
+ var RIDBError = class _RIDBError {
1765
+ static __wrap(ptr) {
1766
+ ptr = ptr >>> 0;
1767
+ const obj = Object.create(_RIDBError.prototype);
1768
+ obj.__wbg_ptr = ptr;
1769
+ RIDBErrorFinalization.register(obj, obj.__wbg_ptr, obj);
1770
+ return obj;
1771
+ }
1772
+ toJSON() {
1773
+ return {
1774
+ type: this.type,
1775
+ code: this.code,
1776
+ message: this.message
1777
+ };
1778
+ }
1779
+ toString() {
1780
+ return JSON.stringify(this);
1781
+ }
1782
+ __destroy_into_raw() {
1783
+ const ptr = this.__wbg_ptr;
1784
+ this.__wbg_ptr = 0;
1785
+ RIDBErrorFinalization.unregister(this);
1786
+ return ptr;
1787
+ }
1788
+ free() {
1789
+ const ptr = this.__destroy_into_raw();
1790
+ wasm.__wbg_ridberror_free(ptr);
1791
+ }
1792
+ /**
1793
+ * @param {string} err_type
1794
+ * @param {string} message
1795
+ * @param {number} code
1796
+ */
1797
+ constructor(err_type, message, code) {
1798
+ const ptr0 = passStringToWasm0(err_type, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1799
+ const len0 = WASM_VECTOR_LEN;
1800
+ const ptr1 = passStringToWasm0(message, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1801
+ const len1 = WASM_VECTOR_LEN;
1802
+ const ret = wasm.ridberror_new(ptr0, len0, ptr1, len1, code);
1803
+ this.__wbg_ptr = ret >>> 0;
1804
+ return this;
1805
+ }
1806
+ /**
1807
+ * @returns {string}
1808
+ */
1809
+ get type() {
1810
+ let deferred1_0;
1811
+ let deferred1_1;
1812
+ try {
1813
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1814
+ wasm.ridberror_type(retptr, this.__wbg_ptr);
1815
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1816
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1817
+ deferred1_0 = r0;
1818
+ deferred1_1 = r1;
1819
+ return getStringFromWasm0(r0, r1);
1820
+ } finally {
1821
+ wasm.__wbindgen_add_to_stack_pointer(16);
1822
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1823
+ }
1824
+ }
1825
+ /**
1826
+ * @returns {any}
1827
+ */
1828
+ get code() {
1829
+ const ret = wasm.ridberror_code(this.__wbg_ptr);
1830
+ return takeObject(ret);
1831
+ }
1832
+ /**
1833
+ * @returns {string}
1834
+ */
1835
+ get message() {
1836
+ let deferred1_0;
1837
+ let deferred1_1;
1838
+ try {
1839
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1840
+ wasm.ridberror_message(retptr, this.__wbg_ptr);
1841
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1842
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1843
+ deferred1_0 = r0;
1844
+ deferred1_1 = r1;
1845
+ return getStringFromWasm0(r0, r1);
1846
+ } finally {
1847
+ wasm.__wbindgen_add_to_stack_pointer(16);
1848
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1849
+ }
1850
+ }
1851
+ /**
1852
+ * @param {any} err
1853
+ * @returns {RIDBError}
1854
+ */
1855
+ static from(err) {
1856
+ const ret = wasm.ridberror_from(addHeapObject(err));
1857
+ return _RIDBError.__wrap(ret);
1858
+ }
1859
+ /**
1860
+ * @param {string} err
1861
+ * @param {number} code
1862
+ * @returns {RIDBError}
1863
+ */
1864
+ static error(err, code) {
1865
+ const ptr0 = passStringToWasm0(err, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1866
+ const len0 = WASM_VECTOR_LEN;
1867
+ const ret = wasm.ridberror_error(ptr0, len0, code);
1868
+ return _RIDBError.__wrap(ret);
1869
+ }
1870
+ /**
1871
+ * @param {string} err
1872
+ * @param {number} code
1873
+ * @returns {RIDBError}
1874
+ */
1875
+ static query(err, code) {
1876
+ const ptr0 = passStringToWasm0(err, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1877
+ const len0 = WASM_VECTOR_LEN;
1878
+ const ret = wasm.ridberror_query(ptr0, len0, code);
1879
+ return _RIDBError.__wrap(ret);
1880
+ }
1881
+ /**
1882
+ * @param {string} err
1883
+ * @param {number} code
1884
+ * @returns {RIDBError}
1885
+ */
1886
+ static authentication(err, code) {
1887
+ const ptr0 = passStringToWasm0(err, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1888
+ const len0 = WASM_VECTOR_LEN;
1889
+ const ret = wasm.ridberror_authentication(ptr0, len0, code);
1890
+ return _RIDBError.__wrap(ret);
1891
+ }
1892
+ /**
1893
+ * @param {string} err
1894
+ * @param {number} code
1895
+ * @returns {RIDBError}
1896
+ */
1897
+ static serialisation(err, code) {
1898
+ const ptr0 = passStringToWasm0(err, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1899
+ const len0 = WASM_VECTOR_LEN;
1900
+ const ret = wasm.ridberror_serialisation(ptr0, len0, code);
1901
+ return _RIDBError.__wrap(ret);
1902
+ }
1903
+ /**
1904
+ * @param {string} err
1905
+ * @param {number} code
1906
+ * @returns {RIDBError}
1907
+ */
1908
+ static validation(err, code) {
1909
+ const ptr0 = passStringToWasm0(err, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1910
+ const len0 = WASM_VECTOR_LEN;
1911
+ const ret = wasm.ridberror_validation(ptr0, len0, code);
1912
+ return _RIDBError.__wrap(ret);
1913
+ }
1914
+ /**
1915
+ * @param {string} err
1916
+ * @param {number} code
1917
+ * @returns {RIDBError}
1918
+ */
1919
+ static hook(err, code) {
1920
+ const ptr0 = passStringToWasm0(err, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1921
+ const len0 = WASM_VECTOR_LEN;
1922
+ const ret = wasm.ridberror_hook(ptr0, len0, code);
1923
+ return _RIDBError.__wrap(ret);
1924
+ }
1925
+ };
1926
+ var SchemaFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
1927
+ }, unregister: () => {
1928
+ } } : new FinalizationRegistry((ptr) => wasm.__wbg_schema_free(ptr >>> 0));
1929
+ var Schema = class _Schema {
1930
+ static __wrap(ptr) {
1931
+ ptr = ptr >>> 0;
1932
+ const obj = Object.create(_Schema.prototype);
1933
+ obj.__wbg_ptr = ptr;
1934
+ SchemaFinalization.register(obj, obj.__wbg_ptr, obj);
1935
+ return obj;
1936
+ }
1937
+ __destroy_into_raw() {
1938
+ const ptr = this.__wbg_ptr;
1939
+ this.__wbg_ptr = 0;
1940
+ SchemaFinalization.unregister(this);
1941
+ return ptr;
1942
+ }
1943
+ free() {
1944
+ const ptr = this.__destroy_into_raw();
1945
+ wasm.__wbg_schema_free(ptr);
1946
+ }
1947
+ /**
1948
+ * @param {any} document
1949
+ */
1950
+ validate(document2) {
1951
+ try {
1952
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1953
+ wasm.schema_validate(retptr, this.__wbg_ptr, addHeapObject(document2));
1954
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1955
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1956
+ if (r1) {
1957
+ throw takeObject(r0);
1958
+ }
1959
+ } finally {
1960
+ wasm.__wbindgen_add_to_stack_pointer(16);
1961
+ }
1962
+ }
1963
+ /**
1964
+ * @returns {boolean}
1965
+ */
1966
+ is_valid() {
1967
+ try {
1968
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1969
+ wasm.schema_is_valid(retptr, this.__wbg_ptr);
1970
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1971
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1972
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
1973
+ if (r2) {
1974
+ throw takeObject(r1);
1975
+ }
1976
+ return r0 !== 0;
1977
+ } finally {
1978
+ wasm.__wbindgen_add_to_stack_pointer(16);
1979
+ }
1980
+ }
1981
+ /**
1982
+ * Creates a new `Schema` instance from a given `JsValue`.
1983
+ *
1984
+ * # Arguments
1985
+ *
1986
+ * * `schema` - A `JsValue` representing the schema.
1987
+ *
1988
+ * # Returns
1989
+ *
1990
+ * * `Result<Schema, JsValue>` - A result containing the new `Schema` instance or an error.
1991
+ * @param {any} schema
1992
+ * @returns {Schema}
1993
+ */
1994
+ static create(schema) {
1995
+ try {
1996
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1997
+ wasm.schema_create(retptr, addHeapObject(schema));
1998
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1999
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
2000
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
2001
+ if (r2) {
2002
+ throw takeObject(r1);
2003
+ }
2004
+ return _Schema.__wrap(r0);
2005
+ } finally {
2006
+ wasm.__wbindgen_add_to_stack_pointer(16);
2007
+ }
2008
+ }
2009
+ /**
2010
+ * Retrieves the version of the schema.
2011
+ *
2012
+ * # Returns
2013
+ *
2014
+ * * `i32` - The version of the schema.
2015
+ * @returns {number}
2016
+ */
2017
+ get version() {
2018
+ const ret = wasm.schema_version(this.__wbg_ptr);
2019
+ return ret;
2020
+ }
2021
+ /**
2022
+ * Retrieves the primary key of the schema.
2023
+ *
2024
+ * # Returns
2025
+ *
2026
+ * * `String` - The primary key of the schema.
2027
+ * @returns {string}
2028
+ */
2029
+ get primaryKey() {
2030
+ let deferred1_0;
2031
+ let deferred1_1;
2032
+ try {
2033
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2034
+ wasm.schema_primaryKey(retptr, this.__wbg_ptr);
2035
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
2036
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
2037
+ deferred1_0 = r0;
2038
+ deferred1_1 = r1;
2039
+ return getStringFromWasm0(r0, r1);
2040
+ } finally {
2041
+ wasm.__wbindgen_add_to_stack_pointer(16);
2042
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
2043
+ }
2044
+ }
2045
+ /**
2046
+ * Retrieves the type of the schema.
2047
+ *
2048
+ * # Returns
2049
+ *
2050
+ * * `String` - The type of the schema.
2051
+ * @returns {string}
2052
+ */
2053
+ get type() {
2054
+ let deferred1_0;
2055
+ let deferred1_1;
2056
+ try {
2057
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2058
+ wasm.schema_type(retptr, this.__wbg_ptr);
2059
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
2060
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
2061
+ deferred1_0 = r0;
2062
+ deferred1_1 = r1;
2063
+ return getStringFromWasm0(r0, r1);
2064
+ } finally {
2065
+ wasm.__wbindgen_add_to_stack_pointer(16);
2066
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
2067
+ }
2068
+ }
2069
+ /**
2070
+ * Retrieves the indexes of the schema, if any.
2071
+ *
2072
+ * # Returns
2073
+ *
2074
+ * * `Option<Vec<String>>` - The indexes of the schema, if any.
2075
+ * @returns {(string)[] | undefined}
2076
+ */
2077
+ get indexes() {
2078
+ try {
2079
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2080
+ wasm.schema_indexes(retptr, this.__wbg_ptr);
2081
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
2082
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
2083
+ let v1;
2084
+ if (r0 !== 0) {
2085
+ v1 = getArrayJsValueFromWasm0(r0, r1).slice();
2086
+ wasm.__wbindgen_free(r0, r1 * 4, 4);
2087
+ }
2088
+ return v1;
2089
+ } finally {
2090
+ wasm.__wbindgen_add_to_stack_pointer(16);
2091
+ }
2092
+ }
2093
+ /**
2094
+ * @returns {(string)[] | undefined}
2095
+ */
2096
+ get encrypted() {
2097
+ try {
2098
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2099
+ wasm.schema_encrypted(retptr, this.__wbg_ptr);
2100
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
2101
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
2102
+ let v1;
2103
+ if (r0 !== 0) {
2104
+ v1 = getArrayJsValueFromWasm0(r0, r1).slice();
2105
+ wasm.__wbindgen_free(r0, r1 * 4, 4);
2106
+ }
2107
+ return v1;
2108
+ } finally {
2109
+ wasm.__wbindgen_add_to_stack_pointer(16);
2110
+ }
2111
+ }
2112
+ /**
2113
+ * Retrieves the properties of the schema.
2114
+ *
2115
+ * # Returns
2116
+ *
2117
+ * * `Result<JsValue, JsValue>` - A result containing the properties as a `JsValue` or an error.
2118
+ * @returns {any}
2119
+ */
2120
+ get properties() {
2121
+ try {
2122
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2123
+ wasm.schema_properties(retptr, this.__wbg_ptr);
2124
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
2125
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
2126
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
2127
+ if (r2) {
2128
+ throw takeObject(r1);
2129
+ }
2130
+ return takeObject(r0);
2131
+ } finally {
2132
+ wasm.__wbindgen_add_to_stack_pointer(16);
2133
+ }
2134
+ }
2135
+ };
2136
+ var WasmBindgenTestContextFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
2137
+ }, unregister: () => {
2138
+ } } : new FinalizationRegistry((ptr) => wasm.__wbg_wasmbindgentestcontext_free(ptr >>> 0));
2139
+ var WasmBindgenTestContext = class {
2140
+ __destroy_into_raw() {
2141
+ const ptr = this.__wbg_ptr;
2142
+ this.__wbg_ptr = 0;
2143
+ WasmBindgenTestContextFinalization.unregister(this);
2144
+ return ptr;
2145
+ }
2146
+ free() {
2147
+ const ptr = this.__destroy_into_raw();
2148
+ wasm.__wbg_wasmbindgentestcontext_free(ptr);
2149
+ }
2150
+ /**
2151
+ * Creates a new context ready to run tests.
2152
+ *
2153
+ * A `Context` is the main structure through which test execution is
2154
+ * coordinated, and this will collect output and results for all executed
2155
+ * tests.
2156
+ */
2157
+ constructor() {
2158
+ const ret = wasm.wasmbindgentestcontext_new();
2159
+ this.__wbg_ptr = ret >>> 0;
2160
+ return this;
2161
+ }
2162
+ /**
2163
+ * Inform this context about runtime arguments passed to the test
2164
+ * harness.
2165
+ * @param {any[]} args
2166
+ */
2167
+ args(args) {
2168
+ const ptr0 = passArrayJsValueToWasm0(args, wasm.__wbindgen_malloc);
2169
+ const len0 = WASM_VECTOR_LEN;
2170
+ wasm.wasmbindgentestcontext_args(this.__wbg_ptr, ptr0, len0);
2171
+ }
2172
+ /**
2173
+ * Executes a list of tests, returning a promise representing their
2174
+ * eventual completion.
2175
+ *
2176
+ * This is the main entry point for executing tests. All the tests passed
2177
+ * in are the JS `Function` object that was plucked off the
2178
+ * `WebAssembly.Instance` exports list.
2179
+ *
2180
+ * The promise returned resolves to either `true` if all tests passed or
2181
+ * `false` if at least one test failed.
2182
+ * @param {any[]} tests
2183
+ * @returns {Promise<any>}
2184
+ */
2185
+ run(tests) {
2186
+ const ptr0 = passArrayJsValueToWasm0(tests, wasm.__wbindgen_malloc);
2187
+ const len0 = WASM_VECTOR_LEN;
2188
+ const ret = wasm.wasmbindgentestcontext_run(this.__wbg_ptr, ptr0, len0);
2189
+ return takeObject(ret);
2190
+ }
2191
+ };
2192
+ async function __wbg_load(module22, imports) {
2193
+ if (typeof Response === "function" && module22 instanceof Response) {
2194
+ if (typeof WebAssembly.instantiateStreaming === "function") {
2195
+ try {
2196
+ return await WebAssembly.instantiateStreaming(module22, imports);
2197
+ } catch (e) {
2198
+ if (module22.headers.get("Content-Type") != "application/wasm") {
2199
+ 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);
2200
+ } else {
2201
+ throw e;
2202
+ }
2203
+ }
2204
+ }
2205
+ const bytes = await module22.arrayBuffer();
2206
+ return await WebAssembly.instantiate(bytes, imports);
2207
+ } else {
2208
+ const instance = await WebAssembly.instantiate(module22, imports);
2209
+ if (instance instanceof WebAssembly.Instance) {
2210
+ return { instance, module: module22 };
2211
+ } else {
2212
+ return instance;
2213
+ }
2214
+ }
2215
+ }
2216
+ function __wbg_get_imports() {
2217
+ const imports = {};
2218
+ imports.wbg = {};
2219
+ imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
2220
+ takeObject(arg0);
2221
+ };
2222
+ imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
2223
+ const ret = getStringFromWasm0(arg0, arg1);
2224
+ return addHeapObject(ret);
2225
+ };
2226
+ imports.wbg.__wbg_ridberror_new = function(arg0) {
2227
+ const ret = RIDBError.__wrap(arg0);
2228
+ return addHeapObject(ret);
2229
+ };
2230
+ imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
2231
+ const ret = getObject(arg0);
2232
+ return addHeapObject(ret);
2233
+ };
2234
+ imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
2235
+ const obj = getObject(arg1);
2236
+ const ret = typeof obj === "string" ? obj : void 0;
2237
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2238
+ var len1 = WASM_VECTOR_LEN;
2239
+ getInt32Memory0()[arg0 / 4 + 1] = len1;
2240
+ getInt32Memory0()[arg0 / 4 + 0] = ptr1;
2241
+ };
2242
+ imports.wbg.__wbindgen_is_undefined = function(arg0) {
2243
+ const ret = getObject(arg0) === void 0;
2244
+ return ret;
2245
+ };
2246
+ imports.wbg.__wbindgen_number_new = function(arg0) {
2247
+ const ret = arg0;
2248
+ return addHeapObject(ret);
2249
+ };
2250
+ imports.wbg.__wbg_apply_9f557eba1534d597 = function() {
2251
+ return handleError(function(arg0, arg1, arg2) {
2252
+ const ret = getObject(arg1).apply(takeObject(arg2));
2253
+ const ptr1 = passArrayJsValueToWasm0(ret, wasm.__wbindgen_malloc);
2254
+ const len1 = WASM_VECTOR_LEN;
2255
+ getInt32Memory0()[arg0 / 4 + 1] = len1;
2256
+ getInt32Memory0()[arg0 / 4 + 0] = ptr1;
2257
+ }, arguments);
2258
+ };
2259
+ imports.wbg.__wbg_inmemory_new = function(arg0) {
2260
+ const ret = InMemory.__wrap(arg0);
2261
+ return addHeapObject(ret);
2262
+ };
2263
+ imports.wbg.__wbindgen_is_null = function(arg0) {
2264
+ const ret = getObject(arg0) === null;
2265
+ return ret;
2266
+ };
2267
+ imports.wbg.__wbg_close_6384ed3c27ef25c1 = function() {
2268
+ return handleError(function(arg0) {
2269
+ const ret = getObject(arg0).close();
2270
+ return addHeapObject(ret);
2271
+ }, arguments);
2272
+ };
2273
+ imports.wbg.__wbindgen_cb_drop = function(arg0) {
2274
+ const obj = takeObject(arg0).original;
2275
+ if (obj.cnt-- == 1) {
2276
+ obj.a = 0;
2277
+ return true;
2278
+ }
2279
+ const ret = false;
2280
+ return ret;
2281
+ };
2282
+ imports.wbg.__wbg_count_19db4c3174d573d5 = function() {
2283
+ return handleError(function(arg0, arg1, arg2, arg3, arg4) {
2284
+ const ret = getObject(arg0).count(getStringFromWasm0(arg1, arg2), takeObject(arg3), QueryOptions2.__wrap(arg4));
2285
+ return addHeapObject(ret);
2286
+ }, arguments);
2287
+ };
2288
+ imports.wbg.__wbg_start_76c138c3b73ae6f8 = function() {
2289
+ return handleError(function(arg0) {
2290
+ const ret = getObject(arg0).start();
2291
+ return addHeapObject(ret);
2292
+ }, arguments);
2293
+ };
2294
+ imports.wbg.__wbindgen_number_get = function(arg0, arg1) {
2295
+ const obj = getObject(arg1);
2296
+ const ret = typeof obj === "number" ? obj : void 0;
2297
+ getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret;
2298
+ getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
2299
+ };
2300
+ imports.wbg.__wbg_find_567c5c9f064fe3d2 = function() {
2301
+ return handleError(function(arg0, arg1, arg2, arg3, arg4) {
2302
+ const ret = getObject(arg0).find(getStringFromWasm0(arg1, arg2), takeObject(arg3), QueryOptions2.__wrap(arg4));
2303
+ return addHeapObject(ret);
2304
+ }, arguments);
2305
+ };
2306
+ imports.wbg.__wbg_findDocumentById_2edf7350e5f12657 = function() {
2307
+ return handleError(function(arg0, arg1, arg2, arg3) {
2308
+ const ret = getObject(arg0).findDocumentById(getStringFromWasm0(arg1, arg2), takeObject(arg3));
2309
+ return addHeapObject(ret);
2310
+ }, arguments);
2311
+ };
2312
+ imports.wbg.__wbg_write_1159c67c07f62020 = function() {
2313
+ return handleError(function(arg0, arg1) {
2314
+ const ret = getObject(arg0).write(Operation2.__wrap(arg1));
2315
+ return addHeapObject(ret);
2316
+ }, arguments);
2317
+ };
2318
+ imports.wbg.__wbg_indexdb_new = function(arg0) {
2319
+ const ret = IndexDB.__wrap(arg0);
2320
+ return addHeapObject(ret);
2321
+ };
2322
+ imports.wbg.__wbg_database_new = function(arg0) {
2323
+ const ret = Database.__wrap(arg0);
2324
+ return addHeapObject(ret);
2325
+ };
2326
+ imports.wbg.__wbg_collection_new = function(arg0) {
2327
+ const ret = Collection.__wrap(arg0);
2328
+ return addHeapObject(ret);
2329
+ };
2330
+ imports.wbg.__wbindgen_is_object = function(arg0) {
2331
+ const val = getObject(arg0);
2332
+ const ret = typeof val === "object" && val !== null;
2333
+ return ret;
2334
+ };
2335
+ imports.wbg.__wbindgen_is_string = function(arg0) {
2336
+ const ret = typeof getObject(arg0) === "string";
2337
+ return ret;
2338
+ };
2339
+ imports.wbg.__wbindgen_error_new = function(arg0, arg1) {
2340
+ const ret = new Error(getStringFromWasm0(arg0, arg1));
2341
+ return addHeapObject(ret);
2342
+ };
2343
+ imports.wbg.__wbindgen_is_array = function(arg0) {
2344
+ const ret = Array.isArray(getObject(arg0));
2345
+ return ret;
2346
+ };
2347
+ imports.wbg.__wbindgen_boolean_get = function(arg0) {
2348
+ const v = getObject(arg0);
2349
+ const ret = typeof v === "boolean" ? v ? 1 : 0 : 2;
2350
+ return ret;
2351
+ };
2352
+ imports.wbg.__wbindgen_is_falsy = function(arg0) {
2353
+ const ret = !getObject(arg0);
2354
+ return ret;
2355
+ };
2356
+ imports.wbg.__wbindgen_jsval_eq = function(arg0, arg1) {
2357
+ const ret = getObject(arg0) === getObject(arg1);
2358
+ return ret;
2359
+ };
2360
+ imports.wbg.__wbindgen_is_function = function(arg0) {
2361
+ const ret = typeof getObject(arg0) === "function";
2362
+ return ret;
2363
+ };
2364
+ imports.wbg.__wbindgen_is_bigint = function(arg0) {
2365
+ const ret = typeof getObject(arg0) === "bigint";
2366
+ return ret;
2367
+ };
2368
+ imports.wbg.__wbindgen_in = function(arg0, arg1) {
2369
+ const ret = getObject(arg0) in getObject(arg1);
2370
+ return ret;
2371
+ };
2372
+ imports.wbg.__wbindgen_bigint_from_i64 = function(arg0) {
2373
+ const ret = arg0;
2374
+ return addHeapObject(ret);
2375
+ };
2376
+ imports.wbg.__wbindgen_bigint_from_u64 = function(arg0) {
2377
+ const ret = BigInt.asUintN(64, arg0);
2378
+ return addHeapObject(ret);
2379
+ };
2380
+ imports.wbg.__wbg_crypto_1d1f22824a6a080c = function(arg0) {
2381
+ const ret = getObject(arg0).crypto;
2382
+ return addHeapObject(ret);
2383
+ };
2384
+ imports.wbg.__wbg_process_4a72847cc503995b = function(arg0) {
2385
+ const ret = getObject(arg0).process;
2386
+ return addHeapObject(ret);
2387
+ };
2388
+ imports.wbg.__wbg_versions_f686565e586dd935 = function(arg0) {
2389
+ const ret = getObject(arg0).versions;
2390
+ return addHeapObject(ret);
2391
+ };
2392
+ imports.wbg.__wbg_node_104a2ff8d6ea03a2 = function(arg0) {
2393
+ const ret = getObject(arg0).node;
2394
+ return addHeapObject(ret);
2395
+ };
2396
+ imports.wbg.__wbg_require_cca90b1a94a0255b = function() {
2397
+ return handleError(function() {
2398
+ const ret = module2.require;
2399
+ return addHeapObject(ret);
2400
+ }, arguments);
2401
+ };
2402
+ imports.wbg.__wbg_msCrypto_eb05e62b530a1508 = function(arg0) {
2403
+ const ret = getObject(arg0).msCrypto;
2404
+ return addHeapObject(ret);
2405
+ };
2406
+ imports.wbg.__wbg_randomFillSync_5c9c955aa56b6049 = function() {
2407
+ return handleError(function(arg0, arg1) {
2408
+ getObject(arg0).randomFillSync(takeObject(arg1));
2409
+ }, arguments);
2410
+ };
2411
+ imports.wbg.__wbg_getRandomValues_3aa56aa6edec874c = function() {
2412
+ return handleError(function(arg0, arg1) {
2413
+ getObject(arg0).getRandomValues(getObject(arg1));
2414
+ }, arguments);
2415
+ };
2416
+ imports.wbg.__wbg_instanceof_Window_f401953a2cf86220 = function(arg0) {
2417
+ let result;
2418
+ try {
2419
+ result = getObject(arg0) instanceof Window;
2420
+ } catch (_) {
2421
+ result = false;
2422
+ }
2423
+ const ret = result;
2424
+ return ret;
2425
+ };
2426
+ imports.wbg.__wbg_indexedDB_7c51d9056667f4e0 = function() {
2427
+ return handleError(function(arg0) {
2428
+ const ret = getObject(arg0).indexedDB;
2429
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
2430
+ }, arguments);
2431
+ };
2432
+ imports.wbg.__wbg_setTimeout_c172d5704ef82276 = function() {
2433
+ return handleError(function(arg0, arg1, arg2) {
2434
+ const ret = getObject(arg0).setTimeout(getObject(arg1), arg2);
2435
+ return ret;
2436
+ }, arguments);
2437
+ };
2438
+ imports.wbg.__wbg_instanceof_WorkerGlobalScope_46b577f151fad960 = function(arg0) {
2439
+ let result;
2440
+ try {
2441
+ result = getObject(arg0) instanceof WorkerGlobalScope;
2442
+ } catch (_) {
2443
+ result = false;
2444
+ }
2445
+ const ret = result;
2446
+ return ret;
2447
+ };
2448
+ imports.wbg.__wbg_indexedDB_d312f95759a15fdc = function() {
2449
+ return handleError(function(arg0) {
2450
+ const ret = getObject(arg0).indexedDB;
2451
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
2452
+ }, arguments);
2453
+ };
2454
+ imports.wbg.__wbg_setTimeout_8502a960d5dde06e = function() {
2455
+ return handleError(function(arg0, arg1, arg2) {
2456
+ const ret = getObject(arg0).setTimeout(getObject(arg1), arg2);
2457
+ return ret;
2458
+ }, arguments);
2459
+ };
2460
+ imports.wbg.__wbg_debug_5fb96680aecf5dc8 = function(arg0) {
2461
+ console.debug(getObject(arg0));
2462
+ };
2463
+ imports.wbg.__wbg_openCursor_425aba9cbe1d4d39 = function() {
2464
+ return handleError(function(arg0) {
2465
+ const ret = getObject(arg0).openCursor();
2466
+ return addHeapObject(ret);
2467
+ }, arguments);
2468
+ };
2469
+ imports.wbg.__wbg_openCursor_e3042770817a8d57 = function() {
2470
+ return handleError(function(arg0, arg1) {
2471
+ const ret = getObject(arg0).openCursor(getObject(arg1));
2472
+ return addHeapObject(ret);
2473
+ }, arguments);
2474
+ };
2475
+ imports.wbg.__wbg_createIndex_b8da1f5571f644be = function() {
2476
+ return handleError(function(arg0, arg1, arg2, arg3, arg4, arg5) {
2477
+ const ret = getObject(arg0).createIndex(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4), getObject(arg5));
2478
+ return addHeapObject(ret);
2479
+ }, arguments);
2480
+ };
2481
+ imports.wbg.__wbg_delete_f60bba7d0ae59a4f = function() {
2482
+ return handleError(function(arg0, arg1) {
2483
+ const ret = getObject(arg0).delete(getObject(arg1));
2484
+ return addHeapObject(ret);
2485
+ }, arguments);
2486
+ };
2487
+ imports.wbg.__wbg_get_5361b64cac0d0826 = function() {
2488
+ return handleError(function(arg0, arg1) {
2489
+ const ret = getObject(arg0).get(getObject(arg1));
2490
+ return addHeapObject(ret);
2491
+ }, arguments);
2492
+ };
2493
+ imports.wbg.__wbg_index_383b6812c1508030 = function() {
2494
+ return handleError(function(arg0, arg1, arg2) {
2495
+ const ret = getObject(arg0).index(getStringFromWasm0(arg1, arg2));
2496
+ return addHeapObject(ret);
2497
+ }, arguments);
2498
+ };
2499
+ imports.wbg.__wbg_openCursor_30d58ae27a327629 = function() {
2500
+ return handleError(function(arg0) {
2501
+ const ret = getObject(arg0).openCursor();
2502
+ return addHeapObject(ret);
2503
+ }, arguments);
2504
+ };
2505
+ imports.wbg.__wbg_openCursor_611b1e488c393dd8 = function() {
2506
+ return handleError(function(arg0, arg1) {
2507
+ const ret = getObject(arg0).openCursor(getObject(arg1));
2508
+ return addHeapObject(ret);
2509
+ }, arguments);
2510
+ };
2511
+ imports.wbg.__wbg_put_22792e17580ca18b = function() {
2512
+ return handleError(function(arg0, arg1, arg2) {
2513
+ const ret = getObject(arg0).put(getObject(arg1), getObject(arg2));
2514
+ return addHeapObject(ret);
2515
+ }, arguments);
2516
+ };
2517
+ imports.wbg.__wbg_target_2fc177e386c8b7b0 = function(arg0) {
2518
+ const ret = getObject(arg0).target;
2519
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
2520
+ };
2521
+ imports.wbg.__wbg_instanceof_IdbDatabase_db671cf2454a9542 = function(arg0) {
2522
+ let result;
2523
+ try {
2524
+ result = getObject(arg0) instanceof IDBDatabase;
2525
+ } catch (_) {
2526
+ result = false;
2527
+ }
2528
+ const ret = result;
2529
+ return ret;
2530
+ };
2531
+ imports.wbg.__wbg_objectStoreNames_588b5924274239fd = function(arg0) {
2532
+ const ret = getObject(arg0).objectStoreNames;
2533
+ return addHeapObject(ret);
2534
+ };
2535
+ imports.wbg.__wbg_close_6bfe4ca2fe67cb67 = function(arg0) {
2536
+ getObject(arg0).close();
2537
+ };
2538
+ imports.wbg.__wbg_createObjectStore_882f2f6b1b1ef040 = function() {
2539
+ return handleError(function(arg0, arg1, arg2) {
2540
+ const ret = getObject(arg0).createObjectStore(getStringFromWasm0(arg1, arg2));
2541
+ return addHeapObject(ret);
2542
+ }, arguments);
2543
+ };
2544
+ imports.wbg.__wbg_transaction_c32bb10c9c692f4b = function() {
2545
+ return handleError(function(arg0, arg1, arg2) {
2546
+ const ret = getObject(arg0).transaction(getStringFromWasm0(arg1, arg2));
2547
+ return addHeapObject(ret);
2548
+ }, arguments);
2549
+ };
2550
+ imports.wbg.__wbg_transaction_1e282a79e9bb7387 = function() {
2551
+ return handleError(function(arg0, arg1, arg2, arg3) {
2552
+ const ret = getObject(arg0).transaction(getStringFromWasm0(arg1, arg2), takeObject(arg3));
2553
+ return addHeapObject(ret);
2554
+ }, arguments);
2555
+ };
2556
+ imports.wbg.__wbg_objectStore_da468793bd9df17b = function() {
2557
+ return handleError(function(arg0, arg1, arg2) {
2558
+ const ret = getObject(arg0).objectStore(getStringFromWasm0(arg1, arg2));
2559
+ return addHeapObject(ret);
2560
+ }, arguments);
2561
+ };
2562
+ imports.wbg.__wbg_continue_f1c3e0815924de62 = function() {
2563
+ return handleError(function(arg0) {
2564
+ getObject(arg0).continue();
2565
+ }, arguments);
2566
+ };
2567
+ imports.wbg.__wbg_length_9ae5daf9a690cba9 = function(arg0) {
2568
+ const ret = getObject(arg0).length;
2569
+ return ret;
2570
+ };
2571
+ imports.wbg.__wbg_contains_c65b44400b549286 = function(arg0, arg1, arg2) {
2572
+ const ret = getObject(arg0).contains(getStringFromWasm0(arg1, arg2));
2573
+ return ret;
2574
+ };
2575
+ imports.wbg.__wbg_get_910bbb94abdcf488 = function(arg0, arg1, arg2) {
2576
+ const ret = getObject(arg1)[arg2 >>> 0];
2577
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2578
+ var len1 = WASM_VECTOR_LEN;
2579
+ getInt32Memory0()[arg0 / 4 + 1] = len1;
2580
+ getInt32Memory0()[arg0 / 4 + 0] = ptr1;
2581
+ };
2582
+ imports.wbg.__wbg_instanceof_IdbCursorWithValue_abeb44d13d947bc2 = function(arg0) {
2583
+ let result;
2584
+ try {
2585
+ result = getObject(arg0) instanceof IDBCursorWithValue;
2586
+ } catch (_) {
2587
+ result = false;
2588
+ }
2589
+ const ret = result;
2590
+ return ret;
2591
+ };
2592
+ imports.wbg.__wbg_value_86d3334f5075b232 = function() {
2593
+ return handleError(function(arg0) {
2594
+ const ret = getObject(arg0).value;
2595
+ return addHeapObject(ret);
2596
+ }, arguments);
2597
+ };
2598
+ imports.wbg.__wbg_open_f0d7259fd7e689ce = function() {
2599
+ return handleError(function(arg0, arg1, arg2, arg3) {
2600
+ const ret = getObject(arg0).open(getStringFromWasm0(arg1, arg2), arg3 >>> 0);
2601
+ return addHeapObject(ret);
2602
+ }, arguments);
2603
+ };
2604
+ imports.wbg.__wbg_only_cacf767244bdc280 = function() {
2605
+ return handleError(function(arg0) {
2606
+ const ret = IDBKeyRange.only(getObject(arg0));
2607
+ return addHeapObject(ret);
2608
+ }, arguments);
2609
+ };
2610
+ imports.wbg.__wbg_instanceof_IdbOpenDbRequest_3f4a166bc0340578 = function(arg0) {
2611
+ let result;
2612
+ try {
2613
+ result = getObject(arg0) instanceof IDBOpenDBRequest;
2614
+ } catch (_) {
2615
+ result = false;
2616
+ }
2617
+ const ret = result;
2618
+ return ret;
2619
+ };
2620
+ imports.wbg.__wbg_setonupgradeneeded_ad7645373c7d5e1b = function(arg0, arg1) {
2621
+ getObject(arg0).onupgradeneeded = getObject(arg1);
2622
+ };
2623
+ imports.wbg.__wbg_instanceof_IdbRequest_93249da04f5370b6 = function(arg0) {
2624
+ let result;
2625
+ try {
2626
+ result = getObject(arg0) instanceof IDBRequest;
2627
+ } catch (_) {
2628
+ result = false;
2629
+ }
2630
+ const ret = result;
2631
+ return ret;
2632
+ };
2633
+ imports.wbg.__wbg_result_6cedf5f78600a79c = function() {
2634
+ return handleError(function(arg0) {
2635
+ const ret = getObject(arg0).result;
2636
+ return addHeapObject(ret);
2637
+ }, arguments);
2638
+ };
2639
+ imports.wbg.__wbg_error_685b20024dc2d6ca = function() {
2640
+ return handleError(function(arg0) {
2641
+ const ret = getObject(arg0).error;
2642
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
2643
+ }, arguments);
2644
+ };
2645
+ imports.wbg.__wbg_setonsuccess_632ce0a1460455c2 = function(arg0, arg1) {
2646
+ getObject(arg0).onsuccess = getObject(arg1);
2647
+ };
2648
+ imports.wbg.__wbg_setonerror_8479b33e7568a904 = function(arg0, arg1) {
2649
+ getObject(arg0).onerror = getObject(arg1);
2650
+ };
2651
+ imports.wbg.__wbindgen_jsval_loose_eq = function(arg0, arg1) {
2652
+ const ret = getObject(arg0) == getObject(arg1);
2653
+ return ret;
2654
+ };
2655
+ imports.wbg.__wbindgen_as_number = function(arg0) {
2656
+ const ret = +getObject(arg0);
2657
+ return ret;
2658
+ };
2659
+ imports.wbg.__wbg_String_389b54bd9d25375f = function(arg0, arg1) {
2660
+ const ret = String(getObject(arg1));
2661
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2662
+ const len1 = WASM_VECTOR_LEN;
2663
+ getInt32Memory0()[arg0 / 4 + 1] = len1;
2664
+ getInt32Memory0()[arg0 / 4 + 0] = ptr1;
2665
+ };
2666
+ imports.wbg.__wbg_getwithrefkey_4a92a5eca60879b9 = function(arg0, arg1) {
2667
+ const ret = getObject(arg0)[getObject(arg1)];
2668
+ return addHeapObject(ret);
2669
+ };
2670
+ imports.wbg.__wbg_set_9182712abebf82ef = function(arg0, arg1, arg2) {
2671
+ getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
2672
+ };
2673
+ imports.wbg.__wbg_log_28eee4e6432efd24 = function(arg0, arg1) {
2674
+ console.log(getStringFromWasm0(arg0, arg1));
2675
+ };
2676
+ imports.wbg.__wbg_String_55b8bdc4bc243677 = function(arg0, arg1) {
2677
+ const ret = String(getObject(arg1));
2678
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2679
+ const len1 = WASM_VECTOR_LEN;
2680
+ getInt32Memory0()[arg0 / 4 + 1] = len1;
2681
+ getInt32Memory0()[arg0 / 4 + 0] = ptr1;
2682
+ };
2683
+ imports.wbg.__wbg_getElementById_8458f2a6c28467dc = function(arg0, arg1, arg2) {
2684
+ const ret = getObject(arg0).getElementById(getStringFromWasm0(arg1, arg2));
2685
+ return addHeapObject(ret);
2686
+ };
2687
+ imports.wbg.__wbg_settextcontent_fc3ff485b96fcb1d = function(arg0, arg1, arg2) {
2688
+ getObject(arg0).textContent = getStringFromWasm0(arg1, arg2);
2689
+ };
2690
+ imports.wbg.__wbg_wbgtestinvoke_8c20f4132af2bded = function() {
2691
+ return handleError(function(arg0, arg1) {
2692
+ try {
2693
+ var state0 = { a: arg0, b: arg1 };
2694
+ var cb0 = () => {
2695
+ const a = state0.a;
2696
+ state0.a = 0;
2697
+ try {
2698
+ return __wbg_adapter_292(a, state0.b);
2699
+ } finally {
2700
+ state0.a = a;
2701
+ }
2702
+ };
2703
+ __wbg_test_invoke(cb0);
2704
+ } finally {
2705
+ state0.a = state0.b = 0;
2706
+ }
2707
+ }, arguments);
2708
+ };
2709
+ imports.wbg.__wbg_static_accessor_document_d4b6ae7f5578480f = function() {
2710
+ const ret = document;
2711
+ return addHeapObject(ret);
2712
+ };
2713
+ imports.wbg.__wbg_stack_17c77e9f5bfe6714 = function(arg0, arg1) {
2714
+ const ret = getObject(arg1).stack;
2715
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2716
+ const len1 = WASM_VECTOR_LEN;
2717
+ getInt32Memory0()[arg0 / 4 + 1] = len1;
2718
+ getInt32Memory0()[arg0 / 4 + 0] = ptr1;
2719
+ };
2720
+ imports.wbg.__wbg_self_55106357ec10ecd4 = function(arg0) {
2721
+ const ret = getObject(arg0).self;
2722
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
2723
+ };
2724
+ imports.wbg.__wbg_constructor_fd0d22d60b7dfd72 = function(arg0) {
2725
+ const ret = getObject(arg0).constructor;
2726
+ return addHeapObject(ret);
2727
+ };
2728
+ imports.wbg.__wbg_name_7f439d24ff7ba1d3 = function(arg0, arg1) {
2729
+ const ret = getObject(arg1).name;
2730
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2731
+ const len1 = WASM_VECTOR_LEN;
2732
+ getInt32Memory0()[arg0 / 4 + 1] = len1;
2733
+ getInt32Memory0()[arg0 / 4 + 0] = ptr1;
2734
+ };
2735
+ imports.wbg.__wbg_textcontent_67e4e811cbdf00fc = function(arg0, arg1) {
2736
+ const ret = getObject(arg1).textContent;
2737
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2738
+ const len1 = WASM_VECTOR_LEN;
2739
+ getInt32Memory0()[arg0 / 4 + 1] = len1;
2740
+ getInt32Memory0()[arg0 / 4 + 0] = ptr1;
2741
+ };
2742
+ imports.wbg.__wbg_stack_44743fb7d71926a0 = function(arg0) {
2743
+ const ret = getObject(arg0).stack;
2744
+ return addHeapObject(ret);
2745
+ };
2746
+ imports.wbg.__wbg_wbgtestoutputwriteln_4db3bd64914ec955 = function(arg0) {
2747
+ __wbg_test_output_writeln(takeObject(arg0));
2748
+ };
2749
+ imports.wbg.__wbg_stack_436273c21658169b = function(arg0) {
2750
+ const ret = getObject(arg0).stack;
2751
+ return addHeapObject(ret);
2752
+ };
2753
+ imports.wbg.__wbg_new_abda76e883ba8a5f = function() {
2754
+ const ret = new Error();
2755
+ return addHeapObject(ret);
2756
+ };
2757
+ imports.wbg.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) {
2758
+ const ret = getObject(arg1).stack;
2759
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2760
+ const len1 = WASM_VECTOR_LEN;
2761
+ getInt32Memory0()[arg0 / 4 + 1] = len1;
2762
+ getInt32Memory0()[arg0 / 4 + 0] = ptr1;
2763
+ };
2764
+ imports.wbg.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) {
2765
+ let deferred0_0;
2766
+ let deferred0_1;
2767
+ try {
2768
+ deferred0_0 = arg0;
2769
+ deferred0_1 = arg1;
2770
+ console.error(getStringFromWasm0(arg0, arg1));
2771
+ } finally {
2772
+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
2773
+ }
2774
+ };
2775
+ imports.wbg.__wbg_queueMicrotask_481971b0d87f3dd4 = function(arg0) {
2776
+ queueMicrotask(getObject(arg0));
2777
+ };
2778
+ imports.wbg.__wbg_queueMicrotask_3cbae2ec6b6cd3d6 = function(arg0) {
2779
+ const ret = getObject(arg0).queueMicrotask;
2780
+ return addHeapObject(ret);
2781
+ };
2782
+ imports.wbg.__wbg_get_bd8e338fbd5f5cc8 = function(arg0, arg1) {
2783
+ const ret = getObject(arg0)[arg1 >>> 0];
2784
+ return addHeapObject(ret);
2785
+ };
2786
+ imports.wbg.__wbg_length_cd7af8117672b8b8 = function(arg0) {
2787
+ const ret = getObject(arg0).length;
2788
+ return ret;
2789
+ };
2790
+ imports.wbg.__wbg_new_16b304a2cfa7ff4a = function() {
2791
+ const ret = new Array();
2792
+ return addHeapObject(ret);
2793
+ };
2794
+ imports.wbg.__wbg_newnoargs_e258087cd0daa0ea = function(arg0, arg1) {
2795
+ const ret = new Function(getStringFromWasm0(arg0, arg1));
2796
+ return addHeapObject(ret);
2797
+ };
2798
+ imports.wbg.__wbg_new_d9bc3a0147634640 = function() {
2799
+ const ret = /* @__PURE__ */ new Map();
2800
+ return addHeapObject(ret);
2801
+ };
2802
+ imports.wbg.__wbg_next_40fc327bfc8770e6 = function(arg0) {
2803
+ const ret = getObject(arg0).next;
2804
+ return addHeapObject(ret);
2805
+ };
2806
+ imports.wbg.__wbg_next_196c84450b364254 = function() {
2807
+ return handleError(function(arg0) {
2808
+ const ret = getObject(arg0).next();
2809
+ return addHeapObject(ret);
2810
+ }, arguments);
2811
+ };
2812
+ imports.wbg.__wbg_done_298b57d23c0fc80c = function(arg0) {
2813
+ const ret = getObject(arg0).done;
2814
+ return ret;
2815
+ };
2816
+ imports.wbg.__wbg_value_d93c65011f51a456 = function(arg0) {
2817
+ const ret = getObject(arg0).value;
2818
+ return addHeapObject(ret);
2819
+ };
2820
+ imports.wbg.__wbg_iterator_2cee6dadfd956dfa = function() {
2821
+ const ret = Symbol.iterator;
2822
+ return addHeapObject(ret);
2823
+ };
2824
+ imports.wbg.__wbg_get_e3c254076557e348 = function() {
2825
+ return handleError(function(arg0, arg1) {
2826
+ const ret = Reflect.get(getObject(arg0), getObject(arg1));
2827
+ return addHeapObject(ret);
2828
+ }, arguments);
2829
+ };
2830
+ imports.wbg.__wbg_call_27c0f87801dedf93 = function() {
2831
+ return handleError(function(arg0, arg1) {
2832
+ const ret = getObject(arg0).call(getObject(arg1));
2833
+ return addHeapObject(ret);
2834
+ }, arguments);
2835
+ };
2836
+ imports.wbg.__wbg_new_72fb9a18b5ae2624 = function() {
2837
+ const ret = new Object();
2838
+ return addHeapObject(ret);
2839
+ };
2840
+ imports.wbg.__wbg_self_ce0dbfc45cf2f5be = function() {
2841
+ return handleError(function() {
2842
+ const ret = self.self;
2843
+ return addHeapObject(ret);
2844
+ }, arguments);
2845
+ };
2846
+ imports.wbg.__wbg_window_c6fb939a7f436783 = function() {
2847
+ return handleError(function() {
2848
+ const ret = window.window;
2849
+ return addHeapObject(ret);
2850
+ }, arguments);
2851
+ };
2852
+ imports.wbg.__wbg_globalThis_d1e6af4856ba331b = function() {
2853
+ return handleError(function() {
2854
+ const ret = globalThis.globalThis;
2855
+ return addHeapObject(ret);
2856
+ }, arguments);
2857
+ };
2858
+ imports.wbg.__wbg_global_207b558942527489 = function() {
2859
+ return handleError(function() {
2860
+ const ret = global.global;
2861
+ return addHeapObject(ret);
2862
+ }, arguments);
2863
+ };
2864
+ imports.wbg.__wbg_set_d4638f722068f043 = function(arg0, arg1, arg2) {
2865
+ getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
2866
+ };
2867
+ imports.wbg.__wbg_from_89e3fc3ba5e6fb48 = function(arg0) {
2868
+ const ret = Array.from(getObject(arg0));
2869
+ return addHeapObject(ret);
2870
+ };
2871
+ imports.wbg.__wbg_forEach_2be8de7347d63332 = function(arg0, arg1, arg2) {
2872
+ try {
2873
+ var state0 = { a: arg1, b: arg2 };
2874
+ var cb0 = (arg02, arg12, arg22) => {
2875
+ const a = state0.a;
2876
+ state0.a = 0;
2877
+ try {
2878
+ return __wbg_adapter_335(a, state0.b, arg02, arg12, arg22);
2879
+ } finally {
2880
+ state0.a = a;
2881
+ }
2882
+ };
2883
+ getObject(arg0).forEach(cb0);
2884
+ } finally {
2885
+ state0.a = state0.b = 0;
2886
+ }
2887
+ };
2888
+ imports.wbg.__wbg_isArray_2ab64d95e09ea0ae = function(arg0) {
2889
+ const ret = Array.isArray(getObject(arg0));
2890
+ return ret;
2891
+ };
2892
+ imports.wbg.__wbg_of_4a2b313a453ec059 = function(arg0) {
2893
+ const ret = Array.of(getObject(arg0));
2894
+ return addHeapObject(ret);
2895
+ };
2896
+ imports.wbg.__wbg_push_a5b05aedc7234f9f = function(arg0, arg1) {
2897
+ const ret = getObject(arg0).push(getObject(arg1));
2898
+ return ret;
2899
+ };
2900
+ imports.wbg.__wbg_instanceof_ArrayBuffer_836825be07d4c9d2 = function(arg0) {
2901
+ let result;
2902
+ try {
2903
+ result = getObject(arg0) instanceof ArrayBuffer;
2904
+ } catch (_) {
2905
+ result = false;
2906
+ }
2907
+ const ret = result;
2908
+ return ret;
2909
+ };
2910
+ imports.wbg.__wbg_message_5bf28016c2b49cfb = function(arg0) {
2911
+ const ret = getObject(arg0).message;
2912
+ return addHeapObject(ret);
2913
+ };
2914
+ imports.wbg.__wbg_name_e7429f0dda6079e2 = function(arg0) {
2915
+ const ret = getObject(arg0).name;
2916
+ return addHeapObject(ret);
2917
+ };
2918
+ imports.wbg.__wbg_call_b3ca7c6051f9bec1 = function() {
2919
+ return handleError(function(arg0, arg1, arg2) {
2920
+ const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
2921
+ return addHeapObject(ret);
2922
+ }, arguments);
2923
+ };
2924
+ imports.wbg.__wbg_call_938992c832f74314 = function() {
2925
+ return handleError(function(arg0, arg1, arg2, arg3, arg4) {
2926
+ const ret = getObject(arg0).call(getObject(arg1), getObject(arg2), getObject(arg3), getObject(arg4));
2927
+ return addHeapObject(ret);
2928
+ }, arguments);
2929
+ };
2930
+ imports.wbg.__wbg_set_8417257aaedc936b = function(arg0, arg1, arg2) {
2931
+ const ret = getObject(arg0).set(getObject(arg1), getObject(arg2));
2932
+ return addHeapObject(ret);
2933
+ };
2934
+ imports.wbg.__wbg_isSafeInteger_f7b04ef02296c4d2 = function(arg0) {
2935
+ const ret = Number.isSafeInteger(getObject(arg0));
2936
+ return ret;
2937
+ };
2938
+ imports.wbg.__wbg_getTime_2bc4375165f02d15 = function(arg0) {
2939
+ const ret = getObject(arg0).getTime();
2940
+ return ret;
2941
+ };
2942
+ imports.wbg.__wbg_new0_7d84e5b2cd9fdc73 = function() {
2943
+ const ret = /* @__PURE__ */ new Date();
2944
+ return addHeapObject(ret);
2945
+ };
2946
+ imports.wbg.__wbg_instanceof_Object_71ca3c0a59266746 = function(arg0) {
2947
+ let result;
2948
+ try {
2949
+ result = getObject(arg0) instanceof Object;
2950
+ } catch (_) {
2951
+ result = false;
2952
+ }
2953
+ const ret = result;
2954
+ return ret;
2955
+ };
2956
+ imports.wbg.__wbg_assign_496d2d14fecafbcf = function(arg0, arg1) {
2957
+ const ret = Object.assign(getObject(arg0), getObject(arg1));
2958
+ return addHeapObject(ret);
2959
+ };
2960
+ imports.wbg.__wbg_entries_95cc2c823b285a09 = function(arg0) {
2961
+ const ret = Object.entries(getObject(arg0));
2962
+ return addHeapObject(ret);
2963
+ };
2964
+ imports.wbg.__wbg_is_010fdc0f4ab96916 = function(arg0, arg1) {
2965
+ const ret = Object.is(getObject(arg0), getObject(arg1));
2966
+ return ret;
2967
+ };
2968
+ imports.wbg.__wbg_keys_91e412b4b222659f = function(arg0) {
2969
+ const ret = Object.keys(getObject(arg0));
2970
+ return addHeapObject(ret);
2971
+ };
2972
+ imports.wbg.__wbg_new_81740750da40724f = function(arg0, arg1) {
2973
+ try {
2974
+ var state0 = { a: arg0, b: arg1 };
2975
+ var cb0 = (arg02, arg12) => {
2976
+ const a = state0.a;
2977
+ state0.a = 0;
2978
+ try {
2979
+ return __wbg_adapter_392(a, state0.b, arg02, arg12);
2980
+ } finally {
2981
+ state0.a = a;
2982
+ }
2983
+ };
2984
+ const ret = new Promise(cb0);
2985
+ return addHeapObject(ret);
2986
+ } finally {
2987
+ state0.a = state0.b = 0;
2988
+ }
2989
+ };
2990
+ imports.wbg.__wbg_resolve_b0083a7967828ec8 = function(arg0) {
2991
+ const ret = Promise.resolve(getObject(arg0));
2992
+ return addHeapObject(ret);
2993
+ };
2994
+ imports.wbg.__wbg_then_0c86a60e8fcfe9f6 = function(arg0, arg1) {
2995
+ const ret = getObject(arg0).then(getObject(arg1));
2996
+ return addHeapObject(ret);
2997
+ };
2998
+ imports.wbg.__wbg_then_a73caa9a87991566 = function(arg0, arg1, arg2) {
2999
+ const ret = getObject(arg0).then(getObject(arg1), getObject(arg2));
3000
+ return addHeapObject(ret);
3001
+ };
3002
+ imports.wbg.__wbg_buffer_12d079cc21e14bdb = function(arg0) {
3003
+ const ret = getObject(arg0).buffer;
3004
+ return addHeapObject(ret);
3005
+ };
3006
+ imports.wbg.__wbg_newwithbyteoffsetandlength_aa4a17c33a06e5cb = function(arg0, arg1, arg2) {
3007
+ const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
3008
+ return addHeapObject(ret);
3009
+ };
3010
+ imports.wbg.__wbg_new_63b92bc8671ed464 = function(arg0) {
3011
+ const ret = new Uint8Array(getObject(arg0));
3012
+ return addHeapObject(ret);
3013
+ };
3014
+ imports.wbg.__wbg_set_a47bac70306a19a7 = function(arg0, arg1, arg2) {
3015
+ getObject(arg0).set(getObject(arg1), arg2 >>> 0);
3016
+ };
3017
+ imports.wbg.__wbg_length_c20a40f15020d68a = function(arg0) {
3018
+ const ret = getObject(arg0).length;
3019
+ return ret;
3020
+ };
3021
+ imports.wbg.__wbg_instanceof_Uint8Array_2b3bbecd033d19f6 = function(arg0) {
3022
+ let result;
3023
+ try {
3024
+ result = getObject(arg0) instanceof Uint8Array;
3025
+ } catch (_) {
3026
+ result = false;
3027
+ }
3028
+ const ret = result;
3029
+ return ret;
3030
+ };
3031
+ imports.wbg.__wbg_newwithlength_e9b4878cebadb3d3 = function(arg0) {
3032
+ const ret = new Uint8Array(arg0 >>> 0);
3033
+ return addHeapObject(ret);
3034
+ };
3035
+ imports.wbg.__wbg_subarray_a1f73cd4b5b42fe1 = function(arg0, arg1, arg2) {
3036
+ const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
3037
+ return addHeapObject(ret);
3038
+ };
3039
+ imports.wbg.__wbg_apply_0a5aa603881e6d79 = function() {
3040
+ return handleError(function(arg0, arg1, arg2) {
3041
+ const ret = Reflect.apply(getObject(arg0), getObject(arg1), getObject(arg2));
3042
+ return addHeapObject(ret);
3043
+ }, arguments);
3044
+ };
3045
+ imports.wbg.__wbg_deleteProperty_13e721a56f19e842 = function() {
3046
+ return handleError(function(arg0, arg1) {
3047
+ const ret = Reflect.deleteProperty(getObject(arg0), getObject(arg1));
3048
+ return ret;
3049
+ }, arguments);
3050
+ };
3051
+ imports.wbg.__wbg_has_0af94d20077affa2 = function() {
3052
+ return handleError(function(arg0, arg1) {
3053
+ const ret = Reflect.has(getObject(arg0), getObject(arg1));
3054
+ return ret;
3055
+ }, arguments);
3056
+ };
3057
+ imports.wbg.__wbg_set_1f9b04f170055d33 = function() {
3058
+ return handleError(function(arg0, arg1, arg2) {
3059
+ const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
3060
+ return ret;
3061
+ }, arguments);
3062
+ };
3063
+ imports.wbg.__wbg_parse_66d1801634e099ac = function() {
3064
+ return handleError(function(arg0, arg1) {
3065
+ const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
3066
+ return addHeapObject(ret);
3067
+ }, arguments);
3068
+ };
3069
+ imports.wbg.__wbg_stringify_8887fe74e1c50d81 = function() {
3070
+ return handleError(function(arg0) {
3071
+ const ret = JSON.stringify(getObject(arg0));
3072
+ return addHeapObject(ret);
3073
+ }, arguments);
3074
+ };
3075
+ imports.wbg.__wbindgen_bigint_get_as_i64 = function(arg0, arg1) {
3076
+ const v = getObject(arg1);
3077
+ const ret = typeof v === "bigint" ? v : void 0;
3078
+ getBigInt64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? BigInt(0) : ret;
3079
+ getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
3080
+ };
3081
+ imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {
3082
+ const ret = debugString(getObject(arg1));
3083
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3084
+ const len1 = WASM_VECTOR_LEN;
3085
+ getInt32Memory0()[arg0 / 4 + 1] = len1;
3086
+ getInt32Memory0()[arg0 / 4 + 0] = ptr1;
3087
+ };
3088
+ imports.wbg.__wbindgen_throw = function(arg0, arg1) {
3089
+ throw new Error(getStringFromWasm0(arg0, arg1));
3090
+ };
3091
+ imports.wbg.__wbindgen_memory = function() {
3092
+ const ret = wasm.memory;
3093
+ return addHeapObject(ret);
3094
+ };
3095
+ imports.wbg.__wbindgen_closure_wrapper814 = function(arg0, arg1, arg2) {
3096
+ const ret = makeClosure(arg0, arg1, 336, __wbg_adapter_56);
3097
+ return addHeapObject(ret);
3098
+ };
3099
+ imports.wbg.__wbindgen_closure_wrapper816 = function(arg0, arg1, arg2) {
3100
+ const ret = makeMutClosure(arg0, arg1, 336, __wbg_adapter_59);
3101
+ return addHeapObject(ret);
3102
+ };
3103
+ imports.wbg.__wbindgen_closure_wrapper818 = function(arg0, arg1, arg2) {
3104
+ const ret = makeMutClosure(arg0, arg1, 336, __wbg_adapter_62);
3105
+ return addHeapObject(ret);
3106
+ };
3107
+ imports.wbg.__wbindgen_closure_wrapper1616 = function(arg0, arg1, arg2) {
3108
+ const ret = makeMutClosure(arg0, arg1, 441, __wbg_adapter_65);
3109
+ return addHeapObject(ret);
3110
+ };
3111
+ return imports;
3112
+ }
3113
+ function __wbg_init_memory(imports, maybe_memory) {
3114
+ }
3115
+ function __wbg_finalize_init(instance, module22) {
3116
+ wasm = instance.exports;
3117
+ __wbg_init.__wbindgen_wasm_module = module22;
3118
+ cachedBigInt64Memory0 = null;
3119
+ cachedFloat64Memory0 = null;
3120
+ cachedInt32Memory0 = null;
3121
+ cachedUint32Memory0 = null;
3122
+ cachedUint8Memory0 = null;
3123
+ wasm.__wbindgen_start();
3124
+ return wasm;
3125
+ }
3126
+ function initSync(module22) {
3127
+ if (wasm !== void 0) return wasm;
3128
+ const imports = __wbg_get_imports();
3129
+ __wbg_init_memory(imports);
3130
+ if (!(module22 instanceof WebAssembly.Module)) {
3131
+ module22 = new WebAssembly.Module(module22);
3132
+ }
3133
+ const instance = new WebAssembly.Instance(module22, imports);
3134
+ return __wbg_finalize_init(instance, module22);
3135
+ }
3136
+ async function __wbg_init(input) {
3137
+ if (wasm !== void 0) return wasm;
3138
+ const imports = __wbg_get_imports();
3139
+ if (typeof input === "string" || typeof Request === "function" && input instanceof Request || typeof URL === "function" && input instanceof URL) {
3140
+ input = fetch(input);
3141
+ }
3142
+ __wbg_init_memory(imports);
3143
+ const { instance, module: module22 } = await __wbg_load(await input, imports);
3144
+ return __wbg_finalize_init(instance, module22);
3145
+ }
3146
+ var ridb_core_default = __wbg_init;
3147
+ }
3148
+ });
3149
+
3150
+ // src/index.ts
3151
+ var index_exports = {};
3152
+ __export(index_exports, {
3153
+ MongoDBStorage: () => MongoDBStorage,
3154
+ default: () => createMongoDB
3155
+ });
3156
+ module.exports = __toCommonJS(index_exports);
3157
+ var import_ridb_core = __toESM(require_ridb_core());
3158
+ var import_ridb = require("@trust0/ridb");
3159
+ var MongoDBStorage = class _MongoDBStorage extends import_ridb_core.BaseStorage {
3160
+ client;
3161
+ db;
3162
+ mongoConfig;
3163
+ constructor(name, schemas, options = {}) {
3164
+ super(name, schemas, options);
3165
+ this.mongoConfig = options;
3166
+ }
3167
+ /**
3168
+ * Utility method to recursively convert ObjectId values to strings throughout an object
3169
+ * This ensures that MongoDB's ObjectId instances are never returned to the application layer,
3170
+ * maintaining consistency with RIDB's string-based approach and preventing serialization issues.
3171
+ * Also removes MongoDB's automatic _id field entirely from results.
3172
+ * @private
3173
+ */
3174
+ convertObjectIdsToStrings(obj) {
3175
+ if (!obj || typeof obj !== "object") {
3176
+ return obj;
3177
+ }
3178
+ if (obj.constructor?.name === "ObjectId" || obj._bsontype && obj._bsontype === "ObjectId") {
3179
+ const stringValue = obj.toString();
3180
+ return stringValue;
3181
+ }
3182
+ if (Array.isArray(obj)) {
3183
+ return obj.map((item) => this.convertObjectIdsToStrings(item));
3184
+ }
3185
+ const converted = {};
3186
+ for (const [key, value] of Object.entries(obj)) {
3187
+ if (key === "_id") {
3188
+ continue;
3189
+ }
3190
+ converted[key] = this.convertObjectIdsToStrings(value);
3191
+ }
3192
+ return converted;
3193
+ }
3194
+ /**
3195
+ * Create a new MongoDB storage instance
3196
+ * @param name - Database name
3197
+ * @param schemas - Collection schemas
3198
+ * @param options - Storage options including MongoDB connection details
3199
+ * @returns A new Instance of MongoDB storage
3200
+ * @public
3201
+ */
3202
+ static async create(name, schemas, options = {}) {
3203
+ const db = new _MongoDBStorage(name, schemas, options);
3204
+ return db;
3205
+ }
3206
+ /** Start the database connection */
3207
+ async start() {
3208
+ const { MongoClient } = await import("mongodb");
3209
+ const url = this.mongoConfig.url || process.env.MONGODB_URL || "mongodb://localhost:27017";
3210
+ const dbName = this.mongoConfig.dbName || this.name;
3211
+ this.client = new MongoClient(url, this.mongoConfig.mongoOptions || {});
3212
+ await this.client.connect();
3213
+ this.db = this.client.db(dbName);
3214
+ }
3215
+ /** Close the database connection */
3216
+ async close() {
3217
+ if (this.client) {
3218
+ await this.client.close();
3219
+ this.client = void 0;
3220
+ this.db = void 0;
3221
+ }
3222
+ }
3223
+ /** Get MongoDB collection for a given collection name */
3224
+ getCollection(collectionName) {
3225
+ if (!this.db) {
3226
+ throw new Error("Database not started. Call start() first.");
3227
+ }
3228
+ const collection = this.db.collection(collectionName);
3229
+ return collection;
3230
+ }
3231
+ /** Find a document by its ID */
3232
+ async findDocumentById(collectionName, id) {
3233
+ const collection = this.getCollection(String(collectionName));
3234
+ const schema = this.getSchema(String(collectionName));
3235
+ const primaryKey = schema.primaryKey;
3236
+ const query = { [primaryKey]: id };
3237
+ const doc = await collection.findOne(query);
3238
+ if (!doc) {
3239
+ return null;
3240
+ }
3241
+ const converted = this.convertObjectIdsToStrings(doc);
3242
+ return converted;
3243
+ }
3244
+ /** Write an operation (insert, update, delete) */
3245
+ async write(op) {
3246
+ const collectionName = String(op.collection);
3247
+ const collection = this.getCollection(collectionName);
3248
+ const { primaryKey } = this.getSchema(collectionName);
3249
+ switch (op.opType) {
3250
+ case import_ridb_core.OpType.CREATE: {
3251
+ const id = primaryKey in op.data ? op.data[primaryKey] : null;
3252
+ if (!id) {
3253
+ throw new Error("Document ID is required");
3254
+ }
3255
+ const existQuery = { [primaryKey]: id };
3256
+ const existing = await collection.findOne(existQuery);
3257
+ if (existing) {
3258
+ throw new Error(`Document with ${primaryKey} '${id}' already exists`);
3259
+ }
3260
+ const docToInsert = { ...op.data };
3261
+ const insertResult = await collection.insertOne(docToInsert);
3262
+ const result = this.convertObjectIdsToStrings(op.data);
3263
+ return result;
3264
+ }
3265
+ case import_ridb_core.OpType.UPDATE: {
3266
+ const id = primaryKey in op.data ? op.data[primaryKey] : null;
3267
+ if (!id) {
3268
+ throw new Error("Document ID is required");
3269
+ }
3270
+ const updateQuery = { [primaryKey]: id };
3271
+ const updateData = { $set: op.data };
3272
+ const result = await collection.updateOne(updateQuery, updateData);
3273
+ if (result.matchedCount === 0) {
3274
+ throw new Error("Document ID not found");
3275
+ }
3276
+ const convertedResult = this.convertObjectIdsToStrings(op.data);
3277
+ return convertedResult;
3278
+ }
3279
+ case import_ridb_core.OpType.DELETE: {
3280
+ const id = op.data;
3281
+ const deleteQuery = { [primaryKey]: id };
3282
+ const result = await collection.deleteOne(deleteQuery);
3283
+ if (result.deletedCount === 0) {
3284
+ throw new Error("Document ID not found");
3285
+ }
3286
+ const convertedResult = this.convertObjectIdsToStrings(op.data);
3287
+ return convertedResult;
3288
+ }
3289
+ default:
3290
+ throw new Error(`Unknown operation type: ${op.opType}`);
3291
+ }
3292
+ }
3293
+ /** Convert RIDB query to MongoDB filter */
3294
+ convertQueryToMongoFilter(query, schema) {
3295
+ if (!query || typeof query !== "object") {
3296
+ return {};
3297
+ }
3298
+ const filter = {};
3299
+ for (const [key, value] of Object.entries(query)) {
3300
+ if (value === null || value === void 0) {
3301
+ filter[key] = { $exists: false };
3302
+ } else if (typeof value === "object" && value !== null) {
3303
+ if ("$in" in value) {
3304
+ filter[key] = { $in: this.convertObjectIdsToStrings(value.$in) };
3305
+ } else if ("$nin" in value) {
3306
+ filter[key] = { $nin: this.convertObjectIdsToStrings(value.$nin) };
3307
+ } else if ("$gt" in value) {
3308
+ filter[key] = { $gt: this.convertObjectIdsToStrings(value.$gt) };
3309
+ } else if ("$gte" in value) {
3310
+ filter[key] = { $gte: this.convertObjectIdsToStrings(value.$gte) };
3311
+ } else if ("$lt" in value) {
3312
+ filter[key] = { $lt: this.convertObjectIdsToStrings(value.$lt) };
3313
+ } else if ("$lte" in value) {
3314
+ filter[key] = { $lte: this.convertObjectIdsToStrings(value.$lte) };
3315
+ } else if ("$ne" in value) {
3316
+ filter[key] = { $ne: this.convertObjectIdsToStrings(value.$ne) };
3317
+ } else if ("$regex" in value) {
3318
+ filter[key] = { $regex: value.$regex };
3319
+ } else {
3320
+ filter[key] = this.convertObjectIdsToStrings(value);
3321
+ }
3322
+ } else {
3323
+ filter[key] = this.convertObjectIdsToStrings(value);
3324
+ }
3325
+ }
3326
+ return filter;
3327
+ }
3328
+ /** Count documents matching a query (supports offset & limit) */
3329
+ async count(collectionName, query, options) {
3330
+ const collection = this.getCollection(String(collectionName));
3331
+ const schema = this.getSchema(String(collectionName));
3332
+ const filter = this.convertQueryToMongoFilter(query, schema);
3333
+ let countOptions = {};
3334
+ if (options?.offset) {
3335
+ countOptions.skip = options.offset;
3336
+ }
3337
+ if (options?.limit) {
3338
+ countOptions.limit = options.limit;
3339
+ }
3340
+ const count = await collection.countDocuments(filter, Object.keys(countOptions).length > 0 ? countOptions : void 0);
3341
+ return count;
3342
+ }
3343
+ /** Find documents matching a query with pagination */
3344
+ async find(collectionName, query, options) {
3345
+ const collection = this.getCollection(String(collectionName));
3346
+ const schema = this.getSchema(String(collectionName));
3347
+ const filter = this.convertQueryToMongoFilter(query, schema);
3348
+ let findQuery = collection.find(filter);
3349
+ if (options?.offset) {
3350
+ findQuery = findQuery.skip(options.offset);
3351
+ }
3352
+ if (options?.limit) {
3353
+ findQuery = findQuery.limit(options.limit);
3354
+ }
3355
+ const docs = await findQuery.toArray();
3356
+ const convertedDocs = docs.map((doc) => this.convertObjectIdsToStrings(doc));
3357
+ return convertedDocs;
3358
+ }
3359
+ };
3360
+ async function createMongoDB() {
3361
+ const { BaseStorage: base } = await (0, import_ridb.WasmInternal)();
3362
+ Object.setPrototypeOf(MongoDBStorage.prototype, base.prototype);
3363
+ return MongoDBStorage;
3364
+ }
3365
+ // Annotate the CommonJS export names for ESM import in node:
3366
+ 0 && (module.exports = {
3367
+ MongoDBStorage
3368
+ });