@danielx/civet 0.10.5 → 0.10.6

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.mjs CHANGED
@@ -485,7 +485,7 @@ ${body}`;
485
485
  // source/parser.hera
486
486
  var import_lib2 = __toESM(require_machine());
487
487
 
488
- // unplugin-civet:/home/daniel/apps/Civet/source/parser/lib.civet.jsx
488
+ // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\lib.civet.jsx
489
489
  var lib_civet_exports = {};
490
490
  __export(lib_civet_exports, {
491
491
  addPostfixStatement: () => addPostfixStatement,
@@ -496,6 +496,8 @@ __export(lib_civet_exports, {
496
496
  blockWithPrefix: () => blockWithPrefix,
497
497
  braceBlock: () => braceBlock,
498
498
  bracedBlock: () => bracedBlock,
499
+ convertArrowFunctionToMethod: () => convertArrowFunctionToMethod,
500
+ convertFunctionToMethod: () => convertFunctionToMethod,
499
501
  convertNamedImportsToObject: () => convertNamedImportsToObject,
500
502
  convertObjectToJSXAttributes: () => convertObjectToJSXAttributes,
501
503
  convertWithClause: () => convertWithClause,
@@ -565,7 +567,7 @@ __export(lib_civet_exports, {
565
567
  wrapTypeInPromise: () => wrapTypeInPromise
566
568
  });
567
569
 
568
- // unplugin-civet:/home/daniel/apps/Civet/source/parser/util.civet.jsx
570
+ // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\util.civet.jsx
569
571
  function len(arr, length) {
570
572
  return arr.length === length;
571
573
  }
@@ -1566,7 +1568,7 @@ function flatJoin(array, separator) {
1566
1568
  return result;
1567
1569
  }
1568
1570
 
1569
- // unplugin-civet:/home/daniel/apps/Civet/source/parser/traversal.civet.jsx
1571
+ // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\traversal.civet.jsx
1570
1572
  function gatherRecursiveWithinFunction(node, predicate) {
1571
1573
  return gatherRecursive(node, predicate, isFunction);
1572
1574
  }
@@ -1675,7 +1677,7 @@ function gatherRecursiveAll(node, predicate) {
1675
1677
  return nodes;
1676
1678
  }
1677
1679
 
1678
- // unplugin-civet:/home/daniel/apps/Civet/source/parser/ref.civet.jsx
1680
+ // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\ref.civet.jsx
1679
1681
  var range = (start, end) => {
1680
1682
  const length = end - start;
1681
1683
  if (length <= 0) return [];
@@ -1770,7 +1772,7 @@ function populateRefs(statements) {
1770
1772
  }
1771
1773
  }
1772
1774
 
1773
- // unplugin-civet:/home/daniel/apps/Civet/source/parser/binding.civet.jsx
1775
+ // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\binding.civet.jsx
1774
1776
  function adjustAtBindings(statements, asThis = false) {
1775
1777
  for (let ref1 = gatherRecursiveAll(statements, ($1) => $1.type === "AtBindingProperty"), i1 = 0, len3 = ref1.length; i1 < len3; i1++) {
1776
1778
  const binding = ref1[i1];
@@ -2037,12 +2039,12 @@ function gatherBindingPatternTypeSuffix(pattern) {
2037
2039
  return pattern;
2038
2040
  }
2039
2041
 
2040
- // unplugin-civet:/home/daniel/apps/Civet/source/parser/comptime.civet.jsx
2042
+ // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\comptime.civet.jsx
2041
2043
  import { resolve, dirname } from "node:path";
2042
2044
  import { createRequire } from "node:module";
2043
2045
  import vm from "node:vm";
2044
2046
 
2045
- // unplugin-civet:/home/daniel/apps/Civet/source/parser/helper.civet.jsx
2047
+ // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\helper.civet.jsx
2046
2048
  var preludeVar = "var ";
2047
2049
  function ts(children) {
2048
2050
  return {
@@ -2359,7 +2361,7 @@ function extractPreludeFor(node) {
2359
2361
  }
2360
2362
  }
2361
2363
 
2362
- // unplugin-civet:/home/daniel/apps/Civet/source/generate.civet.jsx
2364
+ // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\generate.civet.jsx
2363
2365
  function stringify(node) {
2364
2366
  try {
2365
2367
  return JSON.stringify(removeParentPointers(node));
@@ -2469,7 +2471,7 @@ function prune(node) {
2469
2471
  return node;
2470
2472
  }
2471
2473
 
2472
- // unplugin-civet:/home/daniel/apps/Civet/source/parser/comptime.civet.jsx
2474
+ // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\comptime.civet.jsx
2473
2475
  function expressionizeComptime(statement) {
2474
2476
  const { expressions } = statement.block;
2475
2477
  const expression = wrapIIFE(expressions, hasAwait(expressions));
@@ -2790,7 +2792,7 @@ function serialize(value, context) {
2790
2792
  return recurse(value);
2791
2793
  }
2792
2794
 
2793
- // unplugin-civet:/home/daniel/apps/Civet/source/parser/function.civet.jsx
2795
+ // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\function.civet.jsx
2794
2796
  var concatAssign = (lhs, rhs) => (rhs?.[Symbol.isConcatSpreadable] ?? Array.isArray(rhs) ? lhs.push.apply(lhs, rhs) : lhs.push(rhs), lhs);
2795
2797
  function getTypeArguments(args) {
2796
2798
  while (typeof args === "object" && args != null && "args" in args) {
@@ -4223,7 +4225,7 @@ function makeAmpersandFunction(rhs) {
4223
4225
  return fn;
4224
4226
  }
4225
4227
 
4226
- // unplugin-civet:/home/daniel/apps/Civet/source/parser/block.civet.jsx
4228
+ // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\block.civet.jsx
4227
4229
  function blockWithPrefix(prefixStatements, block) {
4228
4230
  if (prefixStatements && prefixStatements.length) {
4229
4231
  const expressions = [...prefixStatements, ...block.expressions];
@@ -4444,7 +4446,7 @@ function blockContainingStatement(exp) {
4444
4446
  };
4445
4447
  }
4446
4448
 
4447
- // unplugin-civet:/home/daniel/apps/Civet/source/parser/op.civet.jsx
4449
+ // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\op.civet.jsx
4448
4450
  var precedenceOrder = [
4449
4451
  ["||", "??"],
4450
4452
  ["^^"],
@@ -4780,7 +4782,7 @@ function expandChainedComparisons([first, binops]) {
4780
4782
  }
4781
4783
  }
4782
4784
 
4783
- // unplugin-civet:/home/daniel/apps/Civet/source/parser/pattern-matching.civet.jsx
4785
+ // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\pattern-matching.civet.jsx
4784
4786
  function processPatternTest(lhs, patterns) {
4785
4787
  const { ref, refAssignmentComma } = maybeRefAssignment(lhs, "m");
4786
4788
  const conditionExpression = flatJoin(patterns.map(($1) => getPatternConditions($1, ref)).map(($2) => flatJoin($2, " && ")), " || ");
@@ -5299,7 +5301,7 @@ function aliasBinding(p, ref) {
5299
5301
  }
5300
5302
  }
5301
5303
 
5302
- // unplugin-civet:/home/daniel/apps/Civet/source/parser/declaration.civet.jsx
5304
+ // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\declaration.civet.jsx
5303
5305
  function len2(arr, length) {
5304
5306
  return arr.length === length;
5305
5307
  }
@@ -5853,7 +5855,7 @@ function convertWithClause(withClause, extendsClause) {
5853
5855
  return [extendsToken, insertTrimmingSpace(ws, " "), wrapped];
5854
5856
  }
5855
5857
 
5856
- // unplugin-civet:/home/daniel/apps/Civet/source/parser/unary.civet.jsx
5858
+ // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\unary.civet.jsx
5857
5859
  function processUnaryExpression(pre, exp, post) {
5858
5860
  if (!(pre.length || post)) {
5859
5861
  return exp;
@@ -6015,7 +6017,7 @@ function processUnaryNestedExpression(pre, args, post) {
6015
6017
  return processUnaryExpression(pre, args, post);
6016
6018
  }
6017
6019
 
6018
- // unplugin-civet:/home/daniel/apps/Civet/source/parser/pipe.civet.jsx
6020
+ // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\pipe.civet.jsx
6019
6021
  function constructInvocation(fn, arg) {
6020
6022
  let expr = fn.expr;
6021
6023
  while (expr.type === "ParenthesizedExpression") {
@@ -6238,7 +6240,7 @@ function processPipelineExpressions(statements) {
6238
6240
  }
6239
6241
  }
6240
6242
 
6241
- // unplugin-civet:/home/daniel/apps/Civet/source/parser/for.civet.jsx
6243
+ // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\for.civet.jsx
6242
6244
  function processRangeExpression(start, ws1, range2, end) {
6243
6245
  ws1 = [ws1, range2.children[0]];
6244
6246
  const ws2 = range2.children[1];
@@ -6683,7 +6685,7 @@ function processForInOf($0) {
6683
6685
  };
6684
6686
  }
6685
6687
 
6686
- // unplugin-civet:/home/daniel/apps/Civet/source/parser/auto-dec.civet.jsx
6688
+ // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\auto-dec.civet.jsx
6687
6689
  var concatAssign2 = (lhs, rhs) => (rhs?.[Symbol.isConcatSpreadable] ?? Array.isArray(rhs) ? lhs.push.apply(lhs, rhs) : lhs.push(rhs), lhs);
6688
6690
  function findDecs(statements) {
6689
6691
  const declarations = gatherNodes(statements, ($) => $.type === "Declaration");
@@ -6780,7 +6782,7 @@ function createVarDecs(block, scopes, pushVar) {
6780
6782
  findAssignments(assignmentStatements2.map((s) => s.children), decs2)
6781
6783
  );
6782
6784
  }
6783
- return assignmentStatements2;
6785
+ return assignmentStatements2.filter(($4) => !($4.parent?.type === "CoffeeClassPublic"));
6784
6786
  }
6785
6787
  pushVar ??= (name) => {
6786
6788
  varIds.push(name);
@@ -6791,7 +6793,7 @@ function createVarDecs(block, scopes, pushVar) {
6791
6793
  scopes.push(decs);
6792
6794
  const varIds = [];
6793
6795
  const assignmentStatements = findAssignments(statements, scopes);
6794
- const undeclaredIdentifiers = assignmentStatements.flatMap(($4) => $4?.names || []);
6796
+ const undeclaredIdentifiers = assignmentStatements.flatMap(($5) => $5?.names || []);
6795
6797
  undeclaredIdentifiers.filter((x, i, a) => {
6796
6798
  if (!hasDec(x)) return a.indexOf(x) === i;
6797
6799
  return;
@@ -6829,7 +6831,7 @@ function createVarDecs(block, scopes, pushVar) {
6829
6831
  scopes.pop();
6830
6832
  }
6831
6833
 
6832
- // unplugin-civet:/home/daniel/apps/Civet/source/parser/string.civet.jsx
6834
+ // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\string.civet.jsx
6833
6835
  function getIndentLevel(str, tab) {
6834
6836
  if (tab != null && tab != 1) {
6835
6837
  const tabs = str.match(/\t/g);
@@ -6997,7 +6999,7 @@ function quoteString(str) {
6997
6999
  return JSON.stringify(str);
6998
7000
  }
6999
7001
 
7000
- // unplugin-civet:/home/daniel/apps/Civet/source/parser/lib.civet.jsx
7002
+ // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\lib.civet.jsx
7001
7003
  var xor = (a, b) => a ? !b && a : b;
7002
7004
  function addPostfixStatement(statement, ws, post) {
7003
7005
  const expressions = [
@@ -7669,6 +7671,45 @@ function convertMethodToFunction(method) {
7669
7671
  block
7670
7672
  };
7671
7673
  }
7674
+ function convertFunctionToMethod(id, exp) {
7675
+ const fnTokenIndex = exp.children.findIndex(function(c) {
7676
+ return c?.token?.startsWith("function");
7677
+ });
7678
+ const children = exp.children.slice();
7679
+ if (exp.generator) {
7680
+ children.splice(fnTokenIndex, 2, children[fnTokenIndex + 1], id);
7681
+ } else {
7682
+ children.splice(fnTokenIndex, 1, id);
7683
+ }
7684
+ return {
7685
+ ...exp,
7686
+ type: "MethodDefinition",
7687
+ name: id.name,
7688
+ signature: { ...exp.signature, id, name: id.name },
7689
+ children
7690
+ };
7691
+ }
7692
+ function convertArrowFunctionToMethod(id, exp) {
7693
+ const block = { ...exp.block };
7694
+ const children = exp.children.filter(function(c) {
7695
+ return !(Array.isArray(c) && c[c.length - 1]?.token?.includes("=>"));
7696
+ }).map(function(c) {
7697
+ return c === exp.block ? block : c;
7698
+ });
7699
+ children.unshift(id);
7700
+ exp = {
7701
+ ...exp,
7702
+ type: "MethodDefinition",
7703
+ name: id.name,
7704
+ signature: { ...exp.signature, id, name: id.name },
7705
+ block,
7706
+ children,
7707
+ autoBind: true
7708
+ };
7709
+ block.parent = exp;
7710
+ braceBlock(block);
7711
+ return exp;
7712
+ }
7672
7713
  function convertNamedImportsToObject(node, pattern) {
7673
7714
  const properties = node.specifiers.map((specifier) => {
7674
7715
  if (specifier.ts) {
@@ -8453,7 +8494,17 @@ function processCoffeeClasses(statements) {
8453
8494
  })()
8454
8495
  );
8455
8496
  }
8456
- const privates = expressions.filter(($15) => $15[1]?.type === "CoffeeClassPrivate");
8497
+ const public_static_function_assignments = expressions.filter(($15) => $15[1]?.type === "CoffeeClassPublic" && $15[1].assignment?.expression?.type === "FunctionExpression").map(($16) => $16[1].assignment);
8498
+ for (const public_static_function_assignment of public_static_function_assignments) {
8499
+ const id = public_static_function_assignment.lhs[0][1];
8500
+ replaceNode(public_static_function_assignment, convertFunctionToMethod(id, public_static_function_assignment.expression));
8501
+ }
8502
+ const public_static_arrow_function_assignments = expressions.filter(($17) => $17[1]?.type === "CoffeeClassPublic" && $17[1].assignment?.expression?.type === "ArrowFunction").map(($18) => $18[1].assignment);
8503
+ for (const public_static_arrow_function_assignment of public_static_arrow_function_assignments) {
8504
+ const id = public_static_arrow_function_assignment.lhs[0][1];
8505
+ replaceNode(public_static_arrow_function_assignment, convertArrowFunctionToMethod(id, public_static_arrow_function_assignment.expression));
8506
+ }
8507
+ const privates = expressions.filter(($19) => $19[1]?.type === "CoffeeClassPrivate");
8457
8508
  if (!privates.length) {
8458
8509
  continue;
8459
8510
  }
@@ -8518,7 +8569,7 @@ function processProgram(root) {
8518
8569
  root.topLevelYield ? "*" : void 0
8519
8570
  );
8520
8571
  statements = [["", rootIIFE]];
8521
- root.children = root.children.map(($16) => $16 === root.expressions ? statements : $16);
8572
+ root.children = root.children.map(($20) => $20 === root.expressions ? statements : $20);
8522
8573
  root.expressions = statements;
8523
8574
  }
8524
8575
  hoistRefDecs(statements);
@@ -8549,9 +8600,9 @@ async function processProgramAsync(root) {
8549
8600
  await processComptime(statements);
8550
8601
  }
8551
8602
  function processRepl(root, rootIIFE) {
8552
- const topBlock = gatherRecursive(rootIIFE, ($17) => $17.type === "BlockStatement")[0];
8603
+ const topBlock = gatherRecursive(rootIIFE, ($21) => $21.type === "BlockStatement")[0];
8553
8604
  let i = 0;
8554
- for (let ref23 = gatherRecursiveWithinFunction(topBlock, ($18) => $18.type === "Declaration"), i14 = 0, len11 = ref23.length; i14 < len11; i14++) {
8605
+ for (let ref23 = gatherRecursiveWithinFunction(topBlock, ($22) => $22.type === "Declaration"), i14 = 0, len11 = ref23.length; i14 < len11; i14++) {
8555
8606
  const decl = ref23[i14];
8556
8607
  if (!decl.names?.length) {
8557
8608
  continue;
@@ -8565,7 +8616,7 @@ function processRepl(root, rootIIFE) {
8565
8616
  root.expressions.splice(i++, 0, ["", `var ${decl.names.join(",")}`, ";"]);
8566
8617
  }
8567
8618
  }
8568
- for (let ref24 = gatherRecursive(topBlock, ($19) => $19.type === "FunctionExpression"), i15 = 0, len12 = ref24.length; i15 < len12; i15++) {
8619
+ for (let ref24 = gatherRecursive(topBlock, ($23) => $23.type === "FunctionExpression"), i15 = 0, len12 = ref24.length; i15 < len12; i15++) {
8569
8620
  const func = ref24[i15];
8570
8621
  if (func.name && func.parent?.type === "BlockStatement") {
8571
8622
  if (func.parent === topBlock) {
@@ -8578,7 +8629,7 @@ function processRepl(root, rootIIFE) {
8578
8629
  }
8579
8630
  }
8580
8631
  }
8581
- for (let ref25 = gatherRecursiveWithinFunction(topBlock, ($20) => $20.type === "ClassExpression"), i16 = 0, len13 = ref25.length; i16 < len13; i16++) {
8632
+ for (let ref25 = gatherRecursiveWithinFunction(topBlock, ($24) => $24.type === "ClassExpression"), i16 = 0, len13 = ref25.length; i16 < len13; i16++) {
8582
8633
  const classExp = ref25[i16];
8583
8634
  let m8;
8584
8635
  if (classExp.name && classExp.parent === topBlock || (m8 = classExp.parent, typeof m8 === "object" && m8 != null && "type" in m8 && m8.type === "ReturnStatement" && "parent" in m8 && m8.parent === topBlock)) {
@@ -8590,7 +8641,7 @@ function processRepl(root, rootIIFE) {
8590
8641
  function processPlaceholders(statements) {
8591
8642
  const placeholderMap = /* @__PURE__ */ new Map();
8592
8643
  const liftedIfs = /* @__PURE__ */ new Set();
8593
- for (let ref26 = gatherRecursiveAll(statements, ($21) => $21.type === "Placeholder"), i17 = 0, len14 = ref26.length; i17 < len14; i17++) {
8644
+ for (let ref26 = gatherRecursiveAll(statements, ($25) => $25.type === "Placeholder"), i17 = 0, len14 = ref26.length; i17 < len14; i17++) {
8594
8645
  const exp = ref26[i17];
8595
8646
  let ancestor;
8596
8647
  if (exp.subtype === ".") {
@@ -9978,7 +10029,7 @@ var $R9 = (0, import_lib2.$R)(new RegExp("(?=[\\/?])", "suy"));
9978
10029
  var $R10 = (0, import_lib2.$R)(new RegExp("(?=[\\/\\[{?.!@#'\u2019:])", "suy"));
9979
10030
  var $R11 = (0, import_lib2.$R)(new RegExp("%%?", "suy"));
9980
10031
  var $R12 = (0, import_lib2.$R)(new RegExp("[.\\s]", "suy"));
9981
- var $R13 = (0, import_lib2.$R)(new RegExp("[)}]", "suy"));
10032
+ var $R13 = (0, import_lib2.$R)(new RegExp("[)\\]}]", "suy"));
9982
10033
  var $R14 = (0, import_lib2.$R)(new RegExp("[+-]", "suy"));
9983
10034
  var $R15 = (0, import_lib2.$R)(new RegExp("\\+\\+|--|\u29FA|\u2014|[\\+\\-&]\\S", "suy"));
9984
10035
  var $R16 = (0, import_lib2.$R)(new RegExp(`(?=[0-9.'"tfyno])`, "suy"));
@@ -11358,7 +11409,20 @@ var NestedClassElement$0 = (0, import_lib2.$S)(Nested, ClassElement, StatementDe
11358
11409
  function NestedClassElement(ctx, state2) {
11359
11410
  return (0, import_lib2.$EVENT)(ctx, state2, "NestedClassElement", NestedClassElement$0);
11360
11411
  }
11361
- var ClassElement$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(Decorators), (0, import_lib2.$E)((0, import_lib2.$S)(Declare, (0, import_lib2.$E)(_))), (0, import_lib2.$E)(AccessModifier), (0, import_lib2.$E)((0, import_lib2.$S)(Static, (0, import_lib2.$E)(_))), (0, import_lib2.$E)((0, import_lib2.$S)(Override, (0, import_lib2.$E)(_))), ClassElementDefinition), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
11412
+ var ClassElement$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(CoffeeClassesEnabled, (0, import_lib2.$E)(Decorators), (0, import_lib2.$E)((0, import_lib2.$S)(Declare, (0, import_lib2.$E)(_))), (0, import_lib2.$E)(AccessModifier), (0, import_lib2.$E)((0, import_lib2.$S)(Static, (0, import_lib2.$E)(_))), (0, import_lib2.$E)((0, import_lib2.$S)(Override, (0, import_lib2.$E)(_))), ActualAssignment), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7) {
11413
+ var decorators = $2;
11414
+ var declare = $3;
11415
+ var access = $4;
11416
+ var static_ = $5;
11417
+ var override = $6;
11418
+ var assignment = $7;
11419
+ return {
11420
+ type: static_ ? "CoffeeClassPublic" : "CoffeeClassPrivate",
11421
+ children: [decorators, declare, access, static_, override, assignment],
11422
+ assignment
11423
+ };
11424
+ });
11425
+ var ClassElement$1 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(Decorators), (0, import_lib2.$E)((0, import_lib2.$S)(Declare, (0, import_lib2.$E)(_))), (0, import_lib2.$E)(AccessModifier), (0, import_lib2.$E)((0, import_lib2.$S)(Static, (0, import_lib2.$E)(_))), (0, import_lib2.$E)((0, import_lib2.$S)(Override, (0, import_lib2.$E)(_))), ClassElementDefinition), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
11362
11426
  var decorators = $1;
