@powerlines/plugin-react 0.1.122 → 0.1.123

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 (100) hide show
  1. package/dist/_virtual/rolldown_runtime.cjs +37 -1
  2. package/dist/_virtual/rolldown_runtime.mjs +29 -1
  3. package/dist/components/index.cjs +3 -1
  4. package/dist/components/index.mjs +3 -1
  5. package/dist/components/react-optimized.cjs +45 -1
  6. package/dist/components/react-optimized.mjs +43 -1
  7. package/dist/deepkit/schemas/reflection.cjs +3940 -1
  8. package/dist/deepkit/schemas/reflection.mjs +3938 -1
  9. package/dist/deepkit/schemas/reflection2.cjs +4112 -1
  10. package/dist/deepkit/schemas/reflection2.mjs +4110 -1
  11. package/dist/deepkit/src/capnp.cjs +913 -1
  12. package/dist/deepkit/src/capnp.mjs +911 -1
  13. package/dist/deepkit/src/esbuild-plugin.cjs +47 -4
  14. package/dist/deepkit/src/esbuild-plugin.mjs +46 -4
  15. package/dist/deepkit/src/reflect-type.cjs +22 -1
  16. package/dist/deepkit/src/reflect-type.mjs +20 -1
  17. package/dist/deepkit/src/resolve-reflections.cjs +16 -1
  18. package/dist/deepkit/src/resolve-reflections.mjs +15 -1
  19. package/dist/deepkit/src/transformer.cjs +52 -1
  20. package/dist/deepkit/src/transformer.mjs +49 -1
  21. package/dist/deepkit/src/transpile.cjs +29 -1
  22. package/dist/deepkit/src/transpile.mjs +27 -1
  23. package/dist/deepkit/src/utilities.cjs +66 -1
  24. package/dist/deepkit/src/utilities.mjs +65 -1
  25. package/dist/deepkit/src/vendor/type-compiler/index.cjs +38 -1
  26. package/dist/deepkit/src/vendor/type-compiler/index.mjs +19 -1
  27. package/dist/deepkit/src/vendor/type.cjs +20 -1
  28. package/dist/deepkit/src/vendor/type.mjs +11 -1
  29. package/dist/index.cjs +104 -1
  30. package/dist/index.mjs +98 -1
  31. package/dist/plugin-alloy/src/core/components/output.cjs +45 -1
  32. package/dist/plugin-alloy/src/core/components/output.mjs +44 -1
  33. package/dist/plugin-alloy/src/core/contexts/context.cjs +11 -1
  34. package/dist/plugin-alloy/src/core/contexts/context.mjs +10 -1
  35. package/dist/plugin-alloy/src/index.cjs +93 -1
  36. package/dist/plugin-alloy/src/index.mjs +91 -1
  37. package/dist/plugin-automd/src/index.cjs +101 -1
  38. package/dist/plugin-automd/src/index.mjs +98 -1
  39. package/dist/plugin-babel/src/helpers/ast-utils.cjs +10 -1
  40. package/dist/plugin-babel/src/helpers/ast-utils.mjs +9 -1
  41. package/dist/plugin-babel/src/helpers/create-plugin.cjs +41 -1
  42. package/dist/plugin-babel/src/helpers/create-plugin.mjs +39 -1
  43. package/dist/plugin-babel/src/helpers/filters.cjs +23 -1
  44. package/dist/plugin-babel/src/helpers/filters.mjs +21 -1
  45. package/dist/plugin-babel/src/helpers/index.cjs +5 -1
  46. package/dist/plugin-babel/src/helpers/index.mjs +7 -1
  47. package/dist/plugin-babel/src/helpers/module-helpers.cjs +38 -1
  48. package/dist/plugin-babel/src/helpers/module-helpers.mjs +35 -1
  49. package/dist/plugin-babel/src/helpers/options.cjs +50 -1
  50. package/dist/plugin-babel/src/helpers/options.mjs +47 -1
  51. package/dist/plugin-babel/src/index.cjs +91 -1
  52. package/dist/plugin-babel/src/index.mjs +89 -1
  53. package/dist/plugin-env/src/babel/index.cjs +1 -1
  54. package/dist/plugin-env/src/babel/index.mjs +3 -1
  55. package/dist/plugin-env/src/babel/plugin.cjs +120 -4
  56. package/dist/plugin-env/src/babel/plugin.mjs +118 -4
  57. package/dist/plugin-env/src/components/docs.cjs +9 -1
  58. package/dist/plugin-env/src/components/docs.mjs +11 -1
  59. package/dist/plugin-env/src/components/env.cjs +432 -11
  60. package/dist/plugin-env/src/components/env.mjs +430 -9
  61. package/dist/plugin-env/src/components/index.cjs +2 -1
  62. package/dist/plugin-env/src/components/index.mjs +4 -1
  63. package/dist/plugin-env/src/helpers/automd-generator.cjs +22 -1
  64. package/dist/plugin-env/src/helpers/automd-generator.mjs +21 -1
  65. package/dist/plugin-env/src/helpers/create-reflection-resource.cjs +55 -1
  66. package/dist/plugin-env/src/helpers/create-reflection-resource.mjs +54 -1
  67. package/dist/plugin-env/src/helpers/index.cjs +6 -1
  68. package/dist/plugin-env/src/helpers/index.mjs +8 -1
  69. package/dist/plugin-env/src/helpers/load.cjs +83 -1
  70. package/dist/plugin-env/src/helpers/load.mjs +80 -1
  71. package/dist/plugin-env/src/helpers/persistence.cjs +200 -1
  72. package/dist/plugin-env/src/helpers/persistence.mjs +189 -1
  73. package/dist/plugin-env/src/helpers/reflect.cjs +111 -1
  74. package/dist/plugin-env/src/helpers/reflect.mjs +103 -1
  75. package/dist/plugin-env/src/helpers/source-file-env.cjs +24 -1
  76. package/dist/plugin-env/src/helpers/source-file-env.mjs +23 -1
  77. package/dist/plugin-env/src/helpers/template-helpers.cjs +2 -1
  78. package/dist/plugin-env/src/helpers/template-helpers.mjs +4 -1
  79. package/dist/plugin-env/src/index.cjs +170 -5
  80. package/dist/plugin-env/src/index.mjs +168 -5
  81. package/dist/powerlines/src/lib/build/esbuild.cjs +102 -14
  82. package/dist/powerlines/src/lib/build/esbuild.mjs +100 -14
  83. package/dist/powerlines/src/lib/entry.cjs +12 -1
  84. package/dist/powerlines/src/lib/entry.mjs +14 -1
  85. package/dist/powerlines/src/lib/logger.cjs +41 -1
  86. package/dist/powerlines/src/lib/logger.mjs +39 -1
  87. package/dist/powerlines/src/lib/typescript/tsconfig.cjs +38 -1
  88. package/dist/powerlines/src/lib/typescript/tsconfig.mjs +35 -1
  89. package/dist/powerlines/src/lib/utilities/bundle.cjs +35 -1
  90. package/dist/powerlines/src/lib/utilities/bundle.mjs +34 -1
  91. package/dist/powerlines/src/lib/utilities/resolve.cjs +30 -1
  92. package/dist/powerlines/src/lib/utilities/resolve.mjs +29 -1
  93. package/dist/powerlines/src/plugin-utils/paths.cjs +1 -1
  94. package/dist/powerlines/src/plugin-utils/paths.mjs +3 -1
  95. package/dist/powerlines/src/types/context.d.cts +27 -3
  96. package/dist/powerlines/src/types/context.d.mts +27 -3
  97. package/dist/types/index.mjs +1 -1
  98. package/dist/types/plugin.mjs +1 -1
  99. package/dist/types/runtime.mjs +1 -1
  100. package/package.json +10 -10
