@powerlines/plugin-react 0.1.121 → 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 (110) 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.d.cts +2 -1
  7. package/dist/components/react-optimized.mjs +43 -1
  8. package/dist/deepkit/schemas/reflection.cjs +3940 -1
  9. package/dist/deepkit/schemas/reflection.mjs +3938 -1
  10. package/dist/deepkit/schemas/reflection2.cjs +4112 -1
  11. package/dist/deepkit/schemas/reflection2.mjs +4110 -1
  12. package/dist/deepkit/src/capnp.cjs +913 -1
  13. package/dist/deepkit/src/capnp.mjs +911 -1
  14. package/dist/deepkit/src/esbuild-plugin.cjs +47 -4
  15. package/dist/deepkit/src/esbuild-plugin.mjs +46 -4
  16. package/dist/deepkit/src/reflect-type.cjs +22 -1
  17. package/dist/deepkit/src/reflect-type.mjs +20 -1
  18. package/dist/deepkit/src/resolve-reflections.cjs +16 -1
  19. package/dist/deepkit/src/resolve-reflections.mjs +15 -1
  20. package/dist/deepkit/src/transformer.cjs +52 -1
  21. package/dist/deepkit/src/transformer.mjs +49 -1
  22. package/dist/deepkit/src/transpile.cjs +29 -1
  23. package/dist/deepkit/src/transpile.mjs +27 -1
  24. package/dist/deepkit/src/utilities.cjs +66 -1
  25. package/dist/deepkit/src/utilities.mjs +65 -1
  26. package/dist/deepkit/src/vendor/type-compiler/index.cjs +38 -1
  27. package/dist/deepkit/src/vendor/type-compiler/index.mjs +19 -1
  28. package/dist/deepkit/src/vendor/type.cjs +20 -1
  29. package/dist/deepkit/src/vendor/type.mjs +11 -1
  30. package/dist/index.cjs +104 -1
  31. package/dist/index.mjs +98 -1
  32. package/dist/plugin-alloy/src/core/components/output.cjs +45 -1
  33. package/dist/plugin-alloy/src/core/components/output.mjs +44 -1
  34. package/dist/plugin-alloy/src/core/contexts/context.cjs +11 -1
  35. package/dist/plugin-alloy/src/core/contexts/context.mjs +10 -1
  36. package/dist/plugin-alloy/src/index.cjs +93 -2
  37. package/dist/plugin-alloy/src/index.mjs +91 -2
  38. package/dist/plugin-alloy/src/types/components.d.mts +1 -1
  39. package/dist/plugin-alloy/src/types/plugin.d.cts +1 -0
  40. package/dist/plugin-alloy/src/types/plugin.d.mts +3 -3
  41. package/dist/plugin-automd/src/index.cjs +101 -1
  42. package/dist/plugin-automd/src/index.mjs +98 -1
  43. package/dist/plugin-babel/src/helpers/ast-utils.cjs +10 -1
  44. package/dist/plugin-babel/src/helpers/ast-utils.mjs +9 -1
  45. package/dist/plugin-babel/src/helpers/create-plugin.cjs +41 -1
  46. package/dist/plugin-babel/src/helpers/create-plugin.mjs +39 -1
  47. package/dist/plugin-babel/src/helpers/filters.cjs +23 -1
  48. package/dist/plugin-babel/src/helpers/filters.mjs +21 -1
  49. package/dist/plugin-babel/src/helpers/index.cjs +5 -1
  50. package/dist/plugin-babel/src/helpers/index.mjs +7 -1
  51. package/dist/plugin-babel/src/helpers/module-helpers.cjs +38 -1
  52. package/dist/plugin-babel/src/helpers/module-helpers.mjs +35 -1
  53. package/dist/plugin-babel/src/helpers/options.cjs +50 -1
  54. package/dist/plugin-babel/src/helpers/options.mjs +47 -1
  55. package/dist/plugin-babel/src/index.cjs +91 -1
  56. package/dist/plugin-babel/src/index.mjs +89 -1
  57. package/dist/plugin-env/src/babel/index.cjs +1 -1
  58. package/dist/plugin-env/src/babel/index.mjs +3 -1
  59. package/dist/plugin-env/src/babel/plugin.cjs +120 -4
  60. package/dist/plugin-env/src/babel/plugin.mjs +118 -4
  61. package/dist/plugin-env/src/components/docs.cjs +9 -1
  62. package/dist/plugin-env/src/components/docs.mjs +11 -1
  63. package/dist/plugin-env/src/components/env.cjs +432 -11
  64. package/dist/plugin-env/src/components/env.mjs +430 -9
  65. package/dist/plugin-env/src/components/index.cjs +2 -1
  66. package/dist/plugin-env/src/components/index.mjs +4 -1
  67. package/dist/plugin-env/src/helpers/automd-generator.cjs +22 -1
  68. package/dist/plugin-env/src/helpers/automd-generator.mjs +21 -1
  69. package/dist/plugin-env/src/helpers/create-reflection-resource.cjs +55 -1
  70. package/dist/plugin-env/src/helpers/create-reflection-resource.mjs +54 -1
  71. package/dist/plugin-env/src/helpers/index.cjs +6 -1
  72. package/dist/plugin-env/src/helpers/index.mjs +8 -1
  73. package/dist/plugin-env/src/helpers/load.cjs +83 -1
  74. package/dist/plugin-env/src/helpers/load.mjs +80 -1
  75. package/dist/plugin-env/src/helpers/persistence.cjs +200 -1
  76. package/dist/plugin-env/src/helpers/persistence.mjs +189 -1
  77. package/dist/plugin-env/src/helpers/reflect.cjs +111 -1
  78. package/dist/plugin-env/src/helpers/reflect.mjs +103 -1
  79. package/dist/plugin-env/src/helpers/source-file-env.cjs +24 -1
  80. package/dist/plugin-env/src/helpers/source-file-env.mjs +23 -1
  81. package/dist/plugin-env/src/helpers/template-helpers.cjs +2 -1
  82. package/dist/plugin-env/src/helpers/template-helpers.mjs +4 -1
  83. package/dist/plugin-env/src/index.cjs +170 -5
  84. package/dist/plugin-env/src/index.mjs +168 -5
  85. package/dist/plugin-env/src/types/plugin.d.cts +1 -0
  86. package/dist/powerlines/src/lib/build/esbuild.cjs +102 -14
  87. package/dist/powerlines/src/lib/build/esbuild.mjs +100 -14
  88. package/dist/powerlines/src/lib/entry.cjs +12 -1
  89. package/dist/powerlines/src/lib/entry.mjs +14 -1
  90. package/dist/powerlines/src/lib/logger.cjs +41 -1
  91. package/dist/powerlines/src/lib/logger.mjs +39 -1
  92. package/dist/powerlines/src/lib/typescript/tsconfig.cjs +38 -1
  93. package/dist/powerlines/src/lib/typescript/tsconfig.mjs +35 -1
  94. package/dist/powerlines/src/lib/utilities/bundle.cjs +35 -1
  95. package/dist/powerlines/src/lib/utilities/bundle.mjs +34 -1
  96. package/dist/powerlines/src/lib/utilities/resolve.cjs +30 -1
  97. package/dist/powerlines/src/lib/utilities/resolve.mjs +29 -1
  98. package/dist/powerlines/src/plugin-utils/paths.cjs +1 -1
  99. package/dist/powerlines/src/plugin-utils/paths.mjs +3 -1
  100. package/dist/powerlines/src/types/context.d.cts +43 -2
  101. package/dist/powerlines/src/types/context.d.mts +43 -2
  102. package/dist/powerlines/src/types/fs.d.cts +14 -0
  103. package/dist/powerlines/src/types/fs.d.mts +14 -0
  104. package/dist/types/index.mjs +1 -1
  105. package/dist/types/plugin.mjs +1 -1
  106. package/dist/types/runtime.mjs +1 -1
  107. package/package.json +10 -10
  108. package/dist/plugin-alloy/src/vendor/index.cjs +0 -1
  109. package/dist/plugin-alloy/src/vendor/index.d.mts +0 -7
  110. package/dist/plugin-alloy/src/vendor/index.mjs +0 -1
