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