powerlines 0.24.8 → 0.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (460) hide show
  1. package/dist/{api-C32Buv5_.d.ts → api-BTK8aYwE.d.cts} +1 -1
  2. package/dist/{api-wzd5AREv.d.cts → api-eyrYBmQh.d.ts} +1 -1
  3. package/dist/api.cjs +8 -6
  4. package/dist/api.d.cts +20 -22
  5. package/dist/api.d.ts +20 -22
  6. package/dist/api.js +7 -5
  7. package/dist/astro.cjs +12 -10
  8. package/dist/astro.d.cts +19 -21
  9. package/dist/astro.d.ts +19 -21
  10. package/dist/astro.js +10 -8
  11. package/dist/{chunk-JKBJF3UI.js → chunk-2MYPFASJ.js} +2 -0
  12. package/dist/chunk-2VIXD2XB.js +3 -0
  13. package/dist/{chunk-OB7MYWHE.js → chunk-44PO64SX.js} +4 -2
  14. package/dist/chunk-4JCNAKOE.cjs +4 -0
  15. package/dist/{chunk-QH4TS5V4.cjs → chunk-6MFZ436T.cjs} +978 -1032
  16. package/dist/chunk-6ZGIV2SU.cjs +4 -0
  17. package/dist/chunk-7BZQBW77.cjs +4 -0
  18. package/dist/{chunk-JQCWV4DT.js → chunk-7LKYXMB3.js} +2 -0
  19. package/dist/{chunk-SHUYVCID.js → chunk-7QVYU63E.js} +2 -0
  20. package/dist/chunk-AFJCY3R6.js +3 -0
  21. package/dist/chunk-AXIRZAL7.js +3 -0
  22. package/dist/chunk-BTNHSS2P.cjs +13 -0
  23. package/dist/{chunk-FQXHIKCM.cjs → chunk-C2U4ATHO.cjs} +9 -7
  24. package/dist/chunk-DFLNRC3B.cjs +4 -0
  25. package/dist/chunk-DS7OM4NX.cjs +4 -0
  26. package/dist/{chunk-W5X3ZEZ5.js → chunk-EBXVKPUX.js} +2 -0
  27. package/dist/{chunk-X74SYWFL.cjs → chunk-G2EHTXK6.cjs} +9 -7
  28. package/dist/chunk-GIE6OE3X.js +3 -0
  29. package/dist/chunk-HJW7OH6E.js +3 -0
  30. package/dist/{chunk-MOXO6WJO.js → chunk-HSIMIWOH.js} +3 -1
  31. package/dist/{chunk-5IBA5HC2.cjs → chunk-HTJKPEWU.cjs} +6 -4
  32. package/dist/chunk-IHUNA3MO.cjs +4 -0
  33. package/dist/chunk-JU2HWIWS.js +12 -0
  34. package/dist/{chunk-BCHFSOQ4.js → chunk-LQXE5JHF.js} +906 -957
  35. package/dist/chunk-MBBNZS6K.cjs +16 -0
  36. package/dist/{chunk-3TNZWTLG.js → chunk-NNADGQRN.js} +5 -3
  37. package/dist/chunk-OYASPHNL.js +3 -0
  38. package/dist/chunk-PCCFAZML.js +3 -0
  39. package/dist/{chunk-USNT2KNT.cjs → chunk-PK6SKIKE.cjs} +2 -0
  40. package/dist/{chunk-ETKZMGLN.cjs → chunk-PSTCR335.cjs} +2 -0
  41. package/dist/chunk-Q7EJVZVI.cjs +4 -0
  42. package/dist/{chunk-CJSGAITR.js → chunk-S7MXT5A2.js} +3 -1
  43. package/dist/{chunk-7RWEBVQC.cjs → chunk-SDVEUTY2.cjs} +13 -11
  44. package/dist/{chunk-OLCL34MI.js → chunk-SYDUPBME.js} +6 -4
  45. package/dist/chunk-TLHFXGYV.js +3 -0
  46. package/dist/chunk-TP5MEMLG.cjs +12 -0
  47. package/dist/chunk-VNRXLY2T.js +3 -0
  48. package/dist/chunk-VQCQRLGM.cjs +4 -0
  49. package/dist/chunk-XZO6ZJQP.cjs +4 -0
  50. package/dist/{chunk-XP7OML7S.cjs → chunk-YUX7LOBU.cjs} +2 -0
  51. package/dist/chunk-YZZUOOPS.cjs +4 -0
  52. package/dist/chunk-Z5H7LD6W.js +3 -0
  53. package/dist/{chunk-VBR53KGY.js → chunk-Z5UEYORO.js} +5 -3
  54. package/dist/{chunk-PAMSESZV.cjs → chunk-Z6ARQDHR.cjs} +2 -0
  55. package/dist/config.cjs +5 -3
  56. package/dist/config.d.cts +19 -21
  57. package/dist/config.d.ts +19 -21
  58. package/dist/config.js +4 -2
  59. package/dist/{resolved-CSqGKlA5.d.cts → context-TizkCfOv.d.cts} +848 -849
  60. package/dist/{resolved-BABoCnXm.d.ts → context-jhcT1Vi1.d.ts} +848 -849
  61. package/dist/esbuild.cjs +13 -11
  62. package/dist/esbuild.d.cts +19 -21
  63. package/dist/esbuild.d.ts +19 -21
  64. package/dist/esbuild.js +10 -8
  65. package/dist/farm.cjs +9 -7
  66. package/dist/farm.d.cts +19 -21
  67. package/dist/farm.d.ts +19 -21
  68. package/dist/farm.js +8 -6
  69. package/dist/index.cjs +39 -41
  70. package/dist/index.d.cts +30 -55
  71. package/dist/index.d.ts +30 -55
  72. package/dist/index.js +20 -18
  73. package/dist/lib/{api-CDUN9en8.d.ts → api-CCOhyMZo.d.cts} +1 -1
  74. package/dist/lib/{api-BRMITKt-.d.cts → api-CpJJXdtL.d.ts} +1 -1
  75. package/dist/lib/build/esbuild.cjs +5 -5
  76. package/dist/lib/build/esbuild.d.cts +2 -2
  77. package/dist/lib/build/esbuild.d.ts +2 -2
  78. package/dist/lib/build/esbuild.js +2 -2
  79. package/dist/lib/build/index.cjs +25 -25
  80. package/dist/lib/build/index.d.cts +4 -4
  81. package/dist/lib/build/index.d.ts +4 -4
  82. package/dist/lib/build/index.js +9 -9
  83. package/dist/lib/build/rolldown.cjs +3 -3
  84. package/dist/lib/build/rolldown.d.cts +2 -2
  85. package/dist/lib/build/rolldown.d.ts +2 -2
  86. package/dist/lib/build/rolldown.js +2 -2
  87. package/dist/lib/build/rollup.cjs +3 -3
  88. package/dist/lib/build/rollup.d.cts +2 -2
  89. package/dist/lib/build/rollup.d.ts +2 -2
  90. package/dist/lib/build/rollup.js +1 -1
  91. package/dist/lib/build/rspack.cjs +2 -2
  92. package/dist/lib/build/rspack.d.cts +2 -2
  93. package/dist/lib/build/rspack.d.ts +2 -2
  94. package/dist/lib/build/rspack.js +1 -1
  95. package/dist/lib/build/tsup.cjs +6 -6
  96. package/dist/lib/build/tsup.d.cts +2 -2
  97. package/dist/lib/build/tsup.d.ts +2 -2
  98. package/dist/lib/build/tsup.js +3 -3
  99. package/dist/lib/build/unbuild.cjs +5 -5
  100. package/dist/lib/build/unbuild.d.cts +4 -4
  101. package/dist/lib/build/unbuild.d.ts +4 -4
  102. package/dist/lib/build/unbuild.js +2 -2
  103. package/dist/lib/build/vite.cjs +5 -5
  104. package/dist/lib/build/vite.d.cts +2 -2
  105. package/dist/lib/build/vite.d.ts +2 -2
  106. package/dist/lib/build/vite.js +3 -3
  107. package/dist/lib/build/webpack.cjs +2 -2
  108. package/dist/lib/build/webpack.d.cts +2 -2
  109. package/dist/lib/build/webpack.d.ts +2 -2
  110. package/dist/lib/build/webpack.js +1 -1
  111. package/dist/lib/chunk-3T56KQ7U.cjs +49 -0
  112. package/dist/lib/{chunk-PZLO6FZW.js → chunk-3W53W5J2.js} +2 -2
  113. package/dist/lib/chunk-4W6WV35V.js +108 -0
  114. package/dist/lib/chunk-6OYSDQXE.cjs +139 -0
  115. package/dist/lib/{chunk-EV357RFB.cjs → chunk-7MHUTBEC.cjs} +1 -3
  116. package/dist/lib/{chunk-A2NFSQ5K.js → chunk-7OVZZWGY.js} +1 -1
  117. package/dist/lib/chunk-A2NW7WAN.js +47 -0
  118. package/dist/lib/chunk-D6MI2V6R.cjs +115 -0
  119. package/dist/lib/{chunk-VHLINWXG.js → chunk-DLVVEHMU.js} +1 -1
  120. package/dist/lib/{chunk-XLYMVIVD.cjs → chunk-DNQBXFNE.cjs} +10 -10
  121. package/dist/lib/{chunk-UGVHYKKN.js → chunk-DYLE5FD3.js} +39 -2
  122. package/dist/lib/{chunk-AKBAX4FH.js → chunk-EN52JYUK.js} +1 -1
  123. package/dist/lib/{chunk-JYDGFQIV.cjs → chunk-F2CXZUSB.cjs} +1 -1
  124. package/dist/lib/{chunk-7VJ42H2I.cjs → chunk-HRRI4KOM.cjs} +1 -3
  125. package/dist/lib/{chunk-LPRZ3HD4.cjs → chunk-IXTLRVAK.cjs} +3 -3
  126. package/dist/lib/{chunk-SYF7QG2J.js → chunk-J3BW52BU.js} +1 -1
  127. package/dist/lib/chunk-KFDNKOXM.js +56 -0
  128. package/dist/lib/chunk-L56XA427.js +137 -0
  129. package/dist/lib/{chunk-6PPZCPME.cjs → chunk-LOW2TIQ6.cjs} +2 -2
  130. package/dist/lib/{chunk-TMZCGC5U.js → chunk-MI55FDCZ.js} +1 -1
  131. package/dist/lib/{chunk-DUZJ7ZF2.cjs → chunk-MKKWFHGE.cjs} +2 -2
  132. package/dist/lib/{chunk-ISBHXSDH.cjs → chunk-N5XEKCVW.cjs} +1 -1
  133. package/dist/lib/{chunk-XZFEHPYE.js → chunk-N5YLKWC2.js} +1 -1
  134. package/dist/lib/chunk-NIRFKQAD.js +845 -0
  135. package/dist/lib/{chunk-YMHOAMCU.cjs → chunk-NLJR4WIX.cjs} +41 -4
  136. package/dist/lib/{chunk-L3HESXYF.cjs → chunk-NUE5DIH3.cjs} +3 -3
  137. package/dist/lib/chunk-OBA5U4Y2.js +1059 -0
  138. package/dist/lib/{chunk-FQLZZYYO.js → chunk-OEF6EHQV.js} +1 -3
  139. package/dist/lib/{chunk-WTTBXYFQ.js → chunk-OFXWRM3U.js} +2 -2
  140. package/dist/lib/chunk-ONETLSPO.js +85 -0
  141. package/dist/lib/{chunk-2OV26JXJ.cjs → chunk-PQRWG64T.cjs} +3 -3
  142. package/dist/lib/chunk-R33US3PV.cjs +1081 -0
  143. package/dist/lib/{chunk-OA7OL7HF.cjs → chunk-SFEEJZLK.cjs} +38 -66
  144. package/dist/lib/{chunk-H6EOZSIZ.js → chunk-TAVG226Z.js} +1 -1
  145. package/dist/lib/{chunk-DALRRHB4.cjs → chunk-TSFG3WEA.cjs} +1 -1
  146. package/dist/lib/{chunk-RMA2PMP7.cjs → chunk-TZCC5IWH.cjs} +3 -3
  147. package/dist/lib/chunk-VHCBD2IS.js +149 -0
  148. package/dist/lib/{chunk-HY6DNFCT.js → chunk-VODWHWD6.js} +2 -2
  149. package/dist/lib/{chunk-2X5DUDNT.js → chunk-W6GWSJ22.js} +2 -2
  150. package/dist/lib/chunk-WBSA6OG6.cjs +860 -0
  151. package/dist/lib/{chunk-TOCNXURI.cjs → chunk-WCXA5WFX.cjs} +4 -4
  152. package/dist/lib/{chunk-6I5PL7H2.js → chunk-WGSZ4X6N.js} +1 -3
  153. package/dist/lib/{chunk-T2KQZC5K.js → chunk-WLDQUTFD.js} +27 -54
  154. package/dist/lib/{chunk-AOHJEL2Q.js → chunk-WOKPJMGJ.js} +3 -3
  155. package/dist/lib/{chunk-TDJNFAOV.cjs → chunk-X6JDYLWM.cjs} +1 -1
  156. package/dist/lib/chunk-XLHFUATD.cjs +151 -0
  157. package/dist/lib/chunk-XUYQYUWZ.cjs +87 -0
  158. package/dist/lib/chunk-YYEAV24J.cjs +67 -0
  159. package/dist/lib/{config-D8KrE7SZ.d.cts → config-Cqxh4V21.d.cts} +58 -475
  160. package/dist/lib/{config-DBIFdRoq.d.ts → config-D-WwQL-4.d.ts} +58 -475
  161. package/dist/lib/config-file.d.cts +2 -2
  162. package/dist/lib/config-file.d.ts +2 -2
  163. package/dist/lib/contexts/api-context.cjs +12 -7
  164. package/dist/lib/contexts/api-context.d.cts +27 -4
  165. package/dist/lib/contexts/api-context.d.ts +27 -4
  166. package/dist/lib/contexts/api-context.js +11 -6
  167. package/dist/lib/contexts/context.cjs +10 -5
  168. package/dist/lib/contexts/context.d.cts +7 -7
  169. package/dist/lib/contexts/context.d.ts +7 -7
  170. package/dist/lib/contexts/context.js +9 -4
  171. package/dist/lib/contexts/environment-context.cjs +11 -6
  172. package/dist/lib/contexts/environment-context.d.cts +4 -4
  173. package/dist/lib/contexts/environment-context.d.ts +4 -4
  174. package/dist/lib/contexts/environment-context.js +10 -5
  175. package/dist/lib/contexts/index.cjs +14 -9
  176. package/dist/lib/contexts/index.d.cts +4 -4
  177. package/dist/lib/contexts/index.d.ts +4 -4
  178. package/dist/lib/contexts/index.js +11 -6
  179. package/dist/lib/contexts/plugin-context.d.cts +4 -4
  180. package/dist/lib/contexts/plugin-context.d.ts +4 -4
  181. package/dist/lib/entry.cjs +9 -9
  182. package/dist/lib/entry.d.cts +2 -2
  183. package/dist/lib/entry.d.ts +2 -2
  184. package/dist/lib/entry.js +1 -1
  185. package/dist/lib/fs/helpers.cjs +47 -0
  186. package/dist/lib/fs/helpers.d.cts +74 -0
  187. package/dist/lib/fs/helpers.d.ts +74 -0
  188. package/dist/lib/fs/helpers.js +2 -0
  189. package/dist/lib/fs/index.cjs +17 -0
  190. package/dist/lib/fs/index.d.cts +33 -0
  191. package/dist/lib/fs/index.d.ts +33 -0
  192. package/dist/lib/fs/index.js +8 -0
  193. package/dist/lib/fs/storage/base.cjs +11 -0
  194. package/dist/lib/fs/storage/base.d.cts +138 -0
  195. package/dist/lib/fs/storage/base.d.ts +138 -0
  196. package/dist/lib/fs/storage/base.js +2 -0
  197. package/dist/lib/fs/storage/file-system.cjs +13 -0
  198. package/dist/lib/fs/storage/file-system.d.cts +90 -0
  199. package/dist/lib/fs/storage/file-system.d.ts +90 -0
  200. package/dist/lib/fs/storage/file-system.js +4 -0
  201. package/dist/lib/fs/storage/index.cjs +22 -0
  202. package/dist/lib/fs/storage/index.d.cts +6 -0
  203. package/dist/lib/fs/storage/index.d.ts +6 -0
  204. package/dist/lib/fs/storage/index.js +5 -0
  205. package/dist/lib/fs/storage/virtual.cjs +12 -0
  206. package/dist/lib/fs/storage/virtual.d.cts +66 -0
  207. package/dist/lib/fs/storage/virtual.d.ts +66 -0
  208. package/dist/lib/fs/storage/virtual.js +3 -0
  209. package/dist/lib/fs/vfs.cjs +16 -0
  210. package/dist/lib/fs/vfs.d.cts +247 -0
  211. package/dist/lib/fs/vfs.d.ts +247 -0
  212. package/dist/lib/fs/vfs.js +7 -0
  213. package/dist/lib/fs-Dg-aTfiN.d.cts +378 -0
  214. package/dist/lib/fs-Dg-aTfiN.d.ts +378 -0
  215. package/dist/lib/index.cjs +62 -68
  216. package/dist/lib/index.d.cts +18 -356
  217. package/dist/lib/index.d.ts +18 -356
  218. package/dist/lib/index.js +19 -13
  219. package/dist/lib/{internal-CaGANOWK.d.cts → internal-Cl7s1iAA.d.cts} +2 -2
  220. package/dist/lib/{internal-1qCyw7bA.d.ts → internal-W5pvS6e9.d.ts} +2 -2
  221. package/dist/lib/logger.d.cts +2 -2
  222. package/dist/lib/logger.d.ts +2 -2
  223. package/dist/lib/typescript/import-transformer.cjs +7 -45
  224. package/dist/lib/typescript/import-transformer.d.cts +2 -2
  225. package/dist/lib/typescript/import-transformer.d.ts +2 -2
  226. package/dist/lib/typescript/import-transformer.js +2 -47
  227. package/dist/lib/typescript/index.cjs +10 -22
  228. package/dist/lib/typescript/index.d.cts +4 -4
  229. package/dist/lib/typescript/index.d.ts +4 -4
  230. package/dist/lib/typescript/index.js +2 -2
  231. package/dist/lib/typescript/ts-morph.cjs +6 -2
  232. package/dist/lib/typescript/ts-morph.d.cts +28 -4
  233. package/dist/lib/typescript/ts-morph.d.ts +28 -4
  234. package/dist/lib/typescript/ts-morph.js +1 -1
  235. package/dist/lib/unplugin/factory.cjs +14 -9
  236. package/dist/lib/unplugin/factory.d.cts +4 -4
  237. package/dist/lib/unplugin/factory.d.ts +4 -4
  238. package/dist/lib/unplugin/factory.js +13 -8
  239. package/dist/lib/unplugin/helpers.d.cts +2 -2
  240. package/dist/lib/unplugin/helpers.d.ts +2 -2
  241. package/dist/lib/unplugin/index.cjs +16 -11
  242. package/dist/lib/unplugin/index.d.cts +4 -4
  243. package/dist/lib/unplugin/index.d.ts +4 -4
  244. package/dist/lib/unplugin/index.js +14 -9
  245. package/dist/lib/unplugin/plugin.cjs +2 -2
  246. package/dist/lib/unplugin/plugin.d.cts +4 -4
  247. package/dist/lib/unplugin/plugin.d.ts +4 -4
  248. package/dist/lib/unplugin/plugin.js +1 -1
  249. package/dist/lib/{unplugin-CEeJqADD.d.ts → unplugin-Cg2NoKj0.d.ts} +2 -2
  250. package/dist/lib/{unplugin-bUSyjd0S.d.cts → unplugin-trF-VLnO.d.cts} +2 -2
  251. package/dist/lib/utilities/bundle.cjs +4 -4
  252. package/dist/lib/utilities/bundle.d.cts +2 -2
  253. package/dist/lib/utilities/bundle.d.ts +2 -2
  254. package/dist/lib/utilities/bundle.js +3 -3
  255. package/dist/lib/utilities/cache.d.cts +2 -2
  256. package/dist/lib/utilities/cache.d.ts +2 -2
  257. package/dist/lib/utilities/file-header.d.cts +2 -2
  258. package/dist/lib/utilities/file-header.d.ts +2 -2
  259. package/dist/lib/utilities/index.cjs +22 -22
  260. package/dist/lib/utilities/index.d.cts +2 -2
  261. package/dist/lib/utilities/index.d.ts +2 -2
  262. package/dist/lib/utilities/index.js +6 -6
  263. package/dist/lib/utilities/meta.cjs +7 -7
  264. package/dist/lib/utilities/meta.d.cts +2 -2
  265. package/dist/lib/utilities/meta.d.ts +2 -2
  266. package/dist/lib/utilities/meta.js +1 -1
  267. package/dist/lib/utilities/resolve.cjs +5 -5
  268. package/dist/lib/utilities/resolve.d.cts +2 -2
  269. package/dist/lib/utilities/resolve.d.ts +2 -2
  270. package/dist/lib/utilities/resolve.js +4 -4
  271. package/dist/lib/utilities/source-file.d.cts +2 -2
  272. package/dist/lib/utilities/source-file.d.ts +2 -2
  273. package/dist/lib/utilities/source-map.d.cts +2 -2
  274. package/dist/lib/utilities/source-map.d.ts +2 -2
  275. package/dist/lib/utilities/worker.d.cts +2 -2
  276. package/dist/lib/utilities/worker.d.ts +2 -2
  277. package/dist/lib/utilities/write-file.d.cts +2 -2
  278. package/dist/lib/utilities/write-file.d.ts +2 -2
  279. package/dist/next.cjs +11 -9
  280. package/dist/next.js +9 -7
  281. package/dist/nuxt.cjs +13 -11
  282. package/dist/nuxt.js +11 -9
  283. package/dist/plugin-utils/{chunk-JHTLGE4X.js → chunk-K2GWRZPV.js} +1 -1
  284. package/dist/plugin-utils/{chunk-HSYQWNIH.cjs → chunk-VWFJOPKC.cjs} +1 -1
  285. package/dist/plugin-utils/{context-BITGF5LZ.d.cts → context-PtfEjz3_.d.cts} +187 -230
  286. package/dist/plugin-utils/{context-BITGF5LZ.d.ts → context-PtfEjz3_.d.ts} +187 -230
  287. package/dist/plugin-utils/context-helpers.d.cts +1 -2
  288. package/dist/plugin-utils/context-helpers.d.ts +1 -2
  289. package/dist/plugin-utils/enforce.d.cts +1 -2
  290. package/dist/plugin-utils/enforce.d.ts +1 -2
  291. package/dist/plugin-utils/extend.d.cts +1 -2
  292. package/dist/plugin-utils/extend.d.ts +1 -2
  293. package/dist/plugin-utils/get-config-path.d.cts +1 -2
  294. package/dist/plugin-utils/get-config-path.d.ts +1 -2
  295. package/dist/plugin-utils/helpers.d.cts +1 -2
  296. package/dist/plugin-utils/helpers.d.ts +1 -2
  297. package/dist/plugin-utils/index.cjs +2 -2
  298. package/dist/plugin-utils/index.d.cts +1 -2
  299. package/dist/plugin-utils/index.d.ts +1 -2
  300. package/dist/plugin-utils/index.js +1 -1
  301. package/dist/plugin-utils/merge.d.cts +1 -2
  302. package/dist/plugin-utils/merge.d.ts +1 -2
  303. package/dist/plugin-utils/paths.cjs +2 -2
  304. package/dist/plugin-utils/paths.d.cts +2 -3
  305. package/dist/plugin-utils/paths.d.ts +2 -3
  306. package/dist/plugin-utils/paths.js +1 -1
  307. package/dist/rolldown.cjs +9 -7
  308. package/dist/rolldown.d.cts +19 -21
  309. package/dist/rolldown.d.ts +19 -21
  310. package/dist/rolldown.js +8 -6
  311. package/dist/rollup.cjs +9 -7
  312. package/dist/rollup.d.cts +19 -21
  313. package/dist/rollup.d.ts +19 -21
  314. package/dist/rollup.js +8 -6
  315. package/dist/rspack.cjs +9 -7
  316. package/dist/rspack.d.cts +18 -20
  317. package/dist/rspack.d.ts +18 -20
  318. package/dist/rspack.js +8 -6
  319. package/dist/tsup.cjs +12 -10
  320. package/dist/tsup.js +10 -8
  321. package/dist/types/api.cjs +3 -1
  322. package/dist/types/api.cjs.map +1 -0
  323. package/dist/types/api.d.cts +20 -22
  324. package/dist/types/api.d.ts +20 -22
  325. package/dist/types/api.js +3 -1
  326. package/dist/types/api.js.map +1 -0
  327. package/dist/types/babel.cjs +3 -1
  328. package/dist/types/babel.cjs.map +1 -0
  329. package/dist/types/babel.d.cts +17 -19
  330. package/dist/types/babel.d.ts +17 -19
  331. package/dist/types/babel.js +3 -1
  332. package/dist/types/babel.js.map +1 -0
  333. package/dist/types/build.cjs +3 -1
  334. package/dist/types/build.cjs.map +1 -0
  335. package/dist/types/build.js +3 -1
  336. package/dist/types/build.js.map +1 -0
  337. package/dist/types/commands.cjs +5 -3
  338. package/dist/types/commands.cjs.map +1 -0
  339. package/dist/types/commands.d.cts +18 -20
  340. package/dist/types/commands.d.ts +18 -20
  341. package/dist/types/commands.js +4 -2
  342. package/dist/types/commands.js.map +1 -0
  343. package/dist/types/config.cjs +3 -1
  344. package/dist/types/config.cjs.map +1 -0
  345. package/dist/types/config.d.cts +2 -4
  346. package/dist/types/config.d.ts +2 -4
  347. package/dist/types/config.js +3 -1
  348. package/dist/types/config.js.map +1 -0
  349. package/dist/types/context.cjs +5 -3
  350. package/dist/types/context.cjs.map +1 -0
  351. package/dist/types/context.d.cts +8 -10
  352. package/dist/types/context.d.ts +8 -10
  353. package/dist/types/context.js +4 -2
  354. package/dist/types/context.js.map +1 -0
  355. package/dist/types/fs.cjs +10 -4
  356. package/dist/types/fs.cjs.map +1 -0
  357. package/dist/types/fs.d.cts +138 -184
  358. package/dist/types/fs.d.ts +138 -184
  359. package/dist/types/fs.js +4 -2
  360. package/dist/types/fs.js.map +1 -0
  361. package/dist/types/hooks.cjs +3 -1
  362. package/dist/types/hooks.cjs.map +1 -0
  363. package/dist/types/hooks.d.cts +19 -21
  364. package/dist/types/hooks.d.ts +19 -21
  365. package/dist/types/hooks.js +3 -1
  366. package/dist/types/hooks.js.map +1 -0
  367. package/dist/types/index.cjs +26 -20
  368. package/dist/types/index.cjs.map +1 -0
  369. package/dist/types/index.d.cts +13 -15
  370. package/dist/types/index.d.ts +13 -15
  371. package/dist/types/index.js +17 -15
  372. package/dist/types/index.js.map +1 -0
  373. package/dist/types/internal.cjs +2 -0
  374. package/dist/types/internal.cjs.map +1 -0
  375. package/dist/types/internal.d.cts +20 -22
  376. package/dist/types/internal.d.ts +20 -22
  377. package/dist/types/internal.js +2 -0
  378. package/dist/types/internal.js.map +1 -0
  379. package/dist/types/plugin.cjs +5 -3
  380. package/dist/types/plugin.cjs.map +1 -0
  381. package/dist/types/plugin.d.cts +9 -11
  382. package/dist/types/plugin.d.ts +9 -11
  383. package/dist/types/plugin.js +4 -2
  384. package/dist/types/plugin.js.map +1 -0
  385. package/dist/types/resolved.cjs +3 -1
  386. package/dist/types/resolved.cjs.map +1 -0
  387. package/dist/types/resolved.d.cts +7 -9
  388. package/dist/types/resolved.d.ts +7 -9
  389. package/dist/types/resolved.js +3 -1
  390. package/dist/types/resolved.js.map +1 -0
  391. package/dist/types/tsconfig.cjs +3 -1
  392. package/dist/types/tsconfig.cjs.map +1 -0
  393. package/dist/types/tsconfig.js +3 -1
  394. package/dist/types/tsconfig.js.map +1 -0
  395. package/dist/types/typedoc.cjs +3 -1
  396. package/dist/types/typedoc.cjs.map +1 -0
  397. package/dist/types/typedoc.js +3 -1
  398. package/dist/types/typedoc.js.map +1 -0
  399. package/dist/types/unplugin.cjs +3 -1
  400. package/dist/types/unplugin.cjs.map +1 -0
  401. package/dist/types/unplugin.d.cts +11 -13
  402. package/dist/types/unplugin.d.ts +11 -13
  403. package/dist/types/unplugin.js +3 -1
  404. package/dist/types/unplugin.js.map +1 -0
  405. package/dist/unloader.cjs +9 -7
  406. package/dist/unloader.d.cts +19 -21
  407. package/dist/unloader.d.ts +19 -21
  408. package/dist/unloader.js +8 -6
  409. package/dist/unplugin.cjs +20 -20
  410. package/dist/unplugin.d.cts +19 -21
  411. package/dist/unplugin.d.ts +19 -21
  412. package/dist/unplugin.js +10 -10
  413. package/dist/vite.cjs +13 -11
  414. package/dist/vite.d.cts +19 -21
  415. package/dist/vite.d.ts +19 -21
  416. package/dist/vite.js +10 -8
  417. package/dist/webpack.cjs +12 -10
  418. package/dist/webpack.d.cts +19 -21
  419. package/dist/webpack.d.ts +19 -21
  420. package/dist/webpack.js +9 -7
  421. package/package.json +72 -19
  422. package/schemas/fs.capnp +4 -59
  423. package/dist/chunk-2NO7N5OW.cjs +0 -2
  424. package/dist/chunk-7GYTTM4M.cjs +0 -2
  425. package/dist/chunk-AENPRFWJ.cjs +0 -2
  426. package/dist/chunk-AYKZK666.cjs +0 -8
  427. package/dist/chunk-BUR2JQ6G.cjs +0 -11
  428. package/dist/chunk-DRXFQCNC.js +0 -1
  429. package/dist/chunk-FNZDWE4L.js +0 -1
  430. package/dist/chunk-GHJU2KGP.cjs +0 -2
  431. package/dist/chunk-GRU7B3QM.cjs +0 -2
  432. package/dist/chunk-HQFZ64VC.cjs +0 -2
  433. package/dist/chunk-J4BQZHTQ.js +0 -1
  434. package/dist/chunk-JGB5YQ2U.js +0 -1
  435. package/dist/chunk-KALR2O2F.cjs +0 -2
  436. package/dist/chunk-LOUZXJFY.cjs +0 -10
  437. package/dist/chunk-OO3YXM72.js +0 -1
  438. package/dist/chunk-QE3WGMAP.js +0 -1
  439. package/dist/chunk-SMNKPH4T.js +0 -1
  440. package/dist/chunk-T2P533I5.js +0 -1
  441. package/dist/chunk-V3MLQDZQ.js +0 -1
  442. package/dist/chunk-VT7NVLLU.js +0 -5
  443. package/dist/chunk-YRJ4MLVL.cjs +0 -2
  444. package/dist/chunk-ZC43PZXS.cjs +0 -2
  445. package/dist/lib/chunk-3MZQ4MQX.cjs +0 -2360
  446. package/dist/lib/chunk-5JAFU45Z.js +0 -2324
  447. package/dist/lib/chunk-HAXL7QE7.js +0 -154
  448. package/dist/lib/chunk-SAS5EPBD.cjs +0 -107
  449. package/dist/lib/chunk-WUYK74EH.cjs +0 -165
  450. package/dist/lib/chunk-YQ3ODCHV.js +0 -105
  451. package/dist/lib/typescript/compiler-host.cjs +0 -164
  452. package/dist/lib/typescript/compiler-host.d.cts +0 -63
  453. package/dist/lib/typescript/compiler-host.d.ts +0 -63
  454. package/dist/lib/typescript/compiler-host.js +0 -156
  455. package/dist/lib/typescript/program.cjs +0 -27
  456. package/dist/lib/typescript/program.d.cts +0 -68
  457. package/dist/lib/typescript/program.d.ts +0 -68
  458. package/dist/lib/typescript/program.js +0 -2
  459. /package/dist/{chunk-2NCILNCH.cjs → lib/chunk-K2SFTPN3.cjs} +0 -0
  460. /package/dist/{chunk-BLNT5INX.js → lib/chunk-NQAHFTUW.js} +0 -0
