From c5cb1234a9ba36f39d9ef8ff930460211ae6c93c Mon Sep 17 00:00:00 2001 From: Dreamacro <8615343+Dreamacro@users.noreply.github.com> Date: Sat, 26 Sep 2020 22:21:29 +0800 Subject: [PATCH] Fix: bundle and bug --- config/paths.js | 1 - package-lock.json | 177 +++++++++--------- package.json | 20 +- src/components/Modal/index.tsx | 4 +- src/components/Tags/index.tsx | 4 +- src/containers/Connections/index.tsx | 4 +- src/containers/Connections/store.ts | 10 +- .../ExternalControllerDrawer/index.tsx | 4 +- src/containers/Logs/index.tsx | 4 +- .../Proxies/components/Provider/index.tsx | 4 +- src/containers/Proxies/index.tsx | 8 +- src/containers/Rules/Provider/index.tsx | 4 +- src/containers/Rules/index.tsx | 8 +- src/containers/Settings/index.tsx | 4 +- src/containers/Sidebar/index.tsx | 4 +- src/stores/recoil.ts | 6 +- 16 files changed, 128 insertions(+), 138 deletions(-) diff --git a/config/paths.js b/config/paths.js index 4a33798..21b2b1a 100644 --- a/config/paths.js +++ b/config/paths.js @@ -17,7 +17,6 @@ const resolveApp = relativePath => path.resolve(appDirectory, relativePath); // like /todos/42/static/js/bundle.7289d.js. We have to know the root. const publicUrlOrPath = getPublicUrlOrPath( process.env.NODE_ENV === 'development', - require(resolveApp('package.json')).homepage, process.env.PUBLIC_URL ); diff --git a/package-lock.json b/package-lock.json index bdc65ea..4e9e235 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1883,9 +1883,9 @@ "dev": true }, "@types/html-minifier-terser": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/@types/html-minifier-terser/-/html-minifier-terser-5.1.0.tgz", - "integrity": "sha512-iYCgjm1dGPRuo12+BStjd1HiVQqhlRhWDOQigNxn023HcjnhsiFz9pc6CzJj4HwDCSQca9bxTL4PxJDbkdm3PA==", + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/@types/html-minifier-terser/-/html-minifier-terser-5.1.1.tgz", + "integrity": "sha512-giAlZwstKbmvMk1OO7WXSj4OZ0keXAcl2TQq4LWHiiPH2ByaH7WeUzng+Qej8UPxxv+8lRTuouo0iaNDBuzIBA==", "dev": true }, "@types/json-schema": { @@ -1913,9 +1913,9 @@ "dev": true }, "@types/node": { - "version": "14.11.1", - "resolved": "https://registry.npmjs.org/@types/node/-/node-14.11.1.tgz", - "integrity": "sha512-oTQgnd0hblfLsJ6BvJzzSL+Inogp3lq9fGgqRkMB/ziKMgEUaFl801OncOzUmalfzt14N0oPHMK47ipl+wbTIw==", + "version": "14.11.2", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.11.2.tgz", + "integrity": "sha512-jiE3QIxJ8JLNcb1Ps6rDbysDhN4xa8DJJvuC9prr6w+1tIh+QAbYyNF3tyiZNLDBIuBCf4KEcV2UvQm/V60xfA==", "dev": true }, "@types/parse-json": { @@ -2083,13 +2083,13 @@ } }, "@typescript-eslint/eslint-plugin": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.1.1.tgz", - "integrity": "sha512-Hoxyt99EA9LMmqo/5PuWWPeWeB3mKyvibfJ1Hy5SfiUpjE8Nqp+5QNd9fOkzL66+fqvIWSIE+Ett16LGMzCGnQ==", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.2.0.tgz", + "integrity": "sha512-zBNRkzvLSwo6y5TG0DVcmshZIYBHKtmzD4N+LYnfTFpzc4bc79o8jNRSb728WV7A4Cegbs+MV5IRAj8BKBgOVQ==", "dev": true, "requires": { - "@typescript-eslint/experimental-utils": "4.1.1", - "@typescript-eslint/scope-manager": "4.1.1", + "@typescript-eslint/experimental-utils": "4.2.0", + "@typescript-eslint/scope-manager": "4.2.0", "debug": "^4.1.1", "functional-red-black-tree": "^1.0.1", "regexpp": "^3.0.0", @@ -2098,12 +2098,12 @@ }, "dependencies": { "debug": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", - "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.2.0.tgz", + "integrity": "sha512-IX2ncY78vDTjZMFUdmsvIRFY2Cf4FnD0wRs+nQwJU8Lu99/tPFdb0VybiiMTPe3I6rQmwsqQqRBvxU+bZ/I8sg==", "dev": true, "requires": { - "ms": "^2.1.1" + "ms": "2.1.2" } }, "ms": { @@ -2115,38 +2115,38 @@ } }, "@typescript-eslint/experimental-utils": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-4.1.1.tgz", - "integrity": "sha512-jzYsNciHoa4Z3c1URtmeT/bamYm8Dwfw6vuN3WHIE/BXb1iC4KveAnXDErTAZtPVxTYBaYn3n2gbt6F6D2rm1A==", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-4.2.0.tgz", + "integrity": "sha512-5BBj6BjgHEndBaQQpUVzRIPERz03LBc0MCQkHwUaH044FJFL08SwWv/sQftk7gf0ShZ2xZysz0LTwCwNt4Xu3w==", "dev": true, "requires": { "@types/json-schema": "^7.0.3", - "@typescript-eslint/scope-manager": "4.1.1", - "@typescript-eslint/types": "4.1.1", - "@typescript-eslint/typescript-estree": "4.1.1", + "@typescript-eslint/scope-manager": "4.2.0", + "@typescript-eslint/types": "4.2.0", + "@typescript-eslint/typescript-estree": "4.2.0", "eslint-scope": "^5.0.0", "eslint-utils": "^2.0.0" } }, "@typescript-eslint/parser": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-4.1.1.tgz", - "integrity": "sha512-NLIhmicpKGfJbdXyQBz9j48PA6hq6e+SDOoXy7Ak6bq1ebGqbgG+fR1UIDAuay6OjQdot69c/URu2uLlsP8GQQ==", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-4.2.0.tgz", + "integrity": "sha512-54jJ6MwkOtowpE48C0QJF9iTz2/NZxfKVJzv1ha5imigzHbNSLN9yvbxFFH1KdlRPQrlR8qxqyOvLHHxd397VA==", "dev": true, "requires": { - "@typescript-eslint/scope-manager": "4.1.1", - "@typescript-eslint/types": "4.1.1", - "@typescript-eslint/typescript-estree": "4.1.1", + "@typescript-eslint/scope-manager": "4.2.0", + "@typescript-eslint/types": "4.2.0", + "@typescript-eslint/typescript-estree": "4.2.0", "debug": "^4.1.1" }, "dependencies": { "debug": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", - "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.2.0.tgz", + "integrity": "sha512-IX2ncY78vDTjZMFUdmsvIRFY2Cf4FnD0wRs+nQwJU8Lu99/tPFdb0VybiiMTPe3I6rQmwsqQqRBvxU+bZ/I8sg==", "dev": true, "requires": { - "ms": "^2.1.1" + "ms": "2.1.2" } }, "ms": { @@ -2158,29 +2158,29 @@ } }, "@typescript-eslint/scope-manager": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.1.1.tgz", - "integrity": "sha512-0W8TTobCvIIQ2FsrYTffyZGAAFUyIbEHq5EYJb1m7Rpd005jrnOvKOo8ywCLhs/Bm17C+KsrUboBvBAARQVvyA==", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.2.0.tgz", + "integrity": "sha512-Tb402cxxObSxWIVT+PnBp5ruT2V/36yj6gG4C9AjkgRlZpxrLAzWDk3neen6ToMBGeGdxtnfFLoJRUecGz9mYQ==", "dev": true, "requires": { - "@typescript-eslint/types": "4.1.1", - "@typescript-eslint/visitor-keys": "4.1.1" + "@typescript-eslint/types": "4.2.0", + "@typescript-eslint/visitor-keys": "4.2.0" } }, "@typescript-eslint/types": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.1.1.tgz", - "integrity": "sha512-zrBiqOKYerMTllKcn+BP+i1b7LW/EbMMYytroXMxUTvFPn1smkCu0D7lSAx29fTUO4jnwV0ljSvYQtn2vNrNxA==", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.2.0.tgz", + "integrity": "sha512-xkv5nIsxfI/Di9eVwN+G9reWl7Me9R5jpzmZUch58uQ7g0/hHVuGUbbn4NcxcM5y/R4wuJIIEPKPDb5l4Fdmwg==", "dev": true }, "@typescript-eslint/typescript-estree": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.1.1.tgz", - "integrity": "sha512-2AUg5v0liVBsqbGxBphbJ0QbGqSRVaF5qPoTPWcxop+66vMdU1h4CCvHxTC47+Qb+Pr4l2RhXDd41JNpwcQEKw==", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.2.0.tgz", + "integrity": "sha512-iWDLCB7z4MGkLipduF6EOotdHNtgxuNKnYD54nMS/oitFnsk4S3S/TE/UYXQTra550lHtlv9eGmp+dvN9pUDtA==", "dev": true, "requires": { - "@typescript-eslint/types": "4.1.1", - "@typescript-eslint/visitor-keys": "4.1.1", + "@typescript-eslint/types": "4.2.0", + "@typescript-eslint/visitor-keys": "4.2.0", "debug": "^4.1.1", "globby": "^11.0.1", "is-glob": "^4.0.1", @@ -2190,12 +2190,12 @@ }, "dependencies": { "debug": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", - "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.2.0.tgz", + "integrity": "sha512-IX2ncY78vDTjZMFUdmsvIRFY2Cf4FnD0wRs+nQwJU8Lu99/tPFdb0VybiiMTPe3I6rQmwsqQqRBvxU+bZ/I8sg==", "dev": true, "requires": { - "ms": "^2.1.1" + "ms": "2.1.2" } }, "ms": { @@ -2207,12 +2207,12 @@ } }, "@typescript-eslint/visitor-keys": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.1.1.tgz", - "integrity": "sha512-/EOOXbA2ferGLG6RmCHEQ0lTTLkOlXYDgblCmQk3tIU7mTPLm4gKhFMeeUSe+bcchTUsKeCk8xcpbop5Zr/8Rw==", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.2.0.tgz", + "integrity": "sha512-WIf4BNOlFOH2W+YqGWa6YKLcK/EB3gEj2apCrqLw6mme1RzBy0jtJ9ewJgnrZDB640zfnv8L+/gwGH5sYp/rGw==", "dev": true, "requires": { - "@typescript-eslint/types": "4.1.1", + "@typescript-eslint/types": "4.2.0", "eslint-visitor-keys": "^2.0.0" }, "dependencies": { @@ -5064,6 +5064,11 @@ "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=", "dev": true }, + "dequal": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.2.tgz", + "integrity": "sha512-q9K8BlJVxK7hQYqa6XISGmBZbtQQWVXSrRrWreHC94rMt1QL/Impruc+7p2CYSYuVIUr+YCt6hjrs1kkdJRTug==" + }, "des.js": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/des.js/-/des.js-1.0.1.tgz", @@ -6001,9 +6006,9 @@ } }, "eslint-plugin-react": { - "version": "7.20.6", - "resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.20.6.tgz", - "integrity": "sha512-kidMTE5HAEBSLu23CUDvj8dc3LdBU0ri1scwHBZjI41oDv4tjsWZKU7MQccFzH1QYPYhsnTF2ovh7JlcIcmxgg==", + "version": "7.21.2", + "resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.21.2.tgz", + "integrity": "sha512-j3XKvrK3rpBzveKFbgAeGsWb9uz6iUOrR0jixRfjwdFeGSRsXvVTFtHDQYCjsd1/6Z/xvb8Vy3LiI5Reo7fDrg==", "dev": true, "requires": { "array-includes": "^3.1.1", @@ -6027,15 +6032,6 @@ "requires": { "esutils": "^2.0.2" } - }, - "resolve": { - "version": "1.17.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.17.0.tgz", - "integrity": "sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w==", - "dev": true, - "requires": { - "path-parse": "^1.0.6" - } } } }, @@ -6422,9 +6418,10 @@ } }, "fast-deep-equal": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz", - "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=" + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true }, "fast-glob": { "version": "3.2.4", @@ -7763,9 +7760,9 @@ } }, "html-webpack-plugin": { - "version": "4.4.1", - "resolved": "https://registry.npmjs.org/html-webpack-plugin/-/html-webpack-plugin-4.4.1.tgz", - "integrity": "sha512-nEtdEIsIGXdXGG7MjTTZlmhqhpHU9pJFc1OYxcP36c5/ZKP6b0BJMww2QTvJGQYA9aMxUnjDujpZdYcVOXiBCQ==", + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/html-webpack-plugin/-/html-webpack-plugin-4.5.0.tgz", + "integrity": "sha512-MouoXEYSjTzCrjIxWwg8gxL5fE2X2WZJLmBYXlaJhQUH5K/b5OrqmV7T4dB7iu0xkmJ6JlUuV6fFVtnqbPopZw==", "dev": true, "requires": { "@types/html-minifier-terser": "^5.0.0", @@ -11729,9 +11726,9 @@ } }, "react-table": { - "version": "7.5.0", - "resolved": "https://registry.npmjs.org/react-table/-/react-table-7.5.0.tgz", - "integrity": "sha512-hLsbNqLJkkYiATVteM8mthP8y5vnLPB2qdi9FeGZjsvb2m5vxj6cavIgk35oulvBmYD6Kox0HFfI332HPZpC7w==" + "version": "7.5.1", + "resolved": "https://registry.npmjs.org/react-table/-/react-table-7.5.1.tgz", + "integrity": "sha512-rprrUElCqvj79lyY2XbUoYLzwA5Mm4CGS8ElQ8OyzocvmkvCcmunvvfbpIg9Jm9HnMBjVZcVyPFPZ1BFelIBKw==" }, "react-virtualized-auto-sizer": { "version": "1.0.2", @@ -12703,9 +12700,9 @@ } }, "is-callable": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.1.tgz", - "integrity": "sha512-wliAfSzx6V+6WfMOmus1xy0XvSgf/dlStkvTfq7F0g4bOIW0PSUbnyse3NhDwdyYS1ozfUtAAySqTws3z9Eqgg==", + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.2.tgz", + "integrity": "sha512-dnMqspv5nU3LoewK2N/y7KLtxtakvTuaCsU9FU50/QDmdbHNy/4/JuRtMHqRU22o3q+W89YQndQEeCVwK+3qrA==", "dev": true }, "is-regex": { @@ -13548,11 +13545,11 @@ } }, "swr": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/swr/-/swr-0.3.2.tgz", - "integrity": "sha512-Bs5Bihq1hQ66O5bdKaL47iZ2nlAaBsd8tTLRLkw9stZeuBEfH7zSuQI95S2TpchL0ybsMq3isWwuso2uPvCfHA==", + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/swr/-/swr-0.3.5.tgz", + "integrity": "sha512-sZNed7JBEnFC42+XFWJ+aYGGVg5D3qNyISZOke3oL/gM1UNm0tsj9mbhTPT99SV9DzbKbT1NFTTRandPdhvpUA==", "requires": { - "fast-deep-equal": "2.0.1" + "dequal": "2.0.2" } }, "table": { @@ -13646,9 +13643,9 @@ } }, "terser-webpack-plugin": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-4.2.1.tgz", - "integrity": "sha512-D0IZQNl1ZN/JivFNDFzOeU2Bk2LdQQESHJhKTHsodpUmISkaeRwVFk7gzHzX4OuQwanDGelOxIEsBt1SZ+s6nA==", + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-4.2.2.tgz", + "integrity": "sha512-3qAQpykRTD5DReLu5/cwpsg7EZFzP3Q0Hp2XUWJUw2mpq2jfgOKTZr8IZKKnNieRVVo1UauROTdhbQJZveGKtQ==", "dev": true, "requires": { "cacache": "^15.0.5", @@ -13658,7 +13655,7 @@ "schema-utils": "^2.7.1", "serialize-javascript": "^5.0.1", "source-map": "^0.6.1", - "terser": "^5.3.1", + "terser": "^5.3.2", "webpack-sources": "^1.4.3" }, "dependencies": { @@ -13686,12 +13683,6 @@ "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", "dev": true }, - "fast-deep-equal": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", - "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", - "dev": true - }, "find-cache-dir": { "version": "3.3.1", "resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-3.3.1.tgz", @@ -14041,9 +14032,9 @@ "dev": true }, "typescript": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.0.2.tgz", - "integrity": "sha512-e4ERvRV2wb+rRZ/IQeb3jm2VxBsirQLpQhdxplZ2MEzGvDkkMmPglecnNDfSUBivMjP93vRbngYYDQqQ/78bcQ==", + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.0.3.tgz", + "integrity": "sha512-tEu6DGxGgRJPb/mVPIZ48e69xCn2yRmCgYmDugAVwmJ6o+0u1RI18eO7E7WBTLYLaEVVOhwQmcdhQHweux/WPg==", "dev": true }, "unicode-canonical-property-names-ecmascript": { diff --git a/package.json b/package.json index 36f6129..56caede 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "homepage": "https://github.com/Dreamacro/clash-dashboard", "scripts": { "start": "node scripts/start.js", - "build": "node scripts/build.js", + "build": "GENERATE_SOURCEMAP=false node scripts/build.js", "lint": "npm run lint:ts", "lint:ts": "eslint --ext=jsx,ts,tsx --fix src", "contributors:add": "all-contributors add", @@ -29,15 +29,15 @@ "@svgr/webpack": "^5.4.0", "@types/classnames": "^2.2.10", "@types/lodash": "^4.14.161", - "@types/node": "^14.11.1", + "@types/node": "^14.11.2", "@types/react": "^16.9.0", "@types/react-dom": "^16.9.0", "@types/react-router-dom": "^5.1.5", "@types/react-table": "^7.0.23", "@types/react-virtualized-auto-sizer": "^1.0.0", "@types/react-window": "^1.8.2", - "@typescript-eslint/eslint-plugin": "^4.1.1", - "@typescript-eslint/parser": "^4.1.1", + "@typescript-eslint/eslint-plugin": "^4.2.0", + "@typescript-eslint/parser": "^4.2.0", "babel-eslint": "10.1.0", "babel-loader": "8.1.0", "babel-plugin-named-asset-import": "^0.3.6", @@ -53,11 +53,11 @@ "eslint-plugin-flowtype": "^5.2.0", "eslint-plugin-import": "^2.22.0", "eslint-plugin-jsx-a11y": "^6.3.1", - "eslint-plugin-react": "^7.20.6", + "eslint-plugin-react": "^7.21.2", "eslint-plugin-react-hooks": "^4.1.2", "file-loader": "^6.1.0", "fs-extra": "^9.0.1", - "html-webpack-plugin": "^4.4.1", + "html-webpack-plugin": "^4.5.0", "identity-obj-proxy": "3.0.0", "mini-css-extract-plugin": "^0.11.2", "optimize-css-assets-webpack-plugin": "^5.0.4", @@ -75,11 +75,11 @@ "sass-loader": "^10.0.2", "semver": "^7.3.2", "style-loader": "^1.2.1", - "terser-webpack-plugin": "^4.2.1", + "terser-webpack-plugin": "^4.2.2", "ts-pnp": "^1.2.0", "tsconfig-paths-webpack-plugin": "^3.3.0", "type-fest": "^0.16.0", - "typescript": "^4.0.2", + "typescript": "^4.0.3", "url-loader": "^4.1.0", "webpack": "^4.44.2", "webpack-dev-server": "3.11.0", @@ -96,11 +96,11 @@ "react": "^16.13.1", "react-dom": "^16.13.1", "react-router-dom": "^5.2.0", - "react-table": "^7.5.0", + "react-table": "^7.5.1", "react-virtualized-auto-sizer": "^1.0.2", "react-window": "^1.8.5", "recoil": "0.0.13", - "swr": "^0.3.2", + "swr": "^0.3.5", "use-immer": "^0.4.1" }, "browserslist": { diff --git a/src/components/Modal/index.tsx b/src/components/Modal/index.tsx index a7e4b11..cbe29ca 100644 --- a/src/components/Modal/index.tsx +++ b/src/components/Modal/index.tsx @@ -48,8 +48,8 @@ export function Modal (props: ModalProps) { children } = props - const { useTranslation } = useI18n() - const { t } = useTranslation('Modal') + const { translation } = useI18n() + const { t } = translation('Modal') const portalRef = useRef(document.createElement('div')) const maskRef = useRef(null) diff --git a/src/components/Tags/index.tsx b/src/components/Tags/index.tsx index 5f51454..fb26729 100644 --- a/src/components/Tags/index.tsx +++ b/src/components/Tags/index.tsx @@ -17,8 +17,8 @@ interface TagsProps extends BaseComponentProps { export function Tags (props: TagsProps) { const { className, data, onClick, select, canClick, errSet, rowHeight: rawHeight } = props - const { useTranslation } = useI18n() - const { t } = useTranslation('Proxies') + const { translation } = useI18n() + const { t } = translation('Proxies') const [expand, setExpand] = useState(false) const [showExtend, setShowExtend] = useState(false) diff --git a/src/containers/Connections/index.tsx b/src/containers/Connections/index.tsx index 5f021f2..7b32264 100644 --- a/src/containers/Connections/index.tsx +++ b/src/containers/Connections/index.tsx @@ -63,8 +63,8 @@ function formatSpeed (upload: number, download: number) { } export default function Connections () { - const { useTranslation, lang } = useI18n() - const t = useTranslation('Connections').t + const { translation, lang } = useI18n() + const t = useMemo(() => translation('Connections').t, [translation]) // total const [traffic, setTraffic] = useObject({ diff --git a/src/containers/Connections/store.ts b/src/containers/Connections/store.ts index ccbfa46..c3e2d57 100644 --- a/src/containers/Connections/store.ts +++ b/src/containers/Connections/store.ts @@ -1,5 +1,5 @@ import * as API from '@lib/request' -import { useState, useMemo, useRef } from 'react' +import { useState, useMemo, useRef, useCallback } from 'react' type Connections = API.Connections & { completed?: boolean, speed: { upload: number, download: number } } @@ -64,16 +64,16 @@ export function useConnections () { const [connections, setConnections] = useState([]) const [save, setSave] = useState(false) - function feed (connections: API.Connections[]) { + const feed = useCallback(function (connections: API.Connections[]) { store.appendToSet(connections) if (shouldFlush.current) { setConnections(store.getConnections()) } shouldFlush.current = !shouldFlush.current - } + }, [store]) - function toggleSave () { + const toggleSave = useCallback(function () { const state = store.toggleSave() setSave(state) @@ -82,7 +82,7 @@ export function useConnections () { } shouldFlush.current = true - } + }, [store]) return { connections, feed, toggleSave, save } } diff --git a/src/containers/ExternalControllerDrawer/index.tsx b/src/containers/ExternalControllerDrawer/index.tsx index 8cc708d..35cb387 100644 --- a/src/containers/ExternalControllerDrawer/index.tsx +++ b/src/containers/ExternalControllerDrawer/index.tsx @@ -5,8 +5,8 @@ import { useI18n, useAPIInfo, useIdentity } from '@stores' import './style.scss' export default function ExternalController () { - const { useTranslation } = useI18n() - const { t } = useTranslation('Settings') + const { translation } = useI18n() + const { t } = translation('Settings') const { data: info, update, fetch } = useAPIInfo() const { identity, set: setIdentity } = useIdentity() const [value, set] = useObject({ diff --git a/src/containers/Logs/index.tsx b/src/containers/Logs/index.tsx index ff1d0e6..fd61e9b 100644 --- a/src/containers/Logs/index.tsx +++ b/src/containers/Logs/index.tsx @@ -11,8 +11,8 @@ export default function Logs () { const listRef = useRef(null) const logsRef = useRef([]) const [logs, setLogs] = useState([]) - const { useTranslation } = useI18n() - const { t } = useTranslation('Logs') + const { translation } = useI18n() + const { t } = translation('Logs') useLayoutEffect(() => { const ul = listRef.current diff --git a/src/containers/Proxies/components/Provider/index.tsx b/src/containers/Proxies/components/Provider/index.tsx index 82945b7..622fd01 100644 --- a/src/containers/Proxies/components/Provider/index.tsx +++ b/src/containers/Proxies/components/Provider/index.tsx @@ -15,10 +15,10 @@ interface ProvidersProps { export function Provider (props: ProvidersProps) { const { update } = useProxyProviders() - const { useTranslation, lang } = useI18n() + const { translation, lang } = useI18n() const { provider } = props - const { t } = useTranslation('Proxies') + const { t } = translation('Proxies') const { visible, hide, show } = useVisible() diff --git a/src/containers/Proxies/index.tsx b/src/containers/Proxies/index.tsx index 63663af..c14252f 100644 --- a/src/containers/Proxies/index.tsx +++ b/src/containers/Proxies/index.tsx @@ -30,8 +30,8 @@ function ProxyGroups () { const { groups, global } = useProxy() const { data: config, set: setConfig } = useConfig() const { general } = useGeneral() - const { useTranslation } = useI18n() - const { t } = useTranslation('Proxies') + const { translation } = useI18n() + const { t } = translation('Proxies') const list = useMemo( () => general.mode === 'global' ? [global] : groups, @@ -68,7 +68,7 @@ function ProxyGroups () { function ProxyProviders () { const { providers } = useProxyProviders() - const { useTranslation } = useI18n() + const { translation: useTranslation } = useI18n() const { t } = useTranslation('Proxies') return <> @@ -92,7 +92,7 @@ function ProxyProviders () { function Proxies () { const { proxies } = useProxy() - const { useTranslation } = useI18n() + const { translation: useTranslation } = useI18n() const { t } = useTranslation('Proxies') function handleNotitySpeedTest () { diff --git a/src/containers/Rules/Provider/index.tsx b/src/containers/Rules/Provider/index.tsx index ed210f0..3f4a597 100644 --- a/src/containers/Rules/Provider/index.tsx +++ b/src/containers/Rules/Provider/index.tsx @@ -13,10 +13,10 @@ interface ProvidersProps { export function Provider (props: ProvidersProps) { const { update } = useRuleProviders() - const { useTranslation, lang } = useI18n() + const { translation, lang } = useI18n() const { provider } = props - const { t } = useTranslation('Rules') + const { t } = translation('Rules') const { visible, hide, show } = useVisible() diff --git a/src/containers/Rules/index.tsx b/src/containers/Rules/index.tsx index e6b8146..c876780 100644 --- a/src/containers/Rules/index.tsx +++ b/src/containers/Rules/index.tsx @@ -9,8 +9,8 @@ import './style.scss' function RuleProviders () { const { providers } = useRuleProviders() - const { useTranslation } = useI18n() - const { t } = useTranslation('Rules') + const { translation } = useI18n() + const { t } = translation('Rules') return <> { @@ -33,8 +33,8 @@ function RuleProviders () { export default function Rules () { const { rules, update } = useRule() - const { useTranslation } = useI18n() - const { t } = useTranslation('Rules') + const { translation } = useI18n() + const { t } = translation('Rules') useSWR('rules', update) diff --git a/src/containers/Settings/index.tsx b/src/containers/Settings/index.tsx index eba8d4c..235b97d 100644 --- a/src/containers/Settings/index.tsx +++ b/src/containers/Settings/index.tsx @@ -17,8 +17,8 @@ export default function Settings () { const { general, update: fetchGeneral } = useGeneral() const { set: setIdentity } = useIdentity() const { data: apiInfo } = useAPIInfo() - const { useTranslation, setLang, lang } = useI18n() - const { t } = useTranslation('Settings') + const { translation, setLang, lang } = useI18n() + const { t } = translation('Settings') const [info, set] = useObject({ socks5ProxyPort: 7891, httpProxyPort: 7890, diff --git a/src/containers/Sidebar/index.tsx b/src/containers/Sidebar/index.tsx index 817f1ac..40e75a6 100644 --- a/src/containers/Sidebar/index.tsx +++ b/src/containers/Sidebar/index.tsx @@ -18,10 +18,10 @@ interface SidebarProps { export default function Sidebar (props: SidebarProps) { const { routes } = props - const { useTranslation } = useI18n() + const { translation } = useI18n() const { version, premium, update } = useVersion() const { data } = useClashXData() - const { t } = useTranslation('SideBar') + const { t } = translation('SideBar') useSWR('version', update) diff --git a/src/stores/recoil.ts b/src/stores/recoil.ts index 5e70958..5f90343 100644 --- a/src/stores/recoil.ts +++ b/src/stores/recoil.ts @@ -50,7 +50,7 @@ export function useI18n () { setLanguage(lang) } - const useTranslation = useCallback( + const translation = useCallback( function (namespace: keyof typeof Language['en_US']) { function t (path: string) { return get(Language[lang][namespace], path) as string @@ -60,7 +60,7 @@ export function useI18n () { [lang] ) - return { lang, locales, setLang, useTranslation } + return { lang, locales, setLang, translation } } export const version = atom({ @@ -170,7 +170,7 @@ export const proxies = atom({ export function useProxy () { const [allProxy, set] = useRecoilObjectWithImmer(proxies) - const { mutate } = swr(['/proxies', set], async () => { + const { mutate } = swr('/proxies', async () => { const allProxies = await API.getProxies() const global = allProxies.data.proxies.GLOBAL as API.Group