powerlines 0.24.8 → 0.25.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 (460) hide show
  1. package/dist/{api-C32Buv5_.d.ts → api-BTK8aYwE.d.cts} +1 -1
  2. package/dist/{api-wzd5AREv.d.cts → api-eyrYBmQh.d.ts} +1 -1
  3. package/dist/api.cjs +8 -6
  4. package/dist/api.d.cts +20 -22
  5. package/dist/api.d.ts +20 -22
  6. package/dist/api.js +7 -5
  7. package/dist/astro.cjs +12 -10
  8. package/dist/astro.d.cts +19 -21
  9. package/dist/astro.d.ts +19 -21
  10. package/dist/astro.js +10 -8
  11. package/dist/{chunk-JKBJF3UI.js → chunk-2MYPFASJ.js} +2 -0
  12. package/dist/chunk-2VIXD2XB.js +3 -0
  13. package/dist/{chunk-OB7MYWHE.js → chunk-44PO64SX.js} +4 -2
  14. package/dist/chunk-4JCNAKOE.cjs +4 -0
  15. package/dist/{chunk-QH4TS5V4.cjs → chunk-6MFZ436T.cjs} +978 -1032
  16. package/dist/chunk-6ZGIV2SU.cjs +4 -0
  17. package/dist/chunk-7BZQBW77.cjs +4 -0
  18. package/dist/{chunk-JQCWV4DT.js → chunk-7LKYXMB3.js} +2 -0
  19. package/dist/{chunk-SHUYVCID.js → chunk-7QVYU63E.js} +2 -0
  20. package/dist/chunk-AFJCY3R6.js +3 -0
  21. package/dist/chunk-AXIRZAL7.js +3 -0
  22. package/dist/chunk-BTNHSS2P.cjs +13 -0
  23. package/dist/{chunk-FQXHIKCM.cjs → chunk-C2U4ATHO.cjs} +9 -7
  24. package/dist/chunk-DFLNRC3B.cjs +4 -0
  25. package/dist/chunk-DS7OM4NX.cjs +4 -0
  26. package/dist/{chunk-W5X3ZEZ5.js → chunk-EBXVKPUX.js} +2 -0
  27. package/dist/{chunk-X74SYWFL.cjs → chunk-G2EHTXK6.cjs} +9 -7
  28. package/dist/chunk-GIE6OE3X.js +3 -0
  29. package/dist/chunk-HJW7OH6E.js +3 -0
  30. package/dist/{chunk-MOXO6WJO.js → chunk-HSIMIWOH.js} +3 -1
  31. package/dist/{chunk-5IBA5HC2.cjs → chunk-HTJKPEWU.cjs} +6 -4
  32. package/dist/chunk-IHUNA3MO.cjs +4 -0
  33. package/dist/chunk-JU2HWIWS.js +12 -0
  34. package/dist/{chunk-BCHFSOQ4.js → chunk-LQXE5JHF.js} +906 -957
  35. package/dist/chunk-MBBNZS6K.cjs +16 -0
  36. package/dist/{chunk-3TNZWTLG.js → chunk-NNADGQRN.js} +5 -3
  37. package/dist/chunk-OYASPHNL.js +3 -0
  38. package/dist/chunk-PCCFAZML.js +3 -0
  39. package/dist/{chunk-USNT2KNT.cjs → chunk-PK6SKIKE.cjs} +2 -0
  40. package/dist/{chunk-ETKZMGLN.cjs → chunk-PSTCR335.cjs} +2 -0
  41. package/dist/chunk-Q7EJVZVI.cjs +4 -0
  42. package/dist/{chunk-CJSGAITR.js → chunk-S7MXT5A2.js} +3 -1
  43. package/dist/{chunk-7RWEBVQC.cjs → chunk-SDVEUTY2.cjs} +13 -11
  44. package/dist/{chunk-OLCL34MI.js → chunk-SYDUPBME.js} +6 -4
  45. package/dist/chunk-TLHFXGYV.js +3 -0
  46. package/dist/chunk-TP5MEMLG.cjs +12 -0
  47. package/dist/chunk-VNRXLY2T.js +3 -0
  48. package/dist/chunk-VQCQRLGM.cjs +4 -0
  49. package/dist/chunk-XZO6ZJQP.cjs +4 -0
  50. package/dist/{chunk-XP7OML7S.cjs → chunk-YUX7LOBU.cjs} +2 -0
  51. package/dist/chunk-YZZUOOPS.cjs +4 -0
  52. package/dist/chunk-Z5H7LD6W.js +3 -0
  53. package/dist/{chunk-VBR53KGY.js → chunk-Z5UEYORO.js} +5 -3
  54. package/dist/{chunk-PAMSESZV.cjs → chunk-Z6ARQDHR.cjs} +2 -0
  55. package/dist/config.cjs +5 -3
  56. package/dist/config.d.cts +19 -21
  57. package/dist/config.d.ts +19 -21
  58. package/dist/config.js +4 -2
  59. package/dist/{resolved-CSqGKlA5.d.cts → context-TizkCfOv.d.cts} +848 -849
  60. package/dist/{resolved-BABoCnXm.d.ts → context-jhcT1Vi1.d.ts} +848 -849
  61. package/dist/esbuild.cjs +13 -11
  62. package/dist/esbuild.d.cts +19 -21
  63. package/dist/esbuild.d.ts +19 -21
  64. package/dist/esbuild.js +10 -8
  65. package/dist/farm.cjs +9 -7
  66. package/dist/farm.d.cts +19 -21
  67. package/dist/farm.d.ts +19 -21
  68. package/dist/farm.js +8 -6
  69. package/dist/index.cjs +39 -41
  70. package/dist/index.d.cts +30 -55
  71. package/dist/index.d.ts +30 -55
  72. package/dist/index.js +20 -18
  73. package/dist/lib/{api-CDUN9en8.d.ts → api-CCOhyMZo.d.cts} +1 -1
  74. package/dist/lib/{api-BRMITKt-.d.cts → api-CpJJXdtL.d.ts} +1 -1
  75. package/dist/lib/build/esbuild.cjs +5 -5
  76. package/dist/lib/build/esbuild.d.cts +2 -2
  77. package/dist/lib/build/esbuild.d.ts +2 -2
  78. package/dist/lib/build/esbuild.js +2 -2
  79. package/dist/lib/build/index.cjs +25 -25
  80. package/dist/lib/build/index.d.cts +4 -4
  81. package/dist/lib/build/index.d.ts +4 -4
  82. package/dist/lib/build/index.js +9 -9
  83. package/dist/lib/build/rolldown.cjs +3 -3
  84. package/dist/lib/build/rolldown.d.cts +2 -2
  85. package/dist/lib/build/rolldown.d.ts +2 -2
  86. package/dist/lib/build/rolldown.js +2 -2
  87. package/dist/lib/build/rollup.cjs +3 -3
  88. package/dist/lib/build/rollup.d.cts +2 -2
  89. package/dist/lib/build/rollup.d.ts +2 -2
  90. package/dist/lib/build/rollup.js +1 -1
  91. package/dist/lib/build/rspack.cjs +2 -2
  92. package/dist/lib/build/rspack.d.cts +2 -2
  93. package/dist/lib/build/rspack.d.ts +2 -2
  94. package/dist/lib/build/rspack.js +1 -1
  95. package/dist/lib/build/tsup.cjs +6 -6
  96. package/dist/lib/build/tsup.d.cts +2 -2
  97. package/dist/lib/build/tsup.d.ts +2 -2
  98. package/dist/lib/build/tsup.js +3 -3
  99. package/dist/lib/build/unbuild.cjs +5 -5
  100. package/dist/lib/build/unbuild.d.cts +4 -4
  101. package/dist/lib/build/unbuild.d.ts +4 -4
  102. package/dist/lib/build/unbuild.js +2 -2
  103. package/dist/lib/build/vite.cjs +5 -5
  104. package/dist/lib/build/vite.d.cts +2 -2
  105. package/dist/lib/build/vite.d.ts +2 -2
  106. package/dist/lib/build/vite.js +3 -3
  107. package/dist/lib/build/webpack.cjs +2 -2
  108. package/dist/lib/build/webpack.d.cts +2 -2
  109. package/dist/lib/build/webpack.d.ts +2 -2
  110. package/dist/lib/build/webpack.js +1 -1
  111. package/dist/lib/chunk-3T56KQ7U.cjs +49 -0
  112. package/dist/lib/{chunk-PZLO6FZW.js → chunk-3W53W5J2.js} +2 -2
  113. package/dist/lib/chunk-4W6WV35V.js +108 -0
  114. package/dist/lib/chunk-6OYSDQXE.cjs +139 -0
  115. package/dist/lib/{chunk-EV357RFB.cjs → chunk-7MHUTBEC.cjs} +1 -3
  116. package/dist/lib/{chunk-A2NFSQ5K.js → chunk-7OVZZWGY.js} +1 -1
  117. package/dist/lib/chunk-A2NW7WAN.js +47 -0
  118. package/dist/lib/chunk-D6MI2V6R.cjs +115 -0
  119. package/dist/lib/{chunk-VHLINWXG.js → chunk-DLVVEHMU.js} +1 -1
  120. package/dist/lib/{chunk-XLYMVIVD.cjs → chunk-DNQBXFNE.cjs} +10 -10
  121. package/dist/lib/{chunk-UGVHYKKN.js → chunk-DYLE5FD3.js} +39 -2
  122. package/dist/lib/{chunk-AKBAX4FH.js → chunk-EN52JYUK.js} +1 -1
  123. package/dist/lib/{chunk-JYDGFQIV.cjs → chunk-F2CXZUSB.cjs} +1 -1
  124. package/dist/lib/{chunk-7VJ42H2I.cjs → chunk-HRRI4KOM.cjs} +1 -3
  125. package/dist/lib/{chunk-LPRZ3HD4.cjs → chunk-IXTLRVAK.cjs} +3 -3
  126. package/dist/lib/{chunk-SYF7QG2J.js → chunk-J3BW52BU.js} +1 -1
  127. package/dist/lib/chunk-KFDNKOXM.js +56 -0
  128. package/dist/lib/chunk-L56XA427.js +137 -0
  129. package/dist/lib/{chunk-6PPZCPME.cjs → chunk-LOW2TIQ6.cjs} +2 -2
  130. package/dist/lib/{chunk-TMZCGC5U.js → chunk-MI55FDCZ.js} +1 -1
  131. package/dist/lib/{chunk-DUZJ7ZF2.cjs → chunk-MKKWFHGE.cjs} +2 -2
  132. package/dist/lib/{chunk-ISBHXSDH.cjs → chunk-N5XEKCVW.cjs} +1 -1
  133. package/dist/lib/{chunk-XZFEHPYE.js → chunk-N5YLKWC2.js} +1 -1
  134. package/dist/lib/chunk-NIRFKQAD.js +845 -0
  135. package/dist/lib/{chunk-YMHOAMCU.cjs → chunk-NLJR4WIX.cjs} +41 -4
  136. package/dist/lib/{chunk-L3HESXYF.cjs → chunk-NUE5DIH3.cjs} +3 -3
  137. package/dist/lib/chunk-OBA5U4Y2.js +1059 -0
  138. package/dist/lib/{chunk-FQLZZYYO.js → chunk-OEF6EHQV.js} +1 -3
  139. package/dist/lib/{chunk-WTTBXYFQ.js → chunk-OFXWRM3U.js} +2 -2
  140. package/dist/lib/chunk-ONETLSPO.js +85 -0
  141. package/dist/lib/{chunk-2OV26JXJ.cjs → chunk-PQRWG64T.cjs} +3 -3
  142. package/dist/lib/chunk-R33US3PV.cjs +1081 -0
  143. package/dist/lib/{chunk-OA7OL7HF.cjs → chunk-SFEEJZLK.cjs} +38 -66
  144. package/dist/lib/{chunk-H6EOZSIZ.js → chunk-TAVG226Z.js} +1 -1
  145. package/dist/lib/{chunk-DALRRHB4.cjs → chunk-TSFG3WEA.cjs} +1 -1
  146. package/dist/lib/{chunk-RMA2PMP7.cjs → chunk-TZCC5IWH.cjs} +3 -3
  147. package/dist/lib/chunk-VHCBD2IS.js +149 -0
  148. package/dist/lib/{chunk-HY6DNFCT.js → chunk-VODWHWD6.js} +2 -2
  149. package/dist/lib/{chunk-2X5DUDNT.js → chunk-W6GWSJ22.js} +2 -2
  150. package/dist/lib/chunk-WBSA6OG6.cjs +860 -0
  151. package/dist/lib/{chunk-TOCNXURI.cjs → chunk-WCXA5WFX.cjs} +4 -4
  152. package/dist/lib/{chunk-6I5PL7H2.js → chunk-WGSZ4X6N.js} +1 -3
  153. package/dist/lib/{chunk-T2KQZC5K.js → chunk-WLDQUTFD.js} +27 -54
  154. package/dist/lib/{chunk-AOHJEL2Q.js → chunk-WOKPJMGJ.js} +3 -3
  155. package/dist/lib/{chunk-TDJNFAOV.cjs → chunk-X6JDYLWM.cjs} +1 -1
  156. package/dist/lib/chunk-XLHFUATD.cjs +151 -0
  157. package/dist/lib/chunk-XUYQYUWZ.cjs +87 -0
  158. package/dist/lib/chunk-YYEAV24J.cjs +67 -0
  159. package/dist/lib/{config-D8KrE7SZ.d.cts → config-Cqxh4V21.d.cts} +58 -475
  160. package/dist/lib/{config-DBIFdRoq.d.ts → config-D-WwQL-4.d.ts} +58 -475
  161. package/dist/lib/config-file.d.cts +2 -2
  162. package/dist/lib/config-file.d.ts +2 -2
  163. package/dist/lib/contexts/api-context.cjs +12 -7
  164. package/dist/lib/contexts/api-context.d.cts +27 -4
  165. package/dist/lib/contexts/api-context.d.ts +27 -4
  166. package/dist/lib/contexts/api-context.js +11 -6
  167. package/dist/lib/contexts/context.cjs +10 -5
  168. package/dist/lib/contexts/context.d.cts +7 -7
  169. package/dist/lib/contexts/context.d.ts +7 -7
  170. package/dist/lib/contexts/context.js +9 -4
  171. package/dist/lib/contexts/environment-context.cjs +11 -6
  172. package/dist/lib/contexts/environment-context.d.cts +4 -4
  173. package/dist/lib/contexts/environment-context.d.ts +4 -4
  174. package/dist/lib/contexts/environment-context.js +10 -5
  175. package/dist/lib/contexts/index.cjs +14 -9
  176. package/dist/lib/contexts/index.d.cts +4 -4
  177. package/dist/lib/contexts/index.d.ts +4 -4
  178. package/dist/lib/contexts/index.js +11 -6
  179. package/dist/lib/contexts/plugin-context.d.cts +4 -4
  180. package/dist/lib/contexts/plugin-context.d.ts +4 -4
  181. package/dist/lib/entry.cjs +9 -9
  182. package/dist/lib/entry.d.cts +2 -2
  183. package/dist/lib/entry.d.ts +2 -2
  184. package/dist/lib/entry.js +1 -1
  185. package/dist/lib/fs/helpers.cjs +47 -0
  186. package/dist/lib/fs/helpers.d.cts +74 -0
  187. package/dist/lib/fs/helpers.d.ts +74 -0
  188. package/dist/lib/fs/helpers.js +2 -0
  189. package/dist/lib/fs/index.cjs +17 -0
  190. package/dist/lib/fs/index.d.cts +33 -0
  191. package/dist/lib/fs/index.d.ts +33 -0
  192. package/dist/lib/fs/index.js +8 -0
  193. package/dist/lib/fs/storage/base.cjs +11 -0
  194. package/dist/lib/fs/storage/base.d.cts +138 -0
  195. package/dist/lib/fs/storage/base.d.ts +138 -0
  196. package/dist/lib/fs/storage/base.js +2 -0
  197. package/dist/lib/fs/storage/file-system.cjs +13 -0
  198. package/dist/lib/fs/storage/file-system.d.cts +90 -0
  199. package/dist/lib/fs/storage/file-system.d.ts +90 -0
  200. package/dist/lib/fs/storage/file-system.js +4 -0
  201. package/dist/lib/fs/storage/index.cjs +22 -0
  202. package/dist/lib/fs/storage/index.d.cts +6 -0
  203. package/dist/lib/fs/storage/index.d.ts +6 -0
  204. package/dist/lib/fs/storage/index.js +5 -0
  205. package/dist/lib/fs/storage/virtual.cjs +12 -0
  206. package/dist/lib/fs/storage/virtual.d.cts +66 -0
  207. package/dist/lib/fs/storage/virtual.d.ts +66 -0
  208. package/dist/lib/fs/storage/virtual.js +3 -0
  209. package/dist/lib/fs/vfs.cjs +16 -0
  210. package/dist/lib/fs/vfs.d.cts +247 -0
  211. package/dist/lib/fs/vfs.d.ts +247 -0
  212. package/dist/lib/fs/vfs.js +7 -0
  213. package/dist/lib/fs-Dg-aTfiN.d.cts +378 -0
  214. package/dist/lib/fs-Dg-aTfiN.d.ts +378 -0
  215. package/dist/lib/index.cjs +62 -68
  216. package/dist/lib/index.d.cts +18 -356
  217. package/dist/lib/index.d.ts +18 -356
  218. package/dist/lib/index.js +19 -13
  219. package/dist/lib/{internal-CaGANOWK.d.cts → internal-Cl7s1iAA.d.cts} +2 -2
  220. package/dist/lib/{internal-1qCyw7bA.d.ts → internal-W5pvS6e9.d.ts} +2 -2
  221. package/dist/lib/logger.d.cts +2 -2
  222. package/dist/lib/logger.d.ts +2 -2
  223. package/dist/lib/typescript/import-transformer.cjs +7 -45
  224. package/dist/lib/typescript/import-transformer.d.cts +2 -2
  225. package/dist/lib/typescript/import-transformer.d.ts +2 -2
  226. package/dist/lib/typescript/import-transformer.js +2 -47
  227. package/dist/lib/typescript/index.cjs +10 -22
  228. package/dist/lib/typescript/index.d.cts +4 -4
  229. package/dist/lib/typescript/index.d.ts +4 -4
  230. package/dist/lib/typescript/index.js +2 -2
  231. package/dist/lib/typescript/ts-morph.cjs +6 -2
  232. package/dist/lib/typescript/ts-morph.d.cts +28 -4
  233. package/dist/lib/typescript/ts-morph.d.ts +28 -4
  234. package/dist/lib/typescript/ts-morph.js +1 -1
  235. package/dist/lib/unplugin/factory.cjs +14 -9
  236. package/dist/lib/unplugin/factory.d.cts +4 -4
  237. package/dist/lib/unplugin/factory.d.ts +4 -4
  238. package/dist/lib/unplugin/factory.js +13 -8
  239. package/dist/lib/unplugin/helpers.d.cts +2 -2
  240. package/dist/lib/unplugin/helpers.d.ts +2 -2
  241. package/dist/lib/unplugin/index.cjs +16 -11
  242. package/dist/lib/unplugin/index.d.cts +4 -4
  243. package/dist/lib/unplugin/index.d.ts +4 -4
  244. package/dist/lib/unplugin/index.js +14 -9
  245. package/dist/lib/unplugin/plugin.cjs +2 -2
  246. package/dist/lib/unplugin/plugin.d.cts +4 -4
  247. package/dist/lib/unplugin/plugin.d.ts +4 -4
  248. package/dist/lib/unplugin/plugin.js +1 -1
  249. package/dist/lib/{unplugin-CEeJqADD.d.ts → unplugin-Cg2NoKj0.d.ts} +2 -2
  250. package/dist/lib/{unplugin-bUSyjd0S.d.cts → unplugin-trF-VLnO.d.cts} +2 -2
  251. package/dist/lib/utilities/bundle.cjs +4 -4
  252. package/dist/lib/utilities/bundle.d.cts +2 -2
  253. package/dist/lib/utilities/bundle.d.ts +2 -2
  254. package/dist/lib/utilities/bundle.js +3 -3
  255. package/dist/lib/utilities/cache.d.cts +2 -2
  256. package/dist/lib/utilities/cache.d.ts +2 -2
  257. package/dist/lib/utilities/file-header.d.cts +2 -2
  258. package/dist/lib/utilities/file-header.d.ts +2 -2
  259. package/dist/lib/utilities/index.cjs +22 -22
  260. package/dist/lib/utilities/index.d.cts +2 -2
  261. package/dist/lib/utilities/index.d.ts +2 -2
  262. package/dist/lib/utilities/index.js +6 -6
  263. package/dist/lib/utilities/meta.cjs +7 -7
  264. package/dist/lib/utilities/meta.d.cts +2 -2
  265. package/dist/lib/utilities/meta.d.ts +2 -2
  266. package/dist/lib/utilities/meta.js +1 -1
  267. package/dist/lib/utilities/resolve.cjs +5 -5
  268. package/dist/lib/utilities/resolve.d.cts +2 -2
  269. package/dist/lib/utilities/resolve.d.ts +2 -2
  270. package/dist/lib/utilities/resolve.js +4 -4
  271. package/dist/lib/utilities/source-file.d.cts +2 -2
  272. package/dist/lib/utilities/source-file.d.ts +2 -2
  273. package/dist/lib/utilities/source-map.d.cts +2 -2
  274. package/dist/lib/utilities/source-map.d.ts +2 -2
  275. package/dist/lib/utilities/worker.d.cts +2 -2
  276. package/dist/lib/utilities/worker.d.ts +2 -2
  277. package/dist/lib/utilities/write-file.d.cts +2 -2
  278. package/dist/lib/utilities/write-file.d.ts +2 -2
  279. package/dist/next.cjs +11 -9
  280. package/dist/next.js +9 -7
  281. package/dist/nuxt.cjs +13 -11
  282. package/dist/nuxt.js +11 -9
  283. package/dist/plugin-utils/{chunk-JHTLGE4X.js → chunk-K2GWRZPV.js} +1 -1
  284. package/dist/plugin-utils/{chunk-HSYQWNIH.cjs → chunk-VWFJOPKC.cjs} +1 -1
  285. package/dist/plugin-utils/{context-BITGF5LZ.d.cts → context-PtfEjz3_.d.cts} +187 -230
  286. package/dist/plugin-utils/{context-BITGF5LZ.d.ts → context-PtfEjz3_.d.ts} +187 -230
  287. package/dist/plugin-utils/context-helpers.d.cts +1 -2
  288. package/dist/plugin-utils/context-helpers.d.ts +1 -2
  289. package/dist/plugin-utils/enforce.d.cts +1 -2
  290. package/dist/plugin-utils/enforce.d.ts +1 -2
  291. package/dist/plugin-utils/extend.d.cts +1 -2
  292. package/dist/plugin-utils/extend.d.ts +1 -2
  293. package/dist/plugin-utils/get-config-path.d.cts +1 -2
  294. package/dist/plugin-utils/get-config-path.d.ts +1 -2
  295. package/dist/plugin-utils/helpers.d.cts +1 -2
  296. package/dist/plugin-utils/helpers.d.ts +1 -2
  297. package/dist/plugin-utils/index.cjs +2 -2
  298. package/dist/plugin-utils/index.d.cts +1 -2
  299. package/dist/plugin-utils/index.d.ts +1 -2
  300. package/dist/plugin-utils/index.js +1 -1
  301. package/dist/plugin-utils/merge.d.cts +1 -2
  302. package/dist/plugin-utils/merge.d.ts +1 -2
  303. package/dist/plugin-utils/paths.cjs +2 -2
  304. package/dist/plugin-utils/paths.d.cts +2 -3
  305. package/dist/plugin-utils/paths.d.ts +2 -3
  306. package/dist/plugin-utils/paths.js +1 -1
  307. package/dist/rolldown.cjs +9 -7
  308. package/dist/rolldown.d.cts +19 -21
  309. package/dist/rolldown.d.ts +19 -21
  310. package/dist/rolldown.js +8 -6
  311. package/dist/rollup.cjs +9 -7
  312. package/dist/rollup.d.cts +19 -21
  313. package/dist/rollup.d.ts +19 -21
  314. package/dist/rollup.js +8 -6
  315. package/dist/rspack.cjs +9 -7
  316. package/dist/rspack.d.cts +18 -20
  317. package/dist/rspack.d.ts +18 -20
  318. package/dist/rspack.js +8 -6
  319. package/dist/tsup.cjs +12 -10
  320. package/dist/tsup.js +10 -8
  321. package/dist/types/api.cjs +3 -1
  322. package/dist/types/api.cjs.map +1 -0
  323. package/dist/types/api.d.cts +20 -22
  324. package/dist/types/api.d.ts +20 -22
  325. package/dist/types/api.js +3 -1
  326. package/dist/types/api.js.map +1 -0
  327. package/dist/types/babel.cjs +3 -1
  328. package/dist/types/babel.cjs.map +1 -0
  329. package/dist/types/babel.d.cts +17 -19
  330. package/dist/types/babel.d.ts +17 -19
  331. package/dist/types/babel.js +3 -1
  332. package/dist/types/babel.js.map +1 -0
  333. package/dist/types/build.cjs +3 -1
  334. package/dist/types/build.cjs.map +1 -0
  335. package/dist/types/build.js +3 -1
  336. package/dist/types/build.js.map +1 -0
  337. package/dist/types/commands.cjs +5 -3
  338. package/dist/types/commands.cjs.map +1 -0
  339. package/dist/types/commands.d.cts +18 -20
  340. package/dist/types/commands.d.ts +18 -20
  341. package/dist/types/commands.js +4 -2
  342. package/dist/types/commands.js.map +1 -0
  343. package/dist/types/config.cjs +3 -1
  344. package/dist/types/config.cjs.map +1 -0
  345. package/dist/types/config.d.cts +2 -4
  346. package/dist/types/config.d.ts +2 -4
  347. package/dist/types/config.js +3 -1
  348. package/dist/types/config.js.map +1 -0
  349. package/dist/types/context.cjs +5 -3
  350. package/dist/types/context.cjs.map +1 -0
  351. package/dist/types/context.d.cts +8 -10
  352. package/dist/types/context.d.ts +8 -10
  353. package/dist/types/context.js +4 -2
  354. package/dist/types/context.js.map +1 -0
  355. package/dist/types/fs.cjs +10 -4
  356. package/dist/types/fs.cjs.map +1 -0
  357. package/dist/types/fs.d.cts +138 -184
  358. package/dist/types/fs.d.ts +138 -184
  359. package/dist/types/fs.js +4 -2
  360. package/dist/types/fs.js.map +1 -0
  361. package/dist/types/hooks.cjs +3 -1
  362. package/dist/types/hooks.cjs.map +1 -0
  363. package/dist/types/hooks.d.cts +19 -21
  364. package/dist/types/hooks.d.ts +19 -21
  365. package/dist/types/hooks.js +3 -1
  366. package/dist/types/hooks.js.map +1 -0
  367. package/dist/types/index.cjs +26 -20
  368. package/dist/types/index.cjs.map +1 -0
  369. package/dist/types/index.d.cts +13 -15
  370. package/dist/types/index.d.ts +13 -15
  371. package/dist/types/index.js +17 -15
  372. package/dist/types/index.js.map +1 -0
  373. package/dist/types/internal.cjs +2 -0
  374. package/dist/types/internal.cjs.map +1 -0
  375. package/dist/types/internal.d.cts +20 -22
  376. package/dist/types/internal.d.ts +20 -22
  377. package/dist/types/internal.js +2 -0
  378. package/dist/types/internal.js.map +1 -0
  379. package/dist/types/plugin.cjs +5 -3
  380. package/dist/types/plugin.cjs.map +1 -0
  381. package/dist/types/plugin.d.cts +9 -11
  382. package/dist/types/plugin.d.ts +9 -11
  383. package/dist/types/plugin.js +4 -2
  384. package/dist/types/plugin.js.map +1 -0
  385. package/dist/types/resolved.cjs +3 -1
  386. package/dist/types/resolved.cjs.map +1 -0
  387. package/dist/types/resolved.d.cts +7 -9
  388. package/dist/types/resolved.d.ts +7 -9
  389. package/dist/types/resolved.js +3 -1
  390. package/dist/types/resolved.js.map +1 -0
  391. package/dist/types/tsconfig.cjs +3 -1
  392. package/dist/types/tsconfig.cjs.map +1 -0
  393. package/dist/types/tsconfig.js +3 -1
  394. package/dist/types/tsconfig.js.map +1 -0
  395. package/dist/types/typedoc.cjs +3 -1
  396. package/dist/types/typedoc.cjs.map +1 -0
  397. package/dist/types/typedoc.js +3 -1
  398. package/dist/types/typedoc.js.map +1 -0
  399. package/dist/types/unplugin.cjs +3 -1
  400. package/dist/types/unplugin.cjs.map +1 -0
  401. package/dist/types/unplugin.d.cts +11 -13
  402. package/dist/types/unplugin.d.ts +11 -13
  403. package/dist/types/unplugin.js +3 -1
  404. package/dist/types/unplugin.js.map +1 -0
  405. package/dist/unloader.cjs +9 -7
  406. package/dist/unloader.d.cts +19 -21
  407. package/dist/unloader.d.ts +19 -21
  408. package/dist/unloader.js +8 -6
  409. package/dist/unplugin.cjs +20 -20
  410. package/dist/unplugin.d.cts +19 -21
  411. package/dist/unplugin.d.ts +19 -21
  412. package/dist/unplugin.js +10 -10
  413. package/dist/vite.cjs +13 -11
  414. package/dist/vite.d.cts +19 -21
  415. package/dist/vite.d.ts +19 -21
  416. package/dist/vite.js +10 -8
  417. package/dist/webpack.cjs +12 -10
  418. package/dist/webpack.d.cts +19 -21
  419. package/dist/webpack.d.ts +19 -21
  420. package/dist/webpack.js +9 -7
  421. package/package.json +72 -19
  422. package/schemas/fs.capnp +4 -59
  423. package/dist/chunk-2NO7N5OW.cjs +0 -2
  424. package/dist/chunk-7GYTTM4M.cjs +0 -2
  425. package/dist/chunk-AENPRFWJ.cjs +0 -2
  426. package/dist/chunk-AYKZK666.cjs +0 -8
  427. package/dist/chunk-BUR2JQ6G.cjs +0 -11
  428. package/dist/chunk-DRXFQCNC.js +0 -1
  429. package/dist/chunk-FNZDWE4L.js +0 -1
  430. package/dist/chunk-GHJU2KGP.cjs +0 -2
  431. package/dist/chunk-GRU7B3QM.cjs +0 -2
  432. package/dist/chunk-HQFZ64VC.cjs +0 -2
  433. package/dist/chunk-J4BQZHTQ.js +0 -1
  434. package/dist/chunk-JGB5YQ2U.js +0 -1
  435. package/dist/chunk-KALR2O2F.cjs +0 -2
  436. package/dist/chunk-LOUZXJFY.cjs +0 -10
  437. package/dist/chunk-OO3YXM72.js +0 -1
  438. package/dist/chunk-QE3WGMAP.js +0 -1
  439. package/dist/chunk-SMNKPH4T.js +0 -1
  440. package/dist/chunk-T2P533I5.js +0 -1
  441. package/dist/chunk-V3MLQDZQ.js +0 -1
  442. package/dist/chunk-VT7NVLLU.js +0 -5
  443. package/dist/chunk-YRJ4MLVL.cjs +0 -2
  444. package/dist/chunk-ZC43PZXS.cjs +0 -2
  445. package/dist/lib/chunk-3MZQ4MQX.cjs +0 -2360
  446. package/dist/lib/chunk-5JAFU45Z.js +0 -2324
  447. package/dist/lib/chunk-HAXL7QE7.js +0 -154
  448. package/dist/lib/chunk-SAS5EPBD.cjs +0 -107
  449. package/dist/lib/chunk-WUYK74EH.cjs +0 -165
  450. package/dist/lib/chunk-YQ3ODCHV.js +0 -105
  451. package/dist/lib/typescript/compiler-host.cjs +0 -164
  452. package/dist/lib/typescript/compiler-host.d.cts +0 -63
  453. package/dist/lib/typescript/compiler-host.d.ts +0 -63
  454. package/dist/lib/typescript/compiler-host.js +0 -156
  455. package/dist/lib/typescript/program.cjs +0 -27
  456. package/dist/lib/typescript/program.d.cts +0 -68
  457. package/dist/lib/typescript/program.d.ts +0 -68
  458. package/dist/lib/typescript/program.js +0 -2
  459. /package/dist/{chunk-2NCILNCH.cjs → lib/chunk-K2SFTPN3.cjs} +0 -0
  460. /package/dist/{chunk-BLNT5INX.js → lib/chunk-NQAHFTUW.js} +0 -0