@@ -1,16 +1,17 @@
1
- import { PLUGIN_NON_HOOK_FIELDS } from './chunk-JQCWV4DT.js';
2
- import { SUPPORTED_COMMANDS } from './chunk-JKBJF3UI.js';
3
- import { __VFS_PATCH__, __VFS_REVERT__ } from './chunk-VT7NVLLU.js';
4
- import { __name } from './chunk-SHUYVCID.js';
1
+ import { PLUGIN_NON_HOOK_FIELDS } from './chunk-7LKYXMB3.js';
2
+ import { SUPPORTED_COMMANDS } from './chunk-2MYPFASJ.js';
3
+ import { StoragePreset } from './chunk-JU2HWIWS.js';
4
+ import { __name } from './chunk-7QVYU63E.js';
5
5
  import { transformAsync } from '@babel/core';
6
6
  import { formatLogMessage } from '@storm-software/config-tools/logger/console';
7
7
  import { LogLevelLabel } from '@storm-software/config-tools/types';
8
8
  import { toArray } from '@stryke/convert/to-array';
9
9
  import { copyFiles } from '@stryke/fs/copy-file';
10
+ import { createDirectory } from '@stryke/fs/helpers';
10
11
  import { install } from '@stryke/fs/install';
11
- import { listFiles, listFilesSync } from '@stryke/fs/list-files';
12
+ import { listFilesSync, listFiles } from '@stryke/fs/list-files';
12
13
  import { isPackageExists, isPackageListed, doesPackageMatch, getPackageListing } from '@stryke/fs/package-fns';
13
- import { getResolutionCombinations, resolve, resolveSync, resolvePackage } from '@stryke/fs/resolve';
14
+ import { getResolutionCombinations, resolve as resolve$1, resolveSync, resolvePackage } from '@stryke/fs/resolve';
14
15
  import { appendPath } from '@stryke/path/append';
15
16
  import { joinPaths as joinPaths$1 } from '@stryke/path/join-paths';
16
17
  import { replacePath, replaceExtension } from '@stryke/path/replace';
@@ -25,17 +26,18 @@ import chalk5 from 'chalk';
25
26
  import Handlebars from 'handlebars';
26
27
  import { declare } from '@babel/helper-plugin-utils';
27
28
  import * as t from '@babel/types';
28
- import ts2, { flattenDiagnosticMessageText } from 'typescript';
29
- import defu6, { defu } from 'defu';
29
+ import ts, { flattenDiagnosticMessageText } from 'typescript';
30
+ import { joinPaths } from '@stryke/path/join';
31
+ import defu7, { defu } from 'defu';
32
+ import { InMemoryFileSystemHost, Project } from 'ts-morph';
30
33
  import { getPackageName, hasPackageVersion, getPackageVersion } from '@stryke/string-format/package';
31
34
  import { getObjectDiff } from '@donedeal0/superdiff';
32
35
  import { readJsonFile, readJsonFileSync } from '@stryke/fs/json';
33
36
  import { StormJSON } from '@stryke/json/storm-json';
34
- import { findFilePath, findFileExtension, relativePath, findFileName, findFileDotExtensionSafe } from '@stryke/path/file-path-fns';
35
- import { isParentPath } from '@stryke/path/is-parent-path';
37
+ import { hasFileExtension, findFilePath, findFileName, relativePath, findFileDotExtensionSafe } from '@stryke/path/file-path-fns';
36
38
  import { titleCase } from '@stryke/string-format/title-case';
37
- import { existsSync } from '@stryke/fs/exists';
38
- import { writeFile as writeFile$1 } from '@stryke/fs/write-file';
39
+ import { existsSync, exists } from '@stryke/fs/exists';
40
+ import { writeFileSync, writeFile as writeFile$1 } from '@stryke/fs/write-file';
39
41
  import { resolveConfig, format } from 'prettier';
40
42
  import { getWorkspaceConfig } from '@storm-software/config-tools/get-config';
41
43
  import { loadConfig } from 'c12';
@@ -46,7 +48,6 @@ import { murmurhash } from '@stryke/hash/murmurhash';
46
48
  import { getUnique, getUniqueBy } from '@stryke/helpers/get-unique';
47
49
  import { omit } from '@stryke/helpers/omit';
48
50
  import { isAbsolutePath, isAbsolute } from '@stryke/path/is-type';
49
- import { joinPaths } from '@stryke/path/join';
50
51
  import { isNull } from '@stryke/type-checks/is-null';
51
52
  import { isString } from '@stryke/type-checks/is-string';
52
53
  import { uuid } from '@stryke/unique-id/uuid';
@@ -56,21 +57,20 @@ import { isUndefined } from '@stryke/type-checks/is-undefined';
56
57
  import { parseTypeDefinition } from '@stryke/convert/parse-type-definition';
57
58
  import { isFile } from '@stryke/fs/is-file';
58
59
  import * as $ from '@stryke/capnp';
59
- import { bufferToString } from '@stryke/convert/buffer-to-string';
60
60
  import { readFileBuffer, readFileBufferSync, writeFileBuffer } from '@stryke/fs/buffer';
61
- import { toAbsolutePath, correctPath } from '@stryke/path/correct-path';
61
+ import { correctPath, toAbsolutePath } from '@stryke/path/correct-path';
62
+ import { isParentPath } from '@stryke/path/is-parent-path';
62
63
  import { prettyBytes } from '@stryke/string-format/pretty-bytes';
63
- import { isBuffer } from '@stryke/type-checks/is-buffer';
64
64
  import { create } from 'flat-cache';
65
65
  import { Blob } from 'node:buffer';
66
- import _fs from 'node:fs';
67
66
  import { getLogFn, getLogLevel } from '@storm-software/config-tools/logger';
68
67
  import { getColor } from '@storm-software/config-tools/utilities/colors';
69
68
  import { noop } from '@stryke/helpers/noop';
70
69
  import { slash } from '@stryke/path/slash';
71
- import { Volume } from 'memfs';
72
- import { Union } from 'unionfs';
73
- import { InMemoryFileSystemHost, Project } from 'ts-morph';
70
+ import { readFileSync, readFile } from '@stryke/fs/read-file';
71
+ import { unlinkSync } from 'node:fs';
72
+ import { unlink } from 'node:fs/promises';
73
+ import { resolve } from 'node:path';
74
74
  import '@stryke/fs/remove-file';
75
75
  import { kebabCase } from '@stryke/string-format/kebab-case';
76
76
  import { isObject } from '@stryke/type-checks/is-object';
@@ -176,6 +176,108 @@ var moduleResolverBabelPlugin = /* @__PURE__ */ __name((context) => {
176
176
  };
177
177
  }, "builder"));
178
178
  }, "moduleResolverBabelPlugin");
