From e3603195a1a454ca320ef9371a2e1d836ef266eb Mon Sep 17 00:00:00 2001 From: Der_Googler <54764558+DerGoogler@users.noreply.github.com> Date: Sat, 28 Oct 2023 00:41:36 +0200 Subject: [PATCH] Configure API changes --- Website/package-lock.json | 436 ++++++++++++------ Website/package.json | 3 +- .../src/components/ConfigureView/index.tsx | 77 +++- Website/src/components/ConfigureView/libs.ts | 18 +- Website/src/hooks/useSettings.tsx | 30 +- Website/src/native/SuFile.ts | 25 +- Website/src/util/configure-sample.ts | 5 +- Website/tsconfig.json | 1 - Website/webpack.config.ts | 1 - 9 files changed, 415 insertions(+), 181 deletions(-) diff --git a/Website/package-lock.json b/Website/package-lock.json index 538a3614..3c13dda5 100644 --- a/Website/package-lock.json +++ b/Website/package-lock.json @@ -19,15 +19,16 @@ "@mui/material": "^5.13.7", "@nyariv/sandboxjs": "^0.8.23", "@primer/octicons-react": "^19.4.0", + "@wasmer/wasmfs": "^0.12.0", "ace-builds": "^1.23.3", "ajv": "^8.12.0", "ansi-to-react": "^6.1.6", "axios": "^0.27.2", - "browserfs": "^1.4.3", "default-composer": "^0.4.0", "eruda": "^3.0.0", "flatlist-react": "^1.5.14", "framer-motion": "^10.16.4", + "fs-monkey": "^1.0.5", "googlers-tools": "^1.2.8", "highlight.js": "^11.6.0", "install": "^0.13.0", @@ -3101,6 +3102,16 @@ "@types/node": "*" } }, + "node_modules/@wasmer/wasmfs": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/@wasmer/wasmfs/-/wasmfs-0.12.0.tgz", + "integrity": "sha512-m1ftchyQ1DfSenm5XbbdGIpb6KJHH5z0gODo3IZr6lATkj4WXfX/UeBTZ0aG9YVShBp+kHLdUHvOkqjy6p/GWw==", + "dependencies": { + "memfs": "3.0.4", + "pako": "^1.0.11", + "tar-stream": "^2.1.0" + } + }, "node_modules/@webassemblyjs/ast": { "version": "1.11.1", "dev": true, @@ -3459,14 +3470,6 @@ "dev": true, "license": "MIT" }, - "node_modules/async": { - "version": "2.6.4", - "resolved": "https://registry.npmjs.org/async/-/async-2.6.4.tgz", - "integrity": "sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA==", - "dependencies": { - "lodash": "^4.17.14" - } - }, "node_modules/asynckit": { "version": "0.4.0", "license": "MIT" @@ -3570,6 +3573,25 @@ "version": "1.0.2", "license": "MIT" }, + "node_modules/base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, "node_modules/batch": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/batch/-/batch-0.6.1.tgz", @@ -3592,6 +3614,16 @@ "node": ">=8" } }, + "node_modules/bl": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz", + "integrity": "sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==", + "dependencies": { + "buffer": "^5.5.0", + "inherits": "^2.0.4", + "readable-stream": "^3.4.0" + } + }, "node_modules/body-parser": { "version": "1.20.1", "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz", @@ -3682,21 +3714,6 @@ "dev": true, "license": "ISC" }, - "node_modules/browserfs": { - "version": "1.4.3", - "resolved": "https://registry.npmjs.org/browserfs/-/browserfs-1.4.3.tgz", - "integrity": "sha512-tz8HClVrzTJshcyIu8frE15cjqjcBIu15Bezxsvl/i+6f59iNCN3kznlWjz0FEb3DlnDx3gW5szxeT6D1x0s0w==", - "dependencies": { - "async": "^2.1.4", - "pako": "^1.0.4" - }, - "bin": { - "make_xhrfs_index": "dist/scripts/make_xhrfs_index.js" - }, - "engines": { - "node": ">= 0.10" - } - }, "node_modules/browserslist": { "version": "4.22.1", "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.22.1.tgz", @@ -3728,6 +3745,29 @@ "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" } }, + "node_modules/buffer": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", + "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.1.13" + } + }, "node_modules/buffer-from": { "version": "1.1.2", "dev": true, @@ -4098,8 +4138,9 @@ }, "node_modules/core-util-is": { "version": "1.0.3", - "dev": true, - "license": "MIT" + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", + "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==", + "dev": true }, "node_modules/cosmiconfig": { "version": "7.0.1", @@ -4615,6 +4656,14 @@ "node": ">= 0.8" } }, + "node_modules/end-of-stream": { + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", + "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", + "dependencies": { + "once": "^1.4.0" + } + }, "node_modules/enhanced-resolve": { "version": "5.10.0", "dev": true, @@ -4895,6 +4944,11 @@ "version": "3.1.3", "license": "MIT" }, + "node_modules/fast-extend": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/fast-extend/-/fast-extend-1.0.2.tgz", + "integrity": "sha512-XXA9RmlPatkFKUzqVZAFth18R4Wo+Xug/S+C7YlYA3xrXwfPlW3dqNwOb4hvQo7wZJ2cNDYhrYuPzVOfHy5/uQ==" + }, "node_modules/fast-json-stable-stringify": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", @@ -5173,6 +5227,11 @@ "node": ">= 0.6" } }, + "node_modules/fs-constants": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", + "integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==" + }, "node_modules/fs-extra": { "version": "11.1.1", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.1.1.tgz", @@ -5188,10 +5247,9 @@ } }, "node_modules/fs-monkey": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/fs-monkey/-/fs-monkey-1.0.4.tgz", - "integrity": "sha512-INM/fWAxMICjttnD0DX1rBvinKskj5G1w+oy/pnm9u/tSlnBrzFonJMcalKJ30P8RRsPzKcCG7Q8l0jx5Fh9YQ==", - "dev": true + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/fs-monkey/-/fs-monkey-1.0.5.tgz", + "integrity": "sha512-8uMbBjrhzW76TYgEV27Y5E//W2f/lTFmx78P2w19FZSxarhI/798APGQyuGCwmkNxgwGRhrLfvWyLBvNtuOmew==" }, "node_modules/fs.realpath": { "version": "1.0.0", @@ -5421,6 +5479,21 @@ "wbuf": "^1.1.0" } }, + "node_modules/hpack.js/node_modules/readable-stream": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz", + "integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==", + "dev": true, + "dependencies": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, "node_modules/html-entities": { "version": "2.3.3", "resolved": "https://registry.npmjs.org/html-entities/-/html-entities-2.3.3.tgz", @@ -5550,6 +5623,25 @@ "postcss": "^8.1.0" } }, + "node_modules/ieee754": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, "node_modules/immutable": { "version": "4.1.0", "dev": true, @@ -5598,7 +5690,6 @@ }, "node_modules/inherits": { "version": "2.0.4", - "dev": true, "license": "ISC" }, "node_modules/install": { @@ -5766,8 +5857,9 @@ }, "node_modules/isarray": { "version": "1.0.0", - "dev": true, - "license": "MIT" + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==", + "dev": true }, "node_modules/isexe": { "version": "2.0.0", @@ -6035,11 +6127,6 @@ "node": ">=8" } }, - "node_modules/lodash": { - "version": "4.17.21", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" - }, "node_modules/lodash.debounce": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/lodash.debounce/-/lodash.debounce-4.0.8.tgz", @@ -6183,17 +6270,19 @@ } }, "node_modules/memfs": { - "version": "3.5.1", - "resolved": "https://registry.npmjs.org/memfs/-/memfs-3.5.1.tgz", - "integrity": "sha512-UWbFJKvj5k+nETdteFndTpYxdeTMox/ULeqX5k/dpaQJCCFmj5EeKv3dBcyO2xmkRAx2vppRu5dVG7SOtsGOzA==", - "dev": true, + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/memfs/-/memfs-3.0.4.tgz", + "integrity": "sha512-OcZEzwX9E5AoY8SXjuAvw0DbIAYwUzV/I236I8Pqvrlv7sL/Y0E9aRCon05DhaV8pg1b32uxj76RgW0s5xjHBA==", "dependencies": { - "fs-monkey": "^1.0.3" - }, - "engines": { - "node": ">= 4.0.0" + "fast-extend": "1.0.2", + "fs-monkey": "0.3.3" } }, + "node_modules/memfs/node_modules/fs-monkey": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/fs-monkey/-/fs-monkey-0.3.3.tgz", + "integrity": "sha512-FNUvuTAJ3CqCQb5ELn+qCbGR/Zllhf2HtwsdAtBi59s1WeCjKMT81fHcSu7dwIskqGVK+MmOrb7VOBlq3/SItw==" + }, "node_modules/merge-descriptors": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", @@ -9573,7 +9662,6 @@ }, "node_modules/once": { "version": "1.4.0", - "dev": true, "license": "ISC", "dependencies": { "wrappy": "1" @@ -10348,8 +10436,9 @@ }, "node_modules/process-nextick-args": { "version": "2.0.1", - "dev": true, - "license": "MIT" + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", + "dev": true }, "node_modules/prop-types": { "version": "15.8.1", @@ -10818,17 +10907,16 @@ } }, "node_modules/readable-stream": { - "version": "2.3.7", - "dev": true, - "license": "MIT", + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", + "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", "dependencies": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + }, + "engines": { + "node": ">= 6" } }, "node_modules/readdir-scoped-modules": { @@ -11523,20 +11611,6 @@ "wbuf": "^1.7.3" } }, - "node_modules/spdy-transport/node_modules/readable-stream": { - "version": "3.6.2", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", - "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", - "dev": true, - "dependencies": { - "inherits": "^2.0.3", - "string_decoder": "^1.1.1", - "util-deprecate": "^1.0.1" - }, - "engines": { - "node": ">= 6" - } - }, "node_modules/sprintf-js": { "version": "1.0.3", "dev": true, @@ -11563,7 +11637,6 @@ }, "node_modules/string_decoder": { "version": "1.1.1", - "dev": true, "license": "MIT", "dependencies": { "safe-buffer": "~5.1.0" @@ -11674,6 +11747,21 @@ "node": ">=6" } }, + "node_modules/tar-stream": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.2.0.tgz", + "integrity": "sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==", + "dependencies": { + "bl": "^4.0.3", + "end-of-stream": "^1.4.1", + "fs-constants": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^3.1.1" + }, + "engines": { + "node": ">=6" + } + }, "node_modules/terser": { "version": "5.19.0", "resolved": "https://registry.npmjs.org/terser/-/terser-5.19.0.tgz", @@ -12209,7 +12297,6 @@ }, "node_modules/util-deprecate": { "version": "1.0.2", - "dev": true, "license": "MIT" }, "node_modules/util-extend": { @@ -12584,6 +12671,18 @@ "ajv": "^8.8.2" } }, + "node_modules/webpack-dev-middleware/node_modules/memfs": { + "version": "3.5.3", + "resolved": "https://registry.npmjs.org/memfs/-/memfs-3.5.3.tgz", + "integrity": "sha512-UERzLsxzllchadvbPs5aolHh65ISpKpM+ccLbOJ8/vvpBKmAWf+la7dXFy7Mr0ySHbdHrFv5kGFCUHHe6GFEmw==", + "dev": true, + "dependencies": { + "fs-monkey": "^1.0.4" + }, + "engines": { + "node": ">= 4.0.0" + } + }, "node_modules/webpack-dev-middleware/node_modules/schema-utils": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-4.0.1.tgz", @@ -12805,7 +12904,6 @@ }, "node_modules/wrappy": { "version": "1.0.2", - "dev": true, "license": "ISC" }, "node_modules/ws": { @@ -14976,6 +15074,16 @@ "@types/node": "*" } }, + "@wasmer/wasmfs": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/@wasmer/wasmfs/-/wasmfs-0.12.0.tgz", + "integrity": "sha512-m1ftchyQ1DfSenm5XbbdGIpb6KJHH5z0gODo3IZr6lATkj4WXfX/UeBTZ0aG9YVShBp+kHLdUHvOkqjy6p/GWw==", + "requires": { + "memfs": "3.0.4", + "pako": "^1.0.11", + "tar-stream": "^2.1.0" + } + }, "@webassemblyjs/ast": { "version": "1.11.1", "dev": true, @@ -15240,14 +15348,6 @@ "version": "2.0.6", "dev": true }, - "async": { - "version": "2.6.4", - "resolved": "https://registry.npmjs.org/async/-/async-2.6.4.tgz", - "integrity": "sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA==", - "requires": { - "lodash": "^4.17.14" - } - }, "asynckit": { "version": "0.4.0" }, @@ -15324,6 +15424,11 @@ "balanced-match": { "version": "1.0.2" }, + "base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==" + }, "batch": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/batch/-/batch-0.6.1.tgz", @@ -15338,6 +15443,16 @@ "version": "2.2.0", "dev": true }, + "bl": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz", + "integrity": "sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==", + "requires": { + "buffer": "^5.5.0", + "inherits": "^2.0.4", + "readable-stream": "^3.4.0" + } + }, "body-parser": { "version": "1.20.1", "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz", @@ -15416,15 +15531,6 @@ "version": "1.3.1", "dev": true }, - "browserfs": { - "version": "1.4.3", - "resolved": "https://registry.npmjs.org/browserfs/-/browserfs-1.4.3.tgz", - "integrity": "sha512-tz8HClVrzTJshcyIu8frE15cjqjcBIu15Bezxsvl/i+6f59iNCN3kznlWjz0FEb3DlnDx3gW5szxeT6D1x0s0w==", - "requires": { - "async": "^2.1.4", - "pako": "^1.0.4" - } - }, "browserslist": { "version": "4.22.1", "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.22.1.tgz", @@ -15436,6 +15542,15 @@ "update-browserslist-db": "^1.0.13" } }, + "buffer": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", + "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", + "requires": { + "base64-js": "^1.3.1", + "ieee754": "^1.1.13" + } + }, "buffer-from": { "version": "1.1.2", "dev": true @@ -15674,6 +15789,8 @@ }, "core-util-is": { "version": "1.0.3", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", + "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==", "dev": true }, "cosmiconfig": { @@ -16005,6 +16122,14 @@ "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==", "dev": true }, + "end-of-stream": { + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", + "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", + "requires": { + "once": "^1.4.0" + } + }, "enhanced-resolve": { "version": "5.10.0", "dev": true, @@ -16205,6 +16330,11 @@ "fast-deep-equal": { "version": "3.1.3" }, + "fast-extend": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/fast-extend/-/fast-extend-1.0.2.tgz", + "integrity": "sha512-XXA9RmlPatkFKUzqVZAFth18R4Wo+Xug/S+C7YlYA3xrXwfPlW3dqNwOb4hvQo7wZJ2cNDYhrYuPzVOfHy5/uQ==" + }, "fast-json-stable-stringify": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", @@ -16391,6 +16521,11 @@ "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==", "dev": true }, + "fs-constants": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", + "integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==" + }, "fs-extra": { "version": "11.1.1", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.1.1.tgz", @@ -16403,10 +16538,9 @@ } }, "fs-monkey": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/fs-monkey/-/fs-monkey-1.0.4.tgz", - "integrity": "sha512-INM/fWAxMICjttnD0DX1rBvinKskj5G1w+oy/pnm9u/tSlnBrzFonJMcalKJ30P8RRsPzKcCG7Q8l0jx5Fh9YQ==", - "dev": true + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/fs-monkey/-/fs-monkey-1.0.5.tgz", + "integrity": "sha512-8uMbBjrhzW76TYgEV27Y5E//W2f/lTFmx78P2w19FZSxarhI/798APGQyuGCwmkNxgwGRhrLfvWyLBvNtuOmew==" }, "fs.realpath": { "version": "1.0.0", @@ -16556,6 +16690,23 @@ "obuf": "^1.0.0", "readable-stream": "^2.0.1", "wbuf": "^1.1.0" + }, + "dependencies": { + "readable-stream": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz", + "integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==", + "dev": true, + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + } } }, "html-entities": { @@ -16650,6 +16801,11 @@ "dev": true, "requires": {} }, + "ieee754": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==" + }, "immutable": { "version": "4.1.0", "dev": true @@ -16678,8 +16834,7 @@ } }, "inherits": { - "version": "2.0.4", - "dev": true + "version": "2.0.4" }, "install": { "version": "0.13.0", @@ -16770,6 +16925,8 @@ }, "isarray": { "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==", "dev": true }, "isexe": { @@ -16966,11 +17123,6 @@ "p-locate": "^4.1.0" } }, - "lodash": { - "version": "4.17.21", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" - }, "lodash.debounce": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/lodash.debounce/-/lodash.debounce-4.0.8.tgz", @@ -17063,12 +17215,19 @@ "dev": true }, "memfs": { - "version": "3.5.1", - "resolved": "https://registry.npmjs.org/memfs/-/memfs-3.5.1.tgz", - "integrity": "sha512-UWbFJKvj5k+nETdteFndTpYxdeTMox/ULeqX5k/dpaQJCCFmj5EeKv3dBcyO2xmkRAx2vppRu5dVG7SOtsGOzA==", - "dev": true, + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/memfs/-/memfs-3.0.4.tgz", + "integrity": "sha512-OcZEzwX9E5AoY8SXjuAvw0DbIAYwUzV/I236I8Pqvrlv7sL/Y0E9aRCon05DhaV8pg1b32uxj76RgW0s5xjHBA==", "requires": { - "fs-monkey": "^1.0.3" + "fast-extend": "1.0.2", + "fs-monkey": "0.3.3" + }, + "dependencies": { + "fs-monkey": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/fs-monkey/-/fs-monkey-0.3.3.tgz", + "integrity": "sha512-FNUvuTAJ3CqCQb5ELn+qCbGR/Zllhf2HtwsdAtBi59s1WeCjKMT81fHcSu7dwIskqGVK+MmOrb7VOBlq3/SItw==" + } } }, "merge-descriptors": { @@ -19240,7 +19399,6 @@ }, "once": { "version": "1.4.0", - "dev": true, "requires": { "wrappy": "1" } @@ -19673,6 +19831,8 @@ }, "process-nextick-args": { "version": "2.0.1", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", "dev": true }, "prop-types": { @@ -20004,16 +20164,13 @@ } }, "readable-stream": { - "version": "2.3.7", - "dev": true, + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", + "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" } }, "readdir-scoped-modules": { @@ -20536,19 +20693,6 @@ "obuf": "^1.1.2", "readable-stream": "^3.0.6", "wbuf": "^1.7.3" - }, - "dependencies": { - "readable-stream": { - "version": "3.6.2", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", - "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", - "dev": true, - "requires": { - "inherits": "^2.0.3", - "string_decoder": "^1.1.1", - "util-deprecate": "^1.0.1" - } - } } }, "sprintf-js": { @@ -20572,7 +20716,6 @@ }, "string_decoder": { "version": "1.1.1", - "dev": true, "requires": { "safe-buffer": "~5.1.0" } @@ -20636,6 +20779,18 @@ "version": "2.2.1", "dev": true }, + "tar-stream": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.2.0.tgz", + "integrity": "sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==", + "requires": { + "bl": "^4.0.3", + "end-of-stream": "^1.4.1", + "fs-constants": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^3.1.1" + } + }, "terser": { "version": "5.19.0", "resolved": "https://registry.npmjs.org/terser/-/terser-5.19.0.tgz", @@ -20955,8 +21110,7 @@ "requires": {} }, "util-deprecate": { - "version": "1.0.2", - "dev": true + "version": "1.0.2" }, "util-extend": { "version": "1.0.3", @@ -21258,6 +21412,15 @@ "fast-deep-equal": "^3.1.3" } }, + "memfs": { + "version": "3.5.3", + "resolved": "https://registry.npmjs.org/memfs/-/memfs-3.5.3.tgz", + "integrity": "sha512-UERzLsxzllchadvbPs5aolHh65ISpKpM+ccLbOJ8/vvpBKmAWf+la7dXFy7Mr0ySHbdHrFv5kGFCUHHe6GFEmw==", + "dev": true, + "requires": { + "fs-monkey": "^1.0.4" + } + }, "schema-utils": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-4.0.1.tgz", @@ -21370,8 +21533,7 @@ "dev": true }, "wrappy": { - "version": "1.0.2", - "dev": true + "version": "1.0.2" }, "ws": { "version": "8.13.0", diff --git a/Website/package.json b/Website/package.json index 17d14ca8..79243907 100644 --- a/Website/package.json +++ b/Website/package.json @@ -41,15 +41,16 @@ "@mui/material": "^5.13.7", "@nyariv/sandboxjs": "^0.8.23", "@primer/octicons-react": "^19.4.0", + "@wasmer/wasmfs": "^0.12.0", "ace-builds": "^1.23.3", "ajv": "^8.12.0", "ansi-to-react": "^6.1.6", "axios": "^0.27.2", - "browserfs": "^1.4.3", "default-composer": "^0.4.0", "eruda": "^3.0.0", "flatlist-react": "^1.5.14", "framer-motion": "^10.16.4", + "fs-monkey": "^1.0.5", "googlers-tools": "^1.2.8", "highlight.js": "^11.6.0", "install": "^0.13.0", diff --git a/Website/src/components/ConfigureView/index.tsx b/Website/src/components/ConfigureView/index.tsx index 5ca92165..354e8f2f 100644 --- a/Website/src/components/ConfigureView/index.tsx +++ b/Website/src/components/ConfigureView/index.tsx @@ -11,8 +11,10 @@ import Sandbox from "@nyariv/sandboxjs"; import { transform, registerPlugin } from "@babel/standalone"; import * as React from "react"; import { PluginObj } from "@babel/core"; -import { globals } from "./libs"; +import { globals, libraries } from "./libs"; import { DialogEditListItem, StyledListSubheader } from "./components"; +import { SuFile, wasmFs } from "@Native/SuFile"; +import { ModConf, useSettings } from "@Hooks/useSettings"; function plugin({ types: t }): PluginObj { return { @@ -67,22 +69,63 @@ const scope = { export const ConfigureView = React.memo((props) => { const { theme } = useTheme(); - const Component = sandbox - .compile>(parseCode(props.children as string))({ - modid: props.modid, - window: { - open(href: string) { - os.open(href, { - target: "_blank", - features: { - color: theme.palette.primary.main, - }, - }); - }, + const { modConf } = useSettings(); + + const format = React.useCallback<(key: K) => ModConf[K]>((key) => modConf(key, { MODID: props.modid }), []); + + React.useEffect(() => { + wasmFs.volume.fromJSON( + { + [format("PROPS")]: `id=${props.modid}`, + [format("CONFINDEX")]: 'export default "DO NOT USE THIS FILE OR IMPORT IT!"', }, - ...scope, - }) - .run(); + format("CONFCWD") + ); + }, [props.modid]); - return ; + const box = React.useCallback( + (code: string) => + sandbox + .compile | undefined>( + parseCode(code), + true + )({ + modid: props.modid, + modpath: (path: string) => `${format("MODULECWD")}/${path}`, + confpath: (path: string) => `${format("CONFCWD")}/${path}`, + window: { + open(href: string) { + os.open(href, { + target: "_blank", + features: { + color: theme.palette.primary.main, + }, + }); + }, + }, + require(id: string) { + if (id.startsWith("!conf/")) { + const filename = id.replace(/!conf\/(.+)/gm, `${format("CONFCWD")}/$1`); + const file = new SuFile(filename); + if (file.exist()) { + return box(file.read()); + } else { + return `Imported \"${filename}\" file not found`; + } + } else { + return libraries.find((lib) => id === lib.name)?.__esModule; + } + }, + ...scope, + }) + .run(), + [] + ); + const Component = box(props.children as string); + + if (Component) { + return ; + } else { + return
export is undefined
; + } }); diff --git a/Website/src/components/ConfigureView/libs.ts b/Website/src/components/ConfigureView/libs.ts index 2e3c5b4c..6514d3a6 100644 --- a/Website/src/components/ConfigureView/libs.ts +++ b/Website/src/components/ConfigureView/libs.ts @@ -11,6 +11,8 @@ import { useNativeProperties } from "@Hooks/useNativeProperties"; import { Markdown, PromoBanner } from "./components"; import { useActivity } from "@Hooks/useActivity"; import { Toolbar } from "@Components/onsenui/Toolbar"; +import { SuFile } from "@Native/SuFile"; +import { os } from "@Native/Os"; export const libraries = [ { @@ -54,18 +56,22 @@ export const libraries = [ }, { - name: "@mmrl/native", + name: "@mmrl/sufile", __esModule: { - // SuFile: SuFile, + read: SuFile.read, + write: SuFile.write, + list: SuFile.list, + exist: SuFile.exist, + delete: SuFile.delete, + deleteRecursive: SuFile.deleteRecursive, }, }, ]; +const prototypeWhitelist = Sandbox.SAFE_PROTOTYPES; +prototypeWhitelist.set(Node, new Set()); + export const globals = { ...Sandbox.SAFE_GLOBALS, Object, - // React: require("react"), - require(id: string) { - return libraries.find((lib) => id === lib.name)?.__esModule; - }, }; diff --git a/Website/src/hooks/useSettings.tsx b/Website/src/hooks/useSettings.tsx index 115dcd0a..adf2c927 100644 --- a/Website/src/hooks/useSettings.tsx +++ b/Website/src/hooks/useSettings.tsx @@ -173,6 +173,7 @@ export interface ModConf { // default paths ADB: string; MODULES: string; + MODULECWD: string; PROPS: string; SYSTEM: string; SEPOLICY: string; @@ -215,26 +216,27 @@ export const INITIAL_MOD_CONF: ModConf = { // default paths ADB: "/data/adb", MODULES: "/modules", - PROPS: "//module.prop", - SYSTEM: "//system.prop", - SEPOLICY: "//sepolicy.rule", - CONFIG: `//system/usr/share/mmrl/config/.mdx`, + MODULECWD: "/", + PROPS: "/module.prop", + SYSTEM: "/system.prop", + SEPOLICY: "/sepolicy.rule", + CONFIG: `/system/usr/share/mmrl/config/.mdx`, // service paths - LATESERVICE: "//service.sh", - POSTSERVICE: "//post-fs-data.sh", - POSTMOUNT: "//post-mount.sh", - BOOTCOMP: "//boot-completed.sh", + LATESERVICE: "/service.sh", + POSTSERVICE: "/post-fs-data.sh", + POSTMOUNT: "/post-mount.sh", + BOOTCOMP: "/boot-completed.sh", // status paths - SKIPMOUNT: "//skip_mount", - DISABLE: "//disable", - REMOVE: "//remove", - UPDATE: "//update", + SKIPMOUNT: "/skip_mount", + DISABLE: "/disable", + REMOVE: "/remove", + UPDATE: "/update", // others - MMRLINI: "/mmrl_install_tools", - CONFCWD: "//system/usr/share/mmrl/config/", + MMRLINI: "/mmrl_install_tools", + CONFCWD: "/system/usr/share/mmrl/config/", CONFINDEX: "/index.jsx", }; diff --git a/Website/src/native/SuFile.ts b/Website/src/native/SuFile.ts index 2a3b1693..b86e0f08 100644 --- a/Website/src/native/SuFile.ts +++ b/Website/src/native/SuFile.ts @@ -1,4 +1,8 @@ +import { IFs } from "memfs"; import { Native } from "./Native"; +import { WasmFs } from "@wasmer/wasmfs"; + +export const wasmFs = new WasmFs(); interface NativeSuFile { readFile(path: string): string; @@ -15,18 +19,31 @@ interface NativeSuFile { */ class SuFile extends Native { private path: string; + private _fs: IFs = wasmFs.fs; public constructor(path?: string) { super(); this.path = path ? path : ""; this.interfaceName = "__sufile__"; + // Support for browsers + // if (!this.isAndroid) { + // this._fs = null as unknown as IFs; + // } } public read(): string { if (this.isAndroid) { return this.getInterface.readFile(this.path); } else { - return ""; + return this._fs.readFileSync(this.path).toString(); + } + } + + public write(content: string): void { + if (this.isAndroid) { + null; + } else { + this._fs.writeFileSync(this.path, content); } } @@ -49,7 +66,7 @@ class SuFile extends Native { if (this.isAndroid) { return this.getInterface.existFile(this.path); } else { - return false; + return this._fs.existsSync(this.path); } } @@ -79,6 +96,10 @@ class SuFile extends Native { return new SuFile(path).read(); } + public static write(path: string, content: string): void { + new SuFile(path).write(content); + } + /** * * @param path diff --git a/Website/src/util/configure-sample.ts b/Website/src/util/configure-sample.ts index 60665adf..17b637f8 100644 --- a/Website/src/util/configure-sample.ts +++ b/Website/src/util/configure-sample.ts @@ -169,5 +169,6 @@ function InstallToolsConfig() { ); } -export default InstallToolsConfig; -`; +export default { + onCreate: InstallToolsConfig +};`; diff --git a/Website/tsconfig.json b/Website/tsconfig.json index 33d4c1be..a05c7b14 100644 --- a/Website/tsconfig.json +++ b/Website/tsconfig.json @@ -6,7 +6,6 @@ "emitDeclarationOnly": false, "experimentalDecorators": true, "declarationMap": false, - "allowImportingTsExtensions": true, "typeRoots": ["src/typings/global.d.ts"], "sourceMap": true, "strict": true, diff --git a/Website/webpack.config.ts b/Website/webpack.config.ts index 87bea2ca..31fa12ec 100644 --- a/Website/webpack.config.ts +++ b/Website/webpack.config.ts @@ -4,7 +4,6 @@ import { Configuration, DefinePlugin } from "webpack"; import webpackDevServer from "webpack-dev-server"; import MiniCssExtractPlugin from "mini-css-extract-plugin"; import CssMinimizerPlugin from "css-minimizer-webpack-plugin"; -import * as fs from "fs"; const outputPath = "./../www";