11363
11427
  var declare = $2;
11364
11428
  var access = $3;
@@ -11384,14 +11448,14 @@ var ClassElement$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E
11384
11448
  children: [decorators, declare, access, static_, override, ...definition.children]
11385
11449
  };
11386
11450
  });
11387
- var ClassElement$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(Static, BracedBlock), function($skip, $loc, $0, $1, $2) {
11451
+ var ClassElement$2 = (0, import_lib2.$TS)((0, import_lib2.$S)(Static, BracedBlock), function($skip, $loc, $0, $1, $2) {
11388
11452
  return {
11389
11453
  type: "ClassStaticBlock",
11390
11454
  children: $0
11391
11455
  };
11392
11456
  });
11393
- var ClassElement$2 = EmptyStatement;
11394
- var ClassElement$$ = [ClassElement$0, ClassElement$1, ClassElement$2];
11457
+ var ClassElement$3 = EmptyStatement;
11458
+ var ClassElement$$ = [ClassElement$0, ClassElement$1, ClassElement$2, ClassElement$3];
11395
11459
  function ClassElement(ctx, state2) {
11396
11460
  return (0, import_lib2.$EVENT_C)(ctx, state2, "ClassElement", ClassElement$$);
11397
11461
  }
@@ -11444,37 +11508,10 @@ var FieldDefinition$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(CoffeeClassesEn
11444
11508
  var exp = $6;
11445
11509
  switch (exp.type) {
11446
11510
  case "FunctionExpression": {
11447
- const fnTokenIndex = exp.children.findIndex((c) => c?.token?.startsWith("function"));
11448
- const children = exp.children.slice();
11449
- if (exp.generator) {
11450
- children.splice(fnTokenIndex, 2, children[fnTokenIndex + 1], id);
11451
- } else {
11452
- children.splice(fnTokenIndex, 1, id);
11453
- }
11454
- return {
11455
- ...exp,
11456
- type: "MethodDefinition",
11457
- name: id.name,
11458
- signature: { ...exp.signature, id, name: id.name },
11459
- children
11460
- };
11511
+ return convertFunctionToMethod(id, exp);
11461
11512
  }
11462
11513
  case "ArrowFunction": {
11463
- const block = { ...exp.block };
11464
- const children = exp.children.filter((c) => !(Array.isArray(c) && c[c.length - 1]?.token?.includes("=>"))).map((c) => c === exp.block ? block : c);
11465
- children.unshift(id);
11466
- exp = {
11467
- ...exp,
11468
- type: "MethodDefinition",
11469
- name: id.name,
11470
- signature: { ...exp.signature, id, name: id.name },
11471
- block,
11472
- children,
11473
- autoBind: true
11474
- };
11475
- block.parent = exp;
11476
- braceBlock(block);
11477
- return exp;
11514
+ return convertArrowFunctionToMethod(id, exp);
11478
11515
  }
11479
11516
  default:
11480
11517
  return {
@@ -11501,15 +11538,7 @@ var FieldDefinition$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(InsertReadonly,
11501
11538
  readonly
11502
11539
  };
11503
11540
  });
11504
- var FieldDefinition$2 = (0, import_lib2.$TS)((0, import_lib2.$S)(CoffeeClassesEnabled, ActualAssignment), function($skip, $loc, $0, $1, $2) {
11505
- var assignment = $2;
11506
- return {
11507
- type: "CoffeeClassPrivate",
11508
- children: [assignment],
11509
- assignment
11510
- };
11511
- });
11512
- var FieldDefinition$3 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)((0, import_lib2.$S)(Abstract, (0, import_lib2.$E)(_))), (0, import_lib2.$E)((0, import_lib2.$S)(Readonly, (0, import_lib2.$E)(_))), ClassElementName, (0, import_lib2.$E)(TypeSuffix), (0, import_lib2.$E)(Initializer)), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
11541
+ var FieldDefinition$2 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)((0, import_lib2.$S)(Abstract, (0, import_lib2.$E)(_))), (0, import_lib2.$E)((0, import_lib2.$S)(Readonly, (0, import_lib2.$E)(_))), ClassElementName, (0, import_lib2.$E)(TypeSuffix), (0, import_lib2.$E)(Initializer)), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
11513
11542
  var abstract = $1;
