@danielx/civet 0.7.34 → 0.7.35

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
@@ -28,9 +28,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  mod
29
29
  ));
30
30
 
31
- // node_modules/.pnpm/@danielx+hera@0.8.16/node_modules/@danielx/hera/dist/machine.js
31
+ // node_modules/@danielx/hera/dist/machine.js
32
32
  var require_machine = __commonJS({
33
- "node_modules/.pnpm/@danielx+hera@0.8.16/node_modules/@danielx/hera/dist/machine.js"(exports, module) {
33
+ "node_modules/@danielx/hera/dist/machine.js"(exports, module) {
34
34
  "use strict";
35
35
  var __defProp2 = Object.defineProperty;
36
36
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
@@ -544,11 +544,13 @@ __export(lib_exports, {
544
544
  processProgramAsync: () => processProgramAsync,
545
545
  processTryBlock: () => processTryBlock,
546
546
  processUnaryExpression: () => processUnaryExpression,
547
+ processUnaryNestedExpression: () => processUnaryNestedExpression,
547
548
  quoteString: () => quoteString,
548
549
  reorderBindingRestProperty: () => reorderBindingRestProperty,
549
550
  replaceNode: () => replaceNode,
550
551
  replaceNodes: () => replaceNodes,
551
552
  skipImplicitArguments: () => skipImplicitArguments,
553
+ stripTrailingImplicitComma: () => stripTrailingImplicitComma,
552
554
  trimFirstSpace: () => trimFirstSpace,
553
555
  typeOfJSX: () => typeOfJSX,
554
556
  wrapIIFE: () => wrapIIFE
@@ -685,6 +687,40 @@ function isWhitespaceOrEmpty(node) {
685
687
  return node.every(isWhitespaceOrEmpty);
686
688
  return false;
687
689
  }
690
+ function firstNonSpace(node) {
691
+ if (!(node != null)) {
692
+ return;
693
+ }
694
+ if (Array.isArray(node)) {
695
+ for (let i2 = 0, len22 = node.length; i2 < len22; i2++) {
696
+ const child = node[i2];
697
+ let ref1;
698
+ if (ref1 = firstNonSpace(child)) {
699
+ const first = ref1;
700
+ return first;
701
+ }
702
+ }
703
+ return void 0;
704
+ } else if (isParent(node)) {
705
+ let ref2;
706
+ if (ref2 = firstNonSpace(node.children)) {
707
+ const first = ref2;
708
+ return first;
709
+ } else {
710
+ return node;
711
+ }
712
+ } else if (isToken(node)) {
713
+ let m;
714
+ if (m = node.token, typeof m === "string" && /^[ \t]*$/.test(m)) {
715
+ return;
716
+ }
717
+ } else if (typeof node === "string") {
718
+ if (typeof node === "string" && /^[ \t]*$/.test(node)) {
719
+ return;
720
+ }
721
+ }
722
+ return node;
723
+ }
688
724
  function isExit(node) {
689
725
  if (!(node != null)) {
690
726
  return false;
@@ -722,6 +758,14 @@ function isComma(node) {
722
758
  ;
723
759
  return;
724
760
  }
761
+ function stripTrailingImplicitComma(children) {
762
+ const last = children[children.length - 1];
763
+ if (isComma(last) && last.implicit) {
764
+ return children.slice(0, -1);
765
+ } else {
766
+ return children;
767
+ }
768
+ }
725
769
  function insertTrimmingSpace(target, c) {
726
770
  if (!(target != null)) {
727
771
  return target;
@@ -894,8 +938,8 @@ function startsWithPredicate(node, predicate, skip = isWhitespaceOrEmpty) {
894
938
  return void 0;
895
939
  }
896
940
  if (Array.isArray(node)) {
897
- for (let i2 = 0, len22 = node.length; i2 < len22; i2++) {
898
- const child = node[i2];
941
+ for (let i3 = 0, len3 = node.length; i3 < len3; i3++) {
942
+ const child = node[i3];
899
943
  if (skip(child)) {
900
944
  continue;
901
945
  }
@@ -982,6 +1026,9 @@ function makeLeftHandSideExpression(expression) {
982
1026
  return expression;
983
1027
  }
984
1028
  }
1029
+ return parenthesizeExpression(expression);
1030
+ }
1031
+ function parenthesizeExpression(expression) {
985
1032
  return makeNode({
986
1033
  type: "ParenthesizedExpression",
987
1034
  children: ["(", expression, ")"],
@@ -997,8 +1044,8 @@ function updateParentPointers(node, parent, depth = 1) {
997
1044
  return;
998
1045
  }
999
1046
  if (Array.isArray(node)) {
1000
- for (let i3 = 0, len3 = node.length; i3 < len3; i3++) {
1001
- const child = node[i3];
1047
+ for (let i4 = 0, len4 = node.length; i4 < len4; i4++) {
1048
+ const child = node[i4];
1002
1049
  updateParentPointers(child, parent, depth);
1003
1050
  }
1004
1051
  return;
@@ -1008,8 +1055,8 @@ function updateParentPointers(node, parent, depth = 1) {
1008
1055
  node.parent = parent;
1009
1056
  }
1010
1057
  if (depth && isParent(node)) {
1011
- for (let ref1 = node.children, i4 = 0, len4 = ref1.length; i4 < len4; i4++) {
1012
- const child = ref1[i4];
1058
+ for (let ref3 = node.children, i5 = 0, len5 = ref3.length; i5 < len5; i5++) {
1059
+ const child = ref3[i5];
1013
1060
  updateParentPointers(child, node, depth - 1);
1014
1061
  }
1015
1062
  }
@@ -1139,8 +1186,8 @@ function wrapIIFE(expressions, asyncFlag, generator) {
1139
1186
  children.splice(1, 0, ".bind(this)");
1140
1187
  }
1141
1188
  if (gatherRecursiveWithinFunction(block, (a2) => typeof a2 === "object" && a2 != null && "token" in a2 && a2.token === "arguments").length) {
1142
- let ref2;
1143
- children[children.length - 1] = (ref2 = parameters.children)[ref2.length - 1] = "(arguments)";
1189
+ let ref4;
1190
+ children[children.length - 1] = (ref4 = parameters.children)[ref4.length - 1] = "(arguments)";
1144
1191
  }
1145
1192
  }
1146
1193
  const exp = makeNode({
@@ -1163,9 +1210,9 @@ function wrapWithReturn(expression) {
1163
1210
  }
1164
1211
  function flatJoin(array, separator) {
1165
1212
  const result = [];
1166
- for (let i5 = 0, len5 = array.length; i5 < len5; i5++) {
1167
- const i = i5;
1168
- const items = array[i5];
1213
+ for (let i6 = 0, len6 = array.length; i6 < len6; i6++) {
1214
+ const i = i6;
1215
+ const items = array[i6];
1169
1216
  if (i) {
1170
1217
  result.push(separator);
1171
1218
  }
@@ -1564,12 +1611,6 @@ function isVoidType(t) {
1564
1611
  function isPromiseVoidType(t) {
1565
1612
  return t?.type === "TypeIdentifier" && t.raw === "Promise" && t.args?.types?.length === 1 && isVoidType(t.args.types[0]);
1566
1613
  }
1567
- function isGeneratorVoidType(t) {
1568
- return t?.type === "TypeIdentifier" && (t.raw === "Iterator" || t.raw === "Generator") && t.args?.types?.length >= 2 && isVoidType(t.args.types[1]);
1569
- }
1570
- function isAsyncGeneratorVoidType(t) {
1571
- return t?.type === "TypeIdentifier" && (t.raw === "AsyncIterator" || t.raw === "AsyncGenerator") && t.args?.types?.length >= 2 && isVoidType(t.args.types[1]);
1572
- }
1573
1614
  function implicitFunctionBlock(f) {
1574
1615
  if (f.abstract || f.block || f.signature?.optional)
1575
1616
  return;
@@ -1607,7 +1648,7 @@ function processReturn(f, implicitReturns) {
1607
1648
  const { async, generator, set } = modifier;
1608
1649
  const isMethod = f.type === "MethodDefinition";
1609
1650
  const isConstructor = isMethod && name === "constructor";
1610
- const isVoid = isVoidType(returnType2?.t) || async && (isPromiseVoidType(returnType2?.t) || generator && isAsyncGeneratorVoidType(returnType2?.t)) || !async && generator && isGeneratorVoidType(returnType2?.t);
1651
+ const isVoid = generator || isVoidType(returnType2?.t) || async && isPromiseVoidType(returnType2?.t);
1611
1652
  if (block?.type === "BlockStatement") {
1612
1653
  if (isVoid || set || isConstructor) {
1613
1654
  if (block.bare && block.implicitlyReturned) {
@@ -1623,10 +1664,7 @@ function processReturn(f, implicitReturns) {
1623
1664
  }
1624
1665
  function processReturnValue(func) {
1625
1666
  const { block } = func;
1626
- const values = gatherRecursiveWithinFunction(
1627
- block,
1628
- ({ type }) => type === "ReturnValue"
1629
- );
1667
+ const values = gatherRecursiveWithinFunction(block, ($) => $.type === "ReturnValue");
1630
1668
  if (!values.length) {
1631
1669
  return false;
1632
1670
  }
@@ -1636,7 +1674,7 @@ function processReturnValue(func) {
1636
1674
  value.children = [ref];
1637
1675
  const { ancestor, child } = findAncestor(
1638
1676
  value,
1639
- ({ type }) => type === "Declaration",
1677
+ ($1) => $1.type === "Declaration",
1640
1678
  isFunction
1641
1679
  );
1642
1680
  if (ancestor) {
@@ -1656,8 +1694,8 @@ function processReturnValue(func) {
1656
1694
  }
1657
1695
  }
1658
1696
  if (declaration) {
1659
- if (!(declaration.suffix != null)) {
1660
- declaration.children[1] = declaration.suffix = returnType;
1697
+ if (!(declaration.typeSuffix != null)) {
1698
+ declaration.children[1] = declaration.typeSuffix = returnType;
1661
1699
  }
1662
1700
  } else {
1663
1701
  block.expressions.unshift([
@@ -1997,7 +2035,7 @@ function processBreakContinueWith(statement) {
1997
2035
  let changed = false;
1998
2036
  for (const control of gatherRecursiveWithinFunction(
1999
2037
  statement.block,
2000
- ($) => $.type === "BreakStatement" || $.type === "ContinueStatement"
2038
+ ($2) => $2.type === "BreakStatement" || $2.type === "ContinueStatement"
2001
2039
  )) {
2002
2040
  let controlName2 = function() {
2003
2041
  switch (control.type) {
@@ -2032,7 +2070,7 @@ function processBreakContinueWith(statement) {
2032
2070
  )
2033
2071
  );
2034
2072
  updateParentPointers(control.with, control);
2035
- const i = control.children.findIndex(($1) => $1?.type === "Error");
2073
+ const i = control.children.findIndex(($3) => $3?.type === "Error");
2036
2074
  if (i >= 0) {
2037
2075
  control.children.splice(i, 1);
2038
2076
  }
@@ -2156,8 +2194,8 @@ function processSignature(f) {
2156
2194
  }
2157
2195
  if (hasYield(block) && !f.generator?.length) {
2158
2196
  if (f.type === "ArrowFunction") {
2159
- gatherRecursiveWithinFunction(block, ($2) => $2.type === "YieldExpression").forEach((y) => {
2160
- const i = y.children.findIndex(($3) => $3.type === "Yield");
2197
+ gatherRecursiveWithinFunction(block, ($4) => $4.type === "YieldExpression").forEach((y) => {
2198
+ const i = y.children.findIndex(($5) => $5.type === "Yield");
2161
2199
  return y.children.splice(i + 1, 0, {
2162
2200
  type: "Error",
2163
2201
  message: "Can't use yield inside of => arrow function"
@@ -2281,12 +2319,13 @@ function processCoffeeDo(ws, expression) {
2281
2319
  expression = {
2282
2320
  ...expression,
2283
2321
  parameters: newParameters,
2284
- children: expression.children.map(($4) => $4 === parameters ? newParameters : $4)
2322
+ children: expression.children.map(($6) => $6 === parameters ? newParameters : $6)
2285
2323
  };
2286
2324
  }
2287
2325
  return {
2288
2326
  type: "CallExpression",
2289
2327
  children: [
2328
+ ws,
2290
2329
  makeLeftHandSideExpression(expression),
2291
2330
  {
2292
2331
  type: "Call",
@@ -2302,7 +2341,7 @@ function makeAmpersandFunction(rhs) {
2302
2341
  ref = makeRef("$");
2303
2342
  inplacePrepend(ref, body);
2304
2343
  }
2305
- if (startsWithPredicate(body, ($5) => $5.type === "ObjectExpression")) {
2344
+ if (startsWithPredicate(body, ($7) => $7.type === "ObjectExpression")) {
2306
2345
  body = makeLeftHandSideExpression(body);
2307
2346
  }
2308
2347
  const parameters = makeNode({
@@ -3492,7 +3531,7 @@ function aliasBinding(p, ref) {
3492
3531
  function len2(arr, length) {
3493
3532
  return arr.length === length;
3494
3533
  }
3495
- function processAssignmentDeclaration(decl, pattern, suffix, ws, assign, e) {
3534
+ function processAssignmentDeclaration(decl, pattern, typeSuffix, ws, assign, e) {
3496
3535
  decl = {
3497
3536
  ...decl,
3498
3537
  $loc: {
@@ -3504,7 +3543,7 @@ function processAssignmentDeclaration(decl, pattern, suffix, ws, assign, e) {
3504
3543
  splices = splices.map((s) => [", ", s]);
3505
3544
  const thisAssignments = assignments.map((a) => ["", a, ";"]);
3506
3545
  if ("typeSuffix" in pattern) {
3507
- suffix ??= pattern.typeSuffix;
3546
+ typeSuffix ??= pattern.typeSuffix;
3508
3547
  }
3509
3548
  const initializer = makeNode({
3510
3549
  type: "Initializer",
@@ -3516,9 +3555,9 @@ function processAssignmentDeclaration(decl, pattern, suffix, ws, assign, e) {
3516
3555
  pattern,
3517
3556
  initializer,
3518
3557
  splices,
3519
- suffix,
3558
+ typeSuffix,
3520
3559
  thisAssignments,
3521
- children: [pattern, suffix, initializer]
3560
+ children: [pattern, typeSuffix, initializer]
3522
3561
  });
3523
3562
  const children = [decl, binding];
3524
3563
  return makeNode({
@@ -3535,9 +3574,9 @@ function processDeclarations(statements) {
3535
3574
  gatherRecursiveAll(statements, ($) => $.type === "Declaration").forEach((statement) => {
3536
3575
  const { bindings } = statement;
3537
3576
  return bindings?.forEach((binding) => {
3538
- const suffix = binding.suffix;
3539
- if (suffix && suffix.optional && suffix.t) {
3540
- convertOptionalType(suffix);
3577
+ const { typeSuffix } = binding;
3578
+ if (typeSuffix && typeSuffix.optional && typeSuffix.t) {
3579
+ convertOptionalType(typeSuffix);
3541
3580
  }
3542
3581
  const { initializer } = binding;
3543
3582
  if (initializer) {
@@ -3618,8 +3657,8 @@ function processDeclarationCondition(condition, rootCondition, parent) {
3618
3657
  }
3619
3658
  const { decl, bindings } = condition.declaration;
3620
3659
  const binding = bindings[0];
3621
- let { pattern, suffix, initializer } = binding;
3622
- const nullCheck = suffix?.optional && !suffix.t && !suffix.nonnull;
3660
+ let { pattern, typeSuffix, initializer } = binding;
3661
+ const nullCheck = typeSuffix?.optional && !typeSuffix.t && !typeSuffix.nonnull;
3623
3662
  if (!(initializer != null)) {
3624
3663
  condition.children = [
3625
3664
  {
@@ -3657,14 +3696,14 @@ function processDeclarationCondition(condition, rootCondition, parent) {
3657
3696
  if (nullCheck) {
3658
3697
  children.unshift("(");
3659
3698
  children.push(") != null");
3660
- suffix = void 0;
3699
+ typeSuffix = void 0;
3661
3700
  }
3662
3701
  Object.assign(condition, {
3663
3702
  type: "AssignmentExpression",
3664
3703
  children,
3665
3704
  hoistDec: !simple ? {
3666
3705
  type: "Declaration",
3667
- children: ["let ", ref, suffix],
3706
+ children: ["let ", ref, typeSuffix],
3668
3707
  names: []
3669
3708
  } : void 0,
3670
3709
  pattern,
@@ -3672,7 +3711,7 @@ function processDeclarationCondition(condition, rootCondition, parent) {
3672
3711
  });
3673
3712
  }
3674
3713
  updateParentPointers(condition, parent);
3675
- rootCondition.blockPrefix = getPatternBlockPrefix(pattern, ref, decl, suffix);
3714
+ rootCondition.blockPrefix = getPatternBlockPrefix(pattern, ref, decl, typeSuffix);
3676
3715
  }
3677
3716
  function processDeclarationConditions(node) {
3678
3717
  gatherRecursiveAll(
@@ -4050,6 +4089,10 @@ function processUnaryExpression(pre, exp, post) {
4050
4089
  };
4051
4090
  pre = pre.slice(0, -1);
4052
4091
  } else {
4092
+ let m;
4093
+ 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)) {
4094
+ exp = parenthesizeExpression(exp);
4095
+ }
4053
4096
  exp = {
4054
4097
  type: "AwaitExpression",
4055
4098
  children: [...last.children, exp]
@@ -4065,6 +4108,77 @@ function processUnaryExpression(pre, exp, post) {
4065
4108
  children: [...pre, exp, post]
4066
4109
  };
4067
4110
  }
4111
+ function processUnaryNestedExpression(pre, args, post) {
4112
+ const isArray = args.type === "ArrayExpression";
4113
+ if (!isArray) {
4114
+ args = stripTrailingImplicitComma(args);
4115
+ }
4116
+ if (isArray || args.length > 2) {
4117
+ const last = pre[pre.length - 1];
4118
+ if (!(typeof last === "object" && last != null && "type" in last && last.type === "Await")) {
4119
+ return;
4120
+ }
4121
+ if (last.op) {
4122
+ if (!isArray) {
4123
+ args = {
4124
+ type: "ArrayExpression",
4125
+ children: ["[", args, "]"]
4126
+ };
4127
+ }
4128
+ } else {
4129
+ pre.pop();
4130
+ if (!isArray) {
4131
+ args = args;
4132
+ args = {
4133
+ type: "ArrayExpression",
4134
+ children: [
4135
+ "[",
4136
+ ...(() => {
4137
+ const results = [];
4138
+ for (let i = 0, len3 = args.length; i < len3; i++) {
4139
+ const arg = args[i];
4140
+ if (typeof arg === "object" && arg != null && "type" in arg && arg.type === "Argument") {
4141
+ const expression = processUnaryExpression([last], arg.expression);
4142
+ results.push({
4143
+ ...arg,
4144
+ expression,
4145
+ children: arg.children.map(($) => $ === arg.expression ? expression : $)
4146
+ });
4147
+ } else {
4148
+ results.push(arg);
4149
+ }
4150
+ }
4151
+ return results;
4152
+ })(),
4153
+ "]"
4154
+ ]
4155
+ };
4156
+ } else {
4157
+ args = trimFirstSpace(args);
4158
+ args = {
4159
+ ...args,
4160
+ children: args.children.map(
4161
+ (arg) => {
4162
+ if (typeof arg === "object" && arg != null && "type" in arg && arg.type === "ArrayElement" && "expression" in arg && "children" in arg) {
4163
+ const { type, expression: exp, children } = arg;
4164
+ let expression = processUnaryExpression([last], trimFirstSpace(exp));
4165
+ expression = prepend(getTrimmingSpace(exp), expression);
4166
+ return {
4167
+ ...arg,
4168
+ expression,
4169
+ children: children.map(($1) => $1 === exp ? expression : $1)
4170
+ };
4171
+ } else {
4172
+ return arg;
4173
+ }
4174
+ }
4175
+ )
4176
+ };
4177
+ }
4178
+ }
4179
+ }
4180
+ return processUnaryExpression(pre, args, post);
4181
+ }
4068
4182
 
4069
4183
  // source/parser/pipe.civet
4070
4184
  function constructInvocation(fn, arg) {
@@ -4102,36 +4216,31 @@ function constructInvocation(fn, arg) {
4102
4216
  };
4103
4217
  }
4104
4218
  function constructPipeStep(fn, arg, returning) {
4219
+ if (!returning) {
4220
+ returning = null;
4221
+ }
4105
4222
  let children = [[fn.leadingComment, fn.expr, fn.trailingComment].map(skipIfOnlyWS), " ", arg];
4106
4223
  switch (fn.expr.token) {
4107
- case "yield":
4108
- case "await":
4109
- if (fn.expr.op) {
4110
- children = processUnaryExpression([fn.expr], arg, void 0);
4111
- }
4112
- if (returning) {
4113
- return [
4114
- children,
4115
- returning
4116
- ];
4117
- }
4224
+ case "await": {
4225
+ children = processUnaryExpression([fn.expr], arg, void 0);
4226
+ }
4227
+ case "yield": {
4118
4228
  return [
4119
4229
  children,
4120
- null
4230
+ returning
4121
4231
  ];
4122
- case "return":
4232
+ }
4233
+ case "return": {
4123
4234
  return [{
4124
4235
  type: "ReturnStatement",
4125
4236
  children
4126
4237
  }, null];
4238
+ }
4127
4239
  }
4128
- if (returning) {
4129
- return [
4130
- constructInvocation(fn, arg),
4131
- returning
4132
- ];
4133
- }
4134
- return [constructInvocation(fn, arg), null];
4240
+ return [
4241
+ constructInvocation(fn, arg),
4242
+ returning
4243
+ ];
4135
4244
  }
4136
4245
  function processPipelineExpressions(statements) {
4137
4246
  gatherRecursiveAll(statements, (n) => n.type === "PipelineExpression").forEach((s) => {
@@ -4388,7 +4497,29 @@ function processForInOf($0, getRef) {
4388
4497
  message: "'own' is only meaningful in for..in loops"
4389
4498
  };
4390
4499
  }
4391
- if (!declaration2 && !own) {
4500
+ const { binding } = declaration;
4501
+ let pattern = binding?.pattern;
4502
+ if (binding?.typeSuffix || inOf.token === "in" && declaration2 && pattern.type !== "Identifier") {
4503
+ const itemRef = makeRef(inOf.token === "in" ? "key" : "item");
4504
+ blockPrefix.push(["", {
4505
+ type: "Declaration",
4506
+ children: [declaration, " = ", itemRef],
4507
+ names: declaration.names
4508
+ }, ";"]);
4509
+ pattern = itemRef;
4510
+ declaration = {
4511
+ type: "ForDeclaration",
4512
+ binding: {
4513
+ type: "Binding",
4514
+ pattern,
4515
+ children: [pattern],
4516
+ names: []
4517
+ },
4518
+ children: ["const ", itemRef],
4519
+ names: []
4520
+ };
4521
+ }
4522
+ if (!(declaration2 || own)) {
4392
4523
  return {
4393
4524
  declaration,
4394
4525
  blockPrefix,
@@ -4427,29 +4558,6 @@ function processForInOf($0, getRef) {
4427
4558
  children: [" ", expRef2, " =", exp]
4428
4559
  };
4429
4560
  }
4430
- const { binding } = declaration;
4431
- let { pattern } = binding;
4432
- if (!(pattern.type === "Identifier")) {
4433
- const keyRef = makeRef("key");
4434
- blockPrefix.push(["", [
4435
- declaration,
4436
- " = ",
4437
- keyRef
4438
- ], ";"]);
4439
- pattern = keyRef;
4440
- declaration = {
4441
- type: "ForDeclaration",
4442
- binding: {
4443
- type: "Binding",
4444
- pattern,
4445
- children: [pattern],
4446
- names: [],
4447
- suffix: binding.suffix
4448
- },
4449
- children: ["const ", keyRef],
4450
- names: []
4451
- };
4452
- }
4453
4561
  if (own) {
4454
4562
  const hasPropRef = getRef("hasProp");
4455
4563
  blockPrefix.push(["", ["if (!", hasPropRef, "(", insertTrimmingSpace(expRef2, ""), ", ", insertTrimmingSpace(pattern, ""), ")) continue"], ";"]);
@@ -6131,44 +6239,82 @@ function attachPostfixStatementAsExpression(exp, post) {
6131
6239
  }
6132
6240
  function processTypes(node) {
6133
6241
  return gatherRecursiveAll(node, (n) => n.type === "TypeUnary").forEach((unary) => {
6134
- let last;
6135
- let count = 0;
6136
- let ref10;
6137
- while (unary.suffix.length && (ref10 = unary.suffix)[ref10.length - 1]?.token === "?") {
6138
- last = unary.suffix.pop();
6139
- count++;
6140
- }
6141
- if (!count) {
6242
+ if (!unary.suffix.length) {
6142
6243
  return;
6143
6244
  }
6144
- let ref11;
6145
- if (unary.suffix.length || unary.prefix.length)
6146
- ref11 = unary;
6147
- else
6148
- ref11 = unary.t;
6149
- const t = ref11;
6150
- if (unary.parent?.type === "TypeTuple") {
6151
- if (count === 1) {
6152
- unary.suffix.push(last);
6153
- return;
6245
+ let ref10;
6246
+ let m3;
6247
+ if (m3 = (ref10 = unary.suffix)[ref10.length - 1], typeof m3 === "object" && m3 != null && "token" in m3 && m3.token === "?") {
6248
+ const { token } = m3;
6249
+ let last;
6250
+ let count = 0;
6251
+ let ref11;
6252
+ while (unary.suffix.length && (ref11 = unary.suffix)[ref11.length - 1]?.token === "?") {
6253
+ last = unary.suffix.pop();
6254
+ count++;
6154
6255
  }
6155
- replaceNode(unary, [
6156
- getTrimmingSpace(unary),
6157
- "(",
6158
- parenthesizeType(trimFirstSpace(t)),
6159
- " | null)",
6160
- last
6161
- ]);
6162
- } else {
6163
- replaceNode(unary, {
6164
- type: "TypeParenthesized",
6165
- ts: true,
6166
- children: [
6256
+ let ref12;
6257
+ while (unary.suffix.length && (ref12 = unary.suffix)[ref12.length - 1]?.type === "NonNullAssertion") {
6258
+ unary.suffix.pop();
6259
+ }
6260
+ let ref13;
6261
+ if (unary.suffix.length || unary.prefix.length)
6262
+ ref13 = unary;
6263
+ else
6264
+ ref13 = unary.t;
6265
+ const t = ref13;
6266
+ if (unary.parent?.type === "TypeTuple") {
6267
+ if (count === 1) {
6268
+ unary.suffix.push(last);
6269
+ return;
6270
+ }
6271
+ replaceNode(unary, [
6167
6272
  getTrimmingSpace(unary),
6168
6273
  "(",
6169
6274
  parenthesizeType(trimFirstSpace(t)),
6170
- count === 1 ? " | undefined" : " | undefined | null",
6171
- ")"
6275
+ " | null)",
6276
+ last
6277
+ ]);
6278
+ } else {
6279
+ replaceNode(unary, {
6280
+ type: "TypeParenthesized",
6281
+ ts: true,
6282
+ children: [
6283
+ getTrimmingSpace(unary),
6284
+ "(",
6285
+ parenthesizeType(trimFirstSpace(t)),
6286
+ count === 1 ? " | undefined" : " | undefined | null",
6287
+ ")"
6288
+ ]
6289
+ });
6290
+ }
6291
+ } else if (typeof m3 === "object" && m3 != null && "type" in m3 && m3.type === "NonNullAssertion") {
6292
+ const { type } = m3;
6293
+ let ref14;
6294
+ while (unary.suffix.length && (ref14 = unary.suffix)[ref14.length - 1]?.type === "NonNullAssertion") {
6295
+ unary.suffix.pop();
6296
+ }
6297
+ let ref15;
6298
+ while (unary.suffix.length && (ref15 = unary.suffix)[ref15.length - 1]?.token === "?") {
6299
+ unary.suffix.pop();
6300
+ }
6301
+ const t = trimFirstSpace(
6302
+ unary.suffix.length || unary.prefix.length ? unary : unary.t
6303
+ );
6304
+ const args = {
6305
+ type: "TypeArguments",
6306
+ ts: true,
6307
+ types: [t],
6308
+ children: ["<", t, ">"]
6309
+ };
6310
+ replaceNode(unary, {
6311
+ type: "TypeIdentifier",
6312
+ raw: "NonNullable",
6313
+ args,
6314
+ children: [
6315
+ getTrimmingSpace(unary),
6316
+ "NonNullable",
6317
+ args
6172
6318
  ]
6173
6319
  });
6174
6320
  }
@@ -6178,11 +6324,11 @@ function processStatementExpressions(statements) {
6178
6324
  gatherRecursiveAll(statements, ($7) => $7.type === "StatementExpression").forEach((_exp) => {
6179
6325
  const exp = _exp;
6180
6326
  const { statement } = exp;
6181
- let ref12;
6327
+ let ref16;
6182
6328
  switch (statement.type) {
6183
6329
  case "IfStatement": {
6184
- if (ref12 = expressionizeIfStatement(statement)) {
6185
- const expression = ref12;
6330
+ if (ref16 = expressionizeIfStatement(statement)) {
6331
+ const expression = ref16;
6186
6332
  return replaceNode(statement, expression, exp);
6187
6333
  } else {
6188
6334
  return replaceNode(statement, wrapIIFE([["", statement]]), exp);
@@ -6328,10 +6474,10 @@ function processPlaceholders(statements) {
6328
6474
  if (type === "IfStatement") {
6329
6475
  liftedIfs.add(ancestor2);
6330
6476
  }
6331
- let m3;
6332
6477
  let m4;
6478
+ let m5;
6333
6479
  return type === "Call" || // Block, except for if/else blocks when condition already lifted
6334
- 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
6480
+ 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
6335
6481
  type === "Initializer" || // Right-hand side of assignment
6336
6482
  type === "AssignmentExpression" && findChildIndex(ancestor2, child2) === ancestor2.children.indexOf(ancestor2.expression) || type === "ReturnStatement" || type === "YieldExpression";
6337
6483
  }));
@@ -6410,8 +6556,8 @@ function processPlaceholders(statements) {
6410
6556
  for (let i4 = 0, len3 = placeholders.length; i4 < len3; i4++) {
6411
6557
  const placeholder = placeholders[i4];
6412
6558
  typeSuffix ??= placeholder.typeSuffix;
6413
- let ref13;
6414
- replaceNode((ref13 = placeholder.children)[ref13.length - 1], ref);
6559
+ let ref17;
6560
+ replaceNode((ref17 = placeholder.children)[ref17.length - 1], ref);
6415
6561
  }
6416
6562
  const { parent } = ancestor;
6417
6563
  const body = maybeUnwrap(ancestor);
@@ -6428,16 +6574,16 @@ function processPlaceholders(statements) {
6428
6574
  }
6429
6575
  case "PipelineExpression": {
6430
6576
  const i = findChildIndex(parent, ancestor);
6431
- let ref14;
6577
+ let ref18;
6432
6578
  if (i === 1) {
6433
- ref14 = ancestor === parent.children[i];
6579
+ ref18 = ancestor === parent.children[i];
6434
6580
  } else if (i === 2) {
6435
- ref14 = ancestor === parent.children[i][findChildIndex(parent.children[i], ancestor)][3];
6581
+ ref18 = ancestor === parent.children[i][findChildIndex(parent.children[i], ancestor)][3];
6436
6582
  } else {
6437
- ref14 = void 0;
6583
+ ref18 = void 0;
6438
6584
  }
6439
6585
  ;
6440
- outer = ref14;
6586
+ outer = ref18;
6441
6587
  break;
6442
6588
  }
6443
6589
  case "AssignmentExpression":
@@ -6452,9 +6598,9 @@ function processPlaceholders(statements) {
6452
6598
  fnExp = makeLeftHandSideExpression(fnExp);
6453
6599
  }
6454
6600
  replaceNode(ancestor, fnExp, parent);
6455
- let ref15;
6456
- if (ref15 = getTrimmingSpace(body)) {
6457
- const ws = ref15;
6601
+ let ref19;
6602
+ if (ref19 = getTrimmingSpace(body)) {
6603
+ const ws = ref19;
6458
6604
  inplaceInsertTrimmingSpace(body, "");
6459
6605
  inplacePrepend(ws, fnExp);
6460
6606
  }
@@ -6499,8 +6645,8 @@ function reorderBindingRestProperty(props) {
6499
6645
  }
6500
6646
  ];
6501
6647
  }
6502
- let ref16;
6503
- if (Array.isArray(rest.delim) && (ref16 = rest.delim)[ref16.length - 1]?.token === ",") {
6648
+ let ref20;
6649
+ if (Array.isArray(rest.delim) && (ref20 = rest.delim)[ref20.length - 1]?.token === ",") {
6504
6650
  rest.delim = rest.delim.slice(0, -1);
6505
6651
  rest.children = [...rest.children.slice(0, -1), rest.delim];
6506
6652
  }
@@ -6665,6 +6811,7 @@ var grammar = {
6665
6811
  NestedArgumentList,
6666
6812
  NestedArgument,
6667
6813
  SingleLineArgumentExpressions,
6814
+ WArgumentPart,
6668
6815
  ArgumentPart,
6669
6816
  NonPipelineArgumentPart,
6670
6817
  BinaryOpExpression,
@@ -6676,6 +6823,8 @@ var grammar = {
6676
6823
  UnaryExpression,
6677
6824
  UnaryWithoutParenthesizedAssignment,
6678
6825
  UnaryBody,
6826
+ MaybeNestedCoffeeDoBody,
6827
+ CoffeeDoBody,
6679
6828
  UnaryWithoutParenthesizedAssignmentBody,
6680
6829
  ParenthesizedAssignment,
6681
6830
  UnaryPostfix,
@@ -7008,6 +7157,7 @@ var grammar = {
7008
7157
  MaybeNestedNonPipelineExtendedExpression,
7009
7158
  MaybeNestedPostfixedExpression,
7010
7159
  MaybeNestedExtendedExpression,
7160
+ NestedExtendedExpression,
7011
7161
  MaybeParenNestedExtendedExpression,
7012
7162
  ImportDeclaration,
7013
7163
  ImpliedImport,
@@ -7949,9 +8099,7 @@ var ImplicitArguments$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(ApplicationSt
7949
8099
  var close = $5;
7950
8100
  if (skipImplicitArguments(args))
7951
8101
  return $skip;
7952
- let last = args[args.length - 1];
7953
- if (last?.token === "," && last.implicit)
7954
- args = args.slice(0, -1);
8102
+ args = stripTrailingImplicitComma(args);
7955
8103
  return {
7956
8104
  type: "Call",
7957
8105
  args,
@@ -8129,24 +8277,43 @@ var NestedArgument$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(Nested, SingleLi
8129
8277
  var args = $2;
8130
8278
  var comma = $3;
8131
8279
  let [arg0, ...rest] = args;
8132
- arg0 = [indent, ...arg0];
8280
+ arg0 = prepend(indent, arg0);
8133
8281
  return [arg0, ...rest, comma];
8134
8282
  });
8135
8283
  function NestedArgument(ctx, state2) {
8136
8284
  return (0, import_lib3.$EVENT)(ctx, state2, "NestedArgument", NestedArgument$0);
8137
8285
  }
8138
- 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) {
8286
+ 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) {
8139
8287
  return [$1, ...$2.flat()];
8140
8288
  });
8141
8289
  function SingleLineArgumentExpressions(ctx, state2) {
8142
8290
  return (0, import_lib3.$EVENT)(ctx, state2, "SingleLineArgumentExpressions", SingleLineArgumentExpressions$0);
8143
8291
  }
8144
- var ArgumentPart$0 = (0, import_lib3.$S)(DotDotDot, ExtendedExpression);
8292
+ var WArgumentPart$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$E)(_), ArgumentPart), function($skip, $loc, $0, $1, $2) {
8293
+ return prepend($1, $2);
8294
+ });
8295
+ function WArgumentPart(ctx, state2) {
8296
+ return (0, import_lib3.$EVENT)(ctx, state2, "WArgumentPart", WArgumentPart$0);
8297
+ }
8298
+ var ArgumentPart$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(DotDotDot, ExtendedExpression), function($skip, $loc, $0, $1, $2) {
8299
+ var spread = $1;
8300
+ var expression = $2;
8301
+ return {
8302
+ type: "Argument",
8303
+ children: $0,
8304
+ expression,
8305
+ spread
8306
+ };
8307
+ });
8145
8308
  var ArgumentPart$1 = (0, import_lib3.$TS)((0, import_lib3.$S)(ExtendedExpression, (0, import_lib3.$E)(DotDotDot)), function($skip, $loc, $0, $1, $2) {
8146
- if ($2) {
8147
- return [$2, $1];
8148
- }
8149
- return $1;
8309
+ var expression = $1;
8310
+ var spread = $2;
8311
+ return {
8312
+ type: "Argument",
8313
+ children: spread ? [spread, expression] : [expression],
8314
+ expression,
8315
+ spread
8316
+ };
8150
8317
  });
8151
8318
  var ArgumentPart$$ = [ArgumentPart$0, ArgumentPart$1];
8152
8319
  function ArgumentPart(ctx, state2) {
@@ -8234,17 +8401,18 @@ var RHS$$ = [RHS$0, RHS$1];
8234
8401
  function RHS(ctx, state2) {
8235
8402
  return (0, import_lib3.$EVENT_C)(ctx, state2, "RHS", RHS$$);
8236
8403
  }
8237
- 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) {
8404
+ 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) {
8405
+ var pre = $2;
8406
+ var args = $3;
8407
+ var post = $4;
8408
+ return processUnaryNestedExpression(pre, args, post) ?? $skip;
8409
+ });
8410
+ 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) {
8238
8411
  var pre = $1;
8239
8412
  var exp = $2;
8240
8413
  var post = $3;
8241
8414
  return processUnaryExpression(pre, exp, post);
8242
8415
  });
8243
- 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) {
8244
- var ws = $3;
8245
- var exp = $4;
8246
- return processCoffeeDo(ws, exp);
8247
- });
8248
8416
  var UnaryExpression$$ = [UnaryExpression$0, UnaryExpression$1];
8249
8417
  function UnaryExpression(ctx, state2) {
8250
8418
  return (0, import_lib3.$EVENT_C)(ctx, state2, "UnaryExpression", UnaryExpression$$);
@@ -8258,14 +8426,35 @@ var UnaryWithoutParenthesizedAssignment$0 = (0, import_lib3.$TS)((0, import_lib3
8258
8426
  function UnaryWithoutParenthesizedAssignment(ctx, state2) {
8259
8427
  return (0, import_lib3.$EVENT)(ctx, state2, "UnaryWithoutParenthesizedAssignment", UnaryWithoutParenthesizedAssignment$0);
8260
8428
  }
8261
- var UnaryBody$0 = ParenthesizedAssignment;
8262
- var UnaryBody$1 = ExpressionizedStatementWithTrailingCallExpressions;
8263
- var UnaryBody$2 = UpdateExpression;
8264
- var UnaryBody$3 = NestedNonAssignmentExtendedExpression;
8265
- var UnaryBody$$ = [UnaryBody$0, UnaryBody$1, UnaryBody$2, UnaryBody$3];
8429
+ var UnaryBody$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(CoffeeDoEnabled, Do, MaybeNestedCoffeeDoBody), function($skip, $loc, $0, $1, $2, $3) {
8430
+ var body = $3;
8431
+ return processCoffeeDo(...body);
8432
+ });
8433
+ var UnaryBody$1 = ParenthesizedAssignment;
8434
+ var UnaryBody$2 = ExpressionizedStatementWithTrailingCallExpressions;
8435
+ var UnaryBody$3 = UpdateExpression;
8436
+ var UnaryBody$4 = NestedNonAssignmentExtendedExpression;
8437
+ var UnaryBody$$ = [UnaryBody$0, UnaryBody$1, UnaryBody$2, UnaryBody$3, UnaryBody$4];
8266
8438
  function UnaryBody(ctx, state2) {
8267
8439
  return (0, import_lib3.$EVENT_C)(ctx, state2, "UnaryBody", UnaryBody$$);
8268
8440
  }
8441
+ 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) {
8442
+ if (!$2)
8443
+ return $skip;
8444
+ return $2;
8445
+ });
8446
+ var MaybeNestedCoffeeDoBody$1 = (0, import_lib3.$S)((0, import_lib3.$E)(_), CoffeeDoBody);
8447
+ var MaybeNestedCoffeeDoBody$$ = [MaybeNestedCoffeeDoBody$0, MaybeNestedCoffeeDoBody$1];
8448
+ function MaybeNestedCoffeeDoBody(ctx, state2) {
8449
+ return (0, import_lib3.$EVENT_C)(ctx, state2, "MaybeNestedCoffeeDoBody", MaybeNestedCoffeeDoBody$$);
8450
+ }
8451
+ var CoffeeDoBody$0 = ArrowFunction;
8452
+ var CoffeeDoBody$1 = (0, import_lib3.$S)(LeftHandSideExpression, (0, import_lib3.$N)((0, import_lib3.$S)(__, AssignmentOpSymbol)));
8453
+ var CoffeeDoBody$2 = ExtendedExpression;
8454
+ var CoffeeDoBody$$ = [CoffeeDoBody$0, CoffeeDoBody$1, CoffeeDoBody$2];
8455
+ function CoffeeDoBody(ctx, state2) {
8456
+ return (0, import_lib3.$EVENT_C)(ctx, state2, "CoffeeDoBody", CoffeeDoBody$$);
8457
+ }
8269
8458
  var UnaryWithoutParenthesizedAssignmentBody$0 = UpdateExpression;
8270
8459
  var UnaryWithoutParenthesizedAssignmentBody$1 = ExpressionizedStatementWithTrailingCallExpressions;
8271
8460
  var UnaryWithoutParenthesizedAssignmentBody$2 = NestedNonAssignmentExtendedExpression;
@@ -8464,7 +8653,7 @@ var ArrowFunction$0 = ThinArrowFunction;
8464
8653
  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) {
8465
8654
  var async = $1;
8466
8655
  var parameters = $2;
8467
- var suffix = $3;
8656
+ var returnType = $3;
8468
8657
  var arrow = $4;
8469
8658
  var expOrBlock = $5;
8470
8659
  if (!async)
@@ -8475,13 +8664,13 @@ var ArrowFunction$1 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$
8475
8664
  modifier: {
8476
8665
  async: !!async.length
8477
8666
  },
8478
- returnType: suffix
8667
+ returnType
8479
8668
  },
8480
8669
  parameters,
8481
- returnType: suffix,
8670
+ returnType,
8482
8671
  async,
8483
8672
  block: expOrBlock,
8484
- children: [async, parameters, suffix, arrow, expOrBlock]
8673
+ children: [async, parameters, returnType, arrow, expOrBlock]
8485
8674
  };
8486
8675
  });
8487
8676
  var ArrowFunction$$ = [ArrowFunction$0, ArrowFunction$1];
@@ -10213,7 +10402,7 @@ var FunctionSignature$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_li
10213
10402
  var wid = $4;
10214
10403
  var w = $5;
10215
10404
  var parameters = $6;
10216
- var suffix = $7;
10405
+ var returnType = $7;
10217
10406
  if (!async)
10218
10407
  async = [];
10219
10408
  if (!generator)
@@ -10224,7 +10413,7 @@ var FunctionSignature$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_li
10224
10413
  id,
10225
10414
  name: id?.name,
10226
10415
  parameters,
10227
- returnType: suffix,
10416
+ returnType,
10228
10417
  async,
10229
10418
  generator,
10230
10419
  modifier: {
@@ -10232,7 +10421,7 @@ var FunctionSignature$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_li
10232
10421
  generator: !!generator.length
10233
10422
  },
10234
10423
  block: null,
10235
- children: !parameters.implicit ? [async, func, generator, wid, w, parameters, suffix] : [async, func, generator, wid, parameters, w, suffix]
10424
+ children: !parameters.implicit ? [async, func, generator, wid, w, parameters, returnType] : [async, func, generator, wid, parameters, w, returnType]
10236
10425
  // move whitespace w to after implicit () in parameters
10237
10426
  };
10238
10427
  });
@@ -10431,7 +10620,7 @@ var OperatorSignature$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_li
10431
10620
  var behavior = $7;
10432
10621
  var w2 = $8;
10433
10622
  var parameters = $9;
10434
- var suffix = $10;
10623
+ var returnType = $10;
10435
10624
  if (!async)
10436
10625
  async = [];
10437
10626
  if (!generator)
@@ -10446,7 +10635,7 @@ var OperatorSignature$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_li
10446
10635
  id,
10447
10636
  name: id.name,
10448
10637
  parameters,
10449
- returnType: suffix,
10638
+ returnType,
10450
10639
  async,
10451
10640
  generator,
10452
10641
  modifier: {
@@ -10454,7 +10643,7 @@ var OperatorSignature$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_li
10454
10643
  generator: !!generator.length
10455
10644
  },
10456
10645
  block: null,
10457
- children: [async, func, generator, w1, id, w2, parameters, suffix],
10646
+ children: [async, func, generator, w1, id, w2, parameters, returnType],
10458
10647
  behavior
10459
10648
  };
10460
10649
  });
@@ -10501,7 +10690,7 @@ function OperatorAssociativity(ctx, state2) {
10501
10690
  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) {
10502
10691
  var async = $1;
10503
10692
  var parameters = $2;
10504
- var suffix = $3;
10693
+ var returnType = $3;
10505
10694
  var arrow = $5;
10506
10695
  var block = $6;
10507
10696
  if (!async)
@@ -10511,7 +10700,7 @@ var ThinArrowFunction$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_li
10511
10700
  type: "FunctionExpression",
10512
10701
  id: void 0,
10513
10702
  parameters,
10514
- returnType: suffix,
10703
+ returnType,
10515
10704
  async,
10516
10705
  generator,
10517
10706
  block,
@@ -10523,14 +10712,14 @@ var ThinArrowFunction$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_li
10523
10712
  async: !!async.length,
10524
10713
  generator: !!generator.length
10525
10714
  },
10526
- returnType: suffix
10715
+ returnType
10527
10716
  },
10528
10717
  children: [
10529
10718
  async,
10530
10719
  { $loc: arrow.$loc, token: "function" },
10531
10720
  generator,
10532
10721
  parameters,
10533
- suffix,
10722
+ returnType,
10534
10723
  block
10535
10724
  ]
10536
10725
  };
@@ -11227,6 +11416,7 @@ var ArrayElementExpression$2 = (0, import_lib3.$TS)((0, import_lib3.$S)(Extended
11227
11416
  return {
11228
11417
  type: "SpreadElement",
11229
11418
  children: [ws, dots, exp],
11419
+ expression: exp,
11230
11420
  names: exp.names
11231
11421
  };
11232
11422
  });
@@ -11238,12 +11428,14 @@ var ArrayElementExpression$3 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, impo
11238
11428
  return {
11239
11429
  type: "ArrayElement",
11240
11430
  children: [exp],
11431
+ expression: exp,
11241
11432
  names: exp.names
11242
11433
  };
11243
11434
  } else {
11244
11435
  return {
11245
11436
  type: "SpreadElement",
11246
11437
  children: [...spread, exp],
11438
+ expression: exp,
11247
11439
  names: exp.names
11248
11440
  };
11249
11441
  }
@@ -11287,9 +11479,9 @@ var BulletedArray$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(InsertOpenBracket
11287
11479
  // replace first space with bracket
11288
11480
  ...content[1].flat()
11289
11481
  ];
11290
- const last = content[content.length - 1];
11482
+ let last = content[content.length - 1];
11291
11483
  if (last.children?.at(-1)?.implicit) {
11292
- last.children = last.children.slice(0, -1);
11484
+ content[content.length - 1] = last = { ...last, children: last.children.slice(0, -1) };
11293
11485
  }
11294
11486
  return {
11295
11487
  type: "ArrayExpression",
@@ -13179,14 +13371,14 @@ function ForDeclaration(ctx, state2) {
13179
13371
  }
13180
13372
  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) {
13181
13373
  var pattern = $1;
13182
- var suffix = $2;
13183
- suffix ??= pattern.typeSuffix;
13374
+ var typeSuffix = $2;
13375
+ typeSuffix ??= pattern.typeSuffix;
13184
13376
  return {
13185
13377
  type: "Binding",
13186
- children: [pattern, suffix],
13378
+ children: [pattern, typeSuffix],
13187
13379
  names: pattern.names,
13188
13380
  pattern,
13189
- suffix,
13381
+ typeSuffix,
13190
13382
  splices: [],
13191
13383
  thisAssignments: []
13192
13384
  };
@@ -13823,6 +14015,16 @@ var MaybeNestedExtendedExpression$$ = [MaybeNestedExtendedExpression$0, MaybeNes
13823
14015
  function MaybeNestedExtendedExpression(ctx, state2) {
13824
14016
  return (0, import_lib3.$EVENT_C)(ctx, state2, "MaybeNestedExtendedExpression", MaybeNestedExtendedExpression$$);
13825
14017
  }
14018
+ var NestedExtendedExpression$0 = NestedBulletedArray;
14019
+ 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) {
14020
+ if ($3)
14021
+ return $3;
14022
+ return $skip;
14023
+ });
14024
+ var NestedExtendedExpression$$ = [NestedExtendedExpression$0, NestedExtendedExpression$1];
14025
+ function NestedExtendedExpression(ctx, state2) {
14026
+ return (0, import_lib3.$EVENT_C)(ctx, state2, "NestedExtendedExpression", NestedExtendedExpression$$);
14027
+ }
13826
14028
  var MaybeParenNestedExtendedExpression$0 = (0, import_lib3.$T)((0, import_lib3.$S)((0, import_lib3.$N)(EOS), ExtendedExpression), function(value) {
13827
14029
  return value[1];
13828
14030
  });
@@ -14317,16 +14519,16 @@ function TypeAssignment(ctx, state2) {
14317
14519
  }
14318
14520
  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) {
14319
14521
  var pattern = $1;
14320
- var suffix = $2;
14522
+ var typeSuffix = $2;
14321
14523
  var initializer = $3;
14322
14524
  const [splices, thisAssignments] = gatherBindingCode(pattern);
14323
- suffix ??= pattern.typeSuffix;
14525
+ typeSuffix ??= pattern.typeSuffix;
14324
14526
  return {
14325
14527
  type: "Binding",
14326
- children: [pattern, suffix, initializer],
14528
+ children: [pattern, typeSuffix, initializer],
14327
14529
  names: pattern.names,
14328
14530
  pattern,
14329
- suffix,
14531
+ typeSuffix,
14330
14532
  initializer,
14331
14533
  splices: splices.map((s) => [",", s]),
14332
14534
  thisAssignments: thisAssignments.map((s) => ["", s, ";"])
@@ -14334,14 +14536,14 @@ var LexicalBinding$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(BindingPattern,
14334
14536
  });
14335
14537
  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) {
14336
14538
  var pattern = $1;
14337
- var suffix = $2;
14539
+ var typeSuffix = $2;
14338
14540
  var initializer = $3;
14339
14541
  return {
14340
14542
  type: "Binding",
14341
14543
  children: $0,
14342
14544
  names: pattern.names,
14343
14545
  pattern,
14344
- suffix,
14546
+ typeSuffix,
14345
14547
  initializer,
14346
14548
  splices: [],
14347
14549
  thisAssignments: []
@@ -16286,14 +16488,14 @@ function UsingDeclaration(ctx, state2) {
16286
16488
  }
16287
16489
  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) {
16288
16490
  var pattern = $1;
16289
- var suffix = $2;
16491
+ var typeSuffix = $2;
16290
16492
  var initializer = $3;
16291
16493
  return {
16292
16494
  type: "Binding",
16293
16495
  children: $0,
16294
16496
  names: pattern.names,
16295
16497
  pattern,
16296
- suffix,
16498
+ typeSuffix,
16297
16499
  initializer,
16298
16500
  splices: [],
16299
16501
  thisAssignments: []
@@ -16855,7 +17057,8 @@ function TypeUnary(ctx, state2) {
16855
17057
  }
16856
17058
  var TypeUnarySuffix$0 = TypeIndexedAccess;
16857
17059
  var TypeUnarySuffix$1 = QuestionMark;
16858
- var TypeUnarySuffix$$ = [TypeUnarySuffix$0, TypeUnarySuffix$1];
17060
+ var TypeUnarySuffix$2 = NonNullAssertion;
17061
+ var TypeUnarySuffix$$ = [TypeUnarySuffix$0, TypeUnarySuffix$1, TypeUnarySuffix$2];
16859
17062
  function TypeUnarySuffix(ctx, state2) {
16860
17063
  return (0, import_lib3.$EVENT_C)(ctx, state2, "TypeUnarySuffix", TypeUnarySuffix$$);
16861
17064
  }