powerlines 0.20.0 → 0.22.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 (307) hide show
  1. package/dist/api.cjs +4 -4
  2. package/dist/api.d.cts +7 -8
  3. package/dist/api.d.ts +7 -8
  4. package/dist/api.js +3 -3
  5. package/dist/astro.cjs +10 -10
  6. package/dist/astro.d.cts +1 -2
  7. package/dist/astro.d.ts +1 -2
  8. package/dist/astro.js +7 -7
  9. package/dist/{chunk-WRP6ANCC.js → chunk-237NITCY.js} +20 -5
  10. package/dist/{chunk-LM6YBGC6.cjs → chunk-2HNC5JVK.cjs} +2 -2
  11. package/dist/{chunk-4KCSCJ6E.js → chunk-2Q2PSPZK.js} +1 -1
  12. package/dist/{chunk-24AZZCCW.js → chunk-3FS7K4DZ.js} +1 -1
  13. package/dist/{chunk-OQNYDN5F.cjs → chunk-3JH36WUJ.cjs} +2 -2
  14. package/dist/{chunk-CTSV5JAF.cjs → chunk-44UTUCBG.cjs} +21 -8
  15. package/dist/{chunk-MOH4CWHN.cjs → chunk-6XRDZOE3.cjs} +968 -664
  16. package/dist/{chunk-MZQXGWUK.cjs → chunk-7C2NEC7D.cjs} +2 -2
  17. package/dist/{chunk-SIEHJFKB.js → chunk-A5GTERYN.js} +2 -2
  18. package/dist/chunk-B4KLWFY6.cjs +32 -0
  19. package/dist/{chunk-FBMQTOMN.js → chunk-C5TKY75S.js} +1 -1
  20. package/dist/{chunk-T4AJOD6A.cjs → chunk-DMXXNXLS.cjs} +4 -4
  21. package/dist/{chunk-IHWRGHX6.cjs → chunk-F4BD5CXH.cjs} +2 -2
  22. package/dist/chunk-GRAVJX3I.js +29 -0
  23. package/dist/{chunk-WE7PLY4H.cjs → chunk-HV7SHEHD.cjs} +11 -4
  24. package/dist/{chunk-WJ4CZKXY.js → chunk-JKBJF3UI.js} +1 -1
  25. package/dist/{chunk-2QGVOWKM.js → chunk-L4AXJFX2.js} +19 -6
  26. package/dist/{chunk-VXF37DA2.cjs → chunk-LKYBC6DX.cjs} +4 -4
  27. package/dist/{chunk-A2EZ3M22.js → chunk-M6XGEVJY.js} +1 -1
  28. package/dist/{chunk-FYKDALJL.js → chunk-NZXMP4J5.js} +1 -1
  29. package/dist/{chunk-F4TS44KB.js → chunk-OZU47JET.js} +999 -702
  30. package/dist/{chunk-FCTNMPJF.cjs → chunk-PAMSESZV.cjs} +1 -1
  31. package/dist/{chunk-TY3QAXEY.js → chunk-PDFOF6ZP.js} +11 -4
  32. package/dist/{chunk-IMMNZSFZ.cjs → chunk-PJP4MECA.cjs} +2 -2
  33. package/dist/{chunk-VSZXQLMI.js → chunk-QQGXARP3.js} +1 -1
  34. package/dist/{chunk-6UVRB3IN.cjs → chunk-SQANNMRF.cjs} +22 -7
  35. package/dist/{chunk-2KGMZZ36.js → chunk-SVDPKN3U.js} +1 -1
  36. package/dist/chunk-SVF4ATJR.cjs +8 -0
  37. package/dist/{chunk-VVFIZVYE.cjs → chunk-UVM4JAR3.cjs} +2 -2
  38. package/dist/{chunk-JKF342AW.js → chunk-WU7I52LM.js} +2 -2
  39. package/dist/{chunk-P3BP6LXC.cjs → chunk-WYJGOC3Y.cjs} +2 -2
  40. package/dist/{chunk-KL7HP7JM.cjs → chunk-YG5ORYN2.cjs} +2 -2
  41. package/dist/{chunk-QH3M5FBF.js → chunk-ZPOCM5XZ.js} +1 -1
  42. package/dist/chunk-ZWF7LZXE.js +5 -0
  43. package/dist/config.d.cts +1 -2
  44. package/dist/config.d.ts +1 -2
  45. package/dist/esbuild.cjs +9 -9
  46. package/dist/esbuild.d.cts +1 -2
  47. package/dist/esbuild.d.ts +1 -2
  48. package/dist/esbuild.js +6 -6
  49. package/dist/farm.cjs +5 -5
  50. package/dist/farm.d.cts +1 -2
  51. package/dist/farm.d.ts +1 -2
  52. package/dist/farm.js +4 -4
  53. package/dist/{hooks-CUxY7WKY.d.cts → hooks-CJ1W5lrx.d.cts} +1 -1
  54. package/dist/{hooks-BBZyf9CN.d.ts → hooks-CNEZpkMS.d.ts} +1 -1
  55. package/dist/index.cjs +45 -287
  56. package/dist/index.d.cts +3 -4
  57. package/dist/index.d.ts +3 -4
  58. package/dist/index.js +20 -244
  59. package/dist/lib/build/esbuild.cjs +5 -5
  60. package/dist/lib/build/esbuild.d.cts +1 -3
  61. package/dist/lib/build/esbuild.d.ts +1 -3
  62. package/dist/lib/build/esbuild.js +2 -2
  63. package/dist/lib/build/index.cjs +23 -23
  64. package/dist/lib/build/index.d.cts +2 -4
  65. package/dist/lib/build/index.d.ts +2 -4
  66. package/dist/lib/build/index.js +8 -8
  67. package/dist/lib/build/rolldown.cjs +3 -3
  68. package/dist/lib/build/rolldown.d.cts +1 -3
  69. package/dist/lib/build/rolldown.d.ts +1 -3
  70. package/dist/lib/build/rolldown.js +2 -2
  71. package/dist/lib/build/rollup.cjs +3 -3
  72. package/dist/lib/build/rollup.d.cts +1 -3
  73. package/dist/lib/build/rollup.d.ts +1 -3
  74. package/dist/lib/build/rollup.js +1 -1
  75. package/dist/lib/build/rspack.d.cts +1 -3
  76. package/dist/lib/build/rspack.d.ts +1 -3
  77. package/dist/lib/build/tsup.cjs +6 -6
  78. package/dist/lib/build/tsup.d.cts +1 -3
  79. package/dist/lib/build/tsup.d.ts +1 -3
  80. package/dist/lib/build/tsup.js +3 -3
  81. package/dist/lib/build/unbuild.cjs +5 -5
  82. package/dist/lib/build/unbuild.d.cts +2 -4
  83. package/dist/lib/build/unbuild.d.ts +2 -4
  84. package/dist/lib/build/unbuild.js +2 -2
  85. package/dist/lib/build/vite.cjs +5 -5
  86. package/dist/lib/build/vite.d.cts +1 -3
  87. package/dist/lib/build/vite.d.ts +1 -3
  88. package/dist/lib/build/vite.js +3 -3
  89. package/dist/lib/build/webpack.cjs +2 -2
  90. package/dist/lib/build/webpack.d.cts +1 -3
  91. package/dist/lib/build/webpack.d.ts +1 -3
  92. package/dist/lib/build/webpack.js +1 -1
  93. package/dist/lib/{chunk-K4FER6YK.cjs → chunk-27VJFYDM.cjs} +13 -6
  94. package/dist/lib/{chunk-ZJNDT3GX.js → chunk-3G4C3YAU.js} +12 -5
  95. package/dist/lib/{chunk-TTKY3DR4.js → chunk-43VJVIL2.js} +975 -679
  96. package/dist/lib/{chunk-CLV4J4L7.cjs → chunk-4FX4VOLA.cjs} +2 -3
  97. package/dist/lib/{chunk-DFRWBQQT.js → chunk-5GM5UAUO.js} +3 -4
  98. package/dist/lib/{chunk-S5F4DE65.js → chunk-5SADLYYK.js} +1 -1
  99. package/dist/lib/{chunk-TNHDC2ZQ.cjs → chunk-7XHBIYIN.cjs} +1 -20
  100. package/dist/lib/{chunk-SM3S7DYW.js → chunk-BHDQZ6YX.js} +12 -2
  101. package/dist/lib/{chunk-FGYAS4NB.cjs → chunk-CSJ6KNIX.cjs} +11 -4
  102. package/dist/lib/{chunk-O36FCQM6.cjs → chunk-E2MVGKGH.cjs} +2 -2
  103. package/dist/lib/{chunk-O5LNKYQV.cjs → chunk-FN7673NC.cjs} +2 -2
  104. package/dist/lib/{chunk-HIY6WOU3.cjs → chunk-GDXHCTCX.cjs} +13 -6
  105. package/dist/lib/{chunk-IBONIIAZ.cjs → chunk-HCOHRD3Q.cjs} +19 -6
  106. package/dist/lib/{chunk-OI2V6L7D.js → chunk-HOZ37BFN.js} +2 -3
  107. package/dist/lib/{chunk-4QRL5CNE.js → chunk-HQ5YA43H.js} +11 -4
  108. package/dist/lib/{chunk-IXREPTHZ.js → chunk-IOM7GRZU.js} +1 -1
  109. package/dist/lib/{chunk-WFUO3YPK.js → chunk-L4NEN725.js} +19 -4
  110. package/dist/lib/{chunk-H7V7EPB2.cjs → chunk-LAFEAMNN.cjs} +2 -2
  111. package/dist/lib/{chunk-7Y5MJRWF.js → chunk-LIN4KAV3.js} +57 -34
  112. package/dist/lib/{chunk-MWA3DWY5.cjs → chunk-LMO7PRBP.cjs} +4 -5
  113. package/dist/lib/{chunk-ARCFV3IJ.cjs → chunk-LPA7UJIR.cjs} +955 -657
  114. package/dist/lib/{chunk-OTBLE55Z.cjs → chunk-MPCVQK2D.cjs} +12 -1
  115. package/dist/lib/{chunk-4RUHX7LV.js → chunk-QAXCBFBP.js} +1 -1
  116. package/dist/lib/{chunk-WWNNBLU7.js → chunk-T7RMV2FW.js} +18 -5
  117. package/dist/lib/{chunk-7K7JH3DF.cjs → chunk-ULJVBW4L.cjs} +19 -4
  118. package/dist/lib/{chunk-UDJ37BEE.cjs → chunk-VGSV2BEL.cjs} +57 -34
  119. package/dist/lib/{chunk-GRJJZ5VJ.js → chunk-YH5GOJS3.js} +2 -15
  120. package/dist/lib/{chunk-NU4GDWLL.js → chunk-YV6MDKW4.js} +12 -5
  121. package/dist/lib/{config-DN8Ad0lv.d.cts → config-7vXtXiGg.d.cts} +67 -67
  122. package/dist/lib/{config-Bag1Ft7u.d.ts → config-B9aVEiiX.d.ts} +67 -67
  123. package/dist/lib/config-file.d.cts +1 -3
  124. package/dist/lib/config-file.d.ts +1 -3
  125. package/dist/lib/create-program.d.cts +1 -3
  126. package/dist/lib/create-program.d.ts +1 -3
  127. package/dist/lib/entry.cjs +9 -9
  128. package/dist/lib/entry.d.cts +1 -3
  129. package/dist/lib/entry.d.ts +1 -3
  130. package/dist/lib/entry.js +1 -1
  131. package/dist/lib/{hooks-BVnPAWgt.d.ts → hooks-BxUBzqCb.d.ts} +1 -1
  132. package/dist/lib/{hooks-H2P-7xA4.d.cts → hooks-cvv50JDh.d.cts} +1 -1
  133. package/dist/lib/index.cjs +32 -28
  134. package/dist/lib/index.d.cts +326 -7
  135. package/dist/lib/index.d.ts +326 -7
  136. package/dist/lib/index.js +8 -8
  137. package/dist/lib/logger.d.cts +1 -3
  138. package/dist/lib/logger.d.ts +1 -3
  139. package/dist/lib/typescript/compiler-host.d.cts +1 -3
  140. package/dist/lib/typescript/compiler-host.d.ts +1 -3
  141. package/dist/lib/typescript/import-transformer.d.cts +1 -3
  142. package/dist/lib/typescript/import-transformer.d.ts +1 -3
  143. package/dist/lib/typescript/index.d.cts +1 -3
  144. package/dist/lib/typescript/index.d.ts +1 -3
  145. package/dist/lib/typescript/program.d.cts +1 -3
  146. package/dist/lib/typescript/program.d.ts +1 -3
  147. package/dist/lib/unplugin/factory.cjs +5 -5
  148. package/dist/lib/unplugin/factory.d.cts +7 -9
  149. package/dist/lib/unplugin/factory.d.ts +7 -9
  150. package/dist/lib/unplugin/factory.js +4 -4
  151. package/dist/lib/unplugin/index.cjs +8 -8
  152. package/dist/lib/unplugin/index.d.cts +2 -4
  153. package/dist/lib/unplugin/index.d.ts +2 -4
  154. package/dist/lib/unplugin/index.js +5 -5
  155. package/dist/lib/unplugin/plugin.cjs +3 -3
  156. package/dist/lib/unplugin/plugin.d.cts +1 -3
  157. package/dist/lib/unplugin/plugin.d.ts +1 -3
  158. package/dist/lib/unplugin/plugin.js +2 -2
  159. package/dist/lib/unplugin/resolve-id.cjs +2 -2
  160. package/dist/lib/unplugin/resolve-id.d.cts +1 -3
  161. package/dist/lib/unplugin/resolve-id.d.ts +1 -3
  162. package/dist/lib/unplugin/resolve-id.js +1 -1
  163. package/dist/lib/utilities/bundle.cjs +4 -4
  164. package/dist/lib/utilities/bundle.d.cts +1 -3
  165. package/dist/lib/utilities/bundle.d.ts +1 -3
  166. package/dist/lib/utilities/bundle.js +3 -3
  167. package/dist/lib/utilities/cache.d.cts +1 -3
  168. package/dist/lib/utilities/cache.d.ts +1 -3
  169. package/dist/lib/utilities/file-header.d.cts +1 -3
  170. package/dist/lib/utilities/file-header.d.ts +1 -3
  171. package/dist/lib/utilities/index.cjs +14 -14
  172. package/dist/lib/utilities/index.d.cts +1 -3
  173. package/dist/lib/utilities/index.d.ts +1 -3
  174. package/dist/lib/utilities/index.js +5 -5
  175. package/dist/lib/utilities/meta.cjs +8 -8
  176. package/dist/lib/utilities/meta.d.cts +1 -3
  177. package/dist/lib/utilities/meta.d.ts +1 -3
  178. package/dist/lib/utilities/meta.js +1 -1
  179. package/dist/lib/utilities/resolve-path.d.cts +1 -3
  180. package/dist/lib/utilities/resolve-path.d.ts +1 -3
  181. package/dist/lib/utilities/resolve.cjs +5 -5
  182. package/dist/lib/utilities/resolve.d.cts +1 -3
  183. package/dist/lib/utilities/resolve.d.ts +1 -3
  184. package/dist/lib/utilities/resolve.js +4 -4
  185. package/dist/lib/utilities/source-file.d.cts +1 -3
  186. package/dist/lib/utilities/source-file.d.ts +1 -3
  187. package/dist/lib/utilities/source-map.d.cts +1 -3
  188. package/dist/lib/utilities/source-map.d.ts +1 -3
  189. package/dist/lib/utilities/worker.d.cts +1 -3
  190. package/dist/lib/utilities/worker.d.ts +1 -3
  191. package/dist/lib/utilities/write-file.d.cts +1 -3
  192. package/dist/lib/utilities/write-file.d.ts +1 -3
  193. package/dist/next.cjs +9 -9
  194. package/dist/next.js +6 -6
  195. package/dist/nuxt.cjs +11 -11
  196. package/dist/nuxt.js +8 -8
  197. package/dist/plugin-utils/{chunk-YKIS7BLU.cjs → chunk-5MO4BCOW.cjs} +24 -0
  198. package/dist/plugin-utils/{chunk-HHFA3IEZ.js → chunk-CYVV2MB7.js} +24 -0
  199. package/dist/plugin-utils/chunk-DGUQQKZF.js +41 -0
  200. package/dist/plugin-utils/{chunk-75UVEMIV.cjs → chunk-DZZPNO5H.cjs} +2 -2
  201. package/dist/plugin-utils/{chunk-WEIEQXIJ.cjs → chunk-ECFS7DPV.cjs} +5 -5
  202. package/dist/plugin-utils/{chunk-MQOW6ENT.cjs → chunk-F65J5WOX.cjs} +1 -1
  203. package/dist/plugin-utils/{chunk-IHME6YWJ.js → chunk-GV7O3E7P.js} +1 -1
  204. package/dist/plugin-utils/chunk-HZIY2AV4.cjs +43 -0
  205. package/dist/plugin-utils/{chunk-PK6PYFWY.js → chunk-L277XSSN.js} +1 -1
  206. package/dist/plugin-utils/{chunk-YDYJAGMP.js → chunk-QKMG6ZAU.js} +1 -1
  207. package/dist/plugin-utils/{chunk-5TL6KEQ5.cjs → chunk-UNAGYQRB.cjs} +4 -4
  208. package/dist/plugin-utils/{chunk-432MQOUZ.js → chunk-XIXI67PY.js} +1 -1
  209. package/dist/plugin-utils/{config-pwKiZvzJ.d.cts → context-BseW8r26.d.cts} +406 -406
  210. package/dist/plugin-utils/{config-pwKiZvzJ.d.ts → context-BseW8r26.d.ts} +406 -406
  211. package/dist/plugin-utils/context-helpers.cjs +11 -0
  212. package/dist/plugin-utils/context-helpers.d.cts +29 -0
  213. package/dist/plugin-utils/context-helpers.d.ts +29 -0
  214. package/dist/plugin-utils/context-helpers.js +2 -0
  215. package/dist/plugin-utils/enforce.cjs +5 -5
  216. package/dist/plugin-utils/enforce.d.cts +9 -11
  217. package/dist/plugin-utils/enforce.d.ts +9 -11
  218. package/dist/plugin-utils/enforce.js +4 -4
  219. package/dist/plugin-utils/extend.cjs +4 -4
  220. package/dist/plugin-utils/extend.d.cts +9 -11
  221. package/dist/plugin-utils/extend.d.ts +9 -11
  222. package/dist/plugin-utils/extend.js +3 -3
  223. package/dist/plugin-utils/get-config-path.cjs +2 -2
  224. package/dist/plugin-utils/get-config-path.d.cts +9 -11
  225. package/dist/plugin-utils/get-config-path.d.ts +9 -11
  226. package/dist/plugin-utils/get-config-path.js +1 -1
  227. package/dist/plugin-utils/helpers.cjs +14 -14
  228. package/dist/plugin-utils/helpers.d.cts +7 -9
  229. package/dist/plugin-utils/helpers.d.ts +7 -9
  230. package/dist/plugin-utils/helpers.js +1 -1
  231. package/dist/plugin-utils/index.cjs +27 -22
  232. package/dist/plugin-utils/index.d.cts +10 -11
  233. package/dist/plugin-utils/index.d.ts +10 -11
  234. package/dist/plugin-utils/index.js +6 -5
  235. package/dist/plugin-utils/merge.cjs +3 -3
  236. package/dist/plugin-utils/merge.d.cts +9 -11
  237. package/dist/plugin-utils/merge.d.ts +9 -11
  238. package/dist/plugin-utils/merge.js +2 -2
  239. package/dist/plugin-utils/paths.d.cts +9 -11
  240. package/dist/plugin-utils/paths.d.ts +9 -11
  241. package/dist/{resolved-ohMN-3VJ.d.cts → resolved-D8vIizyA.d.cts} +15 -16
  242. package/dist/{resolved-Sxyrlt6g.d.ts → resolved-DWxXKJYy.d.ts} +15 -16
  243. package/dist/rolldown.cjs +8 -8
  244. package/dist/rolldown.d.cts +1 -2
  245. package/dist/rolldown.d.ts +1 -2
  246. package/dist/rolldown.js +5 -5
  247. package/dist/rollup.cjs +8 -8
  248. package/dist/rollup.d.cts +1 -2
  249. package/dist/rollup.d.ts +1 -2
  250. package/dist/rollup.js +5 -5
  251. package/dist/rspack.cjs +8 -8
  252. package/dist/rspack.d.cts +1 -2
  253. package/dist/rspack.d.ts +1 -2
  254. package/dist/rspack.js +5 -5
  255. package/dist/tsup.cjs +10 -10
  256. package/dist/tsup.js +7 -7
  257. package/dist/types/babel.d.cts +1 -2
  258. package/dist/types/babel.d.ts +1 -2
  259. package/dist/types/build.d.cts +18 -1
  260. package/dist/types/build.d.ts +18 -1
  261. package/dist/types/commands.cjs +2 -2
  262. package/dist/types/commands.d.cts +1 -2
  263. package/dist/types/commands.d.ts +1 -2
  264. package/dist/types/commands.js +1 -1
  265. package/dist/types/config.d.cts +1 -2
  266. package/dist/types/config.d.ts +1 -2
  267. package/dist/types/context.d.cts +1 -2
  268. package/dist/types/context.d.ts +1 -2
  269. package/dist/types/hooks.d.cts +1 -2
  270. package/dist/types/hooks.d.ts +1 -2
  271. package/dist/types/index.cjs +6 -22
  272. package/dist/types/index.d.cts +2 -3
  273. package/dist/types/index.d.ts +2 -3
  274. package/dist/types/index.js +2 -2
  275. package/dist/types/internal.d.cts +2 -3
  276. package/dist/types/internal.d.ts +2 -3
  277. package/dist/types/plugin.d.cts +1 -2
  278. package/dist/types/plugin.d.ts +1 -2
  279. package/dist/types/resolved.d.cts +1 -2
  280. package/dist/types/resolved.d.ts +1 -2
  281. package/dist/types/unplugin.d.cts +1 -2
  282. package/dist/types/unplugin.d.ts +1 -2
  283. package/dist/types/vfs.cjs +4 -20
  284. package/dist/types/vfs.d.cts +47 -54
  285. package/dist/types/vfs.d.ts +47 -54
  286. package/dist/types/vfs.js +1 -1
  287. package/dist/unloader.cjs +8 -8
  288. package/dist/unloader.d.cts +1 -2
  289. package/dist/unloader.d.ts +1 -2
  290. package/dist/unloader.js +5 -5
  291. package/dist/unplugin.cjs +20 -20
  292. package/dist/unplugin.d.cts +2 -3
  293. package/dist/unplugin.d.ts +2 -3
  294. package/dist/unplugin.js +17 -17
  295. package/dist/vite.cjs +9 -9
  296. package/dist/vite.d.cts +1 -2
  297. package/dist/vite.d.ts +1 -2
  298. package/dist/vite.js +6 -6
  299. package/dist/webpack.cjs +8 -8
  300. package/dist/webpack.d.cts +1 -2
  301. package/dist/webpack.d.ts +1 -2
  302. package/dist/webpack.js +5 -5
  303. package/package.json +3 -3
  304. package/dist/chunk-OBYFBPPO.js +0 -9
  305. package/dist/chunk-RF6RSWD4.cjs +0 -16
  306. package/dist/chunk-SECEPZQ3.cjs +0 -32
  307. package/dist/chunk-XBS3AHAK.js +0 -29
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
3
  var chunkETKZMGLN_cjs = require('./chunk-ETKZMGLN.cjs');
