@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/CHANGELOG.md CHANGED
@@ -4,6 +4,13 @@ This changelog is generated automatically by [`build/changelog.civet`](build/cha
4
4
  For each version of Civet, it lists and links to all incorporated PRs,
5
5
  as well as a full diff and commit list.
6
6
 
7
+ ## 0.8.14 (2024-11-07, [diff](https://github.com/DanielXMoore/Civet/compare/v0.8.13...v0.8.14), [commits](https://github.com/DanielXMoore/Civet/commits/v0.8.14))
8
+ * Syntax highlighting: fix leading `_` being treated as a number [[#1578](https://github.com/DanielXMoore/Civet/pull/1578)]
9
+ * Scientific numeric literals take priority over access [[#1579](https://github.com/DanielXMoore/Civet/pull/1579)]
10
+ * Fix parenthesized `⧺` and `—` shorthands for `++` and `--` [[#1584](https://github.com/DanielXMoore/Civet/pull/1584)]
11
+ * Fix wrapping of braced objects in parentheses [[#1585](https://github.com/DanielXMoore/Civet/pull/1585)]
12
+ * Object comprehensions via loops in braces [[#1563](https://github.com/DanielXMoore/Civet/pull/1563)]
13
+
7
14
  ## 0.8.13 (2024-11-05, [diff](https://github.com/DanielXMoore/Civet/compare/v0.8.12...v0.8.13), [commits](https://github.com/DanielXMoore/Civet/commits/v0.8.13))
8
15
  * Playground copy button for large text fragments [[#1569](https://github.com/DanielXMoore/Civet/pull/1569)]
9
16
  * Fix unplugin `typecheck`: source mapping and `rewriteCivetImports` combination [[#1571](https://github.com/DanielXMoore/Civet/pull/1571)]
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;
@@ -3146,6 +3146,8 @@ ${js}`
3146
3146
  }
3147
3147
  }
3148
3148
  })());
3149
+ } else if (statement.object) {
3150
+ declaration.children.push("={}");
3149
3151
  } else {
3150
3152
  if (decl === "const") {
3151
3153
  declaration.children.push("=[]");
@@ -3161,6 +3163,9 @@ ${js}`
3161
3163
  }
3162
3164
  if (!block.empty) {
3163
3165
  assignResults(block, (node) => {
3166
+ if (statement.object) {
3167
+ return ["Object.assign(", resultsRef, ",", node, ")"];
3168
+ }
3164
3169
  if (!reduction) {
3165
3170
  return [resultsRef, ".push(", node, ")"];
3166
3171
  }
@@ -4765,8 +4770,8 @@ ${js}`
4765
4770
  return;
4766
4771
  }
4767
4772
  let { expression } = condition;
4768
- 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]) {
4769
- 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;
4770
4775
  const type = [type1, type2];
4771
4776
  expression = expression2;
4772
4777
  }
@@ -4785,7 +4790,7 @@ ${js}`
4785
4790
  let children = condition.children;
4786
4791
  if (s.negated) {
4787
4792
  let m;
4788
- 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")) {
4789
4794
  throw new Error("Unsupported negated condition");
4790
4795
  }
4791
4796
  ;
@@ -5089,7 +5094,9 @@ ${js}`
5089
5094
  if (pre.length) {
5090
5095
  return {
5091
5096
  type: "UnaryExpression",
5092
- children: [...pre, exp]
5097
+ children: [pre, exp],
5098
+ pre,
5099
+ expression: exp
5093
5100
  };
5094
5101
  }
5095
5102
  return exp;
@@ -5141,7 +5148,10 @@ ${js}`
5141
5148
  }
5142
5149
  return {
5143
5150
  type: "UnaryExpression",
5144
- children: [...pre, exp, post]
5151
+ children: [pre, exp, post],
5152
+ pre,
5153
+ expression: exp,
5154
+ post
5145
5155
  };
5146
5156
  }
5147
5157
  function processUnaryNestedExpression(pre, args, post) {
@@ -6181,12 +6191,16 @@ ${js}`
6181
6191
  if (i < 0) {
6182
6192
  throw new Error(`Could not find expression in condition`);
6183
6193
  }
6194
+ const pre = ["!"];
6195
+ expression = makeLeftHandSideExpression(expression);
6184
6196
  children[i] = expression = {
6185
6197
  type: "UnaryExpression",
6186
6198
  children: [
6187
- "!",
6188
- makeLeftHandSideExpression(expression)
6189
- ]
6199
+ pre,
6200
+ expression
6201
+ ],
6202
+ pre,
6203
+ expression
6190
6204
  };
6191
6205
  return { ...condition, expression, children };
6192
6206
  }
@@ -6753,7 +6767,7 @@ ${js}`
6753
6767
  return [comma, makeExpressionStatement(exp)];
6754
6768
  })
6755
6769
  ];
6756
- } 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)) {
6757
6771
  return makeLeftHandSideExpression(expression);
6758
6772
  } else {
6759
6773
  return expression;
@@ -7466,12 +7480,12 @@ ${js}`
7466
7480
  } else if (config2.autoVar) {
7467
7481
  createVarDecs(root, []);
7468
7482
  }
7469
- processBlocks(statements);
7470
- populateRefs(statements);
7471
- adjustAtBindings(statements);
7472
7483
  if (config2.repl) {
7473
7484
  processRepl(root, rootIIFE);
7474
7485
  }
7486
+ processBlocks(statements);
7487
+ populateRefs(statements);
7488
+ adjustAtBindings(statements);
7475
7489
  if (getSync()) {
7476
7490
  processComptime(statements);
7477
7491
  }
@@ -7490,7 +7504,11 @@ ${js}`
7490
7504
  }
7491
7505
  if (decl.parent === topBlock || decl.decl === "var") {
7492
7506
  decl.children.shift();
7493
- 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(",")}`, ";"]);
7494
7512
  }
7495
7513
  }
7496
7514
  for (let ref27 = gatherRecursive(topBlock, ($15) => $15.type === "FunctionExpression"), i10 = 0, len9 = ref27.length; i10 < len9; i10++) {
@@ -7502,7 +7520,7 @@ ${js}`
7502
7520
  func.parent = root;
7503
7521
  } else {
7504
7522
  func.children.unshift(func.name, "=");
7505
- root.expressions.splice(i++, 0, ["", `var ${func.name};`]);
7523
+ root.expressions.splice(i++, 0, ["", `var ${func.name}`, ";"]);
7506
7524
  }
7507
7525
  }
7508
7526
  }
@@ -7511,7 +7529,7 @@ ${js}`
7511
7529
  let m5;
7512
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)) {
7513
7531
  classExp.children.unshift(classExp.name, "=");
7514
- root.expressions.splice(i++, 0, ["", `var ${classExp.name};`]);
7532
+ root.expressions.splice(i++, 0, ["", `var ${classExp.name}`, ";"]);
7515
7533
  }
7516
7534
  }
7517
7535
  }
@@ -8347,6 +8365,7 @@ ${js}`
8347
8365
  Dot,
8348
8366
  DotDot,
8349
8367
  DotDotDot,
8368
+ InsertDotDotDot,
8350
8369
  DoubleColon,
8351
8370
  DoubleColonAsColon,
8352
8371
  DoubleQuote,
@@ -8907,7 +8926,7 @@ ${js}`
8907
8926
  var $R12 = (0, import_lib2.$R)(new RegExp("[.\\s]", "suy"));
8908
8927
  var $R13 = (0, import_lib2.$R)(new RegExp("[)}]", "suy"));
8909
8928
  var $R14 = (0, import_lib2.$R)(new RegExp("[+-]", "suy"));
8910
- var $R15 = (0, import_lib2.$R)(new RegExp("\\+\\+|--|[\\+\\-&]\\S", "suy"));
8929
+ var $R15 = (0, import_lib2.$R)(new RegExp("\\+\\+|--|\u29FA|\u2014|[\\+\\-&]\\S", "suy"));
8911
8930
  var $R16 = (0, import_lib2.$R)(new RegExp(`(?=[0-9.'"tfyno])`, "suy"));
8912
8931
  var $R17 = (0, import_lib2.$R)(new RegExp("(?=true|false|yes|no|on|off)", "suy"));
8913
8932
  var $R18 = (0, import_lib2.$R)(new RegExp("(?=\\p{ID_Start}|[_$])", "suy"));
@@ -9769,9 +9788,7 @@ ${js}`
9769
9788
  }
9770
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) {
9771
9790
  var exp = $3;
9772
- if (exp.type === "ObjectExpression") {
9773
- exp = makeLeftHandSideExpression(exp);
9774
- }
9791
+ exp = makeExpressionStatement(exp);
9775
9792
  const expressions = [["", exp]];
9776
9793
  return {
9777
9794
  type: "BlockStatement",
@@ -11705,7 +11722,7 @@ ${js}`
11705
11722
  expression: fn
11706
11723
  };
11707
11724
  });
11708
- 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) {
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) {
11709
11726
  var open = $1;
11710
11727
  var ws1 = $2;
11711
11728
  var op = $5;
@@ -13024,12 +13041,41 @@ ${js}`
13024
13041
  function ObjectPropertyDelimiter(ctx, state2) {
13025
13042
  return (0, import_lib2.$EVENT_C)(ctx, state2, "ObjectPropertyDelimiter", ObjectPropertyDelimiter$$);
13026
13043
  }
13027
- 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) {
13028
13074
  var ws = $1;
13029
13075
  var prop = $2;
13030
13076
  return prepend(ws, prop);
13031
13077
  });
13032
- 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) {
13033
13079
  var ws = $1;
13034
13080
  var toggle = $2;
13035
13081
  var id = $3;
@@ -13051,7 +13097,7 @@ ${js}`
13051
13097
  value: id
13052
13098
  };
13053
13099
  });
13054
- 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) {
13055
13101
  var ws = $1;
13056
13102
  var def = $2;
13057
13103
  if (def.type === "MultiMethodDefinition") {
@@ -13063,7 +13109,7 @@ ${js}`
13063
13109
  return $skip;
13064
13110
  return prepend(ws, def);
13065
13111
  });
13066
- 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) {
13067
13113
  var ws = $1;
13068
13114
  var dots = $2;
13069
13115
  var exp = $3;
@@ -13075,7 +13121,7 @@ ${js}`
13075
13121
  value: exp
13076
13122
  };
13077
13123
  });
13078
- 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) {
13079
13125
  var ws = $1;
13080
13126
  var pre = $3;
13081
13127
  var value = $4;
@@ -13140,7 +13186,7 @@ ${js}`
13140
13186
  value
13141
13187
  };
13142
13188
  });
13143
- 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];
13144
13190
  function PropertyDefinition(ctx, state2) {
13145
13191
  return (0, import_lib2.$EVENT_C)(ctx, state2, "PropertyDefinition", PropertyDefinition$$);
13146
13192
  }
@@ -16121,7 +16167,7 @@ ${js}`
16121
16167
  function DecimalBigIntegerLiteral(ctx, state2) {
16122
16168
  return (0, import_lib2.$EVENT)(ctx, state2, "DecimalBigIntegerLiteral", DecimalBigIntegerLiteral$0);
16123
16169
  }
16124
- 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) {
16125
16171
  return $1 + ".";
16126
16172
  });
16127
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)));
@@ -16760,6 +16806,12 @@ ${js}`
16760
16806
  function DotDotDot(ctx, state2) {
16761
16807
  return (0, import_lib2.$EVENT_C)(ctx, state2, "DotDotDot", DotDotDot$$);
16762
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
+ }
16763
16815
  var DoubleColon$0 = (0, import_lib2.$TV)((0, import_lib2.$EXPECT)($L162, 'DoubleColon "::"'), function($skip, $loc, $0, $1) {
16764
16816
  return { $loc, token: $1 };
16765
16817
  });