@powerlines/plugin-rspack 0.5.65 → 0.5.67

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- const e=require(`../unplugin-BULbaczZ.cjs`);require(`../helpers-LF26RHol.cjs`),exports.createRspackPlugin=e.t;
1
+ const e=require(`../unplugin-BhjempsZ.cjs`);require(`../helpers-LF26RHol.cjs`),exports.createRspackPlugin=e.t;
@@ -1,4 +1,4 @@
1
- import "../plugin-BhH1l9o8.cjs";
2
- import { t as createRspackPlugin } from "../unplugin-y_62vxHE.cjs";
1
+ import "../plugin-CKBCxnSx.cjs";
2
+ import { t as createRspackPlugin } from "../unplugin-B05IYTFN.cjs";
3
3
  import "../index-D6CnpA_r.cjs";
4
4
  export { createRspackPlugin };
@@ -1,4 +1,4 @@
1
- import "../plugin-2BiSZzHl.mjs";
2
- import { t as createRspackPlugin } from "../unplugin-BHRIzeZN.mjs";
1
+ import "../plugin-C_2WTt9t.mjs";
2
+ import { t as createRspackPlugin } from "../unplugin-Dox2_b1o.mjs";
3
3
  import "../index-DL0uimUT.mjs";
4
4
  export { createRspackPlugin };
@@ -1 +1 @@
1
- const e=require(`../unplugin-BULbaczZ.cjs`);exports.createRspackPlugin=e.t;
1
+ const e=require(`../unplugin-BhjempsZ.cjs`);exports.createRspackPlugin=e.t;
@@ -1,3 +1,3 @@
1
- import "../plugin-BhH1l9o8.cjs";
2
- import { t as createRspackPlugin } from "../unplugin-y_62vxHE.cjs";
1
+ import "../plugin-CKBCxnSx.cjs";
2
+ import { t as createRspackPlugin } from "../unplugin-B05IYTFN.cjs";
3
3
  export { createRspackPlugin };
@@ -1,3 +1,3 @@
1
- import "../plugin-2BiSZzHl.mjs";
2
- import { t as createRspackPlugin } from "../unplugin-BHRIzeZN.mjs";
1
+ import "../plugin-C_2WTt9t.mjs";
2
+ import { t as createRspackPlugin } from "../unplugin-Dox2_b1o.mjs";
3
3
  export { createRspackPlugin };
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,`__esModule`,{value:!0});const e=require(`./unplugin-BULbaczZ.cjs`);require(`./helpers-LF26RHol.cjs`),require(`./plugin-pBKbb5K9.cjs`),require(`./types-o3zWarRp.cjs`);let t=require(`@rspack/core`),n=require(`@storm-software/config-tools/types`),r=require(`defu`);r=e.n(r);let i=require(`@stryke/helpers/omit`),a=require(`@stryke/path/join-paths`);function o(e){return(0,r.default)({resolve:{alias:e.builtins.reduce((t,n)=>{let r=e.fs.ids[n];return r&&(t[n]=r),t},{})}},e.config.build.variant===`rspack`?e.config.build.override:{},e.config.build.variant===`rspack`?(0,i.omit)(e.config.build,[`override`,`variant`]):{},{external:e.config.build.external,noExternal:e.config.build.noExternal,skipNodeModulesBundle:e.config.build.skipNodeModulesBundle},{output:{path:(0,a.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.output.buildPath)},name:e.config.name,node:e.config.build.platform===`node`?{__dirname:!0,__filename:!0,global:!0}:!1,mode:e.config.mode===`development`?`development`:`production`,recordsInputPath:(0,a.joinPaths)(e.cachePath,`rspack`,`.rspack-records.json`),recordsOutputPath:(0,a.joinPaths)(e.cachePath,`rspack`,`.rspack-records.json`),context:(0,a.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot),noExternal:e.builtins,cache:e.config.mode===`development`,devtool:e.config.mode===`development`?`source-map`:!1,optimization:{minimize:e.config.mode!==`development`}})}const s=(i={})=>({name:`rspack`,config(){return this.log(n.LogLevelLabel.TRACE,"Providing default configuration for the Powerlines `rspack` build plugin."),{build:{...i,variant:`rspack`}}},async build(){(0,t.rspack)((0,r.default)({entry:this.entry.reduce((e,t)=>(e[t.output||t.name||t.file]=t.file,e),{})},o(this),{plugins:[e.t(this)]}))}});var c=s;exports.createRspackPlugin=e.t,exports.default=c,exports.plugin=s;
1
+ Object.defineProperty(exports,`__esModule`,{value:!0});const e=require(`./unplugin-BhjempsZ.cjs`);require(`./helpers-LF26RHol.cjs`),require(`./plugin-pBKbb5K9.cjs`),require(`./types-o3zWarRp.cjs`);let t=require(`@rspack/core`),n=require(`@storm-software/config-tools/types`),r=require(`defu`);r=e.n(r);let i=require(`@stryke/helpers/omit`),a=require(`@stryke/path/join-paths`);function o(e){return(0,r.default)({resolve:{alias:e.builtins.reduce((t,n)=>{let r=e.fs.ids[n];return r&&(t[n]=r),t},{})}},e.config.build.variant===`rspack`?e.config.build.override:{},e.config.build.variant===`rspack`?(0,i.omit)(e.config.build,[`override`,`variant`]):{},{external:e.config.build.external,noExternal:e.config.build.noExternal,skipNodeModulesBundle:e.config.build.skipNodeModulesBundle},{output:{path:(0,a.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.output.buildPath)},name:e.config.name,node:e.config.build.platform===`node`?{__dirname:!0,__filename:!0,global:!0}:!1,mode:e.config.mode===`development`?`development`:`production`,recordsInputPath:(0,a.joinPaths)(e.cachePath,`rspack`,`.rspack-records.json`),recordsOutputPath:(0,a.joinPaths)(e.cachePath,`rspack`,`.rspack-records.json`),context:(0,a.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot),noExternal:e.builtins,cache:e.config.mode===`development`,devtool:e.config.mode===`development`?`source-map`:!1,optimization:{minimize:e.config.mode!==`development`}})}const s=(i={})=>({name:`rspack`,config(){return this.log(n.LogLevelLabel.TRACE,"Providing default configuration for the Powerlines `rspack` build plugin."),{build:{...i,variant:`rspack`}}},async build(){(0,t.rspack)((0,r.default)({entry:this.entry.reduce((e,t)=>(e[t.output||t.name||t.file]=t.file,e),{})},o(this),{plugins:[e.t(this)]}))}});var c=s;exports.createRspackPlugin=e.t,exports.default=c,exports.plugin=s;
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { a as __ΩRspackPluginOptions, i as __ΩRspackPluginContext, n as RspackPluginOptions, o as __ΩRspackPluginResolvedConfig, r as RspackPluginResolvedConfig, s as Plugin, t as RspackPluginContext } from "./plugin-BhH1l9o8.cjs";
2
- import { t as createRspackPlugin } from "./unplugin-y_62vxHE.cjs";
1
+ import { a as __ΩRspackPluginOptions, i as __ΩRspackPluginContext, n as RspackPluginOptions, o as __ΩRspackPluginResolvedConfig, r as RspackPluginResolvedConfig, s as Plugin, t as RspackPluginContext } from "./plugin-CKBCxnSx.cjs";
2
+ import { t as createRspackPlugin } from "./unplugin-B05IYTFN.cjs";
3
3
  import "./index-D6CnpA_r.cjs";
4
4
  import "./index-D4ELpJXS.cjs";
5
5
 
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { a as __ΩRspackPluginOptions, i as __ΩRspackPluginContext, n as RspackPluginOptions, o as __ΩRspackPluginResolvedConfig, r as RspackPluginResolvedConfig, s as Plugin, t as RspackPluginContext } from "./plugin-2BiSZzHl.mjs";
2
- import { t as createRspackPlugin } from "./unplugin-BHRIzeZN.mjs";
1
+ import { a as __ΩRspackPluginOptions, i as __ΩRspackPluginContext, n as RspackPluginOptions, o as __ΩRspackPluginResolvedConfig, r as RspackPluginResolvedConfig, s as Plugin, t as RspackPluginContext } from "./plugin-C_2WTt9t.mjs";
2
+ import { t as createRspackPlugin } from "./unplugin-Dox2_b1o.mjs";
3
3
  import "./index-DL0uimUT.mjs";
4
4
  import "./index-9iG2qHLe.mjs";
5
5
 
@@ -161,10 +161,7 @@ type RspackBuildConfig = Omit<Configuration, "name" | "entry" | "entryPoints" |
161
161
  type RspackResolvedBuildConfig = Configuration & BuildResolvedConfig;
162
162
  //#endregion
163
163
  //#region ../powerlines/src/types/fs.d.ts
164
- declare enum StoragePreset {
165
- VIRTUAL = "virtual",
166
- FS = "fs",
167
- }
164
+ type StoragePreset = "fs" | "virtual";
168
165
  /**
169
166
  * Interface defining the methods and properties for a storage adapter.
170
167
  */
@@ -913,7 +910,7 @@ interface Plugin<in out TContext extends PluginContext<ResolvedConfig> = PluginC
913
910
  * @param environment - The environment to check.
914
911
  * @returns `true` if the plugin should be active in the specified environment, `false` otherwise.
915
912
  */
916
- applyToEnvironment?: (environment: EnvironmentResolvedConfig) => MaybePromise<boolean | PluginConfig<any>>;
913
+ applyToEnvironment?: (environment: EnvironmentResolvedConfig) => boolean | PluginConfig<any>;
917
914
  }
918
915
  //#endregion
919
916
  //#region ../powerlines/src/types/tsconfig.d.ts
@@ -6,7 +6,6 @@ import { ResolveOptions } from "@stryke/fs/resolve";
6
6
  import "@babel/helper-plugin-utils";
7
7
  import ts from "typescript";
8
8
  import { Project } from "ts-morph";
9
- import "c12";
10
9
  import { EnvPaths } from "@stryke/env/get-env-paths";
11
10
  import { FetchRequestOptions } from "@stryke/http/fetch";
12
11
  import { ParseResult, ParserOptions } from "oxc-parser";
@@ -164,10 +163,7 @@ type RspackBuildConfig = Omit<Configuration, "name" | "entry" | "entryPoints" |
164
163
  type RspackResolvedBuildConfig = Configuration & BuildResolvedConfig;
165
164
  //#endregion
166
165
  //#region ../powerlines/src/types/fs.d.ts
167
- declare enum StoragePreset {
168
- VIRTUAL = "virtual",
169
- FS = "fs",
170
- }
166
+ type StoragePreset = "fs" | "virtual";
171
167
  /**
172
168
  * Interface defining the methods and properties for a storage adapter.
173
169
  */
@@ -916,7 +912,7 @@ interface Plugin<in out TContext extends PluginContext<ResolvedConfig> = PluginC
916
912
  * @param environment - The environment to check.
917
913
  * @returns `true` if the plugin should be active in the specified environment, `false` otherwise.
918
914
  */
919
- applyToEnvironment?: (environment: EnvironmentResolvedConfig) => MaybePromise<boolean | PluginConfig<any>>;
915
+ applyToEnvironment?: (environment: EnvironmentResolvedConfig) => boolean | PluginConfig<any>;
920
916
  }
921
917
  //#endregion
922
918
  //#region ../powerlines/src/types/tsconfig.d.ts
@@ -1,3 +1,3 @@
1
- import { a as __ΩRspackPluginOptions, i as __ΩRspackPluginContext, n as RspackPluginOptions, o as __ΩRspackPluginResolvedConfig, r as RspackPluginResolvedConfig, t as RspackPluginContext } from "../plugin-BhH1l9o8.cjs";
1
+ import { a as __ΩRspackPluginOptions, i as __ΩRspackPluginContext, n as RspackPluginOptions, o as __ΩRspackPluginResolvedConfig, r as RspackPluginResolvedConfig, t as RspackPluginContext } from "../plugin-CKBCxnSx.cjs";
2
2
  import "../index-D4ELpJXS.cjs";
3
3
  export { RspackPluginContext, RspackPluginOptions, RspackPluginResolvedConfig, __ΩRspackPluginContext, __ΩRspackPluginOptions, __ΩRspackPluginResolvedConfig };
@@ -1,3 +1,3 @@
1
- import { a as __ΩRspackPluginOptions, i as __ΩRspackPluginContext, n as RspackPluginOptions, o as __ΩRspackPluginResolvedConfig, r as RspackPluginResolvedConfig, t as RspackPluginContext } from "../plugin-2BiSZzHl.mjs";
1
+ import { a as __ΩRspackPluginOptions, i as __ΩRspackPluginContext, n as RspackPluginOptions, o as __ΩRspackPluginResolvedConfig, r as RspackPluginResolvedConfig, t as RspackPluginContext } from "../plugin-C_2WTt9t.mjs";
2
2
  import "../index-9iG2qHLe.mjs";
3
3
  export { RspackPluginContext, RspackPluginOptions, RspackPluginResolvedConfig, __ΩRspackPluginContext, __ΩRspackPluginOptions, __ΩRspackPluginResolvedConfig };
@@ -1,2 +1,2 @@
1
- import { a as __ΩRspackPluginOptions, i as __ΩRspackPluginContext, n as RspackPluginOptions, o as __ΩRspackPluginResolvedConfig, r as RspackPluginResolvedConfig, t as RspackPluginContext } from "../plugin-BhH1l9o8.cjs";
1
+ import { a as __ΩRspackPluginOptions, i as __ΩRspackPluginContext, n as RspackPluginOptions, o as __ΩRspackPluginResolvedConfig, r as RspackPluginResolvedConfig, t as RspackPluginContext } from "../plugin-CKBCxnSx.cjs";
2
2
  export { RspackPluginContext, RspackPluginOptions, RspackPluginResolvedConfig, __ΩRspackPluginContext, __ΩRspackPluginOptions, __ΩRspackPluginResolvedConfig };
@@ -1,2 +1,2 @@
1
- import { a as __ΩRspackPluginOptions, i as __ΩRspackPluginContext, n as RspackPluginOptions, o as __ΩRspackPluginResolvedConfig, r as RspackPluginResolvedConfig, t as RspackPluginContext } from "../plugin-2BiSZzHl.mjs";
1
+ import { a as __ΩRspackPluginOptions, i as __ΩRspackPluginContext, n as RspackPluginOptions, o as __ΩRspackPluginResolvedConfig, r as RspackPluginResolvedConfig, t as RspackPluginContext } from "../plugin-C_2WTt9t.mjs";
2
2
  export { RspackPluginContext, RspackPluginOptions, RspackPluginResolvedConfig, __ΩRspackPluginContext, __ΩRspackPluginOptions, __ΩRspackPluginResolvedConfig };
@@ -1,4 +1,4 @@
1
- import { t as RspackPluginContext } from "./plugin-BhH1l9o8.cjs";
1
+ import { t as RspackPluginContext } from "./plugin-CKBCxnSx.cjs";
2
2
  import * as unplugin0 from "unplugin";
3
3
 
4
4
  //#region src/helpers/unplugin.d.ts