4
- var chunkRF6RSWD4_cjs = require('./chunk-RF6RSWD4.cjs');
5
- var chunkFCTNMPJF_cjs = require('./chunk-FCTNMPJF.cjs');
4
+ var chunkSVF4ATJR_cjs = require('./chunk-SVF4ATJR.cjs');
5
+ var chunkPAMSESZV_cjs = require('./chunk-PAMSESZV.cjs');
6
6
  var chunkUSNT2KNT_cjs = require('./chunk-USNT2KNT.cjs');
7
7
  var core = require('@babel/core');
8
8
  var console = require('@storm-software/config-tools/logger/console');
@@ -25,7 +25,7 @@ var isSet = require('@stryke/type-checks/is-set');
25
25
  var isSetObject = require('@stryke/type-checks/is-set-object');
26
26
  var isSetString = require('@stryke/type-checks/is-set-string');
27
27
  var chalk5 = require('chalk');
28
- var defu4 = require('defu');
28
+ var defu3 = require('defu');
29
29
  var Handlebars = require('handlebars');
30
30
  var helperPluginUtils = require('@babel/helper-plugin-utils');
31
31
  var t = require('@babel/types');
@@ -49,23 +49,25 @@ var uuid = require('@stryke/unique-id/uuid');
49
49
  var oxcParser = require('oxc-parser');
50
50
  var parseTypeDefinition = require('@stryke/convert/parse-type-definition');
51
51
  var isFile = require('@stryke/fs/is-file');
52
+ var $ = require('@stryke/capnp');
53
+ var bufferToString = require('@stryke/convert/buffer-to-string');
54
+ var buffer = require('@stryke/fs/buffer');
55
+ var prettyBytes = require('@stryke/string-format/pretty-bytes');
56
+ var isBuffer = require('@stryke/type-checks/is-buffer');
57
+ var buffer$1 = require('buffer');
58
+ var fs = require('fs');
59
+ var prettier = require('prettier');
52
60
  var logger = require('@storm-software/config-tools/logger');
53
61
  var colors = require('@storm-software/config-tools/utilities/colors');
54
62
  var noop = require('@stryke/helpers/noop');
63
+ var isUndefined = require('@stryke/type-checks/is-undefined');
64
+ var isParentPath = require('@stryke/path/is-parent-path');
65
+ var volume = require('memfs/lib/node/volume');
66
+ var unionfs = require('unionfs');
55
67
  require('@stryke/fs/remove-file');
56
68
  var hashFiles = require('@stryke/hash/hash-files');
57
69
  var kebabCase = require('@stryke/string-format/kebab-case');
58
- var isUndefined = require('@stryke/type-checks/is-undefined');
59
70
  var jiti = require('jiti');
60
- var bufferToString = require('@stryke/convert/buffer-to-string');
61
- var isParentPath = require('@stryke/path/is-parent-path');
62
- var prettyBytes = require('@stryke/string-format/pretty-bytes');
63
- var isBuffer = require('@stryke/type-checks/is-buffer');
64
- var memfs = require('memfs');
65
- var buffer = require('buffer');
66
- var fs = require('fs');
67
- var prettier = require('prettier');
68
- var unionfs = require('unionfs');
69
71
  var isObject = require('@stryke/type-checks/is-object');
70
72
  var ts2 = require('typescript');
71
73
  var _package = require('@stryke/string-format/package');
@@ -94,9 +96,10 @@ function _interopNamespace(e) {
94
96
  }
95
97
 
96
98
  var chalk5__default = /*#__PURE__*/_interopDefault(chalk5);
97
- var defu4__default = /*#__PURE__*/_interopDefault(defu4);
99
+ var defu3__default = /*#__PURE__*/_interopDefault(defu3);
98
100
  var Handlebars__default = /*#__PURE__*/_interopDefault(Handlebars);
99
101
  var t__namespace = /*#__PURE__*/_interopNamespace(t);
102
+ var $__namespace = /*#__PURE__*/_interopNamespace($);
100
103
  var fs__default = /*#__PURE__*/_interopDefault(fs);
101
104
  var ts2__default = /*#__PURE__*/_interopDefault(ts2);
102
105
 
@@ -202,7 +205,7 @@ var moduleResolverBabelPlugin = /* @__PURE__ */ chunkUSNT2KNT_cjs.__name((contex
202
205
  }, "builder"));
203
206
  }, "moduleResolverBabelPlugin");
