powerlines 0.36.28 → 0.37.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (323) hide show
  1. package/dist/{context-DU4oqb6r.d.cts → api-CLQePK25.d.cts} +262 -127
  2. package/dist/{context-DmCNtNIs.d.ts → api-DClrDYWk.d.ts} +262 -127
  3. package/dist/api.cjs +4 -4
  4. package/dist/api.d.cts +7 -7
  5. package/dist/api.d.ts +7 -7
  6. package/dist/api.js +3 -3
  7. package/dist/astro.cjs +6 -6
  8. package/dist/astro.d.cts +6 -5
  9. package/dist/astro.d.ts +6 -5
  10. package/dist/astro.js +5 -5
  11. package/dist/{chunk-K4ZR45W7.cjs → chunk-2ZNVD64B.cjs} +4 -4
  12. package/dist/{chunk-7IDSUDJN.js → chunk-3JGCXWAM.js} +3 -3
  13. package/dist/chunk-42ZHOCZJ.cjs +14 -0
  14. package/dist/{chunk-PZZP3VX2.cjs → chunk-4PIVB3SY.cjs} +14 -9
  15. package/dist/{chunk-ZCMOAOQN.cjs → chunk-B6DVCLP5.cjs} +8 -7
  16. package/dist/chunk-CCJQBJKQ.js +12 -0
  17. package/dist/{chunk-VZMAJMBD.js → chunk-DVJEAUGP.js} +5 -5
  18. package/dist/{chunk-3CCAN6GY.cjs → chunk-E4QAO32M.cjs} +176 -128
  19. package/dist/chunk-FON7JDQF.cjs +12 -0
  20. package/dist/{chunk-NSHXFNIL.js → chunk-IBQ5USID.js} +12 -7
  21. package/dist/{chunk-TP4FRF4H.cjs → chunk-JQDMR7OP.cjs} +2 -2
  22. package/dist/{chunk-4VQBXIAH.js → chunk-MI5E6YZI.js} +3 -3
  23. package/dist/chunk-NITQ5IYP.js +22 -0
  24. package/dist/{chunk-JMX44J5R.js → chunk-NM3AFEVI.js} +174 -128
  25. package/dist/{chunk-AJPO5EP7.js → chunk-PQXP7XQK.js} +8 -7
  26. package/dist/{chunk-OCEXXVLR.cjs → chunk-TFRZZNXL.cjs} +6 -6
  27. package/dist/{chunk-JTK4RYSG.js → chunk-U5MNJ4XF.js} +3 -3
  28. package/dist/{chunk-EXY3RCJH.js → chunk-UNIWU6XL.js} +2 -2
  29. package/dist/chunk-V5WOGN7O.cjs +25 -0
  30. package/dist/chunk-XHOP5GXJ.cjs +12 -0
  31. package/dist/esbuild.cjs +8 -8
  32. package/dist/esbuild.d.cts +6 -5
  33. package/dist/esbuild.d.ts +6 -5
  34. package/dist/esbuild.js +5 -5
  35. package/dist/farm.cjs +5 -5
  36. package/dist/farm.d.cts +6 -5
  37. package/dist/farm.d.ts +6 -5
  38. package/dist/farm.js +4 -4
  39. package/dist/index.cjs +30 -22
  40. package/dist/index.d.cts +6 -7
  41. package/dist/index.d.ts +6 -7
  42. package/dist/index.js +6 -6
  43. package/dist/lib/build/esbuild.d.cts +1 -1
  44. package/dist/lib/build/esbuild.d.ts +1 -1
  45. package/dist/lib/build/index.d.cts +2 -3
  46. package/dist/lib/build/index.d.ts +2 -3
  47. package/dist/lib/build/rolldown.d.cts +1 -1
  48. package/dist/lib/build/rolldown.d.ts +1 -1
  49. package/dist/lib/build/rollup.d.cts +1 -1
  50. package/dist/lib/build/rollup.d.ts +1 -1
  51. package/dist/lib/build/rspack.d.cts +1 -1
  52. package/dist/lib/build/rspack.d.ts +1 -1
  53. package/dist/lib/build/tsdown.d.cts +1 -1
  54. package/dist/lib/build/tsdown.d.ts +1 -1
  55. package/dist/lib/build/tsup.d.cts +1 -1
  56. package/dist/lib/build/tsup.d.ts +1 -1
  57. package/dist/lib/build/unbuild.d.cts +2 -3
  58. package/dist/lib/build/unbuild.d.ts +2 -3
  59. package/dist/lib/build/vite.d.cts +1 -1
  60. package/dist/lib/build/vite.d.ts +1 -1
  61. package/dist/lib/build/webpack.d.cts +1 -1
  62. package/dist/lib/build/webpack.d.ts +1 -1
  63. package/dist/lib/chunk-254IMO3A.js +17 -0
  64. package/dist/lib/chunk-254IMO3A.js.map +1 -0
  65. package/dist/lib/{chunk-T3VYM4BO.cjs → chunk-4QMQCXAG.cjs} +6 -6
  66. package/dist/lib/{chunk-T3VYM4BO.cjs.map → chunk-4QMQCXAG.cjs.map} +1 -1
  67. package/dist/lib/chunk-64R4MDJ7.cjs +25 -0
  68. package/dist/lib/chunk-64R4MDJ7.cjs.map +1 -0
  69. package/dist/lib/{chunk-HEMW2YZA.js → chunk-7PD2L3PS.js} +2 -2
  70. package/dist/lib/{chunk-HEMW2YZA.js.map → chunk-7PD2L3PS.js.map} +1 -1
  71. package/dist/lib/{chunk-PWKYZBQQ.js → chunk-FI4QUQV2.js} +4 -4
  72. package/dist/lib/{chunk-PWKYZBQQ.js.map → chunk-FI4QUQV2.js.map} +1 -1
  73. package/dist/lib/{chunk-3RTOKGVV.cjs → chunk-G3BXMS2V.cjs} +47 -48
  74. package/dist/lib/chunk-G3BXMS2V.cjs.map +1 -0
  75. package/dist/lib/chunk-GNEHIBN4.cjs +20 -0
  76. package/dist/lib/chunk-GNEHIBN4.cjs.map +1 -0
  77. package/dist/lib/{chunk-57WHQU5T.cjs → chunk-GZDE4GLY.cjs} +2 -2
  78. package/dist/lib/{chunk-57WHQU5T.cjs.map → chunk-GZDE4GLY.cjs.map} +1 -1
  79. package/dist/lib/chunk-HGE5DAZF.js +22 -0
  80. package/dist/lib/chunk-HGE5DAZF.js.map +1 -0
  81. package/dist/lib/{chunk-GUZKITBG.js → chunk-I7BLJZ4D.js} +5 -5
  82. package/dist/lib/chunk-I7BLJZ4D.js.map +1 -0
  83. package/dist/lib/{chunk-MZQFHBHY.cjs → chunk-QVDESIYV.cjs} +5 -5
  84. package/dist/lib/chunk-QVDESIYV.cjs.map +1 -0
  85. package/dist/lib/{chunk-POY47Z36.js → chunk-TO3SBSXL.js} +35 -36
  86. package/dist/lib/chunk-TO3SBSXL.js.map +1 -0
  87. package/dist/lib/{chunk-XAALLEOG.js → chunk-TWAVU346.js} +27 -29
  88. package/dist/lib/chunk-TWAVU346.js.map +1 -0
  89. package/dist/lib/{chunk-C7KNYLNP.cjs → chunk-UXLXQOJD.cjs} +29 -30
  90. package/dist/lib/chunk-UXLXQOJD.cjs.map +1 -0
  91. package/dist/lib/chunk-WAN5RBXY.cjs +234 -0
  92. package/dist/lib/chunk-WAN5RBXY.cjs.map +1 -0
  93. package/dist/lib/chunk-XDUEQVFC.js +232 -0
  94. package/dist/lib/chunk-XDUEQVFC.js.map +1 -0
  95. package/dist/lib/{config-BSQhtJCR.d.ts → config-BLfOgflT.d.ts} +230 -104
  96. package/dist/lib/{config-CP6f9ozu.d.cts → config-CmG_oSbS.d.cts} +230 -104
  97. package/dist/lib/config-file.d.cts +1 -1
  98. package/dist/lib/config-file.d.ts +1 -1
  99. package/dist/lib/contexts/api-context.cjs +7 -5
  100. package/dist/lib/contexts/api-context.d.cts +2 -3
  101. package/dist/lib/contexts/api-context.d.ts +2 -3
  102. package/dist/lib/contexts/api-context.js +6 -4
  103. package/dist/lib/contexts/context.cjs +3 -2
  104. package/dist/lib/contexts/context.d.cts +2 -3
  105. package/dist/lib/contexts/context.d.ts +2 -3
  106. package/dist/lib/contexts/context.js +2 -1
  107. package/dist/lib/contexts/environment-context.cjs +6 -4
  108. package/dist/lib/contexts/environment-context.d.cts +3 -4
  109. package/dist/lib/contexts/environment-context.d.ts +3 -4
  110. package/dist/lib/contexts/environment-context.js +5 -3
  111. package/dist/lib/contexts/index.cjs +10 -8
  112. package/dist/lib/contexts/index.d.cts +2 -3
  113. package/dist/lib/contexts/index.d.ts +2 -3
  114. package/dist/lib/contexts/index.js +6 -4
  115. package/dist/lib/contexts/plugin-context.cjs +2 -2
  116. package/dist/lib/contexts/plugin-context.d.cts +2 -3
  117. package/dist/lib/contexts/plugin-context.d.ts +2 -3
  118. package/dist/lib/contexts/plugin-context.js +1 -1
  119. package/dist/lib/entry.d.cts +1 -1
  120. package/dist/lib/entry.d.ts +1 -1
  121. package/dist/lib/fs/index.d.cts +1 -1
  122. package/dist/lib/fs/index.d.ts +1 -1
  123. package/dist/lib/fs/vfs.d.cts +1 -1
  124. package/dist/lib/fs/vfs.d.ts +1 -1
  125. package/dist/lib/index.cjs +22 -17
  126. package/dist/lib/index.d.cts +3 -5
  127. package/dist/lib/index.d.ts +3 -5
  128. package/dist/lib/index.js +8 -7
  129. package/dist/lib/{internal-BusfSz8D.d.ts → internal-BfGb9HLc.d.ts} +4 -3
  130. package/dist/lib/{internal-CPKLmt5v.d.cts → internal-CYMrNGHE.d.cts} +4 -3
  131. package/dist/lib/logger.d.cts +1 -1
  132. package/dist/lib/logger.d.ts +1 -1
  133. package/dist/lib/typescript/import-transformer.d.cts +1 -1
  134. package/dist/lib/typescript/import-transformer.d.ts +1 -1
  135. package/dist/lib/typescript/index.d.cts +1 -1
  136. package/dist/lib/typescript/index.d.ts +1 -1
  137. package/dist/lib/typescript/ts-morph.d.cts +1 -1
  138. package/dist/lib/typescript/ts-morph.d.ts +1 -1
  139. package/dist/lib/unplugin/factory.cjs +8 -6
  140. package/dist/lib/unplugin/factory.d.cts +4 -128
  141. package/dist/lib/unplugin/factory.d.ts +4 -128
  142. package/dist/lib/unplugin/factory.js +7 -5
  143. package/dist/lib/unplugin/helpers.cjs +7 -2
  144. package/dist/lib/unplugin/helpers.d.cts +9 -2
  145. package/dist/lib/unplugin/helpers.d.ts +9 -2
  146. package/dist/lib/unplugin/helpers.js +2 -1
  147. package/dist/lib/unplugin/index.cjs +15 -10
  148. package/dist/lib/unplugin/index.d.cts +4 -6
  149. package/dist/lib/unplugin/index.d.ts +4 -6
  150. package/dist/lib/unplugin/index.js +8 -7
  151. package/dist/lib/unplugin/plugin.cjs +4 -3
  152. package/dist/lib/unplugin/plugin.d.cts +2 -4
  153. package/dist/lib/unplugin/plugin.d.ts +2 -4
  154. package/dist/lib/unplugin/plugin.js +3 -2
  155. package/dist/lib/utilities/bundle.d.cts +1 -1
  156. package/dist/lib/utilities/bundle.d.ts +1 -1
  157. package/dist/lib/utilities/cache.d.cts +1 -1
  158. package/dist/lib/utilities/cache.d.ts +1 -1
  159. package/dist/lib/utilities/file-header.d.cts +1 -1
  160. package/dist/lib/utilities/file-header.d.ts +1 -1
  161. package/dist/lib/utilities/index.d.cts +1 -1
  162. package/dist/lib/utilities/index.d.ts +1 -1
  163. package/dist/lib/utilities/meta.d.cts +1 -1
  164. package/dist/lib/utilities/meta.d.ts +1 -1
  165. package/dist/lib/utilities/resolve.d.cts +1 -1
  166. package/dist/lib/utilities/resolve.d.ts +1 -1
  167. package/dist/lib/utilities/source-file.d.cts +1 -1
  168. package/dist/lib/utilities/source-file.d.ts +1 -1
  169. package/dist/lib/utilities/source-map.d.cts +1 -1
  170. package/dist/lib/utilities/source-map.d.ts +1 -1
  171. package/dist/lib/utilities/worker.d.cts +1 -1
  172. package/dist/lib/utilities/worker.d.ts +1 -1
  173. package/dist/lib/utilities/write-file.d.cts +1 -1
  174. package/dist/lib/utilities/write-file.d.ts +1 -1
  175. package/dist/next.cjs +6 -6
  176. package/dist/next.js +5 -5
  177. package/dist/nuxt.cjs +9 -9
  178. package/dist/nuxt.d.cts +4 -3
  179. package/dist/nuxt.d.ts +4 -3
  180. package/dist/nuxt.js +7 -7
  181. package/dist/plugin-utils/{chunk-EJ5XPAJQ.cjs → chunk-2I5L22QB.cjs} +8 -6
  182. package/dist/plugin-utils/chunk-2I5L22QB.cjs.map +1 -0
  183. package/dist/plugin-utils/{chunk-AHZPK4Z5.cjs → chunk-4FLR5DY5.cjs} +7 -7
  184. package/dist/plugin-utils/{chunk-AHZPK4Z5.cjs.map → chunk-4FLR5DY5.cjs.map} +1 -1
  185. package/dist/plugin-utils/{chunk-BWAX3NRG.cjs → chunk-6YOLE5BT.cjs} +34 -21
  186. package/dist/plugin-utils/chunk-6YOLE5BT.cjs.map +1 -0
  187. package/dist/plugin-utils/{chunk-JAG7QJDV.cjs → chunk-ARNNN4GS.cjs} +5 -5
  188. package/dist/plugin-utils/chunk-ARNNN4GS.cjs.map +1 -0
  189. package/dist/plugin-utils/{chunk-FTVPZZJO.js → chunk-I3FSMSLD.js} +32 -20
  190. package/dist/plugin-utils/chunk-I3FSMSLD.js.map +1 -0
  191. package/dist/plugin-utils/{chunk-N4IXPCGY.js → chunk-RZAQTG45.js} +3 -3
  192. package/dist/plugin-utils/{chunk-N4IXPCGY.js.map → chunk-RZAQTG45.js.map} +1 -1
  193. package/dist/plugin-utils/{chunk-JCX2UJYO.js → chunk-XDURJUGS.js} +5 -3
  194. package/dist/plugin-utils/chunk-XDURJUGS.js.map +1 -0
  195. package/dist/plugin-utils/{chunk-WZCGJ7JR.js → chunk-Z2BYI6KW.js} +3 -3
  196. package/dist/plugin-utils/chunk-Z2BYI6KW.js.map +1 -0
  197. package/dist/plugin-utils/{context-GdayEWcl.d.cts → context-BQTlTcfV.d.cts} +444 -76
  198. package/dist/plugin-utils/{context-GdayEWcl.d.ts → context-BQTlTcfV.d.ts} +444 -76
  199. package/dist/plugin-utils/context-helpers.d.cts +11 -2
  200. package/dist/plugin-utils/context-helpers.d.ts +11 -2
  201. package/dist/plugin-utils/enforce.cjs +5 -5
  202. package/dist/plugin-utils/enforce.d.cts +13 -4
  203. package/dist/plugin-utils/enforce.d.ts +13 -4
  204. package/dist/plugin-utils/enforce.js +4 -4
  205. package/dist/plugin-utils/extend.cjs +4 -4
  206. package/dist/plugin-utils/extend.d.cts +11 -2
  207. package/dist/plugin-utils/extend.d.ts +11 -2
  208. package/dist/plugin-utils/extend.js +3 -3
  209. package/dist/plugin-utils/get-config-path.d.cts +11 -2
  210. package/dist/plugin-utils/get-config-path.d.ts +11 -2
  211. package/dist/plugin-utils/helpers.cjs +25 -21
  212. package/dist/plugin-utils/helpers.d.cts +36 -32
  213. package/dist/plugin-utils/helpers.d.ts +36 -32
  214. package/dist/plugin-utils/helpers.js +1 -1
  215. package/dist/plugin-utils/index.cjs +31 -27
  216. package/dist/plugin-utils/index.d.cts +12 -3
  217. package/dist/plugin-utils/index.d.ts +12 -3
  218. package/dist/plugin-utils/index.js +4 -4
  219. package/dist/plugin-utils/merge.cjs +3 -3
  220. package/dist/plugin-utils/merge.d.cts +11 -2
  221. package/dist/plugin-utils/merge.d.ts +11 -2
  222. package/dist/plugin-utils/merge.js +2 -2
  223. package/dist/plugin-utils/paths.d.cts +11 -2
  224. package/dist/plugin-utils/paths.d.ts +11 -2
  225. package/dist/rolldown.cjs +8 -8
  226. package/dist/rolldown.d.cts +6 -5
  227. package/dist/rolldown.d.ts +6 -5
  228. package/dist/rolldown.js +5 -5
  229. package/dist/rollup.cjs +5 -5
  230. package/dist/rollup.d.cts +6 -5
  231. package/dist/rollup.d.ts +6 -5
  232. package/dist/rollup.js +4 -4
  233. package/dist/rspack.cjs +5 -5
  234. package/dist/rspack.d.cts +6 -5
  235. package/dist/rspack.d.ts +6 -5
  236. package/dist/rspack.js +4 -4
  237. package/dist/tsdown.cjs +6 -6
  238. package/dist/tsdown.js +5 -5
  239. package/dist/tsup.cjs +6 -6
  240. package/dist/tsup.js +5 -5
  241. package/dist/types/api.d.cts +5 -5
  242. package/dist/types/api.d.ts +5 -5
  243. package/dist/types/babel.d.cts +6 -5
  244. package/dist/types/babel.d.ts +6 -5
  245. package/dist/types/build.cjs +7 -3
  246. package/dist/types/build.d.cts +19 -13
  247. package/dist/types/build.d.ts +19 -13
  248. package/dist/types/build.js +1 -1
  249. package/dist/types/commands.d.cts +4 -3
  250. package/dist/types/commands.d.ts +4 -3
  251. package/dist/types/config.d.cts +3 -2
  252. package/dist/types/config.d.ts +3 -2
  253. package/dist/types/context.cjs +2 -2
  254. package/dist/types/context.d.cts +3 -2
  255. package/dist/types/context.d.ts +3 -2
  256. package/dist/types/context.js +1 -1
  257. package/dist/types/hooks.cjs +8 -1
  258. package/dist/types/hooks.d.cts +15 -14
  259. package/dist/types/hooks.d.ts +15 -14
  260. package/dist/types/hooks.js +2 -1
  261. package/dist/types/index.cjs +19 -11
  262. package/dist/types/index.d.cts +4 -5
  263. package/dist/types/index.d.ts +4 -5
  264. package/dist/types/index.js +4 -4
  265. package/dist/types/internal.d.cts +8 -6
  266. package/dist/types/internal.d.ts +8 -6
  267. package/dist/types/plugin.cjs +7 -7
  268. package/dist/types/plugin.d.cts +3 -2
  269. package/dist/types/plugin.d.ts +3 -2
  270. package/dist/types/plugin.js +2 -2
  271. package/dist/types/resolved.d.cts +2 -1
  272. package/dist/types/resolved.d.ts +2 -1
  273. package/dist/types/unplugin.d.cts +14 -39
  274. package/dist/types/unplugin.d.ts +14 -39
  275. package/dist/unloader.cjs +5 -5
  276. package/dist/unloader.d.cts +4 -3
  277. package/dist/unloader.d.ts +4 -3
  278. package/dist/unloader.js +4 -4
  279. package/dist/unplugin.cjs +17 -15
  280. package/dist/unplugin.d.cts +18 -13
  281. package/dist/unplugin.d.ts +18 -13
  282. package/dist/unplugin.js +9 -13
  283. package/dist/vite.cjs +8 -8
  284. package/dist/vite.d.cts +6 -5
  285. package/dist/vite.d.ts +6 -5
  286. package/dist/vite.js +5 -5
  287. package/dist/webpack.cjs +8 -8
  288. package/dist/webpack.d.cts +6 -5
  289. package/dist/webpack.d.ts +6 -5
  290. package/dist/webpack.js +5 -5
  291. package/package.json +7 -4
  292. package/dist/api-D0gA4eJU.d.cts +0 -142
  293. package/dist/api-cYTlb0MO.d.ts +0 -142
  294. package/dist/chunk-HJW7OH6E.js +0 -3
  295. package/dist/chunk-J7SXQCBV.cjs +0 -12
  296. package/dist/chunk-U2RJRKLT.js +0 -15
  297. package/dist/chunk-WVLFG7L6.cjs +0 -12
  298. package/dist/chunk-XOMY3USD.cjs +0 -17
  299. package/dist/chunk-XZO6ZJQP.cjs +0 -4
  300. package/dist/lib/api-BeWRTlF3.d.cts +0 -141
  301. package/dist/lib/api-C00m3GB0.d.ts +0 -141
  302. package/dist/lib/chunk-3RTOKGVV.cjs.map +0 -1
  303. package/dist/lib/chunk-A4RSMLXW.cjs +0 -13
  304. package/dist/lib/chunk-A4RSMLXW.cjs.map +0 -1
  305. package/dist/lib/chunk-C7KNYLNP.cjs.map +0 -1
  306. package/dist/lib/chunk-DLX6BNNE.cjs +0 -196
  307. package/dist/lib/chunk-DLX6BNNE.cjs.map +0 -1
  308. package/dist/lib/chunk-GUZKITBG.js.map +0 -1
  309. package/dist/lib/chunk-HDUSUF6L.js +0 -11
  310. package/dist/lib/chunk-HDUSUF6L.js.map +0 -1
  311. package/dist/lib/chunk-MZQFHBHY.cjs.map +0 -1
  312. package/dist/lib/chunk-POY47Z36.js.map +0 -1
  313. package/dist/lib/chunk-XAALLEOG.js.map +0 -1
  314. package/dist/lib/chunk-XHDL2XZB.js +0 -194
  315. package/dist/lib/chunk-XHDL2XZB.js.map +0 -1
  316. package/dist/lib/unplugin-BKtwOoMk.d.ts +0 -18
  317. package/dist/lib/unplugin-BWG1mWFO.d.cts +0 -18
  318. package/dist/plugin-utils/chunk-BWAX3NRG.cjs.map +0 -1
  319. package/dist/plugin-utils/chunk-EJ5XPAJQ.cjs.map +0 -1
  320. package/dist/plugin-utils/chunk-FTVPZZJO.js.map +0 -1
  321. package/dist/plugin-utils/chunk-JAG7QJDV.cjs.map +0 -1
  322. package/dist/plugin-utils/chunk-JCX2UJYO.js.map +0 -1
  323. package/dist/plugin-utils/chunk-WZCGJ7JR.js.map +0 -1
