@rindle/wasm 0.1.0-rc.5

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/pkg/rindle.js ADDED
@@ -0,0 +1,953 @@
1
+ /* @ts-self-types="./rindle.d.ts" */
2
+
3
+ /**
4
+ * The in-memory live-query engine, callable from JavaScript. See the module docs.
5
+ */
6
+ export class Db {
7
+ __destroy_into_raw() {
8
+ const ptr = this.__wbg_ptr;
9
+ this.__wbg_ptr = 0;
10
+ DbFinalization.unregister(this);
11
+ return ptr;
12
+ }
13
+ free() {
14
+ const ptr = this.__destroy_into_raw();
15
+ wasm.__wbg_db_free(ptr, 0);
16
+ }
17
+ /**
18
+ * Tear down a registered query: drop its sink + reclaim its pipeline (disconnect from
19
+ * the shared sources, free its slots — [`Graph::destroy_pipeline`]). Other queries
20
+ * and the shared sources are untouched. A no-op for an unknown id.
21
+ * @param {number} query_id
22
+ */
23
+ destroyQuery(query_id) {
24
+ wasm.db_destroyQuery(this.__wbg_ptr, query_id);
25
+ }
26
+ constructor() {
27
+ const ret = wasm.db_new();
28
+ this.__wbg_ptr = ret;
29
+ DbFinalization.register(this, this.__wbg_ptr, this);
30
+ return this;
31
+ }
32
+ /**
33
+ * Register a live query from a Zero-wire AST under the caller's opaque `query_id`.
34
+ * Lowers it into the shared graph, sinks it in a change-sink, and hydrates. Returns
35
+ * `{ queryId, comparatorVersion, schema, snapshot }` — the `hello` + hydrate
36
+ * snapshot for the JS `ArrayView` (snapshot cells **bare**). A malformed AST /
37
+ * unknown table / unknown column throws a JS `Error` carrying a `.kind`.
38
+ * @param {number} query_id
39
+ * @param {any} ast_json
40
+ * @returns {any}
41
+ */
42
+ query(query_id, ast_json) {
43
+ const ret = wasm.db_query(this.__wbg_ptr, query_id, ast_json);
44
+ if (ret[2]) {
45
+ throw takeFromExternrefTable0(ret[1]);
46
+ }
47
+ return takeFromExternrefTable0(ret[0]);
48
+ }
49
+ /**
50
+ * Register a base table from a `SchemaSpec` (`{ columns, primaryKey, sort? }` —
51
+ * [`marshal::schema_from_js`]; any `relationships` in the spec are ignored — nesting
52
+ * is query-local via `sub`). Seeds an empty shared source. Idempotent per name.
53
+ * @param {string} table
54
+ * @param {any} schema
55
+ */
56
+ registerTable(table, schema) {
57
+ const ptr0 = passStringToWasm0(table, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
58
+ const len0 = WASM_VECTOR_LEN;
59
+ const ret = wasm.db_registerTable(this.__wbg_ptr, ptr0, len0, schema);
60
+ if (ret[1]) {
61
+ throw takeFromExternrefTable0(ret[0]);
62
+ }
63
+ }
64
+ /**
65
+ * Open a §1.3 reconcile cycle against the coherent server delta `deltas` —
66
+ * an array of base-table row ops `{ table, type: "add"|"remove"|"edit", row,
67
+ * old? }` (the cv-released normalized batch, bare cells). Runs the rewind
68
+ * (steps 1–4): the engine's input becomes the authoritative state `S'`, with
69
+ * every optimistic write un-applied and the server delta folded in; `sync`
70
+ * re-forks. Nothing is delivered yet — the JS side now **re-invokes each
71
+ * still-pending client mutator** (ordinary `write()`/`commit()` calls, whose
72
+ * events buffer into the cycle), then calls
73
+ * [`server_batch_end`](Db::server_batch_end) for the one coalesced delivery.
74
+ *
75
+ * Errors if a cycle is already open, on an unknown table, or on a push failure
76
+ * — after which the optimistic state is poisoned (a partial rewind may have
77
+ * applied): the only safe recovery is to discard this `Db` and re-hydrate.
78
+ * @param {any} deltas
79
+ */
80
+ serverBatchBegin(deltas) {
81
+ const ret = wasm.db_serverBatchBegin(this.__wbg_ptr, deltas);
82
+ if (ret[1]) {
83
+ throw takeFromExternrefTable0(ret[0]);
84
+ }
85
+ }
86
+ /**
87
+ * Close the open cycle: deliver the whole buffered event stream (rewind +
88
+ * re-invocations) per query, **in order**, as `[{ queryId, events: FlatChange[] }]`
89
+ * — one batch per affected query. The stream is forwarded RAW: the IVM sink emits
90
+ * changes in a valid incremental order (`FLAT-CHANGES-DESIGN.md` §5.4), so the
91
+ * receiver folds them in order to reach `view(head_new)`. The §3 "notify once"
92
+ * boundary is the view's own — one `applyChanges` per batch, settling before it
93
+ * notifies. Queries the cycle never touched are omitted.
94
+ *
95
+ * Note: a still-pending write whose re-invocation reproduced its prediction emits a
96
+ * balanced `remove`+`add` here. That nets to no observable change once the view
97
+ * settles, but it is no longer suppressed *at this boundary* (the netting/reordering
98
+ * that did so was the source of the coalescer correctness bugs). Restoring
99
+ * no-op-cycle ⇒ no-notify is a view-level optimization (Step 2 of the removal).
100
+ * @returns {any}
101
+ */
102
+ serverBatchEnd() {
103
+ const ret = wasm.db_serverBatchEnd(this.__wbg_ptr);
104
+ if (ret[2]) {
105
+ throw takeFromExternrefTable0(ret[1]);
106
+ }
107
+ return takeFromExternrefTable0(ret[0]);
108
+ }
109
+ /**
110
+ * Remove a base table previously added by [`register_table`](Self::register_table): free
111
+ * its source node, drop its optimistic baseline, and forget it from the source map — the
112
+ * inverse of `register_table`. For a SYNTHETIC aggregate table (`__agg_*`) whose last
113
+ * reading query has been destroyed (`AGGREGATE-SYNC-DESIGN.md` §4): aggregate state is
114
+ * reclaimed, not permanent. Idempotent for an unknown/already-removed table. Throws a JS
115
+ * `Error` if the table still has a live query connected to it — the caller must
116
+ * `destroy_query` every reader first (the optimistic/normalized backend refcounts so this
117
+ * holds).
118
+ * @param {string} table
119
+ */
120
+ unregisterTable(table) {
121
+ const ptr0 = passStringToWasm0(table, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
122
+ const len0 = WASM_VECTOR_LEN;
123
+ const ret = wasm.db_unregisterTable(this.__wbg_ptr, ptr0, len0);
124
+ if (ret[1]) {
125
+ throw takeFromExternrefTable0(ret[0]);
126
+ }
127
+ }
128
+ /**
129
+ * Open a write transaction. Stage row ops with [`WriteTxn::add`]/`remove`/`edit`,
130
+ * then [`WriteTxn::commit`] to apply them as one batch and get the per-query flat
131
+ * changes back. Dropping (or `rollback`) without committing applies nothing.
132
+ * @returns {WriteTxn}
133
+ */
134
+ write() {
135
+ const ret = wasm.db_write(this.__wbg_ptr);
136
+ return WriteTxn.__wrap(ret);
137
+ }
138
+ }
139
+ if (Symbol.dispose) Db.prototype[Symbol.dispose] = Db.prototype.free;
140
+
141
+ /**
142
+ * A built, hydrated query view, callable from JavaScript.
143
+ */
144
+ export class RindleView {
145
+ static __wrap(ptr) {
146
+ const obj = Object.create(RindleView.prototype);
147
+ obj.__wbg_ptr = ptr;
148
+ RindleViewFinalization.register(obj, obj.__wbg_ptr, obj);
149
+ return obj;
150
+ }
151
+ __destroy_into_raw() {
152
+ const ptr = this.__wbg_ptr;
153
+ this.__wbg_ptr = 0;
154
+ RindleViewFinalization.unregister(this);
155
+ return ptr;
156
+ }
157
+ free() {
158
+ const ptr = this.__destroy_into_raw();
159
+ wasm.__wbg_rindleview_free(ptr, 0);
160
+ }
161
+ /**
162
+ * Build + hydrate a view from an AST (JS JSON) and a table→schema map.
163
+ *
164
+ * - `ast_json`: the query AST — Zero's wire shape (see `src/ast.rs`).
165
+ * - `schemas`: `{ tableName: <SchemaSpec> }` (see [`marshal::schema_from_js`]).
166
+ * - `data`: optional `{ tableName: row[][] }` initial rows (each row a cell
167
+ * array, positional with the schema's `columns`); a table absent here seeds
168
+ * empty.
169
+ *
170
+ * A `BuildError`/`RindleError` is thrown as a JS `Error` with a `.kind` tag.
171
+ * @param {any} ast_json
172
+ * @param {any} schemas
173
+ * @param {any} data
174
+ * @returns {RindleView}
175
+ */
176
+ static build(ast_json, schemas, data) {
177
+ const ret = wasm.rindleview_build(ast_json, schemas, data);
178
+ if (ret[2]) {
179
+ throw takeFromExternrefTable0(ret[1]);
180
+ }
181
+ return RindleView.__wrap(ret[0]);
182
+ }
183
+ /**
184
+ * The current materialized view tree as a JS value (array / object / `null`).
185
+ * @returns {any}
186
+ */
187
+ data() {
188
+ const ret = wasm.rindleview_data(this.__wbg_ptr);
189
+ return ret;
190
+ }
191
+ /**
192
+ * Close the current transaction: fire listeners with the new snapshot.
193
+ */
194
+ flush() {
195
+ wasm.rindleview_flush(this.__wbg_ptr);
196
+ }
197
+ /**
198
+ * Push one source change `{ type: 'add'|'remove'|'edit', row, old? }` to `table`.
199
+ * Does **not** flush — call [`RindleView::flush`] to close the transaction (so a JS
200
+ * client can batch several pushes into one notification).
201
+ * @param {string} table
202
+ * @param {any} change
203
+ */
204
+ push(table, change) {
205
+ const ptr0 = passStringToWasm0(table, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
206
+ const len0 = WASM_VECTOR_LEN;
207
+ const ret = wasm.rindleview_push(this.__wbg_ptr, ptr0, len0, change);
208
+ if (ret[1]) {
209
+ throw takeFromExternrefTable0(ret[0]);
210
+ }
211
+ }
212
+ /**
213
+ * The view's current result type (`"unknown" | "complete" | "error"`).
214
+ * @returns {any}
215
+ */
216
+ resultType() {
217
+ const ret = wasm.rindleview_resultType(this.__wbg_ptr);
218
+ return ret;
219
+ }
220
+ /**
221
+ * Resolve the async result type (the `queryComplete` transition); fires
222
+ * listeners out of band. Accepts `"complete" | "error" | "unknown"`.
223
+ * @param {string} rt
224
+ */
225
+ setResultType(rt) {
226
+ const ptr0 = passStringToWasm0(rt, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
227
+ const len0 = WASM_VECTOR_LEN;
228
+ wasm.rindleview_setResultType(this.__wbg_ptr, ptr0, len0);
229
+ }
230
+ /**
231
+ * Subscribe a JS callback `(data, resultType) => void`, fired **once
232
+ * immediately** and on every subsequent [`RindleView::flush`]. Returns the
233
+ * listener index.
234
+ * @param {Function} cb
235
+ * @returns {number}
236
+ */
237
+ subscribe(cb) {
238
+ const ret = wasm.rindleview_subscribe(this.__wbg_ptr, cb);
239
+ return ret >>> 0;
240
+ }
241
+ }
242
+ if (Symbol.dispose) RindleView.prototype[Symbol.dispose] = RindleView.prototype.free;
243
+
244
+ /**
245
+ * An open write transaction: a staging buffer of row ops applied atomically at
246
+ * [`commit`](WriteTxn::commit). Nothing touches the engine until commit, so a dropped or
247
+ * rolled-back txn is a clean no-op (no `Drop` undo needed).
248
+ */
249
+ export class WriteTxn {
250
+ static __wrap(ptr) {
251
+ const obj = Object.create(WriteTxn.prototype);
252
+ obj.__wbg_ptr = ptr;
253
+ WriteTxnFinalization.register(obj, obj.__wbg_ptr, obj);
254
+ return obj;
255
+ }
256
+ __destroy_into_raw() {
257
+ const ptr = this.__wbg_ptr;
258
+ this.__wbg_ptr = 0;
259
+ WriteTxnFinalization.unregister(this);
260
+ return ptr;
261
+ }
262
+ free() {
263
+ const ptr = this.__destroy_into_raw();
264
+ wasm.__wbg_writetxn_free(ptr, 0);
265
+ }
266
+ /**
267
+ * Stage an add of `row` (a positional cell array, width-checked against the table's
268
+ * schema) to `table`.
269
+ * @param {string} table
270
+ * @param {any} row
271
+ */
272
+ add(table, row) {
273
+ const ptr0 = passStringToWasm0(table, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
274
+ const len0 = WASM_VECTOR_LEN;
275
+ const ret = wasm.writetxn_add(this.__wbg_ptr, ptr0, len0, row);
276
+ if (ret[1]) {
277
+ throw takeFromExternrefTable0(ret[0]);
278
+ }
279
+ }
280
+ /**
281
+ * Apply the staged ops (push through the shared sources, fanning to every dependent
282
+ * query), drain each affected query's sink, and return `[{ queryId, events:
283
+ * FlatChange[] }]` for the queries that changed (empties omitted, like
284
+ * `Publisher::commit`). Consumes the transaction.
285
+ *
286
+ * **Inside a server-batch cycle** (a pending mutator re-invocation between
287
+ * [`Db::server_batch_begin`] and [`Db::server_batch_end`]) the drained events
288
+ * buffer into the cycle instead and an **empty** array returns — the §3
289
+ * notify-once boundary: the whole cycle delivers exactly once, coalesced, at
290
+ * `serverBatchEnd`.
291
+ * @returns {any}
292
+ */
293
+ commit() {
294
+ const ptr = this.__destroy_into_raw();
295
+ const ret = wasm.writetxn_commit(ptr);
296
+ if (ret[2]) {
297
+ throw takeFromExternrefTable0(ret[1]);
298
+ }
299
+ return takeFromExternrefTable0(ret[0]);
300
+ }
301
+ /**
302
+ * Stage an edit of `old` → `new_row` in `table` (both width-checked).
303
+ *
304
+ * **Partial (optimistic) edit (`PROJECTION-SUPPORT-DESIGN.md` §8 / OQ-3).** An
305
+ * [`OwnedValue::Absent`] cell in `new_row` means *"not touching this column — leave it
306
+ * unchanged"*: it falls through to the current **effective** row (the live engine under
307
+ * this txn's staged overlay, i.e. what [`WriteTxn::get`] would return). The merge is
308
+ * resolved **here, at the staging boundary**, into a concrete full-width
309
+ * [`SourceChange::Edit`] whose `old` is that effective row — so operators, indexes, and
310
+ * the overlay never learn about merge semantics (they keep seeing whole rows), and a
311
+ * re-invocation after a server rebase re-reads the *new* effective row and re-merges.
312
+ * Presence is **monotonic**: a partial edit only *sets* columns (or leaves them), never
313
+ * narrows — narrowing is sync-only (§4.2). A full `new_row` (no `Absent`) stages verbatim,
314
+ * byte-identical to before (§7).
315
+ * @param {string} table
316
+ * @param {any} old
317
+ * @param {any} new_row
318
+ */
319
+ edit(table, old, new_row) {
320
+ const ptr0 = passStringToWasm0(table, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
321
+ const len0 = WASM_VECTOR_LEN;
322
+ const ret = wasm.writetxn_edit(this.__wbg_ptr, ptr0, len0, old, new_row);
323
+ if (ret[1]) {
324
+ throw takeFromExternrefTable0(ret[0]);
325
+ }
326
+ }
327
+ /**
328
+ * The current row of `table` whose primary key equals `pk` (an array of the PK
329
+ * column cells, in `primaryKey` order), or `undefined`. Reads the live engine
330
+ * state **plus this transaction's own staged ops** (later staged ops win), so a
331
+ * read-dependent client mutator sees its prior writes — the §4.1 contract. During
332
+ * a server-batch cycle the live state is the rebased base (`S'` + the pending
333
+ * mutations re-invoked so far), which is exactly what re-invocation must read.
334
+ * @param {string} table
335
+ * @param {any} pk
336
+ * @returns {any}
337
+ */
338
+ get(table, pk) {
339
+ const ptr0 = passStringToWasm0(table, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
340
+ const len0 = WASM_VECTOR_LEN;
341
+ const ret = wasm.writetxn_get(this.__wbg_ptr, ptr0, len0, pk);
342
+ if (ret[2]) {
343
+ throw takeFromExternrefTable0(ret[1]);
344
+ }
345
+ return takeFromExternrefTable0(ret[0]);
346
+ }
347
+ /**
348
+ * Stage a remove of `row` from `table`.
349
+ * @param {string} table
350
+ * @param {any} row
351
+ */
352
+ remove(table, row) {
353
+ const ptr0 = passStringToWasm0(table, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
354
+ const len0 = WASM_VECTOR_LEN;
355
+ const ret = wasm.writetxn_remove(this.__wbg_ptr, ptr0, len0, row);
356
+ if (ret[1]) {
357
+ throw takeFromExternrefTable0(ret[0]);
358
+ }
359
+ }
360
+ /**
361
+ * Discard the staged ops without applying anything. (Nothing was applied, so this
362
+ * just consumes the handle; it exists for a symmetric, explicit API.)
363
+ */
364
+ rollback() {
365
+ const ptr = this.__destroy_into_raw();
366
+ wasm.writetxn_rollback(ptr);
367
+ }
368
+ }
369
+ if (Symbol.dispose) WriteTxn.prototype[Symbol.dispose] = WriteTxn.prototype.free;
370
+
371
+ /**
372
+ * Install the panic hook so a residual wasm panic surfaces a legible JS `Error`
373
+ * (with a Rust message) instead of an opaque `RuntimeError: unreachable` (WS09.6).
374
+ * Runs once on module load.
375
+ */
376
+ export function __rindle_wasm_start() {
377
+ wasm.__rindle_wasm_start();
378
+ }
379
+ function __wbg_get_imports() {
380
+ const import0 = {
381
+ __proto__: null,
382
+ __wbg_Error_ef53bc310eb298a0: function(arg0, arg1) {
383
+ const ret = Error(getStringFromWasm0(arg0, arg1));
384
+ return ret;
385
+ },
386
+ __wbg_Number_6b506e6536831eaa: function(arg0) {
387
+ const ret = Number(arg0);
388
+ return ret;
389
+ },
390
+ __wbg_String_8564e559799eccda: function(arg0, arg1) {
391
+ const ret = String(arg1);
392
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
393
+ const len1 = WASM_VECTOR_LEN;
394
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
395
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
396
+ },
397
+ __wbg___wbindgen_bigint_get_as_i64_38130e98eecd467d: function(arg0, arg1) {
398
+ const v = arg1;
399
+ const ret = typeof(v) === 'bigint' ? v : undefined;
400
+ getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
401
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
402
+ },
403
+ __wbg___wbindgen_boolean_get_1a45e2c38d4d41b9: function(arg0) {
404
+ const v = arg0;
405
+ const ret = typeof(v) === 'boolean' ? v : undefined;
406
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
407
+ },
408
+ __wbg___wbindgen_debug_string_0accd80f45e5faa2: function(arg0, arg1) {
409
+ const ret = debugString(arg1);
410
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
411
+ const len1 = WASM_VECTOR_LEN;
412
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
413
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
414
+ },
415
+ __wbg___wbindgen_in_70a403a56e771704: function(arg0, arg1) {
416
+ const ret = arg0 in arg1;
417
+ return ret;
418
+ },
419
+ __wbg___wbindgen_is_bigint_6ffd6468a9bc44b9: function(arg0) {
420
+ const ret = typeof(arg0) === 'bigint';
421
+ return ret;
422
+ },
423
+ __wbg___wbindgen_is_function_754e9f305ff6029e: function(arg0) {
424
+ const ret = typeof(arg0) === 'function';
425
+ return ret;
426
+ },
427
+ __wbg___wbindgen_is_null_87c3bfe968c6a5ad: function(arg0) {
428
+ const ret = arg0 === null;
429
+ return ret;
430
+ },
431
+ __wbg___wbindgen_is_object_56732c2bc353f41d: function(arg0) {
432
+ const val = arg0;
433
+ const ret = typeof(val) === 'object' && val !== null;
434
+ return ret;
435
+ },
436
+ __wbg___wbindgen_is_string_c236cabd84a4d769: function(arg0) {
437
+ const ret = typeof(arg0) === 'string';
438
+ return ret;
439
+ },
440
+ __wbg___wbindgen_is_undefined_67b456be8673d3d7: function(arg0) {
441
+ const ret = arg0 === undefined;
442
+ return ret;
443
+ },
444
+ __wbg___wbindgen_jsval_eq_1068e624fa87f6ab: function(arg0, arg1) {
445
+ const ret = arg0 === arg1;
446
+ return ret;
447
+ },
448
+ __wbg___wbindgen_jsval_loose_eq_2c56564c75129511: function(arg0, arg1) {
449
+ const ret = arg0 == arg1;
450
+ return ret;
451
+ },
452
+ __wbg___wbindgen_number_get_9bb1761122181af2: function(arg0, arg1) {
453
+ const obj = arg1;
454
+ const ret = typeof(obj) === 'number' ? obj : undefined;
455
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
456
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
457
+ },
458
+ __wbg___wbindgen_string_get_72bdf95d3ae505b1: function(arg0, arg1) {
459
+ const obj = arg1;
460
+ const ret = typeof(obj) === 'string' ? obj : undefined;
461
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
462
+ var len1 = WASM_VECTOR_LEN;
463
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
464
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
465
+ },
466
+ __wbg___wbindgen_throw_1506f2235d1bdba0: function(arg0, arg1) {
467
+ throw new Error(getStringFromWasm0(arg0, arg1));
468
+ },
469
+ __wbg_call_40e4174f169eaca7: function() { return handleError(function (arg0, arg1, arg2, arg3) {
470
+ const ret = arg0.call(arg1, arg2, arg3);
471
+ return ret;
472
+ }, arguments); },
473
+ __wbg_call_8a89609d89f6608a: function() { return handleError(function (arg0, arg1) {
474
+ const ret = arg0.call(arg1);
475
+ return ret;
476
+ }, arguments); },
477
+ __wbg_done_60cf307fcc680536: function(arg0) {
478
+ const ret = arg0.done;
479
+ return ret;
480
+ },
481
+ __wbg_entries_04b37a02507f1713: function(arg0) {
482
+ const ret = Object.entries(arg0);
483
+ return ret;
484
+ },
485
+ __wbg_error_a6fa202b58aa1cd3: function(arg0, arg1) {
486
+ let deferred0_0;
487
+ let deferred0_1;
488
+ try {
489
+ deferred0_0 = arg0;
490
+ deferred0_1 = arg1;
491
+ console.error(getStringFromWasm0(arg0, arg1));
492
+ } finally {
493
+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
494
+ }
495
+ },
496
+ __wbg_from_d300fe49deab18f5: function(arg0) {
497
+ const ret = Array.from(arg0);
498
+ return ret;
499
+ },
500
+ __wbg_get_1f8f054ddbaa7db2: function() { return handleError(function (arg0, arg1) {
501
+ const ret = Reflect.get(arg0, arg1);
502
+ return ret;
503
+ }, arguments); },
504
+ __wbg_get_2b48c7d0d006a781: function(arg0, arg1) {
505
+ const ret = arg0[arg1 >>> 0];
506
+ return ret;
507
+ },
508
+ __wbg_get_de6a0f7d4d18a304: function() { return handleError(function (arg0, arg1) {
509
+ const ret = Reflect.get(arg0, arg1);
510
+ return ret;
511
+ }, arguments); },
512
+ __wbg_get_unchecked_33f6e5c9e2f2d6b2: function(arg0, arg1) {
513
+ const ret = arg0[arg1 >>> 0];
514
+ return ret;
515
+ },
516
+ __wbg_get_with_ref_key_6412cf3094599694: function(arg0, arg1) {
517
+ const ret = arg0[arg1];
518
+ return ret;
519
+ },
520
+ __wbg_instanceof_ArrayBuffer_8f49811467741499: function(arg0) {
521
+ let result;
522
+ try {
523
+ result = arg0 instanceof ArrayBuffer;
524
+ } catch (_) {
525
+ result = false;
526
+ }
527
+ const ret = result;
528
+ return ret;
529
+ },
530
+ __wbg_instanceof_Map_9fc06d9a951bcee6: function(arg0) {
531
+ let result;
532
+ try {
533
+ result = arg0 instanceof Map;
534
+ } catch (_) {
535
+ result = false;
536
+ }
537
+ const ret = result;
538
+ return ret;
539
+ },
540
+ __wbg_instanceof_Object_873c13f9f41aec78: function(arg0) {
541
+ let result;
542
+ try {
543
+ result = arg0 instanceof Object;
544
+ } catch (_) {
545
+ result = false;
546
+ }
547
+ const ret = result;
548
+ return ret;
549
+ },
550
+ __wbg_instanceof_Uint8Array_86f30649f63ef9c2: function(arg0) {
551
+ let result;
552
+ try {
553
+ result = arg0 instanceof Uint8Array;
554
+ } catch (_) {
555
+ result = false;
556
+ }
557
+ const ret = result;
558
+ return ret;
559
+ },
560
+ __wbg_isArray_67c2c9c4313f4448: function(arg0) {
561
+ const ret = Array.isArray(arg0);
562
+ return ret;
563
+ },
564
+ __wbg_isSafeInteger_66acec27e09e99a7: function(arg0) {
565
+ const ret = Number.isSafeInteger(arg0);
566
+ return ret;
567
+ },
568
+ __wbg_iterator_8732428d309e270e: function() {
569
+ const ret = Symbol.iterator;
570
+ return ret;
571
+ },
572
+ __wbg_length_4a591ecaa01354d9: function(arg0) {
573
+ const ret = arg0.length;
574
+ return ret;
575
+ },
576
+ __wbg_length_66f1a4b2e9026940: function(arg0) {
577
+ const ret = arg0.length;
578
+ return ret;
579
+ },
580
+ __wbg_new_227d7c05414eb861: function() {
581
+ const ret = new Error();
582
+ return ret;
583
+ },
584
+ __wbg_new_50bb5ebeecef71a8: function(arg0, arg1) {
585
+ const ret = new Error(getStringFromWasm0(arg0, arg1));
586
+ return ret;
587
+ },
588
+ __wbg_new_578aeef4b6b94378: function(arg0) {
589
+ const ret = new Uint8Array(arg0);
590
+ return ret;
591
+ },
592
+ __wbg_new_ce1ab61c1c2b300d: function() {
593
+ const ret = new Object();
594
+ return ret;
595
+ },
596
+ __wbg_new_d90091b82fdf5b91: function() {
597
+ const ret = new Array();
598
+ return ret;
599
+ },
600
+ __wbg_next_9e03acdf51c4960d: function(arg0) {
601
+ const ret = arg0.next;
602
+ return ret;
603
+ },
604
+ __wbg_next_eb8ca7351fa27906: function() { return handleError(function (arg0) {
605
+ const ret = arg0.next();
606
+ return ret;
607
+ }, arguments); },
608
+ __wbg_prototypesetcall_3249fc62a0fafa30: function(arg0, arg1, arg2) {
609
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
610
+ },
611
+ __wbg_push_a6822215aa43e71c: function(arg0, arg1) {
612
+ const ret = arg0.push(arg1);
613
+ return ret;
614
+ },
615
+ __wbg_set_6e30c9374c26414c: function() { return handleError(function (arg0, arg1, arg2) {
616
+ const ret = Reflect.set(arg0, arg1, arg2);
617
+ return ret;
618
+ }, arguments); },
619
+ __wbg_stack_3b0d974bbf31e44f: function(arg0, arg1) {
620
+ const ret = arg1.stack;
621
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
622
+ const len1 = WASM_VECTOR_LEN;
623
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
624
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
625
+ },
626
+ __wbg_stringify_8286df6dcc591521: function() { return handleError(function (arg0) {
627
+ const ret = JSON.stringify(arg0);
628
+ return ret;
629
+ }, arguments); },
630
+ __wbg_value_f3625092ee4b37f4: function(arg0) {
631
+ const ret = arg0.value;
632
+ return ret;
633
+ },
634
+ __wbindgen_cast_0000000000000001: function(arg0) {
635
+ // Cast intrinsic for `F64 -> Externref`.
636
+ const ret = arg0;
637
+ return ret;
638
+ },
639
+ __wbindgen_cast_0000000000000002: function(arg0) {
640
+ // Cast intrinsic for `I64 -> Externref`.
641
+ const ret = arg0;
642
+ return ret;
643
+ },
644
+ __wbindgen_cast_0000000000000003: function(arg0, arg1) {
645
+ // Cast intrinsic for `Ref(String) -> Externref`.
646
+ const ret = getStringFromWasm0(arg0, arg1);
647
+ return ret;
648
+ },
649
+ __wbindgen_cast_0000000000000004: function(arg0) {
650
+ // Cast intrinsic for `U64 -> Externref`.
651
+ const ret = BigInt.asUintN(64, arg0);
652
+ return ret;
653
+ },
654
+ __wbindgen_init_externref_table: function() {
655
+ const table = wasm.__wbindgen_externrefs;
656
+ const offset = table.grow(4);
657
+ table.set(0, undefined);
658
+ table.set(offset + 0, undefined);
659
+ table.set(offset + 1, null);
660
+ table.set(offset + 2, true);
661
+ table.set(offset + 3, false);
662
+ },
663
+ };
664
+ return {
665
+ __proto__: null,
666
+ "./rindle_bg.js": import0,
667
+ };
668
+ }
669
+
670
+ const DbFinalization = (typeof FinalizationRegistry === 'undefined')
671
+ ? { register: () => {}, unregister: () => {} }
672
+ : new FinalizationRegistry(ptr => wasm.__wbg_db_free(ptr, 1));
673
+ const RindleViewFinalization = (typeof FinalizationRegistry === 'undefined')
674
+ ? { register: () => {}, unregister: () => {} }
675
+ : new FinalizationRegistry(ptr => wasm.__wbg_rindleview_free(ptr, 1));
676
+ const WriteTxnFinalization = (typeof FinalizationRegistry === 'undefined')
677
+ ? { register: () => {}, unregister: () => {} }
678
+ : new FinalizationRegistry(ptr => wasm.__wbg_writetxn_free(ptr, 1));
679
+
680
+ function addToExternrefTable0(obj) {
681
+ const idx = wasm.__externref_table_alloc();
682
+ wasm.__wbindgen_externrefs.set(idx, obj);
683
+ return idx;
684
+ }
685
+
686
+ function debugString(val) {
687
+ // primitive types
688
+ const type = typeof val;
689
+ if (type == 'number' || type == 'boolean' || val == null) {
690
+ return `${val}`;
691
+ }
692
+ if (type == 'string') {
693
+ return `"${val}"`;
694
+ }
695
+ if (type == 'symbol') {
696
+ const description = val.description;
697
+ if (description == null) {
698
+ return 'Symbol';
699
+ } else {
700
+ return `Symbol(${description})`;
701
+ }
702
+ }
703
+ if (type == 'function') {
704
+ const name = val.name;
705
+ if (typeof name == 'string' && name.length > 0) {
706
+ return `Function(${name})`;
707
+ } else {
708
+ return 'Function';
709
+ }
710
+ }
711
+ // objects
712
+ if (Array.isArray(val)) {
713
+ const length = val.length;
714
+ let debug = '[';
715
+ if (length > 0) {
716
+ debug += debugString(val[0]);
717
+ }
718
+ for(let i = 1; i < length; i++) {
719
+ debug += ', ' + debugString(val[i]);
720
+ }
721
+ debug += ']';
722
+ return debug;
723
+ }
724
+ // Test for built-in
725
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
726
+ let className;
727
+ if (builtInMatches && builtInMatches.length > 1) {
728
+ className = builtInMatches[1];
729
+ } else {
730
+ // Failed to match the standard '[object ClassName]'
731
+ return toString.call(val);
732
+ }
733
+ if (className == 'Object') {
734
+ // we're a user defined class or Object
735
+ // JSON.stringify avoids problems with cycles, and is generally much
736
+ // easier than looping through ownProperties of `val`.
737
+ try {
738
+ return 'Object(' + JSON.stringify(val) + ')';
739
+ } catch (_) {
740
+ return 'Object';
741
+ }
742
+ }
743
+ // errors
744
+ if (val instanceof Error) {
745
+ return `${val.name}: ${val.message}\n${val.stack}`;
746
+ }
747
+ // TODO we could test for more things here, like `Set`s and `Map`s.
748
+ return className;
749
+ }
750
+
751
+ function getArrayU8FromWasm0(ptr, len) {
752
+ ptr = ptr >>> 0;
753
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
754
+ }
755
+
756
+ let cachedDataViewMemory0 = null;
757
+ function getDataViewMemory0() {
758
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
759
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
760
+ }
761
+ return cachedDataViewMemory0;
762
+ }
763
+
764
+ function getStringFromWasm0(ptr, len) {
765
+ return decodeText(ptr >>> 0, len);
766
+ }
767
+
768
+ let cachedUint8ArrayMemory0 = null;
769
+ function getUint8ArrayMemory0() {
770
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
771
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
772
+ }
773
+ return cachedUint8ArrayMemory0;
774
+ }
775
+
776
+ function handleError(f, args) {
777
+ try {
778
+ return f.apply(this, args);
779
+ } catch (e) {
780
+ const idx = addToExternrefTable0(e);
781
+ wasm.__wbindgen_exn_store(idx);
782
+ }
783
+ }
784
+
785
+ function isLikeNone(x) {
786
+ return x === undefined || x === null;
787
+ }
788
+
789
+ function passStringToWasm0(arg, malloc, realloc) {
790
+ if (realloc === undefined) {
791
+ const buf = cachedTextEncoder.encode(arg);
792
+ const ptr = malloc(buf.length, 1) >>> 0;
793
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
794
+ WASM_VECTOR_LEN = buf.length;
795
+ return ptr;
796
+ }
797
+
798
+ let len = arg.length;
799
+ let ptr = malloc(len, 1) >>> 0;
800
+
801
+ const mem = getUint8ArrayMemory0();
802
+
803
+ let offset = 0;
804
+
805
+ for (; offset < len; offset++) {
806
+ const code = arg.charCodeAt(offset);
807
+ if (code > 0x7F) break;
808
+ mem[ptr + offset] = code;
809
+ }
810
+ if (offset !== len) {
811
+ if (offset !== 0) {
812
+ arg = arg.slice(offset);
813
+ }
814
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
815
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
816
+ const ret = cachedTextEncoder.encodeInto(arg, view);
817
+
818
+ offset += ret.written;
819
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
820
+ }
821
+
822
+ WASM_VECTOR_LEN = offset;
823
+ return ptr;
824
+ }
825
+
826
+ function takeFromExternrefTable0(idx) {
827
+ const value = wasm.__wbindgen_externrefs.get(idx);
828
+ wasm.__externref_table_dealloc(idx);
829
+ return value;
830
+ }
831
+
832
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
833
+ cachedTextDecoder.decode();
834
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
835
+ let numBytesDecoded = 0;
836
+ function decodeText(ptr, len) {
837
+ numBytesDecoded += len;
838
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
839
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
840
+ cachedTextDecoder.decode();
841
+ numBytesDecoded = len;
842
+ }
843
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
844
+ }
845
+
846
+ const cachedTextEncoder = new TextEncoder();
847
+
848
+ if (!('encodeInto' in cachedTextEncoder)) {
849
+ cachedTextEncoder.encodeInto = function (arg, view) {
850
+ const buf = cachedTextEncoder.encode(arg);
851
+ view.set(buf);
852
+ return {
853
+ read: arg.length,
854
+ written: buf.length
855
+ };
856
+ };
857
+ }
858
+
859
+ let WASM_VECTOR_LEN = 0;
860
+
861
+ let wasmModule, wasmInstance, wasm;
862
+ function __wbg_finalize_init(instance, module) {
863
+ wasmInstance = instance;
864
+ wasm = instance.exports;
865
+ wasmModule = module;
866
+ cachedDataViewMemory0 = null;
867
+ cachedUint8ArrayMemory0 = null;
868
+ wasm.__wbindgen_start();
869
+ return wasm;
870
+ }
871
+
872
+ async function __wbg_load(module, imports) {
873
+ if (typeof Response === 'function' && module instanceof Response) {
874
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
875
+ try {
876
+ return await WebAssembly.instantiateStreaming(module, imports);
877
+ } catch (e) {
878
+ const validResponse = module.ok && expectedResponseType(module.type);
879
+
880
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
881
+ 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);
882
+
883
+ } else { throw e; }
884
+ }
885
+ }
886
+
887
+ const bytes = await module.arrayBuffer();
888
+ return await WebAssembly.instantiate(bytes, imports);
889
+ } else {
890
+ const instance = await WebAssembly.instantiate(module, imports);
891
+
892
+ if (instance instanceof WebAssembly.Instance) {
893
+ return { instance, module };
894
+ } else {
895
+ return instance;
896
+ }
897
+ }
898
+
899
+ function expectedResponseType(type) {
900
+ switch (type) {
901
+ case 'basic': case 'cors': case 'default': return true;
902
+ }
903
+ return false;
904
+ }
905
+ }
906
+
907
+ function initSync(module) {
908
+ if (wasm !== undefined) return wasm;
909
+
910
+
911
+ if (module !== undefined) {
912
+ if (Object.getPrototypeOf(module) === Object.prototype) {
913
+ ({module} = module)
914
+ } else {
915
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
916
+ }
917
+ }
918
+
919
+ const imports = __wbg_get_imports();
920
+ if (!(module instanceof WebAssembly.Module)) {
921
+ module = new WebAssembly.Module(module);
922
+ }
923
+ const instance = new WebAssembly.Instance(module, imports);
924
+ return __wbg_finalize_init(instance, module);
925
+ }
926
+
927
+ async function __wbg_init(module_or_path) {
928
+ if (wasm !== undefined) return wasm;
929
+
930
+
931
+ if (module_or_path !== undefined) {
932
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
933
+ ({module_or_path} = module_or_path)
934
+ } else {
935
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
936
+ }
937
+ }
938
+
939
+ if (module_or_path === undefined) {
940
+ module_or_path = new URL('rindle_bg.wasm', import.meta.url);
941
+ }
942
+ const imports = __wbg_get_imports();
943
+
944
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
945
+ module_or_path = fetch(module_or_path);
946
+ }
947
+
948
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
949
+
950
+ return __wbg_finalize_init(instance, module);
951
+ }
952
+
953
+ export { initSync, __wbg_init as default };