package/dist/index.cjs CHANGED
@@ -1 +1,104 @@
1
- Object.defineProperty(exports,`__esModule`,{value:!0});const e=require(`./_virtual/rolldown_runtime.cjs`),t=require(`./deepkit/src/vendor/type.cjs`),n=require(`./plugin-babel/src/index.cjs`),r=require(`./plugin-env/src/index.cjs`),i=require(`./powerlines/src/lib/typescript/tsconfig.cjs`),a=require(`./components/react-optimized.cjs`);require(`./components/index.cjs`);let o=require(`@alloy-js/core/jsx-runtime`),s=require(`@storm-software/config-tools/types`),c=require(`defu`);c=e.__toESM(c);let l=require(`@vitejs/plugin-react`);l=e.__toESM(l);const u=(e={})=>[n.default(e.babel),r.default(e.env),{name:`react`,config(){return(0,c.default)({react:e},{react:{jsxImportSource:this.tsconfig.tsconfigJson.compilerOptions?.jsxImportSource}},{react:{jsxRuntime:`automatic`,jsxImportSource:`react`,compiler:{target:`19`,compilationMode:`infer`,gating:{source:`${this.config.output.builtinPrefix}:react/optimized`,importSpecifierName:`isOptimizationEnabled`},enableReanimatedCheck:!0,logger:{logEvent:(e,t)=>{this.log(t.kind===`CompileSuccess`?s.LogLevelLabel.SUCCESS:t.kind===`AutoDepsEligible`||t.kind===`AutoDepsDecorations`?s.LogLevelLabel.INFO:t.kind===`CompileSkip`||t.kind===`CompileDiagnostic`?s.LogLevelLabel.DEBUG:t.kind===`Timing`?s.LogLevelLabel.TRACE:s.LogLevelLabel.ERROR,`(${e}) ${t.kind===`CompileSuccess`?`React Compiler Success`:t.kind===`AutoDepsEligible`?`React AutoDeps Eligible - ${t.depArrayLoc.identifierName||`No identifier`}`:t.kind===`AutoDepsDecorations`?`React AutoDeps Decorations - ${t.decorations.filter(e=>e.identifierName).map(e=>e.identifierName).join(`, `)}`:t.kind===`CompileSkip`?`React Compile Skip - ${t.reason}`:t.kind===`CompileDiagnostic`?`React Compile Diagnostic - (Category: ${t.detail.category}) ${t.detail.reason}${t.detail.description?`\n${t.detail.description}`:``}`:t.kind===`Timing`?`React ${t.measurement.entryType} Timing (${t.measurement.name}) - ${t.measurement.duration}ms`:`React Compiler Error - ${t.fnLoc?.identifierName||`unknown location`}`}`)}}}}})},configResolved(){if(this.dependencies.react=`^19.2.3`,this.dependencies[`react-dom`]=`^19.2.3`,this.devDependencies[`@types/react`]=`^19.2.3`,this.devDependencies[`@types/react-dom`]=`^19.2.3`,this.config.react.compiler!==!1&&(this.config.transform.babel??={},this.config.transform.babel.plugins??=[],this.config.transform.babel.plugins.push([`babel-plugin-react-compiler`,this.config.react.compiler])),this.tsconfig.tsconfigJson.compilerOptions??={},this.tsconfig.tsconfigJson.compilerOptions.lib??=[],this.tsconfig.tsconfigJson.compilerOptions.module??=`esnext`,this.tsconfig.tsconfigJson.compilerOptions.jsxImportSource=this.config.react.jsxImportSource,this.tsconfig.options.jsxImportSource===`react`?this.tsconfig.tsconfigJson.compilerOptions.jsx??=`react-jsx`:this.tsconfig.tsconfigJson.compilerOptions.jsx??=`preserve`,this.environment.consumer===`client`&&(i.isMatchFound(`dom`,this.tsconfig.tsconfigJson.compilerOptions.lib)||this.tsconfig.tsconfigJson.compilerOptions.lib.push(`DOM`),i.isMatchFound(`dom.iterable`,this.tsconfig.tsconfigJson.compilerOptions.lib)||this.tsconfig.tsconfigJson.compilerOptions.lib.push(`DOM.Iterable`)),i.isMatchFound(`esnext`,this.tsconfig.tsconfigJson.compilerOptions.lib)||this.tsconfig.tsconfigJson.compilerOptions.lib.push(`ESNext`),this.tsconfig.options.resolveJsonModule!==!0&&(this.tsconfig.tsconfigJson.compilerOptions.resolveJsonModule=!0),this.config.build.variant===`vite`){this.tsconfig.tsconfigJson.compilerOptions.types??=[],i.isMatchFound(`vite/client`,this.tsconfig.tsconfigJson.compilerOptions.types)||this.tsconfig.tsconfigJson.compilerOptions.types.push(`vite/client`);let e=this.config.build;e.build??={},e.build.target=`chrome95`,e.plugins??=[],e.plugins.unshift((0,l.default)({babel:this.config.transform.babel,jsxImportSource:this.config.react.jsxImportSource,jsxRuntime:this.config.react.jsxRuntime,reactRefreshHost:this.config.react.reactRefreshHost}))}this.env?.types?.env&&!this.env.types.env.hasProperty(`DISABLE_REACT_COMPILER`)&&this.env.types.env.addProperty({name:`DISABLE_REACT_COMPILER`,optional:!0,readonly:!0,description:`Disables the React compiler optimizations.`,visibility:t.type_exports.ReflectionVisibility.public,type:{kind:t.type_exports.ReflectionKind.boolean},default:!1})},async prepare(){let e=this;return this.render((0,o.createComponent)(a.ReactOptimizedBuiltin,{get override(){return e.config.react.compiler===!1?!1:void 0}}))}}];var d=u;exports.ReactOptimizedBuiltin=a.ReactOptimizedBuiltin,exports.default=d,exports.plugin=u;
1
+ Object.defineProperty(exports, '__esModule', { value: true });
2
+ const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
3
+ const require_type = require('./deepkit/src/vendor/type.cjs');
4
+ const require_index = require('./plugin-babel/src/index.cjs');
5
+ const require_index$1 = require('./plugin-env/src/index.cjs');
6
+ const require_tsconfig = require('./powerlines/src/lib/typescript/tsconfig.cjs');
7
+ const require_components_react_optimized = require('./components/react-optimized.cjs');
8
+ require('./components/index.cjs');
9
+ let __alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
10
+ let __storm_software_config_tools_types = require("@storm-software/config-tools/types");
11
+ let defu = require("defu");
12
+ defu = require_rolldown_runtime.__toESM(defu);
13
+ let __vitejs_plugin_react = require("@vitejs/plugin-react");
14
+ __vitejs_plugin_react = require_rolldown_runtime.__toESM(__vitejs_plugin_react);
15
+
16
+ //#region src/index.tsx
17
+ /**
18
+ * A package containing a Powerlines plugin for building a React application.
19
+ */
20
+ const plugin = (options = {}) => {
21
+ return [
22
+ require_index.default(options.babel),
23
+ require_index$1.default(options.env),
24
+ {
25
+ name: "react",
26
+ config() {
27
+ return (0, defu.default)({ react: options }, { react: { jsxImportSource: this.tsconfig.tsconfigJson.compilerOptions?.jsxImportSource } }, { react: {
28
+ jsxRuntime: "automatic",
29
+ jsxImportSource: "react",
30
+ compiler: {
31
+ target: "19",
32
+ compilationMode: "infer",
33
+ gating: {
34
+ source: `${this.config.output.builtinPrefix}:react/optimized`,
35
+ importSpecifierName: "isOptimizationEnabled"
36
+ },
37
+ enableReanimatedCheck: true,
38
+ logger: { logEvent: (filename, event) => {
39
+ this.log(event.kind === "CompileSuccess" ? __storm_software_config_tools_types.LogLevelLabel.SUCCESS : event.kind === "AutoDepsEligible" || event.kind === "AutoDepsDecorations" ? __storm_software_config_tools_types.LogLevelLabel.INFO : event.kind === "CompileSkip" || event.kind === "CompileDiagnostic" ? __storm_software_config_tools_types.LogLevelLabel.DEBUG : event.kind === "Timing" ? __storm_software_config_tools_types.LogLevelLabel.TRACE : __storm_software_config_tools_types.LogLevelLabel.ERROR, `(${filename}) ${event.kind === "CompileSuccess" ? `React Compiler Success` : event.kind === "AutoDepsEligible" ? `React AutoDeps Eligible - ${event.depArrayLoc.identifierName || "No identifier"}` : event.kind === "AutoDepsDecorations" ? `React AutoDeps Decorations - ${event.decorations.filter((dec) => dec.identifierName).map((dec) => dec.identifierName).join(", ")}` : event.kind === "CompileSkip" ? `React Compile Skip - ${event.reason}` : event.kind === "CompileDiagnostic" ? `React Compile Diagnostic - (Category: ${event.detail.category}) ${event.detail.reason}${event.detail.description ? `\n${event.detail.description}` : ""}` : event.kind === "Timing" ? `React ${event.measurement.entryType} Timing (${event.measurement.name}) - ${event.measurement.duration}ms` : `React Compiler Error - ${event.fnLoc?.identifierName || "unknown location"}`}`);
40
+ } }
41
+ }
42
+ } });
43
+ },
44
+ configResolved() {
45
+ this.dependencies.react = "^19.2.3";
46
+ this.dependencies["react-dom"] = "^19.2.3";
47
+ this.devDependencies["@types/react"] = "^19.2.3";
48
+ this.devDependencies["@types/react-dom"] = "^19.2.3";
49
+ if (this.config.react.compiler !== false) {
50
+ this.config.transform.babel ??= {};
51
+ this.config.transform.babel.plugins ??= [];
52
+ this.config.transform.babel.plugins.push(["babel-plugin-react-compiler", this.config.react.compiler]);
53
+ }
54
+ this.tsconfig.tsconfigJson.compilerOptions ??= {};
55
+ this.tsconfig.tsconfigJson.compilerOptions.lib ??= [];
56
+ this.tsconfig.tsconfigJson.compilerOptions.module ??= "esnext";
57
+ this.tsconfig.tsconfigJson.compilerOptions.jsxImportSource = this.config.react.jsxImportSource;
58
+ if (this.tsconfig.options.jsxImportSource === "react") this.tsconfig.tsconfigJson.compilerOptions.jsx ??= "react-jsx";
59
+ else this.tsconfig.tsconfigJson.compilerOptions.jsx ??= "preserve";
60
+ if (this.environment.consumer === "client") {
61
+ if (!require_tsconfig.isMatchFound("dom", this.tsconfig.tsconfigJson.compilerOptions.lib)) this.tsconfig.tsconfigJson.compilerOptions.lib.push("DOM");
62
+ if (!require_tsconfig.isMatchFound("dom.iterable", this.tsconfig.tsconfigJson.compilerOptions.lib)) this.tsconfig.tsconfigJson.compilerOptions.lib.push("DOM.Iterable");
63
+ }
64
+ if (!require_tsconfig.isMatchFound("esnext", this.tsconfig.tsconfigJson.compilerOptions.lib)) this.tsconfig.tsconfigJson.compilerOptions.lib.push("ESNext");
65
+ if (this.tsconfig.options.resolveJsonModule !== true) this.tsconfig.tsconfigJson.compilerOptions.resolveJsonModule = true;
66
+ if (this.config.build.variant === "vite") {
67
+ this.tsconfig.tsconfigJson.compilerOptions.types ??= [];
68
+ if (!require_tsconfig.isMatchFound("vite/client", this.tsconfig.tsconfigJson.compilerOptions.types)) this.tsconfig.tsconfigJson.compilerOptions.types.push("vite/client");
69
+ const viteBuildConfig = this.config.build;
70
+ viteBuildConfig.build ??= {};
71
+ viteBuildConfig.build.target = "chrome95";
72
+ viteBuildConfig.plugins ??= [];
73
+ viteBuildConfig.plugins.unshift((0, __vitejs_plugin_react.default)({
74
+ babel: this.config.transform.babel,
75
+ jsxImportSource: this.config.react.jsxImportSource,
76
+ jsxRuntime: this.config.react.jsxRuntime,
77
+ reactRefreshHost: this.config.react.reactRefreshHost
78
+ }));
79
+ }
80
+ if (this.env?.types?.env && !this.env.types.env.hasProperty("DISABLE_REACT_COMPILER")) this.env.types.env.addProperty({
81
+ name: "DISABLE_REACT_COMPILER",
82
+ optional: true,
83
+ readonly: true,
84
+ description: "Disables the React compiler optimizations.",
85
+ visibility: require_type.type_exports.ReflectionVisibility.public,
86
+ type: { kind: require_type.type_exports.ReflectionKind.boolean },
87
+ default: false
88
+ });
89
+ },
90
+ async prepare() {
91
+ const _self$ = this;
92
+ return this.render((0, __alloy_js_core_jsx_runtime.createComponent)(require_components_react_optimized.ReactOptimizedBuiltin, { get override() {
93
+ return _self$.config.react.compiler === false ? false : void 0;
94
+ } }));
95
+ }
96
+ }
97
+ ];
98
+ };
99
+ var src_default = plugin;
100
+
101
+ //#endregion
102
+ exports.ReactOptimizedBuiltin = require_components_react_optimized.ReactOptimizedBuiltin;
103
+ exports.default = src_default;
104
+ exports.plugin = plugin;
package/dist/index.mjs CHANGED
@@ -1 +1,98 @@
1
- import{type_exports as e}from"./deepkit/src/vendor/type.mjs";import t from"./plugin-babel/src/index.mjs";import n from"./plugin-env/src/index.mjs";import{isMatchFound as r}from"./powerlines/src/lib/typescript/tsconfig.mjs";import{ReactOptimizedBuiltin as i}from"./components/react-optimized.mjs";import"./components/index.mjs";import{createComponent as a}from"@alloy-js/core/jsx-runtime";import{LogLevelLabel as o}from"@storm-software/config-tools/types";import s from"defu";import c from"@vitejs/plugin-react";const l=(l={})=>[t(l.babel),n(l.env),{name:`react`,config(){return s({react:l},{react:{jsxImportSource:this.tsconfig.tsconfigJson.compilerOptions?.jsxImportSource}},{react:{jsxRuntime:`automatic`,jsxImportSource:`react`,compiler:{target:`19`,compilationMode:`infer`,gating:{source:`${this.config.output.builtinPrefix}:react/optimized`,importSpecifierName:`isOptimizationEnabled`},enableReanimatedCheck:!0,logger:{logEvent:(e,t)=>{this.log(t.kind===`CompileSuccess`?o.SUCCESS:t.kind===`AutoDepsEligible`||t.kind===`AutoDepsDecorations`?o.INFO:t.kind===`CompileSkip`||t.kind===`CompileDiagnostic`?o.DEBUG:t.kind===`Timing`?o.TRACE:o.ERROR,`(${e}) ${t.kind===`CompileSuccess`?`React Compiler Success`:t.kind===`AutoDepsEligible`?`React AutoDeps Eligible - ${t.depArrayLoc.identifierName||`No identifier`}`:t.kind===`AutoDepsDecorations`?`React AutoDeps Decorations - ${t.decorations.filter(e=>e.identifierName).map(e=>e.identifierName).join(`, `)}`:t.kind===`CompileSkip`?`React Compile Skip - ${t.reason}`:t.kind===`CompileDiagnostic`?`React Compile Diagnostic - (Category: ${t.detail.category}) ${t.detail.reason}${t.detail.description?`\n${t.detail.description}`:``}`:t.kind===`Timing`?`React ${t.measurement.entryType} Timing (${t.measurement.name}) - ${t.measurement.duration}ms`:`React Compiler Error - ${t.fnLoc?.identifierName||`unknown location`}`}`)}}}}})},configResolved(){if(this.dependencies.react=`^19.2.3`,this.dependencies[`react-dom`]=`^19.2.3`,this.devDependencies[`@types/react`]=`^19.2.3`,this.devDependencies[`@types/react-dom`]=`^19.2.3`,this.config.react.compiler!==!1&&(this.config.transform.babel??={},this.config.transform.babel.plugins??=[],this.config.transform.babel.plugins.push([`babel-plugin-react-compiler`,this.config.react.compiler])),this.tsconfig.tsconfigJson.compilerOptions??={},this.tsconfig.tsconfigJson.compilerOptions.lib??=[],this.tsconfig.tsconfigJson.compilerOptions.module??=`esnext`,this.tsconfig.tsconfigJson.compilerOptions.jsxImportSource=this.config.react.jsxImportSource,this.tsconfig.options.jsxImportSource===`react`?this.tsconfig.tsconfigJson.compilerOptions.jsx??=`react-jsx`:this.tsconfig.tsconfigJson.compilerOptions.jsx??=`preserve`,this.environment.consumer===`client`&&(r(`dom`,this.tsconfig.tsconfigJson.compilerOptions.lib)||this.tsconfig.tsconfigJson.compilerOptions.lib.push(`DOM`),r(`dom.iterable`,this.tsconfig.tsconfigJson.compilerOptions.lib)||this.tsconfig.tsconfigJson.compilerOptions.lib.push(`DOM.Iterable`)),r(`esnext`,this.tsconfig.tsconfigJson.compilerOptions.lib)||this.tsconfig.tsconfigJson.compilerOptions.lib.push(`ESNext`),this.tsconfig.options.resolveJsonModule!==!0&&(this.tsconfig.tsconfigJson.compilerOptions.resolveJsonModule=!0),this.config.build.variant===`vite`){this.tsconfig.tsconfigJson.compilerOptions.types??=[],r(`vite/client`,this.tsconfig.tsconfigJson.compilerOptions.types)||this.tsconfig.tsconfigJson.compilerOptions.types.push(`vite/client`);let e=this.config.build;e.build??={},e.build.target=`chrome95`,e.plugins??=[],e.plugins.unshift(c({babel:this.config.transform.babel,jsxImportSource:this.config.react.jsxImportSource,jsxRuntime:this.config.react.jsxRuntime,reactRefreshHost:this.config.react.reactRefreshHost}))}this.env?.types?.env&&!this.env.types.env.hasProperty(`DISABLE_REACT_COMPILER`)&&this.env.types.env.addProperty({name:`DISABLE_REACT_COMPILER`,optional:!0,readonly:!0,description:`Disables the React compiler optimizations.`,visibility:e.ReflectionVisibility.public,type:{kind:e.ReflectionKind.boolean},default:!1})},async prepare(){let e=this;return this.render(a(i,{get override(){return e.config.react.compiler===!1?!1:void 0}}))}}];var u=l;export{i as ReactOptimizedBuiltin,u as default,l as plugin};
1
+ import { type_exports } from "./deepkit/src/vendor/type.mjs";
2
+ import src_default$1 from "./plugin-babel/src/index.mjs";
3
+ import src_default$2 from "./plugin-env/src/index.mjs";
4
+ import { isMatchFound } from "./powerlines/src/lib/typescript/tsconfig.mjs";
5
+ import { ReactOptimizedBuiltin } from "./components/react-optimized.mjs";
6
+ import "./components/index.mjs";
7
+ import { createComponent } from "@alloy-js/core/jsx-runtime";
8
+ import { LogLevelLabel } from "@storm-software/config-tools/types";
9
+ import defu from "defu";
10
+ import viteReactPlugin from "@vitejs/plugin-react";
11
+
12
+ //#region src/index.tsx
13
+ /**
14
+ * A package containing a Powerlines plugin for building a React application.
15
+ */
16
+ const plugin = (options = {}) => {
17
+ return [
18
+ src_default$1(options.babel),
19
+ src_default$2(options.env),
20
+ {
21
+ name: "react",
22
+ config() {
23
+ return defu({ react: options }, { react: { jsxImportSource: this.tsconfig.tsconfigJson.compilerOptions?.jsxImportSource } }, { react: {
24
+ jsxRuntime: "automatic",
25
+ jsxImportSource: "react",
26
+ compiler: {
27
+ target: "19",
28
+ compilationMode: "infer",
29
+ gating: {
30
+ source: `${this.config.output.builtinPrefix}:react/optimized`,
31
+ importSpecifierName: "isOptimizationEnabled"
32
+ },
33
+ enableReanimatedCheck: true,
34
+ logger: { logEvent: (filename, event) => {
35
+ this.log(event.kind === "CompileSuccess" ? LogLevelLabel.SUCCESS : event.kind === "AutoDepsEligible" || event.kind === "AutoDepsDecorations" ? LogLevelLabel.INFO : event.kind === "CompileSkip" || event.kind === "CompileDiagnostic" ? LogLevelLabel.DEBUG : event.kind === "Timing" ? LogLevelLabel.TRACE : LogLevelLabel.ERROR, `(${filename}) ${event.kind === "CompileSuccess" ? `React Compiler Success` : event.kind === "AutoDepsEligible" ? `React AutoDeps Eligible - ${event.depArrayLoc.identifierName || "No identifier"}` : event.kind === "AutoDepsDecorations" ? `React AutoDeps Decorations - ${event.decorations.filter((dec) => dec.identifierName).map((dec) => dec.identifierName).join(", ")}` : event.kind === "CompileSkip" ? `React Compile Skip - ${event.reason}` : event.kind === "CompileDiagnostic" ? `React Compile Diagnostic - (Category: ${event.detail.category}) ${event.detail.reason}${event.detail.description ? `\n${event.detail.description}` : ""}` : event.kind === "Timing" ? `React ${event.measurement.entryType} Timing (${event.measurement.name}) - ${event.measurement.duration}ms` : `React Compiler Error - ${event.fnLoc?.identifierName || "unknown location"}`}`);
36
+ } }
37
+ }
38
+ } });
39
+ },
40
+ configResolved() {
41
+ this.dependencies.react = "^19.2.3";
42
+ this.dependencies["react-dom"] = "^19.2.3";
43
+ this.devDependencies["@types/react"] = "^19.2.3";
44
+ this.devDependencies["@types/react-dom"] = "^19.2.3";
45
+ if (this.config.react.compiler !== false) {
46
+ this.config.transform.babel ??= {};
47
+ this.config.transform.babel.plugins ??= [];
48
+ this.config.transform.babel.plugins.push(["babel-plugin-react-compiler", this.config.react.compiler]);
49
+ }
50
+ this.tsconfig.tsconfigJson.compilerOptions ??= {};
51
+ this.tsconfig.tsconfigJson.compilerOptions.lib ??= [];
52
+ this.tsconfig.tsconfigJson.compilerOptions.module ??= "esnext";
53
+ this.tsconfig.tsconfigJson.compilerOptions.jsxImportSource = this.config.react.jsxImportSource;
54
+ if (this.tsconfig.options.jsxImportSource === "react") this.tsconfig.tsconfigJson.compilerOptions.jsx ??= "react-jsx";
55
+ else this.tsconfig.tsconfigJson.compilerOptions.jsx ??= "preserve";
56
+ if (this.environment.consumer === "client") {
57
+ if (!isMatchFound("dom", this.tsconfig.tsconfigJson.compilerOptions.lib)) this.tsconfig.tsconfigJson.compilerOptions.lib.push("DOM");
58
+ if (!isMatchFound("dom.iterable", this.tsconfig.tsconfigJson.compilerOptions.lib)) this.tsconfig.tsconfigJson.compilerOptions.lib.push("DOM.Iterable");
59
+ }
60
+ if (!isMatchFound("esnext", this.tsconfig.tsconfigJson.compilerOptions.lib)) this.tsconfig.tsconfigJson.compilerOptions.lib.push("ESNext");
61
+ if (this.tsconfig.options.resolveJsonModule !== true) this.tsconfig.tsconfigJson.compilerOptions.resolveJsonModule = true;
62
+ if (this.config.build.variant === "vite") {
63
+ this.tsconfig.tsconfigJson.compilerOptions.types ??= [];
64
+ if (!isMatchFound("vite/client", this.tsconfig.tsconfigJson.compilerOptions.types)) this.tsconfig.tsconfigJson.compilerOptions.types.push("vite/client");
65
+ const viteBuildConfig = this.config.build;
66
+ viteBuildConfig.build ??= {};
67
+ viteBuildConfig.build.target = "chrome95";
68
+ viteBuildConfig.plugins ??= [];
69
+ viteBuildConfig.plugins.unshift(viteReactPlugin({
70
+ babel: this.config.transform.babel,
71
+ jsxImportSource: this.config.react.jsxImportSource,
72
+ jsxRuntime: this.config.react.jsxRuntime,
73
+ reactRefreshHost: this.config.react.reactRefreshHost
74
+ }));
75
+ }
76
+ if (this.env?.types?.env && !this.env.types.env.hasProperty("DISABLE_REACT_COMPILER")) this.env.types.env.addProperty({
77
+ name: "DISABLE_REACT_COMPILER",
78
+ optional: true,
79
+ readonly: true,
80
+ description: "Disables the React compiler optimizations.",
81
+ visibility: type_exports.ReflectionVisibility.public,
82
+ type: { kind: type_exports.ReflectionKind.boolean },
83
+ default: false
84
+ });
85
+ },
86
+ async prepare() {
87
+ const _self$ = this;
88
+ return this.render(createComponent(ReactOptimizedBuiltin, { get override() {
89
+ return _self$.config.react.compiler === false ? false : void 0;
90
+ } }));
91
+ }
92
+ }
93
+ ];
94
+ };
95
+ var src_default = plugin;
96
+
97
+ //#endregion
98
+ export { ReactOptimizedBuiltin, src_default as default, plugin };
@@ -1 +1,45 @@
1
- const e=require(`../../../../_virtual/rolldown_runtime.cjs`),t=require(`../../vendor/index.cjs`),n=require(`../contexts/context.cjs`);let r=require(`@alloy-js/core/jsx-runtime`),i=require(`@stryke/path/replace`);function a(e){let[{children:a,context:o,basePath:s},c]=(0,t.vendor_exports.splitProps)(e,[`children`,`context`,`basePath`]),l=(0,t.vendor_exports.ref)(o),u=(0,t.vendor_exports.computed)(()=>s?(0,i.replacePath)(s,l.value.workspaceConfig.workspaceRoot):l.value.workspaceConfig.workspaceRoot);return(0,r.createComponent)(t.vendor_exports.Output,(0,r.mergeProps)(c,{get basePath(){return u.value},get children(){return(0,r.createComponent)(n.PowerlinesContext.Provider,{value:{ref:l},get children(){return(0,r.createComponent)(t.vendor_exports.Show,{get when(){return!!l.value},children:a})}})}}))}exports.Output=a;
1
+ const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.cjs');
2
+ const require_context = require('../contexts/context.cjs');
3
+ let __alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
4
+ let __alloy_js_core = require("@alloy-js/core");
5
+ let __stryke_path_replace = require("@stryke/path/replace");
6
+
7
+ //#region ../plugin-alloy/src/core/components/output.tsx
8
+ /**
9
+ * Output component for rendering the Powerlines plugin's output files via templates.
10
+ */
11
+ function Output(props) {
12
+ const [{ children, context, meta, basePath }, rest] = (0, __alloy_js_core.splitProps)(props, [
13
+ "children",
14
+ "context",
15
+ "meta",
16
+ "basePath"
17
+ ]);
18
+ const contextRef = (0, __alloy_js_core.ref)(context);
19
+ const metaRef = (0, __alloy_js_core.ref)(meta ?? {});
20
+ const basePathRef = (0, __alloy_js_core.computed)(() => basePath ? (0, __stryke_path_replace.replacePath)(basePath, contextRef.value.workspaceConfig.workspaceRoot) : contextRef.value.workspaceConfig.workspaceRoot);
21
+ return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Output, (0, __alloy_js_core_jsx_runtime.mergeProps)(rest, {
22
+ get basePath() {
23
+ return basePathRef.value;
24
+ },
25
+ get children() {
26
+ return (0, __alloy_js_core_jsx_runtime.createComponent)(require_context.PowerlinesContext.Provider, {
27
+ value: {
28
+ ref: contextRef,
29
+ meta: metaRef
30
+ },
31
+ get children() {
32
+ return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
33
+ get when() {
34
+ return Boolean(contextRef.value);
35
+ },
36
+ children
37
+ });
38
+ }
39
+ });
40
+ }
41
+ }));
42
+ }
43
+
44
+ //#endregion
45
+ exports.Output = Output;
@@ -1 +1,44 @@
1
- import{vendor_exports as e}from"../../vendor/index.mjs";import{PowerlinesContext as t}from"../contexts/context.mjs";import{createComponent as n,mergeProps as r}from"@alloy-js/core/jsx-runtime";import{replacePath as i}from"@stryke/path/replace";function a(a){let[{children:o,context:s,basePath:c},l]=(0,e.splitProps)(a,[`children`,`context`,`basePath`]),u=(0,e.ref)(s),d=(0,e.computed)(()=>c?i(c,u.value.workspaceConfig.workspaceRoot):u.value.workspaceConfig.workspaceRoot);return n(e.Output,r(l,{get basePath(){return d.value},get children(){return n(t.Provider,{value:{ref:u},get children(){return n(e.Show,{get when(){return!!u.value},children:o})}})}}))}export{a as Output};
1
+ import { PowerlinesContext } from "../contexts/context.mjs";
2
+ import { createComponent, mergeProps } from "@alloy-js/core/jsx-runtime";
3
+ import { Output, Show, computed, ref, splitProps } from "@alloy-js/core";
4
+ import { replacePath } from "@stryke/path/replace";
5
+
6
+ //#region ../plugin-alloy/src/core/components/output.tsx
7
+ /**
8
+ * Output component for rendering the Powerlines plugin's output files via templates.
9
+ */
10
+ function Output$1(props) {
11
+ const [{ children, context, meta, basePath }, rest] = splitProps(props, [
12
+ "children",
13
+ "context",
14
+ "meta",
15
+ "basePath"
16
+ ]);
17
+ const contextRef = ref(context);
18
+ const metaRef = ref(meta ?? {});
19
+ const basePathRef = computed(() => basePath ? replacePath(basePath, contextRef.value.workspaceConfig.workspaceRoot) : contextRef.value.workspaceConfig.workspaceRoot);
20
+ return createComponent(Output, mergeProps(rest, {
21
+ get basePath() {
22
+ return basePathRef.value;
23
+ },
24
+ get children() {
25
+ return createComponent(PowerlinesContext.Provider, {
26
+ value: {
27
+ ref: contextRef,
28
+ meta: metaRef
29
+ },
30
+ get children() {
31
+ return createComponent(Show, {
32
+ get when() {
33
+ return Boolean(contextRef.value);
34
+ },
35
+ children
36
+ });
37
+ }
38
+ });
39
+ }
40
+ }));
41
+ }
42
+
43
+ //#endregion
44
+ export { Output$1 as Output };
@@ -1 +1,11 @@
1
- const e=require(`../../vendor/index.cjs`),t=(0,e.vendor_exports.createNamedContext)(`powerlines`);exports.PowerlinesContext=t;
1
+ const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.cjs');
2
+ let __alloy_js_core = require("@alloy-js/core");
3
+
4
+ //#region ../plugin-alloy/src/core/contexts/context.ts
5
+ /**
6
+ * The Powerlines context used in template rendering.
7
+ */
8
+ const PowerlinesContext = (0, __alloy_js_core.createNamedContext)("powerlines");
9
+
10
+ //#endregion
11
+ exports.PowerlinesContext = PowerlinesContext;
@@ -1 +1,10 @@
1
- import{vendor_exports as e}from"../../vendor/index.mjs";const t=(0,e.createNamedContext)(`powerlines`);export{t as PowerlinesContext};
1
+ import { createNamedContext } from "@alloy-js/core";
2
+
3
+ //#region ../plugin-alloy/src/core/contexts/context.ts
4
+ /**
5
+ * The Powerlines context used in template rendering.
6
+ */
7
+ const PowerlinesContext = createNamedContext("powerlines");
8
+
9
+ //#endregion
10
+ export { PowerlinesContext };
@@ -1,2 +1,93 @@
1
- const e=require(`../../_virtual/rolldown_runtime.cjs`),t=require(`./vendor/index.cjs`),n=require(`./core/components/output.cjs`);let r=require(`@alloy-js/core/jsx-runtime`),i=require(`@storm-software/config-tools/types`),a=require(`@stryke/path/is-parent-path`),o=require(`@stryke/type-checks/is-set-string`),s=require(`@alloy-js/rollup-plugin`);s=e.__toESM(s);let c=require(`@stryke/json/storm-json`),l=require(`@stryke/path/replace`),u=require(`prettier/doc.js`),d=require(`rolldown/experimental`);const f=(e={})=>[{name:`alloy:config`,config(){return{alloy:{typescript:!0,...e},build:{inputOptions:{transform:{jsx:{runtime:`classic`,pragma:`Alloy.createElement`,importSource:`@powerlines/plugin-alloy/vendor`}}},plugins:[(0,s.default)(),(0,d.viteAliasPlugin)({entries:[{find:`@alloy-js/core`,replacement:`@powerlines/plugin-alloy/vendor`},{find:`@alloy-js/core/jsx-runtime`,replacement:`@powerlines/plugin-alloy/vendor/jsx-runtime`}]})],alias:{"@alloy-js/core":`@powerlines/plugin-alloy/vendor`,"@alloy-js/core/jsx-runtime":`@powerlines/plugin-alloy/vendor/jsx-runtime`}}}},async configResolved(){(this.tsconfig.tsconfigJson.compilerOptions?.jsx!==`preserve`||this.tsconfig.tsconfigJson.compilerOptions?.jsxImportSource!==`@powerlines/plugin-alloy/vendor`)&&(this.tsconfig.tsconfigJson.compilerOptions??={},this.tsconfig.tsconfigJson.compilerOptions.jsx!==`preserve`&&(this.tsconfig.tsconfigJson.compilerOptions.jsx=`preserve`),this.tsconfig.tsconfigJson.compilerOptions.jsxImportSource!==`@powerlines/plugin-alloy/vendor`&&(this.tsconfig.tsconfigJson.compilerOptions.jsxImportSource=`@powerlines/plugin-alloy/vendor`),await this.fs.write(this.tsconfig.tsconfigFilePath,c.StormJSON.stringify(this.tsconfig.tsconfigJson))),this.config.alloy?.typescript!==!1&&(this.dependencies[`@alloy-js/typescript`]=`^0.22.0`),this.config.alloy?.json===!0&&(this.dependencies[`@alloy-js/json`]=`^0.22.0`),this.config.alloy?.markdown===!0&&(this.dependencies[`@alloy-js/markdown`]=`^0.22.0`)},resolveId(e){return e===`@alloy-js/core`?{id:`@powerlines/plugin-alloy/vendor`,external:!0}:e===`@alloy-js/core/jsx-runtime`?{id:`@powerlines/plugin-alloy/vendor/jsx-runtime`,external:!0}:null}},{name:`alloy:update-context`,configResolved:{order:`pre`,async handler(){this.render=async e=>{let i=this,a=(0,t.vendor_exports.renderTree)((0,r.createComponent)(n.Output,{context:i,get basePath(){return i.workspaceConfig.workspaceRoot},children:e}));await m(this,a,this.config.alloy)}}}}];var p=f;async function m(e,n,r={}){await(0,t.vendor_exports.flushJobsAsync)();let s,c=async(n,o)=>{if(!Array.isArray(o))return;let u=async e=>{for(let t of o)await c(e,t)},d=(0,t.vendor_exports.getContextForRenderNode)(o);if(!d)return u(n);if(d.meta?.directory){let e={kind:`directory`,path:d.meta.directory.path,contents:[]};n?n.contents.push(e):s=e,await u(e)}else if(d.meta?.sourceFile){if(!n)throw Error(`Source file doesn't have parent directory. Make sure you have used the Output component.`);let t;if(d.meta?.builtin){if(!d.meta.builtin.id)throw Error("Built-in runtime module doesn't have an ID. Make sure you have used the `<BuiltinFile />` component.");e.log(i.LogLevelLabel.TRACE,`Rendering built-in runtime module with ID: ${d.meta.builtin.id}`),t={kind:`builtin`,id:d.meta.builtin.id,path:(0,l.replacePath)(d.meta.sourceFile.path,e.builtinsPath),filetype:d.meta.sourceFile.filetype,preset:d.meta.output?.mode,contents:await h(e,o,r)}}else d.meta?.entry||(0,a.isParentPath)(e.entryPath,d.meta.sourceFile.path)?(e.log(i.LogLevelLabel.TRACE,`Rendering entry module at path: ${d.meta.sourceFile.path}`),t={kind:`entry`,typeDefinition:d.meta.entry?.typeDefinition,path:d.meta.sourceFile.path,filetype:d.meta.sourceFile.filetype,preset:d.meta.output?.mode,contents:await h(e,o,r)}):(e.log(i.LogLevelLabel.TRACE,`Rendering source file at path: ${d.meta.sourceFile.path}`),t={kind:`file`,path:d.meta.sourceFile.path,filetype:d.meta.sourceFile.filetype,preset:d.meta.output?.mode,contents:await h(e,o,r)});n.contents.push(t)}else if(d.meta?.copyFile){if(!n)throw Error(`Copy file doesn't have parent directory. Make sure you have used the Output component.`);if(e.log(i.LogLevelLabel.TRACE,`Processing copy file operation from "${d.meta.copyFile.sourcePath}" to "${d.meta.copyFile.path}"`),!d.meta.copyFile.sourcePath)throw Error("Copy file doesn't have a source path. Make sure you have provided a `sourcePath` property to the `meta.copyFile` context.");if(!d.meta.copyFile.path)throw Error("Copy file doesn't have a destination path. Make sure you have provided a `path` property to the `meta.copyFile` context.");n.contents.push({kind:`file`,path:d.meta.copyFile.path,sourcePath:d.meta.copyFile.sourcePath,preset:d.meta.output?.preset})}else await u(n)};await c(void 0,n);let u=async(e,t)=>{for(let n of t.contents)if(n.kind===`directory`)await u(e,n);else if(n.kind===`builtin`)await e.emitBuiltin(n.contents,n.id,n.path);else if(n.kind===`entry`)await e.emitEntry(n.contents,n.path,n.typeDefinition);else if(n.kind===`file`)if(`sourcePath`in n&&n.sourcePath){if(!e.fs.existsSync(n.sourcePath))throw Error(`Source file "${n.sourcePath}" for copy operation does not exist.`);let t=await e.fs.read(n.sourcePath);if(!(0,o.isSetString)(t))throw Error(`Source file "${n.sourcePath}" for copy operation is empty.`);await e.fs.write(n.path,t)}else if(`contents`in n&&(0,o.isSetString)(n.contents))await e.fs.write(n.path,n.contents);else throw Error(`Unexpected output extracted from the render tree: \n\n${JSON.stringify(n,null,2)}`)};await u(e,s)}async function h(e,n,r={}){r.printWidth??=160,r.tabWidth??=2,r.useTabs??=!1,r.insertFinalNewLine??=!0,await(0,t.vendor_exports.flushJobsAsync)();let i=u.printer.printDocToString(g(n),r).formatted;return r.insertFinalNewLine&&!i.endsWith(`
2
- `)?`${i}\n`:i}function g(e){let n=[];for(let r of e)if(typeof r==`string`){let e=r.split(/\r?\n/).flatMap((e,t,n)=>(n.length-1,[e]));n.push(e)}else (0,t.vendor_exports.isPrintHook)(r)?n.push(r.print(r.subtree,g)):n.push(g(r));return n}exports.default=p;
1
+ const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
2
+ const require_output = require('./core/components/output.cjs');
3
+ let __alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
4
+ let __alloy_js_core = require("@alloy-js/core");
5
+ let __alloy_js_rollup_plugin = require("@alloy-js/rollup-plugin");
6
+ __alloy_js_rollup_plugin = require_rolldown_runtime.__toESM(__alloy_js_rollup_plugin);
7
+ let __stryke_json_storm_json = require("@stryke/json/storm-json");
8
+
9
+ //#region ../plugin-alloy/src/index.tsx
10
+ /**
11
+ * Alloy-js plugin for Powerlines.
12
+ *
13
+ * @param options - The Alloy-js plugin user configuration options.
14
+ * @returns A Powerlines plugin that integrates Alloy-js transformations.
15
+ */
16
+ const plugin = (options = {}) => {
17
+ return [{
18
+ name: "alloy:config",
19
+ config() {
20
+ return {
21
+ alloy: {
22
+ typescript: true,
23
+ ...options
24
+ },
25
+ build: {
26
+ inputOptions: { transform: { jsx: {
27
+ runtime: "classic",
28
+ pragma: "Alloy.createElement",
29
+ importSource: "@alloy-js/core"
30
+ } } },
31
+ plugins: [(0, __alloy_js_rollup_plugin.default)()]
32
+ }
33
+ };
34
+ },
35
+ async configResolved() {
36
+ if (this.tsconfig.tsconfigJson.compilerOptions?.jsx !== "preserve" || this.tsconfig.tsconfigJson.compilerOptions?.jsxImportSource !== "@alloy-js/core") {
37
+ this.tsconfig.tsconfigJson.compilerOptions ??= {};
38
+ if (this.tsconfig.tsconfigJson.compilerOptions.jsx !== "preserve") this.tsconfig.tsconfigJson.compilerOptions.jsx = "preserve";
39
+ if (this.tsconfig.tsconfigJson.compilerOptions.jsxImportSource !== "@alloy-js/core") this.tsconfig.tsconfigJson.compilerOptions.jsxImportSource = "@alloy-js/core";
40
+ await this.fs.write(this.tsconfig.tsconfigFilePath, __stryke_json_storm_json.StormJSON.stringify(this.tsconfig.tsconfigJson));
41
+ }
42
+ this.dependencies["@alloy-js/core"] = "^0.22.0";
43
+ if (this.config.alloy?.typescript !== false) this.dependencies["@alloy-js/typescript"] = "^0.22.0";
44
+ if (this.config.alloy?.json === true) this.dependencies["@alloy-js/json"] = "^0.22.0";
45
+ if (this.config.alloy?.markdown === true) this.dependencies["@alloy-js/markdown"] = "^0.22.0";
46
+ }
47
+ }, {
48
+ name: "alloy:update-context",
49
+ configResolved: {
50
+ order: "pre",
51
+ async handler() {
52
+ this.render = async (children) => {
53
+ const _self$ = this;
54
+ const meta = {};
55
+ await (0, __alloy_js_core.traverseOutput)(await (0, __alloy_js_core.renderAsync)((0, __alloy_js_core_jsx_runtime.createComponent)(require_output.Output, {
56
+ context: _self$,
57
+ meta,
58
+ get basePath() {
59
+ return _self$.workspaceConfig.workspaceRoot;
60
+ },
61
+ children
62
+ })), {
63
+ visitDirectory: (directory) => {
64
+ if (this.fs.existsSync(directory.path)) return;
65
+ this.fs.mkdirSync(directory.path);
66
+ },
67
+ visitFile: (file) => {
68
+ if ("contents" in file) {
69
+ const metadata = meta[file.path] ?? {};
70
+ if (metadata.kind === "builtin") {
71
+ if (!metadata.id) throw new Error(`Built-in file "${file.path}" is missing its ID in the render metadata.`);
72
+ this.emitBuiltinSync(file.contents, metadata.id, file.path, {
73
+ skipFormat: metadata.skipFormat,
74
+ storage: metadata.storage
75
+ });
76
+ } else if (metadata.kind === "entry") this.emitEntrySync(file.contents, file.path, {
77
+ skipFormat: metadata.skipFormat,
78
+ storage: metadata.storage,
79
+ ...metadata.typeDefinition ?? {}
80
+ });
81
+ else this.emitSync(file.path, file.contents, metadata);
82
+ } else this.fs.copySync(file.sourcePath, file.path);
83
+ }
84
+ });
85
+ };
86
+ }
87
+ }
88
+ }];
89
+ };
90
+ var src_default = plugin;
91
+
92
+ //#endregion
93
+ exports.default = src_default;
@@ -1,2 +1,91 @@
1
- import{vendor_exports as e}from"./vendor/index.mjs";import{Output as t}from"./core/components/output.mjs";import{createComponent as n}from"@alloy-js/core/jsx-runtime";import{LogLevelLabel as r}from"@storm-software/config-tools/types";import{isParentPath as i}from"@stryke/path/is-parent-path";import{isSetString as a}from"@stryke/type-checks/is-set-string";import o from"@alloy-js/rollup-plugin";import{StormJSON as s}from"@stryke/json/storm-json";import{replacePath as c}from"@stryke/path/replace";import{printer as l}from"prettier/doc.js";import{viteAliasPlugin as u}from"rolldown/experimental";var d=(r={})=>[{name:`alloy:config`,config(){return{alloy:{typescript:!0,...r},build:{inputOptions:{transform:{jsx:{runtime:`classic`,pragma:`Alloy.createElement`,importSource:`@powerlines/plugin-alloy/vendor`}}},plugins:[o(),u({entries:[{find:`@alloy-js/core`,replacement:`@powerlines/plugin-alloy/vendor`},{find:`@alloy-js/core/jsx-runtime`,replacement:`@powerlines/plugin-alloy/vendor/jsx-runtime`}]})],alias:{"@alloy-js/core":`@powerlines/plugin-alloy/vendor`,"@alloy-js/core/jsx-runtime":`@powerlines/plugin-alloy/vendor/jsx-runtime`}}}},async configResolved(){(this.tsconfig.tsconfigJson.compilerOptions?.jsx!==`preserve`||this.tsconfig.tsconfigJson.compilerOptions?.jsxImportSource!==`@powerlines/plugin-alloy/vendor`)&&(this.tsconfig.tsconfigJson.compilerOptions??={},this.tsconfig.tsconfigJson.compilerOptions.jsx!==`preserve`&&(this.tsconfig.tsconfigJson.compilerOptions.jsx=`preserve`),this.tsconfig.tsconfigJson.compilerOptions.jsxImportSource!==`@powerlines/plugin-alloy/vendor`&&(this.tsconfig.tsconfigJson.compilerOptions.jsxImportSource=`@powerlines/plugin-alloy/vendor`),await this.fs.write(this.tsconfig.tsconfigFilePath,s.stringify(this.tsconfig.tsconfigJson))),this.config.alloy?.typescript!==!1&&(this.dependencies[`@alloy-js/typescript`]=`^0.22.0`),this.config.alloy?.json===!0&&(this.dependencies[`@alloy-js/json`]=`^0.22.0`),this.config.alloy?.markdown===!0&&(this.dependencies[`@alloy-js/markdown`]=`^0.22.0`)},resolveId(e){return e===`@alloy-js/core`?{id:`@powerlines/plugin-alloy/vendor`,external:!0}:e===`@alloy-js/core/jsx-runtime`?{id:`@powerlines/plugin-alloy/vendor/jsx-runtime`,external:!0}:null}},{name:`alloy:update-context`,configResolved:{order:`pre`,async handler(){this.render=async r=>{let i=this,a=(0,e.renderTree)(n(t,{context:i,get basePath(){return i.workspaceConfig.workspaceRoot},children:r}));await f(this,a,this.config.alloy)}}}}];async function f(t,n,o={}){await(0,e.flushJobsAsync)();let s,l=async(n,a)=>{if(!Array.isArray(a))return;let u=async e=>{for(let t of a)await l(e,t)},d=(0,e.getContextForRenderNode)(a);if(!d)return u(n);if(d.meta?.directory){let e={kind:`directory`,path:d.meta.directory.path,contents:[]};n?n.contents.push(e):s=e,await u(e)}else if(d.meta?.sourceFile){if(!n)throw Error(`Source file doesn't have parent directory. Make sure you have used the Output component.`);let e;if(d.meta?.builtin){if(!d.meta.builtin.id)throw Error("Built-in runtime module doesn't have an ID. Make sure you have used the `<BuiltinFile />` component.");t.log(r.TRACE,`Rendering built-in runtime module with ID: ${d.meta.builtin.id}`),e={kind:`builtin`,id:d.meta.builtin.id,path:c(d.meta.sourceFile.path,t.builtinsPath),filetype:d.meta.sourceFile.filetype,preset:d.meta.output?.mode,contents:await p(t,a,o)}}else d.meta?.entry||i(t.entryPath,d.meta.sourceFile.path)?(t.log(r.TRACE,`Rendering entry module at path: ${d.meta.sourceFile.path}`),e={kind:`entry`,typeDefinition:d.meta.entry?.typeDefinition,path:d.meta.sourceFile.path,filetype:d.meta.sourceFile.filetype,preset:d.meta.output?.mode,contents:await p(t,a,o)}):(t.log(r.TRACE,`Rendering source file at path: ${d.meta.sourceFile.path}`),e={kind:`file`,path:d.meta.sourceFile.path,filetype:d.meta.sourceFile.filetype,preset:d.meta.output?.mode,contents:await p(t,a,o)});n.contents.push(e)}else if(d.meta?.copyFile){if(!n)throw Error(`Copy file doesn't have parent directory. Make sure you have used the Output component.`);if(t.log(r.TRACE,`Processing copy file operation from "${d.meta.copyFile.sourcePath}" to "${d.meta.copyFile.path}"`),!d.meta.copyFile.sourcePath)throw Error("Copy file doesn't have a source path. Make sure you have provided a `sourcePath` property to the `meta.copyFile` context.");if(!d.meta.copyFile.path)throw Error("Copy file doesn't have a destination path. Make sure you have provided a `path` property to the `meta.copyFile` context.");n.contents.push({kind:`file`,path:d.meta.copyFile.path,sourcePath:d.meta.copyFile.sourcePath,preset:d.meta.output?.preset})}else await u(n)};await l(void 0,n);let u=async(e,t)=>{for(let n of t.contents)if(n.kind===`directory`)await u(e,n);else if(n.kind===`builtin`)await e.emitBuiltin(n.contents,n.id,n.path);else if(n.kind===`entry`)await e.emitEntry(n.contents,n.path,n.typeDefinition);else if(n.kind===`file`)if(`sourcePath`in n&&n.sourcePath){if(!e.fs.existsSync(n.sourcePath))throw Error(`Source file "${n.sourcePath}" for copy operation does not exist.`);let t=await e.fs.read(n.sourcePath);if(!a(t))throw Error(`Source file "${n.sourcePath}" for copy operation is empty.`);await e.fs.write(n.path,t)}else if(`contents`in n&&a(n.contents))await e.fs.write(n.path,n.contents);else throw Error(`Unexpected output extracted from the render tree: \n\n${JSON.stringify(n,null,2)}`)};await u(t,s)}async function p(t,n,r={}){r.printWidth??=160,r.tabWidth??=2,r.useTabs??=!1,r.insertFinalNewLine??=!0,await(0,e.flushJobsAsync)();let i=l.printDocToString(m(n),r).formatted;return r.insertFinalNewLine&&!i.endsWith(`
2
- `)?`${i}\n`:i}function m(t){let n=[];for(let r of t)if(typeof r==`string`){let e=r.split(/\r?\n/).flatMap((e,t,n)=>(n.length-1,[e]));n.push(e)}else (0,e.isPrintHook)(r)?n.push(r.print(r.subtree,m)):n.push(m(r));return n}export{d as default};
1
+ import { Output as Output$1 } from "./core/components/output.mjs";
2
+ import { createComponent } from "@alloy-js/core/jsx-runtime";
3
+ import { renderAsync, traverseOutput } from "@alloy-js/core";
4
+ import alloy from "@alloy-js/rollup-plugin";
5
+ import { StormJSON } from "@stryke/json/storm-json";
6
+
7
+ //#region ../plugin-alloy/src/index.tsx
8
+ /**
9
+ * Alloy-js plugin for Powerlines.
10
+ *
11
+ * @param options - The Alloy-js plugin user configuration options.
12
+ * @returns A Powerlines plugin that integrates Alloy-js transformations.
13
+ */
14
+ const plugin = (options = {}) => {
15
+ return [{
16
+ name: "alloy:config",
17
+ config() {
18
+ return {
19
+ alloy: {
20
+ typescript: true,
21
+ ...options
22
+ },
23
+ build: {
24
+ inputOptions: { transform: { jsx: {
25
+ runtime: "classic",
26
+ pragma: "Alloy.createElement",
27
+ importSource: "@alloy-js/core"
28
+ } } },
29
+ plugins: [alloy()]
30
+ }
31
+ };
32
+ },
33
+ async configResolved() {
34
+ if (this.tsconfig.tsconfigJson.compilerOptions?.jsx !== "preserve" || this.tsconfig.tsconfigJson.compilerOptions?.jsxImportSource !== "@alloy-js/core") {
35
+ this.tsconfig.tsconfigJson.compilerOptions ??= {};
36
+ if (this.tsconfig.tsconfigJson.compilerOptions.jsx !== "preserve") this.tsconfig.tsconfigJson.compilerOptions.jsx = "preserve";
37
+ if (this.tsconfig.tsconfigJson.compilerOptions.jsxImportSource !== "@alloy-js/core") this.tsconfig.tsconfigJson.compilerOptions.jsxImportSource = "@alloy-js/core";
38
+ await this.fs.write(this.tsconfig.tsconfigFilePath, StormJSON.stringify(this.tsconfig.tsconfigJson));
39
+ }
40
+ this.dependencies["@alloy-js/core"] = "^0.22.0";
41
+ if (this.config.alloy?.typescript !== false) this.dependencies["@alloy-js/typescript"] = "^0.22.0";
42
+ if (this.config.alloy?.json === true) this.dependencies["@alloy-js/json"] = "^0.22.0";
43
+ if (this.config.alloy?.markdown === true) this.dependencies["@alloy-js/markdown"] = "^0.22.0";
44
+ }
45
+ }, {
46
+ name: "alloy:update-context",
47
+ configResolved: {
48
+ order: "pre",
49
+ async handler() {
50
+ this.render = async (children) => {
51
+ const _self$ = this;
52
+ const meta = {};
53
+ await traverseOutput(await renderAsync(createComponent(Output$1, {
54
+ context: _self$,
55
+ meta,
56
+ get basePath() {
57
+ return _self$.workspaceConfig.workspaceRoot;
58
+ },
59
+ children
60
+ })), {
61
+ visitDirectory: (directory) => {
62
+ if (this.fs.existsSync(directory.path)) return;
63
+ this.fs.mkdirSync(directory.path);
64
+ },
65
+ visitFile: (file) => {
66
+ if ("contents" in file) {
67
+ const metadata = meta[file.path] ?? {};
68
+ if (metadata.kind === "builtin") {
69
+ if (!metadata.id) throw new Error(`Built-in file "${file.path}" is missing its ID in the render metadata.`);
70
+ this.emitBuiltinSync(file.contents, metadata.id, file.path, {
71
+ skipFormat: metadata.skipFormat,
72
+ storage: metadata.storage
73
+ });
74
+ } else if (metadata.kind === "entry") this.emitEntrySync(file.contents, file.path, {
75
+ skipFormat: metadata.skipFormat,
76
+ storage: metadata.storage,
77
+ ...metadata.typeDefinition ?? {}
78
+ });
79
+ else this.emitSync(file.path, file.contents, metadata);
80
+ } else this.fs.copySync(file.sourcePath, file.path);
81
+ }
82
+ });
83
+ };
84
+ }
85
+ }
86
+ }];
87
+ };
88
+ var src_default = plugin;
89
+
90
+ //#endregion
91
+ export { src_default as default };
@@ -1,4 +1,4 @@
1
1
  import "../../../powerlines/src/types/fs.mjs";
