powerlines 0.9.0 → 0.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/astro.cjs +9 -9
- package/dist/astro.d.cts +2 -1
- package/dist/astro.d.ts +2 -1
- package/dist/astro.js +6 -6
- package/dist/{chunk-3L4KRPXQ.cjs → chunk-2RHPFVYT.cjs} +17 -18
- package/dist/{chunk-VQ5O5N7V.js → chunk-3Y5CCIJR.js} +3 -3
- package/dist/{chunk-YE56I7CZ.cjs → chunk-5XYGZ3DC.cjs} +2 -2
- package/dist/{chunk-V4TNA6HX.js → chunk-5Y4JYQ66.js} +3 -3
- package/dist/{chunk-WM76YQJH.cjs → chunk-66GXB2UY.cjs} +4 -4
- package/dist/{chunk-VOB62ELC.js → chunk-6TJGZR5X.js} +4 -4
- package/dist/{chunk-OKC6TA7P.js → chunk-6UDHGAAI.js} +3 -3
- package/dist/{chunk-ETEQKM36.cjs → chunk-7IWH37DY.cjs} +2 -2
- package/dist/{chunk-BDTLKRKQ.js → chunk-EGSEJQCE.js} +3 -3
- package/dist/{chunk-ILVCZATT.js → chunk-GPPJ2CRE.js} +2 -2
- package/dist/{chunk-RGJMMCOR.js → chunk-HVT7PBFF.js} +3 -3
- package/dist/chunk-IJBH5OUN.cjs +12 -0
- package/dist/chunk-JBTSAOIQ.js +31 -0
- package/dist/{chunk-W3NQCDUN.js → chunk-KYGEWAEG.js} +3 -3
- package/dist/{chunk-FOLQTZUP.cjs → chunk-L2SAK2JC.cjs} +4 -4
- package/dist/chunk-LXMNDUPG.cjs +12 -0
- package/dist/{chunk-GHW2FUF5.js → chunk-N7NE3VOU.js} +4 -4
- package/dist/{chunk-OEL3BTQP.js → chunk-OYIM2M74.js} +547 -522
- package/dist/{chunk-QK36ULYT.cjs → chunk-QHGPZK2H.cjs} +4 -4
- package/dist/chunk-RQ4CHMPO.cjs +12 -0
- package/dist/chunk-S5QFX2GM.cjs +12 -0
- package/dist/{chunk-IOBFVFH2.js → chunk-S746E63M.js} +3 -3
- package/dist/{chunk-MKZOY5EV.js → chunk-SDEBJQDT.js} +12 -13
- package/dist/chunk-SL3CXJWD.cjs +34 -0
- package/dist/{chunk-KC4VY5X4.cjs → chunk-UHCRNFFC.cjs} +9 -9
- package/dist/{chunk-ZQZ5ZUGG.cjs → chunk-UTVZVGM3.cjs} +555 -530
- package/dist/{chunk-QIKKQQF7.cjs → chunk-UZQYBO6Z.cjs} +4 -4
- package/dist/{chunk-65PSZQFC.js → chunk-VIRKTIPK.js} +3 -3
- package/dist/{chunk-UYS3BU6I.js → chunk-WCPY7HPU.js} +4 -4
- package/dist/{chunk-MMDBMHAW.js → chunk-WPVIF35O.js} +2 -2
- package/dist/chunk-YG7U2GIR.cjs +24 -0
- package/dist/{chunk-BY4UTCHZ.cjs → chunk-ZBDP43LG.cjs} +6 -6
- package/dist/chunk-ZFATNDSY.cjs +12 -0
- package/dist/{chunk-C3I5QEF5.js → chunk-ZU4IRZSQ.js} +7 -7
- package/dist/define-config.d.cts +2 -1
- package/dist/define-config.d.ts +2 -1
- package/dist/esbuild.cjs +8 -8
- package/dist/esbuild.d.cts +2 -1
- package/dist/esbuild.d.ts +2 -1
- package/dist/esbuild.js +5 -5
- package/dist/extend-plugin.d.cts +2 -1
- package/dist/extend-plugin.d.ts +2 -1
- package/dist/farm.cjs +4 -4
- package/dist/farm.d.cts +2 -1
- package/dist/farm.d.ts +2 -1
- package/dist/farm.js +3 -3
- package/dist/{hooks-D0gf1nT3.d.ts → hooks-BGYnc61f.d.ts} +1 -1
- package/dist/{hooks-fVJu9DCF.d.cts → hooks-gk8S8LFP.d.cts} +1 -1
- package/dist/index.cjs +27 -27
- package/dist/index.d.cts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +18 -18
- package/dist/internal/api.cjs +3 -3
- package/dist/internal/api.d.cts +3 -2
- package/dist/internal/api.d.ts +3 -2
- package/dist/internal/api.js +2 -2
- package/dist/lib/build/esbuild.cjs +4 -4
- package/dist/lib/build/esbuild.d.cts +2 -1
- package/dist/lib/build/esbuild.d.ts +2 -1
- package/dist/lib/build/esbuild.js +1 -1
- package/dist/lib/build/index.cjs +25 -25
- package/dist/lib/build/index.d.cts +3 -2
- package/dist/lib/build/index.d.ts +3 -2
- package/dist/lib/build/index.js +9 -9
- package/dist/lib/build/rolldown.cjs +3 -3
- package/dist/lib/build/rolldown.d.cts +2 -1
- package/dist/lib/build/rolldown.d.ts +2 -1
- package/dist/lib/build/rolldown.js +2 -2
- package/dist/lib/build/rollup.cjs +3 -3
- package/dist/lib/build/rollup.d.cts +2 -1
- package/dist/lib/build/rollup.d.ts +2 -1
- package/dist/lib/build/rollup.js +1 -1
- package/dist/lib/build/rspack.cjs +2 -2
- package/dist/lib/build/rspack.d.cts +2 -1
- package/dist/lib/build/rspack.d.ts +2 -1
- package/dist/lib/build/rspack.js +1 -1
- package/dist/lib/build/tsup.cjs +5 -5
- package/dist/lib/build/tsup.d.cts +2 -1
- package/dist/lib/build/tsup.d.ts +2 -1
- package/dist/lib/build/tsup.js +2 -2
- package/dist/lib/build/unbuild.cjs +6 -6
- package/dist/lib/build/unbuild.d.cts +3 -2
- package/dist/lib/build/unbuild.d.ts +3 -2
- package/dist/lib/build/unbuild.js +3 -3
- package/dist/lib/build/vite.cjs +4 -4
- package/dist/lib/build/vite.d.cts +2 -1
- package/dist/lib/build/vite.d.ts +2 -1
- package/dist/lib/build/vite.js +2 -2
- package/dist/lib/build/webpack.cjs +2 -2
- package/dist/lib/build/webpack.d.cts +2 -1
- package/dist/lib/build/webpack.d.ts +2 -1
- package/dist/lib/build/webpack.js +1 -1
- package/dist/lib/{chunk-7CZ2QZEV.js → chunk-3I2YOM2E.js} +4 -4
- package/dist/lib/chunk-3I2YOM2E.js.map +1 -0
- package/dist/lib/{chunk-KAOWUIFH.cjs → chunk-4XUVP2LL.cjs} +3 -3
- package/dist/lib/chunk-4XUVP2LL.cjs.map +1 -0
- package/dist/lib/{chunk-ZKYZWEHY.cjs → chunk-6U2UX2PX.cjs} +4 -4
- package/dist/lib/chunk-6U2UX2PX.cjs.map +1 -0
- package/dist/lib/{chunk-VRNWPH35.cjs → chunk-7EAV6Q7B.cjs} +10 -9
- package/dist/lib/chunk-7EAV6Q7B.cjs.map +1 -0
- package/dist/lib/{chunk-ZYBUJ2HE.js → chunk-CAPN4FSS.js} +7 -7
- package/dist/lib/chunk-CAPN4FSS.js.map +1 -0
- package/dist/lib/{chunk-LTBRHAQ2.cjs → chunk-GJNFAFKR.cjs} +4 -4
- package/dist/lib/chunk-GJNFAFKR.cjs.map +1 -0
- package/dist/lib/{chunk-VANFTXBT.cjs → chunk-GWYTWFZE.cjs} +7 -7
- package/dist/lib/chunk-GWYTWFZE.cjs.map +1 -0
- package/dist/lib/{chunk-DKE25WTL.js → chunk-HQ6TGY34.js} +2 -2
- package/dist/lib/chunk-HQ6TGY34.js.map +1 -0
- package/dist/lib/{chunk-QSBORJCS.js → chunk-HZDOJWUO.js} +6 -6
- package/dist/lib/chunk-HZDOJWUO.js.map +1 -0
- package/dist/lib/{chunk-ECJPGNXE.cjs → chunk-IK3ABDPP.cjs} +2 -2
- package/dist/lib/chunk-IK3ABDPP.cjs.map +1 -0
- package/dist/lib/{chunk-G5DJO4HA.cjs → chunk-JTUL3477.cjs} +5 -5
- package/dist/lib/chunk-JTUL3477.cjs.map +1 -0
- package/dist/lib/{chunk-E7UTFXPP.js → chunk-KFE2IR3Y.js} +4 -4
- package/dist/lib/chunk-KFE2IR3Y.js.map +1 -0
- package/dist/lib/{chunk-RY67J24J.js → chunk-KSBESEOF.js} +2 -2
- package/dist/lib/chunk-KSBESEOF.js.map +1 -0
- package/dist/lib/{chunk-26W3IQT6.js → chunk-LTVWU4J2.js} +5 -5
- package/dist/lib/chunk-LTVWU4J2.js.map +1 -0
- package/dist/lib/{chunk-GWAVDFOE.js → chunk-M7U5RMK7.js} +8 -6
- package/dist/lib/chunk-M7U5RMK7.js.map +1 -0
- package/dist/lib/{chunk-YQG6JE5R.cjs → chunk-M7WHFUKR.cjs} +549 -527
- package/dist/lib/chunk-M7WHFUKR.cjs.map +1 -0
- package/dist/lib/{chunk-EOO7IRCI.js → chunk-MAHHHINV.js} +3 -3
- package/dist/lib/chunk-MAHHHINV.js.map +1 -0
- package/dist/lib/{chunk-7FQQFIHR.cjs → chunk-NANLYIUO.cjs} +4 -4
- package/dist/lib/chunk-NANLYIUO.cjs.map +1 -0
- package/dist/lib/{chunk-TNCZYSNV.js → chunk-NE46WXNJ.js} +2 -2
- package/dist/lib/chunk-NE46WXNJ.js.map +1 -0
- package/dist/lib/{chunk-QGJVGFY4.js → chunk-OF5IJ4WG.js} +6 -6
- package/dist/lib/chunk-OF5IJ4WG.js.map +1 -0
- package/dist/lib/{chunk-6IEUZ5DZ.js → chunk-PIFE7MUZ.js} +525 -503
- package/dist/lib/chunk-PIFE7MUZ.js.map +1 -0
- package/dist/lib/{chunk-2ZYHO243.js → chunk-PXSRMP4E.js} +2 -2
- package/dist/lib/chunk-PXSRMP4E.js.map +1 -0
- package/dist/lib/{chunk-CXYZENE4.js → chunk-Q2L3FNJO.js} +13 -7
- package/dist/lib/chunk-Q2L3FNJO.js.map +1 -0
- package/dist/lib/{chunk-XFIGAAKN.cjs → chunk-Q2RUDKWY.cjs} +8 -6
- package/dist/lib/chunk-Q2RUDKWY.cjs.map +1 -0
- package/dist/lib/{chunk-NFDRIBCM.js → chunk-Q3KJZ3B5.js} +5 -7
- package/dist/lib/chunk-Q3KJZ3B5.js.map +1 -0
- package/dist/lib/{chunk-FHZJQZOE.cjs → chunk-QXJHCA3E.cjs} +7 -7
- package/dist/lib/chunk-QXJHCA3E.cjs.map +1 -0
- package/dist/lib/{chunk-TZFBE35T.cjs → chunk-RQICHHZM.cjs} +2 -2
- package/dist/lib/chunk-RQICHHZM.cjs.map +1 -0
- package/dist/lib/{chunk-7MXG5EG2.js → chunk-RXQWNSZX.js} +3 -3
- package/dist/lib/chunk-RXQWNSZX.js.map +1 -0
- package/dist/lib/{chunk-I6A564OE.cjs → chunk-U36VZLW6.cjs} +2 -2
- package/dist/lib/chunk-U36VZLW6.cjs.map +1 -0
- package/dist/lib/{chunk-65DUUIIF.cjs → chunk-UQJWVRRE.cjs} +2 -2
- package/dist/lib/chunk-UQJWVRRE.cjs.map +1 -0
- package/dist/lib/{chunk-XHCRXNQ3.cjs → chunk-V5OY4ALI.cjs} +5 -5
- package/dist/lib/chunk-V5OY4ALI.cjs.map +1 -0
- package/dist/lib/{chunk-I3I4BYJ4.js → chunk-VJN72T2O.js} +5 -5
- package/dist/lib/chunk-VJN72T2O.js.map +1 -0
- package/dist/lib/{chunk-KACTPBW2.cjs → chunk-W4OMKQ7W.cjs} +14 -8
- package/dist/lib/chunk-W4OMKQ7W.cjs.map +1 -0
- package/dist/lib/{chunk-SB3NFYXT.cjs → chunk-XZD7S5TU.cjs} +5 -5
- package/dist/lib/chunk-XZD7S5TU.cjs.map +1 -0
- package/dist/lib/{chunk-PJKWY74P.js → chunk-YBIWVB66.js} +10 -9
- package/dist/lib/chunk-YBIWVB66.js.map +1 -0
- package/dist/lib/{chunk-JXIRUV56.js → chunk-YF3YHK4X.js} +5 -5
- package/dist/lib/chunk-YF3YHK4X.js.map +1 -0
- package/dist/lib/{chunk-TJQEGHJA.cjs → chunk-YVDJCVE5.cjs} +12 -12
- package/dist/lib/chunk-YVDJCVE5.cjs.map +1 -0
- package/dist/lib/{chunk-M2TB43VG.cjs → chunk-ZP7PDTVE.cjs} +7 -9
- package/dist/lib/chunk-ZP7PDTVE.cjs.map +1 -0
- package/dist/lib/{config-BOPIY57U.d.cts → config-AuIGsUck.d.cts} +110 -106
- package/dist/lib/{config-Chd_3Uh3.d.ts → config-B_WTwd49.d.ts} +110 -106
- package/dist/lib/config-file.d.cts +2 -1
- package/dist/lib/config-file.d.ts +2 -1
- package/dist/lib/entry.d.cts +2 -1
- package/dist/lib/entry.d.ts +2 -1
- package/dist/lib/{hooks-DkVRKYVN.d.cts → hooks-4KkL9GD2.d.cts} +1 -1
- package/dist/lib/{hooks-56fQP2HY.d.ts → hooks-DErK4Fv4.d.ts} +1 -1
- package/dist/lib/index.cjs +36 -36
- package/dist/lib/index.d.cts +3 -2
- package/dist/lib/index.d.ts +3 -2
- package/dist/lib/index.js +11 -11
- package/dist/lib/logger.d.cts +2 -1
- package/dist/lib/logger.d.ts +2 -1
- package/dist/lib/typescript/compiler-host.cjs +6 -6
- package/dist/lib/typescript/compiler-host.cjs.map +1 -1
- package/dist/lib/typescript/compiler-host.d.cts +2 -1
- package/dist/lib/typescript/compiler-host.d.ts +2 -1
- package/dist/lib/typescript/compiler-host.js +5 -5
- package/dist/lib/typescript/compiler-host.js.map +1 -1
- package/dist/lib/typescript/import-transformer.cjs +1 -1
- package/dist/lib/typescript/import-transformer.cjs.map +1 -1
- package/dist/lib/typescript/import-transformer.d.cts +2 -1
- package/dist/lib/typescript/import-transformer.d.ts +2 -1
- package/dist/lib/typescript/import-transformer.js +1 -1
- package/dist/lib/typescript/import-transformer.js.map +1 -1
- package/dist/lib/typescript/index.cjs +6 -6
- package/dist/lib/typescript/index.d.cts +2 -1
- package/dist/lib/typescript/index.d.ts +2 -1
- package/dist/lib/typescript/index.js +1 -1
- package/dist/lib/typescript/program.cjs +6 -6
- package/dist/lib/typescript/program.d.cts +2 -1
- package/dist/lib/typescript/program.d.ts +2 -1
- package/dist/lib/typescript/program.js +1 -1
- package/dist/lib/unplugin/factory.cjs +6 -6
- package/dist/lib/unplugin/factory.d.cts +3 -2
- package/dist/lib/unplugin/factory.d.ts +3 -2
- package/dist/lib/unplugin/factory.js +5 -5
- package/dist/lib/unplugin/index.cjs +9 -9
- package/dist/lib/unplugin/index.d.cts +3 -2
- package/dist/lib/unplugin/index.d.ts +3 -2
- package/dist/lib/unplugin/index.js +6 -6
- package/dist/lib/unplugin/plugin.cjs +4 -4
- package/dist/lib/unplugin/plugin.d.cts +2 -1
- package/dist/lib/unplugin/plugin.d.ts +2 -1
- package/dist/lib/unplugin/plugin.js +3 -3
- package/dist/lib/unplugin/resolve-id.cjs +2 -2
- package/dist/lib/unplugin/resolve-id.d.cts +2 -1
- package/dist/lib/unplugin/resolve-id.d.ts +2 -1
- package/dist/lib/unplugin/resolve-id.js +1 -1
- package/dist/lib/utilities/cache.cjs +4 -4
- package/dist/lib/utilities/cache.js +2 -2
- package/dist/lib/utilities/file-header.d.cts +2 -1
- package/dist/lib/utilities/file-header.d.ts +2 -1
- package/dist/lib/utilities/index.cjs +24 -24
- package/dist/lib/utilities/index.d.cts +2 -1
- package/dist/lib/utilities/index.d.ts +2 -1
- package/dist/lib/utilities/index.js +7 -7
- package/dist/lib/utilities/meta.cjs +8 -8
- package/dist/lib/utilities/meta.d.cts +2 -1
- package/dist/lib/utilities/meta.d.ts +2 -1
- package/dist/lib/utilities/meta.js +1 -1
- package/dist/lib/utilities/plugin-helpers.d.cts +2 -1
- package/dist/lib/utilities/plugin-helpers.d.ts +2 -1
- package/dist/lib/utilities/resolve-path.cjs +2 -2
- package/dist/lib/utilities/resolve-path.d.cts +2 -1
- package/dist/lib/utilities/resolve-path.d.ts +2 -1
- package/dist/lib/utilities/resolve-path.js +1 -1
- package/dist/lib/utilities/source-file.cjs +4 -4
- package/dist/lib/utilities/source-file.js +1 -1
- package/dist/lib/utilities/source-map.cjs +2 -2
- package/dist/lib/utilities/source-map.js +1 -1
- package/dist/lib/utilities/worker.cjs +3 -3
- package/dist/lib/utilities/worker.d.cts +2 -1
- package/dist/lib/utilities/worker.d.ts +2 -1
- package/dist/lib/utilities/worker.js +1 -1
- package/dist/lib/utilities/write-file.cjs +2 -2
- package/dist/lib/utilities/write-file.d.cts +2 -1
- package/dist/lib/utilities/write-file.d.ts +2 -1
- package/dist/lib/utilities/write-file.js +1 -1
- package/dist/next.cjs +8 -8
- package/dist/next.js +5 -5
- package/dist/nuxt.cjs +10 -10
- package/dist/nuxt.js +7 -7
- package/dist/{resolved-NZTd64-O.d.cts → resolved-CcuVqMqc.d.cts} +28 -3
- package/dist/{resolved-DhHHMnUD.d.ts → resolved-Dhscmo3z.d.ts} +28 -3
- package/dist/rolldown.cjs +7 -7
- package/dist/rolldown.d.cts +2 -1
- package/dist/rolldown.d.ts +2 -1
- package/dist/rolldown.js +4 -4
- package/dist/rollup.cjs +7 -7
- package/dist/rollup.d.cts +2 -1
- package/dist/rollup.d.ts +2 -1
- package/dist/rollup.js +4 -4
- package/dist/rspack.cjs +7 -7
- package/dist/rspack.d.cts +2 -1
- package/dist/rspack.d.ts +2 -1
- package/dist/rspack.js +4 -4
- package/dist/tsup.cjs +9 -9
- package/dist/tsup.js +6 -6
- package/dist/types/babel.d.cts +2 -1
- package/dist/types/babel.d.ts +2 -1
- package/dist/types/commands.d.cts +2 -1
- package/dist/types/commands.d.ts +2 -1
- package/dist/types/compiler.d.cts +2 -1
- package/dist/types/compiler.d.ts +2 -1
- package/dist/types/config.d.cts +2 -1
- package/dist/types/config.d.ts +2 -1
- package/dist/types/context.cjs +2 -2
- package/dist/types/context.d.cts +2 -1
- package/dist/types/context.d.ts +2 -1
- package/dist/types/context.js +1 -1
- package/dist/types/hooks.d.cts +2 -1
- package/dist/types/hooks.d.ts +2 -1
- package/dist/types/index.cjs +9 -9
- package/dist/types/index.d.cts +3 -2
- package/dist/types/index.d.ts +3 -2
- package/dist/types/index.js +2 -2
- package/dist/types/internal.d.cts +3 -2
- package/dist/types/internal.d.ts +3 -2
- package/dist/types/plugin.d.cts +2 -1
- package/dist/types/plugin.d.ts +2 -1
- package/dist/types/resolved.d.cts +2 -1
- package/dist/types/resolved.d.ts +2 -1
- package/dist/types/unplugin.d.cts +2 -1
- package/dist/types/unplugin.d.ts +2 -1
- package/dist/types/vfs.cjs +7 -7
- package/dist/types/vfs.d.cts +93 -111
- package/dist/types/vfs.d.ts +93 -111
- package/dist/types/vfs.js +1 -1
- package/dist/unloader.cjs +7 -7
- package/dist/unloader.d.cts +2 -1
- package/dist/unloader.d.ts +2 -1
- package/dist/unloader.js +4 -4
- package/dist/unplugin.cjs +19 -19
- package/dist/unplugin.d.cts +3 -2
- package/dist/unplugin.d.ts +3 -2
- package/dist/unplugin.js +16 -16
- package/dist/vite.cjs +8 -8
- package/dist/vite.d.cts +2 -1
- package/dist/vite.d.ts +2 -1
- package/dist/vite.js +5 -5
- package/dist/webpack.cjs +7 -7
- package/dist/webpack.d.cts +2 -1
- package/dist/webpack.d.ts +2 -1
- package/dist/webpack.js +4 -4
- package/package.json +9 -9
- package/dist/chunk-4JUWHOFJ.cjs +0 -12
- package/dist/chunk-ARHKVB3S.cjs +0 -12
- package/dist/chunk-JCXSBKRJ.js +0 -31
- package/dist/chunk-NRMXL6VA.cjs +0 -34
- package/dist/chunk-QKXJRYA5.cjs +0 -12
- package/dist/chunk-STLRGAW6.cjs +0 -24
- package/dist/chunk-TJIHTRP5.cjs +0 -12
- package/dist/chunk-VES34CLG.cjs +0 -12
- package/dist/lib/chunk-26W3IQT6.js.map +0 -1
- package/dist/lib/chunk-2ZYHO243.js.map +0 -1
- package/dist/lib/chunk-65DUUIIF.cjs.map +0 -1
- package/dist/lib/chunk-6IEUZ5DZ.js.map +0 -1
- package/dist/lib/chunk-7CZ2QZEV.js.map +0 -1
- package/dist/lib/chunk-7FQQFIHR.cjs.map +0 -1
- package/dist/lib/chunk-7MXG5EG2.js.map +0 -1
- package/dist/lib/chunk-CXYZENE4.js.map +0 -1
- package/dist/lib/chunk-DKE25WTL.js.map +0 -1
- package/dist/lib/chunk-E7UTFXPP.js.map +0 -1
- package/dist/lib/chunk-ECJPGNXE.cjs.map +0 -1
- package/dist/lib/chunk-EOO7IRCI.js.map +0 -1
- package/dist/lib/chunk-FHZJQZOE.cjs.map +0 -1
- package/dist/lib/chunk-G5DJO4HA.cjs.map +0 -1
- package/dist/lib/chunk-GWAVDFOE.js.map +0 -1
- package/dist/lib/chunk-I3I4BYJ4.js.map +0 -1
- package/dist/lib/chunk-I6A564OE.cjs.map +0 -1
- package/dist/lib/chunk-JXIRUV56.js.map +0 -1
- package/dist/lib/chunk-KACTPBW2.cjs.map +0 -1
- package/dist/lib/chunk-KAOWUIFH.cjs.map +0 -1
- package/dist/lib/chunk-LTBRHAQ2.cjs.map +0 -1
- package/dist/lib/chunk-M2TB43VG.cjs.map +0 -1
- package/dist/lib/chunk-NFDRIBCM.js.map +0 -1
- package/dist/lib/chunk-PJKWY74P.js.map +0 -1
- package/dist/lib/chunk-QGJVGFY4.js.map +0 -1
- package/dist/lib/chunk-QSBORJCS.js.map +0 -1
- package/dist/lib/chunk-RY67J24J.js.map +0 -1
- package/dist/lib/chunk-SB3NFYXT.cjs.map +0 -1
- package/dist/lib/chunk-TJQEGHJA.cjs.map +0 -1
- package/dist/lib/chunk-TNCZYSNV.js.map +0 -1
- package/dist/lib/chunk-TZFBE35T.cjs.map +0 -1
- package/dist/lib/chunk-VANFTXBT.cjs.map +0 -1
- package/dist/lib/chunk-VRNWPH35.cjs.map +0 -1
- package/dist/lib/chunk-XFIGAAKN.cjs.map +0 -1
- package/dist/lib/chunk-XHCRXNQ3.cjs.map +0 -1
- package/dist/lib/chunk-YQG6JE5R.cjs.map +0 -1
- package/dist/lib/chunk-ZKYZWEHY.cjs.map +0 -1
- package/dist/lib/chunk-ZYBUJ2HE.js.map +0 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { writeFile } from './chunk-
|
|
1
|
+
import { writeFile } from './chunk-HQ6TGY34.js';
|
|
2
2
|
import { getFileHeader } from './chunk-7R23HVGQ.js';
|
|
3
|
-
import { __VFS_CACHE__, __VFS_RESOLVER__, __VFS_VIRTUAL__, __VFS_UNIFIED__, __VFS_INIT__, __VFS_REVERT__, CACHE_HASH_LENGTH, PROJECT_ROOT_HASH_LENGTH, getPrefixedProjectRootHash, getChecksum, writeMetaFile } from './chunk-
|
|
3
|
+
import { __VFS_CACHE__, __VFS_RESOLVER__, __VFS_VIRTUAL__, __VFS_UNIFIED__, __VFS_INIT__, __VFS_REVERT__, CACHE_HASH_LENGTH, PROJECT_ROOT_HASH_LENGTH, getPrefixedProjectRootHash, getChecksum, writeMetaFile } from './chunk-M7U5RMK7.js';
|
|
4
4
|
import { isPlugin, checkDedupe, isPluginHook, isHookExternal, addPluginHook, getHookHandler, isPluginConfig, isPluginConfigTuple, isPluginConfigObject } from './chunk-UGRFAVAJ.js';
|
|
5
|
-
import { handleResolveId } from './chunk-
|
|
5
|
+
import { handleResolveId } from './chunk-YBIWVB66.js';
|
|
6
6
|
import { getParsedTypeScriptConfig, getTsconfigFilePath, isIncludeMatchFound } from './chunk-OO4BIM7N.js';
|
|
7
7
|
import { loadWorkspaceConfig, loadUserConfigFile } from './chunk-56LQSSQ3.js';
|
|
8
8
|
import { extendLog, createLog } from './chunk-35EO5Y7R.js';
|
|
9
|
-
import { getSourceFile, getString } from './chunk-
|
|
9
|
+
import { getSourceFile, getString } from './chunk-PXSRMP4E.js';
|
|
10
10
|
import { resolveEntriesSync, getUniqueEntries } from './chunk-STAKGAWR.js';
|
|
11
11
|
import { __name } from './chunk-7QVYU63E.js';
|
|
12
12
|
import { LogLevelLabel } from '@storm-software/config-tools/types';
|
|
@@ -20,8 +20,6 @@ import { createDirectory } from '@stryke/fs/helpers';
|
|
|
20
20
|
import { install } from '@stryke/fs/install';
|
|
21
21
|
import { listFiles } from '@stryke/fs/list-files';
|
|
22
22
|
import { isPackageExists, isPackageListed, doesPackageMatch, getPackageListing } from '@stryke/fs/package-fns';
|
|
23
|
-
import { findFilePath, hasFileExtension, findFileExtensionSafe, relativePath, findFileName } from '@stryke/path/file-path-fns';
|
|
24
|
-
import { isParentPath } from '@stryke/path/is-parent-path';
|
|
25
23
|
import { joinPaths } from '@stryke/path/join-paths';
|
|
26
24
|
import { replacePath } from '@stryke/path/replace';
|
|
27
25
|
import { isError } from '@stryke/type-checks/is-error';
|
|
@@ -42,6 +40,8 @@ import { murmurhash } from '@stryke/hash/murmurhash';
|
|
|
42
40
|
import { getUnique } from '@stryke/helpers/get-unique';
|
|
43
41
|
import { omit } from '@stryke/helpers/omit';
|
|
44
42
|
import { appendPath } from '@stryke/path/append';
|
|
43
|
+
import { findFilePath, findFileExtensionSafe, hasFileExtension, relativePath, findFileName } from '@stryke/path/file-path-fns';
|
|
44
|
+
import { isAbsolutePath, isAbsolute } from '@stryke/path/is-type';
|
|
45
45
|
import { joinPaths as joinPaths$1 } from '@stryke/path/join';
|
|
46
46
|
import { isNull } from '@stryke/type-checks/is-null';
|
|
47
47
|
import { isString } from '@stryke/type-checks/is-string';
|
|
@@ -49,13 +49,14 @@ import { uuid } from '@stryke/unique-id/uuid';
|
|
|
49
49
|
import { parseAsync } from 'oxc-parser';
|
|
50
50
|
import { createJiti } from 'jiti';
|
|
51
51
|
import { bufferToString } from '@stryke/convert/buffer-to-string';
|
|
52
|
-
import {
|
|
52
|
+
import { isParentPath } from '@stryke/path/is-parent-path';
|
|
53
53
|
import { prettyBytes } from '@stryke/string-format/pretty-bytes';
|
|
54
54
|
import { isBuffer } from '@stryke/type-checks/is-buffer';
|
|
55
|
+
import { isUndefined } from '@stryke/type-checks/is-undefined';
|
|
55
56
|
import { Volume } from 'memfs';
|
|
56
57
|
import { Blob } from 'node:buffer';
|
|
57
58
|
import fs from 'node:fs';
|
|
58
|
-
import {
|
|
59
|
+
import { resolveConfig, format } from 'prettier';
|
|
59
60
|
import { Union } from 'unionfs';
|
|
60
61
|
import { isObject } from '@stryke/type-checks/is-object';
|
|
61
62
|
import { transformAsync } from '@babel/core';
|
|
@@ -132,6 +133,154 @@ function createResolver(options) {
|
|
|
132
133
|
return baseResolver;
|
|
133
134
|
}
|
|
134
135
|
__name(createResolver, "createResolver");
|
|
136
|
+
function isBufferEncoding(options) {
|
|
137
|
+
return isSetString(options) || options === null;
|
|
138
|
+
}
|
|
139
|
+
__name(isBufferEncoding, "isBufferEncoding");
|
|
140
|
+
function isPowerlinesWriteFileOptions(options) {
|
|
141
|
+
return !isBufferEncoding(options) && isSetObject(options) && ("skipFormat" in options || "mode" in options && (options.mode === "fs" || options.mode === "virtual"));
|
|
142
|
+
}
|
|
143
|
+
__name(isPowerlinesWriteFileOptions, "isPowerlinesWriteFileOptions");
|
|
144
|
+
function isNodeWriteFileOptions(options) {
|
|
145
|
+
return !isUndefined(options) && (isBufferEncoding(options) || !isPowerlinesWriteFileOptions(options));
|
|
146
|
+
}
|
|
147
|
+
__name(isNodeWriteFileOptions, "isNodeWriteFileOptions");
|
|
148
|
+
function isPowerLinesWriteFileData(data) {
|
|
149
|
+
return !!(isSetObject(data) && "code" in data && data.code);
|
|
150
|
+
}
|
|
151
|
+
__name(isPowerLinesWriteFileData, "isPowerLinesWriteFileData");
|
|
152
|
+
var FILE_PREFIX = "file://";
|
|
153
|
+
function toFilePath(pathOrUrl) {
|
|
154
|
+
if (!pathOrUrl) {
|
|
155
|
+
throw new Error("No Path or URL provided to Virtual File System");
|
|
156
|
+
}
|
|
157
|
+
let result = pathOrUrl.toString();
|
|
158
|
+
if (result.startsWith(FILE_PREFIX)) {
|
|
159
|
+
result = result.slice(FILE_PREFIX.length);
|
|
160
|
+
}
|
|
161
|
+
return result;
|
|
162
|
+
}
|
|
163
|
+
__name(toFilePath, "toFilePath");
|
|
164
|
+
var FS_METHODS = [
|
|
165
|
+
"mkdir",
|
|
166
|
+
"mkdirSync",
|
|
167
|
+
"rmdir",
|
|
168
|
+
"rmdirSync",
|
|
169
|
+
"unlink",
|
|
170
|
+
"unlinkSync",
|
|
171
|
+
"existsSync",
|
|
172
|
+
"realpathSync",
|
|
173
|
+
"writeFileSync",
|
|
174
|
+
"readFileSync",
|
|
175
|
+
"readdirSync",
|
|
176
|
+
"createWriteStream",
|
|
177
|
+
"WriteStream",
|
|
178
|
+
"createReadStream",
|
|
179
|
+
"ReadStream"
|
|
180
|
+
];
|
|
181
|
+
var FS_PROMISE_METHODS = [
|
|
182
|
+
"mkdir",
|
|
183
|
+
"rm",
|
|
184
|
+
"rmdir",
|
|
185
|
+
"unlink",
|
|
186
|
+
"writeFile",
|
|
187
|
+
"readFile",
|
|
188
|
+
"readdir",
|
|
189
|
+
"stat",
|
|
190
|
+
"lstat"
|
|
191
|
+
];
|
|
192
|
+
function cloneFS(originalFS) {
|
|
193
|
+
const clonedFS = {
|
|
194
|
+
...originalFS,
|
|
195
|
+
promises: {
|
|
196
|
+
...originalFS.promises ?? {}
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
for (const method of FS_METHODS) {
|
|
200
|
+
if (originalFS[method]) {
|
|
201
|
+
clonedFS[method] = originalFS[method];
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
originalFS.promises ??= {};
|
|
205
|
+
for (const method of FS_PROMISE_METHODS) {
|
|
206
|
+
if (originalFS.promises[method]) {
|
|
207
|
+
clonedFS.promises ??= {};
|
|
208
|
+
clonedFS.promises[method] = originalFS.promises[method];
|
|
209
|
+
clonedFS[method] = originalFS.promises[method];
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
for (const prop in clonedFS) {
|
|
213
|
+
if (isFunction(clonedFS[prop])) {
|
|
214
|
+
clonedFS[prop] = clonedFS[prop].bind(originalFS);
|
|
215
|
+
if (isFunction(clonedFS.promises[prop])) {
|
|
216
|
+
clonedFS.promises[prop] = clonedFS.promises[prop].bind(originalFS);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
for (const prop in clonedFS.promises) {
|
|
221
|
+
if (isFunction(clonedFS.promises[prop])) {
|
|
222
|
+
clonedFS.promises[prop] = clonedFS.promises[prop].bind(originalFS);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
return clonedFS;
|
|
226
|
+
}
|
|
227
|
+
__name(cloneFS, "cloneFS");
|
|
228
|
+
function patchFS(originalFS, vfs) {
|
|
229
|
+
const clonedFS = cloneFS(originalFS);
|
|
230
|
+
originalFS.mkdirSync = (file, options) => vfs.mkdirSync(toFilePath(file), options);
|
|
231
|
+
originalFS.mkdir = (file, options, callback) => vfs.mkdir(toFilePath(file), options, callback);
|
|
232
|
+
originalFS.promises.mkdir = async (file, options) => vfs.mkdir(toFilePath(file), options);
|
|
233
|
+
originalFS.unlinkSync = (file) => vfs.unlinkSync(toFilePath(file));
|
|
234
|
+
originalFS.promises.rm = async (file, options) => vfs.rm(toFilePath(file), options);
|
|
235
|
+
originalFS.promises.unlink = async (file) => vfs.unlink(toFilePath(file));
|
|
236
|
+
originalFS.existsSync = (file) => vfs.existsSync(toFilePath(file));
|
|
237
|
+
Object.defineProperty(originalFS, "realpathSync", {
|
|
238
|
+
value: /* @__PURE__ */ __name((file, options) => vfs.realpathSync(toFilePath(file), options), "value")
|
|
239
|
+
});
|
|
240
|
+
originalFS.writeFileSync = (file, data, options) => vfs.writeFileSync(toFilePath(file), data, options);
|
|
241
|
+
originalFS.promises.writeFile = async (file, data, options) => vfs.writeFile(toFilePath(file), data, options);
|
|
242
|
+
originalFS.readFileSync = (file, options) => vfs.readFileSync(toFilePath(file), options);
|
|
243
|
+
originalFS.promises.readFile = (file, options) => vfs.readFile(toFilePath(file), options);
|
|
244
|
+
originalFS.readdirSync = (file, options) => vfs.readdirSync(toFilePath(file), options);
|
|
245
|
+
originalFS.promises.readdir = (file, options) => vfs.readdir(toFilePath(file), options);
|
|
246
|
+
Object.defineProperty(originalFS, "statSync", {
|
|
247
|
+
value: /* @__PURE__ */ __name((file, options) => vfs.statSync(toFilePath(file), options), "value")
|
|
248
|
+
});
|
|
249
|
+
originalFS.stat = (file, options) => vfs.statSync(toFilePath(file), options);
|
|
250
|
+
originalFS.promises.stat = (file, options) => vfs.stat(toFilePath(file), options);
|
|
251
|
+
Object.defineProperty(originalFS, "lstatSync", {
|
|
252
|
+
value: /* @__PURE__ */ __name((file, options) => vfs.lstatSync(toFilePath(file), options), "value")
|
|
253
|
+
});
|
|
254
|
+
originalFS.lstat = (file, options) => vfs.lstatSync(toFilePath(file), options);
|
|
255
|
+
originalFS.promises.lstat = (file, options) => vfs.lstat(toFilePath(file), options);
|
|
256
|
+
return () => {
|
|
257
|
+
originalFS.mkdirSync = clonedFS.mkdirSync;
|
|
258
|
+
originalFS.mkdir = clonedFS.mkdir;
|
|
259
|
+
originalFS.promises.mkdir = clonedFS.promises.mkdir;
|
|
260
|
+
originalFS.unlinkSync = clonedFS.unlinkSync;
|
|
261
|
+
originalFS.promises.rm = clonedFS.promises.rm;
|
|
262
|
+
originalFS.promises.unlink = clonedFS.promises.unlink;
|
|
263
|
+
originalFS.existsSync = clonedFS.existsSync;
|
|
264
|
+
originalFS.realpathSync = clonedFS.realpathSync;
|
|
265
|
+
originalFS.writeFileSync = clonedFS.writeFileSync;
|
|
266
|
+
originalFS.promises.writeFile = clonedFS.promises.writeFile;
|
|
267
|
+
originalFS.readFileSync = clonedFS.readFileSync;
|
|
268
|
+
originalFS.promises.readFile = clonedFS.promises.readFile;
|
|
269
|
+
originalFS.readdirSync = clonedFS.readdirSync;
|
|
270
|
+
originalFS.promises.readdir = clonedFS.promises.readdir;
|
|
271
|
+
Object.defineProperty(originalFS, "statSync", {
|
|
272
|
+
value: clonedFS.statSync
|
|
273
|
+
});
|
|
274
|
+
originalFS.stat = clonedFS.stat;
|
|
275
|
+
originalFS.promises.stat = clonedFS.promises.stat;
|
|
276
|
+
Object.defineProperty(originalFS, "lstatSync", {
|
|
277
|
+
value: clonedFS.lstatSync
|
|
278
|
+
});
|
|
279
|
+
originalFS.lstat = clonedFS.lstat;
|
|
280
|
+
originalFS.promises.lstat = clonedFS.promises.lstat;
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
__name(patchFS, "patchFS");
|
|
135
284
|
var VirtualFileSystem = class {
|
|
136
285
|
static {
|
|
137
286
|
__name(this, "VirtualFileSystem");
|
|
@@ -139,7 +288,11 @@ var VirtualFileSystem = class {
|
|
|
139
288
|
/**
|
|
140
289
|
* The internal map of virtual files.
|
|
141
290
|
*/
|
|
142
|
-
#
|
|
291
|
+
#meta = {};
|
|
292
|
+
/**
|
|
293
|
+
* A map of unique identifiers to their virtual file paths.
|
|
294
|
+
*/
|
|
295
|
+
#ids = {};
|
|
143
296
|
/**
|
|
144
297
|
* A map of virtual file paths to their underlying file content.
|
|
145
298
|
*/
|
|
@@ -180,6 +333,16 @@ var VirtualFileSystem = class {
|
|
|
180
333
|
*/
|
|
181
334
|
#log;
|
|
182
335
|
/**
|
|
336
|
+
* Checks if a path exists in the virtual file system (VFS).
|
|
337
|
+
*
|
|
338
|
+
* @param path - The path to check.
|
|
339
|
+
* @returns `true` if the path exists, otherwise `false`.
|
|
340
|
+
*/
|
|
341
|
+
#existsSync(path) {
|
|
342
|
+
const formattedPath = this.formatPath(path);
|
|
343
|
+
return this.#virtualFS.existsSync(formattedPath) || this.#fs.existsSync(formattedPath) || this.resolveFS(path).existsSync(formattedPath);
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
183
346
|
* Exposes the internal VFS map for advanced usage.
|
|
184
347
|
*/
|
|
185
348
|
get [__VFS_CACHE__]() {
|
|
@@ -204,15 +367,54 @@ var VirtualFileSystem = class {
|
|
|
204
367
|
return this.#unifiedFS;
|
|
205
368
|
}
|
|
206
369
|
/**
|
|
370
|
+
* A proxy to access the underlying file metadata.
|
|
371
|
+
*/
|
|
372
|
+
get meta() {
|
|
373
|
+
return new Proxy(this.#meta, {
|
|
374
|
+
get: /* @__PURE__ */ __name((target, prop) => {
|
|
375
|
+
if (target[prop]) {
|
|
376
|
+
return {
|
|
377
|
+
id: prop,
|
|
378
|
+
mode: this.#virtualFS.existsSync(prop) ? "virtual" : this.#fs.existsSync(prop) ? "fs" : this.#context.config.output.mode,
|
|
379
|
+
details: {},
|
|
380
|
+
variant: "normal",
|
|
381
|
+
...target[prop]
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
return void 0;
|
|
385
|
+
}, "get"),
|
|
386
|
+
set: /* @__PURE__ */ __name((target, prop, value) => {
|
|
387
|
+
target[prop] = value;
|
|
388
|
+
this.#ids[value.id || prop] = prop;
|
|
389
|
+
return true;
|
|
390
|
+
}, "set"),
|
|
391
|
+
deleteProperty: /* @__PURE__ */ __name((target, prop) => {
|
|
392
|
+
delete this.#ids[target[prop]?.id || prop];
|
|
393
|
+
delete target[prop];
|
|
394
|
+
return true;
|
|
395
|
+
}, "deleteProperty")
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* A map of module ids to their file paths.
|
|
400
|
+
*/
|
|
401
|
+
get ids() {
|
|
402
|
+
return this.#ids;
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
207
405
|
* Creates a new instance of the VirtualFileSystem.
|
|
208
406
|
*
|
|
209
407
|
* @param context - The context of the virtual file system, typically containing options and logging functions.
|
|
210
408
|
* @param serialized - A map of files/file contents to populate in cache
|
|
211
409
|
*/
|
|
212
|
-
constructor(context, serialized) {
|
|
410
|
+
constructor(context, serialized = {}) {
|
|
213
411
|
this.#context = context;
|
|
214
412
|
this.#cachedFS = /* @__PURE__ */ new Map();
|
|
215
|
-
this.#
|
|
413
|
+
this.#meta = Object.fromEntries(Object.entries(serialized.virtualFilesMeta ?? {}));
|
|
414
|
+
this.#ids = Object.fromEntries(Object.entries(this.#meta).map(([path, data]) => [
|
|
415
|
+
data.id || path,
|
|
416
|
+
path
|
|
417
|
+
]));
|
|
216
418
|
if (!this.#fs.existsSync(this.#context.dataPath)) {
|
|
217
419
|
this.#fs.mkdirSync(this.#context.dataPath, {
|
|
218
420
|
recursive: true
|
|
@@ -294,65 +496,44 @@ var VirtualFileSystem = class {
|
|
|
294
496
|
}
|
|
295
497
|
}
|
|
296
498
|
/**
|
|
297
|
-
*
|
|
499
|
+
* Check if a path or id corresponds to a virtual file **(does not actually exists on disk)**.
|
|
298
500
|
*
|
|
299
|
-
* @
|
|
501
|
+
* @param pathOrId - The path or id to check.
|
|
502
|
+
* @param options - Optional parameters for resolving the path.
|
|
503
|
+
* @returns Whether the path or id corresponds to a virtual file **(does not actually exists on disk)**.
|
|
300
504
|
*/
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
*
|
|
307
|
-
* @returns An array of formatted runtime IDs.
|
|
308
|
-
*/
|
|
309
|
-
get runtimeIds() {
|
|
310
|
-
return Array.from(this.builtinIdMap.keys()).map((id) => this.formatRuntimeId(id));
|
|
311
|
-
}
|
|
312
|
-
/**
|
|
313
|
-
* Checks if a given path or ID corresponds to a runtime file.
|
|
314
|
-
*
|
|
315
|
-
* @param pathOrId - The path or ID to check.
|
|
316
|
-
* @param options - Options for resolving the path, such as paths to check.
|
|
317
|
-
* @returns `true` if the path or ID corresponds to a runtime file, otherwise `false`.
|
|
318
|
-
*/
|
|
319
|
-
isBuiltinFile(pathOrId, options) {
|
|
320
|
-
return !!this.builtinIdMap.values().find((path) => path === this.resolvePath(pathOrId, {
|
|
505
|
+
isVirtual(pathOrId, options = {}) {
|
|
506
|
+
if (!pathOrId) {
|
|
507
|
+
return false;
|
|
508
|
+
}
|
|
509
|
+
const resolvedPath = this.resolve(pathOrId, {
|
|
321
510
|
...options,
|
|
322
511
|
type: "file"
|
|
323
|
-
})
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
* @param id - The ID to check.
|
|
329
|
-
* @returns Whether the ID is a valid runtime ID.
|
|
330
|
-
*/
|
|
331
|
-
isValidBuiltinId(id) {
|
|
332
|
-
return id.startsWith(`${this.#context.config.output.builtinPrefix}:`);
|
|
512
|
+
});
|
|
513
|
+
if (!resolvedPath) {
|
|
514
|
+
return false;
|
|
515
|
+
}
|
|
516
|
+
return this.meta[resolvedPath]?.mode === "virtual";
|
|
333
517
|
}
|
|
334
518
|
/**
|
|
335
|
-
* Check if a path or
|
|
519
|
+
* Check if a path or id corresponds to a file written to the file system **(actually exists on disk)**.
|
|
336
520
|
*
|
|
337
|
-
* @param pathOrId - The path or
|
|
338
|
-
* @param options -
|
|
339
|
-
* @returns Whether the path or
|
|
521
|
+
* @param pathOrId - The path or id to check.
|
|
522
|
+
* @param options - Optional parameters for resolving the path.
|
|
523
|
+
* @returns Whether the path or id corresponds to a file written to the file system **(actually exists on disk)**.
|
|
340
524
|
*/
|
|
341
|
-
|
|
525
|
+
isFs(pathOrId, options = {}) {
|
|
342
526
|
if (!pathOrId) {
|
|
343
527
|
return false;
|
|
344
528
|
}
|
|
345
|
-
const resolvedPath = this.
|
|
529
|
+
const resolvedPath = this.resolve(pathOrId, {
|
|
346
530
|
...options,
|
|
347
531
|
type: "file"
|
|
348
532
|
});
|
|
349
533
|
if (!resolvedPath) {
|
|
350
534
|
return false;
|
|
351
535
|
}
|
|
352
|
-
|
|
353
|
-
return true;
|
|
354
|
-
}
|
|
355
|
-
return this.#virtualFS.existsSync(resolvedPath);
|
|
536
|
+
return this.meta[resolvedPath]?.mode === "fs";
|
|
356
537
|
}
|
|
357
538
|
/**
|
|
358
539
|
* Check if a path exists within one of the directories specified in the tsconfig.json's `path` field.
|
|
@@ -366,37 +547,6 @@ var VirtualFileSystem = class {
|
|
|
366
547
|
return !!this.#context.tsconfig.options.paths && Object.keys(this.#context.tsconfig.options.paths).some((path) => pathOrId.startsWith(path.replaceAll("*", "")));
|
|
367
548
|
}
|
|
368
549
|
/**
|
|
369
|
-
* Checks if a given ID corresponds to a runtime file path.
|
|
370
|
-
*
|
|
371
|
-
* @param id - The unique identifier for the runtime file.
|
|
372
|
-
* @param pathOrId - The path or ID to check.
|
|
373
|
-
* @returns `true` if the ID corresponds to the path or ID of a runtime file, otherwise `false`.
|
|
374
|
-
*/
|
|
375
|
-
isMatchingBuiltinId(id, pathOrId) {
|
|
376
|
-
const resolvedPath = this.resolvePath(pathOrId);
|
|
377
|
-
const resolvedId = this.resolveId(pathOrId);
|
|
378
|
-
return !!(this.isBuiltinFile(pathOrId) && (resolvedPath && (resolvedPath === this.builtinIdMap.get(id) || resolvedPath === this.builtinIdMap.get(this.formatRuntimeId(id))) || resolvedId && (resolvedId === this.builtinIdMap.get(id) || resolvedId === this.builtinIdMap.get(this.formatRuntimeId(id)))));
|
|
379
|
-
}
|
|
380
|
-
/**
|
|
381
|
-
* Lists all runtime files in the virtual file system.
|
|
382
|
-
*
|
|
383
|
-
* @returns A promise that resolves to an array of runtime files.
|
|
384
|
-
*/
|
|
385
|
-
async listBuiltinFiles() {
|
|
386
|
-
const runtimeFiles = [];
|
|
387
|
-
for (const [id, path] of this.builtinIdMap.entries()) {
|
|
388
|
-
const contents = await this.readFile(path);
|
|
389
|
-
if (contents) {
|
|
390
|
-
runtimeFiles.push({
|
|
391
|
-
id: this.formatRuntimeId(id),
|
|
392
|
-
path,
|
|
393
|
-
contents
|
|
394
|
-
});
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
return runtimeFiles;
|
|
398
|
-
}
|
|
399
|
-
/**
|
|
400
550
|
* Lists files in a given path.
|
|
401
551
|
*
|
|
402
552
|
* @param path - The path to list files from.
|
|
@@ -413,7 +563,7 @@ var VirtualFileSystem = class {
|
|
|
413
563
|
*/
|
|
414
564
|
unlinkSync(path, options) {
|
|
415
565
|
const formattedPath = toFilePath(path);
|
|
416
|
-
if (!this.
|
|
566
|
+
if (!this.isFile(formattedPath)) {
|
|
417
567
|
return;
|
|
418
568
|
}
|
|
419
569
|
this.#log(LogLevelLabel.TRACE, `Synchronously removing file: ${formattedPath}`);
|
|
@@ -428,7 +578,7 @@ var VirtualFileSystem = class {
|
|
|
428
578
|
*/
|
|
429
579
|
async unlink(path, options) {
|
|
430
580
|
const formattedPath = toFilePath(path);
|
|
431
|
-
if (!this.
|
|
581
|
+
if (!this.isFile(formattedPath)) {
|
|
432
582
|
return;
|
|
433
583
|
}
|
|
434
584
|
this.#log(LogLevelLabel.TRACE, `Removing file: ${formattedPath}`);
|
|
@@ -448,7 +598,7 @@ var VirtualFileSystem = class {
|
|
|
448
598
|
*/
|
|
449
599
|
rmdirSync(path, options = {}) {
|
|
450
600
|
const formattedPath = toFilePath(path);
|
|
451
|
-
if (!this.
|
|
601
|
+
if (!this.isDirectory(formattedPath)) {
|
|
452
602
|
return;
|
|
453
603
|
}
|
|
454
604
|
this.#log(LogLevelLabel.TRACE, `Synchronously removing directory: ${formattedPath}`);
|
|
@@ -467,7 +617,7 @@ var VirtualFileSystem = class {
|
|
|
467
617
|
*/
|
|
468
618
|
async rmdir(path, options = {}) {
|
|
469
619
|
const formattedPath = toFilePath(path);
|
|
470
|
-
if (!this.
|
|
620
|
+
if (!this.isDirectory(formattedPath)) {
|
|
471
621
|
return;
|
|
472
622
|
}
|
|
473
623
|
this.#log(LogLevelLabel.TRACE, `Removing directory: ${formattedPath}`);
|
|
@@ -494,7 +644,7 @@ var VirtualFileSystem = class {
|
|
|
494
644
|
*/
|
|
495
645
|
async rm(path, options = {}) {
|
|
496
646
|
this.#log(LogLevelLabel.TRACE, `Removing: ${toFilePath(path)}`);
|
|
497
|
-
if (this.
|
|
647
|
+
if (this.isDirectory(path)) {
|
|
498
648
|
return this.rmdir(path, options);
|
|
499
649
|
}
|
|
500
650
|
return this.unlink(path, options);
|
|
@@ -538,12 +688,12 @@ var VirtualFileSystem = class {
|
|
|
538
688
|
/**
|
|
539
689
|
* Lists files in a given path.
|
|
540
690
|
*
|
|
541
|
-
* @param
|
|
691
|
+
* @param pathOrId - The path to list files from.
|
|
542
692
|
* @param options - Options for listing files, such as encoding and recursion.
|
|
543
693
|
* @returns An array of file names in the specified path.
|
|
544
694
|
*/
|
|
545
|
-
async readdir(
|
|
546
|
-
return this.resolveFS(
|
|
695
|
+
async readdir(pathOrId, options = "utf8") {
|
|
696
|
+
return this.resolveFS(pathOrId).promises.readdir(toFilePath(pathOrId), options);
|
|
547
697
|
}
|
|
548
698
|
/**
|
|
549
699
|
* Asynchronously reads a file from the virtual file system (VFS).
|
|
@@ -555,7 +705,7 @@ var VirtualFileSystem = class {
|
|
|
555
705
|
if (!pathOrId) {
|
|
556
706
|
return void 0;
|
|
557
707
|
}
|
|
558
|
-
const filePath = this.
|
|
708
|
+
const filePath = this.resolve(toFilePath(pathOrId), {
|
|
559
709
|
type: "file"
|
|
560
710
|
});
|
|
561
711
|
if (filePath) {
|
|
@@ -584,7 +734,7 @@ var VirtualFileSystem = class {
|
|
|
584
734
|
if (!pathOrId) {
|
|
585
735
|
return void 0;
|
|
586
736
|
}
|
|
587
|
-
const filePath = this.
|
|
737
|
+
const filePath = this.resolve(toFilePath(pathOrId), {
|
|
588
738
|
type: "file"
|
|
589
739
|
});
|
|
590
740
|
if (filePath) {
|
|
@@ -601,137 +751,80 @@ var VirtualFileSystem = class {
|
|
|
601
751
|
/**
|
|
602
752
|
* Writes a file to the virtual file system (VFS).
|
|
603
753
|
*
|
|
604
|
-
* @param
|
|
754
|
+
* @param path - The path to the file.
|
|
605
755
|
* @param data - The contents of the file.
|
|
606
756
|
* @param options - Optional parameters for writing the file.
|
|
607
757
|
* @returns A promise that resolves when the file is written.
|
|
608
758
|
*/
|
|
609
|
-
async writeFile(
|
|
610
|
-
const
|
|
611
|
-
if (!this.
|
|
612
|
-
await this.mkdir(findFilePath(
|
|
759
|
+
async writeFile(path, data = "", options = "utf8") {
|
|
760
|
+
const formattedPath = this.formatPath(path);
|
|
761
|
+
if (!this.isDirectory(findFilePath(formattedPath))) {
|
|
762
|
+
await this.mkdir(findFilePath(formattedPath), isPowerlinesWriteFileOptions(options) ? options : void 0);
|
|
763
|
+
}
|
|
764
|
+
let code = isPowerLinesWriteFileData(data) ? data.code : data;
|
|
765
|
+
if ((!isPowerlinesWriteFileOptions(options) || !options.skipFormat) && isSetString(code)) {
|
|
766
|
+
const resolvedConfig = await resolveConfig(formattedPath);
|
|
767
|
+
if (resolvedConfig) {
|
|
768
|
+
code = await format(code, {
|
|
769
|
+
absolutePath: formattedPath,
|
|
770
|
+
...resolvedConfig
|
|
771
|
+
});
|
|
772
|
+
}
|
|
613
773
|
}
|
|
614
|
-
|
|
615
|
-
this.#
|
|
616
|
-
this.
|
|
617
|
-
|
|
774
|
+
const outputMode = this.resolveOutputMode(formattedPath, isPowerlinesWriteFileOptions(options) ? options : void 0);
|
|
775
|
+
this.#log(LogLevelLabel.TRACE, `Writing ${formattedPath} file to the ${outputMode === "fs" ? "" : "virtual "}file system (size: ${prettyBytes(new Blob(toArray(code)).size)})`);
|
|
776
|
+
this.meta[formattedPath] = {
|
|
777
|
+
path: formattedPath,
|
|
778
|
+
code,
|
|
779
|
+
mode: outputMode,
|
|
780
|
+
variant: "normal",
|
|
781
|
+
...isPowerLinesWriteFileData(data) ? data : {}
|
|
782
|
+
};
|
|
783
|
+
this.clearResolverCache(formattedPath);
|
|
784
|
+
const ifs = this.resolveFS(formattedPath, isPowerlinesWriteFileOptions(options) ? options : void 0);
|
|
618
785
|
if (isFunction(ifs.promises.writeFile)) {
|
|
619
|
-
return ifs.promises.writeFile(
|
|
620
|
-
"mode"
|
|
621
|
-
]));
|
|
786
|
+
return ifs.promises.writeFile(formattedPath, code, isNodeWriteFileOptions(options) ? options : "utf8");
|
|
622
787
|
}
|
|
623
|
-
return ifs.writeFileSync(
|
|
624
|
-
"mode"
|
|
625
|
-
]));
|
|
788
|
+
return ifs.writeFileSync(formattedPath, code, isNodeWriteFileOptions(options) ? options : "utf8");
|
|
626
789
|
}
|
|
627
790
|
/**
|
|
628
791
|
* Synchronously writes a file to the virtual file system (VFS).
|
|
629
792
|
*
|
|
630
|
-
* @param
|
|
793
|
+
* @param path - The file to write.
|
|
631
794
|
* @param data - The contents of the file.
|
|
632
795
|
* @param options - Optional parameters for writing the file.
|
|
633
796
|
*/
|
|
634
|
-
writeFileSync(
|
|
635
|
-
const
|
|
636
|
-
if (!this.
|
|
637
|
-
this.mkdirSync(findFilePath(
|
|
638
|
-
}
|
|
639
|
-
|
|
640
|
-
this
|
|
641
|
-
this.
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
797
|
+
writeFileSync(path, data = "", options = "utf8") {
|
|
798
|
+
const formattedPath = this.formatPath(path);
|
|
799
|
+
if (!this.isDirectory(findFilePath(formattedPath))) {
|
|
800
|
+
this.mkdirSync(findFilePath(formattedPath), isPowerlinesWriteFileOptions(options) ? options : void 0);
|
|
801
|
+
}
|
|
802
|
+
const code = isPowerLinesWriteFileData(data) ? data.code : data;
|
|
803
|
+
const outputMode = this.resolveOutputMode(formattedPath, isPowerlinesWriteFileOptions(options) ? options : void 0);
|
|
804
|
+
this.#log(LogLevelLabel.TRACE, `Writing ${formattedPath} file to the ${outputMode === "fs" ? "" : "virtual "}file system (size: ${prettyBytes(new Blob(toArray(code)).size)})`);
|
|
805
|
+
this.meta[formattedPath] = {
|
|
806
|
+
path: formattedPath,
|
|
807
|
+
code,
|
|
808
|
+
mode: outputMode,
|
|
809
|
+
variant: "normal",
|
|
810
|
+
...isPowerLinesWriteFileData(data) ? data : {}
|
|
811
|
+
};
|
|
812
|
+
this.clearResolverCache(formattedPath);
|
|
813
|
+
const writeStream = this.resolveFS(formattedPath, isPowerlinesWriteFileOptions(options) ? options : void 0).createWriteStream(formattedPath);
|
|
645
814
|
try {
|
|
646
|
-
writeStream.write(
|
|
815
|
+
writeStream.write(code);
|
|
647
816
|
} finally {
|
|
648
817
|
writeStream.close();
|
|
649
818
|
}
|
|
650
819
|
}
|
|
651
820
|
/**
|
|
652
|
-
* Writes a runtime file to the virtual file system (VFS).
|
|
653
|
-
*
|
|
654
|
-
* @param id - The unique identifier for the runtime file.
|
|
655
|
-
* @param path - The path to the runtime file.
|
|
656
|
-
* @param contents - The contents of the runtime file.
|
|
657
|
-
* @param options - Optional parameters for writing the runtime file.
|
|
658
|
-
* @returns A promise that resolves when the file is written.
|
|
659
|
-
*/
|
|
660
|
-
async writeBuiltinFile(id, path, contents, options = {}) {
|
|
661
|
-
const formattedId = this.formatRuntimeId(id);
|
|
662
|
-
const absolutePath = this.formatAbsoluteFilePath(toFilePath(path));
|
|
663
|
-
this.builtinIdMap.set(formattedId, absolutePath);
|
|
664
|
-
let data = contents;
|
|
665
|
-
if (!options.skipFormat) {
|
|
666
|
-
data = await format(contents, {
|
|
667
|
-
absolutePath,
|
|
668
|
-
...await resolveConfig(absolutePath)
|
|
669
|
-
});
|
|
670
|
-
}
|
|
671
|
-
const _options = defu3(isSetString(options) ? {} : options ?? {}, {
|
|
672
|
-
encoding: isSetString(options) ? options : "utf8",
|
|
673
|
-
mode: "virtual"
|
|
674
|
-
});
|
|
675
|
-
this.#log(LogLevelLabel.DEBUG, `Writing runtime file ${absolutePath} (size: ${prettyBytes(new Blob(toArray(data)).size)}) to ${this.resolveOutputMode(absolutePath, _options) === "fs" ? "disk" : "memory"}`);
|
|
676
|
-
return this.writeFile(absolutePath, data, _options);
|
|
677
|
-
}
|
|
678
|
-
/**
|
|
679
|
-
* Adds an entry file to the virtual file system.
|
|
680
|
-
*
|
|
681
|
-
* @param name - The file name or absolute path of the entry module.
|
|
682
|
-
* @param contents - The contents of the entry file.
|
|
683
|
-
* @param options - Optional parameters for writing the entry file.
|
|
684
|
-
*/
|
|
685
|
-
async writeEntryFile(name, contents, options = {}) {
|
|
686
|
-
const absolutePath = this.formatAbsoluteFilePath(isAbsolutePath(toFilePath(name)) ? toFilePath(name) : toFilePath(joinPaths(this.#context.entryPath, name)));
|
|
687
|
-
let data = contents;
|
|
688
|
-
if (!options.skipFormat) {
|
|
689
|
-
data = await format(contents, {
|
|
690
|
-
absolutePath,
|
|
691
|
-
...await resolveConfig(absolutePath)
|
|
692
|
-
});
|
|
693
|
-
}
|
|
694
|
-
const _options = defu3(isSetString(options) ? {} : options ?? {}, {
|
|
695
|
-
encoding: isSetString(options) ? options : "utf8",
|
|
696
|
-
mode: "virtual"
|
|
697
|
-
});
|
|
698
|
-
this.#log(LogLevelLabel.DEBUG, `Writing entry file ${absolutePath} (size: ${prettyBytes(new Blob(toArray(data)).size)}) to ${this.resolveOutputMode(absolutePath, _options) === "fs" ? "disk" : "virtual memory"}`);
|
|
699
|
-
return this.writeFile(absolutePath, data, _options);
|
|
700
|
-
}
|
|
701
|
-
/**
|
|
702
|
-
* Writes a file to disk from the physical file system (on disk).
|
|
703
|
-
*
|
|
704
|
-
* @param path - The path to the file to write.
|
|
705
|
-
* @param contents - The contents of the file to write.
|
|
706
|
-
* @param options - Optional parameters for writing the file.
|
|
707
|
-
* @returns A promise that resolves when the file is written.
|
|
708
|
-
*/
|
|
709
|
-
async writeFileToDisk(path, contents, options = {}) {
|
|
710
|
-
const absolutePath = this.formatAbsoluteFilePath(toFilePath(path));
|
|
711
|
-
let data = contents;
|
|
712
|
-
if (!options.skipFormat) {
|
|
713
|
-
const resolvedConfig = await resolveConfig(absolutePath);
|
|
714
|
-
if (resolvedConfig) {
|
|
715
|
-
data = await format(contents, {
|
|
716
|
-
absolutePath,
|
|
717
|
-
...resolvedConfig
|
|
718
|
-
});
|
|
719
|
-
}
|
|
720
|
-
}
|
|
721
|
-
return this.writeFile(absolutePath, data, defu3({
|
|
722
|
-
mode: "fs"
|
|
723
|
-
}, isSetString(options) ? {} : options ?? {}, {
|
|
724
|
-
encoding: isSetString(options) ? options : "utf8"
|
|
725
|
-
}));
|
|
726
|
-
}
|
|
727
|
-
/**
|
|
728
821
|
* Synchronously checks if a file exists in the virtual file system (VFS).
|
|
729
822
|
*
|
|
730
823
|
* @param pathOrId - The path or ID of the file to check.
|
|
731
824
|
* @returns `true` if the file exists, otherwise `false`.
|
|
732
825
|
*/
|
|
733
826
|
existsSync(pathOrId) {
|
|
734
|
-
return this.
|
|
827
|
+
return this.resolve(pathOrId) !== false;
|
|
735
828
|
}
|
|
736
829
|
/**
|
|
737
830
|
* Checks if a file exists in the virtual file system (VFS).
|
|
@@ -739,32 +832,22 @@ var VirtualFileSystem = class {
|
|
|
739
832
|
* @remarks
|
|
740
833
|
* This is a base method used by {@link existsSync} - it does not try to resolve the path prior to checking if it exists or not.
|
|
741
834
|
*
|
|
742
|
-
* @param
|
|
835
|
+
* @param pathOrId - The path of the file to check.
|
|
743
836
|
* @returns `true` if the file exists, otherwise `false`.
|
|
744
837
|
*/
|
|
745
|
-
|
|
746
|
-
const
|
|
747
|
-
return
|
|
838
|
+
isFile(pathOrId) {
|
|
839
|
+
const resolved = this.resolve(pathOrId);
|
|
840
|
+
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()));
|
|
748
841
|
}
|
|
749
842
|
/**
|
|
750
843
|
* Checks if a directory exists in the virtual file system (VFS).
|
|
751
844
|
*
|
|
752
|
-
* @param
|
|
845
|
+
* @param pathOrId - The path of the directory to check.
|
|
753
846
|
* @returns `true` if the directory exists, otherwise `false`.
|
|
754
847
|
*/
|
|
755
|
-
|
|
756
|
-
const
|
|
757
|
-
return this.#virtualFS.existsSync(
|
|
758
|
-
}
|
|
759
|
-
/**
|
|
760
|
-
* Checks if a path exists in the virtual file system (VFS).
|
|
761
|
-
*
|
|
762
|
-
* @param path - The path to check.
|
|
763
|
-
* @returns `true` if the path exists, otherwise `false`.
|
|
764
|
-
*/
|
|
765
|
-
pathExistsSync(path) {
|
|
766
|
-
const formattedPath = this.formatAbsoluteFilePath(toFilePath(path));
|
|
767
|
-
return this.isValidBuiltinId(formattedPath) || this.#virtualFS.existsSync(formattedPath) || this.#fs.existsSync(formattedPath) || this.resolveFS(path).existsSync(formattedPath);
|
|
848
|
+
isDirectory(pathOrId) {
|
|
849
|
+
const resolved = this.resolve(pathOrId);
|
|
850
|
+
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()));
|
|
768
851
|
}
|
|
769
852
|
/**
|
|
770
853
|
* Retrieves the status of a file in the virtual file system (VFS).
|
|
@@ -773,7 +856,7 @@ var VirtualFileSystem = class {
|
|
|
773
856
|
* @returns A promise that resolves to the file's status information, or false if the file does not exist.
|
|
774
857
|
*/
|
|
775
858
|
async stat(pathOrId, options) {
|
|
776
|
-
return this.resolveFS(pathOrId).promises.stat(this.
|
|
859
|
+
return this.resolveFS(pathOrId).promises.stat(this.resolve(toFilePath(pathOrId)) || toFilePath(pathOrId), options);
|
|
777
860
|
}
|
|
778
861
|
/**
|
|
779
862
|
* Synchronously retrieves the status of a file in the virtual file system (VFS).
|
|
@@ -782,7 +865,7 @@ var VirtualFileSystem = class {
|
|
|
782
865
|
* @returns The file's status information, or false if the file does not exist.
|
|
783
866
|
*/
|
|
784
867
|
statSync(pathOrId) {
|
|
785
|
-
return this.resolveFS(pathOrId).statSync(this.
|
|
868
|
+
return this.resolveFS(pathOrId).statSync(this.resolve(toFilePath(pathOrId)) || toFilePath(pathOrId));
|
|
786
869
|
}
|
|
787
870
|
/**
|
|
788
871
|
* Retrieves the status of a symbolic link in the virtual file system (VFS).
|
|
@@ -791,7 +874,7 @@ var VirtualFileSystem = class {
|
|
|
791
874
|
* @returns A promise that resolves to the symbolic link's status information, or false if the link does not exist.
|
|
792
875
|
*/
|
|
793
876
|
async lstat(pathOrId, options) {
|
|
794
|
-
return this.resolveFS(pathOrId).promises.lstat(this.
|
|
877
|
+
return this.resolveFS(pathOrId).promises.lstat(this.resolve(toFilePath(pathOrId)) || toFilePath(pathOrId), options);
|
|
795
878
|
}
|
|
796
879
|
/**
|
|
797
880
|
* Synchronously retrieves the status of a symbolic link in the virtual file system (VFS).
|
|
@@ -800,23 +883,7 @@ var VirtualFileSystem = class {
|
|
|
800
883
|
* @returns The symbolic link's status information, or false if the link does not exist.
|
|
801
884
|
*/
|
|
802
885
|
lstatSync(pathOrId, options) {
|
|
803
|
-
return this.resolveFS(pathOrId).lstatSync(this.
|
|
804
|
-
}
|
|
805
|
-
/**
|
|
806
|
-
* Resolves a path or ID to a runtime file id in the virtual file system.
|
|
807
|
-
*
|
|
808
|
-
* @param pathOrId - The path or id of the file to resolve.
|
|
809
|
-
* @returns The resolved id of the runtime file if it exists, otherwise false.
|
|
810
|
-
*/
|
|
811
|
-
resolveId(pathOrId) {
|
|
812
|
-
if (this.builtinIdMap.has(this.formatRuntimeId(toFilePath(pathOrId)))) {
|
|
813
|
-
return this.formatRuntimeId(toFilePath(pathOrId));
|
|
814
|
-
}
|
|
815
|
-
const filePath = this.resolvePath(toFilePath(pathOrId));
|
|
816
|
-
if (filePath) {
|
|
817
|
-
return this.builtinIdMap.keys().find((id) => this.builtinIdMap.get(id) === filePath) || false;
|
|
818
|
-
}
|
|
819
|
-
return false;
|
|
886
|
+
return this.resolveFS(pathOrId).lstatSync(this.resolve(toFilePath(pathOrId)) || toFilePath(pathOrId), options);
|
|
820
887
|
}
|
|
821
888
|
/**
|
|
822
889
|
* Resolves a path based on TypeScript's `tsconfig.json` paths.
|
|
@@ -829,9 +896,9 @@ var VirtualFileSystem = class {
|
|
|
829
896
|
resolveTsconfigPath(path) {
|
|
830
897
|
if (this.#context.tsconfig.options.paths) {
|
|
831
898
|
for (const tsconfigPathKey of Object.keys(this.#context.tsconfig.options.paths).filter((tsconfigPath) => path.startsWith(tsconfigPath.replaceAll("*", "")))) {
|
|
832
|
-
const resolvedPath = this.#context.tsconfig.options.paths[tsconfigPathKey]?.find((tsconfigPath) => this.
|
|
899
|
+
const resolvedPath = this.#context.tsconfig.options.paths[tsconfigPathKey]?.find((tsconfigPath) => this.resolvePath(joinPaths(this.#context.workspaceConfig.workspaceRoot, tsconfigPath.replaceAll("*", ""), path.replace(tsconfigPathKey.replaceAll("*", ""), ""))) || this.formatPath(tsconfigPath) === this.formatPath(path));
|
|
833
900
|
if (resolvedPath) {
|
|
834
|
-
return this.
|
|
901
|
+
return this.formatPath(resolvedPath) === this.formatPath(path) ? this.formatPath(resolvedPath) : this.resolvePath(joinPaths(this.#context.workspaceConfig.workspaceRoot, resolvedPath.replaceAll("*", ""), path.replace(tsconfigPathKey.replaceAll("*", ""), "")));
|
|
835
902
|
}
|
|
836
903
|
}
|
|
837
904
|
}
|
|
@@ -861,7 +928,7 @@ var VirtualFileSystem = class {
|
|
|
861
928
|
* @returns The resolved real path if it exists, otherwise undefined.
|
|
862
929
|
*/
|
|
863
930
|
realpathSync(pathOrId) {
|
|
864
|
-
const filePath = this.
|
|
931
|
+
const filePath = this.resolve(toFilePath(pathOrId));
|
|
865
932
|
if (!filePath) {
|
|
866
933
|
throw new Error(`File not found: ${toFilePath(pathOrId)}`);
|
|
867
934
|
}
|
|
@@ -874,24 +941,18 @@ var VirtualFileSystem = class {
|
|
|
874
941
|
* @param options - Optional parameters for resolving the path, such as whether to include the file extension.
|
|
875
942
|
* @returns The resolved file path if it exists, otherwise undefined.
|
|
876
943
|
*/
|
|
877
|
-
|
|
878
|
-
const
|
|
879
|
-
const resolverKey = `${
|
|
944
|
+
resolve(pathOrId, options = {}) {
|
|
945
|
+
const formattedPathOrId = toFilePath(pathOrId);
|
|
946
|
+
const resolverKey = `${formattedPathOrId}${options.withExtension ? "-ext" : ""}${options.paths ? `-${murmurhash(options.paths)}` : ""}${options.type ? `-${options.type}` : ""}`;
|
|
880
947
|
if (this.#cachedResolver.has(resolverKey)) {
|
|
881
948
|
return this.#cachedResolver.get(resolverKey);
|
|
882
|
-
} else if (this.#cachedFS.has(formattedPath)) {
|
|
883
|
-
return formattedPath;
|
|
884
949
|
}
|
|
885
|
-
let result =
|
|
886
|
-
if (
|
|
887
|
-
result = this.
|
|
888
|
-
} else {
|
|
889
|
-
result = this.resolvePathName(formattedPath, options);
|
|
950
|
+
let result = this.resolveId(formattedPathOrId);
|
|
951
|
+
if (!result) {
|
|
952
|
+
result = this.resolvePath(formattedPathOrId, options);
|
|
890
953
|
}
|
|
891
954
|
if (!result) {
|
|
892
955
|
result = false;
|
|
893
|
-
} else {
|
|
894
|
-
result = toFilePath(result);
|
|
895
956
|
}
|
|
896
957
|
if (result && options.withExtension === false) {
|
|
897
958
|
return result.replace(/\.[m|c]?[t|j]sx?$/, "");
|
|
@@ -900,16 +961,12 @@ var VirtualFileSystem = class {
|
|
|
900
961
|
return result;
|
|
901
962
|
}
|
|
902
963
|
/**
|
|
903
|
-
*
|
|
964
|
+
* Retrieves the partial metadata for all files in the virtual file system (VFS).
|
|
904
965
|
*
|
|
905
|
-
* @
|
|
906
|
-
* @returns The formatted file path.
|
|
966
|
+
* @returns A record containing the partial metadata for all files.
|
|
907
967
|
*/
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
throw new Error(`Invalid path provided. Expected a string or a valid file path.`);
|
|
911
|
-
}
|
|
912
|
-
return path.replace(new RegExp(`^${this.#context.config.output.builtinPrefix}:`), "").replace(/^\\0/, "");
|
|
968
|
+
getPartialMeta() {
|
|
969
|
+
return Object.fromEntries(Object.entries(this.#meta).filter(([_, data]) => isSetObject(data)));
|
|
913
970
|
}
|
|
914
971
|
/**
|
|
915
972
|
* Converts a relative path to an absolute path based on the workspace and project root.
|
|
@@ -917,56 +974,67 @@ var VirtualFileSystem = class {
|
|
|
917
974
|
* @param path - The relative path to convert.
|
|
918
975
|
* @returns The absolute path.
|
|
919
976
|
*/
|
|
920
|
-
|
|
921
|
-
const formattedPath =
|
|
977
|
+
formatPath(path) {
|
|
978
|
+
const formattedPath = toFilePath(path);
|
|
922
979
|
if (isAbsolutePath(formattedPath) || formattedPath.startsWith(this.#context.workspaceConfig.workspaceRoot)) {
|
|
923
980
|
return formattedPath;
|
|
924
981
|
} else if (formattedPath.startsWith(this.#context.config.projectRoot)) {
|
|
925
982
|
return joinPaths(this.#context.workspaceConfig.workspaceRoot, formattedPath);
|
|
926
983
|
}
|
|
927
984
|
return formattedPath;
|
|
928
|
-
}
|
|
985
|
+
}
|
|
929
986
|
/**
|
|
930
|
-
* Formats a
|
|
987
|
+
* Formats a file id by removing the file extension and prepending the runtime prefix.
|
|
931
988
|
*
|
|
932
|
-
* @param id - The
|
|
933
|
-
* @returns The formatted
|
|
989
|
+
* @param id - The file ID to format.
|
|
990
|
+
* @returns The formatted file ID.
|
|
934
991
|
*/
|
|
935
|
-
|
|
936
|
-
|
|
992
|
+
formatId(id) {
|
|
993
|
+
const formattedId = toFilePath(id);
|
|
994
|
+
return `${this.#context.config.output.builtinPrefix}:${formattedId.replace(new RegExp(`^${this.#context.config.output.builtinPrefix}:`), "").replace(/^\\0/, "").replace(findFileExtensionSafe(formattedId), "")}`;
|
|
937
995
|
}
|
|
938
996
|
/**
|
|
939
|
-
* Resolves
|
|
997
|
+
* Resolves an id parameter to a corresponding virtual file path in the virtual file system (VFS).
|
|
940
998
|
*
|
|
941
|
-
* @param
|
|
942
|
-
* @returns The resolved file
|
|
999
|
+
* @param id - The id to resolve.
|
|
1000
|
+
* @returns The resolved file id if it exists, otherwise undefined.
|
|
943
1001
|
*/
|
|
944
|
-
|
|
945
|
-
if (
|
|
946
|
-
return false;
|
|
1002
|
+
resolveId(id) {
|
|
1003
|
+
if (this.#ids[this.formatId(id)]) {
|
|
1004
|
+
return this.#ids[this.formatId(id)] || false;
|
|
947
1005
|
}
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
1006
|
+
return false;
|
|
1007
|
+
}
|
|
1008
|
+
/**
|
|
1009
|
+
* Resolves a path parameter to a corresponding virtual file path in the virtual file system (VFS).
|
|
1010
|
+
*
|
|
1011
|
+
* @param path - The path to resolve.
|
|
1012
|
+
* @param options - Optional parameters for resolving the path.
|
|
1013
|
+
* @returns The resolved file path if it exists, otherwise undefined.
|
|
1014
|
+
*/
|
|
1015
|
+
resolvePath(path, options = {}) {
|
|
1016
|
+
if (isAbsolutePath(path)) {
|
|
1017
|
+
if (this.#existsSync(path)) {
|
|
1018
|
+
return path;
|
|
951
1019
|
}
|
|
952
|
-
const result = checkVariants(
|
|
1020
|
+
const result = this.checkVariants(path);
|
|
953
1021
|
if (result) {
|
|
954
1022
|
return result;
|
|
955
1023
|
}
|
|
956
1024
|
}
|
|
957
|
-
for (const
|
|
958
|
-
const request = joinPaths(
|
|
959
|
-
if (
|
|
1025
|
+
for (const parentPath of this.resolveParentPaths(path, options.paths)) {
|
|
1026
|
+
const request = joinPaths(parentPath, path);
|
|
1027
|
+
if (this.#existsSync(request)) {
|
|
960
1028
|
return request;
|
|
961
1029
|
}
|
|
962
|
-
const result = checkVariants(request
|
|
1030
|
+
const result = this.checkVariants(request);
|
|
963
1031
|
if (result) {
|
|
964
1032
|
return result;
|
|
965
1033
|
}
|
|
966
1034
|
}
|
|
967
1035
|
return false;
|
|
968
1036
|
}
|
|
969
|
-
resolveParentPaths(request,
|
|
1037
|
+
resolveParentPaths(request, parents = []) {
|
|
970
1038
|
let paths = [
|
|
971
1039
|
this.#context.workspaceConfig.workspaceRoot,
|
|
972
1040
|
joinPaths(this.#context.workspaceConfig.workspaceRoot, this.#context.config.projectRoot)
|
|
@@ -984,7 +1052,7 @@ var VirtualFileSystem = class {
|
|
|
984
1052
|
ret.push(path);
|
|
985
1053
|
}
|
|
986
1054
|
return ret;
|
|
987
|
-
},
|
|
1055
|
+
}, parents.filter(Boolean).map((p) => this.formatPath(p)));
|
|
988
1056
|
}
|
|
989
1057
|
/**
|
|
990
1058
|
* Select the file system module to use for the operation based on the path or URL.
|
|
@@ -1015,7 +1083,7 @@ var VirtualFileSystem = class {
|
|
|
1015
1083
|
} else if (options.mode === "fs" || this.#context.config.output.mode === "fs" || isParentPath(toFilePath(pathOrUrl), this.#context.dataPath) || isParentPath(toFilePath(pathOrUrl), this.#context.cachePath) || isParentPath(toFilePath(pathOrUrl), joinPaths(this.#context.workspaceConfig.workspaceRoot, this.#context.config.output.outputPath))) {
|
|
1016
1084
|
return "fs";
|
|
1017
1085
|
}
|
|
1018
|
-
return
|
|
1086
|
+
return void 0;
|
|
1019
1087
|
}
|
|
1020
1088
|
/**
|
|
1021
1089
|
* Clears the resolver cache for a given path.
|
|
@@ -1025,208 +1093,93 @@ var VirtualFileSystem = class {
|
|
|
1025
1093
|
clearResolverCache(path) {
|
|
1026
1094
|
this.#cachedResolver.keys().filter((key) => key.startsWith(toFilePath(path))).forEach((key) => this.#cachedResolver.delete(key));
|
|
1027
1095
|
}
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
__name(toFilePath, "toFilePath");
|
|
1041
|
-
var FS_METHODS = [
|
|
1042
|
-
"mkdir",
|
|
1043
|
-
"mkdirSync",
|
|
1044
|
-
"rmdir",
|
|
1045
|
-
"rmdirSync",
|
|
1046
|
-
"unlink",
|
|
1047
|
-
"unlinkSync",
|
|
1048
|
-
"existsSync",
|
|
1049
|
-
"realpathSync",
|
|
1050
|
-
"writeFileSync",
|
|
1051
|
-
"readFileSync",
|
|
1052
|
-
"readdirSync",
|
|
1053
|
-
"createWriteStream",
|
|
1054
|
-
"WriteStream",
|
|
1055
|
-
"createReadStream",
|
|
1056
|
-
"ReadStream"
|
|
1057
|
-
];
|
|
1058
|
-
var FS_PROMISE_METHODS = [
|
|
1059
|
-
"mkdir",
|
|
1060
|
-
"rm",
|
|
1061
|
-
"rmdir",
|
|
1062
|
-
"unlink",
|
|
1063
|
-
"writeFile",
|
|
1064
|
-
"readFile",
|
|
1065
|
-
"readdir",
|
|
1066
|
-
"stat",
|
|
1067
|
-
"lstat"
|
|
1068
|
-
];
|
|
1069
|
-
function cloneFS(originalFS) {
|
|
1070
|
-
const clonedFS = {
|
|
1071
|
-
...originalFS,
|
|
1072
|
-
promises: {
|
|
1073
|
-
...originalFS.promises ?? {}
|
|
1096
|
+
/**
|
|
1097
|
+
* Check if the file exists with different variants (index, extensions).
|
|
1098
|
+
*
|
|
1099
|
+
* @param request - The request path to check.
|
|
1100
|
+
* @param parentPath - An optional parent path to prepend to the request.
|
|
1101
|
+
* @returns The file path if it exists, otherwise false.
|
|
1102
|
+
*/
|
|
1103
|
+
checkVariants(request, parentPath) {
|
|
1104
|
+
const path = parentPath ? joinPaths(parentPath, request) : request;
|
|
1105
|
+
let file = this.checkExtensions(path);
|
|
1106
|
+
if (file) {
|
|
1107
|
+
return file;
|
|
1074
1108
|
}
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
clonedFS[method] = originalFS[method];
|
|
1109
|
+
file = this.checkIndex(path);
|
|
1110
|
+
if (file) {
|
|
1111
|
+
return file;
|
|
1079
1112
|
}
|
|
1113
|
+
return false;
|
|
1080
1114
|
}
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1115
|
+
/**
|
|
1116
|
+
* Check if the index file exists in the given request path.
|
|
1117
|
+
*
|
|
1118
|
+
* @param request - The request path to check.
|
|
1119
|
+
* @returns The index file path if it exists, otherwise false.
|
|
1120
|
+
*/
|
|
1121
|
+
checkIndex(request) {
|
|
1122
|
+
let file = joinPaths(request, "index");
|
|
1123
|
+
if (this.#existsSync(file)) {
|
|
1124
|
+
return file;
|
|
1087
1125
|
}
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
clonedFS[prop] = clonedFS[prop].bind(originalFS);
|
|
1092
|
-
if (isFunction(clonedFS.promises[prop])) {
|
|
1093
|
-
clonedFS.promises[prop] = clonedFS.promises[prop].bind(originalFS);
|
|
1094
|
-
}
|
|
1126
|
+
file = this.checkExtensions(file);
|
|
1127
|
+
if (file) {
|
|
1128
|
+
return file;
|
|
1095
1129
|
}
|
|
1130
|
+
return false;
|
|
1096
1131
|
}
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1132
|
+
/**
|
|
1133
|
+
* Check if the file exists with different extensions.
|
|
1134
|
+
*
|
|
1135
|
+
* @param request - The request path to check.
|
|
1136
|
+
* @param vfs - The file system module to use for checking file existence.
|
|
1137
|
+
* @returns The file path if it exists with any of the checked extensions, otherwise false.
|
|
1138
|
+
*/
|
|
1139
|
+
checkExtensions(request) {
|
|
1140
|
+
let file = `${request}.ts`;
|
|
1141
|
+
if (this.#existsSync(file)) {
|
|
1142
|
+
return file;
|
|
1100
1143
|
}
|
|
1144
|
+
file = `${request}.mts`;
|
|
1145
|
+
if (this.#existsSync(file)) {
|
|
1146
|
+
return file;
|
|
1147
|
+
}
|
|
1148
|
+
file = `${request}.cts`;
|
|
1149
|
+
if (this.#existsSync(file)) {
|
|
1150
|
+
return file;
|
|
1151
|
+
}
|
|
1152
|
+
file = `${request}.tsx`;
|
|
1153
|
+
if (this.#existsSync(file)) {
|
|
1154
|
+
return file;
|
|
1155
|
+
}
|
|
1156
|
+
file = `${request}.js`;
|
|
1157
|
+
if (this.#existsSync(file)) {
|
|
1158
|
+
return file;
|
|
1159
|
+
}
|
|
1160
|
+
file = `${request}.mjs`;
|
|
1161
|
+
if (this.#existsSync(file)) {
|
|
1162
|
+
return file;
|
|
1163
|
+
}
|
|
1164
|
+
file = `${request}.cjs`;
|
|
1165
|
+
if (this.#existsSync(file)) {
|
|
1166
|
+
return file;
|
|
1167
|
+
}
|
|
1168
|
+
file = `${request}.jsx`;
|
|
1169
|
+
if (this.#existsSync(file)) {
|
|
1170
|
+
return file;
|
|
1171
|
+
}
|
|
1172
|
+
file = `${request}.json`;
|
|
1173
|
+
if (this.#existsSync(file)) {
|
|
1174
|
+
return file;
|
|
1175
|
+
}
|
|
1176
|
+
file = `${request}.d.ts`;
|
|
1177
|
+
if (this.#existsSync(file)) {
|
|
1178
|
+
return file;
|
|
1179
|
+
}
|
|
1180
|
+
return false;
|
|
1101
1181
|
}
|
|
1102
|
-
|
|
1103
|
-
}
|
|
1104
|
-
__name(cloneFS, "cloneFS");
|
|
1105
|
-
function patchFS(originalFS, vfs) {
|
|
1106
|
-
const clonedFS = cloneFS(originalFS);
|
|
1107
|
-
originalFS.mkdirSync = (file, options) => vfs.mkdirSync(toFilePath(file), options);
|
|
1108
|
-
originalFS.mkdir = (file, options, callback) => vfs.mkdir(toFilePath(file), options, callback);
|
|
1109
|
-
originalFS.promises.mkdir = async (file, options) => vfs.mkdir(toFilePath(file), options);
|
|
1110
|
-
originalFS.unlinkSync = (file) => vfs.unlinkSync(toFilePath(file));
|
|
1111
|
-
originalFS.promises.rm = async (file, options) => vfs.rm(toFilePath(file), options);
|
|
1112
|
-
originalFS.promises.unlink = async (file) => vfs.unlink(toFilePath(file));
|
|
1113
|
-
originalFS.existsSync = (file) => vfs.existsSync(toFilePath(file));
|
|
1114
|
-
Object.defineProperty(originalFS, "realpathSync", {
|
|
1115
|
-
value: /* @__PURE__ */ __name((file, options) => vfs.realpathSync(toFilePath(file), options), "value")
|
|
1116
|
-
});
|
|
1117
|
-
originalFS.writeFileSync = (file, data, options) => vfs.writeFileSync(toFilePath(file), data, options);
|
|
1118
|
-
originalFS.promises.writeFile = async (file, data, options) => vfs.writeFile(toFilePath(file), data, options);
|
|
1119
|
-
originalFS.readFileSync = (file, options) => vfs.readFileSync(toFilePath(file), options);
|
|
1120
|
-
originalFS.promises.readFile = (file, options) => vfs.readFile(toFilePath(file), options);
|
|
1121
|
-
originalFS.readdirSync = (file, options) => vfs.readdirSync(toFilePath(file), options);
|
|
1122
|
-
originalFS.promises.readdir = (file, options) => vfs.readdir(toFilePath(file), options);
|
|
1123
|
-
Object.defineProperty(originalFS, "statSync", {
|
|
1124
|
-
value: /* @__PURE__ */ __name((file, options) => vfs.statSync(toFilePath(file), options), "value")
|
|
1125
|
-
});
|
|
1126
|
-
originalFS.stat = (file, options) => vfs.statSync(toFilePath(file), options);
|
|
1127
|
-
originalFS.promises.stat = (file, options) => vfs.stat(toFilePath(file), options);
|
|
1128
|
-
Object.defineProperty(originalFS, "lstatSync", {
|
|
1129
|
-
value: /* @__PURE__ */ __name((file, options) => vfs.lstatSync(toFilePath(file), options), "value")
|
|
1130
|
-
});
|
|
1131
|
-
originalFS.lstat = (file, options) => vfs.lstatSync(toFilePath(file), options);
|
|
1132
|
-
originalFS.promises.lstat = (file, options) => vfs.lstat(toFilePath(file), options);
|
|
1133
|
-
return () => {
|
|
1134
|
-
originalFS.mkdirSync = clonedFS.mkdirSync;
|
|
1135
|
-
originalFS.mkdir = clonedFS.mkdir;
|
|
1136
|
-
originalFS.promises.mkdir = clonedFS.promises.mkdir;
|
|
1137
|
-
originalFS.unlinkSync = clonedFS.unlinkSync;
|
|
1138
|
-
originalFS.promises.rm = clonedFS.promises.rm;
|
|
1139
|
-
originalFS.promises.unlink = clonedFS.promises.unlink;
|
|
1140
|
-
originalFS.existsSync = clonedFS.existsSync;
|
|
1141
|
-
originalFS.realpathSync = clonedFS.realpathSync;
|
|
1142
|
-
originalFS.writeFileSync = clonedFS.writeFileSync;
|
|
1143
|
-
originalFS.promises.writeFile = clonedFS.promises.writeFile;
|
|
1144
|
-
originalFS.readFileSync = clonedFS.readFileSync;
|
|
1145
|
-
originalFS.promises.readFile = clonedFS.promises.readFile;
|
|
1146
|
-
originalFS.readdirSync = clonedFS.readdirSync;
|
|
1147
|
-
originalFS.promises.readdir = clonedFS.promises.readdir;
|
|
1148
|
-
Object.defineProperty(originalFS, "statSync", {
|
|
1149
|
-
value: clonedFS.statSync
|
|
1150
|
-
});
|
|
1151
|
-
originalFS.stat = clonedFS.stat;
|
|
1152
|
-
originalFS.promises.stat = clonedFS.promises.stat;
|
|
1153
|
-
Object.defineProperty(originalFS, "lstatSync", {
|
|
1154
|
-
value: clonedFS.lstatSync
|
|
1155
|
-
});
|
|
1156
|
-
originalFS.lstat = clonedFS.lstat;
|
|
1157
|
-
originalFS.promises.lstat = clonedFS.promises.lstat;
|
|
1158
|
-
};
|
|
1159
|
-
}
|
|
1160
|
-
__name(patchFS, "patchFS");
|
|
1161
|
-
function checkVariants(request, vfs, parentPath) {
|
|
1162
|
-
const path = parentPath ? joinPaths(parentPath, request) : request;
|
|
1163
|
-
let file = checkExtensions(path, vfs);
|
|
1164
|
-
if (file) {
|
|
1165
|
-
return file;
|
|
1166
|
-
}
|
|
1167
|
-
file = checkIndex(path, vfs);
|
|
1168
|
-
if (file) {
|
|
1169
|
-
return file;
|
|
1170
|
-
}
|
|
1171
|
-
return false;
|
|
1172
|
-
}
|
|
1173
|
-
__name(checkVariants, "checkVariants");
|
|
1174
|
-
function checkIndex(request, vfs) {
|
|
1175
|
-
let file = joinPaths(request, "index");
|
|
1176
|
-
if (vfs.fileExistsSync(file)) {
|
|
1177
|
-
return file;
|
|
1178
|
-
}
|
|
1179
|
-
file = checkExtensions(file, vfs);
|
|
1180
|
-
if (file) {
|
|
1181
|
-
return file;
|
|
1182
|
-
}
|
|
1183
|
-
return false;
|
|
1184
|
-
}
|
|
1185
|
-
__name(checkIndex, "checkIndex");
|
|
1186
|
-
function checkExtensions(request, vfs) {
|
|
1187
|
-
let file = `${request}.ts`;
|
|
1188
|
-
if (vfs.fileExistsSync(file)) {
|
|
1189
|
-
return file;
|
|
1190
|
-
}
|
|
1191
|
-
file = `${request}.mts`;
|
|
1192
|
-
if (vfs.fileExistsSync(file)) {
|
|
1193
|
-
return file;
|
|
1194
|
-
}
|
|
1195
|
-
file = `${request}.cts`;
|
|
1196
|
-
if (vfs.fileExistsSync(file)) {
|
|
1197
|
-
return file;
|
|
1198
|
-
}
|
|
1199
|
-
file = `${request}.tsx`;
|
|
1200
|
-
if (vfs.fileExistsSync(file)) {
|
|
1201
|
-
return file;
|
|
1202
|
-
}
|
|
1203
|
-
file = `${request}.js`;
|
|
1204
|
-
if (vfs.fileExistsSync(file)) {
|
|
1205
|
-
return file;
|
|
1206
|
-
}
|
|
1207
|
-
file = `${request}.mjs`;
|
|
1208
|
-
if (vfs.fileExistsSync(file)) {
|
|
1209
|
-
return file;
|
|
1210
|
-
}
|
|
1211
|
-
file = `${request}.cjs`;
|
|
1212
|
-
if (vfs.fileExistsSync(file)) {
|
|
1213
|
-
return file;
|
|
1214
|
-
}
|
|
1215
|
-
file = `${request}.jsx`;
|
|
1216
|
-
if (vfs.fileExistsSync(file)) {
|
|
1217
|
-
return file;
|
|
1218
|
-
}
|
|
1219
|
-
file = `${request}.json`;
|
|
1220
|
-
if (vfs.fileExistsSync(file)) {
|
|
1221
|
-
return file;
|
|
1222
|
-
}
|
|
1223
|
-
file = `${request}.d.ts`;
|
|
1224
|
-
if (vfs.fileExistsSync(file)) {
|
|
1225
|
-
return file;
|
|
1226
|
-
}
|
|
1227
|
-
return false;
|
|
1228
|
-
}
|
|
1229
|
-
__name(checkExtensions, "checkExtensions");
|
|
1182
|
+
};
|
|
1230
1183
|
function createVfs(context) {
|
|
1231
1184
|
const vfs = new VirtualFileSystem(context);
|
|
1232
1185
|
return vfs;
|
|
@@ -1234,7 +1187,8 @@ function createVfs(context) {
|
|
|
1234
1187
|
__name(createVfs, "createVfs");
|
|
1235
1188
|
|
|
1236
1189
|
// src/internal/contexts/context.ts
|
|
1237
|
-
var
|
|
1190
|
+
var configCache = /* @__PURE__ */ new WeakMap();
|
|
1191
|
+
var parseCache = /* @__PURE__ */ new WeakMap();
|
|
1238
1192
|
var PowerlinesContext = class _PowerlinesContext {
|
|
1239
1193
|
static {
|
|
1240
1194
|
__name(this, "PowerlinesContext");
|
|
@@ -1461,6 +1415,57 @@ var PowerlinesContext = class _PowerlinesContext {
|
|
|
1461
1415
|
return relativeToWorkspaceRoot(this.config.projectRoot);
|
|
1462
1416
|
}
|
|
1463
1417
|
/**
|
|
1418
|
+
* The builtin module id that exist in the Powerlines virtual file system
|
|
1419
|
+
*/
|
|
1420
|
+
get builtins() {
|
|
1421
|
+
return Object.values(this.fs.meta).filter((meta) => meta && meta.variant === "builtin").map((meta) => meta?.id).filter(Boolean);
|
|
1422
|
+
}
|
|
1423
|
+
/**
|
|
1424
|
+
* Get the project root relative to the workspace root
|
|
1425
|
+
*/
|
|
1426
|
+
async getBuiltins() {
|
|
1427
|
+
return Promise.all(Object.entries(this.fs.meta).filter(([, meta]) => meta && meta.variant === "builtin").map(async ([path, meta]) => {
|
|
1428
|
+
const code = await this.fs.readFile(path);
|
|
1429
|
+
return {
|
|
1430
|
+
...meta,
|
|
1431
|
+
path,
|
|
1432
|
+
code
|
|
1433
|
+
};
|
|
1434
|
+
}));
|
|
1435
|
+
}
|
|
1436
|
+
/**
|
|
1437
|
+
* Resolves a entry virtual file and writes it to the VFS if it does not already exist
|
|
1438
|
+
*
|
|
1439
|
+
* @param code - The source code of the entry file
|
|
1440
|
+
* @param path - A path to write the entry file to
|
|
1441
|
+
* @param options - Optional write file options
|
|
1442
|
+
*/
|
|
1443
|
+
async writeEntry(code, path, options = {}) {
|
|
1444
|
+
return this.fs.writeFile(isAbsolute(path) ? path : appendPath(path, this.entryPath), {
|
|
1445
|
+
code,
|
|
1446
|
+
variant: "entry"
|
|
1447
|
+
}, defu3(options, {
|
|
1448
|
+
mode: this.config.output.mode
|
|
1449
|
+
}));
|
|
1450
|
+
}
|
|
1451
|
+
/**
|
|
1452
|
+
* Resolves a builtin virtual file and writes it to the VFS if it does not already exist
|
|
1453
|
+
*
|
|
1454
|
+
* @param code - The source code of the builtin file
|
|
1455
|
+
* @param id - The unique identifier of the builtin file
|
|
1456
|
+
* @param path - An optional path to write the builtin file to
|
|
1457
|
+
* @param options - Optional write file options
|
|
1458
|
+
*/
|
|
1459
|
+
async writeBuiltin(code, id, path, options = {}) {
|
|
1460
|
+
return this.fs.writeFile(path ? isAbsolute(path) ? path : joinPaths$1(this.builtinsPath, path) : appendPath(id, this.builtinsPath), {
|
|
1461
|
+
id,
|
|
1462
|
+
code,
|
|
1463
|
+
variant: "builtin"
|
|
1464
|
+
}, defu3(options, {
|
|
1465
|
+
mode: this.config.output.mode
|
|
1466
|
+
}));
|
|
1467
|
+
}
|
|
1468
|
+
/**
|
|
1464
1469
|
* Parses the source code and returns a {@link ParseResult} object.
|
|
1465
1470
|
*
|
|
1466
1471
|
* @param code - The source code to parse.
|
|
@@ -1469,12 +1474,31 @@ var PowerlinesContext = class _PowerlinesContext {
|
|
|
1469
1474
|
* @returns The parsed {@link ParseResult} object.
|
|
1470
1475
|
*/
|
|
1471
1476
|
async parse(code, id, options = {}) {
|
|
1472
|
-
|
|
1477
|
+
if (parseCache.has({
|
|
1478
|
+
code,
|
|
1479
|
+
options
|
|
1480
|
+
})) {
|
|
1481
|
+
return parseCache.get({
|
|
1482
|
+
code,
|
|
1483
|
+
options
|
|
1484
|
+
});
|
|
1485
|
+
}
|
|
1486
|
+
const result = await parseAsync(id, code, defu3(options ?? {}, {
|
|
1473
1487
|
lang: hasFileExtension(id) ? void 0 : "ts",
|
|
1474
1488
|
astType: hasFileExtension(id) ? void 0 : "ts",
|
|
1475
1489
|
sourceType: "module",
|
|
1476
1490
|
showSemanticErrors: false
|
|
1477
1491
|
}));
|
|
1492
|
+
if (result.errors && result.errors.length > 0) {
|
|
1493
|
+
throw new Error(`Powerlines parsing errors in file: ${id}
|
|
1494
|
+
${result.errors.map((error) => ` [${error.severity}] ${error.message}${error.codeframe ? ` (${error.codeframe})` : ""}${error.helpMessage ? `
|
|
1495
|
+
Help: ${error.helpMessage}` : ""}`).join("\n")}`);
|
|
1496
|
+
}
|
|
1497
|
+
parseCache.set({
|
|
1498
|
+
code,
|
|
1499
|
+
options
|
|
1500
|
+
}, result);
|
|
1501
|
+
return result;
|
|
1478
1502
|
}
|
|
1479
1503
|
/**
|
|
1480
1504
|
* Update the context using a new user configuration options
|
|
@@ -1563,8 +1587,8 @@ var PowerlinesContext = class _PowerlinesContext {
|
|
|
1563
1587
|
configFile: config.configFile ?? this.config.configFile,
|
|
1564
1588
|
command: this.config.inlineConfig?.command
|
|
1565
1589
|
};
|
|
1566
|
-
if (
|
|
1567
|
-
const result =
|
|
1590
|
+
if (configCache.has(cacheKey)) {
|
|
1591
|
+
const result = configCache.get(cacheKey);
|
|
1568
1592
|
this.projectJson = result.projectJson;
|
|
1569
1593
|
this.packageJson = result.packageJson;
|
|
1570
1594
|
this.#checksum = result.checksum;
|
|
@@ -1589,7 +1613,7 @@ var PowerlinesContext = class _PowerlinesContext {
|
|
|
1589
1613
|
});
|
|
1590
1614
|
const userConfig = await loadUserConfigFile(cacheKey.projectRoot, this.resolver, cacheKey.command, cacheKey.mode, cacheKey.configFile);
|
|
1591
1615
|
this.mergeUserConfig(userConfig.config);
|
|
1592
|
-
|
|
1616
|
+
configCache.set(cacheKey, {
|
|
1593
1617
|
projectJson: this.projectJson,
|
|
1594
1618
|
packageJson: this.packageJson,
|
|
1595
1619
|
checksum: this.#checksum,
|
|
@@ -2048,7 +2072,7 @@ function resolveModulePath(nodePath, state) {
|
|
|
2048
2072
|
return;
|
|
2049
2073
|
}
|
|
2050
2074
|
const sourcePath = nodePath.node.value;
|
|
2051
|
-
const resolvedPath = state.context?.fs.
|
|
2075
|
+
const resolvedPath = state.context?.fs.resolve(sourcePath);
|
|
2052
2076
|
if (resolvedPath) {
|
|
2053
2077
|
nodePath.replaceWith(t.stringLiteral(
|
|
2054
2078
|
// Remove the file extension if it exists
|
|
@@ -2149,8 +2173,9 @@ var moduleResolverBabelPlugin = /* @__PURE__ */ __name((context) => {
|
|
|
2149
2173
|
async function generateTypes(context) {
|
|
2150
2174
|
context.log(LogLevelLabel.TRACE, `Preparing the TypeScript definitions for the Powerlines project.`);
|
|
2151
2175
|
context.log(LogLevelLabel.TRACE, "Transforming built-ins runtime modules files.");
|
|
2152
|
-
const builtinFiles = await
|
|
2153
|
-
|
|
2176
|
+
const builtinFiles = await context.getBuiltins();
|
|
2177
|
+
const builtinFilePaths = await Promise.all(builtinFiles.map(async (file) => {
|
|
2178
|
+
const result = await transformAsync(file.code.toString(), {
|
|
2154
2179
|
highlightCode: true,
|
|
2155
2180
|
code: true,
|
|
2156
2181
|
ast: false,
|
|
@@ -2178,14 +2203,14 @@ async function generateTypes(context) {
|
|
|
2178
2203
|
throw new Error(`Powerlines - Generate Types failed to compile ${file.id}`);
|
|
2179
2204
|
}
|
|
2180
2205
|
context.log(LogLevelLabel.TRACE, `Writing transformed built-in runtime file ${file.id}.`);
|
|
2181
|
-
await context.
|
|
2206
|
+
await context.writeBuiltin(result.code, file.id, file.path);
|
|
2182
2207
|
return file.path;
|
|
2183
2208
|
}));
|
|
2184
2209
|
const typescriptPath = await resolvePackage("typescript");
|
|
2185
2210
|
if (!typescriptPath) {
|
|
2186
2211
|
throw new Error("Could not resolve TypeScript package location. Please ensure TypeScript is installed.");
|
|
2187
2212
|
}
|
|
2188
|
-
const files =
|
|
2213
|
+
const files = builtinFilePaths.reduce((ret, fileName) => {
|
|
2189
2214
|
const formatted = replacePath(fileName, context.workspaceConfig.workspaceRoot);
|
|
2190
2215
|
if (!ret.includes(formatted)) {
|
|
2191
2216
|
ret.push(formatted);
|
|
@@ -2220,9 +2245,9 @@ async function generateTypes(context) {
|
|
|
2220
2245
|
const emitResult = program.emit(void 0, (fileName, text, _, __, sourceFiles, _data) => {
|
|
2221
2246
|
const sourceFile2 = sourceFiles?.[0];
|
|
2222
2247
|
if (sourceFile2?.fileName && !fileName.endsWith(".map")) {
|
|
2223
|
-
if (
|
|
2248
|
+
if (builtinFiles.some((file) => file.id === sourceFile2.fileName || file.path === sourceFile2.fileName)) {
|
|
2224
2249
|
builtinModules += `
|
|
2225
|
-
declare module "${context.fs.
|
|
2250
|
+
declare module "${context.fs.resolve(sourceFile2.fileName)}" {
|
|
2226
2251
|
${text.trim().replace(/^\s*export\s*declare\s*/gm, "export ").replace(/^\s*declare\s*/gm, "")}
|
|
2227
2252
|
}
|
|
2228
2253
|
`;
|
|
@@ -2261,7 +2286,9 @@ ${builtinModules}`.replace(
|
|
|
2261
2286
|
/import\s*(?:type\s*)?\{?[\w,\s]*(?:\}\s*)?from\s*(?:'|")@?[a-zA-Z0-9-\\/.]*(?:'|");?/g,
|
|
2262
2287
|
""
|
|
2263
2288
|
).replaceAll("#private;", "").replace(/__Ω/g, ""));
|
|
2264
|
-
await context.fs.
|
|
2289
|
+
await context.fs.writeFile(sourceFile.id, getString(sourceFile.code), {
|
|
2290
|
+
mode: "fs"
|
|
2291
|
+
});
|
|
2265
2292
|
}
|
|
2266
2293
|
__name(generateTypes, "generateTypes");
|
|
2267
2294
|
async function installPackage(context, packageName, dev = false) {
|
|
@@ -2425,7 +2452,9 @@ async function initializeTsconfig(context) {
|
|
|
2425
2452
|
const tsconfigFilePath = getTsconfigFilePath(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.config.tsconfig);
|
|
2426
2453
|
context.tsconfig.originalTsconfigJson = await readJsonFile(tsconfigFilePath);
|
|
2427
2454
|
context.tsconfig.tsconfigJson = await resolveTsconfigChanges(context);
|
|
2428
|
-
await context.fs.
|
|
2455
|
+
await context.fs.writeFile(tsconfigFilePath, StormJSON.stringify(context.tsconfig.tsconfigJson), {
|
|
2456
|
+
mode: "fs"
|
|
2457
|
+
});
|
|
2429
2458
|
context.tsconfig = getParsedTypeScriptConfig(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.config.tsconfig, context.config.tsconfigRaw, context.tsconfig.originalTsconfigJson);
|
|
2430
2459
|
}
|
|
2431
2460
|
__name(initializeTsconfig, "initializeTsconfig");
|
|
@@ -2561,11 +2590,6 @@ ${formatLogMessage(context.config)}`);
|
|
|
2561
2590
|
await this.callPreHook(context, "prepare");
|
|
2562
2591
|
if (context.config.projectType === "application") {
|
|
2563
2592
|
context.log(LogLevelLabel.TRACE, "Generating built-in barrel file");
|
|
2564
|
-
await context.fs.writeBuiltinFile("index", joinPaths(context.builtinsPath, "index.ts"), `
|
|
2565
|
-
${getFileHeader(context)}
|
|
2566
|
-
|
|
2567
|
-
${(await context.fs.listBuiltinFiles()).filter((file) => !isParentPath(file.path, joinPaths(context.builtinsPath, "log")) && !isParentPath(file.path, joinPaths(context.builtinsPath, "storage"))).map((file) => `export * from "./${replacePath(file.path, context.builtinsPath).replace(`.${findFileExtensionSafe(file.path)}`, "")}";`).join("\n")}
|
|
2568
|
-
`);
|
|
2569
2593
|
}
|
|
2570
2594
|
if (context.config.output.dts !== false) {
|
|
2571
2595
|
await generateTypes(context);
|
|
@@ -3039,9 +3063,7 @@ function createUnpluginFactory(variant, decorate) {
|
|
|
3039
3063
|
async function load(id) {
|
|
3040
3064
|
const environment = await api.context.getEnvironment();
|
|
3041
3065
|
if (id) {
|
|
3042
|
-
const resolvedPath = environment.fs.
|
|
3043
|
-
type: "file"
|
|
3044
|
-
});
|
|
3066
|
+
const resolvedPath = environment.fs.resolve(id);
|
|
3045
3067
|
if (resolvedPath) {
|
|
3046
3068
|
return environment.fs.readFile(resolvedPath);
|
|
3047
3069
|
}
|
|
@@ -3118,5 +3140,5 @@ function createUnpluginFactory(variant, decorate) {
|
|
|
3118
3140
|
__name(createUnpluginFactory, "createUnpluginFactory");
|
|
3119
3141
|
|
|
3120
3142
|
export { createUnpluginFactory };
|
|
3121
|
-
//# sourceMappingURL=chunk-
|
|
3122
|
-
//# sourceMappingURL=chunk-
|
|
3143
|
+
//# sourceMappingURL=chunk-PIFE7MUZ.js.map
|
|
3144
|
+
//# sourceMappingURL=chunk-PIFE7MUZ.js.map
|