@danielx/civet 0.7.34 → 0.7.36

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
@@ -573,11 +573,13 @@ ${body}`;
573
573
  processProgramAsync: () => processProgramAsync,
574
574
  processTryBlock: () => processTryBlock,
575
575
  processUnaryExpression: () => processUnaryExpression,
576
+ processUnaryNestedExpression: () => processUnaryNestedExpression,
576
577
  quoteString: () => quoteString,
577
578
  reorderBindingRestProperty: () => reorderBindingRestProperty,
578
579
  replaceNode: () => replaceNode,
579
580
  replaceNodes: () => replaceNodes,
580
581
  skipImplicitArguments: () => skipImplicitArguments,
582
+ stripTrailingImplicitComma: () => stripTrailingImplicitComma,
581
583
  trimFirstSpace: () => trimFirstSpace,
582
584
  typeOfJSX: () => typeOfJSX,
583
585
  wrapIIFE: () => wrapIIFE
@@ -714,6 +716,40 @@ ${body}`;
714
716
  return node.every(isWhitespaceOrEmpty);
715
717
  return false;
716
718
  }
719
+ function firstNonSpace(node) {
720
+ if (!(node != null)) {
721
+ return;
722
+ }
723
+ if (Array.isArray(node)) {
724
+ for (let i2 = 0, len22 = node.length; i2 < len22; i2++) {
725
+ const child = node[i2];
726
+ let ref1;
727
+ if (ref1 = firstNonSpace(child)) {
728
+ const first = ref1;
729
+ return first;
730
+ }
731
+ }
732
+ return void 0;
733
+ } else if (isParent(node)) {
734
+ let ref2;
735
+ if (ref2 = firstNonSpace(node.children)) {
736
+ const first = ref2;
737
+ return first;
738
+ } else {
739
+ return node;
740
+ }
741
+ } else if (isToken(node)) {
742
+ let m;
743
+ if (m = node.token, typeof m === "string" && /^[ \t]*$/.test(m)) {
744
+ return;
745
+ }
746
+ } else if (typeof node === "string") {
747
+ if (typeof node === "string" && /^[ \t]*$/.test(node)) {
748
+ return;
749
+ }
750
+ }
751
+ return node;
752
+ }
717
753
  function isExit(node) {
718
754
  if (!(node != null)) {
719
755
  return false;
@@ -751,6 +787,14 @@ ${body}`;
751
787
  ;
752
788
  return;
753
789
  }
790
+ function stripTrailingImplicitComma(children) {
791
+ const last = children[children.length - 1];
792
+ if (isComma(last) && last.implicit) {
793
+ return children.slice(0, -1);
794
+ } else {
795
+ return children;
796
+ }
797
+ }
754
798
  function insertTrimmingSpace(target, c) {
755
799
  if (!(target != null)) {
756
800
  return target;
@@ -923,8 +967,8 @@ ${body}`;
923
967
  return void 0;
924
968
  }
925
969
  if (Array.isArray(node)) {
926
- for (let i2 = 0, len22 = node.length; i2 < len22; i2++) {
927
- const child = node[i2];
970
+ for (let i3 = 0, len3 = node.length; i3 < len3; i3++) {
971
+ const child = node[i3];
928
972
  if (skip(child)) {
929
973
  continue;
930
974
  }
@@ -1011,6 +1055,9 @@ ${body}`;
1011
1055
  return expression;
1012
1056
  }
1013
1057
  }
1058
+ return parenthesizeExpression(expression);
1059
+ }
1060
+ function parenthesizeExpression(expression) {
1014
1061
  return makeNode({
1015
1062
  type: "ParenthesizedExpression",
1016
1063
  children: ["(", expression, ")"],
@@ -1026,8 +1073,8 @@ ${body}`;
1026
1073
  return;
1027
1074
  }
1028
1075
  if (Array.isArray(node)) {
1029
- for (let i3 = 0, len3 = node.length; i3 < len3; i3++) {
1030
- const child = node[i3];
1076
+ for (let i4 = 0, len4 = node.length; i4 < len4; i4++) {
1077
+ const child = node[i4];
1031
1078
  updateParentPointers(child, parent, depth);
1032
1079
  }
1033
1080
  return;
@@ -1037,8 +1084,8 @@ ${body}`;
1037
1084
  node.parent = parent;
1038
1085
  }
1039
1086
  if (depth && isParent(node)) {
1040
- for (let ref1 = node.children, i4 = 0, len4 = ref1.length; i4 < len4; i4++) {
1041
- const child = ref1[i4];
1087
+ for (let ref3 = node.children, i5 = 0, len5 = ref3.length; i5 < len5; i5++) {
1088
+ const child = ref3[i5];
1042
1089
  updateParentPointers(child, node, depth - 1);
1043
1090
  }
1044
1091
  }
@@ -1168,8 +1215,8 @@ ${body}`;
1168
1215
  children.splice(1, 0, ".bind(this)");
1169
1216
  }
1170
1217
  if (gatherRecursiveWithinFunction(block, (a2) => typeof a2 === "object" && a2 != null && "token" in a2 && a2.token === "arguments").length) {
1171
- let ref2;
1172
- children[children.length - 1] = (ref2 = parameters.children)[ref2.length - 1] = "(arguments)";
1218
+ let ref4;
1219
+ children[children.length - 1] = (ref4 = parameters.children)[ref4.length - 1] = "(arguments)";
1173
1220
  }
1174
1221
  }
1175
1222
  const exp = makeNode({
@@ -1192,9 +1239,9 @@ ${body}`;
1192
1239
  }
1193
1240
  function flatJoin(array, separator) {
1194
1241
  const result = [];
1195
- for (let i5 = 0, len5 = array.length; i5 < len5; i5++) {
1196
- const i = i5;
1197
- const items = array[i5];
1242
+ for (let i6 = 0, len6 = array.length; i6 < len6; i6++) {
1243
+ const i = i6;
1244
+ const items = array[i6];
1198
1245
  if (i) {
1199
1246
  result.push(separator);
1200
1247
  }
@@ -1593,12 +1640,6 @@ ${body}`;
1593
1640
  function isPromiseVoidType(t) {
1594
1641
  return t?.type === "TypeIdentifier" && t.raw === "Promise" && t.args?.types?.length === 1 && isVoidType(t.args.types[0]);
1595
1642
  }
1596
- function isGeneratorVoidType(t) {
1597
- return t?.type === "TypeIdentifier" && (t.raw === "Iterator" || t.raw === "Generator") && t.args?.types?.length >= 2 && isVoidType(t.args.types[1]);
1598
- }
1599
- function isAsyncGeneratorVoidType(t) {
1600
- return t?.type === "TypeIdentifier" && (t.raw === "AsyncIterator" || t.raw === "AsyncGenerator") && t.args?.types?.length >= 2 && isVoidType(t.args.types[1]);
1601
- }
1602
1643
  function implicitFunctionBlock(f) {
1603
1644
  if (f.abstract || f.block || f.signature?.optional)
1604
1645
  return;
@@ -1636,7 +1677,7 @@ ${body}`;
1636
1677
  const { async, generator, set } = modifier;
1637
1678
  const isMethod = f.type === "MethodDefinition";
1638
1679
  const isConstructor = isMethod && name === "constructor";
1639
- const isVoid = isVoidType(returnType2?.t) || async && (isPromiseVoidType(returnType2?.t) || generator && isAsyncGeneratorVoidType(returnType2?.t)) || !async && generator && isGeneratorVoidType(returnType2?.t);
1680
+ const isVoid = generator || isVoidType(returnType2?.t) || async && isPromiseVoidType(returnType2?.t);
1640
1681
  if (block?.type === "BlockStatement") {
1641
1682
  if (isVoid || set || isConstructor) {
1642
1683
  if (block.bare && block.implicitlyReturned) {
@@ -1652,10 +1693,7 @@ ${body}`;
1652
1693
  }
1653
1694
  function processReturnValue(func) {
1654
1695
  const { block } = func;
1655
- const values = gatherRecursiveWithinFunction(
1656
- block,
1657
- ({ type }) => type === "ReturnValue"
1658
- );
1696
+ const values = gatherRecursiveWithinFunction(block, ($) => $.type === "ReturnValue");
1659
1697
  if (!values.length) {
1660
1698
  return false;
1661
1699
  }
@@ -1665,7 +1703,7 @@ ${body}`;
1665
1703
  value.children = [ref];
1666
1704
  const { ancestor, child } = findAncestor(
1667
1705
  value,
1668
- ({ type }) => type === "Declaration",
1706
+ ($1) => $1.type === "Declaration",
1669
1707
  isFunction
1670
1708
  );
1671
1709
  if (ancestor) {
@@ -1685,8 +1723,8 @@ ${body}`;
1685
1723
  }
1686
1724
  }
1687
1725
  if (declaration) {
1688
- if (!(declaration.suffix != null)) {
1689
- declaration.children[1] = declaration.suffix = returnType;
1726
+ if (!(declaration.typeSuffix != null)) {
1727
+ declaration.children[1] = declaration.typeSuffix = returnType;
1690
1728
  }
1691
1729
  } else {
1692
1730
  block.expressions.unshift([
@@ -2026,7 +2064,7 @@ ${body}`;
2026
2064
  let changed = false;
2027
2065
  for (const control of gatherRecursiveWithinFunction(
2028
2066
  statement.block,
2029
- ($) => $.type === "BreakStatement" || $.type === "ContinueStatement"
2067
+ ($2) => $2.type === "BreakStatement" || $2.type === "ContinueStatement"
2030
2068
  )) {
2031
2069
  let controlName2 = function() {
2032
2070
  switch (control.type) {
@@ -2061,7 +2099,7 @@ ${body}`;
2061
2099
  )
2062
2100
  );
2063
2101
  updateParentPointers(control.with, control);
2064
- const i = control.children.findIndex(($1) => $1?.type === "Error");
2102
+ const i = control.children.findIndex(($3) => $3?.type === "Error");
2065
2103
  if (i >= 0) {
2066
2104
  control.children.splice(i, 1);
2067
2105
  }
@@ -2185,8 +2223,8 @@ ${body}`;
2185
2223
  }
2186
2224
  if (hasYield(block) && !f.generator?.length) {
2187
2225
  if (f.type === "ArrowFunction") {
2188
- gatherRecursiveWithinFunction(block, ($2) => $2.type === "YieldExpression").forEach((y) => {
2189
- const i = y.children.findIndex(($3) => $3.type === "Yield");
2226
+ gatherRecursiveWithinFunction(block, ($4) => $4.type === "YieldExpression").forEach((y) => {
2227
+ const i = y.children.findIndex(($5) => $5.type === "Yield");
2190
2228
  return y.children.splice(i + 1, 0, {
2191
2229
  type: "Error",
2192
2230
  message: "Can't use yield inside of => arrow function"
@@ -2268,6 +2306,9 @@ ${body}`;
2268
2306
  function skipImplicitArguments(args) {
2269
2307
  if (args.length === 1) {
2270
2308
  let arg0 = args[0];
2309
+ if (arg0.type === "Argument") {
2310
+ arg0 = arg0.expression;
2311
+ }
2271
2312
  if (arg0.type === "StatementExpression") {
2272
2313
  arg0 = arg0.statement;
2273
2314
  }
@@ -2310,12 +2351,13 @@ ${body}`;
2310
2351
  expression = {
2311
2352
  ...expression,
2312
2353
  parameters: newParameters,
2313
- children: expression.children.map(($4) => $4 === parameters ? newParameters : $4)
2354
+ children: expression.children.map(($6) => $6 === parameters ? newParameters : $6)
2314
2355
  };
2315
2356
  }
2316
2357
  return {
2317
2358
  type: "CallExpression",
2318
2359
  children: [
2360
+ ws,
2319
2361
  makeLeftHandSideExpression(expression),
2320
2362
  {
2321
2363
  type: "Call",
@@ -2331,7 +2373,7 @@ ${body}`;
2331
2373
  ref = makeRef("$");
2332
2374
  inplacePrepend(ref, body);
2333
2375
  }
2334
- if (startsWithPredicate(body, ($5) => $5.type === "ObjectExpression")) {
2376
+ if (startsWithPredicate(body, ($7) => $7.type === "ObjectExpression")) {
2335
2377
  body = makeLeftHandSideExpression(body);
2336
2378
  }
2337
2379
  const parameters = makeNode({
@@ -3521,7 +3563,7 @@ ${body}`;
3521
3563
  function len2(arr, length) {
3522
3564
  return arr.length === length;
3523
3565
  }
3524
- function processAssignmentDeclaration(decl, pattern, suffix, ws, assign, e) {
3566
+ function processAssignmentDeclaration(decl, pattern, typeSuffix, ws, assign, e) {
3525
3567
  decl = {
3526
3568
  ...decl,
3527
3569
  $loc: {
@@ -3533,7 +3575,7 @@ ${body}`;
3533
3575
  splices = splices.map((s) => [", ", s]);
3534
3576
  const thisAssignments = assignments.map((a) => ["", a, ";"]);
3535
3577
  if ("typeSuffix" in pattern) {
3536
- suffix ??= pattern.typeSuffix;
3578
+ typeSuffix ??= pattern.typeSuffix;
3537
3579
  }
3538
3580
  const initializer = makeNode({
3539
3581
  type: "Initializer",
@@ -3545,9 +3587,9 @@ ${body}`;
3545
3587
  pattern,
3546
3588
  initializer,
3547
3589
  splices,
3548
- suffix,
3590
+ typeSuffix,
3549
3591
  thisAssignments,
3550
- children: [pattern, suffix, initializer]
3592
+ children: [pattern, typeSuffix, initializer]
3551
3593
  });
3552
3594
  const children = [decl, binding];
3553
3595
  return makeNode({
@@ -3564,9 +3606,9 @@ ${body}`;
3564
3606
  gatherRecursiveAll(statements, ($) => $.type === "Declaration").forEach((statement) => {
3565
3607
  const { bindings } = statement;
3566
3608
  return bindings?.forEach((binding) => {
3567
- const suffix = binding.suffix;
3568
- if (suffix && suffix.optional && suffix.t) {
3569
- convertOptionalType(suffix);
3609
+ const { typeSuffix } = binding;
3610
+ if (typeSuffix && typeSuffix.optional && typeSuffix.t) {
3611
+ convertOptionalType(typeSuffix);
3570
3612
  }
3571
3613
  const { initializer } = binding;
3572
3614
  if (initializer) {
@@ -3647,8 +3689,8 @@ ${body}`;
3647
3689
  }
3648
3690
  const { decl, bindings } = condition.declaration;
3649
3691
  const binding = bindings[0];
3650
- let { pattern, suffix, initializer } = binding;
3651
- const nullCheck = suffix?.optional && !suffix.t && !suffix.nonnull;
3692
+ let { pattern, typeSuffix, initializer } = binding;
3693
+ const nullCheck = typeSuffix?.optional && !typeSuffix.t && !typeSuffix.nonnull;
3652
3694
  if (!(initializer != null)) {
3653
3695
  condition.children = [
3654
3696
  {
@@ -3686,14 +3728,14 @@ ${body}`;
3686
3728
  if (nullCheck) {
3687
3729
  children.unshift("(");
3688
3730
  children.push(") != null");
3689
- suffix = void 0;
3731
+ typeSuffix = void 0;
3690
3732
  }
3691
3733
  Object.assign(condition, {
3692
3734
  type: "AssignmentExpression",
3693
3735
  children,
3694
3736
  hoistDec: !simple ? {
3695
3737
  type: "Declaration",
3696
- children: ["let ", ref, suffix],
3738
+ children: ["let ", ref, typeSuffix],
3697
3739
  names: []
3698
3740
  } : void 0,
3699
3741
  pattern,
@@ -3701,7 +3743,7 @@ ${body}`;
3701
3743
  });
3702
3744
  }
3703
3745
  updateParentPointers(condition, parent);
3704
- rootCondition.blockPrefix = getPatternBlockPrefix(pattern, ref, decl, suffix);
3746
+ rootCondition.blockPrefix = getPatternBlockPrefix(pattern, ref, decl, typeSuffix);
3705
3747
  }
3706
3748
  function processDeclarationConditions(node) {
3707
3749
  gatherRecursiveAll(
@@ -4079,6 +4121,10 @@ ${body}`;
4079
4121
  };
4080
4122
  pre = pre.slice(0, -1);
4081
4123
  } else {
4124
+ let m;
4125
+ if (m = firstNonSpace(exp), typeof m === "string" && /^[ \t]*\n/.test(m) || typeof m === "object" && m != null && "token" in m && typeof m.token === "string" && /^[ \t]*\n/.test(m.token)) {
4126
+ exp = parenthesizeExpression(exp);
4127
+ }
4082
4128
  exp = {
4083
4129
  type: "AwaitExpression",
4084
4130
  children: [...last.children, exp]
@@ -4094,6 +4140,77 @@ ${body}`;
4094
4140
  children: [...pre, exp, post]
4095
4141
  };
4096
4142
  }
4143
+ function processUnaryNestedExpression(pre, args, post) {
4144
+ const isArray = args.type === "ArrayExpression";
4145
+ if (!isArray) {
4146
+ args = stripTrailingImplicitComma(args);
4147
+ }
4148
+ if (isArray || args.length > 2) {
4149
+ const last = pre[pre.length - 1];
4150
+ if (!(typeof last === "object" && last != null && "type" in last && last.type === "Await")) {
4151
+ return;
4152
+ }
4153
+ if (last.op) {
4154
+ if (!isArray) {
4155
+ args = {
4156
+ type: "ArrayExpression",
4157
+ children: ["[", args, "]"]
4158
+ };
4159
+ }
4160
+ } else {
4161
+ pre.pop();
4162
+ if (!isArray) {
4163
+ args = args;
4164
+ args = {
4165
+ type: "ArrayExpression",
4166
+ children: [
4167
+ "[",
4168
+ ...(() => {
4169
+ const results = [];
4170
+ for (let i = 0, len3 = args.length; i < len3; i++) {
4171
+ const arg = args[i];
4172
+ if (typeof arg === "object" && arg != null && "type" in arg && arg.type === "Argument") {
4173
+ const expression = processUnaryExpression([last], arg.expression);
4174
+ results.push({
4175
+ ...arg,
4176
+ expression,
4177
+ children: arg.children.map(($) => $ === arg.expression ? expression : $)
4178
+ });
4179
+ } else {
4180
+ results.push(arg);
4181
+ }
4182
+ }
4183
+ return results;
4184
+ })(),
4185
+ "]"
4186
+ ]
4187
+ };
4188
+ } else {
4189
+ args = trimFirstSpace(args);
4190
+ args = {
4191
+ ...args,
4192
+ children: args.children.map(
4193
+ (arg) => {
4194
+ if (typeof arg === "object" && arg != null && "type" in arg && arg.type === "ArrayElement" && "expression" in arg && "children" in arg) {
4195
+ const { type, expression: exp, children } = arg;
4196
+ let expression = processUnaryExpression([last], trimFirstSpace(exp));
4197
+ expression = prepend(getTrimmingSpace(exp), expression);
4198
+ return {
4199
+ ...arg,
4200
+ expression,
4201
+ children: children.map(($1) => $1 === exp ? expression : $1)
4202
+ };
4203
+ } else {
4204
+ return arg;
4205
+ }
4206
+ }
4207
+ )
4208
+ };
4209
+ }
4210
+ }
4211
+ }
4212
+ return processUnaryExpression(pre, args, post);
4213
+ }
4097
4214
 
4098
4215
  // source/parser/pipe.civet
4099
4216
  function constructInvocation(fn, arg) {
@@ -4131,36 +4248,31 @@ ${body}`;
4131
4248
  };
4132
4249
  }
4133
4250
  function constructPipeStep(fn, arg, returning) {
4251
+ if (!returning) {
4252
+ returning = null;
4253
+ }
4134
4254
  let children = [[fn.leadingComment, fn.expr, fn.trailingComment].map(skipIfOnlyWS), " ", arg];
4135
4255
  switch (fn.expr.token) {
4136
- case "yield":
4137
- case "await":
4138
- if (fn.expr.op) {
4139
- children = processUnaryExpression([fn.expr], arg, void 0);
4140
- }
4141
- if (returning) {
4142
- return [
4143
- children,
4144
- returning
4145
- ];
4146
- }
4256
+ case "await": {
4257
+ children = processUnaryExpression([fn.expr], arg, void 0);
4258
+ }
4259
+ case "yield": {
4147
4260
  return [
4148
4261
  children,
4149
- null
4262
+ returning
4150
4263
  ];
4151
- case "return":
4264
+ }
4265
+ case "return": {
4152
4266
  return [{
4153
4267
  type: "ReturnStatement",
4154
4268
  children
4155
4269
  }, null];
4270
+ }
4156
4271
  }
4157
- if (returning) {
4158
- return [
4159
- constructInvocation(fn, arg),
4160
- returning
4161
- ];
4162
- }
4163
- return [constructInvocation(fn, arg), null];
4272
+ return [
4273
+ constructInvocation(fn, arg),
4274
+ returning
4275
+ ];
4164
4276
  }
4165
4277
  function processPipelineExpressions(statements) {
4166
4278
  gatherRecursiveAll(statements, (n) => n.type === "PipelineExpression").forEach((s) => {
@@ -4417,7 +4529,29 @@ ${body}`;
4417
4529
  message: "'own' is only meaningful in for..in loops"
4418
4530
  };
4419
4531
  }
4420
- if (!declaration2 && !own) {
4532
+ const { binding } = declaration;
4533
+ let pattern = binding?.pattern;
4534
+ if (binding?.typeSuffix || inOf.token === "in" && declaration2 && pattern.type !== "Identifier") {
4535
+ const itemRef = makeRef(inOf.token === "in" ? "key" : "item");
4536
+ blockPrefix.push(["", {
4537
+ type: "Declaration",
4538
+ children: [declaration, " = ", itemRef],
4539
+ names: declaration.names
4540
+ }, ";"]);
4541
+ pattern = itemRef;
4542
+ declaration = {
4543
+ type: "ForDeclaration",
4544
+ binding: {
4545
+ type: "Binding",
4546
+ pattern,
4547
+ children: [pattern],
4548
+ names: []
4549
+ },
4550
+ children: ["const ", itemRef],
4551
+ names: []
4552
+ };
4553
+ }
4554
+ if (!(declaration2 || own)) {
4421
4555
  return {
4422
4556
  declaration,
4423
4557
  blockPrefix,
@@ -4456,29 +4590,6 @@ ${body}`;
4456
4590
  children: [" ", expRef2, " =", exp]
4457
4591
  };
4458
4592
  }
4459
- const { binding } = declaration;
4460
- let { pattern } = binding;
4461
- if (!(pattern.type === "Identifier")) {
4462
- const keyRef = makeRef("key");
4463
- blockPrefix.push(["", [
4464
- declaration,
4465
- " = ",
4466
- keyRef
4467
- ], ";"]);
4468
- pattern = keyRef;
4469
- declaration = {
4470
- type: "ForDeclaration",
4471
- binding: {
4472
- type: "Binding",
4473
- pattern,
4474
- children: [pattern],
4475
- names: [],
4476
- suffix: binding.suffix
4477
- },
4478
- children: ["const ", keyRef],
4479
- names: []
4480
- };
4481
- }
4482
4593
  if (own) {
4483
4594
  const hasPropRef = getRef("hasProp");
4484
4595
  blockPrefix.push(["", ["if (!", hasPropRef, "(", insertTrimmingSpace(expRef2, ""), ", ", insertTrimmingSpace(pattern, ""), ")) continue"], ";"]);
@@ -6175,44 +6286,82 @@ ${js}`
6175
6286
  }
6176
6287
  function processTypes(node) {
6177
6288
  return gatherRecursiveAll(node, (n) => n.type === "TypeUnary").forEach((unary) => {
6178
- let last;
6179
- let count = 0;
6180
- let ref10;
6181
- while (unary.suffix.length && (ref10 = unary.suffix)[ref10.length - 1]?.token === "?") {
6182
- last = unary.suffix.pop();
6183
- count++;
6184
- }
6185
- if (!count) {
6289
+ if (!unary.suffix.length) {
6186
6290
  return;
6187
6291
  }
6188
- let ref11;
6189
- if (unary.suffix.length || unary.prefix.length)
6190
- ref11 = unary;
6191
- else
6192
- ref11 = unary.t;
6193
- const t = ref11;
6194
- if (unary.parent?.type === "TypeTuple") {
6195
- if (count === 1) {
6196
- unary.suffix.push(last);
6197
- return;
6292
+ let ref10;
6293
+ let m3;
6294
+ if (m3 = (ref10 = unary.suffix)[ref10.length - 1], typeof m3 === "object" && m3 != null && "token" in m3 && m3.token === "?") {
6295
+ const { token } = m3;
6296
+ let last;
6297
+ let count = 0;
6298
+ let ref11;
6299
+ while (unary.suffix.length && (ref11 = unary.suffix)[ref11.length - 1]?.token === "?") {
6300
+ last = unary.suffix.pop();
6301
+ count++;
6198
6302
  }
6199
- replaceNode(unary, [
6200
- getTrimmingSpace(unary),
6201
- "(",
6202
- parenthesizeType(trimFirstSpace(t)),
6203
- " | null)",
6204
- last
6205
- ]);
6206
- } else {
6207
- replaceNode(unary, {
6208
- type: "TypeParenthesized",
6209
- ts: true,
6210
- children: [
6303
+ let ref12;
6304
+ while (unary.suffix.length && (ref12 = unary.suffix)[ref12.length - 1]?.type === "NonNullAssertion") {
6305
+ unary.suffix.pop();
6306
+ }
6307
+ let ref13;
6308
+ if (unary.suffix.length || unary.prefix.length)
6309
+ ref13 = unary;
6310
+ else
6311
+ ref13 = unary.t;
6312
+ const t = ref13;
6313
+ if (unary.parent?.type === "TypeTuple") {
6314
+ if (count === 1) {
6315
+ unary.suffix.push(last);
6316
+ return;
6317
+ }
6318
+ replaceNode(unary, [
6211
6319
  getTrimmingSpace(unary),
6212
6320
  "(",
6213
6321
  parenthesizeType(trimFirstSpace(t)),
6214
- count === 1 ? " | undefined" : " | undefined | null",
6215
- ")"
6322
+ " | null)",
6323
+ last
6324
+ ]);
6325
+ } else {
6326
+ replaceNode(unary, {
6327
+ type: "TypeParenthesized",
6328
+ ts: true,
6329
+ children: [
6330
+ getTrimmingSpace(unary),
6331
+ "(",
6332
+ parenthesizeType(trimFirstSpace(t)),
6333
+ count === 1 ? " | undefined" : " | undefined | null",
6334
+ ")"
6335
+ ]
6336
+ });
6337
+ }
6338
+ } else if (typeof m3 === "object" && m3 != null && "type" in m3 && m3.type === "NonNullAssertion") {
6339
+ const { type } = m3;
6340
+ let ref14;
6341
+ while (unary.suffix.length && (ref14 = unary.suffix)[ref14.length - 1]?.type === "NonNullAssertion") {
6342
+ unary.suffix.pop();
6343
+ }
6344
+ let ref15;
6345
+ while (unary.suffix.length && (ref15 = unary.suffix)[ref15.length - 1]?.token === "?") {
6346
+ unary.suffix.pop();
6347
+ }
6348
+ const t = trimFirstSpace(
6349
+ unary.suffix.length || unary.prefix.length ? unary : unary.t
6350
+ );
6351
+ const args = {
6352
+ type: "TypeArguments",
6353
+ ts: true,
6354
+ types: [t],
6355
+ children: ["<", t, ">"]
6356
+ };
6357
+ replaceNode(unary, {
6358
+ type: "TypeIdentifier",
6359
+ raw: "NonNullable",
6360
+ args,
6361
+ children: [
6362
+ getTrimmingSpace(unary),
6363
+ "NonNullable",
6364
+ args
6216
6365
  ]
6217
6366
  });
6218
6367
  }
@@ -6222,11 +6371,11 @@ ${js}`
6222
6371
  gatherRecursiveAll(statements, ($7) => $7.type === "StatementExpression").forEach((_exp) => {
6223
6372
  const exp = _exp;
6224
6373
  const { statement } = exp;
6225
- let ref12;
6374
+ let ref16;
6226
6375
  switch (statement.type) {
6227
6376
  case "IfStatement": {
6228
- if (ref12 = expressionizeIfStatement(statement)) {
6229
- const expression = ref12;
6377
+ if (ref16 = expressionizeIfStatement(statement)) {
6378
+ const expression = ref16;
6230
6379
  return replaceNode(statement, expression, exp);
6231
6380
  } else {
6232
6381
  return replaceNode(statement, wrapIIFE([["", statement]]), exp);
@@ -6289,6 +6438,7 @@ ${js}`
6289
6438
  assert.equal(state2.forbidBracedApplication.length, 1, "forbidBracedApplication");
6290
6439
  assert.equal(state2.forbidClassImplicitCall.length, 1, "forbidClassImplicitCall");
6291
6440
  assert.equal(state2.forbidIndentedApplication.length, 1, "forbidIndentedApplication");
6441
+ assert.equal(state2.forbidNestedBinaryOp.length, 1, "forbidNestedBinaryOp");
6292
6442
  assert.equal(state2.forbidNewlineBinaryOp.length, 1, "forbidNewlineBinaryOp");
6293
6443
  assert.equal(state2.forbidTrailingMemberProperty.length, 1, "forbidTrailingMemberProperty");
6294
6444
  assert.equal(state2.JSXTagStack.length, 1, "JSXTagStack");
@@ -6372,10 +6522,10 @@ ${js}`
6372
6522
  if (type === "IfStatement") {
6373
6523
  liftedIfs.add(ancestor2);
6374
6524
  }
6375
- let m3;
6376
6525
  let m4;
6526
+ let m5;
6377
6527
  return type === "Call" || // Block, except for if/else blocks when condition already lifted
6378
- type === "BlockStatement" && !((m3 = ancestor2.parent, typeof m3 === "object" && m3 != null && "type" in m3 && m3.type === "IfStatement") && liftedIfs.has(ancestor2.parent)) && !((m4 = ancestor2.parent, typeof m4 === "object" && m4 != null && "type" in m4 && m4.type === "ElseClause" && "parent" in m4 && typeof m4.parent === "object" && m4.parent != null && "type" in m4.parent && m4.parent.type === "IfStatement") && liftedIfs.has(ancestor2.parent.parent)) || type === "PipelineExpression" || // Declaration
6528
+ type === "BlockStatement" && !((m4 = ancestor2.parent, typeof m4 === "object" && m4 != null && "type" in m4 && m4.type === "IfStatement") && liftedIfs.has(ancestor2.parent)) && !((m5 = ancestor2.parent, typeof m5 === "object" && m5 != null && "type" in m5 && m5.type === "ElseClause" && "parent" in m5 && typeof m5.parent === "object" && m5.parent != null && "type" in m5.parent && m5.parent.type === "IfStatement") && liftedIfs.has(ancestor2.parent.parent)) || type === "PipelineExpression" || // Declaration
6379
6529
  type === "Initializer" || // Right-hand side of assignment
6380
6530
  type === "AssignmentExpression" && findChildIndex(ancestor2, child2) === ancestor2.children.indexOf(ancestor2.expression) || type === "ReturnStatement" || type === "YieldExpression";
6381
6531
  }));
@@ -6454,14 +6604,18 @@ ${js}`
6454
6604
  for (let i4 = 0, len3 = placeholders.length; i4 < len3; i4++) {
6455
6605
  const placeholder = placeholders[i4];
6456
6606
  typeSuffix ??= placeholder.typeSuffix;
6457
- let ref13;
6458
- replaceNode((ref13 = placeholder.children)[ref13.length - 1], ref);
6607
+ let ref17;
6608
+ replaceNode((ref17 = placeholder.children)[ref17.length - 1], ref);
6459
6609
  }
6460
6610
  const { parent } = ancestor;
6461
6611
  const body = maybeUnwrap(ancestor);
6462
6612
  let fnExp = makeAmpersandFunction({ ref, typeSuffix, body });
6463
6613
  let outer;
6464
6614
  switch (parent?.type) {
6615
+ case "Argument": {
6616
+ outer = ancestor === parent.expression;
6617
+ break;
6618
+ }
6465
6619
  case "Call": {
6466
6620
  outer = ancestor === parent.args[findChildIndex(parent.args, ancestor)];
6467
6621
  break;
@@ -6472,16 +6626,16 @@ ${js}`
6472
6626
  }
6473
6627
  case "PipelineExpression": {
6474
6628
  const i = findChildIndex(parent, ancestor);
6475
- let ref14;
6629
+ let ref18;
6476
6630
  if (i === 1) {
6477
- ref14 = ancestor === parent.children[i];
6631
+ ref18 = ancestor === parent.children[i];
6478
6632
  } else if (i === 2) {
6479
- ref14 = ancestor === parent.children[i][findChildIndex(parent.children[i], ancestor)][3];
6633
+ ref18 = ancestor === parent.children[i][findChildIndex(parent.children[i], ancestor)][3];
6480
6634
  } else {
6481
- ref14 = void 0;
6635
+ ref18 = void 0;
6482
6636
  }
6483
6637
  ;
6484
- outer = ref14;
6638
+ outer = ref18;
6485
6639
  break;
6486
6640
  }
6487
6641
  case "AssignmentExpression":
@@ -6496,9 +6650,9 @@ ${js}`
6496
6650
  fnExp = makeLeftHandSideExpression(fnExp);
6497
6651
  }
6498
6652
  replaceNode(ancestor, fnExp, parent);
6499
- let ref15;
6500
- if (ref15 = getTrimmingSpace(body)) {
6501
- const ws = ref15;
6653
+ let ref19;
6654
+ if (ref19 = getTrimmingSpace(body)) {
6655
+ const ws = ref19;
6502
6656
  inplaceInsertTrimmingSpace(body, "");
6503
6657
  inplacePrepend(ws, fnExp);
6504
6658
  }
@@ -6543,8 +6697,8 @@ ${js}`
6543
6697
  }
6544
6698
  ];
6545
6699
  }
6546
- let ref16;
6547
- if (Array.isArray(rest.delim) && (ref16 = rest.delim)[ref16.length - 1]?.token === ",") {
6700
+ let ref20;
6701
+ if (Array.isArray(rest.delim) && (ref20 = rest.delim)[ref20.length - 1]?.token === ",") {
6548
6702
  rest.delim = rest.delim.slice(0, -1);
6549
6703
  rest.children = [...rest.children.slice(0, -1), rest.delim];
6550
6704
  }
@@ -6705,13 +6859,13 @@ ${js}`
6705
6859
  AllowedTrailingCallExpressions,
6706
6860
  CommaDelimiter,
6707
6861
  ArgumentList,
6708
- NonPipelineArgumentList,
6709
6862
  NestedArgumentList,
6710
6863
  NestedArgument,
6711
6864
  SingleLineArgumentExpressions,
6865
+ WArgumentPart,
6712
6866
  ArgumentPart,
6713
- NonPipelineArgumentPart,
6714
6867
  BinaryOpExpression,
6868
+ BinaryOpNotDedented,
6715
6869
  BinaryOpRHS,
6716
6870
  IsLike,
6717
6871
  WRHS,
@@ -6720,6 +6874,8 @@ ${js}`
6720
6874
  UnaryExpression,
6721
6875
  UnaryWithoutParenthesizedAssignment,
6722
6876
  UnaryBody,
6877
+ MaybeNestedCoffeeDoBody,
6878
+ CoffeeDoBody,
6723
6879
  UnaryWithoutParenthesizedAssignmentBody,
6724
6880
  ParenthesizedAssignment,
6725
6881
  UnaryPostfix,
@@ -6742,12 +6898,15 @@ ${js}`
6742
6898
  FatArrowToken,
6743
6899
  TrailingDeclaration,
6744
6900
  TrailingPipe,
6901
+ TrailingPostfix,
6745
6902
  FatArrowBody,
6746
6903
  ConditionalExpression,
6747
6904
  TernaryRest,
6748
6905
  NestedTernaryRest,
6749
6906
  ShortCircuitExpression,
6750
6907
  PipelineExpression,
6908
+ PipelineExpressionBody,
6909
+ PipelineExpressionBodySameLine,
6751
6910
  PipelineHeadItem,
6752
6911
  PipelineTailItem,
6753
6912
  PrimaryExpression,
@@ -6957,7 +7116,6 @@ ${js}`
6957
7116
  PostfixedNoCommaStatement,
6958
7117
  PostfixedExpression,
6959
7118
  PostfixedCommaExpression,
6960
- NonPipelinePostfixedExpression,
6961
7119
  PostfixStatement,
6962
7120
  _PostfixStatement,
6963
7121
  Statement,
@@ -7035,10 +7193,18 @@ ${js}`
7035
7193
  AllowTrailingMemberProperty,
7036
7194
  RestoreTrailingMemberProperty,
7037
7195
  TrailingMemberPropertyAllowed,
7196
+ AllowNestedBinaryOp,
7197
+ ForbidNestedBinaryOp,
7198
+ RestoreNestedBinaryOp,
7199
+ NestedBinaryOpAllowed,
7038
7200
  AllowNewlineBinaryOp,
7039
7201
  ForbidNewlineBinaryOp,
7040
7202
  RestoreNewlineBinaryOp,
7041
7203
  NewlineBinaryOpAllowed,
7204
+ AllowPipeline,
7205
+ ForbidPipeline,
7206
+ RestorePipeline,
7207
+ PipelineAllowed,
7042
7208
  AllowAll,
7043
7209
  RestoreAll,
7044
7210
  CommaExpressionStatement,
@@ -7052,6 +7218,7 @@ ${js}`
7052
7218
  MaybeNestedNonPipelineExtendedExpression,
7053
7219
  MaybeNestedPostfixedExpression,
7054
7220
  MaybeNestedExtendedExpression,
7221
+ NestedExtendedExpression,
7055
7222
  MaybeParenNestedExtendedExpression,
7056
7223
  ImportDeclaration,
7057
7224
  ImpliedImport,
@@ -7986,16 +8153,16 @@ ${js}`
7986
8153
  function Arguments(ctx, state2) {
7987
8154
  return (0, import_lib3.$EVENT_C)(ctx, state2, "Arguments", Arguments$$);
7988
8155
  }
7989
- var ImplicitArguments$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(ApplicationStart, InsertOpenParen, (0, import_lib3.$E)(Trimmed_), NonPipelineArgumentList, InsertCloseParen), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
8156
+ var ImplicitArguments$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(ApplicationStart, InsertOpenParen, (0, import_lib3.$E)(Trimmed_), ForbidNestedBinaryOp, ForbidPipeline, (0, import_lib3.$E)(ArgumentList), RestorePipeline, RestoreNestedBinaryOp, InsertCloseParen), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
7990
8157
  var open = $2;
7991
8158
  var ws = $3;
7992
- var args = $4;
7993
- var close = $5;
8159
+ var args = $6;
8160
+ var close = $9;
8161
+ if (!args)
8162
+ return $skip;
7994
8163
  if (skipImplicitArguments(args))
7995
8164
  return $skip;
7996
- let last = args[args.length - 1];
7997
- if (last?.token === "," && last.implicit)
7998
- args = args.slice(0, -1);
8165
+ args = stripTrailingImplicitComma(args);
7999
8166
  return {
8000
8167
  type: "Call",
8001
8168
  args,
@@ -8105,33 +8272,7 @@ ${js}`
8105
8272
  function CommaDelimiter(ctx, state2) {
8106
8273
  return (0, import_lib3.$EVENT)(ctx, state2, "CommaDelimiter", CommaDelimiter$0);
8107
8274
  }
8108
- var ArgumentList$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(ArgumentPart, (0, import_lib3.$Q)((0, import_lib3.$S)(CommaDelimiter, (0, import_lib3.$N)(EOS), (0, import_lib3.$E)(_), ArgumentPart)), (0, import_lib3.$P)((0, import_lib3.$S)(CommaDelimiter, (0, import_lib3.$C)(NestedBulletedArray, NestedImplicitObjectLiteral, NestedArgumentList)))), function($skip, $loc, $0, $1, $2, $3) {
8109
- return [
8110
- $1,
8111
- ...$2.flatMap(([comma, eos, ws, arg]) => [comma, prepend(ws, arg)]),
8112
- ...$3.flatMap(
8113
- ([comma, args]) => Array.isArray(args) ? [comma, ...args] : [comma, args]
8114
- )
8115
- ];
8116
- });
8117
- var ArgumentList$1 = (0, import_lib3.$TS)((0, import_lib3.$S)(NestedBulletedArray), function($skip, $loc, $0, $1) {
8118
- return [trimFirstSpace($1)];
8119
- });
8120
- var ArgumentList$2 = (0, import_lib3.$TS)((0, import_lib3.$S)(NestedImplicitObjectLiteral), function($skip, $loc, $0, $1) {
8121
- return [trimFirstSpace($1)];
8122
- });
8123
- var ArgumentList$3 = NestedArgumentList;
8124
- var ArgumentList$4 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$E)(_), ArgumentPart, (0, import_lib3.$Q)((0, import_lib3.$S)(CommaDelimiter, (0, import_lib3.$E)(_), ArgumentPart))), function($skip, $loc, $0, $1, $2, $3) {
8125
- return [
8126
- prepend($1, $2),
8127
- ...$3.flatMap(([comma, ws, arg]) => [comma, prepend(ws, arg)])
8128
- ];
8129
- });
8130
- var ArgumentList$$ = [ArgumentList$0, ArgumentList$1, ArgumentList$2, ArgumentList$3, ArgumentList$4];
8131
- function ArgumentList(ctx, state2) {
8132
- return (0, import_lib3.$EVENT_C)(ctx, state2, "ArgumentList", ArgumentList$$);
8133
- }
8134
- var NonPipelineArgumentList$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$N)(EOS), NonPipelineArgumentPart, (0, import_lib3.$Q)((0, import_lib3.$S)(CommaDelimiter, (0, import_lib3.$N)(EOS), (0, import_lib3.$E)(_), NonPipelineArgumentPart)), (0, import_lib3.$P)((0, import_lib3.$S)(CommaDelimiter, (0, import_lib3.$C)(NestedBulletedArray, NestedImplicitObjectLiteral, NestedArgumentList)))), function($skip, $loc, $0, $1, $2, $3, $4) {
8275
+ var ArgumentList$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$N)(EOS), ArgumentPart, (0, import_lib3.$Q)((0, import_lib3.$S)(CommaDelimiter, (0, import_lib3.$N)(EOS), (0, import_lib3.$E)(_), ArgumentPart)), (0, import_lib3.$P)((0, import_lib3.$S)(CommaDelimiter, (0, import_lib3.$C)(NestedBulletedArray, NestedImplicitObjectLiteral, NestedArgumentList)))), function($skip, $loc, $0, $1, $2, $3, $4) {
8135
8276
  return [
8136
8277
  $2,
8137
8278
  ...$3.flatMap(([comma, eos, ws, arg]) => [comma, prepend(ws, arg)]),
@@ -8140,7 +8281,7 @@ ${js}`
8140
8281
  )
8141
8282
  ];
8142
8283
  });
8143
- var NonPipelineArgumentList$1 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$C)(NestedBulletedArray, NestedImplicitObjectLiteral), (0, import_lib3.$Q)((0, import_lib3.$S)(CommaDelimiter, (0, import_lib3.$C)(NestedBulletedArray, NestedImplicitObjectLiteral, NestedArgumentList)))), function($skip, $loc, $0, $1, $2) {
8284
+ var ArgumentList$1 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$C)(NestedBulletedArray, NestedImplicitObjectLiteral), (0, import_lib3.$Q)((0, import_lib3.$S)(CommaDelimiter, (0, import_lib3.$C)(NestedBulletedArray, NestedImplicitObjectLiteral, NestedArgumentList)))), function($skip, $loc, $0, $1, $2) {
8144
8285
  return [
8145
8286
  trimFirstSpace($1),
8146
8287
  ...$2.flatMap(
@@ -8148,19 +8289,19 @@ ${js}`
8148
8289
  )
8149
8290
  ];
8150
8291
  });
8151
- var NonPipelineArgumentList$2 = NestedArgumentList;
8152
- var NonPipelineArgumentList$3 = (0, import_lib3.$TS)((0, import_lib3.$S)(NonPipelineArgumentPart, (0, import_lib3.$Q)((0, import_lib3.$S)(CommaDelimiter, (0, import_lib3.$E)(_), NonPipelineArgumentPart))), function($skip, $loc, $0, $1, $2) {
8292
+ var ArgumentList$2 = NestedArgumentList;
8293
+ var ArgumentList$3 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$E)(_), ArgumentPart, (0, import_lib3.$Q)((0, import_lib3.$S)(CommaDelimiter, (0, import_lib3.$E)(_), ArgumentPart))), function($skip, $loc, $0, $1, $2, $3) {
8153
8294
  return [
8154
- $1,
8155
- ...$2.flatMap(([comma, ws, arg]) => [comma, prepend(ws, arg)])
8295
+ prepend($1, $2),
8296
+ ...$3.flatMap(([comma, ws, arg]) => [comma, prepend(ws, arg)])
8156
8297
  ];
8157
8298
  });
8158
- var NonPipelineArgumentList$$ = [NonPipelineArgumentList$0, NonPipelineArgumentList$1, NonPipelineArgumentList$2, NonPipelineArgumentList$3];
8159
- function NonPipelineArgumentList(ctx, state2) {
8160
- return (0, import_lib3.$EVENT_C)(ctx, state2, "NonPipelineArgumentList", NonPipelineArgumentList$$);
8299
+ var ArgumentList$$ = [ArgumentList$0, ArgumentList$1, ArgumentList$2, ArgumentList$3];
8300
+ function ArgumentList(ctx, state2) {
8301
+ return (0, import_lib3.$EVENT_C)(ctx, state2, "ArgumentList", ArgumentList$$);
8161
8302
  }
8162
- var NestedArgumentList$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(PushIndent, (0, import_lib3.$Q)(NestedArgument), PopIndent), function($skip, $loc, $0, $1, $2, $3) {
8163
- var args = $2;
8303
+ var NestedArgumentList$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(PushIndent, AllowPipeline, (0, import_lib3.$Q)(NestedArgument), RestorePipeline, PopIndent), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
8304
+ var args = $3;
8164
8305
  if (!args.length)
8165
8306
  return $skip;
8166
8307
  return args.flat();
@@ -8173,40 +8314,48 @@ ${js}`
8173
8314
  var args = $2;
8174
8315
  var comma = $3;
8175
8316
  let [arg0, ...rest] = args;
8176
- arg0 = [indent, ...arg0];
8317
+ arg0 = prepend(indent, arg0);
8177
8318
  return [arg0, ...rest, comma];
8178
8319
  });
8179
8320
  function NestedArgument(ctx, state2) {
8180
8321
  return (0, import_lib3.$EVENT)(ctx, state2, "NestedArgument", NestedArgument$0);
8181
8322
  }
8182
- var SingleLineArgumentExpressions$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$S)((0, import_lib3.$E)(_), ArgumentPart), (0, import_lib3.$Q)((0, import_lib3.$S)((0, import_lib3.$S)((0, import_lib3.$E)(_), Comma), (0, import_lib3.$S)((0, import_lib3.$E)(_), ArgumentPart)))), function($skip, $loc, $0, $1, $2) {
8323
+ var SingleLineArgumentExpressions$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(WArgumentPart, (0, import_lib3.$Q)((0, import_lib3.$S)((0, import_lib3.$S)((0, import_lib3.$E)(_), Comma), WArgumentPart))), function($skip, $loc, $0, $1, $2) {
8183
8324
  return [$1, ...$2.flat()];
8184
8325
  });
8185
8326
  function SingleLineArgumentExpressions(ctx, state2) {
8186
8327
  return (0, import_lib3.$EVENT)(ctx, state2, "SingleLineArgumentExpressions", SingleLineArgumentExpressions$0);
8187
8328
  }
8188
- var ArgumentPart$0 = (0, import_lib3.$S)(DotDotDot, ExtendedExpression);
8329
+ var WArgumentPart$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$E)(_), ArgumentPart), function($skip, $loc, $0, $1, $2) {
8330
+ return prepend($1, $2);
8331
+ });
8332
+ function WArgumentPart(ctx, state2) {
8333
+ return (0, import_lib3.$EVENT)(ctx, state2, "WArgumentPart", WArgumentPart$0);
8334
+ }
8335
+ var ArgumentPart$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(DotDotDot, ExtendedExpression), function($skip, $loc, $0, $1, $2) {
8336
+ var spread = $1;
8337
+ var expression = $2;
8338
+ return {
8339
+ type: "Argument",
8340
+ children: $0,
8341
+ expression,
8342
+ spread
8343
+ };
8344
+ });
8189
8345
  var ArgumentPart$1 = (0, import_lib3.$TS)((0, import_lib3.$S)(ExtendedExpression, (0, import_lib3.$E)(DotDotDot)), function($skip, $loc, $0, $1, $2) {
8190
- if ($2) {
8191
- return [$2, $1];
8192
- }
8193
- return $1;
8346
+ var expression = $1;
8347
+ var spread = $2;
8348
+ return {
8349
+ type: "Argument",
8350
+ children: spread ? [spread, expression] : [expression],
8351
+ expression,
8352
+ spread
8353
+ };
8194
8354
  });
8195
8355
  var ArgumentPart$$ = [ArgumentPart$0, ArgumentPart$1];
8196
8356
  function ArgumentPart(ctx, state2) {
8197
8357
  return (0, import_lib3.$EVENT_C)(ctx, state2, "ArgumentPart", ArgumentPart$$);
8198
8358
  }
8199
- var NonPipelineArgumentPart$0 = (0, import_lib3.$S)(DotDotDot, NonPipelineExtendedExpression);
8200
- var NonPipelineArgumentPart$1 = (0, import_lib3.$TS)((0, import_lib3.$S)(NonPipelineExtendedExpression, (0, import_lib3.$E)(DotDotDot)), function($skip, $loc, $0, $1, $2) {
8201
- if ($2) {
8202
- return [$2, $1];
8203
- }
8204
- return $1;
8205
- });
8206
- var NonPipelineArgumentPart$$ = [NonPipelineArgumentPart$0, NonPipelineArgumentPart$1];
8207
- function NonPipelineArgumentPart(ctx, state2) {
8208
- return (0, import_lib3.$EVENT_C)(ctx, state2, "NonPipelineArgumentPart", NonPipelineArgumentPart$$);
8209
- }
8210
8359
  var BinaryOpExpression$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(UnaryExpression, (0, import_lib3.$Q)(BinaryOpRHS)), function($skip, $loc, $0, $1, $2) {
8211
8360
  if (!$2.length)
8212
8361
  return $1;
@@ -8215,7 +8364,13 @@ ${js}`
8215
8364
  function BinaryOpExpression(ctx, state2) {
8216
8365
  return (0, import_lib3.$EVENT)(ctx, state2, "BinaryOpExpression", BinaryOpExpression$0);
8217
8366
  }
8218
- var BinaryOpRHS$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(NotDedented, IsLike, (0, import_lib3.$E)(_), PatternExpressionList), function($skip, $loc, $0, $1, $2, $3, $4) {
8367
+ var BinaryOpNotDedented$0 = (0, import_lib3.$T)((0, import_lib3.$S)((0, import_lib3.$C)(NestedBinaryOpAllowed, (0, import_lib3.$N)(Nested)), NotDedented), function(value) {
8368
+ return value[1];
8369
+ });
8370
+ function BinaryOpNotDedented(ctx, state2) {
8371
+ return (0, import_lib3.$EVENT)(ctx, state2, "BinaryOpNotDedented", BinaryOpNotDedented$0);
8372
+ }
8373
+ var BinaryOpRHS$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(BinaryOpNotDedented, IsLike, (0, import_lib3.$E)(_), PatternExpressionList), function($skip, $loc, $0, $1, $2, $3, $4) {
8219
8374
  var ws1 = $1;
8220
8375
  var op = $2;
8221
8376
  var ws2 = $3;
@@ -8278,17 +8433,18 @@ ${js}`
8278
8433
  function RHS(ctx, state2) {
8279
8434
  return (0, import_lib3.$EVENT_C)(ctx, state2, "RHS", RHS$$);
8280
8435
  }
8281
- var UnaryExpression$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$Q)(UnaryOp), UnaryBody, (0, import_lib3.$E)(UnaryPostfix)), function($skip, $loc, $0, $1, $2, $3) {
8436
+ var UnaryExpression$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(IndentedApplicationAllowed, (0, import_lib3.$P)(UnaryOp), (0, import_lib3.$C)(ArrayLiteral, NestedArgumentList), (0, import_lib3.$E)(UnaryPostfix)), function($skip, $loc, $0, $1, $2, $3, $4) {
8437
+ var pre = $2;
8438
+ var args = $3;
8439
+ var post = $4;
8440
+ return processUnaryNestedExpression(pre, args, post) ?? $skip;
8441
+ });
8442
+ var UnaryExpression$1 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$Q)(UnaryOp), UnaryBody, (0, import_lib3.$E)(UnaryPostfix)), function($skip, $loc, $0, $1, $2, $3) {
8282
8443
  var pre = $1;
8283
8444
  var exp = $2;
8284
8445
  var post = $3;
8285
8446
  return processUnaryExpression(pre, exp, post);
8286
8447
  });
8287
- var UnaryExpression$1 = (0, import_lib3.$TS)((0, import_lib3.$S)(CoffeeDoEnabled, Do, __, (0, import_lib3.$C)(ArrowFunction, (0, import_lib3.$S)(LeftHandSideExpression, (0, import_lib3.$N)((0, import_lib3.$S)(__, AssignmentOpSymbol))), ExtendedExpression)), function($skip, $loc, $0, $1, $2, $3, $4) {
8288
- var ws = $3;
8289
- var exp = $4;
8290
- return processCoffeeDo(ws, exp);
8291
- });
8292
8448
  var UnaryExpression$$ = [UnaryExpression$0, UnaryExpression$1];
8293
8449
  function UnaryExpression(ctx, state2) {
8294
8450
  return (0, import_lib3.$EVENT_C)(ctx, state2, "UnaryExpression", UnaryExpression$$);
@@ -8302,14 +8458,35 @@ ${js}`
8302
8458
  function UnaryWithoutParenthesizedAssignment(ctx, state2) {
8303
8459
  return (0, import_lib3.$EVENT)(ctx, state2, "UnaryWithoutParenthesizedAssignment", UnaryWithoutParenthesizedAssignment$0);
8304
8460
  }
8305
- var UnaryBody$0 = ParenthesizedAssignment;
8306
- var UnaryBody$1 = ExpressionizedStatementWithTrailingCallExpressions;
8307
- var UnaryBody$2 = UpdateExpression;
8308
- var UnaryBody$3 = NestedNonAssignmentExtendedExpression;
8309
- var UnaryBody$$ = [UnaryBody$0, UnaryBody$1, UnaryBody$2, UnaryBody$3];
8461
+ var UnaryBody$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(CoffeeDoEnabled, Do, MaybeNestedCoffeeDoBody), function($skip, $loc, $0, $1, $2, $3) {
8462
+ var body = $3;
8463
+ return processCoffeeDo(...body);
8464
+ });
8465
+ var UnaryBody$1 = ParenthesizedAssignment;
8466
+ var UnaryBody$2 = ExpressionizedStatementWithTrailingCallExpressions;
8467
+ var UnaryBody$3 = UpdateExpression;
8468
+ var UnaryBody$4 = NestedNonAssignmentExtendedExpression;
8469
+ var UnaryBody$$ = [UnaryBody$0, UnaryBody$1, UnaryBody$2, UnaryBody$3, UnaryBody$4];
8310
8470
  function UnaryBody(ctx, state2) {
8311
8471
  return (0, import_lib3.$EVENT_C)(ctx, state2, "UnaryBody", UnaryBody$$);
8312
8472
  }
8473
+ var MaybeNestedCoffeeDoBody$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(PushIndent, (0, import_lib3.$E)((0, import_lib3.$S)(Nested, CoffeeDoBody)), PopIndent), function($skip, $loc, $0, $1, $2, $3) {
8474
+ if (!$2)
8475
+ return $skip;
8476
+ return $2;
8477
+ });
8478
+ var MaybeNestedCoffeeDoBody$1 = (0, import_lib3.$S)((0, import_lib3.$E)(_), CoffeeDoBody);
8479
+ var MaybeNestedCoffeeDoBody$$ = [MaybeNestedCoffeeDoBody$0, MaybeNestedCoffeeDoBody$1];
8480
+ function MaybeNestedCoffeeDoBody(ctx, state2) {
8481
+ return (0, import_lib3.$EVENT_C)(ctx, state2, "MaybeNestedCoffeeDoBody", MaybeNestedCoffeeDoBody$$);
8482
+ }
8483
+ var CoffeeDoBody$0 = ArrowFunction;
8484
+ var CoffeeDoBody$1 = (0, import_lib3.$S)(LeftHandSideExpression, (0, import_lib3.$N)((0, import_lib3.$S)(__, AssignmentOpSymbol)));
8485
+ var CoffeeDoBody$2 = ExtendedExpression;
8486
+ var CoffeeDoBody$$ = [CoffeeDoBody$0, CoffeeDoBody$1, CoffeeDoBody$2];
8487
+ function CoffeeDoBody(ctx, state2) {
8488
+ return (0, import_lib3.$EVENT_C)(ctx, state2, "CoffeeDoBody", CoffeeDoBody$$);
8489
+ }
8313
8490
  var UnaryWithoutParenthesizedAssignmentBody$0 = UpdateExpression;
8314
8491
  var UnaryWithoutParenthesizedAssignmentBody$1 = ExpressionizedStatementWithTrailingCallExpressions;
8315
8492
  var UnaryWithoutParenthesizedAssignmentBody$2 = NestedNonAssignmentExtendedExpression;
@@ -8508,7 +8685,7 @@ ${js}`
8508
8685
  var ArrowFunction$1 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$E)((0, import_lib3.$S)(Async, _)), ArrowParameters, (0, import_lib3.$E)(ReturnTypeSuffix), FatArrow, FatArrowBody), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
8509
8686
  var async = $1;
8510
8687
  var parameters = $2;
8511
- var suffix = $3;
8688
+ var returnType = $3;
8512
8689
  var arrow = $4;
8513
8690
  var expOrBlock = $5;
8514
8691
  if (!async)
@@ -8519,13 +8696,13 @@ ${js}`
8519
8696
  modifier: {
8520
8697
  async: !!async.length
8521
8698
  },
8522
- returnType: suffix
8699
+ returnType
8523
8700
  },
8524
8701
  parameters,
8525
- returnType: suffix,
8702
+ returnType,
8526
8703
  async,
8527
8704
  block: expOrBlock,
8528
- children: [async, parameters, suffix, arrow, expOrBlock]
8705
+ children: [async, parameters, returnType, arrow, expOrBlock]
8529
8706
  };
8530
8707
  });
8531
8708
  var ArrowFunction$$ = [ArrowFunction$0, ArrowFunction$1];
@@ -8556,7 +8733,11 @@ ${js}`
8556
8733
  function TrailingPipe(ctx, state2) {
8557
8734
  return (0, import_lib3.$EVENT)(ctx, state2, "TrailingPipe", TrailingPipe$0);
8558
8735
  }
8559
- var FatArrowBody$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$N)(EOS), (0, import_lib3.$N)((0, import_lib3.$S)((0, import_lib3.$E)(_), ExpressionizedStatement)), NonPipelinePostfixedExpression, (0, import_lib3.$N)(TrailingDeclaration), (0, import_lib3.$N)(TrailingPipe), (0, import_lib3.$N)(SemicolonDelimiter)), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
8736
+ var TrailingPostfix$0 = (0, import_lib3.$S)((0, import_lib3.$E)(_), PostfixStatement);
8737
+ function TrailingPostfix(ctx, state2) {
8738
+ return (0, import_lib3.$EVENT)(ctx, state2, "TrailingPostfix", TrailingPostfix$0);
8739
+ }
8740
+ var FatArrowBody$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$N)(EOS), (0, import_lib3.$N)((0, import_lib3.$S)((0, import_lib3.$E)(_), ExpressionizedStatement)), NonPipelineExtendedExpression, (0, import_lib3.$N)(TrailingDeclaration), (0, import_lib3.$N)(TrailingPipe), (0, import_lib3.$N)(TrailingPostfix), (0, import_lib3.$N)(SemicolonDelimiter)), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7) {
8560
8741
  var exp = $3;
8561
8742
  if (exp.type === "ObjectExpression") {
8562
8743
  exp = makeLeftHandSideExpression(exp);
@@ -8606,10 +8787,10 @@ ${js}`
8606
8787
  function ShortCircuitExpression(ctx, state2) {
8607
8788
  return (0, import_lib3.$EVENT)(ctx, state2, "ShortCircuitExpression", ShortCircuitExpression$0);
8608
8789
  }
8609
- var PipelineExpression$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$E)(_), PipelineHeadItem, (0, import_lib3.$P)((0, import_lib3.$S)(NotDedented, Pipe, __, PipelineTailItem))), function($skip, $loc, $0, $1, $2, $3) {
8610
- var ws = $1;
8611
- var head = $2;
8612
- var body = $3;
8790
+ var PipelineExpression$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(PipelineAllowed, (0, import_lib3.$E)(_), PipelineHeadItem, PipelineExpressionBody), function($skip, $loc, $0, $1, $2, $3, $4) {
8791
+ var ws = $2;
8792
+ var head = $3;
8793
+ var body = $4;
8613
8794
  if (head.type === "ArrowFunction" && head.ampersandBlock) {
8614
8795
  const expressions = [{
8615
8796
  type: "PipelineExpression",
@@ -8631,6 +8812,25 @@ ${js}`
8631
8812
  function PipelineExpression(ctx, state2) {
8632
8813
  return (0, import_lib3.$EVENT)(ctx, state2, "PipelineExpression", PipelineExpression$0);
8633
8814
  }
8815
+ var PipelineExpressionBody$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(PipelineExpressionBodySameLine, PushIndent, (0, import_lib3.$Q)((0, import_lib3.$S)((0, import_lib3.$S)(Nested, Pipe, __, PipelineTailItem), PipelineExpressionBodySameLine)), PopIndent), function($skip, $loc, $0, $1, $2, $3, $4) {
8816
+ var first = $1;
8817
+ var rest = $3;
8818
+ if (!rest.length)
8819
+ return $skip;
8820
+ return [
8821
+ ...first,
8822
+ ...rest.map(([nested, line]) => [nested, ...line]).flat()
8823
+ ];
8824
+ });
8825
+ var PipelineExpressionBody$1 = (0, import_lib3.$P)((0, import_lib3.$S)(NotDedented, Pipe, __, PipelineTailItem));
8826
+ var PipelineExpressionBody$$ = [PipelineExpressionBody$0, PipelineExpressionBody$1];
8827
+ function PipelineExpressionBody(ctx, state2) {
8828
+ return (0, import_lib3.$EVENT_C)(ctx, state2, "PipelineExpressionBody", PipelineExpressionBody$$);
8829
+ }
8830
+ var PipelineExpressionBodySameLine$0 = (0, import_lib3.$Q)((0, import_lib3.$S)((0, import_lib3.$E)(_), Pipe, __, PipelineTailItem));
8831
+ function PipelineExpressionBodySameLine(ctx, state2) {
8832
+ return (0, import_lib3.$EVENT)(ctx, state2, "PipelineExpressionBodySameLine", PipelineExpressionBodySameLine$0);
8833
+ }
8634
8834
  var PipelineHeadItem$0 = NonPipelineExtendedExpression;
8635
8835
  var PipelineHeadItem$1 = ParenthesizedExpression;
8636
8836
  var PipelineHeadItem$$ = [PipelineHeadItem$0, PipelineHeadItem$1];
@@ -10257,7 +10457,7 @@ ${js}`
10257
10457
  var wid = $4;
10258
10458
  var w = $5;
10259
10459
  var parameters = $6;
10260
- var suffix = $7;
10460
+ var returnType = $7;
10261
10461
  if (!async)
10262
10462
  async = [];
10263
10463
  if (!generator)
@@ -10268,7 +10468,7 @@ ${js}`
10268
10468
  id,
10269
10469
  name: id?.name,
10270
10470
  parameters,
10271
- returnType: suffix,
10471
+ returnType,
10272
10472
  async,
10273
10473
  generator,
10274
10474
  modifier: {
@@ -10276,7 +10476,7 @@ ${js}`
10276
10476
  generator: !!generator.length
10277
10477
  },
10278
10478
  block: null,
10279
- children: !parameters.implicit ? [async, func, generator, wid, w, parameters, suffix] : [async, func, generator, wid, parameters, w, suffix]
10479
+ children: !parameters.implicit ? [async, func, generator, wid, w, parameters, returnType] : [async, func, generator, wid, parameters, w, returnType]
10280
10480
  // move whitespace w to after implicit () in parameters
10281
10481
  };
10282
10482
  });
@@ -10475,7 +10675,7 @@ ${js}`
10475
10675
  var behavior = $7;
10476
10676
  var w2 = $8;
10477
10677
  var parameters = $9;
10478
- var suffix = $10;
10678
+ var returnType = $10;
10479
10679
  if (!async)
10480
10680
  async = [];
10481
10681
  if (!generator)
@@ -10490,7 +10690,7 @@ ${js}`
10490
10690
  id,
10491
10691
  name: id.name,
10492
10692
  parameters,
10493
- returnType: suffix,
10693
+ returnType,
10494
10694
  async,
10495
10695
  generator,
10496
10696
  modifier: {
@@ -10498,7 +10698,7 @@ ${js}`
10498
10698
  generator: !!generator.length
10499
10699
  },
10500
10700
  block: null,
10501
- children: [async, func, generator, w1, id, w2, parameters, suffix],
10701
+ children: [async, func, generator, w1, id, w2, parameters, returnType],
10502
10702
  behavior
10503
10703
  };
10504
10704
  });
@@ -10545,7 +10745,7 @@ ${js}`
10545
10745
  var ThinArrowFunction$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$E)((0, import_lib3.$S)(Async, _)), ArrowParameters, (0, import_lib3.$E)(ReturnTypeSuffix), (0, import_lib3.$E)(_), Arrow, NoCommaBracedOrEmptyBlock), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
10546
10746
  var async = $1;
10547
10747
  var parameters = $2;
10548
- var suffix = $3;
10748
+ var returnType = $3;
10549
10749
  var arrow = $5;
10550
10750
  var block = $6;
10551
10751
  if (!async)
@@ -10555,7 +10755,7 @@ ${js}`
10555
10755
  type: "FunctionExpression",
10556
10756
  id: void 0,
10557
10757
  parameters,
10558
- returnType: suffix,
10758
+ returnType,
10559
10759
  async,
10560
10760
  generator,
10561
10761
  block,
@@ -10567,14 +10767,14 @@ ${js}`
10567
10767
  async: !!async.length,
10568
10768
  generator: !!generator.length
10569
10769
  },
10570
- returnType: suffix
10770
+ returnType
10571
10771
  },
10572
10772
  children: [
10573
10773
  async,
10574
10774
  { $loc: arrow.$loc, token: "function" },
10575
10775
  generator,
10576
10776
  parameters,
10577
- suffix,
10777
+ returnType,
10578
10778
  block
10579
10779
  ]
10580
10780
  };
@@ -11271,6 +11471,7 @@ ${js}`
11271
11471
  return {
11272
11472
  type: "SpreadElement",
11273
11473
  children: [ws, dots, exp],
11474
+ expression: exp,
11274
11475
  names: exp.names
11275
11476
  };
11276
11477
  });
@@ -11282,12 +11483,14 @@ ${js}`
11282
11483
  return {
11283
11484
  type: "ArrayElement",
11284
11485
  children: [exp],
11486
+ expression: exp,
11285
11487
  names: exp.names
11286
11488
  };
11287
11489
  } else {
11288
11490
  return {
11289
11491
  type: "SpreadElement",
11290
11492
  children: [...spread, exp],
11493
+ expression: exp,
11291
11494
  names: exp.names
11292
11495
  };
11293
11496
  }
@@ -11301,10 +11504,10 @@ ${js}`
11301
11504
  function ArrayElementExpression(ctx, state2) {
11302
11505
  return (0, import_lib3.$EVENT_C)(ctx, state2, "ArrayElementExpression", ArrayElementExpression$$);
11303
11506
  }
11304
- var NestedBulletedArray$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$S)(InsertSpace, InsertOpenBracket), PushIndent, (0, import_lib3.$Q)(NestedArrayBullet), InsertCloseBracket, PopIndent), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
11507
+ var NestedBulletedArray$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$S)(InsertSpace, InsertOpenBracket), PushIndent, AllowPipeline, (0, import_lib3.$Q)(NestedArrayBullet), RestorePipeline, InsertCloseBracket, PopIndent), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7) {
11305
11508
  var open = $1;
11306
- var content = $3;
11307
- var close = $4;
11509
+ var content = $4;
11510
+ var close = $6;
11308
11511
  if (!content.length)
11309
11512
  return $skip;
11310
11513
  content = content.flat();
@@ -11331,9 +11534,9 @@ ${js}`
11331
11534
  // replace first space with bracket
11332
11535
  ...content[1].flat()
11333
11536
  ];
11334
- const last = content[content.length - 1];
11537
+ let last = content[content.length - 1];
11335
11538
  if (last.children?.at(-1)?.implicit) {
11336
- last.children = last.children.slice(0, -1);
11539
+ content[content.length - 1] = last = { ...last, children: last.children.slice(0, -1) };
11337
11540
  }
11338
11541
  return {
11339
11542
  type: "ArrayExpression",
@@ -11471,8 +11674,8 @@ ${js}`
11471
11674
  function BracedObjectLiteralContent(ctx, state2) {
11472
11675
  return (0, import_lib3.$EVENT_C)(ctx, state2, "BracedObjectLiteralContent", BracedObjectLiteralContent$$);
11473
11676
  }
11474
- var NestedImplicitObjectLiteral$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(InsertOpenBrace, PushIndent, (0, import_lib3.$E)(NestedImplicitPropertyDefinitions), PopIndent, InsertNewline, InsertIndent, InsertCloseBrace), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7) {
11475
- var properties = $3;
11677
+ var NestedImplicitObjectLiteral$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(InsertOpenBrace, PushIndent, AllowPipeline, (0, import_lib3.$E)(NestedImplicitPropertyDefinitions), RestorePipeline, PopIndent, InsertNewline, InsertIndent, InsertCloseBrace), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
11678
+ var properties = $4;
11476
11679
  if (!properties)
11477
11680
  return $skip;
11478
11681
  return {
@@ -12165,18 +12368,23 @@ ${js}`
12165
12368
  return (0, import_lib3.$EVENT_C)(ctx, state2, "CoffeeWordAssignmentOp", CoffeeWordAssignmentOp$$);
12166
12369
  }
12167
12370
  var NotDedentedBinaryOp$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$E)(IndentedFurther), (0, import_lib3.$E)(_), BinaryOp), function($skip, $loc, $0, $1, $2, $3) {
12371
+ var ws1 = $1;
12372
+ var ws2 = $2;
12373
+ var op = $3;
12168
12374
  const ws = [];
12169
- if ($1)
12170
- ws.push(...$1);
12171
- if ($2)
12172
- ws.push(...$2);
12173
- return [ws, $3];
12375
+ if (ws1)
12376
+ ws.push(...ws1);
12377
+ if (ws2)
12378
+ ws.push(...ws2);
12379
+ return [ws, op];
12174
12380
  });
