@volter/tabnode 0.5.27 → 0.5.29
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/assets/{runtime-worker-DPvtXRd8.js → runtime-worker-Dv_vTkXr.js} +202 -93
- package/dist/index.mjs +203 -94
- package/dist/shims/async_hooks.d.ts +12 -21
- package/package.json +1 -1
- package/src/runtime.ts +157 -9
- package/src/shims/async_hooks.ts +83 -83
- package/src/shims/child_process.ts +31 -6
|
@@ -6521,99 +6521,85 @@ forGuestRealm(() => {
|
|
|
6521
6521
|
const realm = globalThis;
|
|
6522
6522
|
if (!realm.__browserRuntimeHeldWork) takeFromHost(globalThis, "__browserRuntimeHeldWork", ownHeldWork);
|
|
6523
6523
|
});
|
|
6524
|
-
|
|
6525
|
-
|
|
6526
|
-
|
|
6527
|
-
|
|
6528
|
-
|
|
6529
|
-
|
|
6530
|
-
|
|
6531
|
-
|
|
6532
|
-
|
|
6533
|
-
|
|
6534
|
-
|
|
6535
|
-
|
|
6536
|
-
|
|
6537
|
-
|
|
6538
|
-
|
|
6539
|
-
|
|
6540
|
-
|
|
6541
|
-
|
|
6542
|
-
|
|
6524
|
+
const ROOT_FRAME = /* @__PURE__ */ new Map();
|
|
6525
|
+
let currentFrame = ROOT_FRAME;
|
|
6526
|
+
const nativeQueueMicrotask = globalThis.queueMicrotask.bind(globalThis);
|
|
6527
|
+
let resetQueued = false;
|
|
6528
|
+
const resetFrame = () => {
|
|
6529
|
+
resetQueued = false;
|
|
6530
|
+
currentFrame = ROOT_FRAME;
|
|
6531
|
+
};
|
|
6532
|
+
const resumeFrame = (frame) => {
|
|
6533
|
+
if (frame === currentFrame) return;
|
|
6534
|
+
currentFrame = frame;
|
|
6535
|
+
if (!resetQueued) {
|
|
6536
|
+
resetQueued = true;
|
|
6537
|
+
nativeQueueMicrotask(resetFrame);
|
|
6538
|
+
}
|
|
6539
|
+
};
|
|
6540
|
+
const withFrame = (frame, callback) => {
|
|
6541
|
+
const previous = currentFrame;
|
|
6542
|
+
currentFrame = frame;
|
|
6543
|
+
try {
|
|
6544
|
+
return callback();
|
|
6545
|
+
} finally {
|
|
6546
|
+
currentFrame = previous;
|
|
6543
6547
|
}
|
|
6544
|
-
}
|
|
6545
|
-
const __substrateAsyncLocalStorages = /* @__PURE__ */ new Set();
|
|
6548
|
+
};
|
|
6546
6549
|
class AsyncLocalStorage {
|
|
6547
|
-
constructor() {
|
|
6548
|
-
__publicField(this, "store");
|
|
6549
|
-
__substrateAsyncLocalStorages.add(this);
|
|
6550
|
-
}
|
|
6551
6550
|
static snapshot() {
|
|
6552
|
-
const captured =
|
|
6553
|
-
|
|
6554
|
-
return (callback, ...args) => {
|
|
6555
|
-
const previous = /* @__PURE__ */ new Map();
|
|
6556
|
-
for (const [storage, store] of captured) {
|
|
6557
|
-
previous.set(storage, storage.store);
|
|
6558
|
-
storage.store = store;
|
|
6559
|
-
}
|
|
6560
|
-
try {
|
|
6561
|
-
return callback(...args);
|
|
6562
|
-
} finally {
|
|
6563
|
-
for (const [storage, store] of previous) storage.store = store;
|
|
6564
|
-
}
|
|
6565
|
-
};
|
|
6551
|
+
const captured = currentFrame;
|
|
6552
|
+
return (callback, ...args) => withFrame(captured, () => callback(...args));
|
|
6566
6553
|
}
|
|
6567
6554
|
static bind(callback) {
|
|
6568
6555
|
const snapshot = AsyncLocalStorage.snapshot();
|
|
6569
6556
|
return (...args) => snapshot(callback, ...args);
|
|
6570
6557
|
}
|
|
6571
6558
|
disable() {
|
|
6559
|
+
if (!currentFrame.has(this)) return;
|
|
6560
|
+
const next2 = new Map(currentFrame);
|
|
6561
|
+
next2.delete(this);
|
|
6562
|
+
currentFrame = next2;
|
|
6572
6563
|
}
|
|
6573
6564
|
getStore() {
|
|
6574
|
-
return this
|
|
6565
|
+
return currentFrame.get(this);
|
|
6575
6566
|
}
|
|
6576
|
-
/**
|
|
6577
|
-
* A store entered for an async callback used to be left the moment the
|
|
6578
|
-
* callback returned its promise, so the first `await` inside a Server Action
|
|
6579
|
-
* lost Next's request store and `cookies()` was "outside a request scope". A
|
|
6580
|
-
* tab has no async_hooks and no AsyncContext, and an `await` of a native
|
|
6581
|
-
* promise bypasses any `then` a patch could install, so the continuations
|
|
6582
|
-
* cannot be followed. What can be done honestly is keep the store current
|
|
6583
|
-
* until the callback's promise settles: exact for one run at a time, and
|
|
6584
|
-
* last-entered-wins where two async runs overlap.
|
|
6585
|
-
*/
|
|
6586
6567
|
run(store, callback, ...args) {
|
|
6587
|
-
const
|
|
6588
|
-
this
|
|
6589
|
-
|
|
6590
|
-
try {
|
|
6591
|
-
result = callback(...args);
|
|
6592
|
-
} catch (error) {
|
|
6593
|
-
this.store = prev;
|
|
6594
|
-
throw error;
|
|
6595
|
-
}
|
|
6596
|
-
if (result && typeof result.then === "function") {
|
|
6597
|
-
const restore = () => {
|
|
6598
|
-
if (this.store === store) this.store = prev;
|
|
6599
|
-
};
|
|
6600
|
-
result.then(restore, restore);
|
|
6601
|
-
return result;
|
|
6602
|
-
}
|
|
6603
|
-
this.store = prev;
|
|
6604
|
-
return result;
|
|
6568
|
+
const next2 = new Map(currentFrame);
|
|
6569
|
+
next2.set(this, store);
|
|
6570
|
+
return withFrame(next2, () => callback(...args));
|
|
6605
6571
|
}
|
|
6606
6572
|
exit(callback) {
|
|
6607
|
-
const
|
|
6608
|
-
this
|
|
6609
|
-
|
|
6610
|
-
return callback();
|
|
6611
|
-
} finally {
|
|
6612
|
-
this.store = prev;
|
|
6613
|
-
}
|
|
6573
|
+
const next2 = new Map(currentFrame);
|
|
6574
|
+
next2.delete(this);
|
|
6575
|
+
return withFrame(next2, callback);
|
|
6614
6576
|
}
|
|
6615
6577
|
enterWith(store) {
|
|
6616
|
-
|
|
6578
|
+
const next2 = new Map(currentFrame);
|
|
6579
|
+
next2.set(this, store);
|
|
6580
|
+
currentFrame = next2;
|
|
6581
|
+
}
|
|
6582
|
+
}
|
|
6583
|
+
class AsyncResource {
|
|
6584
|
+
constructor(_type2, _options3) {
|
|
6585
|
+
__publicField(this, "frame", currentFrame);
|
|
6586
|
+
}
|
|
6587
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6588
|
+
runInAsyncScope(fn2, thisArg, ...args) {
|
|
6589
|
+
return withFrame(this.frame, () => fn2.apply(thisArg, args));
|
|
6590
|
+
}
|
|
6591
|
+
emitDestroy() {
|
|
6592
|
+
return this;
|
|
6593
|
+
}
|
|
6594
|
+
asyncId() {
|
|
6595
|
+
return 0;
|
|
6596
|
+
}
|
|
6597
|
+
triggerAsyncId() {
|
|
6598
|
+
return 0;
|
|
6599
|
+
}
|
|
6600
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6601
|
+
static bind(fn2, _type2) {
|
|
6602
|
+
return AsyncLocalStorage.bind(fn2);
|
|
6617
6603
|
}
|
|
6618
6604
|
}
|
|
6619
6605
|
forGuestRealm(() => {
|
|
@@ -6640,6 +6626,14 @@ forGuestRealm(() => {
|
|
|
6640
6626
|
};
|
|
6641
6627
|
takeFromHost(Promise.prototype, "then", carriedThen);
|
|
6642
6628
|
takeFromHost(globalThis, "__substrateCarried", carried);
|
|
6629
|
+
takeFromHost(globalThis, "__substrateContext", () => currentFrame);
|
|
6630
|
+
takeFromHost(globalThis, "__substrateResume", (frame, value) => {
|
|
6631
|
+
resumeFrame(frame);
|
|
6632
|
+
return value;
|
|
6633
|
+
});
|
|
6634
|
+
takeFromHost(globalThis, "__substrateRestore", (frame) => {
|
|
6635
|
+
resumeFrame(frame);
|
|
6636
|
+
});
|
|
6643
6637
|
});
|
|
6644
6638
|
function createHook(_callbacks) {
|
|
6645
6639
|
return {
|
|
@@ -29572,7 +29566,7 @@ Parser.acorn = {
|
|
|
29572
29566
|
function parse3(input, options) {
|
|
29573
29567
|
return Parser.parse(input, options);
|
|
29574
29568
|
}
|
|
29575
|
-
class Script {
|
|
29569
|
+
let Script$1 = class Script {
|
|
29576
29570
|
constructor(code2, _options22) {
|
|
29577
29571
|
__publicField(this, "code");
|
|
29578
29572
|
this.code = code2;
|
|
@@ -29635,7 +29629,7 @@ class Script {
|
|
|
29635
29629
|
createCachedData() {
|
|
29636
29630
|
return Buffer.from("");
|
|
29637
29631
|
}
|
|
29638
|
-
}
|
|
29632
|
+
};
|
|
29639
29633
|
function createContext(contextObject, _options22) {
|
|
29640
29634
|
return contextObject || {};
|
|
29641
29635
|
}
|
|
@@ -29646,7 +29640,7 @@ function runInThisContext(code, _options) {
|
|
|
29646
29640
|
return eval(code);
|
|
29647
29641
|
}
|
|
29648
29642
|
function runInNewContext(code2, contextObject, _options22) {
|
|
29649
|
-
const script = new Script(code2);
|
|
29643
|
+
const script = new Script$1(code2);
|
|
29650
29644
|
return script.runInNewContext(contextObject);
|
|
29651
29645
|
}
|
|
29652
29646
|
function runInContext(code2, context2, _options22) {
|
|
@@ -29684,7 +29678,7 @@ class SyntheticModule extends Module {
|
|
|
29684
29678
|
}
|
|
29685
29679
|
}
|
|
29686
29680
|
var vm$1 = {
|
|
29687
|
-
Script,
|
|
29681
|
+
Script: Script$1,
|
|
29688
29682
|
createContext,
|
|
29689
29683
|
isContext,
|
|
29690
29684
|
runInThisContext,
|
|
@@ -29698,7 +29692,7 @@ var vm$1 = {
|
|
|
29698
29692
|
var vmShim = /* @__PURE__ */ Object.freeze({
|
|
29699
29693
|
__proto__: null,
|
|
29700
29694
|
Module,
|
|
29701
|
-
Script,
|
|
29695
|
+
Script: Script$1,
|
|
29702
29696
|
SourceTextModule,
|
|
29703
29697
|
SyntheticModule,
|
|
29704
29698
|
compileFunction,
|
|
@@ -74706,7 +74700,24 @@ function readPackageJson(cwd) {
|
|
|
74706
74700
|
}
|
|
74707
74701
|
}
|
|
74708
74702
|
async function handleNpmRun(args, ctx) {
|
|
74709
|
-
|
|
74703
|
+
let scriptName;
|
|
74704
|
+
let silent = false;
|
|
74705
|
+
let ifPresent = false;
|
|
74706
|
+
const passed = [];
|
|
74707
|
+
for (let index2 = 0; index2 < args.length; index2++) {
|
|
74708
|
+
const arg = args[index2];
|
|
74709
|
+
if (arg === "--") {
|
|
74710
|
+
if (scriptName !== void 0) passed.push(...args.slice(index2 + 1));
|
|
74711
|
+
break;
|
|
74712
|
+
}
|
|
74713
|
+
if (arg.startsWith("-") && arg !== "-") {
|
|
74714
|
+
if (arg === "--silent" || arg === "-s" || arg === "--quiet" || arg === "-q" || arg === "--loglevel=silent") silent = true;
|
|
74715
|
+
else if (arg === "--if-present") ifPresent = true;
|
|
74716
|
+
continue;
|
|
74717
|
+
}
|
|
74718
|
+
if (scriptName === void 0) scriptName = arg;
|
|
74719
|
+
else passed.push(arg);
|
|
74720
|
+
}
|
|
74710
74721
|
if (!scriptName) {
|
|
74711
74722
|
return listScripts(ctx);
|
|
74712
74723
|
}
|
|
@@ -74716,6 +74727,7 @@ async function handleNpmRun(args, ctx) {
|
|
|
74716
74727
|
const scripts = pkgJson.scripts || {};
|
|
74717
74728
|
const scriptCommand = scripts[scriptName];
|
|
74718
74729
|
if (!scriptCommand) {
|
|
74730
|
+
if (ifPresent) return { stdout: "", stderr: "", exitCode: 0 };
|
|
74719
74731
|
const available = Object.keys(scripts);
|
|
74720
74732
|
let msg2 = `npm ERR! Missing script: "${scriptName}"
|
|
74721
74733
|
`;
|
|
@@ -74748,7 +74760,7 @@ async function handleNpmRun(args, ctx) {
|
|
|
74748
74760
|
const label = `${pkgJson.name || ""}@${pkgJson.version || ""}`;
|
|
74749
74761
|
const preScript = scripts[`pre${scriptName}`];
|
|
74750
74762
|
if (preScript) {
|
|
74751
|
-
allStderr += `
|
|
74763
|
+
if (!silent) allStderr += `
|
|
74752
74764
|
> ${label} pre${scriptName}
|
|
74753
74765
|
> ${preScript}
|
|
74754
74766
|
|
|
@@ -74760,12 +74772,13 @@ async function handleNpmRun(args, ctx) {
|
|
|
74760
74772
|
return { stdout: allStdout, stderr: allStderr, exitCode: preResult.exitCode };
|
|
74761
74773
|
}
|
|
74762
74774
|
}
|
|
74763
|
-
|
|
74775
|
+
const command = passed.length > 0 ? `${scriptCommand} ${passed.map((arg) => /^[\w@%+=:,./-]+$/.test(arg) ? arg : `'${arg.replace(/'/g, `'\\''`)}'`).join(" ")}` : scriptCommand;
|
|
74776
|
+
if (!silent) allStderr += `
|
|
74764
74777
|
> ${label} ${scriptName}
|
|
74765
|
-
> ${
|
|
74778
|
+
> ${command}
|
|
74766
74779
|
|
|
74767
74780
|
`;
|
|
74768
|
-
const mainResult = await ctx.exec(
|
|
74781
|
+
const mainResult = await ctx.exec(command, { cwd: ctx.cwd, env: npmEnv, ...typeof ctx.stdin === "string" ? { stdin: ctx.stdin } : {} });
|
|
74769
74782
|
allStdout += mainResult.stdout;
|
|
74770
74783
|
allStderr += mainResult.stderr;
|
|
74771
74784
|
if (mainResult.exitCode !== 0) {
|
|
@@ -74773,7 +74786,7 @@ async function handleNpmRun(args, ctx) {
|
|
|
74773
74786
|
}
|
|
74774
74787
|
const postScript = scripts[`post${scriptName}`];
|
|
74775
74788
|
if (postScript) {
|
|
74776
|
-
allStderr += `
|
|
74789
|
+
if (!silent) allStderr += `
|
|
74777
74790
|
> ${label} post${scriptName}
|
|
74778
74791
|
> ${postScript}
|
|
74779
74792
|
|
|
@@ -78279,6 +78292,22 @@ function __substrateGuestConstructor(Constructor, process2) {
|
|
|
78279
78292
|
return __substrateFunctionScope(__substrateGuestGlobal(process2), String(compiled));
|
|
78280
78293
|
} });
|
|
78281
78294
|
}
|
|
78295
|
+
const __substrateScriptScope = Function("__substrateScriptGlobals", "__substrateScriptSource", "with (__substrateScriptGlobals) { return eval(__substrateScriptSource); }");
|
|
78296
|
+
const __substrateGuestVms = /* @__PURE__ */ new WeakMap();
|
|
78297
|
+
function __substrateGuestVm(process2) {
|
|
78298
|
+
let vm2 = __substrateGuestVms.get(process2);
|
|
78299
|
+
if (vm2) return vm2;
|
|
78300
|
+
const run = (code2) => __substrateScriptScope(__substrateGuestGlobal(process2), String(code2));
|
|
78301
|
+
class Script2 extends Script$1 {
|
|
78302
|
+
runInThisContext(_options3) {
|
|
78303
|
+
return run(this.code);
|
|
78304
|
+
}
|
|
78305
|
+
}
|
|
78306
|
+
vm2 = { ...vmShim, Script: Script2, runInThisContext: (code2, _options3) => run(code2), default: void 0 };
|
|
78307
|
+
vm2.default = vm2;
|
|
78308
|
+
__substrateGuestVms.set(process2, vm2);
|
|
78309
|
+
return vm2;
|
|
78310
|
+
}
|
|
78282
78311
|
function __substrateModuleTypes(code2, resolvedPath, format2, process2) {
|
|
78283
78312
|
const typescript = format2 === void 0 ? /[.](?:ts|mts|cts)$/u.test(resolvedPath) && !resolvedPath.endsWith(".d.ts") : format2 === "typescript" || format2 === "commonjs-typescript" || format2 === "module-typescript";
|
|
78284
78313
|
if (!typescript) return code2;
|
|
@@ -78491,6 +78520,72 @@ function collectDirectEval(node, replacements) {
|
|
|
78491
78520
|
replacements.push([source.start, source.start, "__substrateEvalSource("]);
|
|
78492
78521
|
replacements.push([source.end, source.end, ")"]);
|
|
78493
78522
|
}
|
|
78523
|
+
const ASYNC_FRAME = "__substrateAsyncFrame";
|
|
78524
|
+
const FOLLOW_MARK = "/*substrate*/";
|
|
78525
|
+
const FOLLOW_TAKE = `const ${ASYNC_FRAME}=__substrateContext();`;
|
|
78526
|
+
const FOLLOW_RESTORE = `__substrateRestore(${ASYNC_FRAME});`;
|
|
78527
|
+
const FOLLOW_RESUME_FRAMED = `__substrateResume(${ASYNC_FRAME},`;
|
|
78528
|
+
const FOLLOW_RESUME_TAKEN = "__substrateResume(__substrateContext(),";
|
|
78529
|
+
function __substrateFollowAwaits(code2) {
|
|
78530
|
+
if (!/\bawait\b/.test(code2)) return code2;
|
|
78531
|
+
let ast;
|
|
78532
|
+
try {
|
|
78533
|
+
ast = parse3(code2, { ecmaVersion: "latest", sourceType: "script", allowReturnOutsideFunction: true, allowHashBang: true, allowAwaitOutsideFunction: true });
|
|
78534
|
+
} catch {
|
|
78535
|
+
return code2;
|
|
78536
|
+
}
|
|
78537
|
+
const edits = [];
|
|
78538
|
+
const insert = (at3, text) => {
|
|
78539
|
+
edits.push([at3, at3, text]);
|
|
78540
|
+
};
|
|
78541
|
+
const isFunction = (node) => node.type === "FunctionDeclaration" || node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression";
|
|
78542
|
+
const visit = (node, framed, parent) => {
|
|
78543
|
+
if (isFunction(node)) {
|
|
78544
|
+
framed = node.async && node.body.type === "BlockStatement";
|
|
78545
|
+
if (framed) {
|
|
78546
|
+
const directives = node.body.body.filter((statement) => statement.directive !== void 0);
|
|
78547
|
+
const at3 = directives.length ? directives[directives.length - 1].end : node.body.start + 1;
|
|
78548
|
+
insert(at3, FOLLOW_TAKE);
|
|
78549
|
+
}
|
|
78550
|
+
} else if (node.type === "AwaitExpression") {
|
|
78551
|
+
insert(node.start, framed ? FOLLOW_RESUME_FRAMED : FOLLOW_RESUME_TAKEN);
|
|
78552
|
+
insert(node.end, `${FOLLOW_MARK})`);
|
|
78553
|
+
} else if (framed && node.type === "CatchClause") {
|
|
78554
|
+
insert(node.body.start + 1, FOLLOW_RESTORE);
|
|
78555
|
+
} else if (framed && node.type === "TryStatement" && node.finalizer) {
|
|
78556
|
+
insert(node.finalizer.start + 1, FOLLOW_RESTORE);
|
|
78557
|
+
} else if (framed && node.type === "ForOfStatement" && node.await) {
|
|
78558
|
+
const whole = (parent == null ? void 0 : parent.type) === "LabeledStatement" ? parent : node;
|
|
78559
|
+
insert(whole.start, `{${FOLLOW_MARK}`);
|
|
78560
|
+
insert(whole.end, `;${FOLLOW_RESTORE}${FOLLOW_MARK}}`);
|
|
78561
|
+
if (node.body.type === "BlockStatement") insert(node.body.start + 1, FOLLOW_RESTORE);
|
|
78562
|
+
else {
|
|
78563
|
+
insert(node.body.start, `{${FOLLOW_MARK}${FOLLOW_RESTORE}`);
|
|
78564
|
+
insert(node.body.end, `${FOLLOW_MARK}}`);
|
|
78565
|
+
}
|
|
78566
|
+
}
|
|
78567
|
+
for (const key of Object.keys(node)) {
|
|
78568
|
+
if (key === "type" || key === "start" || key === "end" || key === "loc" || key === "range") continue;
|
|
78569
|
+
const child = node[key];
|
|
78570
|
+
if (!child || typeof child !== "object") continue;
|
|
78571
|
+
if (Array.isArray(child)) {
|
|
78572
|
+
for (const item of child) if (item && typeof item.type === "string") visit(item, framed, node);
|
|
78573
|
+
} else if (typeof child.type === "string") visit(child, framed, node);
|
|
78574
|
+
}
|
|
78575
|
+
};
|
|
78576
|
+
visit(ast, false, void 0);
|
|
78577
|
+
return edits.length ? applyReplacements(code2, edits) : code2;
|
|
78578
|
+
}
|
|
78579
|
+
function __substrateUnfollowAwaits(source) {
|
|
78580
|
+
if (!source.includes("__substrate")) return source;
|
|
78581
|
+
return source.replaceAll(`;${FOLLOW_RESTORE}${FOLLOW_MARK}}`, "").replaceAll(`{${FOLLOW_MARK}${FOLLOW_RESTORE}`, "").replaceAll(`{${FOLLOW_MARK}`, "").replaceAll(`${FOLLOW_MARK}}`, "").replaceAll(`${FOLLOW_MARK})`, "").replaceAll(FOLLOW_TAKE, "").replaceAll(FOLLOW_RESTORE, "").replaceAll(FOLLOW_RESUME_FRAMED, "").replaceAll(FOLLOW_RESUME_TAKEN, "");
|
|
78582
|
+
}
|
|
78583
|
+
forGuestRealm(() => {
|
|
78584
|
+
const native = Function.prototype.toString;
|
|
78585
|
+
takeFromHost(Function.prototype, "toString", function toString2() {
|
|
78586
|
+
return __substrateUnfollowAwaits(native.call(this));
|
|
78587
|
+
});
|
|
78588
|
+
});
|
|
78494
78589
|
function applyReplacements(code2, replacements) {
|
|
78495
78590
|
replacements.sort((a, b) => b[0] - a[0] || b[1] - a[1]);
|
|
78496
78591
|
let out = code2;
|
|
@@ -78512,12 +78607,12 @@ function __substratePrepareBody(rawCode, resolvedPath, format2, process2) {
|
|
|
78512
78607
|
const lowered = transformEsmToCjs(code2, resolvedPath);
|
|
78513
78608
|
code2 = lowered === code2 ? code2 : `${__substrateModuleMarker}"use strict";${lowered}`;
|
|
78514
78609
|
} else {
|
|
78515
|
-
code2 =
|
|
78610
|
+
code2 = __substrateRewriteDynamicImportsInScript(code2);
|
|
78516
78611
|
}
|
|
78517
|
-
return code2;
|
|
78612
|
+
return __substrateFollowAwaits(code2);
|
|
78518
78613
|
}
|
|
78519
78614
|
const PREPARED_MODULES_DIR = "/.tabnode/prepared";
|
|
78520
|
-
const PREPARED_MODULES_FORMAT = "tabnode-prepared-
|
|
78615
|
+
const PREPARED_MODULES_FORMAT = "tabnode-prepared-2";
|
|
78521
78616
|
function preparedModuleKey(rawCode, resolvedPath) {
|
|
78522
78617
|
var _a3;
|
|
78523
78618
|
const extension = (_a3 = /\.(js|cjs|mjs)$/u.exec(resolvedPath)) == null ? void 0 : _a3[1];
|
|
@@ -78659,6 +78754,17 @@ async function __substrateImportChain(hooks, id2, parentURL, moduleRequire) {
|
|
|
78659
78754
|
}));
|
|
78660
78755
|
return doors.__loadFromURL(resolved.url, loaded2.format ?? resolved.format, loaded2.source ?? void 0);
|
|
78661
78756
|
}
|
|
78757
|
+
function createImportMeta(moduleRequire, url2, dirname2, filename) {
|
|
78758
|
+
const resolve2 = (specifier, parent) => {
|
|
78759
|
+
const id2 = typeof specifier === "string" ? specifier : String(specifier);
|
|
78760
|
+
const base = parent === void 0 ? url2 : String(parent);
|
|
78761
|
+
if (id2.startsWith("./") || id2.startsWith("../") || id2.startsWith("/")) return new URL(id2, base).href;
|
|
78762
|
+
if (/^[a-zA-Z][a-zA-Z\d+.-]*:/.test(id2)) return id2.startsWith("node:") ? id2 : new URL(id2).href;
|
|
78763
|
+
if (Object.prototype.hasOwnProperty.call(builtinModules, id2)) return `node:${id2}`;
|
|
78764
|
+
return "file://" + moduleRequire.resolve(id2);
|
|
78765
|
+
};
|
|
78766
|
+
return { url: url2, dirname: dirname2, filename, resolve: resolve2 };
|
|
78767
|
+
}
|
|
78662
78768
|
function createDynamicImport(moduleRequire, process2, parentURL) {
|
|
78663
78769
|
return async (specifier) => {
|
|
78664
78770
|
var _a3;
|
|
@@ -79627,7 +79733,7 @@ function createRequire(vfs2, fsShim, process2, currentDir, moduleCache, options,
|
|
|
79627
79733
|
dirname2,
|
|
79628
79734
|
process2,
|
|
79629
79735
|
consoleWrapper,
|
|
79630
|
-
|
|
79736
|
+
createImportMeta(moduleRequire, importMetaUrl, dirname2, resolvedPath),
|
|
79631
79737
|
dynamicImport,
|
|
79632
79738
|
__substrateGuestGlobal,
|
|
79633
79739
|
__substrateGuestConstructor
|
|
@@ -79730,6 +79836,9 @@ function createRequire(vfs2, fsShim, process2, currentDir, moduleCache, options,
|
|
|
79730
79836
|
if (id2 === "module") {
|
|
79731
79837
|
return __substrateModule();
|
|
79732
79838
|
}
|
|
79839
|
+
if (id2 === "vm") {
|
|
79840
|
+
return __substrateGuestVm(process2);
|
|
79841
|
+
}
|
|
79733
79842
|
if (id2 === "wasi") {
|
|
79734
79843
|
return __substrateGuestWasi(fsShim, process2);
|
|
79735
79844
|
}
|
|
@@ -79952,7 +80061,7 @@ class Runtime {
|
|
|
79952
80061
|
const lowered = transformEsmToCjs(code2, filename);
|
|
79953
80062
|
code2 = lowered === code2 ? code2 : `${__substrateModuleMarker}"use strict";${lowered}`;
|
|
79954
80063
|
} else {
|
|
79955
|
-
code2 =
|
|
80064
|
+
code2 = __substrateRewriteDynamicImportsInScript(code2);
|
|
79956
80065
|
}
|
|
79957
80066
|
try {
|
|
79958
80067
|
const importMetaUrl = "file://" + filename;
|
|
@@ -79983,7 +80092,7 @@ class Runtime {
|
|
|
79983
80092
|
dirname$1,
|
|
79984
80093
|
this.process,
|
|
79985
80094
|
consoleWrapper,
|
|
79986
|
-
|
|
80095
|
+
createImportMeta(require2, importMetaUrl, dirname$1, filename),
|
|
79987
80096
|
dynamicImport,
|
|
79988
80097
|
__substrateGuestGlobal,
|
|
79989
80098
|
__substrateGuestConstructor
|