@danielx/civet 0.5.73 → 0.5.75

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
@@ -597,6 +597,7 @@ ${input.slice(result.pos)}
597
597
  NestedElementList,
598
598
  NestedElement,
599
599
  ArrayElementDelimiter,
600
+ ElementListWithIndentedApplicationForbidden,
600
601
  ElementList,
601
602
  ElementListRest,
602
603
  ArrayElementExpression,
@@ -639,6 +640,7 @@ ${input.slice(result.pos)}
639
640
  StatementListItem,
640
641
  PostfixedStatement,
641
642
  PostfixedExpression,
643
+ NonPipelinePostfixedExpression,
642
644
  PostfixStatement,
643
645
  Statement,
644
646
  EmptyStatement,
@@ -662,6 +664,7 @@ ${input.slice(result.pos)}
662
664
  LoopStatement,
663
665
  LoopClause,
664
666
  DoWhileStatement,
667
+ DoStatement,
665
668
  WhileStatement,
666
669
  WhileClause,
667
670
  ForStatement,
@@ -1035,6 +1038,7 @@ ${input.slice(result.pos)}
1035
1038
  TrackIndented,
1036
1039
  Samedent,
1037
1040
  IndentedFurther,
1041
+ NotDedented,
1038
1042
  PushIndent,
1039
1043
  PopIndent,
1040
1044
  Nested
@@ -1963,7 +1967,7 @@ ${input.slice(result.pos)}
1963
1967
  var rhs = $2;
1964
1968
  return [[], op, [], rhs];
1965
1969
  });
1966
- var BinaryOpRHS$1 = $S(__, BinaryOp, $C(_, $S(EOS, __)), RHS);
1970
+ var BinaryOpRHS$1 = $S(NotDedented, BinaryOp, $C(_, $S(EOS, __)), RHS);
1967
1971
  function BinaryOpRHS(state) {
1968
1972
  let eventData;
1969
1973
  if (state.events) {
@@ -2445,7 +2449,7 @@ ${input.slice(result.pos)}
2445
2449
  return result;
2446
2450
  }
2447
2451
  }
2448
- var FatArrowBody$0 = $T($S($N(EOS), PostfixedExpression, $N(SemicolonDelimiter)), function(value) {
2452
+ var FatArrowBody$0 = $T($S($N(EOS), NonPipelinePostfixedExpression, $N(SemicolonDelimiter)), function(value) {
2449
2453
  var exp = value[1];
2450
2454
  return exp;
2451
2455
  });
@@ -2576,12 +2580,13 @@ ${input.slice(result.pos)}
2576
2580
  return result;
2577
2581
  }
2578
2582
  }
2579
- var PipelineExpression$0 = $TS($S(PipelineHeadItem, $P($S(__, Pipe, __, PipelineTailItem))), function($skip, $loc, $0, $1, $2) {
2580
- var head = $1;
2581
- var body = $2;
2583
+ var PipelineExpression$0 = $TS($S($E(_), PipelineHeadItem, $P($S(NotDedented, Pipe, __, PipelineTailItem))), function($skip, $loc, $0, $1, $2, $3) {
2584
+ var ws = $1;
2585
+ var head = $2;
2586
+ var body = $3;
2582
2587
  return {
2583
2588
  type: "PipelineExpression",
2584
- children: [head, body]
2589
+ children: [ws, head, body]
2585
2590
  };
2586
2591
  });
2587
2592
  function PipelineExpression(state) {
@@ -5477,9 +5482,13 @@ ${input.slice(result.pos)}
5477
5482
  };
5478
5483
  }
5479
5484
  const { ref } = rhs;
5485
+ const children = [ref, " => ", prefix, rhs];
5486
+ if (module.hasAwait(rhs)) {
5487
+ children.unshift("async ");
5488
+ }
5480
5489
  return {
5481
5490
  type: "ArrowFunction",
5482
- children: [ref, " => ", prefix, rhs],
5491
+ children,
5483
5492
  ampersandBlock: true
5484
5493
  };
5485
5494
  });
@@ -6512,7 +6521,7 @@ ${input.slice(result.pos)}
6512
6521
  var ArrayLiteral$0 = $T($S(ArrayBindingPattern, UpcomingAssignment), function(value) {
6513
6522
  return value[0];
6514
6523
  });