2
2
  import "../../../powerlines/src/types/resolved.mjs";
3
- import "../vendor/index.mjs";
3
+ import { Children } from "@alloy-js/core";
4
4
  import "@alloy-js/typescript";
@@ -1,6 +1,7 @@
1
1
  import { UserConfig } from "../../../powerlines/src/types/config.cjs";
2
2
  import { ResolvedConfig } from "../../../powerlines/src/types/resolved.cjs";
3
3
  import { PluginContext } from "../../../powerlines/src/types/context.cjs";
4
+ import { Children, PrintTreeOptions } from "@alloy-js/core";
4
5
 
5
6
  //#region ../plugin-alloy/src/types/plugin.d.ts
6
7
  type AlloyPluginOptions = Partial<PrintTreeOptions> & {
@@ -1,10 +1,10 @@
1
1
  import { UserConfig } from "../../../powerlines/src/types/config.mjs";
2
2
  import { ResolvedConfig } from "../../../powerlines/src/types/resolved.mjs";
3
3
  import { PluginContext } from "../../../powerlines/src/types/context.mjs";
4
- import { index_d_exports } from "../vendor/index.mjs";
4
+ import { Children, PrintTreeOptions } from "@alloy-js/core";
5
5
 
6
6
  //#region ../plugin-alloy/src/types/plugin.d.ts
7
- type AlloyPluginOptions = Partial<index_d_exports.PrintTreeOptions> & {
7
+ type AlloyPluginOptions = Partial<PrintTreeOptions> & {
8
8
  /**
9
9
  * If true, the Alloy framework is used to generate Typescript output files.
10
10
  *
@@ -31,7 +31,7 @@ type AlloyPluginResolvedConfig = ResolvedConfig & {
31
31
  alloy: AlloyPluginOptions;
32
32
  };
33
33
  type AlloyPluginContext<TResolvedConfig extends AlloyPluginResolvedConfig = AlloyPluginResolvedConfig> = PluginContext<TResolvedConfig> & {
34
- render: <TContext extends AlloyPluginContext>(this: TContext, children: index_d_exports.Children) => Promise<void>;
34
+ render: <TContext extends AlloyPluginContext>(this: TContext, children: Children) => Promise<void>;
35
35
  };
36
36
  //#endregion
37
37
  export { AlloyPluginContext, AlloyPluginOptions, AlloyPluginResolvedConfig, AlloyPluginUserConfig };