12175
- var NotDedentedBinaryOp$1 = (0, import_lib3.$TS)((0, import_lib3.$S)(Nested, (0, import_lib3.$E)(_), (0, import_lib3.$N)(Identifier), (0, import_lib3.$C)((0, import_lib3.$N)((0, import_lib3.$EXPECT)($L75, 'NotDedentedBinaryOp "*"')), (0, import_lib3.$N)(ImportDeclaration)), BinaryOp), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
12176
- var op = $5;
12177
- const ws = [...$1];
12178
- if ($2)
12179
- ws.push(...$2);
12381
+ var NotDedentedBinaryOp$1 = (0, import_lib3.$TS)((0, import_lib3.$S)(NestedBinaryOpAllowed, Nested, (0, import_lib3.$E)(_), (0, import_lib3.$N)(Identifier), (0, import_lib3.$C)((0, import_lib3.$N)((0, import_lib3.$EXPECT)($L75, 'NotDedentedBinaryOp "*"')), (0, import_lib3.$N)(ImportDeclaration)), BinaryOp), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
12382
+ var ws1 = $2;
12383
+ var ws2 = $3;
12384
+ var op = $6;
12385
+ const ws = [...ws1];
12386
+ if (ws2)
12387
+ ws.push(...ws2);
12180
12388
  return [ws, op];
12181
12389
  });
