@volter/tabnode 0.5.38 → 0.5.39
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.
|
@@ -78650,7 +78650,27 @@ function __substrateFollowAwaits(code2) {
|
|
|
78650
78650
|
for (const [at3, text] of leading) insert(at3, text);
|
|
78651
78651
|
};
|
|
78652
78652
|
visit(ast, false, void 0);
|
|
78653
|
-
|
|
78653
|
+
const followed = edits.length ? applyReplacements(code2, edits) : code2;
|
|
78654
|
+
return __substrateTopLevelAwait(ast) ? `${followed}
|
|
78655
|
+
${__substrateTopLevelAwaitMarker}` : followed;
|
|
78656
|
+
}
|
|
78657
|
+
const __substrateTopLevelAwaitMarker = "/*__substrate_top_level_await__*/";
|
|
78658
|
+
function __substrateTopLevelAwait(ast) {
|
|
78659
|
+
const isFunction = (node) => node.type === "FunctionDeclaration" || node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression";
|
|
78660
|
+
const stack = [ast];
|
|
78661
|
+
while (stack.length) {
|
|
78662
|
+
const node = stack.pop();
|
|
78663
|
+
if (node.type === "AwaitExpression" || node.type === "ForOfStatement" && node.await) return true;
|
|
78664
|
+
for (const key of Object.keys(node)) {
|
|
78665
|
+
if (key === "type" || key === "start" || key === "end" || key === "loc" || key === "range") continue;
|
|
78666
|
+
const child = node[key];
|
|
78667
|
+
if (!child || typeof child !== "object") continue;
|
|
78668
|
+
for (const item of Array.isArray(child) ? child : [child]) {
|
|
78669
|
+
if (item && typeof item.type === "string" && !isFunction(item)) stack.push(item);
|
|
78670
|
+
}
|
|
78671
|
+
}
|
|
78672
|
+
}
|
|
78673
|
+
return false;
|
|
78654
78674
|
}
|
|
78655
78675
|
function __substrateUnfollowAwaits(source) {
|
|
78656
78676
|
if (!source.includes("__substrate")) return source;
|
|
@@ -79795,10 +79815,10 @@ function createRequire(vfs2, fsShim, process2, currentDir, moduleCache, options,
|
|
|
79795
79815
|
const wrappedCode = `(function($exports, $require, $module, $filename, $dirname, $process, $console, $importMeta, $dynamicImport, __substrateGuestGlobal, __substrateGuestConstructor) { var exports = $exports; var require = $require; var module = $module; var __filename = $filename; var __dirname = $dirname; var process = $process; var console = $console; var import_meta = $importMeta; var __dynamicImport = $dynamicImport; var document = void 0, window = void 0, location = void 0, self = void 0; var globalThis = __substrateGuestGlobal($process); var global = globalThis; var Buffer = globalThis.Buffer; var queueMicrotask = globalThis.queueMicrotask, atob = globalThis.atob, btoa = globalThis.btoa, structuredClone = globalThis.structuredClone, setTimeout = globalThis.setTimeout, clearTimeout = globalThis.clearTimeout, setInterval = globalThis.setInterval, clearInterval = globalThis.clearInterval; globalThis.process = $process; global.process = $process; with ({ __proto__: null, get navigator() { return globalThis.navigator; }, set navigator(value) { globalThis.navigator = value; }, get Navigator() { return globalThis.Navigator; }, set Navigator(value) { globalThis.Navigator = value; }, get Promise() { return globalThis.Promise; }, set Promise(value) { globalThis.Promise = value; }, get fetch() { return globalThis.fetch; }, set fetch(value) { globalThis.fetch = value; } }) { return (function() {${code2}
|
|
79796
79816
|
}).call(${strictBody ? "void 0" : "$module.exports"}); }
|
|
79797
79817
|
})${__substrateSourceURL(resolvedPath)}`;
|
|
79798
|
-
let bodyKind = code2.includes(__substrateAwaitMarker) ? "generator" : "sync";
|
|
79818
|
+
let bodyKind = code2.includes(__substrateTopLevelAwaitMarker) ? "async" : code2.includes(__substrateAwaitMarker) ? "generator" : "sync";
|
|
79799
79819
|
let fn2;
|
|
79800
79820
|
try {
|
|
79801
|
-
fn2 = __substrateSloppyEval(bodyKind === "generator" ? __substrateGeneratorBody(wrappedCode) : wrappedCode);
|
|
79821
|
+
fn2 = __substrateSloppyEval(bodyKind === "generator" ? __substrateGeneratorBody(wrappedCode) : bodyKind === "async" ? __substrateAsyncBody(wrappedCode) : wrappedCode);
|
|
79802
79822
|
} catch (evalError) {
|
|
79803
79823
|
const msg2 = evalError instanceof Error ? evalError.message : String(evalError);
|
|
79804
79824
|
if (!(evalError instanceof SyntaxError)) throw evalError;
|
|
@@ -80156,10 +80176,10 @@ class Runtime {
|
|
|
80156
80176
|
}).call(${strictBody ? "void 0" : "$module.exports"}); }
|
|
80157
80177
|
})${__substrateSourceURL(filename)}`;
|
|
80158
80178
|
const dynamicImport = createDynamicImport(require2, this.process, filename.startsWith("data:") ? filename : `file://${filename}`);
|
|
80159
|
-
let bodyKind = code2.includes(__substrateAwaitMarker) ? "generator" : "sync";
|
|
80179
|
+
let bodyKind = code2.includes(__substrateTopLevelAwaitMarker) ? "async" : code2.includes(__substrateAwaitMarker) ? "generator" : "sync";
|
|
80160
80180
|
let fn2;
|
|
80161
80181
|
try {
|
|
80162
|
-
fn2 = __substrateSloppyEval(bodyKind === "generator" ? __substrateGeneratorBody(wrappedCode) : wrappedCode);
|
|
80182
|
+
fn2 = __substrateSloppyEval(bodyKind === "generator" ? __substrateGeneratorBody(wrappedCode) : bodyKind === "async" ? __substrateAsyncBody(wrappedCode) : wrappedCode);
|
|
80163
80183
|
} catch (syntaxError) {
|
|
80164
80184
|
if (!(syntaxError instanceof SyntaxError)) throw syntaxError;
|
|
80165
80185
|
bodyKind = "async";
|
package/dist/index.mjs
CHANGED
|
@@ -38308,7 +38308,27 @@ function __substrateFollowAwaits(code2) {
|
|
|
38308
38308
|
for (const [at2, text] of leading) insert(at2, text);
|
|
38309
38309
|
};
|
|
38310
38310
|
visit(ast, false, void 0);
|
|
38311
|
-
|
|
38311
|
+
const followed = edits.length ? applyReplacements(code2, edits) : code2;
|
|
38312
|
+
return __substrateTopLevelAwait(ast) ? `${followed}
|
|
38313
|
+
${__substrateTopLevelAwaitMarker}` : followed;
|
|
38314
|
+
}
|
|
38315
|
+
const __substrateTopLevelAwaitMarker = "/*__substrate_top_level_await__*/";
|
|
38316
|
+
function __substrateTopLevelAwait(ast) {
|
|
38317
|
+
const isFunction = (node) => node.type === "FunctionDeclaration" || node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression";
|
|
38318
|
+
const stack = [ast];
|
|
38319
|
+
while (stack.length) {
|
|
38320
|
+
const node = stack.pop();
|
|
38321
|
+
if (node.type === "AwaitExpression" || node.type === "ForOfStatement" && node.await) return true;
|
|
38322
|
+
for (const key of Object.keys(node)) {
|
|
38323
|
+
if (key === "type" || key === "start" || key === "end" || key === "loc" || key === "range") continue;
|
|
38324
|
+
const child = node[key];
|
|
38325
|
+
if (!child || typeof child !== "object") continue;
|
|
38326
|
+
for (const item of Array.isArray(child) ? child : [child]) {
|
|
38327
|
+
if (item && typeof item.type === "string" && !isFunction(item)) stack.push(item);
|
|
38328
|
+
}
|
|
38329
|
+
}
|
|
38330
|
+
}
|
|
38331
|
+
return false;
|
|
38312
38332
|
}
|
|
38313
38333
|
function __substrateUnfollowAwaits(source) {
|
|
38314
38334
|
if (!source.includes("__substrate")) return source;
|
|
@@ -39456,10 +39476,10 @@ function createRequire(vfs2, fsShim, process2, currentDir, moduleCache, options,
|
|
|
39456
39476
|
const wrappedCode = `(function($exports, $require, $module, $filename, $dirname, $process, $console, $importMeta, $dynamicImport, __substrateGuestGlobal, __substrateGuestConstructor) { var exports = $exports; var require = $require; var module = $module; var __filename = $filename; var __dirname = $dirname; var process = $process; var console = $console; var import_meta = $importMeta; var __dynamicImport = $dynamicImport; var document = void 0, window = void 0, location = void 0, self = void 0; var globalThis = __substrateGuestGlobal($process); var global = globalThis; var Buffer = globalThis.Buffer; var queueMicrotask = globalThis.queueMicrotask, atob = globalThis.atob, btoa = globalThis.btoa, structuredClone = globalThis.structuredClone, setTimeout = globalThis.setTimeout, clearTimeout = globalThis.clearTimeout, setInterval = globalThis.setInterval, clearInterval = globalThis.clearInterval; globalThis.process = $process; global.process = $process; with ({ __proto__: null, get navigator() { return globalThis.navigator; }, set navigator(value) { globalThis.navigator = value; }, get Navigator() { return globalThis.Navigator; }, set Navigator(value) { globalThis.Navigator = value; }, get Promise() { return globalThis.Promise; }, set Promise(value) { globalThis.Promise = value; }, get fetch() { return globalThis.fetch; }, set fetch(value) { globalThis.fetch = value; } }) { return (function() {${code2}
|
|
39457
39477
|
}).call(${strictBody ? "void 0" : "$module.exports"}); }
|
|
39458
39478
|
})${__substrateSourceURL(resolvedPath)}`;
|
|
39459
|
-
let bodyKind = code2.includes(__substrateAwaitMarker) ? "generator" : "sync";
|
|
39479
|
+
let bodyKind = code2.includes(__substrateTopLevelAwaitMarker) ? "async" : code2.includes(__substrateAwaitMarker) ? "generator" : "sync";
|
|
39460
39480
|
let fn;
|
|
39461
39481
|
try {
|
|
39462
|
-
fn = __substrateSloppyEval(bodyKind === "generator" ? __substrateGeneratorBody(wrappedCode) : wrappedCode);
|
|
39482
|
+
fn = __substrateSloppyEval(bodyKind === "generator" ? __substrateGeneratorBody(wrappedCode) : bodyKind === "async" ? __substrateAsyncBody(wrappedCode) : wrappedCode);
|
|
39463
39483
|
} catch (evalError) {
|
|
39464
39484
|
const msg2 = evalError instanceof Error ? evalError.message : String(evalError);
|
|
39465
39485
|
if (!(evalError instanceof SyntaxError)) throw evalError;
|
|
@@ -39817,10 +39837,10 @@ class Runtime {
|
|
|
39817
39837
|
}).call(${strictBody ? "void 0" : "$module.exports"}); }
|
|
39818
39838
|
})${__substrateSourceURL(filename)}`;
|
|
39819
39839
|
const dynamicImport = createDynamicImport(require2, this.process, filename.startsWith("data:") ? filename : `file://${filename}`);
|
|
39820
|
-
let bodyKind = code2.includes(__substrateAwaitMarker) ? "generator" : "sync";
|
|
39840
|
+
let bodyKind = code2.includes(__substrateTopLevelAwaitMarker) ? "async" : code2.includes(__substrateAwaitMarker) ? "generator" : "sync";
|
|
39821
39841
|
let fn;
|
|
39822
39842
|
try {
|
|
39823
|
-
fn = __substrateSloppyEval(bodyKind === "generator" ? __substrateGeneratorBody(wrappedCode) : wrappedCode);
|
|
39843
|
+
fn = __substrateSloppyEval(bodyKind === "generator" ? __substrateGeneratorBody(wrappedCode) : bodyKind === "async" ? __substrateAsyncBody(wrappedCode) : wrappedCode);
|
|
39824
39844
|
} catch (syntaxError) {
|
|
39825
39845
|
if (!(syntaxError instanceof SyntaxError)) throw syntaxError;
|
|
39826
39846
|
bodyKind = "async";
|
|
@@ -40314,7 +40334,7 @@ class WorkerRuntime {
|
|
|
40314
40334
|
this.worker = new Worker(
|
|
40315
40335
|
new URL(
|
|
40316
40336
|
/* @vite-ignore */
|
|
40317
|
-
"/assets/runtime-worker-
|
|
40337
|
+
"/assets/runtime-worker-D73ktngT.js",
|
|
40318
40338
|
import.meta.url
|
|
40319
40339
|
),
|
|
40320
40340
|
{ type: "module" }
|
package/package.json
CHANGED
package/src/runtime.ts
CHANGED
|
@@ -509,7 +509,34 @@ function __substrateFollowAwaits(code: string): string {
|
|
|
509
509
|
for (const [at, text] of leading) insert(at, text);
|
|
510
510
|
};
|
|
511
511
|
visit(ast, false, undefined);
|
|
512
|
-
|
|
512
|
+
const followed = edits.length ? applyReplacements(code, edits) : code;
|
|
513
|
+
return __substrateTopLevelAwait(ast) ? `${followed}\n${__substrateTopLevelAwaitMarker}` : followed;
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
/**
|
|
517
|
+
* Whether a module body awaits outside every function of its own. Its
|
|
518
|
+
* import markers make it a generator, and in a generator `await (x)` is a
|
|
519
|
+
* call of an identifier named `await`: chrome-devtools-mcp's bundle
|
|
520
|
+
* (`const HOST_RUNTIME = await (async () => ...)()`) compiled, ran, and
|
|
521
|
+
* threw "await is not defined". Such a body runs as an async function.
|
|
522
|
+
*/
|
|
523
|
+
const __substrateTopLevelAwaitMarker = '/*__substrate_top_level_await__*/';
|
|
524
|
+
function __substrateTopLevelAwait(ast: any): boolean {
|
|
525
|
+
const isFunction = (node: any): boolean => node.type === 'FunctionDeclaration' || node.type === 'FunctionExpression' || node.type === 'ArrowFunctionExpression';
|
|
526
|
+
const stack: any[] = [ast];
|
|
527
|
+
while (stack.length) {
|
|
528
|
+
const node = stack.pop();
|
|
529
|
+
if (node.type === 'AwaitExpression' || (node.type === 'ForOfStatement' && node.await)) return true;
|
|
530
|
+
for (const key of Object.keys(node)) {
|
|
531
|
+
if (key === 'type' || key === 'start' || key === 'end' || key === 'loc' || key === 'range') continue;
|
|
532
|
+
const child = node[key];
|
|
533
|
+
if (!child || typeof child !== 'object') continue;
|
|
534
|
+
for (const item of Array.isArray(child) ? child : [child]) {
|
|
535
|
+
if (item && typeof item.type === 'string' && !isFunction(item)) stack.push(item);
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
return false;
|
|
513
540
|
}
|
|
514
541
|
|
|
515
542
|
/**
|
|
@@ -2100,10 +2127,10 @@ function createRequire(
|
|
|
2100
2127
|
// still settling; a body that must wait, on a top-level `await` of its
|
|
2101
2128
|
// own, runs as an async function. Either way its settling is what its
|
|
2102
2129
|
// importers await.
|
|
2103
|
-
let bodyKind: 'sync' | 'generator' | 'async' = code.includes(__substrateAwaitMarker) ? 'generator' : 'sync';
|
|
2130
|
+
let bodyKind: 'sync' | 'generator' | 'async' = code.includes(__substrateTopLevelAwaitMarker) ? 'async' : code.includes(__substrateAwaitMarker) ? 'generator' : 'sync';
|
|
2104
2131
|
let fn;
|
|
2105
2132
|
try {
|
|
2106
|
-
fn = __substrateSloppyEval(bodyKind === 'generator' ? __substrateGeneratorBody(wrappedCode) : wrappedCode);
|
|
2133
|
+
fn = __substrateSloppyEval(bodyKind === 'generator' ? __substrateGeneratorBody(wrappedCode) : bodyKind === 'async' ? __substrateAsyncBody(wrappedCode) : wrappedCode);
|
|
2107
2134
|
} catch (evalError) {
|
|
2108
2135
|
const msg = evalError instanceof Error ? evalError.message : String(evalError);
|
|
2109
2136
|
// A module with top-level await runs. Node runs a `.js` file of a package
|
|
@@ -2648,10 +2675,10 @@ export class Runtime {
|
|
|
2648
2675
|
// a module lowered to a function body made V8 refuse vue3-ssr's server at
|
|
2649
2676
|
// its first top-level `await`. A body V8 refuses for that reason runs as
|
|
2650
2677
|
// an async function body instead.
|
|
2651
|
-
let bodyKind: 'sync' | 'generator' | 'async' = code.includes(__substrateAwaitMarker) ? 'generator' : 'sync';
|
|
2678
|
+
let bodyKind: 'sync' | 'generator' | 'async' = code.includes(__substrateTopLevelAwaitMarker) ? 'async' : code.includes(__substrateAwaitMarker) ? 'generator' : 'sync';
|
|
2652
2679
|
let fn;
|
|
2653
2680
|
try {
|
|
2654
|
-
fn = __substrateSloppyEval(bodyKind === 'generator' ? __substrateGeneratorBody(wrappedCode) : wrappedCode);
|
|
2681
|
+
fn = __substrateSloppyEval(bodyKind === 'generator' ? __substrateGeneratorBody(wrappedCode) : bodyKind === 'async' ? __substrateAsyncBody(wrappedCode) : wrappedCode);
|
|
2655
2682
|
} catch (syntaxError) {
|
|
2656
2683
|
if (!(syntaxError instanceof SyntaxError)) throw syntaxError;
|
|
2657
2684
|
bodyKind = 'async';
|