@loradb/lora-wasm 0.1.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/LICENSE +87 -0
- package/README.md +197 -0
- package/dist/index.d.ts +66 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +87 -0
- package/dist/index.js.map +1 -0
- package/dist/loader-node.d.ts +12 -0
- package/dist/loader-node.d.ts.map +1 -0
- package/dist/loader-node.js +12 -0
- package/dist/loader-node.js.map +1 -0
- package/dist/types.d.ts +193 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +111 -0
- package/dist/types.js.map +1 -0
- package/dist/worker-client.d.ts +41 -0
- package/dist/worker-client.d.ts.map +1 -0
- package/dist/worker-client.js +69 -0
- package/dist/worker-client.js.map +1 -0
- package/dist/worker-protocol.d.ts +40 -0
- package/dist/worker-protocol.d.ts.map +1 -0
- package/dist/worker-protocol.js +9 -0
- package/dist/worker-protocol.js.map +1 -0
- package/dist/worker.d.ts +12 -0
- package/dist/worker.d.ts.map +1 -0
- package/dist/worker.js +75 -0
- package/dist/worker.js.map +1 -0
- package/package.json +98 -0
- package/pkg-bundler/LICENSE +87 -0
- package/pkg-bundler/README.md +197 -0
- package/pkg-bundler/lora_wasm.d.ts +25 -0
- package/pkg-bundler/lora_wasm.js +5 -0
- package/pkg-bundler/lora_wasm_bg.js +559 -0
- package/pkg-bundler/lora_wasm_bg.wasm +0 -0
- package/pkg-bundler/lora_wasm_bg.wasm.d.ts +18 -0
- package/pkg-bundler/package.json +22 -0
- package/pkg-node/LICENSE +87 -0
- package/pkg-node/README.md +197 -0
- package/pkg-node/lora_wasm.d.ts +25 -0
- package/pkg-node/lora_wasm.js +566 -0
- package/pkg-node/lora_wasm_bg.wasm +0 -0
- package/pkg-node/lora_wasm_bg.wasm.d.ts +18 -0
- package/pkg-node/package.json +16 -0
- package/pkg-web/LICENSE +87 -0
- package/pkg-web/README.md +197 -0
- package/pkg-web/lora_wasm.d.ts +67 -0
- package/pkg-web/lora_wasm.js +607 -0
- package/pkg-web/lora_wasm_bg.wasm +0 -0
- package/pkg-web/lora_wasm_bg.wasm.d.ts +18 -0
- package/pkg-web/package.json +20 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../ts/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAMH;;;;;GAKG;AACH,MAAM,MAAM,SAAS,GACjB,IAAI,GACJ,OAAO,GACP,MAAM,GACN,MAAM,GACN,SAAS,EAAE,GACX;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,GAC5B,QAAQ,GACR,QAAQ,GACR,aAAa,GACb,YAAY,GACZ,iBAAiB,GACjB,YAAY,GACZ,SAAS,CAAC;AAEd,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;AAMnD,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;CACvC;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,cAAc,CAAC;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;CACvC;AAED,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB;AAMD,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,mBAAmB;IACnB,GAAG,EAAE,MAAM,CAAC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AChB,QAAQ,MAAM,KACb,gBAUD,CAAC;AAMH;;;;;;;GAOG;AACH,MAAM,MAAM,aAAa,GACrB,YAAY,GACZ,gBAAgB,GAChB,cAAc,GACd,SAAS,CAAC;AAEd;;;GAGG;AACH,qBAAa,SAAU,SAAQ,KAAK;IAClC,SAAgB,IAAI,EAAE,aAAa,CAAC;gBAExB,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,aAAyB;CAK7D;AAID;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,OAAO,GAAG,KAAK,CAO7C"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical typed value model for the JS-facing Lora packages
|
|
3
|
+
* (`lora-node` and `lora-wasm`).
|
|
4
|
+
*
|
|
5
|
+
* Every structural value carries a `kind` discriminator. Temporal and
|
|
6
|
+
* spatial values are tagged so TypeScript can narrow safely after a
|
|
7
|
+
* query runs.
|
|
8
|
+
*
|
|
9
|
+
* Canonical source: `crates/shared-ts/types.ts`. Each JS-facing package
|
|
10
|
+
* (`lora-node`, `lora-wasm`) copies this file into its own `ts/` dir
|
|
11
|
+
* via its `sync:types` npm script. The `verify:types` script fails CI if
|
|
12
|
+
* the copies drift — do not edit the per-package copies directly.
|
|
13
|
+
*/
|
|
14
|
+
// ---------------------------------------------------------------------------
|
|
15
|
+
// Guards
|
|
16
|
+
// ---------------------------------------------------------------------------
|
|
17
|
+
export function isNode(v) {
|
|
18
|
+
return typeof v === "object" && v !== null && !Array.isArray(v) && v.kind === "node";
|
|
19
|
+
}
|
|
20
|
+
export function isRelationship(v) {
|
|
21
|
+
return typeof v === "object" && v !== null && !Array.isArray(v) && v.kind === "relationship";
|
|
22
|
+
}
|
|
23
|
+
export function isPath(v) {
|
|
24
|
+
return typeof v === "object" && v !== null && !Array.isArray(v) && v.kind === "path";
|
|
25
|
+
}
|
|
26
|
+
export function isPoint(v) {
|
|
27
|
+
return typeof v === "object" && v !== null && !Array.isArray(v) && v.kind === "point";
|
|
28
|
+
}
|
|
29
|
+
export function isTemporal(v) {
|
|
30
|
+
if (typeof v !== "object" || v === null || Array.isArray(v))
|
|
31
|
+
return false;
|
|
32
|
+
const kind = v.kind;
|
|
33
|
+
return (kind === "date" ||
|
|
34
|
+
kind === "time" ||
|
|
35
|
+
kind === "localtime" ||
|
|
36
|
+
kind === "datetime" ||
|
|
37
|
+
kind === "localdatetime" ||
|
|
38
|
+
kind === "duration");
|
|
39
|
+
}
|
|
40
|
+
// ---------------------------------------------------------------------------
|
|
41
|
+
// Constructors
|
|
42
|
+
// ---------------------------------------------------------------------------
|
|
43
|
+
export const date = (iso) => ({ kind: "date", iso });
|
|
44
|
+
export const time = (iso) => ({ kind: "time", iso });
|
|
45
|
+
export const localtime = (iso) => ({ kind: "localtime", iso });
|
|
46
|
+
export const datetime = (iso) => ({ kind: "datetime", iso });
|
|
47
|
+
export const localdatetime = (iso) => ({ kind: "localdatetime", iso });
|
|
48
|
+
export const duration = (iso) => ({ kind: "duration", iso });
|
|
49
|
+
export const cartesian = (x, y) => ({
|
|
50
|
+
kind: "point",
|
|
51
|
+
srid: 7203,
|
|
52
|
+
crs: "cartesian",
|
|
53
|
+
x,
|
|
54
|
+
y,
|
|
55
|
+
});
|
|
56
|
+
export const cartesian3d = (x, y, z) => ({
|
|
57
|
+
kind: "point",
|
|
58
|
+
srid: 9157,
|
|
59
|
+
crs: "cartesian-3D",
|
|
60
|
+
x,
|
|
61
|
+
y,
|
|
62
|
+
z,
|
|
63
|
+
});
|
|
64
|
+
export const wgs84 = (longitude, latitude) => ({
|
|
65
|
+
kind: "point",
|
|
66
|
+
srid: 4326,
|
|
67
|
+
crs: "WGS-84-2D",
|
|
68
|
+
x: longitude,
|
|
69
|
+
y: latitude,
|
|
70
|
+
longitude,
|
|
71
|
+
latitude,
|
|
72
|
+
});
|
|
73
|
+
export const wgs84_3d = (longitude, latitude, height) => ({
|
|
74
|
+
kind: "point",
|
|
75
|
+
srid: 4979,
|
|
76
|
+
crs: "WGS-84-3D",
|
|
77
|
+
x: longitude,
|
|
78
|
+
y: latitude,
|
|
79
|
+
z: height,
|
|
80
|
+
longitude,
|
|
81
|
+
latitude,
|
|
82
|
+
height,
|
|
83
|
+
});
|
|
84
|
+
/**
|
|
85
|
+
* Error thrown by `Database.execute` when Lora parsing, analysis, or
|
|
86
|
+
* execution fails.
|
|
87
|
+
*/
|
|
88
|
+
export class LoraError extends Error {
|
|
89
|
+
code;
|
|
90
|
+
constructor(message, code = "UNKNOWN") {
|
|
91
|
+
super(message);
|
|
92
|
+
this.name = "LoraError";
|
|
93
|
+
this.code = code;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
const ERROR_PREFIX_RE = /^(LORA_ERROR|INVALID_PARAMS|WORKER_ERROR):\s*(.*)$/s;
|
|
97
|
+
/**
|
|
98
|
+
* Normalise a thrown value into a `LoraError` with a narrowed `code`
|
|
99
|
+
* when the message carries a recognised prefix; otherwise returns the
|
|
100
|
+
* original `Error` unchanged.
|
|
101
|
+
*/
|
|
102
|
+
export function wrapError(err) {
|
|
103
|
+
if (!(err instanceof Error))
|
|
104
|
+
return new LoraError(String(err), "UNKNOWN");
|
|
105
|
+
const match = ERROR_PREFIX_RE.exec(err.message);
|
|
106
|
+
if (match) {
|
|
107
|
+
return new LoraError(match[2], match[1]);
|
|
108
|
+
}
|
|
109
|
+
return err;
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../ts/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAyOH,8EAA8E;AAC9E,SAAS;AACT,8EAA8E;AAE9E,MAAM,UAAU,MAAM,CAAC,CAAY;IACjC,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAA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;IACX,SAAS;IACT,QAAQ;CACT,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,QAAQ,GAAG,CACtB,SAAiB,EACjB,QAAgB,EAChB,MAAc,EACI,EAAE,CAAC,CAAC;IACtB,IAAI,EAAE,OAAO;IACb,IAAI,EAAE,IAAI;IACV,GAAG,EAAE,WAAW;IAChB,CAAC,EAAE,SAAS;IACZ,CAAC,EAAE,QAAQ;IACX,CAAC,EAAE,MAAM;IACT,SAAS;IACT,QAAQ;IACR,MAAM;CACP,CAAC,CAAC;AAoBH;;;GAGG;AACH,MAAM,OAAO,SAAU,SAAQ,KAAK;IAClB,IAAI,CAAgB;IAEpC,YAAY,OAAe,EAAE,OAAsB,SAAS;QAC1D,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AAED,MAAM,eAAe,GAAG,qDAAqD,CAAC;AAE9E;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAC,GAAY;IACpC,IAAI,CAAC,CAAC,GAAG,YAAY,KAAK,CAAC;QAAE,OAAO,IAAI,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,SAAS,CAAC,CAAC;IAC1E,MAAM,KAAK,GAAG,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAChD,IAAI,KAAK,EAAE,CAAC;QACV,OAAO,IAAI,SAAS,CAAC,KAAK,CAAC,CAAC,CAAE,EAAE,KAAK,CAAC,CAAC,CAAkB,CAAC,CAAC;IAC7D,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Main-thread client for the WASM-in-a-Worker architecture.
|
|
3
|
+
*
|
|
4
|
+
* All queries are posted as messages and awaited as promises; the heavy work
|
|
5
|
+
* runs off the main thread. The API mirrors the in-process `Database` class
|
|
6
|
+
* so consumers can choose the execution model without rewriting their code.
|
|
7
|
+
*/
|
|
8
|
+
import type { LoraParams, LoraValue, QueryResult } from "./types.js";
|
|
9
|
+
import type { Response } from "./worker-protocol.js";
|
|
10
|
+
export interface WorkerLike {
|
|
11
|
+
postMessage(message: unknown): void;
|
|
12
|
+
terminate(): void;
|
|
13
|
+
addEventListener(type: "message", listener: (event: {
|
|
14
|
+
data: Response;
|
|
15
|
+
}) => void): void;
|
|
16
|
+
addEventListener(type: "error", listener: (event: {
|
|
17
|
+
message?: string;
|
|
18
|
+
}) => void): void;
|
|
19
|
+
removeEventListener(type: "message", listener: (event: {
|
|
20
|
+
data: Response;
|
|
21
|
+
}) => void): void;
|
|
22
|
+
}
|
|
23
|
+
export interface WorkerDatabase {
|
|
24
|
+
execute<T extends Record<string, LoraValue> = Record<string, LoraValue>>(query: string, params?: LoraParams): Promise<QueryResult<T>>;
|
|
25
|
+
clear(): Promise<void>;
|
|
26
|
+
nodeCount(): Promise<number>;
|
|
27
|
+
relationshipCount(): Promise<number>;
|
|
28
|
+
dispose(): Promise<void>;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Build a Database client that proxies to the supplied worker.
|
|
32
|
+
*
|
|
33
|
+
* Typical browser usage:
|
|
34
|
+
* ```ts
|
|
35
|
+
* const worker = new Worker(new URL("./worker.js", import.meta.url), { type: "module" });
|
|
36
|
+
* const db = createWorkerDatabase(worker);
|
|
37
|
+
* const result = await db.execute("MATCH (n) RETURN n");
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export declare function createWorkerDatabase(worker: WorkerLike): WorkerDatabase;
|
|
41
|
+
//# sourceMappingURL=worker-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker-client.d.ts","sourceRoot":"","sources":["../ts/worker-client.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,UAAU,EACV,SAAS,EACT,WAAW,EAC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M-in-a-Worker architecture.
|
|
3
|
+
*
|
|
4
|
+
* All queries are posted as messages and awaited as promises; the heavy work
|
|
5
|
+
* runs off the main thread. The API mirrors the in-process `Database` class
|
|
6
|
+
* so consumers can choose the execution model without rewriting their code.
|
|
7
|
+
*/
|
|
8
|
+
import { LoraError } from "./types.js";
|
|
9
|
+
/**
|
|
10
|
+
* Build a Database client that proxies to the supplied worker.
|
|
11
|
+
*
|
|
12
|
+
* Typical browser usage:
|
|
13
|
+
* ```ts
|
|
14
|
+
* const worker = new Worker(new URL("./worker.js", import.meta.url), { type: "module" });
|
|
15
|
+
* const db = createWorkerDatabase(worker);
|
|
16
|
+
* const result = await db.execute("MATCH (n) RETURN n");
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export function createWorkerDatabase(worker) {
|
|
20
|
+
let nextId = 1;
|
|
21
|
+
const pending = new Map();
|
|
22
|
+
worker.addEventListener("message", (event) => {
|
|
23
|
+
const { id, body } = event.data;
|
|
24
|
+
const p = pending.get(id);
|
|
25
|
+
if (!p)
|
|
26
|
+
return;
|
|
27
|
+
pending.delete(id);
|
|
28
|
+
if (body.ok) {
|
|
29
|
+
p.resolve(body.result);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
p.reject(new LoraError(body.error.message, body.error.code));
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
worker.addEventListener("error", (event) => {
|
|
36
|
+
const message = event.message ?? "worker errored";
|
|
37
|
+
for (const p of pending.values()) {
|
|
38
|
+
p.reject(new LoraError(message, "WORKER_ERROR"));
|
|
39
|
+
}
|
|
40
|
+
pending.clear();
|
|
41
|
+
});
|
|
42
|
+
function call(body) {
|
|
43
|
+
const id = nextId++;
|
|
44
|
+
return new Promise((resolve, reject) => {
|
|
45
|
+
pending.set(id, { resolve: resolve, reject });
|
|
46
|
+
const msg = { id, body };
|
|
47
|
+
worker.postMessage(msg);
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
execute(query, params) {
|
|
52
|
+
return call({ op: "execute", query, params: params ?? null });
|
|
53
|
+
},
|
|
54
|
+
async clear() {
|
|
55
|
+
await call({ op: "clear" });
|
|
56
|
+
},
|
|
57
|
+
nodeCount() {
|
|
58
|
+
return call({ op: "nodeCount" });
|
|
59
|
+
},
|
|
60
|
+
relationshipCount() {
|
|
61
|
+
return call({ op: "relationshipCount" });
|
|
62
|
+
},
|
|
63
|
+
async dispose() {
|
|
64
|
+
await call({ op: "dispose" });
|
|
65
|
+
worker.terminate();
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=worker-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker-client.js","sourceRoot":"","sources":["../ts/worker-client.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAOH,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AA2BvC;;;;;;;;;GASG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAkB;IACrD,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,MAAM,OAAO,GAAG,IAAI,GAAG,EAAmB,CAAC;IAE3C,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE;QAC3C,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC;QAChC,MAAM,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC1B,IAAI,CAAC,CAAC;YAAE,OAAO;QACf,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACnB,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC;YACZ,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACzB,CAAC;aAAM,CAAC;YACN,CAAC,CAAC,MAAM,CAAC,IAAI,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,IAA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BAAmB,EAAE,CAAC,CAAC;QACnD,CAAC;QACD,KAAK,CAAC,OAAO;YACX,MAAM,IAAI,CAAO,EAAE,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC;YACpC,MAAM,CAAC,SAAS,EAAE,CAAC;QACrB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wire protocol for the worker-backed Database.
|
|
3
|
+
*
|
|
4
|
+
* Messages are plain objects (structured-clone safe). Each request carries a
|
|
5
|
+
* numeric `id` which the worker echoes back, letting the client correlate
|
|
6
|
+
* asynchronous responses.
|
|
7
|
+
*/
|
|
8
|
+
import type { LoraParams, QueryResult, LoraErrorCode } from "./types.js";
|
|
9
|
+
export type RequestBody = {
|
|
10
|
+
op: "execute";
|
|
11
|
+
query: string;
|
|
12
|
+
params?: LoraParams | null;
|
|
13
|
+
} | {
|
|
14
|
+
op: "clear";
|
|
15
|
+
} | {
|
|
16
|
+
op: "nodeCount";
|
|
17
|
+
} | {
|
|
18
|
+
op: "relationshipCount";
|
|
19
|
+
} | {
|
|
20
|
+
op: "dispose";
|
|
21
|
+
};
|
|
22
|
+
export interface Request {
|
|
23
|
+
id: number;
|
|
24
|
+
body: RequestBody;
|
|
25
|
+
}
|
|
26
|
+
export type ResponseBody = {
|
|
27
|
+
ok: true;
|
|
28
|
+
result: QueryResult | number | null;
|
|
29
|
+
} | {
|
|
30
|
+
ok: false;
|
|
31
|
+
error: {
|
|
32
|
+
message: string;
|
|
33
|
+
code: LoraErrorCode;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
export interface Response {
|
|
37
|
+
id: number;
|
|
38
|
+
body: ResponseBody;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=worker-protocol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker-protocol.d.ts","sourceRoot":"","sources":["../ts/worker-protocol.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEzE,MAAM,MAAM,WAAW,GACnB;IAAE,EAAE,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,UAAU,GAAG,IAAI,CAAA;CAAE,GAC5D;IAAE,EAAE,EAAE,OAAO,CAAA;CAAE,GACf;IAAE,EAAE,EAAE,WAAW,CAAA;CAAE,GACnB;IAAE,EAAE,EAAE,mBAAmB,CAAA;CAAE,GAC3B;IAAE,EAAE,EAAE,SAAS,CAAA;CAAE,CAAC;AAEtB,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,WAAW,CAAC;CACnB;AAED,MAAM,MAAM,YAAY,GACpB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,WAAW,GAAG,MAAM,GAAG,IAAI,CAAA;CAAE,GACjD;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,aAAa,CAAA;KAAE,CAAA;CAAE,CAAC;AAEnE,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,YAAY,CAAC;CACpB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wire protocol for the worker-backed Database.
|
|
3
|
+
*
|
|
4
|
+
* Messages are plain objects (structured-clone safe). Each request carries a
|
|
5
|
+
* numeric `id` which the worker echoes back, letting the client correlate
|
|
6
|
+
* asynchronous responses.
|
|
7
|
+
*/
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=worker-protocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker-protocol.js","sourceRoot":"","sources":["../ts/worker-protocol.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
|
package/dist/worker.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Worker entrypoint — hosts the WASM engine inside a Web Worker so the main
|
|
3
|
+
* thread never runs heavy query work.
|
|
4
|
+
*
|
|
5
|
+
* This file uses the `--target web` wasm-pack output (`pkg-web/`) which
|
|
6
|
+
* takes care of fetching and instantiating the `.wasm` binary itself via
|
|
7
|
+
* the URL passed to `__wbg_init`. That avoids a hard dependency on a
|
|
8
|
+
* bundler plugin for WASM and lets this file run unchanged in any module
|
|
9
|
+
* worker (Vite dev, a static file server, a built tarball).
|
|
10
|
+
*/
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=worker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../ts/worker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG"}
|
package/dist/worker.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Worker entrypoint — hosts the WASM engine inside a Web Worker so the main
|
|
3
|
+
* thread never runs heavy query work.
|
|
4
|
+
*
|
|
5
|
+
* This file uses the `--target web` wasm-pack output (`pkg-web/`) which
|
|
6
|
+
* takes care of fetching and instantiating the `.wasm` binary itself via
|
|
7
|
+
* the URL passed to `__wbg_init`. That avoids a hard dependency on a
|
|
8
|
+
* bundler plugin for WASM and lets this file run unchanged in any module
|
|
9
|
+
* worker (Vite dev, a static file server, a built tarball).
|
|
10
|
+
*/
|
|
11
|
+
/// <reference lib="webworker" />
|
|
12
|
+
import __wbg_init, { WasmDatabase, init as installPanicHook, } from "../pkg-web/lora_wasm.js";
|
|
13
|
+
let db = null;
|
|
14
|
+
let ready = null;
|
|
15
|
+
function ensureReady() {
|
|
16
|
+
if (!ready) {
|
|
17
|
+
ready = (async () => {
|
|
18
|
+
const wasmUrl = new URL("../pkg-web/lora_wasm_bg.wasm", import.meta.url);
|
|
19
|
+
await __wbg_init(wasmUrl);
|
|
20
|
+
installPanicHook();
|
|
21
|
+
db = new WasmDatabase();
|
|
22
|
+
})();
|
|
23
|
+
}
|
|
24
|
+
return ready;
|
|
25
|
+
}
|
|
26
|
+
function extractErrorCode(message) {
|
|
27
|
+
const match = /^(LORA_ERROR|INVALID_PARAMS|WORKER_ERROR):/.exec(message);
|
|
28
|
+
return match?.[1] ?? "UNKNOWN";
|
|
29
|
+
}
|
|
30
|
+
self.onmessage = async (event) => {
|
|
31
|
+
const { id, body } = event.data;
|
|
32
|
+
const respond = (payload) => {
|
|
33
|
+
const res = { id, body: payload };
|
|
34
|
+
self.postMessage(res);
|
|
35
|
+
};
|
|
36
|
+
try {
|
|
37
|
+
await ensureReady();
|
|
38
|
+
if (!db)
|
|
39
|
+
throw new Error("WORKER_ERROR: database not initialized");
|
|
40
|
+
switch (body.op) {
|
|
41
|
+
case "execute": {
|
|
42
|
+
const result = db.execute(body.query, body.params ?? null);
|
|
43
|
+
respond({ ok: true, result: result });
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
case "clear": {
|
|
47
|
+
db.clear();
|
|
48
|
+
respond({ ok: true, result: null });
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
case "nodeCount": {
|
|
52
|
+
respond({ ok: true, result: db.nodeCount() });
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
case "relationshipCount": {
|
|
56
|
+
respond({ ok: true, result: db.relationshipCount() });
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
case "dispose": {
|
|
60
|
+
db.free();
|
|
61
|
+
db = null;
|
|
62
|
+
respond({ ok: true, result: null });
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
catch (err) {
|
|
68
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
69
|
+
respond({
|
|
70
|
+
ok: false,
|
|
71
|
+
error: { message, code: extractErrorCode(message) },
|
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AAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACjE,OAAO,CAAC;YACN,EAAE,EAAE,KAAK;YACT,KAAK,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,gBAAgB,CAAC,OAAO,CAAC,EAAE;SACpD,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@loradb/lora-wasm",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "WebAssembly bindings for the Lora in-memory graph database",
|
|
5
|
+
"license": "BUSL-1.1",
|
|
6
|
+
"author": "LoraDB, Inc.",
|
|
7
|
+
"homepage": "https://github.com/lora-db/lora#readme",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/lora-db/lora.git",
|
|
11
|
+
"directory": "crates/lora-wasm"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/lora-db/lora/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"lora",
|
|
18
|
+
"loradb",
|
|
19
|
+
"graph",
|
|
20
|
+
"cypher",
|
|
21
|
+
"database",
|
|
22
|
+
"wasm",
|
|
23
|
+
"webassembly",
|
|
24
|
+
"neo4j"
|
|
25
|
+
],
|
|
26
|
+
"type": "module",
|
|
27
|
+
"main": "dist/index.js",
|
|
28
|
+
"types": "dist/index.d.ts",
|
|
29
|
+
"exports": {
|
|
30
|
+
".": {
|
|
31
|
+
"types": "./dist/index.d.ts",
|
|
32
|
+
"import": "./dist/index.js"
|
|
33
|
+
},
|
|
34
|
+
"./worker": {
|
|
35
|
+
"types": "./dist/worker.d.ts",
|
|
36
|
+
"import": "./dist/worker.js"
|
|
37
|
+
},
|
|
38
|
+
"./worker-client": {
|
|
39
|
+
"types": "./dist/worker-client.d.ts",
|
|
40
|
+
"import": "./dist/worker-client.js"
|
|
41
|
+
},
|
|
42
|
+
"./bundler": {
|
|
43
|
+
"types": "./pkg-bundler/lora_wasm.d.ts",
|
|
44
|
+
"import": "./pkg-bundler/lora_wasm.js"
|
|
45
|
+
},
|
|
46
|
+
"./web": {
|
|
47
|
+
"types": "./pkg-web/lora_wasm.d.ts",
|
|
48
|
+
"import": "./pkg-web/lora_wasm.js"
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
"files": [
|
|
52
|
+
"dist/",
|
|
53
|
+
"pkg-node/",
|
|
54
|
+
"pkg-bundler/",
|
|
55
|
+
"pkg-web/",
|
|
56
|
+
"README.md",
|
|
57
|
+
"LICENSE"
|
|
58
|
+
],
|
|
59
|
+
"publishConfig": {
|
|
60
|
+
"access": "public",
|
|
61
|
+
"provenance": true,
|
|
62
|
+
"registry": "https://registry.npmjs.org/"
|
|
63
|
+
},
|
|
64
|
+
"engines": {
|
|
65
|
+
"node": ">=20"
|
|
66
|
+
},
|
|
67
|
+
"scripts": {
|
|
68
|
+
"sync:types": "node -e \"require('fs').copyFileSync('../shared-ts/types.ts','ts/types.ts')\"",
|
|
69
|
+
"verify:types": "node -e \"const fs=require('fs'); const a=fs.readFileSync('../shared-ts/types.ts','utf8'); const b=fs.readFileSync('ts/types.ts','utf8'); if (a!==b) { console.error('ts/types.ts is out of sync with shared-ts/types.ts — run npm run sync:types'); process.exit(1);} \"",
|
|
70
|
+
"prebuild": "npm run sync:types",
|
|
71
|
+
"pretypecheck": "npm run sync:types",
|
|
72
|
+
"pretest": "npm run sync:types",
|
|
73
|
+
"build:wasm:node": "wasm-pack build --target nodejs --release --out-dir pkg-node",
|
|
74
|
+
"build:wasm:bundler": "wasm-pack build --target bundler --release --out-dir pkg-bundler",
|
|
75
|
+
"build:wasm:web": "wasm-pack build --target web --release --out-dir pkg-web",
|
|
76
|
+
"build:wasm": "npm run build:wasm:node && npm run build:wasm:bundler && npm run build:wasm:web",
|
|
77
|
+
"postbuild:wasm": "node -e \"for (const d of ['pkg-node','pkg-bundler','pkg-web']) { try { require('fs').rmSync(d + '/.gitignore'); } catch {} }\"",
|
|
78
|
+
"build:ts": "tsc -p tsconfig.json",
|
|
79
|
+
"build": "npm run build:wasm && npm run build:ts",
|
|
80
|
+
"typecheck": "tsc -p tsconfig.test.json --noEmit",
|
|
81
|
+
"test": "vitest run",
|
|
82
|
+
"test:watch": "vitest",
|
|
83
|
+
"test:browser": "playwright test",
|
|
84
|
+
"test:browser:install": "playwright install chromium",
|
|
85
|
+
"copy-license": "node -e \"const fs=require('fs'); try { fs.copyFileSync('../../LICENSE','LICENSE'); } catch (e) { if (e.code !== 'ENOENT') throw e; }\"",
|
|
86
|
+
"prepack": "npm run sync:types && npm run copy-license && npm run build",
|
|
87
|
+
"pack:dry": "npm pack --dry-run"
|
|
88
|
+
},
|
|
89
|
+
"devDependencies": {
|
|
90
|
+
"@playwright/test": "^1.59.1",
|
|
91
|
+
"@types/node": "^22.7.4",
|
|
92
|
+
"typescript": "^5.6.2",
|
|
93
|
+
"vite": "^5.4.21",
|
|
94
|
+
"vite-plugin-top-level-await": "^1.6.0",
|
|
95
|
+
"vite-plugin-wasm": "^3.6.0",
|
|
96
|
+
"vitest": "^2.1.1"
|
|
97
|
+
}
|
|
98
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
Business Source License 1.1
|
|
2
|
+
|
|
3
|
+
Parameters
|
|
4
|
+
|
|
5
|
+
Licensor: LoraDB, Inc.
|
|
6
|
+
Licensed Work: LoraDB
|
|
7
|
+
Change Date: 2029-04-19
|
|
8
|
+
Change License: Apache License, Version 2.0
|
|
9
|
+
|
|
10
|
+
Additional Use Grant: You may use, copy, modify, create derivative works of,
|
|
11
|
+
distribute, and make production use of the Licensed Work
|
|
12
|
+
for internal business purposes and non-production
|
|
13
|
+
purposes, provided that you do not use the Licensed Work
|
|
14
|
+
to offer, operate, or make available a database-as-a-
|
|
15
|
+
service, hosted API, managed database platform, or any
|
|
16
|
+
substantially similar hosted service for third parties.
|
|
17
|
+
|
|
18
|
+
The Additional Use Grant does not permit using the
|
|
19
|
+
Licensed Work to provide a commercial or non-commercial
|
|
20
|
+
hosted service that allows third parties to access LoraDB
|
|
21
|
+
functionality, including as part of a competing managed
|
|
22
|
+
database platform, backend-as-a-service, application
|
|
23
|
+
platform, developer platform, or resale offering.
|
|
24
|
+
|
|
25
|
+
Business Source License
|
|
26
|
+
|
|
27
|
+
Terms
|
|
28
|
+
|
|
29
|
+
The Licensor hereby grants you the right to copy, modify, create derivative
|
|
30
|
+
works, redistribute, and make non-production use of the Licensed Work. The
|
|
31
|
+
Licensor may make an Additional Use Grant, above, permitting limited production
|
|
32
|
+
use.
|
|
33
|
+
|
|
34
|
+
Effective on the Change Date, or the fourth anniversary of the first publicly
|
|
35
|
+
available distribution of a specific version of the Licensed Work under this
|
|
36
|
+
License, whichever comes first, the Licensor hereby grants you rights under
|
|
37
|
+
the terms of the Change License, and the rights granted in the paragraph
|
|
38
|
+
above terminate.
|
|
39
|
+
|
|
40
|
+
If your use of the Licensed Work does not comply with the requirements
|
|
41
|
+
currently in effect as described in this License, you must purchase a
|
|
42
|
+
commercial license from the Licensor, its affiliated entities, or authorized
|
|
43
|
+
resellers, or you must refrain from using the Licensed Work.
|
|
44
|
+
|
|
45
|
+
All copies of the original and modified Licensed Work, and derivative works
|
|
46
|
+
of the Licensed Work, are subject to this License. This License applies
|
|
47
|
+
separately for each version of the Licensed Work and the Change Date may vary
|
|
48
|
+
for each version of the Licensed Work released by Licensor.
|
|
49
|
+
|
|
50
|
+
You must conspicuously display this License on each original or modified copy
|
|
51
|
+
of the Licensed Work. If you receive the Licensed Work in original or modified
|
|
52
|
+
form from a third party, the terms and conditions set forth in this License
|
|
53
|
+
apply to your use of that work.
|
|
54
|
+
|
|
55
|
+
Any use of the Licensed Work in violation of this License will automatically
|
|
56
|
+
terminate your rights under this License for the current and all other
|
|
57
|
+
versions of the Licensed Work.
|
|
58
|
+
|
|
59
|
+
This License does not grant you any right in any trademark or logo of Licensor
|
|
60
|
+
or its affiliates.
|
|
61
|
+
|
|
62
|
+
TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
|
|
63
|
+
AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
|
|
64
|
+
EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF MERCHANTABILITY,
|
|
65
|
+
FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND TITLE.
|
|
66
|
+
|
|
67
|
+
MariaDB hereby grants you permission to use this License's text to license
|
|
68
|
+
your works, and to refer to it using the trademark "Business Source License",
|
|
69
|
+
as long as you comply with the Covenants of Licensor below.
|
|
70
|
+
|
|
71
|
+
Covenants of Licensor
|
|
72
|
+
|
|
73
|
+
In consideration of the right to use this License's text and the "Business
|
|
74
|
+
Source License" name and trademark, Licensor covenants to MariaDB, and to all
|
|
75
|
+
other recipients of the licensed work to be provided by Licensor:
|
|
76
|
+
|
|
77
|
+
1. To specify as the Change License the GPL Version 2.0 or any later version,
|
|
78
|
+
or a license that is compatible with GPL Version 2.0 or a later version,
|
|
79
|
+
where "compatible" means that software provided under the Change License can
|
|
80
|
+
be included in a program with software provided under GPL Version 2.0 or a
|
|
81
|
+
later version. Licensor may specify additional Change Licenses without
|
|
82
|
+
limitation.
|
|
83
|
+
2. To either: (a) specify an additional grant of rights to use that does not
|
|
84
|
+
impose any additional restriction on the right granted in this License, as
|
|
85
|
+
the Additional Use Grant; or (b) insert the text "None".
|
|
86
|
+
3. To specify a Change Date.
|
|
87
|
+
4. Not to modify this License in any other way.
|