albex 0.3.0 → 0.6.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/CHANGELOG.md +466 -0
- package/README.md +32 -19
- package/dist/albex-worker.d.ts +65 -2
- package/dist/albex-worker.d.ts.map +1 -1
- package/dist/albex-worker.js +97 -20
- package/dist/albex-worker.js.map +1 -1
- package/dist/albex.d.ts +359 -55
- package/dist/albex.d.ts.map +1 -1
- package/dist/albex.js +766 -312
- package/dist/albex.js.map +1 -1
- package/dist/errors.d.ts +47 -2
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +41 -3
- package/dist/errors.js.map +1 -1
- package/dist/persistence.js +1 -1
- package/dist/pool/coordinator.d.ts +14 -6
- package/dist/pool/coordinator.d.ts.map +1 -1
- package/dist/pool/coordinator.js +65 -28
- package/dist/pool/coordinator.js.map +1 -1
- package/dist/profile.d.ts +11 -6
- package/dist/profile.d.ts.map +1 -1
- package/dist/profile.js +6 -13
- package/dist/profile.js.map +1 -1
- package/dist/resource-manager.js +1 -1
- package/dist/tiered-store.js +1 -1
- package/dist/wasm-bindings.d.ts +96 -6
- package/dist/wasm-bindings.d.ts.map +1 -1
- package/dist/wasm-bindings.js +110 -7
- package/dist/wasm-bindings.js.map +1 -1
- package/dist/worker-protocol.d.ts +23 -2
- package/dist/worker-protocol.d.ts.map +1 -1
- package/dist/worker-protocol.js +1 -1
- package/dist/worker-runtime.js +27 -3
- package/dist/worker-runtime.js.map +1 -1
- package/package.json +13 -9
- package/src/albex-worker.ts +103 -18
- package/src/albex.ts +2937 -2292
- package/src/errors.ts +63 -2
- package/src/pool/coordinator.ts +61 -34
- package/src/profile.ts +11 -10
- package/src/wasm-bindings.ts +225 -10
- package/src/worker-protocol.ts +12 -2
- package/src/worker-runtime.ts +28 -3
- package/wasm/pkg/albex_pdf.wasm +0 -0
- package/wasm/pkg/albex_wasm.wasm +0 -0
- package/wasm/pkg/albex_wasm_bg.wasm +0 -0
- package/wasm/pkg/albex_wasm_simd.wasm +0 -0
- package/wasm/pkg/albex_wasm_mini.wasm +0 -0
- package/wasm/pkg/albex_wasm_mini_simd.wasm +0 -0
- package/wasm/pkg/albex_wasm_pro.wasm +0 -0
- package/wasm/pkg/albex_wasm_pro_simd.wasm +0 -0
- package/wasm/pkg/albex_wasm_std.wasm +0 -0
- package/wasm/pkg/albex_wasm_std_simd.wasm +0 -0
package/src/worker-runtime.ts
CHANGED
|
@@ -36,8 +36,18 @@ async function dispatch(op: WorkerOp): Promise<unknown> {
|
|
|
36
36
|
}
|
|
37
37
|
case 'search':
|
|
38
38
|
return ensureEngine().search(op.query, op.options);
|
|
39
|
+
case 'listChunks':
|
|
40
|
+
return ensureEngine().listChunks(op.docId);
|
|
39
41
|
case 'removeDocument':
|
|
40
42
|
return ensureEngine().removeDocument(op.id);
|
|
43
|
+
case 'replaceDocument': {
|
|
44
|
+
// Same File-like wrapping as indexFile; the engine's replaceDocument
|
|
45
|
+
// handles remove + re-index + auto-compact under its own lock.
|
|
46
|
+
const file = new File([op.buffer], op.fileName);
|
|
47
|
+
return ensureEngine().replaceDocument(op.name, file);
|
|
48
|
+
}
|
|
49
|
+
case 'takeDiagnostics':
|
|
50
|
+
return ensureEngine().takeDiagnostics();
|
|
41
51
|
case 'compact':
|
|
42
52
|
ensureEngine().compact();
|
|
43
53
|
return undefined;
|
|
@@ -75,22 +85,37 @@ async function dispatch(op: WorkerOp): Promise<unknown> {
|
|
|
75
85
|
}
|
|
76
86
|
}
|
|
77
87
|
|
|
78
|
-
|
|
79
|
-
const { id, op } =
|
|
88
|
+
async function handle(req: WorkerRequest): Promise<void> {
|
|
89
|
+
const { id, op } = req;
|
|
80
90
|
try {
|
|
81
91
|
const result = await dispatch(op);
|
|
82
92
|
const res: WorkerResponse = { id, ok: true, result };
|
|
83
93
|
(self as unknown as Worker).postMessage(res);
|
|
84
94
|
} catch (err) {
|
|
85
|
-
const e = err as Error & { kind?: string };
|
|
95
|
+
const e = err as Error & { kind?: string; limit?: string; max?: number };
|
|
86
96
|
const res: WorkerResponse = {
|
|
87
97
|
id, ok: false,
|
|
88
98
|
error: {
|
|
89
99
|
name: e.name ?? 'Error',
|
|
90
100
|
kind: err instanceof AlbexError ? err.kind : undefined,
|
|
91
101
|
message: e.message ?? String(err),
|
|
102
|
+
// Capacity metadata (which pool + its runtime limit) — plain data,
|
|
103
|
+
// survives structuredClone, lets the main side rehydrate a full
|
|
104
|
+
// AlbexCapacityError.
|
|
105
|
+
limit: typeof e.limit === 'string' ? e.limit : undefined,
|
|
106
|
+
max: typeof e.max === 'number' ? e.max : undefined,
|
|
92
107
|
},
|
|
93
108
|
};
|
|
94
109
|
(self as unknown as Worker).postMessage(res);
|
|
95
110
|
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Process messages strictly in arrival order. The engine guards its own
|
|
114
|
+
// state, but a sync `search` arriving mid-`indexFile` await would otherwise
|
|
115
|
+
// be rejected as "busy"; queueing keeps the worker's externally-observable
|
|
116
|
+
// behaviour serial and matches the main-thread engine's serialization.
|
|
117
|
+
let _queue: Promise<void> = Promise.resolve();
|
|
118
|
+
self.onmessage = (ev: MessageEvent<WorkerRequest>) => {
|
|
119
|
+
const req = ev.data;
|
|
120
|
+
_queue = _queue.then(() => handle(req));
|
|
96
121
|
};
|
package/wasm/pkg/albex_pdf.wasm
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|