@@ -1,6 +1,6 @@
1
1
  import { EnvPaths } from '@stryke/env/get-env-paths';
2
2
  import { FetchRequestOptions } from '@stryke/http/fetch';
3
- import { MaybePromise, NonUndefined, FunctionLike, DeepPartial as DeepPartial$1 } from '@stryke/types/base';
3
+ import { MaybePromise, NonUndefined, AnyFunction, DeepPartial as DeepPartial$1 } from '@stryke/types/base';
4
4
  import { PackageJson } from '@stryke/types/package-json';
5
5
  import { Jiti } from 'jiti';
6
6
  import { SourceMap } from 'magic-string';
@@ -8,21 +8,31 @@ import { ParserOptions, ParseResult } from 'oxc-parser';
8
8
  import { Range } from 'semver';
9
9
  import { Project } from 'ts-morph';
10
10
  import { RequestInfo, Response } from 'undici';
11
- import { TransformResult as TransformResult$1, ExternalIdResult, HookFilter, UnpluginOptions, UnpluginContext, UnpluginBuildContext, UnpluginMessage } from 'unplugin';
11
+ import { UnpluginOptions as UnpluginOptions$1, HookFilter, TransformResult as TransformResult$1, ExternalIdResult, UnpluginContext, UnpluginBuildContext, UnpluginMessage } from 'unplugin';
12
12
  import { Format } from '@storm-software/build-tools/types';
