albex 0.6.0 → 0.7.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/CHANGELOG.md +223 -0
- package/README.md +84 -30
- package/dist/_generated/inline-wasm.d.ts +2 -0
- package/dist/_generated/inline-wasm.d.ts.map +1 -0
- package/dist/_generated/inline-wasm.js +9 -0
- package/dist/_generated/inline-wasm.js.map +1 -0
- package/dist/albex-worker.d.ts +65 -2
- package/dist/albex-worker.d.ts.map +1 -1
- package/dist/albex-worker.js +98 -21
- package/dist/albex-worker.js.map +1 -1
- package/dist/albex.d.ts +250 -42
- package/dist/albex.d.ts.map +1 -1
- package/dist/albex.js +492 -120
- package/dist/albex.js.map +1 -1
- package/dist/errors.d.ts +35 -4
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +38 -3
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +47 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +82 -0
- package/dist/index.js.map +1 -0
- package/dist/inline.d.ts +10 -0
- package/dist/inline.d.ts.map +1 -0
- package/dist/inline.js +17 -0
- package/dist/inline.js.map +1 -0
- package/dist/persistence.js +2 -2
- 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.js +2 -2
- package/dist/resource-manager.js +2 -2
- package/dist/tiered-store.js +2 -2
- package/dist/wasm-bindings.d.ts +50 -1
- package/dist/wasm-bindings.d.ts.map +1 -1
- package/dist/wasm-bindings.js +20 -12
- 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 +2 -2
- package/dist/worker-runtime.js +17 -2
- package/dist/worker-runtime.js.map +1 -1
- package/package.json +14 -9
- package/src/_generated/inline-wasm.ts +9 -0
- package/src/albex-worker.ts +103 -18
- package/src/albex.ts +3053 -2524
- package/src/errors.ts +49 -4
- package/src/index.ts +81 -0
- package/src/inline.ts +9 -0
- package/src/pool/coordinator.ts +61 -34
- package/src/wasm-bindings.ts +78 -12
- package/src/worker-protocol.ts +12 -2
- package/src/worker-runtime.ts +16 -1
- 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/dist/albex-worker.d.ts
CHANGED
|
@@ -20,8 +20,24 @@
|
|
|
20
20
|
* call is in flight at a time. This matches the actual `static mut` model
|
|
21
21
|
* inside the .wasm and is fine for an interactive search UI (each keystroke
|
|
22
22
|
* replaces the previous query).
|
|
23
|
+
*
|
|
24
|
+
* ## OCR is NOT available in the worker
|
|
25
|
+
*
|
|
26
|
+
* `AlbexEngineWorker` has no `attachOcr`: an OCR adapter is an object with
|
|
27
|
+
* functions, and functions cannot cross the `postMessage` boundary (the
|
|
28
|
+
* structured-clone algorithm rejects them). Consequences:
|
|
29
|
+
*
|
|
30
|
+
* - **Scanned (image-only) PDFs index with 0 chunks, silently.** The
|
|
31
|
+
* engine records a diagnostic explaining why — read it with
|
|
32
|
+
* {@link takeDiagnostics} after `indexFile`.
|
|
33
|
+
* - If your corpus contains scanned PDFs and you need their text, index
|
|
34
|
+
* them with the synchronous main-thread `AlbexEngine` plus the OCR
|
|
35
|
+
* adapter (`engine.attachOcr(...)` / `@albex/ocr`'s `enableOcr`), then
|
|
36
|
+
* `save()` the snapshot and `load()` it from the worker engine.
|
|
37
|
+
* - A future protocol iteration could proxy OCR over a dedicated
|
|
38
|
+
* `MessagePort`; until then the main-thread engine is the OCR path.
|
|
23
39
|
*/
|
|
24
|
-
import type { AlbexOptions, IndexedDocument, SearchOptions, SearchResult, EngineStats, SearchStats } from './albex.js';
|
|
40
|
+
import type { AlbexDiagnostic, AlbexOptions, AuthoritativeChunk, IndexedDocument, SearchOptions, SearchResult, EngineStats, SearchStats } from './albex.js';
|
|
25
41
|
export interface AlbexWorkerOptions extends AlbexOptions {
|
|
26
42
|
/** URL to the bundled worker runtime script (worker-runtime.js). */
|
|
27
43
|
workerUrl: string | URL;
|
|
@@ -31,12 +47,38 @@ export declare class AlbexEngineWorker {
|
|
|
31
47
|
private _worker;
|
|
32
48
|
private _nextId;
|
|
33
49
|
private _pending;
|
|
34
|
-
private _docsCache;
|
|
35
50
|
constructor(opts: AlbexWorkerOptions);
|
|
51
|
+
/**
|
|
52
|
+
* Spawn the worker and initialise the engine inside it.
|
|
53
|
+
*
|
|
54
|
+
* Every serializable engine option is forwarded across the worker
|
|
55
|
+
* boundary (`wasmUrl`, `wasmBaseUrl`, `pdfWasmUrl`, `capacity`, `simd`,
|
|
56
|
+
* `gpu`, `gpuThreshold`, `maxFileBytes`) — only `workerUrl`, which is
|
|
57
|
+
* consumed on this side, is stripped. Notes on what applies in a worker:
|
|
58
|
+
*
|
|
59
|
+
* - `capacity`: fully honoured — both the `'std'`/`'large'` presets
|
|
60
|
+
* (plain strings) and a custom object are structured-clone-safe, so
|
|
61
|
+
* the worker-side engine sizes its pools exactly like a main-thread
|
|
62
|
+
* engine would. Mind the memory cost (`'large'` ≈ 180 MB) lives in
|
|
63
|
+
* the worker's heap.
|
|
64
|
+
* - `wasmBaseUrl` + `simd`: fully honoured — the worker-side engine can
|
|
65
|
+
* load the `_simd.wasm` variant.
|
|
66
|
+
* - `gpu` / `gpuThreshold`: honoured where the worker runtime exposes
|
|
67
|
+
* WebGPU. `navigator.gpu` is available in dedicated workers in
|
|
68
|
+
* Chromium-based browsers (compute needs no canvas); elsewhere the
|
|
69
|
+
* engine's GPU probe fails gracefully and searches use the CPU
|
|
70
|
+
* pre-filter, exactly as on the main thread.
|
|
71
|
+
*/
|
|
36
72
|
init(): Promise<void>;
|
|
37
73
|
private _send;
|
|
38
74
|
indexFile(file: File): Promise<IndexedDocument>;
|
|
39
75
|
search(query: string, opts?: SearchOptions): Promise<SearchResult[]>;
|
|
76
|
+
/**
|
|
77
|
+
* Enumerate the authoritative chunks Albex indexed for `docId`
|
|
78
|
+
* (`IndexedDocument.docId` from {@link indexFile}). Mirrors
|
|
79
|
+
* `AlbexEngine.listChunks` across the worker boundary.
|
|
80
|
+
*/
|
|
81
|
+
listChunks(docId: number): Promise<AuthoritativeChunk[]>;
|
|
40
82
|
/**
|
|
41
83
|
* Cooperative variant of `search`. Today the wire still sends a single
|
|
42
84
|
* batch — the result array is fetched in one round-trip from the worker
|
|
@@ -51,6 +93,27 @@ export declare class AlbexEngineWorker {
|
|
|
51
93
|
*/
|
|
52
94
|
searchStream(query: string, opts?: SearchOptions): AsyncIterable<SearchResult>;
|
|
53
95
|
removeDocument(id: string): Promise<boolean>;
|
|
96
|
+
/**
|
|
97
|
+
* Replace a previously indexed document with new content. Mirrors
|
|
98
|
+
* `AlbexEngine.replaceDocument`: equivalent to `removeDocument(name)` +
|
|
99
|
+
* `indexFile(newFile)` without tripping the idempotency check, plus an
|
|
100
|
+
* opportunistic compact under text-pool pressure — all inside the
|
|
101
|
+
* worker-side engine's lock. The file bytes are transferred (zero-copy),
|
|
102
|
+
* like `indexFile`.
|
|
103
|
+
*/
|
|
104
|
+
replaceDocument(name: string, newFile: File): Promise<IndexedDocument>;
|
|
105
|
+
/**
|
|
106
|
+
* Drain and return the diagnostics collected by the worker-side engine
|
|
107
|
+
* since the last call. Mirrors `AlbexEngine.takeDiagnostics` — consult it
|
|
108
|
+
* after `indexFile`/`load` to surface recoverable issues (PDF fallbacks,
|
|
109
|
+
* skipped content, persistence warnings). The worker-side buffer is
|
|
110
|
+
* cleared on each call.
|
|
111
|
+
*
|
|
112
|
+
* Particularly important in a worker: scanned PDFs index with **0 chunks**
|
|
113
|
+
* (no OCR available — see the note on OCR below), and the diagnostic
|
|
114
|
+
* explaining why is only visible through this method.
|
|
115
|
+
*/
|
|
116
|
+
takeDiagnostics(): Promise<AlbexDiagnostic[]>;
|
|
54
117
|
compact(): Promise<void>;
|
|
55
118
|
reset(): Promise<void>;
|
|
56
119
|
getStats(): Promise<EngineStats>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"albex-worker.d.ts","sourceRoot":"","sources":["../src/albex-worker.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"albex-worker.d.ts","sourceRoot":"","sources":["../src/albex-worker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAEH,OAAO,KAAK,EACV,eAAe,EACf,YAAY,EACZ,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,YAAY,EACZ,WAAW,EACX,WAAW,EACZ,MAAM,YAAY,CAAC;AAepB,MAAM,WAAW,kBAAmB,SAAQ,YAAY;IACtD,oEAAoE;IACpE,SAAS,EAAE,MAAM,GAAG,GAAG,CAAC;CACzB;AASD,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAqB;IAC3C,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,OAAO,CAAK;IACpB,OAAO,CAAC,QAAQ,CAA8B;gBAElC,IAAI,EAAE,kBAAkB;IAIpC;;;;;;;;;;;;;;;;;;;;OAoBG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IA4B3B,OAAO,CAAC,KAAK;IASP,SAAS,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,eAAe,CAAC;IAarD,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,GAAE,aAAkB,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;IAIxE;;;;OAIG;IACH,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC;IAIxD;;;;;;;OAOG;IACI,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,GAAE,aAAkB,GAAG,aAAa,CAAC,YAAY,CAAC;IAK9F;;OAEG;I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M,CAAC,OAAO,CAAC,IAAI,IAAI;CAKzB"}
|
package/dist/albex-worker.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* albex v0.
|
|
3
|
-
*
|
|
2
|
+
* albex v0.7.0
|
|
3
|
+
* Local full-text search for documents — runs entirely in the browser, no server, no upload. Zero-config: the WASM core is embedded (~19 KB gzipped), so `npm install albex` then `new AlbexEngine()` works in any bundler, esbuild/Angular included.
|
|
4
4
|
* (c) 2026 RafaCalRob
|
|
5
5
|
* @license MIT
|
|
6
6
|
* https://github.com/RafaCalRob/Albex#readme
|
|
@@ -27,18 +27,54 @@
|
|
|
27
27
|
* call is in flight at a time. This matches the actual `static mut` model
|
|
28
28
|
* inside the .wasm and is fine for an interactive search UI (each keystroke
|
|
29
29
|
* replaces the previous query).
|
|
30
|
+
*
|
|
31
|
+
* ## OCR is NOT available in the worker
|
|
32
|
+
*
|
|
33
|
+
* `AlbexEngineWorker` has no `attachOcr`: an OCR adapter is an object with
|
|
34
|
+
* functions, and functions cannot cross the `postMessage` boundary (the
|
|
35
|
+
* structured-clone algorithm rejects them). Consequences:
|
|
36
|
+
*
|
|
37
|
+
* - **Scanned (image-only) PDFs index with 0 chunks, silently.** The
|
|
38
|
+
* engine records a diagnostic explaining why — read it with
|
|
39
|
+
* {@link takeDiagnostics} after `indexFile`.
|
|
40
|
+
* - If your corpus contains scanned PDFs and you need their text, index
|
|
41
|
+
* them with the synchronous main-thread `AlbexEngine` plus the OCR
|
|
42
|
+
* adapter (`engine.attachOcr(...)` / `@albex/ocr`'s `enableOcr`), then
|
|
43
|
+
* `save()` the snapshot and `load()` it from the worker engine.
|
|
44
|
+
* - A future protocol iteration could proxy OCR over a dedicated
|
|
45
|
+
* `MessagePort`; until then the main-thread engine is the OCR path.
|
|
30
46
|
*/
|
|
31
|
-
import { AlbexError, AlbexInitError, AlbexUnsupportedFormatError, AlbexParseError, AlbexCapacityError, } from './errors.js';
|
|
47
|
+
import { AlbexError, AlbexInitError, AlbexUnsupportedFormatError, AlbexParseError, AlbexCapacityError, assertFileSizeWithinLimit, } from './errors.js';
|
|
32
48
|
let _workerSearchStreamWarned = false;
|
|
33
49
|
export class AlbexEngineWorker {
|
|
34
50
|
_opts;
|
|
35
51
|
_worker;
|
|
36
52
|
_nextId = 1;
|
|
37
53
|
_pending = new Map();
|
|
38
|
-
_docsCache = [];
|
|
39
54
|
constructor(opts) {
|
|
40
55
|
this._opts = opts;
|
|
41
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Spawn the worker and initialise the engine inside it.
|
|
59
|
+
*
|
|
60
|
+
* Every serializable engine option is forwarded across the worker
|
|
61
|
+
* boundary (`wasmUrl`, `wasmBaseUrl`, `pdfWasmUrl`, `capacity`, `simd`,
|
|
62
|
+
* `gpu`, `gpuThreshold`, `maxFileBytes`) — only `workerUrl`, which is
|
|
63
|
+
* consumed on this side, is stripped. Notes on what applies in a worker:
|
|
64
|
+
*
|
|
65
|
+
* - `capacity`: fully honoured — both the `'std'`/`'large'` presets
|
|
66
|
+
* (plain strings) and a custom object are structured-clone-safe, so
|
|
67
|
+
* the worker-side engine sizes its pools exactly like a main-thread
|
|
68
|
+
* engine would. Mind the memory cost (`'large'` ≈ 180 MB) lives in
|
|
69
|
+
* the worker's heap.
|
|
70
|
+
* - `wasmBaseUrl` + `simd`: fully honoured — the worker-side engine can
|
|
71
|
+
* load the `_simd.wasm` variant.
|
|
72
|
+
* - `gpu` / `gpuThreshold`: honoured where the worker runtime exposes
|
|
73
|
+
* WebGPU. `navigator.gpu` is available in dedicated workers in
|
|
74
|
+
* Chromium-based browsers (compute needs no canvas); elsewhere the
|
|
75
|
+
* engine's GPU probe fails gracefully and searches use the CPU
|
|
76
|
+
* pre-filter, exactly as on the main thread.
|
|
77
|
+
*/
|
|
42
78
|
async init() {
|
|
43
79
|
this._worker = new Worker(this._opts.workerUrl, { type: 'module' });
|
|
44
80
|
this._worker.onmessage = (ev) => {
|
|
@@ -59,10 +95,18 @@ export class AlbexEngineWorker {
|
|
|
59
95
|
p.reject(err);
|
|
60
96
|
this._pending.clear();
|
|
61
97
|
};
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
98
|
+
// Forward every serializable engine option. AlbexOptions is data-only
|
|
99
|
+
// (strings/numbers/booleans), but filter defensively so a future
|
|
100
|
+
// non-clonable option (function, DOM handle) cannot break postMessage.
|
|
101
|
+
const opts = {};
|
|
102
|
+
for (const [k, v] of Object.entries(this._opts)) {
|
|
103
|
+
if (k === 'workerUrl')
|
|
104
|
+
continue; // consumed on this side
|
|
105
|
+
if (v === undefined || typeof v === 'function')
|
|
106
|
+
continue;
|
|
107
|
+
opts[k] = v;
|
|
108
|
+
}
|
|
109
|
+
await this._send({ kind: 'init', opts });
|
|
66
110
|
}
|
|
67
111
|
_send(op, transfer = []) {
|
|
68
112
|
const id = this._nextId++;
|
|
@@ -73,15 +117,25 @@ export class AlbexEngineWorker {
|
|
|
73
117
|
});
|
|
74
118
|
}
|
|
75
119
|
async indexFile(file) {
|
|
120
|
+
// Size guard BEFORE reading: the worker-side engine enforces the same
|
|
121
|
+
// limit, but checking here avoids buffering an oversized file on the
|
|
122
|
+
// main thread just to have the worker reject it.
|
|
123
|
+
assertFileSizeWithinLimit(file, this._opts.maxFileBytes);
|
|
76
124
|
const buffer = await file.arrayBuffer();
|
|
77
125
|
// Transfer the buffer to avoid a copy.
|
|
78
|
-
|
|
79
|
-
this._docsCache.push(doc);
|
|
80
|
-
return doc;
|
|
126
|
+
return this._send({ kind: 'indexFile', name: file.name, buffer }, [buffer]);
|
|
81
127
|
}
|
|
82
128
|
search(query, opts = {}) {
|
|
83
129
|
return this._send({ kind: 'search', query, options: opts });
|
|
84
130
|
}
|
|
131
|
+
/**
|
|
132
|
+
* Enumerate the authoritative chunks Albex indexed for `docId`
|
|
133
|
+
* (`IndexedDocument.docId` from {@link indexFile}). Mirrors
|
|
134
|
+
* `AlbexEngine.listChunks` across the worker boundary.
|
|
135
|
+
*/
|
|
136
|
+
listChunks(docId) {
|
|
137
|
+
return this._send({ kind: 'listChunks', docId });
|
|
138
|
+
}
|
|
85
139
|
/**
|
|
86
140
|
* Cooperative variant of `search`. Today the wire still sends a single
|
|
87
141
|
* batch — the result array is fetched in one round-trip from the worker
|
|
@@ -106,16 +160,37 @@ export class AlbexEngineWorker {
|
|
|
106
160
|
yield* this.searchCooperative(query, opts);
|
|
107
161
|
}
|
|
108
162
|
async removeDocument(id) {
|
|
109
|
-
|
|
110
|
-
if (ok)
|
|
111
|
-
this._docsCache = this._docsCache.filter(d => d.name !== id && d.contentHash !== id);
|
|
112
|
-
return ok;
|
|
163
|
+
return this._send({ kind: 'removeDocument', id });
|
|
113
164
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
165
|
+
/**
|
|
166
|
+
* Replace a previously indexed document with new content. Mirrors
|
|
167
|
+
* `AlbexEngine.replaceDocument`: equivalent to `removeDocument(name)` +
|
|
168
|
+
* `indexFile(newFile)` without tripping the idempotency check, plus an
|
|
169
|
+
* opportunistic compact under text-pool pressure — all inside the
|
|
170
|
+
* worker-side engine's lock. The file bytes are transferred (zero-copy),
|
|
171
|
+
* like `indexFile`.
|
|
172
|
+
*/
|
|
173
|
+
async replaceDocument(name, newFile) {
|
|
174
|
+
assertFileSizeWithinLimit(newFile, this._opts.maxFileBytes);
|
|
175
|
+
const buffer = await newFile.arrayBuffer();
|
|
176
|
+
return this._send({ kind: 'replaceDocument', name, fileName: newFile.name, buffer }, [buffer]);
|
|
118
177
|
}
|
|
178
|
+
/**
|
|
179
|
+
* Drain and return the diagnostics collected by the worker-side engine
|
|
180
|
+
* since the last call. Mirrors `AlbexEngine.takeDiagnostics` — consult it
|
|
181
|
+
* after `indexFile`/`load` to surface recoverable issues (PDF fallbacks,
|
|
182
|
+
* skipped content, persistence warnings). The worker-side buffer is
|
|
183
|
+
* cleared on each call.
|
|
184
|
+
*
|
|
185
|
+
* Particularly important in a worker: scanned PDFs index with **0 chunks**
|
|
186
|
+
* (no OCR available — see the note on OCR below), and the diagnostic
|
|
187
|
+
* explaining why is only visible through this method.
|
|
188
|
+
*/
|
|
189
|
+
takeDiagnostics() {
|
|
190
|
+
return this._send({ kind: 'takeDiagnostics' });
|
|
191
|
+
}
|
|
192
|
+
async compact() { await this._send({ kind: 'compact' }); }
|
|
193
|
+
async reset() { await this._send({ kind: 'reset' }); }
|
|
119
194
|
getStats() { return this._send({ kind: 'getStats' }); }
|
|
120
195
|
getLastSearchStats() { return this._send({ kind: 'getLastSearchStats' }); }
|
|
121
196
|
getDocuments() { return this._send({ kind: 'getDocuments' }); }
|
|
@@ -134,7 +209,6 @@ export class AlbexEngineWorker {
|
|
|
134
209
|
p.reject(new AlbexError('disposed', 'Engine disposed'));
|
|
135
210
|
this._pending.clear();
|
|
136
211
|
this._worker?.terminate();
|
|
137
|
-
this._docsCache = [];
|
|
138
212
|
}
|
|
139
213
|
}
|
|
140
214
|
function rehydrateError(e) {
|
|
@@ -142,7 +216,10 @@ function rehydrateError(e) {
|
|
|
142
216
|
case 'init': return new AlbexInitError(e.message);
|
|
143
217
|
case 'unsupported_format': return new AlbexUnsupportedFormatError(e.message.replace(/^Unsupported format: \./, ''));
|
|
144
218
|
case 'parse': return new AlbexParseError('unknown', e.message);
|
|
145
|
-
|
|
219
|
+
// `limit`/`max` survive the wire (worker-runtime serialises them) so
|
|
220
|
+
// the rehydrated error still reports the runtime capacity that
|
|
221
|
+
// overflowed inside the worker-side engine.
|
|
222
|
+
case 'capacity': return new AlbexCapacityError(e.message, e.limit, e.max);
|
|
146
223
|
default: {
|
|
147
224
|
const err = new Error(e.message);
|
|
148
225
|
err.name = e.name;
|
package/dist/albex-worker.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"albex-worker.js","sourceRoot":"","sources":["../src/albex-worker.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"albex-worker.js","sourceRoot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