@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.js CHANGED
@@ -599,6 +599,7 @@ ${input.slice(result.pos)}
599
599
  NestedElementList,
600
600
  NestedElement,
601
601
  ArrayElementDelimiter,
602
+ ElementListWithIndentedApplicationForbidden,
602
603
  ElementList,
603
604
  ElementListRest,
604
605
  ArrayElementExpression,
@@ -641,6 +642,7 @@ ${input.slice(result.pos)}
641
642
  StatementListItem,
642
643
  PostfixedStatement,
643
644
  PostfixedExpression,
645
+ NonPipelinePostfixedExpression,
644
646
  PostfixStatement,
645
647
  Statement,
646
648
  EmptyStatement,
@@ -664,6 +666,7 @@ ${input.slice(result.pos)}
664
666
  LoopStatement,
665
667
  LoopClause,
666
668
  DoWhileStatement,
669
+ DoStatement,
667
670
  WhileStatement,
668
671
  WhileClause,
669
672
  ForStatement,
@@ -1037,6 +1040,7 @@ ${input.slice(result.pos)}
1037
1040
  TrackIndented,
1038
1041
  Samedent,
1039
1042
  IndentedFurther,
1043
+ NotDedented,
1040
1044
  PushIndent,
1041
1045
  PopIndent,
1042
1046
  Nested
@@ -1965,7 +1969,7 @@ ${input.slice(result.pos)}
1965
1969
  var rhs = $2;
1966
1970
  return [[], op, [], rhs];
1967
1971
  });
1968
- var BinaryOpRHS$1 = $S(__, BinaryOp, $C(_, $S(EOS, __)), RHS);
1972
+ var BinaryOpRHS$1 = $S(NotDedented, BinaryOp, $C(_, $S(EOS, __)), RHS);
1969
1973
  function BinaryOpRHS(state) {
1970
1974
  let eventData;
1971
1975
  if (state.events) {
@@ -2447,7 +2451,7 @@ ${input.slice(result.pos)}
2447
2451
  return result;
2448
2452
  }
2449
2453
  }
2450
- var FatArrowBody$0 = $T($S($N(EOS), PostfixedExpression, $N(SemicolonDelimiter)), function(value) {
2454
+ var FatArrowBody$0 = $T($S($N(EOS), NonPipelinePostfixedExpression, $N(SemicolonDelimiter)), function(value) {
2451
2455
  var exp = value[1];
2452
2456
  return exp;
2453
2457
  });
@@ -2578,12 +2582,13 @@ ${input.slice(result.pos)}
2578
2582
  return result;
2579
2583
  }
2580
2584
  }
2581
- var PipelineExpression$0 = $TS($S(PipelineHeadItem, $P($S(__, Pipe, __, PipelineTailItem))), function($skip, $loc, $0, $1, $2) {
2582
- var head = $1;
2583
- var body = $2;
2585
+ var PipelineExpression$0 = $TS($S($E(_), PipelineHeadItem, $P($S(NotDedented, Pipe, __, PipelineTailItem))), function($skip, $loc, $0, $1, $2, $3) {
2586
+ var ws = $1;
2587
+ var head = $2;
2588
+ var body = $3;
2584
2589
  return {
2585
2590
  type: "PipelineExpression",
2586
- children: [head, body]
2591
+ children: [ws, head, body]
2587
2592
  };
2588
2593
  });
2589
2594
  function PipelineExpression(state) {
@@ -5479,9 +5484,13 @@ ${input.slice(result.pos)}
5479
5484
  };
5480
5485
  }
5481
5486
  const { ref } = rhs;
5487
+ const children = [ref, " => ", prefix, rhs];
5488
+ if (module2.hasAwait(rhs)) {
5489
+ children.unshift("async ");
5490
+ }
5482
5491
  return {
5483
5492
  type: "ArrowFunction",
5484
- children: [ref, " => ", prefix, rhs],
5493
+ children,
5485
5494
  ampersandBlock: true
5486
5495
  };
5487
5496
  });
@@ -6514,7 +6523,7 @@ ${input.slice(result.pos)}
6514
6523
  var ArrayLiteral$0 = $T($S(ArrayBindingPattern, UpcomingAssignment), function(value) {
6515
6524
  return value[0];
6516
6525
  });
