@danielx/civet 0.8.12 → 0.8.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/browser.js CHANGED
@@ -38,9 +38,9 @@ var Civet = (() => {
38
38
  ));
39
39
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
40
40
 
41
- // node_modules/@danielx/hera/dist/machine.js
41
+ // node_modules/.pnpm/@danielx+hera@0.8.16/node_modules/@danielx/hera/dist/machine.js
42
42
  var require_machine = __commonJS({
43
- "node_modules/@danielx/hera/dist/machine.js"(exports, module) {
43
+ "node_modules/.pnpm/@danielx+hera@0.8.16/node_modules/@danielx/hera/dist/machine.js"(exports, module) {
44
44
  "use strict";
45
45
  var __defProp2 = Object.defineProperty;
46
46
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
@@ -1873,8 +1873,8 @@ ${body}`;
1873
1873
  ts(": <T>(object: T, prop: PropertyKey) => boolean"),
1874
1874
  " = ({}.constructor",
1875
1875
  asAny,
1876
- ").hasOwn;\n"
1877
- ]]);
1876
+ ").hasOwn"
1877
+ ], ";\n"]);
1878
1878
  },
1879
1879
  is(isRef) {
1880
1880
  state.prelude.push(["", [
@@ -1883,9 +1883,8 @@ ${body}`;
1883
1883
  isRef,
1884
1884
  ts(": { <B, A extends B> (a: A, b: B): b is A, <A, B> (a: A, b: B): a is A & B }"),
1885
1885
  " = Object.is",
1886
- asAny,
1887
- ";\n"
1888
- ]]);
1886
+ asAny
1887
+ ], ";\n"]);
1889
1888
  },
