@danielx/civet 0.6.13 → 0.6.15

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
@@ -208,7 +208,7 @@ var require_lib = __commonJS({
208
208
  ref.children = [makeLeftHandSideExpression(arg)];
209
209
  return {
210
210
  type: "UnwrappedExpression",
211
- children: [skipIfOnlyWS(fn.leadingComment), ...body, skipIfOnlyWS(fn.trailingComment)]
211
+ children: [skipIfOnlyWS(fn.leadingComment), body, skipIfOnlyWS(fn.trailingComment)]
212
212
  };
213
213
  }
214
214
  expr = fn.expr;
@@ -630,12 +630,20 @@ var require_lib = __commonJS({
630
630
  children
631
631
  };
632
632
  }
633
+ function isExistence(exp) {
634
+ if (exp.type === "ParenthesizedExpression" && exp.implicit) {
635
+ exp = exp.expression;
636
+ }
637
+ if (exp.type === "Existence") {
638
+ return exp;
639
+ }
640
+ }
633
641
  function expandChainedComparisons([first, binops]) {
634
642
  const relationalOps = ["==", "===", "!=", "!==", "<", "<=", ">", ">=", "in"];
635
643
  const lowerPrecedenceOps = ["??", "&&", "||", "&", "|", "^"];
636
644
  let results = [];
637
645
  let i = 0;
638
- let l = binops.length;
646
+ const l = binops.length;
639
647
  let start = 0;
640
648
  let chains = [];
641
649
  while (i < l) {
@@ -651,12 +659,15 @@ var require_lib = __commonJS({
651
659
  processChains();
652
660
  return results;
653
661
  function processChains() {
662
+ first = expandExistence(first);
654
663
  if (chains.length > 1) {
655
664
  chains.forEach((index, k) => {
656
665
  if (k > 0) {
657
666
  results.push(" ", "&&", " ");
658
667
  }
659
- const [pre, op, post, exp] = binops[index];
668
+ const binop = binops[index];
669
+ let [pre, op, post, exp] = binop;
670
+ exp = binop[3] = expandExistence(exp);
660
671
  let endIndex;
661
672
  if (k < chains.length - 1) {
662
673
  endIndex = chains[k + 1];
@@ -673,6 +684,14 @@ var require_lib = __commonJS({
673
684
  }
674
685
  chains.length = 0;
675
686
  }
687
+ function expandExistence(exp) {
688
+ const existence = isExistence(exp);
689
+ if (existence) {
690
+ results.push(existence, " ", "&&", " ");
691
+ return existence.expression;
692
+ }
693
+ return exp;
694
+ }
676
695
  }
677
696
  function processParams(f) {
678
697
  const { type, parameters, block } = f;
@@ -1125,8 +1144,10 @@ var require_lib = __commonJS({
1125
1144
  function makeLeftHandSideExpression(expression) {
1126
1145
  switch (expression.type) {
1127
1146
  case "Ref":
1147
+ case "AmpersandRef":
1128
1148
  case "Identifier":
1129
1149
  case "Literal":
1150
+ case "IterationExpression":
1130
1151
  case "CallExpression":
1131
1152
  case "MemberExpression":
1132
1153
  case "ParenthesizedExpression":
@@ -1139,7 +1160,8 @@ var require_lib = __commonJS({
1139
1160
  return {
1140
1161
  type: "ParenthesizedExpression",
1141
1162
  children: ["(", expression, ")"],
1142
- expression
1163
+ expression,
1164
+ implicit: true
1143
1165
  };
1144
1166
  }
1145
1167
  }
@@ -1402,6 +1424,46 @@ var require_lib = __commonJS({
1402
1424
  tail.push(...splices.map((s) => [", ", s]), ...thisAssignments.map((a) => [", ", a]));
1403
1425
  }
1404
1426
  function processAssignments(statements) {
1427
+ gatherRecursiveAll(statements, (n) => n.type === "AssignmentExpression" || n.type === "UpdateExpression").forEach((exp) => {
1428
+ function extractAssignment(lhs) {
1429
+ let expr = lhs;
1430
+ while (expr.type === "ParenthesizedExpression") {
1431
+ expr = expr.expression;
1432
+ }
1433
+ if (expr.type === "AssignmentExpression" || expr.type === "UpdateExpression") {
1434
+ if (expr.type === "UpdateExpression" && expr.children[0] === expr.assigned) {
1435
+ post.push([", ", lhs]);
1436
+ } else {
1437
+ pre.push([lhs, ", "]);
1438
+ }
1439
+ return expr.assigned;
1440
+ }
1441
+ }
1442
+ const pre = [], post = [];
1443
+ switch (exp.type) {
1444
+ case "AssignmentExpression":
1445
+ if (!exp.lhs)
1446
+ return;
1447
+ exp.lhs.forEach((lhsPart, i) => {
1448
+ let newLhs2 = extractAssignment(lhsPart[1]);
1449
+ if (newLhs2) {
1450
+ lhsPart[1] = newLhs2;
1451
+ }
1452
+ });
1453
+ break;
1454
+ case "UpdateExpression":
1455
+ let newLhs = extractAssignment(exp.assigned);
1456
+ if (newLhs) {
1457
+ const i = exp.children.indexOf(exp.assigned);
1458
+ exp.assigned = exp.children[i] = newLhs;
1459
+ }
1460
+ break;
1461
+ }
1462
+ if (pre.length)
1463
+ exp.children.unshift(...pre);
1464
+ if (post.length)
1465
+ exp.children.push(...post);
1466
+ });
1405
1467
  gatherRecursiveAll(statements, (n) => n.type === "AssignmentExpression" && n.names === null).forEach((exp) => {
1406
1468
  let { lhs: $1, exp: $2 } = exp, tail = [], i = 0, len = $1.length;
1407
1469
  if ($1.some((left) => left[left.length - 1].special)) {
@@ -1411,7 +1473,14 @@ var require_lib = __commonJS({
1411
1473
  const [, lhs, , op] = $1[0];
1412
1474
  const { call } = op;
1413
1475
  op[op.length - 1] = "=";
1414
- $2 = [call, "(", lhs, ", ", $2, ")"];
1476
+ const index2 = exp.children.indexOf($2);
1477
+ if (index2 < 0)
1478
+ throw new Error("Assertion error: exp not in AssignmentExpression");
1479
+ exp.children.splice(
1480
+ index2,
1481
+ 1,
1482
+ exp.exp = $2 = [call, "(", lhs, ", ", $2, ")"]
1483
+ );
1415
1484
  }
1416
1485
  let wrapped = false;
1417
1486
  while (i < len) {
@@ -1462,49 +1531,11 @@ var require_lib = __commonJS({
1462
1531
  }
1463
1532
  i--;
1464
1533
  }
1465
- const names = $1.flatMap(([, l]) => l.names || []);
1466
- exp.children = [$1, $2, ...tail];
1467
- exp.names = names;
1468
- });
1469
- gatherRecursiveAll(statements, (n) => n.type === "AssignmentExpression" || n.type === "UpdateExpression").forEach((exp) => {
1470
- function extractAssignment(lhs) {
1471
- let expr = lhs;
1472
- while (expr.type === "ParenthesizedExpression") {
1473
- expr = expr.expression;
1474
- }
1475
- if (expr.type === "AssignmentExpression" || expr.type === "UpdateExpression") {
1476
- if (expr.type === "UpdateExpression" && expr.children[0] === expr.assigned) {
1477
- post.push([", ", lhs]);
1478
- } else {
1479
- pre.push([lhs, ", "]);
1480
- }
1481
- return expr.assigned;
1482
- }
1483
- }
1484
- const pre = [], post = [];
1485
- switch (exp.type) {
1486
- case "AssignmentExpression":
1487
- if (!exp.lhs)
1488
- return;
1489
- exp.lhs.forEach((lhsPart, i) => {
1490
- let newLhs2 = extractAssignment(lhsPart[1]);
1491
- if (newLhs2) {
1492
- lhsPart[1] = newLhs2;
1493
- }
1494
- });
1495
- break;
1496
- case "UpdateExpression":
1497
- let newLhs = extractAssignment(exp.assigned);
1498
- if (newLhs) {
1499
- const i = exp.children.indexOf(exp.assigned);
1500
- exp.assigned = exp.children[i] = newLhs;
1501
- }
1502
- break;
1503
- }
1504
- if (pre.length)
1505
- exp.children.unshift(...pre);
1506
- if (post.length)
1507
- exp.children.push(...post);
1534
+ exp.names = $1.flatMap(([, l]) => l.names || []);
1535
+ const index = exp.children.indexOf($2);
1536
+ if (index < 0)
1537
+ throw new Error("Assertion error: exp not in AssignmentExpression");
1538
+ exp.children.splice(index + 1, 0, ...tail);
1508
1539
  });
1509
1540
  }
1510
1541
  function attachPostfixStatementAsExpression(exp, post) {
@@ -1951,7 +1982,8 @@ var require_lib = __commonJS({
1951
1982
  });
1952
1983
  }
1953
1984
  } else {
1954
- s.children = children;
1985
+ if (i === 0)
1986
+ s.children = children;
1955
1987
  }
1956
1988
  if (returns && (ref = needsRef(arg))) {
1957
1989
  usingRef = usingRef || ref;
@@ -2247,27 +2279,20 @@ var require_lib = __commonJS({
2247
2279
  if (post?.token === "?") {
2248
2280
  post = {
2249
2281
  $loc: post.$loc,
2250
- token: " != null"
2282
+ token: "!="
2251
2283
  };
2252
- switch (exp.type) {
2253
- case "Identifier":
2254
- case "Literal":
2255
- case "AmpersandRef":
2256
- return {
2257
- ...exp,
2258
- children: [...pre, ...exp.children, post]
2259
- };
2260
- default:
2261
- const expression = {
2262
- ...exp,
2263
- children: [...pre, "(", exp.children, ")", post]
2264
- };
2265
- return {
2266
- type: "ParenthesizedExpression",
2267
- children: ["(", expression, ")"],
2268
- expression
2269
- };
2284
+ if (pre.length) {
2285
+ exp = {
2286
+ type: "UnaryExpression",
2287
+ children: [...pre, exp, void 0]
2288
+ };
2270
2289
  }
2290
+ const existence = {
2291
+ type: "Existence",
2292
+ expression: exp,
2293
+ children: [exp, " ", post, " ", "null"]
2294
+ };
2295
+ return makeLeftHandSideExpression(existence);
2271
2296
  }
2272
2297
  if (exp.type === "Literal") {
2273
2298
  if (pre.length === 1 && pre[0].token === "-") {
@@ -2948,6 +2973,7 @@ ${input.slice(result.pos)}
2948
2973
  NonPipelineExtendedExpression,
2949
2974
  NonAssignmentExtendedExpression,
2950
2975
  NestedNonAssignmentExtendedExpression,
2976
+ ExpressionizedStatementWithTrailingCallExpressions,
2951
2977
  ExpressionizedStatement,
2952
2978
  Expression,
2953
2979
  Arguments,
@@ -2958,6 +2984,8 @@ ${input.slice(result.pos)}
2958
2984
  ArgumentsWithTrailingMemberExpressions,
2959
2985
  TrailingMemberExpressions,
2960
2986
  AllowedTrailingMemberExpressions,
2987
+ TrailingCallExpressions,
2988
+ AllowedTrailingCallExpressions,
2961
2989
  CommaDelimiter,
2962
2990
  ArgumentList,
2963
2991
  NonPipelineArgumentList,
@@ -3140,6 +3168,7 @@ ${input.slice(result.pos)}
3140
3168
  OperatorAssignmentOp,
3141
3169
  AssignmentOpSymbol,
3142
3170
  CoffeeWordAssignmentOp,
3171
+ NotDedentedBinaryOp,
3143
3172
  BinaryOp,
3144
3173
  BinaryOpSymbol,
3145
3174
  Xor,
@@ -3498,6 +3527,7 @@ ${input.slice(result.pos)}
3498
3527
  TypeIndex,
3499
3528
  TypeSuffix,
3500
3529
  ReturnTypeSuffix,
3530
+ ReturnType,
3501
3531
  TypePredicate,
3502
3532
  Type,
3503
3533
  TypeBinary,
@@ -3802,7 +3832,7 @@ ${input.slice(result.pos)}
3802
3832
  var $R6 = $R(new RegExp("[!+-]", "suy"));
3803
3833
  var $R7 = $R(new RegExp("<(?!\\p{ID_Start}|[_$])", "suy"));
3804
3834
  var $R8 = $R(new RegExp("!\\^\\^?", "suy"));
3805
- var $R9 = $R(new RegExp("(?!\\+\\+|--)[!~+-](?!\\s|[!~+-]*&)", "suy"));
3835
+ var $R9 = $R(new RegExp("(?!\\+\\+|--)[!~+-](?!\\s|[!~+-]*[&.])", "suy"));
3806
3836
  var $R10 = $R(new RegExp("(?=[\\s\\)])", "suy"));
3807
3837
  var $R11 = $R(new RegExp('[^;"\\s]+', "suy"));
3808
3838
  var $R12 = $R(new RegExp("(?:0|[1-9](?:_[0-9]|[0-9])*)n", "suy"));
@@ -4095,7 +4125,10 @@ ${input.slice(result.pos)}
4095
4125
  }
4096
4126
  }
4097
4127
  var NonAssignmentExtendedExpression$0 = NestedNonAssignmentExtendedExpression;
4098
- var NonAssignmentExtendedExpression$1 = $TS($S(__, ExpressionizedStatement), function($skip, $loc, $0, $1, $2) {
4128
+ var NonAssignmentExtendedExpression$1 = $TS($S(__, ExpressionizedStatementWithTrailingCallExpressions), function($skip, $loc, $0, $1, $2) {
4129
+ if ($2.length) {
4130
+ return [...$1, ...$2];
4131
+ }
4099
4132
  return {
4100
4133
  ...$2,
4101
4134
  children: [...$1, ...$2.children]
@@ -4123,11 +4156,17 @@ ${input.slice(result.pos)}
4123
4156
  return result;
4124
4157
  }
4125
4158
  }
4126
- var NestedNonAssignmentExtendedExpression$0 = $TS($S($Y(EOS), PushIndent, $E($S(Nested, ExpressionizedStatement)), PopIndent), function($skip, $loc, $0, $1, $2, $3, $4) {
4159
+ var NestedNonAssignmentExtendedExpression$0 = $TS($S($Y(EOS), PushIndent, $E($S(Nested, ExpressionizedStatementWithTrailingCallExpressions)), PopIndent, $E(AllowedTrailingCallExpressions)), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
4127
4160
  var expression = $3;
4128
- if (expression)
4161
+ var trailing = $5;
4162
+ if (!expression)
4163
+ return $skip;
4164
+ if (!trailing)
4129
4165
  return expression;
4130
- return $skip;
4166
+ return {
4167
+ type: "CallExpression",
4168
+ children: [expression, ...trailing.flat()]
4169
+ };
4131
4170
  });
4132
4171
  function NestedNonAssignmentExtendedExpression(state) {
4133
4172
  let eventData;
@@ -4151,6 +4190,39 @@ ${input.slice(result.pos)}
4151
4190
  return result;
4152
4191
  }
4153
4192
  }
4193
+ var ExpressionizedStatementWithTrailingCallExpressions$0 = $TS($S(ExpressionizedStatement, $E(AllowedTrailingCallExpressions)), function($skip, $loc, $0, $1, $2) {
4194
+ if (!$2)
4195
+ return $1;
4196
+ return {
4197
+ type: "CallExpression",
4198
+ children: [
4199
+ makeLeftHandSideExpression($1),
4200
+ $2
4201
+ ]
4202
+ };
4203
+ });
4204
+ function ExpressionizedStatementWithTrailingCallExpressions(state) {
4205
+ let eventData;
4206
+ if (state.events) {
4207
+ const result = state.events.enter?.("ExpressionizedStatementWithTrailingCallExpressions", state);
4208
+ if (result) {
4209
+ if (result.cache)
4210
+ return result.cache;
4211
+ eventData = result.data;
4212
+ }
4213
+ }
4214
+ if (state.tokenize) {
4215
+ const result = $TOKEN("ExpressionizedStatementWithTrailingCallExpressions", state, ExpressionizedStatementWithTrailingCallExpressions$0(state));
4216
+ if (state.events)
4217
+ state.events.exit?.("ExpressionizedStatementWithTrailingCallExpressions", state, result, eventData);
4218
+ return result;
4219
+ } else {
4220
+ const result = ExpressionizedStatementWithTrailingCallExpressions$0(state);
4221
+ if (state.events)
4222
+ state.events.exit?.("ExpressionizedStatementWithTrailingCallExpressions", state, result, eventData);
4223
+ return result;
4224
+ }
4225
+ }
4154
4226
  var ExpressionizedStatement$0 = DebuggerExpression;
4155
4227
  var ExpressionizedStatement$1 = IfExpression;
4156
4228
  var ExpressionizedStatement$2 = UnlessExpression;
@@ -4436,6 +4508,54 @@ ${input.slice(result.pos)}
4436
4508
  return result;
4437
4509
  }
4438
4510
  }
4511
+ var TrailingCallExpressions$0 = $P($S($C(Samedent, IndentedFurther), $Y($S($E($EXPECT($L5, fail, 'TrailingCallExpressions "?"')), $EXPECT($L6, fail, 'TrailingCallExpressions "."'), $N($R$0($EXPECT($R1, fail, "TrailingCallExpressions /[0-9]/"))))), $P(CallExpressionRest)));
4512
+ function TrailingCallExpressions(state) {
4513
+ let eventData;
4514
+ if (state.events) {
4515
+ const result = state.events.enter?.("TrailingCallExpressions", state);
4516
+ if (result) {
4517
+ if (result.cache)
4518
+ return result.cache;
4519
+ eventData = result.data;
4520
+ }
4521
+ }
4522
+ if (state.tokenize) {
4523
+ const result = $TOKEN("TrailingCallExpressions", state, TrailingCallExpressions$0(state));
4524
+ if (state.events)
4525
+ state.events.exit?.("TrailingCallExpressions", state, result, eventData);
4526
+ return result;
4527
+ } else {
4528
+ const result = TrailingCallExpressions$0(state);
4529
+ if (state.events)
4530
+ state.events.exit?.("TrailingCallExpressions", state, result, eventData);
4531
+ return result;
4532
+ }
4533
+ }
4534
+ var AllowedTrailingCallExpressions$0 = $T($S(TrailingMemberPropertyAllowed, TrailingCallExpressions), function(value) {
4535
+ return value[1];
4536
+ });
4537
+ function AllowedTrailingCallExpressions(state) {
4538
+ let eventData;
4539
+ if (state.events) {
4540
+ const result = state.events.enter?.("AllowedTrailingCallExpressions", state);
4541
+ if (result) {
4542
+ if (result.cache)
4543
+ return result.cache;
4544
+ eventData = result.data;
4545
+ }
4546
+ }
4547
+ if (state.tokenize) {
4548
+ const result = $TOKEN("AllowedTrailingCallExpressions", state, AllowedTrailingCallExpressions$0(state));
4549
+ if (state.events)
4550
+ state.events.exit?.("AllowedTrailingCallExpressions", state, result, eventData);
4551
+ return result;
4552
+ } else {
4553
+ const result = AllowedTrailingCallExpressions$0(state);
4554
+ if (state.events)
4555
+ state.events.exit?.("AllowedTrailingCallExpressions", state, result, eventData);
4556
+ return result;
4557
+ }
4558
+ }
4439
4559
  var CommaDelimiter$0 = $S($E($C(Samedent, IndentedFurther)), $Q(_), Comma);
4440
4560
  function CommaDelimiter(state) {
4441
4561
  let eventData;
@@ -4683,9 +4803,9 @@ ${input.slice(result.pos)}
4683
4803
  var rhs = $2;
4684
4804
  return [[], op, [], rhs];
4685
4805
  });
4686
- var BinaryOpRHS$1 = $T($S(NewlineBinaryOpAllowed, $S(NotDedented, BinaryOp, $C(_, $S(EOS, __)), RHS)), function(value) {
4687
- var rhs = value[1];
4688
- return rhs;
4806
+ var BinaryOpRHS$1 = $TS($S(NewlineBinaryOpAllowed, $S(NotDedentedBinaryOp, $C(_, $S(EOS, __)), RHS)), function($skip, $loc, $0, $1, $2) {
4807
+ var rhs = $2;
4808
+ return [...rhs[0], ...rhs.slice(1)];
4689
4809
  });
4690
4810
  var BinaryOpRHS$2 = $T($S($N(NewlineBinaryOpAllowed), SingleLineBinaryOpRHS), function(value) {
4691
4811
  return value[1];
@@ -4743,7 +4863,7 @@ ${input.slice(result.pos)}
4743
4863
  }
4744
4864
  var RHS$0 = ParenthesizedAssignment;
4745
4865
  var RHS$1 = UnaryExpression;
4746
- var RHS$2 = ExpressionizedStatement;
4866
+ var RHS$2 = ExpressionizedStatementWithTrailingCallExpressions;
4747
4867
  function RHS(state) {
4748
4868
  let eventData;
4749
4869
  if (state.events) {
@@ -4824,10 +4944,7 @@ ${input.slice(result.pos)}
4824
4944
  }
4825
4945
  }
4826
4946
  var UnaryPostfix$0 = QuestionMark;
4827
- var UnaryPostfix$1 = $T($P($S(__, As, Type)), function(value) {
4828
- return { "ts": true, "children": value };
4829
- });
4830
- var UnaryPostfix$2 = $T($P($S(__, Satisfies, Type)), function(value) {
4947
+ var UnaryPostfix$1 = $T($P($S(__, $C(As, Satisfies), Type)), function(value) {
4831
4948
  return { "ts": true, "children": value };
4832
4949
  });
4833
4950
  function UnaryPostfix(state) {
@@ -4841,12 +4958,12 @@ ${input.slice(result.pos)}
4841
4958
  }
4842
4959
  }
4843
4960
  if (state.tokenize) {
4844
- const result = $TOKEN("UnaryPostfix", state, UnaryPostfix$0(state) || UnaryPostfix$1(state) || UnaryPostfix$2(state));
4961
+ const result = $TOKEN("UnaryPostfix", state, UnaryPostfix$0(state) || UnaryPostfix$1(state));
4845
4962
  if (state.events)
4846
4963
  state.events.exit?.("UnaryPostfix", state, result, eventData);
4847
4964
  return result;
4848
4965
  } else {
4849
- const result = UnaryPostfix$0(state) || UnaryPostfix$1(state) || UnaryPostfix$2(state);
4966
+ const result = UnaryPostfix$0(state) || UnaryPostfix$1(state);
4850
4967
  if (state.events)
4851
4968
  state.events.exit?.("UnaryPostfix", state, result, eventData);
4852
4969
  return result;
@@ -5457,6 +5574,15 @@ ${input.slice(result.pos)}
5457
5574
  switch (exp.type) {
5458
5575
  case "IterationExpression":
5459
5576
  return exp;
5577
+ case "ParenthesizedExpression":
5578
+ if (exp.implicit) {
5579
+ return {
5580
+ ...exp,
5581
+ children: [open, exp.expression, ws, close],
5582
+ implicit: false
5583
+ };
5584
+ }
5585
+ break;
5460
5586
  }
5461
5587
  return {
5462
5588
  type: "ParenthesizedExpression",
@@ -7897,17 +8023,29 @@ ${input.slice(result.pos)}
7897
8023
  return $skip;
7898
8024
  let body, ref;
7899
8025
  if (!rhs) {
7900
- ref = {
8026
+ body = ref = {
7901
8027
  type: "Ref",
7902
8028
  base: "$",
7903
8029
  id: "$"
7904
8030
  };
7905
- body = [prefix, ref];
7906
8031
  } else {
7907
- ({ ref } = rhs);
7908
- body = [prefix, rhs];
8032
+ let exp = rhs;
8033
+ while (!exp.ref && exp.expression) {
8034
+ exp = exp.expression;
8035
+ }
8036
+ ({ ref } = exp);
8037
+ if (!ref) {
8038
+ throw new Error("Could not find ref in ampersand shorthand block");
8039
+ }
8040
+ body = rhs;
8041
+ }
8042
+ if (prefix) {
8043
+ body = {
8044
+ type: "UnaryExpression",
8045
+ children: [prefix, body, void 0]
8046
+ };
7909
8047
  }
7910
- const children = [ref, " => ", ...body];
8048
+ const children = [ref, " => ", body];
7911
8049
  if (hasAwait(body)) {
7912
8050
  children.unshift("async ");
7913
8051
  }
@@ -8067,7 +8205,7 @@ ${input.slice(result.pos)}
8067
8205
  var callExpRest = $1;
8068
8206
  var unaryPostfix = $2;
8069
8207
  var binopRHS = $3;
8070
- if (!callExpRest && !binopRHS)
8208
+ if (!callExpRest && !binopRHS && !unaryPostfix)
8071
8209
  return $skip;
8072
8210
  const ref = {
8073
8211
  type: "Ref",
@@ -10571,6 +10709,42 @@ ${input.slice(result.pos)}
10571
10709
  return result;
10572
10710
  }
10573
10711
  }
10712
+ var NotDedentedBinaryOp$0 = $TS($S($E(IndentedFurther), $E(_), BinaryOp), function($skip, $loc, $0, $1, $2, $3) {
10713
+ const ws = [];
10714
+ if ($1)
10715
+ ws.push(...$1);
10716
+ if ($2)
10717
+ ws.push(...$2);
10718
+ return [ws, $3];
10719
+ });
10720
+ var NotDedentedBinaryOp$1 = $TS($S(Samedent, $E(_), $N(Identifier), BinaryOp), function($skip, $loc, $0, $1, $2, $3, $4) {
10721
+ const ws = [...$1];
10722
+ if ($2)
10723
+ ws.push(...$2);
10724
+ return [ws, $4];
10725
+ });
10726
+ function NotDedentedBinaryOp(state) {
10727
+ let eventData;
10728
+ if (state.events) {
10729
+ const result = state.events.enter?.("NotDedentedBinaryOp", state);
10730
+ if (result) {
10731
+ if (result.cache)
10732
+ return result.cache;
10733
+ eventData = result.data;
10734
+ }
10735
+ }
10736
+ if (state.tokenize) {
10737
+ const result = $TOKEN("NotDedentedBinaryOp", state, NotDedentedBinaryOp$0(state) || NotDedentedBinaryOp$1(state));
10738
+ if (state.events)
10739
+ state.events.exit?.("NotDedentedBinaryOp", state, result, eventData);
10740
+ return result;
10741
+ } else {
10742
+ const result = NotDedentedBinaryOp$0(state) || NotDedentedBinaryOp$1(state);
10743
+ if (state.events)
10744
+ state.events.exit?.("NotDedentedBinaryOp", state, result, eventData);
10745
+ return result;
10746
+ }
10747
+ }
10574
10748
  var BinaryOp$0 = $TS($S(BinaryOpSymbol), function($skip, $loc, $0, $1) {
10575
10749
  if (typeof $1 === "string")
10576
10750
  return { $loc, token: $1 };
@@ -10900,7 +11074,7 @@ ${input.slice(result.pos)}
10900
11074
  return result;
10901
11075
  }
10902
11076
  }
10903
- var UnaryOp$0 = $TR($EXPECT($R9, fail, "UnaryOp /(?!\\+\\+|--)[!~+-](?!\\s|[!~+-]*&)/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
11077
+ var UnaryOp$0 = $TR($EXPECT($R9, fail, "UnaryOp /(?!\\+\\+|--)[!~+-](?!\\s|[!~+-]*[&.])/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
10904
11078
  return { $loc, token: $0 };
10905
11079
  });
10906
11080
  var UnaryOp$1 = AwaitOp;
@@ -11389,6 +11563,8 @@ ${input.slice(result.pos)}
11389
11563
  var kind = $1;
11390
11564
  var condition = $2;
11391
11565
  kind = { ...kind, token: "if" };
11566
+ kind.token += getTrimmingSpace(condition);
11567
+ condition = insertTrimmingSpace(condition, "");
11392
11568
  return {
11393
11569
  type: "IfStatement",
11394
11570
  children: [kind, ["(!", condition, ")"]],
@@ -21158,27 +21334,54 @@ ${input.slice(result.pos)}
21158
21334
  return result;
21159
21335
  }
21160
21336
  }
21161
- var ReturnTypeSuffix$0 = $TS($S($E(_), Colon, $E($S(__, $EXPECT($L202, fail, 'ReturnTypeSuffix "asserts"'), NonIdContinue)), TypePredicate), function($skip, $loc, $0, $1, $2, $3, $4) {
21162
- var asserts = $3;
21163
- var t = $4;
21337
+ var ReturnTypeSuffix$0 = $TS($S($E(_), Colon, ReturnType), function($skip, $loc, $0, $1, $2, $3) {
21338
+ var t = $3;
21339
+ return { ...t, children: [$1, $2, ...t.children] };
21340
+ });
21341
+ function ReturnTypeSuffix(state) {
21342
+ let eventData;
21343
+ if (state.events) {
21344
+ const result = state.events.enter?.("ReturnTypeSuffix", state);
21345
+ if (result) {
21346
+ if (result.cache)
21347
+ return result.cache;
21348
+ eventData = result.data;
21349
+ }
21350
+ }
21351
+ if (state.tokenize) {
21352
+ const result = $TOKEN("ReturnTypeSuffix", state, ReturnTypeSuffix$0(state));
21353
+ if (state.events)
21354
+ state.events.exit?.("ReturnTypeSuffix", state, result, eventData);
21355
+ return result;
21356
+ } else {
21357
+ const result = ReturnTypeSuffix$0(state);
21358
+ if (state.events)
21359
+ state.events.exit?.("ReturnTypeSuffix", state, result, eventData);
21360
+ return result;
21361
+ }
21362
+ }
21363
+ var ReturnType$0 = $TS($S($E($S(__, $EXPECT($L202, fail, 'ReturnType "asserts"'), NonIdContinue)), TypePredicate), function($skip, $loc, $0, $1, $2) {
21364
+ var asserts = $1;
21365
+ var t = $2;
21164
21366
  if (asserts) {
21165
21367
  t = {
21166
21368
  type: "AssertsType",
21167
21369
  t,
21168
- children: [asserts[0], asserts[1], t]
21370
+ children: [asserts[0], asserts[1], t],
21371
+ ts: true
21169
21372
  };
21170
21373
  }
21171
21374
  return {
21172
21375
  type: "ReturnTypeAnnotation",
21173
- children: [$1, $2, t],
21376
+ children: [t],
21174
21377
  t,
21175
21378
  ts: true
21176
21379
  };
21177
21380
  });
21178
- function ReturnTypeSuffix(state) {
21381
+ function ReturnType(state) {
21179
21382
  let eventData;
21180
21383
  if (state.events) {
21181
- const result = state.events.enter?.("ReturnTypeSuffix", state);
21384
+ const result = state.events.enter?.("ReturnType", state);
21182
21385
  if (result) {
21183
21386
  if (result.cache)
21184
21387
  return result.cache;
@@ -21186,14 +21389,14 @@ ${input.slice(result.pos)}
21186
21389
  }
21187
21390
  }
21188
21391
  if (state.tokenize) {
21189
- const result = $TOKEN("ReturnTypeSuffix", state, ReturnTypeSuffix$0(state));
21392
+ const result = $TOKEN("ReturnType", state, ReturnType$0(state));
21190
21393
  if (state.events)
21191
- state.events.exit?.("ReturnTypeSuffix", state, result, eventData);
21394
+ state.events.exit?.("ReturnType", state, result, eventData);
21192
21395
  return result;
21193
21396
  } else {
21194
- const result = ReturnTypeSuffix$0(state);
21397
+ const result = ReturnType$0(state);
21195
21398
  if (state.events)
21196
- state.events.exit?.("ReturnTypeSuffix", state, result, eventData);
21399
+ state.events.exit?.("ReturnType", state, result, eventData);
21197
21400
  return result;
21198
21401
  }
21199
21402
  }
@@ -21850,7 +22053,7 @@ ${input.slice(result.pos)}
21850
22053
  return result;
21851
22054
  }
21852
22055
  }
21853
- var FunctionType$0 = $TS($S($E($S(New, $E(_))), Parameters, __, TypeArrowFunction, $E(Type)), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
22056
+ var FunctionType$0 = $TS($S($E($S($E($S(Abstract, $E(_))), New, $E(_))), Parameters, __, TypeArrowFunction, $E(ReturnType)), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
21854
22057
  var type = $5;
21855
22058
  if (type) {
21856
22059
  return $0;