6517
- var ArrayLiteral$1 = $TS($S(OpenBracket, AllowAll, $E($S(ArrayLiteralContent, __, CloseBracket)), RestoreIndentedApplication, RestoreAll), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
6526
+ var ArrayLiteral$1 = $TS($S(OpenBracket, AllowAll, $E($S(ArrayLiteralContent, __, CloseBracket)), RestoreAll), function($skip, $loc, $0, $1, $2, $3, $4) {
6518
6527
  var open = $1;
6519
6528
  if (!$3)
6520
6529
  return $skip;
@@ -6651,7 +6660,7 @@ ${input.slice(result.pos)}
6651
6660
  var ArrayLiteralContent$0 = RangeExpression;
6652
6661
  var ArrayLiteralContent$1 = $S(NestedImplicitObjectLiteral, $Q($S(__, Comma, NestedImplicitObjectLiteral)));
6653
6662
  var ArrayLiteralContent$2 = NestedElementList;
6654
- var ArrayLiteralContent$3 = $TS($S(ElementList, InsertComma, $E(NestedElementList)), function($skip, $loc, $0, $1, $2, $3) {
6663
+ var ArrayLiteralContent$3 = $TS($S(ElementListWithIndentedApplicationForbidden, InsertComma, $E(NestedElementList)), function($skip, $loc, $0, $1, $2, $3) {
6655
6664
  var list = $1;
6656
6665
  var comma = $2;
6657
6666
  var nested = $3;
@@ -6780,6 +6789,33 @@ ${input.slice(result.pos)}
6780
6789
  return result;
6781
6790
  }
6782
6791
  }
6792
+ var ElementListWithIndentedApplicationForbidden$0 = $TS($S(ForbidIndentedApplication, $E(ElementList), RestoreIndentedApplication), function($skip, $loc, $0, $1, $2, $3) {
6793
+ if ($2)
6794
+ return $2;
6795
+ return $skip;
6796
+ });
6797
+ function ElementListWithIndentedApplicationForbidden(state) {
6798
+ let eventData;
6799
+ if (state.events) {
6800
+ const result = state.events.enter?.("ElementListWithIndentedApplicationForbidden", state);
6801
+ if (result) {
6802
+ if (result.cache)
6803
+ return result.cache;
6804
+ eventData = result.data;
6805
+ }
6806
+ }
6807
+ if (state.tokenize) {
6808
+ const result = $TOKEN("ElementListWithIndentedApplicationForbidden", state, ElementListWithIndentedApplicationForbidden$0(state));
6809
+ if (state.events)
6810
+ state.events.exit?.("ElementListWithIndentedApplicationForbidden", state, result, eventData);
6811
+ return result;
6812
+ } else {
6813
+ const result = ElementListWithIndentedApplicationForbidden$0(state);
6814
+ if (state.events)
6815
+ state.events.exit?.("ElementListWithIndentedApplicationForbidden", state, result, eventData);
6816
+ return result;
6817
+ }
6818
+ }
6783
6819
  var ElementList$0 = $TS($S(ArrayElementExpression, $Q(ElementListRest)), function($skip, $loc, $0, $1, $2) {
6784
6820
  var first = $1;
6785
6821
  var rest = $2;
@@ -8364,6 +8400,35 @@ ${input.slice(result.pos)}
8364
8400
  return result;
8365
8401
  }
8366
8402
  }
8403
+ var NonPipelinePostfixedExpression$0 = $TS($S(NonPipelineExtendedExpression, $E($S($Q(TrailingComment), PostfixStatement))), function($skip, $loc, $0, $1, $2) {
8404
+ var expression = $1;
8405
+ var post = $2;
8406
+ if (post)
8407
+ return module2.attachPostfixStatementAsExpression(expression, post);
8408
+ return expression;
8409
+ });
8410
+ function NonPipelinePostfixedExpression(state) {
8411
+ let eventData;
8412
+ if (state.events) {
8413
+ const result = state.events.enter?.("NonPipelinePostfixedExpression", state);
8414
+ if (result) {
8415
+ if (result.cache)
8416
+ return result.cache;
8417
+ eventData = result.data;
8418
+ }
8419
+ }
8420
+ if (state.tokenize) {
8421
+ const result = $TOKEN("NonPipelinePostfixedExpression", state, NonPipelinePostfixedExpression$0(state));
8422
+ if (state.events)
8423
+ state.events.exit?.("NonPipelinePostfixedExpression", state, result, eventData);
8424
+ return result;
8425
+ } else {
8426
+ const result = NonPipelinePostfixedExpression$0(state);
8427
+ if (state.events)
8428
+ state.events.exit?.("NonPipelinePostfixedExpression", state, result, eventData);
8429
+ return result;
8430
+ }
8431
+ }
8367
8432
  var PostfixStatement$0 = ForClause;
8368
8433
  var PostfixStatement$1 = IfClause;
8369
8434
  var PostfixStatement$2 = LoopClause;
@@ -8900,8 +8965,11 @@ ${input.slice(result.pos)}
8900
8965
  var IterationStatement$1 = $T($S($N(CoffeeDoEnabled), DoWhileStatement), function(value) {
8901
8966
  return value[1];
8902
8967
  });
8903
- var IterationStatement$2 = WhileStatement;
8904
- var IterationStatement$3 = ForStatement;
8968
+ var IterationStatement$2 = $T($S($N(CoffeeDoEnabled), DoStatement), function(value) {
8969
+ return value[1];
8970
+ });
8971
+ var IterationStatement$3 = WhileStatement;
8972
+ var IterationStatement$4 = ForStatement;
8905
8973
  function IterationStatement(state) {
8906
8974
  let eventData;
8907
8975
  if (state.events) {
@@ -8913,12 +8981,12 @@ ${input.slice(result.pos)}
8913
8981
  }
8914
8982
  }
8915
8983
  if (state.tokenize) {
8916
- const result = $TOKEN("IterationStatement", state, IterationStatement$0(state) || IterationStatement$1(state) || IterationStatement$2(state) || IterationStatement$3(state));
8984
+ const result = $TOKEN("IterationStatement", state, IterationStatement$0(state) || IterationStatement$1(state) || IterationStatement$2(state) || IterationStatement$3(state) || IterationStatement$4(state));
8917
8985
  if (state.events)
8918
8986
  state.events.exit?.("IterationStatement", state, result, eventData);
8919
8987
  return result;
8920
8988
  } else {
8921
- const result = IterationStatement$0(state) || IterationStatement$1(state) || IterationStatement$2(state) || IterationStatement$3(state);
8989
+ const result = IterationStatement$0(state) || IterationStatement$1(state) || IterationStatement$2(state) || IterationStatement$3(state) || IterationStatement$4(state);
8922
8990
  if (state.events)
8923
8991
  state.events.exit?.("IterationStatement", state, result, eventData);
8924
8992
  return result;
@@ -8927,6 +8995,7 @@ ${input.slice(result.pos)}
8927
8995
  var IterationExpression$0 = $TS($S(IterationStatement), function($skip, $loc, $0, $1) {
8928
8996
  return {
8929
8997
  type: "IterationExpression",
8998
+ subtype: $1.type,
8930
8999
  children: [$1],
8931
9000
  block: $1.block
8932
9001
  };
@@ -9035,6 +9104,37 @@ ${input.slice(result.pos)}
9035
9104
  return result;
9036
9105
  }
9037
9106
  }
9107
+ var DoStatement$0 = $TS($S(Do, NoPostfixBracedBlock), function($skip, $loc, $0, $1, $2) {
9108
+ var block = $2;
9109
+ block = module2.insertTrimmingSpace(block, "");
9110
+ return {
9111
+ type: "DoStatement",
9112
+ children: [block],
9113
+ block
9114
+ };
9115
+ });
9116
+ function DoStatement(state) {
9117
+ let eventData;
9118
+ if (state.events) {
9119
+ const result = state.events.enter?.("DoStatement", state);
9120
+ if (result) {
9121
+ if (result.cache)
9122
+ return result.cache;
9123
+ eventData = result.data;
9124
+ }
9125
+ }
9126
+ if (state.tokenize) {
9127
+ const result = $TOKEN("DoStatement", state, DoStatement$0(state));
9128
+ if (state.events)
9129
+ state.events.exit?.("DoStatement", state, result, eventData);
9130
+ return result;
9131
+ } else {
9132
+ const result = DoStatement$0(state);
9133
+ if (state.events)
9134
+ state.events.exit?.("DoStatement", state, result, eventData);
9135
+ return result;
9136
+ }
9137
+ }
9038
9138
  var WhileStatement$0 = $TS($S(WhileClause, Block), function($skip, $loc, $0, $1, $2) {
9039
9139
  var clause = $1;
9040
9140
  var block = $2;
@@ -9208,7 +9308,7 @@ ${input.slice(result.pos)}
9208
9308
  return result;
9209
9309
  }
9210
9310
  }
9211
- var WhenCondition$0 = $T($S(__, When, ExtendedExpression), function(value) {
9311
+ var WhenCondition$0 = $T($S(__, When, ExpressionWithIndentedApplicationForbidden), function(value) {
9212
9312
  var exp = value[2];
9213
9313
  return exp;
9214
9314
  });
@@ -9234,7 +9334,7 @@ ${input.slice(result.pos)}
9234
9334
  return result;
9235
9335
  }
9236
9336
  }
9237
- 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) {
9337
+ 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) {
9238
9338
  var open = $2;
9239
9339
  var declaration = $3;
9240
9340
  var index = $4;
@@ -9721,7 +9821,7 @@ ${input.slice(result.pos)}
9721
9821
  var e = $0;
9722
9822
  return {
9723
9823
  type: "SwitchExpression",
9724
- children: ["(()=>{", e.children, "})()"],
9824
+ children: module2.wrapIIFE(e.children),
9725
9825
  expression: e.expression,
9726
9826
  caseBlock: e.caseBlock
9727
9827
  };
@@ -9976,13 +10076,31 @@ ${input.slice(result.pos)}
9976
10076
  var c = $3;
9977
10077
  var f = $4;
9978
10078
  if (!c && !f) {
10079
+ const e = [];
10080
+ const emptyCatchBlock = {
10081
+ type: "BlockStatement",
10082
+ expressions: e,
10083
+ children: ["{", e, "}"],
10084
+ bare: false,
10085
+ empty: true
10086
+ };
10087
+ c = {
10088
+ type: "CatchClause",
10089
+ children: [" catch(e) ", emptyCatchBlock],
10090
+ block: emptyCatchBlock
10091
+ };
9979
10092
  return {
9980
10093
  type: "TryStatement",
9981
- children: [t, b, " catch(e) {}"]
10094
+ blocks: [b, emptyCatchBlock],
10095
+ children: [t, b, c]
9982
10096
  };
9983
10097
  }
10098
+ const blocks = [b];
10099
+ if (c)
10100
+ blocks.push(c.block);
9984
10101
  return {
9985
10102
  type: "TryStatement",
10103
+ blocks,
9986
10104
  children: [t, b, c, f]
9987
10105
  };
9988
10106
  });
@@ -10012,8 +10130,8 @@ ${input.slice(result.pos)}
10012
10130
  var t = $0;
10013
10131
  return {
10014
10132
  type: "TryExpression",
10015
- blocks: [t.children[1], t.children[2]?.[3]],
10016
- children: ["(()=>{", t, "})()"]
10133
+ blocks: t.blocks,
10134
+ children: module2.wrapIIFE(t)
10017
10135
  };
10018
10136
  });
10019
10137
  function TryExpression(state) {
@@ -10038,7 +10156,14 @@ ${input.slice(result.pos)}
10038
10156
  return result;
10039
10157
  }
10040
10158
  }
10041
- var CatchClause$0 = $S($C(Samedent, _), Catch, $E(CatchBind), $C(ThenClause, BracedOrEmptyBlock));
10159
+ var CatchClause$0 = $TS($S($C(Samedent, _), Catch, $E(CatchBind), $C(ThenClause, BracedOrEmptyBlock)), function($skip, $loc, $0, $1, $2, $3, $4) {
10160
+ var block = $4;
10161
+ return {
10162
+ type: "CatchClause",
10163
+ children: $0,
10164
+ block
10165
+ };
10166
+ });
10042
10167
  function CatchClause(state) {
10043
10168
  let eventData;
10044
10169
  if (state.events) {
@@ -10702,7 +10827,7 @@ ${input.slice(result.pos)}
10702
10827
  var DebuggerExpression$0 = $TS($S(Debugger), function($skip, $loc, $0, $1) {
10703
10828
  return {
10704
10829
  type: "DebuggerExpression",
10705
- children: ["(()=>{", $1, "})()"]
10830
+ children: module2.wrapIIFE($1)
10706
10831
  };
10707
10832
  });
10708
10833
  function DebuggerExpression(state) {
@@ -10730,7 +10855,7 @@ ${input.slice(result.pos)}
10730
10855
  var ThrowExpression$0 = $TS($S(Throw, ExtendedExpression), function($skip, $loc, $0, $1, $2) {
10731
10856
  return {
10732
10857
  type: "ThrowExpression",
10733
- children: ["(()=>{", $0, "})()"]
10858
+ children: module2.wrapIIFE($0)
10734
10859
  };
10735
10860
  });
10736
10861
  function ThrowExpression(state) {
@@ -13220,7 +13345,7 @@ ${input.slice(result.pos)}
13220
13345
  }
13221
13346
  }
13222
13347
  var StatementDelimiter$0 = SemicolonDelimiter;
13223
- 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);
13348
+ 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);
13224
13349
  var StatementDelimiter$2 = $Y(EOS);
13225
13350
  function StatementDelimiter(state) {
13226
13351
  let eventData;
@@ -13471,7 +13596,7 @@ ${input.slice(result.pos)}
13471
13596
  }
13472
13597
  }
