@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.js CHANGED
@@ -483,7 +483,7 @@ ${body}`;
483
483
  }
484
484
  });
485
485
 
486
- // unplugin-civet:/home/daniel/apps/Civet/source/main.civet.jsx
486
+ // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\main.civet.jsx
487
487
  var main_civet_exports = {};
488
488
  __export(main_civet_exports, {
489
489
  ParseError: () => import_lib2.ParseError,
@@ -504,7 +504,7 @@ module.exports = __toCommonJS(main_civet_exports);
504
504
  // source/parser.hera
505
505
  var import_lib2 = __toESM(require_machine());
506
506
 
507
- // unplugin-civet:/home/daniel/apps/Civet/source/parser/lib.civet.jsx
507
+ // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\lib.civet.jsx
508
508
  var lib_civet_exports = {};
509
509
  __export(lib_civet_exports, {
510
510
  addPostfixStatement: () => addPostfixStatement,
@@ -515,6 +515,8 @@ __export(lib_civet_exports, {
515
515
  blockWithPrefix: () => blockWithPrefix,
516
516
  braceBlock: () => braceBlock,
517
517
  bracedBlock: () => bracedBlock,
518
+ convertArrowFunctionToMethod: () => convertArrowFunctionToMethod,
519
+ convertFunctionToMethod: () => convertFunctionToMethod,
518
520
  convertNamedImportsToObject: () => convertNamedImportsToObject,
519
521
  convertObjectToJSXAttributes: () => convertObjectToJSXAttributes,
520
522
  convertWithClause: () => convertWithClause,
@@ -584,7 +586,7 @@ __export(lib_civet_exports, {
584
586
  wrapTypeInPromise: () => wrapTypeInPromise
585
587
  });
586
588
 
587
- // unplugin-civet:/home/daniel/apps/Civet/source/parser/util.civet.jsx
589
+ // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\util.civet.jsx
588
590
  function len(arr, length) {
589
591
  return arr.length === length;
590
592
  }
@@ -1585,7 +1587,7 @@ function flatJoin(array, separator) {
1585
1587
  return result;
1586
1588
  }
1587
1589
 
1588
- // unplugin-civet:/home/daniel/apps/Civet/source/parser/traversal.civet.jsx
1590
+ // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\traversal.civet.jsx
1589
1591
  function gatherRecursiveWithinFunction(node, predicate) {
1590
1592
  return gatherRecursive(node, predicate, isFunction);
1591
1593
  }
@@ -1694,7 +1696,7 @@ function gatherRecursiveAll(node, predicate) {
1694
1696
  return nodes;
1695
1697
  }
1696
1698
 
1697
- // unplugin-civet:/home/daniel/apps/Civet/source/parser/ref.civet.jsx
1699
+ // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\ref.civet.jsx
1698
1700
  var range = (start, end) => {
1699
1701
  const length = end - start;
1700
1702
  if (length <= 0) return [];
@@ -1789,7 +1791,7 @@ function populateRefs(statements) {
1789
1791
  }
1790
1792
  }
1791
1793
 
1792
- // unplugin-civet:/home/daniel/apps/Civet/source/parser/binding.civet.jsx
1794
+ // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\binding.civet.jsx
1793
1795
  function adjustAtBindings(statements, asThis = false) {
1794
1796
  for (let ref1 = gatherRecursiveAll(statements, ($1) => $1.type === "AtBindingProperty"), i1 = 0, len3 = ref1.length; i1 < len3; i1++) {
1795
1797
  const binding = ref1[i1];
@@ -2056,12 +2058,12 @@ function gatherBindingPatternTypeSuffix(pattern) {
2056
2058
  return pattern;
2057
2059
  }
2058
2060
 
2059
- // unplugin-civet:/home/daniel/apps/Civet/source/parser/comptime.civet.jsx
2061
+ // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\comptime.civet.jsx
2060
2062
  var import_node_path = require("node:path");
2061
2063
  var import_node_module = require("node:module");
2062
2064
  var import_node_vm = __toESM(require("node:vm"));
2063
2065
 
2064
- // unplugin-civet:/home/daniel/apps/Civet/source/parser/helper.civet.jsx
2066
+ // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\helper.civet.jsx
2065
2067
  var preludeVar = "var ";
2066
2068
  function ts(children) {
2067
2069
  return {
@@ -2378,7 +2380,7 @@ function extractPreludeFor(node) {
2378
2380
  }
2379
2381
  }
2380
2382
 
2381
- // unplugin-civet:/home/daniel/apps/Civet/source/generate.civet.jsx
2383
+ // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\generate.civet.jsx
2382
2384
  function stringify(node) {
2383
2385
  try {
2384
2386
  return JSON.stringify(removeParentPointers(node));
@@ -2488,7 +2490,7 @@ function prune(node) {
2488
2490
  return node;
2489
2491
  }
2490
2492
 
2491
- // unplugin-civet:/home/daniel/apps/Civet/source/parser/comptime.civet.jsx
2493
+ // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\comptime.civet.jsx
2492
2494
  function expressionizeComptime(statement) {
2493
2495
  const { expressions } = statement.block;
2494
2496
  const expression = wrapIIFE(expressions, hasAwait(expressions));
@@ -2809,7 +2811,7 @@ function serialize(value, context) {
2809
2811
  return recurse(value);
2810
2812
  }
2811
2813
 
2812
- // unplugin-civet:/home/daniel/apps/Civet/source/parser/function.civet.jsx
2814
+ // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\function.civet.jsx
2813
2815
  var concatAssign = (lhs, rhs) => (rhs?.[Symbol.isConcatSpreadable] ?? Array.isArray(rhs) ? lhs.push.apply(lhs, rhs) : lhs.push(rhs), lhs);
2814
2816
  function getTypeArguments(args) {
2815
2817
  while (typeof args === "object" && args != null && "args" in args) {
@@ -4242,7 +4244,7 @@ function makeAmpersandFunction(rhs) {
4242
4244
  return fn;
4243
4245
  }
4244
4246
 
4245
- // unplugin-civet:/home/daniel/apps/Civet/source/parser/block.civet.jsx
4247
+ // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\block.civet.jsx
4246
4248
  function blockWithPrefix(prefixStatements, block) {
4247
4249
  if (prefixStatements && prefixStatements.length) {
4248
4250
  const expressions = [...prefixStatements, ...block.expressions];
@@ -4463,7 +4465,7 @@ function blockContainingStatement(exp) {
4463
4465
  };
4464
4466
  }
4465
4467
 
4466
- // unplugin-civet:/home/daniel/apps/Civet/source/parser/op.civet.jsx
4468
+ // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\op.civet.jsx
4467
4469
  var precedenceOrder = [
4468
4470
  ["||", "??"],
4469
4471
  ["^^"],
@@ -4799,7 +4801,7 @@ function expandChainedComparisons([first, binops]) {
4799
4801
  }
4800
4802
  }
4801
4803
 
4802
- // unplugin-civet:/home/daniel/apps/Civet/source/parser/pattern-matching.civet.jsx
4804
+ // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\pattern-matching.civet.jsx
4803
4805
  function processPatternTest(lhs, patterns) {
4804
4806
  const { ref, refAssignmentComma } = maybeRefAssignment(lhs, "m");
4805
4807
  const conditionExpression = flatJoin(patterns.map(($1) => getPatternConditions($1, ref)).map(($2) => flatJoin($2, " && ")), " || ");
@@ -5318,7 +5320,7 @@ function aliasBinding(p, ref) {
5318
5320
  }
5319
5321
  }
5320
5322
 
5321
- // unplugin-civet:/home/daniel/apps/Civet/source/parser/declaration.civet.jsx
5323
+ // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\declaration.civet.jsx
5322
5324
  function len2(arr, length) {
5323
5325
  return arr.length === length;
5324
5326
  }
@@ -5872,7 +5874,7 @@ function convertWithClause(withClause, extendsClause) {
5872
5874
  return [extendsToken, insertTrimmingSpace(ws, " "), wrapped];
5873
5875
  }
5874
5876
 
5875
- // unplugin-civet:/home/daniel/apps/Civet/source/parser/unary.civet.jsx
5877
+ // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\unary.civet.jsx
5876
5878
  function processUnaryExpression(pre, exp, post) {
5877
5879
  if (!(pre.length || post)) {
5878
5880
  return exp;
@@ -6034,7 +6036,7 @@ function processUnaryNestedExpression(pre, args, post) {
6034
6036
  return processUnaryExpression(pre, args, post);
6035
6037
  }
6036
6038
 
6037
- // unplugin-civet:/home/daniel/apps/Civet/source/parser/pipe.civet.jsx
6039
+ // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\pipe.civet.jsx
6038
6040
  function constructInvocation(fn, arg) {
6039
6041
  let expr = fn.expr;
6040
6042
  while (expr.type === "ParenthesizedExpression") {
@@ -6257,7 +6259,7 @@ function processPipelineExpressions(statements) {
6257
6259
  }
6258
6260
  }
6259
6261
 
6260
- // unplugin-civet:/home/daniel/apps/Civet/source/parser/for.civet.jsx
6262
+ // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\for.civet.jsx
6261
6263
  function processRangeExpression(start, ws1, range2, end) {
6262
6264
  ws1 = [ws1, range2.children[0]];
6263
6265
  const ws2 = range2.children[1];
@@ -6702,7 +6704,7 @@ function processForInOf($0) {
6702
6704
  };
6703
6705
  }
6704
6706
 
6705
- // unplugin-civet:/home/daniel/apps/Civet/source/parser/auto-dec.civet.jsx
6707
+ // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\auto-dec.civet.jsx
6706
6708
  var concatAssign2 = (lhs, rhs) => (rhs?.[Symbol.isConcatSpreadable] ?? Array.isArray(rhs) ? lhs.push.apply(lhs, rhs) : lhs.push(rhs), lhs);
6707
6709
  function findDecs(statements) {
6708
6710
  const declarations = gatherNodes(statements, ($) => $.type === "Declaration");
@@ -6799,7 +6801,7 @@ function createVarDecs(block, scopes, pushVar) {
6799
6801
  findAssignments(assignmentStatements2.map((s) => s.children), decs2)
6800
6802
  );
6801
6803
  }
6802
- return assignmentStatements2;
6804
+ return assignmentStatements2.filter(($4) => !($4.parent?.type === "CoffeeClassPublic"));
6803
6805
  }
6804
6806
  pushVar ??= (name) => {
6805
6807
  varIds.push(name);
@@ -6810,7 +6812,7 @@ function createVarDecs(block, scopes, pushVar) {
6810
6812
  scopes.push(decs);
6811
6813
  const varIds = [];
6812
6814
  const assignmentStatements = findAssignments(statements, scopes);
6813
- const undeclaredIdentifiers = assignmentStatements.flatMap(($4) => $4?.names || []);
6815
+ const undeclaredIdentifiers = assignmentStatements.flatMap(($5) => $5?.names || []);
6814
6816
  undeclaredIdentifiers.filter((x, i, a) => {
6815
6817
  if (!hasDec(x)) return a.indexOf(x) === i;
6816
6818
  return;
@@ -6848,7 +6850,7 @@ function createVarDecs(block, scopes, pushVar) {
6848
6850
  scopes.pop();
6849
6851
  }
6850
6852
 
6851
- // unplugin-civet:/home/daniel/apps/Civet/source/parser/string.civet.jsx
6853
+ // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\string.civet.jsx
6852
6854
  function getIndentLevel(str, tab) {
6853
6855
  if (tab != null && tab != 1) {
6854
6856
  const tabs = str.match(/\t/g);
@@ -7016,7 +7018,7 @@ function quoteString(str) {
7016
7018
  return JSON.stringify(str);
7017
7019
  }
7018
7020
 
7019
- // unplugin-civet:/home/daniel/apps/Civet/source/parser/lib.civet.jsx
7021
+ // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\lib.civet.jsx
7020
7022
  var xor = (a, b) => a ? !b && a : b;
7021
7023
  function addPostfixStatement(statement, ws, post) {
7022
7024
  const expressions = [
@@ -7688,6 +7690,45 @@ function convertMethodToFunction(method) {
7688
7690
  block
7689
7691
  };
7690
7692
  }
7693
+ function convertFunctionToMethod(id, exp) {
7694
+ const fnTokenIndex = exp.children.findIndex(function(c) {
7695
+ return c?.token?.startsWith("function");
7696
+ });
7697
+ const children = exp.children.slice();
7698
+ if (exp.generator) {
7699
+ children.splice(fnTokenIndex, 2, children[fnTokenIndex + 1], id);
7700
+ } else {
7701
+ children.splice(fnTokenIndex, 1, id);
7702
+ }
7703
+ return {
7704
+ ...exp,
7705
+ type: "MethodDefinition",
7706
+ name: id.name,
7707
+ signature: { ...exp.signature, id, name: id.name },
7708
+ children
7709
+ };
7710
+ }
7711
+ function convertArrowFunctionToMethod(id, exp) {
7712
+ const block = { ...exp.block };
7713
+ const children = exp.children.filter(function(c) {
7714
+ return !(Array.isArray(c) && c[c.length - 1]?.token?.includes("=>"));
7715
+ }).map(function(c) {
7716
+ return c === exp.block ? block : c;
7717
+ });
7718
+ children.unshift(id);
7719
+ exp = {
7720
+ ...exp,
7721
+ type: "MethodDefinition",
7722
+ name: id.name,
7723
+ signature: { ...exp.signature, id, name: id.name },
7724
+ block,
7725
+ children,
7726
+ autoBind: true
7727
+ };
7728
+ block.parent = exp;
7729
+ braceBlock(block);
7730
+ return exp;
7731
+ }
7691
7732
  function convertNamedImportsToObject(node, pattern) {
7692
7733
  const properties = node.specifiers.map((specifier) => {
7693
7734
  if (specifier.ts) {
@@ -8472,7 +8513,17 @@ function processCoffeeClasses(statements) {
8472
8513
  })()
8473
8514
  );
8474
8515
  }
8475
- const privates = expressions.filter(($15) => $15[1]?.type === "CoffeeClassPrivate");
8516
+ const public_static_function_assignments = expressions.filter(($15) => $15[1]?.type === "CoffeeClassPublic" && $15[1].assignment?.expression?.type === "FunctionExpression").map(($16) => $16[1].assignment);
8517
+ for (const public_static_function_assignment of public_static_function_assignments) {
8518
+ const id = public_static_function_assignment.lhs[0][1];
8519
+ replaceNode(public_static_function_assignment, convertFunctionToMethod(id, public_static_function_assignment.expression));
8520
+ }
8521
+ const public_static_arrow_function_assignments = expressions.filter(($17) => $17[1]?.type === "CoffeeClassPublic" && $17[1].assignment?.expression?.type === "ArrowFunction").map(($18) => $18[1].assignment);
8522
+ for (const public_static_arrow_function_assignment of public_static_arrow_function_assignments) {
8523
+ const id = public_static_arrow_function_assignment.lhs[0][1];
8524
+ replaceNode(public_static_arrow_function_assignment, convertArrowFunctionToMethod(id, public_static_arrow_function_assignment.expression));
8525
+ }
8526
+ const privates = expressions.filter(($19) => $19[1]?.type === "CoffeeClassPrivate");
8476
8527
  if (!privates.length) {
8477
8528
  continue;
8478
8529
  }
@@ -8537,7 +8588,7 @@ function processProgram(root) {
8537
8588
  root.topLevelYield ? "*" : void 0
8538
8589
  );
8539
8590
  statements = [["", rootIIFE]];
8540
- root.children = root.children.map(($16) => $16 === root.expressions ? statements : $16);
8591
+ root.children = root.children.map(($20) => $20 === root.expressions ? statements : $20);
8541
8592
  root.expressions = statements;
8542
8593
  }
8543
8594
  hoistRefDecs(statements);
@@ -8568,9 +8619,9 @@ async function processProgramAsync(root) {
8568
8619
  await processComptime(statements);
8569
8620
  }
8570
8621
  function processRepl(root, rootIIFE) {
8571
- const topBlock = gatherRecursive(rootIIFE, ($17) => $17.type === "BlockStatement")[0];
8622
+ const topBlock = gatherRecursive(rootIIFE, ($21) => $21.type === "BlockStatement")[0];
8572
8623
  let i = 0;
8573
- for (let ref23 = gatherRecursiveWithinFunction(topBlock, ($18) => $18.type === "Declaration"), i14 = 0, len11 = ref23.length; i14 < len11; i14++) {
8624
+ for (let ref23 = gatherRecursiveWithinFunction(topBlock, ($22) => $22.type === "Declaration"), i14 = 0, len11 = ref23.length; i14 < len11; i14++) {
8574
8625
  const decl = ref23[i14];
8575
8626
  if (!decl.names?.length) {
8576
8627
  continue;
@@ -8584,7 +8635,7 @@ function processRepl(root, rootIIFE) {
8584
8635
  root.expressions.splice(i++, 0, ["", `var ${decl.names.join(",")}`, ";"]);
8585
8636
  }
8586
8637
  }
8587
- for (let ref24 = gatherRecursive(topBlock, ($19) => $19.type === "FunctionExpression"), i15 = 0, len12 = ref24.length; i15 < len12; i15++) {
8638
+ for (let ref24 = gatherRecursive(topBlock, ($23) => $23.type === "FunctionExpression"), i15 = 0, len12 = ref24.length; i15 < len12; i15++) {
8588
8639
  const func = ref24[i15];
8589
8640
  if (func.name && func.parent?.type === "BlockStatement") {
8590
8641
  if (func.parent === topBlock) {
@@ -8597,7 +8648,7 @@ function processRepl(root, rootIIFE) {
8597
8648
  }
8598
8649
  }
8599
8650
  }
8600
- for (let ref25 = gatherRecursiveWithinFunction(topBlock, ($20) => $20.type === "ClassExpression"), i16 = 0, len13 = ref25.length; i16 < len13; i16++) {
8651
+ for (let ref25 = gatherRecursiveWithinFunction(topBlock, ($24) => $24.type === "ClassExpression"), i16 = 0, len13 = ref25.length; i16 < len13; i16++) {
8601
8652
  const classExp = ref25[i16];
8602
8653
  let m8;
8603
8654
  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)) {
@@ -8609,7 +8660,7 @@ function processRepl(root, rootIIFE) {
8609
8660
  function processPlaceholders(statements) {
8610
8661
  const placeholderMap = /* @__PURE__ */ new Map();
8611
8662
  const liftedIfs = /* @__PURE__ */ new Set();
8612
- for (let ref26 = gatherRecursiveAll(statements, ($21) => $21.type === "Placeholder"), i17 = 0, len14 = ref26.length; i17 < len14; i17++) {
8663
+ for (let ref26 = gatherRecursiveAll(statements, ($25) => $25.type === "Placeholder"), i17 = 0, len14 = ref26.length; i17 < len14; i17++) {
8613
8664
  const exp = ref26[i17];
8614
8665
  let ancestor;
8615
8666
  if (exp.subtype === ".") {
@@ -9997,7 +10048,7 @@ var $R9 = (0, import_lib2.$R)(new RegExp("(?=[\\/?])", "suy"));
9997
10048
  var $R10 = (0, import_lib2.$R)(new RegExp("(?=[\\/\\[{?.!@#'\u2019:])", "suy"));
9998
10049
  var $R11 = (0, import_lib2.$R)(new RegExp("%%?", "suy"));
9999
10050
  var $R12 = (0, import_lib2.$R)(new RegExp("[.\\s]", "suy"));
10000
- var $R13 = (0, import_lib2.$R)(new RegExp("[)}]", "suy"));
10051
+ var $R13 = (0, import_lib2.$R)(new RegExp("[)\\]}]", "suy"));
10001
10052
  var $R14 = (0, import_lib2.$R)(new RegExp("[+-]", "suy"));
10002
10053
  var $R15 = (0, import_lib2.$R)(new RegExp("\\+\\+|--|\u29FA|\u2014|[\\+\\-&]\\S", "suy"));
10003
10054
  var $R16 = (0, import_lib2.$R)(new RegExp(`(?=[0-9.'"tfyno])`, "suy"));
@@ -11377,7 +11428,20 @@ var NestedClassElement$0 = (0, import_lib2.$S)(Nested, ClassElement, StatementDe
11377
11428
  function NestedClassElement(ctx, state2) {
11378
11429
  return (0, import_lib2.$EVENT)(ctx, state2, "NestedClassElement", NestedClassElement$0);
11379
11430
  }
11380
- 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) {
11431
+ 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) {
11432
+ var decorators = $2;
11433
+ var declare = $3;
11434
+ var access = $4;
11435
+ var static_ = $5;
11436
+ var override = $6;
11437
+ var assignment = $7;
11438
+ return {
11439
+ type: static_ ? "CoffeeClassPublic" : "CoffeeClassPrivate",
11440
+ children: [decorators, declare, access, static_, override, assignment],
11441
+ assignment
11442
+ };
11443
+ });
11444
+ 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) {
11381
11445
  var decorators = $1;
11382
11446
  var declare = $2;
11383
11447
  var access = $3;
@@ -11403,14 +11467,14 @@ var ClassElement$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E
11403
11467
  children: [decorators, declare, access, static_, override, ...definition.children]
11404
11468
  };
