powerlines 0.19.5 → 0.21.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 (315) hide show
  1. package/dist/api.cjs +4 -4
  2. package/dist/api.d.cts +7 -8
  3. package/dist/api.d.ts +7 -8
  4. package/dist/api.js +3 -3
  5. package/dist/astro.cjs +10 -10
  6. package/dist/astro.d.cts +1 -2
  7. package/dist/astro.d.ts +1 -2
  8. package/dist/astro.js +7 -7
  9. package/dist/{chunk-MLAYLHZO.js → chunk-237NITCY.js} +20 -5
  10. package/dist/{chunk-5PRY6OJM.cjs → chunk-2HNC5JVK.cjs} +2 -2
  11. package/dist/{chunk-AEJIVPUZ.js → chunk-2Q2PSPZK.js} +1 -1
  12. package/dist/{chunk-JPWBN72J.js → chunk-3FS7K4DZ.js} +1 -1
  13. package/dist/{chunk-BSGWY4AP.cjs → chunk-3JH36WUJ.cjs} +2 -2
  14. package/dist/{chunk-ZOUGUAQY.cjs → chunk-44UTUCBG.cjs} +34 -16
  15. package/dist/{chunk-KMELWYHW.cjs → chunk-6XRDZOE3.cjs} +967 -664
  16. package/dist/{chunk-YQZXG4X6.cjs → chunk-7C2NEC7D.cjs} +2 -2
  17. package/dist/{chunk-GQM2JCO3.js → chunk-A5GTERYN.js} +2 -2
  18. package/dist/chunk-B4KLWFY6.cjs +32 -0
  19. package/dist/{chunk-I4LLZ5BI.js → chunk-C5TKY75S.js} +1 -1
  20. package/dist/{chunk-TK6CN2KT.cjs → chunk-DMXXNXLS.cjs} +4 -4
  21. package/dist/{chunk-MCDMY6GK.cjs → chunk-F4BD5CXH.cjs} +2 -2
  22. package/dist/chunk-GRAVJX3I.js +29 -0
  23. package/dist/chunk-HV7SHEHD.cjs +118 -0
  24. package/dist/{chunk-WJ4CZKXY.js → chunk-JKBJF3UI.js} +1 -1
  25. package/dist/{chunk-BHPTTRBA.js → chunk-L4AXJFX2.js} +32 -14
  26. package/dist/{chunk-Z63SQZUB.cjs → chunk-LKYBC6DX.cjs} +4 -4
  27. package/dist/{chunk-RR7EC4RF.js → chunk-M6XGEVJY.js} +1 -1
  28. package/dist/{chunk-PAJB5K7A.js → chunk-NZXMP4J5.js} +3 -2
  29. package/dist/{chunk-GFINPIIK.js → chunk-OZU47JET.js} +1000 -704
  30. package/dist/{chunk-FCTNMPJF.cjs → chunk-PAMSESZV.cjs} +1 -1
  31. package/dist/chunk-PDFOF6ZP.js +112 -0
  32. package/dist/{chunk-7HKTQSUG.cjs → chunk-PJP4MECA.cjs} +4 -3
  33. package/dist/{chunk-OJSRHKHW.js → chunk-QQGXARP3.js} +1 -1
  34. package/dist/{chunk-ULFJBFI7.cjs → chunk-SQANNMRF.cjs} +22 -7
  35. package/dist/{chunk-HI3LNK6Q.js → chunk-SVDPKN3U.js} +1 -1
  36. package/dist/chunk-SVF4ATJR.cjs +8 -0
  37. package/dist/{chunk-A3FMGMBV.cjs → chunk-UVM4JAR3.cjs} +2 -2
  38. package/dist/{chunk-VICSRRKQ.js → chunk-WU7I52LM.js} +2 -2
  39. package/dist/{chunk-X5LPEBDE.cjs → chunk-WYJGOC3Y.cjs} +2 -2
  40. package/dist/{chunk-LIXKMZW5.cjs → chunk-YG5ORYN2.cjs} +2 -2
  41. package/dist/{chunk-HEG6IAVR.js → chunk-ZPOCM5XZ.js} +1 -1
  42. package/dist/chunk-ZWF7LZXE.js +5 -0
  43. package/dist/config.d.cts +1 -2
  44. package/dist/config.d.ts +1 -2
  45. package/dist/esbuild.cjs +9 -9
  46. package/dist/esbuild.d.cts +1 -2
  47. package/dist/esbuild.d.ts +1 -2
  48. package/dist/esbuild.js +6 -6
  49. package/dist/farm.cjs +5 -5
  50. package/dist/farm.d.cts +1 -2
  51. package/dist/farm.d.ts +1 -2
  52. package/dist/farm.js +4 -4
  53. package/dist/{hooks-C6t50M6a.d.cts → hooks-CJ1W5lrx.d.cts} +1 -1
  54. package/dist/{hooks-Bq2jUAKs.d.ts → hooks-CNEZpkMS.d.ts} +1 -1
  55. package/dist/index.cjs +45 -287
  56. package/dist/index.d.cts +3 -4
  57. package/dist/index.d.ts +3 -4
  58. package/dist/index.js +20 -244
  59. package/dist/lib/build/esbuild.cjs +5 -5
  60. package/dist/lib/build/esbuild.d.cts +3 -5
  61. package/dist/lib/build/esbuild.d.ts +3 -5
  62. package/dist/lib/build/esbuild.js +2 -2
  63. package/dist/lib/build/index.cjs +25 -25
  64. package/dist/lib/build/index.d.cts +3 -5
  65. package/dist/lib/build/index.d.ts +3 -5
  66. package/dist/lib/build/index.js +9 -9
  67. package/dist/lib/build/rolldown.cjs +3 -3
  68. package/dist/lib/build/rolldown.d.cts +1 -3
  69. package/dist/lib/build/rolldown.d.ts +1 -3
  70. package/dist/lib/build/rolldown.js +2 -2
  71. package/dist/lib/build/rollup.cjs +3 -3
  72. package/dist/lib/build/rollup.d.cts +1 -3
  73. package/dist/lib/build/rollup.d.ts +1 -3
  74. package/dist/lib/build/rollup.js +1 -1
  75. package/dist/lib/build/rspack.cjs +2 -2
  76. package/dist/lib/build/rspack.d.cts +1 -3
  77. package/dist/lib/build/rspack.d.ts +1 -3
  78. package/dist/lib/build/rspack.js +1 -1
  79. package/dist/lib/build/tsup.cjs +6 -6
  80. package/dist/lib/build/tsup.d.cts +1 -3
  81. package/dist/lib/build/tsup.d.ts +1 -3
  82. package/dist/lib/build/tsup.js +3 -3
  83. package/dist/lib/build/unbuild.cjs +5 -5
  84. package/dist/lib/build/unbuild.d.cts +2 -4
  85. package/dist/lib/build/unbuild.d.ts +2 -4
  86. package/dist/lib/build/unbuild.js +2 -2
  87. package/dist/lib/build/vite.cjs +5 -5
  88. package/dist/lib/build/vite.d.cts +1 -3
  89. package/dist/lib/build/vite.d.ts +1 -3
  90. package/dist/lib/build/vite.js +3 -3
  91. package/dist/lib/build/webpack.cjs +2 -2
  92. package/dist/lib/build/webpack.d.cts +1 -3
  93. package/dist/lib/build/webpack.d.ts +1 -3
  94. package/dist/lib/build/webpack.js +1 -1
  95. package/dist/lib/chunk-27VJFYDM.cjs +132 -0
  96. package/dist/lib/chunk-3G4C3YAU.js +124 -0
  97. package/dist/lib/{chunk-DX4TFRS3.js → chunk-43VJVIL2.js} +976 -681
  98. package/dist/lib/{chunk-5EXW3ZRC.cjs → chunk-4FX4VOLA.cjs} +25 -4
  99. package/dist/lib/{chunk-ADKYAHF5.js → chunk-5GM5UAUO.js} +32 -12
  100. package/dist/lib/{chunk-JB2JJXGW.js → chunk-5SADLYYK.js} +1 -1
  101. package/dist/lib/{chunk-KXCEN6Y4.js → chunk-5SP6QZLX.js} +1 -1
  102. package/dist/lib/{chunk-TNHDC2ZQ.cjs → chunk-7XHBIYIN.cjs} +1 -20
  103. package/dist/lib/{chunk-SM3S7DYW.js → chunk-BHDQZ6YX.js} +12 -2
  104. package/dist/lib/{chunk-F7IDAYLH.cjs → chunk-CSJ6KNIX.cjs} +12 -9
  105. package/dist/lib/{chunk-37W2ZDLA.cjs → chunk-E2MVGKGH.cjs} +2 -2
  106. package/dist/lib/{chunk-ET5QBFGZ.cjs → chunk-FN7673NC.cjs} +2 -2
  107. package/dist/lib/{chunk-67IBLMW6.cjs → chunk-GDXHCTCX.cjs} +14 -7
  108. package/dist/lib/{chunk-ESNHFT4V.cjs → chunk-HCOHRD3Q.cjs} +26 -13
  109. package/dist/lib/{chunk-SYHVP3OW.js → chunk-HOZ37BFN.js} +23 -4
  110. package/dist/lib/{chunk-7OHD3BD4.js → chunk-HQ5YA43H.js} +12 -9
  111. package/dist/lib/{chunk-47WZIAPZ.js → chunk-IOM7GRZU.js} +5 -8
  112. package/dist/lib/{chunk-WFUO3YPK.js → chunk-L4NEN725.js} +19 -4
  113. package/dist/lib/{chunk-MVSXEH4P.cjs → chunk-LAFEAMNN.cjs} +6 -9
  114. package/dist/lib/{chunk-7Y5MJRWF.js → chunk-LIN4KAV3.js} +57 -34
  115. package/dist/lib/{chunk-LJ4WO7TW.cjs → chunk-LMO7PRBP.cjs} +35 -13
  116. package/dist/lib/{chunk-4AMFNBTX.cjs → chunk-LPA7UJIR.cjs} +956 -659
  117. package/dist/lib/{chunk-OTBLE55Z.cjs → chunk-MPCVQK2D.cjs} +12 -1
  118. package/dist/lib/{chunk-5ASXKB2V.js → chunk-QAXCBFBP.js} +1 -1
  119. package/dist/lib/{chunk-N2EGPL2L.js → chunk-T7RMV2FW.js} +25 -12
  120. package/dist/lib/{chunk-7K7JH3DF.cjs → chunk-ULJVBW4L.cjs} +19 -4
  121. package/dist/lib/{chunk-UDJ37BEE.cjs → chunk-VGSV2BEL.cjs} +57 -34
  122. package/dist/lib/{chunk-AOKLB4V2.cjs → chunk-Y2BHXV33.cjs} +1 -1
  123. package/dist/lib/{chunk-GRJJZ5VJ.js → chunk-YH5GOJS3.js} +2 -15
  124. package/dist/lib/{chunk-Q3ERHHXJ.js → chunk-YV6MDKW4.js} +13 -6
  125. package/dist/lib/{config-LK_Wl1SU.d.cts → config-7vXtXiGg.d.cts} +204 -118
  126. package/dist/lib/{config-CnPcoKqT.d.ts → config-B9aVEiiX.d.ts} +204 -118
  127. package/dist/lib/config-file.d.cts +1 -3
  128. package/dist/lib/config-file.d.ts +1 -3
  129. package/dist/lib/create-program.d.cts +1 -3
  130. package/dist/lib/create-program.d.ts +1 -3
  131. package/dist/lib/entry.cjs +9 -9
  132. package/dist/lib/entry.d.cts +1 -3
  133. package/dist/lib/entry.d.ts +1 -3
  134. package/dist/lib/entry.js +1 -1
  135. package/dist/lib/{hooks-DX1o8l6J.d.ts → hooks-BxUBzqCb.d.ts} +1 -1
  136. package/dist/lib/{hooks-BD2rDhpA.d.cts → hooks-cvv50JDh.d.cts} +1 -1
  137. package/dist/lib/index.cjs +32 -28
  138. package/dist/lib/index.d.cts +326 -7
  139. package/dist/lib/index.d.ts +326 -7
  140. package/dist/lib/index.js +8 -8
  141. package/dist/lib/logger.d.cts +1 -3
  142. package/dist/lib/logger.d.ts +1 -3
  143. package/dist/lib/typescript/compiler-host.d.cts +1 -3
  144. package/dist/lib/typescript/compiler-host.d.ts +1 -3
  145. package/dist/lib/typescript/import-transformer.d.cts +1 -3
  146. package/dist/lib/typescript/import-transformer.d.ts +1 -3
  147. package/dist/lib/typescript/index.d.cts +1 -3
  148. package/dist/lib/typescript/index.d.ts +1 -3
  149. package/dist/lib/typescript/program.d.cts +1 -3
  150. package/dist/lib/typescript/program.d.ts +1 -3
  151. package/dist/lib/unplugin/factory.cjs +5 -5
  152. package/dist/lib/unplugin/factory.d.cts +7 -9
  153. package/dist/lib/unplugin/factory.d.ts +7 -9
  154. package/dist/lib/unplugin/factory.js +4 -4
  155. package/dist/lib/unplugin/index.cjs +8 -8
  156. package/dist/lib/unplugin/index.d.cts +2 -4
  157. package/dist/lib/unplugin/index.d.ts +2 -4
  158. package/dist/lib/unplugin/index.js +5 -5
  159. package/dist/lib/unplugin/plugin.cjs +3 -3
  160. package/dist/lib/unplugin/plugin.d.cts +1 -3
  161. package/dist/lib/unplugin/plugin.d.ts +1 -3
  162. package/dist/lib/unplugin/plugin.js +2 -2
  163. package/dist/lib/unplugin/resolve-id.cjs +2 -2
  164. package/dist/lib/unplugin/resolve-id.d.cts +1 -3
  165. package/dist/lib/unplugin/resolve-id.d.ts +1 -3
  166. package/dist/lib/unplugin/resolve-id.js +1 -1
  167. package/dist/lib/utilities/bundle.cjs +4 -4
  168. package/dist/lib/utilities/bundle.d.cts +1 -3
  169. package/dist/lib/utilities/bundle.d.ts +1 -3
  170. package/dist/lib/utilities/bundle.js +3 -3
  171. package/dist/lib/utilities/cache.d.cts +1 -3
  172. package/dist/lib/utilities/cache.d.ts +1 -3
  173. package/dist/lib/utilities/file-header.d.cts +1 -3
  174. package/dist/lib/utilities/file-header.d.ts +1 -3
  175. package/dist/lib/utilities/index.cjs +14 -14
  176. package/dist/lib/utilities/index.d.cts +1 -3
  177. package/dist/lib/utilities/index.d.ts +1 -3
  178. package/dist/lib/utilities/index.js +5 -5
  179. package/dist/lib/utilities/meta.cjs +8 -8
  180. package/dist/lib/utilities/meta.d.cts +1 -3
  181. package/dist/lib/utilities/meta.d.ts +1 -3
  182. package/dist/lib/utilities/meta.js +1 -1
  183. package/dist/lib/utilities/resolve-path.d.cts +1 -3
  184. package/dist/lib/utilities/resolve-path.d.ts +1 -3
  185. package/dist/lib/utilities/resolve.cjs +5 -5
  186. package/dist/lib/utilities/resolve.d.cts +1 -3
  187. package/dist/lib/utilities/resolve.d.ts +1 -3
  188. package/dist/lib/utilities/resolve.js +4 -4
  189. package/dist/lib/utilities/source-file.d.cts +1 -3
  190. package/dist/lib/utilities/source-file.d.ts +1 -3
  191. package/dist/lib/utilities/source-map.d.cts +1 -3
  192. package/dist/lib/utilities/source-map.d.ts +1 -3
  193. package/dist/lib/utilities/worker.d.cts +1 -3
  194. package/dist/lib/utilities/worker.d.ts +1 -3
  195. package/dist/lib/utilities/write-file.d.cts +1 -3
  196. package/dist/lib/utilities/write-file.d.ts +1 -3
  197. package/dist/next.cjs +9 -9
  198. package/dist/next.js +6 -6
  199. package/dist/nuxt.cjs +11 -11
  200. package/dist/nuxt.js +8 -8
  201. package/dist/plugin-utils/{chunk-YKIS7BLU.cjs → chunk-5MO4BCOW.cjs} +24 -0
  202. package/dist/plugin-utils/{chunk-HHFA3IEZ.js → chunk-CYVV2MB7.js} +24 -0
  203. package/dist/plugin-utils/{chunk-75UVEMIV.cjs → chunk-DZZPNO5H.cjs} +2 -2
  204. package/dist/plugin-utils/{chunk-WEIEQXIJ.cjs → chunk-ECFS7DPV.cjs} +5 -5
  205. package/dist/plugin-utils/{chunk-MQOW6ENT.cjs → chunk-F65J5WOX.cjs} +1 -1
  206. package/dist/plugin-utils/{chunk-IHME6YWJ.js → chunk-GV7O3E7P.js} +1 -1
  207. package/dist/plugin-utils/chunk-J33TXWF6.js +12 -0
  208. package/dist/plugin-utils/{chunk-PK6PYFWY.js → chunk-L277XSSN.js} +1 -1
  209. package/dist/plugin-utils/{chunk-YDYJAGMP.js → chunk-QKMG6ZAU.js} +1 -1
  210. package/dist/plugin-utils/chunk-QP6OJWFG.cjs +14 -0
  211. package/dist/plugin-utils/{chunk-5TL6KEQ5.cjs → chunk-UNAGYQRB.cjs} +4 -4
  212. package/dist/plugin-utils/{chunk-432MQOUZ.js → chunk-XIXI67PY.js} +1 -1
  213. package/dist/plugin-utils/{config-48EWGWXq.d.cts → config-BzVVjChJ.d.cts} +201 -115
  214. package/dist/plugin-utils/{config-48EWGWXq.d.ts → config-BzVVjChJ.d.ts} +201 -115
  215. package/dist/plugin-utils/enforce.cjs +5 -5
  216. package/dist/plugin-utils/enforce.d.cts +1 -3
  217. package/dist/plugin-utils/enforce.d.ts +1 -3
  218. package/dist/plugin-utils/enforce.js +4 -4
  219. package/dist/plugin-utils/extend.cjs +4 -4
  220. package/dist/plugin-utils/extend.d.cts +1 -3
  221. package/dist/plugin-utils/extend.d.ts +1 -3
  222. package/dist/plugin-utils/extend.js +3 -3
  223. package/dist/plugin-utils/get-config-path.cjs +2 -2
  224. package/dist/plugin-utils/get-config-path.d.cts +2 -4
  225. package/dist/plugin-utils/get-config-path.d.ts +2 -4
  226. package/dist/plugin-utils/get-config-path.js +1 -1
  227. package/dist/plugin-utils/helpers.cjs +14 -14
  228. package/dist/plugin-utils/helpers.d.cts +3 -5
  229. package/dist/plugin-utils/helpers.d.ts +3 -5
  230. package/dist/plugin-utils/helpers.js +1 -1
  231. package/dist/plugin-utils/index.cjs +24 -24
  232. package/dist/plugin-utils/index.d.cts +1 -3
  233. package/dist/plugin-utils/index.d.ts +1 -3
  234. package/dist/plugin-utils/index.js +6 -6
  235. package/dist/plugin-utils/merge.cjs +3 -3
  236. package/dist/plugin-utils/merge.d.cts +1 -3
  237. package/dist/plugin-utils/merge.d.ts +1 -3
  238. package/dist/plugin-utils/merge.js +2 -2
  239. package/dist/plugin-utils/paths.cjs +2 -2
  240. package/dist/plugin-utils/paths.d.cts +4 -5
  241. package/dist/plugin-utils/paths.d.ts +4 -5
  242. package/dist/plugin-utils/paths.js +1 -1
  243. package/dist/{resolved-B41SbjnS.d.cts → resolved-D8vIizyA.d.cts} +81 -66
  244. package/dist/{resolved-J7a2Aeuk.d.ts → resolved-DWxXKJYy.d.ts} +81 -66
  245. package/dist/rolldown.cjs +8 -8
  246. package/dist/rolldown.d.cts +1 -2
  247. package/dist/rolldown.d.ts +1 -2
  248. package/dist/rolldown.js +5 -5
  249. package/dist/rollup.cjs +8 -8
  250. package/dist/rollup.d.cts +1 -2
  251. package/dist/rollup.d.ts +1 -2
  252. package/dist/rollup.js +5 -5
  253. package/dist/rspack.cjs +8 -8
  254. package/dist/rspack.d.cts +1 -2
  255. package/dist/rspack.d.ts +1 -2
  256. package/dist/rspack.js +5 -5
  257. package/dist/tsup.cjs +10 -10
  258. package/dist/tsup.js +7 -7
  259. package/dist/types/babel.d.cts +1 -2
  260. package/dist/types/babel.d.ts +1 -2
  261. package/dist/types/build.d.cts +94 -7
  262. package/dist/types/build.d.ts +94 -7
  263. package/dist/types/commands.cjs +2 -2
  264. package/dist/types/commands.d.cts +1 -2
  265. package/dist/types/commands.d.ts +1 -2
  266. package/dist/types/commands.js +1 -1
  267. package/dist/types/config.d.cts +1 -2
  268. package/dist/types/config.d.ts +1 -2
  269. package/dist/types/context.d.cts +2 -3
  270. package/dist/types/context.d.ts +2 -3
  271. package/dist/types/hooks.d.cts +1 -2
  272. package/dist/types/hooks.d.ts +1 -2
  273. package/dist/types/index.cjs +6 -22
  274. package/dist/types/index.d.cts +2 -3
  275. package/dist/types/index.d.ts +2 -3
  276. package/dist/types/index.js +2 -2
  277. package/dist/types/internal.d.cts +2 -3
  278. package/dist/types/internal.d.ts +2 -3
  279. package/dist/types/plugin.d.cts +1 -2
  280. package/dist/types/plugin.d.ts +1 -2
  281. package/dist/types/resolved.d.cts +1 -2
  282. package/dist/types/resolved.d.ts +1 -2
  283. package/dist/types/unplugin.d.cts +1 -2
  284. package/dist/types/unplugin.d.ts +1 -2
  285. package/dist/types/vfs.cjs +4 -20
  286. package/dist/types/vfs.d.cts +47 -54
  287. package/dist/types/vfs.d.ts +47 -54
  288. package/dist/types/vfs.js +1 -1
  289. package/dist/unloader.cjs +8 -8
  290. package/dist/unloader.d.cts +3 -4
  291. package/dist/unloader.d.ts +3 -4
  292. package/dist/unloader.js +5 -5
  293. package/dist/unplugin.cjs +20 -20
  294. package/dist/unplugin.d.cts +4 -5
  295. package/dist/unplugin.d.ts +4 -5
  296. package/dist/unplugin.js +17 -17
  297. package/dist/vite.cjs +9 -9
  298. package/dist/vite.d.cts +1 -2
  299. package/dist/vite.d.ts +1 -2
  300. package/dist/vite.js +6 -6
  301. package/dist/webpack.cjs +8 -8
  302. package/dist/webpack.d.cts +1 -2
  303. package/dist/webpack.d.ts +1 -2
  304. package/dist/webpack.js +5 -5
  305. package/package.json +8 -6
  306. package/dist/chunk-CWCEYGLM.js +0 -43
  307. package/dist/chunk-F5NKLRZD.cjs +0 -49
  308. package/dist/chunk-OBYFBPPO.js +0 -9
  309. package/dist/chunk-RDMLGFIT.js +0 -29
  310. package/dist/chunk-RF6RSWD4.cjs +0 -16
  311. package/dist/chunk-XDLLDHRY.cjs +0 -32
  312. package/dist/lib/chunk-POOHWK7C.cjs +0 -63
  313. package/dist/lib/chunk-VLHOYZG2.js +0 -55
  314. package/dist/plugin-utils/chunk-2HFS2OOG.cjs +0 -14
  315. package/dist/plugin-utils/chunk-CVZA2RT3.js +0 -12
