@danielx/civet 0.8.13 → 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/main.js CHANGED
@@ -30,9 +30,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
30
30
  ));
31
31
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
32
 
33
- // node_modules/@danielx/hera/dist/machine.js
33
+ // node_modules/.pnpm/@danielx+hera@0.8.16/node_modules/@danielx/hera/dist/machine.js
34
34
  var require_machine = __commonJS({
35
- "node_modules/@danielx/hera/dist/machine.js"(exports2, module2) {
35
+ "node_modules/.pnpm/@danielx+hera@0.8.16/node_modules/@danielx/hera/dist/machine.js"(exports2, module2) {
36
36
  "use strict";
37
37
  var __defProp2 = Object.defineProperty;
38
38
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
@@ -3122,6 +3122,8 @@ function iterationDeclaration(statement) {
3122
3122
  }
3123
3123
  }
3124
3124
  })());
3125
+ } else if (statement.object) {
3126
+ declaration.children.push("={}");
3125
3127
  } else {
3126
3128
  if (decl === "const") {
3127
3129
  declaration.children.push("=[]");
@@ -3137,6 +3139,9 @@ function iterationDeclaration(statement) {
3137
3139
  }
3138
3140
  if (!block.empty) {
3139
3141
  assignResults(block, (node) => {
3142
+ if (statement.object) {
3143
+ return ["Object.assign(", resultsRef, ",", node, ")"];
3144
+ }
3140
3145
  if (!reduction) {
3141
3146
  return [resultsRef, ".push(", node, ")"];
3142
3147
  }
@@ -4741,8 +4746,8 @@ function processDeclarationConditionStatement(s) {
4741
4746
  return;
4742
4747
  }
4743
4748
  let { expression } = condition;
4744
- 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]) {
4745
- const { type: type1, children: [, { type: type2, expression: expression2 }] } = expression;
4749
+ 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]) {
4750
+ const { type: type1, children: [[], { type: type2, expression: expression2 }] } = expression;
4746
4751
  const type = [type1, type2];
4747
4752
  expression = expression2;
4748
4753
  }
@@ -4761,7 +4766,7 @@ function processDeclarationConditionStatement(s) {
4761
4766
  let children = condition.children;
4762
4767
  if (s.negated) {
4763
4768
  let m;
4764
- 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")) {
4769
+ 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")) {
4765
4770
  throw new Error("Unsupported negated condition");
4766
4771
  }
4767
4772
  ;
@@ -5065,7 +5070,9 @@ function processUnaryExpression(pre, exp, post) {
5065
5070
  if (pre.length) {
5066
5071
  return {
5067
5072
  type: "UnaryExpression",
5068
- children: [...pre, exp]
5073
+ children: [pre, exp],
5074
+ pre,
5075
+ expression: exp
5069
5076
  };
5070
5077
  }
5071
5078
  return exp;
@@ -5117,7 +5124,10 @@ function processUnaryExpression(pre, exp, post) {
5117
5124
  }
5118
5125
  return {
5119
5126
  type: "UnaryExpression",
5120
- children: [...pre, exp, post]
5127
+ children: [pre, exp, post],
5128
+ pre,
5129
+ expression: exp,
5130
+ post
5121
5131
  };
5122
5132
  }
5123
5133
  function processUnaryNestedExpression(pre, args, post) {
@@ -6157,12 +6167,16 @@ function negateCondition(condition) {
6157
6167
  if (i < 0) {
6158
6168
  throw new Error(`Could not find expression in condition`);
6159
6169
  }
6170
+ const pre = ["!"];
6171
+ expression = makeLeftHandSideExpression(expression);
6160
6172
  children[i] = expression = {
6161
6173
  type: "UnaryExpression",
6162
6174
  children: [
6163
- "!",
6164
- makeLeftHandSideExpression(expression)
6165
- ]
6175
+ pre,
6176
+ expression
6177
+ ],
6178
+ pre,
6179
+ expression
6166
6180
  };
6167
6181
  return { ...condition, expression, children };
6168
6182
  }
@@ -6729,7 +6743,7 @@ function makeExpressionStatement(expression) {
6729
6743
  return [comma, makeExpressionStatement(exp)];
6730
6744
  })
6731
6745
  ];
6732
- } else if (expression?.type === "ObjectExpression" || expression?.type === "FunctionExpression" && !expression.id) {
6746
+ } else if (expression?.type === "ObjectExpression" || expression?.type === "FunctionExpression" && !expression.id || expression?.type === "UnaryExpression" && !expression.pre?.length && expression.expression !== makeExpressionStatement(expression.expression)) {
6733
6747
  return makeLeftHandSideExpression(expression);
6734
6748
  } else {
6735
6749
  return expression;
@@ -7442,12 +7456,12 @@ function processProgram(root) {
7442
7456
  } else if (config2.autoVar) {
7443
7457
  createVarDecs(root, []);
7444
7458
  }
7445
- processBlocks(statements);
7446
- populateRefs(statements);
7447
- adjustAtBindings(statements);
7448
7459
  if (config2.repl) {
7449
7460
  processRepl(root, rootIIFE);
7450
7461
  }
7462
+ processBlocks(statements);
7463
+ populateRefs(statements);
7464
+ adjustAtBindings(statements);
7451
7465
  if (getSync()) {
7452
7466
  processComptime(statements);
7453
7467
  }
@@ -7466,7 +7480,11 @@ function processRepl(root, rootIIFE) {
7466
7480
  }
7467
7481
  if (decl.parent === topBlock || decl.decl === "var") {
7468
7482
  decl.children.shift();
7469
- root.expressions.splice(i++, 0, ["", `var ${decl.names.join(",")};`]);
7483
+ if (decl.bindings[0]?.pattern?.type === "ObjectBindingPattern") {
7484
+ decl.children.unshift("(");
7485
+ decl.children.push(")");
7486
+ }
7487
+ root.expressions.splice(i++, 0, ["", `var ${decl.names.join(",")}`, ";"]);
7470
7488
  }
7471
7489
  }