13
13
  import { LogLevelLabel } from '@storm-software/config-tools/types';
14
14
  import { StormWorkspaceConfig } from '@storm-software/config/types';
15
15
  import { TypeDefinition, TypeDefinitionParameter } from '@stryke/types/configuration';
16
16
  import { AssetGlob } from '@stryke/types/file';
17
17
  import { DateString } from 'compatx';
18
- import { ResolvedPreviewOptions, PreviewOptions } from 'vite';
18
+ import { UserConfig as UserConfig$1, DepOptimizationOptions, ResolvedPreviewOptions, PreviewOptions } from 'vite';
19
+ import { UserConfig as UserConfig$3 } from '@farmfe/core';
20
+ import { Configuration as Configuration$1 } from '@rspack/core';
21
+ import { BuildOptions as BuildOptions$1 } from '@storm-software/tsup/types';
22
+ import { UnbuildOptions } from '@storm-software/unbuild/types';
23
+ import { BuildOptions } from 'esbuild';
24
+ import { RolldownOptions } from 'rolldown';
25
+ import { RollupOptions, OutputOptions, LoadResult } from 'rollup';
26
+ import { UserConfig as UserConfig$2 } from 'tsdown';
27
+ import { Configuration } from 'webpack';
19
28
  import { ResolveOptions as ResolveOptions$1 } from '@stryke/fs/resolve';