@@ -1,12 +1,12 @@
1
1
  import { writeFile } from './chunk-TANQDHYY.js';
2
2
  import { getFileHeader } from './chunk-GANVMM73.js';
3
- import { __VFS_CACHE__, __VFS_RESOLVER__, __VFS_VIRTUAL__, __VFS_UNIFIED__, __VFS_INIT__, __VFS_REVERT__, CACHE_HASH_LENGTH, PROJECT_ROOT_HASH_LENGTH, getPrefixedProjectRootHash, getChecksum, writeMetaFile } from './chunk-GRJJZ5VJ.js';
4
- import { handleResolveId } from './chunk-WFUO3YPK.js';
3
+ import { CACHE_HASH_LENGTH, PROJECT_ROOT_HASH_LENGTH, getPrefixedProjectRootHash, getChecksum, writeMetaFile } from './chunk-YH5GOJS3.js';
4
+ import { handleResolveId } from './chunk-L4NEN725.js';
5
5
  import { getParsedTypeScriptConfig, getTsconfigFilePath, isIncludeMatchFound } from './chunk-YOENMDZY.js';
6
6
  import { loadWorkspaceConfig, loadUserConfigFile } from './chunk-ZPIKFR7Z.js';
7
7
  import { extendLog, createLog } from './chunk-ENRLU4UR.js';
8
8
  import { getString } from './chunk-M263EZ4F.js';
9
- import { resolveEntriesSync, getUniqueEntries } from './chunk-SM3S7DYW.js';
9
+ import { resolveEntriesSync, getUniqueEntries, replacePathTokens } from './chunk-BHDQZ6YX.js';
10
10
  import { __name } from './chunk-SHUYVCID.js';
11
11
  import { LogLevelLabel } from '@storm-software/config-tools/types';
12
12
  import { relativeToWorkspaceRoot, getWorkspaceRoot } from '@stryke/fs/get-workspace-root';
@@ -21,7 +21,7 @@ import { install } from '@stryke/fs/install';
21
21
  import { listFiles } from '@stryke/fs/list-files';
22
22
  import { isPackageExists, isPackageListed, doesPackageMatch, getPackageListing } from '@stryke/fs/package-fns';
23
23
  import { resolvePackage } from '@stryke/fs/resolve';
24
- import { joinPaths } from '@stryke/path/join-paths';
24
+ import { joinPaths as joinPaths$1 } from '@stryke/path/join-paths';
25
25
  import { replacePath } from '@stryke/path/replace';
26
26
  import { isError } from '@stryke/type-checks/is-error';
27
27
  import { isFunction } from '@stryke/type-checks/is-function';
@@ -31,7 +31,7 @@ import { isSet } from '@stryke/type-checks/is-set';
31
31
  import { isSetObject } from '@stryke/type-checks/is-set-object';
32
32
  import { isSetString } from '@stryke/type-checks/is-set-string';
33
33
  import chalk4 from 'chalk';
34
- import defu3, { defu } from 'defu';
34
+ import defu2, { defu } from 'defu';
35
35
  import Handlebars from 'handlebars';
36
36
  import { declare } from '@babel/helper-plugin-utils';
37
37
  import * as t from '@babel/types';
@@ -43,24 +43,26 @@ import { getUnique } from '@stryke/helpers/get-unique';
43
43
  import { omit } from '@stryke/helpers/omit';
44
44
  import { StormJSON } from '@stryke/json/storm-json';
45
45
  import { appendPath } from '@stryke/path/append';
46
- import { findFilePath, findFileDotExtensionSafe, hasFileExtension, relativePath, findFileName } from '@stryke/path/file-path-fns';
46
+ import { findFileDotExtensionSafe, findFilePath, hasFileExtension, relativePath, findFileName } from '@stryke/path/file-path-fns';
47
47
  import { isAbsolutePath, isAbsolute } from '@stryke/path/is-type';
48
- import { joinPaths as joinPaths$1 } from '@stryke/path/join';
48
+ import { joinPaths } from '@stryke/path/join';
49
49
  import { isNull } from '@stryke/type-checks/is-null';
50
50
  import { isString } from '@stryke/type-checks/is-string';
51
51
  import { uuid } from '@stryke/unique-id/uuid';
52
52
  import { parseAsync } from 'oxc-parser';
53
- import { isUndefined } from '@stryke/type-checks/is-undefined';
54
- import { createJiti } from 'jiti';
53
+ import * as $ from '@stryke/capnp';
55
54
  import { bufferToString } from '@stryke/convert/buffer-to-string';
56
- import { isParentPath } from '@stryke/path/is-parent-path';
55
+ import { readFileBuffer, readFileBufferSync, writeFileBuffer } from '@stryke/fs/buffer';
57
56
  import { prettyBytes } from '@stryke/string-format/pretty-bytes';
58
57
  import { isBuffer } from '@stryke/type-checks/is-buffer';
59
- import { Volume } from 'memfs';
60
58
  import { Blob } from 'node:buffer';
61
59
  import fs from 'node:fs';
62
60
  import { resolveConfig, format } from 'prettier';
61
+ import { isUndefined } from '@stryke/type-checks/is-undefined';
62
+ import { isParentPath } from '@stryke/path/is-parent-path';
63
+ import { Volume } from 'memfs/lib/node/volume';
63
64
  import { Union } from 'unionfs';
65
+ import { createJiti } from 'jiti';
64
66
  import { isObject } from '@stryke/type-checks/is-object';
65
67
  import ts, { createProgram, createCompilerHost, getPreEmitDiagnostics, getLineAndCharacterOfPosition, flattenDiagnosticMessageText } from 'typescript';
66
68
  import { getPackageName, hasPackageVersion, getPackageVersion } from '@stryke/string-format/package';
@@ -170,7 +172,7 @@ var moduleResolverBabelPlugin = /* @__PURE__ */ __name((context) => {
170
172
  }, "moduleResolverBabelPlugin");
171
173
  var DEFAULT_ENVIRONMENT = "default";
