powerlines 0.9.0 → 0.10.1

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 (365) hide show
  1. package/dist/astro.cjs +9 -9
  2. package/dist/astro.d.cts +2 -1
  3. package/dist/astro.d.ts +2 -1
  4. package/dist/astro.js +6 -6
  5. package/dist/{chunk-3L4KRPXQ.cjs → chunk-2RHPFVYT.cjs} +17 -18
  6. package/dist/{chunk-VQ5O5N7V.js → chunk-3Y5CCIJR.js} +3 -3
  7. package/dist/{chunk-YE56I7CZ.cjs → chunk-5XYGZ3DC.cjs} +2 -2
  8. package/dist/{chunk-V4TNA6HX.js → chunk-5Y4JYQ66.js} +3 -3
  9. package/dist/{chunk-WM76YQJH.cjs → chunk-66GXB2UY.cjs} +4 -4
  10. package/dist/{chunk-VOB62ELC.js → chunk-6TJGZR5X.js} +4 -4
  11. package/dist/{chunk-OKC6TA7P.js → chunk-6UDHGAAI.js} +3 -3
  12. package/dist/{chunk-ETEQKM36.cjs → chunk-7IWH37DY.cjs} +2 -2
  13. package/dist/{chunk-BDTLKRKQ.js → chunk-EGSEJQCE.js} +3 -3
  14. package/dist/{chunk-ILVCZATT.js → chunk-GPPJ2CRE.js} +2 -2
  15. package/dist/{chunk-RGJMMCOR.js → chunk-HVT7PBFF.js} +3 -3
  16. package/dist/chunk-IJBH5OUN.cjs +12 -0
  17. package/dist/chunk-JBTSAOIQ.js +31 -0
  18. package/dist/{chunk-W3NQCDUN.js → chunk-KYGEWAEG.js} +3 -3
  19. package/dist/{chunk-FOLQTZUP.cjs → chunk-L2SAK2JC.cjs} +4 -4
  20. package/dist/chunk-LXMNDUPG.cjs +12 -0
  21. package/dist/{chunk-GHW2FUF5.js → chunk-N7NE3VOU.js} +4 -4
  22. package/dist/{chunk-OEL3BTQP.js → chunk-OYIM2M74.js} +547 -522
  23. package/dist/{chunk-QK36ULYT.cjs → chunk-QHGPZK2H.cjs} +4 -4
  24. package/dist/chunk-RQ4CHMPO.cjs +12 -0
  25. package/dist/chunk-S5QFX2GM.cjs +12 -0
  26. package/dist/{chunk-IOBFVFH2.js → chunk-S746E63M.js} +3 -3
  27. package/dist/{chunk-MKZOY5EV.js → chunk-SDEBJQDT.js} +12 -13
  28. package/dist/chunk-SL3CXJWD.cjs +34 -0
  29. package/dist/{chunk-KC4VY5X4.cjs → chunk-UHCRNFFC.cjs} +9 -9
  30. package/dist/{chunk-ZQZ5ZUGG.cjs → chunk-UTVZVGM3.cjs} +555 -530
  31. package/dist/{chunk-QIKKQQF7.cjs → chunk-UZQYBO6Z.cjs} +4 -4
  32. package/dist/{chunk-65PSZQFC.js → chunk-VIRKTIPK.js} +3 -3
  33. package/dist/{chunk-UYS3BU6I.js → chunk-WCPY7HPU.js} +4 -4
  34. package/dist/{chunk-MMDBMHAW.js → chunk-WPVIF35O.js} +2 -2
  35. package/dist/chunk-YG7U2GIR.cjs +24 -0
  36. package/dist/{chunk-BY4UTCHZ.cjs → chunk-ZBDP43LG.cjs} +6 -6
  37. package/dist/chunk-ZFATNDSY.cjs +12 -0
  38. package/dist/{chunk-C3I5QEF5.js → chunk-ZU4IRZSQ.js} +7 -7
  39. package/dist/define-config.d.cts +2 -1
  40. package/dist/define-config.d.ts +2 -1
  41. package/dist/esbuild.cjs +8 -8
  42. package/dist/esbuild.d.cts +2 -1
  43. package/dist/esbuild.d.ts +2 -1
  44. package/dist/esbuild.js +5 -5
  45. package/dist/extend-plugin.d.cts +2 -1
  46. package/dist/extend-plugin.d.ts +2 -1
  47. package/dist/farm.cjs +4 -4
  48. package/dist/farm.d.cts +2 -1
  49. package/dist/farm.d.ts +2 -1
  50. package/dist/farm.js +3 -3
  51. package/dist/{hooks-D0gf1nT3.d.ts → hooks-BGYnc61f.d.ts} +1 -1
  52. package/dist/{hooks-fVJu9DCF.d.cts → hooks-gk8S8LFP.d.cts} +1 -1
  53. package/dist/index.cjs +27 -27
  54. package/dist/index.d.cts +4 -3
  55. package/dist/index.d.ts +4 -3
  56. package/dist/index.js +18 -18
  57. package/dist/internal/api.cjs +3 -3
  58. package/dist/internal/api.d.cts +3 -2
  59. package/dist/internal/api.d.ts +3 -2
  60. package/dist/internal/api.js +2 -2
  61. package/dist/lib/build/esbuild.cjs +4 -4
  62. package/dist/lib/build/esbuild.d.cts +2 -1
  63. package/dist/lib/build/esbuild.d.ts +2 -1
  64. package/dist/lib/build/esbuild.js +1 -1
  65. package/dist/lib/build/index.cjs +25 -25
  66. package/dist/lib/build/index.d.cts +3 -2
  67. package/dist/lib/build/index.d.ts +3 -2
  68. package/dist/lib/build/index.js +9 -9
  69. package/dist/lib/build/rolldown.cjs +3 -3
  70. package/dist/lib/build/rolldown.d.cts +2 -1
  71. package/dist/lib/build/rolldown.d.ts +2 -1
  72. package/dist/lib/build/rolldown.js +2 -2
  73. package/dist/lib/build/rollup.cjs +3 -3
  74. package/dist/lib/build/rollup.d.cts +2 -1
  75. package/dist/lib/build/rollup.d.ts +2 -1
  76. package/dist/lib/build/rollup.js +1 -1
  77. package/dist/lib/build/rspack.cjs +2 -2
  78. package/dist/lib/build/rspack.d.cts +2 -1
  79. package/dist/lib/build/rspack.d.ts +2 -1
  80. package/dist/lib/build/rspack.js +1 -1
  81. package/dist/lib/build/tsup.cjs +5 -5
  82. package/dist/lib/build/tsup.d.cts +2 -1
  83. package/dist/lib/build/tsup.d.ts +2 -1
  84. package/dist/lib/build/tsup.js +2 -2
  85. package/dist/lib/build/unbuild.cjs +6 -6
  86. package/dist/lib/build/unbuild.d.cts +3 -2
  87. package/dist/lib/build/unbuild.d.ts +3 -2
  88. package/dist/lib/build/unbuild.js +3 -3
  89. package/dist/lib/build/vite.cjs +4 -4
  90. package/dist/lib/build/vite.d.cts +2 -1
  91. package/dist/lib/build/vite.d.ts +2 -1
  92. package/dist/lib/build/vite.js +2 -2
  93. package/dist/lib/build/webpack.cjs +2 -2
  94. package/dist/lib/build/webpack.d.cts +2 -1
  95. package/dist/lib/build/webpack.d.ts +2 -1
  96. package/dist/lib/build/webpack.js +1 -1
  97. package/dist/lib/{chunk-7CZ2QZEV.js → chunk-3I2YOM2E.js} +4 -4
  98. package/dist/lib/chunk-3I2YOM2E.js.map +1 -0
  99. package/dist/lib/{chunk-KAOWUIFH.cjs → chunk-4XUVP2LL.cjs} +3 -3
  100. package/dist/lib/chunk-4XUVP2LL.cjs.map +1 -0
  101. package/dist/lib/{chunk-ZKYZWEHY.cjs → chunk-6U2UX2PX.cjs} +4 -4
  102. package/dist/lib/chunk-6U2UX2PX.cjs.map +1 -0
  103. package/dist/lib/{chunk-VRNWPH35.cjs → chunk-7EAV6Q7B.cjs} +10 -9
  104. package/dist/lib/chunk-7EAV6Q7B.cjs.map +1 -0
  105. package/dist/lib/{chunk-ZYBUJ2HE.js → chunk-CAPN4FSS.js} +7 -7
  106. package/dist/lib/chunk-CAPN4FSS.js.map +1 -0
  107. package/dist/lib/{chunk-LTBRHAQ2.cjs → chunk-GJNFAFKR.cjs} +4 -4
  108. package/dist/lib/chunk-GJNFAFKR.cjs.map +1 -0
  109. package/dist/lib/{chunk-VANFTXBT.cjs → chunk-GWYTWFZE.cjs} +7 -7
  110. package/dist/lib/chunk-GWYTWFZE.cjs.map +1 -0
  111. package/dist/lib/{chunk-DKE25WTL.js → chunk-HQ6TGY34.js} +2 -2
  112. package/dist/lib/chunk-HQ6TGY34.js.map +1 -0
  113. package/dist/lib/{chunk-QSBORJCS.js → chunk-HZDOJWUO.js} +6 -6
  114. package/dist/lib/chunk-HZDOJWUO.js.map +1 -0
  115. package/dist/lib/{chunk-ECJPGNXE.cjs → chunk-IK3ABDPP.cjs} +2 -2
  116. package/dist/lib/chunk-IK3ABDPP.cjs.map +1 -0
  117. package/dist/lib/{chunk-G5DJO4HA.cjs → chunk-JTUL3477.cjs} +5 -5
  118. package/dist/lib/chunk-JTUL3477.cjs.map +1 -0
  119. package/dist/lib/{chunk-E7UTFXPP.js → chunk-KFE2IR3Y.js} +4 -4
  120. package/dist/lib/chunk-KFE2IR3Y.js.map +1 -0
  121. package/dist/lib/{chunk-RY67J24J.js → chunk-KSBESEOF.js} +2 -2
  122. package/dist/lib/chunk-KSBESEOF.js.map +1 -0
  123. package/dist/lib/{chunk-26W3IQT6.js → chunk-LTVWU4J2.js} +5 -5
  124. package/dist/lib/chunk-LTVWU4J2.js.map +1 -0
  125. package/dist/lib/{chunk-GWAVDFOE.js → chunk-M7U5RMK7.js} +8 -6
  126. package/dist/lib/chunk-M7U5RMK7.js.map +1 -0
  127. package/dist/lib/{chunk-YQG6JE5R.cjs → chunk-M7WHFUKR.cjs} +549 -527
  128. package/dist/lib/chunk-M7WHFUKR.cjs.map +1 -0
  129. package/dist/lib/{chunk-EOO7IRCI.js → chunk-MAHHHINV.js} +3 -3
  130. package/dist/lib/chunk-MAHHHINV.js.map +1 -0
  131. package/dist/lib/{chunk-7FQQFIHR.cjs → chunk-NANLYIUO.cjs} +4 -4
  132. package/dist/lib/chunk-NANLYIUO.cjs.map +1 -0
  133. package/dist/lib/{chunk-TNCZYSNV.js → chunk-NE46WXNJ.js} +2 -2
  134. package/dist/lib/chunk-NE46WXNJ.js.map +1 -0
  135. package/dist/lib/{chunk-QGJVGFY4.js → chunk-OF5IJ4WG.js} +6 -6
  136. package/dist/lib/chunk-OF5IJ4WG.js.map +1 -0
  137. package/dist/lib/{chunk-6IEUZ5DZ.js → chunk-PIFE7MUZ.js} +525 -503
  138. package/dist/lib/chunk-PIFE7MUZ.js.map +1 -0
  139. package/dist/lib/{chunk-2ZYHO243.js → chunk-PXSRMP4E.js} +2 -2
  140. package/dist/lib/chunk-PXSRMP4E.js.map +1 -0
  141. package/dist/lib/{chunk-CXYZENE4.js → chunk-Q2L3FNJO.js} +13 -7
  142. package/dist/lib/chunk-Q2L3FNJO.js.map +1 -0
  143. package/dist/lib/{chunk-XFIGAAKN.cjs → chunk-Q2RUDKWY.cjs} +8 -6
  144. package/dist/lib/chunk-Q2RUDKWY.cjs.map +1 -0
  145. package/dist/lib/{chunk-NFDRIBCM.js → chunk-Q3KJZ3B5.js} +5 -7
  146. package/dist/lib/chunk-Q3KJZ3B5.js.map +1 -0
  147. package/dist/lib/{chunk-FHZJQZOE.cjs → chunk-QXJHCA3E.cjs} +7 -7
  148. package/dist/lib/chunk-QXJHCA3E.cjs.map +1 -0
  149. package/dist/lib/{chunk-TZFBE35T.cjs → chunk-RQICHHZM.cjs} +2 -2
  150. package/dist/lib/chunk-RQICHHZM.cjs.map +1 -0
  151. package/dist/lib/{chunk-7MXG5EG2.js → chunk-RXQWNSZX.js} +3 -3
  152. package/dist/lib/chunk-RXQWNSZX.js.map +1 -0
  153. package/dist/lib/{chunk-I6A564OE.cjs → chunk-U36VZLW6.cjs} +2 -2
  154. package/dist/lib/chunk-U36VZLW6.cjs.map +1 -0
  155. package/dist/lib/{chunk-65DUUIIF.cjs → chunk-UQJWVRRE.cjs} +2 -2
  156. package/dist/lib/chunk-UQJWVRRE.cjs.map +1 -0
  157. package/dist/lib/{chunk-XHCRXNQ3.cjs → chunk-V5OY4ALI.cjs} +5 -5
  158. package/dist/lib/chunk-V5OY4ALI.cjs.map +1 -0
  159. package/dist/lib/{chunk-I3I4BYJ4.js → chunk-VJN72T2O.js} +5 -5
  160. package/dist/lib/chunk-VJN72T2O.js.map +1 -0
  161. package/dist/lib/{chunk-KACTPBW2.cjs → chunk-W4OMKQ7W.cjs} +14 -8
  162. package/dist/lib/chunk-W4OMKQ7W.cjs.map +1 -0
  163. package/dist/lib/{chunk-SB3NFYXT.cjs → chunk-XZD7S5TU.cjs} +5 -5
  164. package/dist/lib/chunk-XZD7S5TU.cjs.map +1 -0
  165. package/dist/lib/{chunk-PJKWY74P.js → chunk-YBIWVB66.js} +10 -9
  166. package/dist/lib/chunk-YBIWVB66.js.map +1 -0
  167. package/dist/lib/{chunk-JXIRUV56.js → chunk-YF3YHK4X.js} +5 -5
  168. package/dist/lib/chunk-YF3YHK4X.js.map +1 -0
  169. package/dist/lib/{chunk-TJQEGHJA.cjs → chunk-YVDJCVE5.cjs} +12 -12
  170. package/dist/lib/chunk-YVDJCVE5.cjs.map +1 -0
  171. package/dist/lib/{chunk-M2TB43VG.cjs → chunk-ZP7PDTVE.cjs} +7 -9
  172. package/dist/lib/chunk-ZP7PDTVE.cjs.map +1 -0
  173. package/dist/lib/{config-BOPIY57U.d.cts → config-AuIGsUck.d.cts} +110 -106
  174. package/dist/lib/{config-Chd_3Uh3.d.ts → config-B_WTwd49.d.ts} +110 -106
  175. package/dist/lib/config-file.d.cts +2 -1
  176. package/dist/lib/config-file.d.ts +2 -1
  177. package/dist/lib/entry.d.cts +2 -1
  178. package/dist/lib/entry.d.ts +2 -1
  179. package/dist/lib/{hooks-DkVRKYVN.d.cts → hooks-4KkL9GD2.d.cts} +1 -1
  180. package/dist/lib/{hooks-56fQP2HY.d.ts → hooks-DErK4Fv4.d.ts} +1 -1
  181. package/dist/lib/index.cjs +36 -36
  182. package/dist/lib/index.d.cts +3 -2
  183. package/dist/lib/index.d.ts +3 -2
  184. package/dist/lib/index.js +11 -11
  185. package/dist/lib/logger.d.cts +2 -1
  186. package/dist/lib/logger.d.ts +2 -1
  187. package/dist/lib/typescript/compiler-host.cjs +6 -6
  188. package/dist/lib/typescript/compiler-host.cjs.map +1 -1
  189. package/dist/lib/typescript/compiler-host.d.cts +2 -1
  190. package/dist/lib/typescript/compiler-host.d.ts +2 -1
  191. package/dist/lib/typescript/compiler-host.js +5 -5
  192. package/dist/lib/typescript/compiler-host.js.map +1 -1
  193. package/dist/lib/typescript/import-transformer.cjs +1 -1
  194. package/dist/lib/typescript/import-transformer.cjs.map +1 -1
  195. package/dist/lib/typescript/import-transformer.d.cts +2 -1
  196. package/dist/lib/typescript/import-transformer.d.ts +2 -1
  197. package/dist/lib/typescript/import-transformer.js +1 -1
  198. package/dist/lib/typescript/import-transformer.js.map +1 -1
  199. package/dist/lib/typescript/index.cjs +6 -6
  200. package/dist/lib/typescript/index.d.cts +2 -1
  201. package/dist/lib/typescript/index.d.ts +2 -1
  202. package/dist/lib/typescript/index.js +1 -1
  203. package/dist/lib/typescript/program.cjs +6 -6
  204. package/dist/lib/typescript/program.d.cts +2 -1
  205. package/dist/lib/typescript/program.d.ts +2 -1
  206. package/dist/lib/typescript/program.js +1 -1
  207. package/dist/lib/unplugin/factory.cjs +6 -6
  208. package/dist/lib/unplugin/factory.d.cts +3 -2
  209. package/dist/lib/unplugin/factory.d.ts +3 -2
  210. package/dist/lib/unplugin/factory.js +5 -5
  211. package/dist/lib/unplugin/index.cjs +9 -9
  212. package/dist/lib/unplugin/index.d.cts +3 -2
  213. package/dist/lib/unplugin/index.d.ts +3 -2
  214. package/dist/lib/unplugin/index.js +6 -6
  215. package/dist/lib/unplugin/plugin.cjs +4 -4
  216. package/dist/lib/unplugin/plugin.d.cts +2 -1
  217. package/dist/lib/unplugin/plugin.d.ts +2 -1
  218. package/dist/lib/unplugin/plugin.js +3 -3
  219. package/dist/lib/unplugin/resolve-id.cjs +2 -2
  220. package/dist/lib/unplugin/resolve-id.d.cts +2 -1
  221. package/dist/lib/unplugin/resolve-id.d.ts +2 -1
  222. package/dist/lib/unplugin/resolve-id.js +1 -1
  223. package/dist/lib/utilities/cache.cjs +4 -4
  224. package/dist/lib/utilities/cache.js +2 -2
  225. package/dist/lib/utilities/file-header.d.cts +2 -1
  226. package/dist/lib/utilities/file-header.d.ts +2 -1
  227. package/dist/lib/utilities/index.cjs +24 -24
  228. package/dist/lib/utilities/index.d.cts +2 -1
  229. package/dist/lib/utilities/index.d.ts +2 -1
  230. package/dist/lib/utilities/index.js +7 -7
  231. package/dist/lib/utilities/meta.cjs +8 -8
  232. package/dist/lib/utilities/meta.d.cts +2 -1
  233. package/dist/lib/utilities/meta.d.ts +2 -1
  234. package/dist/lib/utilities/meta.js +1 -1
  235. package/dist/lib/utilities/plugin-helpers.d.cts +2 -1
  236. package/dist/lib/utilities/plugin-helpers.d.ts +2 -1
  237. package/dist/lib/utilities/resolve-path.cjs +2 -2
  238. package/dist/lib/utilities/resolve-path.d.cts +2 -1
  239. package/dist/lib/utilities/resolve-path.d.ts +2 -1
  240. package/dist/lib/utilities/resolve-path.js +1 -1
  241. package/dist/lib/utilities/source-file.cjs +4 -4
  242. package/dist/lib/utilities/source-file.js +1 -1
  243. package/dist/lib/utilities/source-map.cjs +2 -2
  244. package/dist/lib/utilities/source-map.js +1 -1
  245. package/dist/lib/utilities/worker.cjs +3 -3
  246. package/dist/lib/utilities/worker.d.cts +2 -1
  247. package/dist/lib/utilities/worker.d.ts +2 -1
  248. package/dist/lib/utilities/worker.js +1 -1
  249. package/dist/lib/utilities/write-file.cjs +2 -2
  250. package/dist/lib/utilities/write-file.d.cts +2 -1
  251. package/dist/lib/utilities/write-file.d.ts +2 -1
  252. package/dist/lib/utilities/write-file.js +1 -1
  253. package/dist/next.cjs +8 -8
  254. package/dist/next.js +5 -5
  255. package/dist/nuxt.cjs +10 -10
  256. package/dist/nuxt.js +7 -7
  257. package/dist/{resolved-NZTd64-O.d.cts → resolved-CcuVqMqc.d.cts} +28 -3
  258. package/dist/{resolved-DhHHMnUD.d.ts → resolved-Dhscmo3z.d.ts} +28 -3
  259. package/dist/rolldown.cjs +7 -7
  260. package/dist/rolldown.d.cts +2 -1
  261. package/dist/rolldown.d.ts +2 -1
  262. package/dist/rolldown.js +4 -4
  263. package/dist/rollup.cjs +7 -7
  264. package/dist/rollup.d.cts +2 -1
  265. package/dist/rollup.d.ts +2 -1
  266. package/dist/rollup.js +4 -4
  267. package/dist/rspack.cjs +7 -7
  268. package/dist/rspack.d.cts +2 -1
  269. package/dist/rspack.d.ts +2 -1
  270. package/dist/rspack.js +4 -4
  271. package/dist/tsup.cjs +9 -9
  272. package/dist/tsup.js +6 -6
  273. package/dist/types/babel.d.cts +2 -1
  274. package/dist/types/babel.d.ts +2 -1
  275. package/dist/types/commands.d.cts +2 -1
  276. package/dist/types/commands.d.ts +2 -1
  277. package/dist/types/compiler.d.cts +2 -1
  278. package/dist/types/compiler.d.ts +2 -1
  279. package/dist/types/config.d.cts +2 -1
  280. package/dist/types/config.d.ts +2 -1
  281. package/dist/types/context.cjs +2 -2
  282. package/dist/types/context.d.cts +2 -1
  283. package/dist/types/context.d.ts +2 -1
  284. package/dist/types/context.js +1 -1
  285. package/dist/types/hooks.d.cts +2 -1
  286. package/dist/types/hooks.d.ts +2 -1
  287. package/dist/types/index.cjs +9 -9
  288. package/dist/types/index.d.cts +3 -2
  289. package/dist/types/index.d.ts +3 -2
  290. package/dist/types/index.js +2 -2
  291. package/dist/types/internal.d.cts +3 -2
  292. package/dist/types/internal.d.ts +3 -2
  293. package/dist/types/plugin.d.cts +2 -1
  294. package/dist/types/plugin.d.ts +2 -1
  295. package/dist/types/resolved.d.cts +2 -1
  296. package/dist/types/resolved.d.ts +2 -1
  297. package/dist/types/unplugin.d.cts +2 -1
  298. package/dist/types/unplugin.d.ts +2 -1
  299. package/dist/types/vfs.cjs +7 -7
  300. package/dist/types/vfs.d.cts +93 -111
  301. package/dist/types/vfs.d.ts +93 -111
  302. package/dist/types/vfs.js +1 -1
  303. package/dist/unloader.cjs +7 -7
  304. package/dist/unloader.d.cts +2 -1
  305. package/dist/unloader.d.ts +2 -1
  306. package/dist/unloader.js +4 -4
  307. package/dist/unplugin.cjs +19 -19
  308. package/dist/unplugin.d.cts +3 -2
  309. package/dist/unplugin.d.ts +3 -2
  310. package/dist/unplugin.js +16 -16
  311. package/dist/vite.cjs +8 -8
  312. package/dist/vite.d.cts +2 -1
  313. package/dist/vite.d.ts +2 -1
  314. package/dist/vite.js +5 -5
  315. package/dist/webpack.cjs +7 -7
  316. package/dist/webpack.d.cts +2 -1
  317. package/dist/webpack.d.ts +2 -1
  318. package/dist/webpack.js +4 -4
  319. package/package.json +9 -9
  320. package/dist/chunk-4JUWHOFJ.cjs +0 -12
  321. package/dist/chunk-ARHKVB3S.cjs +0 -12
  322. package/dist/chunk-JCXSBKRJ.js +0 -31
  323. package/dist/chunk-NRMXL6VA.cjs +0 -34
  324. package/dist/chunk-QKXJRYA5.cjs +0 -12
  325. package/dist/chunk-STLRGAW6.cjs +0 -24
  326. package/dist/chunk-TJIHTRP5.cjs +0 -12
  327. package/dist/chunk-VES34CLG.cjs +0 -12
  328. package/dist/lib/chunk-26W3IQT6.js.map +0 -1
  329. package/dist/lib/chunk-2ZYHO243.js.map +0 -1
  330. package/dist/lib/chunk-65DUUIIF.cjs.map +0 -1
  331. package/dist/lib/chunk-6IEUZ5DZ.js.map +0 -1
  332. package/dist/lib/chunk-7CZ2QZEV.js.map +0 -1
  333. package/dist/lib/chunk-7FQQFIHR.cjs.map +0 -1
  334. package/dist/lib/chunk-7MXG5EG2.js.map +0 -1
  335. package/dist/lib/chunk-CXYZENE4.js.map +0 -1
  336. package/dist/lib/chunk-DKE25WTL.js.map +0 -1
  337. package/dist/lib/chunk-E7UTFXPP.js.map +0 -1
  338. package/dist/lib/chunk-ECJPGNXE.cjs.map +0 -1
  339. package/dist/lib/chunk-EOO7IRCI.js.map +0 -1
  340. package/dist/lib/chunk-FHZJQZOE.cjs.map +0 -1
  341. package/dist/lib/chunk-G5DJO4HA.cjs.map +0 -1
  342. package/dist/lib/chunk-GWAVDFOE.js.map +0 -1
  343. package/dist/lib/chunk-I3I4BYJ4.js.map +0 -1
  344. package/dist/lib/chunk-I6A564OE.cjs.map +0 -1
  345. package/dist/lib/chunk-JXIRUV56.js.map +0 -1
  346. package/dist/lib/chunk-KACTPBW2.cjs.map +0 -1
  347. package/dist/lib/chunk-KAOWUIFH.cjs.map +0 -1
  348. package/dist/lib/chunk-LTBRHAQ2.cjs.map +0 -1
  349. package/dist/lib/chunk-M2TB43VG.cjs.map +0 -1
  350. package/dist/lib/chunk-NFDRIBCM.js.map +0 -1
  351. package/dist/lib/chunk-PJKWY74P.js.map +0 -1
  352. package/dist/lib/chunk-QGJVGFY4.js.map +0 -1
  353. package/dist/lib/chunk-QSBORJCS.js.map +0 -1
  354. package/dist/lib/chunk-RY67J24J.js.map +0 -1
  355. package/dist/lib/chunk-SB3NFYXT.cjs.map +0 -1
  356. package/dist/lib/chunk-TJQEGHJA.cjs.map +0 -1
  357. package/dist/lib/chunk-TNCZYSNV.js.map +0 -1
  358. package/dist/lib/chunk-TZFBE35T.cjs.map +0 -1
  359. package/dist/lib/chunk-VANFTXBT.cjs.map +0 -1
  360. package/dist/lib/chunk-VRNWPH35.cjs.map +0 -1
  361. package/dist/lib/chunk-XFIGAAKN.cjs.map +0 -1
  362. package/dist/lib/chunk-XHCRXNQ3.cjs.map +0 -1
  363. package/dist/lib/chunk-YQG6JE5R.cjs.map +0 -1
  364. package/dist/lib/chunk-ZKYZWEHY.cjs.map +0 -1
  365. package/dist/lib/chunk-ZYBUJ2HE.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import { PLUGIN_NON_HOOK_FIELDS } from './chunk-EBMELFCF.js';
