@danielx/civet 0.6.48 → 0.6.49
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 +46 -30
- package/dist/main.js +46 -30
- package/dist/main.mjs +46 -30
- package/package.json +1 -1
package/dist/browser.js
CHANGED
|
@@ -506,6 +506,7 @@ ${input.slice(result.pos)}
|
|
|
506
506
|
}
|
|
507
507
|
return;
|
|
508
508
|
}
|
|
509
|
+
node = node;
|
|
509
510
|
node.parent = parent;
|
|
510
511
|
if (node.children) {
|
|
511
512
|
for (const child of node.children) {
|
|
@@ -524,6 +525,7 @@ ${input.slice(result.pos)}
|
|
|
524
525
|
}
|
|
525
526
|
return;
|
|
526
527
|
}
|
|
528
|
+
node = node;
|
|
527
529
|
if (parent != null)
|
|
528
530
|
node.parent = parent;
|
|
529
531
|
if (depth && node.children) {
|
|
@@ -532,20 +534,24 @@ ${input.slice(result.pos)}
|
|
|
532
534
|
}
|
|
533
535
|
}
|
|
534
536
|
}
|
|
537
|
+
function makeNode(node) {
|
|
538
|
+
updateParentPointers(node);
|
|
539
|
+
return node;
|
|
540
|
+
}
|
|
535
541
|
function addPostfixStatement(statement, ws, post) {
|
|
536
542
|
const expressions = [
|
|
537
543
|
...post.blockPrefix || [],
|
|
538
544
|
["", statement]
|
|
539
545
|
];
|
|
540
|
-
const block = {
|
|
546
|
+
const block = makeNode({
|
|
541
547
|
type: "BlockStatement",
|
|
542
548
|
children: [" { ", expressions, " }"],
|
|
543
549
|
expressions
|
|
544
|
-
};
|
|
550
|
+
});
|
|
545
551
|
const children = [...post.children, block];
|
|
546
552
|
if (!isWhitespaceOrEmpty(ws))
|
|
547
553
|
children.push(ws);
|
|
548
|
-
post = { ...post, children, block };
|
|
554
|
+
post = makeNode({ ...post, children, block });
|
|
549
555
|
if (post.type === "IfStatement") {
|
|
550
556
|
post.then = block;
|
|
551
557
|
}
|
|
@@ -659,6 +665,7 @@ ${input.slice(result.pos)}
|
|
|
659
665
|
});
|
|
660
666
|
}
|
|
661
667
|
const expressions = [...prefixStatements, ...block.expressions];
|
|
668
|
+
addParentPointers(prefixStatements, block);
|
|
662
669
|
block = {
|
|
663
670
|
...block,
|
|
664
671
|
expressions,
|
|
@@ -668,6 +675,7 @@ ${input.slice(result.pos)}
|
|
|
668
675
|
block.children = [[" {"], ...block.children, "}"];
|
|
669
676
|
block.bare = false;
|
|
670
677
|
}
|
|
678
|
+
updateParentPointers(block);
|
|
671
679
|
}
|
|
672
680
|
return block;
|
|
673
681
|
}
|
|
@@ -685,10 +693,11 @@ ${input.slice(result.pos)}
|
|
|
685
693
|
const { ref, body } = expr;
|
|
686
694
|
ref.type = "PipedExpression";
|
|
687
695
|
ref.children = [makeLeftHandSideExpression(arg)];
|
|
688
|
-
|
|
696
|
+
updateParentPointers(ref);
|
|
697
|
+
return makeNode({
|
|
689
698
|
type: "UnwrappedExpression",
|
|
690
699
|
children: [skipIfOnlyWS(fn.leadingComment), body, skipIfOnlyWS(fn.trailingComment)]
|
|
691
|
-
};
|
|
700
|
+
});
|
|
692
701
|
}
|
|
693
702
|
expr = fn.expr;
|
|
694
703
|
const lhs = makeLeftHandSideExpression(expr);
|
|
@@ -902,6 +911,7 @@ ${input.slice(result.pos)}
|
|
|
902
911
|
if (subtype === "DoStatement") {
|
|
903
912
|
insertReturn(block);
|
|
904
913
|
children.splice(i, 1, ...wrapIIFE(["", statement, void 0], async));
|
|
914
|
+
updateParentPointers(exp);
|
|
905
915
|
return;
|
|
906
916
|
}
|
|
907
917
|
const resultsRef = makeRef("results");
|
|
@@ -916,6 +926,7 @@ ${input.slice(result.pos)}
|
|
|
916
926
|
["", wrapWithReturn(resultsRef)]
|
|
917
927
|
], async)
|
|
918
928
|
);
|
|
929
|
+
updateParentPointers(exp);
|
|
919
930
|
}
|
|
920
931
|
function processBinaryOpExpression($0) {
|
|
921
932
|
const expandedOps = expandChainedComparisons($0);
|
|
@@ -1209,10 +1220,10 @@ ${input.slice(result.pos)}
|
|
|
1209
1220
|
}
|
|
1210
1221
|
function wrapWithReturn(expression) {
|
|
1211
1222
|
const children = expression ? ["return ", expression] : ["return"];
|
|
1212
|
-
return {
|
|
1223
|
+
return makeNode({
|
|
1213
1224
|
type: "ReturnStatement",
|
|
1214
1225
|
children
|
|
1215
|
-
};
|
|
1226
|
+
});
|
|
1216
1227
|
}
|
|
1217
1228
|
function isExistence(exp) {
|
|
1218
1229
|
if (exp.type === "ParenthesizedExpression" && exp.implicit) {
|
|
@@ -1507,6 +1518,7 @@ ${input.slice(result.pos)}
|
|
|
1507
1518
|
const indent = expressions[index][0];
|
|
1508
1519
|
expressions.splice(index, 0, [indent, dec, ";"]);
|
|
1509
1520
|
}
|
|
1521
|
+
addParentPointers(dec, block);
|
|
1510
1522
|
}
|
|
1511
1523
|
function patternAsValue(pattern) {
|
|
1512
1524
|
switch (pattern.type) {
|
|
@@ -1585,7 +1597,8 @@ ${input.slice(result.pos)}
|
|
|
1585
1597
|
case "Declaration":
|
|
1586
1598
|
exp.children.push(["", {
|
|
1587
1599
|
type: "ReturnStatement",
|
|
1588
|
-
children: [";return ", patternAsValue(exp.bindings.at(-1).pattern)]
|
|
1600
|
+
children: [";return ", patternAsValue(exp.bindings.at(-1).pattern)],
|
|
1601
|
+
parent: exp
|
|
1589
1602
|
}]);
|
|
1590
1603
|
return;
|
|
1591
1604
|
case "FunctionExpression":
|
|
@@ -1594,7 +1607,8 @@ ${input.slice(result.pos)}
|
|
|
1594
1607
|
"",
|
|
1595
1608
|
{
|
|
1596
1609
|
type: "ReturnStatement",
|
|
1597
|
-
children: [";return ", exp.id]
|
|
1610
|
+
children: [";return ", exp.id],
|
|
1611
|
+
parent: exp
|
|
1598
1612
|
}
|
|
1599
1613
|
]);
|
|
1600
1614
|
return;
|
|
@@ -1616,7 +1630,8 @@ ${input.slice(result.pos)}
|
|
|
1616
1630
|
exp.children.push(["", {
|
|
1617
1631
|
type: "ReturnStatement",
|
|
1618
1632
|
// NOTE: add a prefixed semi-colon because the if block may not be braced
|
|
1619
|
-
children: [";return"]
|
|
1633
|
+
children: [";return"],
|
|
1634
|
+
parent: exp
|
|
1620
1635
|
}]);
|
|
1621
1636
|
return;
|
|
1622
1637
|
case "PatternMatchingStatement":
|
|
@@ -2036,14 +2051,13 @@ ${input.slice(result.pos)}
|
|
|
2036
2051
|
case "ThrowExpression":
|
|
2037
2052
|
case "TryExpression":
|
|
2038
2053
|
return expression;
|
|
2039
|
-
default:
|
|
2040
|
-
return {
|
|
2041
|
-
type: "ParenthesizedExpression",
|
|
2042
|
-
children: ["(", expression, ")"],
|
|
2043
|
-
expression,
|
|
2044
|
-
implicit: true
|
|
2045
|
-
};
|
|
2046
2054
|
}
|
|
2055
|
+
return makeNode({
|
|
2056
|
+
type: "ParenthesizedExpression",
|
|
2057
|
+
children: ["(", expression, ")"],
|
|
2058
|
+
expression,
|
|
2059
|
+
implicit: true
|
|
2060
|
+
});
|
|
2047
2061
|
}
|
|
2048
2062
|
function modifyString(str) {
|
|
2049
2063
|
return str.replace(/(^.?|[^\\]{2})(\\\\)*\n/g, "$1$2\\n");
|
|
@@ -2250,7 +2264,7 @@ ${input.slice(result.pos)}
|
|
|
2250
2264
|
splices = splices.map((s) => [", ", s]);
|
|
2251
2265
|
thisAssignments = thisAssignments.map((a) => ["", a, ";"]);
|
|
2252
2266
|
const initializer = [ws, assign, e];
|
|
2253
|
-
const binding = {
|
|
2267
|
+
const binding = makeNode({
|
|
2254
2268
|
type: "Binding",
|
|
2255
2269
|
pattern: id,
|
|
2256
2270
|
initializer,
|
|
@@ -2258,9 +2272,9 @@ ${input.slice(result.pos)}
|
|
|
2258
2272
|
suffix,
|
|
2259
2273
|
thisAssignments,
|
|
2260
2274
|
children: [id, suffix, initializer]
|
|
2261
|
-
};
|
|
2275
|
+
});
|
|
2262
2276
|
const children = [decl, binding];
|
|
2263
|
-
return {
|
|
2277
|
+
return makeNode({
|
|
2264
2278
|
type: "Declaration",
|
|
2265
2279
|
names: id.names,
|
|
2266
2280
|
decl,
|
|
@@ -2268,9 +2282,9 @@ ${input.slice(result.pos)}
|
|
|
2268
2282
|
splices,
|
|
2269
2283
|
thisAssignments,
|
|
2270
2284
|
children
|
|
2271
|
-
};
|
|
2285
|
+
});
|
|
2272
2286
|
}
|
|
2273
|
-
function processDeclarationCondition(condition, rootCondition) {
|
|
2287
|
+
function processDeclarationCondition(condition, rootCondition, parent) {
|
|
2274
2288
|
if (!(condition.type === "DeclarationCondition")) {
|
|
2275
2289
|
return;
|
|
2276
2290
|
}
|
|
@@ -2289,6 +2303,7 @@ ${input.slice(result.pos)}
|
|
|
2289
2303
|
pattern,
|
|
2290
2304
|
ref
|
|
2291
2305
|
});
|
|
2306
|
+
addParentPointers(condition, parent);
|
|
2292
2307
|
Object.assign(rootCondition, {
|
|
2293
2308
|
blockPrefix: [
|
|
2294
2309
|
["", [decl, pattern, suffix, " = ", ref, ...splices], ";"],
|
|
@@ -2312,7 +2327,7 @@ ${input.slice(result.pos)}
|
|
|
2312
2327
|
const type = [type1, type2];
|
|
2313
2328
|
expression = expression2;
|
|
2314
2329
|
}
|
|
2315
|
-
processDeclarationCondition(expression, condition.expression);
|
|
2330
|
+
processDeclarationCondition(expression, condition.expression, s);
|
|
2316
2331
|
const { ref, pattern } = expression;
|
|
2317
2332
|
if (pattern) {
|
|
2318
2333
|
let conditions = [];
|
|
@@ -2362,10 +2377,12 @@ ${input.slice(result.pos)}
|
|
|
2362
2377
|
parent: s
|
|
2363
2378
|
};
|
|
2364
2379
|
s.children[1] = s.condition;
|
|
2380
|
+
updateParentPointers(s);
|
|
2365
2381
|
const block = blockWithPrefix([["", [{
|
|
2366
2382
|
type: "Declaration",
|
|
2367
2383
|
children: ["let ", ...condition.expression.children]
|
|
2368
2384
|
}], ";"], ...blockPrefix], makeEmptyBlock());
|
|
2385
|
+
updateParentPointers(block, s.parent);
|
|
2369
2386
|
replaceBlockExpression(s.parent, s, block);
|
|
2370
2387
|
block.expressions.push(["", s]);
|
|
2371
2388
|
s.parent = block;
|
|
@@ -3598,12 +3615,12 @@ ${input.slice(result.pos)}
|
|
|
3598
3615
|
children: ["await "]
|
|
3599
3616
|
};
|
|
3600
3617
|
}
|
|
3601
|
-
const block = {
|
|
3618
|
+
const block = makeNode({
|
|
3602
3619
|
type: "BlockStatement",
|
|
3603
3620
|
expressions,
|
|
3604
3621
|
children: ["{", expressions, "}"],
|
|
3605
3622
|
bare: false
|
|
3606
|
-
};
|
|
3623
|
+
});
|
|
3607
3624
|
const parameters = {
|
|
3608
3625
|
type: "Parameters",
|
|
3609
3626
|
children: ["()"],
|
|
@@ -3615,7 +3632,7 @@ ${input.slice(result.pos)}
|
|
|
3615
3632
|
},
|
|
3616
3633
|
returnType: void 0
|
|
3617
3634
|
};
|
|
3618
|
-
const fn = {
|
|
3635
|
+
const fn = makeNode({
|
|
3619
3636
|
type: "ArrowFunction",
|
|
3620
3637
|
signature,
|
|
3621
3638
|
parameters,
|
|
@@ -3624,12 +3641,11 @@ ${input.slice(result.pos)}
|
|
|
3624
3641
|
async,
|
|
3625
3642
|
block,
|
|
3626
3643
|
children: [async, parameters, "=>", block]
|
|
3627
|
-
};
|
|
3628
|
-
|
|
3629
|
-
const exp = {
|
|
3644
|
+
});
|
|
3645
|
+
const exp = makeNode({
|
|
3630
3646
|
type: "CallExpression",
|
|
3631
3647
|
children: [makeLeftHandSideExpression(fn), "()"]
|
|
3632
|
-
};
|
|
3648
|
+
});
|
|
3633
3649
|
if (prefix) {
|
|
3634
3650
|
return [makeLeftHandSideExpression([prefix, exp])];
|
|
3635
3651
|
}
|
package/dist/main.js
CHANGED
|
@@ -498,6 +498,7 @@ var require_lib = __commonJS({
|
|
|
498
498
|
}
|
|
499
499
|
return;
|
|
500
500
|
}
|
|
501
|
+
node = node;
|
|
501
502
|
node.parent = parent;
|
|
502
503
|
if (node.children) {
|
|
503
504
|
for (const child of node.children) {
|
|
@@ -516,6 +517,7 @@ var require_lib = __commonJS({
|
|
|
516
517
|
}
|
|
517
518
|
return;
|
|
518
519
|
}
|
|
520
|
+
node = node;
|
|
519
521
|
if (parent != null)
|
|
520
522
|
node.parent = parent;
|
|
521
523
|
if (depth && node.children) {
|
|
@@ -524,20 +526,24 @@ var require_lib = __commonJS({
|
|
|
524
526
|
}
|
|
525
527
|
}
|
|
526
528
|
}
|
|
529
|
+
function makeNode(node) {
|
|
530
|
+
updateParentPointers(node);
|
|
531
|
+
return node;
|
|
532
|
+
}
|
|
527
533
|
function addPostfixStatement(statement, ws, post) {
|
|
528
534
|
const expressions = [
|
|
529
535
|
...post.blockPrefix || [],
|
|
530
536
|
["", statement]
|
|
531
537
|
];
|
|
532
|
-
const block = {
|
|
538
|
+
const block = makeNode({
|
|
533
539
|
type: "BlockStatement",
|
|
534
540
|
children: [" { ", expressions, " }"],
|
|
535
541
|
expressions
|
|
536
|
-
};
|
|
542
|
+
});
|
|
537
543
|
const children = [...post.children, block];
|
|
538
544
|
if (!isWhitespaceOrEmpty(ws))
|
|
539
545
|
children.push(ws);
|
|
540
|
-
post = { ...post, children, block };
|
|
546
|
+
post = makeNode({ ...post, children, block });
|
|
541
547
|
if (post.type === "IfStatement") {
|
|
542
548
|
post.then = block;
|
|
543
549
|
}
|
|
@@ -651,6 +657,7 @@ var require_lib = __commonJS({
|
|
|
651
657
|
});
|
|
652
658
|
}
|
|
653
659
|
const expressions = [...prefixStatements, ...block.expressions];
|
|
660
|
+
addParentPointers(prefixStatements, block);
|
|
654
661
|
block = {
|
|
655
662
|
...block,
|
|
656
663
|
expressions,
|
|
@@ -660,6 +667,7 @@ var require_lib = __commonJS({
|
|
|
660
667
|
block.children = [[" {"], ...block.children, "}"];
|
|
661
668
|
block.bare = false;
|
|
662
669
|
}
|
|
670
|
+
updateParentPointers(block);
|
|
663
671
|
}
|
|
664
672
|
return block;
|
|
665
673
|
}
|
|
@@ -677,10 +685,11 @@ var require_lib = __commonJS({
|
|
|
677
685
|
const { ref, body } = expr;
|
|
678
686
|
ref.type = "PipedExpression";
|
|
679
687
|
ref.children = [makeLeftHandSideExpression(arg)];
|
|
680
|
-
|
|
688
|
+
updateParentPointers(ref);
|
|
689
|
+
return makeNode({
|
|
681
690
|
type: "UnwrappedExpression",
|
|
682
691
|
children: [skipIfOnlyWS(fn.leadingComment), body, skipIfOnlyWS(fn.trailingComment)]
|
|
683
|
-
};
|
|
692
|
+
});
|
|
684
693
|
}
|
|
685
694
|
expr = fn.expr;
|
|
686
695
|
const lhs = makeLeftHandSideExpression(expr);
|
|
@@ -894,6 +903,7 @@ var require_lib = __commonJS({
|
|
|
894
903
|
if (subtype === "DoStatement") {
|
|
895
904
|
insertReturn(block);
|
|
896
905
|
children.splice(i, 1, ...wrapIIFE(["", statement, void 0], async));
|
|
906
|
+
updateParentPointers(exp);
|
|
897
907
|
return;
|
|
898
908
|
}
|
|
899
909
|
const resultsRef = makeRef("results");
|
|
@@ -908,6 +918,7 @@ var require_lib = __commonJS({
|
|
|
908
918
|
["", wrapWithReturn(resultsRef)]
|
|
909
919
|
], async)
|
|
910
920
|
);
|
|
921
|
+
updateParentPointers(exp);
|
|
911
922
|
}
|
|
912
923
|
function processBinaryOpExpression($0) {
|
|
913
924
|
const expandedOps = expandChainedComparisons($0);
|
|
@@ -1201,10 +1212,10 @@ var require_lib = __commonJS({
|
|
|
1201
1212
|
}
|
|
1202
1213
|
function wrapWithReturn(expression) {
|
|
1203
1214
|
const children = expression ? ["return ", expression] : ["return"];
|
|
1204
|
-
return {
|
|
1215
|
+
return makeNode({
|
|
1205
1216
|
type: "ReturnStatement",
|
|
1206
1217
|
children
|
|
1207
|
-
};
|
|
1218
|
+
});
|
|
1208
1219
|
}
|
|
1209
1220
|
function isExistence(exp) {
|
|
1210
1221
|
if (exp.type === "ParenthesizedExpression" && exp.implicit) {
|
|
@@ -1499,6 +1510,7 @@ var require_lib = __commonJS({
|
|
|
1499
1510
|
const indent = expressions[index][0];
|
|
1500
1511
|
expressions.splice(index, 0, [indent, dec, ";"]);
|
|
1501
1512
|
}
|
|
1513
|
+
addParentPointers(dec, block);
|
|
1502
1514
|
}
|
|
1503
1515
|
function patternAsValue(pattern) {
|
|
1504
1516
|
switch (pattern.type) {
|
|
@@ -1577,7 +1589,8 @@ var require_lib = __commonJS({
|
|
|
1577
1589
|
case "Declaration":
|
|
1578
1590
|
exp.children.push(["", {
|
|
1579
1591
|
type: "ReturnStatement",
|
|
1580
|
-
children: [";return ", patternAsValue(exp.bindings.at(-1).pattern)]
|
|
1592
|
+
children: [";return ", patternAsValue(exp.bindings.at(-1).pattern)],
|
|
1593
|
+
parent: exp
|
|
1581
1594
|
}]);
|
|
1582
1595
|
return;
|
|
1583
1596
|
case "FunctionExpression":
|
|
@@ -1586,7 +1599,8 @@ var require_lib = __commonJS({
|
|
|
1586
1599
|
"",
|
|
1587
1600
|
{
|
|
1588
1601
|
type: "ReturnStatement",
|
|
1589
|
-
children: [";return ", exp.id]
|
|
1602
|
+
children: [";return ", exp.id],
|
|
1603
|
+
parent: exp
|
|
1590
1604
|
}
|
|
1591
1605
|
]);
|
|
1592
1606
|
return;
|
|
@@ -1608,7 +1622,8 @@ var require_lib = __commonJS({
|
|
|
1608
1622
|
exp.children.push(["", {
|
|
1609
1623
|
type: "ReturnStatement",
|
|
1610
1624
|
// NOTE: add a prefixed semi-colon because the if block may not be braced
|
|
1611
|
-
children: [";return"]
|
|
1625
|
+
children: [";return"],
|
|
1626
|
+
parent: exp
|
|
1612
1627
|
}]);
|
|
1613
1628
|
return;
|
|
1614
1629
|
case "PatternMatchingStatement":
|
|
@@ -2028,14 +2043,13 @@ var require_lib = __commonJS({
|
|
|
2028
2043
|
case "ThrowExpression":
|
|
2029
2044
|
case "TryExpression":
|
|
2030
2045
|
return expression;
|
|
2031
|
-
default:
|
|
2032
|
-
return {
|
|
2033
|
-
type: "ParenthesizedExpression",
|
|
2034
|
-
children: ["(", expression, ")"],
|
|
2035
|
-
expression,
|
|
2036
|
-
implicit: true
|
|
2037
|
-
};
|
|
2038
2046
|
}
|
|
2047
|
+
return makeNode({
|
|
2048
|
+
type: "ParenthesizedExpression",
|
|
2049
|
+
children: ["(", expression, ")"],
|
|
2050
|
+
expression,
|
|
2051
|
+
implicit: true
|
|
2052
|
+
});
|
|
2039
2053
|
}
|
|
2040
2054
|
function modifyString(str) {
|
|
2041
2055
|
return str.replace(/(^.?|[^\\]{2})(\\\\)*\n/g, "$1$2\\n");
|
|
@@ -2242,7 +2256,7 @@ var require_lib = __commonJS({
|
|
|
2242
2256
|
splices = splices.map((s) => [", ", s]);
|
|
2243
2257
|
thisAssignments = thisAssignments.map((a) => ["", a, ";"]);
|
|
2244
2258
|
const initializer = [ws, assign, e];
|
|
2245
|
-
const binding = {
|
|
2259
|
+
const binding = makeNode({
|
|
2246
2260
|
type: "Binding",
|
|
2247
2261
|
pattern: id,
|
|
2248
2262
|
initializer,
|
|
@@ -2250,9 +2264,9 @@ var require_lib = __commonJS({
|
|
|
2250
2264
|
suffix,
|
|
2251
2265
|
thisAssignments,
|
|
2252
2266
|
children: [id, suffix, initializer]
|
|
2253
|
-
};
|
|
2267
|
+
});
|
|
2254
2268
|
const children = [decl, binding];
|
|
2255
|
-
return {
|
|
2269
|
+
return makeNode({
|
|
2256
2270
|
type: "Declaration",
|
|
2257
2271
|
names: id.names,
|
|
2258
2272
|
decl,
|
|
@@ -2260,9 +2274,9 @@ var require_lib = __commonJS({
|
|
|
2260
2274
|
splices,
|
|
2261
2275
|
thisAssignments,
|
|
2262
2276
|
children
|
|
2263
|
-
};
|
|
2277
|
+
});
|
|
2264
2278
|
}
|
|
2265
|
-
function processDeclarationCondition(condition, rootCondition) {
|
|
2279
|
+
function processDeclarationCondition(condition, rootCondition, parent) {
|
|
2266
2280
|
if (!(condition.type === "DeclarationCondition")) {
|
|
2267
2281
|
return;
|
|
2268
2282
|
}
|
|
@@ -2281,6 +2295,7 @@ var require_lib = __commonJS({
|
|
|
2281
2295
|
pattern,
|
|
2282
2296
|
ref
|
|
2283
2297
|
});
|
|
2298
|
+
addParentPointers(condition, parent);
|
|
2284
2299
|
Object.assign(rootCondition, {
|
|
2285
2300
|
blockPrefix: [
|
|
2286
2301
|
["", [decl, pattern, suffix, " = ", ref, ...splices], ";"],
|
|
@@ -2304,7 +2319,7 @@ var require_lib = __commonJS({
|
|
|
2304
2319
|
const type = [type1, type2];
|
|
2305
2320
|
expression = expression2;
|
|
2306
2321
|
}
|
|
2307
|
-
processDeclarationCondition(expression, condition.expression);
|
|
2322
|
+
processDeclarationCondition(expression, condition.expression, s);
|
|
2308
2323
|
const { ref, pattern } = expression;
|
|
2309
2324
|
if (pattern) {
|
|
2310
2325
|
let conditions = [];
|
|
@@ -2354,10 +2369,12 @@ var require_lib = __commonJS({
|
|
|
2354
2369
|
parent: s
|
|
2355
2370
|
};
|
|
2356
2371
|
s.children[1] = s.condition;
|
|
2372
|
+
updateParentPointers(s);
|
|
2357
2373
|
const block = blockWithPrefix([["", [{
|
|
2358
2374
|
type: "Declaration",
|
|
2359
2375
|
children: ["let ", ...condition.expression.children]
|
|
2360
2376
|
}], ";"], ...blockPrefix], makeEmptyBlock());
|
|
2377
|
+
updateParentPointers(block, s.parent);
|
|
2361
2378
|
replaceBlockExpression(s.parent, s, block);
|
|
2362
2379
|
block.expressions.push(["", s]);
|
|
2363
2380
|
s.parent = block;
|
|
@@ -3590,12 +3607,12 @@ var require_lib = __commonJS({
|
|
|
3590
3607
|
children: ["await "]
|
|
3591
3608
|
};
|
|
3592
3609
|
}
|
|
3593
|
-
const block = {
|
|
3610
|
+
const block = makeNode({
|
|
3594
3611
|
type: "BlockStatement",
|
|
3595
3612
|
expressions,
|
|
3596
3613
|
children: ["{", expressions, "}"],
|
|
3597
3614
|
bare: false
|
|
3598
|
-
};
|
|
3615
|
+
});
|
|
3599
3616
|
const parameters = {
|
|
3600
3617
|
type: "Parameters",
|
|
3601
3618
|
children: ["()"],
|
|
@@ -3607,7 +3624,7 @@ var require_lib = __commonJS({
|
|
|
3607
3624
|
},
|
|
3608
3625
|
returnType: void 0
|
|
3609
3626
|
};
|
|
3610
|
-
const fn = {
|
|
3627
|
+
const fn = makeNode({
|
|
3611
3628
|
type: "ArrowFunction",
|
|
3612
3629
|
signature,
|
|
3613
3630
|
parameters,
|
|
@@ -3616,12 +3633,11 @@ var require_lib = __commonJS({
|
|
|
3616
3633
|
async,
|
|
3617
3634
|
block,
|
|
3618
3635
|
children: [async, parameters, "=>", block]
|
|
3619
|
-
};
|
|
3620
|
-
|
|
3621
|
-
const exp = {
|
|
3636
|
+
});
|
|
3637
|
+
const exp = makeNode({
|
|
3622
3638
|
type: "CallExpression",
|
|
3623
3639
|
children: [makeLeftHandSideExpression(fn), "()"]
|
|
3624
|
-
};
|
|
3640
|
+
});
|
|
3625
3641
|
if (prefix) {
|
|
3626
3642
|
return [makeLeftHandSideExpression([prefix, exp])];
|
|
3627
3643
|
}
|
package/dist/main.mjs
CHANGED
|
@@ -496,6 +496,7 @@ var require_lib = __commonJS({
|
|
|
496
496
|
}
|
|
497
497
|
return;
|
|
498
498
|
}
|
|
499
|
+
node = node;
|
|
499
500
|
node.parent = parent;
|
|
500
501
|
if (node.children) {
|
|
501
502
|
for (const child of node.children) {
|
|
@@ -514,6 +515,7 @@ var require_lib = __commonJS({
|
|
|
514
515
|
}
|
|
515
516
|
return;
|
|
516
517
|
}
|
|
518
|
+
node = node;
|
|
517
519
|
if (parent != null)
|
|
518
520
|
node.parent = parent;
|
|
519
521
|
if (depth && node.children) {
|
|
@@ -522,20 +524,24 @@ var require_lib = __commonJS({
|
|
|
522
524
|
}
|
|
523
525
|
}
|
|
524
526
|
}
|
|
527
|
+
function makeNode(node) {
|
|
528
|
+
updateParentPointers(node);
|
|
529
|
+
return node;
|
|
530
|
+
}
|
|
525
531
|
function addPostfixStatement(statement, ws, post) {
|
|
526
532
|
const expressions = [
|
|
527
533
|
...post.blockPrefix || [],
|
|
528
534
|
["", statement]
|
|
529
535
|
];
|
|
530
|
-
const block = {
|
|
536
|
+
const block = makeNode({
|
|
531
537
|
type: "BlockStatement",
|
|
532
538
|
children: [" { ", expressions, " }"],
|
|
533
539
|
expressions
|
|
534
|
-
};
|
|
540
|
+
});
|
|
535
541
|
const children = [...post.children, block];
|
|
536
542
|
if (!isWhitespaceOrEmpty(ws))
|
|
537
543
|
children.push(ws);
|
|
538
|
-
post = { ...post, children, block };
|
|
544
|
+
post = makeNode({ ...post, children, block });
|
|
539
545
|
if (post.type === "IfStatement") {
|
|
540
546
|
post.then = block;
|
|
541
547
|
}
|
|
@@ -649,6 +655,7 @@ var require_lib = __commonJS({
|
|
|
649
655
|
});
|
|
650
656
|
}
|
|
651
657
|
const expressions = [...prefixStatements, ...block.expressions];
|
|
658
|
+
addParentPointers(prefixStatements, block);
|
|
652
659
|
block = {
|
|
653
660
|
...block,
|
|
654
661
|
expressions,
|
|
@@ -658,6 +665,7 @@ var require_lib = __commonJS({
|
|
|
658
665
|
block.children = [[" {"], ...block.children, "}"];
|
|
659
666
|
block.bare = false;
|
|
660
667
|
}
|
|
668
|
+
updateParentPointers(block);
|
|
661
669
|
}
|
|
662
670
|
return block;
|
|
663
671
|
}
|
|
@@ -675,10 +683,11 @@ var require_lib = __commonJS({
|
|
|
675
683
|
const { ref, body } = expr;
|
|
676
684
|
ref.type = "PipedExpression";
|
|
677
685
|
ref.children = [makeLeftHandSideExpression(arg)];
|
|
678
|
-
|
|
686
|
+
updateParentPointers(ref);
|
|
687
|
+
return makeNode({
|
|
679
688
|
type: "UnwrappedExpression",
|
|
680
689
|
children: [skipIfOnlyWS(fn.leadingComment), body, skipIfOnlyWS(fn.trailingComment)]
|
|
681
|
-
};
|
|
690
|
+
});
|
|
682
691
|
}
|
|
683
692
|
expr = fn.expr;
|
|
684
693
|
const lhs = makeLeftHandSideExpression(expr);
|
|
@@ -892,6 +901,7 @@ var require_lib = __commonJS({
|
|
|
892
901
|
if (subtype === "DoStatement") {
|
|
893
902
|
insertReturn(block);
|
|
894
903
|
children.splice(i, 1, ...wrapIIFE(["", statement, void 0], async));
|
|
904
|
+
updateParentPointers(exp);
|
|
895
905
|
return;
|
|
896
906
|
}
|
|
897
907
|
const resultsRef = makeRef("results");
|
|
@@ -906,6 +916,7 @@ var require_lib = __commonJS({
|
|
|
906
916
|
["", wrapWithReturn(resultsRef)]
|
|
907
917
|
], async)
|
|
908
918
|
);
|
|
919
|
+
updateParentPointers(exp);
|
|
909
920
|
}
|
|
910
921
|
function processBinaryOpExpression($0) {
|
|
911
922
|
const expandedOps = expandChainedComparisons($0);
|
|
@@ -1199,10 +1210,10 @@ var require_lib = __commonJS({
|
|
|
1199
1210
|
}
|
|
1200
1211
|
function wrapWithReturn(expression) {
|
|
1201
1212
|
const children = expression ? ["return ", expression] : ["return"];
|
|
1202
|
-
return {
|
|
1213
|
+
return makeNode({
|
|
1203
1214
|
type: "ReturnStatement",
|
|
1204
1215
|
children
|
|
1205
|
-
};
|
|
1216
|
+
});
|
|
1206
1217
|
}
|
|
1207
1218
|
function isExistence(exp) {
|
|
1208
1219
|
if (exp.type === "ParenthesizedExpression" && exp.implicit) {
|
|
@@ -1497,6 +1508,7 @@ var require_lib = __commonJS({
|
|
|
1497
1508
|
const indent = expressions[index][0];
|
|
1498
1509
|
expressions.splice(index, 0, [indent, dec, ";"]);
|
|
1499
1510
|
}
|
|
1511
|
+
addParentPointers(dec, block);
|
|
1500
1512
|
}
|
|
1501
1513
|
function patternAsValue(pattern) {
|
|
1502
1514
|
switch (pattern.type) {
|
|
@@ -1575,7 +1587,8 @@ var require_lib = __commonJS({
|
|
|
1575
1587
|
case "Declaration":
|
|
1576
1588
|
exp.children.push(["", {
|
|
1577
1589
|
type: "ReturnStatement",
|
|
1578
|
-
children: [";return ", patternAsValue(exp.bindings.at(-1).pattern)]
|
|
1590
|
+
children: [";return ", patternAsValue(exp.bindings.at(-1).pattern)],
|
|
1591
|
+
parent: exp
|
|
1579
1592
|
}]);
|
|
1580
1593
|
return;
|
|
1581
1594
|
case "FunctionExpression":
|
|
@@ -1584,7 +1597,8 @@ var require_lib = __commonJS({
|
|
|
1584
1597
|
"",
|
|
1585
1598
|
{
|
|
1586
1599
|
type: "ReturnStatement",
|
|
1587
|
-
children: [";return ", exp.id]
|
|
1600
|
+
children: [";return ", exp.id],
|
|
1601
|
+
parent: exp
|
|
1588
1602
|
}
|
|
1589
1603
|
]);
|
|
1590
1604
|
return;
|
|
@@ -1606,7 +1620,8 @@ var require_lib = __commonJS({
|
|
|
1606
1620
|
exp.children.push(["", {
|
|
1607
1621
|
type: "ReturnStatement",
|
|
1608
1622
|
// NOTE: add a prefixed semi-colon because the if block may not be braced
|
|
1609
|
-
children: [";return"]
|
|
1623
|
+
children: [";return"],
|
|
1624
|
+
parent: exp
|
|
1610
1625
|
}]);
|
|
1611
1626
|
return;
|
|
1612
1627
|
case "PatternMatchingStatement":
|
|
@@ -2026,14 +2041,13 @@ var require_lib = __commonJS({
|
|
|
2026
2041
|
case "ThrowExpression":
|
|
2027
2042
|
case "TryExpression":
|
|
2028
2043
|
return expression;
|
|
2029
|
-
default:
|
|
2030
|
-
return {
|
|
2031
|
-
type: "ParenthesizedExpression",
|
|
2032
|
-
children: ["(", expression, ")"],
|
|
2033
|
-
expression,
|
|
2034
|
-
implicit: true
|
|
2035
|
-
};
|
|
2036
2044
|
}
|
|
2045
|
+
return makeNode({
|
|
2046
|
+
type: "ParenthesizedExpression",
|
|
2047
|
+
children: ["(", expression, ")"],
|
|
2048
|
+
expression,
|
|
2049
|
+
implicit: true
|
|
2050
|
+
});
|
|
2037
2051
|
}
|
|
2038
2052
|
function modifyString(str) {
|
|
2039
2053
|
return str.replace(/(^.?|[^\\]{2})(\\\\)*\n/g, "$1$2\\n");
|
|
@@ -2240,7 +2254,7 @@ var require_lib = __commonJS({
|
|
|
2240
2254
|
splices = splices.map((s) => [", ", s]);
|
|
2241
2255
|
thisAssignments = thisAssignments.map((a) => ["", a, ";"]);
|
|
2242
2256
|
const initializer = [ws, assign, e];
|
|
2243
|
-
const binding = {
|
|
2257
|
+
const binding = makeNode({
|
|
2244
2258
|
type: "Binding",
|
|
2245
2259
|
pattern: id,
|
|
2246
2260
|
initializer,
|
|
@@ -2248,9 +2262,9 @@ var require_lib = __commonJS({
|
|
|
2248
2262
|
suffix,
|
|
2249
2263
|
thisAssignments,
|
|
2250
2264
|
children: [id, suffix, initializer]
|
|
2251
|
-
};
|
|
2265
|
+
});
|
|
2252
2266
|
const children = [decl, binding];
|
|
2253
|
-
return {
|
|
2267
|
+
return makeNode({
|
|
2254
2268
|
type: "Declaration",
|
|
2255
2269
|
names: id.names,
|
|
2256
2270
|
decl,
|
|
@@ -2258,9 +2272,9 @@ var require_lib = __commonJS({
|
|
|
2258
2272
|
splices,
|
|
2259
2273
|
thisAssignments,
|
|
2260
2274
|
children
|
|
2261
|
-
};
|
|
2275
|
+
});
|
|
2262
2276
|
}
|
|
2263
|
-
function processDeclarationCondition(condition, rootCondition) {
|
|
2277
|
+
function processDeclarationCondition(condition, rootCondition, parent) {
|
|
2264
2278
|
if (!(condition.type === "DeclarationCondition")) {
|
|
2265
2279
|
return;
|
|
2266
2280
|
}
|
|
@@ -2279,6 +2293,7 @@ var require_lib = __commonJS({
|
|
|
2279
2293
|
pattern,
|
|
2280
2294
|
ref
|
|
2281
2295
|
});
|
|
2296
|
+
addParentPointers(condition, parent);
|
|
2282
2297
|
Object.assign(rootCondition, {
|
|
2283
2298
|
blockPrefix: [
|
|
2284
2299
|
["", [decl, pattern, suffix, " = ", ref, ...splices], ";"],
|
|
@@ -2302,7 +2317,7 @@ var require_lib = __commonJS({
|
|
|
2302
2317
|
const type = [type1, type2];
|
|
2303
2318
|
expression = expression2;
|
|
2304
2319
|
}
|
|
2305
|
-
processDeclarationCondition(expression, condition.expression);
|
|
2320
|
+
processDeclarationCondition(expression, condition.expression, s);
|
|
2306
2321
|
const { ref, pattern } = expression;
|
|
2307
2322
|
if (pattern) {
|
|
2308
2323
|
let conditions = [];
|
|
@@ -2352,10 +2367,12 @@ var require_lib = __commonJS({
|
|
|
2352
2367
|
parent: s
|
|
2353
2368
|
};
|
|
2354
2369
|
s.children[1] = s.condition;
|
|
2370
|
+
updateParentPointers(s);
|
|
2355
2371
|
const block = blockWithPrefix([["", [{
|
|
2356
2372
|
type: "Declaration",
|
|
2357
2373
|
children: ["let ", ...condition.expression.children]
|
|
2358
2374
|
}], ";"], ...blockPrefix], makeEmptyBlock());
|
|
2375
|
+
updateParentPointers(block, s.parent);
|
|
2359
2376
|
replaceBlockExpression(s.parent, s, block);
|
|
2360
2377
|
block.expressions.push(["", s]);
|
|
2361
2378
|
s.parent = block;
|
|
@@ -3588,12 +3605,12 @@ var require_lib = __commonJS({
|
|
|
3588
3605
|
children: ["await "]
|
|
3589
3606
|
};
|
|
3590
3607
|
}
|
|
3591
|
-
const block = {
|
|
3608
|
+
const block = makeNode({
|
|
3592
3609
|
type: "BlockStatement",
|
|
3593
3610
|
expressions,
|
|
3594
3611
|
children: ["{", expressions, "}"],
|
|
3595
3612
|
bare: false
|
|
3596
|
-
};
|
|
3613
|
+
});
|
|
3597
3614
|
const parameters = {
|
|
3598
3615
|
type: "Parameters",
|
|
3599
3616
|
children: ["()"],
|
|
@@ -3605,7 +3622,7 @@ var require_lib = __commonJS({
|
|
|
3605
3622
|
},
|
|
3606
3623
|
returnType: void 0
|
|
3607
3624
|
};
|
|
3608
|
-
const fn = {
|
|
3625
|
+
const fn = makeNode({
|
|
3609
3626
|
type: "ArrowFunction",
|
|
3610
3627
|
signature,
|
|
3611
3628
|
parameters,
|
|
@@ -3614,12 +3631,11 @@ var require_lib = __commonJS({
|
|
|
3614
3631
|
async,
|
|
3615
3632
|
block,
|
|
3616
3633
|
children: [async, parameters, "=>", block]
|
|
3617
|
-
};
|
|
3618
|
-
|
|
3619
|
-
const exp = {
|
|
3634
|
+
});
|
|
3635
|
+
const exp = makeNode({
|
|
3620
3636
|
type: "CallExpression",
|
|
3621
3637
|
children: [makeLeftHandSideExpression(fn), "()"]
|
|
3622
|
-
};
|
|
3638
|
+
});
|
|
3623
3639
|
if (prefix) {
|
|
3624
3640
|
return [makeLeftHandSideExpression([prefix, exp])];
|
|
3625
3641
|
}
|