11405
11469
  });
11406
- var ClassElement$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(Static, BracedBlock), function($skip, $loc, $0, $1, $2) {
11470
+ var ClassElement$2 = (0, import_lib2.$TS)((0, import_lib2.$S)(Static, BracedBlock), function($skip, $loc, $0, $1, $2) {
11407
11471
  return {
11408
11472
  type: "ClassStaticBlock",
11409
11473
  children: $0
11410
11474
  };
11411
11475
  });
11412
- var ClassElement$2 = EmptyStatement;
11413
- var ClassElement$$ = [ClassElement$0, ClassElement$1, ClassElement$2];
11476
+ var ClassElement$3 = EmptyStatement;
11477
+ var ClassElement$$ = [ClassElement$0, ClassElement$1, ClassElement$2, ClassElement$3];
11414
11478
  function ClassElement(ctx, state2) {
11415
11479
  return (0, import_lib2.$EVENT_C)(ctx, state2, "ClassElement", ClassElement$$);
11416
11480
  }
@@ -11463,37 +11527,10 @@ var FieldDefinition$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(CoffeeClassesEn
11463
11527
  var exp = $6;
11464
11528
  switch (exp.type) {
11465
11529
  case "FunctionExpression": {
11466
- const fnTokenIndex = exp.children.findIndex((c) => c?.token?.startsWith("function"));
11467
- const children = exp.children.slice();
11468
- if (exp.generator) {
11469
- children.splice(fnTokenIndex, 2, children[fnTokenIndex + 1], id);
11470
- } else {
11471
- children.splice(fnTokenIndex, 1, id);
11472
- }
11473
- return {
11474
- ...exp,
11475
- type: "MethodDefinition",
11476
- name: id.name,
11477
- signature: { ...exp.signature, id, name: id.name },
11478
- children
11479
- };
11530
+ return convertFunctionToMethod(id, exp);
11480
11531
  }
11481
11532
  case "ArrowFunction": {
11482
- const block = { ...exp.block };
11483
- const children = exp.children.filter((c) => !(Array.isArray(c) && c[c.length - 1]?.token?.includes("=>"))).map((c) => c === exp.block ? block : c);
11484
- children.unshift(id);
11485
- exp = {
11486
- ...exp,
11487
- type: "MethodDefinition",
11488
- name: id.name,
11489
- signature: { ...exp.signature, id, name: id.name },
11490
- block,
11491
- children,
11492
- autoBind: true
11493
- };
11494
- block.parent = exp;
11495
- braceBlock(block);
11496
- return exp;
11533
+ return convertArrowFunctionToMethod(id, exp);
11497
11534
  }
11498
11535
  default:
11499
11536
  return {
@@ -11520,15 +11557,7 @@ var FieldDefinition$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(InsertReadonly,
11520
11557
  readonly
11521
11558
  };
11522
11559
  });
11523
- var FieldDefinition$2 = (0, import_lib2.$TS)((0, import_lib2.$S)(CoffeeClassesEnabled, ActualAssignment), function($skip, $loc, $0, $1, $2) {
11524
- var assignment = $2;
11525
- return {
11526
- type: "CoffeeClassPrivate",
11527
- children: [assignment],
11528
- assignment
11529
- };
11530
- });
11531
- 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) {
11560
+ 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) {
11532
11561
  var abstract = $1;
11533
11562
  var readonly = $2;
11534
11563
  var id = $3;
@@ -11545,7 +11574,7 @@ var FieldDefinition$3 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2
11545
11574
  initializer
11546
11575
  };
11547
11576
  });
