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