11514
11543
  var readonly = $2;
11515
11544
  var id = $3;
@@ -11526,7 +11555,7 @@ var FieldDefinition$3 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2
11526
11555
  initializer
11527
11556
  };
11528
11557
  });
11529
- var FieldDefinition$$ = [FieldDefinition$0, FieldDefinition$1, FieldDefinition$2, FieldDefinition$3];
11558
+ var FieldDefinition$$ = [FieldDefinition$0, FieldDefinition$1, FieldDefinition$2];
11530
11559
  function FieldDefinition(ctx, state2) {
11531
11560
  return (0, import_lib2.$EVENT_C)(ctx, state2, "FieldDefinition", FieldDefinition$$);
11532
11561
  }
@@ -12297,7 +12326,7 @@ function ParameterElement(ctx, state2) {
12297
12326
  return (0, import_lib2.$EVENT)(ctx, state2, "ParameterElement", ParameterElement$0);
12298
12327
  }
12299
12328
  var ParameterElementDelimiter$0 = (0, import_lib2.$S)((0, import_lib2.$E)(_), Comma);
12300
- var ParameterElementDelimiter$1 = (0, import_lib2.$Y)((0, import_lib2.$S)(__, (0, import_lib2.$R$0)((0, import_lib2.$EXPECT)($R13, "ParameterElementDelimiter /[)}]/"))));
12329
+ var ParameterElementDelimiter$1 = (0, import_lib2.$Y)((0, import_lib2.$S)(__, (0, import_lib2.$R$0)((0, import_lib2.$EXPECT)($R13, "ParameterElementDelimiter /[)\\]}]/"))));
12301
12330
  var ParameterElementDelimiter$2 = (0, import_lib2.$T)((0, import_lib2.$S)((0, import_lib2.$Y)(EOS), InsertComma), function(value) {
12302
12331
  return value[1];
12303
12332
  });
