powerlines 0.30.9 → 0.30.10
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.
- package/dist/api.cjs +2 -2
- package/dist/api.js +1 -1
- package/dist/astro.cjs +4 -4
- package/dist/astro.js +3 -3
- package/dist/{chunk-RDRKBM2J.js → chunk-7GYPWBEP.js} +3 -3
- package/dist/chunk-F7QESYUW.cjs +12 -0
- package/dist/{chunk-DJCJP2K3.js → chunk-IDLTP3CA.js} +11 -8
- package/dist/{chunk-5EV7B7LS.cjs → chunk-JCQNCKL6.cjs} +11 -8
- package/dist/{chunk-AQSF7JCD.js → chunk-LAAYAZCS.js} +3 -3
- package/dist/chunk-QCTZQ37E.cjs +12 -0
- package/dist/{chunk-AU4GWG43.cjs → chunk-TGULIA3I.cjs} +5 -5
- package/dist/{chunk-I3HIGKIE.cjs → chunk-TLNZXWBF.cjs} +4 -4
- package/dist/{chunk-W6J7EJ2B.js → chunk-XSHI4YXA.js} +3 -3
- package/dist/{chunk-LTUR7TOP.js → chunk-Y6BHFF2K.js} +3 -3
- package/dist/{chunk-MEZ6JUXR.js → chunk-YRYNUZMV.js} +3 -3
- package/dist/{chunk-RPLRKL7X.cjs → chunk-Z2YRWYQH.cjs} +4 -4
- package/dist/esbuild.cjs +6 -6
- package/dist/esbuild.js +3 -3
- package/dist/farm.cjs +3 -3
- package/dist/farm.js +2 -2
- package/dist/index.cjs +9 -9
- package/dist/index.js +2 -2
- package/dist/lib/build/index.cjs +5 -5
- package/dist/lib/build/index.js +1 -1
- package/dist/lib/build/tsdown.cjs +5 -5
- package/dist/lib/build/tsdown.js +1 -1
- package/dist/lib/{chunk-26EMHPES.js → chunk-5FVICSI2.js} +6 -5
- package/dist/lib/chunk-5FVICSI2.js.map +1 -0
- package/dist/lib/{chunk-RYILFB66.cjs → chunk-5KOLVUSY.cjs} +9 -8
- package/dist/lib/chunk-5KOLVUSY.cjs.map +1 -0
- package/dist/lib/{chunk-NMTYZRD3.cjs → chunk-75KYTRYW.cjs} +12 -12
- package/dist/lib/{chunk-NMTYZRD3.cjs.map → chunk-75KYTRYW.cjs.map} +1 -1
- package/dist/lib/{chunk-HN76MIOU.cjs → chunk-CLLQO726.cjs} +5 -4
- package/dist/lib/chunk-CLLQO726.cjs.map +1 -0
- package/dist/lib/{chunk-P6UDUIUO.js → chunk-D7GUAMYL.js} +4 -4
- package/dist/lib/{chunk-P6UDUIUO.js.map → chunk-D7GUAMYL.js.map} +1 -1
- package/dist/lib/{chunk-NAX6YQ7E.cjs → chunk-KLRDCXEP.cjs} +3 -3
- package/dist/lib/{chunk-NAX6YQ7E.cjs.map → chunk-KLRDCXEP.cjs.map} +1 -1
- package/dist/lib/{chunk-ZNPYK23Q.cjs → chunk-Q2CL3VW4.cjs} +16 -15
- package/dist/lib/chunk-Q2CL3VW4.cjs.map +1 -0
- package/dist/lib/{chunk-W5W4YR3Q.js → chunk-QOTSQ6ZF.js} +7 -6
- package/dist/lib/chunk-QOTSQ6ZF.js.map +1 -0
- package/dist/lib/{chunk-M446NHAJ.js → chunk-VN2OA25X.js} +5 -4
- package/dist/lib/chunk-VN2OA25X.js.map +1 -0
- package/dist/lib/{chunk-MOFTDKP2.js → chunk-WOQDW3EX.js} +3 -3
- package/dist/lib/{chunk-MOFTDKP2.js.map → chunk-WOQDW3EX.js.map} +1 -1
- package/dist/lib/contexts/api-context.cjs +4 -4
- package/dist/lib/contexts/api-context.js +3 -3
- package/dist/lib/contexts/context.cjs +2 -2
- package/dist/lib/contexts/context.d.cts +1 -1
- package/dist/lib/contexts/context.d.ts +1 -1
- package/dist/lib/contexts/context.js +1 -1
- package/dist/lib/contexts/environment-context.cjs +3 -3
- package/dist/lib/contexts/environment-context.js +2 -2
- package/dist/lib/contexts/index.cjs +6 -6
- package/dist/lib/contexts/index.js +3 -3
- package/dist/lib/index.cjs +8 -8
- package/dist/lib/index.js +4 -4
- package/dist/lib/unplugin/factory.cjs +5 -5
- package/dist/lib/unplugin/factory.js +4 -4
- package/dist/lib/unplugin/index.cjs +5 -5
- package/dist/lib/unplugin/index.js +4 -4
- package/dist/next.cjs +4 -4
- package/dist/next.js +3 -3
- package/dist/nuxt.cjs +7 -7
- package/dist/nuxt.js +5 -5
- package/dist/rolldown.cjs +6 -6
- package/dist/rolldown.js +3 -3
- package/dist/rollup.cjs +3 -3
- package/dist/rollup.js +2 -2
- package/dist/rspack.cjs +3 -3
- package/dist/rspack.js +2 -2
- package/dist/tsdown.cjs +4 -4
- package/dist/tsdown.js +3 -3
- package/dist/tsup.cjs +4 -4
- package/dist/tsup.js +3 -3
- package/dist/unloader.cjs +3 -3
- package/dist/unloader.js +2 -2
- package/dist/unplugin.cjs +5 -5
- package/dist/unplugin.js +3 -3
- package/dist/vite.cjs +6 -6
- package/dist/vite.js +3 -3
- package/dist/webpack.cjs +6 -6
- package/dist/webpack.js +3 -3
- package/package.json +23 -23
- package/dist/chunk-QAJDNAY4.cjs +0 -12
- package/dist/chunk-Z5BZ26WT.cjs +0 -12
- package/dist/lib/chunk-26EMHPES.js.map +0 -1
- package/dist/lib/chunk-HN76MIOU.cjs.map +0 -1
- package/dist/lib/chunk-M446NHAJ.js.map +0 -1
- package/dist/lib/chunk-RYILFB66.cjs.map +0 -1
- package/dist/lib/chunk-W5W4YR3Q.js.map +0 -1
- package/dist/lib/chunk-ZNPYK23Q.cjs.map +0 -1
|
@@ -61,7 +61,7 @@ function extractTsdownConfig(context) {
|
|
|
61
61
|
const typeDef = parseTypeDefinition.parseTypeDefinition(entry);
|
|
62
62
|
return typeDef?.file;
|
|
63
63
|
}).filter(Boolean) : [
|
|
64
|
-
"src
|
|
64
|
+
"src/**/*.ts",
|
|
65
65
|
"src/**/*.tsx"
|
|
66
66
|
],
|
|
67
67
|
alias: context.builtins.reduce((ret, id) => {
|
|
@@ -112,5 +112,5 @@ exports.DEFAULT_TSDOWN_CONFIG = DEFAULT_TSDOWN_CONFIG;
|
|
|
112
112
|
exports.extractTsdownConfig = extractTsdownConfig;
|
|
113
113
|
exports.resolveFromTsdownFormat = resolveFromTsdownFormat;
|
|
114
114
|
exports.resolveTsdownFormat = resolveTsdownFormat;
|
|
115
|
-
//# sourceMappingURL=chunk-
|
|
116
|
-
//# sourceMappingURL=chunk-
|
|
115
|
+
//# sourceMappingURL=chunk-KLRDCXEP.cjs.map
|
|
116
|
+
//# sourceMappingURL=chunk-KLRDCXEP.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/lib/build/tsdown.ts"],"names":["DEFAULT_TSDOWN_CONFIG","platform","target","cjsDefault","unbundle","shims","fixedExtension","nodeProtocol","clean","resolveTsdownFormat","formats","toArray","map","format","resolveFromTsdownFormat","formatMessage","__name","context","msgs","filter","Boolean","join","replace","RegExp","config","name","trim","extractTsdownConfig","defu","entry","isSetString","Array","isArray","length","typeDef","parseTypeDefinition","file","alias","builtins","reduce","ret","id","path","fs","ids","noExternal","build","variant","override","omit","cwd","appendPath","projectRoot","workspaceConfig","workspaceRoot","dts","parallel","newContext","tsconfig","tsconfigFilePath","sourcemap","mode","outDir","output","buildPath","treeshake","treeShaking","undefined","minify","metafile","debug","silent","logLevel","customLogger","level","info","warn","warnOnce","error","success"],"mappings":";;;;;;;;;;;;;;AAkCO,IAAMA,qBAAAA,GAA4D;EACvEC,QAAAA,EAAU,SAAA;EACVC,MAAAA,EAAQ,QAAA;EACRC,UAAAA,EAAY,IAAA;EACZC,QAAAA,EAAU,IAAA;EACVC,KAAAA,EAAO,IAAA;EACPC,cAAAA,EAAgB,IAAA;EAChBC,YAAAA,EAAc,IAAA;EACdC,KAAAA,EAAO;AACT;AAQO,SAASC,oBACdC,OAAAA,EAA2B;AAE3B,EAAA,OAAOC,eAAAA,CAAQD,OAAAA,CAAAA,CAASE,GAAAA,CAAIC,CAAAA,MAAAA,KAAAA;AAC1B,IAAA,QAAQA,MAAAA;MACN,KAAK,KAAA;AACH,QAAA,OAAO,KAAA;MACT,KAAK,MAAA;AACH,QAAA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AAA,CAAQ,MAAA,EAAQ,EAAA,CAAA,CAAA,IAC5DL,QAAQ2D,IAAAA,CAAK7D,aAAAA,CAAcE,SAAAA,GAAYC,IAAAA,CAAAA,CAAAA,EAF/B,UAAA,CAAA;MAGV4D,KAAAA,kBAAO9D,wBAAA,CAAA,CAAA,GAAIE,SACTY,uBAAAA,CAAYf,aAAAA,CAAcE,SAAAA,GAAYC,IAAAA,EAAMI,OAAAA,CAAQ,MAAA,EAAQ,EAAA,CAAA,CAAA,IAC5DL,QAAQ6D,KAAAA,CAAM/D,aAAAA,CAAcE,SAAAA,GAAYC,IAAAA,CAAAA,CAAAA,EAFnC,OAAA,CAAA;MAGP6D,OAAAA,kBAAS/D,wBAAA,CAAA,CAAA,GAAIE,SACXY,uBAAAA,CAAYf,aAAAA,CAAcE,SAAAA,GAAYC,IAAAA,EAAMI,OAAAA,CAAQ,MAAA,EAAQ,EAAA,CAAA,CAAA,IAC5DL,QAAQ0D,IAAAA,CAAK5D,aAAAA,CAAcE,SAAAA,GAAYC,IAAAA,CAAAA,CAAAA,EAFhC,SAAA;AAGX;AACF,GAAA,EACAlB,qBAAAA,CAAAA;AAEJ;AAzGgB2B,wBAAAA,CAAAA,mBAAAA,EAAAA,qBAAAA,CAAAA","file":"chunk-NAX6YQ7E.cjs","sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { Format } from \"@storm-software/build-tools/types\";\nimport { parseTypeDefinition } from \"@stryke/convert/parse-type-definition\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { omit } from \"@stryke/helpers/omit\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport defu from \"defu\";\nimport { Format as TsdownFormat } from \"tsdown\";\nimport {\n ESBuildBuildConfig,\n TsdownBuildConfig,\n TsdownResolvedBuildConfig,\n TsupBuildConfig\n} from \"../../types/build\";\nimport { Context } from \"../../types/context\";\n\nexport const DEFAULT_TSDOWN_CONFIG: Partial<TsdownResolvedBuildConfig> = {\n platform: \"neutral\",\n target: \"esnext\",\n cjsDefault: true,\n unbundle: true,\n shims: true,\n fixedExtension: true,\n nodeProtocol: true,\n clean: false\n} as const;\n\n/**\n * Resolves the entry options for [tsdown](https://github.com/rolldown/tsdown).\n *\n * @param formats - The formats to resolve.\n * @returns The resolved entry options.\n */\nexport function resolveTsdownFormat(\n formats?: Format | Format[]\n): TsdownFormat[] {\n return toArray(formats).map(format => {\n switch (format) {\n case \"cjs\":\n return \"cjs\";\n case \"iife\":\n return \"iife\";\n case \"esm\":\n default:\n return \"esm\";\n }\n });\n}\n\n/**\n * Resolves the entry options for [tsdown](https://github.com/rolldown/tsdown).\n *\n * @param formats - The formats to resolve.\n * @returns The resolved entry options.\n */\nexport function resolveFromTsdownFormat(\n formats?: TsdownFormat | TsdownFormat[]\n): Format[] {\n return toArray(formats).map(format => {\n switch (format) {\n case \"cjs\":\n case \"commonjs\":\n return \"cjs\";\n case \"iife\":\n return \"iife\";\n case \"esm\":\n case \"es\":\n case \"module\":\n case \"umd\":\n default:\n return \"esm\";\n }\n });\n}\n\nconst formatMessage = (context: Context, ...msgs: any[]) =>\n msgs\n .filter(Boolean)\n .join(\" \")\n .replace(new RegExp(`\\\\[${context.config.name}\\\\]`, \"g\"), \"\")\n .trim();\n\n/**\n * Resolves the options for [tsdown](https://github.com/rolldown/tsdown).\n *\n * @param context - The build context.\n * @returns The resolved options.\n */\nexport function extractTsdownConfig(\n context: Context\n): TsdownResolvedBuildConfig {\n return defu(\n {\n entry:\n isSetString(context.config.entry) ||\n (Array.isArray(context.config.entry) && context.config.entry.length > 0)\n ? (toArray(context.config.entry)\n .map(entry => {\n const typeDef = parseTypeDefinition(entry);\n\n return typeDef?.file;\n })\n .filter(Boolean) as string[])\n : [\"src/**.ts\", \"src/**/*.tsx\"],\n alias: context.builtins.reduce(\n (ret, id) => {\n const path = context.fs.ids[id];\n if (path) {\n ret[id] = path;\n }\n\n return ret;\n },\n {} as Record<string, string>\n ),\n noExternal: context.builtins\n },\n context.config.build.variant === \"tsdown\"\n ? context.config.build.override\n : {},\n context.config.build.variant === \"tsdown\"\n ? omit(context.config.build, [\"override\", \"variant\"])\n : {},\n {\n name: context.config.name,\n cwd: appendPath(\n context.config.projectRoot,\n context.workspaceConfig.workspaceRoot\n ),\n dts: {\n parallel: true,\n newContext: true,\n cwd: appendPath(\n context.config.projectRoot,\n context.workspaceConfig.workspaceRoot\n ),\n tsconfig: appendPath(\n context.tsconfig.tsconfigFilePath,\n context.workspaceConfig.workspaceRoot\n ),\n sourcemap: context.config.mode === \"development\"\n },\n outDir: appendPath(\n context.config.output.buildPath,\n context.workspaceConfig.workspaceRoot\n ),\n tsconfig: appendPath(\n context.tsconfig.tsconfigFilePath,\n context.workspaceConfig.workspaceRoot\n ),\n format: resolveTsdownFormat(context.config.output.format).filter(Boolean),\n mode: context.config.mode,\n treeshake:\n context.config.build.variant === \"tsdown\"\n ? (context.config.build as TsdownBuildConfig)?.treeshake\n : context.config.build.variant === \"tsup\"\n ? (context.config.build as TsupBuildConfig)?.treeshake\n : context.config.build.variant === \"esbuild\"\n ? (context.config.build as ESBuildBuildConfig)?.treeShaking\n : undefined,\n minify: context.config.mode === \"production\",\n metafile: context.config.mode === \"development\",\n sourcemap: context.config.mode === \"development\",\n debug: context.config.mode === \"development\",\n silent:\n context.config.logLevel === null ||\n context.config.mode === \"production\",\n logLevel:\n context.config.logLevel === \"trace\" ? \"debug\" : context.config.logLevel,\n customLogger: {\n level:\n context.config.logLevel === \"trace\"\n ? \"debug\"\n : context.config.logLevel,\n info: (...msgs: any[]) =>\n isSetString(formatMessage(context, ...msgs).replace(/\\s+/g, \"\")) &&\n context.info(formatMessage(context, ...msgs)),\n warn: (...msgs: any[]) =>\n isSetString(formatMessage(context, ...msgs).replace(/\\s+/g, \"\")) &&\n context.warn(formatMessage(context, ...msgs)),\n warnOnce: (...msgs: any[]) =>\n isSetString(formatMessage(context, ...msgs).replace(/\\s+/g, \"\")) &&\n context.warn(formatMessage(context, ...msgs)),\n error: (...msgs: any[]) =>\n isSetString(formatMessage(context, ...msgs).replace(/\\s+/g, \"\")) &&\n context.error(formatMessage(context, ...msgs)),\n success: (...msgs: any[]) =>\n isSetString(formatMessage(context, ...msgs).replace(/\\s+/g, \"\")) &&\n context.info(formatMessage(context, ...msgs))\n }\n } as TsdownResolvedBuildConfig,\n DEFAULT_TSDOWN_CONFIG\n );\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/lib/build/tsdown.ts"],"names":["DEFAULT_TSDOWN_CONFIG","platform","target","cjsDefault","unbundle","shims","fixedExtension","nodeProtocol","clean","resolveTsdownFormat","formats","toArray","map","format","resolveFromTsdownFormat","formatMessage","__name","context","msgs","filter","Boolean","join","replace","RegExp","config","name","trim","extractTsdownConfig","defu","entry","isSetString","Array","isArray","length","typeDef","parseTypeDefinition","file","alias","builtins","reduce","ret","id","path","fs","ids","noExternal","build","variant","override","omit","cwd","appendPath","projectRoot","workspaceConfig","workspaceRoot","dts","parallel","newContext","tsconfig","tsconfigFilePath","sourcemap","mode","outDir","output","buildPath","treeshake","treeShaking","undefined","minify","metafile","debug","silent","logLevel","customLogger","level","info","warn","warnOnce","error","success"],"mappings":";;;;;;;;;;;;;;AAkCO,IAAMA,qBAAAA,GAA4D;EACvEC,QAAAA,EAAU,SAAA;EACVC,MAAAA,EAAQ,QAAA;EACRC,UAAAA,EAAY,IAAA;EACZC,QAAAA,EAAU,IAAA;EACVC,KAAAA,EAAO,IAAA;EACPC,cAAAA,EAAgB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,EAAMI,OAAAA,CAAQ,MAAA,EAAQ,EAAA,CAAA,CAAA,IAC5DL,QAAQ2D,IAAAA,CAAK7D,aAAAA,CAAcE,SAAAA,GAAYC,IAAAA,CAAAA,CAAAA,EAFnC,MAAA,CAAA;MAGN2D,QAAAA,kBAAU7D,wBAAA,CAAA,CAAA,GAAIE,SACZY,uBAAAA,CAAYf,aAAAA,CAAcE,SAAAA,GAAYC,IAAAA,EAAMI,OAAAA,CAAQ,MAAA,EAAQ,EAAA,CAAA,CAAA,IAC5DL,QAAQ2D,IAAAA,CAAK7D,aAAAA,CAAcE,SAAAA,GAAYC,IAAAA,CAAAA,CAAAA,EAF/B,UAAA,CAAA;MAGV4D,KAAAA,kBAAO9D,wBAAA,CAAA,CAAA,GAAIE,SACTY,uBAAAA,CAAYf,aAAAA,CAAcE,SAAAA,GAAYC,IAAAA,EAAMI,OAAAA,CAAQ,MAAA,EAAQ,EAAA,CAAA,CAAA,IAC5DL,QAAQ6D,KAAAA,CAAM/D,aAAAA,CAAcE,SAAAA,GAAYC,IAAAA,CAAAA,CAAAA,EAFnC,OAAA,CAAA;MAGP6D,OAAAA,kBAAS/D,wBAAA,CAAA,CAAA,GAAIE,SACXY,uBAAAA,CAAYf,aAAAA,CAAcE,SAAAA,GAAYC,IAAAA,EAAMI,OAAAA,CAAQ,MAAA,EAAQ,EAAA,CAAA,CAAA,IAC5DL,QAAQ0D,IAAAA,CAAK5D,aAAAA,CAAcE,SAAAA,GAAYC,IAAAA,CAAAA,CAAAA,EAFhC,SAAA;AAGX;AACF,GAAA,EACAlB,qBAAAA,CAAAA;AAEJ;AAzGgB2B,wBAAAA,CAAAA,mBAAAA,EAAAA,qBAAAA,CAAAA","file":"chunk-KLRDCXEP.cjs","sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { Format } from \"@storm-software/build-tools/types\";\nimport { parseTypeDefinition } from \"@stryke/convert/parse-type-definition\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { omit } from \"@stryke/helpers/omit\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport defu from \"defu\";\nimport { Format as TsdownFormat } from \"tsdown\";\nimport {\n ESBuildBuildConfig,\n TsdownBuildConfig,\n TsdownResolvedBuildConfig,\n TsupBuildConfig\n} from \"../../types/build\";\nimport { Context } from \"../../types/context\";\n\nexport const DEFAULT_TSDOWN_CONFIG: Partial<TsdownResolvedBuildConfig> = {\n platform: \"neutral\",\n target: \"esnext\",\n cjsDefault: true,\n unbundle: true,\n shims: true,\n fixedExtension: true,\n nodeProtocol: true,\n clean: false\n} as const;\n\n/**\n * Resolves the entry options for [tsdown](https://github.com/rolldown/tsdown).\n *\n * @param formats - The formats to resolve.\n * @returns The resolved entry options.\n */\nexport function resolveTsdownFormat(\n formats?: Format | Format[]\n): TsdownFormat[] {\n return toArray(formats).map(format => {\n switch (format) {\n case \"cjs\":\n return \"cjs\";\n case \"iife\":\n return \"iife\";\n case \"esm\":\n default:\n return \"esm\";\n }\n });\n}\n\n/**\n * Resolves the entry options for [tsdown](https://github.com/rolldown/tsdown).\n *\n * @param formats - The formats to resolve.\n * @returns The resolved entry options.\n */\nexport function resolveFromTsdownFormat(\n formats?: TsdownFormat | TsdownFormat[]\n): Format[] {\n return toArray(formats).map(format => {\n switch (format) {\n case \"cjs\":\n case \"commonjs\":\n return \"cjs\";\n case \"iife\":\n return \"iife\";\n case \"esm\":\n case \"es\":\n case \"module\":\n case \"umd\":\n default:\n return \"esm\";\n }\n });\n}\n\nconst formatMessage = (context: Context, ...msgs: any[]) =>\n msgs\n .filter(Boolean)\n .join(\" \")\n .replace(new RegExp(`\\\\[${context.config.name}\\\\]`, \"g\"), \"\")\n .trim();\n\n/**\n * Resolves the options for [tsdown](https://github.com/rolldown/tsdown).\n *\n * @param context - The build context.\n * @returns The resolved options.\n */\nexport function extractTsdownConfig(\n context: Context\n): TsdownResolvedBuildConfig {\n return defu(\n {\n entry:\n isSetString(context.config.entry) ||\n (Array.isArray(context.config.entry) && context.config.entry.length > 0)\n ? (toArray(context.config.entry)\n .map(entry => {\n const typeDef = parseTypeDefinition(entry);\n\n return typeDef?.file;\n })\n .filter(Boolean) as string[])\n : [\"src/**/*.ts\", \"src/**/*.tsx\"],\n alias: context.builtins.reduce(\n (ret, id) => {\n const path = context.fs.ids[id];\n if (path) {\n ret[id] = path;\n }\n\n return ret;\n },\n {} as Record<string, string>\n ),\n noExternal: context.builtins\n },\n context.config.build.variant === \"tsdown\"\n ? context.config.build.override\n : {},\n context.config.build.variant === \"tsdown\"\n ? omit(context.config.build, [\"override\", \"variant\"])\n : {},\n {\n name: context.config.name,\n cwd: appendPath(\n context.config.projectRoot,\n context.workspaceConfig.workspaceRoot\n ),\n dts: {\n parallel: true,\n newContext: true,\n cwd: appendPath(\n context.config.projectRoot,\n context.workspaceConfig.workspaceRoot\n ),\n tsconfig: appendPath(\n context.tsconfig.tsconfigFilePath,\n context.workspaceConfig.workspaceRoot\n ),\n sourcemap: context.config.mode === \"development\"\n },\n outDir: appendPath(\n context.config.output.buildPath,\n context.workspaceConfig.workspaceRoot\n ),\n tsconfig: appendPath(\n context.tsconfig.tsconfigFilePath,\n context.workspaceConfig.workspaceRoot\n ),\n format: resolveTsdownFormat(context.config.output.format).filter(Boolean),\n mode: context.config.mode,\n treeshake:\n context.config.build.variant === \"tsdown\"\n ? (context.config.build as TsdownBuildConfig)?.treeshake\n : context.config.build.variant === \"tsup\"\n ? (context.config.build as TsupBuildConfig)?.treeshake\n : context.config.build.variant === \"esbuild\"\n ? (context.config.build as ESBuildBuildConfig)?.treeShaking\n : undefined,\n minify: context.config.mode === \"production\",\n metafile: context.config.mode === \"development\",\n sourcemap: context.config.mode === \"development\",\n debug: context.config.mode === \"development\",\n silent:\n context.config.logLevel === null ||\n context.config.mode === \"production\",\n logLevel:\n context.config.logLevel === \"trace\" ? \"debug\" : context.config.logLevel,\n customLogger: {\n level:\n context.config.logLevel === \"trace\"\n ? \"debug\"\n : context.config.logLevel,\n info: (...msgs: any[]) =>\n isSetString(formatMessage(context, ...msgs).replace(/\\s+/g, \"\")) &&\n context.info(formatMessage(context, ...msgs)),\n warn: (...msgs: any[]) =>\n isSetString(formatMessage(context, ...msgs).replace(/\\s+/g, \"\")) &&\n context.warn(formatMessage(context, ...msgs)),\n warnOnce: (...msgs: any[]) =>\n isSetString(formatMessage(context, ...msgs).replace(/\\s+/g, \"\")) &&\n context.warn(formatMessage(context, ...msgs)),\n error: (...msgs: any[]) =>\n isSetString(formatMessage(context, ...msgs).replace(/\\s+/g, \"\")) &&\n context.error(formatMessage(context, ...msgs)),\n success: (...msgs: any[]) =>\n isSetString(formatMessage(context, ...msgs).replace(/\\s+/g, \"\")) &&\n context.info(formatMessage(context, ...msgs))\n }\n } as TsdownResolvedBuildConfig,\n DEFAULT_TSDOWN_CONFIG\n );\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunk63DAS6TJ_cjs = require('./chunk-63DAS6TJ.cjs');
|
|
4
|
-
var
|
|
4
|
+
var chunkCLLQO726_cjs = require('./chunk-CLLQO726.cjs');
|
|
5
5
|
var chunkPK6SKIKE_cjs = require('./chunk-PK6SKIKE.cjs');
|
|
6
6
|
var resolve = require('@stryke/fs/resolve');
|
|
7
7
|
var isFunction = require('@stryke/type-checks/is-function');
|
|
@@ -18,7 +18,7 @@ var PLUGIN_NON_HOOK_FIELDS = [
|
|
|
18
18
|
];
|
|
19
19
|
|
|
20
20
|
// src/lib/contexts/environment-context.ts
|
|
21
|
-
var PowerlinesEnvironmentContext = class _PowerlinesEnvironmentContext extends
|
|
21
|
+
var PowerlinesEnvironmentContext = class _PowerlinesEnvironmentContext extends chunkCLLQO726_cjs.PowerlinesContext {
|
|
22
22
|
static {
|
|
23
23
|
chunkPK6SKIKE_cjs.__name(this, "PowerlinesEnvironmentContext");
|
|
24
24
|
}
|
|
@@ -36,10 +36,11 @@ var PowerlinesEnvironmentContext = class _PowerlinesEnvironmentContext extends c
|
|
|
36
36
|
static async fromConfig(workspaceConfig, config) {
|
|
37
37
|
const context = new _PowerlinesEnvironmentContext(config, workspaceConfig);
|
|
38
38
|
await context.init();
|
|
39
|
-
|
|
40
|
-
if (!
|
|
39
|
+
const powerlinesPath = await resolve.resolvePackage("powerlines");
|
|
40
|
+
if (!powerlinesPath) {
|
|
41
41
|
throw new Error("Could not resolve `powerlines` package location.");
|
|
42
42
|
}
|
|
43
|
+
context.powerlinesPath = powerlinesPath;
|
|
43
44
|
return context;
|
|
44
45
|
}
|
|
45
46
|
/**
|
|
@@ -66,10 +67,10 @@ var PowerlinesEnvironmentContext = class _PowerlinesEnvironmentContext extends c
|
|
|
66
67
|
if (!result || isObject.isObject(result) && Object.keys(result).length === 0) {
|
|
67
68
|
return;
|
|
68
69
|
}
|
|
69
|
-
if (
|
|
70
|
+
if (chunkCLLQO726_cjs.isPluginConfig(result)) {
|
|
70
71
|
return this.$$internal.addPlugin(result);
|
|
71
72
|
}
|
|
72
|
-
resolvedPlugin =
|
|
73
|
+
resolvedPlugin = chunkCLLQO726_cjs.isPlugin(result) ? result : plugin;
|
|
73
74
|
}
|
|
74
75
|
const context = chunk63DAS6TJ_cjs.createPluginContext(resolvedPlugin, this);
|
|
75
76
|
this.plugins.push({
|
|
@@ -79,28 +80,28 @@ var PowerlinesEnvironmentContext = class _PowerlinesEnvironmentContext extends c
|
|
|
79
80
|
this.#hooks = Object.keys(resolvedPlugin).filter((key) => !PLUGIN_NON_HOOK_FIELDS.includes(key)).reduce((ret, key) => {
|
|
80
81
|
const hook = key;
|
|
81
82
|
const pluginHook = resolvedPlugin[hook];
|
|
82
|
-
if (!
|
|
83
|
+
if (!chunkCLLQO726_cjs.isPluginHook(pluginHook)) {
|
|
83
84
|
return ret;
|
|
84
85
|
}
|
|
85
|
-
if (!
|
|
86
|
+
if (!chunkCLLQO726_cjs.isHookExternal(hook)) {
|
|
86
87
|
ret[hook] ??= {};
|
|
87
88
|
if (resolvedPlugin.enforce) {
|
|
88
89
|
ret[hook][`${resolvedPlugin.enforce}Enforced`] ??= [];
|
|
89
|
-
|
|
90
|
+
chunkCLLQO726_cjs.addPluginHook(context, resolvedPlugin, pluginHook, ret[hook][`${resolvedPlugin.enforce}Enforced`]);
|
|
90
91
|
return ret;
|
|
91
92
|
}
|
|
92
93
|
if (isFunction.isFunction(pluginHook) || !pluginHook.order) {
|
|
93
94
|
ret[hook].normal ??= [];
|
|
94
|
-
|
|
95
|
+
chunkCLLQO726_cjs.addPluginHook(context, resolvedPlugin, pluginHook, ret[hook].normal);
|
|
95
96
|
return ret;
|
|
96
97
|
}
|
|
97
98
|
ret[hook][`${pluginHook.order}Ordered`] ??= [];
|
|
98
|
-
|
|
99
|
+
chunkCLLQO726_cjs.addPluginHook(context, resolvedPlugin, pluginHook, ret[hook][`${pluginHook.order}Ordered`]);
|
|
99
100
|
} else {
|
|
100
101
|
ret[hook] ??= [];
|
|
101
102
|
ret[hook].push({
|
|
102
103
|
plugin: resolvedPlugin,
|
|
103
|
-
hook:
|
|
104
|
+
hook: chunkCLLQO726_cjs.getHookHandler(pluginHook).bind(context)
|
|
104
105
|
});
|
|
105
106
|
}
|
|
106
107
|
return ret;
|
|
@@ -112,7 +113,7 @@ var PowerlinesEnvironmentContext = class _PowerlinesEnvironmentContext extends c
|
|
|
112
113
|
selectHooks(hook, options) {
|
|
113
114
|
const result = [];
|
|
114
115
|
if (this.hooks[hook]) {
|
|
115
|
-
if (!
|
|
116
|
+
if (!chunkCLLQO726_cjs.isHookExternal(hook)) {
|
|
116
117
|
const hooks = this.hooks[hook];
|
|
117
118
|
if (options?.order) {
|
|
118
119
|
if (options?.order === "pre") {
|
|
@@ -202,5 +203,5 @@ var PowerlinesEnvironmentContext = class _PowerlinesEnvironmentContext extends c
|
|
|
202
203
|
};
|
|
203
204
|
|
|
204
205
|
exports.PowerlinesEnvironmentContext = PowerlinesEnvironmentContext;
|
|
205
|
-
//# sourceMappingURL=chunk-
|
|
206
|
-
//# sourceMappingURL=chunk-
|
|
206
|
+
//# sourceMappingURL=chunk-Q2CL3VW4.cjs.map
|
|
207
|
+
//# sourceMappingURL=chunk-Q2CL3VW4.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/types/plugin.ts","../../src/lib/contexts/environment-context.ts"],"names":["PLUGIN_NON_HOOK_FIELDS","PowerlinesEnvironmentContext","PowerlinesContext","fromConfig","workspaceConfig","config","context","init","powerlinesPath","resolvePackage","Error","environment","plugins","hooks","addPlugin","plugin","resolvedPlugin","isFunction","applyToEnvironment","result","Promise","resolve","isObject","Object","keys","length","isPluginConfig","$$internal","isPlugin","createPluginContext","push","filter","key","includes","reduce","ret","hook","pluginHook","isPluginHook","isHookExternal","enforce","addPluginHook","order","normal","getHookHandler","bind","selectHooks","options","preOrdered","map","h","find","p","name","handle","handler","preEnforced","postOrdered","postEnforced","resolvedConfig"],"mappings":";;;;;;;;;;AA4YO,IAAMA,sBAAAA,GAAyB;AACpC,EAAA,MAAA;AACA,EAAA,KAAA;AACA,EAAA,SAAA;AACA,EAAA,QAAA;AACA,EAAA,WAAA;AACA,EAAA;;;;ACnWK,IAAMC,4BAAAA,GAAN,MAAMA,6BAAAA,SAGHC,mCAAAA,CAAAA;EAlDV;;;;;;AAwDE,EAAA,MAAA,GAAoD,EAAC;;;;;;;;EAWrD,aAAoBC,UAAAA,CAGlBC,iBACAC,MAAAA,EACwD;AACxD,IAAA,MAAMC,OAAAA,GAAU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GACN,IAAA,CAAKjB,KAAAA,CAAMuB,IAAAA,CAAAA,CAAMa,GAAAA,CAAIC,CAAAA,CAAAA,KAAAA;AACtB,UAAA,MAAMnC,MAAAA,GAAS,IAAA,CAAKH,OAAAA,CAAQuC,IAAAA,CAC1BC,CAAAA,CAAAA,KAAKA,CAAAA,CAAErC,MAAAA,CAAOsC,IAAAA,KAASH,CAAAA,CAAEnC,MAAAA,CAAOsC,IAAI,CAAA;AAEtC,UAAA,IAAI,CAACtC,MAAAA,EAAQ;AACX,YAAA,MAAM,IAAIL,KAAAA,CACR,CAAA,0CAAA,EAA6CwC,CAAAA,CAAEnC,MAAAA,CAAOsC,IAAI,CAAA,EAAA,CAAI,CAAA;AAElE,UAAA;AAEA,UAAA,OAAO;AACLC,YAAAA,MAAAA,EAAQJ,CAAAA,CAAEK,OAAAA;AACVjD,YAAAA,OAAAA,EAASS,MAAAA,CAAOT;AAClB,WAAA;AACF,QAAA,CAAA,CAAA,CAAA;AAEJ,MAAA;AACF,IAAA;AAEA,IAAA,OAAOa,MAAAA;AACT,EAAA;AAEA,EAAA,WAAA,CACEd,QACAD,eAAAA,EACA;AACA,IAAA,KAAA,CAAMA,eAAAA,CAAAA;AAEN,IAAA,IAAA,CAAKuD,cAAAA,GAAiBtD,MAAAA;AACxB,EAAA;AACF","file":"chunk-Q2CL3VW4.cjs","sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { ArrayValues } from \"@stryke/types/array\";\nimport type { FunctionLike, MaybePromise } from \"@stryke/types/base\";\nimport type {\n ExternalIdResult,\n HookFilter,\n TransformResult,\n UnpluginOptions\n} from \"unplugin\";\nimport type { UnpluginBuildVariant } from \"./build\";\nimport type { CommandType } from \"./commands\";\nimport type { EnvironmentConfig, PluginConfig } from \"./config\";\nimport type {\n BuildPluginContext,\n PluginContext,\n UnresolvedContext\n} from \"./context\";\nimport type { EnvironmentResolvedConfig, ResolvedConfig } from \"./resolved\";\n\nexport interface PluginHookObject<\n THookFunction extends FunctionLike,\n TFilter extends keyof HookFilter = never\n> {\n /**\n * The order in which the plugin should be applied.\n */\n order?: \"pre\" | \"post\" | null | undefined;\n\n /**\n * A filter to determine when the hook should be called.\n */\n filter?: Pick<HookFilter, TFilter>;\n\n /**\n * The hook function to be called.\n */\n handler: THookFunction;\n}\n\nexport type PluginHook<\n THookFunction extends FunctionLike,\n TFilter extends keyof HookFilter = never\n> = THookFunction | PluginHookObject<THookFunction, TFilter>;\n\n/**\n * A result returned by the plugin from the `types` hook that describes the declaration types output file.\n */\nexport interface TypesResult {\n directives?: string[];\n code: string;\n}\n\ntype DeepPartial<T> = {\n [K in keyof T]?: DeepPartial<T[K]>;\n};\n\nexport type ConfigResult<TContext extends PluginContext = PluginContext> =\n DeepPartial<TContext[\"config\"]> & Record<string, any>;\n\nexport interface BasePluginHookFunctions<\n TContext extends PluginContext = PluginContext\n> extends Record<CommandType, (this: TContext) => MaybePromise<void>> {\n /**\n * A function that returns configuration options to be merged with the build context's options.\n *\n * @remarks\n * Modify config before it's resolved. The hook can either mutate {@link Context.config} on the passed-in context directly, or return a partial config object that will be deeply merged into existing config.\n *\n * @warning User plugins are resolved before running this hook so injecting other plugins inside the config hook will have no effect. If you want to add plugins, consider doing so in the {@link Plugin.dependsOn} property instead.\n *\n * @see https://vitejs.dev/guide/api-plugin#config\n *\n * @param this - The build context.\n * @param config - The partial configuration object to be modified.\n * @returns A promise that resolves to a partial configuration object.\n */\n config: (\n this: UnresolvedContext<TContext[\"config\"]>\n ) => MaybePromise<ConfigResult<TContext>>;\n\n /**\n * Modify environment configs before it's resolved. The hook can either mutate the passed-in environment config directly, or return a partial config object that will be deeply merged into existing config.\n *\n * @remarks\n * This hook is called for each environment with a partially resolved environment config that already accounts for the default environment config values set at the root level. If plugins need to modify the config of a given environment, they should do it in this hook instead of the config hook. Leaving the config hook only for modifying the root default environment config.\n *\n * @see https://vitejs.dev/guide/api-plugin#configenvironment\n *\n * @param this - The build context.\n * @param name - The name of the environment being configured.\n * @param environment - The Vite-like environment object containing information about the current build environment.\n * @returns A promise that resolves when the hook is complete.\n */\n configEnvironment: (\n this: TContext,\n name: string,\n environment: EnvironmentConfig\n ) => MaybePromise<Partial<EnvironmentResolvedConfig> | undefined | null>;\n\n /**\n * A hook that is called when the plugin is resolved.\n *\n * @see https://vitejs.dev/guide/api-plugin#configresolved\n *\n * @param this - The build context.\n * @returns A promise that resolves when the hook is complete.\n */\n configResolved: (this: TContext) => MaybePromise<void>;\n\n /**\n * A hook that is called to overwrite the generated declaration types file (.d.ts). The generated type definitions should describe the built-in modules/logic added during the `prepare` task.\n *\n * @param this - The build context.\n * @param code - The source code to generate types for.\n * @returns A promise that resolves when the hook is complete.\n */\n types: (\n this: TContext,\n code: string\n ) => MaybePromise<TypesResult | string | undefined | null>;\n\n /**\n * A hook that is called at the start of the build process.\n *\n * @param this - The build context and unplugin build context.\n * @returns A promise that resolves when the hook is complete.\n */\n buildStart: (\n this: BuildPluginContext<TContext[\"config\"]> & TContext\n ) => MaybePromise<void>;\n\n /**\n * A hook that is called at the end of the build process.\n *\n * @param this - The build context and unplugin build context.\n * @returns A promise that resolves when the hook is complete.\n */\n buildEnd: (\n this: BuildPluginContext<TContext[\"config\"]> & TContext\n ) => MaybePromise<void>;\n\n /**\n * A hook that is called to transform the source code.\n *\n * @param this - The build context, unplugin build context, and unplugin context.\n * @param code - The source code to transform.\n * @param id - The identifier of the source code.\n * @returns A promise that resolves when the hook is complete.\n */\n transform: (\n this: BuildPluginContext<TContext[\"config\"]> & TContext,\n code: string,\n id: string\n ) => MaybePromise<TransformResult>;\n\n /**\n * A hook that is called to load the source code.\n *\n * @param this - The build context, unplugin build context, and unplugin context.\n * @param id - The identifier of the source code.\n * @returns A promise that resolves when the hook is complete.\n */\n load: (\n this: BuildPluginContext<TContext[\"config\"]> & TContext,\n id: string\n ) => MaybePromise<TransformResult>;\n\n /**\n * A hook that is called to resolve the identifier of the source code.\n *\n * @param this - The build context, unplugin build context, and unplugin context.\n * @param id - The identifier of the source code.\n * @param importer - The importer of the source code.\n * @param options - The options for resolving the identifier.\n * @returns A promise that resolves when the hook is complete.\n */\n resolveId: (\n this: BuildPluginContext<TContext[\"config\"]> & TContext,\n id: string,\n importer: string | undefined,\n options: { isEntry: boolean }\n ) => MaybePromise<string | ExternalIdResult | null | undefined>;\n\n /**\n * A hook that is called to write the bundle to disk.\n *\n * @param this - The build context.\n * @returns A promise that resolves when the hook is complete.\n */\n writeBundle: (this: TContext) => MaybePromise<void>;\n}\n\nexport type BuildPlugin<\n TContext extends PluginContext = PluginContext,\n TBuildVariant extends UnpluginBuildVariant = UnpluginBuildVariant,\n TOptions extends Required<UnpluginOptions>[TBuildVariant] =\n Required<UnpluginOptions>[TBuildVariant]\n> = {\n [TKey in keyof TOptions]: TOptions[TKey] extends FunctionLike\n ? (\n this: ThisParameterType<TOptions[TKey]> & TContext,\n ...args: Parameters<TOptions[TKey]>\n ) => ReturnType<TOptions[TKey]> | MaybePromise<ReturnType<TOptions[TKey]>>\n : TOptions[TKey];\n};\n\nexport type ExternalPluginHookFunctionsVariant<\n TContext extends PluginContext = PluginContext,\n TBuildVariant extends UnpluginBuildVariant = UnpluginBuildVariant\n> = {\n [TKey in keyof BuildPlugin<TContext, TBuildVariant> &\n string as `${TBuildVariant}:${TKey}`]: BuildPlugin<\n TContext,\n TBuildVariant\n >[TKey];\n};\n\nexport type ExternalPluginHookFunctions<TContext extends PluginContext> =\n ExternalPluginHookFunctionsVariant<TContext, \"vite\"> &\n ExternalPluginHookFunctionsVariant<TContext, \"esbuild\"> &\n ExternalPluginHookFunctionsVariant<TContext, \"rolldown\"> &\n ExternalPluginHookFunctionsVariant<TContext, \"rollup\"> &\n ExternalPluginHookFunctionsVariant<TContext, \"webpack\"> &\n ExternalPluginHookFunctionsVariant<TContext, \"rspack\"> &\n ExternalPluginHookFunctionsVariant<TContext, \"farm\">;\n\nexport type PluginHookFunctions<\n TContext extends PluginContext = PluginContext\n> = BasePluginHookFunctions<TContext> & ExternalPluginHookFunctions<TContext>;\n\nexport type PluginHooks<TContext extends PluginContext = PluginContext> = {\n [TKey in keyof BasePluginHookFunctions<TContext>]: PluginHook<\n BasePluginHookFunctions<TContext>[TKey]\n >;\n} & {\n /**\n * A function that returns configuration options to be merged with the build context's options.\n *\n * @remarks\n * Modify config before it's resolved. The hook can either mutate {@link Context.config} on the passed-in context directly, or return a partial config object that will be deeply merged into existing config.\n *\n * @warning User plugins are resolved before running this hook so injecting other plugins inside the config hook will have no effect. If you want to add plugins, consider doing so in the {@link Plugin.dependsOn} property instead.\n *\n * @see https://vitejs.dev/guide/api-plugin#config\n *\n * @param this - The build context.\n * @param config - The partial configuration object to be modified.\n * @returns A promise that resolves to a partial configuration object.\n */\n config:\n | PluginHook<\n (\n this: UnresolvedContext<TContext[\"config\"]>\n ) => MaybePromise<ConfigResult<TContext>>\n >\n | ConfigResult<TContext>;\n\n /**\n * A hook that is called to transform the source code.\n *\n * @param this - The build context, unplugin build context, and unplugin context.\n * @param code - The source code to transform.\n * @param id - The identifier of the source code.\n * @returns A promise that resolves when the hook is complete.\n */\n transform: PluginHook<\n (\n this: BuildPluginContext<TContext[\"config\"]> & TContext,\n code: string,\n id: string\n ) => MaybePromise<TransformResult>,\n \"code\" | \"id\"\n >;\n\n /**\n * A hook that is called to load the source code.\n *\n * @param this - The build context, unplugin build context, and unplugin context.\n * @param id - The identifier of the source code.\n * @returns A promise that resolves when the hook is complete.\n */\n load: PluginHook<\n (\n this: BuildPluginContext<TContext[\"config\"]> & TContext,\n id: string\n ) => MaybePromise<TransformResult>,\n \"id\"\n >;\n\n /**\n * A hook that is called to resolve the identifier of the source code.\n *\n * @param this - The build context, unplugin build context, and unplugin context.\n * @param id - The identifier of the source code.\n * @param importer - The importer of the source code.\n * @param options - The options for resolving the identifier.\n * @returns A promise that resolves when the hook is complete.\n */\n resolveId: PluginHook<\n (\n this: BuildPluginContext<TContext[\"config\"]> & TContext,\n id: string,\n importer: string | undefined,\n options: { isEntry: boolean }\n ) => MaybePromise<string | ExternalIdResult | null | undefined>,\n \"id\"\n >;\n};\n\nexport type PluginBuildPlugins<TContext extends PluginContext = PluginContext> =\n {\n [TBuildVariant in UnpluginBuildVariant]?: BuildPlugin<\n TContext,\n TBuildVariant\n >;\n };\n\nexport interface Plugin<\n in out TContext extends PluginContext<ResolvedConfig> =\n PluginContext<ResolvedConfig>\n>\n extends Partial<PluginHooks<TContext>>, PluginBuildPlugins<TContext> {\n /**\n * The name of the plugin, for use in deduplication, error messages and logs.\n */\n name: string;\n\n /**\n * An API object that can be used for inter-plugin communication.\n *\n * @see https://rollupjs.org/plugin-development/#direct-plugin-communication\n */\n api?: Record<string, any>;\n\n /**\n * Enforce plugin invocation tier similar to webpack loaders. Hooks ordering is still subject to the `order` property in the hook object.\n *\n * @remarks\n * The Plugin invocation order is as follows:\n * - `enforce: 'pre'` plugins\n * - `order: 'pre'` plugin hooks\n * - any other plugins (normal)\n * - `order: 'post'` plugin hooks\n * - `enforce: 'post'` plugins\n *\n * @see https://vitejs.dev/guide/api-plugin.html#plugin-ordering\n * @see https://rollupjs.org/plugin-development/#build-hooks\n * @see https://webpack.js.org/concepts/loaders/#enforce---pre-and-post\n * @see https://esbuild.github.io/plugins/#concepts\n */\n enforce?: \"pre\" | \"post\";\n\n /**\n * A function to determine if two plugins are the same and can be de-duplicated.\n *\n * @remarks\n * If this is not provided, plugins are de-duplicated by comparing their names.\n *\n * @param other - The other plugin to compare against.\n * @returns `true` if the two plugins are the same, `false` otherwise.\n */\n dedupe?: false | ((other: Plugin<any>) => boolean);\n\n /**\n * A list of pre-requisite plugins that must be loaded before this plugin can be used.\n */\n dependsOn?: PluginConfig<any>[];\n\n /**\n * Define environments where this plugin should be active. By default, the plugin is active in all environments.\n *\n * @param environment - The environment to check.\n * @returns `true` if the plugin should be active in the specified environment, `false` otherwise.\n */\n applyToEnvironment?: (\n environment: EnvironmentResolvedConfig\n ) => boolean | PluginConfig<any>;\n}\n\nexport const PLUGIN_NON_HOOK_FIELDS = [\n \"name\",\n \"api\",\n \"enforce\",\n \"dedupe\",\n \"dependsOn\",\n \"applyToEnvironment\"\n] as const;\n\nexport type PluginNonHookFields =\n | ArrayValues<typeof PLUGIN_NON_HOOK_FIELDS>\n | UnpluginBuildVariant;\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { resolvePackage } from \"@stryke/fs/resolve\";\nimport { isFunction } from \"@stryke/type-checks/is-function\";\nimport { isObject } from \"@stryke/type-checks/is-object\";\nimport { ArrayValues } from \"@stryke/types/array\";\nimport {\n addPluginHook,\n getHookHandler,\n isHookExternal,\n isPlugin,\n isPluginConfig,\n isPluginHook\n} from \"../../plugin-utils/helpers\";\nimport { WorkspaceConfig } from \"../../types/config\";\nimport {\n EnvironmentContext,\n EnvironmentContextPlugin,\n PluginContext,\n SelectHooksOptions,\n SelectHooksResult\n} from \"../../types/context\";\nimport { BaseHooksList, HookKeys, HooksList } from \"../../types/hooks\";\nimport { Plugin, PLUGIN_NON_HOOK_FIELDS } from \"../../types/plugin\";\nimport {\n EnvironmentResolvedConfig,\n ResolvedConfig\n} from \"../../types/resolved\";\nimport { PowerlinesContext } from \"./context\";\nimport { createPluginContext } from \"./plugin-context\";\n\nexport class PowerlinesEnvironmentContext<\n TResolvedConfig extends ResolvedConfig = ResolvedConfig\n>\n extends PowerlinesContext<TResolvedConfig>\n implements EnvironmentContext<TResolvedConfig>\n{\n /**\n * The hooks registered by plugins in this environment\n */\n #hooks: HooksList<PluginContext<TResolvedConfig>> = {} as HooksList<\n PluginContext<TResolvedConfig>\n >;\n\n /**\n * Create a new Storm context from the workspace root and user config.\n *\n * @param workspaceConfig - The root directory of the workspace.\n * @param config - The user configuration options.\n * @returns A promise that resolves to the new context.\n */\n public static async fromConfig<\n TResolvedConfig extends ResolvedConfig = ResolvedConfig\n >(\n workspaceConfig: WorkspaceConfig,\n config: TResolvedConfig\n ): Promise<PowerlinesEnvironmentContext<TResolvedConfig>> {\n const context = new PowerlinesEnvironmentContext<TResolvedConfig>(\n config,\n workspaceConfig\n );\n await context.init();\n\n const powerlinesPath = await resolvePackage(\"powerlines\");\n if (!powerlinesPath) {\n throw new Error(\"Could not resolve `powerlines` package location.\");\n }\n\n context.powerlinesPath = powerlinesPath;\n\n return context;\n }\n\n /**\n * The resolved environment configuration\n */\n public environment!: EnvironmentResolvedConfig;\n\n /**\n * The list of plugins applied to this environment\n */\n public plugins: EnvironmentContextPlugin<TResolvedConfig>[] = [];\n\n /**\n * The resolved configuration options\n */\n public override get config(): TResolvedConfig {\n return super.config;\n }\n\n public get hooks(): HooksList<PluginContext<TResolvedConfig>> {\n return this.#hooks;\n }\n\n public async addPlugin(plugin: Plugin<PluginContext<TResolvedConfig>>) {\n let resolvedPlugin = plugin;\n if (isFunction(plugin.applyToEnvironment)) {\n const result = await Promise.resolve(\n plugin.applyToEnvironment(this.environment)\n );\n\n if (!result || (isObject(result) && Object.keys(result).length === 0)) {\n return;\n }\n\n if (isPluginConfig(result)) {\n return this.$$internal.addPlugin(result);\n }\n\n resolvedPlugin = isPlugin<TResolvedConfig>(result) ? result : plugin;\n }\n\n const context = createPluginContext<TResolvedConfig>(resolvedPlugin, this);\n\n this.plugins.push({\n plugin: resolvedPlugin,\n context\n });\n\n this.#hooks = Object.keys(resolvedPlugin)\n .filter(\n key =>\n !PLUGIN_NON_HOOK_FIELDS.includes(\n key as ArrayValues<typeof PLUGIN_NON_HOOK_FIELDS>\n )\n )\n .reduce((ret, key) => {\n const hook = key as keyof HooksList<PluginContext<TResolvedConfig>>;\n const pluginHook = resolvedPlugin[hook as keyof typeof resolvedPlugin];\n if (!isPluginHook(pluginHook)) {\n return ret;\n }\n\n if (!isHookExternal(hook)) {\n ret[hook] ??= {};\n if (resolvedPlugin.enforce) {\n ret[hook][`${resolvedPlugin.enforce}Enforced`] ??= [];\n\n addPluginHook(\n context,\n resolvedPlugin,\n pluginHook,\n ret[hook][`${resolvedPlugin.enforce}Enforced`]!\n );\n\n return ret;\n }\n\n if (isFunction(pluginHook) || !pluginHook.order) {\n ret[hook].normal ??= [];\n\n addPluginHook(\n context,\n resolvedPlugin,\n pluginHook,\n ret[hook].normal\n );\n\n return ret;\n }\n\n ret[hook][`${pluginHook.order}Ordered`] ??= [];\n\n addPluginHook(\n context,\n resolvedPlugin,\n pluginHook,\n ret[hook][`${pluginHook.order}Ordered`]!\n );\n } else {\n ret[hook] ??= [];\n ret[hook].push({\n plugin: resolvedPlugin,\n hook: getHookHandler(pluginHook).bind(context)\n } as any);\n }\n\n return ret;\n }, this.hooks);\n }\n\n /**\n * Retrieves the hook handlers for a specific hook name\n */\n public selectHooks<TKey extends HookKeys<PluginContext<TResolvedConfig>>>(\n hook: TKey,\n options?: SelectHooksOptions\n ): SelectHooksResult<TResolvedConfig, TKey>[] {\n const result = [] as SelectHooksResult<TResolvedConfig, TKey>[];\n\n if (this.hooks[hook]) {\n if (!isHookExternal(hook)) {\n const hooks = this.hooks[hook] as BaseHooksList<\n PluginContext<TResolvedConfig>\n >;\n if (options?.order) {\n if (options?.order === \"pre\") {\n result.push(\n ...(hooks.preOrdered ?? []).map(h => {\n const plugin = this.plugins.find(\n p => p.plugin.name === h.plugin.name\n );\n if (!plugin) {\n throw new Error(\n `Could not find plugin context for plugin \"${\n h.plugin.name\n }\".`\n );\n }\n\n return {\n handle: h.handler,\n context: plugin.context\n };\n })\n );\n result.push(\n ...(hooks.preEnforced ?? []).map(h => {\n const plugin = this.plugins.find(\n p => p.plugin.name === h.plugin.name\n );\n if (!plugin) {\n throw new Error(\n `Could not find plugin context for plugin \"${\n h.plugin.name\n }\".`\n );\n }\n\n return {\n handle: h.handler,\n context: plugin.context\n };\n })\n );\n } else if (options?.order === \"post\") {\n result.push(\n ...(hooks.postOrdered ?? []).map(h => {\n const plugin = this.plugins.find(\n p => p.plugin.name === h.plugin.name\n );\n if (!plugin) {\n throw new Error(\n `Could not find plugin context for plugin \"${\n h.plugin.name\n }\".`\n );\n }\n\n return {\n handle: h.handler,\n context: plugin.context\n };\n })\n );\n result.push(\n ...(hooks.postEnforced ?? []).map(h => {\n const plugin = this.plugins.find(\n p => p.plugin.name === h.plugin.name\n );\n if (!plugin) {\n throw new Error(\n `Could not find plugin context for plugin \"${\n h.plugin.name\n }\".`\n );\n }\n\n return {\n handle: h.handler,\n context: plugin.context\n };\n })\n );\n } else {\n result.push(\n ...(hooks.normal ?? []).map(h => {\n const plugin = this.plugins.find(\n p => p.plugin.name === h.plugin.name\n );\n if (!plugin) {\n throw new Error(\n `Could not find plugin context for plugin \"${\n h.plugin.name\n }\".`\n );\n }\n\n return {\n handle: h.handler,\n context: plugin.context\n };\n })\n );\n }\n } else {\n result.push(...this.selectHooks(hook, { order: \"pre\" }));\n result.push(...this.selectHooks(hook, { order: \"normal\" }));\n result.push(...this.selectHooks(hook, { order: \"post\" }));\n }\n } else {\n result.push(\n ...this.hooks[hook].map(h => {\n const plugin = this.plugins.find(\n p => p.plugin.name === h.plugin.name\n );\n if (!plugin) {\n throw new Error(\n `Could not find plugin context for plugin \"${h.plugin.name}\".`\n );\n }\n\n return {\n handle: h.handler,\n context: plugin.context\n };\n })\n );\n }\n }\n\n return result;\n }\n\n protected constructor(\n config: TResolvedConfig,\n workspaceConfig: WorkspaceConfig\n ) {\n super(workspaceConfig);\n\n this.resolvedConfig = config;\n }\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { PowerlinesEnvironmentContext } from './chunk-
|
|
2
|
-
import { PowerlinesContext } from './chunk-
|
|
1
|
+
import { PowerlinesEnvironmentContext } from './chunk-5FVICSI2.js';
|
|
2
|
+
import { PowerlinesContext } from './chunk-VN2OA25X.js';
|
|
3
3
|
import { loadWorkspaceConfig } from './chunk-Q25ZPXA7.js';
|
|
4
4
|
import { __name } from './chunk-7QVYU63E.js';
|
|
5
5
|
import { LogLevelLabel } from '@storm-software/config-tools/types';
|
|
@@ -74,10 +74,11 @@ var PowerlinesAPIContext = class _PowerlinesAPIContext extends PowerlinesContext
|
|
|
74
74
|
static async from(workspaceRoot, config) {
|
|
75
75
|
const context = new _PowerlinesAPIContext(await loadWorkspaceConfig(workspaceRoot, config.root));
|
|
76
76
|
await context.withUserConfig(config);
|
|
77
|
-
|
|
78
|
-
if (!
|
|
77
|
+
const powerlinesPath = await resolvePackage("powerlines");
|
|
78
|
+
if (!powerlinesPath) {
|
|
79
79
|
throw new Error("Could not resolve `powerlines` package location.");
|
|
80
80
|
}
|
|
81
|
+
context.powerlinesPath = powerlinesPath;
|
|
81
82
|
return context;
|
|
82
83
|
}
|
|
83
84
|
/**
|
|
@@ -228,5 +229,5 @@ var PowerlinesAPIContext = class _PowerlinesAPIContext extends PowerlinesContext
|
|
|
228
229
|
};
|
|
229
230
|
|
|
230
231
|
export { PowerlinesAPIContext };
|
|
231
|
-
//# sourceMappingURL=chunk-
|
|
232
|
-
//# sourceMappingURL=chunk-
|
|
232
|
+
//# sourceMappingURL=chunk-QOTSQ6ZF.js.map
|
|
233
|
+
//# sourceMappingURL=chunk-QOTSQ6ZF.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/internal/helpers/environment.ts","../../src/lib/contexts/api-context.ts"],"names":["DEFAULT_ENVIRONMENT","createEnvironment","name","userConfig","defu","environments","title","titleCase","ssr","mainFields","build","platform","extensions","consumer","preview","port","open","strictPort","host","allowedHosts","cors","headers","undefined","createDefaultEnvironment","PowerlinesAPIContext","PowerlinesContext","from","workspaceRoot","config","context","loadWorkspaceConfig","root","withUserConfig","powerlinesPath","resolvePackage","Error","$$internal","value","environment","Object","values","log","createLog","plugins","workspaceConfig","init","Promise","all","toArray","keys","length","map","env","in","PowerlinesEnvironmentContext","fromConfig","isSetObject","inlineConfig","withInlineConfig","plugin","addPlugin","options","isHighPriority","push","getEnvironment","LogLevelLabel","DEBUG","chalk","bold","cyanBright","WARN","getEnvironmentSafe"],"mappings":";;;;;;;;;;;;AAuBO,IAAMA,mBAAAA,GAAsB,SAAA;AAE5B,SAASC,iBAAAA,CACdC,MACAC,UAAAA,EAA4C;AAE5C,EAAA,OAAOC,KACLD,UAAAA,CAAWE,YAAAA,GAAeH,IAAAA,CAAAA,IAAS,EAAC,EACpC;AACEA,IAAAA,IAAAA;AACAI,IAAAA,KAAAA,EAAOH,UAAAA,CAAWG,KAAAA,IAASC,SAAAA,CAAUJ,UAAAA,CAAWD,IAAI,CAAA;IACpDM,GAAAA,EAAK,KAAA;IACLC,UAAAA,EACEN,UAAAA,CAAWO,KAAAA,EAAOC,QAAAA,KAAa,SAAA,GAC3B;AAAC,MAAA,SAAA;AAAW,MAAA,QAAA;AAAU,MAAA,aAAA;AAAe,MAAA;AACrC,KAAA,GAAA;AAAC,MAAA,QAAA;AAAU,MAAA,aAAA;AAAe,MAAA;;IAChCC,UAAAA,EAAY;AAAC,MAAA,MAAA;AAAQ,MAAA,KAAA;AAAO,MAAA,MAAA;AAAQ,MAAA,KAAA;AAAO,MAAA,MAAA;AAAQ,MAAA,MAAA;AAAQ,MAAA;;AAC3DC,IAAAA,QAAAA,EAAUV,UAAAA,CAAWO,KAAAA,EAAOC,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AAA,CAAK8D,cAAAA,CAAe9D,IAAAA,CAAAA;IACnC,CAAA,CAAA,MAAQ;AACN,MAAA,OAAOoB,MAAAA;AACT,IAAA;AACF,EAAA;AACF","file":"chunk-QOTSQ6ZF.js","sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport defu from \"defu\";\nimport { APIContext, Context } from \"../../types/context\";\nimport { EnvironmentResolvedConfig } from \"../../types/resolved\";\n\nexport const DEFAULT_ENVIRONMENT = \"default\" as const;\n\nexport function createEnvironment<TContext extends Context = Context>(\n name: string,\n userConfig: TContext[\"config\"][\"userConfig\"]\n): EnvironmentResolvedConfig {\n return defu(\n userConfig.environments?.[name] ?? {},\n {\n name,\n title: userConfig.title || titleCase(userConfig.name),\n ssr: false,\n mainFields:\n userConfig.build?.platform === \"browser\"\n ? [\"browser\", \"module\", \"jsnext:main\", \"jsnext\"]\n : [\"module\", \"jsnext:main\", \"jsnext\"],\n extensions: [\".mjs\", \".js\", \".mts\", \".ts\", \".jsx\", \".tsx\", \".json\"],\n consumer: userConfig.build?.platform === \"browser\" ? \"client\" : \"server\",\n preview:\n userConfig.build?.platform === \"browser\"\n ? {\n port: 5173,\n open: true,\n strictPort: false,\n // https: false,\n host: \"localhost\",\n allowedHosts: [\".\"],\n cors: true,\n headers: {}\n }\n : undefined\n },\n userConfig\n ) as EnvironmentResolvedConfig;\n}\n\nexport function createDefaultEnvironment<\n TContext extends APIContext = APIContext\n>(userConfig: TContext[\"config\"][\"userConfig\"]): EnvironmentResolvedConfig {\n return createEnvironment(DEFAULT_ENVIRONMENT, userConfig);\n}\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { LogLevelLabel } from \"@storm-software/config-tools/types\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { resolvePackage } from \"@stryke/fs/resolve\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport chalk from \"chalk\";\nimport {\n createDefaultEnvironment,\n createEnvironment\n} from \"../../internal/helpers/environment\";\nimport {\n InitialUserConfig,\n InlineConfig,\n LogFn,\n UserConfig,\n WorkspaceConfig\n} from \"../../types/config\";\nimport {\n APIContext,\n EnvironmentContext,\n InitContextOptions,\n PluginContext\n} from \"../../types/context\";\nimport {\n UNSAFE_ContextInternal,\n UNSAFE_EnvironmentContext\n} from \"../../types/internal\";\nimport { Plugin } from \"../../types/plugin\";\nimport {\n EnvironmentResolvedConfig,\n ResolvedConfig\n} from \"../../types/resolved\";\nimport { loadWorkspaceConfig } from \"../config-file\";\nimport { PowerlinesContext } from \"./context\";\nimport { PowerlinesEnvironmentContext } from \"./environment-context\";\n\nexport class PowerlinesAPIContext<\n TResolvedConfig extends ResolvedConfig = ResolvedConfig\n>\n extends PowerlinesContext<TResolvedConfig>\n implements APIContext<TResolvedConfig>\n{\n #environments: Record<string, UNSAFE_EnvironmentContext<TResolvedConfig>> =\n {};\n\n #plugins: Plugin<PluginContext<TResolvedConfig>>[] = [];\n\n #log!: LogFn;\n\n /**\n * Create a new Storm context from the workspace root and user config.\n *\n * @param workspaceRoot - The root directory of the workspace.\n * @param config - The user configuration options.\n * @returns A promise that resolves to the new context.\n */\n public static override async from<\n TResolvedConfig extends ResolvedConfig = ResolvedConfig\n >(\n workspaceRoot: string,\n config: InitialUserConfig<TResolvedConfig[\"userConfig\"]>\n ): Promise<APIContext<TResolvedConfig>> {\n const context = new PowerlinesAPIContext<TResolvedConfig>(\n await loadWorkspaceConfig(workspaceRoot, config.root)\n );\n await context.withUserConfig(config);\n\n const powerlinesPath = await resolvePackage(\"powerlines\");\n if (!powerlinesPath) {\n throw new Error(\"Could not resolve `powerlines` package location.\");\n }\n\n context.powerlinesPath = powerlinesPath;\n\n return context;\n }\n\n /**\n * Internal context fields and methods\n *\n * @danger\n * This field is for internal use only and should not be accessed or modified directly. It is unstable and can be changed at anytime.\n *\n * @internal\n */\n public override get $$internal(): UNSAFE_ContextInternal<TResolvedConfig> {\n return super.$$internal;\n }\n\n /**\n * Internal context fields and methods\n *\n * @danger\n * This field is for internal use only and should not be accessed or modified directly. It is unstable and can be changed at anytime.\n *\n * @internal\n */\n public override set $$internal(\n value: UNSAFE_ContextInternal<TResolvedConfig>\n ) {\n super.$$internal = value;\n for (const environment of Object.values(this.environments)) {\n environment.$$internal = super.$$internal;\n }\n }\n\n /**\n * A record of all environments by name\n */\n public get environments(): Record<\n string,\n UNSAFE_EnvironmentContext<TResolvedConfig>\n > {\n return this.#environments;\n }\n\n public override get log(): LogFn {\n if (!this.#log) {\n this.#log = this.createLog(\"engine\");\n }\n\n return this.#log;\n }\n\n public get plugins(): Array<Plugin<PluginContext<TResolvedConfig>>> {\n return this.#plugins;\n }\n\n protected constructor(workspaceConfig: WorkspaceConfig) {\n super(workspaceConfig);\n }\n\n /**\n * Initialize the context with the provided configuration options\n *\n * @param config - The partial user configuration to use for initialization.\n */\n protected override async init(\n config: Partial<TResolvedConfig[\"userConfig\"]> = {}\n ) {\n await super.init(config);\n\n await Promise.all(\n toArray(\n this.config.userConfig.environments &&\n Object.keys(this.config.userConfig.environments).length > 0\n ? Object.keys(this.config.userConfig.environments).map(name =>\n createEnvironment(name, this.config.userConfig)\n )\n : createDefaultEnvironment(this.config.userConfig)\n ).map(async env => {\n this.#environments[env.name] = await this.in(env);\n })\n );\n }\n\n /**\n * A function to copy the context and update the fields for a specific environment\n *\n * @param environment - The environment configuration to use.\n * @returns A new context instance with the updated environment.\n */\n public async in(\n environment: EnvironmentResolvedConfig\n ): Promise<UNSAFE_EnvironmentContext<TResolvedConfig>> {\n let context: UNSAFE_EnvironmentContext<TResolvedConfig>;\n if (this.environments[environment.name]) {\n context = this.environments[environment.name] as any;\n } else {\n context = (await PowerlinesEnvironmentContext.fromConfig(\n this.workspaceConfig,\n this.config\n )) as any;\n }\n\n if (isSetObject(this.config.inlineConfig)) {\n await context.withInlineConfig(this.config.inlineConfig);\n }\n\n context.environment = environment;\n context.plugins = [];\n\n for (const plugin of this.plugins) {\n await context.addPlugin(plugin);\n }\n\n return context;\n }\n\n /**\n * Update the context using a new user configuration options\n *\n * @param userConfig - The new user configuration options.\n */\n public override async withUserConfig(\n userConfig: InitialUserConfig<TResolvedConfig[\"userConfig\"]>,\n options: InitContextOptions = {\n isHighPriority: true\n }\n ) {\n await super.withUserConfig(userConfig, options);\n\n await Promise.all(\n Object.keys(this.#environments).map(async name => {\n await this.#environments[name]!.withUserConfig(\n userConfig as UserConfig,\n options\n );\n })\n );\n }\n\n /**\n * Update the context using a new inline configuration options\n *\n * @param inlineConfig - The new inline configuration options.\n */\n public override async withInlineConfig(\n inlineConfig: TResolvedConfig[\"inlineConfig\"],\n options: InitContextOptions = {\n isHighPriority: true\n }\n ) {\n await super.withInlineConfig(inlineConfig, options);\n\n await Promise.all(\n Object.keys(this.#environments).map(async name => {\n await this.#environments[name]!.withInlineConfig(\n inlineConfig as InlineConfig,\n options\n );\n })\n );\n }\n\n /**\n * Add a plugin to the API context and all environments\n *\n * @param plugin - The plugin to add.\n */\n public async addPlugin(plugin: Plugin<PluginContext<TResolvedConfig>>) {\n this.plugins.push(plugin);\n\n await Promise.all(\n Object.keys(this.environments).map(async name => {\n await this.environments[name]!.addPlugin(plugin);\n })\n );\n }\n\n /**\n * Get an environment by name, or the default environment if no name is provided\n *\n * @param name - The name of the environment to retrieve.\n * @returns The requested environment context.\n */\n public async getEnvironment(name?: string) {\n let environment: EnvironmentContext<TResolvedConfig> | undefined;\n if (name) {\n environment = this.environments[name];\n }\n\n if (Object.keys(this.environments).length === 1) {\n environment = this.environments[Object.keys(this.environments)[0]!];\n\n this.log(\n LogLevelLabel.DEBUG,\n `Applying the only configured environment: ${chalk.bold.cyanBright(\n environment?.environment.name\n )}`\n );\n }\n\n if (!environment) {\n if (name) {\n throw new Error(`Environment \"${name}\" not found.`);\n }\n\n environment = await this.in(\n createDefaultEnvironment(this.config.userConfig)\n );\n\n this.log(\n LogLevelLabel.WARN,\n `No environment specified, and no default environment found. Using a temporary default environment: ${chalk.bold.cyanBright(\n environment?.environment.name\n )}`\n );\n }\n\n return environment;\n }\n\n public async getEnvironmentSafe(\n name?: string\n ): Promise<EnvironmentContext<TResolvedConfig> | undefined> {\n try {\n return await this.getEnvironment(name);\n } catch {\n return undefined;\n }\n }\n}\n"]}
|
|
@@ -202,10 +202,11 @@ var PowerlinesContext = class _PowerlinesContext {
|
|
|
202
202
|
static async from(workspaceRoot, config) {
|
|
203
203
|
const context = new _PowerlinesContext(await loadWorkspaceConfig(workspaceRoot, config.root));
|
|
204
204
|
await context.withUserConfig(config);
|
|
205
|
-
|
|
206
|
-
if (!
|
|
205
|
+
const powerlinesPath = await resolvePackage("powerlines");
|
|
206
|
+
if (!powerlinesPath) {
|
|
207
207
|
throw new Error("Could not resolve `powerlines` package location.");
|
|
208
208
|
}
|
|
209
|
+
context.powerlinesPath = powerlinesPath;
|
|
209
210
|
return context;
|
|
210
211
|
}
|
|
211
212
|
/**
|
|
@@ -1027,5 +1028,5 @@ var PowerlinesContext = class _PowerlinesContext {
|
|
|
1027
1028
|
};
|
|
1028
1029
|
|
|
1029
1030
|
export { PowerlinesContext, addPluginHook, checkDedupe, getHookHandler, isHookExternal, isPlugin, isPluginConfig, isPluginConfigObject, isPluginConfigTuple, isPluginHook };
|
|
1030
|
-
//# sourceMappingURL=chunk-
|
|
1031
|
-
//# sourceMappingURL=chunk-
|
|
1031
|
+
//# sourceMappingURL=chunk-VN2OA25X.js.map
|
|
1032
|
+
//# sourceMappingURL=chunk-VN2OA25X.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/internal/helpers/resolver.ts","../../src/types/commands.ts","../../src/plugin-utils/helpers.ts","../../src/lib/contexts/context.ts"],"names":["resolveOptions","options","defu","interopDefault","fsCache","mode","joinPaths","cacheDir","moduleCache","createPluginResolver","createJiti","workspaceRoot","projectRoot","createResolver","baseResolver","plugin","SUPPORTED_COMMANDS","isPlugin","value","isSetObject","isSetString","name","isUndefined","applyToEnvironment","isFunction","dedupe","dependsOn","Array","isArray","every","isPluginConfig","command","handler","isPluginConfigObject","isPluginConfigTuple","length","isPluginHookFunction","isPluginHookObject","isPluginHook","getHookHandler","pluginHook","isHookExternal","hook","startsWith","checkDedupe","plugins","some","p","addPluginHook","context","hooksList","map","push","bind","configCache","WeakMap","agent","Agent","keepAliveTimeout","setGlobalDispatcher","compose","interceptors","retry","maxRetries","minTimeout","maxTimeout","timeoutFactor","retryAfter","PowerlinesContext","uuid","Date","now","config","variant","build","projectType","type","root","title","description","sourceRoot","configFile","customLogger","logLevel","tsconfig","tsconfigRaw","skipCache","skipInstalls","entry","output","lint","transform","framework","from","loadWorkspaceConfig","withUserConfig","powerlinesPath","resolvePackage","Error","dependencies","devDependencies","persistedMeta","undefined","packageJson","projectJson","resolver","resolvePatterns","$$internal","resolveEntriesSync","toArray","tsconfigFilePath","tsconfigPathsToRegExp","paths","fs","VirtualFileSystem","createSync","checksum","meta","buildId","releaseId","timestamp","projectRootHash","murmurhash","workspaceConfig","maxLength","PROJECT_ROOT_HASH_LENGTH","configHash","CACHE_HASH_LENGTH","resolvedConfig","log","logFn","createLog","envPaths","getEnvPaths","orgId","appId","artifactsPath","builtinsPath","entryPath","dataPath","data","getPrefixedProjectRootHash","cachePath","cache","dtsPath","dts","appendPath","relativeToWorkspaceRoot","builtins","Object","values","metadata","filter","id","Boolean","program","createProgram","skipAddingFilesFromTsConfig","parserCache","create","cacheId","ttl","lruSize","persistInterval","requestCache","fetch","input","cacheKey","toString","JSON","stringify","cached","get","Response","body","status","statusText","headers","response","fetchRequest","timeout","result","text","fromEntries","entries","set","parse","code","lang","sourceType","showSemanticErrors","resolve","importer","moduleId","alias","find","a","match","replacement","isVirtual","conditions","extensions","external","skipNodeModulesBundle","noExternal","test","load","resolvedId","read","getBuiltins","Promise","all","path","emitEntry","write","isAbsolute","emitBuiltin","userConfig","isHighPriority","mergeUserConfig","init","withInlineConfig","inlineConfig","workspacePackageJsonPath","existsSync","readJsonFile","repository","url","fatal","message","LogLevelLabel","FATAL","isString","StormJSON","error","ERROR","warn","WARN","info","INFO","debug","DEBUG","trace","TRACE","isNull","extendLog","generateChecksum","hashDirectory","ignore","has","projectJsonPath","packageJsonPath","loadUserConfigFile","getTsconfigFilePath","version","outputPath","directories","builtinPrefix","assets","glob","platform","preview","environments","babel","presets","eslint","target","override","getUniqueEntries","split","titleCase","getUnique","format","buildPath","asset","replacePath","reduce","ret","replacePathTokens","polyfill","into","omit"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,SAASA,eAAeC,OAAAA,EAA8B;AACpD,EAAA,OAAOC,MAAKD,OAAAA,EAAS;IACnBE,cAAAA,EAAgB,IAAA;AAChBC,IAAAA,OAAAA,EACEH,QAAQI,IAAAA,KAAS,aAAA,GACbC,YAAUL,OAAAA,CAAQM,QAAAA,EAAU,MAAA,CAAA,GAC5B,KAAA;AACNC,IAAAA,WAAAA,EAAaP,QAAQI,IAAAA,KAAS;GAChC,CAAA;AACF;AATSL,MAAAA,CAAAA,cAAAA,EAAAA,g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AAKhM,KAAAA,GACL;KACV,EACAiM,IAAAA,CAAK5L,IAAAA,IAAQ,EAAC,EAAG;AAAC,MAAA;KAAQ,CAAA,EAC1B4L,IAAAA,CAAKD,IAAAA,IAAQ,EAAC,EAAG;AAAC,MAAA;KAAQ,CAAA,CAAA;AAG5B,IAAA,IAAI,IAAA,CAAKhN,MAAAA,CAAOiJ,UAAAA,CAAWhI,MAAAA,EAAQuL,MAAAA,EAAQ;AACzC,MAAA,IAAA,CAAKxM,MAAAA,CAAOiJ,UAAAA,CAAWhI,MAAAA,CAAOuL,MAAAA,GAASD,SAAAA,CACrClK,OAAAA,CAAQ,IAAA,CAAKrC,MAAAA,CAAOiJ,UAAAA,CAAWhI,MAAAA,EAAQuL,MAAAA,CAAAA,CAAAA;AAE3C,IAAA;AAEA,IAAA,IAAA,CAAKxM,MAAAA,CAAOiJ,UAAAA,CAAW5K,OAAAA,GAAAA,CAAW,IAAA,CAAK2B,OAAOiJ,UAAAA,CAAW5K,OAAAA,IAAW,EAAA,EACjE2G,OAAOE,OAAAA,CAAAA,CACP0H,MAAAA,CAAO,CAACC,KAAKtQ,MAAAA,KAAAA;AACZ,MAAA,IACEE,QAAAA,CAASF,MAAAA,CAAAA,IACT6B,WAAAA,CACE7B,MAAAA,EACAsQ,GAAAA,CAAI7H,MAAAA,CAAOzG,CAAAA,CAAAA,KAAK9B,QAAAA,CAAS8B,CAAAA,CAAAA,CAAAA,CAAAA,EAE3B;AACA,QAAA,OAAOsO,GAAAA;AACT,MAAA;AAEAA,MAAAA,GAAAA,CAAIjO,KAAKrC,MAAAA,CAAAA;AAET,MAAA,OAAOsQ,GAAAA;AACT,IAAA,CAAA,EAAG,EAAE,CAAA;AACT,EAAA;AACF","file":"chunk-VN2OA25X.js","sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport defu from \"defu\";\nimport { Jiti, JitiOptions, createJiti } from \"jiti\";\nimport { Resolver } from \"../../types/context\";\nimport { ResolvedConfig } from \"../../types/resolved\";\n\nexport type CreateResolverOptions = Omit<\n JitiOptions,\n \"fsCache\" | \"moduleCache\" | \"interopDefault\"\n> &\n Pick<ResolvedConfig, \"mode\" | \"logLevel\" | \"skipCache\"> & {\n workspaceRoot: string;\n projectRoot: string;\n cacheDir: string;\n };\n\n/**\n * Create a Jiti resolver for the given workspace and project root.\n *\n * @param options - The options for creating the resolver.\n * @returns A Jiti instance configured for the specified workspace and project root.\n */\nfunction resolveOptions(options: CreateResolverOptions): JitiOptions {\n return defu(options, {\n interopDefault: true,\n fsCache:\n options.mode !== \"development\"\n ? joinPaths(options.cacheDir, \"jiti\")\n : false,\n moduleCache: options.mode !== \"development\"\n });\n}\n\n/**\n * Create a Jiti resolver for the given workspace and project root.\n *\n * @param options - The options for creating the resolver.\n * @returns A Jiti instance configured for the specified workspace and project root.\n */\nfunction createPluginResolver(options: CreateResolverOptions): Jiti {\n return createJiti(\n joinPaths(options.workspaceRoot, options.projectRoot),\n resolveOptions({\n ...options\n\n // transform: (params: TransformOptions): TransformResult => {\n // if (!params.filename) {\n // return {\n // code: params.source\n // };\n // }\n\n // const babelOptions = {\n // babelrc: false,\n // configFile: false,\n // compact: false,\n // retainLines: isBoolean(params.retainLines)\n // ? params.retainLines\n // : true,\n // filename: params.filename,\n // plugins: [\n // [\n // transformModuleBabelPlugin,\n // {\n // allowTopLevelThis: true,\n // noInterop: !params.interopDefault,\n // async: params.async\n // }\n // ],\n // [importMetaPathsBabelPlugin, { filename: params.filename }],\n // [importMetaEnvBabelPlugin],\n // [transformMetadataBabelPlugin],\n // [syntaxClassPropertiesPlugin],\n // [transformExportNamespaceFromPlugin]\n // ]\n // } as BabelTransformOptions;\n\n // if (\n // findFileExtension(params.filename) === \"jsx\" ||\n // findFileExtension(params.filename) === \"tsx\"\n // ) {\n // babelOptions.plugins!.push([syntaxJSXPlugin]);\n // babelOptions.plugins!.push([\n // alloyPlugin,\n // {\n // alloyModuleName: \"@alloy-js/core\"\n // }\n // ]);\n // babelOptions.plugins!.push([\n // jsxDomExpressionsPlugin,\n // {\n // alloyModuleName: \"@alloy-js/core\",\n // moduleName: \"@alloy-js/core/jsx-runtime\",\n // generate: \"universal\",\n // wrapConditionals: true,\n // preserveWhitespace: true\n // }\n // ]);\n // }\n\n // if (\n // findFileExtension(params.filename) === \"ts\" ||\n // findFileExtension(params.filename) === \"tsx\"\n // ) {\n // babelOptions.plugins!.push([\n // typescriptPlugin,\n // {\n // allowDeclareFields: true,\n // isTSX: findFileExtension(params.filename) === \"tsx\"\n // }\n // ]);\n\n // babelOptions.plugins!.unshift([transformMetadataBabelPlugin]);\n // babelOptions.plugins!.unshift([\n // proposalDecoratorsPlugin,\n // { legacy: true }\n // ]);\n\n // babelOptions.plugins!.push([parameterDecoratorPlugin]);\n // babelOptions.plugins!.push([syntaxImportAssertionsPlugin]);\n // }\n\n // const result = transformSync(params.source, babelOptions);\n // if (!result?.code) {\n // return {\n // code: params.source,\n // error: new Error(\"Failed to transform source code.\")\n // };\n // }\n\n // return {\n // code: result.code\n // };\n // }\n } as CreateResolverOptions)\n );\n}\n\n/**\n * Create a Jiti resolver for the given workspace and project root.\n *\n * @param options - The options for creating the resolver.\n * @returns A Jiti instance configured for the specified workspace and project root.\n */\nexport function createResolver(options: CreateResolverOptions): Resolver {\n const baseResolver = createJiti(\n joinPaths(options.workspaceRoot, options.projectRoot),\n resolveOptions(options)\n ) as Resolver;\n baseResolver.plugin = createPluginResolver(options);\n\n return baseResolver;\n}\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { ArrayValues } from \"@stryke/types/array\";\nimport type { MaybePromise } from \"@stryke/types/base\";\nimport type { Context } from \"./context\";\n\nexport const SUPPORTED_COMMANDS = [\n \"new\",\n \"clean\",\n \"prepare\",\n \"lint\",\n \"test\",\n \"build\",\n \"docs\",\n \"deploy\",\n \"finalize\"\n] as const;\n\nexport type CommandType = ArrayValues<typeof SUPPORTED_COMMANDS>;\nexport type Commands<TContext extends Context = Context> = Record<\n CommandType,\n (this: TContext) => MaybePromise<void>\n>;\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isFunction } from \"@stryke/type-checks/is-function\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { isUndefined } from \"@stryke/type-checks/is-undefined\";\nimport { AnyFunction } from \"@stryke/types/base\";\nimport { SUPPORTED_COMMANDS } from \"../types/commands\";\nimport {\n PluginConfig,\n PluginConfigObject,\n PluginConfigTuple\n} from \"../types/config\";\nimport { PluginContext } from \"../types/context\";\nimport {\n BaseHookKeys,\n BaseHooksListItem,\n ExternalHookKeys,\n HookKeys\n} from \"../types/hooks\";\nimport { Plugin, PluginHook, PluginHookObject } from \"../types/plugin\";\nimport { ResolvedConfig } from \"../types/resolved\";\n\n/**\n * Type guard to check if an object is a {@link Plugin}\n *\n * @param value - The object to check\n * @returns True if the object is a {@link Plugin}, false otherwise\n */\nexport function isPlugin<\n TResolvedConfig extends ResolvedConfig = ResolvedConfig\n>(value: unknown): value is Plugin<PluginContext<TResolvedConfig>> {\n return (\n isSetObject(value) &&\n \"name\" in value &&\n isSetString(value.name) &&\n (isUndefined(\n (value as Plugin<PluginContext<TResolvedConfig>>).applyToEnvironment\n ) ||\n (\"applyToEnvironment\" in value &&\n isFunction(value.applyToEnvironment))) &&\n (isUndefined((value as Plugin<PluginContext<TResolvedConfig>>).dedupe) ||\n (\"dedupe\" in value && isFunction(value.dedupe))) &&\n (isUndefined((value as Plugin<PluginContext<TResolvedConfig>>).dependsOn) ||\n (\"dependsOn\" in value &&\n Array.isArray(value.dependsOn) &&\n value.dependsOn.every(isPluginConfig))) &&\n SUPPORTED_COMMANDS.every(\n command =>\n isUndefined(\n (value as Plugin<PluginContext<TResolvedConfig>>)[command]\n ) ||\n (command in value &&\n (isFunction((value as Record<string, any>)[command]) ||\n (isSetObject((value as Record<string, any>)[command]) &&\n \"handler\" in (value as Record<string, any>)[command] &&\n isFunction((value as Record<string, any>)[command].handler))))\n )\n );\n}\n\n/**\n * Type guard to check if an object is a {@link PluginConfigObject}\n *\n * @param value - The object to check\n * @returns True if the object is a {@link PluginConfigObject}, false otherwise\n */\nexport function isPluginConfigObject(\n value: unknown\n): value is PluginConfigObject {\n return (\n isSetObject(value) &&\n \"plugin\" in value &&\n (((isSetString(value.plugin) || isFunction(value.plugin)) &&\n \"options\" in value &&\n isSetObject(value.options)) ||\n isPlugin(value.plugin))\n );\n}\n\n/**\n * Type guard to check if an object is a {@link PluginConfigTuple}\n *\n * @param value - The object to check\n * @returns True if the object is a {@link PluginConfigTuple}, false otherwise\n */\nexport function isPluginConfigTuple(\n value: unknown\n): value is PluginConfigTuple {\n return (\n Array.isArray(value) &&\n (value.length === 1 || value.length === 2) &&\n (((isSetString(value[0]) || isFunction(value[0])) &&\n value.length > 1 &&\n isSetObject(value[1])) ||\n isPlugin(value[0]))\n );\n}\n\n/**\n * Type guard to check if an object is a {@link PluginConfig}\n *\n * @param value - The object to check\n * @returns True if the object is a {@link PluginConfig}, false otherwise\n */\nexport function isPluginConfig(value: unknown): value is PluginConfig {\n return (\n isSetString(value) ||\n isFunction(value) ||\n isPlugin(value) ||\n isPluginConfigObject(value) ||\n isPluginConfigTuple(value)\n );\n}\n\n/**\n * Type guard to check if an value is a {@link PluginHook} function\n *\n * @param value - The value to check\n * @returns True if the value is a {@link PluginHook} function, false otherwise\n */\nexport function isPluginHookFunction(value: unknown): value is AnyFunction {\n return (\n isFunction(value) ||\n (isSetObject(value) && \"handler\" in value && isFunction(value.handler))\n );\n}\n\n/**\n * Type guard to check if an value is a {@link PluginHook} function\n *\n * @param value - The value to check\n * @returns True if the value is a {@link PluginHook} function, false otherwise\n */\nexport function isPluginHookObject(\n value: unknown\n): value is PluginHookObject<AnyFunction> {\n return isSetObject(value) && \"handler\" in value && isFunction(value.handler);\n}\n\n/**\n * Type guard to check if an object is a {@link PluginHook}\n *\n * @param value - The object to check\n * @returns True if the object is a {@link PluginHook}, false otherwise\n */\nexport function isPluginHook(value: unknown): value is PluginHook<AnyFunction> {\n return isPluginHookFunction(value) || isPluginHookObject(value);\n}\n\n/**\n * Extract the hook handler function from a plugin hook\n *\n * @param pluginHook - The plugin hook to extract the handler function from\n * @returns The hook handler function\n */\nexport function getHookHandler(\n pluginHook: PluginHook<AnyFunction>\n): AnyFunction {\n return isFunction(pluginHook) ? pluginHook : pluginHook.handler;\n}\n\n/**\n * Extract a plugin hook from a plugin\n *\n * @param context - The build context\n * @param plugin - The plugin to extract the hook from\n * @param hook - The name of the hook to extract\n * @returns The extracted hook, or undefined if the hook does not exist\n */\nexport function extractPluginHook<\n TContext extends PluginContext = PluginContext,\n TPlugin extends Plugin<TContext> = Plugin<TContext>\n>(context: TContext, plugin: TPlugin, hook: BaseHookKeys<TContext>) {\n const pluginHook = plugin[hook];\n if (!isPluginHook(pluginHook)) {\n return undefined;\n }\n\n return isFunction(pluginHook)\n ? {\n normal: pluginHook.bind(context)\n }\n : {\n [pluginHook.order ? pluginHook.order : \"normal\"]:\n pluginHook.handler.bind(context)\n };\n}\n\n/**\n * Check if a hook is external.\n *\n * @param hook - The name of the hook to check.\n * @returns True if the hook is external, false otherwise.\n */\nexport function isHookExternal(hook: HookKeys): hook is ExternalHookKeys {\n return (\n hook.startsWith(\"vite:\") ||\n hook.startsWith(\"esbuild:\") ||\n hook.startsWith(\"rolldown:\") ||\n hook.startsWith(\"rollup:\") ||\n hook.startsWith(\"webpack:\") ||\n hook.startsWith(\"rspack:\") ||\n hook.startsWith(\"farm:\")\n );\n}\n\n/**\n * Check if a hook is internal.\n *\n * @param hook - The name of the hook to check.\n * @returns True if the hook is external, false otherwise.\n */\nexport function isHookInternal(hook: HookKeys): hook is BaseHookKeys {\n return !isHookExternal(hook);\n}\n\n/**\n * Check if a plugin should be deduplicated.\n *\n * @param plugin - The plugin to check\n * @param plugins - The list of plugins to check against\n * @returns True if the plugin should be deduplicated, false otherwise\n */\nexport function checkDedupe<\n TResolvedConfig extends ResolvedConfig = ResolvedConfig,\n TContext extends PluginContext<TResolvedConfig> =\n PluginContext<TResolvedConfig>\n>(plugin: Plugin<TContext>, plugins: Plugin<TContext>[]) {\n return (\n plugin.dedupe === false ||\n plugins.some(\n p =>\n p.dedupe !== false &&\n ((isFunction(p.dedupe) && p.dedupe(plugin)) || p.name === plugin.name)\n )\n );\n}\n\n/**\n * Add a plugin hook to the hooks list.\n *\n * @param context - The plugin context\n * @param plugin - The plugin to add the hook from\n * @param pluginHook - The plugin hook to add\n * @param hooksList - The list of hooks to add to\n */\nexport function addPluginHook<TContext extends PluginContext = PluginContext>(\n context: TContext,\n plugin: Plugin<TContext>,\n pluginHook: PluginHook<AnyFunction>,\n hooksList: BaseHooksListItem<TContext, BaseHookKeys<TContext>>[]\n) {\n if (\n !checkDedupe(\n plugin,\n hooksList.map(hook => hook.plugin)\n )\n ) {\n hooksList.push(\n isFunction(pluginHook)\n ? {\n plugin,\n handler: getHookHandler(pluginHook).bind(context)\n }\n : {\n plugin,\n ...pluginHook,\n handler: getHookHandler(pluginHook).bind(context)\n }\n );\n }\n}\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { LogLevelLabel } from \"@storm-software/config-tools/types\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { EnvPaths, getEnvPaths } from \"@stryke/env/get-env-paths\";\nimport { existsSync } from \"@stryke/fs/exists\";\nimport { relativeToWorkspaceRoot } from \"@stryke/fs/get-workspace-root\";\nimport { readJsonFile } from \"@stryke/fs/json\";\nimport { resolvePackage } from \"@stryke/fs/resolve\";\nimport { hashDirectory } from \"@stryke/hash/hash-files\";\nimport { murmurhash } from \"@stryke/hash/murmurhash\";\nimport { getUnique } from \"@stryke/helpers/get-unique\";\nimport { omit } from \"@stryke/helpers/omit\";\nimport { fetchRequest } from \"@stryke/http/fetch\";\nimport { StormJSON } from \"@stryke/json/storm-json\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { isAbsolute } from \"@stryke/path/is-type\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { replacePath } from \"@stryke/path/replace\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { isNull } from \"@stryke/type-checks/is-null\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport { PackageJson } from \"@stryke/types/package-json\";\nimport { uuid } from \"@stryke/unique-id/uuid\";\nimport { match, tsconfigPathsToRegExp } from \"bundle-require\";\nimport defu from \"defu\";\nimport { create, FlatCache } from \"flat-cache\";\nimport { parse, ParseResult } from \"oxc-parser\";\nimport { Range } from \"semver\";\nimport { Project } from \"ts-morph\";\nimport {\n Agent,\n BodyInit,\n interceptors,\n RequestInfo,\n Response,\n setGlobalDispatcher\n} from \"undici\";\nimport { ExternalIdResult, UnpluginMessage } from \"unplugin\";\nimport {\n createResolver,\n CreateResolverOptions\n} from \"../../internal/helpers/resolver\";\nimport { checkDedupe, isPlugin } from \"../../plugin-utils/helpers\";\nimport { replacePathTokens } from \"../../plugin-utils/paths\";\nimport {\n InitialUserConfig,\n LogFn,\n ParsedUserConfig,\n PluginConfig,\n PowerlinesCommand,\n WorkspaceConfig\n} from \"../../types/config\";\nimport {\n Context,\n FetchOptions,\n InitContextOptions,\n MetaInfo,\n ParseOptions,\n Resolver,\n TransformResult\n} from \"../../types/context\";\nimport {\n ResolveOptions,\n VirtualFile,\n VirtualFileSystemInterface,\n WriteOptions\n} from \"../../types/fs\";\nimport { UNSAFE_ContextInternal } from \"../../types/internal\";\nimport {\n ResolvedConfig,\n ResolvedEntryTypeDefinition\n} from \"../../types/resolved\";\nimport { ParsedTypeScriptConfig } from \"../../types/tsconfig\";\nimport { loadUserConfigFile, loadWorkspaceConfig } from \"../config-file\";\nimport { getUniqueEntries, resolveEntriesSync } from \"../entry\";\nimport { VirtualFileSystem } from \"../fs/vfs\";\nimport { createLog, extendLog } from \"../logger\";\nimport { createProgram } from \"../typescript/ts-morph\";\nimport { getTsconfigFilePath } from \"../typescript/tsconfig\";\nimport {\n CACHE_HASH_LENGTH,\n getPrefixedProjectRootHash,\n PROJECT_ROOT_HASH_LENGTH\n} from \"../utilities/meta\";\n\ninterface ConfigCacheKey {\n projectRoot: string;\n mode: \"test\" | \"development\" | \"production\";\n skipCache: boolean;\n configFile?: string;\n framework: string;\n command?: string;\n}\n\ninterface ConfigCacheResult {\n projectJson: Context[\"projectJson\"];\n packageJson: Context[\"packageJson\"];\n checksum: string;\n resolver: Resolver;\n userConfig: ParsedUserConfig;\n}\n\nconst configCache = new WeakMap<ConfigCacheKey, ConfigCacheResult>();\n\nconst agent = new Agent({ keepAliveTimeout: 10000 });\nsetGlobalDispatcher(\n agent.compose(\n interceptors.retry({\n maxRetries: 3,\n minTimeout: 1000,\n maxTimeout: 10000,\n timeoutFactor: 2,\n retryAfter: true\n })\n )\n);\n\nexport class PowerlinesContext<\n TResolvedConfig extends ResolvedConfig = ResolvedConfig\n> implements Context<TResolvedConfig> {\n /**\n * Internal references storage\n *\n * @danger\n * This field is for internal use only and should not be accessed or modified directly. It is unstable and can be changed at anytime.\n *\n * @internal\n */\n #internal = {} as UNSAFE_ContextInternal<TResolvedConfig>;\n\n #workspaceConfig: WorkspaceConfig;\n\n #checksum: string | null = null;\n\n #buildId: string = uuid();\n\n #releaseId: string = uuid();\n\n #timestamp: number = Date.now();\n\n #envPaths: EnvPaths;\n\n #fs!: VirtualFileSystemInterface;\n\n #tsconfig!: ParsedTypeScriptConfig;\n\n #program!: Project;\n\n #parserCache!: FlatCache;\n\n #requestCache!: FlatCache;\n\n #getConfigProps(config: Partial<TResolvedConfig[\"userConfig\"]> = {}) {\n return {\n variant: config.build?.variant,\n projectType: config.type,\n projectRoot: config.root,\n name: config.name,\n title: config.title,\n description: config.description,\n sourceRoot: config.sourceRoot,\n configFile: config.configFile,\n customLogger: config.customLogger,\n logLevel: config.logLevel,\n tsconfig: config.tsconfig,\n tsconfigRaw: config.tsconfigRaw,\n skipCache: config.skipCache,\n skipInstalls: config.skipInstalls,\n entry: config.entry,\n output: config.output,\n plugins: config.plugins,\n mode: config.mode,\n lint: config.lint,\n transform: config.transform,\n build: config.build,\n framework: config.framework,\n ...config\n };\n }\n\n /**\n * Create a new Storm context from the workspace root and user config.\n *\n * @param workspaceRoot - The root directory of the workspace.\n * @param config - The user configuration options.\n * @returns A promise that resolves to the new context.\n */\n public static async from<\n TResolvedConfig extends ResolvedConfig = ResolvedConfig\n >(\n workspaceRoot: string,\n config: InitialUserConfig<TResolvedConfig[\"userConfig\"]>\n ): Promise<Context> {\n const context = new PowerlinesContext<TResolvedConfig>(\n await loadWorkspaceConfig(workspaceRoot, config.root)\n );\n await context.withUserConfig(config);\n\n const powerlinesPath = await resolvePackage(\"powerlines\");\n if (!powerlinesPath) {\n throw new Error(\"Could not resolve `powerlines` package location.\");\n }\n\n context.powerlinesPath = powerlinesPath;\n\n return context;\n }\n\n /**\n * An object containing the dependencies that should be installed for the project\n */\n public dependencies: Record<string, string | Range> = {};\n\n /**\n * An object containing the development dependencies that should be installed for the project\n */\n public devDependencies: Record<string, string | Range> = {};\n\n /**\n * The persisted meta information about the current build\n */\n public persistedMeta: MetaInfo | undefined = undefined;\n\n /**\n * The path to the Powerlines package\n */\n public powerlinesPath!: string;\n\n /**\n * The parsed `package.json` file for the project\n */\n public packageJson!: PackageJson;\n\n /**\n * The parsed `project.json` file for the project\n */\n public projectJson: Record<string, any> | undefined = undefined;\n\n /**\n * The module resolver for the project\n */\n public resolver!: Resolver;\n\n /**\n * The resolved configuration options\n */\n private resolvePatterns: RegExp[] = [];\n\n /**\n * Internal context fields and methods\n *\n * @danger\n * This field is for internal use only and should not be accessed or modified directly. It is unstable and can be changed at anytime.\n *\n * @internal\n */\n public get $$internal(): UNSAFE_ContextInternal<TResolvedConfig> {\n return this.#internal;\n }\n\n /**\n * Internal context fields and methods\n *\n * @danger\n * This field is for internal use only and should not be accessed or modified directly. It is unstable and can be changed at anytime.\n *\n * @internal\n */\n public set $$internal(value: UNSAFE_ContextInternal<TResolvedConfig>) {\n this.#internal = value;\n }\n\n /**\n * The resolved entry type definitions for the project\n */\n public get entry(): ResolvedEntryTypeDefinition[] {\n return resolveEntriesSync(this, toArray(this.config.entry));\n }\n\n /**\n * The TypeScript configuration parsed from the tsconfig file\n */\n public get tsconfig(): ParsedTypeScriptConfig {\n if (!this.#tsconfig) {\n this.tsconfig = {\n tsconfigFilePath: this.config.tsconfig\n } as ParsedTypeScriptConfig;\n }\n\n return this.#tsconfig;\n }\n\n /**\n * Sets the TypeScript configuration parsed from the tsconfig file\n */\n public set tsconfig(value: ParsedTypeScriptConfig) {\n this.#tsconfig = value;\n this.resolvePatterns = tsconfigPathsToRegExp(value?.options?.paths ?? {});\n }\n\n /**\n * The virtual file system interface for the project\n */\n public get fs(): VirtualFileSystemInterface {\n if (!this.#fs) {\n this.#fs = VirtualFileSystem.createSync(this);\n }\n\n return this.#fs;\n }\n\n /**\n * Get the checksum of the project's current state\n */\n public get checksum(): string | null {\n return this.#checksum;\n }\n\n /**\n * The meta information about the current build\n */\n public get meta() {\n return {\n buildId: this.#buildId,\n releaseId: this.#releaseId,\n checksum: this.#checksum,\n timestamp: this.#timestamp,\n projectRootHash: murmurhash(\n {\n workspaceRoot: this.workspaceConfig?.workspaceRoot,\n projectRoot: this.config?.projectRoot\n },\n {\n maxLength: PROJECT_ROOT_HASH_LENGTH\n }\n ),\n configHash: murmurhash(this.config, {\n maxLength: CACHE_HASH_LENGTH\n })\n } as MetaInfo;\n }\n\n /**\n * The resolved configuration options\n */\n public get config(): TResolvedConfig {\n return this.resolvedConfig ?? {};\n }\n\n /**\n * The logger function\n */\n public get log(): LogFn {\n if (!this.logFn) {\n this.logFn = this.createLog();\n }\n\n return this.logFn;\n }\n\n /**\n * The workspace configuration\n */\n public get workspaceConfig(): WorkspaceConfig {\n return this.#workspaceConfig;\n }\n\n /**\n * The environment paths for the project\n */\n public get envPaths(): EnvPaths {\n if (!this.#envPaths) {\n this.#envPaths = getEnvPaths({\n orgId: \"storm-software\",\n appId: \"powerlines\",\n workspaceRoot: this.workspaceConfig.workspaceRoot\n });\n }\n\n return this.#envPaths;\n }\n\n /**\n * Get the path to the artifacts directory for the project\n */\n public get artifactsPath(): string {\n return joinPaths(\n this.workspaceConfig.workspaceRoot,\n this.config.projectRoot,\n this.config.output.artifactsPath\n );\n }\n\n /**\n * Get the path to the builtin modules used by the project\n */\n public get builtinsPath(): string {\n return joinPaths(this.artifactsPath, \"builtins\");\n }\n\n /**\n * Get the path to the entry directory for the project\n */\n public get entryPath(): string {\n return joinPaths(this.artifactsPath, \"entry\");\n }\n\n /**\n * Get the path to the data directory for the project\n */\n public get dataPath(): string {\n return joinPaths(\n this.envPaths.data,\n \"projects\",\n getPrefixedProjectRootHash(this.config.name, this.meta.projectRootHash)\n );\n }\n\n /**\n * Get the path to the cache directory for the project\n */\n public get cachePath(): string {\n return joinPaths(\n this.envPaths.cache,\n \"projects\",\n murmurhash(\n {\n checksum: this.#checksum,\n config: this.meta.configHash\n },\n {\n maxLength: CACHE_HASH_LENGTH\n }\n )\n );\n }\n\n /**\n * Get the path to the generated declaration file for the project\n */\n public get dtsPath(): string {\n return this.config.output.dts\n ? appendPath(this.config.output.dts, this.workspaceConfig.workspaceRoot)\n : joinPaths(\n this.workspaceConfig.workspaceRoot,\n this.config.projectRoot,\n \"powerlines.d.ts\"\n );\n }\n\n /**\n * Get the project root relative to the workspace root\n */\n public get relativeToWorkspaceRoot() {\n return relativeToWorkspaceRoot(this.config.projectRoot);\n }\n\n /**\n * The builtin module id that exist in the Powerlines virtual file system\n */\n public get builtins(): string[] {\n return Object.values(this.fs.metadata)\n .filter(meta => meta && meta.type === \"builtin\")\n .map(meta => meta?.id)\n .filter(Boolean);\n }\n\n /**\n * The {@link Project} instance used for type reflection and module manipulation\n *\n * @see https://ts-morph.com/\n *\n * @remarks\n * This instance is created lazily on first access.\n */\n public get program(): Project {\n if (!this.#program) {\n this.#program = createProgram(this, {\n skipAddingFilesFromTsConfig: true\n });\n }\n\n return this.#program;\n }\n\n /**\n * Gets the parser cache.\n */\n protected get parserCache(): FlatCache {\n if (!this.#parserCache) {\n this.#parserCache = create({\n cacheId: \"parser\",\n cacheDir: this.cachePath,\n ttl: 2 * 60 * 60 * 1000,\n lruSize: 5000,\n persistInterval: 250\n });\n }\n\n return this.#parserCache;\n }\n\n /**\n * Gets the request cache.\n */\n protected get requestCache(): FlatCache {\n if (!this.#requestCache) {\n this.#requestCache = create({\n cacheId: \"http\",\n cacheDir: this.cachePath,\n ttl: 5 * 60 * 1000,\n lruSize: 5000,\n persistInterval: 250\n });\n }\n\n return this.#requestCache;\n }\n\n /**\n * A function to perform HTTP fetch requests\n *\n * @remarks\n * This function uses a caching layer to avoid duplicate requests during the Powerlines process.\n *\n * @example\n * ```ts\n * const response = await context.fetch(\"https://api.example.com/data\");\n * const data = await response.json();\n * ```\n *\n * @see https://github.com/nodejs/undici\n *\n * @param input - The URL to fetch.\n * @param options - The fetch request options.\n * @returns A promise that resolves to a response returned by the fetch.\n */\n public async fetch(\n input: RequestInfo,\n options: FetchOptions = {}\n ): Promise<Response> {\n const cacheKey = murmurhash({\n input: input.toString(),\n options: JSON.stringify(options)\n });\n\n if (!this.config.skipCache && !options.skipCache) {\n const cached = this.requestCache.get<{ body: BodyInit } & ResponseInit>(\n cacheKey\n );\n if (cached) {\n return new Response(cached.body, {\n status: cached.status,\n statusText: cached.statusText,\n headers: cached.headers\n });\n }\n }\n\n const response = await fetchRequest(input, { timeout: 12_000, ...options });\n const result = {\n body: await response.text(),\n status: response.status,\n statusText: response.statusText,\n headers: Object.fromEntries(response.headers.entries())\n };\n\n if (!this.config.skipCache && !options.skipCache) {\n try {\n this.requestCache.set(cacheKey, result);\n } catch {\n // Do nothing\n }\n }\n\n return new Response(result.body, {\n status: result.status,\n statusText: result.statusText,\n headers: result.headers\n });\n }\n\n /**\n * Parse code using [Oxc-Parser](https://github.com/oxc/oxc) into an (ESTree-compatible)[https://github.com/estree/estree] AST object.\n *\n * @remarks\n * This function can be used to parse TypeScript code into an AST for further analysis or transformation.\n *\n * @example\n * ```ts\n * const ast = context.parse(\"const x: number = 42;\");\n * ```\n *\n * @see https://rollupjs.org/plugin-development/#this-parse\n * @see https://github.com/oxc/oxc\n *\n * @param code - The source code to parse.\n * @param options - The options to pass to the parser.\n * @returns An (ESTree-compatible)[https://github.com/estree/estree] AST object.\n */\n public async parse(code: string, options: ParseOptions = {}) {\n const cacheKey = murmurhash({\n code,\n options\n });\n\n let result!: ParseResult;\n if (!this.config.skipCache) {\n result = this.parserCache.get<ParseResult>(cacheKey);\n if (result) {\n return result;\n }\n }\n\n result = await parse(`source.${options.lang || \"ts\"}`, code, {\n ...options,\n sourceType: \"module\",\n showSemanticErrors: this.config.mode === \"development\"\n });\n\n if (!this.config.skipCache) {\n this.parserCache.set(cacheKey, result);\n }\n\n return result;\n }\n\n /**\n * A helper function to resolve modules in the Virtual File System\n *\n * @remarks\n * This function can be used to resolve modules relative to the project root directory.\n *\n * @example\n * ```ts\n * const resolved = await context.resolve(\"some-module\", \"/path/to/importer\");\n * ```\n *\n * @param id - The module to resolve.\n * @param importer - An optional path to the importer module.\n * @param options - Additional resolution options.\n * @returns A promise that resolves to the resolved module path.\n */\n public async resolve(\n id: string,\n importer?: string,\n options: ResolveOptions = {}\n ): Promise<ExternalIdResult | undefined> {\n let moduleId = id;\n if (this.config.build.alias) {\n if (Array.isArray(this.config.build.alias)) {\n const alias = this.config.build.alias.find(a =>\n match(moduleId, [a.find])\n );\n if (alias) {\n moduleId = alias.replacement;\n }\n } else if (\n isSetObject(this.config.build.alias) &&\n this.config.build.alias[id]\n ) {\n moduleId = this.config.build.alias[id];\n }\n }\n\n if (this.fs.isVirtual(moduleId)) {\n const result = await this.fs.resolve(moduleId, importer, {\n conditions: this.config.build.conditions,\n extensions: this.config.build.extensions,\n ...options\n });\n if (!result) {\n return undefined;\n }\n\n return {\n id: `\\0${result}`,\n external: this.config.projectType !== \"application\"\n };\n }\n\n if (this.config.build.skipNodeModulesBundle) {\n if (\n match(moduleId, this.resolvePatterns) ||\n match(moduleId, this.config.build.noExternal)\n ) {\n return undefined;\n }\n\n if (\n match(moduleId, this.config.build.external) ||\n moduleId.startsWith(\"node:\")\n ) {\n return { id: moduleId, external: true };\n }\n\n // Exclude any other import that looks like a Node module\n if (!/^[A-Z]:[/\\\\]|^\\.{0,2}\\/|^\\.{1,2}$/.test(moduleId)) {\n return {\n id: moduleId,\n external: true\n };\n }\n } else {\n if (match(moduleId, this.config.build.noExternal)) {\n return undefined;\n }\n\n if (\n match(moduleId, this.config.build.external) ||\n moduleId.startsWith(\"node:\")\n ) {\n return { id: moduleId, external: true };\n }\n }\n\n return undefined;\n }\n\n /**\n * A helper function to load modules from the Virtual File System\n *\n * @remarks\n * This function can be used to load modules relative to the project root directory.\n *\n * @example\n * ```ts\n * const module = await context.load(\"some-module\", \"/path/to/importer\");\n * ```\n *\n * @param id - The module to load.\n * @returns A promise that resolves to the loaded module.\n */\n public async load(id: string): Promise<TransformResult | undefined> {\n const resolvedId = await this.fs.resolve(id);\n if (!resolvedId) {\n return undefined;\n }\n\n const code = await this.fs.read(resolvedId);\n if (!code) {\n return undefined;\n }\n\n return { code, map: null };\n }\n\n /**\n * Get the builtin virtual files that exist in the Powerlines virtual file system\n */\n public async getBuiltins() {\n return Promise.all(\n Object.entries(this.fs.metadata)\n .filter(([, meta]) => meta && meta.type === \"builtin\")\n .map(async ([path, meta]) => {\n const code = await this.fs.read(path);\n\n return { ...meta, path, code } as VirtualFile;\n })\n );\n }\n\n /**\n * Resolves a entry virtual file and writes it to the VFS if it does not already exist\n *\n * @param code - The source code of the entry file\n * @param path - A path to write the entry file to\n * @param options - Optional write file options\n */\n public async emitEntry(\n code: string,\n path: string,\n options: WriteOptions = {}\n ): Promise<void> {\n return this.fs.write(\n isAbsolute(path) ? path : appendPath(path, this.entryPath),\n code,\n defu(options, { type: \"entry\" })\n );\n }\n\n /**\n * Resolves a builtin virtual file and writes it to the VFS if it does not already exist\n *\n * @param code - The source code of the builtin file\n * @param id - The unique identifier of the builtin file\n * @param path - An optional path to write the builtin file to\n * @param options - Optional write file options\n */\n public async emitBuiltin(\n code: string,\n id: string,\n path?: string,\n options: WriteOptions = {}\n ): Promise<void> {\n return this.fs.write(\n path\n ? isAbsolute(path)\n ? path\n : joinPaths(this.builtinsPath, path)\n : appendPath(id, this.builtinsPath),\n code,\n defu(options, { type: \"builtin\" })\n );\n }\n\n /**\n * Update the context using a new user configuration options\n *\n * @param userConfig - The new user configuration options.\n */\n public async withUserConfig(\n userConfig: InitialUserConfig<TResolvedConfig[\"userConfig\"]>,\n options: InitContextOptions = {\n isHighPriority: true\n }\n ) {\n this.mergeUserConfig(userConfig as Partial<TResolvedConfig[\"userConfig\"]>);\n\n await this.init(this.config.userConfig, options);\n }\n\n /**\n * Update the context using a new inline configuration options\n *\n * @param inlineConfig - The new inline configuration options.\n */\n public async withInlineConfig(\n inlineConfig: TResolvedConfig[\"inlineConfig\"],\n options: InitContextOptions = {\n isHighPriority: true\n }\n ) {\n this.config.inlineConfig = inlineConfig;\n\n if (inlineConfig.command === \"new\") {\n const workspacePackageJsonPath = joinPaths(\n this.workspaceConfig.workspaceRoot,\n \"package.json\"\n );\n if (!existsSync(workspacePackageJsonPath)) {\n throw new Error(\n `The workspace package.json file could not be found at ${workspacePackageJsonPath}`\n );\n }\n\n this.packageJson = await readJsonFile<PackageJson>(\n workspacePackageJsonPath\n );\n\n this.workspaceConfig.repository ??= isSetString(\n this.packageJson?.repository\n )\n ? this.packageJson.repository\n : this.packageJson?.repository?.url;\n }\n\n await this.init(this.config.inlineConfig, options);\n }\n\n /**\n * A logging function for fatal messages\n *\n * @param message - The message to log.\n */\n public fatal(message: string | UnpluginMessage) {\n this.log(\n LogLevelLabel.FATAL,\n isString(message) ? message : StormJSON.stringify(message)\n );\n }\n\n /**\n * A logging function for error messages\n *\n * @param message - The message to log.\n */\n public error(message: string | UnpluginMessage) {\n this.log(\n LogLevelLabel.ERROR,\n isString(message) ? message : StormJSON.stringify(message)\n );\n }\n\n /**\n * A logging function for warning messages\n *\n * @param message - The message to log.\n */\n public warn(message: string | UnpluginMessage) {\n this.log(\n LogLevelLabel.WARN,\n isString(message) ? message : StormJSON.stringify(message)\n );\n }\n\n /**\n * A logging function for informational messages\n *\n * @param message - The message to log.\n */\n public info(message: string | UnpluginMessage) {\n this.log(\n LogLevelLabel.INFO,\n isString(message) ? message : StormJSON.stringify(message)\n );\n }\n\n /**\n * A logging function for debug messages\n *\n * @param message - The message to log.\n */\n public debug(message: string | UnpluginMessage) {\n this.log(\n LogLevelLabel.DEBUG,\n isString(message) ? message : StormJSON.stringify(message)\n );\n }\n\n /**\n * A logging function for trace messages\n *\n * @param message - The message to log.\n */\n public trace(message: string | UnpluginMessage) {\n this.log(\n LogLevelLabel.TRACE,\n isString(message) ? message : StormJSON.stringify(message)\n );\n }\n\n /**\n * Create a new logger instance\n *\n * @param name - The name to use for the logger instance\n * @returns A logger function\n */\n public createLog(name: string | null = null): LogFn {\n return createLog(name, {\n ...this.config,\n logLevel: isNull(this.config.logLevel) ? \"silent\" : this.config.logLevel\n });\n }\n\n /**\n * Extend the current logger instance with a new name\n *\n * @param name - The name to use for the extended logger instance\n * @returns A logger function\n */\n public extendLog(name: string): LogFn {\n return extendLog(this.log, name);\n }\n\n /**\n * Generates a checksum representing the current context state\n *\n * @param root - The root directory of the project to generate the checksum for\n * @returns A promise that resolves to a string representing the checksum\n */\n public async generateChecksum(\n root = this.config.projectRoot\n ): Promise<string> {\n this.#checksum = await hashDirectory(root, {\n ignore: [\"node_modules\", \".git\", \".nx\", \".cache\", \".storm\", \"tmp\", \"dist\"]\n });\n\n return this.#checksum;\n }\n\n /**\n * Creates a new StormContext instance.\n *\n * @param workspaceConfig - The workspace configuration.\n */\n protected constructor(workspaceConfig: WorkspaceConfig) {\n this.#workspaceConfig = workspaceConfig;\n this.#envPaths = getEnvPaths({\n orgId: \"storm-software\",\n appId: \"powerlines\",\n workspaceRoot: workspaceConfig.workspaceRoot\n });\n }\n\n /**\n * The resolved configuration for this context\n */\n protected resolvedConfig: TResolvedConfig = {} as TResolvedConfig;\n\n /**\n * A logger function specific to this context\n */\n protected logFn!: LogFn;\n\n /**\n * Initialize the context with the provided configuration options\n *\n * @param config - The partial user configuration to use for initialization.\n */\n protected async init(\n config: Partial<TResolvedConfig[\"userConfig\"]> = {},\n options: InitContextOptions = {\n isHighPriority: true\n }\n ) {\n const cacheKey: ConfigCacheKey = {\n projectRoot:\n config.root ??\n this.config.projectRoot ??\n this.config.userConfig?.root ??\n this.config.inlineConfig?.root,\n mode: (config.mode ?? this.config.mode) || this.workspaceConfig.mode,\n skipCache: config.skipCache ?? this.config.skipCache ?? false,\n configFile: config.configFile ?? this.config.configFile,\n framework: config.framework ?? this.config.framework ?? \"powerlines\",\n command: this.config.inlineConfig?.command\n };\n\n if (configCache.has(cacheKey)) {\n const result = configCache.get(cacheKey)!;\n\n this.projectJson = result.projectJson;\n this.packageJson = result.packageJson;\n this.#checksum = result.checksum;\n this.resolver = result.resolver;\n\n this.mergeUserConfig(result.userConfig.config, this.config.userConfig);\n } else {\n const projectJsonPath = joinPaths(cacheKey.projectRoot, \"project.json\");\n if (existsSync(projectJsonPath)) {\n this.projectJson = await readJsonFile(projectJsonPath);\n }\n\n const packageJsonPath = joinPaths(cacheKey.projectRoot, \"package.json\");\n if (existsSync(packageJsonPath)) {\n this.packageJson = await readJsonFile<PackageJson>(packageJsonPath);\n }\n\n this.#checksum = await this.generateChecksum(cacheKey.projectRoot);\n this.resolver = createResolver({\n workspaceRoot: this.workspaceConfig.workspaceRoot,\n projectRoot: cacheKey.projectRoot,\n cacheDir: this.cachePath,\n mode: cacheKey.mode,\n logLevel: (config.logLevel ||\n this.config?.logLevel ||\n this.workspaceConfig.logLevel ||\n \"info\") as CreateResolverOptions[\"logLevel\"],\n skipCache: cacheKey.skipCache\n });\n\n const userConfig = await loadUserConfigFile(\n cacheKey.projectRoot,\n this.workspaceConfig.workspaceRoot,\n this.resolver,\n cacheKey.command as PowerlinesCommand | undefined,\n cacheKey.mode,\n cacheKey.configFile,\n cacheKey.framework\n );\n this.mergeUserConfig(userConfig.config);\n\n configCache.set(cacheKey, {\n projectJson: this.projectJson,\n packageJson: this.packageJson,\n checksum: this.#checksum,\n resolver: this.resolver,\n userConfig\n });\n }\n\n config.tsconfig ??= getTsconfigFilePath(\n this.workspaceConfig.workspaceRoot,\n cacheKey.projectRoot,\n config.tsconfig\n );\n\n if (isSetObject(config)) {\n this.resolvedConfig = defu(\n {\n inlineConfig: this.config.inlineConfig,\n userConfig: this.config.userConfig\n },\n options.isHighPriority ? this.#getConfigProps(config) : {},\n {\n command: this.config.inlineConfig?.command,\n ...this.#getConfigProps(this.config.inlineConfig)\n },\n this.#getConfigProps(this.config.userConfig),\n {\n mode: this.workspaceConfig?.mode,\n logLevel: this.workspaceConfig?.logLevel,\n skipCache: this.workspaceConfig?.skipCache\n },\n {\n name: this.projectJson?.name || this.packageJson?.name,\n version: this.packageJson?.version,\n description: this.packageJson?.description,\n sourceRoot:\n this.projectJson?.sourceRoot ||\n appendPath(\"src\", cacheKey.projectRoot),\n output: defu(config.output ?? {}, {\n outputPath: cacheKey.projectRoot\n ? joinPaths(\n this.workspaceConfig?.directories?.build || \"dist\",\n cacheKey.projectRoot\n )\n : this.workspaceConfig?.directories?.build || \"dist\",\n artifactsPath: joinPaths(\n cacheKey.projectRoot,\n `.${config.framework ?? \"powerlines\"}`\n ),\n dts: joinPaths(\n cacheKey.projectRoot,\n `${config.framework ?? \"powerlines\"}.d.ts`\n ),\n builtinPrefix: config.framework ?? \"powerlines\",\n assets: [\n {\n glob: \"LICENSE\"\n },\n {\n input: cacheKey.projectRoot,\n glob: \"*.md\"\n },\n {\n input: cacheKey.projectRoot,\n glob: \"package.json\"\n }\n ]\n })\n },\n options.isHighPriority ? {} : this.#getConfigProps(config),\n {\n inlineConfig: {},\n userConfig: {},\n framework: \"powerlines\",\n platform: \"neutral\",\n mode: \"production\",\n projectType: \"application\",\n logLevel: \"info\",\n preview: false,\n environments: {},\n transform: {\n babel: {\n plugins: [],\n presets: []\n }\n },\n lint: {\n eslint: {}\n },\n build: {\n target: \"esnext\",\n override: {}\n }\n }\n ) as any;\n }\n\n this.config.entry = getUniqueEntries(this.config.entry);\n\n if (\n this.config.name?.startsWith(\"@\") &&\n this.config.name.split(\"/\").filter(Boolean).length > 1\n ) {\n this.config.name = this.config.name.split(\"/\").filter(Boolean)[1]!;\n }\n\n this.config.title ??= titleCase(this.config.name);\n\n if (this.config.userConfig.build?.external) {\n this.config.userConfig.build.external = getUnique(\n this.config.userConfig.build.external\n );\n }\n if (this.config.userConfig.build?.noExternal) {\n this.config.userConfig.build.noExternal = getUnique(\n this.config.userConfig.build.noExternal\n );\n }\n\n if (this.config.build.external) {\n this.config.build.external = getUnique(this.config.build.external);\n }\n if (this.config.build.noExternal) {\n this.config.build.noExternal = getUnique(this.config.build.noExternal);\n }\n\n this.config.output.format = getUnique(\n toArray(\n this.config.output?.format ??\n (this.config.projectType === \"library\" ? [\"cjs\", \"esm\"] : [\"esm\"])\n )\n );\n\n if (\n this.config.projectRoot &&\n this.config.projectRoot !== \".\" &&\n this.config.projectRoot !== \"./\" &&\n this.config.projectRoot !== this.workspaceConfig.workspaceRoot\n ) {\n this.config.output.outputPath ??= joinPaths(\n \"dist\",\n this.config.projectRoot\n );\n this.config.output.buildPath ??= joinPaths(\n this.config.projectRoot,\n \"dist\"\n );\n } else {\n this.config.output.outputPath ??= \"dist\";\n this.config.output.buildPath ??= \"dist\";\n }\n\n this.config.output.assets = getUnique(\n this.config.output.assets.map(asset => {\n return {\n glob: isSetObject(asset) ? asset.glob : asset,\n input:\n isString(asset) ||\n !asset.input ||\n asset.input === \".\" ||\n asset.input === \"/\" ||\n asset.input === \"./\"\n ? this.workspaceConfig.workspaceRoot\n : appendPath(asset.input, this.workspaceConfig.workspaceRoot),\n output: appendPath(\n isSetObject(asset) && asset.output\n ? joinPaths(\n this.config.output.outputPath,\n replacePath(asset.output, this.config.output.outputPath)\n )\n : this.config.output.outputPath,\n this.workspaceConfig.workspaceRoot\n ),\n ignore:\n isSetObject(asset) && asset.ignore\n ? toArray(asset.ignore)\n : undefined\n };\n })\n );\n\n this.config.plugins = (this.config.plugins ?? [])\n .filter(Boolean)\n .reduce((ret, plugin) => {\n if (\n isPlugin(plugin) &&\n checkDedupe(\n plugin,\n ret.filter(p => isPlugin(p))\n )\n ) {\n return ret;\n }\n\n ret.push(plugin);\n\n return ret;\n }, [] as PluginConfig[]);\n\n // Apply path token replacements\n\n if (this.config.tsconfig) {\n this.config.tsconfig = replacePathTokens(this, this.config.tsconfig);\n }\n\n if (this.config.output.dts) {\n this.config.output.dts = replacePathTokens(this, this.config.output.dts);\n }\n\n if (this.config.build.polyfill) {\n this.config.build.polyfill = this.config.build.polyfill.map(polyfill =>\n replacePathTokens(this, polyfill)\n );\n }\n\n if (this.config.output.assets) {\n this.config.output.assets = this.config.output.assets.map(asset => ({\n ...asset,\n glob: replacePathTokens(this, asset.glob),\n ignore: asset.ignore\n ? asset.ignore.map(ignore => replacePathTokens(this, ignore))\n : undefined,\n input: replacePathTokens(this, asset.input),\n output: replacePathTokens(this, asset.output)\n }));\n }\n\n this.#fs ??= await VirtualFileSystem.create(this);\n }\n\n protected mergeUserConfig(\n from: Partial<TResolvedConfig[\"userConfig\"]> = {},\n into: Partial<TResolvedConfig[\"userConfig\"]> = this.config.userConfig ?? {}\n ) {\n this.config.userConfig = defu(\n {\n entry:\n Array.isArray(from.entry) && from.entry.length > 0\n ? from.entry\n : Array.isArray(into?.entry) && into.entry.length > 0\n ? into.entry\n : []\n },\n omit(from ?? {}, [\"entry\"]),\n omit(into ?? {}, [\"entry\"])\n ) as TResolvedConfig[\"userConfig\"];\n\n if (this.config.userConfig.output?.format) {\n this.config.userConfig.output.format = getUnique(\n toArray(this.config.userConfig.output?.format)\n );\n }\n\n this.config.userConfig.plugins = (this.config.userConfig.plugins ?? [])\n .filter(Boolean)\n .reduce((ret, plugin) => {\n if (\n isPlugin(plugin) &&\n checkDedupe(\n plugin,\n ret.filter(p => isPlugin(p))\n )\n ) {\n return ret;\n }\n\n ret.push(plugin);\n\n return ret;\n }, [] as PluginConfig[]);\n }\n}\n"]}
|