@danielx/civet 0.9.4 → 0.9.5

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
@@ -1650,6 +1650,15 @@ function gatherRecursiveAll(node, predicate) {
1650
1650
  }
1651
1651
 
1652
1652
  // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\ref.civet.jsx
1653
+ var range = (start, end) => {
1654
+ const length = end - start;
1655
+ if (length <= 0) return [];
1656
+ const arr = Array(length);
1657
+ for (let i = 0; i < length; ++i) {
1658
+ arr[i] = i + start;
1659
+ }
1660
+ return arr;
1661
+ };
1653
1662
  function makeRef(base = "ref", id = base) {
1654
1663
  return {
1655
1664
  type: "Ref",
@@ -1662,7 +1671,7 @@ function needsRef(expression, base = "ref") {
1662
1671
  return;
1663
1672
  }
1664
1673
  if (Array.isArray(expression)) {
1665
- const nonempty = ((s) => Array.from({ length: expression.length - s }, (_2, i) => s + i))(0).filter((i) => !isWhitespaceOrEmpty(expression[i]));
1674
+ const nonempty = range(0, expression.length).filter((i) => !isWhitespaceOrEmpty(expression[i]));
1666
1675
  if (nonempty.length === 1) {
1667
1676
  let ref1;
1668
1677
  if (ref1 = needsRef(expression[nonempty[0]], base)) {
@@ -1678,8 +1687,9 @@ function needsRef(expression, base = "ref") {
1678
1687
  case "Ref":
1679
1688
  case "Identifier":
1680
1689
  case "Literal":
1681
- case "Placeholder":
1690
+ case "Placeholder": {
1682
1691
  return;
1692
+ }
1683
1693
  }
1684
1694
  return makeRef(base);
1685
1695
  }
@@ -1709,10 +1719,34 @@ function maybeRefAssignment(exp, base = "ref") {
1709
1719
  return { ref, ...makeRefAssignment(ref, exp) };
1710
1720
  }
1711
1721
  }
1722
+ function populateRefs(statements) {
1723
+ const refNodes = gatherRecursive(statements, ($) => $.type === "Ref");
1724
+ if (!refNodes.length) {
1725
+ return;
1726
+ }
1727
+ const ids = gatherRecursive(statements, ($1) => $1.type === "Identifier");
1728
+ const names = new Set(ids.flatMap(({ names: names2 }) => names2 || []));
1729
+ for (let i1 = 0, len3 = refNodes.length; i1 < len3; i1++) {
1730
+ const ref = refNodes[i1];
1731
+ if (!(ref.type === "Ref")) {
1732
+ continue;
1733
+ }
1734
+ const { base } = ref;
1735
+ ref.type = "Identifier";
1736
+ let n = 0;
1737
+ let name = base;
1738
+ while (names.has(name)) {
1739
+ n++;
1740
+ name = `${base}${n}`;
1741
+ }
1742
+ names.add(name);
1743
+ ref.children = ref.names = [name];
1744
+ }
1745
+ }
1712
1746
 
1713
1747
  // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\binding.civet.jsx
1714
1748
  function adjustAtBindings(statements, asThis = false) {
1715
- for (let ref1 = gatherRecursiveAll(statements, ($) => $.type === "AtBindingProperty"), i1 = 0, len3 = ref1.length; i1 < len3; i1++) {
1749
+ for (let ref1 = gatherRecursiveAll(statements, ($1) => $1.type === "AtBindingProperty"), i1 = 0, len3 = ref1.length; i1 < len3; i1++) {
1716
1750
  const binding = ref1[i1];
1717
1751
  const { ref } = binding;
1718
1752
  if (asThis) {
@@ -1730,7 +1764,7 @@ function adjustAtBindings(statements, asThis = false) {
1730
1764
  }
1731
1765
  }
1732
1766
  function adjustBindingElements(elements) {
1733
- const names = elements.flatMap(($1) => $1.names || []);
1767
+ const names = elements.flatMap(($2) => $2.names || []);
1734
1768
  const { length } = elements;
1735
1769
  let blockPrefix, restIndex = -1, restCount = 0;
1736
1770
  for (let i2 = 0, len1 = elements.length; i2 < len1; i2++) {
@@ -1788,16 +1822,40 @@ function adjustBindingElements(elements) {
1788
1822
  length
1789
1823
  };
1790
1824
  }
1825
+ function gatherSubbindings(node, subbindings = []) {
1826
+ for (let ref2 = gatherRecursiveAll(node, ($) => $.subbinding != null), i3 = 0, len22 = ref2.length; i3 < len22; i3++) {
1827
+ const p = ref2[i3];
1828
+ const { subbinding } = p;
1829
+ subbindings.push(", ", subbinding);
1830
+ gatherSubbindings(subbinding, subbindings);
1831
+ }
1832
+ return subbindings;
1833
+ }
1834
+ function simplifyBindingProperties(node) {
1835
+ const results = [];
1836
+ for (let ref3 = gatherRecursiveAll(node, ($3) => $3.type === "BindingProperty"), i4 = 0, len3 = ref3.length; i4 < len3; i4++) {
1837
+ const p = ref3[i4];
1838
+ const { name, value } = p;
1839
+ if (value?.type === "NamedBindingPattern" && value.binding === name) {
1840
+ const [ws] = p.children;
1841
+ results.push(p.children = [ws, name, p.delim]);
1842
+ } else {
1843
+ results.push(void 0);
1844
+ }
1845
+ }
1846
+ ;
1847
+ return results;
1848
+ }
1791
1849
  function gatherBindingCode(statements, opts) {
1792
1850
  const thisAssignments = [];
1793
1851
  const splices = [];
1794
1852
  function insertRestSplices(s, p, thisAssignments2) {
1795
1853
  let m;
1796
- for (let ref2 = gatherRecursiveAll(
1854
+ for (let ref4 = gatherRecursiveAll(
1797
1855
  s,
1798
1856
  (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];
1857
+ ), i5 = 0, len4 = ref4.length; i5 < len4; i5++) {
1858
+ let n = ref4[i5];
1801
1859
  if (n.type === "AtBinding") {
1802
1860
  const { ref } = n;
1803
1861
  const { id } = ref;
@@ -1806,7 +1864,7 @@ function gatherBindingCode(statements, opts) {
1806
1864
  }
1807
1865
  if (opts?.assignPins) {
1808
1866
  if (n.type === "PinProperty") {
1809
- n.children = n.children.flatMap(($2) => $2 === n.name ? [n.name, ": ", n.value] : $2);
1867
+ n.children = n.children.flatMap(($4) => $4 === n.name ? [n.name, ": ", n.value] : $4);
1810
1868
  updateParentPointers(n);
1811
1869
  n = n.value;
1812
1870
  }
@@ -1828,8 +1886,8 @@ function gatherBindingCode(statements, opts) {
1828
1886
  }
1829
1887
  }
1830
1888
  if (opts?.injectParamProps && n.type === "Parameter" && n.accessModifier) {
1831
- for (let ref3 = n.names, i4 = 0, len3 = ref3.length; i4 < len3; i4++) {
1832
- const id = ref3[i4];
1889
+ for (let ref5 = n.names, i6 = 0, len5 = ref5.length; i6 < len5; i6++) {
1890
+ const id = ref5[i6];
1833
1891
  thisAssignments2.push({
1834
1892
  type: "AssignmentExpression",
1835
1893
  children: [`this.${id} = `, id],
@@ -1847,8 +1905,8 @@ function gatherBindingCode(statements, opts) {
1847
1905
  return [splices, thisAssignments];
1848
1906
  }
1849
1907
  function arrayElementHasTrailingComma(elementNode) {
1850
- let ref4;
1851
- const lastChild = (ref4 = elementNode.children)[ref4.length - 1];
1908
+ let ref6;
1909
+ const lastChild = (ref6 = elementNode.children)[ref6.length - 1];
1852
1910
  return lastChild && lastChild[lastChild.length - 1]?.token === ",";
1853
1911
  }
1854
1912
  function gatherBindingPatternTypeSuffix(pattern) {
@@ -1859,9 +1917,9 @@ function gatherBindingPatternTypeSuffix(pattern) {
1859
1917
  switch (pattern.type) {
1860
1918
  case "ArrayBindingPattern": {
1861
1919
  {
1862
- const results = [];
1863
- for (let ref5 = pattern.elements, i5 = 0, len4 = ref5.length; i5 < len4; i5++) {
1864
- const elem = ref5[i5];
1920
+ const results1 = [];
1921
+ for (let ref7 = pattern.elements, i7 = 0, len6 = ref7.length; i7 < len6; i7++) {
1922
+ const elem = ref7[i7];
1865
1923
  let { typeSuffix } = elem;
1866
1924
  typeSuffix ??= elem.binding?.typeSuffix;
1867
1925
  if (typeSuffix) {
@@ -1878,10 +1936,10 @@ function gatherBindingPatternTypeSuffix(pattern) {
1878
1936
  } else {
1879
1937
  typeElement[0] ??= "unknown";
1880
1938
  }
1881
- results.push(typeElement);
1939
+ results1.push(typeElement);
1882
1940
  }
1883
1941
  ;
1884
- const types = results;
1942
+ const types = results1;
1885
1943
  if (count) {
1886
1944
  const t = [": [", types, "]"];
1887
1945
  pattern.typeSuffix = {
@@ -1898,9 +1956,9 @@ function gatherBindingPatternTypeSuffix(pattern) {
1898
1956
  case "ObjectBindingPattern": {
1899
1957
  {
1900
1958
  let restType;
1901
- const results1 = [];
1902
- for (let ref6 = pattern.properties, i6 = 0, len5 = ref6.length; i6 < len5; i6++) {
1903
- const prop = ref6[i6];
1959
+ const results2 = [];
1960
+ for (let ref8 = pattern.properties, i8 = 0, len7 = ref8.length; i8 < len7; i8++) {
1961
+ const prop = ref8[i8];
1904
1962
  let { typeSuffix } = prop;
1905
1963
  typeSuffix ??= prop.value?.typeSuffix;
1906
1964
  if (typeSuffix) {
@@ -1914,12 +1972,12 @@ function gatherBindingPatternTypeSuffix(pattern) {
1914
1972
  switch (prop.type) {
1915
1973
  case "BindingProperty": {
1916
1974
  const ws = prop.children.slice(0, prop.children.indexOf(prop.name));
1917
- results1.push([...ws, prop.name, typeSuffix, prop.delim]);
1975
+ results2.push([...ws, prop.name, typeSuffix, prop.delim]);
1918
1976
  break;
1919
1977
  }
1920
1978
  case "AtBindingProperty": {
1921
1979
  const ws = prop.children.slice(0, prop.children.indexOf(prop.binding));
1922
- results1.push([...ws, prop.ref.id, typeSuffix, prop.delim]);
1980
+ results2.push([...ws, prop.ref.id.replace(/^#/, ""), typeSuffix, prop.delim]);
1923
1981
  break;
1924
1982
  }
1925
1983
  case "BindingRestProperty": {
@@ -1929,7 +1987,7 @@ function gatherBindingPatternTypeSuffix(pattern) {
1929
1987
  }
1930
1988
  }
1931
1989
  ;
1932
- const types = results1;
1990
+ const types = results2;
1933
1991
  if (count) {
1934
1992
  const t = ["{", types, "}"];
1935
1993
  if (restType != null) {
@@ -3657,7 +3715,8 @@ function processParams(f) {
3657
3715
  parameters.names.push(...rest.names || []);
3658
3716
  rest.children.pop();
3659
3717
  if (after.length) {
3660
- if (rest.binding.type === "ArrayBindingPattern" || rest.binding.type === "ObjectBindingPattern") {
3718
+ let m4;
3719
+ if (m4 = rest.binding.type, m4 === "ArrayBindingPattern" || m4 === "ObjectBindingPattern" || m4 === "NamedBindingPattern") {
3661
3720
  parameters.parameters.push({
3662
3721
  type: "Error",
3663
3722
  message: "Non-end rest parameter cannot be binding pattern"
@@ -3789,6 +3848,9 @@ function processParams(f) {
3789
3848
  injectParamProps: isConstructor,
3790
3849
  assignPins: true
3791
3850
  });
3851
+ const subbindings = gatherSubbindings(parameters.parameters);
3852
+ simplifyBindingProperties(parameters.parameters);
3853
+ simplifyBindingProperties(subbindings);
3792
3854
  if (isConstructor) {
3793
3855
  const { ancestor } = findAncestor(f, ($10) => $10.type === "ClassExpression");
3794
3856
  if (ancestor != null) {
@@ -3796,8 +3858,8 @@ function processParams(f) {
3796
3858
  const classExpressions = ancestor.body.expressions;
3797
3859
  let index2 = findChildIndex(classExpressions, f);
3798
3860
  assert.notEqual(index2, -1, "Could not find constructor in class");
3799
- let m4;
3800
- while (m4 = classExpressions[index2 - 1]?.[1], typeof m4 === "object" && m4 != null && "type" in m4 && m4.type === "MethodDefinition" && "name" in m4 && m4.name === "constructor") {
3861
+ let m5;
3862
+ while (m5 = classExpressions[index2 - 1]?.[1], typeof m5 === "object" && m5 != null && "type" in m5 && m5.type === "MethodDefinition" && "name" in m5 && m5.name === "constructor") {
3801
3863
  index2--;
3802
3864
  }
3803
3865
  const fStatement = classExpressions[index2];
@@ -3837,6 +3899,15 @@ function processParams(f) {
3837
3899
  children: [";"]
3838
3900
  };
3839
3901
  let prefix = [];
3902
+ if (subbindings.length) {
3903
+ prefix.push(makeNode({
3904
+ type: "Declaration",
3905
+ children: ["const ", subbindings.slice(1)],
3906
+ names: subbindings.flatMap(($16) => $16.names ?? []),
3907
+ bindings: [],
3908
+ decl: "const"
3909
+ }));
3910
+ }
3840
3911
  for (let ref20 = splices, i11 = 0, len10 = ref20.length; i11 < len10; i11++) {
3841
3912
  const binding = ref20[i11];
3842
3913
  assert.equal(binding.type, "PostRestBindingElements", "splice should be of type Binding");
@@ -3890,7 +3961,7 @@ function processSignature(f) {
3890
3961
  f.async.push("async ");
3891
3962
  signature.modifier.async = true;
3892
3963
  } else {
3893
- for (let ref21 = gatherRecursiveWithinFunction(block, ($16) => $16.type === "Await"), i12 = 0, len11 = ref21.length; i12 < len11; i12++) {
3964
+ for (let ref21 = gatherRecursiveWithinFunction(block, ($17) => $17.type === "Await"), i12 = 0, len11 = ref21.length; i12 < len11; i12++) {
3894
3965
  const a = ref21[i12];
3895
3966
  const i = findChildIndex(a.parent, a);
3896
3967
  a.parent.children.splice(i + 1, 0, {
@@ -3905,9 +3976,9 @@ function processSignature(f) {
3905
3976
  f.generator.push("*");
3906
3977
  signature.modifier.generator = true;
3907
3978
  } else {
3908
- for (let ref22 = gatherRecursiveWithinFunction(block, ($17) => $17.type === "YieldExpression"), i13 = 0, len12 = ref22.length; i13 < len12; i13++) {
3979
+ for (let ref22 = gatherRecursiveWithinFunction(block, ($18) => $18.type === "YieldExpression"), i13 = 0, len12 = ref22.length; i13 < len12; i13++) {
3909
3980
  const y = ref22[i13];
3910
- const i = y.children.findIndex(($18) => $18.type === "Yield");
3981
+ const i = y.children.findIndex(($19) => $19.type === "Yield");
3911
3982
  y.children.splice(i + 1, 0, {
3912
3983
  type: "Error",
3913
3984
  message: `yield invalid in ${f.type === "ArrowFunction" ? "=> arrow function" : signature.modifier.get ? "getter" : signature.modifier.set ? "setter" : signature.name}`
@@ -3920,7 +3991,7 @@ function processSignature(f) {
3920
3991
  }
3921
3992
  }
3922
3993
  function processFunctions(statements, config2) {
3923
- for (let ref23 = gatherRecursiveAll(statements, ($19) => $19.type === "FunctionExpression" || $19.type === "ArrowFunction" || $19.type === "MethodDefinition"), i14 = 0, len13 = ref23.length; i14 < len13; i14++) {
3994
+ for (let ref23 = gatherRecursiveAll(statements, ($20) => $20.type === "FunctionExpression" || $20.type === "ArrowFunction" || $20.type === "MethodDefinition"), i14 = 0, len13 = ref23.length; i14 < len13; i14++) {
3924
3995
  const f = ref23[i14];
3925
3996
  if (f.type === "FunctionExpression" || f.type === "MethodDefinition") {
3926
3997
  implicitFunctionBlock(f);
@@ -3990,7 +4061,7 @@ function expressionizeIteration(exp) {
3990
4061
  }
3991
4062
  }
3992
4063
  function processIterationExpressions(statements) {
3993
- for (let ref25 = gatherRecursiveAll(statements, ($20) => $20.type === "IterationExpression"), i15 = 0, len14 = ref25.length; i15 < len14; i15++) {
4064
+ for (let ref25 = gatherRecursiveAll(statements, ($21) => $21.type === "IterationExpression"), i15 = 0, len14 = ref25.length; i15 < len14; i15++) {
3994
4065
  const s = ref25[i15];
3995
4066
  expressionizeIteration(s);
3996
4067
  }
@@ -4040,12 +4111,12 @@ function processCoffeeDo(ws, expression) {
4040
4111
  const newParameters = {
4041
4112
  ...parameters,
4042
4113
  parameters: newParameterList,
4043
- children: parameters.children.map(($21) => $21 === parameterList ? newParameterList : $21)
4114
+ children: parameters.children.map(($22) => $22 === parameterList ? newParameterList : $22)
4044
4115
  };
4045
4116
  expression = {
4046
4117
  ...expression,
4047
4118
  parameters: newParameters,
4048
- children: expression.children.map(($22) => $22 === parameters ? newParameters : $22)
4119
+ children: expression.children.map(($23) => $23 === parameters ? newParameters : $23)
4049
4120
  };
4050
4121
  }
4051
4122
  return {
@@ -4067,7 +4138,7 @@ function makeAmpersandFunction(rhs) {
4067
4138
  ref = makeRef("$");
4068
4139
  inplacePrepend(ref, body);
4069
4140
  }
4070
- if (startsWithPredicate(body, ($23) => $23.type === "ObjectExpression")) {
4141
+ if (startsWithPredicate(body, ($24) => $24.type === "ObjectExpression")) {
4071
4142
  body = makeLeftHandSideExpression(body);
4072
4143
  }
4073
4144
  const parameterList = [
@@ -4863,17 +4934,15 @@ function getPatternConditions(pattern, ref, conditions = []) {
4863
4934
  break;
4864
4935
  }
4865
4936
  case "ConditionFragment": {
4866
- let { children } = pattern;
4867
- if (children.length) {
4868
- let [first, ...rest] = children;
4937
+ let { rhs } = pattern;
4938
+ if (rhs.length) {
4939
+ let [first, ...rest] = rhs;
4869
4940
  let [ws, ...op] = first;
4870
4941
  ws = [" "].concat(ws);
4871
4942
  first = [ws, ...op];
4872
- children = [first, ...rest];
4943
+ rhs = [first, ...rest];
4873
4944
  }
4874
- conditions.push(
4875
- processBinaryOpExpression([ref, children])
4876
- );
4945
+ conditions.push(processBinaryOpExpression([ref, rhs]));
4877
4946
  break;
4878
4947
  }
4879
4948
  case "RegularExpressionLiteral": {
@@ -4891,6 +4960,10 @@ function getPatternConditions(pattern, ref, conditions = []) {
4891
4960
  ]);
4892
4961
  break;
4893
4962
  }
4963
+ case "NamedBindingPattern": {
4964
+ getPatternConditions(pattern.pattern, ref, conditions);
4965
+ break;
4966
+ }
4894
4967
  case "Literal": {
4895
4968
  conditions.push([
4896
4969
  ref,
@@ -4920,43 +4993,60 @@ function getPatternBlockPrefix(pattern, ref, decl = "const ", typeSuffix) {
4920
4993
  }
4921
4994
  case "Literal":
4922
4995
  case "RegularExpressionLiteral":
4923
- case "PinPattern":
4924
- case "ConditionFragment": {
4996
+ case "PinPattern": {
4925
4997
  return;
4926
4998
  }
4999
+ case "ConditionFragment": {
5000
+ if (!pattern.binding) {
5001
+ return;
5002
+ }
5003
+ ;
5004
+ break;
5005
+ }
4927
5006
  }
4928
5007
  let [splices, thisAssignments] = gatherBindingCode(pattern);
4929
5008
  const patternBindings2 = nonMatcherBindings(pattern);
4930
- const results = [];
4931
- for (let ref2 = gatherRecursiveAll(patternBindings2, ($7) => $7.subbinding != null), i5 = 0, len4 = ref2.length; i5 < len4; i5++) {
4932
- const p = ref2[i5];
4933
- results.push(prepend(", ", p.subbinding));
4934
- }
4935
- ;
4936
- const subbindings = results;
4937
- splices = splices.map((s) => [", ", nonMatcherBindings(s)]);
4938
- thisAssignments = thisAssignments.map(($8) => ["", $8, ";"]);
4939
- const duplicateDeclarations = aggregateDuplicateBindings([patternBindings2, splices]);
4940
- return [
4941
- ["", {
5009
+ const subbindings = gatherSubbindings(patternBindings2);
5010
+ simplifyBindingProperties(patternBindings2);
5011
+ simplifyBindingProperties(subbindings);
5012
+ splices = splices.flatMap((s) => [", ", nonMatcherBindings(s)]);
5013
+ thisAssignments = thisAssignments.map(($7) => ["", $7, ";"]);
5014
+ const duplicateDeclarations = aggregateDuplicateBindings([patternBindings2, splices, subbindings]);
5015
+ const blockPrefix = [];
5016
+ if (ref || subbindings.length || splices.length) {
5017
+ const children = [decl];
5018
+ if (ref) {
5019
+ children.push(patternBindings2, typeSuffix, " = ", ref);
5020
+ }
5021
+ children.push(...subbindings);
5022
+ children.push(...splices);
5023
+ if (!ref) {
5024
+ children.splice(1, 1);
5025
+ }
5026
+ blockPrefix.push(["", {
4942
5027
  type: "Declaration",
4943
- children: [decl, patternBindings2, typeSuffix, " = ", ref, ...subbindings, ...splices],
5028
+ children,
5029
+ decl,
4944
5030
  names: [],
4945
5031
  bindings: []
4946
5032
  // avoid implicit return of any bindings
4947
- }, ";"],
4948
- ...thisAssignments,
4949
- ...duplicateDeclarations.map(($9) => ["", $9, ";"])
4950
- ];
5033
+ }, ";"]);
5034
+ }
5035
+ blockPrefix.push(...thisAssignments);
5036
+ blockPrefix.push(...duplicateDeclarations.map(($8) => ["", $8, ";"]));
5037
+ if (!blockPrefix.length) {
5038
+ return;
5039
+ }
5040
+ return blockPrefix;
4951
5041
  }
4952
5042
  function elideMatchersFromArrayBindings(elements) {
4953
- const results1 = [];
4954
- for (let i6 = 0, len5 = elements.length; i6 < len5; i6++) {
4955
- const element = elements[i6];
5043
+ const results = [];
5044
+ for (let i5 = 0, len4 = elements.length; i5 < len4; i5++) {
5045
+ const element = elements[i5];
4956
5046
  switch (element.type) {
4957
5047
  case "BindingRestElement":
4958
5048
  case "ElisionElement": {
4959
- results1.push(element);
5049
+ results.push(element);
4960
5050
  break;
4961
5051
  }
4962
5052
  case "BindingElement": {
@@ -4965,12 +5055,12 @@ function elideMatchersFromArrayBindings(elements) {
4965
5055
  case "RegularExpressionLiteral":
4966
5056
  case "StringLiteral":
4967
5057
  case "PinPattern": {
4968
- results1.push(element.delim);
5058
+ results.push(element.delim);
4969
5059
  break;
4970
5060
  }
4971
5061
  default: {
4972
5062
  const binding = nonMatcherBindings(element.binding);
4973
- results1.push(makeNode({
5063
+ results.push(makeNode({
4974
5064
  ...element,
4975
5065
  binding,
4976
5066
  children: element.children.map((c) => {
@@ -4985,29 +5075,23 @@ function elideMatchersFromArrayBindings(elements) {
4985
5075
  }
4986
5076
  }
4987
5077
  ;
4988
- return results1;
5078
+ return results;
4989
5079
  }
4990
5080
  function elideMatchersFromPropertyBindings(properties) {
4991
- const results2 = [];
4992
- for (let i7 = 0, len6 = properties.length; i7 < len6; i7++) {
4993
- const p = properties[i7];
5081
+ const results1 = [];
5082
+ for (let i6 = 0, len5 = properties.length; i6 < len5; i6++) {
5083
+ const p = properties[i6];
4994
5084
  switch (p.type) {
4995
5085
  case "BindingProperty":
4996
5086
  case "PinProperty": {
4997
- const { children, name, value, bind } = p;
5087
+ const { children, name, value } = p;
4998
5088
  const [ws] = children;
4999
5089
  const shouldElide = name.type === "NumericLiteral" && !value?.name || name.type === "ComputedPropertyName" && value?.subtype === "NumericLiteral";
5000
5090
  if (shouldElide) {
5001
- if (bind) {
5002
- results2.push({
5003
- type: "Error",
5004
- message: `Cannot bind ${name.type}`
5005
- });
5006
- } else {
5007
- continue;
5008
- }
5091
+ continue;
5009
5092
  } else {
5010
5093
  let contents;
5094
+ let m1;
5011
5095
  switch (value?.type) {
5012
5096
  case "ArrayBindingPattern":
5013
5097
  case "ObjectBindingPattern": {
@@ -5024,22 +5108,28 @@ function elideMatchersFromPropertyBindings(properties) {
5024
5108
  contents = p;
5025
5109
  break;
5026
5110
  }
5111
+ case "NamedBindingPattern": {
5112
+ const bindings = nonMatcherBindings(value.pattern);
5113
+ contents = {
5114
+ ...p,
5115
+ subbinding: (m1 = bindings?.type, m1 === "ArrayBindingPattern" || m1 === "ObjectBindingPattern" || m1 === "Identifier") ? [
5116
+ bindings,
5117
+ " = ",
5118
+ name
5119
+ ] : void 0
5120
+ };
5121
+ if (p.name === value.binding) {
5122
+ contents.children = [ws, name, p.delim];
5123
+ }
5124
+ ;
5125
+ break;
5126
+ }
5027
5127
  default: {
5028
5128
  contents = void 0;
5029
5129
  }
5030
5130
  }
5031
- if (bind) {
5032
- results2.push({
5033
- ...p,
5034
- children: [ws, name, p.delim],
5035
- subbinding: contents?.value ? [
5036
- contents.value,
5037
- " = ",
5038
- name
5039
- ] : void 0
5040
- });
5041
- } else if (contents) {
5042
- results2.push(contents);
5131
+ if (contents) {
5132
+ results1.push(contents);
5043
5133
  } else {
5044
5134
  continue;
5045
5135
  }
@@ -5048,14 +5138,15 @@ function elideMatchersFromPropertyBindings(properties) {
5048
5138
  break;
5049
5139
  }
5050
5140
  default: {
5051
- results2.push(p);
5141
+ results1.push(p);
5052
5142
  }
5053
5143
  }
5054
5144
  }
5055
5145
  ;
5056
- return results2;
5146
+ return results1;
5057
5147
  }
5058
5148
  function nonMatcherBindings(pattern) {
5149
+ let m2;
5059
5150
  switch (pattern.type) {
5060
5151
  case "ArrayBindingPattern":
5061
5152
  case "PostRestBindingElements": {
@@ -5063,7 +5154,7 @@ function nonMatcherBindings(pattern) {
5063
5154
  return makeNode({
5064
5155
  ...pattern,
5065
5156
  elements,
5066
- children: pattern.children.map(($10) => $10 === pattern.elements ? elements : $10)
5157
+ children: pattern.children.map(($9) => $9 === pattern.elements ? elements : $9)
5067
5158
  });
5068
5159
  }
5069
5160
  case "ObjectBindingPattern": {
@@ -5071,9 +5162,19 @@ function nonMatcherBindings(pattern) {
5071
5162
  return makeNode({
5072
5163
  ...pattern,
5073
5164
  properties,
5074
- children: pattern.children.map(($11) => $11 === pattern.properties ? properties : $11)
5165
+ children: pattern.children.map(($10) => $10 === pattern.properties ? properties : $10)
5075
5166
  });
5076
5167
  }
5168
+ case "NamedBindingPattern": {
5169
+ const bindings = nonMatcherBindings(pattern.pattern);
5170
+ return makeNode({
5171
+ ...pattern,
5172
+ subbinding: (m2 = bindings?.type, m2 === "ArrayBindingPattern" || m2 === "ObjectBindingPattern" || m2 === "Identifier") ? [bindings, " = ", pattern.binding] : void 0
5173
+ });
5174
+ }
5175
+ case "ConditionFragment": {
5176
+ return pattern.binding;
5177
+ }
5077
5178
  default: {
5078
5179
  return pattern;
5079
5180
  }
@@ -5089,11 +5190,11 @@ function aggregateDuplicateBindings(bindings) {
5089
5190
  );
5090
5191
  const declarations = [];
5091
5192
  const propsGroupedByName = /* @__PURE__ */ new Map();
5092
- for (let i8 = 0, len7 = props.length; i8 < len7; i8++) {
5093
- const p = props[i8];
5193
+ for (let i7 = 0, len6 = props.length; i7 < len6; i7++) {
5194
+ const p = props[i7];
5094
5195
  const { name, value } = p;
5095
- let m1;
5096
- if (m1 = value?.type, m1 === "ArrayBindingPattern" || m1 === "ObjectBindingPattern") {
5196
+ let m3;
5197
+ if (m3 = value?.type, m3 === "ArrayBindingPattern" || m3 === "ObjectBindingPattern") {
5097
5198
  continue;
5098
5199
  }
5099
5200
  const key = value?.name || name?.name || name;
@@ -5115,8 +5216,8 @@ function aggregateDuplicateBindings(bindings) {
5115
5216
  pos: 0,
5116
5217
  input: key
5117
5218
  })) {
5118
- for (let i9 = 0, len8 = shared.length; i9 < len8; i9++) {
5119
- const p = shared[i9];
5219
+ for (let i8 = 0, len7 = shared.length; i8 < len7; i8++) {
5220
+ const p = shared[i8];
5120
5221
  aliasBinding(p, makeRef(`_${key}`, key));
5121
5222
  }
5122
5223
  return;
@@ -5208,8 +5309,18 @@ function processDeclarations(statements) {
5208
5309
  if (!(bindings != null)) {
5209
5310
  continue;
5210
5311
  }
5211
- for (let i2 = 0, len22 = bindings.length; i2 < len22; i2++) {
5212
- const binding = bindings[i2];
5312
+ for (let i2 = bindings.length + -1; i2 >= 0; --i2) {
5313
+ const i = i2;
5314
+ const binding = bindings[i];
5315
+ const subbindings = gatherSubbindings(binding);
5316
+ if (subbindings.length) {
5317
+ simplifyBindingProperties(binding);
5318
+ simplifyBindingProperties(subbindings);
5319
+ spliceChild(declaration, binding, 1, binding, subbindings);
5320
+ }
5321
+ }
5322
+ for (let i3 = 0, len22 = bindings.length; i3 < len22; i3++) {
5323
+ const binding = bindings[i3];
5213
5324
  let { typeSuffix, initializer } = binding;
5214
5325
  if (typeSuffix && typeSuffix.optional) {
5215
5326
  if (initializer && !typeSuffix.t) {
@@ -5247,6 +5358,25 @@ function processDeclarations(statements) {
5247
5358
  }
5248
5359
  }
5249
5360
  }
5361
+ for (let ref2 = gatherRecursiveAll(statements, ($1) => $1.type === "ForStatement"), i4 = 0, len3 = ref2.length; i4 < len3; i4++) {
5362
+ const statement = ref2[i4];
5363
+ const { declaration } = statement;
5364
+ if (!(declaration?.type === "ForDeclaration")) {
5365
+ continue;
5366
+ }
5367
+ const { binding } = declaration;
5368
+ const blockPrefix = getPatternBlockPrefix(
5369
+ binding.pattern,
5370
+ void 0,
5371
+ append(declaration.decl, " "),
5372
+ binding.typeSuffix
5373
+ );
5374
+ simplifyBindingProperties(binding);
5375
+ if (blockPrefix != null) {
5376
+ statement.block.expressions.unshift(...blockPrefix);
5377
+ braceBlock(statement.block);
5378
+ }
5379
+ }
5250
5380
  }
5251
5381
  function prependStatementExpressionBlock(initializer, statement) {
5252
5382
  let { expression: exp } = initializer;
@@ -5390,8 +5520,7 @@ function processDeclarationConditionStatement(s) {
5390
5520
  }
5391
5521
  let { expression } = condition;
5392
5522
  if (expression && typeof expression === "object" && "type" in expression && expression.type === "UnaryExpression" && "children" in expression && Array.isArray(expression.children) && len2(expression.children, 2) && Array.isArray(expression.children[0]) && len2(expression.children[0], 1) && expression.children[0][0] === "!" && typeof expression.children[1] === "object" && expression.children[1] != null && "type" in expression.children[1] && expression.children[1].type === "ParenthesizedExpression" && "expression" in expression.children[1]) {
5393
- const { type: type1, children: [[], { type: type2, expression: expression2 }] } = expression;
5394
- const type = [type1, type2];
5523
+ const { children: [[], { expression: expression2 }] } = expression;
5395
5524
  expression = expression2;
5396
5525
  }
5397
5526
  processDeclarationCondition(expression, condition.expression, s);
@@ -5416,8 +5545,8 @@ function processDeclarationConditionStatement(s) {
5416
5545
  ({ children } = condition.expression.children[1]);
5417
5546
  }
5418
5547
  children.unshift("(");
5419
- for (let i3 = 0, len3 = conditions.length; i3 < len3; i3++) {
5420
- const c = conditions[i3];
5548
+ for (let i5 = 0, len4 = conditions.length; i5 < len4; i5++) {
5549
+ const c = conditions[i5];
5421
5550
  children.push(" && ", c);
5422
5551
  }
5423
5552
  children.push(")");
@@ -5439,11 +5568,11 @@ function processDeclarationConditionStatement(s) {
5439
5568
  ancestor.expressions.splice(index + 1, 0, ...blockPrefix);
5440
5569
  updateParentPointers(ancestor);
5441
5570
  braceBlock(ancestor);
5442
- let ref2;
5571
+ let ref3;
5443
5572
  switch (s.type) {
5444
5573
  case "IfStatement": {
5445
- if (ref2 = s.else?.block) {
5446
- const elseBlock = ref2;
5574
+ if (ref3 = s.else?.block) {
5575
+ const elseBlock = ref3;
5447
5576
  if (elseBlock.bare && !elseBlock.semicolon) {
5448
5577
  elseBlock.children.push(elseBlock.semicolon = ";");
5449
5578
  }
@@ -5467,13 +5596,13 @@ function processDeclarationConditionStatement(s) {
5467
5596
  if (s.negated) {
5468
5597
  if (e != null) {
5469
5598
  const block = blockWithPrefix(blockPrefix, e.block);
5470
- e.children = e.children.map(($1) => $1 === e.block ? block : $1);
5599
+ e.children = e.children.map(($2) => $2 === e.block ? block : $2);
5471
5600
  e.block = block;
5472
5601
  updateParentPointers(e);
5473
5602
  }
5474
5603
  } else {
5475
5604
  const block = blockWithPrefix(blockPrefix, s.then);
5476
- s.children = s.children.map(($2) => $2 === s.then ? block : $2);
5605
+ s.children = s.children.map(($3) => $3 === s.then ? block : $3);
5477
5606
  s.then = block;
5478
5607
  updateParentPointers(s);
5479
5608
  }
@@ -5486,7 +5615,7 @@ function processDeclarationConditionStatement(s) {
5486
5615
  }
5487
5616
  const { children, block } = s;
5488
5617
  const newBlock = blockWithPrefix(blockPrefix, block);
5489
- s.children = children.map(($3) => $3 === block ? newBlock : $3);
5618
+ s.children = children.map(($4) => $4 === block ? newBlock : $4);
5490
5619
  updateParentPointers(s);
5491
5620
  break;
5492
5621
  }
@@ -5514,7 +5643,7 @@ function processDeclarationConditionStatement(s) {
5514
5643
  const block = makeEmptyBlock();
5515
5644
  replaceBlockExpression(s.parent, s, block);
5516
5645
  block.expressions.push(["", s]);
5517
- s.children.splice(s.children.findIndex(($4) => $4.token === "switch"), 0, blockPrefix);
5646
+ s.children.splice(s.children.findIndex(($5) => $5.token === "switch"), 0, blockPrefix);
5518
5647
  s.parent = block;
5519
5648
  } else {
5520
5649
  const block = blockWithPrefix([["", [{
@@ -5534,12 +5663,12 @@ function processDeclarationConditionStatement(s) {
5534
5663
  function dynamizeFromClause(from) {
5535
5664
  from = from.slice(1);
5536
5665
  from = trimFirstSpace(from);
5537
- let ref3;
5538
- if (ref3 = from[from.length - 1]?.assertion) {
5539
- const assert2 = ref3;
5540
- let ref4;
5541
- ref4 = from[from.length - 1];
5542
- ref4.children = ref4.children.filter((a2) => a2 !== assert2);
5666
+ let ref4;
5667
+ if (ref4 = from[from.length - 1]?.assertion) {
5668
+ const assert2 = ref4;
5669
+ let ref5;
5670
+ ref5 = from[from.length - 1];
5671
+ ref5.children = ref5.children.filter((a2) => a2 !== assert2);
5543
5672
  from.push(", {", assert2.keyword, ":", assert2.object, "}");
5544
5673
  }
5545
5674
  return ["(", ...from, ")"];
@@ -5548,20 +5677,20 @@ function dynamizeImportDeclaration(decl) {
5548
5677
  const { imports } = decl;
5549
5678
  let { star, binding, specifiers } = imports;
5550
5679
  const justDefault = binding && !specifiers && !star;
5551
- let ref5;
5680
+ let ref6;
5552
5681
  {
5553
5682
  if (binding) {
5554
5683
  if (specifiers) {
5555
- ref5 = makeRef();
5684
+ ref6 = makeRef();
5556
5685
  } else {
5557
- ref5 = binding;
5686
+ ref6 = binding;
5558
5687
  }
5559
5688
  } else {
5560
- ref5 = convertNamedImportsToObject(imports, true);
5689
+ ref6 = convertNamedImportsToObject(imports, true);
5561
5690
  }
5562
5691
  }
5563
5692
  ;
5564
- const pattern = ref5;
5693
+ const pattern = ref6;
5565
5694
  const c = "const";
5566
5695
  const expression = [
5567
5696
  justDefault ? "(" : void 0,
@@ -5826,7 +5955,7 @@ function processUnaryNestedExpression(pre, args, post) {
5826
5955
  children: args.children.map(
5827
5956
  (arg) => {
5828
5957
  if (typeof arg === "object" && arg != null && "type" in arg && arg.type === "ArrayElement" && "expression" in arg && "children" in arg) {
5829
- const { type, expression: exp, children } = arg;
5958
+ const { expression: exp, children } = arg;
5830
5959
  let expression = processUnaryExpression([last], trimFirstSpace(exp));
5831
5960
  expression = prepend(getTrimmingSpace(exp), expression);
5832
5961
  return {
@@ -6072,12 +6201,12 @@ function processPipelineExpressions(statements) {
6072
6201
  }
6073
6202
 
6074
6203
  // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\for.civet.jsx
6075
- function processRangeExpression(start, ws1, range, end) {
6076
- ws1 = [ws1, range.children[0]];
6077
- const ws2 = range.children[1];
6078
- const comma = { $loc: range.$loc, token: "," };
6204
+ function processRangeExpression(start, ws1, range2, end) {
6205
+ ws1 = [ws1, range2.children[0]];
6206
+ const ws2 = range2.children[1];
6207
+ const comma = { $loc: range2.$loc, token: "," };
6079
6208
  let ref;
6080
- switch (range.increasing) {
6209
+ switch (range2.increasing) {
6081
6210
  case true: {
6082
6211
  ref = ($) => $;
6083
6212
  break;
@@ -6092,7 +6221,7 @@ function processRangeExpression(start, ws1, range, end) {
6092
6221
  }
6093
6222
  ;
6094
6223
  const abs = ref;
6095
- const lengthAdjust = 1 - Number(!range.left.inclusive) - Number(!range.right.inclusive);
6224
+ const lengthAdjust = 1 - Number(!range2.left.inclusive) - Number(!range2.right.inclusive);
6096
6225
  let children;
6097
6226
  if (typeof start === "object" && start != null && "type" in start && start.type === "Literal" && (typeof end === "object" && end != null && "type" in end && end.type === "Literal")) {
6098
6227
  let startValue = literalValue(start);
@@ -6105,7 +6234,7 @@ function processRangeExpression(start, ws1, range, end) {
6105
6234
  let endCode = endValue.charCodeAt(0);
6106
6235
  const step = startCode <= endCode ? 1 : -1;
6107
6236
  const length = abs(endCode - startCode) + lengthAdjust;
6108
- if (!range.left.inclusive) {
6237
+ if (!range2.left.inclusive) {
6109
6238
  startCode += step;
6110
6239
  }
6111
6240
  if (length <= 26) {
@@ -6126,13 +6255,13 @@ function processRangeExpression(start, ws1, range, end) {
6126
6255
  ")"
6127
6256
  ];
6128
6257
  }
6129
- if (range.error != null) {
6130
- children.unshift(range.error);
6258
+ if (range2.error != null) {
6259
+ children.unshift(range2.error);
6131
6260
  }
6132
6261
  } else if (typeof startValue === "number" && typeof endValue === "number") {
6133
6262
  const step = startValue <= endValue ? 1 : -1;
6134
6263
  const length = abs(endValue - startValue) + lengthAdjust;
6135
- if (!range.left.inclusive) {
6264
+ if (!range2.left.inclusive) {
6136
6265
  startValue += step;
6137
6266
  }
6138
6267
  if (length <= 20) {
@@ -6141,22 +6270,22 @@ function processRangeExpression(start, ws1, range, end) {
6141
6270
  Array.from({ length }, (_2, i) => startValue + i * step).join(", "),
6142
6271
  "]"
6143
6272
  ];
6144
- if (range.error != null) {
6145
- children.unshift(range.error);
6273
+ if (range2.error != null) {
6274
+ children.unshift(range2.error);
6146
6275
  }
6147
6276
  }
6148
6277
  }
6149
6278
  }
6150
6279
  if (!(children != null)) {
6151
- if (range.increasing != null) {
6152
- const sign = range.increasing ? "+" : "-";
6280
+ if (range2.increasing != null) {
6281
+ const sign = range2.increasing ? "+" : "-";
6153
6282
  end = makeLeftHandSideExpression(end);
6154
6283
  children = [
6155
- getHelperRef(range.increasing ? "range" : "revRange"),
6284
+ getHelperRef(range2.increasing ? "range" : "revRange"),
6156
6285
  "(",
6157
- range.left.inclusive ? start : [makeLeftHandSideExpression(start), ` ${sign} 1`],
6286
+ range2.left.inclusive ? start : [makeLeftHandSideExpression(start), ` ${sign} 1`],
6158
6287
  ",",
6159
- range.right.inclusive ? [makeLeftHandSideExpression(end), ` ${sign} 1`] : end,
6288
+ range2.right.inclusive ? [makeLeftHandSideExpression(end), ` ${sign} 1`] : end,
6160
6289
  ...ws1,
6161
6290
  ")"
6162
6291
  ];
@@ -6165,11 +6294,11 @@ function processRangeExpression(start, ws1, range, end) {
6165
6294
  "((s, e) => s > e ? ",
6166
6295
  getHelperRef("revRange"),
6167
6296
  "(s, e",
6168
- range.right.inclusive ? " - 1" : void 0,
6297
+ range2.right.inclusive ? " - 1" : void 0,
6169
6298
  ") : ",
6170
6299
  getHelperRef("range"),
6171
6300
  "(s, e",
6172
- range.right.inclusive ? " + 1" : void 0,
6301
+ range2.right.inclusive ? " + 1" : void 0,
6173
6302
  "))",
6174
6303
  "(",
6175
6304
  start,
@@ -6186,14 +6315,14 @@ function processRangeExpression(start, ws1, range, end) {
6186
6315
  children,
6187
6316
  start,
6188
6317
  end,
6189
- error: range.error,
6190
- left: range.left,
6191
- right: range.right,
6192
- increasing: range.increasing
6318
+ error: range2.error,
6319
+ left: range2.left,
6320
+ right: range2.right,
6321
+ increasing: range2.increasing
6193
6322
  };
6194
6323
  }
6195
- function forRange(open, forDeclaration, range, stepExp, close) {
6196
- let { start, end, left, right, increasing } = range;
6324
+ function forRange(open, forDeclaration, range2, stepExp, close) {
6325
+ let { start, end, left, right, increasing } = range2;
6197
6326
  const counterRef = makeRef("i");
6198
6327
  const infinite = typeof end === "object" && end != null && "type" in end && end.type === "Identifier" && "name" in end && end.name === "Infinity";
6199
6328
  let stepRef, asc;
@@ -6292,7 +6421,7 @@ function forRange(open, forDeclaration, range, stepExp, close) {
6292
6421
  // This declaration doesn't always appear in the output,
6293
6422
  // but it's still helpful for determining the primary loop variable
6294
6423
  declaration: forDeclaration,
6295
- children: [range.error, open, declaration, "; ", ...condition, "; ", ...increment, close],
6424
+ children: [range2.error, open, declaration, "; ", ...condition, "; ", ...increment, close],
6296
6425
  blockPrefix
6297
6426
  };
6298
6427
  }
@@ -6352,6 +6481,7 @@ function processForInOf($0) {
6352
6481
  declaration = {
6353
6482
  type: "Declaration",
6354
6483
  children: ["let ", ...expRefDec, counterRef, " = 0, ", lenRef, " = ", trimFirstSpace(expRef2), ".length"],
6484
+ decl: "let",
6355
6485
  names: []
6356
6486
  };
6357
6487
  const condition = [counterRef, " < ", lenRef, "; "];
@@ -6375,6 +6505,9 @@ function processForInOf($0) {
6375
6505
  }
6376
6506
  const { binding } = declaration;
6377
6507
  let pattern = binding?.pattern;
6508
+ if (pattern?.type === "NamedBindingPattern") {
6509
+ pattern = pattern.binding;
6510
+ }
6378
6511
  if (binding?.typeSuffix || inOf.token === "in" && declaration2 && pattern.type !== "Identifier") {
6379
6512
  const itemRef = makeRef(inOf.token === "in" ? "key" : "item");
6380
6513
  blockPrefix.push(["", {
@@ -6413,12 +6546,14 @@ function processForInOf($0) {
6413
6546
  hoistDec = {
6414
6547
  type: "Declaration",
6415
6548
  children: ["let ", counterRef, " = 0"],
6549
+ decl: "let",
6416
6550
  names: []
6417
6551
  };
6418
6552
  blockPrefix.push(["", {
6419
6553
  type: "Declaration",
6420
6554
  children: [trimFirstSpace(ws2), decl2, " = ", counterRef, "++"],
6421
- names: decl2.names
6555
+ names: decl2.names,
6556
+ decl: decl2.decl
6422
6557
  }, ";"]);
6423
6558
  break;
6424
6559
  }
@@ -6428,7 +6563,8 @@ function processForInOf($0) {
6428
6563
  hoistDec = {
6429
6564
  type: "Declaration",
6430
6565
  children: ["let ", expRef2],
6431
- names: []
6566
+ names: [],
6567
+ decl: "let"
6432
6568
  };
6433
6569
  exp = {
6434
6570
  type: "AssignmentExpression",
@@ -6440,20 +6576,58 @@ function processForInOf($0) {
6440
6576
  blockPrefix.push(["", ["if (!", hasPropRef, "(", trimFirstSpace(expRef2), ", ", trimFirstSpace(pattern), ")) continue"], ";"]);
6441
6577
  }
6442
6578
  if (decl2) {
6443
- blockPrefix.push(["", {
6444
- type: "Declaration",
6579
+ const trimmedPattern = trimFirstSpace(pattern);
6580
+ const expression = makeNode({
6581
+ type: "MemberExpression",
6445
6582
  children: [
6446
- trimFirstSpace(ws2),
6447
- decl2,
6448
- " = ",
6449
6583
  trimFirstSpace(expRef2),
6450
- "[",
6451
- trimFirstSpace(pattern),
6452
- "]"
6453
- ],
6454
- decl: decl2,
6455
- names: decl2.names
6456
- }, ";"]);
6584
+ makeNode({
6585
+ type: "Index",
6586
+ expression: trimmedPattern,
6587
+ children: ["[", trimmedPattern, "]"]
6588
+ })
6589
+ ]
6590
+ });
6591
+ blockPrefix.push([
6592
+ "",
6593
+ (() => {
6594
+ if (decl2.type === "ForDeclaration") {
6595
+ const { binding: binding2, children } = decl2;
6596
+ binding2.children.push(binding2.initializer = makeNode({
6597
+ type: "Initializer",
6598
+ expression,
6599
+ children: [" = ", expression]
6600
+ }));
6601
+ return makeNode({
6602
+ type: "Declaration",
6603
+ children: [
6604
+ trimFirstSpace(ws2),
6605
+ ...children
6606
+ ],
6607
+ bindings: [decl2.binding],
6608
+ decl: decl2.decl,
6609
+ names: decl2.names
6610
+ });
6611
+ } else {
6612
+ return makeNode({
6613
+ type: "AssignmentExpression",
6614
+ children: [
6615
+ trimFirstSpace(ws2),
6616
+ decl2,
6617
+ " = ",
6618
+ trimFirstSpace(expRef2),
6619
+ "[",
6620
+ trimFirstSpace(pattern),
6621
+ "]"
6622
+ ],
6623
+ names: decl2.names,
6624
+ lhs: decl2,
6625
+ assigned: decl2
6626
+ });
6627
+ }
6628
+ })(),
6629
+ ";"
6630
+ ]);
6457
6631
  }
6458
6632
  ;
6459
6633
  break;
@@ -6983,7 +7157,7 @@ function processTryBlock($0) {
6983
7157
  const clauses = cs.map((clause) => {
6984
7158
  let ref1;
6985
7159
  if ((ref1 = clause.binding?.parameter) && typeof ref1 === "object" && "type" in ref1 && ref1.type === "CatchPattern" && "patterns" in ref1) {
6986
- const { type, patterns } = ref1;
7160
+ const { patterns } = ref1;
6987
7161
  return {
6988
7162
  type: "PatternClause",
6989
7163
  patterns,
@@ -7587,7 +7761,14 @@ function makeGetterMethod(name, ws, value, returnType, block, kind = { token: "g
7587
7761
  function processBindingPatternLHS(lhs, tail) {
7588
7762
  adjustAtBindings(lhs, true);
7589
7763
  const [splices, thisAssignments] = gatherBindingCode(lhs);
7590
- tail.push(...splices.map((s) => [", ", s]), ...thisAssignments.map((a) => [", ", a]));
7764
+ const subbindings = gatherSubbindings(lhs);
7765
+ simplifyBindingProperties(lhs);
7766
+ simplifyBindingProperties(subbindings);
7767
+ tail.push(
7768
+ ...splices.map((s) => [", ", s]),
7769
+ ...thisAssignments.map((a) => [", ", a]),
7770
+ ...subbindings
7771
+ );
7591
7772
  }
7592
7773
  function processAssignments(statements) {
7593
7774
  for (let ref7 = gatherRecursiveAll(statements, ($4) => $4.type === "AssignmentExpression" || $4.type === "UpdateExpression"), i5 = 0, len3 = ref7.length; i5 < len3; i5++) {
@@ -7756,7 +7937,7 @@ function processAssignments(statements) {
7756
7937
  message: "Slice range cannot be decreasing in assignment"
7757
7938
  });
7758
7939
  break;
7759
- } else if (m3 = lhs.type, m3 === "ObjectBindingPattern" || m3 === "ArrayBindingPattern") {
7940
+ } else if (m3 = lhs.type, m3 === "ObjectBindingPattern" || m3 === "ArrayBindingPattern" || m3 === "NamedBindingPattern") {
7760
7941
  processBindingPatternLHS(lhs, tail);
7761
7942
  gatherRecursiveAll(lhs, ($9) => $9.type === "Ref").forEach(refsToDeclare.add.bind(refsToDeclare));
7762
7943
  }
@@ -7905,7 +8086,7 @@ function processTypes(node) {
7905
8086
  while (suffixIndex >= 0) {
7906
8087
  const suffix = unary.suffix[suffixIndex];
7907
8088
  if (typeof suffix === "object" && suffix != null && "token" in suffix && suffix.token === "?") {
7908
- const { token } = suffix;
8089
+ const {} = suffix;
7909
8090
  let count = 0;
7910
8091
  let m4;
7911
8092
  while (m4 = unary.suffix[suffixIndex], typeof m4 === "object" && m4 != null && "token" in m4 && m4.token === "?") {
@@ -7963,7 +8144,7 @@ function processTypes(node) {
7963
8144
  }
7964
8145
  results2.push(replaceNode(unary, replace, parent));
7965
8146
  } else if (typeof suffix === "object" && suffix != null && "type" in suffix && suffix.type === "NonNullAssertion") {
7966
- const { type } = suffix;
8147
+ const {} = suffix;
7967
8148
  let m6;
7968
8149
  while (m6 = unary.suffix[suffixIndex], typeof m6 === "object" && m6 != null && "type" in m6 && m6.type === "NonNullAssertion") {
7969
8150
  unary.suffix.splice(suffixIndex--, 1);
@@ -8361,30 +8542,10 @@ function processRepl(root, rootIIFE) {
8361
8542
  }
8362
8543
  }
8363
8544
  }
8364
- function populateRefs(statements) {
8365
- const refNodes = gatherRecursive(statements, ($21) => $21.type === "Ref");
8366
- if (refNodes.length) {
8367
- const ids = gatherRecursive(statements, (s) => s.type === "Identifier");
8368
- const names = new Set(ids.flatMap(({ names: names2 }) => names2 || []));
8369
- refNodes.forEach((ref) => {
8370
- const { type, base } = ref;
8371
- if (type !== "Ref") return;
8372
- ref.type = "Identifier";
8373
- let n = 0;
8374
- let name = base;
8375
- while (names.has(name)) {
8376
- n++;
8377
- name = `${base}${n}`;
8378
- }
8379
- names.add(name);
8380
- return ref.children = ref.names = [name];
8381
- });
8382
- }
8383
- }
8384
8545
  function processPlaceholders(statements) {
8385
8546
  const placeholderMap = /* @__PURE__ */ new Map();
8386
8547
  const liftedIfs = /* @__PURE__ */ new Set();
8387
- for (let ref25 = gatherRecursiveAll(statements, ($22) => $22.type === "Placeholder"), i17 = 0, len14 = ref25.length; i17 < len14; i17++) {
8548
+ for (let ref25 = gatherRecursiveAll(statements, ($21) => $21.type === "Placeholder"), i17 = 0, len14 = ref25.length; i17 < len14; i17++) {
8388
8549
  const exp = ref25[i17];
8389
8550
  let ancestor;
8390
8551
  if (exp.subtype === ".") {
@@ -8827,6 +8988,7 @@ var grammar = {
8827
8988
  NWBindingIdentifier,
8828
8989
  AtIdentifierRef,
8829
8990
  PinPattern,
8991
+ NamedBindingPattern,
8830
8992
  BindingPattern,
8831
8993
  ObjectBindingPattern,
8832
8994
  ObjectBindingPatternContent,
@@ -11376,8 +11538,9 @@ var LeftHandSideExpression$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, impo
11376
11538
  expression
11377
11539
  };
11378
11540
  });
11379
- var LeftHandSideExpression$1 = CallExpression;
11380
- var LeftHandSideExpression$$ = [LeftHandSideExpression$0, LeftHandSideExpression$1];
11541
+ var LeftHandSideExpression$1 = NamedBindingPattern;
11542
+ var LeftHandSideExpression$2 = CallExpression;
11543
+ var LeftHandSideExpression$$ = [LeftHandSideExpression$0, LeftHandSideExpression$1, LeftHandSideExpression$2];
11381
11544
  function LeftHandSideExpression(ctx, state2) {
11382
11545
  return (0, import_lib2.$EVENT_C)(ctx, state2, "LeftHandSideExpression", LeftHandSideExpression$$);
11383
11546
  }
@@ -12000,7 +12163,7 @@ var FunctionRestParameter$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, impor
12000
12163
  function FunctionRestParameter(ctx, state2) {
12001
12164
  return (0, import_lib2.$EVENT)(ctx, state2, "FunctionRestParameter", FunctionRestParameter$0);
12002
12165
  }
12003
- var ParameterElement$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), (0, import_lib2.$E)(AccessModifier), (0, import_lib2.$E)(_), (0, import_lib2.$C)(NWBindingIdentifier, BindingPattern), (0, import_lib2.$E)(TypeSuffix), (0, import_lib2.$E)(Initializer), ParameterElementDelimiter), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7) {
12166
+ var ParameterElement$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), (0, import_lib2.$E)(AccessModifier), (0, import_lib2.$E)(_), (0, import_lib2.$C)(BindingPattern, NWBindingIdentifier), (0, import_lib2.$E)(TypeSuffix), (0, import_lib2.$E)(Initializer), ParameterElementDelimiter), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7) {
12004
12167
  var accessModifier = $2;
12005
12168
  var binding = $4;
12006
12169
  var typeSuffix = $5;
@@ -12113,12 +12276,31 @@ var PinPattern$$ = [PinPattern$0, PinPattern$1, PinPattern$2, PinPattern$3];
12113
12276
  function PinPattern(ctx, state2) {
12114
12277
  return (0, import_lib2.$EVENT_C)(ctx, state2, "PinPattern", PinPattern$$);
12115
12278
  }
12279
+ var NamedBindingPattern$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(BindingIdentifier, Caret, (0, import_lib2.$E)(_), BindingPattern), function($skip, $loc, $0, $1, $2, $3, $4) {
12280
+ var binding = $1;
12281
+ var ws = $3;
12282
+ var pattern = $4;
12283
+ pattern = prepend(ws, pattern);
12284
+ return {
12285
+ type: "NamedBindingPattern",
12286
+ // NOTE: children just has binding, not pattern, for easy destructuring
12287
+ children: [binding],
12288
+ binding,
12289
+ pattern,
12290
+ subbinding: [pattern, " = ", binding],
12291
+ typeSuffix: pattern.typeSuffix
12292
+ };
12293
+ });
12294
+ function NamedBindingPattern(ctx, state2) {
12295
+ return (0, import_lib2.$EVENT)(ctx, state2, "NamedBindingPattern", NamedBindingPattern$0);
12296
+ }
12116
12297
  var BindingPattern$0 = ObjectBindingPattern;
12117
12298
  var BindingPattern$1 = ArrayBindingPattern;
12118
12299
  var BindingPattern$2 = PinPattern;
12119
12300
  var BindingPattern$3 = Literal;
12120
12301
  var BindingPattern$4 = RegularExpressionLiteral;
12121
- var BindingPattern$$ = [BindingPattern$0, BindingPattern$1, BindingPattern$2, BindingPattern$3, BindingPattern$4];
12302
+ var BindingPattern$5 = NamedBindingPattern;
12303
+ var BindingPattern$$ = [BindingPattern$0, BindingPattern$1, BindingPattern$2, BindingPattern$3, BindingPattern$4, BindingPattern$5];
12122
12304
  function BindingPattern(ctx, state2) {
12123
12305
  return (0, import_lib2.$EVENT_C)(ctx, state2, "BindingPattern", BindingPattern$$);
12124
12306
  }
@@ -12242,7 +12424,7 @@ function NestedBindingPropertyList(ctx, state2) {
12242
12424
  return (0, import_lib2.$EVENT)(ctx, state2, "NestedBindingPropertyList", NestedBindingPropertyList$0);
12243
12425
  }
12244
12426
  var BindingProperty$0 = BindingRestProperty;
12245
- var BindingProperty$1 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), PropertyName, (0, import_lib2.$E)(Caret), (0, import_lib2.$E)(_), Colon, (0, import_lib2.$E)(_), (0, import_lib2.$C)(BindingIdentifier, BindingPattern), (0, import_lib2.$E)(BindingTypeSuffix), (0, import_lib2.$E)(Initializer)), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
12427
+ var BindingProperty$1 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), PropertyName, (0, import_lib2.$E)(Caret), (0, import_lib2.$E)(_), Colon, (0, import_lib2.$E)(_), (0, import_lib2.$C)(BindingPattern, BindingIdentifier), (0, import_lib2.$E)(BindingTypeSuffix), (0, import_lib2.$E)(Initializer)), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
12246
12428
  var ws1 = $1;
12247
12429
  var name = $2;
12248
12430
  var bind = $3;
@@ -12252,6 +12434,19 @@ var BindingProperty$1 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2
12252
12434
  var value = $7;
12253
12435
  var typeSuffix = $8;
12254
12436
  var initializer = $9;
12437
+ if (bind) {
12438
+ const binding = name, pattern = value;
12439
+ value = {
12440
+ type: "NamedBindingPattern",
12441
+ // NOTE: children just has binding, not pattern, for easy destructuring
12442
+ children: [binding],
12443
+ binding,
12444
+ pattern,
12445
+ subbinding: [pattern, " = ", binding],
12446
+ typeSuffix: pattern.typeSuffix,
12447
+ names: value.names
12448
+ };
12449
+ }
12255
12450
  return {
12256
12451
  type: "BindingProperty",
12257
12452
  children: [ws1, name, ws2, colon, ws3, value, initializer],
@@ -12260,8 +12455,7 @@ var BindingProperty$1 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2
12260
12455
  value,
12261
12456
  typeSuffix,
12262
12457
  initializer,
12263
- names: value.names,
12264
- bind: !!bind
12458
+ names: value.names
12265
12459
  };
12266
12460
  });
12267
12461
  var BindingProperty$2 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), Caret, BindingIdentifier, (0, import_lib2.$E)(BindingTypeSuffix), (0, import_lib2.$E)(Initializer)), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
@@ -12326,8 +12520,7 @@ var BindingProperty$3 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2
12326
12520
  typeSuffix,
12327
12521
  initializer,
12328
12522
  names: binding.names,
12329
- identifier: binding,
12330
- bind: !!bind
12523
+ identifier: binding
12331
12524
  };
12332
12525
  });
12333
12526
  var BindingProperty$$ = [BindingProperty$0, BindingProperty$1, BindingProperty$2, BindingProperty$3];
@@ -12385,7 +12578,7 @@ function NestedBindingElements(ctx, state2) {
12385
12578
  return (0, import_lib2.$EVENT)(ctx, state2, "NestedBindingElements", NestedBindingElements$0);
12386
12579
  }
12387
12580
  var BindingElement$0 = BindingRestElement;
12388
- var BindingElement$1 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), (0, import_lib2.$C)(BindingIdentifier, BindingPattern), (0, import_lib2.$E)(BindingTypeSuffix), (0, import_lib2.$E)(Initializer)), function($skip, $loc, $0, $1, $2, $3, $4) {
12581
+ var BindingElement$1 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), (0, import_lib2.$C)(BindingPattern, BindingIdentifier), (0, import_lib2.$E)(BindingTypeSuffix), (0, import_lib2.$E)(Initializer)), function($skip, $loc, $0, $1, $2, $3, $4) {
12389
12582
  var ws = $1;
12390
12583
  var binding = $2;
12391
12584
  var typeSuffix = $3;
@@ -12410,7 +12603,7 @@ var BindingElement$$ = [BindingElement$0, BindingElement$1, BindingElement$2];
12410
12603
  function BindingElement(ctx, state2) {
12411
12604
  return (0, import_lib2.$EVENT_C)(ctx, state2, "BindingElement", BindingElement$$);
12412
12605
  }
12413
- var BindingRestElement$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), DotDotDot, (0, import_lib2.$C)(BindingIdentifier, BindingPattern, EmptyBindingPattern), (0, import_lib2.$E)(BindingTypeSuffix)), function($skip, $loc, $0, $1, $2, $3, $4) {
12606
+ var BindingRestElement$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), DotDotDot, (0, import_lib2.$C)(BindingPattern, BindingIdentifier, EmptyBindingPattern), (0, import_lib2.$E)(BindingTypeSuffix)), function($skip, $loc, $0, $1, $2, $3, $4) {
12414
12607
  var ws = $1;
12415
12608
  var dots = $2;
12416
12609
  var binding = $3;
@@ -12426,7 +12619,7 @@ var BindingRestElement$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_l
12426
12619
  rest: true
12427
12620
  };
12428
12621
  });
12429
- var BindingRestElement$1 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), (0, import_lib2.$C)(BindingIdentifier, BindingPattern), DotDotDot), function($skip, $loc, $0, $1, $2, $3) {
12622
+ var BindingRestElement$1 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), (0, import_lib2.$C)(BindingPattern, BindingIdentifier), DotDotDot), function($skip, $loc, $0, $1, $2, $3) {
12430
12623
  var ws = $1;
12431
12624
  var binding = $2;
12432
12625
  var dots = $3;
@@ -13435,9 +13628,9 @@ function RangeEnd(ctx, state2) {
13435
13628
  var RangeExpression$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(Expression, __, RangeDots, Expression), function($skip, $loc, $0, $1, $2, $3, $4) {
13436
13629
  var start = $1;
13437
13630
  var ws = $2;
13438
- var range = $3;
13631
+ var range2 = $3;
13439
13632
  var end = $4;
13440
- return processRangeExpression(start, ws, range, end);
13633
+ return processRangeExpression(start, ws, range2, end);
13441
13634
  });
13442
13635
  var RangeExpression$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(Expression, __, DotDot, (0, import_lib2.$Y)((0, import_lib2.$S)(__, CloseBracket))), function($skip, $loc, $0, $1, $2, $3, $4) {
13443
13636
  var s = $1;
@@ -15575,10 +15768,13 @@ var ForDeclaration$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(LetOrConstOrVar,
15575
15768
  var ForDeclaration$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(InsertConst, (0, import_lib2.$N)(ActualMemberExpression), ForBinding), function($skip, $loc, $0, $1, $2, $3) {
15576
15769
  var c = $1;
15577
15770
  var binding = $3;
15771
+ if (gatherRecursive(binding, ($) => $.type === "PinPattern").length) {
15772
+ return $skip;
15773
+ }
15578
15774
  return {
15579
15775
  type: "ForDeclaration",
15580
15776
  children: [c, binding],
15581
- decl: c.token,
15777
+ decl: c.token.trimEnd(),
15582
15778
  binding,
15583
15779
  names: binding.names
15584
15780
  };
@@ -15748,12 +15944,17 @@ function PatternExpressionList(ctx, state2) {
15748
15944
  return (0, import_lib2.$EVENT)(ctx, state2, "PatternExpressionList", PatternExpressionList$0);
15749
15945
  }
15750
15946
  var PatternExpression$0 = BindingPattern;
15751
- var PatternExpression$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(ForbidIndentedApplication, (0, import_lib2.$E)((0, import_lib2.$P)(SingleLineBinaryOpRHS)), RestoreIndentedApplication), function($skip, $loc, $0, $1, $2, $3) {
15752
- var pattern = $2;
15753
- if (!pattern) return $skip;
15947
+ var PatternExpression$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(ForbidIndentedApplication, (0, import_lib2.$E)((0, import_lib2.$S)((0, import_lib2.$E)((0, import_lib2.$S)(BindingIdentifier, (0, import_lib2.$E)(Caret))), (0, import_lib2.$P)(SingleLineBinaryOpRHS))), RestoreIndentedApplication), function($skip, $loc, $0, $1, $2, $3) {
15948
+ var body = $2;
15949
+ if (!body) return $skip;
15950
+ const [named, rhs] = body;
15951
+ let binding;
15952
+ if (named) [binding] = named;
15754
15953
  return {
15755
15954
  type: "ConditionFragment",
15756
- children: pattern
15955
+ children: [binding, rhs],
15956
+ binding,
15957
+ rhs
15757
15958
  };
15758
15959
  });
15759
15960
  var PatternExpression$$ = [PatternExpression$0, PatternExpression$1];
@@ -15865,31 +16066,31 @@ var FinallyClause$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(Finally, (0, impo
15865
16066
  function FinallyClause(ctx, state2) {
15866
16067
  return (0, import_lib2.$EVENT)(ctx, state2, "FinallyClause", FinallyClause$0);
15867
16068
  }
15868
- var CatchParameter$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(BindingIdentifier, (0, import_lib2.$E)(TypeSuffix)), function($skip, $loc, $0, $1, $2) {
16069
+ var CatchParameter$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$C)(ObjectBindingPattern, ArrayBindingPattern), TypeSuffix), function($skip, $loc, $0, $1, $2) {
15869
16070
  var binding = $1;
15870
16071
  var typeSuffix = $2;
15871
16072
  return {
15872
16073
  type: "CatchParameter",
15873
16074
  binding,
15874
16075
  typeSuffix,
15875
- children: $0
16076
+ children: [binding, typeSuffix]
16077
+ };
16078
+ });
16079
+ var CatchParameter$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(PatternExpressionList), function($skip, $loc, $0, $1) {
16080
+ return {
16081
+ type: "CatchPattern",
16082
+ children: $0,
16083
+ patterns: $1
15876
16084
  };
15877
16085
  });
15878
- var CatchParameter$1 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$C)(ObjectBindingPattern, ArrayBindingPattern), TypeSuffix), function($skip, $loc, $0, $1, $2) {
16086
+ var CatchParameter$2 = (0, import_lib2.$TS)((0, import_lib2.$S)(BindingIdentifier, (0, import_lib2.$E)(TypeSuffix)), function($skip, $loc, $0, $1, $2) {
15879
16087
  var binding = $1;
15880
16088
  var typeSuffix = $2;
15881
16089
  return {
15882
16090
  type: "CatchParameter",
15883
16091
  binding,
15884
16092
  typeSuffix,
15885
- children: [binding, typeSuffix]
15886
- };
15887
- });
15888
- var CatchParameter$2 = (0, import_lib2.$TS)((0, import_lib2.$S)(PatternExpressionList), function($skip, $loc, $0, $1) {
15889
- return {
15890
- type: "CatchPattern",
15891
- children: $0,
15892
- patterns: $1
16093
+ children: $0
15893
16094
  };
15894
16095
  });
15895
16096
  var CatchParameter$$ = [CatchParameter$0, CatchParameter$1, CatchParameter$2];
@@ -17505,7 +17706,7 @@ var By$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$EXPECT)($L1
17505
17706
  function By(ctx, state2) {
17506
17707
  return (0, import_lib2.$EVENT)(ctx, state2, "By", By$0);
17507
17708
  }
17508
- var Caret$0 = (0, import_lib2.$TV)((0, import_lib2.$EXPECT)($L22, 'Caret "^"'), function($skip, $loc, $0, $1) {
17709
+ var Caret$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$EXPECT)($L22, 'Caret "^"'), (0, import_lib2.$N)((0, import_lib2.$EXPECT)($L22, 'Caret "^"'))), function($skip, $loc, $0, $1, $2) {
17509
17710
  return { $loc, token: $1 };
17510
17711
  });
17511
17712
  function Caret(ctx, state2) {