6515
- var ArrayLiteral$1 = $TS($S(OpenBracket, AllowAll, $E($S(ArrayLiteralContent, __, CloseBracket)), RestoreIndentedApplication, RestoreAll), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
6524
+ var ArrayLiteral$1 = $TS($S(OpenBracket, AllowAll, $E($S(ArrayLiteralContent, __, CloseBracket)), RestoreAll), function($skip, $loc, $0, $1, $2, $3, $4) {
6516
6525
  var open = $1;
6517
6526
  if (!$3)
6518
6527
  return $skip;
@@ -6649,7 +6658,7 @@ ${input.slice(result.pos)}
6649
6658
  var ArrayLiteralContent$0 = RangeExpression;
6650
6659
  var ArrayLiteralContent$1 = $S(NestedImplicitObjectLiteral, $Q($S(__, Comma, NestedImplicitObjectLiteral)));
6651
6660
  var ArrayLiteralContent$2 = NestedElementList;
6652
- var ArrayLiteralContent$3 = $TS($S(ElementList, InsertComma, $E(NestedElementList)), function($skip, $loc, $0, $1, $2, $3) {
6661
+ var ArrayLiteralContent$3 = $TS($S(ElementListWithIndentedApplicationForbidden, InsertComma, $E(NestedElementList)), function($skip, $loc, $0, $1, $2, $3) {
6653
6662
  var list = $1;
6654
6663
  var comma = $2;
6655
6664
  var nested = $3;
@@ -6778,6 +6787,33 @@ ${input.slice(result.pos)}
6778
6787
  return result;
6779
6788
  }
6780
6789
  }
6790
+ var ElementListWithIndentedApplicationForbidden$0 = $TS($S(ForbidIndentedApplication, $E(ElementList), RestoreIndentedApplication), function($skip, $loc, $0, $1, $2, $3) {
6791
+ if ($2)
6792
+ return $2;
6793
+ return $skip;
6794
+ });
6795
+ function ElementListWithIndentedApplicationForbidden(state) {
6796
+ let eventData;
6797
+ if (state.events) {
6798
+ const result = state.events.enter?.("ElementListWithIndentedApplicationForbidden", state);
6799
+ if (result) {
6800
+ if (result.cache)
6801
+ return result.cache;
6802
+ eventData = result.data;
6803
+ }
6804
+ }
6805
+ if (state.tokenize) {
6806
+ const result = $TOKEN("ElementListWithIndentedApplicationForbidden", state, ElementListWithIndentedApplicationForbidden$0(state));
6807
+ if (state.events)
6808
+ state.events.exit?.("ElementListWithIndentedApplicationForbidden", state, result, eventData);
6809
+ return result;
6810
+ } else {
6811
+ const result = ElementListWithIndentedApplicationForbidden$0(state);
6812
+ if (state.events)
6813
+ state.events.exit?.("ElementListWithIndentedApplicationForbidden", state, result, eventData);
6814
+ return result;
6815
+ }
6816
+ }
6781
6817
  var ElementList$0 = $TS($S(ArrayElementExpression, $Q(ElementListRest)), function($skip, $loc, $0, $1, $2) {
6782
6818
  var first = $1;
6783
6819
  var rest = $2;
@@ -8362,6 +8398,35 @@ ${input.slice(result.pos)}
8362
8398
  return result;
8363
8399
  }
8364
8400
  }
8401
+ var NonPipelinePostfixedExpression$0 = $TS($S(NonPipelineExtendedExpression, $E($S($Q(TrailingComment), PostfixStatement))), function($skip, $loc, $0, $1, $2) {
8402
+ var expression = $1;
8403
+ var post = $2;
8404
+ if (post)
8405
+ return module.attachPostfixStatementAsExpression(expression, post);
8406
+ return expression;
8407
+ });
8408
+ function NonPipelinePostfixedExpression(state) {
8409
+ let eventData;
8410
+ if (state.events) {
8411
+ const result = state.events.enter?.("NonPipelinePostfixedExpression", state);
8412
+ if (result) {
8413
+ if (result.cache)
8414
+ return result.cache;
8415
+ eventData = result.data;
8416
+ }
8417
+ }
8418
+ if (state.tokenize) {
8419
+ const result = $TOKEN("NonPipelinePostfixedExpression", state, NonPipelinePostfixedExpression$0(state));
8420
+ if (state.events)
8421
+ state.events.exit?.("NonPipelinePostfixedExpression", state, result, eventData);
8422
+ return result;
8423
+ } else {
8424
+ const result = NonPipelinePostfixedExpression$0(state);
8425
+ if (state.events)
8426
+ state.events.exit?.("NonPipelinePostfixedExpression", state, result, eventData);
8427
+ return result;
8428
+ }
8429
+ }
8365
8430
  var PostfixStatement$0 = ForClause;
8366
8431
  var PostfixStatement$1 = IfClause;
8367
8432
  var PostfixStatement$2 = LoopClause;
@@ -8898,8 +8963,11 @@ ${input.slice(result.pos)}
8898
8963
  var IterationStatement$1 = $T($S($N(CoffeeDoEnabled), DoWhileStatement), function(value) {
8899
8964
  return value[1];
8900
8965
  });
8901
- var IterationStatement$2 = WhileStatement;
8902
- var IterationStatement$3 = ForStatement;
8966
+ var IterationStatement$2 = $T($S($N(CoffeeDoEnabled), DoStatement), function(value) {
8967
+ return value[1];
8968
+ });
8969
+ var IterationStatement$3 = WhileStatement;
8970
+ var IterationStatement$4 = ForStatement;
8903
8971
  function IterationStatement(state) {
8904
8972
  let eventData;
8905
8973
  if (state.events) {
@@ -8911,12 +8979,12 @@ ${input.slice(result.pos)}
8911
8979
  }
8912
8980
  }
8913
8981
  if (state.tokenize) {
8914
- const result = $TOKEN("IterationStatement", state, IterationStatement$0(state) || IterationStatement$1(state) || IterationStatement$2(state) || IterationStatement$3(state));
8982
+ const result = $TOKEN("IterationStatement", state, IterationStatement$0(state) || IterationStatement$1(state) || IterationStatement$2(state) || IterationStatement$3(state) || IterationStatement$4(state));
8915
8983
  if (state.events)
8916
8984
  state.events.exit?.("IterationStatement", state, result, eventData);
8917
8985
  return result;
8918
8986
  } else {
8919
- const result = IterationStatement$0(state) || IterationStatement$1(state) || IterationStatement$2(state) || IterationStatement$3(state);
8987
+ const result = IterationStatement$0(state) || IterationStatement$1(state) || IterationStatement$2(state) || IterationStatement$3(state) || IterationStatement$4(state);
8920
8988
  if (state.events)
8921
8989
  state.events.exit?.("IterationStatement", state, result, eventData);
8922
8990
  return result;
@@ -8925,6 +8993,7 @@ ${input.slice(result.pos)}
8925
8993
  var IterationExpression$0 = $TS($S(IterationStatement), function($skip, $loc, $0, $1) {
8926
8994
  return {
8927
8995
  type: "IterationExpression",
8996
+ subtype: $1.type,
8928
8997
  children: [$1],
8929
8998
  block: $1.block
8930
8999
  };
@@ -9033,6 +9102,37 @@ ${input.slice(result.pos)}
9033
9102
  return result;
9034
9103
  }
9035
9104
  }
9105
+ var DoStatement$0 = $TS($S(Do, NoPostfixBracedBlock), function($skip, $loc, $0, $1, $2) {
9106
+ var block = $2;
9107
+ block = module.insertTrimmingSpace(block, "");
9108
+ return {
9109
+ type: "DoStatement",
9110
+ children: [block],
9111
+ block
9112
+ };
9113
+ });
9114
+ function DoStatement(state) {
9115
+ let eventData;
9116
+ if (state.events) {
9117
+ const result = state.events.enter?.("DoStatement", state);
9118
+ if (result) {
9119
+ if (result.cache)
9120
+ return result.cache;
9121
+ eventData = result.data;
9122
+ }
9123
+ }
9124
+ if (state.tokenize) {
9125
+ const result = $TOKEN("DoStatement", state, DoStatement$0(state));
9126
+ if (state.events)
9127
+ state.events.exit?.("DoStatement", state, result, eventData);
9128
+ return result;
9129
+ } else {
9130
+ const result = DoStatement$0(state);
9131
+ if (state.events)
9132
+ state.events.exit?.("DoStatement", state, result, eventData);
9133
+ return result;
9134
+ }
9135
+ }
9036
9136
  var WhileStatement$0 = $TS($S(WhileClause, Block), function($skip, $loc, $0, $1, $2) {
9037
9137
  var clause = $1;
9038
9138
  var block = $2;
@@ -9206,7 +9306,7 @@ ${input.slice(result.pos)}
9206
9306
  return result;
9207
9307
  }
9208
9308
  }
9209
- var WhenCondition$0 = $T($S(__, When, ExtendedExpression), function(value) {
9309
+ var WhenCondition$0 = $T($S(__, When, ExpressionWithIndentedApplicationForbidden), function(value) {
9210
9310
  var exp = value[2];
9211
9311
  return exp;
9212
9312
  });
@@ -9232,7 +9332,7 @@ ${input.slice(result.pos)}
9232
9332
  return result;
9233
9333
  }
9234
9334
  }
9235
- var CoffeeForStatementParameters$0 = $TS($S($E($S(Await, __)), InsertOpenParen, CoffeeForDeclaration, $E(CoffeeForIndex), __, $C(In, Of, From), ExtendedExpression, $E($S(__, By, ExtendedExpression)), InsertCloseParen), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
9335
+ var CoffeeForStatementParameters$0 = $TS($S($E($S(Await, __)), InsertOpenParen, CoffeeForDeclaration, $E(CoffeeForIndex), __, $C(In, Of, From), ExpressionWithIndentedApplicationForbidden, $E($S(__, By, ExpressionWithIndentedApplicationForbidden)), InsertCloseParen), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
9236
9336
  var open = $2;
9237
9337
  var declaration = $3;
9238
9338
  var index = $4;
@@ -9719,7 +9819,7 @@ ${input.slice(result.pos)}
9719
9819
  var e = $0;
9720
9820
  return {
9721
9821
  type: "SwitchExpression",
9722
- children: ["(()=>{", e.children, "})()"],
9822
+ children: module.wrapIIFE(e.children),
9723
9823
  expression: e.expression,
9724
9824
  caseBlock: e.caseBlock
9725
9825
  };
@@ -9974,13 +10074,31 @@ ${input.slice(result.pos)}
9974
10074
  var c = $3;
9975
10075
  var f = $4;
9976
10076
  if (!c && !f) {
10077
+ const e = [];
10078
+ const emptyCatchBlock = {
10079
+ type: "BlockStatement",
10080
+ expressions: e,
10081
+ children: ["{", e, "}"],
10082
+ bare: false,
10083
+ empty: true
10084
+ };
10085
+ c = {
10086
+ type: "CatchClause",
10087
+ children: [" catch(e) ", emptyCatchBlock],
10088
+ block: emptyCatchBlock
10089
+ };
9977
10090
  return {
9978
10091
  type: "TryStatement",
9979
- children: [t, b, " catch(e) {}"]
10092
+ blocks: [b, emptyCatchBlock],
10093
+ children: [t, b, c]
9980
10094
  };
9981
10095
  }
10096
+ const blocks = [b];
10097
+ if (c)
10098
+ blocks.push(c.block);
9982
10099
  return {
9983
10100
  type: "TryStatement",
10101
+ blocks,
9984
10102
  children: [t, b, c, f]
9985
10103
  };
9986
10104
  });
@@ -10010,8 +10128,8 @@ ${input.slice(result.pos)}
10010
10128
  var t = $0;
10011
10129
  return {
10012
10130
  type: "TryExpression",
10013
- blocks: [t.children[1], t.children[2]?.[3]],
10014
- children: ["(()=>{", t, "})()"]
10131
+ blocks: t.blocks,
10132
+ children: module.wrapIIFE(t)
10015
10133
  };
10016
10134
  });
10017
10135
  function TryExpression(state) {
@@ -10036,7 +10154,14 @@ ${input.slice(result.pos)}
10036
10154
  return result;
10037
10155
  }
10038
10156
  }
10039
- var CatchClause$0 = $S($C(Samedent, _), Catch, $E(CatchBind), $C(ThenClause, BracedOrEmptyBlock));
10157
+ var CatchClause$0 = $TS($S($C(Samedent, _), Catch, $E(CatchBind), $C(ThenClause, BracedOrEmptyBlock)), function($skip, $loc, $0, $1, $2, $3, $4) {
10158
+ var block = $4;
10159
+ return {
10160
+ type: "CatchClause",
10161
+ children: $0,
10162
+ block
10163
+ };
10164
+ });
10040
10165
  function CatchClause(state) {
10041
10166
  let eventData;
10042
10167
  if (state.events) {
@@ -10700,7 +10825,7 @@ ${input.slice(result.pos)}
10700
10825
  var DebuggerExpression$0 = $TS($S(Debugger), function($skip, $loc, $0, $1) {
10701
10826
  return {
10702
10827
  type: "DebuggerExpression",
10703
- children: ["(()=>{", $1, "})()"]
10828
+ children: module.wrapIIFE($1)
10704
10829
  };
10705
10830
  });
10706
10831
  function DebuggerExpression(state) {
@@ -10728,7 +10853,7 @@ ${input.slice(result.pos)}
10728
10853
  var ThrowExpression$0 = $TS($S(Throw, ExtendedExpression), function($skip, $loc, $0, $1, $2) {
10729
10854
  return {
10730
10855
  type: "ThrowExpression",
10731
- children: ["(()=>{", $0, "})()"]
10856
+ children: module.wrapIIFE($0)
10732
10857
  };
10733
10858
  });
10734
10859
  function ThrowExpression(state) {
@@ -13218,7 +13343,7 @@ ${input.slice(result.pos)}
13218
13343
  }
13219
13344
  }
13220
13345
  var StatementDelimiter$0 = SemicolonDelimiter;
13221
- var StatementDelimiter$1 = $S($Y($S(Samedent, $C($EXPECT($L2, fail, 'StatementDelimiter "("'), $EXPECT($L97, fail, 'StatementDelimiter "["'), $EXPECT($L98, fail, 'StatementDelimiter "`"'), $EXPECT($L58, fail, 'StatementDelimiter "+"'), $EXPECT($L17, fail, 'StatementDelimiter "-"'), $EXPECT($L54, fail, 'StatementDelimiter "*"'), $EXPECT($L55, fail, 'StatementDelimiter "/"'), ObjectLiteral, Arrow, $S(Function, $E($S($E(_), Star)), $E(_), $EXPECT($L2, fail, 'StatementDelimiter "("'))))), InsertSemicolon);
13346
+ var StatementDelimiter$1 = $S($Y($S(Samedent, $C($EXPECT($L2, fail, 'StatementDelimiter "("'), $EXPECT($L97, fail, 'StatementDelimiter "["'), $EXPECT($L98, fail, 'StatementDelimiter "`"'), $EXPECT($L58, fail, 'StatementDelimiter "+"'), $EXPECT($L17, fail, 'StatementDelimiter "-"'), $EXPECT($L54, fail, 'StatementDelimiter "*"'), $EXPECT($L55, fail, 'StatementDelimiter "/"'), ObjectLiteral, Arrow, FatArrow, $S(Function, $E($S($E(_), Star)), $E(_), $EXPECT($L2, fail, 'StatementDelimiter "("'))))), InsertSemicolon);
13222
13347
  var StatementDelimiter$2 = $Y(EOS);
13223
13348
  function StatementDelimiter(state) {
13224
13349
  let eventData;
@@ -13469,7 +13594,7 @@ ${input.slice(result.pos)}
13469
13594
  }
13470
13595
  }
13471
13596
  var Await$0 = $TS($S($EXPECT($L104, fail, 'Await "await"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
13472
- return { $loc, token: $1 };
13597
+ return { $loc, token: $1, type: "Await" };
13473
13598
  });
13474
13599
  function Await(state) {
13475
13600
  let eventData;
@@ -17451,6 +17576,9 @@ ${input.slice(result.pos)}
17451
17576
  var TypeSuffix$1 = $T($S(QuestionMark, $E(_)), function(value) {
17452
17577
  return { "type": "TypeSuffix", "ts": true, "children": value };
17453
17578
  });
17579
+ var TypeSuffix$2 = $T($S(NonNullAssertion, $E(_), $E($S(Colon, Type))), function(value) {
17580
+ return { "type": "TypeSuffix", "ts": true, "children": value };
17581
+ });
17454
17582
  function TypeSuffix(state) {
17455
17583
  let eventData;
17456
17584
  if (state.events) {
@@ -17462,12 +17590,12 @@ ${input.slice(result.pos)}
17462
17590
  }
17463
17591
  }
17464
17592
  if (state.tokenize) {
17465
- const result = $TOKEN("TypeSuffix", state, TypeSuffix$0(state) || TypeSuffix$1(state));
17593
+ const result = $TOKEN("TypeSuffix", state, TypeSuffix$0(state) || TypeSuffix$1(state) || TypeSuffix$2(state));
17466
17594
  if (state.events)
17467
17595
  state.events.exit?.("TypeSuffix", state, result, eventData);
17468
17596
  return result;
17469
17597
  } else {
17470
- const result = TypeSuffix$0(state) || TypeSuffix$1(state);
17598
+ const result = TypeSuffix$0(state) || TypeSuffix$1(state) || TypeSuffix$2(state);
17471
17599
  if (state.events)
17472
17600
  state.events.exit?.("TypeSuffix", state, result, eventData);
17473
17601
  return result;
@@ -19872,15 +20000,49 @@ ${input.slice(result.pos)}
19872
20000
  return post;
19873
20001
  };
19874
20002
  function expressionizeIteration(exp) {
20003
+ const i = exp.children.indexOf(exp.block);
20004
+ if (exp.subtype === "DoStatement") {
20005
+ insertReturn(exp.block);
20006
+ exp.children.splice(i, 1, ...module.wrapIIFE(exp.children));
20007
+ return;
20008
+ }
19875
20009
  const resultsRef = {
19876
20010
  type: "Ref",
19877
20011
  base: "results",
19878
20012
  id: "results"
19879
20013
  };
19880
20014
  insertPush(exp.block, resultsRef);
19881
- exp.children = ["(()=>{const ", resultsRef, "=[];", ...exp.children, "; return ", resultsRef, "})()"];
20015
+ exp.children.splice(i, 1, module.wrapIIFE(
20016
+ ["const ", resultsRef, "=[];", ...exp.children, "; return ", resultsRef]
20017
+ ));
19882
20018
  }
20019
+ module.hasAwait = (exp) => {
20020
+ return gatherRecursiveWithinFunction(exp, ({ type }) => type === "Await").length > 0;
20021
+ };
20022
+ module.wrapIIFE = (exp) => {
20023
+ let prefix, suffix;
20024
+ if (module.hasAwait(exp)) {
20025
+ prefix = "(await (async ()=>{";
20026
+ suffix = "})())";
20027
+ } else {
20028
+ prefix = "(()=>{";
20029
+ suffix = "})()";
20030
+ }
20031
+ if (Array.isArray(exp)) {
20032
+ return [prefix, ...exp, suffix];
20033
+ } else {
20034
+ return [prefix, exp, suffix];
20035
+ }
20036
+ };
19883
20037
  function wrapIterationReturningResults(statement, outerRef) {
20038
+ if (statement.type === "DoStatement") {
20039
+ if (outerRef) {
20040
+ insertPush(statement.block, outerRef);
20041
+ } else {
20042
+ insertReturn(statement.block);
20043
+ }
20044
+ return;
20045
+ }
19884
20046
  const resultsRef = {
19885
20047
  type: "Ref",
19886
20048
  base: "results",
@@ -19903,7 +20065,12 @@ ${input.slice(result.pos)}
19903
20065
  return;
19904
20066
  switch (node.type) {
19905
20067
  case "BlockStatement":
19906
- insertPush(node.expressions[node.expressions.length - 1], ref);
20068
+ if (node.expressions.length) {
20069
+ const last = node.expressions[node.expressions.length - 1];
20070
+ insertPush(last, ref);
20071
+ } else {
20072
+ node.expressions.push([ref, ".push(void 0);"]);
20073
+ }
19907
20074
  return;
19908
20075
  case "CaseBlock":
19909
20076
  node.clauses.forEach((clause) => {
@@ -19936,6 +20103,7 @@ ${input.slice(result.pos)}
19936
20103
  return;
19937
20104
  case "ForStatement":
19938
20105
  case "IterationStatement":
20106
+ case "DoStatement":
19939
20107
  wrapIterationReturningResults(exp, ref);
19940
20108
  return;
19941
20109
  case "BlockStatement":
@@ -19955,9 +20123,7 @@ ${input.slice(result.pos)}
19955
20123
  insertPush(exp.children[2], ref);
19956
20124
  return;
19957
20125
  case "TryStatement":
19958
- insertPush(exp.children[1], ref);
19959
- if (exp.children[2])
19960
- insertPush(exp.children[2][2], ref);
20126
+ exp.blocks.forEach((block) => insertPush(block, ref));
19961
20127
  return;
19962
20128
  }
19963
20129
  node.splice(1, 0, ref, ".push(");
@@ -19993,7 +20159,14 @@ ${input.slice(result.pos)}
19993
20159
  return;
19994
20160
  switch (node.type) {
19995
20161
  case "BlockStatement":
19996
- insertReturn(node.expressions[node.expressions.length - 1]);
20162
+ if (node.expressions.length) {
20163
+ const last = node.expressions[node.expressions.length - 1];
20164
+ insertReturn(last);
20165
+ } else {
20166
+ if (node.parent.type === "CatchClause") {
20167
+ node.expressions.push(["return"]);
20168
+ }
20169
+ }
19997
20170
  return;
19998
20171
  case "WhenClause":
19999
20172
  node.children.splice(node.children.indexOf(node.break), 1);
@@ -20026,6 +20199,7 @@ ${input.slice(result.pos)}
20026
20199
  return;
20027
20200
  case "ForStatement":
20028
20201
  case "IterationStatement":
20202
+ case "DoStatement":
20029
20203
  wrapIterationReturningResults(exp);
20030
20204
  return;
20031
20205
  case "BlockStatement":
@@ -20045,9 +20219,7 @@ ${input.slice(result.pos)}
20045
20219
  insertSwitchReturns(exp);
20046
20220
  return;
20047
20221
  case "TryStatement":
20048
- insertReturn(exp.children[1]);
20049
- if (exp.children[2])
20050
- insertReturn(exp.children[2][3]);
20222
+ exp.blocks.forEach((block) => insertReturn(block));
20051
20223
  return;
20052
20224
  }
20053
20225
  if (node[node.length - 1]?.type === "SemicolonDelimiter")
@@ -20223,10 +20395,12 @@ ${input.slice(result.pos)}
20223
20395
  if (Array.isArray(target)) {
20224
20396
  if (target.length === 1) {
20225
20397
  return module.skipIfOnlyWS(target[0]);
20398
+ } else if (target.every((e) => module.skipIfOnlyWS(e) === void 0)) {
20399
+ return void 0;
20226
20400
  }
20227
20401
  return target;
20228
20402
  }
20229
- if (target.token && target.token.trim() === "") {
20403
+ if (target.token != null && target.token.trim() === "") {
20230
20404
  return void 0;
20231
20405
  }
20232
20406
  return target;
@@ -20471,12 +20645,14 @@ ${input.slice(result.pos)}
20471
20645
  return;
20472
20646
  if (typeof node !== "object")
20473
20647
  return;
20474
- node.parent = parent;
20475
20648
  if (Array.isArray(node)) {
20476
20649
  for (const child of node) {
20477
- addParentPointers(child, node);
20650
+ addParentPointers(child, parent);
20478
20651
  }
20479
- } else if (node.children) {
20652
+ return;
20653
+ }
20654
+ node.parent = parent;
20655
+ if (node.children) {
20480
20656
  for (const child of node.children) {
20481
20657
  addParentPointers(child, node);
20482
20658
  }
@@ -20761,8 +20937,9 @@ ${input.slice(result.pos)}
20761
20937
  module.attachPostfixStatementAsExpression = function(exp, post) {
20762
20938
  let clause;
20763
20939
  switch (post[1].type) {
20764
- case "IterationStatement":
20765
20940
  case "ForStatement":
20941
+ case "IterationStatement":
20942
+ case "DoStatement":
20766
20943
  clause = module.addPostfixStatement(exp, ...post);
20767
20944
  return {
20768
20945
  type: "IterationExpression",
@@ -20967,6 +21144,37 @@ ${input.slice(result.pos)}
20967
21144
  return pattern;
20968
21145
  }
20969
21146
  }
21147
+ function aggregateDuplicateBindings(bindings) {
21148
+ const props2 = gatherRecursiveAll(bindings, (n) => n.type === "BindingMatchProperty");
21149
+ const declarations = [];
21150
+ const propsGroupedByName = /* @__PURE__ */ new Map();
21151
+ for (const p of props2) {
21152
+ const { name } = p;
21153
+ const key = name.name;
21154
+ if (propsGroupedByName.has(key)) {
21155
+ propsGroupedByName.get(key).push(p);
21156
+ } else {
21157
+ propsGroupedByName.set(key, [p]);
21158
+ }
21159
+ }
21160
+ propsGroupedByName.forEach((shared, key) => {
21161
+ if (shared.length === 1)
21162
+ return;
21163
+ const refs = shared.map((p) => {
21164
+ const ref = {
21165
+ type: "Ref",
21166
+ base: key,
21167
+ id: key
21168
+ };
21169
+ p.children.push(": ", ref);
21170
+ return ref;
21171
+ });
21172
+ declarations.push(["const ", key, " = [", ...refs.map((r, i) => {
21173
+ return i === 0 ? r : [", ", r];
21174
+ }), "]"]);
21175
+ });
21176
+ return declarations;
21177
+ }
20970
21178
  function processPatternMatching(statements) {
20971
21179
  gatherRecursiveAll(statements, (n) => n.type === "SwitchStatement" || n.type === "SwitchExpression").forEach((s) => {
20972
21180
  const { caseBlock } = s;
@@ -21033,10 +21241,13 @@ ${input.slice(result.pos)}
21033
21241
  if (pattern.properties?.length === 0)
21034
21242
  break;
21035
21243
  let [splices, thisAssignments] = gatherBindingCode(pattern);
21244
+ const patternBindings = nonMatcherBindings(pattern);
21036
21245
  splices = splices.map((s2) => [", ", nonMatcherBindings(s2)]);
21037
21246
  thisAssignments = thisAssignments.map((a) => [indent, a, ";\n"]);
21038
- prefix.push([indent, "const ", nonMatcherBindings(pattern), " = ", ref, splices, ";\n"]);
21247
+ const duplicateDeclarations = aggregateDuplicateBindings([patternBindings, splices]);
21248
+ prefix.push([indent, "const ", patternBindings, " = ", ref, splices, ";\n"]);
21039
21249
  prefix.push(...thisAssignments);
21250
+ prefix.push(...duplicateDeclarations.map((d) => [indent, d, ";\n"]));
21040
21251
  break;
21041
21252
  }
21042
21253
  }
@@ -21059,19 +21270,19 @@ ${input.slice(result.pos)}
21059
21270
  });
21060
21271
  if (module.config.implicitReturns && s.type === "SwitchExpression") {
21061
21272
  insertReturn(root[0]);
21062
- root.unshift("(()=>{");
21063
- root.push("})()");
21273
+ root.splice(0, 1, module.wrapIIFE(root[0]));
21064
21274
  }
21065
21275
  s.type = "PatternMatchingStatement";
21066
21276
  s.children = [root];
21277
+ addParentPointers(s, s.parent);
21067
21278
  });
21068
21279
  }
21069
21280
  function processPipelineExpressions(statements) {
21070
21281
  gatherRecursiveAll(statements, (n) => n.type === "PipelineExpression").forEach((s) => {
21071
- const [, body] = s.children;
21072
- let [arg] = s.children;
21282
+ const [ws, , body] = s.children;
21283
+ let [, arg] = s.children;
21073
21284
  let i = 0, l = body.length;
21074
- const children = [];
21285
+ const children = [ws];
21075
21286
  for (i = 0; i < l; i++) {
21076
21287
  const step = body[i];
21077
21288
  const [leadingComment, pipe, trailingComment, expr] = step;
@@ -21096,7 +21307,17 @@ ${input.slice(result.pos)}
21096
21307
  returns ? arg : null
21097
21308
  );
21098
21309
  if (result.type === "ReturnStatement") {
21310
+ if (i < l - 1) {
21311
+ result.children.push({
21312
+ type: "Error",
21313
+ message: "Can't continue a pipeline after returning"
21314
+ });
21315
+ }
21099
21316
  arg = result;
21317
+ if (children[children.length - 1] === ",") {
21318
+ children.pop();
21319
+ children.push(";");
21320
+ }
21100
21321
  break;
21101
21322
  }
21102
21323
  if (returning) {
@@ -21108,6 +21329,7 @@ ${input.slice(result.pos)}
21108
21329
  }
21109
21330
  children.push(arg);
21110
21331
  s.children = children;
21332
+ addParentPointers(s, s.parent);
21111
21333
  });
21112
21334
  }
21113
21335
  module.processProgram = function(statements) {
@@ -21527,6 +21749,36 @@ ${input.slice(result.pos)}
21527
21749
  return result;
21528
21750
  }
21529
21751
  }
21752
+ var NotDedented$0 = $TS($S($E($C(Samedent, IndentedFurther)), $E(_)), function($skip, $loc, $0, $1, $2) {
21753
+ const ws = [];
21754
+ if ($1)
21755
+ ws.push(...$1);
21756
+ if ($2)
21757
+ ws.push(...$2);
21758
+ return ws.flat(Infinity).filter(Boolean);
21759
+ });
21760
+ function NotDedented(state) {
21761
+ let eventData;
21762
+ if (state.events) {
21763
+ const result = state.events.enter?.("NotDedented", state);
21764
+ if (result) {
21765
+ if (result.cache)
21766
+ return result.cache;
21767
+ eventData = result.data;
21768
+ }
21769
+ }
21770
+ if (state.tokenize) {
21771
+ const result = $TOKEN("NotDedented", state, NotDedented$0(state));
21772
+ if (state.events)
21773
+ state.events.exit?.("NotDedented", state, result, eventData);
21774
+ return result;
21775
+ } else {
21776
+ const result = NotDedented$0(state);
21777
+ if (state.events)
21778
+ state.events.exit?.("NotDedented", state, result, eventData);
21779
+ return result;
21780
+ }
21781
+ }
21530
21782
  var PushIndent$0 = $Y($S(EOS, TrackIndented));
21531
21783
  function PushIndent(state) {
21532
21784
  let eventData;
@@ -22045,7 +22297,7 @@ var parse;
22045
22297
  var uncacheable;
22046
22298
  ({ parse } = import_parser.default);
22047
22299
  ({ SourceMap: SourceMap2, base64Encode: base64Encode2 } = util_exports);
22048
- uncacheable = /* @__PURE__ */ new Set(["ActualAssignment", "AllowAll", "AllowIndentedApplication", "AllowTrailingMemberProperty", "AllowedTrailingMemberExpressions", "ApplicationStart", "Arguments", "ArgumentsWithTrailingMemberExpressions", "ArrowFunction", "ArrowFunctionTail", "AssignmentExpression", "AssignmentExpressionTail", "BinaryOpExpression", "BinaryOpRHS", "BracedBlock", "BracedObjectLiteralContent", "BracedOrEmptyBlock", "CallExpression", "CallExpressionRest", "CoffeeCommentEnabled", "CommaDelimiter", "ConditionalExpression", "Declaration", "Debugger", "ElseClause", "Expression", "ExpressionStatement", "ExpressionWithIndentedApplicationForbidden", "ExtendedExpression", "FatArrowBody", "ForbidIndentedApplication", "ForbidTrailingMemberProperty", "FunctionDeclaration", "FunctionExpression", "HoistableDeclaration", "ImplicitArguments", "ImplicitInlineObjectPropertyDelimiter", "ImplicitNestedBlock", "IndentedApplicationAllowed", "IndentedFurther", "IndentedJSXChildExpression", "InlineObjectLiteral", "InsertIndent", "JSXChild", "JSXChildren", "JSXElement", "JSXFragment", "JSXImplicitFragment", "JSXMixedChildren", "JSXNested", "JSXNestedChildren", "JSXOptionalClosingElement", "JSXOptionalClosingFragment", "JSXTag", "LeftHandSideExpression", "MemberExpression", "MemberExpressionRest", "Nested", "NestedBindingElement", "NestedBindingElements", "NestedBlockExpression", "NestedBlockExpression", "NestedBlockStatement", "NestedBlockStatements", "NestedClassSignatureElement", "NestedClassSignatureElements", "NestedDeclareElement", "NestedDeclareElements", "NestedElement", "NestedElementList", "NestedImplicitObjectLiteral", "NestedImplicitPropertyDefinition", "NestedImplicitPropertyDefinitions", "NestedInterfaceProperty", "NestedJSXChildExpression", "NestedModuleItem", "NestedModuleItems", "NestedObject", "NestedPropertyDefinitions", "NonSingleBracedBlock", "ObjectLiteral", "PopIndent", "PopJSXStack", "PostfixedExpression", "PostfixedStatement", "PrimaryExpression", "PushIndent", "PushJSXOpeningElement", "PushJSXOpeningFragment", "RestoreAll", "RestoreIndentedApplication", "RestoreTrailingMemberProperty", "RHS", "Samedent", "ShortCircuitExpression", "SingleLineAssignmentExpression", "SingleLineComment", "SingleLineStatements", "SnugNamedProperty", "Statement", "StatementListItem", "SuffixedExpression", "SuffixedStatement", "ThinArrowFunction", "TrackIndented", "TrailingMemberExpressions", "TrailingMemberPropertyAllowed", "TypedJSXElement", "TypedJSXFragment", "UnaryExpression", "UpdateExpression"]);
22300
+ uncacheable = /* @__PURE__ */ new Set(["ActualAssignment", "AllowAll", "AllowIndentedApplication", "AllowTrailingMemberProperty", "AllowedTrailingMemberExpressions", "ApplicationStart", "Arguments", "ArgumentsWithTrailingMemberExpressions", "ArrowFunction", "ArrowFunctionTail", "AssignmentExpression", "AssignmentExpressionTail", "BinaryOpExpression", "BinaryOpRHS", "BracedBlock", "BracedObjectLiteralContent", "BracedOrEmptyBlock", "CallExpression", "CallExpressionRest", "CoffeeCommentEnabled", "CommaDelimiter", "ConditionalExpression", "Declaration", "Debugger", "ElementListWithIndentedApplicationForbidden", "ElseClause", "Expression", "ExpressionStatement", "ExpressionWithIndentedApplicationForbidden", "ExtendedExpression", "FatArrowBody", "ForbidIndentedApplication", "ForbidTrailingMemberProperty", "FunctionDeclaration", "FunctionExpression", "HoistableDeclaration", "ImplicitArguments", "ImplicitInlineObjectPropertyDelimiter", "ImplicitNestedBlock", "IndentedApplicationAllowed", "IndentedFurther", "IndentedJSXChildExpression", "InlineObjectLiteral", "InsertIndent", "JSXChild", "JSXChildren", "JSXElement", "JSXFragment", "JSXImplicitFragment", "JSXMixedChildren", "JSXNested", "JSXNestedChildren", "JSXOptionalClosingElement", "JSXOptionalClosingFragment", "JSXTag", "LeftHandSideExpression", "MemberExpression", "MemberExpressionRest", "Nested", "NestedBindingElement", "NestedBindingElements", "NestedBlockExpression", "NestedBlockExpression", "NestedBlockStatement", "NestedBlockStatements", "NestedClassSignatureElement", "NestedClassSignatureElements", "NestedDeclareElement", "NestedDeclareElements", "NestedElement", "NestedElementList", "NestedImplicitObjectLiteral", "NestedImplicitPropertyDefinition", "NestedImplicitPropertyDefinitions", "NestedInterfaceProperty", "NestedJSXChildExpression", "NestedModuleItem", "NestedModuleItems", "NestedObject", "NestedPropertyDefinitions", "NonSingleBracedBlock", "NotDedented", "ObjectLiteral", "PopIndent", "PopJSXStack", "PostfixedExpression", "PostfixedStatement", "PrimaryExpression", "PushIndent", "PushJSXOpeningElement", "PushJSXOpeningFragment", "RestoreAll", "RestoreIndentedApplication", "RestoreTrailingMemberProperty", "RHS", "Samedent", "ShortCircuitExpression", "SingleLineAssignmentExpression", "SingleLineComment", "SingleLineStatements", "SnugNamedProperty", "Statement", "StatementListItem", "SuffixedExpression", "SuffixedStatement", "ThinArrowFunction", "TrackIndented", "TrailingMemberExpressions", "TrailingMemberPropertyAllowed", "TypedJSXElement", "TypedJSXFragment", "UnaryExpression", "UpdateExpression"]);
22049
22301
  var compile = function(src, options) {
22050
22302
  var ast, code, events, filename, ref, result, sm, srcMapJSON;
22051
22303
  if (!options) {