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