@danielx/civet 0.11.5 → 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.
Files changed (43) hide show
  1. package/CHANGELOG.md +306 -0
  2. package/README.md +2 -7
  3. package/dist/babel-plugin.js +7 -6
  4. package/dist/babel-plugin.mjs +3 -3
  5. package/dist/browser.js +807 -540
  6. package/dist/civet +24 -18
  7. package/dist/config.js +7313 -7
  8. package/dist/config.mjs +7338 -4
  9. package/dist/esbuild-plugin.js +7 -6
  10. package/dist/esm.mjs +10 -16
  11. package/dist/main.js +1787 -895
  12. package/dist/main.mjs +1782 -891
  13. package/dist/node-worker.mjs +1 -2
  14. package/dist/ts-diagnostic.js +5 -4
  15. package/dist/ts-diagnostic.mjs +1 -1
  16. package/dist/types.d.ts +11 -2
  17. package/dist/unplugin/astro.js +8 -7
  18. package/dist/unplugin/astro.mjs +6 -4
  19. package/dist/unplugin/esbuild.d.ts +1 -1
  20. package/dist/unplugin/esbuild.js +7 -6
  21. package/dist/unplugin/esbuild.mjs +5 -3
  22. package/dist/unplugin/farm.d.ts +3 -1
  23. package/dist/unplugin/farm.js +7 -6
  24. package/dist/unplugin/farm.mjs +6 -4
  25. package/dist/unplugin/rolldown.d.ts +1 -1
  26. package/dist/unplugin/rolldown.js +7 -6
  27. package/dist/unplugin/rolldown.mjs +5 -3
  28. package/dist/unplugin/rollup.d.ts +1 -1
  29. package/dist/unplugin/rollup.js +7 -6
  30. package/dist/unplugin/rollup.mjs +5 -3
  31. package/dist/unplugin/rspack.d.ts +1 -1
  32. package/dist/unplugin/rspack.js +7 -6
  33. package/dist/unplugin/rspack.mjs +5 -3
  34. package/dist/unplugin/unplugin.d.ts +27 -3
  35. package/dist/unplugin/unplugin.js +68 -42
  36. package/dist/unplugin/unplugin.mjs +53 -30
  37. package/dist/unplugin/vite.d.ts +1 -1
  38. package/dist/unplugin/vite.js +7 -6
  39. package/dist/unplugin/vite.mjs +5 -3
  40. package/dist/unplugin/webpack.d.ts +1 -1
  41. package/dist/unplugin/webpack.js +7 -6
  42. package/dist/unplugin/webpack.mjs +5 -3
  43. package/package.json +33 -17
@@ -1,4 +1,4 @@
1
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\node-worker.civet.jsx
1
+ // source/node-worker.civet
2
2
  import { parentPort } from "node:worker_threads";
3
3
  import module from "node:module";
