@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/browser.js CHANGED
@@ -27,6 +27,123 @@ var Civet = (() => {
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
 
30
+ // source/lib.js
31
+ var require_lib = __commonJS({
32
+ "source/lib.js"(exports, module) {
33
+ "use strict";
34
+ function clone(node) {
35
+ removeParentPointers(node);
36
+ return deepCopy(node);
37
+ }
38
+ function deepCopy(node) {
39
+ if (node == null)
40
+ return node;
41
+ if (typeof node !== "object")
42
+ return node;
43
+ if (Array.isArray(node)) {
44
+ return node.map(deepCopy);
45
+ }
46
+ return Object.fromEntries(
47
+ Object.entries(node).map(([key, value]) => {
48
+ return [key, deepCopy(value)];
49
+ })
50
+ );
51
+ }
52
+ function removeParentPointers(node) {
53
+ if (node == null)
54
+ return;
55
+ if (typeof node !== "object")
56
+ return;
57
+ if (Array.isArray(node)) {
58
+ for (const child of node) {
59
+ removeParentPointers(child);
60
+ }
61
+ return;
62
+ }
63
+ node.parent = null;
64
+ if (node.children) {
65
+ for (const child of node.children) {
66
+ removeParentPointers(child);
67
+ }
68
+ }
69
+ }
70
+ function gatherNodes(node, predicate) {
71
+ if (node == null)
72
+ return [];
73
+ if (Array.isArray(node)) {
74
+ return node.flatMap((n) => gatherNodes(n, predicate));
75
+ }
76
+ if (predicate(node)) {
77
+ return [node];
78
+ }
79
+ switch (node.type) {
80
+ case "BlockStatement":
81
+ return [];
82
+ case "ForStatement":
83
+ const isDec = node.declaration?.type === "Declaration";
84
+ return node.children.flatMap((n) => {
85
+ if (isDec && n === node.declaration)
86
+ return [];
87
+ return gatherNodes(n, predicate);
88
+ });
89
+ default:
90
+ return gatherNodes(node.children, predicate);
91
+ }
92
+ return [];
93
+ }
94
+ function gatherRecursive(node, predicate, skipPredicate) {
95
+ if (node == null)
96
+ return [];
97
+ if (Array.isArray(node)) {
98
+ return node.flatMap((n) => gatherRecursive(n, predicate, skipPredicate));
99
+ }
100
+ if (skipPredicate?.(node))
101
+ return [];
102
+ if (predicate(node)) {
103
+ return [node];
104
+ }
105
+ return gatherRecursive(node.children, predicate, skipPredicate);
106
+ }
107
+ function gatherRecursiveAll(node, predicate) {
108
+ if (node == null)
109
+ return [];
110
+ if (Array.isArray(node)) {
111
+ return node.flatMap((n) => gatherRecursiveAll(n, predicate));
112
+ }
113
+ const nodes = gatherRecursiveAll(node.children, predicate);
114
+ if (predicate(node)) {
115
+ nodes.push(node);
116
+ }
117
+ return nodes;
118
+ }
119
+ function hasAwait(exp) {
120
+ return gatherRecursiveWithinFunction(exp, ({ type }) => type === "Await").length > 0;
121
+ }
122
+ function hasYield(exp) {
123
+ return gatherRecursiveWithinFunction(exp, ({ type }) => type === "Yield").length > 0;
124
+ }
125
+ function isFunction(node) {
126
+ const { type } = node;
127
+ return type === "FunctionExpression" || type === "ArrowFunction" || type === "MethodDefinition" || node.async;
128
+ }
129
+ function gatherRecursiveWithinFunction(node, predicate) {
130
+ return gatherRecursive(node, predicate, isFunction);
131
+ }
132
+ module.exports = {
133
+ clone,
134
+ deepCopy,
135
+ gatherNodes,
136
+ gatherRecursive,
137
+ gatherRecursiveAll,
138
+ gatherRecursiveWithinFunction,
139
+ hasAwait,
140
+ hasYield,
141
+ isFunction,
142
+ removeParentPointers
143
+ };
144
+ }
145
+ });
146
+
30
147
  // source/parser.hera
31
148
  var require_parser = __commonJS({
32
149
  "source/parser.hera"(exports, module) {
@@ -469,7 +586,6 @@ ${input.slice(result.pos)}
469
586
  YieldExpression,
470
587
  YieldTail,
471
588
  ArrowFunction,
472
- ArrowFunctionTail,
473
589
  FatArrow,
474
590
  FatArrowBody,
475
591
  ConditionalExpression,
@@ -566,6 +682,7 @@ ${input.slice(result.pos)}
566
682
  FunctionDeclaration,
567
683
  FunctionSignature,
568
684
  FunctionExpression,
685
+ AmpersandFunctionExpression,
569
686
  OperatorDeclaration,
570
687
  OperatorSignature,
571
688
  AmpersandBlockRHS,
@@ -1880,8 +1997,8 @@ ${input.slice(result.pos)}
1880
1997
  return module.insertTrimmingSpace($1, "");
1881
1998
  });
1882
1999
  var ArgumentList$2 = NestedArgumentList;
1883
- var ArgumentList$3 = $TS($S($Q(TrailingComment), ArgumentPart, $Q($S(CommaDelimiter, $Q(TrailingComment), ArgumentPart))), function($skip, $loc, $0, $1, $2, $3) {
1884
- return [...$1, $2, ...$3];
2000
+ var ArgumentList$3 = $TS($S($E(_), ArgumentPart, $Q($S(CommaDelimiter, $E(_), ArgumentPart))), function($skip, $loc, $0, $1, $2, $3) {
2001
+ return [...$1 || [], $2, ...$3];
1885
2002
  });
1886
2003
  function ArgumentList(state) {
1887
2004
  let eventData;
@@ -1910,8 +2027,8 @@ ${input.slice(result.pos)}
1910
2027
  return module.insertTrimmingSpace($1, "");
1911
2028
  });
1912
2029
  var NonPipelineArgumentList$2 = NestedArgumentList;
1913
- var NonPipelineArgumentList$3 = $TS($S($Q(TrailingComment), NonPipelineArgumentPart, $Q($S(CommaDelimiter, $Q(TrailingComment), NonPipelineArgumentPart))), function($skip, $loc, $0, $1, $2, $3) {
1914
- return [...$1, $2, ...$3];
2030
+ var NonPipelineArgumentList$3 = $TS($S($E(_), NonPipelineArgumentPart, $Q($S(CommaDelimiter, $E(_), NonPipelineArgumentPart))), function($skip, $loc, $0, $1, $2, $3) {
2031
+ return [...$1 || [], $2, ...$3];
1915
2032
  });
1916
2033
  function NonPipelineArgumentList(state) {
1917
2034
  let eventData;
@@ -1986,7 +2103,7 @@ ${input.slice(result.pos)}
1986
2103
  return result;
1987
2104
  }
1988
2105
  }
1989
- var SingleLineArgumentExpressions$0 = $S($Q(TrailingComment), ArgumentPart, $Q($S($Q(TrailingComment), Comma, $Q(TrailingComment), ArgumentPart)));
2106
+ var SingleLineArgumentExpressions$0 = $S($E(_), ArgumentPart, $Q($S($E(_), Comma, $E(_), ArgumentPart)));
1990
2107
  function SingleLineArgumentExpressions(state) {
1991
2108
  let eventData;
1992
2109
  if (state.events) {
@@ -2345,10 +2462,10 @@ ${input.slice(result.pos)}
2345
2462
  return result;
2346
2463
  }
2347
2464
  }
2348
- var SingleLineAssignmentExpression$0 = $TS($S($Q(TrailingComment), AssignmentExpressionTail), function($skip, $loc, $0, $1, $2) {
2465
+ var SingleLineAssignmentExpression$0 = $TS($S($E(_), AssignmentExpressionTail), function($skip, $loc, $0, $1, $2) {
2349
2466
  var ws = $1;
2350
2467
  var tail = $2;
2351
- if (ws.length) {
2468
+ if (ws?.length) {
2352
2469
  if (tail.children && tail.type !== "IterationExpression") {
2353
2470
  return {
2354
2471
  ...tail,
@@ -2465,7 +2582,7 @@ ${input.slice(result.pos)}
2465
2582
  }
2466
2583
  }
2467
2584
  var YieldTail$0 = $Y(EOS);
2468
- var YieldTail$1 = $S($E($S($Q(TrailingComment), Star)), AssignmentExpression);
2585
+ var YieldTail$1 = $S($E($S($E(_), Star)), AssignmentExpression);
2469
2586
  function YieldTail(state) {
2470
2587
  let eventData;
2471
2588
  if (state.events) {
@@ -2488,53 +2605,36 @@ ${input.slice(result.pos)}
2488
2605
  return result;
2489
2606
  }
2490
2607
  }
2491
- var ArrowFunction$0 = $TS($S($E($S(Async, __)), ArrowFunctionTail), function($skip, $loc, $0, $1, $2) {
2492
- var tail = $2;
2493
- return {
2494
- ...tail,
2495
- children: [...$1 || [], ...tail.children]
2496
- };
2497
- });
2498
- function ArrowFunction(state) {
2499
- let eventData;
2500
- if (state.events) {
2501
- const result = state.events.enter?.("ArrowFunction", state);
2502
- if (result) {
2503
- if (result.cache)
2504
- return result.cache;
2505
- eventData = result.data;
2506
- }
2608
+ var ArrowFunction$0 = ThinArrowFunction;
2609
+ var ArrowFunction$1 = $TS($S($E($S(Async, _)), Parameters, $E(ReturnTypeSuffix), FatArrow, FatArrowBody), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
2610
+ var async = $1;
2611
+ var parameters = $2;
2612
+ var suffix = $3;
2613
+ var expOrBlock = $5;
2614
+ if (hasAwait(expOrBlock) && !async) {
2615
+ async = "async ";
2507
2616
  }
2508
- if (state.tokenize) {
2509
- const result = $TOKEN("ArrowFunction", state, ArrowFunction$0(state));
2510
- if (state.events)
2511
- state.events.exit?.("ArrowFunction", state, result, eventData);
2512
- return result;
2513
- } else {
2514
- const result = ArrowFunction$0(state);
2515
- if (state.events)
2516
- state.events.exit?.("ArrowFunction", state, result, eventData);
2517
- return result;
2617
+ let error;
2618
+ if (hasYield(expOrBlock)) {
2619
+ error = {
2620
+ type: "Error",
2621
+ message: "Can't use yield inside of => arrow function"
2622
+ };
2518
2623
  }
2519
- }
2520
- var ArrowFunctionTail$0 = ThinArrowFunction;
2521
- var ArrowFunctionTail$1 = $TS($S(Parameters, $E(ReturnTypeSuffix), FatArrow, FatArrowBody), function($skip, $loc, $0, $1, $2, $3, $4) {
2522
- var parameters = $1;
2523
- var suffix = $2;
2524
- var expOrBlock = $4;
2525
2624
  return {
2526
2625
  type: "ArrowFunction",
2527
2626
  parameters,
2528
2627
  returnType: suffix,
2529
2628
  ts: false,
2629
+ async,
2530
2630
  block: expOrBlock,
2531
- children: $0
2631
+ children: [async, $0.slice(1), error]
2532
2632
  };
2533
2633
  });
2534
- function ArrowFunctionTail(state) {
2634
+ function ArrowFunction(state) {
2535
2635
  let eventData;
2536
2636
  if (state.events) {
2537
- const result = state.events.enter?.("ArrowFunctionTail", state);
2637
+ const result = state.events.enter?.("ArrowFunction", state);
2538
2638
  if (result) {
2539
2639
  if (result.cache)
2540
2640
  return result.cache;
@@ -2542,14 +2642,14 @@ ${input.slice(result.pos)}
2542
2642
  }
2543
2643
  }
2544
2644
  if (state.tokenize) {
2545
- const result = $TOKEN("ArrowFunctionTail", state, ArrowFunctionTail$0(state) || ArrowFunctionTail$1(state));
2645
+ const result = $TOKEN("ArrowFunction", state, ArrowFunction$0(state) || ArrowFunction$1(state));
2546
2646
  if (state.events)
2547
- state.events.exit?.("ArrowFunctionTail", state, result, eventData);
2647
+ state.events.exit?.("ArrowFunction", state, result, eventData);
2548
2648
  return result;
2549
2649
  } else {
2550
- const result = ArrowFunctionTail$0(state) || ArrowFunctionTail$1(state);
2650
+ const result = ArrowFunction$0(state) || ArrowFunction$1(state);
2551
2651
  if (state.events)
2552
- state.events.exit?.("ArrowFunctionTail", state, result, eventData);
2652
+ state.events.exit?.("ArrowFunction", state, result, eventData);
2553
2653
  return result;
2554
2654
  }
2555
2655
  }
@@ -2637,7 +2737,7 @@ ${input.slice(result.pos)}
2637
2737
  }
2638
2738
  }
2639
2739
  var TernaryRest$0 = NestedTernaryRest;
2640
- 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) {
2740
+ 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) {
2641
2741
  return $0.slice(2);
2642
2742
  });
2643
2743
  function TernaryRest(state) {
@@ -2716,6 +2816,23 @@ ${input.slice(result.pos)}
2716
2816
  var ws = $1;
2717
2817
  var head = $2;
2718
2818
  var body = $3;
2819
+ if (head.token === "&") {
2820
+ const ref = {
2821
+ type: "Ref",
2822
+ base: "$"
2823
+ };
2824
+ const arrowBody = {
2825
+ type: "PipelineExpression",
2826
+ children: [ws, ref, body]
2827
+ };
2828
+ return {
2829
+ type: "ArrowFunction",
2830
+ children: [ref, " => ", arrowBody],
2831
+ ref,
2832
+ body: [arrowBody],
2833
+ ampersandBlock: true
2834
+ };
2835
+ }
2719
2836
  return {
2720
2837
  type: "PipelineExpression",
2721
2838
  children: [ws, head, body]
@@ -2745,6 +2862,7 @@ ${input.slice(result.pos)}
2745
2862
  }
2746
2863
  var PipelineHeadItem$0 = NonPipelineExtendedExpression;
2747
2864
  var PipelineHeadItem$1 = ParenthesizedExpression;
2865
+ var PipelineHeadItem$2 = Ampersand;
2748
2866
  function PipelineHeadItem(state) {
2749
2867
  let eventData;
2750
2868
  if (state.events) {
@@ -2756,12 +2874,12 @@ ${input.slice(result.pos)}
2756
2874
  }
2757
2875
  }
2758
2876
  if (state.tokenize) {
2759
- const result = $TOKEN("PipelineHeadItem", state, PipelineHeadItem$0(state) || PipelineHeadItem$1(state));
2877
+ const result = $TOKEN("PipelineHeadItem", state, PipelineHeadItem$0(state) || PipelineHeadItem$1(state) || PipelineHeadItem$2(state));
2760
2878
  if (state.events)
2761
2879
  state.events.exit?.("PipelineHeadItem", state, result, eventData);
2762
2880
  return result;
2763
2881
  } else {
2764
- const result = PipelineHeadItem$0(state) || PipelineHeadItem$1(state);
2882
+ const result = PipelineHeadItem$0(state) || PipelineHeadItem$1(state) || PipelineHeadItem$2(state);
2765
2883
  if (state.events)
2766
2884
  state.events.exit?.("PipelineHeadItem", state, result, eventData);
2767
2885
  return result;
@@ -2770,7 +2888,10 @@ ${input.slice(result.pos)}
2770
2888
  var PipelineTailItem$0 = Await;
2771
2889
  var PipelineTailItem$1 = Yield;
2772
2890
  var PipelineTailItem$2 = Return;
2773
- var PipelineTailItem$3 = PipelineHeadItem;
2891
+ var PipelineTailItem$3 = AmpersandFunctionExpression;
2892
+ var PipelineTailItem$4 = $T($S($N(Ampersand), PipelineHeadItem), function(value) {
2893
+ return value[1];
2894
+ });
2774
2895
  function PipelineTailItem(state) {
2775
2896
  let eventData;
2776
2897
  if (state.events) {
@@ -2782,12 +2903,12 @@ ${input.slice(result.pos)}
2782
2903
  }
2783
2904
  }
2784
2905
  if (state.tokenize) {
2785
- const result = $TOKEN("PipelineTailItem", state, PipelineTailItem$0(state) || PipelineTailItem$1(state) || PipelineTailItem$2(state) || PipelineTailItem$3(state));
2906
+ const result = $TOKEN("PipelineTailItem", state, PipelineTailItem$0(state) || PipelineTailItem$1(state) || PipelineTailItem$2(state) || PipelineTailItem$3(state) || PipelineTailItem$4(state));
2786
2907
  if (state.events)
2787
2908
  state.events.exit?.("PipelineTailItem", state, result, eventData);
2788
2909
  return result;
2789
2910
  } else {
2790
- const result = PipelineTailItem$0(state) || PipelineTailItem$1(state) || PipelineTailItem$2(state) || PipelineTailItem$3(state);
2911
+ const result = PipelineTailItem$0(state) || PipelineTailItem$1(state) || PipelineTailItem$2(state) || PipelineTailItem$3(state) || PipelineTailItem$4(state);
2791
2912
  if (state.events)
2792
2913
  state.events.exit?.("PipelineTailItem", state, result, eventData);
2793
2914
  return result;
@@ -3234,7 +3355,7 @@ ${input.slice(result.pos)}
3234
3355
  return result;
3235
3356
  }
3236
3357
  }
3237
- var ClassElement$0 = $S($E(Decorators), $E(AccessModifier), $E($S(Static, $Q(TrailingComment))), ClassElementDefinition);
3358
+ var ClassElement$0 = $S($E(Decorators), $E(AccessModifier), $E($S(Static, $E(_))), ClassElementDefinition);
3238
3359
  var ClassElement$1 = $S(Static, BracedBlock);
3239
3360
  function ClassElement(state) {
3240
3361
  let eventData;
@@ -3380,7 +3501,7 @@ ${input.slice(result.pos)}
3380
3501
  return result;
3381
3502
  }
3382
3503
  }
3383
- var ClassSignatureElement$0 = $S($E(Decorators), $E(AccessModifier), $E($S(Static, $Q(TrailingComment))), $C(MethodSignature, FieldDefinition));
3504
+ var ClassSignatureElement$0 = $S($E(Decorators), $E(AccessModifier), $E($S(Static, $E(_))), $C(MethodSignature, FieldDefinition));
3384
3505
  var ClassSignatureElement$1 = $S(Static, ClassSignatureBody);
3385
3506
  function ClassSignatureElement(state) {
3386
3507
  let eventData;
@@ -3439,9 +3560,16 @@ ${input.slice(result.pos)}
3439
3560
  var exp = $6;
3440
3561
  switch (exp.type) {
3441
3562
  case "FunctionExpression":
3563
+ const fnTokenIndex = exp.children.findIndex((c) => c?.token?.startsWith("function"));
3564
+ const children = exp.children.slice();
3565
+ if (exp.generator) {
3566
+ children.splice(fnTokenIndex, 2, children[fnTokenIndex + 1], id);
3567
+ } else {
3568
+ children.splice(fnTokenIndex, 1, id);
3569
+ }
3442
3570
  return {
3443
3571
  ...exp,
3444
- children: [id, ...exp.children.slice(1)]
3572
+ children
3445
3573
  };
3446
3574
  default:
3447
3575
  return [id, " = ", exp];
@@ -3456,7 +3584,7 @@ ${input.slice(result.pos)}
3456
3584
  };
3457
3585
  return $0;
3458
3586
  });
3459
- 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) {
3587
+ 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) {
3460
3588
  if ($1)
3461
3589
  return { children: $0, ts: true };
3462
3590
  return $0;
@@ -5542,22 +5670,28 @@ ${input.slice(result.pos)}
5542
5670
  return result;
5543
5671
  }
5544
5672
  }
5545
- 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) {
5673
+ 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) {
5546
5674
  var async = $1;
5547
5675
  var func = $2;
5548
- var star = $3;
5676
+ var generator = $3;
5549
5677
  var wid = $4;
5550
5678
  var w = $5;
5551
5679
  var parameters = $6;
5552
5680
  var suffix = $7;
5681
+ if (!async)
5682
+ async = [];
5683
+ if (!generator)
5684
+ generator = [];
5553
5685
  return {
5554
5686
  type: "FunctionSignature",
5555
5687
  id: wid?.[1],
5556
5688
  parameters,
5557
5689
  returnType: suffix,
5558
5690
  ts: false,
5691
+ async,
5692
+ generator,
5559
5693
  block: null,
5560
- children: !parameters.implicit ? $0 : [async, func, star, wid, parameters, w, suffix]
5694
+ children: !parameters.implicit ? $0 : [async, func, generator, wid, parameters, w, suffix]
5561
5695
  };
5562
5696
  });
5563
5697
  function FunctionSignature(state) {
@@ -5589,6 +5723,12 @@ ${input.slice(result.pos)}
5589
5723
  signature.ts = true;
5590
5724
  return signature;
5591
5725
  }
5726
+ if (hasAwait(block) && !signature.async.length) {
5727
+ signature.async.push("async ");
5728
+ }
5729
+ if (hasYield(block) && !signature.generator.length) {
5730
+ signature.generator.push("*");
5731
+ }
5592
5732
  return {
5593
5733
  ...signature,
5594
5734
  type: "FunctionExpression",
@@ -5596,7 +5736,30 @@ ${input.slice(result.pos)}
5596
5736
  block
5597
5737
  };
5598
5738
  });
5599
- 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) {
5739
+ var FunctionExpression$1 = AmpersandFunctionExpression;
5740
+ function FunctionExpression(state) {
5741
+ let eventData;
5742
+ if (state.events) {
5743
+ const result = state.events.enter?.("FunctionExpression", state);
5744
+ if (result) {
5745
+ if (result.cache)
5746
+ return result.cache;
5747
+ eventData = result.data;
5748
+ }
5749
+ }
5750
+ if (state.tokenize) {
5751
+ const result = $TOKEN("FunctionExpression", state, FunctionExpression$0(state) || FunctionExpression$1(state));
5752
+ if (state.events)
5753
+ state.events.exit?.("FunctionExpression", state, result, eventData);
5754
+ return result;
5755
+ } else {
5756
+ const result = FunctionExpression$0(state) || FunctionExpression$1(state);
5757
+ if (state.events)
5758
+ state.events.exit?.("FunctionExpression", state, result, eventData);
5759
+ return result;
5760
+ }
5761
+ }
5762
+ 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) {
5600
5763
  var prefix = $1;
5601
5764
  var rhs = $3;
5602
5765
  if (!prefix && !rhs)
@@ -5614,7 +5777,7 @@ ${input.slice(result.pos)}
5614
5777
  body = [prefix, rhs];
5615
5778
  }
5616
5779
  const children = [ref, " => ", ...body];
5617
- if (module.hasAwait(body)) {
5780
+ if (hasAwait(body)) {
5618
5781
  children.unshift("async ");
5619
5782
  }
5620
5783
  return {
@@ -5625,10 +5788,10 @@ ${input.slice(result.pos)}
5625
5788
  ampersandBlock: true
5626
5789
  };
5627
5790
  });
5628
- function FunctionExpression(state) {
5791
+ function AmpersandFunctionExpression(state) {
5629
5792
  let eventData;
5630
5793
  if (state.events) {
5631
- const result = state.events.enter?.("FunctionExpression", state);
5794
+ const result = state.events.enter?.("AmpersandFunctionExpression", state);
5632
5795
  if (result) {
5633
5796
  if (result.cache)
5634
5797
  return result.cache;
@@ -5636,14 +5799,14 @@ ${input.slice(result.pos)}
5636
5799
  }
5637
5800
  }
5638
5801
  if (state.tokenize) {
5639
- const result = $TOKEN("FunctionExpression", state, FunctionExpression$0(state) || FunctionExpression$1(state));
5802
+ const result = $TOKEN("AmpersandFunctionExpression", state, AmpersandFunctionExpression$0(state));
5640
5803
  if (state.events)
5641
- state.events.exit?.("FunctionExpression", state, result, eventData);
5804
+ state.events.exit?.("AmpersandFunctionExpression", state, result, eventData);
5642
5805
  return result;
5643
5806
  } else {
5644
- const result = FunctionExpression$0(state) || FunctionExpression$1(state);
5807
+ const result = AmpersandFunctionExpression$0(state);
5645
5808
  if (state.events)
5646
- state.events.exit?.("FunctionExpression", state, result, eventData);
5809
+ state.events.exit?.("AmpersandFunctionExpression", state, result, eventData);
5647
5810
  return result;
5648
5811
  }
5649
5812
  }
@@ -5814,20 +5977,32 @@ ${input.slice(result.pos)}
5814
5977
  return result;
5815
5978
  }
5816
5979
  }
5817
- var ThinArrowFunction$0 = $TS($S(Parameters, $E(ReturnTypeSuffix), $Q(_), Arrow, BracedOrEmptyBlock), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
5818
- var parameters = $1;
5819
- var suffix = $2;
5820
- var arrow = $4;
5821
- var block = $5;
5980
+ var ThinArrowFunction$0 = $TS($S($E($S(Async, _)), Parameters, $E(ReturnTypeSuffix), $Q(_), Arrow, BracedOrEmptyBlock), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
5981
+ var async = $1;
5982
+ var parameters = $2;
5983
+ var suffix = $3;
5984
+ var arrow = $5;
5985
+ var block = $6;
5986
+ if (hasAwait(block) && !async) {
5987
+ async = "async ";
5988
+ }
5989
+ let generator;
5990
+ if (hasYield(block)) {
5991
+ generator = "*";
5992
+ }
5822
5993
  return {
5823
5994
  type: "FunctionExpression",
5824
5995
  id: void 0,
5825
5996
  parameters,
5826
5997
  returnType: suffix,
5827
5998
  ts: false,
5999
+ async,
6000
+ generator,
5828
6001
  block,
5829
6002
  children: [
6003
+ async,
5830
6004
  { $loc: arrow.$loc, token: "function" },
6005
+ generator,
5831
6006
  parameters,
5832
6007
  suffix,
5833
6008
  block
@@ -6198,7 +6373,7 @@ ${input.slice(result.pos)}
6198
6373
  return result;
6199
6374
  }
6200
6375
  }
6201
- var NonSingleBracedBlock$0 = $TS($S($Q(TrailingComment), OpenBrace, AllowAll, $E($S(BracedContent, __, CloseBrace)), RestoreAll), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
6376
+ var NonSingleBracedBlock$0 = $TS($S($E(_), OpenBrace, AllowAll, $E($S(BracedContent, __, CloseBrace)), RestoreAll), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
6202
6377
  var ws1 = $1;
6203
6378
  var open = $2;
6204
6379
  if (!$4)
@@ -6314,7 +6489,7 @@ ${input.slice(result.pos)}
6314
6489
  }
6315
6490
  }
6316
6491
  var BracedContent$0 = NestedBlockStatements;
6317
- var BracedContent$1 = $TS($S($Q(TrailingComment), Statement), function($skip, $loc, $0, $1, $2) {
6492
+ var BracedContent$1 = $TS($S($E(_), Statement), function($skip, $loc, $0, $1, $2) {
6318
6493
  const expressions = [["", $2]];
6319
6494
  return {
6320
6495
  type: "BlockStatement",
@@ -7358,7 +7533,7 @@ ${input.slice(result.pos)}
7358
7533
  return result;
7359
7534
  }
7360
7535
  }
7361
- var ImplicitInlineObjectPropertyDelimiter$0 = $S($Q(TrailingComment), Comma);
7536
+ var ImplicitInlineObjectPropertyDelimiter$0 = $S($E(_), Comma);
7362
7537
  var ImplicitInlineObjectPropertyDelimiter$1 = $T($S($Y($S($C(Samedent, $Q(_)), NamedProperty)), InsertComma), function(value) {
7363
7538
  return value[1];
7364
7539
  });
@@ -7794,9 +7969,38 @@ ${input.slice(result.pos)}
7794
7969
  var MethodDefinition$1 = $TS($S(MethodSignature, $N(PropertyAccess), BracedOrEmptyBlock), function($skip, $loc, $0, $1, $2, $3) {
7795
7970
  var signature = $1;
7796
7971
  var block = $3;
7972
+ let children = $0;
7973
+ let generatorPos = 0;
7974
+ const { modifier } = signature;
7975
+ if (hasAwait(block)) {
7976
+ generatorPos++;
7977
+ children = children.slice();
7978
+ if (modifier?.get || modifier?.set) {
7979
+ children.push({
7980
+ type: "Error",
7981
+ message: "Getters and setters cannot be async"
7982
+ });
7983
+ } else if (modifier?.async) {
7984
+ } else {
7985
+ children.unshift("async ");
7986
+ }
7987
+ }
7988
+ if (hasYield(block)) {
7989
+ if (children === $0)
7990
+ children = children.slice();
7991
+ if (modifier?.get || modifier?.set) {
7992
+ children.push({
7993
+ type: "Error",
7994
+ message: "Getters and setters cannot be generators"
7995
+ });
7996
+ } else if (modifier?.generator) {
7997
+ } else {
7998
+ children.splice(generatorPos, 0, "*");
7999
+ }
8000
+ }
7797
8001
  return {
7798
8002
  type: "MethodDefinition",
7799
- children: $0,
8003
+ children,
7800
8004
  name: signature.name,
7801
8005
  signature,
7802
8006
  block,
@@ -7825,9 +8029,37 @@ ${input.slice(result.pos)}
7825
8029
  return result;
7826
8030
  }
7827
8031
  }
7828
- var MethodModifier$0 = $S(GetOrSet, $Q(TrailingComment));
7829
- var MethodModifier$1 = $S($S(Async, __), $E($S(Star, __)));
7830
- var MethodModifier$2 = $S(Star, __);
8032
+ var MethodModifier$0 = $TS($S(GetOrSet, $E(_)), function($skip, $loc, $0, $1, $2) {
8033
+ var kind = $1;
8034
+ return {
8035
+ type: "MethodModifier",
8036
+ async: false,
8037
+ generator: false,
8038
+ get: kind.token === "get",
8039
+ set: kind.token === "set",
8040
+ children: $0
8041
+ };
8042
+ });
8043
+ var MethodModifier$1 = $TS($S($S(Async, __), $E($S(Star, __))), function($skip, $loc, $0, $1, $2) {
8044
+ return {
8045
+ type: "MethodModifier",
8046
+ async: true,
8047
+ get: false,
8048
+ set: false,
8049
+ generator: !!$1,
8050
+ children: $0
8051
+ };
8052
+ });
8053
+ var MethodModifier$2 = $TS($S(Star, __), function($skip, $loc, $0, $1, $2) {
8054
+ return {
8055
+ type: "MethodModifier",
8056
+ async: false,
8057
+ get: false,
8058
+ set: false,
8059
+ generator: true,
8060
+ children: $0
8061
+ };
8062
+ });
7831
8063
  function MethodModifier(state) {
7832
8064
  let eventData;
7833
8065
  if (state.events) {
@@ -7860,7 +8092,8 @@ ${input.slice(result.pos)}
7860
8092
  parameters
7861
8093
  };
7862
8094
  });
7863
- var MethodSignature$1 = $TS($S($E(MethodModifier), ClassElementName, $Q(_), NonEmptyParameters, $E(ReturnTypeSuffix)), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
8095
+ var MethodSignature$1 = $TS($S($E(MethodModifier), ClassElementName, $E(_), NonEmptyParameters, $E(ReturnTypeSuffix)), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
8096
+ var modifier = $1;
7864
8097
  var name = $2;
7865
8098
  var parameters = $4;
7866
8099
  var suffix = $5;
@@ -7873,7 +8106,7 @@ ${input.slice(result.pos)}
7873
8106
  type: "MethodSignature",
7874
8107
  children: $0,
7875
8108
  name,
7876
- modifier: $1?.[0]?.token,
8109
+ modifier,
7877
8110
  returnType: suffix,
7878
8111
  parameters
7879
8112
  };
@@ -7981,8 +8214,8 @@ ${input.slice(result.pos)}
7981
8214
  return result;
7982
8215
  }
7983
8216
  }
7984
- var AssignmentOp$0 = $TS($S(AssignmentOpSymbol, $Q(TrailingComment)), function($skip, $loc, $0, $1, $2) {
7985
- if ($2.length) {
8217
+ var AssignmentOp$0 = $TS($S(AssignmentOpSymbol, $E(_)), function($skip, $loc, $0, $1, $2) {
8218
+ if ($2?.length) {
7986
8219
  return {
7987
8220
  token: $1,
7988
8221
  children: [$1, ...$2]
@@ -8012,21 +8245,21 @@ ${input.slice(result.pos)}
8012
8245
  return result;
8013
8246
  }
8014
8247
  }
8015
- var OperatorAssignmentOp$0 = $TS($S(Xor, $EXPECT($L2, fail, 'OperatorAssignmentOp "="'), $Y(Whitespace), $Q(TrailingComment)), function($skip, $loc, $0, $1, $2, $3, $4) {
8248
+ var OperatorAssignmentOp$0 = $TS($S(Xor, $EXPECT($L2, fail, 'OperatorAssignmentOp "="'), $Y(Whitespace), $E(_)), function($skip, $loc, $0, $1, $2, $3, $4) {
8016
8249
  return {
8017
8250
  special: true,
8018
8251
  call: module.getRef("xor"),
8019
8252
  children: [$2, ...$4]
8020
8253
  };
8021
8254
  });
8022
- var OperatorAssignmentOp$1 = $TS($S(Xnor, $EXPECT($L2, fail, 'OperatorAssignmentOp "="'), $Y(Whitespace), $Q(TrailingComment)), function($skip, $loc, $0, $1, $2, $3, $4) {
8255
+ var OperatorAssignmentOp$1 = $TS($S(Xnor, $EXPECT($L2, fail, 'OperatorAssignmentOp "="'), $Y(Whitespace), $E(_)), function($skip, $loc, $0, $1, $2, $3, $4) {
8023
8256
  return {
8024
8257
  special: true,
8025
8258
  call: module.getRef("xnor"),
8026
8259
  children: [$2, ...$4]
8027
8260
  };
8028
8261
  });
8029
- var OperatorAssignmentOp$2 = $TS($S(Identifier, $EXPECT($L2, fail, 'OperatorAssignmentOp "="'), $Y(Whitespace), $Q(TrailingComment)), function($skip, $loc, $0, $1, $2, $3, $4) {
8262
+ var OperatorAssignmentOp$2 = $TS($S(Identifier, $EXPECT($L2, fail, 'OperatorAssignmentOp "="'), $Y(Whitespace), $E(_)), function($skip, $loc, $0, $1, $2, $3, $4) {
8030
8263
  return {
8031
8264
  special: true,
8032
8265
  call: $1,
@@ -8492,7 +8725,7 @@ ${input.slice(result.pos)}
8492
8725
  return result;
8493
8726
  }
8494
8727
  }
8495
- var PostfixedStatement$0 = $TS($S(Statement, $E($S($Q(TrailingComment), PostfixStatement))), function($skip, $loc, $0, $1, $2) {
8728
+ var PostfixedStatement$0 = $TS($S(Statement, $E($S($E(_), PostfixStatement))), function($skip, $loc, $0, $1, $2) {
8496
8729
  var statement = $1;
8497
8730
  var post = $2;
8498
8731
  if (post)
@@ -8521,7 +8754,7 @@ ${input.slice(result.pos)}
8521
8754
  return result;
8522
8755
  }
8523
8756
  }
8524
- var PostfixedExpression$0 = $TS($S(ExtendedExpression, $E($S($Q(TrailingComment), PostfixStatement))), function($skip, $loc, $0, $1, $2) {
8757
+ var PostfixedExpression$0 = $TS($S(ExtendedExpression, $E($S($E(_), PostfixStatement))), function($skip, $loc, $0, $1, $2) {
8525
8758
  var expression = $1;
8526
8759
  var post = $2;
8527
8760
  if (post)
@@ -8550,7 +8783,7 @@ ${input.slice(result.pos)}
8550
8783
  return result;
8551
8784
  }
8552
8785
  }
8553
- var NonPipelinePostfixedExpression$0 = $TS($S(NonPipelineExtendedExpression, $E($S($Q(TrailingComment), PostfixStatement))), function($skip, $loc, $0, $1, $2) {
8786
+ var NonPipelinePostfixedExpression$0 = $TS($S(NonPipelineExtendedExpression, $E($S($E(_), PostfixStatement))), function($skip, $loc, $0, $1, $2) {
8554
8787
  var expression = $1;
8555
8788
  var post = $2;
8556
8789
  if (post)
@@ -8643,8 +8876,8 @@ ${input.slice(result.pos)}
8643
8876
  return result;
8644
8877
  }
8645
8878
  }
8646
- var EmptyStatement$0 = $T($S($Q(TrailingComment), $Y($EXPECT($L85, fail, 'EmptyStatement ";"'))), function(value) {
8647
- return { "type": "EmptyStatement", "children": value[0] };
8879
+ var EmptyStatement$0 = $TS($S($E(_), $Y($EXPECT($L85, fail, 'EmptyStatement ";"'))), function($skip, $loc, $0, $1, $2) {
8880
+ return { type: "EmptyStatement", children: $1 || [] };
8648
8881
  });
8649
8882
  function EmptyStatement(state) {
8650
8883
  let eventData;
@@ -8808,7 +9041,7 @@ ${input.slice(result.pos)}
8808
9041
  }
8809
9042
  }
8810
9043
  var ElseClause$0 = $S(Samedent, Else, Block);
8811
- var ElseClause$1 = $S($Q(TrailingComment), Else, Block);
9044
+ var ElseClause$1 = $S($E(_), Else, Block);
8812
9045
  function ElseClause(state) {
8813
9046
  let eventData;
8814
9047
  if (state.events) {
@@ -8943,7 +9176,7 @@ ${input.slice(result.pos)}
8943
9176
  return result;
8944
9177
  }
8945
9178
  }
8946
- var ElseExpressionClause$0 = $TS($S($C($S(Samedent, Else), $S($Q(TrailingComment), Else)), ElseExpressionBlock), function($skip, $loc, $0, $1, $2) {
9179
+ var ElseExpressionClause$0 = $TS($S($C($S(Samedent, Else), $S($E(_), Else)), ElseExpressionBlock), function($skip, $loc, $0, $1, $2) {
8947
9180
  return [...$1, $2];
8948
9181
  });
8949
9182
  function ElseExpressionClause(state) {
@@ -9319,7 +9552,7 @@ ${input.slice(result.pos)}
9319
9552
  return result;
9320
9553
  }
9321
9554
  }
9322
- var WhileClause$0 = $TS($S($C(While, Until), $Q(TrailingComment), Condition), function($skip, $loc, $0, $1, $2, $3) {
9555
+ var WhileClause$0 = $TS($S($C(While, Until), $E(_), Condition), function($skip, $loc, $0, $1, $2, $3) {
9323
9556
  var kind = $1;
9324
9557
  var ws = $2;
9325
9558
  var cond = $3;
@@ -10416,7 +10649,7 @@ ${input.slice(result.pos)}
10416
10649
  return result;
10417
10650
  }
10418
10651
  }
10419
- var Condition$0 = $T($S(ParenthesizedExpression, $N($S($Q(TrailingComment), $C(BinaryOp, AssignmentOp, Dot, QuestionMark))), $N($S(_, OperatorAssignmentOp))), function(value) {
10652
+ var Condition$0 = $T($S(ParenthesizedExpression, $N($S($E(_), $C(BinaryOp, AssignmentOp, Dot, QuestionMark))), $N($S(_, OperatorAssignmentOp))), function(value) {
10420
10653
  return value[0];
10421
10654
  });
10422
10655
  var Condition$1 = $TS($S(InsertOpenParen, ExpressionWithIndentedApplicationForbidden, InsertCloseParen), function($skip, $loc, $0, $1, $2, $3) {
@@ -13381,9 +13614,7 @@ ${input.slice(result.pos)}
13381
13614
  return result;
13382
13615
  }
13383
13616
  }
13384
- var TrailingComment$0 = NonNewlineWhitespace;
13385
- var TrailingComment$1 = InlineComment;
13386
- var TrailingComment$2 = SingleLineComment;
13617
+ var TrailingComment$0 = $S($E(_), SingleLineComment);
13387
13618
  function TrailingComment(state) {
13388
13619
  let eventData;
13389
13620
  if (state.events) {
@@ -13395,12 +13626,12 @@ ${input.slice(result.pos)}
13395
13626
  }
13396
13627
  }
13397
13628
  if (state.tokenize) {
13398
- const result = $TOKEN("TrailingComment", state, TrailingComment$0(state) || TrailingComment$1(state) || TrailingComment$2(state));
13629
+ const result = $TOKEN("TrailingComment", state, TrailingComment$0(state));
13399
13630
  if (state.events)
13400
13631
  state.events.exit?.("TrailingComment", state, result, eventData);
13401
13632
  return result;
13402
13633
  } else {
13403
- const result = TrailingComment$0(state) || TrailingComment$1(state) || TrailingComment$2(state);
13634
+ const result = TrailingComment$0(state);
13404
13635
  if (state.events)
13405
13636
  state.events.exit?.("TrailingComment", state, result, eventData);
13406
13637
  return result;
@@ -13531,7 +13762,7 @@ ${input.slice(result.pos)}
13531
13762
  return result;
13532
13763
  }
13533
13764
  }
13534
- var ExpressionDelimiter$0 = $TS($S($Q(TrailingComment), Semicolon, InsertComma, $Q(TrailingComment)), function($skip, $loc, $0, $1, $2, $3, $4) {
13765
+ var ExpressionDelimiter$0 = $TS($S($E(_), Semicolon, InsertComma, $E(TrailingComment)), function($skip, $loc, $0, $1, $2, $3, $4) {
13535
13766
  return [$1, $3, $4];
13536
13767
  });
13537
13768
  var ExpressionDelimiter$1 = $T($S($Y(EOS), InsertComma), function(value) {
@@ -13608,7 +13839,7 @@ ${input.slice(result.pos)}
13608
13839
  return result;
13609
13840
  }
13610
13841
  }
13611
- var SemicolonDelimiter$0 = $TS($S($Q(TrailingComment), Semicolon, $Q(TrailingComment)), function($skip, $loc, $0, $1, $2, $3) {
13842
+ var SemicolonDelimiter$0 = $TS($S($E(_), Semicolon, $E(TrailingComment)), function($skip, $loc, $0, $1, $2, $3) {
13612
13843
  return {
13613
13844
  type: "SemicolonDelimiter",
13614
13845
  children: $0
@@ -15743,7 +15974,7 @@ ${input.slice(result.pos)}
15743
15974
  }
15744
15975
  }
15745
15976
  var Yield$0 = $TS($S($EXPECT($L164, fail, 'Yield "yield"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
15746
- return { $loc, token: $1 };
15977
+ return { $loc, token: $1, type: "Yield" };
15747
15978
  });
15748
15979
  function Yield(state) {
15749
15980
  let eventData;
@@ -17214,9 +17445,9 @@ ${input.slice(result.pos)}
17214
17445
  return result;
17215
17446
  }
17216
17447
  }
17217
- var TypeDeclarationRest$0 = $S(TypeKeyword, $Q(TrailingComment), IdentifierName, $E(TypeParameters), __, Equals, $C($S($E(_), Type), $S(__, Type)));
17218
- var TypeDeclarationRest$1 = $S(Interface, $Q(TrailingComment), IdentifierName, $E(TypeParameters), $E(InterfaceExtendsClause), InterfaceBlock);
17219
- var TypeDeclarationRest$2 = $S(Namespace, $Q(TrailingComment), IdentifierName, ModuleBlock);
17448
+ var TypeDeclarationRest$0 = $S(TypeKeyword, $E(_), IdentifierName, $E(TypeParameters), __, Equals, $C($S($E(_), Type), $S(__, Type)));
17449
+ var TypeDeclarationRest$1 = $S(Interface, $E(_), IdentifierName, $E(TypeParameters), $E(InterfaceExtendsClause), InterfaceBlock);
17450
+ var TypeDeclarationRest$2 = $S(Namespace, $E(_), IdentifierName, ModuleBlock);
17220
17451
  var TypeDeclarationRest$3 = FunctionSignature;
17221
17452
  function TypeDeclarationRest(state) {
17222
17453
  let eventData;
@@ -17243,7 +17474,7 @@ ${input.slice(result.pos)}
17243
17474
  var TypeLexicalDeclaration$0 = $S(__, LetOrConstOrVar, TypeDeclarationBinding, $Q($S(CommaDelimiter, __, TypeDeclarationBinding)));
17244
17475
  var TypeLexicalDeclaration$1 = $S(__, EnumDeclaration);
17245
17476
  var TypeLexicalDeclaration$2 = ClassSignature;
17246
- var TypeLexicalDeclaration$3 = $S(Namespace, $Q(TrailingComment), IdentifierName, DeclareBlock);
17477
+ var TypeLexicalDeclaration$3 = $S(Namespace, $E(_), IdentifierName, DeclareBlock);
17247
17478
  var TypeLexicalDeclaration$4 = $S(Module, _, StringLiteral, $E(DeclareBlock));
17248
17479
  var TypeLexicalDeclaration$5 = $S(Global, $E(DeclareBlock));
17249
17480
  function TypeLexicalDeclaration(state) {
@@ -17815,7 +18046,7 @@ ${input.slice(result.pos)}
17815
18046
  return result;
17816
18047
  }
17817
18048
  }
17818
- var EnumDeclaration$0 = $TS($S($E($S(Const, _)), Enum, $Q(TrailingComment), IdentifierName, EnumBlock), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
18049
+ var EnumDeclaration$0 = $TS($S($E($S(Const, _)), Enum, $E(_), IdentifierName, EnumBlock), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
17819
18050
  var isConst = $1;
17820
18051
  var id = $4;
17821
18052
  var block = $5;
@@ -17836,7 +18067,7 @@ ${input.slice(result.pos)}
17836
18067
  let init, isString;
17837
18068
  if (property.init) {
17838
18069
  init = module.replaceNodes(
17839
- module.deepCopy(property.init),
18070
+ deepCopy(property.init),
17840
18071
  (n) => n.type === "Identifier" && names.has(n.name),
17841
18072
  (n) => [id, '["', n.name, '"]']
17842
18073
  );
@@ -20555,15 +20786,12 @@ ${input.slice(result.pos)}
20555
20786
  ], exp.async)
20556
20787
  );
20557
20788
  }
20558
- module.hasAwait = (exp) => {
20559
- return gatherRecursiveWithinFunction(exp, ({ type }) => type === "Await").length > 0;
20560
- };
20561
20789
  module.wrapIIFE = (exp, async) => {
20562
20790
  let prefix, suffix;
20563
20791
  if (async) {
20564
20792
  prefix = "(async ()=>{";
20565
20793
  suffix = "})()";
20566
- } else if (module.hasAwait(exp)) {
20794
+ } else if (hasAwait(exp)) {
20567
20795
  prefix = "(await (async ()=>{";
20568
20796
  suffix = "})())";
20569
20797
  } else {
@@ -21137,62 +21365,6 @@ ${input.slice(result.pos)}
21137
21365
  }, props2]
21138
21366
  };
21139
21367
  };
21140
- function gatherNodes(node, predicate) {
21141
- if (node == null)
21142
- return [];
21143
- if (Array.isArray(node)) {
21144
- return node.flatMap((n) => gatherNodes(n, predicate));
21145
- }
21146
- if (predicate(node)) {
21147
- return [node];
21148
- }
21149
- switch (node.type) {
21150
- case "BlockStatement":
21151
- return [];
21152
- case "ForStatement":
21153
- const isDec = node.declaration?.type === "Declaration";
21154
- return node.children.flatMap((n) => {
21155
- if (isDec && n === node.declaration)
21156
- return [];
21157
- return gatherNodes(n, predicate);
21158
- });
21159
- default:
21160
- return gatherNodes(node.children, predicate);
21161
- }
21162
- return [];
21163
- }
21164
- function gatherRecursive(node, predicate, skipPredicate) {
21165
- if (node == null)
21166
- return [];
21167
- if (Array.isArray(node)) {
21168
- return node.flatMap((n) => gatherRecursive(n, predicate, skipPredicate));
21169
- }
21170
- if (skipPredicate?.(node))
21171
- return [];
21172
- if (predicate(node)) {
21173
- return [node];
21174
- }
21175
- return gatherRecursive(node.children, predicate, skipPredicate);
21176
- }
21177
- function gatherRecursiveAll(node, predicate) {
21178
- if (node == null)
21179
- return [];
21180
- if (Array.isArray(node)) {
21181
- return node.flatMap((n) => gatherRecursiveAll(n, predicate));
21182
- }
21183
- const nodes = gatherRecursiveAll(node.children, predicate);
21184
- if (predicate(node)) {
21185
- nodes.push(node);
21186
- }
21187
- return nodes;
21188
- }
21189
- function isFunction(node) {
21190
- const { type } = node;
21191
- return type === "FunctionExpression" || type === "ArrowFunction" || type === "MethodDefinition" || node.async;
21192
- }
21193
- function gatherRecursiveWithinFunction(node, predicate) {
21194
- return gatherRecursive(node, predicate, isFunction);
21195
- }
21196
21368
  function addParentPointers(node, parent) {
21197
21369
  if (node == null)
21198
21370
  return;
@@ -21211,43 +21383,6 @@ ${input.slice(result.pos)}
21211
21383
  }
21212
21384
  }
21213
21385
  }
21214
- function removeParentPointers(node) {
21215
- if (node == null)
21216
- return;
21217
- if (typeof node !== "object")
21218
- return;
21219
- if (Array.isArray(node)) {
21220
- for (const child of node) {
21221
- removeParentPointers(child);
21222
- }
21223
- return;
21224
- }
21225
- node.parent = null;
21226
- if (node.children) {
21227
- for (const child of node.children) {
21228
- removeParentPointers(child);
21229
- }
21230
- }
21231
- }
21232
- function clone(node) {
21233
- removeParentPointers(node);
21234
- return deepCopy(node);
21235
- }
21236
- function deepCopy(node) {
21237
- if (node == null)
21238
- return node;
21239
- if (typeof node !== "object")
21240
- return node;
21241
- if (Array.isArray(node)) {
21242
- return node.map(deepCopy);
21243
- }
21244
- return Object.fromEntries(
21245
- Object.entries(node).map(([key, value]) => {
21246
- return [key, deepCopy(value)];
21247
- })
21248
- );
21249
- }
21250
- module.deepCopy = deepCopy;
21251
21386
  function findAncestor(node, predicate, stopPredicate) {
21252
21387
  node = node.parent;
21253
21388
  while (node && !stopPredicate?.(node)) {
@@ -21401,7 +21536,7 @@ ${input.slice(result.pos)}
21401
21536
  const { signature, block } = f;
21402
21537
  const isConstructor = signature.name === "constructor";
21403
21538
  const isVoid = isVoidType(signature.returnType?.t);
21404
- const isSet = signature.modifier === "set";
21539
+ const isSet = signature.modifier?.set;
21405
21540
  if (!isConstructor && !isSet && !isVoid) {
21406
21541
  insertReturn(block);
21407
21542
  }
@@ -21562,24 +21697,24 @@ ${input.slice(result.pos)}
21562
21697
  };
21563
21698
  module.convertMethodToFunction = function(method) {
21564
21699
  const { signature, block } = method;
21565
- let opening = signature.children[0];
21566
- if (opening) {
21567
- if (opening[0].type === "GetOrSet") {
21700
+ let { modifier } = signature;
21701
+ if (modifier) {
21702
+ if (modifier.get || modifier.set) {
21568
21703
  throw new Error("cannot convert get/set method to function");
21569
- } else if (opening[0][0]?.type === "Async") {
21570
- opening = [opening[0][0], " function ", ...opening.slice(1)];
21704
+ } else if (modifier.async) {
21705
+ modifier = [modifier.children[0][0], " function ", ...modifier.children.slice(1)];
21571
21706
  } else {
21572
- opening = ["function ", ...opening];
21707
+ modifier = ["function ", ...modifier.children];
21573
21708
  }
21574
21709
  } else {
21575
- opening = "function ";
21710
+ modifier = "function ";
21576
21711
  }
21577
21712
  return {
21578
21713
  ...signature,
21579
21714
  id: signature.name,
21580
21715
  type: "FunctionExpression",
21581
21716
  children: [
21582
- [opening, ...signature.children.slice(1)],
21717
+ [modifier, ...signature.children.slice(1)],
21583
21718
  block
21584
21719
  ],
21585
21720
  block
@@ -22210,8 +22345,12 @@ ${input.slice(result.pos)}
22210
22345
  module.gatherBindingCode = gatherBindingCode;
22211
22346
  module.constructInvocation = function(fn, arg) {
22212
22347
  const fnArr = [fn.leadingComment, fn.expr, fn.trailingComment];
22213
- if (fn.expr.ampersandBlock) {
22214
- const { ref, body } = fn.expr;
22348
+ let expr = fn.expr;
22349
+ while (expr.type === "ParenthesizedExpression") {
22350
+ expr = expr.expression;
22351
+ }
22352
+ if (expr.ampersandBlock) {
22353
+ const { ref, body } = expr;
22215
22354
  ref.type = "PipedExpression";
22216
22355
  ref.children = [module.makeLeftHandSideExpression(arg)];
22217
22356
  return {
@@ -22219,7 +22358,8 @@ ${input.slice(result.pos)}
22219
22358
  children: [module.skipIfOnlyWS(fn.leadingComment), ...body, module.skipIfOnlyWS(fn.trailingComment)]
22220
22359
  };
22221
22360
  }
22222
- const lhs = module.makeLeftHandSideExpression(fn.expr);
22361
+ expr = fn.expr;
22362
+ const lhs = module.makeLeftHandSideExpression(expr);
22223
22363
  let comment = module.skipIfOnlyWS(fn.trailingComment);
22224
22364
  if (comment)
22225
22365
  lhs.children.splice(2, 0, comment);
@@ -22543,6 +22683,18 @@ ${input.slice(result.pos)}
22543
22683
  }
22544
22684
  exports.parse = parse2;
22545
22685
  exports.default = { parse: parse2 };
22686
+ var {
22687
+ clone,
22688
+ deepCopy,
22689
+ gatherNodes,
22690
+ gatherRecursive,
22691
+ gatherRecursiveAll,
22692
+ gatherRecursiveWithinFunction,
22693
+ hasAwait,
22694
+ hasYield,
22695
+ isFunction,
22696
+ removeParentPointers
22697
+ } = require_lib();
22546
22698
  }
22547
22699
  });
22548
22700