12182
12390
  var NotDedentedBinaryOp$$ = [NotDedentedBinaryOp$0, NotDedentedBinaryOp$1];
@@ -12604,16 +12812,6 @@ ${js}`
12604
12812
  function PostfixedCommaExpression(ctx, state2) {
12605
12813
  return (0, import_lib3.$EVENT)(ctx, state2, "PostfixedCommaExpression", PostfixedCommaExpression$0);
12606
12814
  }
12607
- var NonPipelinePostfixedExpression$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(NonPipelineExtendedExpression, (0, import_lib3.$E)((0, import_lib3.$S)((0, import_lib3.$E)(_), PostfixStatement))), function($skip, $loc, $0, $1, $2) {
12608
- var expression = $1;
12609
- var post = $2;
12610
- if (post)
12611
- return attachPostfixStatementAsExpression(expression, post);
12612
- return expression;
12613
- });
12614
- function NonPipelinePostfixedExpression(ctx, state2) {
12615
- return (0, import_lib3.$EVENT)(ctx, state2, "NonPipelinePostfixedExpression", NonPipelinePostfixedExpression$0);
12616
- }
12617
12815
  var PostfixStatement$0 = (0, import_lib3.$T)((0, import_lib3.$S)((0, import_lib3.$EXPECT)($R29, "PostfixStatement /(?=for|if|loop|unless|until|while)/"), _PostfixStatement), function(value) {
12618
12816
  return value[1];
12619
12817
  });
@@ -13223,14 +13421,14 @@ ${js}`
13223
13421
  }
