@loradb/lora-wasm 0.5.6 → 0.8.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.
Files changed (45) hide show
  1. package/README.md +76 -34
  2. package/dist/decode.d.ts +29 -0
  3. package/dist/decode.d.ts.map +1 -0
  4. package/dist/decode.js +338 -0
  5. package/dist/decode.js.map +1 -0
  6. package/dist/index.d.ts +21 -31
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +35 -37
  9. package/dist/index.js.map +1 -1
  10. package/dist/loader-node.d.ts +1 -1
  11. package/dist/snapshot.d.ts +49 -16
  12. package/dist/snapshot.d.ts.map +1 -1
  13. package/dist/snapshot.js +36 -54
  14. package/dist/snapshot.js.map +1 -1
  15. package/dist/types.d.ts +81 -7
  16. package/dist/types.d.ts.map +1 -1
  17. package/dist/types.js +10 -2
  18. package/dist/types.js.map +1 -1
  19. package/dist/worker-client.d.ts +20 -20
  20. package/dist/worker-client.d.ts.map +1 -1
  21. package/dist/worker-client.js +32 -22
  22. package/dist/worker-client.js.map +1 -1
  23. package/dist/worker-protocol.d.ts +5 -2
  24. package/dist/worker-protocol.d.ts.map +1 -1
  25. package/dist/worker.js +18 -10
  26. package/dist/worker.js.map +1 -1
  27. package/package.json +5 -5
  28. package/pkg-bundler/README.md +76 -34
  29. package/pkg-bundler/lora_wasm.d.ts +37 -10
  30. package/pkg-bundler/lora_wasm_bg.js +173 -26
  31. package/pkg-bundler/lora_wasm_bg.wasm +0 -0
  32. package/pkg-bundler/lora_wasm_bg.wasm.d.ts +5 -2
  33. package/pkg-bundler/package.json +1 -1
  34. package/pkg-node/README.md +76 -34
  35. package/pkg-node/lora_wasm.d.ts +37 -10
  36. package/pkg-node/lora_wasm.js +173 -26
  37. package/pkg-node/lora_wasm_bg.wasm +0 -0
  38. package/pkg-node/lora_wasm_bg.wasm.d.ts +5 -2
  39. package/pkg-node/package.json +1 -1
  40. package/pkg-web/README.md +76 -34
  41. package/pkg-web/lora_wasm.d.ts +42 -12
  42. package/pkg-web/lora_wasm.js +156 -26
  43. package/pkg-web/lora_wasm_bg.wasm +0 -0
  44. package/pkg-web/lora_wasm_bg.wasm.d.ts +5 -2
  45. package/pkg-web/package.json +1 -1
@@ -173,17 +173,17 @@ function takeFromExternrefTable0(idx) {
173
173
  return value;
174
174
  }
175
175
 
176
- function getArrayU8FromWasm0(ptr, len) {
177
- ptr = ptr >>> 0;
178
- return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
179
- }
180
-
181
176
  function passArray8ToWasm0(arg, malloc) {
182
177
  const ptr = malloc(arg.length * 1, 1) >>> 0;
183
178
  getUint8ArrayMemory0().set(arg, ptr / 1);
184
179
  WASM_VECTOR_LEN = arg.length;
185
180
  return ptr;
186
181
  }
182
+
183
+ function getArrayU8FromWasm0(ptr, len) {
184
+ ptr = ptr >>> 0;
185
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
186
+ }
187
187
  /**
188
188
  * Call once at module start to install a panic hook that routes Rust
189
189
  * panics to `console.error`. No-op if compiled without the default feature.
@@ -251,23 +251,37 @@ export class WasmDatabase {
251
251
  return takeFromExternrefTable0(ret[0]);
252
252
  }
253
253
  /**
254
- * @returns {number}
254
+ * Replace the graph state with a database snapshot decoded from `bytes`.
255
+ * Legacy store snapshot bytes are accepted for compatibility.
256
+ *
257
+ * Returns a plain object matching the shape of `SnapshotMeta`:
258
+ * `{ formatVersion, nodeCount, relationshipCount, walLsn }`.
259
+ * @param {Uint8Array} bytes
260
+ * @param {any} options
261
+ * @returns {any}
255
262
  */
