@danielx/civet 0.10.3 → 0.10.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,12 @@ This changelog is generated automatically by [`build/changelog.civet`](build/cha
4
4
  For each version of Civet, it lists and links to all incorporated PRs,
5
5
  as well as a full diff and commit list.
6
6
 
7
+ ## 0.10.4 (2025-05-17, [diff](https://github.com/DanielXMoore/Civet/compare/v0.10.3...v0.10.4), [commits](https://github.com/DanielXMoore/Civet/commits/v0.10.4))
8
+ * Fix implicit returns in IIFEs with "civet -implicitReturns" [[#1737](https://github.com/DanielXMoore/Civet/pull/1737)]
9
+ * Typed pinned arguments such as `(^x: T) =>`; forbid implicit object literals in pinned patterns [[#1736](https://github.com/DanielXMoore/Civet/pull/1736)]
10
+ * Fix `outputExtension` option in unplugin, enabling `.svelte.ts`/`.svelte.js` for Svelte Runes reactive compatibility [[#1733](https://github.com/DanielXMoore/Civet/pull/1733)]
11
+ * Type-only class field declarations `declare field: T` [[#1741](https://github.com/DanielXMoore/Civet/pull/1741)]
12
+
7
13
  ## 0.10.3 (2025-04-28, [diff](https://github.com/DanielXMoore/Civet/compare/v0.10.2...v0.10.3), [commits](https://github.com/DanielXMoore/Civet/commits/v0.10.3))
8
14
  * Explicit changelog build script shell [[#1727](https://github.com/DanielXMoore/Civet/pull/1727)]
9
15
  * ESM loader supports civetconfig by default, and overriding configuration [[#1734](https://github.com/DanielXMoore/Civet/pull/1734)]
package/dist/browser.js CHANGED
@@ -1164,6 +1164,8 @@ ${body}`), super(message), this.header = header, this.body = body, this.filename
1164
1164
  },
1165
1165
  parameters,
1166
1166
  returnType: void 0,
1167
+ implicitReturn: !0,
1168
+ // force implicit return in IIFE
1167
1169
  children: generator.length ? [async, "function", generator, parameters] : [async, parameters]
1168
1170
  }, fn;
1169
1171
  generator.length ? fn = makeNode({
@@ -2291,7 +2293,7 @@ ${js}`
2291
2293
  }
2292
2294
  function processReturn(f, implicitReturns) {
2293
2295
  let { returnType } = f.signature;
2294
- if (returnType && returnType.optional && convertOptionalType(returnType), !processReturnValue(f) && implicitReturns) {
2296
+ if (returnType && returnType.optional && convertOptionalType(returnType), !processReturnValue(f) && (implicitReturns || f.signature.implicitReturn)) {
2295
2297
  let { signature, block } = f, { modifier, name, returnType: returnType2 } = signature, { async, generator, set } = modifier, isConstructor = f.type === "MethodDefinition" && name === "constructor", isVoid = generator || isVoidType(returnType2?.t) || async && isPromiseVoidType(returnType2?.t);
2296
2298
  block?.type === "BlockStatement" && (isVoid || set || isConstructor ? block.bare && block.implicitlyReturned && braceBlock(block) : block.implicitlyReturned || insertReturn(block));
2297
2299
  }
@@ -8346,17 +8348,20 @@ ${js}`
8346
8348
  function NestedClassElement(ctx, state2) {
8347
8349
  return (0, import_lib2.$EVENT)(ctx, state2, "NestedClassElement", NestedClassElement$0);
8348
8350
  }
8349
- 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) {
8350
- var decorators = $1, definition = $5;
8351
+ 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) {
8352
+ var decorators = $1, declare = $2, access = $3, static_ = $4, override = $5, definition = $6;
8353
+ let ts2 = definition.ts || !!declare;
8351
8354
  return definition.type === "MultiMethodDefinition" ? {
8352
8355
  ...definition,
8356
+ ts: ts2,
8353
8357
  children: definition.children.map((c) => ({
8354
8358
  ...c,
8355
- children: [decorators, ...c.children]
8359
+ children: [decorators, declare, access, static_, override, ...c.children]
8356
8360
  }))
8357
8361
  } : {
8358
8362
  ...definition,
8359
- children: [decorators, $2, $3, $4, ...definition.children]
8363
+ ts: ts2,
8364
+ children: [decorators, declare, access, static_, override, ...definition.children]
8360
8365
  };
8361
8366
  }), ClassElement$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(Static, BracedBlock), function($skip, $loc, $0, $1, $2) {
8362
8367
  return {
@@ -9088,35 +9093,42 @@ ${js}`
9088
9093
  function AtIdentifierRef(ctx, state2) {
9089
9094
  return (0, import_lib2.$EVENT_C)(ctx, state2, "AtIdentifierRef", AtIdentifierRef$$);
9090
9095
  }
9091
- var PinPattern$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(Caret, SingleLineExpressionWithIndentedApplicationForbidden), function($skip, $loc, $0, $1, $2) {
9096
+ 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) {
9092
9097
  var expression = $2;
9093
9098
  return {
9094
9099
  type: "PinPattern",
9095
9100
  children: [expression],
9096
9101
  expression
9097
9102
  };
9098
- }), PinPattern$1 = (0, import_lib2.$TV)(ActualMemberExpression, function($skip, $loc, $0, $1) {
9103
+ }), PinPattern$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(Caret, SingleLineExpressionWithIndentedApplicationForbidden), function($skip, $loc, $0, $1, $2) {
9104
+ var expression = $2;
9105
+ return {
9106
+ type: "PinPattern",
9107
+ children: [expression],
9108
+ expression
9109
+ };
9110
+ }), PinPattern$2 = (0, import_lib2.$TV)(ActualMemberExpression, function($skip, $loc, $0, $1) {
9099
9111
  var expression = $0;
9100
9112
  return {
9101
9113
  type: "PinPattern",
9102
9114
  children: [expression],
9103
9115
  expression
9104
9116
  };
9105
- }), PinPattern$2 = (0, import_lib2.$TV)((0, import_lib2.$S)((0, import_lib2.$EXPECT)($R14, "PinPattern /[+-]/"), NumericLiteral), function($skip, $loc, $0, $1) {
9117
+ }), PinPattern$3 = (0, import_lib2.$TV)((0, import_lib2.$S)((0, import_lib2.$EXPECT)($R14, "PinPattern /[+-]/"), NumericLiteral), function($skip, $loc, $0, $1) {
9106
9118
  var expression = $0;
9107
9119
  return {
9108
9120
  type: "PinPattern",
9109
9121
  children: [expression],
9110
9122
  expression
9111
9123
  };
9112
- }), PinPattern$3 = (0, import_lib2.$TV)(Undefined, function($skip, $loc, $0, $1) {
9124
+ }), PinPattern$4 = (0, import_lib2.$TV)(Undefined, function($skip, $loc, $0, $1) {
9113
9125
  var expression = $0;
9114
9126
  return {
9115
9127
  type: "PinPattern",
9116
9128
  children: [expression],
9117
9129
  expression
9118
9130
  };
9119
- }), PinPattern$$ = [PinPattern$0, PinPattern$1, PinPattern$2, PinPattern$3];
9131
+ }), PinPattern$$ = [PinPattern$0, PinPattern$1, PinPattern$2, PinPattern$3, PinPattern$4];
9120
9132
  function PinPattern(ctx, state2) {
9121
9133
  return (0, import_lib2.$EVENT_C)(ctx, state2, "PinPattern", PinPattern$$);
9122
9134
  }
package/dist/main.js CHANGED
@@ -1488,6 +1488,8 @@ function wrapIIFE(expressions, asyncFlag, generatorStar) {
1488
1488
  },
1489
1489
  parameters,
1490
1490
  returnType: void 0,
1491
+ implicitReturn: true,
1492
+ // force implicit return in IIFE
1491
1493
  children: generator.length ? [async, "function", generator, parameters] : [async, parameters]
1492
1494
  };
1493
1495
  let fn;
@@ -2895,7 +2897,7 @@ function processReturn(f, implicitReturns) {
2895
2897
  if (returnType && returnType.optional) {
2896
2898
  convertOptionalType(returnType);
2897
2899
  }
2898
- if (!processReturnValue(f) && implicitReturns) {
2900
+ if (!processReturnValue(f) && (implicitReturns || f.signature.implicitReturn)) {
2899
2901
  const { signature, block } = f;
2900
2902
  const { modifier, name, returnType: returnType2 } = signature;
2901
2903
  const { async, generator, set } = modifier;
@@ -11374,23 +11376,30 @@ var NestedClassElement$0 = (0, import_lib2.$S)(Nested, ClassElement, StatementDe
11374
11376
  function NestedClassElement(ctx, state2) {
11375
11377
  return (0, import_lib2.$EVENT)(ctx, state2, "NestedClassElement", NestedClassElement$0);
11376
11378
  }
11377
- 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) {
11379
+ 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) {
11378
11380
  var decorators = $1;
11379
- var definition = $5;
11381
+ var declare = $2;
11382
+ var access = $3;
11383
+ var static_ = $4;
11384
+ var override = $5;
11385
+ var definition = $6;
11386
+ const ts2 = definition.ts || !!declare;
11380
11387
  if (definition.type === "MultiMethodDefinition") {
11381
11388
  return {
11382
11389
  ...definition,
11390
+ ts: ts2,
11383
11391
  children: definition.children.map((c) => {
11384
11392
  return {
11385
11393
  ...c,
11386
- children: [decorators, ...c.children]
11394
+ children: [decorators, declare, access, static_, override, ...c.children]
11387
11395
  };
11388
11396
  })
11389
11397
  };
11390
11398
  }
11391
11399
  return {
11392
11400
  ...definition,
11393
- children: [decorators, $2, $3, $4, ...definition.children]
11401
+ ts: ts2,
11402
+ children: [decorators, declare, access, static_, override, ...definition.children]
11394
11403
  };
11395
11404
  });
11396
11405
  var ClassElement$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(Static, BracedBlock), function($skip, $loc, $0, $1, $2) {
@@ -12356,7 +12365,15 @@ var AtIdentifierRef$$ = [AtIdentifierRef$0, AtIdentifierRef$1];
12356
12365
  function AtIdentifierRef(ctx, state2) {
12357
12366
  return (0, import_lib2.$EVENT_C)(ctx, state2, "AtIdentifierRef", AtIdentifierRef$$);
12358
12367
  }
12359
- var PinPattern$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(Caret, SingleLineExpressionWithIndentedApplicationForbidden), function($skip, $loc, $0, $1, $2) {
12368
+ 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) {
12369
+ var expression = $2;
12370
+ return {
12371
+ type: "PinPattern",
12372
+ children: [expression],
12373
+ expression
12374
+ };
12375
+ });
12376
+ var PinPattern$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(Caret, SingleLineExpressionWithIndentedApplicationForbidden), function($skip, $loc, $0, $1, $2) {
12360
12377
  var expression = $2;
12361
12378
  return {
12362
12379
  type: "PinPattern",
@@ -12364,7 +12381,7 @@ var PinPattern$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(Caret, SingleLineExp
12364
12381
  expression
12365
12382
  };
12366
12383
  });
12367
- var PinPattern$1 = (0, import_lib2.$TV)(ActualMemberExpression, function($skip, $loc, $0, $1) {
12384
+ var PinPattern$2 = (0, import_lib2.$TV)(ActualMemberExpression, function($skip, $loc, $0, $1) {
12368
12385
  var expression = $0;
12369
12386
  return {
12370
12387
  type: "PinPattern",
@@ -12372,7 +12389,7 @@ var PinPattern$1 = (0, import_lib2.$TV)(ActualMemberExpression, function($skip,
12372
12389
  expression
12373
12390
  };
12374
12391
  });
12375
- var PinPattern$2 = (0, import_lib2.$TV)((0, import_lib2.$S)((0, import_lib2.$EXPECT)($R14, "PinPattern /[+-]/"), NumericLiteral), function($skip, $loc, $0, $1) {
12392
+ var PinPattern$3 = (0, import_lib2.$TV)((0, import_lib2.$S)((0, import_lib2.$EXPECT)($R14, "PinPattern /[+-]/"), NumericLiteral), function($skip, $loc, $0, $1) {
12376
12393
  var expression = $0;
12377
12394
  return {
12378
12395
  type: "PinPattern",
@@ -12380,7 +12397,7 @@ var PinPattern$2 = (0, import_lib2.$TV)((0, import_lib2.$S)((0, import_lib2.$EXP
12380
12397
  expression
12381
12398
  };
12382
12399
  });
12383
- var PinPattern$3 = (0, import_lib2.$TV)(Undefined, function($skip, $loc, $0, $1) {
12400
+ var PinPattern$4 = (0, import_lib2.$TV)(Undefined, function($skip, $loc, $0, $1) {
12384
12401
  var expression = $0;
12385
12402
  return {
12386
12403
  type: "PinPattern",
@@ -12388,7 +12405,7 @@ var PinPattern$3 = (0, import_lib2.$TV)(Undefined, function($skip, $loc, $0, $1)
12388
12405
  expression
12389
12406
  };
12390
12407
  });
12391
- var PinPattern$$ = [PinPattern$0, PinPattern$1, PinPattern$2, PinPattern$3];
12408
+ var PinPattern$$ = [PinPattern$0, PinPattern$1, PinPattern$2, PinPattern$3, PinPattern$4];
12392
12409
  function PinPattern(ctx, state2) {
12393
12410
  return (0, import_lib2.$EVENT_C)(ctx, state2, "PinPattern", PinPattern$$);
12394
12411
  }
package/dist/main.mjs CHANGED
@@ -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;
@@ -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;
@@ -11355,23 +11357,30 @@ var NestedClassElement$0 = (0, import_lib2.$S)(Nested, ClassElement, StatementDe
11355
11357
  function NestedClassElement(ctx, state2) {
11356
11358
  return (0, import_lib2.$EVENT)(ctx, state2, "NestedClassElement", NestedClassElement$0);
11357
11359
  }
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) {
11360
+ 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
11361
  var decorators = $1;
11360
- var definition = $5;
11362
+ var declare = $2;
11363
+ var access = $3;
11364
+ var static_ = $4;
11365
+ var override = $5;
11366
+ var definition = $6;
11367
+ const ts2 = definition.ts || !!declare;
11361
11368
  if (definition.type === "MultiMethodDefinition") {
11362
11369
  return {
11363
11370
  ...definition,
11371
+ ts: ts2,
11364
11372
  children: definition.children.map((c) => {
11365
11373
  return {
11366
11374
  ...c,
11367
- children: [decorators, ...c.children]
11375
+ children: [decorators, declare, access, static_, override, ...c.children]
11368
11376
  };
11369
11377
  })
11370
11378
  };
11371
11379
  }
11372
11380
  return {
11373
11381
  ...definition,
11374
- children: [decorators, $2, $3, $4, ...definition.children]
11382
+ ts: ts2,
11383
+ children: [decorators, declare, access, static_, override, ...definition.children]
11375
11384
  };
11376
11385
  });
11377
11386
  var ClassElement$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(Static, BracedBlock), function($skip, $loc, $0, $1, $2) {
@@ -12337,7 +12346,15 @@ var AtIdentifierRef$$ = [AtIdentifierRef$0, AtIdentifierRef$1];
12337
12346
  function AtIdentifierRef(ctx, state2) {
12338
12347
  return (0, import_lib2.$EVENT_C)(ctx, state2, "AtIdentifierRef", AtIdentifierRef$$);
12339
12348
  }
12340
- var PinPattern$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(Caret, SingleLineExpressionWithIndentedApplicationForbidden), function($skip, $loc, $0, $1, $2) {
12349
+ 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) {
12350
+ var expression = $2;
12351
+ return {
12352
+ type: "PinPattern",
12353
+ children: [expression],
12354
+ expression
12355
+ };
12356
+ });
12357
+ var PinPattern$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(Caret, SingleLineExpressionWithIndentedApplicationForbidden), function($skip, $loc, $0, $1, $2) {
12341
12358
  var expression = $2;
12342
12359
  return {
12343
12360
  type: "PinPattern",
@@ -12345,7 +12362,7 @@ var PinPattern$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(Caret, SingleLineExp
12345
12362
  expression
12346
12363
  };
12347
12364
  });
12348
- var PinPattern$1 = (0, import_lib2.$TV)(ActualMemberExpression, function($skip, $loc, $0, $1) {
12365
+ var PinPattern$2 = (0, import_lib2.$TV)(ActualMemberExpression, function($skip, $loc, $0, $1) {
12349
12366
  var expression = $0;
12350
12367
  return {
12351
12368
  type: "PinPattern",
@@ -12353,7 +12370,7 @@ var PinPattern$1 = (0, import_lib2.$TV)(ActualMemberExpression, function($skip,
12353
12370
  expression
12354
12371
  };
12355
12372
  });
12356
- var PinPattern$2 = (0, import_lib2.$TV)((0, import_lib2.$S)((0, import_lib2.$EXPECT)($R14, "PinPattern /[+-]/"), NumericLiteral), function($skip, $loc, $0, $1) {
12373
+ var PinPattern$3 = (0, import_lib2.$TV)((0, import_lib2.$S)((0, import_lib2.$EXPECT)($R14, "PinPattern /[+-]/"), NumericLiteral), function($skip, $loc, $0, $1) {
12357
12374
  var expression = $0;
12358
12375
  return {
12359
12376
  type: "PinPattern",
@@ -12361,7 +12378,7 @@ var PinPattern$2 = (0, import_lib2.$TV)((0, import_lib2.$S)((0, import_lib2.$EXP
12361
12378
  expression
12362
12379
  };
12363
12380
  });
12364
- var PinPattern$3 = (0, import_lib2.$TV)(Undefined, function($skip, $loc, $0, $1) {
12381
+ var PinPattern$4 = (0, import_lib2.$TV)(Undefined, function($skip, $loc, $0, $1) {
12365
12382
  var expression = $0;
12366
12383
  return {
12367
12384
  type: "PinPattern",
@@ -12369,7 +12386,7 @@ var PinPattern$3 = (0, import_lib2.$TV)(Undefined, function($skip, $loc, $0, $1)
12369
12386
  expression
12370
12387
  };
12371
12388
  });
12372
- var PinPattern$$ = [PinPattern$0, PinPattern$1, PinPattern$2, PinPattern$3];
12389
+ var PinPattern$$ = [PinPattern$0, PinPattern$1, PinPattern$2, PinPattern$3, PinPattern$4];
12373
12390
  function PinPattern(ctx, state2) {
12374
12391
  return (0, import_lib2.$EVENT_C)(ctx, state2, "PinPattern", PinPattern$$);
12375
12392
  }
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
@@ -52,18 +52,20 @@ 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";
@@ -20,18 +20,20 @@ DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning";
20
20
  DiagnosticCategory[DiagnosticCategory["Error"] = 1] = "Error";
21
21
  DiagnosticCategory[DiagnosticCategory["Suggestion"] = 2] = "Suggestion";
22
22
  DiagnosticCategory[DiagnosticCategory["Message"] = 3] = "Message";
23
- var civetExtension = /\.civet$/;
24
- var isCivetTranspiled = /(\.civet)(\.[jt]sx)?([?#].*)?$/;
25
23
  var postfixRE = /[?#].*$/s;
26
24
  var isWindows = os.platform() === "win32";
27
25
  var windowsSlashRE = /\\/g;
28
- function cleanCivetId(id) {
26
+ var civetSuffix = ".civet";
27
+ function extractCivetFilename(id, outputExtension) {
29
28
  let postfix = "";
30
- id = id.replace(postfixRE, (match) => {
29
+ let filename = id.replace(postfixRE, (match) => {
31
30
  postfix = match;
32
31
  return "";
33
- }).replace(/\.[jt]sx$/, "");
34
- return { id, postfix };
32
+ });
33
+ if (filename.endsWith(outputExtension)) {
34
+ filename = filename.slice(0, -outputExtension.length);
35
+ }
36
+ return { filename, postfix };
35
37
  }
36
38
  function tryStatSync(file) {
37
39
  try {
@@ -327,10 +329,8 @@ var rawPlugin = (options = {}, meta) => {
327
329
  } else {
328
330
  console.log(`WARNING: No .d.ts extension in ${filePath}`);
329
331
  }
330
- let ref1;
331
- if (ref1 = filePath.match(civetExtension)) {
332
- const match = ref1;
333
- filePath = filePath.slice(0, -match[0].length);
332
+ if (filePath.endsWith(civetSuffix)) {
333
+ filePath = filePath.slice(0, -civetSuffix.length);
334
334
  } else {
335
335
  console.log(`WARNING: No .civet extension in ${filePath}`);
336
336
  }
@@ -363,38 +363,36 @@ var rawPlugin = (options = {}, meta) => {
363
363
  id = aliasResolver(id);
364
364
  }
365
365
  if (/\0/.test(id)) return null;
366
- let postfix;
367
- ({ id, postfix } = cleanCivetId(id));
368
- let ref2;
369
- if (path.isAbsolute(id)) {
370
- ref2 = resolveAbsolutePath(rootDir, id, implicitExtension);
366
+ const { filename, postfix } = extractCivetFilename(id, outExt);
367
+ let ref1;
368
+ if (path.isAbsolute(filename)) {
369
+ ref1 = resolveAbsolutePath(rootDir, filename, implicitExtension);
371
370
  } else {
372
- ref2 = path.resolve(path.dirname(importer ?? ""), id);
371
+ ref1 = path.resolve(path.dirname(importer ?? ""), filename);
373
372
  }
374
373
  ;
375
- let resolvedId = ref2;
376
- if (!resolvedId) return null;
377
- if (!resolvedId.endsWith(".civet")) {
374
+ let resolved = ref1;
375
+ if (!resolved) return null;
376
+ if (!resolved.endsWith(civetSuffix)) {
378
377
  if (!implicitExtension) return null;
379
- const implicitId = implicitCivet(resolvedId);
378
+ const implicitId = implicitCivet(resolved);
380
379
  if (!implicitId) return null;
381
- resolvedId = implicitId;
380
+ resolved = implicitId;
382
381
  }
383
382
  if (options2.scan && meta.framework === "vite") {
384
- resolvedId = `\0${resolvedId}`;
383
+ resolved = `\0${resolved}`;
385
384
  }
386
- return resolvedId + outExt + postfix;
385
+ return resolved + outExt + postfix;
387
386
  },
388
387
  loadInclude(id) {
389
- return isCivetTranspiled.test(id);
388
+ return extractCivetFilename(id, outExt).filename.endsWith(civetSuffix);
390
389
  },
391
390
  async load(id) {
392
- const match = isCivetTranspiled.exec(id);
393
- if (!match) {
391
+ let { filename } = extractCivetFilename(id, outExt);
392
+ if (!filename.endsWith(civetSuffix)) {
394
393
  return null;
395
394
  }
396
- const basename = id.slice(0, match.index + match[1].length);
397
- const filename = path.resolve(rootDir, basename);
395
+ filename = path.resolve(rootDir, filename);
398
396
  this.addWatchFile(filename);
399
397
  let mtime, cached, resolve;
400
398
  if (cache != null) {
@@ -408,9 +406,9 @@ var rawPlugin = (options = {}, meta) => {
408
406
  if (cached.promise) {
409
407
  await cached.promise;
410
408
  }
411
- let ref3;
412
- if ((ref3 = cached.result) != null) {
413
- const result = ref3;
409
+ let ref2;
410
+ if ((ref2 = cached.result) != null) {
411
+ const result = ref2;
414
412
  return result;
415
413
  }
416
414
  }
@@ -486,8 +484,8 @@ var rawPlugin = (options = {}, meta) => {
486
484
  }
487
485
  }
488
486
  if (transformTS) {
489
- for (let ref4 = lib.gatherRecursive(ast, ($) => $.type === "ModuleSpecifier"), i = 0, len = ref4.length; i < len; i++) {
490
- const _spec = ref4[i];
487
+ for (let ref3 = lib.gatherRecursive(ast, ($) => $.type === "ModuleSpecifier"), i = 0, len = ref3.length; i < len; i++) {
488
+ const _spec = ref3[i];
491
489
  const spec = _spec;
492
490
  if (spec.module?.input) {
493
491
  spec.module.token = spec.module.input.replace(/\.([mc])?ts(['"])$/, ".$1js$2");
@@ -590,9 +588,9 @@ var rawPlugin = (options = {}, meta) => {
590
588
  compiler.options.resolve.extensions.unshift(".civet");
591
589
  }
592
590
  return aliasResolver = (id) => {
593
- let ref5;
594
- for (const key in ref5 = compiler.options.resolve.alias) {
595
- const value = ref5[key];
591
+ let ref4;
592
+ for (const key in ref4 = compiler.options.resolve.alias) {
593
+ const value = ref4[key];
596
594
  if (key.endsWith("$")) {
597
595
  if (id === key.slice(0, -1)) {
598
596
  return typeof value === "string" ? value : "\0";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@danielx/civet",
3
3
  "type": "commonjs",
4
- "version": "0.10.3",
4
+ "version": "0.10.4",
5
5
  "description": "CoffeeScript style syntax for TypeScript",
6
6
  "main": "dist/main.js",
7
7
  "module": "dist/main.mjs",