7472
7490
  for (let ref27 = gatherRecursive(topBlock, ($15) => $15.type === "FunctionExpression"), i10 = 0, len9 = ref27.length; i10 < len9; i10++) {
@@ -7478,7 +7496,7 @@ function processRepl(root, rootIIFE) {
7478
7496
  func.parent = root;
7479
7497
  } else {
7480
7498
  func.children.unshift(func.name, "=");
7481
- root.expressions.splice(i++, 0, ["", `var ${func.name};`]);
7499
+ root.expressions.splice(i++, 0, ["", `var ${func.name}`, ";"]);
7482
7500
  }
7483
7501
  }
7484
7502
  }
@@ -7487,7 +7505,7 @@ function processRepl(root, rootIIFE) {
7487
7505
  let m5;
7488
7506
  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)) {
7489
7507
  classExp.children.unshift(classExp.name, "=");
7490
- root.expressions.splice(i++, 0, ["", `var ${classExp.name};`]);
7508
+ root.expressions.splice(i++, 0, ["", `var ${classExp.name}`, ";"]);
7491
7509
  }
7492
7510
  }
7493
7511
  }
@@ -8323,6 +8341,7 @@ var grammar = {
8323
8341
  Dot,
8324
8342
  DotDot,
8325
8343
  DotDotDot,
8344
+ InsertDotDotDot,
8326
8345
  DoubleColon,
8327
8346
  DoubleColonAsColon,
8328
8347
  DoubleQuote,
@@ -8883,7 +8902,7 @@ var $R11 = (0, import_lib2.$R)(new RegExp("%%?", "suy"));
8883
8902
  var $R12 = (0, import_lib2.$R)(new RegExp("[.\\s]", "suy"));
8884
8903
  var $R13 = (0, import_lib2.$R)(new RegExp("[)}]", "suy"));
8885
8904
  var $R14 = (0, import_lib2.$R)(new RegExp("[+-]", "suy"));
8886
- var $R15 = (0, import_lib2.$R)(new RegExp("\\+\\+|--|[\\+\\-&]\\S", "suy"));
8905
+ var $R15 = (0, import_lib2.$R)(new RegExp("\\+\\+|--|\u29FA|\u2014|[\\+\\-&]\\S", "suy"));
8887
8906
  var $R16 = (0, import_lib2.$R)(new RegExp(`(?=[0-9.'"tfyno])`, "suy"));
8888
8907
  var $R17 = (0, import_lib2.$R)(new RegExp("(?=true|false|yes|no|on|off)", "suy"));
8889
8908
  var $R18 = (0, import_lib2.$R)(new RegExp("(?=\\p{ID_Start}|[_$])", "suy"));
@@ -9745,9 +9764,7 @@ function TrailingPostfix(ctx, state2) {
9745
9764
  }
9746
9765
  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) {
9747
9766
  var exp = $3;
9748
- if (exp.type === "ObjectExpression") {
9749
- exp = makeLeftHandSideExpression(exp);
9750
- }
9767
+ exp = makeExpressionStatement(exp);
9751
9768
  const expressions = [["", exp]];
9752
9769
  return {
9753
9770
  type: "BlockStatement",
@@ -11681,7 +11698,7 @@ var FunctionExpression$4 = (0, import_lib2.$TS)((0, import_lib2.$S)(OpenParen, _
11681
11698
  expression: fn
11682
11699
  };
11683
11700
  });
11684
- var FunctionExpression$5 = (0, import_lib2.$TS)((0, import_lib2.$S)(OpenParen, __, (0, import_lib2.$N)((0, import_lib2.$EXPECT)($R15, "FunctionExpression /\\+\\+|--|[\\+\\-&]\\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) {
11701
+ 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) {
11685
11702
  var open = $1;
11686
11703
  var ws1 = $2;
11687
11704
  var op = $5;
@@ -13000,12 +13017,41 @@ var ObjectPropertyDelimiter$$ = [ObjectPropertyDelimiter$0, ObjectPropertyDelimi
13000
13017
  function ObjectPropertyDelimiter(ctx, state2) {
13001
13018
  return (0, import_lib2.$EVENT_C)(ctx, state2, "ObjectPropertyDelimiter", ObjectPropertyDelimiter$$);
13002
13019
  }
13003
- var PropertyDefinition$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), NamedProperty), function($skip, $loc, $0, $1, $2) {
13020
+ var PropertyDefinition$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), InsertDotDotDot, IterationExpression), function($skip, $loc, $0, $1, $2, $3) {
13021
+ var ws = $1;
13022
+ var dots = $2;
13023
+ var exp = $3;
13024
+ let { statement } = exp;
13025
+ if (exp.block.implicit && (statement.type === "DoStatement" || statement.subtype === "loop")) {
13026
+ return $skip;
13027
+ }
13028
+ statement = { ...statement, object: true };
13029
+ exp = {
13030
+ ...exp,
13031
+ statement,
13032
+ children: exp.children.map(($) => $ === exp.statement ? statement : $)
13033
+ };
13034
+ const children = [ws, dots, exp];
13035
+ if (statement.reduction) {
13036
+ children.unshift({
13037
+ type: "Error",
13038
+ message: "Reduction loops are forbidden in object literals"
13039
+ });
13040
+ }
13041
+ return {
13042
+ type: "SpreadProperty",
13043
+ children,
13044
+ names: exp.names,
13045
+ dots,
13046
+ value: exp
13047
+ };
13048
+ });
13049
+ var PropertyDefinition$1 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), NamedProperty), function($skip, $loc, $0, $1, $2) {
13004
13050
  var ws = $1;
13005
13051
  var prop = $2;
13006
13052
  return prepend(ws, prop);
13007
13053
  });