2
- import { __VFS_CACHE__, __VFS_RESOLVER__, __VFS_VIRTUAL__, __VFS_UNIFIED__, __VFS_INIT__, __VFS_REVERT__ } from './chunk-ILVCZATT.js';
2
+ import { __VFS_CACHE__, __VFS_RESOLVER__, __VFS_VIRTUAL__, __VFS_UNIFIED__, __VFS_INIT__, __VFS_REVERT__ } from './chunk-GPPJ2CRE.js';
3
3
  import { SUPPORTED_COMMANDS } from './chunk-LO77RPRV.js';
4
4
  import { __name } from './chunk-7QVYU63E.js';
5
5
  import { formatLogMessage } from '@storm-software/config-tools/logger/console';
@@ -11,8 +11,6 @@ import { createDirectory } from '@stryke/fs/helpers';
11
11
  import { install } from '@stryke/fs/install';
12
12
  import { listFiles, listFilesSync } from '@stryke/fs/list-files';
13
13
  import { isPackageExists, isPackageListed, doesPackageMatch, getPackageListing } from '@stryke/fs/package-fns';
14
- import { findFilePath, hasFileExtension, findFileExtensionSafe, relativePath, findFileName } from '@stryke/path/file-path-fns';
15
- import { isParentPath } from '@stryke/path/is-parent-path';
16
14
  import { joinPaths } from '@stryke/path/join-paths';
