@danielx/civet 0.5.72 → 0.5.74

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
@@ -494,6 +494,11 @@ ${input.slice(result.pos)}
494
494
  NestedClassElement,
495
495
  ClassElement,
496
496
  ClassElementDefinition,
497
+ ClassSignature,
498
+ ClassSignatureBody,
499
+ NestedClassSignatureElements,
500
+ NestedClassSignatureElement,
501
+ ClassSignatureElement,
497
502
  AccessModifier,
498
503
  FieldDefinition,
499
504
  ThisLiteral,
@@ -637,6 +642,7 @@ ${input.slice(result.pos)}
637
642
  StatementListItem,
638
643
  PostfixedStatement,
639
644
  PostfixedExpression,
645
+ NonPipelinePostfixedExpression,
640
646
  PostfixStatement,
641
647
  Statement,
642
648
  EmptyStatement,
@@ -660,6 +666,7 @@ ${input.slice(result.pos)}
660
666
  LoopStatement,
661
667
  LoopClause,
662
668
  DoWhileStatement,
669
+ DoStatement,
663
670
  WhileStatement,
664
671
  WhileClause,
665
672
  ForStatement,
@@ -842,6 +849,7 @@ ${input.slice(result.pos)}
842
849
  Import,
843
850
  In,
844
851
  LetOrConst,
852
+ LetOrConstOrVar,
845
853
  Loop,
846
854
  New,
847
855
  Not,
@@ -935,6 +943,8 @@ ${input.slice(result.pos)}
935
943
  InterfaceExtendsTarget,
936
944
  TypeKeyword,
937
945
  Interface,
946
+ Global,
947
+ Module,
938
948
  Namespace,
939
949
  InterfaceBlock,
940
950
  NestedInterfaceProperties,
@@ -942,9 +952,13 @@ ${input.slice(result.pos)}
942
952
  InterfaceProperty,
943
953
  BasicInterfaceProperty,
944
954
  InterfacePropertyDelimiter,
945
- NamespaceBlock,
946
- NestedTypeDeclarations,
947
- NestedTypeDeclaration,
955
+ ModuleBlock,
956
+ NestedModuleItems,
957
+ NestedModuleItem,
958
+ DeclareBlock,
959
+ NestedDeclareElements,
960
+ NestedDeclareElement,
961
+ DeclareElement,
948
962
  TypeIndexSignature,
949
963
  TypeIndex,
950
964
  TypeSuffix,
@@ -1026,6 +1040,7 @@ ${input.slice(result.pos)}
1026
1040
  TrackIndented,
1027
1041
  Samedent,
1028
1042
  IndentedFurther,
1043
+ NotDedented,
1029
1044
  PushIndent,
1030
1045
  PopIndent,
1031
1046
  Nested
@@ -1203,12 +1218,14 @@ ${input.slice(result.pos)}
1203
1218
  var $L170 = $L("-->");
1204
1219
  var $L171 = $L("type");
1205
1220
  var $L172 = $L("interface");
1206
- var $L173 = $L("namespace");
1207
- var $L174 = $L("asserts");
1208
- var $L175 = $L("keyof");
1209
- var $L176 = $L("infer");
1210
- var $L177 = $L("[]");
1211
- var $L178 = $L("civet");
1221
+ var $L173 = $L("global");
1222
+ var $L174 = $L("module");
1223
+ var $L175 = $L("namespace");
1224
+ var $L176 = $L("asserts");
1225
+ var $L177 = $L("keyof");
1226
+ var $L178 = $L("infer");
1227
+ var $L179 = $L("[]");
1228
+ var $L180 = $L("civet");
1212
1229
  var $R0 = $R(new RegExp("(as|for|while|until|of|satisfies|then|when|implements|xor|xnor)(?!\\p{ID_Continue}|[\\u200C\\u200D$])", "suy"));
1213
1230
  var $R1 = $R(new RegExp("[0-9]", "suy"));
1214
1231
  var $R2 = $R(new RegExp("[)}]", "suy"));
@@ -1952,7 +1969,7 @@ ${input.slice(result.pos)}
1952
1969
  var rhs = $2;
1953
1970
  return [[], op, [], rhs];
1954
1971
  });
1955
- var BinaryOpRHS$1 = $S(__, BinaryOp, $C(_, $S(EOS, __)), RHS);
1972
+ var BinaryOpRHS$1 = $S(NotDedented, BinaryOp, $C(_, $S(EOS, __)), RHS);
1956
1973
  function BinaryOpRHS(state) {
1957
1974
  let eventData;
1958
1975
  if (state.events) {
@@ -2434,7 +2451,7 @@ ${input.slice(result.pos)}
2434
2451
  return result;
2435
2452
  }
2436
2453
  }
2437
- 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) {
2438
2455
  var exp = value[1];
2439
2456
  return exp;
2440
2457
  });
@@ -2565,12 +2582,13 @@ ${input.slice(result.pos)}
2565
2582
  return result;
2566
2583
  }
2567
2584
  }
2568
- var PipelineExpression$0 = $TS($S(PipelineHeadItem, $P($S(__, Pipe, __, PipelineTailItem))), function($skip, $loc, $0, $1, $2) {
2569
- var head = $1;
2570
- 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;
2571
2589
  return {
2572
2590
  type: "PipelineExpression",
2573
- children: [head, body]
2591
+ children: [ws, head, body]
2574
2592
  };
2575
2593
  });
2576
2594
  function PipelineExpression(state) {
@@ -2738,9 +2756,7 @@ ${input.slice(result.pos)}
2738
2756
  return result;
2739
2757
  }
2740
2758
  }
2741
- var ClassExpression$0 = $TS($S($E(Decorators), $E($S(Abstract, __)), Class, $E(ClassBinding), $E(ClassHeritage), ClassBody), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
2742
- return $0;
2743
- });
2759
+ var ClassExpression$0 = $S($E(Decorators), $E($S(Abstract, __)), Class, $E(ClassBinding), $E(ClassHeritage), ClassBody);
2744
2760
  function ClassExpression(state) {
2745
2761
  let eventData;
2746
2762
  if (state.events) {
@@ -3136,6 +3152,128 @@ ${input.slice(result.pos)}
3136
3152
  return result;
3137
3153
  }
3138
3154
  }
