@dreamlake/dreamdb 0.3.1 → 0.4.0

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/web/dreamdb.js ADDED
@@ -0,0 +1,1558 @@
1
+ /* @ts-self-types="./dreamdb.d.ts" */
2
+
3
+ /**
4
+ * A `fetch`-backed backend rooted at a base URL.
5
+ */
6
+ export class S3Backend {
7
+ __destroy_into_raw() {
8
+ const ptr = this.__wbg_ptr;
9
+ this.__wbg_ptr = 0;
10
+ S3BackendFinalization.unregister(this);
11
+ return ptr;
12
+ }
13
+ free() {
14
+ const ptr = this.__destroy_into_raw();
15
+ wasm.__wbg_s3backend_free(ptr, 0);
16
+ }
17
+ /**
18
+ * Fetch `path` (relative to the base URL) and resolve to its bytes.
19
+ * `opts.noCache` is accepted for API compatibility (currently a no-op:
20
+ * content is hash-addressed; refs are read fresh each page load anyway).
21
+ * @param {string} path
22
+ * @param {any} _opts
23
+ * @returns {Promise<Uint8Array>}
24
+ */
25
+ get(path, _opts) {
26
+ const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
27
+ const len0 = WASM_VECTOR_LEN;
28
+ const ret = wasm.s3backend_get(this.__wbg_ptr, ptr0, len0, _opts);
29
+ return ret;
30
+ }
31
+ /**
32
+ * List object paths under `prefix`. Stub (returns empty); the current
33
+ * consumer read paths don't require listing.
34
+ * @param {string} _prefix
35
+ * @returns {Promise<Array<any>>}
36
+ */
37
+ list(_prefix) {
38
+ const ptr0 = passStringToWasm0(_prefix, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
39
+ const len0 = WASM_VECTOR_LEN;
40
+ const ret = wasm.s3backend_list(this.__wbg_ptr, ptr0, len0);
41
+ return ret;
42
+ }
43
+ /**
44
+ * Construct rooted at `base_url` (trailing slash trimmed).
45
+ * @param {string} base_url
46
+ */
47
+ constructor(base_url) {
48
+ const ptr0 = passStringToWasm0(base_url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
49
+ const len0 = WASM_VECTOR_LEN;
50
+ const ret = wasm.s3backend_new(ptr0, len0);
51
+ this.__wbg_ptr = ret;
52
+ S3BackendFinalization.register(this, this.__wbg_ptr, this);
53
+ return this;
54
+ }
55
+ }
56
+ if (Symbol.dispose) S3Backend.prototype[Symbol.dispose] = S3Backend.prototype.free;
57
+
58
+ export class Space {
59
+ static __wrap(ptr) {
60
+ const obj = Object.create(Space.prototype);
61
+ obj.__wbg_ptr = ptr;
62
+ SpaceFinalization.register(obj, obj.__wbg_ptr, obj);
63
+ return obj;
64
+ }
65
+ __destroy_into_raw() {
66
+ const ptr = this.__wbg_ptr;
67
+ this.__wbg_ptr = 0;
68
+ SpaceFinalization.unregister(this);
69
+ return ptr;
70
+ }
71
+ free() {
72
+ const ptr = this.__destroy_into_raw();
73
+ wasm.__wbg_space_free(ptr, 0);
74
+ }
75
+ /**
76
+ * The base URL objects are fetched relative to (consumers build their own
77
+ * object URLs from this — e.g. `dreamdb-demo`'s track readers).
78
+ * @returns {string}
79
+ */
80
+ get connectorBase() {
81
+ let deferred1_0;
82
+ let deferred1_1;
83
+ try {
84
+ const ret = wasm.space_connectorBase(this.__wbg_ptr);
85
+ deferred1_0 = ret[0];
86
+ deferred1_1 = ret[1];
87
+ return getStringFromWasm0(ret[0], ret[1]);
88
+ } finally {
89
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
90
+ }
91
+ }
92
+ /**
93
+ * Open a Space from a `.../refs/<name>` or `.../manifests/<hash>` URI,
94
+ * resolving the ref (if any) and loading the manifest. If `backend` is
95
+ * provided it handles IO (relative paths); otherwise a direct-fetch
96
+ * connector rooted at the parsed base URL is used (the `dreamdb-demo`
97
+ * no-backend path).
98
+ * @param {string} uri
99
+ * @param {any} backend
100
+ * @returns {Promise<Space>}
101
+ */
102
+ static fromUri(uri, backend) {
103
+ const ptr0 = passStringToWasm0(uri, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
104
+ const len0 = WASM_VECTOR_LEN;
105
+ const ret = wasm.space_fromUri(ptr0, len0, backend);
106
+ return ret;
107
+ }
108
+ /**
109
+ * Walk the manifest DAG from HEAD, up to `max_depth` entries. Each entry:
110
+ * `{ manifestHash, ts, writer, tracks: [{modality, address}] }`.
111
+ * @param {number | null} [max_depth]
112
+ * @returns {Promise<Array<any>>}
113
+ */
114
+ history(max_depth) {
115
+ const ret = wasm.space_history(this.__wbg_ptr, isLikeNone(max_depth) ? Number.MAX_SAFE_INTEGER : (max_depth) >>> 0);
116
+ return ret;
117
+ }
118
+ /**
119
+ * The manifest's base32 multihash.
120
+ * @returns {string}
121
+ */
122
+ get manifestHash() {
123
+ let deferred1_0;
124
+ let deferred1_1;
125
+ try {
126
+ const ret = wasm.space_manifestHash(this.__wbg_ptr);
127
+ deferred1_0 = ret[0];
128
+ deferred1_1 = ret[1];
129
+ return getStringFromWasm0(ret[0], ret[1]);
130
+ } finally {
131
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
132
+ }
133
+ }
134
+ /**
135
+ * Hybrid search fusing a lexical (BM25) sub-query and a dense (vector)
136
+ * sub-query per spec/0015 §5/§6. Returns the fused `[{ anchor, score }]`
137
+ * list sorted by fused score descending — the same scored shape as
138
+ * `queryVector`.
139
+ *
140
+ * `vector` is the dense sub-query embedding (a `Float32Array`). `opts` is a
141
+ * plain JS object:
142
+ * ```js
143
+ * {
144
+ * textField, textQuery, // BM25 sub-query (required)
145
+ * vectorField, // dense field the `vector` targets (required)
146
+ * topK = 10, // fused results to return
147
+ * fusion = 'rrf', // 'rrf' | 'linear' | 'max' | 'pareto'
148
+ * rrfK = 60, // RRF rank constant (fusion='rrf')
149
+ * textWeight = 1, vectorWeight = 1, // Linear weights (fusion='linear')
150
+ * textK = topK, vectorK = topK, // per-sub-query candidate depths
151
+ * textRequired = false, vectorRequired = false, // §5.3 boolean-AND gates
152
+ * }
153
+ * ```
154
+ *
155
+ * Delegates to the real (tested) `dreamdb-dataset::Dataset::query_hybrid`.
156
+ * (v0 does not expose the optional scalar pre/post-filter; it runs with no
157
+ * scalar gate.)
158
+ * @param {Float32Array} vector
159
+ * @param {any} opts
160
+ * @returns {Promise<Array<any>>}
161
+ */
162
+ queryHybrid(vector, opts) {
163
+ const ptr0 = passArrayF32ToWasm0(vector, wasm.__wbindgen_malloc);
164
+ const len0 = WASM_VECTOR_LEN;
165
+ const ret = wasm.space_queryHybrid(this.__wbg_ptr, ptr0, len0, opts);
166
+ return ret;
167
+ }
168
+ /**
169
+ * Scalar-index lookup: every anchor whose `field` satisfies `op value`
170
+ * (spec/0011). Returns a `BigUint64Array`-style `Array` of anchors,
171
+ * tombstone-suppressed, sorted ascending and deduped.
172
+ *
173
+ * This is the expansion half of a compact lexical index. A BM25 index
174
+ * built over a scalar field's DISTINCT values returns one representative
175
+ * anchor per matched value; resolving that value back to *every* record
176
+ * carrying it is a scalar-index lookup, not a text-index concern. Keeping
177
+ * the split this way is what lets the text index stay small enough to
178
+ * load in a browser — indexing one document per record instead produced a
179
+ * 406 MB object for ~1,700 distinct strings.
180
+ *
181
+ * `op` is one of `==`, `!=`, `<`, `<=`, `>`, `>=`. `value` may be a
182
+ * string, number, or boolean; strings match both `String` and
183
+ * `Categorical` scalar fields.
184
+ * @param {string} field
185
+ * @param {string} op
186
+ * @param {any} value
187
+ * @returns {Promise<Array<any>>}
188
+ */
189
+ queryScalar(field, op, value) {
190
+ const ptr0 = passStringToWasm0(field, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
191
+ const len0 = WASM_VECTOR_LEN;
192
+ const ptr1 = passStringToWasm0(op, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
193
+ const len1 = WASM_VECTOR_LEN;
194
+ const ret = wasm.space_queryScalar(this.__wbg_ptr, ptr0, len0, ptr1, len1, value);
195
+ return ret;
196
+ }
197
+ /**
198
+ * Lexical BM25 text search over a text `field` (spec/0015 §3.6).
199
+ *
200
+ * Tokenizes `query` with the built-in `dreamdb.utf8-words` tokenizer
201
+ * (lowercase + split on non-alphanumeric — pure Rust, compiled into the
202
+ * wasm; no external model needed even though the field's embeddings were
203
+ * produced elsewhere), scores docs with BM25, and suppresses tombstoned
204
+ * anchors. Returns `[{ anchor, score }]` sorted by score descending — the
205
+ * same scored shape as `queryVector`.
206
+ *
207
+ * Delegates to the real (tested) `dreamdb-dataset::Dataset::query_text`.
208
+ * @param {string} field
209
+ * @param {string} query
210
+ * @param {number} top_k
211
+ * @returns {Promise<Array<any>>}
212
+ */
213
+ queryText(field, query, top_k) {
214
+ const ptr0 = passStringToWasm0(field, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
215
+ const len0 = WASM_VECTOR_LEN;
216
+ const ptr1 = passStringToWasm0(query, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
217
+ const len1 = WASM_VECTOR_LEN;
218
+ const ret = wasm.space_queryText(this.__wbg_ptr, ptr0, len0, ptr1, len1, top_k);
219
+ return ret;
220
+ }
221
+ /**
222
+ * Top-K cosine vector search over an embedding `field`. `opts` may be a
223
+ * number (topK) or `{ topK?, probeCount? }`. Returns `[{ anchor, score }]`
224
+ * sorted by score descending — the shape dreamdb-ts's `queryVector` yields.
225
+ *
226
+ * Delegates to the real (tested) `dreamdb-dataset` query path: ADC cull +
227
+ * two-pass rerank + HotShard merge + tombstone suppression.
228
+ * @param {string} field
229
+ * @param {Float32Array} query
230
+ * @param {any} opts
231
+ * @returns {Promise<Array<any>>}
232
+ */
233
+ queryVector(field, query, opts) {
234
+ const ptr0 = passStringToWasm0(field, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
235
+ const len0 = WASM_VECTOR_LEN;
236
+ const ptr1 = passArrayF32ToWasm0(query, wasm.__wbindgen_malloc);
237
+ const len1 = WASM_VECTOR_LEN;
238
+ const ret = wasm.space_queryVector(this.__wbg_ptr, ptr0, len0, ptr1, len1, opts);
239
+ return ret;
240
+ }
241
+ /**
242
+ * Read a scalar track as a `Map<anchorString, value>`. Single-anchor
243
+ * entries resolve from the track index; multi-anchor entries fetch (and
244
+ * de-dupe) their bucket and roaring-decode the anchor set.
245
+ * @param {any} track
246
+ * @param {any} _opts
247
+ * @returns {Promise<Map<any, any>>}
248
+ */
249
+ readScalarColumn(track, _opts) {
250
+ const ret = wasm.space_readScalarColumn(this.__wbg_ptr, track, _opts);
251
+ return ret;
252
+ }
253
+ /**
254
+ * Fetch a track object and return its `object_index` (array of CBOR
255
+ * entries). Inline indexes only — paged indexes are not resolved (matching
256
+ * dreamdb-ts, which also doesn't support them on this path).
257
+ * @param {any} track
258
+ * @returns {Promise<Array<any>>}
259
+ */
260
+ resolveObjectIndex(track) {
261
+ const ret = wasm.space_resolveObjectIndex(this.__wbg_ptr, track);
262
+ return ret;
263
+ }
264
+ /**
265
+ * Base32 hash of the manifest's first timeline.
266
+ * @returns {string}
267
+ */
268
+ timelineId() {
269
+ let deferred2_0;
270
+ let deferred2_1;
271
+ try {
272
+ const ret = wasm.space_timelineId(this.__wbg_ptr);
273
+ var ptr1 = ret[0];
274
+ var len1 = ret[1];
275
+ if (ret[3]) {
276
+ ptr1 = 0; len1 = 0;
277
+ throw takeFromExternrefTable0(ret[2]);
278
+ }
279
+ deferred2_0 = ptr1;
280
+ deferred2_1 = len1;
281
+ return getStringFromWasm0(ptr1, len1);
282
+ } finally {
283
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
284
+ }
285
+ }
286
+ /**
287
+ * Find a track by its resolved `key` or by `modality`.
288
+ * @param {string} key_or_modality
289
+ * @returns {any}
290
+ */
291
+ trackFor(key_or_modality) {
292
+ const ptr0 = passStringToWasm0(key_or_modality, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
293
+ const len0 = WASM_VECTOR_LEN;
294
+ const ret = wasm.space_trackFor(this.__wbg_ptr, ptr0, len0);
295
+ return ret;
296
+ }
297
+ /**
298
+ * List resolved tracks from this manifest.
299
+ * @returns {Array<any>}
300
+ */
301
+ tracks() {
302
+ const ret = wasm.space_tracks(this.__wbg_ptr);
303
+ return ret;
304
+ }
305
+ }
306
+ if (Symbol.dispose) Space.prototype[Symbol.dispose] = Space.prototype.free;
307
+
308
+ /**
309
+ * A write handle onto a ref.
310
+ */
311
+ export class Writer {
312
+ static __wrap(ptr) {
313
+ const obj = Object.create(Writer.prototype);
314
+ obj.__wbg_ptr = ptr;
315
+ WriterFinalization.register(obj, obj.__wbg_ptr, obj);
316
+ return obj;
317
+ }
318
+ __destroy_into_raw() {
319
+ const ptr = this.__wbg_ptr;
320
+ this.__wbg_ptr = 0;
321
+ WriterFinalization.unregister(this);
322
+ return ptr;
323
+ }
324
+ free() {
325
+ const ptr = this.__destroy_into_raw();
326
+ wasm.__wbg_writer_free(ptr, 0);
327
+ }
328
+ /**
329
+ * Append records and commit in one call.
330
+ *
331
+ * `samples` is an array of `{ anchor?: bigint|number, <field>: value }`.
332
+ * See `marshal::samples_from_js` for the accepted field shapes.
333
+ *
334
+ * Committing here rather than exposing a separate staged mode is
335
+ * deliberate for the browser surface: a staged write that is never
336
+ * committed leaves uploaded objects unreferenced, and a tab can close at
337
+ * any moment. `appendStaged` exists on the Node surface where the process
338
+ * lifetime is under the caller's control.
339
+ * @param {Array<any>} samples
340
+ * @returns {Promise<number>}
341
+ */
342
+ appendMany(samples) {
343
+ const ret = wasm.writer_appendMany(this.__wbg_ptr, samples);
344
+ return ret;
345
+ }
346
+ /**
347
+ * Flush staged entries and publish a new manifest.
348
+ *
349
+ * Fails with a CAS conflict if the ref moved underneath this writer. That
350
+ * is not retried automatically: an automatic retry would hide a logical
351
+ * conflict, and the caller is the only one who knows whether re-applying
352
+ * its records on top of the new head is correct.
353
+ * @returns {Promise<string>}
354
+ */
355
+ commit() {
356
+ const ret = wasm.writer_commit(this.__wbg_ptr);
357
+ return ret;
358
+ }
359
+ /**
360
+ * Tombstone records by anchor. Returns the new manifest hash.
361
+ * @param {BigUint64Array} anchors
362
+ * @param {string | null} [reason]
363
+ * @returns {Promise<string>}
364
+ */
365
+ deleteRecords(anchors, reason) {
366
+ const ptr0 = passArray64ToWasm0(anchors, wasm.__wbindgen_malloc);
367
+ const len0 = WASM_VECTOR_LEN;
368
+ var ptr1 = isLikeNone(reason) ? 0 : passStringToWasm0(reason, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
369
+ var len1 = WASM_VECTOR_LEN;
370
+ const ret = wasm.writer_deleteRecords(this.__wbg_ptr, ptr0, len0, ptr1, len1);
371
+ return ret;
372
+ }
373
+ /**
374
+ * Current manifest hash, base32.
375
+ * @returns {string}
376
+ */
377
+ get manifestHash() {
378
+ let deferred2_0;
379
+ let deferred2_1;
380
+ try {
381
+ const ret = wasm.writer_manifestHash(this.__wbg_ptr);
382
+ var ptr1 = ret[0];
383
+ var len1 = ret[1];
384
+ if (ret[3]) {
385
+ ptr1 = 0; len1 = 0;
386
+ throw takeFromExternrefTable0(ret[2]);
387
+ }
388
+ deferred2_0 = ptr1;
389
+ deferred2_1 = len1;
390
+ return getStringFromWasm0(ptr1, len1);
391
+ } finally {
392
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
393
+ }
394
+ }
395
+ /**
396
+ * Open a ref for writing.
397
+ *
398
+ * `uri` is the same `.../refs/<name>` form `Space.fromUri` takes; a
399
+ * `.../manifests/<hash>` URI is rejected rather than silently opening
400
+ * something unwritable, because a manifest hash names an immutable
401
+ * snapshot — there is nothing for a commit to advance.
402
+ *
403
+ * `backend` must implement `put` (Backend contract v2). Passing a
404
+ * read-only backend fails at the first write with a clear message rather
405
+ * than here, since the connector cannot know what the JS object omits
406
+ * until it calls it.
407
+ * @param {string} uri
408
+ * @param {any} backend
409
+ * @returns {Promise<Writer>}
410
+ */
411
+ static open(uri, backend) {
412
+ const ptr0 = passStringToWasm0(uri, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
413
+ const len0 = WASM_VECTOR_LEN;
414
+ const ret = wasm.writer_open(ptr0, len0, backend);
415
+ return ret;
416
+ }
417
+ /**
418
+ * The ref this writer advances.
419
+ * @returns {string}
420
+ */
421
+ get refName() {
422
+ let deferred1_0;
423
+ let deferred1_1;
424
+ try {
425
+ const ret = wasm.writer_refName(this.__wbg_ptr);
426
+ deferred1_0 = ret[0];
427
+ deferred1_1 = ret[1];
428
+ return getStringFromWasm0(ret[0], ret[1]);
429
+ } finally {
430
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
431
+ }
432
+ }
433
+ /**
434
+ * Tag the current manifest with an immutable label (`refs/<ref>@<label>`).
435
+ * @param {string} label
436
+ * @returns {Promise<string>}
437
+ */
438
+ snapshot(label) {
439
+ const ptr0 = passStringToWasm0(label, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
440
+ const len0 = WASM_VECTOR_LEN;
441
+ const ret = wasm.writer_snapshot(this.__wbg_ptr, ptr0, len0);
442
+ return ret;
443
+ }
444
+ }
445
+ if (Symbol.dispose) Writer.prototype[Symbol.dispose] = Writer.prototype.free;
446
+
447
+ /**
448
+ * Install a panic hook that logs the panic message AND its `file:line:col`
449
+ * to the console before the wasm trap surfaces to JS.
450
+ *
451
+ * Without this, every Rust panic reaches JavaScript as a bare
452
+ * `RuntimeError: unreachable` with nothing but wasm frame offsets — and it is
453
+ * indistinguishable from an allocation failure, since Rust's alloc-error
454
+ * handler also aborts. That ambiguity cost real debugging time: a browser
455
+ * `unreachable` from exhausting wasm32's 32-bit address space on an oversized
456
+ * index was initially read as an integer-overflow panic.
457
+ *
458
+ * Zero new deps — uses the already-enabled `web-sys` `console` feature.
459
+ * Runs once at module init.
460
+ */
461
+ export function __wasm_init() {
462
+ wasm.__wasm_init();
463
+ }
464
+
465
+ /**
466
+ * Parse an object path and re-format it. Byte-identity of the result is the
467
+ * actual assertion: a parser that silently drops a component still "parses".
468
+ * @param {string} path
469
+ * @returns {string}
470
+ */
471
+ export function addressRoundTrip(path) {
472
+ let deferred3_0;
473
+ let deferred3_1;
474
+ try {
475
+ const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
476
+ const len0 = WASM_VECTOR_LEN;
477
+ const ret = wasm.addressRoundTrip(ptr0, len0);
478
+ var ptr2 = ret[0];
479
+ var len2 = ret[1];
480
+ if (ret[3]) {
481
+ ptr2 = 0; len2 = 0;
482
+ throw takeFromExternrefTable0(ret[2]);
483
+ }
484
+ deferred3_0 = ptr2;
485
+ deferred3_1 = len2;
486
+ return getStringFromWasm0(ptr2, len2);
487
+ } finally {
488
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
489
+ }
490
+ }
491
+
492
+ /**
493
+ * The address variant name (`Genesis`, `Manifest`, `Ref`, …) for a path.
494
+ *
495
+ * Derived from the Debug representation rather than a hand-written match.
496
+ * `DreamDbAddress` has seventeen variants and gains one whenever the protocol
497
+ * does; a match arm per variant would be a second list to keep in sync, and
498
+ * the vectors only ever assert the name.
499
+ * @param {string} path
500
+ * @returns {string}
501
+ */
502
+ export function addressVariant(path) {
503
+ let deferred3_0;
504
+ let deferred3_1;
505
+ try {
506
+ const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
507
+ const len0 = WASM_VECTOR_LEN;
508
+ const ret = wasm.addressVariant(ptr0, len0);
509
+ var ptr2 = ret[0];
510
+ var len2 = ret[1];
511
+ if (ret[3]) {
512
+ ptr2 = 0; len2 = 0;
513
+ throw takeFromExternrefTable0(ret[2]);
514
+ }
515
+ deferred3_0 = ptr2;
516
+ deferred3_1 = len2;
517
+ return getStringFromWasm0(ptr2, len2);
518
+ } finally {
519
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
520
+ }
521
+ }
522
+
523
+ /**
524
+ * Encode arbitrary bytes as lowercase RFC-4648 base32 (no padding).
525
+ *
526
+ * Byte-identical to `dreamdb-ts`'s `bytesToBase32` (alphabet
527
+ * `abcdefghijklmnopqrstuvwxyz234567`) and to `dreamdb_core`'s multihash
528
+ * `to_base32`, which is how object addresses are spelled on disk.
529
+ * @param {Uint8Array} bytes
530
+ * @returns {string}
531
+ */
532
+ export function bytesToBase32(bytes) {
533
+ let deferred2_0;
534
+ let deferred2_1;
535
+ try {
536
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
537
+ const len0 = WASM_VECTOR_LEN;
538
+ const ret = wasm.bytesToBase32(ptr0, len0);
539
+ deferred2_0 = ret[0];
540
+ deferred2_1 = ret[1];
541
+ return getStringFromWasm0(ret[0], ret[1]);
542
+ } finally {
543
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
544
+ }
545
+ }
546
+
547
+ /**
548
+ * Decode a single CBOR value from `bytes` into its JS representation.
549
+ * @param {Uint8Array} bytes
550
+ * @returns {any}
551
+ */
552
+ export function decodeCbor(bytes) {
553
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
554
+ const len0 = WASM_VECTOR_LEN;
555
+ const ret = wasm.decodeCbor(ptr0, len0);
556
+ if (ret[2]) {
557
+ throw takeFromExternrefTable0(ret[1]);
558
+ }
559
+ return takeFromExternrefTable0(ret[0]);
560
+ }
561
+
562
+ /**
563
+ * Canonically encode a JS value as CBOR, returning the bytes.
564
+ *
565
+ * Canonical here means what spec/0002 §3.1 means: map keys sorted by their
566
+ * encoded bytes, shortest-form integers, no indefinite lengths. Two writers
567
+ * that disagree on this produce different content hashes for the same logical
568
+ * object, and every address derived from them diverges.
569
+ * @param {any} value
570
+ * @returns {Uint8Array}
571
+ */
572
+ export function encodeCbor(value) {
573
+ const ret = wasm.encodeCbor(value);
574
+ if (ret[3]) {
575
+ throw takeFromExternrefTable0(ret[2]);
576
+ }
577
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
578
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
579
+ return v1;
580
+ }
581
+
582
+ /**
583
+ * Parse a modality tag into `{class, encoding, trackKind, objectKind, params,
584
+ * flags}`, or throw if it is invalid.
585
+ *
586
+ * `params` is a plain object of the `key=value` segments and `flags` an array
587
+ * of the bare ones (`bucketed`, `graph`). They are separate because the
588
+ * grammar treats them differently and merging them would make a flag
589
+ * indistinguishable from a parameter whose value happened to be empty.
590
+ * @param {string} tag
591
+ * @returns {any}
592
+ */
593
+ export function modalityParse(tag) {
594
+ const ptr0 = passStringToWasm0(tag, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
595
+ const len0 = WASM_VECTOR_LEN;
596
+ const ret = wasm.modalityParse(ptr0, len0);
597
+ if (ret[2]) {
598
+ throw takeFromExternrefTable0(ret[1]);
599
+ }
600
+ return takeFromExternrefTable0(ret[0]);
601
+ }
602
+
603
+ /**
604
+ * BLAKE3-256 multihash of `bytes`, base32 (the form used in object paths).
605
+ * @param {Uint8Array} bytes
606
+ * @returns {string}
607
+ */
608
+ export function multihashBase32(bytes) {
609
+ let deferred2_0;
610
+ let deferred2_1;
611
+ try {
612
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
613
+ const len0 = WASM_VECTOR_LEN;
614
+ const ret = wasm.multihashBase32(ptr0, len0);
615
+ deferred2_0 = ret[0];
616
+ deferred2_1 = ret[1];
617
+ return getStringFromWasm0(ret[0], ret[1]);
618
+ } finally {
619
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
620
+ }
621
+ }
622
+
623
+ /**
624
+ * BLAKE3-256 multihash of `bytes` as lowercase hex (33 bytes: tag + digest).
625
+ * @param {Uint8Array} bytes
626
+ * @returns {string}
627
+ */
628
+ export function multihashHex(bytes) {
629
+ let deferred2_0;
630
+ let deferred2_1;
631
+ try {
632
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
633
+ const len0 = WASM_VECTOR_LEN;
634
+ const ret = wasm.multihashHex(ptr0, len0);
635
+ deferred2_0 = ret[0];
636
+ deferred2_1 = ret[1];
637
+ return getStringFromWasm0(ret[0], ret[1]);
638
+ } finally {
639
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
640
+ }
641
+ }
642
+
643
+ /**
644
+ * DreamDB's half-open `[start, end)` → an HTTP `Range` header value.
645
+ *
646
+ * The off-by-one here is worth a vector of its own: HTTP ranges are
647
+ * *inclusive* of the end byte. Getting it wrong reads one byte too few from
648
+ * every object, which corrupts decode in ways that look like anything but an
649
+ * off-by-one.
650
+ * @param {bigint} start
651
+ * @param {bigint} end
652
+ * @returns {string}
653
+ */
654
+ export function rangeHeader(start, end) {
655
+ let deferred2_0;
656
+ let deferred2_1;
657
+ try {
658
+ const ret = wasm.rangeHeader(start, end);
659
+ var ptr1 = ret[0];
660
+ var len1 = ret[1];
661
+ if (ret[3]) {
662
+ ptr1 = 0; len1 = 0;
663
+ throw takeFromExternrefTable0(ret[2]);
664
+ }
665
+ deferred2_0 = ptr1;
666
+ deferred2_1 = len1;
667
+ return getStringFromWasm0(ptr1, len1);
668
+ } finally {
669
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
670
+ }
671
+ }
672
+
673
+ /**
674
+ * Round-trip a spatial key through its base-2 form, per spec/0002 §6.
675
+ *
676
+ * Returns the re-encoded string, so a caller can assert byte-identity rather
677
+ * than merely "it parsed".
678
+ * @param {string} bits
679
+ * @returns {string}
680
+ */
681
+ export function spatialKeyRoundTrip(bits) {
682
+ let deferred3_0;
683
+ let deferred3_1;
684
+ try {
685
+ const ptr0 = passStringToWasm0(bits, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
686
+ const len0 = WASM_VECTOR_LEN;
687
+ const ret = wasm.spatialKeyRoundTrip(ptr0, len0);
688
+ var ptr2 = ret[0];
689
+ var len2 = ret[1];
690
+ if (ret[3]) {
691
+ ptr2 = 0; len2 = 0;
692
+ throw takeFromExternrefTable0(ret[2]);
693
+ }
694
+ deferred3_0 = ptr2;
695
+ deferred3_1 = len2;
696
+ return getStringFromWasm0(ptr2, len2);
697
+ } finally {
698
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
699
+ }
700
+ }
701
+
702
+ /**
703
+ * The 16-char hex address form → TimeAnchor. Throws on a malformed input
704
+ * (wrong length, uppercase) rather than coercing it.
705
+ * @param {string} s
706
+ * @returns {bigint}
707
+ */
708
+ export function timeAnchorFromHex(s) {
709
+ const ptr0 = passStringToWasm0(s, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
710
+ const len0 = WASM_VECTOR_LEN;
711
+ const ret = wasm.timeAnchorFromHex(ptr0, len0);
712
+ if (ret[2]) {
713
+ throw takeFromExternrefTable0(ret[1]);
714
+ }
715
+ return BigInt.asUintN(64, ret[0]);
716
+ }
717
+
718
+ /**
719
+ * TimeAnchor → the 16-char hex used in addresses.
720
+ * @param {bigint} value
721
+ * @returns {string}
722
+ */
723
+ export function timeAnchorHex(value) {
724
+ let deferred1_0;
725
+ let deferred1_1;
726
+ try {
727
+ const ret = wasm.timeAnchorHex(value);
728
+ deferred1_0 = ret[0];
729
+ deferred1_1 = ret[1];
730
+ return getStringFromWasm0(ret[0], ret[1]);
731
+ } finally {
732
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
733
+ }
734
+ }
735
+
736
+ /**
737
+ * Which time bucket an anchor falls in, given a duration like `"1s"`/`"60s"`.
738
+ * @param {bigint} t_start
739
+ * @param {string} duration
740
+ * @returns {bigint}
741
+ */
742
+ export function timeBucket(t_start, duration) {
743
+ const ptr0 = passStringToWasm0(duration, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
744
+ const len0 = WASM_VECTOR_LEN;
745
+ const ret = wasm.timeBucket(t_start, ptr0, len0);
746
+ if (ret[2]) {
747
+ throw takeFromExternrefTable0(ret[1]);
748
+ }
749
+ return BigInt.asUintN(64, ret[0]);
750
+ }
751
+
752
+ /**
753
+ * Package version — useful for consumers to confirm which build is loaded.
754
+ * @returns {string}
755
+ */
756
+ export function version() {
757
+ let deferred1_0;
758
+ let deferred1_1;
759
+ try {
760
+ const ret = wasm.version();
761
+ deferred1_0 = ret[0];
762
+ deferred1_1 = ret[1];
763
+ return getStringFromWasm0(ret[0], ret[1]);
764
+ } finally {
765
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
766
+ }
767
+ }
768
+
769
+ /**
770
+ * The all-zero spatial-key path segment used for non-spatial (fragment) object
771
+ * addresses. Matches `dreamdb-ts`'s `ZERO_SPATIAL_KEY` constant exactly.
772
+ * @returns {string}
773
+ */
774
+ export function zeroSpatialKey() {
775
+ let deferred1_0;
776
+ let deferred1_1;
777
+ try {
778
+ const ret = wasm.zeroSpatialKey();
779
+ deferred1_0 = ret[0];
780
+ deferred1_1 = ret[1];
781
+ return getStringFromWasm0(ret[0], ret[1]);
782
+ } finally {
783
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
784
+ }
785
+ }
786
+ function __wbg_get_imports() {
787
+ const import0 = {
788
+ __proto__: null,
789
+ __wbg_Error_bce6d499ff0a4aff: function(arg0, arg1) {
790
+ const ret = Error(getStringFromWasm0(arg0, arg1));
791
+ return ret;
792
+ },
793
+ __wbg_String_8564e559799eccda: function(arg0, arg1) {
794
+ const ret = String(arg1);
795
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
796
+ const len1 = WASM_VECTOR_LEN;
797
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
798
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
799
+ },
800
+ __wbg___wbindgen_bigint_get_as_i64_410e28c7b761ad83: function(arg0, arg1) {
801
+ const v = arg1;
802
+ const ret = typeof(v) === 'bigint' ? v : undefined;
803
+ getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
804
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
805
+ },
806
+ __wbg___wbindgen_boolean_get_2304fb8c853028c8: function(arg0) {
807
+ const v = arg0;
808
+ const ret = typeof(v) === 'boolean' ? v : undefined;
809
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
810
+ },
811
+ __wbg___wbindgen_debug_string_edece8177ad01481: function(arg0, arg1) {
812
+ const ret = debugString(arg1);
813
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
814
+ const len1 = WASM_VECTOR_LEN;
815
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
816
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
817
+ },
818
+ __wbg___wbindgen_in_07056af4f902c445: function(arg0, arg1) {
819
+ const ret = arg0 in arg1;
820
+ return ret;
821
+ },
822
+ __wbg___wbindgen_is_bigint_aeae3893f30ed54e: function(arg0) {
823
+ const ret = typeof(arg0) === 'bigint';
824
+ return ret;
825
+ },
826
+ __wbg___wbindgen_is_function_5cd60d5cf78b4eef: function(arg0) {
827
+ const ret = typeof(arg0) === 'function';
828
+ return ret;
829
+ },
830
+ __wbg___wbindgen_is_null_2042690d351e14f0: function(arg0) {
831
+ const ret = arg0 === null;
832
+ return ret;
833
+ },
834
+ __wbg___wbindgen_is_object_b4593df85baada48: function(arg0) {
835
+ const val = arg0;
836
+ const ret = typeof(val) === 'object' && val !== null;
837
+ return ret;
838
+ },
839
+ __wbg___wbindgen_is_undefined_35bb9f4c7fd651d5: function(arg0) {
840
+ const ret = arg0 === undefined;
841
+ return ret;
842
+ },
843
+ __wbg___wbindgen_jsval_eq_c0ed08b3e0f393b9: function(arg0, arg1) {
844
+ const ret = arg0 === arg1;
845
+ return ret;
846
+ },
847
+ __wbg___wbindgen_jsval_loose_eq_0ad77b7717db155c: function(arg0, arg1) {
848
+ const ret = arg0 == arg1;
849
+ return ret;
850
+ },
851
+ __wbg___wbindgen_number_get_f73a1244370fcc2c: function(arg0, arg1) {
852
+ const obj = arg1;
853
+ const ret = typeof(obj) === 'number' ? obj : undefined;
854
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
855
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
856
+ },
857
+ __wbg___wbindgen_string_get_d109740c0d18f4d7: function(arg0, arg1) {
858
+ const obj = arg1;
859
+ const ret = typeof(obj) === 'string' ? obj : undefined;
860
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
861
+ var len1 = WASM_VECTOR_LEN;
862
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
863
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
864
+ },
865
+ __wbg___wbindgen_throw_9c31b086c2b26051: function(arg0, arg1) {
866
+ throw new Error(getStringFromWasm0(arg0, arg1));
867
+ },
868
+ __wbg__wbg_cb_unref_3fa391f3fcdb55f8: function(arg0) {
869
+ arg0._wbg_cb_unref();
870
+ },
871
+ __wbg_arrayBuffer_cb5d4748b5f3cad5: function() { return handleError(function (arg0) {
872
+ const ret = arg0.arrayBuffer();
873
+ return ret;
874
+ }, arguments); },
875
+ __wbg_call_084ee3e860ee9f92: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
876
+ const ret = arg0.call(arg1, arg2, arg3, arg4);
877
+ return ret;
878
+ }, arguments); },
879
+ __wbg_call_13665d9f14390edc: function() { return handleError(function (arg0, arg1) {
880
+ const ret = arg0.call(arg1);
881
+ return ret;
882
+ }, arguments); },
883
+ __wbg_call_dfde26266607c996: function() { return handleError(function (arg0, arg1, arg2) {
884
+ const ret = arg0.call(arg1, arg2);
885
+ return ret;
886
+ }, arguments); },
887
+ __wbg_done_54b8da57023b7ed2: function(arg0) {
888
+ const ret = arg0.done;
889
+ return ret;
890
+ },
891
+ __wbg_entries_564a7e8b1e54ede5: function(arg0) {
892
+ const ret = Object.entries(arg0);
893
+ return ret;
894
+ },
895
+ __wbg_error_f085d7e62279b703: function(arg0) {
896
+ console.error(arg0);
897
+ },
898
+ __wbg_get_3e9a707ab7d352eb: function() { return handleError(function (arg0, arg1) {
899
+ const ret = Reflect.get(arg0, arg1);
900
+ return ret;
901
+ }, arguments); },
902
+ __wbg_get_98fdf51d029a75eb: function(arg0, arg1) {
903
+ const ret = arg0[arg1 >>> 0];
904
+ return ret;
905
+ },
906
+ __wbg_get_dcf82ab8aad1a593: function() { return handleError(function (arg0, arg1) {
907
+ const ret = Reflect.get(arg0, arg1);
908
+ return ret;
909
+ }, arguments); },
910
+ __wbg_get_unchecked_1dfe6d05ad91d9b7: function(arg0, arg1) {
911
+ const ret = arg0[arg1 >>> 0];
912
+ return ret;
913
+ },
914
+ __wbg_headers_4cfb0c75793d7a8d: function(arg0) {
915
+ const ret = arg0.headers;
916
+ return ret;
917
+ },
918
+ __wbg_instanceof_ArrayBuffer_53db37b06f6b9afe: function(arg0) {
919
+ let result;
920
+ try {
921
+ result = arg0 instanceof ArrayBuffer;
922
+ } catch (_) {
923
+ result = false;
924
+ }
925
+ const ret = result;
926
+ return ret;
927
+ },
928
+ __wbg_instanceof_Float32Array_3cc6d04a6a12262f: function(arg0) {
929
+ let result;
930
+ try {
931
+ result = arg0 instanceof Float32Array;
932
+ } catch (_) {
933
+ result = false;
934
+ }
935
+ const ret = result;
936
+ return ret;
937
+ },
938
+ __wbg_instanceof_Map_16f217b9a2a08d8c: function(arg0) {
939
+ let result;
940
+ try {
941
+ result = arg0 instanceof Map;
942
+ } catch (_) {
943
+ result = false;
944
+ }
945
+ const ret = result;
946
+ return ret;
947
+ },
948
+ __wbg_instanceof_Object_03924e0dbda74bd8: function(arg0) {
949
+ let result;
950
+ try {
951
+ result = arg0 instanceof Object;
952
+ } catch (_) {
953
+ result = false;
954
+ }
955
+ const ret = result;
956
+ return ret;
957
+ },
958
+ __wbg_instanceof_Promise_09012cfa9708520a: function(arg0) {
959
+ let result;
960
+ try {
961
+ result = arg0 instanceof Promise;
962
+ } catch (_) {
963
+ result = false;
964
+ }
965
+ const ret = result;
966
+ return ret;
967
+ },
968
+ __wbg_instanceof_Response_ecfc823e8fb354e2: function(arg0) {
969
+ let result;
970
+ try {
971
+ result = arg0 instanceof Response;
972
+ } catch (_) {
973
+ result = false;
974
+ }
975
+ const ret = result;
976
+ return ret;
977
+ },
978
+ __wbg_instanceof_Uint8Array_abd07d4bd221d50b: function(arg0) {
979
+ let result;
980
+ try {
981
+ result = arg0 instanceof Uint8Array;
982
+ } catch (_) {
983
+ result = false;
984
+ }
985
+ const ret = result;
986
+ return ret;
987
+ },
988
+ __wbg_isArray_94898ed3aad6947b: function(arg0) {
989
+ const ret = Array.isArray(arg0);
990
+ return ret;
991
+ },
992
+ __wbg_isSafeInteger_01e964d144ad3a55: function(arg0) {
993
+ const ret = Number.isSafeInteger(arg0);
994
+ return ret;
995
+ },
996
+ __wbg_iterator_1441b47f341dc34f: function() {
997
+ const ret = Symbol.iterator;
998
+ return ret;
999
+ },
1000
+ __wbg_length_13e61aa81636ec86: function(arg0) {
1001
+ const ret = arg0.length;
1002
+ return ret;
1003
+ },
1004
+ __wbg_length_2591a0f4f659a55c: function(arg0) {
1005
+ const ret = arg0.length;
1006
+ return ret;
1007
+ },
1008
+ __wbg_length_56fcd3e2b7e0299d: function(arg0) {
1009
+ const ret = arg0.length;
1010
+ return ret;
1011
+ },
1012
+ __wbg_new_02d162bc6cf02f60: function() {
1013
+ const ret = new Object();
1014
+ return ret;
1015
+ },
1016
+ __wbg_new_070df68d66325372: function() {
1017
+ const ret = new Map();
1018
+ return ret;
1019
+ },
1020
+ __wbg_new_310879b66b6e95e1: function() {
1021
+ const ret = new Array();
1022
+ return ret;
1023
+ },
1024
+ __wbg_new_7ddec6de44ff8f5d: function(arg0) {
1025
+ const ret = new Uint8Array(arg0);
1026
+ return ret;
1027
+ },
1028
+ __wbg_new_from_slice_269e35316ed2d061: function(arg0, arg1) {
1029
+ const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
1030
+ return ret;
1031
+ },
1032
+ __wbg_new_typed_c072c4ce9a2a0cdf: function(arg0, arg1) {
1033
+ try {
1034
+ var state0 = {a: arg0, b: arg1};
1035
+ var cb0 = (arg0, arg1) => {
1036
+ const a = state0.a;
1037
+ state0.a = 0;
1038
+ try {
1039
+ return wasm_bindgen_f7c54996eb9137d9___convert__closures_____invoke___js_sys_ac40961855821e8e___Function_fn_wasm_bindgen_f7c54996eb9137d9___JsValue_____wasm_bindgen_f7c54996eb9137d9___sys__Undefined___js_sys_ac40961855821e8e___Function_fn_wasm_bindgen_f7c54996eb9137d9___JsValue_____wasm_bindgen_f7c54996eb9137d9___sys__Undefined_______true_(a, state0.b, arg0, arg1);
1040
+ } finally {
1041
+ state0.a = a;
1042
+ }
1043
+ };
1044
+ const ret = new Promise(cb0);
1045
+ return ret;
1046
+ } finally {
1047
+ state0.a = 0;
1048
+ }
1049
+ },
1050
+ __wbg_new_with_str_and_init_ffe9977c986ea039: function() { return handleError(function (arg0, arg1, arg2) {
1051
+ const ret = new Request(getStringFromWasm0(arg0, arg1), arg2);
1052
+ return ret;
1053
+ }, arguments); },
1054
+ __wbg_next_2a4e19f4f5083b0f: function(arg0) {
1055
+ const ret = arg0.next;
1056
+ return ret;
1057
+ },
1058
+ __wbg_next_6429a146bf756f93: function() { return handleError(function (arg0) {
1059
+ const ret = arg0.next();
1060
+ return ret;
1061
+ }, arguments); },
1062
+ __wbg_now_81363d44c96dd239: function() {
1063
+ const ret = Date.now();
1064
+ return ret;
1065
+ },
1066
+ __wbg_ok_556a55299dd238ba: function(arg0) {
1067
+ const ret = arg0.ok;
1068
+ return ret;
1069
+ },
1070
+ __wbg_prototypesetcall_5f9bdc8d75e07276: function(arg0, arg1, arg2) {
1071
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
1072
+ },
1073
+ __wbg_prototypesetcall_fe9d129a614489fa: function(arg0, arg1, arg2) {
1074
+ Float32Array.prototype.set.call(getArrayF32FromWasm0(arg0, arg1), arg2);
1075
+ },
1076
+ __wbg_push_b77c476b01548d0a: function(arg0, arg1) {
1077
+ const ret = arg0.push(arg1);
1078
+ return ret;
1079
+ },
1080
+ __wbg_queueMicrotask_78d584b53af520f5: function(arg0) {
1081
+ const ret = arg0.queueMicrotask;
1082
+ return ret;
1083
+ },
1084
+ __wbg_queueMicrotask_b39ea83c7f01971a: function(arg0) {
1085
+ queueMicrotask(arg0);
1086
+ },
1087
+ __wbg_resolve_d17db9352f5a220e: function(arg0) {
1088
+ const ret = Promise.resolve(arg0);
1089
+ return ret;
1090
+ },
1091
+ __wbg_set_a0e911be3da02782: function() { return handleError(function (arg0, arg1, arg2) {
1092
+ const ret = Reflect.set(arg0, arg1, arg2);
1093
+ return ret;
1094
+ }, arguments); },
1095
+ __wbg_set_d57e5106f0271787: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
1096
+ arg0.set(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
1097
+ }, arguments); },
1098
+ __wbg_set_facb7a5914e0fa39: function(arg0, arg1, arg2) {
1099
+ const ret = arg0.set(arg1, arg2);
1100
+ return ret;
1101
+ },
1102
+ __wbg_space_new: function(arg0) {
1103
+ const ret = Space.__wrap(arg0);
1104
+ return ret;
1105
+ },
1106
+ __wbg_static_accessor_GLOBAL_THIS_02344c9b09eb08a9: function() {
1107
+ const ret = typeof globalThis === 'undefined' ? null : globalThis;
1108
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
1109
+ },
1110
+ __wbg_static_accessor_GLOBAL_ac6d4ac874d5cd54: function() {
1111
+ const ret = typeof global === 'undefined' ? null : global;
1112
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
1113
+ },
1114
+ __wbg_static_accessor_SELF_9b2406c23aeb2023: function() {
1115
+ const ret = typeof self === 'undefined' ? null : self;
1116
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
1117
+ },
1118
+ __wbg_static_accessor_WINDOW_b34d2126934e16ba: function() {
1119
+ const ret = typeof window === 'undefined' ? null : window;
1120
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
1121
+ },
1122
+ __wbg_status_0853c9f5752c7ee2: function(arg0) {
1123
+ const ret = arg0.status;
1124
+ return ret;
1125
+ },
1126
+ __wbg_then_837494e384b37459: function(arg0, arg1) {
1127
+ const ret = arg0.then(arg1);
1128
+ return ret;
1129
+ },
1130
+ __wbg_then_bd927500e8905df2: function(arg0, arg1, arg2) {
1131
+ const ret = arg0.then(arg1, arg2);
1132
+ return ret;
1133
+ },
1134
+ __wbg_value_9cc0518af87a489c: function(arg0) {
1135
+ const ret = arg0.value;
1136
+ return ret;
1137
+ },
1138
+ __wbg_writer_new: function(arg0) {
1139
+ const ret = Writer.__wrap(arg0);
1140
+ return ret;
1141
+ },
1142
+ __wbindgen_cast_0000000000000001: function(arg0, arg1) {
1143
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 488, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
1144
+ const ret = makeMutClosure(arg0, arg1, wasm_bindgen_f7c54996eb9137d9___convert__closures_____invoke___wasm_bindgen_f7c54996eb9137d9___JsValue__core_7d5f0a2ba6a62c33___result__Result_____wasm_bindgen_f7c54996eb9137d9___JsError___true_);
1145
+ return ret;
1146
+ },
1147
+ __wbindgen_cast_0000000000000002: function(arg0) {
1148
+ // Cast intrinsic for `F64 -> Externref`.
1149
+ const ret = arg0;
1150
+ return ret;
1151
+ },
1152
+ __wbindgen_cast_0000000000000003: function(arg0, arg1) {
1153
+ // Cast intrinsic for `I128 -> Externref`.
1154
+ const ret = (BigInt.asUintN(64, arg0) | (arg1 << BigInt(64)));
1155
+ return ret;
1156
+ },
1157
+ __wbindgen_cast_0000000000000004: function(arg0) {
1158
+ // Cast intrinsic for `I64 -> Externref`.
1159
+ const ret = arg0;
1160
+ return ret;
1161
+ },
1162
+ __wbindgen_cast_0000000000000005: function(arg0, arg1) {
1163
+ // Cast intrinsic for `Ref(String) -> Externref`.
1164
+ const ret = getStringFromWasm0(arg0, arg1);
1165
+ return ret;
1166
+ },
1167
+ __wbindgen_cast_0000000000000006: function(arg0) {
1168
+ // Cast intrinsic for `U64 -> Externref`.
1169
+ const ret = BigInt.asUintN(64, arg0);
1170
+ return ret;
1171
+ },
1172
+ __wbindgen_init_externref_table: function() {
1173
+ const table = wasm.__wbindgen_externrefs;
1174
+ const offset = table.grow(4);
1175
+ table.set(0, undefined);
1176
+ table.set(offset + 0, undefined);
1177
+ table.set(offset + 1, null);
1178
+ table.set(offset + 2, true);
1179
+ table.set(offset + 3, false);
1180
+ },
1181
+ };
1182
+ return {
1183
+ __proto__: null,
1184
+ "./dreamdb_bg.js": import0,
1185
+ };
1186
+ }
1187
+
1188
+ function wasm_bindgen_f7c54996eb9137d9___convert__closures_____invoke___wasm_bindgen_f7c54996eb9137d9___JsValue__core_7d5f0a2ba6a62c33___result__Result_____wasm_bindgen_f7c54996eb9137d9___JsError___true_(arg0, arg1, arg2) {
1189
+ const ret = wasm.wasm_bindgen_f7c54996eb9137d9___convert__closures_____invoke___wasm_bindgen_f7c54996eb9137d9___JsValue__core_7d5f0a2ba6a62c33___result__Result_____wasm_bindgen_f7c54996eb9137d9___JsError___true_(arg0, arg1, arg2);
1190
+ if (ret[1]) {
1191
+ throw takeFromExternrefTable0(ret[0]);
1192
+ }
1193
+ }
1194
+
1195
+ function wasm_bindgen_f7c54996eb9137d9___convert__closures_____invoke___js_sys_ac40961855821e8e___Function_fn_wasm_bindgen_f7c54996eb9137d9___JsValue_____wasm_bindgen_f7c54996eb9137d9___sys__Undefined___js_sys_ac40961855821e8e___Function_fn_wasm_bindgen_f7c54996eb9137d9___JsValue_____wasm_bindgen_f7c54996eb9137d9___sys__Undefined_______true_(arg0, arg1, arg2, arg3) {
1196
+ wasm.wasm_bindgen_f7c54996eb9137d9___convert__closures_____invoke___js_sys_ac40961855821e8e___Function_fn_wasm_bindgen_f7c54996eb9137d9___JsValue_____wasm_bindgen_f7c54996eb9137d9___sys__Undefined___js_sys_ac40961855821e8e___Function_fn_wasm_bindgen_f7c54996eb9137d9___JsValue_____wasm_bindgen_f7c54996eb9137d9___sys__Undefined_______true_(arg0, arg1, arg2, arg3);
1197
+ }
1198
+
1199
+ const S3BackendFinalization = (typeof FinalizationRegistry === 'undefined')
1200
+ ? { register: () => {}, unregister: () => {} }
1201
+ : new FinalizationRegistry(ptr => wasm.__wbg_s3backend_free(ptr, 1));
1202
+ const SpaceFinalization = (typeof FinalizationRegistry === 'undefined')
1203
+ ? { register: () => {}, unregister: () => {} }
1204
+ : new FinalizationRegistry(ptr => wasm.__wbg_space_free(ptr, 1));
1205
+ const WriterFinalization = (typeof FinalizationRegistry === 'undefined')
1206
+ ? { register: () => {}, unregister: () => {} }
1207
+ : new FinalizationRegistry(ptr => wasm.__wbg_writer_free(ptr, 1));
1208
+
1209
+ function addToExternrefTable0(obj) {
1210
+ const idx = wasm.__externref_table_alloc();
1211
+ wasm.__wbindgen_externrefs.set(idx, obj);
1212
+ return idx;
1213
+ }
1214
+
1215
+ const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')
1216
+ ? { register: () => {}, unregister: () => {} }
1217
+ : new FinalizationRegistry(state => wasm.__wbindgen_destroy_closure(state.a, state.b));
1218
+
1219
+ function debugString(val) {
1220
+ // primitive types
1221
+ const type = typeof val;
1222
+ if (type == 'number' || type == 'boolean' || val == null) {
1223
+ return `${val}`;
1224
+ }
1225
+ if (type == 'string') {
1226
+ return `"${val}"`;
1227
+ }
1228
+ if (type == 'symbol') {
1229
+ const description = val.description;
1230
+ if (description == null) {
1231
+ return 'Symbol';
1232
+ } else {
1233
+ return `Symbol(${description})`;
1234
+ }
1235
+ }
1236
+ if (type == 'function') {
1237
+ const name = val.name;
1238
+ if (typeof name == 'string' && name.length > 0) {
1239
+ return `Function(${name})`;
1240
+ } else {
1241
+ return 'Function';
1242
+ }
1243
+ }
1244
+ // objects
1245
+ if (Array.isArray(val)) {
1246
+ const length = val.length;
1247
+ let debug = '[';
1248
+ if (length > 0) {
1249
+ debug += debugString(val[0]);
1250
+ }
1251
+ for(let i = 1; i < length; i++) {
1252
+ debug += ', ' + debugString(val[i]);
1253
+ }
1254
+ debug += ']';
1255
+ return debug;
1256
+ }
1257
+ // Test for built-in
1258
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
1259
+ let className;
1260
+ if (builtInMatches && builtInMatches.length > 1) {
1261
+ className = builtInMatches[1];
1262
+ } else {
1263
+ // Failed to match the standard '[object ClassName]'
1264
+ return toString.call(val);
1265
+ }
1266
+ if (className == 'Object') {
1267
+ // we're a user defined class or Object
1268
+ // JSON.stringify avoids problems with cycles, and is generally much
1269
+ // easier than looping through ownProperties of `val`.
1270
+ try {
1271
+ return 'Object(' + JSON.stringify(val) + ')';
1272
+ } catch (_) {
1273
+ return 'Object';
1274
+ }
1275
+ }
1276
+ // errors
1277
+ if (val instanceof Error) {
1278
+ return `${val.name}: ${val.message}\n${val.stack}`;
1279
+ }
1280
+ // TODO we could test for more things here, like `Set`s and `Map`s.
1281
+ return className;
1282
+ }
1283
+
1284
+ function getArrayF32FromWasm0(ptr, len) {
1285
+ ptr = ptr >>> 0;
1286
+ return getFloat32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
1287
+ }
1288
+
1289
+ function getArrayU8FromWasm0(ptr, len) {
1290
+ ptr = ptr >>> 0;
1291
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
1292
+ }
1293
+
1294
+ let cachedBigUint64ArrayMemory0 = null;
1295
+ function getBigUint64ArrayMemory0() {
1296
+ if (cachedBigUint64ArrayMemory0 === null || cachedBigUint64ArrayMemory0.byteLength === 0) {
1297
+ cachedBigUint64ArrayMemory0 = new BigUint64Array(wasm.memory.buffer);
1298
+ }
1299
+ return cachedBigUint64ArrayMemory0;
1300
+ }
1301
+
1302
+ let cachedDataViewMemory0 = null;
1303
+ function getDataViewMemory0() {
1304
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
1305
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
1306
+ }
1307
+ return cachedDataViewMemory0;
1308
+ }
1309
+
1310
+ let cachedFloat32ArrayMemory0 = null;
1311
+ function getFloat32ArrayMemory0() {
1312
+ if (cachedFloat32ArrayMemory0 === null || cachedFloat32ArrayMemory0.byteLength === 0) {
1313
+ cachedFloat32ArrayMemory0 = new Float32Array(wasm.memory.buffer);
1314
+ }
1315
+ return cachedFloat32ArrayMemory0;
1316
+ }
1317
+
1318
+ function getStringFromWasm0(ptr, len) {
1319
+ return decodeText(ptr >>> 0, len);
1320
+ }
1321
+
1322
+ let cachedUint8ArrayMemory0 = null;
1323
+ function getUint8ArrayMemory0() {
1324
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
1325
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
1326
+ }
1327
+ return cachedUint8ArrayMemory0;
1328
+ }
1329
+
1330
+ function handleError(f, args) {
1331
+ try {
1332
+ return f.apply(this, args);
1333
+ } catch (e) {
1334
+ const idx = addToExternrefTable0(e);
1335
+ wasm.__wbindgen_exn_store(idx);
1336
+ }
1337
+ }
1338
+
1339
+ function isLikeNone(x) {
1340
+ return x === undefined || x === null;
1341
+ }
1342
+
1343
+ function makeMutClosure(arg0, arg1, f) {
1344
+ const state = { a: arg0, b: arg1, cnt: 1 };
1345
+ const real = (...args) => {
1346
+
1347
+ // First up with a closure we increment the internal reference
1348
+ // count. This ensures that the Rust closure environment won't
1349
+ // be deallocated while we're invoking it.
1350
+ state.cnt++;
1351
+ const a = state.a;
1352
+ state.a = 0;
1353
+ try {
1354
+ return f(a, state.b, ...args);
1355
+ } finally {
1356
+ state.a = a;
1357
+ real._wbg_cb_unref();
1358
+ }
1359
+ };
1360
+ real._wbg_cb_unref = () => {
1361
+ if (--state.cnt === 0) {
1362
+ wasm.__wbindgen_destroy_closure(state.a, state.b);
1363
+ state.a = 0;
1364
+ CLOSURE_DTORS.unregister(state);
1365
+ }
1366
+ };
1367
+ CLOSURE_DTORS.register(real, state, state);
1368
+ return real;
1369
+ }
1370
+
1371
+ function passArray64ToWasm0(arg, malloc) {
1372
+ const ptr = malloc(arg.length * 8, 8) >>> 0;
1373
+ getBigUint64ArrayMemory0().set(arg, ptr / 8);
1374
+ WASM_VECTOR_LEN = arg.length;
1375
+ return ptr;
1376
+ }
1377
+
1378
+ function passArray8ToWasm0(arg, malloc) {
1379
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
1380
+ getUint8ArrayMemory0().set(arg, ptr / 1);
1381
+ WASM_VECTOR_LEN = arg.length;
1382
+ return ptr;
1383
+ }
1384
+
1385
+ function passArrayF32ToWasm0(arg, malloc) {
1386
+ const ptr = malloc(arg.length * 4, 4) >>> 0;
1387
+ getFloat32ArrayMemory0().set(arg, ptr / 4);
1388
+ WASM_VECTOR_LEN = arg.length;
1389
+ return ptr;
1390
+ }
1391
+
1392
+ function passStringToWasm0(arg, malloc, realloc) {
1393
+ if (realloc === undefined) {
1394
+ const buf = cachedTextEncoder.encode(arg);
1395
+ const ptr = malloc(buf.length, 1) >>> 0;
1396
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
1397
+ WASM_VECTOR_LEN = buf.length;
1398
+ return ptr;
1399
+ }
1400
+
1401
+ let len = arg.length;
1402
+ let ptr = malloc(len, 1) >>> 0;
1403
+
1404
+ const mem = getUint8ArrayMemory0();
1405
+
1406
+ let offset = 0;
1407
+
1408
+ for (; offset < len; offset++) {
1409
+ const code = arg.charCodeAt(offset);
1410
+ if (code > 0x7F) break;
1411
+ mem[ptr + offset] = code;
1412
+ }
1413
+ if (offset !== len) {
1414
+ if (offset !== 0) {
1415
+ arg = arg.slice(offset);
1416
+ }
1417
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
1418
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
1419
+ const ret = cachedTextEncoder.encodeInto(arg, view);
1420
+
1421
+ offset += ret.written;
1422
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
1423
+ }
1424
+
1425
+ WASM_VECTOR_LEN = offset;
1426
+ return ptr;
1427
+ }
1428
+
1429
+ function takeFromExternrefTable0(idx) {
1430
+ const value = wasm.__wbindgen_externrefs.get(idx);
1431
+ wasm.__externref_table_dealloc(idx);
1432
+ return value;
1433
+ }
1434
+
1435
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
1436
+ cachedTextDecoder.decode();
1437
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
1438
+ let numBytesDecoded = 0;
1439
+ function decodeText(ptr, len) {
1440
+ numBytesDecoded += len;
1441
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
1442
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
1443
+ cachedTextDecoder.decode();
1444
+ numBytesDecoded = len;
1445
+ }
1446
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
1447
+ }
1448
+
1449
+ const cachedTextEncoder = new TextEncoder();
1450
+
1451
+ if (!('encodeInto' in cachedTextEncoder)) {
1452
+ cachedTextEncoder.encodeInto = function (arg, view) {
1453
+ const buf = cachedTextEncoder.encode(arg);
1454
+ view.set(buf);
1455
+ return {
1456
+ read: arg.length,
1457
+ written: buf.length
1458
+ };
1459
+ };
1460
+ }
1461
+
1462
+ let WASM_VECTOR_LEN = 0;
1463
+
1464
+ let wasmModule, wasmInstance, wasm;
1465
+ function __wbg_finalize_init(instance, module) {
1466
+ wasmInstance = instance;
1467
+ wasm = instance.exports;
1468
+ wasmModule = module;
1469
+ cachedBigUint64ArrayMemory0 = null;
1470
+ cachedDataViewMemory0 = null;
1471
+ cachedFloat32ArrayMemory0 = null;
1472
+ cachedUint8ArrayMemory0 = null;
1473
+ wasm.__wbindgen_start();
1474
+ return wasm;
1475
+ }
1476
+
1477
+ async function __wbg_load(module, imports) {
1478
+ if (typeof Response === 'function' && module instanceof Response) {
1479
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
1480
+ try {
1481
+ return await WebAssembly.instantiateStreaming(module, imports);
1482
+ } catch (e) {
1483
+ const validResponse = module.ok && expectedResponseType(module.type);
1484
+
1485
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
1486
+ 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);
1487
+
1488
+ } else { throw e; }
1489
+ }
1490
+ }
1491
+
1492
+ const bytes = await module.arrayBuffer();
1493
+ return await WebAssembly.instantiate(bytes, imports);
1494
+ } else {
1495
+ const instance = await WebAssembly.instantiate(module, imports);
1496
+
1497
+ if (instance instanceof WebAssembly.Instance) {
1498
+ return { instance, module };
1499
+ } else {
1500
+ return instance;
1501
+ }
1502
+ }
1503
+
1504
+ function expectedResponseType(type) {
1505
+ switch (type) {
1506
+ case 'basic': case 'cors': case 'default': return true;
1507
+ }
1508
+ return false;
1509
+ }
1510
+ }
1511
+
1512
+ function initSync(module) {
1513
+ if (wasm !== undefined) return wasm;
1514
+
1515
+
1516
+ if (module !== undefined) {
1517
+ if (Object.getPrototypeOf(module) === Object.prototype) {
1518
+ ({module} = module)
1519
+ } else {
1520
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
1521
+ }
1522
+ }
1523
+
1524
+ const imports = __wbg_get_imports();
1525
+ if (!(module instanceof WebAssembly.Module)) {
1526
+ module = new WebAssembly.Module(module);
1527
+ }
1528
+ const instance = new WebAssembly.Instance(module, imports);
1529
+ return __wbg_finalize_init(instance, module);
1530
+ }
1531
+
1532
+ async function __wbg_init(module_or_path) {
1533
+ if (wasm !== undefined) return wasm;
1534
+
1535
+
1536
+ if (module_or_path !== undefined) {
1537
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
1538
+ ({module_or_path} = module_or_path)
1539
+ } else {
1540
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
1541
+ }
1542
+ }
1543
+
1544
+ if (module_or_path === undefined) {
1545
+ module_or_path = new URL('dreamdb_bg.wasm', import.meta.url);
1546
+ }
1547
+ const imports = __wbg_get_imports();
1548
+
1549
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
1550
+ module_or_path = fetch(module_or_path);
1551
+ }
1552
+
1553
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
1554
+
1555
+ return __wbg_finalize_init(instance, module);
1556
+ }
1557
+
1558
+ export { initSync, __wbg_init as default };