@danielx/civet 0.5.80 → 0.5.81

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/main.mjs CHANGED
@@ -24,6 +24,106 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
24
24
  mod
25
25
  ));
26
26
 
27
+ // source/lib.js
28
+ var require_lib = __commonJS({
29
+ "source/lib.js"(exports, module) {
30
+ "use strict";
31
+ function clone(node) {
32
+ removeParentPointers(node);
33
+ return deepCopy(node);
34
+ }
35
+ function deepCopy(node) {
36
+ if (node == null)
37
+ return node;
38
+ if (typeof node !== "object")
39
+ return node;
40
+ if (Array.isArray(node)) {
41
+ return node.map(deepCopy);
42
+ }
43
+ return Object.fromEntries(
44
+ Object.entries(node).map(([key, value]) => {
45
+ return [key, deepCopy(value)];
46
+ })
47
+ );
48
+ }
49
+ function removeParentPointers(node) {
50
+ if (node == null)
51
+ return;
52
+ if (typeof node !== "object")
53
+ return;
54
+ if (Array.isArray(node)) {
55
+ for (const child of node) {
56
+ removeParentPointers(child);
57
+ }
58
+ return;
59
+ }
60
+ node.parent = null;
61
+ if (node.children) {
62
+ for (const child of node.children) {
63
+ removeParentPointers(child);
64
+ }
65
+ }
66
+ }
67
+ function gatherNodes(node, predicate) {
68
+ if (node == null)
69
+ return [];
70
+ if (Array.isArray(node)) {
71
+ return node.flatMap((n) => gatherNodes(n, predicate));
72
+ }
73
+ if (predicate(node)) {
74
+ return [node];
75
+ }
76
+ switch (node.type) {
77
+ case "BlockStatement":
78
+ return [];
79
+ case "ForStatement":
80
+ const isDec = node.declaration?.type === "Declaration";
81
+ return node.children.flatMap((n) => {
82
+ if (isDec && n === node.declaration)
83
+ return [];
84
+ return gatherNodes(n, predicate);
85
+ });
86
+ default:
87
+ return gatherNodes(node.children, predicate);
88
+ }
89
+ return [];
90
+ }
91
+ function gatherRecursive(node, predicate, skipPredicate) {
92
+ if (node == null)
93
+ return [];
94
+ if (Array.isArray(node)) {
95
+ return node.flatMap((n) => gatherRecursive(n, predicate, skipPredicate));
96
+ }
97
+ if (skipPredicate?.(node))
98
+ return [];
99
+ if (predicate(node)) {
100
+ return [node];
101
+ }
102
+ return gatherRecursive(node.children, predicate, skipPredicate);
103
+ }
104
+ function gatherRecursiveAll(node, predicate) {
105
+ if (node == null)
106
+ return [];
107
+ if (Array.isArray(node)) {
108
+ return node.flatMap((n) => gatherRecursiveAll(n, predicate));
109
+ }
110
+ const nodes = gatherRecursiveAll(node.children, predicate);
111
+ if (predicate(node)) {
112
+ nodes.push(node);
113
+ }
114
+ return nodes;
115
+ }
116
+ module.exports = {
117
+ clone,
118
+ deepCopy,
119
+ gatherNodes,
120
+ gatherRecursive,
121
+ gatherRecursiveAll,
122
+ removeParentPointers
123
+ };
124
+ }
125
+ });
126
+
27
127
  // source/parser.hera