@@ -1 +1,98 @@
1
- import e from"defu";import{replacePath as t}from"@stryke/path/replace";import{toArray as n}from"@stryke/convert/to-array";import{isDirectory as r}from"@stryke/fs/is-file";import{listFiles as i}from"@stryke/fs/list-files";import{appendPath as a}from"@stryke/path/append";import{isAbsolutePath as o}from"@stryke/path/is-type";import{joinPaths as s}from"@stryke/path/join-paths";import{loadConfig as c,resolveConfig as l,transform as u}from"automd";import{loadConfig as d}from"c12";import f from"markdown-toc";var p=(p={})=>({name:`automd`,async config(){let t=await c(s(this.workspaceConfig.workspaceRoot,this.config.projectRoot),p);return(!t.prefix||!Array.isArray(t.prefix))&&(t.prefix=n(t.prefix??[])),t.prefix.includes(`automd`)||t.prefix.push(`automd`),t.prefix.includes(`powerlines`)||t.prefix.push(`powerlines`),{automd:e(t??{},{configFile:p.configFile,allowIssues:!0,dir:this.config.projectRoot,watch:!1,input:`README.md`,toc:{maxDepth:6,bullets:`-`}})}},async configResolved(){if(this.config.framework&&!n(this.config.automd.prefix).includes(this.config.framework)&&(this.config.automd.prefix=n(this.config.automd.prefix).concat(this.config.framework)),this.config.automd.configFile){let{config:t}=await d({cwd:this.config.automd.dir,configFile:this.config.automd.configFile,defaults:{ignore:[`**/node_modules`,`**/dist`,`**/.*`],dir:this.config.automd.dir}});this.config.automd=l(e(this.config.automd,{...t,prefix:n(t.prefix??[])}))}this.config.automd.input=(await Promise.all(n(this.config.automd.input).map(async e=>e.includes(`*`)?i(o(e)?e:a(e,this.config.projectRoot),{ignore:this.config.automd.ignore}):o(e)?e:a(e,this.config.projectRoot)))).flat(),this.config.automd.output&&!o(this.config.automd.output)&&(this.config.automd.output=a(this.config.automd.output,this.config.projectRoot)),this.config.automd.generators??={},this.config.automd.toc!==!1&&(this.config.automd.generators.toc??={name:`toc`,generate:e=>{let t=this.config.automd.toc??{};return{contents:f(e.block.md,{...t,maxdepth:t.maxDepth,first1:t.firstH1}).content}}})},async docs(){await Promise.all(n(this.config.automd.input).map(async e=>{let n=await this.fs.read(e);if(n){let i=await u(n,this.config.automd);if(i.hasIssues&&this.config.automd.allowIssues===!1)throw Error(`AutoMD found issues in file "${e}". Please resolve the issues or set \`allowIssues\` to true in the plugin configuration to ignore them.`);i.hasChanged&&await this.fs.write(a(this.config.automd.output?r(this.config.automd.output)?t(e,this.config.automd.output):this.config.automd.output:e,this.config.projectRoot),i.contents)}}))}});export{p as default};
1
+ import defu from "defu";
2
+ import { replacePath } from "@stryke/path/replace";
3
+ import { toArray } from "@stryke/convert/to-array";
4
+ import { isDirectory } from "@stryke/fs/is-file";
5
+ import { listFiles } from "@stryke/fs/list-files";
6
+ import { appendPath } from "@stryke/path/append";
7
+ import { isAbsolutePath } from "@stryke/path/is-type";
8
+ import { joinPaths } from "@stryke/path/join-paths";
9
+ import { loadConfig, resolveConfig, transform } from "automd";
10
+ import { loadConfig as loadConfig$1 } from "c12";
11
+ import toc from "markdown-toc";
12
+
13
+ //#region ../plugin-automd/src/index.ts
14
+ /**
15
+ * AutoMD Plugin
16
+ *
17
+ * @remarks
18
+ * A Powerlines plugin to use the AutoMD markdown transformer during the prepare task.
19
+ *
20
+ * @see https://automd.unjs.io/
21
+ *
22
+ * @param options - The plugin options.
23
+ * @returns A Powerlines plugin instance.
24
+ */
25
+ const plugin = (options = {}) => {
26
+ return {
27
+ name: "automd",
28
+ async config() {
29
+ const config = await loadConfig(joinPaths(this.workspaceConfig.workspaceRoot, this.config.projectRoot), options);
30
+ if (!config.prefix || !Array.isArray(config.prefix)) config.prefix = toArray(config.prefix ?? []);
31
+ if (!config.prefix.includes("automd")) config.prefix.push("automd");
32
+ if (!config.prefix.includes("powerlines")) config.prefix.push("powerlines");
33
+ return { automd: defu(config ?? {}, {
34
+ configFile: options.configFile,
35
+ allowIssues: true,
36
+ dir: this.config.projectRoot,
37
+ watch: false,
38
+ input: "README.md",
39
+ toc: {
40
+ maxDepth: 6,
41
+ bullets: "-"
42
+ }
43
+ }) };
44
+ },
45
+ async configResolved() {
46
+ if (this.config.framework && !toArray(this.config.automd.prefix).includes(this.config.framework)) this.config.automd.prefix = toArray(this.config.automd.prefix).concat(this.config.framework);
47
+ if (this.config.automd.configFile) {
48
+ const { config } = await loadConfig$1({
49
+ cwd: this.config.automd.dir,
50
+ configFile: this.config.automd.configFile,
51
+ defaults: {
52
+ ignore: [
53
+ "**/node_modules",
54
+ "**/dist",
55
+ "**/.*"
56
+ ],
57
+ dir: this.config.automd.dir
58
+ }
59
+ });
60
+ this.config.automd = resolveConfig(defu(this.config.automd, {
61
+ ...config,
62
+ prefix: toArray(config.prefix ?? [])
63
+ }));
64
+ }
65
+ this.config.automd.input = (await Promise.all(toArray(this.config.automd.input).map(async (input) => {
66
+ if (input.includes("*")) return listFiles(isAbsolutePath(input) ? input : appendPath(input, this.config.projectRoot), { ignore: this.config.automd.ignore });
67
+ return isAbsolutePath(input) ? input : appendPath(input, this.config.projectRoot);
68
+ }))).flat();
69
+ if (this.config.automd.output && !isAbsolutePath(this.config.automd.output)) this.config.automd.output = appendPath(this.config.automd.output, this.config.projectRoot);
70
+ this.config.automd.generators ??= {};
71
+ if (this.config.automd.toc !== false) this.config.automd.generators.toc ??= {
72
+ name: "toc",
73
+ generate: (ctx) => {
74
+ const opts = this.config.automd.toc ?? {};
75
+ return { contents: toc(ctx.block.md, {
76
+ ...opts,
77
+ maxdepth: opts.maxDepth,
78
+ first1: opts.firstH1
79
+ }).content };
80
+ }
81
+ };
82
+ },
83
+ async docs() {
84
+ await Promise.all(toArray(this.config.automd.input).map(async (input) => {
85
+ const contents = await this.fs.read(input);
86
+ if (contents) {
87
+ const result = await transform(contents, this.config.automd);
88
+ if (result.hasIssues && this.config.automd.allowIssues === false) throw new Error(`AutoMD found issues in file "${input}". Please resolve the issues or set \`allowIssues\` to true in the plugin configuration to ignore them.`);
89
+ if (result.hasChanged) await this.fs.write(appendPath(this.config.automd.output ? isDirectory(this.config.automd.output) ? replacePath(input, this.config.automd.output) : this.config.automd.output : input, this.config.projectRoot), result.contents);
90
+ }
91
+ }));
92
+ }
93
+ };
94
+ };
95
+ var src_default = plugin;
96
+
97
+ //#endregion
98
+ export { src_default as default };
@@ -1 +1,10 @@
1
- const e=require(`../../../_virtual/rolldown_runtime.cjs`);let t=require(`@babel/generator`);t=e.__toESM(t),require(`@babel/parser`);let n=t.default;`default`in n&&(n=n.default);
1
+ const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
2
+ let __babel_generator = require("@babel/generator");
3
+ __babel_generator = require_rolldown_runtime.__toESM(__babel_generator);
4
+ require("@babel/parser");
5
+
6
+ //#region ../plugin-babel/src/helpers/ast-utils.ts
7
+ let generate = __babel_generator.default;
8
+ if ("default" in generate) generate = generate.default;
9
+
10
+ //#endregion
@@ -1 +1,9 @@
1
- import e from"@babel/generator";import"@babel/parser";let t=e;`default`in t&&(t=t.default);export{};
1
+ import _generate from "@babel/generator";
2
+ import "@babel/parser";
3
+
4
+ //#region ../plugin-babel/src/helpers/ast-utils.ts
5
+ let generate = _generate;
6
+ if ("default" in generate) generate = generate.default;
7
+
8
+ //#endregion
9
+ export { };
@@ -1 +1,41 @@
1
- const e=require(`../../../_virtual/rolldown_runtime.cjs`),t=require(`../../../powerlines/src/lib/logger.cjs`);let n=require(`@storm-software/config-tools/types`),r=require(`chalk`);r=e.__toESM(r);let i=require(`@babel/helper-plugin-utils`);function a(e,a){let o=o=>(0,i.declare)((i,s,c)=>{i.cache.using(()=>o.meta.checksum),i.assertVersion(`^7.0.0-0`);let l=t.extendLog(o.log,e);l(n.LogLevelLabel.TRACE,`Initializing the ${r.default.bold.cyanBright(e)} Babel plugin`);let u=a({log:l,name:e,api:i,options:s,context:o,dirname:c});return u.name=e,l(n.LogLevelLabel.TRACE,`Completed initialization of the ${r.default.bold.cyanBright(e)} Babel plugin`),u});return o.$$name=e,o}exports.createBabelPlugin=a;
1
+ const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
2
+ const require_logger = require('../../../powerlines/src/lib/logger.cjs');
3
+ let __storm_software_config_tools_types = require("@storm-software/config-tools/types");
4
+ let chalk = require("chalk");
5
+ chalk = require_rolldown_runtime.__toESM(chalk);
6
+ let __babel_helper_plugin_utils = require("@babel/helper-plugin-utils");
7
+
8
+ //#region ../plugin-babel/src/helpers/create-plugin.ts
9
+ /**
10
+ * Create a Babel plugin using the provided builder function.
11
+ *
12
+ * @param name - The name of the plugin.
13
+ * @param builder - The builder function that defines the plugin behavior.
14
+ * @returns A Babel plugin declaration.
15
+ */
16
+ function createBabelPlugin(name, builder) {
17
+ const plugin = (context) => {
18
+ return (0, __babel_helper_plugin_utils.declare)((api, options, dirname) => {
19
+ api.cache.using(() => context.meta.checksum);
20
+ api.assertVersion("^7.0.0-0");
21
+ const log = require_logger.extendLog(context.log, name);
22
+ log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Initializing the ${chalk.default.bold.cyanBright(name)} Babel plugin`);
23
+ const result = builder({
24
+ log,
25
+ name,
26
+ api,
27
+ options,
28
+ context,
29
+ dirname
30
+ });
31
+ result.name = name;
32
+ log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Completed initialization of the ${chalk.default.bold.cyanBright(name)} Babel plugin`);
33
+ return result;
34
+ });
35
+ };
36
+ plugin.$$name = name;
37
+ return plugin;
38
+ }
39
+
40
+ //#endregion
41
+ exports.createBabelPlugin = createBabelPlugin;
@@ -1 +1,39 @@
1
- import{extendLog as e}from"../../../powerlines/src/lib/logger.mjs";import{LogLevelLabel as t}from"@storm-software/config-tools/types";import n from"chalk";import{declare as r}from"@babel/helper-plugin-utils";function i(i,a){let o=o=>r((r,s,c)=>{r.cache.using(()=>o.meta.checksum),r.assertVersion(`^7.0.0-0`);let l=e(o.log,i);l(t.TRACE,`Initializing the ${n.bold.cyanBright(i)} Babel plugin`);let u=a({log:l,name:i,api:r,options:s,context:o,dirname:c});return u.name=i,l(t.TRACE,`Completed initialization of the ${n.bold.cyanBright(i)} Babel plugin`),u});return o.$$name=i,o}export{i as createBabelPlugin};
1
+ import { extendLog } from "../../../powerlines/src/lib/logger.mjs";
2
+ import { LogLevelLabel } from "@storm-software/config-tools/types";
3
+ import chalk from "chalk";
4
+ import { declare } from "@babel/helper-plugin-utils";
5
+
6
+ //#region ../plugin-babel/src/helpers/create-plugin.ts
7
+ /**
8
+ * Create a Babel plugin using the provided builder function.
9
+ *
10
+ * @param name - The name of the plugin.
11
+ * @param builder - The builder function that defines the plugin behavior.
12
+ * @returns A Babel plugin declaration.
13
+ */
14
+ function createBabelPlugin(name, builder) {
15
+ const plugin = (context) => {
16
+ return declare((api, options, dirname) => {
17
+ api.cache.using(() => context.meta.checksum);
18
+ api.assertVersion("^7.0.0-0");
19
+ const log = extendLog(context.log, name);
20
+ log(LogLevelLabel.TRACE, `Initializing the ${chalk.bold.cyanBright(name)} Babel plugin`);
21
+ const result = builder({
22
+ log,
23
+ name,
24
+ api,
25
+ options,
26
+ context,
27
+ dirname
28
+ });
29
+ result.name = name;
30
+ log(LogLevelLabel.TRACE, `Completed initialization of the ${chalk.bold.cyanBright(name)} Babel plugin`);
31
+ return result;
32
+ });
33
+ };
34
+ plugin.$$name = name;
35
+ return plugin;
36
+ }
37
+
38
+ //#endregion
39
+ export { createBabelPlugin };
@@ -1 +1,23 @@
1
- const e=require(`../../../_virtual/rolldown_runtime.cjs`);let t=require(`@stryke/type-checks/is-function`);require(`@stryke/type-checks/is-object`);let n=require(`@stryke/type-checks/is-set-string`);function r(e){return(0,n.isSetString)(e)?e:Array.isArray(e)&&e.length>0?r(e[0]):e.$$name||e.name?e.$$name||e.name:void 0}function i(e,t){return!!(r(t)&&e.some(e=>Array.isArray(e)&&r(e[0])===r(t)))}exports.getPluginName=r,exports.isDuplicatePlugin=i;
1
+ const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
2
+ let __stryke_type_checks_is_function = require("@stryke/type-checks/is-function");
3
+ require("@stryke/type-checks/is-object");
4
+ let __stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
5
+
6
+ //#region ../plugin-babel/src/helpers/filters.ts
7
+ function getPluginName(plugin) {
8
+ return (0, __stryke_type_checks_is_set_string.isSetString)(plugin) ? plugin : Array.isArray(plugin) && plugin.length > 0 ? getPluginName(plugin[0]) : plugin.$$name || plugin.name ? plugin.$$name || plugin.name : void 0;
9
+ }
10
+ /**
11
+ * Check if a Babel plugin is a duplicate of another plugin in the list.
12
+ *
13
+ * @param plugins - The list of existing Babel plugins.
14
+ * @param plugin - The Babel plugin to check for duplicates.
15
+ * @returns True if the plugin is a duplicate, false otherwise.
16
+ */
17
+ function isDuplicatePlugin(plugins, plugin) {
18
+ return !!(getPluginName(plugin) && plugins.some((existing) => Array.isArray(existing) && getPluginName(existing[0]) === getPluginName(plugin)));
19
+ }
20
+
21
+ //#endregion
22
+ exports.getPluginName = getPluginName;
23
+ exports.isDuplicatePlugin = isDuplicatePlugin;
@@ -1 +1,21 @@
1
- import{isFunction as e}from"@stryke/type-checks/is-function";import"@stryke/type-checks/is-object";import{isSetString as t}from"@stryke/type-checks/is-set-string";function n(e){return t(e)?e:Array.isArray(e)&&e.length>0?n(e[0]):e.$$name||e.name?e.$$name||e.name:void 0}function r(e,t){return!!(n(t)&&e.some(e=>Array.isArray(e)&&n(e[0])===n(t)))}export{n as getPluginName,r as isDuplicatePlugin};
1
+ import { isFunction } from "@stryke/type-checks/is-function";
2
+ import "@stryke/type-checks/is-object";
3
+ import { isSetString } from "@stryke/type-checks/is-set-string";
4
+
5
+ //#region ../plugin-babel/src/helpers/filters.ts
6
+ function getPluginName(plugin) {
7
+ return isSetString(plugin) ? plugin : Array.isArray(plugin) && plugin.length > 0 ? getPluginName(plugin[0]) : plugin.$$name || plugin.name ? plugin.$$name || plugin.name : void 0;
8
+ }
9
+ /**
10
+ * Check if a Babel plugin is a duplicate of another plugin in the list.
11
+ *
12
+ * @param plugins - The list of existing Babel plugins.
13
+ * @param plugin - The Babel plugin to check for duplicates.
14
+ * @returns True if the plugin is a duplicate, false otherwise.
15
+ */
16
+ function isDuplicatePlugin(plugins, plugin) {
17
+ return !!(getPluginName(plugin) && plugins.some((existing) => Array.isArray(existing) && getPluginName(existing[0]) === getPluginName(plugin)));
18
+ }
19
+
20
+ //#endregion
21
+ export { getPluginName, isDuplicatePlugin };
@@ -1 +1,5 @@
1
- const e=require(`./filters.cjs`),t=require(`./options.cjs`);require(`./ast-utils.cjs`);const n=require(`./create-plugin.cjs`),r=require(`./module-helpers.cjs`);
1
+ const require_filters = require('./filters.cjs');
2
+ const require_options = require('./options.cjs');
3
+ require('./ast-utils.cjs');
4
+ const require_create_plugin = require('./create-plugin.cjs');
5
+ const require_module_helpers = require('./module-helpers.cjs');
@@ -1 +1,7 @@
1
- import{getPluginName as e,isDuplicatePlugin as t}from"./filters.mjs";import{resolveBabelPlugin as n,resolvePluginFunction as r}from"./options.mjs";import"./ast-utils.mjs";import{createBabelPlugin as i}from"./create-plugin.mjs";import{addImport as a,addImportsToProgram as o}from"./module-helpers.mjs";export{};
1
+ import { getPluginName, isDuplicatePlugin } from "./filters.mjs";
2
+ import { resolveBabelPlugin, resolvePluginFunction } from "./options.mjs";
3
+ import "./ast-utils.mjs";
4
+ import { createBabelPlugin } from "./create-plugin.mjs";
5
+ import { addImport, addImportsToProgram } from "./module-helpers.mjs";
6
+
7
+ export { };
@@ -1 +1,38 @@
1
- const e=require(`../../../_virtual/rolldown_runtime.cjs`);require(`./ast-utils.cjs`);let t=require(`@babel/types`);t=e.__toESM(t);let n=require(`@stryke/type-checks/is-string`);function r(e,t){o(e.scope.getProgramParent().path,t)}function i(e){return e.get(`specifiers`).filter(Boolean).every(e=>e?.isImportSpecifier())&&e.node.importKind!==`type`&&e.node.importKind!==`typeof`}function a(e){let t=new Map;return e.traverse({ImportDeclaration(e){i(e)&&t.set(e.node.source.value,e)}}),t}function o(e,n){a(e).get(n.module)||e.unshiftContainer(`body`,t.importDeclaration([t.importSpecifier(t.identifier(n.name||n.imported),t.identifier(n.imported))],t.stringLiteral(n.module)))}exports.addImport=r,exports.addImportsToProgram=o;
1
+ const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
2
+ require('./ast-utils.cjs');
3
+ let __babel_types = require("@babel/types");
4
+ __babel_types = require_rolldown_runtime.__toESM(__babel_types);
5
+ let __stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
6
+
7
+ //#region ../plugin-babel/src/helpers/module-helpers.ts
8
+ /**
9
+ * Adds an import to the program if it doesn't already exist.
10
+ *
11
+ * @param path - The current NodePath in the AST.
12
+ * @param specifier - The import specifier.
13
+ */
14
+ function addImport(path, specifier) {
15
+ addImportsToProgram(path.scope.getProgramParent().path, specifier);
16
+ }
17
+ function isNonNamespacedImport(importDeclPath) {
18
+ return importDeclPath.get("specifiers").filter(Boolean).every((specifier) => specifier?.isImportSpecifier()) && importDeclPath.node.importKind !== "type" && importDeclPath.node.importKind !== "typeof";
19
+ }
20
+ function getExistingImports(program) {
21
+ const existingImports = /* @__PURE__ */ new Map();
22
+ program.traverse({ ImportDeclaration(path) {
23
+ if (isNonNamespacedImport(path)) existingImports.set(path.node.source.value, path);
24
+ } });
25
+ return existingImports;
26
+ }
27
+ function addImportsToProgram(path, specifier) {
28
+ /**
29
+ * If an existing import of this module exists (ie \`import \{ ... \} from
30
+ * '<moduleName>'\`), inject new imported specifiers into the list of
31
+ * destructured variables.
32
+ */
33
+ if (!getExistingImports(path).get(specifier.module)) path.unshiftContainer("body", __babel_types.importDeclaration([__babel_types.importSpecifier(__babel_types.identifier(specifier.name || specifier.imported), __babel_types.identifier(specifier.imported))], __babel_types.stringLiteral(specifier.module)));
34
+ }
35
+
36
+ //#endregion
37
+ exports.addImport = addImport;
38
+ exports.addImportsToProgram = addImportsToProgram;
@@ -1 +1,35 @@
1
- import"./ast-utils.mjs";import*as e from"@babel/types";import{isString as t}from"@stryke/type-checks/is-string";function n(e,t){a(e.scope.getProgramParent().path,t)}function r(e){return e.get(`specifiers`).filter(Boolean).every(e=>e?.isImportSpecifier())&&e.node.importKind!==`type`&&e.node.importKind!==`typeof`}function i(e){let t=new Map;return e.traverse({ImportDeclaration(e){r(e)&&t.set(e.node.source.value,e)}}),t}function a(t,n){i(t).get(n.module)||t.unshiftContainer(`body`,e.importDeclaration([e.importSpecifier(e.identifier(n.name||n.imported),e.identifier(n.imported))],e.stringLiteral(n.module)))}export{n as addImport,a as addImportsToProgram};
1
+ import "./ast-utils.mjs";
2
+ import * as t from "@babel/types";
3
+ import { isString } from "@stryke/type-checks/is-string";
4
+
5
+ //#region ../plugin-babel/src/helpers/module-helpers.ts
6
+ /**
7
+ * Adds an import to the program if it doesn't already exist.
8
+ *
9
+ * @param path - The current NodePath in the AST.
10
+ * @param specifier - The import specifier.
11
+ */
12
+ function addImport(path, specifier) {
13
+ addImportsToProgram(path.scope.getProgramParent().path, specifier);
14
+ }
15
+ function isNonNamespacedImport(importDeclPath) {
16
+ return importDeclPath.get("specifiers").filter(Boolean).every((specifier) => specifier?.isImportSpecifier()) && importDeclPath.node.importKind !== "type" && importDeclPath.node.importKind !== "typeof";
17
+ }
18
+ function getExistingImports(program) {
19
+ const existingImports = /* @__PURE__ */ new Map();
20
+ program.traverse({ ImportDeclaration(path) {
21
+ if (isNonNamespacedImport(path)) existingImports.set(path.node.source.value, path);
22
+ } });
23
+ return existingImports;
24
+ }
25
+ function addImportsToProgram(path, specifier) {
26
+ /**
27
+ * If an existing import of this module exists (ie \`import \{ ... \} from
28
+ * '<moduleName>'\`), inject new imported specifiers into the list of
29
+ * destructured variables.
30
+ */
31
+ if (!getExistingImports(path).get(specifier.module)) path.unshiftContainer("body", t.importDeclaration([t.importSpecifier(t.identifier(specifier.name || specifier.imported), t.identifier(specifier.imported))], t.stringLiteral(specifier.module)));
32
+ }
33
+
34
+ //#endregion
35
+ export { addImport, addImportsToProgram };
@@ -1 +1,50 @@
1
- const e=require(`../../../_virtual/rolldown_runtime.cjs`),t=require(`./filters.cjs`);let n=require(`@storm-software/config-tools/types`),r=require(`@stryke/type-checks/is-function`),i=require(`chalk`);i=e.__toESM(i);function a(e,t){try{return Array.isArray(t)&&t.length>0&&t[0]?(0,r.isFunction)(t[0])?t[0](e):t[0]:(0,r.isFunction)(t)?t(e):t}catch{return t[0]}}function o(e,o,s,c){if(Array.isArray(c)&&c.length>0&&c[0]){if(c.length>2&&c[2]&&(0,r.isFunction)(c[2])&&!c[2](o,s)){e.log(n.LogLevelLabel.TRACE,`Skipping filtered Babel plugin ${i.default.bold.cyanBright(t.getPluginName(c)||`unnamed`)} for ${s}`);return}return c.length>2?[a(e,c),c[1],c[2]]:[a(e,c),c[1],null]}return[a(e,c),{},null]}exports.resolveBabelPlugin=o,exports.resolvePluginFunction=a;
1
+ const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
2
+ const require_filters = require('./filters.cjs');
3
+ let __storm_software_config_tools_types = require("@storm-software/config-tools/types");
4
+ let __stryke_type_checks_is_function = require("@stryke/type-checks/is-function");
5
+ let chalk = require("chalk");
6
+ chalk = require_rolldown_runtime.__toESM(chalk);
7
+
8
+ //#region ../plugin-babel/src/helpers/options.ts
9
+ function resolvePluginFunction(context, plugin) {
10
+ try {
11
+ return Array.isArray(plugin) && plugin.length > 0 && plugin[0] ? (0, __stryke_type_checks_is_function.isFunction)(plugin[0]) ? plugin[0](context) : plugin[0] : (0, __stryke_type_checks_is_function.isFunction)(plugin) ? plugin(context) : plugin;
12
+ } catch {
13
+ return plugin[0];
14
+ }
15
+ }
16
+ /**
17
+ * Resolve the [Babel](https://babeljs.io/) plugin.
18
+ *
19
+ * @param context - The context for the transformation.
20
+ * @param code - The code to be transformed.
21
+ * @param id - The ID of the source file.
22
+ * @param plugin - The Babel plugin to resolve.
23
+ * @returns The resolved Babel plugin options, or undefined if the plugin is filtered out.
24
+ */
25
+ function resolveBabelPlugin(context, code, id, plugin) {
26
+ if (Array.isArray(plugin) && plugin.length > 0 && plugin[0]) {
27
+ if (plugin.length > 2 && plugin[2] && (0, __stryke_type_checks_is_function.isFunction)(plugin[2]) && !plugin[2](code, id)) {
28
+ context.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Skipping filtered Babel plugin ${chalk.default.bold.cyanBright(require_filters.getPluginName(plugin) || "unnamed")} for ${id}`);
29
+ return;
30
+ }
31
+ return plugin.length > 2 ? [
32
+ resolvePluginFunction(context, plugin),
33
+ plugin[1],
34
+ plugin[2]
35
+ ] : [
36
+ resolvePluginFunction(context, plugin),
37
+ plugin[1],
38
+ null
39
+ ];
40
+ }
41
+ return [
42
+ resolvePluginFunction(context, plugin),
43
+ {},
44
+ null
45
+ ];
46
+ }
47
+
48
+ //#endregion
49
+ exports.resolveBabelPlugin = resolveBabelPlugin;
50
+ exports.resolvePluginFunction = resolvePluginFunction;
@@ -1 +1,47 @@
1
- import{getPluginName as e}from"./filters.mjs";import{LogLevelLabel as t}from"@storm-software/config-tools/types";import{isFunction as n}from"@stryke/type-checks/is-function";import r from"chalk";function i(e,t){try{return Array.isArray(t)&&t.length>0&&t[0]?n(t[0])?t[0](e):t[0]:n(t)?t(e):t}catch{return t[0]}}function a(a,o,s,c){if(Array.isArray(c)&&c.length>0&&c[0]){if(c.length>2&&c[2]&&n(c[2])&&!c[2](o,s)){a.log(t.TRACE,`Skipping filtered Babel plugin ${r.bold.cyanBright(e(c)||`unnamed`)} for ${s}`);return}return c.length>2?[i(a,c),c[1],c[2]]:[i(a,c),c[1],null]}return[i(a,c),{},null]}export{a as resolveBabelPlugin,i as resolvePluginFunction};
1
+ import { getPluginName } from "./filters.mjs";
2
+ import { LogLevelLabel } from "@storm-software/config-tools/types";
3
+ import { isFunction } from "@stryke/type-checks/is-function";
4
+ import chalk from "chalk";
5
+
6
+ //#region ../plugin-babel/src/helpers/options.ts
7
+ function resolvePluginFunction(context, plugin) {
8
+ try {
9
+ return Array.isArray(plugin) && plugin.length > 0 && plugin[0] ? isFunction(plugin[0]) ? plugin[0](context) : plugin[0] : isFunction(plugin) ? plugin(context) : plugin;
10
+ } catch {
11
+ return plugin[0];
12
+ }
13
+ }
14
+ /**
15
+ * Resolve the [Babel](https://babeljs.io/) plugin.
16
+ *
17
+ * @param context - The context for the transformation.
18
+ * @param code - The code to be transformed.
19
+ * @param id - The ID of the source file.
20
+ * @param plugin - The Babel plugin to resolve.
21
+ * @returns The resolved Babel plugin options, or undefined if the plugin is filtered out.
22
+ */
23
+ function resolveBabelPlugin(context, code, id, plugin) {
24
+ if (Array.isArray(plugin) && plugin.length > 0 && plugin[0]) {
25
+ if (plugin.length > 2 && plugin[2] && isFunction(plugin[2]) && !plugin[2](code, id)) {
26
+ context.log(LogLevelLabel.TRACE, `Skipping filtered Babel plugin ${chalk.bold.cyanBright(getPluginName(plugin) || "unnamed")} for ${id}`);
27
+ return;
28
+ }
29
+ return plugin.length > 2 ? [
30
+ resolvePluginFunction(context, plugin),
31
+ plugin[1],
32
+ plugin[2]
33
+ ] : [
34
+ resolvePluginFunction(context, plugin),
35
+ plugin[1],
36
+ null
37
+ ];
38
+ }
39
+ return [
40
+ resolvePluginFunction(context, plugin),
41
+ {},
42
+ null
43
+ ];
44
+ }
45
+
46
+ //#endregion
47
+ export { resolveBabelPlugin, resolvePluginFunction };
@@ -1 +1,91 @@
1
- const e=require(`../../_virtual/rolldown_runtime.cjs`),t=require(`./helpers/filters.cjs`),n=require(`./helpers/options.cjs`),r=require(`./helpers/create-plugin.cjs`),i=require(`./helpers/module-helpers.cjs`);require(`./helpers/index.cjs`);let a=require(`@babel/core`),o=require(`@storm-software/config-tools/types`),s=require(`@stryke/path/file-path-fns`),c=require(`@stryke/path/is-parent-path`),l=require(`@stryke/type-checks/is-set-object`),u=require(`defu`);u=e.__toESM(u);const d=(e={})=>({name:`babel`,config(){if((0,l.isSetObject)(e))return{transform:{babel:e}}},configResolved:{order:`pre`,handler(){this.devDependencies[`@babel/core`]=`^7.28.4`,this.config.transform.babel=(0,u.default)(this.config.transform.babel??{},{plugins:[],presets:[]})}},async transform(r,i){if((0,c.isParentPath)(i,this.powerlinesPath)||r.includes(`/* @storm-ignore */`)||r.includes(`/* @storm-disable */`))return this.log(o.LogLevelLabel.TRACE,`Skipping Babel transformation for: ${i}`),{code:r,id:i};this.log(o.LogLevelLabel.TRACE,`Babel transforming file: ${i}`);let l=this.config.transform.babel.plugins.map(e=>n.resolveBabelPlugin(this,r,i,e)).filter((e,n,r)=>e&&!t.isDuplicatePlugin(r,e)),d=this.config.transform.babel.presets.map(e=>n.resolveBabelPlugin(this,r,i,e)).filter((e,n,r)=>e&&!t.isDuplicatePlugin(r,e));if(Array.isArray(l)&&l.length===0&&Array.isArray(d)&&d.length===0)return{code:r,id:i};[`ts`,`cts`,`mts`,`tsx`].includes((0,s.findFileExtensionSafe)(i))&&!t.isDuplicatePlugin(l,`@babel/plugin-syntax-typescript`)&&!t.isDuplicatePlugin(d,`@babel/preset-typescript`)&&l.unshift([`@babel/plugin-syntax-typescript`,{isTSX:(0,s.findFileExtension)(i)===`.tsx`}]);let f=await(0,a.transformAsync)(r,{highlightCode:!0,code:!0,ast:!1,cloneInputAst:!1,comments:!0,sourceType:`module`,configFile:!1,babelrc:!1,envName:this.config.mode,caller:{name:this.config.framework},...this.config.transform.babel??{},filename:i,plugins:l.map(t=>Array.isArray(t)&&t.length>=2?[t[0],(0,u.default)(t.length>1&&t[1]?t[1]:{},{options:e})]:t).filter(Boolean),presets:d.map(t=>Array.isArray(t)&&t.length>=2?[t[0],(0,u.default)(t.length>1&&t[1]?t[1]:{},{options:e})]:t).filter(Boolean)});if(!f?.code)throw Error(`Powerlines - Babel plugin failed to compile ${i}`);return{code:f.code,id:i}}});var f=d;exports.default=f;
1
+ const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
2
+ const require_filters = require('./helpers/filters.cjs');
3
+ const require_options = require('./helpers/options.cjs');
4
+ const require_create_plugin = require('./helpers/create-plugin.cjs');
5
+ const require_module_helpers = require('./helpers/module-helpers.cjs');
6
+ require('./helpers/index.cjs');
7
+ let __babel_core = require("@babel/core");
8
+ let __storm_software_config_tools_types = require("@storm-software/config-tools/types");
9
+ let __stryke_path_file_path_fns = require("@stryke/path/file-path-fns");
10
+ let __stryke_path_is_parent_path = require("@stryke/path/is-parent-path");
11
+ let __stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
12
+ let defu = require("defu");
13
+ defu = require_rolldown_runtime.__toESM(defu);
14
+
15
+ //#region ../plugin-babel/src/index.ts
16
+ /**
17
+ * Babel plugin for Powerlines.
18
+ *
19
+ * @param options - The Babel plugin user configuration options.
20
+ * @returns A Powerlines plugin that integrates Babel transformations.
21
+ */
22
+ const plugin = (options = {}) => {
23
+ return {
24
+ name: "babel",
25
+ config() {
26
+ if (!(0, __stryke_type_checks_is_set_object.isSetObject)(options)) return;
27
+ return { transform: { babel: options } };
28
+ },
29
+ configResolved: {
30
+ order: "pre",
31
+ handler() {
32
+ this.devDependencies["@babel/core"] = "^7.28.4";
33
+ this.config.transform.babel = (0, defu.default)(this.config.transform.babel ?? {}, {
34
+ plugins: [],
35
+ presets: []
36
+ });
37
+ }
38
+ },
39
+ async transform(code, id) {
40
+ if ((0, __stryke_path_is_parent_path.isParentPath)(id, this.powerlinesPath) || code.includes("/* @storm-ignore */") || code.includes("/* @storm-disable */")) {
41
+ this.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Skipping Babel transformation for: ${id}`);
42
+ return {
43
+ code,
44
+ id
45
+ };
46
+ }
47
+ this.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Babel transforming file: ${id}`);
48
+ const plugins = this.config.transform.babel.plugins.map((plugin$1) => require_options.resolveBabelPlugin(this, code, id, plugin$1)).filter((plugin$1, _, arr) => plugin$1 && !require_filters.isDuplicatePlugin(arr, plugin$1));
49
+ const presets = this.config.transform.babel.presets.map((preset) => require_options.resolveBabelPlugin(this, code, id, preset)).filter((preset, _, arr) => preset && !require_filters.isDuplicatePlugin(arr, preset));
50
+ if (Array.isArray(plugins) && plugins.length === 0 && Array.isArray(presets) && presets.length === 0) return {
51
+ code,
52
+ id
53
+ };
54
+ if ([
55
+ "ts",
56
+ "cts",
57
+ "mts",
58
+ "tsx"
59
+ ].includes((0, __stryke_path_file_path_fns.findFileExtensionSafe)(id)) && !require_filters.isDuplicatePlugin(plugins, "@babel/plugin-syntax-typescript") && !require_filters.isDuplicatePlugin(presets, "@babel/preset-typescript")) plugins.unshift(["@babel/plugin-syntax-typescript", { isTSX: (0, __stryke_path_file_path_fns.findFileExtension)(id) === ".tsx" }]);
60
+ const result = await (0, __babel_core.transformAsync)(code, {
61
+ highlightCode: true,
62
+ code: true,
63
+ ast: false,
64
+ cloneInputAst: false,
65
+ comments: true,
66
+ sourceType: "module",
67
+ configFile: false,
68
+ babelrc: false,
69
+ envName: this.config.mode,
70
+ caller: { name: this.config.framework },
71
+ ...this.config.transform.babel ?? {},
72
+ filename: id,
73
+ plugins: plugins.map((plugin$1) => {
74
+ return Array.isArray(plugin$1) && plugin$1.length >= 2 ? [plugin$1[0], (0, defu.default)(plugin$1.length > 1 && plugin$1[1] ? plugin$1[1] : {}, { options })] : plugin$1;
75
+ }).filter(Boolean),
76
+ presets: presets.map((preset) => {
77
+ return Array.isArray(preset) && preset.length >= 2 ? [preset[0], (0, defu.default)(preset.length > 1 && preset[1] ? preset[1] : {}, { options })] : preset;
78
+ }).filter(Boolean)
79
+ });
80
+ if (!result?.code) throw new Error(`Powerlines - Babel plugin failed to compile ${id}`);
81
+ return {
82
+ code: result.code,
83
+ id
84
+ };
85
+ }
86
+ };
87
+ };
88
+ var src_default = plugin;
89
+
90
+ //#endregion
91
+ exports.default = src_default;