@feltdb/core 0.4.5 → 0.4.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/README.md +9 -0
  2. package/bin/create-feltdb.js +3 -0
  3. package/bin/feltdb.js +3 -0
  4. package/dist/analytics-backend.js +1 -1
  5. package/dist/cli/api-client.js +236 -0
  6. package/dist/cli/cli.js +18 -0
  7. package/dist/cli/commands.js +795 -0
  8. package/dist/cli/config.js +66 -0
  9. package/dist/cli/index.js +399 -0
  10. package/dist/create/application-identity.js +132 -0
  11. package/dist/create/cli-scripts-generator.js +211 -0
  12. package/dist/create/cli.js +251 -0
  13. package/dist/create/create.js +1862 -0
  14. package/dist/create/docker-compose-generator.js +258 -0
  15. package/dist/create/index.js +4 -0
  16. package/dist/create/package-versions.js +4 -0
  17. package/dist/create/runtime-templates.js +272 -0
  18. package/dist/index-backend.js +1 -1
  19. package/dist/react/useFeltDB.d.ts +1 -1
  20. package/dist/react/useFeltDB.js +1 -1
  21. package/dist/studio/KeyManagementPanel-B0s0xAXz.js +298 -0
  22. package/dist/studio/components/KeyManagementPanel.d.ts.map +1 -1
  23. package/dist/studio/components/KeyManagementPanel.js +1 -1
  24. package/dist/studio/components/index.js +2 -2
  25. package/dist/studio/{components-BRYUceo9.js → components-BAycgZhP.js} +1 -1
  26. package/dist/studio/index.js +2 -2
  27. package/dist/studio-app/assets/{feltdb_wasm-BXMn9UxO.js → feltdb_wasm-Bb1Pg6qz.js} +1 -1
  28. package/dist/studio-app/assets/feltdb_wasm_bg-2_wVudcZ.wasm +0 -0
  29. package/dist/studio-app/assets/{index-B-lZjdtI.js → index-DKVLtS37.js} +2 -2
  30. package/dist/studio-app/index.html +1 -1
  31. package/dist/wasm/feltdb_wasm.d.ts +461 -0
  32. package/dist/wasm/feltdb_wasm.js +1690 -0
  33. package/dist/wasm/feltdb_wasm_bg.wasm +0 -0
  34. package/dist/wasm/feltdb_wasm_bg.wasm.d.ts +84 -0
  35. package/dist/wasm/package.json +16 -0
  36. package/package.json +11 -5
  37. package/dist/studio/KeyManagementPanel-BOvWTRyH.js +0 -246
  38. package/dist/studio-app/assets/feltdb_wasm_bg-bYYbZeRM.wasm +0 -0