256
- relationshipCount() {
257
- const ret = wasm.wasmdatabase_relationshipCount(this.__wbg_ptr);
258
- return ret >>> 0;
263
+ loadSnapshot(bytes, options) {
264
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
265
+ const len0 = WASM_VECTOR_LEN;
266
+ const ret = wasm.wasmdatabase_loadSnapshot(this.__wbg_ptr, ptr0, len0, options);
267
+ if (ret[2]) {
268
+ throw takeFromExternrefTable0(ret[1]);
269
+ }
270
+ return takeFromExternrefTable0(ret[0]);
259
271
  }
260
272
  /**
261
- * Serialize the graph into a byte buffer. The caller is responsible for
262
- * writing it to disk, IndexedDB, localStorage, or wherever — WASM does
263
- * not have direct filesystem access. The returned bytes can later be
264
- * passed to `loadSnapshotFromBytes` on any `WasmDatabase` instance.
273
+ * Serialize the graph into database snapshot bytes. The caller is
274
+ * responsible for writing them to IndexedDB, localStorage, a server, or
275
+ * another host-provided store — WASM has no direct filesystem access.
276
+ * The returned bytes can later be passed to `loadSnapshot` on any
277
+ * `WasmDatabase` instance.
265
278
  *
266
279
  * Returns the serialized bytes as a `Uint8Array`.
280
+ * @param {any} options
267
281
  * @returns {Uint8Array}
268
282
  */
269
- saveSnapshotToBytes() {
270
- const ret = wasm.wasmdatabase_saveSnapshotToBytes(this.__wbg_ptr);
283
+ saveSnapshot(options) {
284
+ const ret = wasm.wasmdatabase_saveSnapshot(this.__wbg_ptr, options);
271
285
  if (ret[3]) {
272
286
  throw takeFromExternrefTable0(ret[2]);
273
287
  }
@@ -276,21 +290,34 @@ export class WasmDatabase {
276
290
  return v1;
277
291
  }
278
292
  /**
279
- * Replace the graph state with a snapshot decoded from `bytes`.
293
+ * Execute a Lora query and return the result as a binary buffer.
280
294
  *
281
- * Returns a plain object matching the shape of `SnapshotMeta`:
282
- * `{ formatVersion, nodeCount, relationshipCount, walLsn }`.
283
- * @param {Uint8Array} bytes
284
- * @returns {any}
295
+ * Wire format is the shared `lora_binding_buffer` layout. The TS
296
+ * wrapper decodes it once into the same `{ columns, rows }` shape
297
+ * `execute()` returns, but in a tight V8 loop instead of going
298
+ * through `serde_wasm_bindgen` value-by-value. Materially faster
299
+ * on bulk reads.
300
+ * @param {string} query
301
+ * @param {any} params
302
+ * @returns {Uint8Array}
285
303
  */
286
- loadSnapshotFromBytes(bytes) {
287
- const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
304
+ executeBuffer(query, params) {
305
+ const ptr0 = passStringToWasm0(query, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
288
306
  const len0 = WASM_VECTOR_LEN;
289
- const ret = wasm.wasmdatabase_loadSnapshotFromBytes(this.__wbg_ptr, ptr0, len0);
290
- if (ret[2]) {
291
- throw takeFromExternrefTable0(ret[1]);
307
+ const ret = wasm.wasmdatabase_executeBuffer(this.__wbg_ptr, ptr0, len0, params);
308
+ if (ret[3]) {
309
+ throw takeFromExternrefTable0(ret[2]);
292
310
  }
293
- return takeFromExternrefTable0(ret[0]);
311
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
312
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
313
+ return v2;
314
+ }
315
+ /**
316
+ * @returns {number}
317
+ */
318
+ relationshipCount() {
319
+ const ret = wasm.wasmdatabase_relationshipCount(this.__wbg_ptr);
320
+ return ret >>> 0;
294
321
  }
295
322
  constructor() {
296
323
  const ret = wasm.wasmdatabase_new();
@@ -320,6 +347,43 @@ export class WasmDatabase {
320
347
  }
321
348
  return takeFromExternrefTable0(ret[0]);
322
349
  }
350
+ /**
351
+ * Compile a query and return its plan without executing it.
352
+ *
353
+ * Mutating queries (CREATE / MERGE / SET / DELETE / REMOVE) leave
354
+ * the graph untouched — this method never runs the executor.
355
+ * @param {string} query
356
+ * @param {any} params
357
+ * @returns {any}
358
+ */
359
+ explain(query, params) {
360
+ const ptr0 = passStringToWasm0(query, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
361
+ const len0 = WASM_VECTOR_LEN;
362
+ const ret = wasm.wasmdatabase_explain(this.__wbg_ptr, ptr0, len0, params);
363
+ if (ret[2]) {
364
+ throw takeFromExternrefTable0(ret[1]);
365
+ }
366
+ return takeFromExternrefTable0(ret[0]);
367
+ }
368
+ /**
369
+ * Execute a query and return the plan plus runtime metrics.
370
+ *
371
+ * **PROFILE executes the query for real.** Mutating queries are
372
+ * persisted exactly as in `execute()`. Use `explain()` to inspect
373
+ * a mutating plan without running it.
374
+ * @param {string} query
375
+ * @param {any} params
376
+ * @returns {any}
377
+ */
378
+ profile(query, params) {
379
+ const ptr0 = passStringToWasm0(query, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
380
+ const len0 = WASM_VECTOR_LEN;
381
+ const ret = wasm.wasmdatabase_profile(this.__wbg_ptr, ptr0, len0, params);
382
+ if (ret[2]) {
383
+ throw takeFromExternrefTable0(ret[1]);
384
+ }
385
+ return takeFromExternrefTable0(ret[0]);
386
+ }
323
387
  }
324
388
 
325
389
  const WasmQueryStreamFinalization = (typeof FinalizationRegistry === 'undefined')
@@ -421,6 +485,14 @@ function __wbg_get_imports() {
421
485
  const ret = arg0.call(arg1);
422
486
  return ret;
423
487
  }, arguments) };
488
+ imports.wbg.__wbg_call_7cccdd69e0791ae2 = function() { return handleError(function (arg0, arg1, arg2) {
489
+ const ret = arg0.call(arg1, arg2);
490
+ return ret;
491
+ }, arguments) };
492
+ imports.wbg.__wbg_crypto_86f2631e91b51511 = function(arg0) {
493
+ const ret = arg0.crypto;
494
+ return ret;
495
+ };
424
496
  imports.wbg.__wbg_done_769e5ede4b31c67b = function(arg0) {
425
497
  const ret = arg0.done;
426
498
  return ret;
@@ -440,6 +512,9 @@ function __wbg_get_imports() {
440
512
  wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
441
513
  }
442
514
  };
515
+ imports.wbg.__wbg_getRandomValues_b3f15fcbfabb0f8b = function() { return handleError(function (arg0, arg1) {
516
+ arg0.getRandomValues(arg1);
517
+ }, arguments) };
443
518
  imports.wbg.__wbg_get_67b2ba62fc30de12 = function() { return handleError(function (arg0, arg1) {
444
519
  const ret = Reflect.get(arg0, arg1);
445
520
  return ret;
@@ -498,6 +573,10 @@ function __wbg_get_imports() {
498
573
  const ret = arg0.length;
499
574
  return ret;
500
575
  };
576
+ imports.wbg.__wbg_msCrypto_d562bbe83e0d4b91 = function(arg0) {
577
+ const ret = arg0.msCrypto;
578
+ return ret;
579
+ };
501
580
  imports.wbg.__wbg_new_405e22f390576ce2 = function() {
502
581
  const ret = new Object();
503
582
  return ret;
@@ -518,6 +597,18 @@ function __wbg_get_imports() {
518
597
  const ret = new Uint8Array(arg0);
519
598
  return ret;
520
599
  };
600
+ imports.wbg.__wbg_newnoargs_105ed471475aaf50 = function(arg0, arg1) {
601
+ const ret = new Function(getStringFromWasm0(arg0, arg1));
602
+ return ret;
603
+ };
604
+ imports.wbg.__wbg_newwithbyteoffsetandlength_d97e637ebe145a9a = function(arg0, arg1, arg2) {
605
+ const ret = new Uint8Array(arg0, arg1 >>> 0, arg2 >>> 0);
606
+ return ret;
607
+ };
608
+ imports.wbg.__wbg_newwithlength_a381634e90c276d4 = function(arg0) {
609
+ const ret = new Uint8Array(arg0 >>> 0);
610
+ return ret;
611
+ };
521
612
  imports.wbg.__wbg_next_25feadfc0913fea9 = function(arg0) {
522
613
  const ret = arg0.next;
523
614
  return ret;
@@ -526,10 +617,25 @@ function __wbg_get_imports() {
526
617
  const ret = arg0.next();
527
618
  return ret;
528
619
  }, arguments) };
620
+ imports.wbg.__wbg_node_e1f24f89a7336c2e = function(arg0) {
621
+ const ret = arg0.node;
622
+ return ret;
623
+ };
529
624
  imports.wbg.__wbg_now_807e54c39636c349 = function() {
530
625
  const ret = Date.now();
531
626
  return ret;
532
627
  };
628
+ imports.wbg.__wbg_process_3975fd6c72f520aa = function(arg0) {
629
+ const ret = arg0.process;
630
+ return ret;
631
+ };
632
+ imports.wbg.__wbg_randomFillSync_f8c153b79f285817 = function() { return handleError(function (arg0, arg1) {
633
+ arg0.randomFillSync(arg1);
634
+ }, arguments) };
635
+ imports.wbg.__wbg_require_b74f47fc2d022fd6 = function() { return handleError(function () {
636
+ const ret = module.require;
637
+ return ret;
638
+ }, arguments) };
533
639
  imports.wbg.__wbg_set_37837023f3d740e8 = function(arg0, arg1, arg2) {
534
640
  arg0[arg1 >>> 0] = arg2;
535
641
  };
@@ -550,10 +656,34 @@ function __wbg_get_imports() {
550
656
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
551
657
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
552
658
  };
659
+ imports.wbg.__wbg_static_accessor_GLOBAL_88a902d13a557d07 = function() {
660
+ const ret = typeof global === 'undefined' ? null : global;
661
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
662
+ };
663
+ imports.wbg.__wbg_static_accessor_GLOBAL_THIS_56578be7e9f832b0 = function() {
664
+ const ret = typeof globalThis === 'undefined' ? null : globalThis;
665
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
666
+ };
667
+ imports.wbg.__wbg_static_accessor_SELF_37c5d418e4bf5819 = function() {
668
+ const ret = typeof self === 'undefined' ? null : self;
669
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
670
+ };
671
+ imports.wbg.__wbg_static_accessor_WINDOW_5de37043a91a9c40 = function() {
672
+ const ret = typeof window === 'undefined' ? null : window;
673
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
674
+ };
675
+ imports.wbg.__wbg_subarray_aa9065fa9dc5df96 = function(arg0, arg1, arg2) {
676
+ const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
677
+ return ret;
678
+ };
553
679
  imports.wbg.__wbg_value_cd1ffa7b1ab794f1 = function(arg0) {
554
680
  const ret = arg0.value;
555
681
  return ret;
556
682
  };
683
+ imports.wbg.__wbg_versions_4e31226f5e8dc909 = function(arg0) {
684
+ const ret = arg0.versions;
685
+ return ret;
686
+ };
557
687
  imports.wbg.__wbindgen_bigint_from_i64 = function(arg0) {
558
688
  const ret = arg0;
559
689
  return ret;
Binary file
@@ -5,12 +5,15 @@ export const __wbg_wasmdatabase_free: (a: number, b: number) => void;
5
5
  export const __wbg_wasmquerystream_free: (a: number, b: number) => void;
6
6
  export const wasmdatabase_clear: (a: number) => void;
7
7
  export const wasmdatabase_execute: (a: number, b: number, c: number, d: any) => [number, number, number];
8
- export const wasmdatabase_loadSnapshotFromBytes: (a: number, b: number, c: number) => [number, number, number];
8
+ export const wasmdatabase_executeBuffer: (a: number, b: number, c: number, d: any) => [number, number, number, number];
9
+ export const wasmdatabase_explain: (a: number, b: number, c: number, d: any) => [number, number, number];
10
+ export const wasmdatabase_loadSnapshot: (a: number, b: number, c: number, d: any) => [number, number, number];
9
11
  export const wasmdatabase_new: () => number;
10
12
  export const wasmdatabase_nodeCount: (a: number) => number;
11
13
  export const wasmdatabase_openStream: (a: number, b: number, c: number, d: any) => [number, number, number];
14
+ export const wasmdatabase_profile: (a: number, b: number, c: number, d: any) => [number, number, number];
12
15
  export const wasmdatabase_relationshipCount: (a: number) => number;
13
- export const wasmdatabase_saveSnapshotToBytes: (a: number) => [number, number, number, number];
16
+ export const wasmdatabase_saveSnapshot: (a: number, b: any) => [number, number, number, number];
14
17
  export const wasmdatabase_transaction: (a: number, b: any, c: number, d: number) => [number, number, number];
15
18
  export const wasmquerystream_close: (a: number) => void;
16
19
  export const wasmquerystream_columns: (a: number) => [number, number, number];
@@ -5,7 +5,7 @@
5
5
  "LoraDB, Inc."
6
6
  ],
7
7
  "description": "WebAssembly bindings for the Lora in-memory graph database",
8
- "version": "0.5.6",
8
+ "version": "0.8.0",
9
9
  "license": "BUSL-1.1",
10
10
  "files": [
11
11
  "lora_wasm_bg.wasm",