@danielx/civet 0.5.80 → 0.5.82

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,123 @@ 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
+ function hasAwait(exp) {
117
+ return gatherRecursiveWithinFunction(exp, ({ type }) => type === "Await").length > 0;
118
+ }
119
+ function hasYield(exp) {
120
+ return gatherRecursiveWithinFunction(exp, ({ type }) => type === "Yield").length > 0;
121
+ }
122
+ function isFunction(node) {
123
+ const { type } = node;
124
+ return type === "FunctionExpression" || type === "ArrowFunction" || type === "MethodDefinition" || node.async;
125
+ }
126
+ function gatherRecursiveWithinFunction(node, predicate) {
127
+ return gatherRecursive(node, predicate, isFunction);
128
+ }
129
+ module.exports = {
130
+ clone,
131
+ deepCopy,
132
+ gatherNodes,
133
+ gatherRecursive,
134
+ gatherRecursiveAll,
135
+ gatherRecursiveWithinFunction,
136
+ hasAwait,
137
+ hasYield,
138
+ isFunction,
139
+ removeParentPointers
140
+ };
141
+ }
142
+ });
143
+
27
144
  // source/parser.hera
28
145
  var require_parser = __commonJS({
29
146
  "source/parser.hera"(exports, module) {
@@ -466,7 +583,6 @@ ${input.slice(result.pos)}
466
583
  YieldExpression,
467
584
  YieldTail,
468
585
  ArrowFunction,
469
- ArrowFunctionTail,
470
586
  FatArrow,
471
587
  FatArrowBody,
472
588
  ConditionalExpression,
@@ -563,6 +679,7 @@ ${input.slice(result.pos)}
563
679
  FunctionDeclaration,
564
680
  FunctionSignature,
565
681
  FunctionExpression,
682
+ AmpersandFunctionExpression,
566
683
  OperatorDeclaration,
567
684
  OperatorSignature,
568
685
  AmpersandBlockRHS,
@@ -1877,8 +1994,8 @@ ${input.slice(result.pos)}
1877
1994
  return module.insertTrimmingSpace($1, "");
1878
1995
  });
1879
1996
  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];
1997
+ var ArgumentList$3 = $TS($S($E(_), ArgumentPart, $Q($S(CommaDelimiter, $E(_), ArgumentPart))), function($skip, $loc, $0, $1, $2, $3) {
1998
+ return [...$1 || [], $2, ...$3];
1882
1999
  });
1883
2000
  function ArgumentList(state) {
1884
2001
  let eventData;
@@ -1907,8 +2024,8 @@ ${input.slice(result.pos)}
1907
2024
  return module.insertTrimmingSpace($1, "");
1908
2025
  });
1909
2026
  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];
2027
+ var NonPipelineArgumentList$3 = $TS($S($E(_), NonPipelineArgumentPart, $Q($S(CommaDelimiter, $E(_), NonPipelineArgumentPart))), function($skip, $loc, $0, $1, $2, $3) {
2028
+ return [...$1 || [], $2, ...$3];
1912
2029
  });
1913
2030
  function NonPipelineArgumentList(state) {
1914
2031
  let eventData;
@@ -1983,7 +2100,7 @@ ${input.slice(result.pos)}
1983
2100
  return result;
1984
2101
  }
1985
2102
  }
1986
- var SingleLineArgumentExpressions$0 = $S($Q(TrailingComment), ArgumentPart, $Q($S($Q(TrailingComment), Comma, $Q(TrailingComment), ArgumentPart)));
2103
+ var SingleLineArgumentExpressions$0 = $S($E(_), ArgumentPart, $Q($S($E(_), Comma, $E(_), ArgumentPart)));
1987
2104
  function SingleLineArgumentExpressions(state) {
1988
2105
  let eventData;
1989
2106
  if (state.events) {
@@ -2342,10 +2459,10 @@ ${input.slice(result.pos)}
2342
2459
  return result;
2343
2460
  }
2344
2461
  }