172
174
  function createEnvironment(name, userConfig) {
173
- return defu3(userConfig.environments?.[name] ?? {}, {
175
+ return defu2(userConfig.environments?.[name] ?? {}, {
174
176
  name,
175
177
  title: userConfig.title || titleCase(userConfig.name),
176
178
  ssr: false,
@@ -213,94 +215,232 @@ function createDefaultEnvironment(userConfig) {
213
215
  return createEnvironment(DEFAULT_ENVIRONMENT, userConfig);
214
216
  }
215
217
  __name(createDefaultEnvironment, "createDefaultEnvironment");
216
-
217
- // src/types/commands.ts
218
- var SUPPORTED_COMMANDS = [
219
- "new",
220
- "clean",
221
- "prepare",
222
- "lint",
223
- "test",
224
- "build",
225
- "docs",
226
- "release",
227
- "finalize"
228
- ];
229
-
230
- // src/plugin-utils/helpers.ts
231
- function isPlugin(value) {
232
- return isSetObject(value) && "name" in value && isSetString(value.name) && (isUndefined(value.applyToEnvironment) || "applyToEnvironment" in value && isFunction(value.applyToEnvironment)) && (isUndefined(value.dedupe) || "dedupe" in value && isFunction(value.dedupe)) && (isUndefined(value.dependsOn) || "dependsOn" in value && Array.isArray(value.dependsOn) && value.dependsOn.every(isPluginConfig)) && SUPPORTED_COMMANDS.every((command) => isUndefined(value[command]) || command in value && (isFunction(value[command]) || isSetObject(value[command]) && "handler" in value[command] && isFunction(value[command].handler)));
233
- }
234
- __name(isPlugin, "isPlugin");
235
- function isPluginConfigObject(value) {
236
- return isSetObject(value) && "plugin" in value && ((isSetString(value.plugin) || isFunction(value.plugin)) && "options" in value && isSetObject(value.options) || isPlugin(value.plugin));
237
- }
238
- __name(isPluginConfigObject, "isPluginConfigObject");
239
- function isPluginConfigTuple(value) {
240
- return Array.isArray(value) && (value.length === 1 || value.length === 2) && ((isSetString(value[0]) || isFunction(value[0])) && value.length > 1 && isSetObject(value[1]) || isPlugin(value[0]));
241
- }
242
- __name(isPluginConfigTuple, "isPluginConfigTuple");
243
- function isPluginConfig(value) {
244
- return isSetString(value) || isFunction(value) || isPlugin(value) || isPluginConfigObject(value) || isPluginConfigTuple(value);
245
- }
246
- __name(isPluginConfig, "isPluginConfig");
247
- function isPluginHookFunction(value) {
248
- return isFunction(value) || isSetObject(value) && "handler" in value && isFunction(value.handler);
249
- }
250
- __name(isPluginHookFunction, "isPluginHookFunction");
251
- function isPluginHookObject(value) {
252
- return isSetObject(value) && "handler" in value && isFunction(value.handler);
253
- }
254
- __name(isPluginHookObject, "isPluginHookObject");
255
- function isPluginHook(value) {
256
- return isPluginHookFunction(value) || isPluginHookObject(value);
257
- }
258
- __name(isPluginHook, "isPluginHook");
259
- function getHookHandler(pluginHook) {
260
- return isFunction(pluginHook) ? pluginHook : pluginHook.handler;
261
- }
262
- __name(getHookHandler, "getHookHandler");
263
- function isHookExternal(hook) {
264
- return hook.startsWith("vite:") || hook.startsWith("esbuild:") || hook.startsWith("rolldown:") || hook.startsWith("rollup:") || hook.startsWith("webpack:") || hook.startsWith("rspack:") || hook.startsWith("farm:");
265
- }
266
- __name(isHookExternal, "isHookExternal");
267
- function checkDedupe(plugin, plugins) {
268
- return plugin.dedupe === false || plugins.some((p) => p.dedupe !== false && (isFunction(p.dedupe) && p.dedupe(plugin) || p.name === plugin.name));
269
- }
270
- __name(checkDedupe, "checkDedupe");
271
- function addPluginHook(context, plugin, pluginHook, hooksList) {
272
- if (!checkDedupe(plugin, hooksList.map((hook) => hook.plugin))) {
273
- hooksList.push(isFunction(pluginHook) ? {
274
- plugin,
275
- handler: getHookHandler(pluginHook).bind(context)
276
- } : {
277
- plugin,
278
- ...pluginHook,
279
- handler: getHookHandler(pluginHook).bind(context)
280
- });
218
+ BigInt("0xa56c61324b9d6e49");
219
+ var FileMetadata_KeyValuePair = class extends $.Struct {
220
+ static {
221
+ __name(this, "FileMetadata_KeyValuePair");
281
222
  }
282
- }
283
- __name(addPluginHook, "addPluginHook");
284
- function resolveOptions(options) {
285
- return defu3(options, {
286
- interopDefault: true,
287
- fsCache: options.mode !== "development" ? joinPaths(options.cacheDir, "jiti") : false,
288
- moduleCache: options.mode !== "development"
289
- });
290
- }
291
- __name(resolveOptions, "resolveOptions");
292
- function createPluginResolver(options) {
293
- return createJiti(joinPaths(options.workspaceRoot, options.projectRoot), resolveOptions({
294
- ...options
295
- }));
296
- }
297
- __name(createPluginResolver, "createPluginResolver");
298
- function createResolver(options) {
299
- const baseResolver = createJiti(joinPaths(options.workspaceRoot, options.projectRoot), resolveOptions(options));
300
- baseResolver.plugin = createPluginResolver(options);
301
- return baseResolver;
302
- }
303
- __name(createResolver, "createResolver");
223
+ static _capnp = {
224
+ displayName: "KeyValuePair",
225
+ id: "eabb26cf58b2a14c",
226
+ size: new $.ObjectSize(0, 2)
227
+ };
228
+ get key() {
229
+ return $.utils.getText(0, this);
230
+ }
231
+ set key(value) {
232
+ $.utils.setText(0, value, this);
233
+ }
234
+ get value() {
235
+ return $.utils.getText(1, this);
236
+ }
237
+ set value(value) {
238
+ $.utils.setText(1, value, this);
239
+ }
240
+ toString() {
241
+ return "FileMetadata_KeyValuePair_" + super.toString();
242
+ }
243
+ };
244
+ var FileMetadata = class _FileMetadata extends $.Struct {
245
+ static {
246
+ __name(this, "FileMetadata");
247
+ }
248
+ static KeyValuePair = FileMetadata_KeyValuePair;
249
+ static _capnp = {
250
+ displayName: "FileMetadata",
251
+ id: "8e2cab5d7e28c7b3",
252
+ size: new $.ObjectSize(0, 4),
253
+ defaultVariant: "normal"
254
+ };
255
+ static _Properties;
256
+ /**
257
+ * The variant of the file.
258
+ *
259
+ */
260
+ get id() {
261
+ return $.utils.getText(0, this);
262
+ }
263
+ set id(value) {
264
+ $.utils.setText(0, value, this);
265
+ }
266
+ /**
267
+ * The output mode of the file.
268
+ *
269
+ */
270
+ get variant() {
271
+ return $.utils.getText(1, this, _FileMetadata._capnp.defaultVariant);
272
+ }
273
+ set variant(value) {
274
+ $.utils.setText(1, value, this);
275
+ }
276
+ /**
277
+ * Additional metadata associated with the file.
278
+ *
279
+ */
280
+ get mode() {
281
+ return $.utils.getText(2, this);
282
+ }
283
+ set mode(value) {
284
+ $.utils.setText(2, value, this);
285
+ }
286
+ _adoptProperties(value) {
287
+ $.utils.adopt(value, $.utils.getPointer(3, this));
288
+ }
289
+ _disownProperties() {
290
+ return $.utils.disown(this.properties);
291
+ }
292
+ get properties() {
293
+ return $.utils.getList(3, _FileMetadata._Properties, this);
294
+ }
295
+ _hasProperties() {
296
+ return !$.utils.isNull($.utils.getPointer(3, this));
297
+ }
298
+ _initProperties(length) {
299
+ return $.utils.initList(3, _FileMetadata._Properties, length, this);
300
+ }
301
+ set properties(value) {
302
+ $.utils.copyFrom(value, $.utils.getPointer(3, this));
303
+ }
304
+ toString() {
305
+ return "FileMetadata_" + super.toString();
306
+ }
307
+ };
308
+ var FileIdentifier = class extends $.Struct {
309
+ static {
310
+ __name(this, "FileIdentifier");
311
+ }
312
+ static _capnp = {
313
+ displayName: "FileIdentifier",
314
+ id: "e12b8732389d7406",
315
+ size: new $.ObjectSize(0, 2)
316
+ };
317
+ /**
318
+ * An additional identifier for the file.
319
+ *
320
+ */
321
+ get path() {
322
+ return $.utils.getText(0, this);
323
+ }
324
+ set path(value) {
325
+ $.utils.setText(0, value, this);
326
+ }
327
+ get id() {
328
+ return $.utils.getText(1, this);
329
+ }
330
+ set id(value) {
331
+ $.utils.setText(1, value, this);
332
+ }
333
+ toString() {
334
+ return "FileIdentifier_" + super.toString();
335
+ }
336
+ };
337
+ var FileData = class extends $.Struct {
338
+ static {
339
+ __name(this, "FileData");
340
+ }
341
+ static _capnp = {
342
+ displayName: "FileData",
343
+ id: "fa6725c8a360f9a2",
344
+ size: new $.ObjectSize(0, 2)
345
+ };
346
+ /**
347
+ * The contents of the file.
348
+ *
349
+ */
350
+ get path() {
351
+ return $.utils.getText(0, this);
352
+ }
353
+ set path(value) {
354
+ $.utils.setText(0, value, this);
355
+ }
356
+ get content() {
357
+ return $.utils.getText(1, this);
358
+ }
359
+ set content(value) {
360
+ $.utils.setText(1, value, this);
361
+ }
362
+ toString() {
363
+ return "FileData_" + super.toString();
364
+ }
365
+ };
366
+ var FileSystemData = class _FileSystemData extends $.Struct {
367
+ static {
368
+ __name(this, "FileSystemData");
369
+ }
370
+ static _capnp = {
371
+ displayName: "FileSystemData",
372
+ id: "aaa72a672ac0732f",
373
+ size: new $.ObjectSize(0, 3)
374
+ };
375
+ static _Ids;
376
+ static _Metadata;
377
+ static _Files;
378
+ _adoptIds(value) {
379
+ $.utils.adopt(value, $.utils.getPointer(0, this));
380
+ }
381
+ _disownIds() {
382
+ return $.utils.disown(this.ids);
383
+ }
384
+ get ids() {
385
+ return $.utils.getList(0, _FileSystemData._Ids, this);
386
+ }
387
+ _hasIds() {
388
+ return !$.utils.isNull($.utils.getPointer(0, this));
389
+ }
390
+ _initIds(length) {
391
+ return $.utils.initList(0, _FileSystemData._Ids, length, this);
392
+ }
393
+ set ids(value) {
394
+ $.utils.copyFrom(value, $.utils.getPointer(0, this));
395
+ }
396
+ _adoptMetadata(value) {
397
+ $.utils.adopt(value, $.utils.getPointer(1, this));
398
+ }
399
+ _disownMetadata() {
400
+ return $.utils.disown(this.metadata);
401
+ }
402
+ get metadata() {
403
+ return $.utils.getList(1, _FileSystemData._Metadata, this);
404
+ }
405
+ _hasMetadata() {
406
+ return !$.utils.isNull($.utils.getPointer(1, this));
407
+ }
408
+ _initMetadata(length) {
409
+ return $.utils.initList(1, _FileSystemData._Metadata, length, this);
410
+ }
411
+ set metadata(value) {
412
+ $.utils.copyFrom(value, $.utils.getPointer(1, this));
413
+ }
414
+ _adoptFiles(value) {
415
+ $.utils.adopt(value, $.utils.getPointer(2, this));
416
+ }
417
+ _disownFiles() {
418
+ return $.utils.disown(this.files);
419
+ }
420
+ get files() {
421
+ return $.utils.getList(2, _FileSystemData._Files, this);
422
+ }
423
+ _hasFiles() {
424
+ return !$.utils.isNull($.utils.getPointer(2, this));
425
+ }
426
+ _initFiles(length) {
427
+ return $.utils.initList(2, _FileSystemData._Files, length, this);
428
+ }
429
+ set files(value) {
430
+ $.utils.copyFrom(value, $.utils.getPointer(2, this));
431
+ }
432
+ toString() {
433
+ return "FileSystemData_" + super.toString();
434
+ }
435
+ };
436
+ FileMetadata._Properties = $.CompositeList(FileMetadata_KeyValuePair);
437
+ FileSystemData._Ids = $.CompositeList(FileIdentifier);
438
+ FileSystemData._Metadata = $.CompositeList(FileMetadata);
439
+ FileSystemData._Files = $.CompositeList(FileData);
440
+
441
+ // src/types/vfs.ts
442
+ var __VFS_PATCH__ = Symbol("__VFS_PATCH__");
443
+ var __VFS_REVERT__ = Symbol("__VFS_REVERT__");
304
444
  function isBufferEncoding(options) {
305
445
  return isSetString(options) || options === null;
306
446
  }
@@ -449,46 +589,201 @@ function patchFS(originalFS, vfs) {
449
589
  };
450
590
  }
451
591
  __name(patchFS, "patchFS");
452
- var VirtualFileSystem = class {
592
+ var UnifiedFS = class _UnifiedFS extends Union {
453
593
  static {
454
- __name(this, "VirtualFileSystem");
594
+ __name(this, "UnifiedFS");
455
595
  }
456
596
  /**
457
597
  * The internal map of virtual files.
458
598
  */
459
- #meta = {};
599
+ #virtualFS = new Volume();
460
600
  /**
461
- * A map of unique identifiers to their virtual file paths.
601
+ * The physical file system.
462
602
  */
463
- #ids = {};
603
+ #physicalFS = cloneFS(fs);
464
604
  /**
465
- * A map of virtual file paths to their underlying file content.
605
+ * The context of the unified file system.
466
606
  */
467
- #cachedFS = /* @__PURE__ */ new Map();
607
+ #context;
608
+ static create(context, data) {
609
+ let result = new _UnifiedFS(context, data);
610
+ result = result.use(result.#physicalFS);
611
+ if (result.#context.config.output.mode !== "fs") {
612
+ result = result.use(result.#virtualFS);
613
+ }
614
+ return result;
615
+ }
468
616
  /**
469
- * A map of virtual file paths to their underlying file content.
617
+ * Gets the virtual file system (VFS).
470
618
  */
471
- #cachedResolver = /* @__PURE__ */ new Map();
619
+ get virtual() {
620
+ return this.#virtualFS;
621
+ }
472
622
  /**
473
- * The internal map of virtual files.
623
+ * Gets the physical file system (FS).
474
624
  */
475
- #virtualFS = new Volume();
625
+ get physical() {
626
+ return this.#physicalFS;
627
+ }
476
628
  /**
477
- * The physical file system.
629
+ * Creates a new instance of the VirtualFileSystem.
630
+ *
631
+ * @param context - The context of the virtual file system, typically containing options and logging functions.
632
+ * @param data - A buffer containing the serialized virtual file system data.
478
633
  */
479
- #fs = cloneFS(fs);
634
+ constructor(context, data) {
635
+ super();
636
+ this.#context = context;
637
+ if (!this.#physicalFS.existsSync(this.#context.dataPath)) {
638
+ this.#physicalFS.mkdirSync(this.#context.dataPath, {
639
+ recursive: true
640
+ });
641
+ }
642
+ if (!this.#physicalFS.existsSync(this.#context.cachePath)) {
643
+ this.#physicalFS.mkdirSync(this.#context.cachePath, {
644
+ recursive: true
645
+ });
646
+ }
647
+ if (!this.#physicalFS.existsSync(joinPaths(this.#context.workspaceConfig.workspaceRoot, this.#context.config.output.outputPath))) {
648
+ this.#physicalFS.mkdirSync(joinPaths(this.#context.workspaceConfig.workspaceRoot, this.#context.config.output.outputPath), {
649
+ recursive: true
650
+ });
651
+ }
652
+ if (this.#context.config.output.mode !== "fs") {
653
+ this.#virtualFS = Volume.fromJSON(data._hasFiles() && data.files.length > 0 ? data.files.values().reduce((ret, file) => {
654
+ ret[file.path] = file.content;
655
+ return ret;
656
+ }, {}) : {});
657
+ if (!this.#virtualFS.existsSync(this.#context.artifactsPath)) {
658
+ this.#virtualFS.mkdirSync(this.#context.artifactsPath, {
659
+ recursive: true
660
+ });
661
+ }
662
+ if (!this.#virtualFS.existsSync(this.#context.builtinsPath)) {
663
+ this.#virtualFS.mkdirSync(this.#context.builtinsPath, {
664
+ recursive: true
665
+ });
666
+ }
667
+ if (!this.#virtualFS.existsSync(this.#context.entryPath)) {
668
+ this.#virtualFS.mkdirSync(this.#context.entryPath, {
669
+ recursive: true
670
+ });
671
+ }
672
+ if (!this.#virtualFS.existsSync(this.#context.dtsPath)) {
673
+ this.#virtualFS.mkdirSync(this.#context.dtsPath, {
674
+ recursive: true
675
+ });
676
+ }
677
+ } else if (this.#context.config.projectType === "application") {
678
+ if (!this.#physicalFS.existsSync(this.#context.artifactsPath)) {
679
+ this.#physicalFS.mkdirSync(this.#context.artifactsPath, {
680
+ recursive: true
681
+ });
682
+ }
683
+ if (!this.#physicalFS.existsSync(this.#context.builtinsPath)) {
684
+ this.#physicalFS.mkdirSync(this.#context.builtinsPath, {
685
+ recursive: true
686
+ });
687
+ }
688
+ if (!this.#physicalFS.existsSync(this.#context.entryPath)) {
689
+ this.#physicalFS.mkdirSync(this.#context.entryPath, {
690
+ recursive: true
691
+ });
692
+ }
693
+ if (!this.#physicalFS.existsSync(this.#context.dtsPath)) {
694
+ this.#physicalFS.mkdirSync(this.#context.dtsPath, {
695
+ recursive: true
696
+ });
697
+ }
698
+ }
699
+ }
700
+ /**
701
+ * Select the file system module to use for the operation based on the path or URL.
702
+ *
703
+ * @param pathOrUrl - The path to perform the file system operation on.
704
+ * @param options - Options for the operation, such as output mode.
705
+ * @returns The file system module used for the operation.
706
+ */
707
+ resolveFS(pathOrUrl, options = {}) {
708
+ const mode = this.resolveMode(pathOrUrl, options);
709
+ if (mode === "virtual") {
710
+ return {
711
+ ...this.#virtualFS,
712
+ mode: "virtual"
713
+ };
714
+ } else if (mode === "fs") {
715
+ return {
716
+ ...this.#physicalFS,
717
+ mode: "fs"
718
+ };
719
+ }
720
+ return {
721
+ ...this,
722
+ mode: this.#context.config.output.mode
723
+ };
724
+ }
725
+ /**
726
+ * Select the file system module to use for the operation based on the path or URL.
727
+ *
728
+ * @param pathOrUrl - The path to perform the file system operation on.
729
+ * @param options - Options for the operation, such as output mode.
730
+ * @returns The file system module used for the operation.
731
+ */
732
+ resolveMode(pathOrUrl, options = {}) {
733
+ if (options.mode === "virtual" && this.#context.config.output.mode !== "fs" && isParentPath(toFilePath(pathOrUrl), this.#context.artifactsPath)) {
734
+ return "virtual";
735
+ } else if (options.mode === "fs" || this.#context.config.output.mode === "fs" || isParentPath(toFilePath(pathOrUrl), this.#context.dataPath) || isParentPath(toFilePath(pathOrUrl), this.#context.cachePath) || isParentPath(toFilePath(pathOrUrl), joinPaths(this.#context.workspaceConfig.workspaceRoot, this.#context.config.output.outputPath))) {
736
+ return "fs";
737
+ }
738
+ return void 0;
739
+ }
740
+ /**
741
+ * Serializes the virtual file system (VFS) to a JSON object.
742
+ *
743
+ * @returns A JSON representation of the virtual file system.
744
+ */
745
+ toJSON() {
746
+ return this.#virtualFS.toJSON();
747
+ }
748
+ };
749
+
750
+ // src/lib/fs/vfs.ts
751
+ var VirtualFileSystem = class _VirtualFileSystem {
752
+ static {
753
+ __name(this, "VirtualFileSystem");
754
+ }
755
+ /**
756
+ * A map of virtual file IDs to their associated metadata.
757
+ */
758
+ #metadata;
759
+ /**
760
+ * A map of virtual file IDs to their underlying file paths.
761
+ */
762
+ #ids;
763
+ /**
764
+ * A map of underlying file paths to their virtual file IDs.
765
+ */
766
+ #paths;
767
+ /**
768
+ * A map of virtual file paths to their underlying file content.
769
+ */
770
+ #cachedResolver = /* @__PURE__ */ new Map();
480
771
  /**
481
772
  * The unified volume that combines the virtual file system with the real file system.
482
773
  *
483
774
  * @remarks
484
775
  * This volume allows for seamless access to both virtual and real files.
485
776
  */
486
- #unifiedFS = new Union();
777
+ #unifiedFS;
487
778
  /**
488
779
  * Indicator specifying if the file system module is patched
489
780
  */
490
781
  #isPatched = false;
491
782
  /**
783
+ * Indicator specifying if the virtual file system (VFS) is disposed
784
+ */
785
+ #isDisposed = false;
786
+ /**
492
787
  * Function to revert require patch
493
788
  */
494
789
  #revert;
@@ -508,160 +803,275 @@ var VirtualFileSystem = class {
508
803
  */
509
804
  #existsSync(path) {
510
805
  const formattedPath = this.formatPath(path);
511
- return this.#virtualFS.existsSync(formattedPath) || this.#fs.existsSync(formattedPath) || this.resolveFS(path).existsSync(formattedPath);
806
+ return this.#unifiedFS.virtual.existsSync(formattedPath) || this.#unifiedFS.physical.existsSync(formattedPath) || this.#unifiedFS.resolveFS(path).existsSync(formattedPath);
512
807
  }
513
808
  /**
514
- * Exposes the internal VFS map for advanced usage.
809
+ * Builds a regular expression from a string pattern for path matching.
810
+ *
811
+ * @param strPattern - The string pattern to convert.
812
+ * @returns A regular expression for matching paths.
515
813
  */
516
- get [__VFS_CACHE__]() {
517
- return this.#cachedFS;
814
+ #buildRegex(strPattern) {
815
+ const token = "::GLOBSTAR::";
816
+ return new RegExp(`^${this.formatPath(strPattern).replace(/\*\*/g, token).replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*/g, "[^/]*").replace(/\?/g, "[^/]").replace(new RegExp(token, "g"), ".*")}$`);
518
817
  }
519
818
  /**
520
- * Exposes the internal VFS resolver cache for advanced usage.
819
+ * Formats a file id by removing the file extension and prepending the runtime prefix.
820
+ *
821
+ * @param id - The file ID to format.
822
+ * @returns The formatted file ID.
521
823
  */
522
- get [__VFS_RESOLVER__]() {
523
- return this.#cachedResolver;
824
+ #formatId(id) {
825
+ const formattedId = toFilePath(id);
826
+ return `${this.#context.config.output.builtinPrefix}:${formattedId.replace(new RegExp(`^${this.#context.config.output.builtinPrefix}:`), "").replace(/^\\0/, "").replace(findFileDotExtensionSafe(formattedId), "")}`;
524
827
  }
525
828
  /**
526
- * Exposes the internal VFS map for advanced usage.
829
+ * Resolves an id parameter to a corresponding virtual file path in the virtual file system (VFS).
830
+ *
831
+ * @param id - The id to resolve.
832
+ * @returns The resolved file id if it exists, otherwise undefined.
527
833
  */
528
- get [__VFS_VIRTUAL__]() {
529
- return this.#virtualFS;
834
+ #resolveId(id) {
835
+ if (this.#ids[this.#formatId(id)]) {
836
+ return this.#ids[this.#formatId(id)] || false;
837
+ }
838
+ return false;
530
839
  }
531
840
  /**
532
- * Exposes the internal UFS map for advanced usage.
841
+ * Resolves a path parameter to a corresponding virtual file path in the virtual file system (VFS).
842
+ *
843
+ * @param path - The path to resolve.
844
+ * @param options - Optional parameters for resolving the path.
845
+ * @returns The resolved file path if it exists, otherwise undefined.
533
846
  */
534
- get [__VFS_UNIFIED__]() {
535
- return this.#unifiedFS;
847
+ #resolvePath(path, options = {}) {
848
+ if (isAbsolutePath(path)) {
849
+ if (this.#existsSync(path)) {
850
+ return path;
851
+ }
852
+ const result = this.#checkVariants(path);
853
+ if (result) {
854
+ return result;
855
+ }
856
+ }
857
+ for (const parentPath of this.#resolveParentPaths(path, options.paths)) {
858
+ const request = joinPaths$1(parentPath, path);
859
+ if (this.#existsSync(request)) {
860
+ return request;
861
+ }
862
+ const result = this.#checkVariants(request);
863
+ if (result) {
864
+ return result;
865
+ }
866
+ }
867
+ return false;
536
868
  }
537
869
  /**
538
- * A proxy to access the underlying file metadata.
870
+ * Resolves parent paths for a given request.
871
+ *
872
+ * @param request - The request path to resolve parent paths for.
873
+ * @param parents - An optional array of parent paths to consider.
874
+ * @returns An array of resolved parent paths.
539
875
  */
540
- get meta() {
541
- return new Proxy(this.#meta, {
542
- get: /* @__PURE__ */ __name((target, prop) => {
543
- if (target[prop]) {
544
- return {
545
- id: prop,
546
- mode: this.#virtualFS.existsSync(prop) ? "virtual" : this.#fs.existsSync(prop) ? "fs" : this.#context.config.output.mode,
547
- details: {},
548
- variant: "normal",
549
- ...target[prop]
550
- };
876
+ #resolveParentPaths(request, parents = []) {
877
+ let paths = [
878
+ this.#context.workspaceConfig.workspaceRoot,
879
+ joinPaths$1(this.#context.workspaceConfig.workspaceRoot, this.#context.config.projectRoot)
880
+ ];
881
+ if (this.#context.tsconfig.options.paths) {
882
+ paths = this.#context.tsconfig.options.paths ? Object.keys(this.#context.tsconfig.options.paths).filter((tsconfigPath) => request.startsWith(tsconfigPath.replaceAll("*", ""))).map((tsconfigPath) => this.#context.tsconfig.options.paths?.[tsconfigPath]).flat().reduce((ret, path) => {
883
+ if (path && !ret.includes(joinPaths$1(this.#context.workspaceConfig.workspaceRoot, path))) {
884
+ ret.push(joinPaths$1(this.#context.workspaceConfig.workspaceRoot, path));
551
885
  }
552
- return void 0;
553
- }, "get"),
554
- set: /* @__PURE__ */ __name((target, prop, value) => {
555
- target[prop] = value;
556
- this.#ids[value.id || prop] = prop;
557
- return true;
558
- }, "set"),
559
- deleteProperty: /* @__PURE__ */ __name((target, prop) => {
560
- delete this.#ids[target[prop]?.id || prop];
561
- delete target[prop];
562
- return true;
563
- }, "deleteProperty")
564
- });
886
+ return ret;
887
+ }, paths) : paths;
888
+ }
889
+ return paths.reduce((ret, path) => {
890
+ if (!ret.includes(path)) {
891
+ ret.push(path);
892
+ }
893
+ return ret;
894
+ }, parents.filter(Boolean).map((p) => this.formatPath(p)));
565
895
  }
566
896
  /**
567
- * A map of module ids to their file paths.
897
+ * Clears the resolver cache for a given path.
898
+ *
899
+ * @param path - The path to clear the resolver cache for.
568
900
  */
569
- get ids() {
570
- return this.#ids;
901
+ #clearResolverCache(path) {
902
+ this.#cachedResolver.keys().filter((key) => key.startsWith(toFilePath(path))).forEach((key) => this.#cachedResolver.delete(key));
571
903
  }
572
904
  /**
573
- * Creates a new instance of the VirtualFileSystem.
905
+ * Check if the file exists with different variants (index, extensions).
574
906
  *
575
- * @param context - The context of the virtual file system, typically containing options and logging functions.
576
- * @param serialized - A map of files/file contents to populate in cache
907
+ * @param request - The request path to check.
908
+ * @param parentPath - An optional parent path to prepend to the request.
909
+ * @returns The file path if it exists, otherwise false.
577
910
  */
578
- constructor(context, serialized = {}) {
579
- this.#context = context;
580
- this.#cachedFS = /* @__PURE__ */ new Map();
581
- this.#meta = Object.fromEntries(Object.entries(serialized.virtualFilesMeta ?? {}));
582
- this.#ids = Object.fromEntries(Object.entries(this.#meta).map(([path, data]) => [
583
- data.id || path,
584
- path
585
- ]));
586
- if (!this.#fs.existsSync(this.#context.dataPath)) {
587
- this.#fs.mkdirSync(this.#context.dataPath, {
588
- recursive: true
589
- });
911
+ #checkVariants(request, parentPath) {
912
+ const path = parentPath ? joinPaths$1(parentPath, request) : request;
913
+ let file = this.#checkExtensions(path);
914
+ if (file) {
915
+ return file;
590
916
  }
591
- if (!this.#fs.existsSync(this.#context.cachePath)) {
592
- this.#fs.mkdirSync(this.#context.cachePath, {
593
- recursive: true
594
- });
917
+ file = this.#checkIndex(path);
918
+ if (file) {
919
+ return file;
595
920
  }
596
- if (!this.#fs.existsSync(joinPaths(this.#context.workspaceConfig.workspaceRoot, this.#context.config.output.outputPath))) {
597
- this.#fs.mkdirSync(joinPaths(this.#context.workspaceConfig.workspaceRoot, this.#context.config.output.outputPath), {
598
- recursive: true
599
- });
921
+ return false;
922
+ }
923
+ /**
924
+ * Check if the index file exists in the given request path.
925
+ *
926
+ * @param request - The request path to check.
927
+ * @returns The index file path if it exists, otherwise false.
928
+ */
929
+ #checkIndex(request) {
930
+ let file = joinPaths$1(request, "index");
931
+ if (this.#existsSync(file)) {
932
+ return file;
600
933
  }
