@cortexkit/pi-magic-context 0.44.4 → 0.46.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/embedding-worker.js +47 -0
- package/dist/emscripten-module-0g8f45e6.js +602 -0
- package/dist/emscripten-module-0pekdjxz.js +1532 -0
- package/dist/emscripten-module-e67xwsp3.js +503 -0
- package/dist/emscripten-module-pj1vyb44.js +4559 -0
- package/dist/ffi-3cx1cxpk.js +78 -0
- package/dist/ffi-7bqqe4cd.js +91 -0
- package/dist/ffi-7e6gryj5.js +91 -0
- package/dist/ffi-bpvkebwr.js +78 -0
- package/dist/historian-calibration-extension.js +7 -4
- package/dist/index-266qrgss.js +417 -0
- package/dist/index-2p1e8706.js +30 -0
- package/dist/index-4vfrjwf6.js +7737 -0
- package/dist/{index-59dmj4zs.js → index-7n8gb6j3.js} +165 -3
- package/dist/index-901ekbga.js +244 -0
- package/dist/{module-asyncify-2EFITU5U-rkqjhjxd.js → index-g20jdh0p.js} +114 -105
- package/dist/{index-5fw91enm.js → index-n3g5mwa8.js} +1 -1
- package/dist/index-phh7e055.js +290 -0
- package/dist/index-q1yc6bs0.js +104 -0
- package/dist/index-sg8zbjs0.js +8937 -0
- package/dist/index-td885aah.js +576 -0
- package/dist/index-vf38qhee.js +150 -0
- package/dist/{index-5am7amy4.js → index-vhzmjpsk.js} +10220 -25155
- package/dist/{index-n8kg008j.js → index-w76x3af7.js} +28 -18
- package/dist/index-wv28nczk.js +464 -0
- package/dist/{index-npagr1cy.js → index-xvw8zptx.js} +4021 -3973
- package/dist/index.js +6942 -2942
- package/dist/{message-time-backfill-5yrp95cx.js → message-time-backfill-4688z1k2.js} +19 -4
- package/dist/migration-worker.js +56 -0
- package/dist/module-ES6BEMUI-3cet1pyp.js +12 -0
- package/dist/module-asyncify-2EFITU5U-c2razzd9.js +6 -0
- package/dist/{read-session-chunk-w493f72c.js → read-session-chunk-tc6yn2pe.js} +32 -5
- package/dist/rpc-notifications-gm1mdpwh.js +16 -0
- package/dist/{safe-notification-target-y3hg2m7p.js → safe-notification-target-6cn3z99t.js} +2 -2
- package/dist/subagent-entry.js +15 -6
- package/package.json +7 -6
- package/dist/index-97e5fzy3.js +0 -16
- package/dist/index-b3eqj1g6.js +0 -51
- package/dist/index-rn7gafjr.js +0 -8
- package/dist/index-v6t0tg85.js +0 -13
- package/dist/rpc-notifications-jxy30tgz.js +0 -8
|
@@ -163,8 +163,10 @@ var SECRET_QUALIFIERS = new Set([
|
|
|
163
163
|
"github",
|
|
164
164
|
"huggingface",
|
|
165
165
|
"aws",
|
|
166
|
-
"azure"
|
|
166
|
+
"azure",
|
|
167
|
+
"id"
|
|
167
168
|
]);
|
|
169
|
+
var UNQUALIFIED_SECRET_SEGMENT_PATTERN = /^(?:password|secret|credential|bearer|authorization)s?$/;
|
|
168
170
|
function isSecretKey(key) {
|
|
169
171
|
const segments = key.replace(/([a-z0-9])([A-Z])/g, "$1_$2").toLowerCase().split(/[._-]+/).filter(Boolean);
|
|
170
172
|
if (segments.length === 0)
|
|
@@ -191,6 +193,8 @@ function isSecretKey(key) {
|
|
|
191
193
|
}
|
|
192
194
|
if (!trailingOk)
|
|
193
195
|
continue;
|
|
196
|
+
if (UNQUALIFIED_SECRET_SEGMENT_PATTERN.test(seg))
|
|
197
|
+
return true;
|
|
194
198
|
for (let k = i - 1;k >= 0; k--) {
|
|
195
199
|
const lead = segments[k];
|
|
196
200
|
if (lead && SECRET_QUALIFIERS.has(lead))
|
|
@@ -251,6 +255,18 @@ var SECRET_TEXT_PATTERNS = [
|
|
|
251
255
|
pattern: /\b(Authorization\s*:\s*Bearer\s+)([A-Za-z0-9._~+/=-]{8,})/gi,
|
|
252
256
|
replacement: (_full, prefix) => `${prefix}<REDACTED:bearer>`
|
|
253
257
|
},
|
|
258
|
+
{
|
|
259
|
+
pattern: /\b((?:Proxy-)?Authorization\s*:\s*(?:Basic|Digest|Token|Negotiate|NTLM)\s+)([A-Za-z0-9._~+/=-]{4,})/gi,
|
|
260
|
+
replacement: (_full, prefix) => `${prefix}<REDACTED:authorization>`
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
pattern: /\b((?:x-)?(?:api-?key|api-?token|auth-?token|access-?token)\s*:\s*)([^\s'"`,;<>]{6,})/gi,
|
|
264
|
+
replacement: (full, prefix, value) => isNonSecretScalarValue(value) ? full : `${prefix}<REDACTED:api_key>`
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
pattern: /\b([a-z][a-z0-9+.-]*:\/\/[^\s/:@]+:)([^\s/@]+)(@)/gi,
|
|
268
|
+
replacement: (_full, prefix, _password, at) => `${prefix}<REDACTED:password>${at}`
|
|
269
|
+
},
|
|
254
270
|
{
|
|
255
271
|
pattern: /\beyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g,
|
|
256
272
|
replacement: "<JWT_REDACTED>"
|
|
@@ -317,6 +333,122 @@ function sanitizeConfigValue(value, keyPath = []) {
|
|
|
317
333
|
return value;
|
|
318
334
|
}
|
|
319
335
|
|
|
336
|
+
// ../plugin/src/shared/stale-plugin-build.ts
|
|
337
|
+
import { posix } from "node:path";
|
|
338
|
+
import { fileURLToPath } from "node:url";
|
|
339
|
+
var STATE = Symbol.for("magic-context.stale-plugin-build");
|
|
340
|
+
function state() {
|
|
341
|
+
const globals = globalThis;
|
|
342
|
+
return globals[STATE] ??= {
|
|
343
|
+
hosts: new Map,
|
|
344
|
+
loggedChunks: new Set,
|
|
345
|
+
notified: false
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
function absolutePath(value) {
|
|
349
|
+
let path = value;
|
|
350
|
+
if (path.startsWith("file:")) {
|
|
351
|
+
try {
|
|
352
|
+
path = fileURLToPath(path);
|
|
353
|
+
} catch {
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
path = path.replaceAll("\\", "/").replace(/^\/(?=[A-Za-z]:\/)/, "");
|
|
358
|
+
if (!path.startsWith("/") && !/^[A-Za-z]:\//.test(path))
|
|
359
|
+
return;
|
|
360
|
+
path = posix.normalize(path);
|
|
361
|
+
return /^[A-Za-z]:\//.test(path) ? path.toLowerCase() : path;
|
|
362
|
+
}
|
|
363
|
+
function distForModule(moduleUrl) {
|
|
364
|
+
const path = absolutePath(moduleUrl);
|
|
365
|
+
if (!path)
|
|
366
|
+
return;
|
|
367
|
+
const dist = path.lastIndexOf("/dist/");
|
|
368
|
+
return dist < 0 ? undefined : path.slice(0, dist + "/dist".length);
|
|
369
|
+
}
|
|
370
|
+
function stalePluginBuildGuidance(harness) {
|
|
371
|
+
return harness === "pi" || harness === "omp" ? "Magic Context was rebuilt while this Pi was running; type /reload to load the new build" : "Magic Context was rebuilt while this OpenCode host was running; restart the host to load the new build";
|
|
372
|
+
}
|
|
373
|
+
function deliverNotice(host) {
|
|
374
|
+
const current = state();
|
|
375
|
+
if (current.notified || !current.pendingNotice || !host.notify)
|
|
376
|
+
return;
|
|
377
|
+
current.notified = true;
|
|
378
|
+
try {
|
|
379
|
+
Promise.resolve(host.notify(current.pendingNotice)).catch(() => {});
|
|
380
|
+
} catch {}
|
|
381
|
+
}
|
|
382
|
+
function registerStalePluginBuildHost(options) {
|
|
383
|
+
const dist = distForModule(options.moduleUrl);
|
|
384
|
+
if (!dist)
|
|
385
|
+
return;
|
|
386
|
+
const host = { ...options, dist };
|
|
387
|
+
state().hosts.set(dist, host);
|
|
388
|
+
deliverNotice(host);
|
|
389
|
+
}
|
|
390
|
+
function classifyStalePluginBuild(error) {
|
|
391
|
+
if (error instanceof StalePluginBuildError)
|
|
392
|
+
return error.build;
|
|
393
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
394
|
+
const missing = message.match(/(?:Cannot find module|ENOENT reading)\s+(['"])(.*?)\1/);
|
|
395
|
+
if (!missing)
|
|
396
|
+
return null;
|
|
397
|
+
let chunk = absolutePath(missing[2]);
|
|
398
|
+
if (!chunk && /^\.\.?[/\\]/.test(missing[2])) {
|
|
399
|
+
const importer = message.slice((missing.index ?? 0) + missing[0].length).match(/(?:imported from|from)\s+(?:['"]([^'"]+)['"]|([^\n]+))/);
|
|
400
|
+
const from = importer && absolutePath((importer[1] ?? importer[2]).trim());
|
|
401
|
+
if (from)
|
|
402
|
+
chunk = absolutePath(posix.join(posix.dirname(from), missing[2].replaceAll("\\", "/")));
|
|
403
|
+
}
|
|
404
|
+
if (!chunk)
|
|
405
|
+
return null;
|
|
406
|
+
for (const host of state().hosts.values()) {
|
|
407
|
+
if (chunk.startsWith(`${host.dist}/`)) {
|
|
408
|
+
return { chunk, guidance: stalePluginBuildGuidance(host.harness) };
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
const ownDist = distForModule(import.meta.url);
|
|
412
|
+
return ownDist && chunk.startsWith(`${ownDist}/`) ? { chunk, guidance: stalePluginBuildGuidance(getHarness()) } : null;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
class StalePluginBuildError extends Error {
|
|
416
|
+
build;
|
|
417
|
+
constructor(build) {
|
|
418
|
+
super(build.guidance);
|
|
419
|
+
this.build = build;
|
|
420
|
+
this.name = "StalePluginBuildError";
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
function stalePluginBuildDiagnostic(error) {
|
|
424
|
+
const pending = state().pendingNotice;
|
|
425
|
+
const message = error instanceof Error ? error.message : typeof error === "string" ? error : "";
|
|
426
|
+
if (pending && message.includes(pending))
|
|
427
|
+
return null;
|
|
428
|
+
const build = classifyStalePluginBuild(error);
|
|
429
|
+
if (!build)
|
|
430
|
+
return;
|
|
431
|
+
const current = state();
|
|
432
|
+
current.pendingNotice ??= build.guidance;
|
|
433
|
+
for (const host of current.hosts.values())
|
|
434
|
+
deliverNotice(host);
|
|
435
|
+
if (current.loggedChunks.has(build.chunk))
|
|
436
|
+
return null;
|
|
437
|
+
current.loggedChunks.add(build.chunk);
|
|
438
|
+
return `[magic-context] stale plugin build: missing ${build.chunk.replace(/[\r\n]/g, " ")}; ${build.guidance}`;
|
|
439
|
+
}
|
|
440
|
+
async function importPluginModule(load) {
|
|
441
|
+
try {
|
|
442
|
+
return await load();
|
|
443
|
+
} catch (error) {
|
|
444
|
+
const build = classifyStalePluginBuild(error);
|
|
445
|
+
if (!build)
|
|
446
|
+
throw error;
|
|
447
|
+
log("[magic-context] lazy import failed", error);
|
|
448
|
+
throw new StalePluginBuildError(build);
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
|
|
320
452
|
// ../plugin/src/shared/logger.ts
|
|
321
453
|
var isTestEnv = false;
|
|
322
454
|
var buffer = [];
|
|
@@ -459,15 +591,45 @@ function scheduleFlush() {
|
|
|
459
591
|
flush();
|
|
460
592
|
}, FLUSH_INTERVAL_MS);
|
|
461
593
|
}
|
|
462
|
-
|
|
594
|
+
var lineForwarder = null;
|
|
595
|
+
function setLogLineForwarder(forward) {
|
|
596
|
+
lineForwarder = forward;
|
|
597
|
+
}
|
|
598
|
+
function writeForwardedLogLine(line) {
|
|
463
599
|
if (isTestEnv)
|
|
464
600
|
return;
|
|
465
601
|
try {
|
|
602
|
+
buffer.push(line);
|
|
603
|
+
bufferedBytes += Buffer.byteLength(line);
|
|
604
|
+
boundBuffer();
|
|
605
|
+
if (buffer.length >= BUFFER_SIZE_LIMIT)
|
|
606
|
+
flush();
|
|
607
|
+
else
|
|
608
|
+
scheduleFlush();
|
|
609
|
+
} catch {}
|
|
610
|
+
}
|
|
611
|
+
function log(message, data) {
|
|
612
|
+
try {
|
|
613
|
+
let diagnostic = stalePluginBuildDiagnostic(data);
|
|
614
|
+
if (diagnostic === undefined)
|
|
615
|
+
diagnostic = stalePluginBuildDiagnostic(message);
|
|
616
|
+
if (diagnostic === null)
|
|
617
|
+
return;
|
|
618
|
+
if (diagnostic !== undefined) {
|
|
619
|
+
message = diagnostic;
|
|
620
|
+
data = undefined;
|
|
621
|
+
}
|
|
622
|
+
if (isTestEnv)
|
|
623
|
+
return;
|
|
466
624
|
const timestamp = new Date().toISOString();
|
|
467
625
|
const serialized = data === undefined ? "" : data instanceof Error ? ` ${sanitizeDiagnosticText(`${data.message}${data.stack ? `
|
|
468
626
|
${data.stack}` : ""}`)}` : ` ${JSON.stringify(sanitizeConfigValue(data))}`;
|
|
469
627
|
const line = `[${timestamp}] ${sanitizeDiagnosticText(message)}${serialized}
|
|
470
628
|
`;
|
|
629
|
+
if (lineForwarder) {
|
|
630
|
+
lineForwarder(line);
|
|
631
|
+
return;
|
|
632
|
+
}
|
|
471
633
|
buffer.push(line);
|
|
472
634
|
bufferedBytes += Buffer.byteLength(line);
|
|
473
635
|
boundBuffer();
|
|
@@ -488,4 +650,4 @@ if (!isTestEnv) {
|
|
|
488
650
|
process.on("exit", flush);
|
|
489
651
|
}
|
|
490
652
|
|
|
491
|
-
export { setHarness, getHarness, harnessOwnsOpenCodeStore, getDataDir, ensureCortexKitArtifactGitignore, getProjectMagicContextHistorianDir, getMagicContextStorageDir, getLegacyOpenCodeMagicContextStorageDir, sanitizeDiagnosticText, hasShareabilitySensitiveText, log, sessionLog, flushLogger };
|
|
653
|
+
export { setHarness, getHarness, harnessOwnsOpenCodeStore, getDataDir, ensureCortexKitArtifactGitignore, getProjectMagicContextHistorianDir, getMagicContextStorageDir, getLegacyOpenCodeMagicContextStorageDir, sanitizeDiagnosticText, hasShareabilitySensitiveText, registerStalePluginBuildHost, classifyStalePluginBuild, importPluginModule, setLogLineForwarder, writeForwardedLogLine, log, sessionLog, flushLogger };
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import {
|
|
2
|
+
assertSync2,
|
|
3
|
+
EvalFlags2,
|
|
4
|
+
IntrinsicsFlags2,
|
|
5
|
+
JSPromiseStateEnum2,
|
|
6
|
+
GetOwnPropertyNamesFlags2,
|
|
7
|
+
IsEqualOp2,
|
|
8
|
+
setDebugMode2,
|
|
9
|
+
debugLog2,
|
|
10
|
+
errors_exports,
|
|
11
|
+
QuickJSMemoryLeakDetected,
|
|
12
|
+
QuickJSEmscriptenModuleError,
|
|
13
|
+
UsingDisposable2,
|
|
14
|
+
Lifetime2,
|
|
15
|
+
StaticLifetime2,
|
|
16
|
+
WeakLifetime2,
|
|
17
|
+
Scope2,
|
|
18
|
+
createDisposableArray2,
|
|
19
|
+
DisposableSuccess2,
|
|
20
|
+
DisposableFail2,
|
|
21
|
+
DisposableResult2,
|
|
22
|
+
QuickJSDeferredPromise2,
|
|
23
|
+
DefaultIntrinsics2,
|
|
24
|
+
QuickJSContext2,
|
|
25
|
+
QuickJSRuntime2,
|
|
26
|
+
QuickJSWASMModule2,
|
|
27
|
+
QuickJSAsyncContext2,
|
|
28
|
+
QuickJSAsyncRuntime2,
|
|
29
|
+
QuickJSAsyncWASMModule2
|
|
30
|
+
} from "./index-g20jdh0p.js";
|
|
31
|
+
|
|
32
|
+
// ../../node_modules/.bun/quickjs-emscripten-core@0.32.0/node_modules/quickjs-emscripten-core/dist/index.mjs
|
|
33
|
+
async function newQuickJSWASMModuleFromVariant(variantOrPromise) {
|
|
34
|
+
let variant = smartUnwrap(await variantOrPromise), [wasmModuleLoader, QuickJSFFI, { QuickJSWASMModule: QuickJSWASMModule2 }] = await Promise.all([variant.importModuleLoader().then(smartUnwrap), variant.importFFI(), import("./module-ES6BEMUI-3cet1pyp.js").then(smartUnwrap)]), wasmModule = await wasmModuleLoader();
|
|
35
|
+
wasmModule.type = "sync";
|
|
36
|
+
let ffi = new QuickJSFFI(wasmModule);
|
|
37
|
+
return new QuickJSWASMModule2(wasmModule, ffi);
|
|
38
|
+
}
|
|
39
|
+
async function newQuickJSAsyncWASMModuleFromVariant(variantOrPromise) {
|
|
40
|
+
let variant = smartUnwrap(await variantOrPromise), [wasmModuleLoader, QuickJSAsyncFFI, { QuickJSAsyncWASMModule: QuickJSAsyncWASMModule2 }] = await Promise.all([variant.importModuleLoader().then(smartUnwrap), variant.importFFI(), import("./module-asyncify-2EFITU5U-c2razzd9.js").then(smartUnwrap)]), wasmModule = await wasmModuleLoader();
|
|
41
|
+
wasmModule.type = "async";
|
|
42
|
+
let ffi = new QuickJSAsyncFFI(wasmModule);
|
|
43
|
+
return new QuickJSAsyncWASMModule2(wasmModule, ffi);
|
|
44
|
+
}
|
|
45
|
+
function memoizePromiseFactory(fn) {
|
|
46
|
+
let promise;
|
|
47
|
+
return () => promise ?? (promise = fn());
|
|
48
|
+
}
|
|
49
|
+
function smartUnwrap(val) {
|
|
50
|
+
return val && "default" in val && val.default ? val.default && "default" in val.default && val.default.default ? val.default.default : val.default : val;
|
|
51
|
+
}
|
|
52
|
+
function newVariant(baseVariant, options) {
|
|
53
|
+
return { ...baseVariant, async importModuleLoader() {
|
|
54
|
+
let moduleLoader = smartUnwrap(await baseVariant.importModuleLoader());
|
|
55
|
+
return async function() {
|
|
56
|
+
let moduleLoaderArg = options.emscriptenModule ? { ...options.emscriptenModule } : {}, log = options.log ?? ((...args) => debugLog2("newVariant moduleLoader:", ...args)), tapValue = (message, val) => (log(...message, val), val), force = (val) => typeof val == "function" ? val() : val;
|
|
57
|
+
(options.wasmLocation || options.wasmSourceMapLocation || options.locateFile) && (moduleLoaderArg.locateFile = (fileName, relativeTo) => {
|
|
58
|
+
let args = { fileName, relativeTo };
|
|
59
|
+
if (fileName.endsWith(".wasm") && options.wasmLocation !== undefined)
|
|
60
|
+
return tapValue(["locateFile .wasm: provide wasmLocation", args], options.wasmLocation);
|
|
61
|
+
if (fileName.endsWith(".map")) {
|
|
62
|
+
if (options.wasmSourceMapLocation !== undefined)
|
|
63
|
+
return tapValue(["locateFile .map: provide wasmSourceMapLocation", args], options.wasmSourceMapLocation);
|
|
64
|
+
if (options.wasmLocation && !options.locateFile)
|
|
65
|
+
return tapValue(["locateFile .map: infer from wasmLocation", args], options.wasmLocation + ".map");
|
|
66
|
+
}
|
|
67
|
+
return options.locateFile ? tapValue(["locateFile: use provided fn", args], options.locateFile(fileName, relativeTo)) : tapValue(["locateFile: unhandled, passthrough", args], fileName);
|
|
68
|
+
}), options.wasmBinary && (moduleLoaderArg.wasmBinary = await force(options.wasmBinary)), options.wasmMemory && (moduleLoaderArg.wasmMemory = await force(options.wasmMemory));
|
|
69
|
+
let optionsWasmModule = options.wasmModule, modulePromise;
|
|
70
|
+
optionsWasmModule && (moduleLoaderArg.instantiateWasm = async (imports, onSuccess) => {
|
|
71
|
+
modulePromise ?? (modulePromise = Promise.resolve(force(optionsWasmModule)));
|
|
72
|
+
let wasmModule = await modulePromise;
|
|
73
|
+
if (!wasmModule)
|
|
74
|
+
throw new QuickJSEmscriptenModuleError(`options.wasmModule returned ${String(wasmModule)}`);
|
|
75
|
+
let instance = await WebAssembly.instantiate(wasmModule, imports);
|
|
76
|
+
return onSuccess(instance), instance.exports;
|
|
77
|
+
}), moduleLoaderArg.monitorRunDependencies = (left) => {
|
|
78
|
+
log("monitorRunDependencies:", left);
|
|
79
|
+
}, moduleLoaderArg.quickjsEmscriptenInit = () => newMockExtensions(log);
|
|
80
|
+
let resultPromise = moduleLoader(moduleLoaderArg), extensions = moduleLoaderArg.quickjsEmscriptenInit?.(log);
|
|
81
|
+
if (optionsWasmModule && extensions?.receiveWasmOffsetConverter && !extensions.existingWasmOffsetConverter) {
|
|
82
|
+
let wasmBinary = await force(options.wasmBinary) ?? new ArrayBuffer(0);
|
|
83
|
+
modulePromise ?? (modulePromise = Promise.resolve(force(optionsWasmModule)));
|
|
84
|
+
let wasmModule = await modulePromise;
|
|
85
|
+
if (!wasmModule)
|
|
86
|
+
throw new QuickJSEmscriptenModuleError(`options.wasmModule returned ${String(wasmModule)}`);
|
|
87
|
+
extensions.receiveWasmOffsetConverter(wasmBinary, wasmModule);
|
|
88
|
+
}
|
|
89
|
+
if (extensions?.receiveSourceMapJSON) {
|
|
90
|
+
let loadedSourceMapData = await force(options.wasmSourceMapData);
|
|
91
|
+
typeof loadedSourceMapData == "string" ? extensions.receiveSourceMapJSON(JSON.parse(loadedSourceMapData)) : loadedSourceMapData ? extensions.receiveSourceMapJSON(loadedSourceMapData) : extensions.receiveSourceMapJSON({ version: 3, names: [], sources: [], mappings: "" });
|
|
92
|
+
}
|
|
93
|
+
return resultPromise;
|
|
94
|
+
};
|
|
95
|
+
} };
|
|
96
|
+
}
|
|
97
|
+
function newMockExtensions(log) {
|
|
98
|
+
let mockMessage = "mock called, emscripten module may not be initialized yet";
|
|
99
|
+
return { mock: true, removeRunDependency(name) {
|
|
100
|
+
log(`${mockMessage}: removeRunDependency called:`, name);
|
|
101
|
+
}, receiveSourceMapJSON(data) {
|
|
102
|
+
log(`${mockMessage}: receiveSourceMapJSON called:`, data);
|
|
103
|
+
}, WasmOffsetConverter: undefined, receiveWasmOffsetConverter(bytes, mod) {
|
|
104
|
+
log(`${mockMessage}: receiveWasmOffsetConverter called:`, bytes, mod);
|
|
105
|
+
} };
|
|
106
|
+
}
|
|
107
|
+
function isSuccess(successOrFail) {
|
|
108
|
+
return !("error" in successOrFail);
|
|
109
|
+
}
|
|
110
|
+
function isFail(successOrFail) {
|
|
111
|
+
return "error" in successOrFail;
|
|
112
|
+
}
|
|
113
|
+
function shouldInterruptAfterDeadline(deadline) {
|
|
114
|
+
let deadlineAsNumber = typeof deadline == "number" ? deadline : deadline.getTime();
|
|
115
|
+
return function() {
|
|
116
|
+
return Date.now() > deadlineAsNumber;
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
var TestQuickJSWASMModule = class {
|
|
120
|
+
constructor(parent) {
|
|
121
|
+
this.parent = parent;
|
|
122
|
+
this.contexts = new Set;
|
|
123
|
+
this.runtimes = new Set;
|
|
124
|
+
}
|
|
125
|
+
newRuntime(options) {
|
|
126
|
+
let runtime = this.parent.newRuntime({ ...options, ownedLifetimes: [new Lifetime2(undefined, undefined, () => this.runtimes.delete(runtime)), ...options?.ownedLifetimes ?? []] });
|
|
127
|
+
return this.runtimes.add(runtime), runtime;
|
|
128
|
+
}
|
|
129
|
+
newContext(options) {
|
|
130
|
+
let context = this.parent.newContext({ ...options, ownedLifetimes: [new Lifetime2(undefined, undefined, () => this.contexts.delete(context)), ...options?.ownedLifetimes ?? []] });
|
|
131
|
+
return this.contexts.add(context), context;
|
|
132
|
+
}
|
|
133
|
+
evalCode(code, options) {
|
|
134
|
+
return this.parent.evalCode(code, options);
|
|
135
|
+
}
|
|
136
|
+
disposeAll() {
|
|
137
|
+
let allDisposables = [...this.contexts, ...this.runtimes];
|
|
138
|
+
this.runtimes.clear(), this.contexts.clear(), allDisposables.forEach((d) => {
|
|
139
|
+
d.alive && d.dispose();
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
assertNoMemoryAllocated() {
|
|
143
|
+
if (this.getFFI().QTS_RecoverableLeakCheck())
|
|
144
|
+
throw new QuickJSMemoryLeakDetected("Leak sanitizer detected un-freed memory");
|
|
145
|
+
if (this.contexts.size > 0)
|
|
146
|
+
throw new QuickJSMemoryLeakDetected(`${this.contexts.size} contexts leaked`);
|
|
147
|
+
if (this.runtimes.size > 0)
|
|
148
|
+
throw new QuickJSMemoryLeakDetected(`${this.runtimes.size} runtimes leaked`);
|
|
149
|
+
}
|
|
150
|
+
getWasmMemory() {
|
|
151
|
+
return this.parent.getWasmMemory();
|
|
152
|
+
}
|
|
153
|
+
getFFI() {
|
|
154
|
+
return this.parent.getFFI();
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
// ../../node_modules/.bun/@jitl+quickjs-wasmfile-debug-sync@0.32.0/node_modules/@jitl/quickjs-wasmfile-debug-sync/dist/index.mjs
|
|
159
|
+
var variant = { type: "sync", importFFI: () => import("./ffi-bpvkebwr.js").then((mod) => mod.QuickJSFFI), importModuleLoader: () => import("./emscripten-module-pj1vyb44.js").then((mod) => mod.default) };
|
|
160
|
+
var src_default = variant;
|
|
161
|
+
|
|
162
|
+
// ../../node_modules/.bun/@jitl+quickjs-wasmfile-release-sync@0.32.0/node_modules/@jitl/quickjs-wasmfile-release-sync/dist/index.mjs
|
|
163
|
+
var variant2 = { type: "sync", importFFI: () => import("./ffi-3cx1cxpk.js").then((mod) => mod.QuickJSFFI), importModuleLoader: () => import("./emscripten-module-e67xwsp3.js").then((mod) => mod.default) };
|
|
164
|
+
var src_default2 = variant2;
|
|
165
|
+
|
|
166
|
+
// ../../node_modules/.bun/@jitl+quickjs-wasmfile-debug-asyncify@0.32.0/node_modules/@jitl/quickjs-wasmfile-debug-asyncify/dist/index.mjs
|
|
167
|
+
var variant3 = { type: "async", importFFI: () => import("./ffi-7e6gryj5.js").then((mod) => mod.QuickJSAsyncFFI), importModuleLoader: () => import("./emscripten-module-0pekdjxz.js").then((mod) => mod.default) };
|
|
168
|
+
var src_default3 = variant3;
|
|
169
|
+
|
|
170
|
+
// ../../node_modules/.bun/@jitl+quickjs-wasmfile-release-asyncify@0.32.0/node_modules/@jitl/quickjs-wasmfile-release-asyncify/dist/index.mjs
|
|
171
|
+
var variant4 = { type: "async", importFFI: () => import("./ffi-7bqqe4cd.js").then((mod) => mod.QuickJSAsyncFFI), importModuleLoader: () => import("./emscripten-module-0g8f45e6.js").then((mod) => mod.default) };
|
|
172
|
+
var src_default4 = variant4;
|
|
173
|
+
|
|
174
|
+
// ../../node_modules/.bun/quickjs-emscripten@0.32.0/node_modules/quickjs-emscripten/dist/chunk-OHAYRCBA.mjs
|
|
175
|
+
async function newQuickJSWASMModule(variantOrPromise = src_default2) {
|
|
176
|
+
return newQuickJSWASMModuleFromVariant(variantOrPromise);
|
|
177
|
+
}
|
|
178
|
+
async function newQuickJSAsyncWASMModule(variantOrPromise = src_default4) {
|
|
179
|
+
return newQuickJSAsyncWASMModuleFromVariant(variantOrPromise);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// ../../node_modules/.bun/quickjs-emscripten@0.32.0/node_modules/quickjs-emscripten/dist/index.mjs
|
|
183
|
+
var singleton;
|
|
184
|
+
var singletonPromise;
|
|
185
|
+
async function getQuickJS() {
|
|
186
|
+
return singletonPromise ?? (singletonPromise = newQuickJSWASMModule().then((instance) => (singleton = instance, instance))), await singletonPromise;
|
|
187
|
+
}
|
|
188
|
+
function getQuickJSSync() {
|
|
189
|
+
if (!singleton)
|
|
190
|
+
throw new Error("QuickJS not initialized. Await getQuickJS() at least once.");
|
|
191
|
+
return singleton;
|
|
192
|
+
}
|
|
193
|
+
async function newAsyncRuntime(options) {
|
|
194
|
+
return (await newQuickJSAsyncWASMModule()).newRuntime(options);
|
|
195
|
+
}
|
|
196
|
+
async function newAsyncContext(options) {
|
|
197
|
+
return (await newQuickJSAsyncWASMModule()).newContext(options);
|
|
198
|
+
}
|
|
199
|
+
export {
|
|
200
|
+
src_default3 as DEBUG_ASYNC,
|
|
201
|
+
src_default as DEBUG_SYNC,
|
|
202
|
+
DefaultIntrinsics2 as DefaultIntrinsics,
|
|
203
|
+
DisposableFail2 as DisposableFail,
|
|
204
|
+
DisposableResult2 as DisposableResult,
|
|
205
|
+
DisposableSuccess2 as DisposableSuccess,
|
|
206
|
+
EvalFlags2 as EvalFlags,
|
|
207
|
+
GetOwnPropertyNamesFlags2 as GetOwnPropertyNamesFlags,
|
|
208
|
+
IntrinsicsFlags2 as IntrinsicsFlags,
|
|
209
|
+
IsEqualOp2 as IsEqualOp,
|
|
210
|
+
JSPromiseStateEnum2 as JSPromiseStateEnum,
|
|
211
|
+
Lifetime2 as Lifetime,
|
|
212
|
+
QuickJSAsyncContext2 as QuickJSAsyncContext,
|
|
213
|
+
QuickJSAsyncRuntime2 as QuickJSAsyncRuntime,
|
|
214
|
+
QuickJSAsyncWASMModule2 as QuickJSAsyncWASMModule,
|
|
215
|
+
QuickJSContext2 as QuickJSContext,
|
|
216
|
+
QuickJSDeferredPromise2 as QuickJSDeferredPromise,
|
|
217
|
+
QuickJSRuntime2 as QuickJSRuntime,
|
|
218
|
+
QuickJSWASMModule2 as QuickJSWASMModule,
|
|
219
|
+
src_default4 as RELEASE_ASYNC,
|
|
220
|
+
src_default2 as RELEASE_SYNC,
|
|
221
|
+
Scope2 as Scope,
|
|
222
|
+
StaticLifetime2 as StaticLifetime,
|
|
223
|
+
TestQuickJSWASMModule,
|
|
224
|
+
UsingDisposable2 as UsingDisposable,
|
|
225
|
+
WeakLifetime2 as WeakLifetime,
|
|
226
|
+
assertSync2 as assertSync,
|
|
227
|
+
createDisposableArray2 as createDisposableArray,
|
|
228
|
+
debugLog2 as debugLog,
|
|
229
|
+
errors_exports as errors,
|
|
230
|
+
getQuickJS,
|
|
231
|
+
getQuickJSSync,
|
|
232
|
+
isFail,
|
|
233
|
+
isSuccess,
|
|
234
|
+
memoizePromiseFactory,
|
|
235
|
+
newAsyncContext,
|
|
236
|
+
newAsyncRuntime,
|
|
237
|
+
newQuickJSAsyncWASMModule,
|
|
238
|
+
newQuickJSAsyncWASMModuleFromVariant,
|
|
239
|
+
newQuickJSWASMModule,
|
|
240
|
+
newQuickJSWASMModuleFromVariant,
|
|
241
|
+
newVariant,
|
|
242
|
+
setDebugMode2 as setDebugMode,
|
|
243
|
+
shouldInterruptAfterDeadline
|
|
244
|
+
};
|