@surrealdb/wasm-native 3.3.0-beta.2 → 3.3.0-beta.3

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/README.md CHANGED
@@ -63,10 +63,39 @@ engine.free();
63
63
  | `init` | Instantiates the module; must resolve before anything else is called |
64
64
  | `SurrealWasmEngine` | One embedded instance: `connect`, `execute`, `notifications`, `export`, `import`, `version`, `free` |
65
65
  | `ConnectionOptions` | Capabilities, timeouts, and the namespace/database created on new storage |
66
+ | `./module` | The `.wasm` file itself, for a caller that resolves the module source itself |
66
67
 
67
68
  Storage backends are selected by the endpoint: `mem://` and `indxdb://name`, the latter backed by
68
69
  the browser's IndexedDB.
69
70
 
71
+ ### Where `init` reads the module from
72
+
73
+ `init()` with no argument resolves `index_bg.wasm` against the loader's own URL, which is right
74
+ only while the loader and the module sit beside each other. A bundler that copies the loader
75
+ elsewhere — Vite's dependency pre-bundling moves it into `node_modules/.vite/deps/` — leaves the
76
+ fetch pointing at a path the dev server answers with its HTML fallback, and instantiation fails on
77
+ the bytes not being a module (`expected magic word 00 61 73 6d, found 3c 21 64 6f`, which is
78
+ `<!do`).
79
+
80
+ `init` therefore accepts an explicit module source, and this package exports the `.wasm` under
81
+ `./module` so a caller can own the resolution rather than inherit the loader's location:
82
+
83
+ ```ts
84
+ import init from "@surrealdb/wasm-native";
85
+ import wasmUrl from "@surrealdb/wasm-native/module?url";
86
+
87
+ await init({ module_or_path: wasmUrl });
88
+ ```
89
+
90
+ Both are part of this package's surface and will keep working: the argument form is wasm-bindgen's
91
+ own `--target web` entry point, and `./module` is a subpath export declared here. Leaving the loader
92
+ where it was put works too, with Vite:
93
+
94
+ ```ts
95
+ // vite.config.ts
96
+ optimizeDeps: { exclude: ["@surrealdb/wasm", "@surrealdb/wasm-native"] }
97
+ ```
98
+
70
99
  A reply is the method's value; only a failure is wrapped, in an `{ error }` envelope.
71
100
  `notifications()` returns a `ReadableStream` of encoded live-query notifications, which ends when
72
101
  the engine is freed. Every instance must be released with `free()`.
package/dist/index.d.ts CHANGED
@@ -141,11 +141,11 @@ export interface InitOutput {
141
141
  readonly intounderlyingsink_write: (a: number, b: number) => number;
142
142
  readonly intounderlyingsource_cancel: (a: number) => void;
143
143
  readonly intounderlyingsource_pull: (a: number, b: number) => number;
144
- readonly __wasm_bindgen_func_elem_27714: (a: number, b: number, c: number, d: number) => void;
145
- readonly __wasm_bindgen_func_elem_4266: (a: number, b: number, c: number, d: number) => void;
146
- readonly __wasm_bindgen_func_elem_27715: (a: number, b: number, c: number, d: number) => void;
147
- readonly __wasm_bindgen_func_elem_4339: (a: number, b: number, c: number, d: number) => void;
148
- readonly __wasm_bindgen_func_elem_7486: (a: number, b: number) => void;
144
+ readonly __wasm_bindgen_func_elem_27670: (a: number, b: number, c: number, d: number) => void;
145
+ readonly __wasm_bindgen_func_elem_4272: (a: number, b: number, c: number, d: number) => void;
146
+ readonly __wasm_bindgen_func_elem_27668: (a: number, b: number, c: number, d: number) => void;
147
+ readonly __wasm_bindgen_func_elem_4345: (a: number, b: number, c: number, d: number) => void;
148
+ readonly __wasm_bindgen_func_elem_7494: (a: number, b: number) => void;
149
149
  readonly __wbindgen_export: (a: number, b: number) => number;
150
150
  readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
151
151
  readonly __wbindgen_export3: (a: number) => void;
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /* @ts-self-types="./index.d.ts" */
2
- import { open, to_string } from './snippets/surrealdb-kvs-indxdb-9b92279ac8b54d3a/src/js/db.js';
2
+ import { open, to_string } from './snippets/surrealdb-kvs-indxdb-4dc16250e3190622/src/js/db.js';
3
3
 
4
4
 
5
5
  export class IntoUnderlyingByteSource {
@@ -360,7 +360,7 @@ function __wbg_get_imports() {
360
360
  const ret = getObject(arg0).arrayBuffer();
361
361
  return addHeapObject(ret);
362
362
  }, arguments); },