601
- this.#unifiedFS = this.#unifiedFS.use(this.#fs);
602
- if (this.#context.config.output.mode !== "fs") {
603
- if (serialized?.virtualFiles && Object.keys(serialized.virtualFiles).length > 0) {
604
- this.#virtualFS = Volume.fromJSON(serialized.virtualFiles);
605
- }
606
- if (!this.#virtualFS.existsSync(this.#context.artifactsPath)) {
607
- this.#virtualFS.mkdirSync(this.#context.artifactsPath, {
608
- recursive: true
609
- });
610
- }
611
- if (!this.#virtualFS.existsSync(this.#context.builtinsPath)) {
612
- this.#virtualFS.mkdirSync(this.#context.builtinsPath, {
613
- recursive: true
614
- });
615
- }
616
- if (!this.#virtualFS.existsSync(this.#context.entryPath)) {
617
- this.#virtualFS.mkdirSync(this.#context.entryPath, {
618
- recursive: true
619
- });
620
- }
621
- if (!this.#virtualFS.existsSync(this.#context.dtsPath)) {
622
- this.#virtualFS.mkdirSync(this.#context.dtsPath, {
623
- recursive: true
624
- });
625
- }
626
- this.#unifiedFS = this.#unifiedFS.use(this.#virtualFS);
627
- } else if (this.#context.config.projectType === "application") {
628
- if (!this.#fs.existsSync(this.#context.artifactsPath)) {
629
- this.#fs.mkdirSync(this.#context.artifactsPath, {
630
- recursive: true
631
- });
632
- }
633
- if (!this.#fs.existsSync(this.#context.builtinsPath)) {
634
- this.#fs.mkdirSync(this.#context.builtinsPath, {
635
- recursive: true
636
- });
637
- }
638
- if (!this.#fs.existsSync(this.#context.entryPath)) {
639
- this.#fs.mkdirSync(this.#context.entryPath, {
640
- recursive: true
641
- });
642
- }
643
- if (!this.#fs.existsSync(this.#context.dtsPath)) {
644
- this.#fs.mkdirSync(this.#context.dtsPath, {
645
- recursive: true
646
- });
647
- }
934
+ file = this.#checkExtensions(file);
935
+ if (file) {
936
+ return file;
937
+ }
938
+ return false;
939
+ }
940
+ /**
941
+ * Check if the file exists with different extensions.
942
+ *
943
+ * @param request - The request path to check.
944
+ * @returns The file path if it exists with any of the checked extensions, otherwise false.
945
+ */
946
+ #checkExtensions(request) {
947
+ let file = `${request}.ts`;
948
+ if (this.#existsSync(file)) {
949
+ return file;
950
+ }
951
+ file = `${request}.mts`;
952
+ if (this.#existsSync(file)) {
953
+ return file;
954
+ }
955
+ file = `${request}.cts`;
956
+ if (this.#existsSync(file)) {
957
+ return file;
958
+ }
959
+ file = `${request}.tsx`;
960
+ if (this.#existsSync(file)) {
961
+ return file;
962
+ }
963
+ file = `${request}.js`;
964
+ if (this.#existsSync(file)) {
965
+ return file;
966
+ }
967
+ file = `${request}.mjs`;
968
+ if (this.#existsSync(file)) {
969
+ return file;
970
+ }
971
+ file = `${request}.cjs`;
972
+ if (this.#existsSync(file)) {
973
+ return file;
974
+ }
975
+ file = `${request}.jsx`;
976
+ if (this.#existsSync(file)) {
977
+ return file;
978
+ }
979
+ file = `${request}.json`;
980
+ if (this.#existsSync(file)) {
981
+ return file;
982
+ }
983
+ file = `${request}.d.ts`;
984
+ if (this.#existsSync(file)) {
985
+ return file;
648
986
  }
649
- this.#log = extendLog(this.#context.log, "virtual-file-system");
987
+ return false;
650
988
  }
651
- [__VFS_INIT__]() {
652
- if (!this.#isPatched && this.#context.config.output.mode !== "fs") {
653
- this.#revert = patchFS(fs, this);
654
- this.#isPatched = true;
989
+ /**
990
+ * Creates a virtual file system (VFS) that is backed up to a Cap'n Proto message buffer.
991
+ *
992
+ * @param context - The context of the virtual file system, typically containing options and logging functions.
993
+ * @returns A promise that resolves to a new virtual file system instance.
994
+ */
995
+ static async create(context) {
996
+ if (!context.config.skipCache && existsSync(joinPaths$1(context.cachePath, "fs.bin"))) {
997
+ const buffer = await readFileBuffer(joinPaths$1(context.cachePath, "fs.bin"));
998
+ const message2 = new $.Message(buffer, false);
999
+ return new _VirtualFileSystem(context, message2.getRoot(FileSystemData));
655
1000
  }
1001
+ const message = new $.Message();
1002
+ return new _VirtualFileSystem(context, message.initRoot(FileSystemData));
656
1003
  }
657
- [__VFS_REVERT__]() {
658
- if (this.#isPatched && this.#context.config.output.mode !== "fs") {
659
- if (!this.#revert) {
660
- throw new Error("Attempting to revert File System patch prior to calling `__init__` function");
661
- }
662
- this.#revert?.();
663
- this.#isPatched = false;
1004
+ /**
1005
+ * Synchronously creates a virtual file system (VFS) that is backed up to a Cap'n Proto message buffer.
1006
+ *
1007
+ * @param context - The context of the virtual file system, typically containing options and logging functions.
1008
+ * @returns A new virtual file system instance.
1009
+ */
1010
+ static createSync(context) {
1011
+ if (!context.config.skipCache && existsSync(joinPaths$1(context.cachePath, "fs.bin"))) {
1012
+ const buffer = readFileBufferSync(joinPaths$1(context.cachePath, "fs.bin"));
1013
+ const message2 = new $.Message(buffer, false);
1014
+ return new _VirtualFileSystem(context, message2.getRoot(FileSystemData));
1015
+ }
1016
+ const message = new $.Message();
1017
+ return new _VirtualFileSystem(context, message.initRoot(FileSystemData));
1018
+ }
1019
+ /**
1020
+ * A map of file ids to their metadata.
1021
+ */
1022
+ get metadata() {
1023
+ return this.#metadata;
1024
+ }
1025
+ /**
1026
+ * A map of module ids to their file paths.
1027
+ */
1028
+ get ids() {
1029
+ return this.#ids;
1030
+ }
1031
+ /**
1032
+ * A map of virtual file paths to their IDs.
1033
+ */
1034
+ get paths() {
1035
+ return this.#paths;
1036
+ }
1037
+ /**
1038
+ * Creates a new instance of the {@link VirtualFileSystem}.
1039
+ *
1040
+ * @param context - The context of the virtual file system, typically containing options and logging functions.
1041
+ * @param data - A buffer containing the serialized virtual file system data.
1042
+ */
1043
+ constructor(context, data) {
1044
+ this.#context = context;
1045
+ this.#unifiedFS = UnifiedFS.create(context, data);
1046
+ this.#metadata = {};
1047
+ if (data._hasMetadata()) {
1048
+ this.#metadata = data.metadata.values().reduce((ret, data2) => {
1049
+ ret[data2.id] = {
1050
+ id: data2.id,
1051
+ variant: data2.variant,
1052
+ mode: data2.mode,
1053
+ properties: data2._hasProperties() ? data2.properties.values().reduce((ret2, item) => {
1054
+ ret2[item.key] = item.value;
1055
+ return ret2;
1056
+ }, {}) : {}
1057
+ };
1058
+ return ret;
1059
+ }, {});
1060
+ }
1061
+ this.#ids = {};
1062
+ this.#paths = {};
1063
+ if (data._hasIds()) {
1064
+ this.#ids = data.ids.values().reduce((ret, data2) => {
1065
+ ret[data2.id] ??= data2.path;
1066
+ ret[data2.path] ??= data2.path;
1067
+ return ret;
1068
+ }, {});
1069
+ this.#paths = data.ids.values().reduce((ret, data2) => {
1070
+ ret[data2.path] ??= data2.id;
1071
+ return ret;
1072
+ }, {});
664
1073
  }
1074
+ this.#log = extendLog(this.#context.log, "file-system");
665
1075
  }
666
1076
  /**
667
1077
  * Check if a path or id corresponds to a virtual file **(does not actually exists on disk)**.
@@ -681,7 +1091,7 @@ var VirtualFileSystem = class {
681
1091
  if (!resolvedPath) {
682
1092
  return false;
683
1093
  }
684
- return this.meta[resolvedPath]?.mode === "virtual";
1094
+ return this.metadata[resolvedPath]?.mode === "virtual";
685
1095
  }
686
1096
  /**
687
1097
  * Check if a path or id corresponds to a file written to the file system **(actually exists on disk)**.
@@ -690,7 +1100,7 @@ var VirtualFileSystem = class {
690
1100
  * @param options - Optional parameters for resolving the path.
691
1101
  * @returns Whether the path or id corresponds to a file written to the file system **(actually exists on disk)**.
692
1102
  */
