@danielx/civet 0.6.57 → 0.6.59
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/browser.js +123 -59
- package/dist/main.js +123 -59
- package/dist/main.mjs +123 -59
- package/package.json +1 -1
package/dist/browser.js
CHANGED
|
@@ -1131,12 +1131,12 @@ ${input.slice(result.pos)}
|
|
|
1131
1131
|
}
|
|
1132
1132
|
return node;
|
|
1133
1133
|
}
|
|
1134
|
-
function wrapIterationReturningResults(statement, outerRef) {
|
|
1134
|
+
function wrapIterationReturningResults(statement, outer, outerRef) {
|
|
1135
1135
|
if (statement.type === "DoStatement") {
|
|
1136
1136
|
if (outerRef) {
|
|
1137
1137
|
insertPush(statement.block, outerRef);
|
|
1138
1138
|
} else {
|
|
1139
|
-
insertReturn(statement.block);
|
|
1139
|
+
insertReturn(statement.block, outer);
|
|
1140
1140
|
}
|
|
1141
1141
|
return;
|
|
1142
1142
|
}
|
|
@@ -1146,7 +1146,7 @@ ${input.slice(result.pos)}
|
|
|
1146
1146
|
children: ["const ", resultsRef, "=[];"]
|
|
1147
1147
|
};
|
|
1148
1148
|
insertPush(statement.block, resultsRef);
|
|
1149
|
-
|
|
1149
|
+
outer.children.unshift(declaration);
|
|
1150
1150
|
if (outerRef) {
|
|
1151
1151
|
statement.children.push(";", outerRef, ".push(", resultsRef, ");");
|
|
1152
1152
|
} else {
|
|
@@ -1180,10 +1180,17 @@ ${input.slice(result.pos)}
|
|
|
1180
1180
|
}
|
|
1181
1181
|
if (!Array.isArray(node))
|
|
1182
1182
|
return;
|
|
1183
|
-
|
|
1184
|
-
if (!exp)
|
|
1183
|
+
let [, exp] = node;
|
|
1184
|
+
if (!exp) {
|
|
1185
1185
|
return;
|
|
1186
|
+
}
|
|
1186
1187
|
const indent = getIndent(node);
|
|
1188
|
+
const outer = exp;
|
|
1189
|
+
let { type } = exp;
|
|
1190
|
+
if (type === "LabelledStatement") {
|
|
1191
|
+
exp = exp.statement;
|
|
1192
|
+
({ type } = exp);
|
|
1193
|
+
}
|
|
1187
1194
|
switch (exp.type) {
|
|
1188
1195
|
case "BreakStatement":
|
|
1189
1196
|
case "ContinueStatement":
|
|
@@ -1204,7 +1211,7 @@ ${input.slice(result.pos)}
|
|
|
1204
1211
|
case "ForStatement":
|
|
1205
1212
|
case "IterationStatement":
|
|
1206
1213
|
case "DoStatement":
|
|
1207
|
-
wrapIterationReturningResults(exp, ref);
|
|
1214
|
+
wrapIterationReturningResults(exp, outer, ref);
|
|
1208
1215
|
return;
|
|
1209
1216
|
case "BlockStatement":
|
|
1210
1217
|
insertPush(exp.expressions[exp.expressions.length - 1], ref);
|
|
@@ -1573,7 +1580,7 @@ ${input.slice(result.pos)}
|
|
|
1573
1580
|
return pattern;
|
|
1574
1581
|
}
|
|
1575
1582
|
}
|
|
1576
|
-
function insertReturn(node) {
|
|
1583
|
+
function insertReturn(node, outerNode = node) {
|
|
1577
1584
|
if (!node)
|
|
1578
1585
|
return;
|
|
1579
1586
|
switch (node.type) {
|
|
@@ -1588,7 +1595,9 @@ ${input.slice(result.pos)}
|
|
|
1588
1595
|
}
|
|
1589
1596
|
return;
|
|
1590
1597
|
case "WhenClause":
|
|
1591
|
-
|
|
1598
|
+
if (node.break) {
|
|
1599
|
+
node.children.splice(node.children.indexOf(node.break), 1);
|
|
1600
|
+
}
|
|
1592
1601
|
if (node.block.expressions.length) {
|
|
1593
1602
|
insertReturn(node.block);
|
|
1594
1603
|
} else {
|
|
@@ -1601,12 +1610,20 @@ ${input.slice(result.pos)}
|
|
|
1601
1610
|
}
|
|
1602
1611
|
if (!Array.isArray(node))
|
|
1603
1612
|
return;
|
|
1604
|
-
|
|
1605
|
-
if (semi?.type === "SemicolonDelimiter")
|
|
1613
|
+
let [, exp, semi] = node;
|
|
1614
|
+
if (semi?.type === "SemicolonDelimiter") {
|
|
1606
1615
|
return;
|
|
1607
|
-
|
|
1616
|
+
}
|
|
1617
|
+
if (!exp) {
|
|
1608
1618
|
return;
|
|
1609
|
-
|
|
1619
|
+
}
|
|
1620
|
+
const outer = exp;
|
|
1621
|
+
let { type } = exp;
|
|
1622
|
+
if (type === "LabelledStatement") {
|
|
1623
|
+
exp = exp.statement;
|
|
1624
|
+
({ type } = exp);
|
|
1625
|
+
}
|
|
1626
|
+
switch (type) {
|
|
1610
1627
|
case "BreakStatement":
|
|
1611
1628
|
case "ContinueStatement":
|
|
1612
1629
|
case "DebuggerStatement":
|
|
@@ -1637,7 +1654,7 @@ ${input.slice(result.pos)}
|
|
|
1637
1654
|
case "ForStatement":
|
|
1638
1655
|
case "IterationStatement":
|
|
1639
1656
|
case "DoStatement":
|
|
1640
|
-
wrapIterationReturningResults(exp);
|
|
1657
|
+
wrapIterationReturningResults(exp, outer);
|
|
1641
1658
|
return;
|
|
1642
1659
|
case "BlockStatement":
|
|
1643
1660
|
insertReturn(exp.expressions[exp.expressions.length - 1]);
|
|
@@ -1690,6 +1707,9 @@ ${input.slice(result.pos)}
|
|
|
1690
1707
|
function isPromiseVoidType(t) {
|
|
1691
1708
|
return t?.type === "IdentifierType" && t.raw === "Promise" && t.args?.types?.length === 1 && isVoidType(t.args.types[0]);
|
|
1692
1709
|
}
|
|
1710
|
+
function isGeneratorVoidType(t) {
|
|
1711
|
+
return t?.type === "IdentifierType" && (t.raw === "Iterator" || t.raw === "Generator") && t.args?.types?.length >= 2 && isVoidType(t.args.types[1]);
|
|
1712
|
+
}
|
|
1693
1713
|
function isWhitespaceOrEmpty(node) {
|
|
1694
1714
|
if (!node)
|
|
1695
1715
|
return true;
|
|
@@ -1707,6 +1727,14 @@ ${input.slice(result.pos)}
|
|
|
1707
1727
|
return node.every(isWhitespaceOrEmpty);
|
|
1708
1728
|
return;
|
|
1709
1729
|
}
|
|
1730
|
+
function isExit(node) {
|
|
1731
|
+
return [
|
|
1732
|
+
"ReturnStatement",
|
|
1733
|
+
"ThrowStatement",
|
|
1734
|
+
"BreakStatement",
|
|
1735
|
+
"ContinueStatement"
|
|
1736
|
+
].includes(node?.type);
|
|
1737
|
+
}
|
|
1710
1738
|
function gatherRecursiveWithinFunction(node, predicate) {
|
|
1711
1739
|
return gatherRecursive(node, predicate, isFunction);
|
|
1712
1740
|
}
|
|
@@ -2397,9 +2425,7 @@ ${input.slice(result.pos)}
|
|
|
2397
2425
|
case "IterationStatement": {
|
|
2398
2426
|
const { children, block } = s;
|
|
2399
2427
|
const newBlock = blockWithPrefix(condition.expression.blockPrefix, block);
|
|
2400
|
-
s.children = children.map(
|
|
2401
|
-
return c.type === "BlockStatement" ? newBlock : c;
|
|
2402
|
-
});
|
|
2428
|
+
s.children = children.map((c) => c?.type === "BlockStatement" ? newBlock : c);
|
|
2403
2429
|
updateParentPointers(newBlock, s);
|
|
2404
2430
|
break;
|
|
2405
2431
|
}
|
|
@@ -2477,10 +2503,10 @@ ${input.slice(result.pos)}
|
|
|
2477
2503
|
if (!processReturnValue(f) && implicitReturns) {
|
|
2478
2504
|
const { signature, block } = f;
|
|
2479
2505
|
const { modifier, name, returnType } = signature;
|
|
2480
|
-
const { async, set } = modifier;
|
|
2506
|
+
const { async, generator, set } = modifier;
|
|
2481
2507
|
const isMethod = f.type === "MethodDefinition";
|
|
2482
2508
|
const isConstructor = isMethod && name === "constructor";
|
|
2483
|
-
const isVoid = isVoidType(returnType?.t) || async && isPromiseVoidType(returnType?.t);
|
|
2509
|
+
const isVoid = isVoidType(returnType?.t) || async && isPromiseVoidType(returnType?.t) || !async && generator && isGeneratorVoidType(returnType?.t);
|
|
2484
2510
|
const isBlock = block?.type === "BlockStatement";
|
|
2485
2511
|
if (!isVoid && !set && !isConstructor && isBlock) {
|
|
2486
2512
|
insertReturn(block);
|
|
@@ -2947,6 +2973,15 @@ ${input.slice(result.pos)}
|
|
|
2947
2973
|
gatherRecursiveAll(statements, (n) => n.type === "SwitchStatement").forEach((s) => {
|
|
2948
2974
|
const { caseBlock } = s;
|
|
2949
2975
|
const { clauses } = caseBlock;
|
|
2976
|
+
for (const c of clauses) {
|
|
2977
|
+
if (c.type === "WhenClause" && c.break) {
|
|
2978
|
+
const last = c.block?.expressions?.at(-1)?.[1];
|
|
2979
|
+
if (isExit(last)) {
|
|
2980
|
+
c.children.splice(c.children.indexOf(c.break), 1);
|
|
2981
|
+
c.break = void 0;
|
|
2982
|
+
}
|
|
2983
|
+
}
|
|
2984
|
+
}
|
|
2950
2985
|
let errors = false;
|
|
2951
2986
|
let isPattern = false;
|
|
2952
2987
|
if (clauses.some((c) => c.type === "PatternClause")) {
|
|
@@ -3575,20 +3610,29 @@ ${input.slice(result.pos)}
|
|
|
3575
3610
|
};
|
|
3576
3611
|
}
|
|
3577
3612
|
function replaceNodes(root, predicate, replacer) {
|
|
3578
|
-
if (root
|
|
3613
|
+
if (!(root != null)) {
|
|
3579
3614
|
return root;
|
|
3615
|
+
}
|
|
3580
3616
|
const array = Array.isArray(root) ? root : root.children;
|
|
3581
|
-
if (!array)
|
|
3582
|
-
|
|
3583
|
-
|
|
3584
|
-
|
|
3617
|
+
if (!array) {
|
|
3618
|
+
if (predicate(root)) {
|
|
3619
|
+
return replacer(root, root);
|
|
3620
|
+
} else {
|
|
3621
|
+
return root;
|
|
3622
|
+
}
|
|
3623
|
+
}
|
|
3624
|
+
for (let i4 = 0, len4 = array.length; i4 < len4; i4++) {
|
|
3625
|
+
const i = i4;
|
|
3626
|
+
const node = array[i4];
|
|
3627
|
+
if (!(node != null)) {
|
|
3585
3628
|
return;
|
|
3629
|
+
}
|
|
3586
3630
|
if (predicate(node)) {
|
|
3587
|
-
|
|
3631
|
+
array[i] = replacer(node, root);
|
|
3588
3632
|
} else {
|
|
3589
|
-
|
|
3633
|
+
replaceNodes(node, predicate, replacer);
|
|
3590
3634
|
}
|
|
3591
|
-
}
|
|
3635
|
+
}
|
|
3592
3636
|
return root;
|
|
3593
3637
|
}
|
|
3594
3638
|
function skipIfOnlyWS(target) {
|
|
@@ -5997,33 +6041,8 @@ ${input.slice(result.pos)}
|
|
|
5997
6041
|
expression
|
|
5998
6042
|
};
|
|
5999
6043
|
});
|
|
6000
|
-
var MemberBracketContent$1 = $TS($S(Dot, $C(TemplateLiteral, StringLiteral, IntegerLiteral)), function($skip, $loc, $0, $1, $2) {
|
|
6001
|
-
var dot = $1;
|
|
6002
|
-
var literal = $2;
|
|
6003
|
-
if (Array.isArray(dot))
|
|
6004
|
-
dot = dot[0];
|
|
6005
|
-
return {
|
|
6006
|
-
type: "Index",
|
|
6007
|
-
children: [
|
|
6008
|
-
{ token: "[", $loc: dot.$loc },
|
|
6009
|
-
literal,
|
|
6010
|
-
"]"
|
|
6011
|
-
]
|
|
6012
|
-
};
|
|
6013
|
-
});
|
|
6014
|
-
var MemberBracketContent$2 = $TS($S(Dot, $EXPECT($L19, 'MemberBracketContent "-"'), IntegerLiteral), function($skip, $loc, $0, $1, $2, $3) {
|
|
6015
|
-
var dot = $1;
|
|
6016
|
-
var neg = $2;
|
|
6017
|
-
var num = $3;
|
|
6018
|
-
return [
|
|
6019
|
-
{ type: "PropertyAccess", children: [dot, "at"] },
|
|
6020
|
-
// not including `name` so that `{x.-1}` doesn't use it
|
|
6021
|
-
{ type: "Call", children: ["(", neg, num, ")"] }
|
|
6022
|
-
];
|
|
6023
|
-
});
|
|
6024
|
-
var MemberBracketContent$$ = [MemberBracketContent$0, MemberBracketContent$1, MemberBracketContent$2];
|
|
6025
6044
|
function MemberBracketContent(ctx, state) {
|
|
6026
|
-
return $
|
|
6045
|
+
return $EVENT(ctx, state, "MemberBracketContent", MemberBracketContent$0);
|
|
6027
6046
|
}
|
|
6028
6047
|
var SliceParameters$0 = $TS($S(ExtendedExpression, __, $C(DotDotDot, DotDot), $E(ExtendedExpression)), function($skip, $loc, $0, $1, $2, $3, $4) {
|
|
6029
6048
|
var start = $1;
|
|
@@ -6103,7 +6122,34 @@ ${input.slice(result.pos)}
|
|
|
6103
6122
|
function PropertyAccessModifier(ctx, state) {
|
|
6104
6123
|
return $EVENT_C(ctx, state, "PropertyAccessModifier", PropertyAccessModifier$$);
|
|
6105
6124
|
}
|
|
6106
|
-
var PropertyAccess$0 = $TS($S(AccessStart, $
|
|
6125
|
+
var PropertyAccess$0 = $TS($S(AccessStart, $C(TemplateLiteral, StringLiteral, IntegerLiteral)), function($skip, $loc, $0, $1, $2) {
|
|
6126
|
+
var dot = $1;
|
|
6127
|
+
var literal = $2;
|
|
6128
|
+
dot = replaceNodes(
|
|
6129
|
+
deepCopy(dot),
|
|
6130
|
+
(node) => node.token === ".",
|
|
6131
|
+
(node) => ({ token: "[", $loc: node.$loc })
|
|
6132
|
+
);
|
|
6133
|
+
return {
|
|
6134
|
+
type: "Index",
|
|
6135
|
+
children: [
|
|
6136
|
+
dot,
|
|
6137
|
+
literal,
|
|
6138
|
+
"]"
|
|
6139
|
+
]
|
|
6140
|
+
};
|
|
6141
|
+
});
|
|
6142
|
+
var PropertyAccess$1 = $TS($S(AccessStart, $EXPECT($L19, 'PropertyAccess "-"'), IntegerLiteral), function($skip, $loc, $0, $1, $2, $3) {
|
|
6143
|
+
var dot = $1;
|
|
6144
|
+
var neg = $2;
|
|
6145
|
+
var num = $3;
|
|
6146
|
+
return [
|
|
6147
|
+
{ type: "PropertyAccess", children: [dot, "at"] },
|
|
6148
|
+
// not including `name` so that `{x.-1}` doesn't use it
|
|
6149
|
+
{ type: "Call", children: ["(", neg, num, ")"] }
|
|
6150
|
+
];
|
|
6151
|
+
});
|
|
6152
|
+
var PropertyAccess$2 = $TS($S(AccessStart, $Q(InlineComment), $C(IdentifierName, PrivateIdentifier)), function($skip, $loc, $0, $1, $2, $3) {
|
|
6107
6153
|
var access = $1;
|
|
6108
6154
|
var comments = $2;
|
|
6109
6155
|
var id = $3;
|
|
@@ -6114,7 +6160,7 @@ ${input.slice(result.pos)}
|
|
|
6114
6160
|
children
|
|
6115
6161
|
};
|
|
6116
6162
|
});
|
|
6117
|
-
var PropertyAccess$
|
|
6163
|
+
var PropertyAccess$3 = $TS($S(CoffeePrototypeEnabled, DoubleColon, $E(IdentifierName)), function($skip, $loc, $0, $1, $2, $3) {
|
|
6118
6164
|
var p = $2;
|
|
6119
6165
|
var id = $3;
|
|
6120
6166
|
if (id) {
|
|
@@ -6131,7 +6177,7 @@ ${input.slice(result.pos)}
|
|
|
6131
6177
|
};
|
|
6132
6178
|
}
|
|
6133
6179
|
});
|
|
6134
|
-
var PropertyAccess$$ = [PropertyAccess$0, PropertyAccess$1];
|
|
6180
|
+
var PropertyAccess$$ = [PropertyAccess$0, PropertyAccess$1, PropertyAccess$2, PropertyAccess$3];
|
|
6135
6181
|
function PropertyAccess(ctx, state) {
|
|
6136
6182
|
return $EVENT_C(ctx, state, "PropertyAccess", PropertyAccess$$);
|
|
6137
6183
|
}
|
|
@@ -6845,7 +6891,12 @@ ${input.slice(result.pos)}
|
|
|
6845
6891
|
return {
|
|
6846
6892
|
...fn,
|
|
6847
6893
|
id,
|
|
6848
|
-
children: [
|
|
6894
|
+
children: [
|
|
6895
|
+
...fn.children.slice(0, 3),
|
|
6896
|
+
insertTrimmingSpace(ws, " "),
|
|
6897
|
+
id,
|
|
6898
|
+
...fn.children.slice(3)
|
|
6899
|
+
]
|
|
6849
6900
|
};
|
|
6850
6901
|
});
|
|
6851
6902
|
var FunctionExpression$$ = [FunctionExpression$0, FunctionExpression$1, FunctionExpression$2, FunctionExpression$3];
|
|
@@ -8100,7 +8151,7 @@ ${input.slice(result.pos)}
|
|
|
8100
8151
|
var block = $3;
|
|
8101
8152
|
let children = $0;
|
|
8102
8153
|
let generatorPos = 0;
|
|
8103
|
-
|
|
8154
|
+
let { modifier } = signature;
|
|
8104
8155
|
if (hasAwait(block)) {
|
|
8105
8156
|
generatorPos++;
|
|
8106
8157
|
children = children.slice();
|
|
@@ -8112,6 +8163,8 @@ ${input.slice(result.pos)}
|
|
|
8112
8163
|
} else if (modifier?.async) {
|
|
8113
8164
|
} else {
|
|
8114
8165
|
children.unshift("async ");
|
|
8166
|
+
modifier = { ...modifier, async: true };
|
|
8167
|
+
signature = { ...signature, modifier };
|
|
8115
8168
|
}
|
|
8116
8169
|
}
|
|
8117
8170
|
if (hasYield(block)) {
|
|
@@ -8125,6 +8178,8 @@ ${input.slice(result.pos)}
|
|
|
8125
8178
|
} else if (modifier?.generator) {
|
|
8126
8179
|
} else {
|
|
8127
8180
|
children.splice(generatorPos, 0, "*");
|
|
8181
|
+
modifier = { ...modifier, generator: true };
|
|
8182
|
+
signature = { ...signature, modifier };
|
|
8128
8183
|
}
|
|
8129
8184
|
}
|
|
8130
8185
|
return {
|
|
@@ -8226,7 +8281,7 @@ ${input.slice(result.pos)}
|
|
|
8226
8281
|
async: true,
|
|
8227
8282
|
get: false,
|
|
8228
8283
|
set: false,
|
|
8229
|
-
generator: !!$
|
|
8284
|
+
generator: !!$2,
|
|
8230
8285
|
children: $0
|
|
8231
8286
|
};
|
|
8232
8287
|
});
|
|
@@ -8853,7 +8908,16 @@ ${input.slice(result.pos)}
|
|
|
8853
8908
|
function BlockStatement(ctx, state) {
|
|
8854
8909
|
return $EVENT(ctx, state, "BlockStatement", BlockStatement$0);
|
|
8855
8910
|
}
|
|
8856
|
-
var LabelledStatement$0 = $S(Label, LabelledItem)
|
|
8911
|
+
var LabelledStatement$0 = $TS($S(Label, LabelledItem), function($skip, $loc, $0, $1, $2) {
|
|
8912
|
+
var label = $1;
|
|
8913
|
+
var statement = $2;
|
|
8914
|
+
return {
|
|
8915
|
+
type: "LabelledStatement",
|
|
8916
|
+
label,
|
|
8917
|
+
statement,
|
|
8918
|
+
children: $0
|
|
8919
|
+
};
|
|
8920
|
+
});
|
|
8857
8921
|
function LabelledStatement(ctx, state) {
|
|
8858
8922
|
return $EVENT(ctx, state, "LabelledStatement", LabelledStatement$0);
|
|
8859
8923
|
}
|
package/dist/main.js
CHANGED
|
@@ -1123,12 +1123,12 @@ var require_lib = __commonJS({
|
|
|
1123
1123
|
}
|
|
1124
1124
|
return node;
|
|
1125
1125
|
}
|
|
1126
|
-
function wrapIterationReturningResults(statement, outerRef) {
|
|
1126
|
+
function wrapIterationReturningResults(statement, outer, outerRef) {
|
|
1127
1127
|
if (statement.type === "DoStatement") {
|
|
1128
1128
|
if (outerRef) {
|
|
1129
1129
|
insertPush(statement.block, outerRef);
|
|
1130
1130
|
} else {
|
|
1131
|
-
insertReturn(statement.block);
|
|
1131
|
+
insertReturn(statement.block, outer);
|
|
1132
1132
|
}
|
|
1133
1133
|
return;
|
|
1134
1134
|
}
|
|
@@ -1138,7 +1138,7 @@ var require_lib = __commonJS({
|
|
|
1138
1138
|
children: ["const ", resultsRef, "=[];"]
|
|
1139
1139
|
};
|
|
1140
1140
|
insertPush(statement.block, resultsRef);
|
|
1141
|
-
|
|
1141
|
+
outer.children.unshift(declaration);
|
|
1142
1142
|
if (outerRef) {
|
|
1143
1143
|
statement.children.push(";", outerRef, ".push(", resultsRef, ");");
|
|
1144
1144
|
} else {
|
|
@@ -1172,10 +1172,17 @@ var require_lib = __commonJS({
|
|
|
1172
1172
|
}
|
|
1173
1173
|
if (!Array.isArray(node))
|
|
1174
1174
|
return;
|
|
1175
|
-
|
|
1176
|
-
if (!exp)
|
|
1175
|
+
let [, exp] = node;
|
|
1176
|
+
if (!exp) {
|
|
1177
1177
|
return;
|
|
1178
|
+
}
|
|
1178
1179
|
const indent = getIndent(node);
|
|
1180
|
+
const outer = exp;
|
|
1181
|
+
let { type } = exp;
|
|
1182
|
+
if (type === "LabelledStatement") {
|
|
1183
|
+
exp = exp.statement;
|
|
1184
|
+
({ type } = exp);
|
|
1185
|
+
}
|
|
1179
1186
|
switch (exp.type) {
|
|
1180
1187
|
case "BreakStatement":
|
|
1181
1188
|
case "ContinueStatement":
|
|
@@ -1196,7 +1203,7 @@ var require_lib = __commonJS({
|
|
|
1196
1203
|
case "ForStatement":
|
|
1197
1204
|
case "IterationStatement":
|
|
1198
1205
|
case "DoStatement":
|
|
1199
|
-
wrapIterationReturningResults(exp, ref);
|
|
1206
|
+
wrapIterationReturningResults(exp, outer, ref);
|
|
1200
1207
|
return;
|
|
1201
1208
|
case "BlockStatement":
|
|
1202
1209
|
insertPush(exp.expressions[exp.expressions.length - 1], ref);
|
|
@@ -1565,7 +1572,7 @@ var require_lib = __commonJS({
|
|
|
1565
1572
|
return pattern;
|
|
1566
1573
|
}
|
|
1567
1574
|
}
|
|
1568
|
-
function insertReturn(node) {
|
|
1575
|
+
function insertReturn(node, outerNode = node) {
|
|
1569
1576
|
if (!node)
|
|
1570
1577
|
return;
|
|
1571
1578
|
switch (node.type) {
|
|
@@ -1580,7 +1587,9 @@ var require_lib = __commonJS({
|
|
|
1580
1587
|
}
|
|
1581
1588
|
return;
|
|
1582
1589
|
case "WhenClause":
|
|
1583
|
-
|
|
1590
|
+
if (node.break) {
|
|
1591
|
+
node.children.splice(node.children.indexOf(node.break), 1);
|
|
1592
|
+
}
|
|
1584
1593
|
if (node.block.expressions.length) {
|
|
1585
1594
|
insertReturn(node.block);
|
|
1586
1595
|
} else {
|
|
@@ -1593,12 +1602,20 @@ var require_lib = __commonJS({
|
|
|
1593
1602
|
}
|
|
1594
1603
|
if (!Array.isArray(node))
|
|
1595
1604
|
return;
|
|
1596
|
-
|
|
1597
|
-
if (semi?.type === "SemicolonDelimiter")
|
|
1605
|
+
let [, exp, semi] = node;
|
|
1606
|
+
if (semi?.type === "SemicolonDelimiter") {
|
|
1598
1607
|
return;
|
|
1599
|
-
|
|
1608
|
+
}
|
|
1609
|
+
if (!exp) {
|
|
1600
1610
|
return;
|
|
1601
|
-
|
|
1611
|
+
}
|
|
1612
|
+
const outer = exp;
|
|
1613
|
+
let { type } = exp;
|
|
1614
|
+
if (type === "LabelledStatement") {
|
|
1615
|
+
exp = exp.statement;
|
|
1616
|
+
({ type } = exp);
|
|
1617
|
+
}
|
|
1618
|
+
switch (type) {
|
|
1602
1619
|
case "BreakStatement":
|
|
1603
1620
|
case "ContinueStatement":
|
|
1604
1621
|
case "DebuggerStatement":
|
|
@@ -1629,7 +1646,7 @@ var require_lib = __commonJS({
|
|
|
1629
1646
|
case "ForStatement":
|
|
1630
1647
|
case "IterationStatement":
|
|
1631
1648
|
case "DoStatement":
|
|
1632
|
-
wrapIterationReturningResults(exp);
|
|
1649
|
+
wrapIterationReturningResults(exp, outer);
|
|
1633
1650
|
return;
|
|
1634
1651
|
case "BlockStatement":
|
|
1635
1652
|
insertReturn(exp.expressions[exp.expressions.length - 1]);
|
|
@@ -1682,6 +1699,9 @@ var require_lib = __commonJS({
|
|
|
1682
1699
|
function isPromiseVoidType(t) {
|
|
1683
1700
|
return t?.type === "IdentifierType" && t.raw === "Promise" && t.args?.types?.length === 1 && isVoidType(t.args.types[0]);
|
|
1684
1701
|
}
|
|
1702
|
+
function isGeneratorVoidType(t) {
|
|
1703
|
+
return t?.type === "IdentifierType" && (t.raw === "Iterator" || t.raw === "Generator") && t.args?.types?.length >= 2 && isVoidType(t.args.types[1]);
|
|
1704
|
+
}
|
|
1685
1705
|
function isWhitespaceOrEmpty(node) {
|
|
1686
1706
|
if (!node)
|
|
1687
1707
|
return true;
|
|
@@ -1699,6 +1719,14 @@ var require_lib = __commonJS({
|
|
|
1699
1719
|
return node.every(isWhitespaceOrEmpty);
|
|
1700
1720
|
return;
|
|
1701
1721
|
}
|
|
1722
|
+
function isExit(node) {
|
|
1723
|
+
return [
|
|
1724
|
+
"ReturnStatement",
|
|
1725
|
+
"ThrowStatement",
|
|
1726
|
+
"BreakStatement",
|
|
1727
|
+
"ContinueStatement"
|
|
1728
|
+
].includes(node?.type);
|
|
1729
|
+
}
|
|
1702
1730
|
function gatherRecursiveWithinFunction(node, predicate) {
|
|
1703
1731
|
return gatherRecursive(node, predicate, isFunction);
|
|
1704
1732
|
}
|
|
@@ -2389,9 +2417,7 @@ var require_lib = __commonJS({
|
|
|
2389
2417
|
case "IterationStatement": {
|
|
2390
2418
|
const { children, block } = s;
|
|
2391
2419
|
const newBlock = blockWithPrefix(condition.expression.blockPrefix, block);
|
|
2392
|
-
s.children = children.map(
|
|
2393
|
-
return c.type === "BlockStatement" ? newBlock : c;
|
|
2394
|
-
});
|
|
2420
|
+
s.children = children.map((c) => c?.type === "BlockStatement" ? newBlock : c);
|
|
2395
2421
|
updateParentPointers(newBlock, s);
|
|
2396
2422
|
break;
|
|
2397
2423
|
}
|
|
@@ -2469,10 +2495,10 @@ var require_lib = __commonJS({
|
|
|
2469
2495
|
if (!processReturnValue(f) && implicitReturns) {
|
|
2470
2496
|
const { signature, block } = f;
|
|
2471
2497
|
const { modifier, name, returnType } = signature;
|
|
2472
|
-
const { async, set } = modifier;
|
|
2498
|
+
const { async, generator, set } = modifier;
|
|
2473
2499
|
const isMethod = f.type === "MethodDefinition";
|
|
2474
2500
|
const isConstructor = isMethod && name === "constructor";
|
|
2475
|
-
const isVoid = isVoidType(returnType?.t) || async && isPromiseVoidType(returnType?.t);
|
|
2501
|
+
const isVoid = isVoidType(returnType?.t) || async && isPromiseVoidType(returnType?.t) || !async && generator && isGeneratorVoidType(returnType?.t);
|
|
2476
2502
|
const isBlock = block?.type === "BlockStatement";
|
|
2477
2503
|
if (!isVoid && !set && !isConstructor && isBlock) {
|
|
2478
2504
|
insertReturn(block);
|
|
@@ -2939,6 +2965,15 @@ var require_lib = __commonJS({
|
|
|
2939
2965
|
gatherRecursiveAll(statements, (n) => n.type === "SwitchStatement").forEach((s) => {
|
|
2940
2966
|
const { caseBlock } = s;
|
|
2941
2967
|
const { clauses } = caseBlock;
|
|
2968
|
+
for (const c of clauses) {
|
|
2969
|
+
if (c.type === "WhenClause" && c.break) {
|
|
2970
|
+
const last = c.block?.expressions?.at(-1)?.[1];
|
|
2971
|
+
if (isExit(last)) {
|
|
2972
|
+
c.children.splice(c.children.indexOf(c.break), 1);
|
|
2973
|
+
c.break = void 0;
|
|
2974
|
+
}
|
|
2975
|
+
}
|
|
2976
|
+
}
|
|
2942
2977
|
let errors = false;
|
|
2943
2978
|
let isPattern = false;
|
|
2944
2979
|
if (clauses.some((c) => c.type === "PatternClause")) {
|
|
@@ -3567,20 +3602,29 @@ var require_lib = __commonJS({
|
|
|
3567
3602
|
};
|
|
3568
3603
|
}
|
|
3569
3604
|
function replaceNodes(root, predicate, replacer) {
|
|
3570
|
-
if (root
|
|
3605
|
+
if (!(root != null)) {
|
|
3571
3606
|
return root;
|
|
3607
|
+
}
|
|
3572
3608
|
const array = Array.isArray(root) ? root : root.children;
|
|
3573
|
-
if (!array)
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
|
|
3609
|
+
if (!array) {
|
|
3610
|
+
if (predicate(root)) {
|
|
3611
|
+
return replacer(root, root);
|
|
3612
|
+
} else {
|
|
3613
|
+
return root;
|
|
3614
|
+
}
|
|
3615
|
+
}
|
|
3616
|
+
for (let i4 = 0, len4 = array.length; i4 < len4; i4++) {
|
|
3617
|
+
const i = i4;
|
|
3618
|
+
const node = array[i4];
|
|
3619
|
+
if (!(node != null)) {
|
|
3577
3620
|
return;
|
|
3621
|
+
}
|
|
3578
3622
|
if (predicate(node)) {
|
|
3579
|
-
|
|
3623
|
+
array[i] = replacer(node, root);
|
|
3580
3624
|
} else {
|
|
3581
|
-
|
|
3625
|
+
replaceNodes(node, predicate, replacer);
|
|
3582
3626
|
}
|
|
3583
|
-
}
|
|
3627
|
+
}
|
|
3584
3628
|
return root;
|
|
3585
3629
|
}
|
|
3586
3630
|
function skipIfOnlyWS(target) {
|
|
@@ -5989,33 +6033,8 @@ var require_parser = __commonJS({
|
|
|
5989
6033
|
expression
|
|
5990
6034
|
};
|
|
5991
6035
|
});
|
|
5992
|
-
var MemberBracketContent$1 = $TS($S(Dot, $C(TemplateLiteral, StringLiteral, IntegerLiteral)), function($skip, $loc, $0, $1, $2) {
|
|
5993
|
-
var dot = $1;
|
|
5994
|
-
var literal = $2;
|
|
5995
|
-
if (Array.isArray(dot))
|
|
5996
|
-
dot = dot[0];
|
|
5997
|
-
return {
|
|
5998
|
-
type: "Index",
|
|
5999
|
-
children: [
|
|
6000
|
-
{ token: "[", $loc: dot.$loc },
|
|
6001
|
-
literal,
|
|
6002
|
-
"]"
|
|
6003
|
-
]
|
|
6004
|
-
};
|
|
6005
|
-
});
|
|
6006
|
-
var MemberBracketContent$2 = $TS($S(Dot, $EXPECT($L19, 'MemberBracketContent "-"'), IntegerLiteral), function($skip, $loc, $0, $1, $2, $3) {
|
|
6007
|
-
var dot = $1;
|
|
6008
|
-
var neg = $2;
|
|
6009
|
-
var num = $3;
|
|
6010
|
-
return [
|
|
6011
|
-
{ type: "PropertyAccess", children: [dot, "at"] },
|
|
6012
|
-
// not including `name` so that `{x.-1}` doesn't use it
|
|
6013
|
-
{ type: "Call", children: ["(", neg, num, ")"] }
|
|
6014
|
-
];
|
|
6015
|
-
});
|
|
6016
|
-
var MemberBracketContent$$ = [MemberBracketContent$0, MemberBracketContent$1, MemberBracketContent$2];
|
|
6017
6036
|
function MemberBracketContent(ctx, state) {
|
|
6018
|
-
return $
|
|
6037
|
+
return $EVENT(ctx, state, "MemberBracketContent", MemberBracketContent$0);
|
|
6019
6038
|
}
|
|
6020
6039
|
var SliceParameters$0 = $TS($S(ExtendedExpression, __, $C(DotDotDot, DotDot), $E(ExtendedExpression)), function($skip, $loc, $0, $1, $2, $3, $4) {
|
|
6021
6040
|
var start = $1;
|
|
@@ -6095,7 +6114,34 @@ var require_parser = __commonJS({
|
|
|
6095
6114
|
function PropertyAccessModifier(ctx, state) {
|
|
6096
6115
|
return $EVENT_C(ctx, state, "PropertyAccessModifier", PropertyAccessModifier$$);
|
|
6097
6116
|
}
|
|
6098
|
-
var PropertyAccess$0 = $TS($S(AccessStart, $
|
|
6117
|
+
var PropertyAccess$0 = $TS($S(AccessStart, $C(TemplateLiteral, StringLiteral, IntegerLiteral)), function($skip, $loc, $0, $1, $2) {
|
|
6118
|
+
var dot = $1;
|
|
6119
|
+
var literal = $2;
|
|
6120
|
+
dot = replaceNodes(
|
|
6121
|
+
deepCopy(dot),
|
|
6122
|
+
(node) => node.token === ".",
|
|
6123
|
+
(node) => ({ token: "[", $loc: node.$loc })
|
|
6124
|
+
);
|
|
6125
|
+
return {
|
|
6126
|
+
type: "Index",
|
|
6127
|
+
children: [
|
|
6128
|
+
dot,
|
|
6129
|
+
literal,
|
|
6130
|
+
"]"
|
|
6131
|
+
]
|
|
6132
|
+
};
|
|
6133
|
+
});
|
|
6134
|
+
var PropertyAccess$1 = $TS($S(AccessStart, $EXPECT($L19, 'PropertyAccess "-"'), IntegerLiteral), function($skip, $loc, $0, $1, $2, $3) {
|
|
6135
|
+
var dot = $1;
|
|
6136
|
+
var neg = $2;
|
|
6137
|
+
var num = $3;
|
|
6138
|
+
return [
|
|
6139
|
+
{ type: "PropertyAccess", children: [dot, "at"] },
|
|
6140
|
+
// not including `name` so that `{x.-1}` doesn't use it
|
|
6141
|
+
{ type: "Call", children: ["(", neg, num, ")"] }
|
|
6142
|
+
];
|
|
6143
|
+
});
|
|
6144
|
+
var PropertyAccess$2 = $TS($S(AccessStart, $Q(InlineComment), $C(IdentifierName, PrivateIdentifier)), function($skip, $loc, $0, $1, $2, $3) {
|
|
6099
6145
|
var access = $1;
|
|
6100
6146
|
var comments = $2;
|
|
6101
6147
|
var id = $3;
|
|
@@ -6106,7 +6152,7 @@ var require_parser = __commonJS({
|
|
|
6106
6152
|
children
|
|
6107
6153
|
};
|
|
6108
6154
|
});
|
|
6109
|
-
var PropertyAccess$
|
|
6155
|
+
var PropertyAccess$3 = $TS($S(CoffeePrototypeEnabled, DoubleColon, $E(IdentifierName)), function($skip, $loc, $0, $1, $2, $3) {
|
|
6110
6156
|
var p = $2;
|
|
6111
6157
|
var id = $3;
|
|
6112
6158
|
if (id) {
|
|
@@ -6123,7 +6169,7 @@ var require_parser = __commonJS({
|
|
|
6123
6169
|
};
|
|
6124
6170
|
}
|
|
6125
6171
|
});
|
|
6126
|
-
var PropertyAccess$$ = [PropertyAccess$0, PropertyAccess$1];
|
|
6172
|
+
var PropertyAccess$$ = [PropertyAccess$0, PropertyAccess$1, PropertyAccess$2, PropertyAccess$3];
|
|
6127
6173
|
function PropertyAccess(ctx, state) {
|
|
6128
6174
|
return $EVENT_C(ctx, state, "PropertyAccess", PropertyAccess$$);
|
|
6129
6175
|
}
|
|
@@ -6837,7 +6883,12 @@ var require_parser = __commonJS({
|
|
|
6837
6883
|
return {
|
|
6838
6884
|
...fn,
|
|
6839
6885
|
id,
|
|
6840
|
-
children: [
|
|
6886
|
+
children: [
|
|
6887
|
+
...fn.children.slice(0, 3),
|
|
6888
|
+
insertTrimmingSpace(ws, " "),
|
|
6889
|
+
id,
|
|
6890
|
+
...fn.children.slice(3)
|
|
6891
|
+
]
|
|
6841
6892
|
};
|
|
6842
6893
|
});
|
|
6843
6894
|
var FunctionExpression$$ = [FunctionExpression$0, FunctionExpression$1, FunctionExpression$2, FunctionExpression$3];
|
|
@@ -8092,7 +8143,7 @@ var require_parser = __commonJS({
|
|
|
8092
8143
|
var block = $3;
|
|
8093
8144
|
let children = $0;
|
|
8094
8145
|
let generatorPos = 0;
|
|
8095
|
-
|
|
8146
|
+
let { modifier } = signature;
|
|
8096
8147
|
if (hasAwait(block)) {
|
|
8097
8148
|
generatorPos++;
|
|
8098
8149
|
children = children.slice();
|
|
@@ -8104,6 +8155,8 @@ var require_parser = __commonJS({
|
|
|
8104
8155
|
} else if (modifier?.async) {
|
|
8105
8156
|
} else {
|
|
8106
8157
|
children.unshift("async ");
|
|
8158
|
+
modifier = { ...modifier, async: true };
|
|
8159
|
+
signature = { ...signature, modifier };
|
|
8107
8160
|
}
|
|
8108
8161
|
}
|
|
8109
8162
|
if (hasYield(block)) {
|
|
@@ -8117,6 +8170,8 @@ var require_parser = __commonJS({
|
|
|
8117
8170
|
} else if (modifier?.generator) {
|
|
8118
8171
|
} else {
|
|
8119
8172
|
children.splice(generatorPos, 0, "*");
|
|
8173
|
+
modifier = { ...modifier, generator: true };
|
|
8174
|
+
signature = { ...signature, modifier };
|
|
8120
8175
|
}
|
|
8121
8176
|
}
|
|
8122
8177
|
return {
|
|
@@ -8218,7 +8273,7 @@ var require_parser = __commonJS({
|
|
|
8218
8273
|
async: true,
|
|
8219
8274
|
get: false,
|
|
8220
8275
|
set: false,
|
|
8221
|
-
generator: !!$
|
|
8276
|
+
generator: !!$2,
|
|
8222
8277
|
children: $0
|
|
8223
8278
|
};
|
|
8224
8279
|
});
|
|
@@ -8845,7 +8900,16 @@ var require_parser = __commonJS({
|
|
|
8845
8900
|
function BlockStatement(ctx, state) {
|
|
8846
8901
|
return $EVENT(ctx, state, "BlockStatement", BlockStatement$0);
|
|
8847
8902
|
}
|
|
8848
|
-
var LabelledStatement$0 = $S(Label, LabelledItem)
|
|
8903
|
+
var LabelledStatement$0 = $TS($S(Label, LabelledItem), function($skip, $loc, $0, $1, $2) {
|
|
8904
|
+
var label = $1;
|
|
8905
|
+
var statement = $2;
|
|
8906
|
+
return {
|
|
8907
|
+
type: "LabelledStatement",
|
|
8908
|
+
label,
|
|
8909
|
+
statement,
|
|
8910
|
+
children: $0
|
|
8911
|
+
};
|
|
8912
|
+
});
|
|
8849
8913
|
function LabelledStatement(ctx, state) {
|
|
8850
8914
|
return $EVENT(ctx, state, "LabelledStatement", LabelledStatement$0);
|
|
8851
8915
|
}
|
package/dist/main.mjs
CHANGED
|
@@ -1121,12 +1121,12 @@ var require_lib = __commonJS({
|
|
|
1121
1121
|
}
|
|
1122
1122
|
return node;
|
|
1123
1123
|
}
|
|
1124
|
-
function wrapIterationReturningResults(statement, outerRef) {
|
|
1124
|
+
function wrapIterationReturningResults(statement, outer, outerRef) {
|
|
1125
1125
|
if (statement.type === "DoStatement") {
|
|
1126
1126
|
if (outerRef) {
|
|
1127
1127
|
insertPush(statement.block, outerRef);
|
|
1128
1128
|
} else {
|
|
1129
|
-
insertReturn(statement.block);
|
|
1129
|
+
insertReturn(statement.block, outer);
|
|
1130
1130
|
}
|
|
1131
1131
|
return;
|
|
1132
1132
|
}
|
|
@@ -1136,7 +1136,7 @@ var require_lib = __commonJS({
|
|
|
1136
1136
|
children: ["const ", resultsRef, "=[];"]
|
|
1137
1137
|
};
|
|
1138
1138
|
insertPush(statement.block, resultsRef);
|
|
1139
|
-
|
|
1139
|
+
outer.children.unshift(declaration);
|
|
1140
1140
|
if (outerRef) {
|
|
1141
1141
|
statement.children.push(";", outerRef, ".push(", resultsRef, ");");
|
|
1142
1142
|
} else {
|
|
@@ -1170,10 +1170,17 @@ var require_lib = __commonJS({
|
|
|
1170
1170
|
}
|
|
1171
1171
|
if (!Array.isArray(node))
|
|
1172
1172
|
return;
|
|
1173
|
-
|
|
1174
|
-
if (!exp)
|
|
1173
|
+
let [, exp] = node;
|
|
1174
|
+
if (!exp) {
|
|
1175
1175
|
return;
|
|
1176
|
+
}
|
|
1176
1177
|
const indent = getIndent(node);
|
|
1178
|
+
const outer = exp;
|
|
1179
|
+
let { type } = exp;
|
|
1180
|
+
if (type === "LabelledStatement") {
|
|
1181
|
+
exp = exp.statement;
|
|
1182
|
+
({ type } = exp);
|
|
1183
|
+
}
|
|
1177
1184
|
switch (exp.type) {
|
|
1178
1185
|
case "BreakStatement":
|
|
1179
1186
|
case "ContinueStatement":
|
|
@@ -1194,7 +1201,7 @@ var require_lib = __commonJS({
|
|
|
1194
1201
|
case "ForStatement":
|
|
1195
1202
|
case "IterationStatement":
|
|
1196
1203
|
case "DoStatement":
|
|
1197
|
-
wrapIterationReturningResults(exp, ref);
|
|
1204
|
+
wrapIterationReturningResults(exp, outer, ref);
|
|
1198
1205
|
return;
|
|
1199
1206
|
case "BlockStatement":
|
|
1200
1207
|
insertPush(exp.expressions[exp.expressions.length - 1], ref);
|
|
@@ -1563,7 +1570,7 @@ var require_lib = __commonJS({
|
|
|
1563
1570
|
return pattern;
|
|
1564
1571
|
}
|
|
1565
1572
|
}
|
|
1566
|
-
function insertReturn(node) {
|
|
1573
|
+
function insertReturn(node, outerNode = node) {
|
|
1567
1574
|
if (!node)
|
|
1568
1575
|
return;
|
|
1569
1576
|
switch (node.type) {
|
|
@@ -1578,7 +1585,9 @@ var require_lib = __commonJS({
|
|
|
1578
1585
|
}
|
|
1579
1586
|
return;
|
|
1580
1587
|
case "WhenClause":
|
|
1581
|
-
|
|
1588
|
+
if (node.break) {
|
|
1589
|
+
node.children.splice(node.children.indexOf(node.break), 1);
|
|
1590
|
+
}
|
|
1582
1591
|
if (node.block.expressions.length) {
|
|
1583
1592
|
insertReturn(node.block);
|
|
1584
1593
|
} else {
|
|
@@ -1591,12 +1600,20 @@ var require_lib = __commonJS({
|
|
|
1591
1600
|
}
|
|
1592
1601
|
if (!Array.isArray(node))
|
|
1593
1602
|
return;
|
|
1594
|
-
|
|
1595
|
-
if (semi?.type === "SemicolonDelimiter")
|
|
1603
|
+
let [, exp, semi] = node;
|
|
1604
|
+
if (semi?.type === "SemicolonDelimiter") {
|
|
1596
1605
|
return;
|
|
1597
|
-
|
|
1606
|
+
}
|
|
1607
|
+
if (!exp) {
|
|
1598
1608
|
return;
|
|
1599
|
-
|
|
1609
|
+
}
|
|
1610
|
+
const outer = exp;
|
|
1611
|
+
let { type } = exp;
|
|
1612
|
+
if (type === "LabelledStatement") {
|
|
1613
|
+
exp = exp.statement;
|
|
1614
|
+
({ type } = exp);
|
|
1615
|
+
}
|
|
1616
|
+
switch (type) {
|
|
1600
1617
|
case "BreakStatement":
|
|
1601
1618
|
case "ContinueStatement":
|
|
1602
1619
|
case "DebuggerStatement":
|
|
@@ -1627,7 +1644,7 @@ var require_lib = __commonJS({
|
|
|
1627
1644
|
case "ForStatement":
|
|
1628
1645
|
case "IterationStatement":
|
|
1629
1646
|
case "DoStatement":
|
|
1630
|
-
wrapIterationReturningResults(exp);
|
|
1647
|
+
wrapIterationReturningResults(exp, outer);
|
|
1631
1648
|
return;
|
|
1632
1649
|
case "BlockStatement":
|
|
1633
1650
|
insertReturn(exp.expressions[exp.expressions.length - 1]);
|
|
@@ -1680,6 +1697,9 @@ var require_lib = __commonJS({
|
|
|
1680
1697
|
function isPromiseVoidType(t) {
|
|
1681
1698
|
return t?.type === "IdentifierType" && t.raw === "Promise" && t.args?.types?.length === 1 && isVoidType(t.args.types[0]);
|
|
1682
1699
|
}
|
|
1700
|
+
function isGeneratorVoidType(t) {
|
|
1701
|
+
return t?.type === "IdentifierType" && (t.raw === "Iterator" || t.raw === "Generator") && t.args?.types?.length >= 2 && isVoidType(t.args.types[1]);
|
|
1702
|
+
}
|
|
1683
1703
|
function isWhitespaceOrEmpty(node) {
|
|
1684
1704
|
if (!node)
|
|
1685
1705
|
return true;
|
|
@@ -1697,6 +1717,14 @@ var require_lib = __commonJS({
|
|
|
1697
1717
|
return node.every(isWhitespaceOrEmpty);
|
|
1698
1718
|
return;
|
|
1699
1719
|
}
|
|
1720
|
+
function isExit(node) {
|
|
1721
|
+
return [
|
|
1722
|
+
"ReturnStatement",
|
|
1723
|
+
"ThrowStatement",
|
|
1724
|
+
"BreakStatement",
|
|
1725
|
+
"ContinueStatement"
|
|
1726
|
+
].includes(node?.type);
|
|
1727
|
+
}
|
|
1700
1728
|
function gatherRecursiveWithinFunction(node, predicate) {
|
|
1701
1729
|
return gatherRecursive(node, predicate, isFunction);
|
|
1702
1730
|
}
|
|
@@ -2387,9 +2415,7 @@ var require_lib = __commonJS({
|
|
|
2387
2415
|
case "IterationStatement": {
|
|
2388
2416
|
const { children, block } = s;
|
|
2389
2417
|
const newBlock = blockWithPrefix(condition.expression.blockPrefix, block);
|
|
2390
|
-
s.children = children.map(
|
|
2391
|
-
return c.type === "BlockStatement" ? newBlock : c;
|
|
2392
|
-
});
|
|
2418
|
+
s.children = children.map((c) => c?.type === "BlockStatement" ? newBlock : c);
|
|
2393
2419
|
updateParentPointers(newBlock, s);
|
|
2394
2420
|
break;
|
|
2395
2421
|
}
|
|
@@ -2467,10 +2493,10 @@ var require_lib = __commonJS({
|
|
|
2467
2493
|
if (!processReturnValue(f) && implicitReturns) {
|
|
2468
2494
|
const { signature, block } = f;
|
|
2469
2495
|
const { modifier, name, returnType } = signature;
|
|
2470
|
-
const { async, set } = modifier;
|
|
2496
|
+
const { async, generator, set } = modifier;
|
|
2471
2497
|
const isMethod = f.type === "MethodDefinition";
|
|
2472
2498
|
const isConstructor = isMethod && name === "constructor";
|
|
2473
|
-
const isVoid = isVoidType(returnType?.t) || async && isPromiseVoidType(returnType?.t);
|
|
2499
|
+
const isVoid = isVoidType(returnType?.t) || async && isPromiseVoidType(returnType?.t) || !async && generator && isGeneratorVoidType(returnType?.t);
|
|
2474
2500
|
const isBlock = block?.type === "BlockStatement";
|
|
2475
2501
|
if (!isVoid && !set && !isConstructor && isBlock) {
|
|
2476
2502
|
insertReturn(block);
|
|
@@ -2937,6 +2963,15 @@ var require_lib = __commonJS({
|
|
|
2937
2963
|
gatherRecursiveAll(statements, (n) => n.type === "SwitchStatement").forEach((s) => {
|
|
2938
2964
|
const { caseBlock } = s;
|
|
2939
2965
|
const { clauses } = caseBlock;
|
|
2966
|
+
for (const c of clauses) {
|
|
2967
|
+
if (c.type === "WhenClause" && c.break) {
|
|
2968
|
+
const last = c.block?.expressions?.at(-1)?.[1];
|
|
2969
|
+
if (isExit(last)) {
|
|
2970
|
+
c.children.splice(c.children.indexOf(c.break), 1);
|
|
2971
|
+
c.break = void 0;
|
|
2972
|
+
}
|
|
2973
|
+
}
|
|
2974
|
+
}
|
|
2940
2975
|
let errors = false;
|
|
2941
2976
|
let isPattern = false;
|
|
2942
2977
|
if (clauses.some((c) => c.type === "PatternClause")) {
|
|
@@ -3565,20 +3600,29 @@ var require_lib = __commonJS({
|
|
|
3565
3600
|
};
|
|
3566
3601
|
}
|
|
3567
3602
|
function replaceNodes(root, predicate, replacer) {
|
|
3568
|
-
if (root
|
|
3603
|
+
if (!(root != null)) {
|
|
3569
3604
|
return root;
|
|
3605
|
+
}
|
|
3570
3606
|
const array = Array.isArray(root) ? root : root.children;
|
|
3571
|
-
if (!array)
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3607
|
+
if (!array) {
|
|
3608
|
+
if (predicate(root)) {
|
|
3609
|
+
return replacer(root, root);
|
|
3610
|
+
} else {
|
|
3611
|
+
return root;
|
|
3612
|
+
}
|
|
3613
|
+
}
|
|
3614
|
+
for (let i4 = 0, len4 = array.length; i4 < len4; i4++) {
|
|
3615
|
+
const i = i4;
|
|
3616
|
+
const node = array[i4];
|
|
3617
|
+
if (!(node != null)) {
|
|
3575
3618
|
return;
|
|
3619
|
+
}
|
|
3576
3620
|
if (predicate(node)) {
|
|
3577
|
-
|
|
3621
|
+
array[i] = replacer(node, root);
|
|
3578
3622
|
} else {
|
|
3579
|
-
|
|
3623
|
+
replaceNodes(node, predicate, replacer);
|
|
3580
3624
|
}
|
|
3581
|
-
}
|
|
3625
|
+
}
|
|
3582
3626
|
return root;
|
|
3583
3627
|
}
|
|
3584
3628
|
function skipIfOnlyWS(target) {
|
|
@@ -5987,33 +6031,8 @@ var require_parser = __commonJS({
|
|
|
5987
6031
|
expression
|
|
5988
6032
|
};
|
|
5989
6033
|
});
|
|
5990
|
-
var MemberBracketContent$1 = $TS($S(Dot, $C(TemplateLiteral, StringLiteral, IntegerLiteral)), function($skip, $loc, $0, $1, $2) {
|
|
5991
|
-
var dot = $1;
|
|
5992
|
-
var literal = $2;
|
|
5993
|
-
if (Array.isArray(dot))
|
|
5994
|
-
dot = dot[0];
|
|
5995
|
-
return {
|
|
5996
|
-
type: "Index",
|
|
5997
|
-
children: [
|
|
5998
|
-
{ token: "[", $loc: dot.$loc },
|
|
5999
|
-
literal,
|
|
6000
|
-
"]"
|
|
6001
|
-
]
|
|
6002
|
-
};
|
|
6003
|
-
});
|
|
6004
|
-
var MemberBracketContent$2 = $TS($S(Dot, $EXPECT($L19, 'MemberBracketContent "-"'), IntegerLiteral), function($skip, $loc, $0, $1, $2, $3) {
|
|
6005
|
-
var dot = $1;
|
|
6006
|
-
var neg = $2;
|
|
6007
|
-
var num = $3;
|
|
6008
|
-
return [
|
|
6009
|
-
{ type: "PropertyAccess", children: [dot, "at"] },
|
|
6010
|
-
// not including `name` so that `{x.-1}` doesn't use it
|
|
6011
|
-
{ type: "Call", children: ["(", neg, num, ")"] }
|
|
6012
|
-
];
|
|
6013
|
-
});
|
|
6014
|
-
var MemberBracketContent$$ = [MemberBracketContent$0, MemberBracketContent$1, MemberBracketContent$2];
|
|
6015
6034
|
function MemberBracketContent(ctx, state) {
|
|
6016
|
-
return $
|
|
6035
|
+
return $EVENT(ctx, state, "MemberBracketContent", MemberBracketContent$0);
|
|
6017
6036
|
}
|
|
6018
6037
|
var SliceParameters$0 = $TS($S(ExtendedExpression, __, $C(DotDotDot, DotDot), $E(ExtendedExpression)), function($skip, $loc, $0, $1, $2, $3, $4) {
|
|
6019
6038
|
var start = $1;
|
|
@@ -6093,7 +6112,34 @@ var require_parser = __commonJS({
|
|
|
6093
6112
|
function PropertyAccessModifier(ctx, state) {
|
|
6094
6113
|
return $EVENT_C(ctx, state, "PropertyAccessModifier", PropertyAccessModifier$$);
|
|
6095
6114
|
}
|
|
6096
|
-
var PropertyAccess$0 = $TS($S(AccessStart, $
|
|
6115
|
+
var PropertyAccess$0 = $TS($S(AccessStart, $C(TemplateLiteral, StringLiteral, IntegerLiteral)), function($skip, $loc, $0, $1, $2) {
|
|
6116
|
+
var dot = $1;
|
|
6117
|
+
var literal = $2;
|
|
6118
|
+
dot = replaceNodes(
|
|
6119
|
+
deepCopy(dot),
|
|
6120
|
+
(node) => node.token === ".",
|
|
6121
|
+
(node) => ({ token: "[", $loc: node.$loc })
|
|
6122
|
+
);
|
|
6123
|
+
return {
|
|
6124
|
+
type: "Index",
|
|
6125
|
+
children: [
|
|
6126
|
+
dot,
|
|
6127
|
+
literal,
|
|
6128
|
+
"]"
|
|
6129
|
+
]
|
|
6130
|
+
};
|
|
6131
|
+
});
|
|
6132
|
+
var PropertyAccess$1 = $TS($S(AccessStart, $EXPECT($L19, 'PropertyAccess "-"'), IntegerLiteral), function($skip, $loc, $0, $1, $2, $3) {
|
|
6133
|
+
var dot = $1;
|
|
6134
|
+
var neg = $2;
|
|
6135
|
+
var num = $3;
|
|
6136
|
+
return [
|
|
6137
|
+
{ type: "PropertyAccess", children: [dot, "at"] },
|
|
6138
|
+
// not including `name` so that `{x.-1}` doesn't use it
|
|
6139
|
+
{ type: "Call", children: ["(", neg, num, ")"] }
|
|
6140
|
+
];
|
|
6141
|
+
});
|
|
6142
|
+
var PropertyAccess$2 = $TS($S(AccessStart, $Q(InlineComment), $C(IdentifierName, PrivateIdentifier)), function($skip, $loc, $0, $1, $2, $3) {
|
|
6097
6143
|
var access = $1;
|
|
6098
6144
|
var comments = $2;
|
|
6099
6145
|
var id = $3;
|
|
@@ -6104,7 +6150,7 @@ var require_parser = __commonJS({
|
|
|
6104
6150
|
children
|
|
6105
6151
|
};
|
|
6106
6152
|
});
|
|
6107
|
-
var PropertyAccess$
|
|
6153
|
+
var PropertyAccess$3 = $TS($S(CoffeePrototypeEnabled, DoubleColon, $E(IdentifierName)), function($skip, $loc, $0, $1, $2, $3) {
|
|
6108
6154
|
var p = $2;
|
|
6109
6155
|
var id = $3;
|
|
6110
6156
|
if (id) {
|
|
@@ -6121,7 +6167,7 @@ var require_parser = __commonJS({
|
|
|
6121
6167
|
};
|
|
6122
6168
|
}
|
|
6123
6169
|
});
|
|
6124
|
-
var PropertyAccess$$ = [PropertyAccess$0, PropertyAccess$1];
|
|
6170
|
+
var PropertyAccess$$ = [PropertyAccess$0, PropertyAccess$1, PropertyAccess$2, PropertyAccess$3];
|
|
6125
6171
|
function PropertyAccess(ctx, state) {
|
|
6126
6172
|
return $EVENT_C(ctx, state, "PropertyAccess", PropertyAccess$$);
|
|
6127
6173
|
}
|
|
@@ -6835,7 +6881,12 @@ var require_parser = __commonJS({
|
|
|
6835
6881
|
return {
|
|
6836
6882
|
...fn,
|
|
6837
6883
|
id,
|
|
6838
|
-
children: [
|
|
6884
|
+
children: [
|
|
6885
|
+
...fn.children.slice(0, 3),
|
|
6886
|
+
insertTrimmingSpace(ws, " "),
|
|
6887
|
+
id,
|
|
6888
|
+
...fn.children.slice(3)
|
|
6889
|
+
]
|
|
6839
6890
|
};
|
|
6840
6891
|
});
|
|
6841
6892
|
var FunctionExpression$$ = [FunctionExpression$0, FunctionExpression$1, FunctionExpression$2, FunctionExpression$3];
|
|
@@ -8090,7 +8141,7 @@ var require_parser = __commonJS({
|
|
|
8090
8141
|
var block = $3;
|
|
8091
8142
|
let children = $0;
|
|
8092
8143
|
let generatorPos = 0;
|
|
8093
|
-
|
|
8144
|
+
let { modifier } = signature;
|
|
8094
8145
|
if (hasAwait(block)) {
|
|
8095
8146
|
generatorPos++;
|
|
8096
8147
|
children = children.slice();
|
|
@@ -8102,6 +8153,8 @@ var require_parser = __commonJS({
|
|
|
8102
8153
|
} else if (modifier?.async) {
|
|
8103
8154
|
} else {
|
|
8104
8155
|
children.unshift("async ");
|
|
8156
|
+
modifier = { ...modifier, async: true };
|
|
8157
|
+
signature = { ...signature, modifier };
|
|
8105
8158
|
}
|
|
8106
8159
|
}
|
|
8107
8160
|
if (hasYield(block)) {
|
|
@@ -8115,6 +8168,8 @@ var require_parser = __commonJS({
|
|
|
8115
8168
|
} else if (modifier?.generator) {
|
|
8116
8169
|
} else {
|
|
8117
8170
|
children.splice(generatorPos, 0, "*");
|
|
8171
|
+
modifier = { ...modifier, generator: true };
|
|
8172
|
+
signature = { ...signature, modifier };
|
|
8118
8173
|
}
|
|
8119
8174
|
}
|
|
8120
8175
|
return {
|
|
@@ -8216,7 +8271,7 @@ var require_parser = __commonJS({
|
|
|
8216
8271
|
async: true,
|
|
8217
8272
|
get: false,
|
|
8218
8273
|
set: false,
|
|
8219
|
-
generator: !!$
|
|
8274
|
+
generator: !!$2,
|
|
8220
8275
|
children: $0
|
|
8221
8276
|
};
|
|
8222
8277
|
});
|
|
@@ -8843,7 +8898,16 @@ var require_parser = __commonJS({
|
|
|
8843
8898
|
function BlockStatement(ctx, state) {
|
|
8844
8899
|
return $EVENT(ctx, state, "BlockStatement", BlockStatement$0);
|
|
8845
8900
|
}
|
|
8846
|
-
var LabelledStatement$0 = $S(Label, LabelledItem)
|
|
8901
|
+
var LabelledStatement$0 = $TS($S(Label, LabelledItem), function($skip, $loc, $0, $1, $2) {
|
|
8902
|
+
var label = $1;
|
|
8903
|
+
var statement = $2;
|
|
8904
|
+
return {
|
|
8905
|
+
type: "LabelledStatement",
|
|
8906
|
+
label,
|
|
8907
|
+
statement,
|
|
8908
|
+
children: $0
|
|
8909
|
+
};
|
|
8910
|
+
});
|
|
8847
8911
|
function LabelledStatement(ctx, state) {
|
|
8848
8912
|
return $EVENT(ctx, state, "LabelledStatement", LabelledStatement$0);
|
|
8849
8913
|
}
|