17
15
  import { replacePath } from '@stryke/path/replace';
18
16
  import { isError } from '@stryke/type-checks/is-error';
@@ -28,21 +26,23 @@ import { readJsonFile, readJsonFileSync } from '@stryke/fs/json';
28
26
  import { appendPath } from '@stryke/path/append';
29
27
  import defu5, { defu } from 'defu';
30
28
  import ts2, { createProgram, createCompilerHost, getPreEmitDiagnostics, getLineAndCharacterOfPosition, flattenDiagnosticMessageText } from 'typescript';
31
- import { titleCase } from '@stryke/string-format/title-case';
32
29
  import '@stryke/fs/remove-file';
33
30
  import { hashDirectory } from '@stryke/hash/hash-files';
34
31
  import { getUnique, getUniqueBy } from '@stryke/helpers/get-unique';
32
+ import { findFilePath, findFileExtensionSafe, hasFileExtension, relativePath, findFileName } from '@stryke/path/file-path-fns';
35
33
  import { kebabCase } from '@stryke/string-format/kebab-case';
36
34
  import { isUndefined } from '@stryke/type-checks/is-undefined';
37
35
  import { writeFile as writeFile$1 } from '@stryke/fs/write-file';
38
- import { format, resolveConfig } from 'prettier';
36
+ import { resolveConfig, format } from 'prettier';
39
37
  import { resolvePackage } from '@stryke/fs/resolve';
40
38
  import { getWorkspaceConfig } from '@storm-software/config-tools/get-config';
41
39
  import { loadConfig } from 'c12';
40
+ import { titleCase } from '@stryke/string-format/title-case';
42
41
  import { getEnvPaths } from '@stryke/env/get-env-paths';
43
42
  import { relativeToWorkspaceRoot } from '@stryke/fs/get-workspace-root';
44
43
  import { murmurhash } from '@stryke/hash/murmurhash';
45
44
  import { omit } from '@stryke/helpers/omit';
45
+ import { isAbsolutePath, isAbsolute } from '@stryke/path/is-type';
46
46
  import { joinPaths as joinPaths$1 } from '@stryke/path/join';
47
47
  import { isNull } from '@stryke/type-checks/is-null';
48
48
  import { isString } from '@stryke/type-checks/is-string';
@@ -54,7 +54,7 @@ import { getColor } from '@storm-software/config-tools/utilities/colors';
54
54
  import { noop } from '@stryke/helpers/noop';
55
55
  import { createJiti } from 'jiti';
56
56
  import { bufferToString } from '@stryke/convert/buffer-to-string';
57
- import { isAbsolutePath } from '@stryke/path/is-type';
57
+ import { isParentPath } from '@stryke/path/is-parent-path';
58
58
  import { prettyBytes } from '@stryke/string-format/pretty-bytes';
59
59
  import { isBuffer } from '@stryke/type-checks/is-buffer';
60
60
  import { Volume } from 'memfs';
@@ -154,26 +154,6 @@ ${parsedCommandLine.errors.map((error) => `- ${(error.category !== void 0 && err
154
154
  };
155
155
  }
156
156
  __name(getParsedTypeScriptConfig, "getParsedTypeScriptConfig");
157
- function getBaseFileHeader(context) {
158
- return `
159
- // Generated with ${titleCase(context.config.framework)}
160
- // Note: Do not edit this file manually - it will be overwritten automatically
161
- `;
162
- }
163
- __name(getBaseFileHeader, "getBaseFileHeader");
164
- function getFileHeader(context, options = {}) {
165
- const { directive = null, prettierIgnore = false } = options;
166
- return `/* eslint-disable */
167
- // biome-ignore lint: disable
168
- ${prettierIgnore ? `// prettier-ignore` : ""}${directive ? `
169
-
170
- ${directive}
171
- ` : "\n"}
172
- ${getBaseFileHeader(context)}
173
-
174
- `;
175
- }
176
- __name(getFileHeader, "getFileHeader");
177
157
  var PROJECT_ROOT_HASH_LENGTH = 45;
178
158
  var CACHE_HASH_LENGTH = 62;
179
159
  function getPrefixedProjectRootHash(name, projectRootHash) {
@@ -198,11 +178,13 @@ __name(getChecksum, "getChecksum");
198
178
  async function writeMetaFile(context) {
199
179
  const metaFilePath = joinPaths(context.dataPath, "meta.json");
200
180
  context.log(LogLevelLabel.DEBUG, `Writing runtime metadata to ${metaFilePath}`);
201
- await context.fs.writeFileToDisk(metaFilePath, JSON.stringify({
181
+ await context.fs.writeFile(metaFilePath, JSON.stringify({
202
182
  ...context.meta,
203
- builtinIdMap: Object.fromEntries(context.fs.builtinIdMap.entries()),
204
- virtualFiles: context.fs[__VFS_VIRTUAL__].toJSON(context.artifactsPath)
205
- }, null, 2));
183
+ virtualFiles: context.fs[__VFS_VIRTUAL__].toJSON(context.artifactsPath),
184
+ virtualFilesMeta: context.fs.getPartialMeta()
185
+ }, null, 2), {
186
+ mode: "fs"
187
+ });
206
188
  }
207
189
  __name(writeMetaFile, "writeMetaFile");
208
190
  function isPlugin(value) {
@@ -468,6 +450,154 @@ function createResolver(options) {
468
450
  return baseResolver;
469
451
  }
470
452
  __name(createResolver, "createResolver");
453
+ function isBufferEncoding(options) {
454
+ return isSetString(options) || options === null;
455
+ }
456
+ __name(isBufferEncoding, "isBufferEncoding");
457
+ function isPowerlinesWriteFileOptions(options) {
458
+ return !isBufferEncoding(options) && isSetObject(options) && ("skipFormat" in options || "mode" in options && (options.mode === "fs" || options.mode === "virtual"));
459
+ }
460
+ __name(isPowerlinesWriteFileOptions, "isPowerlinesWriteFileOptions");
461
+ function isNodeWriteFileOptions(options) {
462
+ return !isUndefined(options) && (isBufferEncoding(options) || !isPowerlinesWriteFileOptions(options));
463
+ }
464
+ __name(isNodeWriteFileOptions, "isNodeWriteFileOptions");
465
+ function isPowerLinesWriteFileData(data) {
466
+ return !!(isSetObject(data) && "code" in data && data.code);
467
+ }
468
+ __name(isPowerLinesWriteFileData, "isPowerLinesWriteFileData");
469
+ var FILE_PREFIX = "file://";
470
+ function toFilePath(pathOrUrl) {
471
+ if (!pathOrUrl) {
472
+ throw new Error("No Path or URL provided to Virtual File System");
473
+ }
474
+ let result = pathOrUrl.toString();
475
+ if (result.startsWith(FILE_PREFIX)) {
476
+ result = result.slice(FILE_PREFIX.length);
477
+ }
478
+ return result;
479
+ }
480
+ __name(toFilePath, "toFilePath");
481
+ var FS_METHODS = [
482
+ "mkdir",
483
+ "mkdirSync",
484
+ "rmdir",
485
+ "rmdirSync",
486
+ "unlink",
487
+ "unlinkSync",
488
+ "existsSync",
489
+ "realpathSync",
490
+ "writeFileSync",
491
+ "readFileSync",
492
+ "readdirSync",
493
+ "createWriteStream",
494
+ "WriteStream",
495
+ "createReadStream",
496
+ "ReadStream"
497
+ ];
498
+ var FS_PROMISE_METHODS = [
499
+ "mkdir",
500
+ "rm",
501
+ "rmdir",
502
+ "unlink",
503
+ "writeFile",
504
+ "readFile",
505
+ "readdir",
506
+ "stat",
507
+ "lstat"
508
+ ];
509
+ function cloneFS(originalFS) {
510
+ const clonedFS = {
511
+ ...originalFS,
512
+ promises: {
513
+ ...originalFS.promises ?? {}
514
+ }
515
+ };
516
+ for (const method of FS_METHODS) {
517
+ if (originalFS[method]) {
518
+ clonedFS[method] = originalFS[method];
519
+ }
520
+ }
521
+ originalFS.promises ??= {};
522
+ for (const method of FS_PROMISE_METHODS) {
523
+ if (originalFS.promises[method]) {
524
+ clonedFS.promises ??= {};
525
+ clonedFS.promises[method] = originalFS.promises[method];
526
+ clonedFS[method] = originalFS.promises[method];
527
+ }
528
+ }
529
+ for (const prop in clonedFS) {
530
+ if (isFunction(clonedFS[prop])) {
531
+ clonedFS[prop] = clonedFS[prop].bind(originalFS);
532
+ if (isFunction(clonedFS.promises[prop])) {
533
+ clonedFS.promises[prop] = clonedFS.promises[prop].bind(originalFS);
534
+ }
535
+ }
536
+ }
537
+ for (const prop in clonedFS.promises) {
538
+ if (isFunction(clonedFS.promises[prop])) {
539
+ clonedFS.promises[prop] = clonedFS.promises[prop].bind(originalFS);
540
+ }
541
+ }
542
+ return clonedFS;
543
+ }
544
+ __name(cloneFS, "cloneFS");
545
+ function patchFS(originalFS, vfs) {
546
+ const clonedFS = cloneFS(originalFS);
547
+ originalFS.mkdirSync = (file, options) => vfs.mkdirSync(toFilePath(file), options);
548
+ originalFS.mkdir = (file, options, callback) => vfs.mkdir(toFilePath(file), options, callback);
549
+ originalFS.promises.mkdir = async (file, options) => vfs.mkdir(toFilePath(file), options);
550
+ originalFS.unlinkSync = (file) => vfs.unlinkSync(toFilePath(file));
551
+ originalFS.promises.rm = async (file, options) => vfs.rm(toFilePath(file), options);
552
+ originalFS.promises.unlink = async (file) => vfs.unlink(toFilePath(file));
553
+ originalFS.existsSync = (file) => vfs.existsSync(toFilePath(file));
554
+ Object.defineProperty(originalFS, "realpathSync", {
555
+ value: /* @__PURE__ */ __name((file, options) => vfs.realpathSync(toFilePath(file), options), "value")
556
+ });
557
+ originalFS.writeFileSync = (file, data, options) => vfs.writeFileSync(toFilePath(file), data, options);
558
+ originalFS.promises.writeFile = async (file, data, options) => vfs.writeFile(toFilePath(file), data, options);
559
+ originalFS.readFileSync = (file, options) => vfs.readFileSync(toFilePath(file), options);
560
+ originalFS.promises.readFile = (file, options) => vfs.readFile(toFilePath(file), options);
561
+ originalFS.readdirSync = (file, options) => vfs.readdirSync(toFilePath(file), options);
562
+ originalFS.promises.readdir = (file, options) => vfs.readdir(toFilePath(file), options);
563
+ Object.defineProperty(originalFS, "statSync", {
564
+ value: /* @__PURE__ */ __name((file, options) => vfs.statSync(toFilePath(file), options), "value")
565
+ });
566
+ originalFS.stat = (file, options) => vfs.statSync(toFilePath(file), options);
567
+ originalFS.promises.stat = (file, options) => vfs.stat(toFilePath(file), options);
568
+ Object.defineProperty(originalFS, "lstatSync", {
569
+ value: /* @__PURE__ */ __name((file, options) => vfs.lstatSync(toFilePath(file), options), "value")
570
+ });
571
+ originalFS.lstat = (file, options) => vfs.lstatSync(toFilePath(file), options);
572
+ originalFS.promises.lstat = (file, options) => vfs.lstat(toFilePath(file), options);
573
+ return () => {
574
+ originalFS.mkdirSync = clonedFS.mkdirSync;
575
+ originalFS.mkdir = clonedFS.mkdir;
576
+ originalFS.promises.mkdir = clonedFS.promises.mkdir;
577
+ originalFS.unlinkSync = clonedFS.unlinkSync;
578
+ originalFS.promises.rm = clonedFS.promises.rm;
579
+ originalFS.promises.unlink = clonedFS.promises.unlink;
580
+ originalFS.existsSync = clonedFS.existsSync;
581
+ originalFS.realpathSync = clonedFS.realpathSync;
582
+ originalFS.writeFileSync = clonedFS.writeFileSync;
583
+ originalFS.promises.writeFile = clonedFS.promises.writeFile;
584
+ originalFS.readFileSync = clonedFS.readFileSync;
585
+ originalFS.promises.readFile = clonedFS.promises.readFile;
586
+ originalFS.readdirSync = clonedFS.readdirSync;
587
+ originalFS.promises.readdir = clonedFS.promises.readdir;
588
+ Object.defineProperty(originalFS, "statSync", {
589
+ value: clonedFS.statSync
590
+ });
591
+ originalFS.stat = clonedFS.stat;
592
+ originalFS.promises.stat = clonedFS.promises.stat;
593
+ Object.defineProperty(originalFS, "lstatSync", {
594
+ value: clonedFS.lstatSync
595
+ });
596
+ originalFS.lstat = clonedFS.lstat;
597
+ originalFS.promises.lstat = clonedFS.promises.lstat;
598
+ };
599
+ }
600
+ __name(patchFS, "patchFS");
471
601
  var VirtualFileSystem = class {
472
602
  static {
473
603
  __name(this, "VirtualFileSystem");
@@ -475,7 +605,11 @@ var VirtualFileSystem = class {
475
605
  /**
476
606
  * The internal map of virtual files.
477
607
  */
478
- #builtinIdMap = /* @__PURE__ */ new Map();
608
+ #meta = {};
609
+ /**
610
+ * A map of unique identifiers to their virtual file paths.
611
+ */
612
+ #ids = {};
479
613
  /**
480
614
  * A map of virtual file paths to their underlying file content.
481
615
  */
@@ -516,6 +650,16 @@ var VirtualFileSystem = class {
516
650
  */
517
651
  #log;
518
652
  /**
653
+ * Checks if a path exists in the virtual file system (VFS).
654
+ *
655
+ * @param path - The path to check.
656
+ * @returns `true` if the path exists, otherwise `false`.
657
+ */
658
+ #existsSync(path) {
659
+ const formattedPath = this.formatPath(path);
660
+ return this.#virtualFS.existsSync(formattedPath) || this.#fs.existsSync(formattedPath) || this.resolveFS(path).existsSync(formattedPath);
661
+ }
662
+ /**
519
663
  * Exposes the internal VFS map for advanced usage.
520
664
  */
521
665
  get [__VFS_CACHE__]() {
@@ -540,15 +684,54 @@ var VirtualFileSystem = class {
540
684
  return this.#unifiedFS;
541
685
  }
542
686
  /**
687
+ * A proxy to access the underlying file metadata.
688
+ */
689
+ get meta() {
690
+ return new Proxy(this.#meta, {
691
+ get: /* @__PURE__ */ __name((target, prop) => {
692
+ if (target[prop]) {
693
+ return {
694
+ id: prop,
695
+ mode: this.#virtualFS.existsSync(prop) ? "virtual" : this.#fs.existsSync(prop) ? "fs" : this.#context.config.output.mode,
696
+ details: {},
697
+ variant: "normal",
698
+ ...target[prop]
699
+ };
700
+ }
701
+ return void 0;
702
+ }, "get"),
703
+ set: /* @__PURE__ */ __name((target, prop, value) => {
704
+ target[prop] = value;
705
+ this.#ids[value.id || prop] = prop;
706
+ return true;
707
+ }, "set"),
708
+ deleteProperty: /* @__PURE__ */ __name((target, prop) => {
709
+ delete this.#ids[target[prop]?.id || prop];
710
+ delete target[prop];
711
+ return true;
712
+ }, "deleteProperty")
713
+ });
714
+ }
715
+ /**
716
+ * A map of module ids to their file paths.
717
+ */
718
+ get ids() {
719
+ return this.#ids;
720
+ }
721
+ /**
543
722
  * Creates a new instance of the VirtualFileSystem.
544
723
  *
545
724
  * @param context - The context of the virtual file system, typically containing options and logging functions.
546
725
  * @param serialized - A map of files/file contents to populate in cache
547
726
  */
548
- constructor(context, serialized) {
727
+ constructor(context, serialized = {}) {
549
728
  this.#context = context;
550
729
  this.#cachedFS = /* @__PURE__ */ new Map();
551
- this.#builtinIdMap = new Map(Object.entries(serialized?.builtinIdMap ?? {}));
730
+ this.#meta = Object.fromEntries(Object.entries(serialized.virtualFilesMeta ?? {}));
731
+ this.#ids = Object.fromEntries(Object.entries(this.#meta).map(([path, data]) => [
732
+ data.id || path,
733
+ path
734
+ ]));
552
735
  if (!this.#fs.existsSync(this.#context.dataPath)) {
553
736
  this.#fs.mkdirSync(this.#context.dataPath, {
554
737
  recursive: true
@@ -630,65 +813,44 @@ var VirtualFileSystem = class {
630
813
  }
631
814
  }
632
815
  /**
633
- * Returns a Map of all runtime file IDs and their corresponding paths in the virtual file system.
634
- *
635
- * @returns A Map where the keys are runtime file IDs (strings) and the values are their corresponding paths (strings).
636
- */
637
- get builtinIdMap() {
638
- return this.#builtinIdMap;
639
- }
640
- /**
641
- * Lists all runtime IDs in the virtual file system.
642
- *
643
- * @returns An array of formatted runtime IDs.
644
- */
645
- get runtimeIds() {
646
- return Array.from(this.builtinIdMap.keys()).map((id) => this.formatRuntimeId(id));
647
- }
648
- /**
649
- * Checks if a given path or ID corresponds to a runtime file.
816
+ * Check if a path or id corresponds to a virtual file **(does not actually exists on disk)**.
650
817
  *
651
- * @param pathOrId - The path or ID to check.
652
- * @param options - Options for resolving the path, such as paths to check.
653
- * @returns `true` if the path or ID corresponds to a runtime file, otherwise `false`.
818
+ * @param pathOrId - The path or id to check.
819
+ * @param options - Optional parameters for resolving the path.
820
+ * @returns Whether the path or id corresponds to a virtual file **(does not actually exists on disk)**.
654
821
  */
655
- isBuiltinFile(pathOrId, options) {
656
- return !!this.builtinIdMap.values().find((path) => path === this.resolvePath(pathOrId, {
822
+ isVirtual(pathOrId, options = {}) {
823
+ if (!pathOrId) {
824
+ return false;
825
+ }
826
+ const resolvedPath = this.resolve(pathOrId, {
657
827
  ...options,
658
828
  type: "file"
659
- }));
660
- }
661
- /**
662
- * Checks if a provided string is a valid runtime ID (does not need to already be created in the file system).
663
- *
664
- * @param id - The ID to check.
665
- * @returns Whether the ID is a valid runtime ID.
666
- */
667
- isValidBuiltinId(id) {
668
- return id.startsWith(`${this.#context.config.output.builtinPrefix}:`);
829
+ });
830
+ if (!resolvedPath) {
831
+ return false;
832
+ }
833
+ return this.meta[resolvedPath]?.mode === "virtual";
669
834
  }
