@danielx/civet 0.5.76 → 0.5.78

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
@@ -849,6 +849,7 @@ ${input.slice(result.pos)}
849
849
  Import,
850
850
  In,
851
851
  LetOrConst,
852
+ Const,
852
853
  LetOrConstOrVar,
853
854
  Loop,
854
855
  New,
@@ -942,6 +943,7 @@ ${input.slice(result.pos)}
942
943
  InterfaceExtendsClause,
943
944
  InterfaceExtendsTarget,
944
945
  TypeKeyword,
946
+ Enum,
945
947
  Interface,
946
948
  Global,
947
949
  Module,
@@ -959,6 +961,11 @@ ${input.slice(result.pos)}
959
961
  NestedDeclareElements,
960
962
  NestedDeclareElement,
961
963
  DeclareElement,
964
+ EnumDeclaration,
965
+ EnumBlock,
966
+ NestedEnumProperties,
967
+ NestedEnumProperty,
968
+ EnumProperty,
962
969
  TypeIndexSignature,
963
970
  TypeIndex,
964
971
  TypeSuffix,
@@ -1217,16 +1224,17 @@ ${input.slice(result.pos)}
1217
1224
  var $L169 = $L("<!--");
1218
1225
  var $L170 = $L("-->");
1219
1226
  var $L171 = $L("type");
1220
- var $L172 = $L("interface");
1221
- var $L173 = $L("global");
1222
- var $L174 = $L("module");
1223
- var $L175 = $L("namespace");
1224
- var $L176 = $L("asserts");
1225
- var $L177 = $L("keyof");
1226
- var $L178 = $L("infer");
1227
- var $L179 = $L("[]");
1228
- var $L180 = $L("civet");
1229
- var $R0 = $R(new RegExp("(as|for|while|until|of|satisfies|then|when|implements|xor|xnor)(?!\\p{ID_Continue}|[\\u200C\\u200D$])", "suy"));
1227
+ var $L172 = $L("enum");
1228
+ var $L173 = $L("interface");
1229
+ var $L174 = $L("global");
1230
+ var $L175 = $L("module");
1231
+ var $L176 = $L("namespace");
1232
+ var $L177 = $L("asserts");
1233
+ var $L178 = $L("keyof");
1234
+ var $L179 = $L("infer");
1235
+ var $L180 = $L("[]");
1236
+ var $L181 = $L("civet");
1237
+ var $R0 = $R(new RegExp("(as|of|satisfies|then|when|implements|xor|xnor)(?!\\p{ID_Continue}|[\\u200C\\u200D$])", "suy"));
1230
1238
  var $R1 = $R(new RegExp("[0-9]", "suy"));
1231
1239
  var $R2 = $R(new RegExp("[)}]", "suy"));
1232
1240
  var $R3 = $R(new RegExp("[&]", "suy"));
@@ -1279,18 +1287,19 @@ ${input.slice(result.pos)}
1279
1287
  var $R50 = $R(new RegExp("(?:\\p{ID_Start}|[_$])(?:\\p{ID_Continue}|[\\u200C\\u200D$-])*", "suy"));
1280
1288
  var $R51 = $R(new RegExp("[\\s>]", "suy"));
1281
1289
  var $R52 = $R(new RegExp("(?:[\\w\\-:]+|\\([^()]*\\)|\\[[^\\[\\]]*\\])+", "suy"));
1282
- var $R53 = $R(new RegExp("[<>]", "suy"));
1283
- var $R54 = $R(new RegExp("[!~+-](?!\\s|[!~+-]*&)", "suy"));
1284
- var $R55 = $R(new RegExp("(?:-[^-]|[^-]*)*", "suy"));
1285
- var $R56 = $R(new RegExp("[^{}<>\\r\\n]+", "suy"));
1286
- var $R57 = $R(new RegExp("[+-]?", "suy"));
1287
- var $R58 = $R(new RegExp("[+-]", "suy"));
1288
- var $R59 = $R(new RegExp("#![^\\r\\n]*", "suy"));
1289
- var $R60 = $R(new RegExp("[\\t ]*", "suy"));
1290
- var $R61 = $R(new RegExp("[\\s]*", "suy"));
1291
- var $R62 = $R(new RegExp("\\s+([+-]?)([a-zA-Z0-9-]+)(\\s*=\\s*([a-zA-Z0-9.+-]*))?", "suy"));
1292
- var $R63 = $R(new RegExp("\\r\\n|\\n|\\r|$", "suy"));
1293
- var $R64 = $R(new RegExp("[ \\t]*", "suy"));
1290
+ var $R53 = $R(new RegExp(`"[^"]*"|'[^']*'`, "suy"));
1291
+ var $R54 = $R(new RegExp("[<>]", "suy"));
1292
+ var $R55 = $R(new RegExp("[!~+-](?!\\s|[!~+-]*&)", "suy"));
1293
+ var $R56 = $R(new RegExp("(?:-[^-]|[^-]*)*", "suy"));
1294
+ var $R57 = $R(new RegExp("[^{}<>\\r\\n]+", "suy"));
1295
+ var $R58 = $R(new RegExp("[+-]?", "suy"));
1296
+ var $R59 = $R(new RegExp("[+-]", "suy"));
1297
+ var $R60 = $R(new RegExp("#![^\\r\\n]*", "suy"));
1298
+ var $R61 = $R(new RegExp("[\\t ]*", "suy"));
1299
+ var $R62 = $R(new RegExp("[\\s]*", "suy"));
1300
+ var $R63 = $R(new RegExp("\\s+([+-]?)([a-zA-Z0-9-]+)(\\s*=\\s*([a-zA-Z0-9.+-]*))?", "suy"));
1301
+ var $R64 = $R(new RegExp("\\r\\n|\\n|\\r|$", "suy"));
1302
+ var $R65 = $R(new RegExp("[ \\t]*", "suy"));
1294
1303
  var Program$0 = $TS($S(Reset, Init, __, $Q(TopLevelStatement), __), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
1295
1304
  var statements = $4;
1296
1305
  module2.processProgram(statements);
@@ -1538,6 +1547,9 @@ ${input.slice(result.pos)}
1538
1547
  var ws = $4;
1539
1548
  var args = $5;
1540
1549
  var close = $6;
1550
+ if (args.length === 1 && args[0].type === "IterationExpression" && args[0].subtype !== "DoStatement" && !args[0].async && module2.isEmptyBareBlock(args[0].block)) {
1551
+ return $skip;
1552
+ }
1541
1553
  return [ta?.[0], open, module2.insertTrimmingSpace(ws, ""), args, close];
1542
1554
  });
1543
1555
  function ImplicitArguments(state) {
@@ -1609,7 +1621,7 @@ ${input.slice(result.pos)}
1609
1621
  return result;
1610
1622
  }
1611
1623
  }