29
+ import { ArrayValues } from '@stryke/types/array';
20
30
  import { TsConfigJson, CompilerOptions } from '@stryke/types/tsconfig';
21
31
  import ts from 'typescript';
22
- import { ArrayValues } from '@stryke/types/array';
23
32
 
24
- type UnpluginBuildVariant = "rollup" | "webpack" | "rspack" | "vite" | "esbuild" | "farm" | "unloader" | "rolldown";
25
- type BuildVariant = UnpluginBuildVariant | "tsup" | "tsdown" | "unbuild";
33
+ type UnpluginBuilderVariant = "rollup" | "webpack" | "rspack" | "vite" | "esbuild" | "farm" | "unloader" | "rolldown" | "bun";
34
+ type BuilderVariant = UnpluginBuilderVariant | "tsup" | "tsdown" | "unbuild";
35
+ type InferUnpluginVariant<TBuildVariant extends BuilderVariant> = TBuildVariant extends "tsup" ? "esbuild" : TBuildVariant extends "tsdown" ? "rolldown" : TBuildVariant extends "unbuild" ? "rollup" : TBuildVariant;
26
36
  interface BuildConfig {
27
37
  /**
28
38
  * The platform to build the project for
@@ -163,6 +173,34 @@ interface BuildConfig {
163
173
  override?: Record<string, any>;
164
174
  }
165
175
  type BuildResolvedConfig = Omit<BuildConfig, "override">;
176
+ type ESBuildBuildConfig = Omit<BuildOptions, "entryPoints" | "sourceRoot" | "platform" | "outdir" | "env" | "assets" | "external" | "inject" | "tsconfig" | "tsconfigRaw" | "logLevel"> & BuildConfig;
177
+ type ESBuildResolvedBuildConfig = Omit<BuildOptions, "inject"> & BuildResolvedConfig;
178
+ type ViteBuildConfig = Omit<UserConfig$1, "entry" | "entryPoints" | "tsconfig" | "tsconfigRaw" | "environments" | "output"> & BuildConfig & {
179
+ /**
180
+ * Optimize deps config
181
+ */
182
+ optimizeDeps?: Omit<DepOptimizationOptions, "extensions">;
183
+ };
184
+ type ViteResolvedBuildConfig = UserConfig$1 & BuildResolvedConfig;
185
+ type WebpackBuildConfig = Omit<Configuration, "name" | "entry" | "entryPoints" | "tsconfig" | "tsconfigRaw"> & BuildConfig;
186
+ type WebpackResolvedBuildConfig = Configuration & BuildResolvedConfig;
187
+ type RspackBuildConfig = Omit<Configuration$1, "name" | "entry" | "entryPoints" | "tsconfig" | "tsconfigRaw"> & BuildConfig;
188
+ type RspackResolvedBuildConfig = Configuration$1 & BuildResolvedConfig;
189
+ type RollupBuildOutputConfig = Omit<OutputOptions, "dir" | "format">;
190
+ type RollupBuildConfig = Omit<RollupOptions, "entry" | "external" | "input" | "output" | "logLevel"> & {
191
+ output: RollupBuildOutputConfig | RollupBuildOutputConfig[];
192
+ } & BuildConfig;
193
+ type RollupResolvedBuildConfig = RollupOptions & BuildResolvedConfig;
194
+ type RolldownBuildConfig = Omit<RolldownOptions, "input" | "external" | "tsconfig" | "logLevel" | "output"> & BuildConfig;
195
+ type RolldownResolvedBuildConfig = RolldownOptions & BuildResolvedConfig;
196
+ type TsupBuildConfig = Partial<Omit<BuildOptions$1, "userOptions" | "tsconfig" | "tsconfigRaw" | "assets" | "outputPath" | "mode" | "format" | "platform" | "projectRoot" | "clean" | "env" | "entry" | "entryPoints" | "external" | "noExternal" | "skipNodeModulesBundle">> & BuildConfig;
197
+ type TsupResolvedBuildConfig = BuildOptions$1 & BuildResolvedConfig;
198
+ type TsdownBuildConfig = Partial<Omit<UserConfig$2, "name" | "outDir" | "clean" | "cwd" | "tsconfig" | "publicDir" | "copy" | "alias" | "format" | "platform" | "env" | "define" | "entry" | "external" | "noExternal" | "skipNodeModulesBundle">> & BuildConfig;
199
+ type TsdownResolvedBuildConfig = UserConfig$2 & BuildResolvedConfig;
200
+ type UnbuildBuildConfig = Partial<Omit<UnbuildOptions, "tsconfig" | "tsconfigRaw" | "assets" | "outputPath" | "mode" | "format" | "platform" | "projectRoot" | "env" | "entry" | "entryPoints">> & BuildConfig;
201
+ type UnbuildResolvedBuildConfig = UnbuildOptions & BuildResolvedConfig;
202
+ type FarmBuildConfig = Partial<Omit<UserConfig$3, "tsconfig" | "tsconfigRaw" | "assets" | "outputPath" | "mode" | "format" | "platform" | "projectRoot" | "env" | "entry" | "entryPoints">> & BuildConfig;
203
+ type FarmResolvedBuildConfig = UserConfig$3 & BuildResolvedConfig;
166
204
 
167
205
  type StoragePreset = "fs" | "virtual";
168
206
  /**
@@ -708,7 +746,7 @@ type ResolvedConfig<TUserConfig extends UserConfig = UserConfig> = Omit<TUserCon
708
746
  * Configuration provided to build processes
709
747
  *
710
748
  * @remarks
711
- * This configuration can be used by plugins during the `build` command. It will generally contain options specific to the selected {@link BuildVariant | build variant}.
749
+ * This configuration can be used by plugins during the `build` command. It will generally contain options specific to the selected {@link BuilderVariant | build variant}.
712
750
  */
713
751
  build: Omit<TUserConfig["build"], "override"> & Required<Pick<Required<TUserConfig["build"]>, "override">>;
714
752
  /**
@@ -718,8 +756,205 @@ type ResolvedConfig<TUserConfig extends UserConfig = UserConfig> = Omit<TUserCon
718
756
  */
719
757
  logLevel: "error" | "warn" | "info" | "debug" | "trace" | null;
720
758
  };
