beamdb 0.9.2

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/beam.js ADDED
@@ -0,0 +1,837 @@
1
+ /* @ts-self-types="./beam.d.ts" */
2
+
3
+ /**
4
+ * JavaScript-facing BEAM API.
5
+ *
6
+ * Wraps a [`Node`] and exposes a simplified interface for browser use.
7
+ * Each `Beam` instance is an independent node in the P2P mesh.
8
+ */
9
+ export class Beam {
10
+ static __wrap(ptr) {
11
+ const obj = Object.create(Beam.prototype);
12
+ obj.__wbg_ptr = ptr;
13
+ BeamFinalization.register(obj, obj.__wbg_ptr, obj);
14
+ return obj;
15
+ }
16
+ __destroy_into_raw() {
17
+ const ptr = this.__wbg_ptr;
18
+ this.__wbg_ptr = 0;
19
+ BeamFinalization.unregister(this);
20
+ return ptr;
21
+ }
22
+ free() {
23
+ const ptr = this.__destroy_into_raw();
24
+ wasm.__wbg_beam_free(ptr, 0);
25
+ }
26
+ /**
27
+ * Connects to a relay server via WebSocket.
28
+ *
29
+ * The connection is asynchronous — data will start flowing once the
30
+ * WebSocket handshake completes. You can call `put()` immediately;
31
+ * messages will be queued and sent once connected.
32
+ *
33
+ * # Arguments
34
+ *
35
+ * * `url` - WebSocket URL (e.g. `"wss://relay.example.com/ws"`)
36
+ * @param {string} url
37
+ */
38
+ connect(url) {
39
+ const ptr0 = passStringToWasm0(url, wasm.__wbindgen_export, wasm.__wbindgen_export2);
40
+ const len0 = WASM_VECTOR_LEN;
41
+ wasm.beam_connect(this.__wbg_ptr, ptr0, len0);
42
+ }
43
+ /**
44
+ * Reads the value at the given path once.
45
+ *
46
+ * Returns a `Promise` that resolves to the value (string) or `null`
47
+ * if not found within the timeout (default 66ms, matching Gun.js).
48
+ *
49
+ * ```js
50
+ * const val = await beam.get("chat.123");
51
+ * if (val) console.log("got:", val);
52
+ * ```
53
+ * @param {string} path
54
+ * @returns {Promise<any>}
55
+ */
56
+ get(path) {
57
+ const ptr0 = passStringToWasm0(path, wasm.__wbindgen_export, wasm.__wbindgen_export2);
58
+ const len0 = WASM_VECTOR_LEN;
59
+ const ret = wasm.beam_get(this.__wbg_ptr, ptr0, len0);
60
+ return takeObject(ret);
61
+ }
62
+ /**
63
+ * Creates a new BEAM node with in-memory storage.
64
+ *
65
+ * Data is lost when the page reloads. For persistence, use
66
+ * [`new_persistent()`](Self::new_persistent) instead.
67
+ */
68
+ constructor() {
69
+ const ret = wasm.beam_new();
70
+ this.__wbg_ptr = ret;
71
+ BeamFinalization.register(this, this.__wbg_ptr, this);
72
+ return this;
73
+ }
74
+ /**
75
+ * Creates a new BEAM node with IndexedDB persistent storage.
76
+ *
77
+ * Data survives page reloads. The IndexedDB database opens
78
+ * asynchronously — writes are buffered until the DB is ready,
79
+ * then flushed automatically.
80
+ * @returns {Beam}
81
+ */
82
+ static new_persistent() {
83
+ const ret = wasm.beam_new_persistent();
84
+ return Beam.__wrap(ret);
85
+ }
86
+ /**
87
+ * Subscribes to child updates at the given path.
88
+ *
89
+ * Uses Gun.js `.on()` semantics: the callback fires for each child
90
+ * value under the path, not just the path's own value. For example,
91
+ * `beam.on("chat", cb)` fires for each message written to
92
+ * `chat.<timestamp>`.
93
+ *
94
+ * The subscription lives until `stop()` is called or the `Beam`
95
+ * instance is dropped.
96
+ *
97
+ * ```js
98
+ * beam.on("chat", (value) => {
99
+ * console.log("new message:", value);
100
+ * });
101
+ * ```
102
+ * @param {string} path
103
+ * @param {Function} callback
104
+ */
105
+ on(path, callback) {
106
+ const ptr0 = passStringToWasm0(path, wasm.__wbindgen_export, wasm.__wbindgen_export2);
107
+ const len0 = WASM_VECTOR_LEN;
108
+ wasm.beam_on(this.__wbg_ptr, ptr0, len0, addHeapObject(callback));
109
+ }
110
+ /**
111
+ * Writes a string value to the graph at the given path.
112
+ *
113
+ * # Arguments
114
+ *
115
+ * * `path` - Dot-separated path (e.g. `"chat.123"`)
116
+ * * `value` - String to store
117
+ * @param {string} path
118
+ * @param {string} value
119
+ */
120
+ put(path, value) {
121
+ const ptr0 = passStringToWasm0(path, wasm.__wbindgen_export, wasm.__wbindgen_export2);
122
+ const len0 = WASM_VECTOR_LEN;
123
+ const ptr1 = passStringToWasm0(value, wasm.__wbindgen_export, wasm.__wbindgen_export2);
124
+ const len1 = WASM_VECTOR_LEN;
125
+ wasm.beam_put(this.__wbg_ptr, ptr0, len0, ptr1, len1);
126
+ }
127
+ /**
128
+ * Writes a boolean value to the graph at the given path.
129
+ * @param {string} path
130
+ * @param {boolean} value
131
+ */
132
+ put_bool(path, value) {
133
+ const ptr0 = passStringToWasm0(path, wasm.__wbindgen_export, wasm.__wbindgen_export2);
134
+ const len0 = WASM_VECTOR_LEN;
135
+ wasm.beam_put_bool(this.__wbg_ptr, ptr0, len0, value);
136
+ }
137
+ /**
138
+ * Writes a null value to the graph at the given path.
139
+ * @param {string} path
140
+ */
141
+ put_null(path) {
142
+ const ptr0 = passStringToWasm0(path, wasm.__wbindgen_export, wasm.__wbindgen_export2);
143
+ const len0 = WASM_VECTOR_LEN;
144
+ wasm.beam_put_null(this.__wbg_ptr, ptr0, len0);
145
+ }
146
+ /**
147
+ * Writes a numeric value to the graph at the given path.
148
+ * @param {string} path
149
+ * @param {number} value
150
+ */
151
+ put_num(path, value) {
152
+ const ptr0 = passStringToWasm0(path, wasm.__wbindgen_export, wasm.__wbindgen_export2);
153
+ const len0 = WASM_VECTOR_LEN;
154
+ wasm.beam_put_num(this.__wbg_ptr, ptr0, len0, value);
155
+ }
156
+ /**
157
+ * Stops the node and closes all connections.
158
+ */
159
+ stop() {
160
+ wasm.beam_stop(this.__wbg_ptr);
161
+ }
162
+ }
163
+ if (Symbol.dispose) Beam.prototype[Symbol.dispose] = Beam.prototype.free;
164
+
165
+ /**
166
+ * Entry point invoked by JavaScript in a worker.
167
+ * @param {number} ptr
168
+ */
169
+ export function task_worker_entry_point(ptr) {
170
+ try {
171
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
172
+ wasm.task_worker_entry_point(retptr, ptr);
173
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
174
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
175
+ if (r1) {
176
+ throw takeObject(r0);
177
+ }
178
+ } finally {
179
+ wasm.__wbindgen_add_to_stack_pointer(16);
180
+ }
181
+ }
182
+ function __wbg_get_imports() {
183
+ const import0 = {
184
+ __proto__: null,
185
+ __wbg___wbindgen_debug_string_a57024b9c6e4a48b: function(arg0, arg1) {
186
+ const ret = debugString(getObject(arg1));
187
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
188
+ const len1 = WASM_VECTOR_LEN;
189
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
190
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
191
+ },
192
+ __wbg___wbindgen_is_function_5e4570eb24ffa122: function(arg0) {
193
+ const ret = typeof(getObject(arg0)) === 'function';
194
+ return ret;
195
+ },
196
+ __wbg___wbindgen_is_null_7d13f41e1a2d5140: function(arg0) {
197
+ const ret = getObject(arg0) === null;
198
+ return ret;
199
+ },
200
+ __wbg___wbindgen_is_undefined_6cff064c44e0d823: function(arg0) {
201
+ const ret = getObject(arg0) === undefined;
202
+ return ret;
203
+ },
204
+ __wbg___wbindgen_string_get_d154f1e671052120: function(arg0, arg1) {
205
+ const obj = getObject(arg1);
206
+ const ret = typeof(obj) === 'string' ? obj : undefined;
207
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
208
+ var len1 = WASM_VECTOR_LEN;
209
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
210
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
211
+ },
212
+ __wbg___wbindgen_throw_bb96b2010945f0bc: function(arg0, arg1) {
213
+ throw new Error(getStringFromWasm0(arg0, arg1));
214
+ },
215
+ __wbg__wbg_cb_unref_be22cc64ae6946a0: function(arg0) {
216
+ getObject(arg0)._wbg_cb_unref();
217
+ },
218
+ __wbg_call_35dba3c747ad7521: function() { return handleError(function (arg0, arg1, arg2) {
219
+ const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
220
+ return addHeapObject(ret);
221
+ }, arguments); },
222
+ __wbg_close_b857478a8d4c1a16: function() { return handleError(function (arg0) {
223
+ getObject(arg0).close();
224
+ }, arguments); },
225
+ __wbg_createObjectStore_d3884936b845900f: function() { return handleError(function (arg0, arg1, arg2) {
226
+ const ret = getObject(arg0).createObjectStore(getStringFromWasm0(arg1, arg2));
227
+ return addHeapObject(ret);
228
+ }, arguments); },
229
+ __wbg_data_57d8ce4eb5f0a433: function(arg0) {
230
+ const ret = getObject(arg0).data;
231
+ return addHeapObject(ret);
232
+ },
233
+ __wbg_error_757e9472f8410341: function(arg0, arg1) {
234
+ let deferred0_0;
235
+ let deferred0_1;
236
+ try {
237
+ deferred0_0 = arg0;
238
+ deferred0_1 = arg1;
239
+ console.error(getStringFromWasm0(arg0, arg1));
240
+ } finally {
241
+ wasm.__wbindgen_export4(deferred0_0, deferred0_1, 1);
242
+ }
243
+ },
244
+ __wbg_error_d6fc53d6c1dec840: function(arg0, arg1) {
245
+ console.error(getStringFromWasm0(arg0, arg1));
246
+ },
247
+ __wbg_error_dd408a7b3cb542dd: function(arg0) {
248
+ console.error(getObject(arg0));
249
+ },
250
+ __wbg_getRandomValues_a608c4436c19407a: function() { return handleError(function (arg0, arg1) {
251
+ globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
252
+ }, arguments); },
253
+ __wbg_get_4babbbf9303c1945: function() { return handleError(function (arg0, arg1) {
254
+ const ret = getObject(arg0).get(getObject(arg1));
255
+ return addHeapObject(ret);
256
+ }, arguments); },
257
+ __wbg_has_b3a6e6d0d28295fa: function() { return handleError(function (arg0, arg1) {
258
+ const ret = Reflect.has(getObject(arg0), getObject(arg1));
259
+ return ret;
260
+ }, arguments); },
261
+ __wbg_indexedDB_9e20c97c033151f3: function() { return handleError(function (arg0) {
262
+ const ret = getObject(arg0).indexedDB;
263
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
264
+ }, arguments); },
265
+ __wbg_instanceof_Window_5625ff9937037a38: function(arg0) {
266
+ let result;
267
+ try {
268
+ result = getObject(arg0) instanceof Window;
269
+ } catch (_) {
270
+ result = false;
271
+ }
272
+ const ret = result;
273
+ return ret;
274
+ },
275
+ __wbg_log_e6372b4fbfc9f81e: function(arg0) {
276
+ console.log(getObject(arg0));
277
+ },
278
+ __wbg_new_20a7c62e9b30cbf7: function() { return handleError(function (arg0, arg1) {
279
+ const ret = new WebSocket(getStringFromWasm0(arg0, arg1));
280
+ return addHeapObject(ret);
281
+ }, arguments); },
282
+ __wbg_new_227d7c05414eb861: function() {
283
+ const ret = new Error();
284
+ return addHeapObject(ret);
285
+ },
286
+ __wbg_new_418fb92a013d5930: function(arg0, arg1) {
287
+ try {
288
+ var state0 = {a: arg0, b: arg1};
289
+ var cb0 = (arg0, arg1) => {
290
+ const a = state0.a;
291
+ state0.a = 0;
292
+ try {
293
+ return __wasm_bindgen_func_elem_1115(a, state0.b, arg0, arg1);
294
+ } finally {
295
+ state0.a = a;
296
+ }
297
+ };
298
+ const ret = new Promise(cb0);
299
+ return addHeapObject(ret);
300
+ } finally {
301
+ state0.a = 0;
302
+ }
303
+ },
304
+ __wbg_new_typed_cceaf62d8d95e9f2: function(arg0, arg1) {
305
+ try {
306
+ var state0 = {a: arg0, b: arg1};
307
+ var cb0 = (arg0, arg1) => {
308
+ const a = state0.a;
309
+ state0.a = 0;
310
+ try {
311
+ return __wasm_bindgen_func_elem_1115(a, state0.b, arg0, arg1);
312
+ } finally {
313
+ state0.a = a;
314
+ }
315
+ };
316
+ const ret = new Promise(cb0);
317
+ return addHeapObject(ret);
318
+ } finally {
319
+ state0.a = 0;
320
+ }
321
+ },
322
+ __wbg_now_8b265300afd5f2b9: function() {
323
+ const ret = Date.now();
324
+ return ret;
325
+ },
326
+ __wbg_now_cace042f68c814d8: function(arg0) {
327
+ const ret = getObject(arg0).now();
328
+ return ret;
329
+ },
330
+ __wbg_objectStore_222b7add2b5c2770: function() { return handleError(function (arg0, arg1, arg2) {
331
+ const ret = getObject(arg0).objectStore(getStringFromWasm0(arg1, arg2));
332
+ return addHeapObject(ret);
333
+ }, arguments); },
334
+ __wbg_open_c5ecda93515ce190: function() { return handleError(function (arg0, arg1, arg2, arg3) {
335
+ const ret = getObject(arg0).open(getStringFromWasm0(arg1, arg2), arg3 >>> 0);
336
+ return addHeapObject(ret);
337
+ }, arguments); },
338
+ __wbg_performance_5fc5a6563dcd33de: function(arg0) {
339
+ const ret = getObject(arg0).performance;
340
+ return addHeapObject(ret);
341
+ },
342
+ __wbg_postMessage_6dcc1574fef77104: function() { return handleError(function (arg0, arg1) {
343
+ getObject(arg0).postMessage(getObject(arg1));
344
+ }, arguments); },
345
+ __wbg_put_5e0ae8c80bb952a7: function() { return handleError(function (arg0, arg1, arg2) {
346
+ const ret = getObject(arg0).put(getObject(arg1), getObject(arg2));
347
+ return addHeapObject(ret);
348
+ }, arguments); },
349
+ __wbg_queueMicrotask_ac694eae12e92dfb: function(arg0) {
350
+ queueMicrotask(getObject(arg0));
351
+ },
352
+ __wbg_queueMicrotask_be5fe34a8f4cad4d: function(arg0) {
353
+ const ret = getObject(arg0).queueMicrotask;
354
+ return addHeapObject(ret);
355
+ },
356
+ __wbg_readyState_fe79161592fd15ce: function(arg0) {
357
+ const ret = getObject(arg0).readyState;
358
+ return ret;
359
+ },
360
+ __wbg_resolve_020f95d838c6ef25: function(arg0) {
361
+ const ret = Promise.resolve(getObject(arg0));
362
+ return addHeapObject(ret);
363
+ },
364
+ __wbg_result_0501bea148306f01: function() { return handleError(function (arg0) {
365
+ const ret = getObject(arg0).result;
366
+ return addHeapObject(ret);
367
+ }, arguments); },
368
+ __wbg_send_5f7b516053d59f8d: function() { return handleError(function (arg0, arg1, arg2) {
369
+ getObject(arg0).send(getStringFromWasm0(arg1, arg2));
370
+ }, arguments); },
371
+ __wbg_setTimeout_593504220b42c5a5: function(arg0, arg1) {
372
+ globalThis.setTimeout(getObject(arg0), arg1);
373
+ },
374
+ __wbg_set_onclose_cb71fea4ad9056fc: function(arg0, arg1) {
375
+ getObject(arg0).onclose = getObject(arg1);
376
+ },
377
+ __wbg_set_onerror_41278ace6abe3973: function(arg0, arg1) {
378
+ getObject(arg0).onerror = getObject(arg1);
379
+ },
380
+ __wbg_set_onerror_f1491b13f0fea022: function(arg0, arg1) {
381
+ getObject(arg0).onerror = getObject(arg1);
382
+ },
383
+ __wbg_set_onmessage_065a797dafa9c437: function(arg0, arg1) {
384
+ getObject(arg0).onmessage = getObject(arg1);
385
+ },
386
+ __wbg_set_onopen_b28699f3431204cf: function(arg0, arg1) {
387
+ getObject(arg0).onopen = getObject(arg1);
388
+ },
389
+ __wbg_set_onsuccess_86d76d6974cd57e4: function(arg0, arg1) {
390
+ getObject(arg0).onsuccess = getObject(arg1);
391
+ },
392
+ __wbg_set_onupgradeneeded_79b60102909f4a5e: function(arg0, arg1) {
393
+ getObject(arg0).onupgradeneeded = getObject(arg1);
394
+ },
395
+ __wbg_stack_3b0d974bbf31e44f: function(arg0, arg1) {
396
+ const ret = getObject(arg1).stack;
397
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
398
+ const len1 = WASM_VECTOR_LEN;
399
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
400
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
401
+ },
402
+ __wbg_static_accessor_GLOBAL_THIS_466428f93b4eaa76: function() {
403
+ const ret = typeof globalThis === 'undefined' ? null : globalThis;
404
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
405
+ },
406
+ __wbg_static_accessor_GLOBAL_c7aea38d4de089bc: function() {
407
+ const ret = typeof global === 'undefined' ? null : global;
408
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
409
+ },
410
+ __wbg_static_accessor_SELF_42d4fae05e59267a: function() {
411
+ const ret = typeof self === 'undefined' ? null : self;
412
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
413
+ },
414
+ __wbg_static_accessor_WINDOW_e0db14a0eba6a812: function() {
415
+ const ret = typeof window === 'undefined' ? null : window;
416
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
417
+ },
418
+ __wbg_target_13424fe1cdc436ac: function(arg0) {
419
+ const ret = getObject(arg0).target;
420
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
421
+ },
422
+ __wbg_then_7026b513a94278a8: function(arg0, arg1) {
423
+ const ret = getObject(arg0).then(getObject(arg1));
424
+ return addHeapObject(ret);
425
+ },
426
+ __wbg_then_72819b8d4e081fb5: function(arg0, arg1, arg2) {
427
+ const ret = getObject(arg0).then(getObject(arg1), getObject(arg2));
428
+ return addHeapObject(ret);
429
+ },
430
+ __wbg_transaction_728366e915610cb0: function() { return handleError(function (arg0, arg1, arg2, arg3) {
431
+ const ret = getObject(arg0).transaction(getStringFromWasm0(arg1, arg2), __wbindgen_enum_IdbTransactionMode[arg3]);
432
+ return addHeapObject(ret);
433
+ }, arguments); },
434
+ __wbindgen_cast_0000000000000001: function(arg0, arg1) {
435
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 12, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
436
+ const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_234);
437
+ return addHeapObject(ret);
438
+ },
439
+ __wbindgen_cast_0000000000000002: function(arg0, arg1) {
440
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 269, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
441
+ const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_1101);
442
+ return addHeapObject(ret);
443
+ },
444
+ __wbindgen_cast_0000000000000003: function(arg0, arg1) {
445
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("IDBVersionChangeEvent")], shim_idx: 12, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
446
+ const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_234_2);
447
+ return addHeapObject(ret);
448
+ },
449
+ __wbindgen_cast_0000000000000004: function(arg0, arg1) {
450
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("MessageEvent")], shim_idx: 12, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
451
+ const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_234_3);
452
+ return addHeapObject(ret);
453
+ },
454
+ __wbindgen_cast_0000000000000005: function(arg0) {
455
+ // Cast intrinsic for `F64 -> Externref`.
456
+ const ret = arg0;
457
+ return addHeapObject(ret);
458
+ },
459
+ __wbindgen_cast_0000000000000006: function(arg0, arg1) {
460
+ // Cast intrinsic for `Ref(String) -> Externref`.
461
+ const ret = getStringFromWasm0(arg0, arg1);
462
+ return addHeapObject(ret);
463
+ },
464
+ __wbindgen_object_clone_ref: function(arg0) {
465
+ const ret = getObject(arg0);
466
+ return addHeapObject(ret);
467
+ },
468
+ __wbindgen_object_drop_ref: function(arg0) {
469
+ takeObject(arg0);
470
+ },
471
+ };
472
+ return {
473
+ __proto__: null,
474
+ "./beam_bg.js": import0,
475
+ };
476
+ }
477
+
478
+ function __wasm_bindgen_func_elem_234(arg0, arg1, arg2) {
479
+ wasm.__wasm_bindgen_func_elem_234(arg0, arg1, addHeapObject(arg2));
480
+ }
481
+
482
+ function __wasm_bindgen_func_elem_234_2(arg0, arg1, arg2) {
483
+ wasm.__wasm_bindgen_func_elem_234_2(arg0, arg1, addHeapObject(arg2));
484
+ }
485
+
486
+ function __wasm_bindgen_func_elem_234_3(arg0, arg1, arg2) {
487
+ wasm.__wasm_bindgen_func_elem_234_3(arg0, arg1, addHeapObject(arg2));
488
+ }
489
+
490
+ function __wasm_bindgen_func_elem_1101(arg0, arg1, arg2) {
491
+ try {
492
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
493
+ wasm.__wasm_bindgen_func_elem_1101(retptr, arg0, arg1, addHeapObject(arg2));
494
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
495
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
496
+ if (r1) {
497
+ throw takeObject(r0);
498
+ }
499
+ } finally {
500
+ wasm.__wbindgen_add_to_stack_pointer(16);
501
+ }
502
+ }
503
+
504
+ function __wasm_bindgen_func_elem_1115(arg0, arg1, arg2, arg3) {
505
+ wasm.__wasm_bindgen_func_elem_1115(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
506
+ }
507
+
508
+
509
+ const __wbindgen_enum_IdbTransactionMode = ["readonly", "readwrite", "versionchange", "readwriteflush", "cleanup"];
510
+ const BeamFinalization = (typeof FinalizationRegistry === 'undefined')
511
+ ? { register: () => {}, unregister: () => {} }
512
+ : new FinalizationRegistry(ptr => wasm.__wbg_beam_free(ptr, 1));
513
+
514
+ function addHeapObject(obj) {
515
+ if (heap_next === heap.length) heap.push(heap.length + 1);
516
+ const idx = heap_next;
517
+ heap_next = heap[idx];
518
+
519
+ heap[idx] = obj;
520
+ return idx;
521
+ }
522
+
523
+ const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')
524
+ ? { register: () => {}, unregister: () => {} }
525
+ : new FinalizationRegistry(state => wasm.__wbindgen_export5(state.a, state.b));
526
+
527
+ function debugString(val) {
528
+ // primitive types
529
+ const type = typeof val;
530
+ if (type == 'number' || type == 'boolean' || val == null) {
531
+ return `${val}`;
532
+ }
533
+ if (type == 'string') {
534
+ return `"${val}"`;
535
+ }
536
+ if (type == 'symbol') {
537
+ const description = val.description;
538
+ if (description == null) {
539
+ return 'Symbol';
540
+ } else {
541
+ return `Symbol(${description})`;
542
+ }
543
+ }
544
+ if (type == 'function') {
545
+ const name = val.name;
546
+ if (typeof name == 'string' && name.length > 0) {
547
+ return `Function(${name})`;
548
+ } else {
549
+ return 'Function';
550
+ }
551
+ }
552
+ // objects
553
+ if (Array.isArray(val)) {
554
+ const length = val.length;
555
+ let debug = '[';
556
+ if (length > 0) {
557
+ debug += debugString(val[0]);
558
+ }
559
+ for(let i = 1; i < length; i++) {
560
+ debug += ', ' + debugString(val[i]);
561
+ }
562
+ debug += ']';
563
+ return debug;
564
+ }
565
+ // Test for built-in
566
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
567
+ let className;
568
+ if (builtInMatches && builtInMatches.length > 1) {
569
+ className = builtInMatches[1];
570
+ } else {
571
+ // Failed to match the standard '[object ClassName]'
572
+ return toString.call(val);
573
+ }
574
+ if (className == 'Object') {
575
+ // we're a user defined class or Object
576
+ // JSON.stringify avoids problems with cycles, and is generally much
577
+ // easier than looping through ownProperties of `val`.
578
+ try {
579
+ return 'Object(' + JSON.stringify(val) + ')';
580
+ } catch (_) {
581
+ return 'Object';
582
+ }
583
+ }
584
+ // errors
585
+ if (val instanceof Error) {
586
+ return `${val.name}: ${val.message}\n${val.stack}`;
587
+ }
588
+ // TODO we could test for more things here, like `Set`s and `Map`s.
589
+ return className;
590
+ }
591
+
592
+ function dropObject(idx) {
593
+ if (idx < 1028) return;
594
+ heap[idx] = heap_next;
595
+ heap_next = idx;
596
+ }
597
+
598
+ function getArrayU8FromWasm0(ptr, len) {
599
+ ptr = ptr >>> 0;
600
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
601
+ }
602
+
603
+ let cachedDataViewMemory0 = null;
604
+ function getDataViewMemory0() {
605
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
606
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
607
+ }
608
+ return cachedDataViewMemory0;
609
+ }
610
+
611
+ function getStringFromWasm0(ptr, len) {
612
+ return decodeText(ptr >>> 0, len);
613
+ }
614
+
615
+ let cachedUint8ArrayMemory0 = null;
616
+ function getUint8ArrayMemory0() {
617
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
618
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
619
+ }
620
+ return cachedUint8ArrayMemory0;
621
+ }
622
+
623
+ function getObject(idx) { return heap[idx]; }
624
+
625
+ function handleError(f, args) {
626
+ try {
627
+ return f.apply(this, args);
628
+ } catch (e) {
629
+ wasm.__wbindgen_export3(addHeapObject(e));
630
+ }
631
+ }
632
+
633
+ let heap = new Array(1024).fill(undefined);
634
+ heap.push(undefined, null, true, false);
635
+
636
+ let heap_next = heap.length;
637
+
638
+ function isLikeNone(x) {
639
+ return x === undefined || x === null;
640
+ }
641
+
642
+ function makeMutClosure(arg0, arg1, f) {
643
+ const state = { a: arg0, b: arg1, cnt: 1 };
644
+ const real = (...args) => {
645
+
646
+ // First up with a closure we increment the internal reference
647
+ // count. This ensures that the Rust closure environment won't
648
+ // be deallocated while we're invoking it.
649
+ state.cnt++;
650
+ const a = state.a;
651
+ state.a = 0;
652
+ try {
653
+ return f(a, state.b, ...args);
654
+ } finally {
655
+ state.a = a;
656
+ real._wbg_cb_unref();
657
+ }
658
+ };
659
+ real._wbg_cb_unref = () => {
660
+ if (--state.cnt === 0) {
661
+ wasm.__wbindgen_export5(state.a, state.b);
662
+ state.a = 0;
663
+ CLOSURE_DTORS.unregister(state);
664
+ }
665
+ };
666
+ CLOSURE_DTORS.register(real, state, state);
667
+ return real;
668
+ }
669
+
670
+ function passStringToWasm0(arg, malloc, realloc) {
671
+ if (realloc === undefined) {
672
+ const buf = cachedTextEncoder.encode(arg);
673
+ const ptr = malloc(buf.length, 1) >>> 0;
674
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
675
+ WASM_VECTOR_LEN = buf.length;
676
+ return ptr;
677
+ }
678
+
679
+ let len = arg.length;
680
+ let ptr = malloc(len, 1) >>> 0;
681
+
682
+ const mem = getUint8ArrayMemory0();
683
+
684
+ let offset = 0;
685
+
686
+ for (; offset < len; offset++) {
687
+ const code = arg.charCodeAt(offset);
688
+ if (code > 0x7F) break;
689
+ mem[ptr + offset] = code;
690
+ }
691
+ if (offset !== len) {
692
+ if (offset !== 0) {
693
+ arg = arg.slice(offset);
694
+ }
695
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
696
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
697
+ const ret = cachedTextEncoder.encodeInto(arg, view);
698
+
699
+ offset += ret.written;
700
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
701
+ }
702
+
703
+ WASM_VECTOR_LEN = offset;
704
+ return ptr;
705
+ }
706
+
707
+ function takeObject(idx) {
708
+ const ret = getObject(idx);
709
+ dropObject(idx);
710
+ return ret;
711
+ }
712
+
713
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
714
+ cachedTextDecoder.decode();
715
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
716
+ let numBytesDecoded = 0;
717
+ function decodeText(ptr, len) {
718
+ numBytesDecoded += len;
719
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
720
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
721
+ cachedTextDecoder.decode();
722
+ numBytesDecoded = len;
723
+ }
724
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
725
+ }
726
+
727
+ const cachedTextEncoder = new TextEncoder();
728
+
729
+ if (!('encodeInto' in cachedTextEncoder)) {
730
+ cachedTextEncoder.encodeInto = function (arg, view) {
731
+ const buf = cachedTextEncoder.encode(arg);
732
+ view.set(buf);
733
+ return {
734
+ read: arg.length,
735
+ written: buf.length
736
+ };
737
+ };
738
+ }
739
+
740
+ let WASM_VECTOR_LEN = 0;
741
+
742
+ let wasmModule, wasmInstance, wasm;
743
+ function __wbg_finalize_init(instance, module) {
744
+ wasmInstance = instance;
745
+ wasm = instance.exports;
746
+ wasmModule = module;
747
+ cachedDataViewMemory0 = null;
748
+ cachedUint8ArrayMemory0 = null;
749
+ return wasm;
750
+ }
751
+
752
+ async function __wbg_load(module, imports) {
753
+ if (typeof Response === 'function' && module instanceof Response) {
754
+ if (!module.ok) {
755
+ throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
756
+ }
757
+
758
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
759
+ try {
760
+ return await WebAssembly.instantiateStreaming(module, imports);
761
+ } catch (e) {
762
+ const validResponse = expectedResponseType(module.type);
763
+
764
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
765
+ 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);
766
+
767
+ } else { throw e; }
768
+ }
769
+ }
770
+
771
+ const bytes = await module.arrayBuffer();
772
+ return await WebAssembly.instantiate(bytes, imports);
773
+ } else {
774
+ const instance = await WebAssembly.instantiate(module, imports);
775
+
776
+ if (instance instanceof WebAssembly.Instance) {
777
+ return { instance, module };
778
+ } else {
779
+ return instance;
780
+ }
781
+ }
782
+
783
+ function expectedResponseType(type) {
784
+ switch (type) {
785
+ case 'basic': case 'cors': case 'default': return true;
786
+ }
787
+ return false;
788
+ }
789
+ }
790
+
791
+ function initSync(module) {
792
+ if (wasm !== undefined) return wasm;
793
+
794
+
795
+ if (module !== undefined) {
796
+ if (Object.getPrototypeOf(module) === Object.prototype) {
797
+ ({module} = module)
798
+ } else {
799
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
800
+ }
801
+ }
802
+
803
+ const imports = __wbg_get_imports();
804
+ if (!(module instanceof WebAssembly.Module)) {
805
+ module = new WebAssembly.Module(module);
806
+ }
807
+ const instance = new WebAssembly.Instance(module, imports);
808
+ return __wbg_finalize_init(instance, module);
809
+ }
810
+
811
+ async function __wbg_init(module_or_path) {
812
+ if (wasm !== undefined) return wasm;
813
+
814
+
815
+ if (module_or_path !== undefined) {
816
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
817
+ ({module_or_path} = module_or_path)
818
+ } else {
819
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
820
+ }
821
+ }
822
+
823
+ if (module_or_path === undefined) {
824
+ module_or_path = new URL('beam_bg.wasm', import.meta.url);
825
+ }
826
+ const imports = __wbg_get_imports();
827
+
828
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
829
+ module_or_path = fetch(module_or_path);
830
+ }
831
+
832
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
833
+
834
+ return __wbg_finalize_init(instance, module);
835
+ }
836
+
837
+ export { initSync, __wbg_init as default };