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