@danielx/civet 0.11.5 → 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,7 +17,7 @@ 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
22
  return _extends = Object.assign ? Object.assign.bind() : function(n) {
22
23
  for (var e = 1; e < arguments.length; e++) {
@@ -186,32 +187,38 @@ var requirePath = function requirePath2() {
186
187
  return __require(String.fromCharCode(112, 97, 116, 104));
187
188
  };
188
189
 
189
- // 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
190
191
  import os from "os";
191
-
192
- // source/unplugin/constants.mjs
193
192
  var DEFAULT_EXTENSIONS = [".mjs", ".js", ".mts", ".ts", ".jsx", ".tsx", ".json"];
194
-
195
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\unplugin\unplugin.civet.jsx
196
193
  var DiagnosticCategory = {};
197
194
  DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning";
198
195
  DiagnosticCategory[DiagnosticCategory["Error"] = 1] = "Error";
199
196
  DiagnosticCategory[DiagnosticCategory["Suggestion"] = 2] = "Suggestion";
200
197
  DiagnosticCategory[DiagnosticCategory["Message"] = 3] = "Message";
201
- var postfixRE = /[?#].*$/s;
198
+ var queryPostfixRE = /\?.*$/s;
199
+ var escapedHashRE = /\0#/g;
202
200
  var isWindows = os.platform() === "win32";
203
201
  var windowsSlashRE = /\\/g;
204
202
  var civetSuffix = ".civet";
205
203
  var workerRE = /(?:\?|&)(?:worker|sharedworker)(?:&|$|#)/;
206
204
  function extractCivetFilename(id, outputExtension) {
207
205
  let postfix = "";
208
- let filename = id.replace(postfixRE, (match) => {
206
+ id = id.replace(escapedHashRE, "#");
207
+ let filename = id.replace(queryPostfixRE, (match) => {
209
208
  postfix = match;
210
209
  return "";
211
210
  });
212
211
  if (filename.endsWith(outputExtension)) {
213
212
  filename = filename.slice(0, -outputExtension.length);
214
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
+ }
215
222
  return { filename, postfix };
216
223
  }
217
224
  function tryStatSync(file) {
@@ -271,6 +278,7 @@ var rawPlugin = (options = {}, meta) => {
271
278
  const sourceMaps = /* @__PURE__ */ new Map();
272
279
  let compilerOptions, compilerOptionsWithSourceMap;
273
280
  let rootDir = process.cwd();
281
+ let outDir = path.join(rootDir, "dist");
274
282
  let esbuildOptions;
275
283
  let configErrors;
276
284
  let configFileNames;
@@ -560,7 +568,7 @@ var rawPlugin = (options = {}, meta) => {
560
568
  if (options2.scan && meta.framework === "vite") {
561
569
  resolved = `\0${resolved}`;
562
570
  }
563
- return resolved + outExt + postfix;
571
+ return resolved + (meta.framework === "esbuild" ? "" : outExt) + postfix;
564
572
  },
565
573
  loadInclude(id) {
566
574
  const { filename, postfix } = extractCivetFilename(id, outExt);
@@ -609,7 +617,7 @@ var rawPlugin = (options = {}, meta) => {
609
617
  let sourceMap;
610
618
  const civetOptions = {
611
619
  ...compileOptions,
612
- filename: id,
620
+ filename,
613
621
  errors: []
614
622
  };
615
623
  const rawCivetSource = decode(await fs.promises.readFile(filename));
@@ -617,7 +625,10 @@ var rawPlugin = (options = {}, meta) => {
617
625
  ...civetOptions,
618
626
  ast: true
619
627
  });
620
- const civetSourceMap = new SourceMap(rawCivetSource);
628
+ const civetSourceMap = new SourceMap(
629
+ rawCivetSource,
630
+ normalizePath(path.relative(outDir, filename))
631
+ );
621
632
  if (ts === "civet") {
622
633
  compiled = await civet.generate(ast, {
623
634
  ...civetOptions,
@@ -639,7 +650,7 @@ var rawPlugin = (options = {}, meta) => {
639
650
  const result = await esbuildTransform(compiledTS, {
640
651
  jsx: "preserve",
641
652
  loader: "tsx",
642
- sourcefile: id,
653
+ sourcefile: filename,
643
654
  sourcemap: "external"
644
655
  });
645
656
  compiled = result.code;
@@ -663,7 +674,7 @@ var rawPlugin = (options = {}, meta) => {
663
674
  }
664
675
  }
665
676
  if (transformTS) {
666
- 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++) {
667
678
  const _spec = ref3[i];
668
679
  const spec = _spec;
669
680
  if (spec.module?.input) {
@@ -685,10 +696,7 @@ var rawPlugin = (options = {}, meta) => {
685
696
  sourceMaps.set(slashed, civetSourceMap);
686
697
  }
687
698
  }
688
- const jsonSourceMap = sourceMap && (typeof sourceMap === "string" ? JSON.parse(sourceMap) : sourceMap.json(
689
- path.relative(rootDir, extractCivetFilename(id, outExt).filename),
690
- path.relative(rootDir, id)
691
- ));
699
+ const jsonSourceMap = sourceMap && (typeof sourceMap === "string" ? JSON.parse(sourceMap) : sourceMap.json(normalizePath(path.relative(outDir, id))));
692
700
  let transformed = {
693
701
  code: compiled,
694
702
  map: jsonSourceMap
@@ -706,8 +714,12 @@ var rawPlugin = (options = {}, meta) => {
706
714
  }
707
715
  },
708
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",
709
720
  config(options2) {
710
721
  esbuildOptions = options2;
722
+ outDir = options2.outdir || path.dirname(options2.outfile);
711
723
  }
712
724
  },
713
725
  vite: {
@@ -716,6 +728,7 @@ var rawPlugin = (options = {}, meta) => {
716
728
  skipWorker = true;
717
729
  }
718
730
  rootDir = path.resolve(process.cwd(), config.root ?? "");
731
+ outDir = path.resolve(rootDir, config.build?.outDir ?? "dist");
719
732
  if (implicitExtension) {
720
733
  config.resolve ??= {};
721
734
  config.resolve.extensions ??= DEFAULT_EXTENSIONS;
@@ -765,7 +778,6 @@ var rawPlugin = (options = {}, meta) => {
765
778
  },
766
779
  webpack(compiler) {
767
780
  if (implicitExtension) {
768
- compiler.options ??= {};
769
781
  compiler.options.resolve ??= {};
770
782
  compiler.options.resolve.extensions ??= ["", ".js", ".json", ".wasm"];
771
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.5",
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
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
  }