From 89cdf84e23c55a75e3acefc56d740f0c3811fafa Mon Sep 17 00:00:00 2001 From: ccagml Date: Thu, 8 Dec 2022 21:36:45 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E4=B8=AD=E6=96=87?= =?UTF-8?q?=E9=A2=98=E8=A7=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 305 ++++++++---------- package.json | 11 +- src/controller/TreeViewController.ts | 65 ++-- src/extension.ts | 2 +- src/model/Model.ts | 6 - src/rpc/actionChain/chainNode/core.ts | 65 ++-- src/rpc/actionChain/chainNode/leetcode.cn.ts | 141 +++++++- src/rpc/actionChain/chainNode/leetcode.ts | 178 +++++++--- .../actionChain/chainNode/solution.discuss.ts | 106 +----- src/rpc/actionChain/chainNodeBase.ts | 3 + src/rpc/factory/api/listApi.ts | 91 ------ src/rpc/factory/api/queryApi.ts | 53 +++ src/rpc/factory/api/submissionApi.ts | 156 --------- src/rpc/factory/apiFactory.ts | 4 +- src/service/ExecuteService.ts | 11 +- src/service/FileButtonService.ts | 2 +- src/service/SolutionService.ts | 31 +- thirdpartynotice.txt | 29 -- 18 files changed, 569 insertions(+), 690 deletions(-) delete mode 100644 src/rpc/factory/api/listApi.ts delete mode 100644 src/rpc/factory/api/submissionApi.ts diff --git a/package-lock.json b/package-lock.json index d3bc904..2ad93b5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "vscode-leetcode-problem-rating", - "version": "2.7.3", + "version": "2.8.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "vscode-leetcode-problem-rating", - "version": "2.7.3", + "version": "2.8.1", "license": "MIT", "dependencies": { "ansi-styles": "3.2.1", @@ -22,7 +22,6 @@ "prompt": "^1.2.0", "request": "2.88.0", "underscore": "1.12.1", - "unescape-js": "^1.1.4", "wordwrap": "1.0.0" }, "devDependencies": { @@ -243,9 +242,9 @@ "dev": true }, "node_modules/@types/lodash": { - "version": "4.14.189", - "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.189.tgz", - "integrity": "sha512-kb9/98N6X8gyME9Cf7YaqIMvYGnBSWqEci6tiettE6iJWH1XdJz/PO8LB0GtLCG7x8dU3KWhZT+lA1a35127tA==", + "version": "4.14.191", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.191.tgz", + "integrity": "sha512-BdZ5BCCvho3EIXw6wUCXHe7rS53AIDPLE+JzwgT+OsJk53oBfbSmZZ7CX4VaRoN78N+TJpFi9QPlfIVNmJYWxQ==", "dev": true }, "node_modules/@types/markdown-it": { @@ -258,9 +257,9 @@ } }, "node_modules/@types/node": { - "version": "14.18.33", - "resolved": "https://registry.npmjs.org/@types/node/-/node-14.18.33.tgz", - "integrity": "sha512-qelS/Ra6sacc4loe/3MSjXNL1dNQ/GjxNHVzuChwMfmk7HuycRLVQN2qNY3XahK+fZc5E2szqQSKUyAF0E+2bg==", + "version": "14.18.34", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.18.34.tgz", + "integrity": "sha512-hcU9AIQVHmPnmjRK+XUUYlILlr9pQrsqSrwov/JK1pnf3GTQowVBhx54FbvM0AU/VXGH4i3+vgXS5EguR7fysA==", "dev": true }, "node_modules/@types/semver": { @@ -276,14 +275,14 @@ "dev": true }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "5.43.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.43.0.tgz", - "integrity": "sha512-wNPzG+eDR6+hhW4yobEmpR36jrqqQv1vxBq5LJO3fBAktjkvekfr4BRl+3Fn1CM/A+s8/EiGUbOMDoYqWdbtXA==", + "version": "5.45.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.45.1.tgz", + "integrity": "sha512-cOizjPlKEh0bXdFrBLTrI/J6B/QMlhwE9auOov53tgB+qMukH6/h8YAK/qw+QJGct/PTbdh2lytGyipxCcEtAw==", "dev": true, "dependencies": { - "@typescript-eslint/scope-manager": "5.43.0", - "@typescript-eslint/type-utils": "5.43.0", - "@typescript-eslint/utils": "5.43.0", + "@typescript-eslint/scope-manager": "5.45.1", + "@typescript-eslint/type-utils": "5.45.1", + "@typescript-eslint/utils": "5.45.1", "debug": "^4.3.4", "ignore": "^5.2.0", "natural-compare-lite": "^1.4.0", @@ -309,14 +308,14 @@ } }, "node_modules/@typescript-eslint/parser": { - "version": "5.43.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.43.0.tgz", - "integrity": "sha512-2iHUK2Lh7PwNUlhFxxLI2haSDNyXvebBO9izhjhMoDC+S3XI9qt2DGFUsiJ89m2k7gGYch2aEpYqV5F/+nwZug==", + "version": "5.45.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.45.1.tgz", + "integrity": "sha512-JQ3Ep8bEOXu16q0ztsatp/iQfDCtvap7sp/DKo7DWltUquj5AfCOpX2zSzJ8YkAVnrQNqQ5R62PBz2UtrfmCkA==", "dev": true, "dependencies": { - "@typescript-eslint/scope-manager": "5.43.0", - "@typescript-eslint/types": "5.43.0", - "@typescript-eslint/typescript-estree": "5.43.0", + "@typescript-eslint/scope-manager": "5.45.1", + "@typescript-eslint/types": "5.45.1", + "@typescript-eslint/typescript-estree": "5.45.1", "debug": "^4.3.4" }, "engines": { @@ -336,13 +335,13 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "5.43.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.43.0.tgz", - "integrity": "sha512-XNWnGaqAtTJsUiZaoiGIrdJYHsUOd3BZ3Qj5zKp9w6km6HsrjPk/TGZv0qMTWyWj0+1QOqpHQ2gZOLXaGA9Ekw==", + "version": "5.45.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.45.1.tgz", + "integrity": "sha512-D6fCileR6Iai7E35Eb4Kp+k0iW7F1wxXYrOhX/3dywsOJpJAQ20Fwgcf+P/TDtvQ7zcsWsrJaglaQWDhOMsspQ==", "dev": true, "dependencies": { - "@typescript-eslint/types": "5.43.0", - "@typescript-eslint/visitor-keys": "5.43.0" + "@typescript-eslint/types": "5.45.1", + "@typescript-eslint/visitor-keys": "5.45.1" }, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -353,13 +352,13 @@ } }, "node_modules/@typescript-eslint/type-utils": { - "version": "5.43.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.43.0.tgz", - "integrity": "sha512-K21f+KY2/VvYggLf5Pk4tgBOPs2otTaIHy2zjclo7UZGLyFH86VfUOm5iq+OtDtxq/Zwu2I3ujDBykVW4Xtmtg==", + "version": "5.45.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.45.1.tgz", + "integrity": "sha512-aosxFa+0CoYgYEl3aptLe1svP910DJq68nwEJzyQcrtRhC4BN0tJAvZGAe+D0tzjJmFXe+h4leSsiZhwBa2vrA==", "dev": true, "dependencies": { - "@typescript-eslint/typescript-estree": "5.43.0", - "@typescript-eslint/utils": "5.43.0", + "@typescript-eslint/typescript-estree": "5.45.1", + "@typescript-eslint/utils": "5.45.1", "debug": "^4.3.4", "tsutils": "^3.21.0" }, @@ -380,9 +379,9 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "5.43.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.43.0.tgz", - "integrity": "sha512-jpsbcD0x6AUvV7tyOlyvon0aUsQpF8W+7TpJntfCUWU1qaIKu2K34pMwQKSzQH8ORgUrGYY6pVIh1Pi8TNeteg==", + "version": "5.45.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.45.1.tgz", + "integrity": "sha512-HEW3U0E5dLjUT+nk7b4lLbOherS1U4ap+b9pfu2oGsW3oPu7genRaY9dDv3nMczC1rbnRY2W/D7SN05wYoGImg==", "dev": true, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -393,13 +392,13 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "5.43.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.43.0.tgz", - "integrity": "sha512-BZ1WVe+QQ+igWal2tDbNg1j2HWUkAa+CVqdU79L4HP9izQY6CNhXfkNwd1SS4+sSZAP/EthI1uiCSY/+H0pROg==", + "version": "5.45.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.45.1.tgz", + "integrity": "sha512-76NZpmpCzWVrrb0XmYEpbwOz/FENBi+5W7ipVXAsG3OoFrQKJMiaqsBMbvGRyLtPotGqUfcY7Ur8j0dksDJDng==", "dev": true, "dependencies": { - "@typescript-eslint/types": "5.43.0", - "@typescript-eslint/visitor-keys": "5.43.0", + "@typescript-eslint/types": "5.45.1", + "@typescript-eslint/visitor-keys": "5.45.1", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", @@ -420,16 +419,16 @@ } }, "node_modules/@typescript-eslint/utils": { - "version": "5.43.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.43.0.tgz", - "integrity": "sha512-8nVpA6yX0sCjf7v/NDfeaOlyaIIqL7OaIGOWSPFqUKK59Gnumd3Wa+2l8oAaYO2lk0sO+SbWFWRSvhu8gLGv4A==", + "version": "5.45.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.45.1.tgz", + "integrity": "sha512-rlbC5VZz68+yjAzQBc4I7KDYVzWG2X/OrqoZrMahYq3u8FFtmQYc+9rovo/7wlJH5kugJ+jQXV5pJMnofGmPRw==", "dev": true, "dependencies": { "@types/json-schema": "^7.0.9", "@types/semver": "^7.3.12", - "@typescript-eslint/scope-manager": "5.43.0", - "@typescript-eslint/types": "5.43.0", - "@typescript-eslint/typescript-estree": "5.43.0", + "@typescript-eslint/scope-manager": "5.45.1", + "@typescript-eslint/types": "5.45.1", + "@typescript-eslint/typescript-estree": "5.45.1", "eslint-scope": "^5.1.1", "eslint-utils": "^3.0.0", "semver": "^7.3.7" @@ -446,12 +445,12 @@ } }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "5.43.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.43.0.tgz", - "integrity": "sha512-icl1jNH/d18OVHLfcwdL3bWUKsBeIiKYTGxMJCoGe7xFht+E4QgzOqoWYrU8XSLJWhVw8nTacbm03v23J/hFTg==", + "version": "5.45.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.45.1.tgz", + "integrity": "sha512-cy9ln+6rmthYWjH9fmx+5FU/JDpjQb586++x2FZlveq7GdGuLLW9a2Jcst2TGekH82bXpfmRNSwP9tyEs6RjvQ==", "dev": true, "dependencies": { - "@typescript-eslint/types": "5.43.0", + "@typescript-eslint/types": "5.45.1", "eslint-visitor-keys": "^3.3.0" }, "engines": { @@ -1045,9 +1044,9 @@ } }, "node_modules/eslint": { - "version": "8.27.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.27.0.tgz", - "integrity": "sha512-0y1bfG2ho7mty+SiILVf9PfuRA49ek4Nc60Wmmu62QlobNR+CeXa4xXIJgcuwSQgZiWaPH+5BDsctpIW0PR/wQ==", + "version": "8.29.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.29.0.tgz", + "integrity": "sha512-isQ4EEiyUjZFbEKvEGJKKGBwXtvXX+zJbkVKCgTuB9t/+jUBcy8avhkEwWJecI15BkRkOYmvIM5ynbhRjEkoeg==", "dev": true, "dependencies": { "@eslint/eslintrc": "^1.3.3", @@ -1327,9 +1326,9 @@ "dev": true }, "node_modules/fastq": { - "version": "1.13.0", - "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.13.0.tgz", - "integrity": "sha512-YpkpUnK8od0o1hmeSc7UUs/eB/vIPWJYjKck2QKIzAf71Vm1AAQ3EbuZB3g2JIy+pg+ERD0vqI79KyZiB2e2Nw==", + "version": "1.14.0", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.14.0.tgz", + "integrity": "sha512-eR2D+V9/ExcbF9ls441yIuN6TI2ED1Y2ZcA5BmMtJsOkWOFRJQ0Jt0g1UwqXJJVAb+V+umH5Dfr8oh4EVP7VVg==", "dev": true, "dependencies": { "reusify": "^1.0.4" @@ -1634,9 +1633,9 @@ } }, "node_modules/ignore": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.0.tgz", - "integrity": "sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ==", + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.1.tgz", + "integrity": "sha512-d2qQLzTJ9WxQftPAuEQpSPmKqzxePjzVbpAVv62AQ64NTL+wR4JkrVqR/LqFsFEUsHDAiId52mJteHDFuDkElA==", "dev": true, "engines": { "node": ">= 4" @@ -1767,10 +1766,14 @@ "integrity": "sha512-Yljz7ffyPbrLpLngrMtZ7NduUgVvi6wG9RJ9IUcyCd59YQ911PBJphODUcbOVbqYfxe1wuYf/LJ8PauMRwsM/g==" }, "node_modules/js-sdsl": { - "version": "4.1.5", - "resolved": "https://registry.npmjs.org/js-sdsl/-/js-sdsl-4.1.5.tgz", - "integrity": "sha512-08bOAKweV2NUC1wqTtf3qZlnpOX/R2DU9ikpjOHs0H+ibQv3zpncVQg6um4uYtRtrwIX8M4Nh3ytK4HGlYAq7Q==", - "dev": true + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/js-sdsl/-/js-sdsl-4.2.0.tgz", + "integrity": "sha512-dyBIzQBDkCqCu+0upx25Y2jGdbTGxE9fshMsCdK0ViOongpV+n5tXRcZY9v7CaVQ79AGS9KA1KHtojxiM7aXSQ==", + "dev": true, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/js-sdsl" + } }, "node_modules/js-tokens": { "version": "4.0.0", @@ -2134,9 +2137,9 @@ } }, "node_modules/parse5": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/parse5/-/parse5-7.1.1.tgz", - "integrity": "sha512-kwpuwzB+px5WUg9pyK0IcK/shltJN5/OVhQagxhCQNtT9Y9QRZqNY2e1cmbu/paRh5LMnz/oVTVLBpjFmMZhSg==", + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-7.1.2.tgz", + "integrity": "sha512-Czj1WaSVpaoj0wbhMzLmWD69anp2WH7FXMB9n1Sy8/ZFF9jolSQVMu1Ij5WIyGmcBmhk7EOndpO4mIpihVqAXw==", "dependencies": { "entities": "^4.4.0" }, @@ -2234,9 +2237,9 @@ } }, "node_modules/prettier": { - "version": "2.7.1", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.7.1.tgz", - "integrity": "sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g==", + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.1.tgz", + "integrity": "sha512-lqGoSJBQNJidqCHE80vqZJHWHRFoNYsSpP9AjFhlhi9ODCJA541svILes/+/1GM3VaL/abZi7cpFzOpdR9UPKg==", "dev": true, "bin": { "prettier": "bin-prettier.js" @@ -2575,11 +2578,6 @@ "node": ">=8" } }, - "node_modules/string.fromcodepoint": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/string.fromcodepoint/-/string.fromcodepoint-0.2.1.tgz", - "integrity": "sha512-n69H31OnxSGSZyZbgBlvYIXlrMhJQ0dQAX1js1QDhpaUH6zmU3QYlj07bCwCNlPOu3oRXIubGPl2gDGnHsiCqg==" - }, "node_modules/strip-ansi": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", @@ -2857,9 +2855,9 @@ } }, "node_modules/typescript": { - "version": "4.9.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.3.tgz", - "integrity": "sha512-CIfGzTelbKNEnLpLdGFgdyKhG23CKdKgQPOBc+OUNrkJ2vr+KSzsSV5kq5iWhEQbok+quxgGzrAtGWCyU7tHnA==", + "version": "4.9.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.4.tgz", + "integrity": "sha512-Uz+dTXYzxXXbsFpM86Wh3dKCxrQqUcVMxwU54orwlJjOpO3ao8L7j5lH+dWfTwgCwIuM9GQ2kvVotzYJMXTBZg==", "dev": true, "bin": { "tsc": "bin/tsc", @@ -2879,14 +2877,6 @@ "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.12.1.tgz", "integrity": "sha512-hEQt0+ZLDVUMhebKxL4x1BTtDY7bavVofhZ9KZ4aI26X9SRaE+Y3m83XUL1UP2jn8ynjndwCCpEHdUG+9pP1Tw==" }, - "node_modules/unescape-js": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/unescape-js/-/unescape-js-1.1.4.tgz", - "integrity": "sha512-42SD8NOQEhdYntEiUQdYq/1V/YHwr1HLwlHuTJB5InVVdOSbgI6xu8jK5q65yIzuFCfczzyDF/7hbGzVbyCw0g==", - "dependencies": { - "string.fromcodepoint": "^0.2.1" - } - }, "node_modules/universalify": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", @@ -3244,9 +3234,9 @@ "dev": true }, "@types/lodash": { - "version": "4.14.189", - "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.189.tgz", - "integrity": "sha512-kb9/98N6X8gyME9Cf7YaqIMvYGnBSWqEci6tiettE6iJWH1XdJz/PO8LB0GtLCG7x8dU3KWhZT+lA1a35127tA==", + "version": "4.14.191", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.191.tgz", + "integrity": "sha512-BdZ5BCCvho3EIXw6wUCXHe7rS53AIDPLE+JzwgT+OsJk53oBfbSmZZ7CX4VaRoN78N+TJpFi9QPlfIVNmJYWxQ==", "dev": true }, "@types/markdown-it": { @@ -3259,9 +3249,9 @@ } }, "@types/node": { - "version": "14.18.33", - "resolved": "https://registry.npmjs.org/@types/node/-/node-14.18.33.tgz", - "integrity": "sha512-qelS/Ra6sacc4loe/3MSjXNL1dNQ/GjxNHVzuChwMfmk7HuycRLVQN2qNY3XahK+fZc5E2szqQSKUyAF0E+2bg==", + "version": "14.18.34", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.18.34.tgz", + "integrity": "sha512-hcU9AIQVHmPnmjRK+XUUYlILlr9pQrsqSrwov/JK1pnf3GTQowVBhx54FbvM0AU/VXGH4i3+vgXS5EguR7fysA==", "dev": true }, "@types/semver": { @@ -3277,14 +3267,14 @@ "dev": true }, "@typescript-eslint/eslint-plugin": { - "version": "5.43.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.43.0.tgz", - "integrity": "sha512-wNPzG+eDR6+hhW4yobEmpR36jrqqQv1vxBq5LJO3fBAktjkvekfr4BRl+3Fn1CM/A+s8/EiGUbOMDoYqWdbtXA==", + "version": "5.45.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.45.1.tgz", + "integrity": "sha512-cOizjPlKEh0bXdFrBLTrI/J6B/QMlhwE9auOov53tgB+qMukH6/h8YAK/qw+QJGct/PTbdh2lytGyipxCcEtAw==", "dev": true, "requires": { - "@typescript-eslint/scope-manager": "5.43.0", - "@typescript-eslint/type-utils": "5.43.0", - "@typescript-eslint/utils": "5.43.0", + "@typescript-eslint/scope-manager": "5.45.1", + "@typescript-eslint/type-utils": "5.45.1", + "@typescript-eslint/utils": "5.45.1", "debug": "^4.3.4", "ignore": "^5.2.0", "natural-compare-lite": "^1.4.0", @@ -3294,53 +3284,53 @@ } }, "@typescript-eslint/parser": { - "version": "5.43.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.43.0.tgz", - "integrity": "sha512-2iHUK2Lh7PwNUlhFxxLI2haSDNyXvebBO9izhjhMoDC+S3XI9qt2DGFUsiJ89m2k7gGYch2aEpYqV5F/+nwZug==", + "version": "5.45.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.45.1.tgz", + "integrity": "sha512-JQ3Ep8bEOXu16q0ztsatp/iQfDCtvap7sp/DKo7DWltUquj5AfCOpX2zSzJ8YkAVnrQNqQ5R62PBz2UtrfmCkA==", "dev": true, "requires": { - "@typescript-eslint/scope-manager": "5.43.0", - "@typescript-eslint/types": "5.43.0", - "@typescript-eslint/typescript-estree": "5.43.0", + "@typescript-eslint/scope-manager": "5.45.1", + "@typescript-eslint/types": "5.45.1", + "@typescript-eslint/typescript-estree": "5.45.1", "debug": "^4.3.4" } }, "@typescript-eslint/scope-manager": { - "version": "5.43.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.43.0.tgz", - "integrity": "sha512-XNWnGaqAtTJsUiZaoiGIrdJYHsUOd3BZ3Qj5zKp9w6km6HsrjPk/TGZv0qMTWyWj0+1QOqpHQ2gZOLXaGA9Ekw==", + "version": "5.45.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.45.1.tgz", + "integrity": "sha512-D6fCileR6Iai7E35Eb4Kp+k0iW7F1wxXYrOhX/3dywsOJpJAQ20Fwgcf+P/TDtvQ7zcsWsrJaglaQWDhOMsspQ==", "dev": true, "requires": { - "@typescript-eslint/types": "5.43.0", - "@typescript-eslint/visitor-keys": "5.43.0" + "@typescript-eslint/types": "5.45.1", + "@typescript-eslint/visitor-keys": "5.45.1" } }, "@typescript-eslint/type-utils": { - "version": "5.43.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.43.0.tgz", - "integrity": "sha512-K21f+KY2/VvYggLf5Pk4tgBOPs2otTaIHy2zjclo7UZGLyFH86VfUOm5iq+OtDtxq/Zwu2I3ujDBykVW4Xtmtg==", + "version": "5.45.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.45.1.tgz", + "integrity": "sha512-aosxFa+0CoYgYEl3aptLe1svP910DJq68nwEJzyQcrtRhC4BN0tJAvZGAe+D0tzjJmFXe+h4leSsiZhwBa2vrA==", "dev": true, "requires": { - "@typescript-eslint/typescript-estree": "5.43.0", - "@typescript-eslint/utils": "5.43.0", + "@typescript-eslint/typescript-estree": "5.45.1", + "@typescript-eslint/utils": "5.45.1", "debug": "^4.3.4", "tsutils": "^3.21.0" } }, "@typescript-eslint/types": { - "version": "5.43.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.43.0.tgz", - "integrity": "sha512-jpsbcD0x6AUvV7tyOlyvon0aUsQpF8W+7TpJntfCUWU1qaIKu2K34pMwQKSzQH8ORgUrGYY6pVIh1Pi8TNeteg==", + "version": "5.45.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.45.1.tgz", + "integrity": "sha512-HEW3U0E5dLjUT+nk7b4lLbOherS1U4ap+b9pfu2oGsW3oPu7genRaY9dDv3nMczC1rbnRY2W/D7SN05wYoGImg==", "dev": true }, "@typescript-eslint/typescript-estree": { - "version": "5.43.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.43.0.tgz", - "integrity": "sha512-BZ1WVe+QQ+igWal2tDbNg1j2HWUkAa+CVqdU79L4HP9izQY6CNhXfkNwd1SS4+sSZAP/EthI1uiCSY/+H0pROg==", + "version": "5.45.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.45.1.tgz", + "integrity": "sha512-76NZpmpCzWVrrb0XmYEpbwOz/FENBi+5W7ipVXAsG3OoFrQKJMiaqsBMbvGRyLtPotGqUfcY7Ur8j0dksDJDng==", "dev": true, "requires": { - "@typescript-eslint/types": "5.43.0", - "@typescript-eslint/visitor-keys": "5.43.0", + "@typescript-eslint/types": "5.45.1", + "@typescript-eslint/visitor-keys": "5.45.1", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", @@ -3349,28 +3339,28 @@ } }, "@typescript-eslint/utils": { - "version": "5.43.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.43.0.tgz", - "integrity": "sha512-8nVpA6yX0sCjf7v/NDfeaOlyaIIqL7OaIGOWSPFqUKK59Gnumd3Wa+2l8oAaYO2lk0sO+SbWFWRSvhu8gLGv4A==", + "version": "5.45.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.45.1.tgz", + "integrity": "sha512-rlbC5VZz68+yjAzQBc4I7KDYVzWG2X/OrqoZrMahYq3u8FFtmQYc+9rovo/7wlJH5kugJ+jQXV5pJMnofGmPRw==", "dev": true, "requires": { "@types/json-schema": "^7.0.9", "@types/semver": "^7.3.12", - "@typescript-eslint/scope-manager": "5.43.0", - "@typescript-eslint/types": "5.43.0", - "@typescript-eslint/typescript-estree": "5.43.0", + "@typescript-eslint/scope-manager": "5.45.1", + "@typescript-eslint/types": "5.45.1", + "@typescript-eslint/typescript-estree": "5.45.1", "eslint-scope": "^5.1.1", "eslint-utils": "^3.0.0", "semver": "^7.3.7" } }, "@typescript-eslint/visitor-keys": { - "version": "5.43.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.43.0.tgz", - "integrity": "sha512-icl1jNH/d18OVHLfcwdL3bWUKsBeIiKYTGxMJCoGe7xFht+E4QgzOqoWYrU8XSLJWhVw8nTacbm03v23J/hFTg==", + "version": "5.45.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.45.1.tgz", + "integrity": "sha512-cy9ln+6rmthYWjH9fmx+5FU/JDpjQb586++x2FZlveq7GdGuLLW9a2Jcst2TGekH82bXpfmRNSwP9tyEs6RjvQ==", "dev": true, "requires": { - "@typescript-eslint/types": "5.43.0", + "@typescript-eslint/types": "5.45.1", "eslint-visitor-keys": "^3.3.0" } }, @@ -3810,9 +3800,9 @@ "dev": true }, "eslint": { - "version": "8.27.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.27.0.tgz", - "integrity": "sha512-0y1bfG2ho7mty+SiILVf9PfuRA49ek4Nc60Wmmu62QlobNR+CeXa4xXIJgcuwSQgZiWaPH+5BDsctpIW0PR/wQ==", + "version": "8.29.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.29.0.tgz", + "integrity": "sha512-isQ4EEiyUjZFbEKvEGJKKGBwXtvXX+zJbkVKCgTuB9t/+jUBcy8avhkEwWJecI15BkRkOYmvIM5ynbhRjEkoeg==", "dev": true, "requires": { "@eslint/eslintrc": "^1.3.3", @@ -4026,9 +4016,9 @@ "dev": true }, "fastq": { - "version": "1.13.0", - "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.13.0.tgz", - "integrity": "sha512-YpkpUnK8od0o1hmeSc7UUs/eB/vIPWJYjKck2QKIzAf71Vm1AAQ3EbuZB3g2JIy+pg+ERD0vqI79KyZiB2e2Nw==", + "version": "1.14.0", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.14.0.tgz", + "integrity": "sha512-eR2D+V9/ExcbF9ls441yIuN6TI2ED1Y2ZcA5BmMtJsOkWOFRJQ0Jt0g1UwqXJJVAb+V+umH5Dfr8oh4EVP7VVg==", "dev": true, "requires": { "reusify": "^1.0.4" @@ -4252,9 +4242,9 @@ } }, "ignore": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.0.tgz", - "integrity": "sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ==", + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.1.tgz", + "integrity": "sha512-d2qQLzTJ9WxQftPAuEQpSPmKqzxePjzVbpAVv62AQ64NTL+wR4JkrVqR/LqFsFEUsHDAiId52mJteHDFuDkElA==", "dev": true }, "import-fresh": { @@ -4352,9 +4342,9 @@ "integrity": "sha512-Yljz7ffyPbrLpLngrMtZ7NduUgVvi6wG9RJ9IUcyCd59YQ911PBJphODUcbOVbqYfxe1wuYf/LJ8PauMRwsM/g==" }, "js-sdsl": { - "version": "4.1.5", - "resolved": "https://registry.npmjs.org/js-sdsl/-/js-sdsl-4.1.5.tgz", - "integrity": "sha512-08bOAKweV2NUC1wqTtf3qZlnpOX/R2DU9ikpjOHs0H+ibQv3zpncVQg6um4uYtRtrwIX8M4Nh3ytK4HGlYAq7Q==", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/js-sdsl/-/js-sdsl-4.2.0.tgz", + "integrity": "sha512-dyBIzQBDkCqCu+0upx25Y2jGdbTGxE9fshMsCdK0ViOongpV+n5tXRcZY9v7CaVQ79AGS9KA1KHtojxiM7aXSQ==", "dev": true }, "js-tokens": { @@ -4641,9 +4631,9 @@ } }, "parse5": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/parse5/-/parse5-7.1.1.tgz", - "integrity": "sha512-kwpuwzB+px5WUg9pyK0IcK/shltJN5/OVhQagxhCQNtT9Y9QRZqNY2e1cmbu/paRh5LMnz/oVTVLBpjFmMZhSg==", + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-7.1.2.tgz", + "integrity": "sha512-Czj1WaSVpaoj0wbhMzLmWD69anp2WH7FXMB9n1Sy8/ZFF9jolSQVMu1Ij5WIyGmcBmhk7EOndpO4mIpihVqAXw==", "requires": { "entities": "^4.4.0" } @@ -4711,9 +4701,9 @@ "dev": true }, "prettier": { - "version": "2.7.1", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.7.1.tgz", - "integrity": "sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g==", + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.1.tgz", + "integrity": "sha512-lqGoSJBQNJidqCHE80vqZJHWHRFoNYsSpP9AjFhlhi9ODCJA541svILes/+/1GM3VaL/abZi7cpFzOpdR9UPKg==", "dev": true }, "prompt": { @@ -4930,11 +4920,6 @@ "strip-ansi": "^6.0.1" } }, - "string.fromcodepoint": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/string.fromcodepoint/-/string.fromcodepoint-0.2.1.tgz", - "integrity": "sha512-n69H31OnxSGSZyZbgBlvYIXlrMhJQ0dQAX1js1QDhpaUH6zmU3QYlj07bCwCNlPOu3oRXIubGPl2gDGnHsiCqg==" - }, "strip-ansi": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", @@ -5136,9 +5121,9 @@ "dev": true }, "typescript": { - "version": "4.9.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.3.tgz", - "integrity": "sha512-CIfGzTelbKNEnLpLdGFgdyKhG23CKdKgQPOBc+OUNrkJ2vr+KSzsSV5kq5iWhEQbok+quxgGzrAtGWCyU7tHnA==", + "version": "4.9.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.4.tgz", + "integrity": "sha512-Uz+dTXYzxXXbsFpM86Wh3dKCxrQqUcVMxwU54orwlJjOpO3ao8L7j5lH+dWfTwgCwIuM9GQ2kvVotzYJMXTBZg==", "dev": true }, "uc.micro": { @@ -5151,14 +5136,6 @@ "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.12.1.tgz", "integrity": "sha512-hEQt0+ZLDVUMhebKxL4x1BTtDY7bavVofhZ9KZ4aI26X9SRaE+Y3m83XUL1UP2jn8ynjndwCCpEHdUG+9pP1Tw==" }, - "unescape-js": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/unescape-js/-/unescape-js-1.1.4.tgz", - "integrity": "sha512-42SD8NOQEhdYntEiUQdYq/1V/YHwr1HLwlHuTJB5InVVdOSbgI6xu8jK5q65yIzuFCfczzyDF/7hbGzVbyCw0g==", - "requires": { - "string.fromcodepoint": "^0.2.1" - } - }, "universalify": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", diff --git a/package.json b/package.json index e811e4f..678b739 100644 --- a/package.json +++ b/package.json @@ -140,7 +140,7 @@ "icon": "$(search)" }, { - "command": "lcpr.showSolution", + "command": "lcpr.getHelp", "title": "获取题解", "category": "LeetCode" }, @@ -377,7 +377,7 @@ "group": "leetcode@2" }, { - "command": "lcpr.showSolution", + "command": "lcpr.getHelp", "when": "view == QuestionExplorer && viewItem =~ /problem*/", "group": "leetcode@3" }, @@ -412,7 +412,7 @@ "group": "leetcode@2" }, { - "command": "lcpr.showSolution", + "command": "lcpr.getHelp", "when": "view == BricksExplorer && viewItem =~ /nodebricks*/", "group": "leetcode@3" }, @@ -443,7 +443,7 @@ "when": "never" }, { - "command": "lcpr.showSolution", + "command": "lcpr.getHelp", "when": "never" }, { @@ -486,7 +486,7 @@ "group": "leetcode@2" }, { - "command": "lcpr.showSolution", + "command": "lcpr.getHelp", "group": "leetcode@3" }, { @@ -1142,7 +1142,6 @@ "prompt": "^1.2.0", "request": "2.88.0", "underscore": "1.12.1", - "unescape-js": "^1.1.4", "wordwrap": "1.0.0" } } diff --git a/src/controller/TreeViewController.ts b/src/controller/TreeViewController.ts index 2edb846..c5ad789 100644 --- a/src/controller/TreeViewController.ts +++ b/src/controller/TreeViewController.ts @@ -9,7 +9,6 @@ import * as lodash from "lodash"; import * as path from "path"; -import * as unescapeJS from "unescape-js"; import * as vscode from "vscode"; import { toNumber } from "lodash"; import { Disposable, Uri, window } from "vscode"; @@ -475,7 +474,7 @@ class TreeViewController implements Disposable { * It returns a list of problems * @returns An array of problems. */ - public async listProblems(): Promise { + public async getAllProblems(): Promise { try { if (statusBarService.getStatus() === UserStatus.SignedOut) { return []; @@ -483,7 +482,7 @@ class TreeViewController implements Disposable { const showLockedFlag: boolean = isShowLocked(); const useEndpointTranslation: boolean = isUseEndpointTranslation(); - const result: string = await executeService.listProblems(showLockedFlag, useEndpointTranslation); + const result: string = await executeService.getAllProblems(showLockedFlag, useEndpointTranslation); const all_problem_info = JSON.parse(result); const problems: IProblem[] = []; const AllScoreData = treeDataService.getScoreData(); @@ -561,12 +560,12 @@ class TreeViewController implements Disposable { label: `周赛期数查询`, detail: `周赛期数查询`, value: `contest`, + }, + { + label: `测试api`, + detail: `测试api`, + value: `testapi`, } - // { - // label: `测试api`, - // detail: `测试api`, - // value: `testapi`, - // } // , // { // label: `每日一题`, @@ -600,7 +599,7 @@ class TreeViewController implements Disposable { } } - public async showSolution(input: NodeModel | vscode.Uri): Promise { + public async getHelp(input: NodeModel | vscode.Uri): Promise { let problemInput: string | undefined; if (input instanceof NodeModel) { // Triggerred from explorer @@ -629,10 +628,36 @@ class TreeViewController implements Disposable { if (!language) { return; } + + const picks: Array> = []; + picks.push( + { + label: "获取中文站题解", + description: "", + detail: "", + value: "cn", + }, + { + label: "获取英文站题解", + description: "", + detail: "", + value: "en", + } + ); + const choice: IQuickItemEx | undefined = await vscode.window.showQuickPick(picks); + if (!choice) { + return; + } + try { const needTranslation: boolean = isUseEndpointTranslation(); - const solution: string = await executeService.showSolution(problemInput, language, needTranslation); - solutionService.show(unescapeJS(solution)); + const solution: string = await executeService.getHelp( + problemInput, + language, + needTranslation, + choice.value == "cn" + ); + solutionService.show(solution); } catch (error) { logOutput.appendLine(error.toString()); await promptForOpenOutputChannel("Failed to fetch the top voted solution. 请查看控制台信息~", OutPutType.error); @@ -645,16 +670,10 @@ class TreeViewController implements Disposable { return; } try { - const twoFactor: string | undefined = await vscode.window.showInputBox({ - prompt: "测试数据", - ignoreFocusOut: true, - validateInput: (s: string): string | undefined => (s && s.trim() ? undefined : "The input must not be empty"), - }); - + let problemInput = await this.getActiveFilePath(); // vscode.window.showErrorMessage(twoFactor || "输入错误"); - const solution: string = await executeService.getTestApi(twoFactor || ""); - const query_result = JSON.parse(solution); - console.log(query_result); + const solution: string = await executeService.getTestApi(problemInput || ""); + solutionService.show(solution); } catch (error) { logOutput.appendLine(error.toString()); await promptForOpenOutputChannel("Failed to fetch today question. 请查看控制台信息~", OutPutType.error); @@ -667,7 +686,7 @@ class TreeViewController implements Disposable { return; } const choice: IQuickItemEx | undefined = await vscode.window.showQuickPick( - this.parseProblemsToPicks(this.listProblems()), + this.parseProblemsToPicks(this.getAllProblems()), { matchOnDetail: true, matchOnDescription: true, @@ -688,7 +707,7 @@ class TreeViewController implements Disposable { } public async pickOne(): Promise { - const problems: IProblem[] = await this.listProblems(); + const problems: IProblem[] = await this.getAllProblems(); let randomProblem: IProblem; const user_score = statusBarService.getUserContestScore(); @@ -1053,7 +1072,7 @@ class TreeViewController implements Disposable { const temp_waitUserContest: boolean = this.waitUserContest; this.dispose(); let user_score = statusBarService.getUserContestScore(); - for (const problem of await this.listProblems()) { + for (const problem of await this.getAllProblems()) { this.explorerNodeMap.set(problem.id, new NodeModel(problem, true, user_score)); this.fidToQid.set(problem.id, problem.qid.toString()); this.qidToFid.set(problem.qid.toString(), problem.id); diff --git a/src/extension.ts b/src/extension.ts index f4e480d..e14ae03 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -71,7 +71,7 @@ export async function activate(context: ExtensionContext): Promise { commands.registerCommand("lcpr.deleteAllCache", () => loginContorller.deleteAllCache()), commands.registerCommand("leetcode.searchScoreRange", () => treeViewController.searchScoreRange()), commands.registerCommand("lcpr.searchProblem", () => treeViewController.searchProblem()), - commands.registerCommand("lcpr.showSolution", (input: NodeModel | Uri) => treeViewController.showSolution(input)), + commands.registerCommand("lcpr.getHelp", (input: NodeModel | Uri) => treeViewController.getHelp(input)), commands.registerCommand("lcpr.refreshExplorer", () => treeDataService.refresh()), commands.registerCommand("lcpr.testSolution", (uri?: Uri) => treeViewController.testSolution(uri)), commands.registerCommand("lcpr.testCaseDef", (uri?, allCase?) => treeViewController.testCaseDef(uri, allCase)), diff --git a/src/model/Model.ts b/src/model/Model.ts index 9462606..e11464a 100644 --- a/src/model/Model.ts +++ b/src/model/Model.ts @@ -180,12 +180,6 @@ export enum Category { Choice = "Choice", } -export const supportedPlugins: string[] = [ - // "company", - "solution.discuss", - "leetcode.cn", -]; - export enum DescriptionConfiguration { InWebView = "In Webview", InFileComment = "In File Comment", diff --git a/src/rpc/actionChain/chainNode/core.ts b/src/rpc/actionChain/chainNode/core.ts index 395f413..fa68770 100644 --- a/src/rpc/actionChain/chainNode/core.ts +++ b/src/rpc/actionChain/chainNode/core.ts @@ -17,9 +17,9 @@ import { configUtils } from "../../utils/configUtils"; import { ChainNodeBase } from "../chainNodeBase"; -function hasTag(o, tag) { - return Array.isArray(o) && o.some((x) => x.indexOf(tag.toLowerCase()) >= 0); -} +// function hasTag(o, tag) { +// return Array.isArray(o) && o.some((x) => x.indexOf(tag.toLowerCase()) >= 0); +// } /* It's a class that extends the ChainNodeBase class, and it has a bunch of methods that are called by the LeetCode CLI */ @@ -36,17 +36,17 @@ class CorePlugin extends ChainNodeBase { this.getProblems(!opts.dontTranslate, function (e, problems) { if (e) return cb(e); - for (let q of (opts.query || "").split("")) { - const f = QUERY_HANDLERS[q]; - if (!f) continue; - problems = problems.filter((x) => f(x, q)); - } + // for (let q of (opts.query || "").split("")) { + // const f = QUERY_HANDLERS[q]; + // if (!f) continue; + // problems = problems.filter((x) => f(x, q)); + // } - for (let t of opts.tag || []) { - problems = problems.filter(function (x) { - return x.category === t || hasTag(x.companies, t) || hasTag(x.tags, t); - }); - } + // for (let t of opts.tag || []) { + // problems = problems.filter(function (x) { + // return x.category === t || hasTag(x.companies, t) || hasTag(x.tags, t); + // }); + // } return cb(null, problems); }); @@ -139,27 +139,30 @@ class CorePlugin extends ChainNodeBase { return cb(null, result); }); }; + getHelp = (problem, cn_flag, lang) => { + this.getHelpOnline(problem, cn_flag, lang); + }; } -const isLevel = (x, q) => x.level[0].toLowerCase() === q.toLowerCase(); -const isACed = (x) => x.state === "ac"; -const isLocked = (x) => x.locked; -const isStarred = (x) => x.starred; +// const isLevel = (x, q) => x.level[0].toLowerCase() === q.toLowerCase(); +// const isACed = (x) => x.state === "ac"; +// const isLocked = (x) => x.locked; +// const isStarred = (x) => x.starred; /* It's a dictionary that maps the query to the function that filters the problems. */ -const QUERY_HANDLERS = { - e: isLevel, - E: _.negate(isLevel), - m: isLevel, - M: _.negate(isLevel), - h: isLevel, - H: _.negate(isLevel), - l: isLocked, - L: _.negate(isLocked), - d: isACed, - D: _.negate(isACed), - s: isStarred, - S: _.negate(isStarred), -}; +// const QUERY_HANDLERS = { +// e: isLevel, +// E: _.negate(isLevel), +// m: isLevel, +// M: _.negate(isLevel), +// h: isLevel, +// H: _.negate(isLevel), +// l: isLocked, +// L: _.negate(isLocked), +// d: isACed, +// D: _.negate(isACed), +// s: isStarred, +// S: _.negate(isStarred), +// }; export const corePlugin: CorePlugin = new CorePlugin(); diff --git a/src/rpc/actionChain/chainNode/leetcode.cn.ts b/src/rpc/actionChain/chainNode/leetcode.cn.ts index 2386245..c29d92c 100644 --- a/src/rpc/actionChain/chainNode/leetcode.cn.ts +++ b/src/rpc/actionChain/chainNode/leetcode.cn.ts @@ -14,7 +14,7 @@ let request = require("request"); import { configUtils } from "../../utils/configUtils"; import { sessionUtils } from "../../utils/sessionUtils"; - +import { reply } from "../../utils/ReplyUtils"; class LeetCodeCn extends ChainNodeBase { id = 15; name = "leetcode.cn"; @@ -192,17 +192,136 @@ class LeetCodeCn extends ChainNodeBase { /* A function that is used to test the api. */ // eslint-disable-next-line @typescript-eslint/no-unused-vars getTestApi = (value: any, _) => { - const _request = request.defaults({ jar: true }); - _request( - "https://zerotrac.github.io/leetcode_problem_rating/data.json", - function (error: any, info: any, body: any) { - console.log(error); - console.log(info); - let a = body; - console.log(a, value); - } - ); + console.log(value); + let question_slug = "determine-color-of-a-chessboard-square"; + let lang = "cpp"; + + getSolutionArticlesSlugList(question_slug, lang, (e, articles_slug) => { + if (e) return; + getSolutionBySlug(question_slug, articles_slug, lang); + }); }; + + getHelpOnline = (problem, cn_flag, lang) => { + if (cn_flag) { + getSolutionArticlesSlugList(problem.slug, lang, (e, articles_slug) => { + if (e) return; + getSolutionBySlug(problem.slug, articles_slug, lang); + }); + } else { + this.next.getHelpOnline(problem, cn_flag, lang); + } + }; +} + +function getSolutionBySlug(question_slug: string, articles_slug: string, lang: string) { + const opts = makeOpts(configUtils.sys.urls.graphql); + opts.headers.Origin = configUtils.sys.urls.base; + let URL_DISCUSS = "https://leetcode.cn/problems/$slug/solution/$articles_slug/"; + opts.headers.Referer = URL_DISCUSS.replace("$slug", question_slug).replace("$articles_slug", articles_slug); + + opts.json = true; + opts.body = { + operationName: "solutionDetailArticle", + variables: { slug: "pan-duan-guo-ji-xiang-qi-qi-pan-zhong-yi-8dv4", orderBy: "DEFAULT" }, + query: [ + "query solutionDetailArticle($slug: String!, $orderBy: SolutionArticleOrderBy!) {", + " solutionArticle(slug: $slug, orderBy: $orderBy) {", + " ...solutionArticle", + " content", + " question {", + " questionTitleSlug", + " __typename", + " }", + " __typename", + "}", + "}", + "fragment solutionArticle on SolutionArticleNode {", + " uuid", + " title", + " slug", + " identifier", + "author {", + " username", + " profile {", + " realName", + " __typename", + " }", + " __typename", + "}", + "byLeetcode", + "__typename", + "}", + ].join("\n"), + }; + + request.post(opts, function (_, __, body) { + // let bbb = body; + // console.log(bbb); + let solution = body.data.solutionArticle; + if (!solution) return reply.error("本题没有题解"); + + let link = URL_DISCUSS.replace("$slug", question_slug).replace("$articles_slug", articles_slug); + let content = solution.content.replace(/\\n/g, "\n").replace(/\\t/g, "\t"); + + let solution_result: any = {}; + solution_result.problem_name = "暂代题目名称"; + solution_result.title = solution.title; + solution_result.url = link; + solution_result.lang = lang; + solution_result.author = solution.author.username; + solution_result.votes = solution.voteCount; + solution_result.body = content; + reply.info(JSON.stringify({ code: 100, solution: solution_result })); + }); +} + +function getSolutionArticlesSlugList(question_slug: string, lang: string, cb) { + const opts = makeOpts(configUtils.sys.urls.graphql); + opts.headers.Origin = configUtils.sys.urls.base; + // let URL_DISCUSSES = "https://leetcode.com/graphql"; + let URL_DISCUSS = "https://leetcode.cn/problems/$slug/solution"; + opts.headers.Referer = URL_DISCUSS.replace("$slug", question_slug); + + opts.json = true; + opts.body = { + operationName: "questionSolutionArticles", + variables: { questionSlug: question_slug, first: 1, skip: 0, orderBy: "DEFAULT", tagSlugs: [lang] }, + query: [ + "query questionSolutionArticles($questionSlug: String!, $skip: Int, $first: Int, $orderBy: SolutionArticleOrderBy, $userInput: String, $tagSlugs: [String!]) {", + "questionSolutionArticles(questionSlug: $questionSlug, skip: $skip, first: $first, orderBy: $orderBy, userInput: $userInput, tagSlugs: $tagSlugs) {", + " totalNum", + " edges {", + " node {", + " ...solutionArticle", + " __typename", + " }", + " __typename", + " }", + " __typename", + " }", + "}", + "fragment solutionArticle on SolutionArticleNode {", + " uuid", + " slug", + " byLeetcode", + " __typename", + "}", + ].join("\n"), + }; + + request.post(opts, function (e, _, body) { + let edges = body?.data?.questionSolutionArticles?.edges || []; + let temp_result; + edges.forEach((element) => { + if (element?.node?.slug) { + temp_result = element?.node?.slug; + return; + } + }); + + cb(e, temp_result); + }); } function signOpts(opts: any, user: any) { diff --git a/src/rpc/actionChain/chainNode/leetcode.ts b/src/rpc/actionChain/chainNode/leetcode.ts index 531e330..51a5743 100644 --- a/src/rpc/actionChain/chainNode/leetcode.ts +++ b/src/rpc/actionChain/chainNode/leetcode.ts @@ -29,34 +29,6 @@ class LeetCode extends ChainNodeBase { super(); } - signOpts(opts, user) { - opts.headers.Cookie = "LEETCODE_SESSION=" + user.sessionId + ";csrftoken=" + user.sessionCSRF + ";"; - opts.headers["X-CSRFToken"] = user.sessionCSRF; - opts.headers["X-Requested-With"] = "XMLHttpRequest"; - } - - makeOpts(url) { - const opts: any = {}; - opts.url = url; - opts.headers = {}; - - if (sessionUtils.isLogin()) this.signOpts(opts, sessionUtils.getUser()); - return opts; - } - - checkError(e, resp, expectedStatus) { - if (!e && resp && resp.statusCode !== expectedStatus) { - const code = resp.statusCode; - - if (code === 403 || code === 401) { - e = sessionUtils.errors.EXPIRED; - } else { - e = { msg: "http error", statusCode: code }; - } - } - return e; - } - init() { configUtils.app = "leetcode"; } @@ -83,11 +55,11 @@ class LeetCode extends ChainNodeBase { /* Getting the problems from the category. */ getCategoryProblems = (category, cb) => { - const opts = this.makeOpts(configUtils.sys.urls.problems.replace("$category", category)); + const opts = makeOpts(configUtils.sys.urls.problems.replace("$category", category)); let that = this; request(opts, function (e, resp, body) { - e = that.checkError(e, resp, 200); + e = checkError(e, resp, 200); if (e) return cb(e); const json = JSON.parse(body); @@ -124,7 +96,7 @@ server to get the problem's description, test cases, and other information. */ const user = sessionUtils.getUser(); if (problem.locked && !user.paid) return cb("failed to load locked problem!"); - const opts = this.makeOpts(configUtils.sys.urls.graphql); + const opts = makeOpts(configUtils.sys.urls.graphql); opts.headers.Origin = configUtils.sys.urls.base; opts.headers.Referer = problem.link; @@ -151,7 +123,7 @@ server to get the problem's description, test cases, and other information. */ let that = this; request.post(opts, function (e, resp, body) { - e = that.checkError(e, resp, 200); + e = checkError(e, resp, 200); if (e) return cb(e); const q = body.data.question; @@ -192,7 +164,7 @@ server to get the problem's description, test cases, and other information. */ let that = this; request(opts, function (e, resp, body) { - e = that.checkError(e, resp, 200); + e = checkError(e, resp, 200); if (e) return cb(e); if (body.error) { @@ -219,7 +191,7 @@ server to get the problem's description, test cases, and other information. */ let that = this; request(opts, function (e, resp, body) { - e = that.checkError(e, resp, 200); + e = checkError(e, resp, 200); if (e) return cb(e); let result = JSON.parse(body); @@ -282,7 +254,7 @@ server to get the problem's description, test cases, and other information. */ /* Testing the code. */ testProblem = (problem, cb) => { - const opts = this.makeOpts(configUtils.sys.urls.test.replace("$slug", problem.slug)); + const opts = makeOpts(configUtils.sys.urls.test.replace("$slug", problem.slug)); opts.body = { data_input: problem.testcase }; let that = this; this.runCode(opts, problem, function (e, task) { @@ -303,7 +275,7 @@ server to get the problem's description, test cases, and other information. */ /* Submitting a problem to the server. */ submitProblem = (problem, cb) => { - const opts = this.makeOpts(configUtils.sys.urls.submit.replace("$slug", problem.slug)); + const opts = makeOpts(configUtils.sys.urls.submit.replace("$slug", problem.slug)); opts.body = { judge_type: "large" }; let that = this; this.runCode(opts, problem, function (e, task) { @@ -319,11 +291,11 @@ server to get the problem's description, test cases, and other information. */ /* Getting the submissions for a problem. */ getSubmissions = (problem, cb) => { - const opts = this.makeOpts(configUtils.sys.urls.submissions.replace("$slug", problem.slug)); + const opts = makeOpts(configUtils.sys.urls.submissions.replace("$slug", problem.slug)); opts.headers.Referer = configUtils.sys.urls.problem.replace("$slug", problem.slug); let that = this; request(opts, function (e, resp, body) { - e = that.checkError(e, resp, 200); + e = checkError(e, resp, 200); if (e) return cb(e); // FIXME: this only return the 1st 20 submissions, we should get next if necessary. @@ -337,10 +309,10 @@ server to get the problem's description, test cases, and other information. */ /* Getting the submission code and the runtime distribution chart. */ getSubmission = (submission, cb) => { - const opts = this.makeOpts(configUtils.sys.urls.submission.replace("$id", submission.id)); + const opts = makeOpts(configUtils.sys.urls.submission.replace("$id", submission.id)); let that = this; request(opts, function (e, resp, body) { - e = that.checkError(e, resp, 200); + e = checkError(e, resp, 200); if (e) return cb(e); let re = body.match(/submissionCode:\s('[^']*')/); @@ -356,7 +328,7 @@ server to get the problem's description, test cases, and other information. */ starProblem = (problem, starred, cb) => { const user = sessionUtils.getUser(); const operationName = starred ? "addQuestionToFavorite" : "removeQuestionFromFavorite"; - const opts = this.makeOpts(configUtils.sys.urls.graphql); + const opts = makeOpts(configUtils.sys.urls.graphql); opts.headers.Origin = configUtils.sys.urls.base; opts.headers.Referer = problem.link; @@ -370,7 +342,7 @@ server to get the problem's description, test cases, and other information. */ let that = this; // eslint-disable-next-line @typescript-eslint/no-unused-vars request.post(opts, function (e: any, resp: any, _) { - e = that.checkError(e, resp, 200); + e = checkError(e, resp, 200); if (e) return cb(e); return cb(null, starred); }); @@ -378,11 +350,11 @@ server to get the problem's description, test cases, and other information. */ /* Making a request to the server to get the favorites. */ getFavorites = (cb: any) => { - const opts = this.makeOpts(configUtils.sys.urls.favorites); + const opts = makeOpts(configUtils.sys.urls.favorites); let that = this; request(opts, function (e, resp, body) { - e = that.checkError(e, resp, 200); + e = checkError(e, resp, 200); if (e) return cb(e); const favorites = JSON.parse(body); @@ -393,7 +365,7 @@ server to get the problem's description, test cases, and other information. */ /* Making a POST request to the GraphQL API. */ getUserInfo = (cb: any) => { let that = this; - const opts = this.makeOpts(configUtils.sys.urls.graphql); + const opts = makeOpts(configUtils.sys.urls.graphql); opts.headers.Origin = configUtils.sys.urls.base; opts.headers.Referer = configUtils.sys.urls.base; opts.json = true; @@ -403,7 +375,7 @@ server to get the problem's description, test cases, and other information. */ }; request.post(opts, function (e, resp, body) { - e = that.checkError(e, resp, 200); + e = checkError(e, resp, 200); if (e) return cb(e); const user = body.data.user; @@ -413,14 +385,14 @@ server to get the problem's description, test cases, and other information. */ /* Making a request to the server and returning the response. */ runSession = (method: any, data: any, cb: any) => { - const opts = this.makeOpts(configUtils.sys.urls.session); + const opts = makeOpts(configUtils.sys.urls.session); opts.json = true; opts.method = method; opts.body = data; let that = this; request(opts, function (e, resp, body) { - e = that.checkError(e, resp, 200); + e = checkError(e, resp, 200); if (e && e.statusCode === 302) e = sessionUtils.errors.EXPIRED; return e ? cb(e) : cb(null, body.sessions); @@ -454,7 +426,7 @@ and csrf token to the user object and saves the user object to the session. */ let that = this; // eslint-disable-next-line @typescript-eslint/no-unused-vars request(configUtils.sys.urls.login, function (e: any, resp: any, _) { - e = that.checkError(e, resp, 200); + e = checkError(e, resp, 200); if (e) return cb(e); user.loginCSRF = commUtils.getSetCookieValue(resp, "csrftoken"); const opts = { @@ -706,6 +678,114 @@ and csrf token to the user object and saves the user object to the session. */ }); }); }; + getHelpOnline = (problem, _, lang) => { + getHelpEn(problem, lang, function (e, solution) { + if (e) return; + if (!solution) return reply.error("Solution not found for " + lang); + let URL_DISCUSS = "https://leetcode.com/problems/$slug/discuss/$id"; + let link = URL_DISCUSS.replace("$slug", problem.slug).replace("$id", solution.id); + let content = solution.post.content.replace(/\\n/g, "\n").replace(/\\t/g, "\t"); + + let solution_result: any = {}; + solution_result.problem_name = problem.name; + solution_result.title = solution.title; + solution_result.url = link; + solution_result.lang = lang; + solution_result.author = solution.post.author.username; + solution_result.votes = solution.post.voteCount; + solution_result.body = content; + reply.info(JSON.stringify({ code: 100, solution: solution_result })); + }); + }; +} + +/** + * It takes a problem object, a language, and a callback. It then makes a request to the LeetCode + * Discuss API to get the top voted solution for that problem in that language + * @param problem - the problem object + * @param lang - The language of the solution. + * @param cb - callback function + * @returns A solution to the problem. + */ +function getHelpEn(problem, lang, cb) { + if (!problem) return cb(); + let URL_DISCUSSES = "https://leetcode.com/graphql"; + + if (lang === "python3") lang = "python"; + + let opts = { + url: URL_DISCUSSES, + json: true, + body: { + query: [ + "query questionTopicsList($questionId: String!, $orderBy: TopicSortingOption, $skip: Int, $query: String, $first: Int!, $tags: [String!]) {", + " questionTopicsList(questionId: $questionId, orderBy: $orderBy, skip: $skip, query: $query, first: $first, tags: $tags) {", + " ...TopicsList", + " }", + "}", + "fragment TopicsList on TopicConnection {", + " totalNum", + " edges {", + " node {", + " id", + " title", + " post {", + " content", + " voteCount", + " author {", + " username", + " }", + " }", + " }", + " }", + "}", + ].join("\n"), + + operationName: "questionTopicsList", + variables: JSON.stringify({ + query: "", + first: 1, + skip: 0, + orderBy: "most_votes", + questionId: "" + problem.id, + tags: [lang], + }), + }, + }; + request(opts, function (e, resp, body) { + if (e) return cb(e); + if (resp.statusCode !== 200) return cb({ msg: "http error", statusCode: resp.statusCode }); + + const solutions = body.data.questionTopicsList.edges; + const solution = solutions.length > 0 ? solutions[0].node : null; + return cb(null, solution); + }); +} +function makeOpts(url) { + const opts: any = {}; + opts.url = url; + opts.headers = {}; + + if (sessionUtils.isLogin()) signOpts(opts, sessionUtils.getUser()); + return opts; +} + +function signOpts(opts, user) { + opts.headers.Cookie = "LEETCODE_SESSION=" + user.sessionId + ";csrftoken=" + user.sessionCSRF + ";"; + opts.headers["X-CSRFToken"] = user.sessionCSRF; + opts.headers["X-Requested-With"] = "XMLHttpRequest"; +} +function checkError(e, resp, expectedStatus) { + if (!e && resp && resp.statusCode !== expectedStatus) { + const code = resp.statusCode; + + if (code === 403 || code === 401) { + e = sessionUtils.errors.EXPIRED; + } else { + e = { msg: "http error", statusCode: code }; + } + } + return e; } export const pluginObj: LeetCode = new LeetCode(); diff --git a/src/rpc/actionChain/chainNode/solution.discuss.ts b/src/rpc/actionChain/chainNode/solution.discuss.ts index 0a38e1c..2923eb8 100644 --- a/src/rpc/actionChain/chainNode/solution.discuss.ts +++ b/src/rpc/actionChain/chainNode/solution.discuss.ts @@ -7,112 +7,8 @@ * Copyright (c) 2022 ccagml . All rights reserved. */ -let request = require("request"); - -import { reply } from "../../utils/ReplyUtils"; -import { sessionUtils } from "../../utils/sessionUtils"; import { ChainNodeBase } from "../chainNodeBase"; -class SolutionDiscuss extends ChainNodeBase { - id = 200; - name = "solution.discuss"; - builtin = true; - constructor() { - super(); - } - - getProblem = (problem, needTranslation, cb) => { - this.next.getProblem(problem, needTranslation, function (e, problem) { - if (e || !sessionUtils.argv.solution) return cb(e, problem); - - let lang = sessionUtils.argv.lang; - getSolution(problem, lang, function (e, solution) { - if (e) return cb(e); - if (!solution) return reply.error("Solution not found for " + lang); - - let link = URL_DISCUSS.replace("$slug", problem.slug).replace("$id", solution.id); - let content = solution.post.content.replace(/\\n/g, "\n").replace(/\\t/g, "\t"); - - reply.info(); - reply.info(problem.name); - reply.info(); - reply.info(solution.title); - reply.info(); - reply.info(link); - reply.info(); - reply.info("* Lang: " + lang); - reply.info("* Author: " + solution.post.author.username); - reply.info("* Votes: " + solution.post.voteCount); - reply.info(); - reply.info(content); - }); - }); - }; -} - -let URL_DISCUSSES = "https://leetcode.com/graphql"; -let URL_DISCUSS = "https://leetcode.com/problems/$slug/discuss/$id"; - -/** - * It takes a problem object, a language, and a callback. It then makes a request to the LeetCode - * Discuss API to get the top voted solution for that problem in that language - * @param problem - the problem object - * @param lang - The language of the solution. - * @param cb - callback function - * @returns A solution to the problem. - */ -function getSolution(problem, lang, cb) { - if (!problem) return cb(); - - if (lang === "python3") lang = "python"; - - let opts = { - url: URL_DISCUSSES, - json: true, - body: { - query: [ - "query questionTopicsList($questionId: String!, $orderBy: TopicSortingOption, $skip: Int, $query: String, $first: Int!, $tags: [String!]) {", - " questionTopicsList(questionId: $questionId, orderBy: $orderBy, skip: $skip, query: $query, first: $first, tags: $tags) {", - " ...TopicsList", - " }", - "}", - "fragment TopicsList on TopicConnection {", - " totalNum", - " edges {", - " node {", - " id", - " title", - " post {", - " content", - " voteCount", - " author {", - " username", - " }", - " }", - " }", - " }", - "}", - ].join("\n"), - - operationName: "questionTopicsList", - variables: JSON.stringify({ - query: "", - first: 1, - skip: 0, - orderBy: "most_votes", - questionId: "" + problem.id, - tags: [lang], - }), - }, - }; - request(opts, function (e, resp, body) { - if (e) return cb(e); - if (resp.statusCode !== 200) return cb({ msg: "http error", statusCode: resp.statusCode }); - - const solutions = body.data.questionTopicsList.edges; - const solution = solutions.length > 0 ? solutions[0].node : null; - return cb(null, solution); - }); -} +class SolutionDiscuss extends ChainNodeBase {} export const pluginObj: SolutionDiscuss = new SolutionDiscuss(); diff --git a/src/rpc/actionChain/chainNodeBase.ts b/src/rpc/actionChain/chainNodeBase.ts index 30e8640..4d5c8c7 100644 --- a/src/rpc/actionChain/chainNodeBase.ts +++ b/src/rpc/actionChain/chainNodeBase.ts @@ -115,4 +115,7 @@ export class ChainNodeBase { public getRating(cb: Function): void { this.next.getRating(cb); } + public getHelpOnline(problem, cn_flag, lang): void { + this.next.getHelpOnline(problem, cn_flag, lang); + } } diff --git a/src/rpc/factory/api/listApi.ts b/src/rpc/factory/api/listApi.ts deleted file mode 100644 index 4de5833..0000000 --- a/src/rpc/factory/api/listApi.ts +++ /dev/null @@ -1,91 +0,0 @@ -/* - * https://github.com/ccagml/vscode-leetcode-problem-rating/src/rpc/factory/api/listApi.ts - * Path: /home/cc/vscode-leetcode-problem-rating - * Created Date: Thursday, November 17th 2022, 11:44:14 am - * Author: ccagml - * - * Copyright (c) 2022 ccagml . All rights reserved. - */ - -import { reply } from "../../utils/ReplyUtils"; -import { sessionUtils } from "../../utils/sessionUtils"; -import { ApiBase } from "../apiBase"; -import { chainMgr } from "../../actionChain/chainManager"; - -class ListApi extends ApiBase { - constructor() { - super(); - } - - callArg(argv) { - let argv_config = this.api_argv() - .option("q", { - alias: "query", - type: "string", - default: "", - describe: [ - "Filter questions by condition:", - "Uppercase means negative", - "e = easy E = m+h", - "m = medium M = e+h", - "h = hard H = e+m", - "d = done D = not done", - "l = locked L = non locked", - "s = starred S = not starred", - ].join("\n"), - }) - .option("s", { - alias: "stat", - type: "boolean", - default: false, - describe: "Show statistics of listed questions", - }) - .option("t", { - alias: "tag", - type: "array", - default: [], - describe: "Filter questions by tag", - }) - .option("x", { - alias: "extra", - type: "boolean", - default: false, - describe: "Show extra details: category, companies, tags.", - }) - .option("T", { - alias: "dontTranslate", - type: "boolean", - default: false, - describe: "Set to true to disable endpoint's translation", - }) - .positional("keyword", { - type: "string", - default: "", - describe: "Filter questions by keyword", - }); - - argv_config.parseArgFromCmd(argv); - - return argv_config.get_result(); - } - - call(argv) { - sessionUtils.argv = argv; - chainMgr.getChainHead().filterProblems(argv, function (e, problems) { - if (e) return reply.info(e); - let new_objcet: Array = []; - problems.forEach((element) => { - let temp_ele: any = {}; - for (const key in element) { - if (key != "link") { - temp_ele[key] = element[key]; - } - } - new_objcet.push(temp_ele); - }); - reply.info(JSON.stringify(new_objcet)); - }); - } -} - -export const listApi: ListApi = new ListApi(); diff --git a/src/rpc/factory/api/queryApi.ts b/src/rpc/factory/api/queryApi.ts index 522a290..1e9171a 100644 --- a/src/rpc/factory/api/queryApi.ts +++ b/src/rpc/factory/api/queryApi.ts @@ -12,6 +12,7 @@ import { sessionUtils } from "../../utils/sessionUtils"; import { ApiBase } from "../apiBase"; import { chainMgr } from "../../actionChain/chainManager"; +import { configUtils } from "../../utils/configUtils"; class QueryApi extends ApiBase { constructor() { @@ -43,11 +44,40 @@ class QueryApi extends ApiBase { default: false, describe: "ranking", }) + .option("d", { + alias: "getAllProblems", + type: "boolean", + default: false, + describe: "getAllProblems", + }) + .option("e", { + alias: "getHelp", + type: "boolean", + default: false, + describe: "getHelp", + }) + .option("f", { + alias: "help_cn", + type: "boolean", + default: false, + describe: "getHelp help_cn", + }) + .option("g", { + alias: "lang", + type: "string", + default: configUtils.code.lang, + describe: "getHelp Programming language of the source code", + }) .option("z", { alias: "test", type: "string", default: "", describe: "test", + }) + .positional("keyword", { + type: "string", + default: "", + describe: "帮助的参数?", }); argv_config.parseArgFromCmd(argv); return argv_config.get_result(); @@ -81,6 +111,29 @@ class QueryApi extends ApiBase { }; reply.info(JSON.stringify(log_data)); }); + } else if (argv.d) { + chainMgr.getChainHead().filterProblems(argv, function (e, problems) { + if (e) return reply.info(e); + let new_objcet: Array = []; + problems.forEach((element) => { + let temp_ele: any = {}; + for (const key in element) { + if (key != "link") { + temp_ele[key] = element[key]; + } + } + new_objcet.push(temp_ele); + }); + reply.info(JSON.stringify(new_objcet)); + }); + } else if (argv.e) { + if (argv.keyword.length > 0) { + // show specific one + chainMgr.getChainHead().getProblem(argv.keyword, !argv.dontTranslate, function (e, problem) { + if (e) return reply.info(e); + chainMgr.getChainHead().getHelpOnline(problem, argv.f, argv.g); + }); + } } else if (argv.z) { chainMgr.getChainHead().getQueryZ(argv.z, function (e, result) { if (e) return; diff --git a/src/rpc/factory/api/submissionApi.ts b/src/rpc/factory/api/submissionApi.ts deleted file mode 100644 index 21d1f82..0000000 --- a/src/rpc/factory/api/submissionApi.ts +++ /dev/null @@ -1,156 +0,0 @@ -/* - * https://github.com/ccagml/vscode-leetcode-problem-rating/src/rpc/factory/api/submission.ts - * Path: /home/cc/vscode-leetcode-problem-rating - * Created Date: Monday, November 14th 2022, 4:04:31 pm - * Author: ccagml - * - * Copyright (c) 2022 ccagml . All rights reserved. - */ - -// let path = require('path'); - -// let _ = require('underscore'); - -// import { commUtils } from "../commUtils"; -// import { file } from "../file"; -// import { config } from "../config"; -// import { log } from "../log"; -// import { Queue } from "../queue"; -// import { corePlugin } from "../core"; -// import { sessionUtils } from "../session"; - -class SubMission { - constructor() {} - - // callArg = function (argv) { - // let argv_config = this.api_argv().option('a', { - // alias: 'all', - // type: 'boolean', - // default: false, - // describe: 'Download all questions' - // }) - // .option('l', { - // alias: 'lang', - // type: 'string', - // default: 'all', - // describe: 'Filter by programming language' - // }) - // .option('o', { - // alias: 'outdir', - // type: 'string', - // describe: 'Where to save submission code', - // default: '.' - // }) - // .option('x', { - // alias: 'extra', - // type: 'boolean', - // default: false, - // describe: 'Show extra question details in submission code' - // }) - // .option('T', { - // alias: 'dontTranslate', - // type: 'boolean', - // default: false, - // describe: 'Set to true to disable endpoint\'s translation', - // }) - // .positional('keyword', { - // type: 'string', - // default: '', - // describe: 'Download specific question by id' - // }); - // argv_config.parseArgFromCmd(argv); - - // return argv_config.get_result(); - // }; - - // doTask(problem, queue, cb) { - // let that = this; - // const argv = queue.ctx.argv; - - // function onTaskDone(e, msg) { - // // NOTE: msg color means different purpose: - // // - red: error - // // - green: accepted, fresh download - // // - yellow: not ac-ed, fresh download - // // - white: existed already, skip download - // log.info('[%=4s] %-60s %s', problem.fid, problem.name, - // (e ? 'ERROR: ' + (e.msg || e) : msg)); - // if (cb) cb(e); - // } - - // if (argv.extra) { - // // have to get problem details, e.g. problem description. - // corePlugin.getProblem(problem.fid, !argv.dontTranslate, function (e, problem) { - // if (e) return cb(e); - // that.exportSubmission(problem, argv, onTaskDone); - // }); - // } else { - // that.exportSubmission(problem, argv, onTaskDone); - // } - // } - - // exportSubmission(problem, argv, cb) { - // corePlugin.getSubmissions(problem, function (e, submissions) { - // if (e) return cb(e); - // if (submissions.length === 0) - // return cb('No submissions?'); - - // // get obj list contain required filetype - // submissions = submissions.filter(x => argv.lang === 'all' || argv.lang === x.lang); - // if (submissions.length === 0) - // return cb('No submissions in required language.'); - - // // if no accepted, use the latest non-accepted one - // const submission = submissions.find(x => x.status_display === 'Accepted') || submissions[0]; - // submission.ac = (submission.status_display === 'Accepted'); - - // const data = _.extend({}, submission, problem); - // data.sid = submission.id; - // data.ac = submission.ac ? 'ac' : 'notac'; - // const basename = storageUtils.fmt(config.storageUtils.submission, data); - // const f = path.join(argv.outdir, basename + storageUtils.getFileExtByLanguage(submission.lang)); - - // storageUtils.mkdir(argv.outdir); - // // skip the existing cached submissions - // if (storageUtils.exist(f)) - // return cb(null, f); - - // corePlugin.getSubmission(submission, function (e, submission) { - // if (e) return cb(e); - - // const opts = { - // lang: submission.lang, - // code: submission.code, - // tpl: argv.extra ? 'detailed' : 'codeonly' - // }; - // storageUtils.write(f, corePlugin.exportProblem(problem, opts)); - // cb(null, submission.ac ? f - // : f); - // }); - // }); - // } - - // handler(argv) { - // session.argv = argv; - // const q = new Queue(null, { argv: argv }, this.doTask); - - // if (argv.all) { - // corePlugin.getProblems(false, function (e, problems) { - // if (e) return log.info(e); - // problems = problems.filter(x => x.state === 'ac' || x.state === 'notac'); - // q.addTasks(problems).run(); - // }); - // return; - // } - - // if (!argv.keyword) - // return log.info('missing keyword?'); - - // corePlugin.getProblem(argv.keyword, !argv.dontTranslate, function (e, problem) { - // if (e) return log.info(e); - // q.addTask(problem).run(); - // }); - // }; -} - -export const subMissionCommand: SubMission = new SubMission(); diff --git a/src/rpc/factory/apiFactory.ts b/src/rpc/factory/apiFactory.ts index 065defe..45a49cc 100644 --- a/src/rpc/factory/apiFactory.ts +++ b/src/rpc/factory/apiFactory.ts @@ -1,5 +1,5 @@ import { cacheApi } from "./api/cacheApi"; -import { listApi } from "./api/listApi"; + import { pluginApi } from "./api/pluginApi"; import { queryApi } from "./api/queryApi"; import { showApi } from "./api/showApi"; @@ -14,8 +14,6 @@ class ApiFactory { getApi(api: string): IApi | undefined { if (api == "cache") { return cacheApi; - } else if (api == "list") { - return listApi; } else if (api == "plugin") { return pluginApi; } else if (api == "query") { diff --git a/src/service/ExecuteService.ts b/src/service/ExecuteService.ts index be0ae26..f8aac66 100644 --- a/src/service/ExecuteService.ts +++ b/src/service/ExecuteService.ts @@ -109,8 +109,8 @@ class ExecuteService implements Disposable { ]); } - public async listProblems(showLocked: boolean, needTranslation: boolean): Promise { - const cmd: string[] = [await this.getLeetCodeBinaryPath(), "list"]; + public async getAllProblems(showLocked: boolean, needTranslation: boolean): Promise { + const cmd: string[] = [await this.getLeetCodeBinaryPath(), "query", "-d"]; if (!needTranslation) { cmd.push("-T"); // use -T to prevent translation } @@ -146,12 +146,15 @@ class ExecuteService implements Disposable { } } - public async showSolution(input: string, language: string, needTranslation: boolean): Promise { + public async getHelp(input: string, language: string, needTranslation: boolean, cn_help?: boolean): Promise { // solution don't support translation - const cmd: string[] = [await this.getLeetCodeBinaryPath(), "show", input, "--solution", "-l", language]; + const cmd: string[] = [await this.getLeetCodeBinaryPath(), "query", input, "-e", "-g", language]; if (!needTranslation) { cmd.push("-T"); } + if (cn_help) { + cmd.push("-f"); + } const solution: string = await this.executeCommandWithProgressEx("正在获取题解~~~", this.nodeExecutable, cmd); return solution; } diff --git a/src/service/FileButtonService.ts b/src/service/FileButtonService.ts index 88e974f..775d09e 100644 --- a/src/service/FileButtonService.ts +++ b/src/service/FileButtonService.ts @@ -86,7 +86,7 @@ export class FileButtonService implements vscode.CodeLensProvider { temp_result.push( new vscode.CodeLens(range, { title: "Solution", - command: "lcpr.showSolution", + command: "lcpr.getHelp", arguments: [document.uri], }) ); diff --git a/src/service/SolutionService.ts b/src/service/SolutionService.ts index d9da011..28a30a7 100644 --- a/src/service/SolutionService.ts +++ b/src/service/SolutionService.ts @@ -75,16 +75,27 @@ class SolutionService extends BaseWebViewService { } private parseSolution(raw: string): Solution { - raw = raw.slice(1); // skip first empty line - [this.problemName, raw] = raw.split(/\n\n([^]+)/); // parse problem name and skip one line - const solution: Solution = new Solution(); - // [^] matches everything including \n, yet can be replaced by . in ES2018's `m` flag - [solution.title, raw] = raw.split(/\n\n([^]+)/); - [solution.url, raw] = raw.split(/\n\n([^]+)/); - [solution.lang, raw] = raw.match(/\* Lang:\s+(.+)\n([^]+)/)!.slice(1); - [solution.author, raw] = raw.match(/\* Author:\s+(.+)\n([^]+)/)!.slice(1); - [solution.votes, raw] = raw.match(/\* Votes:\s+(\d+)\n\n([^]+)/)!.slice(1); - solution.body = raw; + // raw = raw.slice(1); // skip first empty line + // [this.problemName, raw] = raw.split(/\n\n([^]+)/); // parse problem name and skip one line + // const solution: Solution = new Solution(); + // // [^] matches everything including \n, yet can be replaced by . in ES2018's `m` flag + // [solution.title, raw] = raw.split(/\n\n([^]+)/); + // [solution.url, raw] = raw.split(/\n\n([^]+)/); + // [solution.lang, raw] = raw.match(/\* Lang:\s+(.+)\n([^]+)/)!.slice(1); + // [solution.author, raw] = raw.match(/\* Author:\s+(.+)\n([^]+)/)!.slice(1); + // [solution.votes, raw] = raw.match(/\* Votes:\s+(\d+)\n\n([^]+)/)!.slice(1); + // solution.body = raw; + let obj = JSON.parse(raw); + let solution: Solution = new Solution(); + if (obj.code == 100) { + this.problemName = obj.solution.problem_name; + solution.title = obj.solution.title; + solution.url = obj.solution.url; + solution.lang = obj.solution.lang; + solution.author = obj.solution.author; + solution.votes = obj.solution.votes || 0; + solution.body = obj.solution.body; + } return solution; } } diff --git a/thirdpartynotice.txt b/thirdpartynotice.txt index bf02c4d..606dde2 100644 --- a/thirdpartynotice.txt +++ b/thirdpartynotice.txt @@ -9,7 +9,6 @@ are grateful to these developers for their contribution to open source. 2. highlight.js (https://github.com/highlightjs/highlight.js/) 3. lodash (https://github.com/lodash/lodash) 4. markdown-it (https://github.com/markdown-it/markdown-it) -5. unescape-js (https://github.com/iamakulov/unescape-js) MIT License @@ -174,31 +173,3 @@ OTHER DEALINGS IN THE SOFTWARE. END OF markdown-it NOTICES AND INFORMATION ================================== - -unescape-js NOTICES BEGIN HERE -============================= - -The MIT License (MIT) - -Copyright (c) Ivan Akulov (http://iamakulov.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. - -END OF unescape-js NOTICES AND INFORMATION -================================== From 2059f614e125a170ca8bea40f33169f9a49879f9 Mon Sep 17 00:00:00 2001 From: ccagml Date: Thu, 8 Dec 2022 21:57:53 +0800 Subject: [PATCH 2/5] update --- src/rpc/actionChain/chainNode/leetcode.ts | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/rpc/actionChain/chainNode/leetcode.ts b/src/rpc/actionChain/chainNode/leetcode.ts index 51a5743..19cbe0f 100644 --- a/src/rpc/actionChain/chainNode/leetcode.ts +++ b/src/rpc/actionChain/chainNode/leetcode.ts @@ -57,7 +57,6 @@ class LeetCode extends ChainNodeBase { getCategoryProblems = (category, cb) => { const opts = makeOpts(configUtils.sys.urls.problems.replace("$category", category)); - let that = this; request(opts, function (e, resp, body) { e = checkError(e, resp, 200); if (e) return cb(e); @@ -121,7 +120,6 @@ server to get the problem's description, test cases, and other information. */ operationName: "getQuestionDetail", }; - let that = this; request.post(opts, function (e, resp, body) { e = checkError(e, resp, 200); if (e) return cb(e); @@ -293,7 +291,7 @@ server to get the problem's description, test cases, and other information. */ getSubmissions = (problem, cb) => { const opts = makeOpts(configUtils.sys.urls.submissions.replace("$slug", problem.slug)); opts.headers.Referer = configUtils.sys.urls.problem.replace("$slug", problem.slug); - let that = this; + request(opts, function (e, resp, body) { e = checkError(e, resp, 200); if (e) return cb(e); @@ -310,7 +308,7 @@ server to get the problem's description, test cases, and other information. */ /* Getting the submission code and the runtime distribution chart. */ getSubmission = (submission, cb) => { const opts = makeOpts(configUtils.sys.urls.submission.replace("$id", submission.id)); - let that = this; + request(opts, function (e, resp, body) { e = checkError(e, resp, 200); if (e) return cb(e); @@ -339,7 +337,6 @@ server to get the problem's description, test cases, and other information. */ operationName: operationName, }; - let that = this; // eslint-disable-next-line @typescript-eslint/no-unused-vars request.post(opts, function (e: any, resp: any, _) { e = checkError(e, resp, 200); @@ -352,7 +349,6 @@ server to get the problem's description, test cases, and other information. */ getFavorites = (cb: any) => { const opts = makeOpts(configUtils.sys.urls.favorites); - let that = this; request(opts, function (e, resp, body) { e = checkError(e, resp, 200); if (e) return cb(e); @@ -364,7 +360,6 @@ server to get the problem's description, test cases, and other information. */ /* Making a POST request to the GraphQL API. */ getUserInfo = (cb: any) => { - let that = this; const opts = makeOpts(configUtils.sys.urls.graphql); opts.headers.Origin = configUtils.sys.urls.base; opts.headers.Referer = configUtils.sys.urls.base; @@ -390,7 +385,6 @@ server to get the problem's description, test cases, and other information. */ opts.method = method; opts.body = data; - let that = this; request(opts, function (e, resp, body) { e = checkError(e, resp, 200); if (e && e.statusCode === 302) e = sessionUtils.errors.EXPIRED; @@ -423,7 +417,6 @@ page and gets the csrf token. It then makes a post request to the login page wit the user's login and password. If the response status code is 302, it saves the user's session id and csrf token to the user object and saves the user object to the session. */ signin = (user: any, cb: any) => { - let that = this; // eslint-disable-next-line @typescript-eslint/no-unused-vars request(configUtils.sys.urls.login, function (e: any, resp: any, _) { e = checkError(e, resp, 200); From cd4b4c10f4f20884db78a28773ff5aec4766bf49 Mon Sep 17 00:00:00 2001 From: ccagml Date: Thu, 8 Dec 2022 21:58:51 +0800 Subject: [PATCH 3/5] update --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 912f7bb..6a36e62 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## version 待定 + +- 增加中文题解 +- 删除多余依赖包引用 + ## version 2.8.1 - 插入头文件,解决避免都是红色波浪线语法提示 From 42b52d61178d86afca90cc9fe9eb933d1b61ef6a Mon Sep 17 00:00:00 2001 From: ccagml Date: Thu, 8 Dec 2022 22:46:48 +0800 Subject: [PATCH 4/5] update --- src/rpc/actionChain/chainNode/leetcode.cn.ts | 1 + src/rpc/actionChain/chainNode/leetcode.ts | 3 ++- src/rpc/actionChain/chainNode/solution.discuss.ts | 14 -------------- src/service/SolutionService.ts | 6 +++++- 4 files changed, 8 insertions(+), 16 deletions(-) delete mode 100644 src/rpc/actionChain/chainNode/solution.discuss.ts diff --git a/src/rpc/actionChain/chainNode/leetcode.cn.ts b/src/rpc/actionChain/chainNode/leetcode.cn.ts index c29d92c..1b4d66d 100644 --- a/src/rpc/actionChain/chainNode/leetcode.cn.ts +++ b/src/rpc/actionChain/chainNode/leetcode.cn.ts @@ -272,6 +272,7 @@ function getSolutionBySlug(question_slug: string, articles_slug: string, lang: s solution_result.author = solution.author.username; solution_result.votes = solution.voteCount; solution_result.body = content; + solution_result.is_cn = true; reply.info(JSON.stringify({ code: 100, solution: solution_result })); }); } diff --git a/src/rpc/actionChain/chainNode/leetcode.ts b/src/rpc/actionChain/chainNode/leetcode.ts index 19cbe0f..9aab1a7 100644 --- a/src/rpc/actionChain/chainNode/leetcode.ts +++ b/src/rpc/actionChain/chainNode/leetcode.ts @@ -674,7 +674,7 @@ and csrf token to the user object and saves the user object to the session. */ getHelpOnline = (problem, _, lang) => { getHelpEn(problem, lang, function (e, solution) { if (e) return; - if (!solution) return reply.error("Solution not found for " + lang); + if (!solution) return reply.info(JSON.stringify({ code: -1, msg: `Solution not found for ${lang}` })); let URL_DISCUSS = "https://leetcode.com/problems/$slug/discuss/$id"; let link = URL_DISCUSS.replace("$slug", problem.slug).replace("$id", solution.id); let content = solution.post.content.replace(/\\n/g, "\n").replace(/\\t/g, "\t"); @@ -687,6 +687,7 @@ and csrf token to the user object and saves the user object to the session. */ solution_result.author = solution.post.author.username; solution_result.votes = solution.post.voteCount; solution_result.body = content; + solution_result.is_cn = false; reply.info(JSON.stringify({ code: 100, solution: solution_result })); }); }; diff --git a/src/rpc/actionChain/chainNode/solution.discuss.ts b/src/rpc/actionChain/chainNode/solution.discuss.ts deleted file mode 100644 index 2923eb8..0000000 --- a/src/rpc/actionChain/chainNode/solution.discuss.ts +++ /dev/null @@ -1,14 +0,0 @@ -/* - * https://github.com/ccagml/vscode-leetcode-problem-rating/src/rpc/actionChain/solution.discuss.ts - * Path: /home/cc/vscode-leetcode-problem-rating - * Created Date: Monday, November 14th 2022, 4:04:31 pm - * Author: ccagml - * - * Copyright (c) 2022 ccagml . All rights reserved. - */ - -import { ChainNodeBase } from "../chainNodeBase"; - -class SolutionDiscuss extends ChainNodeBase {} - -export const pluginObj: SolutionDiscuss = new SolutionDiscuss(); diff --git a/src/service/SolutionService.ts b/src/service/SolutionService.ts index 28a30a7..7992dde 100644 --- a/src/service/SolutionService.ts +++ b/src/service/SolutionService.ts @@ -42,7 +42,9 @@ class SolutionService extends BaseWebViewService { const styles: string = markdownService.getStyles(); const { title, url, lang, author, votes } = this.solution; const head: string = markdownService.render(`# [${title}](${url})`); - const auth: string = `[${author}](https://leetcode.com/${author}/)`; + const auth: string = this.solution.is_cn + ? `[${author}](https://leetcode.cn/u/${author}/)` + : `[${author}](https://leetcode.com/${author}/)`; const info: string = markdownService.render( [ `| Language | Author | Votes |`, @@ -95,6 +97,7 @@ class SolutionService extends BaseWebViewService { solution.author = obj.solution.author; solution.votes = obj.solution.votes || 0; solution.body = obj.solution.body; + solution.is_cn = obj.solution.is_cn; } return solution; } @@ -108,6 +111,7 @@ class Solution { public author: string = ""; public votes: string = ""; public body: string = ""; // Markdown supported + public is_cn?: boolean = false; } export const solutionService: SolutionService = new SolutionService(); From 542c123551579189675aee607127f3b3ab4bba61 Mon Sep 17 00:00:00 2001 From: ccagml Date: Thu, 8 Dec 2022 22:49:00 +0800 Subject: [PATCH 5/5] 2.9.1 --- CHANGELOG.md | 2 +- README.md | 1 + package-lock.json | 164 +++++++++++++++++++++++----------------------- package.json | 2 +- 4 files changed, 85 insertions(+), 84 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a36e62..f289450 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -## version 待定 +## version 2.9.1 - 增加中文题解 - 删除多余依赖包引用 diff --git a/README.md b/README.md index 8606863..b899cb0 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,7 @@ - [新增一个 remark 功能](#新增在工作目录存放数据) - [新增题目自定义分类](#新增在工作目录存放数据) - [答案不同上色,配置默认不开启](#插件配置项) +- 增加获取中文站的题解 # 关于本项目 diff --git a/package-lock.json b/package-lock.json index 2ad93b5..f46a874 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "vscode-leetcode-problem-rating", - "version": "2.8.1", + "version": "2.9.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "vscode-leetcode-problem-rating", - "version": "2.8.1", + "version": "2.9.1", "license": "MIT", "dependencies": { "ansi-styles": "3.2.1", @@ -275,14 +275,14 @@ "dev": true }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "5.45.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.45.1.tgz", - "integrity": "sha512-cOizjPlKEh0bXdFrBLTrI/J6B/QMlhwE9auOov53tgB+qMukH6/h8YAK/qw+QJGct/PTbdh2lytGyipxCcEtAw==", + "version": "5.46.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.46.0.tgz", + "integrity": "sha512-QrZqaIOzJAjv0sfjY4EjbXUi3ZOFpKfzntx22gPGr9pmFcTjcFw/1sS1LJhEubfAGwuLjNrPV0rH+D1/XZFy7Q==", "dev": true, "dependencies": { - "@typescript-eslint/scope-manager": "5.45.1", - "@typescript-eslint/type-utils": "5.45.1", - "@typescript-eslint/utils": "5.45.1", + "@typescript-eslint/scope-manager": "5.46.0", + "@typescript-eslint/type-utils": "5.46.0", + "@typescript-eslint/utils": "5.46.0", "debug": "^4.3.4", "ignore": "^5.2.0", "natural-compare-lite": "^1.4.0", @@ -308,14 +308,14 @@ } }, "node_modules/@typescript-eslint/parser": { - "version": "5.45.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.45.1.tgz", - "integrity": "sha512-JQ3Ep8bEOXu16q0ztsatp/iQfDCtvap7sp/DKo7DWltUquj5AfCOpX2zSzJ8YkAVnrQNqQ5R62PBz2UtrfmCkA==", + "version": "5.46.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.46.0.tgz", + "integrity": "sha512-joNO6zMGUZg+C73vwrKXCd8usnsmOYmgW/w5ZW0pG0RGvqeznjtGDk61EqqTpNrFLUYBW2RSBFrxdAZMqA4OZA==", "dev": true, "dependencies": { - "@typescript-eslint/scope-manager": "5.45.1", - "@typescript-eslint/types": "5.45.1", - "@typescript-eslint/typescript-estree": "5.45.1", + "@typescript-eslint/scope-manager": "5.46.0", + "@typescript-eslint/types": "5.46.0", + "@typescript-eslint/typescript-estree": "5.46.0", "debug": "^4.3.4" }, "engines": { @@ -335,13 +335,13 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "5.45.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.45.1.tgz", - "integrity": "sha512-D6fCileR6Iai7E35Eb4Kp+k0iW7F1wxXYrOhX/3dywsOJpJAQ20Fwgcf+P/TDtvQ7zcsWsrJaglaQWDhOMsspQ==", + "version": "5.46.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.46.0.tgz", + "integrity": "sha512-7wWBq9d/GbPiIM6SqPK9tfynNxVbfpihoY5cSFMer19OYUA3l4powA2uv0AV2eAZV6KoAh6lkzxv4PoxOLh1oA==", "dev": true, "dependencies": { - "@typescript-eslint/types": "5.45.1", - "@typescript-eslint/visitor-keys": "5.45.1" + "@typescript-eslint/types": "5.46.0", + "@typescript-eslint/visitor-keys": "5.46.0" }, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -352,13 +352,13 @@ } }, "node_modules/@typescript-eslint/type-utils": { - "version": "5.45.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.45.1.tgz", - "integrity": "sha512-aosxFa+0CoYgYEl3aptLe1svP910DJq68nwEJzyQcrtRhC4BN0tJAvZGAe+D0tzjJmFXe+h4leSsiZhwBa2vrA==", + "version": "5.46.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.46.0.tgz", + "integrity": "sha512-dwv4nimVIAsVS2dTA0MekkWaRnoYNXY26dKz8AN5W3cBFYwYGFQEqm/cG+TOoooKlncJS4RTbFKgcFY/pOiBCg==", "dev": true, "dependencies": { - "@typescript-eslint/typescript-estree": "5.45.1", - "@typescript-eslint/utils": "5.45.1", + "@typescript-eslint/typescript-estree": "5.46.0", + "@typescript-eslint/utils": "5.46.0", "debug": "^4.3.4", "tsutils": "^3.21.0" }, @@ -379,9 +379,9 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "5.45.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.45.1.tgz", - "integrity": "sha512-HEW3U0E5dLjUT+nk7b4lLbOherS1U4ap+b9pfu2oGsW3oPu7genRaY9dDv3nMczC1rbnRY2W/D7SN05wYoGImg==", + "version": "5.46.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.46.0.tgz", + "integrity": "sha512-wHWgQHFB+qh6bu0IAPAJCdeCdI0wwzZnnWThlmHNY01XJ9Z97oKqKOzWYpR2I83QmshhQJl6LDM9TqMiMwJBTw==", "dev": true, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -392,13 +392,13 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "5.45.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.45.1.tgz", - "integrity": "sha512-76NZpmpCzWVrrb0XmYEpbwOz/FENBi+5W7ipVXAsG3OoFrQKJMiaqsBMbvGRyLtPotGqUfcY7Ur8j0dksDJDng==", + "version": "5.46.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.46.0.tgz", + "integrity": "sha512-kDLNn/tQP+Yp8Ro2dUpyyVV0Ksn2rmpPpB0/3MO874RNmXtypMwSeazjEN/Q6CTp8D7ExXAAekPEcCEB/vtJkw==", "dev": true, "dependencies": { - "@typescript-eslint/types": "5.45.1", - "@typescript-eslint/visitor-keys": "5.45.1", + "@typescript-eslint/types": "5.46.0", + "@typescript-eslint/visitor-keys": "5.46.0", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", @@ -419,16 +419,16 @@ } }, "node_modules/@typescript-eslint/utils": { - "version": "5.45.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.45.1.tgz", - "integrity": "sha512-rlbC5VZz68+yjAzQBc4I7KDYVzWG2X/OrqoZrMahYq3u8FFtmQYc+9rovo/7wlJH5kugJ+jQXV5pJMnofGmPRw==", + "version": "5.46.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.46.0.tgz", + "integrity": "sha512-4O+Ps1CRDw+D+R40JYh5GlKLQERXRKW5yIQoNDpmXPJ+C7kaPF9R7GWl+PxGgXjB3PQCqsaaZUpZ9dG4U6DO7g==", "dev": true, "dependencies": { "@types/json-schema": "^7.0.9", "@types/semver": "^7.3.12", - "@typescript-eslint/scope-manager": "5.45.1", - "@typescript-eslint/types": "5.45.1", - "@typescript-eslint/typescript-estree": "5.45.1", + "@typescript-eslint/scope-manager": "5.46.0", + "@typescript-eslint/types": "5.46.0", + "@typescript-eslint/typescript-estree": "5.46.0", "eslint-scope": "^5.1.1", "eslint-utils": "^3.0.0", "semver": "^7.3.7" @@ -445,12 +445,12 @@ } }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "5.45.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.45.1.tgz", - "integrity": "sha512-cy9ln+6rmthYWjH9fmx+5FU/JDpjQb586++x2FZlveq7GdGuLLW9a2Jcst2TGekH82bXpfmRNSwP9tyEs6RjvQ==", + "version": "5.46.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.46.0.tgz", + "integrity": "sha512-E13gBoIXmaNhwjipuvQg1ByqSAu/GbEpP/qzFihugJ+MomtoJtFAJG/+2DRPByf57B863m0/q7Zt16V9ohhANw==", "dev": true, "dependencies": { - "@typescript-eslint/types": "5.45.1", + "@typescript-eslint/types": "5.46.0", "eslint-visitor-keys": "^3.3.0" }, "engines": { @@ -3267,14 +3267,14 @@ "dev": true }, "@typescript-eslint/eslint-plugin": { - "version": "5.45.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.45.1.tgz", - "integrity": "sha512-cOizjPlKEh0bXdFrBLTrI/J6B/QMlhwE9auOov53tgB+qMukH6/h8YAK/qw+QJGct/PTbdh2lytGyipxCcEtAw==", + "version": "5.46.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.46.0.tgz", + "integrity": "sha512-QrZqaIOzJAjv0sfjY4EjbXUi3ZOFpKfzntx22gPGr9pmFcTjcFw/1sS1LJhEubfAGwuLjNrPV0rH+D1/XZFy7Q==", "dev": true, "requires": { - "@typescript-eslint/scope-manager": "5.45.1", - "@typescript-eslint/type-utils": "5.45.1", - "@typescript-eslint/utils": "5.45.1", + "@typescript-eslint/scope-manager": "5.46.0", + "@typescript-eslint/type-utils": "5.46.0", + "@typescript-eslint/utils": "5.46.0", "debug": "^4.3.4", "ignore": "^5.2.0", "natural-compare-lite": "^1.4.0", @@ -3284,53 +3284,53 @@ } }, "@typescript-eslint/parser": { - "version": "5.45.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.45.1.tgz", - "integrity": "sha512-JQ3Ep8bEOXu16q0ztsatp/iQfDCtvap7sp/DKo7DWltUquj5AfCOpX2zSzJ8YkAVnrQNqQ5R62PBz2UtrfmCkA==", + "version": "5.46.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.46.0.tgz", + "integrity": "sha512-joNO6zMGUZg+C73vwrKXCd8usnsmOYmgW/w5ZW0pG0RGvqeznjtGDk61EqqTpNrFLUYBW2RSBFrxdAZMqA4OZA==", "dev": true, "requires": { - "@typescript-eslint/scope-manager": "5.45.1", - "@typescript-eslint/types": "5.45.1", - "@typescript-eslint/typescript-estree": "5.45.1", + "@typescript-eslint/scope-manager": "5.46.0", + "@typescript-eslint/types": "5.46.0", + "@typescript-eslint/typescript-estree": "5.46.0", "debug": "^4.3.4" } }, "@typescript-eslint/scope-manager": { - "version": "5.45.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.45.1.tgz", - "integrity": "sha512-D6fCileR6Iai7E35Eb4Kp+k0iW7F1wxXYrOhX/3dywsOJpJAQ20Fwgcf+P/TDtvQ7zcsWsrJaglaQWDhOMsspQ==", + "version": "5.46.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.46.0.tgz", + "integrity": "sha512-7wWBq9d/GbPiIM6SqPK9tfynNxVbfpihoY5cSFMer19OYUA3l4powA2uv0AV2eAZV6KoAh6lkzxv4PoxOLh1oA==", "dev": true, "requires": { - "@typescript-eslint/types": "5.45.1", - "@typescript-eslint/visitor-keys": "5.45.1" + "@typescript-eslint/types": "5.46.0", + "@typescript-eslint/visitor-keys": "5.46.0" } }, "@typescript-eslint/type-utils": { - "version": "5.45.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.45.1.tgz", - "integrity": "sha512-aosxFa+0CoYgYEl3aptLe1svP910DJq68nwEJzyQcrtRhC4BN0tJAvZGAe+D0tzjJmFXe+h4leSsiZhwBa2vrA==", + "version": "5.46.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.46.0.tgz", + "integrity": "sha512-dwv4nimVIAsVS2dTA0MekkWaRnoYNXY26dKz8AN5W3cBFYwYGFQEqm/cG+TOoooKlncJS4RTbFKgcFY/pOiBCg==", "dev": true, "requires": { - "@typescript-eslint/typescript-estree": "5.45.1", - "@typescript-eslint/utils": "5.45.1", + "@typescript-eslint/typescript-estree": "5.46.0", + "@typescript-eslint/utils": "5.46.0", "debug": "^4.3.4", "tsutils": "^3.21.0" } }, "@typescript-eslint/types": { - "version": "5.45.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.45.1.tgz", - "integrity": "sha512-HEW3U0E5dLjUT+nk7b4lLbOherS1U4ap+b9pfu2oGsW3oPu7genRaY9dDv3nMczC1rbnRY2W/D7SN05wYoGImg==", + "version": "5.46.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.46.0.tgz", + "integrity": "sha512-wHWgQHFB+qh6bu0IAPAJCdeCdI0wwzZnnWThlmHNY01XJ9Z97oKqKOzWYpR2I83QmshhQJl6LDM9TqMiMwJBTw==", "dev": true }, "@typescript-eslint/typescript-estree": { - "version": "5.45.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.45.1.tgz", - "integrity": "sha512-76NZpmpCzWVrrb0XmYEpbwOz/FENBi+5W7ipVXAsG3OoFrQKJMiaqsBMbvGRyLtPotGqUfcY7Ur8j0dksDJDng==", + "version": "5.46.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.46.0.tgz", + "integrity": "sha512-kDLNn/tQP+Yp8Ro2dUpyyVV0Ksn2rmpPpB0/3MO874RNmXtypMwSeazjEN/Q6CTp8D7ExXAAekPEcCEB/vtJkw==", "dev": true, "requires": { - "@typescript-eslint/types": "5.45.1", - "@typescript-eslint/visitor-keys": "5.45.1", + "@typescript-eslint/types": "5.46.0", + "@typescript-eslint/visitor-keys": "5.46.0", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", @@ -3339,28 +3339,28 @@ } }, "@typescript-eslint/utils": { - "version": "5.45.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.45.1.tgz", - "integrity": "sha512-rlbC5VZz68+yjAzQBc4I7KDYVzWG2X/OrqoZrMahYq3u8FFtmQYc+9rovo/7wlJH5kugJ+jQXV5pJMnofGmPRw==", + "version": "5.46.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.46.0.tgz", + "integrity": "sha512-4O+Ps1CRDw+D+R40JYh5GlKLQERXRKW5yIQoNDpmXPJ+C7kaPF9R7GWl+PxGgXjB3PQCqsaaZUpZ9dG4U6DO7g==", "dev": true, "requires": { "@types/json-schema": "^7.0.9", "@types/semver": "^7.3.12", - "@typescript-eslint/scope-manager": "5.45.1", - "@typescript-eslint/types": "5.45.1", - "@typescript-eslint/typescript-estree": "5.45.1", + "@typescript-eslint/scope-manager": "5.46.0", + "@typescript-eslint/types": "5.46.0", + "@typescript-eslint/typescript-estree": "5.46.0", "eslint-scope": "^5.1.1", "eslint-utils": "^3.0.0", "semver": "^7.3.7" } }, "@typescript-eslint/visitor-keys": { - "version": "5.45.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.45.1.tgz", - "integrity": "sha512-cy9ln+6rmthYWjH9fmx+5FU/JDpjQb586++x2FZlveq7GdGuLLW9a2Jcst2TGekH82bXpfmRNSwP9tyEs6RjvQ==", + "version": "5.46.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.46.0.tgz", + "integrity": "sha512-E13gBoIXmaNhwjipuvQg1ByqSAu/GbEpP/qzFihugJ+MomtoJtFAJG/+2DRPByf57B863m0/q7Zt16V9ohhANw==", "dev": true, "requires": { - "@typescript-eslint/types": "5.45.1", + "@typescript-eslint/types": "5.46.0", "eslint-visitor-keys": "^3.3.0" } }, diff --git a/package.json b/package.json index 678b739..5a9e2fd 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "vscode-leetcode-problem-rating", "displayName": "LeetCode", "description": "LeetCode 官方插件增强, 代码开源, 增加 LeetCode 题目难度分, 给个star吧, 球球了", - "version": "2.8.1", + "version": "2.9.1", "author": "ccagml", "publisher": "ccagml", "license": "MIT",