13008
- 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) {
13054
+ 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) {
13009
13055
  var ws = $1;
13010
13056
  var toggle = $2;
13011
13057
  var id = $3;
@@ -13027,7 +13073,7 @@ var PropertyDefinition$1 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_l
13027
13073
  value: id
13028
13074
  };
13029
13075
  });
13030
- var PropertyDefinition$2 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), MethodDefinition), function($skip, $loc, $0, $1, $2) {
13076
+ var PropertyDefinition$3 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), MethodDefinition), function($skip, $loc, $0, $1, $2) {
13031
13077
  var ws = $1;
13032
13078
  var def = $2;
13033
13079
  if (def.type === "MultiMethodDefinition") {
@@ -13039,7 +13085,7 @@ var PropertyDefinition$2 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_l
13039
13085
  return $skip;
13040
13086
  return prepend(ws, def);
13041
13087
  });
13042
- var PropertyDefinition$3 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), DotDotDot, Expression), function($skip, $loc, $0, $1, $2, $3) {
13088
+ var PropertyDefinition$4 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), DotDotDot, Expression), function($skip, $loc, $0, $1, $2, $3) {
13043
13089
  var ws = $1;
13044
13090
  var dots = $2;
13045
13091
  var exp = $3;
@@ -13051,7 +13097,7 @@ var PropertyDefinition$3 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_l
13051
13097
  value: exp
13052
13098
  };