3155
+ var ClassSignature$0 = $S($E(Decorators), $E($S(Abstract, __)), Class, $E(ClassBinding), $E(ClassHeritage), ClassSignatureBody);
3156
+ function ClassSignature(state) {
3157
+ let eventData;
3158
+ if (state.events) {
3159
+ const result = state.events.enter?.("ClassSignature", state);
3160
+ if (result) {
3161
+ if (result.cache)
3162
+ return result.cache;
3163
+ eventData = result.data;
3164
+ }
3165
+ }
3166
+ if (state.tokenize) {
3167
+ const result = $TOKEN("ClassSignature", state, ClassSignature$0(state));
3168
+ if (state.events)
3169
+ state.events.exit?.("ClassSignature", state, result, eventData);
3170
+ return result;
3171
+ } else {
3172
+ const result = ClassSignature$0(state);
3173
+ if (state.events)
3174
+ state.events.exit?.("ClassSignature", state, result, eventData);
3175
+ return result;
3176
+ }
3177
+ }
3178
+ var ClassSignatureBody$0 = $S(__, OpenBrace, $E(NestedClassSignatureElements), __, CloseBrace);
3179
+ var ClassSignatureBody$1 = $S(InsertOpenBrace, $E(NestedClassSignatureElements), InsertNewline, InsertIndent, InsertCloseBrace);
3180
+ function ClassSignatureBody(state) {
3181
+ let eventData;
3182
+ if (state.events) {
3183
+ const result = state.events.enter?.("ClassSignatureBody", state);
3184
+ if (result) {
3185
+ if (result.cache)
3186
+ return result.cache;
3187
+ eventData = result.data;
3188
+ }
3189
+ }
3190
+ if (state.tokenize) {
3191
+ const result = $TOKEN("ClassSignatureBody", state, ClassSignatureBody$0(state) || ClassSignatureBody$1(state));
3192
+ if (state.events)
3193
+ state.events.exit?.("ClassSignatureBody", state, result, eventData);
3194
+ return result;
3195
+ } else {
3196
+ const result = ClassSignatureBody$0(state) || ClassSignatureBody$1(state);
3197
+ if (state.events)
3198
+ state.events.exit?.("ClassSignatureBody", state, result, eventData);
3199
+ return result;
3200
+ }
3201
+ }
3202
+ var NestedClassSignatureElements$0 = $TS($S(PushIndent, $Q(NestedClassSignatureElement), PopIndent), function($skip, $loc, $0, $1, $2, $3) {
3203
+ var elements = $2;
3204
+ if (!elements.length)
3205
+ return $skip;
3206
+ return elements;
3207
+ });
3208
+ function NestedClassSignatureElements(state) {
3209
+ let eventData;
3210
+ if (state.events) {
3211
+ const result = state.events.enter?.("NestedClassSignatureElements", state);
3212
+ if (result) {
3213
+ if (result.cache)
3214
+ return result.cache;
3215
+ eventData = result.data;
3216
+ }
3217
+ }
3218
+ if (state.tokenize) {
3219
+ const result = $TOKEN("NestedClassSignatureElements", state, NestedClassSignatureElements$0(state));
3220
+ if (state.events)
3221
+ state.events.exit?.("NestedClassSignatureElements", state, result, eventData);
3222
+ return result;
3223
+ } else {
3224
+ const result = NestedClassSignatureElements$0(state);
3225
+ if (state.events)
3226
+ state.events.exit?.("NestedClassSignatureElements", state, result, eventData);
3227
+ return result;
3228
+ }
3229
+ }
3230
+ var NestedClassSignatureElement$0 = $S(Nested, ClassSignatureElement, StatementDelimiter);
3231
+ function NestedClassSignatureElement(state) {
3232
+ let eventData;
3233
+ if (state.events) {
3234
+ const result = state.events.enter?.("NestedClassSignatureElement", state);
3235
+ if (result) {
3236
+ if (result.cache)
3237
+ return result.cache;
3238
+ eventData = result.data;
3239
+ }
3240
+ }
3241
+ if (state.tokenize) {
3242
+ const result = $TOKEN("NestedClassSignatureElement", state, NestedClassSignatureElement$0(state));
3243
+ if (state.events)
3244
+ state.events.exit?.("NestedClassSignatureElement", state, result, eventData);
3245
+ return result;
3246
+ } else {
3247
+ const result = NestedClassSignatureElement$0(state);
3248
+ if (state.events)
3249
+ state.events.exit?.("NestedClassSignatureElement", state, result, eventData);
3250
+ return result;
3251
+ }
3252
+ }
3253
+ var ClassSignatureElement$0 = $S($E(Decorators), $E(AccessModifier), $E($S(Static, $Q(TrailingComment))), $C(MethodSignature, FieldDefinition));
3254
+ var ClassSignatureElement$1 = $S(Static, ClassSignatureBody);
3255
+ function ClassSignatureElement(state) {
3256
+ let eventData;
3257
+ if (state.events) {
3258
+ const result = state.events.enter?.("ClassSignatureElement", state);
3259
+ if (result) {
3260
+ if (result.cache)
3261
+ return result.cache;
3262
+ eventData = result.data;
3263
+ }
3264
+ }
3265
+ if (state.tokenize) {
3266
+ const result = $TOKEN("ClassSignatureElement", state, ClassSignatureElement$0(state) || ClassSignatureElement$1(state));
3267
+ if (state.events)
3268
+ state.events.exit?.("ClassSignatureElement", state, result, eventData);
3269
+ return result;
3270
+ } else {
3271
+ const result = ClassSignatureElement$0(state) || ClassSignatureElement$1(state);
3272
+ if (state.events)
3273
+ state.events.exit?.("ClassSignatureElement", state, result, eventData);
3274
+ return result;
3275
+ }
3276
+ }
3139
3277
  var AccessModifier$0 = $TS($S($E($S($C(Public, Private, Protected), __)), $E($S(Readonly, __))), function($skip, $loc, $0, $1, $2) {
3140
3278
  if (!($1 || $2))
3141
3279
  return $skip;
@@ -8231,6 +8369,35 @@ ${input.slice(result.pos)}
8231
8369
  return result;
8232
8370
  }
8233
8371
  }
8372
+ var NonPipelinePostfixedExpression$0 = $TS($S(NonPipelineExtendedExpression, $E($S($Q(TrailingComment), PostfixStatement))), function($skip, $loc, $0, $1, $2) {
8373
+ var expression = $1;
8374
+ var post = $2;
8375
+ if (post)
8376
+ return module.attachPostfixStatementAsExpression(expression, post);
8377
+ return expression;
8378
+ });
8379
+ function NonPipelinePostfixedExpression(state) {
8380
+ let eventData;
8381
+ if (state.events) {
8382
+ const result = state.events.enter?.("NonPipelinePostfixedExpression", state);
8383
+ if (result) {
8384
+ if (result.cache)
8385
+ return result.cache;
8386
+ eventData = result.data;
8387
+ }
8388
+ }
8389
+ if (state.tokenize) {
8390
+ const result = $TOKEN("NonPipelinePostfixedExpression", state, NonPipelinePostfixedExpression$0(state));
8391
+ if (state.events)
8392
+ state.events.exit?.("NonPipelinePostfixedExpression", state, result, eventData);
8393
+ return result;
8394
+ } else {
8395
+ const result = NonPipelinePostfixedExpression$0(state);
8396
+ if (state.events)
8397
+ state.events.exit?.("NonPipelinePostfixedExpression", state, result, eventData);
8398
+ return result;
8399
+ }
8400
+ }
8234
8401
  var PostfixStatement$0 = ForClause;
8235
8402
  var PostfixStatement$1 = IfClause;
8236
8403
  var PostfixStatement$2 = LoopClause;
@@ -8767,8 +8934,11 @@ ${input.slice(result.pos)}
8767
8934
  var IterationStatement$1 = $T($S($N(CoffeeDoEnabled), DoWhileStatement), function(value) {
8768
8935
  return value[1];
8769
8936
  });
