powerlines 0.36.7 → 0.36.9
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-BFFEVa-a.d.cts → api-BWgo9nPi.d.cts} +1 -1
- package/dist/{api-CNRRz6AD.d.ts → api-DvNkzaVu.d.ts} +1 -1
- package/dist/api.cjs +4 -3
- package/dist/api.d.cts +2 -2
- package/dist/api.d.ts +2 -2
- package/dist/api.js +3 -2
- package/dist/astro.cjs +6 -5
- package/dist/astro.d.cts +1 -1
- package/dist/astro.d.ts +1 -1
- package/dist/astro.js +5 -4
- package/dist/{chunk-AIODZINF.js → chunk-3MGUJSWR.js} +3 -3
- package/dist/{chunk-A23X2AGC.cjs → chunk-4R3HEBO5.cjs} +4 -4
- package/dist/chunk-AJPO5EP7.js +32 -0
- package/dist/{chunk-DEG5XSW5.js → chunk-CALTNXXH.js} +58 -20
- package/dist/chunk-HBY4WRXL.cjs +12 -0
- package/dist/{chunk-4Q5WMB5Y.cjs → chunk-HI6PZNZQ.cjs} +59 -21
- package/dist/{chunk-KI5WQSIV.js → chunk-HIPGXSUK.js} +3 -3
- package/dist/{chunk-JYQ4PD2Q.js → chunk-OCI63N4G.js} +3 -3
- package/dist/chunk-PKMYBUJQ.cjs +12 -0
- package/dist/{chunk-PSD735JF.js → chunk-SSI65F2I.js} +3 -3
- package/dist/chunk-U2RJRKLT.js +15 -0
- package/dist/{chunk-V7KCSS2Q.js → chunk-W44XLC76.js} +3 -3
- package/dist/chunk-XOMY3USD.cjs +17 -0
- package/dist/{chunk-QXSWQQYM.cjs → chunk-YP42N5D7.cjs} +4 -4
- package/dist/chunk-ZCMOAOQN.cjs +36 -0
- package/dist/{chunk-7KT5WZN4.cjs → chunk-ZCQYNPDB.cjs} +5 -5
- package/dist/{context-CEJVLdeO.d.cts → context-CbAqO09i.d.cts} +8 -2
- package/dist/{context-eZSF6e_s.d.ts → context-DC6tBOBW.d.ts} +8 -2
- package/dist/esbuild.cjs +8 -7
- package/dist/esbuild.d.cts +1 -1
- package/dist/esbuild.d.ts +1 -1
- package/dist/esbuild.js +5 -4
- package/dist/farm.cjs +5 -4
- package/dist/farm.d.cts +1 -1
- package/dist/farm.d.ts +1 -1
- package/dist/farm.js +4 -3
- package/dist/index.cjs +25 -13
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +4 -4
- package/dist/lib/{api-CDJdFTPm.d.ts → api-BF0XHYsK.d.ts} +1 -1
- package/dist/lib/{api-5JEMIrCI.d.cts → api-Oduv5r36.d.cts} +1 -1
- package/dist/lib/build/esbuild.d.cts +1 -1
- package/dist/lib/build/esbuild.d.ts +1 -1
- package/dist/lib/build/index.d.cts +3 -3
- package/dist/lib/build/index.d.ts +3 -3
- package/dist/lib/build/rolldown.d.cts +1 -1
- package/dist/lib/build/rolldown.d.ts +1 -1
- package/dist/lib/build/rollup.d.cts +1 -1
- package/dist/lib/build/rollup.d.ts +1 -1
- package/dist/lib/build/rspack.d.cts +1 -1
- package/dist/lib/build/rspack.d.ts +1 -1
- package/dist/lib/build/tsdown.d.cts +1 -1
- package/dist/lib/build/tsdown.d.ts +1 -1
- package/dist/lib/build/tsup.d.cts +1 -1
- package/dist/lib/build/tsup.d.ts +1 -1
- package/dist/lib/build/unbuild.d.cts +3 -3
- package/dist/lib/build/unbuild.d.ts +3 -3
- package/dist/lib/build/vite.d.cts +1 -1
- package/dist/lib/build/vite.d.ts +1 -1
- package/dist/lib/build/webpack.d.cts +1 -1
- package/dist/lib/build/webpack.d.ts +1 -1
- package/dist/lib/{chunk-LO5DWCMR.cjs → chunk-3RTUKWWL.cjs} +37 -20
- package/dist/lib/chunk-3RTUKWWL.cjs.map +1 -0
- package/dist/lib/{chunk-SADRLVE7.cjs → chunk-6VKHSJ2P.cjs} +73 -14
- package/dist/lib/chunk-6VKHSJ2P.cjs.map +1 -0
- package/dist/lib/{chunk-2YAAI6BY.js → chunk-DIM5X2B7.js} +3 -13
- package/dist/lib/chunk-DIM5X2B7.js.map +1 -0
- package/dist/lib/{chunk-35EO5Y7R.js → chunk-F5GKG7AF.js} +7 -4
- package/dist/lib/chunk-F5GKG7AF.js.map +1 -0
- package/dist/lib/{chunk-QIV2657I.js → chunk-FG5KIBUV.js} +5 -5
- package/dist/lib/chunk-FG5KIBUV.js.map +1 -0
- package/dist/lib/{chunk-632PWWU7.cjs → chunk-GFUPZMLG.cjs} +7 -4
- package/dist/lib/chunk-GFUPZMLG.cjs.map +1 -0
- package/dist/lib/{chunk-ZVZFMMNL.js → chunk-GUZKITBG.js} +3 -3
- package/dist/lib/{chunk-ZVZFMMNL.js.map → chunk-GUZKITBG.js.map} +1 -1
- package/dist/lib/{chunk-FZQTFDSL.cjs → chunk-IOGI3CRA.cjs} +14 -24
- package/dist/lib/chunk-IOGI3CRA.cjs.map +1 -0
- package/dist/lib/{chunk-53LK7IG5.cjs → chunk-LSHBFMOA.cjs} +4 -4
- package/dist/lib/{chunk-53LK7IG5.cjs.map → chunk-LSHBFMOA.cjs.map} +1 -1
- package/dist/lib/{chunk-3DKBH67A.cjs → chunk-MZQFHBHY.cjs} +4 -4
- package/dist/lib/{chunk-3DKBH67A.cjs.map → chunk-MZQFHBHY.cjs.map} +1 -1
- package/dist/lib/{chunk-RHADQ6HA.js → chunk-OZKNYQEG.js} +3 -3
- package/dist/lib/{chunk-RHADQ6HA.js.map → chunk-OZKNYQEG.js.map} +1 -1
- package/dist/lib/{chunk-H7ZLQIQJ.js → chunk-P7G6JMYM.js} +28 -11
- package/dist/lib/chunk-P7G6JMYM.js.map +1 -0
- package/dist/lib/{chunk-TB2ZWKZN.js → chunk-PEUTCIA5.js} +3 -3
- package/dist/lib/{chunk-TB2ZWKZN.js.map → chunk-PEUTCIA5.js.map} +1 -1
- package/dist/lib/{chunk-OGEFARN2.cjs → chunk-R56TN3SN.cjs} +4 -4
- package/dist/lib/{chunk-OGEFARN2.cjs.map → chunk-R56TN3SN.cjs.map} +1 -1
- package/dist/lib/{chunk-JNDYXB7E.js → chunk-U62D4YIG.js} +68 -11
- package/dist/lib/chunk-U62D4YIG.js.map +1 -0
- package/dist/lib/{chunk-ATE22SGR.cjs → chunk-YVTKFZ6T.cjs} +7 -7
- package/dist/lib/chunk-YVTKFZ6T.cjs.map +1 -0
- package/dist/lib/{config-B-c9HuOG.d.cts → config-CI0wMZ6n.d.cts} +2 -2
- package/dist/lib/{config-B1veyual.d.ts → config-ddlkdTiQ.d.ts} +2 -2
- package/dist/lib/config-file.d.cts +1 -1
- package/dist/lib/config-file.d.ts +1 -1
- package/dist/lib/contexts/api-context.cjs +6 -6
- package/dist/lib/contexts/api-context.d.cts +3 -3
- package/dist/lib/contexts/api-context.d.ts +3 -3
- package/dist/lib/contexts/api-context.js +5 -5
- package/dist/lib/contexts/context.cjs +4 -4
- package/dist/lib/contexts/context.d.cts +3 -3
- package/dist/lib/contexts/context.d.ts +3 -3
- package/dist/lib/contexts/context.js +3 -3
- package/dist/lib/contexts/environment-context.cjs +5 -5
- package/dist/lib/contexts/environment-context.d.cts +3 -3
- package/dist/lib/contexts/environment-context.d.ts +3 -3
- package/dist/lib/contexts/environment-context.js +4 -4
- package/dist/lib/contexts/index.cjs +8 -8
- package/dist/lib/contexts/index.d.cts +3 -3
- package/dist/lib/contexts/index.d.ts +3 -3
- package/dist/lib/contexts/index.js +5 -5
- package/dist/lib/contexts/plugin-context.d.cts +3 -3
- package/dist/lib/contexts/plugin-context.d.ts +3 -3
- package/dist/lib/entry.d.cts +1 -1
- package/dist/lib/entry.d.ts +1 -1
- package/dist/lib/fs/index.cjs +3 -3
- package/dist/lib/fs/index.d.cts +1 -1
- package/dist/lib/fs/index.d.ts +1 -1
- package/dist/lib/fs/index.js +2 -2
- package/dist/lib/fs/vfs.cjs +3 -3
- package/dist/lib/fs/vfs.d.cts +1 -1
- package/dist/lib/fs/vfs.d.ts +1 -1
- package/dist/lib/fs/vfs.js +2 -2
- package/dist/lib/index.cjs +39 -39
- package/dist/lib/index.d.cts +4 -4
- package/dist/lib/index.d.ts +4 -4
- package/dist/lib/index.js +13 -13
- package/dist/lib/{internal-CyU9mm3A.d.ts → internal-CpImHgP1.d.ts} +2 -2
- package/dist/lib/{internal-DljLUjCB.d.cts → internal-VWg0uhQX.d.cts} +2 -2
- package/dist/lib/logger.cjs +3 -3
- package/dist/lib/logger.d.cts +1 -1
- package/dist/lib/logger.d.ts +1 -1
- package/dist/lib/logger.js +1 -1
- package/dist/lib/typescript/import-transformer.d.cts +1 -1
- package/dist/lib/typescript/import-transformer.d.ts +1 -1
- package/dist/lib/typescript/index.d.cts +1 -1
- package/dist/lib/typescript/index.d.ts +1 -1
- package/dist/lib/typescript/ts-morph.d.cts +1 -1
- package/dist/lib/typescript/ts-morph.d.ts +1 -1
- package/dist/lib/unplugin/factory.cjs +7 -7
- package/dist/lib/unplugin/factory.d.cts +3 -3
- package/dist/lib/unplugin/factory.d.ts +3 -3
- package/dist/lib/unplugin/factory.js +6 -6
- package/dist/lib/unplugin/helpers.d.cts +1 -1
- package/dist/lib/unplugin/helpers.d.ts +1 -1
- package/dist/lib/unplugin/index.cjs +12 -12
- package/dist/lib/unplugin/index.d.cts +3 -3
- package/dist/lib/unplugin/index.d.ts +3 -3
- package/dist/lib/unplugin/index.js +8 -8
- package/dist/lib/unplugin/plugin.cjs +3 -3
- package/dist/lib/unplugin/plugin.d.cts +3 -3
- package/dist/lib/unplugin/plugin.d.ts +3 -3
- package/dist/lib/unplugin/plugin.js +2 -2
- package/dist/lib/{unplugin-Bbv2ATez.d.ts → unplugin-7X-TYepN.d.ts} +2 -2
- package/dist/lib/{unplugin-Cb0evIiM.d.cts → unplugin-B9f6tzsB.d.cts} +2 -2
- package/dist/lib/utilities/bundle.d.cts +1 -1
- package/dist/lib/utilities/bundle.d.ts +1 -1
- package/dist/lib/utilities/cache.d.cts +1 -1
- package/dist/lib/utilities/cache.d.ts +1 -1
- package/dist/lib/utilities/file-header.d.cts +1 -1
- package/dist/lib/utilities/file-header.d.ts +1 -1
- package/dist/lib/utilities/index.cjs +23 -23
- package/dist/lib/utilities/index.d.cts +1 -1
- package/dist/lib/utilities/index.d.ts +1 -1
- package/dist/lib/utilities/index.js +5 -5
- package/dist/lib/utilities/meta.d.cts +1 -1
- package/dist/lib/utilities/meta.d.ts +1 -1
- package/dist/lib/utilities/resolve.d.cts +1 -1
- package/dist/lib/utilities/resolve.d.ts +1 -1
- package/dist/lib/utilities/source-file.d.cts +1 -1
- package/dist/lib/utilities/source-file.d.ts +1 -1
- package/dist/lib/utilities/source-map.d.cts +1 -1
- package/dist/lib/utilities/source-map.d.ts +1 -1
- package/dist/lib/utilities/worker.cjs +4 -4
- package/dist/lib/utilities/worker.d.cts +1 -1
- package/dist/lib/utilities/worker.d.ts +1 -1
- package/dist/lib/utilities/worker.js +2 -2
- package/dist/lib/utilities/write-file.d.cts +1 -1
- package/dist/lib/utilities/write-file.d.ts +1 -1
- package/dist/next.cjs +6 -5
- package/dist/next.js +5 -4
- package/dist/nuxt.cjs +9 -8
- package/dist/nuxt.d.cts +1 -1
- package/dist/nuxt.d.ts +1 -1
- package/dist/nuxt.js +7 -6
- package/dist/plugin-utils/{chunk-4K76UMSW.cjs → chunk-AHZPK4Z5.cjs} +7 -7
- package/dist/plugin-utils/{chunk-4K76UMSW.cjs.map → chunk-AHZPK4Z5.cjs.map} +1 -1
- package/dist/plugin-utils/{chunk-Q72RPP6W.cjs → chunk-BWAX3NRG.cjs} +52 -8
- package/dist/plugin-utils/chunk-BWAX3NRG.cjs.map +1 -0
- package/dist/plugin-utils/{chunk-R3QMSBAQ.cjs → chunk-EJ5XPAJQ.cjs} +6 -6
- package/dist/plugin-utils/{chunk-R3QMSBAQ.cjs.map → chunk-EJ5XPAJQ.cjs.map} +1 -1
- package/dist/plugin-utils/{chunk-6H74NYXL.js → chunk-FTVPZZJO.js} +52 -9
- package/dist/plugin-utils/chunk-FTVPZZJO.js.map +1 -0
- package/dist/plugin-utils/{chunk-F7YMH4ZA.cjs → chunk-JAG7QJDV.cjs} +5 -5
- package/dist/plugin-utils/{chunk-F7YMH4ZA.cjs.map → chunk-JAG7QJDV.cjs.map} +1 -1
- package/dist/plugin-utils/{chunk-OYJBYXML.js → chunk-JCX2UJYO.js} +3 -3
- package/dist/plugin-utils/{chunk-OYJBYXML.js.map → chunk-JCX2UJYO.js.map} +1 -1
- package/dist/plugin-utils/{chunk-6E36JQV2.js → chunk-N4IXPCGY.js} +3 -3
- package/dist/plugin-utils/{chunk-6E36JQV2.js.map → chunk-N4IXPCGY.js.map} +1 -1
- package/dist/plugin-utils/{chunk-5YR5W7JN.js → chunk-WZCGJ7JR.js} +3 -3
- package/dist/plugin-utils/{chunk-5YR5W7JN.js.map → chunk-WZCGJ7JR.js.map} +1 -1
- package/dist/plugin-utils/context-helpers.d.cts +1 -1
- package/dist/plugin-utils/context-helpers.d.ts +1 -1
- package/dist/plugin-utils/{context-0ur9Uamc.d.cts → context-tOHhfmcN.d.cts} +1 -1
- package/dist/plugin-utils/{context-0ur9Uamc.d.ts → context-tOHhfmcN.d.ts} +1 -1
- package/dist/plugin-utils/enforce.cjs +5 -5
- package/dist/plugin-utils/enforce.d.cts +1 -1
- package/dist/plugin-utils/enforce.d.ts +1 -1
- package/dist/plugin-utils/enforce.js +4 -4
- package/dist/plugin-utils/extend.cjs +4 -4
- package/dist/plugin-utils/extend.d.cts +1 -1
- package/dist/plugin-utils/extend.d.ts +1 -1
- package/dist/plugin-utils/extend.js +3 -3
- package/dist/plugin-utils/get-config-path.d.cts +1 -1
- package/dist/plugin-utils/get-config-path.d.ts +1 -1
- package/dist/plugin-utils/helpers.cjs +18 -14
- package/dist/plugin-utils/helpers.d.cts +13 -6
- package/dist/plugin-utils/helpers.d.ts +13 -6
- package/dist/plugin-utils/helpers.js +1 -1
- package/dist/plugin-utils/index.cjs +24 -20
- package/dist/plugin-utils/index.d.cts +2 -2
- package/dist/plugin-utils/index.d.ts +2 -2
- package/dist/plugin-utils/index.js +4 -4
- package/dist/plugin-utils/merge.cjs +3 -3
- package/dist/plugin-utils/merge.d.cts +1 -1
- package/dist/plugin-utils/merge.d.ts +1 -1
- package/dist/plugin-utils/merge.js +2 -2
- package/dist/plugin-utils/paths.d.cts +1 -1
- package/dist/plugin-utils/paths.d.ts +1 -1
- package/dist/rolldown.cjs +8 -7
- package/dist/rolldown.d.cts +1 -1
- package/dist/rolldown.d.ts +1 -1
- package/dist/rolldown.js +5 -4
- package/dist/rollup.cjs +5 -4
- package/dist/rollup.d.cts +1 -1
- package/dist/rollup.d.ts +1 -1
- package/dist/rollup.js +4 -3
- package/dist/rspack.cjs +5 -4
- package/dist/rspack.d.cts +1 -1
- package/dist/rspack.d.ts +1 -1
- package/dist/rspack.js +4 -3
- package/dist/tsdown.cjs +6 -5
- package/dist/tsdown.js +5 -4
- package/dist/tsup.cjs +6 -5
- package/dist/tsup.js +5 -4
- package/dist/types/api.d.cts +2 -2
- package/dist/types/api.d.ts +2 -2
- package/dist/types/babel.d.cts +1 -1
- package/dist/types/babel.d.ts +1 -1
- package/dist/types/build.cjs +8 -1
- package/dist/types/build.d.cts +2 -1
- package/dist/types/build.d.ts +2 -1
- package/dist/types/build.js +2 -1
- package/dist/types/commands.d.cts +1 -1
- package/dist/types/commands.d.ts +1 -1
- package/dist/types/config.d.cts +1 -1
- package/dist/types/config.d.ts +1 -1
- package/dist/types/context.d.cts +1 -1
- package/dist/types/context.d.ts +1 -1
- package/dist/types/hooks.d.cts +1 -1
- package/dist/types/hooks.d.ts +1 -1
- package/dist/types/index.cjs +15 -3
- package/dist/types/index.d.cts +3 -3
- package/dist/types/index.d.ts +3 -3
- package/dist/types/index.js +2 -2
- package/dist/types/internal.d.cts +2 -2
- package/dist/types/internal.d.ts +2 -2
- package/dist/types/plugin.cjs +12 -2
- package/dist/types/plugin.d.cts +1 -1
- package/dist/types/plugin.d.ts +1 -1
- package/dist/types/plugin.js +3 -1
- package/dist/types/resolved.d.cts +1 -1
- package/dist/types/resolved.d.ts +1 -1
- package/dist/types/unplugin.d.cts +2 -2
- package/dist/types/unplugin.d.ts +2 -2
- package/dist/unloader.cjs +5 -4
- package/dist/unloader.d.cts +1 -1
- package/dist/unloader.d.ts +1 -1
- package/dist/unloader.js +4 -3
- package/dist/unplugin.cjs +7 -6
- package/dist/unplugin.d.cts +2 -2
- package/dist/unplugin.d.ts +2 -2
- package/dist/unplugin.js +5 -4
- package/dist/vite.cjs +8 -7
- package/dist/vite.d.cts +1 -1
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +5 -4
- package/dist/webpack.cjs +8 -7
- package/dist/webpack.d.cts +1 -1
- package/dist/webpack.d.ts +1 -1
- package/dist/webpack.js +5 -4
- package/package.json +2 -2
- package/dist/chunk-AXIRZAL7.js +0 -3
- package/dist/chunk-FONMKERT.js +0 -12
- package/dist/chunk-LU6QA54F.cjs +0 -14
- package/dist/chunk-P2TEUGJQ.cjs +0 -12
- package/dist/chunk-VQCQRLGM.cjs +0 -4
- package/dist/chunk-ZWRTXSA4.cjs +0 -12
- package/dist/lib/chunk-2YAAI6BY.js.map +0 -1
- package/dist/lib/chunk-35EO5Y7R.js.map +0 -1
- package/dist/lib/chunk-632PWWU7.cjs.map +0 -1
- package/dist/lib/chunk-ATE22SGR.cjs.map +0 -1
- package/dist/lib/chunk-FZQTFDSL.cjs.map +0 -1
- package/dist/lib/chunk-H7ZLQIQJ.js.map +0 -1
- package/dist/lib/chunk-JNDYXB7E.js.map +0 -1
- package/dist/lib/chunk-LO5DWCMR.cjs.map +0 -1
- package/dist/lib/chunk-QIV2657I.js.map +0 -1
- package/dist/lib/chunk-SADRLVE7.cjs.map +0 -1
- package/dist/plugin-utils/chunk-6H74NYXL.js.map +0 -1
- package/dist/plugin-utils/chunk-Q72RPP6W.cjs.map +0 -1
|
@@ -6,6 +6,18 @@ var isSetObject = require('@stryke/type-checks/is-set-object');
|
|
|
6
6
|
var isSetString = require('@stryke/type-checks/is-set-string');
|
|
7
7
|
var isUndefined = require('@stryke/type-checks/is-undefined');
|
|
8
8
|
|
|
9
|
+
// src/types/build.ts
|
|
10
|
+
var UNPLUGIN_BUILD_VARIANTS = [
|
|
11
|
+
"rollup",
|
|
12
|
+
"webpack",
|
|
13
|
+
"rspack",
|
|
14
|
+
"vite",
|
|
15
|
+
"esbuild",
|
|
16
|
+
"farm",
|
|
17
|
+
"unloader",
|
|
18
|
+
"rolldown"
|
|
19
|
+
];
|
|
20
|
+
|
|
9
21
|
// src/types/commands.ts
|
|
10
22
|
var SUPPORTED_COMMANDS = [
|
|
11
23
|
"new",
|
|
@@ -18,10 +30,22 @@ var SUPPORTED_COMMANDS = [
|
|
|
18
30
|
"deploy",
|
|
19
31
|
"finalize"
|
|
20
32
|
];
|
|
33
|
+
var KNOWN_HOOKS = [
|
|
34
|
+
...SUPPORTED_COMMANDS,
|
|
35
|
+
"config",
|
|
36
|
+
"configEnvironment",
|
|
37
|
+
"configResolved",
|
|
38
|
+
"buildStart",
|
|
39
|
+
"buildEnd",
|
|
40
|
+
"transform",
|
|
41
|
+
"load",
|
|
42
|
+
"resolveId",
|
|
43
|
+
"writeBundle"
|
|
44
|
+
];
|
|
21
45
|
|
|
22
46
|
// src/plugin-utils/helpers.ts
|
|
23
47
|
function isPlugin(value) {
|
|
24
|
-
return isSetObject.isSetObject(value) && "name" in value && isSetString.isSetString(value.name) && (isUndefined.isUndefined(value.applyToEnvironment) || "applyToEnvironment" in value && isFunction.isFunction(value.applyToEnvironment)) && (isUndefined.isUndefined(value.dedupe) || "dedupe" in value && isFunction.isFunction(value.dedupe)) &&
|
|
48
|
+
return isSetObject.isSetObject(value) && "name" in value && isSetString.isSetString(value.name) && (isUndefined.isUndefined(value.api) || "api" in value && isSetObject.isSetObject(value.api)) && (isUndefined.isUndefined(value.applyToEnvironment) || "applyToEnvironment" in value && isFunction.isFunction(value.applyToEnvironment)) && (isUndefined.isUndefined(value.dedupe) || "dedupe" in value && isFunction.isFunction(value.dedupe)) && KNOWN_HOOKS.every((hook) => isUndefined.isUndefined(value[hook]) || hook in value && (isPluginHookFunction(value[hook]) || hook === "config" && isSetObject.isSetObject(value[hook]))) && UNPLUGIN_BUILD_VARIANTS.every((variant) => isUndefined.isUndefined(value[variant]) || variant in value && isSetObject.isSetObject(value[variant]));
|
|
25
49
|
}
|
|
26
50
|
chunkPK6SKIKE_cjs.__name(isPlugin, "isPlugin");
|
|
27
51
|
function isPluginConfigObject(value) {
|
|
@@ -33,17 +57,17 @@ function isPluginConfigTuple(value) {
|
|
|
33
57
|
}
|
|
34
58
|
chunkPK6SKIKE_cjs.__name(isPluginConfigTuple, "isPluginConfigTuple");
|
|
35
59
|
function isPluginConfig(value) {
|
|
36
|
-
return isSetString.isSetString(value) || isFunction.isFunction(value) || isPlugin(value) || Array.isArray(value) && value.every((item) =>
|
|
60
|
+
return isSetString.isSetString(value) || isFunction.isFunction(value) || isPlugin(value) || isPluginConfigObject(value) || isPluginConfigTuple(value) || Array.isArray(value) && value.every((item) => isPluginConfig(item));
|
|
37
61
|
}
|
|
38
62
|
chunkPK6SKIKE_cjs.__name(isPluginConfig, "isPluginConfig");
|
|
39
|
-
function isPluginHookFunction(value) {
|
|
40
|
-
return isFunction.isFunction(value) || isSetObject.isSetObject(value) && "handler" in value && isFunction.isFunction(value.handler);
|
|
41
|
-
}
|
|
42
|
-
chunkPK6SKIKE_cjs.__name(isPluginHookFunction, "isPluginHookFunction");
|
|
43
63
|
function isPluginHookObject(value) {
|
|
44
64
|
return isSetObject.isSetObject(value) && "handler" in value && isFunction.isFunction(value.handler);
|
|
45
65
|
}
|
|
46
66
|
chunkPK6SKIKE_cjs.__name(isPluginHookObject, "isPluginHookObject");
|
|
67
|
+
function isPluginHookFunction(value) {
|
|
68
|
+
return isFunction.isFunction(value) || isPluginHookObject(value);
|
|
69
|
+
}
|
|
70
|
+
chunkPK6SKIKE_cjs.__name(isPluginHookFunction, "isPluginHookFunction");
|
|
47
71
|
function isPluginHook(value) {
|
|
48
72
|
return isPluginHookFunction(value) || isPluginHookObject(value);
|
|
49
73
|
}
|
|
@@ -89,10 +113,30 @@ function addPluginHook(context, plugin, pluginHook, hooksList) {
|
|
|
89
113
|
}
|
|
90
114
|
}
|
|
91
115
|
chunkPK6SKIKE_cjs.__name(addPluginHook, "addPluginHook");
|
|
116
|
+
function findInvalidPluginConfig(config) {
|
|
117
|
+
if (isPluginConfig(config)) {
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
if (Array.isArray(config)) {
|
|
121
|
+
const invalidItems = [];
|
|
122
|
+
config.forEach((item) => {
|
|
123
|
+
const invalid = findInvalidPluginConfig(item);
|
|
124
|
+
if (invalid) {
|
|
125
|
+
invalidItems.push(...invalid.map((i) => JSON.stringify(i, null, 2)));
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
return invalidItems.length > 0 ? invalidItems : null;
|
|
129
|
+
}
|
|
130
|
+
return [
|
|
131
|
+
JSON.stringify(config, null, 2)
|
|
132
|
+
];
|
|
133
|
+
}
|
|
134
|
+
chunkPK6SKIKE_cjs.__name(findInvalidPluginConfig, "findInvalidPluginConfig");
|
|
92
135
|
|
|
93
136
|
exports.addPluginHook = addPluginHook;
|
|
94
137
|
exports.checkDedupe = checkDedupe;
|
|
95
138
|
exports.extractPluginHook = extractPluginHook;
|
|
139
|
+
exports.findInvalidPluginConfig = findInvalidPluginConfig;
|
|
96
140
|
exports.getHookHandler = getHookHandler;
|
|
97
141
|
exports.isHookExternal = isHookExternal;
|
|
98
142
|
exports.isHookInternal = isHookInternal;
|
|
@@ -103,5 +147,5 @@ exports.isPluginConfigTuple = isPluginConfigTuple;
|
|
|
103
147
|
exports.isPluginHook = isPluginHook;
|
|
104
148
|
exports.isPluginHookFunction = isPluginHookFunction;
|
|
105
149
|
exports.isPluginHookObject = isPluginHookObject;
|
|
106
|
-
//# sourceMappingURL=chunk-
|
|
107
|
-
//# sourceMappingURL=chunk-
|
|
150
|
+
//# sourceMappingURL=chunk-BWAX3NRG.cjs.map
|
|
151
|
+
//# sourceMappingURL=chunk-BWAX3NRG.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/types/build.ts","../../src/types/commands.ts","../../src/types/plugin.ts","../../src/plugin-utils/helpers.ts"],"names":["UNPLUGIN_BUILD_VARIANTS","SUPPORTED_COMMANDS","KNOWN_HOOKS","isPlugin","value","isSetObject","isSetString","name","isUndefined","api","applyToEnvironment","isFunction","dedupe","every","hook","isPluginHookFunction","variant","isPluginConfigObject","plugin","options","isPluginConfigTuple","Array","isArray","length","isPluginConfig","item","isPluginHookObject","handler","isPluginHook","getHookHandler","pluginHook","extractPluginHook","context","undefined","normal","bind","order","isHookExternal","startsWith","isHookInternal","checkDedupe","plugins","some","p","addPluginHook","hooksList","map","push","findInvalidPluginConfig","config","invalidItems","forEach","invalid","i","JSON","stringify"],"mappings":";;;;;;;;;AA6CO,IAAMA,uBAAAA,GAAkD;AAC7D,EAAA,QAAA;AACA,EAAA,SAAA;AACA,EAAA,QAAA;AACA,EAAA,MAAA;AACA,EAAA,SAAA;AACA,EAAA,MAAA;AACA,EAAA,UAAA;AACA,EAAA;;;;AC/BK,IAAMC,kBAAAA,GAAqB;AAChC,EAAA,KAAA;AACA,EAAA,OAAA;AACA,EAAA,SAAA;AACA,EAAA,MAAA;AACA,EAAA,MAAA;AACA,EAAA,OAAA;AACA,EAAA,MAAA;AACA,EAAA,QAAA;AACA,EAAA;;AC0XK,IAAMC,WAAAA,GAAc;AACtBD,EAAAA,GAAAA,kBAAAA;AACH,EAAA,QAAA;AACA,EAAA,mBAAA;AACA,EAAA,gBAAA;AACA,EAAA,YAAA;AACA,EAAA,UAAA;AACA,EAAA,WAAA;AACA,EAAA,MAAA;AACA,EAAA,WAAA;AACA,EAAA;;;;ACjXK,SAASE,SAEdC,KAAAA,EAAc;AACd,EAAA,OACEC,wBAAYD,KAAAA,CAAAA,IACZ,MAAA,IAAUA,KAAAA,IACVE,wBAAYF,KAAAA,CAAMG,IAAI,CAAA,KACrBC,uBAAAA,CAAaJ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ACHH,MAAAA,OAAAA,EAASE,cAAAA,CAAeC,UAAAA,CAAAA,CAAYK,IAAAA,CAAKH,OAAAA;KAC3C,CAAA;AAER,EAAA;AACF;AAzBgBY,wBAAAA,CAAAA,aAAAA,EAAAA,eAAAA,CAAAA;AAiCT,SAASI,wBAEdC,MAAAA,EAA8B;AAC9B,EAAA,IAAIzB,cAAAA,CAAyByB,MAAAA,CAAAA,EAAS;AACpC,IAAA,OAAO,IAAA;AACT,EAAA;AAEA,EAAA,IAAI5B,KAAAA,CAAMC,OAAAA,CAAQ2B,MAAAA,CAAAA,EAAqC;AACrD,IAAA,MAAMC,eAAyB,EAAA;AAC9BD,IAAAA,MAAAA,CAAoCE,OAAAA,CAAQ1B,CAAAA,IAAAA,KAAAA;AAC3C,MAAA,MAAM2B,OAAAA,GAAUJ,wBAAkCvB,IAAAA,CAAAA;AAClD,MAAA,IAAI2B,OAAAA,EAAS;AACXF,QAAAA,YAAAA,CAAaH,IAAAA,CAAI,GAAIK,OAAAA,CAAQN,GAAAA,CAAIO,CAAAA,CAAAA,KAAKC,IAAAA,CAAKC,SAAAA,CAAUF,CAAAA,EAAG,IAAA,EAAM,CAAA,CAAA,CAAA,CAAA;AAChE,MAAA;IACF,CAAA,CAAA;AAEA,IAAA,OAAOH,YAAAA,CAAa3B,MAAAA,GAAS,CAAA,GAAI2B,YAAAA,GAAe,IAAA;AAClD,EAAA;AAEA,EAAA,OAAO;IAACI,IAAAA,CAAKC,SAAAA,CAAUN,MAAAA,EAAQ,IAAA,EAAM,CAAA;;AACvC;AApBgBD,wBAAAA,CAAAA,uBAAAA,EAAAA,yBAAAA,CAAAA","file":"chunk-BWAX3NRG.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 { UserConfig as ExternalFarmOptions } from \"@farmfe/core\";\nimport type { Configuration as ExternalRspackOptions } from \"@rspack/core\";\nimport type { BuildOptions as ExternalTsupOptions } from \"@storm-software/tsup/types\";\nimport type { UnbuildOptions as ExternalUnbuildOptions } from \"@storm-software/unbuild/types\";\nimport type { BuildOptions as ExternalESBuildOptions } from \"esbuild\";\nimport type { RolldownOptions as ExternalRolldownOptions } from \"rolldown\";\nimport type {\n RollupOptions as ExternalRollupOptions,\n OutputOptions as ExternalRollupOutputOptions\n} from \"rollup\";\nimport type { UserConfig as ExternalTsdownOptions } from \"tsdown\";\nimport type {\n DepOptimizationOptions,\n UserConfig as ExternalViteUserConfig\n} from \"vite\";\nimport type { Configuration as ExternalWebpackOptions } from \"webpack\";\n\nexport type UnpluginBuildVariant =\n | \"rollup\"\n | \"webpack\"\n | \"rspack\"\n | \"vite\"\n | \"esbuild\"\n | \"farm\"\n | \"unloader\"\n | \"rolldown\";\n\nexport const UNPLUGIN_BUILD_VARIANTS: UnpluginBuildVariant[] = [\n \"rollup\",\n \"webpack\",\n \"rspack\",\n \"vite\",\n \"esbuild\",\n \"farm\",\n \"unloader\",\n \"rolldown\"\n];\n\nexport type BuildVariant = UnpluginBuildVariant | \"tsup\" | \"tsdown\" | \"unbuild\";\n\nexport type InferUnpluginVariant<TBuildVariant extends BuildVariant> =\n TBuildVariant extends \"tsup\"\n ? \"esbuild\"\n : TBuildVariant extends \"tsdown\"\n ? \"rolldown\"\n : TBuildVariant extends \"unbuild\"\n ? \"rollup\"\n : TBuildVariant;\n\nexport interface BuildConfig {\n /**\n * The platform to build the project for\n *\n * @defaultValue \"neutral\"\n */\n platform?: \"node\" | \"browser\" | \"neutral\";\n\n /**\n * Array of strings indicating the polyfills to include for the build.\n *\n * @remarks\n * This option allows you to specify which polyfills should be included in the build process to ensure compatibility with the target environment. The paths for the polyfills can use placeholder tokens (the `replacePathTokens` helper function will be used to resolve the actual values).\n *\n * @example\n * ```ts\n * {\n * polyfill: ['{projectRoot}/custom-polyfill.ts']\n * }\n * ```\n */\n polyfill?: string[];\n\n /**\n * Array of strings indicating the order in which fields in a package.json file should be resolved to determine the entry point for a module.\n *\n * @defaultValue `['browser', 'module', 'jsnext:main', 'jsnext']`\n */\n mainFields?: string[];\n\n /**\n * Array of strings indicating what conditions should be used for module resolution.\n */\n conditions?: string[];\n\n /**\n * Array of strings indicating what file extensions should be used for module resolution.\n *\n * @defaultValue `['.mjs', '.js', '.mts', '.ts', '.jsx', '.tsx', '.json']`\n */\n extensions?: string[];\n\n /**\n * Array of strings indicating what modules should be deduplicated to a single version in the build.\n *\n * @remarks\n * This option is useful for ensuring that only one version of a module is included in the bundle, which can help reduce bundle size and avoid conflicts.\n */\n dedupe?: string[];\n\n /**\n * Array of strings or regular expressions that indicate what modules are builtin for the environment.\n */\n builtins?: (string | RegExp)[];\n\n /**\n * Define global variable replacements.\n *\n * @remarks\n * This option allows you to specify global constants that will be replaced in the code during the build process. It is similar to the `define` option in esbuild and Vite, enabling you to replace specific identifiers with constant expressions at build time.\n *\n * @example\n * ```ts\n * {\n * define: {\n * __VERSION__: '\"1.0.0\"',\n * __DEV__: 'process.env.NODE_ENV !== \"production\"'\n * }\n * }\n * ```\n *\n * @see https://esbuild.github.io/api/#define\n * @see https://vitejs.dev/config/build-options.html#define\n * @see https://github.com/rollup/plugins/tree/master/packages/replace\n */\n define?: Record<string, any>;\n\n /**\n * Global variables that will have import statements injected where necessary\n *\n * @remarks\n * This option allows you to specify global variables that should be automatically imported from specified modules whenever they are used in the code. This is particularly useful for polyfilling Node.js globals in a browser environment.\n *\n * @example\n * ```ts\n * {\n * inject: {\n * process: 'process/browser',\n * Buffer: ['buffer', 'Buffer'],\n * }\n * }\n * ```\n *\n * @see https://github.com/rollup/plugins/tree/master/packages/inject\n */\n inject?: Record<string, string | string[]>;\n\n /**\n * The alias mappings to use for module resolution during the build process.\n *\n * @remarks\n * This option allows you to define custom path aliases for modules, which can be useful for simplifying imports and managing dependencies.\n *\n * @example\n * ```ts\n * {\n * alias: {\n * \"@utils\": \"./src/utils\",\n * \"@components\": \"./src/components\"\n * }\n * }\n * ```\n *\n * @see https://github.com/rollup/plugins/tree/master/packages/alias\n */\n alias?:\n | Record<string, string>\n | Array<{\n find: string | RegExp;\n replacement: string;\n }>;\n\n /**\n * A list of modules that should not be bundled, even if they are external dependencies.\n *\n * @remarks\n * This option is useful for excluding specific modules from the bundle, such as Node.js built-in modules or other libraries that should not be bundled.\n */\n external?: (string | RegExp)[];\n\n /**\n * A list of modules that should always be bundled, even if they are external dependencies.\n */\n noExternal?: (string | RegExp)[];\n\n /**\n * Should the Powerlines CLI processes skip bundling the `node_modules` directory?\n */\n skipNodeModulesBundle?: boolean;\n\n /**\n * If true, `process.env` referenced in code will be preserved as-is and evaluated in runtime. Otherwise, it is statically replaced as an empty object.\n *\n * @defaultValue false\n */\n keepProcessEnv?: boolean;\n\n /**\n * An optional set of override options to apply to the selected build variant.\n *\n * @remarks\n * This option allows you to provide configuration options with the guarantee that they will **not** be overridden and will take precedence over other build configurations.\n */\n override?: Record<string, any>;\n}\n\nexport type BuildResolvedConfig = Omit<BuildConfig, \"override\">;\n\n// ESBuild\nexport type ESBuildBuildConfig = Omit<\n ExternalESBuildOptions,\n | \"entryPoints\"\n | \"sourceRoot\"\n | \"platform\"\n | \"outdir\"\n | \"env\"\n | \"assets\"\n | \"external\"\n | \"inject\"\n | \"tsconfig\"\n | \"tsconfigRaw\"\n | \"logLevel\"\n> &\n BuildConfig;\nexport type ESBuildResolvedBuildConfig = Omit<\n ExternalESBuildOptions,\n \"inject\"\n> &\n BuildResolvedConfig;\n\n// Vite\nexport type ViteBuildConfig = Omit<\n ExternalViteUserConfig,\n | \"entry\"\n | \"entryPoints\"\n | \"tsconfig\"\n | \"tsconfigRaw\"\n | \"environments\"\n | \"output\"\n> &\n BuildConfig & {\n /**\n * Optimize deps config\n */\n optimizeDeps?: Omit<DepOptimizationOptions, \"extensions\">;\n };\nexport type ViteResolvedBuildConfig = ExternalViteUserConfig &\n BuildResolvedConfig;\n\n// Webpack\nexport type WebpackBuildConfig = Omit<\n ExternalWebpackOptions,\n \"name\" | \"entry\" | \"entryPoints\" | \"tsconfig\" | \"tsconfigRaw\"\n> &\n BuildConfig;\nexport type WebpackResolvedBuildConfig = ExternalWebpackOptions &\n BuildResolvedConfig;\n\n// Rspack\nexport type RspackBuildConfig = Omit<\n ExternalRspackOptions,\n \"name\" | \"entry\" | \"entryPoints\" | \"tsconfig\" | \"tsconfigRaw\"\n> &\n BuildConfig;\nexport type RspackResolvedBuildConfig = ExternalRspackOptions &\n BuildResolvedConfig;\n\n// Rollup\nexport type RollupBuildOutputConfig = Omit<\n ExternalRollupOutputOptions,\n \"dir\" | \"format\"\n>;\nexport type RollupBuildConfig = Omit<\n ExternalRollupOptions,\n \"entry\" | \"external\" | \"input\" | \"output\" | \"logLevel\"\n> & {\n output: RollupBuildOutputConfig | RollupBuildOutputConfig[];\n} & BuildConfig;\nexport type RollupResolvedBuildConfig = ExternalRollupOptions &\n BuildResolvedConfig;\n\n// Rolldown\nexport type RolldownBuildConfig = Omit<\n ExternalRolldownOptions,\n \"input\" | \"external\" | \"tsconfig\" | \"logLevel\" | \"output\"\n> &\n BuildConfig;\nexport type RolldownResolvedBuildConfig = ExternalRolldownOptions &\n BuildResolvedConfig;\n\n// Tsup\nexport type TsupBuildConfig = Partial<\n Omit<\n ExternalTsupOptions,\n | \"userOptions\"\n | \"tsconfig\"\n | \"tsconfigRaw\"\n | \"assets\"\n | \"outputPath\"\n | \"mode\"\n | \"format\"\n | \"platform\"\n | \"projectRoot\"\n | \"clean\"\n | \"env\"\n | \"entry\"\n | \"entryPoints\"\n | \"external\"\n | \"noExternal\"\n | \"skipNodeModulesBundle\"\n >\n> &\n BuildConfig;\nexport type TsupResolvedBuildConfig = ExternalTsupOptions & BuildResolvedConfig;\n\n// Tsdown\nexport type TsdownBuildConfig = Partial<\n Omit<\n ExternalTsdownOptions,\n | \"name\"\n | \"outDir\"\n | \"clean\"\n | \"cwd\"\n | \"tsconfig\"\n | \"publicDir\"\n | \"copy\"\n | \"alias\"\n | \"format\"\n | \"platform\"\n | \"env\"\n | \"define\"\n | \"entry\"\n | \"external\"\n | \"noExternal\"\n | \"skipNodeModulesBundle\"\n >\n> &\n BuildConfig;\nexport type TsdownResolvedBuildConfig = ExternalTsdownOptions &\n BuildResolvedConfig;\n\n// Unbuild\nexport type UnbuildBuildConfig = Partial<\n Omit<\n ExternalUnbuildOptions,\n | \"tsconfig\"\n | \"tsconfigRaw\"\n | \"assets\"\n | \"outputPath\"\n | \"mode\"\n | \"format\"\n | \"platform\"\n | \"projectRoot\"\n | \"env\"\n | \"entry\"\n | \"entryPoints\"\n >\n> &\n BuildConfig;\nexport type UnbuildResolvedBuildConfig = ExternalUnbuildOptions &\n BuildResolvedConfig;\n\n// Farm\nexport type FarmBuildConfig = Partial<\n Omit<\n ExternalFarmOptions,\n | \"tsconfig\"\n | \"tsconfigRaw\"\n | \"assets\"\n | \"outputPath\"\n | \"mode\"\n | \"format\"\n | \"platform\"\n | \"projectRoot\"\n | \"env\"\n | \"entry\"\n | \"entryPoints\"\n >\n> &\n BuildConfig;\nexport type FarmResolvedBuildConfig = ExternalFarmOptions & BuildResolvedConfig;\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 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 { UNPLUGIN_BUILD_VARIANTS } from \"./build\";\nimport type { CommandType } from \"./commands\";\nimport { SUPPORTED_COMMANDS } 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.\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 TContext extends PluginContext<ResolvedConfig> = 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<TContext>[];\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<TContext>;\n}\n\nexport const PLUGIN_NON_HOOK_FIELDS = [\n \"name\",\n \"api\",\n \"enforce\",\n \"dedupe\",\n \"applyToEnvironment\"\n] as const;\n\nexport type PluginNonHookFields =\n | ArrayValues<typeof PLUGIN_NON_HOOK_FIELDS>\n | UnpluginBuildVariant;\n\nexport const KNOWN_HOOKS = [\n ...SUPPORTED_COMMANDS,\n \"config\",\n \"configEnvironment\",\n \"configResolved\",\n \"buildStart\",\n \"buildEnd\",\n \"transform\",\n \"load\",\n \"resolveId\",\n \"writeBundle\"\n] as const;\n\nexport type KnownHooks = ArrayValues<typeof KNOWN_HOOKS>;\n\nexport const KNOWN_PLUGIN_FIELDS = [\n ...PLUGIN_NON_HOOK_FIELDS,\n ...KNOWN_HOOKS,\n ...UNPLUGIN_BUILD_VARIANTS\n] as const;\n\nexport type KnownPluginFields = ArrayValues<typeof KNOWN_PLUGIN_FIELDS>;\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 { UNPLUGIN_BUILD_VARIANTS } from \"../types/build\";\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 {\n KNOWN_HOOKS,\n Plugin,\n PluginHook,\n PluginHookObject\n} 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 TContext extends PluginContext = PluginContext<ResolvedConfig>\n>(value: unknown): value is Plugin<TContext> {\n return (\n isSetObject(value) &&\n \"name\" in value &&\n isSetString(value.name) &&\n (isUndefined((value as Plugin<TContext>).api) ||\n (\"api\" in value && isSetObject(value.api))) &&\n (isUndefined((value as Plugin<TContext>).applyToEnvironment) ||\n (\"applyToEnvironment\" in value &&\n isFunction(value.applyToEnvironment))) &&\n (isUndefined((value as Plugin<TContext>).dedupe) ||\n (\"dedupe\" in value && isFunction(value.dedupe))) &&\n KNOWN_HOOKS.every(\n hook =>\n isUndefined((value as Plugin<TContext>)[hook]) ||\n (hook in value &&\n (isPluginHookFunction((value as Plugin<TContext>)[hook]) ||\n (hook === \"config\" &&\n isSetObject((value as Plugin<TContext>)[hook]))))\n ) &&\n UNPLUGIN_BUILD_VARIANTS.every(\n variant =>\n isUndefined((value as Plugin<TContext>)[variant]) ||\n (variant in value && isSetObject((value as Plugin<TContext>)[variant]))\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<\n TContext extends PluginContext = PluginContext<ResolvedConfig>\n>(value: unknown): value is PluginConfig<TContext> {\n return (\n isSetString(value) ||\n isFunction(value) ||\n isPlugin<TContext>(value) ||\n isPluginConfigObject(value) ||\n isPluginConfigTuple(value) ||\n (Array.isArray(value) && value.every(item => isPluginConfig(item)))\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 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 isFunction(value) || isPluginHookObject(value);\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 * Check the provided {@link PluginConfig}, and return a stringified version of the invalid configuration. If an array is provided, check each item in the array.\n *\n * @param config - The plugin configuration to check\n * @returns Null if the configuration is valid, otherwise an array of stringified invalid configurations\n */\nexport function findInvalidPluginConfig<\n TContext extends PluginContext = PluginContext<ResolvedConfig>\n>(config: PluginConfig<TContext>): string[] | null {\n if (isPluginConfig<TContext>(config)) {\n return null;\n }\n\n if (Array.isArray(config as PluginConfig<TContext>[])) {\n const invalidItems: string[] = [];\n (config as PluginConfig<TContext>[]).forEach(item => {\n const invalid = findInvalidPluginConfig<TContext>(item);\n if (invalid) {\n invalidItems.push(...invalid.map(i => JSON.stringify(i, null, 2)));\n }\n });\n\n return invalidItems.length > 0 ? invalidItems : null;\n }\n\n return [JSON.stringify(config, null, 2)];\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkBWAX3NRG_cjs = require('./chunk-BWAX3NRG.cjs');
|
|
4
4
|
var chunkPK6SKIKE_cjs = require('./chunk-PK6SKIKE.cjs');
|
|
5
5
|
var defu = require('defu');
|
|
6
6
|
|
|
@@ -9,14 +9,14 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
|
9
9
|
var defu__default = /*#__PURE__*/_interopDefault(defu);
|
|
10
10
|
|
|
11
11
|
var mergePlugin = defu.createDefu((obj, key, value) => {
|
|
12
|
-
if (
|
|
12
|
+
if (chunkBWAX3NRG_cjs.isPluginHook(obj[key]) && chunkBWAX3NRG_cjs.isPluginHook(value)) {
|
|
13
13
|
obj[key] = {
|
|
14
14
|
...obj[key],
|
|
15
15
|
...value,
|
|
16
16
|
handler: /* @__PURE__ */ chunkPK6SKIKE_cjs.__name(async (...params) => {
|
|
17
17
|
const [resultA, resultB] = await Promise.all([
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
chunkBWAX3NRG_cjs.getHookHandler(obj[key])(...params),
|
|
19
|
+
chunkBWAX3NRG_cjs.getHookHandler(value)(...params)
|
|
20
20
|
]);
|
|
21
21
|
return resultB && resultA ? defu__default.default(resultA, resultB) : resultA || resultB;
|
|
22
22
|
}, "handler")
|
|
@@ -31,5 +31,5 @@ function merge(pluginA, pluginB) {
|
|
|
31
31
|
chunkPK6SKIKE_cjs.__name(merge, "merge");
|
|
32
32
|
|
|
33
33
|
exports.merge = merge;
|
|
34
|
-
//# sourceMappingURL=chunk-
|
|
35
|
-
//# sourceMappingURL=chunk-
|
|
34
|
+
//# sourceMappingURL=chunk-EJ5XPAJQ.cjs.map
|
|
35
|
+
//# sourceMappingURL=chunk-EJ5XPAJQ.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/plugin-utils/merge.ts"],"names":["mergePlugin","createDefu","obj","key","value","isPluginHook","handler","params","resultA","resultB","Promise","all","getHookHandler","defu","merge","pluginA","pluginB"],"mappings":";;;;;;;;;;AAmCA,IAAMA,WAAAA,GAAcC,eAAAA,CAAW,CAACC,GAAAA,EAAKC,KAAKC,KAAAA,KAAAA;AACxC,EAAA,IAAIC,+BAAaH,GAAAA,CAAIC,GAAAA,CAAI,CAAA,IAAKE,8BAAAA,CAAaD,KAAAA,CAAAA,EAAQ;AACjDF,IAAAA,GAAAA,CAAIC,GAAAA,CAAAA,GAAO;AACT,MAAA,GAAGD,IAAIC,GAAAA,CAAAA;MACP,GAAGC,KAAAA;AACHE,MAAAA,OAAAA,qDAAmBC,MAAAA,KAAAA;AACjB,QAAA,MAAM,CAACC,OAAAA,EAASC,OAAAA,CAAAA,GAAW,MAAMC,QAAQC,GAAAA,CAAI;AAC3CC,UAAAA,gCAAAA,CAAeV,GAAAA,CAAIC,GAAAA,CAAI,CAAA,CAAA,GAAKI,MAAAA,CAAAA;UAC5BK,gCAAAA,CAAeR,KAAAA,CAAAA,CAAAA,GAAUG,MAAAA;AAC1B,SAAA,CAAA;AAED,QAAA,OAAOE,WAAWD,OAAAA,GAAUK,qBAAAA,CAAKL,OAAAA,EAASC,OAAAA,IAAWD,OAAAA,IAAWC,OAAAA;MAClE,CAAA,EAPS,SAAA;AAQX,KAAA;AACA,IAAA,OAAO,IAAA;AACT,EAAA;AAEA,EAAA,OAAO,KAAA;AACT,CAAA,CAAA;AASO,SAASK,KAAAA,CACdC,SACAC,OAAAA,EAAmD;AAEnD,EAAA,OAAOhB,WAAAA,CAAYe,SAASC,OAAAA,CAAAA;AAK9B;AATgBF,wBAAAA,CAAAA,KAAAA,EAAAA,OAAAA,CAAAA","file":"chunk-
|
|
1
|
+
{"version":3,"sources":["../../src/plugin-utils/merge.ts"],"names":["mergePlugin","createDefu","obj","key","value","isPluginHook","handler","params","resultA","resultB","Promise","all","getHookHandler","defu","merge","pluginA","pluginB"],"mappings":";;;;;;;;;;AAmCA,IAAMA,WAAAA,GAAcC,eAAAA,CAAW,CAACC,GAAAA,EAAKC,KAAKC,KAAAA,KAAAA;AACxC,EAAA,IAAIC,+BAAaH,GAAAA,CAAIC,GAAAA,CAAI,CAAA,IAAKE,8BAAAA,CAAaD,KAAAA,CAAAA,EAAQ;AACjDF,IAAAA,GAAAA,CAAIC,GAAAA,CAAAA,GAAO;AACT,MAAA,GAAGD,IAAIC,GAAAA,CAAAA;MACP,GAAGC,KAAAA;AACHE,MAAAA,OAAAA,qDAAmBC,MAAAA,KAAAA;AACjB,QAAA,MAAM,CAACC,OAAAA,EAASC,OAAAA,CAAAA,GAAW,MAAMC,QAAQC,GAAAA,CAAI;AAC3CC,UAAAA,gCAAAA,CAAeV,GAAAA,CAAIC,GAAAA,CAAI,CAAA,CAAA,GAAKI,MAAAA,CAAAA;UAC5BK,gCAAAA,CAAeR,KAAAA,CAAAA,CAAAA,GAAUG,MAAAA;AAC1B,SAAA,CAAA;AAED,QAAA,OAAOE,WAAWD,OAAAA,GAAUK,qBAAAA,CAAKL,OAAAA,EAASC,OAAAA,IAAWD,OAAAA,IAAWC,OAAAA;MAClE,CAAA,EAPS,SAAA;AAQX,KAAA;AACA,IAAA,OAAO,IAAA;AACT,EAAA;AAEA,EAAA,OAAO,KAAA;AACT,CAAA,CAAA;AASO,SAASK,KAAAA,CACdC,SACAC,OAAAA,EAAmD;AAEnD,EAAA,OAAOhB,WAAAA,CAAYe,SAASC,OAAAA,CAAAA;AAK9B;AATgBF,wBAAAA,CAAAA,KAAAA,EAAAA,OAAAA,CAAAA","file":"chunk-EJ5XPAJQ.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 defu, { createDefu } from \"defu\";\nimport { PartialPlugin } from \"../types/config\";\nimport { PluginContext } from \"../types/context\";\nimport { Plugin } from \"../types/plugin\";\nimport { getHookHandler, isPluginHook } from \"./helpers\";\n\nexport type MergeResult<\n TContext extends PluginContext,\n TPluginA extends Plugin<TContext> | PartialPlugin<TContext>,\n TPluginB extends Plugin<TContext> | PartialPlugin<TContext>\n> =\n TPluginA extends Plugin<TContext>\n ? Plugin<TContext>\n : TPluginB extends Plugin<TContext>\n ? Plugin<TContext>\n : PartialPlugin<TContext>;\n\nconst mergePlugin = createDefu((obj, key, value) => {\n if (isPluginHook(obj[key]) && isPluginHook(value)) {\n obj[key] = {\n ...obj[key],\n ...value,\n handler: async (...params: any[]) => {\n const [resultA, resultB] = await Promise.all([\n getHookHandler(obj[key])(...params),\n getHookHandler(value)(...params)\n ]);\n\n return resultB && resultA ? defu(resultA, resultB) : resultA || resultB;\n }\n };\n return true;\n }\n\n return false;\n});\n\n/**\n * Merges two {@link Plugin | plugins} or {@link PartialPlugin | partial plugins} together.\n *\n * @param pluginA - The first {@link Plugin | plugin} or {@link PartialPlugin | partial plugin} to merge.\n * @param pluginB - The second {@link Plugin | plugin} or {@link PartialPlugin | partial plugin} to merge.\n * @returns The merged {@link Plugin | plugin} or {@link PartialPlugin | partial plugin}.\n */\nexport function merge<TContext extends PluginContext = PluginContext>(\n pluginA: Plugin<TContext> | PartialPlugin<TContext>,\n pluginB: Plugin<TContext> | PartialPlugin<TContext>\n): MergeResult<TContext, typeof pluginA, typeof pluginB> {\n return mergePlugin(pluginA, pluginB) as MergeResult<\n TContext,\n typeof pluginA,\n typeof pluginB\n >;\n}\n"]}
|
|
@@ -4,6 +4,18 @@ import { isSetObject } from '@stryke/type-checks/is-set-object';
|
|
|
4
4
|
import { isSetString } from '@stryke/type-checks/is-set-string';
|
|
5
5
|
import { isUndefined } from '@stryke/type-checks/is-undefined';
|
|
6
6
|
|
|
7
|
+
// src/types/build.ts
|
|
8
|
+
var UNPLUGIN_BUILD_VARIANTS = [
|
|
9
|
+
"rollup",
|
|
10
|
+
"webpack",
|
|
11
|
+
"rspack",
|
|
12
|
+
"vite",
|
|
13
|
+
"esbuild",
|
|
14
|
+
"farm",
|
|
15
|
+
"unloader",
|
|
16
|
+
"rolldown"
|
|
17
|
+
];
|
|
18
|
+
|
|
7
19
|
// src/types/commands.ts
|
|
8
20
|
var SUPPORTED_COMMANDS = [
|
|
9
21
|
"new",
|
|
@@ -16,10 +28,22 @@ var SUPPORTED_COMMANDS = [
|
|
|
16
28
|
"deploy",
|
|
17
29
|
"finalize"
|
|
18
30
|
];
|
|
31
|
+
var KNOWN_HOOKS = [
|
|
32
|
+
...SUPPORTED_COMMANDS,
|
|
33
|
+
"config",
|
|
34
|
+
"configEnvironment",
|
|
35
|
+
"configResolved",
|
|
36
|
+
"buildStart",
|
|
37
|
+
"buildEnd",
|
|
38
|
+
"transform",
|
|
39
|
+
"load",
|
|
40
|
+
"resolveId",
|
|
41
|
+
"writeBundle"
|
|
42
|
+
];
|
|
19
43
|
|
|
20
44
|
// src/plugin-utils/helpers.ts
|
|
21
45
|
function isPlugin(value) {
|
|
22
|
-
return isSetObject(value) && "name" in value && isSetString(value.name) && (isUndefined(value.applyToEnvironment) || "applyToEnvironment" in value && isFunction(value.applyToEnvironment)) && (isUndefined(value.dedupe) || "dedupe" in value && isFunction(value.dedupe)) &&
|
|
46
|
+
return isSetObject(value) && "name" in value && isSetString(value.name) && (isUndefined(value.api) || "api" in value && isSetObject(value.api)) && (isUndefined(value.applyToEnvironment) || "applyToEnvironment" in value && isFunction(value.applyToEnvironment)) && (isUndefined(value.dedupe) || "dedupe" in value && isFunction(value.dedupe)) && KNOWN_HOOKS.every((hook) => isUndefined(value[hook]) || hook in value && (isPluginHookFunction(value[hook]) || hook === "config" && isSetObject(value[hook]))) && UNPLUGIN_BUILD_VARIANTS.every((variant) => isUndefined(value[variant]) || variant in value && isSetObject(value[variant]));
|
|
23
47
|
}
|
|
24
48
|
__name(isPlugin, "isPlugin");
|
|
25
49
|
function isPluginConfigObject(value) {
|
|
@@ -31,17 +55,17 @@ function isPluginConfigTuple(value) {
|
|
|
31
55
|
}
|
|
32
56
|
__name(isPluginConfigTuple, "isPluginConfigTuple");
|
|
33
57
|
function isPluginConfig(value) {
|
|
34
|
-
return isSetString(value) || isFunction(value) || isPlugin(value) || Array.isArray(value) && value.every((item) =>
|
|
58
|
+
return isSetString(value) || isFunction(value) || isPlugin(value) || isPluginConfigObject(value) || isPluginConfigTuple(value) || Array.isArray(value) && value.every((item) => isPluginConfig(item));
|
|
35
59
|
}
|
|
36
60
|
__name(isPluginConfig, "isPluginConfig");
|
|
37
|
-
function isPluginHookFunction(value) {
|
|
38
|
-
return isFunction(value) || isSetObject(value) && "handler" in value && isFunction(value.handler);
|
|
39
|
-
}
|
|
40
|
-
__name(isPluginHookFunction, "isPluginHookFunction");
|
|
41
61
|
function isPluginHookObject(value) {
|
|
42
62
|
return isSetObject(value) && "handler" in value && isFunction(value.handler);
|
|
43
63
|
}
|
|
44
64
|
__name(isPluginHookObject, "isPluginHookObject");
|
|
65
|
+
function isPluginHookFunction(value) {
|
|
66
|
+
return isFunction(value) || isPluginHookObject(value);
|
|
67
|
+
}
|
|
68
|
+
__name(isPluginHookFunction, "isPluginHookFunction");
|
|
45
69
|
function isPluginHook(value) {
|
|
46
70
|
return isPluginHookFunction(value) || isPluginHookObject(value);
|
|
47
71
|
}
|
|
@@ -87,7 +111,26 @@ function addPluginHook(context, plugin, pluginHook, hooksList) {
|
|
|
87
111
|
}
|
|
88
112
|
}
|
|
89
113
|
__name(addPluginHook, "addPluginHook");
|
|
114
|
+
function findInvalidPluginConfig(config) {
|
|
115
|
+
if (isPluginConfig(config)) {
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
if (Array.isArray(config)) {
|
|
119
|
+
const invalidItems = [];
|
|
120
|
+
config.forEach((item) => {
|
|
121
|
+
const invalid = findInvalidPluginConfig(item);
|
|
122
|
+
if (invalid) {
|
|
123
|
+
invalidItems.push(...invalid.map((i) => JSON.stringify(i, null, 2)));
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
return invalidItems.length > 0 ? invalidItems : null;
|
|
127
|
+
}
|
|
128
|
+
return [
|
|
129
|
+
JSON.stringify(config, null, 2)
|
|
130
|
+
];
|
|
131
|
+
}
|
|
132
|
+
__name(findInvalidPluginConfig, "findInvalidPluginConfig");
|
|
90
133
|
|
|
91
|
-
export { addPluginHook, checkDedupe, extractPluginHook, getHookHandler, isHookExternal, isHookInternal, isPlugin, isPluginConfig, isPluginConfigObject, isPluginConfigTuple, isPluginHook, isPluginHookFunction, isPluginHookObject };
|
|
92
|
-
//# sourceMappingURL=chunk-
|
|
93
|
-
//# sourceMappingURL=chunk-
|
|
134
|
+
export { addPluginHook, checkDedupe, extractPluginHook, findInvalidPluginConfig, getHookHandler, isHookExternal, isHookInternal, isPlugin, isPluginConfig, isPluginConfigObject, isPluginConfigTuple, isPluginHook, isPluginHookFunction, isPluginHookObject };
|
|
135
|
+
//# sourceMappingURL=chunk-FTVPZZJO.js.map
|
|
136
|
+
//# sourceMappingURL=chunk-FTVPZZJO.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/types/build.ts","../../src/types/commands.ts","../../src/types/plugin.ts","../../src/plugin-utils/helpers.ts"],"names":["UNPLUGIN_BUILD_VARIANTS","SUPPORTED_COMMANDS","KNOWN_HOOKS","isPlugin","value","isSetObject","isSetString","name","isUndefined","api","applyToEnvironment","isFunction","dedupe","every","hook","isPluginHookFunction","variant","isPluginConfigObject","plugin","options","isPluginConfigTuple","Array","isArray","length","isPluginConfig","item","isPluginHookObject","handler","isPluginHook","getHookHandler","pluginHook","extractPluginHook","context","undefined","normal","bind","order","isHookExternal","startsWith","isHookInternal","checkDedupe","plugins","some","p","addPluginHook","hooksList","map","push","findInvalidPluginConfig","config","invalidItems","forEach","invalid","i","JSON","stringify"],"mappings":";;;;;;;AA6CO,IAAMA,uBAAAA,GAAkD;AAC7D,EAAA,QAAA;AACA,EAAA,SAAA;AACA,EAAA,QAAA;AACA,EAAA,MAAA;AACA,EAAA,SAAA;AACA,EAAA,MAAA;AACA,EAAA,UAAA;AACA,EAAA;;;;AC/BK,IAAMC,kBAAAA,GAAqB;AAChC,EAAA,KAAA;AACA,EAAA,OAAA;AACA,EAAA,SAAA;AACA,EAAA,MAAA;AACA,EAAA,MAAA;AACA,EAAA,OAAA;AACA,EAAA,MAAA;AACA,EAAA,QAAA;AACA,EAAA;;AC0XK,IAAMC,WAAAA,GAAc;AACtBD,EAAAA,GAAAA,kBAAAA;AACH,EAAA,QAAA;AACA,EAAA,mBAAA;AACA,EAAA,gBAAA;AACA,EAAA,YAAA;AACA,EAAA,UAAA;AACA,EAAA,WAAA;AACA,EAAA,MAAA;AACA,EAAA,WAAA;AACA,EAAA;;;;ACjXK,SAASE,SAEdC,KAAAA,EAAc;AACd,EAAA,OACEC,YAA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,OAAAA;KAC3C,GACA;AACEd,MAAAA,MAAAA;MACA,GAAGY,UAAAA;AACHH,MAAAA,OAAAA,EAASE,cAAAA,CAAeC,UAAAA,CAAAA,CAAYK,IAAAA,CAAKH,OAAAA;KAC3C,CAAA;AAER,EAAA;AACF;AAzBgBY,MAAAA,CAAAA,aAAAA,EAAAA,eAAAA,CAAAA;AAiCT,SAASI,wBAEdC,MAAAA,EAA8B;AAC9B,EAAA,IAAIzB,cAAAA,CAAyByB,MAAAA,CAAAA,EAAS;AACpC,IAAA,OAAO,IAAA;AACT,EAAA;AAEA,EAAA,IAAI5B,KAAAA,CAAMC,OAAAA,CAAQ2B,MAAAA,CAAAA,EAAqC;AACrD,IAAA,MAAMC,eAAyB,EAAA;AAC9BD,IAAAA,MAAAA,CAAoCE,OAAAA,CAAQ1B,CAAAA,IAAAA,KAAAA;AAC3C,MAAA,MAAM2B,OAAAA,GAAUJ,wBAAkCvB,IAAAA,CAAAA;AAClD,MAAA,IAAI2B,OAAAA,EAAS;AACXF,QAAAA,YAAAA,CAAaH,IAAAA,CAAI,GAAIK,OAAAA,CAAQN,GAAAA,CAAIO,CAAAA,CAAAA,KAAKC,IAAAA,CAAKC,SAAAA,CAAUF,CAAAA,EAAG,IAAA,EAAM,CAAA,CAAA,CAAA,CAAA;AAChE,MAAA;IACF,CAAA,CAAA;AAEA,IAAA,OAAOH,YAAAA,CAAa3B,MAAAA,GAAS,CAAA,GAAI2B,YAAAA,GAAe,IAAA;AAClD,EAAA;AAEA,EAAA,OAAO;IAACI,IAAAA,CAAKC,SAAAA,CAAUN,MAAAA,EAAQ,IAAA,EAAM,CAAA;;AACvC;AApBgBD,MAAAA,CAAAA,uBAAAA,EAAAA,yBAAAA,CAAAA","file":"chunk-FTVPZZJO.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 type { UserConfig as ExternalFarmOptions } from \"@farmfe/core\";\nimport type { Configuration as ExternalRspackOptions } from \"@rspack/core\";\nimport type { BuildOptions as ExternalTsupOptions } from \"@storm-software/tsup/types\";\nimport type { UnbuildOptions as ExternalUnbuildOptions } from \"@storm-software/unbuild/types\";\nimport type { BuildOptions as ExternalESBuildOptions } from \"esbuild\";\nimport type { RolldownOptions as ExternalRolldownOptions } from \"rolldown\";\nimport type {\n RollupOptions as ExternalRollupOptions,\n OutputOptions as ExternalRollupOutputOptions\n} from \"rollup\";\nimport type { UserConfig as ExternalTsdownOptions } from \"tsdown\";\nimport type {\n DepOptimizationOptions,\n UserConfig as ExternalViteUserConfig\n} from \"vite\";\nimport type { Configuration as ExternalWebpackOptions } from \"webpack\";\n\nexport type UnpluginBuildVariant =\n | \"rollup\"\n | \"webpack\"\n | \"rspack\"\n | \"vite\"\n | \"esbuild\"\n | \"farm\"\n | \"unloader\"\n | \"rolldown\";\n\nexport const UNPLUGIN_BUILD_VARIANTS: UnpluginBuildVariant[] = [\n \"rollup\",\n \"webpack\",\n \"rspack\",\n \"vite\",\n \"esbuild\",\n \"farm\",\n \"unloader\",\n \"rolldown\"\n];\n\nexport type BuildVariant = UnpluginBuildVariant | \"tsup\" | \"tsdown\" | \"unbuild\";\n\nexport type InferUnpluginVariant<TBuildVariant extends BuildVariant> =\n TBuildVariant extends \"tsup\"\n ? \"esbuild\"\n : TBuildVariant extends \"tsdown\"\n ? \"rolldown\"\n : TBuildVariant extends \"unbuild\"\n ? \"rollup\"\n : TBuildVariant;\n\nexport interface BuildConfig {\n /**\n * The platform to build the project for\n *\n * @defaultValue \"neutral\"\n */\n platform?: \"node\" | \"browser\" | \"neutral\";\n\n /**\n * Array of strings indicating the polyfills to include for the build.\n *\n * @remarks\n * This option allows you to specify which polyfills should be included in the build process to ensure compatibility with the target environment. The paths for the polyfills can use placeholder tokens (the `replacePathTokens` helper function will be used to resolve the actual values).\n *\n * @example\n * ```ts\n * {\n * polyfill: ['{projectRoot}/custom-polyfill.ts']\n * }\n * ```\n */\n polyfill?: string[];\n\n /**\n * Array of strings indicating the order in which fields in a package.json file should be resolved to determine the entry point for a module.\n *\n * @defaultValue `['browser', 'module', 'jsnext:main', 'jsnext']`\n */\n mainFields?: string[];\n\n /**\n * Array of strings indicating what conditions should be used for module resolution.\n */\n conditions?: string[];\n\n /**\n * Array of strings indicating what file extensions should be used for module resolution.\n *\n * @defaultValue `['.mjs', '.js', '.mts', '.ts', '.jsx', '.tsx', '.json']`\n */\n extensions?: string[];\n\n /**\n * Array of strings indicating what modules should be deduplicated to a single version in the build.\n *\n * @remarks\n * This option is useful for ensuring that only one version of a module is included in the bundle, which can help reduce bundle size and avoid conflicts.\n */\n dedupe?: string[];\n\n /**\n * Array of strings or regular expressions that indicate what modules are builtin for the environment.\n */\n builtins?: (string | RegExp)[];\n\n /**\n * Define global variable replacements.\n *\n * @remarks\n * This option allows you to specify global constants that will be replaced in the code during the build process. It is similar to the `define` option in esbuild and Vite, enabling you to replace specific identifiers with constant expressions at build time.\n *\n * @example\n * ```ts\n * {\n * define: {\n * __VERSION__: '\"1.0.0\"',\n * __DEV__: 'process.env.NODE_ENV !== \"production\"'\n * }\n * }\n * ```\n *\n * @see https://esbuild.github.io/api/#define\n * @see https://vitejs.dev/config/build-options.html#define\n * @see https://github.com/rollup/plugins/tree/master/packages/replace\n */\n define?: Record<string, any>;\n\n /**\n * Global variables that will have import statements injected where necessary\n *\n * @remarks\n * This option allows you to specify global variables that should be automatically imported from specified modules whenever they are used in the code. This is particularly useful for polyfilling Node.js globals in a browser environment.\n *\n * @example\n * ```ts\n * {\n * inject: {\n * process: 'process/browser',\n * Buffer: ['buffer', 'Buffer'],\n * }\n * }\n * ```\n *\n * @see https://github.com/rollup/plugins/tree/master/packages/inject\n */\n inject?: Record<string, string | string[]>;\n\n /**\n * The alias mappings to use for module resolution during the build process.\n *\n * @remarks\n * This option allows you to define custom path aliases for modules, which can be useful for simplifying imports and managing dependencies.\n *\n * @example\n * ```ts\n * {\n * alias: {\n * \"@utils\": \"./src/utils\",\n * \"@components\": \"./src/components\"\n * }\n * }\n * ```\n *\n * @see https://github.com/rollup/plugins/tree/master/packages/alias\n */\n alias?:\n | Record<string, string>\n | Array<{\n find: string | RegExp;\n replacement: string;\n }>;\n\n /**\n * A list of modules that should not be bundled, even if they are external dependencies.\n *\n * @remarks\n * This option is useful for excluding specific modules from the bundle, such as Node.js built-in modules or other libraries that should not be bundled.\n */\n external?: (string | RegExp)[];\n\n /**\n * A list of modules that should always be bundled, even if they are external dependencies.\n */\n noExternal?: (string | RegExp)[];\n\n /**\n * Should the Powerlines CLI processes skip bundling the `node_modules` directory?\n */\n skipNodeModulesBundle?: boolean;\n\n /**\n * If true, `process.env` referenced in code will be preserved as-is and evaluated in runtime. Otherwise, it is statically replaced as an empty object.\n *\n * @defaultValue false\n */\n keepProcessEnv?: boolean;\n\n /**\n * An optional set of override options to apply to the selected build variant.\n *\n * @remarks\n * This option allows you to provide configuration options with the guarantee that they will **not** be overridden and will take precedence over other build configurations.\n */\n override?: Record<string, any>;\n}\n\nexport type BuildResolvedConfig = Omit<BuildConfig, \"override\">;\n\n// ESBuild\nexport type ESBuildBuildConfig = Omit<\n ExternalESBuildOptions,\n | \"entryPoints\"\n | \"sourceRoot\"\n | \"platform\"\n | \"outdir\"\n | \"env\"\n | \"assets\"\n | \"external\"\n | \"inject\"\n | \"tsconfig\"\n | \"tsconfigRaw\"\n | \"logLevel\"\n> &\n BuildConfig;\nexport type ESBuildResolvedBuildConfig = Omit<\n ExternalESBuildOptions,\n \"inject\"\n> &\n BuildResolvedConfig;\n\n// Vite\nexport type ViteBuildConfig = Omit<\n ExternalViteUserConfig,\n | \"entry\"\n | \"entryPoints\"\n | \"tsconfig\"\n | \"tsconfigRaw\"\n | \"environments\"\n | \"output\"\n> &\n BuildConfig & {\n /**\n * Optimize deps config\n */\n optimizeDeps?: Omit<DepOptimizationOptions, \"extensions\">;\n };\nexport type ViteResolvedBuildConfig = ExternalViteUserConfig &\n BuildResolvedConfig;\n\n// Webpack\nexport type WebpackBuildConfig = Omit<\n ExternalWebpackOptions,\n \"name\" | \"entry\" | \"entryPoints\" | \"tsconfig\" | \"tsconfigRaw\"\n> &\n BuildConfig;\nexport type WebpackResolvedBuildConfig = ExternalWebpackOptions &\n BuildResolvedConfig;\n\n// Rspack\nexport type RspackBuildConfig = Omit<\n ExternalRspackOptions,\n \"name\" | \"entry\" | \"entryPoints\" | \"tsconfig\" | \"tsconfigRaw\"\n> &\n BuildConfig;\nexport type RspackResolvedBuildConfig = ExternalRspackOptions &\n BuildResolvedConfig;\n\n// Rollup\nexport type RollupBuildOutputConfig = Omit<\n ExternalRollupOutputOptions,\n \"dir\" | \"format\"\n>;\nexport type RollupBuildConfig = Omit<\n ExternalRollupOptions,\n \"entry\" | \"external\" | \"input\" | \"output\" | \"logLevel\"\n> & {\n output: RollupBuildOutputConfig | RollupBuildOutputConfig[];\n} & BuildConfig;\nexport type RollupResolvedBuildConfig = ExternalRollupOptions &\n BuildResolvedConfig;\n\n// Rolldown\nexport type RolldownBuildConfig = Omit<\n ExternalRolldownOptions,\n \"input\" | \"external\" | \"tsconfig\" | \"logLevel\" | \"output\"\n> &\n BuildConfig;\nexport type RolldownResolvedBuildConfig = ExternalRolldownOptions &\n BuildResolvedConfig;\n\n// Tsup\nexport type TsupBuildConfig = Partial<\n Omit<\n ExternalTsupOptions,\n | \"userOptions\"\n | \"tsconfig\"\n | \"tsconfigRaw\"\n | \"assets\"\n | \"outputPath\"\n | \"mode\"\n | \"format\"\n | \"platform\"\n | \"projectRoot\"\n | \"clean\"\n | \"env\"\n | \"entry\"\n | \"entryPoints\"\n | \"external\"\n | \"noExternal\"\n | \"skipNodeModulesBundle\"\n >\n> &\n BuildConfig;\nexport type TsupResolvedBuildConfig = ExternalTsupOptions & BuildResolvedConfig;\n\n// Tsdown\nexport type TsdownBuildConfig = Partial<\n Omit<\n ExternalTsdownOptions,\n | \"name\"\n | \"outDir\"\n | \"clean\"\n | \"cwd\"\n | \"tsconfig\"\n | \"publicDir\"\n | \"copy\"\n | \"alias\"\n | \"format\"\n | \"platform\"\n | \"env\"\n | \"define\"\n | \"entry\"\n | \"external\"\n | \"noExternal\"\n | \"skipNodeModulesBundle\"\n >\n> &\n BuildConfig;\nexport type TsdownResolvedBuildConfig = ExternalTsdownOptions &\n BuildResolvedConfig;\n\n// Unbuild\nexport type UnbuildBuildConfig = Partial<\n Omit<\n ExternalUnbuildOptions,\n | \"tsconfig\"\n | \"tsconfigRaw\"\n | \"assets\"\n | \"outputPath\"\n | \"mode\"\n | \"format\"\n | \"platform\"\n | \"projectRoot\"\n | \"env\"\n | \"entry\"\n | \"entryPoints\"\n >\n> &\n BuildConfig;\nexport type UnbuildResolvedBuildConfig = ExternalUnbuildOptions &\n BuildResolvedConfig;\n\n// Farm\nexport type FarmBuildConfig = Partial<\n Omit<\n ExternalFarmOptions,\n | \"tsconfig\"\n | \"tsconfigRaw\"\n | \"assets\"\n | \"outputPath\"\n | \"mode\"\n | \"format\"\n | \"platform\"\n | \"projectRoot\"\n | \"env\"\n | \"entry\"\n | \"entryPoints\"\n >\n> &\n BuildConfig;\nexport type FarmResolvedBuildConfig = ExternalFarmOptions & BuildResolvedConfig;\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 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 { UNPLUGIN_BUILD_VARIANTS } from \"./build\";\nimport type { CommandType } from \"./commands\";\nimport { SUPPORTED_COMMANDS } 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.\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 TContext extends PluginContext<ResolvedConfig> = 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<TContext>[];\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<TContext>;\n}\n\nexport const PLUGIN_NON_HOOK_FIELDS = [\n \"name\",\n \"api\",\n \"enforce\",\n \"dedupe\",\n \"applyToEnvironment\"\n] as const;\n\nexport type PluginNonHookFields =\n | ArrayValues<typeof PLUGIN_NON_HOOK_FIELDS>\n | UnpluginBuildVariant;\n\nexport const KNOWN_HOOKS = [\n ...SUPPORTED_COMMANDS,\n \"config\",\n \"configEnvironment\",\n \"configResolved\",\n \"buildStart\",\n \"buildEnd\",\n \"transform\",\n \"load\",\n \"resolveId\",\n \"writeBundle\"\n] as const;\n\nexport type KnownHooks = ArrayValues<typeof KNOWN_HOOKS>;\n\nexport const KNOWN_PLUGIN_FIELDS = [\n ...PLUGIN_NON_HOOK_FIELDS,\n ...KNOWN_HOOKS,\n ...UNPLUGIN_BUILD_VARIANTS\n] as const;\n\nexport type KnownPluginFields = ArrayValues<typeof KNOWN_PLUGIN_FIELDS>;\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 { UNPLUGIN_BUILD_VARIANTS } from \"../types/build\";\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 {\n KNOWN_HOOKS,\n Plugin,\n PluginHook,\n PluginHookObject\n} 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 TContext extends PluginContext = PluginContext<ResolvedConfig>\n>(value: unknown): value is Plugin<TContext> {\n return (\n isSetObject(value) &&\n \"name\" in value &&\n isSetString(value.name) &&\n (isUndefined((value as Plugin<TContext>).api) ||\n (\"api\" in value && isSetObject(value.api))) &&\n (isUndefined((value as Plugin<TContext>).applyToEnvironment) ||\n (\"applyToEnvironment\" in value &&\n isFunction(value.applyToEnvironment))) &&\n (isUndefined((value as Plugin<TContext>).dedupe) ||\n (\"dedupe\" in value && isFunction(value.dedupe))) &&\n KNOWN_HOOKS.every(\n hook =>\n isUndefined((value as Plugin<TContext>)[hook]) ||\n (hook in value &&\n (isPluginHookFunction((value as Plugin<TContext>)[hook]) ||\n (hook === \"config\" &&\n isSetObject((value as Plugin<TContext>)[hook]))))\n ) &&\n UNPLUGIN_BUILD_VARIANTS.every(\n variant =>\n isUndefined((value as Plugin<TContext>)[variant]) ||\n (variant in value && isSetObject((value as Plugin<TContext>)[variant]))\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<\n TContext extends PluginContext = PluginContext<ResolvedConfig>\n>(value: unknown): value is PluginConfig<TContext> {\n return (\n isSetString(value) ||\n isFunction(value) ||\n isPlugin<TContext>(value) ||\n isPluginConfigObject(value) ||\n isPluginConfigTuple(value) ||\n (Array.isArray(value) && value.every(item => isPluginConfig(item)))\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 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 isFunction(value) || isPluginHookObject(value);\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 * Check the provided {@link PluginConfig}, and return a stringified version of the invalid configuration. If an array is provided, check each item in the array.\n *\n * @param config - The plugin configuration to check\n * @returns Null if the configuration is valid, otherwise an array of stringified invalid configurations\n */\nexport function findInvalidPluginConfig<\n TContext extends PluginContext = PluginContext<ResolvedConfig>\n>(config: PluginConfig<TContext>): string[] | null {\n if (isPluginConfig<TContext>(config)) {\n return null;\n }\n\n if (Array.isArray(config as PluginConfig<TContext>[])) {\n const invalidItems: string[] = [];\n (config as PluginConfig<TContext>[]).forEach(item => {\n const invalid = findInvalidPluginConfig<TContext>(item);\n if (invalid) {\n invalidItems.push(...invalid.map(i => JSON.stringify(i, null, 2)));\n }\n });\n\n return invalidItems.length > 0 ? invalidItems : null;\n }\n\n return [JSON.stringify(config, null, 2)];\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkAHZPK4Z5_cjs = require('./chunk-AHZPK4Z5.cjs');
|
|
4
4
|
var chunkPK6SKIKE_cjs = require('./chunk-PK6SKIKE.cjs');
|
|
5
5
|
var toArray = require('@stryke/convert/to-array');
|
|
6
6
|
var isFunction = require('@stryke/type-checks/is-function');
|
|
@@ -16,12 +16,12 @@ async function enforceBuild(plugin, variant) {
|
|
|
16
16
|
}
|
|
17
17
|
};
|
|
18
18
|
if (isFunction.isFunction(plugin)) {
|
|
19
|
-
return
|
|
19
|
+
return chunkAHZPK4Z5_cjs.extend(plugin, extension);
|
|
20
20
|
}
|
|
21
|
-
return
|
|
21
|
+
return chunkAHZPK4Z5_cjs.extend(plugin, () => extension)({});
|
|
22
22
|
}
|
|
23
23
|
chunkPK6SKIKE_cjs.__name(enforceBuild, "enforceBuild");
|
|
24
24
|
|
|
25
25
|
exports.enforceBuild = enforceBuild;
|
|
26
|
-
//# sourceMappingURL=chunk-
|
|
27
|
-
//# sourceMappingURL=chunk-
|
|
26
|
+
//# sourceMappingURL=chunk-JAG7QJDV.cjs.map
|
|
27
|
+
//# sourceMappingURL=chunk-JAG7QJDV.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/plugin-utils/enforce.ts"],"names":["enforceBuild","plugin","variant","extension","configResolved","allowedVariants","toArray","currentVariant","config","build","includes","Error","Array","isArray","map","v","slice","join","isFunction","extend"],"mappings":";;;;;;;AA+CA,eAAsBA,YAAAA,CAIpBC,QACAC,OAAAA,EAAwC;AAExC,EAAA,MAAMC,SAAAA,GAAY;IAChBC,cAAAA,GAAAA;AACE,MAAA,MAAMC,eAAAA,GAAkBC,gBAAuBJ,OAAAA,CAAAA;AAC/C,MAAA,MAAMK,cAAAA,GAAiB,IAAA,CAAKC,MAAAA,EAAQC,KAAAA,EAAOP,OAAAA;AAI3C,MAAA,IAAI,CAACK,cAAAA,IAAkB,CAACF,eAAAA,CAAgBK,QAAAA,CAASH,cAAAA,CAAAA,EAAiB;AAChE,QAAA,MAAM,IAAII,MACR,CAAA,oBAAA,EACEC,KAAAA,CAAMC,QAAQX,OAAAA,CAAAA,GACV,sBAAsBA,OAAAA,CACnBY,GAAAA,CAAIC,CAAAA,CAAAA,KAAK,CAAA,CAAA,EAAIA,CAAAA,CAAAA,CAAAA,CAAI,CAAA,CACjBC,MAAM,CAAA,EAAG,EAAC,EACVC,IAAAA,CAAK,IAAA,CAAA,CAAA,KAAA,EAAaf,OAAAA,CAClBY,IAAIC,CAAAA,CAAAA,KAAK,IAAIA,CAAAA,CAAAA,CAAAA,CAAI,EACjBC,KAAAA,CAAM,EAAC,EACPC,IAAAA,CAAK,EAAA,CAAA,CAAA,CAAA,GACR,CAAA,mBAAA,EAAsBf,OAAAA,CAAAA,CAAAA,CAAU,CAAA,gBAAA,EAEpCK,cAAAA,IAAkB,WAAA,CAAA,8EAAA,CAC4D,CAAA;AAEpF,MAAA;AACF,IAAA;AACF,GAAA;AAIA,EAAA,IAAIW,qBAAAA,CAAWjB,MAAAA,CAAAA,EAAS;AACtB,IAAA,OAAOkB,wBAAAA,CAAOlB,QAAQE,SAAAA,CAAAA;AACxB,EAAA;AAEA,EAAA,OAAOgB,yBAAOlB,MAAAA,EAAQ,MAAME,SAAAA,CAAAA,CAAW,EAAC,CAAA;AAC1C;AAzCsBH,wBAAAA,CAAAA,YAAAA,EAAAA,cAAAA,CAAAA","file":"chunk-
|
|
1
|
+
{"version":3,"sources":["../../src/plugin-utils/enforce.ts"],"names":["enforceBuild","plugin","variant","extension","configResolved","allowedVariants","toArray","currentVariant","config","build","includes","Error","Array","isArray","map","v","slice","join","isFunction","extend"],"mappings":";;;;;;;AA+CA,eAAsBA,YAAAA,CAIpBC,QACAC,OAAAA,EAAwC;AAExC,EAAA,MAAMC,SAAAA,GAAY;IAChBC,cAAAA,GAAAA;AACE,MAAA,MAAMC,eAAAA,GAAkBC,gBAAuBJ,OAAAA,CAAAA;AAC/C,MAAA,MAAMK,cAAAA,GAAiB,IAAA,CAAKC,MAAAA,EAAQC,KAAAA,EAAOP,OAAAA;AAI3C,MAAA,IAAI,CAACK,cAAAA,IAAkB,CAACF,eAAAA,CAAgBK,QAAAA,CAASH,cAAAA,CAAAA,EAAiB;AAChE,QAAA,MAAM,IAAII,MACR,CAAA,oBAAA,EACEC,KAAAA,CAAMC,QAAQX,OAAAA,CAAAA,GACV,sBAAsBA,OAAAA,CACnBY,GAAAA,CAAIC,CAAAA,CAAAA,KAAK,CAAA,CAAA,EAAIA,CAAAA,CAAAA,CAAAA,CAAI,CAAA,CACjBC,MAAM,CAAA,EAAG,EAAC,EACVC,IAAAA,CAAK,IAAA,CAAA,CAAA,KAAA,EAAaf,OAAAA,CAClBY,IAAIC,CAAAA,CAAAA,KAAK,IAAIA,CAAAA,CAAAA,CAAAA,CAAI,EACjBC,KAAAA,CAAM,EAAC,EACPC,IAAAA,CAAK,EAAA,CAAA,CAAA,CAAA,GACR,CAAA,mBAAA,EAAsBf,OAAAA,CAAAA,CAAAA,CAAU,CAAA,gBAAA,EAEpCK,cAAAA,IAAkB,WAAA,CAAA,8EAAA,CAC4D,CAAA;AAEpF,MAAA;AACF,IAAA;AACF,GAAA;AAIA,EAAA,IAAIW,qBAAAA,CAAWjB,MAAAA,CAAAA,EAAS;AACtB,IAAA,OAAOkB,wBAAAA,CAAOlB,QAAQE,SAAAA,CAAAA;AACxB,EAAA;AAEA,EAAA,OAAOgB,yBAAOlB,MAAAA,EAAQ,MAAME,SAAAA,CAAAA,CAAW,EAAC,CAAA;AAC1C;AAzCsBH,wBAAAA,CAAAA,YAAAA,EAAAA,cAAAA,CAAAA","file":"chunk-JAG7QJDV.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 { toArray } from \"@stryke/convert/to-array\";\nimport { isFunction } from \"@stryke/type-checks/is-function\";\nimport { BuildVariant } from \"../types/build\";\nimport { PartialPlugin, PluginFactory } from \"../types/config\";\nimport { PluginContext } from \"../types/context\";\nimport { Plugin } from \"../types/plugin\";\nimport { extend } from \"./extend\";\n\n/**\n * Enforces a specific build variant for a plugin.\n *\n * @param plugin - The plugin or plugin factory to enforce the build variant on.\n * @param variant - The build variant to enforce.\n * @returns A new plugin or plugin factory that enforces the specified build variant.\n */\nexport function enforceBuild<\n TContext extends PluginContext = PluginContext,\n TBuildVariant extends BuildVariant = BuildVariant\n>(\n plugin: Plugin<TContext> | Plugin<TContext>[],\n variant: TBuildVariant | TBuildVariant[]\n): Promise<Plugin<TContext>[]>;\nexport function enforceBuild<\n TContext extends PluginContext = PluginContext,\n TBuildVariant extends BuildVariant = BuildVariant\n>(\n plugin: PluginFactory<TContext>,\n variant: TBuildVariant | TBuildVariant[]\n): Promise<PluginFactory<TContext>>;\nexport async function enforceBuild<\n TContext extends PluginContext = PluginContext,\n TBuildVariant extends BuildVariant = BuildVariant\n>(\n plugin: Plugin<TContext> | Plugin<TContext>[] | PluginFactory<TContext>,\n variant: TBuildVariant | TBuildVariant[]\n) {\n const extension = {\n configResolved(this: TContext) {\n const allowedVariants = toArray<TBuildVariant>(variant);\n const currentVariant = this.config?.build?.variant as\n | TBuildVariant\n | undefined;\n\n if (!currentVariant || !allowedVariants.includes(currentVariant)) {\n throw new Error(\n `The plugin requires ${\n Array.isArray(variant)\n ? `the build variants ${variant\n .map(v => `\"${v}\"`)\n .slice(0, -1)\n .join(\", \")}, or ${variant\n .map(v => `\"${v}\"`)\n .slice(-1)\n .join(\"\")}`\n : `the build variant \"${variant}\"`\n }, but received \"${\n currentVariant ?? \"undefined\"\n }\". Please ensure the \\`build.variant\\` is set correctly in your configuration.`\n );\n }\n }\n } as PartialPlugin<TContext>;\n\n // The `extend` function has different overloads for plugin factories vs concrete\n // plugins - narrow here so TypeScript can select the correct overload.\n if (isFunction(plugin)) {\n return extend(plugin, extension);\n }\n\n return extend(plugin, () => extension)({});\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isPluginHook, getHookHandler } from './chunk-
|
|
1
|
+
import { isPluginHook, getHookHandler } from './chunk-FTVPZZJO.js';
|
|
2
2
|
import { __name } from './chunk-7QVYU63E.js';
|
|
3
3
|
import defu, { createDefu } from 'defu';
|
|
4
4
|
|
|
@@ -25,5 +25,5 @@ function merge(pluginA, pluginB) {
|
|
|
25
25
|
__name(merge, "merge");
|
|
26
26
|
|
|
27
27
|
export { merge };
|
|
28
|
-
//# sourceMappingURL=chunk-
|
|
29
|
-
//# sourceMappingURL=chunk-
|
|
28
|
+
//# sourceMappingURL=chunk-JCX2UJYO.js.map
|
|
29
|
+
//# sourceMappingURL=chunk-JCX2UJYO.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/plugin-utils/merge.ts"],"names":["mergePlugin","createDefu","obj","key","value","isPluginHook","handler","params","resultA","resultB","Promise","all","getHookHandler","defu","merge","pluginA","pluginB"],"mappings":";;;;AAmCA,IAAMA,WAAAA,GAAcC,UAAAA,CAAW,CAACC,GAAAA,EAAKC,KAAKC,KAAAA,KAAAA;AACxC,EAAA,IAAIC,aAAaH,GAAAA,CAAIC,GAAAA,CAAI,CAAA,IAAKE,YAAAA,CAAaD,KAAAA,CAAAA,EAAQ;AACjDF,IAAAA,GAAAA,CAAIC,GAAAA,CAAAA,GAAO;AACT,MAAA,GAAGD,IAAIC,GAAAA,CAAAA;MACP,GAAGC,KAAAA;AACHE,MAAAA,OAAAA,mCAAmBC,MAAAA,KAAAA;AACjB,QAAA,MAAM,CAACC,OAAAA,EAASC,OAAAA,CAAAA,GAAW,MAAMC,QAAQC,GAAAA,CAAI;AAC3CC,UAAAA,cAAAA,CAAeV,GAAAA,CAAIC,GAAAA,CAAI,CAAA,CAAA,GAAKI,MAAAA,CAAAA;UAC5BK,cAAAA,CAAeR,KAAAA,CAAAA,CAAAA,GAAUG,MAAAA;AAC1B,SAAA,CAAA;AAED,QAAA,OAAOE,WAAWD,OAAAA,GAAUK,IAAAA,CAAKL,OAAAA,EAASC,OAAAA,IAAWD,OAAAA,IAAWC,OAAAA;MAClE,CAAA,EAPS,SAAA;AAQX,KAAA;AACA,IAAA,OAAO,IAAA;AACT,EAAA;AAEA,EAAA,OAAO,KAAA;AACT,CAAA,CAAA;AASO,SAASK,KAAAA,CACdC,SACAC,OAAAA,EAAmD;AAEnD,EAAA,OAAOhB,WAAAA,CAAYe,SAASC,OAAAA,CAAAA;AAK9B;AATgBF,MAAAA,CAAAA,KAAAA,EAAAA,OAAAA,CAAAA","file":"chunk-
|
|
1
|
+
{"version":3,"sources":["../../src/plugin-utils/merge.ts"],"names":["mergePlugin","createDefu","obj","key","value","isPluginHook","handler","params","resultA","resultB","Promise","all","getHookHandler","defu","merge","pluginA","pluginB"],"mappings":";;;;AAmCA,IAAMA,WAAAA,GAAcC,UAAAA,CAAW,CAACC,GAAAA,EAAKC,KAAKC,KAAAA,KAAAA;AACxC,EAAA,IAAIC,aAAaH,GAAAA,CAAIC,GAAAA,CAAI,CAAA,IAAKE,YAAAA,CAAaD,KAAAA,CAAAA,EAAQ;AACjDF,IAAAA,GAAAA,CAAIC,GAAAA,CAAAA,GAAO;AACT,MAAA,GAAGD,IAAIC,GAAAA,CAAAA;MACP,GAAGC,KAAAA;AACHE,MAAAA,OAAAA,mCAAmBC,MAAAA,KAAAA;AACjB,QAAA,MAAM,CAACC,OAAAA,EAASC,OAAAA,CAAAA,GAAW,MAAMC,QAAQC,GAAAA,CAAI;AAC3CC,UAAAA,cAAAA,CAAeV,GAAAA,CAAIC,GAAAA,CAAI,CAAA,CAAA,GAAKI,MAAAA,CAAAA;UAC5BK,cAAAA,CAAeR,KAAAA,CAAAA,CAAAA,GAAUG,MAAAA;AAC1B,SAAA,CAAA;AAED,QAAA,OAAOE,WAAWD,OAAAA,GAAUK,IAAAA,CAAKL,OAAAA,EAASC,OAAAA,IAAWD,OAAAA,IAAWC,OAAAA;MAClE,CAAA,EAPS,SAAA;AAQX,KAAA;AACA,IAAA,OAAO,IAAA;AACT,EAAA;AAEA,EAAA,OAAO,KAAA;AACT,CAAA,CAAA;AASO,SAASK,KAAAA,CACdC,SACAC,OAAAA,EAAmD;AAEnD,EAAA,OAAOhB,WAAAA,CAAYe,SAASC,OAAAA,CAAAA;AAK9B;AATgBF,MAAAA,CAAAA,KAAAA,EAAAA,OAAAA,CAAAA","file":"chunk-JCX2UJYO.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 defu, { createDefu } from \"defu\";\nimport { PartialPlugin } from \"../types/config\";\nimport { PluginContext } from \"../types/context\";\nimport { Plugin } from \"../types/plugin\";\nimport { getHookHandler, isPluginHook } from \"./helpers\";\n\nexport type MergeResult<\n TContext extends PluginContext,\n TPluginA extends Plugin<TContext> | PartialPlugin<TContext>,\n TPluginB extends Plugin<TContext> | PartialPlugin<TContext>\n> =\n TPluginA extends Plugin<TContext>\n ? Plugin<TContext>\n : TPluginB extends Plugin<TContext>\n ? Plugin<TContext>\n : PartialPlugin<TContext>;\n\nconst mergePlugin = createDefu((obj, key, value) => {\n if (isPluginHook(obj[key]) && isPluginHook(value)) {\n obj[key] = {\n ...obj[key],\n ...value,\n handler: async (...params: any[]) => {\n const [resultA, resultB] = await Promise.all([\n getHookHandler(obj[key])(...params),\n getHookHandler(value)(...params)\n ]);\n\n return resultB && resultA ? defu(resultA, resultB) : resultA || resultB;\n }\n };\n return true;\n }\n\n return false;\n});\n\n/**\n * Merges two {@link Plugin | plugins} or {@link PartialPlugin | partial plugins} together.\n *\n * @param pluginA - The first {@link Plugin | plugin} or {@link PartialPlugin | partial plugin} to merge.\n * @param pluginB - The second {@link Plugin | plugin} or {@link PartialPlugin | partial plugin} to merge.\n * @returns The merged {@link Plugin | plugin} or {@link PartialPlugin | partial plugin}.\n */\nexport function merge<TContext extends PluginContext = PluginContext>(\n pluginA: Plugin<TContext> | PartialPlugin<TContext>,\n pluginB: Plugin<TContext> | PartialPlugin<TContext>\n): MergeResult<TContext, typeof pluginA, typeof pluginB> {\n return mergePlugin(pluginA, pluginB) as MergeResult<\n TContext,\n typeof pluginA,\n typeof pluginB\n >;\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { merge } from './chunk-
|
|
1
|
+
import { merge } from './chunk-JCX2UJYO.js';
|
|
2
2
|
import { __name } from './chunk-7QVYU63E.js';
|
|
3
3
|
import { toArray } from '@stryke/convert/to-array';
|
|
4
4
|
import { isFunction } from '@stryke/type-checks/is-function';
|
|
@@ -27,5 +27,5 @@ function extend(plugin, extension) {
|
|
|
27
27
|
__name(extend, "extend");
|
|
28
28
|
|
|
29
29
|
export { extend };
|
|
30
|
-
//# sourceMappingURL=chunk-
|
|
31
|
-
//# sourceMappingURL=chunk-
|
|
30
|
+
//# sourceMappingURL=chunk-N4IXPCGY.js.map
|
|
31
|
+
//# sourceMappingURL=chunk-N4IXPCGY.js.map
|