13053
13099
  });
13054
- 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) {
13100
+ 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) {
13055
13101
  var ws = $1;
13056
13102
  var pre = $3;
13057
13103
  var value = $4;
@@ -13116,7 +13162,7 @@ var PropertyDefinition$4 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_l
13116
13162
  value
13117
13163
  };
13118
13164
  });
13119
- var PropertyDefinition$$ = [PropertyDefinition$0, PropertyDefinition$1, PropertyDefinition$2, PropertyDefinition$3, PropertyDefinition$4];
13165
+ var PropertyDefinition$$ = [PropertyDefinition$0, PropertyDefinition$1, PropertyDefinition$2, PropertyDefinition$3, PropertyDefinition$4, PropertyDefinition$5];
13120
13166
  function PropertyDefinition(ctx, state2) {
13121
13167
  return (0, import_lib2.$EVENT_C)(ctx, state2, "PropertyDefinition", PropertyDefinition$$);
13122
13168
  }
@@ -16097,7 +16143,7 @@ var DecimalBigIntegerLiteral$0 = (0, import_lib2.$R$0)((0, import_lib2.$EXPECT)(
16097
16143
  function DecimalBigIntegerLiteral(ctx, state2) {
16098
16144
  return (0, import_lib2.$EVENT)(ctx, state2, "DecimalBigIntegerLiteral", DecimalBigIntegerLiteral$0);
16099
16145
  }
16100
- 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) {
16146
+ 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) {
16101
16147
  return $1 + ".";
16102
16148
  });
16103
16149
  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)));
@@ -16736,6 +16782,12 @@ var DotDotDot$$ = [DotDotDot$0, DotDotDot$1];
16736
16782
  function DotDotDot(ctx, state2) {
16737
16783
  return (0, import_lib2.$EVENT_C)(ctx, state2, "DotDotDot", DotDotDot$$);
16738
16784
  }
16785
+ var InsertDotDotDot$0 = (0, import_lib2.$TV)((0, import_lib2.$EXPECT)($L0, 'InsertDotDotDot ""'), function($skip, $loc, $0, $1) {
16786
+ return { $loc, token: "..." };
16787
+ });
16788
+ function InsertDotDotDot(ctx, state2) {
16789
+ return (0, import_lib2.$EVENT)(ctx, state2, "InsertDotDotDot", InsertDotDotDot$0);
16790
+ }
16739
16791
  var DoubleColon$0 = (0, import_lib2.$TV)((0, import_lib2.$EXPECT)($L162, 'DoubleColon "::"'), function($skip, $loc, $0, $1) {
16740
16792
  return { $loc, token: $1 };
16741
16793
  });
package/dist/main.mjs CHANGED
@@ -28,9 +28,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  mod
29
29
  ));
30
30
 