13224
13422
  var ForBinding$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$C)(BindingPattern, BindingIdentifier), (0, import_lib3.$E)(TypeSuffix)), function($skip, $loc, $0, $1, $2) {
13225
13423
  var pattern = $1;
13226
- var suffix = $2;
13227
- suffix ??= pattern.typeSuffix;
13424
+ var typeSuffix = $2;
13425
+ typeSuffix ??= pattern.typeSuffix;
13228
13426
  return {
13229
13427
  type: "Binding",
13230
- children: [pattern, suffix],
13428
+ children: [pattern, typeSuffix],
13231
13429
  names: pattern.names,
13232
13430
  pattern,
13233
- suffix,
13431
+ typeSuffix,
13234
13432
  splices: [],
13235
13433
  thisAssignments: []
13236
13434
  };
@@ -13703,6 +13901,34 @@ ${js}`
13703
13901
  function TrailingMemberPropertyAllowed(ctx, state2) {
13704
13902
  return (0, import_lib3.$EVENT)(ctx, state2, "TrailingMemberPropertyAllowed", TrailingMemberPropertyAllowed$0);
13705
13903
  }
13904
+ var AllowNestedBinaryOp$0 = (0, import_lib3.$TV)((0, import_lib3.$EXPECT)($L0, 'AllowNestedBinaryOp ""'), function($skip, $loc, $0, $1) {
13905
+ state.forbidNestedBinaryOp.push(false);
13906
+ });
13907
+ function AllowNestedBinaryOp(ctx, state2) {
13908
+ return (0, import_lib3.$EVENT)(ctx, state2, "AllowNestedBinaryOp", AllowNestedBinaryOp$0);
13909
+ }
13910
+ var ForbidNestedBinaryOp$0 = (0, import_lib3.$TV)((0, import_lib3.$EXPECT)($L0, 'ForbidNestedBinaryOp ""'), function($skip, $loc, $0, $1) {
13911
+ state.forbidNestedBinaryOp.push(true);
13912
+ });
13913
+ function ForbidNestedBinaryOp(ctx, state2) {
13914
+ return (0, import_lib3.$EVENT)(ctx, state2, "ForbidNestedBinaryOp", ForbidNestedBinaryOp$0);
13915
+ }
13916
+ var RestoreNestedBinaryOp$0 = (0, import_lib3.$TV)((0, import_lib3.$EXPECT)($L0, 'RestoreNestedBinaryOp ""'), function($skip, $loc, $0, $1) {
13917
+ state.forbidNestedBinaryOp.pop();
13918
+ });
13919
+ function RestoreNestedBinaryOp(ctx, state2) {
13920
+ return (0, import_lib3.$EVENT)(ctx, state2, "RestoreNestedBinaryOp", RestoreNestedBinaryOp$0);
13921
+ }
13922
+ var NestedBinaryOpAllowed$0 = (0, import_lib3.$TV)((0, import_lib3.$EXPECT)($L0, 'NestedBinaryOpAllowed ""'), function($skip, $loc, $0, $1) {
13923
+ if (config.verbose) {
13924
+ console.log("forbidNestedBinaryOp:", state.forbidNestedBinaryOp);
13925
+ }
13926
+ if (state.nestedBinaryOpForbidden)
13927
+ return $skip;
13928
+ });
13929
+ function NestedBinaryOpAllowed(ctx, state2) {
13930
+ return (0, import_lib3.$EVENT)(ctx, state2, "NestedBinaryOpAllowed", NestedBinaryOpAllowed$0);
13931
+ }
13706
13932
  var AllowNewlineBinaryOp$0 = (0, import_lib3.$TV)((0, import_lib3.$EXPECT)($L0, 'AllowNewlineBinaryOp ""'), function($skip, $loc, $0, $1) {
13707
13933
  state.forbidNewlineBinaryOp.push(false);
13708
13934
  });
@@ -13731,11 +13957,39 @@ ${js}`
13731
13957
  function NewlineBinaryOpAllowed(ctx, state2) {
13732
13958
  return (0, import_lib3.$EVENT)(ctx, state2, "NewlineBinaryOpAllowed", NewlineBinaryOpAllowed$0);
13733
13959
  }
13734
- var AllowAll$0 = (0, import_lib3.$S)(AllowTrailingMemberProperty, AllowBracedApplication, AllowIndentedApplication, AllowClassImplicitCall, AllowNewlineBinaryOp);
13960
+ var AllowPipeline$0 = (0, import_lib3.$TV)((0, import_lib3.$EXPECT)($L0, 'AllowPipeline ""'), function($skip, $loc, $0, $1) {
13961
+ state.forbidPipeline.push(false);
13962
+ });
13963
+ function AllowPipeline(ctx, state2) {
13964
+ return (0, import_lib3.$EVENT)(ctx, state2, "AllowPipeline", AllowPipeline$0);
13965
+ }
13966
+ var ForbidPipeline$0 = (0, import_lib3.$TV)((0, import_lib3.$EXPECT)($L0, 'ForbidPipeline ""'), function($skip, $loc, $0, $1) {
13967
+ state.forbidPipeline.push(true);
13968
+ });
13969
+ function ForbidPipeline(ctx, state2) {
13970
+ return (0, import_lib3.$EVENT)(ctx, state2, "ForbidPipeline", ForbidPipeline$0);
13971
+ }
13972
+ var RestorePipeline$0 = (0, import_lib3.$TV)((0, import_lib3.$EXPECT)($L0, 'RestorePipeline ""'), function($skip, $loc, $0, $1) {
13973
+ state.forbidPipeline.pop();
13974
+ });
13975
+ function RestorePipeline(ctx, state2) {
13976
+ return (0, import_lib3.$EVENT)(ctx, state2, "RestorePipeline", RestorePipeline$0);
13977
+ }
13978
+ var PipelineAllowed$0 = (0, import_lib3.$TV)((0, import_lib3.$EXPECT)($L0, 'PipelineAllowed ""'), function($skip, $loc, $0, $1) {
13979
+ if (config.verbose) {
13980
+ console.log("forbidPipeline:", state.forbidPipeline);
13981
+ }
13982
+ if (state.pipelineForbidden)
13983
+ return $skip;
13984
+ });
13985
+ function PipelineAllowed(ctx, state2) {
13986
+ return (0, import_lib3.$EVENT)(ctx, state2, "PipelineAllowed", PipelineAllowed$0);
13987
+ }
13988
+ var AllowAll$0 = (0, import_lib3.$S)(AllowTrailingMemberProperty, AllowBracedApplication, AllowIndentedApplication, AllowClassImplicitCall, AllowNestedBinaryOp, AllowNewlineBinaryOp, AllowPipeline);
13735
13989
  function AllowAll(ctx, state2) {
13736
13990
  return (0, import_lib3.$EVENT)(ctx, state2, "AllowAll", AllowAll$0);
13737
13991
  }
13738
- var RestoreAll$0 = (0, import_lib3.$S)(RestoreTrailingMemberProperty, RestoreBracedApplication, RestoreIndentedApplication, RestoreClassImplicitCall, RestoreNewlineBinaryOp);
13992
+ var RestoreAll$0 = (0, import_lib3.$S)(RestoreTrailingMemberProperty, RestoreBracedApplication, RestoreIndentedApplication, RestoreClassImplicitCall, RestoreNestedBinaryOp, RestoreNewlineBinaryOp, RestorePipeline);
13739
13993
  function RestoreAll(ctx, state2) {
13740
13994
  return (0, import_lib3.$EVENT)(ctx, state2, "RestoreAll", RestoreAll$0);
13741
13995
  }
@@ -13867,6 +14121,16 @@ ${js}`
13867
14121
  function MaybeNestedExtendedExpression(ctx, state2) {
13868
14122
  return (0, import_lib3.$EVENT_C)(ctx, state2, "MaybeNestedExtendedExpression", MaybeNestedExtendedExpression$$);
13869
14123
  }
14124
+ var NestedExtendedExpression$0 = NestedBulletedArray;
14125
+ var NestedExtendedExpression$1 = (0, import_lib3.$TS)((0, import_lib3.$S)(PushIndent, (0, import_lib3.$E)((0, import_lib3.$S)(Nested, ExtendedExpression)), PopIndent), function($skip, $loc, $0, $1, $2, $3) {
14126
+ if ($3)
14127
+ return $3;
14128
+ return $skip;
14129
+ });
14130
+ var NestedExtendedExpression$$ = [NestedExtendedExpression$0, NestedExtendedExpression$1];
14131
+ function NestedExtendedExpression(ctx, state2) {
14132
+ return (0, import_lib3.$EVENT_C)(ctx, state2, "NestedExtendedExpression", NestedExtendedExpression$$);
14133
+ }
13870
14134
  var MaybeParenNestedExtendedExpression$0 = (0, import_lib3.$T)((0, import_lib3.$S)((0, import_lib3.$N)(EOS), ExtendedExpression), function(value) {
13871
14135
  return value[1];
13872
14136
  });
@@ -14361,16 +14625,16 @@ ${js}`
14361
14625
  }
