diff --git a/.pnp.cjs b/.pnp.cjs index 6a5f375..03e7b4e 100644 --- a/.pnp.cjs +++ b/.pnp.cjs @@ -33,11 +33,14 @@ const RAW_RUNTIME_STATE = ["@docusaurus/tsconfig", "npm:3.6.3"],\ ["@docusaurus/types", "virtual:f78c1e3bcca68c85029c31baaa03b00afb3f4a37fdf75a02a5c6641bf68e41c67a7197a443bdedd194efbd0fd58485f0fa4ac537f6319161bde534249e729f39#npm:3.6.3"],\ ["@mdx-js/react", "virtual:f78c1e3bcca68c85029c31baaa03b00afb3f4a37fdf75a02a5c6641bf68e41c67a7197a443bdedd194efbd0fd58485f0fa4ac537f6319161bde534249e729f39#npm:3.1.0"],\ + ["@types/prismjs", "npm:1.26.5"],\ ["clsx", "npm:2.1.1"],\ - ["prism-react-renderer", "virtual:f78c1e3bcca68c85029c31baaa03b00afb3f4a37fdf75a02a5c6641bf68e41c67a7197a443bdedd194efbd0fd58485f0fa4ac537f6319161bde534249e729f39#npm:2.4.0"],\ - ["react", "npm:18.3.1"],\ - ["react-dom", "virtual:f78c1e3bcca68c85029c31baaa03b00afb3f4a37fdf75a02a5c6641bf68e41c67a7197a443bdedd194efbd0fd58485f0fa4ac537f6319161bde534249e729f39#npm:18.3.1"],\ - ["typescript", "patch:typescript@npm%3A5.6.3#optional!builtin::version=5.6.3&hash=8c6c40"]\ + ["prism-react-renderer", "virtual:f78c1e3bcca68c85029c31baaa03b00afb3f4a37fdf75a02a5c6641bf68e41c67a7197a443bdedd194efbd0fd58485f0fa4ac537f6319161bde534249e729f39#npm:2.4.1"],\ + ["prismjs", "npm:1.29.0"],\ + ["react", "npm:19.0.0"],\ + ["react-dom", "virtual:f78c1e3bcca68c85029c31baaa03b00afb3f4a37fdf75a02a5c6641bf68e41c67a7197a443bdedd194efbd0fd58485f0fa4ac537f6319161bde534249e729f39#npm:19.0.0"],\ + ["typescript", "patch:typescript@npm%3A5.7.2#optional!builtin::version=5.7.2&hash=5786d5"],\ + ["utility-types", "npm:3.11.0"]\ ],\ "linkType": "SOFT"\ }]\ @@ -3769,8 +3772,8 @@ const RAW_RUNTIME_STATE = ["@types/react-dom", null],\ ["@types/search-insights", null],\ ["algoliasearch", "npm:5.15.0"],\ - ["react", "npm:18.3.1"],\ - ["react-dom", "virtual:f78c1e3bcca68c85029c31baaa03b00afb3f4a37fdf75a02a5c6641bf68e41c67a7197a443bdedd194efbd0fd58485f0fa4ac537f6319161bde534249e729f39#npm:18.3.1"],\ + ["react", "npm:19.0.0"],\ + ["react-dom", "virtual:f78c1e3bcca68c85029c31baaa03b00afb3f4a37fdf75a02a5c6641bf68e41c67a7197a443bdedd194efbd0fd58485f0fa4ac537f6319161bde534249e729f39#npm:19.0.0"],\ ["search-insights", null]\ ],\ "packagePeers": [\ @@ -3897,9 +3900,9 @@ const RAW_RUNTIME_STATE = ["lodash", "npm:4.17.21"],\ ["p-map", "npm:4.0.0"],\ ["prompts", "npm:2.4.2"],\ - ["react", "npm:18.3.1"],\ + ["react", "npm:19.0.0"],\ ["react-dev-utils", "virtual:4b0631a4efca79a85c9fde74319e6a9cb5bae18ac9fd796713dd546221fd5915382d82ce3176b2de5446413164ee43010ca328bfbd341e9b52ee5be2f19b0360#npm:12.0.1"],\ - ["react-dom", "virtual:f78c1e3bcca68c85029c31baaa03b00afb3f4a37fdf75a02a5c6641bf68e41c67a7197a443bdedd194efbd0fd58485f0fa4ac537f6319161bde534249e729f39#npm:18.3.1"],\ + ["react-dom", "virtual:f78c1e3bcca68c85029c31baaa03b00afb3f4a37fdf75a02a5c6641bf68e41c67a7197a443bdedd194efbd0fd58485f0fa4ac537f6319161bde534249e729f39#npm:19.0.0"],\ ["react-helmet-async", "virtual:4b0631a4efca79a85c9fde74319e6a9cb5bae18ac9fd796713dd546221fd5915382d82ce3176b2de5446413164ee43010ca328bfbd341e9b52ee5be2f19b0360#npm:1.3.0"],\ ["react-loadable", [\ "@docusaurus/react-loadable",\ @@ -3964,9 +3967,9 @@ const RAW_RUNTIME_STATE = ["lodash", "npm:4.17.21"],\ ["p-map", "npm:4.0.0"],\ ["prompts", "npm:2.4.2"],\ - ["react", "npm:18.3.1"],\ + ["react", "npm:19.0.0"],\ ["react-dev-utils", "virtual:4b0631a4efca79a85c9fde74319e6a9cb5bae18ac9fd796713dd546221fd5915382d82ce3176b2de5446413164ee43010ca328bfbd341e9b52ee5be2f19b0360#npm:12.0.1"],\ - ["react-dom", "virtual:f78c1e3bcca68c85029c31baaa03b00afb3f4a37fdf75a02a5c6641bf68e41c67a7197a443bdedd194efbd0fd58485f0fa4ac537f6319161bde534249e729f39#npm:18.3.1"],\ + ["react-dom", "virtual:f78c1e3bcca68c85029c31baaa03b00afb3f4a37fdf75a02a5c6641bf68e41c67a7197a443bdedd194efbd0fd58485f0fa4ac537f6319161bde534249e729f39#npm:19.0.0"],\ ["react-helmet-async", "virtual:4b0631a4efca79a85c9fde74319e6a9cb5bae18ac9fd796713dd546221fd5915382d82ce3176b2de5446413164ee43010ca328bfbd341e9b52ee5be2f19b0360#npm:1.3.0"],\ ["react-loadable", [\ "@docusaurus/react-loadable",\ @@ -4048,8 +4051,8 @@ const RAW_RUNTIME_STATE = ["image-size", "npm:1.1.1"],\ ["mdast-util-mdx", "npm:3.0.0"],\ ["mdast-util-to-string", "npm:4.0.0"],\ - ["react", "npm:18.3.1"],\ - ["react-dom", "virtual:f78c1e3bcca68c85029c31baaa03b00afb3f4a37fdf75a02a5c6641bf68e41c67a7197a443bdedd194efbd0fd58485f0fa4ac537f6319161bde534249e729f39#npm:18.3.1"],\ + ["react", "npm:19.0.0"],\ + ["react-dom", "virtual:f78c1e3bcca68c85029c31baaa03b00afb3f4a37fdf75a02a5c6641bf68e41c67a7197a443bdedd194efbd0fd58485f0fa4ac537f6319161bde534249e729f39#npm:19.0.0"],\ ["rehype-raw", "npm:7.0.0"],\ ["remark-directive", "npm:3.0.0"],\ ["remark-emoji", "npm:4.0.1"],\ @@ -4089,8 +4092,8 @@ const RAW_RUNTIME_STATE = ["image-size", "npm:1.1.1"],\ ["mdast-util-mdx", "npm:3.0.0"],\ ["mdast-util-to-string", "npm:4.0.0"],\ - ["react", "npm:18.3.1"],\ - ["react-dom", "virtual:f78c1e3bcca68c85029c31baaa03b00afb3f4a37fdf75a02a5c6641bf68e41c67a7197a443bdedd194efbd0fd58485f0fa4ac537f6319161bde534249e729f39#npm:18.3.1"],\ + ["react", "npm:19.0.0"],\ + ["react-dom", "virtual:f78c1e3bcca68c85029c31baaa03b00afb3f4a37fdf75a02a5c6641bf68e41c67a7197a443bdedd194efbd0fd58485f0fa4ac537f6319161bde534249e729f39#npm:19.0.0"],\ ["rehype-raw", "npm:7.0.0"],\ ["remark-directive", "npm:3.0.0"],\ ["remark-emoji", "npm:4.0.1"],\ @@ -4131,8 +4134,8 @@ const RAW_RUNTIME_STATE = ["@types/react-dom", null],\ ["@types/react-router-config", "npm:5.0.11"],\ ["@types/react-router-dom", "npm:5.3.3"],\ - ["react", "npm:18.3.1"],\ - ["react-dom", "virtual:f78c1e3bcca68c85029c31baaa03b00afb3f4a37fdf75a02a5c6641bf68e41c67a7197a443bdedd194efbd0fd58485f0fa4ac537f6319161bde534249e729f39#npm:18.3.1"],\ + ["react", "npm:19.0.0"],\ + ["react-dom", "virtual:f78c1e3bcca68c85029c31baaa03b00afb3f4a37fdf75a02a5c6641bf68e41c67a7197a443bdedd194efbd0fd58485f0fa4ac537f6319161bde534249e729f39#npm:19.0.0"],\ ["react-helmet-async", "virtual:1e45540384fb2b899b25f19aaffec8e6da7ecfb7ae74f15f95ebc4d649947c4ee6ea2575d145a232d3eb6b944cfaec4d6bd351010283589e80cc4ef92e451e2f#npm:2.0.5"],\ ["react-loadable", [\ "@docusaurus/react-loadable",\ @@ -4175,8 +4178,8 @@ const RAW_RUNTIME_STATE = ["feed", "npm:4.2.2"],\ ["fs-extra", "npm:11.2.0"],\ ["lodash", "npm:4.17.21"],\ - ["react", "npm:18.3.1"],\ - ["react-dom", "virtual:f78c1e3bcca68c85029c31baaa03b00afb3f4a37fdf75a02a5c6641bf68e41c67a7197a443bdedd194efbd0fd58485f0fa4ac537f6319161bde534249e729f39#npm:18.3.1"],\ + ["react", "npm:19.0.0"],\ + ["react-dom", "virtual:f78c1e3bcca68c85029c31baaa03b00afb3f4a37fdf75a02a5c6641bf68e41c67a7197a443bdedd194efbd0fd58485f0fa4ac537f6319161bde534249e729f39#npm:19.0.0"],\ ["reading-time", "npm:1.5.0"],\ ["srcset", "npm:4.0.0"],\ ["tslib", "npm:2.8.1"],\ @@ -4223,8 +4226,8 @@ const RAW_RUNTIME_STATE = ["fs-extra", "npm:11.2.0"],\ ["js-yaml", "npm:4.1.0"],\ ["lodash", "npm:4.17.21"],\ - ["react", "npm:18.3.1"],\ - ["react-dom", "virtual:f78c1e3bcca68c85029c31baaa03b00afb3f4a37fdf75a02a5c6641bf68e41c67a7197a443bdedd194efbd0fd58485f0fa4ac537f6319161bde534249e729f39#npm:18.3.1"],\ + ["react", "npm:19.0.0"],\ + ["react-dom", "virtual:f78c1e3bcca68c85029c31baaa03b00afb3f4a37fdf75a02a5c6641bf68e41c67a7197a443bdedd194efbd0fd58485f0fa4ac537f6319161bde534249e729f39#npm:19.0.0"],\ ["tslib", "npm:2.8.1"],\ ["utility-types", "npm:3.11.0"],\ ["webpack", "virtual:a00a792a121a1501d324c83e0e5f69cfb8f1e1c335d9091a22db87a1a0e3933344cf9918123bc8646135d4b047174c107b008fdd11c68f91562356a388d01266#npm:5.96.1"]\ @@ -4258,8 +4261,8 @@ const RAW_RUNTIME_STATE = ["@types/react", null],\ ["@types/react-dom", null],\ ["fs-extra", "npm:11.2.0"],\ - ["react", "npm:18.3.1"],\ - ["react-dom", "virtual:f78c1e3bcca68c85029c31baaa03b00afb3f4a37fdf75a02a5c6641bf68e41c67a7197a443bdedd194efbd0fd58485f0fa4ac537f6319161bde534249e729f39#npm:18.3.1"],\ + ["react", "npm:19.0.0"],\ + ["react-dom", "virtual:f78c1e3bcca68c85029c31baaa03b00afb3f4a37fdf75a02a5c6641bf68e41c67a7197a443bdedd194efbd0fd58485f0fa4ac537f6319161bde534249e729f39#npm:19.0.0"],\ ["tslib", "npm:2.8.1"],\ ["webpack", "virtual:a00a792a121a1501d324c83e0e5f69cfb8f1e1c335d9091a22db87a1a0e3933344cf9918123bc8646135d4b047174c107b008fdd11c68f91562356a388d01266#npm:5.96.1"]\ ],\ @@ -4290,8 +4293,8 @@ const RAW_RUNTIME_STATE = ["@types/react", null],\ ["@types/react-dom", null],\ ["fs-extra", "npm:11.2.0"],\ - ["react", "npm:18.3.1"],\ - ["react-dom", "virtual:f78c1e3bcca68c85029c31baaa03b00afb3f4a37fdf75a02a5c6641bf68e41c67a7197a443bdedd194efbd0fd58485f0fa4ac537f6319161bde534249e729f39#npm:18.3.1"],\ + ["react", "npm:19.0.0"],\ + ["react-dom", "virtual:f78c1e3bcca68c85029c31baaa03b00afb3f4a37fdf75a02a5c6641bf68e41c67a7197a443bdedd194efbd0fd58485f0fa4ac537f6319161bde534249e729f39#npm:19.0.0"],\ ["react-json-view-lite", "virtual:1d9b92cc33d29b4ed8b1ba2d7c4d3b6856096fb0f089a246e806709cdda5bd9f9c7018bddd648a00e23a8d8f27eaa95706f0520bd50b3fd146954752a4e17671#npm:1.5.0"],\ ["tslib", "npm:2.8.1"]\ ],\ @@ -4321,8 +4324,8 @@ const RAW_RUNTIME_STATE = ["@docusaurus/utils-validation", "npm:3.6.3"],\ ["@types/react", null],\ ["@types/react-dom", null],\ - ["react", "npm:18.3.1"],\ - ["react-dom", "virtual:f78c1e3bcca68c85029c31baaa03b00afb3f4a37fdf75a02a5c6641bf68e41c67a7197a443bdedd194efbd0fd58485f0fa4ac537f6319161bde534249e729f39#npm:18.3.1"],\ + ["react", "npm:19.0.0"],\ + ["react-dom", "virtual:f78c1e3bcca68c85029c31baaa03b00afb3f4a37fdf75a02a5c6641bf68e41c67a7197a443bdedd194efbd0fd58485f0fa4ac537f6319161bde534249e729f39#npm:19.0.0"],\ ["tslib", "npm:2.8.1"]\ ],\ "packagePeers": [\ @@ -4352,8 +4355,8 @@ const RAW_RUNTIME_STATE = ["@types/gtag.js", "npm:0.0.12"],\ ["@types/react", null],\ ["@types/react-dom", null],\ - ["react", "npm:18.3.1"],\ - ["react-dom", "virtual:f78c1e3bcca68c85029c31baaa03b00afb3f4a37fdf75a02a5c6641bf68e41c67a7197a443bdedd194efbd0fd58485f0fa4ac537f6319161bde534249e729f39#npm:18.3.1"],\ + ["react", "npm:19.0.0"],\ + ["react-dom", "virtual:f78c1e3bcca68c85029c31baaa03b00afb3f4a37fdf75a02a5c6641bf68e41c67a7197a443bdedd194efbd0fd58485f0fa4ac537f6319161bde534249e729f39#npm:19.0.0"],\ ["tslib", "npm:2.8.1"]\ ],\ "packagePeers": [\ @@ -4382,8 +4385,8 @@ const RAW_RUNTIME_STATE = ["@docusaurus/utils-validation", "npm:3.6.3"],\ ["@types/react", null],\ ["@types/react-dom", null],\ - ["react", "npm:18.3.1"],\ - ["react-dom", "virtual:f78c1e3bcca68c85029c31baaa03b00afb3f4a37fdf75a02a5c6641bf68e41c67a7197a443bdedd194efbd0fd58485f0fa4ac537f6319161bde534249e729f39#npm:18.3.1"],\ + ["react", "npm:19.0.0"],\ + ["react-dom", "virtual:f78c1e3bcca68c85029c31baaa03b00afb3f4a37fdf75a02a5c6641bf68e41c67a7197a443bdedd194efbd0fd58485f0fa4ac537f6319161bde534249e729f39#npm:19.0.0"],\ ["tslib", "npm:2.8.1"]\ ],\ "packagePeers": [\ @@ -4416,8 +4419,8 @@ const RAW_RUNTIME_STATE = ["@types/react", null],\ ["@types/react-dom", null],\ ["fs-extra", "npm:11.2.0"],\ - ["react", "npm:18.3.1"],\ - ["react-dom", "virtual:f78c1e3bcca68c85029c31baaa03b00afb3f4a37fdf75a02a5c6641bf68e41c67a7197a443bdedd194efbd0fd58485f0fa4ac537f6319161bde534249e729f39#npm:18.3.1"],\ + ["react", "npm:19.0.0"],\ + ["react-dom", "virtual:f78c1e3bcca68c85029c31baaa03b00afb3f4a37fdf75a02a5c6641bf68e41c67a7197a443bdedd194efbd0fd58485f0fa4ac537f6319161bde534249e729f39#npm:19.0.0"],\ ["sitemap", "npm:7.1.2"],\ ["tslib", "npm:2.8.1"]\ ],\ @@ -4457,8 +4460,8 @@ const RAW_RUNTIME_STATE = ["@docusaurus/types", "virtual:f78c1e3bcca68c85029c31baaa03b00afb3f4a37fdf75a02a5c6641bf68e41c67a7197a443bdedd194efbd0fd58485f0fa4ac537f6319161bde534249e729f39#npm:3.6.3"],\ ["@types/react", null],\ ["@types/react-dom", null],\ - ["react", "npm:18.3.1"],\ - ["react-dom", "virtual:f78c1e3bcca68c85029c31baaa03b00afb3f4a37fdf75a02a5c6641bf68e41c67a7197a443bdedd194efbd0fd58485f0fa4ac537f6319161bde534249e729f39#npm:18.3.1"]\ + ["react", "npm:19.0.0"],\ + ["react-dom", "virtual:f78c1e3bcca68c85029c31baaa03b00afb3f4a37fdf75a02a5c6641bf68e41c67a7197a443bdedd194efbd0fd58485f0fa4ac537f6319161bde534249e729f39#npm:19.0.0"]\ ],\ "packagePeers": [\ "@types/react-dom",\ @@ -4482,7 +4485,7 @@ const RAW_RUNTIME_STATE = "packageDependencies": [\ ["@docusaurus/react-loadable", "virtual:4b0631a4efca79a85c9fde74319e6a9cb5bae18ac9fd796713dd546221fd5915382d82ce3176b2de5446413164ee43010ca328bfbd341e9b52ee5be2f19b0360#npm:6.0.0"],\ ["@types/react", "npm:18.3.12"],\ - ["react", "npm:18.3.1"]\ + ["react", "npm:19.0.0"]\ ],\ "packagePeers": [\ "react"\ @@ -4524,10 +4527,10 @@ const RAW_RUNTIME_STATE = ["lodash", "npm:4.17.21"],\ ["nprogress", "npm:0.2.0"],\ ["postcss", "npm:8.4.49"],\ - ["prism-react-renderer", "virtual:f78c1e3bcca68c85029c31baaa03b00afb3f4a37fdf75a02a5c6641bf68e41c67a7197a443bdedd194efbd0fd58485f0fa4ac537f6319161bde534249e729f39#npm:2.4.0"],\ + ["prism-react-renderer", "virtual:a5630e3c1097a534baed8fb28bd2320a3975f56b1a7e35314a2c85380c6ec1f6df693b3e0d5587f597641c57dcbf43265bb73d82d68adf68a800f30159a78455#npm:2.4.0"],\ ["prismjs", "npm:1.29.0"],\ - ["react", "npm:18.3.1"],\ - ["react-dom", "virtual:f78c1e3bcca68c85029c31baaa03b00afb3f4a37fdf75a02a5c6641bf68e41c67a7197a443bdedd194efbd0fd58485f0fa4ac537f6319161bde534249e729f39#npm:18.3.1"],\ + ["react", "npm:19.0.0"],\ + ["react-dom", "virtual:f78c1e3bcca68c85029c31baaa03b00afb3f4a37fdf75a02a5c6641bf68e41c67a7197a443bdedd194efbd0fd58485f0fa4ac537f6319161bde534249e729f39#npm:19.0.0"],\ ["react-router-dom", "virtual:4b0631a4efca79a85c9fde74319e6a9cb5bae18ac9fd796713dd546221fd5915382d82ce3176b2de5446413164ee43010ca328bfbd341e9b52ee5be2f19b0360#npm:5.3.4"],\ ["rtlcss", "npm:4.3.0"],\ ["tslib", "npm:2.8.1"],\ @@ -4567,8 +4570,8 @@ const RAW_RUNTIME_STATE = ["clsx", "npm:2.1.1"],\ ["parse-numeric-range", "npm:1.3.0"],\ ["prism-react-renderer", "virtual:2ad545680716e1e37d9f24cc17c401fe5345f43f16bca750955741983a337a040a0c6b9e839b92e679a8d46f3dae8da3746063d08e82681422322022e6064622#npm:2.4.0"],\ - ["react", "npm:18.3.1"],\ - ["react-dom", "virtual:f78c1e3bcca68c85029c31baaa03b00afb3f4a37fdf75a02a5c6641bf68e41c67a7197a443bdedd194efbd0fd58485f0fa4ac537f6319161bde534249e729f39#npm:18.3.1"],\ + ["react", "npm:19.0.0"],\ + ["react-dom", "virtual:f78c1e3bcca68c85029c31baaa03b00afb3f4a37fdf75a02a5c6641bf68e41c67a7197a443bdedd194efbd0fd58485f0fa4ac537f6319161bde534249e729f39#npm:19.0.0"],\ ["tslib", "npm:2.8.1"],\ ["utility-types", "npm:3.11.0"]\ ],\ @@ -4610,8 +4613,8 @@ const RAW_RUNTIME_STATE = ["eta", "npm:2.2.0"],\ ["fs-extra", "npm:11.2.0"],\ ["lodash", "npm:4.17.21"],\ - ["react", "npm:18.3.1"],\ - ["react-dom", "virtual:f78c1e3bcca68c85029c31baaa03b00afb3f4a37fdf75a02a5c6641bf68e41c67a7197a443bdedd194efbd0fd58485f0fa4ac537f6319161bde534249e729f39#npm:18.3.1"],\ + ["react", "npm:19.0.0"],\ + ["react-dom", "virtual:f78c1e3bcca68c85029c31baaa03b00afb3f4a37fdf75a02a5c6641bf68e41c67a7197a443bdedd194efbd0fd58485f0fa4ac537f6319161bde534249e729f39#npm:19.0.0"],\ ["tslib", "npm:2.8.1"],\ ["utility-types", "npm:3.11.0"]\ ],\ @@ -4686,8 +4689,8 @@ const RAW_RUNTIME_STATE = ["@types/react-dom", null],\ ["commander", "npm:5.1.0"],\ ["joi", "npm:17.13.3"],\ - ["react", "npm:18.3.1"],\ - ["react-dom", "virtual:f78c1e3bcca68c85029c31baaa03b00afb3f4a37fdf75a02a5c6641bf68e41c67a7197a443bdedd194efbd0fd58485f0fa4ac537f6319161bde534249e729f39#npm:18.3.1"],\ + ["react", "npm:19.0.0"],\ + ["react-dom", "virtual:f78c1e3bcca68c85029c31baaa03b00afb3f4a37fdf75a02a5c6641bf68e41c67a7197a443bdedd194efbd0fd58485f0fa4ac537f6319161bde534249e729f39#npm:19.0.0"],\ ["react-helmet-async", "virtual:285782b97f14cab5eafac7d2803c36e376c603e6c434830454a817dd393c2b44f6ae46d9b607280ee079e8fced504b6e16ef4de27ee1c5774da1e63a53d68089#npm:1.3.0"],\ ["utility-types", "npm:3.11.0"],\ ["webpack", "virtual:a00a792a121a1501d324c83e0e5f69cfb8f1e1c335d9091a22db87a1a0e3933344cf9918123bc8646135d4b047174c107b008fdd11c68f91562356a388d01266#npm:5.96.1"],\ @@ -4944,7 +4947,7 @@ const RAW_RUNTIME_STATE = ["@mdx-js/react", "virtual:f78c1e3bcca68c85029c31baaa03b00afb3f4a37fdf75a02a5c6641bf68e41c67a7197a443bdedd194efbd0fd58485f0fa4ac537f6319161bde534249e729f39#npm:3.1.0"],\ ["@types/mdx", "npm:2.0.13"],\ ["@types/react", null],\ - ["react", "npm:18.3.1"]\ + ["react", "npm:19.0.0"]\ ],\ "packagePeers": [\ "@types/react",\ @@ -8235,11 +8238,14 @@ const RAW_RUNTIME_STATE = ["@docusaurus/tsconfig", "npm:3.6.3"],\ ["@docusaurus/types", "virtual:f78c1e3bcca68c85029c31baaa03b00afb3f4a37fdf75a02a5c6641bf68e41c67a7197a443bdedd194efbd0fd58485f0fa4ac537f6319161bde534249e729f39#npm:3.6.3"],\ ["@mdx-js/react", "virtual:f78c1e3bcca68c85029c31baaa03b00afb3f4a37fdf75a02a5c6641bf68e41c67a7197a443bdedd194efbd0fd58485f0fa4ac537f6319161bde534249e729f39#npm:3.1.0"],\ + ["@types/prismjs", "npm:1.26.5"],\ ["clsx", "npm:2.1.1"],\ - ["prism-react-renderer", "virtual:f78c1e3bcca68c85029c31baaa03b00afb3f4a37fdf75a02a5c6641bf68e41c67a7197a443bdedd194efbd0fd58485f0fa4ac537f6319161bde534249e729f39#npm:2.4.0"],\ - ["react", "npm:18.3.1"],\ - ["react-dom", "virtual:f78c1e3bcca68c85029c31baaa03b00afb3f4a37fdf75a02a5c6641bf68e41c67a7197a443bdedd194efbd0fd58485f0fa4ac537f6319161bde534249e729f39#npm:18.3.1"],\ - ["typescript", "patch:typescript@npm%3A5.6.3#optional!builtin::version=5.6.3&hash=8c6c40"]\ + ["prism-react-renderer", "virtual:f78c1e3bcca68c85029c31baaa03b00afb3f4a37fdf75a02a5c6641bf68e41c67a7197a443bdedd194efbd0fd58485f0fa4ac537f6319161bde534249e729f39#npm:2.4.1"],\ + ["prismjs", "npm:1.29.0"],\ + ["react", "npm:19.0.0"],\ + ["react-dom", "virtual:f78c1e3bcca68c85029c31baaa03b00afb3f4a37fdf75a02a5c6641bf68e41c67a7197a443bdedd194efbd0fd58485f0fa4ac537f6319161bde534249e729f39#npm:19.0.0"],\ + ["typescript", "patch:typescript@npm%3A5.7.2#optional!builtin::version=5.7.2&hash=5786d5"],\ + ["utility-types", "npm:3.11.0"]\ ],\ "linkType": "SOFT"\ }]\ @@ -14435,6 +14441,13 @@ const RAW_RUNTIME_STATE = ],\ "linkType": "SOFT"\ }],\ + ["npm:2.4.1", {\ + "packageLocation": "../../AppData/Local/Yarn/Berry/cache/prism-react-renderer-npm-2.4.1-b9eaf468f6-10c0.zip/node_modules/prism-react-renderer/",\ + "packageDependencies": [\ + ["prism-react-renderer", "npm:2.4.1"]\ + ],\ + "linkType": "SOFT"\ + }],\ ["virtual:2ad545680716e1e37d9f24cc17c401fe5345f43f16bca750955741983a337a040a0c6b9e839b92e679a8d46f3dae8da3746063d08e82681422322022e6064622#npm:2.4.0", {\ "packageLocation": "./.yarn/__virtual__/prism-react-renderer-virtual-462c254160/3/AppData/Local/Yarn/Berry/cache/prism-react-renderer-npm-2.4.0-3fab7693fe-10c0.zip/node_modules/prism-react-renderer/",\ "packageDependencies": [\ @@ -14442,7 +14455,7 @@ const RAW_RUNTIME_STATE = ["@types/prismjs", "npm:1.26.5"],\ ["@types/react", "npm:18.3.12"],\ ["clsx", "npm:2.1.1"],\ - ["react", "npm:18.3.1"]\ + ["react", "npm:19.0.0"]\ ],\ "packagePeers": [\ "@types/react",\ @@ -14450,14 +14463,29 @@ const RAW_RUNTIME_STATE = ],\ "linkType": "HARD"\ }],\ - ["virtual:f78c1e3bcca68c85029c31baaa03b00afb3f4a37fdf75a02a5c6641bf68e41c67a7197a443bdedd194efbd0fd58485f0fa4ac537f6319161bde534249e729f39#npm:2.4.0", {\ - "packageLocation": "./.yarn/__virtual__/prism-react-renderer-virtual-9bbb89e8bf/3/AppData/Local/Yarn/Berry/cache/prism-react-renderer-npm-2.4.0-3fab7693fe-10c0.zip/node_modules/prism-react-renderer/",\ + ["virtual:a5630e3c1097a534baed8fb28bd2320a3975f56b1a7e35314a2c85380c6ec1f6df693b3e0d5587f597641c57dcbf43265bb73d82d68adf68a800f30159a78455#npm:2.4.0", {\ + "packageLocation": "./.yarn/__virtual__/prism-react-renderer-virtual-bcf6870bf7/3/AppData/Local/Yarn/Berry/cache/prism-react-renderer-npm-2.4.0-3fab7693fe-10c0.zip/node_modules/prism-react-renderer/",\ "packageDependencies": [\ - ["prism-react-renderer", "virtual:f78c1e3bcca68c85029c31baaa03b00afb3f4a37fdf75a02a5c6641bf68e41c67a7197a443bdedd194efbd0fd58485f0fa4ac537f6319161bde534249e729f39#npm:2.4.0"],\ + ["prism-react-renderer", "virtual:a5630e3c1097a534baed8fb28bd2320a3975f56b1a7e35314a2c85380c6ec1f6df693b3e0d5587f597641c57dcbf43265bb73d82d68adf68a800f30159a78455#npm:2.4.0"],\ ["@types/prismjs", "npm:1.26.5"],\ ["@types/react", null],\ ["clsx", "npm:2.1.1"],\ - ["react", "npm:18.3.1"]\ + ["react", "npm:19.0.0"]\ + ],\ + "packagePeers": [\ + "@types/react",\ + "react"\ + ],\ + "linkType": "HARD"\ + }],\ + ["virtual:f78c1e3bcca68c85029c31baaa03b00afb3f4a37fdf75a02a5c6641bf68e41c67a7197a443bdedd194efbd0fd58485f0fa4ac537f6319161bde534249e729f39#npm:2.4.1", {\ + "packageLocation": "./.yarn/__virtual__/prism-react-renderer-virtual-640b3e75b2/3/AppData/Local/Yarn/Berry/cache/prism-react-renderer-npm-2.4.1-b9eaf468f6-10c0.zip/node_modules/prism-react-renderer/",\ + "packageDependencies": [\ + ["prism-react-renderer", "virtual:f78c1e3bcca68c85029c31baaa03b00afb3f4a37fdf75a02a5c6641bf68e41c67a7197a443bdedd194efbd0fd58485f0fa4ac537f6319161bde534249e729f39#npm:2.4.1"],\ + ["@types/prismjs", "npm:1.26.5"],\ + ["@types/react", null],\ + ["clsx", "npm:2.1.1"],\ + ["react", "npm:19.0.0"]\ ],\ "packagePeers": [\ "@types/react",\ @@ -14666,11 +14694,10 @@ const RAW_RUNTIME_STATE = }]\ ]],\ ["react", [\ - ["npm:18.3.1", {\ - "packageLocation": "../../AppData/Local/Yarn/Berry/cache/react-npm-18.3.1-af38f3c1ae-10c0.zip/node_modules/react/",\ + ["npm:19.0.0", {\ + "packageLocation": "../../AppData/Local/Yarn/Berry/cache/react-npm-19.0.0-e33c9aa1c0-10c0.zip/node_modules/react/",\ "packageDependencies": [\ - ["react", "npm:18.3.1"],\ - ["loose-envify", "npm:1.4.0"]\ + ["react", "npm:19.0.0"]\ ],\ "linkType": "HARD"\ }]\ @@ -14726,21 +14753,20 @@ const RAW_RUNTIME_STATE = }]\ ]],\ ["react-dom", [\ - ["npm:18.3.1", {\ - "packageLocation": "../../AppData/Local/Yarn/Berry/cache/react-dom-npm-18.3.1-a805663f38-10c0.zip/node_modules/react-dom/",\ + ["npm:19.0.0", {\ + "packageLocation": "../../AppData/Local/Yarn/Berry/cache/react-dom-npm-19.0.0-b7981c573e-10c0.zip/node_modules/react-dom/",\ "packageDependencies": [\ - ["react-dom", "npm:18.3.1"]\ + ["react-dom", "npm:19.0.0"]\ ],\ "linkType": "SOFT"\ }],\ - ["virtual:f78c1e3bcca68c85029c31baaa03b00afb3f4a37fdf75a02a5c6641bf68e41c67a7197a443bdedd194efbd0fd58485f0fa4ac537f6319161bde534249e729f39#npm:18.3.1", {\ - "packageLocation": "./.yarn/__virtual__/react-dom-virtual-7d750af289/3/AppData/Local/Yarn/Berry/cache/react-dom-npm-18.3.1-a805663f38-10c0.zip/node_modules/react-dom/",\ + ["virtual:f78c1e3bcca68c85029c31baaa03b00afb3f4a37fdf75a02a5c6641bf68e41c67a7197a443bdedd194efbd0fd58485f0fa4ac537f6319161bde534249e729f39#npm:19.0.0", {\ + "packageLocation": "./.yarn/__virtual__/react-dom-virtual-c615d4bb57/3/AppData/Local/Yarn/Berry/cache/react-dom-npm-19.0.0-b7981c573e-10c0.zip/node_modules/react-dom/",\ "packageDependencies": [\ - ["react-dom", "virtual:f78c1e3bcca68c85029c31baaa03b00afb3f4a37fdf75a02a5c6641bf68e41c67a7197a443bdedd194efbd0fd58485f0fa4ac537f6319161bde534249e729f39#npm:18.3.1"],\ + ["react-dom", "virtual:f78c1e3bcca68c85029c31baaa03b00afb3f4a37fdf75a02a5c6641bf68e41c67a7197a443bdedd194efbd0fd58485f0fa4ac537f6319161bde534249e729f39#npm:19.0.0"],\ ["@types/react", null],\ - ["loose-envify", "npm:1.4.0"],\ - ["react", "npm:18.3.1"],\ - ["scheduler", "npm:0.23.2"]\ + ["react", "npm:19.0.0"],\ + ["scheduler", "npm:0.25.0"]\ ],\ "packagePeers": [\ "@types/react",\ @@ -14788,7 +14814,7 @@ const RAW_RUNTIME_STATE = ["react-helmet-async", "virtual:1e45540384fb2b899b25f19aaffec8e6da7ecfb7ae74f15f95ebc4d649947c4ee6ea2575d145a232d3eb6b944cfaec4d6bd351010283589e80cc4ef92e451e2f#npm:2.0.5"],\ ["@types/react", "npm:18.3.12"],\ ["invariant", "npm:2.2.4"],\ - ["react", "npm:18.3.1"],\ + ["react", "npm:19.0.0"],\ ["react-fast-compare", "npm:3.2.2"],\ ["shallowequal", "npm:1.1.0"]\ ],\ @@ -14807,8 +14833,8 @@ const RAW_RUNTIME_STATE = ["@types/react-dom", null],\ ["invariant", "npm:2.2.4"],\ ["prop-types", "npm:15.8.1"],\ - ["react", "npm:18.3.1"],\ - ["react-dom", "virtual:f78c1e3bcca68c85029c31baaa03b00afb3f4a37fdf75a02a5c6641bf68e41c67a7197a443bdedd194efbd0fd58485f0fa4ac537f6319161bde534249e729f39#npm:18.3.1"],\ + ["react", "npm:19.0.0"],\ + ["react-dom", "virtual:f78c1e3bcca68c85029c31baaa03b00afb3f4a37fdf75a02a5c6641bf68e41c67a7197a443bdedd194efbd0fd58485f0fa4ac537f6319161bde534249e729f39#npm:19.0.0"],\ ["react-fast-compare", "npm:3.2.2"],\ ["shallowequal", "npm:1.1.0"]\ ],\ @@ -14829,8 +14855,8 @@ const RAW_RUNTIME_STATE = ["@types/react-dom", null],\ ["invariant", "npm:2.2.4"],\ ["prop-types", "npm:15.8.1"],\ - ["react", "npm:18.3.1"],\ - ["react-dom", "virtual:f78c1e3bcca68c85029c31baaa03b00afb3f4a37fdf75a02a5c6641bf68e41c67a7197a443bdedd194efbd0fd58485f0fa4ac537f6319161bde534249e729f39#npm:18.3.1"],\ + ["react", "npm:19.0.0"],\ + ["react-dom", "virtual:f78c1e3bcca68c85029c31baaa03b00afb3f4a37fdf75a02a5c6641bf68e41c67a7197a443bdedd194efbd0fd58485f0fa4ac537f6319161bde534249e729f39#npm:19.0.0"],\ ["react-fast-compare", "npm:3.2.2"],\ ["shallowequal", "npm:1.1.0"]\ ],\ @@ -14887,7 +14913,7 @@ const RAW_RUNTIME_STATE = "packageDependencies": [\ ["react-json-view-lite", "virtual:1d9b92cc33d29b4ed8b1ba2d7c4d3b6856096fb0f089a246e806709cdda5bd9f9c7018bddd648a00e23a8d8f27eaa95706f0520bd50b3fd146954752a4e17671#npm:1.5.0"],\ ["@types/react", null],\ - ["react", "npm:18.3.1"]\ + ["react", "npm:19.0.0"]\ ],\ "packagePeers": [\ "@types/react",\ @@ -14945,7 +14971,7 @@ const RAW_RUNTIME_STATE = ["loose-envify", "npm:1.4.0"],\ ["path-to-regexp", "npm:1.9.0"],\ ["prop-types", "npm:15.8.1"],\ - ["react", "npm:18.3.1"],\ + ["react", "npm:19.0.0"],\ ["react-is", "npm:16.13.1"],\ ["tiny-invariant", "npm:1.3.3"],\ ["tiny-warning", "npm:1.0.3"]\ @@ -14972,7 +14998,7 @@ const RAW_RUNTIME_STATE = ["@babel/runtime", "npm:7.26.0"],\ ["@types/react", null],\ ["@types/react-router", null],\ - ["react", "npm:18.3.1"],\ + ["react", "npm:19.0.0"],\ ["react-router", "virtual:4b0631a4efca79a85c9fde74319e6a9cb5bae18ac9fd796713dd546221fd5915382d82ce3176b2de5446413164ee43010ca328bfbd341e9b52ee5be2f19b0360#npm:5.3.4"]\ ],\ "packagePeers": [\ @@ -15001,7 +15027,7 @@ const RAW_RUNTIME_STATE = ["history", "npm:4.10.1"],\ ["loose-envify", "npm:1.4.0"],\ ["prop-types", "npm:15.8.1"],\ - ["react", "npm:18.3.1"],\ + ["react", "npm:19.0.0"],\ ["react-router", "virtual:4b0631a4efca79a85c9fde74319e6a9cb5bae18ac9fd796713dd546221fd5915382d82ce3176b2de5446413164ee43010ca328bfbd341e9b52ee5be2f19b0360#npm:5.3.4"],\ ["tiny-invariant", "npm:1.3.3"],\ ["tiny-warning", "npm:1.0.3"]\ @@ -15561,11 +15587,10 @@ const RAW_RUNTIME_STATE = }]\ ]],\ ["scheduler", [\ - ["npm:0.23.2", {\ - "packageLocation": "../../AppData/Local/Yarn/Berry/cache/scheduler-npm-0.23.2-6d1dd9c2b7-10c0.zip/node_modules/scheduler/",\ + ["npm:0.25.0", {\ + "packageLocation": "../../AppData/Local/Yarn/Berry/cache/scheduler-npm-0.25.0-f89e6cad04-10c0.zip/node_modules/scheduler/",\ "packageDependencies": [\ - ["scheduler", "npm:0.23.2"],\ - ["loose-envify", "npm:1.4.0"]\ + ["scheduler", "npm:0.25.0"]\ ],\ "linkType": "HARD"\ }]\ @@ -16542,10 +16567,10 @@ const RAW_RUNTIME_STATE = }]\ ]],\ ["typescript", [\ - ["patch:typescript@npm%3A5.6.3#optional!builtin::version=5.6.3&hash=8c6c40", {\ - "packageLocation": "../../AppData/Local/Yarn/Berry/cache/typescript-patch-8964a48ba3-10c0.zip/node_modules/typescript/",\ + ["patch:typescript@npm%3A5.7.2#optional!builtin::version=5.7.2&hash=5786d5", {\ + "packageLocation": "../../AppData/Local/Yarn/Berry/cache/typescript-patch-aed9e5263d-10c0.zip/node_modules/typescript/",\ "packageDependencies": [\ - ["typescript", "patch:typescript@npm%3A5.6.3#optional!builtin::version=5.6.3&hash=8c6c40"]\ + ["typescript", "patch:typescript@npm%3A5.7.2#optional!builtin::version=5.7.2&hash=5786d5"]\ ],\ "linkType": "HARD"\ }]\ diff --git a/.pnp.loader.mjs b/.pnp.loader.mjs index dc5d2b3..e5a5429 100644 --- a/.pnp.loader.mjs +++ b/.pnp.loader.mjs @@ -2,45 +2,45 @@ // @ts-nocheck import fs from 'fs'; -import {URL as URL$1, fileURLToPath, pathToFileURL} from 'url'; +import { URL as URL$1, fileURLToPath, pathToFileURL } from 'url'; import path from 'path'; -import {createHash} from 'crypto'; -import {EOL} from 'os'; -import esmModule, {createRequire, isBuiltin} from 'module'; +import { createHash } from 'crypto'; +import { EOL } from 'os'; +import esmModule, { createRequire, isBuiltin } from 'module'; import assert from 'assert'; const SAFE_TIME = 456789e3; const PortablePath = { - root: `/`, - dot: `.`, - parent: `..` + root: `/`, + dot: `.`, + parent: `..` }; const npath = Object.create(path); const ppath = Object.create(path.posix); npath.cwd = () => process.cwd(); ppath.cwd = process.platform === `win32` ? () => toPortablePath(process.cwd()) : process.cwd; if (process.platform === `win32`) { - ppath.resolve = (...segments) => { - if (segments.length > 0 && ppath.isAbsolute(segments[0])) { - return path.posix.resolve(...segments); - } else { - return path.posix.resolve(ppath.cwd(), ...segments); - } - }; -} -const contains = function (pathUtils, from, to) { - from = pathUtils.normalize(from); - to = pathUtils.normalize(to); - if (from === to) - return `.`; - if (!from.endsWith(pathUtils.sep)) - from = from + pathUtils.sep; - if (to.startsWith(from)) { - return to.slice(from.length); + ppath.resolve = (...segments) => { + if (segments.length > 0 && ppath.isAbsolute(segments[0])) { + return path.posix.resolve(...segments); } else { - return null; + return path.posix.resolve(ppath.cwd(), ...segments); } + }; +} +const contains = function(pathUtils, from, to) { + from = pathUtils.normalize(from); + to = pathUtils.normalize(to); + if (from === to) + return `.`; + if (!from.endsWith(pathUtils.sep)) + from = from + pathUtils.sep; + if (to.startsWith(from)) { + return to.slice(from.length); + } else { + return null; + } }; npath.contains = (from, to) => contains(npath, from, to); ppath.contains = (from, to) => contains(ppath, from, to); @@ -48,1590 +48,1382 @@ const WINDOWS_PATH_REGEXP = /^([a-zA-Z]:.*)$/; const UNC_WINDOWS_PATH_REGEXP = /^\/\/(\.\/)?(.*)$/; const PORTABLE_PATH_REGEXP = /^\/([a-zA-Z]:.*)$/; const UNC_PORTABLE_PATH_REGEXP = /^\/unc\/(\.dot\/)?(.*)$/; - function fromPortablePathWin32(p) { - let portablePathMatch, uncPortablePathMatch; - if (portablePathMatch = p.match(PORTABLE_PATH_REGEXP)) - p = portablePathMatch[1]; - else if (uncPortablePathMatch = p.match(UNC_PORTABLE_PATH_REGEXP)) - p = `\\\\${uncPortablePathMatch[1] ? `.\\` : ``}${uncPortablePathMatch[2]}`; - else - return p; - return p.replace(/\//g, `\\`); -} - -function toPortablePathWin32(p) { - p = p.replace(/\\/g, `/`); - let windowsPathMatch, uncWindowsPathMatch; - if (windowsPathMatch = p.match(WINDOWS_PATH_REGEXP)) - p = `/${windowsPathMatch[1]}`; - else if (uncWindowsPathMatch = p.match(UNC_WINDOWS_PATH_REGEXP)) - p = `/unc/${uncWindowsPathMatch[1] ? `.dot/` : ``}${uncWindowsPathMatch[2]}`; + let portablePathMatch, uncPortablePathMatch; + if (portablePathMatch = p.match(PORTABLE_PATH_REGEXP)) + p = portablePathMatch[1]; + else if (uncPortablePathMatch = p.match(UNC_PORTABLE_PATH_REGEXP)) + p = `\\\\${uncPortablePathMatch[1] ? `.\\` : ``}${uncPortablePathMatch[2]}`; + else return p; + return p.replace(/\//g, `\\`); +} +function toPortablePathWin32(p) { + p = p.replace(/\\/g, `/`); + let windowsPathMatch, uncWindowsPathMatch; + if (windowsPathMatch = p.match(WINDOWS_PATH_REGEXP)) + p = `/${windowsPathMatch[1]}`; + else if (uncWindowsPathMatch = p.match(UNC_WINDOWS_PATH_REGEXP)) + p = `/unc/${uncWindowsPathMatch[1] ? `.dot/` : ``}${uncWindowsPathMatch[2]}`; + return p; } - const toPortablePath = process.platform === `win32` ? toPortablePathWin32 : (p) => p; const fromPortablePath = process.platform === `win32` ? fromPortablePathWin32 : (p) => p; npath.fromPortablePath = fromPortablePath; npath.toPortablePath = toPortablePath; - function convertPath(targetPathUtils, sourcePath) { - return targetPathUtils === npath ? fromPortablePath(sourcePath) : toPortablePath(sourcePath); + return targetPathUtils === npath ? fromPortablePath(sourcePath) : toPortablePath(sourcePath); } const defaultTime = new Date(SAFE_TIME * 1e3); const defaultTimeMs = defaultTime.getTime(); - async function copyPromise(destinationFs, destination, sourceFs, source, opts) { - const normalizedDestination = destinationFs.pathUtils.normalize(destination); - const normalizedSource = sourceFs.pathUtils.normalize(source); - const prelayout = []; - const postlayout = []; - const {atime, mtime} = opts.stableTime ? { - atime: defaultTime, - mtime: defaultTime - } : await sourceFs.lstatPromise(normalizedSource); - await destinationFs.mkdirpPromise(destinationFs.pathUtils.dirname(destination), {utimes: [atime, mtime]}); - await copyImpl(prelayout, postlayout, destinationFs, normalizedDestination, sourceFs, normalizedSource, { - ...opts, - didParentExist: true - }); - for (const operation of prelayout) - await operation(); - await Promise.all(postlayout.map((operation) => { - return operation(); - })); + const normalizedDestination = destinationFs.pathUtils.normalize(destination); + const normalizedSource = sourceFs.pathUtils.normalize(source); + const prelayout = []; + const postlayout = []; + const { atime, mtime } = opts.stableTime ? { atime: defaultTime, mtime: defaultTime } : await sourceFs.lstatPromise(normalizedSource); + await destinationFs.mkdirpPromise(destinationFs.pathUtils.dirname(destination), { utimes: [atime, mtime] }); + await copyImpl(prelayout, postlayout, destinationFs, normalizedDestination, sourceFs, normalizedSource, { ...opts, didParentExist: true }); + for (const operation of prelayout) + await operation(); + await Promise.all(postlayout.map((operation) => { + return operation(); + })); } - async function copyImpl(prelayout, postlayout, destinationFs, destination, sourceFs, source, opts) { - const destinationStat = opts.didParentExist ? await maybeLStat(destinationFs, destination) : null; - const sourceStat = await sourceFs.lstatPromise(source); - const {atime, mtime} = opts.stableTime ? {atime: defaultTime, mtime: defaultTime} : sourceStat; - let updated; - switch (true) { - case sourceStat.isDirectory(): { - updated = await copyFolder(prelayout, postlayout, destinationFs, destination, destinationStat, sourceFs, source, sourceStat, opts); - } - break; - case sourceStat.isFile(): { - updated = await copyFile(prelayout, postlayout, destinationFs, destination, destinationStat, sourceFs, source, sourceStat, opts); - } - break; - case sourceStat.isSymbolicLink(): { - updated = await copySymlink(prelayout, postlayout, destinationFs, destination, destinationStat, sourceFs, source, sourceStat, opts); - } - break; - default: { - throw new Error(`Unsupported file type (${sourceStat.mode})`); - } + const destinationStat = opts.didParentExist ? await maybeLStat(destinationFs, destination) : null; + const sourceStat = await sourceFs.lstatPromise(source); + const { atime, mtime } = opts.stableTime ? { atime: defaultTime, mtime: defaultTime } : sourceStat; + let updated; + switch (true) { + case sourceStat.isDirectory(): + { + updated = await copyFolder(prelayout, postlayout, destinationFs, destination, destinationStat, sourceFs, source, sourceStat, opts); + } + break; + case sourceStat.isFile(): + { + updated = await copyFile(prelayout, postlayout, destinationFs, destination, destinationStat, sourceFs, source, sourceStat, opts); + } + break; + case sourceStat.isSymbolicLink(): + { + updated = await copySymlink(prelayout, postlayout, destinationFs, destination, destinationStat, sourceFs, source, sourceStat, opts); + } + break; + default: { + throw new Error(`Unsupported file type (${sourceStat.mode})`); } - if (opts.linkStrategy?.type !== `HardlinkFromIndex` || !sourceStat.isFile()) { - if (updated || destinationStat?.mtime?.getTime() !== mtime.getTime() || destinationStat?.atime?.getTime() !== atime.getTime()) { - postlayout.push(() => destinationFs.lutimesPromise(destination, atime, mtime)); - updated = true; - } - if (destinationStat === null || (destinationStat.mode & 511) !== (sourceStat.mode & 511)) { - postlayout.push(() => destinationFs.chmodPromise(destination, sourceStat.mode & 511)); - updated = true; - } + } + if (opts.linkStrategy?.type !== `HardlinkFromIndex` || !sourceStat.isFile()) { + if (updated || destinationStat?.mtime?.getTime() !== mtime.getTime() || destinationStat?.atime?.getTime() !== atime.getTime()) { + postlayout.push(() => destinationFs.lutimesPromise(destination, atime, mtime)); + updated = true; } - return updated; + if (destinationStat === null || (destinationStat.mode & 511) !== (sourceStat.mode & 511)) { + postlayout.push(() => destinationFs.chmodPromise(destination, sourceStat.mode & 511)); + updated = true; + } + } + return updated; } - async function maybeLStat(baseFs, p) { - try { - return await baseFs.lstatPromise(p); - } catch (e) { - return null; - } + try { + return await baseFs.lstatPromise(p); + } catch (e) { + return null; + } } - async function copyFolder(prelayout, postlayout, destinationFs, destination, destinationStat, sourceFs, source, sourceStat, opts) { - if (destinationStat !== null && !destinationStat.isDirectory()) { - if (opts.overwrite) { - prelayout.push(async () => destinationFs.removePromise(destination)); - destinationStat = null; - } else { - return false; - } + if (destinationStat !== null && !destinationStat.isDirectory()) { + if (opts.overwrite) { + prelayout.push(async () => destinationFs.removePromise(destination)); + destinationStat = null; + } else { + return false; } - let updated = false; - if (destinationStat === null) { - prelayout.push(async () => { - try { - await destinationFs.mkdirPromise(destination, {mode: sourceStat.mode}); - } catch (err) { - if (err.code !== `EEXIST`) { - throw err; - } - } - }); + } + let updated = false; + if (destinationStat === null) { + prelayout.push(async () => { + try { + await destinationFs.mkdirPromise(destination, { mode: sourceStat.mode }); + } catch (err) { + if (err.code !== `EEXIST`) { + throw err; + } + } + }); + updated = true; + } + const entries = await sourceFs.readdirPromise(source); + const nextOpts = opts.didParentExist && !destinationStat ? { ...opts, didParentExist: false } : opts; + if (opts.stableSort) { + for (const entry of entries.sort()) { + if (await copyImpl(prelayout, postlayout, destinationFs, destinationFs.pathUtils.join(destination, entry), sourceFs, sourceFs.pathUtils.join(source, entry), nextOpts)) { updated = true; + } } - const entries = await sourceFs.readdirPromise(source); - const nextOpts = opts.didParentExist && !destinationStat ? {...opts, didParentExist: false} : opts; - if (opts.stableSort) { - for (const entry of entries.sort()) { - if (await copyImpl(prelayout, postlayout, destinationFs, destinationFs.pathUtils.join(destination, entry), sourceFs, sourceFs.pathUtils.join(source, entry), nextOpts)) { - updated = true; - } - } - } else { - const entriesUpdateStatus = await Promise.all(entries.map(async (entry) => { - await copyImpl(prelayout, postlayout, destinationFs, destinationFs.pathUtils.join(destination, entry), sourceFs, sourceFs.pathUtils.join(source, entry), nextOpts); - })); - if (entriesUpdateStatus.some((status) => status)) { - updated = true; - } + } else { + const entriesUpdateStatus = await Promise.all(entries.map(async (entry) => { + await copyImpl(prelayout, postlayout, destinationFs, destinationFs.pathUtils.join(destination, entry), sourceFs, sourceFs.pathUtils.join(source, entry), nextOpts); + })); + if (entriesUpdateStatus.some((status) => status)) { + updated = true; } - return updated; + } + return updated; } - async function copyFileViaIndex(prelayout, postlayout, destinationFs, destination, destinationStat, sourceFs, source, sourceStat, opts, linkStrategy) { - const sourceHash = await sourceFs.checksumFilePromise(source, {algorithm: `sha1`}); - const defaultMode = 420; - const sourceMode = sourceStat.mode & 511; - const indexFileName = `${sourceHash}${sourceMode !== defaultMode ? sourceMode.toString(8) : ``}`; - const indexPath = destinationFs.pathUtils.join(linkStrategy.indexPath, sourceHash.slice(0, 2), `${indexFileName}.dat`); - let AtomicBehavior; - ((AtomicBehavior2) => { - AtomicBehavior2[AtomicBehavior2["Lock"] = 0] = "Lock"; - AtomicBehavior2[AtomicBehavior2["Rename"] = 1] = "Rename"; - })(AtomicBehavior || (AtomicBehavior = {})); - let atomicBehavior = 1 /* Rename */; - let indexStat = await maybeLStat(destinationFs, indexPath); - if (destinationStat) { - const isDestinationHardlinkedFromIndex = indexStat && destinationStat.dev === indexStat.dev && destinationStat.ino === indexStat.ino; - const isIndexModified = indexStat?.mtimeMs !== defaultTimeMs; - if (isDestinationHardlinkedFromIndex) { - if (isIndexModified && linkStrategy.autoRepair) { - atomicBehavior = 0 /* Lock */; - indexStat = null; - } - } - if (!isDestinationHardlinkedFromIndex) { - if (opts.overwrite) { - prelayout.push(async () => destinationFs.removePromise(destination)); - destinationStat = null; - } else { - return false; - } - } + const sourceHash = await sourceFs.checksumFilePromise(source, { algorithm: `sha1` }); + const defaultMode = 420; + const sourceMode = sourceStat.mode & 511; + const indexFileName = `${sourceHash}${sourceMode !== defaultMode ? sourceMode.toString(8) : ``}`; + const indexPath = destinationFs.pathUtils.join(linkStrategy.indexPath, sourceHash.slice(0, 2), `${indexFileName}.dat`); + let AtomicBehavior; + ((AtomicBehavior2) => { + AtomicBehavior2[AtomicBehavior2["Lock"] = 0] = "Lock"; + AtomicBehavior2[AtomicBehavior2["Rename"] = 1] = "Rename"; + })(AtomicBehavior || (AtomicBehavior = {})); + let atomicBehavior = 1 /* Rename */; + let indexStat = await maybeLStat(destinationFs, indexPath); + if (destinationStat) { + const isDestinationHardlinkedFromIndex = indexStat && destinationStat.dev === indexStat.dev && destinationStat.ino === indexStat.ino; + const isIndexModified = indexStat?.mtimeMs !== defaultTimeMs; + if (isDestinationHardlinkedFromIndex) { + if (isIndexModified && linkStrategy.autoRepair) { + atomicBehavior = 0 /* Lock */; + indexStat = null; + } } - const tempPath = !indexStat && atomicBehavior === 1 /* Rename */ ? `${indexPath}.${Math.floor(Math.random() * 4294967296).toString(16).padStart(8, `0`)}` : null; - let tempPathCleaned = false; - prelayout.push(async () => { - if (!indexStat) { - if (atomicBehavior === 0 /* Lock */) { - await destinationFs.lockPromise(indexPath, async () => { - const content = await sourceFs.readFilePromise(source); - await destinationFs.writeFilePromise(indexPath, content); - }); - } - if (atomicBehavior === 1 /* Rename */ && tempPath) { - const content = await sourceFs.readFilePromise(source); - await destinationFs.writeFilePromise(tempPath, content); - try { - await destinationFs.linkPromise(tempPath, indexPath); - } catch (err) { - if (err.code === `EEXIST`) { - tempPathCleaned = true; - await destinationFs.unlinkPromise(tempPath); - } else { - throw err; - } - } - } - } - if (!destinationStat) { - await destinationFs.linkPromise(indexPath, destination); - } - }); - postlayout.push(async () => { - if (!indexStat) { - await destinationFs.lutimesPromise(indexPath, defaultTime, defaultTime); - if (sourceMode !== defaultMode) { - await destinationFs.chmodPromise(indexPath, sourceMode); - } - } - if (tempPath && !tempPathCleaned) { - await destinationFs.unlinkPromise(tempPath); - } - }); - return false; -} - -async function copyFileDirect(prelayout, postlayout, destinationFs, destination, destinationStat, sourceFs, source, sourceStat, opts) { - if (destinationStat !== null) { - if (opts.overwrite) { - prelayout.push(async () => destinationFs.removePromise(destination)); - destinationStat = null; - } else { - return false; - } + if (!isDestinationHardlinkedFromIndex) { + if (opts.overwrite) { + prelayout.push(async () => destinationFs.removePromise(destination)); + destinationStat = null; + } else { + return false; + } } - prelayout.push(async () => { + } + const tempPath = !indexStat && atomicBehavior === 1 /* Rename */ ? `${indexPath}.${Math.floor(Math.random() * 4294967296).toString(16).padStart(8, `0`)}` : null; + let tempPathCleaned = false; + prelayout.push(async () => { + if (!indexStat) { + if (atomicBehavior === 0 /* Lock */) { + await destinationFs.lockPromise(indexPath, async () => { + const content = await sourceFs.readFilePromise(source); + await destinationFs.writeFilePromise(indexPath, content); + }); + } + if (atomicBehavior === 1 /* Rename */ && tempPath) { const content = await sourceFs.readFilePromise(source); - await destinationFs.writeFilePromise(destination, content); - }); - return true; -} - -async function copyFile(prelayout, postlayout, destinationFs, destination, destinationStat, sourceFs, source, sourceStat, opts) { - if (opts.linkStrategy?.type === `HardlinkFromIndex`) { - return copyFileViaIndex(prelayout, postlayout, destinationFs, destination, destinationStat, sourceFs, source, sourceStat, opts, opts.linkStrategy); - } else { - return copyFileDirect(prelayout, postlayout, destinationFs, destination, destinationStat, sourceFs, source, sourceStat, opts); - } -} - -async function copySymlink(prelayout, postlayout, destinationFs, destination, destinationStat, sourceFs, source, sourceStat, opts) { - if (destinationStat !== null) { - if (opts.overwrite) { - prelayout.push(async () => destinationFs.removePromise(destination)); - destinationStat = null; - } else { - return false; + await destinationFs.writeFilePromise(tempPath, content); + try { + await destinationFs.linkPromise(tempPath, indexPath); + } catch (err) { + if (err.code === `EEXIST`) { + tempPathCleaned = true; + await destinationFs.unlinkPromise(tempPath); + } else { + throw err; + } } + } } - prelayout.push(async () => { - await destinationFs.symlinkPromise(convertPath(destinationFs.pathUtils, await sourceFs.readlinkPromise(source)), destination); - }); - return true; + if (!destinationStat) { + await destinationFs.linkPromise(indexPath, destination); + } + }); + postlayout.push(async () => { + if (!indexStat) { + await destinationFs.lutimesPromise(indexPath, defaultTime, defaultTime); + if (sourceMode !== defaultMode) { + await destinationFs.chmodPromise(indexPath, sourceMode); + } + } + if (tempPath && !tempPathCleaned) { + await destinationFs.unlinkPromise(tempPath); + } + }); + return false; +} +async function copyFileDirect(prelayout, postlayout, destinationFs, destination, destinationStat, sourceFs, source, sourceStat, opts) { + if (destinationStat !== null) { + if (opts.overwrite) { + prelayout.push(async () => destinationFs.removePromise(destination)); + destinationStat = null; + } else { + return false; + } + } + prelayout.push(async () => { + const content = await sourceFs.readFilePromise(source); + await destinationFs.writeFilePromise(destination, content); + }); + return true; +} +async function copyFile(prelayout, postlayout, destinationFs, destination, destinationStat, sourceFs, source, sourceStat, opts) { + if (opts.linkStrategy?.type === `HardlinkFromIndex`) { + return copyFileViaIndex(prelayout, postlayout, destinationFs, destination, destinationStat, sourceFs, source, sourceStat, opts, opts.linkStrategy); + } else { + return copyFileDirect(prelayout, postlayout, destinationFs, destination, destinationStat, sourceFs, source, sourceStat, opts); + } +} +async function copySymlink(prelayout, postlayout, destinationFs, destination, destinationStat, sourceFs, source, sourceStat, opts) { + if (destinationStat !== null) { + if (opts.overwrite) { + prelayout.push(async () => destinationFs.removePromise(destination)); + destinationStat = null; + } else { + return false; + } + } + prelayout.push(async () => { + await destinationFs.symlinkPromise(convertPath(destinationFs.pathUtils, await sourceFs.readlinkPromise(source)), destination); + }); + return true; } class FakeFS { - pathUtils; - - constructor(pathUtils) { - this.pathUtils = pathUtils; - } - - async* genTraversePromise(init, {stableSort = false} = {}) { - const stack = [init]; - while (stack.length > 0) { - const p = stack.shift(); - const entry = await this.lstatPromise(p); - if (entry.isDirectory()) { - const entries = await this.readdirPromise(p); - if (stableSort) { - for (const entry2 of entries.sort()) { - stack.push(this.pathUtils.join(p, entry2)); - } - } else { - throw new Error(`Not supported`); - } - } else { - yield p; - } - } - } - - async checksumFilePromise(path, {algorithm = `sha512`} = {}) { - const fd = await this.openPromise(path, `r`); - try { - const CHUNK_SIZE = 65536; - const chunk = Buffer.allocUnsafeSlow(CHUNK_SIZE); - const hash = createHash(algorithm); - let bytesRead = 0; - while ((bytesRead = await this.readPromise(fd, chunk, 0, CHUNK_SIZE)) !== 0) - hash.update(bytesRead === CHUNK_SIZE ? chunk : chunk.slice(0, bytesRead)); - return hash.digest(`hex`); - } finally { - await this.closePromise(fd); - } - } - - async removePromise(p, {recursive = true, maxRetries = 5} = {}) { - let stat; - try { - stat = await this.lstatPromise(p); - } catch (error) { - if (error.code === `ENOENT`) { - return; - } else { - throw error; - } - } - if (stat.isDirectory()) { - if (recursive) { - const entries = await this.readdirPromise(p); - await Promise.all(entries.map((entry) => { - return this.removePromise(this.pathUtils.resolve(p, entry)); - })); - } - for (let t = 0; t <= maxRetries; t++) { - try { - await this.rmdirPromise(p); - break; - } catch (error) { - if (error.code !== `EBUSY` && error.code !== `ENOTEMPTY`) { - throw error; - } else if (t < maxRetries) { - await new Promise((resolve) => setTimeout(resolve, t * 100)); - } - } - } + pathUtils; + constructor(pathUtils) { + this.pathUtils = pathUtils; + } + async *genTraversePromise(init, { stableSort = false } = {}) { + const stack = [init]; + while (stack.length > 0) { + const p = stack.shift(); + const entry = await this.lstatPromise(p); + if (entry.isDirectory()) { + const entries = await this.readdirPromise(p); + if (stableSort) { + for (const entry2 of entries.sort()) { + stack.push(this.pathUtils.join(p, entry2)); + } } else { - await this.unlinkPromise(p); + throw new Error(`Not supported`); } + } else { + yield p; + } } - - removeSync(p, {recursive = true} = {}) { - let stat; + } + async checksumFilePromise(path, { algorithm = `sha512` } = {}) { + const fd = await this.openPromise(path, `r`); + try { + const CHUNK_SIZE = 65536; + const chunk = Buffer.allocUnsafeSlow(CHUNK_SIZE); + const hash = createHash(algorithm); + let bytesRead = 0; + while ((bytesRead = await this.readPromise(fd, chunk, 0, CHUNK_SIZE)) !== 0) + hash.update(bytesRead === CHUNK_SIZE ? chunk : chunk.slice(0, bytesRead)); + return hash.digest(`hex`); + } finally { + await this.closePromise(fd); + } + } + async removePromise(p, { recursive = true, maxRetries = 5 } = {}) { + let stat; + try { + stat = await this.lstatPromise(p); + } catch (error) { + if (error.code === `ENOENT`) { + return; + } else { + throw error; + } + } + if (stat.isDirectory()) { + if (recursive) { + const entries = await this.readdirPromise(p); + await Promise.all(entries.map((entry) => { + return this.removePromise(this.pathUtils.resolve(p, entry)); + })); + } + for (let t = 0; t <= maxRetries; t++) { try { - stat = this.lstatSync(p); + await this.rmdirPromise(p); + break; } catch (error) { - if (error.code === `ENOENT`) { - return; - } else { - throw error; - } - } - if (stat.isDirectory()) { - if (recursive) - for (const entry of this.readdirSync(p)) - this.removeSync(this.pathUtils.resolve(p, entry)); - this.rmdirSync(p); - } else { - this.unlinkSync(p); - } - } - - async mkdirpPromise(p, {chmod, utimes} = {}) { - p = this.resolve(p); - if (p === this.pathUtils.dirname(p)) - return void 0; - const parts = p.split(this.pathUtils.sep); - let createdDirectory; - for (let u = 2; u <= parts.length; ++u) { - const subPath = parts.slice(0, u).join(this.pathUtils.sep); - if (!this.existsSync(subPath)) { - try { - await this.mkdirPromise(subPath); - } catch (error) { - if (error.code === `EEXIST`) { - continue; - } else { - throw error; - } - } - createdDirectory ??= subPath; - if (chmod != null) - await this.chmodPromise(subPath, chmod); - if (utimes != null) { - await this.utimesPromise(subPath, utimes[0], utimes[1]); - } else { - const parentStat = await this.statPromise(this.pathUtils.dirname(subPath)); - await this.utimesPromise(subPath, parentStat.atime, parentStat.mtime); - } - } - } - return createdDirectory; - } - - mkdirpSync(p, {chmod, utimes} = {}) { - p = this.resolve(p); - if (p === this.pathUtils.dirname(p)) - return void 0; - const parts = p.split(this.pathUtils.sep); - let createdDirectory; - for (let u = 2; u <= parts.length; ++u) { - const subPath = parts.slice(0, u).join(this.pathUtils.sep); - if (!this.existsSync(subPath)) { - try { - this.mkdirSync(subPath); - } catch (error) { - if (error.code === `EEXIST`) { - continue; - } else { - throw error; - } - } - createdDirectory ??= subPath; - if (chmod != null) - this.chmodSync(subPath, chmod); - if (utimes != null) { - this.utimesSync(subPath, utimes[0], utimes[1]); - } else { - const parentStat = this.statSync(this.pathUtils.dirname(subPath)); - this.utimesSync(subPath, parentStat.atime, parentStat.mtime); - } - } - } - return createdDirectory; - } - - async copyPromise(destination, source, { - baseFs = this, - overwrite = true, - stableSort = false, - stableTime = false, - linkStrategy = null - } = {}) { - return await copyPromise(this, destination, baseFs, source, {overwrite, stableSort, stableTime, linkStrategy}); - } - - copySync(destination, source, {baseFs = this, overwrite = true} = {}) { - const stat = baseFs.lstatSync(source); - const exists = this.existsSync(destination); - if (stat.isDirectory()) { - this.mkdirpSync(destination); - const directoryListing = baseFs.readdirSync(source); - for (const entry of directoryListing) { - this.copySync(this.pathUtils.join(destination, entry), baseFs.pathUtils.join(source, entry), { - baseFs, - overwrite - }); - } - } else if (stat.isFile()) { - if (!exists || overwrite) { - if (exists) - this.removeSync(destination); - const content = baseFs.readFileSync(source); - this.writeFileSync(destination, content); - } - } else if (stat.isSymbolicLink()) { - if (!exists || overwrite) { - if (exists) - this.removeSync(destination); - const target = baseFs.readlinkSync(source); - this.symlinkSync(convertPath(this.pathUtils, target), destination); - } - } else { - throw new Error(`Unsupported file type (file: ${source}, mode: 0o${stat.mode.toString(8).padStart(6, `0`)})`); - } - const mode = stat.mode & 511; - this.chmodSync(destination, mode); - } - - async changeFilePromise(p, content, opts = {}) { - if (Buffer.isBuffer(content)) { - return this.changeFileBufferPromise(p, content, opts); - } else { - return this.changeFileTextPromise(p, content, opts); - } - } - - async changeFileBufferPromise(p, content, {mode} = {}) { - let current = Buffer.alloc(0); - try { - current = await this.readFilePromise(p); - } catch (error) { - } - if (Buffer.compare(current, content) === 0) - return; - await this.writeFilePromise(p, content, {mode}); - } - - async changeFileTextPromise(p, content, {automaticNewlines, mode} = {}) { - let current = ``; - try { - current = await this.readFilePromise(p, `utf8`); - } catch (error) { - } - const normalizedContent = automaticNewlines ? normalizeLineEndings(current, content) : content; - if (current === normalizedContent) - return; - await this.writeFilePromise(p, normalizedContent, {mode}); - } - - changeFileSync(p, content, opts = {}) { - if (Buffer.isBuffer(content)) { - return this.changeFileBufferSync(p, content, opts); - } else { - return this.changeFileTextSync(p, content, opts); - } - } - - changeFileBufferSync(p, content, {mode} = {}) { - let current = Buffer.alloc(0); - try { - current = this.readFileSync(p); - } catch (error) { - } - if (Buffer.compare(current, content) === 0) - return; - this.writeFileSync(p, content, {mode}); - } - - changeFileTextSync(p, content, {automaticNewlines = false, mode} = {}) { - let current = ``; - try { - current = this.readFileSync(p, `utf8`); - } catch (error) { - } - const normalizedContent = automaticNewlines ? normalizeLineEndings(current, content) : content; - if (current === normalizedContent) - return; - this.writeFileSync(p, normalizedContent, {mode}); - } - - async movePromise(fromP, toP) { - try { - await this.renamePromise(fromP, toP); - } catch (error) { - if (error.code === `EXDEV`) { - await this.copyPromise(toP, fromP); - await this.removePromise(fromP); - } else { - throw error; - } - } - } - - moveSync(fromP, toP) { - try { - this.renameSync(fromP, toP); - } catch (error) { - if (error.code === `EXDEV`) { - this.copySync(toP, fromP); - this.removeSync(fromP); - } else { - throw error; - } - } - } - - async lockPromise(affectedPath, callback) { - const lockPath = `${affectedPath}.flock`; - const interval = 1e3 / 60; - const startTime = Date.now(); - let fd = null; - const isAlive = async () => { - let pid; - try { - [pid] = await this.readJsonPromise(lockPath); - } catch (error) { - return Date.now() - startTime < 500; - } - try { - process.kill(pid, 0); - return true; - } catch (error) { - return false; - } - }; - while (fd === null) { - try { - fd = await this.openPromise(lockPath, `wx`); - } catch (error) { - if (error.code === `EEXIST`) { - if (!await isAlive()) { - try { - await this.unlinkPromise(lockPath); - continue; - } catch (error2) { - } - } - if (Date.now() - startTime < 60 * 1e3) { - await new Promise((resolve) => setTimeout(resolve, interval)); - } else { - throw new Error(`Couldn't acquire a lock in a reasonable time (via ${lockPath})`); - } - } else { - throw error; - } - } - } - await this.writePromise(fd, JSON.stringify([process.pid])); - try { - return await callback(); - } finally { - try { - await this.closePromise(fd); - await this.unlinkPromise(lockPath); - } catch (error) { - } - } - } - - async readJsonPromise(p) { - const content = await this.readFilePromise(p, `utf8`); - try { - return JSON.parse(content); - } catch (error) { - error.message += ` (in ${p})`; + if (error.code !== `EBUSY` && error.code !== `ENOTEMPTY`) { throw error; + } else if (t < maxRetries) { + await new Promise((resolve) => setTimeout(resolve, t * 100)); + } } + } + } else { + await this.unlinkPromise(p); } - - readJsonSync(p) { - const content = this.readFileSync(p, `utf8`); + } + removeSync(p, { recursive = true } = {}) { + let stat; + try { + stat = this.lstatSync(p); + } catch (error) { + if (error.code === `ENOENT`) { + return; + } else { + throw error; + } + } + if (stat.isDirectory()) { + if (recursive) + for (const entry of this.readdirSync(p)) + this.removeSync(this.pathUtils.resolve(p, entry)); + this.rmdirSync(p); + } else { + this.unlinkSync(p); + } + } + async mkdirpPromise(p, { chmod, utimes } = {}) { + p = this.resolve(p); + if (p === this.pathUtils.dirname(p)) + return void 0; + const parts = p.split(this.pathUtils.sep); + let createdDirectory; + for (let u = 2; u <= parts.length; ++u) { + const subPath = parts.slice(0, u).join(this.pathUtils.sep); + if (!this.existsSync(subPath)) { try { - return JSON.parse(content); + await this.mkdirPromise(subPath); } catch (error) { - error.message += ` (in ${p})`; + if (error.code === `EEXIST`) { + continue; + } else { throw error; + } } + createdDirectory ??= subPath; + if (chmod != null) + await this.chmodPromise(subPath, chmod); + if (utimes != null) { + await this.utimesPromise(subPath, utimes[0], utimes[1]); + } else { + const parentStat = await this.statPromise(this.pathUtils.dirname(subPath)); + await this.utimesPromise(subPath, parentStat.atime, parentStat.mtime); + } + } } - - async writeJsonPromise(p, data, {compact = false} = {}) { - const space = compact ? 0 : 2; - return await this.writeFilePromise(p, `${JSON.stringify(data, null, space)} + return createdDirectory; + } + mkdirpSync(p, { chmod, utimes } = {}) { + p = this.resolve(p); + if (p === this.pathUtils.dirname(p)) + return void 0; + const parts = p.split(this.pathUtils.sep); + let createdDirectory; + for (let u = 2; u <= parts.length; ++u) { + const subPath = parts.slice(0, u).join(this.pathUtils.sep); + if (!this.existsSync(subPath)) { + try { + this.mkdirSync(subPath); + } catch (error) { + if (error.code === `EEXIST`) { + continue; + } else { + throw error; + } + } + createdDirectory ??= subPath; + if (chmod != null) + this.chmodSync(subPath, chmod); + if (utimes != null) { + this.utimesSync(subPath, utimes[0], utimes[1]); + } else { + const parentStat = this.statSync(this.pathUtils.dirname(subPath)); + this.utimesSync(subPath, parentStat.atime, parentStat.mtime); + } + } + } + return createdDirectory; + } + async copyPromise(destination, source, { baseFs = this, overwrite = true, stableSort = false, stableTime = false, linkStrategy = null } = {}) { + return await copyPromise(this, destination, baseFs, source, { overwrite, stableSort, stableTime, linkStrategy }); + } + copySync(destination, source, { baseFs = this, overwrite = true } = {}) { + const stat = baseFs.lstatSync(source); + const exists = this.existsSync(destination); + if (stat.isDirectory()) { + this.mkdirpSync(destination); + const directoryListing = baseFs.readdirSync(source); + for (const entry of directoryListing) { + this.copySync(this.pathUtils.join(destination, entry), baseFs.pathUtils.join(source, entry), { baseFs, overwrite }); + } + } else if (stat.isFile()) { + if (!exists || overwrite) { + if (exists) + this.removeSync(destination); + const content = baseFs.readFileSync(source); + this.writeFileSync(destination, content); + } + } else if (stat.isSymbolicLink()) { + if (!exists || overwrite) { + if (exists) + this.removeSync(destination); + const target = baseFs.readlinkSync(source); + this.symlinkSync(convertPath(this.pathUtils, target), destination); + } + } else { + throw new Error(`Unsupported file type (file: ${source}, mode: 0o${stat.mode.toString(8).padStart(6, `0`)})`); + } + const mode = stat.mode & 511; + this.chmodSync(destination, mode); + } + async changeFilePromise(p, content, opts = {}) { + if (Buffer.isBuffer(content)) { + return this.changeFileBufferPromise(p, content, opts); + } else { + return this.changeFileTextPromise(p, content, opts); + } + } + async changeFileBufferPromise(p, content, { mode } = {}) { + let current = Buffer.alloc(0); + try { + current = await this.readFilePromise(p); + } catch (error) { + } + if (Buffer.compare(current, content) === 0) + return; + await this.writeFilePromise(p, content, { mode }); + } + async changeFileTextPromise(p, content, { automaticNewlines, mode } = {}) { + let current = ``; + try { + current = await this.readFilePromise(p, `utf8`); + } catch (error) { + } + const normalizedContent = automaticNewlines ? normalizeLineEndings(current, content) : content; + if (current === normalizedContent) + return; + await this.writeFilePromise(p, normalizedContent, { mode }); + } + changeFileSync(p, content, opts = {}) { + if (Buffer.isBuffer(content)) { + return this.changeFileBufferSync(p, content, opts); + } else { + return this.changeFileTextSync(p, content, opts); + } + } + changeFileBufferSync(p, content, { mode } = {}) { + let current = Buffer.alloc(0); + try { + current = this.readFileSync(p); + } catch (error) { + } + if (Buffer.compare(current, content) === 0) + return; + this.writeFileSync(p, content, { mode }); + } + changeFileTextSync(p, content, { automaticNewlines = false, mode } = {}) { + let current = ``; + try { + current = this.readFileSync(p, `utf8`); + } catch (error) { + } + const normalizedContent = automaticNewlines ? normalizeLineEndings(current, content) : content; + if (current === normalizedContent) + return; + this.writeFileSync(p, normalizedContent, { mode }); + } + async movePromise(fromP, toP) { + try { + await this.renamePromise(fromP, toP); + } catch (error) { + if (error.code === `EXDEV`) { + await this.copyPromise(toP, fromP); + await this.removePromise(fromP); + } else { + throw error; + } + } + } + moveSync(fromP, toP) { + try { + this.renameSync(fromP, toP); + } catch (error) { + if (error.code === `EXDEV`) { + this.copySync(toP, fromP); + this.removeSync(fromP); + } else { + throw error; + } + } + } + async lockPromise(affectedPath, callback) { + const lockPath = `${affectedPath}.flock`; + const interval = 1e3 / 60; + const startTime = Date.now(); + let fd = null; + const isAlive = async () => { + let pid; + try { + [pid] = await this.readJsonPromise(lockPath); + } catch (error) { + return Date.now() - startTime < 500; + } + try { + process.kill(pid, 0); + return true; + } catch (error) { + return false; + } + }; + while (fd === null) { + try { + fd = await this.openPromise(lockPath, `wx`); + } catch (error) { + if (error.code === `EEXIST`) { + if (!await isAlive()) { + try { + await this.unlinkPromise(lockPath); + continue; + } catch (error2) { + } + } + if (Date.now() - startTime < 60 * 1e3) { + await new Promise((resolve) => setTimeout(resolve, interval)); + } else { + throw new Error(`Couldn't acquire a lock in a reasonable time (via ${lockPath})`); + } + } else { + throw error; + } + } + } + await this.writePromise(fd, JSON.stringify([process.pid])); + try { + return await callback(); + } finally { + try { + await this.closePromise(fd); + await this.unlinkPromise(lockPath); + } catch (error) { + } + } + } + async readJsonPromise(p) { + const content = await this.readFilePromise(p, `utf8`); + try { + return JSON.parse(content); + } catch (error) { + error.message += ` (in ${p})`; + throw error; + } + } + readJsonSync(p) { + const content = this.readFileSync(p, `utf8`); + try { + return JSON.parse(content); + } catch (error) { + error.message += ` (in ${p})`; + throw error; + } + } + async writeJsonPromise(p, data, { compact = false } = {}) { + const space = compact ? 0 : 2; + return await this.writeFilePromise(p, `${JSON.stringify(data, null, space)} `); - } - - writeJsonSync(p, data, {compact = false} = {}) { - const space = compact ? 0 : 2; - return this.writeFileSync(p, `${JSON.stringify(data, null, space)} + } + writeJsonSync(p, data, { compact = false } = {}) { + const space = compact ? 0 : 2; + return this.writeFileSync(p, `${JSON.stringify(data, null, space)} `); - } - - async preserveTimePromise(p, cb) { - const stat = await this.lstatPromise(p); - const result = await cb(); - if (typeof result !== `undefined`) - p = result; - await this.lutimesPromise(p, stat.atime, stat.mtime); - } - - async preserveTimeSync(p, cb) { - const stat = this.lstatSync(p); - const result = cb(); - if (typeof result !== `undefined`) - p = result; - this.lutimesSync(p, stat.atime, stat.mtime); - } + } + async preserveTimePromise(p, cb) { + const stat = await this.lstatPromise(p); + const result = await cb(); + if (typeof result !== `undefined`) + p = result; + await this.lutimesPromise(p, stat.atime, stat.mtime); + } + async preserveTimeSync(p, cb) { + const stat = this.lstatSync(p); + const result = cb(); + if (typeof result !== `undefined`) + p = result; + this.lutimesSync(p, stat.atime, stat.mtime); + } } - class BasePortableFakeFS extends FakeFS { - constructor() { - super(ppath); - } + constructor() { + super(ppath); + } } - function getEndOfLine(content) { - const matches = content.match(/\r?\n/g); - if (matches === null) - return EOL; - const crlf = matches.filter((nl) => nl === `\r + const matches = content.match(/\r?\n/g); + if (matches === null) + return EOL; + const crlf = matches.filter((nl) => nl === `\r `).length; - const lf = matches.length - crlf; - return crlf > lf ? `\r + const lf = matches.length - crlf; + return crlf > lf ? `\r ` : ` `; } - function normalizeLineEndings(originalContent, newContent) { - return newContent.replace(/\r?\n/g, getEndOfLine(originalContent)); + return newContent.replace(/\r?\n/g, getEndOfLine(originalContent)); } class ProxiedFS extends FakeFS { - getExtractHint(hints) { - return this.baseFs.getExtractHint(hints); - } - - resolve(path) { - return this.mapFromBase(this.baseFs.resolve(this.mapToBase(path))); - } - - getRealPath() { - return this.mapFromBase(this.baseFs.getRealPath()); - } - - async openPromise(p, flags, mode) { - return this.baseFs.openPromise(this.mapToBase(p), flags, mode); - } - - openSync(p, flags, mode) { - return this.baseFs.openSync(this.mapToBase(p), flags, mode); - } - - async opendirPromise(p, opts) { - return Object.assign(await this.baseFs.opendirPromise(this.mapToBase(p), opts), {path: p}); - } - - opendirSync(p, opts) { - return Object.assign(this.baseFs.opendirSync(this.mapToBase(p), opts), {path: p}); - } - - async readPromise(fd, buffer, offset, length, position) { - return await this.baseFs.readPromise(fd, buffer, offset, length, position); - } - - readSync(fd, buffer, offset, length, position) { - return this.baseFs.readSync(fd, buffer, offset, length, position); - } - - async writePromise(fd, buffer, offset, length, position) { - if (typeof buffer === `string`) { - return await this.baseFs.writePromise(fd, buffer, offset); - } else { - return await this.baseFs.writePromise(fd, buffer, offset, length, position); - } - } - - writeSync(fd, buffer, offset, length, position) { - if (typeof buffer === `string`) { - return this.baseFs.writeSync(fd, buffer, offset); - } else { - return this.baseFs.writeSync(fd, buffer, offset, length, position); - } - } - - async closePromise(fd) { - return this.baseFs.closePromise(fd); - } - - closeSync(fd) { - this.baseFs.closeSync(fd); - } - - createReadStream(p, opts) { - return this.baseFs.createReadStream(p !== null ? this.mapToBase(p) : p, opts); - } - - createWriteStream(p, opts) { - return this.baseFs.createWriteStream(p !== null ? this.mapToBase(p) : p, opts); - } - - async realpathPromise(p) { - return this.mapFromBase(await this.baseFs.realpathPromise(this.mapToBase(p))); - } - - realpathSync(p) { - return this.mapFromBase(this.baseFs.realpathSync(this.mapToBase(p))); - } - - async existsPromise(p) { - return this.baseFs.existsPromise(this.mapToBase(p)); - } - - existsSync(p) { - return this.baseFs.existsSync(this.mapToBase(p)); - } - - accessSync(p, mode) { - return this.baseFs.accessSync(this.mapToBase(p), mode); - } - - async accessPromise(p, mode) { - return this.baseFs.accessPromise(this.mapToBase(p), mode); - } - - async statPromise(p, opts) { - return this.baseFs.statPromise(this.mapToBase(p), opts); - } - - statSync(p, opts) { - return this.baseFs.statSync(this.mapToBase(p), opts); - } - - async fstatPromise(fd, opts) { - return this.baseFs.fstatPromise(fd, opts); - } - - fstatSync(fd, opts) { - return this.baseFs.fstatSync(fd, opts); - } - - lstatPromise(p, opts) { - return this.baseFs.lstatPromise(this.mapToBase(p), opts); - } - - lstatSync(p, opts) { - return this.baseFs.lstatSync(this.mapToBase(p), opts); - } - - async fchmodPromise(fd, mask) { - return this.baseFs.fchmodPromise(fd, mask); - } - - fchmodSync(fd, mask) { - return this.baseFs.fchmodSync(fd, mask); - } - - async chmodPromise(p, mask) { - return this.baseFs.chmodPromise(this.mapToBase(p), mask); - } - - chmodSync(p, mask) { - return this.baseFs.chmodSync(this.mapToBase(p), mask); - } - - async fchownPromise(fd, uid, gid) { - return this.baseFs.fchownPromise(fd, uid, gid); - } - - fchownSync(fd, uid, gid) { - return this.baseFs.fchownSync(fd, uid, gid); - } - - async chownPromise(p, uid, gid) { - return this.baseFs.chownPromise(this.mapToBase(p), uid, gid); - } - - chownSync(p, uid, gid) { - return this.baseFs.chownSync(this.mapToBase(p), uid, gid); - } - - async renamePromise(oldP, newP) { - return this.baseFs.renamePromise(this.mapToBase(oldP), this.mapToBase(newP)); - } - - renameSync(oldP, newP) { - return this.baseFs.renameSync(this.mapToBase(oldP), this.mapToBase(newP)); - } - - async copyFilePromise(sourceP, destP, flags = 0) { - return this.baseFs.copyFilePromise(this.mapToBase(sourceP), this.mapToBase(destP), flags); - } - - copyFileSync(sourceP, destP, flags = 0) { - return this.baseFs.copyFileSync(this.mapToBase(sourceP), this.mapToBase(destP), flags); - } - - async appendFilePromise(p, content, opts) { - return this.baseFs.appendFilePromise(this.fsMapToBase(p), content, opts); - } - - appendFileSync(p, content, opts) { - return this.baseFs.appendFileSync(this.fsMapToBase(p), content, opts); - } - - async writeFilePromise(p, content, opts) { - return this.baseFs.writeFilePromise(this.fsMapToBase(p), content, opts); - } - - writeFileSync(p, content, opts) { - return this.baseFs.writeFileSync(this.fsMapToBase(p), content, opts); - } - - async unlinkPromise(p) { - return this.baseFs.unlinkPromise(this.mapToBase(p)); - } - - unlinkSync(p) { - return this.baseFs.unlinkSync(this.mapToBase(p)); - } - - async utimesPromise(p, atime, mtime) { - return this.baseFs.utimesPromise(this.mapToBase(p), atime, mtime); - } - - utimesSync(p, atime, mtime) { - return this.baseFs.utimesSync(this.mapToBase(p), atime, mtime); - } - - async lutimesPromise(p, atime, mtime) { - return this.baseFs.lutimesPromise(this.mapToBase(p), atime, mtime); - } - - lutimesSync(p, atime, mtime) { - return this.baseFs.lutimesSync(this.mapToBase(p), atime, mtime); - } - - async mkdirPromise(p, opts) { - return this.baseFs.mkdirPromise(this.mapToBase(p), opts); - } - - mkdirSync(p, opts) { - return this.baseFs.mkdirSync(this.mapToBase(p), opts); - } - - async rmdirPromise(p, opts) { - return this.baseFs.rmdirPromise(this.mapToBase(p), opts); - } - - rmdirSync(p, opts) { - return this.baseFs.rmdirSync(this.mapToBase(p), opts); - } - - async rmPromise(p, opts) { - return this.baseFs.rmPromise(this.mapToBase(p), opts); - } - - rmSync(p, opts) { - return this.baseFs.rmSync(this.mapToBase(p), opts); - } - - async linkPromise(existingP, newP) { - return this.baseFs.linkPromise(this.mapToBase(existingP), this.mapToBase(newP)); - } - - linkSync(existingP, newP) { - return this.baseFs.linkSync(this.mapToBase(existingP), this.mapToBase(newP)); - } - - async symlinkPromise(target, p, type) { - const mappedP = this.mapToBase(p); - if (this.pathUtils.isAbsolute(target)) - return this.baseFs.symlinkPromise(this.mapToBase(target), mappedP, type); - const mappedAbsoluteTarget = this.mapToBase(this.pathUtils.join(this.pathUtils.dirname(p), target)); - const mappedTarget = this.baseFs.pathUtils.relative(this.baseFs.pathUtils.dirname(mappedP), mappedAbsoluteTarget); - return this.baseFs.symlinkPromise(mappedTarget, mappedP, type); - } - - symlinkSync(target, p, type) { - const mappedP = this.mapToBase(p); - if (this.pathUtils.isAbsolute(target)) - return this.baseFs.symlinkSync(this.mapToBase(target), mappedP, type); - const mappedAbsoluteTarget = this.mapToBase(this.pathUtils.join(this.pathUtils.dirname(p), target)); - const mappedTarget = this.baseFs.pathUtils.relative(this.baseFs.pathUtils.dirname(mappedP), mappedAbsoluteTarget); - return this.baseFs.symlinkSync(mappedTarget, mappedP, type); - } - - async readFilePromise(p, encoding) { - return this.baseFs.readFilePromise(this.fsMapToBase(p), encoding); - } - - readFileSync(p, encoding) { - return this.baseFs.readFileSync(this.fsMapToBase(p), encoding); - } - - readdirPromise(p, opts) { - return this.baseFs.readdirPromise(this.mapToBase(p), opts); - } - - readdirSync(p, opts) { - return this.baseFs.readdirSync(this.mapToBase(p), opts); - } - - async readlinkPromise(p) { - return this.mapFromBase(await this.baseFs.readlinkPromise(this.mapToBase(p))); - } - - readlinkSync(p) { - return this.mapFromBase(this.baseFs.readlinkSync(this.mapToBase(p))); - } - - async truncatePromise(p, len) { - return this.baseFs.truncatePromise(this.mapToBase(p), len); - } - - truncateSync(p, len) { - return this.baseFs.truncateSync(this.mapToBase(p), len); - } - - async ftruncatePromise(fd, len) { - return this.baseFs.ftruncatePromise(fd, len); - } - - ftruncateSync(fd, len) { - return this.baseFs.ftruncateSync(fd, len); - } - - watch(p, a, b) { - return this.baseFs.watch( - this.mapToBase(p), - // @ts-expect-error - a, - b - ); - } - - watchFile(p, a, b) { - return this.baseFs.watchFile( - this.mapToBase(p), - // @ts-expect-error - a, - b - ); - } - - unwatchFile(p, cb) { - return this.baseFs.unwatchFile(this.mapToBase(p), cb); - } - - fsMapToBase(p) { - if (typeof p === `number`) { - return p; - } else { - return this.mapToBase(p); - } - } + getExtractHint(hints) { + return this.baseFs.getExtractHint(hints); + } + resolve(path) { + return this.mapFromBase(this.baseFs.resolve(this.mapToBase(path))); + } + getRealPath() { + return this.mapFromBase(this.baseFs.getRealPath()); + } + async openPromise(p, flags, mode) { + return this.baseFs.openPromise(this.mapToBase(p), flags, mode); + } + openSync(p, flags, mode) { + return this.baseFs.openSync(this.mapToBase(p), flags, mode); + } + async opendirPromise(p, opts) { + return Object.assign(await this.baseFs.opendirPromise(this.mapToBase(p), opts), { path: p }); + } + opendirSync(p, opts) { + return Object.assign(this.baseFs.opendirSync(this.mapToBase(p), opts), { path: p }); + } + async readPromise(fd, buffer, offset, length, position) { + return await this.baseFs.readPromise(fd, buffer, offset, length, position); + } + readSync(fd, buffer, offset, length, position) { + return this.baseFs.readSync(fd, buffer, offset, length, position); + } + async writePromise(fd, buffer, offset, length, position) { + if (typeof buffer === `string`) { + return await this.baseFs.writePromise(fd, buffer, offset); + } else { + return await this.baseFs.writePromise(fd, buffer, offset, length, position); + } + } + writeSync(fd, buffer, offset, length, position) { + if (typeof buffer === `string`) { + return this.baseFs.writeSync(fd, buffer, offset); + } else { + return this.baseFs.writeSync(fd, buffer, offset, length, position); + } + } + async closePromise(fd) { + return this.baseFs.closePromise(fd); + } + closeSync(fd) { + this.baseFs.closeSync(fd); + } + createReadStream(p, opts) { + return this.baseFs.createReadStream(p !== null ? this.mapToBase(p) : p, opts); + } + createWriteStream(p, opts) { + return this.baseFs.createWriteStream(p !== null ? this.mapToBase(p) : p, opts); + } + async realpathPromise(p) { + return this.mapFromBase(await this.baseFs.realpathPromise(this.mapToBase(p))); + } + realpathSync(p) { + return this.mapFromBase(this.baseFs.realpathSync(this.mapToBase(p))); + } + async existsPromise(p) { + return this.baseFs.existsPromise(this.mapToBase(p)); + } + existsSync(p) { + return this.baseFs.existsSync(this.mapToBase(p)); + } + accessSync(p, mode) { + return this.baseFs.accessSync(this.mapToBase(p), mode); + } + async accessPromise(p, mode) { + return this.baseFs.accessPromise(this.mapToBase(p), mode); + } + async statPromise(p, opts) { + return this.baseFs.statPromise(this.mapToBase(p), opts); + } + statSync(p, opts) { + return this.baseFs.statSync(this.mapToBase(p), opts); + } + async fstatPromise(fd, opts) { + return this.baseFs.fstatPromise(fd, opts); + } + fstatSync(fd, opts) { + return this.baseFs.fstatSync(fd, opts); + } + lstatPromise(p, opts) { + return this.baseFs.lstatPromise(this.mapToBase(p), opts); + } + lstatSync(p, opts) { + return this.baseFs.lstatSync(this.mapToBase(p), opts); + } + async fchmodPromise(fd, mask) { + return this.baseFs.fchmodPromise(fd, mask); + } + fchmodSync(fd, mask) { + return this.baseFs.fchmodSync(fd, mask); + } + async chmodPromise(p, mask) { + return this.baseFs.chmodPromise(this.mapToBase(p), mask); + } + chmodSync(p, mask) { + return this.baseFs.chmodSync(this.mapToBase(p), mask); + } + async fchownPromise(fd, uid, gid) { + return this.baseFs.fchownPromise(fd, uid, gid); + } + fchownSync(fd, uid, gid) { + return this.baseFs.fchownSync(fd, uid, gid); + } + async chownPromise(p, uid, gid) { + return this.baseFs.chownPromise(this.mapToBase(p), uid, gid); + } + chownSync(p, uid, gid) { + return this.baseFs.chownSync(this.mapToBase(p), uid, gid); + } + async renamePromise(oldP, newP) { + return this.baseFs.renamePromise(this.mapToBase(oldP), this.mapToBase(newP)); + } + renameSync(oldP, newP) { + return this.baseFs.renameSync(this.mapToBase(oldP), this.mapToBase(newP)); + } + async copyFilePromise(sourceP, destP, flags = 0) { + return this.baseFs.copyFilePromise(this.mapToBase(sourceP), this.mapToBase(destP), flags); + } + copyFileSync(sourceP, destP, flags = 0) { + return this.baseFs.copyFileSync(this.mapToBase(sourceP), this.mapToBase(destP), flags); + } + async appendFilePromise(p, content, opts) { + return this.baseFs.appendFilePromise(this.fsMapToBase(p), content, opts); + } + appendFileSync(p, content, opts) { + return this.baseFs.appendFileSync(this.fsMapToBase(p), content, opts); + } + async writeFilePromise(p, content, opts) { + return this.baseFs.writeFilePromise(this.fsMapToBase(p), content, opts); + } + writeFileSync(p, content, opts) { + return this.baseFs.writeFileSync(this.fsMapToBase(p), content, opts); + } + async unlinkPromise(p) { + return this.baseFs.unlinkPromise(this.mapToBase(p)); + } + unlinkSync(p) { + return this.baseFs.unlinkSync(this.mapToBase(p)); + } + async utimesPromise(p, atime, mtime) { + return this.baseFs.utimesPromise(this.mapToBase(p), atime, mtime); + } + utimesSync(p, atime, mtime) { + return this.baseFs.utimesSync(this.mapToBase(p), atime, mtime); + } + async lutimesPromise(p, atime, mtime) { + return this.baseFs.lutimesPromise(this.mapToBase(p), atime, mtime); + } + lutimesSync(p, atime, mtime) { + return this.baseFs.lutimesSync(this.mapToBase(p), atime, mtime); + } + async mkdirPromise(p, opts) { + return this.baseFs.mkdirPromise(this.mapToBase(p), opts); + } + mkdirSync(p, opts) { + return this.baseFs.mkdirSync(this.mapToBase(p), opts); + } + async rmdirPromise(p, opts) { + return this.baseFs.rmdirPromise(this.mapToBase(p), opts); + } + rmdirSync(p, opts) { + return this.baseFs.rmdirSync(this.mapToBase(p), opts); + } + async rmPromise(p, opts) { + return this.baseFs.rmPromise(this.mapToBase(p), opts); + } + rmSync(p, opts) { + return this.baseFs.rmSync(this.mapToBase(p), opts); + } + async linkPromise(existingP, newP) { + return this.baseFs.linkPromise(this.mapToBase(existingP), this.mapToBase(newP)); + } + linkSync(existingP, newP) { + return this.baseFs.linkSync(this.mapToBase(existingP), this.mapToBase(newP)); + } + async symlinkPromise(target, p, type) { + const mappedP = this.mapToBase(p); + if (this.pathUtils.isAbsolute(target)) + return this.baseFs.symlinkPromise(this.mapToBase(target), mappedP, type); + const mappedAbsoluteTarget = this.mapToBase(this.pathUtils.join(this.pathUtils.dirname(p), target)); + const mappedTarget = this.baseFs.pathUtils.relative(this.baseFs.pathUtils.dirname(mappedP), mappedAbsoluteTarget); + return this.baseFs.symlinkPromise(mappedTarget, mappedP, type); + } + symlinkSync(target, p, type) { + const mappedP = this.mapToBase(p); + if (this.pathUtils.isAbsolute(target)) + return this.baseFs.symlinkSync(this.mapToBase(target), mappedP, type); + const mappedAbsoluteTarget = this.mapToBase(this.pathUtils.join(this.pathUtils.dirname(p), target)); + const mappedTarget = this.baseFs.pathUtils.relative(this.baseFs.pathUtils.dirname(mappedP), mappedAbsoluteTarget); + return this.baseFs.symlinkSync(mappedTarget, mappedP, type); + } + async readFilePromise(p, encoding) { + return this.baseFs.readFilePromise(this.fsMapToBase(p), encoding); + } + readFileSync(p, encoding) { + return this.baseFs.readFileSync(this.fsMapToBase(p), encoding); + } + readdirPromise(p, opts) { + return this.baseFs.readdirPromise(this.mapToBase(p), opts); + } + readdirSync(p, opts) { + return this.baseFs.readdirSync(this.mapToBase(p), opts); + } + async readlinkPromise(p) { + return this.mapFromBase(await this.baseFs.readlinkPromise(this.mapToBase(p))); + } + readlinkSync(p) { + return this.mapFromBase(this.baseFs.readlinkSync(this.mapToBase(p))); + } + async truncatePromise(p, len) { + return this.baseFs.truncatePromise(this.mapToBase(p), len); + } + truncateSync(p, len) { + return this.baseFs.truncateSync(this.mapToBase(p), len); + } + async ftruncatePromise(fd, len) { + return this.baseFs.ftruncatePromise(fd, len); + } + ftruncateSync(fd, len) { + return this.baseFs.ftruncateSync(fd, len); + } + watch(p, a, b) { + return this.baseFs.watch( + this.mapToBase(p), + // @ts-expect-error + a, + b + ); + } + watchFile(p, a, b) { + return this.baseFs.watchFile( + this.mapToBase(p), + // @ts-expect-error + a, + b + ); + } + unwatchFile(p, cb) { + return this.baseFs.unwatchFile(this.mapToBase(p), cb); + } + fsMapToBase(p) { + if (typeof p === `number`) { + return p; + } else { + return this.mapToBase(p); + } + } } function direntToPortable(dirent) { - const portableDirent = dirent; - if (typeof dirent.path === `string`) - portableDirent.path = npath.toPortablePath(dirent.path); - return portableDirent; + const portableDirent = dirent; + if (typeof dirent.path === `string`) + portableDirent.path = npath.toPortablePath(dirent.path); + return portableDirent; } - class NodeFS extends BasePortableFakeFS { - realFs; - - constructor(realFs = fs) { - super(); - this.realFs = realFs; - } - - getExtractHint() { - return false; - } - - getRealPath() { - return PortablePath.root; - } - - resolve(p) { - return ppath.resolve(p); - } - - async openPromise(p, flags, mode) { - return await new Promise((resolve, reject) => { - this.realFs.open(npath.fromPortablePath(p), flags, mode, this.makeCallback(resolve, reject)); - }); - } - - openSync(p, flags, mode) { - return this.realFs.openSync(npath.fromPortablePath(p), flags, mode); - } - - async opendirPromise(p, opts) { - return await new Promise((resolve, reject) => { - if (typeof opts !== `undefined`) { - this.realFs.opendir(npath.fromPortablePath(p), opts, this.makeCallback(resolve, reject)); - } else { - this.realFs.opendir(npath.fromPortablePath(p), this.makeCallback(resolve, reject)); - } - }).then((dir) => { - const dirWithFixedPath = dir; - Object.defineProperty(dirWithFixedPath, `path`, { - value: p, - configurable: true, - writable: true - }); - return dirWithFixedPath; - }); - } - - opendirSync(p, opts) { - const dir = typeof opts !== `undefined` ? this.realFs.opendirSync(npath.fromPortablePath(p), opts) : this.realFs.opendirSync(npath.fromPortablePath(p)); - const dirWithFixedPath = dir; - Object.defineProperty(dirWithFixedPath, `path`, { - value: p, - configurable: true, - writable: true - }); - return dirWithFixedPath; - } - - async readPromise(fd, buffer, offset = 0, length = 0, position = -1) { - return await new Promise((resolve, reject) => { - this.realFs.read(fd, buffer, offset, length, position, (error, bytesRead) => { - if (error) { - reject(error); - } else { - resolve(bytesRead); - } - }); - }); - } - - readSync(fd, buffer, offset, length, position) { - return this.realFs.readSync(fd, buffer, offset, length, position); - } - - async writePromise(fd, buffer, offset, length, position) { - return await new Promise((resolve, reject) => { - if (typeof buffer === `string`) { - return this.realFs.write(fd, buffer, offset, this.makeCallback(resolve, reject)); - } else { - return this.realFs.write(fd, buffer, offset, length, position, this.makeCallback(resolve, reject)); - } - }); - } - - writeSync(fd, buffer, offset, length, position) { - if (typeof buffer === `string`) { - return this.realFs.writeSync(fd, buffer, offset); + realFs; + constructor(realFs = fs) { + super(); + this.realFs = realFs; + } + getExtractHint() { + return false; + } + getRealPath() { + return PortablePath.root; + } + resolve(p) { + return ppath.resolve(p); + } + async openPromise(p, flags, mode) { + return await new Promise((resolve, reject) => { + this.realFs.open(npath.fromPortablePath(p), flags, mode, this.makeCallback(resolve, reject)); + }); + } + openSync(p, flags, mode) { + return this.realFs.openSync(npath.fromPortablePath(p), flags, mode); + } + async opendirPromise(p, opts) { + return await new Promise((resolve, reject) => { + if (typeof opts !== `undefined`) { + this.realFs.opendir(npath.fromPortablePath(p), opts, this.makeCallback(resolve, reject)); + } else { + this.realFs.opendir(npath.fromPortablePath(p), this.makeCallback(resolve, reject)); + } + }).then((dir) => { + const dirWithFixedPath = dir; + Object.defineProperty(dirWithFixedPath, `path`, { + value: p, + configurable: true, + writable: true + }); + return dirWithFixedPath; + }); + } + opendirSync(p, opts) { + const dir = typeof opts !== `undefined` ? this.realFs.opendirSync(npath.fromPortablePath(p), opts) : this.realFs.opendirSync(npath.fromPortablePath(p)); + const dirWithFixedPath = dir; + Object.defineProperty(dirWithFixedPath, `path`, { + value: p, + configurable: true, + writable: true + }); + return dirWithFixedPath; + } + async readPromise(fd, buffer, offset = 0, length = 0, position = -1) { + return await new Promise((resolve, reject) => { + this.realFs.read(fd, buffer, offset, length, position, (error, bytesRead) => { + if (error) { + reject(error); } else { - return this.realFs.writeSync(fd, buffer, offset, length, position); + resolve(bytesRead); } + }); + }); + } + readSync(fd, buffer, offset, length, position) { + return this.realFs.readSync(fd, buffer, offset, length, position); + } + async writePromise(fd, buffer, offset, length, position) { + return await new Promise((resolve, reject) => { + if (typeof buffer === `string`) { + return this.realFs.write(fd, buffer, offset, this.makeCallback(resolve, reject)); + } else { + return this.realFs.write(fd, buffer, offset, length, position, this.makeCallback(resolve, reject)); + } + }); + } + writeSync(fd, buffer, offset, length, position) { + if (typeof buffer === `string`) { + return this.realFs.writeSync(fd, buffer, offset); + } else { + return this.realFs.writeSync(fd, buffer, offset, length, position); } - - async closePromise(fd) { - await new Promise((resolve, reject) => { - this.realFs.close(fd, this.makeCallback(resolve, reject)); - }); + } + async closePromise(fd) { + await new Promise((resolve, reject) => { + this.realFs.close(fd, this.makeCallback(resolve, reject)); + }); + } + closeSync(fd) { + this.realFs.closeSync(fd); + } + createReadStream(p, opts) { + const realPath = p !== null ? npath.fromPortablePath(p) : p; + return this.realFs.createReadStream(realPath, opts); + } + createWriteStream(p, opts) { + const realPath = p !== null ? npath.fromPortablePath(p) : p; + return this.realFs.createWriteStream(realPath, opts); + } + async realpathPromise(p) { + return await new Promise((resolve, reject) => { + this.realFs.realpath(npath.fromPortablePath(p), {}, this.makeCallback(resolve, reject)); + }).then((path) => { + return npath.toPortablePath(path); + }); + } + realpathSync(p) { + return npath.toPortablePath(this.realFs.realpathSync(npath.fromPortablePath(p), {})); + } + async existsPromise(p) { + return await new Promise((resolve) => { + this.realFs.exists(npath.fromPortablePath(p), resolve); + }); + } + accessSync(p, mode) { + return this.realFs.accessSync(npath.fromPortablePath(p), mode); + } + async accessPromise(p, mode) { + return await new Promise((resolve, reject) => { + this.realFs.access(npath.fromPortablePath(p), mode, this.makeCallback(resolve, reject)); + }); + } + existsSync(p) { + return this.realFs.existsSync(npath.fromPortablePath(p)); + } + async statPromise(p, opts) { + return await new Promise((resolve, reject) => { + if (opts) { + this.realFs.stat(npath.fromPortablePath(p), opts, this.makeCallback(resolve, reject)); + } else { + this.realFs.stat(npath.fromPortablePath(p), this.makeCallback(resolve, reject)); + } + }); + } + statSync(p, opts) { + if (opts) { + return this.realFs.statSync(npath.fromPortablePath(p), opts); + } else { + return this.realFs.statSync(npath.fromPortablePath(p)); } - - closeSync(fd) { - this.realFs.closeSync(fd); + } + async fstatPromise(fd, opts) { + return await new Promise((resolve, reject) => { + if (opts) { + this.realFs.fstat(fd, opts, this.makeCallback(resolve, reject)); + } else { + this.realFs.fstat(fd, this.makeCallback(resolve, reject)); + } + }); + } + fstatSync(fd, opts) { + if (opts) { + return this.realFs.fstatSync(fd, opts); + } else { + return this.realFs.fstatSync(fd); } - - createReadStream(p, opts) { - const realPath = p !== null ? npath.fromPortablePath(p) : p; - return this.realFs.createReadStream(realPath, opts); + } + async lstatPromise(p, opts) { + return await new Promise((resolve, reject) => { + if (opts) { + this.realFs.lstat(npath.fromPortablePath(p), opts, this.makeCallback(resolve, reject)); + } else { + this.realFs.lstat(npath.fromPortablePath(p), this.makeCallback(resolve, reject)); + } + }); + } + lstatSync(p, opts) { + if (opts) { + return this.realFs.lstatSync(npath.fromPortablePath(p), opts); + } else { + return this.realFs.lstatSync(npath.fromPortablePath(p)); } - - createWriteStream(p, opts) { - const realPath = p !== null ? npath.fromPortablePath(p) : p; - return this.realFs.createWriteStream(realPath, opts); + } + async fchmodPromise(fd, mask) { + return await new Promise((resolve, reject) => { + this.realFs.fchmod(fd, mask, this.makeCallback(resolve, reject)); + }); + } + fchmodSync(fd, mask) { + return this.realFs.fchmodSync(fd, mask); + } + async chmodPromise(p, mask) { + return await new Promise((resolve, reject) => { + this.realFs.chmod(npath.fromPortablePath(p), mask, this.makeCallback(resolve, reject)); + }); + } + chmodSync(p, mask) { + return this.realFs.chmodSync(npath.fromPortablePath(p), mask); + } + async fchownPromise(fd, uid, gid) { + return await new Promise((resolve, reject) => { + this.realFs.fchown(fd, uid, gid, this.makeCallback(resolve, reject)); + }); + } + fchownSync(fd, uid, gid) { + return this.realFs.fchownSync(fd, uid, gid); + } + async chownPromise(p, uid, gid) { + return await new Promise((resolve, reject) => { + this.realFs.chown(npath.fromPortablePath(p), uid, gid, this.makeCallback(resolve, reject)); + }); + } + chownSync(p, uid, gid) { + return this.realFs.chownSync(npath.fromPortablePath(p), uid, gid); + } + async renamePromise(oldP, newP) { + return await new Promise((resolve, reject) => { + this.realFs.rename(npath.fromPortablePath(oldP), npath.fromPortablePath(newP), this.makeCallback(resolve, reject)); + }); + } + renameSync(oldP, newP) { + return this.realFs.renameSync(npath.fromPortablePath(oldP), npath.fromPortablePath(newP)); + } + async copyFilePromise(sourceP, destP, flags = 0) { + return await new Promise((resolve, reject) => { + this.realFs.copyFile(npath.fromPortablePath(sourceP), npath.fromPortablePath(destP), flags, this.makeCallback(resolve, reject)); + }); + } + copyFileSync(sourceP, destP, flags = 0) { + return this.realFs.copyFileSync(npath.fromPortablePath(sourceP), npath.fromPortablePath(destP), flags); + } + async appendFilePromise(p, content, opts) { + return await new Promise((resolve, reject) => { + const fsNativePath = typeof p === `string` ? npath.fromPortablePath(p) : p; + if (opts) { + this.realFs.appendFile(fsNativePath, content, opts, this.makeCallback(resolve, reject)); + } else { + this.realFs.appendFile(fsNativePath, content, this.makeCallback(resolve, reject)); + } + }); + } + appendFileSync(p, content, opts) { + const fsNativePath = typeof p === `string` ? npath.fromPortablePath(p) : p; + if (opts) { + this.realFs.appendFileSync(fsNativePath, content, opts); + } else { + this.realFs.appendFileSync(fsNativePath, content); } - - async realpathPromise(p) { - return await new Promise((resolve, reject) => { - this.realFs.realpath(npath.fromPortablePath(p), {}, this.makeCallback(resolve, reject)); - }).then((path) => { - return npath.toPortablePath(path); - }); + } + async writeFilePromise(p, content, opts) { + return await new Promise((resolve, reject) => { + const fsNativePath = typeof p === `string` ? npath.fromPortablePath(p) : p; + if (opts) { + this.realFs.writeFile(fsNativePath, content, opts, this.makeCallback(resolve, reject)); + } else { + this.realFs.writeFile(fsNativePath, content, this.makeCallback(resolve, reject)); + } + }); + } + writeFileSync(p, content, opts) { + const fsNativePath = typeof p === `string` ? npath.fromPortablePath(p) : p; + if (opts) { + this.realFs.writeFileSync(fsNativePath, content, opts); + } else { + this.realFs.writeFileSync(fsNativePath, content); } - - realpathSync(p) { - return npath.toPortablePath(this.realFs.realpathSync(npath.fromPortablePath(p), {})); - } - - async existsPromise(p) { - return await new Promise((resolve) => { - this.realFs.exists(npath.fromPortablePath(p), resolve); - }); - } - - accessSync(p, mode) { - return this.realFs.accessSync(npath.fromPortablePath(p), mode); - } - - async accessPromise(p, mode) { - return await new Promise((resolve, reject) => { - this.realFs.access(npath.fromPortablePath(p), mode, this.makeCallback(resolve, reject)); - }); - } - - existsSync(p) { - return this.realFs.existsSync(npath.fromPortablePath(p)); - } - - async statPromise(p, opts) { - return await new Promise((resolve, reject) => { - if (opts) { - this.realFs.stat(npath.fromPortablePath(p), opts, this.makeCallback(resolve, reject)); - } else { - this.realFs.stat(npath.fromPortablePath(p), this.makeCallback(resolve, reject)); - } - }); - } - - statSync(p, opts) { - if (opts) { - return this.realFs.statSync(npath.fromPortablePath(p), opts); + } + async unlinkPromise(p) { + return await new Promise((resolve, reject) => { + this.realFs.unlink(npath.fromPortablePath(p), this.makeCallback(resolve, reject)); + }); + } + unlinkSync(p) { + return this.realFs.unlinkSync(npath.fromPortablePath(p)); + } + async utimesPromise(p, atime, mtime) { + return await new Promise((resolve, reject) => { + this.realFs.utimes(npath.fromPortablePath(p), atime, mtime, this.makeCallback(resolve, reject)); + }); + } + utimesSync(p, atime, mtime) { + this.realFs.utimesSync(npath.fromPortablePath(p), atime, mtime); + } + async lutimesPromise(p, atime, mtime) { + return await new Promise((resolve, reject) => { + this.realFs.lutimes(npath.fromPortablePath(p), atime, mtime, this.makeCallback(resolve, reject)); + }); + } + lutimesSync(p, atime, mtime) { + this.realFs.lutimesSync(npath.fromPortablePath(p), atime, mtime); + } + async mkdirPromise(p, opts) { + return await new Promise((resolve, reject) => { + this.realFs.mkdir(npath.fromPortablePath(p), opts, this.makeCallback(resolve, reject)); + }); + } + mkdirSync(p, opts) { + return this.realFs.mkdirSync(npath.fromPortablePath(p), opts); + } + async rmdirPromise(p, opts) { + return await new Promise((resolve, reject) => { + if (opts) { + this.realFs.rmdir(npath.fromPortablePath(p), opts, this.makeCallback(resolve, reject)); + } else { + this.realFs.rmdir(npath.fromPortablePath(p), this.makeCallback(resolve, reject)); + } + }); + } + rmdirSync(p, opts) { + return this.realFs.rmdirSync(npath.fromPortablePath(p), opts); + } + async rmPromise(p, opts) { + return await new Promise((resolve, reject) => { + if (opts) { + this.realFs.rm(npath.fromPortablePath(p), opts, this.makeCallback(resolve, reject)); + } else { + this.realFs.rm(npath.fromPortablePath(p), this.makeCallback(resolve, reject)); + } + }); + } + rmSync(p, opts) { + return this.realFs.rmSync(npath.fromPortablePath(p), opts); + } + async linkPromise(existingP, newP) { + return await new Promise((resolve, reject) => { + this.realFs.link(npath.fromPortablePath(existingP), npath.fromPortablePath(newP), this.makeCallback(resolve, reject)); + }); + } + linkSync(existingP, newP) { + return this.realFs.linkSync(npath.fromPortablePath(existingP), npath.fromPortablePath(newP)); + } + async symlinkPromise(target, p, type) { + return await new Promise((resolve, reject) => { + this.realFs.symlink(npath.fromPortablePath(target.replace(/\/+$/, ``)), npath.fromPortablePath(p), type, this.makeCallback(resolve, reject)); + }); + } + symlinkSync(target, p, type) { + return this.realFs.symlinkSync(npath.fromPortablePath(target.replace(/\/+$/, ``)), npath.fromPortablePath(p), type); + } + async readFilePromise(p, encoding) { + return await new Promise((resolve, reject) => { + const fsNativePath = typeof p === `string` ? npath.fromPortablePath(p) : p; + this.realFs.readFile(fsNativePath, encoding, this.makeCallback(resolve, reject)); + }); + } + readFileSync(p, encoding) { + const fsNativePath = typeof p === `string` ? npath.fromPortablePath(p) : p; + return this.realFs.readFileSync(fsNativePath, encoding); + } + async readdirPromise(p, opts) { + return await new Promise((resolve, reject) => { + if (opts) { + if (opts.recursive && process.platform === `win32`) { + if (opts.withFileTypes) { + this.realFs.readdir(npath.fromPortablePath(p), opts, this.makeCallback((results) => resolve(results.map(direntToPortable)), reject)); + } else { + this.realFs.readdir(npath.fromPortablePath(p), opts, this.makeCallback((results) => resolve(results.map(npath.toPortablePath)), reject)); + } } else { - return this.realFs.statSync(npath.fromPortablePath(p)); + this.realFs.readdir(npath.fromPortablePath(p), opts, this.makeCallback(resolve, reject)); } - } - - async fstatPromise(fd, opts) { - return await new Promise((resolve, reject) => { - if (opts) { - this.realFs.fstat(fd, opts, this.makeCallback(resolve, reject)); - } else { - this.realFs.fstat(fd, this.makeCallback(resolve, reject)); - } - }); - } - - fstatSync(fd, opts) { - if (opts) { - return this.realFs.fstatSync(fd, opts); + } else { + this.realFs.readdir(npath.fromPortablePath(p), this.makeCallback(resolve, reject)); + } + }); + } + readdirSync(p, opts) { + if (opts) { + if (opts.recursive && process.platform === `win32`) { + if (opts.withFileTypes) { + return this.realFs.readdirSync(npath.fromPortablePath(p), opts).map(direntToPortable); } else { - return this.realFs.fstatSync(fd); + return this.realFs.readdirSync(npath.fromPortablePath(p), opts).map(npath.toPortablePath); } + } else { + return this.realFs.readdirSync(npath.fromPortablePath(p), opts); + } + } else { + return this.realFs.readdirSync(npath.fromPortablePath(p)); } - - async lstatPromise(p, opts) { - return await new Promise((resolve, reject) => { - if (opts) { - this.realFs.lstat(npath.fromPortablePath(p), opts, this.makeCallback(resolve, reject)); - } else { - this.realFs.lstat(npath.fromPortablePath(p), this.makeCallback(resolve, reject)); - } - }); - } - - lstatSync(p, opts) { - if (opts) { - return this.realFs.lstatSync(npath.fromPortablePath(p), opts); - } else { - return this.realFs.lstatSync(npath.fromPortablePath(p)); - } - } - - async fchmodPromise(fd, mask) { - return await new Promise((resolve, reject) => { - this.realFs.fchmod(fd, mask, this.makeCallback(resolve, reject)); - }); - } - - fchmodSync(fd, mask) { - return this.realFs.fchmodSync(fd, mask); - } - - async chmodPromise(p, mask) { - return await new Promise((resolve, reject) => { - this.realFs.chmod(npath.fromPortablePath(p), mask, this.makeCallback(resolve, reject)); - }); - } - - chmodSync(p, mask) { - return this.realFs.chmodSync(npath.fromPortablePath(p), mask); - } - - async fchownPromise(fd, uid, gid) { - return await new Promise((resolve, reject) => { - this.realFs.fchown(fd, uid, gid, this.makeCallback(resolve, reject)); - }); - } - - fchownSync(fd, uid, gid) { - return this.realFs.fchownSync(fd, uid, gid); - } - - async chownPromise(p, uid, gid) { - return await new Promise((resolve, reject) => { - this.realFs.chown(npath.fromPortablePath(p), uid, gid, this.makeCallback(resolve, reject)); - }); - } - - chownSync(p, uid, gid) { - return this.realFs.chownSync(npath.fromPortablePath(p), uid, gid); - } - - async renamePromise(oldP, newP) { - return await new Promise((resolve, reject) => { - this.realFs.rename(npath.fromPortablePath(oldP), npath.fromPortablePath(newP), this.makeCallback(resolve, reject)); - }); - } - - renameSync(oldP, newP) { - return this.realFs.renameSync(npath.fromPortablePath(oldP), npath.fromPortablePath(newP)); - } - - async copyFilePromise(sourceP, destP, flags = 0) { - return await new Promise((resolve, reject) => { - this.realFs.copyFile(npath.fromPortablePath(sourceP), npath.fromPortablePath(destP), flags, this.makeCallback(resolve, reject)); - }); - } - - copyFileSync(sourceP, destP, flags = 0) { - return this.realFs.copyFileSync(npath.fromPortablePath(sourceP), npath.fromPortablePath(destP), flags); - } - - async appendFilePromise(p, content, opts) { - return await new Promise((resolve, reject) => { - const fsNativePath = typeof p === `string` ? npath.fromPortablePath(p) : p; - if (opts) { - this.realFs.appendFile(fsNativePath, content, opts, this.makeCallback(resolve, reject)); - } else { - this.realFs.appendFile(fsNativePath, content, this.makeCallback(resolve, reject)); - } - }); - } - - appendFileSync(p, content, opts) { - const fsNativePath = typeof p === `string` ? npath.fromPortablePath(p) : p; - if (opts) { - this.realFs.appendFileSync(fsNativePath, content, opts); - } else { - this.realFs.appendFileSync(fsNativePath, content); - } - } - - async writeFilePromise(p, content, opts) { - return await new Promise((resolve, reject) => { - const fsNativePath = typeof p === `string` ? npath.fromPortablePath(p) : p; - if (opts) { - this.realFs.writeFile(fsNativePath, content, opts, this.makeCallback(resolve, reject)); - } else { - this.realFs.writeFile(fsNativePath, content, this.makeCallback(resolve, reject)); - } - }); - } - - writeFileSync(p, content, opts) { - const fsNativePath = typeof p === `string` ? npath.fromPortablePath(p) : p; - if (opts) { - this.realFs.writeFileSync(fsNativePath, content, opts); - } else { - this.realFs.writeFileSync(fsNativePath, content); - } - } - - async unlinkPromise(p) { - return await new Promise((resolve, reject) => { - this.realFs.unlink(npath.fromPortablePath(p), this.makeCallback(resolve, reject)); - }); - } - - unlinkSync(p) { - return this.realFs.unlinkSync(npath.fromPortablePath(p)); - } - - async utimesPromise(p, atime, mtime) { - return await new Promise((resolve, reject) => { - this.realFs.utimes(npath.fromPortablePath(p), atime, mtime, this.makeCallback(resolve, reject)); - }); - } - - utimesSync(p, atime, mtime) { - this.realFs.utimesSync(npath.fromPortablePath(p), atime, mtime); - } - - async lutimesPromise(p, atime, mtime) { - return await new Promise((resolve, reject) => { - this.realFs.lutimes(npath.fromPortablePath(p), atime, mtime, this.makeCallback(resolve, reject)); - }); - } - - lutimesSync(p, atime, mtime) { - this.realFs.lutimesSync(npath.fromPortablePath(p), atime, mtime); - } - - async mkdirPromise(p, opts) { - return await new Promise((resolve, reject) => { - this.realFs.mkdir(npath.fromPortablePath(p), opts, this.makeCallback(resolve, reject)); - }); - } - - mkdirSync(p, opts) { - return this.realFs.mkdirSync(npath.fromPortablePath(p), opts); - } - - async rmdirPromise(p, opts) { - return await new Promise((resolve, reject) => { - if (opts) { - this.realFs.rmdir(npath.fromPortablePath(p), opts, this.makeCallback(resolve, reject)); - } else { - this.realFs.rmdir(npath.fromPortablePath(p), this.makeCallback(resolve, reject)); - } - }); - } - - rmdirSync(p, opts) { - return this.realFs.rmdirSync(npath.fromPortablePath(p), opts); - } - - async rmPromise(p, opts) { - return await new Promise((resolve, reject) => { - if (opts) { - this.realFs.rm(npath.fromPortablePath(p), opts, this.makeCallback(resolve, reject)); - } else { - this.realFs.rm(npath.fromPortablePath(p), this.makeCallback(resolve, reject)); - } - }); - } - - rmSync(p, opts) { - return this.realFs.rmSync(npath.fromPortablePath(p), opts); - } - - async linkPromise(existingP, newP) { - return await new Promise((resolve, reject) => { - this.realFs.link(npath.fromPortablePath(existingP), npath.fromPortablePath(newP), this.makeCallback(resolve, reject)); - }); - } - - linkSync(existingP, newP) { - return this.realFs.linkSync(npath.fromPortablePath(existingP), npath.fromPortablePath(newP)); - } - - async symlinkPromise(target, p, type) { - return await new Promise((resolve, reject) => { - this.realFs.symlink(npath.fromPortablePath(target.replace(/\/+$/, ``)), npath.fromPortablePath(p), type, this.makeCallback(resolve, reject)); - }); - } - - symlinkSync(target, p, type) { - return this.realFs.symlinkSync(npath.fromPortablePath(target.replace(/\/+$/, ``)), npath.fromPortablePath(p), type); - } - - async readFilePromise(p, encoding) { - return await new Promise((resolve, reject) => { - const fsNativePath = typeof p === `string` ? npath.fromPortablePath(p) : p; - this.realFs.readFile(fsNativePath, encoding, this.makeCallback(resolve, reject)); - }); - } - - readFileSync(p, encoding) { - const fsNativePath = typeof p === `string` ? npath.fromPortablePath(p) : p; - return this.realFs.readFileSync(fsNativePath, encoding); - } - - async readdirPromise(p, opts) { - return await new Promise((resolve, reject) => { - if (opts) { - if (opts.recursive && process.platform === `win32`) { - if (opts.withFileTypes) { - this.realFs.readdir(npath.fromPortablePath(p), opts, this.makeCallback((results) => resolve(results.map(direntToPortable)), reject)); - } else { - this.realFs.readdir(npath.fromPortablePath(p), opts, this.makeCallback((results) => resolve(results.map(npath.toPortablePath)), reject)); - } - } else { - this.realFs.readdir(npath.fromPortablePath(p), opts, this.makeCallback(resolve, reject)); - } - } else { - this.realFs.readdir(npath.fromPortablePath(p), this.makeCallback(resolve, reject)); - } - }); - } - - readdirSync(p, opts) { - if (opts) { - if (opts.recursive && process.platform === `win32`) { - if (opts.withFileTypes) { - return this.realFs.readdirSync(npath.fromPortablePath(p), opts).map(direntToPortable); - } else { - return this.realFs.readdirSync(npath.fromPortablePath(p), opts).map(npath.toPortablePath); - } - } else { - return this.realFs.readdirSync(npath.fromPortablePath(p), opts); - } - } else { - return this.realFs.readdirSync(npath.fromPortablePath(p)); - } - } - - async readlinkPromise(p) { - return await new Promise((resolve, reject) => { - this.realFs.readlink(npath.fromPortablePath(p), this.makeCallback(resolve, reject)); - }).then((path) => { - return npath.toPortablePath(path); - }); - } - - readlinkSync(p) { - return npath.toPortablePath(this.realFs.readlinkSync(npath.fromPortablePath(p))); - } - - async truncatePromise(p, len) { - return await new Promise((resolve, reject) => { - this.realFs.truncate(npath.fromPortablePath(p), len, this.makeCallback(resolve, reject)); - }); - } - - truncateSync(p, len) { - return this.realFs.truncateSync(npath.fromPortablePath(p), len); - } - - async ftruncatePromise(fd, len) { - return await new Promise((resolve, reject) => { - this.realFs.ftruncate(fd, len, this.makeCallback(resolve, reject)); - }); - } - - ftruncateSync(fd, len) { - return this.realFs.ftruncateSync(fd, len); - } - - watch(p, a, b) { - return this.realFs.watch( - npath.fromPortablePath(p), - // @ts-expect-error - a, - b - ); - } - - watchFile(p, a, b) { - return this.realFs.watchFile( - npath.fromPortablePath(p), - // @ts-expect-error - a, - b - ); - } - - unwatchFile(p, cb) { - return this.realFs.unwatchFile(npath.fromPortablePath(p), cb); - } - - makeCallback(resolve, reject) { - return (err, result) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }; - } + } + async readlinkPromise(p) { + return await new Promise((resolve, reject) => { + this.realFs.readlink(npath.fromPortablePath(p), this.makeCallback(resolve, reject)); + }).then((path) => { + return npath.toPortablePath(path); + }); + } + readlinkSync(p) { + return npath.toPortablePath(this.realFs.readlinkSync(npath.fromPortablePath(p))); + } + async truncatePromise(p, len) { + return await new Promise((resolve, reject) => { + this.realFs.truncate(npath.fromPortablePath(p), len, this.makeCallback(resolve, reject)); + }); + } + truncateSync(p, len) { + return this.realFs.truncateSync(npath.fromPortablePath(p), len); + } + async ftruncatePromise(fd, len) { + return await new Promise((resolve, reject) => { + this.realFs.ftruncate(fd, len, this.makeCallback(resolve, reject)); + }); + } + ftruncateSync(fd, len) { + return this.realFs.ftruncateSync(fd, len); + } + watch(p, a, b) { + return this.realFs.watch( + npath.fromPortablePath(p), + // @ts-expect-error + a, + b + ); + } + watchFile(p, a, b) { + return this.realFs.watchFile( + npath.fromPortablePath(p), + // @ts-expect-error + a, + b + ); + } + unwatchFile(p, cb) { + return this.realFs.unwatchFile(npath.fromPortablePath(p), cb); + } + makeCallback(resolve, reject) { + return (err, result) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }; + } } const NUMBER_REGEXP = /^[0-9]+$/; const VIRTUAL_REGEXP = /^(\/(?:[^/]+\/)*?(?:\$\$virtual|__virtual__))((?:\/((?:[^/]+-)?[a-f0-9]+)(?:\/([^/]+))?)?((?:\/.*)?))$/; const VALID_COMPONENT = /^([^/]+-)?[a-f0-9]+$/; - class VirtualFS extends ProxiedFS { - baseFs; - - static makeVirtualPath(base, component, to) { - if (ppath.basename(base) !== `__virtual__`) - throw new Error(`Assertion failed: Virtual folders must be named "__virtual__"`); - if (!ppath.basename(component).match(VALID_COMPONENT)) - throw new Error(`Assertion failed: Virtual components must be ended by an hexadecimal hash`); - const target = ppath.relative(ppath.dirname(base), to); - const segments = target.split(`/`); - let depth = 0; - while (depth < segments.length && segments[depth] === `..`) - depth += 1; - const finalSegments = segments.slice(depth); - const fullVirtualPath = ppath.join(base, component, String(depth), ...finalSegments); - return fullVirtualPath; - } - - static resolveVirtual(p) { - const match = p.match(VIRTUAL_REGEXP); - if (!match || !match[3] && match[5]) - return p; - const target = ppath.dirname(match[1]); - if (!match[3] || !match[4]) - return target; - const isnum = NUMBER_REGEXP.test(match[4]); - if (!isnum) - return p; - const depth = Number(match[4]); - const backstep = `../`.repeat(depth); - const subpath = match[5] || `.`; - return VirtualFS.resolveVirtual(ppath.join(target, backstep, subpath)); - } - - constructor({baseFs = new NodeFS()} = {}) { - super(ppath); - this.baseFs = baseFs; - } - - getExtractHint(hints) { - return this.baseFs.getExtractHint(hints); - } - - getRealPath() { - return this.baseFs.getRealPath(); - } - - realpathSync(p) { - const match = p.match(VIRTUAL_REGEXP); - if (!match) - return this.baseFs.realpathSync(p); - if (!match[5]) - return p; - const realpath = this.baseFs.realpathSync(this.mapToBase(p)); - return VirtualFS.makeVirtualPath(match[1], match[3], realpath); - } - - async realpathPromise(p) { - const match = p.match(VIRTUAL_REGEXP); - if (!match) - return await this.baseFs.realpathPromise(p); - if (!match[5]) - return p; - const realpath = await this.baseFs.realpathPromise(this.mapToBase(p)); - return VirtualFS.makeVirtualPath(match[1], match[3], realpath); - } - - mapToBase(p) { - if (p === ``) - return p; - if (this.pathUtils.isAbsolute(p)) - return VirtualFS.resolveVirtual(p); - const resolvedRoot = VirtualFS.resolveVirtual(this.baseFs.resolve(PortablePath.dot)); - const resolvedP = VirtualFS.resolveVirtual(this.baseFs.resolve(p)); - return ppath.relative(resolvedRoot, resolvedP) || PortablePath.dot; - } - - mapFromBase(p) { - return p; - } + baseFs; + static makeVirtualPath(base, component, to) { + if (ppath.basename(base) !== `__virtual__`) + throw new Error(`Assertion failed: Virtual folders must be named "__virtual__"`); + if (!ppath.basename(component).match(VALID_COMPONENT)) + throw new Error(`Assertion failed: Virtual components must be ended by an hexadecimal hash`); + const target = ppath.relative(ppath.dirname(base), to); + const segments = target.split(`/`); + let depth = 0; + while (depth < segments.length && segments[depth] === `..`) + depth += 1; + const finalSegments = segments.slice(depth); + const fullVirtualPath = ppath.join(base, component, String(depth), ...finalSegments); + return fullVirtualPath; + } + static resolveVirtual(p) { + const match = p.match(VIRTUAL_REGEXP); + if (!match || !match[3] && match[5]) + return p; + const target = ppath.dirname(match[1]); + if (!match[3] || !match[4]) + return target; + const isnum = NUMBER_REGEXP.test(match[4]); + if (!isnum) + return p; + const depth = Number(match[4]); + const backstep = `../`.repeat(depth); + const subpath = match[5] || `.`; + return VirtualFS.resolveVirtual(ppath.join(target, backstep, subpath)); + } + constructor({ baseFs = new NodeFS() } = {}) { + super(ppath); + this.baseFs = baseFs; + } + getExtractHint(hints) { + return this.baseFs.getExtractHint(hints); + } + getRealPath() { + return this.baseFs.getRealPath(); + } + realpathSync(p) { + const match = p.match(VIRTUAL_REGEXP); + if (!match) + return this.baseFs.realpathSync(p); + if (!match[5]) + return p; + const realpath = this.baseFs.realpathSync(this.mapToBase(p)); + return VirtualFS.makeVirtualPath(match[1], match[3], realpath); + } + async realpathPromise(p) { + const match = p.match(VIRTUAL_REGEXP); + if (!match) + return await this.baseFs.realpathPromise(p); + if (!match[5]) + return p; + const realpath = await this.baseFs.realpathPromise(this.mapToBase(p)); + return VirtualFS.makeVirtualPath(match[1], match[3], realpath); + } + mapToBase(p) { + if (p === ``) + return p; + if (this.pathUtils.isAbsolute(p)) + return VirtualFS.resolveVirtual(p); + const resolvedRoot = VirtualFS.resolveVirtual(this.baseFs.resolve(PortablePath.dot)); + const resolvedP = VirtualFS.resolveVirtual(this.baseFs.resolve(p)); + return ppath.relative(resolvedRoot, resolvedP) || PortablePath.dot; + } + mapFromBase(p) { + return p; + } } const URL = Number(process.versions.node.split('.', 1)[0]) < 20 ? URL$1 : globalThis.URL; @@ -1643,130 +1435,125 @@ const SUPPORTS_IMPORT_ATTRIBUTES = major >= 21 || major === 20 && minor >= 10 || const SUPPORTS_IMPORT_ATTRIBUTES_ONLY = major >= 22; function readPackageScope(checkPath) { - const rootSeparatorIndex = checkPath.indexOf(npath.sep); - let separatorIndex; - do { - separatorIndex = checkPath.lastIndexOf(npath.sep); - checkPath = checkPath.slice(0, separatorIndex); - if (checkPath.endsWith(`${npath.sep}node_modules`)) - return false; - const pjson = readPackage(checkPath + npath.sep); - if (pjson) { - return { - data: pjson, - path: checkPath - }; - } - } while (separatorIndex > rootSeparatorIndex); - return false; + const rootSeparatorIndex = checkPath.indexOf(npath.sep); + let separatorIndex; + do { + separatorIndex = checkPath.lastIndexOf(npath.sep); + checkPath = checkPath.slice(0, separatorIndex); + if (checkPath.endsWith(`${npath.sep}node_modules`)) + return false; + const pjson = readPackage(checkPath + npath.sep); + if (pjson) { + return { + data: pjson, + path: checkPath + }; + } + } while (separatorIndex > rootSeparatorIndex); + return false; } - function readPackage(requestPath) { - const jsonPath = npath.resolve(requestPath, `package.json`); - if (!fs.existsSync(jsonPath)) - return null; - return JSON.parse(fs.readFileSync(jsonPath, `utf8`)); + const jsonPath = npath.resolve(requestPath, `package.json`); + if (!fs.existsSync(jsonPath)) + return null; + return JSON.parse(fs.readFileSync(jsonPath, `utf8`)); } async function tryReadFile$1(path2) { - try { - return await fs.promises.readFile(path2, `utf8`); - } catch (error) { - if (error.code === `ENOENT`) - return null; - throw error; - } + try { + return await fs.promises.readFile(path2, `utf8`); + } catch (error) { + if (error.code === `ENOENT`) + return null; + throw error; + } } - function tryParseURL(str, base) { - try { - return new URL(str, base); - } catch { - return null; - } + try { + return new URL(str, base); + } catch { + return null; + } } - let entrypointPath = null; - function setEntrypointPath(file) { - entrypointPath = file; + entrypointPath = file; } - function getFileFormat(filepath) { - const ext = path.extname(filepath); - switch (ext) { - case `.mjs`: { - return `module`; - } - case `.cjs`: { - return `commonjs`; - } - case `.wasm`: { - throw new Error( - `Unknown file extension ".wasm" for ${filepath}` - ); - } - case `.json`: { - return `json`; - } - case `.js`: { - const pkg = readPackageScope(filepath); - if (!pkg) - return `commonjs`; - return pkg.data.type ?? `commonjs`; - } - default: { - if (entrypointPath !== filepath) - return null; - const pkg = readPackageScope(filepath); - if (!pkg) - return `commonjs`; - if (pkg.data.type === `module`) - return null; - return pkg.data.type ?? `commonjs`; - } + const ext = path.extname(filepath); + switch (ext) { + case `.mjs`: { + return `module`; } + case `.cjs`: { + return `commonjs`; + } + case `.wasm`: { + throw new Error( + `Unknown file extension ".wasm" for ${filepath}` + ); + } + case `.json`: { + return `json`; + } + case `.js`: { + const pkg = readPackageScope(filepath); + if (!pkg) + return `commonjs`; + return pkg.data.type ?? `commonjs`; + } + default: { + if (entrypointPath !== filepath) + return null; + const pkg = readPackageScope(filepath); + if (!pkg) + return `commonjs`; + if (pkg.data.type === `module`) + return null; + return pkg.data.type ?? `commonjs`; + } + } } async function load$1(urlString, context, nextLoad) { - const url = tryParseURL(urlString); - if (url?.protocol !== `file:`) - return nextLoad(urlString, context, nextLoad); - const filePath = fileURLToPath(url); - const format = getFileFormat(filePath); - if (!format) - return nextLoad(urlString, context, nextLoad); - if (format === `json`) { - if (SUPPORTS_IMPORT_ATTRIBUTES_ONLY) { - if (context.importAttributes?.type !== `json`) { - const err = new TypeError(`[ERR_IMPORT_ATTRIBUTE_MISSING]: Module "${urlString}" needs an import attribute of "type: json"`); - err.code = `ERR_IMPORT_ATTRIBUTE_MISSING`; - throw err; - } - } else { - const type = `importAttributes` in context ? context.importAttributes?.type : context.importAssertions?.type; - if (type !== `json`) { - const err = new TypeError(`[ERR_IMPORT_ASSERTION_TYPE_MISSING]: Module "${urlString}" needs an import ${SUPPORTS_IMPORT_ATTRIBUTES ? `attribute` : `assertion`} of type "json"`); - err.code = `ERR_IMPORT_ASSERTION_TYPE_MISSING`; - throw err; - } - } + const url = tryParseURL(urlString); + if (url?.protocol !== `file:`) + return nextLoad(urlString, context, nextLoad); + const filePath = fileURLToPath(url); + const format = getFileFormat(filePath); + if (!format) + return nextLoad(urlString, context, nextLoad); + if (format === `json`) { + if (SUPPORTS_IMPORT_ATTRIBUTES_ONLY) { + if (context.importAttributes?.type !== `json`) { + const err = new TypeError(`[ERR_IMPORT_ATTRIBUTE_MISSING]: Module "${urlString}" needs an import attribute of "type: json"`); + err.code = `ERR_IMPORT_ATTRIBUTE_MISSING`; + throw err; + } + } else { + const type = `importAttributes` in context ? context.importAttributes?.type : context.importAssertions?.type; + if (type !== `json`) { + const err = new TypeError(`[ERR_IMPORT_ASSERTION_TYPE_MISSING]: Module "${urlString}" needs an import ${SUPPORTS_IMPORT_ATTRIBUTES ? `attribute` : `assertion`} of type "json"`); + err.code = `ERR_IMPORT_ASSERTION_TYPE_MISSING`; + throw err; + } } - if (process.env.WATCH_REPORT_DEPENDENCIES && process.send) { - const pathToSend = pathToFileURL( - npath.fromPortablePath( - VirtualFS.resolveVirtual(npath.toPortablePath(filePath)) - ) - ).href; - process.send({ - "watch:import": WATCH_MODE_MESSAGE_USES_ARRAYS ? [pathToSend] : pathToSend - }); - } - return { - format, - source: format === `commonjs` ? void 0 : await fs.promises.readFile(filePath, `utf8`), - shortCircuit: true - }; + } + if (process.env.WATCH_REPORT_DEPENDENCIES && process.send) { + const pathToSend = pathToFileURL( + npath.fromPortablePath( + VirtualFS.resolveVirtual(npath.toPortablePath(filePath)) + ) + ).href; + process.send({ + "watch:import": WATCH_MODE_MESSAGE_USES_ARRAYS ? [pathToSend] : pathToSend + }); + } + return { + format, + source: format === `commonjs` ? void 0 : await fs.promises.readFile(filePath, `utf8`), + shortCircuit: true + }; } const ArrayIsArray = Array.isArray; @@ -1786,568 +1573,554 @@ const SafeMap = Map; const JSONParse = JSON.parse; function createErrorType(code, messageCreator, errorType) { - return class extends errorType { - constructor(...args) { - super(messageCreator(...args)); - this.code = code; - this.name = `${errorType.name} [${code}]`; - } - }; + return class extends errorType { + constructor(...args) { + super(messageCreator(...args)); + this.code = code; + this.name = `${errorType.name} [${code}]`; + } + }; } - const ERR_PACKAGE_IMPORT_NOT_DEFINED = createErrorType( - `ERR_PACKAGE_IMPORT_NOT_DEFINED`, - (specifier, packagePath, base) => { - return `Package import specifier "${specifier}" is not defined${packagePath ? ` in package ${packagePath}package.json` : ``} imported from ${base}`; - }, - TypeError + `ERR_PACKAGE_IMPORT_NOT_DEFINED`, + (specifier, packagePath, base) => { + return `Package import specifier "${specifier}" is not defined${packagePath ? ` in package ${packagePath}package.json` : ``} imported from ${base}`; + }, + TypeError ); const ERR_INVALID_MODULE_SPECIFIER = createErrorType( - `ERR_INVALID_MODULE_SPECIFIER`, - (request, reason, base = void 0) => { - return `Invalid module "${request}" ${reason}${base ? ` imported from ${base}` : ``}`; - }, - TypeError + `ERR_INVALID_MODULE_SPECIFIER`, + (request, reason, base = void 0) => { + return `Invalid module "${request}" ${reason}${base ? ` imported from ${base}` : ``}`; + }, + TypeError ); const ERR_INVALID_PACKAGE_TARGET = createErrorType( - `ERR_INVALID_PACKAGE_TARGET`, - (pkgPath, key, target, isImport = false, base = void 0) => { - const relError = typeof target === `string` && !isImport && target.length && !StringPrototypeStartsWith(target, `./`); - if (key === `.`) { - assert(isImport === false); - return `Invalid "exports" main target ${JSONStringify(target)} defined in the package config ${pkgPath}package.json${base ? ` imported from ${base}` : ``}${relError ? `; targets must start with "./"` : ``}`; - } - return `Invalid "${isImport ? `imports` : `exports`}" target ${JSONStringify( - target - )} defined for '${key}' in the package config ${pkgPath}package.json${base ? ` imported from ${base}` : ``}${relError ? `; targets must start with "./"` : ``}`; - }, - Error + `ERR_INVALID_PACKAGE_TARGET`, + (pkgPath, key, target, isImport = false, base = void 0) => { + const relError = typeof target === `string` && !isImport && target.length && !StringPrototypeStartsWith(target, `./`); + if (key === `.`) { + assert(isImport === false); + return `Invalid "exports" main target ${JSONStringify(target)} defined in the package config ${pkgPath}package.json${base ? ` imported from ${base}` : ``}${relError ? `; targets must start with "./"` : ``}`; + } + return `Invalid "${isImport ? `imports` : `exports`}" target ${JSONStringify( + target + )} defined for '${key}' in the package config ${pkgPath}package.json${base ? ` imported from ${base}` : ``}${relError ? `; targets must start with "./"` : ``}`; + }, + Error ); const ERR_INVALID_PACKAGE_CONFIG = createErrorType( - `ERR_INVALID_PACKAGE_CONFIG`, - (path, base, message) => { - return `Invalid package config ${path}${base ? ` while importing ${base}` : ``}${message ? `. ${message}` : ``}`; - }, - Error + `ERR_INVALID_PACKAGE_CONFIG`, + (path, base, message) => { + return `Invalid package config ${path}${base ? ` while importing ${base}` : ``}${message ? `. ${message}` : ``}`; + }, + Error ); function filterOwnProperties(source, keys) { - const filtered = /* @__PURE__ */ Object.create(null); - for (let i = 0; i < keys.length; i++) { - const key = keys[i]; - if (ObjectPrototypeHasOwnProperty(source, key)) { - filtered[key] = source[key]; - } + const filtered = /* @__PURE__ */ Object.create(null); + for (let i = 0; i < keys.length; i++) { + const key = keys[i]; + if (ObjectPrototypeHasOwnProperty(source, key)) { + filtered[key] = source[key]; } - return filtered; + } + return filtered; } const packageJSONCache = new SafeMap(); - function getPackageConfig(path, specifier, base, readFileSyncFn) { - const existing = packageJSONCache.get(path); - if (existing !== void 0) { - return existing; - } - const source = readFileSyncFn(path); - if (source === void 0) { - const packageConfig2 = { - pjsonPath: path, - exists: false, - main: void 0, - name: void 0, - type: "none", - exports: void 0, - imports: void 0 - }; - packageJSONCache.set(path, packageConfig2); - return packageConfig2; - } - let packageJSON; - try { - packageJSON = JSONParse(source); - } catch (error) { - throw new ERR_INVALID_PACKAGE_CONFIG( - path, - (base ? `"${specifier}" from ` : "") + fileURLToPath(base || specifier), - error.message - ); - } - let {imports, main, name, type} = filterOwnProperties(packageJSON, [ - "imports", - "main", - "name", - "type" - ]); - const exports = ObjectPrototypeHasOwnProperty(packageJSON, "exports") ? packageJSON.exports : void 0; - if (typeof imports !== "object" || imports === null) { - imports = void 0; - } - if (typeof main !== "string") { - main = void 0; - } - if (typeof name !== "string") { - name = void 0; - } - if (type !== "module" && type !== "commonjs") { - type = "none"; - } - const packageConfig = { - pjsonPath: path, - exists: true, - main, - name, - type, - exports, - imports + const existing = packageJSONCache.get(path); + if (existing !== void 0) { + return existing; + } + const source = readFileSyncFn(path); + if (source === void 0) { + const packageConfig2 = { + pjsonPath: path, + exists: false, + main: void 0, + name: void 0, + type: "none", + exports: void 0, + imports: void 0 }; - packageJSONCache.set(path, packageConfig); - return packageConfig; + packageJSONCache.set(path, packageConfig2); + return packageConfig2; + } + let packageJSON; + try { + packageJSON = JSONParse(source); + } catch (error) { + throw new ERR_INVALID_PACKAGE_CONFIG( + path, + (base ? `"${specifier}" from ` : "") + fileURLToPath(base || specifier), + error.message + ); + } + let { imports, main, name, type } = filterOwnProperties(packageJSON, [ + "imports", + "main", + "name", + "type" + ]); + const exports = ObjectPrototypeHasOwnProperty(packageJSON, "exports") ? packageJSON.exports : void 0; + if (typeof imports !== "object" || imports === null) { + imports = void 0; + } + if (typeof main !== "string") { + main = void 0; + } + if (typeof name !== "string") { + name = void 0; + } + if (type !== "module" && type !== "commonjs") { + type = "none"; + } + const packageConfig = { + pjsonPath: path, + exists: true, + main, + name, + type, + exports, + imports + }; + packageJSONCache.set(path, packageConfig); + return packageConfig; } - function getPackageScopeConfig(resolved, readFileSyncFn) { - let packageJSONUrl = new URL("./package.json", resolved); - while (true) { - const packageJSONPath2 = packageJSONUrl.pathname; - if (StringPrototypeEndsWith(packageJSONPath2, "node_modules/package.json")) { - break; - } - const packageConfig2 = getPackageConfig( - fileURLToPath(packageJSONUrl), - resolved, - void 0, - readFileSyncFn - ); - if (packageConfig2.exists) { - return packageConfig2; - } - const lastPackageJSONUrl = packageJSONUrl; - packageJSONUrl = new URL("../package.json", packageJSONUrl); - if (packageJSONUrl.pathname === lastPackageJSONUrl.pathname) { - break; - } + let packageJSONUrl = new URL("./package.json", resolved); + while (true) { + const packageJSONPath2 = packageJSONUrl.pathname; + if (StringPrototypeEndsWith(packageJSONPath2, "node_modules/package.json")) { + break; } - const packageJSONPath = fileURLToPath(packageJSONUrl); - const packageConfig = { - pjsonPath: packageJSONPath, - exists: false, - main: void 0, - name: void 0, - type: "none", - exports: void 0, - imports: void 0 - }; - packageJSONCache.set(packageJSONPath, packageConfig); - return packageConfig; + const packageConfig2 = getPackageConfig( + fileURLToPath(packageJSONUrl), + resolved, + void 0, + readFileSyncFn + ); + if (packageConfig2.exists) { + return packageConfig2; + } + const lastPackageJSONUrl = packageJSONUrl; + packageJSONUrl = new URL("../package.json", packageJSONUrl); + if (packageJSONUrl.pathname === lastPackageJSONUrl.pathname) { + break; + } + } + const packageJSONPath = fileURLToPath(packageJSONUrl); + const packageConfig = { + pjsonPath: packageJSONPath, + exists: false, + main: void 0, + name: void 0, + type: "none", + exports: void 0, + imports: void 0 + }; + packageJSONCache.set(packageJSONPath, packageConfig); + return packageConfig; } function throwImportNotDefined(specifier, packageJSONUrl, base) { - throw new ERR_PACKAGE_IMPORT_NOT_DEFINED( - specifier, - packageJSONUrl && fileURLToPath(new URL(".", packageJSONUrl)), - fileURLToPath(base) - ); + throw new ERR_PACKAGE_IMPORT_NOT_DEFINED( + specifier, + packageJSONUrl && fileURLToPath(new URL(".", packageJSONUrl)), + fileURLToPath(base) + ); } - function throwInvalidSubpath(subpath, packageJSONUrl, internal, base) { - const reason = `request is not a valid subpath for the "${internal ? "imports" : "exports"}" resolution of ${fileURLToPath(packageJSONUrl)}`; - throw new ERR_INVALID_MODULE_SPECIFIER( - subpath, - reason, - base && fileURLToPath(base) - ); + const reason = `request is not a valid subpath for the "${internal ? "imports" : "exports"}" resolution of ${fileURLToPath(packageJSONUrl)}`; + throw new ERR_INVALID_MODULE_SPECIFIER( + subpath, + reason, + base && fileURLToPath(base) + ); } - function throwInvalidPackageTarget(subpath, target, packageJSONUrl, internal, base) { - if (typeof target === "object" && target !== null) { - target = JSONStringify(target, null, ""); - } else { - target = `${target}`; - } - throw new ERR_INVALID_PACKAGE_TARGET( - fileURLToPath(new URL(".", packageJSONUrl)), - subpath, - target, - internal, - base && fileURLToPath(base) - ); + if (typeof target === "object" && target !== null) { + target = JSONStringify(target, null, ""); + } else { + target = `${target}`; + } + throw new ERR_INVALID_PACKAGE_TARGET( + fileURLToPath(new URL(".", packageJSONUrl)), + subpath, + target, + internal, + base && fileURLToPath(base) + ); } - const invalidSegmentRegEx = /(^|\\|\/)((\.|%2e)(\.|%2e)?|(n|%6e|%4e)(o|%6f|%4f)(d|%64|%44)(e|%65|%45)(_|%5f)(m|%6d|%4d)(o|%6f|%4f)(d|%64|%44)(u|%75|%55)(l|%6c|%4c)(e|%65|%45)(s|%73|%53))(\\|\/|$)/i; const patternRegEx = /\*/g; - function resolvePackageTargetString(target, subpath, match, packageJSONUrl, base, pattern, internal, conditions) { - if (subpath !== "" && !pattern && target[target.length - 1] !== "/") - throwInvalidPackageTarget(match, target, packageJSONUrl, internal, base); - if (!StringPrototypeStartsWith(target, "./")) { - if (internal && !StringPrototypeStartsWith(target, "../") && !StringPrototypeStartsWith(target, "/")) { - let isURL = false; - try { - new URL(target); - isURL = true; - } catch { - } - if (!isURL) { - const exportTarget = pattern ? RegExpPrototypeSymbolReplace(patternRegEx, target, () => subpath) : target + subpath; - return exportTarget; - } - } - throwInvalidPackageTarget(match, target, packageJSONUrl, internal, base); + if (subpath !== "" && !pattern && target[target.length - 1] !== "/") + throwInvalidPackageTarget(match, target, packageJSONUrl, internal, base); + if (!StringPrototypeStartsWith(target, "./")) { + if (internal && !StringPrototypeStartsWith(target, "../") && !StringPrototypeStartsWith(target, "/")) { + let isURL = false; + try { + new URL(target); + isURL = true; + } catch { + } + if (!isURL) { + const exportTarget = pattern ? RegExpPrototypeSymbolReplace(patternRegEx, target, () => subpath) : target + subpath; + return exportTarget; + } } - if (RegExpPrototypeExec( - invalidSegmentRegEx, - StringPrototypeSlice(target, 2) - ) !== null) - throwInvalidPackageTarget(match, target, packageJSONUrl, internal, base); - const resolved = new URL(target, packageJSONUrl); - const resolvedPath = resolved.pathname; - const packagePath = new URL(".", packageJSONUrl).pathname; - if (!StringPrototypeStartsWith(resolvedPath, packagePath)) - throwInvalidPackageTarget(match, target, packageJSONUrl, internal, base); - if (subpath === "") return resolved; - if (RegExpPrototypeExec(invalidSegmentRegEx, subpath) !== null) { - const request = pattern ? StringPrototypeReplace(match, "*", () => subpath) : match + subpath; - throwInvalidSubpath(request, packageJSONUrl, internal, base); - } - if (pattern) { - return new URL( - RegExpPrototypeSymbolReplace(patternRegEx, resolved.href, () => subpath) - ); - } - return new URL(subpath, resolved); -} - -function isArrayIndex(key) { - const keyNum = +key; - if (`${keyNum}` !== key) return false; - return keyNum >= 0 && keyNum < 4294967295; -} - -function resolvePackageTarget(packageJSONUrl, target, subpath, packageSubpath, base, pattern, internal, conditions) { - if (typeof target === "string") { - return resolvePackageTargetString( - target, - subpath, - packageSubpath, - packageJSONUrl, - base, - pattern, - internal); - } else if (ArrayIsArray(target)) { - if (target.length === 0) { - return null; - } - let lastException; - for (let i = 0; i < target.length; i++) { - const targetItem = target[i]; - let resolveResult; - try { - resolveResult = resolvePackageTarget( - packageJSONUrl, - targetItem, - subpath, - packageSubpath, - base, - pattern, - internal, - conditions - ); - } catch (e) { - lastException = e; - if (e.code === "ERR_INVALID_PACKAGE_TARGET") { - continue; - } - throw e; - } - if (resolveResult === void 0) { - continue; - } - if (resolveResult === null) { - lastException = null; - continue; - } - return resolveResult; - } - if (lastException === void 0 || lastException === null) - return lastException; - throw lastException; - } else if (typeof target === "object" && target !== null) { - const keys = ObjectGetOwnPropertyNames(target); - for (let i = 0; i < keys.length; i++) { - const key = keys[i]; - if (isArrayIndex(key)) { - throw new ERR_INVALID_PACKAGE_CONFIG( - fileURLToPath(packageJSONUrl), - base, - '"exports" cannot contain numeric property keys.' - ); - } - } - for (let i = 0; i < keys.length; i++) { - const key = keys[i]; - if (key === "default" || conditions.has(key)) { - const conditionalTarget = target[key]; - const resolveResult = resolvePackageTarget( - packageJSONUrl, - conditionalTarget, - subpath, - packageSubpath, - base, - pattern, - internal, - conditions - ); - if (resolveResult === void 0) continue; - return resolveResult; - } - } - return void 0; - } else if (target === null) { - return null; - } - throwInvalidPackageTarget( - packageSubpath, - target, - packageJSONUrl, - internal, - base + throwInvalidPackageTarget(match, target, packageJSONUrl, internal, base); + } + if (RegExpPrototypeExec( + invalidSegmentRegEx, + StringPrototypeSlice(target, 2) + ) !== null) + throwInvalidPackageTarget(match, target, packageJSONUrl, internal, base); + const resolved = new URL(target, packageJSONUrl); + const resolvedPath = resolved.pathname; + const packagePath = new URL(".", packageJSONUrl).pathname; + if (!StringPrototypeStartsWith(resolvedPath, packagePath)) + throwInvalidPackageTarget(match, target, packageJSONUrl, internal, base); + if (subpath === "") return resolved; + if (RegExpPrototypeExec(invalidSegmentRegEx, subpath) !== null) { + const request = pattern ? StringPrototypeReplace(match, "*", () => subpath) : match + subpath; + throwInvalidSubpath(request, packageJSONUrl, internal, base); + } + if (pattern) { + return new URL( + RegExpPrototypeSymbolReplace(patternRegEx, resolved.href, () => subpath) ); + } + return new URL(subpath, resolved); } - -function patternKeyCompare(a, b) { - const aPatternIndex = StringPrototypeIndexOf(a, "*"); - const bPatternIndex = StringPrototypeIndexOf(b, "*"); - const baseLenA = aPatternIndex === -1 ? a.length : aPatternIndex + 1; - const baseLenB = bPatternIndex === -1 ? b.length : bPatternIndex + 1; - if (baseLenA > baseLenB) return -1; - if (baseLenB > baseLenA) return 1; - if (aPatternIndex === -1) return 1; - if (bPatternIndex === -1) return -1; - if (a.length > b.length) return -1; - if (b.length > a.length) return 1; - return 0; +function isArrayIndex(key) { + const keyNum = +key; + if (`${keyNum}` !== key) return false; + return keyNum >= 0 && keyNum < 4294967295; } - -function packageImportsResolve({name, base, conditions, readFileSyncFn}) { - if (name === "#" || StringPrototypeStartsWith(name, "#/") || StringPrototypeEndsWith(name, "/")) { - const reason = "is not a valid internal imports specifier name"; - throw new ERR_INVALID_MODULE_SPECIFIER(name, reason, fileURLToPath(base)); +function resolvePackageTarget(packageJSONUrl, target, subpath, packageSubpath, base, pattern, internal, conditions) { + if (typeof target === "string") { + return resolvePackageTargetString( + target, + subpath, + packageSubpath, + packageJSONUrl, + base, + pattern, + internal); + } else if (ArrayIsArray(target)) { + if (target.length === 0) { + return null; } - let packageJSONUrl; - const packageConfig = getPackageScopeConfig(base, readFileSyncFn); - if (packageConfig.exists) { - packageJSONUrl = pathToFileURL(packageConfig.pjsonPath); - const imports = packageConfig.imports; - if (imports) { - if (ObjectPrototypeHasOwnProperty(imports, name) && !StringPrototypeIncludes(name, "*")) { - const resolveResult = resolvePackageTarget( - packageJSONUrl, - imports[name], - "", - name, - base, - false, - true, - conditions - ); - if (resolveResult != null) { - return resolveResult; - } - } else { - let bestMatch = ""; - let bestMatchSubpath; - const keys = ObjectGetOwnPropertyNames(imports); - for (let i = 0; i < keys.length; i++) { - const key = keys[i]; - const patternIndex = StringPrototypeIndexOf(key, "*"); - if (patternIndex !== -1 && StringPrototypeStartsWith( - name, - StringPrototypeSlice(key, 0, patternIndex) - )) { - const patternTrailer = StringPrototypeSlice(key, patternIndex + 1); - if (name.length >= key.length && StringPrototypeEndsWith(name, patternTrailer) && patternKeyCompare(bestMatch, key) === 1 && StringPrototypeLastIndexOf(key, "*") === patternIndex) { - bestMatch = key; - bestMatchSubpath = StringPrototypeSlice( - name, - patternIndex, - name.length - patternTrailer.length - ); - } - } - } - if (bestMatch) { - const target = imports[bestMatch]; - const resolveResult = resolvePackageTarget( - packageJSONUrl, - target, - bestMatchSubpath, - bestMatch, - base, - true, - true, - conditions - ); - if (resolveResult != null) { - return resolveResult; - } - } - } + let lastException; + for (let i = 0; i < target.length; i++) { + const targetItem = target[i]; + let resolveResult; + try { + resolveResult = resolvePackageTarget( + packageJSONUrl, + targetItem, + subpath, + packageSubpath, + base, + pattern, + internal, + conditions + ); + } catch (e) { + lastException = e; + if (e.code === "ERR_INVALID_PACKAGE_TARGET") { + continue; } + throw e; + } + if (resolveResult === void 0) { + continue; + } + if (resolveResult === null) { + lastException = null; + continue; + } + return resolveResult; } - throwImportNotDefined(name, packageJSONUrl, base); + if (lastException === void 0 || lastException === null) + return lastException; + throw lastException; + } else if (typeof target === "object" && target !== null) { + const keys = ObjectGetOwnPropertyNames(target); + for (let i = 0; i < keys.length; i++) { + const key = keys[i]; + if (isArrayIndex(key)) { + throw new ERR_INVALID_PACKAGE_CONFIG( + fileURLToPath(packageJSONUrl), + base, + '"exports" cannot contain numeric property keys.' + ); + } + } + for (let i = 0; i < keys.length; i++) { + const key = keys[i]; + if (key === "default" || conditions.has(key)) { + const conditionalTarget = target[key]; + const resolveResult = resolvePackageTarget( + packageJSONUrl, + conditionalTarget, + subpath, + packageSubpath, + base, + pattern, + internal, + conditions + ); + if (resolveResult === void 0) continue; + return resolveResult; + } + } + return void 0; + } else if (target === null) { + return null; + } + throwInvalidPackageTarget( + packageSubpath, + target, + packageJSONUrl, + internal, + base + ); +} +function patternKeyCompare(a, b) { + const aPatternIndex = StringPrototypeIndexOf(a, "*"); + const bPatternIndex = StringPrototypeIndexOf(b, "*"); + const baseLenA = aPatternIndex === -1 ? a.length : aPatternIndex + 1; + const baseLenB = bPatternIndex === -1 ? b.length : bPatternIndex + 1; + if (baseLenA > baseLenB) return -1; + if (baseLenB > baseLenA) return 1; + if (aPatternIndex === -1) return 1; + if (bPatternIndex === -1) return -1; + if (a.length > b.length) return -1; + if (b.length > a.length) return 1; + return 0; +} +function packageImportsResolve({ name, base, conditions, readFileSyncFn }) { + if (name === "#" || StringPrototypeStartsWith(name, "#/") || StringPrototypeEndsWith(name, "/")) { + const reason = "is not a valid internal imports specifier name"; + throw new ERR_INVALID_MODULE_SPECIFIER(name, reason, fileURLToPath(base)); + } + let packageJSONUrl; + const packageConfig = getPackageScopeConfig(base, readFileSyncFn); + if (packageConfig.exists) { + packageJSONUrl = pathToFileURL(packageConfig.pjsonPath); + const imports = packageConfig.imports; + if (imports) { + if (ObjectPrototypeHasOwnProperty(imports, name) && !StringPrototypeIncludes(name, "*")) { + const resolveResult = resolvePackageTarget( + packageJSONUrl, + imports[name], + "", + name, + base, + false, + true, + conditions + ); + if (resolveResult != null) { + return resolveResult; + } + } else { + let bestMatch = ""; + let bestMatchSubpath; + const keys = ObjectGetOwnPropertyNames(imports); + for (let i = 0; i < keys.length; i++) { + const key = keys[i]; + const patternIndex = StringPrototypeIndexOf(key, "*"); + if (patternIndex !== -1 && StringPrototypeStartsWith( + name, + StringPrototypeSlice(key, 0, patternIndex) + )) { + const patternTrailer = StringPrototypeSlice(key, patternIndex + 1); + if (name.length >= key.length && StringPrototypeEndsWith(name, patternTrailer) && patternKeyCompare(bestMatch, key) === 1 && StringPrototypeLastIndexOf(key, "*") === patternIndex) { + bestMatch = key; + bestMatchSubpath = StringPrototypeSlice( + name, + patternIndex, + name.length - patternTrailer.length + ); + } + } + } + if (bestMatch) { + const target = imports[bestMatch]; + const resolveResult = resolvePackageTarget( + packageJSONUrl, + target, + bestMatchSubpath, + bestMatch, + base, + true, + true, + conditions + ); + if (resolveResult != null) { + return resolveResult; + } + } + } + } + } + throwImportNotDefined(name, packageJSONUrl, base); } let findPnpApi = esmModule.findPnpApi; if (!findPnpApi) { - const require = createRequire(import.meta.url); - const pnpApi = require(`./.pnp.cjs`); - pnpApi.setup(); - findPnpApi = esmModule.findPnpApi; + const require = createRequire(import.meta.url); + const pnpApi = require(`./.pnp.cjs`); + pnpApi.setup(); + findPnpApi = esmModule.findPnpApi; } const pathRegExp = /^(?![a-zA-Z]:[\\/]|\\\\|\.{0,2}(?:\/|$))((?:node:)?(?:@[^/]+\/)?[^/]+)\/*(.*|)$/; const isRelativeRegexp = /^\.{0,2}\//; - function tryReadFile(filePath) { - try { - return fs.readFileSync(filePath, `utf8`); - } catch (err) { - if (err.code === `ENOENT`) - return void 0; - throw err; - } + try { + return fs.readFileSync(filePath, `utf8`); + } catch (err) { + if (err.code === `ENOENT`) + return void 0; + throw err; + } } - async function resolvePrivateRequest(specifier, issuer, context, nextResolve) { - const resolved = packageImportsResolve({ - name: specifier, - base: pathToFileURL(issuer), - conditions: new Set(context.conditions), - readFileSyncFn: tryReadFile - }); - if (resolved instanceof URL) { - return {url: resolved.href, shortCircuit: true}; - } else { - if (resolved.startsWith(`#`)) - throw new Error(`Mapping from one private import to another isn't allowed`); - return resolve$1(resolved, context, nextResolve); - } + const resolved = packageImportsResolve({ + name: specifier, + base: pathToFileURL(issuer), + conditions: new Set(context.conditions), + readFileSyncFn: tryReadFile + }); + if (resolved instanceof URL) { + return { url: resolved.href, shortCircuit: true }; + } else { + if (resolved.startsWith(`#`)) + throw new Error(`Mapping from one private import to another isn't allowed`); + return resolve$1(resolved, context, nextResolve); + } } - async function resolve$1(originalSpecifier, context, nextResolve) { - if (!findPnpApi || isBuiltin(originalSpecifier)) - return nextResolve(originalSpecifier, context, nextResolve); - let specifier = originalSpecifier; - const url = tryParseURL(specifier, isRelativeRegexp.test(specifier) ? context.parentURL : void 0); - if (url) { - if (url.protocol !== `file:`) - return nextResolve(originalSpecifier, context, nextResolve); - specifier = fileURLToPath(url); - } - const {parentURL, conditions = []} = context; - const issuer = parentURL && tryParseURL(parentURL)?.protocol === `file:` ? fileURLToPath(parentURL) : process.cwd(); - const pnpapi = findPnpApi(issuer) ?? (url ? findPnpApi(specifier) : null); - if (!pnpapi) - return nextResolve(originalSpecifier, context, nextResolve); - if (specifier.startsWith(`#`)) - return resolvePrivateRequest(specifier, issuer, context, nextResolve); - const dependencyNameMatch = specifier.match(pathRegExp); - let allowLegacyResolve = false; - if (dependencyNameMatch) { - const [, dependencyName, subPath] = dependencyNameMatch; - if (subPath === `` && dependencyName !== `pnpapi`) { - const resolved = pnpapi.resolveToUnqualified(`${dependencyName}/package.json`, issuer); - if (resolved) { - const content = await tryReadFile$1(resolved); - if (content) { - const pkg = JSON.parse(content); - allowLegacyResolve = pkg.exports == null; - } - } + if (!findPnpApi || isBuiltin(originalSpecifier)) + return nextResolve(originalSpecifier, context, nextResolve); + let specifier = originalSpecifier; + const url = tryParseURL(specifier, isRelativeRegexp.test(specifier) ? context.parentURL : void 0); + if (url) { + if (url.protocol !== `file:`) + return nextResolve(originalSpecifier, context, nextResolve); + specifier = fileURLToPath(url); + } + const { parentURL, conditions = [] } = context; + const issuer = parentURL && tryParseURL(parentURL)?.protocol === `file:` ? fileURLToPath(parentURL) : process.cwd(); + const pnpapi = findPnpApi(issuer) ?? (url ? findPnpApi(specifier) : null); + if (!pnpapi) + return nextResolve(originalSpecifier, context, nextResolve); + if (specifier.startsWith(`#`)) + return resolvePrivateRequest(specifier, issuer, context, nextResolve); + const dependencyNameMatch = specifier.match(pathRegExp); + let allowLegacyResolve = false; + if (dependencyNameMatch) { + const [, dependencyName, subPath] = dependencyNameMatch; + if (subPath === `` && dependencyName !== `pnpapi`) { + const resolved = pnpapi.resolveToUnqualified(`${dependencyName}/package.json`, issuer); + if (resolved) { + const content = await tryReadFile$1(resolved); + if (content) { + const pkg = JSON.parse(content); + allowLegacyResolve = pkg.exports == null; } + } } - let result; - try { - result = pnpapi.resolveRequest(specifier, issuer, { - conditions: new Set(conditions), - // TODO: Handle --experimental-specifier-resolution=node - extensions: allowLegacyResolve ? void 0 : [] - }); - } catch (err) { - if (err instanceof Error && `code` in err && err.code === `MODULE_NOT_FOUND`) - err.code = `ERR_MODULE_NOT_FOUND`; - throw err; - } - if (!result) - throw new Error(`Resolving '${specifier}' from '${issuer}' failed`); - const resultURL = pathToFileURL(result); - if (url) { - resultURL.search = url.search; - resultURL.hash = url.hash; - } - if (!parentURL) - setEntrypointPath(fileURLToPath(resultURL)); - return { - url: resultURL.href, - shortCircuit: true - }; + } + let result; + try { + result = pnpapi.resolveRequest(specifier, issuer, { + conditions: new Set(conditions), + // TODO: Handle --experimental-specifier-resolution=node + extensions: allowLegacyResolve ? void 0 : [] + }); + } catch (err) { + if (err instanceof Error && `code` in err && err.code === `MODULE_NOT_FOUND`) + err.code = `ERR_MODULE_NOT_FOUND`; + throw err; + } + if (!result) + throw new Error(`Resolving '${specifier}' from '${issuer}' failed`); + const resultURL = pathToFileURL(result); + if (url) { + resultURL.search = url.search; + resultURL.hash = url.hash; + } + if (!parentURL) + setEntrypointPath(fileURLToPath(resultURL)); + return { + url: resultURL.href, + shortCircuit: true + }; } if (!HAS_LAZY_LOADED_TRANSLATORS) { - const binding = process.binding(`fs`); - const originalReadFile = binding.readFileUtf8 || binding.readFileSync; - if (originalReadFile) { - binding[originalReadFile.name] = function (...args) { - try { - return fs.readFileSync(args[0], { - encoding: `utf8`, - // @ts-expect-error - The docs says it needs to be a string but - // links to https://nodejs.org/dist/latest-v20.x/docs/api/fs.html#file-system-flags - // which says it can be a number which matches the implementation. - flag: args[1] - }); - } catch { - } - return originalReadFile.apply(this, args); - }; - } else { - const binding2 = process.binding(`fs`); - const originalfstat = binding2.fstat; - const ZIP_MASK = 4278190080; - const ZIP_MAGIC = 704643072; - binding2.fstat = function (...args) { - const [fd, useBigint, req] = args; - if ((fd & ZIP_MASK) === ZIP_MAGIC && useBigint === false && req === void 0) { - try { - const stats = fs.fstatSync(fd); - return new Float64Array([ - stats.dev, - stats.mode, - stats.nlink, - stats.uid, - stats.gid, - stats.rdev, - stats.blksize, - stats.ino, - stats.size, - stats.blocks - // atime sec - // atime ns - // mtime sec - // mtime ns - // ctime sec - // ctime ns - // birthtime sec - // birthtime ns - ]); - } catch { - } - } - return originalfstat.apply(this, args); - }; - } + const binding = process.binding(`fs`); + const originalReadFile = binding.readFileUtf8 || binding.readFileSync; + if (originalReadFile) { + binding[originalReadFile.name] = function(...args) { + try { + return fs.readFileSync(args[0], { + encoding: `utf8`, + // @ts-expect-error - The docs says it needs to be a string but + // links to https://nodejs.org/dist/latest-v20.x/docs/api/fs.html#file-system-flags + // which says it can be a number which matches the implementation. + flag: args[1] + }); + } catch { + } + return originalReadFile.apply(this, args); + }; + } else { + const binding2 = process.binding(`fs`); + const originalfstat = binding2.fstat; + const ZIP_MASK = 4278190080; + const ZIP_MAGIC = 704643072; + binding2.fstat = function(...args) { + const [fd, useBigint, req] = args; + if ((fd & ZIP_MASK) === ZIP_MAGIC && useBigint === false && req === void 0) { + try { + const stats = fs.fstatSync(fd); + return new Float64Array([ + stats.dev, + stats.mode, + stats.nlink, + stats.uid, + stats.gid, + stats.rdev, + stats.blksize, + stats.ino, + stats.size, + stats.blocks + // atime sec + // atime ns + // mtime sec + // mtime ns + // ctime sec + // ctime ns + // birthtime sec + // birthtime ns + ]); + } catch { + } + } + return originalfstat.apply(this, args); + }; + } } const resolve = resolve$1; const load = load$1; -export {load, resolve}; +export { load, resolve }; diff --git a/docs/create_module.md b/docs/create_module.md index a1cc697..8d96803 100644 --- a/docs/create_module.md +++ b/docs/create_module.md @@ -26,7 +26,7 @@ should set your version to that as well. You should also look for this block of code in your `build.gradle.kts file`: -```kts title=build.gradle.kts +```kotlin title="build.gradle.kts" tasks.getByName("jar") { archiveBaseName.set("Module-ExampleModule") archiveVersion.set("") @@ -48,7 +48,7 @@ Plex. When you create a new command, you should register it in your main class as follows -```java +```java title="/src/main/java/ExampleModule.java" registerCommand(new ExampleCommand()); ``` @@ -66,14 +66,19 @@ the main command inside of the actual `execute()` block. Listeners function just like they do in Bukkit, they listen for events. You'll want to do two things. Make sure your listener extends the `PlexListener` class rather than the Bukkit default `Listener` class. The `PlexListener` class is a -wrapper for the `Listener` class and has the same functionality as the Bukkit one. You'll also want to ensure you register the listener in the main class as follows: -```java +wrapper for the `Listener` class and has the same functionality as the Bukkit one. You'll also want to ensure you +register the listener in the main class as follows: + +```java title="/src/main/java/ExampleModule.java" registerListener(new ExampleListener()); ``` + Make sure you replace the `ExampleListener` class with your own class name. -You can listen for as many events as you like per class. An example to listen for an event when a player joins and send them a message is as follows: -```java +You can listen for as many events as you like per class. An example to listen for an event when a player joins and send +them a message is as follows: + +```java title="/src/main/java/ExampleModule.java" @EventHandler public void onPlayerJoin(PlayerJoinEvent event) { @@ -81,3 +86,37 @@ public void onPlayerJoin(PlayerJoinEvent event) player.sendMessage(Component.text("This is a message from Plex's example module!").color(NamedTextColor.GOLD)); } ``` + +## Creating and using configuration files + +To create a configuration file for your module, you should create a new folder in the `/src/main/resources` directory +with the module name. An example for the example module would be `/src/main/resources/examplemodule`. Within the folder, +you can create your `config.yml` file. In the main class, you should add a new `ModuleConfig` globally, and load it on +the `load()` method. + +```java title="/src/main/java/ExampleModule.java" +public class ExampleModule extends PlexModule +{ + @Getter + private static ExampleModule module; + + @Getter + private ModuleConfig config; + + @Override + public void load() + { + module = this; + config = new ModuleConfig(this, "examplemodule/config.yml", "config.yml"); + config.load(); + } +} +``` + +The `"tfmextras/config.yml"` part refers to where the configuration file is stored relative to `/src/main/resources`. +The `"config.yml"` refers to where it should go inside the `/plugins/Plex/modules/Module-Example` folder. + +You can then call values from the configuration with the following: +```java +ExampleModule.getModule().getConfig().getString("module.test-message"); +``` \ No newline at end of file diff --git a/docs/customization/commandblocker.md b/docs/customization/commandblocker.md index bd228f1..b8d4891 100644 --- a/docs/customization/commandblocker.md +++ b/docs/customization/commandblocker.md @@ -12,7 +12,7 @@ this only in conjunction with ranks. If you are using permissions, there is not The default `commands.yml` file is below. -```yaml title=/plugins/Plex/commands.yml +```yaml title="/plugins/Plex/commands.yml" # # Command Blocker # diff --git a/docs/customization/config.md b/docs/customization/config.md index 881d8ff..dacbbf2 100644 --- a/docs/customization/config.md +++ b/docs/customization/config.md @@ -12,7 +12,7 @@ This page will show you how to modify the configuration file. The configuration Below is the default `config.yml` file when Plex is loaded for the first time. -```yaml title=/plugins/Plex/config.yml +```yaml title="/plugins/Plex/config.yml" # Plex Configuration File # For documentation, please visit: https://plex.us.org diff --git a/docs/customization/messages.md b/docs/customization/messages.md index 9e84301..0af5b06 100644 --- a/docs/customization/messages.md +++ b/docs/customization/messages.md @@ -12,7 +12,7 @@ Almost all the messages inside of Plex are fully customizable. This page will do The default `messages.yml` file is below. -```yaml title=/plugins/Plex/messages.yml +```yaml title="/plugins/Plex/messages.yml" # Plex Messages File # This file uses the MiniMessage system. # Documentation available at https://docs.adventure.kyori.net/minimessage/format.html diff --git a/docs/indefinitebans.md b/docs/indefinitebans.md index bb4459f..fd48e88 100644 --- a/docs/indefinitebans.md +++ b/docs/indefinitebans.md @@ -15,7 +15,7 @@ bans. ## Default file -```yaml title=/plugins/Plex/indefbans.yml +```yaml title="/plugins/Plex/indefbans.yml" # Plex Indefinite Bans File # Players with their UUID / IP / Usernames in here will be indefinitely banned until removed diff --git a/docs/redis.mdx b/docs/redis.mdx index 5ae1efe..61a7709 100644 --- a/docs/redis.mdx +++ b/docs/redis.mdx @@ -39,7 +39,7 @@ The password for Redis is set under the "Service Variables" tab. Please change i ### Configuration Once the Redis server has been installed, go to the "File Manager" tab and open `redis.conf`. You will need to change the bind address. -```title=redis.conf +```conf title="redis.conf" ... ################################## NETWORK ##################################### @@ -73,7 +73,7 @@ Find this block in your Redis configuration file and ensure bind is set to `172. ### Plex Configuration Redis should be successfully set up! Now all you have to do is enter your credentials into the Plex configuration file. -```yaml title=/plugins/Plex/config.yml +```yaml title="/plugins/Plex/config.yml" side: enabled: true auth: true diff --git a/docs/versions.md b/docs/versions.md index beae06a..bce9281 100644 --- a/docs/versions.md +++ b/docs/versions.md @@ -14,7 +14,7 @@ generation support has been added to the official API. | Plex Version | Minecraft Versions | |--------------|--------------------| -| 1.5-SNAPSHOT | 1.20.6 - 1.21.3 | +| 1.5-SNAPSHOT | 1.20.6 - 1.21.4 | | 1.4 | 1.20.4 | | 1.3 | 1.19.4 - 1.20.4 | | 1.2 | 1.18.2 - 1.19.2 | diff --git a/docusaurus.config.ts b/docusaurus.config.ts index 650a2ed..37c72b8 100644 --- a/docusaurus.config.ts +++ b/docusaurus.config.ts @@ -133,6 +133,7 @@ const config: Config = { prism: { theme: prismThemes.github, darkTheme: prismThemes.dracula, + additionalLanguages: ['java', 'bash', 'kotlin'], }, } satisfies Preset.ThemeConfig, }; diff --git a/package.json b/package.json index 22d5d0f..c87ec0d 100644 --- a/package.json +++ b/package.json @@ -17,17 +17,20 @@ "dependencies": { "@docusaurus/core": "3.6.3", "@docusaurus/preset-classic": "3.6.3", - "@mdx-js/react": "^3.0.0", - "clsx": "^2.0.0", - "prism-react-renderer": "^2.3.0", - "react": "^18.0.0", - "react-dom": "^18.0.0" + "@mdx-js/react": "^3.1.0", + "clsx": "^2.1.1", + "prism-react-renderer": "^2.4.1", + "prismjs": "^1.29.0", + "react": "^19.0.0", + "react-dom": "^19.0.0", + "utility-types": "^3.11.0" }, "devDependencies": { "@docusaurus/module-type-aliases": "3.6.3", "@docusaurus/tsconfig": "3.6.3", "@docusaurus/types": "3.6.3", - "typescript": "~5.6.2" + "@types/prismjs": "^1.26.5", + "typescript": "~5.7.2" }, "browserslist": { "production": [ diff --git a/src/theme/prism-include-languages.ts b/src/theme/prism-include-languages.ts new file mode 100644 index 0000000..fa45903 --- /dev/null +++ b/src/theme/prism-include-languages.ts @@ -0,0 +1,33 @@ +import siteConfig from '@generated/docusaurus.config'; +import type * as PrismNamespace from 'prismjs'; +import type {Optional} from 'utility-types'; + +export default function prismIncludeLanguages( + PrismObject: typeof PrismNamespace, +): void { + const { + themeConfig: {prism}, + } = siteConfig; + const {additionalLanguages} = prism as {additionalLanguages: string[]}; + + // Prism components work on the Prism instance on the window, while prism- + // react-renderer uses its own Prism instance. We temporarily mount the + // instance onto window, import components to enhance it, then remove it to + // avoid polluting global namespace. + // You can mutate PrismObject: registering plugins, deleting languages... As + // long as you don't re-assign it + + const PrismBefore = globalThis.Prism; + globalThis.Prism = PrismObject; + + additionalLanguages.forEach((lang) => { + // eslint-disable-next-line global-require, import/no-dynamic-require + require(`prismjs/components/prism-${lang}`); + }); + + // Clean up and eventually restore former globalThis.Prism object (if any) + delete (globalThis as Optional).Prism; + if (typeof PrismBefore !== 'undefined') { + globalThis.Prism = PrismObject; + } +} diff --git a/src/theme/prismjs/components/prism-bash.js b/src/theme/prismjs/components/prism-bash.js new file mode 100644 index 0000000..a453775 --- /dev/null +++ b/src/theme/prismjs/components/prism-bash.js @@ -0,0 +1,235 @@ +(function (Prism) { + // $ set | grep '^[A-Z][^[:space:]]*=' | cut -d= -f1 | tr '\n' '|' + // + LC_ALL, RANDOM, REPLY, SECONDS. + // + make sure PS1..4 are here as they are not always set, + // - some useless things. + var envVars = '\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b'; + + var commandAfterHeredoc = { + pattern: /(^(["']?)\w+\2)[ \t]+\S.*/, + lookbehind: true, + alias: 'punctuation', // this looks reasonably well in all themes + inside: null // see below + }; + + var insideString = { + 'bash': commandAfterHeredoc, + 'environment': { + pattern: RegExp('\\$' + envVars), + alias: 'constant' + }, + 'variable': [ + // [0]: Arithmetic Environment + { + pattern: /\$?\(\([\s\S]+?\)\)/, + greedy: true, + inside: { + // If there is a $ sign at the beginning highlight $(( and )) as variable + 'variable': [ + { + pattern: /(^\$\(\([\s\S]+)\)\)/, + lookbehind: true + }, + /^\$\(\(/ + ], + 'number': /\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/, + // Operators according to https://www.gnu.org/software/bash/manual/bashref.html#Shell-Arithmetic + 'operator': /--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/, + // If there is no $ sign at the beginning highlight (( and )) as punctuation + 'punctuation': /\(\(?|\)\)?|,|;/ + } + }, + // [1]: Command Substitution + { + pattern: /\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/, + greedy: true, + inside: { + 'variable': /^\$\(|^`|\)$|`$/ + } + }, + // [2]: Brace expansion + { + pattern: /\$\{[^}]+\}/, + greedy: true, + inside: { + 'operator': /:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/, + 'punctuation': /[\[\]]/, + 'environment': { + pattern: RegExp('(\\{)' + envVars), + lookbehind: true, + alias: 'constant' + } + } + }, + /\$(?:\w+|[#?*!@$])/ + ], + // Escape sequences from echo and printf's manuals, and escaped quotes. + 'entity': /\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/ + }; + + Prism.languages.bash = { + 'shebang': { + pattern: /^#!\s*\/.*/, + alias: 'important' + }, + 'comment': { + pattern: /(^|[^"{\\$])#.*/, + lookbehind: true + }, + 'function-name': [ + // a) function foo { + // b) foo() { + // c) function foo() { + // but not “foo {” + { + // a) and c) + pattern: /(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/, + lookbehind: true, + alias: 'function' + }, + { + // b) + pattern: /\b[\w-]+(?=\s*\(\s*\)\s*\{)/, + alias: 'function' + } + ], + // Highlight variable names as variables in for and select beginnings. + 'for-or-select': { + pattern: /(\b(?:for|select)\s+)\w+(?=\s+in\s)/, + alias: 'variable', + lookbehind: true + }, + // Highlight variable names as variables in the left-hand part + // of assignments (“=” and “+=”). + 'assign-left': { + pattern: /(^|[\s;|&]|[<>]\()\w+(?:\.\w+)*(?=\+?=)/, + inside: { + 'environment': { + pattern: RegExp('(^|[\\s;|&]|[<>]\\()' + envVars), + lookbehind: true, + alias: 'constant' + } + }, + alias: 'variable', + lookbehind: true + }, + // Highlight parameter names as variables + 'parameter': { + pattern: /(^|\s)-{1,2}(?:\w+:[+-]?)?\w+(?:\.\w+)*(?=[=\s]|$)/, + alias: 'variable', + lookbehind: true + }, + 'string': [ + // Support for Here-documents https://en.wikipedia.org/wiki/Here_document + { + pattern: /((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/, + lookbehind: true, + greedy: true, + inside: insideString + }, + // Here-document with quotes around the tag + // → No expansion (so no “inside”). + { + pattern: /((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/, + lookbehind: true, + greedy: true, + inside: { + 'bash': commandAfterHeredoc + } + }, + // “Normal” string + { + // https://www.gnu.org/software/bash/manual/html_node/Double-Quotes.html + pattern: /(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/, + lookbehind: true, + greedy: true, + inside: insideString + }, + { + // https://www.gnu.org/software/bash/manual/html_node/Single-Quotes.html + pattern: /(^|[^$\\])'[^']*'/, + lookbehind: true, + greedy: true + }, + { + // https://www.gnu.org/software/bash/manual/html_node/ANSI_002dC-Quoting.html + pattern: /\$'(?:[^'\\]|\\[\s\S])*'/, + greedy: true, + inside: { + 'entity': insideString.entity + } + } + ], + 'environment': { + pattern: RegExp('\\$?' + envVars), + alias: 'constant' + }, + 'variable': insideString.variable, + 'function': { + pattern: /(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cargo|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|docker|docker-compose|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|java|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|node|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|podman|podman-compose|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|sysctl|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/, + lookbehind: true + }, + 'keyword': { + pattern: /(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/, + lookbehind: true + }, + // https://www.gnu.org/software/bash/manual/html_node/Shell-Builtin-Commands.html + 'builtin': { + pattern: /(^|[\s;|&]|[<>]\()(?:\.|:|alias|bind|break|builtin|caller|cd|command|continue|declare|echo|enable|eval|exec|exit|export|getopts|hash|help|let|local|logout|mapfile|printf|pwd|read|readarray|readonly|return|set|shift|shopt|source|test|times|trap|type|typeset|ulimit|umask|unalias|unset)(?=$|[)\s;|&])/, + lookbehind: true, + // Alias added to make those easier to distinguish from strings. + alias: 'class-name' + }, + 'boolean': { + pattern: /(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/, + lookbehind: true + }, + 'file-descriptor': { + pattern: /\B&\d\b/, + alias: 'important' + }, + 'operator': { + // Lots of redirections here, but not just that. + pattern: /\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/, + inside: { + 'file-descriptor': { + pattern: /^\d/, + alias: 'important' + } + } + }, + 'punctuation': /\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/, + 'number': { + pattern: /(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/, + lookbehind: true + } + }; + + commandAfterHeredoc.inside = Prism.languages.bash; + + /* Patterns in command substitution. */ + var toBeCopied = [ + 'comment', + 'function-name', + 'for-or-select', + 'assign-left', + 'parameter', + 'string', + 'environment', + 'function', + 'keyword', + 'builtin', + 'boolean', + 'file-descriptor', + 'operator', + 'punctuation', + 'number' + ]; + var inside = insideString.variable[1].inside; + for (var i = 0; i < toBeCopied.length; i++) { + inside[toBeCopied[i]] = Prism.languages.bash[toBeCopied[i]]; + } + + Prism.languages.sh = Prism.languages.bash; + Prism.languages.shell = Prism.languages.bash; +}(Prism)); \ No newline at end of file diff --git a/src/theme/prismjs/components/prism-java.js b/src/theme/prismjs/components/prism-java.js new file mode 100644 index 0000000..77d96ed --- /dev/null +++ b/src/theme/prismjs/components/prism-java.js @@ -0,0 +1,124 @@ +(function (Prism) { + + var keywords = /\b(?:abstract|assert|boolean|break|byte|case|catch|char|class|const|continue|default|do|double|else|enum|exports|extends|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|module|native|new|non-sealed|null|open|opens|package|permits|private|protected|provides|public|record(?!\s*[(){}[\]<>=%~.:,;?+\-*/&|^])|requires|return|sealed|short|static|strictfp|super|switch|synchronized|this|throw|throws|to|transient|transitive|try|uses|var|void|volatile|while|with|yield)\b/; + + // full package (optional) + parent classes (optional) + var classNamePrefix = /(?:[a-z]\w*\s*\.\s*)*(?:[A-Z]\w*\s*\.\s*)*/.source; + + // based on the java naming conventions + var className = { + pattern: RegExp(/(^|[^\w.])/.source + classNamePrefix + /[A-Z](?:[\d_A-Z]*[a-z]\w*)?\b/.source), + lookbehind: true, + inside: { + 'namespace': { + pattern: /^[a-z]\w*(?:\s*\.\s*[a-z]\w*)*(?:\s*\.)?/, + inside: { + 'punctuation': /\./ + } + }, + 'punctuation': /\./ + } + }; + + Prism.languages.java = Prism.languages.extend('clike', { + 'string': { + pattern: /(^|[^\\])"(?:\\.|[^"\\\r\n])*"/, + lookbehind: true, + greedy: true + }, + 'class-name': [ + className, + { + // variables, parameters, and constructor references + // this to support class names (or generic parameters) which do not contain a lower case letter (also works for methods) + pattern: RegExp(/(^|[^\w.])/.source + classNamePrefix + /[A-Z]\w*(?=\s+\w+\s*[;,=()]|\s*(?:\[[\s,]*\]\s*)?::\s*new\b)/.source), + lookbehind: true, + inside: className.inside + }, + { + // class names based on keyword + // this to support class names (or generic parameters) which do not contain a lower case letter (also works for methods) + pattern: RegExp(/(\b(?:class|enum|extends|implements|instanceof|interface|new|record|throws)\s+)/.source + classNamePrefix + /[A-Z]\w*\b/.source), + lookbehind: true, + inside: className.inside + } + ], + 'keyword': keywords, + 'function': [ + Prism.languages.clike.function, + { + pattern: /(::\s*)[a-z_]\w*/, + lookbehind: true + } + ], + 'number': /\b0b[01][01_]*L?\b|\b0x(?:\.[\da-f_p+-]+|[\da-f_]+(?:\.[\da-f_p+-]+)?)\b|(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?\d[\d_]*)?[dfl]?/i, + 'operator': { + pattern: /(^|[^.])(?:<<=?|>>>?=?|->|--|\+\+|&&|\|\||::|[?:~]|[-+*/%&|^!=<>]=?)/m, + lookbehind: true + }, + 'constant': /\b[A-Z][A-Z_\d]+\b/ + }); + + Prism.languages.insertBefore('java', 'string', { + 'triple-quoted-string': { + // http://openjdk.java.net/jeps/355#Description + pattern: /"""[ \t]*[\r\n](?:(?:"|"")?(?:\\.|[^"\\]))*"""/, + greedy: true, + alias: 'string' + }, + 'char': { + pattern: /'(?:\\.|[^'\\\r\n]){1,6}'/, + greedy: true + } + }); + + Prism.languages.insertBefore('java', 'class-name', { + 'annotation': { + pattern: /(^|[^.])@\w+(?:\s*\.\s*\w+)*/, + lookbehind: true, + alias: 'punctuation' + }, + 'generics': { + pattern: /<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&))*>)*>)*>)*>/, + inside: { + 'class-name': className, + 'keyword': keywords, + 'punctuation': /[<>(),.:]/, + 'operator': /[?&|]/ + } + }, + 'import': [ + { + pattern: RegExp(/(\bimport\s+)/.source + classNamePrefix + /(?:[A-Z]\w*|\*)(?=\s*;)/.source), + lookbehind: true, + inside: { + 'namespace': className.inside.namespace, + 'punctuation': /\./, + 'operator': /\*/, + 'class-name': /\w+/ + } + }, + { + pattern: RegExp(/(\bimport\s+static\s+)/.source + classNamePrefix + /(?:\w+|\*)(?=\s*;)/.source), + lookbehind: true, + alias: 'static', + inside: { + 'namespace': className.inside.namespace, + 'static': /\b\w+$/, + 'punctuation': /\./, + 'operator': /\*/, + 'class-name': /\w+/ + } + } + ], + 'namespace': { + pattern: RegExp( + /(\b(?:exports|import(?:\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\s+)(?!)[a-z]\w*(?:\.[a-z]\w*)*\.?/ + .source.replace(//g, function () { return keywords.source; })), + lookbehind: true, + inside: { + 'punctuation': /\./, + } + } + }); +}(Prism)); \ No newline at end of file diff --git a/src/theme/prismjs/components/prism-kotlin.js b/src/theme/prismjs/components/prism-kotlin.js new file mode 100644 index 0000000..a453775 --- /dev/null +++ b/src/theme/prismjs/components/prism-kotlin.js @@ -0,0 +1,235 @@ +(function (Prism) { + // $ set | grep '^[A-Z][^[:space:]]*=' | cut -d= -f1 | tr '\n' '|' + // + LC_ALL, RANDOM, REPLY, SECONDS. + // + make sure PS1..4 are here as they are not always set, + // - some useless things. + var envVars = '\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b'; + + var commandAfterHeredoc = { + pattern: /(^(["']?)\w+\2)[ \t]+\S.*/, + lookbehind: true, + alias: 'punctuation', // this looks reasonably well in all themes + inside: null // see below + }; + + var insideString = { + 'bash': commandAfterHeredoc, + 'environment': { + pattern: RegExp('\\$' + envVars), + alias: 'constant' + }, + 'variable': [ + // [0]: Arithmetic Environment + { + pattern: /\$?\(\([\s\S]+?\)\)/, + greedy: true, + inside: { + // If there is a $ sign at the beginning highlight $(( and )) as variable + 'variable': [ + { + pattern: /(^\$\(\([\s\S]+)\)\)/, + lookbehind: true + }, + /^\$\(\(/ + ], + 'number': /\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/, + // Operators according to https://www.gnu.org/software/bash/manual/bashref.html#Shell-Arithmetic + 'operator': /--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/, + // If there is no $ sign at the beginning highlight (( and )) as punctuation + 'punctuation': /\(\(?|\)\)?|,|;/ + } + }, + // [1]: Command Substitution + { + pattern: /\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/, + greedy: true, + inside: { + 'variable': /^\$\(|^`|\)$|`$/ + } + }, + // [2]: Brace expansion + { + pattern: /\$\{[^}]+\}/, + greedy: true, + inside: { + 'operator': /:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/, + 'punctuation': /[\[\]]/, + 'environment': { + pattern: RegExp('(\\{)' + envVars), + lookbehind: true, + alias: 'constant' + } + } + }, + /\$(?:\w+|[#?*!@$])/ + ], + // Escape sequences from echo and printf's manuals, and escaped quotes. + 'entity': /\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/ + }; + + Prism.languages.bash = { + 'shebang': { + pattern: /^#!\s*\/.*/, + alias: 'important' + }, + 'comment': { + pattern: /(^|[^"{\\$])#.*/, + lookbehind: true + }, + 'function-name': [ + // a) function foo { + // b) foo() { + // c) function foo() { + // but not “foo {” + { + // a) and c) + pattern: /(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/, + lookbehind: true, + alias: 'function' + }, + { + // b) + pattern: /\b[\w-]+(?=\s*\(\s*\)\s*\{)/, + alias: 'function' + } + ], + // Highlight variable names as variables in for and select beginnings. + 'for-or-select': { + pattern: /(\b(?:for|select)\s+)\w+(?=\s+in\s)/, + alias: 'variable', + lookbehind: true + }, + // Highlight variable names as variables in the left-hand part + // of assignments (“=” and “+=”). + 'assign-left': { + pattern: /(^|[\s;|&]|[<>]\()\w+(?:\.\w+)*(?=\+?=)/, + inside: { + 'environment': { + pattern: RegExp('(^|[\\s;|&]|[<>]\\()' + envVars), + lookbehind: true, + alias: 'constant' + } + }, + alias: 'variable', + lookbehind: true + }, + // Highlight parameter names as variables + 'parameter': { + pattern: /(^|\s)-{1,2}(?:\w+:[+-]?)?\w+(?:\.\w+)*(?=[=\s]|$)/, + alias: 'variable', + lookbehind: true + }, + 'string': [ + // Support for Here-documents https://en.wikipedia.org/wiki/Here_document + { + pattern: /((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/, + lookbehind: true, + greedy: true, + inside: insideString + }, + // Here-document with quotes around the tag + // → No expansion (so no “inside”). + { + pattern: /((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/, + lookbehind: true, + greedy: true, + inside: { + 'bash': commandAfterHeredoc + } + }, + // “Normal” string + { + // https://www.gnu.org/software/bash/manual/html_node/Double-Quotes.html + pattern: /(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/, + lookbehind: true, + greedy: true, + inside: insideString + }, + { + // https://www.gnu.org/software/bash/manual/html_node/Single-Quotes.html + pattern: /(^|[^$\\])'[^']*'/, + lookbehind: true, + greedy: true + }, + { + // https://www.gnu.org/software/bash/manual/html_node/ANSI_002dC-Quoting.html + pattern: /\$'(?:[^'\\]|\\[\s\S])*'/, + greedy: true, + inside: { + 'entity': insideString.entity + } + } + ], + 'environment': { + pattern: RegExp('\\$?' + envVars), + alias: 'constant' + }, + 'variable': insideString.variable, + 'function': { + pattern: /(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cargo|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|docker|docker-compose|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|java|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|node|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|podman|podman-compose|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|sysctl|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/, + lookbehind: true + }, + 'keyword': { + pattern: /(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/, + lookbehind: true + }, + // https://www.gnu.org/software/bash/manual/html_node/Shell-Builtin-Commands.html + 'builtin': { + pattern: /(^|[\s;|&]|[<>]\()(?:\.|:|alias|bind|break|builtin|caller|cd|command|continue|declare|echo|enable|eval|exec|exit|export|getopts|hash|help|let|local|logout|mapfile|printf|pwd|read|readarray|readonly|return|set|shift|shopt|source|test|times|trap|type|typeset|ulimit|umask|unalias|unset)(?=$|[)\s;|&])/, + lookbehind: true, + // Alias added to make those easier to distinguish from strings. + alias: 'class-name' + }, + 'boolean': { + pattern: /(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/, + lookbehind: true + }, + 'file-descriptor': { + pattern: /\B&\d\b/, + alias: 'important' + }, + 'operator': { + // Lots of redirections here, but not just that. + pattern: /\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/, + inside: { + 'file-descriptor': { + pattern: /^\d/, + alias: 'important' + } + } + }, + 'punctuation': /\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/, + 'number': { + pattern: /(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/, + lookbehind: true + } + }; + + commandAfterHeredoc.inside = Prism.languages.bash; + + /* Patterns in command substitution. */ + var toBeCopied = [ + 'comment', + 'function-name', + 'for-or-select', + 'assign-left', + 'parameter', + 'string', + 'environment', + 'function', + 'keyword', + 'builtin', + 'boolean', + 'file-descriptor', + 'operator', + 'punctuation', + 'number' + ]; + var inside = insideString.variable[1].inside; + for (var i = 0; i < toBeCopied.length; i++) { + inside[toBeCopied[i]] = Prism.languages.bash[toBeCopied[i]]; + } + + Prism.languages.sh = Prism.languages.bash; + Prism.languages.shell = Prism.languages.bash; +}(Prism)); \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index e190760..787a62c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2868,7 +2868,7 @@ __metadata: languageName: node linkType: hard -"@mdx-js/react@npm:^3.0.0": +"@mdx-js/react@npm:^3.0.0, @mdx-js/react@npm:^3.1.0": version: 3.1.0 resolution: "@mdx-js/react@npm:3.1.0" dependencies: @@ -3484,7 +3484,7 @@ __metadata: languageName: node linkType: hard -"@types/prismjs@npm:^1.26.0": +"@types/prismjs@npm:^1.26.0, @types/prismjs@npm:^1.26.5": version: 1.26.5 resolution: "@types/prismjs@npm:1.26.5" checksum: 10c0/5619cb449e0d8df098c8759d6f47bf8fdd510abf5dbdfa999e55c6a2545efbd1e209cc85a33d8d9f4ff2898089a1a6d9a70737c9baffaae635c46852c40d384a @@ -4646,7 +4646,7 @@ __metadata: languageName: node linkType: hard -"clsx@npm:^2.0.0": +"clsx@npm:^2.0.0, clsx@npm:^2.1.1": version: 2.1.1 resolution: "clsx@npm:2.1.1" checksum: 10c0/c4c8eb865f8c82baab07e71bfa8897c73454881c4f99d6bc81585aecd7c441746c1399d08363dc096c550cceaf97bd4ce1e8854e1771e9998d9f94c4fe075839 @@ -5437,12 +5437,15 @@ __metadata: "@docusaurus/preset-classic": "npm:3.6.3" "@docusaurus/tsconfig": "npm:3.6.3" "@docusaurus/types": "npm:3.6.3" - "@mdx-js/react": "npm:^3.0.0" - clsx: "npm:^2.0.0" - prism-react-renderer: "npm:^2.3.0" - react: "npm:^18.0.0" - react-dom: "npm:^18.0.0" - typescript: "npm:~5.6.2" + "@mdx-js/react": "npm:^3.1.0" + "@types/prismjs": "npm:^1.26.5" + clsx: "npm:^2.1.1" + prism-react-renderer: "npm:^2.4.1" + prismjs: "npm:^1.29.0" + react: "npm:^19.0.0" + react-dom: "npm:^19.0.0" + typescript: "npm:~5.7.2" + utility-types: "npm:^3.11.0" languageName: unknown linkType: soft @@ -7782,7 +7785,7 @@ __metadata: languageName: node linkType: hard -"loose-envify@npm:^1.0.0, loose-envify@npm:^1.1.0, loose-envify@npm:^1.2.0, loose-envify@npm:^1.3.1, loose-envify@npm:^1.4.0": +"loose-envify@npm:^1.0.0, loose-envify@npm:^1.2.0, loose-envify@npm:^1.3.1, loose-envify@npm:^1.4.0": version: 1.4.0 resolution: "loose-envify@npm:1.4.0" dependencies: @@ -10340,6 +10343,18 @@ __metadata: languageName: node linkType: hard +"prism-react-renderer@npm:^2.4.1": + version: 2.4.1 + resolution: "prism-react-renderer@npm:2.4.1" + dependencies: + "@types/prismjs": "npm:^1.26.0" + clsx: "npm:^2.0.0" + peerDependencies: + react: ">=16.0.0" + checksum: 10c0/ebbe8feb975224344bbdd046b3a937d121592dbe4b8f22ba0be31f5af37b9a8219f441138ef6cab1c5b96f2aa6b529015200959f7e5e85b60ca69c81d35edcd4 + languageName: node + linkType: hard + "prismjs@npm:^1.29.0": version: 1.29.0 resolution: "prismjs@npm:1.29.0" @@ -10545,15 +10560,14 @@ __metadata: languageName: node linkType: hard -"react-dom@npm:^18.0.0": - version: 18.3.1 - resolution: "react-dom@npm:18.3.1" +"react-dom@npm:^19.0.0": + version: 19.0.0 + resolution: "react-dom@npm:19.0.0" dependencies: - loose-envify: "npm:^1.1.0" - scheduler: "npm:^0.23.2" + scheduler: "npm:^0.25.0" peerDependencies: - react: ^18.3.1 - checksum: 10c0/a752496c1941f958f2e8ac56239172296fcddce1365ce45222d04a1947e0cc5547df3e8447f855a81d6d39f008d7c32eab43db3712077f09e3f67c4874973e85 + react: ^19.0.0 + checksum: 10c0/a36ce7ab507b237ae2759c984cdaad4af4096d8199fb65b3815c16825e5cfeb7293da790a3fc2184b52bfba7ba3ff31c058c01947aff6fd1a3701632aabaa6a9 languageName: node linkType: hard @@ -10687,12 +10701,10 @@ __metadata: languageName: node linkType: hard -"react@npm:^18.0.0": - version: 18.3.1 - resolution: "react@npm:18.3.1" - dependencies: - loose-envify: "npm:^1.1.0" - checksum: 10c0/283e8c5efcf37802c9d1ce767f302dd569dd97a70d9bb8c7be79a789b9902451e0d16334b05d73299b20f048cbc3c7d288bbbde10b701fa194e2089c237dbea3 +"react@npm:^19.0.0": + version: 19.0.0 + resolution: "react@npm:19.0.0" + checksum: 10c0/9cad8f103e8e3a16d15cb18a0d8115d8bd9f9e1ce3420310aea381eb42aa0a4f812cf047bb5441349257a05fba8a291515691e3cb51267279b2d2c3253f38471 languageName: node linkType: hard @@ -11199,12 +11211,10 @@ __metadata: languageName: node linkType: hard -"scheduler@npm:^0.23.2": - version: 0.23.2 - resolution: "scheduler@npm:0.23.2" - dependencies: - loose-envify: "npm:^1.1.0" - checksum: 10c0/26383305e249651d4c58e6705d5f8425f153211aef95f15161c151f7b8de885f24751b377e4a0b3dd42cce09aad3f87a61dab7636859c0d89b7daf1a1e2a5c78 +"scheduler@npm:^0.25.0": + version: 0.25.0 + resolution: "scheduler@npm:0.25.0" + checksum: 10c0/a4bb1da406b613ce72c1299db43759526058fdcc413999c3c3e0db8956df7633acf395cb20eb2303b6a65d658d66b6585d344460abaee8080b4aa931f10eaafe languageName: node linkType: hard @@ -12063,23 +12073,23 @@ __metadata: languageName: node linkType: hard -"typescript@npm:~5.6.2": - version: 5.6.3 - resolution: "typescript@npm:5.6.3" +"typescript@npm:~5.7.2": + version: 5.7.2 + resolution: "typescript@npm:5.7.2" bin: tsc: bin/tsc tsserver: bin/tsserver - checksum: 10c0/44f61d3fb15c35359bc60399cb8127c30bae554cd555b8e2b46d68fa79d680354b83320ad419ff1b81a0bdf324197b29affe6cc28988cd6a74d4ac60c94f9799 + checksum: 10c0/a873118b5201b2ef332127ef5c63fb9d9c155e6fdbe211cbd9d8e65877283797cca76546bad742eea36ed7efbe3424a30376818f79c7318512064e8625d61622 languageName: node linkType: hard -"typescript@patch:typescript@npm%3A~5.6.2#optional!builtin": - version: 5.6.3 - resolution: "typescript@patch:typescript@npm%3A5.6.3#optional!builtin::version=5.6.3&hash=8c6c40" +"typescript@patch:typescript@npm%3A~5.7.2#optional!builtin": + version: 5.7.2 + resolution: "typescript@patch:typescript@npm%3A5.7.2#optional!builtin::version=5.7.2&hash=5786d5" bin: tsc: bin/tsc tsserver: bin/tsserver - checksum: 10c0/7c9d2e07c81226d60435939618c91ec2ff0b75fbfa106eec3430f0fcf93a584bc6c73176676f532d78c3594fe28a54b36eb40b3d75593071a7ec91301533ace7 + checksum: 10c0/f3b8082c9d1d1629a215245c9087df56cb784f9fb6f27b5d55577a20e68afe2a889c040aacff6d27e35be165ecf9dca66e694c42eb9a50b3b2c451b36b5675cb languageName: node linkType: hard @@ -12317,7 +12327,7 @@ __metadata: languageName: node linkType: hard -"utility-types@npm:^3.10.0": +"utility-types@npm:^3.10.0, utility-types@npm:^3.11.0": version: 3.11.0 resolution: "utility-types@npm:3.11.0" checksum: 10c0/2f1580137b0c3e6cf5405f37aaa8f5249961a76d26f1ca8efc0ff49a2fc0e0b2db56de8e521a174d075758e0c7eb3e590edec0832eb44478b958f09914920f19