2345
- var SingleLineAssignmentExpression$0 = $TS($S($Q(TrailingComment), AssignmentExpressionTail), function($skip, $loc, $0, $1, $2) {
2462
+ var SingleLineAssignmentExpression$0 = $TS($S($E(_), AssignmentExpressionTail), function($skip, $loc, $0, $1, $2) {
2346
2463
  var ws = $1;
2347
2464
  var tail = $2;
2348
- if (ws.length) {
2465
+ if (ws?.length) {
2349
2466
  if (tail.children && tail.type !== "IterationExpression") {
2350
2467
  return {
2351
2468
  ...tail,
@@ -2462,7 +2579,7 @@ ${input.slice(result.pos)}
2462
2579
  }
2463
2580
  }
2464
2581
  var YieldTail$0 = $Y(EOS);
2465
- var YieldTail$1 = $S($E($S($Q(TrailingComment), Star)), AssignmentExpression);
2582
+ var YieldTail$1 = $S($E($S($E(_), Star)), AssignmentExpression);
2466
2583
  function YieldTail(state) {
2467
2584
  let eventData;
2468
2585
  if (state.events) {
@@ -2485,53 +2602,36 @@ ${input.slice(result.pos)}
2485
2602
  return result;
2486
2603
  }
2487
2604
  }
2488
- var ArrowFunction$0 = $TS($S($E($S(Async, __)), ArrowFunctionTail), function($skip, $loc, $0, $1, $2) {
2489
- var tail = $2;
2490
- return {
2491
- ...tail,
2492
- children: [...$1 || [], ...tail.children]
2493
- };
2494
- });
2495
- function ArrowFunction(state) {
2496
- let eventData;
2497
- if (state.events) {
2498
- const result = state.events.enter?.("ArrowFunction", state);
2499
- if (result) {
2500
- if (result.cache)
2501
- return result.cache;
2502
- eventData = result.data;
2503
- }
2605
+ var ArrowFunction$0 = ThinArrowFunction;
2606
+ var ArrowFunction$1 = $TS($S($E($S(Async, _)), Parameters, $E(ReturnTypeSuffix), FatArrow, FatArrowBody), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
2607
+ var async = $1;
2608
+ var parameters = $2;
2609
+ var suffix = $3;
2610
+ var expOrBlock = $5;
2611
+ if (hasAwait(expOrBlock) && !async) {
2612
+ async = "async ";
2504
2613
  }
2505
- if (state.tokenize) {
2506
- const result = $TOKEN("ArrowFunction", state, ArrowFunction$0(state));
2507
- if (state.events)
2508
- state.events.exit?.("ArrowFunction", state, result, eventData);
2509
- return result;
2510
- } else {
2511
- const result = ArrowFunction$0(state);
2512
- if (state.events)
2513
- state.events.exit?.("ArrowFunction", state, result, eventData);
2514
- return result;
2614
+ let error;
2615
+ if (hasYield(expOrBlock)) {
2616
+ error = {
2617
+ type: "Error",
2618
+ message: "Can't use yield inside of => arrow function"
2619
+ };
2515
2620
  }
2516
- }
2517
- var ArrowFunctionTail$0 = ThinArrowFunction;
2518
- var ArrowFunctionTail$1 = $TS($S(Parameters, $E(ReturnTypeSuffix), FatArrow, FatArrowBody), function($skip, $loc, $0, $1, $2, $3, $4) {
2519
- var parameters = $1;
2520
- var suffix = $2;
2521
- var expOrBlock = $4;
2522
2621
  return {
2523
2622
  type: "ArrowFunction",
2524
2623
  parameters,
2525
2624
  returnType: suffix,
2526
2625
  ts: false,
2626
+ async,
2527
2627
  block: expOrBlock,
2528
- children: $0
2628
+ children: [async, $0.slice(1), error]
2529
2629
  };
2530
2630
  });
2531
- function ArrowFunctionTail(state) {
2631
+ function ArrowFunction(state) {
2532
2632
  let eventData;
2533
2633
  if (state.events) {
2534
- const result = state.events.enter?.("ArrowFunctionTail", state);
2634
+ const result = state.events.enter?.("ArrowFunction", state);
2535
2635
  if (result) {
2536
2636
  if (result.cache)
2537
2637
  return result.cache;
@@ -2539,14 +2639,14 @@ ${input.slice(result.pos)}
2539
2639
  }
2540
2640
  }
2541
2641
  if (state.tokenize) {
2542
- const result = $TOKEN("ArrowFunctionTail", state, ArrowFunctionTail$0(state) || ArrowFunctionTail$1(state));
2642
+ const result = $TOKEN("ArrowFunction", state, ArrowFunction$0(state) || ArrowFunction$1(state));
2543
2643
  if (state.events)
2544
- state.events.exit?.("ArrowFunctionTail", state, result, eventData);
2644
+ state.events.exit?.("ArrowFunction", state, result, eventData);
2545
2645
  return result;
2546
2646
  } else {
2547
- const result = ArrowFunctionTail$0(state) || ArrowFunctionTail$1(state);
2647
+ const result = ArrowFunction$0(state) || ArrowFunction$1(state);
2548
2648
  if (state.events)
2549
- state.events.exit?.("ArrowFunctionTail", state, result, eventData);
2649
+ state.events.exit?.("ArrowFunction", state, result, eventData);
2550
2650
  return result;
2551
2651
  }
2552
2652
  }
@@ -2634,7 +2734,7 @@ ${input.slice(result.pos)}
2634
2734
  }
2635
2735
  }
2636
2736
  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) {
2737
+ 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
2738
  return $0.slice(2);
2639
2739
  });
2640
2740
  function TernaryRest(state) {
@@ -2713,6 +2813,23 @@ ${input.slice(result.pos)}
2713
2813
  var ws = $1;
2714
2814
  var head = $2;
2715
2815
  var body = $3;
2816
+ if (head.token === "&") {
2817
+ const ref = {
2818
+ type: "Ref",
2819
+ base: "$"
2820
+ };
2821
+ const arrowBody = {
2822
+ type: "PipelineExpression",
2823
+ children: [ws, ref, body]
2824
+ };
2825
+ return {
2826
+ type: "ArrowFunction",
2827
+ children: [ref, " => ", arrowBody],
2828
+ ref,
2829
+ body: [arrowBody],
2830
+ ampersandBlock: true
2831
+ };
2832
+ }
2716
2833
  return {
2717
2834
  type: "PipelineExpression",
2718
2835
  children: [ws, head, body]
@@ -2742,6 +2859,7 @@ ${input.slice(result.pos)}
2742
2859
  }
2743
2860
  var PipelineHeadItem$0 = NonPipelineExtendedExpression;
2744
2861
  var PipelineHeadItem$1 = ParenthesizedExpression;
2862
+ var PipelineHeadItem$2 = Ampersand;
2745
2863
  function PipelineHeadItem(state) {
2746
2864
  let eventData;
2747
2865
  if (state.events) {
@@ -2753,12 +2871,12 @@ ${input.slice(result.pos)}
2753
2871
  }
2754
2872
  }
2755
2873
  if (state.tokenize) {
2756
- const result = $TOKEN("PipelineHeadItem", state, PipelineHeadItem$0(state) || PipelineHeadItem$1(state));
2874
+ const result = $TOKEN("PipelineHeadItem", state, PipelineHeadItem$0(state) || PipelineHeadItem$1(state) || PipelineHeadItem$2(state));
2757
2875
  if (state.events)
2758
2876
  state.events.exit?.("PipelineHeadItem", state, result, eventData);
2759
2877
  return result;
2760
2878
  } else {
2761
- const result = PipelineHeadItem$0(state) || PipelineHeadItem$1(state);
2879
+ const result = PipelineHeadItem$0(state) || PipelineHeadItem$1(state) || PipelineHeadItem$2(state);
2762
2880
  if (state.events)
2763
2881
  state.events.exit?.("PipelineHeadItem", state, result, eventData);
2764
2882
  return result;
@@ -2767,7 +2885,10 @@ ${input.slice(result.pos)}
2767
2885
  var PipelineTailItem$0 = Await;
2768
2886
  var PipelineTailItem$1 = Yield;
2769
2887
  var PipelineTailItem$2 = Return;
2770
- var PipelineTailItem$3 = PipelineHeadItem;
2888
+ var PipelineTailItem$3 = AmpersandFunctionExpression;
2889
+ var PipelineTailItem$4 = $T($S($N(Ampersand), PipelineHeadItem), function(value) {
2890
+ return value[1];
2891
+ });
2771
2892
  function PipelineTailItem(state) {
2772
2893
  let eventData;
2773
2894
  if (state.events) {
@@ -2779,12 +2900,12 @@ ${input.slice(result.pos)}
2779
2900
  }
2780
2901
  }
2781
2902
  if (state.tokenize) {
2782
- const result = $TOKEN("PipelineTailItem", state, PipelineTailItem$0(state) || PipelineTailItem$1(state) || PipelineTailItem$2(state) || PipelineTailItem$3(state));
2903
+ const result = $TOKEN("PipelineTailItem", state, PipelineTailItem$0(state) || PipelineTailItem$1(state) || PipelineTailItem$2(state) || PipelineTailItem$3(state) || PipelineTailItem$4(state));
2783
2904
  if (state.events)
2784
2905
  state.events.exit?.("PipelineTailItem", state, result, eventData);
2785
2906
  return result;
2786
2907
  } else {
2787
- const result = PipelineTailItem$0(state) || PipelineTailItem$1(state) || PipelineTailItem$2(state) || PipelineTailItem$3(state);
2908
+ const result = PipelineTailItem$0(state) || PipelineTailItem$1(state) || PipelineTailItem$2(state) || PipelineTailItem$3(state) || PipelineTailItem$4(state);
2788
2909
  if (state.events)
2789
2910
  state.events.exit?.("PipelineTailItem", state, result, eventData);
2790
2911
  return result;
@@ -3231,7 +3352,7 @@ ${input.slice(result.pos)}
3231
3352
  return result;
3232
3353
  }
3233
3354
  }
3234
- var ClassElement$0 = $S($E(Decorators), $E(AccessModifier), $E($S(Static, $Q(TrailingComment))), ClassElementDefinition);
3355
+ var ClassElement$0 = $S($E(Decorators), $E(AccessModifier), $E($S(Static, $E(_))), ClassElementDefinition);
3235
3356
  var ClassElement$1 = $S(Static, BracedBlock);
3236
3357
  function ClassElement(state) {
3237
3358
  let eventData;
@@ -3377,7 +3498,7 @@ ${input.slice(result.pos)}
3377
3498
  return result;
3378
3499
  }
3379
3500
  }
3380
- var ClassSignatureElement$0 = $S($E(Decorators), $E(AccessModifier), $E($S(Static, $Q(TrailingComment))), $C(MethodSignature, FieldDefinition));
3501
+ var ClassSignatureElement$0 = $S($E(Decorators), $E(AccessModifier), $E($S(Static, $E(_))), $C(MethodSignature, FieldDefinition));
3381
3502
  var ClassSignatureElement$1 = $S(Static, ClassSignatureBody);
3382
3503
  function ClassSignatureElement(state) {
3383
3504
  let eventData;
@@ -3436,9 +3557,16 @@ ${input.slice(result.pos)}
3436
3557
  var exp = $6;
3437
3558
  switch (exp.type) {
3438
3559
  case "FunctionExpression":
3560
+ const fnTokenIndex = exp.children.findIndex((c) => c?.token?.startsWith("function"));
3561
+ const children = exp.children.slice();
3562
+ if (exp.generator) {
3563
+ children.splice(fnTokenIndex, 2, children[fnTokenIndex + 1], id);
3564
+ } else {
3565
+ children.splice(fnTokenIndex, 1, id);
3566
+ }
3439
3567
  return {
3440
3568
  ...exp,
3441
- children: [id, ...exp.children.slice(1)]
3569
+ children
3442
3570
  };
3443
3571
  default:
3444
3572
  return [id, " = ", exp];
@@ -3453,7 +3581,7 @@ ${input.slice(result.pos)}
3453
3581
  };
3454
3582
  return $0;
3455
3583
  });
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) {
3584
+ 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
3585
  if ($1)
3458
3586
  return { children: $0, ts: true };
3459
3587
  return $0;
@@ -5539,22 +5667,28 @@ ${input.slice(result.pos)}
5539
5667
  return result;
5540
5668
  }
5541
5669
  }
5542
- var FunctionSignature$0 = $TS($S($E($S(Async, $E(_))), Function, $E($S($E(_), Star)), $E($S($E(_), NWBindingIdentifier)), $E(_), Parameters, $E(ReturnTypeSuffix)), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7) {
5670
+ var FunctionSignature$0 = $TS($S($E($S(Async, _)), Function, $E($S($E(_), Star)), $E($S($E(_), NWBindingIdentifier)), $E(_), Parameters, $E(ReturnTypeSuffix)), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7) {
5543
5671
  var async = $1;
5544
5672
  var func = $2;
5545
- var star = $3;
5673
+ var generator = $3;
5546
5674
  var wid = $4;
5547
5675
  var w = $5;
5548
5676
  var parameters = $6;
5549
5677
  var suffix = $7;
5678
+ if (!async)
5679
+ async = [];
5680
+ if (!generator)
5681
+ generator = [];
5550
5682
  return {
5551
5683
  type: "FunctionSignature",
5552
5684
  id: wid?.[1],
5553
5685
  parameters,
5554
5686
  returnType: suffix,
5555
5687
  ts: false,
5688
+ async,
5689
+ generator,
5556
5690
  block: null,
5557
- children: !parameters.implicit ? $0 : [async, func, star, wid, parameters, w, suffix]
5691
+ children: !parameters.implicit ? $0 : [async, func, generator, wid, parameters, w, suffix]
5558
5692
  };
5559
5693
  });
5560
5694
  function FunctionSignature(state) {
@@ -5586,6 +5720,12 @@ ${input.slice(result.pos)}
5586
5720
  signature.ts = true;
5587
5721
  return signature;
5588
5722
  }
5723
+ if (hasAwait(block) && !signature.async.length) {
5724
+ signature.async.push("async ");
5725
+ }
5726
+ if (hasYield(block) && !signature.generator.length) {
5727
+ signature.generator.push("*");
5728
+ }
5589
5729
  return {
5590
5730
  ...signature,
5591
5731
  type: "FunctionExpression",
@@ -5593,7 +5733,30 @@ ${input.slice(result.pos)}
5593
5733
  block
5594
5734
  };
5595
5735
  });
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) {
5736
+ var FunctionExpression$1 = AmpersandFunctionExpression;
5737
+ function FunctionExpression(state) {
5738
+ let eventData;
5739
+ if (state.events) {
5740
+ const result = state.events.enter?.("FunctionExpression", state);
5741
+ if (result) {
5742
+ if (result.cache)
5743
+ return result.cache;
5744
+ eventData = result.data;
5745
+ }
5746
+ }
5747
+ if (state.tokenize) {
5748
+ const result = $TOKEN("FunctionExpression", state, FunctionExpression$0(state) || FunctionExpression$1(state));
5749
+ if (state.events)
5750
+ state.events.exit?.("FunctionExpression", state, result, eventData);
5751
+ return result;
5752
+ } else {
5753
+ const result = FunctionExpression$0(state) || FunctionExpression$1(state);
5754
+ if (state.events)
5755
+ state.events.exit?.("FunctionExpression", state, result, eventData);
5756
+ return result;
5757
+ }
5758
+ }
5759
+ 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
5760
  var prefix = $1;
5598
5761
  var rhs = $3;
5599
5762
  if (!prefix && !rhs)
@@ -5611,7 +5774,7 @@ ${input.slice(result.pos)}
5611
5774
  body = [prefix, rhs];
5612
5775
  }
