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.
Files changed (53) hide show
  1. package/CHANGELOG.md +466 -0
  2. package/README.md +32 -19
  3. package/dist/albex-worker.d.ts +65 -2
  4. package/dist/albex-worker.d.ts.map +1 -1
  5. package/dist/albex-worker.js +97 -20
  6. package/dist/albex-worker.js.map +1 -1
  7. package/dist/albex.d.ts +359 -55
  8. package/dist/albex.d.ts.map +1 -1
  9. package/dist/albex.js +766 -312
  10. package/dist/albex.js.map +1 -1
  11. package/dist/errors.d.ts +47 -2
  12. package/dist/errors.d.ts.map +1 -1
  13. package/dist/errors.js +41 -3
  14. package/dist/errors.js.map +1 -1
  15. package/dist/persistence.js +1 -1
  16. package/dist/pool/coordinator.d.ts +14 -6
  17. package/dist/pool/coordinator.d.ts.map +1 -1
  18. package/dist/pool/coordinator.js +65 -28
  19. package/dist/pool/coordinator.js.map +1 -1
  20. package/dist/profile.d.ts +11 -6
  21. package/dist/profile.d.ts.map +1 -1
  22. package/dist/profile.js +6 -13
  23. package/dist/profile.js.map +1 -1
  24. package/dist/resource-manager.js +1 -1
  25. package/dist/tiered-store.js +1 -1
  26. package/dist/wasm-bindings.d.ts +96 -6
  27. package/dist/wasm-bindings.d.ts.map +1 -1
  28. package/dist/wasm-bindings.js +110 -7
  29. package/dist/wasm-bindings.js.map +1 -1
  30. package/dist/worker-protocol.d.ts +23 -2
  31. package/dist/worker-protocol.d.ts.map +1 -1
  32. package/dist/worker-protocol.js +1 -1
  33. package/dist/worker-runtime.js +27 -3
  34. package/dist/worker-runtime.js.map +1 -1
  35. package/package.json +13 -9
  36. package/src/albex-worker.ts +103 -18
  37. package/src/albex.ts +2937 -2292
  38. package/src/errors.ts +63 -2
  39. package/src/pool/coordinator.ts +61 -34
  40. package/src/profile.ts +11 -10
  41. package/src/wasm-bindings.ts +225 -10
  42. package/src/worker-protocol.ts +12 -2
  43. package/src/worker-runtime.ts +28 -3
  44. package/wasm/pkg/albex_pdf.wasm +0 -0
  45. package/wasm/pkg/albex_wasm.wasm +0 -0
  46. package/wasm/pkg/albex_wasm_bg.wasm +0 -0
  47. package/wasm/pkg/albex_wasm_simd.wasm +0 -0
  48. package/wasm/pkg/albex_wasm_mini.wasm +0 -0
  49. package/wasm/pkg/albex_wasm_mini_simd.wasm +0 -0
  50. package/wasm/pkg/albex_wasm_pro.wasm +0 -0
  51. package/wasm/pkg/albex_wasm_pro_simd.wasm +0 -0
  52. package/wasm/pkg/albex_wasm_std.wasm +0 -0
  53. package/wasm/pkg/albex_wasm_std_simd.wasm +0 -0
@@ -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
- self.onmessage = async (ev: MessageEvent<WorkerRequest>) => {
79
- const { id, op } = ev.data;
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
  };
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file