@@ -14233,7 +14262,7 @@ function InlineObjectPropertyDelimiter(ctx, state2) {
14233
14262
  return (0, import_lib2.$EVENT)(ctx, state2, "InlineObjectPropertyDelimiter", InlineObjectPropertyDelimiter$0);
14234
14263
  }
14235
14264
  var ObjectPropertyDelimiter$0 = (0, import_lib2.$S)((0, import_lib2.$E)(_), Comma);
14236
- var ObjectPropertyDelimiter$1 = (0, import_lib2.$Y)((0, import_lib2.$S)(__, (0, import_lib2.$EXPECT)($L37, 'ObjectPropertyDelimiter "}"')));
14265
+ var ObjectPropertyDelimiter$1 = (0, import_lib2.$Y)((0, import_lib2.$S)(__, (0, import_lib2.$R$0)((0, import_lib2.$EXPECT)($R13, "ObjectPropertyDelimiter /[)\\]}]/"))));
14237
14266
  var ObjectPropertyDelimiter$2 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$Y)(EOS), InsertComma), function($skip, $loc, $0, $1, $2) {
14238
14267
  return { ...$2, implicit: true };
14239
14268
  });
@@ -21179,11 +21208,12 @@ var wellKnownSymbols = [
21179
21208
  "unscopables"
21180
21209
  ];
