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