@loradb/lora-wasm 0.4.0 → 0.5.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 +71 -7
- package/dist/index.d.ts +71 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +169 -12
- package/dist/index.js.map +1 -1
- package/dist/snapshot.d.ts +22 -0
- package/dist/snapshot.d.ts.map +1 -0
- package/dist/snapshot.js +107 -0
- package/dist/snapshot.js.map +1 -0
- package/dist/worker-client.d.ts +28 -0
- package/dist/worker-client.d.ts.map +1 -1
- package/dist/worker-client.js +100 -0
- package/dist/worker-client.js.map +1 -1
- package/dist/worker-protocol.d.ts +24 -1
- package/dist/worker-protocol.d.ts.map +1 -1
- package/dist/worker.js +52 -0
- package/dist/worker.js.map +1 -1
- package/package.json +1 -1
- package/pkg-bundler/README.md +71 -7
- package/pkg-bundler/lora_wasm.d.ts +17 -0
- package/pkg-bundler/lora_wasm_bg.js +82 -0
- package/pkg-bundler/lora_wasm_bg.wasm +0 -0
- package/pkg-bundler/lora_wasm_bg.wasm.d.ts +6 -0
- package/pkg-bundler/package.json +1 -1
- package/pkg-node/README.md +71 -7
- package/pkg-node/lora_wasm.d.ts +17 -0
- package/pkg-node/lora_wasm.js +83 -0
- package/pkg-node/lora_wasm_bg.wasm +0 -0
- package/pkg-node/lora_wasm_bg.wasm.d.ts +6 -0
- package/pkg-node/package.json +1 -1
- package/pkg-web/README.md +71 -7
- package/pkg-web/lora_wasm.d.ts +23 -0
- package/pkg-web/lora_wasm.js +82 -0
- package/pkg-web/lora_wasm_bg.wasm +0 -0
- package/pkg-web/lora_wasm_bg.wasm.d.ts +6 -0
- package/pkg-web/package.json +1 -1
package/pkg-node/README.md
CHANGED
|
@@ -37,19 +37,24 @@ npm run test:browser
|
|
|
37
37
|
npm run pack:dry
|
|
38
38
|
```
|
|
39
39
|
|
|
40
|
-
##
|
|
40
|
+
## Execution modes
|
|
41
41
|
|
|
42
|
-
### 1.
|
|
42
|
+
### 1. Default: Worker first, main-thread fallback
|
|
43
43
|
|
|
44
44
|
`lora-wasm` is **async-only** — the sole initialization pattern is
|
|
45
45
|
`createDatabase()`, which bootstraps the WASM module on first call.
|
|
46
46
|
There is no synchronous constructor and no `Database.create()`
|
|
47
47
|
static; `Database` is a type-only export.
|
|
48
48
|
|
|
49
|
+
In browser-like hosts, `createDatabase()` tries to spawn the packaged module
|
|
50
|
+
Worker first and pings it before returning. If the Worker cannot be created or
|
|
51
|
+
fails during startup, the package emits one `console.warn` and falls back to
|
|
52
|
+
the in-process WASM engine so the app can still run.
|
|
53
|
+
|
|
49
54
|
```ts
|
|
50
55
|
import { createDatabase, isNode } from "lora-wasm";
|
|
51
56
|
|
|
52
|
-
const db = await createDatabase();
|
|
57
|
+
const db = await createDatabase(); // Worker-backed in browsers when possible
|
|
53
58
|
await db.execute("CREATE (:Person {name: $n})", { n: "Alice" });
|
|
54
59
|
|
|
55
60
|
const r = await db.execute("MATCH (n:Person) RETURN n");
|
|
@@ -58,7 +63,36 @@ for (const row of r.rows) {
|
|
|
58
63
|
}
|
|
59
64
|
```
|
|
60
65
|
|
|
61
|
-
|
|
66
|
+
To force the in-process engine:
|
|
67
|
+
|
|
68
|
+
```ts
|
|
69
|
+
const db = await createDatabase({ runtime: "main-thread" });
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
To require Worker startup instead of falling back:
|
|
73
|
+
|
|
74
|
+
```ts
|
|
75
|
+
const db = await createDatabase({ runtime: "worker" });
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
To disable the fallback warning:
|
|
79
|
+
|
|
80
|
+
```ts
|
|
81
|
+
const db = await createDatabase({ warnOnFallback: false });
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### 2. Explicit main-thread WASM
|
|
85
|
+
|
|
86
|
+
```ts
|
|
87
|
+
import { createMainThreadDatabase } from "lora-wasm";
|
|
88
|
+
|
|
89
|
+
const db = await createMainThreadDatabase();
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### 3. Custom Web Worker
|
|
93
|
+
|
|
94
|
+
Use this when you need to control the Worker URL, lifecycle, bundler entry, or
|
|
95
|
+
pooling strategy.
|
|
62
96
|
|
|
63
97
|
```ts
|
|
64
98
|
import { createWorkerDatabase } from "lora-wasm/worker-client";
|
|
@@ -75,11 +109,42 @@ const { rows } = await db.execute("MATCH (n) RETURN n.n AS n");
|
|
|
75
109
|
The worker entry (`ts/worker.ts`) hosts the WASM module. The main thread only
|
|
76
110
|
posts messages, so long-running queries never block the event loop / UI.
|
|
77
111
|
|
|
78
|
-
###
|
|
112
|
+
### 4. In-process but typed like the worker (advanced)
|
|
79
113
|
|
|
80
114
|
The same `createWorkerDatabase` signature accepts any `WorkerLike` object —
|
|
81
115
|
useful for tests and for swapping execution backends behind the same API.
|
|
82
116
|
|
|
117
|
+
## Snapshots
|
|
118
|
+
|
|
119
|
+
WASM has no filesystem access, so `saveSnapshot()` defaults to a `Uint8Array`.
|
|
120
|
+
It also accepts typed formats: `"base64"` returns base64 text, `"blob"` returns
|
|
121
|
+
a `Blob`, and `"download"` triggers a browser download from the main thread.
|
|
122
|
+
|
|
123
|
+
`loadSnapshot` accepts a `WasmSnapshotSource`: `Uint8Array`, `ArrayBuffer`,
|
|
124
|
+
`Blob`/`File`, `Response`, web `ReadableStream`, string URL, or `URL`. It does
|
|
125
|
+
not include Node `Buffer`; use `Uint8Array` bytes when running the WASM package
|
|
126
|
+
from Node.
|
|
127
|
+
|
|
128
|
+
```ts
|
|
129
|
+
import { createDatabase } from "lora-wasm";
|
|
130
|
+
|
|
131
|
+
const db = await createDatabase();
|
|
132
|
+
await db.execute("CREATE (:Person {name: 'Alice'})");
|
|
133
|
+
|
|
134
|
+
const bytes = await db.saveSnapshotToBytes();
|
|
135
|
+
const sameBytes = await db.saveSnapshot("binary");
|
|
136
|
+
const blob = await db.saveSnapshot({ format: "blob" });
|
|
137
|
+
await db.saveSnapshot({ format: "download", filename: "graph.lorasnap" });
|
|
138
|
+
|
|
139
|
+
await db.loadSnapshot(bytes);
|
|
140
|
+
await db.loadSnapshot(blob);
|
|
141
|
+
await db.loadSnapshot(new Response(bytes).body!);
|
|
142
|
+
await db.loadSnapshot(new URL("/graph.lorasnap", location.href));
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
`loadSnapshotFromBytes(bytes)` remains available for the narrow
|
|
146
|
+
`Uint8Array`-only path.
|
|
147
|
+
|
|
83
148
|
## Typed value model
|
|
84
149
|
|
|
85
150
|
| TS type | Runtime shape |
|
|
@@ -140,8 +205,7 @@ public surface — consumers can swap backends without rewriting types.
|
|
|
140
205
|
millisecond-granular, so the nanosecond field on returned values is
|
|
141
206
|
zero below the millisecond boundary.
|
|
142
207
|
- Engine errors cross the worker boundary as `LoraError` with a
|
|
143
|
-
narrowed `code`; the engine does not currently
|
|
144
|
-
or offer cancellation.
|
|
208
|
+
narrowed `code`; the engine does not currently offer query cancellation.
|
|
145
209
|
|
|
146
210
|
## Feasibility assessment
|
|
147
211
|
|
package/pkg-node/lora_wasm.d.ts
CHANGED
|
@@ -11,6 +11,16 @@ export function init(): void;
|
|
|
11
11
|
export class WasmDatabase {
|
|
12
12
|
free(): void;
|
|
13
13
|
nodeCount(): number;
|
|
14
|
+
/**
|
|
15
|
+
* Open a true native row stream. Rows are pulled from the Rust executor
|
|
16
|
+
* one `next()` call at a time.
|
|
17
|
+
*/
|
|
18
|
+
openStream(query: string, params: any): WasmQueryStream;
|
|
19
|
+
/**
|
|
20
|
+
* Execute an array of `{ query, params? }` statements inside one native
|
|
21
|
+
* transaction. Returns an array of query results in statement order.
|
|
22
|
+
*/
|
|
23
|
+
transaction(statements: any, mode?: string | null): any;
|
|
14
24
|
relationshipCount(): number;
|
|
15
25
|
/**
|
|
16
26
|
* Serialize the graph into a byte buffer. The caller is responsible for
|
|
@@ -39,3 +49,10 @@ export class WasmDatabase {
|
|
|
39
49
|
*/
|
|
40
50
|
execute(query: string, params: any): any;
|
|
41
51
|
}
|
|
52
|
+
export class WasmQueryStream {
|
|
53
|
+
private constructor();
|
|
54
|
+
free(): void;
|
|
55
|
+
next(): any;
|
|
56
|
+
close(): void;
|
|
57
|
+
columns(): any;
|
|
58
|
+
}
|
package/pkg-node/lora_wasm.js
CHANGED
|
@@ -222,6 +222,38 @@ class WasmDatabase {
|
|
|
222
222
|
const ret = wasm.wasmdatabase_nodeCount(this.__wbg_ptr);
|
|
223
223
|
return ret >>> 0;
|
|
224
224
|
}
|
|
225
|
+
/**
|
|
226
|
+
* Open a true native row stream. Rows are pulled from the Rust executor
|
|
227
|
+
* one `next()` call at a time.
|
|
228
|
+
* @param {string} query
|
|
229
|
+
* @param {any} params
|
|
230
|
+
* @returns {WasmQueryStream}
|
|
231
|
+
*/
|
|
232
|
+
openStream(query, params) {
|
|
233
|
+
const ptr0 = passStringToWasm0(query, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
234
|
+
const len0 = WASM_VECTOR_LEN;
|
|
235
|
+
const ret = wasm.wasmdatabase_openStream(this.__wbg_ptr, ptr0, len0, params);
|
|
236
|
+
if (ret[2]) {
|
|
237
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
238
|
+
}
|
|
239
|
+
return WasmQueryStream.__wrap(ret[0]);
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Execute an array of `{ query, params? }` statements inside one native
|
|
243
|
+
* transaction. Returns an array of query results in statement order.
|
|
244
|
+
* @param {any} statements
|
|
245
|
+
* @param {string | null} [mode]
|
|
246
|
+
* @returns {any}
|
|
247
|
+
*/
|
|
248
|
+
transaction(statements, mode) {
|
|
249
|
+
var ptr0 = isLikeNone(mode) ? 0 : passStringToWasm0(mode, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
250
|
+
var len0 = WASM_VECTOR_LEN;
|
|
251
|
+
const ret = wasm.wasmdatabase_transaction(this.__wbg_ptr, statements, ptr0, len0);
|
|
252
|
+
if (ret[2]) {
|
|
253
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
254
|
+
}
|
|
255
|
+
return takeFromExternrefTable0(ret[0]);
|
|
256
|
+
}
|
|
225
257
|
/**
|
|
226
258
|
* @returns {number}
|
|
227
259
|
*/
|
|
@@ -295,6 +327,57 @@ class WasmDatabase {
|
|
|
295
327
|
}
|
|
296
328
|
module.exports.WasmDatabase = WasmDatabase;
|
|
297
329
|
|
|
330
|
+
const WasmQueryStreamFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
331
|
+
? { register: () => {}, unregister: () => {} }
|
|
332
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmquerystream_free(ptr >>> 0, 1));
|
|
333
|
+
|
|
334
|
+
class WasmQueryStream {
|
|
335
|
+
|
|
336
|
+
static __wrap(ptr) {
|
|
337
|
+
ptr = ptr >>> 0;
|
|
338
|
+
const obj = Object.create(WasmQueryStream.prototype);
|
|
339
|
+
obj.__wbg_ptr = ptr;
|
|
340
|
+
WasmQueryStreamFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
341
|
+
return obj;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
__destroy_into_raw() {
|
|
345
|
+
const ptr = this.__wbg_ptr;
|
|
346
|
+
this.__wbg_ptr = 0;
|
|
347
|
+
WasmQueryStreamFinalization.unregister(this);
|
|
348
|
+
return ptr;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
free() {
|
|
352
|
+
const ptr = this.__destroy_into_raw();
|
|
353
|
+
wasm.__wbg_wasmquerystream_free(ptr, 0);
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* @returns {any}
|
|
357
|
+
*/
|
|
358
|
+
next() {
|
|
359
|
+
const ret = wasm.wasmquerystream_next(this.__wbg_ptr);
|
|
360
|
+
if (ret[2]) {
|
|
361
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
362
|
+
}
|
|
363
|
+
return takeFromExternrefTable0(ret[0]);
|
|
364
|
+
}
|
|
365
|
+
close() {
|
|
366
|
+
wasm.wasmquerystream_close(this.__wbg_ptr);
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* @returns {any}
|
|
370
|
+
*/
|
|
371
|
+
columns() {
|
|
372
|
+
const ret = wasm.wasmquerystream_columns(this.__wbg_ptr);
|
|
373
|
+
if (ret[2]) {
|
|
374
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
375
|
+
}
|
|
376
|
+
return takeFromExternrefTable0(ret[0]);
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
module.exports.WasmQueryStream = WasmQueryStream;
|
|
380
|
+
|
|
298
381
|
module.exports.__wbg_String_8f0eb39a4a4c2f66 = function(arg0, arg1) {
|
|
299
382
|
const ret = String(arg1);
|
|
300
383
|
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
Binary file
|
|
@@ -2,13 +2,19 @@
|
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
4
|
export const __wbg_wasmdatabase_free: (a: number, b: number) => void;
|
|
5
|
+
export const __wbg_wasmquerystream_free: (a: number, b: number) => void;
|
|
5
6
|
export const wasmdatabase_clear: (a: number) => void;
|
|
6
7
|
export const wasmdatabase_execute: (a: number, b: number, c: number, d: any) => [number, number, number];
|
|
7
8
|
export const wasmdatabase_loadSnapshotFromBytes: (a: number, b: number, c: number) => [number, number, number];
|
|
8
9
|
export const wasmdatabase_new: () => number;
|
|
9
10
|
export const wasmdatabase_nodeCount: (a: number) => number;
|
|
11
|
+
export const wasmdatabase_openStream: (a: number, b: number, c: number, d: any) => [number, number, number];
|
|
10
12
|
export const wasmdatabase_relationshipCount: (a: number) => number;
|
|
11
13
|
export const wasmdatabase_saveSnapshotToBytes: (a: number) => [number, number, number, number];
|
|
14
|
+
export const wasmdatabase_transaction: (a: number, b: any, c: number, d: number) => [number, number, number];
|
|
15
|
+
export const wasmquerystream_close: (a: number) => void;
|
|
16
|
+
export const wasmquerystream_columns: (a: number) => [number, number, number];
|
|
17
|
+
export const wasmquerystream_next: (a: number) => [number, number, number];
|
|
12
18
|
export const init: () => void;
|
|
13
19
|
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
14
20
|
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
package/pkg-node/package.json
CHANGED
package/pkg-web/README.md
CHANGED
|
@@ -37,19 +37,24 @@ npm run test:browser
|
|
|
37
37
|
npm run pack:dry
|
|
38
38
|
```
|
|
39
39
|
|
|
40
|
-
##
|
|
40
|
+
## Execution modes
|
|
41
41
|
|
|
42
|
-
### 1.
|
|
42
|
+
### 1. Default: Worker first, main-thread fallback
|
|
43
43
|
|
|
44
44
|
`lora-wasm` is **async-only** — the sole initialization pattern is
|
|
45
45
|
`createDatabase()`, which bootstraps the WASM module on first call.
|
|
46
46
|
There is no synchronous constructor and no `Database.create()`
|
|
47
47
|
static; `Database` is a type-only export.
|
|
48
48
|
|
|
49
|
+
In browser-like hosts, `createDatabase()` tries to spawn the packaged module
|
|
50
|
+
Worker first and pings it before returning. If the Worker cannot be created or
|
|
51
|
+
fails during startup, the package emits one `console.warn` and falls back to
|
|
52
|
+
the in-process WASM engine so the app can still run.
|
|
53
|
+
|
|
49
54
|
```ts
|
|
50
55
|
import { createDatabase, isNode } from "lora-wasm";
|
|
51
56
|
|
|
52
|
-
const db = await createDatabase();
|
|
57
|
+
const db = await createDatabase(); // Worker-backed in browsers when possible
|
|
53
58
|
await db.execute("CREATE (:Person {name: $n})", { n: "Alice" });
|
|
54
59
|
|
|
55
60
|
const r = await db.execute("MATCH (n:Person) RETURN n");
|
|
@@ -58,7 +63,36 @@ for (const row of r.rows) {
|
|
|
58
63
|
}
|
|
59
64
|
```
|
|
60
65
|
|
|
61
|
-
|
|
66
|
+
To force the in-process engine:
|
|
67
|
+
|
|
68
|
+
```ts
|
|
69
|
+
const db = await createDatabase({ runtime: "main-thread" });
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
To require Worker startup instead of falling back:
|
|
73
|
+
|
|
74
|
+
```ts
|
|
75
|
+
const db = await createDatabase({ runtime: "worker" });
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
To disable the fallback warning:
|
|
79
|
+
|
|
80
|
+
```ts
|
|
81
|
+
const db = await createDatabase({ warnOnFallback: false });
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### 2. Explicit main-thread WASM
|
|
85
|
+
|
|
86
|
+
```ts
|
|
87
|
+
import { createMainThreadDatabase } from "lora-wasm";
|
|
88
|
+
|
|
89
|
+
const db = await createMainThreadDatabase();
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### 3. Custom Web Worker
|
|
93
|
+
|
|
94
|
+
Use this when you need to control the Worker URL, lifecycle, bundler entry, or
|
|
95
|
+
pooling strategy.
|
|
62
96
|
|
|
63
97
|
```ts
|
|
64
98
|
import { createWorkerDatabase } from "lora-wasm/worker-client";
|
|
@@ -75,11 +109,42 @@ const { rows } = await db.execute("MATCH (n) RETURN n.n AS n");
|
|
|
75
109
|
The worker entry (`ts/worker.ts`) hosts the WASM module. The main thread only
|
|
76
110
|
posts messages, so long-running queries never block the event loop / UI.
|
|
77
111
|
|
|
78
|
-
###
|
|
112
|
+
### 4. In-process but typed like the worker (advanced)
|
|
79
113
|
|
|
80
114
|
The same `createWorkerDatabase` signature accepts any `WorkerLike` object —
|
|
81
115
|
useful for tests and for swapping execution backends behind the same API.
|
|
82
116
|
|
|
117
|
+
## Snapshots
|
|
118
|
+
|
|
119
|
+
WASM has no filesystem access, so `saveSnapshot()` defaults to a `Uint8Array`.
|
|
120
|
+
It also accepts typed formats: `"base64"` returns base64 text, `"blob"` returns
|
|
121
|
+
a `Blob`, and `"download"` triggers a browser download from the main thread.
|
|
122
|
+
|
|
123
|
+
`loadSnapshot` accepts a `WasmSnapshotSource`: `Uint8Array`, `ArrayBuffer`,
|
|
124
|
+
`Blob`/`File`, `Response`, web `ReadableStream`, string URL, or `URL`. It does
|
|
125
|
+
not include Node `Buffer`; use `Uint8Array` bytes when running the WASM package
|
|
126
|
+
from Node.
|
|
127
|
+
|
|
128
|
+
```ts
|
|
129
|
+
import { createDatabase } from "lora-wasm";
|
|
130
|
+
|
|
131
|
+
const db = await createDatabase();
|
|
132
|
+
await db.execute("CREATE (:Person {name: 'Alice'})");
|
|
133
|
+
|
|
134
|
+
const bytes = await db.saveSnapshotToBytes();
|
|
135
|
+
const sameBytes = await db.saveSnapshot("binary");
|
|
136
|
+
const blob = await db.saveSnapshot({ format: "blob" });
|
|
137
|
+
await db.saveSnapshot({ format: "download", filename: "graph.lorasnap" });
|
|
138
|
+
|
|
139
|
+
await db.loadSnapshot(bytes);
|
|
140
|
+
await db.loadSnapshot(blob);
|
|
141
|
+
await db.loadSnapshot(new Response(bytes).body!);
|
|
142
|
+
await db.loadSnapshot(new URL("/graph.lorasnap", location.href));
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
`loadSnapshotFromBytes(bytes)` remains available for the narrow
|
|
146
|
+
`Uint8Array`-only path.
|
|
147
|
+
|
|
83
148
|
## Typed value model
|
|
84
149
|
|
|
85
150
|
| TS type | Runtime shape |
|
|
@@ -140,8 +205,7 @@ public surface — consumers can swap backends without rewriting types.
|
|
|
140
205
|
millisecond-granular, so the nanosecond field on returned values is
|
|
141
206
|
zero below the millisecond boundary.
|
|
142
207
|
- Engine errors cross the worker boundary as `LoraError` with a
|
|
143
|
-
narrowed `code`; the engine does not currently
|
|
144
|
-
or offer cancellation.
|
|
208
|
+
narrowed `code`; the engine does not currently offer query cancellation.
|
|
145
209
|
|
|
146
210
|
## Feasibility assessment
|
|
147
211
|
|
package/pkg-web/lora_wasm.d.ts
CHANGED
|
@@ -11,6 +11,16 @@ export function init(): void;
|
|
|
11
11
|
export class WasmDatabase {
|
|
12
12
|
free(): void;
|
|
13
13
|
nodeCount(): number;
|
|
14
|
+
/**
|
|
15
|
+
* Open a true native row stream. Rows are pulled from the Rust executor
|
|
16
|
+
* one `next()` call at a time.
|
|
17
|
+
*/
|
|
18
|
+
openStream(query: string, params: any): WasmQueryStream;
|
|
19
|
+
/**
|
|
20
|
+
* Execute an array of `{ query, params? }` statements inside one native
|
|
21
|
+
* transaction. Returns an array of query results in statement order.
|
|
22
|
+
*/
|
|
23
|
+
transaction(statements: any, mode?: string | null): any;
|
|
14
24
|
relationshipCount(): number;
|
|
15
25
|
/**
|
|
16
26
|
* Serialize the graph into a byte buffer. The caller is responsible for
|
|
@@ -39,19 +49,32 @@ export class WasmDatabase {
|
|
|
39
49
|
*/
|
|
40
50
|
execute(query: string, params: any): any;
|
|
41
51
|
}
|
|
52
|
+
export class WasmQueryStream {
|
|
53
|
+
private constructor();
|
|
54
|
+
free(): void;
|
|
55
|
+
next(): any;
|
|
56
|
+
close(): void;
|
|
57
|
+
columns(): any;
|
|
58
|
+
}
|
|
42
59
|
|
|
43
60
|
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
44
61
|
|
|
45
62
|
export interface InitOutput {
|
|
46
63
|
readonly memory: WebAssembly.Memory;
|
|
47
64
|
readonly __wbg_wasmdatabase_free: (a: number, b: number) => void;
|
|
65
|
+
readonly __wbg_wasmquerystream_free: (a: number, b: number) => void;
|
|
48
66
|
readonly wasmdatabase_clear: (a: number) => void;
|
|
49
67
|
readonly wasmdatabase_execute: (a: number, b: number, c: number, d: any) => [number, number, number];
|
|
50
68
|
readonly wasmdatabase_loadSnapshotFromBytes: (a: number, b: number, c: number) => [number, number, number];
|
|
51
69
|
readonly wasmdatabase_new: () => number;
|
|
52
70
|
readonly wasmdatabase_nodeCount: (a: number) => number;
|
|
71
|
+
readonly wasmdatabase_openStream: (a: number, b: number, c: number, d: any) => [number, number, number];
|
|
53
72
|
readonly wasmdatabase_relationshipCount: (a: number) => number;
|
|
54
73
|
readonly wasmdatabase_saveSnapshotToBytes: (a: number) => [number, number, number, number];
|
|
74
|
+
readonly wasmdatabase_transaction: (a: number, b: any, c: number, d: number) => [number, number, number];
|
|
75
|
+
readonly wasmquerystream_close: (a: number) => void;
|
|
76
|
+
readonly wasmquerystream_columns: (a: number) => [number, number, number];
|
|
77
|
+
readonly wasmquerystream_next: (a: number) => [number, number, number];
|
|
55
78
|
readonly init: () => void;
|
|
56
79
|
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
57
80
|
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
package/pkg-web/lora_wasm.js
CHANGED
|
@@ -218,6 +218,38 @@ export class WasmDatabase {
|
|
|
218
218
|
const ret = wasm.wasmdatabase_nodeCount(this.__wbg_ptr);
|
|
219
219
|
return ret >>> 0;
|
|
220
220
|
}
|
|
221
|
+
/**
|
|
222
|
+
* Open a true native row stream. Rows are pulled from the Rust executor
|
|
223
|
+
* one `next()` call at a time.
|
|
224
|
+
* @param {string} query
|
|
225
|
+
* @param {any} params
|
|
226
|
+
* @returns {WasmQueryStream}
|
|
227
|
+
*/
|
|
228
|
+
openStream(query, params) {
|
|
229
|
+
const ptr0 = passStringToWasm0(query, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
230
|
+
const len0 = WASM_VECTOR_LEN;
|
|
231
|
+
const ret = wasm.wasmdatabase_openStream(this.__wbg_ptr, ptr0, len0, params);
|
|
232
|
+
if (ret[2]) {
|
|
233
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
234
|
+
}
|
|
235
|
+
return WasmQueryStream.__wrap(ret[0]);
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Execute an array of `{ query, params? }` statements inside one native
|
|
239
|
+
* transaction. Returns an array of query results in statement order.
|
|
240
|
+
* @param {any} statements
|
|
241
|
+
* @param {string | null} [mode]
|
|
242
|
+
* @returns {any}
|
|
243
|
+
*/
|
|
244
|
+
transaction(statements, mode) {
|
|
245
|
+
var ptr0 = isLikeNone(mode) ? 0 : passStringToWasm0(mode, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
246
|
+
var len0 = WASM_VECTOR_LEN;
|
|
247
|
+
const ret = wasm.wasmdatabase_transaction(this.__wbg_ptr, statements, ptr0, len0);
|
|
248
|
+
if (ret[2]) {
|
|
249
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
250
|
+
}
|
|
251
|
+
return takeFromExternrefTable0(ret[0]);
|
|
252
|
+
}
|
|
221
253
|
/**
|
|
222
254
|
* @returns {number}
|
|
223
255
|
*/
|
|
@@ -290,6 +322,56 @@ export class WasmDatabase {
|
|
|
290
322
|
}
|
|
291
323
|
}
|
|
292
324
|
|
|
325
|
+
const WasmQueryStreamFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
326
|
+
? { register: () => {}, unregister: () => {} }
|
|
327
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmquerystream_free(ptr >>> 0, 1));
|
|
328
|
+
|
|
329
|
+
export class WasmQueryStream {
|
|
330
|
+
|
|
331
|
+
static __wrap(ptr) {
|
|
332
|
+
ptr = ptr >>> 0;
|
|
333
|
+
const obj = Object.create(WasmQueryStream.prototype);
|
|
334
|
+
obj.__wbg_ptr = ptr;
|
|
335
|
+
WasmQueryStreamFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
336
|
+
return obj;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
__destroy_into_raw() {
|
|
340
|
+
const ptr = this.__wbg_ptr;
|
|
341
|
+
this.__wbg_ptr = 0;
|
|
342
|
+
WasmQueryStreamFinalization.unregister(this);
|
|
343
|
+
return ptr;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
free() {
|
|
347
|
+
const ptr = this.__destroy_into_raw();
|
|
348
|
+
wasm.__wbg_wasmquerystream_free(ptr, 0);
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* @returns {any}
|
|
352
|
+
*/
|
|
353
|
+
next() {
|
|
354
|
+
const ret = wasm.wasmquerystream_next(this.__wbg_ptr);
|
|
355
|
+
if (ret[2]) {
|
|
356
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
357
|
+
}
|
|
358
|
+
return takeFromExternrefTable0(ret[0]);
|
|
359
|
+
}
|
|
360
|
+
close() {
|
|
361
|
+
wasm.wasmquerystream_close(this.__wbg_ptr);
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* @returns {any}
|
|
365
|
+
*/
|
|
366
|
+
columns() {
|
|
367
|
+
const ret = wasm.wasmquerystream_columns(this.__wbg_ptr);
|
|
368
|
+
if (ret[2]) {
|
|
369
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
370
|
+
}
|
|
371
|
+
return takeFromExternrefTable0(ret[0]);
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
|
|
293
375
|
async function __wbg_load(module, imports) {
|
|
294
376
|
if (typeof Response === 'function' && module instanceof Response) {
|
|
295
377
|
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
Binary file
|
|
@@ -2,13 +2,19 @@
|
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
4
|
export const __wbg_wasmdatabase_free: (a: number, b: number) => void;
|
|
5
|
+
export const __wbg_wasmquerystream_free: (a: number, b: number) => void;
|
|
5
6
|
export const wasmdatabase_clear: (a: number) => void;
|
|
6
7
|
export const wasmdatabase_execute: (a: number, b: number, c: number, d: any) => [number, number, number];
|
|
7
8
|
export const wasmdatabase_loadSnapshotFromBytes: (a: number, b: number, c: number) => [number, number, number];
|
|
8
9
|
export const wasmdatabase_new: () => number;
|
|
9
10
|
export const wasmdatabase_nodeCount: (a: number) => number;
|
|
11
|
+
export const wasmdatabase_openStream: (a: number, b: number, c: number, d: any) => [number, number, number];
|
|
10
12
|
export const wasmdatabase_relationshipCount: (a: number) => number;
|
|
11
13
|
export const wasmdatabase_saveSnapshotToBytes: (a: number) => [number, number, number, number];
|
|
14
|
+
export const wasmdatabase_transaction: (a: number, b: any, c: number, d: number) => [number, number, number];
|
|
15
|
+
export const wasmquerystream_close: (a: number) => void;
|
|
16
|
+
export const wasmquerystream_columns: (a: number) => [number, number, number];
|
|
17
|
+
export const wasmquerystream_next: (a: number) => [number, number, number];
|
|
12
18
|
export const init: () => void;
|
|
13
19
|
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
14
20
|
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|