21181
21210
 
21182
- // unplugin-civet:/home/daniel/apps/Civet/source/sourcemap.civet.jsx
21211
+ // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\sourcemap.civet.jsx
21183
21212
  var sourcemap_civet_exports = {};
21184
21213
  __export(sourcemap_civet_exports, {
21185
21214
  SourceMap: () => SourceMap,
21186
21215
  base64Encode: () => base64Encode,
21216
+ decodeVLQ: () => decodeVLQ,
21187
21217
  locationTable: () => locationTable,
21188
21218
  lookupLineColumn: () => lookupLineColumn
21189
21219
  });
@@ -21219,7 +21249,6 @@ var SourceMap = class {
21219
21249
  // relative to previous entry
21220
21250
  srcLine;
21221
21251
  srcColumn;
21222
- srcOffset;
21223
21252
  srcTable;
21224
21253
  source;
21225
21254
  constructor(source1) {
@@ -21229,7 +21258,6 @@ var SourceMap = class {
21229
21258
  this.colOffset = 0;
21230
21259
  this.srcLine = 0;
21231
21260
  this.srcColumn = 0;
21232
- this.srcOffset = 0;
21233
21261
  this.srcTable = locationTable(this.source);
21234
21262
  }
21235
21263
  renderMappings() {
@@ -21273,6 +21301,10 @@ var SourceMap = class {
21273
21301
  }
21274
21302
  };
21275
21303
  }
21304
+ /** Generate a comment with the source mapping URL. */
21305
+ comment(srcFileName, outFileName) {
21306
+ return `//${"#"} sourceMappingURL=data:application/json;base64,${base64Encode(JSON.stringify(this.json(srcFileName, outFileName)))}`;
21307
+ }
21276
21308
  updateSourceMap(outputStr, inputPos, colOffset = 0) {
21277
21309
  const outLines = outputStr.split(EOL2);
21278
21310
  let srcLine, srcCol;
@@ -21281,7 +21313,6 @@ var SourceMap = class {
21281
21313
  srcCol += colOffset;
21282
21314
  this.srcLine = srcLine;
21283
21315
  this.srcColumn = srcCol;
21284
- this.srcOffset = inputPos + outputStr.length;
21285
21316
  }
21286
21317
  for (let i3 = 0, len22 = outLines.length; i3 < len22; i3++) {
21287
21318
  const i = i3;
@@ -21304,74 +21335,85 @@ var SourceMap = class {
21304
21335
  }
21305
21336
  return;
21306
21337
  }
21307
- };
21308
- var smRegexp = /\n\/\/# sourceMappingURL=data:application\/json;charset=utf-8;base64,([+a-zA-Z0-9\/]*=?=?)$/;
21309
- var remap = function(codeWithSourceMap, upstreamMap, sourcePath, targetPath) {
21310
- let sourceMapText;
21311
- const codeWithoutSourceMap = codeWithSourceMap.replace(smRegexp, (match, sm) => {
21312
- sourceMapText = sm;
21313
- return "";
21314
- });
21315
- if (sourceMapText) {
21316
- const parsed = parseWithLines(sourceMapText);
21317
- const composedLines = composeLines(upstreamMap.lines, parsed.lines);
21318
- upstreamMap.lines = composedLines;
21319
- }
21320
- const remappedSourceMapJSON = upstreamMap.json(sourcePath, targetPath);
21321
- const newSourceMap = `${"sourceMapping"}URL=data:application/json;charset=utf-8;base64,${base64Encode(JSON.stringify(remappedSourceMapJSON))}`;
21322
- const remappedCodeWithSourceMap = `${codeWithoutSourceMap}
21323
- //# ${newSourceMap}`;
21324
- return remappedCodeWithSourceMap;
21325
- };
21326
- var composeLines = function(upstreamMapping, lines) {
21327
- return lines.map((line) => {
21328
- return line.map((entry) => {
21329
- if (entry.length === 1) {
21330
- return entry;
21331
- }
21332
- const [colDelta, sourceFileIndex, srcLine, srcCol] = entry;
21333
- const srcPos = remapPosition([srcLine, srcCol], upstreamMapping);
21334
- if (!srcPos) {
21335
- return [entry[0]];
21336
- }
21337
- const [upstreamLine, upstreamCol] = srcPos;
21338
- if (entry.length === 4) {
21339
- return [colDelta, sourceFileIndex, upstreamLine, upstreamCol];
21340
- }
21341
- return [colDelta, sourceFileIndex, upstreamLine, upstreamCol, entry[4]];
21338
+ /**
21339
+ Remap a string with compiled code and a source map to use a new source map
21340
+ referencing upstream source files.
21341
+ This modifies the upstream map in place.
21342
+ */
21343
+ static remap = (codeWithSourceMap, upstreamMap, sourcePath, targetPath) => {
21344
+ let sourceMapText;
21345
+ const codeWithoutSourceMap = codeWithSourceMap.replace(smRegexp, (_match, sm) => {
21346
+ sourceMapText = sm;
21347
+ return "";
21342
21348
  });
21343
- });
21344
- };
21345
- var parseWithLines = function(base64encodedJSONstr) {
21346
- const json = JSON.parse(Buffer.from(base64encodedJSONstr, "base64").toString("utf8"));
21347
- let sourceLine = 0;
21348
- let sourceColumn = 0;
21349
- const lines = json.mappings.split(";").map((line) => {
21350
- if (line.length === 0) {
21351
- return [];
21349
+ if (sourceMapText) {
21350
+ const parsed = this.parseWithLines(sourceMapText);
21351
+ const composedLines = this.composeLines(upstreamMap.lines, parsed.lines);
21352
+ upstreamMap.lines = composedLines;
21352
21353
  }
21353
- return line.split(",").map((entry) => {
21354
- const result = decodeVLQ(entry);
21355
- switch (result.length) {
21356
- case 1: {
21357
- return [result[0]];
21358
- }
21359
- case 4: {
21360
- return [result[0], result[1], sourceLine += result[2], sourceColumn += result[3]];
21354
+ const remappedCodeWithSourceMap = `${codeWithoutSourceMap}
21355
+ ${upstreamMap.comment(sourcePath, targetPath)}`;
21356
+ return remappedCodeWithSourceMap;
21357
+ };
21358
+ /**
21359
+ Compose lines from an upstream source map with lines from a downstream source map.
21360
+ */
21361
+ static composeLines = (upstreamMapping, lines) => {
21362
+ return lines.map((line) => {
21363
+ return line.map((entry) => {
21364
+ if (entry.length === 1) {
21365
+ return entry;
21361
21366
  }
21362
- case 5: {
21363
- return [result[0], result[1], sourceLine += result[2], sourceColumn += result[3], result[4]];
21367
+ const [colDelta, sourceFileIndex, srcLine, srcCol] = entry;
21368
+ const srcPos = remapPosition([srcLine, srcCol], upstreamMapping);
21369
+ if (!srcPos) {
21370
+ return [entry[0]];
21364
21371
  }
21365
- default: {
21366
- throw new Error("Unknown source map entry", result);
21372
+ const [upstreamLine, upstreamCol] = srcPos;
21373
+ if (entry.length === 4) {
21374
+ return [colDelta, sourceFileIndex, upstreamLine, upstreamCol];
21367
21375
  }
21376
+ return [colDelta, sourceFileIndex, upstreamLine, upstreamCol, entry[4]];
21377
+ });
21378
+ });
21379
+ };
21380
+ /**
21381
+ Parse a base64 encoded source map string into a SourceMapJSON object with lines.
21382
+ */
21383
+ static parseWithLines = (base64encodedJSONstr) => {
21384
+ const json = JSON.parse(Buffer.from(base64encodedJSONstr, "base64").toString("utf8"));
21385
+ let sourceLine = 0;
21386
+ let sourceColumn = 0;
21387
+ const lines = json.mappings.split(";").map((line) => {
21388
+ if (line.length === 0) {
21389
+ return [];
21368
21390
  }
21391
+ return line.split(",").map((entry) => {
21392
+ const result = decodeVLQ(entry);
21393
+ switch (result.length) {
21394
+ case 1: {
21395
+ ;
21396
+ break;
21397
+ }
21398
+ case 4:
21399
+ case 5: {
21400
+ sourceLine += result[2];
21401
+ result[2] = sourceLine;
21402
+ sourceColumn += result[3];
21403
+ result[3] = sourceColumn;
21404
+ break;
21405
+ }
21406
+ default: {
21407
+ throw new Error(`Unknown source map entry ${JSON.stringify(result)}`);
21408
+ }
21409
+ }
21410
+ return result;
21411
+ });
21369
21412
  });
21370
- });
21371
- json.lines = lines;
21372
- return json;
21413
+ return { ...json, lines };
21414
+ };
21373
21415
  };
21374
- Object.assign(SourceMap, { remap, parseWithLines, composeLines });
21416
+ var smRegexp = /(?:\r?\n|\r)\/\/# sourceMappingURL=data:application\/json;(?:charset=[^;]*;)?base64,([+a-zA-Z0-9\/]*=?=?)(?:\s*)$/;
21375
21417
  var VLQ_SHIFT = 5;
21376
21418
  var VLQ_CONTINUATION_BIT = 1 << VLQ_SHIFT;
21377
21419
  var VLQ_VALUE_MASK = VLQ_CONTINUATION_BIT - 1;
@@ -21388,21 +21430,18 @@ var encodeVlq = function(value) {
21388
21430
  if (valueToEncode) {
21389
21431
  nextChunk |= VLQ_CONTINUATION_BIT;
21390
21432
  }
21391
- answer += encodeBase64(nextChunk);
21433
+ answer += BASE64_CHARS[nextChunk];
21392
21434
  }
21393
21435
  return answer;
21394
21436
  };
21395
21437
  var BASE64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
21396
- var encodeBase64 = function(value) {
21397
- return BASE64_CHARS[value] || (() => {
21398
- throw new Error("Cannot Base64 encode value: ${value}");
21399
- })();
21400
- };
21401
21438
  var base64Encode = function(src) {
21402
21439
  if (typeof Buffer !== "undefined") {
21403
21440
  return Buffer.from(src).toString("base64");
21404
21441
  } else {
21405
- return btoa(src);
21442
+ const bytes = new TextEncoder().encode(src);
21443
+ const binaryString = String.fromCodePoint(...bytes);
21444
+ return btoa(binaryString);
21406
21445
  }
21407
21446
  };
21408
21447
  var vlqTable = new Uint8Array(128);
@@ -21424,7 +21463,7 @@ var vlqChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/
21424
21463
  var decodeError = function(message) {
21425
21464
  throw new Error(message);
21426
21465
  };
21427
- var decodeVLQ = function(mapping) {
21466
+ var decodeVLQ = (mapping) => {
21428
21467
  let i = 0;
21429
21468
  let l = mapping.length;
21430
21469
  let result = [];
@@ -21438,11 +21477,11 @@ var decodeVLQ = function(mapping) {
21438
21477
  }
21439
21478
  const c = mapping.charCodeAt(i);
21440
21479
  if ((c & 127) != c) {
21441
- decodeError("Invalid mapping character: ${JSON.stringify(String.fromCharCode(c))}");
21480
+ decodeError(`Invalid mapping character: ${JSON.stringify(String.fromCharCode(c))}`);
21442
21481
  }
21443
21482
  const index = vlqTable[c & 127];
21444
21483
  if (index === 255) {
21445
- decodeError("Invalid mapping character: ${JSON.stringify(String.fromCharCode(c))}");
21484
+ decodeError(`Invalid mapping character: ${JSON.stringify(String.fromCharCode(c))}`);
21446
21485
  }
21447
21486
  i++;
21448
21487
  vlq |= (index & 31) << shift;
@@ -21460,7 +21499,7 @@ var decodeVLQ = function(mapping) {
21460
21499
  }
21461
21500
  return result;
21462
21501
  };
21463
- var remapPosition = function(position, sourcemapLines) {
21502
+ var remapPosition = (position, sourcemapLines) => {
21464
21503
  const [line, character] = position;
21465
21504
  const textLine = sourcemapLines[line];
21466
21505
  if (!textLine?.length) {
@@ -21493,7 +21532,7 @@ var remapPosition = function(position, sourcemapLines) {
21493
21532
  }
21494
21533
  };
21495
21534
 
21496
- // unplugin-civet:/home/daniel/apps/Civet/source/state-cache.civet.jsx
21535
+ // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\state-cache.civet.jsx
21497
21536
  var StateCache = class {
21498
21537
  cache = /* @__PURE__ */ new Map();
21499
21538
  get(key) {
@@ -21533,7 +21572,7 @@ var StateCache = class {
21533
21572
  }
21534
21573
  };
21535
21574
 
21536
- // unplugin-civet:/home/daniel/apps/Civet/source/worker-pool.civet.jsx
21575
+ // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\worker-pool.civet.jsx
21537
21576
  var WorkerPool = class {
21538
21577
  idle;
21539
21578
  spawned;
@@ -21635,7 +21674,7 @@ var WorkerPool = class {
21635
21674
  }
21636
21675
  };
21637
21676
 
21638
- // unplugin-civet:/home/daniel/apps/Civet/source/main.civet.jsx
21677
+ // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\main.civet.jsx
21639
21678
  var { SourceMap: SourceMap2 } = sourcemap_civet_exports;
21640
21679
  var ParseErrors = class extends Error {
21641
21680
  name = "ParseErrors";
@@ -21793,7 +21832,8 @@ ${counts}`;
21793
21832
  const code = generate_civet_default(ast2, options);
21794
21833
  checkErrors();
21795
21834
  if (options.inlineMap) {
21796
- return SourceMap2.remap(code, options.sourceMap, filename2, filename2 + ".tsx");
21835
+ return `${code}
21836
+ ${options.sourceMap.comment(filename2, filename2 + ".tsx")}`;
21797
21837
  } else {
21798
21838
  return {
21799
21839
  code,