@@ -0,0 +1,44 @@
1
+ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`@storm-software/config-tools/types`),l=require(`defu`);l=s(l);let u=require(`@stryke/helpers/omit`),d=require(`@stryke/path/join-paths`),ee=require(`@stryke/fs/get-workspace-root`),te=require(`unplugin`),ne=require(`@babel/core`),re=require(`@storm-software/config-tools/logger/console`),f=require(`@stryke/convert/to-array`),p=require(`@stryke/fs/helpers`),ie=require(`@stryke/fs/install`),m=require(`@stryke/fs/list-files`),h=require(`@stryke/fs/package-fns`),g=require(`@stryke/fs/resolve`),_=require(`@stryke/path/append`),v=require(`@stryke/path/replace`),ae=require(`@stryke/type-checks/is-error`),y=require(`@stryke/type-checks/is-function`),oe=require(`@stryke/type-checks/is-number`),se=require(`@stryke/type-checks/is-object`),ce=require(`@stryke/type-checks/is-promise`),b=require(`@stryke/type-checks/is-set`),x=require(`@stryke/type-checks/is-set-object`),S=require(`@stryke/type-checks/is-set-string`),C=require(`chalk`);C=s(C);let w=require(`handlebars`);w=s(w);let le=require(`@babel/helper-plugin-utils`),T=require(`@babel/types`);T=s(T);let E=require(`typescript`);E=s(E);let ue=require(`ts-morph`),D=require(`@stryke/type-checks/is-string`),O=require(`@stryke/string-format/package`),de=require(`@donedeal0/superdiff`),k=require(`@stryke/fs/json`),A=require(`@stryke/json/storm-json`),j=require(`@stryke/path/file-path-fns`),M=require(`@stryke/string-format/title-case`),N=require(`@stryke/fs/exists`),fe=require(`@storm-software/config-tools/get-config`),pe=require(`c12`),me=require(`@stryke/env/get-env-paths`),he=require(`@stryke/hash/hash-files`),P=require(`@stryke/hash/murmurhash`),F=require(`@stryke/helpers/get-unique`),ge=require(`@stryke/http/fetch`),I=require(`@stryke/path/is-type`),L=require(`@stryke/path/join`),_e=require(`@stryke/type-checks/is-null`),ve=require(`@stryke/unique-id/uuid`),R=require(`bundle-require`),ye=require(`flat-cache`),be=require(`oxc-parser`),z=require(`undici`),xe=require(`jiti`),B=require(`@stryke/type-checks/is-undefined`),Se=require(`@stryke/convert/parse-type-definition`),Ce=require(`@stryke/fs/is-file`),V=require(`@stryke/capnp`);V=s(V);let we=require(`@stryke/fs/buffer`),H=require(`@stryke/path/is-parent-path`),Te=require(`@stryke/string-format/pretty-bytes`),Ee=require(`node:buffer`),U=require(`node:url`),De=require(`prettier`),Oe=require(`@storm-software/config-tools/logger`),ke=require(`@storm-software/config-tools/utilities/colors`),Ae=require(`@stryke/helpers/noop`),je=require(`@stryke/path/correct-path`),Me=require(`@stryke/path/slash`),Ne=require(`@stryke/fs/read-file`),Pe=require(`@stryke/fs/write-file`),Fe=require(`node:fs`),Ie=require(`node:fs/promises`),Le=require(`node:path`);require(`@stryke/fs/remove-file`);let Re=require(`@stryke/string-format/kebab-case`);require(`magic-string`);function ze(e,t){if(!T.isStringLiteral(e.node))return;let n=e.node.value,r=t.context?.fs.resolveSync(n);r&&e.replaceWith(T.stringLiteral(r.replace(/\.(?:ts|mts|cts)x?$/,``)))}const Be=[`require`,`require.resolve`,`System.import`,`jest.genMockFromModule`,`jest.mock`,`jest.unmock`,`jest.doMock`,`jest.dontMock`,`jest.setMock`,`jest.requireActual`,`jest.requireMock`,`require.requireActual`,`require.requireMock`];function Ve(e,t,n){let{node:r}=t;if(T.isMemberExpression(r))return t.matchesPattern(n);if(!T.isIdentifier(r)||n.includes(`.`))return!1;let i=n.split(`.`)[0];return r.name===i}const He={CallExpression:(e,t)=>{if(t.moduleResolverVisited.has(e))return;let n=e.get(`callee`);(n&&Be.some(e=>Ve(t,n,e))||T.isImport(e.node.callee))&&(t.moduleResolverVisited.add(e),ze(e.get(`arguments.0`),t))},"ImportDeclaration|ExportDeclaration|ExportAllDeclaration":(e,t)=>{!e||!e.get(`source`)||t.moduleResolverVisited.has(e)||(t.moduleResolverVisited.add(e),ze(e.get(`source`),t))}},Ue=e=>(0,le.declare)(function(t){let n=new Set;return{name:`powerlines:module-resolver`,manipulateOptions(e){e.filename??=`unknown`},pre(){n=new Set},visitor:{Program:{enter(r,i){r.traverse(He,{...i,context:e,moduleResolverVisited:n,api:t})},exit(r,i){r.traverse(He,{...i,context:e,moduleResolverVisited:n,api:t})}}},post(){n.clear()}}});var We=class extends ue.InMemoryFileSystemHost{#e;constructor(e){super(),this.#e=e}deleteSync(e){this.#e.fs.removeSync(e)}readDirSync(e){return this.#e.fs.isDirectorySync(e)?this.#e.fs.listSync(e).reduce((e,t)=>{let n=this.#e.fs.resolveSync(t);return n&&e.push({name:t,isDirectory:this.#e.fs.isDirectorySync(n),isFile:this.#e.fs.isFileSync(n),isSymlink:!1}),e},[]):[]}async readFile(e){return this.#e.fs.isFileSync(e)?await this.#e.fs.read(e):``}readFileSync(e){return this.#e.fs.isFileSync(e)?this.#e.fs.readSync(e):``}async writeFile(e,t){return this.#e.fs.write(e,t)}writeFileSync(e,t){this.#e.fs.writeSync(e,t)}async mkdir(e){await this.#e.fs.mkdir(e)}mkdirSync(e){this.#e.fs.mkdirSync(e)}async move(e,t){await this.#e.fs.move(e,t)}moveSync(e,t){this.#e.fs.moveSync(e,t)}async copy(e,t){await this.#e.fs.copy(e,t)}copySync(e,t){this.#e.fs.copySync(e,t)}async fileExists(e){return this.#e.fs.isFile(e)}fileExistsSync(e){return this.#e.fs.isFileSync(e)}async directoryExists(e){return this.#e.fs.isDirectory(e)}directoryExistsSync(e){return this.#e.fs.isDirectorySync(e)}realpathSync(e){return this.#e.fs.resolveSync(e)||e}getCurrentDirectory(){return this.#e.workspaceConfig.workspaceRoot}async glob(e){return this.#e.fs.glob(e)}globSync(e){return this.#e.fs.globSync(e)}};function Ge(e,t){return e.log(c.LogLevelLabel.TRACE,`Creating ts-morph Project instance with configuration from: ${e.tsconfig.tsconfigFilePath}.`),new ue.Project((0,l.default)(t??{},{skipAddingFilesFromTsConfig:!1,tsConfigFilePath:e.tsconfig.tsconfigFilePath,fileSystem:new We(e),compilerOptions:(0,l.default)(e.tsconfig.options??{},{lib:[`lib.esnext.full.d.ts`]})}))}function Ke(e){return e.replace(/import\s*(?:type\s*)?\{?[\w,\s]*(?:\}\s*)?from\s*(?:'|")@?[a-zA-Z0-9-\\/.]*(?:'|");?/g,``).replaceAll(`#private;`,``).replace(/__Ω/g,``)}async function qe(e,t){e.log(c.LogLevelLabel.TRACE,`Running the TypeScript compiler for ${t.length} generated runtime files.`);let n=Ge(e,{skipAddingFilesFromTsConfig:!0});n.addSourceFilesAtPaths(t);let r=n.emitToMemory({emitOnlyDtsFiles:!0}),i=``;for(let t of r.getFiles())if(!t.filePath.endsWith(`.map`)&&e.builtins.some(n=>n===t.filePath||e.fs.metadata[n]?.id&&e.fs.metadata[n]?.id===t.filePath)){let n=await e.fs.resolve(t.filePath);i+=`
2
+ declare module "${n}" {
3
+ ${t.text.trim().replace(/^\s*export\s*declare\s*/gm,`export `).replace(/^\s*declare\s*/gm,``)}
4
+ }
5
+ `}let a=[];r.getDiagnostics().forEach(e=>{e.getSourceFile()?.getBaseName()?a.push(`${e.getSourceFile()?.getBaseName()} (${(e.getLineNumber()??0)+1}): ${(0,E.flattenDiagnosticMessageText)(e.getMessageText().toString(),`
6
+ `)}`):a.push((0,E.flattenDiagnosticMessageText)(e.getMessageText().toString(),`
7
+ `))});let o=a.join(`
8
+ `);if(o)throw Error(`TypeScript compilation failed: \n\n${o.length>5e3?`${o.slice(0,5e3)}...`:o}`);return Ke(i)}const Je=(0,l.createDefu)((e,t,n)=>(0,D.isString)(e[t])&&(0,D.isString)(n)?(e[t]=`${e[t]||``}\n${n||``}`.trim(),!0):!1);async function Ye(e,t,n,...r){let i=e.selectHooks(t,n);if(i.length>0){e.log(c.LogLevelLabel.DEBUG,` 🧩 Calling plugin hook: ${C.default.bold.cyanBright(`${t}${n?.order?` (${n.order})`:``}`)}`);let a=[];if(n?.sequential===!1)a=await Promise.all(i.map(async e=>{if(!(0,y.isFunction)(e.handle))throw Error(`Plugin hook handler for hook "${t}" is not a function.`);return Promise.resolve(e.handle.apply(e.context,[...r]))}));else for(let e of i){if(!(0,y.isFunction)(e.handle))throw Error(`Plugin hook handler for hook "${t}" is not a function.`);if(n?.result===`first`||n?.asNextParam===!1){if(a.push(await Promise.resolve(e.handle.apply(e.context,[...r]))),n?.result===`first`&&(0,b.isSet)(a[a.length-1]))break}else{let t=[...r];a.length>0&&t.length>0&&(t[0]=(0,y.isFunction)(n.asNextParam)?await Promise.resolve(n.asNextParam(a[0])):a[0]);let i=await Promise.resolve(e.handle.apply(e.context,[...t]));i&&(n?.result===`last`?a=[i]:(0,D.isString)(i)?a=[`${(0,D.isString)(a[0])&&a[0]||``}\n${i||``}`.trim()]:(0,se.isObject)(i)&&(a=[Je(i,a[0]??{})]))}}let o=a.filter(e=>(0,b.isSet)(e));if(o.length>0){let e;for(let t of o)e=(0,l.defu)(t,e??{});return e}}}async function Xe(e,t,n=!1){if(await(0,h.isPackageListed)((0,O.getPackageName)(t),{cwd:e.config.projectRoot})){if((0,O.hasPackageVersion)(t)&&!process.env.POWERLINES_SKIP_VERSION_CHECK&&!await(0,h.doesPackageMatch)((0,O.getPackageName)(t),(0,O.getPackageVersion)(t),e.config.projectRoot)){let n=await(0,h.getPackageListing)((0,O.getPackageName)(t),{cwd:e.config.projectRoot});!n?.version.startsWith(`catalog:`)&&!n?.version.startsWith(`workspace:`)&&e.log(c.LogLevelLabel.WARN,`The package "${(0,O.getPackageName)(t)}" is installed but does not match the expected version ${(0,O.getPackageVersion)(t)} (installed version: ${n?.version||`<Unknown>`}). Please ensure this is intentional before proceeding. Note: You can skip this validation with the "STORM_STACK_SKIP_VERSION_CHECK" environment variable.`)}}else if(e.config.skipInstalls!==!0){e.log(c.LogLevelLabel.WARN,`The package "${t}" is not installed. It will be installed automatically.`);let r=await(0,ie.install)(t,{cwd:e.config.projectRoot,dev:n});if((0,oe.isNumber)(r.exitCode)&&r.exitCode>0)throw e.log(c.LogLevelLabel.ERROR,r.stderr),Error(`An error occurred while installing the package "${t}"`)}else e.log(c.LogLevelLabel.WARN,`The package "${t}" is not installed. Since the "skipInstalls" option is set to true, it will not be installed automatically.`)}async function Ze(e){if(e.log(c.LogLevelLabel.TRACE,`Checking and installing missing project dependencies.`),e.dependencies??={},e.devDependencies??={},Object.keys(e.dependencies).length===0&&Object.keys(e.devDependencies).length===0){e.log(c.LogLevelLabel.TRACE,`No dependencies or devDependencies to install. Skipping installation step.`);return}e.log(c.LogLevelLabel.DEBUG,`The following packages are required: \nDependencies: \n${Object.entries(e.dependencies).map(([e,t])=>`- ${e}@${String(t)}`).join(`
9
+ `)}\n\nDevDependencies: \n${Object.entries(e.devDependencies).map(([e,t])=>`- ${e}@${String(t)}`).join(`
10
+ `)}`),await Promise.all([Promise.all(Object.entries(e.dependencies).map(async([t,n])=>Xe(e,`${(0,O.getPackageName)(t)}@${String(n)}`,!1))),Promise.all(Object.entries(e.devDependencies).map(async([t,n])=>Xe(e,`${(0,O.getPackageName)(t)}@${String(n)}`,!0)))])}function W(e,t,n){let r;if(n?r=G(e,t,n):(r=G(e,t,`tsconfig.app.json`),r||(r=G(e,t,`tsconfig.lib.json`),r||=G(e,t,`tsconfig.json`))),!r)throw Error(`Cannot find the \`tsconfig.json\` configuration file for the project at ${t}.`);return r}function G(e,t,n){let r=n;if(!(!(0,N.existsSync)(r)&&(r=(0,_.appendPath)(n,t),!(0,N.existsSync)(r)&&(r=(0,_.appendPath)(n,(0,_.appendPath)(t,e)),!(0,N.existsSync)(r)))))return r}function Qe(e,t,n=[`.ts`,`.tsx`,`.d.ts`]){return t.find(t=>e?.toString().toLowerCase()===t?.toString().toLowerCase()||e?.toString().toLowerCase()===`./${t?.toString().toLowerCase()}`||`./${e?.toString().toLowerCase()}`===t?.toString().toLowerCase()||n.some(n=>`${e?.toString().toLowerCase()}${n}`===t?.toString().toLowerCase()||`${e?.toString().toLowerCase()}${n}`==`./${t?.toString().toLowerCase()}`||`${t?.toString().toLowerCase()}${n}`==`./${e?.toString().toLowerCase()}`||e?.toString().toLowerCase()===`${t?.toString().toLowerCase()}${n}`||e?.toString().toLowerCase()===`./${t?.toString().toLowerCase()}${n}`||t?.toString().toLowerCase()===`./${e?.toString().toLowerCase()}${n}`))}function $e(e,t){return Qe(e,t,`.ts,.tsx,.d.ts,.js,.jsx,.mjs,.cjs,.mts,.cts,/*.ts,/*.tsx,/*.d.ts,/*.js,/*.jsx,/*.mjs,/*.cjs,/*.mts,/*.cts,/**/*.ts,/**/*.tsx,/**/*.d.ts,/**/*.js,/**/*.jsx,/**/*.mjs,/**/*.cjs,/**/*.mts,/**/*.cts`.split(`,`))}function et(e,t){return $e(e,t)!==void 0}function K(e,t,n,r={},i,a=E.default.sys){let o=W(e,t,n),s=(0,k.readJsonFileSync)(o);if(!s)throw Error(`Cannot find the \`tsconfig.json\` configuration file at ${(0,d.joinPaths)(t,n??`tsconfig.json`)}`);let c=E.default.parseJsonConfigFileContent((0,l.default)(r??{},s),a,(0,_.appendPath)(t,e));if(c.errors.length>0){let e=`Cannot parse the TypeScript compiler options. Please investigate the following issues:
11
+ ${c.errors.map(e=>`- ${(e.category!==void 0&&e.code?`[${e.category}-${e.code}]: `:``)+e.messageText.toString()}`).join(`
12
+ `)}
13
+ `;throw Error(e)}return{...c,originalTsconfigJson:i??s,tsconfigJson:s,tsconfigFilePath:o}}function tt(e){return(0,d.joinPaths)((0,j.relativePath)((0,d.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot),(0,j.findFilePath)(e.dtsPath)),(0,j.findFileName)(e.dtsPath))}async function nt(e){let t=K(e.workspaceConfig.workspaceRoot,e.config.projectRoot,e.config.tsconfig,e.config.tsconfigRaw),n=await(0,k.readJsonFile)(W(e.workspaceConfig.workspaceRoot,e.config.projectRoot,e.config.tsconfig));if(n.compilerOptions??={},e.config.output.dts!==!1){let t=tt(e);n.include?.some(n=>et(n,[e.dtsPath,t]))||(n.include??=[],n.include.push(t.startsWith(`./`)?t.slice(2):t))}return t.options.lib?.some(e=>[`lib.esnext.d.ts`,`lib.es2021.d.ts`,`lib.es2022.d.ts`,`lib.es2023.d.ts`].includes(e.toLowerCase()))||(n.compilerOptions.lib??=[],n.compilerOptions.lib.push(`esnext`)),t.options.esModuleInterop!==!0&&(n.compilerOptions.esModuleInterop=!0),t.options.isolatedModules!==!0&&(n.compilerOptions.isolatedModules=!0),e.config.build.platform===`node`&&(t.options.types?.some(e=>e.toLowerCase()===`node`||e.toLowerCase()===`@types/node`)||(n.compilerOptions.types??=[],n.compilerOptions.types.push(`node`))),n}async function rt(e){if(e.log(c.LogLevelLabel.TRACE,`Initializing TypeScript configuration (tsconfig.json) for the Powerlines project.`),!(0,h.isPackageExists)(`typescript`))throw Error(`The TypeScript package is not installed. Please install the package using the command: "npm install typescript --save-dev"`);let t=W(e.workspaceConfig.workspaceRoot,e.config.projectRoot,e.config.tsconfig);e.tsconfig.originalTsconfigJson=await(0,k.readJsonFile)(t),e.tsconfig.tsconfigJson=await nt(e),e.log(c.LogLevelLabel.TRACE,`Writing updated TypeScript configuration (tsconfig.json) file to disk.`),await e.fs.write(t,A.StormJSON.stringify(e.tsconfig.tsconfigJson)),e.tsconfig=K(e.workspaceConfig.workspaceRoot,e.config.projectRoot,e.config.tsconfig,e.config.tsconfigRaw,e.tsconfig.originalTsconfigJson)}async function it(e){let t=await(0,k.readJsonFile)(e.tsconfig.tsconfigFilePath);t?.compilerOptions?.types&&Array.isArray(t.compilerOptions.types)&&!t.compilerOptions.types.length&&delete t.compilerOptions.types;let n=(0,de.getObjectDiff)(e.tsconfig.originalTsconfigJson,t,{ignoreArrayOrder:!0,showOnly:{statuses:[`added`,`deleted`,`updated`],granularity:`deep`}}),r=[],i=(e,t)=>{if(e.status===`added`||e.status===`deleted`||e.status===`updated`)if(e.diff)for(let n of e.diff)i(n,t?`${t}.${e.property}`:e.property);else r.push({field:t?`${t}.${e.property}`:e.property,status:e.status,previous:e.status===`added`?`---`:A.StormJSON.stringify(e.previousValue),current:e.status===`deleted`?`---`:A.StormJSON.stringify(e.currentValue)})};for(let e of n.diff)i(e);if(r.length>0&&e.log(c.LogLevelLabel.WARN,`Updating the following configuration values in "${e.tsconfig.tsconfigFilePath}" file:
14
+
15
+ ${r.map((e,t)=>`${C.default.bold.whiteBright(`${t+1}. ${(0,M.titleCase)(e.status)} the ${e.field} field: `)}
16
+ ${C.default.red(` - Previous: ${e.previous} `)}
17
+ ${C.default.green(` - Updated: ${e.current} `)}
18
+ `).join(`
19
+ `)}
20
+ `),await e.fs.write(e.tsconfig.tsconfigFilePath,A.StormJSON.stringify(t)),e.tsconfig=K(e.workspaceConfig.workspaceRoot,e.config.projectRoot,e.config.tsconfig),!e.tsconfig)throw Error(`Failed to parse the TypeScript configuration file.`)}const at=`default`;function ot(e,t){return(0,l.default)(t.environments?.[e]??{},{name:e,title:t.title||(0,M.titleCase)(t.name),ssr:!1,mainFields:t.build?.platform===`browser`?[`browser`,`module`,`jsnext:main`,`jsnext`]:[`module`,`jsnext:main`,`jsnext`],extensions:[`.mjs`,`.js`,`.mts`,`.ts`,`.jsx`,`.tsx`,`.json`],consumer:t.build?.platform===`browser`?`client`:`server`,preview:t.build?.platform===`browser`?{port:5173,open:!0,strictPort:!1,host:`localhost`,allowedHosts:[`.`],cors:!0,headers:{}}:void 0},t)}function st(e){return ot(`default`,e)}async function ct(e,t){return(0,l.default)({workspaceRoot:e},await(0,fe.getWorkspaceConfig)(!0,{cwd:t,workspaceRoot:e,useDefault:!0}))}async function lt(e,t,n,r,i=`production`,a,o=`powerlines`){let s={},c;if(a&&(c=(0,N.existsSync)((0,v.replacePath)(a,e))?(0,v.replacePath)(a,e):(0,N.existsSync)((0,d.joinPaths)((0,_.appendPath)(e,t),(0,v.replacePath)(a,e)))?(0,d.joinPaths)((0,_.appendPath)(e,t),(0,v.replacePath)(a,e)):(0,N.existsSync)((0,d.joinPaths)((0,_.appendPath)(e,t),a))?(0,d.joinPaths)((0,_.appendPath)(e,t),a):void 0),c||=(0,N.existsSync)((0,d.joinPaths)((0,_.appendPath)(e,t),`${o}.${i}.config.ts`))?(0,d.joinPaths)((0,_.appendPath)(e,t),`${o}.${i}.config.ts`):(0,N.existsSync)((0,d.joinPaths)((0,_.appendPath)(e,t),`${o}.${i}.config.js`))?(0,d.joinPaths)((0,_.appendPath)(e,t),`${o}.${i}.config.js`):(0,N.existsSync)((0,d.joinPaths)((0,_.appendPath)(e,t),`${o}.${i}.config.mts`))?(0,d.joinPaths)((0,_.appendPath)(e,t),`${o}.${i}.config.mts`):(0,N.existsSync)((0,d.joinPaths)((0,_.appendPath)(e,t),`${o}.${i}.config.mjs`))?(0,d.joinPaths)((0,_.appendPath)(e,t),`${o}.${i}.config.mjs`):(0,N.existsSync)((0,d.joinPaths)((0,_.appendPath)(e,t),`${o}.config.ts`))?(0,d.joinPaths)((0,_.appendPath)(e,t),`${o}.config.ts`):(0,N.existsSync)((0,d.joinPaths)((0,_.appendPath)(e,t),`${o}.config.js`))?(0,d.joinPaths)((0,_.appendPath)(e,t),`${o}.config.js`):(0,N.existsSync)((0,d.joinPaths)((0,_.appendPath)(e,t),`${o}.config.mts`))?(0,d.joinPaths)((0,_.appendPath)(e,t),`${o}.config.mts`):(0,N.existsSync)((0,d.joinPaths)((0,_.appendPath)(e,t),`${o}.config.mjs`))?(0,d.joinPaths)((0,_.appendPath)(e,t),`${o}.config.mjs`):void 0,c){let e=await n.import(n.esmResolve(c));if(e){let t={};(0,y.isFunction)(e)&&(t=await Promise.resolve(e({command:r,mode:i,isSsrBuild:!1,isPreview:!1}))),(0,x.isSetObject)(t)&&(s={...t,config:t,configFile:c})}}let u=await(0,pe.loadConfig)({cwd:e,name:o,envName:i,globalRc:!0,packageJson:!0,dotenv:!0,jiti:n});return(0,l.default)(s,(0,x.isSetObject)(u?.config)?{...u.config,...u}:{})}function ut(e){return(0,l.default)(e,{interopDefault:!0,fsCache:e.mode===`development`?!1:(0,d.joinPaths)(e.cacheDir,`jiti`),moduleCache:e.mode!==`development`})}function dt(e){return(0,xe.createJiti)((0,d.joinPaths)(e.workspaceRoot,e.projectRoot),ut({...e}))}function ft(e){let t=(0,xe.createJiti)((0,d.joinPaths)(e.workspaceRoot,e.projectRoot),ut(e));return t.plugin=dt(e),t}const pt=[`new`,`clean`,`prepare`,`lint`,`test`,`build`,`docs`,`deploy`,`finalize`];function q(e){return(0,x.isSetObject)(e)&&`name`in e&&(0,S.isSetString)(e.name)&&((0,B.isUndefined)(e.applyToEnvironment)||`applyToEnvironment`in e&&(0,y.isFunction)(e.applyToEnvironment))&&((0,B.isUndefined)(e.dedupe)||`dedupe`in e&&(0,y.isFunction)(e.dedupe))&&((0,B.isUndefined)(e.dependsOn)||`dependsOn`in e&&Array.isArray(e.dependsOn)&&e.dependsOn.every(gt))&&pt.every(t=>(0,B.isUndefined)(e[t])||t in e&&((0,y.isFunction)(e[t])||(0,x.isSetObject)(e[t])&&`handler`in e[t]&&(0,y.isFunction)(e[t].handler)))}function mt(e){return(0,x.isSetObject)(e)&&`plugin`in e&&(((0,S.isSetString)(e.plugin)||(0,y.isFunction)(e.plugin))&&`options`in e&&(0,x.isSetObject)(e.options)||q(e.plugin))}function ht(e){return Array.isArray(e)&&(e.length===1||e.length===2)&&(((0,S.isSetString)(e[0])||(0,y.isFunction)(e[0]))&&e.length>1&&(0,x.isSetObject)(e[1])||q(e[0]))}function gt(e){return(0,S.isSetString)(e)||(0,y.isFunction)(e)||q(e)||mt(e)||ht(e)}function _t(e){return(0,y.isFunction)(e)||(0,x.isSetObject)(e)&&`handler`in e&&(0,y.isFunction)(e.handler)}function vt(e){return(0,x.isSetObject)(e)&&`handler`in e&&(0,y.isFunction)(e.handler)}function yt(e){return _t(e)||vt(e)}function bt(e){return(0,y.isFunction)(e)?e:e.handler}function xt(e){return e.startsWith(`vite:`)||e.startsWith(`esbuild:`)||e.startsWith(`rolldown:`)||e.startsWith(`rollup:`)||e.startsWith(`webpack:`)||e.startsWith(`rspack:`)||e.startsWith(`farm:`)}function J(e,t){return e.dedupe===!1||t.some(t=>t.dedupe!==!1&&((0,y.isFunction)(t.dedupe)&&t.dedupe(e)||t.name===e.name))}function St(e,t,n,r){J(t,r.map(e=>e.plugin))||r.push((0,y.isFunction)(n)?{plugin:t,handler:bt(n).bind(e)}:{plugin:t,...n,handler:bt(n).bind(e)})}function Y(e,t){return t&&t.replaceAll(`{workspaceRoot}`,e.workspaceConfig.workspaceRoot).replaceAll(`{root}`,e.config.projectRoot).replaceAll(`{projectRoot}`,e.config.projectRoot).replaceAll(`{sourceRoot}`,e.config.sourceRoot).replaceAll(`{powerlinesPath}`,e.powerlinesPath).replaceAll(`{cachePath}`,e.cachePath).replaceAll(`{dataPath}`,e.dataPath).replaceAll(`{logPath}`,e.envPaths.log).replaceAll(`{tempPath}`,e.envPaths.temp).replaceAll(`{configPath}`,e.envPaths.config).replaceAll(`{outputPath}`,e.config.output.outputPath).replaceAll(`{buildPath}`,e.config.output.buildPath).replaceAll(`{artifactsPath}`,(0,v.replacePath)(e.artifactsPath,e.workspaceConfig.workspaceRoot)).replaceAll(`{builtinPath}`,(0,v.replacePath)(e.builtinsPath,e.workspaceConfig.workspaceRoot)).replaceAll(`{entryPath}`,(0,v.replacePath)(e.entryPath,e.workspaceConfig.workspaceRoot))}function Ct(e,t){return(0,v.replacePath)(t.file,(0,d.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot))}function wt(e,t){return{file:Ct(e,t),name:t.name}}function Tt(e,t){return(0,v.replaceExtension)((0,v.replacePath)((0,v.replacePath)((0,v.replacePath)((0,v.replacePath)((0,v.replacePath)(t.file,(0,d.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.sourceRoot)),(0,d.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot)),e.config.sourceRoot),e.config.projectRoot),(0,v.replacePath)(e.config.sourceRoot,e.config.projectRoot)))}function Et(e,t){let n=wt(e,t);return{...n,input:n,output:Tt(e,t)}}function Dt(e,t){return t.map(t=>(0,D.isString)(t)?Y(e,t):Y(e,t.file)).map(t=>{let n=(0,Se.parseTypeDefinition)(t),r=(0,_.appendPath)(n.file,e.config.projectRoot);return(0,Ce.isFile)(r)?Et(e,{file:(0,v.replacePath)(r,e.config.projectRoot),name:n.name}):(0,m.listFilesSync)(r).map(t=>Et(e,{file:t,name:n.name}))}).flat().filter(Boolean)}function Ot(e=[]){return(0,F.getUniqueBy)((0,f.toArray)(e),e=>(0,S.isSetString)(e)?e:(0,P.murmurhash)(e??{},{maxLength:24}))}var kt=class extends V.Struct{static _capnp={displayName:`KeyValuePair`,id:`eabb26cf58b2a14c`,size:new V.ObjectSize(0,2)};get key(){return V.utils.getText(0,this)}set key(e){V.utils.setText(0,e,this)}get value(){return V.utils.getText(1,this)}set value(e){V.utils.setText(1,e,this)}toString(){return`FileMetadata_KeyValuePair_`+super.toString()}},At=class e extends V.Struct{static KeyValuePair=kt;static _capnp={displayName:`FileMetadata`,id:`8e2cab5d7e28c7b3`,size:new V.ObjectSize(8,3),defaultType:`normal`};static _Properties;get id(){return V.utils.getText(0,this)}set id(e){V.utils.setText(0,e,this)}get type(){return V.utils.getText(1,this,e._capnp.defaultType)}set type(e){V.utils.setText(1,e,this)}get timestamp(){return V.utils.getUint32(0,this)}set timestamp(e){V.utils.setUint32(0,e,this)}_adoptProperties(e){V.utils.adopt(e,V.utils.getPointer(2,this))}_disownProperties(){return V.utils.disown(this.properties)}get properties(){return V.utils.getList(2,e._Properties,this)}_hasProperties(){return!V.utils.isNull(V.utils.getPointer(2,this))}_initProperties(t){return V.utils.initList(2,e._Properties,t,this)}set properties(e){V.utils.copyFrom(e,V.utils.getPointer(2,this))}toString(){return`FileMetadata_`+super.toString()}},jt=class extends V.Struct{static _capnp={displayName:`FileId`,id:`990d6a471072f997`,size:new V.ObjectSize(0,2)};get id(){return V.utils.getText(0,this)}set id(e){V.utils.setText(0,e,this)}get path(){return V.utils.getText(1,this)}set path(e){V.utils.setText(1,e,this)}toString(){return`FileId_`+super.toString()}},Mt=class extends V.Struct{static _capnp={displayName:`FileStorage`,id:`9dca66ac858c9ebe`,size:new V.ObjectSize(0,2)};get path(){return V.utils.getText(0,this)}set path(e){V.utils.setText(0,e,this)}get code(){return V.utils.getText(1,this)}set code(e){V.utils.setText(1,e,this)}toString(){return`FileStorage_`+super.toString()}},X=class e extends V.Struct{static _capnp={displayName:`FileSystem`,id:`ae0c23d43e56abcf`,size:new V.ObjectSize(0,3)};static _Ids;static _Storage;static _Metadata;_adoptIds(e){V.utils.adopt(e,V.utils.getPointer(0,this))}_disownIds(){return V.utils.disown(this.ids)}get ids(){return V.utils.getList(0,e._Ids,this)}_hasIds(){return!V.utils.isNull(V.utils.getPointer(0,this))}_initIds(t){return V.utils.initList(0,e._Ids,t,this)}set ids(e){V.utils.copyFrom(e,V.utils.getPointer(0,this))}_adoptStorage(e){V.utils.adopt(e,V.utils.getPointer(1,this))}_disownStorage(){return V.utils.disown(this.storage)}get storage(){return V.utils.getList(1,e._Storage,this)}_hasStorage(){return!V.utils.isNull(V.utils.getPointer(1,this))}_initStorage(t){return V.utils.initList(1,e._Storage,t,this)}set storage(e){V.utils.copyFrom(e,V.utils.getPointer(1,this))}_adoptMetadata(e){V.utils.adopt(e,V.utils.getPointer(2,this))}_disownMetadata(){return V.utils.disown(this.metadata)}get metadata(){return V.utils.getList(2,e._Metadata,this)}_hasMetadata(){return!V.utils.isNull(V.utils.getPointer(2,this))}_initMetadata(t){return V.utils.initList(2,e._Metadata,t,this)}set metadata(e){V.utils.copyFrom(e,V.utils.getPointer(2,this))}toString(){return`FileSystem_`+super.toString()}};At._Properties=V.CompositeList(kt),X._Ids=V.CompositeList(jt),X._Storage=V.CompositeList(Mt),X._Metadata=V.CompositeList(At);const Nt=(e,t={})=>{let n=t.logLevel===null?c.LogLevelLabel.SILENT:t.logLevel||c.LogLevelLabel.INFO;return n===c.LogLevelLabel.SILENT?Ae.noop:t.customLogger?t.customLogger:(r,...i)=>(0,Oe.getLogFn)((0,Oe.getLogLevel)(r),{...t,logLevel:n})(`${C.default.bold.hex((0,ke.getColor)(`brand`,t))(`powerlines${e?`:${e}`:``}${t.name?` ${C.default.gray(`> `)}${t.name}`:``} ${C.default.gray(`> `)}`)}${i.join(` `)} `.trim())},Pt=[`#00A0DD`,`#6FCE4E`,`#FBBF24`,`#F43F5E`,`#3B82F6`,`#A855F7`,`#469592`,`#288EDF`,`#10B981`,`#EF4444`,`#F0EC56`,`#F472B6`,`#22D3EE`,`#EAB308`,`#84CC16`,`#F87171`,`#0EA5E9`,`#D946EF`,`#FACC15`,`#34D399`],Ft=(e,t)=>(n,...r)=>e(n,` ${C.default.inverse.hex(Pt[t.split(``).map(e=>e.charCodeAt(0)).reduce((e,t)=>e+t,0)%Pt.length]||Pt[0])(` ${(0,M.titleCase)(t)} `)} ${r.join(` `)} `);function It(e){return(0,ae.isError)(e)&&`code`in e&&e.code}function Z(e){return It(e)&&(e.code===`ENOENT`||e.code===`EISDIR`?null:e)}function Q(e){return(0,je.correctPath)((0,Me.slash)(e?.toString()||`.`).replace(/^file:\/\//,``))}function Lt(e,t=`powerlines`){return e.replace(/^\\0/,``).startsWith(`${t.replace(/:$/,``)}`)}function Rt(e,t=`powerlines`){return`${t.replace(/:$/,``)}:${Q(e).replace(RegExp(`^${t.replace(/:$/,``)}:`),``).replace(/^\\0/,``).replace((0,j.findFileDotExtensionSafe)(Q(e)),``)}`}function zt(e,t,n=`powerlines`){return(0,I.isAbsolutePath)(e)?e:Lt(Q(e),n)?Rt(Q(e),n).replace(RegExp(`^${n.replace(/:$/,``)}:`),t):Q(e)}function Bt(e,t){return(0,F.getUnique)((0,f.toArray)(t).map(t=>(0,x.isSetObject)(t)&&((0,S.isSetString)(t.input)||(0,S.isSetString)(t.glob))?(0,L.joinPaths)(t.input||e,t.glob||`**/*`):(0,S.isSetString)(t)?t:void 0).filter(S.isSetString))}var Vt=class{#e=!1;options;constructor(e={base:`/`}){this.options=e,this.options.base=(0,Le.resolve)(e.base),this.options.isReadOnly=!!e.isReadOnly}async exists(e){return this.existsSync(e)}async get(e){return this.getSync(e)}async set(e,t){this.options.isReadOnly||this.setSync(e,t)}mkdirSync(e){}async mkdir(e){return Promise.resolve(this.mkdirSync(e))}async remove(e){this.options.isReadOnly||this.removeSync(e)}clearSync(e){if(!this.options.isReadOnly){let t=this.listSync(e||this.options.base);if(!t.length)return;t.map(t=>this.removeSync(e&&!t.startsWith(e)?(0,L.joinPaths)(e,t):t))}}async clear(e){if(!this.options.isReadOnly){let t=await this.list(e||this.options.base);if(!t.length)return;await Promise.all(t.map(async t=>this.remove(e&&!t.startsWith(e)?(0,L.joinPaths)(e,t):t)))}}async list(e){return this.listSync(e)}isDirectorySync(e){return!1}async isDirectory(e){return Promise.resolve(this.isDirectorySync(e))}isFileSync(e){return this.existsSync(e)&&!this.isDirectorySync(e)}async isFile(e){return Promise.resolve(this.isFileSync(e))}dispose(){return Promise.resolve()}async[Symbol.asyncDispose](){return this._dispose()}resolve(e=this.options.base){if(/\.\.:|\.\.$/.test(e))throw Error(`[${this.name}]: Invalid key: ${JSON.stringify(e)} provided to storage adapter.`);return(0,_.appendPath)((0,je.correctPath)(e).replace(/:/g,`/`),this.options.base)}async _dispose(){this.#e||=(await Promise.resolve(this.dispose()),!0)}},Ht=class extends Vt{name=`file-system`;constructor(e){super(e)}existsSync(e){return(0,N.existsSync)(this.resolve(e))}async exists(e){return(0,N.exists)(this.resolve(e))}getSync(e){return(0,Ne.readFileSync)(this.resolve(e))}async get(e){return(0,Ne.readFile)(this.resolve(e))}setSync(e,t){if(!this.options.isReadOnly)return(0,Pe.writeFileSync)(this.resolve(e),t)}async set(e,t){if(!this.options.isReadOnly)return(0,Pe.writeFile)(this.resolve(e),t)}removeSync(e){if(!this.options.isReadOnly)try{return(0,Fe.unlinkSync)(this.resolve(e))}catch(e){return Z(e)}}async remove(e){if(!this.options.isReadOnly)return(0,Ie.unlink)(this.resolve(e)).catch(Z)}mkdirSync(e){(0,p.createDirectorySync)(this.resolve(e))}async mkdir(e){await(0,p.createDirectory)(this.resolve(e))}listSync(e){try{return(0,m.listFilesSync)(this.resolve(e),{ignore:this.options.ignore})}catch(e){return Z(e)??[]}}async list(e){return(0,m.listFiles)(this.resolve(e),{ignore:this.options.ignore}).catch(Z).then(e=>e||[])}isDirectorySync(e){return(0,Ce.isDirectory)(this.resolve(e))}isFileSync(e){return!(0,Ce.isFile)(this.resolve(e))}},$=class extends Vt{name=`virtual`;data=new Map;constructor(e){super(e)}existsSync(e){return this.data.has(this.resolve(e))}getSync(e){return this.data.get(this.resolve(e))??null}setSync(e,t){this.options.isReadOnly||this.data.set(this.resolve(e),t)}removeSync(e){this.options.isReadOnly||this.data.delete(this.resolve(e))}listSync(e){return[...this.data.keys().filter(t=>e?(0,H.isParentPath)(t,this.resolve(e)):!0)]}async dispose(){return this.clear()}},Ut=class e{#e;#t;#n;#r={"":new Ht};#i;#a=!1;#o;#s;#c(e){let t=e;return(0,H.isParentPath)(t,this.#o.builtinsPath)&&(t=(0,v.replacePath)(t,this.#o.builtinsPath)),Rt(t,this.#o.config.output.builtinPrefix)}#l(e){return zt(e.includes(`{`)||e.includes(`}`)?Y(this.#o,e):e,this.#o.builtinsPath,this.#o.config.output.builtinPrefix)}#u(e){let t=`::GLOBSTAR::`;return RegExp(`^${this.#l(e).replace(/\*\*/g,t).replace(/[.+^${}()|[\]\\]/g,`\\$&`).replace(/\*/g,`[^/]*`).replace(/\?/g,`[^/]`).replace(new RegExp(t,`g`),`.*`)}$`)}#d(e){let t=this.resolveSync(this.#l(e))||e;for(let e of Object.keys(this.#r).filter(Boolean).sort().reverse())if((0,H.isParentPath)(t,e))return{base:e,relativeKey:(0,v.replacePath)(t,e),adapter:this.#r[e]};return{base:``,relativeKey:t,adapter:this.#r[``]}}#f(e=``,t=!1){return Object.keys(this.#r).sort().reverse().filter(n=>(0,H.isParentPath)(n,e)||t&&(0,H.isParentPath)(e,n)).map(t=>({relativeBase:e.length>t.length?e.slice(t.length):void 0,base:t,adapter:this.#r[t]}))}static async create(t){if(!t.config.skipCache&&(0,N.existsSync)((0,d.joinPaths)(t.dataPath,`fs.bin`))){let n=await(0,we.readFileBuffer)((0,d.joinPaths)(t.dataPath,`fs.bin`)),r=new V.Message(n,!1).getRoot(X),i=new e(t,r);r._hasStorage()&&r.storage.length>0&&await Promise.all(r.storage.values().map(async e=>{await i.write(e.path,e.code)}))}return new e(t,new V.Message().initRoot(X))}static createSync(t){if(!t.config.skipCache&&(0,N.existsSync)((0,d.joinPaths)(t.dataPath,`fs.bin`))){let n=(0,we.readFileBufferSync)((0,d.joinPaths)(t.dataPath,`fs.bin`)),r=new V.Message(n,!1).getRoot(X),i=new e(t,r);r._hasStorage()&&r.storage.length>0&&r.storage.values().map(e=>{i.writeSync(e.path,e.code)})}return new e(t,new V.Message().initRoot(X))}get metadata(){return new Proxy(this.#e,{get:(e,t)=>e[this.#c(t)]})}get ids(){return new Proxy(this.#n,{get:(e,t)=>e[this.#l(t)]})}get paths(){return new Proxy(this.#n,{get:(e,t)=>e[this.#c(t)]})}get resolverCache(){return this.#i||=(0,ye.create)({cacheId:`module-resolution`,cacheDir:this.#o.cachePath,ttl:3600*1e3,lruSize:5e3,persistInterval:100}),this.#i}constructor(e,t){this.#o=e,(0,x.isSetObject)(this.#o.config.output.storage)&&(this.#r={...this.#r,...this.#o.config.output.storage}),this.#r.virtual??=new $({base:`/_virtual`}),this.#o.config.output.storage!==`fs`&&(this.#r[this.#o.artifactsPath]??=new $({base:this.#o.artifactsPath}),this.#r[this.#o.builtinsPath]??=new $({base:this.#o.builtinsPath}),this.#r[this.#o.entryPath]??=new $({base:this.#o.entryPath})),this.#e={},t._hasMetadata()&&(this.#e=t.metadata.values().reduce((e,t)=>(e[t.id]={id:t.id,type:t.type,timestamp:t.timestamp||Date.now(),properties:t._hasProperties()?t.properties.values().reduce((e,t)=>(e[t.key]=t.value,e),{}):{}},e),{})),this.#t={},this.#n={},t._hasIds()&&(this.#t=t.ids.values().reduce((e,t)=>(e[t.path]??=t.id,e),{}),this.#n=t.ids.values().reduce((e,t)=>(e[t.id]??=t.path,e),{})),this.#s=Ft(this.#o.log,`file-system`)}async exists(e){let{relativeKey:t,adapter:n}=this.#d(e);return n.exists(t)}existsSync(e){let{relativeKey:t,adapter:n}=this.#d(e);return n.existsSync(t)}isVirtual(e){let t=this.resolveSync(e);return t?this.#d(t)?.adapter?.name===`virtual`:!1}isDirectorySync(e){let t=this.resolveSync(e);return t?!!(this.existsSync(t)&&this.#d(t)?.adapter?.isDirectorySync(t)):!1}async isDirectory(e){let t=await this.resolve(e);return t?!!(await this.exists(t)&&await this.#d(t)?.adapter?.isDirectory(t)):!1}isFileSync(e){let t=this.resolveSync(e);return t?this.#d(t)?.adapter?.isFileSync(t)??!1:!1}async isFile(e){let t=await this.resolve(e);return t?await this.#d(t)?.adapter?.isFile(t)??!1:!1}listSync(e){return(0,F.getUnique)(this.#f(e,!0).map(e=>e.adapter.listSync(e.relativeBase?e.base?(0,_.appendPath)(e.relativeBase,e.base):e.relativeBase:e.base)).flat())}async list(e){return(0,F.getUnique)((await Promise.all(this.#f(e,!0).map(async e=>e.adapter.list(e.relativeBase?e.base?(0,_.appendPath)(e.relativeBase,e.base):e.relativeBase:e.base)))).flat())}async remove(e){let t=this.#l(e);this.#s(c.LogLevelLabel.TRACE,`Removing file: ${t}`);let{relativeKey:n,adapter:r}=this.#d(t);(0,j.hasFileExtension)(t)?await r.remove(n):await r.clear(n);let i=this.#t[t];i&&this.#e[i]&&(delete this.#e[i],delete this.#t[t],delete this.#n[i])}removeSync(e){let t=this.#l(e);this.#s(c.LogLevelLabel.TRACE,`Removing file: ${t}`);let{relativeKey:n,adapter:r}=this.#d(t);(0,j.hasFileExtension)(t)?r.removeSync(n):r.clearSync(n);let i=this.#t[t];i&&this.#e[i]&&(delete this.#e[i],delete this.#t[t],delete this.#n[i])}async glob(e){let t=[];for(let n of Bt(this.#o.workspaceConfig.workspaceRoot,e)){let e=this.#l(n);if(!/[*?[\]{}]/.test(e)&&!e.includes(`**`)){if(this.isDirectorySync(e))t.push(...await this.list(e));else{let n=await this.resolve(e);n&&!t.includes(n)&&t.push(n)}continue}let r=(0,I.isAbsolutePath)(e)?e:this.#l((0,d.joinPaths)(this.#o.workspaceConfig.workspaceRoot,e)),i=r.search(/[*?[\]{}]/),a=i===-1?(0,j.findFilePath)(r):r.slice(0,Math.max(0,r.lastIndexOf(`/`,i)));await Promise.all((await this.list(a&&(0,I.isAbsolutePath)(a)?a:this.#o.workspaceConfig.workspaceRoot)).map(async e=>{if(this.#u(r).test(e)){let n=this.resolveSync(e);n&&!t.includes(n)&&t.push(n)}}))}return t}globSync(e){let t=[];for(let n of Bt(this.#o.workspaceConfig.workspaceRoot,e)){let e=this.#l(n);if(!/[*?[\]{}]/.test(e)&&!e.includes(`**`)){if(this.isDirectorySync(e))t.push(...this.listSync(e));else{let n=this.resolveSync(e);n&&!t.includes(n)&&t.push(n)}continue}let r=(0,I.isAbsolutePath)(e)?e:this.#l((0,d.joinPaths)(this.#o.workspaceConfig.workspaceRoot,e)),i=r.search(/[*?[\]{}]/),a=i===-1?(0,j.findFilePath)(r):r.slice(0,Math.max(0,r.lastIndexOf(`/`,i))),o=this.listSync(a&&(0,I.isAbsolutePath)(a)?a:this.#o.workspaceConfig.workspaceRoot);for(let e of o)if(this.#u(r).test(e)){let n=this.resolveSync(e);n&&!t.includes(n)&&t.push(n)}}return t}async copy(e,t){let n=e instanceof URL?(0,U.fileURLToPath)(e):e,r=t instanceof URL?(0,U.fileURLToPath)(t):t;if(!(0,S.isSetString)(n)&&(!(0,x.isSetObject)(n)||!(0,S.isSetString)(n.input))||!(0,S.isSetString)(r))return;let i=(0,D.isString)(n)?n:n.input?n.input:this.#o.workspaceConfig.workspaceRoot,a=await this.resolve(i);if(a)if(this.isDirectorySync(a)||(0,S.isSetString)(n)&&n.includes(`*`)||(0,x.isSetObject)(n)&&(0,S.isSetString)(n.glob))await Promise.all((await this.glob(n)).map(async e=>this.copy(e,(0,_.appendPath)((0,v.replacePath)(e,i),r))));else{let e=await this.read(a);e!==void 0&&await this.write(this.#l(r),e,{skipFormat:!0})}}copySync(e,t){let n=e instanceof URL?(0,U.fileURLToPath)(e):e,r=t instanceof URL?(0,U.fileURLToPath)(t):t;if(!(0,S.isSetString)(n)&&(!(0,x.isSetObject)(n)||!(0,S.isSetString)(n.input))||!(0,S.isSetString)(r))return;let i=(0,D.isString)(n)?n:n.input?n.input:this.#o.workspaceConfig.workspaceRoot,a=this.resolveSync(i);if(a)if(this.isDirectorySync(a)||(0,S.isSetString)(n)&&n.includes(`*`)||(0,x.isSetObject)(n)&&(0,S.isSetString)(n.glob))this.globSync(n).map(e=>this.copySync(e,(0,_.appendPath)((0,j.findFilePath)((0,v.replacePath)(e,i)),r)));else{let e=this.readSync(a);e!==void 0&&this.writeSync(this.#l((0,j.hasFileExtension)(r)?r:(0,_.appendPath)((0,j.findFileName)(a),r)),e,{skipFormat:!0})}}async move(e,t){(0,j.hasFileExtension)(e)?(await this.copy(e,t),await this.remove(e)):await Promise.all((await this.list(e)).map(async e=>{await this.copy(e,t),await this.remove(e)}))}moveSync(e,t){(0,j.hasFileExtension)(e)?(this.copySync(e,t),this.removeSync(e)):this.listSync(e).forEach(e=>{this.copySync(e,t),this.removeSync(e)})}async read(e){let t=await this.resolve(e);if(!t)return;let{relativeKey:n,adapter:r}=this.#d(t);return this.#s(c.LogLevelLabel.TRACE,`Reading ${r.name} file: ${t}`),await r.get(n)??void 0}readSync(e){let t=this.resolveSync(e);if(!t)return;let{relativeKey:n,adapter:r}=this.#d(t);return this.#s(c.LogLevelLabel.TRACE,`Reading ${r.name} file: ${t}`),r.getSync(n)??void 0}async write(e,t=``,n={}){let r=t;if(!n.skipFormat){let n=await(0,De.resolveConfig)(this.#l(e));n&&(r=await(0,De.format)(t,{absolutePath:this.#l(e),...n}))}let{relativeKey:i,adapter:a}=this.#d(e);this.#s(c.LogLevelLabel.TRACE,`Writing ${this.#l(i)} to ${a.name===`virtual`?`the virtual file system`:a.name===`file-system`?`the local file system`:a.name} (size: ${(0,Te.prettyBytes)(new Ee.Blob((0,f.toArray)(r)).size)})`);let o=n?.meta?.id||this.#c(i);return this.#e[o]={variant:`normal`,timestamp:Date.now(),...n.meta??{}},this.#n[o]=this.#l(i),this.#t[this.#l(i)]=o,a.set(i,r)}writeSync(e,t=``,n={}){let{relativeKey:r,adapter:i}=this.#d(e);this.#s(c.LogLevelLabel.TRACE,`Writing ${this.#l(r)} file to ${i.name===`virtual`?`the virtual file system`:i.name===`file-system`?`the local file system`:i.name} (size: ${(0,Te.prettyBytes)(new Ee.Blob((0,f.toArray)(t)).size)})`);let a=n?.meta?.id||this.#c(r);return this.#e[a]={variant:`normal`,timestamp:Date.now(),...n.meta??{}},this.#n[a]=this.#l(r),this.#t[this.#l(r)]=a,i.setSync(r,t)}mkdirSync(e){return this.#d(e)?.adapter?.mkdirSync(e)}async mkdir(e){return this.#d(e)?.adapter?.mkdir(e)}getMetadata(e){let t=this.resolveSync(e);if(t&&this.metadata[t])return this.metadata[t]}async resolve(e,t,n={}){let r=e;if((r.includes(`{`)||r.includes(`}`))&&(r=Y(this.#o,r)),(0,I.isAbsolutePath)(r))return r;let i=(0,P.murmurhash)({path:this.#c(r),importer:t,options:n}),a;if(!this.#o.config.skipCache&&(a=this.resolverCache.get(i),a))return a;if(a=this.paths[this.#c(r)],!a){let e=n.paths??[];t&&!e.includes(t)&&e.push(t),e.push(this.#o.workspaceConfig.workspaceRoot),e.push((0,_.appendPath)(this.#o.config.projectRoot,this.#o.workspaceConfig.workspaceRoot)),e.push((0,_.appendPath)(this.#o.config.sourceRoot,this.#o.workspaceConfig.workspaceRoot)),e.push(...Object.keys(this.#o.tsconfig?.options?.paths??{}).filter(e=>r.startsWith(e.replace(/\*$/,``))).map(e=>this.#o.tsconfig?.options?.paths?.[e]).flat().filter(Boolean).map(e=>(0,_.appendPath)(e,this.#o.workspaceConfig.workspaceRoot)));for(let t of(0,g.getResolutionCombinations)(r,{paths:e})){let{relativeKey:e,adapter:n}=this.#d(t);if(await n.exists(e)){a=t;break}}if(!a)try{a=await(0,g.resolve)(r,{...n,paths:e})}catch{}}return a&&!this.#o.config.skipCache&&this.resolverCache.set(i,a),a}resolveSync(e,t,n={}){let r=e;if((r.includes(`{`)||r.includes(`}`))&&(r=Y(this.#o,r)),(0,I.isAbsolutePath)(r))return r;let i;if(!this.#o.config.skipCache&&(i=this.resolverCache.get(this.#c(r)),i))return i;if(i=this.paths[this.#c(r)],!i){let e=n.paths??[];t&&!e.includes(t)&&e.push(t),e.push(this.#o.workspaceConfig.workspaceRoot),e.push((0,_.appendPath)(this.#o.config.projectRoot,this.#o.workspaceConfig.workspaceRoot)),e.push((0,_.appendPath)(this.#o.config.sourceRoot,this.#o.workspaceConfig.workspaceRoot)),e.push(...Object.keys(this.#o.tsconfig?.options?.paths??{}).filter(e=>r.startsWith(e.replace(/\*$/,``))).map(e=>this.#o.tsconfig?.options?.paths?.[e]).flat().filter(Boolean).map(e=>(0,_.appendPath)(e,this.#o.workspaceConfig.workspaceRoot)));for(let t of(0,g.getResolutionCombinations)(r,{paths:e})){let{relativeKey:e,adapter:n}=this.#d(t);if(n.existsSync(e)){i=t;break}}if(!i)try{i=(0,g.resolveSync)(r,{...n,paths:e})}catch{}}return i&&!this.#o.config.skipCache&&this.resolverCache.set(this.#c(r),i),i}async dispose(){if(!this.#a){this.#a=!0,this.#s(c.LogLevelLabel.DEBUG,`Disposing virtual file system...`),await this.remove((0,d.joinPaths)(this.#o.dataPath,`fs.bin`));let e=new V.Message,t=e.initRoot(X),n=await this.list(),r=t._initStorage(n.length);await Promise.all(n.map(async(e,t)=>{let n=await this.read(e),i=r.get(t);i.path=e,i.code=n||``}));let i=t._initIds(Object.keys(this.ids).length);Object.entries(this.ids).filter(([,e])=>e).forEach(([e,t],n)=>{let r=i.get(n);r.id=e,r.path=t});let a=t._initMetadata(Object.keys(this.metadata).length);Object.entries(this.metadata).filter(([,e])=>e).forEach(([e,t],n)=>{let r=a.get(n);if(r.id=e,r.type=t.type,r.timestamp=t.timestamp??BigInt(Date.now()),t.properties){let e=r._initProperties(Object.keys(t.properties).length);Object.entries(t.properties).forEach(([t,n],r)=>{let i=e.get(r);i.key=t,i.value=n})}}),await(0,we.writeFileBuffer)((0,d.joinPaths)(this.#o.dataPath,`fs.bin`),e.toArrayBuffer()),this.#o.config.skipCache||this.#i.save(!0),await Promise.all(this.#f().map(async e=>e.adapter.dispose())),this.#s(c.LogLevelLabel.TRACE,`Virtual file system has been disposed.`)}}async[Symbol.asyncDispose](){return this.dispose()}};const Wt=45,Gt=62;function Kt(e,t){let n=`${(0,Re.kebabCase)(e)}_${t}`;return n.length>45?n.slice(0,45):n}async function qt(e){let t=(0,d.joinPaths)(e.dataPath,`meta.json`);e.log(c.LogLevelLabel.DEBUG,`Writing runtime metadata to ${t}`),await e.fs.write(t,JSON.stringify(e.meta,null,2))}const Jt=new WeakMap;(0,z.setGlobalDispatcher)(new z.Agent({keepAliveTimeout:1e4}).compose(z.interceptors.retry({maxRetries:3,minTimeout:1e3,maxTimeout:1e4,timeoutFactor:2,retryAfter:!0})));var Yt=class e{#e={};#t;#n=null;#r=(0,ve.uuid)();#i=(0,ve.uuid)();#a=Date.now();#o;#s;#c;#l;#u;#d;#f(e={}){return{variant:e.build?.variant,projectType:e.type,projectRoot:e.root,name:e.name,title:e.title,description:e.description,sourceRoot:e.sourceRoot,configFile:e.configFile,customLogger:e.customLogger,logLevel:e.logLevel,tsconfig:e.tsconfig,tsconfigRaw:e.tsconfigRaw,skipCache:e.skipCache,skipInstalls:e.skipInstalls,entry:e.entry,output:e.output,plugins:e.plugins,mode:e.mode,lint:e.lint,transform:e.transform,build:e.build,framework:e.framework,...e}}static async from(t,n){let r=new e(await ct(t,n.root));if(await r.withUserConfig(n),r.powerlinesPath=await(0,g.resolvePackage)(`powerlines`),!r.powerlinesPath)throw Error("Could not resolve `powerlines` package location.");return r}dependencies={};devDependencies={};persistedMeta=void 0;powerlinesPath;packageJson;projectJson=void 0;resolver;resolvePatterns=[];get $$internal(){return this.#e}set $$internal(e){this.#e=e}get entry(){return Dt(this,(0,f.toArray)(this.config.entry))}get tsconfig(){return this.#c||(this.tsconfig={tsconfigFilePath:this.config.tsconfig}),this.#c}set tsconfig(e){this.#c=e,this.resolvePatterns=(0,R.tsconfigPathsToRegExp)(e?.options?.paths??{})}get fs(){return this.#s||=Ut.createSync(this),this.#s}get checksum(){return this.#n}get meta(){return{buildId:this.#r,releaseId:this.#i,checksum:this.#n,timestamp:this.#a,projectRootHash:(0,P.murmurhash)({workspaceRoot:this.workspaceConfig?.workspaceRoot,projectRoot:this.config?.projectRoot},{maxLength:45}),configHash:(0,P.murmurhash)(this.config,{maxLength:62})}}get config(){return this.resolvedConfig??{}}get log(){return this.logFn||=this.createLog(),this.logFn}get workspaceConfig(){return this.#t}get envPaths(){return this.#o||=(0,me.getEnvPaths)({orgId:`storm-software`,appId:`powerlines`,workspaceRoot:this.workspaceConfig.workspaceRoot}),this.#o}get artifactsPath(){return(0,L.joinPaths)(this.workspaceConfig.workspaceRoot,this.config.projectRoot,this.config.output.artifactsPath)}get builtinsPath(){return(0,L.joinPaths)(this.artifactsPath,`builtins`)}get entryPath(){return(0,L.joinPaths)(this.artifactsPath,`entry`)}get dataPath(){return(0,L.joinPaths)(this.envPaths.data,`projects`,Kt(this.config.name,this.meta.projectRootHash))}get cachePath(){return(0,L.joinPaths)(this.envPaths.cache,`projects`,(0,P.murmurhash)({checksum:this.#n,config:this.meta.configHash},{maxLength:62}))}get dtsPath(){return this.config.output.dts?(0,_.appendPath)(this.config.output.dts,this.workspaceConfig.workspaceRoot):(0,L.joinPaths)(this.workspaceConfig.workspaceRoot,this.config.projectRoot,`powerlines.d.ts`)}get relativeToWorkspaceRoot(){return(0,ee.relativeToWorkspaceRoot)(this.config.projectRoot)}get builtins(){return Object.values(this.fs.metadata).filter(e=>e&&e.type===`builtin`).map(e=>e?.id).filter(Boolean)}get program(){return this.#l||=Ge(this,{skipAddingFilesFromTsConfig:!0}),this.#l}get parserCache(){return this.#u||=(0,ye.create)({cacheId:`parser`,cacheDir:this.cachePath,ttl:7200*1e3,lruSize:5e3,persistInterval:250}),this.#u}get requestCache(){return this.#d||=(0,ye.create)({cacheId:`http`,cacheDir:this.cachePath,ttl:300*1e3,lruSize:5e3,persistInterval:250}),this.#d}async fetch(e,t={}){let n=(0,P.murmurhash)({input:e.toString(),options:JSON.stringify(t)});if(!this.config.skipCache&&!t.skipCache){let e=this.requestCache.get(n);if(e)return new z.Response(e.body,{status:e.status,statusText:e.statusText,headers:e.headers})}let r=await(0,ge.fetchRequest)(e,{timeout:12e3,...t}),i={body:await r.text(),status:r.status,statusText:r.statusText,headers:Object.fromEntries(r.headers.entries())};if(!this.config.skipCache&&!t.skipCache)try{this.requestCache.set(n,i)}catch{}return new z.Response(i.body,{status:i.status,statusText:i.statusText,headers:i.headers})}async parse(e,t={}){let n=(0,P.murmurhash)({code:e,options:t}),r;return!this.config.skipCache&&(r=this.parserCache.get(n),r)?r:(r=await(0,be.parse)(`source.${t.lang||`ts`}`,e,{...t,sourceType:`module`,showSemanticErrors:this.config.mode===`development`}),this.config.skipCache||this.parserCache.set(n,r),r)}async resolve(e,t,n={}){let r=e;if(this.config.build.alias)if(Array.isArray(this.config.build.alias)){let e=this.config.build.alias.find(e=>(0,R.match)(r,[e.find]));e&&(r=e.replacement)}else (0,x.isSetObject)(this.config.build.alias)&&this.config.build.alias[e]&&(r=this.config.build.alias[e]);if(this.fs.isVirtual(r)){let e=await this.fs.resolve(r,t,{conditions:this.config.build.conditions,extensions:this.config.build.extensions,...n});return e?{id:`\0${e}`,external:this.config.projectType!==`application`}:void 0}if(this.config.build.skipNodeModulesBundle){if((0,R.match)(r,this.resolvePatterns)||(0,R.match)(r,this.config.build.noExternal))return;if((0,R.match)(r,this.config.build.external)||r.startsWith(`node:`)||!/^[A-Z]:[/\\]|^\.{0,2}\/|^\.{1,2}$/.test(r))return{id:r,external:!0}}else{if((0,R.match)(r,this.config.build.noExternal))return;if((0,R.match)(r,this.config.build.external)||r.startsWith(`node:`))return{id:r,external:!0}}}async load(e){let t=await this.fs.resolve(e);if(!t)return;let n=await this.fs.read(t);if(n)return{code:n,map:null}}async getBuiltins(){return Promise.all(Object.entries(this.fs.metadata).filter(([,e])=>e&&e.type===`builtin`).map(async([e,t])=>{let n=await this.fs.read(e);return{...t,path:e,code:n}}))}async emitEntry(e,t,n={}){return this.fs.write((0,I.isAbsolute)(t)?t:(0,_.appendPath)(t,this.entryPath),e,(0,l.default)(n,{type:`entry`}))}async emitBuiltin(e,t,n,r={}){return this.fs.write(n?(0,I.isAbsolute)(n)?n:(0,L.joinPaths)(this.builtinsPath,n):(0,_.appendPath)(t,this.builtinsPath),e,(0,l.default)(r,{type:`builtin`}))}async withUserConfig(e,t={isHighPriority:!0}){this.mergeUserConfig(e),await this.init(this.config.userConfig,t)}async withInlineConfig(e,t={isHighPriority:!0}){if(this.config.inlineConfig=e,e.command===`new`){let e=(0,L.joinPaths)(this.workspaceConfig.workspaceRoot,`package.json`);if(!(0,N.existsSync)(e))throw Error(`The workspace package.json file could not be found at ${e}`);this.packageJson=await(0,k.readJsonFile)(e),this.workspaceConfig.repository??=(0,S.isSetString)(this.packageJson?.repository)?this.packageJson.repository:this.packageJson?.repository?.url}await this.init(this.config.inlineConfig,t)}fatal(e){this.log(c.LogLevelLabel.FATAL,(0,D.isString)(e)?e:A.StormJSON.stringify(e))}error(e){this.log(c.LogLevelLabel.ERROR,(0,D.isString)(e)?e:A.StormJSON.stringify(e))}warn(e){this.log(c.LogLevelLabel.WARN,(0,D.isString)(e)?e:A.StormJSON.stringify(e))}info(e){this.log(c.LogLevelLabel.INFO,(0,D.isString)(e)?e:A.StormJSON.stringify(e))}debug(e){this.log(c.LogLevelLabel.DEBUG,(0,D.isString)(e)?e:A.StormJSON.stringify(e))}trace(e){this.log(c.LogLevelLabel.TRACE,(0,D.isString)(e)?e:A.StormJSON.stringify(e))}createLog(e=null){return Nt(e,{...this.config,logLevel:(0,_e.isNull)(this.config.logLevel)?`silent`:this.config.logLevel})}extendLog(e){return Ft(this.log,e)}async generateChecksum(e=this.config.projectRoot){return this.#n=await(0,he.hashDirectory)(e,{ignore:[`node_modules`,`.git`,`.nx`,`.cache`,`.storm`,`tmp`,`dist`]}),this.#n}constructor(e){this.#t=e,this.#o=(0,me.getEnvPaths)({orgId:`storm-software`,appId:`powerlines`,workspaceRoot:e.workspaceRoot})}resolvedConfig={};logFn;async init(e={},t={isHighPriority:!0}){let n={projectRoot:e.root??this.config.projectRoot??this.config.userConfig?.root??this.config.inlineConfig?.root,mode:(e.mode??this.config.mode)||this.workspaceConfig.mode,skipCache:e.skipCache??this.config.skipCache??!1,configFile:e.configFile??this.config.configFile,framework:e.framework??this.config.framework??`powerlines`,command:this.config.inlineConfig?.command};if(Jt.has(n)){let e=Jt.get(n);this.projectJson=e.projectJson,this.packageJson=e.packageJson,this.#n=e.checksum,this.resolver=e.resolver,this.mergeUserConfig(e.userConfig.config,this.config.userConfig)}else{let t=(0,L.joinPaths)(n.projectRoot,`project.json`);(0,N.existsSync)(t)&&(this.projectJson=await(0,k.readJsonFile)(t));let r=(0,L.joinPaths)(n.projectRoot,`package.json`);(0,N.existsSync)(r)&&(this.packageJson=await(0,k.readJsonFile)(r)),this.#n=await this.generateChecksum(n.projectRoot),this.resolver=ft({workspaceRoot:this.workspaceConfig.workspaceRoot,projectRoot:n.projectRoot,cacheDir:this.cachePath,mode:n.mode,logLevel:e.logLevel||this.config?.logLevel||this.workspaceConfig.logLevel||`info`,skipCache:n.skipCache});let i=await lt(n.projectRoot,this.workspaceConfig.workspaceRoot,this.resolver,n.command,n.mode,n.configFile,n.framework);this.mergeUserConfig(i.config),Jt.set(n,{projectJson:this.projectJson,packageJson:this.packageJson,checksum:this.#n,resolver:this.resolver,userConfig:i})}e.tsconfig??=W(this.workspaceConfig.workspaceRoot,n.projectRoot,e.tsconfig),(0,x.isSetObject)(e)&&(this.resolvedConfig=(0,l.default)({inlineConfig:this.config.inlineConfig,userConfig:this.config.userConfig},t.isHighPriority?this.#f(e):{},{command:this.config.inlineConfig?.command,...this.#f(this.config.inlineConfig)},this.#f(this.config.userConfig),{mode:this.workspaceConfig?.mode,logLevel:this.workspaceConfig?.logLevel,skipCache:this.workspaceConfig?.skipCache},{name:this.projectJson?.name||this.packageJson?.name,version:this.packageJson?.version,description:this.packageJson?.description,sourceRoot:this.projectJson?.sourceRoot||(0,_.appendPath)(`src`,n.projectRoot),output:(0,l.default)(e.output??{},{outputPath:n.projectRoot?(0,L.joinPaths)(this.workspaceConfig?.directories?.build||`dist`,n.projectRoot):this.workspaceConfig?.directories?.build||`dist`,artifactsPath:(0,L.joinPaths)(n.projectRoot,`.${e.framework??`powerlines`}`),dts:(0,L.joinPaths)(n.projectRoot,`${e.framework??`powerlines`}.d.ts`),builtinPrefix:e.framework??`powerlines`,assets:[{glob:`LICENSE`},{input:n.projectRoot,glob:`*.md`},{input:n.projectRoot,glob:`package.json`}]})},t.isHighPriority?{}:this.#f(e),{inlineConfig:{},userConfig:{},framework:`powerlines`,platform:`neutral`,mode:`production`,projectType:`application`,logLevel:`info`,preview:!1,environments:{},transform:{babel:{plugins:[],presets:[]}},lint:{eslint:{}},build:{target:`esnext`,override:{}}})),this.config.entry=Ot(this.config.entry),this.config.name?.startsWith(`@`)&&this.config.name.split(`/`).filter(Boolean).length>1&&(this.config.name=this.config.name.split(`/`).filter(Boolean)[1]),this.config.title??=(0,M.titleCase)(this.config.name),this.config.userConfig.build?.external&&(this.config.userConfig.build.external=(0,F.getUnique)(this.config.userConfig.build.external)),this.config.userConfig.build?.noExternal&&(this.config.userConfig.build.noExternal=(0,F.getUnique)(this.config.userConfig.build.noExternal)),this.config.build.external&&(this.config.build.external=(0,F.getUnique)(this.config.build.external)),this.config.build.noExternal&&(this.config.build.noExternal=(0,F.getUnique)(this.config.build.noExternal)),this.config.output.format=(0,F.getUnique)((0,f.toArray)(this.config.output?.format??(this.config.projectType===`library`?[`cjs`,`esm`]:[`esm`]))),this.config.projectRoot&&this.config.projectRoot!==`.`&&this.config.projectRoot!==`./`&&this.config.projectRoot!==this.workspaceConfig.workspaceRoot?(this.config.output.outputPath??=(0,L.joinPaths)(`dist`,this.config.projectRoot),this.config.output.buildPath??=(0,L.joinPaths)(this.config.projectRoot,`dist`)):(this.config.output.outputPath??=`dist`,this.config.output.buildPath??=`dist`),this.config.output.assets=(0,F.getUnique)(this.config.output.assets.map(e=>({glob:(0,x.isSetObject)(e)?e.glob:e,input:(0,D.isString)(e)||!e.input||e.input===`.`||e.input===`/`||e.input===`./`?this.workspaceConfig.workspaceRoot:(0,_.appendPath)(e.input,this.workspaceConfig.workspaceRoot),output:(0,_.appendPath)((0,x.isSetObject)(e)&&e.output?(0,L.joinPaths)(this.config.output.outputPath,(0,v.replacePath)(e.output,this.config.output.outputPath)):this.config.output.outputPath,this.workspaceConfig.workspaceRoot),ignore:(0,x.isSetObject)(e)&&e.ignore?(0,f.toArray)(e.ignore):void 0}))),this.config.plugins=(this.config.plugins??[]).filter(Boolean).reduce((e,t)=>(q(t)&&J(t,e.filter(e=>q(e)))||e.push(t),e),[]),this.config.tsconfig&&(this.config.tsconfig=Y(this,this.config.tsconfig)),this.config.output.dts&&(this.config.output.dts=Y(this,this.config.output.dts)),this.config.build.polyfill&&(this.config.build.polyfill=this.config.build.polyfill.map(e=>Y(this,e))),this.config.output.assets&&(this.config.output.assets=this.config.output.assets.map(e=>({...e,glob:Y(this,e.glob),ignore:e.ignore?e.ignore.map(e=>Y(this,e)):void 0,input:Y(this,e.input),output:Y(this,e.output)}))),this.#s??=await Ut.create(this)}mergeUserConfig(e={},t=this.config.userConfig??{}){this.config.userConfig=(0,l.default)({entry:Array.isArray(e.entry)&&e.entry.length>0?e.entry:Array.isArray(t?.entry)&&t.entry.length>0?t.entry:[]},(0,u.omit)(e??{},[`entry`]),(0,u.omit)(t??{},[`entry`])),this.config.userConfig.output?.format&&(this.config.userConfig.output.format=(0,F.getUnique)((0,f.toArray)(this.config.userConfig.output?.format))),this.config.userConfig.plugins=(this.config.userConfig.plugins??[]).filter(Boolean).reduce((e,t)=>(q(t)&&J(t,e.filter(e=>q(e)))||e.push(t),e),[])}};const Xt=[`name`,`api`,`enforce`,`dedupe`,`dependsOn`,`applyToEnvironment`];function Zt(e,t){let n=e=>(0,D.isString)(e)?e:e.message,r=t.extendLog(e.name),i=async(e,n,...r)=>t.$$internal.api.callHook(e,{sequential:!0,result:`merge`,...n,environment:t},...r);return new Proxy({},{get(e,a){return a===`$$internal`?{...t.$$internal,environment:t,callHook:i}:a===`log`||a===`logger`?r:a===`error`?e=>{r(c.LogLevelLabel.ERROR,n(e))}:a===`warn`?e=>{r(c.LogLevelLabel.WARN,n(e))}:a===`info`?e=>{r(c.LogLevelLabel.INFO,n(e))}:a===`debug`?e=>{r(c.LogLevelLabel.DEBUG,n(e))}:a===`trace`?e=>{r(c.LogLevelLabel.TRACE,n(e))}:t[a]},set(e,n,i){return[`$$internal`,`environment`,`config`,`log`,`logger`,`error`,`warn`,`plugins`,`hooks`,`addPlugin`,`selectHooks`].includes(n)?(r(c.LogLevelLabel.WARN,`Cannot set read-only property "${String(n)}"`),!1):(t[n]=i,!0)}})}var Qt=class e extends Yt{#e={};static async fromConfig(t,n){let r=new e(n,t);if(await r.init(),r.powerlinesPath=await(0,g.resolvePackage)(`powerlines`),!r.powerlinesPath)throw Error("Could not resolve `powerlines` package location.");return r}environment;plugins=[];get config(){return super.config}get hooks(){return this.#e}async addPlugin(e){let t=e;if((0,y.isFunction)(e.applyToEnvironment)){let n=await Promise.resolve(e.applyToEnvironment(this.environment));if(!n||(0,se.isObject)(n)&&Object.keys(n).length===0)return;if(gt(n))return this.$$internal.addPlugin(n);t=q(n)?n:e}let n=Zt(t,this);this.plugins.push({plugin:t,context:n}),this.#e=Object.keys(t).filter(e=>!Xt.includes(e)).reduce((e,r)=>{let i=r,a=t[i];if(!yt(a))return e;if(xt(i))e[i]??=[],e[i].push({plugin:t,hook:bt(a).bind(n)});else{if(e[i]??={},t.enforce)return e[i][`${t.enforce}Enforced`]??=[],St(n,t,a,e[i][`${t.enforce}Enforced`]),e;if((0,y.isFunction)(a)||!a.order)return e[i].normal??=[],St(n,t,a,e[i].normal),e;e[i][`${a.order}Ordered`]??=[],St(n,t,a,e[i][`${a.order}Ordered`])}return e},this.hooks)}selectHooks(e,t){let n=[];if(this.hooks[e])if(xt(e))n.push(...this.hooks[e].map(e=>{let t=this.plugins.find(t=>t.plugin.name===e.plugin.name);if(!t)throw Error(`Could not find plugin context for plugin "${e.plugin.name}".`);return{handle:e.handler,context:t.context}}));else{let r=this.hooks[e];t?.order?t?.order===`pre`?(n.push(...(r.preOrdered??[]).map(e=>{let t=this.plugins.find(t=>t.plugin.name===e.plugin.name);if(!t)throw Error(`Could not find plugin context for plugin "${e.plugin.name}".`);return{handle:e.handler,context:t.context}})),n.push(...(r.preEnforced??[]).map(e=>{let t=this.plugins.find(t=>t.plugin.name===e.plugin.name);if(!t)throw Error(`Could not find plugin context for plugin "${e.plugin.name}".`);return{handle:e.handler,context:t.context}}))):t?.order===`post`?(n.push(...(r.postOrdered??[]).map(e=>{let t=this.plugins.find(t=>t.plugin.name===e.plugin.name);if(!t)throw Error(`Could not find plugin context for plugin "${e.plugin.name}".`);return{handle:e.handler,context:t.context}})),n.push(...(r.postEnforced??[]).map(e=>{let t=this.plugins.find(t=>t.plugin.name===e.plugin.name);if(!t)throw Error(`Could not find plugin context for plugin "${e.plugin.name}".`);return{handle:e.handler,context:t.context}}))):n.push(...(r.normal??[]).map(e=>{let t=this.plugins.find(t=>t.plugin.name===e.plugin.name);if(!t)throw Error(`Could not find plugin context for plugin "${e.plugin.name}".`);return{handle:e.handler,context:t.context}})):(n.push(...this.selectHooks(e,{order:`pre`})),n.push(...this.selectHooks(e,{order:`normal`})),n.push(...this.selectHooks(e,{order:`post`})))}return n}constructor(e,t){super(t),this.resolvedConfig=e}},$t=class e extends Yt{#e={};#t=[];#n;static async from(t,n){let r=new e(await ct(t,n.root));if(await r.withUserConfig(n),r.powerlinesPath=await(0,g.resolvePackage)(`powerlines`),!r.powerlinesPath)throw Error("Could not resolve `powerlines` package location.");return r}get $$internal(){return super.$$internal}set $$internal(e){super.$$internal=e;for(let e of Object.values(this.environments))e.$$internal=super.$$internal}get environments(){return this.#e}get log(){return this.#n||=this.createLog(`engine`),this.#n}get plugins(){return this.#t}constructor(e){super(e)}async init(e={}){await super.init(e),await Promise.all((0,f.toArray)(this.config.userConfig.environments&&Object.keys(this.config.userConfig.environments).length>0?Object.keys(this.config.userConfig.environments).map(e=>ot(e,this.config.userConfig)):st(this.config.userConfig)).map(async e=>{this.#e[e.name]=await this.in(e)}))}async in(e){let t;t=this.environments[e.name]?this.environments[e.name]:await Qt.fromConfig(this.workspaceConfig,this.config),(0,x.isSetObject)(this.config.inlineConfig)&&await t.withInlineConfig(this.config.inlineConfig),t.environment=e,t.plugins=[];for(let e of this.plugins)await t.addPlugin(e);return t}async withUserConfig(e,t={isHighPriority:!0}){await super.withUserConfig(e,t),await Promise.all(Object.keys(this.#e).map(async n=>{await this.#e[n].withUserConfig(e,t)}))}async withInlineConfig(e,t={isHighPriority:!0}){await super.withInlineConfig(e,t),await Promise.all(Object.keys(this.#e).map(async n=>{await this.#e[n].withInlineConfig(e,t)}))}async addPlugin(e){this.plugins.push(e),await Promise.all(Object.keys(this.environments).map(async t=>{await this.environments[t].addPlugin(e)}))}async getEnvironment(e){let t;if(e&&(t=this.environments[e]),Object.keys(this.environments).length===1&&(t=this.environments[Object.keys(this.environments)[0]],this.log(c.LogLevelLabel.DEBUG,`Applying the only configured environment: ${C.default.bold.cyanBright(t?.environment.name)}`)),!t){if(e)throw Error(`Environment "${e}" not found.`);t=await this.in(st(this.config.userConfig)),this.log(c.LogLevelLabel.WARN,`No environment specified, and no default environment found. Using a temporary default environment: ${C.default.bold.cyanBright(t?.environment.name)}`)}return t}async getEnvironmentSafe(e){try{return await this.getEnvironment(e)}catch{return}}};function en(e){return`
21
+ // Generated with ${(0,M.titleCase)(e.config.framework)}
22
+ // Note: Do not edit this file manually - it will be overwritten automatically
23
+ `}function tn(e,t={}){let{directive:n=null,prettierIgnore:r=!1}=t;return`/* eslint-disable */
24
+ // biome-ignore lint: disable
25
+ ${r?`// prettier-ignore`:``}${n?`\n\n${n}\n`:`
26
+ `}
27
+ ${en(e)}
28
+
29
+ `}var nn=class e{#e;get context(){return this.#e}constructor(e){this.#e=e}static async from(t,n){let r=new e(await $t.from(t,n));r.#e.$$internal={api:r,addPlugin:r.#r.bind(r)};for(let e of r.context.config.plugins??[])await r.#r(e);r.context.plugins.length===0&&r.context.log(c.LogLevelLabel.WARN,`No Powerlines plugins were specified in the options. Please ensure this is correct, as it is generally not recommended.`);let i=await r.callHook(`config`,{environment:await r.context.getEnvironment(),sequential:!0,result:`merge`});return await r.context.withUserConfig(i,{isHighPriority:!1}),r}async prepare(e={command:`prepare`}){this.context.log(c.LogLevelLabel.TRACE,` 🏗️ Preparing the Powerlines project`),this.context.log(c.LogLevelLabel.TRACE,` ⚙️ Aggregating configuration options for the Powerlines project`),await this.context.withInlineConfig(e),await this.#n(async e=>{if(e.log(c.LogLevelLabel.TRACE,`Initializing the processing options for the Powerlines project.`),await this.callHook(`configResolved`,{environment:e,order:`pre`}),await rt(e),await this.callHook(`configResolved`,{environment:e,order:`normal`}),e.log(c.LogLevelLabel.DEBUG,`The configuration provided ${(0,f.toArray)(e.config.entry).length} entry point(s), Powerlines has found ${e.entry.length} entry files(s) for the ${e.config.title} project${e.entry.length>0&&e.entry.length<10?`: \n${e.entry.map(e=>`- ${e.input.file||e.file}${e.output?` -> ${e.output}`:``}`).join(`
30
+ `)}`:``}.`),await it(e),await Ze(e),await this.callHook(`configResolved`,{environment:e,order:`post`}),e.log(c.LogLevelLabel.TRACE,`Powerlines configuration has been resolved: \n\n${(0,re.formatLogMessage)(e.config)}`),e.fs.existsSync(e.cachePath)||await(0,p.createDirectory)(e.cachePath),e.fs.existsSync(e.dataPath)||await(0,p.createDirectory)(e.dataPath),await this.callHook(`prepare`,{environment:e,order:`pre`}),await this.callHook(`prepare`,{environment:e,order:`normal`}),e.config.output.dts!==!1){e.log(c.LogLevelLabel.TRACE,`Preparing the TypeScript definitions for the Powerlines project.`),e.fs.existsSync(e.dtsPath)&&await e.fs.remove(e.dtsPath),e.log(c.LogLevelLabel.TRACE,`Transforming built-ins runtime modules files.`);let t=await Promise.all((await e.getBuiltins()).map(async t=>{let n=await(0,ne.transformAsync)(t.code.toString(),{highlightCode:!0,code:!0,ast:!1,cloneInputAst:!1,comments:!0,sourceType:`module`,configFile:!1,babelrc:!1,envName:e.config.mode,caller:{name:`powerlines`},...e.config.transform.babel,filename:t.path,plugins:[[`@babel/plugin-syntax-typescript`],[Ue(e)]]});if(!n?.code)throw Error(`Powerlines - Generate Types failed to compile ${t.id}`);return e.log(c.LogLevelLabel.TRACE,`Writing transformed built-in runtime file ${t.id}.`),await e.emitBuiltin(n.code,t.id,t.path),t.path}));if(!await(0,g.resolvePackage)(`typescript`))throw Error(`Could not resolve TypeScript package location. Please ensure TypeScript is installed.`);let n=t.reduce((t,n)=>{let r=(0,v.replacePath)(n,e.workspaceConfig.workspaceRoot);return t.includes(r)||t.push(r),t},[]);e.log(c.LogLevelLabel.TRACE,`Parsing TypeScript configuration for the Powerlines project.`);let r=await qe(e,n);e.log(c.LogLevelLabel.TRACE,`Generating TypeScript declaration file ${e.dtsPath}.`);let i=[],a=e=>(0,se.isObject)(e)?e.code:e,o=await this.callHook(`types`,{environment:e,sequential:!0,order:`pre`,result:`merge`,asNextParam:a},r);if(o&&((0,x.isSetObject)(o)?(r=o.code,Array.isArray(o.directives)&&o.directives.length>0&&i.push(...o.directives)):(0,S.isSetString)(o)&&(r=o)),o=await this.callHook(`types`,{environment:e,sequential:!0,order:`normal`,result:`merge`,asNextParam:a},r),o&&((0,x.isSetObject)(o)?(r=o.code,Array.isArray(o.directives)&&o.directives.length>0&&i.push(...o.directives)):(0,S.isSetString)(o)&&(r=o)),o=await this.callHook(`types`,{environment:e,sequential:!0,order:`post`,result:`merge`,asNextParam:a},r),o&&((0,x.isSetObject)(o)?(r=o.code,Array.isArray(o.directives)&&o.directives.length>0&&i.push(...o.directives)):(0,S.isSetString)(o)&&(r=o)),r?.trim()||i.length>0)await e.fs.write(e.dtsPath,`${i?`${i.map(e=>`/// <reference types="${e}" />`).join(`
31
+ `)}
32
+
33
+ `:``}${tn(e,{directive:null,prettierIgnore:!1})}
34
+
35
+ ${Ke(r)}
36
+ `);else{let t=tt(e);if(e.tsconfig.tsconfigJson.include&&et(t,e.tsconfig.tsconfigJson.include)){let n=t.startsWith(`./`)?t.slice(2):t;e.tsconfig.tsconfigJson.include=e.tsconfig.tsconfigJson.include.filter(e=>e?.toString()!==n),await e.fs.write(e.tsconfig.tsconfigFilePath,JSON.stringify(e.tsconfig.tsconfigJson,null,2))}}}if(e.tsconfig=K(e.workspaceConfig.workspaceRoot,e.config.projectRoot,e.config.tsconfig),!e.tsconfig)throw Error(`Failed to parse the TypeScript configuration file.`);await this.callHook(`prepare`,{environment:e,order:`post`}),await qt(e),e.persistedMeta=e.meta}),this.context.log(c.LogLevelLabel.INFO,`Powerlines API has been prepared successfully`)}async new(e){this.context.log(c.LogLevelLabel.INFO,`🆕 Creating a new Powerlines project`),await this.prepare(e),await this.#n(async e=>{e.log(c.LogLevelLabel.TRACE,`Initializing the processing options for the Powerlines project.`),await this.callHook(`new`,{environment:e,order:`pre`});let t=await(0,m.listFiles)((0,d.joinPaths)(e.powerlinesPath,`files/common/**/*.hbs`));for(let n of t){e.log(c.LogLevelLabel.TRACE,`Adding template file: ${n}`);let t=w.default.compile(n);await e.fs.write((0,d.joinPaths)(e.config.projectRoot,n.replace(`.hbs`,``)),t(e))}if(await this.callHook(`new`,{environment:e,order:`normal`}),e.config.projectType===`application`){let t=await(0,m.listFiles)((0,d.joinPaths)(e.powerlinesPath,`files/application/**/*.hbs`));for(let n of t){e.log(c.LogLevelLabel.TRACE,`Adding application template file: ${n}`);let t=w.default.compile(n);await e.fs.write((0,d.joinPaths)(e.config.projectRoot,n.replace(`.hbs`,``)),t(e))}}else{let t=await(0,m.listFiles)((0,d.joinPaths)(e.powerlinesPath,`files/library/**/*.hbs`));for(let n of t){e.log(c.LogLevelLabel.TRACE,`Adding library template file: ${n}`);let t=w.default.compile(n);await e.fs.write((0,d.joinPaths)(e.config.projectRoot,n.replace(`.hbs`,``)),t(e))}}await this.callHook(`new`,{environment:e,order:`post`})}),this.context.log(c.LogLevelLabel.TRACE,`Powerlines - New command completed`)}async clean(e={command:`clean`}){this.context.log(c.LogLevelLabel.INFO,`🧹 Cleaning the previous Powerlines artifacts`),await this.prepare(e),await this.#n(async e=>{this.context.log(c.LogLevelLabel.TRACE,`Cleaning the project's dist and artifacts directories.`),await e.fs.remove((0,d.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.output.buildPath)),await e.fs.remove((0,d.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.output.artifactsPath)),await this.callHook(`clean`,{environment:e,sequential:!1})}),this.context.log(c.LogLevelLabel.TRACE,`Powerlines - Clean command completed`)}async lint(e={command:`lint`}){this.context.log(c.LogLevelLabel.INFO,`📋 Linting the Powerlines project`),await this.prepare(e),await this.#n(async e=>{e.config.lint!==!1&&await this.callHook(`lint`,{environment:e,sequential:!1})}),this.context.log(c.LogLevelLabel.TRACE,`Powerlines linting completed`)}async build(e={command:`build`}){this.context.log(c.LogLevelLabel.INFO,`📦 Building the Powerlines project`),await this.prepare(e),await this.#n(async e=>{if(await this.callHook(`build`,{environment:e,order:`pre`}),await this.callHook(`build`,{environment:e,order:`normal`}),e.config.output.buildPath!==e.config.output.outputPath){let t=(0,_.appendPath)(e.config.output.buildPath,e.workspaceConfig.workspaceRoot),n=(0,d.joinPaths)((0,_.appendPath)(e.config.output.outputPath,e.workspaceConfig.workspaceRoot),`dist`);t!==n&&(e.log(c.LogLevelLabel.INFO,`Copying build output files from project's build directory (${e.config.output.buildPath}) to the workspace's output directory (${e.config.output.outputPath}).`),await e.fs.copy(t,n))}await Promise.all(e.config.output.assets.map(async t=>{e.log(c.LogLevelLabel.DEBUG,`Copying asset(s): ${C.default.redBright(e.workspaceConfig.workspaceRoot===t.input?t.glob:(0,d.joinPaths)((0,v.replacePath)(t.input,e.workspaceConfig.workspaceRoot),t.glob))} -> ${C.default.greenBright((0,d.joinPaths)((0,v.replacePath)(t.output,e.workspaceConfig.workspaceRoot),t.glob))} ${Array.isArray(t.ignore)&&t.ignore.length>0?` (ignoring: ${t.ignore.map(e=>C.default.yellowBright(e)).join(`, `)})`:``}`),await e.fs.copy(t,t.output)})),await this.callHook(`build`,{environment:e,order:`post`})}),this.context.log(c.LogLevelLabel.TRACE,`Powerlines build completed`)}async docs(e={command:`docs`}){this.context.log(c.LogLevelLabel.INFO,`📓 Generating documentation for the Powerlines project`),await this.prepare(e),await this.#n(async t=>{t.log(c.LogLevelLabel.TRACE,`Writing documentation for the Powerlines project artifacts.`),await this.prepare(e),await this.#n(async e=>{await this.callHook(`docs`,{environment:e})})}),this.#e.log(c.LogLevelLabel.TRACE,`Powerlines documentation generation completed`)}async deploy(e={command:`deploy`}){this.context.log(c.LogLevelLabel.INFO,`📦 Deploying the Powerlines project`),await this.prepare(e),await this.#n(async e=>{await this.callHook(`deploy`,{environment:e})}),this.context.log(c.LogLevelLabel.TRACE,`Powerlines deploy completed`)}async finalize(){this.context.log(c.LogLevelLabel.TRACE,`Powerlines finalize execution started`),await this.#n(async e=>{await this.callHook(`finalize`,{environment:e}),await e.fs.dispose()}),this.context.log(c.LogLevelLabel.TRACE,`Powerlines finalize execution completed`)}async callHook(e,t,...n){return Ye((0,x.isSetObject)(t?.environment)?t.environment:await this.#e.getEnvironment(t?.environment),e,{sequential:!0,...t},...n)}async[Symbol.asyncDispose](){await this.finalize()}async#t(){return!this.context.config.environments||Object.keys(this.context.config.environments).length<=1?(this.context.log(c.LogLevelLabel.DEBUG,`No environments are configured for this Powerlines project. Using the default environment.`),[await this.context.getEnvironment()]):(this.context.log(c.LogLevelLabel.DEBUG,`Found ${Object.keys(this.context.config.environments).length} configured environment(s) for this Powerlines project.`),(await Promise.all(Object.entries(this.context.config.environments).map(async([e,t])=>{if(!await this.context.getEnvironmentSafe(e)){let n=await this.callHook(`configEnvironment`,{environment:e},e,t);n&&(this.context.environments[e]=await this.context.in(n))}return this.context.environments[e]}))).filter(e=>(0,b.isSet)(e)))}async#n(e){await Promise.all((await this.#t()).map(async t=>Promise.resolve(e(t))))}async#r(e){if(e){let t=await this.#i(e);if(!t)return;if(t.dependsOn)for(let e of t.dependsOn)await this.#r(e);this.context.log(c.LogLevelLabel.DEBUG,`Successfully initialized the ${C.default.bold.cyanBright(t.name)} plugin`),await this.context.addPlugin(t)}}async#i(e){let t=e;if((0,ce.isPromiseLike)(e)&&(t=await Promise.resolve(e)),!gt(t))throw Error(`Invalid plugin specified in the configuration - ${JSON.stringify(t)}. Please ensure the value is a plugin name, an object with the \`plugin\` and \`props\` properties, or an instance of \`Plugin\`.`);let n;if(q(t))n=t;else if((0,y.isFunction)(t))n=await Promise.resolve(t());else if((0,S.isSetString)(t)){let e=await this.#a(t);n=(0,y.isFunction)(e)?await Promise.resolve(e()):e}else if(ht(t)||mt(t)){let e,r;if(ht(t)?(e=t[0],r=t?.length===2?t[1]:void 0):(e=t.plugin,r=t.options),(0,S.isSetString)(e)){let t=await this.#a(e);n=(0,y.isFunction)(t)?await Promise.resolve(r?t(r):t()):t}else (0,y.isFunction)(e)?n=await Promise.resolve(e(r)):q(e)&&(n=e)}if(!n)throw Error(`The plugin configuration ${JSON.stringify(t)} is invalid. This configuration must point to a valid Powerlines plugin module.`);if(!q(n))throw Error(`The plugin option ${JSON.stringify(n)} does not export a valid module. This configuration must point to a valid Powerlines plugin module.`);return J(n,this.context.plugins)?(this.context.log(c.LogLevelLabel.TRACE,`Duplicate ${C.default.bold.cyanBright(n.name)} plugin dependency detected - Skipping initialization.`),null):(this.context.log(c.LogLevelLabel.TRACE,`Initializing the ${C.default.bold.cyanBright(n.name)} plugin...`),n)}async#a(e){if(e.startsWith(`@`)&&e.split(`/`).filter(Boolean).length>2){let t=e.split(`/`).filter(Boolean);e=`${t[0]}/${t[1]}`}let t=(0,h.isPackageExists)(e,{paths:[this.context.workspaceConfig.workspaceRoot,this.context.config.projectRoot]});if(!t&&this.context.config.skipInstalls!==!0){this.#e.log(c.LogLevelLabel.WARN,`The plugin package "${e}" is not installed. It will be installed automatically.`);let t=await(0,ie.install)(e,{cwd:this.context.config.projectRoot});if((0,oe.isNumber)(t.exitCode)&&t.exitCode>0)throw this.#e.log(c.LogLevelLabel.ERROR,t.stderr),Error(`An error occurred while installing the build plugin package "${e}" `)}try{let t=await this.context.resolver.plugin.import(this.context.resolver.plugin.esmResolve((0,d.joinPaths)(e,`plugin`))),n=t.plugin??t.default;if(!n)throw Error(`The plugin package "${e}" does not export a valid module.`);return n}catch(n){try{let t=await this.context.resolver.plugin.import(this.context.resolver.plugin.esmResolve(e)),n=t.plugin??t.default;if(!n)throw Error(`The plugin package "${e}" does not export a valid module.`);return n}catch{throw t?Error(`An error occurred while importing the build plugin package "${e}":
37
+ ${(0,ae.isError)(n)?n.message:String(n)}
38
+
39
+ Note: Please ensure the plugin package's default export is a class that extends \`Plugin\` with a constructor that excepts a single arguments of type \`PluginOptions\`.`):Error(`The plugin package "${e}" is not installed. Please install the package using the command: "npm install ${e} --save-dev"`)}}}};function rn(e){return e?(0,D.isString)(e)?e:(0,x.isSetObject)(e)&&`code`in e?e.code:e.toString():``}function an(e,t){return(0,l.defu)(e,t)}function on(e){let t=e;return(0,te.setParseImpl)(t.parse),()=>{let e=Ft(t.log,`unplugin`);e(c.LogLevelLabel.DEBUG,`Initializing Unplugin`);try{async function n(){e(c.LogLevelLabel.DEBUG,`Powerlines build plugin starting...`),await t.$$internal.callHook(`buildStart`,{sequential:!0})}async function r(e,n,r={isEntry:!1}){let i=await(async()=>{let i=await t.$$internal.callHook(`resolveId`,{sequential:!0,result:`first`,order:`pre`},e,n,r);return i||(i=await t.$$internal.callHook(`resolveId`,{sequential:!0,result:`first`,order:`normal`},e,n,r),i)||(i=await t.resolve(e,n,r),i)?i:t.$$internal.callHook(`resolveId`,{sequential:!0,result:`first`,order:`post`},e,n,r)})();if(i&&r.isEntry&&t.config.build.polyfill&&t.config.build.polyfill.length>0){let e=t.entry.find(e=>e.file===((0,D.isString)(i)?i:i.id));if(e)return e.file=`${(0,v.replaceExtension)((0,D.isString)(i)?i:i.id)}-polyfill.ts`,e.output||=e.output?.replace((0,j.findFileName)(e.output,{withExtension:!0}),e.file),await t.emitEntry(`
40
+ ${t.config.build.polyfill.map(e=>`import "${e}";`).join(`
41
+ `)}
42
+
43
+ export * from "${(0,D.isString)(i)?i:i.id}";
44
+ `,e.file),e.file}return i}async function i(e){let n=await t.$$internal.callHook(`load`,{sequential:!0,result:`first`,order:`pre`},e);return n||(n=await t.$$internal.callHook(`load`,{sequential:!0,result:`first`,order:`normal`},e),n)||(n=await t.load(e),n)?n:t.$$internal.callHook(`load`,{sequential:!0,result:`first`,order:`post`},e)}async function a(e,n){let r=e;for(let e of t.$$internal.environment.selectHooks(`transform`)){let i=await e.handle.apply(an(t,this),[rn(r),n]);i&&(r=i)}return r}async function o(){return e(c.LogLevelLabel.DEBUG,`Powerlines build plugin finishing...`),t.$$internal.callHook(`buildEnd`,{sequential:!0})}async function s(){return e(c.LogLevelLabel.DEBUG,`Finalizing Powerlines project output...`),t.$$internal.callHook(`writeBundle`,{sequential:!0})}return{name:`powerlines`,api:t.$$internal.api,resolveId:{filter:{id:{include:[/.*/]}},handler:r},load:{filter:{id:{include:[/.*/]}},handler:i},transform:a,buildStart:n,buildEnd:o,writeBundle:s,vite:{sharedDuringBuild:!0}}}catch(t){throw e(c.LogLevelLabel.FATAL,t?.message),t}}}function sn(e){return(0,te.createRspackPlugin)(on(e))({})}Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return sn}});
@@ -1,4 +1,4 @@
1
- import { t as RspackPluginContext } from "./plugin-2BiSZzHl.mjs";
1
+ import { t as RspackPluginContext } from "./plugin-C_2WTt9t.mjs";
2
2
  import * as unplugin0 from "unplugin";
3
3
 
4
4
  //#region src/helpers/unplugin.d.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerlines/plugin-rspack",
3
- "version": "0.5.65",
3
+ "version": "0.5.67",
4
4
  "type": "module",
5
5
  "description": "A package containing a Powerlines plugin to build projects using Webpack.",
6
6
  "repository": {
@@ -152,13 +152,13 @@
152
152
  "@stryke/types": "^0.10.13",
153
153
  "defu": "^6.1.4",
154
154
  "jiti": "^2.6.1",
155
- "powerlines": "^0.30.7"
155
+ "powerlines": "^0.30.9"
156
156
  },
157
157
  "devDependencies": {
158
- "@powerlines/nx": "^0.10.56",
159
- "@powerlines/plugin-plugin": "^0.12.8",
158
+ "@powerlines/nx": "^0.10.58",
159
+ "@powerlines/plugin-plugin": "^0.12.10",
160
160
  "@types/node": "^24.10.1"
161
161
  },
162
162
  "publishConfig": { "access": "public" },
163
- "gitHead": "c99d14f5c417d27c6854661afcf485f629f4e143"
163
+ "gitHead": "00fa339177561d404892937d2c24fe2a5b3df4e7"
164
164
  }
@@ -1,44 +0,0 @@
1
- var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`@storm-software/config-tools/types`),l=require(`defu`);l=s(l);let u=require(`@stryke/helpers/omit`),d=require(`@stryke/path/join-paths`),ee=require(`@stryke/fs/get-workspace-root`),te=require(`unplugin`),ne=require(`@babel/core`),re=require(`@storm-software/config-tools/logger/console`),f=require(`@stryke/convert/to-array`),p=require(`@stryke/fs/helpers`),ie=require(`@stryke/fs/install`),m=require(`@stryke/fs/list-files`),h=require(`@stryke/fs/package-fns`),g=require(`@stryke/fs/resolve`),_=require(`@stryke/path/append`),v=require(`@stryke/path/replace`),ae=require(`@stryke/type-checks/is-error`),y=require(`@stryke/type-checks/is-function`),oe=require(`@stryke/type-checks/is-number`),se=require(`@stryke/type-checks/is-object`),ce=require(`@stryke/type-checks/is-promise`),le=require(`@stryke/type-checks/is-set`),b=require(`@stryke/type-checks/is-set-object`),x=require(`@stryke/type-checks/is-set-string`),S=require(`chalk`);S=s(S);let C=require(`handlebars`);C=s(C);let ue=require(`@babel/helper-plugin-utils`),w=require(`@babel/types`);w=s(w);let T=require(`typescript`);T=s(T);let de=require(`ts-morph`),E=require(`@stryke/type-checks/is-string`),D=require(`@stryke/string-format/package`),fe=require(`@donedeal0/superdiff`),O=require(`@stryke/fs/json`),k=require(`@stryke/json/storm-json`),A=require(`@stryke/path/file-path-fns`),j=require(`@stryke/string-format/title-case`),M=require(`@stryke/fs/exists`),pe=require(`@storm-software/config-tools/get-config`),me=require(`c12`),he=require(`@stryke/env/get-env-paths`),ge=require(`@stryke/hash/hash-files`),N=require(`@stryke/hash/murmurhash`),P=require(`@stryke/helpers/get-unique`),_e=require(`@stryke/http/fetch`),F=require(`@stryke/path/is-type`),I=require(`@stryke/path/join`),ve=require(`@stryke/type-checks/is-null`),ye=require(`@stryke/unique-id/uuid`),L=require(`bundle-require`),be=require(`flat-cache`),xe=require(`oxc-parser`),R=require(`undici`),Se=require(`jiti`),z=require(`@stryke/type-checks/is-undefined`),Ce=require(`@stryke/convert/parse-type-definition`),we=require(`@stryke/fs/is-file`),B=require(`@stryke/capnp`);B=s(B);let Te=require(`@stryke/fs/buffer`),V=require(`@stryke/path/is-parent-path`),Ee=require(`@stryke/string-format/pretty-bytes`),De=require(`node:buffer`),H=require(`node:url`),Oe=require(`prettier`),ke=require(`@storm-software/config-tools/logger`),Ae=require(`@storm-software/config-tools/utilities/colors`),je=require(`@stryke/helpers/noop`),Me=require(`@stryke/path/correct-path`),Ne=require(`@stryke/path/slash`),Pe=require(`@stryke/fs/read-file`),Fe=require(`@stryke/fs/write-file`),Ie=require(`node:fs`),Le=require(`node:fs/promises`),Re=require(`node:path`);require(`@stryke/fs/remove-file`);let ze=require(`@stryke/string-format/kebab-case`);require(`magic-string`);function Be(e,t){if(!w.isStringLiteral(e.node))return;let n=e.node.value,r=t.context?.fs.resolveSync(n);r&&e.replaceWith(w.stringLiteral(r.replace(/\.(?:ts|mts|cts)x?$/,``)))}const Ve=[`require`,`require.resolve`,`System.import`,`jest.genMockFromModule`,`jest.mock`,`jest.unmock`,`jest.doMock`,`jest.dontMock`,`jest.setMock`,`jest.requireActual`,`jest.requireMock`,`require.requireActual`,`require.requireMock`];function He(e,t,n){let{node:r}=t;if(w.isMemberExpression(r))return t.matchesPattern(n);if(!w.isIdentifier(r)||n.includes(`.`))return!1;let i=n.split(`.`)[0];return r.name===i}const Ue={CallExpression:(e,t)=>{if(t.moduleResolverVisited.has(e))return;let n=e.get(`callee`);(n&&Ve.some(e=>He(t,n,e))||w.isImport(e.node.callee))&&(t.moduleResolverVisited.add(e),Be(e.get(`arguments.0`),t))},"ImportDeclaration|ExportDeclaration|ExportAllDeclaration":(e,t)=>{!e||!e.get(`source`)||t.moduleResolverVisited.has(e)||(t.moduleResolverVisited.add(e),Be(e.get(`source`),t))}},We=e=>(0,ue.declare)(function(t){let n=new Set;return{name:`powerlines:module-resolver`,manipulateOptions(e){e.filename??=`unknown`},pre(){n=new Set},visitor:{Program:{enter(r,i){r.traverse(Ue,{...i,context:e,moduleResolverVisited:n,api:t})},exit(r,i){r.traverse(Ue,{...i,context:e,moduleResolverVisited:n,api:t})}}},post(){n.clear()}}});var Ge=class extends de.InMemoryFileSystemHost{#e;constructor(e){super(),this.#e=e}deleteSync(e){this.#e.fs.removeSync(e)}readDirSync(e){return this.#e.fs.isDirectorySync(e)?this.#e.fs.listSync(e).reduce((e,t)=>{let n=this.#e.fs.resolveSync(t);return n&&e.push({name:t,isDirectory:this.#e.fs.isDirectorySync(n),isFile:this.#e.fs.isFileSync(n),isSymlink:!1}),e},[]):[]}async readFile(e){return this.#e.fs.isFileSync(e)?await this.#e.fs.read(e):``}readFileSync(e){return this.#e.fs.isFileSync(e)?this.#e.fs.readSync(e):``}async writeFile(e,t){return this.#e.fs.write(e,t)}writeFileSync(e,t){this.#e.fs.writeSync(e,t)}async mkdir(e){await this.#e.fs.mkdir(e)}mkdirSync(e){this.#e.fs.mkdirSync(e)}async move(e,t){await this.#e.fs.move(e,t)}moveSync(e,t){this.#e.fs.moveSync(e,t)}async copy(e,t){await this.#e.fs.copy(e,t)}copySync(e,t){this.#e.fs.copySync(e,t)}async fileExists(e){return this.#e.fs.isFile(e)}fileExistsSync(e){return this.#e.fs.isFileSync(e)}async directoryExists(e){return this.#e.fs.isDirectory(e)}directoryExistsSync(e){return this.#e.fs.isDirectorySync(e)}realpathSync(e){return this.#e.fs.resolveSync(e)||e}getCurrentDirectory(){return this.#e.workspaceConfig.workspaceRoot}async glob(e){return this.#e.fs.glob(e)}globSync(e){return this.#e.fs.globSync(e)}};function Ke(e,t){return e.log(c.LogLevelLabel.TRACE,`Creating ts-morph Project instance with configuration from: ${e.tsconfig.tsconfigFilePath}.`),new de.Project((0,l.default)(t??{},{skipAddingFilesFromTsConfig:!1,tsConfigFilePath:e.tsconfig.tsconfigFilePath,fileSystem:new Ge(e),compilerOptions:(0,l.default)(e.tsconfig.options??{},{lib:[`lib.esnext.full.d.ts`]})}))}function qe(e){return e.replace(/import\s*(?:type\s*)?\{?[\w,\s]*(?:\}\s*)?from\s*(?:'|")@?[a-zA-Z0-9-\\/.]*(?:'|");?/g,``).replaceAll(`#private;`,``).replace(/__Ω/g,``)}async function Je(e,t){e.log(c.LogLevelLabel.TRACE,`Running the TypeScript compiler for ${t.length} generated runtime files.`);let n=Ke(e,{skipAddingFilesFromTsConfig:!0});n.addSourceFilesAtPaths(t);let r=n.emitToMemory({emitOnlyDtsFiles:!0}),i=``;for(let t of r.getFiles())if(!t.filePath.endsWith(`.map`)&&e.builtins.some(n=>n===t.filePath||e.fs.metadata[n]?.id&&e.fs.metadata[n]?.id===t.filePath)){let n=await e.fs.resolve(t.filePath);i+=`
2
- declare module "${n}" {
3
- ${t.text.trim().replace(/^\s*export\s*declare\s*/gm,`export `).replace(/^\s*declare\s*/gm,``)}
4
- }
5
- `}let a=[];r.getDiagnostics().forEach(e=>{e.getSourceFile()?.getBaseName()?a.push(`${e.getSourceFile()?.getBaseName()} (${(e.getLineNumber()??0)+1}): ${(0,T.flattenDiagnosticMessageText)(e.getMessageText().toString(),`
6
- `)}`):a.push((0,T.flattenDiagnosticMessageText)(e.getMessageText().toString(),`
7
- `))});let o=a.join(`
8
- `);if(o)throw Error(`TypeScript compilation failed: \n\n${o.length>5e3?`${o.slice(0,5e3)}...`:o}`);return qe(i)}const Ye=(0,l.createDefu)((e,t,n)=>(0,E.isString)(e[t])&&(0,E.isString)(n)?(e[t]=`${e[t]||``}\n${n||``}`.trim(),!0):!1);async function Xe(e,t,n,...r){let i=e.selectHooks(t,n);if(i.length>0){e.log(c.LogLevelLabel.DEBUG,` 🧩 Calling plugin hook: ${S.default.bold.cyanBright(`${t}${n?.order?` (${n.order})`:``}`)}`);let a=[];if(n?.sequential===!1)a=await Promise.all(i.map(async e=>{if(!(0,y.isFunction)(e.handle))throw Error(`Plugin hook handler for hook "${t}" is not a function.`);return Promise.resolve(e.handle.apply(e.context,[...r]))}));else for(let e of i){if(!(0,y.isFunction)(e.handle))throw Error(`Plugin hook handler for hook "${t}" is not a function.`);if(n?.result===`first`||n?.asNextParam===!1){if(a.push(await Promise.resolve(e.handle.apply(e.context,[...r]))),n?.result===`first`&&(0,le.isSet)(a[a.length-1]))break}else{let t=[...r];a.length>0&&t.length>0&&(t[0]=(0,y.isFunction)(n.asNextParam)?await Promise.resolve(n.asNextParam(a[0])):a[0]);let i=await Promise.resolve(e.handle.apply(e.context,[...t]));i&&(n?.result===`last`?a=[i]:(0,E.isString)(i)?a=[`${(0,E.isString)(a[0])&&a[0]||``}\n${i||``}`.trim()]:(0,se.isObject)(i)&&(a=[Ye(i,a[0]??{})]))}}let o=a.filter(e=>(0,le.isSet)(e));if(o.length>0){let e;for(let t of o)e=(0,l.defu)(t,e??{});return e}}}async function Ze(e,t,n=!1){if(await(0,h.isPackageListed)((0,D.getPackageName)(t),{cwd:e.config.projectRoot})){if((0,D.hasPackageVersion)(t)&&!process.env.POWERLINES_SKIP_VERSION_CHECK&&!await(0,h.doesPackageMatch)((0,D.getPackageName)(t),(0,D.getPackageVersion)(t),e.config.projectRoot)){let n=await(0,h.getPackageListing)((0,D.getPackageName)(t),{cwd:e.config.projectRoot});!n?.version.startsWith(`catalog:`)&&!n?.version.startsWith(`workspace:`)&&e.log(c.LogLevelLabel.WARN,`The package "${(0,D.getPackageName)(t)}" is installed but does not match the expected version ${(0,D.getPackageVersion)(t)} (installed version: ${n?.version||`<Unknown>`}). Please ensure this is intentional before proceeding. Note: You can skip this validation with the "STORM_STACK_SKIP_VERSION_CHECK" environment variable.`)}}else if(e.config.skipInstalls!==!0){e.log(c.LogLevelLabel.WARN,`The package "${t}" is not installed. It will be installed automatically.`);let r=await(0,ie.install)(t,{cwd:e.config.projectRoot,dev:n});if((0,oe.isNumber)(r.exitCode)&&r.exitCode>0)throw e.log(c.LogLevelLabel.ERROR,r.stderr),Error(`An error occurred while installing the package "${t}"`)}else e.log(c.LogLevelLabel.WARN,`The package "${t}" is not installed. Since the "skipInstalls" option is set to true, it will not be installed automatically.`)}async function Qe(e){if(e.log(c.LogLevelLabel.TRACE,`Checking and installing missing project dependencies.`),e.dependencies??={},e.devDependencies??={},Object.keys(e.dependencies).length===0&&Object.keys(e.devDependencies).length===0){e.log(c.LogLevelLabel.TRACE,`No dependencies or devDependencies to install. Skipping installation step.`);return}e.log(c.LogLevelLabel.DEBUG,`The following packages are required: \nDependencies: \n${Object.entries(e.dependencies).map(([e,t])=>`- ${e}@${String(t)}`).join(`
9
- `)}\n\nDevDependencies: \n${Object.entries(e.devDependencies).map(([e,t])=>`- ${e}@${String(t)}`).join(`
10
- `)}`),await Promise.all([Promise.all(Object.entries(e.dependencies).map(async([t,n])=>Ze(e,`${(0,D.getPackageName)(t)}@${String(n)}`,!1))),Promise.all(Object.entries(e.devDependencies).map(async([t,n])=>Ze(e,`${(0,D.getPackageName)(t)}@${String(n)}`,!0)))])}function U(e,t,n){let r;if(n?r=W(e,t,n):(r=W(e,t,`tsconfig.app.json`),r||(r=W(e,t,`tsconfig.lib.json`),r||=W(e,t,`tsconfig.json`))),!r)throw Error(`Cannot find the \`tsconfig.json\` configuration file for the project at ${t}.`);return r}function W(e,t,n){let r=n;if(!(!(0,M.existsSync)(r)&&(r=(0,_.appendPath)(n,t),!(0,M.existsSync)(r)&&(r=(0,_.appendPath)(n,(0,_.appendPath)(t,e)),!(0,M.existsSync)(r)))))return r}function $e(e,t,n=[`.ts`,`.tsx`,`.d.ts`]){return t.find(t=>e?.toString().toLowerCase()===t?.toString().toLowerCase()||e?.toString().toLowerCase()===`./${t?.toString().toLowerCase()}`||`./${e?.toString().toLowerCase()}`===t?.toString().toLowerCase()||n.some(n=>`${e?.toString().toLowerCase()}${n}`===t?.toString().toLowerCase()||`${e?.toString().toLowerCase()}${n}`==`./${t?.toString().toLowerCase()}`||`${t?.toString().toLowerCase()}${n}`==`./${e?.toString().toLowerCase()}`||e?.toString().toLowerCase()===`${t?.toString().toLowerCase()}${n}`||e?.toString().toLowerCase()===`./${t?.toString().toLowerCase()}${n}`||t?.toString().toLowerCase()===`./${e?.toString().toLowerCase()}${n}`))}function et(e,t){return $e(e,t,`.ts,.tsx,.d.ts,.js,.jsx,.mjs,.cjs,.mts,.cts,/*.ts,/*.tsx,/*.d.ts,/*.js,/*.jsx,/*.mjs,/*.cjs,/*.mts,/*.cts,/**/*.ts,/**/*.tsx,/**/*.d.ts,/**/*.js,/**/*.jsx,/**/*.mjs,/**/*.cjs,/**/*.mts,/**/*.cts`.split(`,`))}function tt(e,t){return et(e,t)!==void 0}function G(e,t,n,r={},i,a=T.default.sys){let o=U(e,t,n),s=(0,O.readJsonFileSync)(o);if(!s)throw Error(`Cannot find the \`tsconfig.json\` configuration file at ${(0,d.joinPaths)(t,n??`tsconfig.json`)}`);let c=T.default.parseJsonConfigFileContent((0,l.default)(r??{},s),a,(0,_.appendPath)(t,e));if(c.errors.length>0){let e=`Cannot parse the TypeScript compiler options. Please investigate the following issues:
11
- ${c.errors.map(e=>`- ${(e.category!==void 0&&e.code?`[${e.category}-${e.code}]: `:``)+e.messageText.toString()}`).join(`
12
- `)}
13
- `;throw Error(e)}return{...c,originalTsconfigJson:i??s,tsconfigJson:s,tsconfigFilePath:o}}function nt(e){return(0,d.joinPaths)((0,A.relativePath)((0,d.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot),(0,A.findFilePath)(e.dtsPath)),(0,A.findFileName)(e.dtsPath))}async function rt(e){let t=G(e.workspaceConfig.workspaceRoot,e.config.projectRoot,e.config.tsconfig,e.config.tsconfigRaw),n=await(0,O.readJsonFile)(U(e.workspaceConfig.workspaceRoot,e.config.projectRoot,e.config.tsconfig));if(n.compilerOptions??={},e.config.output.dts!==!1){let t=nt(e);n.include?.some(n=>tt(n,[e.dtsPath,t]))||(n.include??=[],n.include.push(t.startsWith(`./`)?t.slice(2):t))}return t.options.lib?.some(e=>[`lib.esnext.d.ts`,`lib.es2021.d.ts`,`lib.es2022.d.ts`,`lib.es2023.d.ts`].includes(e.toLowerCase()))||(n.compilerOptions.lib??=[],n.compilerOptions.lib.push(`esnext`)),t.options.esModuleInterop!==!0&&(n.compilerOptions.esModuleInterop=!0),t.options.isolatedModules!==!0&&(n.compilerOptions.isolatedModules=!0),e.config.build.platform===`node`&&(t.options.types?.some(e=>e.toLowerCase()===`node`||e.toLowerCase()===`@types/node`)||(n.compilerOptions.types??=[],n.compilerOptions.types.push(`node`))),n}async function it(e){if(e.log(c.LogLevelLabel.TRACE,`Initializing TypeScript configuration (tsconfig.json) for the Powerlines project.`),!(0,h.isPackageExists)(`typescript`))throw Error(`The TypeScript package is not installed. Please install the package using the command: "npm install typescript --save-dev"`);let t=U(e.workspaceConfig.workspaceRoot,e.config.projectRoot,e.config.tsconfig);e.tsconfig.originalTsconfigJson=await(0,O.readJsonFile)(t),e.tsconfig.tsconfigJson=await rt(e),e.log(c.LogLevelLabel.TRACE,`Writing updated TypeScript configuration (tsconfig.json) file to disk.`),await e.fs.write(t,k.StormJSON.stringify(e.tsconfig.tsconfigJson)),e.tsconfig=G(e.workspaceConfig.workspaceRoot,e.config.projectRoot,e.config.tsconfig,e.config.tsconfigRaw,e.tsconfig.originalTsconfigJson)}async function at(e){let t=await(0,O.readJsonFile)(e.tsconfig.tsconfigFilePath);t?.compilerOptions?.types&&Array.isArray(t.compilerOptions.types)&&!t.compilerOptions.types.length&&delete t.compilerOptions.types;let n=(0,fe.getObjectDiff)(e.tsconfig.originalTsconfigJson,t,{ignoreArrayOrder:!0,showOnly:{statuses:[`added`,`deleted`,`updated`],granularity:`deep`}}),r=[],i=(e,t)=>{if(e.status===`added`||e.status===`deleted`||e.status===`updated`)if(e.diff)for(let n of e.diff)i(n,t?`${t}.${e.property}`:e.property);else r.push({field:t?`${t}.${e.property}`:e.property,status:e.status,previous:e.status===`added`?`---`:k.StormJSON.stringify(e.previousValue),current:e.status===`deleted`?`---`:k.StormJSON.stringify(e.currentValue)})};for(let e of n.diff)i(e);if(r.length>0&&e.log(c.LogLevelLabel.WARN,`Updating the following configuration values in "${e.tsconfig.tsconfigFilePath}" file:
14
-
15
- ${r.map((e,t)=>`${S.default.bold.whiteBright(`${t+1}. ${(0,j.titleCase)(e.status)} the ${e.field} field: `)}
16
- ${S.default.red(` - Previous: ${e.previous} `)}
17
- ${S.default.green(` - Updated: ${e.current} `)}
18
- `).join(`
19
- `)}
20
- `),await e.fs.write(e.tsconfig.tsconfigFilePath,k.StormJSON.stringify(t)),e.tsconfig=G(e.workspaceConfig.workspaceRoot,e.config.projectRoot,e.config.tsconfig),!e.tsconfig)throw Error(`Failed to parse the TypeScript configuration file.`)}const ot=`default`;function st(e,t){return(0,l.default)(t.environments?.[e]??{},{name:e,title:t.title||(0,j.titleCase)(t.name),ssr:!1,mainFields:t.build?.platform===`browser`?[`browser`,`module`,`jsnext:main`,`jsnext`]:[`module`,`jsnext:main`,`jsnext`],extensions:[`.mjs`,`.js`,`.mts`,`.ts`,`.jsx`,`.tsx`,`.json`],consumer:t.build?.platform===`browser`?`client`:`server`,preview:t.build?.platform===`browser`?{port:5173,open:!0,strictPort:!1,host:`localhost`,allowedHosts:[`.`],cors:!0,headers:{}}:void 0},t)}function ct(e){return st(`default`,e)}async function lt(e,t){return(0,l.default)({workspaceRoot:e},await(0,pe.getWorkspaceConfig)(!0,{cwd:t,workspaceRoot:e,useDefault:!0}))}async function ut(e,t,n,r,i=`production`,a,o=`powerlines`){let s={},c;if(a&&(c=(0,M.existsSync)((0,v.replacePath)(a,e))?(0,v.replacePath)(a,e):(0,M.existsSync)((0,d.joinPaths)((0,_.appendPath)(e,t),(0,v.replacePath)(a,e)))?(0,d.joinPaths)((0,_.appendPath)(e,t),(0,v.replacePath)(a,e)):(0,M.existsSync)((0,d.joinPaths)((0,_.appendPath)(e,t),a))?(0,d.joinPaths)((0,_.appendPath)(e,t),a):void 0),c||=(0,M.existsSync)((0,d.joinPaths)((0,_.appendPath)(e,t),`${o}.${i}.config.ts`))?(0,d.joinPaths)((0,_.appendPath)(e,t),`${o}.${i}.config.ts`):(0,M.existsSync)((0,d.joinPaths)((0,_.appendPath)(e,t),`${o}.${i}.config.js`))?(0,d.joinPaths)((0,_.appendPath)(e,t),`${o}.${i}.config.js`):(0,M.existsSync)((0,d.joinPaths)((0,_.appendPath)(e,t),`${o}.${i}.config.mts`))?(0,d.joinPaths)((0,_.appendPath)(e,t),`${o}.${i}.config.mts`):(0,M.existsSync)((0,d.joinPaths)((0,_.appendPath)(e,t),`${o}.${i}.config.mjs`))?(0,d.joinPaths)((0,_.appendPath)(e,t),`${o}.${i}.config.mjs`):(0,M.existsSync)((0,d.joinPaths)((0,_.appendPath)(e,t),`${o}.config.ts`))?(0,d.joinPaths)((0,_.appendPath)(e,t),`${o}.config.ts`):(0,M.existsSync)((0,d.joinPaths)((0,_.appendPath)(e,t),`${o}.config.js`))?(0,d.joinPaths)((0,_.appendPath)(e,t),`${o}.config.js`):(0,M.existsSync)((0,d.joinPaths)((0,_.appendPath)(e,t),`${o}.config.mts`))?(0,d.joinPaths)((0,_.appendPath)(e,t),`${o}.config.mts`):(0,M.existsSync)((0,d.joinPaths)((0,_.appendPath)(e,t),`${o}.config.mjs`))?(0,d.joinPaths)((0,_.appendPath)(e,t),`${o}.config.mjs`):void 0,c){let e=await n.import(n.esmResolve(c));if(e){let t={};(0,y.isFunction)(e)&&(t=await Promise.resolve(e({command:r,mode:i,isSsrBuild:!1,isPreview:!1}))),(0,b.isSetObject)(t)&&(s={...t,config:t,configFile:c})}}let u=await(0,me.loadConfig)({cwd:e,name:o,envName:i,globalRc:!0,packageJson:!0,dotenv:!0,jiti:n});return(0,l.default)(s,(0,b.isSetObject)(u?.config)?{...u.config,...u}:{})}function dt(e){return(0,l.default)(e,{interopDefault:!0,fsCache:e.mode===`development`?!1:(0,d.joinPaths)(e.cacheDir,`jiti`),moduleCache:e.mode!==`development`})}function ft(e){return(0,Se.createJiti)((0,d.joinPaths)(e.workspaceRoot,e.projectRoot),dt({...e}))}function pt(e){let t=(0,Se.createJiti)((0,d.joinPaths)(e.workspaceRoot,e.projectRoot),dt(e));return t.plugin=ft(e),t}const mt=[`new`,`clean`,`prepare`,`lint`,`test`,`build`,`docs`,`deploy`,`finalize`];function K(e){return(0,b.isSetObject)(e)&&`name`in e&&(0,x.isSetString)(e.name)&&((0,z.isUndefined)(e.applyToEnvironment)||`applyToEnvironment`in e&&(0,y.isFunction)(e.applyToEnvironment))&&((0,z.isUndefined)(e.dedupe)||`dedupe`in e&&(0,y.isFunction)(e.dedupe))&&((0,z.isUndefined)(e.dependsOn)||`dependsOn`in e&&Array.isArray(e.dependsOn)&&e.dependsOn.every(_t))&&mt.every(t=>(0,z.isUndefined)(e[t])||t in e&&((0,y.isFunction)(e[t])||(0,b.isSetObject)(e[t])&&`handler`in e[t]&&(0,y.isFunction)(e[t].handler)))}function ht(e){return(0,b.isSetObject)(e)&&`plugin`in e&&(((0,x.isSetString)(e.plugin)||(0,y.isFunction)(e.plugin))&&`options`in e&&(0,b.isSetObject)(e.options)||K(e.plugin))}function gt(e){return Array.isArray(e)&&(e.length===1||e.length===2)&&(((0,x.isSetString)(e[0])||(0,y.isFunction)(e[0]))&&e.length>1&&(0,b.isSetObject)(e[1])||K(e[0]))}function _t(e){return(0,x.isSetString)(e)||(0,y.isFunction)(e)||K(e)||ht(e)||gt(e)}function vt(e){return(0,y.isFunction)(e)||(0,b.isSetObject)(e)&&`handler`in e&&(0,y.isFunction)(e.handler)}function yt(e){return(0,b.isSetObject)(e)&&`handler`in e&&(0,y.isFunction)(e.handler)}function bt(e){return vt(e)||yt(e)}function xt(e){return(0,y.isFunction)(e)?e:e.handler}function St(e){return e.startsWith(`vite:`)||e.startsWith(`esbuild:`)||e.startsWith(`rolldown:`)||e.startsWith(`rollup:`)||e.startsWith(`webpack:`)||e.startsWith(`rspack:`)||e.startsWith(`farm:`)}function q(e,t){return e.dedupe===!1||t.some(t=>t.dedupe!==!1&&((0,y.isFunction)(t.dedupe)&&t.dedupe(e)||t.name===e.name))}function Ct(e,t,n,r){q(t,r.map(e=>e.plugin))||r.push((0,y.isFunction)(n)?{plugin:t,handler:xt(n).bind(e)}:{plugin:t,...n,handler:xt(n).bind(e)})}function J(e,t){return t&&t.replaceAll(`{workspaceRoot}`,e.workspaceConfig.workspaceRoot).replaceAll(`{root}`,e.config.projectRoot).replaceAll(`{projectRoot}`,e.config.projectRoot).replaceAll(`{sourceRoot}`,e.config.sourceRoot).replaceAll(`{powerlinesPath}`,e.powerlinesPath).replaceAll(`{cachePath}`,e.cachePath).replaceAll(`{dataPath}`,e.dataPath).replaceAll(`{logPath}`,e.envPaths.log).replaceAll(`{tempPath}`,e.envPaths.temp).replaceAll(`{configPath}`,e.envPaths.config).replaceAll(`{outputPath}`,e.config.output.outputPath).replaceAll(`{buildPath}`,e.config.output.buildPath).replaceAll(`{artifactsPath}`,(0,v.replacePath)(e.artifactsPath,e.workspaceConfig.workspaceRoot)).replaceAll(`{builtinPath}`,(0,v.replacePath)(e.builtinsPath,e.workspaceConfig.workspaceRoot)).replaceAll(`{entryPath}`,(0,v.replacePath)(e.entryPath,e.workspaceConfig.workspaceRoot))}function wt(e,t){return(0,v.replacePath)(t.file,(0,d.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot))}function Tt(e,t){return{file:wt(e,t),name:t.name}}function Et(e,t){return(0,v.replaceExtension)((0,v.replacePath)((0,v.replacePath)((0,v.replacePath)((0,v.replacePath)((0,v.replacePath)(t.file,(0,d.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.sourceRoot)),(0,d.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot)),e.config.sourceRoot),e.config.projectRoot),(0,v.replacePath)(e.config.sourceRoot,e.config.projectRoot)))}function Dt(e,t){let n=Tt(e,t);return{...n,input:n,output:Et(e,t)}}function Ot(e,t){return t.map(t=>(0,E.isString)(t)?J(e,t):J(e,t.file)).map(t=>{let n=(0,Ce.parseTypeDefinition)(t),r=(0,_.appendPath)(n.file,e.config.projectRoot);return(0,we.isFile)(r)?Dt(e,{file:(0,v.replacePath)(r,e.config.projectRoot),name:n.name}):(0,m.listFilesSync)(r).map(t=>Dt(e,{file:t,name:n.name}))}).flat().filter(Boolean)}function kt(e=[]){return(0,P.getUniqueBy)((0,f.toArray)(e),e=>(0,x.isSetString)(e)?e:(0,N.murmurhash)(e??{},{maxLength:24}))}var At=class extends B.Struct{static _capnp={displayName:`KeyValuePair`,id:`eabb26cf58b2a14c`,size:new B.ObjectSize(0,2)};get key(){return B.utils.getText(0,this)}set key(e){B.utils.setText(0,e,this)}get value(){return B.utils.getText(1,this)}set value(e){B.utils.setText(1,e,this)}toString(){return`FileMetadata_KeyValuePair_`+super.toString()}},jt=class e extends B.Struct{static KeyValuePair=At;static _capnp={displayName:`FileMetadata`,id:`8e2cab5d7e28c7b3`,size:new B.ObjectSize(8,3),defaultType:`normal`};static _Properties;get id(){return B.utils.getText(0,this)}set id(e){B.utils.setText(0,e,this)}get type(){return B.utils.getText(1,this,e._capnp.defaultType)}set type(e){B.utils.setText(1,e,this)}get timestamp(){return B.utils.getUint32(0,this)}set timestamp(e){B.utils.setUint32(0,e,this)}_adoptProperties(e){B.utils.adopt(e,B.utils.getPointer(2,this))}_disownProperties(){return B.utils.disown(this.properties)}get properties(){return B.utils.getList(2,e._Properties,this)}_hasProperties(){return!B.utils.isNull(B.utils.getPointer(2,this))}_initProperties(t){return B.utils.initList(2,e._Properties,t,this)}set properties(e){B.utils.copyFrom(e,B.utils.getPointer(2,this))}toString(){return`FileMetadata_`+super.toString()}},Mt=class extends B.Struct{static _capnp={displayName:`FileId`,id:`990d6a471072f997`,size:new B.ObjectSize(0,2)};get id(){return B.utils.getText(0,this)}set id(e){B.utils.setText(0,e,this)}get path(){return B.utils.getText(1,this)}set path(e){B.utils.setText(1,e,this)}toString(){return`FileId_`+super.toString()}},Nt=class extends B.Struct{static _capnp={displayName:`FileStorage`,id:`9dca66ac858c9ebe`,size:new B.ObjectSize(0,2)};get path(){return B.utils.getText(0,this)}set path(e){B.utils.setText(0,e,this)}get code(){return B.utils.getText(1,this)}set code(e){B.utils.setText(1,e,this)}toString(){return`FileStorage_`+super.toString()}},Y=class e extends B.Struct{static _capnp={displayName:`FileSystem`,id:`ae0c23d43e56abcf`,size:new B.ObjectSize(0,3)};static _Ids;static _Storage;static _Metadata;_adoptIds(e){B.utils.adopt(e,B.utils.getPointer(0,this))}_disownIds(){return B.utils.disown(this.ids)}get ids(){return B.utils.getList(0,e._Ids,this)}_hasIds(){return!B.utils.isNull(B.utils.getPointer(0,this))}_initIds(t){return B.utils.initList(0,e._Ids,t,this)}set ids(e){B.utils.copyFrom(e,B.utils.getPointer(0,this))}_adoptStorage(e){B.utils.adopt(e,B.utils.getPointer(1,this))}_disownStorage(){return B.utils.disown(this.storage)}get storage(){return B.utils.getList(1,e._Storage,this)}_hasStorage(){return!B.utils.isNull(B.utils.getPointer(1,this))}_initStorage(t){return B.utils.initList(1,e._Storage,t,this)}set storage(e){B.utils.copyFrom(e,B.utils.getPointer(1,this))}_adoptMetadata(e){B.utils.adopt(e,B.utils.getPointer(2,this))}_disownMetadata(){return B.utils.disown(this.metadata)}get metadata(){return B.utils.getList(2,e._Metadata,this)}_hasMetadata(){return!B.utils.isNull(B.utils.getPointer(2,this))}_initMetadata(t){return B.utils.initList(2,e._Metadata,t,this)}set metadata(e){B.utils.copyFrom(e,B.utils.getPointer(2,this))}toString(){return`FileSystem_`+super.toString()}};jt._Properties=B.CompositeList(At),Y._Ids=B.CompositeList(Mt),Y._Storage=B.CompositeList(Nt),Y._Metadata=B.CompositeList(jt);let Pt=function(e){return e.VIRTUAL=`virtual`,e.FS=`fs`,e}({});const Ft=(e,t={})=>{let n=t.logLevel===null?c.LogLevelLabel.SILENT:t.logLevel||c.LogLevelLabel.INFO;return n===c.LogLevelLabel.SILENT?je.noop:t.customLogger?t.customLogger:(r,...i)=>(0,ke.getLogFn)((0,ke.getLogLevel)(r),{...t,logLevel:n})(`${S.default.bold.hex((0,Ae.getColor)(`brand`,t))(`powerlines${e?`:${e}`:``}${t.name?` ${S.default.gray(`> `)}${t.name}`:``} ${S.default.gray(`> `)}`)}${i.join(` `)} `.trim())},X=[`#00A0DD`,`#6FCE4E`,`#FBBF24`,`#F43F5E`,`#3B82F6`,`#A855F7`,`#469592`,`#288EDF`,`#10B981`,`#EF4444`,`#F0EC56`,`#F472B6`,`#22D3EE`,`#EAB308`,`#84CC16`,`#F87171`,`#0EA5E9`,`#D946EF`,`#FACC15`,`#34D399`],It=(e,t)=>(n,...r)=>e(n,` ${S.default.inverse.hex(X[t.split(``).map(e=>e.charCodeAt(0)).reduce((e,t)=>e+t,0)%X.length]||X[0])(` ${(0,j.titleCase)(t)} `)} ${r.join(` `)} `);function Lt(e){return(0,ae.isError)(e)&&`code`in e&&e.code}function Z(e){return Lt(e)&&(e.code===`ENOENT`||e.code===`EISDIR`?null:e)}function Q(e){return(0,Me.correctPath)((0,Ne.slash)(e?.toString()||`.`).replace(/^file:\/\//,``))}function Rt(e,t=`powerlines`){return e.replace(/^\\0/,``).startsWith(`${t.replace(/:$/,``)}`)}function zt(e,t=`powerlines`){return`${t.replace(/:$/,``)}:${Q(e).replace(RegExp(`^${t.replace(/:$/,``)}:`),``).replace(/^\\0/,``).replace((0,A.findFileDotExtensionSafe)(Q(e)),``)}`}function Bt(e,t,n=`powerlines`){return(0,F.isAbsolutePath)(e)?e:Rt(Q(e),n)?zt(Q(e),n).replace(RegExp(`^${n.replace(/:$/,``)}:`),t):Q(e)}function Vt(e,t){return(0,P.getUnique)((0,f.toArray)(t).map(t=>(0,b.isSetObject)(t)&&((0,x.isSetString)(t.input)||(0,x.isSetString)(t.glob))?(0,I.joinPaths)(t.input||e,t.glob||`**/*`):(0,x.isSetString)(t)?t:void 0).filter(x.isSetString))}var Ht=class{#e=!1;options;constructor(e={base:`/`}){this.options=e,this.options.base=(0,Re.resolve)(e.base),this.options.isReadOnly=!!e.isReadOnly}async exists(e){return this.existsSync(e)}async get(e){return this.getSync(e)}async set(e,t){this.options.isReadOnly||this.setSync(e,t)}mkdirSync(e){}async mkdir(e){return Promise.resolve(this.mkdirSync(e))}async remove(e){this.options.isReadOnly||this.removeSync(e)}clearSync(e){if(!this.options.isReadOnly){let t=this.listSync(e||this.options.base);if(!t.length)return;t.map(t=>this.removeSync(e&&!t.startsWith(e)?(0,I.joinPaths)(e,t):t))}}async clear(e){if(!this.options.isReadOnly){let t=await this.list(e||this.options.base);if(!t.length)return;await Promise.all(t.map(async t=>this.remove(e&&!t.startsWith(e)?(0,I.joinPaths)(e,t):t)))}}async list(e){return this.listSync(e)}isDirectorySync(e){return!1}async isDirectory(e){return Promise.resolve(this.isDirectorySync(e))}isFileSync(e){return this.existsSync(e)&&!this.isDirectorySync(e)}async isFile(e){return Promise.resolve(this.isFileSync(e))}dispose(){return Promise.resolve()}async[Symbol.asyncDispose](){return this._dispose()}resolve(e=this.options.base){if(/\.\.:|\.\.$/.test(e))throw Error(`[${this.name}]: Invalid key: ${JSON.stringify(e)} provided to storage adapter.`);return(0,_.appendPath)((0,Me.correctPath)(e).replace(/:/g,`/`),this.options.base)}async _dispose(){this.#e||=(await Promise.resolve(this.dispose()),!0)}},Ut=class extends Ht{name=`file-system`;constructor(e){super(e)}existsSync(e){return(0,M.existsSync)(this.resolve(e))}async exists(e){return(0,M.exists)(this.resolve(e))}getSync(e){return(0,Pe.readFileSync)(this.resolve(e))}async get(e){return(0,Pe.readFile)(this.resolve(e))}setSync(e,t){if(!this.options.isReadOnly)return(0,Fe.writeFileSync)(this.resolve(e),t)}async set(e,t){if(!this.options.isReadOnly)return(0,Fe.writeFile)(this.resolve(e),t)}removeSync(e){if(!this.options.isReadOnly)try{return(0,Ie.unlinkSync)(this.resolve(e))}catch(e){return Z(e)}}async remove(e){if(!this.options.isReadOnly)return(0,Le.unlink)(this.resolve(e)).catch(Z)}mkdirSync(e){(0,p.createDirectorySync)(this.resolve(e))}async mkdir(e){await(0,p.createDirectory)(this.resolve(e))}listSync(e){try{return(0,m.listFilesSync)(this.resolve(e),{ignore:this.options.ignore})}catch(e){return Z(e)??[]}}async list(e){return(0,m.listFiles)(this.resolve(e),{ignore:this.options.ignore}).catch(Z).then(e=>e||[])}isDirectorySync(e){return(0,we.isDirectory)(this.resolve(e))}isFileSync(e){return!(0,we.isFile)(this.resolve(e))}},$=class extends Ht{name=`virtual`;data=new Map;constructor(e){super(e)}existsSync(e){return this.data.has(this.resolve(e))}getSync(e){return this.data.get(this.resolve(e))??null}setSync(e,t){this.options.isReadOnly||this.data.set(this.resolve(e),t)}removeSync(e){this.options.isReadOnly||this.data.delete(this.resolve(e))}listSync(e){return[...this.data.keys().filter(t=>e?(0,V.isParentPath)(t,this.resolve(e)):!0)]}async dispose(){return this.clear()}},Wt=class e{#e;#t;#n;#r={"":new Ut};#i;#a=!1;#o;#s;#c(e){let t=e;return(0,V.isParentPath)(t,this.#o.builtinsPath)&&(t=(0,v.replacePath)(t,this.#o.builtinsPath)),zt(t,this.#o.config.output.builtinPrefix)}#l(e){return Bt(e.includes(`{`)||e.includes(`}`)?J(this.#o,e):e,this.#o.builtinsPath,this.#o.config.output.builtinPrefix)}#u(e){let t=`::GLOBSTAR::`;return RegExp(`^${this.#l(e).replace(/\*\*/g,t).replace(/[.+^${}()|[\]\\]/g,`\\$&`).replace(/\*/g,`[^/]*`).replace(/\?/g,`[^/]`).replace(new RegExp(t,`g`),`.*`)}$`)}#d(e){let t=this.resolveSync(this.#l(e))||e;for(let e of Object.keys(this.#r).filter(Boolean).sort().reverse())if((0,V.isParentPath)(t,e))return{base:e,relativeKey:(0,v.replacePath)(t,e),adapter:this.#r[e]};return{base:``,relativeKey:t,adapter:this.#r[``]}}#f(e=``,t=!1){return Object.keys(this.#r).sort().reverse().filter(n=>(0,V.isParentPath)(n,e)||t&&(0,V.isParentPath)(e,n)).map(t=>({relativeBase:e.length>t.length?e.slice(t.length):void 0,base:t,adapter:this.#r[t]}))}static async create(t){if(!t.config.skipCache&&(0,M.existsSync)((0,d.joinPaths)(t.dataPath,`fs.bin`))){let n=await(0,Te.readFileBuffer)((0,d.joinPaths)(t.dataPath,`fs.bin`)),r=new B.Message(n,!1).getRoot(Y),i=new e(t,r);r._hasStorage()&&r.storage.length>0&&await Promise.all(r.storage.values().map(async e=>{await i.write(e.path,e.code)}))}return new e(t,new B.Message().initRoot(Y))}static createSync(t){if(!t.config.skipCache&&(0,M.existsSync)((0,d.joinPaths)(t.dataPath,`fs.bin`))){let n=(0,Te.readFileBufferSync)((0,d.joinPaths)(t.dataPath,`fs.bin`)),r=new B.Message(n,!1).getRoot(Y),i=new e(t,r);r._hasStorage()&&r.storage.length>0&&r.storage.values().map(e=>{i.writeSync(e.path,e.code)})}return new e(t,new B.Message().initRoot(Y))}get metadata(){return new Proxy(this.#e,{get:(e,t)=>e[this.#c(t)]})}get ids(){return new Proxy(this.#n,{get:(e,t)=>e[this.#l(t)]})}get paths(){return new Proxy(this.#n,{get:(e,t)=>e[this.#c(t)]})}get resolverCache(){return this.#i||=(0,be.create)({cacheId:`module-resolution`,cacheDir:this.#o.cachePath,ttl:3600*1e3,lruSize:5e3,persistInterval:100}),this.#i}constructor(e,t){this.#o=e,(0,b.isSetObject)(this.#o.config.output.storage)&&(this.#r={...this.#r,...this.#o.config.output.storage}),this.#r.virtual??=new $({base:`/_virtual`}),this.#o.config.output.storage!==Pt.FS&&(this.#r[this.#o.artifactsPath]??=new $({base:this.#o.artifactsPath}),this.#r[this.#o.builtinsPath]??=new $({base:this.#o.builtinsPath}),this.#r[this.#o.entryPath]??=new $({base:this.#o.entryPath})),this.#e={},t._hasMetadata()&&(this.#e=t.metadata.values().reduce((e,t)=>(e[t.id]={id:t.id,type:t.type,timestamp:t.timestamp||Date.now(),properties:t._hasProperties()?t.properties.values().reduce((e,t)=>(e[t.key]=t.value,e),{}):{}},e),{})),this.#t={},this.#n={},t._hasIds()&&(this.#t=t.ids.values().reduce((e,t)=>(e[t.path]??=t.id,e),{}),this.#n=t.ids.values().reduce((e,t)=>(e[t.id]??=t.path,e),{})),this.#s=It(this.#o.log,`file-system`)}async exists(e){let{relativeKey:t,adapter:n}=this.#d(e);return n.exists(t)}existsSync(e){let{relativeKey:t,adapter:n}=this.#d(e);return n.existsSync(t)}isVirtual(e){let t=this.resolveSync(e);return t?this.#d(t)?.adapter?.name===`virtual`:!1}isDirectorySync(e){let t=this.resolveSync(e);return t?!!(this.existsSync(t)&&this.#d(t)?.adapter?.isDirectorySync(t)):!1}async isDirectory(e){let t=await this.resolve(e);return t?!!(await this.exists(t)&&await this.#d(t)?.adapter?.isDirectory(t)):!1}isFileSync(e){let t=this.resolveSync(e);return t?this.#d(t)?.adapter?.isFileSync(t)??!1:!1}async isFile(e){let t=await this.resolve(e);return t?await this.#d(t)?.adapter?.isFile(t)??!1:!1}listSync(e){return(0,P.getUnique)(this.#f(e,!0).map(e=>e.adapter.listSync(e.relativeBase?e.base?(0,_.appendPath)(e.relativeBase,e.base):e.relativeBase:e.base)).flat())}async list(e){return(0,P.getUnique)((await Promise.all(this.#f(e,!0).map(async e=>e.adapter.list(e.relativeBase?e.base?(0,_.appendPath)(e.relativeBase,e.base):e.relativeBase:e.base)))).flat())}async remove(e){let t=this.#l(e);this.#s(c.LogLevelLabel.TRACE,`Removing file: ${t}`);let{relativeKey:n,adapter:r}=this.#d(t);(0,A.hasFileExtension)(t)?await r.remove(n):await r.clear(n);let i=this.#t[t];i&&this.#e[i]&&(delete this.#e[i],delete this.#t[t],delete this.#n[i])}removeSync(e){let t=this.#l(e);this.#s(c.LogLevelLabel.TRACE,`Removing file: ${t}`);let{relativeKey:n,adapter:r}=this.#d(t);(0,A.hasFileExtension)(t)?r.removeSync(n):r.clearSync(n);let i=this.#t[t];i&&this.#e[i]&&(delete this.#e[i],delete this.#t[t],delete this.#n[i])}async glob(e){let t=[];for(let n of Vt(this.#o.workspaceConfig.workspaceRoot,e)){let e=this.#l(n);if(!/[*?[\]{}]/.test(e)&&!e.includes(`**`)){if(this.isDirectorySync(e))t.push(...await this.list(e));else{let n=await this.resolve(e);n&&!t.includes(n)&&t.push(n)}continue}let r=(0,F.isAbsolutePath)(e)?e:this.#l((0,d.joinPaths)(this.#o.workspaceConfig.workspaceRoot,e)),i=r.search(/[*?[\]{}]/),a=i===-1?(0,A.findFilePath)(r):r.slice(0,Math.max(0,r.lastIndexOf(`/`,i)));await Promise.all((await this.list(a&&(0,F.isAbsolutePath)(a)?a:this.#o.workspaceConfig.workspaceRoot)).map(async e=>{if(this.#u(r).test(e)){let n=this.resolveSync(e);n&&!t.includes(n)&&t.push(n)}}))}return t}globSync(e){let t=[];for(let n of Vt(this.#o.workspaceConfig.workspaceRoot,e)){let e=this.#l(n);if(!/[*?[\]{}]/.test(e)&&!e.includes(`**`)){if(this.isDirectorySync(e))t.push(...this.listSync(e));else{let n=this.resolveSync(e);n&&!t.includes(n)&&t.push(n)}continue}let r=(0,F.isAbsolutePath)(e)?e:this.#l((0,d.joinPaths)(this.#o.workspaceConfig.workspaceRoot,e)),i=r.search(/[*?[\]{}]/),a=i===-1?(0,A.findFilePath)(r):r.slice(0,Math.max(0,r.lastIndexOf(`/`,i))),o=this.listSync(a&&(0,F.isAbsolutePath)(a)?a:this.#o.workspaceConfig.workspaceRoot);for(let e of o)if(this.#u(r).test(e)){let n=this.resolveSync(e);n&&!t.includes(n)&&t.push(n)}}return t}async copy(e,t){let n=e instanceof URL?(0,H.fileURLToPath)(e):e,r=t instanceof URL?(0,H.fileURLToPath)(t):t;if(!(0,x.isSetString)(n)&&(!(0,b.isSetObject)(n)||!(0,x.isSetString)(n.input))||!(0,x.isSetString)(r))return;let i=(0,E.isString)(n)?n:n.input?n.input:this.#o.workspaceConfig.workspaceRoot,a=await this.resolve(i);if(a)if(this.isDirectorySync(a)||(0,x.isSetString)(n)&&n.includes(`*`)||(0,b.isSetObject)(n)&&(0,x.isSetString)(n.glob))await Promise.all((await this.glob(n)).map(async e=>this.copy(e,(0,_.appendPath)((0,v.replacePath)(e,i),r))));else{let e=await this.read(a);e!==void 0&&await this.write(this.#l(r),e,{skipFormat:!0})}}copySync(e,t){let n=e instanceof URL?(0,H.fileURLToPath)(e):e,r=t instanceof URL?(0,H.fileURLToPath)(t):t;if(!(0,x.isSetString)(n)&&(!(0,b.isSetObject)(n)||!(0,x.isSetString)(n.input))||!(0,x.isSetString)(r))return;let i=(0,E.isString)(n)?n:n.input?n.input:this.#o.workspaceConfig.workspaceRoot,a=this.resolveSync(i);if(a)if(this.isDirectorySync(a)||(0,x.isSetString)(n)&&n.includes(`*`)||(0,b.isSetObject)(n)&&(0,x.isSetString)(n.glob))this.globSync(n).map(e=>this.copySync(e,(0,_.appendPath)((0,A.findFilePath)((0,v.replacePath)(e,i)),r)));else{let e=this.readSync(a);e!==void 0&&this.writeSync(this.#l((0,A.hasFileExtension)(r)?r:(0,_.appendPath)((0,A.findFileName)(a),r)),e,{skipFormat:!0})}}async move(e,t){(0,A.hasFileExtension)(e)?(await this.copy(e,t),await this.remove(e)):await Promise.all((await this.list(e)).map(async e=>{await this.copy(e,t),await this.remove(e)}))}moveSync(e,t){(0,A.hasFileExtension)(e)?(this.copySync(e,t),this.removeSync(e)):this.listSync(e).forEach(e=>{this.copySync(e,t),this.removeSync(e)})}async read(e){let t=await this.resolve(e);if(!t)return;let{relativeKey:n,adapter:r}=this.#d(t);return this.#s(c.LogLevelLabel.TRACE,`Reading ${r.name} file: ${t}`),await r.get(n)??void 0}readSync(e){let t=this.resolveSync(e);if(!t)return;let{relativeKey:n,adapter:r}=this.#d(t);return this.#s(c.LogLevelLabel.TRACE,`Reading ${r.name} file: ${t}`),r.getSync(n)??void 0}async write(e,t=``,n={}){let r=t;if(!n.skipFormat){let n=await(0,Oe.resolveConfig)(this.#l(e));n&&(r=await(0,Oe.format)(t,{absolutePath:this.#l(e),...n}))}let{relativeKey:i,adapter:a}=this.#d(e);this.#s(c.LogLevelLabel.TRACE,`Writing ${this.#l(i)} to ${a.name===`virtual`?`the virtual file system`:a.name===`file-system`?`the local file system`:a.name} (size: ${(0,Ee.prettyBytes)(new De.Blob((0,f.toArray)(r)).size)})`);let o=n?.meta?.id||this.#c(i);return this.#e[o]={variant:`normal`,timestamp:Date.now(),...n.meta??{}},this.#n[o]=this.#l(i),this.#t[this.#l(i)]=o,a.set(i,r)}writeSync(e,t=``,n={}){let{relativeKey:r,adapter:i}=this.#d(e);this.#s(c.LogLevelLabel.TRACE,`Writing ${this.#l(r)} file to ${i.name===`virtual`?`the virtual file system`:i.name===`file-system`?`the local file system`:i.name} (size: ${(0,Ee.prettyBytes)(new De.Blob((0,f.toArray)(t)).size)})`);let a=n?.meta?.id||this.#c(r);return this.#e[a]={variant:`normal`,timestamp:Date.now(),...n.meta??{}},this.#n[a]=this.#l(r),this.#t[this.#l(r)]=a,i.setSync(r,t)}mkdirSync(e){return this.#d(e)?.adapter?.mkdirSync(e)}async mkdir(e){return this.#d(e)?.adapter?.mkdir(e)}getMetadata(e){let t=this.resolveSync(e);if(t&&this.metadata[t])return this.metadata[t]}async resolve(e,t,n={}){let r=e;if((r.includes(`{`)||r.includes(`}`))&&(r=J(this.#o,r)),(0,F.isAbsolutePath)(r))return r;let i=(0,N.murmurhash)({path:this.#c(r),importer:t,options:n}),a;if(!this.#o.config.skipCache&&(a=this.resolverCache.get(i),a))return a;if(a=this.paths[this.#c(r)],!a){let e=n.paths??[];t&&!e.includes(t)&&e.push(t),e.push(this.#o.workspaceConfig.workspaceRoot),e.push((0,_.appendPath)(this.#o.config.projectRoot,this.#o.workspaceConfig.workspaceRoot)),e.push((0,_.appendPath)(this.#o.config.sourceRoot,this.#o.workspaceConfig.workspaceRoot)),e.push(...Object.keys(this.#o.tsconfig?.options?.paths??{}).filter(e=>r.startsWith(e.replace(/\*$/,``))).map(e=>this.#o.tsconfig?.options?.paths?.[e]).flat().filter(Boolean).map(e=>(0,_.appendPath)(e,this.#o.workspaceConfig.workspaceRoot)));for(let t of(0,g.getResolutionCombinations)(r,{paths:e})){let{relativeKey:e,adapter:n}=this.#d(t);if(await n.exists(e)){a=t;break}}if(!a)try{a=await(0,g.resolve)(r,{...n,paths:e})}catch{}}return a&&!this.#o.config.skipCache&&this.resolverCache.set(i,a),a}resolveSync(e,t,n={}){let r=e;if((r.includes(`{`)||r.includes(`}`))&&(r=J(this.#o,r)),(0,F.isAbsolutePath)(r))return r;let i;if(!this.#o.config.skipCache&&(i=this.resolverCache.get(this.#c(r)),i))return i;if(i=this.paths[this.#c(r)],!i){let e=n.paths??[];t&&!e.includes(t)&&e.push(t),e.push(this.#o.workspaceConfig.workspaceRoot),e.push((0,_.appendPath)(this.#o.config.projectRoot,this.#o.workspaceConfig.workspaceRoot)),e.push((0,_.appendPath)(this.#o.config.sourceRoot,this.#o.workspaceConfig.workspaceRoot)),e.push(...Object.keys(this.#o.tsconfig?.options?.paths??{}).filter(e=>r.startsWith(e.replace(/\*$/,``))).map(e=>this.#o.tsconfig?.options?.paths?.[e]).flat().filter(Boolean).map(e=>(0,_.appendPath)(e,this.#o.workspaceConfig.workspaceRoot)));for(let t of(0,g.getResolutionCombinations)(r,{paths:e})){let{relativeKey:e,adapter:n}=this.#d(t);if(n.existsSync(e)){i=t;break}}if(!i)try{i=(0,g.resolveSync)(r,{...n,paths:e})}catch{}}return i&&!this.#o.config.skipCache&&this.resolverCache.set(this.#c(r),i),i}async dispose(){if(!this.#a){this.#a=!0,this.#s(c.LogLevelLabel.DEBUG,`Disposing virtual file system...`),await this.remove((0,d.joinPaths)(this.#o.dataPath,`fs.bin`));let e=new B.Message,t=e.initRoot(Y),n=await this.list(),r=t._initStorage(n.length);await Promise.all(n.map(async(e,t)=>{let n=await this.read(e),i=r.get(t);i.path=e,i.code=n||``}));let i=t._initIds(Object.keys(this.ids).length);Object.entries(this.ids).filter(([,e])=>e).forEach(([e,t],n)=>{let r=i.get(n);r.id=e,r.path=t});let a=t._initMetadata(Object.keys(this.metadata).length);Object.entries(this.metadata).filter(([,e])=>e).forEach(([e,t],n)=>{let r=a.get(n);if(r.id=e,r.type=t.type,r.timestamp=t.timestamp??BigInt(Date.now()),t.properties){let e=r._initProperties(Object.keys(t.properties).length);Object.entries(t.properties).forEach(([t,n],r)=>{let i=e.get(r);i.key=t,i.value=n})}}),await(0,Te.writeFileBuffer)((0,d.joinPaths)(this.#o.dataPath,`fs.bin`),e.toArrayBuffer()),this.#o.config.skipCache||this.#i.save(!0),await Promise.all(this.#f().map(async e=>e.adapter.dispose())),this.#s(c.LogLevelLabel.TRACE,`Virtual file system has been disposed.`)}}async[Symbol.asyncDispose](){return this.dispose()}};const Gt=45,Kt=62;function qt(e,t){let n=`${(0,ze.kebabCase)(e)}_${t}`;return n.length>45?n.slice(0,45):n}async function Jt(e){let t=(0,d.joinPaths)(e.dataPath,`meta.json`);e.log(c.LogLevelLabel.DEBUG,`Writing runtime metadata to ${t}`),await e.fs.write(t,JSON.stringify(e.meta,null,2))}const Yt=new WeakMap;(0,R.setGlobalDispatcher)(new R.Agent({keepAliveTimeout:1e4}).compose(R.interceptors.retry({maxRetries:3,minTimeout:1e3,maxTimeout:1e4,timeoutFactor:2,retryAfter:!0})));var Xt=class e{#e={};#t;#n=null;#r=(0,ye.uuid)();#i=(0,ye.uuid)();#a=Date.now();#o;#s;#c;#l;#u;#d;#f(e={}){return{variant:e.build?.variant,projectType:e.type,projectRoot:e.root,name:e.name,title:e.title,description:e.description,sourceRoot:e.sourceRoot,configFile:e.configFile,customLogger:e.customLogger,logLevel:e.logLevel,tsconfig:e.tsconfig,tsconfigRaw:e.tsconfigRaw,skipCache:e.skipCache,skipInstalls:e.skipInstalls,entry:e.entry,output:e.output,plugins:e.plugins,mode:e.mode,lint:e.lint,transform:e.transform,build:e.build,framework:e.framework,...e}}static async from(t,n){let r=new e(await lt(t,n.root));if(await r.withUserConfig(n),r.powerlinesPath=await(0,g.resolvePackage)(`powerlines`),!r.powerlinesPath)throw Error("Could not resolve `powerlines` package location.");return r}dependencies={};devDependencies={};persistedMeta=void 0;powerlinesPath;packageJson;projectJson=void 0;resolver;resolvePatterns=[];get $$internal(){return this.#e}set $$internal(e){this.#e=e}get entry(){return Ot(this,(0,f.toArray)(this.config.entry))}get tsconfig(){return this.#c||(this.tsconfig={tsconfigFilePath:this.config.tsconfig}),this.#c}set tsconfig(e){this.#c=e,this.resolvePatterns=(0,L.tsconfigPathsToRegExp)(e?.options?.paths??{})}get fs(){return this.#s||=Wt.createSync(this),this.#s}get checksum(){return this.#n}get meta(){return{buildId:this.#r,releaseId:this.#i,checksum:this.#n,timestamp:this.#a,projectRootHash:(0,N.murmurhash)({workspaceRoot:this.workspaceConfig?.workspaceRoot,projectRoot:this.config?.projectRoot},{maxLength:45}),configHash:(0,N.murmurhash)(this.config,{maxLength:62})}}get config(){return this.resolvedConfig??{}}get log(){return this.logFn||=this.createLog(),this.logFn}get workspaceConfig(){return this.#t}get envPaths(){return this.#o||=(0,he.getEnvPaths)({orgId:`storm-software`,appId:`powerlines`,workspaceRoot:this.workspaceConfig.workspaceRoot}),this.#o}get artifactsPath(){return(0,I.joinPaths)(this.workspaceConfig.workspaceRoot,this.config.projectRoot,this.config.output.artifactsPath)}get builtinsPath(){return(0,I.joinPaths)(this.artifactsPath,`builtins`)}get entryPath(){return(0,I.joinPaths)(this.artifactsPath,`entry`)}get dataPath(){return(0,I.joinPaths)(this.envPaths.data,`projects`,qt(this.config.name,this.meta.projectRootHash))}get cachePath(){return(0,I.joinPaths)(this.envPaths.cache,`projects`,(0,N.murmurhash)({checksum:this.#n,config:this.meta.configHash},{maxLength:62}))}get dtsPath(){return this.config.output.dts?(0,_.appendPath)(this.config.output.dts,this.workspaceConfig.workspaceRoot):(0,I.joinPaths)(this.workspaceConfig.workspaceRoot,this.config.projectRoot,`powerlines.d.ts`)}get relativeToWorkspaceRoot(){return(0,ee.relativeToWorkspaceRoot)(this.config.projectRoot)}get builtins(){return Object.values(this.fs.metadata).filter(e=>e&&e.type===`builtin`).map(e=>e?.id).filter(Boolean)}get program(){return this.#l||=Ke(this,{skipAddingFilesFromTsConfig:!0}),this.#l}get parserCache(){return this.#u||=(0,be.create)({cacheId:`parser`,cacheDir:this.cachePath,ttl:7200*1e3,lruSize:5e3,persistInterval:250}),this.#u}get requestCache(){return this.#d||=(0,be.create)({cacheId:`http`,cacheDir:this.cachePath,ttl:300*1e3,lruSize:5e3,persistInterval:250}),this.#d}async fetch(e,t={}){let n=(0,N.murmurhash)({input:e.toString(),options:JSON.stringify(t)});if(!this.config.skipCache&&!t.skipCache){let e=this.requestCache.get(n);if(e)return new R.Response(e.body,{status:e.status,statusText:e.statusText,headers:e.headers})}let r=await(0,_e.fetchRequest)(e,{timeout:12e3,...t}),i={body:await r.text(),status:r.status,statusText:r.statusText,headers:Object.fromEntries(r.headers.entries())};if(!this.config.skipCache&&!t.skipCache)try{this.requestCache.set(n,i)}catch{}return new R.Response(i.body,{status:i.status,statusText:i.statusText,headers:i.headers})}async parse(e,t={}){let n=(0,N.murmurhash)({code:e,options:t}),r;return!this.config.skipCache&&(r=this.parserCache.get(n),r)?r:(r=await(0,xe.parse)(`source.${t.lang||`ts`}`,e,{...t,sourceType:`module`,showSemanticErrors:this.config.mode===`development`}),this.config.skipCache||this.parserCache.set(n,r),r)}async resolve(e,t,n={}){let r=e;if(this.config.build.alias)if(Array.isArray(this.config.build.alias)){let e=this.config.build.alias.find(e=>(0,L.match)(r,[e.find]));e&&(r=e.replacement)}else (0,b.isSetObject)(this.config.build.alias)&&this.config.build.alias[e]&&(r=this.config.build.alias[e]);if(this.fs.isVirtual(r)){let e=await this.fs.resolve(r,t,{conditions:this.config.build.conditions,extensions:this.config.build.extensions,...n});return e?{id:`\0${e}`,external:this.config.projectType!==`application`}:void 0}if(this.config.build.skipNodeModulesBundle){if((0,L.match)(r,this.resolvePatterns)||(0,L.match)(r,this.config.build.noExternal))return;if((0,L.match)(r,this.config.build.external)||r.startsWith(`node:`)||!/^[A-Z]:[/\\]|^\.{0,2}\/|^\.{1,2}$/.test(r))return{id:r,external:!0}}else{if((0,L.match)(r,this.config.build.noExternal))return;if((0,L.match)(r,this.config.build.external)||r.startsWith(`node:`))return{id:r,external:!0}}}async load(e){let t=await this.fs.resolve(e);if(!t)return;let n=await this.fs.read(t);if(n)return{code:n,map:null}}async getBuiltins(){return Promise.all(Object.entries(this.fs.metadata).filter(([,e])=>e&&e.type===`builtin`).map(async([e,t])=>{let n=await this.fs.read(e);return{...t,path:e,code:n}}))}async emitEntry(e,t,n={}){return this.fs.write((0,F.isAbsolute)(t)?t:(0,_.appendPath)(t,this.entryPath),e,(0,l.default)(n,{type:`entry`}))}async emitBuiltin(e,t,n,r={}){return this.fs.write(n?(0,F.isAbsolute)(n)?n:(0,I.joinPaths)(this.builtinsPath,n):(0,_.appendPath)(t,this.builtinsPath),e,(0,l.default)(r,{type:`builtin`}))}async withUserConfig(e,t={isHighPriority:!0}){this.mergeUserConfig(e),await this.init(this.config.userConfig,t)}async withInlineConfig(e,t={isHighPriority:!0}){if(this.config.inlineConfig=e,e.command===`new`){let e=(0,I.joinPaths)(this.workspaceConfig.workspaceRoot,`package.json`);if(!(0,M.existsSync)(e))throw Error(`The workspace package.json file could not be found at ${e}`);this.packageJson=await(0,O.readJsonFile)(e),this.workspaceConfig.repository??=(0,x.isSetString)(this.packageJson?.repository)?this.packageJson.repository:this.packageJson?.repository?.url}await this.init(this.config.inlineConfig,t)}fatal(e){this.log(c.LogLevelLabel.FATAL,(0,E.isString)(e)?e:k.StormJSON.stringify(e))}error(e){this.log(c.LogLevelLabel.ERROR,(0,E.isString)(e)?e:k.StormJSON.stringify(e))}warn(e){this.log(c.LogLevelLabel.WARN,(0,E.isString)(e)?e:k.StormJSON.stringify(e))}info(e){this.log(c.LogLevelLabel.INFO,(0,E.isString)(e)?e:k.StormJSON.stringify(e))}debug(e){this.log(c.LogLevelLabel.DEBUG,(0,E.isString)(e)?e:k.StormJSON.stringify(e))}trace(e){this.log(c.LogLevelLabel.TRACE,(0,E.isString)(e)?e:k.StormJSON.stringify(e))}createLog(e=null){return Ft(e,{...this.config,logLevel:(0,ve.isNull)(this.config.logLevel)?`silent`:this.config.logLevel})}extendLog(e){return It(this.log,e)}async generateChecksum(e=this.config.projectRoot){return this.#n=await(0,ge.hashDirectory)(e,{ignore:[`node_modules`,`.git`,`.nx`,`.cache`,`.storm`,`tmp`,`dist`]}),this.#n}constructor(e){this.#t=e,this.#o=(0,he.getEnvPaths)({orgId:`storm-software`,appId:`powerlines`,workspaceRoot:e.workspaceRoot})}resolvedConfig={};logFn;async init(e={},t={isHighPriority:!0}){let n={projectRoot:e.root??this.config.projectRoot??this.config.userConfig?.root??this.config.inlineConfig?.root,mode:(e.mode??this.config.mode)||this.workspaceConfig.mode,skipCache:e.skipCache??this.config.skipCache??!1,configFile:e.configFile??this.config.configFile,framework:e.framework??this.config.framework??`powerlines`,command:this.config.inlineConfig?.command};if(Yt.has(n)){let e=Yt.get(n);this.projectJson=e.projectJson,this.packageJson=e.packageJson,this.#n=e.checksum,this.resolver=e.resolver,this.mergeUserConfig(e.userConfig.config,this.config.userConfig)}else{let t=(0,I.joinPaths)(n.projectRoot,`project.json`);(0,M.existsSync)(t)&&(this.projectJson=await(0,O.readJsonFile)(t));let r=(0,I.joinPaths)(n.projectRoot,`package.json`);(0,M.existsSync)(r)&&(this.packageJson=await(0,O.readJsonFile)(r)),this.#n=await this.generateChecksum(n.projectRoot),this.resolver=pt({workspaceRoot:this.workspaceConfig.workspaceRoot,projectRoot:n.projectRoot,cacheDir:this.cachePath,mode:n.mode,logLevel:e.logLevel||this.config?.logLevel||this.workspaceConfig.logLevel||`info`,skipCache:n.skipCache});let i=await ut(n.projectRoot,this.workspaceConfig.workspaceRoot,this.resolver,n.command,n.mode,n.configFile,n.framework);this.mergeUserConfig(i.config),Yt.set(n,{projectJson:this.projectJson,packageJson:this.packageJson,checksum:this.#n,resolver:this.resolver,userConfig:i})}e.tsconfig??=U(this.workspaceConfig.workspaceRoot,n.projectRoot,e.tsconfig),(0,b.isSetObject)(e)&&(this.resolvedConfig=(0,l.default)({inlineConfig:this.config.inlineConfig,userConfig:this.config.userConfig},t.isHighPriority?this.#f(e):{},{command:this.config.inlineConfig?.command,...this.#f(this.config.inlineConfig)},this.#f(this.config.userConfig),{mode:this.workspaceConfig?.mode,logLevel:this.workspaceConfig?.logLevel,skipCache:this.workspaceConfig?.skipCache},{name:this.projectJson?.name||this.packageJson?.name,version:this.packageJson?.version,description:this.packageJson?.description,sourceRoot:this.projectJson?.sourceRoot||(0,_.appendPath)(`src`,n.projectRoot),output:(0,l.default)(e.output??{},{outputPath:n.projectRoot?(0,I.joinPaths)(this.workspaceConfig?.directories?.build||`dist`,n.projectRoot):this.workspaceConfig?.directories?.build||`dist`,artifactsPath:(0,I.joinPaths)(n.projectRoot,`.${e.framework??`powerlines`}`),dts:(0,I.joinPaths)(n.projectRoot,`${e.framework??`powerlines`}.d.ts`),builtinPrefix:e.framework??`powerlines`,assets:[{glob:`LICENSE`},{input:n.projectRoot,glob:`*.md`},{input:n.projectRoot,glob:`package.json`}]})},t.isHighPriority?{}:this.#f(e),{inlineConfig:{},userConfig:{},framework:`powerlines`,platform:`neutral`,mode:`production`,projectType:`application`,logLevel:`info`,preview:!1,environments:{},transform:{babel:{plugins:[],presets:[]}},lint:{eslint:{}},build:{target:`esnext`,override:{}}})),this.config.entry=kt(this.config.entry),this.config.name?.startsWith(`@`)&&this.config.name.split(`/`).filter(Boolean).length>1&&(this.config.name=this.config.name.split(`/`).filter(Boolean)[1]),this.config.title??=(0,j.titleCase)(this.config.name),this.config.userConfig.build?.external&&(this.config.userConfig.build.external=(0,P.getUnique)(this.config.userConfig.build.external)),this.config.userConfig.build?.noExternal&&(this.config.userConfig.build.noExternal=(0,P.getUnique)(this.config.userConfig.build.noExternal)),this.config.build.external&&(this.config.build.external=(0,P.getUnique)(this.config.build.external)),this.config.build.noExternal&&(this.config.build.noExternal=(0,P.getUnique)(this.config.build.noExternal)),this.config.output.format=(0,P.getUnique)((0,f.toArray)(this.config.output?.format??(this.config.projectType===`library`?[`cjs`,`esm`]:[`esm`]))),this.config.projectRoot&&this.config.projectRoot!==`.`&&this.config.projectRoot!==`./`&&this.config.projectRoot!==this.workspaceConfig.workspaceRoot?(this.config.output.outputPath??=(0,I.joinPaths)(`dist`,this.config.projectRoot),this.config.output.buildPath??=(0,I.joinPaths)(this.config.projectRoot,`dist`)):(this.config.output.outputPath??=`dist`,this.config.output.buildPath??=`dist`),this.config.output.assets=(0,P.getUnique)(this.config.output.assets.map(e=>({glob:(0,b.isSetObject)(e)?e.glob:e,input:(0,E.isString)(e)||!e.input||e.input===`.`||e.input===`/`||e.input===`./`?this.workspaceConfig.workspaceRoot:(0,_.appendPath)(e.input,this.workspaceConfig.workspaceRoot),output:(0,_.appendPath)((0,b.isSetObject)(e)&&e.output?(0,I.joinPaths)(this.config.output.outputPath,(0,v.replacePath)(e.output,this.config.output.outputPath)):this.config.output.outputPath,this.workspaceConfig.workspaceRoot),ignore:(0,b.isSetObject)(e)&&e.ignore?(0,f.toArray)(e.ignore):void 0}))),this.config.plugins=(this.config.plugins??[]).filter(Boolean).reduce((e,t)=>(K(t)&&q(t,e.filter(e=>K(e)))||e.push(t),e),[]),this.config.tsconfig&&(this.config.tsconfig=J(this,this.config.tsconfig)),this.config.output.dts&&(this.config.output.dts=J(this,this.config.output.dts)),this.config.build.polyfill&&(this.config.build.polyfill=this.config.build.polyfill.map(e=>J(this,e))),this.config.output.assets&&(this.config.output.assets=this.config.output.assets.map(e=>({...e,glob:J(this,e.glob),ignore:e.ignore?e.ignore.map(e=>J(this,e)):void 0,input:J(this,e.input),output:J(this,e.output)}))),this.#s??=await Wt.create(this)}mergeUserConfig(e={},t=this.config.userConfig??{}){this.config.userConfig=(0,l.default)({entry:Array.isArray(e.entry)&&e.entry.length>0?e.entry:Array.isArray(t?.entry)&&t.entry.length>0?t.entry:[]},(0,u.omit)(e??{},[`entry`]),(0,u.omit)(t??{},[`entry`])),this.config.userConfig.output?.format&&(this.config.userConfig.output.format=(0,P.getUnique)((0,f.toArray)(this.config.userConfig.output?.format))),this.config.userConfig.plugins=(this.config.userConfig.plugins??[]).filter(Boolean).reduce((e,t)=>(K(t)&&q(t,e.filter(e=>K(e)))||e.push(t),e),[])}};const Zt=[`name`,`api`,`enforce`,`dedupe`,`dependsOn`,`applyToEnvironment`];function Qt(e,t){let n=e=>(0,E.isString)(e)?e:e.message,r=t.extendLog(e.name),i=async(e,n,...r)=>t.$$internal.api.callHook(e,{sequential:!0,result:`merge`,...n,environment:t},...r);return new Proxy({},{get(e,a){return a===`$$internal`?{...t.$$internal,environment:t,callHook:i}:a===`log`||a===`logger`?r:a===`error`?e=>{r(c.LogLevelLabel.ERROR,n(e))}:a===`warn`?e=>{r(c.LogLevelLabel.WARN,n(e))}:a===`info`?e=>{r(c.LogLevelLabel.INFO,n(e))}:a===`debug`?e=>{r(c.LogLevelLabel.DEBUG,n(e))}:a===`trace`?e=>{r(c.LogLevelLabel.TRACE,n(e))}:t[a]},set(e,n,i){return[`$$internal`,`environment`,`config`,`log`,`logger`,`error`,`warn`,`plugins`,`hooks`,`addPlugin`,`selectHooks`].includes(n)?(r(c.LogLevelLabel.WARN,`Cannot set read-only property "${String(n)}"`),!1):(t[n]=i,!0)}})}var $t=class e extends Xt{#e={};static async fromConfig(t,n){let r=new e(n,t);if(await r.init(),r.powerlinesPath=await(0,g.resolvePackage)(`powerlines`),!r.powerlinesPath)throw Error("Could not resolve `powerlines` package location.");return r}environment;plugins=[];get config(){return super.config}get hooks(){return this.#e}async addPlugin(e){let t=e;if((0,y.isFunction)(e.applyToEnvironment)){let n=await Promise.resolve(e.applyToEnvironment(this.environment));if(!n||(0,se.isObject)(n)&&Object.keys(n).length===0)return;if(_t(n))return this.$$internal.addPlugin(n);t=K(n)?n:e}let n=Qt(t,this);this.plugins.push({plugin:t,context:n}),this.#e=Object.keys(t).filter(e=>!Zt.includes(e)).reduce((e,r)=>{let i=r,a=t[i];if(!bt(a))return e;if(St(i))e[i]??=[],e[i].push({plugin:t,hook:xt(a).bind(n)});else{if(e[i]??={},t.enforce)return e[i][`${t.enforce}Enforced`]??=[],Ct(n,t,a,e[i][`${t.enforce}Enforced`]),e;if((0,y.isFunction)(a)||!a.order)return e[i].normal??=[],Ct(n,t,a,e[i].normal),e;e[i][`${a.order}Ordered`]??=[],Ct(n,t,a,e[i][`${a.order}Ordered`])}return e},this.hooks)}selectHooks(e,t){let n=[];if(this.hooks[e])if(St(e))n.push(...this.hooks[e].map(e=>{let t=this.plugins.find(t=>t.plugin.name===e.plugin.name);if(!t)throw Error(`Could not find plugin context for plugin "${e.plugin.name}".`);return{handle:e.handler,context:t.context}}));else{let r=this.hooks[e];t?.order?t?.order===`pre`?(n.push(...(r.preOrdered??[]).map(e=>{let t=this.plugins.find(t=>t.plugin.name===e.plugin.name);if(!t)throw Error(`Could not find plugin context for plugin "${e.plugin.name}".`);return{handle:e.handler,context:t.context}})),n.push(...(r.preEnforced??[]).map(e=>{let t=this.plugins.find(t=>t.plugin.name===e.plugin.name);if(!t)throw Error(`Could not find plugin context for plugin "${e.plugin.name}".`);return{handle:e.handler,context:t.context}}))):t?.order===`post`?(n.push(...(r.postOrdered??[]).map(e=>{let t=this.plugins.find(t=>t.plugin.name===e.plugin.name);if(!t)throw Error(`Could not find plugin context for plugin "${e.plugin.name}".`);return{handle:e.handler,context:t.context}})),n.push(...(r.postEnforced??[]).map(e=>{let t=this.plugins.find(t=>t.plugin.name===e.plugin.name);if(!t)throw Error(`Could not find plugin context for plugin "${e.plugin.name}".`);return{handle:e.handler,context:t.context}}))):n.push(...(r.normal??[]).map(e=>{let t=this.plugins.find(t=>t.plugin.name===e.plugin.name);if(!t)throw Error(`Could not find plugin context for plugin "${e.plugin.name}".`);return{handle:e.handler,context:t.context}})):(n.push(...this.selectHooks(e,{order:`pre`})),n.push(...this.selectHooks(e,{order:`normal`})),n.push(...this.selectHooks(e,{order:`post`})))}return n}constructor(e,t){super(t),this.resolvedConfig=e}},en=class e extends Xt{#e={};#t=[];#n;static async from(t,n){let r=new e(await lt(t,n.root));if(await r.withUserConfig(n),r.powerlinesPath=await(0,g.resolvePackage)(`powerlines`),!r.powerlinesPath)throw Error("Could not resolve `powerlines` package location.");return r}get $$internal(){return super.$$internal}set $$internal(e){super.$$internal=e;for(let e of Object.values(this.environments))e.$$internal=super.$$internal}get environments(){return this.#e}get log(){return this.#n||=this.createLog(`engine`),this.#n}get plugins(){return this.#t}constructor(e){super(e)}async init(e={}){await super.init(e),await Promise.all((0,f.toArray)(this.config.userConfig.environments&&Object.keys(this.config.userConfig.environments).length>0?Object.keys(this.config.userConfig.environments).map(e=>st(e,this.config.userConfig)):ct(this.config.userConfig)).map(async e=>{this.#e[e.name]=await this.in(e)}))}async in(e){let t;t=this.environments[e.name]?this.environments[e.name]:await $t.fromConfig(this.workspaceConfig,this.config),(0,b.isSetObject)(this.config.inlineConfig)&&await t.withInlineConfig(this.config.inlineConfig),t.environment=e,t.plugins=[];for(let e of this.plugins)await t.addPlugin(e);return t}async withUserConfig(e,t={isHighPriority:!0}){await super.withUserConfig(e,t),await Promise.all(Object.keys(this.#e).map(async n=>{await this.#e[n].withUserConfig(e,t)}))}async withInlineConfig(e,t={isHighPriority:!0}){await super.withInlineConfig(e,t),await Promise.all(Object.keys(this.#e).map(async n=>{await this.#e[n].withInlineConfig(e,t)}))}async addPlugin(e){this.plugins.push(e),await Promise.all(Object.keys(this.environments).map(async t=>{await this.environments[t].addPlugin(e)}))}async getEnvironment(e){let t;if(e&&(t=this.environments[e]),Object.keys(this.environments).length===1&&(t=this.environments[Object.keys(this.environments)[0]],this.log(c.LogLevelLabel.DEBUG,`Applying the only configured environment: ${S.default.bold.cyanBright(t?.environment.name)}`)),!t){if(e)throw Error(`Environment "${e}" not found.`);t=await this.in(ct(this.config.userConfig)),this.log(c.LogLevelLabel.WARN,`No environment specified, and no default environment found. Using a temporary default environment: ${S.default.bold.cyanBright(t?.environment.name)}`)}return t}async getEnvironmentSafe(e){try{return await this.getEnvironment(e)}catch{return}}};function tn(e){return`
21
- // Generated with ${(0,j.titleCase)(e.config.framework)}
22
- // Note: Do not edit this file manually - it will be overwritten automatically
23
- `}function nn(e,t={}){let{directive:n=null,prettierIgnore:r=!1}=t;return`/* eslint-disable */
24
- // biome-ignore lint: disable
25
- ${r?`// prettier-ignore`:``}${n?`\n\n${n}\n`:`
26
- `}
27
- ${tn(e)}
28
-
29
- `}var rn=class e{#e;get context(){return this.#e}constructor(e){this.#e=e}static async from(t,n){let r=new e(await en.from(t,n));r.#e.$$internal={api:r,addPlugin:r.#r.bind(r)};for(let e of r.context.config.plugins??[])await r.#r(e);r.context.plugins.length===0&&r.context.log(c.LogLevelLabel.WARN,`No Powerlines plugins were specified in the options. Please ensure this is correct, as it is generally not recommended.`);let i=await r.callHook(`config`,{environment:await r.context.getEnvironment(),sequential:!0,result:`merge`});return await r.context.withUserConfig(i,{isHighPriority:!1}),r}async prepare(e={command:`prepare`}){this.context.log(c.LogLevelLabel.TRACE,` 🏗️ Preparing the Powerlines project`),this.context.log(c.LogLevelLabel.TRACE,` ⚙️ Aggregating configuration options for the Powerlines project`),await this.context.withInlineConfig(e),await this.#n(async e=>{if(e.log(c.LogLevelLabel.TRACE,`Initializing the processing options for the Powerlines project.`),await this.callHook(`configResolved`,{environment:e,order:`pre`}),await it(e),await this.callHook(`configResolved`,{environment:e,order:`normal`}),e.log(c.LogLevelLabel.DEBUG,`The configuration provided ${(0,f.toArray)(e.config.entry).length} entry point(s), Powerlines has found ${e.entry.length} entry files(s) for the ${e.config.title} project${e.entry.length>0&&e.entry.length<10?`: \n${e.entry.map(e=>`- ${e.input.file||e.file}${e.output?` -> ${e.output}`:``}`).join(`
30
- `)}`:``}.`),await at(e),await Qe(e),await this.callHook(`configResolved`,{environment:e,order:`post`}),e.log(c.LogLevelLabel.TRACE,`Powerlines configuration has been resolved: \n\n${(0,re.formatLogMessage)(e.config)}`),e.fs.existsSync(e.cachePath)||await(0,p.createDirectory)(e.cachePath),e.fs.existsSync(e.dataPath)||await(0,p.createDirectory)(e.dataPath),await this.callHook(`prepare`,{environment:e,order:`pre`}),await this.callHook(`prepare`,{environment:e,order:`normal`}),e.config.output.dts!==!1){e.log(c.LogLevelLabel.TRACE,`Preparing the TypeScript definitions for the Powerlines project.`),e.fs.existsSync(e.dtsPath)&&await e.fs.remove(e.dtsPath),e.log(c.LogLevelLabel.TRACE,`Transforming built-ins runtime modules files.`);let t=await Promise.all((await e.getBuiltins()).map(async t=>{let n=await(0,ne.transformAsync)(t.code.toString(),{highlightCode:!0,code:!0,ast:!1,cloneInputAst:!1,comments:!0,sourceType:`module`,configFile:!1,babelrc:!1,envName:e.config.mode,caller:{name:`powerlines`},...e.config.transform.babel,filename:t.path,plugins:[[`@babel/plugin-syntax-typescript`],[We(e)]]});if(!n?.code)throw Error(`Powerlines - Generate Types failed to compile ${t.id}`);return e.log(c.LogLevelLabel.TRACE,`Writing transformed built-in runtime file ${t.id}.`),await e.emitBuiltin(n.code,t.id,t.path),t.path}));if(!await(0,g.resolvePackage)(`typescript`))throw Error(`Could not resolve TypeScript package location. Please ensure TypeScript is installed.`);let n=t.reduce((t,n)=>{let r=(0,v.replacePath)(n,e.workspaceConfig.workspaceRoot);return t.includes(r)||t.push(r),t},[]);e.log(c.LogLevelLabel.TRACE,`Parsing TypeScript configuration for the Powerlines project.`);let r=await Je(e,n);e.log(c.LogLevelLabel.TRACE,`Generating TypeScript declaration file ${e.dtsPath}.`);let i=[],a=e=>(0,se.isObject)(e)?e.code:e,o=await this.callHook(`types`,{environment:e,sequential:!0,order:`pre`,result:`merge`,asNextParam:a},r);if(o&&((0,b.isSetObject)(o)?(r=o.code,Array.isArray(o.directives)&&o.directives.length>0&&i.push(...o.directives)):(0,x.isSetString)(o)&&(r=o)),o=await this.callHook(`types`,{environment:e,sequential:!0,order:`normal`,result:`merge`,asNextParam:a},r),o&&((0,b.isSetObject)(o)?(r=o.code,Array.isArray(o.directives)&&o.directives.length>0&&i.push(...o.directives)):(0,x.isSetString)(o)&&(r=o)),o=await this.callHook(`types`,{environment:e,sequential:!0,order:`post`,result:`merge`,asNextParam:a},r),o&&((0,b.isSetObject)(o)?(r=o.code,Array.isArray(o.directives)&&o.directives.length>0&&i.push(...o.directives)):(0,x.isSetString)(o)&&(r=o)),r?.trim()||i.length>0)await e.fs.write(e.dtsPath,`${i?`${i.map(e=>`/// <reference types="${e}" />`).join(`
31
- `)}
32
-
33
- `:``}${nn(e,{directive:null,prettierIgnore:!1})}
34
-
35
- ${qe(r)}
36
- `);else{let t=nt(e);if(e.tsconfig.tsconfigJson.include&&tt(t,e.tsconfig.tsconfigJson.include)){let n=t.startsWith(`./`)?t.slice(2):t;e.tsconfig.tsconfigJson.include=e.tsconfig.tsconfigJson.include.filter(e=>e?.toString()!==n),await e.fs.write(e.tsconfig.tsconfigFilePath,JSON.stringify(e.tsconfig.tsconfigJson,null,2))}}}if(e.tsconfig=G(e.workspaceConfig.workspaceRoot,e.config.projectRoot,e.config.tsconfig),!e.tsconfig)throw Error(`Failed to parse the TypeScript configuration file.`);await this.callHook(`prepare`,{environment:e,order:`post`}),await Jt(e),e.persistedMeta=e.meta}),this.context.log(c.LogLevelLabel.INFO,`Powerlines API has been prepared successfully`)}async new(e){this.context.log(c.LogLevelLabel.INFO,`🆕 Creating a new Powerlines project`),await this.prepare(e),await this.#n(async e=>{e.log(c.LogLevelLabel.TRACE,`Initializing the processing options for the Powerlines project.`),await this.callHook(`new`,{environment:e,order:`pre`});let t=await(0,m.listFiles)((0,d.joinPaths)(e.powerlinesPath,`files/common/**/*.hbs`));for(let n of t){e.log(c.LogLevelLabel.TRACE,`Adding template file: ${n}`);let t=C.default.compile(n);await e.fs.write((0,d.joinPaths)(e.config.projectRoot,n.replace(`.hbs`,``)),t(e))}if(await this.callHook(`new`,{environment:e,order:`normal`}),e.config.projectType===`application`){let t=await(0,m.listFiles)((0,d.joinPaths)(e.powerlinesPath,`files/application/**/*.hbs`));for(let n of t){e.log(c.LogLevelLabel.TRACE,`Adding application template file: ${n}`);let t=C.default.compile(n);await e.fs.write((0,d.joinPaths)(e.config.projectRoot,n.replace(`.hbs`,``)),t(e))}}else{let t=await(0,m.listFiles)((0,d.joinPaths)(e.powerlinesPath,`files/library/**/*.hbs`));for(let n of t){e.log(c.LogLevelLabel.TRACE,`Adding library template file: ${n}`);let t=C.default.compile(n);await e.fs.write((0,d.joinPaths)(e.config.projectRoot,n.replace(`.hbs`,``)),t(e))}}await this.callHook(`new`,{environment:e,order:`post`})}),this.context.log(c.LogLevelLabel.TRACE,`Powerlines - New command completed`)}async clean(e={command:`clean`}){this.context.log(c.LogLevelLabel.INFO,`🧹 Cleaning the previous Powerlines artifacts`),await this.prepare(e),await this.#n(async e=>{this.context.log(c.LogLevelLabel.TRACE,`Cleaning the project's dist and artifacts directories.`),await e.fs.remove((0,d.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.output.buildPath)),await e.fs.remove((0,d.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.output.artifactsPath)),await this.callHook(`clean`,{environment:e,sequential:!1})}),this.context.log(c.LogLevelLabel.TRACE,`Powerlines - Clean command completed`)}async lint(e={command:`lint`}){this.context.log(c.LogLevelLabel.INFO,`📋 Linting the Powerlines project`),await this.prepare(e),await this.#n(async e=>{e.config.lint!==!1&&await this.callHook(`lint`,{environment:e,sequential:!1})}),this.context.log(c.LogLevelLabel.TRACE,`Powerlines linting completed`)}async build(e={command:`build`}){this.context.log(c.LogLevelLabel.INFO,`📦 Building the Powerlines project`),await this.prepare(e),await this.#n(async e=>{if(await this.callHook(`build`,{environment:e,order:`pre`}),await this.callHook(`build`,{environment:e,order:`normal`}),e.config.output.buildPath!==e.config.output.outputPath){let t=(0,_.appendPath)(e.config.output.buildPath,e.workspaceConfig.workspaceRoot),n=(0,d.joinPaths)((0,_.appendPath)(e.config.output.outputPath,e.workspaceConfig.workspaceRoot),`dist`);t!==n&&(e.log(c.LogLevelLabel.INFO,`Copying build output files from project's build directory (${e.config.output.buildPath}) to the workspace's output directory (${e.config.output.outputPath}).`),await e.fs.copy(t,n))}await Promise.all(e.config.output.assets.map(async t=>{e.log(c.LogLevelLabel.DEBUG,`Copying asset(s): ${S.default.redBright(e.workspaceConfig.workspaceRoot===t.input?t.glob:(0,d.joinPaths)((0,v.replacePath)(t.input,e.workspaceConfig.workspaceRoot),t.glob))} -> ${S.default.greenBright((0,d.joinPaths)((0,v.replacePath)(t.output,e.workspaceConfig.workspaceRoot),t.glob))} ${Array.isArray(t.ignore)&&t.ignore.length>0?` (ignoring: ${t.ignore.map(e=>S.default.yellowBright(e)).join(`, `)})`:``}`),await e.fs.copy(t,t.output)})),await this.callHook(`build`,{environment:e,order:`post`})}),this.context.log(c.LogLevelLabel.TRACE,`Powerlines build completed`)}async docs(e={command:`docs`}){this.context.log(c.LogLevelLabel.INFO,`📓 Generating documentation for the Powerlines project`),await this.prepare(e),await this.#n(async t=>{t.log(c.LogLevelLabel.TRACE,`Writing documentation for the Powerlines project artifacts.`),await this.prepare(e),await this.#n(async e=>{await this.callHook(`docs`,{environment:e})})}),this.#e.log(c.LogLevelLabel.TRACE,`Powerlines documentation generation completed`)}async deploy(e={command:`deploy`}){this.context.log(c.LogLevelLabel.INFO,`📦 Deploying the Powerlines project`),await this.prepare(e),await this.#n(async e=>{await this.callHook(`deploy`,{environment:e})}),this.context.log(c.LogLevelLabel.TRACE,`Powerlines deploy completed`)}async finalize(){this.context.log(c.LogLevelLabel.TRACE,`Powerlines finalize execution started`),await this.#n(async e=>{await this.callHook(`finalize`,{environment:e}),await e.fs.dispose()}),this.context.log(c.LogLevelLabel.TRACE,`Powerlines finalize execution completed`)}async callHook(e,t,...n){return Xe((0,b.isSetObject)(t?.environment)?t.environment:await this.#e.getEnvironment(t?.environment),e,{sequential:!0,...t},...n)}async[Symbol.asyncDispose](){await this.finalize()}async#t(){return!this.context.config.environments||Object.keys(this.context.config.environments).length<=1?(this.context.log(c.LogLevelLabel.DEBUG,`No environments are configured for this Powerlines project. Using the default environment.`),[await this.context.getEnvironment()]):(this.context.log(c.LogLevelLabel.DEBUG,`Found ${Object.keys(this.context.config.environments).length} configured environment(s) for this Powerlines project.`),(await Promise.all(Object.entries(this.context.config.environments).map(async([e,t])=>{if(!await this.context.getEnvironmentSafe(e)){let n=await this.callHook(`configEnvironment`,{environment:e},e,t);n&&(this.context.environments[e]=await this.context.in(n))}return this.context.environments[e]}))).filter(e=>(0,le.isSet)(e)))}async#n(e){await Promise.all((await this.#t()).map(async t=>Promise.resolve(e(t))))}async#r(e){if(e){let t=await this.#i(e);if(!t)return;if(t.dependsOn)for(let e of t.dependsOn)await this.#r(e);this.context.log(c.LogLevelLabel.DEBUG,`Successfully initialized the ${S.default.bold.cyanBright(t.name)} plugin`),await this.context.addPlugin(t)}}async#i(e){let t=e;if((0,ce.isPromiseLike)(e)&&(t=await Promise.resolve(e)),!_t(t))throw Error(`Invalid plugin specified in the configuration - ${JSON.stringify(t)}. Please ensure the value is a plugin name, an object with the \`plugin\` and \`props\` properties, or an instance of \`Plugin\`.`);let n;if(K(t))n=t;else if((0,y.isFunction)(t))n=await Promise.resolve(t());else if((0,x.isSetString)(t)){let e=await this.#a(t);n=(0,y.isFunction)(e)?await Promise.resolve(e()):e}else if(gt(t)||ht(t)){let e,r;if(gt(t)?(e=t[0],r=t?.length===2?t[1]:void 0):(e=t.plugin,r=t.options),(0,x.isSetString)(e)){let t=await this.#a(e);n=(0,y.isFunction)(t)?await Promise.resolve(r?t(r):t()):t}else (0,y.isFunction)(e)?n=await Promise.resolve(e(r)):K(e)&&(n=e)}if(!n)throw Error(`The plugin configuration ${JSON.stringify(t)} is invalid. This configuration must point to a valid Powerlines plugin module.`);if(!K(n))throw Error(`The plugin option ${JSON.stringify(n)} does not export a valid module. This configuration must point to a valid Powerlines plugin module.`);return q(n,this.context.plugins)?(this.context.log(c.LogLevelLabel.TRACE,`Duplicate ${S.default.bold.cyanBright(n.name)} plugin dependency detected - Skipping initialization.`),null):(this.context.log(c.LogLevelLabel.TRACE,`Initializing the ${S.default.bold.cyanBright(n.name)} plugin...`),n)}async#a(e){if(e.startsWith(`@`)&&e.split(`/`).filter(Boolean).length>2){let t=e.split(`/`).filter(Boolean);e=`${t[0]}/${t[1]}`}let t=(0,h.isPackageExists)(e,{paths:[this.context.workspaceConfig.workspaceRoot,this.context.config.projectRoot]});if(!t&&this.context.config.skipInstalls!==!0){this.#e.log(c.LogLevelLabel.WARN,`The plugin package "${e}" is not installed. It will be installed automatically.`);let t=await(0,ie.install)(e,{cwd:this.context.config.projectRoot});if((0,oe.isNumber)(t.exitCode)&&t.exitCode>0)throw this.#e.log(c.LogLevelLabel.ERROR,t.stderr),Error(`An error occurred while installing the build plugin package "${e}" `)}try{let t=await this.context.resolver.plugin.import(this.context.resolver.plugin.esmResolve((0,d.joinPaths)(e,`plugin`))),n=t.plugin??t.default;if(!n)throw Error(`The plugin package "${e}" does not export a valid module.`);return n}catch(n){try{let t=await this.context.resolver.plugin.import(this.context.resolver.plugin.esmResolve(e)),n=t.plugin??t.default;if(!n)throw Error(`The plugin package "${e}" does not export a valid module.`);return n}catch{throw t?Error(`An error occurred while importing the build plugin package "${e}":
37
- ${(0,ae.isError)(n)?n.message:String(n)}
38
-
39
- Note: Please ensure the plugin package's default export is a class that extends \`Plugin\` with a constructor that excepts a single arguments of type \`PluginOptions\`.`):Error(`The plugin package "${e}" is not installed. Please install the package using the command: "npm install ${e} --save-dev"`)}}}};function an(e){return e?(0,E.isString)(e)?e:(0,b.isSetObject)(e)&&`code`in e?e.code:e.toString():``}function on(e,t){return(0,l.defu)(e,t)}function sn(e){let t=e;return(0,te.setParseImpl)(t.parse),()=>{let e=It(t.log,`unplugin`);e(c.LogLevelLabel.DEBUG,`Initializing Unplugin`);try{async function n(){e(c.LogLevelLabel.DEBUG,`Powerlines build plugin starting...`),await t.$$internal.callHook(`buildStart`,{sequential:!0})}async function r(e,n,r={isEntry:!1}){let i=await(async()=>{let i=await t.$$internal.callHook(`resolveId`,{sequential:!0,result:`first`,order:`pre`},e,n,r);return i||(i=await t.$$internal.callHook(`resolveId`,{sequential:!0,result:`first`,order:`normal`},e,n,r),i)||(i=await t.resolve(e,n,r),i)?i:t.$$internal.callHook(`resolveId`,{sequential:!0,result:`first`,order:`post`},e,n,r)})();if(i&&r.isEntry&&t.config.build.polyfill&&t.config.build.polyfill.length>0){let e=t.entry.find(e=>e.file===((0,E.isString)(i)?i:i.id));if(e)return e.file=`${(0,v.replaceExtension)((0,E.isString)(i)?i:i.id)}-polyfill.ts`,e.output||=e.output?.replace((0,A.findFileName)(e.output,{withExtension:!0}),e.file),await t.emitEntry(`
40
- ${t.config.build.polyfill.map(e=>`import "${e}";`).join(`
41
- `)}
42
-
43
- export * from "${(0,E.isString)(i)?i:i.id}";
44
- `,e.file),e.file}return i}async function i(e){let n=await t.$$internal.callHook(`load`,{sequential:!0,result:`first`,order:`pre`},e);return n||(n=await t.$$internal.callHook(`load`,{sequential:!0,result:`first`,order:`normal`},e),n)||(n=await t.load(e),n)?n:t.$$internal.callHook(`load`,{sequential:!0,result:`first`,order:`post`},e)}async function a(e,n){let r=e;for(let e of t.$$internal.environment.selectHooks(`transform`)){let i=await e.handle.apply(on(t,this),[an(r),n]);i&&(r=i)}return r}async function o(){return e(c.LogLevelLabel.DEBUG,`Powerlines build plugin finishing...`),t.$$internal.callHook(`buildEnd`,{sequential:!0})}async function s(){return e(c.LogLevelLabel.DEBUG,`Finalizing Powerlines project output...`),t.$$internal.callHook(`writeBundle`,{sequential:!0})}return{name:`powerlines`,api:t.$$internal.api,resolveId:{filter:{id:{include:[/.*/]}},handler:r},load:{filter:{id:{include:[/.*/]}},handler:i},transform:a,buildStart:n,buildEnd:o,writeBundle:s,vite:{sharedDuringBuild:!0}}}catch(t){throw e(c.LogLevelLabel.FATAL,t?.message),t}}}function cn(e){return(0,te.createRspackPlugin)(sn(e))({})}Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return cn}});