8770
- var IterationStatement$2 = WhileStatement;
8771
- var IterationStatement$3 = ForStatement;
8937
+ var IterationStatement$2 = $T($S($N(CoffeeDoEnabled), DoStatement), function(value) {
8938
+ return value[1];
8939
+ });
8940
+ var IterationStatement$3 = WhileStatement;
8941
+ var IterationStatement$4 = ForStatement;
8772
8942
  function IterationStatement(state) {
8773
8943
  let eventData;
8774
8944
  if (state.events) {
@@ -8780,12 +8950,12 @@ ${input.slice(result.pos)}
8780
8950
  }
8781
8951
  }
8782
8952
  if (state.tokenize) {
8783
- const result = $TOKEN("IterationStatement", state, IterationStatement$0(state) || IterationStatement$1(state) || IterationStatement$2(state) || IterationStatement$3(state));
8953
+ const result = $TOKEN("IterationStatement", state, IterationStatement$0(state) || IterationStatement$1(state) || IterationStatement$2(state) || IterationStatement$3(state) || IterationStatement$4(state));
8784
8954
  if (state.events)
8785
8955
  state.events.exit?.("IterationStatement", state, result, eventData);
8786
8956
  return result;
8787
8957
  } else {
8788
- const result = IterationStatement$0(state) || IterationStatement$1(state) || IterationStatement$2(state) || IterationStatement$3(state);
8958
+ const result = IterationStatement$0(state) || IterationStatement$1(state) || IterationStatement$2(state) || IterationStatement$3(state) || IterationStatement$4(state);
8789
8959
  if (state.events)
8790
8960
  state.events.exit?.("IterationStatement", state, result, eventData);
8791
8961
  return result;
@@ -8794,6 +8964,7 @@ ${input.slice(result.pos)}
8794
8964
  var IterationExpression$0 = $TS($S(IterationStatement), function($skip, $loc, $0, $1) {
8795
8965
  return {
8796
8966
  type: "IterationExpression",
8967
+ subtype: $1.type,
8797
8968
  children: [$1],
8798
8969
  block: $1.block
8799
8970
  };
@@ -8902,6 +9073,37 @@ ${input.slice(result.pos)}
8902
9073
  return result;
8903
9074
  }
8904
9075
  }
9076
+ var DoStatement$0 = $TS($S(Do, NoPostfixBracedBlock), function($skip, $loc, $0, $1, $2) {
9077
+ var block = $2;
9078
+ block = module.insertTrimmingSpace(block, "");
9079
+ return {
9080
+ type: "DoStatement",
9081
+ children: [block],
9082
+ block
9083
+ };
9084
+ });
9085
+ function DoStatement(state) {
9086
+ let eventData;
9087
+ if (state.events) {
9088
+ const result = state.events.enter?.("DoStatement", state);
9089
+ if (result) {
9090
+ if (result.cache)
9091
+ return result.cache;
9092
+ eventData = result.data;
9093
+ }
9094
+ }
9095
+ if (state.tokenize) {
9096
+ const result = $TOKEN("DoStatement", state, DoStatement$0(state));
9097
+ if (state.events)
9098
+ state.events.exit?.("DoStatement", state, result, eventData);
9099
+ return result;
9100
+ } else {
9101
+ const result = DoStatement$0(state);
9102
+ if (state.events)
9103
+ state.events.exit?.("DoStatement", state, result, eventData);
9104
+ return result;
9105
+ }
9106
+ }
8905
9107
  var WhileStatement$0 = $TS($S(WhileClause, Block), function($skip, $loc, $0, $1, $2) {
8906
9108
  var clause = $1;
8907
9109
  var block = $2;
@@ -9843,13 +10045,31 @@ ${input.slice(result.pos)}
9843
10045
  var c = $3;
9844
10046
  var f = $4;
9845
10047
  if (!c && !f) {
10048
+ const e = [];
10049
+ const emptyCatchBlock = {
10050
+ type: "BlockStatement",
10051
+ expressions: e,
10052
+ children: ["{", e, "}"],
10053
+ bare: false,
10054
+ empty: true
10055
+ };
10056
+ c = {
10057
+ type: "CatchClause",
10058
+ children: [" catch(e) ", emptyCatchBlock],
10059
+ block: emptyCatchBlock
10060
+ };
9846
10061
  return {
9847
10062
  type: "TryStatement",
9848
- children: [t, b, " catch(e) {}"]
10063
+ blocks: [b, emptyCatchBlock],
10064
+ children: [t, b, c]
9849
10065
  };
9850
10066
  }
10067
+ const blocks = [b];
10068
+ if (c)
10069
+ blocks.push(c.block);
9851
10070
  return {
9852
10071
  type: "TryStatement",
10072
+ blocks,
9853
10073
  children: [t, b, c, f]
9854
10074
  };
9855
10075
  });
@@ -9879,7 +10099,7 @@ ${input.slice(result.pos)}
9879
10099
  var t = $0;
9880
10100
  return {
9881
10101
  type: "TryExpression",
9882
- blocks: [t.children[1], t.children[2]?.[3]],
10102
+ blocks: t.blocks,
9883
10103
  children: ["(()=>{", t, "})()"]
9884
10104
  };
9885
10105
  });
@@ -9905,7 +10125,14 @@ ${input.slice(result.pos)}
9905
10125
  return result;
9906
10126
  }
9907
10127
  }
9908
- var CatchClause$0 = $S($C(Samedent, _), Catch, $E(CatchBind), $C(ThenClause, BracedOrEmptyBlock));
10128
+ var CatchClause$0 = $TS($S($C(Samedent, _), Catch, $E(CatchBind), $C(ThenClause, BracedOrEmptyBlock)), function($skip, $loc, $0, $1, $2, $3, $4) {
10129
+ var block = $4;
10130
+ return {
10131
+ type: "CatchClause",
10132
+ children: $0,
10133
+ block
10134
+ };
10135
+ });
9909
10136
  function CatchClause(state) {
9910
10137
  let eventData;
9911
10138
  if (state.events) {
@@ -11114,7 +11341,7 @@ ${input.slice(result.pos)}
11114
11341
  return $0;
11115
11342
  return { ts: true, children: $0 };
11116
11343
  });
11117
- var ExportDeclaration$2 = $TS($S(Export, __, $C(Declaration, TypeAndNamedExports, VariableStatement, ExportVarDec)), function($skip, $loc, $0, $1, $2, $3) {
11344
+ var ExportDeclaration$2 = $TS($S(Export, __, $C(Declaration, VariableStatement, TypeAndNamedExports, ExportVarDec)), function($skip, $loc, $0, $1, $2, $3) {
11118
11345
  if (!$3.ts)
11119
11346
  return $0;
11120
11347
  return { ts: true, children: $0 };
@@ -13087,7 +13314,7 @@ ${input.slice(result.pos)}
13087
13314
  }
13088
13315
  }
13089
13316
  var StatementDelimiter$0 = SemicolonDelimiter;
13090
- 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);
13317
+ 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);
13091
13318
  var StatementDelimiter$2 = $Y(EOS);
13092
13319
  function StatementDelimiter(state) {
13093
13320
  let eventData;
@@ -14212,6 +14439,30 @@ ${input.slice(result.pos)}
14212
14439
  return result;
14213
14440
  }
14214
14441
  }