1612
- var ForbiddenImplicitCalls$0 = $R$0($EXPECT($R0, fail, "ForbiddenImplicitCalls /(as|for|while|until|of|satisfies|then|when|implements|xor|xnor)(?!\\p{ID_Continue}|[\\u200C\\u200D$])/"));
1624
+ var ForbiddenImplicitCalls$0 = $R$0($EXPECT($R0, fail, "ForbiddenImplicitCalls /(as|of|satisfies|then|when|implements|xor|xnor)(?!\\p{ID_Continue}|[\\u200C\\u200D$])/"));
1613
1625
  var ForbiddenImplicitCalls$1 = $EXPECT($L0, fail, 'ForbiddenImplicitCalls "/ "');
1614
1626
  var ForbiddenImplicitCalls$2 = AtAt;
1615
1627
  var ForbiddenImplicitCalls$3 = $S(Identifier, $EXPECT($L1, fail, 'ForbiddenImplicitCalls "="'), Whitespace);
@@ -5826,10 +5838,10 @@ ${input.slice(result.pos)}
5826
5838
  var Block$0 = ExplicitBlock;
5827
5839
  var Block$1 = ImplicitNestedBlock;
5828
5840
  var Block$2 = ThenClause;
5829
- var Block$3 = $TS($S($Q(TrailingComment), Statement), function($skip, $loc, $0, $1, $2) {
5841
+ var Block$3 = $TS($S($Q(TrailingComment), $N(EOS), Statement), function($skip, $loc, $0, $1, $2, $3) {
5830
5842
  var ws = $1;
5831
- var s = $2;
5832
- const expressions = [$0];
5843
+ var s = $3;
5844
+ const expressions = [[ws, s]];
5833
5845
  return {
5834
5846
  type: "BlockStatement",
5835
5847
  expressions,
@@ -6284,6 +6296,7 @@ ${input.slice(result.pos)}
6284
6296
  var Literal$0 = $TS($S(LiteralContent), function($skip, $loc, $0, $1) {
6285
6297
  return {
6286
6298
  type: "Literal",
6299
+ subtype: $1.type,
6287
6300
  children: $0,
6288
6301
  raw: $1.token
6289
6302
  };
@@ -8993,12 +9006,15 @@ ${input.slice(result.pos)}
8993
9006
  return result;
8994
9007
  }
8995
9008
  }
8996
- var IterationExpression$0 = $TS($S(IterationStatement), function($skip, $loc, $0, $1) {
9009
+ var IterationExpression$0 = $TS($S($E($S(Async, __)), IterationStatement), function($skip, $loc, $0, $1, $2) {
9010
+ var async = $1;
9011
+ var statement = $2;
8997
9012
  return {
8998
9013
  type: "IterationExpression",
8999
- subtype: $1.type,
9000
- children: [$1],
9001
- block: $1.block
9014
+ subtype: statement.type,
9015
+ children: [statement],
9016
+ block: statement.block,
9017
+ async
9002
9018
  };
9003
9019
  });
9004
9020
  function IterationExpression(state) {
@@ -10683,7 +10699,8 @@ ${input.slice(result.pos)}
10683
10699
  return result;
10684
10700
  }
10685
10701
  }
10686
- var ExpressionStatement$0 = Expression;
10702
+ var ExpressionStatement$0 = IterationExpression;
10703
+ var ExpressionStatement$1 = Expression;
10687
10704
  function ExpressionStatement(state) {
10688
10705
  let eventData;
10689
10706
  if (state.events) {
@@ -10695,12 +10712,12 @@ ${input.slice(result.pos)}
10695
10712
  }
10696
10713
  }
10697
10714
  if (state.tokenize) {
10698
- const result = $TOKEN("ExpressionStatement", state, ExpressionStatement$0(state));
10715
+ const result = $TOKEN("ExpressionStatement", state, ExpressionStatement$0(state) || ExpressionStatement$1(state));
10699
10716
  if (state.events)
10700
10717
  state.events.exit?.("ExpressionStatement", state, result, eventData);
10701
10718
  return result;
10702
10719
  } else {
10703
- const result = ExpressionStatement$0(state);
10720
+ const result = ExpressionStatement$0(state) || ExpressionStatement$1(state);
10704
10721
  if (state.events)
10705
10722
  state.events.exit?.("ExpressionStatement", state, result, eventData);
10706
10723
  return result;
@@ -11561,7 +11578,8 @@ ${input.slice(result.pos)}
11561
11578
  var Declaration$1 = ClassDeclaration;
11562
11579
  var Declaration$2 = LexicalDeclaration;
11563
11580
  var Declaration$3 = TypeDeclaration;
11564
- var Declaration$4 = OperatorDeclaration;
11581
+ var Declaration$4 = EnumDeclaration;
11582
+ var Declaration$5 = OperatorDeclaration;
11565
11583
  function Declaration(state) {
11566
11584
  let eventData;
11567
11585
  if (state.events) {
@@ -11573,12 +11591,12 @@ ${input.slice(result.pos)}
11573
11591
  }
11574
11592
  }
11575
11593
  if (state.tokenize) {
11576
- const result = $TOKEN("Declaration", state, Declaration$0(state) || Declaration$1(state) || Declaration$2(state) || Declaration$3(state) || Declaration$4(state));
11594
+ const result = $TOKEN("Declaration", state, Declaration$0(state) || Declaration$1(state) || Declaration$2(state) || Declaration$3(state) || Declaration$4(state) || Declaration$5(state));
11577
11595
  if (state.events)
11578
11596
  state.events.exit?.("Declaration", state, result, eventData);
11579
11597
  return result;
11580
11598
  } else {
11581
- const result = Declaration$0(state) || Declaration$1(state) || Declaration$2(state) || Declaration$3(state) || Declaration$4(state);
11599
+ const result = Declaration$0(state) || Declaration$1(state) || Declaration$2(state) || Declaration$3(state) || Declaration$4(state) || Declaration$5(state);
11582
11600
  if (state.events)
11583
11601
  state.events.exit?.("Declaration", state, result, eventData);
11584
11602
  return result;
@@ -14471,6 +14489,31 @@ ${input.slice(result.pos)}
14471
14489
  return result;
14472
14490
  }
14473
14491
  }
14492
+ var Const$0 = $TS($S($EXPECT($L129, fail, 'Const "const"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
14493
+ return { $loc, token: $1 };
14494
+ });
14495
+ function Const(state) {
14496
+ let eventData;
14497
+ if (state.events) {
14498
+ const result = state.events.enter?.("Const", state);
14499
+ if (result) {
14500
+ if (result.cache)
14501
+ return result.cache;
14502
+ eventData = result.data;
14503
+ }
14504
+ }
14505
+ if (state.tokenize) {
14506
+ const result = $TOKEN("Const", state, Const$0(state));
14507
+ if (state.events)
14508
+ state.events.exit?.("Const", state, result, eventData);
14509
+ return result;
14510
+ } else {
14511
+ const result = Const$0(state);
14512
+ if (state.events)
14513
+ state.events.exit?.("Const", state, result, eventData);
14514
+ return result;
14515
+ }
14516
+ }
14474
14517
  var LetOrConstOrVar$0 = LetOrConst;
14475
14518
  var LetOrConstOrVar$1 = Var;
14476
14519
  function LetOrConstOrVar(state) {
@@ -16242,11 +16285,11 @@ ${input.slice(result.pos)}
16242
16285
  var JSXAttributeValue$2 = JSXFragment;
16243
16286
  var JSXAttributeValue$3 = $TS($S(InsertInlineOpenBrace, InlineJSXAttributeValue, InsertCloseBrace), function($skip, $loc, $0, $1, $2, $3) {
16244
16287
  if ($2.children?.length === 1 && $2.children[0].type === "StringLiteral") {
16245
- return $2.children[0];
16288
+ return $skip;
16246
16289
  }
16247
16290
  return $0;
16248
16291
  });
16249
- var JSXAttributeValue$4 = StringLiteral;
16292
+ var JSXAttributeValue$4 = $R$0($EXPECT($R53, fail, `JSXAttributeValue /"[^"]*"|'[^']*'/`));
16250
16293
  function JSXAttributeValue(state) {
16251
16294
  let eventData;
16252
16295
  if (state.events) {
@@ -16296,7 +16339,7 @@ ${input.slice(result.pos)}
16296
16339
  return result;
16297
16340
  }
16298
16341
  }
16299
- var InlineJSXBinaryOpRHS$0 = $TS($S($N($EXPECT($R53, fail, "InlineJSXBinaryOpRHS /[<>]/")), BinaryOp, InlineJSXUnaryExpression), function($skip, $loc, $0, $1, $2, $3) {
16342
+ var InlineJSXBinaryOpRHS$0 = $TS($S($N($EXPECT($R54, fail, "InlineJSXBinaryOpRHS /[<>]/")), BinaryOp, InlineJSXUnaryExpression), function($skip, $loc, $0, $1, $2, $3) {
16300
16343
  var op = $2;
16301
16344
  var rhs = $3;
16302
16345
  return [[], op, [], rhs];
@@ -16351,7 +16394,7 @@ ${input.slice(result.pos)}
16351
16394
  return result;
16352
16395
  }
16353
16396
  }
16354
- var InlineJSXUnaryOp$0 = $TR($EXPECT($R54, fail, "InlineJSXUnaryOp /[!~+-](?!\\s|[!~+-]*&)/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
16397
+ var InlineJSXUnaryOp$0 = $TR($EXPECT($R55, fail, "InlineJSXUnaryOp /[!~+-](?!\\s|[!~+-]*&)/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
16355
16398
  return { $loc, token: $0 };
16356
16399
  });
16357
16400
  function InlineJSXUnaryOp(state) {
@@ -16796,7 +16839,7 @@ ${input.slice(result.pos)}
16796
16839
  return result;
16797
16840
  }
16798
16841
  }
16799
- var JSXCommentContent$0 = $TR($EXPECT($R55, fail, "JSXCommentContent /(?:-[^-]|[^-]*)*/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
16842
+ var JSXCommentContent$0 = $TR($EXPECT($R56, fail, "JSXCommentContent /(?:-[^-]|[^-]*)*/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
16800
16843
  return { $loc, token: $0.replace(/\*\//g, "* /") };
16801
16844
  });
16802
16845
  function JSXCommentContent(state) {
@@ -16821,7 +16864,7 @@ ${input.slice(result.pos)}
16821
16864
  return result;
16822
16865
  }
16823
16866
  }
16824
- var JSXText$0 = $TR($EXPECT($R56, fail, "JSXText /[^{}<>\\r\\n]+/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
16867
+ var JSXText$0 = $TR($EXPECT($R57, fail, "JSXText /[^{}<>\\r\\n]+/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
16825
16868
  return {
16826
16869
  type: "JSXText",
16827
16870
  token: $0,
@@ -16978,10 +17021,11 @@ ${input.slice(result.pos)}
16978
17021
  }
16979
17022
  }
16980
17023
  var TypeLexicalDeclaration$0 = $S(__, LetOrConstOrVar, TypeDeclarationBinding, $Q($S(CommaDelimiter, __, TypeDeclarationBinding)));
16981
- var TypeLexicalDeclaration$1 = ClassSignature;
16982
- var TypeLexicalDeclaration$2 = $S(Namespace, $Q(TrailingComment), IdentifierName, DeclareBlock);
16983
- var TypeLexicalDeclaration$3 = $S(Module, _, StringLiteral, $E(DeclareBlock));
16984
- var TypeLexicalDeclaration$4 = $S(Global, $E(DeclareBlock));
17024
+ var TypeLexicalDeclaration$1 = $S(__, EnumDeclaration);
17025
+ var TypeLexicalDeclaration$2 = ClassSignature;
17026
+ var TypeLexicalDeclaration$3 = $S(Namespace, $Q(TrailingComment), IdentifierName, DeclareBlock);
17027
+ var TypeLexicalDeclaration$4 = $S(Module, _, StringLiteral, $E(DeclareBlock));
17028
+ var TypeLexicalDeclaration$5 = $S(Global, $E(DeclareBlock));
16985
17029
  function TypeLexicalDeclaration(state) {
16986
17030
  let eventData;
16987
17031
  if (state.events) {
@@ -16993,12 +17037,12 @@ ${input.slice(result.pos)}
16993
17037
  }
16994
17038
  }
16995
17039
  if (state.tokenize) {
16996
- const result = $TOKEN("TypeLexicalDeclaration", state, TypeLexicalDeclaration$0(state) || TypeLexicalDeclaration$1(state) || TypeLexicalDeclaration$2(state) || TypeLexicalDeclaration$3(state) || TypeLexicalDeclaration$4(state));
17040
+ const result = $TOKEN("TypeLexicalDeclaration", state, TypeLexicalDeclaration$0(state) || TypeLexicalDeclaration$1(state) || TypeLexicalDeclaration$2(state) || TypeLexicalDeclaration$3(state) || TypeLexicalDeclaration$4(state) || TypeLexicalDeclaration$5(state));
16997
17041
  if (state.events)
16998
17042
  state.events.exit?.("TypeLexicalDeclaration", state, result, eventData);
16999
17043
  return result;
17000
17044
  } else {
17001
- const result = TypeLexicalDeclaration$0(state) || TypeLexicalDeclaration$1(state) || TypeLexicalDeclaration$2(state) || TypeLexicalDeclaration$3(state) || TypeLexicalDeclaration$4(state);
17045
+ const result = TypeLexicalDeclaration$0(state) || TypeLexicalDeclaration$1(state) || TypeLexicalDeclaration$2(state) || TypeLexicalDeclaration$3(state) || TypeLexicalDeclaration$4(state) || TypeLexicalDeclaration$5(state);
17002
17046
  if (state.events)
17003
17047
  state.events.exit?.("TypeLexicalDeclaration", state, result, eventData);
17004
17048
  return result;
@@ -17098,7 +17142,32 @@ ${input.slice(result.pos)}
17098
17142
  return result;
17099
17143
  }
17100
17144
  }
17101
- var Interface$0 = $TS($S($EXPECT($L172, fail, 'Interface "interface"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
17145
+ var Enum$0 = $TS($S($EXPECT($L172, fail, 'Enum "enum"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
17146
+ return { $loc, token: $1 };
17147
+ });
17148
+ function Enum(state) {
17149
+ let eventData;
17150
+ if (state.events) {
17151
+ const result = state.events.enter?.("Enum", state);
17152
+ if (result) {
17153
+ if (result.cache)
17154
+ return result.cache;
17155
+ eventData = result.data;
17156
+ }
17157
+ }
17158
+ if (state.tokenize) {
17159
+ const result = $TOKEN("Enum", state, Enum$0(state));
17160
+ if (state.events)
17161
+ state.events.exit?.("Enum", state, result, eventData);
17162
+ return result;
17163
+ } else {
17164
+ const result = Enum$0(state);
17165
+ if (state.events)
17166
+ state.events.exit?.("Enum", state, result, eventData);
17167
+ return result;
17168
+ }
17169
+ }
17170
+ var Interface$0 = $TS($S($EXPECT($L173, fail, 'Interface "interface"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
17102
17171
  return { $loc, token: $1 };
17103
17172
  });
17104
17173
  function Interface(state) {
@@ -17123,7 +17192,7 @@ ${input.slice(result.pos)}
17123
17192
  return result;
17124
17193
  }
17125
17194
  }
17126
- var Global$0 = $TS($S($EXPECT($L173, fail, 'Global "global"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
17195
+ var Global$0 = $TS($S($EXPECT($L174, fail, 'Global "global"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
17127
17196
  return { $loc, token: $1 };
17128
17197
  });
17129
17198
  function Global(state) {
@@ -17148,7 +17217,7 @@ ${input.slice(result.pos)}
17148
17217
  return result;
17149
17218
  }
17150
17219
  }
17151
- var Module$0 = $TS($S($EXPECT($L174, fail, 'Module "module"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
17220
+ var Module$0 = $TS($S($EXPECT($L175, fail, 'Module "module"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
17152
17221
  return { $loc, token: $1 };
17153
17222
  });
17154
17223
  function Module(state) {
@@ -17173,7 +17242,7 @@ ${input.slice(result.pos)}
17173
17242
  return result;
17174
17243
  }
17175
17244
  }
17176
- var Namespace$0 = $TS($S($EXPECT($L175, fail, 'Namespace "namespace"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
17245
+ var Namespace$0 = $TS($S($EXPECT($L176, fail, 'Namespace "namespace"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
17177
17246
  return { $loc, token: $1 };
17178
17247
  });
17179
17248
  function Namespace(state) {
@@ -17322,7 +17391,7 @@ ${input.slice(result.pos)}
17322
17391
  return result;
17323
17392
  }
17324
17393
  }
17325
- var InterfacePropertyDelimiter$0 = $S($Q(_), $C(Semicolon, Comma));
17394
+ var InterfacePropertyDelimiter$0 = $S($E(_), $C(Semicolon, Comma));
17326
17395
  var InterfacePropertyDelimiter$1 = $Y($S(__, CloseBrace));
17327
17396
  var InterfacePropertyDelimiter$2 = $Y(EOS);
17328
17397
  function InterfacePropertyDelimiter(state) {
@@ -17526,7 +17595,221 @@ ${input.slice(result.pos)}
17526
17595
  return result;
17527
17596
  }
17528
17597
  }
17529
- var TypeIndexSignature$0 = $S($E($S($R$0($EXPECT($R57, fail, "TypeIndexSignature /[+-]?/")), $EXPECT($L141, fail, 'TypeIndexSignature "readonly"'), __)), OpenBracket, TypeIndex, CloseBracket, $E($S(__, $R$0($EXPECT($R58, fail, "TypeIndexSignature /[+-]/")), QuestionMark)));
17598
+ var EnumDeclaration$0 = $TS($S($E($S(Const, _)), Enum, $Q(TrailingComment), IdentifierName, EnumBlock), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
17599
+ var isConst = $1;
17600
+ var id = $4;
17601
+ var block = $5;
17602
+ const ts = {
17603
+ ts: true,
17604
+ children: $0
17605
+ };
17606
+ if (isConst)
17607
+ return ts;
17608
+ const names = new Set(block.properties.map((p) => p.name.name));
17609
+ return [
17610
+ ts,
17611
+ {
17612
+ js: true,
17613
+ children: [
17614
+ ["let ", id, " = {};\n"],
17615
+ ...block.properties.map((property, i) => {
17616
+ let init, isString;
17617
+ if (property.init) {
17618
+ init = module2.replaceNodes(
17619
+ structuredClone(property.init),
17620
+ (n) => n.type === "Identifier" && names.has(n.name),
17621
+ (n) => [id, '["', n.name, '"]']
17622
+ );
17623
+ const value = init[init.length - 1];
17624
+ isString = value.type === "TemplateLiteral" || value.type === "Literal" && value.subtype === "StringLiteral";
17625
+ } else {
17626
+ init = i === 0 ? " = 0" : [" = ", id, '["', block.properties[i - 1].name, '"] + 1'];
17627
+ }
17628
+ if (isString) {
17629
+ return [
17630
+ id,
17631
+ '["',
17632
+ property.name,
17633
+ '"]',
17634
+ init,
17635
+ ";\n"
17636
+ ];
17637
+ } else {
17638
+ return [
17639
+ id,
17640
+ "[",
17641
+ id,
17642
+ '["',
17643
+ property.name,
17644
+ '"]',
17645
+ init,
17646
+ '] = "',
17647
+ property.name,
17648
+ '";\n'
17649
+ ];
17650
+ }
17651
+ })
17652
+ ]
17653
+ }
17654
+ ];
17655
+ });
17656
+ function EnumDeclaration(state) {
17657
+ let eventData;
17658
+ if (state.events) {
17659
+ const result = state.events.enter?.("EnumDeclaration", state);
17660
+ if (result) {
17661
+ if (result.cache)
17662
+ return result.cache;
17663
+ eventData = result.data;
17664
+ }
17665
+ }
17666
+ if (state.tokenize) {
17667
+ const result = $TOKEN("EnumDeclaration", state, EnumDeclaration$0(state));
17668
+ if (state.events)
17669
+ state.events.exit?.("EnumDeclaration", state, result, eventData);
17670
+ return result;
17671
+ } else {
17672
+ const result = EnumDeclaration$0(state);
17673
+ if (state.events)
17674
+ state.events.exit?.("EnumDeclaration", state, result, eventData);
17675
+ return result;
17676
+ }
17677
+ }
17678
+ var EnumBlock$0 = $TS($S(__, OpenBrace, NestedEnumProperties, __, CloseBrace), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
17679
+ var props2 = $3;
17680
+ return {
17681
+ properties: props2.properties,
17682
+ children: $0
17683
+ };
17684
+ });
17685
+ var EnumBlock$1 = $TS($S(__, OpenBrace, $Q($S(__, EnumProperty)), __, CloseBrace), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
17686
+ var props2 = $3;
17687
+ return {
17688
+ properties: props2.map((p) => p[1]),
17689
+ children: $0
17690
+ };
17691
+ });
17692
+ var EnumBlock$2 = $TS($S(InsertOpenBrace, NestedEnumProperties, InsertNewline, InsertIndent, InsertCloseBrace), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
17693
+ var props2 = $2;
17694
+ return {
17695
+ properties: props2.properties,
17696
+ children: $0
17697
+ };
17698
+ });
17699
+ function EnumBlock(state) {
17700
+ let eventData;
17701
+ if (state.events) {
17702
+ const result = state.events.enter?.("EnumBlock", state);
17703
+ if (result) {
17704
+ if (result.cache)
17705
+ return result.cache;
17706
+ eventData = result.data;
17707
+ }
17708
+ }
17709
+ if (state.tokenize) {
17710
+ const result = $TOKEN("EnumBlock", state, EnumBlock$0(state) || EnumBlock$1(state) || EnumBlock$2(state));
17711
+ if (state.events)
17712
+ state.events.exit?.("EnumBlock", state, result, eventData);
17713
+ return result;
17714
+ } else {
17715
+ const result = EnumBlock$0(state) || EnumBlock$1(state) || EnumBlock$2(state);
17716
+ if (state.events)
17717
+ state.events.exit?.("EnumBlock", state, result, eventData);
17718
+ return result;
17719
+ }
17720
+ }
17721
+ var NestedEnumProperties$0 = $TS($S(PushIndent, $Q(NestedEnumProperty), PopIndent), function($skip, $loc, $0, $1, $2, $3) {
17722
+ var props2 = $2;
17723
+ if (!props2.length)
17724
+ return $skip;
17725
+ return {
17726
+ properties: props2.map((p) => p.property),
17727
+ children: $0
17728
+ };
17729
+ });
17730
+ function NestedEnumProperties(state) {
17731
+ let eventData;
17732
+ if (state.events) {
17733
+ const result = state.events.enter?.("NestedEnumProperties", state);
17734
+ if (result) {
17735
+ if (result.cache)
17736
+ return result.cache;
17737
+ eventData = result.data;
17738
+ }
17739
+ }
17740
+ if (state.tokenize) {
17741
+ const result = $TOKEN("NestedEnumProperties", state, NestedEnumProperties$0(state));
17742
+ if (state.events)
17743
+ state.events.exit?.("NestedEnumProperties", state, result, eventData);
17744
+ return result;
17745
+ } else {
17746
+ const result = NestedEnumProperties$0(state);
17747
+ if (state.events)
17748
+ state.events.exit?.("NestedEnumProperties", state, result, eventData);
17749
+ return result;
17750
+ }
17751
+ }
17752
+ var NestedEnumProperty$0 = $TS($S(Nested, EnumProperty), function($skip, $loc, $0, $1, $2) {
17753
+ return {
17754
+ property: $2,
17755
+ children: $0
17756
+ };
17757
+ });
17758
+ function NestedEnumProperty(state) {
17759
+ let eventData;
17760
+ if (state.events) {
17761
+ const result = state.events.enter?.("NestedEnumProperty", state);
17762
+ if (result) {
17763
+ if (result.cache)
17764
+ return result.cache;
17765
+ eventData = result.data;
17766
+ }
17767
+ }
17768
+ if (state.tokenize) {
17769
+ const result = $TOKEN("NestedEnumProperty", state, NestedEnumProperty$0(state));
17770
+ if (state.events)
17771
+ state.events.exit?.("NestedEnumProperty", state, result, eventData);
17772
+ return result;
17773
+ } else {
17774
+ const result = NestedEnumProperty$0(state);
17775
+ if (state.events)
17776
+ state.events.exit?.("NestedEnumProperty", state, result, eventData);
17777
+ return result;
17778
+ }
17779
+ }
17780
+ var EnumProperty$0 = $TS($S(Identifier, $E($S(__, Equals, ExtendedExpression)), ObjectPropertyDelimiter), function($skip, $loc, $0, $1, $2, $3) {
17781
+ var name = $1;
17782
+ var init = $2;
17783
+ return {
17784
+ type: "EnumProperty",
17785
+ name,
17786
+ init,
17787
+ children: $0
17788
+ };
17789
+ });
17790
+ function EnumProperty(state) {
17791
+ let eventData;
17792
+ if (state.events) {
17793
+ const result = state.events.enter?.("EnumProperty", state);
17794
+ if (result) {
17795
+ if (result.cache)
17796
+ return result.cache;
17797
+ eventData = result.data;
17798
+ }
17799
+ }
17800
+ if (state.tokenize) {
17801
+ const result = $TOKEN("EnumProperty", state, EnumProperty$0(state));
17802
+ if (state.events)
17803
+ state.events.exit?.("EnumProperty", state, result, eventData);
17804
+ return result;
17805
+ } else {
17806
+ const result = EnumProperty$0(state);
17807
+ if (state.events)
17808
+ state.events.exit?.("EnumProperty", state, result, eventData);
17809
+ return result;
17810
+ }
17811
+ }
17812
+ var TypeIndexSignature$0 = $S($E($S($R$0($EXPECT($R58, fail, "TypeIndexSignature /[+-]?/")), $EXPECT($L141, fail, 'TypeIndexSignature "readonly"'), __)), OpenBracket, TypeIndex, CloseBracket, $E($S(__, $R$0($EXPECT($R59, fail, "TypeIndexSignature /[+-]/")), QuestionMark)));
17530
17813
  function TypeIndexSignature(state) {
17531
17814
  let eventData;
17532
17815
  if (state.events) {
@@ -17604,7 +17887,7 @@ ${input.slice(result.pos)}
17604
17887
  return result;
17605
17888
  }
17606
17889
  }
17607
- var ReturnTypeSuffix$0 = $TS($S($E(_), Colon, $E($S(__, $EXPECT($L176, fail, 'ReturnTypeSuffix "asserts"'), NonIdContinue)), TypePredicate), function($skip, $loc, $0, $1, $2, $3, $4) {
17890
+ var ReturnTypeSuffix$0 = $TS($S($E(_), Colon, $E($S(__, $EXPECT($L177, fail, 'ReturnTypeSuffix "asserts"'), NonIdContinue)), TypePredicate), function($skip, $loc, $0, $1, $2, $3, $4) {
17608
17891
  var asserts = $3;
17609
17892
  var t = $4;
17610
17893
  if (asserts) {
@@ -17778,9 +18061,9 @@ ${input.slice(result.pos)}
17778
18061
  return result;
17779
18062
  }
17780
18063
  }
17781
- var TypeUnaryOp$0 = $S($EXPECT($L177, fail, 'TypeUnaryOp "keyof"'), NonIdContinue);
18064
+ var TypeUnaryOp$0 = $S($EXPECT($L178, fail, 'TypeUnaryOp "keyof"'), NonIdContinue);
17782
18065
  var TypeUnaryOp$1 = $S($EXPECT($L157, fail, 'TypeUnaryOp "typeof"'), NonIdContinue);
17783
- var TypeUnaryOp$2 = $S($EXPECT($L178, fail, 'TypeUnaryOp "infer"'), NonIdContinue);
18066
+ var TypeUnaryOp$2 = $S($EXPECT($L179, fail, 'TypeUnaryOp "infer"'), NonIdContinue);
17784
18067
  var TypeUnaryOp$3 = $S($EXPECT($L141, fail, 'TypeUnaryOp "readonly"'), NonIdContinue);
17785
18068
  function TypeUnaryOp(state) {
17786
18069
  let eventData;
@@ -18026,7 +18309,7 @@ ${input.slice(result.pos)}
18026
18309
  var TypeLiteral$2 = $TS($S($EXPECT($L161, fail, 'TypeLiteral "void"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
18027
18310
  return { type: "VoidType", $loc, token: $1 };
18028
18311
  });
18029
- var TypeLiteral$3 = $TV($EXPECT($L179, fail, 'TypeLiteral "[]"'), function($skip, $loc, $0, $1) {
18312
+ var TypeLiteral$3 = $TV($EXPECT($L180, fail, 'TypeLiteral "[]"'), function($skip, $loc, $0, $1) {
18030
18313
  return { $loc, token: "[]" };
18031
18314
  });
18032
18315
  function TypeLiteral(state) {
@@ -18433,7 +18716,7 @@ ${input.slice(result.pos)}
18433
18716
  return result;
18434
18717
  }
18435
18718
  }
18436
- var Shebang$0 = $S($R$0($EXPECT($R59, fail, "Shebang /#![^\\r\\n]*/")), EOL);
18719
+ var Shebang$0 = $S($R$0($EXPECT($R60, fail, "Shebang /#![^\\r\\n]*/")), EOL);
18437
18720
  function Shebang(state) {
18438
18721
  let eventData;
18439
18722
  if (state.events) {
@@ -18456,11 +18739,11 @@ ${input.slice(result.pos)}
18456
18739
  return result;
18457
18740
  }
18458
18741
  }
18459
- var CivetPrologue$0 = $T($S($EXPECT($R60, fail, "CivetPrologue /[\\t ]*/"), DoubleQuote, CivetPrologueContent, DoubleQuote, $TEXT(SimpleStatementDelimiter), $E(EOS)), function(value) {
18742
+ var CivetPrologue$0 = $T($S($EXPECT($R61, fail, "CivetPrologue /[\\t ]*/"), DoubleQuote, CivetPrologueContent, DoubleQuote, $TEXT(SimpleStatementDelimiter), $E(EOS)), function(value) {
18460
18743
  var content = value[2];
18461
18744
  return content;
18462
18745
  });
18463
- var CivetPrologue$1 = $T($S($EXPECT($R60, fail, "CivetPrologue /[\\t ]*/"), SingleQuote, CivetPrologueContent, SingleQuote, $TEXT(SimpleStatementDelimiter), $E(EOS)), function(value) {
18746
+ var CivetPrologue$1 = $T($S($EXPECT($R61, fail, "CivetPrologue /[\\t ]*/"), SingleQuote, CivetPrologueContent, SingleQuote, $TEXT(SimpleStatementDelimiter), $E(EOS)), function(value) {
18464
18747
  var content = value[2];
18465
18748
  return content;
18466
18749
  });
@@ -18486,7 +18769,7 @@ ${input.slice(result.pos)}
18486
18769
  return result;
18487
18770
  }
18488
18771
  }
18489
- 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) {
18772
+ var CivetPrologueContent$0 = $TS($S($EXPECT($L181, fail, 'CivetPrologueContent "civet"'), NonIdContinue, $Q(CivetOption), $EXPECT($R62, fail, "CivetPrologueContent /[\\s]*/")), function($skip, $loc, $0, $1, $2, $3, $4) {
18490
18773
  var options = $3;
18491
18774
  return {
18492
18775
  type: "CivetPrologue",
@@ -18516,7 +18799,7 @@ ${input.slice(result.pos)}
18516
18799
  return result;
18517
18800
  }
18518
18801
  }
18519
- var CivetOption$0 = $TR($EXPECT($R62, fail, "CivetOption /\\s+([+-]?)([a-zA-Z0-9-]+)(\\s*=\\s*([a-zA-Z0-9.+-]*))?/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
18802
+ var CivetOption$0 = $TR($EXPECT($R63, fail, "CivetOption /\\s+([+-]?)([a-zA-Z0-9-]+)(\\s*=\\s*([a-zA-Z0-9.+-]*))?/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
18520
18803
  const optionName = $2.replace(/-+([a-z]?)/g, (_2, l) => {
18521
18804
  if (l)
18522
18805
  return l.toUpperCase();
@@ -18552,7 +18835,7 @@ ${input.slice(result.pos)}
18552
18835
  return result;
18553
18836
  }
18554
18837
  }
18555
- var UnknownPrologue$0 = $S($R$0($EXPECT($R60, fail, "UnknownPrologue /[\\t ]*/")), StringLiteral, $TEXT(SimpleStatementDelimiter), EOS);
18838
+ var UnknownPrologue$0 = $S($R$0($EXPECT($R61, fail, "UnknownPrologue /[\\t ]*/")), StringLiteral, $TEXT(SimpleStatementDelimiter), EOS);
18556
18839
  function UnknownPrologue(state) {
18557
18840
  let eventData;
18558
18841
  if (state.events) {
@@ -18622,7 +18905,7 @@ ${input.slice(result.pos)}
18622
18905
  return result;
18623
18906
  }
18624
18907
  }
18625
- var EOL$0 = $TR($EXPECT($R63, fail, "EOL /\\r\\n|\\n|\\r|$/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
18908
+ var EOL$0 = $TR($EXPECT($R64, fail, "EOL /\\r\\n|\\n|\\r|$/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
18626
18909
  return { $loc, token: $0 };
18627
18910
  });
18628
18911
  function EOL(state) {
@@ -19776,6 +20059,9 @@ ${input.slice(result.pos)}
19776
20059
  module2.modifyString = function(str) {
19777
20060
  return str.replace(/(^.?|[^\\]{2})(\\\\)*\n/g, "$1$2\\n");
19778
20061
  };
20062
+ module2.unmodifyString = function(str) {
20063
+ return str.replace(/\\n/g, "\n");
20064
+ };
19779
20065
  module2.quoteString = function(str) {
19780
20066
  str = str.replace(/\\/g, "\\\\");
19781
20067
  if (str.includes('"') && !str.includes("'")) {
@@ -19927,6 +20213,20 @@ ${input.slice(result.pos)}
19927
20213
  return { children };
19928
20214
  }
19929
20215
  };
20216
+ module2.needsRef = function(expression, base = "ref") {
20217
+ switch (expression.type) {
20218
+ case "Ref":
20219
+ case "Identifier":
20220
+ case "Literal":
20221
+ return;
20222
+ default:
20223
+ return {
20224
+ type: "Ref",
20225
+ base,
20226
+ id: base
20227
+ };
20228
+ }
20229
+ };
19930
20230
  module2.literalValue = function(literal) {
19931
20231
  let { raw } = literal;
19932
20232
  switch (raw) {
@@ -20006,7 +20306,7 @@ ${input.slice(result.pos)}
20006
20306
  const i = exp.children.indexOf(exp.block);
20007
20307
  if (exp.subtype === "DoStatement") {
20008
20308
  insertReturn(exp.block);
20009
- exp.children.splice(i, 1, ...module2.wrapIIFE(exp.children));
20309
+ exp.children.splice(i, 1, ...module2.wrapIIFE(exp.children, exp.async));
20010
20310
  return;
20011
20311
  }
20012
20312
  const resultsRef = {
@@ -20015,16 +20315,28 @@ ${input.slice(result.pos)}
20015
20315
  id: "results"
20016
20316
  };
20017
20317
  insertPush(exp.block, resultsRef);
20018
- exp.children.splice(i, 1, module2.wrapIIFE(
20019
- ["const ", resultsRef, "=[];", ...exp.children, "; return ", resultsRef]
20020
- ));
20318
+ exp.children.splice(
20319
+ i,
20320
+ 1,
20321
+ module2.wrapIIFE([
20322
+ "const ",
20323
+ resultsRef,
20324
+ "=[];",
20325
+ ...exp.children,
20326
+ "; return ",
20327
+ resultsRef
20328
+ ], exp.async)
20329
+ );
20021
20330
  }
20022
20331
  module2.hasAwait = (exp) => {
20023
20332
  return gatherRecursiveWithinFunction(exp, ({ type }) => type === "Await").length > 0;
20024
20333
  };
20025
- module2.wrapIIFE = (exp) => {
20334
+ module2.wrapIIFE = (exp, async) => {
20026
20335
  let prefix, suffix;
20027
- if (module2.hasAwait(exp)) {
20336
+ if (async) {
20337
+ prefix = "(async ()=>{";
20338
+ suffix = "})()";
20339
+ } else if (module2.hasAwait(exp)) {
20028
20340
  prefix = "(await (async ()=>{";
20029
20341
  suffix = "})())";
20030
20342
  } else {
@@ -20232,6 +20544,7 @@ ${input.slice(result.pos)}
20232
20544
  }
20233
20545
  module2.makeLeftHandSideExpression = function(expression) {
20234
20546
  switch (expression.type) {
20547
+ case "Ref":
20235
20548
  case "Identifier":
20236
20549
  case "Literal":
20237
20550
  case "CallExpression":
@@ -20268,6 +20581,12 @@ ${input.slice(result.pos)}
20268
20581
  s = s[0];
20269
20582
  return s.token?.startsWith?.("`");
20270
20583
  };
20584
+ module2.isEmptyBareBlock = function(node) {
20585
+ if (node?.type !== "BlockStatement")
20586
+ return false;
20587
+ const { bare, expressions } = node;
20588
+ return bare && (expressions.length === 0 || expressions.length === 1 && expressions[0][1]?.type === "EmptyStatement");
20589
+ };
20271
20590
  module2.processBinaryOpExpression = function($02) {
20272
20591
  const expandedOps = module2.expandChainedComparisons($02);
20273
20592
  let i = 2;
@@ -20616,14 +20935,14 @@ ${input.slice(result.pos)}
20616
20935
  if (node == null)
20617
20936
  return [];
20618
20937
  if (Array.isArray(node)) {
20619
- return node.flatMap((n) => gatherRecursive(n, predicate));
20938
+ return node.flatMap((n) => gatherRecursive(n, predicate, skipPredicate));
20620
20939
  }
20621
20940
  if (skipPredicate?.(node))
20622
20941
  return [];
20623
20942
  if (predicate(node)) {
20624
20943
  return [node];
20625
20944
  }
20626
- return gatherRecursive(node.children, predicate);
20945
+ return gatherRecursive(node.children, predicate, skipPredicate);
20627
20946
  }
20628
20947
  function gatherRecursiveAll(node, predicate) {
20629
20948
  if (node == null)
@@ -20637,8 +20956,9 @@ ${input.slice(result.pos)}
20637
20956
  }
20638
20957
  return nodes;
20639
20958
  }
20640
- function isFunction({ type }) {
20641
- return type === "FunctionExpression" || type === "ArrowFunction" || type === "MethodDefinition";
20959
+ function isFunction(node) {
20960
+ const { type } = node;
20961
+ return type === "FunctionExpression" || type === "ArrowFunction" || type === "MethodDefinition" || node.async;
20642
20962
  }
20643
20963
  function gatherRecursiveWithinFunction(node, predicate) {
20644
20964
  return gatherRecursive(node, predicate, isFunction);
@@ -20661,6 +20981,28 @@ ${input.slice(result.pos)}
20661
20981
  }
20662
20982
  }
20663
20983
  }
20984
+ function removeParentPointers(node) {
20985
+ if (node == null)
20986
+ return;
20987
+ if (typeof node !== "object")
20988
+ return;
20989
+ if (Array.isArray(node)) {
20990
+ for (const child of node) {
20991
+ removeParentPointers(child);
20992
+ }
20993
+ return;
20994
+ }
20995
+ node.parent = null;
20996
+ if (node.children) {
20997
+ for (const child of node.children) {
20998
+ removeParentPointers(child);
20999
+ }
21000
+ }
21001
+ }
21002
+ function clone(node) {
21003
+ removeParentPointers(node);
21004
+ return structuredClone(node);
21005
+ }
20664
21006
  function findAncestor(node, predicate, stopPredicate) {
20665
21007
  node = node.parent;
20666
21008
  while (node && !stopPredicate?.(node)) {
@@ -20669,6 +21011,23 @@ ${input.slice(result.pos)}
20669
21011
  node = node.parent;
20670
21012
  }
20671
21013
  }
21014
+ module2.replaceNodes = (root, predicate, replacer) => {
21015
+ if (root == null)
21016
+ return root;
21017
+ const array = Array.isArray(root) ? root : root.children;
21018
+ if (!array)
21019
+ return root;
21020
+ array.forEach((node, i) => {
21021
+ if (node == null)
21022
+ return;
21023
+ if (predicate(node)) {
21024
+ array[i] = replacer(node, root);
21025
+ } else {
21026
+ module2.replaceNodes(node, predicate, replacer);
21027
+ }
21028
+ });
21029
+ return root;
21030
+ };
20672
21031
  function processParams(f) {
20673
21032
  const { type, parameters, block } = f;
20674
21033
  if (type === "ArrowFunction" && parameters && parameters.tp && parameters.tp.parameters.length === 1) {
@@ -21161,6 +21520,22 @@ ${input.slice(result.pos)}
21161
21520
  }
21162
21521
  }
21163
21522
  propsGroupedByName.forEach((shared, key) => {
21523
+ if (!key)
21524
+ return;
21525
+ if (ReservedWord({
21526
+ pos: 0,
21527
+ input: key
21528
+ })) {
21529
+ shared.forEach((p) => {
21530
+ const ref = {
21531
+ type: "Ref",
21532
+ base: `_${key}`,
21533
+ id: key
21534
+ };
21535
+ p.children.push(": ", ref);
21536
+ });
21537
+ return;
21538
+ }
21164
21539
  if (shared.length === 1)
21165
21540
  return;
21166
21541
  const refs = shared.map((p) => {
@@ -21202,19 +21577,7 @@ ${input.slice(result.pos)}
21202
21577
  if (expression.type === "ParenthesizedExpression") {
21203
21578
  expression = expression.expression;
21204
21579
  }
21205
- let ref;
21206
- switch (expression.type) {
21207
- case "Identifier":
21208
- case "Literal":
21209
- ref = expression;
21210
- break;
21211
- default:
21212
- ref = {
21213
- type: "Ref",
21214
- base: "m",
21215
- id: "m"
21216
- };
21217
- }
21580
+ let ref = module2.needsRef(expression, "m") || expression;
21218
21581
  let prev = [], root = prev;
21219
21582
  const l = clauses.length;
21220
21583
  clauses.forEach((c, i) => {
@@ -21285,29 +21648,96 @@ ${input.slice(result.pos)}
21285
21648
  const [ws, , body] = s.children;
21286
21649
  let [, arg] = s.children;
21287
21650
  let i = 0, l = body.length;
21288
- const children = [ws];
21651
+ const refDec = [];
21652
+ const children = [ws, refDec];
21653
+ let usingRef = null;
21289
21654
  for (i = 0; i < l; i++) {
21290
21655
  const step = body[i];
21291
21656
  const [leadingComment, pipe, trailingComment, expr] = step;
21292
21657
  const returns = pipe.token === "||>";
21658
+ let ref, result, returning = returns ? arg : null;
21293
21659
  if (pipe.token === "|>=") {
21660
+ let initRef;
21294
21661
  if (i === 0) {
21295
- children.push(arg, " = ");
21662
+ outer:
21663
+ switch (arg.type) {
21664
+ case "MemberExpression":
21665
+ if (arg.children.length <= 2)
21666
+ break;
21667
+ case "CallExpression":
21668
+ const access = arg.children.pop();
21669
+ switch (access.type) {
21670
+ case "PropertyAccess":
21671
+ case "SliceExpression":
21672
+ break;
21673
+ default:
21674
+ children.unshift({
21675
+ type: "Error",
21676
+ $loc: pipe.token.$loc,
21677
+ message: `Can't assign to ${access.type}`
21678
+ });
21679
+ arg.children.push(access);
21680
+ break outer;
21681
+ }
21682
+ usingRef = module2.needsRef({});
21683
+ initRef = {
21684
+ type: "AssignmentExpression",
21685
+ children: [usingRef, " = ", arg, ","]
21686
+ };
21687
+ arg = {
21688
+ type: "MemberExpression",
21689
+ children: [usingRef, access]
21690
+ };
21691
+ break;
21692
+ }
21693
+ children.pop();
21694
+ const lhs = [[
21695
+ [refDec, initRef],
21696
+ arg,
21697
+ [],
21698
+ { token: "=", children: [" = "] }
21699
+ ]];
21700
+ Object.assign(s, {
21701
+ type: "AssignmentExpression",
21702
+ children: [lhs, children],
21703
+ names: null,
21704
+ lhs,
21705
+ assigned: arg,
21706
+ exp: children
21707
+ });
21708
+ arg = clone(arg);
21709
+ if (arg.children[0].type === "Ref") {
21710
+ arg.children[0] = usingRef;
21711
+ }
21296
21712
  } else {
21297
- children.push({
21713
+ children.unshift({
21298
21714
  type: "Error",
21715
+ $loc: pipe.token.$loc,
21299
21716
  message: "Can't use |>= in the middle of a pipeline"
21300
21717
  });
21301
21718
  }
21719
+ } else {
21720
+ s.children = children;
21302
21721
  }
21303
- const [result, returning] = module2.constructPipeStep(
21722
+ if (returns && (ref = module2.needsRef(arg))) {
21723
+ usingRef = usingRef || ref;
21724
+ arg = {
21725
+ type: "ParenthesizedExpression",
21726
+ children: ["(", {
21727
+ type: "AssignmentExpression",
21728
+ children: [usingRef, " = ", arg]
21729
+ }, ")"]
21730
+ };
21731
+ returning = usingRef;
21732
+ }
21733
+ [result, returning] = module2.constructPipeStep(
21304
21734
  {
21305
21735
  leadingComment: module2.skipIfOnlyWS(leadingComment),
21306
21736
  trailingComment: module2.skipIfOnlyWS(trailingComment),
21307
21737
  expr
21308
21738
  },
21309
21739
  arg,
21310
- returns ? arg : null
21740
+ returning
21311
21741
  );
21312
21742
  if (result.type === "ReturnStatement") {
21313
21743
  if (i < l - 1) {
@@ -21330,8 +21760,10 @@ ${input.slice(result.pos)}
21330
21760
  arg = result;
21331
21761
  }
21332
21762
  }
21763
+ if (usingRef) {
21764
+ refDec.unshift("let ", usingRef, ";");
21765
+ }
21333
21766
  children.push(arg);
21334
- s.children = children;
21335
21767
  addParentPointers(s, s.parent);
21336
21768
  });
21337
21769
  }
@@ -21620,7 +22052,7 @@ ${input.slice(result.pos)}
21620
22052
  return result;
21621
22053
  }
21622
22054
  }
21623
- var Indent$0 = $TR($EXPECT($R64, fail, "Indent /[ \\t]*/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
22055
+ var Indent$0 = $TR($EXPECT($R65, fail, "Indent /[ \\t]*/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
21624
22056
  let level;
21625
22057
  if (module2.config.tab) {
21626
22058
  const tabs = $0.match(/\t/g);