5613
5776
  const children = [ref, " => ", ...body];
5614
- if (module.hasAwait(body)) {
5777
+ if (hasAwait(body)) {
5615
5778
  children.unshift("async ");
5616
5779
  }
5617
5780
  return {
@@ -5622,10 +5785,10 @@ ${input.slice(result.pos)}
5622
5785
  ampersandBlock: true
5623
5786
  };
5624
5787
  });
5625
- function FunctionExpression(state) {
5788
+ function AmpersandFunctionExpression(state) {
5626
5789
  let eventData;
5627
5790
  if (state.events) {
5628
- const result = state.events.enter?.("FunctionExpression", state);
5791
+ const result = state.events.enter?.("AmpersandFunctionExpression", state);
5629
5792
  if (result) {
5630
5793
  if (result.cache)
5631
5794
  return result.cache;
@@ -5633,14 +5796,14 @@ ${input.slice(result.pos)}
5633
5796
  }
5634
5797
  }
5635
5798
  if (state.tokenize) {
5636
- const result = $TOKEN("FunctionExpression", state, FunctionExpression$0(state) || FunctionExpression$1(state));
5799
+ const result = $TOKEN("AmpersandFunctionExpression", state, AmpersandFunctionExpression$0(state));
5637
5800
  if (state.events)
5638
- state.events.exit?.("FunctionExpression", state, result, eventData);
5801
+ state.events.exit?.("AmpersandFunctionExpression", state, result, eventData);
5639
5802
  return result;
5640
5803
  } else {
5641
- const result = FunctionExpression$0(state) || FunctionExpression$1(state);
5804
+ const result = AmpersandFunctionExpression$0(state);
5642
5805
  if (state.events)
5643
- state.events.exit?.("FunctionExpression", state, result, eventData);
5806
+ state.events.exit?.("AmpersandFunctionExpression", state, result, eventData);
5644
5807
  return result;
5645
5808
  }
5646
5809
  }
@@ -5811,20 +5974,32 @@ ${input.slice(result.pos)}
5811
5974
  return result;
5812
5975
  }