363
- __wbg_begin_49cec06256103510: function() { return handleError(function (arg0) {
363
+ __wbg_begin_e3594ac63cd2b2e5: function() { return handleError(function (arg0) {
364
364
  const ret = getObject(arg0).begin();
365
365
  return addHeapObject(ret);
366
366
  }, arguments); },
@@ -395,13 +395,13 @@ function __wbg_get_imports() {
395
395
  __wbg_close_249a23304523681b: function() { return handleError(function (arg0) {
396
396
  getObject(arg0).close();
397
397
  }, arguments); },
398
- __wbg_close_38243faabaebb5d7: function() { return handleError(function (arg0) {
398
+ __wbg_close_72d318d9c16e83ef: function() { return handleError(function (arg0) {
399
399
  getObject(arg0).close();
400
400
  }, arguments); },
401
- __wbg_close_72d318d9c16e83ef: function() { return handleError(function (arg0) {
401
+ __wbg_close_e431942a95b59335: function() { return handleError(function (arg0) {
402
402
  getObject(arg0).close();
403
403
  }, arguments); },
404
- __wbg_commit_2156a298112a34d5: function(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14) {
404
+ __wbg_commit_c79b56849637d2ca: function(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14) {
405
405
  const ret = getObject(arg0).commit(getArrayU8FromWasm0(arg1, arg2), getArrayU32FromWasm0(arg3, arg4), getArrayU8FromWasm0(arg5, arg6), getArrayU32FromWasm0(arg7, arg8), getArrayU8FromWasm0(arg9, arg10), getArrayU32FromWasm0(arg11, arg12), getArrayU8FromWasm0(arg13, arg14));
406
406
  return addHeapObject(ret);
407
407
  },
@@ -473,7 +473,7 @@ function __wbg_get_imports() {
473
473
  const ret = Reflect.has(getObject(arg0), getObject(arg1));
474
474
  return ret;
475
475
  }, arguments); },
476
- __wbg_has_84f877379062e2b1: function(arg0, arg1, arg2) {
476
+ __wbg_has_a7ab29ab80428287: function(arg0, arg1, arg2) {
477
477
  const ret = getObject(arg0).has(getArrayU8FromWasm0(arg1, arg2));
478
478
  return addHeapObject(ret);
479
479
  },
@@ -533,11 +533,11 @@ function __wbg_get_imports() {
533
533
  const ret = Symbol.iterator;
534
534
  return addHeapObject(ret);
535
535
  },
536
- __wbg_keyEnds_878911a29ac779a5: function(arg0) {
536
+ __wbg_keyEnds_f5754a2fb464d0b7: function(arg0) {
537
537
  const ret = getObject(arg0).keyEnds;
538
538
  return addHeapObject(ret);
539
539
  },
540
- __wbg_keys_338039d0484a34dd: function(arg0) {
540
+ __wbg_keys_db719abaf17d49a0: function(arg0) {
541
541
  const ret = getObject(arg0).keys;
542
542
  return addHeapObject(ret);
543
543
  },
@@ -604,7 +604,7 @@ function __wbg_get_imports() {
604
604
  const a = state0.a;
605
605
  state0.a = 0;
606
606
  try {
607
- return __wasm_bindgen_func_elem_4339(a, state0.b, arg0, arg1);
607
+ return __wasm_bindgen_func_elem_4345(a, state0.b, arg0, arg1);
608
608
  } finally {
609
609
  state0.a = a;
610
610
  }
@@ -667,7 +667,7 @@ function __wbg_get_imports() {
667
667
  const ret = getObject(arg0).now();
668
668
  return ret;
669
669
  },
670
- __wbg_open_8de28c1c71058b26: function(arg0, arg1) {
670
+ __wbg_open_d3c7a73988c337d0: function(arg0, arg1) {
671
671
  const ret = open(getStringFromWasm0(arg0, arg1));
672
672
  return addHeapObject(ret);
673
673
  },
@@ -703,7 +703,7 @@ function __wbg_get_imports() {
703
703
  __wbg_randomFillSync_6c25eac9869eb53c: function() { return handleError(function (arg0, arg1) {
704
704
  getObject(arg0).randomFillSync(takeObject(arg1));
705
705
  }, arguments); },
706
- __wbg_read_6c706f9e9482137f: function(arg0, arg1, arg2) {
706
+ __wbg_read_9777c38c7aa2eadf: function(arg0, arg1, arg2) {
707
707
  const ret = getObject(arg0).read(getArrayU8FromWasm0(arg1, arg2));
708
708
  return addHeapObject(ret);
709
709
  },
@@ -718,7 +718,7 @@ function __wbg_get_imports() {
718
718
  __wbg_respond_510e32df8aeb6817: function() { return handleError(function (arg0, arg1) {
719
719
  getObject(arg0).respond(arg1 >>> 0);
720
720
  }, arguments); },
721
- __wbg_scan_99d56adc9e0fe97e: function(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) {
721
+ __wbg_scan_f620185042d6f9dd: function(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) {
722
722
  const ret = getObject(arg0).scan(getArrayU8FromWasm0(arg1, arg2), getArrayU8FromWasm0(arg3, arg4), arg5 !== 0, arg6 >>> 0, arg7 !== 0);
723
723
  return addHeapObject(ret);
724
724
  },
@@ -804,7 +804,7 @@ function __wbg_get_imports() {
804
804
  const ret = getObject(arg0).then(getObject(arg1));
805
805
  return addHeapObject(ret);
806
806
  },
807
- __wbg_to_string_b2f71e09adae601d: function(arg0) {
807
+ __wbg_to_string_e3969f722f4c9536: function(arg0) {
808
808
  const ret = to_string(takeObject(arg0));
809
809
  return addHeapObject(ret);
810
810
  },
@@ -815,7 +815,7 @@ function __wbg_get_imports() {
815
815
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
816
816
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
817
817
  },
818
- __wbg_valueEnds_e839d744b07063a7: function(arg0) {
818
+ __wbg_valueEnds_9c9adcd836a17842: function(arg0) {
819
819
  const ret = getObject(arg0).valueEnds;
820
820
  return isLikeNone(ret) ? 0 : addHeapObject(ret);
821
821
  },
@@ -823,7 +823,7 @@ function __wbg_get_imports() {
823
823
  const ret = getObject(arg0).value;
824
824
  return addHeapObject(ret);
825
825
  },
826
- __wbg_values_565f2b427f84b9f4: function(arg0) {
826
+ __wbg_values_2a62516a54768553: function(arg0) {
827
827
  const ret = getObject(arg0).values;
828
828
  return isLikeNone(ret) ? 0 : addHeapObject(ret);
829
829
  },
@@ -836,23 +836,23 @@ function __wbg_get_imports() {
836
836
  return isLikeNone(ret) ? 0 : addHeapObject(ret);
837
837
  },
838
838
  __wbindgen_cast_0000000000000001: function(arg0, arg1) {
839
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Boolean], shim_idx: 1397, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
840
- const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_27714);
839
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Boolean], shim_idx: 1390, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
840
+ const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_27670);
841
841
  return addHeapObject(ret);
842
842
  },
843
843
  __wbindgen_cast_0000000000000002: function(arg0, arg1) {
844
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 282, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
845
- const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_4266);
844
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 284, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
845
+ const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_4272);
846
846
  return addHeapObject(ret);
847
847
  },
848
848
  __wbindgen_cast_0000000000000003: function(arg0, arg1) {
849
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Option(NamedExternref("Uint8Array"))], shim_idx: 1395, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
850
- const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_27715);
849
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Option(NamedExternref("Uint8Array"))], shim_idx: 1388, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
850
+ const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_27668);
851
851
  return addHeapObject(ret);
852
852
  },
853
853
  __wbindgen_cast_0000000000000004: function(arg0, arg1) {
854
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 486, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
855
- const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_7486);
854
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 487, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
855
+ const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_7494);
856
856
  return addHeapObject(ret);
857
857
  },
858
858
  __wbindgen_cast_0000000000000005: function(arg0) {
@@ -901,14 +901,14 @@ function __wbg_get_imports() {
901
901
  };
902
902
  }
903
903
 
904
- function __wasm_bindgen_func_elem_7486(arg0, arg1) {
905
- wasm.__wasm_bindgen_func_elem_7486(arg0, arg1);
904
+ function __wasm_bindgen_func_elem_7494(arg0, arg1) {
905
+ wasm.__wasm_bindgen_func_elem_7494(arg0, arg1);
906
906
  }
907
907
 
908
- function __wasm_bindgen_func_elem_27714(arg0, arg1, arg2) {
908
+ function __wasm_bindgen_func_elem_27670(arg0, arg1, arg2) {
909
909
  try {
910
910
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
911
- wasm.__wasm_bindgen_func_elem_27714(retptr, arg0, arg1, arg2);
911
+ wasm.__wasm_bindgen_func_elem_27670(retptr, arg0, arg1, arg2);
912
912
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
913
913
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
914
914
  if (r1) {
@@ -919,10 +919,10 @@ function __wasm_bindgen_func_elem_27714(arg0, arg1, arg2) {
919
919
  }
920
920
  }
921
921
 
922
- function __wasm_bindgen_func_elem_4266(arg0, arg1, arg2) {
922
+ function __wasm_bindgen_func_elem_4272(arg0, arg1, arg2) {
923
923
  try {
924
924
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
925
- wasm.__wasm_bindgen_func_elem_4266(retptr, arg0, arg1, addHeapObject(arg2));
925
+ wasm.__wasm_bindgen_func_elem_4272(retptr, arg0, arg1, addHeapObject(arg2));
926
926
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
927
927
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
928
928
  if (r1) {
@@ -933,10 +933,10 @@ function __wasm_bindgen_func_elem_4266(arg0, arg1, arg2) {
933
933
  }
934
934
  }
935
935
 
936
- function __wasm_bindgen_func_elem_27715(arg0, arg1, arg2) {
936
+ function __wasm_bindgen_func_elem_27668(arg0, arg1, arg2) {
937
937
  try {
938
938
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
939
- wasm.__wasm_bindgen_func_elem_27715(retptr, arg0, arg1, isLikeNone(arg2) ? 0 : addHeapObject(arg2));
939
+ wasm.__wasm_bindgen_func_elem_27668(retptr, arg0, arg1, isLikeNone(arg2) ? 0 : addHeapObject(arg2));
940
940
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
941
941
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
942
942
  if (r1) {
@@ -947,8 +947,8 @@ function __wasm_bindgen_func_elem_27715(arg0, arg1, arg2) {
947
947
  }
948
948
  }
949
949
 
950
- function __wasm_bindgen_func_elem_4339(arg0, arg1, arg2, arg3) {
951
- wasm.__wasm_bindgen_func_elem_4339(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
950
+ function __wasm_bindgen_func_elem_4345(arg0, arg1, arg2, arg3) {
951
+ wasm.__wasm_bindgen_func_elem_4345(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
952
952
  }
953
953
 
954
954
 
Binary file
@@ -22,11 +22,11 @@ export const intounderlyingsink_close: (a: number) => number;
22
22
  export const intounderlyingsink_write: (a: number, b: number) => number;
23
23
  export const intounderlyingsource_cancel: (a: number) => void;
24
24
  export const intounderlyingsource_pull: (a: number, b: number) => number;
25
- export const __wasm_bindgen_func_elem_27714: (a: number, b: number, c: number, d: number) => void;
26
- export const __wasm_bindgen_func_elem_4266: (a: number, b: number, c: number, d: number) => void;
27
- export const __wasm_bindgen_func_elem_27715: (a: number, b: number, c: number, d: number) => void;
28
- export const __wasm_bindgen_func_elem_4339: (a: number, b: number, c: number, d: number) => void;
29
- export const __wasm_bindgen_func_elem_7486: (a: number, b: number) => void;
25
+ export const __wasm_bindgen_func_elem_27670: (a: number, b: number, c: number, d: number) => void;
26
+ export const __wasm_bindgen_func_elem_4272: (a: number, b: number, c: number, d: number) => void;
27
+ export const __wasm_bindgen_func_elem_27668: (a: number, b: number, c: number, d: number) => void;
28
+ export const __wasm_bindgen_func_elem_4345: (a: number, b: number, c: number, d: number) => void;
29
+ export const __wasm_bindgen_func_elem_7494: (a: number, b: number) => void;
30
30
  export const __wbindgen_export: (a: number, b: number) => number;
31
31
  export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
32
32
  export const __wbindgen_export3: (a: number) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@surrealdb/wasm-native",
3
- "version": "3.3.0-beta.2",
3
+ "version": "3.3.0-beta.3",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "description": "WebAssembly bindings to an embedded SurrealDB engine, for the browser",