179
+ var VirtualFileSystemHost = class extends InMemoryFileSystemHost {
180
+ static {
181
+ __name(this, "VirtualFileSystemHost");
182
+ }
183
+ #context;
184
+ constructor(context) {
185
+ super();
186
+ this.#context = context;
187
+ }
188
+ deleteSync(path) {
189
+ this.#context.fs.removeSync(path);
190
+ }
191
+ readDirSync(dirPath) {
192
+ return this.#context.fs.listSync(dirPath).reduce((ret, entry) => {
193
+ const fullPath = this.#context.fs.resolveSync(joinPaths(dirPath, entry));
194
+ if (fullPath) {
195
+ ret.push({
196
+ name: entry,
197
+ isDirectory: this.#context.fs.existsSync(fullPath),
198
+ isFile: this.#context.fs.existsSync(fullPath),
199
+ isSymlink: false
200
+ });
201
+ }
202
+ return ret;
203
+ }, []);
204
+ }
205
+ async readFile(filePath) {
206
+ if (!this.#context.fs.existsSync(filePath)) {
207
+ throw new Error(`File not found: '${filePath}'. Please check the path and try again.`);
208
+ }
209
+ return await this.#context.fs.read(filePath);
210
+ }
211
+ readFileSync(filePath) {
212
+ if (!this.#context.fs.existsSync(filePath)) {
213
+ throw new Error(`File not found: '${filePath}'. Please check the path and try again.`);
214
+ }
215
+ return this.#context.fs.readSync(filePath);
216
+ }
217
+ async writeFile(filePath, fileText) {
218
+ return this.#context.fs.write(filePath, fileText);
219
+ }
220
+ writeFileSync(filePath, fileText) {
221
+ this.#context.fs.writeSync(filePath, fileText);
222
+ }
223
+ async mkdir(_dirPath) {
224
+ }
225
+ mkdirSync(_dirPath) {
226
+ }
227
+ async move(srcPath, destPath) {
228
+ await this.#context.fs.move(srcPath, destPath);
229
+ }
230
+ moveSync(srcPath, destPath) {
231
+ this.#context.fs.moveSync(srcPath, destPath);
232
+ }
233
+ async copy(srcPath, destPath) {
234
+ await this.#context.fs.copy(srcPath, destPath);
235
+ }
236
+ copySync(srcPath, destPath) {
237
+ this.#context.fs.copySync(srcPath, destPath);
238
+ }
239
+ async fileExists(filePath) {
240
+ return this.#context.fs.exists(filePath);
241
+ }
242
+ fileExistsSync(filePath) {
243
+ return this.#context.fs.existsSync(filePath);
244
+ }
245
+ async directoryExists(dirPath) {
246
+ return this.#context.fs.exists(dirPath);
247
+ }
248
+ directoryExistsSync(dirPath) {
249
+ return this.#context.fs.existsSync(dirPath);
250
+ }
251
+ realpathSync(path) {
252
+ return this.#context.fs.resolveSync(path) || path;
253
+ }
254
+ getCurrentDirectory() {
255
+ return this.#context.workspaceConfig.workspaceRoot;
256
+ }
257
+ async glob(patterns) {
258
+ return this.#context.fs.glob(patterns);
259
+ }
260
+ globSync(patterns) {
261
+ return this.#context.fs.globSync(patterns);
262
+ }
263
+ };
264
+ function createProgram(context, override) {
265
+ context.log(LogLevelLabel.TRACE, `Creating ts-morph Project instance with configuration from: ${context.tsconfig.tsconfigFilePath}.`);
266
+ const project = new Project(defu7(override ?? {}, {
267
+ skipAddingFilesFromTsConfig: false,
268
+ tsConfigFilePath: context.tsconfig.tsconfigFilePath,
269
+ fileSystem: new VirtualFileSystemHost(context),
270
+ compilerOptions: defu7(context.tsconfig.options ?? {}, {
271
+ lib: [
272
+ "lib.esnext.full.d.ts"
273
+ ]
274
+ })
275
+ }));
276
+ return project;
277
+ }
278
+ __name(createProgram, "createProgram");
279
+
280
+ // src/internal/helpers/generate-types.ts
179
281
  function formatTypes(code) {
180
282
  return code.replace(
181
283
  // eslint-disable-next-line regexp/no-super-linear-backtracking
@@ -186,8 +288,11 @@ function formatTypes(code) {
186
288
  __name(formatTypes, "formatTypes");
187
289
  async function emitTypes(context, files) {
188
290
  context.log(LogLevelLabel.TRACE, `Running the TypeScript compiler for ${files.length} generated runtime files.`);
189
- context.program.addSourceFilesAtPaths(files);
190
- const result = context.program.emitToMemory({
291
+ const program = createProgram(context, {
292
+ skipAddingFilesFromTsConfig: true
293
+ });
294
+ program.addSourceFilesAtPaths(files);
295
+ const result = program.emitToMemory({
191
296
  emitOnlyDtsFiles: true
192
297
  });
193
298
  let builtinModules = "";
@@ -384,13 +489,13 @@ function isIncludeMatchFound(tsconfigType, types) {
384
489
  return findIncludeMatch(tsconfigType, types) !== void 0;
385
490
  }
386
491
  __name(isIncludeMatchFound, "isIncludeMatchFound");
387
- function getParsedTypeScriptConfig(workspaceRoot, projectRoot, tsconfig, tsconfigRaw = {}, originalTsconfigJson, host = ts2.sys) {
492
+ function getParsedTypeScriptConfig(workspaceRoot, projectRoot, tsconfig, tsconfigRaw = {}, originalTsconfigJson, host = ts.sys) {
388
493
  const tsconfigFilePath = getTsconfigFilePath(workspaceRoot, projectRoot, tsconfig);
389
494
  const tsconfigJson = readJsonFileSync(tsconfigFilePath);
390
495
  if (!tsconfigJson) {
391
496
  throw new Error(`Cannot find the \`tsconfig.json\` configuration file at ${joinPaths$1(projectRoot, tsconfig ?? "tsconfig.json")}`);
392
497
  }
393
- const parsedCommandLine = ts2.parseJsonConfigFileContent(defu6(tsconfigRaw ?? {}, tsconfigJson), host, appendPath(projectRoot, workspaceRoot));
498
+ const parsedCommandLine = ts.parseJsonConfigFileContent(defu7(tsconfigRaw ?? {}, tsconfigJson), host, appendPath(projectRoot, workspaceRoot));
394
499
  if (parsedCommandLine.errors.length > 0) {
395
500
  const errorMessage = `Cannot parse the TypeScript compiler options. Please investigate the following issues:
396
501
  ${parsedCommandLine.errors.map((error) => `- ${(error.category !== void 0 && error.code ? `[${error.category}-${error.code}]: ` : "") + error.messageText.toString()}`).join("\n")}
@@ -431,15 +536,10 @@ async function resolveTsconfigChanges(context) {
431
536
  const tsconfigJson = await readJsonFile(tsconfigFilePath);
432
537
  tsconfigJson.compilerOptions ??= {};
433
538
  if (context.config.output.dts !== false) {
434
- context.config.output.dts = context.config.output.dts ? isParentPath(context.config.output.dts, context.workspaceConfig.workspaceRoot) ? context.config.output.dts : appendPath(context.config.output.dts, context.workspaceConfig.workspaceRoot) : appendPath(context.config.projectRoot, context.workspaceConfig.workspaceRoot);
435
- if (findFileExtension(context.config.output.dts) !== "d.ts" && findFileExtension(context.config.output.dts) !== "d.cts" && findFileExtension(context.config.output.dts) !== "d.mts") {
436
- context.config.output.dts = joinPaths$1(context.config.output.dts, "powerlines.d.ts");
437
- }
438
- const dtsRelativePath = joinPaths$1(relativePath(joinPaths$1(context.workspaceConfig.workspaceRoot, context.config.projectRoot), findFilePath(context.config.output.dts)), findFileName(context.config.output.dts));
539
+ const dtsRelativePath = joinPaths$1(relativePath(joinPaths$1(context.workspaceConfig.workspaceRoot, context.config.projectRoot), findFilePath(context.dtsPath)), findFileName(context.dtsPath));
439
540
  if (!tsconfigJson.include?.some((filePattern) => isIncludeMatchFound(filePattern, [
440
- String(context.config.output.dts),
441
- dtsRelativePath,
442
- "storm.d.ts"
541
+ context.dtsPath,
542
+ dtsRelativePath
443
543
  ]))) {
444
544
  tsconfigJson.include ??= [];
445
545
  tsconfigJson.include.push(dtsRelativePath.startsWith("./") ? dtsRelativePath.slice(2) : dtsRelativePath);
@@ -454,24 +554,6 @@ async function resolveTsconfigChanges(context) {
454
554
  tsconfigJson.compilerOptions.lib ??= [];
455
555
  tsconfigJson.compilerOptions.lib.push("esnext");
456
556
  }
457
- if (tsconfig.options.module !== ts2.ModuleKind.ESNext) {
458
- tsconfigJson.compilerOptions.module = "ESNext";
459
- }
460
- if (!tsconfig.options.target || ![
461
- ts2.ScriptTarget.ESNext,
462
- ts2.ScriptTarget.ES2024,
463
- ts2.ScriptTarget.ES2023,
464
- ts2.ScriptTarget.ES2022,
465
- ts2.ScriptTarget.ES2021
466
- ].includes(tsconfig.options.target)) {
467
- tsconfigJson.compilerOptions.target = "ESNext";
468
- }
469
- if (tsconfig.options.moduleResolution !== ts2.ModuleResolutionKind.Bundler) {
470
- tsconfigJson.compilerOptions.moduleResolution = "Bundler";
471
- }
472
- if (tsconfig.options.moduleDetection !== ts2.ModuleDetectionKind.Force) {
473
- tsconfigJson.compilerOptions.moduleDetection = "force";
474
- }
475
557
  if (tsconfig.options.esModuleInterop !== true) {
476
558
  tsconfigJson.compilerOptions.esModuleInterop = true;
477
559
  }
@@ -496,9 +578,7 @@ async function initializeTsconfig(context) {
496
578
  context.tsconfig.originalTsconfigJson = await readJsonFile(tsconfigFilePath);
497
579
  context.tsconfig.tsconfigJson = await resolveTsconfigChanges(context);
498
580
  context.log(LogLevelLabel.TRACE, "Writing updated TypeScript configuration (tsconfig.json) file to disk.");
499
- await context.fs.writeFile(tsconfigFilePath, StormJSON.stringify(context.tsconfig.tsconfigJson), {
500
- mode: "fs"
501
- });
581
+ await writeFile(context.log, tsconfigFilePath, StormJSON.stringify(context.tsconfig.tsconfigJson));
502
582
  context.tsconfig = getParsedTypeScriptConfig(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.config.tsconfig, context.config.tsconfigRaw, context.tsconfig.originalTsconfigJson);
503
583
  }
504
584
  __name(initializeTsconfig, "initializeTsconfig");
@@ -558,7 +638,7 @@ async function resolveTsconfig(context) {
558
638
  __name(resolveTsconfig, "resolveTsconfig");
559
639
  var DEFAULT_ENVIRONMENT = "default";
560
640
  function createEnvironment(name, userConfig) {
561
- return defu6(userConfig.environments?.[name] ?? {}, {
641
+ return defu7(userConfig.environments?.[name] ?? {}, {
562
642
  name,
563
643
  title: userConfig.title || titleCase(userConfig.name),
564
644
  ssr: false,
@@ -602,7 +682,7 @@ function createDefaultEnvironment(userConfig) {
602
682
  }
603
683
  __name(createDefaultEnvironment, "createDefaultEnvironment");
604
684
  async function loadWorkspaceConfig(workspaceRoot, cwd) {
605
- return defu6({
685
+ return defu7({
606
686
  workspaceRoot
607
687
  }, await getWorkspaceConfig(true, {
608
688
  cwd,
@@ -650,15 +730,14 @@ async function loadUserConfigFile(projectRoot, workspaceRoot, jiti, command, mod
650
730
  dotenv: true,
651
731
  jiti
652
732
  });
653
- return defu6(resolvedUserConfig, isSetObject(result?.config) ? {
733
+ return defu7(resolvedUserConfig, isSetObject(result?.config) ? {
654
734
  ...result.config,
655
735
  ...result
656
736
  } : {});
657
737
  }
658
738
  __name(loadUserConfigFile, "loadUserConfigFile");
659
739
  function resolveOptions(options) {
660
- return defu6(options, {
661
- debug: options.logLevel === "trace",
740
+ return defu7(options, {
662
741
  interopDefault: true,
663
742
  fsCache: options.mode !== "development" ? joinPaths$1(options.cacheDir, "jiti") : false,
664
743
  moduleCache: options.mode !== "development"
@@ -734,7 +813,7 @@ function replacePathTokens(context, path) {
734
813
  if (!path) {
735
814
  return path;
736
815
  }
737
- return path.replaceAll("{workspaceRoot}", context.workspaceConfig.workspaceRoot).replaceAll("{root}", context.config.projectRoot).replaceAll("{projectRoot}", context.config.projectRoot).replaceAll("{powerlinesPath}", context.powerlinesPath).replaceAll("{cachePath}", context.cachePath).replaceAll("{dataPath}", context.dataPath).replaceAll("{logPath}", context.envPaths.log).replaceAll("{tempPath}", context.envPaths.temp).replaceAll("{configPath}", context.envPaths.config).replaceAll("{outputPath}", context.config.output.outputPath).replaceAll("{distPath}", context.config.output.distPath).replaceAll("{artifactsPath}", replacePath(context.artifactsPath, context.workspaceConfig.workspaceRoot)).replaceAll("{builtinPath}", replacePath(context.builtinsPath, context.workspaceConfig.workspaceRoot)).replaceAll("{entryPath}", replacePath(context.entryPath, context.workspaceConfig.workspaceRoot));
816
+ return path.replaceAll("{workspaceRoot}", context.workspaceConfig.workspaceRoot).replaceAll("{root}", context.config.projectRoot).replaceAll("{projectRoot}", context.config.projectRoot).replaceAll("{powerlinesPath}", context.powerlinesPath).replaceAll("{cachePath}", context.cachePath).replaceAll("{dataPath}", context.dataPath).replaceAll("{logPath}", context.envPaths.log).replaceAll("{tempPath}", context.envPaths.temp).replaceAll("{configPath}", context.envPaths.config).replaceAll("{outputPath}", context.config.output.outputPath).replaceAll("{buildPath}", context.config.output.buildPath).replaceAll("{artifactsPath}", replacePath(context.artifactsPath, context.workspaceConfig.workspaceRoot)).replaceAll("{builtinPath}", replacePath(context.builtinsPath, context.workspaceConfig.workspaceRoot)).replaceAll("{entryPath}", replacePath(context.entryPath, context.workspaceConfig.workspaceRoot));
738
817
  }
739
818
  __name(replacePathTokens, "replacePathTokens");
740
819
  function resolveEntryInputFile(context, typeDefinition) {
@@ -785,19 +864,6 @@ function getUniqueEntries(entries = []) {
785
864
  }
786
865
  __name(getUniqueEntries, "getUniqueEntries");
787
866
  var _capnpFileId = BigInt("0xa56c61324b9d6e49");
788
- var FileType = {
789
- NORMAL: 0,
790
- BUILTIN: 1,
791
- ENTRY: 2,
792
- CHUNK: 3,
793
- PREBUILT: 4,
794
- ASSET: 5
795
- };
796
- var PreserveSignatureType = {
797
- STRICT: 0,
798
- ALLOW_EXTENSION: 1,
799
- EXPORTS_ONLY: 2
800
- };
801
867
  var FileMetadata_KeyValuePair = class extends $.Struct {
802
868
  static {
803
869
  __name(this, "FileMetadata_KeyValuePair");
@@ -831,7 +897,7 @@ var FileMetadata = class _FileMetadata extends $.Struct {
831
897
  static _capnp = {
832
898
  displayName: "FileMetadata",
833
899
  id: "8e2cab5d7e28c7b3",
834
- size: new $.ObjectSize(8, 4),
900
+ size: new $.ObjectSize(8, 3),
835
901
  defaultType: "normal"
836
902
  };
837
903
  static _Properties;
@@ -846,7 +912,7 @@ var FileMetadata = class _FileMetadata extends $.Struct {
846
912
  $.utils.setText(0, value, this);
847
913
  }
848
914
  /**
849
- * The output mode of the file.
915
+ * The timestamp representing the file's creation date.
850
916
  *
851
917
  */
852
918
  get type() {
@@ -856,16 +922,6 @@ var FileMetadata = class _FileMetadata extends $.Struct {
856
922
  $.utils.setText(1, value, this);
857
923
  }
858
924
  /**
859
- * The timestamp representing the file's creation date.
860
- *
861
- */
862
- get mode() {
863
- return $.utils.getText(2, this);
864
- }
865
- set mode(value) {
866
- $.utils.setText(2, value, this);
867
- }
868
- /**
869
925
  * Additional metadata associated with the file.
870
926
  *
871
927
  */
@@ -876,22 +932,22 @@ var FileMetadata = class _FileMetadata extends $.Struct {
876
932
  $.utils.setUint32(0, value, this);
877
933
  }
878
934
  _adoptProperties(value) {
879
- $.utils.adopt(value, $.utils.getPointer(3, this));
935
+ $.utils.adopt(value, $.utils.getPointer(2, this));
880
936
  }
881
937
  _disownProperties() {
882
938
  return $.utils.disown(this.properties);
883
939
  }
884
940
  get properties() {
885
- return $.utils.getList(3, _FileMetadata._Properties, this);
941
+ return $.utils.getList(2, _FileMetadata._Properties, this);
886
942
  }
887
943
  _hasProperties() {
888
- return !$.utils.isNull($.utils.getPointer(3, this));
944
+ return !$.utils.isNull($.utils.getPointer(2, this));
889
945
  }
890
946
  _initProperties(length) {
891
- return $.utils.initList(3, _FileMetadata._Properties, length, this);
947
+ return $.utils.initList(2, _FileMetadata._Properties, length, this);
892
948
  }
893
949
  set properties(value) {
894
- $.utils.copyFrom(value, $.utils.getPointer(3, this));
950
+ $.utils.copyFrom(value, $.utils.getPointer(2, this));
895
951
  }
896
952
  toString() {
897
953
  return "FileMetadata_" + super.toString();
@@ -926,13 +982,13 @@ var FileId = class extends $.Struct {
926
982
  return "FileId_" + super.toString();
927
983
  }
928
984
  };
929
- var FileData = class extends $.Struct {
985
+ var FileStorage = class extends $.Struct {
930
986
  static {
931
- __name(this, "FileData");
987
+ __name(this, "FileStorage");
932
988
  }
933
989
  static _capnp = {
934
- displayName: "FileData",
935
- id: "fa6725c8a360f9a2",
990
+ displayName: "FileStorage",
991
+ id: "9dca66ac858c9ebe",
936
992
  size: new $.ObjectSize(0, 2)
937
993
  };
938
994
  /**
@@ -952,7 +1008,7 @@ var FileData = class extends $.Struct {
952
1008
  $.utils.setText(1, value, this);
953
1009
  }
954
1010
  toString() {
955
- return "FileData_" + super.toString();
1011
+ return "FileStorage_" + super.toString();
956
1012
  }
957
1013
  };
958
1014
  var FileSystem = class _FileSystem extends $.Struct {
@@ -965,7 +1021,7 @@ var FileSystem = class _FileSystem extends $.Struct {
965
1021
  size: new $.ObjectSize(0, 3)
966
1022
  };
967
1023
  static _Ids;
968
- static _Files;
1024
+ static _Storage;
969
1025
  static _Metadata;
970
1026
  _adoptIds(value) {
971
1027
  $.utils.adopt(value, $.utils.getPointer(0, this));
@@ -985,22 +1041,22 @@ var FileSystem = class _FileSystem extends $.Struct {
985
1041
  set ids(value) {
986
1042
  $.utils.copyFrom(value, $.utils.getPointer(0, this));
987
1043
  }
988
- _adoptFiles(value) {
1044
+ _adoptStorage(value) {
989
1045
  $.utils.adopt(value, $.utils.getPointer(1, this));
990
1046
  }
991
- _disownFiles() {
992
- return $.utils.disown(this.files);
1047
+ _disownStorage() {
1048
+ return $.utils.disown(this.storage);
993
1049
  }
994
- get files() {
995
- return $.utils.getList(1, _FileSystem._Files, this);
1050
+ get storage() {
1051
+ return $.utils.getList(1, _FileSystem._Storage, this);
996
1052
  }
997
- _hasFiles() {
1053
+ _hasStorage() {
998
1054
  return !$.utils.isNull($.utils.getPointer(1, this));
999
1055
  }
1000
- _initFiles(length) {
1001
- return $.utils.initList(1, _FileSystem._Files, length, this);
1056
+ _initStorage(length) {
1057
+ return $.utils.initList(1, _FileSystem._Storage, length, this);
1002
1058
  }
1003
- set files(value) {
1059
+ set storage(value) {
1004
1060
  $.utils.copyFrom(value, $.utils.getPointer(1, this));
1005
1061
  }
1006
1062
  _adoptMetadata(value) {
@@ -1027,7 +1083,7 @@ var FileSystem = class _FileSystem extends $.Struct {
1027
1083
  };
1028
1084
  FileMetadata._Properties = $.CompositeList(FileMetadata_KeyValuePair);
1029
1085
  FileSystem._Ids = $.CompositeList(FileId);
1030
- FileSystem._Files = $.CompositeList(FileData);
1086
+ FileSystem._Storage = $.CompositeList(FileStorage);
1031
1087
  FileSystem._Metadata = $.CompositeList(FileMetadata);
1032
1088
  var createLog = /* @__PURE__ */ __name((name, options = {}) => {
1033
1089
  const logLevel = options.logLevel === null ? LogLevelLabel.SILENT : options.logLevel || LogLevelLabel.INFO;
@@ -1067,142 +1123,18 @@ var BADGE_COLORS = [
1067
1123
  var extendLog = /* @__PURE__ */ __name((logFn, name) => {
1068
1124
  return (type, ...args) => logFn(type, ` ${chalk5.inverse.hex(BADGE_COLORS[name.split("").map((char) => char.charCodeAt(0)).reduce((ret, charCode) => ret + charCode, 0) % BADGE_COLORS.length] || BADGE_COLORS[0])(` ${titleCase(name)} `)} ${args.join(" ")} `);
1069
1125
  }, "extendLog");
1070
- function isBufferEncoding(options) {
1071
- return isSetString(options) || options === null;
1072
- }
1073
- __name(isBufferEncoding, "isBufferEncoding");
1074
- function isPowerlinesWriteFileOptions(options) {
1075
- return !isBufferEncoding(options) && isSetObject(options) && "mode" in options && (options.mode === "fs" || options.mode === "virtual");
1126
+ function isFileError(err) {
1127
+ return isError(err) && "code" in err && err.code;
1076
1128
  }
1077
- __name(isPowerlinesWriteFileOptions, "isPowerlinesWriteFileOptions");
1078
- function isVirtualFileData(obj) {
1079
- return !!(isSetObject(obj) && "code" in obj && obj.code);
1129
+ __name(isFileError, "isFileError");
1130
+ function ignoreNotfound(err) {
1131
+ return isFileError(err) && (err.code === "ENOENT" || err.code === "EISDIR" ? null : err);
1080
1132
  }
1081
- __name(isVirtualFileData, "isVirtualFileData");
1133
+ __name(ignoreNotfound, "ignoreNotfound");
1082
1134
  function toFilePath(path) {
1083
1135
  return correctPath(slash(path?.toString() || ".").replace(/^file:\/\//, ""));
1084
1136
  }
1085
1137
  __name(toFilePath, "toFilePath");
1086
- var FS_METHODS = [
1087
- "mkdir",
1088
- "mkdirSync",
1089
- "rmdir",
1090
- "rmdirSync",
1091
- "unlink",
1092
- "unlinkSync",
1093
- "existsSync",
1094
- "realpathSync",
1095
- "writeFileSync",
1096
- "readFileSync",
1097
- "readdirSync",
1098
- "createWriteStream",
1099
- "WriteStream",
1100
- "createReadStream",
1101
- "ReadStream"
1102
- ];
1103
- var FS_PROMISE_METHODS = [
1104
- "mkdir",
1105
- "rm",
1106
- "rmdir",
1107
- "unlink",
1108
- "writeFile",
1109
- "readFile",
1110
- "readdir",
1111
- "stat",
1112
- "lstat"
1113
- ];
1114
- function cloneFS(originalFS) {
1115
- const clonedFS = {
1116
- ...originalFS,
1117
- promises: {
1118
- ...originalFS.promises ?? {}
1119
- }
1120
- };
1121
- for (const method of FS_METHODS) {
1122
- if (originalFS[method]) {
1123
- clonedFS[method] = originalFS[method];
1124
- }
1125
- }
1126
- originalFS.promises ??= {};
1127
- for (const method of FS_PROMISE_METHODS) {
1128
- if (originalFS.promises[method]) {
1129
- clonedFS.promises ??= {};
1130
- clonedFS.promises[method] = originalFS.promises[method];
1131
- clonedFS[method] = originalFS.promises[method];
1132
- }
1133
- }
1134
- for (const prop in clonedFS) {
1135
- if (isFunction(clonedFS[prop])) {
1136
- clonedFS[prop] = clonedFS[prop].bind(originalFS);
1137
- if (isFunction(clonedFS.promises[prop])) {
1138
- clonedFS.promises[prop] = clonedFS.promises[prop].bind(originalFS);
1139
- }
1140
- }
1141
- }
1142
- for (const prop in clonedFS.promises) {
1143
- if (isFunction(clonedFS.promises[prop])) {
1144
- clonedFS.promises[prop] = clonedFS.promises[prop].bind(originalFS);
1145
- }
1146
- }
1147
- return clonedFS;
1148
- }
1149
- __name(cloneFS, "cloneFS");
1150
- function patchFS(originalFS, vfs) {
1151
- const clonedFS = cloneFS(originalFS);
1152
- originalFS.mkdirSync = (file, options) => vfs.mkdirSync(toFilePath(file), options);
1153
- originalFS.mkdir = (file, options, callback) => vfs.mkdir(toFilePath(file), options, callback);
1154
- originalFS.promises.mkdir = async (file, options) => vfs.mkdir(toFilePath(file), options);
1155
- originalFS.unlinkSync = (file) => vfs.unlinkSync(toFilePath(file));
1156
- originalFS.promises.rm = async (file, options) => vfs.rm(toFilePath(file), options);
1157
- originalFS.promises.unlink = async (file) => vfs.unlink(toFilePath(file));
1158
- originalFS.existsSync = (file) => vfs.existsSync(toFilePath(file));
1159
- Object.defineProperty(originalFS, "realpathSync", {
1160
- value: /* @__PURE__ */ __name((file, options) => vfs.realpathSync(toFilePath(file), options), "value")
1161
- });
1162
- originalFS.writeFileSync = (file, data, options) => vfs.writeFileSync(toFilePath(file), data, options);
1163
- originalFS.promises.writeFile = async (file, data, options) => vfs.writeFile(toFilePath(file), data, options);
1164
- originalFS.readFileSync = (file, options) => vfs.readFileSync(toFilePath(file), options);
1165
- originalFS.promises.readFile = (file, options) => vfs.readFile(toFilePath(file), options);
1166
- originalFS.readdirSync = (file, options) => vfs.readdirSync(toFilePath(file), options);
1167
- originalFS.promises.readdir = (file, options) => vfs.readdir(toFilePath(file), options);
1168
- Object.defineProperty(originalFS, "statSync", {
1169
- value: /* @__PURE__ */ __name((file, options) => vfs.statSync(toFilePath(file), options), "value")
1170
- });
1171
- originalFS.stat = (file, options) => vfs.statSync(toFilePath(file), options);
1172
- originalFS.promises.stat = (file, options) => vfs.stat(toFilePath(file), options);
1173
- Object.defineProperty(originalFS, "lstatSync", {
1174
- value: /* @__PURE__ */ __name((file, options) => vfs.lstatSync(toFilePath(file), options), "value")
1175
- });
1176
- originalFS.lstat = (file, options) => vfs.lstatSync(toFilePath(file), options);
1177
- originalFS.promises.lstat = (file, options) => vfs.lstat(toFilePath(file), options);
1178
- return () => {
1179
- originalFS.mkdirSync = clonedFS.mkdirSync;
1180
- originalFS.mkdir = clonedFS.mkdir;
1181
- originalFS.promises.mkdir = clonedFS.promises.mkdir;
1182
- originalFS.unlinkSync = clonedFS.unlinkSync;
1183
- originalFS.promises.rm = clonedFS.promises.rm;
1184
- originalFS.promises.unlink = clonedFS.promises.unlink;
1185
- originalFS.existsSync = clonedFS.existsSync;
1186
- originalFS.realpathSync = clonedFS.realpathSync;
1187
- originalFS.writeFileSync = clonedFS.writeFileSync;
1188
- originalFS.promises.writeFile = clonedFS.promises.writeFile;
1189
- originalFS.readFileSync = clonedFS.readFileSync;
1190
- originalFS.promises.readFile = clonedFS.promises.readFile;
1191
- originalFS.readdirSync = clonedFS.readdirSync;
1192
- originalFS.promises.readdir = clonedFS.promises.readdir;
1193
- Object.defineProperty(originalFS, "statSync", {
1194
- value: clonedFS.statSync
1195
- });
1196
- originalFS.stat = clonedFS.stat;
1197
- originalFS.promises.stat = clonedFS.promises.stat;
1198
- Object.defineProperty(originalFS, "lstatSync", {
1199
- value: clonedFS.lstatSync
1200
- });
1201
- originalFS.lstat = clonedFS.lstat;
1202
- originalFS.promises.lstat = clonedFS.promises.lstat;
1203
- };
1204
- }
1205
- __name(patchFS, "patchFS");
1206
1138
  function isValidId(id, prefix = "powerlines") {
1207
1139
  return id.replace(/^\\0/, "").startsWith(`${prefix.replace(/:$/, "")}`);
1208
1140
  }
@@ -1212,164 +1144,368 @@ function normalizeId(id, prefix = "powerlines") {
1212
1144
  }
1213
1145
  __name(normalizeId, "normalizeId");
1214
1146
  function normalizePath(path, builtinsPath, prefix = "powerlines") {
1215
- return isValidId(toFilePath(path), prefix) ? normalizeId(toFilePath(path), prefix).replace(new RegExp(`^${prefix.replace(/:$/, "")}:`), builtinsPath) : toFilePath(path);
1147
+ return isAbsolutePath(path) ? path : isValidId(toFilePath(path), prefix) ? normalizeId(toFilePath(path), prefix).replace(new RegExp(`^${prefix.replace(/:$/, "")}:`), builtinsPath) : toFilePath(path);
1216
1148
  }
1217
1149
  __name(normalizePath, "normalizePath");
1218
- var UnifiedFS = class _UnifiedFS extends Union {
1150
+ function normalizeKey(key, sep = ":") {
1151
+ if (!key) {
1152
+ return "";
1153
+ }
1154
+ return key.replace(/[:/\\]/g, sep).replace(/^[:/\\]|[:/\\]$/g, "");
1155
+ }
1156
+ __name(normalizeKey, "normalizeKey");
1157
+ function filterKeyByBase(key, base) {
1158
+ if (base) {
1159
+ return key.startsWith(base) && key[key.length - 1] !== "$";
1160
+ }
1161
+ return key[key.length - 1] !== "$";
1162
+ }
1163
+ __name(filterKeyByBase, "filterKeyByBase");
1164
+ var BaseStorageAdapter = class {
1219
1165
  static {
1220
- __name(this, "UnifiedFS");
1166
+ __name(this, "BaseStorageAdapter");
1221
1167
  }
1222
1168
  /**
1223
- * The internal map of virtual files.
1169
+ * Indicates whether the storage adapter has been disposed.
1224
1170
  */
1225
- #virtualFS = new Volume();
1171
+ #isDisposed = false;
1226
1172
  /**
1227
- * The physical file system.
1173
+ * Configuration options for the storage adapter.
1228
1174
  */
1229
- #physicalFS = cloneFS(_fs);
1175
+ options;
1230
1176
  /**
1231
- * The context of the unified file system.
1177
+ * Constructor for the BaseStorageAdapter.
1178
+ *
1179
+ * @param options - Configuration options for the storage adapter.
1232
1180
  */
1233
- #context;
1234
- static create(context, fs2) {
1235
- let result = new _UnifiedFS(context, fs2);
1236
- result = result.use(result.#physicalFS);
1237
- if (result.#context.config.output.mode !== "fs") {
1238
- result = result.use(result.#virtualFS);
1239
- }
1240
- return result;
1181
+ constructor(options = {
1182
+ base: "/"
1183
+ }) {
1184
+ this.options = options;
1185
+ this.options.base = resolve(options.base);
1186
+ this.options.isReadOnly = !!options.isReadOnly;
1241
1187
  }
1242
1188
  /**
1243
- * Gets the virtual file system (VFS).
1189
+ * Asynchronously checks if a key exists in the storage.
1190
+ *
1191
+ * @param key - The key to check for existence.
1192
+ * @returns A promise that resolves to `true` if the key exists, otherwise `false`.
1244
1193
  */
1245
- get virtual() {
1246
- return this.#virtualFS;
1194
+ async exists(key) {
1195
+ return this.existsSync(key);
1247
1196
  }
1248
1197
  /**
1249
- * Gets the physical file system (FS).
1198
+ * Asynchronously retrieves the value associated with a given key.
1199
+ *
1200
+ * @param key - The key whose value is to be retrieved.
1201
+ * @returns A promise that resolves to the value associated with the key, or `null` if the key does not exist.
1250
1202
  */
1251
- get physical() {
1252
- return this.#physicalFS;
1203
+ async get(key) {
1204
+ return this.getSync(key);
1253
1205
  }
1254
1206
  /**
1255
- * Creates a new instance of the VirtualFileSystem.
1207
+ * Asynchronously sets the value for a given key.
1256
1208
  *
1257
- * @param context - The context of the virtual file system, typically containing options and logging functions.
1258
- * @param fs - A buffer containing the serialized virtual file system data.
1209
+ * @param key - The key to set the value for.
1210
+ * @param value - The value to set.
1259
1211
  */
1260
- constructor(context, fs2) {
1261
- super();
1262
- this.#context = context;
1263
- if (!this.#physicalFS.existsSync(this.#context.dataPath)) {
1264
- this.#physicalFS.mkdirSync(this.#context.dataPath, {
1265
- recursive: true
1266
- });
1212
+ async set(key, value) {
1213
+ if (!this.options.isReadOnly) {
1214
+ this.setSync(key, value);
1267
1215
  }
1268
- if (!this.#physicalFS.existsSync(this.#context.cachePath)) {
1269
- this.#physicalFS.mkdirSync(this.#context.cachePath, {
1270
- recursive: true
1271
- });
1272
- }
1273
- if (!this.#physicalFS.existsSync(joinPaths(this.#context.workspaceConfig.workspaceRoot, this.#context.config.output.distPath))) {
1274
- this.#physicalFS.mkdirSync(joinPaths(this.#context.workspaceConfig.workspaceRoot, this.#context.config.output.distPath), {
1275
- recursive: true
1276
- });
1216
+ }
1217
+ /**
1218
+ * Asynchronously removes a key from the storage.
1219
+ *
1220
+ * @param key - The key to remove.
1221
+ */
1222
+ async remove(key) {
1223
+ if (!this.options.isReadOnly) {
1224
+ this.removeSync(key);
1277
1225
  }
1278
- if (this.#context.config.output.mode !== "fs") {
1279
- this.#virtualFS = Volume.fromJSON(fs2._hasFiles() && fs2.files.length > 0 ? fs2.files.values().reduce((ret, file) => {
1280
- ret[file.path] = file.code;
1281
- return ret;
1282
- }, {}) : {});
1283
- if (!this.#virtualFS.existsSync(this.#context.artifactsPath)) {
1284
- this.#virtualFS.mkdirSync(this.#context.artifactsPath, {
1285
- recursive: true
1286
- });
1287
- }
1288
- if (!this.#virtualFS.existsSync(this.#context.builtinsPath)) {
1289
- this.#virtualFS.mkdirSync(this.#context.builtinsPath, {
1290
- recursive: true
1291
- });
1292
- }
1293
- if (!this.#virtualFS.existsSync(this.#context.entryPath)) {
1294
- this.#virtualFS.mkdirSync(this.#context.entryPath, {
1295
- recursive: true
1296
- });
1297
- }
1298
- if (!this.#virtualFS.existsSync(this.#context.dtsPath)) {
1299
- this.#virtualFS.mkdirSync(this.#context.dtsPath, {
1300
- recursive: true
1301
- });
1302
- }
1303
- } else if (this.#context.config.projectType === "application") {
1304
- if (!this.#physicalFS.existsSync(this.#context.artifactsPath)) {
1305
- this.#physicalFS.mkdirSync(this.#context.artifactsPath, {
1306
- recursive: true
1307
- });
1308
- }
1309
- if (!this.#physicalFS.existsSync(this.#context.builtinsPath)) {
1310
- this.#physicalFS.mkdirSync(this.#context.builtinsPath, {
1311
- recursive: true
1312
- });
1226
+ }
1227
+ /**
1228
+ * Synchronously removes all entries from the storage that match the provided base path.
1229
+ *
1230
+ * @param base - The base path to clear keys from.
1231
+ */
1232
+ clearSync(base) {
1233
+ if (!this.options.isReadOnly) {
1234
+ const keys = this.listSync(base || this.options.base);
1235
+ if (!keys.length) {
1236
+ return;
1313
1237
  }
1314
- if (!this.#physicalFS.existsSync(this.#context.entryPath)) {
1315
- this.#physicalFS.mkdirSync(this.#context.entryPath, {
1316
- recursive: true
1317
- });
1238
+ keys.map((key) => this.removeSync(base && !key.startsWith(base) ? joinPaths(base, key) : key));
1239
+ }
1240
+ }
1241
+ /**
1242
+ * Asynchronously removes all entries from the storage that match the provided base path.
1243
+ *
1244
+ * @param base - The base path to clear keys from.
1245
+ * @returns A promise that resolves when the operation is complete.
1246
+ */
1247
+ async clear(base) {
1248
+ if (!this.options.isReadOnly) {
1249
+ const keys = await this.list(base || this.options.base);
1250
+ if (!keys.length) {
1251
+ return;
1318
1252
  }
1319
- if (!this.#physicalFS.existsSync(this.#context.dtsPath)) {
1320
- this.#physicalFS.mkdirSync(this.#context.dtsPath, {
1321
- recursive: true
1322
- });
1253
+ await Promise.all(keys.map(async (key) => this.remove(base && !key.startsWith(base) ? joinPaths(base, key) : key)));
1254
+ }
1255
+ }
1256
+ /**
1257
+ * Asynchronously lists all keys under a given base path.
1258
+ *
1259
+ * @param base - The base path to list keys from.
1260
+ * @returns A promise that resolves to an array of keys under the specified base path.
1261
+ */
1262
+ async list(base) {
1263
+ return this.listSync(base);
1264
+ }
1265
+ /**
1266
+ * Disposes of the storage adapter, releasing any held resources.
1267
+ *
1268
+ * @returns A promise that resolves when the disposal is complete.
1269
+ */
1270
+ dispose() {
1271
+ return Promise.resolve();
1272
+ }
1273
+ /**
1274
+ * Async dispose method to clean up resources.
1275
+ *
1276
+ * @returns A promise that resolves when disposal is complete.
1277
+ */
1278
+ async [Symbol.asyncDispose]() {
1279
+ return this._dispose();
1280
+ }
1281
+ /**
1282
+ * Resolves a given key to its full path within the storage adapter.
1283
+ *
1284
+ * @param key - The key to resolve.
1285
+ * @returns The resolved full path for the key.
1286
+ */
1287
+ resolve(key = this.options.base) {
1288
+ if (/\.\.:|\.\.$/.test(key)) {
1289
+ throw new Error(`[${this.name}]: Invalid key: ${JSON.stringify(key)} provided to storage adapter.`);
1290
+ }
1291
+ return appendPath(correctPath(key).replace(/:/g, "/"), this.options.base);
1292
+ }
1293
+ /**
1294
+ * Disposes of the storage adapter, releasing any held resources.
1295
+ *
1296
+ * @returns A promise that resolves when the disposal is complete.
1297
+ */
1298
+ async _dispose() {
1299
+ if (!this.#isDisposed) {
1300
+ await Promise.resolve(this.dispose());
1301
+ this.#isDisposed = true;
1302
+ }
1303
+ }
1304
+ };
1305
+
1306
+ // src/lib/fs/storage/file-system.ts
1307
+ var FileSystemStorageAdapter = class extends BaseStorageAdapter {
1308
+ static {
1309
+ __name(this, "FileSystemStorageAdapter");
1310
+ }
1311
+ /**
1312
+ * A name identifying the storage adapter type.
1313
+ */
1314
+ name = "file-system";
1315
+ /**
1316
+ * Constructor for the FileSystemStorageAdapter.
1317
+ *
1318
+ * @param options - Configuration options for the storage adapter.
1319
+ */
1320
+ constructor(options) {
1321
+ super(options);
1322
+ }
1323
+ /**
1324
+ * Synchronously checks if a key exists in the storage.
1325
+ *
1326
+ * @param key - The key to check for existence.
1327
+ * @returns Returns `true` if the key exists, otherwise `false`.
1328
+ */
1329
+ existsSync(key) {
1330
+ return existsSync(this.resolve(key));
1331
+ }
1332
+ /**
1333
+ * Asynchronously checks if a key exists in the storage.
1334
+ *
1335
+ * @param key - The key to check for existence.
1336
+ * @returns A promise that resolves to `true` if the key exists, otherwise `false`.
1337
+ */
1338
+ async exists(key) {
1339
+ return exists(this.resolve(key));
1340
+ }
1341
+ /**
1342
+ * Synchronously retrieves the value associated with a given key.
1343
+ *
1344
+ * @param key - The key whose value is to be retrieved.
1345
+ * @returns The value associated with the key, or `null` if the key does not exist.
1346
+ */
1347
+ getSync(key) {
1348
+ return readFileSync(this.resolve(key));
1349
+ }
1350
+ /**
1351
+ * Asynchronously retrieves the value associated with a given key.
1352
+ *
1353
+ * @param key - The key whose value is to be retrieved.
1354
+ * @returns A promise that resolves to the value associated with the key, or `null` if the key does not exist.
1355
+ */
1356
+ async get(key) {
1357
+ return readFile(this.resolve(key));
1358
+ }
1359
+ /**
1360
+ * Synchronously sets the value for a given key.
1361
+ *
1362
+ * @param key - The key to set the value for.
1363
+ * @param value - The value to set.
1364
+ */
1365
+ setSync(key, value) {
1366
+ if (!this.options.isReadOnly) {
1367
+ return writeFileSync(this.resolve(key), value);
1368
+ }
1369
+ }
1370
+ /**
1371
+ * Asynchronously sets the value for a given key.
1372
+ *
1373
+ * @param key - The key to set the value for.
1374
+ * @param value - The value to set.
1375
+ */
1376
+ async set(key, value) {
1377
+ if (!this.options.isReadOnly) {
1378
+ return writeFile$1(this.resolve(key), value);
1379
+ }
1380
+ }
1381
+ /**
1382
+ * Synchronously removes a key from the storage.
1383
+ *
1384
+ * @param key - The key to remove.
1385
+ */
1386
+ removeSync(key) {
1387
+ if (!this.options.isReadOnly) {
1388
+ try {
1389
+ return unlinkSync(this.resolve(key));
1390
+ } catch (err) {
1391
+ return ignoreNotfound(err);
1323
1392
  }
1324
1393
  }
1325
1394
  }
1326
1395
  /**
1327
- * Select the file system module to use for the operation based on the path or URL.
1396
+ * Asynchronously removes a key from the storage.
1328
1397
  *
1329
- * @param pathOrUrl - The path to perform the file system operation on.
1330
- * @param options - Options for the operation, such as output mode.
1331
- * @returns The file system module used for the operation.
1398
+ * @param key - The key to remove.
1332
1399
  */
1333
- resolveFS(pathOrUrl, options = {}) {
1334
- const mode = this.resolveMode(pathOrUrl, options);
1335
- if (mode === "virtual") {
1336
- return {
1337
- ...this.#virtualFS,
1338
- mode: "virtual"
1339
- };
1340
- } else if (mode === "fs") {
1341
- return {
1342
- ...this.#physicalFS,
1343
- mode: "fs"
1344
- };
1400
+ async remove(key) {
1401
+ if (!this.options.isReadOnly) {
1402
+ return unlink(this.resolve(key)).catch(ignoreNotfound);
1345
1403
  }
1346
- return {
1347
- ...this,
1348
- mode: this.#context.config.output.mode
1349
- };
1350
1404
  }
1351
1405
  /**
1352
- * Select the file system module to use for the operation based on the path or URL.
1406
+ * Lists all keys under a given base path synchronously.
1353
1407
  *
1354
- * @param pathOrUrl - The path to perform the file system operation on.
1355
- * @param options - Options for the operation, such as output mode.
1356
- * @returns The file system module used for the operation.
1408
+ * @param base - The base path to list keys from.
1409
+ * @returns An array of keys under the specified base path.
1357
1410
  */
1358
- resolveMode(pathOrUrl, options = {}) {
1359
- if (options.mode === "virtual" && this.#context.config.output.mode !== "fs" && isParentPath(toFilePath(pathOrUrl), this.#context.artifactsPath)) {
1360
- return "virtual";
1361
- } else if (options.mode === "fs" || this.#context.config.output.mode === "fs" || isParentPath(toFilePath(pathOrUrl), this.#context.dataPath) || isParentPath(toFilePath(pathOrUrl), this.#context.cachePath) || isParentPath(toFilePath(pathOrUrl), joinPaths(this.#context.workspaceConfig.workspaceRoot, this.#context.config.output.distPath))) {
1362
- return "fs";
1411
+ listSync(base) {
1412
+ try {
1413
+ return listFilesSync(this.resolve(base), {
1414
+ ignore: this.options.ignore
1415
+ });
1416
+ } catch (err) {
1417
+ return ignoreNotfound(err) ?? [];
1363
1418
  }
1364
- return void 0;
1365
1419
  }
1366
1420
  /**
1367
- * Serializes the virtual file system (VFS) to a JSON object.
1421
+ * Asynchronously lists all keys under a given base path.
1368
1422
  *
1369
- * @returns A JSON representation of the virtual file system.
1423
+ * @param base - The base path to list keys from.
1424
+ * @returns A promise that resolves to an array of keys under the specified base path.
1370
1425
  */
1371
- toJSON() {
1372
- return this.#virtualFS.toJSON();
1426
+ async list(base) {
1427
+ return listFiles(this.resolve(base), {
1428
+ ignore: this.options.ignore
1429
+ }).catch(ignoreNotfound).then((r) => r || []);
1430
+ }
1431
+ };
1432
+ var VirtualStorageAdapter = class extends BaseStorageAdapter {
1433
+ static {
1434
+ __name(this, "VirtualStorageAdapter");
1435
+ }
1436
+ /**
1437
+ * A name identifying the storage adapter type.
1438
+ */
1439
+ name = "virtual";
1440
+ /**
1441
+ * In-memory data storage.
1442
+ */
1443
+ data = /* @__PURE__ */ new Map();
1444
+ /**
1445
+ * Constructor for the VirtualStorageAdapter.
1446
+ *
1447
+ * @param options - Configuration options for the storage adapter.
1448
+ */
1449
+ constructor(options) {
1450
+ super(options);
1451
+ }
1452
+ /**
1453
+ * Synchronously checks if a key exists in the storage.
1454
+ *
1455
+ * @param key - The key to check for existence.
1456
+ * @returns Returns `true` if the key exists, otherwise `false`.
1457
+ */
1458
+ existsSync(key) {
1459
+ return this.data.has(this.resolve(key));
1460
+ }
1461
+ /**
1462
+ * Synchronously retrieves the value associated with a given key.
1463
+ *
1464
+ * @param key - The key whose value is to be retrieved.
1465
+ * @returns The value associated with the key, or `null` if the key does not exist.
1466
+ */
1467
+ getSync(key) {
1468
+ return this.data.get(this.resolve(key)) ?? null;
1469
+ }
1470
+ /**
1471
+ * Synchronously sets the value for a given key.
1472
+ *
1473
+ * @param key - The key to set the value for.
1474
+ * @param value - The value to set.
1475
+ */
1476
+ setSync(key, value) {
1477
+ if (!this.options.isReadOnly) {
1478
+ this.data.set(this.resolve(key), value);
1479
+ }
1480
+ }
1481
+ /**
1482
+ * Synchronously removes a key from the storage.
1483
+ *
1484
+ * @param key - The key to remove.
1485
+ */
1486
+ removeSync(key) {
1487
+ if (!this.options.isReadOnly) {
1488
+ this.data.delete(this.resolve(key));
1489
+ }
1490
+ }
1491
+ /**
1492
+ * Lists all keys under a given base path synchronously.
1493
+ *
1494
+ * @param base - The base path to list keys from.
1495
+ * @returns An array of keys under the specified base path.
1496
+ */
1497
+ listSync(base) {
1498
+ return [
1499
+ ...this.data.keys().filter((key) => !base ? true : isParentPath(key, this.resolve(base)))
1500
+ ];
1501
+ }
1502
+ /**
1503
+ * Disposes of the storage adapter, releasing any held resources.
1504
+ *
1505
+ * @returns A promise that resolves when the disposal is complete.
1506
+ */
1507
+ async dispose() {
1508
+ return this.clear();
1373
1509
  }
1374
1510
  };
1375
1511
 
@@ -1391,29 +1527,23 @@ var VirtualFileSystem = class _VirtualFileSystem {
1391
1527
  */
1392
1528
  #paths;
1393
1529
  /**
1394
- * A cache for module resolution results.
1395
- */
1396
- #resolverCache;
1397
- /**
1398
1530
  * The unified volume that combines the virtual file system with the real file system.
1399
1531
  *
1400
1532
  * @remarks
1401
1533
  * This volume allows for seamless access to both virtual and real files.
1402
1534
  */
1403
- #unifiedFS;
1535
+ #storage = {
1536
+ "": new FileSystemStorageAdapter()
1537
+ };
1404
1538
  /**
1405
- * Indicator specifying if the file system module is patched
1539
+ * A cache for module resolution results.
1406
1540
  */
1407
- #isPatched = false;
1541
+ #resolverCache;
1408
1542
  /**
1409
1543
  * Indicator specifying if the virtual file system (VFS) is disposed
1410
1544
  */
1411
1545
  #isDisposed = false;
1412
1546
  /**
1413
- * Function to revert require patch
1414
- */
1415
- #revert;
1416
- /**
1417
1547
  * The context of the virtual file system.
1418
1548
  */
1419
1549
  #context;
@@ -1422,15 +1552,6 @@ var VirtualFileSystem = class _VirtualFileSystem {
1422
1552
  */
1423
1553
  #log;
1424
1554
  /**
1425
- * Checks if a path exists in the virtual file system (VFS).
1426
- *
1427
- * @param path - The path to check.
1428
- * @returns `true` if the path exists, otherwise `false`.
1429
- */
1430
- #existsSync(path) {
1431
- return this.#unifiedFS.virtual.existsSync(this.#normalizePath(path)) || this.#unifiedFS.physical.existsSync(this.#normalizePath(path)) || this.#unifiedFS.resolveFS(path).existsSync(this.#normalizePath(path));
1432
- }
1433
- /**
1434
1555
  * Normalizes a given module id by resolving it against the built-ins path.
1435
1556
  *
1436
1557
  * @param id - The module id to normalize.
@@ -1459,6 +1580,43 @@ var VirtualFileSystem = class _VirtualFileSystem {
1459
1580
  return new RegExp(`^${this.#normalizePath(path).replace(/\*\*/g, token).replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*/g, "[^/]*").replace(/\?/g, "[^/]").replace(new RegExp(token, "g"), ".*")}$`);
1460
1581
  }
1461
1582
  /**
1583
+ * Gets the storage adapter and relative key for a given key.
1584
+ *
1585
+ * @param key - The key to get the storage adapter for.
1586
+ * @returns The storage adapter and relative key for the given key.
1587
+ */
1588
+ #getStorage(key) {
1589
+ const path = this.resolveSync(this.#normalizePath(key)) || key;
1590
+ for (const base of Object.keys(this.#storage).filter(Boolean).sort().reverse()) {
1591
+ if (isParentPath(path, base)) {
1592
+ return {
1593
+ base,
1594
+ relativeKey: replacePath(path, base),
1595
+ adapter: this.#storage[base]
1596
+ };
1597
+ }
1598
+ }
1599
+ return {
1600
+ base: "",
1601
+ relativeKey: path,
1602
+ adapter: this.#storage[""]
1603
+ };
1604
+ }
1605
+ /**
1606
+ * Gets all storage adapters that match a given base key.
1607
+ *
1608
+ * @param base - The base key to match storage adapters against.
1609
+ * @param includeParent - Whether to include parent storage adapters.
1610
+ * @returns An array of storage adapters that match the given base key.
1611
+ */
1612
+ #getStorages(base = "", includeParent = false) {
1613
+ return Object.keys(this.#storage).sort().reverse().filter((key) => isParentPath(key, base) || includeParent && isParentPath(base, key)).map((key) => ({
1614
+ relativeBase: base.length > key.length ? base.slice(key.length) : void 0,
1615
+ base: key,
1616
+ adapter: this.#storage[key]
1617
+ }));
1618
+ }
1619
+ /**
1462
1620
  * Creates a virtual file system (VFS) that is backed up to a Cap'n Proto message buffer.
1463
1621
  *
1464
1622
  * @param context - The context of the virtual file system, typically containing options and logging functions.
@@ -1468,7 +1626,13 @@ var VirtualFileSystem = class _VirtualFileSystem {
1468
1626
  if (!context.config.skipCache && existsSync(joinPaths$1(context.dataPath, "fs.bin"))) {
1469
1627
  const buffer = await readFileBuffer(joinPaths$1(context.dataPath, "fs.bin"));
1470
1628
  const message2 = new $.Message(buffer, false);
1471
- return new _VirtualFileSystem(context, message2.getRoot(FileSystem));
1629
+ const fs = message2.getRoot(FileSystem);
1630
+ const result = new _VirtualFileSystem(context, fs);
1631
+ if (fs._hasStorage() && fs.storage.length > 0) {
1632
+ await Promise.all(fs.storage.values().map(async (file) => {
1633
+ await result.write(file.path, file.code);
1634
+ }));
1635
+ }
1472
1636
  }
1473
1637
  const message = new $.Message();
1474
1638
  return new _VirtualFileSystem(context, message.initRoot(FileSystem));
@@ -1483,7 +1647,13 @@ var VirtualFileSystem = class _VirtualFileSystem {
1483
1647
  if (!context.config.skipCache && existsSync(joinPaths$1(context.dataPath, "fs.bin"))) {
1484
1648
  const buffer = readFileBufferSync(joinPaths$1(context.dataPath, "fs.bin"));
1485
1649
  const message2 = new $.Message(buffer, false);
1486
- return new _VirtualFileSystem(context, message2.getRoot(FileSystem));
1650
+ const fs = message2.getRoot(FileSystem);
1651
+ const result = new _VirtualFileSystem(context, fs);
1652
+ if (fs._hasStorage() && fs.storage.length > 0) {
1653
+ fs.storage.values().map((file) => {
1654
+ result.writeSync(file.path, file.code);
1655
+ });
1656
+ }
1487
1657
  }
1488
1658
  const message = new $.Message();
1489
1659
  return new _VirtualFileSystem(context, message.initRoot(FileSystem));
@@ -1518,6 +1688,9 @@ var VirtualFileSystem = class _VirtualFileSystem {
1518
1688
  }, "get")
1519
1689
  });
1520
1690
  }
1691
+ /**
1692
+ * Gets the resolver cache.
1693
+ */
1521
1694
  get resolverCache() {
1522
1695
  if (!this.#resolverCache) {
1523
1696
  this.#resolverCache = create({
@@ -1536,16 +1709,34 @@ var VirtualFileSystem = class _VirtualFileSystem {
1536
1709
  * @param context - The context of the virtual file system, typically containing options and logging functions.
1537
1710
  * @param fs - A buffer containing the serialized virtual file system data.
1538
1711
  */
1539
- constructor(context, fs2) {
1712
+ constructor(context, fs) {
1540
1713
  this.#context = context;
1541
- this.#unifiedFS = UnifiedFS.create(context, fs2);
1714
+ if (isSetObject(this.#context.config.output.storage)) {
1715
+ this.#storage = {
1716
+ ...this.#storage,
1717
+ ...this.#context.config.output.storage
1718
+ };
1719
+ }
1720
+ this.#storage.virtual ??= new VirtualStorageAdapter({
1721
+ base: "/_virtual"
1722
+ });
1723
+ if (this.#context.config.output.storage !== StoragePreset.FS) {
1724
+ this.#storage[this.#context.artifactsPath] ??= new VirtualStorageAdapter({
1725
+ base: this.#context.artifactsPath
1726
+ });
1727
+ this.#storage[this.#context.builtinsPath] ??= new VirtualStorageAdapter({
1728
+ base: this.#context.builtinsPath
1729
+ });
1730
+ this.#storage[this.#context.entryPath] ??= new VirtualStorageAdapter({
1731
+ base: this.#context.entryPath
1732
+ });
1733
+ }
1542
1734
  this.#metadata = {};
1543
- if (fs2._hasMetadata()) {
1544
- this.#metadata = fs2.metadata.values().reduce((ret, metadata) => {
1735
+ if (fs._hasMetadata()) {
1736
+ this.#metadata = fs.metadata.values().reduce((ret, metadata) => {
1545
1737
  ret[metadata.id] = {
1546
1738
  id: metadata.id,
1547
1739
  type: metadata.type,
1548
- mode: metadata.mode,
1549
1740
  timestamp: metadata.timestamp || Date.now(),
1550
1741
  properties: metadata._hasProperties() ? metadata.properties.values().reduce((ret2, item) => {
1551
1742
  ret2[item.key] = item.value;
@@ -1557,12 +1748,12 @@ var VirtualFileSystem = class _VirtualFileSystem {
1557
1748
  }
1558
1749
  this.#ids = {};
1559
1750
  this.#paths = {};
1560
- if (fs2._hasIds()) {
1561
- this.#ids = fs2.ids.values().reduce((ret, identifier) => {
1751
+ if (fs._hasIds()) {
1752
+ this.#ids = fs.ids.values().reduce((ret, identifier) => {
1562
1753
  ret[identifier.path] ??= identifier.id;
1563
1754
  return ret;
1564
1755
  }, {});
1565
- this.#paths = fs2.ids.values().reduce((ret, identifier) => {
1756
+ this.#paths = fs.ids.values().reduce((ret, identifier) => {
1566
1757
  ret[identifier.id] ??= identifier.path;
1567
1758
  return ret;
1568
1759
  }, {});
@@ -1570,187 +1761,123 @@ var VirtualFileSystem = class _VirtualFileSystem {
1570
1761
  this.#log = extendLog(this.#context.log, "file-system");
1571
1762
  }
1572
1763
  /**
1573
- * Check if a path or id corresponds to a virtual file **(does not actually exists on disk)**.
1574
- *
1575
- * @param pathOrId - The path or id to check.
1576
- * @returns Whether the path or id corresponds to a virtual file **(does not actually exists on disk)**.
1577
- */
1578
- isVirtual(pathOrId, importer, options = {}) {
1579
- if (!pathOrId) {
1580
- return false;
1581
- }
1582
- const resolvedPath = this.resolveSync(pathOrId, importer, options);
1583
- if (!resolvedPath) {
1584
- return false;
1585
- }
1586
- return this.metadata[resolvedPath]?.mode === "virtual";
1587
- }
1588
- /**
1589
- * Check if a path or id corresponds to a file written to the file system **(actually exists on disk)**.
1590
- *
1591
- * @param pathOrId - The path or id to check.
1592
- * @returns Whether the path or id corresponds to a file written to the file system **(actually exists on disk)**.
1593
- */
1594
- isPhysical(pathOrId, importer, options = {}) {
1595
- if (!pathOrId) {
1596
- return false;
1597
- }
1598
- const resolvedPath = this.resolveSync(pathOrId, importer, options);
1599
- if (!resolvedPath) {
1600
- return false;
1601
- }
1602
- return this.metadata[resolvedPath]?.mode === "fs";
1603
- }
1604
- /**
1605
- * Lists files in a given path.
1606
- *
1607
- * @param path - The path to list files from.
1608
- * @param options - Options for listing files, such as encoding and recursion.
1609
- * @returns An array of file names in the specified path.
1610
- */
1611
- readdirSync(path, options = "utf8") {
1612
- return this.#unifiedFS.resolveFS(path).readdirSync(toFilePath(path), options);
1613
- }
1614
- /**
1615
- * Removes a file in the virtual file system (VFS).
1764
+ * Asynchronously checks if a file exists in the virtual file system (VFS).
1616
1765
  *
1617
- * @param path - The path to create the directory at.
1766
+ * @param path - The path to the file.
1767
+ * @returns A promise that resolves to `true` if the file exists, otherwise `false`.
1618
1768
  */
1619
- unlinkSync(path, options) {
1620
- if (!this.isFile(this.#normalizePath(path))) {
1621
- return;
1622
- }
1623
- this.#log(LogLevelLabel.TRACE, `Synchronously removing file: ${this.#normalizePath(path)}`);
1624
- this.#unifiedFS.resolveFS(path, options).unlinkSync(this.#normalizePath(path));
1625
- if (this.#ids[this.#normalizePath(path)] && this.#metadata[this.#ids[this.#normalizePath(path)]]) {
1626
- delete this.#metadata[this.#ids[this.#normalizePath(path)]];
1627
- delete this.#ids[this.#normalizePath(path)];
1628
- delete this.#paths[this.#normalizeId(path)];
1629
- this.#resolverCache.delete(this.#normalizePath(path));
1630
- }
1769
+ async exists(path) {
1770
+ const { relativeKey, adapter } = this.#getStorage(path);
1771
+ return adapter.exists(relativeKey);
1631
1772
  }
1632
1773
  /**
1633
- * Removes a file in the virtual file system (VFS).
1634
- *
1635
- * @param path - The path to create the directory at.
1636
- */
1637
- async unlink(path, options) {
1638
- if (!this.isFile(this.#normalizePath(path))) {
1639
- return;
1640
- }
1641
- this.#log(LogLevelLabel.TRACE, `Removing file: ${this.#normalizePath(path)}`);
1642
- if (isFunction(this.#unifiedFS.resolveFS(path, options).promises.unlink)) {
1643
- await this.#unifiedFS.resolveFS(path, options).promises.unlink(this.#normalizePath(path));
1644
- if (this.#ids[this.#normalizePath(path)] && this.#metadata[this.#ids[this.#normalizePath(path)]]) {
1645
- delete this.#metadata[this.#ids[this.#normalizePath(path)]];
1646
- }
1647
- } else {
1648
- this.unlinkSync(this.#normalizePath(path), options);
1649
- }
1650
- }
1651
- /**
1652
- * Removes a directory in the virtual file system (VFS).
1774
+ * Synchronously checks if a file exists in the virtual file system (VFS).
1653
1775
  *
1654
- * @param path - The path to create the directory at.
1655
- * @param options - Options for creating the directory.
1776
+ * @param path - The path to the file.
1777
+ * @returns `true` if the file exists, otherwise `false`.
1656
1778
  */
1657
- rmdirSync(path, options = {}) {
1658
- if (!this.isDirectory(this.#normalizePath(path))) {
1659
- return;
1660
- }
1661
- this.#log(LogLevelLabel.TRACE, `Synchronously removing directory: ${this.#normalizePath(path)}`);
1662
- this.#unifiedFS.resolveFS(path, options).rmdirSync(this.#normalizePath(path), defu6(options, {
1663
- recursive: true
1664
- }));
1779
+ existsSync(path) {
1780
+ const { relativeKey, adapter } = this.#getStorage(path);
1781
+ return adapter.existsSync(relativeKey);
1665
1782
  }
1666
1783
  /**
1667
- * Removes a directory in the virtual file system (VFS).
1784
+ * Checks if a file is virtual in the virtual file system (VFS).
1668
1785
  *
1669
- * @param path - The path to create the directory at.
1670
- * @param options - Options for creating the directory.
1671
- * @returns A promise that resolves to the path of the created directory, or undefined if the directory could not be created.
1786
+ * @param path - The path to the file.
1787
+ * @returns `true` if the file is virtual, otherwise `false`.
1672
1788
  */
1673
- async rmdir(path, options = {}) {
1674
- if (!this.isDirectory(this.#normalizePath(path))) {
1675
- return;
1676
- }
1677
- this.#log(LogLevelLabel.TRACE, `Removing directory: ${this.#normalizePath(path)}`);
1678
- if (isFunction(this.#unifiedFS.resolveFS(path, options).promises.rm)) {
1679
- await this.#unifiedFS.resolveFS(path, options).promises.rm(this.#normalizePath(path), defu6(options, {
1680
- force: true,
1681
- recursive: true
1682
- }));
1683
- } else {
1684
- this.rmdirSync(this.#normalizePath(path), defu6(options ?? {}, {
1685
- force: true,
1686
- recursive: true
1687
- }));
1789
+ isVirtual(path) {
1790
+ const resolved = this.resolveSync(path);
1791
+ if (!resolved) {
1792
+ return false;
1688
1793
  }
1794
+ return this.#getStorage(resolved)?.adapter?.name === "virtual";
1689
1795
  }
1690
1796
  /**
1691
- * Removes a file in the virtual file system (VFS).
1797
+ * Lists files in a given path.
1692
1798
  *
1693
- * @param path - The path to the file to remove.
1694
- * @param options - Options for removing the file.
1695
- * @returns A promise that resolves when the file is removed.
1799
+ * @param path - The path to list files from.
1800
+ * @returns An array of file names in the specified path.
1696
1801
  */
1697
- async rm(path, options = {}) {
1698
- this.#log(LogLevelLabel.TRACE, `Removing: ${this.#normalizePath(path)}`);
1699
- if (this.isDirectory(this.#normalizePath(path))) {
1700
- return this.rmdir(this.#normalizePath(path), options);
1802
+ listSync(path) {
1803
+ let maskedMounts = [];
1804
+ const allKeys = [];
1805
+ for (const storage of this.#getStorages(path, true)) {
1806
+ for (const key of storage.adapter.listSync(storage.relativeBase)) {
1807
+ if (!maskedMounts.some((p) => `${storage.base}${normalizeKey(key)}`.startsWith(p))) {
1808
+ allKeys.push(`${storage.base}${normalizeKey(key)}`);
1809
+ }
1810
+ }
1811
+ maskedMounts = [
1812
+ storage.base,
1813
+ ...maskedMounts.filter((p) => !p.startsWith(storage.base))
1814
+ ];
1701
1815
  }
1702
- return this.unlink(this.#normalizePath(path), options);
1816
+ return allKeys.filter((key) => filterKeyByBase(key, path));
1703
1817
  }
1704
1818
  /**
1705
- * Synchronously removes a file or directory in the virtual file system (VFS).
1819
+ * Lists files in a given path.
1706
1820
  *
1707
- * @param path - The path to the file or directory to remove.
1708
- * @param options - Options for removing the file or directory.
1821
+ * @param path - The path to list files from.
1822
+ * @returns An array of file names in the specified path.
1709
1823
  */
1710
- rmSync(path, options = {}) {
1711
- this.#log(LogLevelLabel.TRACE, `Removing: ${this.#normalizePath(path)}`);
1712
- if (this.isDirectory(this.#normalizePath(path))) {
1713
- return this.rmdirSync(this.#normalizePath(path), options);
1824
+ async list(path) {
1825
+ let maskedMounts = [];
1826
+ const allKeys = [];
1827
+ for (const storage of this.#getStorages(path, true)) {
1828
+ for (const key of await storage.adapter.list(storage.relativeBase)) {
1829
+ if (!maskedMounts.some((p) => `${storage.base}${normalizeKey(key)}`.startsWith(p))) {
1830
+ allKeys.push(`${storage.base}${normalizeKey(key)}`);
1831
+ }
1832
+ }
1833
+ maskedMounts = [
1834
+ storage.base,
1835
+ ...maskedMounts.filter((p) => !p.startsWith(storage.base))
1836
+ ];
1714
1837
  }
1715
- return this.unlinkSync(this.#normalizePath(path), options);
1838
+ return allKeys.filter((key) => filterKeyByBase(key, path));
1716
1839
  }
1717
1840
  /**
1718
- * Creates a directory in the virtual file system (VFS).
1841
+ * Removes a file in the virtual file system (VFS).
1719
1842
  *
1720
1843
  * @param path - The path to create the directory at.
1721
- * @param options - Options for creating the directory.
1722
- * @returns A promise that resolves to the path of the created directory, or undefined if the directory could not be created.
1723
- */
1724
- mkdirSync(path, options = {}) {
1725
- return this.#unifiedFS.resolveFS(this.#normalizePath(path), options).mkdirSync(this.#normalizePath(path), defu6(omit(options, [
1726
- "mode"
1727
- ]), {
1728
- recursive: true
1729
- }));
1844
+ */
1845
+ async remove(path) {
1846
+ const normalizedPath = this.#normalizePath(path);
1847
+ this.#log(LogLevelLabel.TRACE, `Removing file: ${normalizedPath}`);
1848
+ const { relativeKey, adapter } = this.#getStorage(normalizedPath);
1849
+ if (hasFileExtension(normalizedPath)) {
1850
+ await adapter.remove(relativeKey);
1851
+ } else {
1852
+ await adapter.clear(relativeKey);
1853
+ }
1854
+ const id = this.#ids[normalizedPath];
1855
+ if (id && this.#metadata[id]) {
1856
+ delete this.#metadata[id];
1857
+ delete this.#ids[normalizedPath];
1858
+ delete this.#paths[id];
1859
+ }
1730
1860
  }
1731
1861
  /**
1732
- * Creates a directory in the virtual file system (VFS).
1862
+ * Removes a file in the virtual file system (VFS).
1733
1863
  *
1734
1864
  * @param path - The path to create the directory at.
1735
- * @param options - Options for creating the directory.
1736
- * @returns A promise that resolves to the path of the created directory, or undefined if the directory could not be created.
1737
1865
  */
1738
- async mkdir(path, options = {}) {
1739
- let result;
1740
- if (isFunction(this.#unifiedFS.resolveFS(this.#normalizePath(path), options).promises.mkdir)) {
1741
- result = await this.#unifiedFS.resolveFS(this.#normalizePath(path), options).promises.mkdir(this.#normalizePath(path), defu6(omit(options, [
1742
- "mode"
1743
- ]), {
1744
- recursive: true
1745
- }));
1866
+ removeSync(path) {
1867
+ const normalizedPath = this.#normalizePath(path);
1868
+ this.#log(LogLevelLabel.TRACE, `Removing file: ${normalizedPath}`);
1869
+ const { relativeKey, adapter } = this.#getStorage(normalizedPath);
1870
+ if (hasFileExtension(normalizedPath)) {
1871
+ adapter.removeSync(relativeKey);
1746
1872
  } else {
1747
- result = this.#unifiedFS.resolveFS(this.#normalizePath(path), options).mkdirSync(this.#normalizePath(path), defu6(omit(options, [
1748
- "mode"
1749
- ]), {
1750
- recursive: true
1751
- }));
1873
+ adapter.clearSync(relativeKey);
1874
+ }
1875
+ const id = this.#ids[normalizedPath];
1876
+ if (id && this.#metadata[id]) {
1877
+ delete this.#metadata[id];
1878
+ delete this.#ids[normalizedPath];
1879
+ delete this.#paths[id];
1752
1880
  }
1753
- return result;
1754
1881
  }
1755
1882
  /**
1756
1883
  * Glob files in the virtual file system (VFS) based on the provided pattern(s).
@@ -1772,38 +1899,14 @@ var VirtualFileSystem = class _VirtualFileSystem {
1772
1899
  const absPattern = isAbsolutePath(normalized) ? normalized : this.#normalizePath(joinPaths$1(this.#context.workspaceConfig.workspaceRoot, normalized));
1773
1900
  const firstGlobIdx = absPattern.search(/[*?[\]{}]/);
1774
1901
  const baseDir = firstGlobIdx === -1 ? findFilePath(absPattern) : absPattern.slice(0, Math.max(0, absPattern.lastIndexOf("/", firstGlobIdx)));
1775
- const stack = [
1776
- baseDir && isAbsolutePath(baseDir) ? baseDir : this.#context.workspaceConfig.workspaceRoot
1777
- ];
1778
- while (stack.length) {
1779
- const dir = stack.pop();
1780
- let entries = [];
1781
- try {
1782
- entries = await this.readdir(dir);
1783
- } catch {
1784
- continue;
1785
- }
1786
- for (const entry of entries) {
1787
- const full = this.#normalizePath(joinPaths$1(dir, entry));
1788
- let stats;
1789
- try {
1790
- stats = this.#unifiedFS.lstatSync(full);
1791
- } catch {
1792
- stats = void 0;
1793
- }
1794
- if (!stats) continue;
1795
- if (stats.isDirectory()) {
1796
- stack.push(full);
1797
- } else if (stats.isFile()) {
1798
- if (this.#buildRegex(absPattern).test(full)) {
1799
- const resolved = this.resolveSync(full);
1800
- if (resolved && !results.includes(resolved)) {
1801
- results.push(resolved);
1802
- }
1803
- }
1902
+ await Promise.all((await this.list(baseDir && isAbsolutePath(baseDir) ? baseDir : this.#context.workspaceConfig.workspaceRoot)).map(async (file) => {
1903
+ if (this.#buildRegex(absPattern).test(file)) {
1904
+ const resolved = this.resolveSync(file);
1905
+ if (resolved && !results.includes(resolved)) {
1906
+ results.push(resolved);
1804
1907
  }
1805
1908
  }
1806
- }
1909
+ }));
1807
1910
  }
1808
1911
  return results;
1809
1912
  }
@@ -1827,35 +1930,12 @@ var VirtualFileSystem = class _VirtualFileSystem {
1827
1930
  const absPattern = isAbsolutePath(normalized) ? normalized : this.#normalizePath(joinPaths$1(this.#context.workspaceConfig.workspaceRoot, normalized));
1828
1931
  const firstGlobIdx = absPattern.search(/[*?[\]{}]/);
1829
1932
  const baseDir = firstGlobIdx === -1 ? findFilePath(absPattern) : absPattern.slice(0, Math.max(0, absPattern.lastIndexOf("/", firstGlobIdx)));
1830
- const stack = [
1831
- baseDir && isAbsolutePath(baseDir) ? baseDir : this.#context.workspaceConfig.workspaceRoot
1832
- ];
1833
- while (stack.length) {
1834
- const dir = stack.pop();
1835
- let entries = [];
1836
- try {
1837
- entries = this.readdirSync(dir);
1838
- } catch {
1839
- continue;
1840
- }
1841
- for (const entry of entries) {
1842
- const full = this.#normalizePath(joinPaths$1(dir, entry));
1843
- let stats;
1844
- try {
1845
- stats = this.#unifiedFS.lstatSync(full);
1846
- } catch {
1847
- stats = void 0;
1848
- }
1849
- if (!stats) continue;
1850
- if (stats.isDirectory()) {
1851
- stack.push(full);
1852
- } else if (stats.isFile()) {
1853
- if (this.#buildRegex(absPattern).test(full)) {
1854
- const resolved = this.resolveSync(full);
1855
- if (resolved && !results.includes(resolved)) {
1856
- results.push(resolved);
1857
- }
1858
- }
1933
+ const files = this.listSync(baseDir && isAbsolutePath(baseDir) ? baseDir : this.#context.workspaceConfig.workspaceRoot);
1934
+ for (const file of files) {
1935
+ if (this.#buildRegex(absPattern).test(file)) {
1936
+ const resolved = this.resolveSync(file);
1937
+ if (resolved && !results.includes(resolved)) {
1938
+ results.push(resolved);
1859
1939
  }
1860
1940
  }
1861
1941
  }
@@ -1863,36 +1943,27 @@ var VirtualFileSystem = class _VirtualFileSystem {
1863
1943
  return results;
1864
1944
  }
1865
1945
  /**
1866
- * Moves a file from one path to another in the virtual file system (VFS).
1867
- *
1868
- * @param srcPath - The source path to move
1869
- * @param destPath - The destination path to move to
1870
- */
1871
- async move(srcPath, destPath) {
1872
- const content = await this.readFile(srcPath);
1873
- await this.writeFile(destPath, content);
1874
- await this.rm(srcPath);
1875
- }
1876
- /**
1877
- * Synchronously moves a file from one path to another in the virtual file system (VFS).
1878
- *
1879
- * @param srcPath - The source path to move
1880
- * @param destPath - The destination path to move to
1881
- */
1882
- moveSync(srcPath, destPath) {
1883
- const content = this.readFileSync(srcPath);
1884
- this.writeFileSync(destPath, content);
1885
- this.rmSync(srcPath);
1886
- }
1887
- /**
1888
1946
  * Copies a file from one path to another in the virtual file system (VFS).
1889
1947
  *
1890
1948
  * @param srcPath - The source path to copy
1891
1949
  * @param destPath - The destination path to copy to
1892
1950
  */
1893
1951
  async copy(srcPath, destPath) {
1894
- const content = await this.readFile(srcPath);
1895
- await this.writeFile(destPath, content);
1952
+ if (hasFileExtension(srcPath)) {
1953
+ const content = await this.read(srcPath);
1954
+ if (content !== void 0) {
1955
+ await this.write(hasFileExtension(destPath) ? destPath : joinPaths$1(destPath, findFileName(srcPath)), content);
1956
+ }
1957
+ } else {
1958
+ await Promise.all((await this.list(srcPath)).map(async (file) => {
1959
+ const relativePath2 = file.replace(this.#normalizePath(srcPath), "");
1960
+ const destinationPath = this.#normalizePath(appendPath(destPath, relativePath2));
1961
+ const content = await this.read(file);
1962
+ if (content !== void 0) {
1963
+ await this.write(destinationPath, content);
1964
+ }
1965
+ }));
1966
+ }
1896
1967
  }
1897
1968
  /**
1898
1969
  * Synchronously copies a file from one path to another in the virtual file system (VFS).
@@ -1901,51 +1972,85 @@ var VirtualFileSystem = class _VirtualFileSystem {
1901
1972
  * @param destPath - The destination path to copy to
1902
1973
  */
1903
1974
  copySync(srcPath, destPath) {
1904
- const content = this.readFileSync(srcPath);
1905
- this.writeFileSync(destPath, content);
1975
+ if (hasFileExtension(srcPath)) {
1976
+ const content = this.readSync(srcPath);
1977
+ if (content !== void 0) {
1978
+ this.writeSync(hasFileExtension(destPath) ? destPath : joinPaths$1(destPath, findFileName(srcPath)), content);
1979
+ }
1980
+ } else {
1981
+ this.listSync(srcPath).forEach((file) => {
1982
+ const relativePath2 = file.replace(this.#normalizePath(srcPath), "");
1983
+ const destinationPath = this.#normalizePath(appendPath(destPath, relativePath2));
1984
+ const content = this.readSync(file);
1985
+ if (content !== void 0) {
1986
+ this.writeSync(destinationPath, content);
1987
+ }
1988
+ });
1989
+ }
1906
1990
  }
1907
1991
  /**
1908
- * Lists files in a given path.
1992
+ * Moves a file (or files) from one path to another in the virtual file system (VFS).
1909
1993
  *
1910
- * @param pathOrId - The path to list files from.
1911
- * @param options - Options for listing files, such as encoding and recursion.
1912
- * @returns An array of file names in the specified path.
1994
+ * @param srcPath - The source path to move
1995
+ * @param destPath - The destination path to move to
1996
+ */
1997
+ async move(srcPath, destPath) {
1998
+ if (hasFileExtension(srcPath)) {
1999
+ await this.copy(srcPath, destPath);
2000
+ await this.remove(srcPath);
2001
+ } else {
2002
+ await Promise.all((await this.list(srcPath)).map(async (file) => {
2003
+ await this.copy(file, destPath);
2004
+ await this.remove(file);
2005
+ }));
2006
+ }
2007
+ }
2008
+ /**
2009
+ * Synchronously moves a file (or files) from one path to another in the virtual file system (VFS).
2010
+ *
2011
+ * @param srcPath - The source path to move
2012
+ * @param destPath - The destination path to move to
1913
2013
  */
1914
- async readdir(pathOrId, options = "utf8") {
1915
- return this.#unifiedFS.resolveFS(pathOrId).promises.readdir(toFilePath(pathOrId), options);
2014
+ moveSync(srcPath, destPath) {
2015
+ if (hasFileExtension(srcPath)) {
2016
+ this.copySync(srcPath, destPath);
2017
+ this.removeSync(srcPath);
2018
+ } else {
2019
+ this.listSync(srcPath).forEach((file) => {
2020
+ this.copySync(file, destPath);
2021
+ this.removeSync(file);
2022
+ });
2023
+ }
1916
2024
  }
1917
2025
  /**
1918
2026
  * Asynchronously reads a file from the virtual file system (VFS).
1919
2027
  *
1920
- * @param pathOrId - The path or ID of the file to read.
2028
+ * @param path - The path or ID of the file to read.
1921
2029
  * @returns A promise that resolves to the contents of the file as a string, or undefined if the file does not exist.
1922
2030
  */
1923
- async readFile(pathOrId, options = "utf8") {
1924
- const filePath = await this.resolve(pathOrId);
1925
- if (filePath && this.isFile(filePath)) {
1926
- let result;
1927
- if (isFunction(this.#unifiedFS.resolveFS(filePath).promises.readFile)) {
1928
- result = (await this.#unifiedFS.resolveFS(filePath).promises.readFile(filePath, options))?.toString("utf8");
1929
- } else {
1930
- result = this.#unifiedFS.resolveFS(filePath).readFileSync(filePath, options);
1931
- }
1932
- return isBuffer(result) ? bufferToString(result) : result;
2031
+ async read(path) {
2032
+ const filePath = await this.resolve(path);
2033
+ if (!filePath) {
2034
+ return void 0;
1933
2035
  }
1934
- return void 0;
2036
+ const { relativeKey, adapter } = this.#getStorage(filePath);
2037
+ this.#log(LogLevelLabel.TRACE, `Reading ${adapter.name} file: ${filePath}`);
2038
+ return await adapter.get(relativeKey) ?? void 0;
1935
2039
  }
1936
2040
  /**
1937
2041
  * Synchronously reads a file from the virtual file system (VFS).
1938
2042
  *
1939
- * @param pathOrId - The path or ID of the file to read.
2043
+ * @param path - The path or ID of the file to read.
1940
2044
  * @returns The contents of the file as a string, or undefined if the file does not exist.
1941
2045
  */
1942
- readFileSync(pathOrId, options = "utf8") {
1943
- const filePath = this.resolveSync(pathOrId);
1944
- if (filePath && this.isFile(filePath)) {
1945
- const result = this.#unifiedFS.resolveFS(filePath).readFileSync(filePath, options);
1946
- return isBuffer(result) ? bufferToString(result) : result;
2046
+ readSync(path) {
2047
+ const filePath = this.resolveSync(path);
2048
+ if (!filePath) {
2049
+ return void 0;
1947
2050
  }
1948
- return void 0;
2051
+ const { relativeKey, adapter } = this.#getStorage(filePath);
2052
+ this.#log(LogLevelLabel.TRACE, `Reading ${adapter.name} file: ${filePath}`);
2053
+ return adapter.getSync(relativeKey) ?? void 0;
1949
2054
  }
1950
2055
  /**
1951
2056
  * Writes a file to the virtual file system (VFS).
@@ -1955,41 +2060,28 @@ var VirtualFileSystem = class _VirtualFileSystem {
1955
2060
  * @param options - Optional parameters for writing the file.
1956
2061
  * @returns A promise that resolves when the file is written.
1957
2062
  */
1958
- async writeFile(path, data = "", options = "utf8") {
1959
- if (!this.isDirectory(findFilePath(this.#normalizePath(path)))) {
1960
- await this.mkdir(findFilePath(this.#normalizePath(path)), isPowerlinesWriteFileOptions(options) ? options : void 0);
1961
- }
1962
- const metadata = isVirtualFileData(data) ? data : {};
1963
- metadata.id = this.#normalizeId(path);
1964
- let code = isVirtualFileData(data) ? metadata.code : data;
1965
- if ((!isPowerlinesWriteFileOptions(options) || !options.skipFormat) && isSetString(code)) {
2063
+ async write(path, data = "", options = {}) {
2064
+ let code = data;
2065
+ if (!options.skipFormat) {
1966
2066
  const resolvedConfig = await resolveConfig(this.#normalizePath(path));
1967
2067
  if (resolvedConfig) {
1968
- code = await format(code, {
2068
+ code = await format(data, {
1969
2069
  absolutePath: this.#normalizePath(path),
1970
2070
  ...resolvedConfig
1971
2071
  });
1972
2072
  }
1973
2073
  }
1974
- const outputMode = this.#unifiedFS.resolveMode(this.#normalizePath(path), isPowerlinesWriteFileOptions(options) ? options : void 0);
1975
- this.#log(LogLevelLabel.TRACE, `Writing ${this.#normalizePath(path)} file to the ${outputMode === "fs" ? "" : "virtual "}file system (size: ${prettyBytes(new Blob(toArray(code)).size)})`);
1976
- this.#metadata[metadata.id] = {
1977
- mode: outputMode,
2074
+ const { relativeKey, adapter } = this.#getStorage(path);
2075
+ this.#log(LogLevelLabel.TRACE, `Writing ${this.#normalizePath(path)} to ${adapter.name === "virtual" ? "the virtual file system" : adapter.name === "file-system" ? "the local file system" : adapter.name} (size: ${prettyBytes(new Blob(toArray(code)).size)})`);
2076
+ const id = options?.meta?.id || this.#normalizeId(path);
2077
+ this.#metadata[id] = {
1978
2078
  variant: "normal",
1979
2079
  timestamp: Date.now(),
1980
- ...metadata
2080
+ ...options.meta ?? {}
1981
2081
  };
1982
- this.#paths[metadata.id] = this.#normalizePath(path);
1983
- this.#ids[this.#normalizePath(path)] = metadata.id;
1984
- const ifs = this.#unifiedFS.resolveFS(this.#normalizePath(path), isPowerlinesWriteFileOptions(options) ? options : void 0);
1985
- if (isFunction(ifs.promises.writeFile)) {
1986
- return ifs.promises.writeFile(this.#normalizePath(path), code, isSetObject(options) ? omit(options, [
1987
- "mode"
1988
- ]) : "utf8");
1989
- }
1990
- return ifs.writeFileSync(this.#normalizePath(path), code, isSetObject(options) ? omit(options, [
1991
- "mode"
1992
- ]) : "utf8");
2082
+ this.#paths[id] = this.#normalizePath(path);
2083
+ this.#ids[this.#normalizePath(path)] = id;
2084
+ return adapter.set(relativeKey, code);
1993
2085
  }
1994
2086
  /**
1995
2087
  * Synchronously writes a file to the virtual file system (VFS).
@@ -1998,38 +2090,18 @@ var VirtualFileSystem = class _VirtualFileSystem {
1998
2090
  * @param data - The contents of the file.
1999
2091
  * @param options - Optional parameters for writing the file.
2000
2092
  */
2001
- writeFileSync(path, data = "", options = "utf8") {
2002
- if (!this.isDirectory(findFilePath(this.#normalizePath(path)))) {
2003
- this.mkdirSync(findFilePath(this.#normalizePath(path)), isPowerlinesWriteFileOptions(options) ? options : void 0);
2004
- }
2005
- const metadata = isVirtualFileData(data) ? data : {};
2006
- metadata.id = this.#normalizeId(path);
2007
- const code = isVirtualFileData(data) ? metadata.code : data;
2008
- const outputMode = this.#unifiedFS.resolveMode(this.#normalizePath(path), isPowerlinesWriteFileOptions(options) ? options : void 0);
2009
- this.#log(LogLevelLabel.TRACE, `Writing ${this.#normalizePath(path)} file to the ${outputMode === "fs" ? "" : "virtual "}file system (size: ${prettyBytes(new Blob(toArray(code)).size)})`);
2010
- this.#metadata[metadata.id] = {
2011
- mode: outputMode,
2093
+ writeSync(path, data = "", options = {}) {
2094
+ const { relativeKey, adapter } = this.#getStorage(path);
2095
+ this.#log(LogLevelLabel.TRACE, `Writing ${this.#normalizePath(path)} file to ${adapter.name === "virtual" ? "the virtual file system" : adapter.name === "file-system" ? "the local file system" : adapter.name} (size: ${prettyBytes(new Blob(toArray(data)).size)})`);
2096
+ const id = options?.meta?.id || this.#normalizeId(path);
2097
+ this.#metadata[id] = {
2012
2098
  variant: "normal",
2013
2099
  timestamp: Date.now(),
2014
- ...metadata
2100
+ ...options.meta ?? {}
2015
2101
  };
2016
- this.#paths[metadata.id] = this.#normalizePath(path);
2017
- this.#ids[this.#normalizePath(path)] = metadata.id;
2018
- const writeStream = this.#unifiedFS.resolveFS(this.#normalizePath(path), isPowerlinesWriteFileOptions(options) ? options : void 0).createWriteStream(this.#normalizePath(path));
2019
- try {
2020
- writeStream.write(code);
2021
- } finally {
2022
- writeStream.close();
2023
- }
2024
- }
2025
- /**
2026
- * Synchronously checks if a file exists in the virtual file system (VFS).
2027
- *
2028
- * @param pathOrId - The path or ID of the file to check.
2029
- * @returns `true` if the file exists, otherwise `false`.
2030
- */
2031
- existsSync(pathOrId) {
2032
- return !!this.resolveSync(pathOrId);
2102
+ this.#paths[id] = this.#normalizePath(path);
2103
+ this.#ids[this.#normalizePath(path)] = id;
2104
+ return adapter.setSync(relativeKey, data);
2033
2105
  }
2034
2106
  /**
2035
2107
  * Retrieves the metadata of a file in the virtual file system (VFS).
@@ -2045,78 +2117,6 @@ var VirtualFileSystem = class _VirtualFileSystem {
2045
2117
  return void 0;
2046
2118
  }
2047
2119
  /**
2048
- * Checks if a file exists in the virtual file system (VFS).
2049
- *
2050
- * @remarks
2051
- * 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.
2052
- *
2053
- * @param pathOrId - The path of the file to check.
2054
- * @returns `true` if the file exists, otherwise `false`.
2055
- */
2056
- isFile(pathOrId) {
2057
- const resolved = this.resolveSync(pathOrId);
2058
- 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()));
2059
- }
2060
- /**
2061
- * Checks if a directory exists in the virtual file system (VFS).
2062
- *
2063
- * @param pathOrId - The path of the directory to check.
2064
- * @returns `true` if the directory exists, otherwise `false`.
2065
- */
2066
- isDirectory(pathOrId) {
2067
- const resolved = this.resolveSync(pathOrId);
2068
- 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()));
2069
- }
2070
- /**
2071
- * Retrieves the status of a file in the virtual file system (VFS).
2072
- *
2073
- * @param pathOrId - The path or ID of the file to retrieve status for.
2074
- * @returns A promise that resolves to the file's status information, or false if the file does not exist.
2075
- */
2076
- async stat(pathOrId, options) {
2077
- return this.#unifiedFS.resolveFS(pathOrId).promises.stat(await this.resolve(pathOrId) || pathOrId, options);
2078
- }
2079
- /**
2080
- * Synchronously retrieves the status of a file in the virtual file system (VFS).
2081
- *
2082
- * @param pathOrId - The path or ID of the file to retrieve status for.
2083
- * @returns The file's status information, or false if the file does not exist.
2084
- */
2085
- statSync(pathOrId) {
2086
- return this.#unifiedFS.resolveFS(pathOrId).statSync(this.resolveSync(pathOrId) || pathOrId);
2087
- }
2088
- /**
2089
- * Retrieves the status of a symbolic link in the virtual file system (VFS).
2090
- *
2091
- * @param pathOrId - The path or ID of the symbolic link to retrieve status for.
2092
- * @returns A promise that resolves to the symbolic link's status information, or false if the link does not exist.
2093
- */
2094
- async lstat(pathOrId, options) {
2095
- return this.#unifiedFS.resolveFS(pathOrId).promises.lstat(await this.resolve(pathOrId) || pathOrId, options);
2096
- }
2097
- /**
2098
- * Synchronously retrieves the status of a symbolic link in the virtual file system (VFS).
2099
- *
2100
- * @param pathOrId - The path or ID of the symbolic link to retrieve status for.
2101
- * @returns The symbolic link's status information, or false if the link does not exist.
2102
- */
2103
- lstatSync(pathOrId, options) {
2104
- return this.#unifiedFS.resolveFS(pathOrId).lstatSync(this.resolveSync(pathOrId) || pathOrId, options);
2105
- }
2106
- /**
2107
- * Resolves a path or ID to its real path in the virtual file system (VFS).
2108
- *
2109
- * @param pathOrId - The path or ID to resolve.
2110
- * @returns The resolved real path if it exists, otherwise undefined.
2111
- */
2112
- realpathSync(pathOrId) {
2113
- const filePath = this.resolveSync(pathOrId);
2114
- if (!filePath) {
2115
- throw new Error(`File not found: ${pathOrId}`);
2116
- }
2117
- return filePath;
2118
- }
2119
- /**
2120
2120
  * A helper function to resolve modules in the virtual file system (VFS).
2121
2121
  *
2122
2122
  * @remarks
@@ -2133,9 +2133,15 @@ var VirtualFileSystem = class _VirtualFileSystem {
2133
2133
  * @returns A promise that resolves to the resolved module path.
2134
2134
  */
2135
2135
  async resolve(id, importer, options = {}) {
2136
- let result = this.resolverCache.get(this.#normalizeId(id));
2137
- if (result) {
2138
- return result;
2136
+ if (isAbsolutePath(id)) {
2137
+ return id;
2138
+ }
2139
+ let result;
2140
+ if (!this.#context.config.skipCache) {
2141
+ result = this.resolverCache.get(this.#normalizeId(id));
2142
+ if (result) {
2143
+ return result;
2144
+ }
2139
2145
  }
2140
2146
  result = this.paths[this.#normalizeId(id)];
2141
2147
  if (!result) {
@@ -2150,12 +2156,14 @@ var VirtualFileSystem = class _VirtualFileSystem {
2150
2156
  for (const combination of getResolutionCombinations(id, {
2151
2157
  paths
2152
2158
  })) {
2153
- if (this.#existsSync(combination)) {
2159
+ const { relativeKey, adapter } = this.#getStorage(combination);
2160
+ if (await adapter.exists(relativeKey)) {
2154
2161
  result = combination;
2162
+ break;
2155
2163
  }
2156
2164
  }
2157
2165
  try {
2158
- result = await resolve(id, {
2166
+ result = await resolve$1(id, {
2159
2167
  paths
2160
2168
  });
2161
2169
  } catch {
@@ -2163,7 +2171,9 @@ var VirtualFileSystem = class _VirtualFileSystem {
2163
2171
  }
2164
2172
  if (result) {
2165
2173
  result = toAbsolutePath(appendPath(result, this.#context.config.projectRoot), this.#context.workspaceConfig.workspaceRoot);
2166
- this.resolverCache.set(this.#normalizeId(id), result);
2174
+ if (!this.#context.config.skipCache) {
2175
+ this.resolverCache.set(this.#normalizeId(id), result);
2176
+ }
2167
2177
  }
2168
2178
  return result;
2169
2179
  }
@@ -2184,9 +2194,15 @@ var VirtualFileSystem = class _VirtualFileSystem {
2184
2194
  * @returns The resolved module path.
2185
2195
  */
2186
2196
  resolveSync(id, importer, options = {}) {
2187
- let result = this.resolverCache.get(this.#normalizeId(id));
2188
- if (result) {
2189
- return result;
2197
+ if (isAbsolutePath(id)) {
2198
+ return id;
2199
+ }
2200
+ let result;
2201
+ if (!this.#context.config.skipCache) {
2202
+ result = this.resolverCache.get(this.#normalizeId(id));
2203
+ if (result) {
2204
+ return result;
2205
+ }
2190
2206
  }
2191
2207
  result = this.paths[this.#normalizeId(id)];
2192
2208
  if (!result) {
@@ -2195,14 +2211,16 @@ var VirtualFileSystem = class _VirtualFileSystem {
2195
2211
  paths.push(importer);
2196
2212
  }
2197
2213
  paths.push(this.#context.workspaceConfig.workspaceRoot);
2198
- paths.push(joinPaths$1(this.#context.workspaceConfig.workspaceRoot, this.#context.config.projectRoot));
2199
- paths.push(joinPaths$1(this.#context.workspaceConfig.workspaceRoot, this.#context.config.sourceRoot));
2200
- paths.push(...Object.keys(this.#context.tsconfig?.options?.paths ?? {}).filter((tsconfigPath) => id.startsWith(tsconfigPath.replace(/\*$/, ""))).map((tsconfigPath) => this.#context.tsconfig?.options?.paths?.[tsconfigPath]).flat().filter(Boolean).map((tsconfigPath) => appendPath(tsconfigPath, this.#context.workspaceConfig.workspaceRoot)));
2214
+ paths.push(appendPath(this.#context.config.projectRoot, this.#context.workspaceConfig.workspaceRoot));
2215
+ paths.push(appendPath(this.#context.config.sourceRoot, this.#context.workspaceConfig.workspaceRoot));
2216
+ paths.push(...Object.keys(this.#context.tsconfig.options.paths ?? {}).filter((tsconfigPath) => id.startsWith(tsconfigPath.replace(/\*$/, ""))).map((tsconfigPath) => this.#context.tsconfig.options.paths?.[tsconfigPath]).flat().filter(Boolean).map((tsconfigPath) => appendPath(tsconfigPath, this.#context.workspaceConfig.workspaceRoot)));
2201
2217
  for (const combination of getResolutionCombinations(id, {
2202
2218
  paths
2203
2219
  })) {
2204
- if (this.#existsSync(combination)) {
2220
+ const { relativeKey, adapter } = this.#getStorage(combination);
2221
+ if (adapter.existsSync(relativeKey)) {
2205
2222
  result = combination;
2223
+ break;
2206
2224
  }
2207
2225
  }
2208
2226
  try {
@@ -2214,7 +2232,9 @@ var VirtualFileSystem = class _VirtualFileSystem {
2214
2232
  }
2215
2233
  if (result) {
2216
2234
  result = toAbsolutePath(appendPath(result, this.#context.config.projectRoot), this.#context.workspaceConfig.workspaceRoot);
2217
- this.resolverCache.set(this.#normalizeId(id), result);
2235
+ if (!this.#context.config.skipCache) {
2236
+ this.resolverCache.set(this.#normalizeId(id), result);
2237
+ }
2218
2238
  }
2219
2239
  return result;
2220
2240
  }
@@ -2225,27 +2245,27 @@ var VirtualFileSystem = class _VirtualFileSystem {
2225
2245
  if (!this.#isDisposed) {
2226
2246
  this.#isDisposed = true;
2227
2247
  this.#log(LogLevelLabel.DEBUG, "Disposing virtual file system...");
2228
- await this.unlink(joinPaths$1(this.#context.dataPath, "fs.bin"));
2248
+ await this.remove(joinPaths$1(this.#context.dataPath, "fs.bin"));
2229
2249
  const message = new $.Message();
2230
- const fs2 = message.initRoot(FileSystem);
2231
- const virtualFiles = Object.entries(this.#unifiedFS.toJSON()).filter(([, code]) => code);
2232
- const files = fs2._initFiles(virtualFiles.length);
2233
- virtualFiles.filter(([, code]) => code).forEach(([path, code], index) => {
2234
- const fd = files.get(index);
2250
+ const fs = message.initRoot(FileSystem);
2251
+ const paths = await this.list();
2252
+ const storage = fs._initStorage(paths.length);
2253
+ await Promise.all(paths.map(async (path, index) => {
2254
+ const code = await this.read(path);
2255
+ const fd = storage.get(index);
2235
2256
  fd.path = path;
2236
2257
  fd.code = code || "";
2237
- });
2238
- const ids = fs2._initIds(Object.keys(this.ids).length);
2258
+ }));
2259
+ const ids = fs._initIds(Object.keys(this.ids).length);
2239
2260
  Object.entries(this.ids).filter(([, path]) => path).forEach(([id, path], index) => {
2240
2261
  const fileId = ids.get(index);
2241
2262
  fileId.id = id;
2242
2263
  fileId.path = path;
2243
2264
  });
2244
- const metadata = fs2._initMetadata(Object.keys(this.metadata).length);
2265
+ const metadata = fs._initMetadata(Object.keys(this.metadata).length);
2245
2266
  Object.entries(this.metadata).filter(([, value]) => value).forEach(([id, value], index) => {
2246
2267
  const fileMetadata = metadata.get(index);
2247
2268
  fileMetadata.id = id;
2248
- fileMetadata.mode = value.mode;
2249
2269
  fileMetadata.type = value.type;
2250
2270
  fileMetadata.timestamp = value.timestamp ?? BigInt(Date.now());
2251
2271
  if (value.properties) {
@@ -2258,134 +2278,40 @@ var VirtualFileSystem = class _VirtualFileSystem {
2258
2278
  }
2259
2279
  });
2260
2280
  await writeFileBuffer(joinPaths$1(this.#context.dataPath, "fs.bin"), message.toArrayBuffer());
2261
- this.#resolverCache.save(true);
2262
- this.#log(LogLevelLabel.DEBUG, "Virtual file system disposed.");
2263
- }
2264
- }
2265
- /**
2266
- * Initializes the virtual file system (VFS) by patching the file system module if necessary.
2267
- */
2268
- [__VFS_PATCH__]() {
2269
- if (!this.#isPatched && this.#context.config.output.mode !== "fs") {
2270
- this.#revert = patchFS(_fs, this);
2271
- this.#isPatched = true;
2272
- }
2273
- }
2274
- /**
2275
- * Reverts the file system module to its original state if it was previously patched.
2276
- */
2277
- [__VFS_REVERT__]() {
2278
- if (this.#isPatched && this.#context.config.output.mode !== "fs") {
2279
- if (!this.#revert) {
2280
- throw new Error("Attempting to revert File System patch prior to calling `__init__` function");
2281
- }
2282
- this.#revert?.();
2283
- this.#isPatched = false;
2284
- }
2285
- }
2281
+ if (!this.#context.config.skipCache) {
2282
+ this.#resolverCache.save(true);
2283
+ }
2284
+ await Promise.all(this.#getStorages().map(async (storage2) => storage2.adapter.dispose()));
2285
+ this.#log(LogLevelLabel.TRACE, "Virtual file system has been disposed.");
2286
+ }
2287
+ }
2288
+ // /**
2289
+ // * Initializes the virtual file system (VFS) by patching the file system module if necessary.
2290
+ // */
2291
+ // public [__VFS_PATCH__]() {
2292
+ // if (!this.#isPatched && this.#context.config.output.mode !== "fs") {
2293
+ // this.#revert = patchFS(fs, this);
2294
+ // this.#isPatched = true;
2295
+ // }
2296
+ // }
2297
+ // /**
2298
+ // * Reverts the file system module to its original state if it was previously patched.
2299
+ // */
2300
+ // public [__VFS_REVERT__]() {
2301
+ // if (this.#isPatched && this.#context.config.output.mode !== "fs") {
2302
+ // if (!this.#revert) {
2303
+ // throw new Error(
2304
+ // "Attempting to revert File System patch prior to calling `__init__` function"
2305
+ // );
2306
+ // }
2307
+ // this.#revert?.();
2308
+ // this.#isPatched = false;
2309
+ // }
2310
+ // }
2286
2311
  async [Symbol.asyncDispose]() {
2287
2312
  return this.dispose();
2288
2313
  }
2289
2314
  };
2290
- var VirtualFileSystemHost = class VirtualFileSystemHost2 extends InMemoryFileSystemHost {
2291
- static {
2292
- __name(this, "VirtualFileSystemHost");
2293
- }
2294
- #fs;
2295
- constructor(fs2) {
2296
- super();
2297
- this.#fs = fs2;
2298
- }
2299
- deleteSync(path) {
2300
- this.#fs.rmSync(path);
2301
- }
2302
- readDirSync(dirPath) {
2303
- return this.#fs.readdirSync(dirPath).reduce((ret, entry) => {
2304
- const fullPath = this.#fs.resolveSync(joinPaths(dirPath, entry));
2305
- if (fullPath) {
2306
- ret.push({
2307
- name: entry,
2308
- isDirectory: this.#fs.isDirectory(fullPath),
2309
- isFile: this.#fs.isFile(fullPath),
2310
- isSymlink: false
2311
- });
2312
- }
2313
- return ret;
2314
- }, []);
2315
- }
2316
- async readFile(filePath) {
2317
- if (!this.#fs.existsSync(filePath)) {
2318
- throw new Error(`File not found: '${filePath}'. Please check the path and try again.`);
2319
- }
2320
- return await this.#fs.readFile(filePath);
2321
- }
2322
- readFileSync(filePath) {
2323
- if (!this.#fs.existsSync(filePath)) {
2324
- throw new Error(`File not found: '${filePath}'. Please check the path and try again.`);
2325
- }
2326
- return this.#fs.readFileSync(filePath);
2327
- }
2328
- async writeFile(filePath, fileText) {
2329
- return this.#fs.writeFile(filePath, fileText);
2330
- }
2331
- writeFileSync(filePath, fileText) {
2332
- this.#fs.writeFileSync(filePath, fileText);
2333
- }
2334
- async mkdir(dirPath) {
2335
- await this.#fs.mkdir(dirPath);
2336
- }
2337
- mkdirSync(dirPath) {
2338
- this.#fs.mkdirSync(dirPath);
2339
- }
2340
- async move(srcPath, destPath) {
2341
- await this.#fs.move(srcPath, destPath);
2342
- }
2343
- moveSync(srcPath, destPath) {
2344
- this.#fs.moveSync(srcPath, destPath);
2345
- }
2346
- async copy(srcPath, destPath) {
2347
- await this.#fs.copy(srcPath, destPath);
2348
- }
2349
- copySync(srcPath, destPath) {
2350
- this.#fs.copySync(srcPath, destPath);
2351
- }
2352
- async fileExists(filePath) {
2353
- return this.#fs.isFile(filePath);
2354
- }
2355
- fileExistsSync(filePath) {
2356
- return this.#fs.isFile(filePath);
2357
- }
2358
- async directoryExists(dirPath) {
2359
- return this.#fs.isDirectory(dirPath);
2360
- }
2361
- directoryExistsSync(dirPath) {
2362
- return this.#fs.isDirectory(dirPath);
2363
- }
2364
- realpathSync(path) {
2365
- return this.#fs.resolveSync(path) || path;
2366
- }
2367
- getCurrentDirectory() {
2368
- return "/";
2369
- }
2370
- async glob(patterns) {
2371
- return this.#fs.glob(patterns);
2372
- }
2373
- globSync(patterns) {
2374
- return this.#fs.globSync(patterns);
2375
- }
2376
- };
2377
- function createProgram(context, override) {
2378
- const project = new Project({
2379
- compilerOptions: {
2380
- ...context.tsconfig.options
2381
- },
2382
- tsConfigFilePath: context.tsconfig.tsconfigFilePath,
2383
- fileSystem: new VirtualFileSystemHost(context.fs),
2384
- ...override
2385
- });
2386
- return project;
2387
- }
2388
- __name(createProgram, "createProgram");
2389
2315
  var PROJECT_ROOT_HASH_LENGTH = 45;
2390
2316
  var CACHE_HASH_LENGTH = 62;
2391
2317
  function getPrefixedProjectRootHash(name, projectRootHash) {
@@ -2396,9 +2322,7 @@ __name(getPrefixedProjectRootHash, "getPrefixedProjectRootHash");
2396
2322
  async function writeMetaFile(context) {
2397
2323
  const metaFilePath = joinPaths$1(context.dataPath, "meta.json");
2398
2324
  context.log(LogLevelLabel.DEBUG, `Writing runtime metadata to ${metaFilePath}`);
2399
- await context.fs.writeFile(metaFilePath, JSON.stringify(context.meta, null, 2), {
2400
- mode: "fs"
2401
- });
2325
+ await context.fs.write(metaFilePath, JSON.stringify(context.meta, null, 2));
2402
2326
  }
2403
2327
  __name(writeMetaFile, "writeMetaFile");
2404
2328
 
@@ -2601,7 +2525,7 @@ var PowerlinesContext = class _PowerlinesContext {
2601
2525
  * Get the path to the artifacts directory for the project
2602
2526
  */
2603
2527
  get artifactsPath() {
2604
- return joinPaths(this.workspaceConfig.workspaceRoot, this.config.projectRoot, this.config.output.artifactsFolder);
2528
+ return joinPaths(this.workspaceConfig.workspaceRoot, this.config.projectRoot, this.config.output.artifactsPath);
2605
2529
  }
2606
2530
  /**
2607
2531
  * Get the path to the builtin modules used by the project
@@ -2741,7 +2665,7 @@ var PowerlinesContext = class _PowerlinesContext {
2741
2665
  if (!resolvedId) {
2742
2666
  return void 0;
2743
2667
  }
2744
- const code = await this.fs.readFile(resolvedId);
2668
+ const code = await this.fs.read(resolvedId);
2745
2669
  if (!code) {
2746
2670
  return void 0;
2747
2671
  }
@@ -2755,7 +2679,7 @@ var PowerlinesContext = class _PowerlinesContext {
2755
2679
  */
2756
2680
  async getBuiltins() {
2757
2681
  return Promise.all(Object.entries(this.fs.metadata).filter(([, meta]) => meta && meta.type === "builtin").map(async ([path, meta]) => {
2758
- const code = await this.fs.readFile(path);
2682
+ const code = await this.fs.read(path);
2759
2683
  return {
2760
2684
  ...meta,
2761
2685
  path,
@@ -2771,11 +2695,8 @@ var PowerlinesContext = class _PowerlinesContext {
2771
2695
  * @param options - Optional write file options
2772
2696
  */
2773
2697
  async emitEntry(code, path, options = {}) {
2774
- return this.fs.writeFile(isAbsolute(path) ? path : appendPath(path, this.entryPath), {
2775
- code,
2698
+ return this.fs.write(isAbsolute(path) ? path : appendPath(path, this.entryPath), code, defu7(options, {
2776
2699
  type: "entry"
2777
- }, defu6(options, {
2778
- mode: this.config.output.mode
2779
2700
  }));
2780
2701
  }
2781
2702
  /**
@@ -2787,12 +2708,8 @@ var PowerlinesContext = class _PowerlinesContext {
2787
2708
  * @param options - Optional write file options
2788
2709
  */
2789
2710
  async emitBuiltin(code, id, path, options = {}) {
2790
- return this.fs.writeFile(path ? isAbsolute(path) ? path : joinPaths(this.builtinsPath, path) : appendPath(id, this.builtinsPath), {
2791
- id,
2792
- code,
2711
+ return this.fs.write(path ? isAbsolute(path) ? path : joinPaths(this.builtinsPath, path) : appendPath(id, this.builtinsPath), code, defu7(options, {
2793
2712
  type: "builtin"
2794
- }, defu6(options, {
2795
- mode: this.config.output.mode
2796
2713
  }));
2797
2714
  }
2798
2715
  /**
@@ -2986,9 +2903,9 @@ var PowerlinesContext = class _PowerlinesContext {
2986
2903
  userConfig
2987
2904
  });
2988
2905
  }
2989
- this.config.tsconfig ??= getTsconfigFilePath(this.workspaceConfig.workspaceRoot, cacheKey.projectRoot, config.tsconfig);
2906
+ config.tsconfig ??= getTsconfigFilePath(this.workspaceConfig.workspaceRoot, cacheKey.projectRoot, config.tsconfig);
2990
2907
  if (isSetObject(config)) {
2991
- this.resolvedConfig = defu6({
2908
+ this.resolvedConfig = defu7({
2992
2909
  inlineConfig: this.config.inlineConfig,
2993
2910
  userConfig: this.config.userConfig
2994
2911
  }, options.isHighPriority ? this.#getConfigProps(config) : {}, {
@@ -3003,12 +2920,11 @@ var PowerlinesContext = class _PowerlinesContext {
3003
2920
  version: this.packageJson?.version,
3004
2921
  description: this.packageJson?.description,
3005
2922
  sourceRoot: this.projectJson?.sourceRoot || appendPath("src", cacheKey.projectRoot),
3006
- output: {
2923
+ output: defu7(config.output ?? {}, {
3007
2924
  outputPath: cacheKey.projectRoot ? joinPaths(this.workspaceConfig?.directories?.build || "dist", cacheKey.projectRoot) : this.workspaceConfig?.directories?.build || "dist",
3008
- mode: "virtual",
2925
+ artifactsPath: joinPaths(cacheKey.projectRoot, `.${config.framework ?? "powerlines"}`),
3009
2926
  dts: joinPaths(cacheKey.projectRoot, `${config.framework ?? "powerlines"}.d.ts`),
3010
2927
  builtinPrefix: config.framework ?? "powerlines",
3011
- artifactsFolder: joinPaths(cacheKey.projectRoot, `.${config.framework ?? "powerlines"}`),
3012
2928
  assets: [
3013
2929
  {
3014
2930
  glob: "LICENSE"
@@ -3022,7 +2938,7 @@ var PowerlinesContext = class _PowerlinesContext {
3022
2938
  glob: "package.json"
3023
2939
  }
3024
2940
  ]
3025
- }
2941
+ })
3026
2942
  }, options.isHighPriority ? {} : this.#getConfigProps(config), {
3027
2943
  inlineConfig: {},
3028
2944
  userConfig: {},
@@ -3067,10 +2983,10 @@ var PowerlinesContext = class _PowerlinesContext {
3067
2983
  ])));
3068
2984
  if (this.config.projectRoot && this.config.projectRoot !== "." && this.config.projectRoot !== "./" && this.config.projectRoot !== this.workspaceConfig.workspaceRoot) {
3069
2985
  this.config.output.outputPath ??= joinPaths("dist", this.config.projectRoot);
3070
- this.config.output.distPath ??= joinPaths(this.config.projectRoot, "dist");
2986
+ this.config.output.buildPath ??= joinPaths(this.config.projectRoot, "dist");
3071
2987
  } else {
3072
2988
  this.config.output.outputPath ??= "dist";
3073
- this.config.output.distPath ??= "dist";
2989
+ this.config.output.buildPath ??= "dist";
3074
2990
  }
3075
2991
  this.config.output.assets = getUnique(this.config.output.assets.map((asset) => {
3076
2992
  return {
@@ -3108,7 +3024,7 @@ var PowerlinesContext = class _PowerlinesContext {
3108
3024
  this.#fs ??= await VirtualFileSystem.create(this);
3109
3025
  }
3110
3026
  mergeUserConfig(from = {}, into = this.config.userConfig ?? {}) {
3111
- this.config.userConfig = defu6({
3027
+ this.config.userConfig = defu7({
3112
3028
  entry: Array.isArray(from.entry) && from.entry.length > 0 ? from.entry : Array.isArray(into?.entry) && into.entry.length > 0 ? into.entry : []
3113
3029
  }, omit(from ?? {}, [
3114
3030
  "entry"
@@ -3404,12 +3320,49 @@ var PowerlinesAPIContext = class _PowerlinesAPIContext extends PowerlinesContext
3404
3320
  }
3405
3321
  return context;
3406
3322
  }
3323
+ /**
3324
+ * Update the context using a new user configuration options
3325
+ *
3326
+ * @param userConfig - The new user configuration options.
3327
+ */
3328
+ async withUserConfig(userConfig, options = {
3329
+ isHighPriority: true
3330
+ }) {
3331
+ await super.withUserConfig(userConfig, options);
3332
+ await Promise.all(Object.keys(this.#environments).map(async (name) => {
3333
+ await this.#environments[name].withUserConfig(userConfig, options);
3334
+ }));
3335
+ }
3336
+ /**
3337
+ * Update the context using a new inline configuration options
3338
+ *
3339
+ * @param inlineConfig - The new inline configuration options.
3340
+ */
3341
+ async withInlineConfig(inlineConfig, options = {
3342
+ isHighPriority: true
3343
+ }) {
3344
+ await super.withInlineConfig(inlineConfig, options);
3345
+ await Promise.all(Object.keys(this.#environments).map(async (name) => {
3346
+ await this.#environments[name].withInlineConfig(inlineConfig, options);
3347
+ }));
3348
+ }
3349
+ /**
3350
+ * Add a plugin to the API context and all environments
3351
+ *
3352
+ * @param plugin - The plugin to add.
3353
+ */
3407
3354
  async addPlugin(plugin) {
3408
3355
  this.plugins.push(plugin);
3409
3356
  await Promise.all(Object.keys(this.environments).map(async (name) => {
3410
3357
  await this.environments[name].addPlugin(plugin);
3411
3358
  }));
3412
3359
  }
3360
+ /**
3361
+ * Get an environment by name, or the default environment if no name is provided
3362
+ *
3363
+ * @param name - The name of the environment to retrieve.
3364
+ * @returns The requested environment context.
3365
+ */
3413
3366
  async getEnvironment(name) {
3414
3367
  let environment;
3415
3368
  if (name) {
@@ -3531,21 +3484,17 @@ ${formatLogMessage(context.config)}`);
3531
3484
  await writeMetaFile(context);
3532
3485
  context.persistedMeta = context.meta;
3533
3486
  if (!context.fs.existsSync(context.cachePath)) {
3534
- await context.fs.mkdir(context.cachePath, {
3535
- mode: "fs"
3536
- });
3487
+ await createDirectory(context.cachePath);
3537
3488
  }
3538
3489
  if (!context.fs.existsSync(context.dataPath)) {
3539
- await context.fs.mkdir(context.dataPath, {
3540
- mode: "fs"
3541
- });
3490
+ await createDirectory(context.dataPath);
3542
3491
  }
3543
3492
  await this.callPreHook(context, "prepare");
3544
3493
  await this.callNormalHook(context, "prepare");
3545
3494
  if (context.config.output.dts !== false) {
3546
3495
  context.log(LogLevelLabel.TRACE, `Preparing the TypeScript definitions for the Powerlines project.`);
3547
3496
  if (context.fs.existsSync(context.dtsPath)) {
3548
- await context.fs.unlink(context.dtsPath);
3497
+ await context.fs.remove(context.dtsPath);
3549
3498
  }
3550
3499
  context.log(LogLevelLabel.TRACE, "Transforming built-ins runtime modules files.");
3551
3500
  const builtinFilePaths = await Promise.all((await context.getBuiltins()).map(async (file) => {
@@ -3632,7 +3581,7 @@ ${formatLogMessage(context.config)}`);
3632
3581
  generatedTypes = result;
3633
3582
  }
3634
3583
  }
3635
- await context.fs.writeFile(context.dtsPath, `${directives ? `${directives.map((directive) => `/// <reference types="${directive}" />`).join("\n")}
3584
+ await context.fs.write(context.dtsPath, `${directives ? `${directives.map((directive) => `/// <reference types="${directive}" />`).join("\n")}
3636
3585
 
3637
3586
  ` : ""}${getFileHeader(context, {
3638
3587
  directive: null,
@@ -3640,9 +3589,7 @@ ${formatLogMessage(context.config)}`);
3640
3589
  })}
3641
3590
 
3642
3591
  ${formatTypes(generatedTypes)}
3643
- `, {
3644
- mode: "fs"
3645
- });
3592
+ `);
3646
3593
  }
3647
3594
  context.tsconfig = getParsedTypeScriptConfig(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.config.tsconfig);
3648
3595
  if (!context.tsconfig) {
@@ -3710,8 +3657,8 @@ ${formatTypes(generatedTypes)}
3710
3657
  await this.prepare(inlineConfig);
3711
3658
  await this.#executeEnvironments(async (context) => {
3712
3659
  this.context.log(LogLevelLabel.TRACE, "Cleaning the project's dist and artifacts directories.");
3713
- await context.fs.rmdir(joinPaths$1(context.workspaceConfig.workspaceRoot, context.config.output.distPath));
3714
- await context.fs.rmdir(joinPaths$1(context.workspaceConfig.workspaceRoot, context.config.output.artifactsFolder));
3660
+ await context.fs.remove(joinPaths$1(context.workspaceConfig.workspaceRoot, context.config.output.buildPath));
3661
+ await context.fs.remove(joinPaths$1(context.workspaceConfig.workspaceRoot, context.config.output.artifactsPath));
3715
3662
  await callHook(context, "clean", {
3716
3663
  sequential: true
3717
3664
  });
@@ -3753,11 +3700,11 @@ ${formatTypes(generatedTypes)}
3753
3700
  await this.#executeEnvironments(async (context) => {
3754
3701
  await this.callPreHook(context, "build");
3755
3702
  await this.callNormalHook(context, "build");
3756
- if (context.config.output.distPath !== context.config.output.outputPath) {
3757
- const sourcePath = appendPath(context.config.output.distPath, context.workspaceConfig.workspaceRoot);
3703
+ if (context.config.output.buildPath !== context.config.output.outputPath) {
3704
+ const sourcePath = appendPath(context.config.output.buildPath, context.workspaceConfig.workspaceRoot);
3758
3705
  const destinationPath = joinPaths$1(appendPath(context.config.output.outputPath, context.workspaceConfig.workspaceRoot), "dist");
3759
3706
  if (sourcePath !== destinationPath) {
3760
- context.log(LogLevelLabel.INFO, `Copying build output files from project's build directory (${context.config.output.distPath}) to the workspace's output directory (${context.config.output.outputPath}).`);
3707
+ context.log(LogLevelLabel.INFO, `Copying build output files from project's build directory (${context.config.output.buildPath}) to the workspace's output directory (${context.config.output.outputPath}).`);
3761
3708
  await copyFiles({
3762
3709
  input: sourcePath,
3763
3710
  glob: "**/*"
@@ -4087,4 +4034,6 @@ Note: Please ensure the plugin package's default export is a class that extends
4087
4034
  }
4088
4035
  };
4089
4036
 
4090
- export { FileData, FileId, FileMetadata, FileMetadata_KeyValuePair, FileSystem, FileType, PowerlinesAPI, PreserveSignatureType, _capnpFileId, createLog, extendLog };
4037
+ export { FileId, FileMetadata, FileMetadata_KeyValuePair, FileStorage, FileSystem, PowerlinesAPI, _capnpFileId, createLog, extendLog };
4038
+ //# sourceMappingURL=chunk-LQXE5JHF.js.map
4039
+ //# sourceMappingURL=chunk-LQXE5JHF.js.map