204
207
  async function loadWorkspaceConfig(workspaceRoot, cwd) {
205
- return defu4__default.default({
208
+ return defu3__default.default({
206
209
  workspaceRoot
207
210
  }, await getConfig.getWorkspaceConfig(true, {
208
211
  cwd,
@@ -244,7 +247,7 @@ async function loadUserConfigFile(projectRoot, jiti, command, mode, configFile,
244
247
  dotenv: true,
245
248
  jiti
246
249
  });
247
- return defu4__default.default(resolvedUserConfig, isSetObject.isSetObject(result?.config) ? {
250
+ return defu3__default.default(resolvedUserConfig, isSetObject.isSetObject(result?.config) ? {
248
251
  ...result.config,
249
252
  ...result
250
253
  } : {});
@@ -252,7 +255,7 @@ async function loadUserConfigFile(projectRoot, jiti, command, mode, configFile,
252
255
  chunkUSNT2KNT_cjs.__name(loadUserConfigFile, "loadUserConfigFile");
253
256
  var DEFAULT_ENVIRONMENT = "default";
254
257
  function createEnvironment(name, userConfig) {
255
- return defu4__default.default(userConfig.environments?.[name] ?? {}, {
258
+ return defu3__default.default(userConfig.environments?.[name] ?? {}, {
256
259
  name,
257
260
  title: userConfig.title || titleCase.titleCase(userConfig.name),
258
261
  ssr: false,
@@ -295,6 +298,15 @@ function createDefaultEnvironment(userConfig) {
295
298
  return createEnvironment(DEFAULT_ENVIRONMENT, userConfig);
296
299
  }
297
300
  chunkUSNT2KNT_cjs.__name(createDefaultEnvironment, "createDefaultEnvironment");
301
+ function replacePathTokens(context, path) {
302
+ if (!path) {
303
+ return path;
304
+ }
305
+ 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("{artifactsPath}", replace.replacePath(context.artifactsPath, context.workspaceConfig.workspaceRoot)).replaceAll("{builtinPath}", replace.replacePath(context.builtinsPath, context.workspaceConfig.workspaceRoot)).replaceAll("{entryPath}", replace.replacePath(context.entryPath, context.workspaceConfig.workspaceRoot));
306
+ }
307
+ chunkUSNT2KNT_cjs.__name(replacePathTokens, "replacePathTokens");
308
+
309
+ // src/lib/entry.ts
298
310
  function resolveEntryInputFile(context, typeDefinition) {
299
311
  return replace.replacePath(typeDefinition.file, joinPaths.joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot));
300
312
  }
@@ -320,7 +332,7 @@ function resolveEntry(context, typeDefinition) {
320
332
  }
321
333
  chunkUSNT2KNT_cjs.__name(resolveEntry, "resolveEntry");
322
334
  function resolveEntriesSync(context, typeDefinitions) {
323
- return typeDefinitions.map((typeDefinition) => {
335
+ return typeDefinitions.map((entry) => isString.isString(entry) ? replacePathTokens(context, entry) : replacePathTokens(context, entry.file)).map((typeDefinition) => {
324
336
  const parsed = parseTypeDefinition.parseTypeDefinition(typeDefinition);
325
337
  const filePath = append.appendPath(parsed.file, context.config.projectRoot);
326
338
  if (isFile.isFile(filePath)) {
@@ -342,6 +354,228 @@ function getUniqueEntries(entries = []) {
342
354
  }));
343
355
  }
344
356
  chunkUSNT2KNT_cjs.__name(getUniqueEntries, "getUniqueEntries");
357
+ var _capnpFileId = BigInt("0xa56c61324b9d6e49");
358
+ var FileMetadata_KeyValuePair = class extends $__namespace.Struct {
359
+ static {
360
+ chunkUSNT2KNT_cjs.__name(this, "FileMetadata_KeyValuePair");
361
+ }
362
+ static _capnp = {
363
+ displayName: "KeyValuePair",
364
+ id: "eabb26cf58b2a14c",
365
+ size: new $__namespace.ObjectSize(0, 2)
366
+ };
367
+ get key() {
368
+ return $__namespace.utils.getText(0, this);
369
+ }
370
+ set key(value) {
371
+ $__namespace.utils.setText(0, value, this);
372
+ }
373
+ get value() {
374
+ return $__namespace.utils.getText(1, this);
375
+ }
376
+ set value(value) {
377
+ $__namespace.utils.setText(1, value, this);
378
+ }
379
+ toString() {
380
+ return "FileMetadata_KeyValuePair_" + super.toString();
381
+ }
382
+ };
383
+ var FileMetadata = class _FileMetadata extends $__namespace.Struct {
384
+ static {
385
+ chunkUSNT2KNT_cjs.__name(this, "FileMetadata");
386
+ }
387
+ static KeyValuePair = FileMetadata_KeyValuePair;
388
+ static _capnp = {
389
+ displayName: "FileMetadata",
390
+ id: "8e2cab5d7e28c7b3",
391
+ size: new $__namespace.ObjectSize(0, 4),
392
+ defaultVariant: "normal"
393
+ };
394
+ static _Properties;
395
+ /**
396
+ * The variant of the file.
397
+ *
398
+ */
399
+ get id() {
400
+ return $__namespace.utils.getText(0, this);
401
+ }
402
+ set id(value) {
403
+ $__namespace.utils.setText(0, value, this);
404
+ }
405
+ /**
406
+ * The output mode of the file.
407
+ *
408
+ */
409
+ get variant() {
410
+ return $__namespace.utils.getText(1, this, _FileMetadata._capnp.defaultVariant);
411
+ }
412
+ set variant(value) {
413
+ $__namespace.utils.setText(1, value, this);
414
+ }
415
+ /**
416
+ * Additional metadata associated with the file.
417
+ *
418
+ */
419
+ get mode() {
420
+ return $__namespace.utils.getText(2, this);
421
+ }
422
+ set mode(value) {
423
+ $__namespace.utils.setText(2, value, this);
424
+ }
425
+ _adoptProperties(value) {
426
+ $__namespace.utils.adopt(value, $__namespace.utils.getPointer(3, this));
427
+ }
428
+ _disownProperties() {
429
+ return $__namespace.utils.disown(this.properties);
430
+ }
431
+ get properties() {
432
+ return $__namespace.utils.getList(3, _FileMetadata._Properties, this);
433
+ }
434
+ _hasProperties() {
435
+ return !$__namespace.utils.isNull($__namespace.utils.getPointer(3, this));
436
+ }
437
+ _initProperties(length) {
438
+ return $__namespace.utils.initList(3, _FileMetadata._Properties, length, this);
439
+ }
440
+ set properties(value) {
441
+ $__namespace.utils.copyFrom(value, $__namespace.utils.getPointer(3, this));
442
+ }
443
+ toString() {
444
+ return "FileMetadata_" + super.toString();
445
+ }
446
+ };
447
+ var FileIdentifier = class extends $__namespace.Struct {
448
+ static {
449
+ chunkUSNT2KNT_cjs.__name(this, "FileIdentifier");
450
+ }
451
+ static _capnp = {
452
+ displayName: "FileIdentifier",
453
+ id: "e12b8732389d7406",
454
+ size: new $__namespace.ObjectSize(0, 2)
455
+ };
456
+ /**
457
+ * An additional identifier for the file.
458
+ *
459
+ */
460
+ get path() {
461
+ return $__namespace.utils.getText(0, this);
462
+ }
463
+ set path(value) {
464
+ $__namespace.utils.setText(0, value, this);
465
+ }
466
+ get id() {
467
+ return $__namespace.utils.getText(1, this);
468
+ }
469
+ set id(value) {
470
+ $__namespace.utils.setText(1, value, this);
471
+ }
472
+ toString() {
473
+ return "FileIdentifier_" + super.toString();
474
+ }
475
+ };
476
+ var FileData = class extends $__namespace.Struct {
477
+ static {
478
+ chunkUSNT2KNT_cjs.__name(this, "FileData");
479
+ }
480
+ static _capnp = {
481
+ displayName: "FileData",
482
+ id: "fa6725c8a360f9a2",
483
+ size: new $__namespace.ObjectSize(0, 2)
484
+ };
485
+ /**
486
+ * The contents of the file.
487
+ *
488
+ */
489
+ get path() {
490
+ return $__namespace.utils.getText(0, this);
491
+ }
492
+ set path(value) {
493
+ $__namespace.utils.setText(0, value, this);
494
+ }
495
+ get content() {
496
+ return $__namespace.utils.getText(1, this);
497
+ }
498
+ set content(value) {
499
+ $__namespace.utils.setText(1, value, this);
500
+ }
501
+ toString() {
502
+ return "FileData_" + super.toString();
503
+ }
504
+ };
505
+ var FileSystemData = class _FileSystemData extends $__namespace.Struct {
506
+ static {
507
+ chunkUSNT2KNT_cjs.__name(this, "FileSystemData");
508
+ }
509
+ static _capnp = {
510
+ displayName: "FileSystemData",
511
+ id: "aaa72a672ac0732f",
512
+ size: new $__namespace.ObjectSize(0, 3)
513
+ };
514
+ static _Ids;
515
+ static _Metadata;
516
+ static _Files;
517
+ _adoptIds(value) {
518
+ $__namespace.utils.adopt(value, $__namespace.utils.getPointer(0, this));
519
+ }
520
+ _disownIds() {
521
+ return $__namespace.utils.disown(this.ids);
522
+ }
523
+ get ids() {
524
+ return $__namespace.utils.getList(0, _FileSystemData._Ids, this);
525
+ }
526
+ _hasIds() {
527
+ return !$__namespace.utils.isNull($__namespace.utils.getPointer(0, this));
528
+ }
529
+ _initIds(length) {
530
+ return $__namespace.utils.initList(0, _FileSystemData._Ids, length, this);
531
+ }
532
+ set ids(value) {
533
+ $__namespace.utils.copyFrom(value, $__namespace.utils.getPointer(0, this));
534
+ }
535
+ _adoptMetadata(value) {
536
+ $__namespace.utils.adopt(value, $__namespace.utils.getPointer(1, this));
537
+ }
538
+ _disownMetadata() {
539
+ return $__namespace.utils.disown(this.metadata);
540
+ }
541
+ get metadata() {
542
+ return $__namespace.utils.getList(1, _FileSystemData._Metadata, this);
543
+ }
544
+ _hasMetadata() {
545
+ return !$__namespace.utils.isNull($__namespace.utils.getPointer(1, this));
546
+ }
547
+ _initMetadata(length) {
548
+ return $__namespace.utils.initList(1, _FileSystemData._Metadata, length, this);
549
+ }
550
+ set metadata(value) {
551
+ $__namespace.utils.copyFrom(value, $__namespace.utils.getPointer(1, this));
552
+ }
553
+ _adoptFiles(value) {
554
+ $__namespace.utils.adopt(value, $__namespace.utils.getPointer(2, this));
555
+ }
556
+ _disownFiles() {
557
+ return $__namespace.utils.disown(this.files);
558
+ }
559
+ get files() {
560
+ return $__namespace.utils.getList(2, _FileSystemData._Files, this);
561
+ }
562
+ _hasFiles() {
563
+ return !$__namespace.utils.isNull($__namespace.utils.getPointer(2, this));
564
+ }
565
+ _initFiles(length) {
566
+ return $__namespace.utils.initList(2, _FileSystemData._Files, length, this);
567
+ }
568
+ set files(value) {
569
+ $__namespace.utils.copyFrom(value, $__namespace.utils.getPointer(2, this));
570
+ }
571
+ toString() {
572
+ return "FileSystemData_" + super.toString();
573
+ }
574
+ };
575
+ FileMetadata._Properties = $__namespace.CompositeList(FileMetadata_KeyValuePair);
576
+ FileSystemData._Ids = $__namespace.CompositeList(FileIdentifier);
577
+ FileSystemData._Metadata = $__namespace.CompositeList(FileMetadata);
578
+ FileSystemData._Files = $__namespace.CompositeList(FileData);
345
579
  var createLog = /* @__PURE__ */ chunkUSNT2KNT_cjs.__name((name, options = {}) => {
346
580
  const logLevel = options.logLevel === null ? types.LogLevelLabel.SILENT : options.logLevel || types.LogLevelLabel.INFO;
347
581
  if (logLevel === types.LogLevelLabel.SILENT) {
@@ -380,112 +614,6 @@ var BADGE_COLORS = [
380
614
  var extendLog = /* @__PURE__ */ chunkUSNT2KNT_cjs.__name((logFn, name) => {
381
615
  return (type, ...args) => logFn(type, ` ${chalk5__default.default.inverse.hex(BADGE_COLORS[name.split("").map((char) => char.charCodeAt(0)).reduce((ret, charCode) => ret + charCode, 0) % BADGE_COLORS.length] || BADGE_COLORS[0])(` ${titleCase.titleCase(name)} `)} ${args.join(" ")} `);
382
616
  }, "extendLog");
383
- var PROJECT_ROOT_HASH_LENGTH = 45;
384
- var CACHE_HASH_LENGTH = 62;
385
- function getPrefixedProjectRootHash(name, projectRootHash) {
386
- const combined = `${kebabCase.kebabCase(name)}_${projectRootHash}`;
387
- return combined.length > PROJECT_ROOT_HASH_LENGTH ? combined.slice(0, PROJECT_ROOT_HASH_LENGTH) : combined;
388
- }
389
- chunkUSNT2KNT_cjs.__name(getPrefixedProjectRootHash, "getPrefixedProjectRootHash");
390
- async function getChecksum(path) {
391
- return hashFiles.hashDirectory(path, {
392
- ignore: [
393
- "node_modules",
394
- ".git",
395
- ".nx",
396
- ".cache",
397
- ".storm",
398
- "tmp",
399
- "dist"
400
- ]
401
- });
402
- }
403
- chunkUSNT2KNT_cjs.__name(getChecksum, "getChecksum");
404
- async function writeMetaFile(context) {
405
- const metaFilePath = joinPaths.joinPaths(context.dataPath, "meta.json");
406
- context.log(types.LogLevelLabel.DEBUG, `Writing runtime metadata to ${metaFilePath}`);
407
- await context.fs.writeFile(metaFilePath, JSON.stringify({
408
- ...context.meta,
409
- virtualFiles: context.fs[chunkRF6RSWD4_cjs.__VFS_VIRTUAL__].toJSON(context.artifactsPath),
410
- virtualFilesMeta: context.fs.getPartialMeta()
411
- }, null, 2), {
412
- mode: "fs"
413
- });
414
- }
415
- chunkUSNT2KNT_cjs.__name(writeMetaFile, "writeMetaFile");
416
- function isPlugin(value) {
417
- return isSetObject.isSetObject(value) && "name" in value && isSetString.isSetString(value.name) && (isUndefined.isUndefined(value.applyToEnvironment) || "applyToEnvironment" in value && isFunction.isFunction(value.applyToEnvironment)) && (isUndefined.isUndefined(value.dedupe) || "dedupe" in value && isFunction.isFunction(value.dedupe)) && (isUndefined.isUndefined(value.dependsOn) || "dependsOn" in value && Array.isArray(value.dependsOn) && value.dependsOn.every(isPluginConfig)) && chunkFCTNMPJF_cjs.SUPPORTED_COMMANDS.every((command) => isUndefined.isUndefined(value[command]) || command in value && (isFunction.isFunction(value[command]) || isSetObject.isSetObject(value[command]) && "handler" in value[command] && isFunction.isFunction(value[command].handler)));
418
- }
419
- chunkUSNT2KNT_cjs.__name(isPlugin, "isPlugin");
420
- function isPluginConfigObject(value) {
421
- return isSetObject.isSetObject(value) && "plugin" in value && ((isSetString.isSetString(value.plugin) || isFunction.isFunction(value.plugin)) && "options" in value && isSetObject.isSetObject(value.options) || isPlugin(value.plugin));
422
- }
423
- chunkUSNT2KNT_cjs.__name(isPluginConfigObject, "isPluginConfigObject");
424
- function isPluginConfigTuple(value) {
425
- return Array.isArray(value) && (value.length === 1 || value.length === 2) && ((isSetString.isSetString(value[0]) || isFunction.isFunction(value[0])) && value.length > 1 && isSetObject.isSetObject(value[1]) || isPlugin(value[0]));
426
- }
427
- chunkUSNT2KNT_cjs.__name(isPluginConfigTuple, "isPluginConfigTuple");
428
- function isPluginConfig(value) {
429
- return isSetString.isSetString(value) || isFunction.isFunction(value) || isPlugin(value) || isPluginConfigObject(value) || isPluginConfigTuple(value);
430
- }
431
- chunkUSNT2KNT_cjs.__name(isPluginConfig, "isPluginConfig");
432
- function isPluginHookFunction(value) {
433
- return isFunction.isFunction(value) || isSetObject.isSetObject(value) && "handler" in value && isFunction.isFunction(value.handler);
434
- }
435
- chunkUSNT2KNT_cjs.__name(isPluginHookFunction, "isPluginHookFunction");
436
- function isPluginHookObject(value) {
437
- return isSetObject.isSetObject(value) && "handler" in value && isFunction.isFunction(value.handler);
438
- }
439
- chunkUSNT2KNT_cjs.__name(isPluginHookObject, "isPluginHookObject");
440
- function isPluginHook(value) {
441
- return isPluginHookFunction(value) || isPluginHookObject(value);
442
- }
443
- chunkUSNT2KNT_cjs.__name(isPluginHook, "isPluginHook");
444
- function getHookHandler(pluginHook) {
445
- return isFunction.isFunction(pluginHook) ? pluginHook : pluginHook.handler;
446
- }
447
- chunkUSNT2KNT_cjs.__name(getHookHandler, "getHookHandler");
448
- function isHookExternal(hook) {
449
- return hook.startsWith("vite:") || hook.startsWith("esbuild:") || hook.startsWith("rolldown:") || hook.startsWith("rollup:") || hook.startsWith("webpack:") || hook.startsWith("rspack:") || hook.startsWith("farm:");
450
- }
451
- chunkUSNT2KNT_cjs.__name(isHookExternal, "isHookExternal");
452
- function checkDedupe(plugin, plugins) {
453
- return plugin.dedupe === false || plugins.some((p) => p.dedupe !== false && (isFunction.isFunction(p.dedupe) && p.dedupe(plugin) || p.name === plugin.name));
454
- }
455
- chunkUSNT2KNT_cjs.__name(checkDedupe, "checkDedupe");
456
- function addPluginHook(context, plugin, pluginHook, hooksList) {
457
- if (!checkDedupe(plugin, hooksList.map((hook) => hook.plugin))) {
458
- hooksList.push(isFunction.isFunction(pluginHook) ? {
459
- plugin,
460
- handler: getHookHandler(pluginHook).bind(context)
461
- } : {
462
- plugin,
463
- ...pluginHook,
464
- handler: getHookHandler(pluginHook).bind(context)
465
- });
466
- }
467
- }
468
- chunkUSNT2KNT_cjs.__name(addPluginHook, "addPluginHook");
469
- function resolveOptions(options) {
470
- return defu4__default.default(options, {
471
- interopDefault: true,
472
- fsCache: options.mode !== "development" ? joinPaths.joinPaths(options.cacheDir, "jiti") : false,
473
- moduleCache: options.mode !== "development"
474
- });
475
- }
476
- chunkUSNT2KNT_cjs.__name(resolveOptions, "resolveOptions");
477
- function createPluginResolver(options) {
478
- return jiti.createJiti(joinPaths.joinPaths(options.workspaceRoot, options.projectRoot), resolveOptions({
479
- ...options
480
- }));
481
- }
482
- chunkUSNT2KNT_cjs.__name(createPluginResolver, "createPluginResolver");
483
- function createResolver(options) {
484
- const baseResolver = jiti.createJiti(joinPaths.joinPaths(options.workspaceRoot, options.projectRoot), resolveOptions(options));
485
- baseResolver.plugin = createPluginResolver(options);
486
- return baseResolver;
487
- }
488
- chunkUSNT2KNT_cjs.__name(createResolver, "createResolver");
489
617
  function isBufferEncoding(options) {
490
618
  return isSetString.isSetString(options) || options === null;
491
619
  }
@@ -634,46 +762,201 @@ function patchFS(originalFS, vfs) {
634
762
  };
635
763
  }
636
764
  chunkUSNT2KNT_cjs.__name(patchFS, "patchFS");
637
- var VirtualFileSystem = class {
765
+ var UnifiedFS = class _UnifiedFS extends unionfs.Union {
638
766
  static {
639
- chunkUSNT2KNT_cjs.__name(this, "VirtualFileSystem");
767
+ chunkUSNT2KNT_cjs.__name(this, "UnifiedFS");
640
768
  }
641
769
  /**
642
770
  * The internal map of virtual files.
643
771
  */
644
- #meta = {};
772
+ #virtualFS = new volume.Volume();
645
773
  /**
646
- * A map of unique identifiers to their virtual file paths.
774
+ * The physical file system.
647
775
  */
648
- #ids = {};
776
+ #physicalFS = cloneFS(fs__default.default);
649
777
  /**
650
- * A map of virtual file paths to their underlying file content.
778
+ * The context of the unified file system.
651
779
  */
652
- #cachedFS = /* @__PURE__ */ new Map();
780
+ #context;
781
+ static create(context, data) {
782
+ let result = new _UnifiedFS(context, data);
783
+ result = result.use(result.#physicalFS);
784
+ if (result.#context.config.output.mode !== "fs") {
785
+ result = result.use(result.#virtualFS);
786
+ }
787
+ return result;
788
+ }
653
789
  /**
654
- * A map of virtual file paths to their underlying file content.
790
+ * Gets the virtual file system (VFS).
655
791
  */
656
- #cachedResolver = /* @__PURE__ */ new Map();
792
+ get virtual() {
793
+ return this.#virtualFS;
794
+ }
657
795
  /**
658
- * The internal map of virtual files.
796
+ * Gets the physical file system (FS).
659
797
  */
660
- #virtualFS = new memfs.Volume();
798
+ get physical() {
799
+ return this.#physicalFS;
800
+ }
661
801
  /**
662
- * The physical file system.
802
+ * Creates a new instance of the VirtualFileSystem.
803
+ *
804
+ * @param context - The context of the virtual file system, typically containing options and logging functions.
805
+ * @param data - A buffer containing the serialized virtual file system data.
663
806
  */
664
- #fs = cloneFS(fs__default.default);
807
+ constructor(context, data) {
808
+ super();
809
+ this.#context = context;
810
+ if (!this.#physicalFS.existsSync(this.#context.dataPath)) {
811
+ this.#physicalFS.mkdirSync(this.#context.dataPath, {
812
+ recursive: true
813
+ });
814
+ }
815
+ if (!this.#physicalFS.existsSync(this.#context.cachePath)) {
816
+ this.#physicalFS.mkdirSync(this.#context.cachePath, {
817
+ recursive: true
818
+ });
819
+ }
820
+ if (!this.#physicalFS.existsSync(join.joinPaths(this.#context.workspaceConfig.workspaceRoot, this.#context.config.output.outputPath))) {
821
+ this.#physicalFS.mkdirSync(join.joinPaths(this.#context.workspaceConfig.workspaceRoot, this.#context.config.output.outputPath), {
822
+ recursive: true
823
+ });
824
+ }
825
+ if (this.#context.config.output.mode !== "fs") {
826
+ this.#virtualFS = volume.Volume.fromJSON(data._hasFiles() && data.files.length > 0 ? data.files.values().reduce((ret, file) => {
827
+ ret[file.path] = file.content;
828
+ return ret;
829
+ }, {}) : {});
830
+ if (!this.#virtualFS.existsSync(this.#context.artifactsPath)) {
831
+ this.#virtualFS.mkdirSync(this.#context.artifactsPath, {
832
+ recursive: true
833
+ });
834
+ }
835
+ if (!this.#virtualFS.existsSync(this.#context.builtinsPath)) {
836
+ this.#virtualFS.mkdirSync(this.#context.builtinsPath, {
837
+ recursive: true
838
+ });
839
+ }
840
+ if (!this.#virtualFS.existsSync(this.#context.entryPath)) {
841
+ this.#virtualFS.mkdirSync(this.#context.entryPath, {
842
+ recursive: true
843
+ });
844
+ }
845
+ if (!this.#virtualFS.existsSync(this.#context.dtsPath)) {
846
+ this.#virtualFS.mkdirSync(this.#context.dtsPath, {
847
+ recursive: true
848
+ });
849
+ }
850
+ } else if (this.#context.config.projectType === "application") {
851
+ if (!this.#physicalFS.existsSync(this.#context.artifactsPath)) {
852
+ this.#physicalFS.mkdirSync(this.#context.artifactsPath, {
853
+ recursive: true
854
+ });
855
+ }
856
+ if (!this.#physicalFS.existsSync(this.#context.builtinsPath)) {
857
+ this.#physicalFS.mkdirSync(this.#context.builtinsPath, {
858
+ recursive: true
859
+ });
860
+ }
861
+ if (!this.#physicalFS.existsSync(this.#context.entryPath)) {
862
+ this.#physicalFS.mkdirSync(this.#context.entryPath, {
863
+ recursive: true
864
+ });
865
+ }
866
+ if (!this.#physicalFS.existsSync(this.#context.dtsPath)) {
867
+ this.#physicalFS.mkdirSync(this.#context.dtsPath, {
868
+ recursive: true
869
+ });
870
+ }
871
+ }
872
+ }
873
+ /**
874
+ * Select the file system module to use for the operation based on the path or URL.
875
+ *
876
+ * @param pathOrUrl - The path to perform the file system operation on.
877
+ * @param options - Options for the operation, such as output mode.
878
+ * @returns The file system module used for the operation.
879
+ */
880
+ resolveFS(pathOrUrl, options = {}) {
881
+ const mode = this.resolveMode(pathOrUrl, options);
882
+ if (mode === "virtual") {
883
+ return {
884
+ ...this.#virtualFS,
885
+ mode: "virtual"
886
+ };
887
+ } else if (mode === "fs") {
888
+ return {
889
+ ...this.#physicalFS,
890
+ mode: "fs"
891
+ };
892
+ }
893
+ return {
894
+ ...this,
895
+ mode: this.#context.config.output.mode
896
+ };
897
+ }
898
+ /**
899
+ * Select the file system module to use for the operation based on the path or URL.
900
+ *
901
+ * @param pathOrUrl - The path to perform the file system operation on.
902
+ * @param options - Options for the operation, such as output mode.
903
+ * @returns The file system module used for the operation.
904
+ */
905
+ resolveMode(pathOrUrl, options = {}) {
906
+ if (options.mode === "virtual" && this.#context.config.output.mode !== "fs" && isParentPath.isParentPath(toFilePath(pathOrUrl), this.#context.artifactsPath)) {
907
+ return "virtual";
908
+ } else if (options.mode === "fs" || this.#context.config.output.mode === "fs" || isParentPath.isParentPath(toFilePath(pathOrUrl), this.#context.dataPath) || isParentPath.isParentPath(toFilePath(pathOrUrl), this.#context.cachePath) || isParentPath.isParentPath(toFilePath(pathOrUrl), join.joinPaths(this.#context.workspaceConfig.workspaceRoot, this.#context.config.output.outputPath))) {
909
+ return "fs";
910
+ }
911
+ return void 0;
912
+ }
913
+ /**
914
+ * Serializes the virtual file system (VFS) to a JSON object.
915
+ *
916
+ * @returns A JSON representation of the virtual file system.
917
+ */
918
+ toJSON() {
919
+ return this.#virtualFS.toJSON();
920
+ }
921
+ };
922
+
923
+ // src/lib/fs/vfs.ts
924
+ var VirtualFileSystem = class _VirtualFileSystem {
925
+ static {
926
+ chunkUSNT2KNT_cjs.__name(this, "VirtualFileSystem");
927
+ }
928
+ /**
929
+ * A map of virtual file IDs to their associated metadata.
930
+ */
931
+ #metadata;
932
+ /**
933
+ * A map of virtual file IDs to their underlying file paths.
934
+ */
935
+ #ids;
936
+ /**
937
+ * A map of underlying file paths to their virtual file IDs.
938
+ */
939
+ #paths;
940
+ /**
941
+ * A map of virtual file paths to their underlying file content.
942
+ */
943
+ #cachedResolver = /* @__PURE__ */ new Map();
665
944
  /**
666
945
  * The unified volume that combines the virtual file system with the real file system.
667
946
  *
668
947
  * @remarks
669
948
  * This volume allows for seamless access to both virtual and real files.
670
949
  */
671
- #unifiedFS = new unionfs.Union();
950
+ #unifiedFS;
672
951
  /**
673
952
  * Indicator specifying if the file system module is patched
674
953
  */
675
954
  #isPatched = false;
676
955
  /**
956
+ * Indicator specifying if the virtual file system (VFS) is disposed
957
+ */
958
+ #isDisposed = false;
959
+ /**
677
960
  * Function to revert require patch
678
961
  */
679
962
  #revert;
@@ -693,60 +976,224 @@ var VirtualFileSystem = class {
693
976
  */
694
977
  #existsSync(path) {
695
978
  const formattedPath = this.formatPath(path);
696
- return this.#virtualFS.existsSync(formattedPath) || this.#fs.existsSync(formattedPath) || this.resolveFS(path).existsSync(formattedPath);
979
+ return this.#unifiedFS.virtual.existsSync(formattedPath) || this.#unifiedFS.physical.existsSync(formattedPath) || this.#unifiedFS.resolveFS(path).existsSync(formattedPath);
697
980
  }
698
981
  /**
699
- * Exposes the internal VFS map for advanced usage.
982
+ * Builds a regular expression from a string pattern for path matching.
983
+ *
984
+ * @param strPattern - The string pattern to convert.
985
+ * @returns A regular expression for matching paths.
700
986
  */
701
- get [chunkRF6RSWD4_cjs.__VFS_CACHE__]() {
702
- return this.#cachedFS;
987
+ #buildRegex(strPattern) {
988
+ const token = "::GLOBSTAR::";
989
+ return new RegExp(`^${this.formatPath(strPattern).replace(/\*\*/g, token).replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*/g, "[^/]*").replace(/\?/g, "[^/]").replace(new RegExp(token, "g"), ".*")}$`);
703
990
  }
704
991
  /**
705
- * Exposes the internal VFS resolver cache for advanced usage.
992
+ * Formats a file id by removing the file extension and prepending the runtime prefix.
993
+ *
994
+ * @param id - The file ID to format.
995
+ * @returns The formatted file ID.
706
996
  */
707
- get [chunkRF6RSWD4_cjs.__VFS_RESOLVER__]() {
708
- return this.#cachedResolver;
997
+ #formatId(id) {
998
+ const formattedId = toFilePath(id);
999
+ return `${this.#context.config.output.builtinPrefix}:${formattedId.replace(new RegExp(`^${this.#context.config.output.builtinPrefix}:`), "").replace(/^\\0/, "").replace(filePathFns.findFileDotExtensionSafe(formattedId), "")}`;
709
1000
  }
710
1001
  /**
711
- * Exposes the internal VFS map for advanced usage.
1002
+ * Resolves an id parameter to a corresponding virtual file path in the virtual file system (VFS).
1003
+ *
1004
+ * @param id - The id to resolve.
1005
+ * @returns The resolved file id if it exists, otherwise undefined.
712
1006
  */
713
- get [chunkRF6RSWD4_cjs.__VFS_VIRTUAL__]() {
714
- return this.#virtualFS;
1007
+ #resolveId(id) {
1008
+ if (this.#ids[this.#formatId(id)]) {
1009
+ return this.#ids[this.#formatId(id)] || false;
1010
+ }
1011
+ return false;
715
1012
  }
716
1013
  /**
717
- * Exposes the internal UFS map for advanced usage.
1014
+ * Resolves a path parameter to a corresponding virtual file path in the virtual file system (VFS).
1015
+ *
1016
+ * @param path - The path to resolve.
1017
+ * @param options - Optional parameters for resolving the path.
1018
+ * @returns The resolved file path if it exists, otherwise undefined.
718
1019
  */
719
- get [chunkRF6RSWD4_cjs.__VFS_UNIFIED__]() {
720
- return this.#unifiedFS;
1020
+ #resolvePath(path, options = {}) {
1021
+ if (isType.isAbsolutePath(path)) {
1022
+ if (this.#existsSync(path)) {
1023
+ return path;
1024
+ }
1025
+ const result = this.#checkVariants(path);
1026
+ if (result) {
1027
+ return result;
1028
+ }
1029
+ }
1030
+ for (const parentPath of this.#resolveParentPaths(path, options.paths)) {
1031
+ const request = joinPaths.joinPaths(parentPath, path);
1032
+ if (this.#existsSync(request)) {
1033
+ return request;
1034
+ }
1035
+ const result = this.#checkVariants(request);
1036
+ if (result) {
1037
+ return result;
1038
+ }
1039
+ }
1040
+ return false;
721
1041
  }
722
1042
  /**
723
- * A proxy to access the underlying file metadata.
1043
+ * Resolves parent paths for a given request.
1044
+ *
1045
+ * @param request - The request path to resolve parent paths for.
1046
+ * @param parents - An optional array of parent paths to consider.
1047
+ * @returns An array of resolved parent paths.
724
1048
  */
725
- get meta() {
726
- return new Proxy(this.#meta, {
727
- get: /* @__PURE__ */ chunkUSNT2KNT_cjs.__name((target, prop) => {
728
- if (target[prop]) {
729
- return {
730
- id: prop,
731
- mode: this.#virtualFS.existsSync(prop) ? "virtual" : this.#fs.existsSync(prop) ? "fs" : this.#context.config.output.mode,
732
- details: {},
733
- variant: "normal",
734
- ...target[prop]
735
- };
1049
+ #resolveParentPaths(request, parents = []) {
1050
+ let paths = [
1051
+ this.#context.workspaceConfig.workspaceRoot,
1052
+ joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, this.#context.config.projectRoot)
1053
+ ];
1054
+ if (this.#context.tsconfig.options.paths) {
1055
+ paths = this.#context.tsconfig.options.paths ? Object.keys(this.#context.tsconfig.options.paths).filter((tsconfigPath) => request.startsWith(tsconfigPath.replaceAll("*", ""))).map((tsconfigPath) => this.#context.tsconfig.options.paths?.[tsconfigPath]).flat().reduce((ret, path) => {
1056
+ if (path && !ret.includes(joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, path))) {
1057
+ ret.push(joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, path));
736
1058
  }
737
- return void 0;
738
- }, "get"),
739
- set: /* @__PURE__ */ chunkUSNT2KNT_cjs.__name((target, prop, value) => {
740
- target[prop] = value;
741
- this.#ids[value.id || prop] = prop;
742
- return true;
743
- }, "set"),
744
- deleteProperty: /* @__PURE__ */ chunkUSNT2KNT_cjs.__name((target, prop) => {
745
- delete this.#ids[target[prop]?.id || prop];
746
- delete target[prop];
747
- return true;
748
- }, "deleteProperty")
749
- });
1059
+ return ret;
1060
+ }, paths) : paths;
1061
+ }
1062
+ return paths.reduce((ret, path) => {
1063
+ if (!ret.includes(path)) {
1064
+ ret.push(path);
1065
+ }
1066
+ return ret;
1067
+ }, parents.filter(Boolean).map((p) => this.formatPath(p)));
1068
+ }
1069
+ /**
1070
+ * Clears the resolver cache for a given path.
1071
+ *
1072
+ * @param path - The path to clear the resolver cache for.
1073
+ */
1074
+ #clearResolverCache(path) {
1075
+ this.#cachedResolver.keys().filter((key) => key.startsWith(toFilePath(path))).forEach((key) => this.#cachedResolver.delete(key));
1076
+ }
1077
+ /**
1078
+ * Check if the file exists with different variants (index, extensions).
1079
+ *
1080
+ * @param request - The request path to check.
1081
+ * @param parentPath - An optional parent path to prepend to the request.
1082
+ * @returns The file path if it exists, otherwise false.
1083
+ */
1084
+ #checkVariants(request, parentPath) {
1085
+ const path = parentPath ? joinPaths.joinPaths(parentPath, request) : request;
1086
+ let file = this.#checkExtensions(path);
1087
+ if (file) {
1088
+ return file;
1089
+ }
1090
+ file = this.#checkIndex(path);
1091
+ if (file) {
1092
+ return file;
1093
+ }
1094
+ return false;
1095
+ }
1096
+ /**
1097
+ * Check if the index file exists in the given request path.
1098
+ *
1099
+ * @param request - The request path to check.
1100
+ * @returns The index file path if it exists, otherwise false.
1101
+ */
1102
+ #checkIndex(request) {
1103
+ let file = joinPaths.joinPaths(request, "index");
1104
+ if (this.#existsSync(file)) {
1105
+ return file;
1106
+ }
1107
+ file = this.#checkExtensions(file);
1108
+ if (file) {
1109
+ return file;
1110
+ }
1111
+ return false;
1112
+ }
1113
+ /**
1114
+ * Check if the file exists with different extensions.
1115
+ *
1116
+ * @param request - The request path to check.
1117
+ * @returns The file path if it exists with any of the checked extensions, otherwise false.
1118
+ */
1119
+ #checkExtensions(request) {
1120
+ let file = `${request}.ts`;
1121
+ if (this.#existsSync(file)) {
1122
+ return file;
1123
+ }
1124
+ file = `${request}.mts`;
1125
+ if (this.#existsSync(file)) {
1126
+ return file;
1127
+ }
1128
+ file = `${request}.cts`;
1129
+ if (this.#existsSync(file)) {
1130
+ return file;
1131
+ }
1132
+ file = `${request}.tsx`;
1133
+ if (this.#existsSync(file)) {
1134
+ return file;
1135
+ }
1136
+ file = `${request}.js`;
1137
+ if (this.#existsSync(file)) {
1138
+ return file;
1139
+ }
1140
+ file = `${request}.mjs`;
1141
+ if (this.#existsSync(file)) {
1142
+ return file;
1143
+ }
1144
+ file = `${request}.cjs`;
1145
+ if (this.#existsSync(file)) {
1146
+ return file;
1147
+ }
1148
+ file = `${request}.jsx`;
1149
+ if (this.#existsSync(file)) {
1150
+ return file;
1151
+ }
1152
+ file = `${request}.json`;
1153
+ if (this.#existsSync(file)) {
1154
+ return file;
1155
+ }
1156
+ file = `${request}.d.ts`;
1157
+ if (this.#existsSync(file)) {
1158
+ return file;
1159
+ }
1160
+ return false;
1161
+ }
1162
+ /**
1163
+ * Creates a virtual file system (VFS) that is backed up to a Cap'n Proto message buffer.
1164
+ *
1165
+ * @param context - The context of the virtual file system, typically containing options and logging functions.
1166
+ * @returns A promise that resolves to a new virtual file system instance.
1167
+ */
1168
+ static async create(context) {
1169
+ if (!context.config.skipCache && exists.existsSync(joinPaths.joinPaths(context.cachePath, "fs.bin"))) {
1170
+ const buffer$1 = await buffer.readFileBuffer(joinPaths.joinPaths(context.cachePath, "fs.bin"));
1171
+ const message2 = new $__namespace.Message(buffer$1, false);
1172
+ return new _VirtualFileSystem(context, message2.getRoot(FileSystemData));
1173
+ }
1174
+ const message = new $__namespace.Message();
1175
+ return new _VirtualFileSystem(context, message.initRoot(FileSystemData));
1176
+ }
1177
+ /**
1178
+ * Synchronously creates a virtual file system (VFS) that is backed up to a Cap'n Proto message buffer.
1179
+ *
1180
+ * @param context - The context of the virtual file system, typically containing options and logging functions.
1181
+ * @returns A new virtual file system instance.
1182
+ */
1183
+ static createSync(context) {
1184
+ if (!context.config.skipCache && exists.existsSync(joinPaths.joinPaths(context.cachePath, "fs.bin"))) {
1185
+ const buffer$1 = buffer.readFileBufferSync(joinPaths.joinPaths(context.cachePath, "fs.bin"));
1186
+ const message2 = new $__namespace.Message(buffer$1, false);
1187
+ return new _VirtualFileSystem(context, message2.getRoot(FileSystemData));
1188
+ }
1189
+ const message = new $__namespace.Message();
1190
+ return new _VirtualFileSystem(context, message.initRoot(FileSystemData));
1191
+ }
1192
+ /**
1193
+ * A map of file ids to their metadata.
1194
+ */
1195
+ get metadata() {
1196
+ return this.#metadata;
750
1197
  }