670
835
  /**
671
- * Check if a path or ID corresponds to a virtual file.
836
+ * Check if a path or id corresponds to a file written to the file system **(actually exists on disk)**.
672
837
  *
673
- * @param pathOrId - The path or ID to check.
674
- * @param options - Options for resolving the path, such as paths to check.
675
- * @returns Whether the path or ID corresponds to a virtual file.
838
+ * @param pathOrId - The path or id to check.
839
+ * @param options - Optional parameters for resolving the path.
840
+ * @returns Whether the path or id corresponds to a file written to the file system **(actually exists on disk)**.
676
841
  */
677
- isVirtualFile(pathOrId, options = {}) {
842
+ isFs(pathOrId, options = {}) {
678
843
  if (!pathOrId) {
679
844
  return false;
680
845
  }
681
- const resolvedPath = this.resolvePath(pathOrId, {
846
+ const resolvedPath = this.resolve(pathOrId, {
682
847
  ...options,
683
848
  type: "file"
684
849
  });
685
850
  if (!resolvedPath) {
686
851
  return false;
687
852
  }
688
- if (this.builtinIdMap.values().find((path) => path === resolvedPath)) {
689
- return true;
690
- }
691
- return this.#virtualFS.existsSync(resolvedPath);
853
+ return this.meta[resolvedPath]?.mode === "fs";
692
854
  }
693
855
  /**
694
856
  * Check if a path exists within one of the directories specified in the tsconfig.json's `path` field.
@@ -702,37 +864,6 @@ var VirtualFileSystem = class {
702
864
  return !!this.#context.tsconfig.options.paths && Object.keys(this.#context.tsconfig.options.paths).some((path) => pathOrId.startsWith(path.replaceAll("*", "")));
703
865
  }
704
866
  /**
705
- * Checks if a given ID corresponds to a runtime file path.
706
- *
707
- * @param id - The unique identifier for the runtime file.
708
- * @param pathOrId - The path or ID to check.
709
- * @returns `true` if the ID corresponds to the path or ID of a runtime file, otherwise `false`.
710
- */
711
- isMatchingBuiltinId(id, pathOrId) {
712
- const resolvedPath = this.resolvePath(pathOrId);
713
- const resolvedId = this.resolveId(pathOrId);
714
- return !!(this.isBuiltinFile(pathOrId) && (resolvedPath && (resolvedPath === this.builtinIdMap.get(id) || resolvedPath === this.builtinIdMap.get(this.formatRuntimeId(id))) || resolvedId && (resolvedId === this.builtinIdMap.get(id) || resolvedId === this.builtinIdMap.get(this.formatRuntimeId(id)))));
715
- }
716
- /**
717
- * Lists all runtime files in the virtual file system.
718
- *
719
- * @returns A promise that resolves to an array of runtime files.
720
- */
721
- async listBuiltinFiles() {
722
- const runtimeFiles = [];
723
- for (const [id, path] of this.builtinIdMap.entries()) {
724
- const contents = await this.readFile(path);
725
- if (contents) {
726
- runtimeFiles.push({
727
- id: this.formatRuntimeId(id),
728
- path,
729
- contents
730
- });
731
- }
732
- }
733
- return runtimeFiles;
734
- }
735
- /**
736
867
  * Lists files in a given path.
737
868
  *
738
869
  * @param path - The path to list files from.
@@ -749,7 +880,7 @@ var VirtualFileSystem = class {
749
880
  */
750
881
  unlinkSync(path, options) {
751
882
  const formattedPath = toFilePath(path);
752
- if (!this.fileExistsSync(path)) {
883
+ if (!this.isFile(formattedPath)) {
753
884
  return;
754
885
  }
755
886
  this.#log(LogLevelLabel.TRACE, `Synchronously removing file: ${formattedPath}`);
@@ -764,7 +895,7 @@ var VirtualFileSystem = class {
764
895
  */
765
896
  async unlink(path, options) {
766
897
  const formattedPath = toFilePath(path);
767
- if (!this.fileExistsSync(path)) {
898
+ if (!this.isFile(formattedPath)) {
768
899
  return;
769
900
  }
770
901
  this.#log(LogLevelLabel.TRACE, `Removing file: ${formattedPath}`);
@@ -784,7 +915,7 @@ var VirtualFileSystem = class {
784
915
  */
785
916
  rmdirSync(path, options = {}) {
786
917
  const formattedPath = toFilePath(path);
787
- if (!this.directoryExistsSync(path)) {
918
+ if (!this.isDirectory(formattedPath)) {
788
919
  return;
789
920
  }
790
921
  this.#log(LogLevelLabel.TRACE, `Synchronously removing directory: ${formattedPath}`);
@@ -803,7 +934,7 @@ var VirtualFileSystem = class {
803
934
  */
804
935
  async rmdir(path, options = {}) {
805
936
  const formattedPath = toFilePath(path);
806
- if (!this.directoryExistsSync(path)) {
937
+ if (!this.isDirectory(formattedPath)) {
807
938
  return;
808
939
  }
809
940
  this.#log(LogLevelLabel.TRACE, `Removing directory: ${formattedPath}`);
@@ -830,7 +961,7 @@ var VirtualFileSystem = class {
830
961
  */
831
962
  async rm(path, options = {}) {
832
963
  this.#log(LogLevelLabel.TRACE, `Removing: ${toFilePath(path)}`);
833
- if (this.directoryExistsSync(path)) {
964
+ if (this.isDirectory(path)) {
834
965
  return this.rmdir(path, options);
835
966
  }
836
967
  return this.unlink(path, options);
@@ -874,12 +1005,12 @@ var VirtualFileSystem = class {
874
1005
  /**
875
1006
  * Lists files in a given path.
876
1007
  *
877
- * @param path - The path to list files from.
1008
+ * @param pathOrId - The path to list files from.
878
1009
  * @param options - Options for listing files, such as encoding and recursion.
879
1010
  * @returns An array of file names in the specified path.
880
1011
  */
881
- async readdir(path, options = "utf8") {
882
- return this.resolveFS(path).promises.readdir(toFilePath(path), options);
1012
+ async readdir(pathOrId, options = "utf8") {
1013
+ return this.resolveFS(pathOrId).promises.readdir(toFilePath(pathOrId), options);
883
1014
  }
884
1015
  /**
885
1016
  * Asynchronously reads a file from the virtual file system (VFS).
@@ -891,7 +1022,7 @@ var VirtualFileSystem = class {
891
1022
  if (!pathOrId) {
892
1023
  return void 0;
893
1024
  }
894
- const filePath = this.resolvePath(toFilePath(pathOrId), {
1025
+ const filePath = this.resolve(toFilePath(pathOrId), {
895
1026
  type: "file"
896
1027
  });
897
1028
  if (filePath) {
@@ -920,7 +1051,7 @@ var VirtualFileSystem = class {
920
1051
  if (!pathOrId) {
921
1052
  return void 0;
922
1053
  }
923
- const filePath = this.resolvePath(toFilePath(pathOrId), {
1054
+ const filePath = this.resolve(toFilePath(pathOrId), {
924
1055
  type: "file"
925
1056
  });
926
1057
  if (filePath) {
@@ -937,137 +1068,80 @@ var VirtualFileSystem = class {
937
1068
  /**
938
1069
  * Writes a file to the virtual file system (VFS).
939
1070
  *
940
- * @param file - The path to the file.
1071
+ * @param path - The path to the file.
941
1072
  * @param data - The contents of the file.
942
1073
  * @param options - Optional parameters for writing the file.
943
1074
  * @returns A promise that resolves when the file is written.
944
1075
  */
945
- async writeFile(file, data = "", options = "utf8") {
946
- const absolutePath = this.formatAbsoluteFilePath(toFilePath(file));
947
- if (!this.directoryExistsSync(findFilePath(absolutePath))) {
948
- await this.mkdir(findFilePath(absolutePath), options);
1076
+ async writeFile(path, data = "", options = "utf8") {
1077
+ const formattedPath = this.formatPath(path);
1078
+ if (!this.isDirectory(findFilePath(formattedPath))) {
1079
+ await this.mkdir(findFilePath(formattedPath), isPowerlinesWriteFileOptions(options) ? options : void 0);
949
1080
  }
950
- this.#log(LogLevelLabel.TRACE, `Writing ${absolutePath} file to the ${this.resolveOutputMode(absolutePath, options) === "fs" ? "" : "virtual "}file system (size: ${prettyBytes(new Blob(toArray(data)).size)})`);
951
- this.#cachedFS.set(absolutePath, data.toString());
952
- this.clearResolverCache(absolutePath);
953
- const ifs = this.resolveFS(absolutePath, options);
1081
+ let code = isPowerLinesWriteFileData(data) ? data.code : data;
1082
+ if ((!isPowerlinesWriteFileOptions(options) || !options.skipFormat) && isSetString(code)) {
1083
+ const resolvedConfig = await resolveConfig(formattedPath);
1084
+ if (resolvedConfig) {
1085
+ code = await format(code, {
1086
+ absolutePath: formattedPath,
1087
+ ...resolvedConfig
1088
+ });
1089
+ }
1090
+ }
1091
+ const outputMode = this.resolveOutputMode(formattedPath, isPowerlinesWriteFileOptions(options) ? options : void 0);
1092
+ this.#log(LogLevelLabel.TRACE, `Writing ${formattedPath} file to the ${outputMode === "fs" ? "" : "virtual "}file system (size: ${prettyBytes(new Blob(toArray(code)).size)})`);
1093
+ this.meta[formattedPath] = {
1094
+ path: formattedPath,
1095
+ code,
1096
+ mode: outputMode,
1097
+ variant: "normal",
1098
+ ...isPowerLinesWriteFileData(data) ? data : {}
1099
+ };
1100
+ this.clearResolverCache(formattedPath);
1101
+ const ifs = this.resolveFS(formattedPath, isPowerlinesWriteFileOptions(options) ? options : void 0);
954
1102
  if (isFunction(ifs.promises.writeFile)) {
955
- return ifs.promises.writeFile(absolutePath, data, omit(options, [
956
- "mode"
957
- ]));
1103
+ return ifs.promises.writeFile(formattedPath, code, isNodeWriteFileOptions(options) ? options : "utf8");
958
1104
  }
959
- return ifs.writeFileSync(absolutePath, data, omit(options, [
960
- "mode"
961
- ]));
1105
+ return ifs.writeFileSync(formattedPath, code, isNodeWriteFileOptions(options) ? options : "utf8");
962
1106
  }
963
1107
  /**
964
1108
  * Synchronously writes a file to the virtual file system (VFS).
965
1109
  *
966
- * @param file - The file to write.
1110
+ * @param path - The file to write.
967
1111
  * @param data - The contents of the file.
968
1112
  * @param options - Optional parameters for writing the file.
969
1113
  */
970
- writeFileSync(file, data = "", options = "utf8") {
971
- const absolutePath = this.formatAbsoluteFilePath(toFilePath(file));
972
- if (!this.directoryExistsSync(findFilePath(absolutePath))) {
973
- this.mkdirSync(findFilePath(absolutePath));
974
- }
975
- this.#log(LogLevelLabel.TRACE, `Writing ${absolutePath} file to the ${this.resolveOutputMode(absolutePath, options) === "fs" ? "" : "virtual "} (size: ${prettyBytes(new Blob(toArray(data)).size)})`);
976
- this.#cachedFS.set(absolutePath, data.toString());
977
- this.clearResolverCache(absolutePath);
978
- const writeStream = this.resolveFS(absolutePath, omit(options, [
979
- "mode"
980
- ])).createWriteStream(absolutePath);
1114
+ writeFileSync(path, data = "", options = "utf8") {
1115
+ const formattedPath = this.formatPath(path);
1116
+ if (!this.isDirectory(findFilePath(formattedPath))) {
1117
+ this.mkdirSync(findFilePath(formattedPath), isPowerlinesWriteFileOptions(options) ? options : void 0);
1118
+ }
1119
+ const code = isPowerLinesWriteFileData(data) ? data.code : data;
1120
+ const outputMode = this.resolveOutputMode(formattedPath, isPowerlinesWriteFileOptions(options) ? options : void 0);
1121
+ this.#log(LogLevelLabel.TRACE, `Writing ${formattedPath} file to the ${outputMode === "fs" ? "" : "virtual "}file system (size: ${prettyBytes(new Blob(toArray(code)).size)})`);
1122
+ this.meta[formattedPath] = {
1123
+ path: formattedPath,
1124
+ code,
1125
+ mode: outputMode,
1126
+ variant: "normal",
1127
+ ...isPowerLinesWriteFileData(data) ? data : {}
1128
+ };
1129
+ this.clearResolverCache(formattedPath);
1130
+ const writeStream = this.resolveFS(formattedPath, isPowerlinesWriteFileOptions(options) ? options : void 0).createWriteStream(formattedPath);
981
1131
  try {
982
- writeStream.write(data);
1132
+ writeStream.write(code);
983
1133
  } finally {
984
1134
  writeStream.close();
985
1135
  }
986
1136
  }
987
1137
  /**
988
- * Writes a runtime file to the virtual file system (VFS).
989
- *
990
- * @param id - The unique identifier for the runtime file.
991
- * @param path - The path to the runtime file.
992
- * @param contents - The contents of the runtime file.
993
- * @param options - Optional parameters for writing the runtime file.
994
- * @returns A promise that resolves when the file is written.
995
- */
996
- async writeBuiltinFile(id, path, contents, options = {}) {
997
- const formattedId = this.formatRuntimeId(id);
998
- const absolutePath = this.formatAbsoluteFilePath(toFilePath(path));
999
- this.builtinIdMap.set(formattedId, absolutePath);
1000
- let data = contents;
1001
- if (!options.skipFormat) {
1002
- data = await format(contents, {
1003
- absolutePath,
1004
- ...await resolveConfig(absolutePath)
1005
- });
1006
- }
1007
- const _options = defu5(isSetString(options) ? {} : options ?? {}, {
1008
- encoding: isSetString(options) ? options : "utf8",
1009
- mode: "virtual"
1010
- });
1011
- this.#log(LogLevelLabel.DEBUG, `Writing runtime file ${absolutePath} (size: ${prettyBytes(new Blob(toArray(data)).size)}) to ${this.resolveOutputMode(absolutePath, _options) === "fs" ? "disk" : "memory"}`);
1012
- return this.writeFile(absolutePath, data, _options);
1013
- }
1014
- /**
1015
- * Adds an entry file to the virtual file system.
1016
- *
1017
- * @param name - The file name or absolute path of the entry module.
1018
- * @param contents - The contents of the entry file.
1019
- * @param options - Optional parameters for writing the entry file.
1020
- */
1021
- async writeEntryFile(name, contents, options = {}) {
1022
- const absolutePath = this.formatAbsoluteFilePath(isAbsolutePath(toFilePath(name)) ? toFilePath(name) : toFilePath(joinPaths(this.#context.entryPath, name)));
1023
- let data = contents;
1024
- if (!options.skipFormat) {
1025
- data = await format(contents, {
1026
- absolutePath,
1027
- ...await resolveConfig(absolutePath)
1028
- });
1029
- }
1030
- const _options = defu5(isSetString(options) ? {} : options ?? {}, {
1031
- encoding: isSetString(options) ? options : "utf8",
1032
- mode: "virtual"
1033
- });
1034
- this.#log(LogLevelLabel.DEBUG, `Writing entry file ${absolutePath} (size: ${prettyBytes(new Blob(toArray(data)).size)}) to ${this.resolveOutputMode(absolutePath, _options) === "fs" ? "disk" : "virtual memory"}`);
1035
- return this.writeFile(absolutePath, data, _options);
1036
- }
1037
- /**
1038
- * Writes a file to disk from the physical file system (on disk).
1039
- *
1040
- * @param path - The path to the file to write.
1041
- * @param contents - The contents of the file to write.
1042
- * @param options - Optional parameters for writing the file.
1043
- * @returns A promise that resolves when the file is written.
1044
- */
1045
- async writeFileToDisk(path, contents, options = {}) {
1046
- const absolutePath = this.formatAbsoluteFilePath(toFilePath(path));
1047
- let data = contents;
1048
- if (!options.skipFormat) {
1049
- const resolvedConfig = await resolveConfig(absolutePath);
1050
- if (resolvedConfig) {
1051
- data = await format(contents, {
1052
- absolutePath,
1053
- ...resolvedConfig
1054
- });
1055
- }
1056
- }
1057
- return this.writeFile(absolutePath, data, defu5({
1058
- mode: "fs"
1059
- }, isSetString(options) ? {} : options ?? {}, {
1060
- encoding: isSetString(options) ? options : "utf8"
1061
- }));
1062
- }
1063
- /**
1064
1138
  * Synchronously checks if a file exists in the virtual file system (VFS).
1065
1139
  *
1066
1140
  * @param pathOrId - The path or ID of the file to check.
1067
1141
  * @returns `true` if the file exists, otherwise `false`.
1068
1142
  */
1069
1143
  existsSync(pathOrId) {
1070
- return this.pathExistsSync(this.resolvePath(toFilePath(pathOrId)) || toFilePath(pathOrId));
1144
+ return this.resolve(pathOrId) !== false;
1071
1145
  }
1072
1146
  /**
1073
1147
  * Checks if a file exists in the virtual file system (VFS).
@@ -1075,32 +1149,22 @@ var VirtualFileSystem = class {
1075
1149
  * @remarks
1076
1150
  * 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.
1077
1151
  *
1078
- * @param path - The path of the file to check.
1152
+ * @param pathOrId - The path of the file to check.
1079
1153
  * @returns `true` if the file exists, otherwise `false`.
1080
1154
  */
1081
- fileExistsSync(path) {
1082
- const formattedPath = this.formatAbsoluteFilePath(toFilePath(path));
1083
- return this.isValidBuiltinId(formattedPath) || this.#virtualFS.existsSync(formattedPath) && this.#virtualFS.lstatSync(formattedPath).isFile() || this.#fs.existsSync(formattedPath) && this.#fs.lstatSync(formattedPath).isFile() || this.resolveFS(path).existsSync(formattedPath) && this.resolveFS(path).lstatSync(formattedPath).isFile();
1155
+ isFile(pathOrId) {
1156
+ const resolved = this.resolve(pathOrId);
1157
+ return !!(resolved && (this.#virtualFS.existsSync(resolved) && this.#virtualFS.lstatSync(resolved).isFile() || this.#fs.existsSync(resolved) && this.#fs.lstatSync(resolved).isFile() || this.resolveFS(resolved).existsSync(resolved) && this.resolveFS(resolved).lstatSync(resolved).isFile()));
1084
1158
  }
1085
1159
  /**
1086
1160
  * Checks if a directory exists in the virtual file system (VFS).
1087
1161
  *
1088
- * @param path - The path of the directory to check.
1162
+ * @param pathOrId - The path of the directory to check.
1089
1163
  * @returns `true` if the directory exists, otherwise `false`.
1090
1164
  */
1091
- directoryExistsSync(path) {
1092
- const formattedPath = this.formatAbsoluteFilePath(toFilePath(path));
1093
- return this.#virtualFS.existsSync(formattedPath) && this.#virtualFS.lstatSync(formattedPath).isDirectory() || this.#fs.existsSync(formattedPath) && this.#fs.lstatSync(formattedPath).isDirectory() || this.resolveFS(path).existsSync(formattedPath) && this.resolveFS(path).lstatSync(formattedPath).isDirectory();
1094
- }
1095
- /**
1096
- * Checks if a path exists in the virtual file system (VFS).
1097
- *
1098
- * @param path - The path to check.
1099
- * @returns `true` if the path exists, otherwise `false`.
1100
- */
1101
- pathExistsSync(path) {
1102
- const formattedPath = this.formatAbsoluteFilePath(toFilePath(path));
1103
- return this.isValidBuiltinId(formattedPath) || this.#virtualFS.existsSync(formattedPath) || this.#fs.existsSync(formattedPath) || this.resolveFS(path).existsSync(formattedPath);
1165
+ isDirectory(pathOrId) {
1166
+ const resolved = this.resolve(pathOrId);
1167
+ return !!(resolved && (this.#virtualFS.existsSync(resolved) && this.#virtualFS.lstatSync(resolved).isDirectory() || this.#fs.existsSync(resolved) && this.#fs.lstatSync(resolved).isDirectory() || this.resolveFS(resolved).existsSync(resolved) && this.resolveFS(resolved).lstatSync(resolved).isDirectory()));
1104
1168
  }
1105
1169
  /**
1106
1170
  * Retrieves the status of a file in the virtual file system (VFS).
@@ -1109,7 +1173,7 @@ var VirtualFileSystem = class {
1109
1173
  * @returns A promise that resolves to the file's status information, or false if the file does not exist.
1110
1174
  */
1111
1175
  async stat(pathOrId, options) {
1112
- return this.resolveFS(pathOrId).promises.stat(this.resolvePath(toFilePath(pathOrId)) || toFilePath(pathOrId), options);
1176
+ return this.resolveFS(pathOrId).promises.stat(this.resolve(toFilePath(pathOrId)) || toFilePath(pathOrId), options);
1113
1177
  }
1114
1178
  /**
1115
1179
  * Synchronously retrieves the status of a file in the virtual file system (VFS).
@@ -1118,7 +1182,7 @@ var VirtualFileSystem = class {
1118
1182
  * @returns The file's status information, or false if the file does not exist.
1119
1183
  */
1120
1184
  statSync(pathOrId) {
1121
- return this.resolveFS(pathOrId).statSync(this.resolvePath(toFilePath(pathOrId)) || toFilePath(pathOrId));
1185
+ return this.resolveFS(pathOrId).statSync(this.resolve(toFilePath(pathOrId)) || toFilePath(pathOrId));
1122
1186
  }
1123
1187
  /**
1124
1188
  * Retrieves the status of a symbolic link in the virtual file system (VFS).
@@ -1127,7 +1191,7 @@ var VirtualFileSystem = class {
1127
1191
  * @returns A promise that resolves to the symbolic link's status information, or false if the link does not exist.
1128
1192
  */
1129
1193
  async lstat(pathOrId, options) {
1130
- return this.resolveFS(pathOrId).promises.lstat(this.resolvePath(toFilePath(pathOrId)) || toFilePath(pathOrId), options);
1194
+ return this.resolveFS(pathOrId).promises.lstat(this.resolve(toFilePath(pathOrId)) || toFilePath(pathOrId), options);
1131
1195
  }
1132
1196
  /**
1133
1197
  * Synchronously retrieves the status of a symbolic link in the virtual file system (VFS).
@@ -1136,23 +1200,7 @@ var VirtualFileSystem = class {
1136
1200
  * @returns The symbolic link's status information, or false if the link does not exist.
1137
1201
  */
1138
1202
  lstatSync(pathOrId, options) {
1139
- return this.resolveFS(pathOrId).lstatSync(this.resolvePath(toFilePath(pathOrId)) || toFilePath(pathOrId), options);
1140
- }
1141
- /**
1142
- * Resolves a path or ID to a runtime file id in the virtual file system.
1143
- *
1144
- * @param pathOrId - The path or id of the file to resolve.
1145
- * @returns The resolved id of the runtime file if it exists, otherwise false.
1146
- */
1147
- resolveId(pathOrId) {
1148
- if (this.builtinIdMap.has(this.formatRuntimeId(toFilePath(pathOrId)))) {
1149
- return this.formatRuntimeId(toFilePath(pathOrId));
1150
- }
1151
- const filePath = this.resolvePath(toFilePath(pathOrId));
1152
- if (filePath) {
1153
- return this.builtinIdMap.keys().find((id) => this.builtinIdMap.get(id) === filePath) || false;
1154
- }
1155
- return false;
1203
+ return this.resolveFS(pathOrId).lstatSync(this.resolve(toFilePath(pathOrId)) || toFilePath(pathOrId), options);
1156
1204
  }
1157
1205
  /**
1158
1206
  * Resolves a path based on TypeScript's `tsconfig.json` paths.
@@ -1165,9 +1213,9 @@ var VirtualFileSystem = class {
1165
1213
  resolveTsconfigPath(path) {
1166
1214
  if (this.#context.tsconfig.options.paths) {
1167
1215
  for (const tsconfigPathKey of Object.keys(this.#context.tsconfig.options.paths).filter((tsconfigPath) => path.startsWith(tsconfigPath.replaceAll("*", "")))) {
1168
- const resolvedPath = this.#context.tsconfig.options.paths[tsconfigPathKey]?.find((tsconfigPath) => this.resolvePathName(joinPaths(this.#context.workspaceConfig.workspaceRoot, tsconfigPath.replaceAll("*", ""), path.replace(tsconfigPathKey.replaceAll("*", ""), ""))) || this.formatAbsoluteFilePath(tsconfigPath) === this.formatAbsoluteFilePath(path));
1216
+ const resolvedPath = this.#context.tsconfig.options.paths[tsconfigPathKey]?.find((tsconfigPath) => this.resolvePath(joinPaths(this.#context.workspaceConfig.workspaceRoot, tsconfigPath.replaceAll("*", ""), path.replace(tsconfigPathKey.replaceAll("*", ""), ""))) || this.formatPath(tsconfigPath) === this.formatPath(path));
1169
1217
  if (resolvedPath) {
1170
- return this.formatAbsoluteFilePath(resolvedPath) === this.formatAbsoluteFilePath(path) ? this.formatAbsoluteFilePath(resolvedPath) : this.resolvePathName(joinPaths(this.#context.workspaceConfig.workspaceRoot, resolvedPath.replaceAll("*", ""), path.replace(tsconfigPathKey.replaceAll("*", ""), "")));
1218
+ return this.formatPath(resolvedPath) === this.formatPath(path) ? this.formatPath(resolvedPath) : this.resolvePath(joinPaths(this.#context.workspaceConfig.workspaceRoot, resolvedPath.replaceAll("*", ""), path.replace(tsconfigPathKey.replaceAll("*", ""), "")));
1171
1219
  }
1172
1220
  }
1173
1221
  }
@@ -1197,7 +1245,7 @@ var VirtualFileSystem = class {
1197
1245
  * @returns The resolved real path if it exists, otherwise undefined.
1198
1246
  */
1199
1247
  realpathSync(pathOrId) {
1200
- const filePath = this.resolvePath(toFilePath(pathOrId));
1248
+ const filePath = this.resolve(toFilePath(pathOrId));
1201
1249
  if (!filePath) {
1202
1250
  throw new Error(`File not found: ${toFilePath(pathOrId)}`);
1203
1251
  }
@@ -1210,24 +1258,18 @@ var VirtualFileSystem = class {
1210
1258
  * @param options - Optional parameters for resolving the path, such as whether to include the file extension.
1211
1259
  * @returns The resolved file path if it exists, otherwise undefined.
1212
1260
  */
1213
- resolvePath(pathOrId, options = {}) {
1214
- const formattedPath = toFilePath(pathOrId);
1215
- const resolverKey = `${formattedPath}${options.withExtension ? "-ext" : ""}${options.paths ? `-${murmurhash(options.paths)}` : ""}${options.type ? `-${options.type}` : ""}`;
1261
+ resolve(pathOrId, options = {}) {
1262
+ const formattedPathOrId = toFilePath(pathOrId);
1263
+ const resolverKey = `${formattedPathOrId}${options.withExtension ? "-ext" : ""}${options.paths ? `-${murmurhash(options.paths)}` : ""}${options.type ? `-${options.type}` : ""}`;
1216
1264
  if (this.#cachedResolver.has(resolverKey)) {
1217
1265
  return this.#cachedResolver.get(resolverKey);
1218
- } else if (this.#cachedFS.has(formattedPath)) {
1219
- return formattedPath;
1220
1266
  }
1221
- let result = false;
1222
- if (this.isValidBuiltinId(formattedPath)) {
1223
- result = this.builtinIdMap.get(this.formatRuntimeId(formattedPath));
1224
- } else {
1225
- result = this.resolvePathName(formattedPath, options);
1267
+ let result = this.resolveId(formattedPathOrId);
1268
+ if (!result) {
1269
+ result = this.resolvePath(formattedPathOrId, options);
1226
1270
  }
1227
1271
  if (!result) {
1228
1272
  result = false;
1229
- } else {
1230
- result = toFilePath(result);
1231
1273
  }
1232
1274
  if (result && options.withExtension === false) {
1233
1275
  return result.replace(/\.[m|c]?[t|j]sx?$/, "");
@@ -1236,16 +1278,12 @@ var VirtualFileSystem = class {
1236
1278
  return result;
1237
1279
  }
1238
1280
  /**
1239
- * Formats a file path by removing the runtime prefix and leading null character.
1281
+ * Retrieves the partial metadata for all files in the virtual file system (VFS).
1240
1282
  *
1241
- * @param path - The file path to format.
1242
- * @returns The formatted file path.
1283
+ * @returns A record containing the partial metadata for all files.
1243
1284
  */
1244
- formatFilePath(path) {
1245
- if (!isSetString(path)) {
1246
- throw new Error(`Invalid path provided. Expected a string or a valid file path.`);
1247
- }
1248
- return path.replace(new RegExp(`^${this.#context.config.output.builtinPrefix}:`), "").replace(/^\\0/, "");
1285
+ getPartialMeta() {
1286
+ return Object.fromEntries(Object.entries(this.#meta).filter(([_, data]) => isSetObject(data)));
1249
1287
  }
1250
1288
  /**
1251
1289
  * Converts a relative path to an absolute path based on the workspace and project root.
@@ -1253,56 +1291,67 @@ var VirtualFileSystem = class {
1253
1291
  * @param path - The relative path to convert.
1254
1292
  * @returns The absolute path.
1255
1293
  */
1256
- formatAbsoluteFilePath = /* @__PURE__ */ __name((path) => {
1257
- const formattedPath = this.formatFilePath(path);
1294
+ formatPath(path) {
1295
+ const formattedPath = toFilePath(path);
1258
1296
  if (isAbsolutePath(formattedPath) || formattedPath.startsWith(this.#context.workspaceConfig.workspaceRoot)) {
1259
1297
  return formattedPath;
1260
1298
  } else if (formattedPath.startsWith(this.#context.config.projectRoot)) {
1261
1299
  return joinPaths(this.#context.workspaceConfig.workspaceRoot, formattedPath);
1262
1300
  }
1263
1301
  return formattedPath;
1264
- }, "formatAbsoluteFilePath");
1302
+ }
1265
1303
  /**
1266
- * Formats a runtime ID by removing the file extension and prepending the runtime prefix.
1304
+ * Formats a file id by removing the file extension and prepending the runtime prefix.
1267
1305
  *
1268
- * @param id - The runtime ID to format.
1269
- * @returns The formatted runtime ID.
1306
+ * @param id - The file ID to format.
1307
+ * @returns The formatted file ID.
1270
1308
  */
1271
- formatRuntimeId(id) {
1272
- return `${this.#context.config.output.builtinPrefix}:${this.formatFilePath(id).replace(/\.[m|c]?[t|j]sx?$/, "")}`;
1309
+ formatId(id) {
1310
+ const formattedId = toFilePath(id);
1311
+ return `${this.#context.config.output.builtinPrefix}:${formattedId.replace(new RegExp(`^${this.#context.config.output.builtinPrefix}:`), "").replace(/^\\0/, "").replace(findFileExtensionSafe(formattedId), "")}`;
1273
1312
  }
1274
1313
  /**
1275
- * Resolves a path or ID parameter to a corresponding virtual file path in the virtual file system (VFS).
1314
+ * Resolves an id parameter to a corresponding virtual file path in the virtual file system (VFS).
1276
1315
  *
1277
- * @param pathOrId - The path or ID to resolve.
1278
- * @returns The resolved file path if it exists, otherwise undefined.
1316
+ * @param id - The id to resolve.
1317
+ * @returns The resolved file id if it exists, otherwise undefined.
1279
1318
  */
1280
- resolvePathName(pathOrId, options = {}) {
1281
- if (pathOrId.startsWith(`${this.#context.config.output.builtinPrefix}:`)) {
1282
- return false;
1319
+ resolveId(id) {
1320
+ if (this.#ids[this.formatId(id)]) {
1321
+ return this.#ids[this.formatId(id)] || false;
1283
1322
  }
1284
- if (isAbsolutePath(pathOrId)) {
1285
- if (options.type === "file" ? this.fileExistsSync(pathOrId) : this.pathExistsSync(pathOrId)) {
1286
- return pathOrId;
1323
+ return false;
1324
+ }
1325
+ /**
1326
+ * Resolves a path parameter to a corresponding virtual file path in the virtual file system (VFS).
1327
+ *
1328
+ * @param path - The path to resolve.
1329
+ * @param options - Optional parameters for resolving the path.
1330
+ * @returns The resolved file path if it exists, otherwise undefined.
1331
+ */
1332
+ resolvePath(path, options = {}) {
1333
+ if (isAbsolutePath(path)) {
1334
+ if (this.#existsSync(path)) {
1335
+ return path;
1287
1336
  }
1288
- const result = checkVariants(pathOrId, this);
1337
+ const result = this.checkVariants(path);
1289
1338
  if (result) {
1290
1339
  return result;
1291
1340
  }
1292
1341
  }
1293
- for (const path of this.resolveParentPaths(pathOrId, options.paths)) {
1294
- const request = joinPaths(path, pathOrId);
1295
- if (options.type === "file" ? this.fileExistsSync(pathOrId) : this.pathExistsSync(pathOrId)) {
1342
+ for (const parentPath of this.resolveParentPaths(path, options.paths)) {
1343
+ const request = joinPaths(parentPath, path);
1344
+ if (this.#existsSync(request)) {
1296
1345
  return request;
1297
1346
  }
1298
- const result = checkVariants(request, this);
1347
+ const result = this.checkVariants(request);
1299
1348
  if (result) {
1300
1349
  return result;
1301
1350
  }
1302
1351
  }
1303
1352
  return false;
1304
1353
  }
1305
- resolveParentPaths(request, current = []) {
1354
+ resolveParentPaths(request, parents = []) {
1306
1355
  let paths = [
1307
1356
  this.#context.workspaceConfig.workspaceRoot,
1308
1357
  joinPaths(this.#context.workspaceConfig.workspaceRoot, this.#context.config.projectRoot)
@@ -1320,7 +1369,7 @@ var VirtualFileSystem = class {
1320
1369
  ret.push(path);
1321
1370
  }
1322
1371
  return ret;
1323
- }, current.filter(Boolean).map((p) => this.formatAbsoluteFilePath(toFilePath(p))));
1372
+ }, parents.filter(Boolean).map((p) => this.formatPath(p)));
1324
1373
  }
1325
1374
  /**
1326
1375
  * Select the file system module to use for the operation based on the path or URL.
@@ -1351,7 +1400,7 @@ var VirtualFileSystem = class {
1351
1400
  } else if (options.mode === "fs" || this.#context.config.output.mode === "fs" || isParentPath(toFilePath(pathOrUrl), this.#context.dataPath) || isParentPath(toFilePath(pathOrUrl), this.#context.cachePath) || isParentPath(toFilePath(pathOrUrl), joinPaths(this.#context.workspaceConfig.workspaceRoot, this.#context.config.output.outputPath))) {
1352
1401
  return "fs";
1353
1402
  }
1354
- return null;
1403
+ return void 0;
1355
1404
  }
1356
1405
  /**
1357
1406
  * Clears the resolver cache for a given path.
@@ -1361,208 +1410,93 @@ var VirtualFileSystem = class {
1361
1410
  clearResolverCache(path) {
1362
1411
  this.#cachedResolver.keys().filter((key) => key.startsWith(toFilePath(path))).forEach((key) => this.#cachedResolver.delete(key));
1363
1412
  }
1364
- };
1365
- var FILE_PREFIX = "file://";
1366
- function toFilePath(pathOrUrl) {
1367
- if (!pathOrUrl) {
1368
- throw new Error("No Path or URL provided to Virtual File System");
1369
- }
1370
- let result = pathOrUrl.toString();
1371
- if (result.startsWith(FILE_PREFIX)) {
1372
- result = result.slice(FILE_PREFIX.length);
1373
- }
1374
- return result;
1375
- }
1376
- __name(toFilePath, "toFilePath");
1377
- var FS_METHODS = [
1378
- "mkdir",
1379
- "mkdirSync",
1380
- "rmdir",
1381
- "rmdirSync",
1382
- "unlink",
1383
- "unlinkSync",
1384
- "existsSync",
1385
- "realpathSync",
1386
- "writeFileSync",
1387
- "readFileSync",
1388
- "readdirSync",
1389
- "createWriteStream",
1390
- "WriteStream",
1391
- "createReadStream",
1392
- "ReadStream"
1393
- ];
1394
- var FS_PROMISE_METHODS = [
1395
- "mkdir",
1396
- "rm",
1397
- "rmdir",
1398
- "unlink",
1399
- "writeFile",
1400
- "readFile",
1401
- "readdir",
1402
- "stat",
1403
- "lstat"
1404
- ];
1405
- function cloneFS(originalFS) {
1406
- const clonedFS = {
1407
- ...originalFS,
1408
- promises: {
1409
- ...originalFS.promises ?? {}
1413
+ /**
1414
+ * Check if the file exists with different variants (index, extensions).
1415
+ *
1416
+ * @param request - The request path to check.
1417
+ * @param parentPath - An optional parent path to prepend to the request.
1418
+ * @returns The file path if it exists, otherwise false.
1419
+ */
1420
+ checkVariants(request, parentPath) {
1421
+ const path = parentPath ? joinPaths(parentPath, request) : request;
1422
+ let file = this.checkExtensions(path);
1423
+ if (file) {
1424
+ return file;
1410
1425
  }
1411
- };
1412
- for (const method of FS_METHODS) {
1413
- if (originalFS[method]) {
1414
- clonedFS[method] = originalFS[method];
1426
+ file = this.checkIndex(path);
1427
+ if (file) {
1428
+ return file;
1415
1429
  }
1430
+ return false;
1416
1431
  }
1417
- originalFS.promises ??= {};
1418
- for (const method of FS_PROMISE_METHODS) {
1419
- if (originalFS.promises[method]) {
1420
- clonedFS.promises ??= {};
1421
- clonedFS.promises[method] = originalFS.promises[method];
1422
- clonedFS[method] = originalFS.promises[method];
1432
+ /**
1433
+ * Check if the index file exists in the given request path.
1434
+ *
1435
+ * @param request - The request path to check.
1436
+ * @returns The index file path if it exists, otherwise false.
1437
+ */
1438
+ checkIndex(request) {
1439
+ let file = joinPaths(request, "index");
1440
+ if (this.#existsSync(file)) {
1441
+ return file;
1423
1442
  }
1424
- }
1425
- for (const prop in clonedFS) {
1426
- if (isFunction(clonedFS[prop])) {
1427
- clonedFS[prop] = clonedFS[prop].bind(originalFS);
1428
- if (isFunction(clonedFS.promises[prop])) {
1429
- clonedFS.promises[prop] = clonedFS.promises[prop].bind(originalFS);
1430
- }
1443
+ file = this.checkExtensions(file);
1444
+ if (file) {
1445
+ return file;
1431
1446
  }
1447
+ return false;
1432
1448
  }
1433
- for (const prop in clonedFS.promises) {
1434
- if (isFunction(clonedFS.promises[prop])) {
1435
- clonedFS.promises[prop] = clonedFS.promises[prop].bind(originalFS);
1449
+ /**
1450
+ * Check if the file exists with different extensions.
1451
+ *
1452
+ * @param request - The request path to check.
1453
+ * @param vfs - The file system module to use for checking file existence.
1454
+ * @returns The file path if it exists with any of the checked extensions, otherwise false.
1455
+ */
1456
+ checkExtensions(request) {
1457
+ let file = `${request}.ts`;
1458
+ if (this.#existsSync(file)) {
1459
+ return file;
1436
1460
  }
1461
+ file = `${request}.mts`;
1462
+ if (this.#existsSync(file)) {
1463
+ return file;
1464
+ }
1465
+ file = `${request}.cts`;
1466
+ if (this.#existsSync(file)) {
1467
+ return file;
1468
+ }
1469
+ file = `${request}.tsx`;
1470
+ if (this.#existsSync(file)) {
1471
+ return file;
1472
+ }
1473
+ file = `${request}.js`;
1474
+ if (this.#existsSync(file)) {
1475
+ return file;
1476
+ }
1477
+ file = `${request}.mjs`;
1478
+ if (this.#existsSync(file)) {
1479
+ return file;
1480
+ }
1481
+ file = `${request}.cjs`;
1482
+ if (this.#existsSync(file)) {
1483
+ return file;
1484
+ }
1485
+ file = `${request}.jsx`;
1486
+ if (this.#existsSync(file)) {
1487
+ return file;
1488
+ }
1489
+ file = `${request}.json`;
1490
+ if (this.#existsSync(file)) {
1491
+ return file;
1492
+ }
1493
+ file = `${request}.d.ts`;
1494
+ if (this.#existsSync(file)) {
1495
+ return file;
1496
+ }
1497
+ return false;
1437
1498
  }
1438
- return clonedFS;
1439
- }
1440
- __name(cloneFS, "cloneFS");
1441
- function patchFS(originalFS, vfs) {
1442
- const clonedFS = cloneFS(originalFS);
1443
- originalFS.mkdirSync = (file, options) => vfs.mkdirSync(toFilePath(file), options);
1444
- originalFS.mkdir = (file, options, callback) => vfs.mkdir(toFilePath(file), options, callback);
1445
- originalFS.promises.mkdir = async (file, options) => vfs.mkdir(toFilePath(file), options);
1446
- originalFS.unlinkSync = (file) => vfs.unlinkSync(toFilePath(file));
1447
- originalFS.promises.rm = async (file, options) => vfs.rm(toFilePath(file), options);
1448
- originalFS.promises.unlink = async (file) => vfs.unlink(toFilePath(file));
1449
- originalFS.existsSync = (file) => vfs.existsSync(toFilePath(file));
1450
- Object.defineProperty(originalFS, "realpathSync", {
1451
- value: /* @__PURE__ */ __name((file, options) => vfs.realpathSync(toFilePath(file), options), "value")
1452
- });
1453
- originalFS.writeFileSync = (file, data, options) => vfs.writeFileSync(toFilePath(file), data, options);
1454
- originalFS.promises.writeFile = async (file, data, options) => vfs.writeFile(toFilePath(file), data, options);
1455
- originalFS.readFileSync = (file, options) => vfs.readFileSync(toFilePath(file), options);
1456
- originalFS.promises.readFile = (file, options) => vfs.readFile(toFilePath(file), options);
1457
- originalFS.readdirSync = (file, options) => vfs.readdirSync(toFilePath(file), options);
1458
- originalFS.promises.readdir = (file, options) => vfs.readdir(toFilePath(file), options);
1459
- Object.defineProperty(originalFS, "statSync", {
1460
- value: /* @__PURE__ */ __name((file, options) => vfs.statSync(toFilePath(file), options), "value")
1461
- });
1462
- originalFS.stat = (file, options) => vfs.statSync(toFilePath(file), options);
1463
- originalFS.promises.stat = (file, options) => vfs.stat(toFilePath(file), options);
1464
- Object.defineProperty(originalFS, "lstatSync", {
1465
- value: /* @__PURE__ */ __name((file, options) => vfs.lstatSync(toFilePath(file), options), "value")
1466
- });
1467
- originalFS.lstat = (file, options) => vfs.lstatSync(toFilePath(file), options);
1468
- originalFS.promises.lstat = (file, options) => vfs.lstat(toFilePath(file), options);
1469
- return () => {
1470
- originalFS.mkdirSync = clonedFS.mkdirSync;
1471
- originalFS.mkdir = clonedFS.mkdir;
1472
- originalFS.promises.mkdir = clonedFS.promises.mkdir;
1473
- originalFS.unlinkSync = clonedFS.unlinkSync;
1474
- originalFS.promises.rm = clonedFS.promises.rm;
1475
- originalFS.promises.unlink = clonedFS.promises.unlink;
1476
- originalFS.existsSync = clonedFS.existsSync;
1477
- originalFS.realpathSync = clonedFS.realpathSync;
1478
- originalFS.writeFileSync = clonedFS.writeFileSync;
1479
- originalFS.promises.writeFile = clonedFS.promises.writeFile;
1480
- originalFS.readFileSync = clonedFS.readFileSync;
1481
- originalFS.promises.readFile = clonedFS.promises.readFile;
1482
- originalFS.readdirSync = clonedFS.readdirSync;
1483
- originalFS.promises.readdir = clonedFS.promises.readdir;
1484
- Object.defineProperty(originalFS, "statSync", {
1485
- value: clonedFS.statSync
1486
- });
1487
- originalFS.stat = clonedFS.stat;
1488
- originalFS.promises.stat = clonedFS.promises.stat;
1489
- Object.defineProperty(originalFS, "lstatSync", {
1490
- value: clonedFS.lstatSync
1491
- });
1492
- originalFS.lstat = clonedFS.lstat;
1493
- originalFS.promises.lstat = clonedFS.promises.lstat;
1494
- };
1495
- }
1496
- __name(patchFS, "patchFS");
1497
- function checkVariants(request, vfs, parentPath) {
1498
- const path = parentPath ? joinPaths(parentPath, request) : request;
1499
- let file = checkExtensions(path, vfs);
1500
- if (file) {
1501
- return file;
1502
- }
1503
- file = checkIndex(path, vfs);
1504
- if (file) {
1505
- return file;
1506
- }
1507
- return false;
1508
- }
1509
- __name(checkVariants, "checkVariants");
1510
- function checkIndex(request, vfs) {
1511
- let file = joinPaths(request, "index");
1512
- if (vfs.fileExistsSync(file)) {
1513
- return file;
1514
- }
1515
- file = checkExtensions(file, vfs);
1516
- if (file) {
1517
- return file;
1518
- }
1519
- return false;
1520
- }
1521
- __name(checkIndex, "checkIndex");
1522
- function checkExtensions(request, vfs) {
1523
- let file = `${request}.ts`;
1524
- if (vfs.fileExistsSync(file)) {
1525
- return file;
1526
- }
1527
- file = `${request}.mts`;
1528
- if (vfs.fileExistsSync(file)) {
1529
- return file;
1530
- }
1531
- file = `${request}.cts`;
1532
- if (vfs.fileExistsSync(file)) {
1533
- return file;
1534
- }
1535
- file = `${request}.tsx`;
1536
- if (vfs.fileExistsSync(file)) {
1537
- return file;
1538
- }
1539
- file = `${request}.js`;
1540
- if (vfs.fileExistsSync(file)) {
1541
- return file;
1542
- }
1543
- file = `${request}.mjs`;
1544
- if (vfs.fileExistsSync(file)) {
1545
- return file;
1546
- }
1547
- file = `${request}.cjs`;
1548
- if (vfs.fileExistsSync(file)) {
1549
- return file;
1550
- }
1551
- file = `${request}.jsx`;
1552
- if (vfs.fileExistsSync(file)) {
1553
- return file;
1554
- }
1555
- file = `${request}.json`;
1556
- if (vfs.fileExistsSync(file)) {
1557
- return file;
1558
- }
1559
- file = `${request}.d.ts`;
1560
- if (vfs.fileExistsSync(file)) {
1561
- return file;
1562
- }
1563
- return false;
1564
- }
1565
- __name(checkExtensions, "checkExtensions");
1499
+ };
1566
1500
  function createVfs(context) {
1567
1501
  const vfs = new VirtualFileSystem(context);
1568
1502
  return vfs;
@@ -1570,7 +1504,8 @@ function createVfs(context) {
1570
1504
  __name(createVfs, "createVfs");
1571
1505
 
1572
1506
  // src/internal/contexts/context.ts
1573
- var cache = /* @__PURE__ */ new WeakMap();
1507
+ var configCache = /* @__PURE__ */ new WeakMap();
1508
+ var parseCache = /* @__PURE__ */ new WeakMap();
1574
1509
  var PowerlinesContext = class _PowerlinesContext {
1575
1510
  static {
1576
1511
  __name(this, "PowerlinesContext");
@@ -1797,6 +1732,57 @@ var PowerlinesContext = class _PowerlinesContext {
1797
1732
  return relativeToWorkspaceRoot(this.config.projectRoot);
1798
1733
  }
1799
1734
  /**
1735
+ * The builtin module id that exist in the Powerlines virtual file system
1736
+ */
1737
+ get builtins() {
1738
+ return Object.values(this.fs.meta).filter((meta) => meta && meta.variant === "builtin").map((meta) => meta?.id).filter(Boolean);
1739
+ }
1740
+ /**
1741
+ * Get the project root relative to the workspace root
1742
+ */
1743
+ async getBuiltins() {
1744
+ return Promise.all(Object.entries(this.fs.meta).filter(([, meta]) => meta && meta.variant === "builtin").map(async ([path, meta]) => {
1745
+ const code = await this.fs.readFile(path);
1746
+ return {
1747
+ ...meta,
1748
+ path,
1749
+ code
1750
+ };
1751
+ }));
1752
+ }
1753
+ /**
1754
+ * Resolves a entry virtual file and writes it to the VFS if it does not already exist
1755
+ *
1756
+ * @param code - The source code of the entry file
1757
+ * @param path - A path to write the entry file to
1758
+ * @param options - Optional write file options
1759
+ */
1760
+ async writeEntry(code, path, options = {}) {
1761
+ return this.fs.writeFile(isAbsolute(path) ? path : appendPath(path, this.entryPath), {
1762
+ code,
1763
+ variant: "entry"
1764
+ }, defu5(options, {
1765
+ mode: this.config.output.mode
1766
+ }));
1767
+ }
1768
+ /**
1769
+ * Resolves a builtin virtual file and writes it to the VFS if it does not already exist
1770
+ *
1771
+ * @param code - The source code of the builtin file
1772
+ * @param id - The unique identifier of the builtin file
1773
+ * @param path - An optional path to write the builtin file to
1774
+ * @param options - Optional write file options
1775
+ */
1776
+ async writeBuiltin(code, id, path, options = {}) {
1777
+ return this.fs.writeFile(path ? isAbsolute(path) ? path : joinPaths$1(this.builtinsPath, path) : appendPath(id, this.builtinsPath), {
1778
+ id,
1779
+ code,
1780
+ variant: "builtin"
1781
+ }, defu5(options, {
1782
+ mode: this.config.output.mode
1783
+ }));
1784
+ }
1785
+ /**
1800
1786
  * Parses the source code and returns a {@link ParseResult} object.
1801
1787
  *
1802
1788
  * @param code - The source code to parse.
@@ -1805,12 +1791,31 @@ var PowerlinesContext = class _PowerlinesContext {
1805
1791
  * @returns The parsed {@link ParseResult} object.
1806
1792
  */
1807
1793
  async parse(code, id, options = {}) {
1808
- return parseAsync(id, code, defu5(options ?? {}, {
1794
+ if (parseCache.has({
1795
+ code,
1796
+ options
1797
+ })) {
1798
+ return parseCache.get({
1799
+ code,
1800
+ options
1801
+ });
1802
+ }
1803
+ const result = await parseAsync(id, code, defu5(options ?? {}, {
1809
1804
  lang: hasFileExtension(id) ? void 0 : "ts",
1810
1805
  astType: hasFileExtension(id) ? void 0 : "ts",
1811
1806
  sourceType: "module",
1812
1807
  showSemanticErrors: false
1813
1808
  }));
1809
+ if (result.errors && result.errors.length > 0) {
1810
+ throw new Error(`Powerlines parsing errors in file: ${id}
1811
+ ${result.errors.map((error) => ` [${error.severity}] ${error.message}${error.codeframe ? ` (${error.codeframe})` : ""}${error.helpMessage ? `
1812
+ Help: ${error.helpMessage}` : ""}`).join("\n")}`);
1813
+ }
1814
+ parseCache.set({
1815
+ code,
1816
+ options
1817
+ }, result);
1818
+ return result;
1814
1819
  }
1815
1820
  /**
1816
1821
  * Update the context using a new user configuration options
@@ -1899,8 +1904,8 @@ var PowerlinesContext = class _PowerlinesContext {
1899
1904
  configFile: config.configFile ?? this.config.configFile,
1900
1905
  command: this.config.inlineConfig?.command
1901
1906
  };
1902
- if (cache.has(cacheKey)) {
1903
- const result = cache.get(cacheKey);
1907
+ if (configCache.has(cacheKey)) {
1908
+ const result = configCache.get(cacheKey);
1904
1909
  this.projectJson = result.projectJson;
1905
1910
  this.packageJson = result.packageJson;
1906
1911
  this.#checksum = result.checksum;
@@ -1925,7 +1930,7 @@ var PowerlinesContext = class _PowerlinesContext {
1925
1930
  });
1926
1931
  const userConfig = await loadUserConfigFile(cacheKey.projectRoot, this.resolver, cacheKey.command, cacheKey.mode, cacheKey.configFile);
1927
1932
  this.mergeUserConfig(userConfig.config);
1928
- cache.set(cacheKey, {
1933
+ configCache.set(cacheKey, {
1929
1934
  projectJson: this.projectJson,
1930
1935
  packageJson: this.packageJson,
1931
1936
  checksum: this.#checksum,
@@ -2370,6 +2375,26 @@ var PowerlinesAPIContext = class _PowerlinesAPIContext extends PowerlinesContext
2370
2375
  }
2371
2376
  }
2372
2377
  };
2378
+ function getBaseFileHeader(context) {
2379
+ return `
2380
+ // Generated with ${titleCase(context.config.framework)}
2381
+ // Note: Do not edit this file manually - it will be overwritten automatically
2382
+ `;
2383
+ }
2384
+ __name(getBaseFileHeader, "getBaseFileHeader");
2385
+ function getFileHeader(context, options = {}) {
2386
+ const { directive = null, prettierIgnore = false } = options;
2387
+ return `/* eslint-disable */
2388
+ // biome-ignore lint: disable
2389
+ ${prettierIgnore ? `// prettier-ignore` : ""}${directive ? `
2390
+
2391
+ ${directive}
2392
+ ` : "\n"}
2393
+ ${getBaseFileHeader(context)}
2394
+
2395
+ `;
2396
+ }
2397
+ __name(getFileHeader, "getFileHeader");
2373
2398
  function getString(code) {
2374
2399
  if (!code) {
2375
2400
  return "";
@@ -2404,7 +2429,7 @@ function resolveModulePath(nodePath, state) {
2404
2429
  return;
2405
2430
  }
2406
2431
  const sourcePath = nodePath.node.value;
2407
- const resolvedPath = state.context?.fs.resolvePath(sourcePath);
2432
+ const resolvedPath = state.context?.fs.resolve(sourcePath);
2408
2433
  if (resolvedPath) {
2409
2434
  nodePath.replaceWith(t.stringLiteral(
2410
2435
  // Remove the file extension if it exists
@@ -2505,8 +2530,9 @@ var moduleResolverBabelPlugin = /* @__PURE__ */ __name((context) => {
2505
2530
  async function generateTypes(context) {
2506
2531
  context.log(LogLevelLabel.TRACE, `Preparing the TypeScript definitions for the Powerlines project.`);
2507
2532
  context.log(LogLevelLabel.TRACE, "Transforming built-ins runtime modules files.");
2508
- const builtinFiles = await Promise.all((await context.fs.listBuiltinFiles()).filter((file) => !context.fs.isMatchingBuiltinId("index", file.id)).map(async (file) => {
2509
- const result = await transformAsync(file.contents, {
2533
+ const builtinFiles = await context.getBuiltins();
2534
+ const builtinFilePaths = await Promise.all(builtinFiles.map(async (file) => {
2535
+ const result = await transformAsync(file.code.toString(), {
2510
2536
  highlightCode: true,
2511
2537
  code: true,
2512
2538
  ast: false,
@@ -2534,14 +2560,14 @@ async function generateTypes(context) {
2534
2560
  throw new Error(`Powerlines - Generate Types failed to compile ${file.id}`);
2535
2561
  }
2536
2562
  context.log(LogLevelLabel.TRACE, `Writing transformed built-in runtime file ${file.id}.`);
2537
- await context.fs.writeBuiltinFile(file.id, file.path, result.code);
2563
+ await context.writeBuiltin(result.code, file.id, file.path);
2538
2564
  return file.path;
2539
2565
  }));
2540
2566
  const typescriptPath = await resolvePackage("typescript");
2541
2567
  if (!typescriptPath) {
2542
2568
  throw new Error("Could not resolve TypeScript package location. Please ensure TypeScript is installed.");
2543
2569
  }
2544
- const files = builtinFiles.reduce((ret, fileName) => {
2570
+ const files = builtinFilePaths.reduce((ret, fileName) => {
2545
2571
  const formatted = replacePath(fileName, context.workspaceConfig.workspaceRoot);
2546
2572
  if (!ret.includes(formatted)) {
2547
2573
  ret.push(formatted);
@@ -2576,9 +2602,9 @@ async function generateTypes(context) {
2576
2602
  const emitResult = program.emit(void 0, (fileName, text, _, __, sourceFiles, _data) => {
2577
2603
  const sourceFile2 = sourceFiles?.[0];
2578
2604
  if (sourceFile2?.fileName && !fileName.endsWith(".map")) {
2579
- if (context.fs.isBuiltinFile(sourceFile2.fileName)) {
2605
+ if (builtinFiles.some((file) => file.id === sourceFile2.fileName || file.path === sourceFile2.fileName)) {
2580
2606
  builtinModules += `
2581
- declare module "${context.fs.resolveId(sourceFile2.fileName)}" {
2607
+ declare module "${context.fs.resolve(sourceFile2.fileName)}" {
2582
2608
  ${text.trim().replace(/^\s*export\s*declare\s*/gm, "export ").replace(/^\s*declare\s*/gm, "")}
2583
2609
  }
2584
2610
  `;
@@ -2617,7 +2643,9 @@ ${builtinModules}`.replace(
2617
2643
  /import\s*(?:type\s*)?\{?[\w,\s]*(?:\}\s*)?from\s*(?:'|")@?[a-zA-Z0-9-\\/.]*(?:'|");?/g,
2618
2644
  ""
2619
2645
  ).replaceAll("#private;", "").replace(/__Ω/g, ""));
2620
- await context.fs.writeFileToDisk(sourceFile.id, getString(sourceFile.code));
2646
+ await context.fs.writeFile(sourceFile.id, getString(sourceFile.code), {
2647
+ mode: "fs"
2648
+ });
2621
2649
  }
2622
2650
  __name(generateTypes, "generateTypes");
2623
2651
  async function installPackage(context, packageName, dev = false) {
@@ -2781,7 +2809,9 @@ async function initializeTsconfig(context) {
2781
2809
  const tsconfigFilePath = getTsconfigFilePath(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.config.tsconfig);
2782
2810
  context.tsconfig.originalTsconfigJson = await readJsonFile(tsconfigFilePath);
2783
2811
  context.tsconfig.tsconfigJson = await resolveTsconfigChanges(context);
2784
- await context.fs.writeFileToDisk(tsconfigFilePath, StormJSON.stringify(context.tsconfig.tsconfigJson));
2812
+ await context.fs.writeFile(tsconfigFilePath, StormJSON.stringify(context.tsconfig.tsconfigJson), {
2813
+ mode: "fs"
2814
+ });
2785
2815
  context.tsconfig = getParsedTypeScriptConfig(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.config.tsconfig, context.config.tsconfigRaw, context.tsconfig.originalTsconfigJson);
2786
2816
  }
2787
2817
  __name(initializeTsconfig, "initializeTsconfig");
@@ -2917,11 +2947,6 @@ ${formatLogMessage(context.config)}`);
2917
2947
  await this.callPreHook(context, "prepare");
2918
2948
  if (context.config.projectType === "application") {
2919
2949
  context.log(LogLevelLabel.TRACE, "Generating built-in barrel file");
2920
- await context.fs.writeBuiltinFile("index", joinPaths(context.builtinsPath, "index.ts"), `
2921
- ${getFileHeader(context)}
2922
-
2923
- ${(await context.fs.listBuiltinFiles()).filter((file) => !isParentPath(file.path, joinPaths(context.builtinsPath, "log")) && !isParentPath(file.path, joinPaths(context.builtinsPath, "storage"))).map((file) => `export * from "./${replacePath(file.path, context.builtinsPath).replace(`.${findFileExtensionSafe(file.path)}`, "")}";`).join("\n")}
2924
- `);
2925
2950
  }
2926
2951
  if (context.config.output.dts !== false) {
2927
2952
  await generateTypes(context);
@@ -3352,5 +3377,5 @@ Note: Please ensure the plugin package's default export is a class that extends
3352
3377
  };
3353
3378
 
3354
3379
  export { PowerlinesAPI, createLog, getString };
3355
- //# sourceMappingURL=chunk-OEL3BTQP.js.map
3356
- //# sourceMappingURL=chunk-OEL3BTQP.js.map
3380
+ //# sourceMappingURL=chunk-OYIM2M74.js.map
3381
+ //# sourceMappingURL=chunk-OYIM2M74.js.map