From 31eef054b6d364d61847a7db2b3eaff93222c770 Mon Sep 17 00:00:00 2001 From: Pierre Jacquier Date: Thu, 30 Mar 2023 20:55:38 -0400 Subject: [PATCH] Re-enable STL support (#61) * OBJ as the new default viewer format * Replace deprecated btoa * Clean up * Hide existing STL toggle * No Box if no before/after * Adds error message when no geometry --- .pnp.cjs | 2393 +++++++++++++++++++-------- package.json | 1 + src/chrome/diff.test.ts | 2 +- src/chrome/diff.ts | 32 +- src/components/diff/CadDiff.tsx | 64 +- src/components/diff/CadDiffPage.tsx | 8 + yarn.lock | 35 +- 7 files changed, 1809 insertions(+), 726 deletions(-) diff --git a/.pnp.cjs b/.pnp.cjs index 8a4b7c2..a5226c8 100644 --- a/.pnp.cjs +++ b/.pnp.cjs @@ -1,11 +1,6 @@ #!/usr/bin/env node /* eslint-disable */ - -try { - Object.freeze({}).detectStrictMode = true; -} catch (error) { - throw new Error(`The whole PnP file got strict-mode-ified, which is known to break (Emscripten libraries aren't strict mode). This usually happens when the file goes through Babel.`); -} +"use strict"; function $$SETUP_STATE(hydrateRuntimeState, basePath) { return hydrateRuntimeState(JSON.parse('{\ @@ -53,6 +48,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["@types/react-dom", "npm:18.0.11"],\ ["@types/testing-library__jest-dom", "npm:5.14.5"],\ ["@types/three", "npm:0.149.0"],\ + ["buffer", "npm:6.0.3"],\ ["dotenv", "npm:16.0.3"],\ ["eslint", "npm:8.37.0"],\ ["eslint-config-prettier", "virtual:ff5ad3439f8ec237c0c86796b437c422a681ce7f1211bc52c84c467fd5c19025673469e4b3bd047db74cf4144d670522e4013a081fcd63cc449dbcb3b5b92460#npm:8.7.0"],\ @@ -66,7 +62,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["react-scripts", "virtual:ff5ad3439f8ec237c0c86796b437c422a681ce7f1211bc52c84c467fd5c19025673469e4b3bd047db74cf4144d670522e4013a081fcd63cc449dbcb3b5b92460#npm:5.0.1"],\ ["styled-components", "virtual:ff5ad3439f8ec237c0c86796b437c422a681ce7f1211bc52c84c467fd5c19025673469e4b3bd047db74cf4144d670522e4013a081fcd63cc449dbcb3b5b92460#npm:5.3.8"],\ ["three", "npm:0.149.0"],\ - ["typescript", "patch:typescript@npm%3A4.9.5#~builtin::version=4.9.5&hash=a1c5e5"]\ + ["typescript", "patch:typescript@npm%3A4.9.5#~builtin::version=4.9.5&hash=23ec76"]\ ],\ "linkType": "SOFT"\ }]\ @@ -321,7 +317,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["@types/babel__core", null],\ ["debug", "virtual:ac3d8e680759ce54399273724d44e041d6c9b73454d191d411a8c44bb27e22f02aaf6ed9d3ad0ac1c298eac4833cff369c9c7b84c573016112c4f84be2cd8543#npm:4.3.4"],\ ["lodash.debounce", "npm:4.0.8"],\ - ["resolve", "patch:resolve@npm%3A1.22.1#~builtin::version=1.22.1&hash=07638b"],\ + ["resolve", "patch:resolve@npm%3A1.22.1#~builtin::version=1.22.1&hash=c3c19d"],\ ["semver", "npm:6.3.0"]\ ],\ "packagePeers": [\ @@ -4173,7 +4169,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { "packageDependencies": [\ ["@playwright/test", "npm:1.32.1"],\ ["@types/node", "npm:18.14.6"],\ - ["fsevents", "patch:fsevents@npm%3A2.3.2#~builtin::version=2.3.2&hash=18f3a7"],\ + ["fsevents", "patch:fsevents@npm%3A2.3.2#~builtin::version=2.3.2&hash=df0bf1"],\ ["playwright-core", "npm:1.32.1"]\ ],\ "linkType": "HARD"\ @@ -4649,7 +4645,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["builtin-modules", "npm:3.3.0"],\ ["deepmerge", "npm:4.3.0"],\ ["is-module", "npm:1.0.0"],\ - ["resolve", "patch:resolve@npm%3A1.22.1#~builtin::version=1.22.1&hash=07638b"],\ + ["resolve", "patch:resolve@npm%3A1.22.1#~builtin::version=1.22.1&hash=c3c19d"],\ ["rollup", "npm:2.79.1"]\ ],\ "packagePeers": [\ @@ -5878,7 +5874,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["regexpp", "npm:3.2.0"],\ ["semver", "npm:7.3.8"],\ ["tsutils", "virtual:9698d22773cab376c7f8ae25f4e88560fd2f806c59021b1894ba59e3165fb61902e4429f862b965d57c4d54ffb7b8c48510de79474c51edb6ba70c6b41633d9b#npm:3.21.0"],\ - ["typescript", "patch:typescript@npm%3A4.9.5#~builtin::version=4.9.5&hash=a1c5e5"]\ + ["typescript", "patch:typescript@npm%3A4.9.5#~builtin::version=4.9.5&hash=23ec76"]\ ],\ "packagePeers": [\ "@types/eslint",\ @@ -5933,7 +5929,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["@typescript-eslint/typescript-estree", "virtual:74bdcd90bb2a85faabd3486ebdc3b59af455da792937582d4df44f05efb03878b45723b9eb3f29f6c05588558dd0a21dc205fd9320daed174f57074b47ef41a1#npm:5.54.1"],\ ["debug", "virtual:ac3d8e680759ce54399273724d44e041d6c9b73454d191d411a8c44bb27e22f02aaf6ed9d3ad0ac1c298eac4833cff369c9c7b84c573016112c4f84be2cd8543#npm:4.3.4"],\ ["eslint", "npm:8.37.0"],\ - ["typescript", "patch:typescript@npm%3A4.9.5#~builtin::version=4.9.5&hash=a1c5e5"]\ + ["typescript", "patch:typescript@npm%3A4.9.5#~builtin::version=4.9.5&hash=23ec76"]\ ],\ "packagePeers": [\ "@types/eslint",\ @@ -5974,7 +5970,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["debug", "virtual:ac3d8e680759ce54399273724d44e041d6c9b73454d191d411a8c44bb27e22f02aaf6ed9d3ad0ac1c298eac4833cff369c9c7b84c573016112c4f84be2cd8543#npm:4.3.4"],\ ["eslint", "npm:8.37.0"],\ ["tsutils", "virtual:9698d22773cab376c7f8ae25f4e88560fd2f806c59021b1894ba59e3165fb61902e4429f862b965d57c4d54ffb7b8c48510de79474c51edb6ba70c6b41633d9b#npm:3.21.0"],\ - ["typescript", "patch:typescript@npm%3A4.9.5#~builtin::version=4.9.5&hash=a1c5e5"]\ + ["typescript", "patch:typescript@npm%3A4.9.5#~builtin::version=4.9.5&hash=23ec76"]\ ],\ "packagePeers": [\ "@types/eslint",\ @@ -6014,7 +6010,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["is-glob", "npm:4.0.3"],\ ["semver", "npm:7.3.8"],\ ["tsutils", "virtual:9698d22773cab376c7f8ae25f4e88560fd2f806c59021b1894ba59e3165fb61902e4429f862b965d57c4d54ffb7b8c48510de79474c51edb6ba70c6b41633d9b#npm:3.21.0"],\ - ["typescript", "patch:typescript@npm%3A4.9.5#~builtin::version=4.9.5&hash=a1c5e5"]\ + ["typescript", "patch:typescript@npm%3A4.9.5#~builtin::version=4.9.5&hash=23ec76"]\ ],\ "packagePeers": [\ "@types/typescript",\ @@ -7023,7 +7019,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["babel-plugin-macros", "npm:3.1.0"],\ ["@babel/runtime", "npm:7.21.0"],\ ["cosmiconfig", "npm:7.1.0"],\ - ["resolve", "patch:resolve@npm%3A1.22.1#~builtin::version=1.22.1&hash=07638b"]\ + ["resolve", "patch:resolve@npm%3A1.22.1#~builtin::version=1.22.1&hash=c3c19d"]\ ],\ "linkType": "HARD"\ }]\ @@ -7285,6 +7281,15 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { "linkType": "HARD"\ }]\ ]],\ + ["base64-js", [\ + ["npm:1.5.1", {\ + "packageLocation": "./.yarn/cache/base64-js-npm-1.5.1-b2f7275641-669632eb37.zip/node_modules/base64-js/",\ + "packageDependencies": [\ + ["base64-js", "npm:1.5.1"]\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ ["batch", [\ ["npm:0.6.1", {\ "packageLocation": "./.yarn/cache/batch-npm-0.6.1-70e2e81169-61f9934c73.zip/node_modules/batch/",\ @@ -7457,6 +7462,17 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { "linkType": "HARD"\ }]\ ]],\ + ["buffer", [\ + ["npm:6.0.3", {\ + "packageLocation": "./.yarn/cache/buffer-npm-6.0.3-cd90dfedfe-5ad23293d9.zip/node_modules/buffer/",\ + "packageDependencies": [\ + ["buffer", "npm:6.0.3"],\ + ["base64-js", "npm:1.5.1"],\ + ["ieee754", "npm:1.2.1"]\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ ["buffer-from", [\ ["npm:1.1.2", {\ "packageLocation": "./.yarn/cache/buffer-from-npm-1.1.2-03d2f20d7e-0448524a56.zip/node_modules/buffer-from/",\ @@ -7713,7 +7729,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["chokidar", "npm:3.5.3"],\ ["anymatch", "npm:3.1.3"],\ ["braces", "npm:3.0.2"],\ - ["fsevents", "patch:fsevents@npm%3A2.3.2#~builtin::version=2.3.2&hash=18f3a7"],\ + ["fsevents", "patch:fsevents@npm%3A2.3.2#~builtin::version=2.3.2&hash=df0bf1"],\ ["glob-parent", "npm:5.1.2"],\ ["is-binary-path", "npm:2.1.0"],\ ["is-glob", "npm:4.0.3"],\ @@ -8984,6 +9000,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["@types/react-dom", "npm:18.0.11"],\ ["@types/testing-library__jest-dom", "npm:5.14.5"],\ ["@types/three", "npm:0.149.0"],\ + ["buffer", "npm:6.0.3"],\ ["dotenv", "npm:16.0.3"],\ ["eslint", "npm:8.37.0"],\ ["eslint-config-prettier", "virtual:ff5ad3439f8ec237c0c86796b437c422a681ce7f1211bc52c84c467fd5c19025673469e4b3bd047db74cf4144d670522e4013a081fcd63cc449dbcb3b5b92460#npm:8.7.0"],\ @@ -8997,7 +9014,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["react-scripts", "virtual:ff5ad3439f8ec237c0c86796b437c422a681ce7f1211bc52c84c467fd5c19025673469e4b3bd047db74cf4144d670522e4013a081fcd63cc449dbcb3b5b92460#npm:5.0.1"],\ ["styled-components", "virtual:ff5ad3439f8ec237c0c86796b437c422a681ce7f1211bc52c84c467fd5c19025673469e4b3bd047db74cf4144d670522e4013a081fcd63cc449dbcb3b5b92460#npm:5.3.8"],\ ["three", "npm:0.149.0"],\ - ["typescript", "patch:typescript@npm%3A4.9.5#~builtin::version=4.9.5&hash=a1c5e5"]\ + ["typescript", "patch:typescript@npm%3A4.9.5#~builtin::version=4.9.5&hash=23ec76"]\ ],\ "linkType": "SOFT"\ }]\ @@ -9622,7 +9639,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["eslint-plugin-react", "virtual:ff5ad3439f8ec237c0c86796b437c422a681ce7f1211bc52c84c467fd5c19025673469e4b3bd047db74cf4144d670522e4013a081fcd63cc449dbcb3b5b92460#npm:7.32.2"],\ ["eslint-plugin-react-hooks", "virtual:36c3befe1d472956b514499ce1e4a73095ed0f246cfe87692d25c86c8df5acd8b2aa4e89e7fd95a9fa38d2001eae09b4865f122f1e3cd7ed381406217d407428#npm:4.6.0"],\ ["eslint-plugin-testing-library", "virtual:36c3befe1d472956b514499ce1e4a73095ed0f246cfe87692d25c86c8df5acd8b2aa4e89e7fd95a9fa38d2001eae09b4865f122f1e3cd7ed381406217d407428#npm:5.10.2"],\ - ["typescript", "patch:typescript@npm%3A4.9.5#~builtin::version=4.9.5&hash=a1c5e5"]\ + ["typescript", "patch:typescript@npm%3A4.9.5#~builtin::version=4.9.5&hash=23ec76"]\ ],\ "packagePeers": [\ "@types/eslint",\ @@ -9640,7 +9657,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["eslint-import-resolver-node", "npm:0.3.7"],\ ["debug", "virtual:65bed195431eadffc59e2238eb20cc12d9a1665bc7458ce780a9320ff795091b03cb5c4c2094938315ddd967b5b02c0f1df67b3ed435c69b7457092b7cc06ed8#npm:3.2.7"],\ ["is-core-module", "npm:2.11.0"],\ - ["resolve", "patch:resolve@npm%3A1.22.1#~builtin::version=1.22.1&hash=07638b"]\ + ["resolve", "patch:resolve@npm%3A1.22.1#~builtin::version=1.22.1&hash=c3c19d"]\ ],\ "linkType": "HARD"\ }]\ @@ -9744,7 +9761,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["is-glob", "npm:4.0.3"],\ ["minimatch", "npm:3.1.2"],\ ["object.values", "npm:1.1.6"],\ - ["resolve", "patch:resolve@npm%3A1.22.1#~builtin::version=1.22.1&hash=07638b"],\ + ["resolve", "patch:resolve@npm%3A1.22.1#~builtin::version=1.22.1&hash=c3c19d"],\ ["semver", "npm:6.3.0"],\ ["tsconfig-paths", "npm:3.14.2"]\ ],\ @@ -9852,7 +9869,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["object.hasown", "npm:1.1.2"],\ ["object.values", "npm:1.1.6"],\ ["prop-types", "npm:15.8.1"],\ - ["resolve", "patch:resolve@npm%3A2.0.0-next.4#~builtin::version=2.0.0-next.4&hash=07638b"],\ + ["resolve", "patch:resolve@npm%3A2.0.0-next.4#~builtin::version=2.0.0-next.4&hash=c3c19d"],\ ["semver", "npm:6.3.0"],\ ["string.prototype.matchall", "npm:4.0.8"]\ ],\ @@ -10487,7 +10504,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["schema-utils", "npm:2.7.0"],\ ["semver", "npm:7.3.8"],\ ["tapable", "npm:1.1.3"],\ - ["typescript", "patch:typescript@npm%3A4.9.5#~builtin::version=4.9.5&hash=a1c5e5"],\ + ["typescript", "patch:typescript@npm%3A4.9.5#~builtin::version=4.9.5&hash=23ec76"],\ ["vue-template-compiler", null],\ ["webpack", "virtual:b887c16a9b3e080455598836bd004e969a104720b605f110640fc7a73cf5e804e79e0505c6ba9dbd22582f5c638669cfa8efa4ba5504af62e17acc45c6742ba4#npm:5.76.0"]\ ],\ @@ -10595,10 +10612,10 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { }]\ ]],\ ["fsevents", [\ - ["patch:fsevents@npm%3A2.3.2#~builtin::version=2.3.2&hash=18f3a7", {\ - "packageLocation": "./.yarn/unplugged/fsevents-patch-3340e2eb10/node_modules/fsevents/",\ + ["patch:fsevents@npm%3A2.3.2#~builtin::version=2.3.2&hash=df0bf1", {\ + "packageLocation": "./.yarn/unplugged/fsevents-patch-2882183fbf/node_modules/fsevents/",\ "packageDependencies": [\ - ["fsevents", "patch:fsevents@npm%3A2.3.2#~builtin::version=2.3.2&hash=18f3a7"],\ + ["fsevents", "patch:fsevents@npm%3A2.3.2#~builtin::version=2.3.2&hash=df0bf1"],\ ["node-gyp", "npm:9.3.1"]\ ],\ "linkType": "HARD"\ @@ -11338,6 +11355,15 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { "linkType": "HARD"\ }]\ ]],\ + ["ieee754", [\ + ["npm:1.2.1", {\ + "packageLocation": "./.yarn/cache/ieee754-npm-1.2.1-fb63b3caeb-5144c0c981.zip/node_modules/ieee754/",\ + "packageDependencies": [\ + ["ieee754", "npm:1.2.1"]\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ ["ignore", [\ ["npm:5.2.4", {\ "packageLocation": "./.yarn/cache/ignore-npm-5.2.4-fbe6e989e5-3d4c309c60.zip/node_modules/ignore/",\ @@ -12242,7 +12268,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["@types/node", "npm:18.14.6"],\ ["anymatch", "npm:3.1.3"],\ ["fb-watchman", "npm:2.0.2"],\ - ["fsevents", "patch:fsevents@npm%3A2.3.2#~builtin::version=2.3.2&hash=18f3a7"],\ + ["fsevents", "patch:fsevents@npm%3A2.3.2#~builtin::version=2.3.2&hash=df0bf1"],\ ["graceful-fs", "npm:4.2.10"],\ ["jest-regex-util", "npm:27.5.1"],\ ["jest-serializer", "npm:27.5.1"],\ @@ -12426,7 +12452,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["jest-pnp-resolver", "virtual:a0a4a415f59ab1a920949fe4f9ac7174aa7df535addf97fcdc124f36cb0389a80c8f31f99ad52fa0c7aaa53f66726b763a7b2a27b93255cb52f9164322c0788e#npm:1.2.3"],\ ["jest-util", "npm:27.5.1"],\ ["jest-validate", "npm:27.5.1"],\ - ["resolve", "patch:resolve@npm%3A1.22.1#~builtin::version=1.22.1&hash=07638b"],\ + ["resolve", "patch:resolve@npm%3A1.22.1#~builtin::version=1.22.1&hash=c3c19d"],\ ["resolve.exports", "npm:1.1.1"],\ ["slash", "npm:3.0.0"]\ ],\ @@ -14971,7 +14997,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["postcss", "npm:8.4.21"],\ ["postcss-value-parser", "npm:4.2.0"],\ ["read-cache", "npm:1.0.0"],\ - ["resolve", "patch:resolve@npm%3A1.22.1#~builtin::version=1.22.1&hash=07638b"]\ + ["resolve", "patch:resolve@npm%3A1.22.1#~builtin::version=1.22.1&hash=c3c19d"]\ ],\ "packagePeers": [\ "@types/postcss",\ @@ -16405,7 +16431,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["shell-quote", "npm:1.8.0"],\ ["strip-ansi", "npm:6.0.1"],\ ["text-table", "npm:0.2.0"],\ - ["typescript", "patch:typescript@npm%3A4.9.5#~builtin::version=4.9.5&hash=a1c5e5"],\ + ["typescript", "patch:typescript@npm%3A4.9.5#~builtin::version=4.9.5&hash=23ec76"],\ ["webpack", "virtual:b887c16a9b3e080455598836bd004e969a104720b605f110640fc7a73cf5e804e79e0505c6ba9dbd22582f5c638669cfa8efa4ba5504af62e17acc45c6742ba4#npm:5.76.0"]\ ],\ "packagePeers": [\ @@ -16572,7 +16598,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["eslint-webpack-plugin", "virtual:b887c16a9b3e080455598836bd004e969a104720b605f110640fc7a73cf5e804e79e0505c6ba9dbd22582f5c638669cfa8efa4ba5504af62e17acc45c6742ba4#npm:3.2.0"],\ ["file-loader", "virtual:b887c16a9b3e080455598836bd004e969a104720b605f110640fc7a73cf5e804e79e0505c6ba9dbd22582f5c638669cfa8efa4ba5504af62e17acc45c6742ba4#npm:6.2.0"],\ ["fs-extra", "npm:10.1.0"],\ - ["fsevents", "patch:fsevents@npm%3A2.3.2#~builtin::version=2.3.2&hash=18f3a7"],\ + ["fsevents", "patch:fsevents@npm%3A2.3.2#~builtin::version=2.3.2&hash=df0bf1"],\ ["html-webpack-plugin", "virtual:b887c16a9b3e080455598836bd004e969a104720b605f110640fc7a73cf5e804e79e0505c6ba9dbd22582f5c638669cfa8efa4ba5504af62e17acc45c6742ba4#npm:5.5.0"],\ ["identity-obj-proxy", "npm:3.0.0"],\ ["jest", "virtual:b887c16a9b3e080455598836bd004e969a104720b605f110640fc7a73cf5e804e79e0505c6ba9dbd22582f5c638669cfa8efa4ba5504af62e17acc45c6742ba4#npm:27.5.1"],\ @@ -16589,7 +16615,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["react-app-polyfill", "npm:3.0.0"],\ ["react-dev-utils", "virtual:b887c16a9b3e080455598836bd004e969a104720b605f110640fc7a73cf5e804e79e0505c6ba9dbd22582f5c638669cfa8efa4ba5504af62e17acc45c6742ba4#npm:12.0.1"],\ ["react-refresh", "npm:0.11.0"],\ - ["resolve", "patch:resolve@npm%3A1.22.1#~builtin::version=1.22.1&hash=07638b"],\ + ["resolve", "patch:resolve@npm%3A1.22.1#~builtin::version=1.22.1&hash=c3c19d"],\ ["resolve-url-loader", "virtual:b887c16a9b3e080455598836bd004e969a104720b605f110640fc7a73cf5e804e79e0505c6ba9dbd22582f5c638669cfa8efa4ba5504af62e17acc45c6742ba4#npm:4.0.0"],\ ["sass-loader", "virtual:b887c16a9b3e080455598836bd004e969a104720b605f110640fc7a73cf5e804e79e0505c6ba9dbd22582f5c638669cfa8efa4ba5504af62e17acc45c6742ba4#npm:12.6.0"],\ ["semver", "npm:7.3.8"],\ @@ -16597,7 +16623,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["style-loader", "virtual:b887c16a9b3e080455598836bd004e969a104720b605f110640fc7a73cf5e804e79e0505c6ba9dbd22582f5c638669cfa8efa4ba5504af62e17acc45c6742ba4#npm:3.3.1"],\ ["tailwindcss", "virtual:b887c16a9b3e080455598836bd004e969a104720b605f110640fc7a73cf5e804e79e0505c6ba9dbd22582f5c638669cfa8efa4ba5504af62e17acc45c6742ba4#npm:3.2.7"],\ ["terser-webpack-plugin", "virtual:b887c16a9b3e080455598836bd004e969a104720b605f110640fc7a73cf5e804e79e0505c6ba9dbd22582f5c638669cfa8efa4ba5504af62e17acc45c6742ba4#npm:5.3.7"],\ - ["typescript", "patch:typescript@npm%3A4.9.5#~builtin::version=4.9.5&hash=a1c5e5"],\ + ["typescript", "patch:typescript@npm%3A4.9.5#~builtin::version=4.9.5&hash=23ec76"],\ ["webpack", "virtual:b887c16a9b3e080455598836bd004e969a104720b605f110640fc7a73cf5e804e79e0505c6ba9dbd22582f5c638669cfa8efa4ba5504af62e17acc45c6742ba4#npm:5.76.0"],\ ["webpack-dev-server", "virtual:b887c16a9b3e080455598836bd004e969a104720b605f110640fc7a73cf5e804e79e0505c6ba9dbd22582f5c638669cfa8efa4ba5504af62e17acc45c6742ba4#npm:4.11.1"],\ ["webpack-manifest-plugin", "virtual:b887c16a9b3e080455598836bd004e969a104720b605f110640fc7a73cf5e804e79e0505c6ba9dbd22582f5c638669cfa8efa4ba5504af62e17acc45c6742ba4#npm:4.1.1"],\ @@ -16861,20 +16887,20 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { }]\ ]],\ ["resolve", [\ - ["patch:resolve@npm%3A1.22.1#~builtin::version=1.22.1&hash=07638b", {\ - "packageLocation": "./.yarn/cache/resolve-patch-46f9469d0d-5656f4d0be.zip/node_modules/resolve/",\ + ["patch:resolve@npm%3A1.22.1#~builtin::version=1.22.1&hash=c3c19d", {\ + "packageLocation": "./.yarn/cache/resolve-patch-0c52e0e4f7-5656f4d0be.zip/node_modules/resolve/",\ "packageDependencies": [\ - ["resolve", "patch:resolve@npm%3A1.22.1#~builtin::version=1.22.1&hash=07638b"],\ + ["resolve", "patch:resolve@npm%3A1.22.1#~builtin::version=1.22.1&hash=c3c19d"],\ ["is-core-module", "npm:2.11.0"],\ ["path-parse", "npm:1.0.7"],\ ["supports-preserve-symlinks-flag", "npm:1.0.0"]\ ],\ "linkType": "HARD"\ }],\ - ["patch:resolve@npm%3A2.0.0-next.4#~builtin::version=2.0.0-next.4&hash=07638b", {\ - "packageLocation": "./.yarn/cache/resolve-patch-bdbf6a2444-4bf9f4f8a4.zip/node_modules/resolve/",\ + ["patch:resolve@npm%3A2.0.0-next.4#~builtin::version=2.0.0-next.4&hash=c3c19d", {\ + "packageLocation": "./.yarn/cache/resolve-patch-34cda421ec-4bf9f4f8a4.zip/node_modules/resolve/",\ "packageDependencies": [\ - ["resolve", "patch:resolve@npm%3A2.0.0-next.4#~builtin::version=2.0.0-next.4&hash=07638b"],\ + ["resolve", "patch:resolve@npm%3A2.0.0-next.4#~builtin::version=2.0.0-next.4&hash=c3c19d"],\ ["is-core-module", "npm:2.11.0"],\ ["path-parse", "npm:1.0.7"],\ ["supports-preserve-symlinks-flag", "npm:1.0.0"]\ @@ -16988,7 +17014,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { "packageLocation": "./.yarn/cache/rollup-npm-2.79.1-94e707a9a3-6a2bf167b3.zip/node_modules/rollup/",\ "packageDependencies": [\ ["rollup", "npm:2.79.1"],\ - ["fsevents", "patch:fsevents@npm%3A2.3.2#~builtin::version=2.3.2&hash=18f3a7"]\ + ["fsevents", "patch:fsevents@npm%3A2.3.2#~builtin::version=2.3.2&hash=df0bf1"]\ ],\ "linkType": "HARD"\ }]\ @@ -18117,7 +18143,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["postcss-selector-parser", "npm:6.0.11"],\ ["postcss-value-parser", "npm:4.2.0"],\ ["quick-lru", "npm:5.1.1"],\ - ["resolve", "patch:resolve@npm%3A1.22.1#~builtin::version=1.22.1&hash=07638b"]\ + ["resolve", "patch:resolve@npm%3A1.22.1#~builtin::version=1.22.1&hash=c3c19d"]\ ],\ "packagePeers": [\ "@types/postcss",\ @@ -18590,7 +18616,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["tsutils", "virtual:9698d22773cab376c7f8ae25f4e88560fd2f806c59021b1894ba59e3165fb61902e4429f862b965d57c4d54ffb7b8c48510de79474c51edb6ba70c6b41633d9b#npm:3.21.0"],\ ["@types/typescript", null],\ ["tslib", "npm:1.14.1"],\ - ["typescript", "patch:typescript@npm%3A4.9.5#~builtin::version=4.9.5&hash=a1c5e5"]\ + ["typescript", "patch:typescript@npm%3A4.9.5#~builtin::version=4.9.5&hash=23ec76"]\ ],\ "packagePeers": [\ "@types/typescript",\ @@ -18697,10 +18723,10 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { }]\ ]],\ ["typescript", [\ - ["patch:typescript@npm%3A4.9.5#~builtin::version=4.9.5&hash=a1c5e5", {\ - "packageLocation": "./.yarn/cache/typescript-patch-b5c51365ca-2eee5c37ca.zip/node_modules/typescript/",\ + ["patch:typescript@npm%3A4.9.5#~builtin::version=4.9.5&hash=23ec76", {\ + "packageLocation": "./.yarn/cache/typescript-patch-72dc6f164f-ab417a2f39.zip/node_modules/typescript/",\ "packageDependencies": [\ - ["typescript", "patch:typescript@npm%3A4.9.5#~builtin::version=4.9.5&hash=a1c5e5"]\ + ["typescript", "patch:typescript@npm%3A4.9.5#~builtin::version=4.9.5&hash=23ec76"]\ ],\ "linkType": "HARD"\ }]\ @@ -19893,6 +19919,8 @@ const StringDecoder = require('string_decoder'); const url = require('url'); const os = require('os'); const nodeUtils = require('util'); +const readline = require('readline'); +const assert = require('assert'); const stream = require('stream'); const zlib = require('zlib'); const events = require('events'); @@ -19922,6 +19950,7 @@ const path__default = /*#__PURE__*/_interopDefaultLegacy(path); const require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0); const StringDecoder__default = /*#__PURE__*/_interopDefaultLegacy(StringDecoder); const nodeUtils__namespace = /*#__PURE__*/_interopNamespace(nodeUtils); +const assert__default = /*#__PURE__*/_interopDefaultLegacy(assert); const zlib__default = /*#__PURE__*/_interopDefaultLegacy(zlib); const S_IFMT = 61440; @@ -20113,15 +20142,10 @@ function areStatsEqual(a, b) { return true; } -var PathType; -(function(PathType2) { - PathType2[PathType2["File"] = 0] = "File"; - PathType2[PathType2["Portable"] = 1] = "Portable"; - PathType2[PathType2["Native"] = 2] = "Native"; -})(PathType || (PathType = {})); const PortablePath = { root: `/`, - dot: `.` + dot: `.`, + parent: `..` }; const Filename = { nodeModules: `node_modules`, @@ -20191,40 +20215,16 @@ function convertPath(targetPathUtils, sourcePath) { return targetPathUtils === npath ? fromPortablePath(sourcePath) : toPortablePath(sourcePath); } -var __defProp$5 = Object.defineProperty; -var __defProps$3 = Object.defineProperties; -var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors; -var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols; -var __hasOwnProp$6 = Object.prototype.hasOwnProperty; -var __propIsEnum$6 = Object.prototype.propertyIsEnumerable; -var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, {enumerable: true, configurable: true, writable: true, value}) : obj[key] = value; -var __spreadValues$5 = (a, b) => { - for (var prop in b || (b = {})) - if (__hasOwnProp$6.call(b, prop)) - __defNormalProp$5(a, prop, b[prop]); - if (__getOwnPropSymbols$6) - for (var prop of __getOwnPropSymbols$6(b)) { - if (__propIsEnum$6.call(b, prop)) - __defNormalProp$5(a, prop, b[prop]); - } - return a; -}; -var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b)); const defaultTime = new Date(SAFE_TIME * 1e3); -var LinkStrategy; -(function(LinkStrategy2) { - LinkStrategy2["Allow"] = `allow`; - LinkStrategy2["ReadOnly"] = `readOnly`; -})(LinkStrategy || (LinkStrategy = {})); 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]}); + const { atime, mtime } = opts.stableTime ? { atime: defaultTime, mtime: defaultTime } : await sourceFs.lstatPromise(normalizedSource); + await destinationFs.mkdirpPromise(destinationFs.pathUtils.dirname(destination), { utimes: [atime, mtime] }); const updateTime = typeof destinationFs.lutimesPromise === `function` ? destinationFs.lutimesPromise.bind(destinationFs) : destinationFs.utimesPromise.bind(destinationFs); - await copyImpl(prelayout, postlayout, updateTime, destinationFs, normalizedDestination, sourceFs, normalizedSource, __spreadProps$3(__spreadValues$5({}, opts), {didParentExist: true})); + await copyImpl(prelayout, postlayout, updateTime, destinationFs, normalizedDestination, sourceFs, normalizedSource, { ...opts, didParentExist: true }); for (const operation of prelayout) await operation(); await Promise.all(postlayout.map((operation) => { @@ -20235,7 +20235,7 @@ async function copyImpl(prelayout, postlayout, updateTime, destinationFs, destin var _a, _b; 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; + const { atime, mtime } = opts.stableTime ? { atime: defaultTime, mtime: defaultTime } : sourceStat; let updated; switch (true) { case sourceStat.isDirectory(): @@ -20288,7 +20288,7 @@ async function copyFolder(prelayout, postlayout, updateTime, destinationFs, dest if (destinationStat === null) { prelayout.push(async () => { try { - await destinationFs.mkdirPromise(destination, {mode: sourceStat.mode}); + await destinationFs.mkdirPromise(destination, { mode: sourceStat.mode }); } catch (err) { if (err.code !== `EEXIST`) { throw err; @@ -20298,7 +20298,7 @@ async function copyFolder(prelayout, postlayout, updateTime, destinationFs, dest updated = true; } const entries = await sourceFs.readdirPromise(source); - const nextOpts = opts.didParentExist && !destinationStat ? __spreadProps$3(__spreadValues$5({}, opts), {didParentExist: false}) : opts; + const nextOpts = opts.didParentExist && !destinationStat ? { ...opts, didParentExist: false } : opts; if (opts.stableSort) { for (const entry of entries.sort()) { if (await copyImpl(prelayout, postlayout, updateTime, destinationFs, destinationFs.pathUtils.join(destination, entry), sourceFs, sourceFs.pathUtils.join(source, entry), nextOpts)) { @@ -20315,11 +20315,11 @@ async function copyFolder(prelayout, postlayout, updateTime, destinationFs, dest } return updated; } -const isCloneSupportedCache = new WeakMap(); +const isCloneSupportedCache = /* @__PURE__ */ new WeakMap(); function makeLinkOperation(opFs, destination, source, sourceStat, linkStrategy) { return async () => { await opFs.linkPromise(source, destination); - if (linkStrategy === LinkStrategy.ReadOnly) { + if (linkStrategy === "readOnly" /* ReadOnly */) { sourceStat.mode &= ~146; await opFs.chmodPromise(destination, sourceStat.mode); } @@ -20380,7 +20380,7 @@ async function copySymlink(prelayout, postlayout, updateTime, destinationFs, des } function makeError$1(code, message) { - return Object.assign(new Error(`${code}: ${message}`), {code}); + return Object.assign(new Error(`${code}: ${message}`), { code }); } function EBUSY(message) { return makeError$1(`EBUSY`, message); @@ -20487,7 +20487,7 @@ class FakeFS { constructor(pathUtils) { this.pathUtils = pathUtils; } - async *genTraversePromise(init, {stableSort = false} = {}) { + async *genTraversePromise(init, { stableSort = false } = {}) { const stack = [init]; while (stack.length > 0) { const p = stack.shift(); @@ -20506,7 +20506,7 @@ class FakeFS { } } } - async removePromise(p, {recursive = true, maxRetries = 5} = {}) { + async removePromise(p, { recursive = true, maxRetries = 5 } = {}) { let stat; try { stat = await this.lstatPromise(p); @@ -20540,7 +20540,7 @@ class FakeFS { await this.unlinkPromise(p); } } - removeSync(p, {recursive = true} = {}) { + removeSync(p, { recursive = true } = {}) { let stat; try { stat = this.lstatSync(p); @@ -20560,7 +20560,7 @@ class FakeFS { this.unlinkSync(p); } } - async mkdirpPromise(p, {chmod, utimes} = {}) { + async mkdirpPromise(p, { chmod, utimes } = {}) { p = this.resolve(p); if (p === this.pathUtils.dirname(p)) return void 0; @@ -20591,7 +20591,7 @@ class FakeFS { } return createdDirectory; } - mkdirpSync(p, {chmod, utimes} = {}) { + mkdirpSync(p, { chmod, utimes } = {}) { p = this.resolve(p); if (p === this.pathUtils.dirname(p)) return void 0; @@ -20622,17 +20622,17 @@ class FakeFS { } 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}); + 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} = {}) { + 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}); + this.copySync(this.pathUtils.join(destination, entry), baseFs.pathUtils.join(source, entry), { baseFs, overwrite }); } } else if (stat.isFile()) { if (!exists || overwrite) { @@ -20661,7 +20661,7 @@ class FakeFS { return this.changeFileTextPromise(p, content, opts); } } - async changeFileBufferPromise(p, content, {mode} = {}) { + async changeFileBufferPromise(p, content, { mode } = {}) { let current = Buffer.alloc(0); try { current = await this.readFilePromise(p); @@ -20669,9 +20669,9 @@ class FakeFS { } if (Buffer.compare(current, content) === 0) return; - await this.writeFilePromise(p, content, {mode}); + await this.writeFilePromise(p, content, { mode }); } - async changeFileTextPromise(p, content, {automaticNewlines, mode} = {}) { + async changeFileTextPromise(p, content, { automaticNewlines, mode } = {}) { let current = ``; try { current = await this.readFilePromise(p, `utf8`); @@ -20680,7 +20680,7 @@ class FakeFS { const normalizedContent = automaticNewlines ? normalizeLineEndings(current, content) : content; if (current === normalizedContent) return; - await this.writeFilePromise(p, normalizedContent, {mode}); + await this.writeFilePromise(p, normalizedContent, { mode }); } changeFileSync(p, content, opts = {}) { if (Buffer.isBuffer(content)) { @@ -20689,7 +20689,7 @@ class FakeFS { return this.changeFileTextSync(p, content, opts); } } - changeFileBufferSync(p, content, {mode} = {}) { + changeFileBufferSync(p, content, { mode } = {}) { let current = Buffer.alloc(0); try { current = this.readFileSync(p); @@ -20697,9 +20697,9 @@ class FakeFS { } if (Buffer.compare(current, content) === 0) return; - this.writeFileSync(p, content, {mode}); + this.writeFileSync(p, content, { mode }); } - changeFileTextSync(p, content, {automaticNewlines = false, mode} = {}) { + changeFileTextSync(p, content, { automaticNewlines = false, mode } = {}) { let current = ``; try { current = this.readFileSync(p, `utf8`); @@ -20708,7 +20708,7 @@ class FakeFS { const normalizedContent = automaticNewlines ? normalizeLineEndings(current, content) : content; if (current === normalizedContent) return; - this.writeFileSync(p, normalizedContent, {mode}); + this.writeFileSync(p, normalizedContent, { mode }); } async movePromise(fromP, toP) { try { @@ -20889,12 +20889,12 @@ class NodeFS extends BasePortableFakeFS { this.realFs.opendir(npath.fromPortablePath(p), this.makeCallback(resolve, reject)); } }).then((dir) => { - return Object.defineProperty(dir, `path`, {value: p, configurable: true, writable: true}); + return Object.defineProperty(dir, `path`, { value: p, configurable: true, writable: true }); }); } opendirSync(p, opts) { const dir = typeof opts !== `undefined` ? this.realFs.opendirSync(npath.fromPortablePath(p), opts) : this.realFs.opendirSync(npath.fromPortablePath(p)); - return Object.defineProperty(dir, `path`, {value: p, configurable: true, writable: true}); + return Object.defineProperty(dir, `path`, { value: p, configurable: true, writable: true }); } async readPromise(fd, buffer, offset = 0, length = 0, position = -1) { return await new Promise((resolve, reject) => { @@ -21032,6 +21032,14 @@ class NodeFS extends BasePortableFakeFS { 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)); @@ -21171,7 +21179,7 @@ class NodeFS extends BasePortableFakeFS { async readdirPromise(p, opts) { return await new Promise((resolve, reject) => { if (opts == null ? void 0 : opts.withFileTypes) { - this.realFs.readdir(npath.fromPortablePath(p), {withFileTypes: true}, this.makeCallback(resolve, reject)); + this.realFs.readdir(npath.fromPortablePath(p), { withFileTypes: true }, this.makeCallback(resolve, reject)); } else { this.realFs.readdir(npath.fromPortablePath(p), this.makeCallback((value) => resolve(value), reject)); } @@ -21179,7 +21187,7 @@ class NodeFS extends BasePortableFakeFS { } readdirSync(p, opts) { if (opts == null ? void 0 : opts.withFileTypes) { - return this.realFs.readdirSync(npath.fromPortablePath(p), {withFileTypes: true}); + return this.realFs.readdirSync(npath.fromPortablePath(p), { withFileTypes: true }); } else { return this.realFs.readdirSync(npath.fromPortablePath(p)); } @@ -21211,10 +21219,18 @@ class NodeFS extends BasePortableFakeFS { return this.realFs.ftruncateSync(fd, len); } watch(p, a, b) { - return this.realFs.watch(npath.fromPortablePath(p), a, b); + return this.realFs.watch( + npath.fromPortablePath(p), + a, + b + ); } watchFile(p, a, b) { - return this.realFs.watchFile(npath.fromPortablePath(p), a, b); + return this.realFs.watchFile( + npath.fromPortablePath(p), + a, + b + ); } unwatchFile(p, cb) { return this.realFs.unwatchFile(npath.fromPortablePath(p), cb); @@ -21230,27 +21246,16 @@ class NodeFS extends BasePortableFakeFS { } } -var Event; -(function(Event2) { - Event2["Change"] = `change`; - Event2["Stop"] = `stop`; -})(Event || (Event = {})); -var Status; -(function(Status2) { - Status2["Ready"] = `ready`; - Status2["Running"] = `running`; - Status2["Stopped"] = `stopped`; -})(Status || (Status = {})); function assertStatus(current, expected) { if (current !== expected) { throw new Error(`Invalid StatWatcher status: expected '${expected}', got '${current}'`); } } class CustomStatWatcher extends events.EventEmitter { - constructor(fakeFs, path, {bigint = false} = {}) { + constructor(fakeFs, path, { bigint = false } = {}) { super(); - this.status = Status.Ready; - this.changeListeners = new Map(); + this.status = "ready" /* Ready */; + this.changeListeners = /* @__PURE__ */ new Map(); this.startTimeout = null; this.fakeFs = fakeFs; this.path = path; @@ -21263,27 +21268,27 @@ class CustomStatWatcher extends events.EventEmitter { return statWatcher; } start() { - assertStatus(this.status, Status.Ready); - this.status = Status.Running; + assertStatus(this.status, "ready" /* Ready */); + this.status = "running" /* Running */; this.startTimeout = setTimeout(() => { this.startTimeout = null; if (!this.fakeFs.existsSync(this.path)) { - this.emit(Event.Change, this.lastStats, this.lastStats); + this.emit("change" /* Change */, this.lastStats, this.lastStats); } }, 3); } stop() { - assertStatus(this.status, Status.Running); - this.status = Status.Stopped; + assertStatus(this.status, "running" /* Running */); + this.status = "stopped" /* Stopped */; if (this.startTimeout !== null) { clearTimeout(this.startTimeout); this.startTimeout = null; } - this.emit(Event.Stop); + this.emit("stop" /* Stop */); } stat() { try { - return this.fakeFs.statSync(this.path, {bigint: this.bigint}); + return this.fakeFs.statSync(this.path, { bigint: this.bigint }); } catch (error) { const statInstance = this.bigint ? new BigIntStatsEntry() : new StatEntry(); return clearStats(statInstance); @@ -21296,16 +21301,16 @@ class CustomStatWatcher extends events.EventEmitter { if (areStatsEqual(currentStats, previousStats)) return; this.lastStats = currentStats; - this.emit(Event.Change, currentStats, previousStats); + this.emit("change" /* Change */, currentStats, previousStats); }, opts.interval); return opts.persistent ? interval : interval.unref(); } registerChangeListener(listener, opts) { - this.addListener(Event.Change, listener); + this.addListener("change" /* Change */, listener); this.changeListeners.set(listener, this.makeInterval(opts)); } unregisterChangeListener(listener) { - this.removeListener(Event.Change, listener); + this.removeListener("change" /* Change */, listener); const interval = this.changeListeners.get(listener); if (typeof interval !== `undefined`) clearInterval(interval); @@ -21331,7 +21336,7 @@ class CustomStatWatcher extends events.EventEmitter { } } -const statWatchersByFakeFS = new WeakMap(); +const statWatchersByFakeFS = /* @__PURE__ */ new WeakMap(); function watchFile(fakeFs, path, a, b) { let bigint; let persistent; @@ -21359,13 +21364,13 @@ function watchFile(fakeFs, path, a, b) { } let statWatchers = statWatchersByFakeFS.get(fakeFs); if (typeof statWatchers === `undefined`) - statWatchersByFakeFS.set(fakeFs, statWatchers = new Map()); + statWatchersByFakeFS.set(fakeFs, statWatchers = /* @__PURE__ */ new Map()); let statWatcher = statWatchers.get(path); if (typeof statWatcher === `undefined`) { - statWatcher = CustomStatWatcher.create(fakeFs, path, {bigint}); + statWatcher = CustomStatWatcher.create(fakeFs, path, { bigint }); statWatchers.set(path, statWatcher); } - statWatcher.registerChangeListener(listener, {persistent, interval}); + statWatcher.registerChangeListener(listener, { persistent, interval }); return statWatcher; } function unwatchFile(fakeFs, path, cb) { @@ -21393,22 +21398,6 @@ function unwatchAllFiles(fakeFs) { } } -var __defProp$4 = Object.defineProperty; -var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols; -var __hasOwnProp$5 = Object.prototype.hasOwnProperty; -var __propIsEnum$5 = Object.prototype.propertyIsEnumerable; -var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, {enumerable: true, configurable: true, writable: true, value}) : obj[key] = value; -var __spreadValues$4 = (a, b) => { - for (var prop in b || (b = {})) - if (__hasOwnProp$5.call(b, prop)) - __defNormalProp$4(a, prop, b[prop]); - if (__getOwnPropSymbols$5) - for (var prop of __getOwnPropSymbols$5(b)) { - if (__propIsEnum$5.call(b, prop)) - __defNormalProp$4(a, prop, b[prop]); - } - return a; -}; const DEFAULT_COMPRESSION_LEVEL = `mixed`; function toUnixTimestamp(time) { if (typeof time === `string` && String(+time) === time) @@ -21454,10 +21443,10 @@ class ZipFS extends BasePortableFakeFS { constructor(source, opts) { super(); this.lzSource = null; - this.listings = new Map(); - this.entries = new Map(); - this.fileSources = new Map(); - this.fds = new Map(); + this.listings = /* @__PURE__ */ new Map(); + this.entries = /* @__PURE__ */ new Map(); + this.fileSources = /* @__PURE__ */ new Map(); + this.fds = /* @__PURE__ */ new Map(); this.nextFd = 0; this.ready = false; this.readOnly = false; @@ -21466,7 +21455,7 @@ class ZipFS extends BasePortableFakeFS { this.level = typeof pathOptions.level !== `undefined` ? pathOptions.level : DEFAULT_COMPRESSION_LEVEL; source != null ? source : source = makeEmptyArchive(); if (typeof source === `string`) { - const {baseFs = new NodeFS()} = pathOptions; + const { baseFs = new NodeFS() } = pathOptions; this.baseFs = baseFs; this.path = source; } else { @@ -21519,7 +21508,7 @@ class ZipFS extends BasePortableFakeFS { } finally { this.libzip.free(errPtr); } - this.listings.set(PortablePath.root, new Set()); + this.listings.set(PortablePath.root, /* @__PURE__ */ new Set()); const entryCount = this.libzip.getNumEntries(this.zip, 0); for (let t = 0; t < entryCount; ++t) { const raw = this.libzip.getName(this.zip, t, 0); @@ -21565,6 +21554,10 @@ class ZipFS extends BasePortableFakeFS { this.prepareClose(); if (!this.lzSource) throw new Error(`ZipFS was not created from a Buffer`); + if (this.entries.size === 0) { + this.discardAndClose(); + return makeEmptyArchive(); + } try { this.libzip.source.keep(this.lzSource); if (this.libzip.close(this.zip) === -1) @@ -21616,7 +21609,7 @@ class ZipFS extends BasePortableFakeFS { const newMode = this.baseFs.existsSync(this.path) || this.stats.mode === DEFAULT_MODE ? void 0 : this.stats.mode; if (this.entries.size === 0) { this.discardAndClose(); - this.baseFs.writeFileSync(this.path, makeEmptyArchive(), {mode: newMode}); + this.baseFs.writeFileSync(this.path, makeEmptyArchive(), { mode: newMode }); } else { const rc = this.libzip.close(this.zip); if (rc === -1) @@ -21640,7 +21633,7 @@ class ZipFS extends BasePortableFakeFS { } openSync(p, flags, mode) { const fd = this.nextFd++; - this.fds.set(fd, {cursor: 0, p}); + this.fds.set(fd, { cursor: 0, p }); return fd; } hasOpenFileHandles() { @@ -21661,7 +21654,7 @@ class ZipFS extends BasePortableFakeFS { const onClose = () => { this.closeSync(fd); }; - return opendir(this, resolvedP, entries, {onClose}); + return opendir(this, resolvedP, entries, { onClose }); } async readPromise(fd, buffer, offset, length, position) { return this.readSync(fd, buffer, offset, length, position); @@ -21700,25 +21693,28 @@ class ZipFS extends BasePortableFakeFS { throw EBADF(`read`); this.fds.delete(fd); } - createReadStream(p, {encoding} = {}) { + createReadStream(p, { encoding } = {}) { if (p === null) throw new Error(`Unimplemented`); const fd = this.openSync(p, `r`); - const stream$1 = Object.assign(new stream.PassThrough({ - emitClose: true, - autoDestroy: true, - destroy: (error, callback) => { - clearImmediate(immediate); - this.closeSync(fd); - callback(error); + const stream$1 = Object.assign( + new stream.PassThrough({ + emitClose: true, + autoDestroy: true, + destroy: (error, callback) => { + clearImmediate(immediate); + this.closeSync(fd); + callback(error); + } + }), + { + close() { + stream$1.destroy(); + }, + bytesRead: 0, + path: p } - }), { - close() { - stream$1.destroy(); - }, - bytesRead: 0, - path: p - }); + ); const immediate = setImmediate(async () => { try { const data = await this.readFilePromise(p, encoding); @@ -21730,37 +21726,40 @@ class ZipFS extends BasePortableFakeFS { }); return stream$1; } - createWriteStream(p, {encoding} = {}) { + createWriteStream(p, { encoding } = {}) { if (this.readOnly) throw EROFS(`open '${p}'`); if (p === null) throw new Error(`Unimplemented`); const chunks = []; const fd = this.openSync(p, `w`); - const stream$1 = Object.assign(new stream.PassThrough({ - autoDestroy: true, - emitClose: true, - destroy: (error, callback) => { - try { - if (error) { - callback(error); - } else { - this.writeFileSync(p, Buffer.concat(chunks), encoding); - callback(null); + const stream$1 = Object.assign( + new stream.PassThrough({ + autoDestroy: true, + emitClose: true, + destroy: (error, callback) => { + try { + if (error) { + callback(error); + } else { + this.writeFileSync(p, Buffer.concat(chunks), encoding); + callback(null); + } + } catch (err) { + callback(err); + } finally { + this.closeSync(fd); } - } catch (err) { - callback(err); - } finally { - this.closeSync(fd); + } + }), + { + bytesWritten: 0, + path: p, + close() { + stream$1.destroy(); } } - }), { - bytesWritten: 0, - path: p, - close() { - stream$1.destroy(); - } - }); + ); stream$1.on(`data`, (chunk) => { const chunkBuffer = Buffer.from(chunk); stream$1.bytesWritten += chunkBuffer.length; @@ -21808,12 +21807,12 @@ class ZipFS extends BasePortableFakeFS { throw EROFS(`access '${p}'`); } } - async statPromise(p, opts = {bigint: false}) { + async statPromise(p, opts = { bigint: false }) { if (opts.bigint) - return this.statSync(p, {bigint: true}); + return this.statSync(p, { bigint: true }); return this.statSync(p); } - statSync(p, opts = {bigint: false, throwIfNoEntry: true}) { + statSync(p, opts = { bigint: false, throwIfNoEntry: true }) { const resolvedP = this.resolveFilename(`stat '${p}'`, p, void 0, opts.throwIfNoEntry); if (resolvedP === void 0) return void 0; @@ -21833,7 +21832,7 @@ class ZipFS extends BasePortableFakeFS { const entry = this.fds.get(fd); if (typeof entry === `undefined`) throw EBADF(`fstatSync`); - const {p} = entry; + const { p } = entry; const resolvedP = this.resolveFilename(`stat '${p}'`, p); if (!this.entries.has(resolvedP) && !this.listings.has(resolvedP)) throw ENOENT(`stat '${p}'`); @@ -21841,12 +21840,12 @@ class ZipFS extends BasePortableFakeFS { throw ENOTDIR(`stat '${p}'`); return this.statImpl(`fstat '${p}'`, resolvedP, opts); } - async lstatPromise(p, opts = {bigint: false}) { + async lstatPromise(p, opts = { bigint: false }) { if (opts.bigint) - return this.lstatSync(p, {bigint: true}); + return this.lstatSync(p, { bigint: true }); return this.lstatSync(p); } - lstatSync(p, opts = {bigint: false, throwIfNoEntry: true}) { + lstatSync(p, opts = { bigint: false, throwIfNoEntry: true }) { const resolvedP = this.resolveFilename(`lstat '${p}'`, p, false, opts.throwIfNoEntry); if (resolvedP === void 0) return void 0; @@ -21883,7 +21882,7 @@ class ZipFS extends BasePortableFakeFS { const defaultMode = type === S_IFDIR ? 493 : 420; const mode = type | this.getUnixMode(entry, defaultMode) & 511; const crc = this.libzip.struct.statCrc(stat); - const statInstance = Object.assign(new StatEntry(), {uid, gid, size, blksize, blocks, atime, birthtime, ctime, mtime, atimeMs, birthtimeMs, ctimeMs, mtimeMs, mode, crc}); + const statInstance = Object.assign(new StatEntry(), { uid, gid, size, blksize, blocks, atime, birthtime, ctime, mtime, atimeMs, birthtimeMs, ctimeMs, mtimeMs, mode, crc }); return opts.bigint === true ? convertToBigIntStats(statInstance) : statInstance; } if (this.listings.has(p)) { @@ -21902,7 +21901,7 @@ class ZipFS extends BasePortableFakeFS { const mtime = new Date(mtimeMs); const mode = S_IFDIR | 493; const crc = 0; - const statInstance = Object.assign(new StatEntry(), {uid, gid, size, blksize, blocks, atime, birthtime, ctime, mtime, atimeMs, birthtimeMs, ctimeMs, mtimeMs, mode, crc}); + const statInstance = Object.assign(new StatEntry(), { uid, gid, size, blksize, blocks, atime, birthtime, ctime, mtime, atimeMs, birthtimeMs, ctimeMs, mtimeMs, mode, crc }); return opts.bigint === true ? convertToBigIntStats(statInstance) : statInstance; } throw new Error(`Unreachable`); @@ -21922,7 +21921,7 @@ class ZipFS extends BasePortableFakeFS { return existingListing; const parentListing = this.registerListing(ppath.dirname(p)); parentListing.add(ppath.basename(p)); - const newListing = new Set(); + const newListing = /* @__PURE__ */ new Set(); this.listings.set(p, newListing); return newListing; } @@ -22005,11 +22004,11 @@ class ZipFS extends BasePortableFakeFS { throw new Error(`Couldn't allocate enough memory`); const heap = new Uint8Array(this.libzip.HEAPU8.buffer, buffer, content.byteLength); heap.set(content); - return {buffer, byteLength: content.byteLength}; + return { buffer, byteLength: content.byteLength }; } allocateUnattachedSource(content) { const error = this.libzip.struct.errorS(); - const {buffer, byteLength} = this.allocateBuffer(content); + const { buffer, byteLength } = this.allocateBuffer(content); const source = this.libzip.source.fromUnattachedBuffer(buffer, byteLength, 0, true, error); if (source === 0) { this.libzip.free(error); @@ -22018,7 +22017,7 @@ class ZipFS extends BasePortableFakeFS { return source; } allocateSource(content) { - const {buffer, byteLength} = this.allocateBuffer(content); + const { buffer, byteLength } = this.allocateBuffer(content); const source = this.libzip.source.fromBuffer(this.zip, buffer, byteLength, 0, true); if (source === 0) { this.libzip.free(buffer); @@ -22060,7 +22059,7 @@ class ZipFS extends BasePortableFakeFS { const attributes = this.libzip.getValue(this.libzip.uint32S, `i32`) >>> 16; return (attributes & S_IFMT) === S_IFLNK; } - getFileSource(index, opts = {asyncDecompress: false}) { + getFileSource(index, opts = { asyncDecompress: false }) { const cachedFileSource = this.fileSources.get(index); if (typeof cachedFileSource !== `undefined`) return cachedFileSource; @@ -22135,6 +22134,12 @@ class ZipFS extends BasePortableFakeFS { throw this.makeLibzipError(this.libzip.getError(this.zip)); } } + async fchownPromise(fd, uid, gid) { + return this.chownPromise(this.fdToPath(fd, `fchown`), uid, gid); + } + fchownSync(fd, uid, gid) { + return this.chownSync(this.fdToPath(fd, `fchownSync`), uid, gid); + } async chownPromise(p, uid, gid) { return this.chownSync(p, uid, gid); } @@ -22148,15 +22153,15 @@ class ZipFS extends BasePortableFakeFS { throw new Error(`Unimplemented`); } async copyFilePromise(sourceP, destP, flags) { - const {indexSource, indexDest, resolvedDestP} = this.prepareCopyFile(sourceP, destP, flags); - const source = await this.getFileSource(indexSource, {asyncDecompress: true}); + const { indexSource, indexDest, resolvedDestP } = this.prepareCopyFile(sourceP, destP, flags); + const source = await this.getFileSource(indexSource, { asyncDecompress: true }); const newIndex = this.setFileSource(resolvedDestP, source); if (newIndex !== indexDest) { this.registerEntry(resolvedDestP, newIndex); } } copyFileSync(sourceP, destP, flags = 0) { - const {indexSource, indexDest, resolvedDestP} = this.prepareCopyFile(sourceP, destP, flags); + const { indexSource, indexDest, resolvedDestP } = this.prepareCopyFile(sourceP, destP, flags); const source = this.getFileSource(indexSource); const newIndex = this.setFileSource(resolvedDestP, source); if (newIndex !== indexDest) { @@ -22186,22 +22191,22 @@ class ZipFS extends BasePortableFakeFS { if (this.readOnly) throw EROFS(`open '${p}'`); if (typeof opts === `undefined`) - opts = {flag: `a`}; + opts = { flag: `a` }; else if (typeof opts === `string`) - opts = {flag: `a`, encoding: opts}; + opts = { flag: `a`, encoding: opts }; else if (typeof opts.flag === `undefined`) - opts = __spreadValues$4({flag: `a`}, opts); + opts = { flag: `a`, ...opts }; return this.writeFilePromise(p, content, opts); } appendFileSync(p, content, opts = {}) { if (this.readOnly) throw EROFS(`open '${p}'`); if (typeof opts === `undefined`) - opts = {flag: `a`}; + opts = { flag: `a` }; else if (typeof opts === `string`) - opts = {flag: `a`, encoding: opts}; + opts = { flag: `a`, encoding: opts }; else if (typeof opts.flag === `undefined`) - opts = __spreadValues$4({flag: `a`}, opts); + opts = { flag: `a`, ...opts }; return this.writeFileSync(p, content, opts); } fdToPath(fd, reason) { @@ -22212,9 +22217,9 @@ class ZipFS extends BasePortableFakeFS { return path; } async writeFilePromise(p, content, opts) { - const {encoding, mode, index, resolvedP} = this.prepareWriteFile(p, opts); + const { encoding, mode, index, resolvedP } = this.prepareWriteFile(p, opts); if (index !== void 0 && typeof opts === `object` && opts.flag && opts.flag.includes(`a`)) - content = Buffer.concat([await this.getFileSource(index, {asyncDecompress: true}), Buffer.from(content)]); + content = Buffer.concat([await this.getFileSource(index, { asyncDecompress: true }), Buffer.from(content)]); if (encoding !== null) content = content.toString(encoding); const newIndex = this.setFileSource(resolvedP, content); @@ -22225,7 +22230,7 @@ class ZipFS extends BasePortableFakeFS { } } writeFileSync(p, content, opts) { - const {encoding, mode, index, resolvedP} = this.prepareWriteFile(p, opts); + const { encoding, mode, index, resolvedP } = this.prepareWriteFile(p, opts); if (index !== void 0 && typeof opts === `object` && opts.flag && opts.flag.includes(`a`)) content = Buffer.concat([this.getFileSource(index), Buffer.from(content)]); if (encoding !== null) @@ -22310,9 +22315,9 @@ class ZipFS extends BasePortableFakeFS { async mkdirPromise(p, opts) { return this.mkdirSync(p, opts); } - mkdirSync(p, {mode = 493, recursive = false} = {}) { + mkdirSync(p, { mode = 493, recursive = false } = {}) { if (recursive) - return this.mkdirpSync(p, {chmod: mode}); + return this.mkdirpSync(p, { chmod: mode }); if (this.readOnly) throw EROFS(`mkdir '${p}'`); const resolvedP = this.resolveFilename(`mkdir '${p}'`, p); @@ -22325,7 +22330,7 @@ class ZipFS extends BasePortableFakeFS { async rmdirPromise(p, opts) { return this.rmdirSync(p, opts); } - rmdirSync(p, {recursive = false} = {}) { + rmdirSync(p, { recursive = false } = {}) { if (this.readOnly) throw EROFS(`rmdir '${p}'`); if (recursive) { @@ -22378,7 +22383,7 @@ class ZipFS extends BasePortableFakeFS { async readFilePromise(p, encoding) { if (typeof encoding === `object`) encoding = encoding ? encoding.encoding : void 0; - const data = await this.readFileBuffer(p, {asyncDecompress: true}); + const data = await this.readFileBuffer(p, { asyncDecompress: true }); return encoding ? data.toString(encoding) : data; } readFileSync(p, encoding) { @@ -22387,7 +22392,7 @@ class ZipFS extends BasePortableFakeFS { const data = this.readFileBuffer(p); return encoding ? data.toString(encoding) : data; } - readFileBuffer(p, opts = {asyncDecompress: false}) { + readFileBuffer(p, opts = { asyncDecompress: false }) { if (typeof p === `number`) p = this.fdToPath(p, `read`); const resolvedP = this.resolveFilename(`open '${p}'`, p); @@ -22423,7 +22428,7 @@ class ZipFS extends BasePortableFakeFS { } async readlinkPromise(p) { const entry = this.prepareReadlink(p); - return (await this.getFileSource(entry, {asyncDecompress: true})).toString(); + return (await this.getFileSource(entry, { asyncDecompress: true })).toString(); } readlinkSync(p) { const entry = this.prepareReadlink(p); @@ -22449,7 +22454,7 @@ class ZipFS extends BasePortableFakeFS { const index = this.entries.get(resolvedP); if (typeof index === `undefined`) throw EINVAL(`open '${p}'`); - const source = await this.getFileSource(index, {asyncDecompress: true}); + const source = await this.getFileSource(index, { asyncDecompress: true }); const truncated = Buffer.alloc(len, 0); source.copy(truncated); return await this.writeFilePromise(p, truncated); @@ -22482,20 +22487,20 @@ class ZipFS extends BasePortableFakeFS { break; default: { - ({persistent = true} = a); + ({ persistent = true } = a); } break; } if (!persistent) - return {on: () => { + return { on: () => { }, close: () => { - }}; + } }; const interval = setInterval(() => { }, 24 * 60 * 60 * 1e3); - return {on: () => { + return { on: () => { }, close: () => { clearInterval(interval); - }}; + } }; } watchFile(p, a, b) { const resolvedP = ppath.resolve(PortablePath.root, p); @@ -22524,10 +22529,10 @@ class ProxiedFS extends FakeFS { 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}); + 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}); + 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); @@ -22609,6 +22614,12 @@ class ProxiedFS extends FakeFS { 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); } @@ -22724,10 +22735,18 @@ class ProxiedFS extends FakeFS { return this.baseFs.ftruncateSync(fd, len); } watch(p, a, b) { - return this.baseFs.watch(this.mapToBase(p), a, b); + return this.baseFs.watch( + this.mapToBase(p), + a, + b + ); } watchFile(p, a, b) { - return this.baseFs.watchFile(this.mapToBase(p), a, b); + return this.baseFs.watchFile( + this.mapToBase(p), + a, + b + ); } unwatchFile(p, cb) { return this.baseFs.unwatchFile(this.mapToBase(p), cb); @@ -22758,6 +22777,10 @@ const NUMBER_REGEXP = /^[0-9]+$/; const VIRTUAL_REGEXP = /^(\/(?:[^/]+\/)*?(?:\$\$virtual|__virtual__))((?:\/((?:[^/]+-)?[a-f0-9]+)(?:\/([^/]+))?)?((?:\/.*)?))$/; const VALID_COMPONENT = /^([^/]+-)?[a-f0-9]+$/; class VirtualFS extends ProxiedFS { + constructor({ baseFs = new NodeFS() } = {}) { + super(ppath); + this.baseFs = baseFs; + } static makeVirtualPath(base, component, to) { if (ppath.basename(base) !== `__virtual__`) throw new Error(`Assertion failed: Virtual folders must be named "__virtual__"`); @@ -22787,10 +22810,6 @@ class VirtualFS extends ProxiedFS { 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); } @@ -22849,17 +22868,17 @@ const getArchivePart = (path, extension) => { return path.slice(0, nextCharIdx); }; class ZipOpenFS extends BasePortableFakeFS { - constructor({libzip, baseFs = new NodeFS(), filter = null, maxOpenFiles = Infinity, readOnlyArchives = false, useCache = true, maxAge = 5e3, fileExtensions = null}) { + constructor({ libzip, baseFs = new NodeFS(), filter = null, maxOpenFiles = Infinity, readOnlyArchives = false, useCache = true, maxAge = 5e3, fileExtensions = null }) { super(); - this.fdMap = new Map(); + this.fdMap = /* @__PURE__ */ new Map(); this.nextFd = 3; - this.isZip = new Set(); - this.notZip = new Set(); - this.realPaths = new Map(); + this.isZip = /* @__PURE__ */ new Set(); + this.notZip = /* @__PURE__ */ new Set(); + this.realPaths = /* @__PURE__ */ new Map(); this.limitOpenFilesTimeout = null; this.libzipFactory = typeof libzip !== `function` ? () => libzip : libzip; this.baseFs = baseFs; - this.zipInstances = useCache ? new Map() : null; + this.zipInstances = useCache ? /* @__PURE__ */ new Map() : null; this.filter = filter; this.maxOpenFiles = maxOpenFiles; this.readOnlyArchives = readOnlyArchives; @@ -22888,7 +22907,7 @@ class ZipOpenFS extends BasePortableFakeFS { saveAndClose() { unwatchAllFiles(this); if (this.zipInstances) { - for (const [path, {zipFs}] of this.zipInstances.entries()) { + for (const [path, { zipFs }] of this.zipInstances.entries()) { zipFs.saveAndClose(); this.zipInstances.delete(path); } @@ -22897,7 +22916,7 @@ class ZipOpenFS extends BasePortableFakeFS { discardAndClose() { unwatchAllFiles(this); if (this.zipInstances) { - for (const [path, {zipFs}] of this.zipInstances.entries()) { + for (const [path, { zipFs }] of this.zipInstances.entries()) { zipFs.discardAndClose(); this.zipInstances.delete(path); } @@ -22914,21 +22933,21 @@ class ZipOpenFS extends BasePortableFakeFS { async openPromise(p, flags, mode) { return await this.makeCallPromise(p, async () => { return await this.baseFs.openPromise(p, flags, mode); - }, async (zipFs, {subPath}) => { + }, async (zipFs, { subPath }) => { return this.remapFd(zipFs, await zipFs.openPromise(subPath, flags, mode)); }); } openSync(p, flags, mode) { return this.makeCallSync(p, () => { return this.baseFs.openSync(p, flags, mode); - }, (zipFs, {subPath}) => { + }, (zipFs, { subPath }) => { return this.remapFd(zipFs, zipFs.openSync(subPath, flags, mode)); }); } async opendirPromise(p, opts) { return await this.makeCallPromise(p, async () => { return await this.baseFs.opendirPromise(p, opts); - }, async (zipFs, {subPath}) => { + }, async (zipFs, { subPath }) => { return await zipFs.opendirPromise(subPath, opts); }, { requireSubpath: false @@ -22937,7 +22956,7 @@ class ZipOpenFS extends BasePortableFakeFS { opendirSync(p, opts) { return this.makeCallSync(p, () => { return this.baseFs.opendirSync(p, opts); - }, (zipFs, {subPath}) => { + }, (zipFs, { subPath }) => { return zipFs.opendirSync(subPath, opts); }, { requireSubpath: false @@ -23022,7 +23041,7 @@ class ZipOpenFS extends BasePortableFakeFS { return this.baseFs.createReadStream(p, opts); return this.makeCallSync(p, () => { return this.baseFs.createReadStream(p, opts); - }, (zipFs, {archivePath, subPath}) => { + }, (zipFs, { archivePath, subPath }) => { const stream = zipFs.createReadStream(subPath, opts); stream.path = npath.fromPortablePath(this.pathUtils.join(archivePath, subPath)); return stream; @@ -23033,14 +23052,14 @@ class ZipOpenFS extends BasePortableFakeFS { return this.baseFs.createWriteStream(p, opts); return this.makeCallSync(p, () => { return this.baseFs.createWriteStream(p, opts); - }, (zipFs, {subPath}) => { + }, (zipFs, { subPath }) => { return zipFs.createWriteStream(subPath, opts); }); } async realpathPromise(p) { return await this.makeCallPromise(p, async () => { return await this.baseFs.realpathPromise(p); - }, async (zipFs, {archivePath, subPath}) => { + }, async (zipFs, { archivePath, subPath }) => { let realArchivePath = this.realPaths.get(archivePath); if (typeof realArchivePath === `undefined`) { realArchivePath = await this.baseFs.realpathPromise(archivePath); @@ -23052,7 +23071,7 @@ class ZipOpenFS extends BasePortableFakeFS { realpathSync(p) { return this.makeCallSync(p, () => { return this.baseFs.realpathSync(p); - }, (zipFs, {archivePath, subPath}) => { + }, (zipFs, { archivePath, subPath }) => { let realArchivePath = this.realPaths.get(archivePath); if (typeof realArchivePath === `undefined`) { realArchivePath = this.baseFs.realpathSync(archivePath); @@ -23064,42 +23083,42 @@ class ZipOpenFS extends BasePortableFakeFS { async existsPromise(p) { return await this.makeCallPromise(p, async () => { return await this.baseFs.existsPromise(p); - }, async (zipFs, {subPath}) => { + }, async (zipFs, { subPath }) => { return await zipFs.existsPromise(subPath); }); } existsSync(p) { return this.makeCallSync(p, () => { return this.baseFs.existsSync(p); - }, (zipFs, {subPath}) => { + }, (zipFs, { subPath }) => { return zipFs.existsSync(subPath); }); } async accessPromise(p, mode) { return await this.makeCallPromise(p, async () => { return await this.baseFs.accessPromise(p, mode); - }, async (zipFs, {subPath}) => { + }, async (zipFs, { subPath }) => { return await zipFs.accessPromise(subPath, mode); }); } accessSync(p, mode) { return this.makeCallSync(p, () => { return this.baseFs.accessSync(p, mode); - }, (zipFs, {subPath}) => { + }, (zipFs, { subPath }) => { return zipFs.accessSync(subPath, mode); }); } async statPromise(p, opts) { return await this.makeCallPromise(p, async () => { return await this.baseFs.statPromise(p, opts); - }, async (zipFs, {subPath}) => { + }, async (zipFs, { subPath }) => { return await zipFs.statPromise(subPath, opts); }); } statSync(p, opts) { return this.makeCallSync(p, () => { return this.baseFs.statSync(p, opts); - }, (zipFs, {subPath}) => { + }, (zipFs, { subPath }) => { return zipFs.statSync(subPath, opts); }); } @@ -23124,14 +23143,14 @@ class ZipOpenFS extends BasePortableFakeFS { async lstatPromise(p, opts) { return await this.makeCallPromise(p, async () => { return await this.baseFs.lstatPromise(p, opts); - }, async (zipFs, {subPath}) => { + }, async (zipFs, { subPath }) => { return await zipFs.lstatPromise(subPath, opts); }); } lstatSync(p, opts) { return this.makeCallSync(p, () => { return this.baseFs.lstatSync(p, opts); - }, (zipFs, {subPath}) => { + }, (zipFs, { subPath }) => { return zipFs.lstatSync(subPath, opts); }); } @@ -23156,28 +23175,46 @@ class ZipOpenFS extends BasePortableFakeFS { async chmodPromise(p, mask) { return await this.makeCallPromise(p, async () => { return await this.baseFs.chmodPromise(p, mask); - }, async (zipFs, {subPath}) => { + }, async (zipFs, { subPath }) => { return await zipFs.chmodPromise(subPath, mask); }); } chmodSync(p, mask) { return this.makeCallSync(p, () => { return this.baseFs.chmodSync(p, mask); - }, (zipFs, {subPath}) => { + }, (zipFs, { subPath }) => { return zipFs.chmodSync(subPath, mask); }); } + async fchownPromise(fd, uid, gid) { + if ((fd & ZIP_MASK) !== ZIP_MAGIC) + return this.baseFs.fchownPromise(fd, uid, gid); + const entry = this.fdMap.get(fd); + if (typeof entry === `undefined`) + throw EBADF(`fchown`); + const [zipFs, realFd] = entry; + return zipFs.fchownPromise(realFd, uid, gid); + } + fchownSync(fd, uid, gid) { + if ((fd & ZIP_MASK) !== ZIP_MAGIC) + return this.baseFs.fchownSync(fd, uid, gid); + const entry = this.fdMap.get(fd); + if (typeof entry === `undefined`) + throw EBADF(`fchownSync`); + const [zipFs, realFd] = entry; + return zipFs.fchownSync(realFd, uid, gid); + } async chownPromise(p, uid, gid) { return await this.makeCallPromise(p, async () => { return await this.baseFs.chownPromise(p, uid, gid); - }, async (zipFs, {subPath}) => { + }, async (zipFs, { subPath }) => { return await zipFs.chownPromise(subPath, uid, gid); }); } chownSync(p, uid, gid) { return this.makeCallSync(p, () => { return this.baseFs.chownSync(p, uid, gid); - }, (zipFs, {subPath}) => { + }, (zipFs, { subPath }) => { return zipFs.chownSync(subPath, uid, gid); }); } @@ -23186,14 +23223,14 @@ class ZipOpenFS extends BasePortableFakeFS { return await this.makeCallPromise(newP, async () => { return await this.baseFs.renamePromise(oldP, newP); }, async () => { - throw Object.assign(new Error(`EEXDEV: cross-device link not permitted`), {code: `EEXDEV`}); + throw Object.assign(new Error(`EEXDEV: cross-device link not permitted`), { code: `EEXDEV` }); }); - }, async (zipFsO, {subPath: subPathO}) => { + }, async (zipFsO, { subPath: subPathO }) => { return await this.makeCallPromise(newP, async () => { - throw Object.assign(new Error(`EEXDEV: cross-device link not permitted`), {code: `EEXDEV`}); - }, async (zipFsN, {subPath: subPathN}) => { + throw Object.assign(new Error(`EEXDEV: cross-device link not permitted`), { code: `EEXDEV` }); + }, async (zipFsN, { subPath: subPathN }) => { if (zipFsO !== zipFsN) { - throw Object.assign(new Error(`EEXDEV: cross-device link not permitted`), {code: `EEXDEV`}); + throw Object.assign(new Error(`EEXDEV: cross-device link not permitted`), { code: `EEXDEV` }); } else { return await zipFsO.renamePromise(subPathO, subPathN); } @@ -23205,14 +23242,14 @@ class ZipOpenFS extends BasePortableFakeFS { return this.makeCallSync(newP, () => { return this.baseFs.renameSync(oldP, newP); }, () => { - throw Object.assign(new Error(`EEXDEV: cross-device link not permitted`), {code: `EEXDEV`}); + throw Object.assign(new Error(`EEXDEV: cross-device link not permitted`), { code: `EEXDEV` }); }); - }, (zipFsO, {subPath: subPathO}) => { + }, (zipFsO, { subPath: subPathO }) => { return this.makeCallSync(newP, () => { - throw Object.assign(new Error(`EEXDEV: cross-device link not permitted`), {code: `EEXDEV`}); - }, (zipFsN, {subPath: subPathN}) => { + throw Object.assign(new Error(`EEXDEV: cross-device link not permitted`), { code: `EEXDEV` }); + }, (zipFsN, { subPath: subPathN }) => { if (zipFsO !== zipFsN) { - throw Object.assign(new Error(`EEXDEV: cross-device link not permitted`), {code: `EEXDEV`}); + throw Object.assign(new Error(`EEXDEV: cross-device link not permitted`), { code: `EEXDEV` }); } else { return zipFsO.renameSync(subPathO, subPathN); } @@ -23222,27 +23259,27 @@ class ZipOpenFS extends BasePortableFakeFS { async copyFilePromise(sourceP, destP, flags = 0) { const fallback = async (sourceFs, sourceP2, destFs, destP2) => { if ((flags & fs.constants.COPYFILE_FICLONE_FORCE) !== 0) - throw Object.assign(new Error(`EXDEV: cross-device clone not permitted, copyfile '${sourceP2}' -> ${destP2}'`), {code: `EXDEV`}); + throw Object.assign(new Error(`EXDEV: cross-device clone not permitted, copyfile '${sourceP2}' -> ${destP2}'`), { code: `EXDEV` }); if (flags & fs.constants.COPYFILE_EXCL && await this.existsPromise(sourceP2)) - throw Object.assign(new Error(`EEXIST: file already exists, copyfile '${sourceP2}' -> '${destP2}'`), {code: `EEXIST`}); + throw Object.assign(new Error(`EEXIST: file already exists, copyfile '${sourceP2}' -> '${destP2}'`), { code: `EEXIST` }); let content; try { content = await sourceFs.readFilePromise(sourceP2); } catch (error) { - throw Object.assign(new Error(`EINVAL: invalid argument, copyfile '${sourceP2}' -> '${destP2}'`), {code: `EINVAL`}); + throw Object.assign(new Error(`EINVAL: invalid argument, copyfile '${sourceP2}' -> '${destP2}'`), { code: `EINVAL` }); } await destFs.writeFilePromise(destP2, content); }; return await this.makeCallPromise(sourceP, async () => { return await this.makeCallPromise(destP, async () => { return await this.baseFs.copyFilePromise(sourceP, destP, flags); - }, async (zipFsD, {subPath: subPathD}) => { + }, async (zipFsD, { subPath: subPathD }) => { return await fallback(this.baseFs, sourceP, zipFsD, subPathD); }); - }, async (zipFsS, {subPath: subPathS}) => { + }, async (zipFsS, { subPath: subPathS }) => { return await this.makeCallPromise(destP, async () => { return await fallback(zipFsS, subPathS, this.baseFs, destP); - }, async (zipFsD, {subPath: subPathD}) => { + }, async (zipFsD, { subPath: subPathD }) => { if (zipFsS !== zipFsD) { return await fallback(zipFsS, subPathS, zipFsD, subPathD); } else { @@ -23254,27 +23291,27 @@ class ZipOpenFS extends BasePortableFakeFS { copyFileSync(sourceP, destP, flags = 0) { const fallback = (sourceFs, sourceP2, destFs, destP2) => { if ((flags & fs.constants.COPYFILE_FICLONE_FORCE) !== 0) - throw Object.assign(new Error(`EXDEV: cross-device clone not permitted, copyfile '${sourceP2}' -> ${destP2}'`), {code: `EXDEV`}); + throw Object.assign(new Error(`EXDEV: cross-device clone not permitted, copyfile '${sourceP2}' -> ${destP2}'`), { code: `EXDEV` }); if (flags & fs.constants.COPYFILE_EXCL && this.existsSync(sourceP2)) - throw Object.assign(new Error(`EEXIST: file already exists, copyfile '${sourceP2}' -> '${destP2}'`), {code: `EEXIST`}); + throw Object.assign(new Error(`EEXIST: file already exists, copyfile '${sourceP2}' -> '${destP2}'`), { code: `EEXIST` }); let content; try { content = sourceFs.readFileSync(sourceP2); } catch (error) { - throw Object.assign(new Error(`EINVAL: invalid argument, copyfile '${sourceP2}' -> '${destP2}'`), {code: `EINVAL`}); + throw Object.assign(new Error(`EINVAL: invalid argument, copyfile '${sourceP2}' -> '${destP2}'`), { code: `EINVAL` }); } destFs.writeFileSync(destP2, content); }; return this.makeCallSync(sourceP, () => { return this.makeCallSync(destP, () => { return this.baseFs.copyFileSync(sourceP, destP, flags); - }, (zipFsD, {subPath: subPathD}) => { + }, (zipFsD, { subPath: subPathD }) => { return fallback(this.baseFs, sourceP, zipFsD, subPathD); }); - }, (zipFsS, {subPath: subPathS}) => { + }, (zipFsS, { subPath: subPathS }) => { return this.makeCallSync(destP, () => { return fallback(zipFsS, subPathS, this.baseFs, destP); - }, (zipFsD, {subPath: subPathD}) => { + }, (zipFsD, { subPath: subPathD }) => { if (zipFsS !== zipFsD) { return fallback(zipFsS, subPathS, zipFsD, subPathD); } else { @@ -23286,112 +23323,112 @@ class ZipOpenFS extends BasePortableFakeFS { async appendFilePromise(p, content, opts) { return await this.makeCallPromise(p, async () => { return await this.baseFs.appendFilePromise(p, content, opts); - }, async (zipFs, {subPath}) => { + }, async (zipFs, { subPath }) => { return await zipFs.appendFilePromise(subPath, content, opts); }); } appendFileSync(p, content, opts) { return this.makeCallSync(p, () => { return this.baseFs.appendFileSync(p, content, opts); - }, (zipFs, {subPath}) => { + }, (zipFs, { subPath }) => { return zipFs.appendFileSync(subPath, content, opts); }); } async writeFilePromise(p, content, opts) { return await this.makeCallPromise(p, async () => { return await this.baseFs.writeFilePromise(p, content, opts); - }, async (zipFs, {subPath}) => { + }, async (zipFs, { subPath }) => { return await zipFs.writeFilePromise(subPath, content, opts); }); } writeFileSync(p, content, opts) { return this.makeCallSync(p, () => { return this.baseFs.writeFileSync(p, content, opts); - }, (zipFs, {subPath}) => { + }, (zipFs, { subPath }) => { return zipFs.writeFileSync(subPath, content, opts); }); } async unlinkPromise(p) { return await this.makeCallPromise(p, async () => { return await this.baseFs.unlinkPromise(p); - }, async (zipFs, {subPath}) => { + }, async (zipFs, { subPath }) => { return await zipFs.unlinkPromise(subPath); }); } unlinkSync(p) { return this.makeCallSync(p, () => { return this.baseFs.unlinkSync(p); - }, (zipFs, {subPath}) => { + }, (zipFs, { subPath }) => { return zipFs.unlinkSync(subPath); }); } async utimesPromise(p, atime, mtime) { return await this.makeCallPromise(p, async () => { return await this.baseFs.utimesPromise(p, atime, mtime); - }, async (zipFs, {subPath}) => { + }, async (zipFs, { subPath }) => { return await zipFs.utimesPromise(subPath, atime, mtime); }); } utimesSync(p, atime, mtime) { return this.makeCallSync(p, () => { return this.baseFs.utimesSync(p, atime, mtime); - }, (zipFs, {subPath}) => { + }, (zipFs, { subPath }) => { return zipFs.utimesSync(subPath, atime, mtime); }); } async mkdirPromise(p, opts) { return await this.makeCallPromise(p, async () => { return await this.baseFs.mkdirPromise(p, opts); - }, async (zipFs, {subPath}) => { + }, async (zipFs, { subPath }) => { return await zipFs.mkdirPromise(subPath, opts); }); } mkdirSync(p, opts) { return this.makeCallSync(p, () => { return this.baseFs.mkdirSync(p, opts); - }, (zipFs, {subPath}) => { + }, (zipFs, { subPath }) => { return zipFs.mkdirSync(subPath, opts); }); } async rmdirPromise(p, opts) { return await this.makeCallPromise(p, async () => { return await this.baseFs.rmdirPromise(p, opts); - }, async (zipFs, {subPath}) => { + }, async (zipFs, { subPath }) => { return await zipFs.rmdirPromise(subPath, opts); }); } rmdirSync(p, opts) { return this.makeCallSync(p, () => { return this.baseFs.rmdirSync(p, opts); - }, (zipFs, {subPath}) => { + }, (zipFs, { subPath }) => { return zipFs.rmdirSync(subPath, opts); }); } async linkPromise(existingP, newP) { return await this.makeCallPromise(newP, async () => { return await this.baseFs.linkPromise(existingP, newP); - }, async (zipFs, {subPath}) => { + }, async (zipFs, { subPath }) => { return await zipFs.linkPromise(existingP, subPath); }); } linkSync(existingP, newP) { return this.makeCallSync(newP, () => { return this.baseFs.linkSync(existingP, newP); - }, (zipFs, {subPath}) => { + }, (zipFs, { subPath }) => { return zipFs.linkSync(existingP, subPath); }); } async symlinkPromise(target, p, type) { return await this.makeCallPromise(p, async () => { return await this.baseFs.symlinkPromise(target, p, type); - }, async (zipFs, {subPath}) => { + }, async (zipFs, { subPath }) => { return await zipFs.symlinkPromise(target, subPath); }); } symlinkSync(target, p, type) { return this.makeCallSync(p, () => { return this.baseFs.symlinkSync(target, p, type); - }, (zipFs, {subPath}) => { + }, (zipFs, { subPath }) => { return zipFs.symlinkSync(target, subPath); }); } @@ -23403,7 +23440,7 @@ class ZipOpenFS extends BasePortableFakeFS { default: return await this.baseFs.readFilePromise(p, encoding); } - }, async (zipFs, {subPath}) => { + }, async (zipFs, { subPath }) => { return await zipFs.readFilePromise(subPath, encoding); }); } @@ -23415,14 +23452,14 @@ class ZipOpenFS extends BasePortableFakeFS { default: return this.baseFs.readFileSync(p, encoding); } - }, (zipFs, {subPath}) => { + }, (zipFs, { subPath }) => { return zipFs.readFileSync(subPath, encoding); }); } async readdirPromise(p, opts) { return await this.makeCallPromise(p, async () => { return await this.baseFs.readdirPromise(p, opts); - }, async (zipFs, {subPath}) => { + }, async (zipFs, { subPath }) => { return await zipFs.readdirPromise(subPath, opts); }, { requireSubpath: false @@ -23431,7 +23468,7 @@ class ZipOpenFS extends BasePortableFakeFS { readdirSync(p, opts) { return this.makeCallSync(p, () => { return this.baseFs.readdirSync(p, opts); - }, (zipFs, {subPath}) => { + }, (zipFs, { subPath }) => { return zipFs.readdirSync(subPath, opts); }, { requireSubpath: false @@ -23440,28 +23477,28 @@ class ZipOpenFS extends BasePortableFakeFS { async readlinkPromise(p) { return await this.makeCallPromise(p, async () => { return await this.baseFs.readlinkPromise(p); - }, async (zipFs, {subPath}) => { + }, async (zipFs, { subPath }) => { return await zipFs.readlinkPromise(subPath); }); } readlinkSync(p) { return this.makeCallSync(p, () => { return this.baseFs.readlinkSync(p); - }, (zipFs, {subPath}) => { + }, (zipFs, { subPath }) => { return zipFs.readlinkSync(subPath); }); } async truncatePromise(p, len) { return await this.makeCallPromise(p, async () => { return await this.baseFs.truncatePromise(p, len); - }, async (zipFs, {subPath}) => { + }, async (zipFs, { subPath }) => { return await zipFs.truncatePromise(subPath, len); }); } truncateSync(p, len) { return this.makeCallSync(p, () => { return this.baseFs.truncateSync(p, len); - }, (zipFs, {subPath}) => { + }, (zipFs, { subPath }) => { return zipFs.truncateSync(subPath, len); }); } @@ -23485,14 +23522,26 @@ class ZipOpenFS extends BasePortableFakeFS { } watch(p, a, b) { return this.makeCallSync(p, () => { - return this.baseFs.watch(p, a, b); - }, (zipFs, {subPath}) => { - return zipFs.watch(subPath, a, b); + return this.baseFs.watch( + p, + a, + b + ); + }, (zipFs, { subPath }) => { + return zipFs.watch( + subPath, + a, + b + ); }); } watchFile(p, a, b) { return this.makeCallSync(p, () => { - return this.baseFs.watchFile(p, a, b); + return this.baseFs.watchFile( + p, + a, + b + ); }, () => { return watchFile(this, p, a, b); }); @@ -23504,7 +23553,7 @@ class ZipOpenFS extends BasePortableFakeFS { return unwatchFile(this, p, cb); }); } - async makeCallPromise(p, discard, accept, {requireSubpath = true} = {}) { + async makeCallPromise(p, discard, accept, { requireSubpath = true } = {}) { if (typeof p !== `string`) return await discard(); const normalizedP = this.resolve(p); @@ -23515,7 +23564,7 @@ class ZipOpenFS extends BasePortableFakeFS { return await discard(); return await this.getZipPromise(zipInfo.archivePath, async (zipFs) => await accept(zipFs, zipInfo)); } - makeCallSync(p, discard, accept, {requireSubpath = true} = {}) { + makeCallSync(p, discard, accept, { requireSubpath = true } = {}) { if (typeof p !== `string`) return discard(); const normalizedP = this.resolve(p); @@ -23571,7 +23620,7 @@ class ZipOpenFS extends BasePortableFakeFS { const now = Date.now(); let nextExpiresAt = now + this.maxAge; let closeCount = max === null ? 0 : this.zipInstances.size - max; - for (const [path, {zipFs, expiresAt, refCount}] of this.zipInstances.entries()) { + for (const [path, { zipFs, expiresAt, refCount }] of this.zipInstances.entries()) { if (refCount !== 0 || zipFs.hasOpenFileHandles()) { continue; } else if (now >= expiresAt) { @@ -23665,7 +23714,7 @@ class ZipOpenFS extends BasePortableFakeFS { } } -class URLFS extends ProxiedFS { +class NodePathFS extends ProxiedFS { constructor(baseFs) { super(npath); this.baseFs = baseFs; @@ -23674,31 +23723,20 @@ class URLFS extends ProxiedFS { return path; } mapToBase(path) { + if (typeof path === `string`) + return path; if (path instanceof url.URL) return url.fileURLToPath(path); - return path; + if (Buffer.isBuffer(path)) { + const str = path.toString(); + if (Buffer.byteLength(str) !== path.byteLength) + throw new Error(`Non-utf8 buffers are not supported at the moment. Please upvote the following issue if you encounter this error: https://github.com/yarnpkg/berry/issues/4942`); + return str; + } + throw new Error(`Unsupported path type: ${nodeUtils.inspect(path)}`); } } -var __defProp$3 = Object.defineProperty; -var __defProps$2 = Object.defineProperties; -var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors; -var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols; -var __hasOwnProp$4 = Object.prototype.hasOwnProperty; -var __propIsEnum$4 = Object.prototype.propertyIsEnumerable; -var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, {enumerable: true, configurable: true, writable: true, value}) : obj[key] = value; -var __spreadValues$3 = (a, b) => { - for (var prop in b || (b = {})) - if (__hasOwnProp$4.call(b, prop)) - __defNormalProp$3(a, prop, b[prop]); - if (__getOwnPropSymbols$4) - for (var prop of __getOwnPropSymbols$4(b)) { - if (__propIsEnum$4.call(b, prop)) - __defNormalProp$3(a, prop, b[prop]); - } - return a; -}; -var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b)); var _a, _b, _c, _d; const kBaseFs = Symbol(`kBaseFs`); const kFd = Symbol(`kFd`); @@ -23725,13 +23763,18 @@ class FileHandle { try { this[kRef](this.appendFile); const encoding = (_a2 = typeof options === `string` ? options : options == null ? void 0 : options.encoding) != null ? _a2 : void 0; - return await this[kBaseFs].appendFilePromise(this.fd, data, encoding ? {encoding} : void 0); + return await this[kBaseFs].appendFilePromise(this.fd, data, encoding ? { encoding } : void 0); } finally { this[kUnref](); } } - chown(uid, gid) { - throw new Error(`Method not implemented.`); + async chown(uid, gid) { + try { + this[kRef](this.chown); + return await this[kBaseFs].fchownPromise(this.fd, uid, gid); + } finally { + this[kUnref](); + } } async chmod(mode) { try { @@ -23742,10 +23785,10 @@ class FileHandle { } } createReadStream(options) { - return this[kBaseFs].createReadStream(null, __spreadProps$2(__spreadValues$3({}, options), {fd: this.fd})); + return this[kBaseFs].createReadStream(null, { ...options, fd: this.fd }); } createWriteStream(options) { - return this[kBaseFs].createWriteStream(null, __spreadProps$2(__spreadValues$3({}, options), {fd: this.fd})); + return this[kBaseFs].createWriteStream(null, { ...options, fd: this.fd }); } datasync() { throw new Error(`Method not implemented.`); @@ -23794,6 +23837,12 @@ class FileHandle { this[kUnref](); } } + readLines(options) { + return readline.createInterface({ + input: this.createReadStream(options), + crlfDelay: Infinity + }); + } async stat(opts) { try { this[kRef](this.stat); @@ -23829,11 +23878,11 @@ class FileHandle { if (ArrayBuffer.isView(args[0])) { const [buffer, offset, length, position] = args; const bytesWritten = await this[kBaseFs].writePromise(this.fd, buffer, offset != null ? offset : void 0, length != null ? length : void 0, position != null ? position : void 0); - return {bytesWritten, buffer}; + return { bytesWritten, buffer }; } else { const [data, position, encoding] = args; const bytesWritten = await this[kBaseFs].writePromise(this.fd, data, position, encoding); - return {bytesWritten, buffer: data}; + return { bytesWritten, buffer: data }; } } finally { this[kUnref](); @@ -23909,7 +23958,7 @@ class FileHandle { } } -const SYNC_IMPLEMENTATIONS = new Set([ +const SYNC_IMPLEMENTATIONS = /* @__PURE__ */ new Set([ `accessSync`, `appendFileSync`, `createReadStream`, @@ -23917,6 +23966,7 @@ const SYNC_IMPLEMENTATIONS = new Set([ `chmodSync`, `fchmodSync`, `chownSync`, + `fchownSync`, `closeSync`, `copyFileSync`, `linkSync`, @@ -23945,11 +23995,12 @@ const SYNC_IMPLEMENTATIONS = new Set([ `writeFileSync`, `writeSync` ]); -const ASYNC_IMPLEMENTATIONS = new Set([ +const ASYNC_IMPLEMENTATIONS = /* @__PURE__ */ new Set([ `accessPromise`, `appendFilePromise`, `fchmodPromise`, `chmodPromise`, + `fchownPromise`, `chownPromise`, `closePromise`, `copyFilePromise`, @@ -23977,7 +24028,7 @@ const ASYNC_IMPLEMENTATIONS = new Set([ `writeSync` ]); function patchFs(patchedFs, fakeFs) { - fakeFs = new URLFS(fakeFs); + fakeFs = new NodePathFS(fakeFs); const setupFn = (target, name, replacement) => { const orig = target[name]; target[name] = replacement; @@ -24069,7 +24120,7 @@ function patchFs(patchedFs, fakeFs) { let [fd, buffer, offset, length, position] = args; if (args.length <= 3) { const options = args[2] || {}; - ({offset = 0, length = buffer.byteLength, position} = options); + ({ offset = 0, length = buffer.byteLength, position } = options); } if (offset == null) offset = 0; @@ -24128,11 +24179,11 @@ function patchFs(patchedFs, fakeFs) { { patchedFs.read[nodeUtils.promisify.custom] = async (fd, buffer, ...args) => { const res = fakeFs.readPromise(fd, buffer, ...args); - return {bytesRead: await res, buffer}; + return { bytesRead: await res, buffer }; }; patchedFs.write[nodeUtils.promisify.custom] = async (fd, buffer, ...args) => { const res = fakeFs.writePromise(fd, buffer, ...args); - return {bytesWritten: await res, buffer}; + return { bytesWritten: await res, buffer }; }; } } @@ -24262,7 +24313,10 @@ var createModule = function() { } function getCFunc(ident) { var func = Module["_" + ident]; - assert(func, "Cannot call unknown function " + ident + ", make sure it is exported"); + assert( + func, + "Cannot call unknown function " + ident + ", make sure it is exported" + ); return func; } function ccall(ident, returnType, argTypes, args, opts) { @@ -24561,14 +24615,16 @@ var createModule = function() { var str = e.toString(); err("failed to compile wasm module: " + str); if (str.includes("imported Memory") || str.includes("memory import")) { - err("Memory size incompatibility issues may be due to changing INITIAL_MEMORY at runtime to something too large. Use ALLOW_MEMORY_GROWTH to allow any size memory (and also make sure not to set INITIAL_MEMORY at runtime to something smaller than it was at compile time)."); + err( + "Memory size incompatibility issues may be due to changing INITIAL_MEMORY at runtime to something too large. Use ALLOW_MEMORY_GROWTH to allow any size memory (and also make sure not to set INITIAL_MEMORY at runtime to something smaller than it was at compile time)." + ); } throw e; } return [instance, module2]; } function createWasm() { - var info = {a: asmLibraryArg}; + var info = { a: asmLibraryArg }; function receiveInstance(instance, module2) { var exports3 = instance.exports; Module["asm"] = exports3; @@ -24663,9 +24719,12 @@ var createModule = function() { }, normalize: function(path) { var isAbsolute = path.charAt(0) === "/", trailingSlash = path.substr(-1) === "/"; - path = PATH.normalizeArray(path.split("/").filter(function(p) { - return !!p; - }), !isAbsolute).join("/"); + path = PATH.normalizeArray( + path.split("/").filter(function(p) { + return !!p; + }), + !isAbsolute + ).join("/"); if (!path && !isAbsolute) { path = "."; } @@ -24732,9 +24791,12 @@ var createModule = function() { resolvedPath = path + "/" + resolvedPath; resolvedAbsolute = path.charAt(0) === "/"; } - resolvedPath = PATH.normalizeArray(resolvedPath.split("/").filter(function(p) { - return !!p; - }), !resolvedAbsolute).join("/"); + resolvedPath = PATH.normalizeArray( + resolvedPath.split("/").filter(function(p) { + return !!p; + }), + !resolvedAbsolute + ).join("/"); return (resolvedAbsolute ? "/" : "") + resolvedPath || "."; }, relative: function(from, to) { @@ -24780,7 +24842,7 @@ var createModule = function() { shutdown: function() { }, register: function(dev, ops) { - TTY.ttys[dev] = {input: [], output: [], ops}; + TTY.ttys[dev] = { input: [], output: [], ops }; FS.registerDevice(dev, TTY.stream_ops); }, stream_ops: { @@ -24849,7 +24911,13 @@ var createModule = function() { var buf = Buffer.alloc ? Buffer.alloc(BUFSIZE) : new Buffer(BUFSIZE); var bytesRead = 0; try { - bytesRead = nodeFS.readSync(process.stdin.fd, buf, 0, BUFSIZE, null); + bytesRead = nodeFS.readSync( + process.stdin.fd, + buf, + 0, + BUFSIZE, + null + ); } catch (e) { if (e.toString().includes("EOF")) bytesRead = 0; @@ -24933,7 +25001,7 @@ var createModule = function() { readdir: MEMFS.node_ops.readdir, symlink: MEMFS.node_ops.symlink }, - stream: {llseek: MEMFS.stream_ops.llseek} + stream: { llseek: MEMFS.stream_ops.llseek } }, file: { node: { @@ -25002,7 +25070,10 @@ var createModule = function() { if (prevCapacity >= newCapacity) return; var CAPACITY_DOUBLING_MAX = 1024 * 1024; - newCapacity = Math.max(newCapacity, prevCapacity * (prevCapacity < CAPACITY_DOUBLING_MAX ? 2 : 1.125) >>> 0); + newCapacity = Math.max( + newCapacity, + prevCapacity * (prevCapacity < CAPACITY_DOUBLING_MAX ? 2 : 1.125) >>> 0 + ); if (prevCapacity != 0) newCapacity = Math.max(newCapacity, 256); var oldContents = node.contents; @@ -25020,7 +25091,9 @@ var createModule = function() { var oldContents = node.contents; node.contents = new Uint8Array(newSize); if (oldContents) { - node.contents.set(oldContents.subarray(0, Math.min(newSize, node.usedBytes))); + node.contents.set( + oldContents.subarray(0, Math.min(newSize, node.usedBytes)) + ); } node.usedBytes = newSize; } @@ -25154,13 +25227,19 @@ var createModule = function() { node.usedBytes = length; return length; } else if (position + length <= node.usedBytes) { - node.contents.set(buffer2.subarray(offset, offset + length), position); + node.contents.set( + buffer2.subarray(offset, offset + length), + position + ); return length; } } MEMFS.expandFileStorage(node, position + length); if (node.contents.subarray && buffer2.subarray) { - node.contents.set(buffer2.subarray(offset, offset + length), position); + node.contents.set( + buffer2.subarray(offset, offset + length), + position + ); } else { for (var i = 0; i < length; i++) { node.contents[position + i] = buffer2[offset + i]; @@ -25185,7 +25264,10 @@ var createModule = function() { }, allocate: function(stream, offset, length) { MEMFS.expandFileStorage(stream.node, offset + length); - stream.node.usedBytes = Math.max(stream.node.usedBytes, offset + length); + stream.node.usedBytes = Math.max( + stream.node.usedBytes, + offset + length + ); }, mmap: function(stream, address, length, position, prot, flags) { if (address !== 0) { @@ -25205,7 +25287,11 @@ var createModule = function() { if (contents.subarray) { contents = contents.subarray(position, position + length); } else { - contents = Array.prototype.slice.call(contents, position, position + length); + contents = Array.prototype.slice.call( + contents, + position, + position + length + ); } } allocated = true; @@ -25215,7 +25301,7 @@ var createModule = function() { } HEAP8.set(contents, ptr); } - return {ptr, allocated}; + return { ptr, allocated }; }, msync: function(stream, buffer2, offset, length, mmapFlags) { if (!FS.isFile(stream.node.mode)) { @@ -25224,7 +25310,14 @@ var createModule = function() { if (mmapFlags & 2) { return 0; } - MEMFS.stream_ops.write(stream, buffer2, 0, length, offset, false); + MEMFS.stream_ops.write( + stream, + buffer2, + 0, + length, + offset, + false + ); return 0; } } @@ -25356,7 +25449,7 @@ var createModule = function() { isWindows: false, staticInit: function() { NODEFS.isWindows = !!process.platform.match(/^win/); - var flags = {fs: fs.constants}; + var flags = { fs: fs.constants }; if (flags["fs"]) { flags = flags["fs"]; } @@ -25498,7 +25591,7 @@ var createModule = function() { if (FS.isDir(node.mode)) { fs.mkdirSync(path, node.mode); } else { - fs.writeFileSync(path, "", {mode: node.mode}); + fs.writeFileSync(path, "", { mode: node.mode }); } } catch (e) { if (!e.code) @@ -25563,7 +25656,10 @@ var createModule = function() { var path = NODEFS.realPath(node); try { path = fs.readlinkSync(path); - path = NODEJS_PATH.relative(NODEJS_PATH.resolve(node.mount.opts.root), path); + path = NODEJS_PATH.relative( + NODEJS_PATH.resolve(node.mount.opts.root), + path + ); return path; } catch (e) { if (!e.code) @@ -25600,14 +25696,26 @@ var createModule = function() { if (length === 0) return 0; try { - return fs.readSync(stream.nfd, NODEFS.bufferFrom(buffer2.buffer), offset, length, position); + return fs.readSync( + stream.nfd, + NODEFS.bufferFrom(buffer2.buffer), + offset, + length, + position + ); } catch (e) { throw new FS.ErrnoError(NODEFS.convertNodeCode(e)); } }, write: function(stream, buffer2, offset, length, position) { try { - return fs.writeSync(stream.nfd, NODEFS.bufferFrom(buffer2.buffer), offset, length, position); + return fs.writeSync( + stream.nfd, + NODEFS.bufferFrom(buffer2.buffer), + offset, + length, + position + ); } catch (e) { throw new FS.ErrnoError(NODEFS.convertNodeCode(e)); } @@ -25640,7 +25748,7 @@ var createModule = function() { } var ptr = mmapAlloc(length); NODEFS.stream_ops.read(stream, HEAP8, ptr, length, position); - return {ptr, allocated: true}; + return { ptr, allocated: true }; }, msync: function(stream, buffer2, offset, length, mmapFlags) { if (!FS.isFile(stream.node.mode)) { @@ -25649,14 +25757,21 @@ var createModule = function() { if (mmapFlags & 2) { return 0; } - NODEFS.stream_ops.write(stream, buffer2, 0, length, offset, false); + NODEFS.stream_ops.write( + stream, + buffer2, + 0, + length, + offset, + false + ); return 0; } } }; var NODERAWFS = { lookupPath: function(path) { - return {path, node: {mode: NODEFS.getMode(path)}}; + return { path, node: { mode: NODEFS.getMode(path) } }; }, createStandardStreams: function() { FS.streams[0] = { @@ -25690,7 +25805,7 @@ var createModule = function() { if (FS.isDir(path)) { fs.mkdirSync(path, mode); } else { - fs.writeFileSync(path, "", {mode}); + fs.writeFileSync(path, "", { mode }); } }, mkdir: function() { @@ -25792,7 +25907,13 @@ var createModule = function() { var seeking = typeof position !== "undefined"; if (!seeking && stream.seekable) position = stream.position; - var bytesRead = fs.readSync(stream.nfd, NODEFS.bufferFrom(buffer2.buffer), offset, length, position); + var bytesRead = fs.readSync( + stream.nfd, + NODEFS.bufferFrom(buffer2.buffer), + offset, + length, + position + ); if (!seeking) stream.position += bytesRead; return bytesRead; @@ -25807,7 +25928,13 @@ var createModule = function() { var seeking = typeof position !== "undefined"; if (!seeking && stream.seekable) position = stream.position; - var bytesWritten = fs.writeSync(stream.nfd, NODEFS.bufferFrom(buffer2.buffer), offset, length, position); + var bytesWritten = fs.writeSync( + stream.nfd, + NODEFS.bufferFrom(buffer2.buffer), + offset, + length, + position + ); if (!seeking) stream.position += bytesWritten; return bytesWritten; @@ -25824,7 +25951,7 @@ var createModule = function() { } var ptr = mmapAlloc(length); FS.read(stream, HEAP8, ptr, length, position); - return {ptr, allocated: true}; + return { ptr, allocated: true }; }, msync: function(stream, buffer2, offset, length, mmapFlags) { if (stream.stream_ops) { @@ -25854,7 +25981,7 @@ var createModule = function() { initialized: false, ignorePermissions: true, trackingDelegate: {}, - tracking: {openFlags: {READ: 1, WRITE: 2}}, + tracking: { openFlags: { READ: 1, WRITE: 2 } }, ErrnoError: null, genericErrors: {}, filesystems: null, @@ -25863,8 +25990,8 @@ var createModule = function() { path = PATH_FS.resolve(FS.cwd(), path); opts = opts || {}; if (!path) - return {path: "", node: null}; - var defaults = {follow_mount: true, recurse_count: 0}; + return { path: "", node: null }; + var defaults = { follow_mount: true, recurse_count: 0 }; for (var key2 in defaults) { if (opts[key2] === void 0) { opts[key2] = defaults[key2]; @@ -25873,9 +26000,12 @@ var createModule = function() { if (opts.recurse_count > 8) { throw new FS.ErrnoError(32); } - var parts = PATH.normalizeArray(path.split("/").filter(function(p) { - return !!p; - }), false); + var parts = PATH.normalizeArray( + path.split("/").filter(function(p) { + return !!p; + }), + false + ); var current = FS.root; var current_path = "/"; for (var i = 0; i < parts.length; i++) { @@ -25905,7 +26035,7 @@ var createModule = function() { } } } - return {path: current_path, node: current}; + return { path: current_path, node: current }; }, getPath: function(node) { var path; @@ -25996,7 +26126,7 @@ var createModule = function() { isSocket: function(mode) { return (mode & 49152) === 49152; }, - flagModes: {r: 0, "r+": 2, w: 577, "w+": 578, a: 1089, "a+": 1090}, + flagModes: { r: 0, "r+": 2, w: 577, "w+": 578, a: 1089, "a+": 1090 }, modeStringToFlags: function(str) { var flags = FS.flagModes[str]; if (typeof flags === "undefined") { @@ -26157,7 +26287,7 @@ var createModule = function() { return ma << 8 | mi; }, registerDevice: function(dev, ops) { - FS.devices[dev] = {stream_ops: ops}; + FS.devices[dev] = { stream_ops: ops }; }, getDevice: function(dev) { return FS.devices[dev]; @@ -26179,7 +26309,9 @@ var createModule = function() { } FS.syncFSRequests++; if (FS.syncFSRequests > 1) { - err("warning: " + FS.syncFSRequests + " FS.syncfs operations in flight at once, probably just doing extra work"); + err( + "warning: " + FS.syncFSRequests + " FS.syncfs operations in flight at once, probably just doing extra work" + ); } var mounts = FS.getMounts(FS.root.mount); var completed = 0; @@ -26213,7 +26345,7 @@ var createModule = function() { if (root && FS.root) { throw new FS.ErrnoError(10); } else if (!root && !pseudo) { - var lookup = FS.lookupPath(mountpoint, {follow_mount: false}); + var lookup = FS.lookupPath(mountpoint, { follow_mount: false }); mountpoint = lookup.path; node = lookup.node; if (FS.isMountpoint(node)) { @@ -26243,7 +26375,7 @@ var createModule = function() { return mountRoot; }, unmount: function(mountpoint) { - var lookup = FS.lookupPath(mountpoint, {follow_mount: false}); + var lookup = FS.lookupPath(mountpoint, { follow_mount: false }); if (!FS.isMountpoint(lookup.node)) { throw new FS.ErrnoError(28); } @@ -26268,7 +26400,7 @@ var createModule = function() { return parent.node_ops.lookup(parent, name); }, mknod: function(path, mode, dev) { - var lookup = FS.lookupPath(path, {parent: true}); + var lookup = FS.lookupPath(path, { parent: true }); var parent = lookup.node; var name = PATH.basename(path); if (!name || name === "." || name === "..") { @@ -26322,7 +26454,7 @@ var createModule = function() { if (!PATH_FS.resolve(oldpath)) { throw new FS.ErrnoError(44); } - var lookup = FS.lookupPath(newpath, {parent: true}); + var lookup = FS.lookupPath(newpath, { parent: true }); var parent = lookup.node; if (!parent) { throw new FS.ErrnoError(44); @@ -26343,9 +26475,9 @@ var createModule = function() { var old_name = PATH.basename(old_path); var new_name = PATH.basename(new_path); var lookup, old_dir, new_dir; - lookup = FS.lookupPath(old_path, {parent: true}); + lookup = FS.lookupPath(old_path, { parent: true }); old_dir = lookup.node; - lookup = FS.lookupPath(new_path, {parent: true}); + lookup = FS.lookupPath(new_path, { parent: true }); new_dir = lookup.node; if (!old_dir || !new_dir) throw new FS.ErrnoError(44); @@ -26395,7 +26527,9 @@ var createModule = function() { FS.trackingDelegate["willMovePath"](old_path, new_path); } } catch (e) { - err("FS.trackingDelegate['willMovePath']('" + old_path + "', '" + new_path + "') threw an exception: " + e.message); + err( + "FS.trackingDelegate['willMovePath']('" + old_path + "', '" + new_path + "') threw an exception: " + e.message + ); } FS.hashRemoveNode(old_node); try { @@ -26409,11 +26543,13 @@ var createModule = function() { if (FS.trackingDelegate["onMovePath"]) FS.trackingDelegate["onMovePath"](old_path, new_path); } catch (e) { - err("FS.trackingDelegate['onMovePath']('" + old_path + "', '" + new_path + "') threw an exception: " + e.message); + err( + "FS.trackingDelegate['onMovePath']('" + old_path + "', '" + new_path + "') threw an exception: " + e.message + ); } }, rmdir: function(path) { - var lookup = FS.lookupPath(path, {parent: true}); + var lookup = FS.lookupPath(path, { parent: true }); var parent = lookup.node; var name = PATH.basename(path); var node = FS.lookupNode(parent, name); @@ -26432,7 +26568,9 @@ var createModule = function() { FS.trackingDelegate["willDeletePath"](path); } } catch (e) { - err("FS.trackingDelegate['willDeletePath']('" + path + "') threw an exception: " + e.message); + err( + "FS.trackingDelegate['willDeletePath']('" + path + "') threw an exception: " + e.message + ); } parent.node_ops.rmdir(parent, name); FS.destroyNode(node); @@ -26440,11 +26578,13 @@ var createModule = function() { if (FS.trackingDelegate["onDeletePath"]) FS.trackingDelegate["onDeletePath"](path); } catch (e) { - err("FS.trackingDelegate['onDeletePath']('" + path + "') threw an exception: " + e.message); + err( + "FS.trackingDelegate['onDeletePath']('" + path + "') threw an exception: " + e.message + ); } }, readdir: function(path) { - var lookup = FS.lookupPath(path, {follow: true}); + var lookup = FS.lookupPath(path, { follow: true }); var node = lookup.node; if (!node.node_ops.readdir) { throw new FS.ErrnoError(54); @@ -26452,7 +26592,7 @@ var createModule = function() { return node.node_ops.readdir(node); }, unlink: function(path) { - var lookup = FS.lookupPath(path, {parent: true}); + var lookup = FS.lookupPath(path, { parent: true }); var parent = lookup.node; var name = PATH.basename(path); var node = FS.lookupNode(parent, name); @@ -26471,7 +26611,9 @@ var createModule = function() { FS.trackingDelegate["willDeletePath"](path); } } catch (e) { - err("FS.trackingDelegate['willDeletePath']('" + path + "') threw an exception: " + e.message); + err( + "FS.trackingDelegate['willDeletePath']('" + path + "') threw an exception: " + e.message + ); } parent.node_ops.unlink(parent, name); FS.destroyNode(node); @@ -26479,7 +26621,9 @@ var createModule = function() { if (FS.trackingDelegate["onDeletePath"]) FS.trackingDelegate["onDeletePath"](path); } catch (e) { - err("FS.trackingDelegate['onDeletePath']('" + path + "') threw an exception: " + e.message); + err( + "FS.trackingDelegate['onDeletePath']('" + path + "') threw an exception: " + e.message + ); } }, readlink: function(path) { @@ -26491,10 +26635,13 @@ var createModule = function() { if (!link.node_ops.readlink) { throw new FS.ErrnoError(28); } - return PATH_FS.resolve(FS.getPath(link.parent), link.node_ops.readlink(link)); + return PATH_FS.resolve( + FS.getPath(link.parent), + link.node_ops.readlink(link) + ); }, stat: function(path, dontFollow) { - var lookup = FS.lookupPath(path, {follow: !dontFollow}); + var lookup = FS.lookupPath(path, { follow: !dontFollow }); var node = lookup.node; if (!node) { throw new FS.ErrnoError(44); @@ -26510,7 +26657,7 @@ var createModule = function() { chmod: function(path, mode, dontFollow) { var node; if (typeof path === "string") { - var lookup = FS.lookupPath(path, {follow: !dontFollow}); + var lookup = FS.lookupPath(path, { follow: !dontFollow }); node = lookup.node; } else { node = path; @@ -26536,7 +26683,7 @@ var createModule = function() { chown: function(path, uid, gid, dontFollow) { var node; if (typeof path === "string") { - var lookup = FS.lookupPath(path, {follow: !dontFollow}); + var lookup = FS.lookupPath(path, { follow: !dontFollow }); node = lookup.node; } else { node = path; @@ -26544,7 +26691,7 @@ var createModule = function() { if (!node.node_ops.setattr) { throw new FS.ErrnoError(63); } - node.node_ops.setattr(node, {timestamp: Date.now()}); + node.node_ops.setattr(node, { timestamp: Date.now() }); }, lchown: function(path, uid, gid) { FS.chown(path, uid, gid, true); @@ -26562,7 +26709,7 @@ var createModule = function() { } var node; if (typeof path === "string") { - var lookup = FS.lookupPath(path, {follow: true}); + var lookup = FS.lookupPath(path, { follow: true }); node = lookup.node; } else { node = path; @@ -26580,7 +26727,7 @@ var createModule = function() { if (errCode) { throw new FS.ErrnoError(errCode); } - node.node_ops.setattr(node, {size: len, timestamp: Date.now()}); + node.node_ops.setattr(node, { size: len, timestamp: Date.now() }); }, ftruncate: function(fd, len) { var stream = FS.getStream(fd); @@ -26593,9 +26740,9 @@ var createModule = function() { FS.truncate(stream.node, len); }, utime: function(path, atime, mtime) { - var lookup = FS.lookupPath(path, {follow: true}); + var lookup = FS.lookupPath(path, { follow: true }); var node = lookup.node; - node.node_ops.setattr(node, {timestamp: Math.max(atime, mtime)}); + node.node_ops.setattr(node, { timestamp: Math.max(atime, mtime) }); }, open: function(path, flags, mode, fd_start, fd_end) { if (path === "") { @@ -26614,7 +26761,7 @@ var createModule = function() { } else { path = PATH.normalize(path); try { - var lookup = FS.lookupPath(path, {follow: !(flags & 131072)}); + var lookup = FS.lookupPath(path, { follow: !(flags & 131072) }); node = lookup.node; } catch (e) { } @@ -26649,16 +26796,20 @@ var createModule = function() { FS.truncate(node, 0); } flags &= ~(128 | 512 | 131072); - var stream = FS.createStream({ - node, - path: FS.getPath(node), - flags, - seekable: true, - position: 0, - stream_ops: node.stream_ops, - ungotten: [], - error: false - }, fd_start, fd_end); + var stream = FS.createStream( + { + node, + path: FS.getPath(node), + flags, + seekable: true, + position: 0, + stream_ops: node.stream_ops, + ungotten: [], + error: false + }, + fd_start, + fd_end + ); if (stream.stream_ops.open) { stream.stream_ops.open(stream); } @@ -26682,7 +26833,9 @@ var createModule = function() { FS.trackingDelegate["onOpenFile"](path, trackingFlags); } } catch (e) { - err("FS.trackingDelegate['onOpenFile']('" + path + "', flags) threw an exception: " + e.message); + err( + "FS.trackingDelegate['onOpenFile']('" + path + "', flags) threw an exception: " + e.message + ); } return stream; }, @@ -26742,7 +26895,13 @@ var createModule = function() { } else if (!stream.seekable) { throw new FS.ErrnoError(70); } - var bytesRead = stream.stream_ops.read(stream, buffer2, offset, length, position); + var bytesRead = stream.stream_ops.read( + stream, + buffer2, + offset, + length, + position + ); if (!seeking) stream.position += bytesRead; return bytesRead; @@ -26772,14 +26931,23 @@ var createModule = function() { } else if (!stream.seekable) { throw new FS.ErrnoError(70); } - var bytesWritten = stream.stream_ops.write(stream, buffer2, offset, length, position, canOwn); + var bytesWritten = stream.stream_ops.write( + stream, + buffer2, + offset, + length, + position, + canOwn + ); if (!seeking) stream.position += bytesWritten; try { if (stream.path && FS.trackingDelegate["onWriteToFile"]) FS.trackingDelegate["onWriteToFile"](stream.path); } catch (e) { - err("FS.trackingDelegate['onWriteToFile']('" + stream.path + "') threw an exception: " + e.message); + err( + "FS.trackingDelegate['onWriteToFile']('" + stream.path + "') threw an exception: " + e.message + ); } return bytesWritten; }, @@ -26811,13 +26979,26 @@ var createModule = function() { if (!stream.stream_ops.mmap) { throw new FS.ErrnoError(43); } - return stream.stream_ops.mmap(stream, address, length, position, prot, flags); + return stream.stream_ops.mmap( + stream, + address, + length, + position, + prot, + flags + ); }, msync: function(stream, buffer2, offset, length, mmapFlags) { if (!stream || !stream.stream_ops.msync) { return 0; } - return stream.stream_ops.msync(stream, buffer2, offset, length, mmapFlags); + return stream.stream_ops.msync( + stream, + buffer2, + offset, + length, + mmapFlags + ); }, munmap: function(stream) { return 0; @@ -26868,7 +27049,7 @@ var createModule = function() { return FS.currentPath; }, chdir: function(path) { - var lookup = FS.lookupPath(path, {follow: true}); + var lookup = FS.lookupPath(path, { follow: true }); if (lookup.node === null) { throw new FS.ErrnoError(44); } @@ -26911,31 +27092,35 @@ var createModule = function() { FS.mkdir("/proc"); var proc_self = FS.mkdir("/proc/self"); FS.mkdir("/proc/self/fd"); - FS.mount({ - mount: function() { - var node = FS.createNode(proc_self, "fd", 16384 | 511, 73); - node.node_ops = { - lookup: function(parent, name) { - var fd = +name; - var stream = FS.getStream(fd); - if (!stream) - throw new FS.ErrnoError(8); - var ret = { - parent: null, - mount: {mountpoint: "fake"}, - node_ops: { - readlink: function() { - return stream.path; + FS.mount( + { + mount: function() { + var node = FS.createNode(proc_self, "fd", 16384 | 511, 73); + node.node_ops = { + lookup: function(parent, name) { + var fd = +name; + var stream = FS.getStream(fd); + if (!stream) + throw new FS.ErrnoError(8); + var ret = { + parent: null, + mount: { mountpoint: "fake" }, + node_ops: { + readlink: function() { + return stream.path; + } } - } - }; - ret.parent = ret; - return ret; - } - }; - return node; - } - }, {}, "/proc/self/fd"); + }; + ret.parent = ret; + return ret; + } + }; + return node; + } + }, + {}, + "/proc/self/fd" + ); }, createStandardStreams: function() { if (Module["stdin"]) { @@ -26982,7 +27167,7 @@ var createModule = function() { FS.createDefaultDirectories(); FS.createDefaultDevices(); FS.createSpecialDirectories(); - FS.filesystems = {MEMFS, NODEFS}; + FS.filesystems = { MEMFS, NODEFS }; }, init: function(input, output, error) { FS.init.initialized = true; @@ -27023,7 +27208,7 @@ var createModule = function() { }, analyzePath: function(path, dontResolveLastLink) { try { - var lookup = FS.lookupPath(path, {follow: !dontResolveLastLink}); + var lookup = FS.lookupPath(path, { follow: !dontResolveLastLink }); path = lookup.path; } catch (e) { } @@ -27039,12 +27224,12 @@ var createModule = function() { parentObject: null }; try { - var lookup = FS.lookupPath(path, {parent: true}); + var lookup = FS.lookupPath(path, { parent: true }); ret.parentExists = true; ret.parentPath = lookup.path; ret.parentObject = lookup.node; ret.name = PATH.basename(path); - lookup = FS.lookupPath(path, {follow: !dontResolveLastLink}); + lookup = FS.lookupPath(path, { follow: !dontResolveLastLink }); ret.exists = true; ret.path = lookup.path; ret.object = lookup.node; @@ -27072,12 +27257,18 @@ var createModule = function() { return current; }, createFile: function(parent, name, properties, canRead, canWrite) { - var path = PATH.join2(typeof parent === "string" ? parent : FS.getPath(parent), name); + var path = PATH.join2( + typeof parent === "string" ? parent : FS.getPath(parent), + name + ); var mode = FS.getMode(canRead, canWrite); return FS.create(path, mode); }, createDataFile: function(parent, name, data, canRead, canWrite, canOwn) { - var path = name ? PATH.join2(typeof parent === "string" ? parent : FS.getPath(parent), name) : parent; + var path = name ? PATH.join2( + typeof parent === "string" ? parent : FS.getPath(parent), + name + ) : parent; var mode = FS.getMode(canRead, canWrite); var node = FS.create(path, mode); if (data) { @@ -27096,7 +27287,10 @@ var createModule = function() { return node; }, createDevice: function(parent, name, input, output) { - var path = PATH.join2(typeof parent === "string" ? parent : FS.getPath(parent), name); + var path = PATH.join2( + typeof parent === "string" ? parent : FS.getPath(parent), + name + ); var mode = FS.getMode(!!input, !!output); if (!FS.createDevice.major) FS.createDevice.major = 64; @@ -27164,7 +27358,7 @@ var createModule = function() { }, createLazyFile: function(parent, name, url, canRead, canWrite) { var properties; { - var properties = {isDevice: false, url}; + var properties = { isDevice: false, url }; } var node = FS.createFile(parent, name, properties, canRead, canWrite); if (properties.contents) { @@ -27217,7 +27411,14 @@ var createModule = function() { if (preFinish) preFinish(); if (!dontCreateFile) { - FS.createDataFile(parent, name, byteArray2, canRead, canWrite, canOwn); + FS.createDataFile( + parent, + name, + byteArray2, + canRead, + canWrite, + canOwn + ); } if (onload) onload(); @@ -27241,9 +27442,13 @@ var createModule = function() { } addRunDependency(); if (typeof url == "string") { - Browser.asyncLoad(url, function(byteArray) { - processData(byteArray); - }, onerror); + Browser.asyncLoad( + url, + function(byteArray) { + processData(byteArray); + }, + onerror + ); } else { processData(url); } @@ -27284,7 +27489,10 @@ var createModule = function() { onerror(); } paths.forEach(function(path) { - var putRequest = files.put(FS.analyzePath(path).object.contents, path); + var putRequest = files.put( + FS.analyzePath(path).object.contents, + path + ); putRequest.onsuccess = function putRequest_onsuccess() { ok++; if (ok + fail == total) @@ -27334,7 +27542,14 @@ var createModule = function() { if (FS.analyzePath(path).exists) { FS.unlink(path); } - FS.createDataFile(PATH.dirname(path), PATH.basename(path), getRequest.result, true, true, true); + FS.createDataFile( + PATH.dirname(path), + PATH.basename(path), + getRequest.result, + true, + true, + true + ); ok++; if (ok + fail == total) finish(); @@ -27395,7 +27610,9 @@ var createModule = function() { HEAP32[buf + 32 >> 2] = 0; tempI64 = [ stat.size >>> 0, - (tempDouble = stat.size, +Math.abs(tempDouble) >= 1 ? tempDouble > 0 ? (Math.min(+Math.floor(tempDouble / 4294967296), 4294967295) | 0) >>> 0 : ~~+Math.ceil((tempDouble - +(~~tempDouble >>> 0)) / 4294967296) >>> 0 : 0) + (tempDouble = stat.size, +Math.abs(tempDouble) >= 1 ? tempDouble > 0 ? (Math.min(+Math.floor(tempDouble / 4294967296), 4294967295) | 0) >>> 0 : ~~+Math.ceil( + (tempDouble - +(~~tempDouble >>> 0)) / 4294967296 + ) >>> 0 : 0) ], HEAP32[buf + 40 >> 2] = tempI64[0], HEAP32[buf + 44 >> 2] = tempI64[1]; HEAP32[buf + 48 >> 2] = 4096; HEAP32[buf + 52 >> 2] = stat.blocks; @@ -27407,7 +27624,9 @@ var createModule = function() { HEAP32[buf + 76 >> 2] = 0; tempI64 = [ stat.ino >>> 0, - (tempDouble = stat.ino, +Math.abs(tempDouble) >= 1 ? tempDouble > 0 ? (Math.min(+Math.floor(tempDouble / 4294967296), 4294967295) | 0) >>> 0 : ~~+Math.ceil((tempDouble - +(~~tempDouble >>> 0)) / 4294967296) >>> 0 : 0) + (tempDouble = stat.ino, +Math.abs(tempDouble) >= 1 ? tempDouble > 0 ? (Math.min(+Math.floor(tempDouble / 4294967296), 4294967295) | 0) >>> 0 : ~~+Math.ceil( + (tempDouble - +(~~tempDouble >>> 0)) / 4294967296 + ) >>> 0 : 0) ], HEAP32[buf + 80 >> 2] = tempI64[0], HEAP32[buf + 84 >> 2] = tempI64[1]; return 0; }, @@ -27451,7 +27670,7 @@ var createModule = function() { return -28; } var node; - var lookup = FS.lookupPath(path, {follow: true}); + var lookup = FS.lookupPath(path, { follow: true }); node = lookup.node; if (!node) { return -44; @@ -27727,8 +27946,14 @@ var createModule = function() { } for (var cutDown = 1; cutDown <= 4; cutDown *= 2) { var overGrownHeapSize = oldSize * (1 + 0.2 / cutDown); - overGrownHeapSize = Math.min(overGrownHeapSize, requestedSize + 100663296); - var newSize = Math.min(maxHeapSize, alignUp(Math.max(requestedSize, overGrownHeapSize), 65536)); + overGrownHeapSize = Math.min( + overGrownHeapSize, + requestedSize + 100663296 + ); + var newSize = Math.min( + maxHeapSize, + alignUp(Math.max(requestedSize, overGrownHeapSize), 65536) + ); var replacement = emscripten_realloc_buffer(newSize); if (replacement) { return true; @@ -27783,7 +28008,9 @@ var createModule = function() { FS.llseek(stream, offset, whence); tempI64 = [ stream.position >>> 0, - (tempDouble = stream.position, +Math.abs(tempDouble) >= 1 ? tempDouble > 0 ? (Math.min(+Math.floor(tempDouble / 4294967296), 4294967295) | 0) >>> 0 : ~~+Math.ceil((tempDouble - +(~~tempDouble >>> 0)) / 4294967296) >>> 0 : 0) + (tempDouble = stream.position, +Math.abs(tempDouble) >= 1 ? tempDouble > 0 ? (Math.min(+Math.floor(tempDouble / 4294967296), 4294967295) | 0) >>> 0 : ~~+Math.ceil( + (tempDouble - +(~~tempDouble >>> 0)) / 4294967296 + ) >>> 0 : 0) ], HEAP32[newOffset >> 2] = tempI64[0], HEAP32[newOffset + 4 >> 2] = tempI64[1]; if (stream.getdents && offset === 0 && whence === 0) stream.getdents = null; @@ -27845,7 +28072,15 @@ var createModule = function() { } function _timegm(tmPtr) { _tzset(); - var time = Date.UTC(HEAP32[tmPtr + 20 >> 2] + 1900, HEAP32[tmPtr + 16 >> 2], HEAP32[tmPtr + 12 >> 2], HEAP32[tmPtr + 8 >> 2], HEAP32[tmPtr + 4 >> 2], HEAP32[tmPtr >> 2], 0); + var time = Date.UTC( + HEAP32[tmPtr + 20 >> 2] + 1900, + HEAP32[tmPtr + 16 >> 2], + HEAP32[tmPtr + 12 >> 2], + HEAP32[tmPtr + 8 >> 2], + HEAP32[tmPtr + 4 >> 2], + HEAP32[tmPtr >> 2], + 0 + ); var date = new Date(time); HEAP32[tmPtr + 24 >> 2] = date.getUTCDay(); var start = Date.UTC(date.getUTCFullYear(), 0, 1, 0, 0, 0, 0); @@ -27923,7 +28158,12 @@ var createModule = function() { function intArrayFromString(stringy, dontAddNull, length) { var len = length > 0 ? length : lengthBytesUTF8(stringy) + 1; var u8array = new Array(len); - var numBytesWritten = stringToUTF8Array(stringy, u8array, 0, u8array.length); + var numBytesWritten = stringToUTF8Array( + stringy, + u8array, + 0, + u8array.length + ); if (dontAddNull) u8array.length = numBytesWritten; return u8array; @@ -27936,7 +28176,11 @@ var createModule = function() { } catch (_) { buf = new Buffer(s, "base64"); } - return new Uint8Array(buf["buffer"], buf["byteOffset"], buf["byteLength"]); + return new Uint8Array( + buf["buffer"], + buf["byteOffset"], + buf["byteLength"] + ); } } function tryParseAsDataURI(filename) { @@ -28089,8 +28333,7 @@ const number64 = [ `number`, `number` ]; -var Errors; -(function(Errors2) { +var Errors = /* @__PURE__ */ ((Errors2) => { Errors2[Errors2["ZIP_ER_OK"] = 0] = "ZIP_ER_OK"; Errors2[Errors2["ZIP_ER_MULTIDISK"] = 1] = "ZIP_ER_MULTIDISK"; Errors2[Errors2["ZIP_ER_RENAME"] = 2] = "ZIP_ER_RENAME"; @@ -28123,7 +28366,8 @@ var Errors; Errors2[Errors2["ZIP_ER_INUSE"] = 29] = "ZIP_ER_INUSE"; Errors2[Errors2["ZIP_ER_TELL"] = 30] = "ZIP_ER_TELL"; Errors2[Errors2["ZIP_ER_COMPRESSED_DATA"] = 31] = "ZIP_ER_COMPRESSED_DATA"; -})(Errors || (Errors = {})); + return Errors2; +})(Errors || {}); const makeInterface = (libzip) => ({ get HEAP8() { return libzip.HEAP8; @@ -28243,27 +28487,7 @@ function getLibzipSync() { return mod; } -var __defProp$2 = Object.defineProperty; -var __defProps$1 = Object.defineProperties; -var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors; -var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols; -var __hasOwnProp$3 = Object.prototype.hasOwnProperty; -var __propIsEnum$3 = Object.prototype.propertyIsEnumerable; -var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, {enumerable: true, configurable: true, writable: true, value}) : obj[key] = value; -var __spreadValues$2 = (a, b) => { - for (var prop in b || (b = {})) - if (__hasOwnProp$3.call(b, prop)) - __defNormalProp$2(a, prop, b[prop]); - if (__getOwnPropSymbols$3) - for (var prop of __getOwnPropSymbols$3(b)) { - if (__propIsEnum$3.call(b, prop)) - __defNormalProp$2(a, prop, b[prop]); - } - return a; -}; -var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b)); -var ErrorCode; -(function(ErrorCode2) { +var ErrorCode = /* @__PURE__ */ ((ErrorCode2) => { ErrorCode2["API_ERROR"] = `API_ERROR`; ErrorCode2["BUILTIN_NODE_RESOLUTION_FAILED"] = `BUILTIN_NODE_RESOLUTION_FAILED`; ErrorCode2["EXPORTS_RESOLUTION_FAILED"] = `EXPORTS_RESOLUTION_FAILED`; @@ -28273,13 +28497,14 @@ var ErrorCode; ErrorCode2["INTERNAL"] = `INTERNAL`; ErrorCode2["UNDECLARED_DEPENDENCY"] = `UNDECLARED_DEPENDENCY`; ErrorCode2["UNSUPPORTED"] = `UNSUPPORTED`; -})(ErrorCode || (ErrorCode = {})); -const MODULE_NOT_FOUND_ERRORS = new Set([ - ErrorCode.BUILTIN_NODE_RESOLUTION_FAILED, - ErrorCode.MISSING_DEPENDENCY, - ErrorCode.MISSING_PEER_DEPENDENCY, - ErrorCode.QUALIFIED_PATH_RESOLUTION_FAILED, - ErrorCode.UNDECLARED_DEPENDENCY + return ErrorCode2; +})(ErrorCode || {}); +const MODULE_NOT_FOUND_ERRORS = /* @__PURE__ */ new Set([ + "BUILTIN_NODE_RESOLUTION_FAILED" /* BUILTIN_NODE_RESOLUTION_FAILED */, + "MISSING_DEPENDENCY" /* MISSING_DEPENDENCY */, + "MISSING_PEER_DEPENDENCY" /* MISSING_PEER_DEPENDENCY */, + "QUALIFIED_PATH_RESOLUTION_FAILED" /* QUALIFIED_PATH_RESOLUTION_FAILED */, + "UNDECLARED_DEPENDENCY" /* UNDECLARED_DEPENDENCY */ ]); function makeError(pnpCode, message, data = {}, code) { code != null ? code : code = MODULE_NOT_FOUND_ERRORS.has(pnpCode) ? `MODULE_NOT_FOUND` : pnpCode; @@ -28289,15 +28514,18 @@ function makeError(pnpCode, message, data = {}, code) { enumerable: false }; return Object.defineProperties(new Error(message), { - code: __spreadProps$1(__spreadValues$2({}, propertySpec), { + code: { + ...propertySpec, value: code - }), - pnpCode: __spreadProps$1(__spreadValues$2({}, propertySpec), { + }, + pnpCode: { + ...propertySpec, value: pnpCode - }), - data: __spreadProps$1(__spreadValues$2({}, propertySpec), { + }, + data: { + ...propertySpec, value: data - }) + } }); } function getIssuerModule(parent) { @@ -28310,6 +28538,9 @@ function getPathForDisplay(p) { return npath.normalize(npath.fromPortablePath(p)); } +const [major, minor] = process.versions.node.split(`.`).map((value) => parseInt(value, 10)); +const WATCH_MODE_MESSAGE_USES_ARRAYS = major > 19 || major === 19 && minor >= 2 || major === 18 && minor >= 13; + const builtinModules = new Set(require$$0.Module.builtinModules || Object.keys(process.binding(`natives`))); const isBuiltinModule = (request) => request.startsWith(`node:`) || builtinModules.has(request); function readPackageScope(checkPath) { @@ -28344,22 +28575,19 @@ Instead change the require of ${basename} in ${parentPath} to a dynamic import() err.code = `ERR_REQUIRE_ESM`; return err; } - -var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols; -var __hasOwnProp$2 = Object.prototype.hasOwnProperty; -var __propIsEnum$2 = Object.prototype.propertyIsEnumerable; -var __objRest$1 = (source, exclude) => { - var target = {}; - for (var prop in source) - if (__hasOwnProp$2.call(source, prop) && exclude.indexOf(prop) < 0) - target[prop] = source[prop]; - if (source != null && __getOwnPropSymbols$2) - for (var prop of __getOwnPropSymbols$2(source)) { - if (exclude.indexOf(prop) < 0 && __propIsEnum$2.call(source, prop)) - target[prop] = source[prop]; +function reportRequiredFilesToWatchMode(files) { + if (process.env.WATCH_REPORT_DEPENDENCIES && process.send) { + files = files.map((filename) => npath.fromPortablePath(VirtualFS.resolveVirtual(npath.toPortablePath(filename)))); + if (WATCH_MODE_MESSAGE_USES_ARRAYS) { + process.send({ "watch:require": files }); + } else { + for (const filename of files) { + process.send({ "watch:require": filename }); + } } - return target; -}; + } +} + function applyPatch(pnpapi, opts) { const defaultCache = {}; let enableNativeHooks = true; @@ -28400,7 +28628,7 @@ function applyPatch(pnpapi, opts) { const modulePath = require$$0.Module._resolveFilename(request, parent, isMain); const isOwnedByRuntime = parentApi !== null ? parentApi.findPackageLocator(modulePath) !== null : false; const moduleApiPath = isOwnedByRuntime ? parentApiPath : opts.manager.findApiPathFor(npath.dirname(modulePath)); - const entry = moduleApiPath !== null ? opts.manager.getApiEntry(moduleApiPath) : {instance: null, cache: defaultCache}; + const entry = moduleApiPath !== null ? opts.manager.getApiEntry(moduleApiPath) : { instance: null, cache: defaultCache }; const cacheEntry = entry.cache[modulePath]; if (cacheEntry) { if (cacheEntry.loaded === false && cacheEntry.isLoading !== true) { @@ -28419,6 +28647,7 @@ function applyPatch(pnpapi, opts) { } const module = new require$$0.Module(modulePath, parent != null ? parent : void 0); module.pnpApiPath = moduleApiPath; + reportRequiredFilesToWatchMode([modulePath]); entry.cache[modulePath] = module; if (isMain) { process.mainModule = module; @@ -28457,11 +28686,11 @@ function applyPatch(pnpapi, opts) { if (issuer !== null) { const path = npath.dirname(issuer.filename); const apiPath = opts.manager.getApiPathFromParent(issuer); - return [{apiPath, path, module}]; + return [{ apiPath, path, module }]; } else { const path = process.cwd(); const apiPath = (_a = opts.manager.findApiPathFor(npath.join(path, `[file]`))) != null ? _a : opts.manager.getApiPathFromParent(null); - return [{apiPath, path, module}]; + return [{ apiPath, path, module }]; } } function makeFakeParent(path) { @@ -28478,7 +28707,7 @@ function applyPatch(pnpapi, opts) { if (!enableNativeHooks) return originalModuleResolveFilename.call(require$$0.Module, request, parent, isMain, options); if (options && options.plugnplay === false) { - const _a = options, rest = __objRest$1(_a, ["plugnplay"]); + const { plugnplay, ...rest } = options; const forwardedOptions = Object.keys(rest).length > 0 ? rest : void 0; try { enableNativeHooks = false; @@ -28492,7 +28721,10 @@ function applyPatch(pnpapi, opts) { optionNames.delete(`paths`); optionNames.delete(`plugnplay`); if (optionNames.size > 0) { - throw makeError(ErrorCode.UNSUPPORTED, `Some options passed to require() aren't supported by PnP yet (${Array.from(optionNames).join(`, `)})`); + throw makeError( + ErrorCode.UNSUPPORTED, + `Some options passed to require() aren't supported by PnP yet (${Array.from(optionNames).join(`, `)})` + ); } } const issuerSpecs = options && options.paths ? getIssuerSpecsFromPaths(options.paths) : getIssuerSpecsFromModule(parent); @@ -28511,7 +28743,7 @@ function applyPatch(pnpapi, opts) { } } let firstError; - for (const {apiPath, path, module} of issuerSpecs) { + for (const { apiPath, path, module } of issuerSpecs) { let resolution; const issuerApi = apiPath !== null ? opts.manager.getApiEntry(apiPath, true).instance : null; try { @@ -28592,7 +28824,12 @@ Require stack: const originalDlopen = process.dlopen; process.dlopen = function(...args) { const [module, filename, ...rest] = args; - return originalDlopen.call(this, module, npath.fromPortablePath(VirtualFS.resolveVirtual(npath.toPortablePath(filename))), ...rest); + return originalDlopen.call( + this, + module, + npath.fromPortablePath(VirtualFS.resolveVirtual(npath.toPortablePath(filename))), + ...rest + ); }; const originalEmit = process.emit; process.emit = function(name, data, ...args) { @@ -28603,21 +28840,21 @@ Require stack: patchFs(fs__default.default, new PosixFS(opts.fakeFs)); } -function hydrateRuntimeState(data, {basePath}) { +function hydrateRuntimeState(data, { basePath }) { const portablePath = npath.toPortablePath(basePath); const absolutePortablePath = ppath.resolve(portablePath); const ignorePattern = data.ignorePatternData !== null ? new RegExp(data.ignorePatternData) : null; - const packageLocatorsByLocations = new Map(); + const packageLocatorsByLocations = /* @__PURE__ */ new Map(); const packageRegistry = new Map(data.packageRegistryData.map(([packageName, packageStoreData]) => { return [packageName, new Map(packageStoreData.map(([packageReference, packageInformationData]) => { var _a; if (packageName === null !== (packageReference === null)) throw new Error(`Assertion failed: The name and reference should be null, or neither should`); const discardFromLookup = (_a = packageInformationData.discardFromLookup) != null ? _a : false; - const packageLocator = {name: packageName, reference: packageReference}; + const packageLocator = { name: packageName, reference: packageReference }; const entry = packageLocatorsByLocations.get(packageInformationData.packageLocation); if (!entry) { - packageLocatorsByLocations.set(packageInformationData.packageLocation, {locator: packageLocator, discardFromLookup}); + packageLocatorsByLocations.set(packageInformationData.packageLocation, { locator: packageLocator, discardFromLookup }); } else { entry.discardFromLookup = entry.discardFromLookup && discardFromLookup; if (!discardFromLookup) { @@ -28766,25 +29003,744 @@ function resolve(pkg, entry='.', options={}) { } } -var __defProp$1 = Object.defineProperty; -var __defProps = Object.defineProperties; -var __getOwnPropDescs = Object.getOwnPropertyDescriptors; -var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols; -var __hasOwnProp$1 = Object.prototype.hasOwnProperty; -var __propIsEnum$1 = Object.prototype.propertyIsEnumerable; -var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, {enumerable: true, configurable: true, writable: true, value}) : obj[key] = value; -var __spreadValues$1 = (a, b) => { - for (var prop in b || (b = {})) - if (__hasOwnProp$1.call(b, prop)) - __defNormalProp$1(a, prop, b[prop]); - if (__getOwnPropSymbols$1) - for (var prop of __getOwnPropSymbols$1(b)) { - if (__propIsEnum$1.call(b, prop)) - __defNormalProp$1(a, prop, b[prop]); +const ArrayIsArray = Array.isArray; +const JSONStringify = JSON.stringify; +const ObjectGetOwnPropertyNames = Object.getOwnPropertyNames; +const ObjectPrototypeHasOwnProperty = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop); +const RegExpPrototypeExec = (obj, string) => RegExp.prototype.exec.call(obj, string); +const RegExpPrototypeSymbolReplace = (obj, ...rest) => RegExp.prototype[Symbol.replace].apply(obj, rest); +const StringPrototypeEndsWith = (str, ...rest) => String.prototype.endsWith.apply(str, rest); +const StringPrototypeIncludes = (str, ...rest) => String.prototype.includes.apply(str, rest); +const StringPrototypeLastIndexOf = (str, ...rest) => String.prototype.lastIndexOf.apply(str, rest); +const StringPrototypeIndexOf = (str, ...rest) => String.prototype.indexOf.apply(str, rest); +const StringPrototypeReplace = (str, ...rest) => String.prototype.replace.apply(str, rest); +const StringPrototypeSlice = (str, ...rest) => String.prototype.slice.apply(str, rest); +const StringPrototypeStartsWith = (str, ...rest) => String.prototype.startsWith.apply(str, rest); +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 a; + }; +} +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 +); +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 +); +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__default.default(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 +); + +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]; + } + } + 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 ` : "") + url.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( + url.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 = url.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; +} + +/** + @license + Copyright Node.js contributors. All rights reserved. + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + IN THE SOFTWARE. +*/ +function throwImportNotDefined(specifier, packageJSONUrl, base) { + throw new ERR_PACKAGE_IMPORT_NOT_DEFINED( + specifier, + packageJSONUrl && url.fileURLToPath(new URL(".", packageJSONUrl)), + url.fileURLToPath(base) + ); +} +function throwInvalidSubpath(subpath, packageJSONUrl, internal, base) { + const reason = `request is not a valid subpath for the "${internal ? "imports" : "exports"}" resolution of ${url.fileURLToPath(packageJSONUrl)}`; + throw new ERR_INVALID_MODULE_SPECIFIER( + subpath, + reason, + base && url.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( + url.fileURLToPath(new URL(".", packageJSONUrl)), + subpath, + target, + internal, + base && url.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 (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( + url.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, url.fileURLToPath(base)); + } + let packageJSONUrl; + const packageConfig = getPackageScopeConfig(base, readFileSyncFn); + if (packageConfig.exists) { + packageJSONUrl = url.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); +} + +const flagSymbol = Symbol('arg flag'); + +class ArgError extends Error { + constructor(msg, code) { + super(msg); + this.name = 'ArgError'; + this.code = code; + + Object.setPrototypeOf(this, ArgError.prototype); + } +} + +function arg( + opts, + { + argv = process.argv.slice(2), + permissive = false, + stopAtPositional = false + } = {} +) { + if (!opts) { + throw new ArgError( + 'argument specification object is required', + 'ARG_CONFIG_NO_SPEC' + ); + } + + const result = { _: [] }; + + const aliases = {}; + const handlers = {}; + + for (const key of Object.keys(opts)) { + if (!key) { + throw new ArgError( + 'argument key cannot be an empty string', + 'ARG_CONFIG_EMPTY_KEY' + ); + } + + if (key[0] !== '-') { + throw new ArgError( + `argument key must start with '-' but found: '${key}'`, + 'ARG_CONFIG_NONOPT_KEY' + ); + } + + if (key.length === 1) { + throw new ArgError( + `argument key must have a name; singular '-' keys are not allowed: ${key}`, + 'ARG_CONFIG_NONAME_KEY' + ); + } + + if (typeof opts[key] === 'string') { + aliases[key] = opts[key]; + continue; + } + + let type = opts[key]; + let isFlag = false; + + if ( + Array.isArray(type) && + type.length === 1 && + typeof type[0] === 'function' + ) { + const [fn] = type; + type = (value, name, prev = []) => { + prev.push(fn(value, name, prev[prev.length - 1])); + return prev; + }; + isFlag = fn === Boolean || fn[flagSymbol] === true; + } else if (typeof type === 'function') { + isFlag = type === Boolean || type[flagSymbol] === true; + } else { + throw new ArgError( + `type missing or not a function or valid array type: ${key}`, + 'ARG_CONFIG_VAD_TYPE' + ); + } + + if (key[1] !== '-' && key.length > 2) { + throw new ArgError( + `short argument keys (with a single hyphen) must have only one character: ${key}`, + 'ARG_CONFIG_SHORTOPT_TOOLONG' + ); + } + + handlers[key] = [type, isFlag]; + } + + for (let i = 0, len = argv.length; i < len; i++) { + const wholeArg = argv[i]; + + if (stopAtPositional && result._.length > 0) { + result._ = result._.concat(argv.slice(i)); + break; + } + + if (wholeArg === '--') { + result._ = result._.concat(argv.slice(i + 1)); + break; + } + + if (wholeArg.length > 1 && wholeArg[0] === '-') { + /* eslint-disable operator-linebreak */ + const separatedArguments = + wholeArg[1] === '-' || wholeArg.length === 2 + ? [wholeArg] + : wholeArg + .slice(1) + .split('') + .map((a) => `-${a}`); + /* eslint-enable operator-linebreak */ + + for (let j = 0; j < separatedArguments.length; j++) { + const arg = separatedArguments[j]; + const [originalArgName, argStr] = + arg[1] === '-' ? arg.split(/=(.*)/, 2) : [arg, undefined]; + + let argName = originalArgName; + while (argName in aliases) { + argName = aliases[argName]; + } + + if (!(argName in handlers)) { + if (permissive) { + result._.push(arg); + continue; + } else { + throw new ArgError( + `unknown or unexpected option: ${originalArgName}`, + 'ARG_UNKNOWN_OPTION' + ); + } + } + + const [type, isFlag] = handlers[argName]; + + if (!isFlag && j + 1 < separatedArguments.length) { + throw new ArgError( + `option requires argument (but was followed by another short argument): ${originalArgName}`, + 'ARG_MISSING_REQUIRED_SHORTARG' + ); + } + + if (isFlag) { + result[argName] = type(true, argName, result[argName]); + } else if (argStr === undefined) { + if ( + argv.length < i + 2 || + (argv[i + 1].length > 1 && + argv[i + 1][0] === '-' && + !( + argv[i + 1].match(/^-?\d*(\.(?=\d))?\d*$/) && + (type === Number || + // eslint-disable-next-line no-undef + (typeof BigInt !== 'undefined' && type === BigInt)) + )) + ) { + const extended = + originalArgName === argName ? '' : ` (alias for ${argName})`; + throw new ArgError( + `option requires argument: ${originalArgName}${extended}`, + 'ARG_MISSING_REQUIRED_LONGARG' + ); + } + + result[argName] = type(argv[i + 1], argName, result[argName]); + ++i; + } else { + result[argName] = type(argStr, argName, result[argName]); + } + } + } else { + result._.push(wholeArg); + } + } + + return result; +} + +arg.flag = (fn) => { + fn[flagSymbol] = true; + return fn; }; -var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b)); + +// Utility types +arg.COUNT = arg.flag((v, name, existingCount) => (existingCount || 0) + 1); + +// Expose error class +arg.ArgError = ArgError; + +var arg_1 = arg; + +/** + @license + The MIT License (MIT) + + Copyright (c) 2014 Blake Embrey (hello@blakeembrey.com) + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +*/ +function getOptionValue(opt) { + parseOptions(); + return options[opt]; +} +let options; +function parseOptions() { + if (!options) { + options = { + "--conditions": [], + ...parseArgv(getNodeOptionsEnvArgv()), + ...parseArgv(process.execArgv) + }; + } +} +function parseArgv(argv) { + return arg_1( + { + "--conditions": [String], + "-C": "--conditions" + }, + { + argv, + permissive: true + } + ); +} +function getNodeOptionsEnvArgv() { + const errors = []; + const envArgv = ParseNodeOptionsEnvVar(process.env.NODE_OPTIONS || "", errors); + if (errors.length !== 0) ; + return envArgv; +} +function ParseNodeOptionsEnvVar(node_options, errors) { + const env_argv = []; + let is_in_string = false; + let will_start_new_arg = true; + for (let index = 0; index < node_options.length; ++index) { + let c = node_options[index]; + if (c === "\\" && is_in_string) { + if (index + 1 === node_options.length) { + errors.push("invalid value for NODE_OPTIONS (invalid escape)\n"); + return env_argv; + } else { + c = node_options[++index]; + } + } else if (c === " " && !is_in_string) { + will_start_new_arg = true; + continue; + } else if (c === '"') { + is_in_string = !is_in_string; + continue; + } + if (will_start_new_arg) { + env_argv.push(c); + will_start_new_arg = false; + } else { + env_argv[env_argv.length - 1] += c; + } + } + if (is_in_string) { + errors.push("invalid value for NODE_OPTIONS (unterminated string)\n"); + } + return env_argv; +} + function makeApi(runtimeState, opts) { const alwaysWarnOnFallback = Number(process.env.PNP_ALWAYS_WARN_ON_FALLBACK) > 0; const debugLevel = Number(process.env.PNP_DEBUG_LEVEL); @@ -28792,9 +29748,9 @@ function makeApi(runtimeState, opts) { const isStrictRegExp = /^(\/|\.{1,2}(\/|$))/; const isDirRegExp = /\/$/; const isRelativeRegexp = /^\.{0,2}\//; - const topLevelLocator = {name: null, reference: null}; + const topLevelLocator = { name: null, reference: null }; const fallbackLocators = []; - const emittedWarnings = new Set(); + const emittedWarnings = /* @__PURE__ */ new Set(); if (runtimeState.enableTopLevelFallback === true) fallbackLocators.push(topLevelLocator); if (opts.compatibilityMode !== false) { @@ -28805,7 +29761,7 @@ function makeApi(runtimeState, opts) { if (reference === null) { throw new Error(`Assertion failed: This reference shouldn't be null`); } else { - fallbackLocators.push({name, reference}); + fallbackLocators.push({ name, reference }); } } } @@ -28827,7 +29783,7 @@ function makeApi(runtimeState, opts) { function trace(entry) { var _a, _b, _c, _d, _e, _f; const colors = (_c = (_b = (_a = process.stderr) == null ? void 0 : _a.hasColors) == null ? void 0 : _b.call(_a)) != null ? _c : process.stdout.isTTY; - const c = (n, str) => `[${n}m${str}`; + const c = (n, str) => `\x1B[${n}m${str}\x1B[0m`; const error = entry.error; if (error) console.error(c(`31;1`, `\u2716 ${(_d = entry.error) == null ? void 0 : _d.message.replace(/\n.*/s, ``)}`)); @@ -28836,10 +29792,10 @@ function makeApi(runtimeState, opts) { if (entry.args.length > 0) console.error(); for (const arg of entry.args) - console.error(` ${c(`37;1`, `In \u2190`)} ${nodeUtils.inspect(arg, {colors, compact: true})}`); + console.error(` ${c(`37;1`, `In \u2190`)} ${nodeUtils.inspect(arg, { colors, compact: true })}`); if (entry.result) { console.error(); - console.error(` ${c(`37;1`, `Out \u2192`)} ${nodeUtils.inspect(entry.result, {colors, compact: true})}`); + console.error(` ${c(`37;1`, `Out \u2192`)} ${nodeUtils.inspect(entry.result, { colors, compact: true })}`); } const stack = (_f = (_e = new Error().stack.match(/(?<=^ +)at.*/gm)) == null ? void 0 : _e.slice(2)) != null ? _f : []; if (stack.length > 0) { @@ -28883,7 +29839,10 @@ function makeApi(runtimeState, opts) { function getPackageInformationSafe(packageLocator) { const packageInformation = getPackageInformation(packageLocator); if (!packageInformation) { - throw makeError(ErrorCode.INTERNAL, `Couldn't find a matching entry in the dependency tree for the specified parent (this is probably an internal error)`); + throw makeError( + ErrorCode.INTERNAL, + `Couldn't find a matching entry in the dependency tree for the specified parent (this is probably an internal error)` + ); } return packageInformation; } @@ -28895,23 +29854,34 @@ function makeApi(runtimeState, opts) { return true; return false; } - const defaultExportsConditions = new Set([`default`, `node`, `require`]); + const defaultExportsConditions = /* @__PURE__ */ new Set([ + `default`, + `node`, + `require`, + ...getOptionValue(`--conditions`) + ]); function applyNodeExportsResolution(unqualifiedPath, conditions = defaultExportsConditions) { const locator = findPackageLocator(ppath.join(unqualifiedPath, `internal.js`), { resolveIgnored: true, includeDiscardFromLookup: true }); if (locator === null) { - throw makeError(ErrorCode.INTERNAL, `The locator that owns the "${unqualifiedPath}" path can't be found inside the dependency tree (this is probably an internal error)`); + throw makeError( + ErrorCode.INTERNAL, + `The locator that owns the "${unqualifiedPath}" path can't be found inside the dependency tree (this is probably an internal error)` + ); } - const {packageLocation} = getPackageInformationSafe(locator); + const { packageLocation } = getPackageInformationSafe(locator); const manifestPath = ppath.join(packageLocation, Filename.manifest); if (!opts.fakeFs.existsSync(manifestPath)) return null; const pkgJson = JSON.parse(opts.fakeFs.readFileSync(manifestPath, `utf8`)); let subpath = ppath.contains(packageLocation, unqualifiedPath); if (subpath === null) { - throw makeError(ErrorCode.INTERNAL, `unqualifiedPath doesn't contain the packageLocation (this is probably an internal error)`); + throw makeError( + ErrorCode.INTERNAL, + `unqualifiedPath doesn't contain the packageLocation (this is probably an internal error)` + ); } if (!isRelativeRegexp.test(subpath)) subpath = `./${subpath}`; @@ -28922,13 +29892,18 @@ function makeApi(runtimeState, opts) { unsafe: true }); } catch (error) { - throw makeError(ErrorCode.EXPORTS_RESOLUTION_FAILED, error.message, {unqualifiedPath: getPathForDisplay(unqualifiedPath), locator, pkgJson, subpath: getPathForDisplay(subpath), conditions}, `ERR_PACKAGE_PATH_NOT_EXPORTED`); + throw makeError( + ErrorCode.EXPORTS_RESOLUTION_FAILED, + error.message, + { unqualifiedPath: getPathForDisplay(unqualifiedPath), locator, pkgJson, subpath: getPathForDisplay(subpath), conditions }, + `ERR_PACKAGE_PATH_NOT_EXPORTED` + ); } if (typeof resolvedExport === `string`) return ppath.join(packageLocation, resolvedExport); return null; } - function applyNodeExtensionResolution(unqualifiedPath, candidates, {extensions}) { + function applyNodeExtensionResolution(unqualifiedPath, candidates, { extensions }) { let stat; try { candidates.push(unqualifiedPath); @@ -28947,7 +29922,7 @@ function makeApi(runtimeState, opts) { if (pkgJson && pkgJson.main) nextUnqualifiedPath = ppath.resolve(unqualifiedPath, pkgJson.main); if (nextUnqualifiedPath && nextUnqualifiedPath !== unqualifiedPath) { - const resolution = applyNodeExtensionResolution(nextUnqualifiedPath, candidates, {extensions}); + const resolution = applyNodeExtensionResolution(nextUnqualifiedPath, candidates, { extensions }); if (resolution !== null) { return resolution; } @@ -28962,7 +29937,7 @@ function makeApi(runtimeState, opts) { } if (stat && stat.isDirectory()) { for (let i = 0, length = extensions.length; i < length; i++) { - const candidateFile = ppath.format({dir: unqualifiedPath, name: `index`, ext: extensions[i]}); + const candidateFile = ppath.format({ dir: unqualifiedPath, name: `index`, ext: extensions[i] }); candidates.push(candidateFile); if (opts.fakeFs.existsSync(candidateFile)) { return candidateFile; @@ -28980,7 +29955,7 @@ function makeApi(runtimeState, opts) { function callNativeResolution(request, issuer) { if (issuer.endsWith(`/`)) issuer = ppath.join(issuer, `internal.js`); - return require$$0.Module._resolveFilename(npath.fromPortablePath(request), makeFakeModule(npath.fromPortablePath(issuer)), false, {plugnplay: false}); + return require$$0.Module._resolveFilename(npath.fromPortablePath(request), makeFakeModule(npath.fromPortablePath(issuer)), false, { plugnplay: false }); } function isPathIgnored(path) { if (ignorePattern === null) @@ -28994,9 +29969,9 @@ function makeApi(runtimeState, opts) { return false; } } - const VERSIONS = {std: 3, resolveVirtual: 1, getAllLocators: 1}; + const VERSIONS = { std: 3, resolveVirtual: 1, getAllLocators: 1 }; const topLevel = topLevelLocator; - function getPackageInformation({name, reference}) { + function getPackageInformation({ name, reference }) { const packageInformationStore = packageRegistry.get(name); if (!packageInformationStore) return null; @@ -29005,7 +29980,7 @@ function makeApi(runtimeState, opts) { return null; return packageInformation; } - function findPackageDependents({name, reference}) { + function findPackageDependents({ name, reference }) { const dependents = []; for (const [dependentName, packageInformationStore] of packageRegistry) { if (dependentName === null) @@ -29027,8 +30002,8 @@ function makeApi(runtimeState, opts) { return dependents; } function findBrokenPeerDependencies(dependency, initialPackage) { - const brokenPackages = new Map(); - const alreadyVisited = new Set(); + const brokenPackages = /* @__PURE__ */ new Map(); + const alreadyVisited = /* @__PURE__ */ new Set(); const traversal = (currentPackage) => { const identifier = JSON.stringify(currentPackage.name); if (alreadyVisited.has(identifier)) @@ -29042,7 +30017,7 @@ function makeApi(runtimeState, opts) { } else { let brokenSet = brokenPackages.get(dependent.name); if (typeof brokenSet === `undefined`) - brokenPackages.set(dependent.name, brokenSet = new Set()); + brokenPackages.set(dependent.name, brokenSet = /* @__PURE__ */ new Set()); brokenSet.add(dependent.reference); } } @@ -29051,10 +30026,10 @@ function makeApi(runtimeState, opts) { const brokenList = []; for (const name of [...brokenPackages.keys()].sort()) for (const reference of [...brokenPackages.get(name)].sort()) - brokenList.push({name, reference}); + brokenList.push({ name, reference }); return brokenList; } - function findPackageLocator(location, {resolveIgnored = false, includeDiscardFromLookup = false} = {}) { + function findPackageLocator(location, { resolveIgnored = false, includeDiscardFromLookup = false } = {}) { if (isPathIgnored(location) && !resolveIgnored) return null; let relativeLocation = ppath.relative(runtimeState.basePath, location); @@ -29072,7 +30047,18 @@ function makeApi(runtimeState, opts) { } while (relativeLocation !== ``); return null; } - function resolveToUnqualified(request, issuer, {considerBuiltins = true} = {}) { + function tryReadFile(filePath) { + try { + return opts.fakeFs.readFileSync(npath.toPortablePath(filePath), `utf8`); + } catch (err) { + if (err.code === `ENOENT`) + return void 0; + throw err; + } + } + function resolveToUnqualified(request, issuer, { considerBuiltins = true } = {}) { + if (request.startsWith(`#`)) + throw new Error(`resolveToUnqualified can not handle private import mappings`); if (request === `pnpapi`) return npath.toPortablePath(opts.pnpapiResolution); if (considerBuiltins && isBuiltinModule(request)) @@ -29083,11 +30069,15 @@ function makeApi(runtimeState, opts) { if (!ppath.isAbsolute(request) || findPackageLocator(request) === null) { const result = callNativeResolution(request, issuer); if (result === false) { - throw makeError(ErrorCode.BUILTIN_NODE_RESOLUTION_FAILED, `The builtin node resolution algorithm was unable to resolve the requested module (it didn't go through the pnp resolver because the issuer was explicitely ignored by the regexp) + throw makeError( + ErrorCode.BUILTIN_NODE_RESOLUTION_FAILED, + `The builtin node resolution algorithm was unable to resolve the requested module (it didn't go through the pnp resolver because the issuer was explicitely ignored by the regexp) Require request: "${requestForDisplay}" Required by: ${issuerForDisplay} -`, {request: requestForDisplay, issuer: issuerForDisplay}); +`, + { request: requestForDisplay, issuer: issuerForDisplay } + ); } return npath.toPortablePath(result); } @@ -29099,7 +30089,11 @@ Required by: ${issuerForDisplay} unqualifiedPath = ppath.normalize(request); } else { if (!issuer) { - throw makeError(ErrorCode.API_ERROR, `The resolveToUnqualified function must be called with a valid issuer when the path isn't a builtin nor absolute`, {request: requestForDisplay, issuer: issuerForDisplay}); + throw makeError( + ErrorCode.API_ERROR, + `The resolveToUnqualified function must be called with a valid issuer when the path isn't a builtin nor absolute`, + { request: requestForDisplay, issuer: issuerForDisplay } + ); } const absoluteIssuer = ppath.resolve(issuer); if (issuer.match(isDirRegExp)) { @@ -29110,18 +30104,26 @@ Required by: ${issuerForDisplay} } } else { if (!issuer) { - throw makeError(ErrorCode.API_ERROR, `The resolveToUnqualified function must be called with a valid issuer when the path isn't a builtin nor absolute`, {request: requestForDisplay, issuer: issuerForDisplay}); + throw makeError( + ErrorCode.API_ERROR, + `The resolveToUnqualified function must be called with a valid issuer when the path isn't a builtin nor absolute`, + { request: requestForDisplay, issuer: issuerForDisplay } + ); } const [, dependencyName, subPath] = dependencyNameMatch; const issuerLocator = findPackageLocator(issuer); if (!issuerLocator) { const result = callNativeResolution(request, issuer); if (result === false) { - throw makeError(ErrorCode.BUILTIN_NODE_RESOLUTION_FAILED, `The builtin node resolution algorithm was unable to resolve the requested module (it didn't go through the pnp resolver because the issuer doesn't seem to be part of the Yarn-managed dependency tree). + throw makeError( + ErrorCode.BUILTIN_NODE_RESOLUTION_FAILED, + `The builtin node resolution algorithm was unable to resolve the requested module (it didn't go through the pnp resolver because the issuer doesn't seem to be part of the Yarn-managed dependency tree). Require path: "${requestForDisplay}" Required by: ${issuerForDisplay} -`, {request: requestForDisplay, issuer: issuerForDisplay}); +`, + { request: requestForDisplay, issuer: issuerForDisplay } + ); } return npath.toPortablePath(result); } @@ -29158,60 +30160,88 @@ Required by: ${issuerForDisplay} let error = null; if (dependencyReference === null) { if (isDependencyTreeRoot(issuerLocator)) { - error = makeError(ErrorCode.MISSING_PEER_DEPENDENCY, `Your application tried to access ${dependencyName} (a peer dependency); this isn't allowed as there is no ancestor to satisfy the requirement. Use a devDependency if needed. + error = makeError( + ErrorCode.MISSING_PEER_DEPENDENCY, + `Your application tried to access ${dependencyName} (a peer dependency); this isn't allowed as there is no ancestor to satisfy the requirement. Use a devDependency if needed. Required package: ${dependencyName}${dependencyName !== requestForDisplay ? ` (via "${requestForDisplay}")` : ``} Required by: ${issuerForDisplay} -`, {request: requestForDisplay, issuer: issuerForDisplay, dependencyName}); +`, + { request: requestForDisplay, issuer: issuerForDisplay, dependencyName } + ); } else { const brokenAncestors = findBrokenPeerDependencies(dependencyName, issuerLocator); if (brokenAncestors.every((ancestor) => isDependencyTreeRoot(ancestor))) { - error = makeError(ErrorCode.MISSING_PEER_DEPENDENCY, `${issuerLocator.name} tried to access ${dependencyName} (a peer dependency) but it isn't provided by your application; this makes the require call ambiguous and unsound. + error = makeError( + ErrorCode.MISSING_PEER_DEPENDENCY, + `${issuerLocator.name} tried to access ${dependencyName} (a peer dependency) but it isn't provided by your application; this makes the require call ambiguous and unsound. Required package: ${dependencyName}${dependencyName !== requestForDisplay ? ` (via "${requestForDisplay}")` : ``} Required by: ${issuerLocator.name}@${issuerLocator.reference} (via ${issuerForDisplay}) ${brokenAncestors.map((ancestorLocator) => `Ancestor breaking the chain: ${ancestorLocator.name}@${ancestorLocator.reference} `).join(``)} -`, {request: requestForDisplay, issuer: issuerForDisplay, issuerLocator: Object.assign({}, issuerLocator), dependencyName, brokenAncestors}); +`, + { request: requestForDisplay, issuer: issuerForDisplay, issuerLocator: Object.assign({}, issuerLocator), dependencyName, brokenAncestors } + ); } else { - error = makeError(ErrorCode.MISSING_PEER_DEPENDENCY, `${issuerLocator.name} tried to access ${dependencyName} (a peer dependency) but it isn't provided by its ancestors; this makes the require call ambiguous and unsound. + error = makeError( + ErrorCode.MISSING_PEER_DEPENDENCY, + `${issuerLocator.name} tried to access ${dependencyName} (a peer dependency) but it isn't provided by its ancestors; this makes the require call ambiguous and unsound. Required package: ${dependencyName}${dependencyName !== requestForDisplay ? ` (via "${requestForDisplay}")` : ``} Required by: ${issuerLocator.name}@${issuerLocator.reference} (via ${issuerForDisplay}) ${brokenAncestors.map((ancestorLocator) => `Ancestor breaking the chain: ${ancestorLocator.name}@${ancestorLocator.reference} `).join(``)} -`, {request: requestForDisplay, issuer: issuerForDisplay, issuerLocator: Object.assign({}, issuerLocator), dependencyName, brokenAncestors}); +`, + { request: requestForDisplay, issuer: issuerForDisplay, issuerLocator: Object.assign({}, issuerLocator), dependencyName, brokenAncestors } + ); } } } else if (dependencyReference === void 0) { if (!considerBuiltins && isBuiltinModule(request)) { if (isDependencyTreeRoot(issuerLocator)) { - error = makeError(ErrorCode.UNDECLARED_DEPENDENCY, `Your application tried to access ${dependencyName}. While this module is usually interpreted as a Node builtin, your resolver is running inside a non-Node resolution context where such builtins are ignored. Since ${dependencyName} isn't otherwise declared in your dependencies, this makes the require call ambiguous and unsound. + error = makeError( + ErrorCode.UNDECLARED_DEPENDENCY, + `Your application tried to access ${dependencyName}. While this module is usually interpreted as a Node builtin, your resolver is running inside a non-Node resolution context where such builtins are ignored. Since ${dependencyName} isn't otherwise declared in your dependencies, this makes the require call ambiguous and unsound. Required package: ${dependencyName}${dependencyName !== requestForDisplay ? ` (via "${requestForDisplay}")` : ``} Required by: ${issuerForDisplay} -`, {request: requestForDisplay, issuer: issuerForDisplay, dependencyName}); +`, + { request: requestForDisplay, issuer: issuerForDisplay, dependencyName } + ); } else { - error = makeError(ErrorCode.UNDECLARED_DEPENDENCY, `${issuerLocator.name} tried to access ${dependencyName}. While this module is usually interpreted as a Node builtin, your resolver is running inside a non-Node resolution context where such builtins are ignored. Since ${dependencyName} isn't otherwise declared in ${issuerLocator.name}'s dependencies, this makes the require call ambiguous and unsound. + error = makeError( + ErrorCode.UNDECLARED_DEPENDENCY, + `${issuerLocator.name} tried to access ${dependencyName}. While this module is usually interpreted as a Node builtin, your resolver is running inside a non-Node resolution context where such builtins are ignored. Since ${dependencyName} isn't otherwise declared in ${issuerLocator.name}'s dependencies, this makes the require call ambiguous and unsound. Required package: ${dependencyName}${dependencyName !== requestForDisplay ? ` (via "${requestForDisplay}")` : ``} Required by: ${issuerForDisplay} -`, {request: requestForDisplay, issuer: issuerForDisplay, issuerLocator: Object.assign({}, issuerLocator), dependencyName}); +`, + { request: requestForDisplay, issuer: issuerForDisplay, issuerLocator: Object.assign({}, issuerLocator), dependencyName } + ); } } else { if (isDependencyTreeRoot(issuerLocator)) { - error = makeError(ErrorCode.UNDECLARED_DEPENDENCY, `Your application tried to access ${dependencyName}, but it isn't declared in your dependencies; this makes the require call ambiguous and unsound. + error = makeError( + ErrorCode.UNDECLARED_DEPENDENCY, + `Your application tried to access ${dependencyName}, but it isn't declared in your dependencies; this makes the require call ambiguous and unsound. Required package: ${dependencyName}${dependencyName !== requestForDisplay ? ` (via "${requestForDisplay}")` : ``} Required by: ${issuerForDisplay} -`, {request: requestForDisplay, issuer: issuerForDisplay, dependencyName}); +`, + { request: requestForDisplay, issuer: issuerForDisplay, dependencyName } + ); } else { - error = makeError(ErrorCode.UNDECLARED_DEPENDENCY, `${issuerLocator.name} tried to access ${dependencyName}, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound. + error = makeError( + ErrorCode.UNDECLARED_DEPENDENCY, + `${issuerLocator.name} tried to access ${dependencyName}, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound. Required package: ${dependencyName}${dependencyName !== requestForDisplay ? ` (via "${requestForDisplay}")` : ``} Required by: ${issuerLocator.name}@${issuerLocator.reference} (via ${issuerForDisplay}) -`, {request: requestForDisplay, issuer: issuerForDisplay, issuerLocator: Object.assign({}, issuerLocator), dependencyName}); +`, + { request: requestForDisplay, issuer: issuerForDisplay, issuerLocator: Object.assign({}, issuerLocator), dependencyName } + ); } } } @@ -29226,14 +30256,18 @@ Required by: ${issuerLocator.name}@${issuerLocator.reference} (via ${issuerForDi process.emitWarning(error); } } - const dependencyLocator = Array.isArray(dependencyReference) ? {name: dependencyReference[0], reference: dependencyReference[1]} : {name: dependencyName, reference: dependencyReference}; + const dependencyLocator = Array.isArray(dependencyReference) ? { name: dependencyReference[0], reference: dependencyReference[1] } : { name: dependencyName, reference: dependencyReference }; const dependencyInformation = getPackageInformationSafe(dependencyLocator); if (!dependencyInformation.packageLocation) { - throw makeError(ErrorCode.MISSING_DEPENDENCY, `A dependency seems valid but didn't get installed for some reason. This might be caused by a partial install, such as dev vs prod. + throw makeError( + ErrorCode.MISSING_DEPENDENCY, + `A dependency seems valid but didn't get installed for some reason. This might be caused by a partial install, such as dev vs prod. Required package: ${dependencyLocator.name}@${dependencyLocator.reference}${dependencyLocator.name !== requestForDisplay ? ` (via "${requestForDisplay}")` : ``} Required by: ${issuerLocator.name}@${issuerLocator.reference} (via ${issuerForDisplay}) -`, {request: requestForDisplay, issuer: issuerForDisplay, dependencyLocator: Object.assign({}, dependencyLocator)}); +`, + { request: requestForDisplay, issuer: issuerForDisplay, dependencyLocator: Object.assign({}, dependencyLocator) } + ); } const dependencyLocation = dependencyInformation.packageLocation; if (subPath) { @@ -29254,17 +30288,18 @@ Required by: ${issuerLocator.name}@${issuerLocator.reference} (via ${issuerForDi return unqualifiedPath; } } - function resolveUnqualified(unqualifiedPath, {extensions = Object.keys(require$$0.Module._extensions)} = {}) { + function resolveUnqualified(unqualifiedPath, { extensions = Object.keys(require$$0.Module._extensions) } = {}) { var _a, _b; const candidates = []; - const qualifiedPath = applyNodeExtensionResolution(unqualifiedPath, candidates, {extensions}); + const qualifiedPath = applyNodeExtensionResolution(unqualifiedPath, candidates, { extensions }); if (qualifiedPath) { return ppath.normalize(qualifiedPath); } else { + reportRequiredFilesToWatchMode(candidates.map((candidate) => npath.fromPortablePath(candidate))); const unqualifiedPathForDisplay = getPathForDisplay(unqualifiedPath); const containingPackage = findPackageLocator(unqualifiedPath); if (containingPackage) { - const {packageLocation} = getPackageInformationSafe(containingPackage); + const { packageLocation } = getPackageInformationSafe(containingPackage); let exists = true; try { opts.fakeFs.accessSync(packageLocation); @@ -29277,38 +30312,67 @@ Required by: ${issuerLocator.name}@${issuerLocator.reference} (via ${issuerForDi Missing package: ${containingPackage.name}@${containingPackage.reference} Expected package location: ${getPathForDisplay(packageLocation)} -`, {unqualifiedPath: unqualifiedPathForDisplay, extensions}); +`, { unqualifiedPath: unqualifiedPathForDisplay, extensions }); } } if (!exists) { const errorMessage = packageLocation.includes(`/unplugged/`) ? `Required unplugged package missing from disk. This may happen when switching branches without running installs (unplugged packages must be fully materialized on disk to work).` : `Required package missing from disk. If you keep your packages inside your repository then restarting the Node process may be enough. Otherwise, try to run an install first.`; - throw makeError(ErrorCode.QUALIFIED_PATH_RESOLUTION_FAILED, `${errorMessage} + throw makeError( + ErrorCode.QUALIFIED_PATH_RESOLUTION_FAILED, + `${errorMessage} Missing package: ${containingPackage.name}@${containingPackage.reference} Expected package location: ${getPathForDisplay(packageLocation)} -`, {unqualifiedPath: unqualifiedPathForDisplay, extensions}); +`, + { unqualifiedPath: unqualifiedPathForDisplay, extensions } + ); } } - throw makeError(ErrorCode.QUALIFIED_PATH_RESOLUTION_FAILED, `Qualified path resolution failed: we looked for the following paths, but none could be accessed. + throw makeError( + ErrorCode.QUALIFIED_PATH_RESOLUTION_FAILED, + `Qualified path resolution failed: we looked for the following paths, but none could be accessed. Source path: ${unqualifiedPathForDisplay} ${candidates.map((candidate) => `Not found: ${getPathForDisplay(candidate)} -`).join(``)}`, {unqualifiedPath: unqualifiedPathForDisplay, extensions}); +`).join(``)}`, + { unqualifiedPath: unqualifiedPathForDisplay, extensions } + ); } } - function resolveRequest(request, issuer, {considerBuiltins, extensions, conditions} = {}) { + function resolvePrivateRequest(request, issuer, opts2) { + var _a; + if (!issuer) + throw new Error(`Assertion failed: An issuer is required to resolve private import mappings`); + const resolved = packageImportsResolve({ + name: request, + base: url.pathToFileURL(npath.fromPortablePath(issuer)), + conditions: (_a = opts2.conditions) != null ? _a : defaultExportsConditions, + readFileSyncFn: tryReadFile + }); + if (resolved instanceof URL) { + return resolveUnqualified(npath.toPortablePath(url.fileURLToPath(resolved)), { extensions: opts2.extensions }); + } else { + if (resolved.startsWith(`#`)) + throw new Error(`Mapping from one private import to another isn't allowed`); + return resolveRequest(resolved, issuer, opts2); + } + } + function resolveRequest(request, issuer, opts2 = {}) { try { - const unqualifiedPath = resolveToUnqualified(request, issuer, {considerBuiltins}); + if (request.startsWith(`#`)) + return resolvePrivateRequest(request, issuer, opts2); + const { considerBuiltins, extensions, conditions } = opts2; + const unqualifiedPath = resolveToUnqualified(request, issuer, { considerBuiltins }); if (request === `pnpapi`) return unqualifiedPath; if (unqualifiedPath === null) return null; const isIssuerIgnored = () => issuer !== null ? isPathIgnored(issuer) : false; const remappedPath = (!considerBuiltins || !isBuiltinModule(request)) && !isIssuerIgnored() ? resolveUnqualifiedExport(request, unqualifiedPath, conditions) : unqualifiedPath; - return resolveUnqualified(remappedPath, {extensions}); + return resolveUnqualified(remappedPath, { extensions }); } catch (error) { if (Object.prototype.hasOwnProperty.call(error, `pnpCode`)) - Object.assign(error.data, {request: getPathForDisplay(request), issuer: issuer && getPathForDisplay(issuer)}); + Object.assign(error.data, { request: getPathForDisplay(request), issuer: issuer && getPathForDisplay(issuer) }); throw error; } } @@ -29322,9 +30386,9 @@ ${candidates.map((candidate) => `Not found: ${getPathForDisplay(candidate)} topLevel, getLocator: (name, referencish) => { if (Array.isArray(referencish)) { - return {name: referencish[0], reference: referencish[1]}; + return { name: referencish[0], reference: referencish[1] }; } else { - return {name, reference: referencish}; + return { name, reference: referencish }; } }, getDependencyTreeRoots: () => { @@ -29335,7 +30399,7 @@ ${candidates.map((candidate) => `Not found: ${getPathForDisplay(candidate)} for (const [name, entry] of packageRegistry) for (const reference of entry.keys()) if (name !== null && reference !== null) - locators.push({name, reference}); + locators.push({ name, reference }); return locators; }, getPackageInformation: (locator) => { @@ -29343,7 +30407,7 @@ ${candidates.map((candidate) => `Not found: ${getPathForDisplay(candidate)} if (info === null) return null; const packageLocation = npath.fromPortablePath(info.packageLocation); - const nativeInfo = __spreadProps(__spreadValues$1({}, info), {packageLocation}); + const nativeInfo = { ...info, packageLocation }; return nativeInfo; }, findPackageLocator: (path) => { @@ -29380,7 +30444,7 @@ ${candidates.map((candidate) => `Not found: ${getPathForDisplay(candidate)} function makeManager(pnpapi, opts) { const initialApiPath = npath.toPortablePath(pnpapi.resolveToUnqualified(`pnpapi`, null)); const initialApiStats = opts.fakeFs.statSync(npath.toPortablePath(initialApiPath)); - const apiMetadata = new Map([ + const apiMetadata = /* @__PURE__ */ new Map([ [initialApiPath, { cache: require$$0.Module._cache, instance: pnpapi, @@ -29422,7 +30486,7 @@ function makeManager(pnpapi, opts) { } return apiEntry; } - const findApiPathCache = new Map(); + const findApiPathCache = /* @__PURE__ */ new Map(); function addToCacheAndReturn(start, end, target) { if (target !== null) target = VirtualFS.resolveVirtual(target); @@ -29447,11 +30511,11 @@ function makeManager(pnpapi, opts) { if (!packageInformation) throw new Error(`Assertion failed: Couldn't get package information for '${modulePath}'`); if (!bestCandidate) - bestCandidate = {packageLocation: packageInformation.packageLocation, apiPaths: []}; + bestCandidate = { packageLocation: packageInformation.packageLocation, apiPaths: [] }; if (packageInformation.packageLocation === bestCandidate.packageLocation) { bestCandidate.apiPaths.push(apiPath); } else if (packageInformation.packageLocation.length > bestCandidate.packageLocation.length) { - bestCandidate = {packageLocation: packageInformation.packageLocation, apiPaths: [apiPath]}; + bestCandidate = { packageLocation: packageInformation.packageLocation, apiPaths: [apiPath] }; } } if (bestCandidate) { @@ -29505,35 +30569,7 @@ ${controlSegment} }; } -var __defProp = Object.defineProperty; -var __getOwnPropSymbols = Object.getOwnPropertySymbols; -var __hasOwnProp = Object.prototype.hasOwnProperty; -var __propIsEnum = Object.prototype.propertyIsEnumerable; -var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {enumerable: true, configurable: true, writable: true, value}) : obj[key] = value; -var __spreadValues = (a, b) => { - for (var prop in b || (b = {})) - if (__hasOwnProp.call(b, prop)) - __defNormalProp(a, prop, b[prop]); - if (__getOwnPropSymbols) - for (var prop of __getOwnPropSymbols(b)) { - if (__propIsEnum.call(b, prop)) - __defNormalProp(a, prop, b[prop]); - } - return a; -}; -var __objRest = (source, exclude) => { - var target = {}; - for (var prop in source) - if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0) - target[prop] = source[prop]; - if (source != null && __getOwnPropSymbols) - for (var prop of __getOwnPropSymbols(source)) { - if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop)) - target[prop] = source[prop]; - } - return target; -}; -const localFs = __spreadValues({}, fs__default.default); +const localFs = { ...fs__default.default }; const nodeFs = new NodeFS(localFs); const defaultRuntimeState = $$SETUP_STATE(hydrateRuntimeState); const defaultPnpapiResolution = __filename; @@ -29563,21 +30599,18 @@ const defaultApi = Object.assign(makeApi(defaultRuntimeState, { fakeFs: dynamicFsLayer, pnpapiResolution: defaultPnpapiResolution }), { - makeApi: (_a) => { - var _b = _a, { - basePath = void 0, - fakeFs = dynamicFsLayer, - pnpapiResolution = defaultPnpapiResolution - } = _b, rest = __objRest(_b, [ - "basePath", - "fakeFs", - "pnpapiResolution" - ]); + makeApi: ({ + basePath = void 0, + fakeFs = dynamicFsLayer, + pnpapiResolution = defaultPnpapiResolution, + ...rest + }) => { const apiRuntimeState = typeof basePath !== `undefined` ? $$SETUP_STATE(hydrateRuntimeState, basePath) : defaultRuntimeState; - return makeApi(apiRuntimeState, __spreadValues({ + return makeApi(apiRuntimeState, { fakeFs, - pnpapiResolution - }, rest)); + pnpapiResolution, + ...rest + }); }, setup: (api) => { applyPatch(api || defaultApi, { @@ -29598,7 +30631,7 @@ if (module.parent && module.parent.id === `internal/preload`) { } if (process.mainModule === module) { const reportError = (code, message, data) => { - process.stdout.write(`${JSON.stringify([{code, message, data}, null])} + process.stdout.write(`${JSON.stringify([{ code, message, data }, null])} `); }; const reportSuccess = (resolution) => { diff --git a/package.json b/package.json index 0f8f59e..8ecf20c 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ "@types/react-dom": "^18.0.11", "@types/testing-library__jest-dom": "^5.14.5", "@types/three": "^0.149.0", + "buffer": "^6.0.3", "github-injection": "^1.1.0", "react": "^18.2.0", "react-dom": "^18.2.0", diff --git a/src/chrome/diff.test.ts b/src/chrome/diff.test.ts index 7ec4f89..234b78e 100644 --- a/src/chrome/diff.test.ts +++ b/src/chrome/diff.test.ts @@ -4,8 +4,8 @@ import { downloadFile, isFilenameSupported } from './diff' it('checks if the filename has a supported extension', () => { expect(isFilenameSupported('noextension')).toBe(false) expect(isFilenameSupported('unsupported.txt')).toBe(false) - expect(isFilenameSupported('unsupported.stl')).toBe(false) expect(isFilenameSupported('supported.obj')).toBe(true) + expect(isFilenameSupported('supported.stl')).toBe(true) expect(isFilenameSupported('supported.stp')).toBe(true) expect(isFilenameSupported('supported.step')).toBe(true) }) diff --git a/src/chrome/diff.ts b/src/chrome/diff.ts index c2ea704..3793477 100644 --- a/src/chrome/diff.ts +++ b/src/chrome/diff.ts @@ -5,21 +5,22 @@ import { FileExportFormat_type, FileImportFormat_type, } from '@kittycad/lib/dist/types/src/models' +import { Buffer } from 'buffer' export const extensionToSrcFormat: { [extension: string]: FileImportFormat_type } = { - 'dae': 'dae', - 'dxf': 'dxf', - 'fbx': 'fbx', - 'obj': 'obj', - 'stp': 'step', - 'step': 'step', - 'svg': 'svg', - // stl disabled for now as there's some GitHub support for them already, see #40 + dae: 'dae', + dxf: 'dxf', + fbx: 'fbx', + obj: 'obj', + stl: 'stl', + stp: 'step', + step: 'step', + svg: 'svg', } -export function isFilenameSupported(filename: string): boolean{ +export function isFilenameSupported(filename: string): boolean { const extension = filename.split('.').pop() return !!(extension && extensionToSrcFormat[extension]) } @@ -56,9 +57,14 @@ async function convert( client: Client, body: string, extension: string, - outputFormat = 'stl' + outputFormat = 'obj' ) { - // TODO: think about the best output format for visual diff injection, now defaults to STL + if (extension === outputFormat) { + console.log( + 'Skipping conversion, as extension is equal to outputFormat' + ) + return Buffer.from(body).toString('base64') + } const response = await file.create_file_conversion({ client, body, @@ -86,7 +92,9 @@ export async function getFileDiff( const extension = filename.split('.').pop() if (!extension || !extensionToSrcFormat[extension]) { throw Error( - `Unsupported extension. Given ${extension}, was expecting ${Object.keys(extensionToSrcFormat)}` + `Unsupported extension. Given ${extension}, was expecting ${Object.keys( + extensionToSrcFormat + )}` ) } diff --git a/src/components/diff/CadDiff.tsx b/src/components/diff/CadDiff.tsx index 3e9058a..9deb4f6 100644 --- a/src/components/diff/CadDiff.tsx +++ b/src/components/diff/CadDiff.tsx @@ -1,27 +1,31 @@ import React, { useEffect, useState } from 'react' import '@react-three/fiber' -import { Box, useTheme } from '@primer/react' +import { Box, useTheme, Text } from '@primer/react' import { FileDiff } from '../../chrome/types' import { Viewer3D } from './Viewer3D' -import { STLLoader } from 'three/examples/jsm/loaders/STLLoader' -import { BufferGeometry } from 'three' +import { OBJLoader } from 'three/examples/jsm/loaders/OBJLoader' +import { BufferGeometry, Mesh } from 'three' import { WireframeColors } from './WireframeModel' +import { Buffer } from 'buffer' -type ViewerSTLProps = { - file: string - colors: WireframeColors -} - -function ViewerSTL({ file, colors }: ViewerSTLProps) { - const [geomety, setGeometry] = useState() +function Loader3D({ file, colors }: { file: string; colors: WireframeColors }) { + const [geometry, setGeometry] = useState() useEffect(() => { - const loader = new STLLoader() - const buffer = window.atob(file) - const geometry = loader.parse(buffer) - console.log(`Model ${geometry.id} loaded`) + const loader = new OBJLoader() + const buffer = Buffer.from(file, 'base64').toString() + const group = loader.parse(buffer) + console.log(`Model ${group.id} loaded`) + console.log(group) + const geometry = (group.children[0] as Mesh)?.geometry setGeometry(geometry) }, [file]) - return geomety ? : null + return geometry ? ( + + ) : ( + + Sorry, the rich diff can't be displayed for this file. + + ) } export function CadDiff({ before, after }: FileDiff): React.ReactElement { @@ -38,19 +42,23 @@ export function CadDiff({ before, after }: FileDiff): React.ReactElement { } return ( - - {before && } - - - {after && } - + {before && ( + + + + )} + {after && ( + + + + )} ) } diff --git a/src/components/diff/CadDiffPage.tsx b/src/components/diff/CadDiffPage.tsx index 2ba2540..852f4ec 100644 --- a/src/components/diff/CadDiffPage.tsx +++ b/src/components/diff/CadDiffPage.tsx @@ -32,6 +32,14 @@ function CadDiffPortal({ const toolbar = element.querySelector('.file-info') if (toolbar != null) { setToolbarContainer(toolbar) + + // STL files might have a toggle already + const existingToggle = element.querySelector( + '.js-prose-diff-toggle-form' + ) + if (existingToggle) { + existingToggle.style.display = 'none' + } } const diff = element.querySelector('.js-file-content') diff --git a/yarn.lock b/yarn.lock index 3d9816c..4406f21 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4814,6 +4814,13 @@ __metadata: languageName: node linkType: hard +"base64-js@npm:^1.3.1": + version: 1.5.1 + resolution: "base64-js@npm:1.5.1" + checksum: 669632eb3745404c2f822a18fc3a0122d2f9a7a13f7fb8b5823ee19d1d2ff9ee5b52c53367176ea4ad093c332fd5ab4bd0ebae5a8e27917a4105a4cfc86b1005 + languageName: node + linkType: hard + "batch@npm:0.6.1": version: 0.6.1 resolution: "batch@npm:0.6.1" @@ -4974,6 +4981,16 @@ __metadata: languageName: node linkType: hard +"buffer@npm:^6.0.3": + version: 6.0.3 + resolution: "buffer@npm:6.0.3" + dependencies: + base64-js: ^1.3.1 + ieee754: ^1.2.1 + checksum: 5ad23293d9a731e4318e420025800b42bf0d264004c0286c8cc010af7a270c7a0f6522e84f54b9ad65cbd6db20b8badbfd8d2ebf4f80fa03dab093b89e68c3f9 + languageName: node + linkType: hard + "builtin-modules@npm:^3.1.0": version: 3.3.0 resolution: "builtin-modules@npm:3.3.0" @@ -6164,6 +6181,7 @@ __metadata: "@types/react-dom": ^18.0.11 "@types/testing-library__jest-dom": ^5.14.5 "@types/three": ^0.149.0 + buffer: ^6.0.3 dotenv: ^16.0.3 eslint: ^8.37.0 eslint-config-prettier: ^8.6.0 @@ -7528,7 +7546,7 @@ __metadata: "fsevents@patch:fsevents@2.3.2#~builtin, fsevents@patch:fsevents@^2.3.2#~builtin, fsevents@patch:fsevents@~2.3.2#~builtin": version: 2.3.2 - resolution: "fsevents@patch:fsevents@npm%3A2.3.2#~builtin::version=2.3.2&hash=18f3a7" + resolution: "fsevents@patch:fsevents@npm%3A2.3.2#~builtin::version=2.3.2&hash=df0bf1" dependencies: node-gyp: latest conditions: os=darwin @@ -8159,6 +8177,13 @@ __metadata: languageName: node linkType: hard +"ieee754@npm:^1.2.1": + version: 1.2.1 + resolution: "ieee754@npm:1.2.1" + checksum: 5144c0c9815e54ada181d80a0b810221a253562422e7c6c3a60b1901154184f49326ec239d618c416c1c5945a2e197107aee8d986a3dd836b53dffefd99b5e7e + languageName: node + linkType: hard + "ignore@npm:^5.2.0": version: 5.2.4 resolution: "ignore@npm:5.2.4" @@ -12363,7 +12388,7 @@ __metadata: "resolve@patch:resolve@^1.1.7#~builtin, resolve@patch:resolve@^1.14.2#~builtin, resolve@patch:resolve@^1.19.0#~builtin, resolve@patch:resolve@^1.20.0#~builtin, resolve@patch:resolve@^1.22.1#~builtin": version: 1.22.1 - resolution: "resolve@patch:resolve@npm%3A1.22.1#~builtin::version=1.22.1&hash=07638b" + resolution: "resolve@patch:resolve@npm%3A1.22.1#~builtin::version=1.22.1&hash=c3c19d" dependencies: is-core-module: ^2.9.0 path-parse: ^1.0.7 @@ -12376,7 +12401,7 @@ __metadata: "resolve@patch:resolve@^2.0.0-next.4#~builtin": version: 2.0.0-next.4 - resolution: "resolve@patch:resolve@npm%3A2.0.0-next.4#~builtin::version=2.0.0-next.4&hash=07638b" + resolution: "resolve@patch:resolve@npm%3A2.0.0-next.4#~builtin::version=2.0.0-next.4&hash=c3c19d" dependencies: is-core-module: ^2.9.0 path-parse: ^1.0.7 @@ -13826,11 +13851,11 @@ __metadata: "typescript@patch:typescript@^4.4.2#~builtin": version: 4.9.5 - resolution: "typescript@patch:typescript@npm%3A4.9.5#~builtin::version=4.9.5&hash=a1c5e5" + resolution: "typescript@patch:typescript@npm%3A4.9.5#~builtin::version=4.9.5&hash=23ec76" bin: tsc: bin/tsc tsserver: bin/tsserver - checksum: 2eee5c37cad4390385db5db5a8e81470e42e8f1401b0358d7390095d6f681b410f2c4a0c496c6ff9ebd775423c7785cdace7bcdad76c7bee283df3d9718c0f20 + checksum: ab417a2f398380c90a6cf5a5f74badd17866adf57f1165617d6a551f059c3ba0a3e4da0d147b3ac5681db9ac76a303c5876394b13b3de75fdd5b1eaa06181c9d languageName: node linkType: hard