11548
- var FieldDefinition$$ = [FieldDefinition$0, FieldDefinition$1, FieldDefinition$2, FieldDefinition$3];
11577
+ var FieldDefinition$$ = [FieldDefinition$0, FieldDefinition$1, FieldDefinition$2];
11549
11578
  function FieldDefinition(ctx, state2) {
11550
11579
  return (0, import_lib2.$EVENT_C)(ctx, state2, "FieldDefinition", FieldDefinition$$);
11551
11580
  }
@@ -12316,7 +12345,7 @@ function ParameterElement(ctx, state2) {
12316
12345
  return (0, import_lib2.$EVENT)(ctx, state2, "ParameterElement", ParameterElement$0);
12317
12346
  }
12318
12347
  var ParameterElementDelimiter$0 = (0, import_lib2.$S)((0, import_lib2.$E)(_), Comma);
12319
- var ParameterElementDelimiter$1 = (0, import_lib2.$Y)((0, import_lib2.$S)(__, (0, import_lib2.$R$0)((0, import_lib2.$EXPECT)($R13, "ParameterElementDelimiter /[)}]/"))));
12348
+ var ParameterElementDelimiter$1 = (0, import_lib2.$Y)((0, import_lib2.$S)(__, (0, import_lib2.$R$0)((0, import_lib2.$EXPECT)($R13, "ParameterElementDelimiter /[)\\]}]/"))));
12320
12349
  var ParameterElementDelimiter$2 = (0, import_lib2.$T)((0, import_lib2.$S)((0, import_lib2.$Y)(EOS), InsertComma), function(value) {
12321
12350
  return value[1];
12322
12351
  });
