@danielx/civet 0.11.4 → 0.11.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.
@@ -1,3 +1,4 @@
1
+ import { createRequire as __civetCreateRequire } from 'node:module'; const require = __civetCreateRequire(import.meta.url);
1
2
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
3
  get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
4
  }) : x)(function(x) {
@@ -5,7 +6,7 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
5
6
  throw Error('Dynamic require of "' + x + '" is not supported');
6
7
  });
7
8
 
8
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\unplugin\unplugin.civet.jsx
9
+ // unplugin-civet:/home/runner/work/Civet/Civet/source/unplugin/unplugin.civet.jsx
9
10
  import { createUnplugin } from "unplugin";
10
11
  import civet, { decode, lib, SourceMap } from "@danielx/civet";
11
12
  import { findInDir, loadConfig } from "@danielx/civet/config";
@@ -16,20 +17,15 @@ import {
16
17
  import * as fs from "fs";
17
18
  import path from "path";
18
19
 
19
- // node_modules/@typescript/vfs/dist/vfs.esm.js
20
+ // node_modules/.pnpm/@typescript+vfs@1.6.4_typescript@5.8.3/node_modules/@typescript/vfs/dist/vfs.esm.js
20
21
  function _extends() {
21
- _extends = Object.assign ? Object.assign.bind() : function(target) {
22
- for (var i = 1; i < arguments.length; i++) {
23
- var source = arguments[i];
24
- for (var key in source) {
25
- if (Object.prototype.hasOwnProperty.call(source, key)) {
26
- target[key] = source[key];
27
- }
28
- }
22
+ return _extends = Object.assign ? Object.assign.bind() : function(n) {
23
+ for (var e = 1; e < arguments.length; e++) {
24
+ var t = arguments[e];
25
+ for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
29
26
  }
30
- return target;
31
- };
32
- return _extends.apply(this, arguments);
27
+ return n;
28
+ }, _extends.apply(null, arguments);
33
29
  }
34
30
  var hasLocalStorage = false;
35
31
  try {
@@ -37,7 +33,7 @@ try {
37
33
  } catch (error) {
38
34
  }
39
35
  var hasProcess = typeof process !== "undefined";
40
- var shouldDebug = hasLocalStorage && /* @__PURE__ */ localStorage.getItem("DEBUG") || hasProcess && process.env.DEBUG;
36
+ var shouldDebug = hasLocalStorage && typeof localStorage.getItem === "function" && /* @__PURE__ */ localStorage.getItem("DEBUG") || hasProcess && process.env.DEBUG;
41
37
  var debugLog = shouldDebug ? console.log : function(_message) {
42
38
  return "";
43
39
  };
@@ -64,7 +60,10 @@ var defaultCompilerOptions = function defaultCompilerOptions2(ts) {
64
60
  module: ts.ModuleKind.ESNext,
65
61
  suppressOutputPathCheck: true,
66
62
  skipLibCheck: true,
67
- skipDefaultLibCheck: true,
63
+ skipDefaultLibCheck: true
64
+ }, ts.versionMajorMinor && Number(ts.versionMajorMinor.split(".")[0]) >= 6 ? {
65
+ ignoreDeprecations: "6.0"
66
+ } : {
68
67
  moduleResolution: ts.ModuleResolutionKind.NodeJs
69
68
  });
70
69
  };
@@ -188,32 +187,38 @@ var requirePath = function requirePath2() {
188
187
  return __require(String.fromCharCode(112, 97, 116, 104));
189
188
  };
190
189
 
191
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\unplugin\unplugin.civet.jsx
190
+ // unplugin-civet:/home/runner/work/Civet/Civet/source/unplugin/unplugin.civet.jsx
192
191
  import os from "os";
193
-
194
- // source/unplugin/constants.mjs
195
192
  var DEFAULT_EXTENSIONS = [".mjs", ".js", ".mts", ".ts", ".jsx", ".tsx", ".json"];
196
-
197
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\unplugin\unplugin.civet.jsx
198
193
  var DiagnosticCategory = {};
199
194
  DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning";
200
195
  DiagnosticCategory[DiagnosticCategory["Error"] = 1] = "Error";
201
196
  DiagnosticCategory[DiagnosticCategory["Suggestion"] = 2] = "Suggestion";
202
197
  DiagnosticCategory[DiagnosticCategory["Message"] = 3] = "Message";
203
- var postfixRE = /[?#].*$/s;
198
+ var queryPostfixRE = /\?.*$/s;
199
+ var escapedHashRE = /\0#/g;
204
200
  var isWindows = os.platform() === "win32";
205
201
  var windowsSlashRE = /\\/g;
206
202
  var civetSuffix = ".civet";
207
203
  var workerRE = /(?:\?|&)(?:worker|sharedworker)(?:&|$|#)/;
208
204
  function extractCivetFilename(id, outputExtension) {
209
205
  let postfix = "";
210
- let filename = id.replace(postfixRE, (match) => {
206
+ id = id.replace(escapedHashRE, "#");
207
+ let filename = id.replace(queryPostfixRE, (match) => {
211
208
  postfix = match;
212
209
  return "";
213
210
  });
214
211
  if (filename.endsWith(outputExtension)) {
215
212
  filename = filename.slice(0, -outputExtension.length);
216
213
  }
214
+ const hashIndex = filename.lastIndexOf("#");
215
+ if (hashIndex >= 0 && !tryStatSync(filename)) {
216
+ postfix = filename.slice(hashIndex) + postfix;
217
+ filename = filename.slice(0, hashIndex);
218
+ if (filename.endsWith(outputExtension)) {
219
+ filename = filename.slice(0, -outputExtension.length);
220
+ }
221
+ }
217
222
  return { filename, postfix };
218
223
  }
219
224
  function tryStatSync(file) {
@@ -273,6 +278,7 @@ var rawPlugin = (options = {}, meta) => {
273
278
  const sourceMaps = /* @__PURE__ */ new Map();
274
279
  let compilerOptions, compilerOptionsWithSourceMap;
275
280
  let rootDir = process.cwd();
281
+ let outDir = path.join(rootDir, "dist");
276
282
  let esbuildOptions;
277
283
  let configErrors;
278
284
  let configFileNames;
@@ -562,7 +568,7 @@ var rawPlugin = (options = {}, meta) => {
562
568
  if (options2.scan && meta.framework === "vite") {
563
569
  resolved = `\0${resolved}`;
564
570
  }
565
- return resolved + outExt + postfix;
571
+ return resolved + (meta.framework === "esbuild" ? "" : outExt) + postfix;
566
572
  },
567
573
  loadInclude(id) {
568
574
  const { filename, postfix } = extractCivetFilename(id, outExt);
@@ -611,7 +617,7 @@ var rawPlugin = (options = {}, meta) => {
611
617
  let sourceMap;
612
618
  const civetOptions = {
613
619
  ...compileOptions,
614
- filename: id,
620
+ filename,
615
621
  errors: []
616
622
  };
617
623
  const rawCivetSource = decode(await fs.promises.readFile(filename));
@@ -619,7 +625,10 @@ var rawPlugin = (options = {}, meta) => {
619
625
  ...civetOptions,
620
626
  ast: true
621
627
  });
622
- const civetSourceMap = new SourceMap(rawCivetSource);
628
+ const civetSourceMap = new SourceMap(
629
+ rawCivetSource,
630
+ normalizePath(path.relative(outDir, filename))
631
+ );
623
632
  if (ts === "civet") {
624
633
  compiled = await civet.generate(ast, {
625
634
  ...civetOptions,
@@ -641,7 +650,7 @@ var rawPlugin = (options = {}, meta) => {
641
650
  const result = await esbuildTransform(compiledTS, {
642
651
  jsx: "preserve",
643
652
  loader: "tsx",
644
- sourcefile: id,
653
+ sourcefile: filename,
645
654
  sourcemap: "external"
646
655
  });
647
656
  compiled = result.code;
@@ -665,7 +674,7 @@ var rawPlugin = (options = {}, meta) => {
665
674
  }
666
675
  }
667
676
  if (transformTS) {
668
- for (let ref3 = lib.gatherRecursive(ast, ($) => $.type === "ModuleSpecifier"), i = 0, len = ref3.length; i < len; i++) {
677
+ for (let ref3 = lib.gatherRecursive(ast, (($) => $.type === "ModuleSpecifier")), i = 0, len = ref3.length; i < len; i++) {
669
678
  const _spec = ref3[i];
670
679
  const spec = _spec;
671
680
  if (spec.module?.input) {
@@ -687,10 +696,7 @@ var rawPlugin = (options = {}, meta) => {
687
696
  sourceMaps.set(slashed, civetSourceMap);
688
697
  }
689
698
  }
690
- const jsonSourceMap = sourceMap && (typeof sourceMap === "string" ? JSON.parse(sourceMap) : sourceMap.json(
691
- path.relative(rootDir, extractCivetFilename(id, outExt).filename),
692
- path.relative(rootDir, id)
693
- ));
699
+ const jsonSourceMap = sourceMap && (typeof sourceMap === "string" ? JSON.parse(sourceMap) : sourceMap.json(normalizePath(path.relative(outDir, id))));
694
700
  let transformed = {
695
701
  code: compiled,
696
702
  map: jsonSourceMap
@@ -708,8 +714,12 @@ var rawPlugin = (options = {}, meta) => {
708
714
  }
709
715
  },
710
716
  esbuild: {
717
+ // Explicitly set the loader so esbuild handles the compiled output
718
+ // correctly even though the virtual module id no longer ends in .jsx/.tsx.
719
+ loader: ts === "preserve" ? "tsx" : "jsx",
711
720
  config(options2) {
712
721
  esbuildOptions = options2;
722
+ outDir = options2.outdir || path.dirname(options2.outfile);
713
723
  }
714
724
  },
715
725
  vite: {
@@ -718,6 +728,7 @@ var rawPlugin = (options = {}, meta) => {
718
728
  skipWorker = true;
719
729
  }
720
730
  rootDir = path.resolve(process.cwd(), config.root ?? "");
731
+ outDir = path.resolve(rootDir, config.build?.outDir ?? "dist");
721
732
  if (implicitExtension) {
722
733
  config.resolve ??= {};
723
734
  config.resolve.extensions ??= DEFAULT_EXTENSIONS;
@@ -767,7 +778,6 @@ var rawPlugin = (options = {}, meta) => {
767
778
  },
768
779
  webpack(compiler) {
769
780
  if (implicitExtension) {
770
- compiler.options ??= {};
771
781
  compiler.options.resolve ??= {};
772
782
  compiler.options.resolve.extensions ??= ["", ".js", ".json", ".wasm"];
773
783
  compiler.options.resolve.extensions.unshift(".civet");
@@ -1,2 +1,2 @@
1
- declare const _default: (options: import("./unplugin.js").PluginOptions) => import("vite").Plugin | import("vite").Plugin[];
1
+ declare const _default: (options: import("./unplugin.js").PluginOptions) => import("vite").Plugin<any> | import("vite").Plugin<any>[];
2
2
  export default _default;
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -26,11 +27,11 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
27
  ));
27
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
29
 
29
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\unplugin\vite.civet.jsx
30
- var vite_civet_exports = {};
31
- __export(vite_civet_exports, {
32
- default: () => vite_civet_default
30
+ // source/unplugin/vite.civet
31
+ var vite_exports = {};
32
+ __export(vite_exports, {
33
+ default: () => vite_default
33
34
  });
34
- module.exports = __toCommonJS(vite_civet_exports);
35
+ module.exports = __toCommonJS(vite_exports);
35
36
  var import_unplugin = __toESM(require("./unplugin.js"));
36
- var vite_civet_default = import_unplugin.default.vite;
37
+ var vite_default = import_unplugin.default.vite;
@@ -1,4 +1,6 @@
1
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\unplugin\vite.civet.jsx
1
+ import { createRequire as __civetCreateRequire } from 'node:module'; const require = __civetCreateRequire(import.meta.url);
2
+
3
+ // unplugin-civet:/home/runner/work/Civet/Civet/source/unplugin/vite.civet.jsx
2
4
  import civetUnplugin from "./unplugin.mjs";
3
5
  var vite_civet_default = civetUnplugin.vite;
4
6
  export {
@@ -1,2 +1,2 @@
1
- declare const _default: (options: import("./unplugin.js").PluginOptions) => WebpackPluginInstance;
1
+ declare const _default: (options: import("./unplugin.js").PluginOptions) => import("unplugin").WebpackPluginInstance;
2
2
  export default _default;
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -26,11 +27,11 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
27
  ));
27
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
29
 
29
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\unplugin\webpack.civet.jsx
30
- var webpack_civet_exports = {};
31
- __export(webpack_civet_exports, {
32
- default: () => webpack_civet_default
30
+ // source/unplugin/webpack.civet
31
+ var webpack_exports = {};
32
+ __export(webpack_exports, {
33
+ default: () => webpack_default
33
34
  });
34
- module.exports = __toCommonJS(webpack_civet_exports);
35
+ module.exports = __toCommonJS(webpack_exports);
35
36
  var import_unplugin = __toESM(require("./unplugin.js"));
36
- var webpack_civet_default = import_unplugin.default.webpack;
37
+ var webpack_default = import_unplugin.default.webpack;
@@ -1,4 +1,6 @@
1
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\unplugin\webpack.civet.jsx
1
+ import { createRequire as __civetCreateRequire } from 'node:module'; const require = __civetCreateRequire(import.meta.url);
2
+
3
+ // unplugin-civet:/home/runner/work/Civet/Civet/source/unplugin/webpack.civet.jsx
2
4
  import civetUnplugin from "./unplugin.mjs";
3
5
  var webpack_civet_default = civetUnplugin.webpack;
4
6
  export {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@danielx/civet",
3
3
  "type": "commonjs",
4
- "version": "0.11.4",
4
+ "version": "0.11.6",
5
5
  "description": "CoffeeScript style syntax for TypeScript",
6
6
  "main": "dist/main.js",
7
7
  "module": "dist/main.mjs",
@@ -95,46 +95,52 @@
95
95
  },
96
96
  "scripts": {
97
97
  "build": "bash ./build/build.sh",
98
- "build:self": "yarn build && bash ./build/build-self.sh",
99
- "docs:dev": "yarn build && vitepress dev civet.dev",
100
- "docs:build": "yarn build && vitepress build civet.dev",
101
- "docs:preview": "yarn build && vitepress preview civet.dev",
102
- "prepublishOnly": "yarn build && yarn test && yarn changelog --release",
98
+ "build:self": "pnpm build && bash ./build/build-self.sh",
99
+ "clean:cache": "rm -rf .cache",
100
+ "docs:dev": "pnpm build && vitepress dev civet.dev",
101
+ "docs:build": "pnpm build && vitepress build civet.dev",
102
+ "docs:preview": "pnpm build && vitepress preview civet.dev",
103
+ "prepublishOnly": "pnpm build && pnpm test:coverage && pnpm changelog --verify",
103
104
  "test": "bash ./build/test.sh",
104
- "test:self": "yarn build && mocha --config .mocharc-self.json",
105
- "changelog": "civet build/changelog.civet"
105
+ "test:coverage": "cross-env CIVET_COVERAGE=1 bash ./build/test.sh",
106
+ "test:self": "cross-env CIVET_SOURCE=./dist/main.js pnpm test",
107
+ "changelog": "civet build/changelog.civet",
108
+ "release": "pnpm changelog --release"
106
109
  },
107
110
  "author": "Daniel X. Moore",
108
111
  "license": "MIT",
109
112
  "dependencies": {
110
113
  "@cspotcode/source-map-support": "^0.8.1",
111
- "unplugin": "^2.3.2"
114
+ "unplugin": "2.3.11"
112
115
  },
113
116
  "devDependencies": {
117
+ "@babel/core": "^7.29.0",
118
+ "@babel/parser": "^7.29.2",
114
119
  "@danielx/civet": "0.9.4",
115
- "@danielx/hera": "^0.8.17",
120
+ "@danielx/hera": "0.8.19",
116
121
  "@prettier/sync": "^0.5.2",
117
122
  "@types/assert": "^1.5.6",
118
123
  "@types/mocha": "^10.0.8",
119
124
  "@types/node": "^22.10.2",
120
- "@typescript/vfs": "^1.6.0",
125
+ "@typescript/vfs": "^1.6.4",
121
126
  "c8": "^7.12.0",
122
- "esbuild": "0.24.0",
127
+ "cross-env": "7.0.3",
128
+ "esbuild": "0.27.5",
123
129
  "marked": "^4.2.4",
124
130
  "mocha": "^10.7.3",
125
131
  "prettier": "^3.2.5",
132
+ "shiki": "^3.0.0",
126
133
  "terser": "^5.16.1",
127
- "ts-node": "^10.9.2",
128
134
  "tslib": "^2.4.0",
129
135
  "typescript": "^5.5.2",
130
- "vite": "^4.4.12",
136
+ "vite": "^8.0.3",
131
137
  "vitepress": "^1.0.0-alpha.35",
132
138
  "vscode-languageserver": "^8.1.0",
133
139
  "vscode-languageserver-textdocument": "^1.0.8",
134
140
  "vue": "^3.2.45"
135
141
  },
136
142
  "peerDependencies": {
137
- "typescript": "^4.5 || ^5.0",
143
+ "typescript": ">=4.5",
138
144
  "yaml": "^2.4.5"
139
145
  },
140
146
  "peerDependenciesMeta": {
@@ -168,5 +174,14 @@
168
174
  "source/bun-civet.civet"
169
175
  ]
170
176
  },
171
- "packageManager": "yarn@1.22.21+sha1.1959a18351b811cdeedbd484a8f86c3cc3bbaf72"
177
+ "packageManager": "pnpm@10.33.0",
178
+ "pnpm": {
179
+ "overrides": {
180
+ "serialize-javascript": "^7.0.3",
181
+ "tmp": "^0.2.5",
182
+ "lodash": "^4.18.0",
183
+ "esbuild": "^0.27.0",
184
+ "diff": "^8.0.3"
185
+ }
186
+ }
172
187
  }