14362
14626
  var LexicalBinding$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(BindingPattern, (0, import_lib3.$E)(TypeSuffix), Initializer), function($skip, $loc, $0, $1, $2, $3) {
14363
14627
  var pattern = $1;
14364
- var suffix = $2;
14628
+ var typeSuffix = $2;
14365
14629
  var initializer = $3;
14366
14630
  const [splices, thisAssignments] = gatherBindingCode(pattern);
14367
- suffix ??= pattern.typeSuffix;
14631
+ typeSuffix ??= pattern.typeSuffix;
14368
14632
  return {
14369
14633
  type: "Binding",
14370
- children: [pattern, suffix, initializer],
14634
+ children: [pattern, typeSuffix, initializer],
14371
14635
  names: pattern.names,
14372
14636
  pattern,
14373
- suffix,
14637
+ typeSuffix,
14374
14638
  initializer,
14375
14639
  splices: splices.map((s) => [",", s]),
14376
14640
  thisAssignments: thisAssignments.map((s) => ["", s, ";"])
@@ -14378,14 +14642,14 @@ ${js}`
14378
14642
  });
14379
14643
  var LexicalBinding$1 = (0, import_lib3.$TS)((0, import_lib3.$S)(BindingIdentifier, (0, import_lib3.$E)(TypeSuffix), (0, import_lib3.$E)(Initializer)), function($skip, $loc, $0, $1, $2, $3) {
14380
14644
  var pattern = $1;
14381
- var suffix = $2;
14645
+ var typeSuffix = $2;
14382
14646
  var initializer = $3;
14383
14647
  return {
14384
14648
  type: "Binding",
14385
14649
  children: $0,
14386
14650
  names: pattern.names,
14387
14651
  pattern,
14388
- suffix,
14652
+ typeSuffix,
14389
14653
  initializer,
14390
14654
  splices: [],
14391
14655
  thisAssignments: []
@@ -16330,14 +16594,14 @@ ${js}`
16330
16594
  }
16331
16595
  var UsingBinding$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(BindingIdentifier, (0, import_lib3.$E)(TypeSuffix), Initializer), function($skip, $loc, $0, $1, $2, $3) {
16332
16596
  var pattern = $1;
16333
- var suffix = $2;
16597
+ var typeSuffix = $2;
16334
16598
  var initializer = $3;
16335
16599
  return {
16336
16600
  type: "Binding",
16337
16601
  children: $0,
16338
16602
  names: pattern.names,
16339
16603
  pattern,
16340
- suffix,
16604
+ typeSuffix,
16341
16605
  initializer,
16342
16606
  splices: [],
16343
16607
  thisAssignments: []
@@ -16899,7 +17163,8 @@ ${js}`
16899
17163
  }
16900
17164
  var TypeUnarySuffix$0 = TypeIndexedAccess;
16901
17165
  var TypeUnarySuffix$1 = QuestionMark;
16902
- var TypeUnarySuffix$$ = [TypeUnarySuffix$0, TypeUnarySuffix$1];
17166
+ var TypeUnarySuffix$2 = NonNullAssertion;
17167
+ var TypeUnarySuffix$$ = [TypeUnarySuffix$0, TypeUnarySuffix$1, TypeUnarySuffix$2];
16903
17168
  function TypeUnarySuffix(ctx, state2) {
16904
17169
  return (0, import_lib3.$EVENT_C)(ctx, state2, "TypeUnarySuffix", TypeUnarySuffix$$);
16905
17170
  }
@@ -17894,7 +18159,9 @@ ${js}`
17894
18159
  state.forbidIndentedApplication = [false];
17895
18160
  state.forbidBracedApplication = [false];
17896
18161
  state.forbidTrailingMemberProperty = [false];
18162
+ state.forbidNestedBinaryOp = [false];
17897
18163
  state.forbidNewlineBinaryOp = [false];
18164
+ state.forbidPipeline = [false];
17898
18165
  state.JSXTagStack = [void 0];
17899
18166
  state.operators = /* @__PURE__ */ new Map();
17900
18167
  state.helperRefs = {};
@@ -18165,12 +18432,24 @@ ${js}`
18165
18432
  return s[s.length - 1];
18166
18433
  }
18167
18434
  },
18435
+ nestedBinaryOpForbidden: {
18436
+ get() {
18437
+ const { forbidNestedBinaryOp: s } = state;
18438
+ return s[s.length - 1];
18439
+ }
18440
+ },
18168
18441
  newlineBinaryOpForbidden: {
18169
18442
  get() {
18170
18443
  const { forbidNewlineBinaryOp: s } = state;
18171
18444
  return s[s.length - 1];
18172
18445
  }
18173
18446
  },
18447
+ pipelineForbidden: {
18448
+ get() {
18449
+ const { forbidPipeline: s } = state;
18450
+ return s[s.length - 1];
18451
+ }
18452
+ },
18174
18453
  currentJSXTag: {
18175
18454
  get() {
18176
18455
  const { JSXTagStack: s } = state;
@@ -18179,12 +18458,12 @@ ${js}`
18179
18458
  }
18180
18459
  });