@@ -14252,7 +14281,7 @@ function InlineObjectPropertyDelimiter(ctx, state2) {
14252
14281
  return (0, import_lib2.$EVENT)(ctx, state2, "InlineObjectPropertyDelimiter", InlineObjectPropertyDelimiter$0);
14253
14282
  }
14254
14283
  var ObjectPropertyDelimiter$0 = (0, import_lib2.$S)((0, import_lib2.$E)(_), Comma);
14255
- var ObjectPropertyDelimiter$1 = (0, import_lib2.$Y)((0, import_lib2.$S)(__, (0, import_lib2.$EXPECT)($L37, 'ObjectPropertyDelimiter "}"')));
14284
+ var ObjectPropertyDelimiter$1 = (0, import_lib2.$Y)((0, import_lib2.$S)(__, (0, import_lib2.$R$0)((0, import_lib2.$EXPECT)($R13, "ObjectPropertyDelimiter /[)\\]}]/"))));
14256
14285
  var ObjectPropertyDelimiter$2 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$Y)(EOS), InsertComma), function($skip, $loc, $0, $1, $2) {
14257
14286
  return { ...$2, implicit: true };
14258
14287
  });
@@ -21198,11 +21227,12 @@ var wellKnownSymbols = [
21198
21227
  "unscopables"
21199
21228
  ];