1890
1889
  /**
1891
1890
  * Array length check with type guard.
@@ -1903,8 +1902,11 @@ ${body}`;
1903
1902
  },
1904
1903
  rslice(rsliceRef) {
1905
1904
  const RSliceable = makeRef("RSliceable");
1905
+ state.prelude.push([
1906
+ "",
1907
+ ts(["type ", RSliceable, "<R> = string | {length: number; slice(start: number, end: number): {reverse(): R}}\n"])
1908
+ ]);
1906
1909
  state.prelude.push(["", [
1907
- ts(["type ", RSliceable, "<R> = string | {length: number; slice(start: number, end: number): {reverse(): R}}\n"]),
1908
1910
  preludeVar,
1909
1911
  rsliceRef,
1910
1912
  ts([": <R, T extends string | ", RSliceable, "<R>>(a: T, start?: number, end?: number) => T extends string ? string : T extends ", RSliceable, "<infer R> ? R : never"]),
@@ -1923,8 +1925,8 @@ ${body}`;
1923
1925
  " } else {\n",
1924
1926
  " return a.slice(end, start + 1).reverse()\n",
1925
1927
  " }\n",
1926
- "});\n"
1927
- ]]);
1928
+ "})"
1929
+ ], ";\n"]);
1928
1930
  },
1929
1931
  div(divRef) {
1930
1932
  state.prelude.push(["", [
@@ -1932,8 +1934,8 @@ ${body}`;
1932
1934
  preludeVar,
1933
1935
  divRef,
1934
1936
  ts(": (a: number, b: number) => number"),
1935
- " = (a, b) => Math.floor(a / b);\n"
1936
- ]]);
1937
+ " = (a, b) => Math.floor(a / b)"
1938
+ ], ";\n"]);
1937
1939
  },
1938
1940
  modulo(moduloRef) {
1939
1941
  state.prelude.push(["", [
@@ -1941,14 +1943,15 @@ ${body}`;
1941
1943
  preludeVar,
1942
1944
  moduloRef,
1943
1945
  ts(": (a: number, b: number) => number"),
1944
- " = (a, b) => (a % b + b) % b;\n"
1945
- ]]);
1946
+ " = (a, b) => (a % b + b) % b"
1947
+ ], ";\n"]);
1946
1948
  },
1947
1949
  Falsy(FalsyRef) {
1948
1950
  state.prelude.push([
1949
1951
  "",
1950
1952
  // [indent, statement]
1951
- ts(["type ", FalsyRef, " = false | 0 | '' | 0n | null | undefined;\n"])
1953
+ ts(["type ", FalsyRef, " = false | 0 | '' | 0n | null | undefined"]),
1954
+ ";\n"
1952
1955
  ]);
1953
1956
  },
1954
1957
  xor(xorRef) {
@@ -1969,9 +1972,8 @@ ${body}`;
1969
1972
  " extends never ? never : A))"
1970
1973
  ]),
1971
1974
  " = (a, b) => (a ? !b && a : b)",
1972
- asAny,
1973
- ";\n"
1974
- ]]);
1975
+ asAny
1976
+ ], ";\n"]);
1975
1977
  },
1976
1978
  xnor(xnorRef) {
1977
1979
  const Falsy = getHelperRef("Falsy");
@@ -1989,9 +1991,8 @@ ${body}`;
1989
1991
  " ? never : B))"
1990
1992
  ]),
1991
1993
  " = (a, b) => (a ? b : !b || a)",
1992
- asAny,
1993
- ";\n"
1994
- ]]);
1994
+ asAny
1995
+ ], ";\n"]);
1995
1996
  },
1996
1997
  concatAssign(ref) {
1997
1998
  state.prelude.push(["", [
@@ -2009,8 +2010,8 @@ ${body}`;
2009
2010
  asAny,
2010
2011
  ") : (lhs",
2011
2012
  asAny,
2012
- ").push(rhs), lhs);\n"
2013
- ]]);
2013
+ ").push(rhs), lhs)"
2014
+ ], ";\n"]);
2014
2015
  },
2015
2016
  AutoPromise(ref) {
2016
2017
  state.prelude.push([
@@ -3145,6 +3146,8 @@ ${js}`
3145
3146
  }
3146
3147
  }
3147
3148
  })());
3149
+ } else if (statement.object) {
3150
+ declaration.children.push("={}");
3148
3151
  } else {
3149
3152
  if (decl === "const") {
3150
3153
  declaration.children.push("=[]");
@@ -3160,6 +3163,9 @@ ${js}`
3160
3163
  }
3161
3164
  if (!block.empty) {
3162
3165
  assignResults(block, (node) => {
3166
+ if (statement.object) {
3167
+ return ["Object.assign(", resultsRef, ",", node, ")"];
3168
+ }
3163
3169
  if (!reduction) {
3164
3170
  return [resultsRef, ".push(", node, ")"];
3165
3171
  }
@@ -4718,7 +4724,7 @@ ${js}`
4718
4724
  const simple = ref === expression;
4719
4725
  let children;
4720
4726
  if (simple) {
4721
- ref = insertTrimmingSpace(ref, "");
4727
+ ref = trimFirstSpace(ref);
4722
4728
  children = [ref];
4723
4729
  } else {
4724
4730
  children = [ref, initializer];
@@ -4764,8 +4770,8 @@ ${js}`
4764
4770
  return;
4765
4771
  }
4766
4772
  let { expression } = condition;
4767
- if (expression && typeof expression === "object" && "type" in expression && expression.type === "UnaryExpression" && "children" in expression && Array.isArray(expression.children) && len2(expression.children, 2) && expression.children[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]) {
4768
- const { type: type1, children: [, { type: type2, expression: expression2 }] } = expression;
4773
+ 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]) {
4774
+ const { type: type1, children: [[], { type: type2, expression: expression2 }] } = expression;
4769
4775
  const type = [type1, type2];
4770
4776
  expression = expression2;
4771
4777
  }
@@ -4784,7 +4790,7 @@ ${js}`
4784
4790
  let children = condition.children;
4785
4791
  if (s.negated) {
4786
4792
  let m;
4787
- 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) && m.children[0] === "!" && typeof m.children[1] === "object" && m.children[1] != null && "type" in m.children[1] && m.children[1].type === "ParenthesizedExpression")) {
4793
+ 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")) {
4788
4794
  throw new Error("Unsupported negated condition");
4789
4795
  }
4790
4796
  ;
@@ -4908,9 +4914,12 @@ ${js}`
4908
4914
  }
4909
4915
  function dynamizeFromClause(from) {
4910
4916
  from = from.slice(1);
4911
- from = insertTrimmingSpace(from, "");
4912
- if (from[from.length - 1]?.type === "ImportAssertion") {
4913
- const assert2 = from.pop();
4917
+ from = trimFirstSpace(from);
4918
+ let ref2;
4919
+ if (ref2 = from[from.length - 1]?.assertion) {
4920
+ const assert2 = ref2;
4921
+ let ref3;
4922
+ ref3 = from[from.length - 1], ref3.children = ref3.children.filter((a2) => a2 !== assert2);
4914
4923
  from.push(", {", assert2.keyword, ":", assert2.object, "}");
4915
4924
  }
4916
4925
  return ["(", ...from, ")"];
@@ -4919,20 +4928,20 @@ ${js}`
4919
4928
  const { imports } = decl;
4920
4929
  let { star, binding, specifiers } = imports;
4921
4930
  const justDefault = binding && !specifiers && !star;
4922
- let ref2;
4931
+ let ref4;
4923
4932
  {
4924
4933
  if (binding) {
4925
4934
  if (specifiers) {
4926
- ref2 = makeRef();
4935
+ ref4 = makeRef();
4927
4936
  } else {
4928
- ref2 = binding;
4937
+ ref4 = binding;
4929
4938
  }
4930
4939
  } else {
4931
- ref2 = convertNamedImportsToObject(imports, true);
4940
+ ref4 = convertNamedImportsToObject(imports, true);
4932
4941
  }
4933
4942
  }
4934
4943
  ;
4935
- const pattern = ref2;
4944
+ const pattern = ref4;
4936
4945
  const c = "const";
4937
4946
  const expression = [
4938
4947
  justDefault ? "(" : void 0,
@@ -5009,7 +5018,7 @@ ${js}`
5009
5018
  { type: "Await", children: "await" },
5010
5019
  " ",
5011
5020
  imp,
5012
- insertTrimmingSpace(ws2, ""),
5021
+ trimFirstSpace(ws2),
5013
5022
  dynamizeFromClause(from),
5014
5023
  {
5015
5024
  type: "PropertyGlob",
@@ -5085,7 +5094,9 @@ ${js}`
5085
5094
  if (pre.length) {
5086
5095
  return {
5087
5096
  type: "UnaryExpression",
5088
- children: [...pre, exp]
5097
+ children: [pre, exp],
5098
+ pre,
5099
+ expression: exp
5089
5100
  };
5090
5101
  }
5091
5102
  return exp;
@@ -5137,7 +5148,10 @@ ${js}`
5137
5148
  }
5138
5149
  return {
5139
5150
  type: "UnaryExpression",
5140
- children: [...pre, exp, post]
5151
+ children: [pre, exp, post],
5152
+ pre,
5153
+ expression: exp,
5154
+ post
5141
5155
  };
5142
5156
  }
5143
5157
  function processUnaryNestedExpression(pre, args, post) {
@@ -6177,12 +6191,16 @@ ${js}`
6177
6191
  if (i < 0) {
6178
6192
  throw new Error(`Could not find expression in condition`);
6179
6193
  }
6194
+ const pre = ["!"];
6195
+ expression = makeLeftHandSideExpression(expression);
6180
6196
  children[i] = expression = {
6181
6197
  type: "UnaryExpression",
6182
6198
  children: [
6183
- "!",
6184
- makeLeftHandSideExpression(expression)
6185
- ]
6199
+ pre,
6200
+ expression
6201
+ ],
6202
+ pre,
6203
+ expression
6186
6204
  };
6187
6205
  return { ...condition, expression, children };
6188
6206
  }
@@ -6660,19 +6678,23 @@ ${js}`
6660
6678
  assert.notEqual(i, 0, "Index access must be preceded by an expression");
6661
6679
  const prefix = i === 1 ? children[0] : children.slice(0, i);
6662
6680
  const { ref, refAssignment } = maybeRefAssignment(prefix);
6681
+ const args = [
6682
+ glob.children.slice(0 + 1, -1),
6683
+ // between "[" and "]" tokens
6684
+ ",",
6685
+ [" ", ref, ".length"]
6686
+ ];
6663
6687
  const call = makeNode({
6664
6688
  type: "CallExpression",
6689
+ implicit: true,
6665
6690
  children: [
6666
6691
  getHelperRef("modulo"),
6667
6692
  makeNode({
6668
6693
  type: "Call",
6694
+ args,
6669
6695
  children: [
6670
6696
  "(",
6671
- ...glob.children.slice(0 + 1, -1),
6672
- // between "[" and "]" tokens
6673
- ", ",
6674
- ref,
6675
- ".length",
6697
+ args,
6676
6698
  ")"
6677
6699
  ]
6678
6700
  })
@@ -6684,7 +6706,7 @@ ${js}`
6684
6706
  ...node,
6685
6707
  children: [
6686
6708
  makeLeftHandSideExpression(refAssignment ?? prefix),
6687
- {
6709
+ makeNode({
6688
6710
  ...glob,
6689
6711
  mod: false,
6690
6712
  expression: call,
@@ -6695,7 +6717,7 @@ ${js}`
6695
6717
  (ref3 = glob.children)[ref3.length - 1]
6696
6718
  // "]" token
6697
6719
  ]
6698
- },
6720
+ }),
6699
6721
  ...children.slice(i + 1)
6700
6722
  ]
6701
6723
  });
@@ -6745,7 +6767,7 @@ ${js}`
6745
6767
  return [comma, makeExpressionStatement(exp)];
6746
6768
  })
6747
6769
  ];
6748
- } else if (expression?.type === "ObjectExpression" || expression?.type === "FunctionExpression" && !expression.id) {
6770
+ } else if (expression?.type === "ObjectExpression" || expression?.type === "FunctionExpression" && !expression.id || expression?.type === "UnaryExpression" && !expression.pre?.length && expression.expression !== makeExpressionStatement(expression.expression)) {
6749
6771
  return makeLeftHandSideExpression(expression);
6750
6772
  } else {
6751
6773
  return expression;
@@ -7458,12 +7480,12 @@ ${js}`
7458
7480
  } else if (config2.autoVar) {
7459
7481
  createVarDecs(root, []);
7460
7482
  }
7461
- processBlocks(statements);
7462
- populateRefs(statements);
7463
- adjustAtBindings(statements);
7464
7483
  if (config2.repl) {
7465
7484
  processRepl(root, rootIIFE);
7466
7485
  }
7486
+ processBlocks(statements);
7487
+ populateRefs(statements);
7488
+ adjustAtBindings(statements);
7467
7489
  if (getSync()) {
7468
7490
  processComptime(statements);
7469
7491
  }
@@ -7482,7 +7504,11 @@ ${js}`
7482
7504
  }
7483
7505
  if (decl.parent === topBlock || decl.decl === "var") {
7484
7506
  decl.children.shift();
7485
- root.expressions.splice(i++, 0, ["", `var ${decl.names.join(",")};`]);
7507
+ if (decl.bindings[0]?.pattern?.type === "ObjectBindingPattern") {
7508
+ decl.children.unshift("(");
7509
+ decl.children.push(")");
7510
+ }
7511
+ root.expressions.splice(i++, 0, ["", `var ${decl.names.join(",")}`, ";"]);
7486
7512
  }
7487
7513
  }
7488
7514
  for (let ref27 = gatherRecursive(topBlock, ($15) => $15.type === "FunctionExpression"), i10 = 0, len9 = ref27.length; i10 < len9; i10++) {
@@ -7494,7 +7520,7 @@ ${js}`
7494
7520
  func.parent = root;
7495
7521
  } else {
7496
7522
  func.children.unshift(func.name, "=");
7497
- root.expressions.splice(i++, 0, ["", `var ${func.name};`]);
7523
+ root.expressions.splice(i++, 0, ["", `var ${func.name}`, ";"]);
7498
7524
  }
7499
7525
  }
7500
7526
  }
@@ -7503,7 +7529,7 @@ ${js}`
7503
7529
  let m5;
7504
7530
  if (classExp.name && classExp.parent === topBlock || (m5 = classExp.parent, typeof m5 === "object" && m5 != null && "type" in m5 && m5.type === "ReturnStatement" && "parent" in m5 && m5.parent === topBlock)) {
7505
7531
  classExp.children.unshift(classExp.name, "=");
7506
- root.expressions.splice(i++, 0, ["", `var ${classExp.name};`]);
7532
+ root.expressions.splice(i++, 0, ["", `var ${classExp.name}`, ";"]);
7507
7533
  }
7508
7534
  }
7509
7535
  }
@@ -8045,6 +8071,7 @@ ${js}`
8045
8071
  ArrayElementDelimiter,
8046
8072
  ElementListWithIndentedApplicationForbidden,
8047
8073
  ElementList,
8074
+ SingleLineElementList,
8048
8075
  ElementListRest,
8049
8076
  ArrayElementExpression,
8050
8077
  NestedBulletedArray,
@@ -8057,6 +8084,7 @@ ${js}`
8057
8084
  BulletedArrayWithTrailing,
8058
8085
  ObjectLiteral,
8059
8086
  BracedObjectLiteral,
8087
+ SingleLineObjectProperties,
8060
8088
  BracedObjectLiteralContent,
8061
8089
  NestedImplicitObjectLiteral,
8062
8090
  NestedImplicitPropertyDefinitions,
@@ -8337,6 +8365,7 @@ ${js}`
8337
8365
  Dot,
8338
8366
  DotDot,
8339
8367
  DotDotDot,
8368
+ InsertDotDotDot,
8340
8369
  DoubleColon,
8341
8370
  DoubleColonAsColon,
8342
8371
  DoubleQuote,
@@ -8897,7 +8926,7 @@ ${js}`
8897
8926
  var $R12 = (0, import_lib2.$R)(new RegExp("[.\\s]", "suy"));
8898
8927
  var $R13 = (0, import_lib2.$R)(new RegExp("[)}]", "suy"));
8899
8928
  var $R14 = (0, import_lib2.$R)(new RegExp("[+-]", "suy"));
8900
- var $R15 = (0, import_lib2.$R)(new RegExp("\\+\\+|--|[\\+\\-&]\\S", "suy"));
8929
+ var $R15 = (0, import_lib2.$R)(new RegExp("\\+\\+|--|\u29FA|\u2014|[\\+\\-&]\\S", "suy"));
8901
8930
  var $R16 = (0, import_lib2.$R)(new RegExp(`(?=[0-9.'"tfyno])`, "suy"));
8902
8931
  var $R17 = (0, import_lib2.$R)(new RegExp("(?=true|false|yes|no|on|off)", "suy"));
8903
8932
  var $R18 = (0, import_lib2.$R)(new RegExp("(?=\\p{ID_Start}|[_$])", "suy"));
@@ -9759,9 +9788,7 @@ ${js}`
9759
9788
  }
9760
9789
  var FatArrowBody$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$N)(EOS), (0, import_lib2.$N)((0, import_lib2.$S)((0, import_lib2.$E)(_), ExpressionizedStatement)), NonPipelineExpression, (0, import_lib2.$N)(TrailingDeclaration), (0, import_lib2.$N)(TrailingPipe), (0, import_lib2.$N)(TrailingPostfix), (0, import_lib2.$N)(SemicolonDelimiter)), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7) {
9761
9790
  var exp = $3;
9762
- if (exp.type === "ObjectExpression") {
9763
- exp = makeLeftHandSideExpression(exp);
9764
- }
9791
+ exp = makeExpressionStatement(exp);
9765
9792
  const expressions = [["", exp]];
9766
9793
  return {
9767
9794
  type: "BlockStatement",
@@ -11695,13 +11722,13 @@ ${js}`
11695
11722
  expression: fn
11696
11723
  };
11697
11724
  });
11698
- var FunctionExpression$5 = (0, import_lib2.$TS)((0, import_lib2.$S)(OpenParen, __, (0, import_lib2.$N)((0, import_lib2.$EXPECT)($R15, "FunctionExpression /\\+\\+|--|[\\+\\-&]\\S/")), BinaryOp, __, NonPipelineAssignmentExpression, CloseParen), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7) {
11725
+ var FunctionExpression$5 = (0, import_lib2.$TS)((0, import_lib2.$S)(OpenParen, __, (0, import_lib2.$N)((0, import_lib2.$EXPECT)($R15, "FunctionExpression /\\+\\+|--|\u29FA|\u2014|[\\+\\-&]\\S/")), (0, import_lib2.$N)((0, import_lib2.$S)(Placeholder, (0, import_lib2.$C)(TypePostfix, BinaryOpRHS))), BinaryOp, __, NonPipelineAssignmentExpression, CloseParen), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8) {
11699
11726
  var open = $1;
11700
11727
  var ws1 = $2;
11701
- var op = $4;
11702
- var ws2 = $5;
11703
- var rhs = $6;
11704
- var close = $7;
11728
+ var op = $5;
11729
+ var ws2 = $6;
11730
+ var rhs = $7;
11731
+ var close = $8;
11705
11732
  const refA = makeRef("a");
11706
11733
  const fn = makeAmpersandFunction({
11707
11734
  ref: refA,
@@ -12403,7 +12430,30 @@ ${js}`
12403
12430
  var _ArrayLiteral$0 = (0, import_lib2.$T)((0, import_lib2.$S)(ArrayBindingPattern, UpcomingAssignment), function(value) {
12404
12431
  return value[0];
12405
12432
  });
12406
- var _ArrayLiteral$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(OpenBracket, AllowAll, (0, import_lib2.$E)((0, import_lib2.$S)(ArrayLiteralContent, __, CloseBracket)), RestoreAll), function($skip, $loc, $0, $1, $2, $3, $4) {
12433
+ var _ArrayLiteral$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(OpenBracket, CloseBracket, ApplicationStart, AllowAll, (0, import_lib2.$E)((0, import_lib2.$C)(NestedElementList, SingleLineElementList)), RestoreAll), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
12434
+ var open = $1;
12435
+ var close = $2;
12436
+ var content = $5;
12437
+ if (!content)
12438
+ return $skip;
12439
+ let last = content[content.length - 1];
12440
+ let lastArray = Array.isArray(last) ? last : last.children;
12441
+ if (isComma(lastArray[lastArray.length - 1])) {
12442
+ lastArray = lastArray.slice(0, -1);
12443
+ if (Array.isArray(last)) {
12444
+ last = lastArray;
12445
+ } else {
12446
+ last = { ...last, children: lastArray };
12447
+ }
12448
+ content = [...content.slice(0, -1), last];
12449
+ }
12450
+ return {
12451
+ type: "ArrayExpression",
12452
+ children: [open, ...content, close],
12453
+ names: content.flatMap((c) => c?.names || [])
12454
+ };
12455
+ });
12456
+ var _ArrayLiteral$2 = (0, import_lib2.$TS)((0, import_lib2.$S)(OpenBracket, AllowAll, (0, import_lib2.$E)((0, import_lib2.$S)(ArrayLiteralContent, __, CloseBracket)), RestoreAll), function($skip, $loc, $0, $1, $2, $3, $4) {
12407
12457
  var open = $1;
12408
12458
  if (!$3)
12409
12459
  return $skip;
@@ -12424,8 +12474,8 @@ ${js}`
12424
12474
  names
12425
12475
  };
12426
12476
  });
12427
- var _ArrayLiteral$2 = NestedBulletedArray;
12428
- var _ArrayLiteral$$ = [_ArrayLiteral$0, _ArrayLiteral$1, _ArrayLiteral$2];
12477
+ var _ArrayLiteral$3 = NestedBulletedArray;
12478
+ var _ArrayLiteral$$ = [_ArrayLiteral$0, _ArrayLiteral$1, _ArrayLiteral$2, _ArrayLiteral$3];
12429
12479
  function _ArrayLiteral(ctx, state2) {
12430
12480
  return (0, import_lib2.$EVENT_C)(ctx, state2, "_ArrayLiteral", _ArrayLiteral$$);
12431
12481
  }
@@ -12598,7 +12648,12 @@ ${js}`
12598
12648
  var ElementList$0 = (0, import_lib2.$T)((0, import_lib2.$S)(BulletedArray), function(value) {
12599
12649
  return [value[0]];
12600
12650
  });
12601
- var ElementList$1 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$N)(EOS), ArrayElementExpression, (0, import_lib2.$Q)(ElementListRest)), function($skip, $loc, $0, $1, $2, $3) {
12651
+ var ElementList$1 = SingleLineElementList;
12652
+ var ElementList$$ = [ElementList$0, ElementList$1];
12653
+ function ElementList(ctx, state2) {
12654
+ return (0, import_lib2.$EVENT_C)(ctx, state2, "ElementList", ElementList$$);
12655
+ }
12656
+ var SingleLineElementList$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$N)(EOS), ArrayElementExpression, (0, import_lib2.$Q)(ElementListRest)), function($skip, $loc, $0, $1, $2, $3) {
12602
12657
  var first = $2;
12603
12658
  var rest = $3;
12604
12659
  if (!rest.length)
@@ -12609,9 +12664,8 @@ ${js}`
12609
12664
  rest.map(([_2, e], i) => append(e, rest[i + 1]?.[0]))
12610
12665
  );
12611
12666
  });
12612
- var ElementList$$ = [ElementList$0, ElementList$1];
12613
- function ElementList(ctx, state2) {
12614
- return (0, import_lib2.$EVENT_C)(ctx, state2, "ElementList", ElementList$$);
12667
+ function SingleLineElementList(ctx, state2) {
12668
+ return (0, import_lib2.$EVENT)(ctx, state2, "SingleLineElementList", SingleLineElementList$0);
12615
12669
  }
12616
12670
  var ElementListRest$0 = (0, import_lib2.$S)((0, import_lib2.$S)((0, import_lib2.$E)(_), Comma, (0, import_lib2.$N)(EOS)), ArrayElementExpression);
12617
12671
  function ElementListRest(ctx, state2) {
@@ -12790,7 +12844,29 @@ ${js}`
12790
12844
  function ObjectLiteral(ctx, state2) {
12791
12845
  return (0, import_lib2.$EVENT_C)(ctx, state2, "ObjectLiteral", ObjectLiteral$$);
12792
12846
  }
12793
- var BracedObjectLiteral$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(OpenBrace, AllowAll, (0, import_lib2.$E)((0, import_lib2.$S)(BracedObjectLiteralContent, __, CloseBrace)), RestoreAll), function($skip, $loc, $0, $1, $2, $3, $4) {
12847
+ var BracedObjectLiteral$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(OpenBrace, CloseBrace, ApplicationStart, AllowAll, (0, import_lib2.$E)((0, import_lib2.$C)(NestedPropertyDefinitions, SingleLineObjectProperties)), RestoreAll), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
12848
+ var open = $1;
12849
+ var close = $2;
12850
+ var properties = $5;
12851
+ if (!properties?.length)
12852
+ return $skip;
12853
+ let last = properties[properties.length - 1];
12854
+ if (last.delim?.implicit) {
12855
+ last = {
12856
+ ...last,
12857
+ delim: void 0,
12858
+ children: last.children.filter((c) => c !== last.delim)
12859
+ };
12860
+ properties = [...properties.slice(0, properties.length - 1), last];
12861
+ }
12862
+ return {
12863
+ type: "ObjectExpression",
12864
+ children: [open, properties, close],
12865
+ names: properties.flatMap((c) => c.names || []),
12866
+ properties
12867
+ };
12868
+ });
12869
+ var BracedObjectLiteral$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(OpenBrace, AllowAll, (0, import_lib2.$E)((0, import_lib2.$S)(BracedObjectLiteralContent, __, CloseBrace)), RestoreAll), function($skip, $loc, $0, $1, $2, $3, $4) {
12794
12870
  var open = $1;
12795
12871
  if (!$3)
12796
12872
  return $skip;
@@ -12802,13 +12878,13 @@ ${js}`
12802
12878
  properties
12803
12879
  };
12804
12880
  });
12881
+ var BracedObjectLiteral$$ = [BracedObjectLiteral$0, BracedObjectLiteral$1];
12805
12882
  function BracedObjectLiteral(ctx, state2) {
12806
- return (0, import_lib2.$EVENT)(ctx, state2, "BracedObjectLiteral", BracedObjectLiteral$0);
12883
+ return (0, import_lib2.$EVENT_C)(ctx, state2, "BracedObjectLiteral", BracedObjectLiteral$$);
12807
12884
  }
12808
- var BracedObjectLiteralContent$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$Q)((0, import_lib2.$S)(PropertyDefinition, ObjectPropertyDelimiter)), (0, import_lib2.$E)(NestedPropertyDefinitions)), function($skip, $loc, $0, $1, $2) {
12809
- var line = $1;
12810
- var nested = $2;
12811
- line = line.flatMap(([prop, delim]) => {
12885
+ var SingleLineObjectProperties$0 = (0, import_lib2.$TV)((0, import_lib2.$Q)((0, import_lib2.$S)(PropertyDefinition, ObjectPropertyDelimiter)), function($skip, $loc, $0, $1) {
12886
+ var line = $0;
12887
+ return line.flatMap(([prop, delim]) => {
12812
12888
  prop = Array.isArray(prop) ? prop : [prop];
12813
12889
  let last = prop[prop.length - 1];
12814
12890
  if (!last)
@@ -12820,6 +12896,13 @@ ${js}`
12820
12896
  };
12821
12897
  return [...prop.slice(0, prop.length - 1), last];
12822
12898
  });
12899
+ });
12900
+ function SingleLineObjectProperties(ctx, state2) {
12901
+ return (0, import_lib2.$EVENT)(ctx, state2, "SingleLineObjectProperties", SingleLineObjectProperties$0);
12902
+ }
12903
+ var BracedObjectLiteralContent$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(SingleLineObjectProperties, (0, import_lib2.$E)(NestedPropertyDefinitions)), function($skip, $loc, $0, $1, $2) {
12904
+ var line = $1;
12905
+ var nested = $2;
12823
12906
  return line.concat(nested || []);
12824
12907
  });
12825
12908
  var BracedObjectLiteralContent$1 = (0, import_lib2.$TV)((0, import_lib2.$P)((0, import_lib2.$S)(__, PropertyDefinition, ObjectPropertyDelimiter)), function($skip, $loc, $0, $1) {
@@ -12951,19 +13034,48 @@ ${js}`
12951
13034
  }
12952
13035
  var ObjectPropertyDelimiter$0 = (0, import_lib2.$S)((0, import_lib2.$E)(_), Comma);
12953
13036
  var ObjectPropertyDelimiter$1 = (0, import_lib2.$Y)((0, import_lib2.$S)(__, (0, import_lib2.$EXPECT)($L37, 'ObjectPropertyDelimiter "}"')));
12954
- var ObjectPropertyDelimiter$2 = (0, import_lib2.$T)((0, import_lib2.$S)((0, import_lib2.$Y)(EOS), InsertComma), function(value) {
12955
- return value[1];
13037
+ var ObjectPropertyDelimiter$2 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$Y)(EOS), InsertComma), function($skip, $loc, $0, $1, $2) {
13038
+ return { ...$2, implicit: true };
12956
13039
  });
12957
13040
  var ObjectPropertyDelimiter$$ = [ObjectPropertyDelimiter$0, ObjectPropertyDelimiter$1, ObjectPropertyDelimiter$2];
12958
13041
  function ObjectPropertyDelimiter(ctx, state2) {
12959
13042
  return (0, import_lib2.$EVENT_C)(ctx, state2, "ObjectPropertyDelimiter", ObjectPropertyDelimiter$$);
12960
13043
  }
12961
- var PropertyDefinition$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), NamedProperty), function($skip, $loc, $0, $1, $2) {
13044
+ var PropertyDefinition$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), InsertDotDotDot, IterationExpression), function($skip, $loc, $0, $1, $2, $3) {
13045
+ var ws = $1;
13046
+ var dots = $2;
13047
+ var exp = $3;
13048
+ let { statement } = exp;
13049
+ if (exp.block.implicit && (statement.type === "DoStatement" || statement.subtype === "loop")) {
13050
+ return $skip;
13051
+ }
13052
+ statement = { ...statement, object: true };
13053
+ exp = {
13054
+ ...exp,
13055
+ statement,
13056
+ children: exp.children.map(($) => $ === exp.statement ? statement : $)
13057
+ };
13058
+ const children = [ws, dots, exp];
13059
+ if (statement.reduction) {
13060
+ children.unshift({
13061
+ type: "Error",
13062
+ message: "Reduction loops are forbidden in object literals"
13063
+ });
13064
+ }
13065
+ return {
13066
+ type: "SpreadProperty",
13067
+ children,
13068
+ names: exp.names,
13069
+ dots,
13070
+ value: exp
13071
+ };
13072
+ });
13073
+ var PropertyDefinition$1 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), NamedProperty), function($skip, $loc, $0, $1, $2) {
12962
13074
  var ws = $1;
12963
13075
  var prop = $2;
12964
13076
  return prepend(ws, prop);
12965
13077
  });
12966
- var PropertyDefinition$1 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), (0, import_lib2.$TEXT)((0, import_lib2.$EXPECT)($R24, "PropertyDefinition /[!+-]?/")), PropertyName, (0, import_lib2.$Y)(ObjectPropertyDelimiter)), function($skip, $loc, $0, $1, $2, $3, $4) {
13078
+ var PropertyDefinition$2 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), (0, import_lib2.$TEXT)((0, import_lib2.$EXPECT)($R24, "PropertyDefinition /[!+-]?/")), PropertyName, (0, import_lib2.$Y)(ObjectPropertyDelimiter)), function($skip, $loc, $0, $1, $2, $3, $4) {
12967
13079
  var ws = $1;
12968
13080
  var toggle = $2;
12969
13081
  var id = $3;
@@ -12985,7 +13097,7 @@ ${js}`
12985
13097
  value: id
12986
13098
  };
12987
13099
  });
12988
- var PropertyDefinition$2 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), MethodDefinition), function($skip, $loc, $0, $1, $2) {
13100
+ var PropertyDefinition$3 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), MethodDefinition), function($skip, $loc, $0, $1, $2) {
12989
13101
  var ws = $1;
12990
13102
  var def = $2;
12991
13103
  if (def.type === "MultiMethodDefinition") {
@@ -12997,7 +13109,7 @@ ${js}`
12997
13109
  return $skip;
12998
13110
  return prepend(ws, def);
12999
13111
  });
13000
- var PropertyDefinition$3 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), DotDotDot, Expression), function($skip, $loc, $0, $1, $2, $3) {
13112
+ var PropertyDefinition$4 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), DotDotDot, Expression), function($skip, $loc, $0, $1, $2, $3) {
13001
13113
  var ws = $1;
13002
13114
  var dots = $2;
13003
13115
  var exp = $3;
@@ -13009,7 +13121,7 @@ ${js}`
13009
13121
  value: exp
13010
13122
  };
13011
13123
  });
13012
- var PropertyDefinition$4 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), (0, import_lib2.$N)((0, import_lib2.$C)(EOS, (0, import_lib2.$EXPECT)($L7, 'PropertyDefinition "."'))), (0, import_lib2.$Q)(UnaryOp), CallExpression, (0, import_lib2.$E)(UnaryPostfix)), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
13124
+ var PropertyDefinition$5 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), (0, import_lib2.$N)((0, import_lib2.$C)(EOS, (0, import_lib2.$EXPECT)($L7, 'PropertyDefinition "."'))), (0, import_lib2.$Q)(UnaryOp), CallExpression, (0, import_lib2.$E)(UnaryPostfix)), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
13013
13125
  var ws = $1;
13014
13126
  var pre = $3;
13015
13127
  var value = $4;
@@ -13074,7 +13186,7 @@ ${js}`
13074
13186
  value
13075
13187
  };
13076
13188
  });
13077
- var PropertyDefinition$$ = [PropertyDefinition$0, PropertyDefinition$1, PropertyDefinition$2, PropertyDefinition$3, PropertyDefinition$4];
13189
+ var PropertyDefinition$$ = [PropertyDefinition$0, PropertyDefinition$1, PropertyDefinition$2, PropertyDefinition$3, PropertyDefinition$4, PropertyDefinition$5];
13078
13190
  function PropertyDefinition(ctx, state2) {
13079
13191
  return (0, import_lib2.$EVENT_C)(ctx, state2, "PropertyDefinition", PropertyDefinition$$);
13080
13192
  }
@@ -15731,8 +15843,9 @@ ${js}`
15731
15843
  return (0, import_lib2.$EVENT_C)(ctx, state2, "ModuleExportName", ModuleExportName$$);
15732
15844
  }
15733
15845
  var ModuleSpecifier$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(UnprocessedModuleSpecifier, (0, import_lib2.$E)(ImportAssertion)), function($skip, $loc, $0, $1, $2) {
15734
- var a = $2;
15735
- let { token } = $1;
15846
+ var module = $1;
15847
+ var assertion = $2;
15848
+ let { token } = module;
15736
15849
  if (config.rewriteTsImports) {
15737
15850
  token = token.replace(/\.([mc])?ts(['"])$/, ".$1js$2");
15738
15851
  }
@@ -15742,9 +15855,15 @@ ${js}`
15742
15855
  `${config.rewriteCivetImports.replace(/\$/g, "$$")}$1`
15743
15856
  );
15744
15857
  }
15745
- if (a)
15746
- return [{ ...$1, token }, a];
15747
- return { ...$1, token };
15858
+ if (token !== module.token) {
15859
+ module = { ...module, token, input: module.token };
15860
+ }
15861
+ return {
15862
+ type: "ModuleSpecifier",
15863
+ module,
15864
+ assertion,
15865
+ children: [module, assertion]
15866
+ };
15748
15867
  });
15749
15868
  function ModuleSpecifier(ctx, state2) {
15750
15869
  return (0, import_lib2.$EVENT)(ctx, state2, "ModuleSpecifier", ModuleSpecifier$0);
@@ -16048,7 +16167,7 @@ ${js}`
16048
16167
  function DecimalBigIntegerLiteral(ctx, state2) {
16049
16168
  return (0, import_lib2.$EVENT)(ctx, state2, "DecimalBigIntegerLiteral", DecimalBigIntegerLiteral$0);
16050
16169
  }
16051
- var DecimalLiteral$0 = (0, import_lib2.$TV)((0, import_lib2.$TEXT)((0, import_lib2.$EXPECT)($R36, "DecimalLiteral /(?:0|[1-9](?:_[0-9]|[0-9])*)(?=\\.(?:\\p{ID_Start}|[_$]))/")), function($skip, $loc, $0, $1) {
16170
+ var DecimalLiteral$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$TEXT)((0, import_lib2.$EXPECT)($R36, "DecimalLiteral /(?:0|[1-9](?:_[0-9]|[0-9])*)(?=\\.(?:\\p{ID_Start}|[_$]))/")), (0, import_lib2.$N)((0, import_lib2.$S)((0, import_lib2.$EXPECT)($L7, 'DecimalLiteral "."'), ExponentPart))), function($skip, $loc, $0, $1, $2) {
16052
16171
  return $1 + ".";
16053
16172
  });
16054
16173
  var DecimalLiteral$1 = (0, import_lib2.$TEXT)((0, import_lib2.$S)((0, import_lib2.$EXPECT)($R37, "DecimalLiteral /(?:0|[1-9](?:_[0-9]|[0-9])*)(?:\\.(?:[0-9](?:_[0-9]|[0-9])*))?/"), (0, import_lib2.$E)(ExponentPart)));
@@ -16687,6 +16806,12 @@ ${js}`
16687
16806
  function DotDotDot(ctx, state2) {
16688
16807
  return (0, import_lib2.$EVENT_C)(ctx, state2, "DotDotDot", DotDotDot$$);
16689
16808
  }
16809
+ var InsertDotDotDot$0 = (0, import_lib2.$TV)((0, import_lib2.$EXPECT)($L0, 'InsertDotDotDot ""'), function($skip, $loc, $0, $1) {
16810
+ return { $loc, token: "..." };
16811
+ });
16812
+ function InsertDotDotDot(ctx, state2) {
16813
+ return (0, import_lib2.$EVENT)(ctx, state2, "InsertDotDotDot", InsertDotDotDot$0);
16814
+ }
16690
16815
  var DoubleColon$0 = (0, import_lib2.$TV)((0, import_lib2.$EXPECT)($L162, 'DoubleColon "::"'), function($skip, $loc, $0, $1) {
16691
16816
  return { $loc, token: $1 };
16692
16817
  });