18181
18460
  function getStateKey() {
18182
- const stateInt = state.currentIndent.level % 256 << 8 | state.classImplicitCallForbidden << 7 | state.indentedApplicationForbidden << 6 | state.bracedApplicationForbidden << 5 | state.trailingMemberPropertyForbidden << 4 | state.newlineBinaryOpForbidden << 3 | // This is slightly different than the rest of the state,
18461
+ const stateInt = state.currentIndent.level % 256 << 8 | state.classImplicitCallForbidden << 7 | state.indentedApplicationForbidden << 6 | state.bracedApplicationForbidden << 5 | state.trailingMemberPropertyForbidden << 4 | state.nestedBinaryOpForbidden << 3 | state.newlineBinaryOpForbidden << 2 | state.pipelineForbidden << 1 | // This is slightly different than the rest of the state,
18183
18462
  // since it is affected by the directive prologue and may be hit
18184
18463
  // by the EOL rule early in the parse. Later if we wanted to
18185
18464
  // allow block scoping of the compat directives we would need to
18186
18465
  // add them all here.
18187
- config.coffeeComment << 2;
18466
+ config.coffeeComment << 0;
18188
18467
  return [stateInt, state.currentJSXTag];
18189
18468
  }
18190
18469
  function parseProgram(input, options) {
@@ -18584,21 +18863,27 @@ ${js}`
18584
18863
  "AllowBracedApplication",
18585
18864
  "AllowIndentedApplication",
18586
18865
  "AllowMultiLineImplicitObjectLiteral",
18866
+ "AllowNestedBinaryOp",
18587
18867
  "AllowNewlineBinaryOp",
18588
18868
  "AllowTrailingMemberProperty",
18869
+ "AllowPipeline",
18589
18870
  "ForbidClassImplicitCall",
18590
18871
  "ForbidBracedApplication",
18591
18872
  "ForbidIndentedApplication",
18592
18873
  "ForbidMultiLineImplicitObjectLiteral",
18874
+ "ForbidNestedBinaryOp",
18593
18875
  "ForbidNewlineBinaryOp",
18594
18876
  "ForbidTrailingMemberProperty",
18877
+ "ForbidPipeline",
18595
18878
  "RestoreAll",
18596
18879
  "RestoreClassImplicitCall",
18597
18880
  "RestoreMultiLineImplicitObjectLiteral",
18598
18881
  "RestoreBracedApplication",
18599
18882
  "RestoreIndentedApplication",
18600
18883
  "RestoreTrailingMemberProperty",
18601
- "RestoreNewlineBinaryOp"
18884
+ "RestoreNestedBinaryOp",
18885
+ "RestoreNewlineBinaryOp",
18886
+ "RestorePipeline"
18602
18887
  ]);
18603
18888
  function compile(src, options) {
18604
18889
  if (!options) {
@@ -18743,13 +19028,16 @@ ${counts}`;
18743
19028
  };
