lucivy-wasm 2.0.1 → 3.0.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/README.md +54 -2
- package/js/lucivy-worker.js +298 -57
- package/js/lucivy.d.ts +130 -1
- package/js/lucivy.js +110 -6
- package/package.json +1 -1
- package/pkg/lucivy.js +2 -2
- package/pkg/lucivy.wasm +0 -0
package/README.md
CHANGED
|
@@ -1,8 +1,28 @@
|
|
|
1
|
-
# lucivy-wasm
|
|
1
|
+
# lucivy-wasm 3.0.1
|
|
2
2
|
|
|
3
3
|
Fast BM25 full-text search for browsers — WASM build with **threading** (emscripten pthreads), OPFS persistence, and snapshot/delta sync support. Runs in a Web Worker.
|
|
4
4
|
|
|
5
|
-
[**Try the live playground**](https://l-defraiteur.github.io/lucivy/) —
|
|
5
|
+
[**Try the live playground**](https://l-defraiteur.github.io/lucivy/) — it clones lucivy's own source from GitHub and indexes it in your browser.
|
|
6
|
+
|
|
7
|
+
### What's new in 3.0.0
|
|
8
|
+
|
|
9
|
+
Measured on 10 000 Linux kernel files, in the browser, 8 threads:
|
|
10
|
+
|
|
11
|
+
- **Indexing in 55 s** (was ~25 min) and **~1.5x the native query time**
|
|
12
|
+
(124-133 ms per query, median 69-92 ms; native 79 / 49) — the engine now
|
|
13
|
+
runs on **mimalloc**; emscripten's default allocator serialised every thread
|
|
14
|
+
on one lock.
|
|
15
|
+
- **SFX v3 index format** with denser sidecars (−22 %), exact highlights on
|
|
16
|
+
every query mode, `parse` boolean syntax, `queryWarnings`, fuzzy by
|
|
17
|
+
Levenshtein or **Jaro-Winkler** (`fuzzy_metric`, `min_similarity`).
|
|
18
|
+
- **Memory made explicit**: `memoryStatus()` says whether the index is held
|
|
19
|
+
in memory (up to 3 GB by default) or streamed from OPFS, and `preload()`
|
|
20
|
+
loads it once, after every background merge is done. A page that has just
|
|
21
|
+
indexed several GB cannot also serve them (4 GB address space): persist,
|
|
22
|
+
reload, open.
|
|
23
|
+
- Bounded by construction: SFX segment budget, two segment builds at a time,
|
|
24
|
+
merges capped at 800 documents (48 small segments fill eight threads where
|
|
25
|
+
19 large ones fed one), at most 512 documents queued.
|
|
6
26
|
|
|
7
27
|
### What's new in v2
|
|
8
28
|
|
|
@@ -84,6 +104,38 @@ const index3 = await lucivy.importSnapshot(snapshotData, '/restored');
|
|
|
84
104
|
lucivy.terminate();
|
|
85
105
|
```
|
|
86
106
|
|
|
107
|
+
#### Startup options
|
|
108
|
+
|
|
109
|
+
`new Lucivy(workerUrl, options)` — every option maps to a module argument
|
|
110
|
+
read before the engine starts; the defaults are the measured ones:
|
|
111
|
+
|
|
112
|
+
| option | default | effect |
|
|
113
|
+
|---|---|---|
|
|
114
|
+
| `noOpfs` | `false` | in-memory filesystem, the index lives for the session |
|
|
115
|
+
| `verbose` | `false` | engine diagnostics (`LUCIVY_VERBOSE`, `V3_PROFILE`) |
|
|
116
|
+
| `fileCacheMb` | index size | whole-file cache; pins the budget when set |
|
|
117
|
+
| `ramIndexMaxMb` | `3072` | above this the index is streamed from OPFS instead of held |
|
|
118
|
+
| `schedulerThreads` | `min(cores, 8)` | luciole scheduler pool (12 gains nothing over 8) |
|
|
119
|
+
| `writerThreads` | `1` | indexer threads; the writer heap follows |
|
|
120
|
+
| `maxMergedDocs` | `800` | largest segment a background merge may produce |
|
|
121
|
+
| `maxBuilds` | `2` | segment builds at once (four exhaust the address space) |
|
|
122
|
+
|
|
123
|
+
#### Memory
|
|
124
|
+
|
|
125
|
+
```javascript
|
|
126
|
+
const st = await index.memoryStatus();
|
|
127
|
+
// { index_bytes, in_memory, num_docs, warnings: [..], shards: [..] }
|
|
128
|
+
if (st.in_memory) {
|
|
129
|
+
const pre = await index.preload(); // { bytes, files, ms, skipped }
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
`preload()` waits for background merges to be quiet, then reads every file
|
|
134
|
+
of the index into memory once — a single substring query opens nearly every
|
|
135
|
+
sidecar of every segment, so lazy reading only hides that cost in the first
|
|
136
|
+
search. It does nothing when the index is streamed. `warnings` carries the
|
|
137
|
+
sentence to show a user when the index does not fit.
|
|
138
|
+
|
|
87
139
|
### LucivyIndex
|
|
88
140
|
|
|
89
141
|
#### Add / update / delete
|
package/js/lucivy-worker.js
CHANGED
|
@@ -1,22 +1,143 @@
|
|
|
1
1
|
// lucivy-worker.js — Web Worker that runs lucivy-emscripten with OPFS persistence.
|
|
2
2
|
//
|
|
3
|
+
// Threading model: the Rust side uses a global actor scheduler with persistent
|
|
4
|
+
// pthreads. ASYNCIFY lets blocking Rust calls (mutex, condvar) yield back to
|
|
5
|
+
// the event loop so emscripten can coordinate pthreads.
|
|
6
|
+
//
|
|
3
7
|
// Usage from main thread:
|
|
4
8
|
// const worker = new Worker('lucivy-worker.js', { type: 'module' });
|
|
5
9
|
// worker.postMessage({ type: 'init', id: 1 });
|
|
6
10
|
//
|
|
7
11
|
// Or use lucivy.js for a Promise-based API.
|
|
8
12
|
|
|
9
|
-
// The emscripten module must be in ../pkg/lucivy.js relative to this worker.
|
|
10
|
-
// We use importScripts-compatible dynamic import.
|
|
11
13
|
let Module = null;
|
|
12
14
|
|
|
13
15
|
const indexes = new Map(); // path -> ctx pointer
|
|
14
16
|
|
|
17
|
+
// ── Debug: relay worker logs to main thread ──────────────────────────────────
|
|
18
|
+
|
|
19
|
+
function wlog(...args) {
|
|
20
|
+
const msg = args.map(a => typeof a === 'object' ? JSON.stringify(a) : String(a)).join(' ');
|
|
21
|
+
self.postMessage({ type: 'log', msg });
|
|
22
|
+
console.log(msg);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// ── Diag: send logs to server + poll eval commands (debug mode only) ─────────
|
|
26
|
+
// Debug mode is enabled when the debug server (serve.mjs) is reachable.
|
|
27
|
+
// In standalone mode (GitHub Pages, static server), diag is disabled automatically.
|
|
28
|
+
|
|
29
|
+
const DIAG_URL = self.location.origin;
|
|
30
|
+
let diagLogBatch = [];
|
|
31
|
+
let diagEnabled = false; // off by default, enabled after probe
|
|
32
|
+
|
|
33
|
+
function diagSendLog(line) {
|
|
34
|
+
if (!diagEnabled) return;
|
|
35
|
+
diagLogBatch.push(line);
|
|
36
|
+
if (diagLogBatch.length >= 50) diagFlush();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function diagFlush() {
|
|
40
|
+
if (!diagEnabled || diagLogBatch.length === 0) return;
|
|
41
|
+
const batch = diagLogBatch;
|
|
42
|
+
diagLogBatch = [];
|
|
43
|
+
fetch(`${DIAG_URL}/log`, { method: 'POST', body: batch.join('\n') }).catch(() => {});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async function diagEvalPoller() {
|
|
47
|
+
while (diagEnabled) {
|
|
48
|
+
try {
|
|
49
|
+
const resp = await fetch(`${DIAG_URL}/eval/poll`);
|
|
50
|
+
const cmd = await resp.json();
|
|
51
|
+
if (cmd.id && cmd.js) {
|
|
52
|
+
wlog(`[eval] executing: ${cmd.js}`);
|
|
53
|
+
let result = null, error = null;
|
|
54
|
+
try {
|
|
55
|
+
result = String(eval(cmd.js));
|
|
56
|
+
} catch (e) {
|
|
57
|
+
error = e.message;
|
|
58
|
+
}
|
|
59
|
+
wlog(`[eval] result: ${error ? 'ERR ' + error : result}`);
|
|
60
|
+
fetch(`${DIAG_URL}/eval/result`, {
|
|
61
|
+
method: 'POST',
|
|
62
|
+
headers: { 'Content-Type': 'application/json' },
|
|
63
|
+
body: JSON.stringify({ id: cmd.id, result, error }),
|
|
64
|
+
}).catch(() => {});
|
|
65
|
+
}
|
|
66
|
+
} catch {}
|
|
67
|
+
await new Promise(r => setTimeout(r, 500));
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Probe: check if debug server is running. Enable diag only if reachable.
|
|
72
|
+
(async () => {
|
|
73
|
+
try {
|
|
74
|
+
const resp = await fetch(`${DIAG_URL}/eval/poll`, { signal: AbortSignal.timeout(1000) });
|
|
75
|
+
if (resp.ok) {
|
|
76
|
+
diagEnabled = true;
|
|
77
|
+
wlog('[diag] debug server detected — diag enabled');
|
|
78
|
+
setInterval(diagFlush, 500);
|
|
79
|
+
diagEvalPoller();
|
|
80
|
+
}
|
|
81
|
+
} catch {
|
|
82
|
+
wlog('[diag] no debug server — standalone mode');
|
|
83
|
+
}
|
|
84
|
+
})();
|
|
85
|
+
|
|
86
|
+
// Hook: intercept eprintln! (emscripten stderr) and send to diag server.
|
|
87
|
+
// emscripten routes eprintln! → Module.printErr → console.error.
|
|
88
|
+
// We monkey-patch console.error in the worker to capture these.
|
|
89
|
+
const _origConsoleError = console.error;
|
|
90
|
+
console.error = function(...args) {
|
|
91
|
+
const msg = args.map(a => typeof a === 'object' ? JSON.stringify(a) : String(a)).join(' ');
|
|
92
|
+
diagSendLog(msg);
|
|
93
|
+
_origConsoleError.apply(console, args);
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
// ── Rust log poller ──────────────────────────────────────────────────────────
|
|
97
|
+
// Polls lucivy_read_logs() every 200ms and relays to main thread via wlog.
|
|
98
|
+
|
|
99
|
+
function startLogPoller() {
|
|
100
|
+
setInterval(async () => {
|
|
101
|
+
if (!Module) return;
|
|
102
|
+
try {
|
|
103
|
+
const ptr = await Module.ccall('lucivy_read_logs', 'number', [], [], { async: true });
|
|
104
|
+
if (!ptr) return;
|
|
105
|
+
const json = Module.UTF8ToString(ptr);
|
|
106
|
+
const logs = JSON.parse(json);
|
|
107
|
+
for (const msg of logs) {
|
|
108
|
+
wlog('[rust] ' + msg);
|
|
109
|
+
}
|
|
110
|
+
} catch (e) { /* ignore */ }
|
|
111
|
+
}, 200);
|
|
112
|
+
}
|
|
113
|
+
|
|
15
114
|
// ── Helpers ──────────────────────────────────────────────────────────────────
|
|
16
115
|
|
|
17
|
-
function
|
|
116
|
+
async function drainRustLogs() {
|
|
117
|
+
try {
|
|
118
|
+
// Try direct call first (no ASYNCIFY overhead), fall back to ccall
|
|
119
|
+
let ptr;
|
|
120
|
+
if (Module._lucivy_read_logs) {
|
|
121
|
+
ptr = Module._lucivy_read_logs();
|
|
122
|
+
} else if (Module.asm && Module.asm._lucivy_read_logs) {
|
|
123
|
+
ptr = Module.asm._lucivy_read_logs();
|
|
124
|
+
} else {
|
|
125
|
+
// List available exports for debugging
|
|
126
|
+
const exports = Module.asm ? Object.keys(Module.asm).filter(k => k.includes('lucivy')).join(', ') : 'no asm';
|
|
127
|
+
wlog('[drain] lucivy_read_logs not found. exports: ' + exports);
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
if (ptr) {
|
|
131
|
+
const json = Module.UTF8ToString(ptr);
|
|
132
|
+
const logs = JSON.parse(json);
|
|
133
|
+
for (const msg of logs) wlog('[rust] ' + msg);
|
|
134
|
+
}
|
|
135
|
+
} catch (e) { wlog('[drain] ERROR: ' + e.message); }
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
async function callStr(fn, ...args) {
|
|
18
139
|
const types = args.map(a => typeof a === 'number' ? 'number' : 'string');
|
|
19
|
-
const ptr = Module.ccall(fn, 'number', types, args);
|
|
140
|
+
const ptr = await Module.ccall(fn, 'number', types, args, { async: true });
|
|
20
141
|
return Module.UTF8ToString(ptr);
|
|
21
142
|
}
|
|
22
143
|
|
|
@@ -108,7 +229,7 @@ async function removeAllFiles(path) {
|
|
|
108
229
|
// ── Sync dirty files from emscripten index to OPFS ──────────────────────────
|
|
109
230
|
|
|
110
231
|
async function syncDirtyToOpfs(path, ctx) {
|
|
111
|
-
const dirtyJson = callStr('lucivy_export_dirty', ctx);
|
|
232
|
+
const dirtyJson = await callStr('lucivy_export_dirty', ctx);
|
|
112
233
|
const dirty = JSON.parse(dirtyJson);
|
|
113
234
|
|
|
114
235
|
const modified = (dirty.modified || []).map(([name, b64]) => [name, base64ToUint8Array(b64)]);
|
|
@@ -133,34 +254,105 @@ self.onmessage = async (e) => {
|
|
|
133
254
|
|
|
134
255
|
switch (type) {
|
|
135
256
|
case 'init': {
|
|
136
|
-
// Dynamic import of the emscripten module.
|
|
137
|
-
// The worker URL determines the base for relative imports.
|
|
138
257
|
const { default: createLucivy } = await import('../pkg/lucivy.js');
|
|
139
|
-
Module = await createLucivy(
|
|
258
|
+
Module = await createLucivy({
|
|
259
|
+
// Intercept eprintln! from ALL pthreads and send to diag server.
|
|
260
|
+
printErr: function(text) {
|
|
261
|
+
diagSendLog(text);
|
|
262
|
+
},
|
|
263
|
+
// `--no-opfs`: in-memory filesystem, index lost at reload.
|
|
264
|
+
arguments: [
|
|
265
|
+
...(args.noOpfs ? ['--no-opfs'] : []),
|
|
266
|
+
...(args.verbose ? ['--verbose'] : []),
|
|
267
|
+
...(args.fileCacheMb ? [`--file-cache-mb=${args.fileCacheMb}`] : []),
|
|
268
|
+
...(args.ramIndexMaxMb ? [`--ram-index-max-mb=${args.ramIndexMaxMb}`] : []),
|
|
269
|
+
...(args.schedulerThreads ? [`--scheduler-threads=${args.schedulerThreads}`] : []),
|
|
270
|
+
...(args.writerThreads ? [`--writer-threads=${args.writerThreads}`] : []),
|
|
271
|
+
...(args.maxMergedDocs ? [`--max-merged-docs=${args.maxMergedDocs}`] : []),
|
|
272
|
+
...(args.maxBuilds ? [`--max-builds=${args.maxBuilds}`] : []),
|
|
273
|
+
],
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
// Scheduler is configured to 4 threads by default in main().
|
|
277
|
+
// Override with lucivy_configure() if needed.
|
|
278
|
+
startLogPoller();
|
|
279
|
+
|
|
280
|
+
// Send SharedArrayBuffer ring buffer info to main thread
|
|
281
|
+
// so it can read Rust logs directly (even during deadlocks).
|
|
282
|
+
try {
|
|
283
|
+
const ringPtr = await Module.ccall(
|
|
284
|
+
'lucivy_log_ring_ptr', 'number', [], [], { async: true });
|
|
285
|
+
const ringSize = await Module.ccall(
|
|
286
|
+
'lucivy_log_ring_size', 'number', [], [], { async: true });
|
|
287
|
+
if (ringPtr && ringSize && Module.HEAPU8.buffer instanceof SharedArrayBuffer) {
|
|
288
|
+
self.postMessage({
|
|
289
|
+
type: 'logRing',
|
|
290
|
+
buffer: Module.HEAPU8.buffer,
|
|
291
|
+
ringPtr,
|
|
292
|
+
ringSize,
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
} catch (e) { /* log ring not available */ }
|
|
296
|
+
|
|
297
|
+
// Get commit status pointer for SAB-based polling (zero ccall).
|
|
298
|
+
try {
|
|
299
|
+
const statusPtr = await Module.ccall(
|
|
300
|
+
'lucivy_commit_status_ptr', 'number', [], [], { async: true });
|
|
301
|
+
if (statusPtr && Module.HEAPU8.buffer instanceof SharedArrayBuffer) {
|
|
302
|
+
self._commitStatusView = new Int32Array(
|
|
303
|
+
Module.HEAPU8.buffer, statusPtr, 1);
|
|
304
|
+
}
|
|
305
|
+
} catch (e) { /* commit status not available */ }
|
|
140
306
|
result = true;
|
|
141
307
|
break;
|
|
142
308
|
}
|
|
143
309
|
|
|
144
310
|
case 'create': {
|
|
145
|
-
const { path, fields, stemmer } = args;
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
311
|
+
const { path, fields, config, stemmer } = args;
|
|
312
|
+
// Support both legacy (fields array) and new (full config object).
|
|
313
|
+
let configJson;
|
|
314
|
+
if (config) {
|
|
315
|
+
configJson = typeof config === 'string' ? config : JSON.stringify(config);
|
|
316
|
+
} else {
|
|
317
|
+
configJson = typeof fields === 'string' ? fields : JSON.stringify(fields);
|
|
318
|
+
}
|
|
319
|
+
const ctx = await Module.ccall('lucivy_create', 'number',
|
|
320
|
+
['string', 'string'],
|
|
321
|
+
[path, configJson], { async: true });
|
|
150
322
|
if (!ctx) throw new Error('lucivy_create returned null');
|
|
151
323
|
indexes.set(path, ctx);
|
|
152
324
|
|
|
325
|
+
// Yield so the event loop can activate global scheduler pthreads
|
|
326
|
+
// spawned on first use. Only matters for the very first index.
|
|
327
|
+
await new Promise(r => setTimeout(r, 0));
|
|
328
|
+
|
|
153
329
|
// Export all files to OPFS for initial persistence (best-effort).
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
330
|
+
// Only when the binding exports it: the index already lives in
|
|
331
|
+
// OPFS through WASMFS, and calling an unknown export aborts the
|
|
332
|
+
// runtime under ASSERTIONS.
|
|
333
|
+
if (Module._lucivy_export_all) {
|
|
334
|
+
try {
|
|
335
|
+
const allJson = await callStr('lucivy_export_all', ctx);
|
|
336
|
+
const allFiles = JSON.parse(allJson);
|
|
337
|
+
const modified = allFiles.map(([name, b64]) => [name, base64ToUint8Array(b64)]);
|
|
338
|
+
await writeFiles(path, modified, []);
|
|
339
|
+
} catch (e) {
|
|
340
|
+
console.warn('[lucivy-worker] OPFS initial sync skipped:', e.message);
|
|
341
|
+
}
|
|
161
342
|
}
|
|
162
343
|
|
|
163
|
-
result = { path, numDocs: Module.ccall('lucivy_num_docs', 'number', ['number'], [ctx]) };
|
|
344
|
+
result = { path, numDocs: await Module.ccall('lucivy_num_docs', 'number', ['number'], [ctx], { async: true }) };
|
|
345
|
+
break;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
case 'openDirect': {
|
|
349
|
+
// The index already lives in OPFS through WASMFS: open it in
|
|
350
|
+
// place (no JS-side file import).
|
|
351
|
+
const { path } = args;
|
|
352
|
+
const ctx = await Module.ccall('lucivy_open', 'number', ['string'], [path], { async: true });
|
|
353
|
+
if (!ctx) throw new Error(`lucivy_open failed for ${path}`);
|
|
354
|
+
indexes.set(path, ctx);
|
|
355
|
+
result = { path, numDocs: await Module.ccall('lucivy_num_docs', 'number', ['number'], [ctx], { async: true }) };
|
|
164
356
|
break;
|
|
165
357
|
}
|
|
166
358
|
|
|
@@ -171,30 +363,27 @@ self.onmessage = async (e) => {
|
|
|
171
363
|
throw new Error(`No index found at OPFS path: ${path}`);
|
|
172
364
|
}
|
|
173
365
|
|
|
174
|
-
|
|
175
|
-
const openCtx = Module.ccall('lucivy_open_begin', 'number', ['string'], [path]);
|
|
366
|
+
const openCtx = await Module.ccall('lucivy_open_begin', 'number', ['string'], [path], { async: true });
|
|
176
367
|
if (!openCtx) throw new Error('lucivy_open_begin returned null');
|
|
177
368
|
|
|
178
369
|
for (const [name, data] of files) {
|
|
179
|
-
// Allocate memory and copy file data.
|
|
180
370
|
const ptr = Module._malloc(data.length);
|
|
181
371
|
Module.HEAPU8.set(data, ptr);
|
|
182
|
-
// Write file name as UTF8.
|
|
183
372
|
const nameBytes = Module.lengthBytesUTF8(name) + 1;
|
|
184
373
|
const namePtr = Module._malloc(nameBytes);
|
|
185
374
|
Module.stringToUTF8(name, namePtr, nameBytes);
|
|
186
|
-
Module.ccall('lucivy_import_file', null,
|
|
375
|
+
await Module.ccall('lucivy_import_file', null,
|
|
187
376
|
['number', 'number', 'number', 'number'],
|
|
188
|
-
[openCtx, namePtr, ptr, data.length]);
|
|
377
|
+
[openCtx, namePtr, ptr, data.length], { async: true });
|
|
189
378
|
Module._free(namePtr);
|
|
190
379
|
Module._free(ptr);
|
|
191
380
|
}
|
|
192
381
|
|
|
193
|
-
const ctx = Module.ccall('lucivy_open_finish', 'number', ['number'], [openCtx]);
|
|
382
|
+
const ctx = await Module.ccall('lucivy_open_finish', 'number', ['number'], [openCtx], { async: true });
|
|
194
383
|
if (!ctx) throw new Error('lucivy_open_finish returned null');
|
|
195
384
|
indexes.set(path, ctx);
|
|
196
385
|
|
|
197
|
-
result = { path, numDocs: Module.ccall('lucivy_num_docs', 'number', ['number'], [ctx]) };
|
|
386
|
+
result = { path, numDocs: await Module.ccall('lucivy_num_docs', 'number', ['number'], [ctx], { async: true }) };
|
|
198
387
|
break;
|
|
199
388
|
}
|
|
200
389
|
|
|
@@ -202,7 +391,7 @@ self.onmessage = async (e) => {
|
|
|
202
391
|
const ctx = getCtx(args.path);
|
|
203
392
|
const fieldsJson = typeof args.fields === 'string'
|
|
204
393
|
? args.fields : JSON.stringify(args.fields);
|
|
205
|
-
const res = callStr('lucivy_add', ctx, args.docId, fieldsJson);
|
|
394
|
+
const res = await callStr('lucivy_add', ctx, args.docId, fieldsJson);
|
|
206
395
|
checkResult(res);
|
|
207
396
|
result = true;
|
|
208
397
|
break;
|
|
@@ -212,7 +401,7 @@ self.onmessage = async (e) => {
|
|
|
212
401
|
const ctx = getCtx(args.path);
|
|
213
402
|
const docsJson = typeof args.docs === 'string'
|
|
214
403
|
? args.docs : JSON.stringify(args.docs);
|
|
215
|
-
const res = callStr('lucivy_add_many', ctx, docsJson);
|
|
404
|
+
const res = await callStr('lucivy_add_many', ctx, docsJson);
|
|
216
405
|
checkResult(res);
|
|
217
406
|
result = true;
|
|
218
407
|
break;
|
|
@@ -220,7 +409,7 @@ self.onmessage = async (e) => {
|
|
|
220
409
|
|
|
221
410
|
case 'remove': {
|
|
222
411
|
const ctx = getCtx(args.path);
|
|
223
|
-
const res = callStr('lucivy_remove', ctx, args.docId);
|
|
412
|
+
const res = await callStr('lucivy_remove', ctx, args.docId);
|
|
224
413
|
checkResult(res);
|
|
225
414
|
result = true;
|
|
226
415
|
break;
|
|
@@ -230,7 +419,7 @@ self.onmessage = async (e) => {
|
|
|
230
419
|
const ctx = getCtx(args.path);
|
|
231
420
|
const fieldsJson = typeof args.fields === 'string'
|
|
232
421
|
? args.fields : JSON.stringify(args.fields);
|
|
233
|
-
const res = callStr('lucivy_update', ctx, args.docId, fieldsJson);
|
|
422
|
+
const res = await callStr('lucivy_update', ctx, args.docId, fieldsJson);
|
|
234
423
|
checkResult(res);
|
|
235
424
|
result = true;
|
|
236
425
|
break;
|
|
@@ -238,34 +427,90 @@ self.onmessage = async (e) => {
|
|
|
238
427
|
|
|
239
428
|
case 'commit': {
|
|
240
429
|
const ctx = getCtx(args.path);
|
|
241
|
-
const res = callStr('lucivy_commit', ctx);
|
|
242
|
-
checkResult(res);
|
|
243
430
|
|
|
244
|
-
//
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
431
|
+
// Commit on a pthread, status polled through the SAB: this JS
|
|
432
|
+
// thread is the emscripten runtime's main thread, and blocking
|
|
433
|
+
// it inside a synchronous ccall starves everything the pthreads
|
|
434
|
+
// proxy to it (OPFS, thread spawn) — the 2000-doc commit of the
|
|
435
|
+
// playground stalled forever that way. Falls back to the
|
|
436
|
+
// synchronous call when the SAB status view is not available.
|
|
437
|
+
if (self._commitStatusView) {
|
|
438
|
+
const started = await Module.ccall('lucivy_commit_async', 'number', ['number'], [ctx], { async: true });
|
|
439
|
+
if (started !== 0) throw new Error('commit already running');
|
|
440
|
+
while (Atomics.load(self._commitStatusView, 0) === 1) {
|
|
441
|
+
await new Promise(r => setTimeout(r, 20));
|
|
442
|
+
}
|
|
443
|
+
const res = await callStr('lucivy_commit_finish');
|
|
444
|
+
checkResult(res);
|
|
445
|
+
} else {
|
|
446
|
+
const res = await callStr('lucivy_commit', ctx);
|
|
447
|
+
checkResult(res);
|
|
249
448
|
}
|
|
250
449
|
|
|
251
|
-
result = { numDocs: Module.ccall('lucivy_num_docs', 'number', ['number'], [ctx]) };
|
|
450
|
+
result = { numDocs: await Module.ccall('lucivy_num_docs', 'number', ['number'], [ctx], { async: true }) };
|
|
252
451
|
break;
|
|
253
452
|
}
|
|
254
453
|
|
|
255
454
|
case 'rollback': {
|
|
256
455
|
const ctx = getCtx(args.path);
|
|
257
|
-
const res = callStr('lucivy_rollback', ctx);
|
|
456
|
+
const res = await callStr('lucivy_rollback', ctx);
|
|
258
457
|
checkResult(res);
|
|
259
458
|
result = true;
|
|
260
459
|
break;
|
|
261
460
|
}
|
|
262
461
|
|
|
462
|
+
case 'compact': {
|
|
463
|
+
// Merge every shard down to segments of at most maxDocs
|
|
464
|
+
// documents (same thread + SAB status pattern as commit).
|
|
465
|
+
const ctx = getCtx(args.path);
|
|
466
|
+
const started = await Module.ccall('lucivy_compact_async', 'number', ['number', 'number'], [ctx, args.maxDocs || 10000], { async: true });
|
|
467
|
+
if (started !== 0) throw new Error('commit already running');
|
|
468
|
+
while (Atomics.load(self._commitStatusView, 0) === 1) {
|
|
469
|
+
await new Promise(r => setTimeout(r, 50));
|
|
470
|
+
}
|
|
471
|
+
checkResult(await callStr('lucivy_commit_finish'));
|
|
472
|
+
result = true;
|
|
473
|
+
break;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
case 'drainMerges': {
|
|
477
|
+
// Same commit path as 'commit' (drain_merges is an alias in the
|
|
478
|
+
// binding); goes through the pthread + SAB status for the same reason.
|
|
479
|
+
const ctx = getCtx(args.path);
|
|
480
|
+
if (self._commitStatusView) {
|
|
481
|
+
const started = await Module.ccall('lucivy_commit_async', 'number', ['number'], [ctx], { async: true });
|
|
482
|
+
if (started !== 0) throw new Error('commit already running');
|
|
483
|
+
while (Atomics.load(self._commitStatusView, 0) === 1) {
|
|
484
|
+
await new Promise(r => setTimeout(r, 20));
|
|
485
|
+
}
|
|
486
|
+
checkResult(await callStr('lucivy_commit_finish'));
|
|
487
|
+
} else {
|
|
488
|
+
checkResult(await callStr('lucivy_drain_merges', ctx));
|
|
489
|
+
}
|
|
490
|
+
result = true;
|
|
491
|
+
break;
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
case 'preload': {
|
|
495
|
+
const ctx = getCtx(args.path);
|
|
496
|
+
result = JSON.parse(await callStr('lucivy_preload', ctx));
|
|
497
|
+
if (result.error) throw new Error(result.error);
|
|
498
|
+
break;
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
case 'memoryStatus': {
|
|
502
|
+
const ctx = getCtx(args.path);
|
|
503
|
+
result = JSON.parse(await callStr('lucivy_memory_status', ctx));
|
|
504
|
+
if (result.error) throw new Error(result.error);
|
|
505
|
+
break;
|
|
506
|
+
}
|
|
507
|
+
|
|
263
508
|
case 'search': {
|
|
264
509
|
const ctx = getCtx(args.path);
|
|
265
510
|
const queryJson = typeof args.query === 'string' && !args.query.startsWith('{')
|
|
266
511
|
? JSON.stringify(args.query)
|
|
267
512
|
: (typeof args.query === 'object' ? JSON.stringify(args.query) : args.query);
|
|
268
|
-
const json = callStr('lucivy_search', ctx, queryJson, args.limit || 10, args.highlights ? 1 : 0, args.fields ? 1 : 0);
|
|
513
|
+
const json = await callStr('lucivy_search', ctx, queryJson, args.limit || 10, args.highlights ? 1 : 0, args.fields ? 1 : 0);
|
|
269
514
|
result = JSON.parse(json);
|
|
270
515
|
if (result.error) throw new Error(result.error);
|
|
271
516
|
break;
|
|
@@ -281,9 +526,10 @@ self.onmessage = async (e) => {
|
|
|
281
526
|
const idsPtr = Module._malloc(ids.byteLength);
|
|
282
527
|
Module.HEAPU8.set(new Uint8Array(ids.buffer), idsPtr);
|
|
283
528
|
|
|
284
|
-
const resPtr = Module.ccall('lucivy_search_filtered', 'number',
|
|
529
|
+
const resPtr = await Module.ccall('lucivy_search_filtered', 'number',
|
|
285
530
|
['number', 'string', 'number', 'number', 'number', 'number', 'number'],
|
|
286
|
-
[ctx, queryJson, args.limit || 10, idsPtr, ids.length, args.highlights ? 1 : 0, args.fields ? 1 : 0]
|
|
531
|
+
[ctx, queryJson, args.limit || 10, idsPtr, ids.length, args.highlights ? 1 : 0, args.fields ? 1 : 0],
|
|
532
|
+
{ async: true });
|
|
287
533
|
const json = Module.UTF8ToString(resPtr);
|
|
288
534
|
Module._free(idsPtr);
|
|
289
535
|
|
|
@@ -293,10 +539,6 @@ self.onmessage = async (e) => {
|
|
|
293
539
|
}
|
|
294
540
|
|
|
295
541
|
case 'close': {
|
|
296
|
-
// Remove from tracking. The Rust context is intentionally NOT destroyed
|
|
297
|
-
// here because lucivy_destroy can deadlock under emscripten pthreads
|
|
298
|
-
// (IndexWriter drop joins threads via the event loop).
|
|
299
|
-
// All WASM memory is fully reclaimed when the worker is terminated.
|
|
300
542
|
indexes.delete(args.path);
|
|
301
543
|
result = true;
|
|
302
544
|
break;
|
|
@@ -304,7 +546,6 @@ self.onmessage = async (e) => {
|
|
|
304
546
|
|
|
305
547
|
case 'destroy': {
|
|
306
548
|
indexes.delete(args.path);
|
|
307
|
-
// OPFS cleanup is best-effort (may hang if storage API unavailable)
|
|
308
549
|
removeAllFiles(args.path).catch(() => {});
|
|
309
550
|
result = true;
|
|
310
551
|
break;
|
|
@@ -313,8 +554,8 @@ self.onmessage = async (e) => {
|
|
|
313
554
|
case 'exportSnapshot': {
|
|
314
555
|
const ctx = getCtx(args.path);
|
|
315
556
|
const lenPtr = Module._malloc(4);
|
|
316
|
-
const dataPtr = Module.ccall('lucivy_export_snapshot', 'number',
|
|
317
|
-
['number', 'number'], [ctx, lenPtr]);
|
|
557
|
+
const dataPtr = await Module.ccall('lucivy_export_snapshot', 'number',
|
|
558
|
+
['number', 'number'], [ctx, lenPtr], { async: true });
|
|
318
559
|
if (!dataPtr) {
|
|
319
560
|
Module._free(lenPtr);
|
|
320
561
|
throw new Error('export failed — index may have uncommitted changes');
|
|
@@ -330,24 +571,24 @@ self.onmessage = async (e) => {
|
|
|
330
571
|
const dataArr = data instanceof Uint8Array ? data : new Uint8Array(data);
|
|
331
572
|
const ptr = Module._malloc(dataArr.length);
|
|
332
573
|
Module.HEAPU8.set(dataArr, ptr);
|
|
333
|
-
const ctx = Module.ccall('lucivy_import_snapshot', 'number',
|
|
334
|
-
['number', 'number', 'string'], [ptr, dataArr.length, path]);
|
|
574
|
+
const ctx = await Module.ccall('lucivy_import_snapshot', 'number',
|
|
575
|
+
['number', 'number', 'string'], [ptr, dataArr.length, path], { async: true });
|
|
335
576
|
Module._free(ptr);
|
|
336
577
|
if (!ctx) throw new Error('import_snapshot failed — invalid snapshot data');
|
|
337
578
|
indexes.set(path, ctx);
|
|
338
|
-
result = { path, numDocs: Module.ccall('lucivy_num_docs', 'number', ['number'], [ctx]) };
|
|
579
|
+
result = { path, numDocs: await Module.ccall('lucivy_num_docs', 'number', ['number'], [ctx], { async: true }) };
|
|
339
580
|
break;
|
|
340
581
|
}
|
|
341
582
|
|
|
342
583
|
case 'numDocs': {
|
|
343
584
|
const ctx = getCtx(args.path);
|
|
344
|
-
result = Module.ccall('lucivy_num_docs', 'number', ['number'], [ctx]);
|
|
585
|
+
result = await Module.ccall('lucivy_num_docs', 'number', ['number'], [ctx], { async: true });
|
|
345
586
|
break;
|
|
346
587
|
}
|
|
347
588
|
|
|
348
589
|
case 'schema': {
|
|
349
590
|
const ctx = getCtx(args.path);
|
|
350
|
-
const json = callStr('lucivy_schema_json', ctx);
|
|
591
|
+
const json = await callStr('lucivy_schema_json', ctx);
|
|
351
592
|
result = json ? JSON.parse(json) : null;
|
|
352
593
|
break;
|
|
353
594
|
}
|
package/js/lucivy.d.ts
CHANGED
|
@@ -136,9 +136,30 @@ export interface LucivyModule extends EmscriptenModule {
|
|
|
136
136
|
/** Finish async commit (blocks until done). */
|
|
137
137
|
_lucivy_commit_finish(ctx: LucivyCtx): CStringPtr;
|
|
138
138
|
|
|
139
|
-
/**
|
|
139
|
+
/** Wait for a quiet index: commit, then every background merge running or about to start. */
|
|
140
140
|
_lucivy_drain_merges(ctx: LucivyCtx): CStringPtr;
|
|
141
141
|
|
|
142
|
+
/** Start a background compaction to segments of at most max_docs documents. */
|
|
143
|
+
_lucivy_compact_async(ctx: LucivyCtx, max_docs: number): number;
|
|
144
|
+
|
|
145
|
+
// ── Memory (3.0.0) ─────────────────────────────────────────────────
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* JSON: {"index_bytes", "in_memory", "num_docs", "warnings": [...], "shards": [...]}.
|
|
149
|
+
* A browser addresses at most 4 GB; above LUCIVY_RAM_INDEX_MAX (3 GB by default)
|
|
150
|
+
* the index is streamed from storage instead of held, and `warnings` says so.
|
|
151
|
+
*/
|
|
152
|
+
_lucivy_memory_status(ctx: LucivyCtx): CStringPtr;
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Wait for background merges to be quiet, then read the whole index into memory
|
|
156
|
+
* when it fits. JSON: {"bytes", "files", "ms", "skipped"}.
|
|
157
|
+
*/
|
|
158
|
+
_lucivy_preload(ctx: LucivyCtx): CStringPtr;
|
|
159
|
+
|
|
160
|
+
/** Honest warnings for a query, without running it. JSON array of strings. */
|
|
161
|
+
_lucivy_query_warnings(ctx: LucivyCtx, query_json: CStringPtr): CStringPtr;
|
|
162
|
+
|
|
142
163
|
// ── Search ─────────────────────────────────────────────────────────
|
|
143
164
|
|
|
144
165
|
/**
|
|
@@ -248,3 +269,111 @@ export interface LucivyModule extends EmscriptenModule {
|
|
|
248
269
|
export default function createLucivy(
|
|
249
270
|
moduleArg?: Partial<EmscriptenModule>,
|
|
250
271
|
): Promise<LucivyModule>;
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
// ── High-level API (js/lucivy.js, runs the module in a Web Worker) ──────
|
|
275
|
+
|
|
276
|
+
/** Startup options: each maps to a module argument read before the engine starts. */
|
|
277
|
+
export interface LucivyOptions {
|
|
278
|
+
/** In-memory filesystem: the index lives for the session only. */
|
|
279
|
+
noOpfs?: boolean;
|
|
280
|
+
/** Engine diagnostics (LUCIVY_VERBOSE, V3_PROFILE). */
|
|
281
|
+
verbose?: boolean;
|
|
282
|
+
/** Whole-file cache budget in MB; pins it when set (default: the index size). */
|
|
283
|
+
fileCacheMb?: number;
|
|
284
|
+
/** Largest index held in memory, MB; above it the index is streamed (default 3072). */
|
|
285
|
+
ramIndexMaxMb?: number;
|
|
286
|
+
/** luciole scheduler threads (default min(cores, 8)). */
|
|
287
|
+
schedulerThreads?: number;
|
|
288
|
+
/** Indexer threads (default 1; the writer heap follows). */
|
|
289
|
+
writerThreads?: number;
|
|
290
|
+
/** Largest segment a background merge may produce (default 800). */
|
|
291
|
+
maxMergedDocs?: number;
|
|
292
|
+
/** Segment builds allowed at once (default 2). */
|
|
293
|
+
maxBuilds?: number;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
export interface FieldDef {
|
|
297
|
+
name: string;
|
|
298
|
+
type: 'text' | 'u64' | 'i64' | 'f64' | 'bool' | 'date' | 'bytes' | string;
|
|
299
|
+
stored?: boolean;
|
|
300
|
+
fast?: boolean;
|
|
301
|
+
indexed?: boolean;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
export interface IndexConfig {
|
|
305
|
+
fields: FieldDef[];
|
|
306
|
+
shards?: number;
|
|
307
|
+
sfx_version?: number;
|
|
308
|
+
[key: string]: unknown;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
export interface SearchOptions {
|
|
312
|
+
limit?: number;
|
|
313
|
+
/** Include byte spans per field (default true). */
|
|
314
|
+
highlights?: boolean;
|
|
315
|
+
/** Include stored field values (default true). */
|
|
316
|
+
fields?: boolean;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
export interface SearchResult {
|
|
320
|
+
docId: number;
|
|
321
|
+
score: number;
|
|
322
|
+
highlights?: Record<string, [number, number][]>;
|
|
323
|
+
fields?: Record<string, unknown>;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
export interface MemoryStatus {
|
|
327
|
+
index_bytes: number;
|
|
328
|
+
in_memory: boolean;
|
|
329
|
+
num_docs: number;
|
|
330
|
+
/** Empty when the index is held in memory; a sentence for the user otherwise. */
|
|
331
|
+
warnings: string[];
|
|
332
|
+
shards: { shard: number; bytes: number; opened: number; listed: number }[];
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
export interface PreloadResult {
|
|
336
|
+
bytes: number;
|
|
337
|
+
files: number;
|
|
338
|
+
ms: number;
|
|
339
|
+
/** True when the index is streamed and nothing was loaded. */
|
|
340
|
+
skipped: boolean;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
export class Lucivy {
|
|
344
|
+
constructor(workerUrl: string | URL, options?: LucivyOptions);
|
|
345
|
+
/** Resolves once the worker and the WASM module are ready. */
|
|
346
|
+
readonly ready: Promise<void>;
|
|
347
|
+
create(path: string, fieldsOrConfig: FieldDef[] | IndexConfig): Promise<LucivyIndex>;
|
|
348
|
+
open(path: string): Promise<LucivyIndex>;
|
|
349
|
+
/** Open an index persisted in OPFS in place (no copy). */
|
|
350
|
+
openDirect(path: string): Promise<LucivyIndex>;
|
|
351
|
+
importSnapshot(data: Uint8Array, path: string): Promise<LucivyIndex>;
|
|
352
|
+
/** Terminate the worker and free every byte of WASM memory. */
|
|
353
|
+
terminate(): void;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
export class LucivyIndex {
|
|
357
|
+
readonly path: string;
|
|
358
|
+
add(docId: number, fields: Record<string, unknown>): Promise<void>;
|
|
359
|
+
addMany(docs: Array<{ docId: number } & Record<string, unknown>>): Promise<void>;
|
|
360
|
+
remove(docId: number): Promise<void>;
|
|
361
|
+
update(docId: number, fields: Record<string, unknown>): Promise<void>;
|
|
362
|
+
commit(options?: { sync?: boolean }): Promise<void>;
|
|
363
|
+
/** Not supported on a sharded index: rejects with the reason. */
|
|
364
|
+
rollback(): Promise<never>;
|
|
365
|
+
/** Merge down to segments of at most maxDocs documents. Not for the browser's own indexes: small segments are what fills the threads. */
|
|
366
|
+
compact(maxDocs?: number): Promise<number>;
|
|
367
|
+
/** Commit, then wait until no background merge is running or about to start. */
|
|
368
|
+
drainMerges(): Promise<void>;
|
|
369
|
+
/** Read the whole index into memory when it fits (after merges are quiet). */
|
|
370
|
+
preload(): Promise<PreloadResult>;
|
|
371
|
+
memoryStatus(): Promise<MemoryStatus>;
|
|
372
|
+
search(query: string | object, options?: SearchOptions): Promise<SearchResult[]>;
|
|
373
|
+
searchFiltered(query: string | object, allowedIds: number[], options?: SearchOptions): Promise<SearchResult[]>;
|
|
374
|
+
numDocs(): Promise<number>;
|
|
375
|
+
schema(): Promise<IndexConfig>;
|
|
376
|
+
exportSnapshot(): Promise<Uint8Array>;
|
|
377
|
+
close(): Promise<void>;
|
|
378
|
+
destroy(): Promise<void>;
|
|
379
|
+
}
|
package/js/lucivy.js
CHANGED
|
@@ -16,12 +16,24 @@
|
|
|
16
16
|
// const results = await index.search('hello');
|
|
17
17
|
|
|
18
18
|
export class Lucivy {
|
|
19
|
-
constructor(workerUrl) {
|
|
19
|
+
constructor(workerUrl, options = {}) {
|
|
20
20
|
this._worker = new Worker(workerUrl, { type: 'module' });
|
|
21
|
+
this._options = options; // { noOpfs?: boolean }
|
|
21
22
|
this._nextId = 1;
|
|
22
23
|
this._pending = new Map();
|
|
23
24
|
|
|
25
|
+
this._logRingInterval = null;
|
|
26
|
+
|
|
24
27
|
this._worker.onmessage = (e) => {
|
|
28
|
+
if (e.data.type === 'log') {
|
|
29
|
+
return; // worker logs visible in worker console
|
|
30
|
+
}
|
|
31
|
+
// Set up SharedArrayBuffer log ring polling (reads Rust logs
|
|
32
|
+
// directly from WASM memory — works even during deadlocks).
|
|
33
|
+
if (e.data.type === 'logRing') {
|
|
34
|
+
this._startLogRingPoller(e.data.buffer, e.data.ringPtr, e.data.ringSize);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
25
37
|
const { id, result, error } = e.data;
|
|
26
38
|
const pending = this._pending.get(id);
|
|
27
39
|
if (pending) {
|
|
@@ -31,7 +43,49 @@ export class Lucivy {
|
|
|
31
43
|
}
|
|
32
44
|
};
|
|
33
45
|
|
|
34
|
-
this.ready = this._call('init'
|
|
46
|
+
this.ready = this._call('init', {
|
|
47
|
+
noOpfs: !!options.noOpfs,
|
|
48
|
+
verbose: !!options.verbose,
|
|
49
|
+
fileCacheMb: options.fileCacheMb || 0,
|
|
50
|
+
ramIndexMaxMb: options.ramIndexMaxMb || 0,
|
|
51
|
+
schedulerThreads: options.schedulerThreads || 0,
|
|
52
|
+
writerThreads: options.writerThreads || 0,
|
|
53
|
+
maxMergedDocs: options.maxMergedDocs || 0,
|
|
54
|
+
maxBuilds: options.maxBuilds || 0,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
_startLogRingPoller(sab, ringPtr, ringSize) {
|
|
59
|
+
// Atomics views for the two u32 header fields
|
|
60
|
+
const writePosView = new Int32Array(sab, ringPtr, 1);
|
|
61
|
+
const wrapCountView = new Int32Array(sab, ringPtr + 4, 1);
|
|
62
|
+
const bytes = new Uint8Array(sab, ringPtr, ringSize);
|
|
63
|
+
let readPos = 8;
|
|
64
|
+
let lastWrap = 0;
|
|
65
|
+
|
|
66
|
+
this._logRingInterval = setInterval(() => {
|
|
67
|
+
try {
|
|
68
|
+
const wrap = Atomics.load(wrapCountView, 0);
|
|
69
|
+
if (wrap !== lastWrap) {
|
|
70
|
+
readPos = 8;
|
|
71
|
+
lastWrap = wrap;
|
|
72
|
+
}
|
|
73
|
+
const writePos = Atomics.load(writePosView, 0);
|
|
74
|
+
while (readPos + 2 <= writePos && readPos + 2 < ringSize) {
|
|
75
|
+
const len = bytes[readPos] | (bytes[readPos + 1] << 8);
|
|
76
|
+
if (len === 0 || readPos + 2 + len > ringSize) break;
|
|
77
|
+
const msgBytes = bytes.slice(readPos + 2, readPos + 2 + len);
|
|
78
|
+
const msg = new TextDecoder().decode(msgBytes);
|
|
79
|
+
// The ring is the only channel that survives a dying
|
|
80
|
+
// pthread: allocation failures and their call stacks are
|
|
81
|
+
// written there and nowhere else. Discarding it here left
|
|
82
|
+
// "memory allocation of N bytes failed" with no site.
|
|
83
|
+
console.log('[ring]', msg);
|
|
84
|
+
if (this._onRing) this._onRing(msg);
|
|
85
|
+
readPos += 2 + len;
|
|
86
|
+
}
|
|
87
|
+
} catch (e) { /* ignore read errors */ }
|
|
88
|
+
}, 50);
|
|
35
89
|
}
|
|
36
90
|
|
|
37
91
|
_call(type, args = {}) {
|
|
@@ -42,8 +96,21 @@ export class Lucivy {
|
|
|
42
96
|
});
|
|
43
97
|
}
|
|
44
98
|
|
|
45
|
-
|
|
46
|
-
|
|
99
|
+
/**
|
|
100
|
+
* Create a new index.
|
|
101
|
+
* @param {string} path
|
|
102
|
+
* @param {Array|Object} fieldsOrConfig — either a fields array or a full SchemaConfig
|
|
103
|
+
* Full config: { fields: [...], sfx: false, tokenizer: "english", ... }
|
|
104
|
+
* Legacy: [{ name: "body", type: "text" }]
|
|
105
|
+
*/
|
|
106
|
+
async create(path, fieldsOrConfig) {
|
|
107
|
+
const isConfig = !Array.isArray(fieldsOrConfig) && typeof fieldsOrConfig === 'object'
|
|
108
|
+
&& fieldsOrConfig.fields;
|
|
109
|
+
if (isConfig) {
|
|
110
|
+
await this._call('create', { path, config: fieldsOrConfig });
|
|
111
|
+
} else {
|
|
112
|
+
await this._call('create', { path, fields: fieldsOrConfig });
|
|
113
|
+
}
|
|
47
114
|
return new LucivyIndex(this, path);
|
|
48
115
|
}
|
|
49
116
|
|
|
@@ -52,6 +119,12 @@ export class Lucivy {
|
|
|
52
119
|
return new LucivyIndex(this, path);
|
|
53
120
|
}
|
|
54
121
|
|
|
122
|
+
/** Open an index that already lives in OPFS, in place. */
|
|
123
|
+
async openDirect(path) {
|
|
124
|
+
await this._call('openDirect', { path });
|
|
125
|
+
return new LucivyIndex(this, path);
|
|
126
|
+
}
|
|
127
|
+
|
|
55
128
|
async importSnapshot(data, path) {
|
|
56
129
|
const res = await this._call('importSnapshot', { data, path });
|
|
57
130
|
return new LucivyIndex(this, path);
|
|
@@ -84,14 +157,45 @@ export class LucivyIndex {
|
|
|
84
157
|
return this._lucivy._call('update', { path: this.path, docId, fields });
|
|
85
158
|
}
|
|
86
159
|
|
|
87
|
-
commit() {
|
|
88
|
-
return this._lucivy._call('commit', { path: this.path });
|
|
160
|
+
commit({ sync = true } = {}) {
|
|
161
|
+
return this._lucivy._call('commit', { path: this.path, sync });
|
|
89
162
|
}
|
|
90
163
|
|
|
91
164
|
rollback() {
|
|
92
165
|
return this._lucivy._call('rollback', { path: this.path });
|
|
93
166
|
}
|
|
94
167
|
|
|
168
|
+
/** Merge every shard down to segments of at most `maxDocs` documents. */
|
|
169
|
+
compact(maxDocs = 10000) {
|
|
170
|
+
return this._lucivy._call('compact', { path: this.path, maxDocs });
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
drainMerges() {
|
|
174
|
+
return this._lucivy._call('drainMerges', { path: this.path });
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Whether the index is held in memory or streamed from storage:
|
|
179
|
+
* `{ index_bytes, in_memory, num_docs, warnings }`. WebAssembly addresses
|
|
180
|
+
* at most 4 GB; above the residency limit searches answer the same hits
|
|
181
|
+
* but read the index batch by batch and take seconds. `warnings` is empty
|
|
182
|
+
* when the index is held in memory, and carries a sentence to show the
|
|
183
|
+
* user when it is not.
|
|
184
|
+
*/
|
|
185
|
+
/**
|
|
186
|
+
* Read the whole index into memory when it fits, so the first query does
|
|
187
|
+
* not pay for it: `{ bytes, files, ms, skipped }`. A single substring
|
|
188
|
+
* query opens nearly every file of the index anyway, so lazy reading only
|
|
189
|
+
* moves that cost into the first search.
|
|
190
|
+
*/
|
|
191
|
+
preload() {
|
|
192
|
+
return this._lucivy._call('preload', { path: this.path });
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
memoryStatus() {
|
|
196
|
+
return this._lucivy._call('memoryStatus', { path: this.path });
|
|
197
|
+
}
|
|
198
|
+
|
|
95
199
|
search(query, options = {}) {
|
|
96
200
|
return this._lucivy._call('search', {
|
|
97
201
|
path: this.path,
|
package/package.json
CHANGED
package/pkg/lucivy.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
async function createLucivy(moduleArg={}){var moduleRtn;var Module=moduleArg;var ENVIRONMENT_IS_WEB=!!globalThis.window;var ENVIRONMENT_IS_WORKER=!!globalThis.WorkerGlobalScope;var ENVIRONMENT_IS_NODE=globalThis.process?.versions?.node&&globalThis.process?.type!="renderer";var ENVIRONMENT_IS_PTHREAD=ENVIRONMENT_IS_WORKER&&self.name?.startsWith("em-pthread");if(ENVIRONMENT_IS_NODE){const{createRequire}=await import("node:module");var require=createRequire(import.meta.url);var worker_threads=require("node:worker_threads");global.Worker=worker_threads.Worker;ENVIRONMENT_IS_WORKER=!worker_threads.isMainThread;ENVIRONMENT_IS_PTHREAD=ENVIRONMENT_IS_WORKER&&worker_threads["workerData"]=="em-pthread"}var arguments_=[];var thisProgram="./this.program";var quit_=(status,toThrow)=>{throw toThrow};var _scriptName=import.meta.url;var scriptDirectory="";function locateFile(path){if(Module["locateFile"]){return Module["locateFile"](path,scriptDirectory)}return scriptDirectory+path}var readAsync,readBinary;if(ENVIRONMENT_IS_NODE){var fs=require("node:fs");if(_scriptName.startsWith("file:")){scriptDirectory=require("node:path").dirname(require("node:url").fileURLToPath(_scriptName))+"/"}readBinary=filename=>{filename=isFileURI(filename)?new URL(filename):filename;var ret=fs.readFileSync(filename);return ret};readAsync=async(filename,binary=true)=>{filename=isFileURI(filename)?new URL(filename):filename;var ret=fs.readFileSync(filename,binary?undefined:"utf8");return ret};if(process.argv.length>1){thisProgram=process.argv[1].replace(/\\/g,"/")}arguments_=process.argv.slice(2);quit_=(status,toThrow)=>{process.exitCode=status;throw toThrow}}else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){try{scriptDirectory=new URL(".",_scriptName).href}catch{}if(!ENVIRONMENT_IS_NODE){if(ENVIRONMENT_IS_WORKER){readBinary=url=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.responseType="arraybuffer";xhr.send(null);return new Uint8Array(xhr.response)}}readAsync=async url=>{if(isFileURI(url)){return new Promise((resolve,reject)=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,true);xhr.responseType="arraybuffer";xhr.onload=()=>{if(xhr.status==200||xhr.status==0&&xhr.response){resolve(xhr.response);return}reject(xhr.status)};xhr.onerror=reject;xhr.send(null)})}var response=await fetch(url,{credentials:"same-origin"});if(response.ok){return response.arrayBuffer()}throw new Error(response.status+" : "+response.url)}}}else{}var defaultPrint=console.log.bind(console);var defaultPrintErr=console.error.bind(console);if(ENVIRONMENT_IS_NODE){var utils=require("node:util");var stringify=a=>typeof a=="object"?utils.inspect(a):a;defaultPrint=(...args)=>fs.writeSync(1,args.map(stringify).join(" ")+"\n");defaultPrintErr=(...args)=>fs.writeSync(2,args.map(stringify).join(" ")+"\n")}var out=defaultPrint;var err=defaultPrintErr;var wasmBinary;var wasmModule;var ABORT=false;var EXITSTATUS;var isFileURI=filename=>filename.startsWith("file://");function growMemViews(){if(wasmMemory.buffer!=HEAP8.buffer){updateMemoryViews()}}var readyPromiseResolve,readyPromiseReject;if(ENVIRONMENT_IS_NODE&&ENVIRONMENT_IS_PTHREAD){globalThis.self=globalThis;var parentPort=worker_threads["parentPort"];if(!globalThis.postMessage){parentPort.on("message",msg=>globalThis.onmessage?.({data:msg}));globalThis.postMessage=msg=>parentPort["postMessage"](msg)}process.on("uncaughtException",err=>{postMessage({cmd:"uncaughtException",error:err});process.exit(1)})}var startWorker;if(ENVIRONMENT_IS_PTHREAD){var initializedJS=false;self.onunhandledrejection=e=>{throw e.reason||e};function handleMessage(e){try{var msgData=e["data"];var cmd=msgData.cmd;if(cmd==="load"){let messageQueue=[];self.onmessage=e=>messageQueue.push(e);startWorker=()=>{postMessage({cmd:"loaded"});for(let msg of messageQueue){handleMessage(msg)}self.onmessage=handleMessage};for(const handler of msgData.handlers){if(!Module[handler]||Module[handler].proxy){Module[handler]=(...args)=>{postMessage({cmd:"callHandler",handler,args})};if(handler=="print")out=Module[handler];if(handler=="printErr")err=Module[handler]}}wasmMemory=msgData.wasmMemory;updateMemoryViews();wasmModule=msgData.wasmModule;createWasm();run()}else if(cmd==="run"){establishStackSpace(msgData.pthread_ptr);__emscripten_thread_init(msgData.pthread_ptr,0,0,1,0,0);PThread.threadInitTLS();__emscripten_thread_mailbox_await(msgData.pthread_ptr);if(!initializedJS){initializedJS=true}try{invokeEntryPoint(msgData.start_routine,msgData.arg)}catch(ex){if(ex!="unwind"){throw ex}}}else if(msgData.target==="setimmediate"){}else if(cmd==="checkMailbox"){if(initializedJS){checkMailbox()}}else if(cmd){err(`worker: received unknown command ${cmd}`);err(msgData)}}catch(ex){__emscripten_thread_crashed();throw ex}}self.onmessage=handleMessage}var HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64;var HEAP64,HEAPU64;var runtimeInitialized=false;function updateMemoryViews(){var b=wasmMemory.buffer;HEAP8=new Int8Array(b);HEAP16=new Int16Array(b);Module["HEAPU8"]=HEAPU8=new Uint8Array(b);HEAPU16=new Uint16Array(b);HEAP32=new Int32Array(b);HEAPU32=new Uint32Array(b);HEAPF32=new Float32Array(b);HEAPF64=new Float64Array(b);HEAP64=new BigInt64Array(b);HEAPU64=new BigUint64Array(b)}function initMemory(){if(ENVIRONMENT_IS_PTHREAD){return}if(Module["wasmMemory"]){wasmMemory=Module["wasmMemory"]}else{var INITIAL_MEMORY=Module["INITIAL_MEMORY"]||16777216;wasmMemory=new WebAssembly.Memory({initial:INITIAL_MEMORY/65536,maximum:65536,shared:true})}updateMemoryViews()}function preRun(){if(Module["preRun"]){if(typeof Module["preRun"]=="function")Module["preRun"]=[Module["preRun"]];while(Module["preRun"].length){addOnPreRun(Module["preRun"].shift())}}callRuntimeCallbacks(onPreRuns)}function initRuntime(){runtimeInitialized=true;if(ENVIRONMENT_IS_PTHREAD)return startWorker();wasmExports["__wasm_call_ctors"]()}function preMain(){}function postRun(){if(ENVIRONMENT_IS_PTHREAD){return}if(Module["postRun"]){if(typeof Module["postRun"]=="function")Module["postRun"]=[Module["postRun"]];while(Module["postRun"].length){addOnPostRun(Module["postRun"].shift())}}callRuntimeCallbacks(onPostRuns)}function abort(what){Module["onAbort"]?.(what);what="Aborted("+what+")";err(what);ABORT=true;what+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(what);readyPromiseReject?.(e);throw e}var wasmBinaryFile;function findWasmBinary(){if(Module["locateFile"]){return locateFile("lucivy.wasm")}return new URL("lucivy.wasm",import.meta.url).href}function getBinarySync(file){if(file==wasmBinaryFile&&wasmBinary){return new Uint8Array(wasmBinary)}if(readBinary){return readBinary(file)}throw"both async and sync fetching of the wasm failed"}async function getWasmBinary(binaryFile){if(!wasmBinary){try{var response=await readAsync(binaryFile);return new Uint8Array(response)}catch{}}return getBinarySync(binaryFile)}async function instantiateArrayBuffer(binaryFile,imports){try{var binary=await getWasmBinary(binaryFile);var instance=await WebAssembly.instantiate(binary,imports);return instance}catch(reason){err(`failed to asynchronously prepare wasm: ${reason}`);abort(reason)}}async function instantiateAsync(binary,binaryFile,imports){if(!binary&&!isFileURI(binaryFile)&&!ENVIRONMENT_IS_NODE){try{var response=fetch(binaryFile,{credentials:"same-origin"});var instantiationResult=await WebAssembly.instantiateStreaming(response,imports);return instantiationResult}catch(reason){err(`wasm streaming compile failed: ${reason}`);err("falling back to ArrayBuffer instantiation")}}return instantiateArrayBuffer(binaryFile,imports)}function getWasmImports(){assignWasmImports();var imports={env:wasmImports,wasi_snapshot_preview1:wasmImports};return imports}async function createWasm(){function receiveInstance(instance,module){wasmExports=instance.exports;wasmExports=Asyncify.instrumentWasmExports(wasmExports);wasmExports=applySignatureConversions(wasmExports);registerTLSInit(wasmExports["_emscripten_tls_init"]);assignWasmExports(wasmExports);wasmModule=module;return wasmExports}function receiveInstantiationResult(result){return receiveInstance(result["instance"],result["module"])}var info=getWasmImports();if(Module["instantiateWasm"]){return new Promise((resolve,reject)=>{Module["instantiateWasm"](info,(inst,mod)=>{resolve(receiveInstance(inst,mod))})})}if(ENVIRONMENT_IS_PTHREAD){var instance=new WebAssembly.Instance(wasmModule,getWasmImports());return receiveInstance(instance,wasmModule)}wasmBinaryFile??=findWasmBinary();var result=await instantiateAsync(wasmBinary,wasmBinaryFile,info);var exports=receiveInstantiationResult(result);return exports}class ExitStatus{name="ExitStatus";constructor(status){this.message=`Program terminated with exit(${status})`;this.status=status}}var terminateWorker=worker=>{worker.terminate();worker.onmessage=e=>{}};var cleanupThread=pthread_ptr=>{var worker=PThread.pthreads[pthread_ptr];PThread.returnWorkerToPool(worker)};var callRuntimeCallbacks=callbacks=>{while(callbacks.length>0){callbacks.shift()(Module)}};var onPreRuns=[];var addOnPreRun=cb=>onPreRuns.push(cb);var runDependencies=0;var dependenciesFulfilled=null;var removeRunDependency=id=>{runDependencies--;Module["monitorRunDependencies"]?.(runDependencies);if(runDependencies==0){if(dependenciesFulfilled){var callback=dependenciesFulfilled;dependenciesFulfilled=null;callback()}}};var addRunDependency=id=>{runDependencies++;Module["monitorRunDependencies"]?.(runDependencies)};var spawnThread=threadParams=>{var worker=PThread.getNewWorker();if(!worker){return 6}PThread.runningWorkers.push(worker);PThread.pthreads[threadParams.pthread_ptr]=worker;worker.pthread_ptr=threadParams.pthread_ptr;var msg={cmd:"run",start_routine:threadParams.startRoutine,arg:threadParams.arg,pthread_ptr:threadParams.pthread_ptr};if(ENVIRONMENT_IS_NODE){worker.unref()}worker.postMessage(msg,threadParams.transferList);return 0};var runtimeKeepaliveCounter=0;var keepRuntimeAlive=()=>noExitRuntime||runtimeKeepaliveCounter>0;var stackSave=()=>_emscripten_stack_get_current();var stackRestore=val=>__emscripten_stack_restore(val);var stackAlloc=sz=>__emscripten_stack_alloc(sz);var proxyToMainThread=(funcIndex,emAsmAddr,proxyMode,...callArgs)=>{var bufSize=8*callArgs.length*2;var sp=stackSave();var args=stackAlloc(bufSize);var b=args>>>3;for(var arg of callArgs){if(typeof arg=="bigint"){(growMemViews(),HEAP64)[b++>>>0]=1n;(growMemViews(),HEAP64)[b++>>>0]=arg}else{(growMemViews(),HEAP64)[b++>>>0]=0n;(growMemViews(),HEAPF64)[b++>>>0]=arg}}var rtn=__emscripten_run_js_on_main_thread(funcIndex,emAsmAddr,bufSize,args,proxyMode);stackRestore(sp);return rtn};function _proc_exit(code){if(ENVIRONMENT_IS_PTHREAD)return proxyToMainThread(0,0,1,code);EXITSTATUS=code;if(!keepRuntimeAlive()){PThread.terminateAllThreads();Module["onExit"]?.(code);ABORT=true}quit_(code,new ExitStatus(code))}var runtimeKeepalivePop=()=>{runtimeKeepaliveCounter-=1};function exitOnMainThread(returnCode){if(ENVIRONMENT_IS_PTHREAD)return proxyToMainThread(1,0,0,returnCode);runtimeKeepalivePop();_exit(returnCode)}var exitJS=(status,implicit)=>{EXITSTATUS=status;if(ENVIRONMENT_IS_PTHREAD){exitOnMainThread(status);throw"unwind"}_proc_exit(status)};var _exit=exitJS;var PThread={unusedWorkers:[],runningWorkers:[],tlsInitFunctions:[],pthreads:{},init(){if(!ENVIRONMENT_IS_PTHREAD){PThread.initMainThread()}},initMainThread(){var pthreadPoolSize=8;while(pthreadPoolSize--){PThread.allocateUnusedWorker()}addOnPreRun(async()=>{var pthreadPoolReady=PThread.loadWasmModuleToAllWorkers();addRunDependency("loading-workers");await pthreadPoolReady;removeRunDependency("loading-workers")})},terminateAllThreads:()=>{for(var worker of PThread.runningWorkers){terminateWorker(worker)}for(var worker of PThread.unusedWorkers){terminateWorker(worker)}PThread.unusedWorkers=[];PThread.runningWorkers=[];PThread.pthreads={}},returnWorkerToPool:worker=>{var pthread_ptr=worker.pthread_ptr;delete PThread.pthreads[pthread_ptr];PThread.unusedWorkers.push(worker);PThread.runningWorkers.splice(PThread.runningWorkers.indexOf(worker),1);worker.pthread_ptr=0;if(ENVIRONMENT_IS_NODE){worker.unref()}__emscripten_thread_free_data(pthread_ptr)},threadInitTLS(){PThread.tlsInitFunctions.forEach(f=>f())},loadWasmModuleToWorker:worker=>new Promise(onFinishedLoading=>{worker.onmessage=e=>{var d=e["data"];var cmd=d.cmd;if(d.targetThread&&d.targetThread!=_pthread_self()){var targetWorker=PThread.pthreads[d.targetThread];if(targetWorker){targetWorker.postMessage(d,d.transferList)}else{err(`Internal error! Worker sent a message "${cmd}" to target pthread ${d.targetThread}, but that thread no longer exists!`)}return}if(cmd==="checkMailbox"){checkMailbox()}else if(cmd==="spawnThread"){spawnThread(d)}else if(cmd==="cleanupThread"){callUserCallback(()=>cleanupThread(d.thread))}else if(cmd==="loaded"){worker.loaded=true;if(ENVIRONMENT_IS_NODE&&!worker.pthread_ptr){worker.unref()}onFinishedLoading(worker)}else if(d.target==="setimmediate"){worker.postMessage(d)}else if(cmd==="uncaughtException"){worker.onerror(d.error)}else if(cmd==="callHandler"){Module[d.handler](...d.args)}else if(cmd){err(`worker sent an unknown command ${cmd}`)}};worker.onerror=e=>{var message="worker sent an error!";err(`${message} ${e.filename}:${e.lineno}: ${e.message}`);throw e};if(ENVIRONMENT_IS_NODE){worker.on("message",data=>worker.onmessage({data}));worker.on("error",e=>worker.onerror(e))}var handlers=[];var knownHandlers=["onExit","onAbort","print","printErr"];for(var handler of knownHandlers){if(Module.propertyIsEnumerable(handler)){handlers.push(handler)}}worker.postMessage({cmd:"load",handlers,wasmMemory,wasmModule})}),async loadWasmModuleToAllWorkers(){if(ENVIRONMENT_IS_PTHREAD){return}let pthreadPoolReady=Promise.all(PThread.unusedWorkers.map(PThread.loadWasmModuleToWorker));return pthreadPoolReady},allocateUnusedWorker(){var worker;if(Module["mainScriptUrlOrBlob"]){var pthreadMainJs=Module["mainScriptUrlOrBlob"];if(typeof pthreadMainJs!="string"){pthreadMainJs=URL.createObjectURL(pthreadMainJs)}worker=new Worker(pthreadMainJs,{type:"module",workerData:"em-pthread",trackUnmanagedFds:false,name:"em-pthread"})}else worker=new Worker(new URL("lucivy.js",import.meta.url),{type:"module",workerData:"em-pthread",trackUnmanagedFds:false,name:"em-pthread"});PThread.unusedWorkers.push(worker)},getNewWorker(){if(PThread.unusedWorkers.length==0){PThread.allocateUnusedWorker();PThread.loadWasmModuleToWorker(PThread.unusedWorkers[0])}return PThread.unusedWorkers.pop()}};var onPostRuns=[];var addOnPostRun=cb=>onPostRuns.push(cb);var dynCalls={};var dynCallLegacy=(sig,ptr,args)=>{sig=sig.replace(/p/g,"i");var f=dynCalls[sig];return f(ptr,...args)};function establishStackSpace(pthread_ptr){var stackHigh=(growMemViews(),HEAPU32)[pthread_ptr+52>>>2>>>0];var stackSize=(growMemViews(),HEAPU32)[pthread_ptr+56>>>2>>>0];var stackLow=stackHigh-stackSize;_emscripten_stack_set_limits(stackHigh,stackLow);stackRestore(stackHigh)}function getValue(ptr,type="i8"){if(type.endsWith("*"))type="*";switch(type){case"i1":return(growMemViews(),HEAP8)[ptr>>>0];case"i8":return(growMemViews(),HEAP8)[ptr>>>0];case"i16":return(growMemViews(),HEAP16)[ptr>>>1>>>0];case"i32":return(growMemViews(),HEAP32)[ptr>>>2>>>0];case"i64":return(growMemViews(),HEAP64)[ptr>>>3>>>0];case"float":return(growMemViews(),HEAPF32)[ptr>>>2>>>0];case"double":return(growMemViews(),HEAPF64)[ptr>>>3>>>0];case"*":return(growMemViews(),HEAPU32)[ptr>>>2>>>0];default:abort(`invalid type for getValue: ${type}`)}}var invokeEntryPoint=(ptr,arg)=>{runtimeKeepaliveCounter=0;noExitRuntime=0;var result=(a1=>dynCall_ii(ptr,a1))(arg);function finish(result){if(keepRuntimeAlive()){EXITSTATUS=result;return}__emscripten_thread_exit(result)}finish(result)};var noExitRuntime=true;var registerTLSInit=tlsInitFunc=>PThread.tlsInitFunctions.push(tlsInitFunc);var runtimeKeepalivePush=()=>{runtimeKeepaliveCounter+=1};var wasmMemory;var INT53_MAX=9007199254740992;var INT53_MIN=-9007199254740992;var bigintToI53Checked=num=>num<INT53_MIN||num>INT53_MAX?NaN:Number(num);var ___call_sighandler=function(fp,sig){fp>>>=0;return(a1=>dynCall_vi(fp,a1))(sig)};var exceptionCaught=[];var uncaughtExceptionCount=0;function ___cxa_begin_catch(ptr){ptr>>>=0;var info=new ExceptionInfo(ptr);if(!info.get_caught()){info.set_caught(true);uncaughtExceptionCount--}info.set_rethrown(false);exceptionCaught.push(info);return ___cxa_get_exception_ptr(ptr)}var exceptionLast=0;class ExceptionInfo{constructor(excPtr){this.excPtr=excPtr;this.ptr=excPtr-24}set_type(type){(growMemViews(),HEAPU32)[this.ptr+4>>>2>>>0]=type}get_type(){return(growMemViews(),HEAPU32)[this.ptr+4>>>2>>>0]}set_destructor(destructor){(growMemViews(),HEAPU32)[this.ptr+8>>>2>>>0]=destructor}get_destructor(){return(growMemViews(),HEAPU32)[this.ptr+8>>>2>>>0]}set_caught(caught){caught=caught?1:0;(growMemViews(),HEAP8)[this.ptr+12>>>0]=caught}get_caught(){return(growMemViews(),HEAP8)[this.ptr+12>>>0]!=0}set_rethrown(rethrown){rethrown=rethrown?1:0;(growMemViews(),HEAP8)[this.ptr+13>>>0]=rethrown}get_rethrown(){return(growMemViews(),HEAP8)[this.ptr+13>>>0]!=0}init(type,destructor){this.set_adjusted_ptr(0);this.set_type(type);this.set_destructor(destructor)}set_adjusted_ptr(adjustedPtr){(growMemViews(),HEAPU32)[this.ptr+16>>>2>>>0]=adjustedPtr}get_adjusted_ptr(){return(growMemViews(),HEAPU32)[this.ptr+16>>>2>>>0]}}var setTempRet0=val=>__emscripten_tempret_set(val);var findMatchingCatch=args=>{var thrown=exceptionLast;if(!thrown){setTempRet0(0);return 0}var info=new ExceptionInfo(thrown);info.set_adjusted_ptr(thrown);var thrownType=info.get_type();if(!thrownType){setTempRet0(0);return thrown}for(var caughtType of args){if(caughtType===0||caughtType===thrownType){break}var adjusted_ptr_addr=info.ptr+16;if(___cxa_can_catch(caughtType,thrownType,adjusted_ptr_addr)){setTempRet0(caughtType);return thrown}}setTempRet0(thrownType);return thrown};function ___cxa_find_matching_catch_2(){return findMatchingCatch([])}function ___cxa_find_matching_catch_3(arg0){arg0>>>=0;return findMatchingCatch([arg0])}function ___cxa_throw(ptr,type,destructor){ptr>>>=0;type>>>=0;destructor>>>=0;var info=new ExceptionInfo(ptr);info.init(type,destructor);___cxa_increment_exception_refcount(ptr);exceptionLast=ptr;uncaughtExceptionCount++;throw exceptionLast}function pthreadCreateProxied(pthread_ptr,attr,startRoutine,arg){if(ENVIRONMENT_IS_PTHREAD)return proxyToMainThread(2,0,1,pthread_ptr,attr,startRoutine,arg);return ___pthread_create_js(pthread_ptr,attr,startRoutine,arg)}var _emscripten_has_threading_support=()=>!!globalThis.SharedArrayBuffer;function ___pthread_create_js(pthread_ptr,attr,startRoutine,arg){pthread_ptr>>>=0;attr>>>=0;startRoutine>>>=0;arg>>>=0;if(!_emscripten_has_threading_support()){return 6}var transferList=[];var error=0;if(ENVIRONMENT_IS_PTHREAD&&(transferList.length===0||error)){return pthreadCreateProxied(pthread_ptr,attr,startRoutine,arg)}if(error)return error;var threadParams={startRoutine,pthread_ptr,arg,transferList};if(ENVIRONMENT_IS_PTHREAD){threadParams.cmd="spawnThread";postMessage(threadParams,transferList);return 0}return spawnThread(threadParams)}function ___resumeException(ptr){ptr>>>=0;if(!exceptionLast){exceptionLast=ptr}throw exceptionLast}var __abort_js=()=>abort("");function __emscripten_init_main_thread_js(tb){tb>>>=0;__emscripten_thread_init(tb,!ENVIRONMENT_IS_WORKER,1,!ENVIRONMENT_IS_WEB,2097152,false);PThread.threadInitTLS()}var handleException=e=>{if(e instanceof ExitStatus||e=="unwind"){return EXITSTATUS}quit_(1,e)};var maybeExit=()=>{if(!keepRuntimeAlive()){try{if(ENVIRONMENT_IS_PTHREAD){if(_pthread_self())__emscripten_thread_exit(EXITSTATUS);return}_exit(EXITSTATUS)}catch(e){handleException(e)}}};var callUserCallback=func=>{if(ABORT){return}try{return func()}catch(e){handleException(e)}finally{maybeExit()}};var waitAsyncPolyfilled=!Atomics.waitAsync||globalThis.Deno||globalThis.navigator?.userAgent&&Number((navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./)||[])[2])<91;function __emscripten_thread_mailbox_await(pthread_ptr){pthread_ptr>>>=0;if(!waitAsyncPolyfilled){var wait=Atomics.waitAsync((growMemViews(),HEAP32),pthread_ptr>>>2,pthread_ptr);wait.value.then(checkMailbox);var waitingAsync=pthread_ptr+128;Atomics.store((growMemViews(),HEAP32),waitingAsync>>>2,1)}}var checkMailbox=()=>callUserCallback(()=>{var pthread_ptr=_pthread_self();if(pthread_ptr){__emscripten_thread_mailbox_await(pthread_ptr);__emscripten_check_mailbox()}});function __emscripten_notify_mailbox_postmessage(targetThread,currThreadId){targetThread>>>=0;currThreadId>>>=0;if(targetThread==currThreadId){setTimeout(checkMailbox)}else if(ENVIRONMENT_IS_PTHREAD){postMessage({targetThread,cmd:"checkMailbox"})}else{var worker=PThread.pthreads[targetThread];if(!worker){return}worker.postMessage({cmd:"checkMailbox"})}}var proxiedJSCallArgs=[];function __emscripten_receive_on_main_thread_js(funcIndex,emAsmAddr,callingThread,bufSize,args,ctx,ctxArgs){emAsmAddr>>>=0;callingThread>>>=0;args>>>=0;ctx>>>=0;ctxArgs>>>=0;proxiedJSCallArgs.length=0;var b=args>>>3;var end=args+bufSize>>>3;while(b<end){var arg;if((growMemViews(),HEAP64)[b++>>>0]){arg=(growMemViews(),HEAP64)[b++>>>0]}else{arg=(growMemViews(),HEAPF64)[b++>>>0]}proxiedJSCallArgs.push(arg)}var func=proxiedFunctionTable[funcIndex];PThread.currentProxiedOperationCallerThread=callingThread;var rtn=func(...proxiedJSCallArgs);PThread.currentProxiedOperationCallerThread=0;if(ctx){rtn.then(rtn=>__emscripten_run_js_on_main_thread_done(ctx,ctxArgs,rtn));return}return rtn}var __emscripten_runtime_keepalive_clear=()=>{noExitRuntime=false;runtimeKeepaliveCounter=0};function __emscripten_thread_cleanup(thread){thread>>>=0;if(!ENVIRONMENT_IS_PTHREAD)cleanupThread(thread);else postMessage({cmd:"cleanupThread",thread})}function __emscripten_thread_set_strongref(thread){thread>>>=0;if(ENVIRONMENT_IS_NODE){PThread.pthreads[thread].ref()}}function __wasmfs_copy_preloaded_file_data(index,buffer){buffer>>>=0;return(growMemViews(),HEAPU8).set(wasmFSPreloadedFiles[index].fileData,buffer>>>0)}var wasmFSPreloadedDirs=[];var __wasmfs_get_num_preloaded_dirs=()=>wasmFSPreloadedDirs.length;var wasmFSPreloadedFiles=[];var wasmFSPreloadingFlushed=false;var __wasmfs_get_num_preloaded_files=()=>{wasmFSPreloadingFlushed=true;return wasmFSPreloadedFiles.length};function __wasmfs_get_preloaded_child_path(index,childNameBuffer){childNameBuffer>>>=0;var s=wasmFSPreloadedDirs[index].childName;var len=lengthBytesUTF8(s)+1;stringToUTF8(s,childNameBuffer,len)}var __wasmfs_get_preloaded_file_mode=index=>wasmFSPreloadedFiles[index].mode;function __wasmfs_get_preloaded_file_size(index){return wasmFSPreloadedFiles[index].fileData.length}function __wasmfs_get_preloaded_parent_path(index,parentPathBuffer){parentPathBuffer>>>=0;var s=wasmFSPreloadedDirs[index].parentPath;var len=lengthBytesUTF8(s)+1;stringToUTF8(s,parentPathBuffer,len)}var lengthBytesUTF8=str=>{var len=0;for(var i=0;i<str.length;++i){var c=str.charCodeAt(i);if(c<=127){len++}else if(c<=2047){len+=2}else if(c>=55296&&c<=57343){len+=4;++i}else{len+=3}}return len};var stringToUTF8Array=(str,heap,outIdx,maxBytesToWrite)=>{outIdx>>>=0;if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx;var endIdx=outIdx+maxBytesToWrite-1;for(var i=0;i<str.length;++i){var u=str.codePointAt(i);if(u<=127){if(outIdx>=endIdx)break;heap[outIdx++>>>0]=u}else if(u<=2047){if(outIdx+1>=endIdx)break;heap[outIdx++>>>0]=192|u>>6;heap[outIdx++>>>0]=128|u&63}else if(u<=65535){if(outIdx+2>=endIdx)break;heap[outIdx++>>>0]=224|u>>12;heap[outIdx++>>>0]=128|u>>6&63;heap[outIdx++>>>0]=128|u&63}else{if(outIdx+3>=endIdx)break;heap[outIdx++>>>0]=240|u>>18;heap[outIdx++>>>0]=128|u>>12&63;heap[outIdx++>>>0]=128|u>>6&63;heap[outIdx++>>>0]=128|u&63;i++}}heap[outIdx>>>0]=0;return outIdx-startIdx};var stringToUTF8=(str,outPtr,maxBytesToWrite)=>stringToUTF8Array(str,(growMemViews(),HEAPU8),outPtr,maxBytesToWrite);function __wasmfs_get_preloaded_path_name(index,fileNameBuffer){fileNameBuffer>>>=0;var s=wasmFSPreloadedFiles[index].pathName;var len=lengthBytesUTF8(s)+1;stringToUTF8(s,fileNameBuffer,len)}class HandleAllocator{allocated=[undefined];freelist=[];get(id){return this.allocated[id]}has(id){return this.allocated[id]!==undefined}allocate(handle){var id=this.freelist.pop()||this.allocated.length;this.allocated[id]=handle;return id}free(id){this.allocated[id]=undefined;this.freelist.push(id)}}var wasmfsOPFSAccessHandles=new HandleAllocator;var wasmfsOPFSProxyFinish=ctx=>{_emscripten_proxy_finish(ctx)};async function __wasmfs_opfs_close_access(ctx,accessID,errPtr){ctx>>>=0;errPtr>>>=0;let accessHandle=wasmfsOPFSAccessHandles.get(accessID);try{await accessHandle.close()}catch{let err=-29;(growMemViews(),HEAP32)[errPtr>>>2>>>0]=err}wasmfsOPFSAccessHandles.free(accessID);wasmfsOPFSProxyFinish(ctx)}var wasmfsOPFSBlobs=new HandleAllocator;var __wasmfs_opfs_close_blob=blobID=>{wasmfsOPFSBlobs.free(blobID)};async function __wasmfs_opfs_flush_access(ctx,accessID,errPtr){ctx>>>=0;errPtr>>>=0;let accessHandle=wasmfsOPFSAccessHandles.get(accessID);try{await accessHandle.flush()}catch{let err=-29;(growMemViews(),HEAP32)[errPtr>>>2>>>0]=err}wasmfsOPFSProxyFinish(ctx)}var wasmfsOPFSDirectoryHandles=new HandleAllocator;var __wasmfs_opfs_free_directory=dirID=>{wasmfsOPFSDirectoryHandles.free(dirID)};var wasmfsOPFSFileHandles=new HandleAllocator;var __wasmfs_opfs_free_file=fileID=>{wasmfsOPFSFileHandles.free(fileID)};var wasmfsOPFSGetOrCreateFile=async(parent,name,create)=>{let parentHandle=wasmfsOPFSDirectoryHandles.get(parent);let fileHandle;try{fileHandle=await parentHandle.getFileHandle(name,{create})}catch(e){if(e.name==="NotFoundError"){return-20}if(e.name==="TypeMismatchError"){return-31}return-29}return wasmfsOPFSFileHandles.allocate(fileHandle)};var wasmfsOPFSGetOrCreateDir=async(parent,name,create)=>{let parentHandle=wasmfsOPFSDirectoryHandles.get(parent);let childHandle;try{childHandle=await parentHandle.getDirectoryHandle(name,{create})}catch(e){if(e.name==="NotFoundError"){return-20}if(e.name==="TypeMismatchError"){return-54}return-29}return wasmfsOPFSDirectoryHandles.allocate(childHandle)};var UTF8Decoder=globalThis.TextDecoder&&new TextDecoder;var findStringEnd=(heapOrArray,idx,maxBytesToRead,ignoreNul)=>{var maxIdx=idx+maxBytesToRead;if(ignoreNul)return maxIdx;while(heapOrArray[idx]&&!(idx>=maxIdx))++idx;return idx};var UTF8ArrayToString=(heapOrArray,idx=0,maxBytesToRead,ignoreNul)=>{idx>>>=0;var endPtr=findStringEnd(heapOrArray,idx,maxBytesToRead,ignoreNul);if(endPtr-idx>16&&heapOrArray.buffer&&UTF8Decoder){return UTF8Decoder.decode(heapOrArray.buffer instanceof ArrayBuffer?heapOrArray.subarray(idx,endPtr):heapOrArray.slice(idx,endPtr))}var str="";while(idx<endPtr){var u0=heapOrArray[idx++];if(!(u0&128)){str+=String.fromCharCode(u0);continue}var u1=heapOrArray[idx++]&63;if((u0&224)==192){str+=String.fromCharCode((u0&31)<<6|u1);continue}var u2=heapOrArray[idx++]&63;if((u0&240)==224){u0=(u0&15)<<12|u1<<6|u2}else{u0=(u0&7)<<18|u1<<12|u2<<6|heapOrArray[idx++]&63}if(u0<65536){str+=String.fromCharCode(u0)}else{var ch=u0-65536;str+=String.fromCharCode(55296|ch>>10,56320|ch&1023)}}return str};var UTF8ToString=(ptr,maxBytesToRead,ignoreNul)=>{ptr>>>=0;return ptr?UTF8ArrayToString((growMemViews(),HEAPU8),ptr,maxBytesToRead,ignoreNul):""};async function __wasmfs_opfs_get_child(ctx,parent,namePtr,childTypePtr,childIDPtr){ctx>>>=0;namePtr>>>=0;childTypePtr>>>=0;childIDPtr>>>=0;let name=UTF8ToString(namePtr);let childType=1;let childID=await wasmfsOPFSGetOrCreateFile(parent,name,false);if(childID==-31){childType=2;childID=await wasmfsOPFSGetOrCreateDir(parent,name,false)}(growMemViews(),HEAP32)[childTypePtr>>>2>>>0]=childType;(growMemViews(),HEAP32)[childIDPtr>>>2>>>0]=childID;wasmfsOPFSProxyFinish(ctx)}async function __wasmfs_opfs_get_entries(ctx,dirID,entriesPtr,errPtr){ctx>>>=0;entriesPtr>>>=0;errPtr>>>=0;let dirHandle=wasmfsOPFSDirectoryHandles.get(dirID);try{let iter=dirHandle.entries();for(let entry;entry=await iter.next(),!entry.done;){let[name,child]=entry.value;let sp=stackSave();let namePtr=stringToUTF8OnStack(name);let type=child.kind=="file"?1:2;__wasmfs_opfs_record_entry(entriesPtr,namePtr,type);stackRestore(sp)}}catch{let err=-29;(growMemViews(),HEAP32)[errPtr>>>2>>>0]=err}wasmfsOPFSProxyFinish(ctx)}async function __wasmfs_opfs_get_size_access(ctx,accessID,sizePtr){ctx>>>=0;sizePtr>>>=0;let accessHandle=wasmfsOPFSAccessHandles.get(accessID);let size;try{size=await accessHandle.getSize()}catch{size=-29}(growMemViews(),HEAP64)[sizePtr>>>3>>>0]=BigInt(size);wasmfsOPFSProxyFinish(ctx)}var __wasmfs_opfs_get_size_blob=function(blobID){var ret=(()=>wasmfsOPFSBlobs.get(blobID).size)();return BigInt(ret)};async function __wasmfs_opfs_get_size_file(ctx,fileID,sizePtr){ctx>>>=0;sizePtr>>>=0;let fileHandle=wasmfsOPFSFileHandles.get(fileID);let size;try{size=(await fileHandle.getFile()).size}catch{size=-29}(growMemViews(),HEAP64)[sizePtr>>>3>>>0]=BigInt(size);wasmfsOPFSProxyFinish(ctx)}async function __wasmfs_opfs_init_root_directory(ctx){ctx>>>=0;if(wasmfsOPFSDirectoryHandles.allocated.length==1){let root=await navigator.storage.getDirectory();wasmfsOPFSDirectoryHandles.allocated.push(root)}wasmfsOPFSProxyFinish(ctx)}async function __wasmfs_opfs_insert_directory(ctx,parent,namePtr,childIDPtr){ctx>>>=0;namePtr>>>=0;childIDPtr>>>=0;let name=UTF8ToString(namePtr);let childID=await wasmfsOPFSGetOrCreateDir(parent,name,true);(growMemViews(),HEAP32)[childIDPtr>>>2>>>0]=childID;wasmfsOPFSProxyFinish(ctx)}async function __wasmfs_opfs_insert_file(ctx,parent,namePtr,childIDPtr){ctx>>>=0;namePtr>>>=0;childIDPtr>>>=0;let name=UTF8ToString(namePtr);let childID=await wasmfsOPFSGetOrCreateFile(parent,name,true);(growMemViews(),HEAP32)[childIDPtr>>>2>>>0]=childID;wasmfsOPFSProxyFinish(ctx)}async function __wasmfs_opfs_move_file(ctx,fileID,newParentID,namePtr,errPtr){ctx>>>=0;namePtr>>>=0;errPtr>>>=0;let name=UTF8ToString(namePtr);let fileHandle=wasmfsOPFSFileHandles.get(fileID);let newDirHandle=wasmfsOPFSDirectoryHandles.get(newParentID);try{await fileHandle.move(newDirHandle,name)}catch{let err=-29;(growMemViews(),HEAP32)[errPtr>>>2>>>0]=err}wasmfsOPFSProxyFinish(ctx)}async function __wasmfs_opfs_open_access(ctx,fileID,accessIDPtr){ctx>>>=0;accessIDPtr>>>=0;let fileHandle=wasmfsOPFSFileHandles.get(fileID);let accessID;try{let accessHandle;var len=FileSystemFileHandle.prototype.createSyncAccessHandle.length;if(len==0){accessHandle=await fileHandle.createSyncAccessHandle()}else{accessHandle=await fileHandle.createSyncAccessHandle({mode:"in-place"})}accessID=wasmfsOPFSAccessHandles.allocate(accessHandle)}catch(e){if(e.name==="InvalidStateError"||e.name==="NoModificationAllowedError"){accessID=-2}else{accessID=-29}}(growMemViews(),HEAP32)[accessIDPtr>>>2>>>0]=accessID;wasmfsOPFSProxyFinish(ctx)}async function __wasmfs_opfs_open_blob(ctx,fileID,blobIDPtr){ctx>>>=0;blobIDPtr>>>=0;let fileHandle=wasmfsOPFSFileHandles.get(fileID);let blobID;try{let blob=await fileHandle.getFile();blobID=wasmfsOPFSBlobs.allocate(blob)}catch(e){if(e.name==="NotAllowedError"){blobID=-2}else{blobID=-29}}(growMemViews(),HEAP32)[blobIDPtr>>>2>>>0]=blobID;wasmfsOPFSProxyFinish(ctx)}function __wasmfs_opfs_read_access(accessID,bufPtr,len,pos){bufPtr>>>=0;pos=bigintToI53Checked(pos);let accessHandle=wasmfsOPFSAccessHandles.get(accessID);let data=(growMemViews(),HEAPU8).subarray(bufPtr>>>0,bufPtr+len>>>0);try{return accessHandle.read(data,{at:pos})}catch(e){if(e.name=="TypeError"){return-28}return-29}}async function __wasmfs_opfs_read_blob(ctx,blobID,bufPtr,len,pos,nreadPtr){ctx>>>=0;bufPtr>>>=0;pos=bigintToI53Checked(pos);nreadPtr>>>=0;let blob=wasmfsOPFSBlobs.get(blobID);let slice=blob.slice(pos,pos+len);let nread=0;try{let buf=await slice.arrayBuffer();let data=new Uint8Array(buf);(growMemViews(),HEAPU8).set(data,bufPtr>>>0);nread+=data.length}catch(e){if(e instanceof RangeError){nread=-21}else{nread=-29}}(growMemViews(),HEAP32)[nreadPtr>>>2>>>0]=nread;wasmfsOPFSProxyFinish(ctx)}async function __wasmfs_opfs_remove_child(ctx,dirID,namePtr,errPtr){ctx>>>=0;namePtr>>>=0;errPtr>>>=0;let name=UTF8ToString(namePtr);let dirHandle=wasmfsOPFSDirectoryHandles.get(dirID);try{await dirHandle.removeEntry(name)}catch{let err=-29;(growMemViews(),HEAP32)[errPtr>>>2>>>0]=err}wasmfsOPFSProxyFinish(ctx)}async function __wasmfs_opfs_set_size_access(ctx,accessID,size,errPtr){ctx>>>=0;size=bigintToI53Checked(size);errPtr>>>=0;let accessHandle=wasmfsOPFSAccessHandles.get(accessID);try{await accessHandle.truncate(size)}catch{let err=-29;(growMemViews(),HEAP32)[errPtr>>>2>>>0]=err}wasmfsOPFSProxyFinish(ctx)}async function __wasmfs_opfs_set_size_file(ctx,fileID,size,errPtr){ctx>>>=0;size=bigintToI53Checked(size);errPtr>>>=0;let fileHandle=wasmfsOPFSFileHandles.get(fileID);try{let writable=await fileHandle.createWritable({keepExistingData:true});await writable.truncate(size);await writable.close()}catch{let err=-29;(growMemViews(),HEAP32)[errPtr>>>2>>>0]=err}wasmfsOPFSProxyFinish(ctx)}function __wasmfs_opfs_write_access(accessID,bufPtr,len,pos){bufPtr>>>=0;pos=bigintToI53Checked(pos);let accessHandle=wasmfsOPFSAccessHandles.get(accessID);let data=(growMemViews(),HEAPU8).subarray(bufPtr>>>0,bufPtr+len>>>0);try{return accessHandle.write(data,{at:pos})}catch(e){if(e.name=="TypeError"){return-28}return-29}}var FS_stdin_getChar_buffer=[];var intArrayFromString=(stringy,dontAddNull,length)=>{var len=length>0?length:lengthBytesUTF8(stringy)+1;var u8array=new Array(len);var numBytesWritten=stringToUTF8Array(stringy,u8array,0,u8array.length);if(dontAddNull)u8array.length=numBytesWritten;return u8array};var FS_stdin_getChar=()=>{if(!FS_stdin_getChar_buffer.length){var result=null;if(ENVIRONMENT_IS_NODE){var BUFSIZE=256;var buf=Buffer.alloc(BUFSIZE);var bytesRead=0;var fd=process.stdin.fd;try{bytesRead=fs.readSync(fd,buf,0,BUFSIZE)}catch(e){if(e.toString().includes("EOF"))bytesRead=0;else throw e}if(bytesRead>0){result=buf.slice(0,bytesRead).toString("utf-8")}}else if(globalThis.window?.prompt){result=window.prompt("Input: ");if(result!==null){result+="\n"}}else{}if(!result){return null}FS_stdin_getChar_buffer=intArrayFromString(result,true)}return FS_stdin_getChar_buffer.shift()};var __wasmfs_stdin_get_char=()=>{var c=FS_stdin_getChar();if(typeof c==="number"){return c}return-1};var __wasmfs_thread_utils_heartbeat=function(queue){queue>>>=0;var intervalID=setInterval(()=>{if(ABORT){clearInterval(intervalID)}else{_emscripten_proxy_execute_queue(queue)}},50)};var _emscripten_get_now=()=>performance.timeOrigin+performance.now();var _emscripten_date_now=()=>Date.now();var nowIsMonotonic=1;var checkWasiClock=clock_id=>clock_id>=0&&clock_id<=3;function _clock_time_get(clk_id,ignored_precision,ptime){ignored_precision=bigintToI53Checked(ignored_precision);ptime>>>=0;if(!checkWasiClock(clk_id)){return 28}var now;if(clk_id===0){now=_emscripten_date_now()}else if(nowIsMonotonic){now=_emscripten_get_now()}else{return 52}var nsec=Math.round(now*1e3*1e3);(growMemViews(),HEAP64)[ptime>>>3>>>0]=BigInt(nsec);return 0}var _emscripten_check_blocking_allowed=()=>{};function _emscripten_err(str){str>>>=0;return err(UTF8ToString(str))}var _emscripten_exit_with_live_runtime=()=>{runtimeKeepalivePush();throw"unwind"};var getHeapMax=()=>4294901760;function _emscripten_get_heap_max(){return getHeapMax()}var _emscripten_num_logical_cores=()=>ENVIRONMENT_IS_NODE?require("node:os").cpus().length:navigator["hardwareConcurrency"];function _emscripten_out(str){str>>>=0;return out(UTF8ToString(str))}var alignMemory=(size,alignment)=>Math.ceil(size/alignment)*alignment;var growMemory=size=>{var oldHeapSize=wasmMemory.buffer.byteLength;var pages=(size-oldHeapSize+65535)/65536|0;try{wasmMemory.grow(pages);updateMemoryViews();return 1}catch(e){}};function _emscripten_resize_heap(requestedSize){requestedSize>>>=0;var oldSize=(growMemViews(),HEAPU8).length;if(requestedSize<=oldSize){return false}var maxHeapSize=getHeapMax();if(requestedSize>maxHeapSize){return false}for(var cutDown=1;cutDown<=4;cutDown*=2){var overGrownHeapSize=oldSize*(1+.2/cutDown);overGrownHeapSize=Math.min(overGrownHeapSize,requestedSize+100663296);var newSize=Math.min(maxHeapSize,alignMemory(Math.max(requestedSize,overGrownHeapSize),65536));var replacement=growMemory(newSize);if(replacement){return true}}return false}var _emscripten_runtime_keepalive_check=keepRuntimeAlive;var _emscripten_unwind_to_js_event_loop=()=>{throw"unwind"};var ENV={};var getExecutableName=()=>thisProgram||"./this.program";var getEnvStrings=()=>{if(!getEnvStrings.strings){var lang=(globalThis.navigator?.language??"C").replace("-","_")+".UTF-8";var env={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:lang,_:getExecutableName()};for(var x in ENV){if(ENV[x]===undefined)delete env[x];else env[x]=ENV[x]}var strings=[];for(var x in env){strings.push(`${x}=${env[x]}`)}getEnvStrings.strings=strings}return getEnvStrings.strings};function _environ_get(__environ,environ_buf){if(ENVIRONMENT_IS_PTHREAD)return proxyToMainThread(3,0,1,__environ,environ_buf);__environ>>>=0;environ_buf>>>=0;var bufSize=0;var envp=0;for(var string of getEnvStrings()){var ptr=environ_buf+bufSize;(growMemViews(),HEAPU32)[__environ+envp>>>2>>>0]=ptr;bufSize+=stringToUTF8(string,ptr,Infinity)+1;envp+=4}return 0}function _environ_sizes_get(penviron_count,penviron_buf_size){if(ENVIRONMENT_IS_PTHREAD)return proxyToMainThread(4,0,1,penviron_count,penviron_buf_size);penviron_count>>>=0;penviron_buf_size>>>=0;var strings=getEnvStrings();(growMemViews(),HEAPU32)[penviron_count>>>2>>>0]=strings.length;var bufSize=0;for(var string of strings){bufSize+=lengthBytesUTF8(string)+1}(growMemViews(),HEAPU32)[penviron_buf_size>>>2>>>0]=bufSize;return 0}var initRandomFill=()=>{if(ENVIRONMENT_IS_NODE){var nodeCrypto=require("node:crypto");return view=>nodeCrypto.randomFillSync(view)}return view=>view.set(crypto.getRandomValues(new Uint8Array(view.byteLength)))};var randomFill=view=>{(randomFill=initRandomFill())(view)};function _random_get(buffer,size){buffer>>>=0;size>>>=0;randomFill((growMemViews(),HEAPU8).subarray(buffer>>>0,buffer+size>>>0));return 0}var stringToUTF8OnStack=str=>{var size=lengthBytesUTF8(str)+1;var ret=stackAlloc(size);stringToUTF8(str,ret,size);return ret};var wasmTableMirror=[];var runAndAbortIfError=func=>{try{return func()}catch(e){abort(e)}};var Asyncify={instrumentWasmImports(imports){var importPattern=/^(invoke_.*|__asyncjs__.*)$/;for(let[x,original]of Object.entries(imports)){if(typeof original=="function"){let isAsyncifyImport=original.isAsync||importPattern.test(x)}}},instrumentFunction(original){var wrapper=(...args)=>{Asyncify.exportCallStack.push(original);try{return original(...args)}finally{if(!ABORT){var top=Asyncify.exportCallStack.pop();Asyncify.maybeStopUnwind()}}};Asyncify.funcWrappers.set(original,wrapper);return wrapper},instrumentWasmExports(exports){var ret={};for(let[x,original]of Object.entries(exports)){if(typeof original=="function"){var wrapper=Asyncify.instrumentFunction(original);ret[x]=wrapper}else{ret[x]=original}}return ret},State:{Normal:0,Unwinding:1,Rewinding:2,Disabled:3},state:0,StackSize:65536,currData:null,handleSleepReturnValue:0,exportCallStack:[],callstackFuncToId:new Map,callStackIdToFunc:new Map,funcWrappers:new Map,callStackId:0,asyncPromiseHandlers:null,sleepCallbacks:[],getCallStackId(func){if(!Asyncify.callstackFuncToId.has(func)){var id=Asyncify.callStackId++;Asyncify.callstackFuncToId.set(func,id);Asyncify.callStackIdToFunc.set(id,func)}return Asyncify.callstackFuncToId.get(func)},maybeStopUnwind(){if(Asyncify.currData&&Asyncify.state===Asyncify.State.Unwinding&&Asyncify.exportCallStack.length===0){Asyncify.state=Asyncify.State.Normal;runtimeKeepalivePush();runAndAbortIfError(_asyncify_stop_unwind);if(typeof Fibers!="undefined"){Fibers.trampoline()}}},whenDone(){return new Promise((resolve,reject)=>{Asyncify.asyncPromiseHandlers={resolve,reject}})},allocateData(){var ptr=_malloc(12+Asyncify.StackSize);Asyncify.setDataHeader(ptr,ptr+12,Asyncify.StackSize);Asyncify.setDataRewindFunc(ptr);return ptr},setDataHeader(ptr,stack,stackSize){(growMemViews(),HEAPU32)[ptr>>>2>>>0]=stack;(growMemViews(),HEAPU32)[ptr+4>>>2>>>0]=stack+stackSize},setDataRewindFunc(ptr){var bottomOfCallStack=Asyncify.exportCallStack[0];var rewindId=Asyncify.getCallStackId(bottomOfCallStack);(growMemViews(),HEAP32)[ptr+8>>>2>>>0]=rewindId},getDataRewindFunc(ptr){var id=(growMemViews(),HEAP32)[ptr+8>>>2>>>0];var func=Asyncify.callStackIdToFunc.get(id);return func},doRewind(ptr){var original=Asyncify.getDataRewindFunc(ptr);var func=Asyncify.funcWrappers.get(original);runtimeKeepalivePop();return callUserCallback(func)},handleSleep(startAsync){if(ABORT)return;if(Asyncify.state===Asyncify.State.Normal){var reachedCallback=false;var reachedAfterCallback=false;startAsync((handleSleepReturnValue=0)=>{if(ABORT)return;Asyncify.handleSleepReturnValue=handleSleepReturnValue;reachedCallback=true;if(!reachedAfterCallback){return}Asyncify.state=Asyncify.State.Rewinding;runAndAbortIfError(()=>_asyncify_start_rewind(Asyncify.currData));if(typeof MainLoop!="undefined"&&MainLoop.func){MainLoop.resume()}var asyncWasmReturnValue,isError=false;try{asyncWasmReturnValue=Asyncify.doRewind(Asyncify.currData)}catch(err){asyncWasmReturnValue=err;isError=true}var handled=false;if(!Asyncify.currData){var asyncPromiseHandlers=Asyncify.asyncPromiseHandlers;if(asyncPromiseHandlers){Asyncify.asyncPromiseHandlers=null;(isError?asyncPromiseHandlers.reject:asyncPromiseHandlers.resolve)(asyncWasmReturnValue);handled=true}}if(isError&&!handled){throw asyncWasmReturnValue}});reachedAfterCallback=true;if(!reachedCallback){Asyncify.state=Asyncify.State.Unwinding;Asyncify.currData=Asyncify.allocateData();if(typeof MainLoop!="undefined"&&MainLoop.func){MainLoop.pause()}runAndAbortIfError(()=>_asyncify_start_unwind(Asyncify.currData))}}else if(Asyncify.state===Asyncify.State.Rewinding){Asyncify.state=Asyncify.State.Normal;runAndAbortIfError(_asyncify_stop_rewind);_free(Asyncify.currData);Asyncify.currData=null;Asyncify.sleepCallbacks.forEach(callUserCallback)}else{abort(`invalid state: ${Asyncify.state}`)}return Asyncify.handleSleepReturnValue},handleAsync:startAsync=>Asyncify.handleSleep(async wakeUp=>{wakeUp(await startAsync())})};var getCFunc=ident=>{var func=Module["_"+ident];return func};var writeArrayToMemory=(array,buffer)=>{(growMemViews(),HEAP8).set(array,buffer>>>0)};var ccall=(ident,returnType,argTypes,args,opts)=>{var toC={string:str=>{var ret=0;if(str!==null&&str!==undefined&&str!==0){ret=stringToUTF8OnStack(str)}return ret},array:arr=>{var ret=stackAlloc(arr.length);writeArrayToMemory(arr,ret);return ret}};function convertReturnValue(ret){if(returnType==="string"){return UTF8ToString(ret)}if(returnType==="pointer")return ret>>>0;if(returnType==="boolean")return Boolean(ret);return ret}var func=getCFunc(ident);var cArgs=[];var stack=0;if(args){for(var i=0;i<args.length;i++){var converter=toC[argTypes[i]];if(converter){if(stack===0)stack=stackSave();cArgs[i]=converter(args[i])}else{cArgs[i]=args[i]}}}var previousAsync=Asyncify.currData;var ret=func(...cArgs);function onDone(ret){runtimeKeepalivePop();if(stack!==0)stackRestore(stack);return convertReturnValue(ret)}var asyncMode=opts?.async;runtimeKeepalivePush();if(Asyncify.currData!=previousAsync){return Asyncify.whenDone().then(onDone)}ret=onDone(ret);if(asyncMode)return Promise.resolve(ret);return ret};var cwrap=(ident,returnType,argTypes,opts)=>{var numericArgs=!argTypes||argTypes.every(type=>type==="number"||type==="boolean");var numericRet=returnType!=="string";if(numericRet&&numericArgs&&!opts){return getCFunc(ident)}return(...args)=>ccall(ident,returnType,argTypes,args,opts)};PThread.init();{initMemory();if(Module["noExitRuntime"])noExitRuntime=Module["noExitRuntime"];if(Module["print"])out=Module["print"];if(Module["printErr"])err=Module["printErr"];if(Module["wasmBinary"])wasmBinary=Module["wasmBinary"];if(Module["arguments"])arguments_=Module["arguments"];if(Module["thisProgram"])thisProgram=Module["thisProgram"];if(Module["preInit"]){if(typeof Module["preInit"]=="function")Module["preInit"]=[Module["preInit"]];while(Module["preInit"].length>0){Module["preInit"].shift()()}}}Module["ccall"]=ccall;Module["cwrap"]=cwrap;Module["getValue"]=getValue;Module["UTF8ToString"]=UTF8ToString;Module["stringToUTF8"]=stringToUTF8;Module["lengthBytesUTF8"]=lengthBytesUTF8;var proxiedFunctionTable=[_proc_exit,exitOnMainThread,pthreadCreateProxied,_environ_get,_environ_sizes_get];var _main,_lucivy_add,_lucivy_add_many,_lucivy_apply_sharded_delta,_lucivy_close,_lucivy_commit,_lucivy_commit_async,_lucivy_commit_finish,_lucivy_commit_status_ptr,_lucivy_configure,_lucivy_create,_lucivy_destroy,_lucivy_drain_merges,_lucivy_dump_mermaid,_lucivy_dump_state,_lucivy_dump_wait_graph,_lucivy_dump_wait_graph_text,_lucivy_export_sharded_delta,_lucivy_export_snapshot,_lucivy_export_stats,_lucivy_import_file,_lucivy_import_snapshot,_lucivy_log_ring_ptr,_lucivy_log_ring_size,_lucivy_merge_stats,_lucivy_num_docs,_lucivy_open,_lucivy_open_begin,_lucivy_open_finish,_lucivy_read_logs,_lucivy_remove,_lucivy_schema_json,_lucivy_search,_lucivy_search_filtered,_lucivy_search_with_global_stats,_lucivy_shard_versions,_lucivy_test_condvar,_lucivy_test_coop,_lucivy_update,__emscripten_tls_init,_pthread_self,_free,_malloc,__emscripten_proxy_main,__emscripten_thread_init,__emscripten_thread_crashed,_htonl,_htons,_emscripten_proxy_execute_queue,_ntohs,_emscripten_proxy_finish,__emscripten_run_js_on_main_thread_done,__emscripten_run_js_on_main_thread,__emscripten_thread_free_data,__emscripten_thread_exit,__emscripten_check_mailbox,_setThrew,__emscripten_tempret_set,_emscripten_stack_set_limits,__emscripten_stack_restore,__emscripten_stack_alloc,_emscripten_stack_get_current,___cxa_free_exception,___cxa_increment_exception_refcount,___cxa_decrement_exception_refcount,___cxa_can_catch,___cxa_get_exception_ptr,__wasmfs_opfs_record_entry,dynCall_iii,dynCall_iiii,dynCall_vi,dynCall_vii,dynCall_viiii,dynCall_viii,dynCall_ii,dynCall_viiiiiii,dynCall_viiiiii,dynCall_iiiii,dynCall_vij,dynCall_viiiii,dynCall_vijii,dynCall_jii,dynCall_ji,dynCall_dii,dynCall_di,dynCall_fi,dynCall_viiif,dynCall_viifiii,dynCall_viij,dynCall_viiiiiiii,dynCall_viiji,dynCall_iiji,dynCall_iij,dynCall_fiif,dynCall_iiiiiiiii,dynCall_v,dynCall_iidiiii,dynCall_jiji,dynCall_iiiij,_asyncify_start_unwind,_asyncify_stop_unwind,_asyncify_start_rewind,_asyncify_stop_rewind,__indirect_function_table,wasmTable;function assignWasmExports(wasmExports){_main=Module["_main"]=wasmExports["__main_argc_argv"];_lucivy_add=Module["_lucivy_add"]=wasmExports["lucivy_add"];_lucivy_add_many=Module["_lucivy_add_many"]=wasmExports["lucivy_add_many"];_lucivy_apply_sharded_delta=Module["_lucivy_apply_sharded_delta"]=wasmExports["lucivy_apply_sharded_delta"];_lucivy_close=Module["_lucivy_close"]=wasmExports["lucivy_close"];_lucivy_commit=Module["_lucivy_commit"]=wasmExports["lucivy_commit"];_lucivy_commit_async=Module["_lucivy_commit_async"]=wasmExports["lucivy_commit_async"];_lucivy_commit_finish=Module["_lucivy_commit_finish"]=wasmExports["lucivy_commit_finish"];_lucivy_commit_status_ptr=Module["_lucivy_commit_status_ptr"]=wasmExports["lucivy_commit_status_ptr"];_lucivy_configure=Module["_lucivy_configure"]=wasmExports["lucivy_configure"];_lucivy_create=Module["_lucivy_create"]=wasmExports["lucivy_create"];_lucivy_destroy=Module["_lucivy_destroy"]=wasmExports["lucivy_destroy"];_lucivy_drain_merges=Module["_lucivy_drain_merges"]=wasmExports["lucivy_drain_merges"];_lucivy_dump_mermaid=Module["_lucivy_dump_mermaid"]=wasmExports["lucivy_dump_mermaid"];_lucivy_dump_state=Module["_lucivy_dump_state"]=wasmExports["lucivy_dump_state"];_lucivy_dump_wait_graph=Module["_lucivy_dump_wait_graph"]=wasmExports["lucivy_dump_wait_graph"];_lucivy_dump_wait_graph_text=Module["_lucivy_dump_wait_graph_text"]=wasmExports["lucivy_dump_wait_graph_text"];_lucivy_export_sharded_delta=Module["_lucivy_export_sharded_delta"]=wasmExports["lucivy_export_sharded_delta"];_lucivy_export_snapshot=Module["_lucivy_export_snapshot"]=wasmExports["lucivy_export_snapshot"];_lucivy_export_stats=Module["_lucivy_export_stats"]=wasmExports["lucivy_export_stats"];_lucivy_import_file=Module["_lucivy_import_file"]=wasmExports["lucivy_import_file"];_lucivy_import_snapshot=Module["_lucivy_import_snapshot"]=wasmExports["lucivy_import_snapshot"];_lucivy_log_ring_ptr=Module["_lucivy_log_ring_ptr"]=wasmExports["lucivy_log_ring_ptr"];_lucivy_log_ring_size=Module["_lucivy_log_ring_size"]=wasmExports["lucivy_log_ring_size"];_lucivy_merge_stats=Module["_lucivy_merge_stats"]=wasmExports["lucivy_merge_stats"];_lucivy_num_docs=Module["_lucivy_num_docs"]=wasmExports["lucivy_num_docs"];_lucivy_open=Module["_lucivy_open"]=wasmExports["lucivy_open"];_lucivy_open_begin=Module["_lucivy_open_begin"]=wasmExports["lucivy_open_begin"];_lucivy_open_finish=Module["_lucivy_open_finish"]=wasmExports["lucivy_open_finish"];_lucivy_read_logs=Module["_lucivy_read_logs"]=wasmExports["lucivy_read_logs"];_lucivy_remove=Module["_lucivy_remove"]=wasmExports["lucivy_remove"];_lucivy_schema_json=Module["_lucivy_schema_json"]=wasmExports["lucivy_schema_json"];_lucivy_search=Module["_lucivy_search"]=wasmExports["lucivy_search"];_lucivy_search_filtered=Module["_lucivy_search_filtered"]=wasmExports["lucivy_search_filtered"];_lucivy_search_with_global_stats=Module["_lucivy_search_with_global_stats"]=wasmExports["lucivy_search_with_global_stats"];_lucivy_shard_versions=Module["_lucivy_shard_versions"]=wasmExports["lucivy_shard_versions"];_lucivy_test_condvar=Module["_lucivy_test_condvar"]=wasmExports["lucivy_test_condvar"];_lucivy_test_coop=Module["_lucivy_test_coop"]=wasmExports["lucivy_test_coop"];_lucivy_update=Module["_lucivy_update"]=wasmExports["lucivy_update"];__emscripten_tls_init=wasmExports["_emscripten_tls_init"];_pthread_self=wasmExports["pthread_self"];_free=Module["_free"]=wasmExports["free"];_malloc=Module["_malloc"]=wasmExports["malloc"];__emscripten_proxy_main=Module["__emscripten_proxy_main"]=wasmExports["_emscripten_proxy_main"];__emscripten_thread_init=wasmExports["_emscripten_thread_init"];__emscripten_thread_crashed=wasmExports["_emscripten_thread_crashed"];_htonl=wasmExports["htonl"];_htons=wasmExports["htons"];_emscripten_proxy_execute_queue=wasmExports["emscripten_proxy_execute_queue"];_ntohs=wasmExports["ntohs"];_emscripten_proxy_finish=wasmExports["emscripten_proxy_finish"];__emscripten_run_js_on_main_thread_done=wasmExports["_emscripten_run_js_on_main_thread_done"];__emscripten_run_js_on_main_thread=wasmExports["_emscripten_run_js_on_main_thread"];__emscripten_thread_free_data=wasmExports["_emscripten_thread_free_data"];__emscripten_thread_exit=wasmExports["_emscripten_thread_exit"];__emscripten_check_mailbox=wasmExports["_emscripten_check_mailbox"];_setThrew=wasmExports["setThrew"];__emscripten_tempret_set=wasmExports["_emscripten_tempret_set"];_emscripten_stack_set_limits=wasmExports["emscripten_stack_set_limits"];__emscripten_stack_restore=wasmExports["_emscripten_stack_restore"];__emscripten_stack_alloc=wasmExports["_emscripten_stack_alloc"];_emscripten_stack_get_current=wasmExports["emscripten_stack_get_current"];___cxa_free_exception=wasmExports["__cxa_free_exception"];___cxa_increment_exception_refcount=wasmExports["__cxa_increment_exception_refcount"];___cxa_decrement_exception_refcount=wasmExports["__cxa_decrement_exception_refcount"];___cxa_can_catch=wasmExports["__cxa_can_catch"];___cxa_get_exception_ptr=wasmExports["__cxa_get_exception_ptr"];__wasmfs_opfs_record_entry=wasmExports["_wasmfs_opfs_record_entry"];dynCall_iii=dynCalls["iii"]=wasmExports["dynCall_iii"];dynCall_iiii=dynCalls["iiii"]=wasmExports["dynCall_iiii"];dynCall_vi=dynCalls["vi"]=wasmExports["dynCall_vi"];dynCall_vii=dynCalls["vii"]=wasmExports["dynCall_vii"];dynCall_viiii=dynCalls["viiii"]=wasmExports["dynCall_viiii"];dynCall_viii=dynCalls["viii"]=wasmExports["dynCall_viii"];dynCall_ii=dynCalls["ii"]=wasmExports["dynCall_ii"];dynCall_viiiiiii=dynCalls["viiiiiii"]=wasmExports["dynCall_viiiiiii"];dynCall_viiiiii=dynCalls["viiiiii"]=wasmExports["dynCall_viiiiii"];dynCall_iiiii=dynCalls["iiiii"]=wasmExports["dynCall_iiiii"];dynCall_vij=dynCalls["vij"]=wasmExports["dynCall_vij"];dynCall_viiiii=dynCalls["viiiii"]=wasmExports["dynCall_viiiii"];dynCall_vijii=dynCalls["vijii"]=wasmExports["dynCall_vijii"];dynCall_jii=dynCalls["jii"]=wasmExports["dynCall_jii"];dynCall_ji=dynCalls["ji"]=wasmExports["dynCall_ji"];dynCall_dii=dynCalls["dii"]=wasmExports["dynCall_dii"];dynCall_di=dynCalls["di"]=wasmExports["dynCall_di"];dynCall_fi=dynCalls["fi"]=wasmExports["dynCall_fi"];dynCall_viiif=dynCalls["viiif"]=wasmExports["dynCall_viiif"];dynCall_viifiii=dynCalls["viifiii"]=wasmExports["dynCall_viifiii"];dynCall_viij=dynCalls["viij"]=wasmExports["dynCall_viij"];dynCall_viiiiiiii=dynCalls["viiiiiiii"]=wasmExports["dynCall_viiiiiiii"];dynCall_viiji=dynCalls["viiji"]=wasmExports["dynCall_viiji"];dynCall_iiji=dynCalls["iiji"]=wasmExports["dynCall_iiji"];dynCall_iij=dynCalls["iij"]=wasmExports["dynCall_iij"];dynCall_fiif=dynCalls["fiif"]=wasmExports["dynCall_fiif"];dynCall_iiiiiiiii=dynCalls["iiiiiiiii"]=wasmExports["dynCall_iiiiiiiii"];dynCall_v=dynCalls["v"]=wasmExports["dynCall_v"];dynCall_iidiiii=dynCalls["iidiiii"]=wasmExports["dynCall_iidiiii"];dynCall_jiji=dynCalls["jiji"]=wasmExports["dynCall_jiji"];dynCall_iiiij=dynCalls["iiiij"]=wasmExports["dynCall_iiiij"];_asyncify_start_unwind=wasmExports["asyncify_start_unwind"];_asyncify_stop_unwind=wasmExports["asyncify_stop_unwind"];_asyncify_start_rewind=wasmExports["asyncify_start_rewind"];_asyncify_stop_rewind=wasmExports["asyncify_stop_rewind"];__indirect_function_table=wasmTable=wasmExports["__indirect_function_table"]}var wasmImports;function assignWasmImports(){wasmImports={__call_sighandler:___call_sighandler,__cxa_begin_catch:___cxa_begin_catch,__cxa_find_matching_catch_2:___cxa_find_matching_catch_2,__cxa_find_matching_catch_3:___cxa_find_matching_catch_3,__cxa_throw:___cxa_throw,__pthread_create_js:___pthread_create_js,__resumeException:___resumeException,_abort_js:__abort_js,_emscripten_init_main_thread_js:__emscripten_init_main_thread_js,_emscripten_notify_mailbox_postmessage:__emscripten_notify_mailbox_postmessage,_emscripten_receive_on_main_thread_js:__emscripten_receive_on_main_thread_js,_emscripten_runtime_keepalive_clear:__emscripten_runtime_keepalive_clear,_emscripten_thread_cleanup:__emscripten_thread_cleanup,_emscripten_thread_mailbox_await:__emscripten_thread_mailbox_await,_emscripten_thread_set_strongref:__emscripten_thread_set_strongref,_wasmfs_copy_preloaded_file_data:__wasmfs_copy_preloaded_file_data,_wasmfs_get_num_preloaded_dirs:__wasmfs_get_num_preloaded_dirs,_wasmfs_get_num_preloaded_files:__wasmfs_get_num_preloaded_files,_wasmfs_get_preloaded_child_path:__wasmfs_get_preloaded_child_path,_wasmfs_get_preloaded_file_mode:__wasmfs_get_preloaded_file_mode,_wasmfs_get_preloaded_file_size:__wasmfs_get_preloaded_file_size,_wasmfs_get_preloaded_parent_path:__wasmfs_get_preloaded_parent_path,_wasmfs_get_preloaded_path_name:__wasmfs_get_preloaded_path_name,_wasmfs_opfs_close_access:__wasmfs_opfs_close_access,_wasmfs_opfs_close_blob:__wasmfs_opfs_close_blob,_wasmfs_opfs_flush_access:__wasmfs_opfs_flush_access,_wasmfs_opfs_free_directory:__wasmfs_opfs_free_directory,_wasmfs_opfs_free_file:__wasmfs_opfs_free_file,_wasmfs_opfs_get_child:__wasmfs_opfs_get_child,_wasmfs_opfs_get_entries:__wasmfs_opfs_get_entries,_wasmfs_opfs_get_size_access:__wasmfs_opfs_get_size_access,_wasmfs_opfs_get_size_blob:__wasmfs_opfs_get_size_blob,_wasmfs_opfs_get_size_file:__wasmfs_opfs_get_size_file,_wasmfs_opfs_init_root_directory:__wasmfs_opfs_init_root_directory,_wasmfs_opfs_insert_directory:__wasmfs_opfs_insert_directory,_wasmfs_opfs_insert_file:__wasmfs_opfs_insert_file,_wasmfs_opfs_move_file:__wasmfs_opfs_move_file,_wasmfs_opfs_open_access:__wasmfs_opfs_open_access,_wasmfs_opfs_open_blob:__wasmfs_opfs_open_blob,_wasmfs_opfs_read_access:__wasmfs_opfs_read_access,_wasmfs_opfs_read_blob:__wasmfs_opfs_read_blob,_wasmfs_opfs_remove_child:__wasmfs_opfs_remove_child,_wasmfs_opfs_set_size_access:__wasmfs_opfs_set_size_access,_wasmfs_opfs_set_size_file:__wasmfs_opfs_set_size_file,_wasmfs_opfs_write_access:__wasmfs_opfs_write_access,_wasmfs_stdin_get_char:__wasmfs_stdin_get_char,_wasmfs_thread_utils_heartbeat:__wasmfs_thread_utils_heartbeat,clock_time_get:_clock_time_get,emscripten_check_blocking_allowed:_emscripten_check_blocking_allowed,emscripten_date_now:_emscripten_date_now,emscripten_err:_emscripten_err,emscripten_exit_with_live_runtime:_emscripten_exit_with_live_runtime,emscripten_get_heap_max:_emscripten_get_heap_max,emscripten_get_now:_emscripten_get_now,emscripten_num_logical_cores:_emscripten_num_logical_cores,emscripten_out:_emscripten_out,emscripten_resize_heap:_emscripten_resize_heap,emscripten_runtime_keepalive_check:_emscripten_runtime_keepalive_check,emscripten_unwind_to_js_event_loop:_emscripten_unwind_to_js_event_loop,environ_get:_environ_get,environ_sizes_get:_environ_sizes_get,exit:_exit,invoke_ii,invoke_iii,invoke_iiii,invoke_v,invoke_vi,invoke_vii,invoke_viii,memory:wasmMemory,proc_exit:_proc_exit,random_get:_random_get}}function invoke_v(index){var sp=stackSave();try{dynCall_v(index)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_vii(index,a1,a2){var sp=stackSave();try{dynCall_vii(index,a1,a2)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_ii(index,a1){var sp=stackSave();try{return dynCall_ii(index,a1)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_vi(index,a1){var sp=stackSave();try{dynCall_vi(index,a1)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iii(index,a1,a2){var sp=stackSave();try{return dynCall_iii(index,a1,a2)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viii(index,a1,a2,a3){var sp=stackSave();try{dynCall_viii(index,a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiii(index,a1,a2,a3){var sp=stackSave();try{return dynCall_iiii(index,a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function applySignatureConversions(wasmExports){wasmExports=Object.assign({},wasmExports);var makeWrapper_p=f=>()=>f()>>>0;var makeWrapper_pp=f=>a0=>f(a0)>>>0;wasmExports["pthread_self"]=makeWrapper_p(wasmExports["pthread_self"]);wasmExports["malloc"]=makeWrapper_pp(wasmExports["malloc"]);wasmExports["_emscripten_stack_alloc"]=makeWrapper_pp(wasmExports["_emscripten_stack_alloc"]);wasmExports["emscripten_stack_get_current"]=makeWrapper_p(wasmExports["emscripten_stack_get_current"]);wasmExports["__cxa_get_exception_ptr"]=makeWrapper_pp(wasmExports["__cxa_get_exception_ptr"]);return wasmExports}function callMain(args=[]){var entryFunction=__emscripten_proxy_main;runtimeKeepalivePush();args.unshift(thisProgram);var argc=args.length;var argv=stackAlloc((argc+1)*4);var argv_ptr=argv;for(var arg of args){(growMemViews(),HEAPU32)[argv_ptr>>>2>>>0]=stringToUTF8OnStack(arg);argv_ptr+=4}(growMemViews(),HEAPU32)[argv_ptr>>>2>>>0]=0;try{var ret=entryFunction(argc,argv);exitJS(ret,true);return ret}catch(e){return handleException(e)}}function run(args=arguments_){if(runDependencies>0){dependenciesFulfilled=run;return}if(ENVIRONMENT_IS_PTHREAD){readyPromiseResolve?.(Module);initRuntime();return}preRun();if(runDependencies>0){dependenciesFulfilled=run;return}function doRun(){Module["calledRun"]=true;if(ABORT)return;initRuntime();preMain();readyPromiseResolve?.(Module);Module["onRuntimeInitialized"]?.();var noInitialRun=Module["noInitialRun"]||false;if(!noInitialRun)callMain(args);postRun()}if(Module["setStatus"]){Module["setStatus"]("Running...");setTimeout(()=>{setTimeout(()=>Module["setStatus"](""),1);doRun()},1)}else{doRun()}}var wasmExports;if(!ENVIRONMENT_IS_PTHREAD){wasmExports=await (createWasm());run()}if(runtimeInitialized){moduleRtn=Module}else{moduleRtn=new Promise((resolve,reject)=>{readyPromiseResolve=resolve;readyPromiseReject=reject})}
|
|
2
|
-
;return
|
|
1
|
+
async function createLucivy(moduleArg={}){var Module=moduleArg;var ENVIRONMENT_IS_WEB=!!globalThis.window;var ENVIRONMENT_IS_WORKER=!!globalThis.WorkerGlobalScope;var ENVIRONMENT_IS_NODE=globalThis.process?.versions?.node&&globalThis.process?.type!="renderer";var ENVIRONMENT_IS_PTHREAD=ENVIRONMENT_IS_WORKER&&globalThis.name=="em-pthread";if(ENVIRONMENT_IS_NODE){const{createRequire}=await import("node:module");var require=createRequire(import.meta.url);var worker_threads=require("node:worker_threads");globalThis.Worker=worker_threads.Worker;ENVIRONMENT_IS_WORKER=!worker_threads.isMainThread;ENVIRONMENT_IS_PTHREAD=ENVIRONMENT_IS_WORKER&&worker_threads.workerData=="em-pthread"}var programArgs=[];var thisProgram="./this.program";var quit_=(status,toThrow)=>{throw toThrow};var _scriptName=import.meta.url;var scriptDirectory="";function locateFile(path){if(Module["locateFile"]){return Module["locateFile"](path,scriptDirectory)}return scriptDirectory+path}var readAsync,readBinary;if(ENVIRONMENT_IS_NODE){var fs=require("node:fs");if(_scriptName.startsWith("file:")){scriptDirectory=require("node:path").dirname(require("node:url").fileURLToPath(_scriptName))+"/"}readBinary=filename=>{filename=isFileURI(filename)?new URL(filename):filename;var ret=fs.readFileSync(filename);return ret};readAsync=async(filename,binary=true)=>{filename=isFileURI(filename)?new URL(filename):filename;var ret=fs.readFileSync(filename,binary?undefined:"utf8");return ret};if(process.argv.length>1){thisProgram=process.argv[1].replace(/\\/g,"/")}programArgs=process.argv.slice(2);quit_=(status,toThrow)=>{process.exitCode=status;throw toThrow}}else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){try{scriptDirectory=new URL(".",_scriptName).href}catch{}if(!ENVIRONMENT_IS_NODE){if(ENVIRONMENT_IS_WORKER){readBinary=url=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.responseType="arraybuffer";xhr.send(null);return new Uint8Array(xhr.response)}}readAsync=async url=>{if(isFileURI(url)){return new Promise((resolve,reject)=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,true);xhr.responseType="arraybuffer";xhr.onload=()=>{if(xhr.status==200||xhr.status==0&&xhr.response){resolve(xhr.response);return}reject(xhr.status)};xhr.onerror=reject;xhr.send(null)})}var response=await fetch(url,{credentials:"same-origin"});if(response.ok){return response.arrayBuffer()}throw new Error(response.status+" : "+response.url)}}}else{}var defaultPrint=console.log.bind(console);var defaultPrintErr=console.error.bind(console);if(ENVIRONMENT_IS_NODE){var utils=require("node:util");var stringify=a=>typeof a=="object"?utils.inspect(a):a;defaultPrint=(...args)=>fs.writeSync(1,args.map(stringify).join(" ")+"\n");defaultPrintErr=(...args)=>fs.writeSync(2,args.map(stringify).join(" ")+"\n")}var out=defaultPrint;var err=defaultPrintErr;var wasmBinary;var wasmModule;var ABORT=false;var EXITSTATUS;var isFileURI=filename=>filename.startsWith("file://");class EmscriptenEH{}class EmscriptenSjLj extends EmscriptenEH{}class CppException extends EmscriptenEH{constructor(excPtr){super();this.excPtr=excPtr}}function growMemViews(){if(wasmMemory.buffer!=HEAP8.buffer){updateMemoryViews()}}if(ENVIRONMENT_IS_NODE&&ENVIRONMENT_IS_PTHREAD){globalThis.self=globalThis;var parentPort=worker_threads.parentPort;if(!globalThis.postMessage){parentPort.on("message",msg=>globalThis.onmessage?.({data:msg}));globalThis.postMessage=msg=>parentPort.postMessage(msg)}process.on("uncaughtException",err=>{postMessage({cmd:8,error:err});process.exit(1)})}var startWorker;if(ENVIRONMENT_IS_PTHREAD){var initializedJS=false;self.onunhandledrejection=e=>{throw e.reason||e};function handleMessage(e){try{var msgData=e.data;var cmd=msgData.cmd;if(cmd==1){let messageQueue=[];self.onmessage=e=>messageQueue.push(e);startWorker=()=>{postMessage({cmd:3});for(let msg of messageQueue){handleMessage(msg)}self.onmessage=handleMessage};for(const handler of msgData.handlers){if(!Module[handler]||Module[handler].proxy){Module[handler]=(...args)=>{postMessage({cmd:9,handler,args})};if(handler=="print")out=Module[handler];if(handler=="printErr")err=Module[handler]}}wasmMemory=msgData.wasmMemory;updateMemoryViews();wasmModule=msgData.wasmModule;createWasm();run();startWorker()}else if(cmd==2){establishStackSpace(msgData.pthread_ptr);__emscripten_thread_init(msgData.pthread_ptr,0,0,1,0,0);PThread.threadInitTLS();__emscripten_thread_mailbox_await(msgData.pthread_ptr);if(!initializedJS){initializedJS=true}try{invokeEntryPoint(msgData.start_routine,msgData.arg)}catch(ex){if(ex!="unwind"){throw ex}}}else if(cmd==4){if(initializedJS){checkMailbox()}}else if(cmd){err(`worker: received unknown command ${cmd}`);err(msgData)}}catch(ex){if(runtimeInitialized)__emscripten_thread_crashed();throw ex}}self.onmessage=handleMessage}var runtimeInitialized=false;function getMemoryBuffer(){return wasmMemory.buffer}function updateMemoryViews(){if(HEAP8?.buffer?.growable)return;var b=getMemoryBuffer();HEAP8=new Int8Array(b);HEAP16=new Int16Array(b);Module["HEAPU8"]=HEAPU8=new Uint8Array(b);HEAP32=new Int32Array(b);HEAPU32=new Uint32Array(b);HEAPF32=new Float32Array(b);HEAPF64=new Float64Array(b);HEAP64=new BigInt64Array(b)}function initMemory(){if(ENVIRONMENT_IS_PTHREAD){return}{var INITIAL_MEMORY=16777216;wasmMemory=new WebAssembly.Memory({initial:INITIAL_MEMORY/65536,maximum:65536,shared:true})}updateMemoryViews()}function preRun(){var preRun=Module["preRun"];if(preRun){if(typeof preRun=="function")preRun=[preRun];onPreRuns.push(...preRun)}callRuntimeCallbacks(onPreRuns)}function initRuntime(){runtimeInitialized=true;if(ENVIRONMENT_IS_PTHREAD)return;wasmExports["__wasm_call_ctors"]()}function postRun(){var postRun=Module["postRun"];if(postRun){if(typeof postRun=="function")postRun=[postRun];onPostRuns.push(...postRun)}callRuntimeCallbacks(onPostRuns)}function abort(what){Module["onAbort"]?.(what);what=`Aborted(${what})`;err(what);ABORT=true;what+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(what);throw e}var wasmBinaryFile;function findWasmBinary(){if(Module["locateFile"]){return locateFile("lucivy.wasm")}return new URL("lucivy.wasm",import.meta.url).href}function getBinarySync(file){if(readBinary){return readBinary(file)}throw"both async and sync fetching of the wasm failed"}async function getWasmBinary(binaryFile){if(!wasmBinary){try{var response=await readAsync(binaryFile);return new Uint8Array(response)}catch{}}return getBinarySync(binaryFile)}async function instantiateArrayBuffer(binaryFile,imports){try{var binary=await getWasmBinary(binaryFile);var instance=await WebAssembly.instantiate(binary,imports);return instance}catch(reason){err(`failed to asynchronously prepare wasm: ${reason}`);abort(reason)}}async function instantiateAsync(binary,binaryFile,imports){if(!binary&&!isFileURI(binaryFile)&&!ENVIRONMENT_IS_NODE){try{var response=fetch(binaryFile,{credentials:"same-origin"});var instantiationResult=await WebAssembly.instantiateStreaming(response,imports);return instantiationResult}catch(reason){err(`wasm streaming compile failed: ${reason}`);err("falling back to ArrayBuffer instantiation")}}return instantiateArrayBuffer(binaryFile,imports)}function getWasmImports(){assignWasmImports();var imports={env:wasmImports,wasi_snapshot_preview1:wasmImports};return imports}async function createWasm(){function receiveInstance(instance,module){wasmExports=instance.exports;wasmExports=applySignatureConversions(wasmExports);registerTLSInit(wasmExports["_emscripten_tls_init"]);assignWasmExports(wasmExports);wasmModule=module;return wasmExports}function receiveInstantiationResult(result){return receiveInstance(result["instance"],result["module"])}var info=getWasmImports();var instantiateWasm=Module["instantiateWasm"];if(instantiateWasm){return new Promise(resolve=>{instantiateWasm(info,(inst,mod)=>resolve(receiveInstance(inst,mod)))})}if(ENVIRONMENT_IS_PTHREAD){var instance=new WebAssembly.Instance(wasmModule,getWasmImports());return receiveInstance(instance,wasmModule)}wasmBinaryFile??=findWasmBinary();var result=await instantiateAsync(wasmBinary,wasmBinaryFile,info);var exports=receiveInstantiationResult(result);return exports}class ExitStatus{name="ExitStatus";constructor(status){this.message=`Program terminated with exit(${status})`;this.status=status}}var HEAP8;var terminateWorker=worker=>{worker.terminate();worker.onmessage=e=>{}};var cleanupThread=pthread_ptr=>{var worker=PThread.pthreads[pthread_ptr];PThread.returnWorkerToPool(worker)};var callRuntimeCallbacks=callbacks=>{while(callbacks.length>0){callbacks.shift()(Module)}};var onPreRuns=[];var addOnPreRun=cb=>onPreRuns.push(cb);var dependenciesPromise=null;var resolveRunDependencies=async()=>dependenciesPromise;var runDependencies=0;var dependenciesPromiseResolve=null;var removeRunDependency=id=>{runDependencies--;Module["monitorRunDependencies"]?.(runDependencies);if(!runDependencies){dependenciesPromiseResolve()}};var addRunDependency=id=>{if(!runDependencies){dependenciesPromise=new Promise(resolve=>dependenciesPromiseResolve=resolve)}runDependencies++;Module["monitorRunDependencies"]?.(runDependencies)};var spawnThread=threadParams=>{var worker=PThread.getNewWorker();if(!worker){return 6}PThread.pthreads[threadParams.pthread_ptr]=worker;worker.pthread_ptr=threadParams.pthread_ptr;var msg={cmd:2,start_routine:threadParams.startRoutine,arg:threadParams.arg,pthread_ptr:threadParams.pthread_ptr};worker.postMessage(msg,threadParams.transferList);return 0};var runtimeKeepaliveCounter=0;var keepRuntimeAlive=()=>noExitRuntime||runtimeKeepaliveCounter>0;var stackSave=()=>_emscripten_stack_get_current();var stackRestore=val=>__emscripten_stack_restore(val);var stackAlloc=sz=>__emscripten_stack_alloc(sz);var HEAPF64;var HEAP64;var proxyToMainThread=(funcIndex,emAsmAddr,proxyMode,...callArgs)=>{var bufSize=8*callArgs.length*2;var sp=stackSave();var args=stackAlloc(bufSize);var b=args>>>3;for(var arg of callArgs){if(typeof arg=="bigint"){(growMemViews(),HEAP64)[b++>>>0]=1n;(growMemViews(),HEAP64)[b++>>>0]=arg}else{(growMemViews(),HEAP64)[b++>>>0]=0n;(growMemViews(),HEAPF64)[b++>>>0]=arg}}var rtn=__emscripten_run_js_on_main_thread(funcIndex,emAsmAddr,bufSize,args,proxyMode);stackRestore(sp);return rtn};function _proc_exit(code){if(ENVIRONMENT_IS_PTHREAD)return proxyToMainThread(0,0,1,code);EXITSTATUS=code;if(!keepRuntimeAlive()){PThread.terminateAllThreads();Module["onExit"]?.(code);ABORT=true}quit_(code,new ExitStatus(code))}var runtimeKeepalivePop=()=>{runtimeKeepaliveCounter-=1};function exitOnMainThread(returnCode){if(ENVIRONMENT_IS_PTHREAD)return proxyToMainThread(1,0,0,returnCode);runtimeKeepalivePop();_exit(returnCode)}var exitJS=(status,implicit)=>{EXITSTATUS=status;if(ENVIRONMENT_IS_PTHREAD){exitOnMainThread(status);throw"unwind"}_proc_exit(status)};var _exit=exitJS;var waitAsyncPolyfilled=!Atomics.waitAsync||globalThis.navigator?.userAgent&&Number((navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./)||[])[2])<91;var HEAP32;var PThread={unusedWorkers:[],tlsInitFunctions:[],pthreads:{},init(){if(!ENVIRONMENT_IS_PTHREAD){PThread.initMainThread()}},initMainThread(){var pthreadPoolSize=Math.min(navigator.hardwareConcurrency||4,16);while(pthreadPoolSize--){PThread.allocateUnusedWorker()}addOnPreRun(async()=>{var pthreadPoolReady=PThread.loadWasmModuleToAllWorkers();addRunDependency("loading-workers");await pthreadPoolReady;removeRunDependency("loading-workers")})},terminateAllThreads:()=>{for(var worker of Object.values(PThread.pthreads)){terminateWorker(worker)}for(var worker of PThread.unusedWorkers){terminateWorker(worker)}PThread.unusedWorkers=[];PThread.pthreads={}},clearMailboxAwait:pthread_ptr=>{if(!waitAsyncPolyfilled){Atomics.notify((growMemViews(),HEAP32),pthread_ptr>>>2)}},terminateRuntime:()=>{PThread.terminateAllThreads();var pthread_ptr=_pthread_self();___set_thread_state(0,0,0,1);PThread.clearMailboxAwait(pthread_ptr)},returnWorkerToPool:worker=>{var pthread_ptr=worker.pthread_ptr;delete PThread.pthreads[pthread_ptr];PThread.unusedWorkers.push(worker);worker.pthread_ptr=0;if(ENVIRONMENT_IS_NODE){worker.unref()}PThread.clearMailboxAwait(pthread_ptr);__emscripten_thread_free_data(pthread_ptr)},threadInitTLS(){PThread.tlsInitFunctions.forEach(f=>f())},loadWasmModuleToWorker:worker=>new Promise(onFinishedLoading=>{worker.onmessage=e=>{var d=e.data;var cmd=d.cmd;if(d.targetThread&&d.targetThread!=_pthread_self()){var targetWorker=PThread.pthreads[d.targetThread];targetWorker?.postMessage(d);return}if(d==="setimmediate"||d==="_si"){worker.postMessage(d);return}switch(cmd){case 4:checkMailbox();break;case 5:spawnThread(d);break;case 6:callUserCallback(()=>cleanupThread(d.thread));break;case 3:if(ENVIRONMENT_IS_NODE&&!worker.strongref){worker.unref()}onFinishedLoading(worker);break;case 8:worker.onerror(d.error);break;case 9:Module[d.handler](...d.args);break;default:if(cmd)err(`worker sent an unknown command ${cmd}`)}};worker.onerror=e=>{var message="worker sent an error!";err(`${message} ${e.filename}:${e.lineno}: ${e.message}`);throw e};if(ENVIRONMENT_IS_NODE){worker.on("message",data=>worker.onmessage({data}));worker.on("error",e=>worker.onerror(e))}var handlers=[];var knownHandlers=["onExit","onAbort","print","printErr"];for(var handler of knownHandlers){if(Module.propertyIsEnumerable(handler)){handlers.push(handler)}}worker.postMessage({cmd:1,handlers,wasmMemory,wasmModule})}),async loadWasmModuleToAllWorkers(){if(ENVIRONMENT_IS_PTHREAD){return}let pthreadPoolReady=Promise.all(PThread.unusedWorkers.map(PThread.loadWasmModuleToWorker));return pthreadPoolReady},allocateUnusedWorker(){var worker;worker=new Worker(new URL("lucivy.js",import.meta.url),{type:"module",workerData:"em-pthread",trackUnmanagedFds:false,name:"em-pthread"});PThread.unusedWorkers.push(worker);return worker},getNewWorker(){if(PThread.unusedWorkers.length==0){var newWorker=PThread.allocateUnusedWorker();PThread.loadWasmModuleToWorker(newWorker)}return PThread.unusedWorkers.pop()}};var onPostRuns=[];var HEAPU32;function establishStackSpace(pthread_ptr){var stackHigh=(growMemViews(),HEAPU32)[pthread_ptr+48>>>2>>>0];var stackSize=(growMemViews(),HEAPU32)[pthread_ptr+52>>>2>>>0];var stackLow=stackHigh-stackSize;_emscripten_stack_set_limits(stackHigh,stackLow);stackRestore(stackHigh)}var wasmTableMirror=[];var getWasmTableEntry=funcPtr=>{var func=wasmTableMirror[funcPtr];if(!func){wasmTableMirror[funcPtr]=func=wasmTable.get(funcPtr)}return func};var invokeEntryPoint=(ptr,arg)=>{runtimeKeepaliveCounter=0;noExitRuntime=0;var result=getWasmTableEntry(ptr)(arg);function finish(result){if(keepRuntimeAlive()){EXITSTATUS=result;return}__emscripten_thread_exit(result)}finish(result)};var noExitRuntime=true;var registerTLSInit=tlsInitFunc=>PThread.tlsInitFunctions.push(tlsInitFunc);var runtimeKeepalivePush=()=>{runtimeKeepaliveCounter+=1};var wasmMemory;var INT53_MAX=9007199254740992;var INT53_MIN=-9007199254740992;var bigintToI53Checked=num=>num<INT53_MIN||num>INT53_MAX?NaN:Number(num);function ___call_sighandler(fp,sig){fp>>>=0;return getWasmTableEntry(fp)(sig)}var exceptionCaught=[];var uncaughtExceptionCount=0;function ___cxa_begin_catch(ptr){ptr>>>=0;var info=new ExceptionInfo(ptr);if(!info.get_caught()){info.set_caught(true);uncaughtExceptionCount--}info.set_rethrown(false);exceptionCaught.push(info);return ___cxa_get_exception_ptr(ptr)}var exceptionLast=null;class ExceptionInfo{constructor(excPtr){this.excPtr=excPtr;this.ptr=excPtr-24}set_type(type){(growMemViews(),HEAPU32)[this.ptr+4>>>2>>>0]=type}get_type(){return(growMemViews(),HEAPU32)[this.ptr+4>>>2>>>0]}set_destructor(destructor){(growMemViews(),HEAPU32)[this.ptr+8>>>2>>>0]=destructor}get_destructor(){return(growMemViews(),HEAPU32)[this.ptr+8>>>2>>>0]}set_caught(caught){caught=caught?1:0;(growMemViews(),HEAP8)[this.ptr+12>>>0]=caught}get_caught(){return(growMemViews(),HEAP8)[this.ptr+12>>>0]!=0}set_rethrown(rethrown){rethrown=rethrown?1:0;(growMemViews(),HEAP8)[this.ptr+13>>>0]=rethrown}get_rethrown(){return(growMemViews(),HEAP8)[this.ptr+13>>>0]!=0}init(type,destructor){this.set_adjusted_ptr(0);this.set_type(type);this.set_destructor(destructor)}set_adjusted_ptr(adjustedPtr){(growMemViews(),HEAPU32)[this.ptr+16>>>2>>>0]=adjustedPtr}get_adjusted_ptr(){return(growMemViews(),HEAPU32)[this.ptr+16>>>2>>>0]}}var setTempRet0=val=>__emscripten_tempret_set(val);var findMatchingCatch=args=>{var thrown=exceptionLast?.excPtr;if(!thrown){setTempRet0(0);return 0}var info=new ExceptionInfo(thrown);info.set_adjusted_ptr(thrown);var thrownType=info.get_type();if(!thrownType){setTempRet0(0);return thrown}for(var caughtType of args){if(!caughtType||caughtType===thrownType){break}var adjusted_ptr_addr=info.ptr+16;if(___cxa_can_catch(caughtType,thrownType,adjusted_ptr_addr)){setTempRet0(caughtType);return thrown}}setTempRet0(thrownType);return thrown};function ___cxa_find_matching_catch_2(){return findMatchingCatch([])}function ___cxa_find_matching_catch_3(arg0){arg0>>>=0;return findMatchingCatch([arg0])}var __Unwind_RaiseException=ex=>{throw ex};function ___cxa_throw(ptr,type,destructor){ptr>>>=0;type>>>=0;destructor>>>=0;var info=new ExceptionInfo(ptr);info.init(type,destructor);___cxa_increment_exception_refcount(ptr);ptr=exceptionLast=new CppException(ptr);uncaughtExceptionCount++;__Unwind_RaiseException(ptr)}function pthreadCreateProxied(pthread_ptr,attr,startRoutine,arg){if(ENVIRONMENT_IS_PTHREAD)return proxyToMainThread(2,0,1,pthread_ptr,attr,startRoutine,arg);return ___pthread_create_js(pthread_ptr,attr,startRoutine,arg)}var _emscripten_has_threading_support=()=>!!globalThis.SharedArrayBuffer;function ___pthread_create_js(pthread_ptr,attr,startRoutine,arg){pthread_ptr>>>=0;attr>>>=0;startRoutine>>>=0;arg>>>=0;if(!_emscripten_has_threading_support()){return 6}var transferList=[];var error=0;if(ENVIRONMENT_IS_PTHREAD&&(!transferList.length||error)){return pthreadCreateProxied(pthread_ptr,attr,startRoutine,arg)}if(error)return error;var threadParams={startRoutine,pthread_ptr,arg,transferList};if(ENVIRONMENT_IS_PTHREAD){threadParams.cmd=5;postMessage(threadParams,transferList);return 0}return spawnThread(threadParams)}var __Unwind_Resume=ex=>{throw ex};function ___resumeException(ptr){ptr>>>=0;ptr=exceptionLast??=new CppException(ptr);__Unwind_Resume(ptr)}var __abort_js=()=>abort("");function __emscripten_init_main_thread_js(tb){tb>>>=0;var can_block=!ENVIRONMENT_IS_WEB;try{Atomics.wait((growMemViews(),HEAP32),0,0,0);can_block=true}catch(e){}__emscripten_thread_init(tb,!ENVIRONMENT_IS_WORKER,1,can_block,2097152,false);PThread.threadInitTLS()}var handleException=e=>{if(e instanceof ExitStatus||e=="unwind"){return EXITSTATUS}quit_(1,e)};var maybeExit=()=>{if(!keepRuntimeAlive()){try{if(ENVIRONMENT_IS_PTHREAD){if(_pthread_self())__emscripten_thread_exit(EXITSTATUS);return}_exit(EXITSTATUS)}catch(e){handleException(e)}}};var callUserCallback=func=>{if(ABORT){return}try{return func()}catch(e){handleException(e)}finally{maybeExit()}};function __emscripten_thread_mailbox_await(pthread_ptr){pthread_ptr>>>=0;if(!waitAsyncPolyfilled){var wait=Atomics.waitAsync((growMemViews(),HEAP32),pthread_ptr>>>2,pthread_ptr);wait.value.then(checkMailbox);var waitingAsync=pthread_ptr+112;Atomics.store((growMemViews(),HEAP32),waitingAsync>>>2,1)}}var checkMailbox=()=>{var pthread_ptr=_pthread_self();if(!pthread_ptr)return;callUserCallback(()=>{__emscripten_thread_mailbox_await(pthread_ptr);__emscripten_check_mailbox()})};function __emscripten_notify_mailbox_postmessage(targetThread,currThreadId){targetThread>>>=0;currThreadId>>>=0;if(targetThread==currThreadId){setTimeout(checkMailbox)}else if(ENVIRONMENT_IS_PTHREAD){postMessage({targetThread,cmd:4})}else{var worker=PThread.pthreads[targetThread];if(!worker){return}worker.postMessage({cmd:4})}}var proxiedJSCallArgs=[];function __emscripten_receive_on_main_thread_js(funcIndex,emAsmAddr,callingThread,bufSize,args,ctx,ctxArgs){emAsmAddr>>>=0;callingThread>>>=0;args>>>=0;ctx>>>=0;ctxArgs>>>=0;proxiedJSCallArgs.length=0;var b=args>>>3;var end=args+bufSize>>>3;while(b<end){var arg;if((growMemViews(),HEAP64)[b++>>>0]){arg=(growMemViews(),HEAP64)[b++>>>0]}else{arg=(growMemViews(),HEAPF64)[b++>>>0]}proxiedJSCallArgs.push(arg)}var func=proxiedFunctionTable[funcIndex];PThread.currentProxiedOperationCallerThread=callingThread;var rtn=func(...proxiedJSCallArgs);PThread.currentProxiedOperationCallerThread=0;if(ctx){rtn.then(rtn=>__emscripten_run_js_on_main_thread_done(ctx,ctxArgs,rtn));return}return rtn}var __emscripten_runtime_keepalive_clear=()=>{noExitRuntime=false;runtimeKeepaliveCounter=0};function __emscripten_thread_cleanup(thread){thread>>>=0;if(!ENVIRONMENT_IS_PTHREAD)cleanupThread(thread);else postMessage({cmd:6,thread})}function __emscripten_thread_set_strongref(thread){thread>>>=0;if(ENVIRONMENT_IS_NODE){var worker=PThread.pthreads[thread];worker.ref();worker.strongref=1}}var HEAPU8;function __wasmfs_copy_preloaded_file_data(index,buffer){buffer>>>=0;return(growMemViews(),HEAPU8).set(wasmFSPreloadedFiles[index].fileData,buffer>>>0)}var wasmFSPreloadedDirs=[];var __wasmfs_get_num_preloaded_dirs=()=>wasmFSPreloadedDirs.length;var wasmFSPreloadedFiles=[];var wasmFSPreloadingFlushed=false;var __wasmfs_get_num_preloaded_files=()=>{wasmFSPreloadingFlushed=true;return wasmFSPreloadedFiles.length};function __wasmfs_get_preloaded_child_path(index,childNameBuffer){childNameBuffer>>>=0;var s=wasmFSPreloadedDirs[index].childName;var len=lengthBytesUTF8(s)+1;stringToUTF8(s,childNameBuffer,len)}var __wasmfs_get_preloaded_file_mode=index=>wasmFSPreloadedFiles[index].mode;function __wasmfs_get_preloaded_file_size(index){return wasmFSPreloadedFiles[index].fileData.length}function __wasmfs_get_preloaded_parent_path(index,parentPathBuffer){parentPathBuffer>>>=0;var s=wasmFSPreloadedDirs[index].parentPath;var len=lengthBytesUTF8(s)+1;stringToUTF8(s,parentPathBuffer,len)}var lengthBytesUTF8=str=>{var len=0;for(var i=0;i<str.length;++i){var c=str.charCodeAt(i);if(c<=127){len++}else if(c<=2047){len+=2}else if(c>=55296&&c<=57343){len+=4;++i}else{len+=3}}return len};var stringToUTF8Array=(str,heap,outIdx,maxBytesToWrite)=>{outIdx>>>=0;if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx;var endIdx=outIdx+maxBytesToWrite-1;for(var i=0;i<str.length;++i){var u=str.codePointAt(i);if(u<=127){if(outIdx>=endIdx)break;heap[outIdx++>>>0]=u}else if(u<=2047){if(outIdx+1>=endIdx)break;heap[outIdx++>>>0]=192|u>>6;heap[outIdx++>>>0]=128|u&63}else if(u<=65535){if(outIdx+2>=endIdx)break;heap[outIdx++>>>0]=224|u>>12;heap[outIdx++>>>0]=128|u>>6&63;heap[outIdx++>>>0]=128|u&63}else{if(outIdx+3>=endIdx)break;heap[outIdx++>>>0]=240|u>>18;heap[outIdx++>>>0]=128|u>>12&63;heap[outIdx++>>>0]=128|u>>6&63;heap[outIdx++>>>0]=128|u&63;i++}}heap[outIdx>>>0]=0;return outIdx-startIdx};var stringToUTF8=(str,outPtr,maxBytesToWrite)=>stringToUTF8Array(str,(growMemViews(),HEAPU8),outPtr,maxBytesToWrite);function __wasmfs_get_preloaded_path_name(index,fileNameBuffer){fileNameBuffer>>>=0;var s=wasmFSPreloadedFiles[index].pathName;var len=lengthBytesUTF8(s)+1;stringToUTF8(s,fileNameBuffer,len)}class HandleAllocator{allocated=[undefined];freelist=[];get(id){return this.allocated[id]}has(id){return this.allocated[id]!==undefined}allocate(handle){var id=this.freelist.pop()??this.allocated.length;this.allocated[id]=handle;return id}free(id){this.allocated[id]=undefined;this.freelist.push(id)}}var wasmfsOPFSAccessHandles=new HandleAllocator;var wasmfsOPFSProxyFinish=ctx=>{_emscripten_proxy_finish(ctx)};async function __wasmfs_opfs_close_access(ctx,accessID,errPtr){ctx>>>=0;errPtr>>>=0;let accessHandle=wasmfsOPFSAccessHandles.get(accessID);try{await accessHandle.close()}catch{let err=-29;(growMemViews(),HEAP32)[errPtr>>>2>>>0]=err}wasmfsOPFSAccessHandles.free(accessID);wasmfsOPFSProxyFinish(ctx)}var wasmfsOPFSBlobs=new HandleAllocator;var __wasmfs_opfs_close_blob=blobID=>{wasmfsOPFSBlobs.free(blobID)};async function __wasmfs_opfs_flush_access(ctx,accessID,errPtr){ctx>>>=0;errPtr>>>=0;let accessHandle=wasmfsOPFSAccessHandles.get(accessID);try{await accessHandle.flush()}catch{let err=-29;(growMemViews(),HEAP32)[errPtr>>>2>>>0]=err}wasmfsOPFSProxyFinish(ctx)}var wasmfsOPFSDirectoryHandles=new HandleAllocator;var __wasmfs_opfs_free_directory=dirID=>{wasmfsOPFSDirectoryHandles.free(dirID)};var wasmfsOPFSFileHandles=new HandleAllocator;var __wasmfs_opfs_free_file=fileID=>{wasmfsOPFSFileHandles.free(fileID)};var wasmfsOPFSGetOrCreateFile=async(parent,name,create)=>{let parentHandle=wasmfsOPFSDirectoryHandles.get(parent);let fileHandle;try{fileHandle=await parentHandle.getFileHandle(name,{create})}catch(e){if(e.name==="NotFoundError"){return-20}if(e.name==="TypeMismatchError"){return-31}return-29}return wasmfsOPFSFileHandles.allocate(fileHandle)};var wasmfsOPFSGetOrCreateDir=async(parent,name,create)=>{let parentHandle=wasmfsOPFSDirectoryHandles.get(parent);let childHandle;try{childHandle=await parentHandle.getDirectoryHandle(name,{create})}catch(e){if(e.name==="NotFoundError"){return-20}if(e.name==="TypeMismatchError"){return-54}return-29}return wasmfsOPFSDirectoryHandles.allocate(childHandle)};var UTF8Decoder=globalThis.TextDecoder&&new TextDecoder;var findStringEnd=(heapOrArray,idx,maxBytesToRead,ignoreNul)=>{var maxIdx=idx+maxBytesToRead;if(ignoreNul)return maxIdx;while(heapOrArray[idx]&&!(idx>=maxIdx))++idx;return idx};var UTF8ArrayToString=(heapOrArray,idx=0,maxBytesToRead,ignoreNul)=>{idx>>>=0;var endPtr=findStringEnd(heapOrArray,idx,maxBytesToRead,ignoreNul);if(endPtr-idx>16&&heapOrArray.buffer&&UTF8Decoder){return UTF8Decoder.decode(heapOrArray.buffer instanceof ArrayBuffer?heapOrArray.subarray(idx,endPtr):heapOrArray.slice(idx,endPtr))}var str="";while(idx<endPtr){var u0=heapOrArray[idx++];if(!(u0&128)){str+=String.fromCharCode(u0);continue}var u1=heapOrArray[idx++]&63;if((u0&224)==192){str+=String.fromCharCode((u0&31)<<6|u1);continue}var u2=heapOrArray[idx++]&63;if((u0&240)==224){u0=(u0&15)<<12|u1<<6|u2}else{u0=(u0&7)<<18|u1<<12|u2<<6|heapOrArray[idx++]&63}if(u0<65536){str+=String.fromCharCode(u0)}else{var ch=u0-65536;str+=String.fromCharCode(55296|ch>>10,56320|ch&1023)}}return str};var UTF8ToString=(ptr,maxBytesToRead,ignoreNul)=>{ptr>>>=0;return ptr?UTF8ArrayToString((growMemViews(),HEAPU8),ptr,maxBytesToRead,ignoreNul):""};async function __wasmfs_opfs_get_child(ctx,parent,namePtr,childTypePtr,childIDPtr){ctx>>>=0;namePtr>>>=0;childTypePtr>>>=0;childIDPtr>>>=0;let name=UTF8ToString(namePtr);let childType=1;let childID=await wasmfsOPFSGetOrCreateFile(parent,name,false);if(childID==-31){childType=2;childID=await wasmfsOPFSGetOrCreateDir(parent,name,false)}(growMemViews(),HEAP32)[childTypePtr>>>2>>>0]=childType;(growMemViews(),HEAP32)[childIDPtr>>>2>>>0]=childID;wasmfsOPFSProxyFinish(ctx)}async function __wasmfs_opfs_get_entries(ctx,dirID,entriesPtr,errPtr){ctx>>>=0;entriesPtr>>>=0;errPtr>>>=0;let dirHandle=wasmfsOPFSDirectoryHandles.get(dirID);try{let iter=dirHandle.entries();for(let entry;entry=await iter.next(),!entry.done;){let[name,child]=entry.value;let sp=stackSave();let namePtr=stringToUTF8OnStack(name);let type=child.kind=="file"?1:2;__wasmfs_opfs_record_entry(entriesPtr,namePtr,type);stackRestore(sp)}}catch{let err=-29;(growMemViews(),HEAP32)[errPtr>>>2>>>0]=err}wasmfsOPFSProxyFinish(ctx)}async function __wasmfs_opfs_get_size_access(ctx,accessID,sizePtr){ctx>>>=0;sizePtr>>>=0;let accessHandle=wasmfsOPFSAccessHandles.get(accessID);let size;try{size=await accessHandle.getSize()}catch{size=-29}(growMemViews(),HEAP64)[sizePtr>>>3>>>0]=BigInt(size);wasmfsOPFSProxyFinish(ctx)}var __wasmfs_opfs_get_size_blob=function(blobID){var ret=(()=>wasmfsOPFSBlobs.get(blobID).size)();return BigInt(ret)};async function __wasmfs_opfs_get_size_file(ctx,fileID,sizePtr){ctx>>>=0;sizePtr>>>=0;let fileHandle=wasmfsOPFSFileHandles.get(fileID);let size;try{size=(await fileHandle.getFile()).size}catch{size=-29}(growMemViews(),HEAP64)[sizePtr>>>3>>>0]=BigInt(size);wasmfsOPFSProxyFinish(ctx)}async function __wasmfs_opfs_init_root_directory(ctx){ctx>>>=0;if(wasmfsOPFSDirectoryHandles.allocated.length==1){let root=await navigator.storage.getDirectory();wasmfsOPFSDirectoryHandles.allocated.push(root)}wasmfsOPFSProxyFinish(ctx)}async function __wasmfs_opfs_insert_directory(ctx,parent,namePtr,childIDPtr){ctx>>>=0;namePtr>>>=0;childIDPtr>>>=0;let name=UTF8ToString(namePtr);let childID=await wasmfsOPFSGetOrCreateDir(parent,name,true);(growMemViews(),HEAP32)[childIDPtr>>>2>>>0]=childID;wasmfsOPFSProxyFinish(ctx)}async function __wasmfs_opfs_insert_file(ctx,parent,namePtr,childIDPtr){ctx>>>=0;namePtr>>>=0;childIDPtr>>>=0;let name=UTF8ToString(namePtr);let childID=await wasmfsOPFSGetOrCreateFile(parent,name,true);(growMemViews(),HEAP32)[childIDPtr>>>2>>>0]=childID;wasmfsOPFSProxyFinish(ctx)}async function __wasmfs_opfs_move_file(ctx,fileID,newParentID,namePtr,errPtr){ctx>>>=0;namePtr>>>=0;errPtr>>>=0;let name=UTF8ToString(namePtr);let fileHandle=wasmfsOPFSFileHandles.get(fileID);let newDirHandle=wasmfsOPFSDirectoryHandles.get(newParentID);try{await fileHandle.move(newDirHandle,name)}catch{let err=-29;(growMemViews(),HEAP32)[errPtr>>>2>>>0]=err}wasmfsOPFSProxyFinish(ctx)}async function __wasmfs_opfs_open_access(ctx,fileID,accessIDPtr){ctx>>>=0;accessIDPtr>>>=0;let fileHandle=wasmfsOPFSFileHandles.get(fileID);let accessID;try{let accessHandle;var len=FileSystemFileHandle.prototype.createSyncAccessHandle.length;if(len==0){accessHandle=await fileHandle.createSyncAccessHandle()}else{accessHandle=await fileHandle.createSyncAccessHandle({mode:"in-place"})}accessID=wasmfsOPFSAccessHandles.allocate(accessHandle)}catch(e){if(e.name==="InvalidStateError"||e.name==="NoModificationAllowedError"){accessID=-2}else{accessID=-29}}(growMemViews(),HEAP32)[accessIDPtr>>>2>>>0]=accessID;wasmfsOPFSProxyFinish(ctx)}async function __wasmfs_opfs_open_blob(ctx,fileID,blobIDPtr){ctx>>>=0;blobIDPtr>>>=0;let fileHandle=wasmfsOPFSFileHandles.get(fileID);let blobID;try{let blob=await fileHandle.getFile();blobID=wasmfsOPFSBlobs.allocate(blob)}catch(e){if(e.name==="NotAllowedError"){blobID=-2}else{blobID=-29}}(growMemViews(),HEAP32)[blobIDPtr>>>2>>>0]=blobID;wasmfsOPFSProxyFinish(ctx)}function __wasmfs_opfs_read_access(accessID,bufPtr,len,pos){bufPtr>>>=0;pos=bigintToI53Checked(pos);let accessHandle=wasmfsOPFSAccessHandles.get(accessID);let data=(growMemViews(),HEAPU8).subarray(bufPtr>>>0,bufPtr+len>>>0);try{return accessHandle.read(data,{at:pos})}catch(e){if(e.name=="TypeError"){return-28}return-29}}async function __wasmfs_opfs_read_blob(ctx,blobID,bufPtr,len,pos,nreadPtr){ctx>>>=0;bufPtr>>>=0;pos=bigintToI53Checked(pos);nreadPtr>>>=0;let blob=wasmfsOPFSBlobs.get(blobID);let slice=blob.slice(pos,pos+len);let nread=0;try{let buf=await slice.arrayBuffer();let data=new Uint8Array(buf);(growMemViews(),HEAPU8).set(data,bufPtr>>>0);nread+=data.length}catch(e){if(e instanceof RangeError){nread=-21}else{nread=-29}}(growMemViews(),HEAP32)[nreadPtr>>>2>>>0]=nread;wasmfsOPFSProxyFinish(ctx)}async function __wasmfs_opfs_remove_child(ctx,dirID,namePtr,errPtr){ctx>>>=0;namePtr>>>=0;errPtr>>>=0;let name=UTF8ToString(namePtr);let dirHandle=wasmfsOPFSDirectoryHandles.get(dirID);try{await dirHandle.removeEntry(name)}catch{let err=-29;(growMemViews(),HEAP32)[errPtr>>>2>>>0]=err}wasmfsOPFSProxyFinish(ctx)}async function __wasmfs_opfs_set_size_access(ctx,accessID,size,errPtr){ctx>>>=0;size=bigintToI53Checked(size);errPtr>>>=0;let accessHandle=wasmfsOPFSAccessHandles.get(accessID);try{await accessHandle.truncate(size)}catch{let err=-29;(growMemViews(),HEAP32)[errPtr>>>2>>>0]=err}wasmfsOPFSProxyFinish(ctx)}async function __wasmfs_opfs_set_size_file(ctx,fileID,size,errPtr){ctx>>>=0;size=bigintToI53Checked(size);errPtr>>>=0;let fileHandle=wasmfsOPFSFileHandles.get(fileID);try{let writable=await fileHandle.createWritable({keepExistingData:true});await writable.truncate(size);await writable.close()}catch{let err=-29;(growMemViews(),HEAP32)[errPtr>>>2>>>0]=err}wasmfsOPFSProxyFinish(ctx)}function __wasmfs_opfs_write_access(accessID,bufPtr,len,pos){bufPtr>>>=0;pos=bigintToI53Checked(pos);let accessHandle=wasmfsOPFSAccessHandles.get(accessID);let data=(growMemViews(),HEAPU8).subarray(bufPtr>>>0,bufPtr+len>>>0);try{return accessHandle.write(data,{at:pos})}catch(e){if(e.name=="TypeError"){return-28}return-29}}var FS_stdin_getChar_buffer=[];var intArrayFromString=(stringy,dontAddNull,length)=>{var len=length>0?length:lengthBytesUTF8(stringy)+1;var u8array=new Array(len);var numBytesWritten=stringToUTF8Array(stringy,u8array,0,u8array.length);if(dontAddNull)u8array.length=numBytesWritten;return u8array};var FS_stdin_getChar=()=>{if(!FS_stdin_getChar_buffer.length){var result=null;if(ENVIRONMENT_IS_NODE){var BUFSIZE=256;var buf=Buffer.alloc(BUFSIZE);var bytesRead=0;var fd=process.stdin.fd;try{bytesRead=fs.readSync(fd,buf,0,BUFSIZE)}catch(e){if(e.toString().includes("EOF"))bytesRead=0;else throw e}if(bytesRead>0){result=buf.slice(0,bytesRead).toString("utf-8")}}else if(globalThis.window?.prompt){result=window.prompt("Input: ");if(result!==null){result+="\n"}}else{}if(!result){return null}FS_stdin_getChar_buffer=intArrayFromString(result,true)}return FS_stdin_getChar_buffer.shift()};var __wasmfs_stdin_get_char=()=>{var c=FS_stdin_getChar();if(typeof c==="number"){return c}return-1};var __wasmfs_thread_utils_heartbeat=function(queue){queue>>>=0;var intervalID=setInterval(()=>{if(ABORT){clearInterval(intervalID)}else{_emscripten_proxy_execute_queue(queue)}},50)};var _emscripten_get_now=()=>performance.timeOrigin+performance.now();var _emscripten_date_now=()=>Date.now();var nowIsMonotonic=1;var checkWasiClock=clock_id=>clock_id>=0&&clock_id<=3;function _clock_time_get(clk_id,ignored_precision,ptime){ignored_precision=bigintToI53Checked(ignored_precision);ptime>>>=0;if(!checkWasiClock(clk_id)){return 28}var now;if(clk_id===0){now=_emscripten_date_now()}else if(nowIsMonotonic){now=_emscripten_get_now()}else{return 52}var nsec=Math.round(now*1e3*1e3);(growMemViews(),HEAP64)[ptime>>>3>>>0]=BigInt(nsec);return 0}var _emscripten_check_blocking_allowed=()=>{};function _emscripten_err(str){str>>>=0;return err(UTF8ToString(str))}var _emscripten_exit_with_live_runtime=()=>{runtimeKeepalivePush();throw"unwind"};var jsStackTrace=()=>(new Error).stack.toString();var getCallstack=flags=>{var callstack=jsStackTrace();var lines=callstack.split("\n");callstack="";var firefoxRe=new RegExp("\\s*(.*?)@(.*?):([0-9]+):([0-9]+)");var chromeRe=new RegExp("\\s*at (.*?) \\((.*):(.*):(.*)\\)");for(var line of lines){var symbolName="";var file="";var lineno=0;var column=0;var parts=chromeRe.exec(line);if(parts?.length==5){symbolName=parts[1];file=parts[2];lineno=parts[3];column=parts[4]}else{parts=firefoxRe.exec(line);if(parts?.length>=4){symbolName=parts[1];file=parts[2];lineno=parts[3];column=parts[4]|0}else{callstack+=line+"\n";continue}}if(symbolName=="_emscripten_log"||symbolName=="_emscripten_get_callstack"){callstack="";continue}if(flags&24){if(flags&64){file=file.substring(file.replace(/\\/g,"/").lastIndexOf("/")+1)}callstack+=` at ${symbolName} (${file}:${lineno}:${column})\n`}}callstack=callstack.replace(/\s+$/,"");return callstack};function _emscripten_get_callstack(flags,str,maxbytes){str>>>=0;var callstack=getCallstack(flags);if(!str||maxbytes<=0){return lengthBytesUTF8(callstack)+1}var bytesWrittenExcludingNull=stringToUTF8(callstack,str,maxbytes);return bytesWrittenExcludingNull+1}var getHeapMax=()=>4294901760;function _emscripten_get_heap_max(){return getHeapMax()}var _emscripten_num_logical_cores=()=>ENVIRONMENT_IS_NODE?require("node:os").cpus().length:navigator["hardwareConcurrency"];function _emscripten_out(str){str>>>=0;return out(UTF8ToString(str))}var alignMemory=(size,alignment)=>Math.ceil(size/alignment)*alignment;var growMemory=size=>{var oldHeapSize=wasmMemory.buffer.byteLength;var pages=(size-oldHeapSize+65535)/65536|0;try{wasmMemory.grow(pages);updateMemoryViews();return 1}catch(e){}};function _emscripten_resize_heap(requestedSize){requestedSize>>>=0;var oldSize=(growMemViews(),HEAPU8).length;if(requestedSize<=oldSize){return false}var maxHeapSize=getHeapMax();if(requestedSize>maxHeapSize){return false}for(var cutDown=1;cutDown<=4;cutDown*=2){var overGrownHeapSize=oldSize*(1+.2/cutDown);overGrownHeapSize=Math.min(overGrownHeapSize,requestedSize+100663296);var newSize=Math.min(maxHeapSize,alignMemory(Math.max(requestedSize,overGrownHeapSize),65536));var replacement=growMemory(newSize);if(replacement){return true}}return false}var _emscripten_runtime_keepalive_check=keepRuntimeAlive;var _emscripten_unwind_to_js_event_loop=()=>{throw"unwind"};var ENV={};var getExecutableName=()=>thisProgram;var getEnvStrings=()=>{if(!getEnvStrings.strings){var lang=(globalThis.navigator?.language??"C").replace("-","_")+".UTF-8";var env={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:lang,_:getExecutableName()};for(var x in ENV){if(ENV[x]===undefined)delete env[x];else env[x]=ENV[x]}var strings=[];for(var x in env){strings.push(`${x}=${env[x]}`)}getEnvStrings.strings=strings}return getEnvStrings.strings};function _environ_get(__environ,environ_buf){if(ENVIRONMENT_IS_PTHREAD)return proxyToMainThread(3,0,1,__environ,environ_buf);__environ>>>=0;environ_buf>>>=0;var bufSize=0;var envp=0;for(var string of getEnvStrings()){var ptr=environ_buf+bufSize;(growMemViews(),HEAPU32)[__environ+envp>>>2>>>0]=ptr;bufSize+=stringToUTF8(string,ptr,Infinity)+1;envp+=4}return 0}function _environ_sizes_get(penviron_count,penviron_buf_size){if(ENVIRONMENT_IS_PTHREAD)return proxyToMainThread(4,0,1,penviron_count,penviron_buf_size);penviron_count>>>=0;penviron_buf_size>>>=0;var strings=getEnvStrings();(growMemViews(),HEAPU32)[penviron_count>>>2>>>0]=strings.length;var bufSize=0;for(var string of strings){bufSize+=lengthBytesUTF8(string)+1}(growMemViews(),HEAPU32)[penviron_buf_size>>>2>>>0]=bufSize;return 0}var initRandomFill=()=>{if(ENVIRONMENT_IS_NODE){var nodeCrypto=require("node:crypto");return view=>(nodeCrypto.randomFillSync(view),0)}return view=>(view.set(crypto.getRandomValues(new Uint8Array(view.byteLength))),0)};var randomFill=view=>(randomFill=initRandomFill())(view);function _random_get(buffer,size){buffer>>>=0;size>>>=0;return randomFill((growMemViews(),HEAPU8).subarray(buffer>>>0,buffer+size>>>0))}var stringToUTF8OnStack=str=>{var size=lengthBytesUTF8(str)+1;var ret=stackAlloc(size);stringToUTF8(str,ret,size);return ret};var getCFunc=ident=>{var func=Module["_"+ident];return func};var writeArrayToMemory=(array,buffer)=>{(growMemViews(),HEAP8).set(array,buffer>>>0)};var ccall=(ident,returnType,argTypes,args,opts)=>{var toC={string:str=>{var ret=0;if(str!==null&&str!==undefined&&str!==0){ret=stringToUTF8OnStack(str)}return ret},array:arr=>{var ret=stackAlloc(arr.length);writeArrayToMemory(arr,ret);return ret}};function convertReturnValue(ret){if(returnType==="string"){return UTF8ToString(ret)}if(returnType==="pointer")return ret>>>0;if(returnType==="boolean")return Boolean(ret);return ret}var func=getCFunc(ident);var cArgs=[];var stack=0;if(args){for(var i=0;i<args.length;i++){var converter=toC[argTypes[i]];if(converter){if(!stack)stack=stackSave();cArgs[i]=converter(args[i])}else{cArgs[i]=args[i]}}}var ret=func(...cArgs);function onDone(ret){if(stack)stackRestore(stack);return convertReturnValue(ret)}ret=onDone(ret);return ret};var cwrap=(ident,returnType,argTypes,opts)=>{var numericArgs=!argTypes||argTypes.every(type=>type==="number"||type==="boolean");var numericRet=returnType!=="string";if(numericRet&&numericArgs&&!opts){return getCFunc(ident)}return(...args)=>ccall(ident,returnType,argTypes,args,opts)};var HEAP16;var HEAPF32;function getValue(ptr,type="i8"){if(type.endsWith("*"))type="*";switch(type){case"i1":return(growMemViews(),HEAP8)[ptr>>>0];case"i8":return(growMemViews(),HEAP8)[ptr>>>0];case"i16":return(growMemViews(),HEAP16)[ptr>>>1>>>0];case"i32":return(growMemViews(),HEAP32)[ptr>>>2>>>0];case"i64":return(growMemViews(),HEAP64)[ptr>>>3>>>0];case"float":return(growMemViews(),HEAPF32)[ptr>>>2>>>0];case"double":return(growMemViews(),HEAPF64)[ptr>>>3>>>0];case"*":return(growMemViews(),HEAPU32)[ptr>>>2>>>0];default:abort(`invalid type for getValue: ${type}`)}}PThread.init();{initMemory();if(Module["noExitRuntime"])noExitRuntime=Module["noExitRuntime"];if(Module["print"])out=Module["print"];if(Module["printErr"])err=Module["printErr"];if(Module["arguments"])programArgs=Module["arguments"];if(Module["thisProgram"])thisProgram=Module["thisProgram"];var preInit=Module["preInit"];if(preInit){if(typeof preInit=="function")Module["preInit"]=preInit=[preInit];while(preInit.length>0){preInit.shift()()}}}Module["ccall"]=ccall;Module["cwrap"]=cwrap;Module["getValue"]=getValue;Module["UTF8ToString"]=UTF8ToString;Module["stringToUTF8"]=stringToUTF8;Module["lengthBytesUTF8"]=lengthBytesUTF8;var proxiedFunctionTable=[_proc_exit,exitOnMainThread,pthreadCreateProxied,_environ_get,_environ_sizes_get];var _main,_lucivy_add,_lucivy_add_many,_lucivy_apply_sharded_delta,_lucivy_close,_lucivy_commit,_lucivy_commit_async,_lucivy_commit_finish,_lucivy_commit_status_ptr,_lucivy_compact_async,_lucivy_configure,_lucivy_create,_lucivy_destroy,_lucivy_drain_merges,_lucivy_dump_mermaid,_lucivy_dump_state,_lucivy_dump_wait_graph,_lucivy_dump_wait_graph_text,_lucivy_export_sharded_delta,_lucivy_export_snapshot,_lucivy_export_stats,_lucivy_import_file,_lucivy_import_snapshot,_lucivy_log_ring_ptr,_lucivy_log_ring_size,_lucivy_memory_status,_lucivy_merge_stats,_lucivy_num_docs,_lucivy_open,_lucivy_open_begin,_lucivy_open_finish,_lucivy_preload,_lucivy_query_warnings,_lucivy_read_logs,_lucivy_remove,_lucivy_schema_json,_lucivy_search,_lucivy_search_filtered,_lucivy_search_with_global_stats,_lucivy_shard_versions,_lucivy_test_condvar,_lucivy_test_coop,_lucivy_test_fs_task,_lucivy_update,_emscripten_builtin_free,__emscripten_tls_init,_pthread_self,_free,_malloc,_realloc,_calloc,__emscripten_proxy_main,_emscripten_builtin_malloc,___libc_free,___libc_malloc,__emscripten_thread_init,___set_thread_state,__emscripten_thread_crashed,_htonl,_htons,_emscripten_proxy_execute_queue,_ntohs,_emscripten_proxy_finish,__emscripten_run_js_on_main_thread_done,__emscripten_run_js_on_main_thread,__emscripten_thread_free_data,__emscripten_thread_exit,_strndup,__emscripten_check_mailbox,__ZdaPv,__ZdaPvm,__ZdlPv,__ZdlPvm,__Znam,__ZnamSt11align_val_t,__Znwm,__ZnwmSt11align_val_t,___libc_calloc,___libc_realloc,_emscripten_builtin_calloc,_emscripten_builtin_realloc,_malloc_size,_malloc_usable_size,_reallocf,_setThrew,__emscripten_tempret_set,_emscripten_stack_set_limits,__emscripten_stack_restore,__emscripten_stack_alloc,_emscripten_stack_get_current,___cxa_increment_exception_refcount,___cxa_can_catch,___cxa_get_exception_ptr,__wasmfs_opfs_record_entry,__indirect_function_table,wasmTable;function assignWasmExports(wasmExports){_main=Module["_main"]=wasmExports["__main_argc_argv"];_lucivy_add=Module["_lucivy_add"]=wasmExports["lucivy_add"];_lucivy_add_many=Module["_lucivy_add_many"]=wasmExports["lucivy_add_many"];_lucivy_apply_sharded_delta=Module["_lucivy_apply_sharded_delta"]=wasmExports["lucivy_apply_sharded_delta"];_lucivy_close=Module["_lucivy_close"]=wasmExports["lucivy_close"];_lucivy_commit=Module["_lucivy_commit"]=wasmExports["lucivy_commit"];_lucivy_commit_async=Module["_lucivy_commit_async"]=wasmExports["lucivy_commit_async"];_lucivy_commit_finish=Module["_lucivy_commit_finish"]=wasmExports["lucivy_commit_finish"];_lucivy_commit_status_ptr=Module["_lucivy_commit_status_ptr"]=wasmExports["lucivy_commit_status_ptr"];_lucivy_compact_async=Module["_lucivy_compact_async"]=wasmExports["lucivy_compact_async"];_lucivy_configure=Module["_lucivy_configure"]=wasmExports["lucivy_configure"];_lucivy_create=Module["_lucivy_create"]=wasmExports["lucivy_create"];_lucivy_destroy=Module["_lucivy_destroy"]=wasmExports["lucivy_destroy"];_lucivy_drain_merges=Module["_lucivy_drain_merges"]=wasmExports["lucivy_drain_merges"];_lucivy_dump_mermaid=Module["_lucivy_dump_mermaid"]=wasmExports["lucivy_dump_mermaid"];_lucivy_dump_state=Module["_lucivy_dump_state"]=wasmExports["lucivy_dump_state"];_lucivy_dump_wait_graph=Module["_lucivy_dump_wait_graph"]=wasmExports["lucivy_dump_wait_graph"];_lucivy_dump_wait_graph_text=Module["_lucivy_dump_wait_graph_text"]=wasmExports["lucivy_dump_wait_graph_text"];_lucivy_export_sharded_delta=Module["_lucivy_export_sharded_delta"]=wasmExports["lucivy_export_sharded_delta"];_lucivy_export_snapshot=Module["_lucivy_export_snapshot"]=wasmExports["lucivy_export_snapshot"];_lucivy_export_stats=Module["_lucivy_export_stats"]=wasmExports["lucivy_export_stats"];_lucivy_import_file=Module["_lucivy_import_file"]=wasmExports["lucivy_import_file"];_lucivy_import_snapshot=Module["_lucivy_import_snapshot"]=wasmExports["lucivy_import_snapshot"];_lucivy_log_ring_ptr=Module["_lucivy_log_ring_ptr"]=wasmExports["lucivy_log_ring_ptr"];_lucivy_log_ring_size=Module["_lucivy_log_ring_size"]=wasmExports["lucivy_log_ring_size"];_lucivy_memory_status=Module["_lucivy_memory_status"]=wasmExports["lucivy_memory_status"];_lucivy_merge_stats=Module["_lucivy_merge_stats"]=wasmExports["lucivy_merge_stats"];_lucivy_num_docs=Module["_lucivy_num_docs"]=wasmExports["lucivy_num_docs"];_lucivy_open=Module["_lucivy_open"]=wasmExports["lucivy_open"];_lucivy_open_begin=Module["_lucivy_open_begin"]=wasmExports["lucivy_open_begin"];_lucivy_open_finish=Module["_lucivy_open_finish"]=wasmExports["lucivy_open_finish"];_lucivy_preload=Module["_lucivy_preload"]=wasmExports["lucivy_preload"];_lucivy_query_warnings=Module["_lucivy_query_warnings"]=wasmExports["lucivy_query_warnings"];_lucivy_read_logs=Module["_lucivy_read_logs"]=wasmExports["lucivy_read_logs"];_lucivy_remove=Module["_lucivy_remove"]=wasmExports["lucivy_remove"];_lucivy_schema_json=Module["_lucivy_schema_json"]=wasmExports["lucivy_schema_json"];_lucivy_search=Module["_lucivy_search"]=wasmExports["lucivy_search"];_lucivy_search_filtered=Module["_lucivy_search_filtered"]=wasmExports["lucivy_search_filtered"];_lucivy_search_with_global_stats=Module["_lucivy_search_with_global_stats"]=wasmExports["lucivy_search_with_global_stats"];_lucivy_shard_versions=Module["_lucivy_shard_versions"]=wasmExports["lucivy_shard_versions"];_lucivy_test_condvar=Module["_lucivy_test_condvar"]=wasmExports["lucivy_test_condvar"];_lucivy_test_coop=Module["_lucivy_test_coop"]=wasmExports["lucivy_test_coop"];_lucivy_test_fs_task=Module["_lucivy_test_fs_task"]=wasmExports["lucivy_test_fs_task"];_lucivy_update=Module["_lucivy_update"]=wasmExports["lucivy_update"];_emscripten_builtin_free=Module["_emscripten_builtin_free"]=wasmExports["emscripten_builtin_free"];__emscripten_tls_init=wasmExports["_emscripten_tls_init"];_pthread_self=wasmExports["pthread_self"];_free=Module["_free"]=wasmExports["free"];_malloc=Module["_malloc"]=wasmExports["malloc"];_realloc=wasmExports["realloc"];_calloc=wasmExports["calloc"];__emscripten_proxy_main=Module["__emscripten_proxy_main"]=wasmExports["_emscripten_proxy_main"];_emscripten_builtin_malloc=Module["_emscripten_builtin_malloc"]=wasmExports["emscripten_builtin_malloc"];___libc_free=Module["___libc_free"]=wasmExports["__libc_free"];___libc_malloc=Module["___libc_malloc"]=wasmExports["__libc_malloc"];__emscripten_thread_init=wasmExports["_emscripten_thread_init"];___set_thread_state=wasmExports["__set_thread_state"];__emscripten_thread_crashed=wasmExports["_emscripten_thread_crashed"];_htonl=wasmExports["htonl"];_htons=wasmExports["htons"];_emscripten_proxy_execute_queue=wasmExports["emscripten_proxy_execute_queue"];_ntohs=wasmExports["ntohs"];_emscripten_proxy_finish=wasmExports["emscripten_proxy_finish"];__emscripten_run_js_on_main_thread_done=wasmExports["_emscripten_run_js_on_main_thread_done"];__emscripten_run_js_on_main_thread=wasmExports["_emscripten_run_js_on_main_thread"];__emscripten_thread_free_data=wasmExports["_emscripten_thread_free_data"];__emscripten_thread_exit=wasmExports["_emscripten_thread_exit"];_strndup=Module["_strndup"]=wasmExports["strndup"];__emscripten_check_mailbox=wasmExports["_emscripten_check_mailbox"];__ZdaPv=Module["__ZdaPv"]=wasmExports["_ZdaPv"];__ZdaPvm=Module["__ZdaPvm"]=wasmExports["_ZdaPvm"];__ZdlPv=Module["__ZdlPv"]=wasmExports["_ZdlPv"];__ZdlPvm=Module["__ZdlPvm"]=wasmExports["_ZdlPvm"];__Znam=Module["__Znam"]=wasmExports["_Znam"];__ZnamSt11align_val_t=Module["__ZnamSt11align_val_t"]=wasmExports["_ZnamSt11align_val_t"];__Znwm=Module["__Znwm"]=wasmExports["_Znwm"];__ZnwmSt11align_val_t=Module["__ZnwmSt11align_val_t"]=wasmExports["_ZnwmSt11align_val_t"];___libc_calloc=Module["___libc_calloc"]=wasmExports["__libc_calloc"];___libc_realloc=Module["___libc_realloc"]=wasmExports["__libc_realloc"];_emscripten_builtin_calloc=Module["_emscripten_builtin_calloc"]=wasmExports["emscripten_builtin_calloc"];_emscripten_builtin_realloc=Module["_emscripten_builtin_realloc"]=wasmExports["emscripten_builtin_realloc"];_malloc_size=Module["_malloc_size"]=wasmExports["malloc_size"];_malloc_usable_size=Module["_malloc_usable_size"]=wasmExports["malloc_usable_size"];_reallocf=Module["_reallocf"]=wasmExports["reallocf"];_setThrew=wasmExports["setThrew"];__emscripten_tempret_set=wasmExports["_emscripten_tempret_set"];_emscripten_stack_set_limits=wasmExports["emscripten_stack_set_limits"];__emscripten_stack_restore=wasmExports["_emscripten_stack_restore"];__emscripten_stack_alloc=wasmExports["_emscripten_stack_alloc"];_emscripten_stack_get_current=wasmExports["emscripten_stack_get_current"];___cxa_increment_exception_refcount=wasmExports["__cxa_increment_exception_refcount"];___cxa_can_catch=wasmExports["__cxa_can_catch"];___cxa_get_exception_ptr=wasmExports["__cxa_get_exception_ptr"];__wasmfs_opfs_record_entry=wasmExports["_wasmfs_opfs_record_entry"];__indirect_function_table=wasmTable=wasmExports["__indirect_function_table"]}var wasmImports;function assignWasmImports(){wasmImports={__call_sighandler:___call_sighandler,__cxa_begin_catch:___cxa_begin_catch,__cxa_find_matching_catch_2:___cxa_find_matching_catch_2,__cxa_find_matching_catch_3:___cxa_find_matching_catch_3,__cxa_throw:___cxa_throw,__pthread_create_js:___pthread_create_js,__resumeException:___resumeException,_abort_js:__abort_js,_emscripten_init_main_thread_js:__emscripten_init_main_thread_js,_emscripten_notify_mailbox_postmessage:__emscripten_notify_mailbox_postmessage,_emscripten_receive_on_main_thread_js:__emscripten_receive_on_main_thread_js,_emscripten_runtime_keepalive_clear:__emscripten_runtime_keepalive_clear,_emscripten_thread_cleanup:__emscripten_thread_cleanup,_emscripten_thread_mailbox_await:__emscripten_thread_mailbox_await,_emscripten_thread_set_strongref:__emscripten_thread_set_strongref,_wasmfs_copy_preloaded_file_data:__wasmfs_copy_preloaded_file_data,_wasmfs_get_num_preloaded_dirs:__wasmfs_get_num_preloaded_dirs,_wasmfs_get_num_preloaded_files:__wasmfs_get_num_preloaded_files,_wasmfs_get_preloaded_child_path:__wasmfs_get_preloaded_child_path,_wasmfs_get_preloaded_file_mode:__wasmfs_get_preloaded_file_mode,_wasmfs_get_preloaded_file_size:__wasmfs_get_preloaded_file_size,_wasmfs_get_preloaded_parent_path:__wasmfs_get_preloaded_parent_path,_wasmfs_get_preloaded_path_name:__wasmfs_get_preloaded_path_name,_wasmfs_opfs_close_access:__wasmfs_opfs_close_access,_wasmfs_opfs_close_blob:__wasmfs_opfs_close_blob,_wasmfs_opfs_flush_access:__wasmfs_opfs_flush_access,_wasmfs_opfs_free_directory:__wasmfs_opfs_free_directory,_wasmfs_opfs_free_file:__wasmfs_opfs_free_file,_wasmfs_opfs_get_child:__wasmfs_opfs_get_child,_wasmfs_opfs_get_entries:__wasmfs_opfs_get_entries,_wasmfs_opfs_get_size_access:__wasmfs_opfs_get_size_access,_wasmfs_opfs_get_size_blob:__wasmfs_opfs_get_size_blob,_wasmfs_opfs_get_size_file:__wasmfs_opfs_get_size_file,_wasmfs_opfs_init_root_directory:__wasmfs_opfs_init_root_directory,_wasmfs_opfs_insert_directory:__wasmfs_opfs_insert_directory,_wasmfs_opfs_insert_file:__wasmfs_opfs_insert_file,_wasmfs_opfs_move_file:__wasmfs_opfs_move_file,_wasmfs_opfs_open_access:__wasmfs_opfs_open_access,_wasmfs_opfs_open_blob:__wasmfs_opfs_open_blob,_wasmfs_opfs_read_access:__wasmfs_opfs_read_access,_wasmfs_opfs_read_blob:__wasmfs_opfs_read_blob,_wasmfs_opfs_remove_child:__wasmfs_opfs_remove_child,_wasmfs_opfs_set_size_access:__wasmfs_opfs_set_size_access,_wasmfs_opfs_set_size_file:__wasmfs_opfs_set_size_file,_wasmfs_opfs_write_access:__wasmfs_opfs_write_access,_wasmfs_stdin_get_char:__wasmfs_stdin_get_char,_wasmfs_thread_utils_heartbeat:__wasmfs_thread_utils_heartbeat,clock_time_get:_clock_time_get,emscripten_check_blocking_allowed:_emscripten_check_blocking_allowed,emscripten_date_now:_emscripten_date_now,emscripten_err:_emscripten_err,emscripten_exit_with_live_runtime:_emscripten_exit_with_live_runtime,emscripten_get_callstack:_emscripten_get_callstack,emscripten_get_heap_max:_emscripten_get_heap_max,emscripten_get_now:_emscripten_get_now,emscripten_num_logical_cores:_emscripten_num_logical_cores,emscripten_out:_emscripten_out,emscripten_resize_heap:_emscripten_resize_heap,emscripten_runtime_keepalive_check:_emscripten_runtime_keepalive_check,emscripten_unwind_to_js_event_loop:_emscripten_unwind_to_js_event_loop,environ_get:_environ_get,environ_sizes_get:_environ_sizes_get,exit:_exit,invoke_ii,invoke_iii,invoke_iiii,invoke_v,invoke_vi,invoke_vii,invoke_viii,memory:wasmMemory,proc_exit:_proc_exit,random_get:_random_get}}function invoke_viii(index,a1,a2,a3){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3)}catch(e){stackRestore(sp);if(!(e instanceof EmscriptenEH))throw e;_setThrew(1,0)}}function invoke_iii(index,a1,a2){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2)}catch(e){stackRestore(sp);if(!(e instanceof EmscriptenEH))throw e;_setThrew(1,0)}}function invoke_vii(index,a1,a2){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2)}catch(e){stackRestore(sp);if(!(e instanceof EmscriptenEH))throw e;_setThrew(1,0)}}function invoke_ii(index,a1){var sp=stackSave();try{return getWasmTableEntry(index)(a1)}catch(e){stackRestore(sp);if(!(e instanceof EmscriptenEH))throw e;_setThrew(1,0)}}function invoke_v(index){var sp=stackSave();try{getWasmTableEntry(index)()}catch(e){stackRestore(sp);if(!(e instanceof EmscriptenEH))throw e;_setThrew(1,0)}}function invoke_vi(index,a1){var sp=stackSave();try{getWasmTableEntry(index)(a1)}catch(e){stackRestore(sp);if(!(e instanceof EmscriptenEH))throw e;_setThrew(1,0)}}function invoke_iiii(index,a1,a2,a3){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3)}catch(e){stackRestore(sp);if(!(e instanceof EmscriptenEH))throw e;_setThrew(1,0)}}function applySignatureConversions(wasmExports){wasmExports=Object.assign({},wasmExports);var makeWrapper_p=f=>()=>f()>>>0;var makeWrapper_pp=f=>a0=>f(a0)>>>0;var makeWrapper_ppp=f=>(a0,a1)=>f(a0,a1)>>>0;wasmExports["_emscripten_tls_init"]=makeWrapper_p(wasmExports["_emscripten_tls_init"]);wasmExports["pthread_self"]=makeWrapper_p(wasmExports["pthread_self"]);wasmExports["malloc"]=makeWrapper_pp(wasmExports["malloc"]);wasmExports["realloc"]=makeWrapper_ppp(wasmExports["realloc"]);wasmExports["calloc"]=makeWrapper_ppp(wasmExports["calloc"]);wasmExports["emscripten_builtin_malloc"]=makeWrapper_pp(wasmExports["emscripten_builtin_malloc"]);wasmExports["__libc_malloc"]=makeWrapper_pp(wasmExports["__libc_malloc"]);wasmExports["strndup"]=makeWrapper_ppp(wasmExports["strndup"]);wasmExports["__libc_calloc"]=makeWrapper_ppp(wasmExports["__libc_calloc"]);wasmExports["__libc_realloc"]=makeWrapper_ppp(wasmExports["__libc_realloc"]);wasmExports["emscripten_builtin_calloc"]=makeWrapper_ppp(wasmExports["emscripten_builtin_calloc"]);wasmExports["emscripten_builtin_realloc"]=makeWrapper_ppp(wasmExports["emscripten_builtin_realloc"]);wasmExports["malloc_usable_size"]=makeWrapper_pp(wasmExports["malloc_usable_size"]);wasmExports["_emscripten_stack_alloc"]=makeWrapper_pp(wasmExports["_emscripten_stack_alloc"]);wasmExports["emscripten_stack_get_current"]=makeWrapper_p(wasmExports["emscripten_stack_get_current"]);wasmExports["__cxa_get_exception_ptr"]=makeWrapper_pp(wasmExports["__cxa_get_exception_ptr"]);return wasmExports}function callMain(args=[]){var entryFunction=__emscripten_proxy_main;runtimeKeepalivePush();args.unshift(thisProgram);var argc=args.length;var argv=stackAlloc((argc+1)*4);var argv_ptr=argv;for(var arg of args){(growMemViews(),HEAPU32)[argv_ptr>>>2>>>0]=stringToUTF8OnStack(arg);argv_ptr+=4}(growMemViews(),HEAPU32)[argv_ptr>>>2>>>0]=0;try{var ret=entryFunction(argc,argv);exitJS(ret,true);return ret}catch(e){return handleException(e)}}async function run(args=programArgs){if(ENVIRONMENT_IS_PTHREAD){initRuntime();return}preRun();if(runDependencies){await resolveRunDependencies()}var setStatus=Module["setStatus"];if(setStatus){setStatus("Running...");await new Promise(resolve=>setTimeout(resolve,1));setTimeout(setStatus,1,"")}if(ABORT)return;initRuntime();Module["onRuntimeInitialized"]?.();var noInitialRun=Module["noInitialRun"]||false;if(!noInitialRun)callMain(args);postRun()}var wasmExports;if(!ENVIRONMENT_IS_PTHREAD){wasmExports=await createWasm();await run()}
|
|
2
|
+
;return Module}export default createLucivy;var isPthread=globalThis.name=="em-pthread";var isNode=globalThis.process?.versions?.node&&globalThis.process?.type!="renderer";if(isNode)isPthread=(await import("node:worker_threads")).workerData==="em-pthread";isPthread&&createLucivy();
|
package/pkg/lucivy.wasm
CHANGED
|
Binary file
|