14442
+ var LetOrConstOrVar$0 = LetOrConst;
14443
+ var LetOrConstOrVar$1 = Var;
14444
+ function LetOrConstOrVar(state) {
14445
+ let eventData;
14446
+ if (state.events) {
14447
+ const result = state.events.enter?.("LetOrConstOrVar", state);
14448
+ if (result) {
14449
+ if (result.cache)
14450
+ return result.cache;
14451
+ eventData = result.data;
14452
+ }
14453
+ }
14454
+ if (state.tokenize) {
14455
+ const result = $TOKEN("LetOrConstOrVar", state, LetOrConstOrVar$0(state) || LetOrConstOrVar$1(state));
14456
+ if (state.events)
14457
+ state.events.exit?.("LetOrConstOrVar", state, result, eventData);
14458
+ return result;
14459
+ } else {
14460
+ const result = LetOrConstOrVar$0(state) || LetOrConstOrVar$1(state);
14461
+ if (state.events)
14462
+ state.events.exit?.("LetOrConstOrVar", state, result, eventData);
14463
+ return result;
14464
+ }
14465
+ }
14215
14466
  var Loop$0 = $TS($S($EXPECT($L130, fail, 'Loop "loop"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
14216
14467
  return { $loc, token: "while(true)" };
14217
14468
  });
@@ -16670,7 +16921,7 @@ ${input.slice(result.pos)}
16670
16921
  }
16671
16922
  var TypeDeclarationRest$0 = $S(TypeKeyword, $Q(TrailingComment), IdentifierName, $E(TypeParameters), __, Equals, $C($S($E(_), Type), $S(__, Type)));
16672
16923
  var TypeDeclarationRest$1 = $S(Interface, $Q(TrailingComment), IdentifierName, $E(TypeParameters), $E(InterfaceExtendsClause), InterfaceBlock);
16673
- var TypeDeclarationRest$2 = $S(Namespace, $Q(TrailingComment), IdentifierName, NamespaceBlock);
16924
+ var TypeDeclarationRest$2 = $S(Namespace, $Q(TrailingComment), IdentifierName, ModuleBlock);
16674
16925
  var TypeDeclarationRest$3 = FunctionSignature;
16675
16926
  function TypeDeclarationRest(state) {
16676
16927
  let eventData;
@@ -16694,7 +16945,11 @@ ${input.slice(result.pos)}
16694
16945
  return result;
16695
16946
  }
16696
16947
  }
16697
- var TypeLexicalDeclaration$0 = $S(__, $N(Namespace), LetOrConst, TypeDeclarationBinding, $Q($S(CommaDelimiter, __, TypeDeclarationBinding)));
16948
+ var TypeLexicalDeclaration$0 = $S(__, LetOrConstOrVar, TypeDeclarationBinding, $Q($S(CommaDelimiter, __, TypeDeclarationBinding)));
16949
+ var TypeLexicalDeclaration$1 = ClassSignature;
16950
+ var TypeLexicalDeclaration$2 = $S(Namespace, $Q(TrailingComment), IdentifierName, DeclareBlock);
16951
+ var TypeLexicalDeclaration$3 = $S(Module, _, StringLiteral, $E(DeclareBlock));
16952
+ var TypeLexicalDeclaration$4 = $S(Global, $E(DeclareBlock));
16698
16953
  function TypeLexicalDeclaration(state) {
16699
16954
  let eventData;
16700
16955
  if (state.events) {
@@ -16706,12 +16961,12 @@ ${input.slice(result.pos)}
16706
16961
  }
16707
16962
  }
16708
16963
  if (state.tokenize) {
16709
- const result = $TOKEN("TypeLexicalDeclaration", state, TypeLexicalDeclaration$0(state));
16964
+ const result = $TOKEN("TypeLexicalDeclaration", state, TypeLexicalDeclaration$0(state) || TypeLexicalDeclaration$1(state) || TypeLexicalDeclaration$2(state) || TypeLexicalDeclaration$3(state) || TypeLexicalDeclaration$4(state));
16710
16965
  if (state.events)
16711
16966
  state.events.exit?.("TypeLexicalDeclaration", state, result, eventData);
16712
16967
  return result;
16713
16968
  } else {
16714
- const result = TypeLexicalDeclaration$0(state);
16969
+ const result = TypeLexicalDeclaration$0(state) || TypeLexicalDeclaration$1(state) || TypeLexicalDeclaration$2(state) || TypeLexicalDeclaration$3(state) || TypeLexicalDeclaration$4(state);
16715
16970
  if (state.events)
16716
16971
  state.events.exit?.("TypeLexicalDeclaration", state, result, eventData);
16717
16972
  return result;
@@ -16786,7 +17041,9 @@ ${input.slice(result.pos)}
16786
17041
  return result;
16787
17042
  }
16788
17043
  }