18744
19029
  }
18745
19030
  if (trace) {
18746
- logs.push("".padStart(stack.length * 2, " ") + ruleName + ":" + state2.pos + "\u2192");
19031
+ logs.push("".padStart(stack.length * 2, " ") + ruleName + ":" + state2.pos + "{");
18747
19032
  stack.push(ruleName);
18748
19033
  }
18749
19034
  return;
18750
19035
  },
18751
19036
  exit: function(ruleName, state2, result) {
18752
19037
  if (uncacheable.has(ruleName)) {
19038
+ if (trace) {
19039
+ logs.push("".padStart(stack.length * 2, " ") + ruleName + ":" + state2.pos + "\u26A0\uFE0F " + (result ? "\u2705" : "\u274C"));
19040
+ }
18753
19041
  return;
18754
19042
  }
18755
19043
  const [stateKey, tagKey] = getStateKey();
@@ -18763,7 +19051,7 @@ ${counts}`;
18763
19051
  }
18764
19052
  if (trace) {
18765
19053
  stack.pop();
18766
- logs.push("".padStart(stack.length * 2, " ") + ruleName + ":" + state2.pos + " " + (result ? "\u2705" : "\u274C"));
19054
+ logs.push("".padStart(stack.length * 2, " ") + ruleName + ":" + state2.pos + "} " + (result ? "\u2705" : "\u274C"));
18767
19055
  }
18768
19056
  return;
18769
19057
  }