4
4
  try {
@@ -22,7 +22,6 @@ try {
22
22
  }
23
23
  return parentPort.postMessage({ id, result, errors: args[1]?.errors });
24
24
  } catch (error) {
25
- console.log(`Civet worker failed to compile:`, error);
26
25
  return parentPort.postMessage({ id, error: {
27
26
  type: error.constructor.name,
28
27
  name: error.name,
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  var __defProp = Object.defineProperty;
2
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -15,13 +16,13 @@ var __copyProps = (to, from, except, desc) => {
15
16
  return to;
16
17
  };
17
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var ts_diagnostic_civet_exports = {};
19
- __export(ts_diagnostic_civet_exports, {
19
+ var ts_diagnostic_exports = {};
20
+ __export(ts_diagnostic_exports, {
20
21
  flattenDiagnosticMessageText: () => flattenDiagnosticMessageText,
21
22
  remapPosition: () => remapPosition,
22
23
  remapRange: () => remapRange
23
24
  });
24
- module.exports = __toCommonJS(ts_diagnostic_civet_exports);
25
+ module.exports = __toCommonJS(ts_diagnostic_exports);
25
26
  function remapPosition(position, sourcemapLines) {
26
27
  if (!sourcemapLines) return position;
27
28
  const { line, character } = position;
@@ -46,7 +47,7 @@ function remapPosition(position, sourcemapLines) {
46
47
  const newChar = srcChar + character - lastMappingPosition;
47
48
  return {
48
49
  line: srcLine,
49
- character: newChar
50
+ character: Math.max(0, newChar)
50
51
  };
51
52
  } else {
52
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
@@ -70,6 +72,10 @@ declare module "@danielx/civet" {
70
72
  * Default is false.
71
73
  */
72
74
  inlineMap?: boolean
75
+ /**
76
+ * Upstream source map to chain with Civet's generated source map.
77
+ */
78
+ upstreamSourceMap?: string | object
73
79
  /**
74
80
  * Whether to return an AST of the parsed code instead of transpiled code.
75
81
  * Default is false.
@@ -142,10 +148,13 @@ declare module "@danielx/civet" {
142
148
  export type SourceMapping = [number] | [number, number, number, number]
143
149
 
144
150
  export class SourceMap {
145
- constructor(source: string)
151
+ constructor(source: string, sourceFileName: string)
146
152
  updateSourceMap?(outputStr: string, inputPos: number): void
147
- json(srcFileName: string, outFileName: string): unknown
153
+ json(outFileName: string): unknown
154
+ composeUpstream(upstreamMap: string | object): void
155
+ composeDownstream(downstreamMap: string | object): void
148
156
  source: string
157
+ sourceFileName: string
149
158
  lines: SourceMapping[][]
150
159
  /** @deprecated */
151
160
  data: { lines: SourceMapping[][] }
@@ -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,14 +27,14 @@ 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\astro.civet.jsx
30
- var astro_civet_exports = {};
31
- __export(astro_civet_exports, {
32
- default: () => astro_civet_default
30
+ // source/unplugin/astro.civet
31
+ var astro_exports = {};
32
+ __export(astro_exports, {
33
+ default: () => astro_default
33
34
  });
34
- module.exports = __toCommonJS(astro_civet_exports);
35
+ module.exports = __toCommonJS(astro_exports);
35
36
  var import_unplugin = __toESM(require("./unplugin.js"));
36
- var astro_civet_default = function(opts = {}) {
37
+ var astro_default = (function(opts = {}) {
37
38
  return {
38
39
  name: "@danielx/civet",
39
40
  hooks: {
@@ -46,4 +47,4 @@ var astro_civet_default = function(opts = {}) {
46
47
  }
47
48
  }
48
49
  };
49
- };
50
+ });
@@ -1,6 +1,8 @@
1
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\unplugin\astro.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/astro.civet
2
4
  import civetUnplugin, {} from "./unplugin.mjs";
3
- var astro_civet_default = function(opts = {}) {
5
+ var astro_default = (function(opts = {}) {
4
6
  return {
5
7
  name: "@danielx/civet",
6
8
  hooks: {
@@ -13,7 +15,7 @@ var astro_civet_default = function(opts = {}) {
13
15
  }
14
16
  }
15
17
  };
16
- };
18
+ });
17
19
  export {
18
- astro_civet_default as default
20
+ astro_default as default
19
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,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\esbuild.civet.jsx
30
- var esbuild_civet_exports = {};
31
- __export(esbuild_civet_exports, {
32
- default: () => esbuild_civet_default
30
+ // source/unplugin/esbuild.civet
31
+ var esbuild_exports = {};
32
+ __export(esbuild_exports, {
33
+ default: () => esbuild_default
33
34
  });
34
- module.exports = __toCommonJS(esbuild_civet_exports);
35
+ module.exports = __toCommonJS(esbuild_exports);
35
36
  var import_unplugin = __toESM(require("./unplugin.js"));
36
- var esbuild_civet_default = import_unplugin.default.esbuild;
37
+ var esbuild_default = import_unplugin.default.esbuild;
@@ -1,6 +1,8 @@
1
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\unplugin\esbuild.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/esbuild.civet
2
4
  import civetUnplugin from "./unplugin.mjs";
3
- var esbuild_civet_default = civetUnplugin.esbuild;
5
+ var esbuild_default = civetUnplugin.esbuild;
4
6
  export {
5
- esbuild_civet_default as default
7
+ esbuild_default as default
6
8
  };
@@ -1,2 +1,4 @@
1
- declare const _default: (options: import("./unplugin.js").PluginOptions) => JsPlugin;
1
+ import type { UnpluginInstance } from "unplugin";
2
+ import { type PluginOptions } from "./unplugin.js";
3
+ declare const _default: UnpluginInstance<PluginOptions>["farm"];
2
4
  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\farm.civet.jsx
30
- var farm_civet_exports = {};
31
- __export(farm_civet_exports, {
32
- default: () => farm_civet_default
30
+ // source/unplugin/farm.civet
31
+ var farm_exports = {};
32
+ __export(farm_exports, {
33
+ default: () => farm_default
33
34
  });
34
- module.exports = __toCommonJS(farm_civet_exports);
35
+ module.exports = __toCommonJS(farm_exports);
35
36
  var import_unplugin = __toESM(require("./unplugin.js"));
36
- var farm_civet_default = import_unplugin.default.farm;
37
+ var farm_default = import_unplugin.default.farm;
@@ -1,6 +1,8 @@
1
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\unplugin\farm.civet.jsx
2
- import civetUnplugin from "./unplugin.mjs";
3
- var farm_civet_default = civetUnplugin.farm;
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/farm.civet
4
+ import civetUnplugin, {} from "./unplugin.mjs";
5
+ var farm_default = civetUnplugin.farm;
4
6
  export {
5
- farm_civet_default as default
7
+ farm_default as default
6
8
  };
@@ -1,2 +1,2 @@
1
- declare const _default: (options: import("./unplugin.js").PluginOptions) => 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,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\rolldown.civet.jsx
30
- var rolldown_civet_exports = {};
31
- __export(rolldown_civet_exports, {
32
- default: () => rolldown_civet_default
30
+ // source/unplugin/rolldown.civet
31
+ var rolldown_exports = {};
32
+ __export(rolldown_exports, {
33
+ default: () => rolldown_default
33
34
  });
34
- module.exports = __toCommonJS(rolldown_civet_exports);
35
+ module.exports = __toCommonJS(rolldown_exports);
35
36
  var import_unplugin = __toESM(require("./unplugin.js"));
36
- var rolldown_civet_default = import_unplugin.default.rolldown;
37
+ var rolldown_default = import_unplugin.default.rolldown;
@@ -1,6 +1,8 @@
1
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\unplugin\rolldown.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/rolldown.civet
2
4
  import civetUnplugin from "./unplugin.mjs";
3
- var rolldown_civet_default = civetUnplugin.rolldown;
5
+ var rolldown_default = civetUnplugin.rolldown;
4
6
  export {
5
- rolldown_civet_default as default
7
+ rolldown_default as default
6
8
  };
@@ -1,2 +1,2 @@
1
- declare const _default: (options: import("./unplugin.js").PluginOptions) => import("rollup").Plugin<any> | import("rollup").Plugin<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,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\rollup.civet.jsx
30
- var rollup_civet_exports = {};
31
- __export(rollup_civet_exports, {
32
- default: () => rollup_civet_default
30
+ // source/unplugin/rollup.civet
31
+ var rollup_exports = {};
32
+ __export(rollup_exports, {
33
+ default: () => rollup_default
33
34
  });
34
- module.exports = __toCommonJS(rollup_civet_exports);
35
+ module.exports = __toCommonJS(rollup_exports);
35
36
  var import_unplugin = __toESM(require("./unplugin.js"));
36
- var rollup_civet_default = import_unplugin.default.rollup;
37
+ var rollup_default = import_unplugin.default.rollup;
@@ -1,6 +1,8 @@
1
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\unplugin\rollup.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/rollup.civet
2
4
  import civetUnplugin from "./unplugin.mjs";
3
- var rollup_civet_default = civetUnplugin.rollup;
5
+ var rollup_default = civetUnplugin.rollup;
4
6
  export {
5
- rollup_civet_default as default
7
+ rollup_default as default
6
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,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\rspack.civet.jsx
30
- var rspack_civet_exports = {};
31
- __export(rspack_civet_exports, {
32
- default: () => rspack_civet_default
30
+ // source/unplugin/rspack.civet
31
+ var rspack_exports = {};
32
+ __export(rspack_exports, {
33
+ default: () => rspack_default
33
34
  });
34
- module.exports = __toCommonJS(rspack_civet_exports);
35
+ module.exports = __toCommonJS(rspack_exports);
35
36
  var import_unplugin = __toESM(require("./unplugin.js"));
36
- var rspack_civet_default = import_unplugin.default.rspack;
37
+ var rspack_default = import_unplugin.default.rspack;
@@ -1,6 +1,8 @@
1
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\unplugin\rspack.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/rspack.civet
2
4
  import civetUnplugin from "./unplugin.mjs";
3
- var rspack_civet_default = civetUnplugin.rspack;
5
+ var rspack_default = civetUnplugin.rspack;
4
6
  export {
5
- rspack_civet_default as default
7
+ rspack_default as default
6
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;