13473
13598
  var Await$0 = $TS($S($EXPECT($L104, fail, 'Await "await"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
13474
- return { $loc, token: $1 };
13599
+ return { $loc, token: $1, type: "Await" };
13475
13600
  });
13476
13601
  function Await(state) {
13477
13602
  let eventData;
@@ -17453,6 +17578,9 @@ ${input.slice(result.pos)}
17453
17578
  var TypeSuffix$1 = $T($S(QuestionMark, $E(_)), function(value) {
17454
17579
  return { "type": "TypeSuffix", "ts": true, "children": value };
17455
17580
  });
17581
+ var TypeSuffix$2 = $T($S(NonNullAssertion, $E(_), $E($S(Colon, Type))), function(value) {
17582
+ return { "type": "TypeSuffix", "ts": true, "children": value };
17583
+ });
17456
17584
  function TypeSuffix(state) {
17457
17585
  let eventData;
17458
17586
  if (state.events) {
@@ -17464,12 +17592,12 @@ ${input.slice(result.pos)}
17464
17592
  }
17465
17593
  }
17466
17594
  if (state.tokenize) {
17467
- const result = $TOKEN("TypeSuffix", state, TypeSuffix$0(state) || TypeSuffix$1(state));
17595
+ const result = $TOKEN("TypeSuffix", state, TypeSuffix$0(state) || TypeSuffix$1(state) || TypeSuffix$2(state));
17468
17596
  if (state.events)
17469
17597
  state.events.exit?.("TypeSuffix", state, result, eventData);
17470
17598
  return result;
17471
17599
  } else {
17472
- const result = TypeSuffix$0(state) || TypeSuffix$1(state);
17600
+ const result = TypeSuffix$0(state) || TypeSuffix$1(state) || TypeSuffix$2(state);
17473
17601
  if (state.events)
17474
17602
  state.events.exit?.("TypeSuffix", state, result, eventData);
17475
17603
  return result;
@@ -19874,15 +20002,49 @@ ${input.slice(result.pos)}
19874
20002
  return post;
19875
20003
  };
19876
20004
  function expressionizeIteration(exp) {
20005
+ const i = exp.children.indexOf(exp.block);
20006
+ if (exp.subtype === "DoStatement") {
20007
+ insertReturn(exp.block);
20008
+ exp.children.splice(i, 1, ...module2.wrapIIFE(exp.children));
20009
+ return;
20010
+ }
19877
20011
  const resultsRef = {
19878
20012
  type: "Ref",
19879
20013
  base: "results",
19880
20014
  id: "results"
19881
20015
  };
19882
20016
  insertPush(exp.block, resultsRef);
19883
- exp.children = ["(()=>{const ", resultsRef, "=[];", ...exp.children, "; return ", resultsRef, "})()"];
20017
+ exp.children.splice(i, 1, module2.wrapIIFE(
20018
+ ["const ", resultsRef, "=[];", ...exp.children, "; return ", resultsRef]
20019
+ ));
19884
20020
  }
20021
+ module2.hasAwait = (exp) => {
20022
+ return gatherRecursiveWithinFunction(exp, ({ type }) => type === "Await").length > 0;
20023
+ };
20024
+ module2.wrapIIFE = (exp) => {
20025
+ let prefix, suffix;
20026
+ if (module2.hasAwait(exp)) {
20027
+ prefix = "(await (async ()=>{";
20028
+ suffix = "})())";
20029
+ } else {
20030
+ prefix = "(()=>{";
20031
+ suffix = "})()";
20032
+ }
20033
+ if (Array.isArray(exp)) {
20034
+ return [prefix, ...exp, suffix];
20035
+ } else {
20036
+ return [prefix, exp, suffix];
20037
+ }
20038
+ };
19885
20039
  function wrapIterationReturningResults(statement, outerRef) {
20040
+ if (statement.type === "DoStatement") {
20041
+ if (outerRef) {
20042
+ insertPush(statement.block, outerRef);
20043
+ } else {
20044
+ insertReturn(statement.block);
20045
+ }
20046
+ return;
20047
+ }
19886
20048
  const resultsRef = {
19887
20049
  type: "Ref",
19888
20050
  base: "results",
@@ -19905,7 +20067,12 @@ ${input.slice(result.pos)}
19905
20067
  return;
19906
20068
  switch (node.type) {
19907
20069
  case "BlockStatement":
19908
- insertPush(node.expressions[node.expressions.length - 1], ref);
20070
+ if (node.expressions.length) {
20071
+ const last = node.expressions[node.expressions.length - 1];
20072
+ insertPush(last, ref);
20073
+ } else {
20074
+ node.expressions.push([ref, ".push(void 0);"]);
20075
+ }
19909
20076
  return;
19910
20077
  case "CaseBlock":
19911
20078
  node.clauses.forEach((clause) => {
@@ -19938,6 +20105,7 @@ ${input.slice(result.pos)}
19938
20105
  return;
19939
20106
  case "ForStatement":
19940
20107
  case "IterationStatement":
20108
+ case "DoStatement":
19941
20109
  wrapIterationReturningResults(exp, ref);
19942
20110
  return;
19943
20111
  case "BlockStatement":
@@ -19957,9 +20125,7 @@ ${input.slice(result.pos)}
19957
20125
  insertPush(exp.children[2], ref);
19958
20126
  return;
19959
20127
  case "TryStatement":
19960
- insertPush(exp.children[1], ref);
19961
- if (exp.children[2])
19962
- insertPush(exp.children[2][2], ref);
20128
+ exp.blocks.forEach((block) => insertPush(block, ref));
19963
20129
  return;
19964
20130
  }
19965
20131
  node.splice(1, 0, ref, ".push(");
@@ -19995,7 +20161,14 @@ ${input.slice(result.pos)}
19995
20161
  return;
19996
20162
  switch (node.type) {
19997
20163
  case "BlockStatement":
19998
- insertReturn(node.expressions[node.expressions.length - 1]);
20164
+ if (node.expressions.length) {
20165
+ const last = node.expressions[node.expressions.length - 1];
20166
+ insertReturn(last);
20167
+ } else {
20168
+ if (node.parent.type === "CatchClause") {
20169
+ node.expressions.push(["return"]);
20170
+ }
20171
+ }
19999
20172
  return;
20000
20173
  case "WhenClause":
20001
20174
  node.children.splice(node.children.indexOf(node.break), 1);
@@ -20028,6 +20201,7 @@ ${input.slice(result.pos)}
20028
20201
  return;
20029
20202
  case "ForStatement":
20030
20203
  case "IterationStatement":
20204
+ case "DoStatement":
20031
20205
  wrapIterationReturningResults(exp);
20032
20206
  return;
20033
20207
  case "BlockStatement":
@@ -20047,9 +20221,7 @@ ${input.slice(result.pos)}
20047
20221
  insertSwitchReturns(exp);
20048
20222
  return;
20049
20223
  case "TryStatement":
20050
- insertReturn(exp.children[1]);
20051
- if (exp.children[2])
20052
- insertReturn(exp.children[2][3]);
20224
+ exp.blocks.forEach((block) => insertReturn(block));
20053
20225
  return;
20054
20226
  }
20055
20227
  if (node[node.length - 1]?.type === "SemicolonDelimiter")
@@ -20225,10 +20397,12 @@ ${input.slice(result.pos)}
20225
20397
  if (Array.isArray(target)) {
20226
20398
  if (target.length === 1) {
20227
20399
  return module2.skipIfOnlyWS(target[0]);
20400
+ } else if (target.every((e) => module2.skipIfOnlyWS(e) === void 0)) {
20401
+ return void 0;
20228
20402
  }
20229
20403
  return target;
20230
20404
  }
20231
- if (target.token && target.token.trim() === "") {
20405
+ if (target.token != null && target.token.trim() === "") {
20232
20406
  return void 0;
20233
20407
  }
20234
20408
  return target;
@@ -20473,12 +20647,14 @@ ${input.slice(result.pos)}
20473
20647
  return;
20474
20648
  if (typeof node !== "object")
20475
20649
  return;
20476
- node.parent = parent;
20477
20650
  if (Array.isArray(node)) {
20478
20651
  for (const child of node) {
20479
- addParentPointers(child, node);
20652
+ addParentPointers(child, parent);
20480
20653
  }
20481
- } else if (node.children) {
20654
+ return;
20655
+ }
20656
+ node.parent = parent;
20657
+ if (node.children) {
20482
20658
  for (const child of node.children) {
20483
20659
  addParentPointers(child, node);
20484
20660
  }
@@ -20763,8 +20939,9 @@ ${input.slice(result.pos)}
20763
20939
  module2.attachPostfixStatementAsExpression = function(exp, post) {
20764
20940
  let clause;
20765
20941
  switch (post[1].type) {
20766
- case "IterationStatement":
20767
20942
  case "ForStatement":
20943
+ case "IterationStatement":
20944
+ case "DoStatement":
20768
20945
  clause = module2.addPostfixStatement(exp, ...post);
20769
20946
  return {
20770
20947
  type: "IterationExpression",
@@ -20969,6 +21146,37 @@ ${input.slice(result.pos)}
20969
21146
  return pattern;
20970
21147
  }
20971
21148
  }
21149
+ function aggregateDuplicateBindings(bindings) {
21150
+ const props2 = gatherRecursiveAll(bindings, (n) => n.type === "BindingMatchProperty");
21151
+ const declarations = [];
21152
+ const propsGroupedByName = /* @__PURE__ */ new Map();
21153
+ for (const p of props2) {
21154
+ const { name } = p;
21155
+ const key = name.name;
21156
+ if (propsGroupedByName.has(key)) {
21157
+ propsGroupedByName.get(key).push(p);
21158
+ } else {
21159
+ propsGroupedByName.set(key, [p]);
21160
+ }
21161
+ }
21162
+ propsGroupedByName.forEach((shared, key) => {
21163
+ if (shared.length === 1)
21164
+ return;
21165
+ const refs = shared.map((p) => {
21166
+ const ref = {
21167
+ type: "Ref",
21168
+ base: key,
21169
+ id: key
21170
+ };
21171
+ p.children.push(": ", ref);
21172
+ return ref;
21173
+ });
21174
+ declarations.push(["const ", key, " = [", ...refs.map((r, i) => {
21175
+ return i === 0 ? r : [", ", r];
21176
+ }), "]"]);
21177
+ });
21178
+ return declarations;
21179
+ }
20972
21180
  function processPatternMatching(statements) {
20973
21181
  gatherRecursiveAll(statements, (n) => n.type === "SwitchStatement" || n.type === "SwitchExpression").forEach((s) => {
20974
21182
  const { caseBlock } = s;
@@ -21035,10 +21243,13 @@ ${input.slice(result.pos)}
21035
21243
  if (pattern.properties?.length === 0)
21036
21244
  break;
21037
21245
  let [splices, thisAssignments] = gatherBindingCode(pattern);
21246
+ const patternBindings = nonMatcherBindings(pattern);
21038
21247
  splices = splices.map((s2) => [", ", nonMatcherBindings(s2)]);
21039
21248
  thisAssignments = thisAssignments.map((a) => [indent, a, ";\n"]);
21040
- prefix.push([indent, "const ", nonMatcherBindings(pattern), " = ", ref, splices, ";\n"]);
21249
+ const duplicateDeclarations = aggregateDuplicateBindings([patternBindings, splices]);
21250
+ prefix.push([indent, "const ", patternBindings, " = ", ref, splices, ";\n"]);
21041
21251
  prefix.push(...thisAssignments);
21252
+ prefix.push(...duplicateDeclarations.map((d) => [indent, d, ";\n"]));
21042
21253
  break;
21043
21254
  }
21044
21255
  }
@@ -21061,19 +21272,19 @@ ${input.slice(result.pos)}
21061
21272
  });
21062
21273
  if (module2.config.implicitReturns && s.type === "SwitchExpression") {
21063
21274
  insertReturn(root[0]);
21064
- root.unshift("(()=>{");
21065
- root.push("})()");
21275
+ root.splice(0, 1, module2.wrapIIFE(root[0]));
21066
21276
  }
21067
21277
  s.type = "PatternMatchingStatement";
21068
21278
  s.children = [root];
21279
+ addParentPointers(s, s.parent);
21069
21280
  });
21070
21281
  }
21071
21282
  function processPipelineExpressions(statements) {
21072
21283
  gatherRecursiveAll(statements, (n) => n.type === "PipelineExpression").forEach((s) => {
21073
- const [, body] = s.children;
21074
- let [arg] = s.children;
21284
+ const [ws, , body] = s.children;
21285
+ let [, arg] = s.children;
21075
21286
  let i = 0, l = body.length;
21076
- const children = [];
21287
+ const children = [ws];
21077
21288
  for (i = 0; i < l; i++) {
21078
21289
  const step = body[i];
21079
21290
  const [leadingComment, pipe, trailingComment, expr] = step;
@@ -21098,7 +21309,17 @@ ${input.slice(result.pos)}
21098
21309
  returns ? arg : null
21099
21310
  );
21100
21311
  if (result.type === "ReturnStatement") {
21312
+ if (i < l - 1) {
21313
+ result.children.push({
21314
+ type: "Error",
21315
+ message: "Can't continue a pipeline after returning"
21316
+ });
21317
+ }
21101
21318
  arg = result;
21319
+ if (children[children.length - 1] === ",") {
21320
+ children.pop();
21321
+ children.push(";");
21322
+ }
21102
21323
  break;
21103
21324
  }
21104
21325
  if (returning) {
@@ -21110,6 +21331,7 @@ ${input.slice(result.pos)}
21110
21331
  }
21111
21332
  children.push(arg);
21112
21333
  s.children = children;
21334
+ addParentPointers(s, s.parent);
21113
21335
  });
21114
21336
  }
21115
21337
  module2.processProgram = function(statements) {
@@ -21529,6 +21751,36 @@ ${input.slice(result.pos)}
21529
21751
  return result;
21530
21752
  }
21531
21753
  }
21754
+ var NotDedented$0 = $TS($S($E($C(Samedent, IndentedFurther)), $E(_)), function($skip, $loc, $0, $1, $2) {
21755
+ const ws = [];
21756
+ if ($1)
21757
+ ws.push(...$1);
21758
+ if ($2)
21759
+ ws.push(...$2);
21760
+ return ws.flat(Infinity).filter(Boolean);
21761
+ });
21762
+ function NotDedented(state) {
21763
+ let eventData;
21764
+ if (state.events) {
21765
+ const result = state.events.enter?.("NotDedented", state);
21766
+ if (result) {
21767
+ if (result.cache)
21768
+ return result.cache;
21769
+ eventData = result.data;
21770
+ }
21771
+ }
21772
+ if (state.tokenize) {
21773
+ const result = $TOKEN("NotDedented", state, NotDedented$0(state));
21774
+ if (state.events)
21775
+ state.events.exit?.("NotDedented", state, result, eventData);
21776
+ return result;
21777
+ } else {
21778
+ const result = NotDedented$0(state);
21779
+ if (state.events)
21780
+ state.events.exit?.("NotDedented", state, result, eventData);
21781
+ return result;
21782
+ }
21783
+ }
21532
21784
  var PushIndent$0 = $Y($S(EOS, TrackIndented));
21533
21785
  function PushIndent(state) {
21534
21786
  let eventData;
@@ -22057,7 +22309,7 @@ var parse;
22057
22309
  var uncacheable;
22058
22310
  ({ parse } = import_parser.default);
22059
22311
  ({ SourceMap: SourceMap2, base64Encode: base64Encode2 } = util_exports);
22060
- 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"]);
22312
+ 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"]);
22061
22313
  var compile = function(src, options) {
22062
22314
  var ast, code, events, filename, ref, result, sm, srcMapJSON;
22063
22315
  if (!options) {