@@ -0,0 +1,1690 @@
1
+ /* @ts-self-types="./feltdb_wasm.d.ts" */
2
+
3
+ /**
4
+ * Wrapper around FeltDb for JavaScript interop
5
+ */
6
+ export class JsDb {
7
+ static __wrap(ptr) {
8
+ const obj = Object.create(JsDb.prototype);
9
+ obj.__wbg_ptr = ptr;
10
+ JsDbFinalization.register(obj, obj.__wbg_ptr, obj);
11
+ return obj;
12
+ }
13
+ __destroy_into_raw() {
14
+ const ptr = this.__wbg_ptr;
15
+ this.__wbg_ptr = 0;
16
+ JsDbFinalization.unregister(this);
17
+ return ptr;
18
+ }
19
+ free() {
20
+ const ptr = this.__destroy_into_raw();
21
+ wasm.__wbg_jsdb_free(ptr, 0);
22
+ }
23
+ /**
24
+ * Acknowledge receipt of operations from a peer
25
+ *
26
+ * # Arguments
27
+ * * `peer_id` - Unique identifier for the peer
28
+ * * `sequence` - Acknowledge operations up to this sequence number
29
+ *
30
+ * # Returns
31
+ * JsResult with success status
32
+ * @param {string} peer_id
33
+ * @param {bigint} sequence
34
+ * @returns {JsResult}
35
+ */
36
+ acknowledge_peer_operations(peer_id, sequence) {
37
+ const ptr0 = passStringToWasm0(peer_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
38
+ const len0 = WASM_VECTOR_LEN;
39
+ const ret = wasm.jsdb_acknowledge_peer_operations(this.__wbg_ptr, ptr0, len0, sequence);
40
+ return JsResult.__wrap(ret);
41
+ }
42
+ /**
43
+ * Add a peer for synchronization
44
+ *
45
+ * # Arguments
46
+ * * `peer_id` - Unique identifier for the peer
47
+ *
48
+ * # Returns
49
+ * JsResult with success status
50
+ * @param {string} peer_id
51
+ * @returns {JsResult}
52
+ */
53
+ add_sync_peer(peer_id) {
54
+ const ptr0 = passStringToWasm0(peer_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
55
+ const len0 = WASM_VECTOR_LEN;
56
+ const ret = wasm.jsdb_add_sync_peer(this.__wbg_ptr, ptr0, len0);
57
+ return JsResult.__wrap(ret);
58
+ }
59
+ /**
60
+ * Delete a record from the database.
61
+ * @param {string} key
62
+ * @returns {JsResult}
63
+ */
64
+ delete(key) {
65
+ const ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
66
+ const len0 = WASM_VECTOR_LEN;
67
+ const ret = wasm.jsdb_delete(this.__wbg_ptr, ptr0, len0);
68
+ return JsResult.__wrap(ret);
69
+ }
70
+ /**
71
+ * @param {string} schema
72
+ * @param {string} authorization
73
+ * @param {string} state_namespace
74
+ * @param {string} query
75
+ * @returns {JsResult}
76
+ */
77
+ execute_canonical_query(schema, authorization, state_namespace, query) {
78
+ const ptr0 = passStringToWasm0(schema, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
79
+ const len0 = WASM_VECTOR_LEN;
80
+ const ptr1 = passStringToWasm0(authorization, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
81
+ const len1 = WASM_VECTOR_LEN;
82
+ const ptr2 = passStringToWasm0(state_namespace, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
83
+ const len2 = WASM_VECTOR_LEN;
84
+ const ptr3 = passStringToWasm0(query, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
85
+ const len3 = WASM_VECTOR_LEN;
86
+ const ret = wasm.jsdb_execute_canonical_query(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
87
+ return JsResult.__wrap(ret);
88
+ }
89
+ /**
90
+ * @param {string} schema
91
+ * @param {string} request
92
+ * @returns {JsResult}
93
+ */
94
+ execute_canonical_transaction(schema, request) {
95
+ const ptr0 = passStringToWasm0(schema, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
96
+ const len0 = WASM_VECTOR_LEN;
97
+ const ptr1 = passStringToWasm0(request, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
98
+ const len1 = WASM_VECTOR_LEN;
99
+ const ret = wasm.jsdb_execute_canonical_transaction(this.__wbg_ptr, ptr0, len0, ptr1, len1);
100
+ return JsResult.__wrap(ret);
101
+ }
102
+ /**
103
+ * Retrieve a record from the database
104
+ *
105
+ * # Arguments
106
+ * * `key` - Key for the record
107
+ *
108
+ * # Returns
109
+ * JSON string of the record or error
110
+ * @param {string} key
111
+ * @returns {JsResult}
112
+ */
113
+ get(key) {
114
+ const ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
115
+ const len0 = WASM_VECTOR_LEN;
116
+ const ret = wasm.jsdb_get(this.__wbg_ptr, ptr0, len0);
117
+ return JsResult.__wrap(ret);
118
+ }
119
+ /**
120
+ * Get all records in a capability namespace
121
+ *
122
+ * # Arguments
123
+ * * `capability` - Capability/namespace name
124
+ *
125
+ * # Returns
126
+ * JSON array string of all records in the capability
127
+ * @param {string} capability
128
+ * @returns {JsResult}
129
+ */
130
+ get_capability_records(capability) {
131
+ const ptr0 = passStringToWasm0(capability, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
132
+ const len0 = WASM_VECTOR_LEN;
133
+ const ret = wasm.jsdb_get_capability_records(this.__wbg_ptr, ptr0, len0);
134
+ return JsResult.__wrap(ret);
135
+ }
136
+ /**
137
+ * Get pending operations for a peer since a given sequence
138
+ *
139
+ * # Arguments
140
+ * * `peer_id` - Unique identifier for the peer
141
+ * * `since_sequence` - Get operations after this sequence number
142
+ *
143
+ * # Returns
144
+ * JSON array of operations as a string
145
+ * @param {string} peer_id
146
+ * @param {bigint} since_sequence
147
+ * @returns {JsResult}
148
+ */
149
+ get_pending_for_peer(peer_id, since_sequence) {
150
+ const ptr0 = passStringToWasm0(peer_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
151
+ const len0 = WASM_VECTOR_LEN;
152
+ const ret = wasm.jsdb_get_pending_for_peer(this.__wbg_ptr, ptr0, len0, since_sequence);
153
+ return JsResult.__wrap(ret);
154
+ }
155
+ /**
156
+ * Get the current sequence number for this instance
157
+ *
158
+ * # Returns
159
+ * The current sequence number
160
+ * @returns {bigint}
161
+ */
162
+ get_sequence() {
163
+ const ret = wasm.jsdb_get_sequence(this.__wbg_ptr);
164
+ return BigInt.asUintN(64, ret);
165
+ }
166
+ /**
167
+ * Insert a record into the database
168
+ *
169
+ * # Arguments
170
+ * * `key` - Key for the record (e.g., "users:123")
171
+ * * `value` - JSON object as a string
172
+ *
173
+ * # Returns
174
+ * JsResult with success status
175
+ * @param {string} key
176
+ * @param {string} value
177
+ * @returns {JsResult}
178
+ */
179
+ insert(key, value) {
180
+ const ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
181
+ const len0 = WASM_VECTOR_LEN;
182
+ const ptr1 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
183
+ const len1 = WASM_VECTOR_LEN;
184
+ const ret = wasm.jsdb_insert(this.__wbg_ptr, ptr0, len0, ptr1, len1);
185
+ return JsResult.__wrap(ret);
186
+ }
187
+ /**
188
+ * Get the instance ID for this FeltDB instance
189
+ *
190
+ * # Returns
191
+ * The unique instance ID as a string
192
+ * @returns {string}
193
+ */
194
+ instance_id() {
195
+ let deferred1_0;
196
+ let deferred1_1;
197
+ try {
198
+ const ret = wasm.jsdb_instance_id(this.__wbg_ptr);
199
+ deferred1_0 = ret[0];
200
+ deferred1_1 = ret[1];
201
+ return getStringFromWasm0(ret[0], ret[1]);
202
+ } finally {
203
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
204
+ }
205
+ }
206
+ /**
207
+ * Check if a type is auto-indexed
208
+ *
209
+ * # Returns
210
+ * Whether the default (generic JSON) type is auto-indexed
211
+ * @returns {boolean}
212
+ */
213
+ is_auto_indexed() {
214
+ const ret = wasm.jsdb_is_auto_indexed(this.__wbg_ptr);
215
+ return ret !== 0;
216
+ }
217
+ /**
218
+ * Query records in the database with a predicate
219
+ *
220
+ * For now, this returns all records of a given type namespace as a simplified implementation.
221
+ * The full closure-based predicate from Rust cannot be directly represented in WASM bindings.
222
+ *
223
+ * # Arguments
224
+ * * `capability` - Capability/namespace to query (e.g., "users")
225
+ *
226
+ * # Returns
227
+ * JSON array string of matching records
228
+ * @param {string} capability
229
+ * @returns {JsResult}
230
+ */
231
+ query(capability) {
232
+ const ptr0 = passStringToWasm0(capability, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
233
+ const len0 = WASM_VECTOR_LEN;
234
+ const ret = wasm.jsdb_query(this.__wbg_ptr, ptr0, len0);
235
+ return JsResult.__wrap(ret);
236
+ }
237
+ /**
238
+ * Remove a peer from synchronization
239
+ *
240
+ * # Arguments
241
+ * * `peer_id` - Unique identifier for the peer
242
+ *
243
+ * # Returns
244
+ * JsResult with success status
245
+ * @param {string} peer_id
246
+ * @returns {JsResult}
247
+ */
248
+ remove_sync_peer(peer_id) {
249
+ const ptr0 = passStringToWasm0(peer_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
250
+ const len0 = WASM_VECTOR_LEN;
251
+ const ret = wasm.jsdb_remove_sync_peer(this.__wbg_ptr, ptr0, len0);
252
+ return JsResult.__wrap(ret);
253
+ }
254
+ /**
255
+ * Get current sync state information
256
+ *
257
+ * # Returns
258
+ * JSON string containing sync state metrics
259
+ * @returns {JsResult}
260
+ */
261
+ sync_info() {
262
+ const ret = wasm.jsdb_sync_info(this.__wbg_ptr);
263
+ return JsResult.__wrap(ret);
264
+ }
265
+ /**
266
+ * Update an existing record through the canonical update operation.
267
+ * @param {string} key
268
+ * @param {string} value
269
+ * @returns {JsResult}
270
+ */
271
+ update(key, value) {
272
+ const ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
273
+ const len0 = WASM_VECTOR_LEN;
274
+ const ptr1 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
275
+ const len1 = WASM_VECTOR_LEN;
276
+ const ret = wasm.jsdb_update(this.__wbg_ptr, ptr0, len0, ptr1, len1);
277
+ return JsResult.__wrap(ret);
278
+ }
279
+ }
280
+ if (Symbol.dispose) JsDb.prototype[Symbol.dispose] = JsDb.prototype.free;
281
+
282
+ /**
283
+ * Result type for WASM operations
284
+ */
285
+ export class JsResult {
286
+ static __wrap(ptr) {
287
+ const obj = Object.create(JsResult.prototype);
288
+ obj.__wbg_ptr = ptr;
289
+ JsResultFinalization.register(obj, obj.__wbg_ptr, obj);
290
+ return obj;
291
+ }
292
+ __destroy_into_raw() {
293
+ const ptr = this.__wbg_ptr;
294
+ this.__wbg_ptr = 0;
295
+ JsResultFinalization.unregister(this);
296
+ return ptr;
297
+ }
298
+ free() {
299
+ const ptr = this.__destroy_into_raw();
300
+ wasm.__wbg_jsresult_free(ptr, 0);
301
+ }
302
+ /**
303
+ * @returns {string | undefined}
304
+ */
305
+ get data() {
306
+ const ret = wasm.jsresult_data(this.__wbg_ptr);
307
+ let v1;
308
+ if (ret[0] !== 0) {
309
+ v1 = getStringFromWasm0(ret[0], ret[1]);
310
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
311
+ }
312
+ return v1;
313
+ }
314
+ /**
315
+ * @returns {string | undefined}
316
+ */
317
+ get error() {
318
+ const ret = wasm.jsresult_error(this.__wbg_ptr);
319
+ let v1;
320
+ if (ret[0] !== 0) {
321
+ v1 = getStringFromWasm0(ret[0], ret[1]);
322
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
323
+ }
324
+ return v1;
325
+ }
326
+ /**
327
+ * @returns {boolean}
328
+ */
329
+ get success() {
330
+ const ret = wasm.jsresult_success(this.__wbg_ptr);
331
+ return ret !== 0;
332
+ }
333
+ }
334
+ if (Symbol.dispose) JsResult.prototype[Symbol.dispose] = JsResult.prototype.free;
335
+
336
+ /**
337
+ * High-performance analytics engine for index monitoring.
338
+ * Tracks metrics, generates reports, and provides tuning recommendations.
339
+ */
340
+ export class WasmAnalytics {
341
+ __destroy_into_raw() {
342
+ const ptr = this.__wbg_ptr;
343
+ this.__wbg_ptr = 0;
344
+ WasmAnalyticsFinalization.unregister(this);
345
+ return ptr;
346
+ }
347
+ free() {
348
+ const ptr = this.__destroy_into_raw();
349
+ wasm.__wbg_wasmanalytics_free(ptr, 0);
350
+ }
351
+ /**
352
+ * Generate performance report for a collection.
353
+ * @param {string} collection_name
354
+ * @param {string} period
355
+ * @returns {string}
356
+ */
357
+ generate_report(collection_name, period) {
358
+ let deferred4_0;
359
+ let deferred4_1;
360
+ try {
361
+ const ptr0 = passStringToWasm0(collection_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
362
+ const len0 = WASM_VECTOR_LEN;
363
+ const ptr1 = passStringToWasm0(period, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
364
+ const len1 = WASM_VECTOR_LEN;
365
+ const ret = wasm.wasmanalytics_generate_report(this.__wbg_ptr, ptr0, len0, ptr1, len1);
366
+ var ptr3 = ret[0];
367
+ var len3 = ret[1];
368
+ if (ret[3]) {
369
+ ptr3 = 0; len3 = 0;
370
+ throw takeFromExternrefTable0(ret[2]);
371
+ }
372
+ deferred4_0 = ptr3;
373
+ deferred4_1 = len3;
374
+ return getStringFromWasm0(ptr3, len3);
375
+ } finally {
376
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
377
+ }
378
+ }
379
+ /**
380
+ * Get metrics for all indexes.
381
+ * @returns {string}
382
+ */
383
+ get_all_metrics() {
384
+ let deferred2_0;
385
+ let deferred2_1;
386
+ try {
387
+ const ret = wasm.wasmanalytics_get_all_metrics(this.__wbg_ptr);
388
+ var ptr1 = ret[0];
389
+ var len1 = ret[1];
390
+ if (ret[3]) {
391
+ ptr1 = 0; len1 = 0;
392
+ throw takeFromExternrefTable0(ret[2]);
393
+ }
394
+ deferred2_0 = ptr1;
395
+ deferred2_1 = len1;
396
+ return getStringFromWasm0(ptr1, len1);
397
+ } finally {
398
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
399
+ }
400
+ }
401
+ /**
402
+ * Get most frequently accessed fields.
403
+ * @param {number} limit
404
+ * @returns {string}
405
+ */
406
+ get_frequent_fields(limit) {
407
+ let deferred2_0;
408
+ let deferred2_1;
409
+ try {
410
+ const ret = wasm.wasmanalytics_get_frequent_fields(this.__wbg_ptr, limit);
411
+ var ptr1 = ret[0];
412
+ var len1 = ret[1];
413
+ if (ret[3]) {
414
+ ptr1 = 0; len1 = 0;
415
+ throw takeFromExternrefTable0(ret[2]);
416
+ }
417
+ deferred2_0 = ptr1;
418
+ deferred2_1 = len1;
419
+ return getStringFromWasm0(ptr1, len1);
420
+ } finally {
421
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
422
+ }
423
+ }
424
+ /**
425
+ * Get metrics for a specific index.
426
+ * @param {string} index_name
427
+ * @returns {string}
428
+ */
429
+ get_index_metrics(index_name) {
430
+ let deferred3_0;
431
+ let deferred3_1;
432
+ try {
433
+ const ptr0 = passStringToWasm0(index_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
434
+ const len0 = WASM_VECTOR_LEN;
435
+ const ret = wasm.wasmanalytics_get_index_metrics(this.__wbg_ptr, ptr0, len0);
436
+ var ptr2 = ret[0];
437
+ var len2 = ret[1];
438
+ if (ret[3]) {
439
+ ptr2 = 0; len2 = 0;
440
+ throw takeFromExternrefTable0(ret[2]);
441
+ }
442
+ deferred3_0 = ptr2;
443
+ deferred3_1 = len2;
444
+ return getStringFromWasm0(ptr2, len2);
445
+ } finally {
446
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
447
+ }
448
+ }
449
+ /**
450
+ * Get slowest queries.
451
+ * @param {number} limit
452
+ * @returns {string}
453
+ */
454
+ get_slowest_queries(limit) {
455
+ let deferred2_0;
456
+ let deferred2_1;
457
+ try {
458
+ const ret = wasm.wasmanalytics_get_slowest_queries(this.__wbg_ptr, limit);
459
+ var ptr1 = ret[0];
460
+ var len1 = ret[1];
461
+ if (ret[3]) {
462
+ ptr1 = 0; len1 = 0;
463
+ throw takeFromExternrefTable0(ret[2]);
464
+ }
465
+ deferred2_0 = ptr1;
466
+ deferred2_1 = len1;
467
+ return getStringFromWasm0(ptr1, len1);
468
+ } finally {
469
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
470
+ }
471
+ }
472
+ constructor() {
473
+ const ret = wasm.wasmanalytics_new();
474
+ this.__wbg_ptr = ret;
475
+ WasmAnalyticsFinalization.register(this, this.__wbg_ptr, this);
476
+ return this;
477
+ }
478
+ /**
479
+ * Record an index usage event.
480
+ * @param {string} index_name
481
+ * @param {string} operation
482
+ * @param {number} time_ms
483
+ */
484
+ record_index_usage(index_name, operation, time_ms) {
485
+ const ptr0 = passStringToWasm0(index_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
486
+ const len0 = WASM_VECTOR_LEN;
487
+ const ptr1 = passStringToWasm0(operation, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
488
+ const len1 = WASM_VECTOR_LEN;
489
+ wasm.wasmanalytics_record_index_usage(this.__wbg_ptr, ptr0, len0, ptr1, len1, time_ms);
490
+ }
491
+ /**
492
+ * Record a query execution with performance metrics.
493
+ * @param {string} fields_json
494
+ * @param {string} operator
495
+ * @param {number} execution_time_ms
496
+ * @param {bigint} rows_scanned
497
+ * @param {bigint} result_count
498
+ * @param {string | null} [index_used]
499
+ */
500
+ record_query(fields_json, operator, execution_time_ms, rows_scanned, result_count, index_used) {
501
+ const ptr0 = passStringToWasm0(fields_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
502
+ const len0 = WASM_VECTOR_LEN;
503
+ const ptr1 = passStringToWasm0(operator, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
504
+ const len1 = WASM_VECTOR_LEN;
505
+ var ptr2 = isLikeNone(index_used) ? 0 : passStringToWasm0(index_used, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
506
+ var len2 = WASM_VECTOR_LEN;
507
+ const ret = wasm.wasmanalytics_record_query(this.__wbg_ptr, ptr0, len0, ptr1, len1, execution_time_ms, rows_scanned, result_count, ptr2, len2);
508
+ if (ret[1]) {
509
+ throw takeFromExternrefTable0(ret[0]);
510
+ }
511
+ }
512
+ /**
513
+ * Reset all collected metrics.
514
+ */
515
+ reset() {
516
+ wasm.wasmanalytics_reset(this.__wbg_ptr);
517
+ }
518
+ }
519
+ if (Symbol.dispose) WasmAnalytics.prototype[Symbol.dispose] = WasmAnalytics.prototype.free;
520
+
521
+ /**
522
+ * Distributed index manager for multi-node synchronization.
523
+ * Coordinates index replication, consistency, and conflict resolution.
524
+ */
525
+ export class WasmDistributedIndexManager {
526
+ __destroy_into_raw() {
527
+ const ptr = this.__wbg_ptr;
528
+ this.__wbg_ptr = 0;
529
+ WasmDistributedIndexManagerFinalization.unregister(this);
530
+ return ptr;
531
+ }
532
+ free() {
533
+ const ptr = this.__destroy_into_raw();
534
+ wasm.__wbg_wasmdistributedindexmanager_free(ptr, 0);
535
+ }
536
+ /**
537
+ * Create a replicated index
538
+ * @param {string} name
539
+ * @param {string} field
540
+ * @param {string} index_type
541
+ */
542
+ create_replicated_index(name, field, index_type) {
543
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
544
+ const len0 = WASM_VECTOR_LEN;
545
+ const ptr1 = passStringToWasm0(field, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
546
+ const len1 = WASM_VECTOR_LEN;
547
+ const ptr2 = passStringToWasm0(index_type, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
548
+ const len2 = WASM_VECTOR_LEN;
549
+ const ret = wasm.wasmdistributedindexmanager_create_replicated_index(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
550
+ if (ret[1]) {
551
+ throw takeFromExternrefTable0(ret[0]);
552
+ }
553
+ }
554
+ /**
555
+ * Detect version conflicts
556
+ * @param {string} index_name
557
+ * @returns {string}
558
+ */
559
+ detect_conflicts(index_name) {
560
+ let deferred3_0;
561
+ let deferred3_1;
562
+ try {
563
+ const ptr0 = passStringToWasm0(index_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
564
+ const len0 = WASM_VECTOR_LEN;
565
+ const ret = wasm.wasmdistributedindexmanager_detect_conflicts(this.__wbg_ptr, ptr0, len0);
566
+ var ptr2 = ret[0];
567
+ var len2 = ret[1];
568
+ if (ret[3]) {
569
+ ptr2 = 0; len2 = 0;
570
+ throw takeFromExternrefTable0(ret[2]);
571
+ }
572
+ deferred3_0 = ptr2;
573
+ deferred3_1 = len2;
574
+ return getStringFromWasm0(ptr2, len2);
575
+ } finally {
576
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
577
+ }
578
+ }
579
+ /**
580
+ * Get replication status for an index
581
+ * @param {string} index_name
582
+ * @returns {string}
583
+ */
584
+ get_replication_status(index_name) {
585
+ let deferred3_0;
586
+ let deferred3_1;
587
+ try {
588
+ const ptr0 = passStringToWasm0(index_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
589
+ const len0 = WASM_VECTOR_LEN;
590
+ const ret = wasm.wasmdistributedindexmanager_get_replication_status(this.__wbg_ptr, ptr0, len0);
591
+ var ptr2 = ret[0];
592
+ var len2 = ret[1];
593
+ if (ret[3]) {
594
+ ptr2 = 0; len2 = 0;
595
+ throw takeFromExternrefTable0(ret[2]);
596
+ }
597
+ deferred3_0 = ptr2;
598
+ deferred3_1 = len2;
599
+ return getStringFromWasm0(ptr2, len2);
600
+ } finally {
601
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
602
+ }
603
+ }
604
+ /**
605
+ * Get list of peers needing replication for an index
606
+ * @param {string} index_name
607
+ * @returns {string}
608
+ */
609
+ get_replication_targets(index_name) {
610
+ let deferred3_0;
611
+ let deferred3_1;
612
+ try {
613
+ const ptr0 = passStringToWasm0(index_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
614
+ const len0 = WASM_VECTOR_LEN;
615
+ const ret = wasm.wasmdistributedindexmanager_get_replication_targets(this.__wbg_ptr, ptr0, len0);
616
+ var ptr2 = ret[0];
617
+ var len2 = ret[1];
618
+ if (ret[3]) {
619
+ ptr2 = 0; len2 = 0;
620
+ throw takeFromExternrefTable0(ret[2]);
621
+ }
622
+ deferred3_0 = ptr2;
623
+ deferred3_1 = len2;
624
+ return getStringFromWasm0(ptr2, len2);
625
+ } finally {
626
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
627
+ }
628
+ }
629
+ /**
630
+ * Get overall synchronization status
631
+ * @returns {string}
632
+ */
633
+ get_sync_status() {
634
+ let deferred2_0;
635
+ let deferred2_1;
636
+ try {
637
+ const ret = wasm.wasmdistributedindexmanager_get_sync_status(this.__wbg_ptr);
638
+ var ptr1 = ret[0];
639
+ var len1 = ret[1];
640
+ if (ret[3]) {
641
+ ptr1 = 0; len1 = 0;
642
+ throw takeFromExternrefTable0(ret[2]);
643
+ }
644
+ deferred2_0 = ptr1;
645
+ deferred2_1 = len1;
646
+ return getStringFromWasm0(ptr1, len1);
647
+ } finally {
648
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
649
+ }
650
+ }
651
+ /**
652
+ * Merge concurrent versions
653
+ * @param {string} index_name
654
+ */
655
+ merge_versions(index_name) {
656
+ const ptr0 = passStringToWasm0(index_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
657
+ const len0 = WASM_VECTOR_LEN;
658
+ const ret = wasm.wasmdistributedindexmanager_merge_versions(this.__wbg_ptr, ptr0, len0);
659
+ if (ret[1]) {
660
+ throw takeFromExternrefTable0(ret[0]);
661
+ }
662
+ }
663
+ /**
664
+ * @param {string} peer_id
665
+ */
666
+ constructor(peer_id) {
667
+ const ptr0 = passStringToWasm0(peer_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
668
+ const len0 = WASM_VECTOR_LEN;
669
+ const ret = wasm.wasmdistributedindexmanager_new(ptr0, len0);
670
+ this.__wbg_ptr = ret;
671
+ WasmDistributedIndexManagerFinalization.register(this, this.__wbg_ptr, this);
672
+ return this;
673
+ }
674
+ /**
675
+ * Register a peer for replication
676
+ * @param {string} peer_id
677
+ */
678
+ register_peer(peer_id) {
679
+ const ptr0 = passStringToWasm0(peer_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
680
+ const len0 = WASM_VECTOR_LEN;
681
+ wasm.wasmdistributedindexmanager_register_peer(this.__wbg_ptr, ptr0, len0);
682
+ }
683
+ /**
684
+ * Set peer reachability
685
+ * @param {string} peer_id
686
+ * @param {boolean} reachable
687
+ */
688
+ set_peer_reachable(peer_id, reachable) {
689
+ const ptr0 = passStringToWasm0(peer_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
690
+ const len0 = WASM_VECTOR_LEN;
691
+ wasm.wasmdistributedindexmanager_set_peer_reachable(this.__wbg_ptr, ptr0, len0, reachable);
692
+ }
693
+ }
694
+ if (Symbol.dispose) WasmDistributedIndexManager.prototype[Symbol.dispose] = WasmDistributedIndexManager.prototype.free;
695
+
696
+ /**
697
+ * High-performance index manager for collections.
698
+ * Wraps Rust IndexManager for optimal query performance.
699
+ */
700
+ export class WasmIndexManager {
701
+ __destroy_into_raw() {
702
+ const ptr = this.__wbg_ptr;
703
+ this.__wbg_ptr = 0;
704
+ WasmIndexManagerFinalization.unregister(this);
705
+ return ptr;
706
+ }
707
+ free() {
708
+ const ptr = this.__destroy_into_raw();
709
+ wasm.__wbg_wasmindexmanager_free(ptr, 0);
710
+ }
711
+ /**
712
+ * Create a new index on the collection.
713
+ * @param {string} config
714
+ */
715
+ create_index(config) {
716
+ const ptr0 = passStringToWasm0(config, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
717
+ const len0 = WASM_VECTOR_LEN;
718
+ const ret = wasm.wasmindexmanager_create_index(this.__wbg_ptr, ptr0, len0);
719
+ if (ret[1]) {
720
+ throw takeFromExternrefTable0(ret[0]);
721
+ }
722
+ }
723
+ /**
724
+ * Get statistics for an index.
725
+ * @param {string} name
726
+ * @returns {string}
727
+ */
728
+ get_stats(name) {
729
+ let deferred3_0;
730
+ let deferred3_1;
731
+ try {
732
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
733
+ const len0 = WASM_VECTOR_LEN;
734
+ const ret = wasm.wasmindexmanager_get_stats(this.__wbg_ptr, ptr0, len0);
735
+ var ptr2 = ret[0];
736
+ var len2 = ret[1];
737
+ if (ret[3]) {
738
+ ptr2 = 0; len2 = 0;
739
+ throw takeFromExternrefTable0(ret[2]);
740
+ }
741
+ deferred3_0 = ptr2;
742
+ deferred3_1 = len2;
743
+ return getStringFromWasm0(ptr2, len2);
744
+ } finally {
745
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
746
+ }
747
+ }
748
+ /**
749
+ * List all indexes.
750
+ * @returns {string}
751
+ */
752
+ list_indexes() {
753
+ let deferred2_0;
754
+ let deferred2_1;
755
+ try {
756
+ const ret = wasm.wasmindexmanager_list_indexes(this.__wbg_ptr);
757
+ var ptr1 = ret[0];
758
+ var len1 = ret[1];
759
+ if (ret[3]) {
760
+ ptr1 = 0; len1 = 0;
761
+ throw takeFromExternrefTable0(ret[2]);
762
+ }
763
+ deferred2_0 = ptr1;
764
+ deferred2_1 = len1;
765
+ return getStringFromWasm0(ptr1, len1);
766
+ } finally {
767
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
768
+ }
769
+ }
770
+ constructor() {
771
+ const ret = wasm.wasmindexmanager_new();
772
+ this.__wbg_ptr = ret;
773
+ WasmIndexManagerFinalization.register(this, this.__wbg_ptr, this);
774
+ return this;
775
+ }
776
+ /**
777
+ * Query an index.
778
+ * @param {string} index_name
779
+ * @param {string} operator
780
+ * @param {string} value
781
+ * @returns {string}
782
+ */
783
+ query_index(index_name, operator, value) {
784
+ let deferred5_0;
785
+ let deferred5_1;
786
+ try {
787
+ const ptr0 = passStringToWasm0(index_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
788
+ const len0 = WASM_VECTOR_LEN;
789
+ const ptr1 = passStringToWasm0(operator, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
790
+ const len1 = WASM_VECTOR_LEN;
791
+ const ptr2 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
792
+ const len2 = WASM_VECTOR_LEN;
793
+ const ret = wasm.wasmindexmanager_query_index(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
794
+ var ptr4 = ret[0];
795
+ var len4 = ret[1];
796
+ if (ret[3]) {
797
+ ptr4 = 0; len4 = 0;
798
+ throw takeFromExternrefTable0(ret[2]);
799
+ }
800
+ deferred5_0 = ptr4;
801
+ deferred5_1 = len4;
802
+ return getStringFromWasm0(ptr4, len4);
803
+ } finally {
804
+ wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
805
+ }
806
+ }
807
+ /**
808
+ * Update a record's index entries.
809
+ * @param {string} record_id
810
+ * @param {string | null | undefined} old_value
811
+ * @param {string} new_value
812
+ */
813
+ update_record(record_id, old_value, new_value) {
814
+ const ptr0 = passStringToWasm0(record_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
815
+ const len0 = WASM_VECTOR_LEN;
816
+ var ptr1 = isLikeNone(old_value) ? 0 : passStringToWasm0(old_value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
817
+ var len1 = WASM_VECTOR_LEN;
818
+ const ptr2 = passStringToWasm0(new_value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
819
+ const len2 = WASM_VECTOR_LEN;
820
+ const ret = wasm.wasmindexmanager_update_record(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
821
+ if (ret[1]) {
822
+ throw takeFromExternrefTable0(ret[0]);
823
+ }
824
+ }
825
+ }
826
+ if (Symbol.dispose) WasmIndexManager.prototype[Symbol.dispose] = WasmIndexManager.prototype.free;
827
+
828
+ /**
829
+ * Shard manager for horizontal scaling.
830
+ * Distributes data across shards and handles rebalancing.
831
+ */
832
+ export class WasmShardManager {
833
+ __destroy_into_raw() {
834
+ const ptr = this.__wbg_ptr;
835
+ this.__wbg_ptr = 0;
836
+ WasmShardManagerFinalization.unregister(this);
837
+ return ptr;
838
+ }
839
+ free() {
840
+ const ptr = this.__destroy_into_raw();
841
+ wasm.__wbg_wasmshardmanager_free(ptr, 0);
842
+ }
843
+ /**
844
+ * Detect hotspots
845
+ * @returns {string}
846
+ */
847
+ detect_hotspots() {
848
+ let deferred2_0;
849
+ let deferred2_1;
850
+ try {
851
+ const ret = wasm.wasmshardmanager_detect_hotspots(this.__wbg_ptr);
852
+ var ptr1 = ret[0];
853
+ var len1 = ret[1];
854
+ if (ret[3]) {
855
+ ptr1 = 0; len1 = 0;
856
+ throw takeFromExternrefTable0(ret[2]);
857
+ }
858
+ deferred2_0 = ptr1;
859
+ deferred2_1 = len1;
860
+ return getStringFromWasm0(ptr1, len1);
861
+ } finally {
862
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
863
+ }
864
+ }
865
+ /**
866
+ * Generate rebalance operations
867
+ * @returns {string}
868
+ */
869
+ generate_rebalance_ops() {
870
+ let deferred2_0;
871
+ let deferred2_1;
872
+ try {
873
+ const ret = wasm.wasmshardmanager_generate_rebalance_ops(this.__wbg_ptr);
874
+ var ptr1 = ret[0];
875
+ var len1 = ret[1];
876
+ if (ret[3]) {
877
+ ptr1 = 0; len1 = 0;
878
+ throw takeFromExternrefTable0(ret[2]);
879
+ }
880
+ deferred2_0 = ptr1;
881
+ deferred2_1 = len1;
882
+ return getStringFromWasm0(ptr1, len1);
883
+ } finally {
884
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
885
+ }
886
+ }
887
+ /**
888
+ * Get all shard metrics
889
+ * @returns {string}
890
+ */
891
+ get_all_metrics() {
892
+ let deferred2_0;
893
+ let deferred2_1;
894
+ try {
895
+ const ret = wasm.wasmshardmanager_get_all_metrics(this.__wbg_ptr);
896
+ var ptr1 = ret[0];
897
+ var len1 = ret[1];
898
+ if (ret[3]) {
899
+ ptr1 = 0; len1 = 0;
900
+ throw takeFromExternrefTable0(ret[2]);
901
+ }
902
+ deferred2_0 = ptr1;
903
+ deferred2_1 = len1;
904
+ return getStringFromWasm0(ptr1, len1);
905
+ } finally {
906
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
907
+ }
908
+ }
909
+ /**
910
+ * Get distribution summary
911
+ * @returns {string}
912
+ */
913
+ get_distribution_summary() {
914
+ let deferred2_0;
915
+ let deferred2_1;
916
+ try {
917
+ const ret = wasm.wasmshardmanager_get_distribution_summary(this.__wbg_ptr);
918
+ var ptr1 = ret[0];
919
+ var len1 = ret[1];
920
+ if (ret[3]) {
921
+ ptr1 = 0; len1 = 0;
922
+ throw takeFromExternrefTable0(ret[2]);
923
+ }
924
+ deferred2_0 = ptr1;
925
+ deferred2_1 = len1;
926
+ return getStringFromWasm0(ptr1, len1);
927
+ } finally {
928
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
929
+ }
930
+ }
931
+ /**
932
+ * Get shard for a key
933
+ * @param {string} key
934
+ * @returns {string}
935
+ */
936
+ get_shard_for_key(key) {
937
+ let deferred3_0;
938
+ let deferred3_1;
939
+ try {
940
+ const ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
941
+ const len0 = WASM_VECTOR_LEN;
942
+ const ret = wasm.wasmshardmanager_get_shard_for_key(this.__wbg_ptr, ptr0, len0);
943
+ var ptr2 = ret[0];
944
+ var len2 = ret[1];
945
+ if (ret[3]) {
946
+ ptr2 = 0; len2 = 0;
947
+ throw takeFromExternrefTable0(ret[2]);
948
+ }
949
+ deferred3_0 = ptr2;
950
+ deferred3_1 = len2;
951
+ return getStringFromWasm0(ptr2, len2);
952
+ } finally {
953
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
954
+ }
955
+ }
956
+ /**
957
+ * Initialize shards
958
+ * @param {string} shard_ids_json
959
+ */
960
+ initialize_shards(shard_ids_json) {
961
+ const ptr0 = passStringToWasm0(shard_ids_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
962
+ const len0 = WASM_VECTOR_LEN;
963
+ const ret = wasm.wasmshardmanager_initialize_shards(this.__wbg_ptr, ptr0, len0);
964
+ if (ret[1]) {
965
+ throw takeFromExternrefTable0(ret[0]);
966
+ }
967
+ }
968
+ /**
969
+ * @param {string} shard_field
970
+ * @param {string} strategy
971
+ */
972
+ constructor(shard_field, strategy) {
973
+ const ptr0 = passStringToWasm0(shard_field, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
974
+ const len0 = WASM_VECTOR_LEN;
975
+ const ptr1 = passStringToWasm0(strategy, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
976
+ const len1 = WASM_VECTOR_LEN;
977
+ const ret = wasm.wasmshardmanager_new(ptr0, len0, ptr1, len1);
978
+ this.__wbg_ptr = ret;
979
+ WasmShardManagerFinalization.register(this, this.__wbg_ptr, this);
980
+ return this;
981
+ }
982
+ /**
983
+ * Record a shard operation
984
+ * @param {string} shard_id
985
+ * @param {string} operation
986
+ * @param {number} time_ms
987
+ * @param {number} records_affected
988
+ * @param {bigint} size_bytes
989
+ */
990
+ record_shard_operation(shard_id, operation, time_ms, records_affected, size_bytes) {
991
+ const ptr0 = passStringToWasm0(shard_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
992
+ const len0 = WASM_VECTOR_LEN;
993
+ const ptr1 = passStringToWasm0(operation, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
994
+ const len1 = WASM_VECTOR_LEN;
995
+ wasm.wasmshardmanager_record_shard_operation(this.__wbg_ptr, ptr0, len0, ptr1, len1, time_ms, records_affected, size_bytes);
996
+ }
997
+ }
998
+ if (Symbol.dispose) WasmShardManager.prototype[Symbol.dispose] = WasmShardManager.prototype.free;
999
+
1000
+ /**
1001
+ * @param {string} local_runtime
1002
+ * @param {string} result
1003
+ * @returns {string}
1004
+ */
1005
+ export function apply_sync_result(local_runtime, result) {
1006
+ let deferred4_0;
1007
+ let deferred4_1;
1008
+ try {
1009
+ const ptr0 = passStringToWasm0(local_runtime, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1010
+ const len0 = WASM_VECTOR_LEN;
1011
+ const ptr1 = passStringToWasm0(result, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1012
+ const len1 = WASM_VECTOR_LEN;
1013
+ const ret = wasm.apply_sync_result(ptr0, len0, ptr1, len1);
1014
+ var ptr3 = ret[0];
1015
+ var len3 = ret[1];
1016
+ if (ret[3]) {
1017
+ ptr3 = 0; len3 = 0;
1018
+ throw takeFromExternrefTable0(ret[2]);
1019
+ }
1020
+ deferred4_0 = ptr3;
1021
+ deferred4_1 = len3;
1022
+ return getStringFromWasm0(ptr3, len3);
1023
+ } finally {
1024
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
1025
+ }
1026
+ }
1027
+
1028
+ /**
1029
+ * @param {string} signed_grant
1030
+ * @param {string} key_id
1031
+ * @param {string} verification_key
1032
+ * @param {string} request
1033
+ * @param {string} grant_chain
1034
+ * @param {string} revocations
1035
+ * @returns {string}
1036
+ */
1037
+ export function authorize_offline(signed_grant, key_id, verification_key, request, grant_chain, revocations) {
1038
+ let deferred8_0;
1039
+ let deferred8_1;
1040
+ try {
1041
+ const ptr0 = passStringToWasm0(signed_grant, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1042
+ const len0 = WASM_VECTOR_LEN;
1043
+ const ptr1 = passStringToWasm0(key_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1044
+ const len1 = WASM_VECTOR_LEN;
1045
+ const ptr2 = passStringToWasm0(verification_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1046
+ const len2 = WASM_VECTOR_LEN;
1047
+ const ptr3 = passStringToWasm0(request, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1048
+ const len3 = WASM_VECTOR_LEN;
1049
+ const ptr4 = passStringToWasm0(grant_chain, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1050
+ const len4 = WASM_VECTOR_LEN;
1051
+ const ptr5 = passStringToWasm0(revocations, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1052
+ const len5 = WASM_VECTOR_LEN;
1053
+ const ret = wasm.authorize_offline(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, ptr5, len5);
1054
+ var ptr7 = ret[0];
1055
+ var len7 = ret[1];
1056
+ if (ret[3]) {
1057
+ ptr7 = 0; len7 = 0;
1058
+ throw takeFromExternrefTable0(ret[2]);
1059
+ }
1060
+ deferred8_0 = ptr7;
1061
+ deferred8_1 = len7;
1062
+ return getStringFromWasm0(ptr7, len7);
1063
+ } finally {
1064
+ wasm.__wbindgen_free(deferred8_0, deferred8_1, 1);
1065
+ }
1066
+ }
1067
+
1068
+ /**
1069
+ * @param {string} bundle_json
1070
+ * @returns {string}
1071
+ */
1072
+ export function canonical_bundle_hash(bundle_json) {
1073
+ let deferred3_0;
1074
+ let deferred3_1;
1075
+ try {
1076
+ const ptr0 = passStringToWasm0(bundle_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1077
+ const len0 = WASM_VECTOR_LEN;
1078
+ const ret = wasm.canonical_bundle_hash(ptr0, len0);
1079
+ var ptr2 = ret[0];
1080
+ var len2 = ret[1];
1081
+ if (ret[3]) {
1082
+ ptr2 = 0; len2 = 0;
1083
+ throw takeFromExternrefTable0(ret[2]);
1084
+ }
1085
+ deferred3_0 = ptr2;
1086
+ deferred3_1 = len2;
1087
+ return getStringFromWasm0(ptr2, len2);
1088
+ } finally {
1089
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
1090
+ }
1091
+ }
1092
+
1093
+ /**
1094
+ * Canonicalizes a typed application manifest using the same Rust implementation
1095
+ * used by the server. JavaScript never defines revision identity independently.
1096
+ * @param {string} input
1097
+ * @returns {string}
1098
+ */
1099
+ export function canonicalize_application_manifest(input) {
1100
+ let deferred3_0;
1101
+ let deferred3_1;
1102
+ try {
1103
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1104
+ const len0 = WASM_VECTOR_LEN;
1105
+ const ret = wasm.canonicalize_application_manifest(ptr0, len0);
1106
+ var ptr2 = ret[0];
1107
+ var len2 = ret[1];
1108
+ if (ret[3]) {
1109
+ ptr2 = 0; len2 = 0;
1110
+ throw takeFromExternrefTable0(ret[2]);
1111
+ }
1112
+ deferred3_0 = ptr2;
1113
+ deferred3_1 = len2;
1114
+ return getStringFromWasm0(ptr2, len2);
1115
+ } finally {
1116
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
1117
+ }
1118
+ }
1119
+
1120
+ /**
1121
+ * @param {string} before
1122
+ * @param {string} after
1123
+ * @returns {string}
1124
+ */
1125
+ export function compare_state_schemas(before, after) {
1126
+ let deferred4_0;
1127
+ let deferred4_1;
1128
+ try {
1129
+ const ptr0 = passStringToWasm0(before, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1130
+ const len0 = WASM_VECTOR_LEN;
1131
+ const ptr1 = passStringToWasm0(after, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1132
+ const len1 = WASM_VECTOR_LEN;
1133
+ const ret = wasm.compare_state_schemas(ptr0, len0, ptr1, len1);
1134
+ var ptr3 = ret[0];
1135
+ var len3 = ret[1];
1136
+ if (ret[3]) {
1137
+ ptr3 = 0; len3 = 0;
1138
+ throw takeFromExternrefTable0(ret[2]);
1139
+ }
1140
+ deferred4_0 = ptr3;
1141
+ deferred4_1 = len3;
1142
+ return getStringFromWasm0(ptr3, len3);
1143
+ } finally {
1144
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
1145
+ }
1146
+ }
1147
+
1148
+ /**
1149
+ * @param {string | null | undefined} from
1150
+ * @param {string} to
1151
+ * @returns {string}
1152
+ */
1153
+ export function diff_application_revisions(from, to) {
1154
+ let deferred4_0;
1155
+ let deferred4_1;
1156
+ try {
1157
+ var ptr0 = isLikeNone(from) ? 0 : passStringToWasm0(from, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1158
+ var len0 = WASM_VECTOR_LEN;
1159
+ const ptr1 = passStringToWasm0(to, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1160
+ const len1 = WASM_VECTOR_LEN;
1161
+ const ret = wasm.diff_application_revisions(ptr0, len0, ptr1, len1);
1162
+ var ptr3 = ret[0];
1163
+ var len3 = ret[1];
1164
+ if (ret[3]) {
1165
+ ptr3 = 0; len3 = 0;
1166
+ throw takeFromExternrefTable0(ret[2]);
1167
+ }
1168
+ deferred4_0 = ptr3;
1169
+ deferred4_1 = len3;
1170
+ return getStringFromWasm0(ptr3, len3);
1171
+ } finally {
1172
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
1173
+ }
1174
+ }
1175
+
1176
+ /**
1177
+ * @param {string} input
1178
+ * @returns {string}
1179
+ */
1180
+ export function hash_application_manifest(input) {
1181
+ let deferred3_0;
1182
+ let deferred3_1;
1183
+ try {
1184
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1185
+ const len0 = WASM_VECTOR_LEN;
1186
+ const ret = wasm.hash_application_manifest(ptr0, len0);
1187
+ var ptr2 = ret[0];
1188
+ var len2 = ret[1];
1189
+ if (ret[3]) {
1190
+ ptr2 = 0; len2 = 0;
1191
+ throw takeFromExternrefTable0(ret[2]);
1192
+ }
1193
+ deferred3_0 = ptr2;
1194
+ deferred3_1 = len2;
1195
+ return getStringFromWasm0(ptr2, len2);
1196
+ } finally {
1197
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
1198
+ }
1199
+ }
1200
+
1201
+ /**
1202
+ * @param {string} revision
1203
+ * @param {string} environment
1204
+ * @returns {string}
1205
+ */
1206
+ export function hash_application_runtime(revision, environment) {
1207
+ let deferred4_0;
1208
+ let deferred4_1;
1209
+ try {
1210
+ const ptr0 = passStringToWasm0(revision, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1211
+ const len0 = WASM_VECTOR_LEN;
1212
+ const ptr1 = passStringToWasm0(environment, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1213
+ const len1 = WASM_VECTOR_LEN;
1214
+ const ret = wasm.hash_application_runtime(ptr0, len0, ptr1, len1);
1215
+ var ptr3 = ret[0];
1216
+ var len3 = ret[1];
1217
+ if (ret[3]) {
1218
+ ptr3 = 0; len3 = 0;
1219
+ throw takeFromExternrefTable0(ret[2]);
1220
+ }
1221
+ deferred4_0 = ptr3;
1222
+ deferred4_1 = len3;
1223
+ return getStringFromWasm0(ptr3, len3);
1224
+ } finally {
1225
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
1226
+ }
1227
+ }
1228
+
1229
+ /**
1230
+ * @param {string} schema
1231
+ * @returns {string}
1232
+ */
1233
+ export function hash_state_schema(schema) {
1234
+ let deferred3_0;
1235
+ let deferred3_1;
1236
+ try {
1237
+ const ptr0 = passStringToWasm0(schema, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1238
+ const len0 = WASM_VECTOR_LEN;
1239
+ const ret = wasm.hash_state_schema(ptr0, len0);
1240
+ var ptr2 = ret[0];
1241
+ var len2 = ret[1];
1242
+ if (ret[3]) {
1243
+ ptr2 = 0; len2 = 0;
1244
+ throw takeFromExternrefTable0(ret[2]);
1245
+ }
1246
+ deferred3_0 = ptr2;
1247
+ deferred3_1 = len2;
1248
+ return getStringFromWasm0(ptr2, len2);
1249
+ } finally {
1250
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
1251
+ }
1252
+ }
1253
+
1254
+ /**
1255
+ * Opens or creates a FeltDB database
1256
+ *
1257
+ * # Arguments
1258
+ * * `path` - Path to the database file
1259
+ *
1260
+ * # Returns
1261
+ * JsDb instance or error
1262
+ * @param {string} path
1263
+ * @returns {JsDb}
1264
+ */
1265
+ export function open(path) {
1266
+ const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1267
+ const len0 = WASM_VECTOR_LEN;
1268
+ const ret = wasm.open(ptr0, len0);
1269
+ if (ret[2]) {
1270
+ throw takeFromExternrefTable0(ret[1]);
1271
+ }
1272
+ return JsDb.__wrap(ret[0]);
1273
+ }
1274
+
1275
+ /**
1276
+ * @param {string} revision
1277
+ * @param {string} environment
1278
+ * @returns {string}
1279
+ */
1280
+ export function resolve_application_runtime(revision, environment) {
1281
+ let deferred4_0;
1282
+ let deferred4_1;
1283
+ try {
1284
+ const ptr0 = passStringToWasm0(revision, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1285
+ const len0 = WASM_VECTOR_LEN;
1286
+ const ptr1 = passStringToWasm0(environment, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1287
+ const len1 = WASM_VECTOR_LEN;
1288
+ const ret = wasm.resolve_application_runtime(ptr0, len0, ptr1, len1);
1289
+ var ptr3 = ret[0];
1290
+ var len3 = ret[1];
1291
+ if (ret[3]) {
1292
+ ptr3 = 0; len3 = 0;
1293
+ throw takeFromExternrefTable0(ret[2]);
1294
+ }
1295
+ deferred4_0 = ptr3;
1296
+ deferred4_1 = len3;
1297
+ return getStringFromWasm0(ptr3, len3);
1298
+ } finally {
1299
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
1300
+ }
1301
+ }
1302
+
1303
+ /**
1304
+ * @param {string} claim
1305
+ * @param {string} worker
1306
+ * @param {string} workload
1307
+ * @param {bigint} now
1308
+ */
1309
+ export function validate_mesh_claim(claim, worker, workload, now) {
1310
+ const ptr0 = passStringToWasm0(claim, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1311
+ const len0 = WASM_VECTOR_LEN;
1312
+ const ptr1 = passStringToWasm0(worker, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1313
+ const len1 = WASM_VECTOR_LEN;
1314
+ const ptr2 = passStringToWasm0(workload, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1315
+ const len2 = WASM_VECTOR_LEN;
1316
+ const ret = wasm.validate_mesh_claim(ptr0, len0, ptr1, len1, ptr2, len2, now);
1317
+ if (ret[1]) {
1318
+ throw takeFromExternrefTable0(ret[0]);
1319
+ }
1320
+ }
1321
+
1322
+ /**
1323
+ * @param {string} schema
1324
+ * @returns {string}
1325
+ */
1326
+ export function validate_state_schema(schema) {
1327
+ let deferred3_0;
1328
+ let deferred3_1;
1329
+ try {
1330
+ const ptr0 = passStringToWasm0(schema, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1331
+ const len0 = WASM_VECTOR_LEN;
1332
+ const ret = wasm.validate_state_schema(ptr0, len0);
1333
+ var ptr2 = ret[0];
1334
+ var len2 = ret[1];
1335
+ if (ret[3]) {
1336
+ ptr2 = 0; len2 = 0;
1337
+ throw takeFromExternrefTable0(ret[2]);
1338
+ }
1339
+ deferred3_0 = ptr2;
1340
+ deferred3_1 = len2;
1341
+ return getStringFromWasm0(ptr2, len2);
1342
+ } finally {
1343
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
1344
+ }
1345
+ }
1346
+
1347
+ /**
1348
+ * @param {string} operation
1349
+ * @returns {string}
1350
+ */
1351
+ export function validate_sync_operation(operation) {
1352
+ let deferred3_0;
1353
+ let deferred3_1;
1354
+ try {
1355
+ const ptr0 = passStringToWasm0(operation, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1356
+ const len0 = WASM_VECTOR_LEN;
1357
+ const ret = wasm.validate_sync_operation(ptr0, len0);
1358
+ var ptr2 = ret[0];
1359
+ var len2 = ret[1];
1360
+ if (ret[3]) {
1361
+ ptr2 = 0; len2 = 0;
1362
+ throw takeFromExternrefTable0(ret[2]);
1363
+ }
1364
+ deferred3_0 = ptr2;
1365
+ deferred3_1 = len2;
1366
+ return getStringFromWasm0(ptr2, len2);
1367
+ } finally {
1368
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
1369
+ }
1370
+ }
1371
+
1372
+ /**
1373
+ * @param {string} from
1374
+ * @param {string} to
1375
+ * @returns {boolean}
1376
+ */
1377
+ export function validate_worker_transition(from, to) {
1378
+ const ptr0 = passStringToWasm0(from, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1379
+ const len0 = WASM_VECTOR_LEN;
1380
+ const ptr1 = passStringToWasm0(to, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1381
+ const len1 = WASM_VECTOR_LEN;
1382
+ const ret = wasm.validate_worker_transition(ptr0, len0, ptr1, len1);
1383
+ if (ret[2]) {
1384
+ throw takeFromExternrefTable0(ret[1]);
1385
+ }
1386
+ return ret[0] !== 0;
1387
+ }
1388
+
1389
+ /**
1390
+ * @param {string} from
1391
+ * @param {string} to
1392
+ * @returns {boolean}
1393
+ */
1394
+ export function validate_workload_transition(from, to) {
1395
+ const ptr0 = passStringToWasm0(from, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1396
+ const len0 = WASM_VECTOR_LEN;
1397
+ const ptr1 = passStringToWasm0(to, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1398
+ const len1 = WASM_VECTOR_LEN;
1399
+ const ret = wasm.validate_workload_transition(ptr0, len0, ptr1, len1);
1400
+ if (ret[2]) {
1401
+ throw takeFromExternrefTable0(ret[1]);
1402
+ }
1403
+ return ret[0] !== 0;
1404
+ }
1405
+
1406
+ /**
1407
+ * @param {string} bundle_json
1408
+ * @returns {boolean}
1409
+ */
1410
+ export function verify_bundle_integrity(bundle_json) {
1411
+ const ptr0 = passStringToWasm0(bundle_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1412
+ const len0 = WASM_VECTOR_LEN;
1413
+ const ret = wasm.verify_bundle_integrity(ptr0, len0);
1414
+ if (ret[2]) {
1415
+ throw takeFromExternrefTable0(ret[1]);
1416
+ }
1417
+ return ret[0] !== 0;
1418
+ }
1419
+
1420
+ /**
1421
+ * Verify a portable signed grant with the exact Rust canonicalization used by
1422
+ * the server. The verification key is provisioned with the offline app shell.
1423
+ * @param {string} signed_grant
1424
+ * @param {string} key_id
1425
+ * @param {string} verification_key
1426
+ * @param {string} request
1427
+ * @param {string} grant_chain
1428
+ * @param {string} revocations
1429
+ * @returns {string}
1430
+ */
1431
+ export function verify_signed_grant(signed_grant, key_id, verification_key, request, grant_chain, revocations) {
1432
+ let deferred8_0;
1433
+ let deferred8_1;
1434
+ try {
1435
+ const ptr0 = passStringToWasm0(signed_grant, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1436
+ const len0 = WASM_VECTOR_LEN;
1437
+ const ptr1 = passStringToWasm0(key_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1438
+ const len1 = WASM_VECTOR_LEN;
1439
+ const ptr2 = passStringToWasm0(verification_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1440
+ const len2 = WASM_VECTOR_LEN;
1441
+ const ptr3 = passStringToWasm0(request, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1442
+ const len3 = WASM_VECTOR_LEN;
1443
+ const ptr4 = passStringToWasm0(grant_chain, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1444
+ const len4 = WASM_VECTOR_LEN;
1445
+ const ptr5 = passStringToWasm0(revocations, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1446
+ const len5 = WASM_VECTOR_LEN;
1447
+ const ret = wasm.verify_signed_grant(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, ptr5, len5);
1448
+ var ptr7 = ret[0];
1449
+ var len7 = ret[1];
1450
+ if (ret[3]) {
1451
+ ptr7 = 0; len7 = 0;
1452
+ throw takeFromExternrefTable0(ret[2]);
1453
+ }
1454
+ deferred8_0 = ptr7;
1455
+ deferred8_1 = len7;
1456
+ return getStringFromWasm0(ptr7, len7);
1457
+ } finally {
1458
+ wasm.__wbindgen_free(deferred8_0, deferred8_1, 1);
1459
+ }
1460
+ }
1461
+ function __wbg_get_imports() {
1462
+ const import0 = {
1463
+ __proto__: null,
1464
+ __wbg___wbindgen_throw_bb96b2010945f0bc: function(arg0, arg1) {
1465
+ throw new Error(getStringFromWasm0(arg0, arg1));
1466
+ },
1467
+ __wbindgen_cast_0000000000000001: function(arg0, arg1) {
1468
+ // Cast intrinsic for `Ref(String) -> Externref`.
1469
+ const ret = getStringFromWasm0(arg0, arg1);
1470
+ return ret;
1471
+ },
1472
+ __wbindgen_init_externref_table: function() {
1473
+ const table = wasm.__wbindgen_externrefs;
1474
+ const offset = table.grow(4);
1475
+ table.set(0, undefined);
1476
+ table.set(offset + 0, undefined);
1477
+ table.set(offset + 1, null);
1478
+ table.set(offset + 2, true);
1479
+ table.set(offset + 3, false);
1480
+ },
1481
+ };
1482
+ return {
1483
+ __proto__: null,
1484
+ "./feltdb_wasm_bg.js": import0,
1485
+ };
1486
+ }
1487
+
1488
+ const JsDbFinalization = (typeof FinalizationRegistry === 'undefined')
1489
+ ? { register: () => {}, unregister: () => {} }
1490
+ : new FinalizationRegistry(ptr => wasm.__wbg_jsdb_free(ptr, 1));
1491
+ const JsResultFinalization = (typeof FinalizationRegistry === 'undefined')
1492
+ ? { register: () => {}, unregister: () => {} }
1493
+ : new FinalizationRegistry(ptr => wasm.__wbg_jsresult_free(ptr, 1));
1494
+ const WasmAnalyticsFinalization = (typeof FinalizationRegistry === 'undefined')
1495
+ ? { register: () => {}, unregister: () => {} }
1496
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmanalytics_free(ptr, 1));
1497
+ const WasmDistributedIndexManagerFinalization = (typeof FinalizationRegistry === 'undefined')
1498
+ ? { register: () => {}, unregister: () => {} }
1499
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmdistributedindexmanager_free(ptr, 1));
1500
+ const WasmIndexManagerFinalization = (typeof FinalizationRegistry === 'undefined')
1501
+ ? { register: () => {}, unregister: () => {} }
1502
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmindexmanager_free(ptr, 1));
1503
+ const WasmShardManagerFinalization = (typeof FinalizationRegistry === 'undefined')
1504
+ ? { register: () => {}, unregister: () => {} }
1505
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmshardmanager_free(ptr, 1));
1506
+
1507
+ function getStringFromWasm0(ptr, len) {
1508
+ return decodeText(ptr >>> 0, len);
1509
+ }
1510
+
1511
+ let cachedUint8ArrayMemory0 = null;
1512
+ function getUint8ArrayMemory0() {
1513
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
1514
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
1515
+ }
1516
+ return cachedUint8ArrayMemory0;
1517
+ }
1518
+
1519
+ function isLikeNone(x) {
1520
+ return x === undefined || x === null;
1521
+ }
1522
+
1523
+ function passStringToWasm0(arg, malloc, realloc) {
1524
+ if (realloc === undefined) {
1525
+ const buf = cachedTextEncoder.encode(arg);
1526
+ const ptr = malloc(buf.length, 1) >>> 0;
1527
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
1528
+ WASM_VECTOR_LEN = buf.length;
1529
+ return ptr;
1530
+ }
1531
+
1532
+ let len = arg.length;
1533
+ let ptr = malloc(len, 1) >>> 0;
1534
+
1535
+ const mem = getUint8ArrayMemory0();
1536
+
1537
+ let offset = 0;
1538
+
1539
+ for (; offset < len; offset++) {
1540
+ const code = arg.charCodeAt(offset);
1541
+ if (code > 0x7F) break;
1542
+ mem[ptr + offset] = code;
1543
+ }
1544
+ if (offset !== len) {
1545
+ if (offset !== 0) {
1546
+ arg = arg.slice(offset);
1547
+ }
1548
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
1549
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
1550
+ const ret = cachedTextEncoder.encodeInto(arg, view);
1551
+
1552
+ offset += ret.written;
1553
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
1554
+ }
1555
+
1556
+ WASM_VECTOR_LEN = offset;
1557
+ return ptr;
1558
+ }
1559
+
1560
+ function takeFromExternrefTable0(idx) {
1561
+ const value = wasm.__wbindgen_externrefs.get(idx);
1562
+ wasm.__externref_table_dealloc(idx);
1563
+ return value;
1564
+ }
1565
+
1566
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
1567
+ cachedTextDecoder.decode();
1568
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
1569
+ let numBytesDecoded = 0;
1570
+ function decodeText(ptr, len) {
1571
+ numBytesDecoded += len;
1572
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
1573
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
1574
+ cachedTextDecoder.decode();
1575
+ numBytesDecoded = len;
1576
+ }
1577
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
1578
+ }
1579
+
1580
+ const cachedTextEncoder = new TextEncoder();
1581
+
1582
+ if (!('encodeInto' in cachedTextEncoder)) {
1583
+ cachedTextEncoder.encodeInto = function (arg, view) {
1584
+ const buf = cachedTextEncoder.encode(arg);
1585
+ view.set(buf);
1586
+ return {
1587
+ read: arg.length,
1588
+ written: buf.length
1589
+ };
1590
+ };
1591
+ }
1592
+
1593
+ let WASM_VECTOR_LEN = 0;
1594
+
1595
+ let wasmModule, wasmInstance, wasm;
1596
+ function __wbg_finalize_init(instance, module) {
1597
+ wasmInstance = instance;
1598
+ wasm = instance.exports;
1599
+ wasmModule = module;
1600
+ cachedUint8ArrayMemory0 = null;
1601
+ wasm.__wbindgen_start();
1602
+ return wasm;
1603
+ }
1604
+
1605
+ async function __wbg_load(module, imports) {
1606
+ if (typeof Response === 'function' && module instanceof Response) {
1607
+ if (!module.ok) {
1608
+ throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
1609
+ }
1610
+
1611
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
1612
+ try {
1613
+ return await WebAssembly.instantiateStreaming(module, imports);
1614
+ } catch (e) {
1615
+ const validResponse = expectedResponseType(module.type);
1616
+
1617
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
1618
+ 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);
1619
+
1620
+ } else { throw e; }
1621
+ }
1622
+ }
1623
+
1624
+ const bytes = await module.arrayBuffer();
1625
+ return await WebAssembly.instantiate(bytes, imports);
1626
+ } else {
1627
+ const instance = await WebAssembly.instantiate(module, imports);
1628
+
1629
+ if (instance instanceof WebAssembly.Instance) {
1630
+ return { instance, module };
1631
+ } else {
1632
+ return instance;
1633
+ }
1634
+ }
1635
+
1636
+ function expectedResponseType(type) {
1637
+ switch (type) {
1638
+ case 'basic': case 'cors': case 'default': return true;
1639
+ }
1640
+ return false;
1641
+ }
1642
+ }
1643
+
1644
+ function initSync(module) {
1645
+ if (wasm !== undefined) return wasm;
1646
+
1647
+
1648
+ if (module !== undefined) {
1649
+ if (Object.getPrototypeOf(module) === Object.prototype) {
1650
+ ({module} = module)
1651
+ } else {
1652
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
1653
+ }
1654
+ }
1655
+
1656
+ const imports = __wbg_get_imports();
1657
+ if (!(module instanceof WebAssembly.Module)) {
1658
+ module = new WebAssembly.Module(module);
1659
+ }
1660
+ const instance = new WebAssembly.Instance(module, imports);
1661
+ return __wbg_finalize_init(instance, module);
1662
+ }
1663
+
1664
+ async function __wbg_init(module_or_path) {
1665
+ if (wasm !== undefined) return wasm;
1666
+
1667
+
1668
+ if (module_or_path !== undefined) {
1669
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
1670
+ ({module_or_path} = module_or_path)
1671
+ } else {
1672
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
1673
+ }
1674
+ }
1675
+
1676
+ if (module_or_path === undefined) {
1677
+ module_or_path = new URL('feltdb_wasm_bg.wasm', import.meta.url);
1678
+ }
1679
+ const imports = __wbg_get_imports();
1680
+
1681
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
1682
+ module_or_path = fetch(module_or_path);
1683
+ }
1684
+
1685
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
1686
+
1687
+ return __wbg_finalize_init(instance, module);
1688
+ }
1689
+
1690
+ export { initSync, __wbg_init as default };