28
128
  var require_parser = __commonJS({
29
129
  "source/parser.hera"(exports, module) {
@@ -563,6 +663,7 @@ ${input.slice(result.pos)}
563
663
  FunctionDeclaration,
564
664
  FunctionSignature,
565
665
  FunctionExpression,
666
+ AmpersandFunctionExpression,
566
667
  OperatorDeclaration,
567
668
  OperatorSignature,
568
669
  AmpersandBlockRHS,
@@ -1877,8 +1978,8 @@ ${input.slice(result.pos)}
1877
1978
  return module.insertTrimmingSpace($1, "");
1878
1979
  });
1879
1980
  var ArgumentList$2 = NestedArgumentList;
1880
- var ArgumentList$3 = $TS($S($Q(TrailingComment), ArgumentPart, $Q($S(CommaDelimiter, $Q(TrailingComment), ArgumentPart))), function($skip, $loc, $0, $1, $2, $3) {
1881
- return [...$1, $2, ...$3];
1981
+ var ArgumentList$3 = $TS($S($E(_), ArgumentPart, $Q($S(CommaDelimiter, $E(_), ArgumentPart))), function($skip, $loc, $0, $1, $2, $3) {
1982
+ return [...$1 || [], $2, ...$3];
1882
1983
  });
1883
1984
  function ArgumentList(state) {
1884
1985
  let eventData;
@@ -1907,8 +2008,8 @@ ${input.slice(result.pos)}
1907
2008
  return module.insertTrimmingSpace($1, "");
1908
2009
  });
1909
2010
  var NonPipelineArgumentList$2 = NestedArgumentList;
1910
- var NonPipelineArgumentList$3 = $TS($S($Q(TrailingComment), NonPipelineArgumentPart, $Q($S(CommaDelimiter, $Q(TrailingComment), NonPipelineArgumentPart))), function($skip, $loc, $0, $1, $2, $3) {
1911
- return [...$1, $2, ...$3];
2011
+ var NonPipelineArgumentList$3 = $TS($S($E(_), NonPipelineArgumentPart, $Q($S(CommaDelimiter, $E(_), NonPipelineArgumentPart))), function($skip, $loc, $0, $1, $2, $3) {
2012
+ return [...$1 || [], $2, ...$3];
1912
2013
  });
1913
2014
  function NonPipelineArgumentList(state) {
1914
2015
  let eventData;
@@ -1983,7 +2084,7 @@ ${input.slice(result.pos)}
1983
2084
  return result;
1984
2085
  }
1985
2086
  }
1986
- var SingleLineArgumentExpressions$0 = $S($Q(TrailingComment), ArgumentPart, $Q($S($Q(TrailingComment), Comma, $Q(TrailingComment), ArgumentPart)));
2087
+ var SingleLineArgumentExpressions$0 = $S($E(_), ArgumentPart, $Q($S($E(_), Comma, $E(_), ArgumentPart)));
1987
2088
  function SingleLineArgumentExpressions(state) {
1988
2089
  let eventData;
1989
2090
  if (state.events) {
@@ -2342,10 +2443,10 @@ ${input.slice(result.pos)}
2342
2443
  return result;
2343
2444
  }
2344
2445
  }
2345
- var SingleLineAssignmentExpression$0 = $TS($S($Q(TrailingComment), AssignmentExpressionTail), function($skip, $loc, $0, $1, $2) {
2446
+ var SingleLineAssignmentExpression$0 = $TS($S($E(_), AssignmentExpressionTail), function($skip, $loc, $0, $1, $2) {
2346
2447
  var ws = $1;
2347
2448
  var tail = $2;
2348
- if (ws.length) {
2449
+ if (ws?.length) {
2349
2450
  if (tail.children && tail.type !== "IterationExpression") {
2350
2451
  return {
2351
2452
  ...tail,
@@ -2462,7 +2563,7 @@ ${input.slice(result.pos)}
2462
2563
  }
2463
2564
  }
2464
2565
  var YieldTail$0 = $Y(EOS);
2465
- var YieldTail$1 = $S($E($S($Q(TrailingComment), Star)), AssignmentExpression);
2566
+ var YieldTail$1 = $S($E($S($E(_), Star)), AssignmentExpression);
2466
2567
  function YieldTail(state) {
2467
2568
  let eventData;
2468
2569
  if (state.events) {
@@ -2634,7 +2735,7 @@ ${input.slice(result.pos)}
2634
2735
  }
2635
2736
  }
2636
2737
  var TernaryRest$0 = NestedTernaryRest;
2637
- var TernaryRest$1 = $TS($S($N(CoffeeBinaryExistentialEnabled), $Y($EXPECT($L9, fail, 'TernaryRest " "')), $Q(TrailingComment), QuestionMark, ExtendedExpression, __, Colon, ExtendedExpression), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8) {
2738
+ var TernaryRest$1 = $TS($S($N(CoffeeBinaryExistentialEnabled), $Y($EXPECT($L9, fail, 'TernaryRest " "')), $E(_), QuestionMark, ExtendedExpression, __, Colon, ExtendedExpression), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8) {
2638
2739
  return $0.slice(2);
2639
2740
  });
2640
2741
  function TernaryRest(state) {
@@ -2713,6 +2814,23 @@ ${input.slice(result.pos)}
2713
2814
  var ws = $1;
2714
2815
  var head = $2;
2715
2816
  var body = $3;
2817
+ if (head.token === "&") {
2818
+ const ref = {
2819
+ type: "Ref",
2820
+ base: "$"
2821
+ };
2822
+ const arrowBody = {
2823
+ type: "PipelineExpression",
2824
+ children: [ws, ref, body]
2825
+ };
2826
+ return {
2827
+ type: "ArrowFunction",
2828
+ children: [ref, " => ", arrowBody],
2829
+ ref,
2830
+ body: [arrowBody],
2831
+ ampersandBlock: true
2832
+ };
2833
+ }
2716
2834
  return {
2717
2835
  type: "PipelineExpression",
2718
2836
  children: [ws, head, body]
@@ -2742,6 +2860,7 @@ ${input.slice(result.pos)}
2742
2860
  }
2743
2861
  var PipelineHeadItem$0 = NonPipelineExtendedExpression;
2744
2862
  var PipelineHeadItem$1 = ParenthesizedExpression;
2863
+ var PipelineHeadItem$2 = Ampersand;
2745
2864
  function PipelineHeadItem(state) {
2746
2865
  let eventData;
2747
2866
  if (state.events) {
@@ -2753,12 +2872,12 @@ ${input.slice(result.pos)}
2753
2872
  }
2754
2873
  }
2755
2874
  if (state.tokenize) {
2756
- const result = $TOKEN("PipelineHeadItem", state, PipelineHeadItem$0(state) || PipelineHeadItem$1(state));
2875
+ const result = $TOKEN("PipelineHeadItem", state, PipelineHeadItem$0(state) || PipelineHeadItem$1(state) || PipelineHeadItem$2(state));
2757
2876
  if (state.events)
2758
2877
  state.events.exit?.("PipelineHeadItem", state, result, eventData);
2759
2878
  return result;
2760
2879
  } else {
2761
- const result = PipelineHeadItem$0(state) || PipelineHeadItem$1(state);
2880
+ const result = PipelineHeadItem$0(state) || PipelineHeadItem$1(state) || PipelineHeadItem$2(state);
2762
2881
  if (state.events)
2763
2882
  state.events.exit?.("PipelineHeadItem", state, result, eventData);
2764
2883
  return result;
@@ -2767,7 +2886,10 @@ ${input.slice(result.pos)}
2767
2886
  var PipelineTailItem$0 = Await;
2768
2887
  var PipelineTailItem$1 = Yield;
2769
2888
  var PipelineTailItem$2 = Return;
2770
- var PipelineTailItem$3 = PipelineHeadItem;
2889
+ var PipelineTailItem$3 = AmpersandFunctionExpression;
2890
+ var PipelineTailItem$4 = $T($S($N(Ampersand), PipelineHeadItem), function(value) {
2891
+ return value[1];
2892
+ });
2771
2893
  function PipelineTailItem(state) {
2772
2894
  let eventData;
2773
2895
  if (state.events) {
@@ -2779,12 +2901,12 @@ ${input.slice(result.pos)}
2779
2901
  }
2780
2902
  }
2781
2903
  if (state.tokenize) {
2782
- const result = $TOKEN("PipelineTailItem", state, PipelineTailItem$0(state) || PipelineTailItem$1(state) || PipelineTailItem$2(state) || PipelineTailItem$3(state));
2904
+ const result = $TOKEN("PipelineTailItem", state, PipelineTailItem$0(state) || PipelineTailItem$1(state) || PipelineTailItem$2(state) || PipelineTailItem$3(state) || PipelineTailItem$4(state));
2783
2905
  if (state.events)
2784
2906
  state.events.exit?.("PipelineTailItem", state, result, eventData);
2785
2907
  return result;
2786
2908
  } else {
2787
- const result = PipelineTailItem$0(state) || PipelineTailItem$1(state) || PipelineTailItem$2(state) || PipelineTailItem$3(state);
2909
+ const result = PipelineTailItem$0(state) || PipelineTailItem$1(state) || PipelineTailItem$2(state) || PipelineTailItem$3(state) || PipelineTailItem$4(state);
2788
2910
  if (state.events)
2789
2911
  state.events.exit?.("PipelineTailItem", state, result, eventData);
2790
2912
  return result;
@@ -3231,7 +3353,7 @@ ${input.slice(result.pos)}
3231
3353
  return result;
3232
3354
  }
3233
3355
  }
3234
- var ClassElement$0 = $S($E(Decorators), $E(AccessModifier), $E($S(Static, $Q(TrailingComment))), ClassElementDefinition);
3356
+ var ClassElement$0 = $S($E(Decorators), $E(AccessModifier), $E($S(Static, $E(_))), ClassElementDefinition);
3235
3357
  var ClassElement$1 = $S(Static, BracedBlock);
3236
3358
  function ClassElement(state) {
3237
3359
  let eventData;
@@ -3377,7 +3499,7 @@ ${input.slice(result.pos)}
3377
3499
  return result;
3378
3500
  }
3379
3501
  }
3380
- var ClassSignatureElement$0 = $S($E(Decorators), $E(AccessModifier), $E($S(Static, $Q(TrailingComment))), $C(MethodSignature, FieldDefinition));
3502
+ var ClassSignatureElement$0 = $S($E(Decorators), $E(AccessModifier), $E($S(Static, $E(_))), $C(MethodSignature, FieldDefinition));
3381
3503
  var ClassSignatureElement$1 = $S(Static, ClassSignatureBody);
3382
3504
  function ClassSignatureElement(state) {
3383
3505
  let eventData;
@@ -3453,7 +3575,7 @@ ${input.slice(result.pos)}
3453
3575
  };
3454
3576
  return $0;
3455
3577
  });
3456
- var FieldDefinition$2 = $TS($S($E($S(Abstract, $Q(TrailingComment))), $E($S(Readonly, $Q(TrailingComment))), ClassElementName, $E(TypeSuffix), $E(Initializer)), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
3578
+ var FieldDefinition$2 = $TS($S($E($S(Abstract, $E(_))), $E($S(Readonly, $E(_))), ClassElementName, $E(TypeSuffix), $E(Initializer)), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
3457
3579
  if ($1)
3458
3580
  return { children: $0, ts: true };
3459
3581
  return $0;
@@ -5593,7 +5715,30 @@ ${input.slice(result.pos)}
5593
5715
  block
5594
5716
  };
5595
5717
  });
5596
- var FunctionExpression$1 = $TS($S($E(AmpersandUnaryPrefix), $C(Ampersand, $S($N(NumericLiteral), $Y($S($E(QuestionMark), Dot)))), $E(AmpersandBlockRHS)), function($skip, $loc, $0, $1, $2, $3) {
5718
+ var FunctionExpression$1 = AmpersandFunctionExpression;
5719
+ function FunctionExpression(state) {
5720
+ let eventData;
5721
+ if (state.events) {
5722
+ const result = state.events.enter?.("FunctionExpression", state);
5723
+ if (result) {
5724
+ if (result.cache)
5725
+ return result.cache;
5726
+ eventData = result.data;
5727
+ }
5728
+ }
5729
+ if (state.tokenize) {
5730
+ const result = $TOKEN("FunctionExpression", state, FunctionExpression$0(state) || FunctionExpression$1(state));
5731
+ if (state.events)
5732
+ state.events.exit?.("FunctionExpression", state, result, eventData);
5733
+ return result;
5734
+ } else {
5735
+ const result = FunctionExpression$0(state) || FunctionExpression$1(state);
5736
+ if (state.events)
5737
+ state.events.exit?.("FunctionExpression", state, result, eventData);
5738
+ return result;
5739
+ }
5740
+ }
5741
+ var AmpersandFunctionExpression$0 = $TS($S($E(AmpersandUnaryPrefix), $C(Ampersand, $S($N(NumericLiteral), $Y($S($E(QuestionMark), Dot)))), $E(AmpersandBlockRHS)), function($skip, $loc, $0, $1, $2, $3) {
5597
5742
  var prefix = $1;
5598
5743
  var rhs = $3;
5599
5744
  if (!prefix && !rhs)
@@ -5622,10 +5767,10 @@ ${input.slice(result.pos)}
5622
5767
  ampersandBlock: true
5623
5768
  };
5624
5769
  });
5625
- function FunctionExpression(state) {
5770
+ function AmpersandFunctionExpression(state) {
5626
5771
  let eventData;
5627
5772
  if (state.events) {
5628
- const result = state.events.enter?.("FunctionExpression", state);
5773
+ const result = state.events.enter?.("AmpersandFunctionExpression", state);
5629
5774
  if (result) {
5630
5775
  if (result.cache)
5631
5776
  return result.cache;
@@ -5633,14 +5778,14 @@ ${input.slice(result.pos)}
5633
5778
  }
5634
5779
  }
5635
5780
  if (state.tokenize) {
5636
- const result = $TOKEN("FunctionExpression", state, FunctionExpression$0(state) || FunctionExpression$1(state));
5781
+ const result = $TOKEN("AmpersandFunctionExpression", state, AmpersandFunctionExpression$0(state));
5637
5782
  if (state.events)
5638
- state.events.exit?.("FunctionExpression", state, result, eventData);
5783
+ state.events.exit?.("AmpersandFunctionExpression", state, result, eventData);
5639
5784
  return result;
5640
5785
  } else {
5641
- const result = FunctionExpression$0(state) || FunctionExpression$1(state);
5786
+ const result = AmpersandFunctionExpression$0(state);
5642
5787
  if (state.events)
5643
- state.events.exit?.("FunctionExpression", state, result, eventData);
5788
+ state.events.exit?.("AmpersandFunctionExpression", state, result, eventData);
5644
5789
  return result;
5645
5790
  }
5646
5791
  }
@@ -6195,7 +6340,7 @@ ${input.slice(result.pos)}
6195
6340
  return result;
6196
6341
  }
6197
6342
  }
6198
- var NonSingleBracedBlock$0 = $TS($S($Q(TrailingComment), OpenBrace, AllowAll, $E($S(BracedContent, __, CloseBrace)), RestoreAll), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
6343
+ var NonSingleBracedBlock$0 = $TS($S($E(_), OpenBrace, AllowAll, $E($S(BracedContent, __, CloseBrace)), RestoreAll), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
6199
6344
  var ws1 = $1;
6200
6345
  var open = $2;
6201
6346
  if (!$4)
@@ -6311,7 +6456,7 @@ ${input.slice(result.pos)}
6311
6456
  }
6312
6457
  }
6313
6458
  var BracedContent$0 = NestedBlockStatements;
6314
- var BracedContent$1 = $TS($S($Q(TrailingComment), Statement), function($skip, $loc, $0, $1, $2) {
6459
+ var BracedContent$1 = $TS($S($E(_), Statement), function($skip, $loc, $0, $1, $2) {
6315
6460
  const expressions = [["", $2]];
6316
6461
  return {
6317
6462
  type: "BlockStatement",
@@ -7355,7 +7500,7 @@ ${input.slice(result.pos)}
7355
7500
  return result;
7356
7501
  }
7357
7502
  }
7358
- var ImplicitInlineObjectPropertyDelimiter$0 = $S($Q(TrailingComment), Comma);
7503
+ var ImplicitInlineObjectPropertyDelimiter$0 = $S($E(_), Comma);
7359
7504
  var ImplicitInlineObjectPropertyDelimiter$1 = $T($S($Y($S($C(Samedent, $Q(_)), NamedProperty)), InsertComma), function(value) {
7360
7505
  return value[1];
7361
7506
  });
@@ -7822,7 +7967,7 @@ ${input.slice(result.pos)}
7822
7967
  return result;
7823
7968
  }
7824
7969
  }
7825
- var MethodModifier$0 = $S(GetOrSet, $Q(TrailingComment));
7970
+ var MethodModifier$0 = $S(GetOrSet, $E(_));
7826
7971
  var MethodModifier$1 = $S($S(Async, __), $E($S(Star, __)));
7827
7972
  var MethodModifier$2 = $S(Star, __);
7828
7973
  function MethodModifier(state) {
@@ -7978,8 +8123,8 @@ ${input.slice(result.pos)}
7978
8123
  return result;
7979
8124
  }
7980
8125
  }
7981
- var AssignmentOp$0 = $TS($S(AssignmentOpSymbol, $Q(TrailingComment)), function($skip, $loc, $0, $1, $2) {
7982
- if ($2.length) {
8126
+ var AssignmentOp$0 = $TS($S(AssignmentOpSymbol, $E(_)), function($skip, $loc, $0, $1, $2) {
8127
+ if ($2?.length) {
7983
8128
  return {
7984
8129
  token: $1,
7985
8130
  children: [$1, ...$2]
@@ -8009,21 +8154,21 @@ ${input.slice(result.pos)}
8009
8154
  return result;
8010
8155
  }
8011
8156
  }
8012
- var OperatorAssignmentOp$0 = $TS($S(Xor, $EXPECT($L2, fail, 'OperatorAssignmentOp "="'), $Y(Whitespace), $Q(TrailingComment)), function($skip, $loc, $0, $1, $2, $3, $4) {
8157
+ var OperatorAssignmentOp$0 = $TS($S(Xor, $EXPECT($L2, fail, 'OperatorAssignmentOp "="'), $Y(Whitespace), $E(_)), function($skip, $loc, $0, $1, $2, $3, $4) {
8013
8158
  return {
8014
8159
  special: true,
8015
8160
  call: module.getRef("xor"),
8016
8161
  children: [$2, ...$4]
8017
8162
  };
8018
8163
  });
8019
- var OperatorAssignmentOp$1 = $TS($S(Xnor, $EXPECT($L2, fail, 'OperatorAssignmentOp "="'), $Y(Whitespace), $Q(TrailingComment)), function($skip, $loc, $0, $1, $2, $3, $4) {
8164
+ var OperatorAssignmentOp$1 = $TS($S(Xnor, $EXPECT($L2, fail, 'OperatorAssignmentOp "="'), $Y(Whitespace), $E(_)), function($skip, $loc, $0, $1, $2, $3, $4) {
8020
8165
  return {
8021
8166
  special: true,
8022
8167
  call: module.getRef("xnor"),
8023
8168
  children: [$2, ...$4]
8024
8169
  };
8025
8170
  });
8026
- var OperatorAssignmentOp$2 = $TS($S(Identifier, $EXPECT($L2, fail, 'OperatorAssignmentOp "="'), $Y(Whitespace), $Q(TrailingComment)), function($skip, $loc, $0, $1, $2, $3, $4) {
8171
+ var OperatorAssignmentOp$2 = $TS($S(Identifier, $EXPECT($L2, fail, 'OperatorAssignmentOp "="'), $Y(Whitespace), $E(_)), function($skip, $loc, $0, $1, $2, $3, $4) {
8027
8172
  return {
8028
8173
  special: true,
8029
8174
  call: $1,
@@ -8489,7 +8634,7 @@ ${input.slice(result.pos)}
8489
8634
  return result;
8490
8635
  }
8491
8636
  }
8492
- var PostfixedStatement$0 = $TS($S(Statement, $E($S($Q(TrailingComment), PostfixStatement))), function($skip, $loc, $0, $1, $2) {
8637
+ var PostfixedStatement$0 = $TS($S(Statement, $E($S($E(_), PostfixStatement))), function($skip, $loc, $0, $1, $2) {
8493
8638
  var statement = $1;
8494
8639
  var post = $2;
8495
8640
  if (post)
@@ -8518,7 +8663,7 @@ ${input.slice(result.pos)}
8518
8663
  return result;
8519
8664
  }
8520
8665
  }
8521
- var PostfixedExpression$0 = $TS($S(ExtendedExpression, $E($S($Q(TrailingComment), PostfixStatement))), function($skip, $loc, $0, $1, $2) {
8666
+ var PostfixedExpression$0 = $TS($S(ExtendedExpression, $E($S($E(_), PostfixStatement))), function($skip, $loc, $0, $1, $2) {
8522
8667
  var expression = $1;
8523
8668
  var post = $2;
8524
8669
  if (post)
@@ -8547,7 +8692,7 @@ ${input.slice(result.pos)}
8547
8692
  return result;
8548
8693
  }
8549
8694
  }
8550
- var NonPipelinePostfixedExpression$0 = $TS($S(NonPipelineExtendedExpression, $E($S($Q(TrailingComment), PostfixStatement))), function($skip, $loc, $0, $1, $2) {
8695
+ var NonPipelinePostfixedExpression$0 = $TS($S(NonPipelineExtendedExpression, $E($S($E(_), PostfixStatement))), function($skip, $loc, $0, $1, $2) {
8551
8696
  var expression = $1;
8552
8697
  var post = $2;
8553
8698
  if (post)
@@ -8640,8 +8785,8 @@ ${input.slice(result.pos)}
8640
8785
  return result;
8641
8786
  }
8642
8787
  }
8643
- var EmptyStatement$0 = $T($S($Q(TrailingComment), $Y($EXPECT($L85, fail, 'EmptyStatement ";"'))), function(value) {
8644
- return { "type": "EmptyStatement", "children": value[0] };
8788
+ var EmptyStatement$0 = $TS($S($E(_), $Y($EXPECT($L85, fail, 'EmptyStatement ";"'))), function($skip, $loc, $0, $1, $2) {
8789
+ return { type: "EmptyStatement", children: $1 || [] };
8645
8790
  });
8646
8791
  function EmptyStatement(state) {
8647
8792
  let eventData;
@@ -8805,7 +8950,7 @@ ${input.slice(result.pos)}
8805
8950
  }
8806
8951
  }
8807
8952
  var ElseClause$0 = $S(Samedent, Else, Block);
8808
- var ElseClause$1 = $S($Q(TrailingComment), Else, Block);
8953
+ var ElseClause$1 = $S($E(_), Else, Block);
8809
8954
  function ElseClause(state) {
8810
8955
  let eventData;
8811
8956
  if (state.events) {
@@ -8940,7 +9085,7 @@ ${input.slice(result.pos)}
8940
9085
  return result;
8941
9086
  }
8942
9087
  }
8943
- var ElseExpressionClause$0 = $TS($S($C($S(Samedent, Else), $S($Q(TrailingComment), Else)), ElseExpressionBlock), function($skip, $loc, $0, $1, $2) {
9088
+ var ElseExpressionClause$0 = $TS($S($C($S(Samedent, Else), $S($E(_), Else)), ElseExpressionBlock), function($skip, $loc, $0, $1, $2) {
8944
9089
  return [...$1, $2];
8945
9090
  });
8946
9091
  function ElseExpressionClause(state) {
@@ -9316,7 +9461,7 @@ ${input.slice(result.pos)}
9316
9461
  return result;
9317
9462
  }
9318
9463
  }
9319
- var WhileClause$0 = $TS($S($C(While, Until), $Q(TrailingComment), Condition), function($skip, $loc, $0, $1, $2, $3) {
9464
+ var WhileClause$0 = $TS($S($C(While, Until), $E(_), Condition), function($skip, $loc, $0, $1, $2, $3) {
9320
9465
  var kind = $1;
9321
9466
  var ws = $2;
9322
9467
  var cond = $3;
@@ -10413,7 +10558,7 @@ ${input.slice(result.pos)}
10413
10558
  return result;
10414
10559
  }
10415
10560
  }
10416
- var Condition$0 = $T($S(ParenthesizedExpression, $N($S($Q(TrailingComment), $C(BinaryOp, AssignmentOp, Dot, QuestionMark))), $N($S(_, OperatorAssignmentOp))), function(value) {
10561
+ var Condition$0 = $T($S(ParenthesizedExpression, $N($S($E(_), $C(BinaryOp, AssignmentOp, Dot, QuestionMark))), $N($S(_, OperatorAssignmentOp))), function(value) {
10417
10562
  return value[0];
10418
10563
  });
10419
10564
  var Condition$1 = $TS($S(InsertOpenParen, ExpressionWithIndentedApplicationForbidden, InsertCloseParen), function($skip, $loc, $0, $1, $2, $3) {
@@ -13378,9 +13523,7 @@ ${input.slice(result.pos)}
13378
13523
  return result;
13379
13524
  }
13380
13525
  }
13381
- var TrailingComment$0 = NonNewlineWhitespace;
13382
- var TrailingComment$1 = InlineComment;
13383
- var TrailingComment$2 = SingleLineComment;
13526
+ var TrailingComment$0 = $S($E(_), SingleLineComment);
13384
13527
  function TrailingComment(state) {
13385
13528
  let eventData;
13386
13529
  if (state.events) {
@@ -13392,12 +13535,12 @@ ${input.slice(result.pos)}
13392
13535
  }
13393
13536
  }
13394
13537
  if (state.tokenize) {
13395
- const result = $TOKEN("TrailingComment", state, TrailingComment$0(state) || TrailingComment$1(state) || TrailingComment$2(state));
13538
+ const result = $TOKEN("TrailingComment", state, TrailingComment$0(state));
13396
13539
  if (state.events)
13397
13540
  state.events.exit?.("TrailingComment", state, result, eventData);
13398
13541
  return result;
13399
13542
  } else {
13400
- const result = TrailingComment$0(state) || TrailingComment$1(state) || TrailingComment$2(state);
13543
+ const result = TrailingComment$0(state);
13401
13544
  if (state.events)
13402
13545
  state.events.exit?.("TrailingComment", state, result, eventData);
13403
13546
  return result;
@@ -13528,7 +13671,7 @@ ${input.slice(result.pos)}
13528
13671
  return result;
13529
13672
  }
13530
13673
  }
13531
- var ExpressionDelimiter$0 = $TS($S($Q(TrailingComment), Semicolon, InsertComma, $Q(TrailingComment)), function($skip, $loc, $0, $1, $2, $3, $4) {
13674
+ var ExpressionDelimiter$0 = $TS($S($E(_), Semicolon, InsertComma, $E(TrailingComment)), function($skip, $loc, $0, $1, $2, $3, $4) {
13532
13675
  return [$1, $3, $4];
13533
13676
  });
13534
13677
  var ExpressionDelimiter$1 = $T($S($Y(EOS), InsertComma), function(value) {
@@ -13605,7 +13748,7 @@ ${input.slice(result.pos)}
13605
13748
  return result;
13606
13749
  }
13607
13750
  }
13608
- var SemicolonDelimiter$0 = $TS($S($Q(TrailingComment), Semicolon, $Q(TrailingComment)), function($skip, $loc, $0, $1, $2, $3) {
13751
+ var SemicolonDelimiter$0 = $TS($S($E(_), Semicolon, $E(TrailingComment)), function($skip, $loc, $0, $1, $2, $3) {
13609
13752
  return {
13610
13753
  type: "SemicolonDelimiter",
13611
13754
  children: $0
@@ -17211,9 +17354,9 @@ ${input.slice(result.pos)}
17211
17354
  return result;
17212
17355
  }
17213
17356
  }
17214
- var TypeDeclarationRest$0 = $S(TypeKeyword, $Q(TrailingComment), IdentifierName, $E(TypeParameters), __, Equals, $C($S($E(_), Type), $S(__, Type)));
17215
- var TypeDeclarationRest$1 = $S(Interface, $Q(TrailingComment), IdentifierName, $E(TypeParameters), $E(InterfaceExtendsClause), InterfaceBlock);
17216
- var TypeDeclarationRest$2 = $S(Namespace, $Q(TrailingComment), IdentifierName, ModuleBlock);
17357
+ var TypeDeclarationRest$0 = $S(TypeKeyword, $E(_), IdentifierName, $E(TypeParameters), __, Equals, $C($S($E(_), Type), $S(__, Type)));
17358
+ var TypeDeclarationRest$1 = $S(Interface, $E(_), IdentifierName, $E(TypeParameters), $E(InterfaceExtendsClause), InterfaceBlock);
17359
+ var TypeDeclarationRest$2 = $S(Namespace, $E(_), IdentifierName, ModuleBlock);
17217
17360
  var TypeDeclarationRest$3 = FunctionSignature;
17218
17361
  function TypeDeclarationRest(state) {
17219
17362
  let eventData;
@@ -17240,7 +17383,7 @@ ${input.slice(result.pos)}
17240
17383
  var TypeLexicalDeclaration$0 = $S(__, LetOrConstOrVar, TypeDeclarationBinding, $Q($S(CommaDelimiter, __, TypeDeclarationBinding)));
17241
17384
  var TypeLexicalDeclaration$1 = $S(__, EnumDeclaration);
17242
17385
  var TypeLexicalDeclaration$2 = ClassSignature;
17243
- var TypeLexicalDeclaration$3 = $S(Namespace, $Q(TrailingComment), IdentifierName, DeclareBlock);
17386
+ var TypeLexicalDeclaration$3 = $S(Namespace, $E(_), IdentifierName, DeclareBlock);
17244
17387
  var TypeLexicalDeclaration$4 = $S(Module, _, StringLiteral, $E(DeclareBlock));
17245
17388
  var TypeLexicalDeclaration$5 = $S(Global, $E(DeclareBlock));
17246
17389
  function TypeLexicalDeclaration(state) {
@@ -17812,7 +17955,7 @@ ${input.slice(result.pos)}
17812
17955
  return result;
17813
17956
  }
17814
17957
  }
17815
- var EnumDeclaration$0 = $TS($S($E($S(Const, _)), Enum, $Q(TrailingComment), IdentifierName, EnumBlock), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
17958
+ var EnumDeclaration$0 = $TS($S($E($S(Const, _)), Enum, $E(_), IdentifierName, EnumBlock), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
17816
17959
  var isConst = $1;
17817
17960
  var id = $4;
17818
17961
  var block = $5;
@@ -17833,7 +17976,7 @@ ${input.slice(result.pos)}
17833
17976
  let init, isString;
17834
17977
  if (property.init) {
17835
17978
  init = module.replaceNodes(
17836
- module.deepCopy(property.init),
17979
+ deepCopy(property.init),
17837
17980
  (n) => n.type === "Identifier" && names.has(n.name),
17838
17981
  (n) => [id, '["', n.name, '"]']
17839
17982
  );
@@ -21134,55 +21277,6 @@ ${input.slice(result.pos)}
21134
21277
  }, props2]
21135
21278
  };
21136
21279
  };
21137
- function gatherNodes(node, predicate) {
21138
- if (node == null)
21139
- return [];
21140
- if (Array.isArray(node)) {
21141
- return node.flatMap((n) => gatherNodes(n, predicate));
21142
- }
21143
- if (predicate(node)) {
21144
- return [node];
21145
- }
21146
- switch (node.type) {
21147
- case "BlockStatement":
21148
- return [];
21149
- case "ForStatement":
21150
- const isDec = node.declaration?.type === "Declaration";
21151
- return node.children.flatMap((n) => {
21152
- if (isDec && n === node.declaration)
21153
- return [];
21154
- return gatherNodes(n, predicate);
21155
- });
21156
- default:
21157
- return gatherNodes(node.children, predicate);
21158
- }
21159
- return [];
21160
- }
21161
- function gatherRecursive(node, predicate, skipPredicate) {
21162
- if (node == null)
21163
- return [];
21164
- if (Array.isArray(node)) {
21165
- return node.flatMap((n) => gatherRecursive(n, predicate, skipPredicate));
21166
- }
21167
- if (skipPredicate?.(node))
21168
- return [];
21169
- if (predicate(node)) {
21170
- return [node];
21171
- }
21172
- return gatherRecursive(node.children, predicate, skipPredicate);
21173
- }
21174
- function gatherRecursiveAll(node, predicate) {
21175
- if (node == null)
21176
- return [];
21177
- if (Array.isArray(node)) {
21178
- return node.flatMap((n) => gatherRecursiveAll(n, predicate));
21179
- }
21180
- const nodes = gatherRecursiveAll(node.children, predicate);
21181
- if (predicate(node)) {
21182
- nodes.push(node);
21183
- }
21184
- return nodes;
21185
- }
21186
21280
  function isFunction(node) {
21187
21281
  const { type } = node;
21188
21282
  return type === "FunctionExpression" || type === "ArrowFunction" || type === "MethodDefinition" || node.async;
@@ -21208,43 +21302,6 @@ ${input.slice(result.pos)}
21208
21302
  }
21209
21303
  }
21210
21304
  }
21211
- function removeParentPointers(node) {
21212
- if (node == null)
21213
- return;
21214
- if (typeof node !== "object")
21215
- return;
21216
- if (Array.isArray(node)) {
21217
- for (const child of node) {
21218
- removeParentPointers(child);
21219
- }
21220
- return;
21221
- }
21222
- node.parent = null;
21223
- if (node.children) {
21224
- for (const child of node.children) {
21225
- removeParentPointers(child);
21226
- }
21227
- }
21228
- }
21229
- function clone(node) {
21230
- removeParentPointers(node);
21231
- return deepCopy(node);
21232
- }
21233
- function deepCopy(node) {
21234
- if (node == null)
21235
- return node;
21236
- if (typeof node !== "object")
21237
- return node;
21238
- if (Array.isArray(node)) {
21239
- return node.map(deepCopy);
21240
- }
21241
- return Object.fromEntries(
21242
- Object.entries(node).map(([key, value]) => {
21243
- return [key, deepCopy(value)];
21244
- })
21245
- );
21246
- }
21247
- module.deepCopy = deepCopy;
21248
21305
  function findAncestor(node, predicate, stopPredicate) {
21249
21306
  node = node.parent;
21250
21307
  while (node && !stopPredicate?.(node)) {
@@ -22207,8 +22264,12 @@ ${input.slice(result.pos)}
22207
22264
  module.gatherBindingCode = gatherBindingCode;
22208
22265
  module.constructInvocation = function(fn, arg) {
22209
22266
  const fnArr = [fn.leadingComment, fn.expr, fn.trailingComment];
22210
- if (fn.expr.ampersandBlock) {
22211
- const { ref, body } = fn.expr;
22267
+ let expr = fn.expr;
22268
+ while (expr.type === "ParenthesizedExpression") {
22269
+ expr = expr.expression;
22270
+ }
22271
+ if (expr.ampersandBlock) {
22272
+ const { ref, body } = expr;
22212
22273
  ref.type = "PipedExpression";
22213
22274
  ref.children = [module.makeLeftHandSideExpression(arg)];
22214
22275
  return {
@@ -22216,7 +22277,8 @@ ${input.slice(result.pos)}
22216
22277
  children: [module.skipIfOnlyWS(fn.leadingComment), ...body, module.skipIfOnlyWS(fn.trailingComment)]
22217
22278
  };
22218
22279
  }
22219
- const lhs = module.makeLeftHandSideExpression(fn.expr);
22280
+ expr = fn.expr;
22281
+ const lhs = module.makeLeftHandSideExpression(expr);
22220
22282
  let comment = module.skipIfOnlyWS(fn.trailingComment);
22221
22283
  if (comment)
22222
22284
  lhs.children.splice(2, 0, comment);
@@ -22540,6 +22602,14 @@ ${input.slice(result.pos)}
22540
22602
  }
22541
22603
  exports.parse = parse2;
22542
22604
  exports.default = { parse: parse2 };
22605
+ var {
22606
+ clone,
22607
+ deepCopy,
22608
+ gatherNodes,
22609
+ gatherRecursive,
22610
+ gatherRecursiveAll,
22611
+ removeParentPointers
22612
+ } = require_lib();
22543
22613
  }
22544
22614
  });
22545
22615