31
- // node_modules/@danielx/hera/dist/machine.js
31
+ // node_modules/.pnpm/@danielx+hera@0.8.16/node_modules/@danielx/hera/dist/machine.js
32
32
  var require_machine = __commonJS({
33
- "node_modules/@danielx/hera/dist/machine.js"(exports, module) {
33
+ "node_modules/.pnpm/@danielx+hera@0.8.16/node_modules/@danielx/hera/dist/machine.js"(exports, module) {
34
34
  "use strict";
35
35
  var __defProp2 = Object.defineProperty;
36
36
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
@@ -3102,6 +3102,8 @@ function iterationDeclaration(statement) {
3102
3102
  }
3103
3103
  }
3104
3104
  })());
3105
+ } else if (statement.object) {
3106
+ declaration.children.push("={}");
3105
3107
  } else {
3106
3108
  if (decl === "const") {
3107
3109
  declaration.children.push("=[]");
@@ -3117,6 +3119,9 @@ function iterationDeclaration(statement) {
3117
3119
  }
3118
3120
  if (!block.empty) {
3119
3121
  assignResults(block, (node) => {
3122
+ if (statement.object) {
3123
+ return ["Object.assign(", resultsRef, ",", node, ")"];
3124
+ }
3120
3125
  if (!reduction) {
3121
3126
  return [resultsRef, ".push(", node, ")"];
3122
3127
  }
@@ -4721,8 +4726,8 @@ function processDeclarationConditionStatement(s) {
4721
4726
  return;
4722
4727
  }
4723
4728
  let { expression } = condition;
4724
- 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]) {
4725
- const { type: type1, children: [, { type: type2, expression: expression2 }] } = expression;
4729
+ 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]) {
4730
+ const { type: type1, children: [[], { type: type2, expression: expression2 }] } = expression;
4726
4731
  const type = [type1, type2];
4727
4732
  expression = expression2;
4728
4733
  }
@@ -4741,7 +4746,7 @@ function processDeclarationConditionStatement(s) {
4741
4746
  let children = condition.children;
4742
4747
  if (s.negated) {
4743
4748
  let m;
4744
- 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")) {
4749
+ 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")) {
4745
4750
  throw new Error("Unsupported negated condition");
4746
4751
  }
4747
4752
  ;
@@ -5045,7 +5050,9 @@ function processUnaryExpression(pre, exp, post) {
5045
5050
  if (pre.length) {
5046
5051
  return {
5047
5052
  type: "UnaryExpression",
5048
- children: [...pre, exp]
5053
+ children: [pre, exp],
5054
+ pre,
5055
+ expression: exp
5049
5056
  };
5050
5057
  }
5051
5058
  return exp;
@@ -5097,7 +5104,10 @@ function processUnaryExpression(pre, exp, post) {
5097
5104
  }
5098
5105
  return {
5099
5106
  type: "UnaryExpression",
5100
- children: [...pre, exp, post]
5107
+ children: [pre, exp, post],
5108
+ pre,
5109
+ expression: exp,
5110
+ post
5101
5111
  };
5102
5112
  }
5103
5113
  function processUnaryNestedExpression(pre, args, post) {
@@ -6137,12 +6147,16 @@ function negateCondition(condition) {
6137
6147
  if (i < 0) {
6138
6148
  throw new Error(`Could not find expression in condition`);
6139
6149
  }
6150
+ const pre = ["!"];
6151
+ expression = makeLeftHandSideExpression(expression);
6140
6152
  children[i] = expression = {
6141
6153
  type: "UnaryExpression",
6142
6154
  children: [
6143
- "!",
6144
- makeLeftHandSideExpression(expression)
6145
- ]
6155
+ pre,
6156
+ expression
6157
+ ],
6158
+ pre,
6159
+ expression
6146
6160
  };
6147
6161
  return { ...condition, expression, children };
6148
6162
  }
@@ -6709,7 +6723,7 @@ function makeExpressionStatement(expression) {
6709
6723
  return [comma, makeExpressionStatement(exp)];
6710
6724
  })
6711
6725
  ];
6712
- } else if (expression?.type === "ObjectExpression" || expression?.type === "FunctionExpression" && !expression.id) {
6726
+ } else if (expression?.type === "ObjectExpression" || expression?.type === "FunctionExpression" && !expression.id || expression?.type === "UnaryExpression" && !expression.pre?.length && expression.expression !== makeExpressionStatement(expression.expression)) {
6713
6727
  return makeLeftHandSideExpression(expression);
6714
6728
  } else {
6715
6729
  return expression;
@@ -7422,12 +7436,12 @@ function processProgram(root) {
7422
7436
  } else if (config2.autoVar) {
7423
7437
  createVarDecs(root, []);
7424
7438
  }
7425
- processBlocks(statements);
7426
- populateRefs(statements);
7427
- adjustAtBindings(statements);
7428
7439
  if (config2.repl) {
7429
7440
  processRepl(root, rootIIFE);
7430
7441
  }
7442
+ processBlocks(statements);
7443
+ populateRefs(statements);
7444
+ adjustAtBindings(statements);
7431
7445
  if (getSync()) {
7432
7446
  processComptime(statements);
7433
7447
  }
@@ -7446,7 +7460,11 @@ function processRepl(root, rootIIFE) {
7446
7460
  }
7447
7461
  if (decl.parent === topBlock || decl.decl === "var") {
7448
7462
  decl.children.shift();
7449
- root.expressions.splice(i++, 0, ["", `var ${decl.names.join(",")};`]);
7463
+ if (decl.bindings[0]?.pattern?.type === "ObjectBindingPattern") {
7464
+ decl.children.unshift("(");
7465
+ decl.children.push(")");
7466
+ }
7467
+ root.expressions.splice(i++, 0, ["", `var ${decl.names.join(",")}`, ";"]);
7450
7468
  }
7451
7469
  }