759
+ type ViteResolvedConfig = ResolvedConfig<ViteUserConfig>;
760
+ type WebpackResolvedConfig = ResolvedConfig<WebpackUserConfig>;
761
+ type RspackResolvedConfig = ResolvedConfig<RspackUserConfig>;
762
+ type ESBuildResolvedConfig = ResolvedConfig<ESBuildUserConfig>;
763
+ type RollupResolvedConfig = ResolvedConfig<RollupUserConfig>;
764
+ type RolldownResolvedConfig = ResolvedConfig<RolldownUserConfig>;
765
+ type TsupResolvedConfig = ResolvedConfig<TsupUserConfig>;
766
+ type TsdownResolvedConfig = ResolvedConfig<TsdownUserConfig>;
767
+ type UnbuildResolvedConfig = ResolvedConfig<UnbuildUserConfig>;
768
+ type FarmResolvedConfig = ResolvedConfig<FarmUserConfig>;
769
+ type InferResolvedConfig<TBuildVariant extends BuilderVariant | undefined> = TBuildVariant extends undefined ? ResolvedConfig : TBuildVariant extends "webpack" ? WebpackResolvedConfig : TBuildVariant extends "rspack" ? RspackResolvedConfig : TBuildVariant extends "vite" ? ViteResolvedConfig : TBuildVariant extends "esbuild" ? ESBuildResolvedConfig : TBuildVariant extends "unbuild" ? UnbuildResolvedConfig : TBuildVariant extends "tsup" ? TsupResolvedConfig : TBuildVariant extends "tsdown" ? TsdownResolvedConfig : TBuildVariant extends "rolldown" ? RolldownResolvedConfig : TBuildVariant extends "rollup" ? RollupResolvedConfig : TBuildVariant extends "farm" ? FarmResolvedConfig : ResolvedConfig;
770
+
771
+ type HookListOrders = "preOrdered" | "preEnforced" | "normal" | "postEnforced" | "postOrdered";
772
+ type UnpluginHookFunctions<TContext extends PluginContext = PluginContext, TUnpluginBuilderVariant extends UnpluginBuilderVariant = UnpluginBuilderVariant, TField extends keyof Required<UnpluginOptions$1>[TUnpluginBuilderVariant] = keyof Required<UnpluginOptions$1>[TUnpluginBuilderVariant]> = Required<UnpluginOptions$1>[TUnpluginBuilderVariant][TField] extends infer THandler | {
773
+ handler: infer THandler;
774
+ } ? THandler extends (this: infer THandlerOriginalContext, ...args: infer THandlerArgs) => infer THandlerReturn ? (this: THandlerOriginalContext & WithUnpluginBuildContext<TContext>, ...args: THandlerArgs) => THandlerReturn : THandler extends {
775
+ handler: infer THandlerFunction;
776
+ } ? THandlerFunction extends (this: infer THandlerFunctionOriginalContext, ...args: infer THandlerFunctionArgs) => infer THandlerFunctionReturn ? (this: THandlerFunctionOriginalContext & WithUnpluginBuildContext<TContext>, ...args: THandlerFunctionArgs) => THandlerFunctionReturn : never : never : never;
777
+ interface PluginHooksListItem<TContext extends PluginContext = PluginContext, TFields extends PluginHookFields<TContext> = PluginHookFields<TContext>> {
778
+ plugin: Plugin<TContext>;
779
+ handler: PluginHookFunctions<TContext>[TFields];
780
+ }
781
+ type PluginHooksList<TContext extends PluginContext = PluginContext, TFields extends PluginHookFields<TContext> = PluginHookFields<TContext>> = {
782
+ [TKey in HookListOrders]?: PluginHooksListItem<TContext, TFields>[] | undefined;
783
+ };
784
+ interface UnpluginHooksListItem<TContext extends PluginContext = PluginContext, TUnpluginBuilderVariant extends UnpluginBuilderVariant = UnpluginBuilderVariant, TField extends keyof Required<UnpluginOptions$1>[TUnpluginBuilderVariant] = keyof Required<UnpluginOptions$1>[TUnpluginBuilderVariant]> {
785
+ plugin: Plugin<TContext>;
786
+ handler: UnpluginHookFunctions<TContext, TUnpluginBuilderVariant, TField>;
787
+ }
788
+ type UnpluginHookList<TContext extends PluginContext = PluginContext, TUnpluginBuilderVariant extends UnpluginBuilderVariant = UnpluginBuilderVariant, TField extends keyof UnpluginOptions$1[TUnpluginBuilderVariant] = keyof UnpluginOptions$1[TUnpluginBuilderVariant]> = {
789
+ [TKey in HookListOrders]?: UnpluginHooksListItem<TContext, TUnpluginBuilderVariant, TField>[] | undefined;
790
+ };
791
+ type UnpluginHookVariantField<TContext extends PluginContext = PluginContext, TUnpluginBuilderVariant extends UnpluginBuilderVariant = UnpluginBuilderVariant> = {
792
+ [TKey in keyof UnpluginOptions$1[TUnpluginBuilderVariant]]?: UnpluginHookList<TContext, TUnpluginBuilderVariant, TKey>;
793
+ };
794
+ type UnpluginHookVariant<TContext extends PluginContext = PluginContext> = {
795
+ [TKey in UnpluginBuilderVariant]?: UnpluginHookVariantField<TContext, TKey>;
796
+ };
797
+ type HookFields<TContext extends PluginContext = PluginContext> = PluginHookFields<TContext> | UnpluginBuilderVariant;
798
+ type HooksList<TContext extends PluginContext = PluginContext> = {
799
+ [TField in HookFields<TContext>]?: TField extends PluginHookFields<TContext> ? PluginHooksList<TContext, TField> : TField extends UnpluginBuilderVariant ? UnpluginHookVariant<TContext>[TField] : never;
800
+ };
801
+ type InferHooksListItem<TContext extends PluginContext, TKey extends string> = TKey extends `${infer TUnpluginBuilderVariant}:${infer TUnpluginField}` ? TUnpluginBuilderVariant extends UnpluginBuilderVariant ? TUnpluginField extends keyof Required<UnpluginOptions$1>[TUnpluginBuilderVariant] ? UnpluginHooksListItem<TContext, TUnpluginBuilderVariant, TUnpluginField> : never : never : TKey extends keyof PluginHookFunctions<TContext> ? PluginHooksListItem<TContext, TKey> : never;
802
+ type InferHookFunction<TContext extends PluginContext, TKey extends string> = TKey extends `${infer TUnpluginBuilderVariant}:${infer TUnpluginField}` ? TUnpluginBuilderVariant extends UnpluginBuilderVariant ? TUnpluginField extends keyof Required<UnpluginOptions$1>[TUnpluginBuilderVariant] ? UnpluginHookFunctions<TContext, TUnpluginBuilderVariant, TUnpluginField> : never : never : TKey extends keyof PluginHookFunctions<TContext> ? PluginHookFunctions<TContext>[TKey] : never;
803
+ type InferHookReturnType<TContext extends PluginContext, TKey extends string> = ReturnType<InferHookFunction<TContext, TKey>>;
804
+ type InferHookParameters<TContext extends PluginContext, TKey extends string> = Parameters<InferHookFunction<TContext, TKey>>;
805
+
806
+ type CallHookOptions = SelectHooksOptions & (({
807
+ /**
808
+ * Whether to call the hooks sequentially or in parallel.
809
+ *
810
+ * @defaultValue true
811
+ */
812
+ sequential?: true;
813
+ } & ({
814
+ /**
815
+ * How to handle multiple return values from hooks.
816
+ * - "merge": Merge all non-undefined return values (if they are objects).
817
+ * - "first": Return the first non-undefined value.
818
+ *
819
+ * @remarks
820
+ * Merging only works if the return values are objects.
821
+ *
822
+ * @defaultValue "merge"
823
+ */
824
+ result: "first";
825
+ } | {
826
+ /**
827
+ * How to handle multiple return values from hooks.
828
+ * - "merge": Merge all non-undefined return values (if they are objects).
829
+ * - "first": Return the first non-undefined value.
830
+ *
831
+ * @remarks
832
+ * Merging only works if the return values are objects.
833
+ *
834
+ * @defaultValue "merge"
835
+ */
836
+ result?: "merge" | "last";
837
+ /**
838
+ * An indicator specifying if the results of the previous hook should be provided as the **first** parameter of the next hook function, or a function to process the result of the previous hook function and pass the returned value as the next hook's **first** parameter
839
+ */
840
+ asNextParam?: false | ((previousResult: any) => MaybePromise<any>);
841
+ })) | {
842
+ /**
843
+ * Whether to call the hooks sequentially or in parallel.
844
+ */
845
+ sequential: false;
846
+ });
847
+
848
+ /**
849
+ * Powerlines API Interface
850
+ */
851
+ interface API<TResolvedConfig extends ResolvedConfig = ResolvedConfig> {
852
+ /**
853
+ * The Powerlines shared API context
854
+ */
855
+ context: APIContext<TResolvedConfig>;
856
+ /**
857
+ * Prepare the Powerlines API
858
+ *
859
+ * @remarks
860
+ * This method will prepare the Powerlines API for use, initializing any necessary resources.
861
+ *
862
+ * @param inlineConfig - The inline configuration for the prepare command
863
+ */
864
+ prepare: (inlineConfig: PrepareInlineConfig | NewInlineConfig | CleanInlineConfig | BuildInlineConfig | LintInlineConfig | DocsInlineConfig | DeployInlineConfig) => Promise<void>;
865
+ /**
866
+ * Create a new Powerlines project
867
+ *
868
+ * @remarks
869
+ * This method will create a new Powerlines project in the current directory.
870
+ *
871
+ * @param inlineConfig - The inline configuration for the new command
872
+ * @returns A promise that resolves when the project has been created
873
+ */
874
+ new: (inlineConfig: NewInlineConfig) => Promise<void>;
875
+ /**
876
+ * Clean any previously prepared artifacts
877
+ *
878
+ * @remarks
879
+ * This method will remove the previous Powerlines artifacts from the project.
880
+ *
881
+ * @param inlineConfig - The inline configuration for the clean command
882
+ * @returns A promise that resolves when the clean command has completed
883
+ */
884
+ clean: (inlineConfig: CleanInlineConfig | PrepareInlineConfig) => Promise<void>;
885
+ /**
886
+ * Lint the project source code
887
+ *
888
+ * @param inlineConfig - The inline configuration for the lint command
889
+ * @returns A promise that resolves when the lint command has completed
890
+ */
891
+ lint: (inlineConfig: LintInlineConfig) => Promise<void>;
892
+ /**
893
+ * Build the project
894
+ *
895
+ * @remarks
896
+ * This method will build the Powerlines project, generating the necessary artifacts.
897
+ *
898
+ * @param inlineConfig - The inline configuration for the build command
899
+ * @returns A promise that resolves when the build command has completed
900
+ */
901
+ build: (inlineConfig: BuildInlineConfig) => Promise<void>;
902
+ /**
903
+ * Prepare the documentation for the project
904
+ *
905
+ * @param inlineConfig - The inline configuration for the docs command
906
+ * @returns A promise that resolves when the documentation generation has completed
907
+ */
908
+ docs: (inlineConfig: DocsInlineConfig) => Promise<void>;
909
+ /**
910
+ * Deploy the project source code
911
+ *
912
+ * @remarks
913
+ * This method will prepare and build the Powerlines project, generating the necessary artifacts for the deployment.
914
+ *
915
+ * @param inlineConfig - The inline configuration for the deploy command
916
+ */
917
+ deploy: (inlineConfig: DeployInlineConfig) => Promise<void>;
918
+ /**
919
+ * Finalization process
920
+ *
921
+ * @remarks
922
+ * This step includes any final processes or clean up required by Powerlines. It will be run after each Powerlines command.
923
+ *
924
+ * @returns A promise that resolves when the finalization process has completed
925
+ */
926
+ finalize: () => Promise<void>;
927
+ /**
928
+ * Invokes the configured plugin hooks
929
+ *
930
+ * @remarks
931
+ * By default, it will call the `"pre"`, `"normal"`, and `"post"` ordered hooks in sequence
932
+ *
933
+ * @param hook - The hook to call
934
+ * @param options - The options to provide to the hook
935
+ * @param args - The arguments to pass to the hook
936
+ * @returns The result of the hook call
937
+ */
938
+ callHook: <TKey extends string>(hook: TKey, options: CallHookOptions & {
939
+ environment?: string | EnvironmentContext<TResolvedConfig>;
940
+ }, ...args: InferHookParameters<PluginContext<TResolvedConfig>, TKey>) => Promise<InferHookReturnType<PluginContext<TResolvedConfig>, TKey> | undefined>;
941
+ }
942
+
943
+ interface UnpluginOptions<TUnpluginBuilderVariant extends UnpluginBuilderVariant = UnpluginBuilderVariant> extends UnpluginOptions$1 {
944
+ /**
945
+ * An API object that can be used for inter-plugin communication.
946
+ *
947
+ * @see https://rollupjs.org/plugin-development/#direct-plugin-communication
948
+ */
949
+ api: API<InferResolvedConfig<TUnpluginBuilderVariant>>;
950
+ }
951
+ type InferUnpluginOptions<TContext extends Context = Context, TBuilderVariant extends BuilderVariant = BuilderVariant, TUnpluginVariant extends InferUnpluginVariant<TBuilderVariant> = InferUnpluginVariant<TBuilderVariant>> = {
952
+ [TKey in keyof Required<UnpluginOptions<TUnpluginVariant>>[TUnpluginVariant]]?: Required<UnpluginOptions<TUnpluginVariant>>[TUnpluginVariant][TKey] extends infer THandler | {
953
+ handler: infer THandler;
954
+ } ? THandler extends (this: infer TOriginalContext, ...args: infer TArgs) => infer TReturn ? PluginHook<(this: TOriginalContext & TContext, ...args: TArgs) => MaybePromise<TReturn>, keyof HookFilter> : Required<UnpluginOptions<TUnpluginVariant>>[TUnpluginVariant][TKey] : Required<UnpluginOptions<TUnpluginVariant>>[TUnpluginVariant][TKey];
955
+ };
721
956
 