751
1198
  /**
752
1199
  * A map of module ids to their file paths.
@@ -755,98 +1202,49 @@ var VirtualFileSystem = class {
755
1202
  return this.#ids;
756
1203
  }
757
1204
  /**
758
- * Creates a new instance of the VirtualFileSystem.
1205
+ * A map of virtual file paths to their IDs.
1206
+ */
1207
+ get paths() {
1208
+ return this.#paths;
1209
+ }
1210
+ /**
1211
+ * Creates a new instance of the {@link VirtualFileSystem}.
759
1212
  *
760
1213
  * @param context - The context of the virtual file system, typically containing options and logging functions.
761
- * @param serialized - A map of files/file contents to populate in cache
1214
+ * @param data - A buffer containing the serialized virtual file system data.
762
1215
  */
763
- constructor(context, serialized = {}) {
1216
+ constructor(context, data) {
764
1217
  this.#context = context;
765
- this.#cachedFS = /* @__PURE__ */ new Map();
766
- this.#meta = Object.fromEntries(Object.entries(serialized.virtualFilesMeta ?? {}));
767
- this.#ids = Object.fromEntries(Object.entries(this.#meta).map(([path, data]) => [
768
- data.id || path,
769
- path
770
- ]));
771
- if (!this.#fs.existsSync(this.#context.dataPath)) {
772
- this.#fs.mkdirSync(this.#context.dataPath, {
773
- recursive: true
774
- });
775
- }
776
- if (!this.#fs.existsSync(this.#context.cachePath)) {
777
- this.#fs.mkdirSync(this.#context.cachePath, {
778
- recursive: true
779
- });
780
- }
781
- if (!this.#fs.existsSync(joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, this.#context.config.output.outputPath))) {
782
- this.#fs.mkdirSync(joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, this.#context.config.output.outputPath), {
783
- recursive: true
784
- });
785
- }
786
- this.#unifiedFS = this.#unifiedFS.use(this.#fs);
787
- if (this.#context.config.output.mode !== "fs") {
788
- if (serialized?.virtualFiles && Object.keys(serialized.virtualFiles).length > 0) {
789
- this.#virtualFS = memfs.Volume.fromJSON(serialized.virtualFiles);
790
- }
791
- if (!this.#virtualFS.existsSync(this.#context.artifactsPath)) {
792
- this.#virtualFS.mkdirSync(this.#context.artifactsPath, {
793
- recursive: true
794
- });
795
- }
796
- if (!this.#virtualFS.existsSync(this.#context.builtinsPath)) {
797
- this.#virtualFS.mkdirSync(this.#context.builtinsPath, {
798
- recursive: true
799
- });
800
- }
801
- if (!this.#virtualFS.existsSync(this.#context.entryPath)) {
802
- this.#virtualFS.mkdirSync(this.#context.entryPath, {
803
- recursive: true
804
- });
805
- }
806
- if (!this.#virtualFS.existsSync(this.#context.dtsPath)) {
807
- this.#virtualFS.mkdirSync(this.#context.dtsPath, {
808
- recursive: true
809
- });
810
- }
811
- this.#unifiedFS = this.#unifiedFS.use(this.#virtualFS);
812
- } else if (this.#context.config.projectType === "application") {
813
- if (!this.#fs.existsSync(this.#context.artifactsPath)) {
814
- this.#fs.mkdirSync(this.#context.artifactsPath, {
815
- recursive: true
816
- });
817
- }
818
- if (!this.#fs.existsSync(this.#context.builtinsPath)) {
819
- this.#fs.mkdirSync(this.#context.builtinsPath, {
820
- recursive: true
821
- });
822
- }
823
- if (!this.#fs.existsSync(this.#context.entryPath)) {
824
- this.#fs.mkdirSync(this.#context.entryPath, {
825
- recursive: true
826
- });
827
- }
828
- if (!this.#fs.existsSync(this.#context.dtsPath)) {
829
- this.#fs.mkdirSync(this.#context.dtsPath, {
830
- recursive: true
831
- });
832
- }
833
- }
834
- this.#log = extendLog(this.#context.log, "virtual-file-system");
835
- }
836
- [chunkRF6RSWD4_cjs.__VFS_INIT__]() {
837
- if (!this.#isPatched && this.#context.config.output.mode !== "fs") {
838
- this.#revert = patchFS(fs__default.default, this);
839
- this.#isPatched = true;
840
- }
841
- }
842
- [chunkRF6RSWD4_cjs.__VFS_REVERT__]() {
843
- if (this.#isPatched && this.#context.config.output.mode !== "fs") {
844
- if (!this.#revert) {
845
- throw new Error("Attempting to revert File System patch prior to calling `__init__` function");
846
- }
847
- this.#revert?.();
848
- this.#isPatched = false;
1218
+ this.#unifiedFS = UnifiedFS.create(context, data);
1219
+ this.#metadata = {};
1220
+ if (data._hasMetadata()) {
1221
+ this.#metadata = data.metadata.values().reduce((ret, data2) => {
1222
+ ret[data2.id] = {
1223
+ id: data2.id,
1224
+ variant: data2.variant,
1225
+ mode: data2.mode,
1226
+ properties: data2._hasProperties() ? data2.properties.values().reduce((ret2, item) => {
1227
+ ret2[item.key] = item.value;
1228
+ return ret2;
1229
+ }, {}) : {}
1230
+ };
1231
+ return ret;
1232
+ }, {});
1233
+ }
1234
+ this.#ids = {};
1235
+ this.#paths = {};
1236
+ if (data._hasIds()) {
1237
+ this.#ids = data.ids.values().reduce((ret, data2) => {
1238
+ ret[data2.id] ??= data2.path;
1239
+ ret[data2.path] ??= data2.path;
1240
+ return ret;
1241
+ }, {});
1242
+ this.#paths = data.ids.values().reduce((ret, data2) => {
1243
+ ret[data2.path] ??= data2.id;
1244
+ return ret;
1245
+ }, {});
849
1246
  }