7452
7470
  for (let ref27 = gatherRecursive(topBlock, ($15) => $15.type === "FunctionExpression"), i10 = 0, len9 = ref27.length; i10 < len9; i10++) {
@@ -7458,7 +7476,7 @@ function processRepl(root, rootIIFE) {
7458
7476
  func.parent = root;
7459
7477
  } else {
7460
7478
  func.children.unshift(func.name, "=");
7461
- root.expressions.splice(i++, 0, ["", `var ${func.name};`]);
7479
+ root.expressions.splice(i++, 0, ["", `var ${func.name}`, ";"]);
7462
7480
  }
7463
7481
  }
7464
7482
  }
@@ -7467,7 +7485,7 @@ function processRepl(root, rootIIFE) {
7467
7485
  let m5;
7468
7486
  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)) {
7469
7487
  classExp.children.unshift(classExp.name, "=");
7470
- root.expressions.splice(i++, 0, ["", `var ${classExp.name};`]);
7488
+ root.expressions.splice(i++, 0, ["", `var ${classExp.name}`, ";"]);
7471
7489
  }
7472
7490
  }
7473
7491
  }
@@ -8303,6 +8321,7 @@ var grammar = {
8303
8321
  Dot,
8304
8322
  DotDot,
8305
8323
  DotDotDot,
8324
+ InsertDotDotDot,
8306
8325
  DoubleColon,
8307
8326
  DoubleColonAsColon,
8308
8327
  DoubleQuote,
@@ -8863,7 +8882,7 @@ var $R11 = (0, import_lib2.$R)(new RegExp("%%?", "suy"));
8863
8882
  var $R12 = (0, import_lib2.$R)(new RegExp("[.\\s]", "suy"));
8864
8883
  var $R13 = (0, import_lib2.$R)(new RegExp("[)}]", "suy"));
8865
8884
  var $R14 = (0, import_lib2.$R)(new RegExp("[+-]", "suy"));
8866
- var $R15 = (0, import_lib2.$R)(new RegExp("\\+\\+|--|[\\+\\-&]\\S", "suy"));
8885
+ var $R15 = (0, import_lib2.$R)(new RegExp("\\+\\+|--|\u29FA|\u2014|[\\+\\-&]\\S", "suy"));
8867
8886
  var $R16 = (0, import_lib2.$R)(new RegExp(`(?=[0-9.'"tfyno])`, "suy"));
8868
8887
  var $R17 = (0, import_lib2.$R)(new RegExp("(?=true|false|yes|no|on|off)", "suy"));
8869
8888
  var $R18 = (0, import_lib2.$R)(new RegExp("(?=\\p{ID_Start}|[_$])", "suy"));
@@ -9725,9 +9744,7 @@ function TrailingPostfix(ctx, state2) {
9725
9744
  }
9726
9745
  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) {
9727
9746
  var exp = $3;
9728
- if (exp.type === "ObjectExpression") {
9729
- exp = makeLeftHandSideExpression(exp);
9730
- }
9747
+ exp = makeExpressionStatement(exp);
9731
9748
  const expressions = [["", exp]];
9732
9749
  return {
9733
9750
  type: "BlockStatement",
@@ -11661,7 +11678,7 @@ var FunctionExpression$4 = (0, import_lib2.$TS)((0, import_lib2.$S)(OpenParen, _
11661
11678
  expression: fn
11662
11679
  };
11663
11680
  });
11664
- var FunctionExpression$5 = (0, import_lib2.$TS)((0, import_lib2.$S)(OpenParen, __, (0, import_lib2.$N)((0, import_lib2.$EXPECT)($R15, "FunctionExpression /\\+\\+|--|[\\+\\-&]\\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) {
11681
+ 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) {
11665
11682
  var open = $1;
11666
11683
  var ws1 = $2;
11667
11684
  var op = $5;
@@ -12980,12 +12997,41 @@ var ObjectPropertyDelimiter$$ = [ObjectPropertyDelimiter$0, ObjectPropertyDelimi
12980
12997
  function ObjectPropertyDelimiter(ctx, state2) {
12981
12998
  return (0, import_lib2.$EVENT_C)(ctx, state2, "ObjectPropertyDelimiter", ObjectPropertyDelimiter$$);
12982
12999
  }
12983
- var PropertyDefinition$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), NamedProperty), function($skip, $loc, $0, $1, $2) {
13000
+ var PropertyDefinition$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), InsertDotDotDot, IterationExpression), function($skip, $loc, $0, $1, $2, $3) {
13001
+ var ws = $1;
13002
+ var dots = $2;
13003
+ var exp = $3;
13004
+ let { statement } = exp;
13005
+ if (exp.block.implicit && (statement.type === "DoStatement" || statement.subtype === "loop")) {
13006
+ return $skip;
13007
+ }
13008
+ statement = { ...statement, object: true };
13009
+ exp = {
13010
+ ...exp,
13011
+ statement,
13012
+ children: exp.children.map(($) => $ === exp.statement ? statement : $)
13013
+ };
13014
+ const children = [ws, dots, exp];
13015
+ if (statement.reduction) {
13016
+ children.unshift({
13017
+ type: "Error",
13018
+ message: "Reduction loops are forbidden in object literals"
13019
+ });
13020
+ }
13021
+ return {
13022
+ type: "SpreadProperty",
13023
+ children,
13024
+ names: exp.names,
13025
+ dots,
13026
+ value: exp
13027
+ };
13028
+ });
13029
+ var PropertyDefinition$1 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), NamedProperty), function($skip, $loc, $0, $1, $2) {
12984
13030
  var ws = $1;
12985
13031
  var prop = $2;
12986
13032
  return prepend(ws, prop);
12987
13033
  });
