@grafeo-db/wasm 0.1.4 → 0.5.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.
package/README.md CHANGED
@@ -1,12 +1,16 @@
1
1
  # @grafeo-db/wasm
2
2
 
3
- WebAssembly bindings for [Grafeo](https://grafeo.dev) - a high-performance, pure-Rust, embeddable graph database.
3
+ Low-level WebAssembly binary for [Grafeo](https://github.com/GrafeoDB/grafeo), a high-performance graph database.
4
4
 
5
- ## Status
5
+ ## Which Package Do You Need?
6
6
 
7
- **Pre-alpha** - The WebAssembly bindings are under development.
7
+ | Package | Use Case |
8
+ |---------|----------|
9
+ | [`@grafeo-db/web`](https://www.npmjs.com/package/@grafeo-db/web) | Browser apps with IndexedDB, Web Workers, React/Vue/Svelte (recommended) |
10
+ | [`@grafeo-db/wasm`](https://www.npmjs.com/package/@grafeo-db/wasm) | Raw WASM binary for custom loaders or non-standard runtimes |
11
+ | [`@grafeo-db/js`](https://www.npmjs.com/package/@grafeo-db/js) | Node.js native bindings (faster than WASM for server-side) |
8
12
 
9
- For production use, please use the [Python bindings](https://pypi.org/project/grafeo/) which are fully functional.
13
+ **Most users should use `@grafeo-db/web`** - it wraps this package and adds browser-specific features.
10
14
 
11
15
  ## Installation
12
16
 
@@ -14,16 +18,66 @@ For production use, please use the [Python bindings](https://pypi.org/project/gr
14
18
  npm install @grafeo-db/wasm
15
19
  ```
16
20
 
17
- ## Planned Features
21
+ ## Usage
18
22
 
19
- - Browser and Node.js compatible WebAssembly module
20
- - Full TypeScript type definitions
21
- - Support for GQL, Cypher, SPARQL, and GraphQL query languages
22
- - In-memory graph database in the browser
23
- - Persistence via IndexedDB or OPFS
23
+ ```typescript
24
+ import init, { GrafeoCore } from '@grafeo-db/wasm';
25
+
26
+ // Initialize the WASM module
27
+ await init();
28
+
29
+ // Low-level API
30
+ const core = new GrafeoCore();
31
+ const result = core.execute(`MATCH (n:Person) RETURN n.name`);
32
+ ```
33
+
34
+ ## Progress
35
+
36
+ - [ ] Core WASM bindings via wasm-bindgen
37
+ - [ ] In-memory database support
38
+ - [ ] All query languages (GQL, Cypher, SPARQL, GraphQL, Gremlin)
39
+ - [ ] TypeScript type definitions
40
+ - [ ] Size optimization (target: <1MB gzipped)
41
+
42
+ ## Package Contents
43
+
44
+ ```
45
+ @grafeo-db/wasm/
46
+ ├── grafeo_wasm_bg.wasm # WebAssembly binary
47
+ ├── grafeo_wasm.js # JavaScript loader
48
+ ├── grafeo_wasm.d.ts # TypeScript definitions
49
+ └── package.json
50
+ ```
51
+
52
+ ## Target Bundle Size
53
+
54
+ | Build | Size (gzip) |
55
+ |-------|-------------|
56
+ | Full (all languages) | ~600 KB |
57
+ | Minimal (GQL only) | ~300 KB |
58
+
59
+ ## Runtime Support
60
+
61
+ | Runtime | Status |
62
+ |---------|--------|
63
+ | Browser (Chrome, Firefox, Safari, Edge) | Planned |
64
+ | Deno | Planned |
65
+ | Cloudflare Workers | Planned |
66
+ | Node.js | Use `@grafeo-db/js` instead |
67
+
68
+ ## Current Alternatives
69
+
70
+ While WASM bindings are in development, you can use:
71
+
72
+ - **Python**: [`grafeo`](https://pypi.org/project/grafeo/) - fully functional
73
+ - **Rust**: [`grafeo`](https://crates.io/crates/grafeo) - fully functional
24
74
 
25
75
  ## Links
26
76
 
27
77
  - [Documentation](https://grafeo.dev)
28
78
  - [GitHub](https://github.com/GrafeoDB/grafeo)
29
- - [Python Package](https://pypi.org/project/grafeo/)
79
+ - [Roadmap](https://github.com/GrafeoDB/grafeo/blob/main/docs/roadmap.md)
80
+
81
+ ## License
82
+
83
+ Apache-2.0
package/grafeo_wasm.d.ts CHANGED
@@ -1,5 +1,141 @@
1
- // grafeo-wasm - WebAssembly bindings for Grafeo
2
- // Pre-alpha - bindings are under development.
3
- // See https://grafeo.dev for current status.
1
+ /* tslint:disable */
2
+ /* eslint-disable */
4
3
 
5
- export {};
4
+ /**
5
+ * A Grafeo graph database instance running in WebAssembly.
6
+ *
7
+ * All data is held in memory within the WASM heap. For persistence,
8
+ * use `exportSnapshot()` / `importSnapshot()` with IndexedDB or
9
+ * the higher-level `@grafeo-db/web` package.
10
+ */
11
+ export class Database {
12
+ free(): void;
13
+ [Symbol.dispose](): void;
14
+ /**
15
+ * Returns the number of edges in the database.
16
+ */
17
+ edgeCount(): number;
18
+ /**
19
+ * Executes a GQL query and returns results as an array of objects.
20
+ *
21
+ * Each row becomes a JavaScript object with column names as keys.
22
+ *
23
+ * ```js
24
+ * const results = db.execute("MATCH (p:Person) RETURN p.name, p.age");
25
+ * // [{name: "Alice", age: 30}, {name: "Bob", age: 25}]
26
+ * ```
27
+ */
28
+ execute(query: string): any;
29
+ /**
30
+ * Executes a GQL query and returns raw columns, rows, and metadata.
31
+ *
32
+ * Returns `{ columns: string[], rows: any[][], executionTimeMs?: number }`.
33
+ */
34
+ executeRaw(query: string): any;
35
+ /**
36
+ * Executes a query using a specific query language.
37
+ *
38
+ * Supported languages: `"gql"`, `"cypher"`, `"sparql"`, `"gremlin"`, `"graphql"`.
39
+ * Languages require their corresponding feature flag to be enabled.
40
+ *
41
+ * ```js
42
+ * const results = db.executeWithLanguage(
43
+ * "MATCH (p:Person) RETURN p.name",
44
+ * "cypher"
45
+ * );
46
+ * ```
47
+ */
48
+ executeWithLanguage(query: string, language: string): any;
49
+ /**
50
+ * Exports the database to a binary snapshot.
51
+ *
52
+ * Returns a `Uint8Array` that can be stored in IndexedDB, localStorage,
53
+ * or sent over the network. Restore with `Database.importSnapshot()`.
54
+ *
55
+ * ```js
56
+ * const bytes = db.exportSnapshot();
57
+ * // Store in IndexedDB, download as file, etc.
58
+ * ```
59
+ */
60
+ exportSnapshot(): Uint8Array;
61
+ /**
62
+ * Creates a database from a binary snapshot.
63
+ *
64
+ * The `data` must have been produced by `exportSnapshot()`.
65
+ *
66
+ * ```js
67
+ * const db = Database.importSnapshot(bytes);
68
+ * ```
69
+ */
70
+ static importSnapshot(data: Uint8Array): Database;
71
+ /**
72
+ * Creates a new in-memory database.
73
+ */
74
+ constructor();
75
+ /**
76
+ * Returns the number of nodes in the database.
77
+ */
78
+ nodeCount(): number;
79
+ /**
80
+ * Returns schema information about the database.
81
+ *
82
+ * Returns an object describing labels, edge types, and property keys.
83
+ *
84
+ * ```js
85
+ * const schema = db.schema();
86
+ * // { lpg: { labels: [...], edgeTypes: [...], propertyKeys: [...] } }
87
+ * ```
88
+ */
89
+ schema(): any;
90
+ /**
91
+ * Returns the Grafeo version.
92
+ */
93
+ static version(): string;
94
+ }
95
+
96
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
97
+
98
+ export interface InitOutput {
99
+ readonly memory: WebAssembly.Memory;
100
+ readonly __wbg_database_free: (a: number, b: number) => void;
101
+ readonly database_edgeCount: (a: number) => number;
102
+ readonly database_execute: (a: number, b: number, c: number) => [number, number, number];
103
+ readonly database_executeRaw: (a: number, b: number, c: number) => [number, number, number];
104
+ readonly database_executeWithLanguage: (a: number, b: number, c: number, d: number, e: number) => [number, number, number];
105
+ readonly database_exportSnapshot: (a: number) => [number, number, number, number];
106
+ readonly database_importSnapshot: (a: number, b: number) => [number, number, number];
107
+ readonly database_new: () => [number, number, number];
108
+ readonly database_nodeCount: (a: number) => number;
109
+ readonly database_schema: (a: number) => [number, number, number];
110
+ readonly database_version: () => [number, number];
111
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
112
+ readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
113
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
114
+ readonly __wbindgen_exn_store: (a: number) => void;
115
+ readonly __externref_table_alloc: () => number;
116
+ readonly __wbindgen_externrefs: WebAssembly.Table;
117
+ readonly __externref_table_dealloc: (a: number) => void;
118
+ readonly __wbindgen_start: () => void;
119
+ }
120
+
121
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
122
+
123
+ /**
124
+ * Instantiates the given `module`, which can either be bytes or
125
+ * a precompiled `WebAssembly.Module`.
126
+ *
127
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
128
+ *
129
+ * @returns {InitOutput}
130
+ */
131
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
132
+
133
+ /**
134
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
135
+ * for everything else, calls `WebAssembly.instantiate` directly.
136
+ *
137
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
138
+ *
139
+ * @returns {Promise<InitOutput>}
140
+ */
141
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
package/grafeo_wasm.js CHANGED
@@ -1,5 +1,544 @@
1
- throw new Error(
2
- 'grafeo-wasm is pre-alpha and not yet implemented. ' +
3
- 'Please see https://grafeo.dev for the current status. ' +
4
- 'For production use, consider the Python bindings: https://pypi.org/project/grafeo/'
5
- );
1
+ /* @ts-self-types="./grafeo_wasm.d.ts" */
2
+
3
+ /**
4
+ * A Grafeo graph database instance running in WebAssembly.
5
+ *
6
+ * All data is held in memory within the WASM heap. For persistence,
7
+ * use `exportSnapshot()` / `importSnapshot()` with IndexedDB or
8
+ * the higher-level `@grafeo-db/web` package.
9
+ */
10
+ export class Database {
11
+ static __wrap(ptr) {
12
+ ptr = ptr >>> 0;
13
+ const obj = Object.create(Database.prototype);
14
+ obj.__wbg_ptr = ptr;
15
+ DatabaseFinalization.register(obj, obj.__wbg_ptr, obj);
16
+ return obj;
17
+ }
18
+ __destroy_into_raw() {
19
+ const ptr = this.__wbg_ptr;
20
+ this.__wbg_ptr = 0;
21
+ DatabaseFinalization.unregister(this);
22
+ return ptr;
23
+ }
24
+ free() {
25
+ const ptr = this.__destroy_into_raw();
26
+ wasm.__wbg_database_free(ptr, 0);
27
+ }
28
+ /**
29
+ * Returns the number of edges in the database.
30
+ * @returns {number}
31
+ */
32
+ edgeCount() {
33
+ const ret = wasm.database_edgeCount(this.__wbg_ptr);
34
+ return ret >>> 0;
35
+ }
36
+ /**
37
+ * Executes a GQL query and returns results as an array of objects.
38
+ *
39
+ * Each row becomes a JavaScript object with column names as keys.
40
+ *
41
+ * ```js
42
+ * const results = db.execute("MATCH (p:Person) RETURN p.name, p.age");
43
+ * // [{name: "Alice", age: 30}, {name: "Bob", age: 25}]
44
+ * ```
45
+ * @param {string} query
46
+ * @returns {any}
47
+ */
48
+ execute(query) {
49
+ const ptr0 = passStringToWasm0(query, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
50
+ const len0 = WASM_VECTOR_LEN;
51
+ const ret = wasm.database_execute(this.__wbg_ptr, ptr0, len0);
52
+ if (ret[2]) {
53
+ throw takeFromExternrefTable0(ret[1]);
54
+ }
55
+ return takeFromExternrefTable0(ret[0]);
56
+ }
57
+ /**
58
+ * Executes a GQL query and returns raw columns, rows, and metadata.
59
+ *
60
+ * Returns `{ columns: string[], rows: any[][], executionTimeMs?: number }`.
61
+ * @param {string} query
62
+ * @returns {any}
63
+ */
64
+ executeRaw(query) {
65
+ const ptr0 = passStringToWasm0(query, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
66
+ const len0 = WASM_VECTOR_LEN;
67
+ const ret = wasm.database_executeRaw(this.__wbg_ptr, ptr0, len0);
68
+ if (ret[2]) {
69
+ throw takeFromExternrefTable0(ret[1]);
70
+ }
71
+ return takeFromExternrefTable0(ret[0]);
72
+ }
73
+ /**
74
+ * Executes a query using a specific query language.
75
+ *
76
+ * Supported languages: `"gql"`, `"cypher"`, `"sparql"`, `"gremlin"`, `"graphql"`.
77
+ * Languages require their corresponding feature flag to be enabled.
78
+ *
79
+ * ```js
80
+ * const results = db.executeWithLanguage(
81
+ * "MATCH (p:Person) RETURN p.name",
82
+ * "cypher"
83
+ * );
84
+ * ```
85
+ * @param {string} query
86
+ * @param {string} language
87
+ * @returns {any}
88
+ */
89
+ executeWithLanguage(query, language) {
90
+ const ptr0 = passStringToWasm0(query, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
91
+ const len0 = WASM_VECTOR_LEN;
92
+ const ptr1 = passStringToWasm0(language, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
93
+ const len1 = WASM_VECTOR_LEN;
94
+ const ret = wasm.database_executeWithLanguage(this.__wbg_ptr, ptr0, len0, ptr1, len1);
95
+ if (ret[2]) {
96
+ throw takeFromExternrefTable0(ret[1]);
97
+ }
98
+ return takeFromExternrefTable0(ret[0]);
99
+ }
100
+ /**
101
+ * Exports the database to a binary snapshot.
102
+ *
103
+ * Returns a `Uint8Array` that can be stored in IndexedDB, localStorage,
104
+ * or sent over the network. Restore with `Database.importSnapshot()`.
105
+ *
106
+ * ```js
107
+ * const bytes = db.exportSnapshot();
108
+ * // Store in IndexedDB, download as file, etc.
109
+ * ```
110
+ * @returns {Uint8Array}
111
+ */
112
+ exportSnapshot() {
113
+ const ret = wasm.database_exportSnapshot(this.__wbg_ptr);
114
+ if (ret[3]) {
115
+ throw takeFromExternrefTable0(ret[2]);
116
+ }
117
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
118
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
119
+ return v1;
120
+ }
121
+ /**
122
+ * Creates a database from a binary snapshot.
123
+ *
124
+ * The `data` must have been produced by `exportSnapshot()`.
125
+ *
126
+ * ```js
127
+ * const db = Database.importSnapshot(bytes);
128
+ * ```
129
+ * @param {Uint8Array} data
130
+ * @returns {Database}
131
+ */
132
+ static importSnapshot(data) {
133
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
134
+ const len0 = WASM_VECTOR_LEN;
135
+ const ret = wasm.database_importSnapshot(ptr0, len0);
136
+ if (ret[2]) {
137
+ throw takeFromExternrefTable0(ret[1]);
138
+ }
139
+ return Database.__wrap(ret[0]);
140
+ }
141
+ /**
142
+ * Creates a new in-memory database.
143
+ */
144
+ constructor() {
145
+ const ret = wasm.database_new();
146
+ if (ret[2]) {
147
+ throw takeFromExternrefTable0(ret[1]);
148
+ }
149
+ this.__wbg_ptr = ret[0] >>> 0;
150
+ DatabaseFinalization.register(this, this.__wbg_ptr, this);
151
+ return this;
152
+ }
153
+ /**
154
+ * Returns the number of nodes in the database.
155
+ * @returns {number}
156
+ */
157
+ nodeCount() {
158
+ const ret = wasm.database_nodeCount(this.__wbg_ptr);
159
+ return ret >>> 0;
160
+ }
161
+ /**
162
+ * Returns schema information about the database.
163
+ *
164
+ * Returns an object describing labels, edge types, and property keys.
165
+ *
166
+ * ```js
167
+ * const schema = db.schema();
168
+ * // { lpg: { labels: [...], edgeTypes: [...], propertyKeys: [...] } }
169
+ * ```
170
+ * @returns {any}
171
+ */
172
+ schema() {
173
+ const ret = wasm.database_schema(this.__wbg_ptr);
174
+ if (ret[2]) {
175
+ throw takeFromExternrefTable0(ret[1]);
176
+ }
177
+ return takeFromExternrefTable0(ret[0]);
178
+ }
179
+ /**
180
+ * Returns the Grafeo version.
181
+ * @returns {string}
182
+ */
183
+ static version() {
184
+ let deferred1_0;
185
+ let deferred1_1;
186
+ try {
187
+ const ret = wasm.database_version();
188
+ deferred1_0 = ret[0];
189
+ deferred1_1 = ret[1];
190
+ return getStringFromWasm0(ret[0], ret[1]);
191
+ } finally {
192
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
193
+ }
194
+ }
195
+ }
196
+ if (Symbol.dispose) Database.prototype[Symbol.dispose] = Database.prototype.free;
197
+
198
+ function __wbg_get_imports() {
199
+ const import0 = {
200
+ __proto__: null,
201
+ __wbg_Error_8c4e43fe74559d73: function(arg0, arg1) {
202
+ const ret = Error(getStringFromWasm0(arg0, arg1));
203
+ return ret;
204
+ },
205
+ __wbg_String_8f0eb39a4a4c2f66: function(arg0, arg1) {
206
+ const ret = String(arg1);
207
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
208
+ const len1 = WASM_VECTOR_LEN;
209
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
210
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
211
+ },
212
+ __wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
213
+ throw new Error(getStringFromWasm0(arg0, arg1));
214
+ },
215
+ __wbg_error_7534b8e9a36f1ab4: function(arg0, arg1) {
216
+ let deferred0_0;
217
+ let deferred0_1;
218
+ try {
219
+ deferred0_0 = arg0;
220
+ deferred0_1 = arg1;
221
+ console.error(getStringFromWasm0(arg0, arg1));
222
+ } finally {
223
+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
224
+ }
225
+ },
226
+ __wbg_getRandomValues_1c61fac11405ffdc: function() { return handleError(function (arg0, arg1) {
227
+ globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
228
+ }, arguments); },
229
+ __wbg_length_32ed9a279acd054c: function(arg0) {
230
+ const ret = arg0.length;
231
+ return ret;
232
+ },
233
+ __wbg_length_9a7876c9728a0979: function(arg0) {
234
+ const ret = arg0.length;
235
+ return ret;
236
+ },
237
+ __wbg_new_361308b2356cecd0: function() {
238
+ const ret = new Object();
239
+ return ret;
240
+ },
241
+ __wbg_new_3eb36ae241fe6f44: function() {
242
+ const ret = new Array();
243
+ return ret;
244
+ },
245
+ __wbg_new_8a6f238a6ece86ea: function() {
246
+ const ret = new Error();
247
+ return ret;
248
+ },
249
+ __wbg_new_with_length_1763c527b2923202: function(arg0) {
250
+ const ret = new Array(arg0 >>> 0);
251
+ return ret;
252
+ },
253
+ __wbg_new_with_length_63f2683cc2521026: function(arg0) {
254
+ const ret = new Float32Array(arg0 >>> 0);
255
+ return ret;
256
+ },
257
+ __wbg_new_with_length_a2c39cbe88fd8ff1: function(arg0) {
258
+ const ret = new Uint8Array(arg0 >>> 0);
259
+ return ret;
260
+ },
261
+ __wbg_set_3f1d0b984ed272ed: function(arg0, arg1, arg2) {
262
+ arg0[arg1] = arg2;
263
+ },
264
+ __wbg_set_6cb8631f80447a67: function() { return handleError(function (arg0, arg1, arg2) {
265
+ const ret = Reflect.set(arg0, arg1, arg2);
266
+ return ret;
267
+ }, arguments); },
268
+ __wbg_set_cc56eefd2dd91957: function(arg0, arg1, arg2) {
269
+ arg0.set(getArrayU8FromWasm0(arg1, arg2));
270
+ },
271
+ __wbg_set_f43e577aea94465b: function(arg0, arg1, arg2) {
272
+ arg0[arg1 >>> 0] = arg2;
273
+ },
274
+ __wbg_set_f8edeec46569cc70: function(arg0, arg1, arg2) {
275
+ arg0.set(getArrayF32FromWasm0(arg1, arg2));
276
+ },
277
+ __wbg_stack_0ed75d68575b0f3c: function(arg0, arg1) {
278
+ const ret = arg1.stack;
279
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
280
+ const len1 = WASM_VECTOR_LEN;
281
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
282
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
283
+ },
284
+ __wbindgen_cast_0000000000000001: function(arg0) {
285
+ // Cast intrinsic for `F64 -> Externref`.
286
+ const ret = arg0;
287
+ return ret;
288
+ },
289
+ __wbindgen_cast_0000000000000002: function(arg0, arg1) {
290
+ // Cast intrinsic for `Ref(String) -> Externref`.
291
+ const ret = getStringFromWasm0(arg0, arg1);
292
+ return ret;
293
+ },
294
+ __wbindgen_cast_0000000000000003: function(arg0) {
295
+ // Cast intrinsic for `U64 -> Externref`.
296
+ const ret = BigInt.asUintN(64, arg0);
297
+ return ret;
298
+ },
299
+ __wbindgen_init_externref_table: function() {
300
+ const table = wasm.__wbindgen_externrefs;
301
+ const offset = table.grow(4);
302
+ table.set(0, undefined);
303
+ table.set(offset + 0, undefined);
304
+ table.set(offset + 1, null);
305
+ table.set(offset + 2, true);
306
+ table.set(offset + 3, false);
307
+ },
308
+ };
309
+ return {
310
+ __proto__: null,
311
+ "./grafeo_wasm_bg.js": import0,
312
+ };
313
+ }
314
+
315
+ const DatabaseFinalization = (typeof FinalizationRegistry === 'undefined')
316
+ ? { register: () => {}, unregister: () => {} }
317
+ : new FinalizationRegistry(ptr => wasm.__wbg_database_free(ptr >>> 0, 1));
318
+
319
+ function addToExternrefTable0(obj) {
320
+ const idx = wasm.__externref_table_alloc();
321
+ wasm.__wbindgen_externrefs.set(idx, obj);
322
+ return idx;
323
+ }
324
+
325
+ function getArrayF32FromWasm0(ptr, len) {
326
+ ptr = ptr >>> 0;
327
+ return getFloat32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
328
+ }
329
+
330
+ function getArrayU8FromWasm0(ptr, len) {
331
+ ptr = ptr >>> 0;
332
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
333
+ }
334
+
335
+ let cachedDataViewMemory0 = null;
336
+ function getDataViewMemory0() {
337
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
338
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
339
+ }
340
+ return cachedDataViewMemory0;
341
+ }
342
+
343
+ let cachedFloat32ArrayMemory0 = null;
344
+ function getFloat32ArrayMemory0() {
345
+ if (cachedFloat32ArrayMemory0 === null || cachedFloat32ArrayMemory0.byteLength === 0) {
346
+ cachedFloat32ArrayMemory0 = new Float32Array(wasm.memory.buffer);
347
+ }
348
+ return cachedFloat32ArrayMemory0;
349
+ }
350
+
351
+ function getStringFromWasm0(ptr, len) {
352
+ ptr = ptr >>> 0;
353
+ return decodeText(ptr, len);
354
+ }
355
+
356
+ let cachedUint8ArrayMemory0 = null;
357
+ function getUint8ArrayMemory0() {
358
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
359
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
360
+ }
361
+ return cachedUint8ArrayMemory0;
362
+ }
363
+
364
+ function handleError(f, args) {
365
+ try {
366
+ return f.apply(this, args);
367
+ } catch (e) {
368
+ const idx = addToExternrefTable0(e);
369
+ wasm.__wbindgen_exn_store(idx);
370
+ }
371
+ }
372
+
373
+ function passArray8ToWasm0(arg, malloc) {
374
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
375
+ getUint8ArrayMemory0().set(arg, ptr / 1);
376
+ WASM_VECTOR_LEN = arg.length;
377
+ return ptr;
378
+ }
379
+
380
+ function passStringToWasm0(arg, malloc, realloc) {
381
+ if (realloc === undefined) {
382
+ const buf = cachedTextEncoder.encode(arg);
383
+ const ptr = malloc(buf.length, 1) >>> 0;
384
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
385
+ WASM_VECTOR_LEN = buf.length;
386
+ return ptr;
387
+ }
388
+
389
+ let len = arg.length;
390
+ let ptr = malloc(len, 1) >>> 0;
391
+
392
+ const mem = getUint8ArrayMemory0();
393
+
394
+ let offset = 0;
395
+
396
+ for (; offset < len; offset++) {
397
+ const code = arg.charCodeAt(offset);
398
+ if (code > 0x7F) break;
399
+ mem[ptr + offset] = code;
400
+ }
401
+ if (offset !== len) {
402
+ if (offset !== 0) {
403
+ arg = arg.slice(offset);
404
+ }
405
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
406
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
407
+ const ret = cachedTextEncoder.encodeInto(arg, view);
408
+
409
+ offset += ret.written;
410
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
411
+ }
412
+
413
+ WASM_VECTOR_LEN = offset;
414
+ return ptr;
415
+ }
416
+
417
+ function takeFromExternrefTable0(idx) {
418
+ const value = wasm.__wbindgen_externrefs.get(idx);
419
+ wasm.__externref_table_dealloc(idx);
420
+ return value;
421
+ }
422
+
423
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
424
+ cachedTextDecoder.decode();
425
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
426
+ let numBytesDecoded = 0;
427
+ function decodeText(ptr, len) {
428
+ numBytesDecoded += len;
429
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
430
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
431
+ cachedTextDecoder.decode();
432
+ numBytesDecoded = len;
433
+ }
434
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
435
+ }
436
+
437
+ const cachedTextEncoder = new TextEncoder();
438
+
439
+ if (!('encodeInto' in cachedTextEncoder)) {
440
+ cachedTextEncoder.encodeInto = function (arg, view) {
441
+ const buf = cachedTextEncoder.encode(arg);
442
+ view.set(buf);
443
+ return {
444
+ read: arg.length,
445
+ written: buf.length
446
+ };
447
+ };
448
+ }
449
+
450
+ let WASM_VECTOR_LEN = 0;
451
+
452
+ let wasmModule, wasm;
453
+ function __wbg_finalize_init(instance, module) {
454
+ wasm = instance.exports;
455
+ wasmModule = module;
456
+ cachedDataViewMemory0 = null;
457
+ cachedFloat32ArrayMemory0 = null;
458
+ cachedUint8ArrayMemory0 = null;
459
+ wasm.__wbindgen_start();
460
+ return wasm;
461
+ }
462
+
463
+ async function __wbg_load(module, imports) {
464
+ if (typeof Response === 'function' && module instanceof Response) {
465
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
466
+ try {
467
+ return await WebAssembly.instantiateStreaming(module, imports);
468
+ } catch (e) {
469
+ const validResponse = module.ok && expectedResponseType(module.type);
470
+
471
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
472
+ 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);
473
+
474
+ } else { throw e; }
475
+ }
476
+ }
477
+
478
+ const bytes = await module.arrayBuffer();
479
+ return await WebAssembly.instantiate(bytes, imports);
480
+ } else {
481
+ const instance = await WebAssembly.instantiate(module, imports);
482
+
483
+ if (instance instanceof WebAssembly.Instance) {
484
+ return { instance, module };
485
+ } else {
486
+ return instance;
487
+ }
488
+ }
489
+
490
+ function expectedResponseType(type) {
491
+ switch (type) {
492
+ case 'basic': case 'cors': case 'default': return true;
493
+ }
494
+ return false;
495
+ }
496
+ }
497
+
498
+ function initSync(module) {
499
+ if (wasm !== undefined) return wasm;
500
+
501
+
502
+ if (module !== undefined) {
503
+ if (Object.getPrototypeOf(module) === Object.prototype) {
504
+ ({module} = module)
505
+ } else {
506
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
507
+ }
508
+ }
509
+
510
+ const imports = __wbg_get_imports();
511
+ if (!(module instanceof WebAssembly.Module)) {
512
+ module = new WebAssembly.Module(module);
513
+ }
514
+ const instance = new WebAssembly.Instance(module, imports);
515
+ return __wbg_finalize_init(instance, module);
516
+ }
517
+
518
+ async function __wbg_init(module_or_path) {
519
+ if (wasm !== undefined) return wasm;
520
+
521
+
522
+ if (module_or_path !== undefined) {
523
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
524
+ ({module_or_path} = module_or_path)
525
+ } else {
526
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
527
+ }
528
+ }
529
+
530
+ if (module_or_path === undefined) {
531
+ module_or_path = new URL('grafeo_wasm_bg.wasm', import.meta.url);
532
+ }
533
+ const imports = __wbg_get_imports();
534
+
535
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
536
+ module_or_path = fetch(module_or_path);
537
+ }
538
+
539
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
540
+
541
+ return __wbg_finalize_init(instance, module);
542
+ }
543
+
544
+ export { initSync, __wbg_init as default };
Binary file
@@ -0,0 +1,22 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export const memory: WebAssembly.Memory;
4
+ export const __wbg_database_free: (a: number, b: number) => void;
5
+ export const database_edgeCount: (a: number) => number;
6
+ export const database_execute: (a: number, b: number, c: number) => [number, number, number];
7
+ export const database_executeRaw: (a: number, b: number, c: number) => [number, number, number];
8
+ export const database_executeWithLanguage: (a: number, b: number, c: number, d: number, e: number) => [number, number, number];
9
+ export const database_exportSnapshot: (a: number) => [number, number, number, number];
10
+ export const database_importSnapshot: (a: number, b: number) => [number, number, number];
11
+ export const database_new: () => [number, number, number];
12
+ export const database_nodeCount: (a: number) => number;
13
+ export const database_schema: (a: number) => [number, number, number];
14
+ export const database_version: () => [number, number];
15
+ export const __wbindgen_malloc: (a: number, b: number) => number;
16
+ export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
17
+ export const __wbindgen_free: (a: number, b: number, c: number) => void;
18
+ export const __wbindgen_exn_store: (a: number) => void;
19
+ export const __externref_table_alloc: () => number;
20
+ export const __wbindgen_externrefs: WebAssembly.Table;
21
+ export const __externref_table_dealloc: (a: number) => void;
22
+ export const __wbindgen_start: () => void;
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@grafeo-db/wasm",
3
- "version": "0.1.4",
3
+ "type": "module",
4
+ "version": "0.5.0",
4
5
  "description": "WebAssembly bindings for Grafeo - a high-performance embeddable graph database",
5
6
  "keywords": [
6
7
  "graph",
@@ -12,8 +13,8 @@
12
13
  "wasm",
13
14
  "webassembly"
14
15
  ],
15
- "author": "StevenBtw",
16
- "license": "MIT",
16
+ "author": "S.T. Grond",
17
+ "license": "Apache-2.0",
17
18
  "repository": {
18
19
  "type": "git",
19
20
  "url": "https://github.com/GrafeoDB/grafeo.git",
@@ -28,6 +29,11 @@
28
29
  "files": [
29
30
  "grafeo_wasm.js",
30
31
  "grafeo_wasm.d.ts",
31
- "grafeo_wasm_bg.wasm"
32
+ "grafeo_wasm_bg.wasm",
33
+ "grafeo_wasm_bg.wasm.d.ts"
34
+ ],
35
+ "sideEffects": [
36
+ "./grafeo_wasm.js",
37
+ "./snippets/*"
32
38
  ]
33
39
  }