@volter/tabnode 0.5.40 → 0.5.42
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.
|
@@ -78613,6 +78613,10 @@ function __substrateFollowAwaits(code2) {
|
|
|
78613
78613
|
const insert = (at3, text) => {
|
|
78614
78614
|
edits.push([at3, at3, text]);
|
|
78615
78615
|
};
|
|
78616
|
+
const closings = [];
|
|
78617
|
+
const close2 = (at3, text) => {
|
|
78618
|
+
closings.push([at3, at3, text]);
|
|
78619
|
+
};
|
|
78616
78620
|
const isFunction = (node) => node.type === "FunctionDeclaration" || node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression";
|
|
78617
78621
|
const visit = (node, framed, parent) => {
|
|
78618
78622
|
const leading = [];
|
|
@@ -78624,7 +78628,7 @@ function __substrateFollowAwaits(code2) {
|
|
|
78624
78628
|
}
|
|
78625
78629
|
} else if (node.type === "AwaitExpression") {
|
|
78626
78630
|
insert(node.start, framed ? FOLLOW_RESUME_FRAMED : FOLLOW_RESUME_TAKEN);
|
|
78627
|
-
|
|
78631
|
+
close2(node.end, `${FOLLOW_MARK})`);
|
|
78628
78632
|
} else if (framed && node.type === "CatchClause") {
|
|
78629
78633
|
leading.push([node.body.start + 1, FOLLOW_RESTORE]);
|
|
78630
78634
|
} else if (framed && node.type === "TryStatement" && node.finalizer) {
|
|
@@ -78632,11 +78636,11 @@ function __substrateFollowAwaits(code2) {
|
|
|
78632
78636
|
} else if (framed && node.type === "ForOfStatement" && node.await) {
|
|
78633
78637
|
const whole = (parent == null ? void 0 : parent.type) === "LabeledStatement" ? parent : node;
|
|
78634
78638
|
insert(whole.start, `{${FOLLOW_MARK}`);
|
|
78635
|
-
|
|
78639
|
+
close2(whole.end, `;${FOLLOW_RESTORE}${FOLLOW_MARK}}`);
|
|
78636
78640
|
if (node.body.type === "BlockStatement") leading.push([node.body.start + 1, FOLLOW_RESTORE]);
|
|
78637
78641
|
else {
|
|
78638
78642
|
leading.push([node.body.start, `{${FOLLOW_MARK}${FOLLOW_RESTORE}`]);
|
|
78639
|
-
|
|
78643
|
+
close2(node.body.end, `${FOLLOW_MARK}}`);
|
|
78640
78644
|
}
|
|
78641
78645
|
}
|
|
78642
78646
|
for (const key of Object.keys(node)) {
|
|
@@ -78650,7 +78654,7 @@ function __substrateFollowAwaits(code2) {
|
|
|
78650
78654
|
for (const [at3, text] of leading) insert(at3, text);
|
|
78651
78655
|
};
|
|
78652
78656
|
visit(ast, false, void 0);
|
|
78653
|
-
const followed = edits.length ? applyReplacements(code2, edits) : code2;
|
|
78657
|
+
const followed = edits.length || closings.length ? applyReplacements(code2, [...edits, ...closings]) : code2;
|
|
78654
78658
|
return __substrateTopLevelAwait(ast) ? `${followed}
|
|
78655
78659
|
${__substrateTopLevelAwaitMarker}` : followed;
|
|
78656
78660
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -38271,6 +38271,10 @@ function __substrateFollowAwaits(code2) {
|
|
|
38271
38271
|
const insert = (at2, text) => {
|
|
38272
38272
|
edits.push([at2, at2, text]);
|
|
38273
38273
|
};
|
|
38274
|
+
const closings = [];
|
|
38275
|
+
const close2 = (at2, text) => {
|
|
38276
|
+
closings.push([at2, at2, text]);
|
|
38277
|
+
};
|
|
38274
38278
|
const isFunction = (node) => node.type === "FunctionDeclaration" || node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression";
|
|
38275
38279
|
const visit = (node, framed, parent) => {
|
|
38276
38280
|
const leading = [];
|
|
@@ -38282,7 +38286,7 @@ function __substrateFollowAwaits(code2) {
|
|
|
38282
38286
|
}
|
|
38283
38287
|
} else if (node.type === "AwaitExpression") {
|
|
38284
38288
|
insert(node.start, framed ? FOLLOW_RESUME_FRAMED : FOLLOW_RESUME_TAKEN);
|
|
38285
|
-
|
|
38289
|
+
close2(node.end, `${FOLLOW_MARK})`);
|
|
38286
38290
|
} else if (framed && node.type === "CatchClause") {
|
|
38287
38291
|
leading.push([node.body.start + 1, FOLLOW_RESTORE]);
|
|
38288
38292
|
} else if (framed && node.type === "TryStatement" && node.finalizer) {
|
|
@@ -38290,11 +38294,11 @@ function __substrateFollowAwaits(code2) {
|
|
|
38290
38294
|
} else if (framed && node.type === "ForOfStatement" && node.await) {
|
|
38291
38295
|
const whole = (parent == null ? void 0 : parent.type) === "LabeledStatement" ? parent : node;
|
|
38292
38296
|
insert(whole.start, `{${FOLLOW_MARK}`);
|
|
38293
|
-
|
|
38297
|
+
close2(whole.end, `;${FOLLOW_RESTORE}${FOLLOW_MARK}}`);
|
|
38294
38298
|
if (node.body.type === "BlockStatement") leading.push([node.body.start + 1, FOLLOW_RESTORE]);
|
|
38295
38299
|
else {
|
|
38296
38300
|
leading.push([node.body.start, `{${FOLLOW_MARK}${FOLLOW_RESTORE}`]);
|
|
38297
|
-
|
|
38301
|
+
close2(node.body.end, `${FOLLOW_MARK}}`);
|
|
38298
38302
|
}
|
|
38299
38303
|
}
|
|
38300
38304
|
for (const key of Object.keys(node)) {
|
|
@@ -38308,7 +38312,7 @@ function __substrateFollowAwaits(code2) {
|
|
|
38308
38312
|
for (const [at2, text] of leading) insert(at2, text);
|
|
38309
38313
|
};
|
|
38310
38314
|
visit(ast, false, void 0);
|
|
38311
|
-
const followed = edits.length ? applyReplacements(code2, edits) : code2;
|
|
38315
|
+
const followed = edits.length || closings.length ? applyReplacements(code2, [...edits, ...closings]) : code2;
|
|
38312
38316
|
return __substrateTopLevelAwait(ast) ? `${followed}
|
|
38313
38317
|
${__substrateTopLevelAwaitMarker}` : followed;
|
|
38314
38318
|
}
|
|
@@ -40334,7 +40338,7 @@ class WorkerRuntime {
|
|
|
40334
40338
|
this.worker = new Worker(
|
|
40335
40339
|
new URL(
|
|
40336
40340
|
/* @vite-ignore */
|
|
40337
|
-
"/assets/runtime-worker-
|
|
40341
|
+
"/assets/runtime-worker-BBHch2BO.js",
|
|
40338
40342
|
import.meta.url
|
|
40339
40343
|
),
|
|
40340
40344
|
{ type: "module" }
|
package/package.json
CHANGED
package/src/runtime.ts
CHANGED
|
@@ -465,6 +465,12 @@ function __substrateFollowAwaits(code: string): string {
|
|
|
465
465
|
}
|
|
466
466
|
const edits: Array<[number, number, string]> = [];
|
|
467
467
|
const insert = (at: number, text: string): void => { edits.push([at, at, text]); };
|
|
468
|
+
// What closes a node goes before what opens the next one at the same offset: a node that ends where another starts
|
|
469
|
+
// never holds it, so its closing lands first. `for await(x of y)await a;await b` ends the loop's body and starts the
|
|
470
|
+
// next statement's `await` at one offset, and the resume opened there landed inside the loop's brace: a SyntaxError
|
|
471
|
+
// in a 7 MB server chunk of Dub's (its web-stream pipe). Closings are kept apart and applied after, so they land first.
|
|
472
|
+
const closings: Array<[number, number, string]> = [];
|
|
473
|
+
const close = (at: number, text: string): void => { closings.push([at, at, text]); };
|
|
468
474
|
const isFunction = (node: any): boolean => node.type === 'FunctionDeclaration' || node.type === 'FunctionExpression' || node.type === 'ArrowFunctionExpression';
|
|
469
475
|
// `framed`: the nearest function is async and holds the frame in ASYNC_FRAME.
|
|
470
476
|
const visit = (node: any, framed: boolean, parent: any): void => {
|
|
@@ -484,7 +490,7 @@ function __substrateFollowAwaits(code: string): string {
|
|
|
484
490
|
}
|
|
485
491
|
} else if (node.type === 'AwaitExpression') {
|
|
486
492
|
insert(node.start, framed ? FOLLOW_RESUME_FRAMED : FOLLOW_RESUME_TAKEN);
|
|
487
|
-
|
|
493
|
+
close(node.end, `${FOLLOW_MARK})`);
|
|
488
494
|
} else if (framed && node.type === 'CatchClause') {
|
|
489
495
|
leading.push([node.body.start + 1, FOLLOW_RESTORE]);
|
|
490
496
|
} else if (framed && node.type === 'TryStatement' && node.finalizer) {
|
|
@@ -494,9 +500,9 @@ function __substrateFollowAwaits(code: string): string {
|
|
|
494
500
|
// made later lands before it, so the body's brace closes inside.
|
|
495
501
|
const whole = parent?.type === 'LabeledStatement' ? parent : node;
|
|
496
502
|
insert(whole.start, `{${FOLLOW_MARK}`);
|
|
497
|
-
|
|
503
|
+
close(whole.end, `;${FOLLOW_RESTORE}${FOLLOW_MARK}}`);
|
|
498
504
|
if (node.body.type === 'BlockStatement') leading.push([node.body.start + 1, FOLLOW_RESTORE]);
|
|
499
|
-
else { leading.push([node.body.start, `{${FOLLOW_MARK}${FOLLOW_RESTORE}`]);
|
|
505
|
+
else { leading.push([node.body.start, `{${FOLLOW_MARK}${FOLLOW_RESTORE}`]); close(node.body.end, `${FOLLOW_MARK}}`); }
|
|
500
506
|
}
|
|
501
507
|
for (const key of Object.keys(node)) {
|
|
502
508
|
if (key === 'type' || key === 'start' || key === 'end' || key === 'loc' || key === 'range') continue;
|
|
@@ -509,7 +515,8 @@ function __substrateFollowAwaits(code: string): string {
|
|
|
509
515
|
for (const [at, text] of leading) insert(at, text);
|
|
510
516
|
};
|
|
511
517
|
visit(ast, false, undefined);
|
|
512
|
-
|
|
518
|
+
// applyReplacements' sort is stable and lands edits at one offset in reverse of their order: closings after openings
|
|
519
|
+
const followed = edits.length || closings.length ? applyReplacements(code, [...edits, ...closings]) : code;
|
|
513
520
|
return __substrateTopLevelAwait(ast) ? `${followed}\n${__substrateTopLevelAwaitMarker}` : followed;
|
|
514
521
|
}
|
|
515
522
|
|