@danielx/civet 0.7.33 → 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
@@ -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
  }
@@ -1065,12 +1112,11 @@ function convertOptionalType(suffix) {
1065
1112
  ]);
1066
1113
  }
1067
1114
  var typeNeedsNoParens = /* @__PURE__ */ new Set([
1068
- "IdentifierType",
1115
+ "TypeIdentifier",
1069
1116
  "ImportType",
1070
- "LiteralType",
1117
+ "TypeLiteral",
1071
1118
  "TupleType",
1072
- "ParenthesizedType",
1073
- "UnaryType"
1119
+ "TypeParenthesized"
1074
1120
  ]);
1075
1121
  function parenthesizeType(type) {
1076
1122
  if (typeNeedsNoParens.has(type.type)) {
@@ -1140,8 +1186,8 @@ function wrapIIFE(expressions, asyncFlag, generator) {
1140
1186
  children.splice(1, 0, ".bind(this)");
1141
1187
  }
1142
1188
  if (gatherRecursiveWithinFunction(block, (a2) => typeof a2 === "object" && a2 != null && "token" in a2 && a2.token === "arguments").length) {
1143
- let ref2;
1144
- 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)";
1145
1191
  }
1146
1192
  }
1147
1193
  const exp = makeNode({
@@ -1164,9 +1210,9 @@ function wrapWithReturn(expression) {
1164
1210
  }
1165
1211
  function flatJoin(array, separator) {
1166
1212
  const result = [];
1167
- for (let i5 = 0, len5 = array.length; i5 < len5; i5++) {
1168
- const i = i5;
1169
- const items = array[i5];
1213
+ for (let i6 = 0, len6 = array.length; i6 < len6; i6++) {
1214
+ const i = i6;
1215
+ const items = array[i6];
1170
1216
  if (i) {
1171
1217
  result.push(separator);
1172
1218
  }
@@ -1560,16 +1606,10 @@ function gatherBindingPatternTypeSuffix(pattern) {
1560
1606
 
1561
1607
  // source/parser/function.civet
1562
1608
  function isVoidType(t) {
1563
- return t?.type === "LiteralType" && t.t.type === "VoidType";
1609
+ return t?.type === "TypeLiteral" && t.t.type === "VoidType";
1564
1610
  }
1565
1611
  function isPromiseVoidType(t) {
1566
- return t?.type === "IdentifierType" && t.raw === "Promise" && t.args?.types?.length === 1 && isVoidType(t.args.types[0]);
1567
- }
1568
- function isGeneratorVoidType(t) {
1569
- return t?.type === "IdentifierType" && (t.raw === "Iterator" || t.raw === "Generator") && t.args?.types?.length >= 2 && isVoidType(t.args.types[1]);
1570
- }
1571
- function isAsyncGeneratorVoidType(t) {
1572
- return t?.type === "IdentifierType" && (t.raw === "AsyncIterator" || t.raw === "AsyncGenerator") && t.args?.types?.length >= 2 && isVoidType(t.args.types[1]);
1612
+ return t?.type === "TypeIdentifier" && t.raw === "Promise" && t.args?.types?.length === 1 && isVoidType(t.args.types[0]);
1573
1613
  }
1574
1614
  function implicitFunctionBlock(f) {
1575
1615
  if (f.abstract || f.block || f.signature?.optional)
@@ -1608,7 +1648,7 @@ function processReturn(f, implicitReturns) {
1608
1648
  const { async, generator, set } = modifier;
1609
1649
  const isMethod = f.type === "MethodDefinition";
1610
1650
  const isConstructor = isMethod && name === "constructor";
1611
- 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);
1612
1652
  if (block?.type === "BlockStatement") {
1613
1653
  if (isVoid || set || isConstructor) {
1614
1654
  if (block.bare && block.implicitlyReturned) {
@@ -1624,10 +1664,7 @@ function processReturn(f, implicitReturns) {
1624
1664
  }
1625
1665
  function processReturnValue(func) {
1626
1666
  const { block } = func;
1627
- const values = gatherRecursiveWithinFunction(
1628
- block,
1629
- ({ type }) => type === "ReturnValue"
1630
- );
1667
+ const values = gatherRecursiveWithinFunction(block, ($) => $.type === "ReturnValue");
1631
1668
  if (!values.length) {
1632
1669
  return false;
1633
1670
  }
@@ -1637,7 +1674,7 @@ function processReturnValue(func) {
1637
1674
  value.children = [ref];
1638
1675
  const { ancestor, child } = findAncestor(
1639
1676
  value,
1640
- ({ type }) => type === "Declaration",
1677
+ ($1) => $1.type === "Declaration",
1641
1678
  isFunction
1642
1679
  );
1643
1680
  if (ancestor) {
@@ -1657,8 +1694,8 @@ function processReturnValue(func) {
1657
1694
  }
1658
1695
  }
1659
1696
  if (declaration) {
1660
- if (!(declaration.suffix != null)) {
1661
- declaration.children[1] = declaration.suffix = returnType;
1697
+ if (!(declaration.typeSuffix != null)) {
1698
+ declaration.children[1] = declaration.typeSuffix = returnType;
1662
1699
  }
1663
1700
  } else {
1664
1701
  block.expressions.unshift([
@@ -1767,14 +1804,13 @@ function assignResults(node, collect) {
1767
1804
  if (isExit(exp)) {
1768
1805
  return;
1769
1806
  }
1807
+ exp = exp;
1770
1808
  const outer = exp;
1771
- let { type } = exp;
1772
- if (type === "LabelledStatement") {
1809
+ if (exp.type === "LabelledStatement") {
1773
1810
  exp = exp.statement;
1774
- ({ type } = exp);
1775
1811
  }
1776
1812
  let ref4;
1777
- switch (type) {
1813
+ switch (exp.type) {
1778
1814
  case "BreakStatement":
1779
1815
  case "ContinueStatement":
1780
1816
  case "DebuggerStatement":
@@ -1999,7 +2035,7 @@ function processBreakContinueWith(statement) {
1999
2035
  let changed = false;
2000
2036
  for (const control of gatherRecursiveWithinFunction(
2001
2037
  statement.block,
2002
- ($) => $.type === "BreakStatement" || $.type === "ContinueStatement"
2038
+ ($2) => $2.type === "BreakStatement" || $2.type === "ContinueStatement"
2003
2039
  )) {
2004
2040
  let controlName2 = function() {
2005
2041
  switch (control.type) {
@@ -2034,7 +2070,7 @@ function processBreakContinueWith(statement) {
2034
2070
  )
2035
2071
  );
2036
2072
  updateParentPointers(control.with, control);
2037
- const i = control.children.findIndex(($1) => $1?.type === "Error");
2073
+ const i = control.children.findIndex(($3) => $3?.type === "Error");
2038
2074
  if (i >= 0) {
2039
2075
  control.children.splice(i, 1);
2040
2076
  }
@@ -2158,8 +2194,8 @@ function processSignature(f) {
2158
2194
  }
2159
2195
  if (hasYield(block) && !f.generator?.length) {
2160
2196
  if (f.type === "ArrowFunction") {
2161
- gatherRecursiveWithinFunction(block, ($2) => $2.type === "YieldExpression").forEach((y) => {
2162
- 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");
2163
2199
  return y.children.splice(i + 1, 0, {
2164
2200
  type: "Error",
2165
2201
  message: "Can't use yield inside of => arrow function"
@@ -2283,12 +2319,13 @@ function processCoffeeDo(ws, expression) {
2283
2319
  expression = {
2284
2320
  ...expression,
2285
2321
  parameters: newParameters,
2286
- children: expression.children.map(($4) => $4 === parameters ? newParameters : $4)
2322
+ children: expression.children.map(($6) => $6 === parameters ? newParameters : $6)
2287
2323
  };
2288
2324
  }
2289
2325
  return {
2290
2326
  type: "CallExpression",
2291
2327
  children: [
2328
+ ws,
2292
2329
  makeLeftHandSideExpression(expression),
2293
2330
  {
2294
2331
  type: "Call",
@@ -2304,7 +2341,7 @@ function makeAmpersandFunction(rhs) {
2304
2341
  ref = makeRef("$");
2305
2342
  inplacePrepend(ref, body);
2306
2343
  }
2307
- if (startsWithPredicate(body, ($5) => $5.type === "ObjectExpression")) {
2344
+ if (startsWithPredicate(body, ($7) => $7.type === "ObjectExpression")) {
2308
2345
  body = makeLeftHandSideExpression(body);
2309
2346
  }
2310
2347
  const parameters = makeNode({
@@ -3494,7 +3531,7 @@ function aliasBinding(p, ref) {
3494
3531
  function len2(arr, length) {
3495
3532
  return arr.length === length;
3496
3533
  }
3497
- function processAssignmentDeclaration(decl, pattern, suffix, ws, assign, e) {
3534
+ function processAssignmentDeclaration(decl, pattern, typeSuffix, ws, assign, e) {
3498
3535
  decl = {
3499
3536
  ...decl,
3500
3537
  $loc: {
@@ -3506,7 +3543,7 @@ function processAssignmentDeclaration(decl, pattern, suffix, ws, assign, e) {
3506
3543
  splices = splices.map((s) => [", ", s]);
3507
3544
  const thisAssignments = assignments.map((a) => ["", a, ";"]);
3508
3545
  if ("typeSuffix" in pattern) {
3509
- suffix ??= pattern.typeSuffix;
3546
+ typeSuffix ??= pattern.typeSuffix;
3510
3547
  }
3511
3548
  const initializer = makeNode({
3512
3549
  type: "Initializer",
@@ -3518,9 +3555,9 @@ function processAssignmentDeclaration(decl, pattern, suffix, ws, assign, e) {
3518
3555
  pattern,
3519
3556
  initializer,
3520
3557
  splices,
3521
- suffix,
3558
+ typeSuffix,
3522
3559
  thisAssignments,
3523
- children: [pattern, suffix, initializer]
3560
+ children: [pattern, typeSuffix, initializer]
3524
3561
  });
3525
3562
  const children = [decl, binding];
3526
3563
  return makeNode({
@@ -3537,9 +3574,9 @@ function processDeclarations(statements) {
3537
3574
  gatherRecursiveAll(statements, ($) => $.type === "Declaration").forEach((statement) => {
3538
3575
  const { bindings } = statement;
3539
3576
  return bindings?.forEach((binding) => {
3540
- const suffix = binding.suffix;
3541
- if (suffix && suffix.optional && suffix.t) {
3542
- convertOptionalType(suffix);
3577
+ const { typeSuffix } = binding;
3578
+ if (typeSuffix && typeSuffix.optional && typeSuffix.t) {
3579
+ convertOptionalType(typeSuffix);
3543
3580
  }
3544
3581
  const { initializer } = binding;
3545
3582
  if (initializer) {
@@ -3620,8 +3657,8 @@ function processDeclarationCondition(condition, rootCondition, parent) {
3620
3657
  }
3621
3658
  const { decl, bindings } = condition.declaration;
3622
3659
  const binding = bindings[0];
3623
- let { pattern, suffix, initializer } = binding;
3624
- const nullCheck = suffix?.optional && !suffix.t && !suffix.nonnull;
3660
+ let { pattern, typeSuffix, initializer } = binding;
3661
+ const nullCheck = typeSuffix?.optional && !typeSuffix.t && !typeSuffix.nonnull;
3625
3662
  if (!(initializer != null)) {
3626
3663
  condition.children = [
3627
3664
  {
@@ -3659,14 +3696,14 @@ function processDeclarationCondition(condition, rootCondition, parent) {
3659
3696
  if (nullCheck) {
3660
3697
  children.unshift("(");
3661
3698
  children.push(") != null");
3662
- suffix = void 0;
3699
+ typeSuffix = void 0;
3663
3700
  }
3664
3701
  Object.assign(condition, {
3665
3702
  type: "AssignmentExpression",
3666
3703
  children,
3667
3704
  hoistDec: !simple ? {
3668
3705
  type: "Declaration",
3669
- children: ["let ", ref, suffix],
3706
+ children: ["let ", ref, typeSuffix],
3670
3707
  names: []
3671
3708
  } : void 0,
3672
3709
  pattern,
@@ -3674,7 +3711,7 @@ function processDeclarationCondition(condition, rootCondition, parent) {
3674
3711
  });
3675
3712
  }
3676
3713
  updateParentPointers(condition, parent);
3677
- rootCondition.blockPrefix = getPatternBlockPrefix(pattern, ref, decl, suffix);
3714
+ rootCondition.blockPrefix = getPatternBlockPrefix(pattern, ref, decl, typeSuffix);
3678
3715
  }
3679
3716
  function processDeclarationConditions(node) {
3680
3717
  gatherRecursiveAll(
@@ -3776,9 +3813,6 @@ function processDeclarationConditionStatement(s) {
3776
3813
  }
3777
3814
  } else {
3778
3815
  const block = blockWithPrefix(blockPrefix, s.then);
3779
- if (block.bare && e && !block.semicolon) {
3780
- block.children.push(block.semicolon = ";");
3781
- }
3782
3816
  s.children = s.children.map(($2) => $2 === s.then ? block : $2);
3783
3817
  s.then = block;
3784
3818
  updateParentPointers(s);
@@ -4055,6 +4089,10 @@ function processUnaryExpression(pre, exp, post) {
4055
4089
  };
4056
4090
  pre = pre.slice(0, -1);
4057
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
+ }
4058
4096
  exp = {
4059
4097
  type: "AwaitExpression",
4060
4098
  children: [...last.children, exp]
@@ -4070,6 +4108,77 @@ function processUnaryExpression(pre, exp, post) {
4070
4108
  children: [...pre, exp, post]
4071
4109
  };
4072
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
+ }
4073
4182
 
4074
4183
  // source/parser/pipe.civet
4075
4184
  function constructInvocation(fn, arg) {
@@ -4107,36 +4216,31 @@ function constructInvocation(fn, arg) {
4107
4216
  };
4108
4217
  }
4109
4218
  function constructPipeStep(fn, arg, returning) {
4219
+ if (!returning) {
4220
+ returning = null;
4221
+ }
4110
4222
  let children = [[fn.leadingComment, fn.expr, fn.trailingComment].map(skipIfOnlyWS), " ", arg];
4111
4223
  switch (fn.expr.token) {
4112
- case "yield":
4113
- case "await":
4114
- if (fn.expr.op) {
4115
- children = processUnaryExpression([fn.expr], arg, void 0);
4116
- }
4117
- if (returning) {
4118
- return [
4119
- children,
4120
- returning
4121
- ];
4122
- }
4224
+ case "await": {
4225
+ children = processUnaryExpression([fn.expr], arg, void 0);
4226
+ }
4227
+ case "yield": {
4123
4228
  return [
4124
4229
  children,
4125
- null
4230
+ returning
4126
4231
  ];
4127
- case "return":
4232
+ }
4233
+ case "return": {
4128
4234
  return [{
4129
4235
  type: "ReturnStatement",
4130
4236
  children
4131
4237
  }, null];
4238
+ }
4132
4239
  }
4133
- if (returning) {
4134
- return [
4135
- constructInvocation(fn, arg),
4136
- returning
4137
- ];
4138
- }
4139
- return [constructInvocation(fn, arg), null];
4240
+ return [
4241
+ constructInvocation(fn, arg),
4242
+ returning
4243
+ ];
4140
4244
  }
4141
4245
  function processPipelineExpressions(statements) {
4142
4246
  gatherRecursiveAll(statements, (n) => n.type === "PipelineExpression").forEach((s) => {
@@ -4393,7 +4497,29 @@ function processForInOf($0, getRef) {
4393
4497
  message: "'own' is only meaningful in for..in loops"
4394
4498
  };
4395
4499
  }
4396
- 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)) {
4397
4523
  return {
4398
4524
  declaration,
4399
4525
  blockPrefix,
@@ -4432,29 +4558,6 @@ function processForInOf($0, getRef) {
4432
4558
  children: [" ", expRef2, " =", exp]
4433
4559
  };
4434
4560
  }
4435
- const { binding } = declaration;
4436
- let { pattern } = binding;
4437
- if (!(pattern.type === "Identifier")) {
4438
- const keyRef = makeRef("key");
4439
- blockPrefix.push(["", [
4440
- declaration,
4441
- " = ",
4442
- keyRef
4443
- ], ";"]);
4444
- pattern = keyRef;
4445
- declaration = {
4446
- type: "ForDeclaration",
4447
- binding: {
4448
- type: "Binding",
4449
- pattern,
4450
- children: [pattern],
4451
- names: [],
4452
- suffix: binding.suffix
4453
- },
4454
- children: ["const ", keyRef],
4455
- names: []
4456
- };
4457
- }
4458
4561
  if (own) {
4459
4562
  const hasPropRef = getRef("hasProp");
4460
4563
  blockPrefix.push(["", ["if (!", hasPropRef, "(", insertTrimmingSpace(expRef2, ""), ", ", insertTrimmingSpace(pattern, ""), ")) continue"], ";"]);
@@ -4487,7 +4590,8 @@ var concatAssign = (lhs, rhs) => (rhs?.[Symbol.isConcatSpreadable] ?? Array.isAr
4487
4590
  function findDecs(statements) {
4488
4591
  const declarations = gatherNodes(statements, ($) => $.type === "Declaration");
4489
4592
  const declarationNames = declarations.flatMap((d) => d.names);
4490
- return new Set(declarationNames);
4593
+ const globals = getConfig().globals || [];
4594
+ return new Set(globals.concat(declarationNames));
4491
4595
  }
4492
4596
  function createConstLetDecs(statements, scopes, letOrConst) {
4493
4597
  function findVarDecs(statements2, decs) {
@@ -5339,7 +5443,7 @@ function expressionizeIfStatement(statement) {
5339
5443
  function expressionizeTypeIf([ifOp, condition, t, e]) {
5340
5444
  const children = [
5341
5445
  "(",
5342
- insertTrimmingSpace(condition, ""),
5446
+ trimFirstSpace(condition),
5343
5447
  "?"
5344
5448
  ];
5345
5449
  if (!xor(ifOp.negated, condition.negated)) {
@@ -5522,7 +5626,7 @@ function processCallMemberExpression(node) {
5522
5626
  [name, value] = [value, name];
5523
5627
  }
5524
5628
  if (!suppressPrefix) {
5525
- value = prefix.concat(insertTrimmingSpace(value, ""));
5629
+ value = prefix.concat(trimFirstSpace(value));
5526
5630
  }
5527
5631
  if (wValue)
5528
5632
  value.unshift(wValue);
@@ -5748,7 +5852,7 @@ function convertObjectToJSXAttributes(obj) {
5748
5852
  if (part.name.type === "ComputedPropertyName") {
5749
5853
  rest.push(part);
5750
5854
  } else {
5751
- parts.push([part.name, "={", insertTrimmingSpace(part.value, ""), "}"]);
5855
+ parts.push([part.name, "={", trimFirstSpace(part.value), "}"]);
5752
5856
  }
5753
5857
  break;
5754
5858
  case "SpreadProperty":
@@ -5773,7 +5877,7 @@ function convertObjectToJSXAttributes(obj) {
5773
5877
  }
5774
5878
  function makeGetterMethod(name, ws, value, returnType, block, kind = { token: "get" }, autoReturn = true) {
5775
5879
  const { token } = kind;
5776
- ws = insertTrimmingSpace(ws, "");
5880
+ ws = trimFirstSpace(ws);
5777
5881
  let setVal;
5778
5882
  const parameters = token === "get" ? {
5779
5883
  type: "Parameters",
@@ -6134,37 +6238,85 @@ function attachPostfixStatementAsExpression(exp, post) {
6134
6238
  }
6135
6239
  }
6136
6240
  function processTypes(node) {
6137
- return gatherRecursiveAll(node, (n) => n.type === "UnaryType").forEach((unary) => {
6138
- let last;
6139
- let count = 0;
6140
- let ref10;
6141
- while (unary.suffix.length && (ref10 = unary.suffix)[ref10.length - 1]?.token === "?") {
6142
- last = unary.suffix.pop();
6143
- count++;
6144
- }
6145
- if (!count) {
6241
+ return gatherRecursiveAll(node, (n) => n.type === "TypeUnary").forEach((unary) => {
6242
+ if (!unary.suffix.length) {
6146
6243
  return;
6147
6244
  }
6148
- if (unary.parent?.type === "TypeTuple") {
6149
- if (count === 1) {
6150
- unary.suffix.push(last);
6151
- 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++;
6152
6255
  }
6153
- replaceNode(unary, [
6154
- getTrimmingSpace(unary),
6155
- "(",
6156
- parenthesizeType(insertTrimmingSpace(unary, "")),
6157
- " | null)",
6158
- last
6159
- ]);
6160
- } else {
6161
- replaceNode(unary, [
6162
- getTrimmingSpace(unary),
6163
- "(",
6164
- parenthesizeType(insertTrimmingSpace(unary, "")),
6165
- count === 1 ? " | undefined" : " | undefined | null",
6166
- ")"
6167
- ]);
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, [
6272
+ getTrimmingSpace(unary),
6273
+ "(",
6274
+ parenthesizeType(trimFirstSpace(t)),
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
6318
+ ]
6319
+ });
6168
6320
  }
6169
6321
  });
6170
6322
  }
@@ -6172,11 +6324,11 @@ function processStatementExpressions(statements) {
6172
6324
  gatherRecursiveAll(statements, ($7) => $7.type === "StatementExpression").forEach((_exp) => {
6173
6325
  const exp = _exp;
6174
6326
  const { statement } = exp;
6175
- let ref11;
6327
+ let ref16;
6176
6328
  switch (statement.type) {
6177
6329
  case "IfStatement": {
6178
- if (ref11 = expressionizeIfStatement(statement)) {
6179
- const expression = ref11;
6330
+ if (ref16 = expressionizeIfStatement(statement)) {
6331
+ const expression = ref16;
6180
6332
  return replaceNode(statement, expression, exp);
6181
6333
  } else {
6182
6334
  return replaceNode(statement, wrapIIFE([["", statement]]), exp);
@@ -6322,10 +6474,10 @@ function processPlaceholders(statements) {
6322
6474
  if (type === "IfStatement") {
6323
6475
  liftedIfs.add(ancestor2);
6324
6476
  }
6325
- let m3;
6326
6477
  let m4;
6478
+ let m5;
6327
6479
  return type === "Call" || // Block, except for if/else blocks when condition already lifted
6328
- 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
6329
6481
  type === "Initializer" || // Right-hand side of assignment
6330
6482
  type === "AssignmentExpression" && findChildIndex(ancestor2, child2) === ancestor2.children.indexOf(ancestor2.expression) || type === "ReturnStatement" || type === "YieldExpression";
6331
6483
  }));
@@ -6404,8 +6556,8 @@ function processPlaceholders(statements) {
6404
6556
  for (let i4 = 0, len3 = placeholders.length; i4 < len3; i4++) {
6405
6557
  const placeholder = placeholders[i4];
6406
6558
  typeSuffix ??= placeholder.typeSuffix;
6407
- let ref12;
6408
- replaceNode((ref12 = placeholder.children)[ref12.length - 1], ref);
6559
+ let ref17;
6560
+ replaceNode((ref17 = placeholder.children)[ref17.length - 1], ref);
6409
6561
  }
6410
6562
  const { parent } = ancestor;
6411
6563
  const body = maybeUnwrap(ancestor);
@@ -6422,16 +6574,16 @@ function processPlaceholders(statements) {
6422
6574
  }
6423
6575
  case "PipelineExpression": {
6424
6576
  const i = findChildIndex(parent, ancestor);
6425
- let ref13;
6577
+ let ref18;
6426
6578
  if (i === 1) {
6427
- ref13 = ancestor === parent.children[i];
6579
+ ref18 = ancestor === parent.children[i];
6428
6580
  } else if (i === 2) {
6429
- ref13 = ancestor === parent.children[i][findChildIndex(parent.children[i], ancestor)][3];
6581
+ ref18 = ancestor === parent.children[i][findChildIndex(parent.children[i], ancestor)][3];
6430
6582
  } else {
6431
- ref13 = void 0;
6583
+ ref18 = void 0;
6432
6584
  }
6433
6585
  ;
6434
- outer = ref13;
6586
+ outer = ref18;
6435
6587
  break;
6436
6588
  }
6437
6589
  case "AssignmentExpression":
@@ -6446,9 +6598,9 @@ function processPlaceholders(statements) {
6446
6598
  fnExp = makeLeftHandSideExpression(fnExp);
6447
6599
  }
6448
6600
  replaceNode(ancestor, fnExp, parent);
6449
- let ref14;
6450
- if (ref14 = getTrimmingSpace(body)) {
6451
- const ws = ref14;
6601
+ let ref19;
6602
+ if (ref19 = getTrimmingSpace(body)) {
6603
+ const ws = ref19;
6452
6604
  inplaceInsertTrimmingSpace(body, "");
6453
6605
  inplacePrepend(ws, fnExp);
6454
6606
  }
@@ -6493,8 +6645,8 @@ function reorderBindingRestProperty(props) {
6493
6645
  }
6494
6646
  ];
6495
6647
  }
6496
- let ref15;
6497
- if (Array.isArray(rest.delim) && (ref15 = rest.delim)[ref15.length - 1]?.token === ",") {
6648
+ let ref20;
6649
+ if (Array.isArray(rest.delim) && (ref20 = rest.delim)[ref20.length - 1]?.token === ",") {
6498
6650
  rest.delim = rest.delim.slice(0, -1);
6499
6651
  rest.children = [...rest.children.slice(0, -1), rest.delim];
6500
6652
  }
@@ -6659,6 +6811,7 @@ var grammar = {
6659
6811
  NestedArgumentList,
6660
6812
  NestedArgument,
6661
6813
  SingleLineArgumentExpressions,
6814
+ WArgumentPart,
6662
6815
  ArgumentPart,
6663
6816
  NonPipelineArgumentPart,
6664
6817
  BinaryOpExpression,
@@ -6670,6 +6823,8 @@ var grammar = {
6670
6823
  UnaryExpression,
6671
6824
  UnaryWithoutParenthesizedAssignment,
6672
6825
  UnaryBody,
6826
+ MaybeNestedCoffeeDoBody,
6827
+ CoffeeDoBody,
6673
6828
  UnaryWithoutParenthesizedAssignmentBody,
6674
6829
  ParenthesizedAssignment,
6675
6830
  UnaryPostfix,
@@ -7002,6 +7157,7 @@ var grammar = {
7002
7157
  MaybeNestedNonPipelineExtendedExpression,
7003
7158
  MaybeNestedPostfixedExpression,
7004
7159
  MaybeNestedExtendedExpression,
7160
+ NestedExtendedExpression,
7005
7161
  MaybeParenNestedExtendedExpression,
7006
7162
  ImportDeclaration,
7007
7163
  ImpliedImport,
@@ -7258,6 +7414,7 @@ var grammar = {
7258
7414
  NamespaceDeclaration,
7259
7415
  OptionalEquals,
7260
7416
  TypeLexicalDeclaration,
7417
+ TypeLetOrConstDeclaration,
7261
7418
  TypeDeclarationBinding,
7262
7419
  InterfaceExtendsClause,
7263
7420
  InterfaceExtendsTarget,
@@ -7751,7 +7908,7 @@ var $R90 = (0, import_lib3.$R)(new RegExp("(extends|not|is)(?!\\p{ID_Continue}|[
7751
7908
  var $R91 = (0, import_lib3.$R)(new RegExp("#![^\\r\\n]*", "suy"));
7752
7909
  var $R92 = (0, import_lib3.$R)(new RegExp("[\\t ]*", "suy"));
7753
7910
  var $R93 = (0, import_lib3.$R)(new RegExp("[\\s]*", "suy"));
7754
- var $R94 = (0, import_lib3.$R)(new RegExp("\\s+([+-]?)([a-zA-Z0-9-]+)(\\s*=\\s*([a-zA-Z0-9.+-]*))?", "suy"));
7911
+ var $R94 = (0, import_lib3.$R)(new RegExp("\\s+([+-]?)([a-zA-Z0-9-]+)(\\s*=\\s*([\\p{ID_Continue}.,+-]*))?", "suy"));
7755
7912
  var $R95 = (0, import_lib3.$R)(new RegExp("\\/\\/\\/[^\\r\\n]*", "suy"));
7756
7913
  var $R96 = (0, import_lib3.$R)(new RegExp("(?=[ \\t\\r\\n\\/#]|$)", "suy"));
7757
7914
  var $R97 = (0, import_lib3.$R)(new RegExp("\\r\\n|\\n|\\r|$", "suy"));
@@ -7942,9 +8099,7 @@ var ImplicitArguments$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(ApplicationSt
7942
8099
  var close = $5;
7943
8100
  if (skipImplicitArguments(args))
7944
8101
  return $skip;
7945
- let last = args[args.length - 1];
7946
- if (last?.token === "," && last.implicit)
7947
- args = args.slice(0, -1);
8102
+ args = stripTrailingImplicitComma(args);
7948
8103
  return {
7949
8104
  type: "Call",
7950
8105
  args,
@@ -8122,24 +8277,43 @@ var NestedArgument$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(Nested, SingleLi
8122
8277
  var args = $2;
8123
8278
  var comma = $3;
8124
8279
  let [arg0, ...rest] = args;
8125
- arg0 = [indent, ...arg0];
8280
+ arg0 = prepend(indent, arg0);
8126
8281
  return [arg0, ...rest, comma];
8127
8282
  });
8128
8283
  function NestedArgument(ctx, state2) {
8129
8284
  return (0, import_lib3.$EVENT)(ctx, state2, "NestedArgument", NestedArgument$0);
8130
8285
  }
8131
- 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) {
8132
8287
  return [$1, ...$2.flat()];
8133
8288
  });
8134
8289
  function SingleLineArgumentExpressions(ctx, state2) {
8135
8290
  return (0, import_lib3.$EVENT)(ctx, state2, "SingleLineArgumentExpressions", SingleLineArgumentExpressions$0);
8136
8291
  }
8137
- 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
+ });
8138
8308
  var ArgumentPart$1 = (0, import_lib3.$TS)((0, import_lib3.$S)(ExtendedExpression, (0, import_lib3.$E)(DotDotDot)), function($skip, $loc, $0, $1, $2) {
8139
- if ($2) {
8140
- return [$2, $1];
8141
- }
8142
- 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
+ };
8143
8317
  });
8144
8318
  var ArgumentPart$$ = [ArgumentPart$0, ArgumentPart$1];
8145
8319
  function ArgumentPart(ctx, state2) {
@@ -8227,17 +8401,18 @@ var RHS$$ = [RHS$0, RHS$1];
8227
8401
  function RHS(ctx, state2) {
8228
8402
  return (0, import_lib3.$EVENT_C)(ctx, state2, "RHS", RHS$$);
8229
8403
  }
8230
- 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) {
8231
8411
  var pre = $1;
8232
8412
  var exp = $2;
8233
8413
  var post = $3;
8234
8414
  return processUnaryExpression(pre, exp, post);
8235
8415
  });
8236
- 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) {
8237
- var ws = $3;
8238
- var exp = $4;
8239
- return processCoffeeDo(ws, exp);
8240
- });
8241
8416
  var UnaryExpression$$ = [UnaryExpression$0, UnaryExpression$1];
8242
8417
  function UnaryExpression(ctx, state2) {
8243
8418
  return (0, import_lib3.$EVENT_C)(ctx, state2, "UnaryExpression", UnaryExpression$$);
@@ -8251,14 +8426,35 @@ var UnaryWithoutParenthesizedAssignment$0 = (0, import_lib3.$TS)((0, import_lib3
8251
8426
  function UnaryWithoutParenthesizedAssignment(ctx, state2) {
8252
8427
  return (0, import_lib3.$EVENT)(ctx, state2, "UnaryWithoutParenthesizedAssignment", UnaryWithoutParenthesizedAssignment$0);
8253
8428
  }
8254
- var UnaryBody$0 = ParenthesizedAssignment;
8255
- var UnaryBody$1 = ExpressionizedStatementWithTrailingCallExpressions;
8256
- var UnaryBody$2 = UpdateExpression;
8257
- var UnaryBody$3 = NestedNonAssignmentExtendedExpression;
8258
- 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];
8259
8438
  function UnaryBody(ctx, state2) {
8260
8439
  return (0, import_lib3.$EVENT_C)(ctx, state2, "UnaryBody", UnaryBody$$);
8261
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
+ }
8262
8458
  var UnaryWithoutParenthesizedAssignmentBody$0 = UpdateExpression;
8263
8459
  var UnaryWithoutParenthesizedAssignmentBody$1 = ExpressionizedStatementWithTrailingCallExpressions;
8264
8460
  var UnaryWithoutParenthesizedAssignmentBody$2 = NestedNonAssignmentExtendedExpression;
@@ -8457,7 +8653,7 @@ var ArrowFunction$0 = ThinArrowFunction;
8457
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) {
8458
8654
  var async = $1;
8459
8655
  var parameters = $2;
8460
- var suffix = $3;
8656
+ var returnType = $3;
8461
8657
  var arrow = $4;
8462
8658
  var expOrBlock = $5;
8463
8659
  if (!async)
@@ -8468,13 +8664,13 @@ var ArrowFunction$1 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$
8468
8664
  modifier: {
8469
8665
  async: !!async.length
8470
8666
  },
8471
- returnType: suffix
8667
+ returnType
8472
8668
  },
8473
8669
  parameters,
8474
- returnType: suffix,
8670
+ returnType,
8475
8671
  async,
8476
8672
  block: expOrBlock,
8477
- children: [async, parameters, suffix, arrow, expOrBlock]
8673
+ children: [async, parameters, returnType, arrow, expOrBlock]
8478
8674
  };
8479
8675
  });
8480
8676
  var ArrowFunction$$ = [ArrowFunction$0, ArrowFunction$1];
@@ -10206,7 +10402,7 @@ var FunctionSignature$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_li
10206
10402
  var wid = $4;
10207
10403
  var w = $5;
10208
10404
  var parameters = $6;
10209
- var suffix = $7;
10405
+ var returnType = $7;
10210
10406
  if (!async)
10211
10407
  async = [];
10212
10408
  if (!generator)
@@ -10217,7 +10413,7 @@ var FunctionSignature$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_li
10217
10413
  id,
10218
10414
  name: id?.name,
10219
10415
  parameters,
10220
- returnType: suffix,
10416
+ returnType,
10221
10417
  async,
10222
10418
  generator,
10223
10419
  modifier: {
@@ -10225,7 +10421,7 @@ var FunctionSignature$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_li
10225
10421
  generator: !!generator.length
10226
10422
  },
10227
10423
  block: null,
10228
- 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]
10229
10425
  // move whitespace w to after implicit () in parameters
10230
10426
  };
10231
10427
  });
@@ -10424,7 +10620,7 @@ var OperatorSignature$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_li
10424
10620
  var behavior = $7;
10425
10621
  var w2 = $8;
10426
10622
  var parameters = $9;
10427
- var suffix = $10;
10623
+ var returnType = $10;
10428
10624
  if (!async)
10429
10625
  async = [];
10430
10626
  if (!generator)
@@ -10439,7 +10635,7 @@ var OperatorSignature$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_li
10439
10635
  id,
10440
10636
  name: id.name,
10441
10637
  parameters,
10442
- returnType: suffix,
10638
+ returnType,
10443
10639
  async,
10444
10640
  generator,
10445
10641
  modifier: {
@@ -10447,7 +10643,7 @@ var OperatorSignature$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_li
10447
10643
  generator: !!generator.length
10448
10644
  },
10449
10645
  block: null,
10450
- children: [async, func, generator, w1, id, w2, parameters, suffix],
10646
+ children: [async, func, generator, w1, id, w2, parameters, returnType],
10451
10647
  behavior
10452
10648
  };
10453
10649
  });
@@ -10494,7 +10690,7 @@ function OperatorAssociativity(ctx, state2) {
10494
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) {
10495
10691
  var async = $1;
10496
10692
  var parameters = $2;
10497
- var suffix = $3;
10693
+ var returnType = $3;
10498
10694
  var arrow = $5;
10499
10695
  var block = $6;
10500
10696
  if (!async)
@@ -10504,7 +10700,7 @@ var ThinArrowFunction$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_li
10504
10700
  type: "FunctionExpression",
10505
10701
  id: void 0,
10506
10702
  parameters,
10507
- returnType: suffix,
10703
+ returnType,
10508
10704
  async,
10509
10705
  generator,
10510
10706
  block,
@@ -10516,14 +10712,14 @@ var ThinArrowFunction$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_li
10516
10712
  async: !!async.length,
10517
10713
  generator: !!generator.length
10518
10714
  },
10519
- returnType: suffix
10715
+ returnType
10520
10716
  },
10521
10717
  children: [
10522
10718
  async,
10523
10719
  { $loc: arrow.$loc, token: "function" },
10524
10720
  generator,
10525
10721
  parameters,
10526
- suffix,
10722
+ returnType,
10527
10723
  block
10528
10724
  ]
10529
10725
  };
@@ -11220,6 +11416,7 @@ var ArrayElementExpression$2 = (0, import_lib3.$TS)((0, import_lib3.$S)(Extended
11220
11416
  return {
11221
11417
  type: "SpreadElement",
11222
11418
  children: [ws, dots, exp],
11419
+ expression: exp,
11223
11420
  names: exp.names
11224
11421
  };
11225
11422
  });
@@ -11231,12 +11428,14 @@ var ArrayElementExpression$3 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, impo
11231
11428
  return {
11232
11429
  type: "ArrayElement",
11233
11430
  children: [exp],
11431
+ expression: exp,
11234
11432
  names: exp.names
11235
11433
  };
11236
11434
  } else {
11237
11435
  return {
11238
11436
  type: "SpreadElement",
11239
11437
  children: [...spread, exp],
11438
+ expression: exp,
11240
11439
  names: exp.names
11241
11440
  };
11242
11441
  }
@@ -11280,9 +11479,9 @@ var BulletedArray$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(InsertOpenBracket
11280
11479
  // replace first space with bracket
11281
11480
  ...content[1].flat()
11282
11481
  ];
11283
- const last = content[content.length - 1];
11482
+ let last = content[content.length - 1];
11284
11483
  if (last.children?.at(-1)?.implicit) {
11285
- last.children = last.children.slice(0, -1);
11484
+ content[content.length - 1] = last = { ...last, children: last.children.slice(0, -1) };
11286
11485
  }
11287
11486
  return {
11288
11487
  type: "ArrayExpression",
@@ -12688,6 +12887,14 @@ var IfStatement$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$C)
12688
12887
  kind = { ...kind, token: "if" };
12689
12888
  condition = negateCondition(condition);
12690
12889
  }
12890
+ if (block.bare && e) {
12891
+ const semicolon = ";";
12892
+ block = {
12893
+ ...block,
12894
+ semicolon,
12895
+ children: [...block.children, semicolon]
12896
+ };
12897
+ }
12691
12898
  return {
12692
12899
  type: "IfStatement",
12693
12900
  children: [kind, ws, condition, block, e],
@@ -12701,6 +12908,13 @@ var IfStatement$1 = (0, import_lib3.$TS)((0, import_lib3.$S)(IfClause, BlockOrEm
12701
12908
  var clause = $1;
12702
12909
  var block = $2;
12703
12910
  var e = $3;
12911
+ if (block.bare && e) {
12912
+ block = {
12913
+ ...block,
12914
+ semicolon: ";",
12915
+ children: [...block.children, ";"]
12916
+ };
12917
+ }
12704
12918
  return {
12705
12919
  type: "IfStatement",
12706
12920
  children: [...clause.children, block, e],
@@ -13157,14 +13371,14 @@ function ForDeclaration(ctx, state2) {
13157
13371
  }
13158
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) {
13159
13373
  var pattern = $1;
13160
- var suffix = $2;
13161
- suffix ??= pattern.typeSuffix;
13374
+ var typeSuffix = $2;
13375
+ typeSuffix ??= pattern.typeSuffix;
13162
13376
  return {
13163
13377
  type: "Binding",
13164
- children: [pattern, suffix],
13378
+ children: [pattern, typeSuffix],
13165
13379
  names: pattern.names,
13166
13380
  pattern,
13167
- suffix,
13381
+ typeSuffix,
13168
13382
  splices: [],
13169
13383
  thisAssignments: []
13170
13384
  };
@@ -13801,6 +14015,16 @@ var MaybeNestedExtendedExpression$$ = [MaybeNestedExtendedExpression$0, MaybeNes
13801
14015
  function MaybeNestedExtendedExpression(ctx, state2) {
13802
14016
  return (0, import_lib3.$EVENT_C)(ctx, state2, "MaybeNestedExtendedExpression", MaybeNestedExtendedExpression$$);
13803
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
+ }
13804
14028
  var MaybeParenNestedExtendedExpression$0 = (0, import_lib3.$T)((0, import_lib3.$S)((0, import_lib3.$N)(EOS), ExtendedExpression), function(value) {
13805
14029
  return value[1];
13806
14030
  });
@@ -14295,16 +14519,16 @@ function TypeAssignment(ctx, state2) {
14295
14519
  }
14296
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) {
14297
14521
  var pattern = $1;
14298
- var suffix = $2;
14522
+ var typeSuffix = $2;
14299
14523
  var initializer = $3;
14300
14524
  const [splices, thisAssignments] = gatherBindingCode(pattern);
14301
- suffix ??= pattern.typeSuffix;
14525
+ typeSuffix ??= pattern.typeSuffix;
14302
14526
  return {
14303
14527
  type: "Binding",
14304
- children: [pattern, suffix, initializer],
14528
+ children: [pattern, typeSuffix, initializer],
14305
14529
  names: pattern.names,
14306
14530
  pattern,
14307
- suffix,
14531
+ typeSuffix,
14308
14532
  initializer,
14309
14533
  splices: splices.map((s) => [",", s]),
14310
14534
  thisAssignments: thisAssignments.map((s) => ["", s, ";"])
@@ -14312,14 +14536,14 @@ var LexicalBinding$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(BindingPattern,
14312
14536
  });
14313
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) {
14314
14538
  var pattern = $1;
14315
- var suffix = $2;
14539
+ var typeSuffix = $2;
14316
14540
  var initializer = $3;
14317
14541
  return {
14318
14542
  type: "Binding",
14319
14543
  children: $0,
14320
14544
  names: pattern.names,
14321
14545
  pattern,
14322
- suffix,
14546
+ typeSuffix,
14323
14547
  initializer,
14324
14548
  splices: [],
14325
14549
  thisAssignments: []
@@ -16264,14 +16488,14 @@ function UsingDeclaration(ctx, state2) {
16264
16488
  }
16265
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) {
16266
16490
  var pattern = $1;
16267
- var suffix = $2;
16491
+ var typeSuffix = $2;
16268
16492
  var initializer = $3;
16269
16493
  return {
16270
16494
  type: "Binding",
16271
16495
  children: $0,
16272
16496
  names: pattern.names,
16273
16497
  pattern,
16274
- suffix,
16498
+ typeSuffix,
16275
16499
  initializer,
16276
16500
  splices: [],
16277
16501
  thisAssignments: []
@@ -16377,7 +16601,17 @@ var OptionalEquals$$ = [OptionalEquals$0, OptionalEquals$1];
16377
16601
  function OptionalEquals(ctx, state2) {
16378
16602
  return (0, import_lib3.$EVENT_C)(ctx, state2, "OptionalEquals", OptionalEquals$$);
16379
16603
  }
16380
- var TypeLexicalDeclaration$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(__, LetOrConstOrVar, TypeDeclarationBinding, (0, import_lib3.$Q)((0, import_lib3.$S)(CommaDelimiter, __, TypeDeclarationBinding))), function($skip, $loc, $0, $1, $2, $3, $4) {
16604
+ var TypeLexicalDeclaration$0 = TypeLetOrConstDeclaration;
16605
+ var TypeLexicalDeclaration$1 = (0, import_lib3.$S)(__, EnumDeclaration);
16606
+ var TypeLexicalDeclaration$2 = ClassSignature;
16607
+ var TypeLexicalDeclaration$3 = (0, import_lib3.$S)(Namespace, (0, import_lib3.$E)(_), IdentifierName, DeclareBlock);
16608
+ var TypeLexicalDeclaration$4 = (0, import_lib3.$S)(Module, _, StringLiteral, (0, import_lib3.$E)(DeclareBlock));
16609
+ var TypeLexicalDeclaration$5 = (0, import_lib3.$S)(Global, (0, import_lib3.$E)(DeclareBlock));
16610
+ var TypeLexicalDeclaration$$ = [TypeLexicalDeclaration$0, TypeLexicalDeclaration$1, TypeLexicalDeclaration$2, TypeLexicalDeclaration$3, TypeLexicalDeclaration$4, TypeLexicalDeclaration$5];
16611
+ function TypeLexicalDeclaration(ctx, state2) {
16612
+ return (0, import_lib3.$EVENT_C)(ctx, state2, "TypeLexicalDeclaration", TypeLexicalDeclaration$$);
16613
+ }
16614
+ var TypeLetOrConstDeclaration$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(__, LetOrConstOrVar, TypeDeclarationBinding, (0, import_lib3.$Q)((0, import_lib3.$S)(CommaDelimiter, __, TypeDeclarationBinding))), function($skip, $loc, $0, $1, $2, $3, $4) {
16381
16615
  var first = $3;
16382
16616
  var rest = $4;
16383
16617
  const names = first.names.concat(...rest.map((b) => b[2].names));
@@ -16388,14 +16622,8 @@ var TypeLexicalDeclaration$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(__, LetO
16388
16622
  names
16389
16623
  };
16390
16624
  });
16391
- var TypeLexicalDeclaration$1 = (0, import_lib3.$S)(__, EnumDeclaration);
16392
- var TypeLexicalDeclaration$2 = ClassSignature;
16393
- var TypeLexicalDeclaration$3 = (0, import_lib3.$S)(Namespace, (0, import_lib3.$E)(_), IdentifierName, DeclareBlock);
16394
- var TypeLexicalDeclaration$4 = (0, import_lib3.$S)(Module, _, StringLiteral, (0, import_lib3.$E)(DeclareBlock));
16395
- var TypeLexicalDeclaration$5 = (0, import_lib3.$S)(Global, (0, import_lib3.$E)(DeclareBlock));
16396
- var TypeLexicalDeclaration$$ = [TypeLexicalDeclaration$0, TypeLexicalDeclaration$1, TypeLexicalDeclaration$2, TypeLexicalDeclaration$3, TypeLexicalDeclaration$4, TypeLexicalDeclaration$5];
16397
- function TypeLexicalDeclaration(ctx, state2) {
16398
- return (0, import_lib3.$EVENT_C)(ctx, state2, "TypeLexicalDeclaration", TypeLexicalDeclaration$$);
16625
+ function TypeLetOrConstDeclaration(ctx, state2) {
16626
+ return (0, import_lib3.$EVENT)(ctx, state2, "TypeLetOrConstDeclaration", TypeLetOrConstDeclaration$0);
16399
16627
  }
16400
16628
  var TypeDeclarationBinding$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) {
16401
16629
  return {
@@ -16539,13 +16767,14 @@ var NestedDeclareElement$0 = (0, import_lib3.$S)(Nested, DeclareElement, Interfa
16539
16767
  function NestedDeclareElement(ctx, state2) {
16540
16768
  return (0, import_lib3.$EVENT)(ctx, state2, "NestedDeclareElement", NestedDeclareElement$0);
16541
16769
  }
16542
- var DeclareElement$0 = (0, import_lib3.$T)((0, import_lib3.$S)((0, import_lib3.$E)(Decorators), (0, import_lib3.$E)((0, import_lib3.$S)(Export, (0, import_lib3.$E)(_))), TypeLexicalDeclaration), function(value) {
16770
+ var DeclareElement$0 = (0, import_lib3.$S)((0, import_lib3.$E)(Decorators), Export, __, Default, __, (0, import_lib3.$C)(Identifier, ClassSignature, InterfaceDeclaration));
16771
+ var DeclareElement$1 = (0, import_lib3.$T)((0, import_lib3.$S)((0, import_lib3.$E)(Decorators), (0, import_lib3.$E)((0, import_lib3.$S)(Export, (0, import_lib3.$E)(_))), TypeLexicalDeclaration), function(value) {
16543
16772
  return { "ts": true, "children": value };
16544
16773
  });
16545
- var DeclareElement$1 = (0, import_lib3.$T)((0, import_lib3.$S)((0, import_lib3.$E)((0, import_lib3.$S)(Export, (0, import_lib3.$E)(_))), TypeDeclarationRest), function(value) {
16774
+ var DeclareElement$2 = (0, import_lib3.$T)((0, import_lib3.$S)((0, import_lib3.$E)((0, import_lib3.$S)(Export, (0, import_lib3.$E)(_))), TypeDeclarationRest), function(value) {
16546
16775
  return { "ts": true, "children": value };
16547
16776
  });
16548
- var DeclareElement$$ = [DeclareElement$0, DeclareElement$1];
16777
+ var DeclareElement$$ = [DeclareElement$0, DeclareElement$1, DeclareElement$2];
16549
16778
  function DeclareElement(ctx, state2) {
16550
16779
  return (0, import_lib3.$EVENT_C)(ctx, state2, "DeclareElement", DeclareElement$$);
16551
16780
  }
@@ -16815,7 +17044,7 @@ var TypeUnary$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$Q)((
16815
17044
  if (!prefix.length && !suffix.length)
16816
17045
  return t;
16817
17046
  return {
16818
- type: "UnaryType",
17047
+ type: "TypeUnary",
16819
17048
  prefix,
16820
17049
  suffix,
16821
17050
  t,
@@ -16828,7 +17057,8 @@ function TypeUnary(ctx, state2) {
16828
17057
  }
16829
17058
  var TypeUnarySuffix$0 = TypeIndexedAccess;
16830
17059
  var TypeUnarySuffix$1 = QuestionMark;
16831
- var TypeUnarySuffix$$ = [TypeUnarySuffix$0, TypeUnarySuffix$1];
17060
+ var TypeUnarySuffix$2 = NonNullAssertion;
17061
+ var TypeUnarySuffix$$ = [TypeUnarySuffix$0, TypeUnarySuffix$1, TypeUnarySuffix$2];
16832
17062
  function TypeUnarySuffix(ctx, state2) {
16833
17063
  return (0, import_lib3.$EVENT_C)(ctx, state2, "TypeUnarySuffix", TypeUnarySuffix$$);
16834
17064
  }
@@ -16893,14 +17123,14 @@ var TypePrimary$6 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$E)
16893
17123
  var TypePrimary$7 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$E)(_), TypeLiteral), function($skip, $loc, $0, $1, $2) {
16894
17124
  var t = $2;
16895
17125
  return {
16896
- type: "LiteralType",
17126
+ type: "TypeLiteral",
16897
17127
  t,
16898
17128
  children: $0
16899
17129
  };
16900
17130
  });
16901
17131
  var TypePrimary$8 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$E)(_), UnknownAlias), function($skip, $loc, $0, $1, $2) {
16902
17132
  return {
16903
- type: "IdentifierType",
17133
+ type: "TypeIdentifier",
16904
17134
  children: $0,
16905
17135
  raw: $2.token,
16906
17136
  args: void 0
@@ -16909,7 +17139,7 @@ var TypePrimary$8 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$E)
16909
17139
  var TypePrimary$9 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$E)(_), Identifier, (0, import_lib3.$Q)((0, import_lib3.$S)(Dot, IdentifierName)), (0, import_lib3.$E)((0, import_lib3.$C)(TypeArguments, ImplicitTypeArguments))), function($skip, $loc, $0, $1, $2, $3, $4) {
16910
17140
  var args = $4;
16911
17141
  return {
16912
- type: "IdentifierType",
17142
+ type: "TypeIdentifier",
16913
17143
  children: $0,
16914
17144
  raw: [$2.name, ...$3.map(([dot, id]) => dot.token + id.name)].join(""),
16915
17145
  args
@@ -16919,7 +17149,7 @@ var TypePrimary$10 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$E
16919
17149
  if (!$4)
16920
17150
  return $skip;
16921
17151
  return {
16922
- type: "ParenthesizedType",
17152
+ type: "TypeParenthesized",
16923
17153
  children: [$1, $2, $4, $6, $7]
16924
17154
  // omit AllowAll/RestoreAll
16925
17155
  };
@@ -17285,16 +17515,20 @@ function TypeBinaryOp(ctx, state2) {
17285
17515
  }
17286
17516
  var TypeFunction$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$E)((0, import_lib3.$S)(Abstract, (0, import_lib3.$E)(_))), (0, import_lib3.$E)((0, import_lib3.$S)(New, (0, import_lib3.$E)(_))), Parameters, __, TypeArrowFunction, (0, import_lib3.$E)(ReturnType)), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
17287
17517
  var type = $6;
17288
- const ret = [...$0];
17518
+ const children = [...$0];
17289
17519
  if ($1 && !$2) {
17290
- ret[1] = {
17520
+ children[1] = {
17291
17521
  type: "Error",
17292
17522
  message: "abstract function types must be constructors (abstract new)"
17293
17523
  };
17294
17524
  }
17295
17525
  if (!type)
17296
- ret.push("void");
17297
- return ret;
17526
+ children.push("void");
17527
+ return {
17528
+ type: "TypeFunction",
17529
+ children,
17530
+ ts: true
17531
+ };
17298
17532
  });
17299
17533
  function TypeFunction(ctx, state2) {
17300
17534
  return (0, import_lib3.$EVENT)(ctx, state2, "TypeFunction", TypeFunction$0);
@@ -17476,17 +17710,22 @@ var CivetPrologueContent$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import
17476
17710
  function CivetPrologueContent(ctx, state2) {
17477
17711
  return (0, import_lib3.$EVENT)(ctx, state2, "CivetPrologueContent", CivetPrologueContent$0);
17478
17712
  }
17479
- var CivetOption$0 = (0, import_lib3.$TR)((0, import_lib3.$EXPECT)($R94, "CivetOption /\\s+([+-]?)([a-zA-Z0-9-]+)(\\s*=\\s*([a-zA-Z0-9.+-]*))?/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
17713
+ var CivetOption$0 = (0, import_lib3.$TR)((0, import_lib3.$EXPECT)($R94, "CivetOption /\\s+([+-]?)([a-zA-Z0-9-]+)(\\s*=\\s*([\\p{ID_Continue}.,+-]*))?/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
17480
17714
  const optionName = $2.replace(/-+([a-z]?)/g, (_2, l) => {
17481
17715
  if (l)
17482
17716
  return l.toUpperCase();
17483
17717
  return "";
17484
17718
  });
17485
17719
  let value = $3 ? $4 : $1 === "-" ? false : true;
17486
- if (optionName === "tab") {
17487
- value = parseFloat(value);
17488
- if (isNaN(value))
17489
- value = 0;
17720
+ switch (optionName) {
17721
+ case "tab":
17722
+ value = parseFloat(value);
17723
+ if (isNaN(value))
17724
+ value = 0;
17725
+ break;
17726
+ case "globals":
17727
+ value = value.split(",").filter(Boolean);
17728
+ break;
17490
17729
  }
17491
17730
  return [optionName, value];
17492
17731
  });
@@ -17839,6 +18078,7 @@ var Reset$0 = (0, import_lib3.$TV)((0, import_lib3.$EXPECT)($L0, 'Reset ""'), fu
17839
18078
  coffeeOf: false,
17840
18079
  coffeePrototype: false,
17841
18080
  defaultElement: "div",
18081
+ globals: [],
17842
18082
  implicitReturns: true,
17843
18083
  jsxCode: false,
17844
18084
  objectIs: false,