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