12988
- 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) {
13034
+ 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) {
12989
13035
  var ws = $1;
12990
13036
  var toggle = $2;
12991
13037
  var id = $3;
@@ -13007,7 +13053,7 @@ var PropertyDefinition$1 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_l
13007
13053
  value: id
13008
13054
  };
13009
13055
  });
13010
- var PropertyDefinition$2 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), MethodDefinition), function($skip, $loc, $0, $1, $2) {
13056
+ var PropertyDefinition$3 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), MethodDefinition), function($skip, $loc, $0, $1, $2) {
13011
13057
  var ws = $1;
13012
13058
  var def = $2;
13013
13059
  if (def.type === "MultiMethodDefinition") {
@@ -13019,7 +13065,7 @@ var PropertyDefinition$2 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_l
13019
13065
  return $skip;
13020
13066
  return prepend(ws, def);
13021
13067
  });
13022
- var PropertyDefinition$3 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), DotDotDot, Expression), function($skip, $loc, $0, $1, $2, $3) {
13068
+ var PropertyDefinition$4 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), DotDotDot, Expression), function($skip, $loc, $0, $1, $2, $3) {
13023
13069
  var ws = $1;
13024
13070
  var dots = $2;
13025
13071
  var exp = $3;
@@ -13031,7 +13077,7 @@ var PropertyDefinition$3 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_l
13031
13077
  value: exp
13032
13078
  };
