@moltendb-web/core 0.1.0-alpha.14 → 0.1.0-alpha.21
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/dist/moltendb-worker.js +29 -20
- package/dist/moltendb.d.ts +10 -3
- package/dist/moltendb.js +16 -7
- package/dist/moltendb_bg.wasm +0 -0
- package/dist/moltendb_bg.wasm.d.ts +4 -3
- package/package.json +1 -1
package/dist/moltendb-worker.js
CHANGED
|
@@ -1,30 +1,39 @@
|
|
|
1
|
-
// MoltenDB Web Worker — auto-generated by moltendb-wasm build script
|
|
2
|
-
// Do not edit directly; edit moltendb-wasm/scripts/build.mjs instead.
|
|
3
1
|
import init, { WorkerDb } from './moltendb.js';
|
|
4
2
|
|
|
5
|
-
let db
|
|
3
|
+
let db;
|
|
6
4
|
|
|
7
|
-
self.onmessage = async (
|
|
8
|
-
const { id, action, ...
|
|
5
|
+
self.onmessage = async (e) => {
|
|
6
|
+
const { id, action, ...payload } = e.data;
|
|
9
7
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
// --- Initialization Phase ---
|
|
9
|
+
if (action === 'init') {
|
|
10
|
+
try {
|
|
11
|
+
await init(payload.workerUrl);
|
|
12
|
+
db = await new WorkerDb(payload.dbName);
|
|
13
|
+
|
|
14
|
+
// THE NATIVE FEED: Listen to Rust and broadcast to the main thread
|
|
15
|
+
db.subscribe((eventStr) => {
|
|
16
|
+
try {
|
|
17
|
+
const eventData = JSON.parse(eventStr);
|
|
18
|
+
// Use type: 'event' so the transport knows it's an unsolicited broadcast
|
|
19
|
+
self.postMessage({ type: 'event', ...eventData });
|
|
20
|
+
} catch (err) {
|
|
21
|
+
console.error("[MoltenDB Worker] Failed to parse event", err);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
17
24
|
|
|
18
|
-
|
|
19
|
-
|
|
25
|
+
self.postMessage({ id, result: { status: 'ok' } });
|
|
26
|
+
} catch (error) {
|
|
27
|
+
self.postMessage({ id, error: String(error) });
|
|
20
28
|
}
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
21
31
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const result = db.handle_message({ action, ...
|
|
32
|
+
// --- Standard Request/Response Phase ---
|
|
33
|
+
try {
|
|
34
|
+
const result = db.handle_message({ action, ...payload });
|
|
25
35
|
self.postMessage({ id, result });
|
|
26
|
-
|
|
27
36
|
} catch (error) {
|
|
28
|
-
self.postMessage({ id, error: error
|
|
37
|
+
self.postMessage({ id, error: String(error) });
|
|
29
38
|
}
|
|
30
|
-
};
|
|
39
|
+
};
|
package/dist/moltendb.d.ts
CHANGED
|
@@ -76,6 +76,12 @@ export class WorkerDb {
|
|
|
76
76
|
* Each unique name is a separate database file in the browser's OPFS storage.
|
|
77
77
|
*/
|
|
78
78
|
constructor(db_name: string);
|
|
79
|
+
/**
|
|
80
|
+
* Subscribe to real-time database changes.
|
|
81
|
+
* The provided JavaScript function will be called with a JSON string
|
|
82
|
+
* representing the mutation event.
|
|
83
|
+
*/
|
|
84
|
+
subscribe(callback: Function): void;
|
|
79
85
|
}
|
|
80
86
|
|
|
81
87
|
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
@@ -86,9 +92,10 @@ export interface InitOutput {
|
|
|
86
92
|
readonly workerdb_analytics: (a: number, b: number, c: number, d: number) => void;
|
|
87
93
|
readonly workerdb_handle_message: (a: number, b: number, c: number) => void;
|
|
88
94
|
readonly workerdb_new: (a: number, b: number) => number;
|
|
89
|
-
readonly
|
|
90
|
-
readonly
|
|
91
|
-
readonly
|
|
95
|
+
readonly workerdb_subscribe: (a: number, b: number) => void;
|
|
96
|
+
readonly __wasm_bindgen_func_elem_3624: (a: number, b: number) => void;
|
|
97
|
+
readonly __wasm_bindgen_func_elem_3703: (a: number, b: number, c: number, d: number) => void;
|
|
98
|
+
readonly __wasm_bindgen_func_elem_3716: (a: number, b: number, c: number, d: number) => void;
|
|
92
99
|
readonly __wbindgen_export: (a: number, b: number) => number;
|
|
93
100
|
readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
94
101
|
readonly __wbindgen_export3: (a: number) => void;
|
package/dist/moltendb.js
CHANGED
|
@@ -131,6 +131,15 @@ export class WorkerDb {
|
|
|
131
131
|
const ret = wasm.workerdb_new(ptr0, len0);
|
|
132
132
|
return takeObject(ret);
|
|
133
133
|
}
|
|
134
|
+
/**
|
|
135
|
+
* Subscribe to real-time database changes.
|
|
136
|
+
* The provided JavaScript function will be called with a JSON string
|
|
137
|
+
* representing the mutation event.
|
|
138
|
+
* @param {Function} callback
|
|
139
|
+
*/
|
|
140
|
+
subscribe(callback) {
|
|
141
|
+
wasm.workerdb_subscribe(this.__wbg_ptr, addHeapObject(callback));
|
|
142
|
+
}
|
|
134
143
|
}
|
|
135
144
|
if (Symbol.dispose) WorkerDb.prototype[Symbol.dispose] = WorkerDb.prototype.free;
|
|
136
145
|
|
|
@@ -377,7 +386,7 @@ function __wbg_get_imports() {
|
|
|
377
386
|
const a = state0.a;
|
|
378
387
|
state0.a = 0;
|
|
379
388
|
try {
|
|
380
|
-
return
|
|
389
|
+
return __wasm_bindgen_func_elem_3716(a, state0.b, arg0, arg1);
|
|
381
390
|
} finally {
|
|
382
391
|
state0.a = a;
|
|
383
392
|
}
|
|
@@ -497,8 +506,8 @@ function __wbg_get_imports() {
|
|
|
497
506
|
return ret;
|
|
498
507
|
}, arguments); },
|
|
499
508
|
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
500
|
-
// Cast intrinsic for `Closure(Closure { dtor_idx:
|
|
501
|
-
const ret = makeMutClosure(arg0, arg1, wasm.
|
|
509
|
+
// Cast intrinsic for `Closure(Closure { dtor_idx: 663, function: Function { arguments: [Externref], shim_idx: 674, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
510
|
+
const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_3624, __wasm_bindgen_func_elem_3703);
|
|
502
511
|
return addHeapObject(ret);
|
|
503
512
|
},
|
|
504
513
|
__wbindgen_cast_0000000000000002: function(arg0) {
|
|
@@ -535,10 +544,10 @@ function __wbg_get_imports() {
|
|
|
535
544
|
};
|
|
536
545
|
}
|
|
537
546
|
|
|
538
|
-
function
|
|
547
|
+
function __wasm_bindgen_func_elem_3703(arg0, arg1, arg2) {
|
|
539
548
|
try {
|
|
540
549
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
541
|
-
wasm.
|
|
550
|
+
wasm.__wasm_bindgen_func_elem_3703(retptr, arg0, arg1, addHeapObject(arg2));
|
|
542
551
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
543
552
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
544
553
|
if (r1) {
|
|
@@ -549,8 +558,8 @@ function __wasm_bindgen_func_elem_3677(arg0, arg1, arg2) {
|
|
|
549
558
|
}
|
|
550
559
|
}
|
|
551
560
|
|
|
552
|
-
function
|
|
553
|
-
wasm.
|
|
561
|
+
function __wasm_bindgen_func_elem_3716(arg0, arg1, arg2, arg3) {
|
|
562
|
+
wasm.__wasm_bindgen_func_elem_3716(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
|
|
554
563
|
}
|
|
555
564
|
|
|
556
565
|
const WorkerDbFinalization = (typeof FinalizationRegistry === 'undefined')
|
package/dist/moltendb_bg.wasm
CHANGED
|
Binary file
|
|
@@ -5,9 +5,10 @@ export const __wbg_workerdb_free: (a: number, b: number) => void;
|
|
|
5
5
|
export const workerdb_analytics: (a: number, b: number, c: number, d: number) => void;
|
|
6
6
|
export const workerdb_handle_message: (a: number, b: number, c: number) => void;
|
|
7
7
|
export const workerdb_new: (a: number, b: number) => number;
|
|
8
|
-
export const
|
|
9
|
-
export const
|
|
10
|
-
export const
|
|
8
|
+
export const workerdb_subscribe: (a: number, b: number) => void;
|
|
9
|
+
export const __wasm_bindgen_func_elem_3624: (a: number, b: number) => void;
|
|
10
|
+
export const __wasm_bindgen_func_elem_3703: (a: number, b: number, c: number, d: number) => void;
|
|
11
|
+
export const __wasm_bindgen_func_elem_3716: (a: number, b: number, c: number, d: number) => void;
|
|
11
12
|
export const __wbindgen_export: (a: number, b: number) => number;
|
|
12
13
|
export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
13
14
|
export const __wbindgen_export3: (a: number) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moltendb-web/core",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.21",
|
|
4
4
|
"description": "MoltenDB WASM runtime — the database engine, Web Worker, and main-thread client in one package.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "Maximilian Both <maximilian.both27@outlook.com>",
|