16789
- var TypeKeyword$0 = $S($EXPECT($L171, fail, 'TypeKeyword "type"'), NonIdContinue);
17044
+ var TypeKeyword$0 = $TS($S($EXPECT($L171, fail, 'TypeKeyword "type"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
17045
+ return { $loc, token: $1 };
17046
+ });
16790
17047
  function TypeKeyword(state) {
16791
17048
  let eventData;
16792
17049
  if (state.events) {
@@ -16809,7 +17066,9 @@ ${input.slice(result.pos)}
16809
17066
  return result;
16810
17067
  }
16811
17068
  }
16812
- var Interface$0 = $S($EXPECT($L172, fail, 'Interface "interface"'), NonIdContinue);
17069
+ var Interface$0 = $TS($S($EXPECT($L172, fail, 'Interface "interface"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
17070
+ return { $loc, token: $1 };
17071
+ });
16813
17072
  function Interface(state) {
16814
17073
  let eventData;
16815
17074
  if (state.events) {
@@ -16832,7 +17091,59 @@ ${input.slice(result.pos)}
16832
17091
  return result;
16833
17092
  }
16834
17093
  }
16835
- var Namespace$0 = $S($EXPECT($L173, fail, 'Namespace "namespace"'), NonIdContinue);
17094
+ var Global$0 = $TS($S($EXPECT($L173, fail, 'Global "global"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
17095
+ return { $loc, token: $1 };
17096
+ });
17097
+ function Global(state) {
17098
+ let eventData;
17099
+ if (state.events) {
17100
+ const result = state.events.enter?.("Global", state);
17101
+ if (result) {
17102
+ if (result.cache)
17103
+ return result.cache;
17104
+ eventData = result.data;
17105
+ }
17106
+ }
17107
+ if (state.tokenize) {
17108
+ const result = $TOKEN("Global", state, Global$0(state));
17109
+ if (state.events)
17110
+ state.events.exit?.("Global", state, result, eventData);
17111
+ return result;
17112
+ } else {
17113
+ const result = Global$0(state);
17114
+ if (state.events)
17115
+ state.events.exit?.("Global", state, result, eventData);
17116
+ return result;
17117
+ }
17118
+ }
17119
+ var Module$0 = $TS($S($EXPECT($L174, fail, 'Module "module"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
17120
+ return { $loc, token: $1 };
17121
+ });
17122
+ function Module(state) {
17123
+ let eventData;
17124
+ if (state.events) {
17125
+ const result = state.events.enter?.("Module", state);
17126
+ if (result) {
17127
+ if (result.cache)
17128
+ return result.cache;
17129
+ eventData = result.data;
17130
+ }
17131
+ }
17132
+ if (state.tokenize) {
17133
+ const result = $TOKEN("Module", state, Module$0(state));
17134
+ if (state.events)
17135
+ state.events.exit?.("Module", state, result, eventData);
17136
+ return result;
17137
+ } else {
17138
+ const result = Module$0(state);
17139
+ if (state.events)
17140
+ state.events.exit?.("Module", state, result, eventData);
17141
+ return result;
17142
+ }
17143
+ }
17144
+ var Namespace$0 = $TS($S($EXPECT($L175, fail, 'Namespace "namespace"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
17145
+ return { $loc, token: $1 };
17146
+ });
16836
17147
  function Namespace(state) {
16837
17148
  let eventData;
16838
17149
  if (state.events) {
@@ -17004,13 +17315,88 @@ ${input.slice(result.pos)}
17004
17315
  return result;
17005
17316
  }
17006
17317
  }
17007
- var NamespaceBlock$0 = $S(__, OpenBrace, NestedTypeDeclarations, __, CloseBrace);
17008
- var NamespaceBlock$1 = $S(__, OpenBrace, $Q($S(__, TypeDeclaration, InterfacePropertyDelimiter)), __, CloseBrace);
17009
- var NamespaceBlock$2 = $S(InsertOpenBrace, NestedTypeDeclarations, InsertNewline, InsertIndent, InsertCloseBrace);
17010
- function NamespaceBlock(state) {
17318
+ var ModuleBlock$0 = $S(__, OpenBrace, NestedModuleItems, __, CloseBrace);
17319
+ var ModuleBlock$1 = $S(InsertOpenBrace, NestedModuleItems, InsertNewline, InsertIndent, InsertCloseBrace);
17320
+ function ModuleBlock(state) {
17321
+ let eventData;
17322
+ if (state.events) {
17323
+ const result = state.events.enter?.("ModuleBlock", state);
17324
+ if (result) {
17325
+ if (result.cache)
17326
+ return result.cache;
17327
+ eventData = result.data;
17328
+ }
17329
+ }
17330
+ if (state.tokenize) {
17331
+ const result = $TOKEN("ModuleBlock", state, ModuleBlock$0(state) || ModuleBlock$1(state));
17332
+ if (state.events)
17333
+ state.events.exit?.("ModuleBlock", state, result, eventData);
17334
+ return result;
17335
+ } else {
17336
+ const result = ModuleBlock$0(state) || ModuleBlock$1(state);
17337
+ if (state.events)
17338
+ state.events.exit?.("ModuleBlock", state, result, eventData);
17339
+ return result;
17340
+ }
17341
+ }
17342
+ var NestedModuleItems$0 = $TS($S(PushIndent, $Q(NestedModuleItem), PopIndent), function($skip, $loc, $0, $1, $2, $3) {
17343
+ var items = $2;
17344
+ if (items.length)
17345
+ return items;
17346
+ return $skip;
17347
+ });
17348
+ function NestedModuleItems(state) {
17349
+ let eventData;
17350
+ if (state.events) {
17351
+ const result = state.events.enter?.("NestedModuleItems", state);
17352
+ if (result) {
17353
+ if (result.cache)
17354
+ return result.cache;
17355
+ eventData = result.data;
17356
+ }
17357
+ }
17358
+ if (state.tokenize) {
17359
+ const result = $TOKEN("NestedModuleItems", state, NestedModuleItems$0(state));
17360
+ if (state.events)
17361
+ state.events.exit?.("NestedModuleItems", state, result, eventData);
17362
+ return result;
17363
+ } else {
17364
+ const result = NestedModuleItems$0(state);
17365
+ if (state.events)
17366
+ state.events.exit?.("NestedModuleItems", state, result, eventData);
17367
+ return result;
17368
+ }
17369
+ }
17370
+ var NestedModuleItem$0 = $S(Nested, ModuleItem, StatementDelimiter);
17371
+ function NestedModuleItem(state) {
17372
+ let eventData;
17373
+ if (state.events) {
17374
+ const result = state.events.enter?.("NestedModuleItem", state);
17375
+ if (result) {
17376
+ if (result.cache)
17377
+ return result.cache;
17378
+ eventData = result.data;
17379
+ }
17380
+ }
17381
+ if (state.tokenize) {
17382
+ const result = $TOKEN("NestedModuleItem", state, NestedModuleItem$0(state));
17383
+ if (state.events)
17384
+ state.events.exit?.("NestedModuleItem", state, result, eventData);
17385
+ return result;
17386
+ } else {
17387
+ const result = NestedModuleItem$0(state);
17388
+ if (state.events)
17389
+ state.events.exit?.("NestedModuleItem", state, result, eventData);
17390
+ return result;
17391
+ }
17392
+ }
17393
+ var DeclareBlock$0 = $S(__, OpenBrace, NestedDeclareElements, __, CloseBrace);
17394
+ var DeclareBlock$1 = $S(__, OpenBrace, $Q($S(__, DeclareElement, InterfacePropertyDelimiter)), __, CloseBrace);
17395
+ var DeclareBlock$2 = $S(InsertOpenBrace, NestedDeclareElements, InsertNewline, InsertIndent, InsertCloseBrace);
17396
+ function DeclareBlock(state) {
17011
17397
  let eventData;
17012
17398
  if (state.events) {
17013
- const result = state.events.enter?.("NamespaceBlock", state);
17399
+ const result = state.events.enter?.("DeclareBlock", state);
17014
17400
  if (result) {
17015
17401
  if (result.cache)
17016
17402
  return result.cache;
@@ -17018,27 +17404,50 @@ ${input.slice(result.pos)}
17018
17404
  }
17019
17405
  }
17020
17406
  if (state.tokenize) {
17021
- const result = $TOKEN("NamespaceBlock", state, NamespaceBlock$0(state) || NamespaceBlock$1(state) || NamespaceBlock$2(state));
17407
+ const result = $TOKEN("DeclareBlock", state, DeclareBlock$0(state) || DeclareBlock$1(state) || DeclareBlock$2(state));
17022
17408
  if (state.events)
17023
- state.events.exit?.("NamespaceBlock", state, result, eventData);
17409
+ state.events.exit?.("DeclareBlock", state, result, eventData);
17024
17410
  return result;
17025
17411
  } else {
17026
- const result = NamespaceBlock$0(state) || NamespaceBlock$1(state) || NamespaceBlock$2(state);
17412
+ const result = DeclareBlock$0(state) || DeclareBlock$1(state) || DeclareBlock$2(state);
17027
17413
  if (state.events)
17028
- state.events.exit?.("NamespaceBlock", state, result, eventData);
17414
+ state.events.exit?.("DeclareBlock", state, result, eventData);
17029
17415
  return result;
17030
17416
  }
17031
17417
  }
17032
- var NestedTypeDeclarations$0 = $TS($S(PushIndent, $Q(NestedTypeDeclaration), PopIndent), function($skip, $loc, $0, $1, $2, $3) {
17418
+ var NestedDeclareElements$0 = $TS($S(PushIndent, $Q(NestedDeclareElement), PopIndent), function($skip, $loc, $0, $1, $2, $3) {
17033
17419
  var decs = $2;
17034
17420
  if (decs.length)
17035
17421
  return decs;
17036
17422
  return $skip;
17037
17423
  });
17038
- function NestedTypeDeclarations(state) {
17424
+ function NestedDeclareElements(state) {
17425
+ let eventData;
17426
+ if (state.events) {
17427
+ const result = state.events.enter?.("NestedDeclareElements", state);
17428
+ if (result) {
17429
+ if (result.cache)
17430
+ return result.cache;
17431
+ eventData = result.data;
17432
+ }
17433
+ }
17434
+ if (state.tokenize) {
17435
+ const result = $TOKEN("NestedDeclareElements", state, NestedDeclareElements$0(state));
17436
+ if (state.events)
17437
+ state.events.exit?.("NestedDeclareElements", state, result, eventData);
17438
+ return result;
17439
+ } else {
17440
+ const result = NestedDeclareElements$0(state);
17441
+ if (state.events)
17442
+ state.events.exit?.("NestedDeclareElements", state, result, eventData);
17443
+ return result;
17444
+ }
17445
+ }
17446
+ var NestedDeclareElement$0 = $S(Nested, DeclareElement, InterfacePropertyDelimiter);
17447
+ function NestedDeclareElement(state) {
17039
17448
  let eventData;
17040
17449
  if (state.events) {
17041
- const result = state.events.enter?.("NestedTypeDeclarations", state);
17450
+ const result = state.events.enter?.("NestedDeclareElement", state);
17042
17451
  if (result) {
17043
17452
  if (result.cache)
17044
17453
  return result.cache;
@@ -17046,22 +17455,27 @@ ${input.slice(result.pos)}
17046
17455
  }
17047
17456
  }
17048
17457
  if (state.tokenize) {
17049
- const result = $TOKEN("NestedTypeDeclarations", state, NestedTypeDeclarations$0(state));
17458
+ const result = $TOKEN("NestedDeclareElement", state, NestedDeclareElement$0(state));
17050
17459
  if (state.events)
17051
- state.events.exit?.("NestedTypeDeclarations", state, result, eventData);
17460
+ state.events.exit?.("NestedDeclareElement", state, result, eventData);
17052
17461
  return result;
17053
17462
  } else {
17054
- const result = NestedTypeDeclarations$0(state);
17463
+ const result = NestedDeclareElement$0(state);
17055
17464
  if (state.events)
17056
- state.events.exit?.("NestedTypeDeclarations", state, result, eventData);
17465
+ state.events.exit?.("NestedDeclareElement", state, result, eventData);
17057
17466
  return result;
17058
17467
  }
17059
17468
  }
17060
- var NestedTypeDeclaration$0 = $S(Nested, TypeDeclaration, InterfacePropertyDelimiter);
17061
- function NestedTypeDeclaration(state) {
17469
+ var DeclareElement$0 = $T($S($E($S(Export, $E(_))), TypeLexicalDeclaration), function(value) {
17470
+ return { "ts": true, "children": value };
17471
+ });
17472
+ var DeclareElement$1 = $T($S($E($S(Export, $E(_))), TypeDeclarationRest), function(value) {
17473
+ return { "ts": true, "children": value };
17474
+ });
17475
+ function DeclareElement(state) {
17062
17476
  let eventData;
17063
17477
  if (state.events) {
17064
- const result = state.events.enter?.("NestedTypeDeclaration", state);
17478
+ const result = state.events.enter?.("DeclareElement", state);
17065
17479
  if (result) {
17066
17480
  if (result.cache)
17067
17481
  return result.cache;
@@ -17069,14 +17483,14 @@ ${input.slice(result.pos)}
17069
17483
  }
17070
17484
  }
17071
17485
  if (state.tokenize) {
17072
- const result = $TOKEN("NestedTypeDeclaration", state, NestedTypeDeclaration$0(state));
17486
+ const result = $TOKEN("DeclareElement", state, DeclareElement$0(state) || DeclareElement$1(state));
17073
17487
  if (state.events)
17074
- state.events.exit?.("NestedTypeDeclaration", state, result, eventData);
17488
+ state.events.exit?.("DeclareElement", state, result, eventData);
17075
17489
  return result;
17076
17490
  } else {
17077
- const result = NestedTypeDeclaration$0(state);
17491
+ const result = DeclareElement$0(state) || DeclareElement$1(state);
17078
17492
  if (state.events)
17079
- state.events.exit?.("NestedTypeDeclaration", state, result, eventData);
17493
+ state.events.exit?.("DeclareElement", state, result, eventData);
17080
17494
  return result;
17081
17495
  }
17082
17496
  }
@@ -17130,6 +17544,12 @@ ${input.slice(result.pos)}
17130
17544
  var TypeSuffix$0 = $T($S($E(QuestionMark), $E(_), Colon, Type), function(value) {
17131
17545
  return { "type": "TypeSuffix", "ts": true, "children": value };
17132
17546
  });
17547
+ var TypeSuffix$1 = $T($S(QuestionMark, $E(_)), function(value) {
17548
+ return { "type": "TypeSuffix", "ts": true, "children": value };
17549
+ });
17550
+ var TypeSuffix$2 = $T($S(NonNullAssertion, $E(_), $E($S(Colon, Type))), function(value) {
17551
+ return { "type": "TypeSuffix", "ts": true, "children": value };
17552
+ });
17133
17553
  function TypeSuffix(state) {
17134
17554
  let eventData;
17135
17555
  if (state.events) {
@@ -17141,18 +17561,18 @@ ${input.slice(result.pos)}
17141
17561
  }
17142
17562
  }
17143
17563
  if (state.tokenize) {
17144
- const result = $TOKEN("TypeSuffix", state, TypeSuffix$0(state));
17564
+ const result = $TOKEN("TypeSuffix", state, TypeSuffix$0(state) || TypeSuffix$1(state) || TypeSuffix$2(state));
17145
17565
  if (state.events)
17146
17566
  state.events.exit?.("TypeSuffix", state, result, eventData);
17147
17567
  return result;
17148
17568
  } else {
17149
- const result = TypeSuffix$0(state);
17569
+ const result = TypeSuffix$0(state) || TypeSuffix$1(state) || TypeSuffix$2(state);
17150
17570
  if (state.events)
17151
17571
  state.events.exit?.("TypeSuffix", state, result, eventData);
17152
17572
  return result;
17153
17573
  }
17154
17574
  }
17155
- var ReturnTypeSuffix$0 = $TS($S($E(_), Colon, $E($S(__, $EXPECT($L174, fail, 'ReturnTypeSuffix "asserts"'), NonIdContinue)), TypePredicate), function($skip, $loc, $0, $1, $2, $3, $4) {
17575
+ var ReturnTypeSuffix$0 = $TS($S($E(_), Colon, $E($S(__, $EXPECT($L176, fail, 'ReturnTypeSuffix "asserts"'), NonIdContinue)), TypePredicate), function($skip, $loc, $0, $1, $2, $3, $4) {
17156
17576
  var asserts = $3;
17157
17577
  var t = $4;
17158
17578
  if (asserts) {
@@ -17326,9 +17746,9 @@ ${input.slice(result.pos)}
17326
17746
  return result;
17327
17747
  }
17328
17748
  }
17329
- var TypeUnaryOp$0 = $S($EXPECT($L175, fail, 'TypeUnaryOp "keyof"'), NonIdContinue);
17749
+ var TypeUnaryOp$0 = $S($EXPECT($L177, fail, 'TypeUnaryOp "keyof"'), NonIdContinue);
17330
17750
  var TypeUnaryOp$1 = $S($EXPECT($L157, fail, 'TypeUnaryOp "typeof"'), NonIdContinue);
17331
- var TypeUnaryOp$2 = $S($EXPECT($L176, fail, 'TypeUnaryOp "infer"'), NonIdContinue);
17751
+ var TypeUnaryOp$2 = $S($EXPECT($L178, fail, 'TypeUnaryOp "infer"'), NonIdContinue);
17332
17752
  var TypeUnaryOp$3 = $S($EXPECT($L141, fail, 'TypeUnaryOp "readonly"'), NonIdContinue);
17333
17753
  function TypeUnaryOp(state) {
17334
17754
  let eventData;
@@ -17574,7 +17994,7 @@ ${input.slice(result.pos)}
17574
17994
  var TypeLiteral$2 = $TS($S($EXPECT($L161, fail, 'TypeLiteral "void"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
17575
17995
  return { type: "VoidType", $loc, token: $1 };
17576
17996
  });
17577
- var TypeLiteral$3 = $TV($EXPECT($L177, fail, 'TypeLiteral "[]"'), function($skip, $loc, $0, $1) {
17997
+ var TypeLiteral$3 = $TV($EXPECT($L179, fail, 'TypeLiteral "[]"'), function($skip, $loc, $0, $1) {
17578
17998
  return { $loc, token: "[]" };
17579
17999
  });
17580
18000
  function TypeLiteral(state) {
@@ -18034,7 +18454,7 @@ ${input.slice(result.pos)}
18034
18454
  return result;
18035
18455
  }
18036
18456
  }
18037
- var CivetPrologueContent$0 = $TS($S($EXPECT($L178, fail, 'CivetPrologueContent "civet"'), NonIdContinue, $Q(CivetOption), $EXPECT($R61, fail, "CivetPrologueContent /[\\s]*/")), function($skip, $loc, $0, $1, $2, $3, $4) {
18457
+ var CivetPrologueContent$0 = $TS($S($EXPECT($L180, fail, 'CivetPrologueContent "civet"'), NonIdContinue, $Q(CivetOption), $EXPECT($R61, fail, "CivetPrologueContent /[\\s]*/")), function($skip, $loc, $0, $1, $2, $3, $4) {
18038
18458
  var options = $3;
18039
18459
  return {
18040
18460
  type: "CivetPrologue",
@@ -19551,15 +19971,29 @@ ${input.slice(result.pos)}
19551
19971
  return post;
19552
19972
  };
19553
19973
  function expressionizeIteration(exp) {
19974
+ const i = exp.children.indexOf(exp.block);
19975
+ if (exp.subtype === "DoStatement") {
19976
+ insertReturn(exp.block);
19977
+ exp.children.splice(i, 1, "(()=>", ...exp.children, ")()");
19978
+ return;
19979
+ }
19554
19980
  const resultsRef = {
19555
19981
  type: "Ref",
19556
19982
  base: "results",
19557
19983
  id: "results"
19558
19984
  };
19559
19985
  insertPush(exp.block, resultsRef);
19560
- exp.children = ["(()=>{const ", resultsRef, "=[];", ...exp.children, "; return ", resultsRef, "})()"];
19986
+ exp.children.splice(i, 1, "(()=>{const ", resultsRef, "=[];", ...exp.children, "; return ", resultsRef, "})()");
19561
19987
  }
19562
19988
  function wrapIterationReturningResults(statement, outerRef) {
19989
+ if (statement.type === "DoStatement") {
19990
+ if (outerRef) {
19991
+ insertPush(statement.block, outerRef);
19992
+ } else {
19993
+ insertReturn(statement.block);
19994
+ }
19995
+ return;
19996
+ }
19563
19997
  const resultsRef = {
19564
19998
  type: "Ref",
19565
19999
  base: "results",
@@ -19582,7 +20016,12 @@ ${input.slice(result.pos)}
19582
20016
  return;
19583
20017
  switch (node.type) {
19584
20018
  case "BlockStatement":
19585
- insertPush(node.expressions[node.expressions.length - 1], ref);
20019
+ if (node.expressions.length) {
20020
+ const last = node.expressions[node.expressions.length - 1];
20021
+ insertPush(last, ref);
20022
+ } else {
20023
+ node.expressions.push([ref, ".push(void 0);"]);
20024
+ }
19586
20025
  return;
19587
20026
  case "CaseBlock":
19588
20027
  node.clauses.forEach((clause) => {
@@ -19615,6 +20054,7 @@ ${input.slice(result.pos)}
19615
20054
  return;
19616
20055
  case "ForStatement":
19617
20056
  case "IterationStatement":
20057
+ case "DoStatement":
19618
20058
  wrapIterationReturningResults(exp, ref);
19619
20059
  return;
19620
20060
  case "BlockStatement":
@@ -19634,9 +20074,7 @@ ${input.slice(result.pos)}
19634
20074
  insertPush(exp.children[2], ref);
19635
20075
  return;
19636
20076
  case "TryStatement":
19637
- insertPush(exp.children[1], ref);
19638
- if (exp.children[2])
19639
- insertPush(exp.children[2][2], ref);
20077
+ exp.blocks.forEach((block) => insertPush(block, ref));
19640
20078
  return;
19641
20079
  }
19642
20080
  node.splice(1, 0, ref, ".push(");
@@ -19672,7 +20110,14 @@ ${input.slice(result.pos)}
19672
20110
  return;
19673
20111
  switch (node.type) {
19674
20112
  case "BlockStatement":
19675
- insertReturn(node.expressions[node.expressions.length - 1]);
20113
+ if (node.expressions.length) {
20114
+ const last = node.expressions[node.expressions.length - 1];
20115
+ insertReturn(last);
20116
+ } else {
20117
+ if (node.parent.type === "CatchClause") {
20118
+ node.expressions.push(["return"]);
20119
+ }
20120
+ }
19676
20121
  return;
19677
20122
  case "WhenClause":
19678
20123
  node.children.splice(node.children.indexOf(node.break), 1);
@@ -19705,6 +20150,7 @@ ${input.slice(result.pos)}
19705
20150
  return;
19706
20151
  case "ForStatement":
19707
20152
  case "IterationStatement":
20153
+ case "DoStatement":
19708
20154
  wrapIterationReturningResults(exp);
19709
20155
  return;
19710
20156
  case "BlockStatement":
@@ -19724,9 +20170,7 @@ ${input.slice(result.pos)}
19724
20170
  insertSwitchReturns(exp);
19725
20171
  return;
19726
20172
  case "TryStatement":
19727
- insertReturn(exp.children[1]);
19728
- if (exp.children[2])
19729
- insertReturn(exp.children[2][3]);
20173
+ exp.blocks.forEach((block) => insertReturn(block));
19730
20174
  return;
19731
20175
  }
19732
20176
  if (node[node.length - 1]?.type === "SemicolonDelimiter")
@@ -19902,10 +20346,12 @@ ${input.slice(result.pos)}
19902
20346
  if (Array.isArray(target)) {
19903
20347
  if (target.length === 1) {
19904
20348
  return module.skipIfOnlyWS(target[0]);
20349
+ } else if (target.every((e) => module.skipIfOnlyWS(e) === void 0)) {
20350
+ return void 0;
19905
20351
  }
19906
20352
  return target;
19907
20353
  }
19908
- if (target.token && target.token.trim() === "") {
20354
+ if (target.token != null && target.token.trim() === "") {
19909
20355
  return void 0;
19910
20356
  }
19911
20357
  return target;
@@ -20440,8 +20886,9 @@ ${input.slice(result.pos)}
20440
20886
  module.attachPostfixStatementAsExpression = function(exp, post) {
20441
20887
  let clause;
20442
20888
  switch (post[1].type) {
20443
- case "IterationStatement":
20444
20889
  case "ForStatement":
20890
+ case "IterationStatement":
20891
+ case "DoStatement":
20445
20892
  clause = module.addPostfixStatement(exp, ...post);
20446
20893
  return {
20447
20894
  type: "IterationExpression",
@@ -20646,6 +21093,37 @@ ${input.slice(result.pos)}
20646
21093
  return pattern;
20647
21094
  }
20648
21095
  }
21096
+ function aggregateDuplicateBindings(bindings) {
21097
+ const props2 = gatherRecursiveAll(bindings, (n) => n.type === "BindingMatchProperty");
21098
+ const declarations = [];
21099
+ const propsGroupedByName = /* @__PURE__ */ new Map();
21100
+ for (const p of props2) {
21101
+ const { name } = p;
21102
+ const key = name.name;
21103
+ if (propsGroupedByName.has(key)) {
21104
+ propsGroupedByName.get(key).push(p);
21105
+ } else {
21106
+ propsGroupedByName.set(key, [p]);
21107
+ }
21108
+ }
21109
+ propsGroupedByName.forEach((shared, key) => {
21110
+ if (shared.length === 1)
21111
+ return;
21112
+ const refs = shared.map((p) => {
21113
+ const ref = {
21114
+ type: "Ref",
21115
+ base: key,
21116
+ id: key
21117
+ };
21118
+ p.children.push(": ", ref);
21119
+ return ref;
21120
+ });
21121
+ declarations.push(["const ", key, " = [", ...refs.map((r, i) => {
21122
+ return i === 0 ? r : [", ", r];
21123
+ }), "]"]);
21124
+ });
21125
+ return declarations;
21126
+ }
20649
21127
  function processPatternMatching(statements) {
20650
21128
  gatherRecursiveAll(statements, (n) => n.type === "SwitchStatement" || n.type === "SwitchExpression").forEach((s) => {
20651
21129
  const { caseBlock } = s;
@@ -20712,10 +21190,13 @@ ${input.slice(result.pos)}
20712
21190
  if (pattern.properties?.length === 0)
20713
21191
  break;
20714
21192
  let [splices, thisAssignments] = gatherBindingCode(pattern);
21193
+ const patternBindings = nonMatcherBindings(pattern);
20715
21194
  splices = splices.map((s2) => [", ", nonMatcherBindings(s2)]);
20716
21195
  thisAssignments = thisAssignments.map((a) => [indent, a, ";\n"]);
20717
- prefix.push([indent, "const ", nonMatcherBindings(pattern), " = ", ref, splices, ";\n"]);
21196
+ const duplicateDeclarations = aggregateDuplicateBindings([patternBindings, splices]);
21197
+ prefix.push([indent, "const ", patternBindings, " = ", ref, splices, ";\n"]);
20718
21198
  prefix.push(...thisAssignments);
21199
+ prefix.push(...duplicateDeclarations.map((d) => [indent, d, ";\n"]));
20719
21200
  break;
20720
21201
  }
20721
21202
  }
@@ -20747,10 +21228,10 @@ ${input.slice(result.pos)}
20747
21228
  }
20748
21229
  function processPipelineExpressions(statements) {
20749
21230
  gatherRecursiveAll(statements, (n) => n.type === "PipelineExpression").forEach((s) => {
20750
- const [, body] = s.children;
20751
- let [arg] = s.children;
21231
+ const [ws, , body] = s.children;
21232
+ let [, arg] = s.children;
20752
21233
  let i = 0, l = body.length;
20753
- const children = [];
21234
+ const children = [ws];
20754
21235
  for (i = 0; i < l; i++) {
20755
21236
  const step = body[i];
20756
21237
  const [leadingComment, pipe, trailingComment, expr] = step;
@@ -20775,7 +21256,17 @@ ${input.slice(result.pos)}
20775
21256
  returns ? arg : null
20776
21257
  );
20777
21258
  if (result.type === "ReturnStatement") {
21259
+ if (i < l - 1) {
21260
+ result.children.push({
21261
+ type: "Error",
21262
+ message: "Can't continue a pipeline after returning"
21263
+ });
21264
+ }
20778
21265
  arg = result;
21266
+ if (children[children.length - 1] === ",") {
21267
+ children.pop();
21268
+ children.push(";");
21269
+ }
20779
21270
  break;
20780
21271
  }
20781
21272
  if (returning) {
@@ -21206,6 +21697,36 @@ ${input.slice(result.pos)}
21206
21697
  return result;
21207
21698
  }
21208
21699
  }
21700
+ var NotDedented$0 = $TS($S($E($C(Samedent, IndentedFurther)), $E(_)), function($skip, $loc, $0, $1, $2) {
21701
+ const ws = [];
21702
+ if ($1)
21703
+ ws.push(...$1);
21704
+ if ($2)
21705
+ ws.push(...$2);
21706
+ return ws.flat(Infinity).filter(Boolean);
21707
+ });
21708
+ function NotDedented(state) {
21709
+ let eventData;
21710
+ if (state.events) {
21711
+ const result = state.events.enter?.("NotDedented", state);
21712
+ if (result) {
21713
+ if (result.cache)
21714
+ return result.cache;
21715
+ eventData = result.data;
21716
+ }
21717
+ }
21718
+ if (state.tokenize) {
21719
+ const result = $TOKEN("NotDedented", state, NotDedented$0(state));
21720
+ if (state.events)
21721
+ state.events.exit?.("NotDedented", state, result, eventData);
21722
+ return result;
21723
+ } else {
21724
+ const result = NotDedented$0(state);
21725
+ if (state.events)
21726
+ state.events.exit?.("NotDedented", state, result, eventData);
21727
+ return result;
21728
+ }
21729
+ }
21209
21730
  var PushIndent$0 = $Y($S(EOS, TrackIndented));
21210
21731
  function PushIndent(state) {
21211
21732
  let eventData;
@@ -21733,7 +22254,7 @@ ${input.slice(result.pos)}
21733
22254
  var uncacheable;
21734
22255
  ({ parse } = import_parser.default);
21735
22256
  ({ SourceMap: SourceMap2, base64Encode: base64Encode2 } = util_exports);
21736
- 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", "NestedElement", "NestedElementList", "NestedImplicitObjectLiteral", "NestedImplicitPropertyDefinition", "NestedImplicitPropertyDefinitions", "NestedInterfaceProperty", "NestedJSXChildExpression", "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"]);
22257
+ 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", "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"]);
21737
22258
  var compile = function(src, options) {
21738
22259
  var ast, code, events, filename, ref, result, sm, srcMapJSON;
21739
22260
  if (!options) {