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