13033
13079
  });
13034
- 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) {
13080
+ 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) {
13035
13081
  var ws = $1;
13036
13082
  var pre = $3;
13037
13083
  var value = $4;
@@ -13096,7 +13142,7 @@ var PropertyDefinition$4 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_l
13096
13142
  value
13097
13143
  };
13098
13144
  });
13099
- var PropertyDefinition$$ = [PropertyDefinition$0, PropertyDefinition$1, PropertyDefinition$2, PropertyDefinition$3, PropertyDefinition$4];
13145
+ var PropertyDefinition$$ = [PropertyDefinition$0, PropertyDefinition$1, PropertyDefinition$2, PropertyDefinition$3, PropertyDefinition$4, PropertyDefinition$5];
13100
13146
  function PropertyDefinition(ctx, state2) {
13101
13147
  return (0, import_lib2.$EVENT_C)(ctx, state2, "PropertyDefinition", PropertyDefinition$$);
13102
13148
  }
@@ -16077,7 +16123,7 @@ var DecimalBigIntegerLiteral$0 = (0, import_lib2.$R$0)((0, import_lib2.$EXPECT)(
16077
16123
  function DecimalBigIntegerLiteral(ctx, state2) {
16078
16124
  return (0, import_lib2.$EVENT)(ctx, state2, "DecimalBigIntegerLiteral", DecimalBigIntegerLiteral$0);
16079
16125
  }
16080
- 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) {
16126
+ 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) {
16081
16127
  return $1 + ".";
16082
16128
  });
16083
16129
  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)));
@@ -16716,6 +16762,12 @@ var DotDotDot$$ = [DotDotDot$0, DotDotDot$1];
16716
16762
  function DotDotDot(ctx, state2) {
16717
16763
  return (0, import_lib2.$EVENT_C)(ctx, state2, "DotDotDot", DotDotDot$$);
16718
16764
  }
16765
+ var InsertDotDotDot$0 = (0, import_lib2.$TV)((0, import_lib2.$EXPECT)($L0, 'InsertDotDotDot ""'), function($skip, $loc, $0, $1) {
16766
+ return { $loc, token: "..." };
16767
+ });
16768
+ function InsertDotDotDot(ctx, state2) {
16769
+ return (0, import_lib2.$EVENT)(ctx, state2, "InsertDotDotDot", InsertDotDotDot$0);
16770
+ }
16719
16771
  var DoubleColon$0 = (0, import_lib2.$TV)((0, import_lib2.$EXPECT)($L162, 'DoubleColon "::"'), function($skip, $loc, $0, $1) {
16720
16772
  return { $loc, token: $1 };
16721
16773
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@danielx/civet",
3
3
  "type": "commonjs",
4
- "version": "0.8.13",
4
+ "version": "0.8.14",
5
5
  "description": "CoffeeScript style syntax for TypeScript",
6
6
  "main": "dist/main.js",
7
7
  "module": "dist/main.mjs",