@danielx/civet 0.11.6 → 0.11.7

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.
@@ -47,7 +47,7 @@ function remapPosition(position, sourcemapLines) {
47
47
  const newChar = srcChar + character - lastMappingPosition;
48
48
  return {
49
49
  line: srcLine,
50
- character: newChar
50
+ character: Math.max(0, newChar)
51
51
  };
52
52
  } else {
53
53
  return position;
@@ -22,7 +22,7 @@ function remapPosition(position, sourcemapLines) {
22
22
  const newChar = srcChar + character - lastMappingPosition;
23
23
  return {
24
24
  line: srcLine,
25
- character: newChar
25
+ character: Math.max(0, newChar)
26
26
  };
27
27
  } else {
28
28
  return position;
package/dist/types.d.ts CHANGED
@@ -22,6 +22,8 @@ declare module "@danielx/civet" {
22
22
  coffeePrototype: boolean
23
23
  coffeeRange: boolean
24
24
  defaultElement: string
25
+ esCompat: boolean
26
+ esArrowFunction: boolean
25
27
  globals: string[]
26
28
  implicitReturns: boolean
27
29
  jsxCode: boolean
@@ -1,8 +1,8 @@
1
1
  import { createRequire as __civetCreateRequire } from 'node:module'; const require = __civetCreateRequire(import.meta.url);
2
2
 
3
- // unplugin-civet:/home/runner/work/Civet/Civet/source/unplugin/astro.civet.jsx
3
+ // unplugin-civet:/home/runner/work/Civet/Civet/source/unplugin/astro.civet
4
4
  import civetUnplugin, {} from "./unplugin.mjs";
5
- var astro_civet_default = (function(opts = {}) {
5
+ var astro_default = (function(opts = {}) {
6
6
  return {
7
7
  name: "@danielx/civet",
8
8
  hooks: {
@@ -17,5 +17,5 @@ var astro_civet_default = (function(opts = {}) {
17
17
  };
18
18
  });
19
19
  export {
20
- astro_civet_default as default
20
+ astro_default as default
21
21
  };
@@ -1,2 +1,2 @@
1
- declare const _default: (options: import("./unplugin.js").PluginOptions) => import("esbuild").Plugin;
1
+ declare const _default: (options?: import("./unplugin.js").PluginOptions | undefined) => import("esbuild").Plugin;
2
2
  export default _default;
@@ -1,8 +1,8 @@
1
1
  import { createRequire as __civetCreateRequire } from 'node:module'; const require = __civetCreateRequire(import.meta.url);
2
2
 
3
- // unplugin-civet:/home/runner/work/Civet/Civet/source/unplugin/esbuild.civet.jsx
3
+ // unplugin-civet:/home/runner/work/Civet/Civet/source/unplugin/esbuild.civet
4
4
  import civetUnplugin from "./unplugin.mjs";
5
- var esbuild_civet_default = civetUnplugin.esbuild;
5
+ var esbuild_default = civetUnplugin.esbuild;
6
6
  export {
7
- esbuild_civet_default as default
7
+ esbuild_default as default
8
8
  };
@@ -1,8 +1,8 @@
1
1
  import { createRequire as __civetCreateRequire } from 'node:module'; const require = __civetCreateRequire(import.meta.url);
2
2
 
3
- // unplugin-civet:/home/runner/work/Civet/Civet/source/unplugin/farm.civet.jsx
3
+ // unplugin-civet:/home/runner/work/Civet/Civet/source/unplugin/farm.civet
4
4
  import civetUnplugin, {} from "./unplugin.mjs";
5
- var farm_civet_default = civetUnplugin.farm;
5
+ var farm_default = civetUnplugin.farm;
6
6
  export {
7
- farm_civet_default as default
7
+ farm_default as default
8
8
  };
@@ -1,2 +1,2 @@
1
- declare const _default: (options: import("./unplugin.js").PluginOptions) => import("rolldown").Plugin<any> | import("rolldown").Plugin<any>[];
1
+ declare const _default: (options?: import("./unplugin.js").PluginOptions | undefined) => import("unplugin").RolldownPlugin<any> | import("unplugin").RolldownPlugin<any>[];
2
2
  export default _default;
@@ -1,8 +1,8 @@
1
1
  import { createRequire as __civetCreateRequire } from 'node:module'; const require = __civetCreateRequire(import.meta.url);
2
2
 
3
- // unplugin-civet:/home/runner/work/Civet/Civet/source/unplugin/rolldown.civet.jsx
3
+ // unplugin-civet:/home/runner/work/Civet/Civet/source/unplugin/rolldown.civet
4
4
  import civetUnplugin from "./unplugin.mjs";
5
- var rolldown_civet_default = civetUnplugin.rolldown;
5
+ var rolldown_default = civetUnplugin.rolldown;
6
6
  export {
7
- rolldown_civet_default as default
7
+ rolldown_default as default
8
8
  };
@@ -1,2 +1,2 @@
1
- declare const _default: (options: import("./unplugin.js").PluginOptions) => import("unplugin").RollupPlugin<any> | import("unplugin").RollupPlugin<any>[];
1
+ declare const _default: (options?: import("./unplugin.js").PluginOptions | undefined) => import("unplugin").RollupPlugin<any> | import("unplugin").RollupPlugin<any>[];
2
2
  export default _default;
@@ -1,8 +1,8 @@
1
1
  import { createRequire as __civetCreateRequire } from 'node:module'; const require = __civetCreateRequire(import.meta.url);
2
2
 
3
- // unplugin-civet:/home/runner/work/Civet/Civet/source/unplugin/rollup.civet.jsx
3
+ // unplugin-civet:/home/runner/work/Civet/Civet/source/unplugin/rollup.civet
4
4
  import civetUnplugin from "./unplugin.mjs";
5
- var rollup_civet_default = civetUnplugin.rollup;
5
+ var rollup_default = civetUnplugin.rollup;
6
6
  export {
7
- rollup_civet_default as default
7
+ rollup_default as default
8
8
  };
@@ -1,2 +1,2 @@
1
- declare const _default: (options: import("./unplugin.js").PluginOptions) => RspackPluginInstance;
1
+ declare const _default: (options?: import("./unplugin.js").PluginOptions | undefined) => RspackPluginInstance;
2
2
  export default _default;
@@ -1,8 +1,8 @@
1
1
  import { createRequire as __civetCreateRequire } from 'node:module'; const require = __civetCreateRequire(import.meta.url);
2
2
 
3
- // unplugin-civet:/home/runner/work/Civet/Civet/source/unplugin/rspack.civet.jsx
3
+ // unplugin-civet:/home/runner/work/Civet/Civet/source/unplugin/rspack.civet
4
4
  import civetUnplugin from "./unplugin.mjs";
5
- var rspack_civet_default = civetUnplugin.rspack;
5
+ var rspack_default = civetUnplugin.rspack;
6
6
  export {
7
- rspack_civet_default as default
7
+ rspack_default as default
8
8
  };
@@ -1,5 +1,7 @@
1
- import { type TransformResult, createUnplugin } from 'unplugin';
1
+ import { type TransformResult, type UnpluginContextMeta } from 'unplugin';
2
2
  import { type ParseOptions } from '@danielx/civet';
3
+ import type { UserConfig } from 'vite';
4
+ import type { BuildOptions } from 'esbuild';
3
5
  export type PluginOptions = {
4
6
  implicitExtension?: boolean;
5
7
  outputExtension?: string;
@@ -19,8 +21,30 @@ export type PluginOptions = {
19
21
  /** config filename, or false/null to not look for default config file */
20
22
  config?: string | false | null;
21
23
  parseOptions?: ParseOptions;
24
+ tsConfig?: any;
22
25
  };
23
26
  export declare function slash(p: string): string;
24
- export declare const rawPlugin: Parameters<typeof createUnplugin<PluginOptions>>[0];
25
- declare var unplugin: import("unplugin").UnpluginInstance<PluginOptions, boolean>;
27
+ export declare const rawPlugin: (options: PluginOptions | undefined, meta: UnpluginContextMeta) => {
28
+ name: string;
29
+ enforce: "pre";
30
+ buildStart(this: import("unplugin").UnpluginBuildContext): Promise<void>;
31
+ buildEnd(this: import("unplugin").UnpluginBuildContext, useConfigFileNames?: boolean): Promise<void>;
32
+ resolveId(this: import("unplugin").UnpluginBuildContext & import("unplugin").UnpluginContext, id: string, importer: string | undefined, options: {
33
+ isEntry: boolean;
34
+ }): string | null;
35
+ loadInclude(id: string): boolean;
36
+ load(this: import("unplugin").UnpluginBuildContext & import("unplugin").UnpluginContext, id: string): Promise<TransformResult>;
37
+ esbuild: {
38
+ loader: "tsx" | "jsx";
39
+ config(options: BuildOptions): void;
40
+ };
41
+ vite: {
42
+ config(this: import("vite").ConfigPluginContext, config: UserConfig): void;
43
+ transformIndexHtml(this: import("vite").MinimalPluginContextWithoutEnvironment, html: string): string;
44
+ handleHotUpdate(this: import("vite").MinimalPluginContextWithoutEnvironment, { file, server, modules }: import("vite").HmrContext): import("vite").ModuleNode[] | undefined;
45
+ };
46
+ rspack(compiler: RspackCompiler): any;
47
+ webpack(compiler: import("unplugin").WebpackCompiler): (id: string) => string;
48
+ };
49
+ declare var unplugin: import("unplugin").UnpluginInstance<PluginOptions | undefined, boolean>;
26
50
  export default unplugin;
@@ -357,14 +357,23 @@ var rawPlugin = (options = {}, meta) => {
357
357
  };
358
358
  var mogrify = mogrify2;
359
359
  const ts2 = await tsPromise;
360
- const tsConfigPath = ts2.findConfigFile(process.cwd(), ts2.sys.fileExists);
361
- if (!tsConfigPath) {
362
- throw new Error("Could not find 'tsconfig.json'");
360
+ let config, error, tsConfigPath;
361
+ if (options.tsConfig) {
362
+ config = options.tsConfig;
363
+ if (options.tsConfig.rootDir) {
364
+ tsConfigPath = import_path.default.join(options.tsConfig.rootDir, "tsconfig.json");
365
+ }
366
+ } else {
367
+ tsConfigPath = ts2.findConfigFile(process.cwd(), ts2.sys.fileExists);
368
+ if (!tsConfigPath) {
369
+ throw new Error("Could not find 'tsconfig.json'");
370
+ }
371
+ ;
372
+ ({ config, error } = ts2.readConfigFile(
373
+ tsConfigPath,
374
+ ts2.sys.readFile
375
+ ));
363
376
  }
364
- const { config, error } = ts2.readConfigFile(
365
- tsConfigPath,
366
- ts2.sys.readFile
367
- );
368
377
  if (error) {
369
378
  console.error(ts2.formatDiagnostic(error, getFormatHost(ts2.sys)));
370
379
  throw error;
@@ -379,7 +388,9 @@ var rawPlugin = (options = {}, meta) => {
379
388
  const configContents = ts2.parseJsonConfigFileContent(
380
389
  config,
381
390
  system,
382
- process.cwd()
391
+ tsConfigPath ? import_path.default.dirname(tsConfigPath) : process.cwd(),
392
+ void 0,
393
+ tsConfigPath
383
394
  );
384
395
  configErrors = configContents.errors;
385
396
  configFileNames = configContents.fileNames;
@@ -763,7 +774,7 @@ var rawPlugin = (options = {}, meta) => {
763
774
  config.resolve.extensions.push(".civet");
764
775
  }
765
776
  },
766
- async transformIndexHtml(html) {
777
+ transformIndexHtml(html) {
767
778
  return html.replace(/<!--[^]*?-->|<[^<>]*>/g, (tag) => {
768
779
  return tag.replace(/<\s*script\b[^<>]*>/gi, (script) => {
769
780
  return script.replace(
@@ -6,7 +6,7 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
6
6
  throw Error('Dynamic require of "' + x + '" is not supported');
7
7
  });
8
8
 
9
- // unplugin-civet:/home/runner/work/Civet/Civet/source/unplugin/unplugin.civet.jsx
9
+ // unplugin-civet:/home/runner/work/Civet/Civet/source/unplugin/unplugin.civet
10
10
  import { createUnplugin } from "unplugin";
11
11
  import civet, { decode, lib, SourceMap } from "@danielx/civet";
12
12
  import { findInDir, loadConfig } from "@danielx/civet/config";
@@ -187,7 +187,7 @@ var requirePath = function requirePath2() {
187
187
  return __require(String.fromCharCode(112, 97, 116, 104));
188
188
  };
189
189
 
190
- // unplugin-civet:/home/runner/work/Civet/Civet/source/unplugin/unplugin.civet.jsx
190
+ // unplugin-civet:/home/runner/work/Civet/Civet/source/unplugin/unplugin.civet
191
191
  import os from "os";
192
192
  var DEFAULT_EXTENSIONS = [".mjs", ".js", ".mts", ".ts", ".jsx", ".tsx", ".json"];
193
193
  var DiagnosticCategory = {};
@@ -331,14 +331,23 @@ var rawPlugin = (options = {}, meta) => {
331
331
  return;
332
332
  };
333
333
  const ts2 = await tsPromise;
334
- const tsConfigPath = ts2.findConfigFile(process.cwd(), ts2.sys.fileExists);
335
- if (!tsConfigPath) {
336
- throw new Error("Could not find 'tsconfig.json'");
334
+ let config, error, tsConfigPath;
335
+ if (options.tsConfig) {
336
+ config = options.tsConfig;
337
+ if (options.tsConfig.rootDir) {
338
+ tsConfigPath = path.join(options.tsConfig.rootDir, "tsconfig.json");
339
+ }
340
+ } else {
341
+ tsConfigPath = ts2.findConfigFile(process.cwd(), ts2.sys.fileExists);
342
+ if (!tsConfigPath) {
343
+ throw new Error("Could not find 'tsconfig.json'");
344
+ }
345
+ ;
346
+ ({ config, error } = ts2.readConfigFile(
347
+ tsConfigPath,
348
+ ts2.sys.readFile
349
+ ));
337
350
  }
338
- const { config, error } = ts2.readConfigFile(
339
- tsConfigPath,
340
- ts2.sys.readFile
341
- );
342
351
  if (error) {
343
352
  console.error(ts2.formatDiagnostic(error, getFormatHost(ts2.sys)));
344
353
  throw error;
@@ -353,7 +362,9 @@ var rawPlugin = (options = {}, meta) => {
353
362
  const configContents = ts2.parseJsonConfigFileContent(
354
363
  config,
355
364
  system,
356
- process.cwd()
365
+ tsConfigPath ? path.dirname(tsConfigPath) : process.cwd(),
366
+ void 0,
367
+ tsConfigPath
357
368
  );
358
369
  configErrors = configContents.errors;
359
370
  configFileNames = configContents.fileNames;
@@ -735,7 +746,7 @@ var rawPlugin = (options = {}, meta) => {
735
746
  config.resolve.extensions.push(".civet");
736
747
  }
737
748
  },
738
- async transformIndexHtml(html) {
749
+ transformIndexHtml(html) {
739
750
  return html.replace(/<!--[^]*?-->|<[^<>]*>/g, (tag) => {
740
751
  return tag.replace(/<\s*script\b[^<>]*>/gi, (script) => {
741
752
  return script.replace(
@@ -806,9 +817,9 @@ var rawPlugin = (options = {}, meta) => {
806
817
  return plugin;
807
818
  };
808
819
  var unplugin = createUnplugin(rawPlugin);
809
- var unplugin_civet_default = unplugin;
820
+ var unplugin_default = unplugin;
810
821
  export {
811
- unplugin_civet_default as default,
822
+ unplugin_default as default,
812
823
  rawPlugin,
813
824
  slash
814
825
  };
@@ -1,2 +1,2 @@
1
- declare const _default: (options: import("./unplugin.js").PluginOptions) => import("vite").Plugin<any> | import("vite").Plugin<any>[];
1
+ declare const _default: (options?: import("./unplugin.js").PluginOptions | undefined) => import("vite").Plugin<any> | import("vite").Plugin<any>[];
2
2
  export default _default;
@@ -1,8 +1,8 @@
1
1
  import { createRequire as __civetCreateRequire } from 'node:module'; const require = __civetCreateRequire(import.meta.url);
2
2
 
3
- // unplugin-civet:/home/runner/work/Civet/Civet/source/unplugin/vite.civet.jsx
3
+ // unplugin-civet:/home/runner/work/Civet/Civet/source/unplugin/vite.civet
4
4
  import civetUnplugin from "./unplugin.mjs";
5
- var vite_civet_default = civetUnplugin.vite;
5
+ var vite_default = civetUnplugin.vite;
6
6
  export {
7
- vite_civet_default as default
7
+ vite_default as default
8
8
  };
@@ -1,2 +1,2 @@
1
- declare const _default: (options: import("./unplugin.js").PluginOptions) => import("unplugin").WebpackPluginInstance;
1
+ declare const _default: (options?: import("./unplugin.js").PluginOptions | undefined) => import("unplugin").WebpackPluginInstance;
2
2
  export default _default;
@@ -1,8 +1,8 @@
1
1
  import { createRequire as __civetCreateRequire } from 'node:module'; const require = __civetCreateRequire(import.meta.url);
2
2
 
3
- // unplugin-civet:/home/runner/work/Civet/Civet/source/unplugin/webpack.civet.jsx
3
+ // unplugin-civet:/home/runner/work/Civet/Civet/source/unplugin/webpack.civet
4
4
  import civetUnplugin from "./unplugin.mjs";
5
- var webpack_civet_default = civetUnplugin.webpack;
5
+ var webpack_default = civetUnplugin.webpack;
6
6
  export {
7
- webpack_civet_default as default
7
+ webpack_default as default
8
8
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@danielx/civet",
3
3
  "type": "commonjs",
4
- "version": "0.11.6",
4
+ "version": "0.11.7",
5
5
  "description": "CoffeeScript style syntax for TypeScript",
6
6
  "main": "dist/main.js",
7
7
  "module": "dist/main.mjs",
@@ -104,6 +104,7 @@
104
104
  "test": "bash ./build/test.sh",
105
105
  "test:coverage": "cross-env CIVET_COVERAGE=1 bash ./build/test.sh",
106
106
  "test:self": "cross-env CIVET_SOURCE=./dist/main.js pnpm test",
107
+ "test:brk": "cross-env CIVET_THREADS=0 pnpm test --inspect-brk",
107
108
  "changelog": "civet build/changelog.civet",
108
109
  "release": "pnpm changelog --release"
109
110
  },
@@ -116,14 +117,14 @@
116
117
  "devDependencies": {
117
118
  "@babel/core": "^7.29.0",
118
119
  "@babel/parser": "^7.29.2",
119
- "@danielx/civet": "0.9.4",
120
- "@danielx/hera": "0.8.19",
120
+ "@danielx/civet": "0.11.6",
121
+ "@danielx/hera": "0.8.20",
121
122
  "@prettier/sync": "^0.5.2",
122
123
  "@types/assert": "^1.5.6",
123
124
  "@types/mocha": "^10.0.8",
124
125
  "@types/node": "^22.10.2",
125
126
  "@typescript/vfs": "^1.6.4",
126
- "c8": "^7.12.0",
127
+ "c8": "^11.0.0",
127
128
  "cross-env": "7.0.3",
128
129
  "esbuild": "0.27.5",
129
130
  "marked": "^4.2.4",
@@ -133,7 +134,7 @@
133
134
  "terser": "^5.16.1",
134
135
  "tslib": "^2.4.0",
135
136
  "typescript": "^5.5.2",
136
- "vite": "^8.0.3",
137
+ "vite": "^8.0.8",
137
138
  "vitepress": "^1.0.0-alpha.35",
138
139
  "vscode-languageserver": "^8.1.0",
139
140
  "vscode-languageserver-textdocument": "^1.0.8",
@@ -180,7 +181,7 @@
180
181
  "serialize-javascript": "^7.0.3",
181
182
  "tmp": "^0.2.5",
182
183
  "lodash": "^4.18.0",
183
- "esbuild": "^0.27.0",
184
+ "esbuild": "0.27.5",
184
185
  "diff": "^8.0.3"
185
186
  }
186
187
  }