722
- interface PluginHookObject<THookFunction extends FunctionLike, TFilter extends keyof HookFilter = never> {
957
+ interface PluginHookObject<THookFunction extends AnyFunction, TFilter extends keyof HookFilter = never> {
723
958
  /**
724
959
  * The order in which the plugin should be applied.
725
960
  */
@@ -733,7 +968,7 @@ interface PluginHookObject<THookFunction extends FunctionLike, TFilter extends k
733
968
  */
734
969
  handler: THookFunction;
735
970
  }
736
- type PluginHook<THookFunction extends FunctionLike, TFilter extends keyof HookFilter = never> = THookFunction | PluginHookObject<THookFunction, TFilter>;
971
+ type PluginHook<THookFunction extends AnyFunction, TFilter extends keyof HookFilter = never> = THookFunction | PluginHookObject<THookFunction, TFilter>;
737
972
  /**
738
973
  * A result returned by the plugin from the `types` hook that describes the declaration types output file.
739
974
  */
@@ -741,11 +976,9 @@ interface TypesResult {
741
976
  directives?: string[];
742
977
  code: string;
743
978
  }
744
- type DeepPartial<T> = {
745
- [K in keyof T]?: DeepPartial<T[K]>;
746
- };
747
- type ConfigResult<TContext extends PluginContext = PluginContext> = DeepPartial<TContext["config"]> & Record<string, any>;
748
- interface BasePluginHookFunctions<TContext extends PluginContext = PluginContext> extends Record<CommandType, (this: TContext) => MaybePromise<void>> {
979
+ type PluginHookFunctions<TContext extends PluginContext> = {
980
+ [TCommandType in CommandType]: (this: TContext) => MaybePromise<void>;
981
+ } & {
749
982
  /**
750
983
  * A function that returns configuration options to be merged with the build context's options.
751
984
  *
@@ -760,7 +993,7 @@ interface BasePluginHookFunctions<TContext extends PluginContext = PluginContext
760
993
  * @param config - The partial configuration object to be modified.
761
994
  * @returns A promise that resolves to a partial configuration object.
762
995
  */
763
- config: (this: UnresolvedContext<TContext["config"]>) => MaybePromise<ConfigResult<TContext>>;
996
+ config: (this: UnresolvedContext<TContext["config"]>) => MaybePromise<DeepPartial<TContext["config"]> & Record<string, any>>;
764
997
  /**
765
998
  * 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.
766
999
  *
@@ -822,7 +1055,7 @@ interface BasePluginHookFunctions<TContext extends PluginContext = PluginContext
822
1055
  * @param id - The identifier of the source code.
823
1056
  * @returns A promise that resolves when the hook is complete.
824
1057
  */
825
- load: (this: BuildPluginContext<TContext["config"]> & TContext, id: string) => MaybePromise<TransformResult$1>;
1058
+ load: (this: BuildPluginContext<TContext["config"]> & TContext, id: string) => MaybePromise<LoadResult>;
826
1059
  /**
827
1060
  * A hook that is called to resolve the identifier of the source code.
828
1061
  *
@@ -842,67 +1075,18 @@ interface BasePluginHookFunctions<TContext extends PluginContext = PluginContext
842
1075
  * @returns A promise that resolves when the hook is complete.
843
1076
  */
844
1077
  writeBundle: (this: TContext) => MaybePromise<void>;
845
- }
846
- type BuildPlugin<TContext extends PluginContext = PluginContext, TBuildVariant extends UnpluginBuildVariant = UnpluginBuildVariant, TOptions extends Required<UnpluginOptions>[TBuildVariant] = Required<UnpluginOptions>[TBuildVariant]> = {
847
- [TKey in keyof TOptions]: TOptions[TKey] extends FunctionLike ? (this: ThisParameterType<TOptions[TKey]> & TContext, ...args: Parameters<TOptions[TKey]>) => ReturnType<TOptions[TKey]> | MaybePromise<ReturnType<TOptions[TKey]>> : TOptions[TKey];
848
1078
  };
849
- type ExternalPluginHookFunctionsVariant<TContext extends PluginContext = PluginContext, TBuildVariant extends UnpluginBuildVariant = UnpluginBuildVariant> = {
850
- [TKey in keyof BuildPlugin<TContext, TBuildVariant> & string as `${TBuildVariant}:${TKey}`]: BuildPlugin<TContext, TBuildVariant>[TKey];
851
- };
852
- type ExternalPluginHookFunctions<TContext extends PluginContext> = ExternalPluginHookFunctionsVariant<TContext, "vite"> & ExternalPluginHookFunctionsVariant<TContext, "esbuild"> & ExternalPluginHookFunctionsVariant<TContext, "rolldown"> & ExternalPluginHookFunctionsVariant<TContext, "rollup"> & ExternalPluginHookFunctionsVariant<TContext, "webpack"> & ExternalPluginHookFunctionsVariant<TContext, "rspack"> & ExternalPluginHookFunctionsVariant<TContext, "farm">;
853
- type PluginHookFunctions<TContext extends PluginContext = PluginContext> = BasePluginHookFunctions<TContext> & ExternalPluginHookFunctions<TContext>;
854
- type PluginHooks<TContext extends PluginContext = PluginContext> = {
855
- [TKey in keyof BasePluginHookFunctions<TContext>]: PluginHook<BasePluginHookFunctions<TContext>[TKey]>;
1079
+ type PluginHooks<TContext extends PluginContext> = {
1080
+ [TPluginHook in keyof PluginHookFunctions<TContext>]?: PluginHook<PluginHookFunctions<TContext>[TPluginHook]>;
856
1081
  } & {
857
- /**
858
- * A function that returns configuration options to be merged with the build context's options.
859
- *
860
- * @remarks
861
- * 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.
862
- *
863
- * @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.
864
- *
865
- * @see https://vitejs.dev/guide/api-plugin#config
866
- *
867
- * @param this - The build context.
868
- * @param config - The partial configuration object to be modified.
869
- * @returns A promise that resolves to a partial configuration object.
870
- */
871
- config: PluginHook<(this: UnresolvedContext<TContext["config"]>) => MaybePromise<ConfigResult<TContext>>> | ConfigResult<TContext>;
872
- /**
873
- * A hook that is called to transform the source code.
874
- *
875
- * @param this - The build context, unplugin build context, and unplugin context.
876
- * @param code - The source code to transform.
877
- * @param id - The identifier of the source code.
878
- * @returns A promise that resolves when the hook is complete.
879
- */
880
- transform: PluginHook<(this: BuildPluginContext<TContext["config"]> & TContext, code: string, id: string) => MaybePromise<TransformResult$1>, "code" | "id">;
881
- /**
882
- * A hook that is called to load the source code.
883
- *
884
- * @param this - The build context, unplugin build context, and unplugin context.
885
- * @param id - The identifier of the source code.
886
- * @returns A promise that resolves when the hook is complete.
887
- */
888
- load: PluginHook<(this: BuildPluginContext<TContext["config"]> & TContext, id: string) => MaybePromise<TransformResult$1>, "id">;
889
- /**
890
- * A hook that is called to resolve the identifier of the source code.
891
- *
892
- * @param this - The build context, unplugin build context, and unplugin context.
893
- * @param id - The identifier of the source code.
894
- * @param importer - The importer of the source code.
895
- * @param options - The options for resolving the identifier.
896
- * @returns A promise that resolves when the hook is complete.
897
- */
898
- resolveId: PluginHook<(this: BuildPluginContext<TContext["config"]> & TContext, id: string, importer: string | undefined, options: {
899
- isEntry: boolean;
900
- }) => MaybePromise<string | ExternalIdResult | null | undefined>, "id">;
1082
+ transform: PluginHook<PluginHookFunctions<TContext>["transform"], "code" | "id">;
1083
+ load: PluginHook<PluginHookFunctions<TContext>["load"], "id">;
1084
+ resolveId: PluginHook<PluginHookFunctions<TContext>["resolveId"], "id">;
901
1085
  };
902
- type PluginBuildPlugins<TContext extends PluginContext = PluginContext> = {
903
- [TBuildVariant in UnpluginBuildVariant]?: BuildPlugin<TContext, TBuildVariant>;
1086
+ type DeepPartial<T> = {
1087
+ [K in keyof T]?: DeepPartial<T[K]>;
904
1088
  };
905
- interface Plugin<TContext extends PluginContext<ResolvedConfig> = PluginContext<ResolvedConfig>> extends Partial<PluginHooks<TContext>>, PluginBuildPlugins<TContext> {
1089
+ type Plugin<TContext extends PluginContext<ResolvedConfig> = PluginContext<ResolvedConfig>> = Partial<PluginHooks<TContext>> & {
906
1090
  /**
907
1091
  * The name of the plugin, for use in deduplication, error messages and logs.
908
1092
  */
@@ -950,7 +1134,25 @@ interface Plugin<TContext extends PluginContext<ResolvedConfig> = PluginContext<
950
1134
  * @returns `true` if the plugin should be active in the specified environment, `false` otherwise.
951
1135
  */
952
1136
  applyToEnvironment?: (environment: EnvironmentResolvedConfig) => boolean | PluginConfig<TContext>;
953
- }
1137
+ /**
1138
+ * A function that returns configuration options to be merged with the build context's options.
1139
+ *
1140
+ * @remarks
1141
+ * 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.
1142
+ *
1143
+ * @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.
1144
+ *
1145
+ * @see https://vitejs.dev/guide/api-plugin#config
1146
+ *
1147
+ * @param this - The build context.
1148
+ * @param config - The partial configuration object to be modified.
1149
+ * @returns A promise that resolves to a partial configuration object.
1150
+ */
1151
+ config?: PluginHook<(this: UnresolvedContext<TContext["config"]>) => MaybePromise<DeepPartial<TContext["config"]> & Record<string, any>>> | (DeepPartial<TContext["config"]> & Record<string, any>);
1152
+ } & {
1153
+ [TBuilderVariant in BuilderVariant]?: InferUnpluginOptions<TContext, TBuilderVariant>;
1154
+ };
1155
+ type PluginHookFields<TContext extends PluginContext = PluginContext> = keyof PluginHookFunctions<TContext>;
954
1156
 
955
1157
  type ReflectionMode = "default" | "explicit" | "never";
956
1158
  type RawReflectionMode = ReflectionMode | "" | boolean | string | string[] | undefined;
@@ -1040,7 +1242,7 @@ type PluginConfigObject<TContext extends PluginContext = PluginContext, TOptions
1040
1242
  * A configuration tuple for a Powerlines plugin.
1041
1243
  */
1042
1244
  type PluginConfig<TContext extends PluginContext = PluginContext> = string | PluginFactory<TContext, void> | Plugin<TContext> | PluginConfigTuple<TContext> | PluginConfigObject<TContext> | Promise<PluginConfig<TContext>> | PluginConfig<TContext>[];
1043
- type PartialPlugin<in out TContext extends PluginContext = PluginContext> = DeepPartial$1<Plugin<TContext>>;
1245
+ type PartialPlugin<TContext extends PluginContext = PluginContext> = DeepPartial$1<Plugin<TContext>>;
1044
1246
  type PartialPluginFactory<in out TContext extends PluginContext = PluginContext, TOptions = any> = (options: TOptions) => MaybePromise<PartialPlugin<TContext> | PartialPlugin<TContext>[]>;
1045
1247
  type ProjectType = "application" | "library";
1046
1248
  interface DeployConfig {
@@ -1366,6 +1568,16 @@ interface UserConfig<TBuildConfig extends BuildConfig = BuildConfig, TBuildResol
1366
1568
  override?: Partial<TBuildResolvedConfig>;
1367
1569
  };
1368
1570
  }
1571
+ type WebpackUserConfig = UserConfig<WebpackBuildConfig, WebpackResolvedBuildConfig, "webpack">;
1572
+ type RspackUserConfig = UserConfig<RspackBuildConfig, RspackResolvedBuildConfig, "rspack">;
1573
+ type RollupUserConfig = UserConfig<RollupBuildConfig, RollupResolvedBuildConfig, "rollup">;
1574
+ type RolldownUserConfig = UserConfig<RolldownBuildConfig, RolldownResolvedBuildConfig, "rolldown">;
1575
+ type ViteUserConfig = UserConfig<ViteBuildConfig, ViteResolvedBuildConfig, "vite">;
1576
+ type ESBuildUserConfig = UserConfig<ESBuildBuildConfig, ESBuildResolvedBuildConfig, "esbuild">;
1577
+ type UnbuildUserConfig = UserConfig<UnbuildBuildConfig, UnbuildResolvedBuildConfig, "unbuild">;
1578
+ type TsupUserConfig = UserConfig<TsupBuildConfig, TsupResolvedBuildConfig, "tsup">;
1579
+ type TsdownUserConfig = UserConfig<TsdownBuildConfig, TsdownResolvedBuildConfig, "tsdown">;
1580
+ type FarmUserConfig = UserConfig<FarmBuildConfig, FarmResolvedBuildConfig, "farm">;
1369
1581
  type PowerlinesCommand = "new" | "prepare" | "build" | "lint" | "test" | "docs" | "deploy" | "clean";
1370
1582
  /**
1371
1583
  * The configuration provided while executing Powerlines commands.
@@ -1376,6 +1588,52 @@ type InlineConfig<TUserConfig extends UserConfig = UserConfig> = Partial<TUserCo
1376
1588
  */
1377
1589
  command: PowerlinesCommand;
1378
1590
  };
1591
+ type NewInlineConfig<TUserConfig extends UserConfig = UserConfig> = InlineConfig<TUserConfig> & Required<Pick<InlineConfig<TUserConfig>, "root">> & {
1592
+ /**
1593
+ * A string identifier for the Powerlines command being executed
1594
+ */
1595
+ command: "new";
1596
+ /**
1597
+ * The package name (from the \`package.json\`) for the project that will be used in the \`new\` command to create a new project based on this configuration
1598
+ */
1599
+ packageName?: string;
1600
+ };
1601
+ type CleanInlineConfig<TUserConfig extends UserConfig = UserConfig> = InlineConfig<TUserConfig> & {
1602
+ /**
1603
+ * A string identifier for the Powerlines command being executed
1604
+ */
1605
+ command: "clean";
1606
+ };
1607
+ type PrepareInlineConfig<TUserConfig extends UserConfig = UserConfig> = InlineConfig<TUserConfig> & {
1608
+ /**
1609
+ * A string identifier for the Powerlines command being executed
1610
+ */
1611
+ command: "prepare";
1612
+ };
1613
+ type BuildInlineConfig<TUserConfig extends UserConfig = UserConfig> = InlineConfig<TUserConfig> & {
1614
+ /**
1615
+ * A string identifier for the Powerlines command being executed
1616
+ */
1617
+ command: "build";
1618
+ };
1619
+ type LintInlineConfig<TUserConfig extends UserConfig = UserConfig> = InlineConfig<TUserConfig> & {
1620
+ /**
1621
+ * A string identifier for the Powerlines command being executed
1622
+ */
1623
+ command: "lint";
1624
+ };
1625
+ type DocsInlineConfig<TUserConfig extends UserConfig = UserConfig> = InlineConfig<TUserConfig> & {
1626
+ /**
1627
+ * A string identifier for the Powerlines command being executed
1628
+ */
1629
+ command: "docs";
1630
+ };
1631
+ type DeployInlineConfig<TUserConfig extends UserConfig = UserConfig> = InlineConfig<TUserConfig> & {
1632
+ /**
1633
+ * A string identifier for the Powerlines command being executed
1634
+ */
1635
+ command: "deploy";
1636
+ };
1379
1637
 
1380
1638
  interface MetaInfo {
1381
1639
  /**
@@ -1410,6 +1668,9 @@ interface TransformResult {
1410
1668
  code: string;
1411
1669
  map: SourceMap | null;
1412
1670
  }
1671
+ interface SelectHooksOptions {
1672
+ order?: "pre" | "post" | "normal";
1673
+ }
1413
1674
  /**
1414
1675
  * Options for initializing or updating the context with new configuration values
1415
1676
  */
@@ -1746,6 +2007,112 @@ type Context<TResolvedConfig extends ResolvedConfig = ResolvedConfig> = Omit<Unr
1746
2007
  */
1747
2008
  config: TResolvedConfig;
1748
2009
  };
2010
+ interface APIContext<TResolvedConfig extends ResolvedConfig = ResolvedConfig> extends Context<TResolvedConfig> {
2011
+ /**
2012
+ * The expected plugins options for the Powerlines project.
2013
+ *
2014
+ * @remarks
2015
+ * This is a record of plugin identifiers to their respective options. This field is populated by the Powerlines engine during both plugin initialization and the `init` command.
2016
+ */
2017
+ plugins: Plugin<PluginContext<TResolvedConfig>>[];
2018
+ /**
2019
+ * A function to add a plugin to the context and update the configuration options
2020
+ */
2021
+ addPlugin: (plugin: Plugin<PluginContext<TResolvedConfig>>) => Promise<void>;
2022
+ /**
2023
+ * A table for storing the current context for each configured environment
2024
+ */
2025
+ environments: Record<string, EnvironmentContext<TResolvedConfig>>;
2026
+ /**
2027
+ * Retrieves the context for a specific environment by name
2028
+ *
2029
+ * @throws Will throw an error if the environment does not exist
2030
+ *
2031
+ * @param name - The name of the environment to retrieve. If not provided, the default environment is returned.
2032
+ * @returns A promise that resolves to the environment context.
2033
+ *
2034
+ * @example
2035
+ * ```ts
2036
+ * const devEnv = await apiContext.getEnvironment("development");
2037
+ * const defaultEnv = await apiContext.getEnvironment();
2038
+ * ```
2039
+ */
2040
+ getEnvironment: (name?: string) => Promise<EnvironmentContext<TResolvedConfig>>;
2041
+ /**
2042
+ * Safely retrieves the context for a specific environment by name
2043
+ *
2044
+ * @param name - The name of the environment to retrieve. If not provided, the default environment is returned.
2045
+ * @returns A promise that resolves to the environment context, or undefined if the environment does not exist.
2046
+ *
2047
+ * @example
2048
+ * ```ts
2049
+ * const devEnv = await apiContext.getEnvironmentSafe("development");
2050
+ * const defaultEnv = await apiContext.getEnvironmentSafe();
2051
+ * ```
2052
+ *
2053
+ * @remarks
2054
+ * This method is similar to `getEnvironment`, but it returns `undefined` instead of throwing an error if the specified environment does not exist.
2055
+ * This can be useful in scenarios where the existence of an environment is optional or uncertain.
2056
+ *
2057
+ * ```ts
2058
+ * const testEnv = await apiContext.getEnvironmentSafe("test");
2059
+ * if (testEnv) {
2060
+ * // Environment exists, safe to use it
2061
+ * } else {
2062
+ * // Environment does not exist, handle accordingly
2063
+ * }
2064
+ * ```
2065
+ *
2066
+ * Using this method helps avoid unhandled exceptions in cases where an environment might not be defined.
2067
+ */
2068
+ getEnvironmentSafe: (name?: string) => Promise<EnvironmentContext<TResolvedConfig> | undefined>;
2069
+ /**
2070
+ * A function to copy the context and update the fields for a specific environment
2071
+ *
2072
+ * @param environment - The environment configuration to use.
2073
+ * @returns A new context instance with the updated environment.
2074
+ */
2075
+ in: (environment: EnvironmentResolvedConfig) => Promise<EnvironmentContext<TResolvedConfig>>;
2076
+ /**
2077
+ * A function to merge all configured environments into a single context
2078
+ *
2079
+ * @returns A promise that resolves to the merged environment context.
2080
+ */
2081
+ toEnvironment: () => Promise<EnvironmentContext<TResolvedConfig>>;
2082
+ }
2083
+ interface EnvironmentContextPlugin<TResolvedConfig extends ResolvedConfig = ResolvedConfig> {
2084
+ plugin: Plugin<PluginContext<TResolvedConfig>>;
2085
+ context: PluginContext<TResolvedConfig>;
2086
+ }
2087
+ type SelectHookResultItem<TContext extends PluginContext, TKey extends string> = InferHooksListItem<TContext, TKey> & {
2088
+ context: TContext;
2089
+ };
2090
+ type SelectHookResult<TContext extends PluginContext, TKey extends string> = SelectHookResultItem<TContext, TKey>[];
2091
+ interface EnvironmentContext<TResolvedConfig extends ResolvedConfig = ResolvedConfig> extends Context<TResolvedConfig> {
2092
+ /**
2093
+ * The expected plugins options for the Powerlines project.
2094
+ *
2095
+ * @remarks
2096
+ * This is a record of plugin identifiers to their respective options. This field is populated by the Powerlines engine during both plugin initialization and the `init` command.
2097
+ */
2098
+ plugins: EnvironmentContextPlugin<TResolvedConfig>[];
2099
+ /**
2100
+ * A function to add a plugin to the context and update the configuration options
2101
+ */
2102
+ addPlugin: (plugin: Plugin<PluginContext<TResolvedConfig>>) => Promise<void>;
2103
+ /**
2104
+ * The environment specific resolved configuration
2105
+ */
2106
+ environment: EnvironmentResolvedConfig;
2107
+ /**
2108
+ * A table holding references to hook functions registered by plugins
2109
+ */
2110
+ hooks: HooksList<PluginContext<TResolvedConfig>>;
2111
+ /**
2112
+ * Retrieves the hook handlers for a specific hook name
2113
+ */
2114
+ selectHooks: <TKey extends string>(key: TKey, options?: SelectHooksOptions) => SelectHookResult<PluginContext<TResolvedConfig>, TKey>;
2115
+ }
1749
2116
  interface PluginContext<out TResolvedConfig extends ResolvedConfig = ResolvedConfig> extends Context<TResolvedConfig>, UnpluginContext {
1750
2117
  /**
1751
2118
  * The environment specific resolved configuration
@@ -1760,5 +2127,6 @@ interface PluginContext<out TResolvedConfig extends ResolvedConfig = ResolvedCon
1760
2127
  logger: LogFn;
1761
2128
  }
1762
2129
  type BuildPluginContext<TResolvedConfig extends ResolvedConfig = ResolvedConfig> = UnpluginBuildContext & PluginContext<TResolvedConfig>;
2130
+ type WithUnpluginBuildContext<TContext extends PluginContext> = UnpluginBuildContext & TContext;
1763
2131
 
1764
- export type { BuildVariant as B, ConfigResult as C, ExternalPluginHookFunctions as E, PluginContext as P, ResolvedConfig as R, TypesResult as T, UnresolvedContext as U, Plugin as a, PluginFactory as b, PartialPluginFactory as c, PartialPlugin as d, BasePluginHookFunctions as e, PluginHookFunctions as f, PluginHookObject as g, PluginConfigObject as h, PluginConfigTuple as i, PluginConfig as j, PluginHook as k, EnvironmentConfig as l, EnvironmentResolvedConfig as m };
2132
+ export type { BuilderVariant as B, EnvironmentConfig as E, HookFields as H, PluginContext as P, ResolvedConfig as R, TypesResult as T, UnresolvedContext as U, Plugin as a, PluginFactory as b, PartialPluginFactory as c, PartialPlugin as d, PluginConfigObject as e, PluginConfigTuple as f, PluginConfig as g, PluginHookObject as h, PluginHook as i, PluginHookFields as j, PluginHooksListItem as k, UnpluginBuilderVariant as l, UnpluginHooksListItem as m, PluginHooks as n, EnvironmentResolvedConfig as o, UnpluginOptions as p };