@danielx/civet 0.6.14 → 0.6.16
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 +173 -66
- package/dist/main.js +173 -66
- package/dist/main.mjs +173 -66
- package/package.json +1 -1
package/dist/browser.js
CHANGED
|
@@ -745,12 +745,15 @@ var Civet = (() => {
|
|
|
745
745
|
}
|
|
746
746
|
}
|
|
747
747
|
function findAncestor(node, predicate, stopPredicate) {
|
|
748
|
-
|
|
749
|
-
while (
|
|
750
|
-
if (predicate(node))
|
|
751
|
-
return node;
|
|
752
|
-
|
|
748
|
+
let { parent } = node;
|
|
749
|
+
while (parent && !stopPredicate?.(parent, node)) {
|
|
750
|
+
if (predicate(parent, node)) {
|
|
751
|
+
return { ancestor: parent, child: node };
|
|
752
|
+
}
|
|
753
|
+
node = parent;
|
|
754
|
+
parent = node.parent;
|
|
753
755
|
}
|
|
756
|
+
return { ancestor: void 0, child: node };
|
|
754
757
|
}
|
|
755
758
|
function gatherNodes(node, predicate) {
|
|
756
759
|
if (node == null)
|
|
@@ -823,14 +826,11 @@ var Civet = (() => {
|
|
|
823
826
|
}
|
|
824
827
|
function hoistRefDecs(statements) {
|
|
825
828
|
gatherRecursiveAll(statements, (s) => s.hoistDec).forEach((node) => {
|
|
826
|
-
let { hoistDec
|
|
829
|
+
let { hoistDec } = node;
|
|
827
830
|
node.hoistDec = null;
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
}
|
|
832
|
-
if (parent) {
|
|
833
|
-
insertHoistDec(parent, node, hoistDec);
|
|
831
|
+
const { ancestor, child } = findAncestor(node, (ancestor2) => ancestor2.type === "BlockStatement" && (!ancestor2.bare || ancestor2.root));
|
|
832
|
+
if (ancestor) {
|
|
833
|
+
insertHoistDec(ancestor, child, hoistDec);
|
|
834
834
|
} else {
|
|
835
835
|
throw new Error("Couldn't find block to hoist declaration into.");
|
|
836
836
|
}
|
|
@@ -1148,6 +1148,7 @@ var Civet = (() => {
|
|
|
1148
1148
|
case "AmpersandRef":
|
|
1149
1149
|
case "Identifier":
|
|
1150
1150
|
case "Literal":
|
|
1151
|
+
case "IterationExpression":
|
|
1151
1152
|
case "CallExpression":
|
|
1152
1153
|
case "MemberExpression":
|
|
1153
1154
|
case "ParenthesizedExpression":
|
|
@@ -1369,6 +1370,8 @@ var Civet = (() => {
|
|
|
1369
1370
|
if (f.abstract || f.block || f.signature?.optional)
|
|
1370
1371
|
return;
|
|
1371
1372
|
const { name, parent } = f;
|
|
1373
|
+
if (parent?.type === "ExportDeclaration")
|
|
1374
|
+
return;
|
|
1372
1375
|
const expressions = parent?.expressions ?? parent?.elements;
|
|
1373
1376
|
const currentIndex = expressions?.findIndex(([, def]) => def === f);
|
|
1374
1377
|
const following = currentIndex >= 0 && expressions[currentIndex + 1]?.[1];
|
|
@@ -1424,6 +1427,46 @@ var Civet = (() => {
|
|
|
1424
1427
|
tail.push(...splices.map((s) => [", ", s]), ...thisAssignments.map((a) => [", ", a]));
|
|
1425
1428
|
}
|
|
1426
1429
|
function processAssignments(statements) {
|
|
1430
|
+
gatherRecursiveAll(statements, (n) => n.type === "AssignmentExpression" || n.type === "UpdateExpression").forEach((exp) => {
|
|
1431
|
+
function extractAssignment(lhs) {
|
|
1432
|
+
let expr = lhs;
|
|
1433
|
+
while (expr.type === "ParenthesizedExpression") {
|
|
1434
|
+
expr = expr.expression;
|
|
1435
|
+
}
|
|
1436
|
+
if (expr.type === "AssignmentExpression" || expr.type === "UpdateExpression") {
|
|
1437
|
+
if (expr.type === "UpdateExpression" && expr.children[0] === expr.assigned) {
|
|
1438
|
+
post.push([", ", lhs]);
|
|
1439
|
+
} else {
|
|
1440
|
+
pre.push([lhs, ", "]);
|
|
1441
|
+
}
|
|
1442
|
+
return expr.assigned;
|
|
1443
|
+
}
|
|
1444
|
+
}
|
|
1445
|
+
const pre = [], post = [];
|
|
1446
|
+
switch (exp.type) {
|
|
1447
|
+
case "AssignmentExpression":
|
|
1448
|
+
if (!exp.lhs)
|
|
1449
|
+
return;
|
|
1450
|
+
exp.lhs.forEach((lhsPart, i) => {
|
|
1451
|
+
let newLhs2 = extractAssignment(lhsPart[1]);
|
|
1452
|
+
if (newLhs2) {
|
|
1453
|
+
lhsPart[1] = newLhs2;
|
|
1454
|
+
}
|
|
1455
|
+
});
|
|
1456
|
+
break;
|
|
1457
|
+
case "UpdateExpression":
|
|
1458
|
+
let newLhs = extractAssignment(exp.assigned);
|
|
1459
|
+
if (newLhs) {
|
|
1460
|
+
const i = exp.children.indexOf(exp.assigned);
|
|
1461
|
+
exp.assigned = exp.children[i] = newLhs;
|
|
1462
|
+
}
|
|
1463
|
+
break;
|
|
1464
|
+
}
|
|
1465
|
+
if (pre.length)
|
|
1466
|
+
exp.children.unshift(...pre);
|
|
1467
|
+
if (post.length)
|
|
1468
|
+
exp.children.push(...post);
|
|
1469
|
+
});
|
|
1427
1470
|
gatherRecursiveAll(statements, (n) => n.type === "AssignmentExpression" && n.names === null).forEach((exp) => {
|
|
1428
1471
|
let { lhs: $1, exp: $2 } = exp, tail = [], i = 0, len = $1.length;
|
|
1429
1472
|
if ($1.some((left) => left[left.length - 1].special)) {
|
|
@@ -1433,7 +1476,14 @@ var Civet = (() => {
|
|
|
1433
1476
|
const [, lhs, , op] = $1[0];
|
|
1434
1477
|
const { call } = op;
|
|
1435
1478
|
op[op.length - 1] = "=";
|
|
1436
|
-
|
|
1479
|
+
const index2 = exp.children.indexOf($2);
|
|
1480
|
+
if (index2 < 0)
|
|
1481
|
+
throw new Error("Assertion error: exp not in AssignmentExpression");
|
|
1482
|
+
exp.children.splice(
|
|
1483
|
+
index2,
|
|
1484
|
+
1,
|
|
1485
|
+
exp.exp = $2 = [call, "(", lhs, ", ", $2, ")"]
|
|
1486
|
+
);
|
|
1437
1487
|
}
|
|
1438
1488
|
let wrapped = false;
|
|
1439
1489
|
while (i < len) {
|
|
@@ -1484,49 +1534,11 @@ var Civet = (() => {
|
|
|
1484
1534
|
}
|
|
1485
1535
|
i--;
|
|
1486
1536
|
}
|
|
1487
|
-
|
|
1488
|
-
exp.children
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
function extractAssignment(lhs) {
|
|
1493
|
-
let expr = lhs;
|
|
1494
|
-
while (expr.type === "ParenthesizedExpression") {
|
|
1495
|
-
expr = expr.expression;
|
|
1496
|
-
}
|
|
1497
|
-
if (expr.type === "AssignmentExpression" || expr.type === "UpdateExpression") {
|
|
1498
|
-
if (expr.type === "UpdateExpression" && expr.children[0] === expr.assigned) {
|
|
1499
|
-
post.push([", ", lhs]);
|
|
1500
|
-
} else {
|
|
1501
|
-
pre.push([lhs, ", "]);
|
|
1502
|
-
}
|
|
1503
|
-
return expr.assigned;
|
|
1504
|
-
}
|
|
1505
|
-
}
|
|
1506
|
-
const pre = [], post = [];
|
|
1507
|
-
switch (exp.type) {
|
|
1508
|
-
case "AssignmentExpression":
|
|
1509
|
-
if (!exp.lhs)
|
|
1510
|
-
return;
|
|
1511
|
-
exp.lhs.forEach((lhsPart, i) => {
|
|
1512
|
-
let newLhs2 = extractAssignment(lhsPart[1]);
|
|
1513
|
-
if (newLhs2) {
|
|
1514
|
-
lhsPart[1] = newLhs2;
|
|
1515
|
-
}
|
|
1516
|
-
});
|
|
1517
|
-
break;
|
|
1518
|
-
case "UpdateExpression":
|
|
1519
|
-
let newLhs = extractAssignment(exp.assigned);
|
|
1520
|
-
if (newLhs) {
|
|
1521
|
-
const i = exp.children.indexOf(exp.assigned);
|
|
1522
|
-
exp.assigned = exp.children[i] = newLhs;
|
|
1523
|
-
}
|
|
1524
|
-
break;
|
|
1525
|
-
}
|
|
1526
|
-
if (pre.length)
|
|
1527
|
-
exp.children.unshift(...pre);
|
|
1528
|
-
if (post.length)
|
|
1529
|
-
exp.children.push(...post);
|
|
1537
|
+
exp.names = $1.flatMap(([, l]) => l.names || []);
|
|
1538
|
+
const index = exp.children.indexOf($2);
|
|
1539
|
+
if (index < 0)
|
|
1540
|
+
throw new Error("Assertion error: exp not in AssignmentExpression");
|
|
1541
|
+
exp.children.splice(index + 1, 0, ...tail);
|
|
1530
1542
|
});
|
|
1531
1543
|
}
|
|
1532
1544
|
function attachPostfixStatementAsExpression(exp, post) {
|
|
@@ -1973,7 +1985,8 @@ var Civet = (() => {
|
|
|
1973
1985
|
});
|
|
1974
1986
|
}
|
|
1975
1987
|
} else {
|
|
1976
|
-
|
|
1988
|
+
if (i === 0)
|
|
1989
|
+
s.children = children;
|
|
1977
1990
|
}
|
|
1978
1991
|
if (returns && (ref = needsRef(arg))) {
|
|
1979
1992
|
usingRef = usingRef || ref;
|
|
@@ -2216,7 +2229,7 @@ var Civet = (() => {
|
|
|
2216
2229
|
let declared;
|
|
2217
2230
|
values.forEach((value) => {
|
|
2218
2231
|
value.children = [ref];
|
|
2219
|
-
const ancestor = findAncestor(
|
|
2232
|
+
const { ancestor } = findAncestor(
|
|
2220
2233
|
value,
|
|
2221
2234
|
({ type }) => type === "Declaration",
|
|
2222
2235
|
isFunction
|
|
@@ -2963,6 +2976,7 @@ ${input.slice(result.pos)}
|
|
|
2963
2976
|
NonPipelineExtendedExpression,
|
|
2964
2977
|
NonAssignmentExtendedExpression,
|
|
2965
2978
|
NestedNonAssignmentExtendedExpression,
|
|
2979
|
+
ExpressionizedStatementWithTrailingCallExpressions,
|
|
2966
2980
|
ExpressionizedStatement,
|
|
2967
2981
|
Expression,
|
|
2968
2982
|
Arguments,
|
|
@@ -2973,6 +2987,8 @@ ${input.slice(result.pos)}
|
|
|
2973
2987
|
ArgumentsWithTrailingMemberExpressions,
|
|
2974
2988
|
TrailingMemberExpressions,
|
|
2975
2989
|
AllowedTrailingMemberExpressions,
|
|
2990
|
+
TrailingCallExpressions,
|
|
2991
|
+
AllowedTrailingCallExpressions,
|
|
2976
2992
|
CommaDelimiter,
|
|
2977
2993
|
ArgumentList,
|
|
2978
2994
|
NonPipelineArgumentList,
|
|
@@ -4112,7 +4128,10 @@ ${input.slice(result.pos)}
|
|
|
4112
4128
|
}
|
|
4113
4129
|
}
|
|
4114
4130
|
var NonAssignmentExtendedExpression$0 = NestedNonAssignmentExtendedExpression;
|
|
4115
|
-
var NonAssignmentExtendedExpression$1 = $TS($S(__,
|
|
4131
|
+
var NonAssignmentExtendedExpression$1 = $TS($S(__, ExpressionizedStatementWithTrailingCallExpressions), function($skip, $loc, $0, $1, $2) {
|
|
4132
|
+
if ($2.length) {
|
|
4133
|
+
return [...$1, ...$2];
|
|
4134
|
+
}
|
|
4116
4135
|
return {
|
|
4117
4136
|
...$2,
|
|
4118
4137
|
children: [...$1, ...$2.children]
|
|
@@ -4140,11 +4159,17 @@ ${input.slice(result.pos)}
|
|
|
4140
4159
|
return result;
|
|
4141
4160
|
}
|
|
4142
4161
|
}
|
|
4143
|
-
var NestedNonAssignmentExtendedExpression$0 = $TS($S($Y(EOS), PushIndent, $E($S(Nested,
|
|
4162
|
+
var NestedNonAssignmentExtendedExpression$0 = $TS($S($Y(EOS), PushIndent, $E($S(Nested, ExpressionizedStatementWithTrailingCallExpressions)), PopIndent, $E(AllowedTrailingCallExpressions)), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
|
|
4144
4163
|
var expression = $3;
|
|
4145
|
-
|
|
4164
|
+
var trailing = $5;
|
|
4165
|
+
if (!expression)
|
|
4166
|
+
return $skip;
|
|
4167
|
+
if (!trailing)
|
|
4146
4168
|
return expression;
|
|
4147
|
-
return
|
|
4169
|
+
return {
|
|
4170
|
+
type: "CallExpression",
|
|
4171
|
+
children: [expression, ...trailing.flat()]
|
|
4172
|
+
};
|
|
4148
4173
|
});
|
|
4149
4174
|
function NestedNonAssignmentExtendedExpression(state) {
|
|
4150
4175
|
let eventData;
|
|
@@ -4168,6 +4193,39 @@ ${input.slice(result.pos)}
|
|
|
4168
4193
|
return result;
|
|
4169
4194
|
}
|
|
4170
4195
|
}
|
|
4196
|
+
var ExpressionizedStatementWithTrailingCallExpressions$0 = $TS($S(ExpressionizedStatement, $E(AllowedTrailingCallExpressions)), function($skip, $loc, $0, $1, $2) {
|
|
4197
|
+
if (!$2)
|
|
4198
|
+
return $1;
|
|
4199
|
+
return {
|
|
4200
|
+
type: "CallExpression",
|
|
4201
|
+
children: [
|
|
4202
|
+
makeLeftHandSideExpression($1),
|
|
4203
|
+
$2
|
|
4204
|
+
]
|
|
4205
|
+
};
|
|
4206
|
+
});
|
|
4207
|
+
function ExpressionizedStatementWithTrailingCallExpressions(state) {
|
|
4208
|
+
let eventData;
|
|
4209
|
+
if (state.events) {
|
|
4210
|
+
const result = state.events.enter?.("ExpressionizedStatementWithTrailingCallExpressions", state);
|
|
4211
|
+
if (result) {
|
|
4212
|
+
if (result.cache)
|
|
4213
|
+
return result.cache;
|
|
4214
|
+
eventData = result.data;
|
|
4215
|
+
}
|
|
4216
|
+
}
|
|
4217
|
+
if (state.tokenize) {
|
|
4218
|
+
const result = $TOKEN("ExpressionizedStatementWithTrailingCallExpressions", state, ExpressionizedStatementWithTrailingCallExpressions$0(state));
|
|
4219
|
+
if (state.events)
|
|
4220
|
+
state.events.exit?.("ExpressionizedStatementWithTrailingCallExpressions", state, result, eventData);
|
|
4221
|
+
return result;
|
|
4222
|
+
} else {
|
|
4223
|
+
const result = ExpressionizedStatementWithTrailingCallExpressions$0(state);
|
|
4224
|
+
if (state.events)
|
|
4225
|
+
state.events.exit?.("ExpressionizedStatementWithTrailingCallExpressions", state, result, eventData);
|
|
4226
|
+
return result;
|
|
4227
|
+
}
|
|
4228
|
+
}
|
|
4171
4229
|
var ExpressionizedStatement$0 = DebuggerExpression;
|
|
4172
4230
|
var ExpressionizedStatement$1 = IfExpression;
|
|
4173
4231
|
var ExpressionizedStatement$2 = UnlessExpression;
|
|
@@ -4453,6 +4511,54 @@ ${input.slice(result.pos)}
|
|
|
4453
4511
|
return result;
|
|
4454
4512
|
}
|
|
4455
4513
|
}
|
|
4514
|
+
var TrailingCallExpressions$0 = $P($S($C(Samedent, IndentedFurther), $Y($S($E($EXPECT($L5, fail, 'TrailingCallExpressions "?"')), $EXPECT($L6, fail, 'TrailingCallExpressions "."'), $N($R$0($EXPECT($R1, fail, "TrailingCallExpressions /[0-9]/"))))), $P(CallExpressionRest)));
|
|
4515
|
+
function TrailingCallExpressions(state) {
|
|
4516
|
+
let eventData;
|
|
4517
|
+
if (state.events) {
|
|
4518
|
+
const result = state.events.enter?.("TrailingCallExpressions", state);
|
|
4519
|
+
if (result) {
|
|
4520
|
+
if (result.cache)
|
|
4521
|
+
return result.cache;
|
|
4522
|
+
eventData = result.data;
|
|
4523
|
+
}
|
|
4524
|
+
}
|
|
4525
|
+
if (state.tokenize) {
|
|
4526
|
+
const result = $TOKEN("TrailingCallExpressions", state, TrailingCallExpressions$0(state));
|
|
4527
|
+
if (state.events)
|
|
4528
|
+
state.events.exit?.("TrailingCallExpressions", state, result, eventData);
|
|
4529
|
+
return result;
|
|
4530
|
+
} else {
|
|
4531
|
+
const result = TrailingCallExpressions$0(state);
|
|
4532
|
+
if (state.events)
|
|
4533
|
+
state.events.exit?.("TrailingCallExpressions", state, result, eventData);
|
|
4534
|
+
return result;
|
|
4535
|
+
}
|
|
4536
|
+
}
|
|
4537
|
+
var AllowedTrailingCallExpressions$0 = $T($S(TrailingMemberPropertyAllowed, TrailingCallExpressions), function(value) {
|
|
4538
|
+
return value[1];
|
|
4539
|
+
});
|
|
4540
|
+
function AllowedTrailingCallExpressions(state) {
|
|
4541
|
+
let eventData;
|
|
4542
|
+
if (state.events) {
|
|
4543
|
+
const result = state.events.enter?.("AllowedTrailingCallExpressions", state);
|
|
4544
|
+
if (result) {
|
|
4545
|
+
if (result.cache)
|
|
4546
|
+
return result.cache;
|
|
4547
|
+
eventData = result.data;
|
|
4548
|
+
}
|
|
4549
|
+
}
|
|
4550
|
+
if (state.tokenize) {
|
|
4551
|
+
const result = $TOKEN("AllowedTrailingCallExpressions", state, AllowedTrailingCallExpressions$0(state));
|
|
4552
|
+
if (state.events)
|
|
4553
|
+
state.events.exit?.("AllowedTrailingCallExpressions", state, result, eventData);
|
|
4554
|
+
return result;
|
|
4555
|
+
} else {
|
|
4556
|
+
const result = AllowedTrailingCallExpressions$0(state);
|
|
4557
|
+
if (state.events)
|
|
4558
|
+
state.events.exit?.("AllowedTrailingCallExpressions", state, result, eventData);
|
|
4559
|
+
return result;
|
|
4560
|
+
}
|
|
4561
|
+
}
|
|
4456
4562
|
var CommaDelimiter$0 = $S($E($C(Samedent, IndentedFurther)), $Q(_), Comma);
|
|
4457
4563
|
function CommaDelimiter(state) {
|
|
4458
4564
|
let eventData;
|
|
@@ -4760,7 +4866,7 @@ ${input.slice(result.pos)}
|
|
|
4760
4866
|
}
|
|
4761
4867
|
var RHS$0 = ParenthesizedAssignment;
|
|
4762
4868
|
var RHS$1 = UnaryExpression;
|
|
4763
|
-
var RHS$2 =
|
|
4869
|
+
var RHS$2 = ExpressionizedStatementWithTrailingCallExpressions;
|
|
4764
4870
|
function RHS(state) {
|
|
4765
4871
|
let eventData;
|
|
4766
4872
|
if (state.events) {
|
|
@@ -14628,14 +14734,15 @@ ${input.slice(result.pos)}
|
|
|
14628
14734
|
}
|
|
14629
14735
|
}
|
|
14630
14736
|
var ExportDeclaration$0 = $TS($S($E(Decorators), Export, __, Default, __, $C(HoistableDeclaration, ClassDeclaration, ExtendedExpression)), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
|
|
14631
|
-
|
|
14737
|
+
var declaration = $6;
|
|
14738
|
+
return { type: "ExportDeclaration", declaration, children: $0 };
|
|
14632
14739
|
});
|
|
14633
14740
|
var ExportDeclaration$1 = $TS($S(Export, __, ExportFromClause, __, FromClause), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
|
|
14634
14741
|
return { type: "ExportDeclaration", ts: $3.ts, children: $0 };
|
|
14635
14742
|
});
|
|
14636
14743
|
var ExportDeclaration$2 = $TS($S($E(Decorators), Export, __, $C(Declaration, VariableStatement, TypeAndNamedExports, ExportVarDec)), function($skip, $loc, $0, $1, $2, $3, $4) {
|
|
14637
|
-
var
|
|
14638
|
-
return { type: "ExportDeclaration", ts:
|
|
14744
|
+
var declaration = $4;
|
|
14745
|
+
return { type: "ExportDeclaration", declaration, ts: declaration.ts, children: $0 };
|
|
14639
14746
|
});
|
|
14640
14747
|
function ExportDeclaration(state) {
|
|
14641
14748
|
let eventData;
|
package/dist/main.js
CHANGED
|
@@ -744,12 +744,15 @@ var require_lib = __commonJS({
|
|
|
744
744
|
}
|
|
745
745
|
}
|
|
746
746
|
function findAncestor(node, predicate, stopPredicate) {
|
|
747
|
-
|
|
748
|
-
while (
|
|
749
|
-
if (predicate(node))
|
|
750
|
-
return node;
|
|
751
|
-
|
|
747
|
+
let { parent } = node;
|
|
748
|
+
while (parent && !stopPredicate?.(parent, node)) {
|
|
749
|
+
if (predicate(parent, node)) {
|
|
750
|
+
return { ancestor: parent, child: node };
|
|
751
|
+
}
|
|
752
|
+
node = parent;
|
|
753
|
+
parent = node.parent;
|
|
752
754
|
}
|
|
755
|
+
return { ancestor: void 0, child: node };
|
|
753
756
|
}
|
|
754
757
|
function gatherNodes(node, predicate) {
|
|
755
758
|
if (node == null)
|
|
@@ -822,14 +825,11 @@ var require_lib = __commonJS({
|
|
|
822
825
|
}
|
|
823
826
|
function hoistRefDecs(statements) {
|
|
824
827
|
gatherRecursiveAll(statements, (s) => s.hoistDec).forEach((node) => {
|
|
825
|
-
let { hoistDec
|
|
828
|
+
let { hoistDec } = node;
|
|
826
829
|
node.hoistDec = null;
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
}
|
|
831
|
-
if (parent) {
|
|
832
|
-
insertHoistDec(parent, node, hoistDec);
|
|
830
|
+
const { ancestor, child } = findAncestor(node, (ancestor2) => ancestor2.type === "BlockStatement" && (!ancestor2.bare || ancestor2.root));
|
|
831
|
+
if (ancestor) {
|
|
832
|
+
insertHoistDec(ancestor, child, hoistDec);
|
|
833
833
|
} else {
|
|
834
834
|
throw new Error("Couldn't find block to hoist declaration into.");
|
|
835
835
|
}
|
|
@@ -1147,6 +1147,7 @@ var require_lib = __commonJS({
|
|
|
1147
1147
|
case "AmpersandRef":
|
|
1148
1148
|
case "Identifier":
|
|
1149
1149
|
case "Literal":
|
|
1150
|
+
case "IterationExpression":
|
|
1150
1151
|
case "CallExpression":
|
|
1151
1152
|
case "MemberExpression":
|
|
1152
1153
|
case "ParenthesizedExpression":
|
|
@@ -1368,6 +1369,8 @@ var require_lib = __commonJS({
|
|
|
1368
1369
|
if (f.abstract || f.block || f.signature?.optional)
|
|
1369
1370
|
return;
|
|
1370
1371
|
const { name, parent } = f;
|
|
1372
|
+
if (parent?.type === "ExportDeclaration")
|
|
1373
|
+
return;
|
|
1371
1374
|
const expressions = parent?.expressions ?? parent?.elements;
|
|
1372
1375
|
const currentIndex = expressions?.findIndex(([, def]) => def === f);
|
|
1373
1376
|
const following = currentIndex >= 0 && expressions[currentIndex + 1]?.[1];
|
|
@@ -1423,6 +1426,46 @@ var require_lib = __commonJS({
|
|
|
1423
1426
|
tail.push(...splices.map((s) => [", ", s]), ...thisAssignments.map((a) => [", ", a]));
|
|
1424
1427
|
}
|
|
1425
1428
|
function processAssignments(statements) {
|
|
1429
|
+
gatherRecursiveAll(statements, (n) => n.type === "AssignmentExpression" || n.type === "UpdateExpression").forEach((exp) => {
|
|
1430
|
+
function extractAssignment(lhs) {
|
|
1431
|
+
let expr = lhs;
|
|
1432
|
+
while (expr.type === "ParenthesizedExpression") {
|
|
1433
|
+
expr = expr.expression;
|
|
1434
|
+
}
|
|
1435
|
+
if (expr.type === "AssignmentExpression" || expr.type === "UpdateExpression") {
|
|
1436
|
+
if (expr.type === "UpdateExpression" && expr.children[0] === expr.assigned) {
|
|
1437
|
+
post.push([", ", lhs]);
|
|
1438
|
+
} else {
|
|
1439
|
+
pre.push([lhs, ", "]);
|
|
1440
|
+
}
|
|
1441
|
+
return expr.assigned;
|
|
1442
|
+
}
|
|
1443
|
+
}
|
|
1444
|
+
const pre = [], post = [];
|
|
1445
|
+
switch (exp.type) {
|
|
1446
|
+
case "AssignmentExpression":
|
|
1447
|
+
if (!exp.lhs)
|
|
1448
|
+
return;
|
|
1449
|
+
exp.lhs.forEach((lhsPart, i) => {
|
|
1450
|
+
let newLhs2 = extractAssignment(lhsPart[1]);
|
|
1451
|
+
if (newLhs2) {
|
|
1452
|
+
lhsPart[1] = newLhs2;
|
|
1453
|
+
}
|
|
1454
|
+
});
|
|
1455
|
+
break;
|
|
1456
|
+
case "UpdateExpression":
|
|
1457
|
+
let newLhs = extractAssignment(exp.assigned);
|
|
1458
|
+
if (newLhs) {
|
|
1459
|
+
const i = exp.children.indexOf(exp.assigned);
|
|
1460
|
+
exp.assigned = exp.children[i] = newLhs;
|
|
1461
|
+
}
|
|
1462
|
+
break;
|
|
1463
|
+
}
|
|
1464
|
+
if (pre.length)
|
|
1465
|
+
exp.children.unshift(...pre);
|
|
1466
|
+
if (post.length)
|
|
1467
|
+
exp.children.push(...post);
|
|
1468
|
+
});
|
|
1426
1469
|
gatherRecursiveAll(statements, (n) => n.type === "AssignmentExpression" && n.names === null).forEach((exp) => {
|
|
1427
1470
|
let { lhs: $1, exp: $2 } = exp, tail = [], i = 0, len = $1.length;
|
|
1428
1471
|
if ($1.some((left) => left[left.length - 1].special)) {
|
|
@@ -1432,7 +1475,14 @@ var require_lib = __commonJS({
|
|
|
1432
1475
|
const [, lhs, , op] = $1[0];
|
|
1433
1476
|
const { call } = op;
|
|
1434
1477
|
op[op.length - 1] = "=";
|
|
1435
|
-
|
|
1478
|
+
const index2 = exp.children.indexOf($2);
|
|
1479
|
+
if (index2 < 0)
|
|
1480
|
+
throw new Error("Assertion error: exp not in AssignmentExpression");
|
|
1481
|
+
exp.children.splice(
|
|
1482
|
+
index2,
|
|
1483
|
+
1,
|
|
1484
|
+
exp.exp = $2 = [call, "(", lhs, ", ", $2, ")"]
|
|
1485
|
+
);
|
|
1436
1486
|
}
|
|
1437
1487
|
let wrapped = false;
|
|
1438
1488
|
while (i < len) {
|
|
@@ -1483,49 +1533,11 @@ var require_lib = __commonJS({
|
|
|
1483
1533
|
}
|
|
1484
1534
|
i--;
|
|
1485
1535
|
}
|
|
1486
|
-
|
|
1487
|
-
exp.children
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
function extractAssignment(lhs) {
|
|
1492
|
-
let expr = lhs;
|
|
1493
|
-
while (expr.type === "ParenthesizedExpression") {
|
|
1494
|
-
expr = expr.expression;
|
|
1495
|
-
}
|
|
1496
|
-
if (expr.type === "AssignmentExpression" || expr.type === "UpdateExpression") {
|
|
1497
|
-
if (expr.type === "UpdateExpression" && expr.children[0] === expr.assigned) {
|
|
1498
|
-
post.push([", ", lhs]);
|
|
1499
|
-
} else {
|
|
1500
|
-
pre.push([lhs, ", "]);
|
|
1501
|
-
}
|
|
1502
|
-
return expr.assigned;
|
|
1503
|
-
}
|
|
1504
|
-
}
|
|
1505
|
-
const pre = [], post = [];
|
|
1506
|
-
switch (exp.type) {
|
|
1507
|
-
case "AssignmentExpression":
|
|
1508
|
-
if (!exp.lhs)
|
|
1509
|
-
return;
|
|
1510
|
-
exp.lhs.forEach((lhsPart, i) => {
|
|
1511
|
-
let newLhs2 = extractAssignment(lhsPart[1]);
|
|
1512
|
-
if (newLhs2) {
|
|
1513
|
-
lhsPart[1] = newLhs2;
|
|
1514
|
-
}
|
|
1515
|
-
});
|
|
1516
|
-
break;
|
|
1517
|
-
case "UpdateExpression":
|
|
1518
|
-
let newLhs = extractAssignment(exp.assigned);
|
|
1519
|
-
if (newLhs) {
|
|
1520
|
-
const i = exp.children.indexOf(exp.assigned);
|
|
1521
|
-
exp.assigned = exp.children[i] = newLhs;
|
|
1522
|
-
}
|
|
1523
|
-
break;
|
|
1524
|
-
}
|
|
1525
|
-
if (pre.length)
|
|
1526
|
-
exp.children.unshift(...pre);
|
|
1527
|
-
if (post.length)
|
|
1528
|
-
exp.children.push(...post);
|
|
1536
|
+
exp.names = $1.flatMap(([, l]) => l.names || []);
|
|
1537
|
+
const index = exp.children.indexOf($2);
|
|
1538
|
+
if (index < 0)
|
|
1539
|
+
throw new Error("Assertion error: exp not in AssignmentExpression");
|
|
1540
|
+
exp.children.splice(index + 1, 0, ...tail);
|
|
1529
1541
|
});
|
|
1530
1542
|
}
|
|
1531
1543
|
function attachPostfixStatementAsExpression(exp, post) {
|
|
@@ -1972,7 +1984,8 @@ var require_lib = __commonJS({
|
|
|
1972
1984
|
});
|
|
1973
1985
|
}
|
|
1974
1986
|
} else {
|
|
1975
|
-
|
|
1987
|
+
if (i === 0)
|
|
1988
|
+
s.children = children;
|
|
1976
1989
|
}
|
|
1977
1990
|
if (returns && (ref = needsRef(arg))) {
|
|
1978
1991
|
usingRef = usingRef || ref;
|
|
@@ -2215,7 +2228,7 @@ var require_lib = __commonJS({
|
|
|
2215
2228
|
let declared;
|
|
2216
2229
|
values.forEach((value) => {
|
|
2217
2230
|
value.children = [ref];
|
|
2218
|
-
const ancestor = findAncestor(
|
|
2231
|
+
const { ancestor } = findAncestor(
|
|
2219
2232
|
value,
|
|
2220
2233
|
({ type }) => type === "Declaration",
|
|
2221
2234
|
isFunction
|
|
@@ -2962,6 +2975,7 @@ ${input.slice(result.pos)}
|
|
|
2962
2975
|
NonPipelineExtendedExpression,
|
|
2963
2976
|
NonAssignmentExtendedExpression,
|
|
2964
2977
|
NestedNonAssignmentExtendedExpression,
|
|
2978
|
+
ExpressionizedStatementWithTrailingCallExpressions,
|
|
2965
2979
|
ExpressionizedStatement,
|
|
2966
2980
|
Expression,
|
|
2967
2981
|
Arguments,
|
|
@@ -2972,6 +2986,8 @@ ${input.slice(result.pos)}
|
|
|
2972
2986
|
ArgumentsWithTrailingMemberExpressions,
|
|
2973
2987
|
TrailingMemberExpressions,
|
|
2974
2988
|
AllowedTrailingMemberExpressions,
|
|
2989
|
+
TrailingCallExpressions,
|
|
2990
|
+
AllowedTrailingCallExpressions,
|
|
2975
2991
|
CommaDelimiter,
|
|
2976
2992
|
ArgumentList,
|
|
2977
2993
|
NonPipelineArgumentList,
|
|
@@ -4111,7 +4127,10 @@ ${input.slice(result.pos)}
|
|
|
4111
4127
|
}
|
|
4112
4128
|
}
|
|
4113
4129
|
var NonAssignmentExtendedExpression$0 = NestedNonAssignmentExtendedExpression;
|
|
4114
|
-
var NonAssignmentExtendedExpression$1 = $TS($S(__,
|
|
4130
|
+
var NonAssignmentExtendedExpression$1 = $TS($S(__, ExpressionizedStatementWithTrailingCallExpressions), function($skip, $loc, $0, $1, $2) {
|
|
4131
|
+
if ($2.length) {
|
|
4132
|
+
return [...$1, ...$2];
|
|
4133
|
+
}
|
|
4115
4134
|
return {
|
|
4116
4135
|
...$2,
|
|
4117
4136
|
children: [...$1, ...$2.children]
|
|
@@ -4139,11 +4158,17 @@ ${input.slice(result.pos)}
|
|
|
4139
4158
|
return result;
|
|
4140
4159
|
}
|
|
4141
4160
|
}
|
|
4142
|
-
var NestedNonAssignmentExtendedExpression$0 = $TS($S($Y(EOS), PushIndent, $E($S(Nested,
|
|
4161
|
+
var NestedNonAssignmentExtendedExpression$0 = $TS($S($Y(EOS), PushIndent, $E($S(Nested, ExpressionizedStatementWithTrailingCallExpressions)), PopIndent, $E(AllowedTrailingCallExpressions)), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
|
|
4143
4162
|
var expression = $3;
|
|
4144
|
-
|
|
4163
|
+
var trailing = $5;
|
|
4164
|
+
if (!expression)
|
|
4165
|
+
return $skip;
|
|
4166
|
+
if (!trailing)
|
|
4145
4167
|
return expression;
|
|
4146
|
-
return
|
|
4168
|
+
return {
|
|
4169
|
+
type: "CallExpression",
|
|
4170
|
+
children: [expression, ...trailing.flat()]
|
|
4171
|
+
};
|
|
4147
4172
|
});
|
|
4148
4173
|
function NestedNonAssignmentExtendedExpression(state) {
|
|
4149
4174
|
let eventData;
|
|
@@ -4167,6 +4192,39 @@ ${input.slice(result.pos)}
|
|
|
4167
4192
|
return result;
|
|
4168
4193
|
}
|
|
4169
4194
|
}
|
|
4195
|
+
var ExpressionizedStatementWithTrailingCallExpressions$0 = $TS($S(ExpressionizedStatement, $E(AllowedTrailingCallExpressions)), function($skip, $loc, $0, $1, $2) {
|
|
4196
|
+
if (!$2)
|
|
4197
|
+
return $1;
|
|
4198
|
+
return {
|
|
4199
|
+
type: "CallExpression",
|
|
4200
|
+
children: [
|
|
4201
|
+
makeLeftHandSideExpression($1),
|
|
4202
|
+
$2
|
|
4203
|
+
]
|
|
4204
|
+
};
|
|
4205
|
+
});
|
|
4206
|
+
function ExpressionizedStatementWithTrailingCallExpressions(state) {
|
|
4207
|
+
let eventData;
|
|
4208
|
+
if (state.events) {
|
|
4209
|
+
const result = state.events.enter?.("ExpressionizedStatementWithTrailingCallExpressions", state);
|
|
4210
|
+
if (result) {
|
|
4211
|
+
if (result.cache)
|
|
4212
|
+
return result.cache;
|
|
4213
|
+
eventData = result.data;
|
|
4214
|
+
}
|
|
4215
|
+
}
|
|
4216
|
+
if (state.tokenize) {
|
|
4217
|
+
const result = $TOKEN("ExpressionizedStatementWithTrailingCallExpressions", state, ExpressionizedStatementWithTrailingCallExpressions$0(state));
|
|
4218
|
+
if (state.events)
|
|
4219
|
+
state.events.exit?.("ExpressionizedStatementWithTrailingCallExpressions", state, result, eventData);
|
|
4220
|
+
return result;
|
|
4221
|
+
} else {
|
|
4222
|
+
const result = ExpressionizedStatementWithTrailingCallExpressions$0(state);
|
|
4223
|
+
if (state.events)
|
|
4224
|
+
state.events.exit?.("ExpressionizedStatementWithTrailingCallExpressions", state, result, eventData);
|
|
4225
|
+
return result;
|
|
4226
|
+
}
|
|
4227
|
+
}
|
|
4170
4228
|
var ExpressionizedStatement$0 = DebuggerExpression;
|
|
4171
4229
|
var ExpressionizedStatement$1 = IfExpression;
|
|
4172
4230
|
var ExpressionizedStatement$2 = UnlessExpression;
|
|
@@ -4452,6 +4510,54 @@ ${input.slice(result.pos)}
|
|
|
4452
4510
|
return result;
|
|
4453
4511
|
}
|
|
4454
4512
|
}
|
|
4513
|
+
var TrailingCallExpressions$0 = $P($S($C(Samedent, IndentedFurther), $Y($S($E($EXPECT($L5, fail, 'TrailingCallExpressions "?"')), $EXPECT($L6, fail, 'TrailingCallExpressions "."'), $N($R$0($EXPECT($R1, fail, "TrailingCallExpressions /[0-9]/"))))), $P(CallExpressionRest)));
|
|
4514
|
+
function TrailingCallExpressions(state) {
|
|
4515
|
+
let eventData;
|
|
4516
|
+
if (state.events) {
|
|
4517
|
+
const result = state.events.enter?.("TrailingCallExpressions", state);
|
|
4518
|
+
if (result) {
|
|
4519
|
+
if (result.cache)
|
|
4520
|
+
return result.cache;
|
|
4521
|
+
eventData = result.data;
|
|
4522
|
+
}
|
|
4523
|
+
}
|
|
4524
|
+
if (state.tokenize) {
|
|
4525
|
+
const result = $TOKEN("TrailingCallExpressions", state, TrailingCallExpressions$0(state));
|
|
4526
|
+
if (state.events)
|
|
4527
|
+
state.events.exit?.("TrailingCallExpressions", state, result, eventData);
|
|
4528
|
+
return result;
|
|
4529
|
+
} else {
|
|
4530
|
+
const result = TrailingCallExpressions$0(state);
|
|
4531
|
+
if (state.events)
|
|
4532
|
+
state.events.exit?.("TrailingCallExpressions", state, result, eventData);
|
|
4533
|
+
return result;
|
|
4534
|
+
}
|
|
4535
|
+
}
|
|
4536
|
+
var AllowedTrailingCallExpressions$0 = $T($S(TrailingMemberPropertyAllowed, TrailingCallExpressions), function(value) {
|
|
4537
|
+
return value[1];
|
|
4538
|
+
});
|
|
4539
|
+
function AllowedTrailingCallExpressions(state) {
|
|
4540
|
+
let eventData;
|
|
4541
|
+
if (state.events) {
|
|
4542
|
+
const result = state.events.enter?.("AllowedTrailingCallExpressions", state);
|
|
4543
|
+
if (result) {
|
|
4544
|
+
if (result.cache)
|
|
4545
|
+
return result.cache;
|
|
4546
|
+
eventData = result.data;
|
|
4547
|
+
}
|
|
4548
|
+
}
|
|
4549
|
+
if (state.tokenize) {
|
|
4550
|
+
const result = $TOKEN("AllowedTrailingCallExpressions", state, AllowedTrailingCallExpressions$0(state));
|
|
4551
|
+
if (state.events)
|
|
4552
|
+
state.events.exit?.("AllowedTrailingCallExpressions", state, result, eventData);
|
|
4553
|
+
return result;
|
|
4554
|
+
} else {
|
|
4555
|
+
const result = AllowedTrailingCallExpressions$0(state);
|
|
4556
|
+
if (state.events)
|
|
4557
|
+
state.events.exit?.("AllowedTrailingCallExpressions", state, result, eventData);
|
|
4558
|
+
return result;
|
|
4559
|
+
}
|
|
4560
|
+
}
|
|
4455
4561
|
var CommaDelimiter$0 = $S($E($C(Samedent, IndentedFurther)), $Q(_), Comma);
|
|
4456
4562
|
function CommaDelimiter(state) {
|
|
4457
4563
|
let eventData;
|
|
@@ -4759,7 +4865,7 @@ ${input.slice(result.pos)}
|
|
|
4759
4865
|
}
|
|
4760
4866
|
var RHS$0 = ParenthesizedAssignment;
|
|
4761
4867
|
var RHS$1 = UnaryExpression;
|
|
4762
|
-
var RHS$2 =
|
|
4868
|
+
var RHS$2 = ExpressionizedStatementWithTrailingCallExpressions;
|
|
4763
4869
|
function RHS(state) {
|
|
4764
4870
|
let eventData;
|
|
4765
4871
|
if (state.events) {
|
|
@@ -14627,14 +14733,15 @@ ${input.slice(result.pos)}
|
|
|
14627
14733
|
}
|
|
14628
14734
|
}
|
|
14629
14735
|
var ExportDeclaration$0 = $TS($S($E(Decorators), Export, __, Default, __, $C(HoistableDeclaration, ClassDeclaration, ExtendedExpression)), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
|
|
14630
|
-
|
|
14736
|
+
var declaration = $6;
|
|
14737
|
+
return { type: "ExportDeclaration", declaration, children: $0 };
|
|
14631
14738
|
});
|
|
14632
14739
|
var ExportDeclaration$1 = $TS($S(Export, __, ExportFromClause, __, FromClause), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
|
|
14633
14740
|
return { type: "ExportDeclaration", ts: $3.ts, children: $0 };
|
|
14634
14741
|
});
|
|
14635
14742
|
var ExportDeclaration$2 = $TS($S($E(Decorators), Export, __, $C(Declaration, VariableStatement, TypeAndNamedExports, ExportVarDec)), function($skip, $loc, $0, $1, $2, $3, $4) {
|
|
14636
|
-
var
|
|
14637
|
-
return { type: "ExportDeclaration", ts:
|
|
14743
|
+
var declaration = $4;
|
|
14744
|
+
return { type: "ExportDeclaration", declaration, ts: declaration.ts, children: $0 };
|
|
14638
14745
|
});
|
|
14639
14746
|
function ExportDeclaration(state) {
|
|
14640
14747
|
let eventData;
|
package/dist/main.mjs
CHANGED
|
@@ -742,12 +742,15 @@ var require_lib = __commonJS({
|
|
|
742
742
|
}
|
|
743
743
|
}
|
|
744
744
|
function findAncestor(node, predicate, stopPredicate) {
|
|
745
|
-
|
|
746
|
-
while (
|
|
747
|
-
if (predicate(node))
|
|
748
|
-
return node;
|
|
749
|
-
|
|
745
|
+
let { parent } = node;
|
|
746
|
+
while (parent && !stopPredicate?.(parent, node)) {
|
|
747
|
+
if (predicate(parent, node)) {
|
|
748
|
+
return { ancestor: parent, child: node };
|
|
749
|
+
}
|
|
750
|
+
node = parent;
|
|
751
|
+
parent = node.parent;
|
|
750
752
|
}
|
|
753
|
+
return { ancestor: void 0, child: node };
|
|
751
754
|
}
|
|
752
755
|
function gatherNodes(node, predicate) {
|
|
753
756
|
if (node == null)
|
|
@@ -820,14 +823,11 @@ var require_lib = __commonJS({
|
|
|
820
823
|
}
|
|
821
824
|
function hoistRefDecs(statements) {
|
|
822
825
|
gatherRecursiveAll(statements, (s) => s.hoistDec).forEach((node) => {
|
|
823
|
-
let { hoistDec
|
|
826
|
+
let { hoistDec } = node;
|
|
824
827
|
node.hoistDec = null;
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
}
|
|
829
|
-
if (parent) {
|
|
830
|
-
insertHoistDec(parent, node, hoistDec);
|
|
828
|
+
const { ancestor, child } = findAncestor(node, (ancestor2) => ancestor2.type === "BlockStatement" && (!ancestor2.bare || ancestor2.root));
|
|
829
|
+
if (ancestor) {
|
|
830
|
+
insertHoistDec(ancestor, child, hoistDec);
|
|
831
831
|
} else {
|
|
832
832
|
throw new Error("Couldn't find block to hoist declaration into.");
|
|
833
833
|
}
|
|
@@ -1145,6 +1145,7 @@ var require_lib = __commonJS({
|
|
|
1145
1145
|
case "AmpersandRef":
|
|
1146
1146
|
case "Identifier":
|
|
1147
1147
|
case "Literal":
|
|
1148
|
+
case "IterationExpression":
|
|
1148
1149
|
case "CallExpression":
|
|
1149
1150
|
case "MemberExpression":
|
|
1150
1151
|
case "ParenthesizedExpression":
|
|
@@ -1366,6 +1367,8 @@ var require_lib = __commonJS({
|
|
|
1366
1367
|
if (f.abstract || f.block || f.signature?.optional)
|
|
1367
1368
|
return;
|
|
1368
1369
|
const { name, parent } = f;
|
|
1370
|
+
if (parent?.type === "ExportDeclaration")
|
|
1371
|
+
return;
|
|
1369
1372
|
const expressions = parent?.expressions ?? parent?.elements;
|
|
1370
1373
|
const currentIndex = expressions?.findIndex(([, def]) => def === f);
|
|
1371
1374
|
const following = currentIndex >= 0 && expressions[currentIndex + 1]?.[1];
|
|
@@ -1421,6 +1424,46 @@ var require_lib = __commonJS({
|
|
|
1421
1424
|
tail.push(...splices.map((s) => [", ", s]), ...thisAssignments.map((a) => [", ", a]));
|
|
1422
1425
|
}
|
|
1423
1426
|
function processAssignments(statements) {
|
|
1427
|
+
gatherRecursiveAll(statements, (n) => n.type === "AssignmentExpression" || n.type === "UpdateExpression").forEach((exp) => {
|
|
1428
|
+
function extractAssignment(lhs) {
|
|
1429
|
+
let expr = lhs;
|
|
1430
|
+
while (expr.type === "ParenthesizedExpression") {
|
|
1431
|
+
expr = expr.expression;
|
|
1432
|
+
}
|
|
1433
|
+
if (expr.type === "AssignmentExpression" || expr.type === "UpdateExpression") {
|
|
1434
|
+
if (expr.type === "UpdateExpression" && expr.children[0] === expr.assigned) {
|
|
1435
|
+
post.push([", ", lhs]);
|
|
1436
|
+
} else {
|
|
1437
|
+
pre.push([lhs, ", "]);
|
|
1438
|
+
}
|
|
1439
|
+
return expr.assigned;
|
|
1440
|
+
}
|
|
1441
|
+
}
|
|
1442
|
+
const pre = [], post = [];
|
|
1443
|
+
switch (exp.type) {
|
|
1444
|
+
case "AssignmentExpression":
|
|
1445
|
+
if (!exp.lhs)
|
|
1446
|
+
return;
|
|
1447
|
+
exp.lhs.forEach((lhsPart, i) => {
|
|
1448
|
+
let newLhs2 = extractAssignment(lhsPart[1]);
|
|
1449
|
+
if (newLhs2) {
|
|
1450
|
+
lhsPart[1] = newLhs2;
|
|
1451
|
+
}
|
|
1452
|
+
});
|
|
1453
|
+
break;
|
|
1454
|
+
case "UpdateExpression":
|
|
1455
|
+
let newLhs = extractAssignment(exp.assigned);
|
|
1456
|
+
if (newLhs) {
|
|
1457
|
+
const i = exp.children.indexOf(exp.assigned);
|
|
1458
|
+
exp.assigned = exp.children[i] = newLhs;
|
|
1459
|
+
}
|
|
1460
|
+
break;
|
|
1461
|
+
}
|
|
1462
|
+
if (pre.length)
|
|
1463
|
+
exp.children.unshift(...pre);
|
|
1464
|
+
if (post.length)
|
|
1465
|
+
exp.children.push(...post);
|
|
1466
|
+
});
|
|
1424
1467
|
gatherRecursiveAll(statements, (n) => n.type === "AssignmentExpression" && n.names === null).forEach((exp) => {
|
|
1425
1468
|
let { lhs: $1, exp: $2 } = exp, tail = [], i = 0, len = $1.length;
|
|
1426
1469
|
if ($1.some((left) => left[left.length - 1].special)) {
|
|
@@ -1430,7 +1473,14 @@ var require_lib = __commonJS({
|
|
|
1430
1473
|
const [, lhs, , op] = $1[0];
|
|
1431
1474
|
const { call } = op;
|
|
1432
1475
|
op[op.length - 1] = "=";
|
|
1433
|
-
|
|
1476
|
+
const index2 = exp.children.indexOf($2);
|
|
1477
|
+
if (index2 < 0)
|
|
1478
|
+
throw new Error("Assertion error: exp not in AssignmentExpression");
|
|
1479
|
+
exp.children.splice(
|
|
1480
|
+
index2,
|
|
1481
|
+
1,
|
|
1482
|
+
exp.exp = $2 = [call, "(", lhs, ", ", $2, ")"]
|
|
1483
|
+
);
|
|
1434
1484
|
}
|
|
1435
1485
|
let wrapped = false;
|
|
1436
1486
|
while (i < len) {
|
|
@@ -1481,49 +1531,11 @@ var require_lib = __commonJS({
|
|
|
1481
1531
|
}
|
|
1482
1532
|
i--;
|
|
1483
1533
|
}
|
|
1484
|
-
|
|
1485
|
-
exp.children
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
function extractAssignment(lhs) {
|
|
1490
|
-
let expr = lhs;
|
|
1491
|
-
while (expr.type === "ParenthesizedExpression") {
|
|
1492
|
-
expr = expr.expression;
|
|
1493
|
-
}
|
|
1494
|
-
if (expr.type === "AssignmentExpression" || expr.type === "UpdateExpression") {
|
|
1495
|
-
if (expr.type === "UpdateExpression" && expr.children[0] === expr.assigned) {
|
|
1496
|
-
post.push([", ", lhs]);
|
|
1497
|
-
} else {
|
|
1498
|
-
pre.push([lhs, ", "]);
|
|
1499
|
-
}
|
|
1500
|
-
return expr.assigned;
|
|
1501
|
-
}
|
|
1502
|
-
}
|
|
1503
|
-
const pre = [], post = [];
|
|
1504
|
-
switch (exp.type) {
|
|
1505
|
-
case "AssignmentExpression":
|
|
1506
|
-
if (!exp.lhs)
|
|
1507
|
-
return;
|
|
1508
|
-
exp.lhs.forEach((lhsPart, i) => {
|
|
1509
|
-
let newLhs2 = extractAssignment(lhsPart[1]);
|
|
1510
|
-
if (newLhs2) {
|
|
1511
|
-
lhsPart[1] = newLhs2;
|
|
1512
|
-
}
|
|
1513
|
-
});
|
|
1514
|
-
break;
|
|
1515
|
-
case "UpdateExpression":
|
|
1516
|
-
let newLhs = extractAssignment(exp.assigned);
|
|
1517
|
-
if (newLhs) {
|
|
1518
|
-
const i = exp.children.indexOf(exp.assigned);
|
|
1519
|
-
exp.assigned = exp.children[i] = newLhs;
|
|
1520
|
-
}
|
|
1521
|
-
break;
|
|
1522
|
-
}
|
|
1523
|
-
if (pre.length)
|
|
1524
|
-
exp.children.unshift(...pre);
|
|
1525
|
-
if (post.length)
|
|
1526
|
-
exp.children.push(...post);
|
|
1534
|
+
exp.names = $1.flatMap(([, l]) => l.names || []);
|
|
1535
|
+
const index = exp.children.indexOf($2);
|
|
1536
|
+
if (index < 0)
|
|
1537
|
+
throw new Error("Assertion error: exp not in AssignmentExpression");
|
|
1538
|
+
exp.children.splice(index + 1, 0, ...tail);
|
|
1527
1539
|
});
|
|
1528
1540
|
}
|
|
1529
1541
|
function attachPostfixStatementAsExpression(exp, post) {
|
|
@@ -1970,7 +1982,8 @@ var require_lib = __commonJS({
|
|
|
1970
1982
|
});
|
|
1971
1983
|
}
|
|
1972
1984
|
} else {
|
|
1973
|
-
|
|
1985
|
+
if (i === 0)
|
|
1986
|
+
s.children = children;
|
|
1974
1987
|
}
|
|
1975
1988
|
if (returns && (ref = needsRef(arg))) {
|
|
1976
1989
|
usingRef = usingRef || ref;
|
|
@@ -2213,7 +2226,7 @@ var require_lib = __commonJS({
|
|
|
2213
2226
|
let declared;
|
|
2214
2227
|
values.forEach((value) => {
|
|
2215
2228
|
value.children = [ref];
|
|
2216
|
-
const ancestor = findAncestor(
|
|
2229
|
+
const { ancestor } = findAncestor(
|
|
2217
2230
|
value,
|
|
2218
2231
|
({ type }) => type === "Declaration",
|
|
2219
2232
|
isFunction
|
|
@@ -2960,6 +2973,7 @@ ${input.slice(result.pos)}
|
|
|
2960
2973
|
NonPipelineExtendedExpression,
|
|
2961
2974
|
NonAssignmentExtendedExpression,
|
|
2962
2975
|
NestedNonAssignmentExtendedExpression,
|
|
2976
|
+
ExpressionizedStatementWithTrailingCallExpressions,
|
|
2963
2977
|
ExpressionizedStatement,
|
|
2964
2978
|
Expression,
|
|
2965
2979
|
Arguments,
|
|
@@ -2970,6 +2984,8 @@ ${input.slice(result.pos)}
|
|
|
2970
2984
|
ArgumentsWithTrailingMemberExpressions,
|
|
2971
2985
|
TrailingMemberExpressions,
|
|
2972
2986
|
AllowedTrailingMemberExpressions,
|
|
2987
|
+
TrailingCallExpressions,
|
|
2988
|
+
AllowedTrailingCallExpressions,
|
|
2973
2989
|
CommaDelimiter,
|
|
2974
2990
|
ArgumentList,
|
|
2975
2991
|
NonPipelineArgumentList,
|
|
@@ -4109,7 +4125,10 @@ ${input.slice(result.pos)}
|
|
|
4109
4125
|
}
|
|
4110
4126
|
}
|
|
4111
4127
|
var NonAssignmentExtendedExpression$0 = NestedNonAssignmentExtendedExpression;
|
|
4112
|
-
var NonAssignmentExtendedExpression$1 = $TS($S(__,
|
|
4128
|
+
var NonAssignmentExtendedExpression$1 = $TS($S(__, ExpressionizedStatementWithTrailingCallExpressions), function($skip, $loc, $0, $1, $2) {
|
|
4129
|
+
if ($2.length) {
|
|
4130
|
+
return [...$1, ...$2];
|
|
4131
|
+
}
|
|
4113
4132
|
return {
|
|
4114
4133
|
...$2,
|
|
4115
4134
|
children: [...$1, ...$2.children]
|
|
@@ -4137,11 +4156,17 @@ ${input.slice(result.pos)}
|
|
|
4137
4156
|
return result;
|
|
4138
4157
|
}
|
|
4139
4158
|
}
|
|
4140
|
-
var NestedNonAssignmentExtendedExpression$0 = $TS($S($Y(EOS), PushIndent, $E($S(Nested,
|
|
4159
|
+
var NestedNonAssignmentExtendedExpression$0 = $TS($S($Y(EOS), PushIndent, $E($S(Nested, ExpressionizedStatementWithTrailingCallExpressions)), PopIndent, $E(AllowedTrailingCallExpressions)), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
|
|
4141
4160
|
var expression = $3;
|
|
4142
|
-
|
|
4161
|
+
var trailing = $5;
|
|
4162
|
+
if (!expression)
|
|
4163
|
+
return $skip;
|
|
4164
|
+
if (!trailing)
|
|
4143
4165
|
return expression;
|
|
4144
|
-
return
|
|
4166
|
+
return {
|
|
4167
|
+
type: "CallExpression",
|
|
4168
|
+
children: [expression, ...trailing.flat()]
|
|
4169
|
+
};
|
|
4145
4170
|
});
|
|
4146
4171
|
function NestedNonAssignmentExtendedExpression(state) {
|
|
4147
4172
|
let eventData;
|
|
@@ -4165,6 +4190,39 @@ ${input.slice(result.pos)}
|
|
|
4165
4190
|
return result;
|
|
4166
4191
|
}
|
|
4167
4192
|
}
|
|
4193
|
+
var ExpressionizedStatementWithTrailingCallExpressions$0 = $TS($S(ExpressionizedStatement, $E(AllowedTrailingCallExpressions)), function($skip, $loc, $0, $1, $2) {
|
|
4194
|
+
if (!$2)
|
|
4195
|
+
return $1;
|
|
4196
|
+
return {
|
|
4197
|
+
type: "CallExpression",
|
|
4198
|
+
children: [
|
|
4199
|
+
makeLeftHandSideExpression($1),
|
|
4200
|
+
$2
|
|
4201
|
+
]
|
|
4202
|
+
};
|
|
4203
|
+
});
|
|
4204
|
+
function ExpressionizedStatementWithTrailingCallExpressions(state) {
|
|
4205
|
+
let eventData;
|
|
4206
|
+
if (state.events) {
|
|
4207
|
+
const result = state.events.enter?.("ExpressionizedStatementWithTrailingCallExpressions", state);
|
|
4208
|
+
if (result) {
|
|
4209
|
+
if (result.cache)
|
|
4210
|
+
return result.cache;
|
|
4211
|
+
eventData = result.data;
|
|
4212
|
+
}
|
|
4213
|
+
}
|
|
4214
|
+
if (state.tokenize) {
|
|
4215
|
+
const result = $TOKEN("ExpressionizedStatementWithTrailingCallExpressions", state, ExpressionizedStatementWithTrailingCallExpressions$0(state));
|
|
4216
|
+
if (state.events)
|
|
4217
|
+
state.events.exit?.("ExpressionizedStatementWithTrailingCallExpressions", state, result, eventData);
|
|
4218
|
+
return result;
|
|
4219
|
+
} else {
|
|
4220
|
+
const result = ExpressionizedStatementWithTrailingCallExpressions$0(state);
|
|
4221
|
+
if (state.events)
|
|
4222
|
+
state.events.exit?.("ExpressionizedStatementWithTrailingCallExpressions", state, result, eventData);
|
|
4223
|
+
return result;
|
|
4224
|
+
}
|
|
4225
|
+
}
|
|
4168
4226
|
var ExpressionizedStatement$0 = DebuggerExpression;
|
|
4169
4227
|
var ExpressionizedStatement$1 = IfExpression;
|
|
4170
4228
|
var ExpressionizedStatement$2 = UnlessExpression;
|
|
@@ -4450,6 +4508,54 @@ ${input.slice(result.pos)}
|
|
|
4450
4508
|
return result;
|
|
4451
4509
|
}
|
|
4452
4510
|
}
|
|
4511
|
+
var TrailingCallExpressions$0 = $P($S($C(Samedent, IndentedFurther), $Y($S($E($EXPECT($L5, fail, 'TrailingCallExpressions "?"')), $EXPECT($L6, fail, 'TrailingCallExpressions "."'), $N($R$0($EXPECT($R1, fail, "TrailingCallExpressions /[0-9]/"))))), $P(CallExpressionRest)));
|
|
4512
|
+
function TrailingCallExpressions(state) {
|
|
4513
|
+
let eventData;
|
|
4514
|
+
if (state.events) {
|
|
4515
|
+
const result = state.events.enter?.("TrailingCallExpressions", state);
|
|
4516
|
+
if (result) {
|
|
4517
|
+
if (result.cache)
|
|
4518
|
+
return result.cache;
|
|
4519
|
+
eventData = result.data;
|
|
4520
|
+
}
|
|
4521
|
+
}
|
|
4522
|
+
if (state.tokenize) {
|
|
4523
|
+
const result = $TOKEN("TrailingCallExpressions", state, TrailingCallExpressions$0(state));
|
|
4524
|
+
if (state.events)
|
|
4525
|
+
state.events.exit?.("TrailingCallExpressions", state, result, eventData);
|
|
4526
|
+
return result;
|
|
4527
|
+
} else {
|
|
4528
|
+
const result = TrailingCallExpressions$0(state);
|
|
4529
|
+
if (state.events)
|
|
4530
|
+
state.events.exit?.("TrailingCallExpressions", state, result, eventData);
|
|
4531
|
+
return result;
|
|
4532
|
+
}
|
|
4533
|
+
}
|
|
4534
|
+
var AllowedTrailingCallExpressions$0 = $T($S(TrailingMemberPropertyAllowed, TrailingCallExpressions), function(value) {
|
|
4535
|
+
return value[1];
|
|
4536
|
+
});
|
|
4537
|
+
function AllowedTrailingCallExpressions(state) {
|
|
4538
|
+
let eventData;
|
|
4539
|
+
if (state.events) {
|
|
4540
|
+
const result = state.events.enter?.("AllowedTrailingCallExpressions", state);
|
|
4541
|
+
if (result) {
|
|
4542
|
+
if (result.cache)
|
|
4543
|
+
return result.cache;
|
|
4544
|
+
eventData = result.data;
|
|
4545
|
+
}
|
|
4546
|
+
}
|
|
4547
|
+
if (state.tokenize) {
|
|
4548
|
+
const result = $TOKEN("AllowedTrailingCallExpressions", state, AllowedTrailingCallExpressions$0(state));
|
|
4549
|
+
if (state.events)
|
|
4550
|
+
state.events.exit?.("AllowedTrailingCallExpressions", state, result, eventData);
|
|
4551
|
+
return result;
|
|
4552
|
+
} else {
|
|
4553
|
+
const result = AllowedTrailingCallExpressions$0(state);
|
|
4554
|
+
if (state.events)
|
|
4555
|
+
state.events.exit?.("AllowedTrailingCallExpressions", state, result, eventData);
|
|
4556
|
+
return result;
|
|
4557
|
+
}
|
|
4558
|
+
}
|
|
4453
4559
|
var CommaDelimiter$0 = $S($E($C(Samedent, IndentedFurther)), $Q(_), Comma);
|
|
4454
4560
|
function CommaDelimiter(state) {
|
|
4455
4561
|
let eventData;
|
|
@@ -4757,7 +4863,7 @@ ${input.slice(result.pos)}
|
|
|
4757
4863
|
}
|
|
4758
4864
|
var RHS$0 = ParenthesizedAssignment;
|
|
4759
4865
|
var RHS$1 = UnaryExpression;
|
|
4760
|
-
var RHS$2 =
|
|
4866
|
+
var RHS$2 = ExpressionizedStatementWithTrailingCallExpressions;
|
|
4761
4867
|
function RHS(state) {
|
|
4762
4868
|
let eventData;
|
|
4763
4869
|
if (state.events) {
|
|
@@ -14625,14 +14731,15 @@ ${input.slice(result.pos)}
|
|
|
14625
14731
|
}
|
|
14626
14732
|
}
|
|
14627
14733
|
var ExportDeclaration$0 = $TS($S($E(Decorators), Export, __, Default, __, $C(HoistableDeclaration, ClassDeclaration, ExtendedExpression)), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
|
|
14628
|
-
|
|
14734
|
+
var declaration = $6;
|
|
14735
|
+
return { type: "ExportDeclaration", declaration, children: $0 };
|
|
14629
14736
|
});
|
|
14630
14737
|
var ExportDeclaration$1 = $TS($S(Export, __, ExportFromClause, __, FromClause), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
|
|
14631
14738
|
return { type: "ExportDeclaration", ts: $3.ts, children: $0 };
|
|
14632
14739
|
});
|
|
14633
14740
|
var ExportDeclaration$2 = $TS($S($E(Decorators), Export, __, $C(Declaration, VariableStatement, TypeAndNamedExports, ExportVarDec)), function($skip, $loc, $0, $1, $2, $3, $4) {
|
|
14634
|
-
var
|
|
14635
|
-
return { type: "ExportDeclaration", ts:
|
|
14741
|
+
var declaration = $4;
|
|
14742
|
+
return { type: "ExportDeclaration", declaration, ts: declaration.ts, children: $0 };
|
|
14636
14743
|
});
|
|
14637
14744
|
function ExportDeclaration(state) {
|
|
14638
14745
|
let eventData;
|