5813
5976
  }
5814
- var ThinArrowFunction$0 = $TS($S(Parameters, $E(ReturnTypeSuffix), $Q(_), Arrow, BracedOrEmptyBlock), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
5815
- var parameters = $1;
5816
- var suffix = $2;
5817
- var arrow = $4;
5818
- var block = $5;
5977
+ var ThinArrowFunction$0 = $TS($S($E($S(Async, _)), Parameters, $E(ReturnTypeSuffix), $Q(_), Arrow, BracedOrEmptyBlock), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
5978
+ var async = $1;
5979
+ var parameters = $2;
5980
+ var suffix = $3;
5981
+ var arrow = $5;
5982
+ var block = $6;
5983
+ if (hasAwait(block) && !async) {
5984
+ async = "async ";
5985
+ }
5986
+ let generator;
5987
+ if (hasYield(block)) {
5988
+ generator = "*";
5989
+ }
5819
5990
  return {
5820
5991
  type: "FunctionExpression",
5821
5992
  id: void 0,
5822
5993
  parameters,
5823
5994
  returnType: suffix,
5824
5995
  ts: false,
5996
+ async,
5997
+ generator,
5825
5998
  block,
5826
5999
  children: [
6000
+ async,
5827
6001
  { $loc: arrow.$loc, token: "function" },
6002
+ generator,
5828
6003
  parameters,
5829
6004
  suffix,
5830
6005
  block
@@ -6195,7 +6370,7 @@ ${input.slice(result.pos)}
6195
6370
  return result;
6196
6371
  }
6197
6372
  }
6198
- var NonSingleBracedBlock$0 = $TS($S($Q(TrailingComment), OpenBrace, AllowAll, $E($S(BracedContent, __, CloseBrace)), RestoreAll), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
6373
+ var NonSingleBracedBlock$0 = $TS($S($E(_), OpenBrace, AllowAll, $E($S(BracedContent, __, CloseBrace)), RestoreAll), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
6199
6374
  var ws1 = $1;
6200
6375
  var open = $2;
6201
6376
  if (!$4)
@@ -6311,7 +6486,7 @@ ${input.slice(result.pos)}
6311
6486
  }
6312
6487
  }
6313
6488
  var BracedContent$0 = NestedBlockStatements;
6314
- var BracedContent$1 = $TS($S($Q(TrailingComment), Statement), function($skip, $loc, $0, $1, $2) {
6489
+ var BracedContent$1 = $TS($S($E(_), Statement), function($skip, $loc, $0, $1, $2) {
6315
6490
  const expressions = [["", $2]];
6316
6491
  return {
6317
6492
  type: "BlockStatement",
@@ -7355,7 +7530,7 @@ ${input.slice(result.pos)}
7355
7530
  return result;
7356
7531
  }
7357
7532
  }
7358
- var ImplicitInlineObjectPropertyDelimiter$0 = $S($Q(TrailingComment), Comma);
7533
+ var ImplicitInlineObjectPropertyDelimiter$0 = $S($E(_), Comma);
7359
7534
  var ImplicitInlineObjectPropertyDelimiter$1 = $T($S($Y($S($C(Samedent, $Q(_)), NamedProperty)), InsertComma), function(value) {
7360
7535
  return value[1];
7361
7536
  });
@@ -7791,9 +7966,38 @@ ${input.slice(result.pos)}
7791
7966
  var MethodDefinition$1 = $TS($S(MethodSignature, $N(PropertyAccess), BracedOrEmptyBlock), function($skip, $loc, $0, $1, $2, $3) {
7792
7967
  var signature = $1;
7793
7968
  var block = $3;
7969
+ let children = $0;
7970
+ let generatorPos = 0;
7971
+ const { modifier } = signature;
7972
+ if (hasAwait(block)) {
7973
+ generatorPos++;
7974
+ children = children.slice();
7975
+ if (modifier?.get || modifier?.set) {
7976
+ children.push({
7977
+ type: "Error",
7978
+ message: "Getters and setters cannot be async"
7979
+ });
7980
+ } else if (modifier?.async) {
7981
+ } else {
7982
+ children.unshift("async ");
7983
+ }
7984
+ }
7985
+ if (hasYield(block)) {
7986
+ if (children === $0)
7987
+ children = children.slice();
7988
+ if (modifier?.get || modifier?.set) {
7989
+ children.push({
7990
+ type: "Error",
7991
+ message: "Getters and setters cannot be generators"
7992
+ });
7993
+ } else if (modifier?.generator) {
7994
+ } else {
7995
+ children.splice(generatorPos, 0, "*");
7996
+ }
7997
+ }
7794
7998
  return {
7795
7999
  type: "MethodDefinition",
7796
- children: $0,
8000
+ children,
7797
8001
  name: signature.name,
7798
8002
  signature,
7799
8003
  block,
@@ -7822,9 +8026,37 @@ ${input.slice(result.pos)}
7822
8026
  return result;
7823
8027
  }
7824
8028
  }
7825
- var MethodModifier$0 = $S(GetOrSet, $Q(TrailingComment));
7826
- var MethodModifier$1 = $S($S(Async, __), $E($S(Star, __)));
7827
- var MethodModifier$2 = $S(Star, __);
8029
+ var MethodModifier$0 = $TS($S(GetOrSet, $E(_)), function($skip, $loc, $0, $1, $2) {
8030
+ var kind = $1;
8031
+ return {
8032
+ type: "MethodModifier",
8033
+ async: false,
8034
+ generator: false,
8035
+ get: kind.token === "get",
8036
+ set: kind.token === "set",
8037
+ children: $0
8038
+ };
8039
+ });
8040
+ var MethodModifier$1 = $TS($S($S(Async, __), $E($S(Star, __))), function($skip, $loc, $0, $1, $2) {
8041
+ return {
8042
+ type: "MethodModifier",
8043
+ async: true,
8044
+ get: false,
8045
+ set: false,
8046
+ generator: !!$1,
8047
+ children: $0
8048
+ };
8049
+ });
8050
+ var MethodModifier$2 = $TS($S(Star, __), function($skip, $loc, $0, $1, $2) {
8051
+ return {
8052
+ type: "MethodModifier",
8053
+ async: false,
8054
+ get: false,
8055
+ set: false,
8056
+ generator: true,
8057
+ children: $0
8058
+ };
8059
+ });
7828
8060
  function MethodModifier(state) {
7829
8061
  let eventData;
7830
8062
  if (state.events) {
@@ -7857,7 +8089,8 @@ ${input.slice(result.pos)}
7857
8089
  parameters
7858
8090
  };
7859
8091
  });
7860
- var MethodSignature$1 = $TS($S($E(MethodModifier), ClassElementName, $Q(_), NonEmptyParameters, $E(ReturnTypeSuffix)), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
8092
+ var MethodSignature$1 = $TS($S($E(MethodModifier), ClassElementName, $E(_), NonEmptyParameters, $E(ReturnTypeSuffix)), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
8093
+ var modifier = $1;
7861
8094
  var name = $2;
7862
8095
  var parameters = $4;
7863
8096
  var suffix = $5;
@@ -7870,7 +8103,7 @@ ${input.slice(result.pos)}
7870
8103
  type: "MethodSignature",
7871
8104
  children: $0,
7872
8105
  name,
7873
- modifier: $1?.[0]?.token,
8106
+ modifier,
7874
8107
  returnType: suffix,
7875
8108
  parameters
7876
8109
  };
@@ -7978,8 +8211,8 @@ ${input.slice(result.pos)}
7978
8211
  return result;
7979
8212
  }
7980
8213
  }
7981
- var AssignmentOp$0 = $TS($S(AssignmentOpSymbol, $Q(TrailingComment)), function($skip, $loc, $0, $1, $2) {
7982
- if ($2.length) {
8214
+ var AssignmentOp$0 = $TS($S(AssignmentOpSymbol, $E(_)), function($skip, $loc, $0, $1, $2) {
8215
+ if ($2?.length) {
7983
8216
  return {
7984
8217
  token: $1,
7985
8218
  children: [$1, ...$2]
@@ -8009,21 +8242,21 @@ ${input.slice(result.pos)}
8009
8242
  return result;
8010
8243
  }
8011
8244
  }
8012
- var OperatorAssignmentOp$0 = $TS($S(Xor, $EXPECT($L2, fail, 'OperatorAssignmentOp "="'), $Y(Whitespace), $Q(TrailingComment)), function($skip, $loc, $0, $1, $2, $3, $4) {
8245
+ var OperatorAssignmentOp$0 = $TS($S(Xor, $EXPECT($L2, fail, 'OperatorAssignmentOp "="'), $Y(Whitespace), $E(_)), function($skip, $loc, $0, $1, $2, $3, $4) {
8013
8246
  return {
8014
8247
  special: true,
8015
8248
  call: module.getRef("xor"),
8016
8249
  children: [$2, ...$4]
8017
8250
  };
8018
8251
  });
8019
- var OperatorAssignmentOp$1 = $TS($S(Xnor, $EXPECT($L2, fail, 'OperatorAssignmentOp "="'), $Y(Whitespace), $Q(TrailingComment)), function($skip, $loc, $0, $1, $2, $3, $4) {
8252
+ var OperatorAssignmentOp$1 = $TS($S(Xnor, $EXPECT($L2, fail, 'OperatorAssignmentOp "="'), $Y(Whitespace), $E(_)), function($skip, $loc, $0, $1, $2, $3, $4) {
8020
8253
  return {
8021
8254
  special: true,
8022
8255
  call: module.getRef("xnor"),
8023
8256
  children: [$2, ...$4]
8024
8257
  };
8025
8258
  });
8026
- var OperatorAssignmentOp$2 = $TS($S(Identifier, $EXPECT($L2, fail, 'OperatorAssignmentOp "="'), $Y(Whitespace), $Q(TrailingComment)), function($skip, $loc, $0, $1, $2, $3, $4) {
8259
+ var OperatorAssignmentOp$2 = $TS($S(Identifier, $EXPECT($L2, fail, 'OperatorAssignmentOp "="'), $Y(Whitespace), $E(_)), function($skip, $loc, $0, $1, $2, $3, $4) {
8027
8260
  return {
8028
8261
  special: true,
8029
8262
  call: $1,
@@ -8489,7 +8722,7 @@ ${input.slice(result.pos)}
8489
8722
  return result;
8490
8723
  }
8491
8724
  }
8492
- var PostfixedStatement$0 = $TS($S(Statement, $E($S($Q(TrailingComment), PostfixStatement))), function($skip, $loc, $0, $1, $2) {
8725
+ var PostfixedStatement$0 = $TS($S(Statement, $E($S($E(_), PostfixStatement))), function($skip, $loc, $0, $1, $2) {
8493
8726
  var statement = $1;
8494
8727
  var post = $2;
8495
8728
  if (post)
@@ -8518,7 +8751,7 @@ ${input.slice(result.pos)}
8518
8751
  return result;
8519
8752
  }
8520
8753
  }
8521
- var PostfixedExpression$0 = $TS($S(ExtendedExpression, $E($S($Q(TrailingComment), PostfixStatement))), function($skip, $loc, $0, $1, $2) {
8754
+ var PostfixedExpression$0 = $TS($S(ExtendedExpression, $E($S($E(_), PostfixStatement))), function($skip, $loc, $0, $1, $2) {
8522
8755
  var expression = $1;
8523
8756
  var post = $2;
8524
8757
  if (post)
@@ -8547,7 +8780,7 @@ ${input.slice(result.pos)}
8547
8780
  return result;
8548
8781
  }
8549
8782
  }
8550
- var NonPipelinePostfixedExpression$0 = $TS($S(NonPipelineExtendedExpression, $E($S($Q(TrailingComment), PostfixStatement))), function($skip, $loc, $0, $1, $2) {
8783
+ var NonPipelinePostfixedExpression$0 = $TS($S(NonPipelineExtendedExpression, $E($S($E(_), PostfixStatement))), function($skip, $loc, $0, $1, $2) {
8551
8784
  var expression = $1;
8552
8785
  var post = $2;
8553
8786
  if (post)
@@ -8640,8 +8873,8 @@ ${input.slice(result.pos)}
8640
8873
  return result;
8641
8874
  }
8642
8875
  }
8643
- var EmptyStatement$0 = $T($S($Q(TrailingComment), $Y($EXPECT($L85, fail, 'EmptyStatement ";"'))), function(value) {
8644
- return { "type": "EmptyStatement", "children": value[0] };
8876
+ var EmptyStatement$0 = $TS($S($E(_), $Y($EXPECT($L85, fail, 'EmptyStatement ";"'))), function($skip, $loc, $0, $1, $2) {
8877
+ return { type: "EmptyStatement", children: $1 || [] };
8645
8878
  });
8646
8879
  function EmptyStatement(state) {
8647
8880
  let eventData;
@@ -8805,7 +9038,7 @@ ${input.slice(result.pos)}
8805
9038
  }
8806
9039
  }
8807
9040
  var ElseClause$0 = $S(Samedent, Else, Block);
8808
- var ElseClause$1 = $S($Q(TrailingComment), Else, Block);
9041
+ var ElseClause$1 = $S($E(_), Else, Block);
8809
9042
  function ElseClause(state) {
8810
9043
  let eventData;
8811
9044
  if (state.events) {
@@ -8940,7 +9173,7 @@ ${input.slice(result.pos)}
8940
9173
  return result;
8941
9174
  }
8942
9175
  }
8943
- var ElseExpressionClause$0 = $TS($S($C($S(Samedent, Else), $S($Q(TrailingComment), Else)), ElseExpressionBlock), function($skip, $loc, $0, $1, $2) {
9176
+ var ElseExpressionClause$0 = $TS($S($C($S(Samedent, Else), $S($E(_), Else)), ElseExpressionBlock), function($skip, $loc, $0, $1, $2) {
8944
9177
  return [...$1, $2];
8945
9178
  });
8946
9179
  function ElseExpressionClause(state) {
@@ -9316,7 +9549,7 @@ ${input.slice(result.pos)}
9316
9549
  return result;
9317
9550
  }
9318
9551
  }
9319
- var WhileClause$0 = $TS($S($C(While, Until), $Q(TrailingComment), Condition), function($skip, $loc, $0, $1, $2, $3) {
9552
+ var WhileClause$0 = $TS($S($C(While, Until), $E(_), Condition), function($skip, $loc, $0, $1, $2, $3) {
9320
9553
  var kind = $1;
9321
9554
  var ws = $2;
9322
9555
  var cond = $3;
@@ -10413,7 +10646,7 @@ ${input.slice(result.pos)}
10413
10646
  return result;
10414
10647
  }
10415
10648
  }
10416
- var Condition$0 = $T($S(ParenthesizedExpression, $N($S($Q(TrailingComment), $C(BinaryOp, AssignmentOp, Dot, QuestionMark))), $N($S(_, OperatorAssignmentOp))), function(value) {
10649
+ var Condition$0 = $T($S(ParenthesizedExpression, $N($S($E(_), $C(BinaryOp, AssignmentOp, Dot, QuestionMark))), $N($S(_, OperatorAssignmentOp))), function(value) {
10417
10650
  return value[0];
10418
10651
  });
10419
10652
  var Condition$1 = $TS($S(InsertOpenParen, ExpressionWithIndentedApplicationForbidden, InsertCloseParen), function($skip, $loc, $0, $1, $2, $3) {
@@ -13378,9 +13611,7 @@ ${input.slice(result.pos)}
13378
13611
  return result;
13379
13612
  }
13380
13613
  }
13381
- var TrailingComment$0 = NonNewlineWhitespace;
13382
- var TrailingComment$1 = InlineComment;
13383
- var TrailingComment$2 = SingleLineComment;
13614
+ var TrailingComment$0 = $S($E(_), SingleLineComment);
13384
13615
  function TrailingComment(state) {
13385
13616
  let eventData;
13386
13617
  if (state.events) {
@@ -13392,12 +13623,12 @@ ${input.slice(result.pos)}
13392
13623
  }
13393
13624
  }
13394
13625
  if (state.tokenize) {
13395
- const result = $TOKEN("TrailingComment", state, TrailingComment$0(state) || TrailingComment$1(state) || TrailingComment$2(state));
13626
+ const result = $TOKEN("TrailingComment", state, TrailingComment$0(state));
13396
13627
  if (state.events)
13397
13628
  state.events.exit?.("TrailingComment", state, result, eventData);
13398
13629
  return result;
13399
13630
  } else {
13400
- const result = TrailingComment$0(state) || TrailingComment$1(state) || TrailingComment$2(state);
13631
+ const result = TrailingComment$0(state);
13401
13632
  if (state.events)
13402
13633
  state.events.exit?.("TrailingComment", state, result, eventData);
13403
13634
  return result;
@@ -13528,7 +13759,7 @@ ${input.slice(result.pos)}
13528
13759
  return result;
13529
13760
  }
13530
13761
  }
13531
- var ExpressionDelimiter$0 = $TS($S($Q(TrailingComment), Semicolon, InsertComma, $Q(TrailingComment)), function($skip, $loc, $0, $1, $2, $3, $4) {
13762
+ var ExpressionDelimiter$0 = $TS($S($E(_), Semicolon, InsertComma, $E(TrailingComment)), function($skip, $loc, $0, $1, $2, $3, $4) {
13532
13763
  return [$1, $3, $4];
13533
13764
  });
13534
13765
  var ExpressionDelimiter$1 = $T($S($Y(EOS), InsertComma), function(value) {
@@ -13605,7 +13836,7 @@ ${input.slice(result.pos)}
13605
13836
  return result;
13606
13837
  }
13607
13838
  }
13608
- var SemicolonDelimiter$0 = $TS($S($Q(TrailingComment), Semicolon, $Q(TrailingComment)), function($skip, $loc, $0, $1, $2, $3) {
13839
+ var SemicolonDelimiter$0 = $TS($S($E(_), Semicolon, $E(TrailingComment)), function($skip, $loc, $0, $1, $2, $3) {
13609
13840
  return {
13610
13841
  type: "SemicolonDelimiter",
13611
13842
  children: $0
@@ -15740,7 +15971,7 @@ ${input.slice(result.pos)}
15740
15971
  }
15741
15972
  }
15742
15973
  var Yield$0 = $TS($S($EXPECT($L164, fail, 'Yield "yield"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
15743
- return { $loc, token: $1 };
15974
+ return { $loc, token: $1, type: "Yield" };
15744
15975
  });
15745
15976
  function Yield(state) {
15746
15977
  let eventData;
@@ -17211,9 +17442,9 @@ ${input.slice(result.pos)}
17211
17442
  return result;
17212
17443
  }
17213
17444
  }
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);
17445
+ var TypeDeclarationRest$0 = $S(TypeKeyword, $E(_), IdentifierName, $E(TypeParameters), __, Equals, $C($S($E(_), Type), $S(__, Type)));
17446
+ var TypeDeclarationRest$1 = $S(Interface, $E(_), IdentifierName, $E(TypeParameters), $E(InterfaceExtendsClause), InterfaceBlock);
17447
+ var TypeDeclarationRest$2 = $S(Namespace, $E(_), IdentifierName, ModuleBlock);
17217
17448
  var TypeDeclarationRest$3 = FunctionSignature;
17218
17449
  function TypeDeclarationRest(state) {
17219
17450
  let eventData;
@@ -17240,7 +17471,7 @@ ${input.slice(result.pos)}
17240
17471
  var TypeLexicalDeclaration$0 = $S(__, LetOrConstOrVar, TypeDeclarationBinding, $Q($S(CommaDelimiter, __, TypeDeclarationBinding)));
17241
17472
  var TypeLexicalDeclaration$1 = $S(__, EnumDeclaration);
17242
17473
  var TypeLexicalDeclaration$2 = ClassSignature;
17243
- var TypeLexicalDeclaration$3 = $S(Namespace, $Q(TrailingComment), IdentifierName, DeclareBlock);
17474
+ var TypeLexicalDeclaration$3 = $S(Namespace, $E(_), IdentifierName, DeclareBlock);
17244
17475
  var TypeLexicalDeclaration$4 = $S(Module, _, StringLiteral, $E(DeclareBlock));
17245
17476
  var TypeLexicalDeclaration$5 = $S(Global, $E(DeclareBlock));
17246
17477
  function TypeLexicalDeclaration(state) {
@@ -17812,7 +18043,7 @@ ${input.slice(result.pos)}
17812
18043
  return result;
17813
18044
  }
17814
18045
  }
17815
- var EnumDeclaration$0 = $TS($S($E($S(Const, _)), Enum, $Q(TrailingComment), IdentifierName, EnumBlock), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
18046
+ var EnumDeclaration$0 = $TS($S($E($S(Const, _)), Enum, $E(_), IdentifierName, EnumBlock), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
17816
18047
  var isConst = $1;
17817
18048
  var id = $4;
17818
18049
  var block = $5;
@@ -17833,7 +18064,7 @@ ${input.slice(result.pos)}
17833
18064
  let init, isString;
17834
18065
  if (property.init) {
17835
18066
  init = module.replaceNodes(
17836
- module.deepCopy(property.init),
18067
+ deepCopy(property.init),
17837
18068
  (n) => n.type === "Identifier" && names.has(n.name),
17838
18069
  (n) => [id, '["', n.name, '"]']
17839
18070
  );
@@ -20552,15 +20783,12 @@ ${input.slice(result.pos)}
20552
20783
  ], exp.async)
20553
20784
  );
20554
20785
  }
20555
- module.hasAwait = (exp) => {
20556
- return gatherRecursiveWithinFunction(exp, ({ type }) => type === "Await").length > 0;
20557
- };
20558
20786
  module.wrapIIFE = (exp, async) => {
20559
20787
  let prefix, suffix;
20560
20788
  if (async) {
20561
20789
  prefix = "(async ()=>{";
20562
20790
  suffix = "})()";
20563
- } else if (module.hasAwait(exp)) {
20791
+ } else if (hasAwait(exp)) {
20564
20792
  prefix = "(await (async ()=>{";
20565
20793
  suffix = "})())";
20566
20794
  } else {
@@ -21134,62 +21362,6 @@ ${input.slice(result.pos)}
21134
21362
  }, props2]
21135
21363
  };
21136
21364
  };
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
- function isFunction(node) {
21187
- const { type } = node;
21188
- return type === "FunctionExpression" || type === "ArrowFunction" || type === "MethodDefinition" || node.async;
21189
- }
21190
- function gatherRecursiveWithinFunction(node, predicate) {
21191
- return gatherRecursive(node, predicate, isFunction);
21192
- }
21193
21365
  function addParentPointers(node, parent) {
21194
21366
  if (node == null)
21195
21367
  return;
@@ -21208,43 +21380,6 @@ ${input.slice(result.pos)}
21208
21380
  }
21209
21381
  }
21210
21382
  }
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
21383
  function findAncestor(node, predicate, stopPredicate) {
21249
21384
  node = node.parent;
21250
21385
  while (node && !stopPredicate?.(node)) {
@@ -21398,7 +21533,7 @@ ${input.slice(result.pos)}
21398
21533
  const { signature, block } = f;
21399
21534
  const isConstructor = signature.name === "constructor";
21400
21535
  const isVoid = isVoidType(signature.returnType?.t);
21401
- const isSet = signature.modifier === "set";
21536
+ const isSet = signature.modifier?.set;
21402
21537
  if (!isConstructor && !isSet && !isVoid) {
21403
21538
  insertReturn(block);
21404
21539
  }
@@ -21559,24 +21694,24 @@ ${input.slice(result.pos)}
21559
21694
  };
21560
21695
  module.convertMethodToFunction = function(method) {
21561
21696
  const { signature, block } = method;
21562
- let opening = signature.children[0];
21563
- if (opening) {
21564
- if (opening[0].type === "GetOrSet") {
21697
+ let { modifier } = signature;
21698
+ if (modifier) {
21699
+ if (modifier.get || modifier.set) {
21565
21700
  throw new Error("cannot convert get/set method to function");
21566
- } else if (opening[0][0]?.type === "Async") {
21567
- opening = [opening[0][0], " function ", ...opening.slice(1)];
21701
+ } else if (modifier.async) {
21702
+ modifier = [modifier.children[0][0], " function ", ...modifier.children.slice(1)];
21568
21703
  } else {
21569
- opening = ["function ", ...opening];
21704
+ modifier = ["function ", ...modifier.children];
21570
21705
  }
21571
21706
  } else {
21572
- opening = "function ";
21707
+ modifier = "function ";
21573
21708
  }
21574
21709
  return {
21575
21710
  ...signature,
21576
21711
  id: signature.name,
21577
21712
  type: "FunctionExpression",
21578
21713
  children: [
21579
- [opening, ...signature.children.slice(1)],
21714
+ [modifier, ...signature.children.slice(1)],
21580
21715
  block
21581
21716
  ],
21582
21717
  block
@@ -22207,8 +22342,12 @@ ${input.slice(result.pos)}
22207
22342
  module.gatherBindingCode = gatherBindingCode;
22208
22343
  module.constructInvocation = function(fn, arg) {
22209
22344
  const fnArr = [fn.leadingComment, fn.expr, fn.trailingComment];
22210
- if (fn.expr.ampersandBlock) {
22211
- const { ref, body } = fn.expr;
22345
+ let expr = fn.expr;
22346
+ while (expr.type === "ParenthesizedExpression") {
22347
+ expr = expr.expression;
22348
+ }
22349
+ if (expr.ampersandBlock) {
22350
+ const { ref, body } = expr;
22212
22351
  ref.type = "PipedExpression";
22213
22352
  ref.children = [module.makeLeftHandSideExpression(arg)];
22214
22353
  return {
@@ -22216,7 +22355,8 @@ ${input.slice(result.pos)}
22216
22355
  children: [module.skipIfOnlyWS(fn.leadingComment), ...body, module.skipIfOnlyWS(fn.trailingComment)]
22217
22356
  };
22218
22357
  }
22219
- const lhs = module.makeLeftHandSideExpression(fn.expr);
22358
+ expr = fn.expr;
22359
+ const lhs = module.makeLeftHandSideExpression(expr);
22220
22360
  let comment = module.skipIfOnlyWS(fn.trailingComment);
22221
22361
  if (comment)
22222
22362
  lhs.children.splice(2, 0, comment);
@@ -22540,6 +22680,18 @@ ${input.slice(result.pos)}
22540
22680
  }
22541
22681
  exports.parse = parse2;
22542
22682
  exports.default = { parse: parse2 };
22683
+ var {
22684
+ clone,
22685
+ deepCopy,
22686
+ gatherNodes,
22687
+ gatherRecursive,
22688
+ gatherRecursiveAll,
22689
+ gatherRecursiveWithinFunction,
22690
+ hasAwait,
22691
+ hasYield,
22692
+ isFunction,
22693
+ removeParentPointers
22694
+ } = require_lib();
22543
22695
  }
22544
22696
  });
22545
22697