@danielx/civet 0.10.3 → 0.10.5

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:C:\Users\edemaine\Projects\Civet\source\parser\lib.civet.jsx
488
+ // unplugin-civet:/home/daniel/apps/Civet/source/parser/lib.civet.jsx
489
489
  var lib_civet_exports = {};
490
490
  __export(lib_civet_exports, {
491
491
  addPostfixStatement: () => addPostfixStatement,
@@ -565,7 +565,7 @@ __export(lib_civet_exports, {
565
565
  wrapTypeInPromise: () => wrapTypeInPromise
566
566
  });
567
567
 
568
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\util.civet.jsx
568
+ // unplugin-civet:/home/daniel/apps/Civet/source/parser/util.civet.jsx
569
569
  function len(arr, length) {
570
570
  return arr.length === length;
571
571
  }
@@ -1469,6 +1469,8 @@ function wrapIIFE(expressions, asyncFlag, generatorStar) {
1469
1469
  },
1470
1470
  parameters,
1471
1471
  returnType: void 0,
1472
+ implicitReturn: true,
1473
+ // force implicit return in IIFE
1472
1474
  children: generator.length ? [async, "function", generator, parameters] : [async, parameters]
1473
1475
  };
1474
1476
  let fn;
@@ -1564,7 +1566,7 @@ function flatJoin(array, separator) {
1564
1566
  return result;
1565
1567
  }
1566
1568
 
1567
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\traversal.civet.jsx
1569
+ // unplugin-civet:/home/daniel/apps/Civet/source/parser/traversal.civet.jsx
1568
1570
  function gatherRecursiveWithinFunction(node, predicate) {
1569
1571
  return gatherRecursive(node, predicate, isFunction);
1570
1572
  }
@@ -1673,7 +1675,7 @@ function gatherRecursiveAll(node, predicate) {
1673
1675
  return nodes;
1674
1676
  }
1675
1677
 
1676
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\ref.civet.jsx
1678
+ // unplugin-civet:/home/daniel/apps/Civet/source/parser/ref.civet.jsx
1677
1679
  var range = (start, end) => {
1678
1680
  const length = end - start;
1679
1681
  if (length <= 0) return [];
@@ -1768,7 +1770,7 @@ function populateRefs(statements) {
1768
1770
  }
1769
1771
  }
1770
1772
 
1771
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\binding.civet.jsx
1773
+ // unplugin-civet:/home/daniel/apps/Civet/source/parser/binding.civet.jsx
1772
1774
  function adjustAtBindings(statements, asThis = false) {
1773
1775
  for (let ref1 = gatherRecursiveAll(statements, ($1) => $1.type === "AtBindingProperty"), i1 = 0, len3 = ref1.length; i1 < len3; i1++) {
1774
1776
  const binding = ref1[i1];
@@ -2035,12 +2037,12 @@ function gatherBindingPatternTypeSuffix(pattern) {
2035
2037
  return pattern;
2036
2038
  }
2037
2039
 
2038
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\comptime.civet.jsx
2040
+ // unplugin-civet:/home/daniel/apps/Civet/source/parser/comptime.civet.jsx
2039
2041
  import { resolve, dirname } from "node:path";
2040
2042
  import { createRequire } from "node:module";
2041
2043
  import vm from "node:vm";
2042
2044
 
2043
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\helper.civet.jsx
2045
+ // unplugin-civet:/home/daniel/apps/Civet/source/parser/helper.civet.jsx
2044
2046
  var preludeVar = "var ";
2045
2047
  function ts(children) {
2046
2048
  return {
@@ -2357,7 +2359,7 @@ function extractPreludeFor(node) {
2357
2359
  }
2358
2360
  }
2359
2361
 
2360
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\generate.civet.jsx
2362
+ // unplugin-civet:/home/daniel/apps/Civet/source/generate.civet.jsx
2361
2363
  function stringify(node) {
2362
2364
  try {
2363
2365
  return JSON.stringify(removeParentPointers(node));
@@ -2467,7 +2469,7 @@ function prune(node) {
2467
2469
  return node;
2468
2470
  }
2469
2471
 
2470
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\comptime.civet.jsx
2472
+ // unplugin-civet:/home/daniel/apps/Civet/source/parser/comptime.civet.jsx
2471
2473
  function expressionizeComptime(statement) {
2472
2474
  const { expressions } = statement.block;
2473
2475
  const expression = wrapIIFE(expressions, hasAwait(expressions));
@@ -2788,7 +2790,7 @@ function serialize(value, context) {
2788
2790
  return recurse(value);
2789
2791
  }
2790
2792
 
2791
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\function.civet.jsx
2793
+ // unplugin-civet:/home/daniel/apps/Civet/source/parser/function.civet.jsx
2792
2794
  var concatAssign = (lhs, rhs) => (rhs?.[Symbol.isConcatSpreadable] ?? Array.isArray(rhs) ? lhs.push.apply(lhs, rhs) : lhs.push(rhs), lhs);
2793
2795
  function getTypeArguments(args) {
2794
2796
  while (typeof args === "object" && args != null && "args" in args) {
@@ -2876,7 +2878,7 @@ function processReturn(f, implicitReturns) {
2876
2878
  if (returnType && returnType.optional) {
2877
2879
  convertOptionalType(returnType);
2878
2880
  }
2879
- if (!processReturnValue(f) && implicitReturns) {
2881
+ if (!processReturnValue(f) && (implicitReturns || f.signature.implicitReturn)) {
2880
2882
  const { signature, block } = f;
2881
2883
  const { modifier, name, returnType: returnType2 } = signature;
2882
2884
  const { async, generator, set } = modifier;
@@ -4221,7 +4223,7 @@ function makeAmpersandFunction(rhs) {
4221
4223
  return fn;
4222
4224
  }
4223
4225
 
4224
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\block.civet.jsx
4226
+ // unplugin-civet:/home/daniel/apps/Civet/source/parser/block.civet.jsx
4225
4227
  function blockWithPrefix(prefixStatements, block) {
4226
4228
  if (prefixStatements && prefixStatements.length) {
4227
4229
  const expressions = [...prefixStatements, ...block.expressions];
@@ -4442,7 +4444,7 @@ function blockContainingStatement(exp) {
4442
4444
  };
4443
4445
  }
4444
4446
 
4445
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\op.civet.jsx
4447
+ // unplugin-civet:/home/daniel/apps/Civet/source/parser/op.civet.jsx
4446
4448
  var precedenceOrder = [
4447
4449
  ["||", "??"],
4448
4450
  ["^^"],
@@ -4778,7 +4780,7 @@ function expandChainedComparisons([first, binops]) {
4778
4780
  }
4779
4781
  }
4780
4782
 
4781
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\pattern-matching.civet.jsx
4783
+ // unplugin-civet:/home/daniel/apps/Civet/source/parser/pattern-matching.civet.jsx
4782
4784
  function processPatternTest(lhs, patterns) {
4783
4785
  const { ref, refAssignmentComma } = maybeRefAssignment(lhs, "m");
4784
4786
  const conditionExpression = flatJoin(patterns.map(($1) => getPatternConditions($1, ref)).map(($2) => flatJoin($2, " && ")), " || ");
@@ -5297,7 +5299,7 @@ function aliasBinding(p, ref) {
5297
5299
  }
5298
5300
  }
5299
5301
 
5300
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\declaration.civet.jsx
5302
+ // unplugin-civet:/home/daniel/apps/Civet/source/parser/declaration.civet.jsx
5301
5303
  function len2(arr, length) {
5302
5304
  return arr.length === length;
5303
5305
  }
@@ -5851,7 +5853,7 @@ function convertWithClause(withClause, extendsClause) {
5851
5853
  return [extendsToken, insertTrimmingSpace(ws, " "), wrapped];
5852
5854
  }
5853
5855
 
5854
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\unary.civet.jsx
5856
+ // unplugin-civet:/home/daniel/apps/Civet/source/parser/unary.civet.jsx
5855
5857
  function processUnaryExpression(pre, exp, post) {
5856
5858
  if (!(pre.length || post)) {
5857
5859
  return exp;
@@ -6013,7 +6015,7 @@ function processUnaryNestedExpression(pre, args, post) {
6013
6015
  return processUnaryExpression(pre, args, post);
6014
6016
  }
6015
6017
 
6016
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\pipe.civet.jsx
6018
+ // unplugin-civet:/home/daniel/apps/Civet/source/parser/pipe.civet.jsx
6017
6019
  function constructInvocation(fn, arg) {
6018
6020
  let expr = fn.expr;
6019
6021
  while (expr.type === "ParenthesizedExpression") {
@@ -6236,7 +6238,7 @@ function processPipelineExpressions(statements) {
6236
6238
  }
6237
6239
  }
6238
6240
 
6239
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\for.civet.jsx
6241
+ // unplugin-civet:/home/daniel/apps/Civet/source/parser/for.civet.jsx
6240
6242
  function processRangeExpression(start, ws1, range2, end) {
6241
6243
  ws1 = [ws1, range2.children[0]];
6242
6244
  const ws2 = range2.children[1];
@@ -6681,7 +6683,7 @@ function processForInOf($0) {
6681
6683
  };
6682
6684
  }
6683
6685
 
6684
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\auto-dec.civet.jsx
6686
+ // unplugin-civet:/home/daniel/apps/Civet/source/parser/auto-dec.civet.jsx
6685
6687
  var concatAssign2 = (lhs, rhs) => (rhs?.[Symbol.isConcatSpreadable] ?? Array.isArray(rhs) ? lhs.push.apply(lhs, rhs) : lhs.push(rhs), lhs);
6686
6688
  function findDecs(statements) {
6687
6689
  const declarations = gatherNodes(statements, ($) => $.type === "Declaration");
@@ -6827,7 +6829,7 @@ function createVarDecs(block, scopes, pushVar) {
6827
6829
  scopes.pop();
6828
6830
  }
6829
6831
 
6830
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\string.civet.jsx
6832
+ // unplugin-civet:/home/daniel/apps/Civet/source/parser/string.civet.jsx
6831
6833
  function getIndentLevel(str, tab) {
6832
6834
  if (tab != null && tab != 1) {
6833
6835
  const tabs = str.match(/\t/g);
@@ -6995,7 +6997,7 @@ function quoteString(str) {
6995
6997
  return JSON.stringify(str);
6996
6998
  }
6997
6999
 
6998
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\lib.civet.jsx
7000
+ // unplugin-civet:/home/daniel/apps/Civet/source/parser/lib.civet.jsx
6999
7001
  var xor = (a, b) => a ? !b && a : b;
7000
7002
  function addPostfixStatement(statement, ws, post) {
7001
7003
  const expressions = [
@@ -8990,6 +8992,7 @@ var grammar = {
8990
8992
  AccessModifier,
8991
8993
  FieldDefinition,
8992
8994
  ThisLiteral,
8995
+ BasicThisLiteral,
8993
8996
  HashThis,
8994
8997
  LengthShorthand,
8995
8998
  AtThis,
@@ -11355,23 +11358,30 @@ var NestedClassElement$0 = (0, import_lib2.$S)(Nested, ClassElement, StatementDe
11355
11358
  function NestedClassElement(ctx, state2) {
11356
11359
  return (0, import_lib2.$EVENT)(ctx, state2, "NestedClassElement", NestedClassElement$0);
11357
11360
  }
11358
- var ClassElement$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(Decorators), (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) {
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) {
11359
11362
  var decorators = $1;
11360
- var definition = $5;
11363
+ var declare = $2;
11364
+ var access = $3;
11365
+ var static_ = $4;
11366
+ var override = $5;
11367
+ var definition = $6;
11368
+ const ts2 = definition.ts || !!declare;
11361
11369
  if (definition.type === "MultiMethodDefinition") {
11362
11370
  return {
11363
11371
  ...definition,
11372
+ ts: ts2,
11364
11373
  children: definition.children.map((c) => {
11365
11374
  return {
11366
11375
  ...c,
11367
- children: [decorators, ...c.children]
11376
+ children: [decorators, declare, access, static_, override, ...c.children]
11368
11377
  };
11369
11378
  })
11370
11379
  };
11371
11380
  }
11372
11381
  return {
11373
11382
  ...definition,
11374
- children: [decorators, $2, $3, $4, ...definition.children]
11383
+ ts: ts2,
11384
+ children: [decorators, declare, access, static_, override, ...definition.children]
11375
11385
  };
11376
11386
  });
11377
11387
  var ClassElement$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(Static, BracedBlock), function($skip, $loc, $0, $1, $2) {
@@ -11520,11 +11530,8 @@ var FieldDefinition$$ = [FieldDefinition$0, FieldDefinition$1, FieldDefinition$2
11520
11530
  function FieldDefinition(ctx, state2) {
11521
11531
  return (0, import_lib2.$EVENT_C)(ctx, state2, "FieldDefinition", FieldDefinition$$);
11522
11532
  }
11523
- var ThisLiteral$0 = (0, import_lib2.$T)((0, import_lib2.$S)(This), function(value) {
11524
- return { "type": "Identifier", "name": "this", "children": [value[0]] };
11525
- });
11526
- var ThisLiteral$1 = HashThis;
11527
- var ThisLiteral$2 = (0, import_lib2.$TS)((0, import_lib2.$S)(AtThis, (0, import_lib2.$TEXT)((0, import_lib2.$S)((0, import_lib2.$E)(Hash), IdentifierName))), function($skip, $loc, $0, $1, $2) {
11533
+ var ThisLiteral$0 = HashThis;
11534
+ var ThisLiteral$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(AtThis, (0, import_lib2.$TEXT)((0, import_lib2.$S)((0, import_lib2.$E)(Hash), IdentifierName))), function($skip, $loc, $0, $1, $2) {
11528
11535
  var at = $1;
11529
11536
  var id = $2;
11530
11537
  return {
@@ -11543,11 +11550,19 @@ var ThisLiteral$2 = (0, import_lib2.$TS)((0, import_lib2.$S)(AtThis, (0, import_
11543
11550
  thisShorthand: true
11544
11551
  };
11545
11552
  });
11546
- var ThisLiteral$3 = AtThis;
11547
- var ThisLiteral$$ = [ThisLiteral$0, ThisLiteral$1, ThisLiteral$2, ThisLiteral$3];
11553
+ var ThisLiteral$2 = BasicThisLiteral;
11554
+ var ThisLiteral$$ = [ThisLiteral$0, ThisLiteral$1, ThisLiteral$2];
11548
11555
  function ThisLiteral(ctx, state2) {
11549
11556
  return (0, import_lib2.$EVENT_C)(ctx, state2, "ThisLiteral", ThisLiteral$$);
11550
11557
  }
11558
+ var BasicThisLiteral$0 = (0, import_lib2.$T)((0, import_lib2.$S)(This), function(value) {
11559
+ return { "type": "Identifier", "name": "this", "children": [value[0]] };
11560
+ });
11561
+ var BasicThisLiteral$1 = AtThis;
11562
+ var BasicThisLiteral$$ = [BasicThisLiteral$0, BasicThisLiteral$1];
11563
+ function BasicThisLiteral(ctx, state2) {
11564
+ return (0, import_lib2.$EVENT_C)(ctx, state2, "BasicThisLiteral", BasicThisLiteral$$);
11565
+ }
11551
11566
  var HashThis$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(AtThis), LengthShorthand, (0, import_lib2.$E)((0, import_lib2.$S)((0, import_lib2.$Y)((0, import_lib2.$S)(_, (0, import_lib2.$E)((0, import_lib2.$S)(Not, __)), ActualIn)), (0, import_lib2.$EXPECT)($L0, 'HashThis ""')))), function($skip, $loc, $0, $1, $2, $3) {
11552
11567
  var at = $1;
11553
11568
  var id = $2;
@@ -11584,7 +11599,7 @@ var HashThis$$ = [HashThis$0, HashThis$1, HashThis$2];
11584
11599
  function HashThis(ctx, state2) {
11585
11600
  return (0, import_lib2.$EVENT_C)(ctx, state2, "HashThis", HashThis$$);
11586
11601
  }
11587
- var LengthShorthand$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(Hash, NonIdContinue), function($skip, $loc, $0, $1, $2) {
11602
+ var LengthShorthand$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$N)(CoffeeCommentEnabled), Hash, NonIdContinue), function($skip, $loc, $0, $1, $2, $3) {
11588
11603
  const id = "length";
11589
11604
  return {
11590
11605
  type: "Identifier",
@@ -12337,7 +12352,15 @@ var AtIdentifierRef$$ = [AtIdentifierRef$0, AtIdentifierRef$1];
12337
12352
  function AtIdentifierRef(ctx, state2) {
12338
12353
  return (0, import_lib2.$EVENT_C)(ctx, state2, "AtIdentifierRef", AtIdentifierRef$$);
12339
12354
  }
12340
- var PinPattern$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(Caret, SingleLineExpressionWithIndentedApplicationForbidden), function($skip, $loc, $0, $1, $2) {
12355
+ var PinPattern$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(Caret, IdentifierName, (0, import_lib2.$Y)(Colon)), function($skip, $loc, $0, $1, $2, $3) {
12356
+ var expression = $2;
12357
+ return {
12358
+ type: "PinPattern",
12359
+ children: [expression],
12360
+ expression
12361
+ };
12362
+ });
12363
+ var PinPattern$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(Caret, SingleLineExpressionWithIndentedApplicationForbidden), function($skip, $loc, $0, $1, $2) {
12341
12364
  var expression = $2;
12342
12365
  return {
12343
12366
  type: "PinPattern",
@@ -12345,7 +12368,7 @@ var PinPattern$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(Caret, SingleLineExp
12345
12368
  expression
12346
12369
  };
12347
12370
  });
12348
- var PinPattern$1 = (0, import_lib2.$TV)(ActualMemberExpression, function($skip, $loc, $0, $1) {
12371
+ var PinPattern$2 = (0, import_lib2.$TV)(ActualMemberExpression, function($skip, $loc, $0, $1) {
12349
12372
  var expression = $0;
12350
12373
  return {
12351
12374
  type: "PinPattern",
@@ -12353,7 +12376,7 @@ var PinPattern$1 = (0, import_lib2.$TV)(ActualMemberExpression, function($skip,
12353
12376
  expression
12354
12377
  };
12355
12378
  });
12356
- var PinPattern$2 = (0, import_lib2.$TV)((0, import_lib2.$S)((0, import_lib2.$EXPECT)($R14, "PinPattern /[+-]/"), NumericLiteral), function($skip, $loc, $0, $1) {
12379
+ var PinPattern$3 = (0, import_lib2.$TV)((0, import_lib2.$S)((0, import_lib2.$EXPECT)($R14, "PinPattern /[+-]/"), NumericLiteral), function($skip, $loc, $0, $1) {
12357
12380
  var expression = $0;
12358
12381
  return {
12359
12382
  type: "PinPattern",
@@ -12361,7 +12384,7 @@ var PinPattern$2 = (0, import_lib2.$TV)((0, import_lib2.$S)((0, import_lib2.$EXP
12361
12384
  expression
12362
12385
  };
12363
12386
  });
12364
- var PinPattern$3 = (0, import_lib2.$TV)(Undefined, function($skip, $loc, $0, $1) {
12387
+ var PinPattern$4 = (0, import_lib2.$TV)(Undefined, function($skip, $loc, $0, $1) {
12365
12388
  var expression = $0;
12366
12389
  return {
12367
12390
  type: "PinPattern",
@@ -12369,7 +12392,7 @@ var PinPattern$3 = (0, import_lib2.$TV)(Undefined, function($skip, $loc, $0, $1)
12369
12392
  expression
12370
12393
  };
12371
12394
  });
12372
- var PinPattern$$ = [PinPattern$0, PinPattern$1, PinPattern$2, PinPattern$3];
12395
+ var PinPattern$$ = [PinPattern$0, PinPattern$1, PinPattern$2, PinPattern$3, PinPattern$4];
12373
12396
  function PinPattern(ctx, state2) {
12374
12397
  return (0, import_lib2.$EVENT_C)(ctx, state2, "PinPattern", PinPattern$$);
12375
12398
  }
@@ -19868,7 +19891,14 @@ var TypeIdentifier$1 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.
19868
19891
  args
19869
19892
  };
19870
19893
  });
19871
- var TypeIdentifier$$ = [TypeIdentifier$0, TypeIdentifier$1];
19894
+ var TypeIdentifier$2 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), BasicThisLiteral), function($skip, $loc, $0, $1, $2) {
19895
+ return {
19896
+ type: "TypeIdentifier",
19897
+ children: $0,
19898
+ raw: $2.name
19899
+ };
19900
+ });
19901
+ var TypeIdentifier$$ = [TypeIdentifier$0, TypeIdentifier$1, TypeIdentifier$2];
19872
19902
  function TypeIdentifier(ctx, state2) {
19873
19903
  return (0, import_lib2.$EVENT_C)(ctx, state2, "TypeIdentifier", TypeIdentifier$$);
19874
19904
  }
@@ -21149,7 +21179,7 @@ var wellKnownSymbols = [
21149
21179
  "unscopables"
21150
21180
  ];
21151
21181
 
21152
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\sourcemap.civet.jsx
21182
+ // unplugin-civet:/home/daniel/apps/Civet/source/sourcemap.civet.jsx
21153
21183
  var sourcemap_civet_exports = {};
21154
21184
  __export(sourcemap_civet_exports, {
21155
21185
  SourceMap: () => SourceMap,
@@ -21463,7 +21493,7 @@ var remapPosition = function(position, sourcemapLines) {
21463
21493
  }
21464
21494
  };
21465
21495
 
21466
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\state-cache.civet.jsx
21496
+ // unplugin-civet:/home/daniel/apps/Civet/source/state-cache.civet.jsx
21467
21497
  var StateCache = class {
21468
21498
  cache = /* @__PURE__ */ new Map();
21469
21499
  get(key) {
@@ -21503,7 +21533,7 @@ var StateCache = class {
21503
21533
  }
21504
21534
  };
21505
21535
 
21506
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\worker-pool.civet.jsx
21536
+ // unplugin-civet:/home/daniel/apps/Civet/source/worker-pool.civet.jsx
21507
21537
  var WorkerPool = class {
21508
21538
  idle;
21509
21539
  spawned;
@@ -21605,7 +21635,7 @@ var WorkerPool = class {
21605
21635
  }
21606
21636
  };
21607
21637
 
21608
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\main.civet.jsx
21638
+ // unplugin-civet:/home/daniel/apps/Civet/source/main.civet.jsx
21609
21639
  var { SourceMap: SourceMap2 } = sourcemap_civet_exports;
21610
21640
  var ParseErrors = class extends Error {
21611
21641
  name = "ParseErrors";
@@ -1,4 +1,4 @@
1
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\node-worker.civet.jsx
1
+ // unplugin-civet:/home/daniel/apps/Civet/source/node-worker.civet.jsx
2
2
  import { parentPort } from "node:worker_threads";
3
3
  import module from "node:module";
4
4
  try {
package/dist/types.d.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  declare module "@danielx/civet" {
2
2
  export type CivetAST = unknown
3
3
  export type ParseOptions = Partial<{
4
- autoVar: boolean
4
+ autoConst: boolean
5
5
  autoLet: boolean
6
+ autoVar: boolean
6
7
  coffeeBinaryExistential: boolean
7
8
  coffeeBooleans: boolean
8
9
  coffeeClasses: boolean
@@ -26,7 +26,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  ));
27
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
28
 
29
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\unplugin\astro.civet.jsx
29
+ // unplugin-civet:/home/daniel/apps/Civet/source/unplugin/astro.civet.jsx
30
30
  var astro_civet_exports = {};
31
31
  __export(astro_civet_exports, {
32
32
  default: () => astro_civet_default
@@ -1,4 +1,4 @@
1
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\unplugin\astro.civet.jsx
1
+ // unplugin-civet:/home/daniel/apps/Civet/source/unplugin/astro.civet.jsx
2
2
  import civetUnplugin, {} from "./unplugin.mjs";
3
3
  var astro_civet_default = function(opts = {}) {
4
4
  return {
@@ -26,7 +26,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  ));
27
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
28
 
29
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\unplugin\esbuild.civet.jsx
29
+ // unplugin-civet:/home/daniel/apps/Civet/source/unplugin/esbuild.civet.jsx
30
30
  var esbuild_civet_exports = {};
31
31
  __export(esbuild_civet_exports, {
32
32
  default: () => esbuild_civet_default
@@ -1,4 +1,4 @@
1
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\unplugin\esbuild.civet.jsx
1
+ // unplugin-civet:/home/daniel/apps/Civet/source/unplugin/esbuild.civet.jsx
2
2
  import civetUnplugin from "./unplugin.mjs";
3
3
  var esbuild_civet_default = civetUnplugin.esbuild;
4
4
  export {
@@ -26,7 +26,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  ));
27
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
28
 
29
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\unplugin\farm.civet.jsx
29
+ // unplugin-civet:/home/daniel/apps/Civet/source/unplugin/farm.civet.jsx
30
30
  var farm_civet_exports = {};
31
31
  __export(farm_civet_exports, {
32
32
  default: () => farm_civet_default
@@ -1,4 +1,4 @@
1
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\unplugin\farm.civet.jsx
1
+ // unplugin-civet:/home/daniel/apps/Civet/source/unplugin/farm.civet.jsx
2
2
  import civetUnplugin from "./unplugin.mjs";
3
3
  var farm_civet_default = civetUnplugin.farm;
4
4
  export {
@@ -26,7 +26,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  ));
27
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
28
 
29
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\unplugin\rolldown.civet.jsx
29
+ // unplugin-civet:/home/daniel/apps/Civet/source/unplugin/rolldown.civet.jsx
30
30
  var rolldown_civet_exports = {};
31
31
  __export(rolldown_civet_exports, {
32
32
  default: () => rolldown_civet_default
@@ -1,4 +1,4 @@
1
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\unplugin\rolldown.civet.jsx
1
+ // unplugin-civet:/home/daniel/apps/Civet/source/unplugin/rolldown.civet.jsx
2
2
  import civetUnplugin from "./unplugin.mjs";
3
3
  var rolldown_civet_default = civetUnplugin.rolldown;
4
4
  export {
@@ -26,7 +26,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  ));
27
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
28
 
29
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\unplugin\rollup.civet.jsx
29
+ // unplugin-civet:/home/daniel/apps/Civet/source/unplugin/rollup.civet.jsx
30
30
  var rollup_civet_exports = {};
31
31
  __export(rollup_civet_exports, {
32
32
  default: () => rollup_civet_default
@@ -1,4 +1,4 @@
1
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\unplugin\rollup.civet.jsx
1
+ // unplugin-civet:/home/daniel/apps/Civet/source/unplugin/rollup.civet.jsx
2
2
  import civetUnplugin from "./unplugin.mjs";
3
3
  var rollup_civet_default = civetUnplugin.rollup;
4
4
  export {
@@ -26,7 +26,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  ));
27
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
28
 
29
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\unplugin\rspack.civet.jsx
29
+ // unplugin-civet:/home/daniel/apps/Civet/source/unplugin/rspack.civet.jsx
30
30
  var rspack_civet_exports = {};
31
31
  __export(rspack_civet_exports, {
32
32
  default: () => rspack_civet_default
@@ -1,4 +1,4 @@
1
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\unplugin\rspack.civet.jsx
1
+ // unplugin-civet:/home/daniel/apps/Civet/source/unplugin/rspack.civet.jsx
2
2
  import civetUnplugin from "./unplugin.mjs";
3
3
  var rspack_civet_default = civetUnplugin.rspack;
4
4
  export {
@@ -26,7 +26,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  ));
27
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
28
 
29
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\unplugin\unplugin.civet.jsx
29
+ // unplugin-civet:/home/daniel/apps/Civet/source/unplugin/unplugin.civet.jsx
30
30
  var unplugin_civet_exports = {};
31
31
  __export(unplugin_civet_exports, {
32
32
  default: () => unplugin_civet_default,
@@ -46,24 +46,26 @@ var import_os = __toESM(require("os"));
46
46
  // source/unplugin/constants.mjs
47
47
  var DEFAULT_EXTENSIONS = [".mjs", ".js", ".mts", ".ts", ".jsx", ".tsx", ".json"];
48
48
 
49
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\unplugin\unplugin.civet.jsx
49
+ // unplugin-civet:/home/daniel/apps/Civet/source/unplugin/unplugin.civet.jsx
50
50
  var DiagnosticCategory = {};
51
51
  DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning";
52
52
  DiagnosticCategory[DiagnosticCategory["Error"] = 1] = "Error";
53
53
  DiagnosticCategory[DiagnosticCategory["Suggestion"] = 2] = "Suggestion";
54
54
  DiagnosticCategory[DiagnosticCategory["Message"] = 3] = "Message";
55
- var civetExtension = /\.civet$/;
56
- var isCivetTranspiled = /(\.civet)(\.[jt]sx)?([?#].*)?$/;
57
55
  var postfixRE = /[?#].*$/s;
58
56
  var isWindows = import_os.default.platform() === "win32";
59
57
  var windowsSlashRE = /\\/g;
60
- function cleanCivetId(id) {
58
+ var civetSuffix = ".civet";
59
+ function extractCivetFilename(id, outputExtension) {
61
60
  let postfix = "";
62
- id = id.replace(postfixRE, (match) => {
61
+ let filename = id.replace(postfixRE, (match) => {
63
62
  postfix = match;
64
63
  return "";
65
- }).replace(/\.[jt]sx$/, "");
66
- return { id, postfix };
64
+ });
65
+ if (filename.endsWith(outputExtension)) {
66
+ filename = filename.slice(0, -outputExtension.length);
67
+ }
68
+ return { filename, postfix };
67
69
  }
68
70
  function tryStatSync(file) {
69
71
  try {
@@ -359,10 +361,8 @@ var rawPlugin = (options = {}, meta) => {
359
361
  } else {
360
362
  console.log(`WARNING: No .d.ts extension in ${filePath}`);
361
363
  }
362
- let ref1;
363
- if (ref1 = filePath.match(civetExtension)) {
364
- const match = ref1;
365
- filePath = filePath.slice(0, -match[0].length);
364
+ if (filePath.endsWith(civetSuffix)) {
365
+ filePath = filePath.slice(0, -civetSuffix.length);
366
366
  } else {
367
367
  console.log(`WARNING: No .civet extension in ${filePath}`);
368
368
  }
@@ -395,38 +395,36 @@ var rawPlugin = (options = {}, meta) => {
395
395
  id = aliasResolver(id);
396
396
  }
397
397
  if (/\0/.test(id)) return null;
398
- let postfix;
399
- ({ id, postfix } = cleanCivetId(id));
400
- let ref2;
401
- if (import_path.default.isAbsolute(id)) {
402
- ref2 = resolveAbsolutePath(rootDir, id, implicitExtension);
398
+ const { filename, postfix } = extractCivetFilename(id, outExt);
399
+ let ref1;
400
+ if (import_path.default.isAbsolute(filename)) {
401
+ ref1 = resolveAbsolutePath(rootDir, filename, implicitExtension);
403
402
  } else {
404
- ref2 = import_path.default.resolve(import_path.default.dirname(importer ?? ""), id);
403
+ ref1 = import_path.default.resolve(import_path.default.dirname(importer ?? ""), filename);
405
404
  }
406
405
  ;
407
- let resolvedId = ref2;
408
- if (!resolvedId) return null;
409
- if (!resolvedId.endsWith(".civet")) {
406
+ let resolved = ref1;
407
+ if (!resolved) return null;
408
+ if (!resolved.endsWith(civetSuffix)) {
410
409
  if (!implicitExtension) return null;
411
- const implicitId = implicitCivet(resolvedId);
410
+ const implicitId = implicitCivet(resolved);
412
411
  if (!implicitId) return null;
413
- resolvedId = implicitId;
412
+ resolved = implicitId;
414
413
  }
415
414
  if (options2.scan && meta.framework === "vite") {
416
- resolvedId = `\0${resolvedId}`;
415
+ resolved = `\0${resolved}`;
417
416
  }
418
- return resolvedId + outExt + postfix;
417
+ return resolved + outExt + postfix;
419
418
  },
420
419
  loadInclude(id) {
421
- return isCivetTranspiled.test(id);
420
+ return extractCivetFilename(id, outExt).filename.endsWith(civetSuffix);
422
421
  },
423
422
  async load(id) {
424
- const match = isCivetTranspiled.exec(id);
425
- if (!match) {
423
+ let { filename } = extractCivetFilename(id, outExt);
424
+ if (!filename.endsWith(civetSuffix)) {
426
425
  return null;
427
426
  }
428
- const basename = id.slice(0, match.index + match[1].length);
429
- const filename = import_path.default.resolve(rootDir, basename);
427
+ filename = import_path.default.resolve(rootDir, filename);
430
428
  this.addWatchFile(filename);
431
429
  let mtime, cached, resolve;
432
430
  if (cache != null) {
@@ -440,9 +438,9 @@ var rawPlugin = (options = {}, meta) => {
440
438
  if (cached.promise) {
441
439
  await cached.promise;
442
440
  }
443
- let ref3;
444
- if ((ref3 = cached.result) != null) {
445
- const result = ref3;
441
+ let ref2;
442
+ if ((ref2 = cached.result) != null) {
443
+ const result = ref2;
446
444
  return result;
447
445
  }
448
446
  }
@@ -518,8 +516,8 @@ var rawPlugin = (options = {}, meta) => {
518
516
  }
519
517
  }
520
518
  if (transformTS) {
521
- for (let ref4 = import_civet.lib.gatherRecursive(ast, ($) => $.type === "ModuleSpecifier"), i = 0, len = ref4.length; i < len; i++) {
522
- const _spec = ref4[i];
519
+ for (let ref3 = import_civet.lib.gatherRecursive(ast, ($) => $.type === "ModuleSpecifier"), i = 0, len = ref3.length; i < len; i++) {
520
+ const _spec = ref3[i];
523
521
  const spec = _spec;
524
522
  if (spec.module?.input) {
525
523
  spec.module.token = spec.module.input.replace(/\.([mc])?ts(['"])$/, ".$1js$2");
@@ -622,9 +620,9 @@ var rawPlugin = (options = {}, meta) => {
622
620
  compiler.options.resolve.extensions.unshift(".civet");
623
621
  }
624
622
  return aliasResolver = (id) => {
625
- let ref5;
626
- for (const key in ref5 = compiler.options.resolve.alias) {
627
- const value = ref5[key];
623
+ let ref4;
624
+ for (const key in ref4 = compiler.options.resolve.alias) {
625
+ const value = ref4[key];
628
626
  if (key.endsWith("$")) {
629
627
  if (id === key.slice(0, -1)) {
630
628
  return typeof value === "string" ? value : "\0";