@minigraf/browser 1.1.1 → 1.2.1

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
@@ -1,86 +1,57 @@
1
- # @minigraf/browser
1
+ # minigraf (WebAssembly)
2
2
 
3
- [![npm](https://img.shields.io/npm/v/@minigraf/browser.svg)](https://www.npmjs.com/package/@minigraf/browser)
4
- [![License: MIT OR Apache-2.0](https://img.shields.io/badge/license-MIT%20OR%20Apache--2.0-blue.svg)](https://github.com/project-minigraf/minigraf#license)
3
+ WebAssembly builds of [Minigraf](https://github.com/project-minigraf/minigraf) — zero-config,
4
+ single-file, embedded bi-temporal graph database with Datalog queries.
5
5
 
6
- > Embedded bi-temporal graph database for the browser — Datalog queries, time travel, IndexedDB persistence
6
+ Two packages are published from this repo:
7
7
 
8
- Minigraf in the browser: zero configuration, persistent graph storage backed by IndexedDB, Datalog queries with recursive rules and time travel. One API, no server required.
8
+ | Package | Target | Install |
9
+ |---------|--------|---------|
10
+ | [`@minigraf/browser`](https://www.npmjs.com/package/@minigraf/browser) | Browser (wasm-bindgen) | `npm install @minigraf/browser` |
11
+ | [`@minigraf/wasi`](https://www.npmjs.com/package/@minigraf/wasi) | Node.js / WASI runtimes | `npm install @minigraf/wasi` |
9
12
 
10
- ## Install
13
+ ## Browser (`@minigraf/browser`)
11
14
 
12
- ```sh
13
- npm install @minigraf/browser
14
- ```
15
-
16
- ## Quick start
17
-
18
- ```javascript
19
- import init, { BrowserDb } from '@minigraf/browser';
20
- await init();
21
-
22
- // Persistent database (survives page reloads — backed by IndexedDB)
23
- const db = await BrowserDb.open('my-graph');
24
-
25
- // In-memory database (ephemeral / testing)
26
- const mem = BrowserDb.openInMemory();
15
+ ```js
16
+ import init, { MiniGrafDb } from '@minigraf/browser'
27
17
 
28
- // Transact facts
29
- const r = JSON.parse(await db.execute(
30
- '(transact [[:alice :person/name "Alice"] [:alice :person/age 30]])'
31
- ));
32
- // { "transacted": 1 }
18
+ await init()
33
19
 
34
- // Query with Datalog
35
- const q = JSON.parse(await db.execute(
36
- '(query [:find ?name ?age :where [?e :person/name ?name] [?e :person/age ?age]])'
37
- ));
38
- // { "variables": ["?name", "?age"], "results": [["Alice", 30]] }
20
+ const db = MiniGrafDb.inMemory()
21
+ db.execute('(transact [[:alice :name "Alice"]])')
39
22
 
40
- // Time travel state as of transaction 1
41
- const snap = JSON.parse(await db.execute(
42
- '(query [:find ?age :as-of 1 :where [:alice :person/age ?age]])'
43
- ));
23
+ const result = JSON.parse(db.execute('(query [:find ?n :where [?e :name ?n]])'))
24
+ console.log(result.results[0][0]) // "Alice"
44
25
  ```
45
26
 
46
- ## Response shapes
27
+ ## WASI (`@minigraf/wasi`)
47
28
 
48
- | Command | JSON |
49
- |---|---|
50
- | `transact` | `{"transacted": <tx_count>}` |
51
- | `retract` | `{"retracted": <tx_count>}` |
52
- | `query` | `{"variables": [...], "results": [[...]]}` |
53
- | `rule` | `{"ok": true}` |
29
+ ```js
30
+ import { instantiateMinigrafWasiWith } from '@minigraf/wasi'
31
+ import { WASI } from 'node:wasi'
54
32
 
55
- ## Export / import
56
-
57
- The `.graph` binary format is byte-identical between browser and native builds. Export a snapshot or load a native-generated file:
58
-
59
- ```javascript
60
- // Export (Uint8Array — byte-identical to a native .graph file)
61
- const bytes = db.exportGraph();
62
-
63
- // Import a native .graph file (must be checkpointed — no pending WAL)
64
- const file = document.querySelector('input[type=file]').files[0];
65
- await db.importGraph(new Uint8Array(await file.arrayBuffer()));
33
+ const wasi = new WASI({ version: 'preview1' })
34
+ const instance = await instantiateMinigrafWasiWith(wasi)
35
+ // Use the WebAssembly instance exports
66
36
  ```
67
37
 
68
- ## Constraints
38
+ ## Building from source
69
39
 
70
- - Requires a browser environment with IndexedDB. Not compatible with Node.js — use the [`minigraf` npm package](https://www.npmjs.com/package/minigraf) for Node.js instead.
71
- - Single-threaded. Runs on the main thread or in a Web Worker; no shared state across workers.
40
+ Requires Rust stable toolchain and `wasm-pack`.
72
41
 
73
- ## wasm-pack clobbering note (for maintainers)
42
+ ```bash
43
+ # Browser target
44
+ wasm-pack build --target web --features browser
74
45
 
75
- `wasm-pack build` may overwrite this file. If it does, `wasm-release.yml` must copy the canonical
76
- README from a stable source (e.g. a root-level `minigraf-wasm.README.md`) into the build output
77
- directory before `npm publish`. Verify this on first release after any `wasm-pack` version upgrade.
46
+ # WASI target
47
+ cargo build --target wasm32-wasip1 --release
48
+ ```
78
49
 
79
- ## Links
50
+ ## Cascade release
80
51
 
81
- - [Full browser integration guide](https://github.com/project-minigraf/minigraf/wiki/Use-Cases#wasm--browser)
82
- - [Repository](https://github.com/project-minigraf/minigraf)
83
- - [Datalog Reference](https://github.com/project-minigraf/minigraf/wiki/Datalog-Reference)
52
+ This repo receives a `core-release` repository_dispatch from the minigraf monorepo
53
+ cascade whenever a new version of the `minigraf` core crate is published. The release
54
+ workflow pins the new version, commits, tags, and publishes both npm packages.
84
55
 
85
56
  ## License
86
57
 
@@ -68,20 +68,23 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
68
68
  export interface InitOutput {
69
69
  readonly memory: WebAssembly.Memory;
70
70
  readonly __wbg_browserdb_free: (a: number, b: number) => void;
71
- readonly browserdb_checkpoint: (a: number) => number;
72
- readonly browserdb_execute: (a: number, b: number, c: number) => number;
73
- readonly browserdb_exportGraph: (a: number, b: number) => void;
74
- readonly browserdb_importGraph: (a: number, b: number) => number;
75
- readonly browserdb_open: (a: number, b: number) => number;
76
- readonly browserdb_openInMemory: (a: number) => void;
77
- readonly __wasm_bindgen_func_elem_2769: (a: number, b: number, c: number, d: number) => void;
78
- readonly __wasm_bindgen_func_elem_2781: (a: number, b: number, c: number, d: number) => void;
79
- readonly __wasm_bindgen_func_elem_658: (a: number, b: number, c: number) => void;
80
- readonly __wbindgen_export: (a: number, b: number) => number;
81
- readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
82
- readonly __wbindgen_export3: (a: number) => void;
83
- readonly __wbindgen_export4: (a: number, b: number) => void;
84
- readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
71
+ readonly browserdb_checkpoint: (a: number) => any;
72
+ readonly browserdb_execute: (a: number, b: number, c: number) => any;
73
+ readonly browserdb_exportGraph: (a: number) => [number, number, number];
74
+ readonly browserdb_importGraph: (a: number, b: any) => any;
75
+ readonly browserdb_open: (a: number, b: number) => any;
76
+ readonly browserdb_openInMemory: () => [number, number, number];
77
+ readonly wasm_bindgen__convert__closures_____invoke__h6588d25cdde23584: (a: number, b: number, c: any) => [number, number];
78
+ readonly wasm_bindgen__convert__closures_____invoke__h4bf2427f775cf424: (a: number, b: number, c: any, d: any) => void;
79
+ readonly wasm_bindgen__convert__closures_____invoke__h433d110f0824d0c1: (a: number, b: number, c: any) => void;
80
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
81
+ readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
82
+ readonly __wbindgen_exn_store: (a: number) => void;
83
+ readonly __externref_table_alloc: () => number;
84
+ readonly __wbindgen_externrefs: WebAssembly.Table;
85
+ readonly __wbindgen_destroy_closure: (a: number, b: number) => void;
86
+ readonly __externref_table_dealloc: (a: number) => void;
87
+ readonly __wbindgen_start: () => void;
85
88
  }
86
89
 
87
90
  export type SyncInitInput = BufferSource | WebAssembly.Module;
@@ -1,4 +1,4 @@
1
- /* @ts-self-types="./minigraf.d.ts" */
1
+ /* @ts-self-types="./minigraf_wasm.d.ts" */
2
2
 
3
3
  /**
4
4
  * Browser-only Minigraf database handle backed by IndexedDB.
@@ -9,7 +9,6 @@
9
9
  */
10
10
  export class BrowserDb {
11
11
  static __wrap(ptr) {
12
- ptr = ptr >>> 0;
13
12
  const obj = Object.create(BrowserDb.prototype);
14
13
  obj.__wbg_ptr = ptr;
15
14
  BrowserDbFinalization.register(obj, obj.__wbg_ptr, obj);
@@ -35,7 +34,7 @@ export class BrowserDb {
35
34
  */
36
35
  checkpoint() {
37
36
  const ret = wasm.browserdb_checkpoint(this.__wbg_ptr);
38
- return takeObject(ret);
37
+ return ret;
39
38
  }
40
39
  /**
41
40
  * Execute a Datalog command string and return a JSON-encoded result.
@@ -49,10 +48,10 @@ export class BrowserDb {
49
48
  * @returns {Promise<string>}
50
49
  */
51
50
  execute(datalog) {
52
- const ptr0 = passStringToWasm0(datalog, wasm.__wbindgen_export, wasm.__wbindgen_export2);
51
+ const ptr0 = passStringToWasm0(datalog, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
53
52
  const len0 = WASM_VECTOR_LEN;
54
53
  const ret = wasm.browserdb_execute(this.__wbg_ptr, ptr0, len0);
55
- return takeObject(ret);
54
+ return ret;
56
55
  }
57
56
  /**
58
57
  * Serialise the current database to a portable `.graph` blob.
@@ -65,19 +64,11 @@ export class BrowserDb {
65
64
  * @returns {Uint8Array}
66
65
  */
67
66
  exportGraph() {
68
- try {
69
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
70
- wasm.browserdb_exportGraph(retptr, this.__wbg_ptr);
71
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
72
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
73
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
74
- if (r2) {
75
- throw takeObject(r1);
76
- }
77
- return takeObject(r0);
78
- } finally {
79
- wasm.__wbindgen_add_to_stack_pointer(16);
67
+ const ret = wasm.browserdb_exportGraph(this.__wbg_ptr);
68
+ if (ret[2]) {
69
+ throw takeFromExternrefTable0(ret[1]);
80
70
  }
71
+ return takeFromExternrefTable0(ret[0]);
81
72
  }
82
73
  /**
83
74
  * Replace the current database with a `.graph` blob.
@@ -89,8 +80,8 @@ export class BrowserDb {
89
80
  * @returns {Promise<void>}
90
81
  */
91
82
  importGraph(data) {
92
- const ret = wasm.browserdb_importGraph(this.__wbg_ptr, addHeapObject(data));
93
- return takeObject(ret);
83
+ const ret = wasm.browserdb_importGraph(this.__wbg_ptr, data);
84
+ return ret;
94
85
  }
95
86
  /**
96
87
  * Open or create a database backed by IndexedDB.
@@ -101,10 +92,10 @@ export class BrowserDb {
101
92
  * @returns {Promise<BrowserDb>}
102
93
  */
103
94
  static open(db_name) {
104
- const ptr0 = passStringToWasm0(db_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
95
+ const ptr0 = passStringToWasm0(db_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
105
96
  const len0 = WASM_VECTOR_LEN;
106
97
  const ret = wasm.browserdb_open(ptr0, len0);
107
- return takeObject(ret);
98
+ return ret;
108
99
  }
109
100
  /**
110
101
  * Open an in-memory database (no IndexedDB — for testing only).
@@ -113,340 +104,323 @@ export class BrowserDb {
113
104
  * @returns {BrowserDb}
114
105
  */
115
106
  static openInMemory() {
116
- try {
117
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
118
- wasm.browserdb_openInMemory(retptr);
119
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
120
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
121
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
122
- if (r2) {
123
- throw takeObject(r1);
124
- }
125
- return BrowserDb.__wrap(r0);
126
- } finally {
127
- wasm.__wbindgen_add_to_stack_pointer(16);
107
+ const ret = wasm.browserdb_openInMemory();
108
+ if (ret[2]) {
109
+ throw takeFromExternrefTable0(ret[1]);
128
110
  }
111
+ return BrowserDb.__wrap(ret[0]);
129
112
  }
130
113
  }
131
114
  if (Symbol.dispose) BrowserDb.prototype[Symbol.dispose] = BrowserDb.prototype.free;
132
-
133
115
  function __wbg_get_imports() {
134
116
  const import0 = {
135
117
  __proto__: null,
136
- __wbg___wbindgen_debug_string_dd5d2d07ce9e6c57: function(arg0, arg1) {
137
- const ret = debugString(getObject(arg1));
138
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
118
+ __wbg___wbindgen_debug_string_c25d447a39f5578f: function(arg0, arg1) {
119
+ const ret = debugString(arg1);
120
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
139
121
  const len1 = WASM_VECTOR_LEN;
140
122
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
141
123
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
142
124
  },
143
- __wbg___wbindgen_is_function_49868bde5eb1e745: function(arg0) {
144
- const ret = typeof(getObject(arg0)) === 'function';
125
+ __wbg___wbindgen_is_function_1ff95bcc5517c252: function(arg0) {
126
+ const ret = typeof(arg0) === 'function';
145
127
  return ret;
146
128
  },
147
- __wbg___wbindgen_is_undefined_c0cca72b82b86f4d: function(arg0) {
148
- const ret = getObject(arg0) === undefined;
129
+ __wbg___wbindgen_is_undefined_c05833b95a3cf397: function(arg0) {
130
+ const ret = arg0 === undefined;
149
131
  return ret;
150
132
  },
151
- __wbg___wbindgen_number_get_7579aab02a8a620c: function(arg0, arg1) {
152
- const obj = getObject(arg1);
133
+ __wbg___wbindgen_number_get_394265ed1e1b84ee: function(arg0, arg1) {
134
+ const obj = arg1;
153
135
  const ret = typeof(obj) === 'number' ? obj : undefined;
154
136
  getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
155
137
  getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
156
138
  },
157
- __wbg___wbindgen_throw_81fc77679af83bc6: function(arg0, arg1) {
139
+ __wbg___wbindgen_throw_344f42d3211c4765: function(arg0, arg1) {
158
140
  throw new Error(getStringFromWasm0(arg0, arg1));
159
141
  },
160
- __wbg__wbg_cb_unref_3c3b4f651835fbcb: function(arg0) {
161
- getObject(arg0)._wbg_cb_unref();
142
+ __wbg__wbg_cb_unref_fffb441def202758: function(arg0) {
143
+ arg0._wbg_cb_unref();
162
144
  },
163
145
  __wbg_browserdb_new: function(arg0) {
164
146
  const ret = BrowserDb.__wrap(arg0);
165
- return addHeapObject(ret);
147
+ return ret;
166
148
  },
167
- __wbg_call_7f2987183bb62793: function() { return handleError(function (arg0, arg1) {
168
- const ret = getObject(arg0).call(getObject(arg1));
169
- return addHeapObject(ret);
149
+ __wbg_call_8a2dd23819f8a60a: function() { return handleError(function (arg0, arg1) {
150
+ const ret = arg0.call(arg1);
151
+ return ret;
170
152
  }, arguments); },
171
- __wbg_call_d578befcc3145dee: function() { return handleError(function (arg0, arg1, arg2) {
172
- const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
173
- return addHeapObject(ret);
153
+ __wbg_call_a6e5c5dce5018821: function() { return handleError(function (arg0, arg1, arg2) {
154
+ const ret = arg0.call(arg1, arg2);
155
+ return ret;
174
156
  }, arguments); },
175
- __wbg_contains_04f0b15b3b6b3f6f: function(arg0, arg1, arg2) {
176
- const ret = getObject(arg0).contains(getStringFromWasm0(arg1, arg2));
157
+ __wbg_contains_72b3d3ec2e94729e: function(arg0, arg1, arg2) {
158
+ const ret = arg0.contains(getStringFromWasm0(arg1, arg2));
177
159
  return ret;
178
160
  },
179
- __wbg_createObjectStore_11c03f9eac3c3672: function() { return handleError(function (arg0, arg1, arg2) {
180
- const ret = getObject(arg0).createObjectStore(getStringFromWasm0(arg1, arg2));
181
- return addHeapObject(ret);
161
+ __wbg_createObjectStore_ff668af6e79f0433: function() { return handleError(function (arg0, arg1, arg2) {
162
+ const ret = arg0.createObjectStore(getStringFromWasm0(arg1, arg2));
163
+ return ret;
182
164
  }, arguments); },
183
- __wbg_getAllKeys_122dfa5978e6ca9a: function() { return handleError(function (arg0) {
184
- const ret = getObject(arg0).getAllKeys();
185
- return addHeapObject(ret);
165
+ __wbg_getAllKeys_600fd10abc7076d8: function() { return handleError(function (arg0) {
166
+ const ret = arg0.getAllKeys();
167
+ return ret;
186
168
  }, arguments); },
187
- __wbg_getAll_19e833a015c08d39: function() { return handleError(function (arg0) {
188
- const ret = getObject(arg0).getAll();
189
- return addHeapObject(ret);
169
+ __wbg_getAll_b31fdebb43579f13: function() { return handleError(function (arg0) {
170
+ const ret = arg0.getAll();
171
+ return ret;
190
172
  }, arguments); },
191
- __wbg_get_4848e350b40afc16: function(arg0, arg1) {
192
- const ret = getObject(arg0)[arg1 >>> 0];
193
- return addHeapObject(ret);
173
+ __wbg_get_507a50627bffa49b: function(arg0, arg1) {
174
+ const ret = arg0[arg1 >>> 0];
175
+ return ret;
194
176
  },
195
- __wbg_indexedDB_af74cb6df65fa636: function() { return handleError(function (arg0) {
196
- const ret = getObject(arg0).indexedDB;
197
- return isLikeNone(ret) ? 0 : addHeapObject(ret);
177
+ __wbg_indexedDB_c7dd741e3b661da5: function() { return handleError(function (arg0) {
178
+ const ret = arg0.indexedDB;
179
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
198
180
  }, arguments); },
199
- __wbg_instanceof_IdbDatabase_0af111edb4be95f4: function(arg0) {
181
+ __wbg_instanceof_IdbDatabase_1cc734ba1b040dd7: function(arg0) {
200
182
  let result;
201
183
  try {
202
- result = getObject(arg0) instanceof IDBDatabase;
184
+ result = arg0 instanceof IDBDatabase;
203
185
  } catch (_) {
204
186
  result = false;
205
187
  }
206
188
  const ret = result;
207
189
  return ret;
208
190
  },
209
- __wbg_instanceof_IdbOpenDbRequest_92df356941adf31e: function(arg0) {
191
+ __wbg_instanceof_IdbOpenDbRequest_c34a5f3bfadf1d88: function(arg0) {
210
192
  let result;
211
193
  try {
212
- result = getObject(arg0) instanceof IDBOpenDBRequest;
194
+ result = arg0 instanceof IDBOpenDBRequest;
213
195
  } catch (_) {
214
196
  result = false;
215
197
  }
216
198
  const ret = result;
217
199
  return ret;
218
200
  },
219
- __wbg_instanceof_Uint8Array_4b8da683deb25d72: function(arg0) {
201
+ __wbg_instanceof_Uint8Array_309b927aaf7a3fc7: function(arg0) {
220
202
  let result;
221
203
  try {
222
- result = getObject(arg0) instanceof Uint8Array;
204
+ result = arg0 instanceof Uint8Array;
223
205
  } catch (_) {
224
206
  result = false;
225
207
  }
226
208
  const ret = result;
227
209
  return ret;
228
210
  },
229
- __wbg_instanceof_Window_c0fee4c064502536: function(arg0) {
211
+ __wbg_instanceof_Window_05ba1ee4f6781663: function(arg0) {
230
212
  let result;
231
213
  try {
232
- result = getObject(arg0) instanceof Window;
214
+ result = arg0 instanceof Window;
233
215
  } catch (_) {
234
216
  result = false;
235
217
  }
236
218
  const ret = result;
237
219
  return ret;
238
220
  },
239
- __wbg_isArray_db61795ad004c139: function(arg0) {
240
- const ret = Array.isArray(getObject(arg0));
221
+ __wbg_isArray_0677c962b281d01a: function(arg0) {
222
+ const ret = Array.isArray(arg0);
241
223
  return ret;
242
224
  },
243
- __wbg_length_0c32cb8543c8e4c8: function(arg0) {
244
- const ret = getObject(arg0).length;
225
+ __wbg_length_1f0964f4a5e2c6d8: function(arg0) {
226
+ const ret = arg0.length;
245
227
  return ret;
246
228
  },
247
- __wbg_length_6e821edde497a532: function(arg0) {
248
- const ret = getObject(arg0).length;
229
+ __wbg_length_370319915dc99107: function(arg0) {
230
+ const ret = arg0.length;
249
231
  return ret;
250
232
  },
251
- __wbg_new_40792555590ec35c: function(arg0, arg1) {
233
+ __wbg_new_aec3e25493d729fe: function(arg0, arg1) {
252
234
  try {
253
235
  var state0 = {a: arg0, b: arg1};
254
236
  var cb0 = (arg0, arg1) => {
255
237
  const a = state0.a;
256
238
  state0.a = 0;
257
239
  try {
258
- return __wasm_bindgen_func_elem_2781(a, state0.b, arg0, arg1);
240
+ return wasm_bindgen__convert__closures_____invoke__h4bf2427f775cf424(a, state0.b, arg0, arg1);
259
241
  } finally {
260
242
  state0.a = a;
261
243
  }
262
244
  };
263
245
  const ret = new Promise(cb0);
264
- return addHeapObject(ret);
246
+ return ret;
265
247
  } finally {
266
248
  state0.a = 0;
267
249
  }
268
250
  },
269
- __wbg_new_from_slice_2580ff33d0d10520: function(arg0, arg1) {
251
+ __wbg_new_from_slice_77cdfb7977362f3c: function(arg0, arg1) {
270
252
  const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
271
- return addHeapObject(ret);
253
+ return ret;
272
254
  },
273
- __wbg_new_typed_14d7cc391ce53d2c: function(arg0, arg1) {
255
+ __wbg_new_typed_1824d93f294193e5: function(arg0, arg1) {
274
256
  try {
275
257
  var state0 = {a: arg0, b: arg1};
276
258
  var cb0 = (arg0, arg1) => {
277
259
  const a = state0.a;
278
260
  state0.a = 0;
279
261
  try {
280
- return __wasm_bindgen_func_elem_2781(a, state0.b, arg0, arg1);
262
+ return wasm_bindgen__convert__closures_____invoke__h4bf2427f775cf424(a, state0.b, arg0, arg1);
281
263
  } finally {
282
264
  state0.a = a;
283
265
  }
284
266
  };
285
267
  const ret = new Promise(cb0);
286
- return addHeapObject(ret);
268
+ return ret;
287
269
  } finally {
288
270
  state0.a = 0;
289
271
  }
290
272
  },
291
- __wbg_now_88621c9c9a4f3ffc: function() {
273
+ __wbg_now_86c0d4ba3fa605b8: function() {
292
274
  const ret = Date.now();
293
275
  return ret;
294
276
  },
295
- __wbg_objectStoreNames_990d8e55c661828b: function(arg0) {
296
- const ret = getObject(arg0).objectStoreNames;
297
- return addHeapObject(ret);
277
+ __wbg_objectStoreNames_146ab25540bff6db: function(arg0) {
278
+ const ret = arg0.objectStoreNames;
279
+ return ret;
298
280
  },
299
- __wbg_objectStore_3d4cade4416cd432: function() { return handleError(function (arg0, arg1, arg2) {
300
- const ret = getObject(arg0).objectStore(getStringFromWasm0(arg1, arg2));
301
- return addHeapObject(ret);
281
+ __wbg_objectStore_d5f47956b6c741e3: function() { return handleError(function (arg0, arg1, arg2) {
282
+ const ret = arg0.objectStore(getStringFromWasm0(arg1, arg2));
283
+ return ret;
302
284
  }, arguments); },
303
- __wbg_open_ac04ec9d75d0eeaf: function() { return handleError(function (arg0, arg1, arg2, arg3) {
304
- const ret = getObject(arg0).open(getStringFromWasm0(arg1, arg2), arg3 >>> 0);
305
- return addHeapObject(ret);
285
+ __wbg_open_72e5234a49d5f85d: function() { return handleError(function (arg0, arg1, arg2, arg3) {
286
+ const ret = arg0.open(getStringFromWasm0(arg1, arg2), arg3 >>> 0);
287
+ return ret;
306
288
  }, arguments); },
307
- __wbg_prototypesetcall_3e05eb9545565046: function(arg0, arg1, arg2) {
308
- Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
289
+ __wbg_prototypesetcall_4770620bbe4688a0: function(arg0, arg1, arg2) {
290
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
309
291
  },
310
- __wbg_put_4485a4012273f7ef: function() { return handleError(function (arg0, arg1, arg2) {
311
- const ret = getObject(arg0).put(getObject(arg1), getObject(arg2));
312
- return addHeapObject(ret);
292
+ __wbg_put_a368805e3dcab3a7: function() { return handleError(function (arg0, arg1, arg2) {
293
+ const ret = arg0.put(arg1, arg2);
294
+ return ret;
313
295
  }, arguments); },
314
- __wbg_queueMicrotask_abaf92f0bd4e80a4: function(arg0) {
315
- const ret = getObject(arg0).queueMicrotask;
316
- return addHeapObject(ret);
296
+ __wbg_queueMicrotask_0ab5b2d2393e99b9: function(arg0) {
297
+ const ret = arg0.queueMicrotask;
298
+ return ret;
317
299
  },
318
- __wbg_queueMicrotask_df5a6dac26d818f3: function(arg0) {
319
- queueMicrotask(getObject(arg0));
300
+ __wbg_queueMicrotask_6a09b7bc46549209: function(arg0) {
301
+ queueMicrotask(arg0);
320
302
  },
321
- __wbg_resolve_0a79de24e9d2267b: function(arg0) {
322
- const ret = Promise.resolve(getObject(arg0));
323
- return addHeapObject(ret);
303
+ __wbg_resolve_2191a4dfe481c25b: function(arg0) {
304
+ const ret = Promise.resolve(arg0);
305
+ return ret;
324
306
  },
325
- __wbg_result_452c1006fc727317: function() { return handleError(function (arg0) {
326
- const ret = getObject(arg0).result;
327
- return addHeapObject(ret);
307
+ __wbg_result_2b1294a2bf8dc773: function() { return handleError(function (arg0) {
308
+ const ret = arg0.result;
309
+ return ret;
328
310
  }, arguments); },
329
- __wbg_set_oncomplete_20fb27150b4ee0d4: function(arg0, arg1) {
330
- getObject(arg0).oncomplete = getObject(arg1);
311
+ __wbg_set_oncomplete_e6abb66d0ad42731: function(arg0, arg1) {
312
+ arg0.oncomplete = arg1;
331
313
  },
332
- __wbg_set_onerror_2b7dfa4e6dea4159: function(arg0, arg1) {
333
- getObject(arg0).onerror = getObject(arg1);
314
+ __wbg_set_onerror_3488a474171ed56d: function(arg0, arg1) {
315
+ arg0.onerror = arg1;
334
316
  },
335
- __wbg_set_onerror_3c4b5087146b11b6: function(arg0, arg1) {
336
- getObject(arg0).onerror = getObject(arg1);
317
+ __wbg_set_onerror_f8d31be44335c633: function(arg0, arg1) {
318
+ arg0.onerror = arg1;
337
319
  },
338
- __wbg_set_onsuccess_f7e5b5cbed5008b1: function(arg0, arg1) {
339
- getObject(arg0).onsuccess = getObject(arg1);
320
+ __wbg_set_onsuccess_cd0c3642a2873e66: function(arg0, arg1) {
321
+ arg0.onsuccess = arg1;
340
322
  },
341
- __wbg_set_onupgradeneeded_d7e8e03a1999bf5d: function(arg0, arg1) {
342
- getObject(arg0).onupgradeneeded = getObject(arg1);
323
+ __wbg_set_onupgradeneeded_7b2cf4ba1c57e655: function(arg0, arg1) {
324
+ arg0.onupgradeneeded = arg1;
343
325
  },
344
- __wbg_static_accessor_GLOBAL_THIS_a1248013d790bf5f: function() {
345
- const ret = typeof globalThis === 'undefined' ? null : globalThis;
346
- return isLikeNone(ret) ? 0 : addHeapObject(ret);
347
- },
348
- __wbg_static_accessor_GLOBAL_f2e0f995a21329ff: function() {
326
+ __wbg_static_accessor_GLOBAL_4ef717fb391d88b7: function() {
349
327
  const ret = typeof global === 'undefined' ? null : global;
350
- return isLikeNone(ret) ? 0 : addHeapObject(ret);
328
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
329
+ },
330
+ __wbg_static_accessor_GLOBAL_THIS_8d1badc68b5a74f4: function() {
331
+ const ret = typeof globalThis === 'undefined' ? null : globalThis;
332
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
351
333
  },
352
- __wbg_static_accessor_SELF_24f78b6d23f286ea: function() {
334
+ __wbg_static_accessor_SELF_146583524fe1469b: function() {
353
335
  const ret = typeof self === 'undefined' ? null : self;
354
- return isLikeNone(ret) ? 0 : addHeapObject(ret);
336
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
355
337
  },
356
- __wbg_static_accessor_WINDOW_59fd959c540fe405: function() {
338
+ __wbg_static_accessor_WINDOW_f2829a2234d7819e: function() {
357
339
  const ret = typeof window === 'undefined' ? null : window;
358
- return isLikeNone(ret) ? 0 : addHeapObject(ret);
340
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
359
341
  },
360
- __wbg_target_732d56b173b7e87c: function(arg0) {
361
- const ret = getObject(arg0).target;
362
- return isLikeNone(ret) ? 0 : addHeapObject(ret);
342
+ __wbg_target_e759594a8d965ed7: function(arg0) {
343
+ const ret = arg0.target;
344
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
363
345
  },
364
- __wbg_then_00eed3ac0b8e82cb: function(arg0, arg1, arg2) {
365
- const ret = getObject(arg0).then(getObject(arg1), getObject(arg2));
366
- return addHeapObject(ret);
346
+ __wbg_then_16d107c451e9905d: function(arg0, arg1, arg2) {
347
+ const ret = arg0.then(arg1, arg2);
348
+ return ret;
367
349
  },
368
- __wbg_then_a0c8db0381c8994c: function(arg0, arg1) {
369
- const ret = getObject(arg0).then(getObject(arg1));
370
- return addHeapObject(ret);
350
+ __wbg_then_6ec10ae38b3e92f7: function(arg0, arg1) {
351
+ const ret = arg0.then(arg1);
352
+ return ret;
371
353
  },
372
- __wbg_transaction_f909284bfed41115: function() { return handleError(function (arg0, arg1, arg2, arg3) {
373
- const ret = getObject(arg0).transaction(getStringFromWasm0(arg1, arg2), __wbindgen_enum_IdbTransactionMode[arg3]);
374
- return addHeapObject(ret);
354
+ __wbg_transaction_d911d96b4b0af154: function() { return handleError(function (arg0, arg1, arg2, arg3) {
355
+ const ret = arg0.transaction(getStringFromWasm0(arg1, arg2), __wbindgen_enum_IdbTransactionMode[arg3]);
356
+ return ret;
375
357
  }, arguments); },
376
358
  __wbindgen_cast_0000000000000001: function(arg0, arg1) {
377
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 237, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
378
- const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_2769);
379
- return addHeapObject(ret);
359
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 70, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
360
+ const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h6588d25cdde23584);
361
+ return ret;
380
362
  },
381
363
  __wbindgen_cast_0000000000000002: function(arg0, arg1) {
382
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("Event")], shim_idx: 6, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
383
- const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_658);
384
- return addHeapObject(ret);
364
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("Event")], shim_idx: 343, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
365
+ const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h433d110f0824d0c1);
366
+ return ret;
385
367
  },
386
368
  __wbindgen_cast_0000000000000003: function(arg0) {
387
369
  // Cast intrinsic for `F64 -> Externref`.
388
370
  const ret = arg0;
389
- return addHeapObject(ret);
371
+ return ret;
390
372
  },
391
373
  __wbindgen_cast_0000000000000004: function(arg0, arg1) {
392
374
  // Cast intrinsic for `Ref(String) -> Externref`.
393
375
  const ret = getStringFromWasm0(arg0, arg1);
394
- return addHeapObject(ret);
395
- },
396
- __wbindgen_object_clone_ref: function(arg0) {
397
- const ret = getObject(arg0);
398
- return addHeapObject(ret);
376
+ return ret;
399
377
  },
400
- __wbindgen_object_drop_ref: function(arg0) {
401
- takeObject(arg0);
378
+ __wbindgen_init_externref_table: function() {
379
+ const table = wasm.__wbindgen_externrefs;
380
+ const offset = table.grow(4);
381
+ table.set(0, undefined);
382
+ table.set(offset + 0, undefined);
383
+ table.set(offset + 1, null);
384
+ table.set(offset + 2, true);
385
+ table.set(offset + 3, false);
402
386
  },
403
387
  };
404
388
  return {
405
389
  __proto__: null,
406
- "./minigraf_bg.js": import0,
390
+ "./minigraf_wasm_bg.js": import0,
407
391
  };
408
392
  }
409
393
 
410
- function __wasm_bindgen_func_elem_658(arg0, arg1, arg2) {
411
- wasm.__wasm_bindgen_func_elem_658(arg0, arg1, addHeapObject(arg2));
394
+ function wasm_bindgen__convert__closures_____invoke__h433d110f0824d0c1(arg0, arg1, arg2) {
395
+ wasm.wasm_bindgen__convert__closures_____invoke__h433d110f0824d0c1(arg0, arg1, arg2);
412
396
  }
413
397
 
414
- function __wasm_bindgen_func_elem_2769(arg0, arg1, arg2) {
415
- try {
416
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
417
- wasm.__wasm_bindgen_func_elem_2769(retptr, arg0, arg1, addHeapObject(arg2));
418
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
419
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
420
- if (r1) {
421
- throw takeObject(r0);
422
- }
423
- } finally {
424
- wasm.__wbindgen_add_to_stack_pointer(16);
398
+ function wasm_bindgen__convert__closures_____invoke__h6588d25cdde23584(arg0, arg1, arg2) {
399
+ const ret = wasm.wasm_bindgen__convert__closures_____invoke__h6588d25cdde23584(arg0, arg1, arg2);
400
+ if (ret[1]) {
401
+ throw takeFromExternrefTable0(ret[0]);
425
402
  }
426
403
  }
427
404
 
428
- function __wasm_bindgen_func_elem_2781(arg0, arg1, arg2, arg3) {
429
- wasm.__wasm_bindgen_func_elem_2781(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
405
+ function wasm_bindgen__convert__closures_____invoke__h4bf2427f775cf424(arg0, arg1, arg2, arg3) {
406
+ wasm.wasm_bindgen__convert__closures_____invoke__h4bf2427f775cf424(arg0, arg1, arg2, arg3);
430
407
  }
431
408
 
432
409
 
433
410
  const __wbindgen_enum_IdbTransactionMode = ["readonly", "readwrite", "versionchange", "readwriteflush", "cleanup"];
434
411
  const BrowserDbFinalization = (typeof FinalizationRegistry === 'undefined')
435
412
  ? { register: () => {}, unregister: () => {} }
436
- : new FinalizationRegistry(ptr => wasm.__wbg_browserdb_free(ptr >>> 0, 1));
413
+ : new FinalizationRegistry(ptr => wasm.__wbg_browserdb_free(ptr, 1));
437
414
 
438
- function addHeapObject(obj) {
439
- if (heap_next === heap.length) heap.push(heap.length + 1);
440
- const idx = heap_next;
441
- heap_next = heap[idx];
442
-
443
- heap[idx] = obj;
415
+ function addToExternrefTable0(obj) {
416
+ const idx = wasm.__externref_table_alloc();
417
+ wasm.__wbindgen_externrefs.set(idx, obj);
444
418
  return idx;
445
419
  }
446
420
 
447
421
  const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')
448
422
  ? { register: () => {}, unregister: () => {} }
449
- : new FinalizationRegistry(state => wasm.__wbindgen_export4(state.a, state.b));
423
+ : new FinalizationRegistry(state => wasm.__wbindgen_destroy_closure(state.a, state.b));
450
424
 
451
425
  function debugString(val) {
452
426
  // primitive types
@@ -513,12 +487,6 @@ function debugString(val) {
513
487
  return className;
514
488
  }
515
489
 
516
- function dropObject(idx) {
517
- if (idx < 1028) return;
518
- heap[idx] = heap_next;
519
- heap_next = idx;
520
- }
521
-
522
490
  function getArrayU8FromWasm0(ptr, len) {
523
491
  ptr = ptr >>> 0;
524
492
  return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
@@ -533,8 +501,7 @@ function getDataViewMemory0() {
533
501
  }
534
502
 
535
503
  function getStringFromWasm0(ptr, len) {
536
- ptr = ptr >>> 0;
537
- return decodeText(ptr, len);
504
+ return decodeText(ptr >>> 0, len);
538
505
  }
539
506
 
540
507
  let cachedUint8ArrayMemory0 = null;
@@ -545,21 +512,15 @@ function getUint8ArrayMemory0() {
545
512
  return cachedUint8ArrayMemory0;
546
513
  }
547
514
 
548
- function getObject(idx) { return heap[idx]; }
549
-
550
515
  function handleError(f, args) {
551
516
  try {
552
517
  return f.apply(this, args);
553
518
  } catch (e) {
554
- wasm.__wbindgen_export3(addHeapObject(e));
519
+ const idx = addToExternrefTable0(e);
520
+ wasm.__wbindgen_exn_store(idx);
555
521
  }
556
522
  }
557
523
 
558
- let heap = new Array(1024).fill(undefined);
559
- heap.push(undefined, null, true, false);
560
-
561
- let heap_next = heap.length;
562
-
563
524
  function isLikeNone(x) {
564
525
  return x === undefined || x === null;
565
526
  }
@@ -583,7 +544,7 @@ function makeMutClosure(arg0, arg1, f) {
583
544
  };
584
545
  real._wbg_cb_unref = () => {
585
546
  if (--state.cnt === 0) {
586
- wasm.__wbindgen_export4(state.a, state.b);
547
+ wasm.__wbindgen_destroy_closure(state.a, state.b);
587
548
  state.a = 0;
588
549
  CLOSURE_DTORS.unregister(state);
589
550
  }
@@ -629,10 +590,10 @@ function passStringToWasm0(arg, malloc, realloc) {
629
590
  return ptr;
630
591
  }
631
592
 
632
- function takeObject(idx) {
633
- const ret = getObject(idx);
634
- dropObject(idx);
635
- return ret;
593
+ function takeFromExternrefTable0(idx) {
594
+ const value = wasm.__wbindgen_externrefs.get(idx);
595
+ wasm.__externref_table_dealloc(idx);
596
+ return value;
636
597
  }
637
598
 
638
599
  let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
@@ -664,12 +625,14 @@ if (!('encodeInto' in cachedTextEncoder)) {
664
625
 
665
626
  let WASM_VECTOR_LEN = 0;
666
627
 
667
- let wasmModule, wasm;
628
+ let wasmModule, wasmInstance, wasm;
668
629
  function __wbg_finalize_init(instance, module) {
630
+ wasmInstance = instance;
669
631
  wasm = instance.exports;
670
632
  wasmModule = module;
671
633
  cachedDataViewMemory0 = null;
672
634
  cachedUint8ArrayMemory0 = null;
635
+ wasm.__wbindgen_start();
673
636
  return wasm;
674
637
  }
675
638
 
@@ -741,7 +704,7 @@ async function __wbg_init(module_or_path) {
741
704
  }
742
705
 
743
706
  if (module_or_path === undefined) {
744
- module_or_path = new URL('minigraf_bg.wasm', import.meta.url);
707
+ module_or_path = new URL('minigraf_wasm_bg.wasm', import.meta.url);
745
708
  }
746
709
  const imports = __wbg_get_imports();
747
710
 
Binary file
package/package.json CHANGED
@@ -1,32 +1,21 @@
1
1
  {
2
2
  "name": "@minigraf/browser",
3
3
  "type": "module",
4
- "collaborators": [
5
- "Aditya Mukhopadhyay"
6
- ],
7
- "description": "Zero-config, single-file, embedded graph database with bi-temporal Datalog queries",
8
- "version": "1.1.1",
4
+ "description": "wasm-pack build shim for Minigraf browser and WASI targets",
5
+ "version": "1.2.1",
9
6
  "license": "MIT OR Apache-2.0",
10
7
  "repository": {
11
8
  "type": "git",
12
- "url": "https://github.com/project-minigraf/minigraf"
9
+ "url": "https://github.com/project-minigraf/minigraf-wasm"
13
10
  },
14
11
  "files": [
15
- "minigraf_bg.wasm",
16
- "minigraf_bg.wasm.d.ts",
17
- "minigraf.js",
18
- "minigraf.d.ts"
12
+ "minigraf_wasm_bg.wasm",
13
+ "minigraf_wasm.js",
14
+ "minigraf_wasm.d.ts"
19
15
  ],
20
- "main": "minigraf.js",
21
- "types": "minigraf.d.ts",
16
+ "main": "minigraf_wasm.js",
17
+ "types": "minigraf_wasm.d.ts",
22
18
  "sideEffects": [
23
19
  "./snippets/*"
24
- ],
25
- "keywords": [
26
- "graph",
27
- "datalog",
28
- "bitemporal",
29
- "embedded",
30
- "database"
31
20
  ]
32
21
  }
package/minigraf_bg.wasm DELETED
Binary file
@@ -1,18 +0,0 @@
1
- /* tslint:disable */
2
- /* eslint-disable */
3
- export const memory: WebAssembly.Memory;
4
- export const __wbg_browserdb_free: (a: number, b: number) => void;
5
- export const browserdb_checkpoint: (a: number) => number;
6
- export const browserdb_execute: (a: number, b: number, c: number) => number;
7
- export const browserdb_exportGraph: (a: number, b: number) => void;
8
- export const browserdb_importGraph: (a: number, b: number) => number;
9
- export const browserdb_open: (a: number, b: number) => number;
10
- export const browserdb_openInMemory: (a: number) => void;
11
- export const __wasm_bindgen_func_elem_2769: (a: number, b: number, c: number, d: number) => void;
12
- export const __wasm_bindgen_func_elem_2781: (a: number, b: number, c: number, d: number) => void;
13
- export const __wasm_bindgen_func_elem_658: (a: number, b: number, c: number) => void;
14
- export const __wbindgen_export: (a: number, b: number) => number;
15
- export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
16
- export const __wbindgen_export3: (a: number) => void;
17
- export const __wbindgen_export4: (a: number, b: number) => void;
18
- export const __wbindgen_add_to_stack_pointer: (a: number) => number;