@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.
@@ -1,4 +1,4 @@
1
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\unplugin\unplugin.civet.jsx
1
+ // unplugin-civet:/home/daniel/apps/Civet/source/unplugin/unplugin.civet.jsx
2
2
  import { createUnplugin } from "unplugin";
3
3
  import civet, { lib, SourceMap } from "@danielx/civet";
4
4
  import { findInDir, loadConfig } from "@danielx/civet/config";
@@ -14,24 +14,26 @@ import os from "os";
14
14
  // source/unplugin/constants.mjs
15
15
  var DEFAULT_EXTENSIONS = [".mjs", ".js", ".mts", ".ts", ".jsx", ".tsx", ".json"];
16
16
 
17
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\unplugin\unplugin.civet.jsx
17
+ // unplugin-civet:/home/daniel/apps/Civet/source/unplugin/unplugin.civet.jsx
18
18
  var DiagnosticCategory = {};
19
19
  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";
@@ -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\vite.civet.jsx
29
+ // unplugin-civet:/home/daniel/apps/Civet/source/unplugin/vite.civet.jsx
30
30
  var vite_civet_exports = {};
31
31
  __export(vite_civet_exports, {
32
32
  default: () => vite_civet_default
@@ -1,4 +1,4 @@
1
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\unplugin\vite.civet.jsx
1
+ // unplugin-civet:/home/daniel/apps/Civet/source/unplugin/vite.civet.jsx
2
2
  import civetUnplugin from "./unplugin.mjs";
3
3
  var vite_civet_default = civetUnplugin.vite;
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\webpack.civet.jsx
29
+ // unplugin-civet:/home/daniel/apps/Civet/source/unplugin/webpack.civet.jsx
30
30
  var webpack_civet_exports = {};
31
31
  __export(webpack_civet_exports, {
32
32
  default: () => webpack_civet_default
@@ -1,4 +1,4 @@
1
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\unplugin\webpack.civet.jsx
1
+ // unplugin-civet:/home/daniel/apps/Civet/source/unplugin/webpack.civet.jsx
2
2
  import civetUnplugin from "./unplugin.mjs";
3
3
  var webpack_civet_default = civetUnplugin.webpack;
4
4
  export {
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.5",
5
5
  "description": "CoffeeScript style syntax for TypeScript",
6
6
  "main": "dist/main.js",
7
7
  "module": "dist/main.mjs",