@@ -1,2324 +0,0 @@
1
- import { CACHE_HASH_LENGTH, PROJECT_ROOT_HASH_LENGTH, getPrefixedProjectRootHash } from './chunk-FQLZZYYO.js';
2
- import { getTsconfigFilePath } from './chunk-ZGMEHSNN.js';
3
- import { createProgram } from './chunk-YQ3ODCHV.js';
4
- import { loadWorkspaceConfig, loadUserConfigFile } from './chunk-XBM7FHNK.js';
5
- import { extendLog, createLog } from './chunk-ENRLU4UR.js';
6
- import { resolveEntriesSync, getUniqueEntries, replacePathTokens } from './chunk-XZFEHPYE.js';
7
- import { __name } from './chunk-SHUYVCID.js';
8
- import { LogLevelLabel } from '@storm-software/config-tools/types';
9
- import { toArray } from '@stryke/convert/to-array';
10
- import { getEnvPaths } from '@stryke/env/get-env-paths';
11
- import { existsSync } from '@stryke/fs/exists';
12
- import { relativeToWorkspaceRoot } from '@stryke/fs/get-workspace-root';
13
- import { readJsonFile } from '@stryke/fs/json';
14
- import { getResolutionCombinations, resolve, resolveSync, resolvePackage } from '@stryke/fs/resolve';
15
- import { hashDirectory } from '@stryke/hash/hash-files';
16
- import { murmurhash } from '@stryke/hash/murmurhash';
17
- import { getUnique } from '@stryke/helpers/get-unique';
18
- import { omit } from '@stryke/helpers/omit';
19
- import { StormJSON } from '@stryke/json/storm-json';
20
- import { appendPath } from '@stryke/path/append';
21
- import { isAbsolutePath, isAbsolute } from '@stryke/path/is-type';
22
- import { joinPaths } from '@stryke/path/join';
23
- import { replacePath } from '@stryke/path/replace';
24
- import { titleCase } from '@stryke/string-format/title-case';
25
- import { isNull } from '@stryke/type-checks/is-null';
26
- import { isSetObject } from '@stryke/type-checks/is-set-object';
27
- import { isSetString } from '@stryke/type-checks/is-set-string';
28
- import { isString } from '@stryke/type-checks/is-string';
29
- import { uuid } from '@stryke/unique-id/uuid';
30
- import { tsconfigPathsToRegExp, match } from 'bundle-require';
31
- import defu2 from 'defu';
32
- import { joinPaths as joinPaths$1 } from '@stryke/path/join-paths';
33
- import { createJiti } from 'jiti';
34
- import { isFunction } from '@stryke/type-checks/is-function';
35
- import { isUndefined } from '@stryke/type-checks/is-undefined';
36
- import * as $ from '@stryke/capnp';
37
- import { bufferToString } from '@stryke/convert/buffer-to-string';
38
- import { readFileBuffer, readFileBufferSync, writeFileBuffer } from '@stryke/fs/buffer';
39
- import { toAbsolutePath, correctPath } from '@stryke/path/correct-path';
40
- import { findFilePath, findFileDotExtensionSafe } from '@stryke/path/file-path-fns';
41
- import { prettyBytes } from '@stryke/string-format/pretty-bytes';
42
- import { isBuffer } from '@stryke/type-checks/is-buffer';
43
- import { create } from 'flat-cache';
44
- import { Blob } from 'node:buffer';
45
- import _fs from 'node:fs';
46
- import { resolveConfig, format } from 'prettier';
47
- import { slash } from '@stryke/path/slash';
48
- import { isParentPath } from '@stryke/path/is-parent-path';
49
- import { Volume } from 'memfs';
50
- import { Union } from 'unionfs';
51
-
52
- function resolveOptions(options) {
53
- return defu2(options, {
54
- debug: options.logLevel === "trace",
55
- interopDefault: true,
56
- fsCache: options.mode !== "development" ? joinPaths$1(options.cacheDir, "jiti") : false,
57
- moduleCache: options.mode !== "development"
58
- });
59
- }
60
- __name(resolveOptions, "resolveOptions");
61
- function createPluginResolver(options) {
62
- return createJiti(joinPaths$1(options.workspaceRoot, options.projectRoot), resolveOptions({
63
- ...options
64
- }));
65
- }
66
- __name(createPluginResolver, "createPluginResolver");
67
- function createResolver(options) {
68
- const baseResolver = createJiti(joinPaths$1(options.workspaceRoot, options.projectRoot), resolveOptions(options));
69
- baseResolver.plugin = createPluginResolver(options);
70
- return baseResolver;
71
- }
72
- __name(createResolver, "createResolver");
73
-
74
- // src/types/commands.ts
75
- var SUPPORTED_COMMANDS = [
76
- "new",
77
- "clean",
78
- "prepare",
79
- "lint",
80
- "test",
81
- "build",
82
- "docs",
83
- "deploy",
84
- "finalize"
85
- ];
86
-
87
- // src/plugin-utils/helpers.ts
88
- function isPlugin(value) {
89
- 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)) && (isUndefined(value.dependsOn) || "dependsOn" in value && Array.isArray(value.dependsOn) && value.dependsOn.every(isPluginConfig)) && SUPPORTED_COMMANDS.every((command) => isUndefined(value[command]) || command in value && (isFunction(value[command]) || isSetObject(value[command]) && "handler" in value[command] && isFunction(value[command].handler)));
90
- }
91
- __name(isPlugin, "isPlugin");
92
- function isPluginConfigObject(value) {
93
- return isSetObject(value) && "plugin" in value && ((isSetString(value.plugin) || isFunction(value.plugin)) && "options" in value && isSetObject(value.options) || isPlugin(value.plugin));
94
- }
95
- __name(isPluginConfigObject, "isPluginConfigObject");
96
- function isPluginConfigTuple(value) {
97
- return Array.isArray(value) && (value.length === 1 || value.length === 2) && ((isSetString(value[0]) || isFunction(value[0])) && value.length > 1 && isSetObject(value[1]) || isPlugin(value[0]));
98
- }
99
- __name(isPluginConfigTuple, "isPluginConfigTuple");
100
- function isPluginConfig(value) {
101
- return isSetString(value) || isFunction(value) || isPlugin(value) || isPluginConfigObject(value) || isPluginConfigTuple(value);
102
- }
103
- __name(isPluginConfig, "isPluginConfig");
104
- function isPluginHookFunction(value) {
105
- return isFunction(value) || isSetObject(value) && "handler" in value && isFunction(value.handler);
106
- }
107
- __name(isPluginHookFunction, "isPluginHookFunction");
108
- function isPluginHookObject(value) {
109
- return isSetObject(value) && "handler" in value && isFunction(value.handler);
110
- }
111
- __name(isPluginHookObject, "isPluginHookObject");
112
- function isPluginHook(value) {
113
- return isPluginHookFunction(value) || isPluginHookObject(value);
114
- }
115
- __name(isPluginHook, "isPluginHook");
116
- function getHookHandler(pluginHook) {
117
- return isFunction(pluginHook) ? pluginHook : pluginHook.handler;
118
- }
119
- __name(getHookHandler, "getHookHandler");
120
- function isHookExternal(hook) {
121
- return hook.startsWith("vite:") || hook.startsWith("esbuild:") || hook.startsWith("rolldown:") || hook.startsWith("rollup:") || hook.startsWith("webpack:") || hook.startsWith("rspack:") || hook.startsWith("farm:");
122
- }
123
- __name(isHookExternal, "isHookExternal");
124
- function checkDedupe(plugin, plugins) {
125
- return plugin.dedupe === false || plugins.some((p) => p.dedupe !== false && (isFunction(p.dedupe) && p.dedupe(plugin) || p.name === plugin.name));
126
- }
127
- __name(checkDedupe, "checkDedupe");
128
- function addPluginHook(context, plugin, pluginHook, hooksList) {
129
- if (!checkDedupe(plugin, hooksList.map((hook) => hook.plugin))) {
130
- hooksList.push(isFunction(pluginHook) ? {
131
- plugin,
132
- handler: getHookHandler(pluginHook).bind(context)
133
- } : {
134
- plugin,
135
- ...pluginHook,
136
- handler: getHookHandler(pluginHook).bind(context)
137
- });
138
- }
139
- }
140
- __name(addPluginHook, "addPluginHook");
141
- BigInt("0xa56c61324b9d6e49");
142
- var FileMetadata_KeyValuePair = class extends $.Struct {
143
- static {
144
- __name(this, "FileMetadata_KeyValuePair");
145
- }
146
- static _capnp = {
147
- displayName: "KeyValuePair",
148
- id: "eabb26cf58b2a14c",
149
- size: new $.ObjectSize(0, 2)
150
- };
151
- get key() {
152
- return $.utils.getText(0, this);
153
- }
154
- set key(value) {
155
- $.utils.setText(0, value, this);
156
- }
157
- get value() {
158
- return $.utils.getText(1, this);
159
- }
160
- set value(value) {
161
- $.utils.setText(1, value, this);
162
- }
163
- toString() {
164
- return "FileMetadata_KeyValuePair_" + super.toString();
165
- }
166
- };
167
- var FileMetadata = class _FileMetadata extends $.Struct {
168
- static {
169
- __name(this, "FileMetadata");
170
- }
171
- static KeyValuePair = FileMetadata_KeyValuePair;
172
- static _capnp = {
173
- displayName: "FileMetadata",
174
- id: "8e2cab5d7e28c7b3",
175
- size: new $.ObjectSize(8, 4),
176
- defaultType: "normal"
177
- };
178
- static _Properties;
179
- /**
180
- * The type of the file.
181
- *
182
- */
183
- get id() {
184
- return $.utils.getText(0, this);
185
- }
186
- set id(value) {
187
- $.utils.setText(0, value, this);
188
- }
189
- /**
190
- * The output mode of the file.
191
- *
192
- */
193
- get type() {
194
- return $.utils.getText(1, this, _FileMetadata._capnp.defaultType);
195
- }
196
- set type(value) {
197
- $.utils.setText(1, value, this);
198
- }
199
- /**
200
- * The timestamp representing the file's creation date.
201
- *
202
- */
203
- get mode() {
204
- return $.utils.getText(2, this);
205
- }
206
- set mode(value) {
207
- $.utils.setText(2, value, this);
208
- }
209
- /**
210
- * Additional metadata associated with the file.
211
- *
212
- */
213
- get timestamp() {
214
- return $.utils.getUint32(0, this);
215
- }
216
- set timestamp(value) {
217
- $.utils.setUint32(0, value, this);
218
- }
219
- _adoptProperties(value) {
220
- $.utils.adopt(value, $.utils.getPointer(3, this));
221
- }
222
- _disownProperties() {
223
- return $.utils.disown(this.properties);
224
- }
225
- get properties() {
226
- return $.utils.getList(3, _FileMetadata._Properties, this);
227
- }
228
- _hasProperties() {
229
- return !$.utils.isNull($.utils.getPointer(3, this));
230
- }
231
- _initProperties(length) {
232
- return $.utils.initList(3, _FileMetadata._Properties, length, this);
233
- }
234
- set properties(value) {
235
- $.utils.copyFrom(value, $.utils.getPointer(3, this));
236
- }
237
- toString() {
238
- return "FileMetadata_" + super.toString();
239
- }
240
- };
241
- var FileId = class extends $.Struct {
242
- static {
243
- __name(this, "FileId");
244
- }
245
- static _capnp = {
246
- displayName: "FileId",
247
- id: "990d6a471072f997",
248
- size: new $.ObjectSize(0, 2)
249
- };
250
- /**
251
- * A virtual (or actual) path to the file in the file system.
252
- *
253
- */
254
- get id() {
255
- return $.utils.getText(0, this);
256
- }
257
- set id(value) {
258
- $.utils.setText(0, value, this);
259
- }
260
- get path() {
261
- return $.utils.getText(1, this);
262
- }
263
- set path(value) {
264
- $.utils.setText(1, value, this);
265
- }
266
- toString() {
267
- return "FileId_" + super.toString();
268
- }
269
- };
270
- var FileData = class extends $.Struct {
271
- static {
272
- __name(this, "FileData");
273
- }
274
- static _capnp = {
275
- displayName: "FileData",
276
- id: "fa6725c8a360f9a2",
277
- size: new $.ObjectSize(0, 2)
278
- };
279
- /**
280
- * A virtual (or actual) path to the file in the file system.
281
- *
282
- */
283
- get path() {
284
- return $.utils.getText(0, this);
285
- }
286
- set path(value) {
287
- $.utils.setText(0, value, this);
288
- }
289
- get code() {
290
- return $.utils.getText(1, this);
291
- }
292
- set code(value) {
293
- $.utils.setText(1, value, this);
294
- }
295
- toString() {
296
- return "FileData_" + super.toString();
297
- }
298
- };
299
- var FileSystem = class _FileSystem extends $.Struct {
300
- static {
301
- __name(this, "FileSystem");
302
- }
303
- static _capnp = {
304
- displayName: "FileSystem",
305
- id: "ae0c23d43e56abcf",
306
- size: new $.ObjectSize(0, 3)
307
- };
308
- static _Ids;
309
- static _Files;
310
- static _Metadata;
311
- _adoptIds(value) {
312
- $.utils.adopt(value, $.utils.getPointer(0, this));
313
- }
314
- _disownIds() {
315
- return $.utils.disown(this.ids);
316
- }
317
- get ids() {
318
- return $.utils.getList(0, _FileSystem._Ids, this);
319
- }
320
- _hasIds() {
321
- return !$.utils.isNull($.utils.getPointer(0, this));
322
- }
323
- _initIds(length) {
324
- return $.utils.initList(0, _FileSystem._Ids, length, this);
325
- }
326
- set ids(value) {
327
- $.utils.copyFrom(value, $.utils.getPointer(0, this));
328
- }
329
- _adoptFiles(value) {
330
- $.utils.adopt(value, $.utils.getPointer(1, this));
331
- }
332
- _disownFiles() {
333
- return $.utils.disown(this.files);
334
- }
335
- get files() {
336
- return $.utils.getList(1, _FileSystem._Files, this);
337
- }
338
- _hasFiles() {
339
- return !$.utils.isNull($.utils.getPointer(1, this));
340
- }
341
- _initFiles(length) {
342
- return $.utils.initList(1, _FileSystem._Files, length, this);
343
- }
344
- set files(value) {
345
- $.utils.copyFrom(value, $.utils.getPointer(1, this));
346
- }
347
- _adoptMetadata(value) {
348
- $.utils.adopt(value, $.utils.getPointer(2, this));
349
- }
350
- _disownMetadata() {
351
- return $.utils.disown(this.metadata);
352
- }
353
- get metadata() {
354
- return $.utils.getList(2, _FileSystem._Metadata, this);
355
- }
356
- _hasMetadata() {
357
- return !$.utils.isNull($.utils.getPointer(2, this));
358
- }
359
- _initMetadata(length) {
360
- return $.utils.initList(2, _FileSystem._Metadata, length, this);
361
- }
362
- set metadata(value) {
363
- $.utils.copyFrom(value, $.utils.getPointer(2, this));
364
- }
365
- toString() {
366
- return "FileSystem_" + super.toString();
367
- }
368
- };
369
- FileMetadata._Properties = $.CompositeList(FileMetadata_KeyValuePair);
370
- FileSystem._Ids = $.CompositeList(FileId);
371
- FileSystem._Files = $.CompositeList(FileData);
372
- FileSystem._Metadata = $.CompositeList(FileMetadata);
373
-
374
- // src/types/fs.ts
375
- var __VFS_PATCH__ = "__VFS_PATCH__";
376
- var __VFS_REVERT__ = "__VFS_REVERT__";
377
- function isBufferEncoding(options) {
378
- return isSetString(options) || options === null;
379
- }
380
- __name(isBufferEncoding, "isBufferEncoding");
381
- function isPowerlinesWriteFileOptions(options) {
382
- return !isBufferEncoding(options) && isSetObject(options) && "mode" in options && (options.mode === "fs" || options.mode === "virtual");
383
- }
384
- __name(isPowerlinesWriteFileOptions, "isPowerlinesWriteFileOptions");
385
- function isVirtualFileData(obj) {
386
- return !!(isSetObject(obj) && "code" in obj && obj.code);
387
- }
388
- __name(isVirtualFileData, "isVirtualFileData");
389
- function toFilePath(path) {
390
- return correctPath(slash(path?.toString() || ".").replace(/^file:\/\//, ""));
391
- }
392
- __name(toFilePath, "toFilePath");
393
- var FS_METHODS = [
394
- "mkdir",
395
- "mkdirSync",
396
- "rmdir",
397
- "rmdirSync",
398
- "unlink",
399
- "unlinkSync",
400
- "existsSync",
401
- "realpathSync",
402
- "writeFileSync",
403
- "readFileSync",
404
- "readdirSync",
405
- "createWriteStream",
406
- "WriteStream",
407
- "createReadStream",
408
- "ReadStream"
409
- ];
410
- var FS_PROMISE_METHODS = [
411
- "mkdir",
412
- "rm",
413
- "rmdir",
414
- "unlink",
415
- "writeFile",
416
- "readFile",
417
- "readdir",
418
- "stat",
419
- "lstat"
420
- ];
421
- function cloneFS(originalFS) {
422
- const clonedFS = {
423
- ...originalFS,
424
- promises: {
425
- ...originalFS.promises ?? {}
426
- }
427
- };
428
- for (const method of FS_METHODS) {
429
- if (originalFS[method]) {
430
- clonedFS[method] = originalFS[method];
431
- }
432
- }
433
- originalFS.promises ??= {};
434
- for (const method of FS_PROMISE_METHODS) {
435
- if (originalFS.promises[method]) {
436
- clonedFS.promises ??= {};
437
- clonedFS.promises[method] = originalFS.promises[method];
438
- clonedFS[method] = originalFS.promises[method];
439
- }
440
- }
441
- for (const prop in clonedFS) {
442
- if (isFunction(clonedFS[prop])) {
443
- clonedFS[prop] = clonedFS[prop].bind(originalFS);
444
- if (isFunction(clonedFS.promises[prop])) {
445
- clonedFS.promises[prop] = clonedFS.promises[prop].bind(originalFS);
446
- }
447
- }
448
- }
449
- for (const prop in clonedFS.promises) {
450
- if (isFunction(clonedFS.promises[prop])) {
451
- clonedFS.promises[prop] = clonedFS.promises[prop].bind(originalFS);
452
- }
453
- }
454
- return clonedFS;
455
- }
456
- __name(cloneFS, "cloneFS");
457
- function patchFS(originalFS, vfs) {
458
- const clonedFS = cloneFS(originalFS);
459
- originalFS.mkdirSync = (file, options) => vfs.mkdirSync(toFilePath(file), options);
460
- originalFS.mkdir = (file, options, callback) => vfs.mkdir(toFilePath(file), options, callback);
461
- originalFS.promises.mkdir = async (file, options) => vfs.mkdir(toFilePath(file), options);
462
- originalFS.unlinkSync = (file) => vfs.unlinkSync(toFilePath(file));
463
- originalFS.promises.rm = async (file, options) => vfs.rm(toFilePath(file), options);
464
- originalFS.promises.unlink = async (file) => vfs.unlink(toFilePath(file));
465
- originalFS.existsSync = (file) => vfs.existsSync(toFilePath(file));
466
- Object.defineProperty(originalFS, "realpathSync", {
467
- value: /* @__PURE__ */ __name((file, options) => vfs.realpathSync(toFilePath(file), options), "value")
468
- });
469
- originalFS.writeFileSync = (file, data, options) => vfs.writeFileSync(toFilePath(file), data, options);
470
- originalFS.promises.writeFile = async (file, data, options) => vfs.writeFile(toFilePath(file), data, options);
471
- originalFS.readFileSync = (file, options) => vfs.readFileSync(toFilePath(file), options);
472
- originalFS.promises.readFile = (file, options) => vfs.readFile(toFilePath(file), options);
473
- originalFS.readdirSync = (file, options) => vfs.readdirSync(toFilePath(file), options);
474
- originalFS.promises.readdir = (file, options) => vfs.readdir(toFilePath(file), options);
475
- Object.defineProperty(originalFS, "statSync", {
476
- value: /* @__PURE__ */ __name((file, options) => vfs.statSync(toFilePath(file), options), "value")
477
- });
478
- originalFS.stat = (file, options) => vfs.statSync(toFilePath(file), options);
479
- originalFS.promises.stat = (file, options) => vfs.stat(toFilePath(file), options);
480
- Object.defineProperty(originalFS, "lstatSync", {
481
- value: /* @__PURE__ */ __name((file, options) => vfs.lstatSync(toFilePath(file), options), "value")
482
- });
483
- originalFS.lstat = (file, options) => vfs.lstatSync(toFilePath(file), options);
484
- originalFS.promises.lstat = (file, options) => vfs.lstat(toFilePath(file), options);
485
- return () => {
486
- originalFS.mkdirSync = clonedFS.mkdirSync;
487
- originalFS.mkdir = clonedFS.mkdir;
488
- originalFS.promises.mkdir = clonedFS.promises.mkdir;
489
- originalFS.unlinkSync = clonedFS.unlinkSync;
490
- originalFS.promises.rm = clonedFS.promises.rm;
491
- originalFS.promises.unlink = clonedFS.promises.unlink;
492
- originalFS.existsSync = clonedFS.existsSync;
493
- originalFS.realpathSync = clonedFS.realpathSync;
494
- originalFS.writeFileSync = clonedFS.writeFileSync;
495
- originalFS.promises.writeFile = clonedFS.promises.writeFile;
496
- originalFS.readFileSync = clonedFS.readFileSync;
497
- originalFS.promises.readFile = clonedFS.promises.readFile;
498
- originalFS.readdirSync = clonedFS.readdirSync;
499
- originalFS.promises.readdir = clonedFS.promises.readdir;
500
- Object.defineProperty(originalFS, "statSync", {
501
- value: clonedFS.statSync
502
- });
503
- originalFS.stat = clonedFS.stat;
504
- originalFS.promises.stat = clonedFS.promises.stat;
505
- Object.defineProperty(originalFS, "lstatSync", {
506
- value: clonedFS.lstatSync
507
- });
508
- originalFS.lstat = clonedFS.lstat;
509
- originalFS.promises.lstat = clonedFS.promises.lstat;
510
- };
511
- }
512
- __name(patchFS, "patchFS");
513
- function isValidId(id, prefix = "powerlines") {
514
- return id.replace(/^\\0/, "").startsWith(`${prefix.replace(/:$/, "")}`);
515
- }
516
- __name(isValidId, "isValidId");
517
- function normalizeId(id, prefix = "powerlines") {
518
- return `${prefix.replace(/:$/, "")}:${toFilePath(id).replace(new RegExp(`^${prefix.replace(/:$/, "")}:`), "").replace(/^\\0/, "").replace(findFileDotExtensionSafe(toFilePath(id)), "")}`;
519
- }
520
- __name(normalizeId, "normalizeId");
521
- function normalizePath(path, builtinsPath, prefix = "powerlines") {
522
- return isValidId(toFilePath(path), prefix) ? normalizeId(toFilePath(path), prefix).replace(new RegExp(`^${prefix.replace(/:$/, "")}:`), builtinsPath) : toFilePath(path);
523
- }
524
- __name(normalizePath, "normalizePath");
525
- var UnifiedFS = class _UnifiedFS extends Union {
526
- static {
527
- __name(this, "UnifiedFS");
528
- }
529
- /**
530
- * The internal map of virtual files.
531
- */
532
- #virtualFS = new Volume();
533
- /**
534
- * The physical file system.
535
- */
536
- #physicalFS = cloneFS(_fs);
537
- /**
538
- * The context of the unified file system.
539
- */
540
- #context;
541
- static create(context, fs2) {
542
- let result = new _UnifiedFS(context, fs2);
543
- result = result.use(result.#physicalFS);
544
- if (result.#context.config.output.mode !== "fs") {
545
- result = result.use(result.#virtualFS);
546
- }
547
- return result;
548
- }
549
- /**
550
- * Gets the virtual file system (VFS).
551
- */
552
- get virtual() {
553
- return this.#virtualFS;
554
- }
555
- /**
556
- * Gets the physical file system (FS).
557
- */
558
- get physical() {
559
- return this.#physicalFS;
560
- }
561
- /**
562
- * Creates a new instance of the VirtualFileSystem.
563
- *
564
- * @param context - The context of the virtual file system, typically containing options and logging functions.
565
- * @param fs - A buffer containing the serialized virtual file system data.
566
- */
567
- constructor(context, fs2) {
568
- super();
569
- this.#context = context;
570
- if (!this.#physicalFS.existsSync(this.#context.dataPath)) {
571
- this.#physicalFS.mkdirSync(this.#context.dataPath, {
572
- recursive: true
573
- });
574
- }
575
- if (!this.#physicalFS.existsSync(this.#context.cachePath)) {
576
- this.#physicalFS.mkdirSync(this.#context.cachePath, {
577
- recursive: true
578
- });
579
- }
580
- if (!this.#physicalFS.existsSync(joinPaths(this.#context.workspaceConfig.workspaceRoot, this.#context.config.output.distPath))) {
581
- this.#physicalFS.mkdirSync(joinPaths(this.#context.workspaceConfig.workspaceRoot, this.#context.config.output.distPath), {
582
- recursive: true
583
- });
584
- }
585
- if (this.#context.config.output.mode !== "fs") {
586
- this.#virtualFS = Volume.fromJSON(fs2._hasFiles() && fs2.files.length > 0 ? fs2.files.values().reduce((ret, file) => {
587
- ret[file.path] = file.code;
588
- return ret;
589
- }, {}) : {});
590
- if (!this.#virtualFS.existsSync(this.#context.artifactsPath)) {
591
- this.#virtualFS.mkdirSync(this.#context.artifactsPath, {
592
- recursive: true
593
- });
594
- }
595
- if (!this.#virtualFS.existsSync(this.#context.builtinsPath)) {
596
- this.#virtualFS.mkdirSync(this.#context.builtinsPath, {
597
- recursive: true
598
- });
599
- }
600
- if (!this.#virtualFS.existsSync(this.#context.entryPath)) {
601
- this.#virtualFS.mkdirSync(this.#context.entryPath, {
602
- recursive: true
603
- });
604
- }
605
- if (!this.#virtualFS.existsSync(this.#context.dtsPath)) {
606
- this.#virtualFS.mkdirSync(this.#context.dtsPath, {
607
- recursive: true
608
- });
609
- }
610
- } else if (this.#context.config.projectType === "application") {
611
- if (!this.#physicalFS.existsSync(this.#context.artifactsPath)) {
612
- this.#physicalFS.mkdirSync(this.#context.artifactsPath, {
613
- recursive: true
614
- });
615
- }
616
- if (!this.#physicalFS.existsSync(this.#context.builtinsPath)) {
617
- this.#physicalFS.mkdirSync(this.#context.builtinsPath, {
618
- recursive: true
619
- });
620
- }
621
- if (!this.#physicalFS.existsSync(this.#context.entryPath)) {
622
- this.#physicalFS.mkdirSync(this.#context.entryPath, {
623
- recursive: true
624
- });
625
- }
626
- if (!this.#physicalFS.existsSync(this.#context.dtsPath)) {
627
- this.#physicalFS.mkdirSync(this.#context.dtsPath, {
628
- recursive: true
629
- });
630
- }
631
- }
632
- }
633
- /**
634
- * Select the file system module to use for the operation based on the path or URL.
635
- *
636
- * @param pathOrUrl - The path to perform the file system operation on.
637
- * @param options - Options for the operation, such as output mode.
638
- * @returns The file system module used for the operation.
639
- */
640
- resolveFS(pathOrUrl, options = {}) {
641
- const mode = this.resolveMode(pathOrUrl, options);
642
- if (mode === "virtual") {
643
- return {
644
- ...this.#virtualFS,
645
- mode: "virtual"
646
- };
647
- } else if (mode === "fs") {
648
- return {
649
- ...this.#physicalFS,
650
- mode: "fs"
651
- };
652
- }
653
- return {
654
- ...this,
655
- mode: this.#context.config.output.mode
656
- };
657
- }
658
- /**
659
- * Select the file system module to use for the operation based on the path or URL.
660
- *
661
- * @param pathOrUrl - The path to perform the file system operation on.
662
- * @param options - Options for the operation, such as output mode.
663
- * @returns The file system module used for the operation.
664
- */
665
- resolveMode(pathOrUrl, options = {}) {
666
- if (options.mode === "virtual" && this.#context.config.output.mode !== "fs" && isParentPath(toFilePath(pathOrUrl), this.#context.artifactsPath)) {
667
- return "virtual";
668
- } else if (options.mode === "fs" || this.#context.config.output.mode === "fs" || isParentPath(toFilePath(pathOrUrl), this.#context.dataPath) || isParentPath(toFilePath(pathOrUrl), this.#context.cachePath) || isParentPath(toFilePath(pathOrUrl), joinPaths(this.#context.workspaceConfig.workspaceRoot, this.#context.config.output.distPath))) {
669
- return "fs";
670
- }
671
- return void 0;
672
- }
673
- /**
674
- * Serializes the virtual file system (VFS) to a JSON object.
675
- *
676
- * @returns A JSON representation of the virtual file system.
677
- */
678
- toJSON() {
679
- return this.#virtualFS.toJSON();
680
- }
681
- };
682
-
683
- // src/lib/fs/vfs.ts
684
- var VirtualFileSystem = class _VirtualFileSystem {
685
- static {
686
- __name(this, "VirtualFileSystem");
687
- }
688
- /**
689
- * A map of virtual file IDs to their associated metadata.
690
- */
691
- #metadata;
692
- /**
693
- * A map of virtual file IDs to their underlying file paths.
694
- */
695
- #ids;
696
- /**
697
- * A map of underlying file paths to their virtual file IDs.
698
- */
699
- #paths;
700
- /**
701
- * A cache for module resolution results.
702
- */
703
- #resolverCache;
704
- /**
705
- * The unified volume that combines the virtual file system with the real file system.
706
- *
707
- * @remarks
708
- * This volume allows for seamless access to both virtual and real files.
709
- */
710
- #unifiedFS;
711
- /**
712
- * Indicator specifying if the file system module is patched
713
- */
714
- #isPatched = false;
715
- /**
716
- * Indicator specifying if the virtual file system (VFS) is disposed
717
- */
718
- #isDisposed = false;
719
- /**
720
- * Function to revert require patch
721
- */
722
- #revert;
723
- /**
724
- * The context of the virtual file system.
725
- */
726
- #context;
727
- /**
728
- * The file system's logging function.
729
- */
730
- #log;
731
- /**
732
- * Checks if a path exists in the virtual file system (VFS).
733
- *
734
- * @param path - The path to check.
735
- * @returns `true` if the path exists, otherwise `false`.
736
- */
737
- #existsSync(path) {
738
- return this.#unifiedFS.virtual.existsSync(this.#normalizePath(path)) || this.#unifiedFS.physical.existsSync(this.#normalizePath(path)) || this.#unifiedFS.resolveFS(path).existsSync(this.#normalizePath(path));
739
- }
740
- /**
741
- * Normalizes a given module id by resolving it against the built-ins path.
742
- *
743
- * @param id - The module id to normalize.
744
- * @returns The normalized module id.
745
- */
746
- #normalizeId(id) {
747
- return normalizeId(id, this.#context.config.output.builtinPrefix);
748
- }
749
- /**
750
- * Normalizes a given path by resolving it against the project root, workspace root, and built-ins path.
751
- *
752
- * @param path - The path to normalize.
753
- * @returns The normalized path.
754
- */
755
- #normalizePath(path) {
756
- return normalizePath(path, this.#context.builtinsPath, this.#context.config.output.builtinPrefix);
757
- }
758
- /**
759
- * Builds a regular expression from a string pattern for path matching.
760
- *
761
- * @param path - The string pattern to convert.
762
- * @returns A regular expression for matching paths.
763
- */
764
- #buildRegex(path) {
765
- const token = "::GLOBSTAR::";
766
- return new RegExp(`^${this.#normalizePath(path).replace(/\*\*/g, token).replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*/g, "[^/]*").replace(/\?/g, "[^/]").replace(new RegExp(token, "g"), ".*")}$`);
767
- }
768
- /**
769
- * Creates a virtual file system (VFS) that is backed up to a Cap'n Proto message buffer.
770
- *
771
- * @param context - The context of the virtual file system, typically containing options and logging functions.
772
- * @returns A promise that resolves to a new virtual file system instance.
773
- */
774
- static async create(context) {
775
- if (!context.config.skipCache && existsSync(joinPaths$1(context.dataPath, "fs.bin"))) {
776
- const buffer = await readFileBuffer(joinPaths$1(context.dataPath, "fs.bin"));
777
- const message2 = new $.Message(buffer, false);
778
- return new _VirtualFileSystem(context, message2.getRoot(FileSystem));
779
- }
780
- const message = new $.Message();
781
- return new _VirtualFileSystem(context, message.initRoot(FileSystem));
782
- }
783
- /**
784
- * Synchronously creates a virtual file system (VFS) that is backed up to a Cap'n Proto message buffer.
785
- *
786
- * @param context - The context of the virtual file system, typically containing options and logging functions.
787
- * @returns A new virtual file system instance.
788
- */
789
- static createSync(context) {
790
- if (!context.config.skipCache && existsSync(joinPaths$1(context.dataPath, "fs.bin"))) {
791
- const buffer = readFileBufferSync(joinPaths$1(context.dataPath, "fs.bin"));
792
- const message2 = new $.Message(buffer, false);
793
- return new _VirtualFileSystem(context, message2.getRoot(FileSystem));
794
- }
795
- const message = new $.Message();
796
- return new _VirtualFileSystem(context, message.initRoot(FileSystem));
797
- }
798
- /**
799
- * A map of file ids to their metadata.
800
- */
801
- get metadata() {
802
- return new Proxy(this.#metadata, {
803
- get: /* @__PURE__ */ __name((target, prop) => {
804
- return target[this.#normalizeId(prop)];
805
- }, "get")
806
- });
807
- }
808
- /**
809
- * A map of file paths to their module ids.
810
- */
811
- get ids() {
812
- return new Proxy(this.#paths, {
813
- get: /* @__PURE__ */ __name((target, prop) => {
814
- return target[this.#normalizePath(prop)];
815
- }, "get")
816
- });
817
- }
818
- /**
819
- * A map of module ids to their file paths.
820
- */
821
- get paths() {
822
- return new Proxy(this.#paths, {
823
- get: /* @__PURE__ */ __name((target, prop) => {
824
- return target[this.#normalizeId(prop)];
825
- }, "get")
826
- });
827
- }
828
- get resolverCache() {
829
- if (!this.#resolverCache) {
830
- this.#resolverCache = create({
831
- cacheId: "module-resolution",
832
- cacheDir: this.#context.cachePath,
833
- ttl: 60 * 60 * 1e3,
834
- lruSize: 5e3,
835
- persistInterval: 100
836
- });
837
- }
838
- return this.#resolverCache;
839
- }
840
- /**
841
- * Creates a new instance of the {@link VirtualFileSystem}.
842
- *
843
- * @param context - The context of the virtual file system, typically containing options and logging functions.
844
- * @param fs - A buffer containing the serialized virtual file system data.
845
- */
846
- constructor(context, fs2) {
847
- this.#context = context;
848
- this.#unifiedFS = UnifiedFS.create(context, fs2);
849
- this.#metadata = {};
850
- if (fs2._hasMetadata()) {
851
- this.#metadata = fs2.metadata.values().reduce((ret, metadata) => {
852
- ret[metadata.id] = {
853
- id: metadata.id,
854
- type: metadata.type,
855
- mode: metadata.mode,
856
- timestamp: metadata.timestamp || Date.now(),
857
- properties: metadata._hasProperties() ? metadata.properties.values().reduce((ret2, item) => {
858
- ret2[item.key] = item.value;
859
- return ret2;
860
- }, {}) : {}
861
- };
862
- return ret;
863
- }, {});
864
- }
865
- this.#ids = {};
866
- this.#paths = {};
867
- if (fs2._hasIds()) {
868
- this.#ids = fs2.ids.values().reduce((ret, identifier) => {
869
- ret[identifier.path] ??= identifier.id;
870
- return ret;
871
- }, {});
872
- this.#paths = fs2.ids.values().reduce((ret, identifier) => {
873
- ret[identifier.id] ??= identifier.path;
874
- return ret;
875
- }, {});
876
- }
877
- this.#log = extendLog(this.#context.log, "file-system");
878
- }
879
- /**
880
- * Check if a path or id corresponds to a virtual file **(does not actually exists on disk)**.
881
- *
882
- * @param pathOrId - The path or id to check.
883
- * @returns Whether the path or id corresponds to a virtual file **(does not actually exists on disk)**.
884
- */
885
- isVirtual(pathOrId, importer, options = {}) {
886
- if (!pathOrId) {
887
- return false;
888
- }
889
- const resolvedPath = this.resolveSync(pathOrId, importer, options);
890
- if (!resolvedPath) {
891
- return false;
892
- }
893
- return this.metadata[resolvedPath]?.mode === "virtual";
894
- }
895
- /**
896
- * Check if a path or id corresponds to a file written to the file system **(actually exists on disk)**.
897
- *
898
- * @param pathOrId - The path or id to check.
899
- * @returns Whether the path or id corresponds to a file written to the file system **(actually exists on disk)**.
900
- */
901
- isPhysical(pathOrId, importer, options = {}) {
902
- if (!pathOrId) {
903
- return false;
904
- }
905
- const resolvedPath = this.resolveSync(pathOrId, importer, options);
906
- if (!resolvedPath) {
907
- return false;
908
- }
909
- return this.metadata[resolvedPath]?.mode === "fs";
910
- }
911
- /**
912
- * Lists files in a given path.
913
- *
914
- * @param path - The path to list files from.
915
- * @param options - Options for listing files, such as encoding and recursion.
916
- * @returns An array of file names in the specified path.
917
- */
918
- readdirSync(path, options = "utf8") {
919
- return this.#unifiedFS.resolveFS(path).readdirSync(toFilePath(path), options);
920
- }
921
- /**
922
- * Removes a file in the virtual file system (VFS).
923
- *
924
- * @param path - The path to create the directory at.
925
- */
926
- unlinkSync(path, options) {
927
- if (!this.isFile(this.#normalizePath(path))) {
928
- return;
929
- }
930
- this.#log(LogLevelLabel.TRACE, `Synchronously removing file: ${this.#normalizePath(path)}`);
931
- this.#unifiedFS.resolveFS(path, options).unlinkSync(this.#normalizePath(path));
932
- if (this.#ids[this.#normalizePath(path)] && this.#metadata[this.#ids[this.#normalizePath(path)]]) {
933
- delete this.#metadata[this.#ids[this.#normalizePath(path)]];
934
- delete this.#ids[this.#normalizePath(path)];
935
- delete this.#paths[this.#normalizeId(path)];
936
- this.#resolverCache.delete(this.#normalizePath(path));
937
- }
938
- }
939
- /**
940
- * Removes a file in the virtual file system (VFS).
941
- *
942
- * @param path - The path to create the directory at.
943
- */
944
- async unlink(path, options) {
945
- if (!this.isFile(this.#normalizePath(path))) {
946
- return;
947
- }
948
- this.#log(LogLevelLabel.TRACE, `Removing file: ${this.#normalizePath(path)}`);
949
- if (isFunction(this.#unifiedFS.resolveFS(path, options).promises.unlink)) {
950
- await this.#unifiedFS.resolveFS(path, options).promises.unlink(this.#normalizePath(path));
951
- if (this.#ids[this.#normalizePath(path)] && this.#metadata[this.#ids[this.#normalizePath(path)]]) {
952
- delete this.#metadata[this.#ids[this.#normalizePath(path)]];
953
- }
954
- } else {
955
- this.unlinkSync(this.#normalizePath(path), options);
956
- }
957
- }
958
- /**
959
- * Removes a directory in the virtual file system (VFS).
960
- *
961
- * @param path - The path to create the directory at.
962
- * @param options - Options for creating the directory.
963
- */
964
- rmdirSync(path, options = {}) {
965
- if (!this.isDirectory(this.#normalizePath(path))) {
966
- return;
967
- }
968
- this.#log(LogLevelLabel.TRACE, `Synchronously removing directory: ${this.#normalizePath(path)}`);
969
- this.#unifiedFS.resolveFS(path, options).rmdirSync(this.#normalizePath(path), defu2(options, {
970
- recursive: true
971
- }));
972
- }
973
- /**
974
- * Removes a directory in the virtual file system (VFS).
975
- *
976
- * @param path - The path to create the directory at.
977
- * @param options - Options for creating the directory.
978
- * @returns A promise that resolves to the path of the created directory, or undefined if the directory could not be created.
979
- */
980
- async rmdir(path, options = {}) {
981
- if (!this.isDirectory(this.#normalizePath(path))) {
982
- return;
983
- }
984
- this.#log(LogLevelLabel.TRACE, `Removing directory: ${this.#normalizePath(path)}`);
985
- if (isFunction(this.#unifiedFS.resolveFS(path, options).promises.rm)) {
986
- await this.#unifiedFS.resolveFS(path, options).promises.rm(this.#normalizePath(path), defu2(options, {
987
- force: true,
988
- recursive: true
989
- }));
990
- } else {
991
- this.rmdirSync(this.#normalizePath(path), defu2(options ?? {}, {
992
- force: true,
993
- recursive: true
994
- }));
995
- }
996
- }
997
- /**
998
- * Removes a file in the virtual file system (VFS).
999
- *
1000
- * @param path - The path to the file to remove.
1001
- * @param options - Options for removing the file.
1002
- * @returns A promise that resolves when the file is removed.
1003
- */
1004
- async rm(path, options = {}) {
1005
- this.#log(LogLevelLabel.TRACE, `Removing: ${this.#normalizePath(path)}`);
1006
- if (this.isDirectory(this.#normalizePath(path))) {
1007
- return this.rmdir(this.#normalizePath(path), options);
1008
- }
1009
- return this.unlink(this.#normalizePath(path), options);
1010
- }
1011
- /**
1012
- * Synchronously removes a file or directory in the virtual file system (VFS).
1013
- *
1014
- * @param path - The path to the file or directory to remove.
1015
- * @param options - Options for removing the file or directory.
1016
- */
1017
- rmSync(path, options = {}) {
1018
- this.#log(LogLevelLabel.TRACE, `Removing: ${this.#normalizePath(path)}`);
1019
- if (this.isDirectory(this.#normalizePath(path))) {
1020
- return this.rmdirSync(this.#normalizePath(path), options);
1021
- }
1022
- return this.unlinkSync(this.#normalizePath(path), options);
1023
- }
1024
- /**
1025
- * Creates a directory in the virtual file system (VFS).
1026
- *
1027
- * @param path - The path to create the directory at.
1028
- * @param options - Options for creating the directory.
1029
- * @returns A promise that resolves to the path of the created directory, or undefined if the directory could not be created.
1030
- */
1031
- mkdirSync(path, options = {}) {
1032
- return this.#unifiedFS.resolveFS(this.#normalizePath(path), options).mkdirSync(this.#normalizePath(path), defu2(omit(options, [
1033
- "mode"
1034
- ]), {
1035
- recursive: true
1036
- }));
1037
- }
1038
- /**
1039
- * Creates a directory in the virtual file system (VFS).
1040
- *
1041
- * @param path - The path to create the directory at.
1042
- * @param options - Options for creating the directory.
1043
- * @returns A promise that resolves to the path of the created directory, or undefined if the directory could not be created.
1044
- */
1045
- async mkdir(path, options = {}) {
1046
- let result;
1047
- if (isFunction(this.#unifiedFS.resolveFS(this.#normalizePath(path), options).promises.mkdir)) {
1048
- result = await this.#unifiedFS.resolveFS(this.#normalizePath(path), options).promises.mkdir(this.#normalizePath(path), defu2(omit(options, [
1049
- "mode"
1050
- ]), {
1051
- recursive: true
1052
- }));
1053
- } else {
1054
- result = this.#unifiedFS.resolveFS(this.#normalizePath(path), options).mkdirSync(this.#normalizePath(path), defu2(omit(options, [
1055
- "mode"
1056
- ]), {
1057
- recursive: true
1058
- }));
1059
- }
1060
- return result;
1061
- }
1062
- /**
1063
- * Glob files in the virtual file system (VFS) based on the provided pattern(s).
1064
- *
1065
- * @param patterns - A pattern (or multiple patterns) to use to determine the file paths to return
1066
- * @returns An array of file paths matching the provided pattern(s)
1067
- */
1068
- async glob(patterns) {
1069
- const results = [];
1070
- for (const pattern of toArray(patterns)) {
1071
- const normalized = this.#normalizePath(pattern);
1072
- if (!/[*?[\]{}]/.test(normalized) && !normalized.includes("**")) {
1073
- const resolved = this.resolveSync(normalized);
1074
- if (resolved && !results.includes(resolved)) {
1075
- results.push(resolved);
1076
- }
1077
- continue;
1078
- }
1079
- const absPattern = isAbsolutePath(normalized) ? normalized : this.#normalizePath(joinPaths$1(this.#context.workspaceConfig.workspaceRoot, normalized));
1080
- const firstGlobIdx = absPattern.search(/[*?[\]{}]/);
1081
- const baseDir = firstGlobIdx === -1 ? findFilePath(absPattern) : absPattern.slice(0, Math.max(0, absPattern.lastIndexOf("/", firstGlobIdx)));
1082
- const stack = [
1083
- baseDir && isAbsolutePath(baseDir) ? baseDir : this.#context.workspaceConfig.workspaceRoot
1084
- ];
1085
- while (stack.length) {
1086
- const dir = stack.pop();
1087
- let entries = [];
1088
- try {
1089
- entries = await this.readdir(dir);
1090
- } catch {
1091
- continue;
1092
- }
1093
- for (const entry of entries) {
1094
- const full = this.#normalizePath(joinPaths$1(dir, entry));
1095
- let stats;
1096
- try {
1097
- stats = this.#unifiedFS.lstatSync(full);
1098
- } catch {
1099
- stats = void 0;
1100
- }
1101
- if (!stats) continue;
1102
- if (stats.isDirectory()) {
1103
- stack.push(full);
1104
- } else if (stats.isFile()) {
1105
- if (this.#buildRegex(absPattern).test(full)) {
1106
- const resolved = this.resolveSync(full);
1107
- if (resolved && !results.includes(resolved)) {
1108
- results.push(resolved);
1109
- }
1110
- }
1111
- }
1112
- }
1113
- }
1114
- }
1115
- return results;
1116
- }
1117
- /**
1118
- * Synchronously glob files in the virtual file system (VFS) based on the provided pattern(s).
1119
- *
1120
- * @param patterns - A pattern (or multiple patterns) to use to determine the file paths to return
1121
- * @returns An array of file paths matching the provided pattern(s)
1122
- */
1123
- globSync(patterns) {
1124
- const results = [];
1125
- for (const pattern of toArray(patterns)) {
1126
- const normalized = this.#normalizePath(pattern);
1127
- if (!/[*?[\]{}]/.test(normalized) && !normalized.includes("**")) {
1128
- const resolved = this.resolveSync(normalized);
1129
- if (resolved && !results.includes(resolved)) {
1130
- results.push(resolved);
1131
- }
1132
- continue;
1133
- }
1134
- const absPattern = isAbsolutePath(normalized) ? normalized : this.#normalizePath(joinPaths$1(this.#context.workspaceConfig.workspaceRoot, normalized));
1135
- const firstGlobIdx = absPattern.search(/[*?[\]{}]/);
1136
- const baseDir = firstGlobIdx === -1 ? findFilePath(absPattern) : absPattern.slice(0, Math.max(0, absPattern.lastIndexOf("/", firstGlobIdx)));
1137
- const stack = [
1138
- baseDir && isAbsolutePath(baseDir) ? baseDir : this.#context.workspaceConfig.workspaceRoot
1139
- ];
1140
- while (stack.length) {
1141
- const dir = stack.pop();
1142
- let entries = [];
1143
- try {
1144
- entries = this.readdirSync(dir);
1145
- } catch {
1146
- continue;
1147
- }
1148
- for (const entry of entries) {
1149
- const full = this.#normalizePath(joinPaths$1(dir, entry));
1150
- let stats;
1151
- try {
1152
- stats = this.#unifiedFS.lstatSync(full);
1153
- } catch {
1154
- stats = void 0;
1155
- }
1156
- if (!stats) continue;
1157
- if (stats.isDirectory()) {
1158
- stack.push(full);
1159
- } else if (stats.isFile()) {
1160
- if (this.#buildRegex(absPattern).test(full)) {
1161
- const resolved = this.resolveSync(full);
1162
- if (resolved && !results.includes(resolved)) {
1163
- results.push(resolved);
1164
- }
1165
- }
1166
- }
1167
- }
1168
- }
1169
- }
1170
- return results;
1171
- }
1172
- /**
1173
- * Moves a file from one path to another in the virtual file system (VFS).
1174
- *
1175
- * @param srcPath - The source path to move
1176
- * @param destPath - The destination path to move to
1177
- */
1178
- async move(srcPath, destPath) {
1179
- const content = await this.readFile(srcPath);
1180
- await this.writeFile(destPath, content);
1181
- await this.rm(srcPath);
1182
- }
1183
- /**
1184
- * Synchronously moves a file from one path to another in the virtual file system (VFS).
1185
- *
1186
- * @param srcPath - The source path to move
1187
- * @param destPath - The destination path to move to
1188
- */
1189
- moveSync(srcPath, destPath) {
1190
- const content = this.readFileSync(srcPath);
1191
- this.writeFileSync(destPath, content);
1192
- this.rmSync(srcPath);
1193
- }
1194
- /**
1195
- * Copies a file from one path to another in the virtual file system (VFS).
1196
- *
1197
- * @param srcPath - The source path to copy
1198
- * @param destPath - The destination path to copy to
1199
- */
1200
- async copy(srcPath, destPath) {
1201
- const content = await this.readFile(srcPath);
1202
- await this.writeFile(destPath, content);
1203
- }
1204
- /**
1205
- * Synchronously copies a file from one path to another in the virtual file system (VFS).
1206
- *
1207
- * @param srcPath - The source path to copy
1208
- * @param destPath - The destination path to copy to
1209
- */
1210
- copySync(srcPath, destPath) {
1211
- const content = this.readFileSync(srcPath);
1212
- this.writeFileSync(destPath, content);
1213
- }
1214
- /**
1215
- * Lists files in a given path.
1216
- *
1217
- * @param pathOrId - The path to list files from.
1218
- * @param options - Options for listing files, such as encoding and recursion.
1219
- * @returns An array of file names in the specified path.
1220
- */
1221
- async readdir(pathOrId, options = "utf8") {
1222
- return this.#unifiedFS.resolveFS(pathOrId).promises.readdir(toFilePath(pathOrId), options);
1223
- }
1224
- /**
1225
- * Asynchronously reads a file from the virtual file system (VFS).
1226
- *
1227
- * @param pathOrId - The path or ID of the file to read.
1228
- * @returns A promise that resolves to the contents of the file as a string, or undefined if the file does not exist.
1229
- */
1230
- async readFile(pathOrId, options = "utf8") {
1231
- const filePath = await this.resolve(pathOrId);
1232
- if (filePath && this.isFile(filePath)) {
1233
- let result;
1234
- if (isFunction(this.#unifiedFS.resolveFS(filePath).promises.readFile)) {
1235
- result = (await this.#unifiedFS.resolveFS(filePath).promises.readFile(filePath, options))?.toString("utf8");
1236
- } else {
1237
- result = this.#unifiedFS.resolveFS(filePath).readFileSync(filePath, options);
1238
- }
1239
- return isBuffer(result) ? bufferToString(result) : result;
1240
- }
1241
- return void 0;
1242
- }
1243
- /**
1244
- * Synchronously reads a file from the virtual file system (VFS).
1245
- *
1246
- * @param pathOrId - The path or ID of the file to read.
1247
- * @returns The contents of the file as a string, or undefined if the file does not exist.
1248
- */
1249
- readFileSync(pathOrId, options = "utf8") {
1250
- const filePath = this.resolveSync(pathOrId);
1251
- if (filePath && this.isFile(filePath)) {
1252
- const result = this.#unifiedFS.resolveFS(filePath).readFileSync(filePath, options);
1253
- return isBuffer(result) ? bufferToString(result) : result;
1254
- }
1255
- return void 0;
1256
- }
1257
- /**
1258
- * Writes a file to the virtual file system (VFS).
1259
- *
1260
- * @param path - The path to the file.
1261
- * @param data - The contents of the file.
1262
- * @param options - Optional parameters for writing the file.
1263
- * @returns A promise that resolves when the file is written.
1264
- */
1265
- async writeFile(path, data = "", options = "utf8") {
1266
- if (!this.isDirectory(findFilePath(this.#normalizePath(path)))) {
1267
- await this.mkdir(findFilePath(this.#normalizePath(path)), isPowerlinesWriteFileOptions(options) ? options : void 0);
1268
- }
1269
- const metadata = isVirtualFileData(data) ? data : {};
1270
- metadata.id = this.#normalizeId(path);
1271
- let code = isVirtualFileData(data) ? metadata.code : data;
1272
- if ((!isPowerlinesWriteFileOptions(options) || !options.skipFormat) && isSetString(code)) {
1273
- const resolvedConfig = await resolveConfig(this.#normalizePath(path));
1274
- if (resolvedConfig) {
1275
- code = await format(code, {
1276
- absolutePath: this.#normalizePath(path),
1277
- ...resolvedConfig
1278
- });
1279
- }
1280
- }
1281
- const outputMode = this.#unifiedFS.resolveMode(this.#normalizePath(path), isPowerlinesWriteFileOptions(options) ? options : void 0);
1282
- this.#log(LogLevelLabel.TRACE, `Writing ${this.#normalizePath(path)} file to the ${outputMode === "fs" ? "" : "virtual "}file system (size: ${prettyBytes(new Blob(toArray(code)).size)})`);
1283
- this.#metadata[metadata.id] = {
1284
- mode: outputMode,
1285
- variant: "normal",
1286
- timestamp: Date.now(),
1287
- ...metadata
1288
- };
1289
- this.#paths[metadata.id] = this.#normalizePath(path);
1290
- this.#ids[this.#normalizePath(path)] = metadata.id;
1291
- const ifs = this.#unifiedFS.resolveFS(this.#normalizePath(path), isPowerlinesWriteFileOptions(options) ? options : void 0);
1292
- if (isFunction(ifs.promises.writeFile)) {
1293
- return ifs.promises.writeFile(this.#normalizePath(path), code, isSetObject(options) ? omit(options, [
1294
- "mode"
1295
- ]) : "utf8");
1296
- }
1297
- return ifs.writeFileSync(this.#normalizePath(path), code, isSetObject(options) ? omit(options, [
1298
- "mode"
1299
- ]) : "utf8");
1300
- }
1301
- /**
1302
- * Synchronously writes a file to the virtual file system (VFS).
1303
- *
1304
- * @param path - The file to write.
1305
- * @param data - The contents of the file.
1306
- * @param options - Optional parameters for writing the file.
1307
- */
1308
- writeFileSync(path, data = "", options = "utf8") {
1309
- if (!this.isDirectory(findFilePath(this.#normalizePath(path)))) {
1310
- this.mkdirSync(findFilePath(this.#normalizePath(path)), isPowerlinesWriteFileOptions(options) ? options : void 0);
1311
- }
1312
- const metadata = isVirtualFileData(data) ? data : {};
1313
- metadata.id = this.#normalizeId(path);
1314
- const code = isVirtualFileData(data) ? metadata.code : data;
1315
- const outputMode = this.#unifiedFS.resolveMode(this.#normalizePath(path), isPowerlinesWriteFileOptions(options) ? options : void 0);
1316
- this.#log(LogLevelLabel.TRACE, `Writing ${this.#normalizePath(path)} file to the ${outputMode === "fs" ? "" : "virtual "}file system (size: ${prettyBytes(new Blob(toArray(code)).size)})`);
1317
- this.#metadata[metadata.id] = {
1318
- mode: outputMode,
1319
- variant: "normal",
1320
- timestamp: Date.now(),
1321
- ...metadata
1322
- };
1323
- this.#paths[metadata.id] = this.#normalizePath(path);
1324
- this.#ids[this.#normalizePath(path)] = metadata.id;
1325
- const writeStream = this.#unifiedFS.resolveFS(this.#normalizePath(path), isPowerlinesWriteFileOptions(options) ? options : void 0).createWriteStream(this.#normalizePath(path));
1326
- try {
1327
- writeStream.write(code);
1328
- } finally {
1329
- writeStream.close();
1330
- }
1331
- }
1332
- /**
1333
- * Synchronously checks if a file exists in the virtual file system (VFS).
1334
- *
1335
- * @param pathOrId - The path or ID of the file to check.
1336
- * @returns `true` if the file exists, otherwise `false`.
1337
- */
1338
- existsSync(pathOrId) {
1339
- return !!this.resolveSync(pathOrId);
1340
- }
1341
- /**
1342
- * Retrieves the metadata of a file in the virtual file system (VFS).
1343
- *
1344
- * @param pathOrId - The path or ID of the file to retrieve metadata for.
1345
- * @returns The metadata of the file, or undefined if the file does not exist.
1346
- */
1347
- getMetadata(pathOrId) {
1348
- const resolved = this.resolveSync(pathOrId);
1349
- if (resolved && this.metadata[resolved]) {
1350
- return this.metadata[resolved];
1351
- }
1352
- return void 0;
1353
- }
1354
- /**
1355
- * Checks if a file exists in the virtual file system (VFS).
1356
- *
1357
- * @remarks
1358
- * This is a base method used by {@link existsSync} - it does not try to resolve the path prior to checking if it exists or not.
1359
- *
1360
- * @param pathOrId - The path of the file to check.
1361
- * @returns `true` if the file exists, otherwise `false`.
1362
- */
1363
- isFile(pathOrId) {
1364
- const resolved = this.resolveSync(pathOrId);
1365
- return !!(resolved && (this.#unifiedFS.virtual.existsSync(resolved) && this.#unifiedFS.virtual.lstatSync(resolved).isFile() || this.#unifiedFS.physical.existsSync(resolved) && this.#unifiedFS.physical.lstatSync(resolved).isFile() || this.#unifiedFS.resolveFS(resolved).existsSync(resolved) && this.#unifiedFS.resolveFS(resolved).lstatSync(resolved).isFile()));
1366
- }
1367
- /**
1368
- * Checks if a directory exists in the virtual file system (VFS).
1369
- *
1370
- * @param pathOrId - The path of the directory to check.
1371
- * @returns `true` if the directory exists, otherwise `false`.
1372
- */
1373
- isDirectory(pathOrId) {
1374
- const resolved = this.resolveSync(pathOrId);
1375
- return !!(resolved && (this.#unifiedFS.virtual.existsSync(resolved) && this.#unifiedFS.virtual.lstatSync(resolved).isDirectory() || this.#unifiedFS.physical.existsSync(resolved) && this.#unifiedFS.physical.lstatSync(resolved).isDirectory() || this.#unifiedFS.resolveFS(resolved).existsSync(resolved) && this.#unifiedFS.resolveFS(resolved).lstatSync(resolved).isDirectory()));
1376
- }
1377
- /**
1378
- * Retrieves the status of a file in the virtual file system (VFS).
1379
- *
1380
- * @param pathOrId - The path or ID of the file to retrieve status for.
1381
- * @returns A promise that resolves to the file's status information, or false if the file does not exist.
1382
- */
1383
- async stat(pathOrId, options) {
1384
- return this.#unifiedFS.resolveFS(pathOrId).promises.stat(await this.resolve(pathOrId) || pathOrId, options);
1385
- }
1386
- /**
1387
- * Synchronously retrieves the status of a file in the virtual file system (VFS).
1388
- *
1389
- * @param pathOrId - The path or ID of the file to retrieve status for.
1390
- * @returns The file's status information, or false if the file does not exist.
1391
- */
1392
- statSync(pathOrId) {
1393
- return this.#unifiedFS.resolveFS(pathOrId).statSync(this.resolveSync(pathOrId) || pathOrId);
1394
- }
1395
- /**
1396
- * Retrieves the status of a symbolic link in the virtual file system (VFS).
1397
- *
1398
- * @param pathOrId - The path or ID of the symbolic link to retrieve status for.
1399
- * @returns A promise that resolves to the symbolic link's status information, or false if the link does not exist.
1400
- */
1401
- async lstat(pathOrId, options) {
1402
- return this.#unifiedFS.resolveFS(pathOrId).promises.lstat(await this.resolve(pathOrId) || pathOrId, options);
1403
- }
1404
- /**
1405
- * Synchronously retrieves the status of a symbolic link in the virtual file system (VFS).
1406
- *
1407
- * @param pathOrId - The path or ID of the symbolic link to retrieve status for.
1408
- * @returns The symbolic link's status information, or false if the link does not exist.
1409
- */
1410
- lstatSync(pathOrId, options) {
1411
- return this.#unifiedFS.resolveFS(pathOrId).lstatSync(this.resolveSync(pathOrId) || pathOrId, options);
1412
- }
1413
- /**
1414
- * Resolves a path or ID to its real path in the virtual file system (VFS).
1415
- *
1416
- * @param pathOrId - The path or ID to resolve.
1417
- * @returns The resolved real path if it exists, otherwise undefined.
1418
- */
1419
- realpathSync(pathOrId) {
1420
- const filePath = this.resolveSync(pathOrId);
1421
- if (!filePath) {
1422
- throw new Error(`File not found: ${pathOrId}`);
1423
- }
1424
- return filePath;
1425
- }
1426
- /**
1427
- * A helper function to resolve modules in the virtual file system (VFS).
1428
- *
1429
- * @remarks
1430
- * This function can be used to resolve modules relative to the project root directory.
1431
- *
1432
- * @example
1433
- * ```ts
1434
- * const resolved = await context.resolvePath("some-module", "/path/to/importer");
1435
- * ```
1436
- *
1437
- * @param id - The module to resolve.
1438
- * @param importer - An optional path to the importer module.
1439
- * @param options - Additional resolution options.
1440
- * @returns A promise that resolves to the resolved module path.
1441
- */
1442
- async resolve(id, importer, options = {}) {
1443
- let result = this.resolverCache.get(this.#normalizeId(id));
1444
- if (result) {
1445
- return result;
1446
- }
1447
- result = this.paths[this.#normalizeId(id)];
1448
- if (!result) {
1449
- const paths = options.paths ?? [];
1450
- if (importer && !paths.includes(importer)) {
1451
- paths.push(importer);
1452
- }
1453
- paths.push(this.#context.workspaceConfig.workspaceRoot);
1454
- paths.push(appendPath(this.#context.config.projectRoot, this.#context.workspaceConfig.workspaceRoot));
1455
- paths.push(appendPath(this.#context.config.sourceRoot, this.#context.workspaceConfig.workspaceRoot));
1456
- paths.push(...Object.keys(this.#context.tsconfig.options.paths ?? {}).filter((tsconfigPath) => id.startsWith(tsconfigPath.replace(/\*$/, ""))).map((tsconfigPath) => this.#context.tsconfig.options.paths?.[tsconfigPath]).flat().filter(Boolean).map((tsconfigPath) => appendPath(tsconfigPath, this.#context.workspaceConfig.workspaceRoot)));
1457
- for (const combination of getResolutionCombinations(id, {
1458
- paths
1459
- })) {
1460
- if (this.#existsSync(combination)) {
1461
- result = combination;
1462
- }
1463
- }
1464
- try {
1465
- result = await resolve(id, {
1466
- paths
1467
- });
1468
- } catch {
1469
- }
1470
- }
1471
- if (result) {
1472
- result = toAbsolutePath(appendPath(result, this.#context.config.projectRoot), this.#context.workspaceConfig.workspaceRoot);
1473
- this.resolverCache.set(this.#normalizeId(id), result);
1474
- }
1475
- return result;
1476
- }
1477
- /**
1478
- * A synchronous helper function to resolve modules using the Jiti resolver
1479
- *
1480
- * @remarks
1481
- * This function can be used to resolve modules relative to the project root directory.
1482
- *
1483
- * @example
1484
- * ```ts
1485
- * const resolvedPath = context.resolveSync("some-module", "/path/to/importer");
1486
- * ```
1487
- *
1488
- * @param id - The module to resolve.
1489
- * @param importer - An optional path to the importer module.
1490
- * @param options - Additional resolution options.
1491
- * @returns The resolved module path.
1492
- */
1493
- resolveSync(id, importer, options = {}) {
1494
- let result = this.resolverCache.get(this.#normalizeId(id));
1495
- if (result) {
1496
- return result;
1497
- }
1498
- result = this.paths[this.#normalizeId(id)];
1499
- if (!result) {
1500
- const paths = options.paths ?? [];
1501
- if (importer && !paths.includes(importer)) {
1502
- paths.push(importer);
1503
- }
1504
- paths.push(this.#context.workspaceConfig.workspaceRoot);
1505
- paths.push(joinPaths$1(this.#context.workspaceConfig.workspaceRoot, this.#context.config.projectRoot));
1506
- paths.push(joinPaths$1(this.#context.workspaceConfig.workspaceRoot, this.#context.config.sourceRoot));
1507
- paths.push(...Object.keys(this.#context.tsconfig?.options?.paths ?? {}).filter((tsconfigPath) => id.startsWith(tsconfigPath.replace(/\*$/, ""))).map((tsconfigPath) => this.#context.tsconfig?.options?.paths?.[tsconfigPath]).flat().filter(Boolean).map((tsconfigPath) => appendPath(tsconfigPath, this.#context.workspaceConfig.workspaceRoot)));
1508
- for (const combination of getResolutionCombinations(id, {
1509
- paths
1510
- })) {
1511
- if (this.#existsSync(combination)) {
1512
- result = combination;
1513
- }
1514
- }
1515
- try {
1516
- result = resolveSync(id, {
1517
- paths
1518
- });
1519
- } catch {
1520
- }
1521
- }
1522
- if (result) {
1523
- result = toAbsolutePath(appendPath(result, this.#context.config.projectRoot), this.#context.workspaceConfig.workspaceRoot);
1524
- this.resolverCache.set(this.#normalizeId(id), result);
1525
- }
1526
- return result;
1527
- }
1528
- /**
1529
- * Disposes of the virtual file system (VFS) by saving its state to disk.
1530
- */
1531
- async dispose() {
1532
- if (!this.#isDisposed) {
1533
- this.#isDisposed = true;
1534
- this.#log(LogLevelLabel.DEBUG, "Disposing virtual file system...");
1535
- await this.unlink(joinPaths$1(this.#context.dataPath, "fs.bin"));
1536
- const message = new $.Message();
1537
- const fs2 = message.initRoot(FileSystem);
1538
- const virtualFiles = Object.entries(this.#unifiedFS.toJSON()).filter(([, code]) => code);
1539
- const files = fs2._initFiles(virtualFiles.length);
1540
- virtualFiles.filter(([, code]) => code).forEach(([path, code], index) => {
1541
- const fd = files.get(index);
1542
- fd.path = path;
1543
- fd.code = code || "";
1544
- });
1545
- const ids = fs2._initIds(Object.keys(this.ids).length);
1546
- Object.entries(this.ids).filter(([, path]) => path).forEach(([id, path], index) => {
1547
- const fileId = ids.get(index);
1548
- fileId.id = id;
1549
- fileId.path = path;
1550
- });
1551
- const metadata = fs2._initMetadata(Object.keys(this.metadata).length);
1552
- Object.entries(this.metadata).filter(([, value]) => value).forEach(([id, value], index) => {
1553
- const fileMetadata = metadata.get(index);
1554
- fileMetadata.id = id;
1555
- fileMetadata.mode = value.mode;
1556
- fileMetadata.type = value.type;
1557
- fileMetadata.timestamp = value.timestamp ?? BigInt(Date.now());
1558
- if (value.properties) {
1559
- const props = fileMetadata._initProperties(Object.keys(value.properties).length);
1560
- Object.entries(value.properties).forEach(([key, val], index2) => {
1561
- const prop = props.get(index2);
1562
- prop.key = key;
1563
- prop.value = val;
1564
- });
1565
- }
1566
- });
1567
- await writeFileBuffer(joinPaths$1(this.#context.dataPath, "fs.bin"), message.toArrayBuffer());
1568
- this.#resolverCache.save(true);
1569
- this.#log(LogLevelLabel.DEBUG, "Virtual file system disposed.");
1570
- }
1571
- }
1572
- /**
1573
- * Initializes the virtual file system (VFS) by patching the file system module if necessary.
1574
- */
1575
- [__VFS_PATCH__]() {
1576
- if (!this.#isPatched && this.#context.config.output.mode !== "fs") {
1577
- this.#revert = patchFS(_fs, this);
1578
- this.#isPatched = true;
1579
- }
1580
- }
1581
- /**
1582
- * Reverts the file system module to its original state if it was previously patched.
1583
- */
1584
- [__VFS_REVERT__]() {
1585
- if (this.#isPatched && this.#context.config.output.mode !== "fs") {
1586
- if (!this.#revert) {
1587
- throw new Error("Attempting to revert File System patch prior to calling `__init__` function");
1588
- }
1589
- this.#revert?.();
1590
- this.#isPatched = false;
1591
- }
1592
- }
1593
- async [Symbol.asyncDispose]() {
1594
- return this.dispose();
1595
- }
1596
- };
1597
-
1598
- // src/lib/contexts/context.ts
1599
- var configCache = /* @__PURE__ */ new WeakMap();
1600
- var PowerlinesContext = class _PowerlinesContext {
1601
- static {
1602
- __name(this, "PowerlinesContext");
1603
- }
1604
- /**
1605
- * Internal reference to the API instance
1606
- *
1607
- * @internal
1608
- */
1609
- #api;
1610
- #workspaceConfig;
1611
- #checksum = null;
1612
- #buildId = uuid();
1613
- #releaseId = uuid();
1614
- #timestamp = Date.now();
1615
- #envPaths;
1616
- #fs;
1617
- #tsconfig;
1618
- #program;
1619
- #resolvePatterns = [];
1620
- #getConfigProps(config = {}) {
1621
- return {
1622
- variant: config.build?.variant,
1623
- projectType: config.type,
1624
- projectRoot: config.root,
1625
- name: config.name,
1626
- title: config.title,
1627
- description: config.description,
1628
- sourceRoot: config.sourceRoot,
1629
- configFile: config.configFile,
1630
- customLogger: config.customLogger,
1631
- logLevel: config.logLevel,
1632
- tsconfig: config.tsconfig,
1633
- tsconfigRaw: config.tsconfigRaw,
1634
- skipCache: config.skipCache,
1635
- skipInstalls: config.skipInstalls,
1636
- entry: config.entry,
1637
- output: config.output,
1638
- plugins: config.plugins,
1639
- mode: config.mode,
1640
- lint: config.lint,
1641
- transform: config.transform,
1642
- build: config.build,
1643
- framework: config.framework
1644
- };
1645
- }
1646
- /**
1647
- * Create a new Storm context from the workspace root and user config.
1648
- *
1649
- * @param workspaceRoot - The root directory of the workspace.
1650
- * @param config - The user configuration options.
1651
- * @returns A promise that resolves to the new context.
1652
- */
1653
- static async from(workspaceRoot, config) {
1654
- const context = new _PowerlinesContext(await loadWorkspaceConfig(workspaceRoot, config.root));
1655
- await context.withUserConfig(config);
1656
- context.powerlinesPath = await resolvePackage("powerlines");
1657
- if (!context.powerlinesPath) {
1658
- throw new Error("Could not resolve `powerlines` package location.");
1659
- }
1660
- return context;
1661
- }
1662
- /**
1663
- * An object containing the dependencies that should be installed for the project
1664
- */
1665
- dependencies = {};
1666
- /**
1667
- * An object containing the development dependencies that should be installed for the project
1668
- */
1669
- devDependencies = {};
1670
- /**
1671
- * The persisted meta information about the current build
1672
- */
1673
- persistedMeta = void 0;
1674
- /**
1675
- * The path to the Powerlines package
1676
- */
1677
- powerlinesPath;
1678
- /**
1679
- * The parsed `package.json` file for the project
1680
- */
1681
- packageJson;
1682
- /**
1683
- * The parsed `project.json` file for the project
1684
- */
1685
- projectJson = void 0;
1686
- /**
1687
- * The module resolver for the project
1688
- */
1689
- resolver;
1690
- /**
1691
- * Internal context fields and methods
1692
- *
1693
- * @internal
1694
- */
1695
- get $$internal() {
1696
- return {
1697
- api: this.#api
1698
- };
1699
- }
1700
- /**
1701
- * The resolved entry type definitions for the project
1702
- */
1703
- get entry() {
1704
- return resolveEntriesSync(this, toArray(this.config.entry));
1705
- }
1706
- /**
1707
- * The TypeScript configuration parsed from the tsconfig file
1708
- */
1709
- get tsconfig() {
1710
- if (!this.#tsconfig) {
1711
- this.tsconfig = {
1712
- tsconfigFilePath: this.config.tsconfig
1713
- };
1714
- }
1715
- return this.#tsconfig;
1716
- }
1717
- /**
1718
- * Sets the TypeScript configuration parsed from the tsconfig file
1719
- */
1720
- set tsconfig(value) {
1721
- this.#tsconfig = value;
1722
- this.#resolvePatterns = tsconfigPathsToRegExp(value?.options?.paths ?? {});
1723
- }
1724
- /**
1725
- * The virtual file system interface for the project
1726
- */
1727
- get fs() {
1728
- if (!this.#fs) {
1729
- this.#fs = VirtualFileSystem.createSync(this);
1730
- }
1731
- return this.#fs;
1732
- }
1733
- /**
1734
- * Get the checksum of the project's current state
1735
- */
1736
- get checksum() {
1737
- return this.#checksum;
1738
- }
1739
- /**
1740
- * The meta information about the current build
1741
- */
1742
- get meta() {
1743
- return {
1744
- buildId: this.#buildId,
1745
- releaseId: this.#releaseId,
1746
- checksum: this.#checksum,
1747
- timestamp: this.#timestamp,
1748
- projectRootHash: murmurhash({
1749
- workspaceRoot: this.workspaceConfig?.workspaceRoot,
1750
- projectRoot: this.config?.projectRoot
1751
- }, {
1752
- maxLength: PROJECT_ROOT_HASH_LENGTH
1753
- }),
1754
- configHash: murmurhash(this.config, {
1755
- maxLength: CACHE_HASH_LENGTH
1756
- })
1757
- };
1758
- }
1759
- /**
1760
- * The resolved configuration options
1761
- */
1762
- get config() {
1763
- return this.resolvedConfig ?? {};
1764
- }
1765
- /**
1766
- * The logger function
1767
- */
1768
- get log() {
1769
- if (!this.logFn) {
1770
- this.logFn = this.createLog();
1771
- }
1772
- return this.logFn;
1773
- }
1774
- /**
1775
- * The workspace configuration
1776
- */
1777
- get workspaceConfig() {
1778
- return this.#workspaceConfig;
1779
- }
1780
- /**
1781
- * The environment paths for the project
1782
- */
1783
- get envPaths() {
1784
- if (!this.#envPaths) {
1785
- this.#envPaths = getEnvPaths({
1786
- orgId: "storm-software",
1787
- appId: "powerlines",
1788
- workspaceRoot: this.workspaceConfig.workspaceRoot
1789
- });
1790
- }
1791
- return this.#envPaths;
1792
- }
1793
- /**
1794
- * Get the path to the artifacts directory for the project
1795
- */
1796
- get artifactsPath() {
1797
- return joinPaths(this.workspaceConfig.workspaceRoot, this.config.projectRoot, this.config.output.artifactsFolder);
1798
- }
1799
- /**
1800
- * Get the path to the builtin modules used by the project
1801
- */
1802
- get builtinsPath() {
1803
- return joinPaths(this.artifactsPath, "builtins");
1804
- }
1805
- /**
1806
- * Get the path to the entry directory for the project
1807
- */
1808
- get entryPath() {
1809
- return joinPaths(this.artifactsPath, "entry");
1810
- }
1811
- /**
1812
- * Get the path to the data directory for the project
1813
- */
1814
- get dataPath() {
1815
- return joinPaths(this.envPaths.data, "projects", getPrefixedProjectRootHash(this.config.name, this.meta.projectRootHash));
1816
- }
1817
- /**
1818
- * Get the path to the cache directory for the project
1819
- */
1820
- get cachePath() {
1821
- return joinPaths(this.envPaths.cache, "projects", murmurhash({
1822
- checksum: this.#checksum,
1823
- config: this.meta.configHash
1824
- }, {
1825
- maxLength: CACHE_HASH_LENGTH
1826
- }));
1827
- }
1828
- /**
1829
- * Get the path to the generated declaration file for the project
1830
- */
1831
- get dtsPath() {
1832
- return this.config.output.dts ? appendPath(this.config.output.dts, this.workspaceConfig.workspaceRoot) : joinPaths(this.workspaceConfig.workspaceRoot, this.config.projectRoot, "powerlines.d.ts");
1833
- }
1834
- /**
1835
- * Get the project root relative to the workspace root
1836
- */
1837
- get relativeToWorkspaceRoot() {
1838
- return relativeToWorkspaceRoot(this.config.projectRoot);
1839
- }
1840
- /**
1841
- * The builtin module id that exist in the Powerlines virtual file system
1842
- */
1843
- get builtins() {
1844
- return Object.values(this.fs.metadata).filter((meta) => meta && meta.type === "builtin").map((meta) => meta?.id).filter(Boolean);
1845
- }
1846
- /**
1847
- * The {@link Project} instance used for type reflection and module manipulation
1848
- *
1849
- * @see https://ts-morph.com/
1850
- *
1851
- * @remarks
1852
- * This instance is created lazily on first access.
1853
- */
1854
- get program() {
1855
- if (!this.#program) {
1856
- this.#program = createProgram(this, {
1857
- skipAddingFilesFromTsConfig: true
1858
- });
1859
- }
1860
- return this.#program;
1861
- }
1862
- /**
1863
- * A helper function to resolve modules in the Virtual File System
1864
- *
1865
- * @remarks
1866
- * This function can be used to resolve modules relative to the project root directory.
1867
- *
1868
- * @example
1869
- * ```ts
1870
- * const resolved = await context.resolve("some-module", "/path/to/importer");
1871
- * ```
1872
- *
1873
- * @param id - The module to resolve.
1874
- * @param importer - An optional path to the importer module.
1875
- * @param options - Additional resolution options.
1876
- * @returns A promise that resolves to the resolved module path.
1877
- */
1878
- async resolveId(id, importer, options = {}) {
1879
- if (this.fs.isVirtual(id)) {
1880
- const result = await this.fs.resolve(id, importer, options);
1881
- if (!result) {
1882
- return void 0;
1883
- }
1884
- return {
1885
- id: `\0${result}`,
1886
- external: this.config.projectType !== "application"
1887
- };
1888
- }
1889
- if (this.config.build.skipNodeModulesBundle) {
1890
- if (match(id, this.#resolvePatterns) || match(id, this.config.build.noExternal)) {
1891
- return void 0;
1892
- }
1893
- if (match(id, this.config.build.external) || id.startsWith("node:")) {
1894
- return {
1895
- id,
1896
- external: true
1897
- };
1898
- }
1899
- if (!/^[A-Z]:[/\\]|^\.{0,2}\/|^\.{1,2}$/.test(id)) {
1900
- return {
1901
- id,
1902
- external: true
1903
- };
1904
- }
1905
- } else {
1906
- if (match(id, this.config.build.noExternal)) {
1907
- return void 0;
1908
- }
1909
- if (match(id, this.config.build.external) || id.startsWith("node:")) {
1910
- return {
1911
- id,
1912
- external: true
1913
- };
1914
- }
1915
- }
1916
- return void 0;
1917
- }
1918
- /**
1919
- * A helper function to load modules from the Virtual File System
1920
- *
1921
- * @remarks
1922
- * This function can be used to load modules relative to the project root directory.
1923
- *
1924
- * @example
1925
- * ```ts
1926
- * const module = await context.load("some-module", "/path/to/importer");
1927
- * ```
1928
- *
1929
- * @param id - The module to load.
1930
- * @returns A promise that resolves to the loaded module.
1931
- */
1932
- async load(id) {
1933
- const resolvedId = await this.fs.resolve(id);
1934
- if (!resolvedId) {
1935
- return void 0;
1936
- }
1937
- const code = await this.fs.readFile(resolvedId);
1938
- if (!code) {
1939
- return void 0;
1940
- }
1941
- return {
1942
- code,
1943
- map: null
1944
- };
1945
- }
1946
- /**
1947
- * Get the builtin virtual files that exist in the Powerlines virtual file system
1948
- */
1949
- async getBuiltins() {
1950
- return Promise.all(Object.entries(this.fs.metadata).filter(([, meta]) => meta && meta.type === "builtin").map(async ([path, meta]) => {
1951
- const code = await this.fs.readFile(path);
1952
- return {
1953
- ...meta,
1954
- path,
1955
- code
1956
- };
1957
- }));
1958
- }
1959
- /**
1960
- * Resolves a entry virtual file and writes it to the VFS if it does not already exist
1961
- *
1962
- * @param code - The source code of the entry file
1963
- * @param path - A path to write the entry file to
1964
- * @param options - Optional write file options
1965
- */
1966
- async emitEntry(code, path, options = {}) {
1967
- return this.fs.writeFile(isAbsolute(path) ? path : appendPath(path, this.entryPath), {
1968
- code,
1969
- type: "entry"
1970
- }, defu2(options, {
1971
- mode: this.config.output.mode
1972
- }));
1973
- }
1974
- /**
1975
- * Resolves a builtin virtual file and writes it to the VFS if it does not already exist
1976
- *
1977
- * @param code - The source code of the builtin file
1978
- * @param id - The unique identifier of the builtin file
1979
- * @param path - An optional path to write the builtin file to
1980
- * @param options - Optional write file options
1981
- */
1982
- async emitBuiltin(code, id, path, options = {}) {
1983
- return this.fs.writeFile(path ? isAbsolute(path) ? path : joinPaths(this.builtinsPath, path) : appendPath(id, this.builtinsPath), {
1984
- id,
1985
- code,
1986
- type: "builtin"
1987
- }, defu2(options, {
1988
- mode: this.config.output.mode
1989
- }));
1990
- }
1991
- /**
1992
- * Update the context using a new user configuration options
1993
- *
1994
- * @param userConfig - The new user configuration options.
1995
- */
1996
- async withUserConfig(userConfig, options = {
1997
- isHighPriority: true
1998
- }) {
1999
- this.mergeUserConfig(userConfig);
2000
- await this.init(this.config.userConfig, options);
2001
- }
2002
- /**
2003
- * Update the context using a new inline configuration options
2004
- *
2005
- * @param inlineConfig - The new inline configuration options.
2006
- */
2007
- async withInlineConfig(inlineConfig, options = {
2008
- isHighPriority: true
2009
- }) {
2010
- this.config.inlineConfig = inlineConfig;
2011
- if (inlineConfig.command === "new") {
2012
- const workspacePackageJsonPath = joinPaths(this.workspaceConfig.workspaceRoot, "package.json");
2013
- if (!existsSync(workspacePackageJsonPath)) {
2014
- throw new Error(`The workspace package.json file could not be found at ${workspacePackageJsonPath}`);
2015
- }
2016
- this.packageJson = await readJsonFile(workspacePackageJsonPath);
2017
- this.workspaceConfig.repository ??= isSetString(this.packageJson?.repository) ? this.packageJson.repository : this.packageJson?.repository?.url;
2018
- }
2019
- await this.init(this.config.inlineConfig, options);
2020
- }
2021
- /**
2022
- * A logging function for fatal messages
2023
- *
2024
- * @param message - The message to log.
2025
- */
2026
- fatal(message) {
2027
- this.log(LogLevelLabel.FATAL, isString(message) ? message : StormJSON.stringify(message));
2028
- }
2029
- /**
2030
- * A logging function for error messages
2031
- *
2032
- * @param message - The message to log.
2033
- */
2034
- error(message) {
2035
- this.log(LogLevelLabel.ERROR, isString(message) ? message : StormJSON.stringify(message));
2036
- }
2037
- /**
2038
- * A logging function for warning messages
2039
- *
2040
- * @param message - The message to log.
2041
- */
2042
- warn(message) {
2043
- this.log(LogLevelLabel.WARN, isString(message) ? message : StormJSON.stringify(message));
2044
- }
2045
- /**
2046
- * A logging function for informational messages
2047
- *
2048
- * @param message - The message to log.
2049
- */
2050
- info(message) {
2051
- this.log(LogLevelLabel.INFO, isString(message) ? message : StormJSON.stringify(message));
2052
- }
2053
- /**
2054
- * A logging function for debug messages
2055
- *
2056
- * @param message - The message to log.
2057
- */
2058
- debug(message) {
2059
- this.log(LogLevelLabel.DEBUG, isString(message) ? message : StormJSON.stringify(message));
2060
- }
2061
- /**
2062
- * A logging function for trace messages
2063
- *
2064
- * @param message - The message to log.
2065
- */
2066
- trace(message) {
2067
- this.log(LogLevelLabel.TRACE, isString(message) ? message : StormJSON.stringify(message));
2068
- }
2069
- /**
2070
- * Create a new logger instance
2071
- *
2072
- * @param name - The name to use for the logger instance
2073
- * @returns A logger function
2074
- */
2075
- createLog(name = null) {
2076
- return createLog(name, {
2077
- ...this.config,
2078
- logLevel: isNull(this.config.logLevel) ? "silent" : this.config.logLevel
2079
- });
2080
- }
2081
- /**
2082
- * Extend the current logger instance with a new name
2083
- *
2084
- * @param name - The name to use for the extended logger instance
2085
- * @returns A logger function
2086
- */
2087
- extendLog(name) {
2088
- return extendLog(this.log, name);
2089
- }
2090
- /**
2091
- * Creates a new StormContext instance.
2092
- *
2093
- * @param workspaceConfig - The workspace configuration.
2094
- */
2095
- constructor(workspaceConfig) {
2096
- this.#workspaceConfig = workspaceConfig;
2097
- this.#envPaths = getEnvPaths({
2098
- orgId: "storm-software",
2099
- appId: "powerlines",
2100
- workspaceRoot: workspaceConfig.workspaceRoot
2101
- });
2102
- }
2103
- /**
2104
- * The resolved configuration for this context
2105
- */
2106
- resolvedConfig = {};
2107
- /**
2108
- * A logger function specific to this context
2109
- */
2110
- logFn;
2111
- /**
2112
- * Generates a checksum representing the current context state
2113
- *
2114
- * @param root - The root directory of the project to generate the checksum for
2115
- * @returns A promise that resolves to a string representing the checksum
2116
- */
2117
- async generateChecksum(root = this.config.projectRoot) {
2118
- this.#checksum = await hashDirectory(root, {
2119
- ignore: [
2120
- "node_modules",
2121
- ".git",
2122
- ".nx",
2123
- ".cache",
2124
- ".storm",
2125
- "tmp",
2126
- "dist"
2127
- ]
2128
- });
2129
- return this.#checksum;
2130
- }
2131
- /**
2132
- * Initialize the context with the provided configuration options
2133
- *
2134
- * @param config - The partial user configuration to use for initialization.
2135
- */
2136
- async init(config = {}, options = {
2137
- isHighPriority: true
2138
- }) {
2139
- const cacheKey = {
2140
- projectRoot: config.root ?? this.config.projectRoot ?? this.config.userConfig?.root ?? this.config.inlineConfig?.root,
2141
- mode: (config.mode ?? this.config.mode) || this.workspaceConfig.mode,
2142
- skipCache: config.skipCache ?? this.config.skipCache ?? false,
2143
- configFile: config.configFile ?? this.config.configFile,
2144
- framework: config.framework ?? this.config.framework ?? "powerlines",
2145
- command: this.config.inlineConfig?.command
2146
- };
2147
- if (configCache.has(cacheKey)) {
2148
- const result = configCache.get(cacheKey);
2149
- this.projectJson = result.projectJson;
2150
- this.packageJson = result.packageJson;
2151
- this.#checksum = result.checksum;
2152
- this.resolver = result.resolver;
2153
- this.mergeUserConfig(result.userConfig.config, this.config.userConfig);
2154
- } else {
2155
- const projectJsonPath = joinPaths(cacheKey.projectRoot, "project.json");
2156
- if (existsSync(projectJsonPath)) {
2157
- this.projectJson = await readJsonFile(projectJsonPath);
2158
- }
2159
- const packageJsonPath = joinPaths(cacheKey.projectRoot, "package.json");
2160
- if (existsSync(packageJsonPath)) {
2161
- this.packageJson = await readJsonFile(packageJsonPath);
2162
- }
2163
- this.#checksum = await this.generateChecksum(cacheKey.projectRoot);
2164
- this.resolver = createResolver({
2165
- workspaceRoot: this.workspaceConfig.workspaceRoot,
2166
- projectRoot: cacheKey.projectRoot,
2167
- cacheDir: this.cachePath,
2168
- mode: cacheKey.mode,
2169
- logLevel: config.logLevel || this.config?.logLevel || this.workspaceConfig.logLevel || "info",
2170
- skipCache: cacheKey.skipCache
2171
- });
2172
- const userConfig = await loadUserConfigFile(cacheKey.projectRoot, this.workspaceConfig.workspaceRoot, this.resolver, cacheKey.command, cacheKey.mode, cacheKey.configFile, cacheKey.framework);
2173
- this.mergeUserConfig(userConfig.config);
2174
- configCache.set(cacheKey, {
2175
- projectJson: this.projectJson,
2176
- packageJson: this.packageJson,
2177
- checksum: this.#checksum,
2178
- resolver: this.resolver,
2179
- userConfig
2180
- });
2181
- }
2182
- this.config.tsconfig ??= getTsconfigFilePath(this.workspaceConfig.workspaceRoot, cacheKey.projectRoot, config.tsconfig);
2183
- if (isSetObject(config)) {
2184
- this.resolvedConfig = defu2({
2185
- inlineConfig: this.config.inlineConfig,
2186
- userConfig: this.config.userConfig
2187
- }, options.isHighPriority ? this.#getConfigProps(config) : {}, {
2188
- command: this.config.inlineConfig?.command,
2189
- ...this.#getConfigProps(this.config.inlineConfig)
2190
- }, this.#getConfigProps(this.config.userConfig), {
2191
- mode: this.workspaceConfig?.mode,
2192
- logLevel: this.workspaceConfig?.logLevel,
2193
- skipCache: this.workspaceConfig?.skipCache
2194
- }, {
2195
- name: this.projectJson?.name || this.packageJson?.name,
2196
- version: this.packageJson?.version,
2197
- description: this.packageJson?.description,
2198
- sourceRoot: this.projectJson?.sourceRoot || appendPath("src", cacheKey.projectRoot),
2199
- output: {
2200
- outputPath: cacheKey.projectRoot ? joinPaths(this.workspaceConfig?.directories?.build || "dist", cacheKey.projectRoot) : this.workspaceConfig?.directories?.build || "dist",
2201
- mode: "virtual",
2202
- dts: joinPaths(cacheKey.projectRoot, `${config.framework ?? "powerlines"}.d.ts`),
2203
- builtinPrefix: config.framework ?? "powerlines",
2204
- artifactsFolder: joinPaths(cacheKey.projectRoot, `.${config.framework ?? "powerlines"}`),
2205
- assets: [
2206
- {
2207
- glob: "LICENSE"
2208
- },
2209
- {
2210
- input: cacheKey.projectRoot,
2211
- glob: "*.md"
2212
- },
2213
- {
2214
- input: cacheKey.projectRoot,
2215
- glob: "package.json"
2216
- }
2217
- ]
2218
- }
2219
- }, options.isHighPriority ? {} : this.#getConfigProps(config), {
2220
- inlineConfig: {},
2221
- userConfig: {},
2222
- framework: "powerlines",
2223
- platform: "neutral",
2224
- mode: "production",
2225
- projectType: "application",
2226
- logLevel: "info",
2227
- preview: false,
2228
- environments: {},
2229
- transform: {
2230
- babel: {
2231
- plugins: [],
2232
- presets: []
2233
- }
2234
- },
2235
- lint: {
2236
- eslint: {}
2237
- },
2238
- build: {
2239
- target: "esnext",
2240
- override: {}
2241
- }
2242
- });
2243
- }
2244
- this.config.entry = getUniqueEntries(this.config.entry);
2245
- if (this.config.name?.startsWith("@") && this.config.name.split("/").filter(Boolean).length > 1) {
2246
- this.config.name = this.config.name.split("/").filter(Boolean)[1];
2247
- }
2248
- this.config.title ??= titleCase(this.config.name);
2249
- if (this.config.build.external) {
2250
- this.config.build.external = getUnique(this.config.build.external);
2251
- }
2252
- if (this.config.build.noExternal) {
2253
- this.config.build.noExternal = getUnique(this.config.build.noExternal);
2254
- }
2255
- this.config.output.format = getUnique(toArray(this.config.output?.format ?? (this.config.projectType === "library" ? [
2256
- "cjs",
2257
- "esm"
2258
- ] : [
2259
- "esm"
2260
- ])));
2261
- if (this.config.projectRoot && this.config.projectRoot !== "." && this.config.projectRoot !== "./" && this.config.projectRoot !== this.workspaceConfig.workspaceRoot) {
2262
- this.config.output.outputPath ??= joinPaths("dist", this.config.projectRoot);
2263
- this.config.output.distPath ??= joinPaths(this.config.projectRoot, "dist");
2264
- } else {
2265
- this.config.output.outputPath ??= "dist";
2266
- this.config.output.distPath ??= "dist";
2267
- }
2268
- this.config.output.assets = getUnique(this.config.output.assets.map((asset) => {
2269
- return {
2270
- glob: isSetObject(asset) ? asset.glob : asset,
2271
- input: isString(asset) || !asset.input || asset.input === "." || asset.input === "/" || asset.input === "./" ? this.workspaceConfig.workspaceRoot : appendPath(asset.input, this.workspaceConfig.workspaceRoot),
2272
- output: appendPath(isSetObject(asset) && asset.output ? joinPaths(this.config.output.outputPath, replacePath(asset.output, this.config.output.outputPath)) : this.config.output.outputPath, this.workspaceConfig.workspaceRoot),
2273
- ignore: isSetObject(asset) && asset.ignore ? toArray(asset.ignore) : void 0
2274
- };
2275
- }));
2276
- this.config.plugins = (this.config.plugins ?? []).filter(Boolean).reduce((ret, plugin) => {
2277
- if (isPlugin(plugin) && checkDedupe(plugin, ret.filter((p) => isPlugin(p)))) {
2278
- return ret;
2279
- }
2280
- ret.push(plugin);
2281
- return ret;
2282
- }, []);
2283
- if (this.config.tsconfig) {
2284
- this.config.tsconfig = replacePathTokens(this, this.config.tsconfig);
2285
- }
2286
- if (this.config.output.dts) {
2287
- this.config.output.dts = replacePathTokens(this, this.config.output.dts);
2288
- }
2289
- if (this.config.build.polyfill) {
2290
- this.config.build.polyfill = this.config.build.polyfill.map((polyfill) => replacePathTokens(this, polyfill));
2291
- }
2292
- if (this.config.output.assets) {
2293
- this.config.output.assets = this.config.output.assets.map((asset) => ({
2294
- ...asset,
2295
- glob: replacePathTokens(this, asset.glob),
2296
- ignore: asset.ignore ? asset.ignore.map((ignore) => replacePathTokens(this, ignore)) : void 0,
2297
- input: replacePathTokens(this, asset.input),
2298
- output: replacePathTokens(this, asset.output)
2299
- }));
2300
- }
2301
- this.#fs ??= await VirtualFileSystem.create(this);
2302
- }
2303
- mergeUserConfig(from = {}, into = this.config.userConfig ?? {}) {
2304
- this.config.userConfig = defu2({
2305
- entry: Array.isArray(from.entry) && from.entry.length > 0 ? from.entry : Array.isArray(into?.entry) && into.entry.length > 0 ? into.entry : []
2306
- }, omit(from ?? {}, [
2307
- "entry"
2308
- ]), omit(into ?? {}, [
2309
- "entry"
2310
- ]));
2311
- if (this.config.userConfig.output?.format) {
2312
- this.config.userConfig.output.format = getUnique(toArray(this.config.userConfig.output?.format));
2313
- }
2314
- this.config.userConfig.plugins = (this.config.userConfig.plugins ?? []).filter(Boolean).reduce((ret, plugin) => {
2315
- if (isPlugin(plugin) && checkDedupe(plugin, ret.filter((p) => isPlugin(p)))) {
2316
- return ret;
2317
- }
2318
- ret.push(plugin);
2319
- return ret;
2320
- }, []);
2321
- }
2322
- };
2323
-
2324
- export { PowerlinesContext, VirtualFileSystem, addPluginHook, checkDedupe, getHookHandler, isHookExternal, isPlugin, isPluginConfig, isPluginConfigObject, isPluginConfigTuple, isPluginHook };