1247
+ this.#log = extendLog(this.#context.log, "file-system");
850
1248
  }
851
1249
  /**
852
1250
  * Check if a path or id corresponds to a virtual file **(does not actually exists on disk)**.
@@ -866,7 +1264,7 @@ var VirtualFileSystem = class {
866
1264
  if (!resolvedPath) {
867
1265
  return false;
868
1266
  }
869
- return this.meta[resolvedPath]?.mode === "virtual";
1267
+ return this.metadata[resolvedPath]?.mode === "virtual";
870
1268
  }
871
1269
  /**
872
1270
  * Check if a path or id corresponds to a file written to the file system **(actually exists on disk)**.
@@ -875,7 +1273,7 @@ var VirtualFileSystem = class {
875
1273
  * @param options - Optional parameters for resolving the path.
876
1274
  * @returns Whether the path or id corresponds to a file written to the file system **(actually exists on disk)**.
877
1275
  */
878
- isFs(pathOrId, options = {}) {
1276
+ isPhysical(pathOrId, options = {}) {
879
1277
  if (!pathOrId) {
880
1278
  return false;
881
1279
  }
@@ -886,18 +1284,7 @@ var VirtualFileSystem = class {
886
1284
  if (!resolvedPath) {
887
1285
  return false;
888
1286
  }
889
- return this.meta[resolvedPath]?.mode === "fs";
890
- }
891
- /**
892
- * Check if a path exists within one of the directories specified in the tsconfig.json's `path` field.
893
- *
894
- * @see https://www.typescriptlang.org/tsconfig#paths
895
- *
896
- * @param pathOrId - The path or ID to check.
897
- * @returns Whether the path or ID corresponds to a virtual file.
898
- */
899
- isTsconfigPath(pathOrId) {
900
- return !!this.#context.tsconfig.options.paths && Object.keys(this.#context.tsconfig.options.paths).some((path) => pathOrId.startsWith(path.replaceAll("*", "")));
1287
+ return this.metadata[resolvedPath]?.mode === "fs";
901
1288
  }
902
1289
  /**
903
1290
  * Lists files in a given path.
@@ -907,7 +1294,7 @@ var VirtualFileSystem = class {
907
1294
  * @returns An array of file names in the specified path.
908
1295
  */
909
1296
  readdirSync(path, options = "utf8") {
910
- return this.resolveFS(path).readdirSync(toFilePath(path), options);
1297
+ return this.#unifiedFS.resolveFS(path).readdirSync(toFilePath(path), options);
911
1298
  }
912
1299
  /**
913
1300
  * Removes a file in the virtual file system (VFS).
@@ -920,9 +1307,11 @@ var VirtualFileSystem = class {
920
1307
  return;
921
1308
  }
922
1309
  this.#log(types.LogLevelLabel.TRACE, `Synchronously removing file: ${formattedPath}`);
923
- this.resolveFS(path, options).unlinkSync(formattedPath);
924
- this.#cachedFS.delete(formattedPath);
925
- this.clearResolverCache(formattedPath);
1310
+ this.#unifiedFS.resolveFS(path, options).unlinkSync(formattedPath);
1311
+ if (this.paths[formattedPath] && this.metadata[this.paths[formattedPath]]) {
1312
+ delete this.metadata[this.paths[formattedPath]];
1313
+ }
1314
+ this.#clearResolverCache(formattedPath);
926
1315
  }
927
1316
  /**
928
1317
  * Removes a file in the virtual file system (VFS).
@@ -935,10 +1324,12 @@ var VirtualFileSystem = class {
935
1324
  return;
936
1325
  }
937
1326
  this.#log(types.LogLevelLabel.TRACE, `Removing file: ${formattedPath}`);
938
- if (isFunction.isFunction(this.resolveFS(path, options).promises.unlink)) {
939
- await this.resolveFS(path, options).promises.unlink(formattedPath);
940
- this.#cachedFS.delete(formattedPath);
941
- this.clearResolverCache(formattedPath);
1327
+ if (isFunction.isFunction(this.#unifiedFS.resolveFS(path, options).promises.unlink)) {
1328
+ await this.#unifiedFS.resolveFS(path, options).promises.unlink(formattedPath);
1329
+ if (this.paths[formattedPath] && this.metadata[this.paths[formattedPath]]) {
1330
+ delete this.metadata[this.paths[formattedPath]];
1331
+ }
1332
+ this.#clearResolverCache(formattedPath);
942
1333
  } else {
943
1334
  this.unlinkSync(formattedPath, options);
944
1335
  }
@@ -955,11 +1346,10 @@ var VirtualFileSystem = class {
955
1346
  return;
956
1347
  }
957
1348
  this.#log(types.LogLevelLabel.TRACE, `Synchronously removing directory: ${formattedPath}`);
958
- this.resolveFS(path, options).rmdirSync(formattedPath, defu4__default.default(options, {
1349
+ this.#unifiedFS.resolveFS(path, options).rmdirSync(formattedPath, defu3__default.default(options, {
959
1350
  recursive: true
960
1351
  }));
961
- this.#cachedFS.delete(formattedPath);
962
- this.clearResolverCache(formattedPath);
1352
+ this.#clearResolverCache(formattedPath);
963
1353
  }
964
1354
  /**
965
1355
  * Removes a directory in the virtual file system (VFS).
@@ -974,15 +1364,14 @@ var VirtualFileSystem = class {
974
1364
  return;
975
1365
  }
976
1366
  this.#log(types.LogLevelLabel.TRACE, `Removing directory: ${formattedPath}`);
977
- if (isFunction.isFunction(this.resolveFS(path, options).promises.rm)) {
978
- await this.resolveFS(path, options).promises.rm(formattedPath, defu4__default.default(options, {
1367
+ if (isFunction.isFunction(this.#unifiedFS.resolveFS(path, options).promises.rm)) {
1368
+ await this.#unifiedFS.resolveFS(path, options).promises.rm(formattedPath, defu3__default.default(options, {
979
1369
  force: true,
980
1370
  recursive: true
981
1371
  }));
982
- this.#cachedFS.delete(formattedPath);
983
- this.clearResolverCache(formattedPath);
1372
+ this.#clearResolverCache(formattedPath);
984
1373
  } else {
985
- this.rmdirSync(formattedPath, defu4__default.default(options ?? {}, {
1374
+ this.rmdirSync(formattedPath, defu3__default.default(options ?? {}, {
986
1375
  force: true,
987
1376
  recursive: true
988
1377
  }));
@@ -1024,8 +1413,8 @@ var VirtualFileSystem = class {
1024
1413
  */
1025
1414
  mkdirSync(path, options = {}) {
1026
1415
  const filePath = toFilePath(path);
1027
- this.clearResolverCache(filePath);
1028
- return this.resolveFS(filePath, options).mkdirSync(filePath, defu4__default.default(options ?? {}, {
1416
+ this.#clearResolverCache(filePath);
1417
+ return this.#unifiedFS.resolveFS(filePath, options).mkdirSync(filePath, defu3__default.default(options ?? {}, {
1029
1418
  recursive: true
1030
1419
  }));
1031
1420
  }
@@ -1039,16 +1428,16 @@ var VirtualFileSystem = class {
1039
1428
  async mkdir(path, options = {}) {
1040
1429
  let result;
1041
1430
  const filePath = toFilePath(path);
1042
- if (isFunction.isFunction(this.resolveFS(filePath, options).promises.mkdir)) {
1043
- result = await this.resolveFS(filePath, options).promises.mkdir(filePath, defu4__default.default(options ?? {}, {
1431
+ if (isFunction.isFunction(this.#unifiedFS.resolveFS(filePath, options).promises.mkdir)) {
1432
+ result = await this.#unifiedFS.resolveFS(filePath, options).promises.mkdir(filePath, defu3__default.default(options ?? {}, {
1044
1433
  recursive: true
1045
1434
  }));
1046
1435
  } else {
1047
- result = this.resolveFS(filePath, options).mkdirSync(filePath, defu4__default.default(options ?? {}, {
1436
+ result = this.#unifiedFS.resolveFS(filePath, options).mkdirSync(filePath, defu3__default.default(options ?? {}, {
1048
1437
  recursive: true
1049
1438
  }));
1050
1439
  }
1051
- this.clearResolverCache(filePath);
1440
+ this.#clearResolverCache(filePath);
1052
1441
  return result;
1053
1442
  }
1054
1443
  /**
@@ -1096,7 +1485,7 @@ var VirtualFileSystem = class {
1096
1485
  if (stats.isDirectory()) {
1097
1486
  stack.push(full);
1098
1487
  } else if (stats.isFile()) {
1099
- if (this.buildRegex(absPattern).test(full)) {
1488
+ if (this.#buildRegex(absPattern).test(full)) {
1100
1489
  const resolved = this.resolve(full, {
1101
1490
  type: "file"
1102
1491
  });
@@ -1155,7 +1544,7 @@ var VirtualFileSystem = class {
1155
1544
  if (stats.isDirectory()) {
1156
1545
  stack.push(full);
1157
1546
  } else if (stats.isFile()) {
1158
- if (this.buildRegex(absPattern).test(full)) {
1547
+ if (this.#buildRegex(absPattern).test(full)) {
1159
1548
  const resolved = this.resolve(full, {
1160
1549
  type: "file"
1161
1550
  });
@@ -1219,7 +1608,7 @@ var VirtualFileSystem = class {
1219
1608
  * @returns An array of file names in the specified path.
1220
1609
  */
1221
1610
  async readdir(pathOrId, options = "utf8") {
1222
- return this.resolveFS(pathOrId).promises.readdir(toFilePath(pathOrId), options);
1611
+ return this.#unifiedFS.resolveFS(pathOrId).promises.readdir(toFilePath(pathOrId), options);
1223
1612
  }
1224
1613
  /**
1225
1614
  * Asynchronously reads a file from the virtual file system (VFS).
@@ -1235,17 +1624,13 @@ var VirtualFileSystem = class {
1235
1624
  type: "file"
1236
1625
  });
1237
1626
  if (filePath) {
1238
- if (this.#cachedFS.has(filePath)) {
1239
- return this.#cachedFS.get(filePath);
1240
- }
1241
1627
  let result;
1242
- if (isFunction.isFunction(this.resolveFS(filePath).promises.readFile)) {
1243
- result = (await this.resolveFS(filePath).promises.readFile(filePath, options))?.toString("utf8");
1628
+ if (isFunction.isFunction(this.#unifiedFS.resolveFS(filePath).promises.readFile)) {
1629
+ result = (await this.#unifiedFS.resolveFS(filePath).promises.readFile(filePath, options))?.toString("utf8");
1244
1630
  } else {
1245
- result = this.resolveFS(filePath).readFileSync(filePath, options);
1631
+ result = this.#unifiedFS.resolveFS(filePath).readFileSync(filePath, options);
1246
1632
  }
1247
1633
  const content = isBuffer.isBuffer(result) ? bufferToString.bufferToString(result) : result;
1248
- this.#cachedFS.set(filePath, content);
1249
1634
  return content;
1250
1635
  }
1251
1636
  return void 0;
@@ -1264,12 +1649,8 @@ var VirtualFileSystem = class {
1264
1649
  type: "file"
1265
1650
  });
1266
1651
  if (filePath) {
1267
- if (this.#cachedFS.has(filePath)) {
1268
- return this.#cachedFS.get(filePath);
1269
- }
1270
- const result = this.resolveFS(filePath).readFileSync(filePath, options);
1652
+ const result = this.#unifiedFS.resolveFS(filePath).readFileSync(filePath, options);
1271
1653
  const content = isBuffer.isBuffer(result) ? bufferToString.bufferToString(result) : result;
1272
- this.#cachedFS.set(filePath, content);
1273
1654
  return content;
1274
1655
  }
1275
1656
  return void 0;
@@ -1297,17 +1678,15 @@ var VirtualFileSystem = class {
1297
1678
  });
1298
1679
  }
1299
1680
  }
1300
- const outputMode = this.resolveOutputMode(formattedPath, isPowerlinesWriteFileOptions(options) ? options : void 0);
1301
- this.#log(types.LogLevelLabel.TRACE, `Writing ${formattedPath} file to the ${outputMode === "fs" ? "" : "virtual "}file system (size: ${prettyBytes.prettyBytes(new buffer.Blob(toArray.toArray(code)).size)})`);
1302
- this.meta[formattedPath] = {
1303
- path: formattedPath,
1304
- code,
1681
+ const outputMode = this.#unifiedFS.resolveMode(formattedPath, isPowerlinesWriteFileOptions(options) ? options : void 0);
1682
+ this.#log(types.LogLevelLabel.TRACE, `Writing ${formattedPath} file to the ${outputMode === "fs" ? "" : "virtual "}file system (size: ${prettyBytes.prettyBytes(new buffer$1.Blob(toArray.toArray(code)).size)})`);
1683
+ this.metadata[formattedPath] = {
1305
1684
  mode: outputMode,
1306
1685
  variant: "normal",
1307
1686
  ...isPowerLinesWriteFileData(data) ? data : {}
1308
1687
  };
1309
- this.clearResolverCache(formattedPath);
1310
- const ifs = this.resolveFS(formattedPath, isPowerlinesWriteFileOptions(options) ? options : void 0);
1688
+ this.#clearResolverCache(formattedPath);
1689
+ const ifs = this.#unifiedFS.resolveFS(formattedPath, isPowerlinesWriteFileOptions(options) ? options : void 0);
1311
1690
  if (isFunction.isFunction(ifs.promises.writeFile)) {
1312
1691
  return ifs.promises.writeFile(formattedPath, code, isNodeWriteFileOptions(options) ? options : "utf8");
1313
1692
  }
@@ -1326,17 +1705,15 @@ var VirtualFileSystem = class {
1326
1705
  this.mkdirSync(filePathFns.findFilePath(formattedPath), isPowerlinesWriteFileOptions(options) ? options : void 0);
1327
1706
  }
1328
1707
  const code = isPowerLinesWriteFileData(data) ? data.code : data;
1329
- const outputMode = this.resolveOutputMode(formattedPath, isPowerlinesWriteFileOptions(options) ? options : void 0);
1330
- this.#log(types.LogLevelLabel.TRACE, `Writing ${formattedPath} file to the ${outputMode === "fs" ? "" : "virtual "}file system (size: ${prettyBytes.prettyBytes(new buffer.Blob(toArray.toArray(code)).size)})`);
1331
- this.meta[formattedPath] = {
1332
- path: formattedPath,
1333
- code,
1708
+ const outputMode = this.#unifiedFS.resolveMode(formattedPath, isPowerlinesWriteFileOptions(options) ? options : void 0);
1709
+ this.#log(types.LogLevelLabel.TRACE, `Writing ${formattedPath} file to the ${outputMode === "fs" ? "" : "virtual "}file system (size: ${prettyBytes.prettyBytes(new buffer$1.Blob(toArray.toArray(code)).size)})`);
1710
+ this.metadata[formattedPath] = {
1334
1711
  mode: outputMode,
1335
1712
  variant: "normal",
1336
1713
  ...isPowerLinesWriteFileData(data) ? data : {}
1337
1714
  };
1338
- this.clearResolverCache(formattedPath);
1339
- const writeStream = this.resolveFS(formattedPath, isPowerlinesWriteFileOptions(options) ? options : void 0).createWriteStream(formattedPath);
1715
+ this.#clearResolverCache(formattedPath);
1716
+ const writeStream = this.#unifiedFS.resolveFS(formattedPath, isPowerlinesWriteFileOptions(options) ? options : void 0).createWriteStream(formattedPath);
1340
1717
  try {
1341
1718
  writeStream.write(code);
1342
1719
  } finally {
@@ -1360,8 +1737,8 @@ var VirtualFileSystem = class {
1360
1737
  */
1361
1738
  getMetadata(pathOrId) {
1362
1739
  const resolved = this.resolve(pathOrId);
1363
- if (resolved && this.meta[resolved]) {
1364
- return this.meta[resolved];
1740
+ if (resolved && this.metadata[resolved]) {
1741
+ return this.metadata[resolved];
1365
1742
  }
1366
1743
  return void 0;
1367
1744
  }
@@ -1376,7 +1753,7 @@ var VirtualFileSystem = class {
1376
1753
  */
1377
1754
  isFile(pathOrId) {
1378
1755
  const resolved = this.resolve(pathOrId);
1379
- 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()));
1756
+ 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()));
1380
1757
  }
1381
1758
  /**
1382
1759
  * Checks if a directory exists in the virtual file system (VFS).
@@ -1386,348 +1763,266 @@ var VirtualFileSystem = class {
1386
1763
  */
1387
1764
  isDirectory(pathOrId) {
1388
1765
  const resolved = this.resolve(pathOrId);
1389
- 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()));
1390
- }
1391
- /**
1392
- * Retrieves the status of a file in the virtual file system (VFS).
1393
- *
1394
- * @param pathOrId - The path or ID of the file to retrieve status for.
1395
- * @returns A promise that resolves to the file's status information, or false if the file does not exist.
1396
- */
1397
- async stat(pathOrId, options) {
1398
- return this.resolveFS(pathOrId).promises.stat(this.resolve(toFilePath(pathOrId)) || toFilePath(pathOrId), options);
1399
- }
1400
- /**
1401
- * Synchronously retrieves the status of a file in the virtual file system (VFS).
1402
- *
1403
- * @param pathOrId - The path or ID of the file to retrieve status for.
1404
- * @returns The file's status information, or false if the file does not exist.
1405
- */
1406
- statSync(pathOrId) {
1407
- return this.resolveFS(pathOrId).statSync(this.resolve(toFilePath(pathOrId)) || toFilePath(pathOrId));
1408
- }
1409
- /**
1410
- * Retrieves the status of a symbolic link in the virtual file system (VFS).
1411
- *
1412
- * @param pathOrId - The path or ID of the symbolic link to retrieve status for.
1413
- * @returns A promise that resolves to the symbolic link's status information, or false if the link does not exist.
1414
- */
1415
- async lstat(pathOrId, options) {
1416
- return this.resolveFS(pathOrId).promises.lstat(this.resolve(toFilePath(pathOrId)) || toFilePath(pathOrId), options);
1417
- }
1418
- /**
1419
- * Synchronously retrieves the status of a symbolic link in the virtual file system (VFS).
1420
- *
1421
- * @param pathOrId - The path or ID of the symbolic link to retrieve status for.
1422
- * @returns The symbolic link's status information, or false if the link does not exist.
1423
- */
1424
- lstatSync(pathOrId, options) {
1425
- return this.resolveFS(pathOrId).lstatSync(this.resolve(toFilePath(pathOrId)) || toFilePath(pathOrId), options);
1426
- }
1427
- /**
1428
- * Resolves a path based on TypeScript's `tsconfig.json` paths.
1429
- *
1430
- * @see https://www.typescriptlang.org/tsconfig#paths
1431
- *
1432
- * @param path - The path to check.
1433
- * @returns The resolved file path if it exists, otherwise undefined.
1434
- */
1435
- resolveTsconfigPath(path) {
1436
- if (this.#context.tsconfig.options.paths) {
1437
- for (const tsconfigPathKey of Object.keys(this.#context.tsconfig.options.paths).filter((tsconfigPath) => path.startsWith(tsconfigPath.replaceAll("*", "")))) {
1438
- const resolvedPath = this.#context.tsconfig.options.paths[tsconfigPathKey]?.find((tsconfigPath) => this.resolvePath(joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, tsconfigPath.replaceAll("*", ""), path.replace(tsconfigPathKey.replaceAll("*", ""), ""))) || this.formatPath(tsconfigPath) === this.formatPath(path));
1439
- if (resolvedPath) {
1440
- return this.formatPath(resolvedPath) === this.formatPath(path) ? this.formatPath(resolvedPath) : this.resolvePath(joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, resolvedPath.replaceAll("*", ""), path.replace(tsconfigPathKey.replaceAll("*", ""), "")));
1441
- }
1442
- }
1443
- }
1444
- return false;
1445
- }
1446
- /**
1447
- * Resolves a path based on TypeScript's `tsconfig.json` paths.
1448
- *
1449
- * @see https://www.typescriptlang.org/tsconfig#paths
1450
- *
1451
- * @param path - The path to check.
1452
- * @returns The resolved file path if it exists, otherwise undefined.
1453
- */
1454
- resolveTsconfigPathPackage(path) {
1455
- if (this.#context.tsconfig.options.paths) {
1456
- const tsconfigPathKeys = Object.keys(this.#context.tsconfig.options.paths).filter((tsconfigPath) => path.startsWith(tsconfigPath.replaceAll("*", "")));
1457
- if (tsconfigPathKeys.length > 0 && tsconfigPathKeys[0]) {
1458
- return tsconfigPathKeys[0].replace(/\/\*$/, "");
1459
- }
1460
- }
1461
- return false;
1462
- }
1463
- /**
1464
- * Resolves a path or ID to its real path in the virtual file system (VFS).
1465
- *
1466
- * @param pathOrId - The path or ID to resolve.
1467
- * @returns The resolved real path if it exists, otherwise undefined.
1468
- */
1469
- realpathSync(pathOrId) {
1470
- const filePath = this.resolve(toFilePath(pathOrId));
1471
- if (!filePath) {
1472
- throw new Error(`File not found: ${toFilePath(pathOrId)}`);
1473
- }
1474
- return filePath;
1475
- }
1476
- /**
1477
- * Resolves a path or ID parameter to a corresponding virtual file path in the virtual file system (VFS).
1478
- *
1479
- * @param pathOrId - The path or ID to resolve.
1480
- * @param options - Optional parameters for resolving the path, such as whether to include the file extension.
1481
- * @returns The resolved file path if it exists, otherwise undefined.
1482
- */
1483
- resolve(pathOrId, options = {}) {
1484
- const formattedPathOrId = toFilePath(pathOrId);
1485
- const resolverKey = `${formattedPathOrId}${options.withExtension ? "-ext" : ""}${options.paths ? `-${murmurhash.murmurhash(options.paths)}` : ""}${options.type ? `-${options.type}` : ""}`;
1486
- if (this.#cachedResolver.has(resolverKey)) {
1487
- return this.#cachedResolver.get(resolverKey);
1488
- }
1489
- let result = this.resolveId(formattedPathOrId);
1490
- if (!result) {
1491
- result = this.resolvePath(formattedPathOrId, options);
1492
- }
1493
- if (!result) {
1494
- result = false;
1495
- }
1496
- if (result && options.withExtension === false) {
1497
- return result.replace(/\.[m|c]?[t|j]sx?$/, "");
1498
- }
1499
- this.#cachedResolver.set(resolverKey, result);
1500
- return result;
1501
- }
1502
- /**
1503
- * Retrieves the partial metadata for all files in the virtual file system (VFS).
1504
- *
1505
- * @returns A record containing the partial metadata for all files.
1506
- */
1507
- getPartialMeta() {
1508
- return Object.fromEntries(Object.entries(this.#meta).filter(([_, data]) => isSetObject.isSetObject(data)));
1509
- }
1510
- buildRegex(strPattern) {
1511
- const token = "::GLOBSTAR::";
1512
- return new RegExp(`^${this.formatPath(strPattern).replace(/\*\*/g, token).replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*/g, "[^/]*").replace(/\?/g, "[^/]").replace(new RegExp(token, "g"), ".*")}$`);
1513
- }
1514
- /**
1515
- * Converts a relative path to an absolute path based on the workspace and project root.
1516
- *
1517
- * @param path - The relative path to convert.
1518
- * @returns The absolute path.
1519
- */
1520
- formatPath(path) {
1521
- const formattedPath = toFilePath(path);
1522
- if (isType.isAbsolutePath(formattedPath) || formattedPath.startsWith(this.#context.workspaceConfig.workspaceRoot)) {
1523
- return formattedPath;
1524
- } else if (formattedPath.startsWith(this.#context.config.projectRoot)) {
1525
- return joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, formattedPath);
1526
- }
1527
- return formattedPath;
1528
- }
1529
- /**
1530
- * Formats a file id by removing the file extension and prepending the runtime prefix.
1531
- *
1532
- * @param id - The file ID to format.
1533
- * @returns The formatted file ID.
1534
- */
1535
- formatId(id) {
1536
- const formattedId = toFilePath(id);
1537
- return `${this.#context.config.output.builtinPrefix}:${formattedId.replace(new RegExp(`^${this.#context.config.output.builtinPrefix}:`), "").replace(/^\\0/, "").replace(filePathFns.findFileDotExtensionSafe(formattedId), "")}`;
1538
- }
1539
- /**
1540
- * Resolves an id parameter to a corresponding virtual file path in the virtual file system (VFS).
1541
- *
1542
- * @param id - The id to resolve.
1543
- * @returns The resolved file id if it exists, otherwise undefined.
1544
- */
1545
- resolveId(id) {
1546
- if (this.#ids[this.formatId(id)]) {
1547
- return this.#ids[this.formatId(id)] || false;
1548
- }
1549
- return false;
1550
- }
1551
- /**
1552
- * Resolves a path parameter to a corresponding virtual file path in the virtual file system (VFS).
1553
- *
1554
- * @param path - The path to resolve.
1555
- * @param options - Optional parameters for resolving the path.
1556
- * @returns The resolved file path if it exists, otherwise undefined.
1557
- */
1558
- resolvePath(path, options = {}) {
1559
- if (isType.isAbsolutePath(path)) {
1560
- if (this.#existsSync(path)) {
1561
- return path;
1562
- }
1563
- const result = this.checkVariants(path);
1564
- if (result) {
1565
- return result;
1566
- }
1567
- }
1568
- for (const parentPath of this.resolveParentPaths(path, options.paths)) {
1569
- const request = joinPaths.joinPaths(parentPath, path);
1570
- if (this.#existsSync(request)) {
1571
- return request;
1572
- }
1573
- const result = this.checkVariants(request);
1574
- if (result) {
1575
- return result;
1576
- }
1577
- }
1578
- return false;
1579
- }
1580
- resolveParentPaths(request, parents = []) {
1581
- let paths = [
1582
- this.#context.workspaceConfig.workspaceRoot,
1583
- joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, this.#context.config.projectRoot)
1584
- ];
1585
- if (this.#context.tsconfig.options.paths) {
1586
- paths = this.#context.tsconfig.options.paths ? Object.keys(this.#context.tsconfig.options.paths).filter((tsconfigPath) => request.startsWith(tsconfigPath.replaceAll("*", ""))).map((tsconfigPath) => this.#context.tsconfig.options.paths?.[tsconfigPath]).flat().reduce((ret, path) => {
1587
- if (path && !ret.includes(joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, path))) {
1588
- ret.push(joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, path));
1589
- }
1590
- return ret;
1591
- }, paths) : paths;
1592
- }
1593
- return paths.reduce((ret, path) => {
1594
- if (!ret.includes(path)) {
1595
- ret.push(path);
1596
- }
1597
- return ret;
1598
- }, parents.filter(Boolean).map((p) => this.formatPath(p)));
1766
+ 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()));
1599
1767
  }
