@danielx/civet 0.9.2 → 0.9.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.js CHANGED
@@ -513,6 +513,7 @@ __export(lib_civet_exports, {
513
513
  append: () => append,
514
514
  attachPostfixStatementAsExpression: () => attachPostfixStatementAsExpression,
515
515
  blockWithPrefix: () => blockWithPrefix,
516
+ braceBlock: () => braceBlock,
516
517
  convertNamedImportsToObject: () => convertNamedImportsToObject,
517
518
  convertObjectToJSXAttributes: () => convertObjectToJSXAttributes,
518
519
  convertWithClause: () => convertWithClause,
@@ -993,6 +994,57 @@ function literalValue(literal) {
993
994
  }
994
995
  }
995
996
  }
997
+ function literalType(literal) {
998
+ let t;
999
+ switch (literal.type) {
1000
+ case "RegularExpressionLiteral": {
1001
+ t = "RegExp";
1002
+ break;
1003
+ }
1004
+ case "TemplateLiteral": {
1005
+ t = "string";
1006
+ break;
1007
+ }
1008
+ case "Literal": {
1009
+ switch (literal.subtype) {
1010
+ case "NullLiteral": {
1011
+ t = "null";
1012
+ break;
1013
+ }
1014
+ case "BooleanLiteral": {
1015
+ t = "boolean";
1016
+ break;
1017
+ }
1018
+ case "NumericLiteral": {
1019
+ if (literal.raw.endsWith("n")) {
1020
+ t = "bigint";
1021
+ } else {
1022
+ t = "number";
1023
+ }
1024
+ ;
1025
+ break;
1026
+ }
1027
+ case "StringLiteral": {
1028
+ t = "string";
1029
+ break;
1030
+ }
1031
+ default: {
1032
+ throw new Error(`unknown literal subtype ${literal.subtype}`);
1033
+ }
1034
+ }
1035
+ ;
1036
+ break;
1037
+ }
1038
+ default: {
1039
+ throw new Error(`unknown literal type ${literal.type}`);
1040
+ }
1041
+ }
1042
+ return {
1043
+ type: "TypeLiteral",
1044
+ t,
1045
+ children: [t]
1046
+ };
1047
+ }
996
1048
  function makeNumericLiteral(n) {
997
1049
  const s = n.toString();
998
1050
  return {
@@ -1305,7 +1357,7 @@ function skipIfOnlyWS(target) {
1305
1357
  return target;
1306
1358
  }
1307
1359
  function spliceChild(node, child, del, ...replacements) {
1308
- const children = node?.children ?? node;
1360
+ const children = Array.isArray(node) ? node : node.children;
1309
1361
  if (!Array.isArray(children)) {
1310
1362
  throw new Error("spliceChild: non-array node has no children field");
1311
1363
  }
@@ -1740,14 +1792,41 @@ function gatherBindingCode(statements, opts) {
1740
1792
  const thisAssignments = [];
1741
1793
  const splices = [];
1742
1794
  function insertRestSplices(s, p, thisAssignments2) {
1743
- for (let ref2 = gatherRecursiveAll(s, (n) => n.blockPrefix || opts?.injectParamProps && n.accessModifier || n.type === "AtBinding"), i3 = 0, len22 = ref2.length; i3 < len22; i3++) {
1744
- const n = ref2[i3];
1795
+ let m;
1796
+ for (let ref2 = gatherRecursiveAll(
1797
+ s,
1798
+ (n) => n.blockPrefix || opts?.injectParamProps && n.accessModifier || n.type === "AtBinding" || opts?.assignPins && (m = n.type, m === "PinPattern" || m === "PinProperty")
1799
+ ), i3 = 0, len22 = ref2.length; i3 < len22; i3++) {
1800
+ let n = ref2[i3];
1745
1801
  if (n.type === "AtBinding") {
1746
1802
  const { ref } = n;
1747
1803
  const { id } = ref;
1748
1804
  thisAssignments2.push([`this.${id} = `, ref]);
1749
1805
  continue;
1750
1806
  }
1807
+ if (opts?.assignPins) {
1808
+ if (n.type === "PinProperty") {
1809
+ n.children = n.children.flatMap(($2) => $2 === n.name ? [n.name, ": ", n.value] : $2);
1810
+ updateParentPointers(n);
1811
+ n = n.value;
1812
+ }
1813
+ if (n.type === "PinPattern") {
1814
+ n.ref = makeRef(
1815
+ n.expression.type === "Identifier" ? n.expression.name : "pin"
1816
+ );
1817
+ n.children = [n.ref];
1818
+ updateParentPointers(n);
1819
+ thisAssignments2.push({
1820
+ type: "AssignmentExpression",
1821
+ children: [n.expression, " = ", n.ref],
1822
+ names: [],
1823
+ lhs: n.expression,
1824
+ assigned: n.expression,
1825
+ expression: n.ref
1826
+ });
1827
+ continue;
1828
+ }
1829
+ }
1751
1830
  if (opts?.injectParamProps && n.type === "Parameter" && n.accessModifier) {
1752
1831
  for (let ref3 = n.names, i4 = 0, len3 = ref3.length; i4 < len3; i4++) {
1753
1832
  const id = ref3[i4];
@@ -3583,20 +3662,21 @@ function processParams(f) {
3583
3662
  indent = expressions[0][0];
3584
3663
  }
3585
3664
  const [splices, thisAssignments] = gatherBindingCode(parameters, {
3586
- injectParamProps: isConstructor
3665
+ injectParamProps: isConstructor,
3666
+ assignPins: true
3587
3667
  });
3588
3668
  if (isConstructor) {
3589
3669
  const { ancestor } = findAncestor(f, ($9) => $9.type === "ClassExpression");
3590
3670
  if (ancestor != null) {
3591
3671
  const fields = new Set(gatherRecursiveWithinFunction(ancestor, ($10) => $10.type === "FieldDefinition").map(($11) => $11.id).filter((a3) => typeof a3 === "object" && a3 != null && "type" in a3 && a3.type === "Identifier").map(($12) => $12.name));
3592
3672
  const classExpressions = ancestor.body.expressions;
3593
- let index = findChildIndex(classExpressions, f);
3594
- assert.notEqual(index, -1, "Could not find constructor in class");
3673
+ let index2 = findChildIndex(classExpressions, f);
3674
+ assert.notEqual(index2, -1, "Could not find constructor in class");
3595
3675
  let m4;
3596
- while (m4 = classExpressions[index - 1]?.[1], typeof m4 === "object" && m4 != null && "type" in m4 && m4.type === "MethodDefinition" && "name" in m4 && m4.name === "constructor") {
3597
- index--;
3676
+ while (m4 = classExpressions[index2 - 1]?.[1], typeof m4 === "object" && m4 != null && "type" in m4 && m4.type === "MethodDefinition" && "name" in m4 && m4.name === "constructor") {
3677
+ index2--;
3598
3678
  }
3599
- const fStatement = classExpressions[index];
3679
+ const fStatement = classExpressions[index2];
3600
3680
  for (let ref18 = gatherRecursive(parameters, ($13) => $13.type === "Parameter"), i9 = 0, len8 = ref18.length; i9 < len8; i9++) {
3601
3681
  const parameter = ref18[i9];
3602
3682
  const { accessModifier } = parameter;
@@ -3617,7 +3697,7 @@ function processParams(f) {
3617
3697
  if (fields.has(id)) {
3618
3698
  continue;
3619
3699
  }
3620
- classExpressions.splice(index++, 0, [fStatement[0], {
3700
+ classExpressions.splice(index2++, 0, [fStatement[0], {
3621
3701
  type: "FieldDefinition",
3622
3702
  id,
3623
3703
  typeSuffix,
@@ -3654,25 +3734,31 @@ function processParams(f) {
3654
3734
  if (!prefix.length) {
3655
3735
  return;
3656
3736
  }
3737
+ let index = -1;
3657
3738
  if (isConstructor) {
3658
- const superCalls = gatherNodes(
3659
- expressions,
3660
- (a4) => typeof a4 === "object" && a4 != null && "type" in a4 && a4.type === "CallExpression" && "children" in a4 && Array.isArray(a4.children) && a4.children.length >= 1 && typeof a4.children[0] === "object" && a4.children[0] != null && "token" in a4.children[0] && a4.children[0].token === "super"
3661
- );
3662
- if (superCalls.length) {
3663
- const { child } = findAncestor(superCalls[0], (a5) => a5 === block);
3664
- const index = findChildIndex(expressions, child);
3665
- if (index < 0) {
3666
- throw new Error("Could not find super call within top-level expressions");
3667
- }
3668
- expressions.splice(index + 1, 0, ...prefix);
3669
- return;
3670
- }
3739
+ index = findSuperCall(block);
3671
3740
  }
3672
- expressions.unshift(...prefix);
3741
+ expressions.splice(index + 1, 0, ...prefix);
3673
3742
  updateParentPointers(block);
3674
3743
  braceBlock(block);
3675
3744
  }
3745
+ function findSuperCall(block) {
3746
+ const { expressions } = block;
3747
+ const superCalls = gatherNodes(
3748
+ expressions,
3749
+ (a4) => typeof a4 === "object" && a4 != null && "type" in a4 && a4.type === "CallExpression" && "children" in a4 && Array.isArray(a4.children) && a4.children.length >= 1 && typeof a4.children[0] === "object" && a4.children[0] != null && "token" in a4.children[0] && a4.children[0].token === "super"
3750
+ );
3751
+ if (superCalls.length) {
3752
+ const { child } = findAncestor(superCalls[0], (a5) => a5 === block);
3753
+ const index = findChildIndex(expressions, child);
3754
+ if (index < 0) {
3755
+ throw new Error("Could not find super call within top-level expressions");
3756
+ }
3757
+ return index;
3758
+ } else {
3759
+ return -1;
3760
+ }
3761
+ }
3676
3762
  function processSignature(f) {
3677
3763
  const { block, signature } = f;
3678
3764
  if (!f.async?.length && hasAwait(block)) {
@@ -4965,18 +5051,47 @@ function processDeclarations(statements) {
4965
5051
  for (let ref1 = gatherRecursiveAll(statements, ($) => $.type === "Declaration"), i1 = 0, len1 = ref1.length; i1 < len1; i1++) {
4966
5052
  const declaration = ref1[i1];
4967
5053
  const { bindings } = declaration;
4968
- bindings?.forEach((binding) => {
4969
- const { typeSuffix } = binding;
4970
- if (typeSuffix && typeSuffix.optional && typeSuffix.t) {
4971
- convertOptionalType(typeSuffix);
5054
+ if (!(bindings != null)) {
5055
+ continue;
5056
+ }
5057
+ for (let i2 = 0, len22 = bindings.length; i2 < len22; i2++) {
5058
+ const binding = bindings[i2];
5059
+ let { typeSuffix, initializer } = binding;
5060
+ if (typeSuffix && typeSuffix.optional) {
5061
+ if (initializer && !typeSuffix.t) {
5062
+ const expression = trimFirstSpace(initializer.expression);
5063
+ let m;
5064
+ if (m = expression.type, m === "Identifier" || m === "MemberExpression") {
5065
+ typeSuffix.children.push(": ", typeSuffix.t = {
5066
+ type: "TypeTypeof",
5067
+ children: ["typeof ", expression],
5068
+ expression
5069
+ });
5070
+ } else if (expression.type === "Literal" || expression.type === "RegularExpressionLiteral" || expression.type === "TemplateLiteral") {
5071
+ typeSuffix.children.push(": ", typeSuffix.t = literalType(expression));
5072
+ } else {
5073
+ spliceChild(binding, typeSuffix, 1, {
5074
+ type: "Error",
5075
+ message: `Optional type can only be inferred from literals or member expressions, not ${expression.type}`
5076
+ });
5077
+ continue;
5078
+ }
5079
+ }
5080
+ if (typeSuffix.t) {
5081
+ convertOptionalType(typeSuffix);
5082
+ } else {
5083
+ spliceChild(binding, typeSuffix, 1);
5084
+ binding.children.push(initializer = binding.initializer = {
5085
+ type: "Initializer",
5086
+ expression: "undefined",
5087
+ children: [" = ", "undefined"]
5088
+ });
5089
+ }
4972
5090
  }
4973
- const { initializer } = binding;
4974
5091
  if (initializer) {
4975
- return prependStatementExpressionBlock(initializer, declaration);
5092
+ prependStatementExpressionBlock(initializer, declaration);
4976
5093
  }
4977
- ;
4978
- return;
4979
- });
5094
+ }
4980
5095
  }
4981
5096
  }
4982
5097
  function prependStatementExpressionBlock(initializer, statement) {
@@ -5139,16 +5254,16 @@ function processDeclarationConditionStatement(s) {
5139
5254
  if (conditions.length) {
5140
5255
  let children = condition.children;
5141
5256
  if (s.negated) {
5142
- let m;
5143
- if (!(m = condition.expression, typeof m === "object" && m != null && "type" in m && m.type === "UnaryExpression" && "children" in m && Array.isArray(m.children) && len2(m.children, 2) && Array.isArray(m.children[0]) && len2(m.children[0], 1) && m.children[0][0] === "!" && typeof m.children[1] === "object" && m.children[1] != null && "type" in m.children[1] && m.children[1].type === "ParenthesizedExpression")) {
5257
+ let m1;
5258
+ if (!(m1 = condition.expression, typeof m1 === "object" && m1 != null && "type" in m1 && m1.type === "UnaryExpression" && "children" in m1 && Array.isArray(m1.children) && len2(m1.children, 2) && Array.isArray(m1.children[0]) && len2(m1.children[0], 1) && m1.children[0][0] === "!" && typeof m1.children[1] === "object" && m1.children[1] != null && "type" in m1.children[1] && m1.children[1].type === "ParenthesizedExpression")) {
5144
5259
  throw new Error("Unsupported negated condition");
5145
5260
  }
5146
5261
  ;
5147
5262
  ({ children } = condition.expression.children[1]);
5148
5263
  }
5149
5264
  children.unshift("(");
5150
- for (let i2 = 0, len22 = conditions.length; i2 < len22; i2++) {
5151
- const c = conditions[i2];
5265
+ for (let i3 = 0, len3 = conditions.length; i3 < len3; i3++) {
5266
+ const c = conditions[i3];
5152
5267
  children.push(" && ", c);
5153
5268
  }
5154
5269
  children.push(")");
@@ -5269,7 +5384,8 @@ function dynamizeFromClause(from) {
5269
5384
  if (ref3 = from[from.length - 1]?.assertion) {
5270
5385
  const assert2 = ref3;
5271
5386
  let ref4;
5272
- ref4 = from[from.length - 1], ref4.children = ref4.children.filter((a2) => a2 !== assert2);
5387
+ ref4 = from[from.length - 1];
5388
+ ref4.children = ref4.children.filter((a2) => a2 !== assert2);
5273
5389
  from.push(", {", assert2.keyword, ":", assert2.object, "}");
5274
5390
  }
5275
5391
  return ["(", ...from, ")"];
@@ -6303,12 +6419,10 @@ function createVarDecs(block, scopes, pushVar) {
6303
6419
  }
6304
6420
  return assignmentStatements2;
6305
6421
  }
6306
- if (!pushVar) {
6307
- pushVar = function(name) {
6308
- varIds.push(name);
6309
- return decs.add(name);
6310
- };
6311
- }
6422
+ pushVar ??= (name) => {
6423
+ varIds.push(name);
6424
+ return decs.add(name);
6425
+ };
6312
6426
  const { expressions: statements } = block;
6313
6427
  const decs = findDecs(statements);
6314
6428
  scopes.push(decs);
@@ -7908,6 +8022,91 @@ function processBreaksContinues(statements) {
7908
8022
  delete label.special;
7909
8023
  }
7910
8024
  }
8025
+ function processCoffeeClasses(statements) {
8026
+ for (let ref21 = gatherRecursiveAll(statements, ($13) => $13.type === "ClassExpression"), i11 = 0, len9 = ref21.length; i11 < len9; i11++) {
8027
+ const ce = ref21[i11];
8028
+ const { expressions } = ce.body;
8029
+ const indent = expressions[0]?.[0] ?? "\n";
8030
+ const autoBinds = expressions.filter(($14) => $14[1]?.autoBind);
8031
+ if (autoBinds.length) {
8032
+ let construct;
8033
+ for (const [, c] of expressions) {
8034
+ if (typeof c === "object" && c != null && "type" in c && c.type === "MethodDefinition" && "name" in c && c.name === "constructor" && c.block) {
8035
+ construct = c;
8036
+ break;
8037
+ }
8038
+ }
8039
+ if (!construct) {
8040
+ const parametersList = [];
8041
+ const parameters = {
8042
+ type: "Parameters",
8043
+ children: [parametersList],
8044
+ parameters: parametersList,
8045
+ names: []
8046
+ };
8047
+ const signature = {
8048
+ type: "MethodSignature",
8049
+ children: ["constructor(", parameters, ")"],
8050
+ parameters,
8051
+ modifier: {},
8052
+ returnType: void 0
8053
+ };
8054
+ const block = makeEmptyBlock();
8055
+ construct = {
8056
+ ...signature,
8057
+ type: "MethodDefinition",
8058
+ name: "constructor",
8059
+ block,
8060
+ signature,
8061
+ children: [...signature.children, block]
8062
+ };
8063
+ expressions.unshift([indent, construct]);
8064
+ }
8065
+ const index = findSuperCall(construct.block);
8066
+ construct.block.expressions.splice(
8067
+ index + 1,
8068
+ 0,
8069
+ ...(() => {
8070
+ const results3 = [];
8071
+ for (let i12 = 0, len10 = autoBinds.length; i12 < len10; i12++) {
8072
+ const [, a] = autoBinds[i12];
8073
+ results3.push([indent, ["this.", a.name, " = this.", a.name, ".bind(this)"], ";"]);
8074
+ }
8075
+ return results3;
8076
+ })()
8077
+ );
8078
+ }
8079
+ const privates = expressions.filter(($15) => $15[1]?.type === "CoffeeClassPrivate");
8080
+ if (!privates.length) {
8081
+ continue;
8082
+ }
8083
+ const { parent } = ce;
8084
+ for (let i13 = expressions.length + -1; i13 >= 0; --i13) {
8085
+ const i = i13;
8086
+ if (expressions[i][1]?.type === "CoffeeClassPrivate") {
8087
+ expressions.splice(i, 1);
8088
+ }
8089
+ }
8090
+ let wrapped = wrapIIFE([
8091
+ ...privates,
8092
+ [indent, wrapWithReturn(ce)]
8093
+ ]);
8094
+ if (ce && typeof ce === "object" && "binding" in ce) {
8095
+ let { binding } = ce;
8096
+ binding = trimFirstSpace(binding);
8097
+ wrapped = makeNode({
8098
+ type: "AssignmentExpression",
8099
+ children: [binding, " = ", wrapped],
8100
+ lhs: binding,
8101
+ // TODO: incorrect shape
8102
+ assigned: binding,
8103
+ expression: wrapped,
8104
+ names: [ce.name]
8105
+ });
8106
+ }
8107
+ replaceNode(ce, wrapped, parent);
8108
+ }
8109
+ }
7911
8110
  function processProgram(root) {
7912
8111
  const state2 = getState();
7913
8112
  const config2 = getConfig();
@@ -7922,7 +8121,7 @@ function processProgram(root) {
7922
8121
  if (config2.iife || config2.repl) {
7923
8122
  rootIIFE = wrapIIFE(root.expressions, root.topLevelAwait);
7924
8123
  const newExpressions = [["", rootIIFE]];
7925
- root.children = root.children.map(($13) => $13 === root.expressions ? newExpressions : $13);
8124
+ root.children = root.children.map(($16) => $16 === root.expressions ? newExpressions : $16);
7926
8125
  root.expressions = newExpressions;
7927
8126
  }
7928
8127
  addParentPointers(root);
@@ -7941,6 +8140,9 @@ function processProgram(root) {
7941
8140
  processBreaksContinues(statements);
7942
8141
  hoistRefDecs(statements);
7943
8142
  processFunctions(statements, config2);
8143
+ if (config2.coffeeClasses) {
8144
+ processCoffeeClasses(statements);
8145
+ }
7944
8146
  statements.unshift(...state2.prelude);
7945
8147
  if (config2.autoLet) {
7946
8148
  createConstLetDecs(statements, [], "let");
@@ -7964,10 +8166,10 @@ async function processProgramAsync(root) {
7964
8166
  await processComptime(statements);
7965
8167
  }
7966
8168
  function processRepl(root, rootIIFE) {
7967
- const topBlock = gatherRecursive(rootIIFE, ($14) => $14.type === "BlockStatement")[0];
8169
+ const topBlock = gatherRecursive(rootIIFE, ($17) => $17.type === "BlockStatement")[0];
7968
8170
  let i = 0;
7969
- for (let ref21 = gatherRecursiveWithinFunction(topBlock, ($15) => $15.type === "Declaration"), i11 = 0, len9 = ref21.length; i11 < len9; i11++) {
7970
- const decl = ref21[i11];
8171
+ for (let ref22 = gatherRecursiveWithinFunction(topBlock, ($18) => $18.type === "Declaration"), i14 = 0, len11 = ref22.length; i14 < len11; i14++) {
8172
+ const decl = ref22[i14];
7971
8173
  if (!decl.names?.length) {
7972
8174
  continue;
7973
8175
  }
@@ -7980,8 +8182,8 @@ function processRepl(root, rootIIFE) {
7980
8182
  root.expressions.splice(i++, 0, ["", `var ${decl.names.join(",")}`, ";"]);
7981
8183
  }
7982
8184
  }
7983
- for (let ref22 = gatherRecursive(topBlock, ($16) => $16.type === "FunctionExpression"), i12 = 0, len10 = ref22.length; i12 < len10; i12++) {
7984
- const func = ref22[i12];
8185
+ for (let ref23 = gatherRecursive(topBlock, ($19) => $19.type === "FunctionExpression"), i15 = 0, len12 = ref23.length; i15 < len12; i15++) {
8186
+ const func = ref23[i15];
7985
8187
  if (func.name && func.parent?.type === "BlockStatement") {
7986
8188
  if (func.parent === topBlock) {
7987
8189
  replaceNode(func, void 0);
@@ -7993,8 +8195,8 @@ function processRepl(root, rootIIFE) {
7993
8195
  }
7994
8196
  }
7995
8197
  }
7996
- for (let ref23 = gatherRecursiveWithinFunction(topBlock, ($17) => $17.type === "ClassExpression"), i13 = 0, len11 = ref23.length; i13 < len11; i13++) {
7997
- const classExp = ref23[i13];
8198
+ for (let ref24 = gatherRecursiveWithinFunction(topBlock, ($20) => $20.type === "ClassExpression"), i16 = 0, len13 = ref24.length; i16 < len13; i16++) {
8199
+ const classExp = ref24[i16];
7998
8200
  let m8;
7999
8201
  if (classExp.name && classExp.parent === topBlock || (m8 = classExp.parent, typeof m8 === "object" && m8 != null && "type" in m8 && m8.type === "ReturnStatement" && "parent" in m8 && m8.parent === topBlock)) {
8000
8202
  classExp.children.unshift(classExp.name, "=");
@@ -8003,7 +8205,7 @@ function processRepl(root, rootIIFE) {
8003
8205
  }
8004
8206
  }
8005
8207
  function populateRefs(statements) {
8006
- const refNodes = gatherRecursive(statements, ($18) => $18.type === "Ref");
8208
+ const refNodes = gatherRecursive(statements, ($21) => $21.type === "Ref");
8007
8209
  if (refNodes.length) {
8008
8210
  const ids = gatherRecursive(statements, (s) => s.type === "Identifier");
8009
8211
  const names = new Set(ids.flatMap(({ names: names2 }) => names2 || []));
@@ -8025,8 +8227,8 @@ function populateRefs(statements) {
8025
8227
  function processPlaceholders(statements) {
8026
8228
  const placeholderMap = /* @__PURE__ */ new Map();
8027
8229
  const liftedIfs = /* @__PURE__ */ new Set();
8028
- for (let ref24 = gatherRecursiveAll(statements, ($19) => $19.type === "Placeholder"), i14 = 0, len12 = ref24.length; i14 < len12; i14++) {
8029
- const exp = ref24[i14];
8230
+ for (let ref25 = gatherRecursiveAll(statements, ($22) => $22.type === "Placeholder"), i17 = 0, len14 = ref25.length; i17 < len14; i17++) {
8231
+ const exp = ref25[i17];
8030
8232
  let ancestor;
8031
8233
  if (exp.subtype === ".") {
8032
8234
  ({ ancestor } = findAncestor(
@@ -8135,11 +8337,11 @@ function processPlaceholders(statements) {
8135
8337
  for (const [ancestor, placeholders] of placeholderMap) {
8136
8338
  let ref = makeRef("$");
8137
8339
  let typeSuffix;
8138
- for (let i15 = 0, len13 = placeholders.length; i15 < len13; i15++) {
8139
- const placeholder = placeholders[i15];
8340
+ for (let i18 = 0, len15 = placeholders.length; i18 < len15; i18++) {
8341
+ const placeholder = placeholders[i18];
8140
8342
  typeSuffix ??= placeholder.typeSuffix;
8141
- let ref25;
8142
- (ref25 = placeholder.children)[ref25.length - 1] = ref;
8343
+ let ref26;
8344
+ (ref26 = placeholder.children)[ref26.length - 1] = ref;
8143
8345
  }
8144
8346
  const { parent } = ancestor;
8145
8347
  const body = maybeUnwrap(ancestor);
@@ -8160,16 +8362,16 @@ function processPlaceholders(statements) {
8160
8362
  }
8161
8363
  case "PipelineExpression": {
8162
8364
  const i = findChildIndex(parent, ancestor);
8163
- let ref26;
8365
+ let ref27;
8164
8366
  if (i === 1) {
8165
- ref26 = ancestor === parent.children[i];
8367
+ ref27 = ancestor === parent.children[i];
8166
8368
  } else if (i === 2) {
8167
- ref26 = ancestor === parent.children[i][findChildIndex(parent.children[i], ancestor)][3];
8369
+ ref27 = ancestor === parent.children[i][findChildIndex(parent.children[i], ancestor)][3];
8168
8370
  } else {
8169
- ref26 = void 0;
8371
+ ref27 = void 0;
8170
8372
  }
8171
8373
  ;
8172
- outer = ref26;
8374
+ outer = ref27;
8173
8375
  break;
8174
8376
  }
8175
8377
  case "AssignmentExpression":
@@ -8184,9 +8386,9 @@ function processPlaceholders(statements) {
8184
8386
  fnExp = makeLeftHandSideExpression(fnExp);
8185
8387
  }
8186
8388
  replaceNode(ancestor, fnExp, parent);
8187
- let ref27;
8188
- if (ref27 = getTrimmingSpace(body)) {
8189
- const ws = ref27;
8389
+ let ref28;
8390
+ if (ref28 = getTrimmingSpace(body)) {
8391
+ const ws = ref28;
8190
8392
  inplaceInsertTrimmingSpace(body, "");
8191
8393
  inplacePrepend(ws, fnExp);
8192
8394
  }
@@ -8230,8 +8432,8 @@ function reorderBindingRestProperty(props) {
8230
8432
  }
8231
8433
  ];
8232
8434
  }
8233
- let ref28;
8234
- if (Array.isArray(rest.delim) && (ref28 = rest.delim)[ref28.length - 1]?.token === ",") {
8435
+ let ref29;
8436
+ if (Array.isArray(rest.delim) && (ref29 = rest.delim)[ref29.length - 1]?.token === ",") {
8235
8437
  rest.delim = rest.delim.slice(0, -1);
8236
8438
  rest.children = [...rest.children.slice(0, -1), rest.delim];
8237
8439
  }
@@ -10762,8 +10964,7 @@ var FieldDefinition$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(CoffeeClassesEn
10762
10964
  var id = $2;
10763
10965
  var exp = $6;
10764
10966
  switch (exp.type) {
10765
- // TODO: => functions
10766
- case "FunctionExpression":
10967
+ case "FunctionExpression": {
10767
10968
  const fnTokenIndex = exp.children.findIndex((c) => c?.token?.startsWith("function"));
10768
10969
  const children = exp.children.slice();
10769
10970
  if (exp.generator) {
@@ -10773,8 +10974,29 @@ var FieldDefinition$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(CoffeeClassesEn
10773
10974
  }
10774
10975
  return {
10775
10976
  ...exp,
10977
+ type: "MethodDefinition",
10978
+ name: id.name,
10979
+ signature: { ...exp.signature, id, name: id.name },
10776
10980
  children
10777
10981
  };
10982
+ }
10983
+ case "ArrowFunction": {
10984
+ const block = { ...exp.block };
10985
+ const children = exp.children.filter((c) => !(Array.isArray(c) && c[c.length - 1]?.token?.includes("=>"))).map((c) => c === exp.block ? block : c);
10986
+ children.unshift(id);
10987
+ exp = {
10988
+ ...exp,
10989
+ type: "MethodDefinition",
10990
+ name: id.name,
10991
+ signature: { ...exp.signature, id, name: id.name },
10992
+ block,
10993
+ children,
10994
+ autoBind: true
10995
+ };
10996
+ block.parent = exp;
10997
+ braceBlock(block);
10998
+ return exp;
10999
+ }
10778
11000
  default:
10779
11001
  return {
10780
11002
  type: "FieldDefinition",
@@ -10784,11 +11006,11 @@ var FieldDefinition$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(CoffeeClassesEn
10784
11006
  }
10785
11007
  });
10786
11008
  var FieldDefinition$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(InsertReadonly, ClassElementName, (0, import_lib2.$E)(TypeSuffix), __, ConstAssignment, MaybeNestedExpression), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
10787
- var r = $1;
11009
+ var readonly = $1;
10788
11010
  var id = $2;
10789
11011
  var typeSuffix = $3;
10790
11012
  var ca = $5;
10791
- r.children[0].$loc = {
11013
+ readonly.children[0].$loc = {
10792
11014
  pos: ca.$loc.pos - 1,
10793
11015
  length: ca.$loc.length + 1
10794
11016
  };
@@ -10796,21 +11018,36 @@ var FieldDefinition$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(InsertReadonly,
10796
11018
  type: "FieldDefinition",
10797
11019
  id,
10798
11020
  typeSuffix,
10799
- children: $0
11021
+ children: $0,
11022
+ readonly
11023
+ };
11024
+ });
11025
+ var FieldDefinition$2 = (0, import_lib2.$TS)((0, import_lib2.$S)(CoffeeClassesEnabled, ActualAssignment), function($skip, $loc, $0, $1, $2) {
11026
+ var assignment = $2;
11027
+ return {
11028
+ type: "CoffeeClassPrivate",
11029
+ children: [assignment],
11030
+ assignment
10800
11031
  };
10801
11032
  });
10802
- var FieldDefinition$2 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)((0, import_lib2.$S)(Abstract, (0, import_lib2.$E)(_))), (0, import_lib2.$E)((0, import_lib2.$S)(Readonly, (0, import_lib2.$E)(_))), ClassElementName, (0, import_lib2.$E)(TypeSuffix), (0, import_lib2.$E)(Initializer)), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
11033
+ var FieldDefinition$3 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)((0, import_lib2.$S)(Abstract, (0, import_lib2.$E)(_))), (0, import_lib2.$E)((0, import_lib2.$S)(Readonly, (0, import_lib2.$E)(_))), ClassElementName, (0, import_lib2.$E)(TypeSuffix), (0, import_lib2.$E)(Initializer)), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
11034
+ var abstract = $1;
11035
+ var readonly = $2;
10803
11036
  var id = $3;
10804
11037
  var typeSuffix = $4;
11038
+ var initializer = $5;
10805
11039
  return {
10806
11040
  type: "FieldDefinition",
10807
11041
  children: $0,
10808
- ts: $1 ? true : void 0,
11042
+ ts: abstract ? true : void 0,
10809
11043
  id,
10810
- typeSuffix
11044
+ typeSuffix,
11045
+ abstract,
11046
+ readonly,
11047
+ initializer
10811
11048
  };
10812
11049
  });
10813
- var FieldDefinition$$ = [FieldDefinition$0, FieldDefinition$1, FieldDefinition$2];
11050
+ var FieldDefinition$$ = [FieldDefinition$0, FieldDefinition$1, FieldDefinition$2, FieldDefinition$3];
10814
11051
  function FieldDefinition(ctx, state2) {
10815
11052
  return (0, import_lib2.$EVENT_C)(ctx, state2, "FieldDefinition", FieldDefinition$$);
10816
11053
  }
@@ -11617,7 +11854,7 @@ var PinPattern$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(Caret, SingleLineExp
11617
11854
  var expression = $2;
11618
11855
  return {
11619
11856
  type: "PinPattern",
11620
- children: $0,
11857
+ children: [expression],
11621
11858
  expression
11622
11859
  };
11623
11860
  });
@@ -11832,6 +12069,7 @@ var BindingProperty$2 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2
11832
12069
  name: binding,
11833
12070
  value: {
11834
12071
  type: "PinPattern",
12072
+ children: [binding],
11835
12073
  expression: binding
11836
12074
  }
11837
12075
  };
@@ -12700,7 +12938,7 @@ function LiteralContent(ctx, state2) {
12700
12938
  return (0, import_lib2.$EVENT_C)(ctx, state2, "LiteralContent", LiteralContent$$);
12701
12939
  }
12702
12940
  var NullLiteral$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$EXPECT)($L38, 'NullLiteral "null"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
12703
- return { $loc, token: $1 };
12941
+ return { type: "NullLiteral", $loc, token: $1 };
12704
12942
  });
12705
12943
  function NullLiteral(ctx, state2) {
12706
12944
  return (0, import_lib2.$EVENT)(ctx, state2, "NullLiteral", NullLiteral$0);
@@ -12715,17 +12953,17 @@ var _BooleanLiteral$0 = (0, import_lib2.$T)((0, import_lib2.$S)(CoffeeBooleansEn
12715
12953
  return value[1];
12716
12954
  });
12717
12955
  var _BooleanLiteral$1 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$C)((0, import_lib2.$EXPECT)($L39, '_BooleanLiteral "true"'), (0, import_lib2.$EXPECT)($L40, '_BooleanLiteral "false"')), NonIdContinue), function($skip, $loc, $0, $1, $2) {
12718
- return { $loc, token: $1 };
12956
+ return { type: "BooleanLiteral", $loc, token: $1 };
12719
12957
  });
12720
12958
  var _BooleanLiteral$$ = [_BooleanLiteral$0, _BooleanLiteral$1];
12721
12959
  function _BooleanLiteral(ctx, state2) {
12722
12960
  return (0, import_lib2.$EVENT_C)(ctx, state2, "_BooleanLiteral", _BooleanLiteral$$);
12723
12961
  }
12724
12962
  var CoffeeScriptBooleanLiteral$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$C)((0, import_lib2.$EXPECT)($L41, 'CoffeeScriptBooleanLiteral "yes"'), (0, import_lib2.$EXPECT)($L42, 'CoffeeScriptBooleanLiteral "on"')), NonIdContinue), function($skip, $loc, $0, $1, $2) {
12725
- return { $loc, token: "true" };
12963
+ return { type: "BooleanLiteral", $loc, token: "true" };
12726
12964
  });
12727
12965
  var CoffeeScriptBooleanLiteral$1 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$C)((0, import_lib2.$EXPECT)($L43, 'CoffeeScriptBooleanLiteral "no"'), (0, import_lib2.$EXPECT)($L44, 'CoffeeScriptBooleanLiteral "off"')), NonIdContinue), function($skip, $loc, $0, $1, $2) {
12728
- return { $loc, token: "false" };
12966
+ return { type: "BooleanLiteral", $loc, token: "false" };
12729
12967
  });
12730
12968
  var CoffeeScriptBooleanLiteral$$ = [CoffeeScriptBooleanLiteral$0, CoffeeScriptBooleanLiteral$1];
12731
12969
  function CoffeeScriptBooleanLiteral(ctx, state2) {
@@ -16611,7 +16849,12 @@ function CoffeeDoubleQuotedStringCharacters(ctx, state2) {
16611
16849
  }
16612
16850
  var RegularExpressionLiteral$0 = HeregexLiteral;
16613
16851
  var RegularExpressionLiteral$1 = (0, import_lib2.$TV)((0, import_lib2.$TEXT)((0, import_lib2.$S)((0, import_lib2.$EXPECT)($L77, 'RegularExpressionLiteral "/"'), RegularExpressionBody, (0, import_lib2.$EXPECT)($L77, 'RegularExpressionLiteral "/"'), RegularExpressionFlags)), function($skip, $loc, $0, $1) {
16614
- return { type: "RegularExpressionLiteral", $loc, token: $1 };
16852
+ var raw = $0;
16853
+ return {
16854
+ type: "RegularExpressionLiteral",
16855
+ raw,
16856
+ children: [{ $loc, token: raw }]
16857
+ };
16615
16858
  });
16616
16859
  var RegularExpressionLiteral$$ = [RegularExpressionLiteral$0, RegularExpressionLiteral$1];
16617
16860
  function RegularExpressionLiteral(ctx, state2) {
@@ -18999,9 +19242,11 @@ function UnknownAlias(ctx, state2) {
18999
19242
  }
19000
19243
  var TypePrimary$0 = (0, import_lib2.$S)((0, import_lib2.$E)(_), Infer, (0, import_lib2.$E)(_), IdentifierName, (0, import_lib2.$E)((0, import_lib2.$S)(NotDedented, ExtendsToken, Type)));
19001
19244
  var TypePrimary$1 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), Typeof, (0, import_lib2.$E)(_), UnaryExpression), function($skip, $loc, $0, $1, $2, $3, $4) {
19245
+ var expression = $4;
19002
19246
  return {
19003
- type: "TypeofType",
19004
- children: $0
19247
+ type: "TypeTypeof",
19248
+ children: $0,
19249
+ expression
19005
19250
  };
19006
19251
  });
19007
19252
  var TypePrimary$2 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), TypeTuple), function($skip, $loc, $0, $1, $2) {