693
- isFs(pathOrId, options = {}) {
1103
+ isPhysical(pathOrId, options = {}) {
694
1104
  if (!pathOrId) {
695
1105
  return false;
696
1106
  }
@@ -701,18 +1111,7 @@ var VirtualFileSystem = class {
701
1111
  if (!resolvedPath) {
702
1112
  return false;
703
1113
  }
704
- return this.meta[resolvedPath]?.mode === "fs";
705
- }
706
- /**
707
- * Check if a path exists within one of the directories specified in the tsconfig.json's `path` field.
708
- *
709
- * @see https://www.typescriptlang.org/tsconfig#paths
710
- *
711
- * @param pathOrId - The path or ID to check.
712
- * @returns Whether the path or ID corresponds to a virtual file.
713
- */
714
- isTsconfigPath(pathOrId) {
715
- return !!this.#context.tsconfig.options.paths && Object.keys(this.#context.tsconfig.options.paths).some((path) => pathOrId.startsWith(path.replaceAll("*", "")));
1114
+ return this.metadata[resolvedPath]?.mode === "fs";
716
1115
  }
717
1116
  /**
718
1117
  * Lists files in a given path.
@@ -722,7 +1121,7 @@ var VirtualFileSystem = class {
722
1121
  * @returns An array of file names in the specified path.
723
1122
  */
724
1123
  readdirSync(path, options = "utf8") {
725
- return this.resolveFS(path).readdirSync(toFilePath(path), options);
1124
+ return this.#unifiedFS.resolveFS(path).readdirSync(toFilePath(path), options);
726
1125
  }
727
1126
  /**
728
1127
  * Removes a file in the virtual file system (VFS).
@@ -735,9 +1134,11 @@ var VirtualFileSystem = class {
735
1134
  return;
736
1135
  }
737
1136
  this.#log(LogLevelLabel.TRACE, `Synchronously removing file: ${formattedPath}`);
738
- this.resolveFS(path, options).unlinkSync(formattedPath);
739
- this.#cachedFS.delete(formattedPath);
740
- this.clearResolverCache(formattedPath);
1137
+ this.#unifiedFS.resolveFS(path, options).unlinkSync(formattedPath);
1138
+ if (this.paths[formattedPath] && this.metadata[this.paths[formattedPath]]) {
1139
+ delete this.metadata[this.paths[formattedPath]];
1140
+ }
1141
+ this.#clearResolverCache(formattedPath);
741
1142
  }
742
1143
  /**
743
1144
  * Removes a file in the virtual file system (VFS).
@@ -750,10 +1151,12 @@ var VirtualFileSystem = class {
750
1151
  return;
751
1152
  }
752
1153
  this.#log(LogLevelLabel.TRACE, `Removing file: ${formattedPath}`);
753
- if (isFunction(this.resolveFS(path, options).promises.unlink)) {
754
- await this.resolveFS(path, options).promises.unlink(formattedPath);
755
- this.#cachedFS.delete(formattedPath);
756
- this.clearResolverCache(formattedPath);
1154
+ if (isFunction(this.#unifiedFS.resolveFS(path, options).promises.unlink)) {
1155
+ await this.#unifiedFS.resolveFS(path, options).promises.unlink(formattedPath);
1156
+ if (this.paths[formattedPath] && this.metadata[this.paths[formattedPath]]) {
1157
+ delete this.metadata[this.paths[formattedPath]];
1158
+ }
1159
+ this.#clearResolverCache(formattedPath);
757
1160
  } else {
758
1161
  this.unlinkSync(formattedPath, options);
759
1162
  }
@@ -770,11 +1173,10 @@ var VirtualFileSystem = class {
770
1173
  return;
771
1174
  }
772
1175
  this.#log(LogLevelLabel.TRACE, `Synchronously removing directory: ${formattedPath}`);
773
- this.resolveFS(path, options).rmdirSync(formattedPath, defu3(options, {
1176
+ this.#unifiedFS.resolveFS(path, options).rmdirSync(formattedPath, defu2(options, {
774
1177
  recursive: true
775
1178
  }));
776
- this.#cachedFS.delete(formattedPath);
777
- this.clearResolverCache(formattedPath);
1179
+ this.#clearResolverCache(formattedPath);
778
1180
  }
779
1181
  /**
780
1182
  * Removes a directory in the virtual file system (VFS).
@@ -789,15 +1191,14 @@ var VirtualFileSystem = class {
789
1191
  return;
790
1192
  }
791
1193
  this.#log(LogLevelLabel.TRACE, `Removing directory: ${formattedPath}`);
792
- if (isFunction(this.resolveFS(path, options).promises.rm)) {
793
- await this.resolveFS(path, options).promises.rm(formattedPath, defu3(options, {
1194
+ if (isFunction(this.#unifiedFS.resolveFS(path, options).promises.rm)) {
1195
+ await this.#unifiedFS.resolveFS(path, options).promises.rm(formattedPath, defu2(options, {
794
1196
  force: true,
795
1197
  recursive: true
796
1198
  }));
797
- this.#cachedFS.delete(formattedPath);
798
- this.clearResolverCache(formattedPath);
1199
+ this.#clearResolverCache(formattedPath);
799
1200
  } else {
800
- this.rmdirSync(formattedPath, defu3(options ?? {}, {
1201
+ this.rmdirSync(formattedPath, defu2(options ?? {}, {
801
1202
  force: true,
802
1203
  recursive: true
803
1204
  }));
@@ -839,8 +1240,8 @@ var VirtualFileSystem = class {
839
1240
  */
840
1241
  mkdirSync(path, options = {}) {
841
1242
  const filePath = toFilePath(path);
842
- this.clearResolverCache(filePath);
843
- return this.resolveFS(filePath, options).mkdirSync(filePath, defu3(options ?? {}, {
1243
+ this.#clearResolverCache(filePath);
1244
+ return this.#unifiedFS.resolveFS(filePath, options).mkdirSync(filePath, defu2(options ?? {}, {
844
1245
  recursive: true
845
1246
  }));
846
1247
  }
@@ -854,16 +1255,16 @@ var VirtualFileSystem = class {
854
1255
  async mkdir(path, options = {}) {
855
1256
  let result;
856
1257
  const filePath = toFilePath(path);
857
- if (isFunction(this.resolveFS(filePath, options).promises.mkdir)) {
858
- result = await this.resolveFS(filePath, options).promises.mkdir(filePath, defu3(options ?? {}, {
1258
+ if (isFunction(this.#unifiedFS.resolveFS(filePath, options).promises.mkdir)) {
1259
+ result = await this.#unifiedFS.resolveFS(filePath, options).promises.mkdir(filePath, defu2(options ?? {}, {
859
1260
  recursive: true
860
1261
  }));
861
1262
  } else {
862
- result = this.resolveFS(filePath, options).mkdirSync(filePath, defu3(options ?? {}, {
1263
+ result = this.#unifiedFS.resolveFS(filePath, options).mkdirSync(filePath, defu2(options ?? {}, {
863
1264
  recursive: true
864
1265
  }));
865
1266
  }
866
- this.clearResolverCache(filePath);
1267
+ this.#clearResolverCache(filePath);
867
1268
  return result;
868
1269
  }
869
1270
  /**
@@ -885,7 +1286,7 @@ var VirtualFileSystem = class {
885
1286
  }
886
1287
  continue;
887
1288
  }
888
- const absPattern = isAbsolutePath(normalized) ? normalized : this.formatPath(joinPaths(this.#context.workspaceConfig.workspaceRoot, normalized));
1289
+ const absPattern = isAbsolutePath(normalized) ? normalized : this.formatPath(joinPaths$1(this.#context.workspaceConfig.workspaceRoot, normalized));
889
1290
  const firstGlobIdx = absPattern.search(/[*?[\]{}]/);
890
1291
  const baseDir = firstGlobIdx === -1 ? findFilePath(absPattern) : absPattern.slice(0, Math.max(0, absPattern.lastIndexOf("/", firstGlobIdx)));
891
1292
  const stack = [
@@ -900,7 +1301,7 @@ var VirtualFileSystem = class {
900
1301
  continue;
901
1302
  }
902
1303
  for (const entry of entries) {
903
- const full = this.formatPath(joinPaths(dir, entry));
1304
+ const full = this.formatPath(joinPaths$1(dir, entry));
904
1305
  let stats;
905
1306
  try {
906
1307
  stats = this.#unifiedFS.lstatSync(full);
@@ -911,7 +1312,7 @@ var VirtualFileSystem = class {
911
1312
  if (stats.isDirectory()) {
912
1313
  stack.push(full);
913
1314
  } else if (stats.isFile()) {
914
- if (this.buildRegex(absPattern).test(full)) {
1315
+ if (this.#buildRegex(absPattern).test(full)) {
915
1316
  const resolved = this.resolve(full, {
916
1317
  type: "file"
917
1318
  });
@@ -944,7 +1345,7 @@ var VirtualFileSystem = class {
944
1345
  }
945
1346
  continue;
946
1347
  }
947
- const absPattern = isAbsolutePath(normalized) ? normalized : this.formatPath(joinPaths(this.#context.workspaceConfig.workspaceRoot, normalized));
1348
+ const absPattern = isAbsolutePath(normalized) ? normalized : this.formatPath(joinPaths$1(this.#context.workspaceConfig.workspaceRoot, normalized));
948
1349
  const firstGlobIdx = absPattern.search(/[*?[\]{}]/);
949
1350
  const baseDir = firstGlobIdx === -1 ? findFilePath(absPattern) : absPattern.slice(0, Math.max(0, absPattern.lastIndexOf("/", firstGlobIdx)));
950
1351
  const stack = [
@@ -959,7 +1360,7 @@ var VirtualFileSystem = class {
959
1360
  continue;
960
1361
  }
961
1362
  for (const entry of entries) {
962
- const full = this.formatPath(joinPaths(dir, entry));
1363
+ const full = this.formatPath(joinPaths$1(dir, entry));
963
1364
  let stats;
964
1365
  try {
965
1366
  stats = this.#unifiedFS.lstatSync(full);
@@ -970,7 +1371,7 @@ var VirtualFileSystem = class {
970
1371
  if (stats.isDirectory()) {
971
1372
  stack.push(full);
972
1373
  } else if (stats.isFile()) {
973
- if (this.buildRegex(absPattern).test(full)) {
1374
+ if (this.#buildRegex(absPattern).test(full)) {
974
1375
  const resolved = this.resolve(full, {
975
1376
  type: "file"
976
1377
  });
@@ -1034,7 +1435,7 @@ var VirtualFileSystem = class {
1034
1435
  * @returns An array of file names in the specified path.
1035
1436
  */
1036
1437
  async readdir(pathOrId, options = "utf8") {
1037
- return this.resolveFS(pathOrId).promises.readdir(toFilePath(pathOrId), options);
1438
+ return this.#unifiedFS.resolveFS(pathOrId).promises.readdir(toFilePath(pathOrId), options);
1038
1439
  }
1039
1440
  /**
1040
1441
  * Asynchronously reads a file from the virtual file system (VFS).
@@ -1050,17 +1451,13 @@ var VirtualFileSystem = class {
1050
1451
  type: "file"
1051
1452
  });
1052
1453
  if (filePath) {
1053
- if (this.#cachedFS.has(filePath)) {
1054
- return this.#cachedFS.get(filePath);
1055
- }
1056
1454
  let result;
1057
- if (isFunction(this.resolveFS(filePath).promises.readFile)) {
1058
- result = (await this.resolveFS(filePath).promises.readFile(filePath, options))?.toString("utf8");
1455
+ if (isFunction(this.#unifiedFS.resolveFS(filePath).promises.readFile)) {
1456
+ result = (await this.#unifiedFS.resolveFS(filePath).promises.readFile(filePath, options))?.toString("utf8");
1059
1457
  } else {
1060
- result = this.resolveFS(filePath).readFileSync(filePath, options);
1458
+ result = this.#unifiedFS.resolveFS(filePath).readFileSync(filePath, options);
1061
1459
  }
1062
1460
  const content = isBuffer(result) ? bufferToString(result) : result;
1063
- this.#cachedFS.set(filePath, content);
1064
1461
  return content;
1065
1462
  }
1066
1463
  return void 0;
@@ -1079,12 +1476,8 @@ var VirtualFileSystem = class {
1079
1476
  type: "file"
1080
1477
  });
1081
1478
  if (filePath) {
1082
- if (this.#cachedFS.has(filePath)) {
1083
- return this.#cachedFS.get(filePath);
1084
- }
1085
- const result = this.resolveFS(filePath).readFileSync(filePath, options);
1479
+ const result = this.#unifiedFS.resolveFS(filePath).readFileSync(filePath, options);
1086
1480
  const content = isBuffer(result) ? bufferToString(result) : result;
1087
- this.#cachedFS.set(filePath, content);
1088
1481
  return content;
1089
1482
  }
1090
1483
  return void 0;
@@ -1112,17 +1505,15 @@ var VirtualFileSystem = class {
1112
1505
  });
1113
1506
  }
1114
1507
  }
1115
- const outputMode = this.resolveOutputMode(formattedPath, isPowerlinesWriteFileOptions(options) ? options : void 0);
1508
+ const outputMode = this.#unifiedFS.resolveMode(formattedPath, isPowerlinesWriteFileOptions(options) ? options : void 0);
1116
1509
  this.#log(LogLevelLabel.TRACE, `Writing ${formattedPath} file to the ${outputMode === "fs" ? "" : "virtual "}file system (size: ${prettyBytes(new Blob(toArray(code)).size)})`);
1117
- this.meta[formattedPath] = {
1118
- path: formattedPath,
1119
- code,
1510
+ this.metadata[formattedPath] = {
1120
1511
  mode: outputMode,
1121
1512
  variant: "normal",
1122
1513
  ...isPowerLinesWriteFileData(data) ? data : {}
1123
1514
  };
1124
- this.clearResolverCache(formattedPath);
1125
- const ifs = this.resolveFS(formattedPath, isPowerlinesWriteFileOptions(options) ? options : void 0);
1515
+ this.#clearResolverCache(formattedPath);
1516
+ const ifs = this.#unifiedFS.resolveFS(formattedPath, isPowerlinesWriteFileOptions(options) ? options : void 0);
1126
1517
  if (isFunction(ifs.promises.writeFile)) {
1127
1518
  return ifs.promises.writeFile(formattedPath, code, isNodeWriteFileOptions(options) ? options : "utf8");
1128
1519
  }
@@ -1141,17 +1532,15 @@ var VirtualFileSystem = class {
1141
1532
  this.mkdirSync(findFilePath(formattedPath), isPowerlinesWriteFileOptions(options) ? options : void 0);
1142
1533
  }
1143
1534
  const code = isPowerLinesWriteFileData(data) ? data.code : data;
1144
- const outputMode = this.resolveOutputMode(formattedPath, isPowerlinesWriteFileOptions(options) ? options : void 0);
1535
+ const outputMode = this.#unifiedFS.resolveMode(formattedPath, isPowerlinesWriteFileOptions(options) ? options : void 0);
1145
1536
  this.#log(LogLevelLabel.TRACE, `Writing ${formattedPath} file to the ${outputMode === "fs" ? "" : "virtual "}file system (size: ${prettyBytes(new Blob(toArray(code)).size)})`);
1146
- this.meta[formattedPath] = {
1147
- path: formattedPath,
1148
- code,
1537
+ this.metadata[formattedPath] = {
1149
1538
  mode: outputMode,
1150
1539
  variant: "normal",
1151
1540
  ...isPowerLinesWriteFileData(data) ? data : {}
1152
1541
  };
1153
- this.clearResolverCache(formattedPath);
1154
- const writeStream = this.resolveFS(formattedPath, isPowerlinesWriteFileOptions(options) ? options : void 0).createWriteStream(formattedPath);
1542
+ this.#clearResolverCache(formattedPath);
1543
+ const writeStream = this.#unifiedFS.resolveFS(formattedPath, isPowerlinesWriteFileOptions(options) ? options : void 0).createWriteStream(formattedPath);
1155
1544
  try {
1156
1545
  writeStream.write(code);
1157
1546
  } finally {
@@ -1175,8 +1564,8 @@ var VirtualFileSystem = class {
1175
1564
  */
1176
1565
  getMetadata(pathOrId) {
1177
1566
  const resolved = this.resolve(pathOrId);
1178
- if (resolved && this.meta[resolved]) {
1179
- return this.meta[resolved];
1567
+ if (resolved && this.metadata[resolved]) {
1568
+ return this.metadata[resolved];
1180
1569
  }
1181
1570
  return void 0;
1182
1571
  }
@@ -1186,363 +1575,267 @@ var VirtualFileSystem = class {
1186
1575
  * @remarks
1187
1576
  * 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.
1188
1577
  *
1189
- * @param pathOrId - The path of the file to check.
1190
- * @returns `true` if the file exists, otherwise `false`.
1191
- */
1192
- isFile(pathOrId) {
1193
- const resolved = this.resolve(pathOrId);
1194
- return !!(resolved && (this.#virtualFS.existsSync(resolved) && this.#virtualFS.lstatSync(resolved).isFile() || this.#fs.existsSync(resolved) && this.#fs.lstatSync(resolved).isFile() || this.resolveFS(resolved).existsSync(resolved) && this.resolveFS(resolved).lstatSync(resolved).isFile()));
1195
- }
1196
- /**
1197
- * Checks if a directory exists in the virtual file system (VFS).
1198
- *
1199
- * @param pathOrId - The path of the directory to check.
1200
- * @returns `true` if the directory exists, otherwise `false`.
1201
- */
1202
- isDirectory(pathOrId) {
1203
- const resolved = this.resolve(pathOrId);
1204
- return !!(resolved && (this.#virtualFS.existsSync(resolved) && this.#virtualFS.lstatSync(resolved).isDirectory() || this.#fs.existsSync(resolved) && this.#fs.lstatSync(resolved).isDirectory() || this.resolveFS(resolved).existsSync(resolved) && this.resolveFS(resolved).lstatSync(resolved).isDirectory()));
1205
- }
1206
- /**
1207
- * Retrieves the status of a file in the virtual file system (VFS).
1208
- *
1209
- * @param pathOrId - The path or ID of the file to retrieve status for.
1210
- * @returns A promise that resolves to the file's status information, or false if the file does not exist.
1211
- */
1212
- async stat(pathOrId, options) {
1213
- return this.resolveFS(pathOrId).promises.stat(this.resolve(toFilePath(pathOrId)) || toFilePath(pathOrId), options);
1214
- }
1215
- /**
1216
- * Synchronously retrieves the status of a file in the virtual file system (VFS).
1217
- *
1218
- * @param pathOrId - The path or ID of the file to retrieve status for.
1219
- * @returns The file's status information, or false if the file does not exist.
1220
- */
1221
- statSync(pathOrId) {
1222
- return this.resolveFS(pathOrId).statSync(this.resolve(toFilePath(pathOrId)) || toFilePath(pathOrId));
1223
- }
1224
- /**
1225
- * Retrieves the status of a symbolic link in the virtual file system (VFS).
1226
- *
1227
- * @param pathOrId - The path or ID of the symbolic link to retrieve status for.
1228
- * @returns A promise that resolves to the symbolic link's status information, or false if the link does not exist.
1229
- */
1230
- async lstat(pathOrId, options) {
1231
- return this.resolveFS(pathOrId).promises.lstat(this.resolve(toFilePath(pathOrId)) || toFilePath(pathOrId), options);
1232
- }
1233
- /**
1234
- * Synchronously retrieves the status of a symbolic link in the virtual file system (VFS).
1235
- *
1236
- * @param pathOrId - The path or ID of the symbolic link to retrieve status for.
1237
- * @returns The symbolic link's status information, or false if the link does not exist.
1238
- */
1239
- lstatSync(pathOrId, options) {
1240
- return this.resolveFS(pathOrId).lstatSync(this.resolve(toFilePath(pathOrId)) || toFilePath(pathOrId), options);
1241
- }
1242
- /**
1243
- * Resolves a path based on TypeScript's `tsconfig.json` paths.
1244
- *
1245
- * @see https://www.typescriptlang.org/tsconfig#paths
1246
- *
1247
- * @param path - The path to check.
1248
- * @returns The resolved file path if it exists, otherwise undefined.
1249
- */
1250
- resolveTsconfigPath(path) {
1251
- if (this.#context.tsconfig.options.paths) {
1252
- for (const tsconfigPathKey of Object.keys(this.#context.tsconfig.options.paths).filter((tsconfigPath) => path.startsWith(tsconfigPath.replaceAll("*", "")))) {
1253
- const resolvedPath = this.#context.tsconfig.options.paths[tsconfigPathKey]?.find((tsconfigPath) => this.resolvePath(joinPaths(this.#context.workspaceConfig.workspaceRoot, tsconfigPath.replaceAll("*", ""), path.replace(tsconfigPathKey.replaceAll("*", ""), ""))) || this.formatPath(tsconfigPath) === this.formatPath(path));
1254
- if (resolvedPath) {
1255
- return this.formatPath(resolvedPath) === this.formatPath(path) ? this.formatPath(resolvedPath) : this.resolvePath(joinPaths(this.#context.workspaceConfig.workspaceRoot, resolvedPath.replaceAll("*", ""), path.replace(tsconfigPathKey.replaceAll("*", ""), "")));
1256
- }
1257
- }
1258
- }
1259
- return false;
1260
- }
1261
- /**
1262
- * Resolves a path based on TypeScript's `tsconfig.json` paths.
1263
- *
1264
- * @see https://www.typescriptlang.org/tsconfig#paths
1265
- *
1266
- * @param path - The path to check.
1267
- * @returns The resolved file path if it exists, otherwise undefined.
1268
- */
1269
- resolveTsconfigPathPackage(path) {
1270
- if (this.#context.tsconfig.options.paths) {
1271
- const tsconfigPathKeys = Object.keys(this.#context.tsconfig.options.paths).filter((tsconfigPath) => path.startsWith(tsconfigPath.replaceAll("*", "")));
1272
- if (tsconfigPathKeys.length > 0 && tsconfigPathKeys[0]) {
1273
- return tsconfigPathKeys[0].replace(/\/\*$/, "");
1274
- }
1275
- }
1276
- return false;
1277
- }
1278
- /**
1279
- * Resolves a path or ID to its real path in the virtual file system (VFS).
1280
- *
1281
- * @param pathOrId - The path or ID to resolve.
1282
- * @returns The resolved real path if it exists, otherwise undefined.
1283
- */
1284
- realpathSync(pathOrId) {
1285
- const filePath = this.resolve(toFilePath(pathOrId));
1286
- if (!filePath) {
1287
- throw new Error(`File not found: ${toFilePath(pathOrId)}`);
1288
- }
1289
- return filePath;
1290
- }
1291
- /**
1292
- * Resolves a path or ID parameter to a corresponding virtual file path in the virtual file system (VFS).
1293
- *
1294
- * @param pathOrId - The path or ID to resolve.
1295
- * @param options - Optional parameters for resolving the path, such as whether to include the file extension.
1296
- * @returns The resolved file path if it exists, otherwise undefined.
1297
- */
1298
- resolve(pathOrId, options = {}) {
1299
- const formattedPathOrId = toFilePath(pathOrId);
1300
- const resolverKey = `${formattedPathOrId}${options.withExtension ? "-ext" : ""}${options.paths ? `-${murmurhash(options.paths)}` : ""}${options.type ? `-${options.type}` : ""}`;
1301
- if (this.#cachedResolver.has(resolverKey)) {
1302
- return this.#cachedResolver.get(resolverKey);
1303
- }
1304
- let result = this.resolveId(formattedPathOrId);
1305
- if (!result) {
1306
- result = this.resolvePath(formattedPathOrId, options);
1307
- }
1308
- if (!result) {
1309
- result = false;
1310
- }
1311
- if (result && options.withExtension === false) {
1312
- return result.replace(/\.[m|c]?[t|j]sx?$/, "");
1313
- }
1314
- this.#cachedResolver.set(resolverKey, result);
1315
- return result;
1316
- }
1317
- /**
1318
- * Retrieves the partial metadata for all files in the virtual file system (VFS).
1319
- *
1320
- * @returns A record containing the partial metadata for all files.
1321
- */
1322
- getPartialMeta() {
1323
- return Object.fromEntries(Object.entries(this.#meta).filter(([_, data]) => isSetObject(data)));
1324
- }
1325
- buildRegex(strPattern) {
1326
- const token = "::GLOBSTAR::";
1327
- return new RegExp(`^${this.formatPath(strPattern).replace(/\*\*/g, token).replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*/g, "[^/]*").replace(/\?/g, "[^/]").replace(new RegExp(token, "g"), ".*")}$`);
1328
- }
1329
- /**
1330
- * Converts a relative path to an absolute path based on the workspace and project root.
1331
- *
1332
- * @param path - The relative path to convert.
1333
- * @returns The absolute path.
1334
- */
1335
- formatPath(path) {
1336
- const formattedPath = toFilePath(path);
1337
- if (isAbsolutePath(formattedPath) || formattedPath.startsWith(this.#context.workspaceConfig.workspaceRoot)) {
1338
- return formattedPath;
1339
- } else if (formattedPath.startsWith(this.#context.config.projectRoot)) {
1340
- return joinPaths(this.#context.workspaceConfig.workspaceRoot, formattedPath);
1341
- }
1342
- return formattedPath;
1343
- }
1344
- /**
1345
- * Formats a file id by removing the file extension and prepending the runtime prefix.
1346
- *
1347
- * @param id - The file ID to format.
1348
- * @returns The formatted file ID.
1349
- */
1350
- formatId(id) {
1351
- const formattedId = toFilePath(id);
1352
- return `${this.#context.config.output.builtinPrefix}:${formattedId.replace(new RegExp(`^${this.#context.config.output.builtinPrefix}:`), "").replace(/^\\0/, "").replace(findFileDotExtensionSafe(formattedId), "")}`;
1353
- }
1354
- /**
1355
- * Resolves an id parameter to a corresponding virtual file path in the virtual file system (VFS).
1356
- *
1357
- * @param id - The id to resolve.
1358
- * @returns The resolved file id if it exists, otherwise undefined.
1359
- */
1360
- resolveId(id) {
1361
- if (this.#ids[this.formatId(id)]) {
1362
- return this.#ids[this.formatId(id)] || false;
1363
- }
1364
- return false;
1365
- }
1366
- /**
1367
- * Resolves a path parameter to a corresponding virtual file path in the virtual file system (VFS).
1368
- *
1369
- * @param path - The path to resolve.
1370
- * @param options - Optional parameters for resolving the path.
1371
- * @returns The resolved file path if it exists, otherwise undefined.
1372
- */
1373
- resolvePath(path, options = {}) {
1374
- if (isAbsolutePath(path)) {
1375
- if (this.#existsSync(path)) {
1376
- return path;
1377
- }
1378
- const result = this.checkVariants(path);
1379
- if (result) {
1380
- return result;
1381
- }
1382
- }
1383
- for (const parentPath of this.resolveParentPaths(path, options.paths)) {
1384
- const request = joinPaths(parentPath, path);
1385
- if (this.#existsSync(request)) {
1386
- return request;
1387
- }
1388
- const result = this.checkVariants(request);
1389
- if (result) {
1390
- return result;
1391
- }
1392
- }
1393
- return false;
1394
- }
1395
- resolveParentPaths(request, parents = []) {
1396
- let paths = [
1397
- this.#context.workspaceConfig.workspaceRoot,
1398
- joinPaths(this.#context.workspaceConfig.workspaceRoot, this.#context.config.projectRoot)
1399
- ];
1400
- if (this.#context.tsconfig.options.paths) {
1401
- paths = this.#context.tsconfig.options.paths ? Object.keys(this.#context.tsconfig.options.paths).filter((tsconfigPath) => request.startsWith(tsconfigPath.replaceAll("*", ""))).map((tsconfigPath) => this.#context.tsconfig.options.paths?.[tsconfigPath]).flat().reduce((ret, path) => {
1402
- if (path && !ret.includes(joinPaths(this.#context.workspaceConfig.workspaceRoot, path))) {
1403
- ret.push(joinPaths(this.#context.workspaceConfig.workspaceRoot, path));
1404
- }
1405
- return ret;
1406
- }, paths) : paths;
1407
- }
1408
- return paths.reduce((ret, path) => {
1409
- if (!ret.includes(path)) {
1410
- ret.push(path);
1411
- }
1412
- return ret;
1413
- }, parents.filter(Boolean).map((p) => this.formatPath(p)));
1578
+ * @param pathOrId - The path of the file to check.
1579
+ * @returns `true` if the file exists, otherwise `false`.
1580
+ */
1581
+ isFile(pathOrId) {
1582
+ const resolved = this.resolve(pathOrId);
1583
+ 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()));
1414
1584
  }
1415
1585
  /**
1416
- * Select the file system module to use for the operation based on the path or URL.
1586
+ * Checks if a directory exists in the virtual file system (VFS).
1417
1587
  *
1418
- * @param pathOrUrl - The path to perform the file system operation on.
1419
- * @param options - Options for the operation, such as output mode.
1420
- * @returns The file system module used for the operation.
1588
+ * @param pathOrId - The path of the directory to check.
1589
+ * @returns `true` if the directory exists, otherwise `false`.
1421
1590
  */
1422
- resolveFS(pathOrUrl, options = {}) {
1423
- const mode = this.resolveOutputMode(pathOrUrl, options);
1424
- if (mode === "virtual") {
1425
- return this.#virtualFS;
1426
- } else if (mode === "fs") {
1427
- return this.#fs;
1428
- }
1429
- return this.#unifiedFS;
1591
+ isDirectory(pathOrId) {
1592
+ const resolved = this.resolve(pathOrId);
1593
+ 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()));
1430
1594
  }
1431
1595
  /**
1432
- * Select the file system module to use for the operation based on the path or URL.
1596
+ * Retrieves the status of a file in the virtual file system (VFS).
1433
1597
  *
1434
- * @param pathOrUrl - The path to perform the file system operation on.
1435
- * @param options - Options for the operation, such as output mode.
1436
- * @returns The file system module used for the operation.
1598
+ * @param pathOrId - The path or ID of the file to retrieve status for.
1599
+ * @returns A promise that resolves to the file's status information, or false if the file does not exist.
1437
1600
  */
1438
- resolveOutputMode(pathOrUrl, options = {}) {
1439
- if (options.mode === "virtual" && this.#context.config.output.mode !== "fs" && isParentPath(toFilePath(pathOrUrl), this.#context.artifactsPath)) {
1440
- return "virtual";
1441
- } else if (options.mode === "fs" || this.#context.config.output.mode === "fs" || isParentPath(toFilePath(pathOrUrl), this.#context.dataPath) || isParentPath(toFilePath(pathOrUrl), this.#context.cachePath) || isParentPath(toFilePath(pathOrUrl), joinPaths(this.#context.workspaceConfig.workspaceRoot, this.#context.config.output.outputPath))) {
1442
- return "fs";
1443
- }
1444
- return void 0;
1601
+ async stat(pathOrId, options) {
1602
+ return this.#unifiedFS.resolveFS(pathOrId).promises.stat(this.resolve(toFilePath(pathOrId)) || toFilePath(pathOrId), options);
1445
1603
  }
1446
1604
  /**
1447
- * Clears the resolver cache for a given path.
1605
+ * Synchronously retrieves the status of a file in the virtual file system (VFS).
1448
1606
  *
1449
- * @param path - The path to clear the resolver cache for.
1607
+ * @param pathOrId - The path or ID of the file to retrieve status for.
1608
+ * @returns The file's status information, or false if the file does not exist.
1450
1609
  */
1451
- clearResolverCache(path) {
1452
- this.#cachedResolver.keys().filter((key) => key.startsWith(toFilePath(path))).forEach((key) => this.#cachedResolver.delete(key));
1610
+ statSync(pathOrId) {
1611
+ return this.#unifiedFS.resolveFS(pathOrId).statSync(this.resolve(toFilePath(pathOrId)) || toFilePath(pathOrId));
1453
1612
  }
1454
1613
  /**
1455
- * Check if the file exists with different variants (index, extensions).
1614
+ * Retrieves the status of a symbolic link in the virtual file system (VFS).
1456
1615
  *
1457
- * @param request - The request path to check.
1458
- * @param parentPath - An optional parent path to prepend to the request.
1459
- * @returns The file path if it exists, otherwise false.
1616
+ * @param pathOrId - The path or ID of the symbolic link to retrieve status for.
1617
+ * @returns A promise that resolves to the symbolic link's status information, or false if the link does not exist.
1460
1618
  */
1461
- checkVariants(request, parentPath) {
1462
- const path = parentPath ? joinPaths(parentPath, request) : request;
1463
- let file = this.checkExtensions(path);
1464
- if (file) {
1465
- return file;
1466
- }
1467
- file = this.checkIndex(path);
1468
- if (file) {
1469
- return file;
1470
- }
1471
- return false;
1619
+ async lstat(pathOrId, options) {
1620
+ return this.#unifiedFS.resolveFS(pathOrId).promises.lstat(this.resolve(toFilePath(pathOrId)) || toFilePath(pathOrId), options);
1472
1621
  }
1473
1622
  /**
1474
- * Check if the index file exists in the given request path.
1623
+ * Synchronously retrieves the status of a symbolic link in the virtual file system (VFS).
1475
1624
  *
1476
- * @param request - The request path to check.
1477
- * @returns The index file path if it exists, otherwise false.
1625
+ * @param pathOrId - The path or ID of the symbolic link to retrieve status for.
1626
+ * @returns The symbolic link's status information, or false if the link does not exist.
1478
1627
  */
1479
- checkIndex(request) {
1480
- let file = joinPaths(request, "index");
1481
- if (this.#existsSync(file)) {
1482
- return file;
1483
- }
1484
- file = this.checkExtensions(file);
1485
- if (file) {
1486
- return file;
1487
- }
1488
- return false;
1628
+ lstatSync(pathOrId, options) {
1629
+ return this.#unifiedFS.resolveFS(pathOrId).lstatSync(this.resolve(toFilePath(pathOrId)) || toFilePath(pathOrId), options);
1489
1630
  }
1490
1631
  /**
1491
- * Check if the file exists with different extensions.
1632
+ * Resolves a path or ID to its real path in the virtual file system (VFS).
1492
1633
  *
1493
- * @param request - The request path to check.
1494
- * @param vfs - The file system module to use for checking file existence.
1495
- * @returns The file path if it exists with any of the checked extensions, otherwise false.
1634
+ * @param pathOrId - The path or ID to resolve.
1635
+ * @returns The resolved real path if it exists, otherwise undefined.
1496
1636
  */
1497
- checkExtensions(request) {
1498
- let file = `${request}.ts`;
1499
- if (this.#existsSync(file)) {
1500
- return file;
1501
- }
1502
- file = `${request}.mts`;
1503
- if (this.#existsSync(file)) {
1504
- return file;
1637
+ realpathSync(pathOrId) {
1638
+ const filePath = this.resolve(toFilePath(pathOrId));
1639
+ if (!filePath) {
1640
+ throw new Error(`File not found: ${toFilePath(pathOrId)}`);
1505
1641
  }
1506
- file = `${request}.cts`;
1507
- if (this.#existsSync(file)) {
1508
- return file;
1642
+ return filePath;
1643
+ }
1644
+ /**
1645
+ * Resolves a path or ID parameter to a corresponding virtual file path in the virtual file system (VFS).
1646
+ *
1647
+ * @param pathOrId - The path or ID to resolve.
1648
+ * @param options - Optional parameters for resolving the path, such as whether to include the file extension.
1649
+ * @returns The resolved file path if it exists, otherwise undefined.
1650
+ */
1651
+ resolve(pathOrId, options = {}) {
1652
+ const formattedPathOrId = toFilePath(pathOrId);
1653
+ const resolverKey = `${formattedPathOrId}${options.withExtension ? "-ext" : ""}${options.paths ? `-${murmurhash(options.paths)}` : ""}${options.type ? `-${options.type}` : ""}`;
1654
+ if (this.#cachedResolver.has(resolverKey)) {
1655
+ return this.#cachedResolver.get(resolverKey);
1509
1656
  }
1510
- file = `${request}.tsx`;
1511
- if (this.#existsSync(file)) {
1512
- return file;
1657
+ let result = this.#resolveId(formattedPathOrId);
1658
+ if (!result) {
1659
+ result = this.#resolvePath(formattedPathOrId, options);
1513
1660
  }
1514
- file = `${request}.js`;
1515
- if (this.#existsSync(file)) {
1516
- return file;
1661
+ if (!result) {
1662
+ result = false;
1517
1663
  }
1518
- file = `${request}.mjs`;
1519
- if (this.#existsSync(file)) {
1520
- return file;
1664
+ if (result && options.withExtension === false) {
1665
+ return result.replace(/\.[m|c]?[t|j]sx?$/, "");
1521
1666
  }
1522
- file = `${request}.cjs`;
1523
- if (this.#existsSync(file)) {
1524
- return file;
1667
+ this.#cachedResolver.set(resolverKey, result);
1668
+ return result;
1669
+ }
1670
+ /**
1671
+ * Converts a relative path to an absolute path based on the workspace and project root.
1672
+ *
1673
+ * @param path - The relative path to convert.
1674
+ * @returns The absolute path.
1675
+ */
1676
+ formatPath(path) {
1677
+ const formattedPath = toFilePath(path);
1678
+ if (isAbsolutePath(formattedPath) || formattedPath.startsWith(this.#context.workspaceConfig.workspaceRoot)) {
1679
+ return formattedPath;
1680
+ } else if (formattedPath.startsWith(this.#context.config.projectRoot)) {
1681
+ return joinPaths$1(this.#context.workspaceConfig.workspaceRoot, formattedPath);
1525
1682
  }
1526
- file = `${request}.jsx`;
1527
- if (this.#existsSync(file)) {
1528
- return file;
1683
+ return formattedPath;
1684
+ }
1685
+ /**
1686
+ * Disposes of the virtual file system (VFS) by saving its state to disk.
1687
+ */
1688
+ async dispose() {
1689
+ if (!this.#isDisposed) {
1690
+ this.#isDisposed = true;
1691
+ this.#log(LogLevelLabel.DEBUG, "Disposing virtual file system...");
1692
+ await this.unlink(joinPaths$1(this.#context.cachePath, "fs.bin"));
1693
+ const message = new $.Message();
1694
+ const data = message.initRoot(FileSystemData);
1695
+ const virtualFS = this.#unifiedFS.toJSON();
1696
+ const files = data._initFiles(Object.keys(virtualFS).length);
1697
+ Object.entries(virtualFS).filter(([_, content]) => content).forEach(([path, content], index) => {
1698
+ const fileData = files.get(index);
1699
+ fileData.path = path;
1700
+ fileData.content = content;
1701
+ });
1702
+ const ids = data._initIds(Object.keys(this.ids).length);
1703
+ Object.entries(this.ids).forEach(([id, path], index) => {
1704
+ const fileId = ids.get(index);
1705
+ fileId.id = id;
1706
+ fileId.path = path;
1707
+ });
1708
+ const metadata = data._initMetadata(Object.keys(this.metadata).length);
1709
+ Object.entries(this.metadata).forEach(([id, value], index) => {
1710
+ const fileMetadata = metadata.get(index);
1711
+ fileMetadata.id = id;
1712
+ fileMetadata.mode = value.mode;
1713
+ fileMetadata.variant = value.variant;
1714
+ if (value.properties) {
1715
+ const props = fileMetadata._initProperties(Object.keys(value.properties).length);
1716
+ Object.entries(value.properties).forEach(([key, val], propIndex) => {
1717
+ const propData = props.get(propIndex);
1718
+ propData.key = key;
1719
+ propData.value = val;
1720
+ });
1721
+ }
1722
+ });
1723
+ await writeFileBuffer(joinPaths$1(this.#context.cachePath, "fs.bin"), message.toArrayBuffer());
1529
1724
  }
1530
- file = `${request}.json`;
1531
- if (this.#existsSync(file)) {
1532
- return file;
1725
+ }
1726
+ /**
1727
+ * Initializes the virtual file system (VFS) by patching the file system module if necessary.
1728
+ */
1729
+ [__VFS_PATCH__]() {
1730
+ if (!this.#isPatched && this.#context.config.output.mode !== "fs") {
1731
+ this.#revert = patchFS(fs, this);
1732
+ this.#isPatched = true;
1533
1733
  }
1534
- file = `${request}.d.ts`;
1535
- if (this.#existsSync(file)) {
1536
- return file;
1734
+ }
1735
+ /**
1736
+ * Reverts the file system module to its original state if it was previously patched.
1737
+ */
1738
+ [__VFS_REVERT__]() {
1739
+ if (this.#isPatched && this.#context.config.output.mode !== "fs") {
1740
+ if (!this.#revert) {
1741
+ throw new Error("Attempting to revert File System patch prior to calling `__init__` function");
1742
+ }
1743
+ this.#revert?.();
1744
+ this.#isPatched = false;
1537
1745
  }
1538
- return false;
1746
+ }
1747
+ async [Symbol.asyncDispose]() {
1748
+ return this.dispose();
1539
1749
  }
1540
1750
  };
1541
- function createVfs(context) {
1542
- const vfs = new VirtualFileSystem(context);
1543
- return vfs;
1751
+
1752
+ // src/types/commands.ts
1753
+ var SUPPORTED_COMMANDS = [
1754
+ "new",
1755
+ "clean",
1756
+ "prepare",
1757
+ "lint",
1758
+ "test",
1759
+ "build",
1760
+ "docs",
1761
+ "deploy",
1762
+ "finalize"
1763
+ ];
1764
+
1765
+ // src/plugin-utils/helpers.ts
1766
+ function isPlugin(value) {
1767
+ return isSetObject(value) && "name" in value && isSetString(value.name) && (isUndefined(value.applyToEnvironment) || "applyToEnvironment" in value && isFunction(value.applyToEnvironment)) && (isUndefined(value.dedupe) || "dedupe" in value && isFunction(value.dedupe)) && (isUndefined(value.dependsOn) || "dependsOn" in value && Array.isArray(value.dependsOn) && value.dependsOn.every(isPluginConfig)) && SUPPORTED_COMMANDS.every((command) => isUndefined(value[command]) || command in value && (isFunction(value[command]) || isSetObject(value[command]) && "handler" in value[command] && isFunction(value[command].handler)));
1768
+ }
1769
+ __name(isPlugin, "isPlugin");
1770
+ function isPluginConfigObject(value) {
1771
+ return isSetObject(value) && "plugin" in value && ((isSetString(value.plugin) || isFunction(value.plugin)) && "options" in value && isSetObject(value.options) || isPlugin(value.plugin));
1772
+ }
1773
+ __name(isPluginConfigObject, "isPluginConfigObject");
1774
+ function isPluginConfigTuple(value) {
1775
+ return Array.isArray(value) && (value.length === 1 || value.length === 2) && ((isSetString(value[0]) || isFunction(value[0])) && value.length > 1 && isSetObject(value[1]) || isPlugin(value[0]));
1776
+ }
1777
+ __name(isPluginConfigTuple, "isPluginConfigTuple");
1778
+ function isPluginConfig(value) {
1779
+ return isSetString(value) || isFunction(value) || isPlugin(value) || isPluginConfigObject(value) || isPluginConfigTuple(value);
1780
+ }
1781
+ __name(isPluginConfig, "isPluginConfig");
1782
+ function isPluginHookFunction(value) {
1783
+ return isFunction(value) || isSetObject(value) && "handler" in value && isFunction(value.handler);
1784
+ }
1785
+ __name(isPluginHookFunction, "isPluginHookFunction");
1786
+ function isPluginHookObject(value) {
1787
+ return isSetObject(value) && "handler" in value && isFunction(value.handler);
1788
+ }
1789
+ __name(isPluginHookObject, "isPluginHookObject");
1790
+ function isPluginHook(value) {
1791
+ return isPluginHookFunction(value) || isPluginHookObject(value);
1792
+ }
1793
+ __name(isPluginHook, "isPluginHook");
1794
+ function getHookHandler(pluginHook) {
1795
+ return isFunction(pluginHook) ? pluginHook : pluginHook.handler;
1796
+ }
1797
+ __name(getHookHandler, "getHookHandler");
1798
+ function isHookExternal(hook) {
1799
+ return hook.startsWith("vite:") || hook.startsWith("esbuild:") || hook.startsWith("rolldown:") || hook.startsWith("rollup:") || hook.startsWith("webpack:") || hook.startsWith("rspack:") || hook.startsWith("farm:");
1800
+ }
1801
+ __name(isHookExternal, "isHookExternal");
1802
+ function checkDedupe(plugin, plugins) {
1803
+ return plugin.dedupe === false || plugins.some((p) => p.dedupe !== false && (isFunction(p.dedupe) && p.dedupe(plugin) || p.name === plugin.name));
1804
+ }
1805
+ __name(checkDedupe, "checkDedupe");
1806
+ function addPluginHook(context, plugin, pluginHook, hooksList) {
1807
+ if (!checkDedupe(plugin, hooksList.map((hook) => hook.plugin))) {
1808
+ hooksList.push(isFunction(pluginHook) ? {
1809
+ plugin,
1810
+ handler: getHookHandler(pluginHook).bind(context)
1811
+ } : {
1812
+ plugin,
1813
+ ...pluginHook,
1814
+ handler: getHookHandler(pluginHook).bind(context)
1815
+ });
1816
+ }
1817
+ }
1818
+ __name(addPluginHook, "addPluginHook");
1819
+ function resolveOptions(options) {
1820
+ return defu2(options, {
1821
+ interopDefault: true,
1822
+ fsCache: options.mode !== "development" ? joinPaths$1(options.cacheDir, "jiti") : false,
1823
+ moduleCache: options.mode !== "development"
1824
+ });
1544
1825
  }
1545
- __name(createVfs, "createVfs");
1826
+ __name(resolveOptions, "resolveOptions");
1827
+ function createPluginResolver(options) {
1828
+ return createJiti(joinPaths$1(options.workspaceRoot, options.projectRoot), resolveOptions({
1829
+ ...options
1830
+ }));
1831
+ }
1832
+ __name(createPluginResolver, "createPluginResolver");
1833
+ function createResolver(options) {
1834
+ const baseResolver = createJiti(joinPaths$1(options.workspaceRoot, options.projectRoot), resolveOptions(options));
1835
+ baseResolver.plugin = createPluginResolver(options);
1836
+ return baseResolver;
1837
+ }
1838
+ __name(createResolver, "createResolver");
1546
1839
 
1547
1840
  // src/internal/contexts/context.ts
1548
1841
  var configCache = /* @__PURE__ */ new WeakMap();
@@ -1582,7 +1875,6 @@ var PowerlinesContext = class _PowerlinesContext {
1582
1875
  lint: config.lint,
1583
1876
  transform: config.transform,
1584
1877
  build: config.build,
1585
- override: config.override,
1586
1878
  framework: config.framework
1587
1879
  };
1588
1880
  }
@@ -1658,7 +1950,7 @@ var PowerlinesContext = class _PowerlinesContext {
1658
1950
  */
1659
1951
  get fs() {
1660
1952
  if (!this.#fs) {
1661
- this.#fs = createVfs(this);
1953
+ this.#fs = VirtualFileSystem.createSync(this);
1662
1954
  }
1663
1955
  return this.#fs;
1664
1956
  }
@@ -1685,9 +1977,7 @@ var PowerlinesContext = class _PowerlinesContext {
1685
1977
  }),
1686
1978
  configHash: murmurhash(this.config, {
1687
1979
  maxLength: CACHE_HASH_LENGTH
1688
- }),
1689
- builtinIdMap: {},
1690
- virtualFiles: {}
1980
+ })
1691
1981
  };
1692
1982
  }
1693
1983
  /**
@@ -1728,31 +2018,31 @@ var PowerlinesContext = class _PowerlinesContext {
1728
2018
  * Get the path to the artifacts directory for the project
1729
2019
  */
1730
2020
  get artifactsPath() {
1731
- return joinPaths$1(this.workspaceConfig.workspaceRoot, this.config.projectRoot, this.config.output.artifactsFolder);
2021
+ return joinPaths(this.workspaceConfig.workspaceRoot, this.config.projectRoot, this.config.output.artifactsFolder);
1732
2022
  }
1733
2023
  /**
1734
2024
  * Get the path to the builtin modules used by the project
1735
2025
  */
1736
2026
  get builtinsPath() {
1737
- return joinPaths$1(this.artifactsPath, "builtins");
2027
+ return joinPaths(this.artifactsPath, "builtins");
1738
2028
  }
1739
2029
  /**
1740
2030
  * Get the path to the entry directory for the project
1741
2031
  */
1742
2032
  get entryPath() {
1743
- return joinPaths$1(this.artifactsPath, "entry");
2033
+ return joinPaths(this.artifactsPath, "entry");
1744
2034
  }
1745
2035
  /**
1746
2036
  * Get the path to the data directory for the project
1747
2037
  */
1748
2038
  get dataPath() {
1749
- return joinPaths$1(this.envPaths.data, "projects", getPrefixedProjectRootHash(this.config.name, this.meta.projectRootHash));
2039
+ return joinPaths(this.envPaths.data, "projects", getPrefixedProjectRootHash(this.config.name, this.meta.projectRootHash));
1750
2040
  }
1751
2041
  /**
1752
2042
  * Get the path to the cache directory for the project
1753
2043
  */
1754
2044
  get cachePath() {
1755
- return joinPaths$1(this.envPaths.cache, "projects", murmurhash({
2045
+ return joinPaths(this.envPaths.cache, "projects", murmurhash({
1756
2046
  checksum: this.#checksum,
1757
2047
  config: this.meta.configHash
1758
2048
  }, {
@@ -1763,7 +2053,7 @@ var PowerlinesContext = class _PowerlinesContext {
1763
2053
  * Get the path to the generated declaration file for the project
1764
2054
  */
1765
2055
  get dtsPath() {
1766
- return this.config.output.dts ? appendPath(this.config.output.dts, this.workspaceConfig.workspaceRoot) : joinPaths$1(this.workspaceConfig.workspaceRoot, this.config.projectRoot, "storm.d.ts");
2056
+ return this.config.output.dts ? appendPath(this.config.output.dts, this.workspaceConfig.workspaceRoot) : joinPaths(this.workspaceConfig.workspaceRoot, this.config.projectRoot, "storm.d.ts");
1767
2057
  }
1768
2058
  /**
1769
2059
  * Get the project root relative to the workspace root
@@ -1775,13 +2065,13 @@ var PowerlinesContext = class _PowerlinesContext {
1775
2065
  * The builtin module id that exist in the Powerlines virtual file system
1776
2066
  */
1777
2067
  get builtins() {
1778
- return Object.values(this.fs.meta).filter((meta) => meta && meta.variant === "builtin").map((meta) => meta?.id).filter(Boolean);
2068
+ return Object.values(this.fs.metadata).filter((meta) => meta && meta.variant === "builtin").map((meta) => meta?.id).filter(Boolean);
1779
2069
  }
1780
2070
  /**
1781
- * Get the project root relative to the workspace root
2071
+ * Get the builtin virtual files that exist in the Powerlines virtual file system
1782
2072
  */
1783
2073
  async getBuiltins() {
1784
- return Promise.all(Object.entries(this.fs.meta).filter(([, meta]) => meta && meta.variant === "builtin").map(async ([path, meta]) => {
2074
+ return Promise.all(Object.entries(this.fs.metadata).filter(([, meta]) => meta && meta.variant === "builtin").map(async ([path, meta]) => {
1785
2075
  const code = await this.fs.readFile(path);
1786
2076
  return {
1787
2077
  ...meta,
@@ -1801,7 +2091,7 @@ var PowerlinesContext = class _PowerlinesContext {
1801
2091
  return this.fs.writeFile(isAbsolute(path) ? path : appendPath(path, this.entryPath), {
1802
2092
  code,
1803
2093
  variant: "entry"
1804
- }, defu3(options, {
2094
+ }, defu2(options, {
1805
2095
  mode: this.config.output.mode
1806
2096
  }));
1807
2097
  }
@@ -1814,11 +2104,11 @@ var PowerlinesContext = class _PowerlinesContext {
1814
2104
  * @param options - Optional write file options
1815
2105
  */
1816
2106
  async writeBuiltin(code, id, path, options = {}) {
1817
- return this.fs.writeFile(path ? isAbsolute(path) ? path : joinPaths$1(this.builtinsPath, path) : appendPath(id, this.builtinsPath), {
2107
+ return this.fs.writeFile(path ? isAbsolute(path) ? path : joinPaths(this.builtinsPath, path) : appendPath(id, this.builtinsPath), {
1818
2108
  id,
1819
2109
  code,
1820
2110
  variant: "builtin"
1821
- }, defu3(options, {
2111
+ }, defu2(options, {
1822
2112
  mode: this.config.output.mode
1823
2113
  }));
1824
2114
  }
@@ -1840,7 +2130,7 @@ var PowerlinesContext = class _PowerlinesContext {
1840
2130
  options
1841
2131
  });
1842
2132
  }
1843
- const result = await parseAsync(id, code, defu3(options ?? {}, {
2133
+ const result = await parseAsync(id, code, defu2(options ?? {}, {
1844
2134
  lang: hasFileExtension(id) ? void 0 : "ts",
1845
2135
  astType: hasFileExtension(id) ? void 0 : "ts",
1846
2136
  sourceType: "module",
@@ -1878,7 +2168,7 @@ ${result.errors.map((error) => ` [${error.severity}] ${error.message}${error.co
1878
2168
  }) {
1879
2169
  this.config.inlineConfig = inlineConfig;
1880
2170
  if (inlineConfig.command === "new") {
1881
- const workspacePackageJsonPath = joinPaths$1(this.workspaceConfig.workspaceRoot, "package.json");
2171
+ const workspacePackageJsonPath = joinPaths(this.workspaceConfig.workspaceRoot, "package.json");
1882
2172
  if (!existsSync(workspacePackageJsonPath)) {
1883
2173
  throw new Error(`The workspace package.json file could not be found at ${workspacePackageJsonPath}`);
1884
2174
  }
@@ -2001,11 +2291,11 @@ ${result.errors.map((error) => ` [${error.severity}] ${error.message}${error.co
2001
2291
  this.resolver = result.resolver;
2002
2292
  this.mergeUserConfig(result.userConfig.config, this.config.userConfig);
2003
2293
  } else {
2004
- const projectJsonPath = joinPaths$1(cacheKey.projectRoot, "project.json");
2294
+ const projectJsonPath = joinPaths(cacheKey.projectRoot, "project.json");
2005
2295
  if (existsSync(projectJsonPath)) {
2006
2296
  this.projectJson = await readJsonFile(projectJsonPath);
2007
2297
  }
2008
- const packageJsonPath = joinPaths$1(cacheKey.projectRoot, "package.json");
2298
+ const packageJsonPath = joinPaths(cacheKey.projectRoot, "package.json");
2009
2299
  if (existsSync(packageJsonPath)) {
2010
2300
  this.packageJson = await readJsonFile(packageJsonPath);
2011
2301
  }
@@ -2028,7 +2318,7 @@ ${result.errors.map((error) => ` [${error.severity}] ${error.message}${error.co
2028
2318
  });
2029
2319
  }
2030
2320
  if (isSetObject(config)) {
2031
- this.resolvedConfig = defu3({
2321
+ this.resolvedConfig = defu2({
2032
2322
  inlineConfig: this.config.inlineConfig,
2033
2323
  userConfig: this.config.userConfig
2034
2324
  }, options.isHighPriority ? this.#getConfigProps(config) : {}, {
@@ -2045,11 +2335,11 @@ ${result.errors.map((error) => ` [${error.severity}] ${error.message}${error.co
2045
2335
  tsconfig: appendPath("tsconfig.json", cacheKey.projectRoot),
2046
2336
  sourceRoot: this.projectJson?.sourceRoot || appendPath("src", cacheKey.projectRoot),
2047
2337
  output: {
2048
- outputPath: joinPaths$1("dist", cacheKey.projectRoot),
2338
+ outputPath: joinPaths("dist", cacheKey.projectRoot),
2049
2339
  mode: "virtual",
2050
- dts: joinPaths$1(cacheKey.projectRoot, `${config.framework ?? "powerlines"}.d.ts`),
2340
+ dts: joinPaths(cacheKey.projectRoot, `${config.framework ?? "powerlines"}.d.ts`),
2051
2341
  builtinPrefix: config.framework ?? "powerlines",
2052
- artifactsFolder: joinPaths$1(cacheKey.projectRoot, `.${config.framework ?? "powerlines"}`),
2342
+ artifactsFolder: joinPaths(cacheKey.projectRoot, `.${config.framework ?? "powerlines"}`),
2053
2343
  assets: [
2054
2344
  {
2055
2345
  glob: "LICENSE"
@@ -2084,9 +2374,9 @@ ${result.errors.map((error) => ` [${error.severity}] ${error.message}${error.co
2084
2374
  eslint: {}
2085
2375
  },
2086
2376
  build: {
2087
- target: "esnext"
2088
- },
2089
- override: {}
2377
+ target: "esnext",
2378
+ override: {}
2379
+ }
2090
2380
  });
2091
2381
  }
2092
2382
  this.config.entry = getUniqueEntries(this.config.entry);
@@ -2106,12 +2396,12 @@ ${result.errors.map((error) => ` [${error.severity}] ${error.message}${error.co
2106
2396
  ] : [
2107
2397
  "esm"
2108
2398
  ])));
2109
- this.config.output.outputPath ??= joinPaths$1("dist", this.config.projectRoot || ".");
2399
+ this.config.output.outputPath ??= joinPaths("dist", this.config.projectRoot || ".");
2110
2400
  this.config.output.assets = getUnique(this.config.output.assets.map((asset) => {
2111
2401
  return {
2112
2402
  glob: isSetObject(asset) ? asset.glob : asset,
2113
2403
  input: isString(asset) || !asset.input || asset.input === "." || asset.input === "/" || asset.input === "./" ? this.workspaceConfig.workspaceRoot : appendPath(asset.input, this.workspaceConfig.workspaceRoot),
2114
- output: appendPath(isSetObject(asset) && asset.output ? joinPaths$1(this.config.output.outputPath, replacePath(asset.output, this.config.output.outputPath)) : this.config.output.outputPath, this.workspaceConfig.workspaceRoot),
2404
+ output: appendPath(isSetObject(asset) && asset.output ? joinPaths(this.config.output.outputPath, replacePath(asset.output, this.config.output.outputPath)) : this.config.output.outputPath, this.workspaceConfig.workspaceRoot),
2115
2405
  ignore: isSetObject(asset) && asset.ignore ? toArray(asset.ignore) : void 0
2116
2406
  };
2117
2407
  }));
@@ -2122,9 +2412,10 @@ ${result.errors.map((error) => ` [${error.severity}] ${error.message}${error.co
2122
2412
  ret.push(plugin);
2123
2413
  return ret;
2124
2414
  }, []);
2415
+ this.#fs ??= await VirtualFileSystem.create(this);
2125
2416
  }
2126
2417
  mergeUserConfig(from = {}, into = this.config.userConfig ?? {}) {
2127
- this.config.userConfig = defu3({
2418
+ this.config.userConfig = defu2({
2128
2419
  entry: Array.isArray(from.entry) && from.entry.length > 0 ? from.entry : Array.isArray(into?.entry) && into.entry.length > 0 ? into.entry : []
2129
2420
  }, omit(from ?? {}, [
2130
2421
  "entry"
@@ -2489,7 +2780,7 @@ async function emitTypes(context, tsconfig, files) {
2489
2780
  const emitResult = program.emit(void 0, (fileName, text, _, __, sourceFiles, _data) => {
2490
2781
  const sourceFile = sourceFiles?.[0];
2491
2782
  if (sourceFile?.fileName && !fileName.endsWith(".map")) {
2492
- if (context.builtins.some((file) => file === sourceFile.fileName || context.fs.meta[file]?.id && context.fs.meta[file]?.id === sourceFile.fileName)) {
2783
+ if (context.builtins.some((file) => file === sourceFile.fileName || context.fs.metadata[file]?.id && context.fs.metadata[file]?.id === sourceFile.fileName)) {
2493
2784
  builtinModules += `
2494
2785
  declare module "${context.fs.resolve(sourceFile.fileName)}" {
2495
2786
  ${text.trim().replace(/^\s*export\s*declare\s*/gm, "export ").replace(/^\s*declare\s*/gm, "")}
@@ -2588,8 +2879,8 @@ async function resolveTsconfigChanges(context) {
2588
2879
  tsconfigJson.compilerOptions.emitDecoratorMetadata = true;
2589
2880
  }
2590
2881
  if (context.config.output.dts) {
2591
- const dtsFilePath = context.config.output.dts ? context.config.output.dts.startsWith(context.workspaceConfig.workspaceRoot) ? context.config.output.dts : joinPaths(context.workspaceConfig.workspaceRoot, context.config.output.dts) : joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, "storm.d.ts");
2592
- const dtsRelativePath = joinPaths(relativePath(joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot), findFilePath(dtsFilePath)), findFileName(dtsFilePath));
2882
+ const dtsFilePath = context.config.output.dts ? context.config.output.dts.startsWith(context.workspaceConfig.workspaceRoot) ? context.config.output.dts : joinPaths$1(context.workspaceConfig.workspaceRoot, context.config.output.dts) : joinPaths$1(context.workspaceConfig.workspaceRoot, context.config.projectRoot, "storm.d.ts");
2883
+ const dtsRelativePath = joinPaths$1(relativePath(joinPaths$1(context.workspaceConfig.workspaceRoot, context.config.projectRoot), findFilePath(dtsFilePath)), findFileName(dtsFilePath));
2593
2884
  if (!tsconfigJson.include?.some((filePattern) => isIncludeMatchFound(filePattern, [
2594
2885
  dtsFilePath,
2595
2886
  dtsRelativePath,
@@ -2808,10 +3099,13 @@ ${context.entry.map((entry) => `- ${entry.input.file || entry.file}${entry.outpu
2808
3099
  await resolveTsconfig(context);
2809
3100
  await installDependencies(context);
2810
3101
  await this.callPostHook(context, "configResolved");
3102
+ if (context.config.build.polyfill) {
3103
+ context.config.build.polyfill = context.config.build.polyfill.map((polyfill) => replacePathTokens(context, polyfill));
3104
+ }
2811
3105
  context.log(LogLevelLabel.TRACE, `Powerlines configuration has been resolved:
2812
3106
 
2813
3107
  ${formatLogMessage(context.config)}`);
2814
- context.fs[__VFS_INIT__]();
3108
+ context.fs[__VFS_PATCH__]();
2815
3109
  await writeMetaFile(context);
2816
3110
  context.persistedMeta = context.meta;
2817
3111
  if (!existsSync(context.cachePath)) {
@@ -2868,10 +3162,10 @@ ${formatLogMessage(context.config)}`);
2868
3162
  }
2869
3163
  return ret;
2870
3164
  }, [
2871
- joinPaths(typescriptPath, "lib", "lib.esnext.full.d.ts")
3165
+ joinPaths$1(typescriptPath, "lib", "lib.esnext.full.d.ts")
2872
3166
  ]);
2873
3167
  context.log(LogLevelLabel.TRACE, "Parsing TypeScript configuration for the Powerlines project.");
2874
- const resolvedTsconfig = getParsedTypeScriptConfig(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.tsconfig.tsconfigFilePath, defu3({
3168
+ const resolvedTsconfig = getParsedTypeScriptConfig(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.tsconfig.tsconfigFilePath, defu2({
2875
3169
  compilerOptions: {
2876
3170
  strict: false,
2877
3171
  noEmit: false,
@@ -2886,7 +3180,7 @@ ${formatLogMessage(context.config)}`);
2886
3180
  ],
2887
3181
  include: files
2888
3182
  }, context.config.tsconfigRaw ?? {}));
2889
- resolvedTsconfig.options.configFilePath = joinPaths(context.workspaceConfig.workspaceRoot, context.tsconfig.tsconfigFilePath);
3183
+ resolvedTsconfig.options.configFilePath = joinPaths$1(context.workspaceConfig.workspaceRoot, context.tsconfig.tsconfigFilePath);
2890
3184
  resolvedTsconfig.options.pathsBasePath = context.workspaceConfig.workspaceRoot;
2891
3185
  resolvedTsconfig.options.suppressOutputPathCheck = true;
2892
3186
  let generatedTypes = await emitTypes(context, resolvedTsconfig, files);
@@ -2962,26 +3256,26 @@ ${formatTypes(generatedTypes)}
2962
3256
  await this.#executeEnvironments(async (context) => {
2963
3257
  context.log(LogLevelLabel.TRACE, `Initializing the processing options for the Powerlines project.`);
2964
3258
  await this.callPreHook(context, "new");
2965
- const files = await listFiles(joinPaths(context.powerlinesPath, "files/common/**/*.hbs"));
3259
+ const files = await listFiles(joinPaths$1(context.powerlinesPath, "files/common/**/*.hbs"));
2966
3260
  for (const file of files) {
2967
3261
  context.log(LogLevelLabel.TRACE, `Adding template file: ${file}`);
2968
3262
  const template = Handlebars.compile(file);
2969
- await writeFile(context.log, joinPaths(context.config.projectRoot, file.replace(".hbs", "")), template(context));
3263
+ await writeFile(context.log, joinPaths$1(context.config.projectRoot, file.replace(".hbs", "")), template(context));
2970
3264
  }
2971
3265
  await this.callNormalHook(context, "new");
2972
3266
  if (context.config.projectType === "application") {
2973
- const files2 = await listFiles(joinPaths(context.powerlinesPath, "files/application/**/*.hbs"));
3267
+ const files2 = await listFiles(joinPaths$1(context.powerlinesPath, "files/application/**/*.hbs"));
2974
3268
  for (const file of files2) {
2975
3269
  context.log(LogLevelLabel.TRACE, `Adding application template file: ${file}`);
2976
3270
  const template = Handlebars.compile(file);
2977
- await writeFile(context.log, joinPaths(context.config.projectRoot, file.replace(".hbs", "")), template(context));
3271
+ await writeFile(context.log, joinPaths$1(context.config.projectRoot, file.replace(".hbs", "")), template(context));
2978
3272
  }
2979
3273
  } else {
2980
- const files2 = await listFiles(joinPaths(context.powerlinesPath, "files/library/**/*.hbs"));
3274
+ const files2 = await listFiles(joinPaths$1(context.powerlinesPath, "files/library/**/*.hbs"));
2981
3275
  for (const file of files2) {
2982
3276
  context.log(LogLevelLabel.TRACE, `Adding library template file: ${file}`);
2983
3277
  const template = Handlebars.compile(file);
2984
- await writeFile(context.log, joinPaths(context.config.projectRoot, file.replace(".hbs", "")), template(context));
3278
+ await writeFile(context.log, joinPaths$1(context.config.projectRoot, file.replace(".hbs", "")), template(context));
2985
3279
  }
2986
3280
  }
2987
3281
  await this.callPostHook(context, "new");
@@ -3045,7 +3339,7 @@ ${formatTypes(generatedTypes)}
3045
3339
  await this.callPreHook(context, "build");
3046
3340
  await this.callNormalHook(context, "build");
3047
3341
  await Promise.all(context.config.output.assets.map(async (asset) => {
3048
- context.log(LogLevelLabel.DEBUG, `Copying asset(s): ${chalk4.redBright(context.workspaceConfig.workspaceRoot === asset.input ? asset.glob : joinPaths(replacePath(asset.input, context.workspaceConfig.workspaceRoot), asset.glob))} -> ${chalk4.greenBright(joinPaths(replacePath(asset.output, context.workspaceConfig.workspaceRoot), asset.glob))} ${Array.isArray(asset.ignore) && asset.ignore.length > 0 ? ` (ignoring: ${asset.ignore.map((i) => chalk4.yellowBright(i)).join(", ")})` : ""}`);
3342
+ context.log(LogLevelLabel.DEBUG, `Copying asset(s): ${chalk4.redBright(context.workspaceConfig.workspaceRoot === asset.input ? asset.glob : joinPaths$1(replacePath(asset.input, context.workspaceConfig.workspaceRoot), asset.glob))} -> ${chalk4.greenBright(joinPaths$1(replacePath(asset.output, context.workspaceConfig.workspaceRoot), asset.glob))} ${Array.isArray(asset.ignore) && asset.ignore.length > 0 ? ` (ignoring: ${asset.ignore.map((i) => chalk4.yellowBright(i)).join(", ")})` : ""}`);
3049
3343
  await copyFiles(asset, asset.output);
3050
3344
  }));
3051
3345
  await this.callPostHook(context, "build");
@@ -3073,22 +3367,22 @@ ${formatTypes(generatedTypes)}
3073
3367
  this.#context.log(LogLevelLabel.TRACE, "Powerlines documentation generation completed");
3074
3368
  }
3075
3369
  /**
3076
- * Release the project
3370
+ * Deploy the project source code
3077
3371
  *
3078
3372
  * @remarks
3079
- * This method will prepare and build the Powerlines project, generating the necessary artifacts for release.
3373
+ * This method will prepare and build the Powerlines project, generating the necessary artifacts for the deployment.
3080
3374
  *
3081
- * @param inlineConfig - The inline configuration for the release command
3375
+ * @param inlineConfig - The inline configuration for the deploy command
3082
3376
  */
3083
- async release(inlineConfig = {
3084
- command: "release"
3377
+ async deploy(inlineConfig = {
3378
+ command: "deploy"
3085
3379
  }) {
3086
- this.context.log(LogLevelLabel.INFO, "\u{1F4E6} Releasing the Powerlines project");
3380
+ this.context.log(LogLevelLabel.INFO, "\u{1F4E6} Deploying the Powerlines project");
3087
3381
  await this.prepare(inlineConfig);
3088
3382
  await this.#executeEnvironments(async (context) => {
3089
- await this.callHook(context, "release");
3383
+ await this.callHook(context, "deploy");
3090
3384
  });
3091
- this.context.log(LogLevelLabel.TRACE, "Powerlines release completed");
3385
+ this.context.log(LogLevelLabel.TRACE, "Powerlines deploy completed");
3092
3386
  }
3093
3387
  /**
3094
3388
  * Finalization process
@@ -3103,6 +3397,7 @@ ${formatTypes(generatedTypes)}
3103
3397
  await this.#executeEnvironments(async (context) => {
3104
3398
  await this.callHook(context, "finalize");
3105
3399
  context.fs[__VFS_REVERT__]();
3400
+ await context.fs.dispose();
3106
3401
  });
3107
3402
  this.context.log(LogLevelLabel.TRACE, "Powerlines finalize execution completed");
3108
3403
  }
@@ -3333,7 +3628,7 @@ ${formatTypes(generatedTypes)}
3333
3628
  }
3334
3629
  }
3335
3630
  try {
3336
- const module = await this.context.resolver.plugin.import(this.context.resolver.plugin.esmResolve(joinPaths(pluginPath, "plugin")));
3631
+ const module = await this.context.resolver.plugin.import(this.context.resolver.plugin.esmResolve(joinPaths$1(pluginPath, "plugin")));
3337
3632
  const result = module.plugin ?? module.default;
3338
3633
  if (!result) {
3339
3634
  throw new Error(`The plugin package "${pluginPath}" does not export a valid module.`);
@@ -3481,4 +3776,4 @@ function createUnpluginFactory(variant, decorate) {
3481
3776
  }
3482
3777
  __name(createUnpluginFactory, "createUnpluginFactory");
3483
3778
 
3484
- export { createUnpluginFactory };
3779
+ export { VirtualFileSystem, createUnpluginFactory };