21200
21229
 
21201
- // unplugin-civet:/home/daniel/apps/Civet/source/sourcemap.civet.jsx
21230
+ // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\sourcemap.civet.jsx
21202
21231
  var sourcemap_civet_exports = {};
21203
21232
  __export(sourcemap_civet_exports, {
21204
21233
  SourceMap: () => SourceMap,
21205
21234
  base64Encode: () => base64Encode,
21235
+ decodeVLQ: () => decodeVLQ,
21206
21236
  locationTable: () => locationTable,
21207
21237
  lookupLineColumn: () => lookupLineColumn
21208
21238
  });
@@ -21238,7 +21268,6 @@ var SourceMap = class {
21238
21268
  // relative to previous entry
21239
21269
  srcLine;
21240
21270
  srcColumn;
21241
- srcOffset;
21242
21271
  srcTable;
21243
21272
  source;
21244
21273
  constructor(source1) {
@@ -21248,7 +21277,6 @@ var SourceMap = class {
21248
21277
  this.colOffset = 0;
21249
21278
  this.srcLine = 0;
21250
21279
  this.srcColumn = 0;
21251
- this.srcOffset = 0;
21252
21280
  this.srcTable = locationTable(this.source);
21253
21281
  }
21254
21282
  renderMappings() {
@@ -21292,6 +21320,10 @@ var SourceMap = class {
21292
21320
  }
21293
21321
  };
21294
21322
  }
21323
+ /** Generate a comment with the source mapping URL. */
21324
+ comment(srcFileName, outFileName) {
21325
+ return `//${"#"} sourceMappingURL=data:application/json;base64,${base64Encode(JSON.stringify(this.json(srcFileName, outFileName)))}`;
21326
+ }
21295
21327
  updateSourceMap(outputStr, inputPos, colOffset = 0) {
21296
21328
  const outLines = outputStr.split(EOL2);
21297
21329
  let srcLine, srcCol;
@@ -21300,7 +21332,6 @@ var SourceMap = class {
21300
21332
  srcCol += colOffset;
21301
21333
  this.srcLine = srcLine;
21302
21334
  this.srcColumn = srcCol;
21303
- this.srcOffset = inputPos + outputStr.length;
21304
21335
  }
21305
21336
  for (let i3 = 0, len22 = outLines.length; i3 < len22; i3++) {
21306
21337
  const i = i3;
@@ -21323,74 +21354,85 @@ var SourceMap = class {
21323
21354
  }
21324
21355
  return;
21325
21356
  }
21326
- };
21327
- var smRegexp = /\n\/\/# sourceMappingURL=data:application\/json;charset=utf-8;base64,([+a-zA-Z0-9\/]*=?=?)$/;
21328
- var remap = function(codeWithSourceMap, upstreamMap, sourcePath, targetPath) {
21329
- let sourceMapText;
21330
- const codeWithoutSourceMap = codeWithSourceMap.replace(smRegexp, (match, sm) => {
21331
- sourceMapText = sm;
21332
- return "";
21333
- });
21334
- if (sourceMapText) {
21335
- const parsed = parseWithLines(sourceMapText);
21336
- const composedLines = composeLines(upstreamMap.lines, parsed.lines);
21337
- upstreamMap.lines = composedLines;
21338
- }
21339
- const remappedSourceMapJSON = upstreamMap.json(sourcePath, targetPath);
21340
- const newSourceMap = `${"sourceMapping"}URL=data:application/json;charset=utf-8;base64,${base64Encode(JSON.stringify(remappedSourceMapJSON))}`;
21341
- const remappedCodeWithSourceMap = `${codeWithoutSourceMap}
21342
- //# ${newSourceMap}`;
21343
- return remappedCodeWithSourceMap;
21344
- };
21345
- var composeLines = function(upstreamMapping, lines) {
21346
- return lines.map((line) => {
21347
- return line.map((entry) => {
21348
- if (entry.length === 1) {
21349
- return entry;
21350
- }
21351
- const [colDelta, sourceFileIndex, srcLine, srcCol] = entry;
21352
- const srcPos = remapPosition([srcLine, srcCol], upstreamMapping);
21353
- if (!srcPos) {
21354
- return [entry[0]];
21355
- }
21356
- const [upstreamLine, upstreamCol] = srcPos;
21357
- if (entry.length === 4) {
21358
- return [colDelta, sourceFileIndex, upstreamLine, upstreamCol];
21359
- }
21360
- return [colDelta, sourceFileIndex, upstreamLine, upstreamCol, entry[4]];
21357
+ /**
21358
+ Remap a string with compiled code and a source map to use a new source map
21359
+ referencing upstream source files.
21360
+ This modifies the upstream map in place.
21361
+ */
21362
+ static remap = (codeWithSourceMap, upstreamMap, sourcePath, targetPath) => {
21363
+ let sourceMapText;
21364
+ const codeWithoutSourceMap = codeWithSourceMap.replace(smRegexp, (_match, sm) => {
21365
+ sourceMapText = sm;
21366
+ return "";
21361
21367
  });
21362
- });
21363
- };
21364
- var parseWithLines = function(base64encodedJSONstr) {
21365
- const json = JSON.parse(Buffer.from(base64encodedJSONstr, "base64").toString("utf8"));
21366
- let sourceLine = 0;
21367
- let sourceColumn = 0;
21368
- const lines = json.mappings.split(";").map((line) => {
21369
- if (line.length === 0) {
21370
- return [];
21368
+ if (sourceMapText) {
21369
+ const parsed = this.parseWithLines(sourceMapText);
21370
+ const composedLines = this.composeLines(upstreamMap.lines, parsed.lines);
21371
+ upstreamMap.lines = composedLines;
21371
21372
  }
21372
- return line.split(",").map((entry) => {
21373
- const result = decodeVLQ(entry);
21374
- switch (result.length) {
21375
- case 1: {
21376
- return [result[0]];
21377
- }
21378
- case 4: {
21379
- return [result[0], result[1], sourceLine += result[2], sourceColumn += result[3]];
21373
+ const remappedCodeWithSourceMap = `${codeWithoutSourceMap}
21374
+ ${upstreamMap.comment(sourcePath, targetPath)}`;
21375
+ return remappedCodeWithSourceMap;
21376
+ };
21377
+ /**
21378
+ Compose lines from an upstream source map with lines from a downstream source map.
21379
+ */
21380
+ static composeLines = (upstreamMapping, lines) => {
21381
+ return lines.map((line) => {
21382
+ return line.map((entry) => {
21383
+ if (entry.length === 1) {
21384
+ return entry;
21380
21385
  }
21381
- case 5: {
21382
- return [result[0], result[1], sourceLine += result[2], sourceColumn += result[3], result[4]];
21386
+ const [colDelta, sourceFileIndex, srcLine, srcCol] = entry;
21387
+ const srcPos = remapPosition([srcLine, srcCol], upstreamMapping);
21388
+ if (!srcPos) {
21389
+ return [entry[0]];
21383
21390
  }
21384
- default: {
21385
- throw new Error("Unknown source map entry", result);
21391
+ const [upstreamLine, upstreamCol] = srcPos;
21392
+ if (entry.length === 4) {
21393
+ return [colDelta, sourceFileIndex, upstreamLine, upstreamCol];
21386
21394
  }
21395
+ return [colDelta, sourceFileIndex, upstreamLine, upstreamCol, entry[4]];
21396
+ });
21397
+ });
21398
+ };
21399
+ /**
21400
+ Parse a base64 encoded source map string into a SourceMapJSON object with lines.
21401
+ */
21402
+ static parseWithLines = (base64encodedJSONstr) => {
21403
+ const json = JSON.parse(Buffer.from(base64encodedJSONstr, "base64").toString("utf8"));
21404
+ let sourceLine = 0;
21405
+ let sourceColumn = 0;
21406
+ const lines = json.mappings.split(";").map((line) => {
21407
+ if (line.length === 0) {
21408
+ return [];
21387
21409
  }
21410
+ return line.split(",").map((entry) => {
21411
+ const result = decodeVLQ(entry);
21412
+ switch (result.length) {
21413
+ case 1: {
21414
+ ;
21415
+ break;
21416
+ }
21417
+ case 4:
21418
+ case 5: {
21419
+ sourceLine += result[2];
21420
+ result[2] = sourceLine;
21421
+ sourceColumn += result[3];
21422
+ result[3] = sourceColumn;
21423
+ break;
21424
+ }
21425
+ default: {
21426
+ throw new Error(`Unknown source map entry ${JSON.stringify(result)}`);
21427
+ }
21428
+ }
21429
+ return result;
21430
+ });
21388
21431
  });
21389
- });
21390
- json.lines = lines;
21391
- return json;
21432
+ return { ...json, lines };
21433
+ };
21392
21434
  };
21393
- Object.assign(SourceMap, { remap, parseWithLines, composeLines });
21435
+ var smRegexp = /(?:\r?\n|\r)\/\/# sourceMappingURL=data:application\/json;(?:charset=[^;]*;)?base64,([+a-zA-Z0-9\/]*=?=?)(?:\s*)$/;
21394
21436
  var VLQ_SHIFT = 5;
21395
21437
  var VLQ_CONTINUATION_BIT = 1 << VLQ_SHIFT;
21396
21438
  var VLQ_VALUE_MASK = VLQ_CONTINUATION_BIT - 1;
@@ -21407,21 +21449,18 @@ var encodeVlq = function(value) {
21407
21449
  if (valueToEncode) {
21408
21450
  nextChunk |= VLQ_CONTINUATION_BIT;
21409
21451
  }
21410
- answer += encodeBase64(nextChunk);
21452
+ answer += BASE64_CHARS[nextChunk];
21411
21453
  }
21412
21454
  return answer;
21413
21455
  };
21414
21456
  var BASE64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
21415
- var encodeBase64 = function(value) {
21416
- return BASE64_CHARS[value] || (() => {
21417
- throw new Error("Cannot Base64 encode value: ${value}");
21418
- })();
21419
- };
21420
21457
  var base64Encode = function(src) {
21421
21458
  if (typeof Buffer !== "undefined") {
21422
21459
  return Buffer.from(src).toString("base64");
21423
21460
  } else {
21424
- return btoa(src);
21461
+ const bytes = new TextEncoder().encode(src);
21462
+ const binaryString = String.fromCodePoint(...bytes);
21463
+ return btoa(binaryString);
21425
21464
  }
21426
21465
  };
21427
21466
  var vlqTable = new Uint8Array(128);
@@ -21443,7 +21482,7 @@ var vlqChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/
21443
21482
  var decodeError = function(message) {
21444
21483
  throw new Error(message);
21445
21484
  };
21446
- var decodeVLQ = function(mapping) {
21485
+ var decodeVLQ = (mapping) => {
21447
21486
  let i = 0;
21448
21487
  let l = mapping.length;
21449
21488
  let result = [];
@@ -21457,11 +21496,11 @@ var decodeVLQ = function(mapping) {
21457
21496
  }
21458
21497
  const c = mapping.charCodeAt(i);
21459
21498
  if ((c & 127) != c) {
21460
- decodeError("Invalid mapping character: ${JSON.stringify(String.fromCharCode(c))}");
21499
+ decodeError(`Invalid mapping character: ${JSON.stringify(String.fromCharCode(c))}`);
21461
21500
  }
21462
21501
  const index = vlqTable[c & 127];
21463
21502
  if (index === 255) {
21464
- decodeError("Invalid mapping character: ${JSON.stringify(String.fromCharCode(c))}");
21503
+ decodeError(`Invalid mapping character: ${JSON.stringify(String.fromCharCode(c))}`);
21465
21504
  }
21466
21505
  i++;
21467
21506
  vlq |= (index & 31) << shift;
@@ -21479,7 +21518,7 @@ var decodeVLQ = function(mapping) {
21479
21518
  }
21480
21519
  return result;
21481
21520
  };
21482
- var remapPosition = function(position, sourcemapLines) {
21521
+ var remapPosition = (position, sourcemapLines) => {
21483
21522
  const [line, character] = position;
21484
21523
  const textLine = sourcemapLines[line];
21485
21524
  if (!textLine?.length) {
@@ -21512,7 +21551,7 @@ var remapPosition = function(position, sourcemapLines) {
21512
21551
  }
21513
21552
  };
21514
21553
 
21515
- // unplugin-civet:/home/daniel/apps/Civet/source/state-cache.civet.jsx
21554
+ // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\state-cache.civet.jsx
21516
21555
  var StateCache = class {
21517
21556
  cache = /* @__PURE__ */ new Map();
21518
21557
  get(key) {
@@ -21552,7 +21591,7 @@ var StateCache = class {
21552
21591
  }
21553
21592
  };
21554
21593
 
21555
- // unplugin-civet:/home/daniel/apps/Civet/source/worker-pool.civet.jsx
21594
+ // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\worker-pool.civet.jsx
21556
21595
  var WorkerPool = class {
21557
21596
  idle;
21558
21597
  spawned;
@@ -21648,7 +21687,7 @@ var WorkerPool = class {
21648
21687
  }
21649
21688
  };
21650
21689
 
21651
- // unplugin-civet:/home/daniel/apps/Civet/source/main.civet.jsx
21690
+ // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\main.civet.jsx
21652
21691
  var { SourceMap: SourceMap2 } = sourcemap_civet_exports;
21653
21692
  var ParseErrors = class extends Error {
21654
21693
  name = "ParseErrors";
@@ -21806,7 +21845,8 @@ ${counts}`;
21806
21845
  const code = generate_civet_default(ast2, options);
21807
21846
  checkErrors();
21808
21847
  if (options.inlineMap) {
21809
- return SourceMap2.remap(code, options.sourceMap, filename2, filename2 + ".tsx");
21848
+ return `${code}
21849
+ ${options.sourceMap.comment(filename2, filename2 + ".tsx")}`;
21810
21850
  } else {
21811
21851
  return {
21812
21852
  code,