1600
1768
  /**
1601
- * Select the file system module to use for the operation based on the path or URL.
1769
+ * Retrieves the status of a file in the virtual file system (VFS).
1602
1770
  *
1603
- * @param pathOrUrl - The path to perform the file system operation on.
1604
- * @param options - Options for the operation, such as output mode.
1605
- * @returns The file system module used for the operation.
1771
+ * @param pathOrId - The path or ID of the file to retrieve status for.
1772
+ * @returns A promise that resolves to the file's status information, or false if the file does not exist.
1606
1773
  */
1607
- resolveFS(pathOrUrl, options = {}) {
1608
- const mode = this.resolveOutputMode(pathOrUrl, options);
1609
- if (mode === "virtual") {
1610
- return this.#virtualFS;
1611
- } else if (mode === "fs") {
1612
- return this.#fs;
1613
- }
1614
- return this.#unifiedFS;
1774
+ async stat(pathOrId, options) {
1775
+ return this.#unifiedFS.resolveFS(pathOrId).promises.stat(this.resolve(toFilePath(pathOrId)) || toFilePath(pathOrId), options);
1615
1776
  }
1616
1777
  /**
1617
- * Select the file system module to use for the operation based on the path or URL.
1778
+ * Synchronously retrieves the status of a file in the virtual file system (VFS).
1618
1779
  *
1619
- * @param pathOrUrl - The path to perform the file system operation on.
1620
- * @param options - Options for the operation, such as output mode.
1621
- * @returns The file system module used for the operation.
1780
+ * @param pathOrId - The path or ID of the file to retrieve status for.
1781
+ * @returns The file's status information, or false if the file does not exist.
1622
1782
  */
1623
- resolveOutputMode(pathOrUrl, options = {}) {
1624
- if (options.mode === "virtual" && this.#context.config.output.mode !== "fs" && isParentPath.isParentPath(toFilePath(pathOrUrl), this.#context.artifactsPath)) {
1625
- return "virtual";
1626
- } else if (options.mode === "fs" || this.#context.config.output.mode === "fs" || isParentPath.isParentPath(toFilePath(pathOrUrl), this.#context.dataPath) || isParentPath.isParentPath(toFilePath(pathOrUrl), this.#context.cachePath) || isParentPath.isParentPath(toFilePath(pathOrUrl), joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, this.#context.config.output.outputPath))) {
1627
- return "fs";
1628
- }
1629
- return void 0;
1783
+ statSync(pathOrId) {
1784
+ return this.#unifiedFS.resolveFS(pathOrId).statSync(this.resolve(toFilePath(pathOrId)) || toFilePath(pathOrId));
1630
1785
  }
1631
1786
  /**
1632
- * Clears the resolver cache for a given path.
1787
+ * Retrieves the status of a symbolic link in the virtual file system (VFS).
1633
1788
  *
1634
- * @param path - The path to clear the resolver cache for.
1789
+ * @param pathOrId - The path or ID of the symbolic link to retrieve status for.
1790
+ * @returns A promise that resolves to the symbolic link's status information, or false if the link does not exist.
1635
1791
  */
1636
- clearResolverCache(path) {
1637
- this.#cachedResolver.keys().filter((key) => key.startsWith(toFilePath(path))).forEach((key) => this.#cachedResolver.delete(key));
1792
+ async lstat(pathOrId, options) {
1793
+ return this.#unifiedFS.resolveFS(pathOrId).promises.lstat(this.resolve(toFilePath(pathOrId)) || toFilePath(pathOrId), options);
1638
1794
  }
1639
1795
  /**
1640
- * Check if the file exists with different variants (index, extensions).
1796
+ * Synchronously retrieves the status of a symbolic link in the virtual file system (VFS).
1641
1797
  *
1642
- * @param request - The request path to check.
1643
- * @param parentPath - An optional parent path to prepend to the request.
1644
- * @returns The file path if it exists, otherwise false.
1798
+ * @param pathOrId - The path or ID of the symbolic link to retrieve status for.
1799
+ * @returns The symbolic link's status information, or false if the link does not exist.
1645
1800
  */
1646
- checkVariants(request, parentPath) {
1647
- const path = parentPath ? joinPaths.joinPaths(parentPath, request) : request;
1648
- let file = this.checkExtensions(path);
1649
- if (file) {
1650
- return file;
1651
- }
1652
- file = this.checkIndex(path);
1653
- if (file) {
1654
- return file;
1655
- }
1656
- return false;
1801
+ lstatSync(pathOrId, options) {
1802
+ return this.#unifiedFS.resolveFS(pathOrId).lstatSync(this.resolve(toFilePath(pathOrId)) || toFilePath(pathOrId), options);
1657
1803
  }
1658
1804
  /**
1659
- * Check if the index file exists in the given request path.
1805
+ * Resolves a path or ID to its real path in the virtual file system (VFS).
1660
1806
  *
1661
- * @param request - The request path to check.
1662
- * @returns The index file path if it exists, otherwise false.
1807
+ * @param pathOrId - The path or ID to resolve.
1808
+ * @returns The resolved real path if it exists, otherwise undefined.
1663
1809
  */
1664
- checkIndex(request) {
1665
- let file = joinPaths.joinPaths(request, "index");
1666
- if (this.#existsSync(file)) {
1667
- return file;
1668
- }
1669
- file = this.checkExtensions(file);
1670
- if (file) {
1671
- return file;
1810
+ realpathSync(pathOrId) {
1811
+ const filePath = this.resolve(toFilePath(pathOrId));
1812
+ if (!filePath) {
1813
+ throw new Error(`File not found: ${toFilePath(pathOrId)}`);
1672
1814
  }
1673
- return false;
1815
+ return filePath;
1674
1816
  }
1675
1817
  /**
1676
- * Check if the file exists with different extensions.
1818
+ * Resolves a path or ID parameter to a corresponding virtual file path in the virtual file system (VFS).
1677
1819
  *
1678
- * @param request - The request path to check.
1679
- * @param vfs - The file system module to use for checking file existence.
1680
- * @returns The file path if it exists with any of the checked extensions, otherwise false.
1820
+ * @param pathOrId - The path or ID to resolve.
1821
+ * @param options - Optional parameters for resolving the path, such as whether to include the file extension.
1822
+ * @returns The resolved file path if it exists, otherwise undefined.
1681
1823
  */
1682
- checkExtensions(request) {
1683
- let file = `${request}.ts`;
1684
- if (this.#existsSync(file)) {
1685
- return file;
1686
- }
1687
- file = `${request}.mts`;
1688
- if (this.#existsSync(file)) {
1689
- return file;
1690
- }
1691
- file = `${request}.cts`;
1692
- if (this.#existsSync(file)) {
1693
- return file;
1824
+ resolve(pathOrId, options = {}) {
1825
+ const formattedPathOrId = toFilePath(pathOrId);
1826
+ const resolverKey = `${formattedPathOrId}${options.withExtension ? "-ext" : ""}${options.paths ? `-${murmurhash.murmurhash(options.paths)}` : ""}${options.type ? `-${options.type}` : ""}`;
1827
+ if (this.#cachedResolver.has(resolverKey)) {
1828
+ return this.#cachedResolver.get(resolverKey);
1694
1829
  }
1695
- file = `${request}.tsx`;
1696
- if (this.#existsSync(file)) {
1697
- return file;
1830
+ let result = this.#resolveId(formattedPathOrId);
1831
+ if (!result) {
1832
+ result = this.#resolvePath(formattedPathOrId, options);
1698
1833
  }
1699
- file = `${request}.js`;
1700
- if (this.#existsSync(file)) {
1701
- return file;
1834
+ if (!result) {
1835
+ result = false;
1702
1836
  }
1703
- file = `${request}.mjs`;
1704
- if (this.#existsSync(file)) {
1705
- return file;
1837
+ if (result && options.withExtension === false) {
1838
+ return result.replace(/\.[m|c]?[t|j]sx?$/, "");
1706
1839
  }
1707
- file = `${request}.cjs`;
1708
- if (this.#existsSync(file)) {
1709
- return file;
1840
+ this.#cachedResolver.set(resolverKey, result);
1841
+ return result;
1842
+ }
1843
+ /**
1844
+ * Converts a relative path to an absolute path based on the workspace and project root.
1845
+ *
1846
+ * @param path - The relative path to convert.
1847
+ * @returns The absolute path.
1848
+ */
1849
+ formatPath(path) {
1850
+ const formattedPath = toFilePath(path);
1851
+ if (isType.isAbsolutePath(formattedPath) || formattedPath.startsWith(this.#context.workspaceConfig.workspaceRoot)) {
1852
+ return formattedPath;
1853
+ } else if (formattedPath.startsWith(this.#context.config.projectRoot)) {
1854
+ return joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, formattedPath);
1710
1855
  }
1711
- file = `${request}.jsx`;
1712
- if (this.#existsSync(file)) {
1713
- return file;
1856
+ return formattedPath;
1857
+ }
1858
+ /**
1859
+ * Disposes of the virtual file system (VFS) by saving its state to disk.
1860
+ */
1861
+ async dispose() {
1862
+ if (!this.#isDisposed) {
1863
+ this.#isDisposed = true;
1864
+ this.#log(types.LogLevelLabel.DEBUG, "Disposing virtual file system...");
1865
+ await this.unlink(joinPaths.joinPaths(this.#context.cachePath, "fs.bin"));
1866
+ const message = new $__namespace.Message();
1867
+ const data = message.initRoot(FileSystemData);
1868
+ const virtualFS = this.#unifiedFS.toJSON();
1869
+ const files = data._initFiles(Object.keys(virtualFS).length);
1870
+ Object.entries(virtualFS).filter(([_, content]) => content).forEach(([path, content], index) => {
1871
+ const fileData = files.get(index);
1872
+ fileData.path = path;
1873
+ fileData.content = content;
1874
+ });
1875
+ const ids = data._initIds(Object.keys(this.ids).length);
1876
+ Object.entries(this.ids).forEach(([id, path], index) => {
1877
+ const fileId = ids.get(index);
1878
+ fileId.id = id;
1879
+ fileId.path = path;
1880
+ });
1881
+ const metadata = data._initMetadata(Object.keys(this.metadata).length);
1882
+ Object.entries(this.metadata).forEach(([id, value], index) => {
1883
+ const fileMetadata = metadata.get(index);
1884
+ fileMetadata.id = id;
1885
+ fileMetadata.mode = value.mode;
1886
+ fileMetadata.variant = value.variant;
1887
+ if (value.properties) {
1888
+ const props = fileMetadata._initProperties(Object.keys(value.properties).length);
1889
+ Object.entries(value.properties).forEach(([key, val], propIndex) => {
1890
+ const propData = props.get(propIndex);
1891
+ propData.key = key;
1892
+ propData.value = val;
1893
+ });
1894
+ }
1895
+ });
1896
+ await buffer.writeFileBuffer(joinPaths.joinPaths(this.#context.cachePath, "fs.bin"), message.toArrayBuffer());
1714
1897
  }
1715
- file = `${request}.json`;
1716
- if (this.#existsSync(file)) {
1717
- return file;
1898
+ }
1899
+ /**
1900
+ * Initializes the virtual file system (VFS) by patching the file system module if necessary.
1901
+ */
1902
+ [chunkSVF4ATJR_cjs.__VFS_PATCH__]() {
1903
+ if (!this.#isPatched && this.#context.config.output.mode !== "fs") {
1904
+ this.#revert = patchFS(fs__default.default, this);
1905
+ this.#isPatched = true;
1718
1906
  }
1719
- file = `${request}.d.ts`;
1720
- if (this.#existsSync(file)) {
1721
- return file;
1907
+ }
1908
+ /**
1909
+ * Reverts the file system module to its original state if it was previously patched.
1910
+ */
1911
+ [chunkSVF4ATJR_cjs.__VFS_REVERT__]() {
1912
+ if (this.#isPatched && this.#context.config.output.mode !== "fs") {
1913
+ if (!this.#revert) {
1914
+ throw new Error("Attempting to revert File System patch prior to calling `__init__` function");
1915
+ }
1916
+ this.#revert?.();
1917
+ this.#isPatched = false;
1722
1918
  }
1723
- return false;
1919
+ }
1920
+ async [Symbol.asyncDispose]() {
1921
+ return this.dispose();
1724
1922
  }
1725
1923
  };
1726
- function createVfs(context) {
1727
- const vfs = new VirtualFileSystem(context);
1728
- return vfs;
1924
+ var PROJECT_ROOT_HASH_LENGTH = 45;
1925
+ var CACHE_HASH_LENGTH = 62;
1926
+ function getPrefixedProjectRootHash(name, projectRootHash) {
1927
+ const combined = `${kebabCase.kebabCase(name)}_${projectRootHash}`;
1928
+ return combined.length > PROJECT_ROOT_HASH_LENGTH ? combined.slice(0, PROJECT_ROOT_HASH_LENGTH) : combined;
1929
+ }
1930
+ chunkUSNT2KNT_cjs.__name(getPrefixedProjectRootHash, "getPrefixedProjectRootHash");
1931
+ async function getChecksum(path) {
1932
+ return hashFiles.hashDirectory(path, {
1933
+ ignore: [
1934
+ "node_modules",
1935
+ ".git",
1936
+ ".nx",
1937
+ ".cache",
1938
+ ".storm",
1939
+ "tmp",
1940
+ "dist"
1941
+ ]
1942
+ });
1943
+ }
1944
+ chunkUSNT2KNT_cjs.__name(getChecksum, "getChecksum");
1945
+ async function writeMetaFile(context) {
1946
+ const metaFilePath = joinPaths.joinPaths(context.dataPath, "meta.json");
1947
+ context.log(types.LogLevelLabel.DEBUG, `Writing runtime metadata to ${metaFilePath}`);
1948
+ await context.fs.writeFile(metaFilePath, JSON.stringify(context.meta, null, 2), {
1949
+ mode: "fs"
1950
+ });
1951
+ }
1952
+ chunkUSNT2KNT_cjs.__name(writeMetaFile, "writeMetaFile");
1953
+ function isPlugin(value) {
1954
+ return isSetObject.isSetObject(value) && "name" in value && isSetString.isSetString(value.name) && (isUndefined.isUndefined(value.applyToEnvironment) || "applyToEnvironment" in value && isFunction.isFunction(value.applyToEnvironment)) && (isUndefined.isUndefined(value.dedupe) || "dedupe" in value && isFunction.isFunction(value.dedupe)) && (isUndefined.isUndefined(value.dependsOn) || "dependsOn" in value && Array.isArray(value.dependsOn) && value.dependsOn.every(isPluginConfig)) && chunkPAMSESZV_cjs.SUPPORTED_COMMANDS.every((command) => isUndefined.isUndefined(value[command]) || command in value && (isFunction.isFunction(value[command]) || isSetObject.isSetObject(value[command]) && "handler" in value[command] && isFunction.isFunction(value[command].handler)));
1955
+ }
1956
+ chunkUSNT2KNT_cjs.__name(isPlugin, "isPlugin");
1957
+ function isPluginConfigObject(value) {
1958
+ return isSetObject.isSetObject(value) && "plugin" in value && ((isSetString.isSetString(value.plugin) || isFunction.isFunction(value.plugin)) && "options" in value && isSetObject.isSetObject(value.options) || isPlugin(value.plugin));
1959
+ }
1960
+ chunkUSNT2KNT_cjs.__name(isPluginConfigObject, "isPluginConfigObject");
1961
+ function isPluginConfigTuple(value) {
1962
+ return Array.isArray(value) && (value.length === 1 || value.length === 2) && ((isSetString.isSetString(value[0]) || isFunction.isFunction(value[0])) && value.length > 1 && isSetObject.isSetObject(value[1]) || isPlugin(value[0]));
1729
1963
  }
1730
- chunkUSNT2KNT_cjs.__name(createVfs, "createVfs");
1964
+ chunkUSNT2KNT_cjs.__name(isPluginConfigTuple, "isPluginConfigTuple");
1965
+ function isPluginConfig(value) {
1966
+ return isSetString.isSetString(value) || isFunction.isFunction(value) || isPlugin(value) || isPluginConfigObject(value) || isPluginConfigTuple(value);
1967
+ }
1968
+ chunkUSNT2KNT_cjs.__name(isPluginConfig, "isPluginConfig");
1969
+ function isPluginHookFunction(value) {
1970
+ return isFunction.isFunction(value) || isSetObject.isSetObject(value) && "handler" in value && isFunction.isFunction(value.handler);
1971
+ }
1972
+ chunkUSNT2KNT_cjs.__name(isPluginHookFunction, "isPluginHookFunction");
1973
+ function isPluginHookObject(value) {
1974
+ return isSetObject.isSetObject(value) && "handler" in value && isFunction.isFunction(value.handler);
1975
+ }
1976
+ chunkUSNT2KNT_cjs.__name(isPluginHookObject, "isPluginHookObject");
1977
+ function isPluginHook(value) {
1978
+ return isPluginHookFunction(value) || isPluginHookObject(value);
1979
+ }
1980
+ chunkUSNT2KNT_cjs.__name(isPluginHook, "isPluginHook");
1981
+ function getHookHandler(pluginHook) {
1982
+ return isFunction.isFunction(pluginHook) ? pluginHook : pluginHook.handler;
1983
+ }
1984
+ chunkUSNT2KNT_cjs.__name(getHookHandler, "getHookHandler");
1985
+ function isHookExternal(hook) {
1986
+ return hook.startsWith("vite:") || hook.startsWith("esbuild:") || hook.startsWith("rolldown:") || hook.startsWith("rollup:") || hook.startsWith("webpack:") || hook.startsWith("rspack:") || hook.startsWith("farm:");
1987
+ }
1988
+ chunkUSNT2KNT_cjs.__name(isHookExternal, "isHookExternal");
1989
+ function checkDedupe(plugin, plugins) {
1990
+ return plugin.dedupe === false || plugins.some((p) => p.dedupe !== false && (isFunction.isFunction(p.dedupe) && p.dedupe(plugin) || p.name === plugin.name));
1991
+ }
1992
+ chunkUSNT2KNT_cjs.__name(checkDedupe, "checkDedupe");
1993
+ function addPluginHook(context, plugin, pluginHook, hooksList) {
1994
+ if (!checkDedupe(plugin, hooksList.map((hook) => hook.plugin))) {
1995
+ hooksList.push(isFunction.isFunction(pluginHook) ? {
1996
+ plugin,
1997
+ handler: getHookHandler(pluginHook).bind(context)
1998
+ } : {
1999
+ plugin,
2000
+ ...pluginHook,
2001
+ handler: getHookHandler(pluginHook).bind(context)
2002
+ });
2003
+ }
2004
+ }
2005
+ chunkUSNT2KNT_cjs.__name(addPluginHook, "addPluginHook");
2006
+ function resolveOptions(options) {
2007
+ return defu3__default.default(options, {
2008
+ interopDefault: true,
2009
+ fsCache: options.mode !== "development" ? joinPaths.joinPaths(options.cacheDir, "jiti") : false,
2010
+ moduleCache: options.mode !== "development"
2011
+ });
2012
+ }
2013
+ chunkUSNT2KNT_cjs.__name(resolveOptions, "resolveOptions");
2014
+ function createPluginResolver(options) {
2015
+ return jiti.createJiti(joinPaths.joinPaths(options.workspaceRoot, options.projectRoot), resolveOptions({
2016
+ ...options
2017
+ }));
2018
+ }
2019
+ chunkUSNT2KNT_cjs.__name(createPluginResolver, "createPluginResolver");
2020
+ function createResolver(options) {
2021
+ const baseResolver = jiti.createJiti(joinPaths.joinPaths(options.workspaceRoot, options.projectRoot), resolveOptions(options));
2022
+ baseResolver.plugin = createPluginResolver(options);
2023
+ return baseResolver;
2024
+ }
2025
+ chunkUSNT2KNT_cjs.__name(createResolver, "createResolver");
1731
2026
 
1732
2027
  // src/internal/contexts/context.ts
1733
2028
  var configCache = /* @__PURE__ */ new WeakMap();
@@ -1842,7 +2137,7 @@ var PowerlinesContext = class _PowerlinesContext {
1842
2137
  */
1843
2138
  get fs() {
1844
2139
  if (!this.#fs) {
1845
- this.#fs = createVfs(this);
2140
+ this.#fs = VirtualFileSystem.createSync(this);
1846
2141
  }
1847
2142
  return this.#fs;
1848
2143
  }
@@ -1869,9 +2164,7 @@ var PowerlinesContext = class _PowerlinesContext {
1869
2164
  }),
1870
2165
  configHash: murmurhash.murmurhash(this.config, {
1871
2166
  maxLength: CACHE_HASH_LENGTH
1872
- }),
1873
- builtinIdMap: {},
1874
- virtualFiles: {}
2167
+ })
1875
2168
  };
1876
2169
  }
1877
2170
  /**
@@ -1959,13 +2252,13 @@ var PowerlinesContext = class _PowerlinesContext {
1959
2252
  * The builtin module id that exist in the Powerlines virtual file system
1960
2253
  */
1961
2254
  get builtins() {
1962
- return Object.values(this.fs.meta).filter((meta) => meta && meta.variant === "builtin").map((meta) => meta?.id).filter(Boolean);
2255
+ return Object.values(this.fs.metadata).filter((meta) => meta && meta.variant === "builtin").map((meta) => meta?.id).filter(Boolean);
1963
2256
  }
1964
2257
  /**
1965
- * Get the project root relative to the workspace root
2258
+ * Get the builtin virtual files that exist in the Powerlines virtual file system
1966
2259
  */
1967
2260
  async getBuiltins() {
1968
- return Promise.all(Object.entries(this.fs.meta).filter(([, meta]) => meta && meta.variant === "builtin").map(async ([path, meta]) => {
2261
+ return Promise.all(Object.entries(this.fs.metadata).filter(([, meta]) => meta && meta.variant === "builtin").map(async ([path, meta]) => {
1969
2262
  const code = await this.fs.readFile(path);
1970
2263
  return {
1971
2264
  ...meta,
@@ -1985,7 +2278,7 @@ var PowerlinesContext = class _PowerlinesContext {
1985
2278
  return this.fs.writeFile(isType.isAbsolute(path) ? path : append.appendPath(path, this.entryPath), {
1986
2279
  code,
1987
2280
  variant: "entry"
1988
- }, defu4__default.default(options, {
2281
+ }, defu3__default.default(options, {
1989
2282
  mode: this.config.output.mode
1990
2283
  }));
1991
2284
  }
@@ -2002,7 +2295,7 @@ var PowerlinesContext = class _PowerlinesContext {
2002
2295
  id,
2003
2296
  code,
2004
2297
  variant: "builtin"
2005
- }, defu4__default.default(options, {
2298
+ }, defu3__default.default(options, {
2006
2299
  mode: this.config.output.mode
2007
2300
  }));
2008
2301
  }
@@ -2024,7 +2317,7 @@ var PowerlinesContext = class _PowerlinesContext {
2024
2317
  options
2025
2318
  });
2026
2319
  }
2027
- const result = await oxcParser.parseAsync(id, code, defu4__default.default(options ?? {}, {
2320
+ const result = await oxcParser.parseAsync(id, code, defu3__default.default(options ?? {}, {
2028
2321
  lang: filePathFns.hasFileExtension(id) ? void 0 : "ts",
2029
2322
  astType: filePathFns.hasFileExtension(id) ? void 0 : "ts",
2030
2323
  sourceType: "module",
@@ -2212,7 +2505,7 @@ ${result.errors.map((error) => ` [${error.severity}] ${error.message}${error.co
2212
2505
  });
2213
2506
  }
2214
2507
  if (isSetObject.isSetObject(config)) {
2215
- this.resolvedConfig = defu4__default.default({
2508
+ this.resolvedConfig = defu3__default.default({
2216
2509
  inlineConfig: this.config.inlineConfig,
2217
2510
  userConfig: this.config.userConfig
2218
2511
  }, options.isHighPriority ? this.#getConfigProps(config) : {}, {
@@ -2306,9 +2599,10 @@ ${result.errors.map((error) => ` [${error.severity}] ${error.message}${error.co
2306
2599
  ret.push(plugin);
2307
2600
  return ret;
2308
2601
  }, []);
2602
+ this.#fs ??= await VirtualFileSystem.create(this);
2309
2603
  }
2310
2604
  mergeUserConfig(from = {}, into = this.config.userConfig ?? {}) {
2311
- this.config.userConfig = defu4__default.default({
2605
+ this.config.userConfig = defu3__default.default({
2312
2606
  entry: Array.isArray(from.entry) && from.entry.length > 0 ? from.entry : Array.isArray(into?.entry) && into.entry.length > 0 ? into.entry : []
2313
2607
  }, omit.omit(from ?? {}, [
2314
2608
  "entry"
@@ -2354,7 +2648,7 @@ async function callHook(context, hook, options, ...args) {
2354
2648
  if (definedResults.length > 0) {
2355
2649
  let mergedResult = void 0;
2356
2650
  for (const result of definedResults) {
2357
- mergedResult = defu4.defu(result, mergedResult ?? {});
2651
+ mergedResult = defu3.defu(result, mergedResult ?? {});
2358
2652
  }
2359
2653
  return mergedResult;
2360
2654
  }
@@ -2664,7 +2958,7 @@ async function emitTypes(context, tsconfig, files) {
2664
2958
  const emitResult = program.emit(void 0, (fileName, text, _, __, sourceFiles, _data) => {
2665
2959
  const sourceFile = sourceFiles?.[0];
2666
2960
  if (sourceFile?.fileName && !fileName.endsWith(".map")) {
2667
- if (context.builtins.some((file) => file === sourceFile.fileName || context.fs.meta[file]?.id && context.fs.meta[file]?.id === sourceFile.fileName)) {
2961
+ if (context.builtins.some((file) => file === sourceFile.fileName || context.fs.metadata[file]?.id && context.fs.metadata[file]?.id === sourceFile.fileName)) {
2668
2962
  builtinModules += `
2669
2963
  declare module "${context.fs.resolve(sourceFile.fileName)}" {
2670
2964
  ${text.trim().replace(/^\s*export\s*declare\s*/gm, "export ").replace(/^\s*declare\s*/gm, "")}
@@ -2813,7 +3107,7 @@ function getParsedTypeScriptConfig(workspaceRoot, projectRoot, tsconfig, tsconfi
2813
3107
  if (!tsconfigJson) {
2814
3108
  throw new Error(`Cannot find the \`tsconfig.json\` configuration file at ${joinPaths.joinPaths(projectRoot, tsconfig ?? "tsconfig.json")}`);
2815
3109
  }
2816
- const parsedCommandLine = ts2__default.default.parseJsonConfigFileContent(defu4__default.default(tsconfigRaw ?? {}, tsconfigJson), host, append.appendPath(projectRoot, workspaceRoot));
3110
+ const parsedCommandLine = ts2__default.default.parseJsonConfigFileContent(defu3__default.default(tsconfigRaw ?? {}, tsconfigJson), host, append.appendPath(projectRoot, workspaceRoot));
2817
3111
  if (parsedCommandLine.errors.length > 0) {
2818
3112
  const errorMessage = `Cannot parse the TypeScript compiler options. Please investigate the following issues:
2819
3113
  ${parsedCommandLine.errors.map((error) => `- ${(error.category !== void 0 && error.code ? `[${error.category}-${error.code}]: ` : "") + error.messageText.toString()}`).join("\n")}
@@ -3105,10 +3399,13 @@ ${context.entry.map((entry) => `- ${entry.input.file || entry.file}${entry.outpu
3105
3399
  await resolveTsconfig(context);
3106
3400
  await installDependencies(context);
3107
3401
  await this.callPostHook(context, "configResolved");
3402
+ if (context.config.build.polyfill) {
3403
+ context.config.build.polyfill = context.config.build.polyfill.map((polyfill) => replacePathTokens(context, polyfill));
3404
+ }
3108
3405
  context.log(types.LogLevelLabel.TRACE, `Powerlines configuration has been resolved:
3109
3406
 
3110
3407
  ${console.formatLogMessage(context.config)}`);
3111
- context.fs[chunkRF6RSWD4_cjs.__VFS_INIT__]();
3408
+ context.fs[chunkSVF4ATJR_cjs.__VFS_PATCH__]();
3112
3409
  await writeMetaFile(context);
3113
3410
  context.persistedMeta = context.meta;
3114
3411
  if (!exists.existsSync(context.cachePath)) {
@@ -3168,7 +3465,7 @@ ${console.formatLogMessage(context.config)}`);
3168
3465
  joinPaths.joinPaths(typescriptPath, "lib", "lib.esnext.full.d.ts")
3169
3466
  ]);
3170
3467
  context.log(types.LogLevelLabel.TRACE, "Parsing TypeScript configuration for the Powerlines project.");
3171
- const resolvedTsconfig = getParsedTypeScriptConfig(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.tsconfig.tsconfigFilePath, defu4__default.default({
3468
+ const resolvedTsconfig = getParsedTypeScriptConfig(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.tsconfig.tsconfigFilePath, defu3__default.default({
3172
3469
  compilerOptions: {
3173
3470
  strict: false,
3174
3471
  noEmit: false,
@@ -3240,7 +3537,7 @@ ${formatTypes(generatedTypes)}
3240
3537
  }
3241
3538
  await this.callPostHook(context, "prepare");
3242
3539
  await writeMetaFile(context);
3243
- context.fs[chunkRF6RSWD4_cjs.__VFS_REVERT__]();
3540
+ context.fs[chunkSVF4ATJR_cjs.__VFS_REVERT__]();
3244
3541
  });
3245
3542
  this.context.log(types.LogLevelLabel.INFO, "Powerlines API has been prepared successfully");
3246
3543
  }
@@ -3370,22 +3667,22 @@ ${formatTypes(generatedTypes)}
3370
3667
  this.#context.log(types.LogLevelLabel.TRACE, "Powerlines documentation generation completed");
3371
3668
  }
3372
3669
  /**
3373
- * Release the project
3670
+ * Deploy the project source code
3374
3671
  *
3375
3672
  * @remarks
3376
- * This method will prepare and build the Powerlines project, generating the necessary artifacts for release.
3673
+ * This method will prepare and build the Powerlines project, generating the necessary artifacts for the deployment.
3377
3674
  *
3378
- * @param inlineConfig - The inline configuration for the release command
3675
+ * @param inlineConfig - The inline configuration for the deploy command
3379
3676
  */
3380
- async release(inlineConfig = {
3381
- command: "release"
3677
+ async deploy(inlineConfig = {
3678
+ command: "deploy"
3382
3679
  }) {
3383
- this.context.log(types.LogLevelLabel.INFO, "\u{1F4E6} Releasing the Powerlines project");
3680
+ this.context.log(types.LogLevelLabel.INFO, "\u{1F4E6} Deploying the Powerlines project");
3384
3681
  await this.prepare(inlineConfig);
3385
3682
  await this.#executeEnvironments(async (context) => {
3386
- await this.callHook(context, "release");
3683
+ await this.callHook(context, "deploy");
3387
3684
  });
3388
- this.context.log(types.LogLevelLabel.TRACE, "Powerlines release completed");
3685
+ this.context.log(types.LogLevelLabel.TRACE, "Powerlines deploy completed");
3389
3686
  }
3390
3687
  /**
3391
3688
  * Finalization process
@@ -3399,7 +3696,8 @@ ${formatTypes(generatedTypes)}
3399
3696
  this.context.log(types.LogLevelLabel.TRACE, "Powerlines finalize execution started");
3400
3697
  await this.#executeEnvironments(async (context) => {
3401
3698
  await this.callHook(context, "finalize");
3402
- context.fs[chunkRF6RSWD4_cjs.__VFS_REVERT__]();
3699
+ context.fs[chunkSVF4ATJR_cjs.__VFS_REVERT__]();
3700
+ await context.fs.dispose();
3403
3701
  });
3404
3702
  this.context.log(types.LogLevelLabel.TRACE, "Powerlines finalize execution completed");
3405
3703
  }
@@ -3658,5 +3956,11 @@ Note: Please ensure the plugin package's default export is a class that extends
3658
3956
  }
3659
3957
  };
3660
3958
 
3959
+ exports.FileData = FileData;
3960
+ exports.FileIdentifier = FileIdentifier;
3961
+ exports.FileMetadata = FileMetadata;
3962
+ exports.FileMetadata_KeyValuePair = FileMetadata_KeyValuePair;
3963
+ exports.FileSystemData = FileSystemData;
3661
3964
  exports.PowerlinesAPI = PowerlinesAPI;
3965
+ exports._capnpFileId = _capnpFileId;
3662
3966
  exports.createLog = createLog;