diff --git a/.eslintrc.json b/.eslintrc.json index 111648c39..0eb6689f2 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -6,8 +6,22 @@ "@typescript-eslint", "header", "simple-import-sort", - "unused-imports" + "unused-imports", + "path-alias" ], + "settings": { + "import/resolver": { + "alias": { + "map": [ + ["@webpack", "./src/webpack"], + ["@webpack/common", "./src/webpack/common"], + ["@utils", "./src/utils"], + ["@api", "./src/api"], + ["@components", "./src/components"] + ] + } + } + }, "rules": { // Since it's only been a month and Vencord has already been stolen // by random skids who rebranded it to "AlphaCord" and erased all license @@ -95,6 +109,8 @@ "unused-imports/no-unused-imports": "error", + "path-alias/no-relative": "error", + "@typescript-eslint/no-restricted-imports": [ "error", { diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 59fa3d2f7..14f30840d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -23,5 +23,8 @@ jobs: - name: Install dependencies run: pnpm install --frozen-lockfile - - name: Lint & Test if it compiles + - name: Lint & Test if desktop version compiles run: pnpm test + + - name: Lint & Test if web version compiles + run: pnpm testWeb diff --git a/browser/VencordNativeStub.ts b/browser/VencordNativeStub.ts index dca7da82e..ef3923ba7 100644 --- a/browser/VencordNativeStub.ts +++ b/browser/VencordNativeStub.ts @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -import IpcEvents from "../src/utils/IpcEvents"; import * as DataStore from "../src/api/DataStore"; +import IpcEvents from "../src/utils/IpcEvents"; // Discord deletes this so need to store in variable const { localStorage } = window; diff --git a/docs/2_PLUGINS.md b/docs/2_PLUGINS.md index 6ac4b2466..705ea89d6 100644 --- a/docs/2_PLUGINS.md +++ b/docs/2_PLUGINS.md @@ -15,7 +15,7 @@ You don't need to run `pnpm build` every time you make a change. Instead, use `p 3. In `index.ts`, copy-paste the following template code: ```ts -import definePlugin from "../../utils/types"; +import definePlugin from "@utils/types"; export default definePlugin({ name: "Epic Plugin", diff --git a/package.json b/package.json index a168448ae..6fabe2ddc 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "lint": "eslint . --ext .js,.jsx,.ts,.tsx", "lint:fix": "pnpm lint --fix", "test": "pnpm lint && pnpm build && pnpm testTsc", + "testWeb": "pnpm lint && pnpm buildWeb && pnpm testTsc", "testTsc": "tsc --noEmit", "uninject": "node scripts/patcher/uninstall.js", "watch": "node scripts/build/build.mjs --watch" @@ -44,7 +45,9 @@ "discord-types": "^1.3.26", "esbuild": "^0.15.5", "eslint": "^8.24.0", + "eslint-import-resolver-alias": "^1.1.2", "eslint-plugin-header": "^3.1.1", + "eslint-plugin-path-alias": "^1.0.0", "eslint-plugin-simple-import-sort": "^8.0.0", "eslint-plugin-unused-imports": "^2.0.0", "moment": "^2.29.4", @@ -53,5 +56,10 @@ "type-fest": "^3.1.0", "typescript": "^4.8.4" }, - "packageManager": "pnpm@7.13.4" + "packageManager": "pnpm@7.13.4", + "pnpm": { + "patchedDependencies": { + "eslint-plugin-path-alias@1.0.0": "patches/eslint-plugin-path-alias@1.0.0.patch" + } + } } diff --git a/patches/eslint-plugin-path-alias@1.0.0.patch b/patches/eslint-plugin-path-alias@1.0.0.patch new file mode 100644 index 000000000..49c46b3dd --- /dev/null +++ b/patches/eslint-plugin-path-alias@1.0.0.patch @@ -0,0 +1,13 @@ +diff --git a/lib/rules/no-relative.js b/lib/rules/no-relative.js +index 71594c83f1f4f733ffcc6047d7f7084348335dbe..d8623d87c89499c442171db3272cba07c9efabbe 100644 +--- a/lib/rules/no-relative.js ++++ b/lib/rules/no-relative.js +@@ -41,7 +41,7 @@ module.exports = { + ImportDeclaration(node) { + const importPath = node.source.value; + +- if (!/^(\.?\.\/)/.test(importPath)) { ++ if (!/^(\.\.\/)/.test(importPath)) { + return; + } + \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ba97ffa93..5000b161e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,5 +1,10 @@ lockfileVersion: 5.4 +patchedDependencies: + eslint-plugin-path-alias@1.0.0: + hash: m6sma4g6bh67km3q6igf6uxaja + path: patches/eslint-plugin-path-alias@1.0.0.patch + specifiers: '@types/diff': ^5.0.2 '@types/node': ^18.7.13 @@ -13,7 +18,9 @@ specifiers: discord-types: ^1.3.26 esbuild: ^0.15.5 eslint: ^8.24.0 + eslint-import-resolver-alias: ^1.1.2 eslint-plugin-header: ^3.1.1 + eslint-plugin-path-alias: ^1.0.0 eslint-plugin-simple-import-sort: ^8.0.0 eslint-plugin-unused-imports: ^2.0.0 fflate: ^0.7.4 @@ -39,7 +46,9 @@ devDependencies: discord-types: 1.3.26 esbuild: 0.15.5 eslint: 8.24.0 + eslint-import-resolver-alias: 1.1.2 eslint-plugin-header: 3.1.1_eslint@8.24.0 + eslint-plugin-path-alias: 1.0.0_m6sma4g6bh67km3q6igf6uxaja_eslint@8.24.0 eslint-plugin-simple-import-sort: 8.0.0_eslint@8.24.0 eslint-plugin-unused-imports: 2.0.0_5yz3upex2kb6hbdwaq7bihlxnq moment: 2.29.4 @@ -403,15 +412,54 @@ packages: resolution: {integrity: sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==} dev: true + /arr-diff/4.0.0: + resolution: {integrity: sha512-YVIQ82gZPGBebQV/a8dar4AitzCQs0jjXwMPZllpXMaGjXPYVUawSxQrRsjhjupyVxEvbHgUmIhKVlND+j02kA==} + engines: {node: '>=0.10.0'} + dev: true + + /arr-union/3.1.0: + resolution: {integrity: sha512-sKpyeERZ02v1FeCZT8lrfJq5u6goHCtpTAzPwJYe7c8SPFOboNjNg1vz2L4VTn9T4PQxEx13TbXLmYUcS6Ug7Q==} + engines: {node: '>=0.10.0'} + dev: true + /array-union/2.1.0: resolution: {integrity: sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==} engines: {node: '>=8'} dev: true + /array-unique/0.3.2: + resolution: {integrity: sha512-SleRWjh9JUud2wH1hPs9rZBZ33H6T9HOiL0uwGnGx9FpE6wKGyfWugmbkEOIs6qWrZhg0LWeLziLrEwQJhs5mQ==} + engines: {node: '>=0.10.0'} + dev: true + + /assign-symbols/1.0.0: + resolution: {integrity: sha512-Q+JC7Whu8HhmTdBph/Tq59IoRtoy6KAm5zzPv00WdujX82lbAL8K7WVjne7vdCsAmbF4AYaDOPyO3k0kl8qIrw==} + engines: {node: '>=0.10.0'} + dev: true + + /atob/2.1.2: + resolution: {integrity: sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==} + engines: {node: '>= 4.5.0'} + hasBin: true + dev: true + /balanced-match/1.0.2: resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==} dev: true + /base/0.11.2: + resolution: {integrity: sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg==} + engines: {node: '>=0.10.0'} + dependencies: + cache-base: 1.0.1 + class-utils: 0.3.6 + component-emitter: 1.3.0 + define-property: 1.0.0 + isobject: 3.0.1 + mixin-deep: 1.3.2 + pascalcase: 0.1.1 + dev: true + /base64-js/1.5.1: resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==} dev: true @@ -449,6 +497,21 @@ packages: ieee754: 1.2.1 dev: true + /cache-base/1.0.1: + resolution: {integrity: sha512-AKcdTnFSWATd5/GCPRxr2ChwIJ85CeyrEyjRHlKxQ56d4XJMGym0uAiKn0xbLOGOl3+yRpOTi484dVCEc5AUzQ==} + engines: {node: '>=0.10.0'} + dependencies: + collection-visit: 1.0.0 + component-emitter: 1.3.0 + get-value: 2.0.6 + has-value: 1.0.0 + isobject: 3.0.1 + set-value: 2.0.1 + to-object-path: 0.3.0 + union-value: 1.0.1 + unset-value: 1.0.0 + dev: true + /callsites/3.1.0: resolution: {integrity: sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==} engines: {node: '>=6'} @@ -466,6 +529,24 @@ packages: resolution: {integrity: sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==} dev: true + /class-utils/0.3.6: + resolution: {integrity: sha512-qOhPa/Fj7s6TY8H8esGu5QNpMMQxz79h+urzrNYN6mn+9BnxlDGf5QZ+XeCDsxSjPqsSR56XOZOJmpeurnLMeg==} + engines: {node: '>=0.10.0'} + dependencies: + arr-union: 3.1.0 + define-property: 0.2.5 + isobject: 3.0.1 + static-extend: 0.1.2 + dev: true + + /collection-visit/1.0.0: + resolution: {integrity: sha512-lNkKvzEeMBBjUGHZ+q6z9pSJla0KWAQPvtzhEV9+iGyQYG+pBpl7xKDhxoNSOZH2hhv0v5k0y2yAM4o4SjoSkw==} + engines: {node: '>=0.10.0'} + dependencies: + map-visit: 1.0.0 + object-visit: 1.0.1 + dev: true + /color-convert/2.0.1: resolution: {integrity: sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==} engines: {node: '>=7.0.0'} @@ -477,6 +558,10 @@ packages: resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==} dev: true + /component-emitter/1.3.0: + resolution: {integrity: sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg==} + dev: true + /concat-map/0.0.1: resolution: {integrity: sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=} dev: true @@ -487,6 +572,11 @@ packages: keypress: 0.2.1 dev: false + /copy-descriptor/0.1.1: + resolution: {integrity: sha512-XgZ0pFcakEUlbwQEVNg3+QAis1FyTL3Qel9FYy8pSkQqoG3PNoT0bOCQtOXcOkur21r2Eq2kI+IE+gsmAEVlYw==} + engines: {node: '>=0.10.0'} + dev: true + /cross-fetch/3.1.5: resolution: {integrity: sha512-lvb1SBsI0Z7GDwmuid+mU3kWVBwTVUbe7S0H52yaaAdQOXq2YktTCZdlAcNKFzE6QtRz0snpw9bNiPeOIkkQvw==} dependencies: @@ -508,6 +598,17 @@ packages: resolution: {integrity: sha512-uX1KG+x9h5hIJsaKR9xHUeUraxf8IODOwq9JLNPq6BwB04a/xgpq3rcx47l5BZu5zBPlgD342tdke3Hom/nJRA==} dev: true + /debug/2.6.9: + resolution: {integrity: sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==} + peerDependencies: + supports-color: '*' + peerDependenciesMeta: + supports-color: + optional: true + dependencies: + ms: 2.0.0 + dev: true + /debug/4.3.4: resolution: {integrity: sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==} engines: {node: '>=6.0'} @@ -520,10 +621,37 @@ packages: ms: 2.1.2 dev: true + /decode-uri-component/0.2.0: + resolution: {integrity: sha512-hjf+xovcEn31w/EUYdTXQh/8smFL/dzYjohQGEIgjyNavaJfBY2p5F527Bo1VPATxv0VYTUC2bOcXvqFwk78Og==} + engines: {node: '>=0.10'} + dev: true + /deep-is/0.1.4: resolution: {integrity: sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==} dev: true + /define-property/0.2.5: + resolution: {integrity: sha512-Rr7ADjQZenceVOAKop6ALkkRAmH1A4Gx9hV/7ZujPUN2rkATqFO0JZLZInbAjpZYoJ1gUx8MRMQVkYemcbMSTA==} + engines: {node: '>=0.10.0'} + dependencies: + is-descriptor: 0.1.6 + dev: true + + /define-property/1.0.0: + resolution: {integrity: sha512-cZTYKFWspt9jZsMscWo8sc/5lbPC9Q0N5nBLgb+Yd915iL3udB1uFgS3B8YCx66UVHq018DAVFoee7x+gxggeA==} + engines: {node: '>=0.10.0'} + dependencies: + is-descriptor: 1.0.2 + dev: true + + /define-property/2.0.2: + resolution: {integrity: sha512-jwK2UV4cnPpbcG7+VRARKTZPUWowwXA8bzH5NP6ud0oeAxyYPuGZUAC7hMugpCdz4BeSZl2Dl9k66CHJ/46ZYQ==} + engines: {node: '>=0.10.0'} + dependencies: + is-descriptor: 1.0.2 + isobject: 3.0.1 + dev: true + /devtools-protocol/0.0.1056733: resolution: {integrity: sha512-CmTu6SQx2g3TbZzDCAV58+LTxVdKplS7xip0g5oDXpZ+isr0rv5dDP8ToyVRywzPHkCCPKgKgScEcwz4uPWDIA==} dev: true @@ -774,6 +902,13 @@ packages: engines: {node: '>=10'} dev: true + /eslint-import-resolver-alias/1.1.2: + resolution: {integrity: sha512-WdviM1Eu834zsfjHtcGHtGfcu+F30Od3V7I9Fi57uhBEwPkjDcii7/yW8jAT+gOhn4P/vOxxNAXbFAKsrrc15w==} + engines: {node: '>= 4'} + peerDependencies: + eslint-plugin-import: '>=1.4.0' + dev: true + /eslint-plugin-header/3.1.1_eslint@8.24.0: resolution: {integrity: sha512-9vlKxuJ4qf793CmeeSrZUvVClw6amtpghq3CuWcB5cUNnWHQhgcqy5eF8oVKFk1G3Y/CbchGfEaw3wiIJaNmVg==} peerDependencies: @@ -782,6 +917,18 @@ packages: eslint: 8.24.0 dev: true + /eslint-plugin-path-alias/1.0.0_m6sma4g6bh67km3q6igf6uxaja_eslint@8.24.0: + resolution: {integrity: sha512-FXus57yC+Zd3sMv46pbloXYwFeNVNHJqlACr9V68FG/IzGFBBokGJpmjDbEjpt8ZCeVSndUubeDWWl2A8sCNVQ==} + peerDependencies: + eslint: ^7 + dependencies: + eslint: 8.24.0 + nanomatch: 1.2.13 + transitivePeerDependencies: + - supports-color + dev: true + patched: true + /eslint-plugin-simple-import-sort/8.0.0_eslint@8.24.0: resolution: {integrity: sha512-bXgJQ+lqhtQBCuWY/FUWdB27j4+lqcvXv5rUARkzbeWLwea+S5eBZEQrhnO+WgX3ZoJHVj0cn943iyXwByHHQw==} peerDependencies: @@ -932,6 +1079,21 @@ packages: engines: {node: '>=0.10.0'} dev: true + /extend-shallow/2.0.1: + resolution: {integrity: sha512-zCnTtlxNoAiDc3gqY2aYAWFx7XWWiasuF2K8Me5WbN8otHKTUKBwjPtNpRs/rbUZm7KxWAaNj7P1a/p52GbVug==} + engines: {node: '>=0.10.0'} + dependencies: + is-extendable: 0.1.1 + dev: true + + /extend-shallow/3.0.2: + resolution: {integrity: sha512-BwY5b5Ql4+qZoefgMj2NUmx+tehVTH/Kf4k1ZEtOHNFcm2wSxMRo992l6X3TIgni2eZVTZ85xMOjF31fwZAj6Q==} + engines: {node: '>=0.10.0'} + dependencies: + assign-symbols: 1.0.0 + is-extendable: 1.0.1 + dev: true + /extract-zip/2.0.1: resolution: {integrity: sha512-GDhU9ntwuKyGXdZBUgTIe+vXnWj0fppUEtMDL0+idd5Sta8TGpHssn/eusA9mrPr9qNDym6SxAYZjNvCn/9RBg==} engines: {node: '>= 10.17.0'} @@ -1019,6 +1181,18 @@ packages: resolution: {integrity: sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ==} dev: true + /for-in/1.0.2: + resolution: {integrity: sha512-7EwmXrOjyL+ChxMhmG5lnW9MPt1aIeZEwKhQzoBUdTV0N3zuwWDZYVJatDvZ2OyzPUvdIAZDsCetk3coyMfcnQ==} + engines: {node: '>=0.10.0'} + dev: true + + /fragment-cache/0.2.1: + resolution: {integrity: sha512-GMBAbW9antB8iZRHLoGw0b3HANt57diZYFO/HL1JGIC1MjKrdmhxvrJbupnVvpys0zsz7yBApXdQyfepKly2kA==} + engines: {node: '>=0.10.0'} + dependencies: + map-cache: 0.2.2 + dev: true + /fs-constants/1.0.0: resolution: {integrity: sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==} dev: true @@ -1034,6 +1208,11 @@ packages: pump: 3.0.0 dev: true + /get-value/2.0.6: + resolution: {integrity: sha512-Ln0UQDlxH1BapMu3GPtf7CuYNwRZf2gwCuPqbyG6pB8WfmFpzqcy4xtAaAMUhnNqjMKTiCPZG2oMT3YSx8U2NA==} + engines: {node: '>=0.10.0'} + dev: true + /glob-parent/5.1.2: resolution: {integrity: sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==} engines: {node: '>= 6'} @@ -1087,6 +1266,37 @@ packages: engines: {node: '>=8'} dev: true + /has-value/0.3.1: + resolution: {integrity: sha512-gpG936j8/MzaeID5Yif+577c17TxaDmhuyVgSwtnL/q8UUTySg8Mecb+8Cf1otgLoD7DDH75axp86ER7LFsf3Q==} + engines: {node: '>=0.10.0'} + dependencies: + get-value: 2.0.6 + has-values: 0.1.4 + isobject: 2.1.0 + dev: true + + /has-value/1.0.0: + resolution: {integrity: sha512-IBXk4GTsLYdQ7Rvt+GRBrFSVEkmuOUy4re0Xjd9kJSUQpnTrWR4/y9RpfexN9vkAPMFuQoeWKwqzPozRTlasGw==} + engines: {node: '>=0.10.0'} + dependencies: + get-value: 2.0.6 + has-values: 1.0.0 + isobject: 3.0.1 + dev: true + + /has-values/0.1.4: + resolution: {integrity: sha512-J8S0cEdWuQbqD9//tlZxiMuMNmxB8PlEwvYwuxsTmR1G5RXUePEX/SJn7aD0GMLieuZYSwNH0cQuJGwnYunXRQ==} + engines: {node: '>=0.10.0'} + dev: true + + /has-values/1.0.0: + resolution: {integrity: sha512-ODYZC64uqzmtfGMEAX/FvZiRyWLpAC3vYnNunURUnkGVTS+mI0smVsWaPydRBsE3g+ok7h960jChO8mFcWlHaQ==} + engines: {node: '>=0.10.0'} + dependencies: + is-number: 3.0.0 + kind-of: 4.0.0 + dev: true + /https-proxy-agent/5.0.1: resolution: {integrity: sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==} engines: {node: '>= 6'} @@ -1130,6 +1340,68 @@ packages: resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==} dev: true + /is-accessor-descriptor/0.1.6: + resolution: {integrity: sha512-e1BM1qnDbMRG3ll2U9dSK0UMHuWOs3pY3AtcFsmvwPtKL3MML/Q86i+GilLfvqEs4GW+ExB91tQ3Ig9noDIZ+A==} + engines: {node: '>=0.10.0'} + dependencies: + kind-of: 3.2.2 + dev: true + + /is-accessor-descriptor/1.0.0: + resolution: {integrity: sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==} + engines: {node: '>=0.10.0'} + dependencies: + kind-of: 6.0.3 + dev: true + + /is-buffer/1.1.6: + resolution: {integrity: sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==} + dev: true + + /is-data-descriptor/0.1.4: + resolution: {integrity: sha512-+w9D5ulSoBNlmw9OHn3U2v51SyoCd0he+bB3xMl62oijhrspxowjU+AIcDY0N3iEJbUEkB15IlMASQsxYigvXg==} + engines: {node: '>=0.10.0'} + dependencies: + kind-of: 3.2.2 + dev: true + + /is-data-descriptor/1.0.0: + resolution: {integrity: sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==} + engines: {node: '>=0.10.0'} + dependencies: + kind-of: 6.0.3 + dev: true + + /is-descriptor/0.1.6: + resolution: {integrity: sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==} + engines: {node: '>=0.10.0'} + dependencies: + is-accessor-descriptor: 0.1.6 + is-data-descriptor: 0.1.4 + kind-of: 5.1.0 + dev: true + + /is-descriptor/1.0.2: + resolution: {integrity: sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==} + engines: {node: '>=0.10.0'} + dependencies: + is-accessor-descriptor: 1.0.0 + is-data-descriptor: 1.0.0 + kind-of: 6.0.3 + dev: true + + /is-extendable/0.1.1: + resolution: {integrity: sha512-5BMULNob1vgFX6EjQw5izWDxrecWK9AM72rugNr0TFldMOi0fj6Jk+zeKIt0xGj4cEfQIJth4w3OKWOJ4f+AFw==} + engines: {node: '>=0.10.0'} + dev: true + + /is-extendable/1.0.1: + resolution: {integrity: sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==} + engines: {node: '>=0.10.0'} + dependencies: + is-plain-object: 2.0.4 + dev: true + /is-extglob/2.1.1: resolution: {integrity: sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==} engines: {node: '>=0.10.0'} @@ -1142,15 +1414,50 @@ packages: is-extglob: 2.1.1 dev: true + /is-number/3.0.0: + resolution: {integrity: sha512-4cboCqIpliH+mAvFNegjZQ4kgKc3ZUhQVr3HvWbSh5q3WH2v82ct+T2Y1hdU5Gdtorx/cLifQjqCbL7bpznLTg==} + engines: {node: '>=0.10.0'} + dependencies: + kind-of: 3.2.2 + dev: true + /is-number/7.0.0: resolution: {integrity: sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==} engines: {node: '>=0.12.0'} dev: true + /is-plain-object/2.0.4: + resolution: {integrity: sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==} + engines: {node: '>=0.10.0'} + dependencies: + isobject: 3.0.1 + dev: true + + /is-windows/1.0.2: + resolution: {integrity: sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==} + engines: {node: '>=0.10.0'} + dev: true + + /isarray/1.0.0: + resolution: {integrity: sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==} + dev: true + /isexe/2.0.0: resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==} dev: true + /isobject/2.1.0: + resolution: {integrity: sha512-+OUdGJlgjOBZDfxnDjYYG6zp487z0JGNQq3cYQYg5f5hKR+syHMsaztzGeml/4kGG55CSpKSpWTY+jYGgsHLgA==} + engines: {node: '>=0.10.0'} + dependencies: + isarray: 1.0.0 + dev: true + + /isobject/3.0.1: + resolution: {integrity: sha512-WhB9zCku7EGTj/HQQRz5aUQEUeoQZH2bWcltRErOpymJ4boYE6wL9Tbr23krRPSZ+C5zqNSrSw+Cc7sZZ4b7vg==} + engines: {node: '>=0.10.0'} + dev: true + /js-sdsl/4.1.5: resolution: {integrity: sha512-08bOAKweV2NUC1wqTtf3qZlnpOX/R2DU9ikpjOHs0H+ibQv3zpncVQg6um4uYtRtrwIX8M4Nh3ytK4HGlYAq7Q==} dev: true @@ -1174,6 +1481,30 @@ packages: resolution: {integrity: sha512-HjorDJFNhnM4SicvaUXac0X77NiskggxJdesG72+O5zBKpSqKFCrqmndKVqpu3pFqkla0St6uGk8Ju0sCurrmg==} dev: false + /kind-of/3.2.2: + resolution: {integrity: sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==} + engines: {node: '>=0.10.0'} + dependencies: + is-buffer: 1.1.6 + dev: true + + /kind-of/4.0.0: + resolution: {integrity: sha512-24XsCxmEbRwEDbz/qz3stgin8TTzZ1ESR56OMCN0ujYg+vRutNSiOj9bHH9u85DKgXguraugV5sFuvbD4FW/hw==} + engines: {node: '>=0.10.0'} + dependencies: + is-buffer: 1.1.6 + dev: true + + /kind-of/5.1.0: + resolution: {integrity: sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==} + engines: {node: '>=0.10.0'} + dev: true + + /kind-of/6.0.3: + resolution: {integrity: sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==} + engines: {node: '>=0.10.0'} + dev: true + /levn/0.4.1: resolution: {integrity: sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==} engines: {node: '>= 0.8.0'} @@ -1200,6 +1531,18 @@ packages: yallist: 4.0.0 dev: true + /map-cache/0.2.2: + resolution: {integrity: sha512-8y/eV9QQZCiyn1SprXSrCmqJN0yNRATe+PO8ztwqrvrbdRLA3eYJF0yaR0YayLWkMbsQSKWS9N2gPcGEc4UsZg==} + engines: {node: '>=0.10.0'} + dev: true + + /map-visit/1.0.0: + resolution: {integrity: sha512-4y7uGv8bd2WdM9vpQsiQNo41Ln1NvhvDRuVt0k2JZQ+ezN2uaQes7lZeZ+QQUHOLQAtDaBJ+7wCbi+ab/KFs+w==} + engines: {node: '>=0.10.0'} + dependencies: + object-visit: 1.0.1 + dev: true + /merge2/1.4.1: resolution: {integrity: sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==} engines: {node: '>= 8'} @@ -1219,6 +1562,14 @@ packages: brace-expansion: 1.1.11 dev: true + /mixin-deep/1.3.2: + resolution: {integrity: sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA==} + engines: {node: '>=0.10.0'} + dependencies: + for-in: 1.0.2 + is-extendable: 1.0.1 + dev: true + /mkdirp-classic/0.5.3: resolution: {integrity: sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==} dev: true @@ -1227,10 +1578,33 @@ packages: resolution: {integrity: sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w==} dev: true + /ms/2.0.0: + resolution: {integrity: sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==} + dev: true + /ms/2.1.2: resolution: {integrity: sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==} dev: true + /nanomatch/1.2.13: + resolution: {integrity: sha512-fpoe2T0RbHwBTBUOftAfBPaDEi06ufaUai0mE6Yn1kacc3SnTErfb/h+X94VXzI64rKFHYImXSvdwGGCmwOqCA==} + engines: {node: '>=0.10.0'} + dependencies: + arr-diff: 4.0.0 + array-unique: 0.3.2 + define-property: 2.0.2 + extend-shallow: 3.0.2 + fragment-cache: 0.2.1 + is-windows: 1.0.2 + kind-of: 6.0.3 + object.pick: 1.3.0 + regex-not: 1.0.2 + snapdragon: 0.8.2 + to-regex: 3.0.2 + transitivePeerDependencies: + - supports-color + dev: true + /natural-compare-lite/1.4.0: resolution: {integrity: sha512-Tj+HTDSJJKaZnfiuw+iaF9skdPpTo2GtEly5JHnWV/hfv2Qj/9RKsGISQtLh2ox3l5EAGw487hnBee0sIJ6v2g==} dev: true @@ -1251,6 +1625,29 @@ packages: whatwg-url: 5.0.0 dev: true + /object-copy/0.1.0: + resolution: {integrity: sha512-79LYn6VAb63zgtmAteVOWo9Vdj71ZVBy3Pbse+VqxDpEP83XuujMrGqHIwAXJ5I/aM0zU7dIyIAhifVTPrNItQ==} + engines: {node: '>=0.10.0'} + dependencies: + copy-descriptor: 0.1.1 + define-property: 0.2.5 + kind-of: 3.2.2 + dev: true + + /object-visit/1.0.1: + resolution: {integrity: sha512-GBaMwwAVK9qbQN3Scdo0OyvgPW7l3lnaVMj84uTOZlswkX0KpF6fyDBJhtTthf7pymztoN36/KEr1DyhF96zEA==} + engines: {node: '>=0.10.0'} + dependencies: + isobject: 3.0.1 + dev: true + + /object.pick/1.3.0: + resolution: {integrity: sha512-tqa/UMy/CCoYmj+H5qc07qvSL9dqcs/WZENZ1JbtWBlATP+iVOe778gE6MSijnyCnORzDuX6hU+LA4SZ09YjFQ==} + engines: {node: '>=0.10.0'} + dependencies: + isobject: 3.0.1 + dev: true + /once/1.4.0: resolution: {integrity: sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==} dependencies: @@ -1290,6 +1687,11 @@ packages: callsites: 3.1.0 dev: true + /pascalcase/0.1.1: + resolution: {integrity: sha512-XHXfu/yOQRy9vYOtUDVMN60OEJjW013GoObG1o+xwQTpB9eYJX/BjXMsdW13ZDPruFhYYn0AG22w0xgQMwl3Nw==} + engines: {node: '>=0.10.0'} + dev: true + /path-exists/4.0.0: resolution: {integrity: sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==} engines: {node: '>=8'} @@ -1374,6 +1776,14 @@ packages: util-deprecate: 1.0.2 dev: true + /regex-not/1.0.2: + resolution: {integrity: sha512-J6SDjUgDxQj5NusnOtdFxDwN/+HWykR8GELwctJ7mdqhcyy1xEc4SRFHUXvxTp661YaVKAjfRLZ9cCqS6tn32A==} + engines: {node: '>=0.10.0'} + dependencies: + extend-shallow: 3.0.2 + safe-regex: 1.1.0 + dev: true + /regexpp/3.2.0: resolution: {integrity: sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg==} engines: {node: '>=8'} @@ -1384,6 +1794,16 @@ packages: engines: {node: '>=4'} dev: true + /resolve-url/0.2.1: + resolution: {integrity: sha512-ZuF55hVUQaaczgOIwqWzkEcEidmlD/xl44x1UZnhOXcYuFN2S6+rcxpG+C1N3So0wvNI3DmJICUFfu2SxhBmvg==} + deprecated: https://github.com/lydell/resolve-url#deprecated + dev: true + + /ret/0.1.15: + resolution: {integrity: sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==} + engines: {node: '>=0.12'} + dev: true + /reusify/1.0.4: resolution: {integrity: sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==} engines: {iojs: '>=1.0.0', node: '>=0.10.0'} @@ -1406,6 +1826,12 @@ packages: resolution: {integrity: sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==} dev: true + /safe-regex/1.1.0: + resolution: {integrity: sha512-aJXcif4xnaNUzvUuC5gcb46oTS7zvg4jpMTnuqtrEPlR3vFr4pxtdTwaF1Qs3Enjn9HK+ZlwQui+a7z0SywIzg==} + dependencies: + ret: 0.1.15 + dev: true + /semver/7.3.7: resolution: {integrity: sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==} engines: {node: '>=10'} @@ -1414,6 +1840,16 @@ packages: lru-cache: 6.0.0 dev: true + /set-value/2.0.1: + resolution: {integrity: sha512-JxHc1weCN68wRY0fhCoXpyK55m/XPHafOmK4UWD7m2CI14GMcFypt4w/0+NV5f/ZMby2F6S2wwA7fgynh9gWSw==} + engines: {node: '>=0.10.0'} + dependencies: + extend-shallow: 2.0.1 + is-extendable: 0.1.1 + is-plain-object: 2.0.4 + split-string: 3.1.0 + dev: true + /shebang-command/2.0.0: resolution: {integrity: sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==} engines: {node: '>=8'} @@ -1431,12 +1867,64 @@ packages: engines: {node: '>=8'} dev: true + /snapdragon/0.8.2: + resolution: {integrity: sha512-FtyOnWN/wCHTVXOMwvSv26d+ko5vWlIDD6zoUJ7LW8vh+ZBC8QdljveRP+crNrtBwioEUWy/4dMtbBjA4ioNlg==} + engines: {node: '>=0.10.0'} + dependencies: + base: 0.11.2 + debug: 2.6.9 + define-property: 0.2.5 + extend-shallow: 2.0.1 + map-cache: 0.2.2 + source-map: 0.5.7 + source-map-resolve: 0.5.3 + use: 3.1.1 + transitivePeerDependencies: + - supports-color + dev: true + + /source-map-resolve/0.5.3: + resolution: {integrity: sha512-Htz+RnsXWk5+P2slx5Jh3Q66vhQj1Cllm0zvnaY98+NFx+Dv2CF/f5O/t8x+KaNdrdIAsruNzoh/KpialbqAnw==} + deprecated: See https://github.com/lydell/source-map-resolve#deprecated + dependencies: + atob: 2.1.2 + decode-uri-component: 0.2.0 + resolve-url: 0.2.1 + source-map-url: 0.4.1 + urix: 0.1.0 + dev: true + + /source-map-url/0.4.1: + resolution: {integrity: sha512-cPiFOTLUKvJFIg4SKVScy4ilPPW6rFgMgfuZJPNoDuMs3nC1HbMUycBoJw77xFIp6z1UJQJOfx6C9GMH80DiTw==} + deprecated: See https://github.com/lydell/source-map-url#deprecated + dev: true + + /source-map/0.5.7: + resolution: {integrity: sha512-LbrmJOMUSdEVxIKvdcJzQC+nQhe8FUZQTXQy6+I75skNgn3OoQ0DZA8YnFa7gp8tqtL3KPf1kmo0R5DoApeSGQ==} + engines: {node: '>=0.10.0'} + dev: true + + /split-string/3.1.0: + resolution: {integrity: sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw==} + engines: {node: '>=0.10.0'} + dependencies: + extend-shallow: 3.0.2 + dev: true + /standalone-electron-types/1.0.0: resolution: {integrity: sha512-0HOi/tlTz3mjWhsAz4uRbpQcHMZ+ifj1JzWW9nugykOHClBBG77ps8QinrzX1eow4Iw2pnC+RFaSYRgufF4BOg==} dependencies: '@types/node': 18.8.4 dev: true + /static-extend/0.1.2: + resolution: {integrity: sha512-72E9+uLc27Mt718pMHt9VMNiAL4LMsmDbBva8mxWUCkT07fSzEGMYUCk0XWY6lp0j6RBAG4cJ3mWuZv2OE3s0g==} + engines: {node: '>=0.10.0'} + dependencies: + define-property: 0.2.5 + object-copy: 0.1.0 + dev: true + /string_decoder/1.3.0: resolution: {integrity: sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==} dependencies: @@ -1490,6 +1978,13 @@ packages: resolution: {integrity: sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==} dev: true + /to-object-path/0.3.0: + resolution: {integrity: sha512-9mWHdnGRuh3onocaHzukyvCZhzvr6tiflAy/JRFXcJX0TjgfWA9pk9t8CMbzmBE4Jfw58pXbkngtBtqYxzNEyg==} + engines: {node: '>=0.10.0'} + dependencies: + kind-of: 3.2.2 + dev: true + /to-regex-range/5.0.1: resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==} engines: {node: '>=8.0'} @@ -1497,6 +1992,16 @@ packages: is-number: 7.0.0 dev: true + /to-regex/3.0.2: + resolution: {integrity: sha512-FWtleNAtZ/Ki2qtqej2CXTOayOH9bHDQF+Q48VpWyDXjbYxA4Yz8iDB31zXOBUlOHHKidDbqGVrTUvQMPmBGBw==} + engines: {node: '>=0.10.0'} + dependencies: + define-property: 2.0.2 + extend-shallow: 3.0.2 + regex-not: 1.0.2 + safe-regex: 1.1.0 + dev: true + /tr46/0.0.3: resolution: {integrity: sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==} dev: true @@ -1545,12 +2050,40 @@ packages: through: 2.3.8 dev: true + /union-value/1.0.1: + resolution: {integrity: sha512-tJfXmxMeWYnczCVs7XAEvIV7ieppALdyepWMkHkwciRpZraG/xwT+s2JN8+pr1+8jCRf80FFzvr+MpQeeoF4Xg==} + engines: {node: '>=0.10.0'} + dependencies: + arr-union: 3.1.0 + get-value: 2.0.6 + is-extendable: 0.1.1 + set-value: 2.0.1 + dev: true + + /unset-value/1.0.0: + resolution: {integrity: sha512-PcA2tsuGSF9cnySLHTLSh2qrQiJ70mn+r+Glzxv2TWZblxsxCC52BDlZoPCsz7STd9pN7EZetkWZBAvk4cgZdQ==} + engines: {node: '>=0.10.0'} + dependencies: + has-value: 0.3.1 + isobject: 3.0.1 + dev: true + /uri-js/4.4.1: resolution: {integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==} dependencies: punycode: 2.1.1 dev: true + /urix/0.1.0: + resolution: {integrity: sha512-Am1ousAhSLBeB9cG/7k7r2R0zj50uDRlZHPGbazid5s9rlF1F/QKYObEKSIunSjIOkJZqwRRLpvewjEkM7pSqg==} + deprecated: Please see https://github.com/lydell/urix#deprecated + dev: true + + /use/3.1.1: + resolution: {integrity: sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ==} + engines: {node: '>=0.10.0'} + dev: true + /util-deprecate/1.0.2: resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==} dev: true diff --git a/scripts/genPluginList.js b/scripts/genPluginList.js index 909ee4066..efe22ac4a 100644 --- a/scripts/genPluginList.js +++ b/scripts/genPluginList.js @@ -58,6 +58,5 @@ ${p.description} list += "\n\n"; } - const data = new TextEncoder().encode(header + tableOfContents + list); - DiscordNative.fileManager.saveWithDialog(data, "plugins.md"); + copy(header + tableOfContents + list); })(); diff --git a/scripts/patcher/common.js b/scripts/patcher/common.js index 3217d5c71..5ccd0e811 100644 --- a/scripts/patcher/common.js +++ b/scripts/patcher/common.js @@ -59,6 +59,7 @@ const LINUX_DISCORD_DIRS = [ "/usr/lib64", "/opt", `${process.env.HOME}/.local/share`, + `${process.env.HOME}/.dvm`, "/var/lib/flatpak/app", `${process.env.HOME}/.local/share/flatpak/app`, ]; diff --git a/src/VencordNative.ts b/src/VencordNative.ts index c98487072..3cd53e188 100644 --- a/src/VencordNative.ts +++ b/src/VencordNative.ts @@ -16,10 +16,9 @@ * along with this program. If not, see . */ +import IPC_EVENTS from "@utils/IpcEvents"; import { IpcRenderer, ipcRenderer } from "electron"; -import IPC_EVENTS from "./utils/IpcEvents"; - function assertEventAllowed(event: string) { if (!(event in IPC_EVENTS)) throw new Error(`Event ${event} not allowed.`); } diff --git a/src/api/Commands/commandHelpers.ts b/src/api/Commands/commandHelpers.ts index 8986248d8..d363d6edb 100644 --- a/src/api/Commands/commandHelpers.ts +++ b/src/api/Commands/commandHelpers.ts @@ -16,15 +16,15 @@ * along with this program. If not, see . */ +import { mergeDefaults } from "@utils/misc"; +import { findByCodeLazy, findByPropsLazy, waitFor } from "@webpack"; import { Message } from "discord-types/general"; import type { PartialDeep } from "type-fest"; -import { lazyWebpack, mergeDefaults } from "../../utils/misc"; -import { filters, waitFor } from "../../webpack"; import { Argument } from "./types"; -const createBotMessage = lazyWebpack(filters.byCode('username:"Clyde"')); -const MessageSender = lazyWebpack(filters.byProps("receiveMessage")); +const createBotMessage = findByCodeLazy('username:"Clyde"'); +const MessageSender = findByPropsLazy("receiveMessage"); let SnowflakeUtils: any; waitFor("fromTimestamp", m => SnowflakeUtils = m); diff --git a/src/api/Commands/index.ts b/src/api/Commands/index.ts index f31043c41..88139d4d3 100644 --- a/src/api/Commands/index.ts +++ b/src/api/Commands/index.ts @@ -16,7 +16,8 @@ * along with this program. If not, see . */ -import { makeCodeblock } from "../../utils/misc"; +import { makeCodeblock } from "@utils/misc"; + import { sendBotMessage } from "./commandHelpers"; import { ApplicationCommandInputType, ApplicationCommandOptionType, ApplicationCommandType, Argument, Command, CommandContext, Option } from "./types"; diff --git a/src/api/MessageEvents.ts b/src/api/MessageEvents.ts index 02638b2bd..1bf6b0bcb 100644 --- a/src/api/MessageEvents.ts +++ b/src/api/MessageEvents.ts @@ -16,11 +16,10 @@ * along with this program. If not, see . */ +import Logger from "@utils/Logger"; +import { MessageStore } from "@webpack/common"; import type { Channel, Message } from "discord-types/general"; -import Logger from "../utils/Logger"; -import { MessageStore } from "../webpack/common"; - const MessageEventsLogger = new Logger("MessageEvents", "#e5c890"); export interface Emoji { diff --git a/src/api/Notices.ts b/src/api/Notices.ts index 4364ca5a0..6d20087a7 100644 --- a/src/api/Notices.ts +++ b/src/api/Notices.ts @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import { waitFor } from "../webpack"; +import { waitFor } from "@webpack"; let NoticesModule: any; waitFor(m => m.show && m.dismiss && !m.suppressAll, m => NoticesModule = m); diff --git a/src/api/ServerList.ts b/src/api/ServerList.ts index d3a9a110a..c98b1740c 100644 --- a/src/api/ServerList.ts +++ b/src/api/ServerList.ts @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import Logger from "../utils/Logger"; +import Logger from "@utils/Logger"; const logger = new Logger("ServerListAPI"); diff --git a/src/api/settings.ts b/src/api/settings.ts index dd8692a2f..9e5480096 100644 --- a/src/api/settings.ts +++ b/src/api/settings.ts @@ -16,13 +16,13 @@ * along with this program. If not, see . */ -import plugins from "~plugins"; +import IpcEvents from "@utils/IpcEvents"; +import Logger from "@utils/Logger"; +import { mergeDefaults } from "@utils/misc"; +import { OptionType } from "@utils/types"; +import { React } from "@webpack/common"; -import IpcEvents from "../utils/IpcEvents"; -import Logger from "../utils/Logger"; -import { mergeDefaults } from "../utils/misc"; -import { OptionType } from "../utils/types"; -import { React } from "../webpack/common"; +import plugins from "~plugins"; const logger = new Logger("Settings"); export interface Settings { @@ -48,16 +48,18 @@ try { var settings = JSON.parse(VencordNative.ipc.sendSync(IpcEvents.GET_SETTINGS)) as Settings; mergeDefaults(settings, DefaultSettings); } catch (err) { - console.error("Corrupt settings file. ", err); var settings = mergeDefaults({} as Settings, DefaultSettings); + logger.error("An error occurred while loading the settings. Corrupt settings file?\n", err); } type SubscriptionCallback = ((newValue: any, path: string) => void) & { _path?: string; }; const subscriptions = new Set(); +const proxyCache = {} as Record; + // Wraps the passed settings object in a Proxy to nicely handle change listeners and default values function makeProxy(settings: any, root = settings, path = ""): Settings { - return new Proxy(settings, { + return proxyCache[path] ??= new Proxy(settings, { get(target, p: string) { const v = target[p]; @@ -67,7 +69,7 @@ function makeProxy(settings: any, root = settings, path = ""): Settings { if (path === "plugins" && p in plugins) return target[p] = makeProxy({ enabled: plugins[p].required ?? false - }, root, `plugins/${p}`); + }, root, `plugins.${p}`); // Since the property is not set, check if this is a plugin's setting and if so, try to resolve // the default value. diff --git a/src/components/CheckedTextInput.tsx b/src/components/CheckedTextInput.tsx index e97519dd7..cf4aa119b 100644 --- a/src/components/CheckedTextInput.tsx +++ b/src/components/CheckedTextInput.tsx @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import { React, TextInput } from "../webpack/common"; +import { React, TextInput } from "@webpack/common"; // TODO: Refactor settings to use this as well interface TextInputProps { diff --git a/src/components/DonateButton.tsx b/src/components/DonateButton.tsx index 6aae8ad02..49f079b4f 100644 --- a/src/components/DonateButton.tsx +++ b/src/components/DonateButton.tsx @@ -16,8 +16,9 @@ * along with this program. If not, see . */ -import IpcEvents from "../utils/IpcEvents"; -import { Button } from "../webpack/common"; +import IpcEvents from "@utils/IpcEvents"; +import { Button } from "@webpack/common"; + import { Heart } from "./Heart"; export default function DonateButton(props: any) { diff --git a/src/components/ErrorBoundary.tsx b/src/components/ErrorBoundary.tsx index 86a594649..8ebc61bbb 100644 --- a/src/components/ErrorBoundary.tsx +++ b/src/components/ErrorBoundary.tsx @@ -16,9 +16,10 @@ * along with this program. If not, see . */ -import Logger from "../utils/Logger"; -import { LazyComponent } from "../utils/misc"; -import { Margins, React } from "../webpack/common"; +import Logger from "@utils/Logger"; +import { LazyComponent } from "@utils/misc"; +import { Margins, React } from "@webpack/common"; + import { ErrorCard } from "./ErrorCard"; interface Props { diff --git a/src/components/ErrorCard.tsx b/src/components/ErrorCard.tsx index f83be383b..e749ea4b6 100644 --- a/src/components/ErrorCard.tsx +++ b/src/components/ErrorCard.tsx @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import { Card } from "../webpack/common"; +import { Card } from "@webpack/common"; interface Props { style?: React.CSSProperties; diff --git a/src/components/Flex.tsx b/src/components/Flex.tsx index 1987faba7..430d85768 100644 --- a/src/components/Flex.tsx +++ b/src/components/Flex.tsx @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import type { React } from "../webpack/common"; +import type { React } from "@webpack/common"; export function Flex(props: React.PropsWithChildren<{ flexDirection?: React.CSSProperties["flexDirection"]; diff --git a/src/components/Link.tsx b/src/components/Link.tsx index 2400ea67f..0f4eb07db 100644 --- a/src/components/Link.tsx +++ b/src/components/Link.tsx @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import { React } from "../webpack/common"; +import { React } from "@webpack/common"; interface Props extends React.DetailedHTMLProps, HTMLAnchorElement> { disabled?: boolean; diff --git a/src/components/Monaco.ts b/src/components/Monaco.ts index 16eff859d..aa98f998c 100644 --- a/src/components/Monaco.ts +++ b/src/components/Monaco.ts @@ -16,16 +16,16 @@ * along with this program. If not, see . */ -import monacoHtml from "~fileContent/monacoWin.html"; +import { debounce } from "@utils/debounce"; +import IpcEvents from "@utils/IpcEvents"; +import { Queue } from "@utils/Queue"; +import { find } from "@webpack"; -import { debounce } from "../utils/debounce"; -import IpcEvents from "../utils/IpcEvents"; -import { Queue } from "../utils/Queue"; -import { find } from "../webpack/webpack"; +import monacoHtml from "~fileContent/monacoWin.html"; const queue = new Queue(); const setCss = debounce((css: string) => { - queue.add(() => VencordNative.ipc.invoke(IpcEvents.SET_QUICK_CSS, css)); + queue.push(() => VencordNative.ipc.invoke(IpcEvents.SET_QUICK_CSS, css)); }); export async function launchMonacoEditor() { diff --git a/src/components/PatchHelper.tsx b/src/components/PatchHelper.tsx index 82b804ae4..22c2b4dc0 100644 --- a/src/components/PatchHelper.tsx +++ b/src/components/PatchHelper.tsx @@ -16,10 +16,11 @@ * along with this program. If not, see . */ -import { debounce } from "../utils/debounce"; -import { makeCodeblock } from "../utils/misc"; -import { Button, Clipboard, Forms, Margins, Parser, React, Switch, TextInput } from "../webpack/common"; -import { search } from "../webpack/webpack"; +import { debounce } from "@utils/debounce"; +import { makeCodeblock } from "@utils/misc"; +import { search } from "@webpack"; +import { Button, Clipboard, Forms, Margins, Parser, React, Switch, Text, TextInput } from "@webpack/common"; + import { CheckedTextInput } from "./CheckedTextInput"; import ErrorBoundary from "./ErrorBoundary"; @@ -243,7 +244,8 @@ function PatchHelper() { } return ( - <> + + Patch Helper find Clipboard.copy(code)}>Copy to Clipboard )} - + ); } diff --git a/src/components/PluginSettings/PluginModal.tsx b/src/components/PluginSettings/PluginModal.tsx index 7331fffaf..d1916673c 100644 --- a/src/components/PluginSettings/PluginModal.tsx +++ b/src/components/PluginSettings/PluginModal.tsx @@ -16,19 +16,19 @@ * along with this program. If not, see . */ +import { generateId } from "@api/Commands"; +import { useSettings } from "@api/settings"; +import ErrorBoundary from "@components/ErrorBoundary"; +import { Flex } from "@components/Flex"; +import { LazyComponent } from "@utils/misc"; +import { ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, ModalSize } from "@utils/modal"; +import { proxyLazy } from "@utils/proxyLazy"; +import { OptionType, Plugin } from "@utils/types"; +import { findByCode, findByPropsLazy } from "@webpack"; +import { Button, FluxDispatcher, Forms, React, Text, Tooltip, UserStore, UserUtils } from "@webpack/common"; import { User } from "discord-types/general"; import { Constructor } from "type-fest"; -import { generateId } from "../../api/Commands"; -import { useSettings } from "../../api/settings"; -import { LazyComponent, lazyWebpack } from "../../utils/misc"; -import { ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, ModalSize } from "../../utils/modal"; -import { proxyLazy } from "../../utils/proxyLazy"; -import { OptionType, Plugin } from "../../utils/types"; -import { filters, findByCode } from "../../webpack"; -import { Button, FluxDispatcher, Forms, React, Text, Tooltip, UserStore, UserUtils } from "../../webpack/common"; -import ErrorBoundary from "../ErrorBoundary"; -import { Flex } from "../Flex"; import { ISettingElementProps, SettingBooleanComponent, @@ -40,7 +40,7 @@ import { } from "./components"; const UserSummaryItem = LazyComponent(() => findByCode("defaultRenderUser", "showDefaultAvatarsForNullUsers")); -const AvatarStyles = lazyWebpack(filters.byProps("moreUsers", "emptyUser", "avatarContainer", "clickableAvatar")); +const AvatarStyles = findByPropsLazy("moreUsers", "emptyUser", "avatarContainer", "clickableAvatar"); const UserRecord: Constructor> = proxyLazy(() => UserStore.getCurrentUser().constructor) as any; interface PluginModalProps extends ModalProps { diff --git a/src/components/PluginSettings/components/SettingBooleanComponent.tsx b/src/components/PluginSettings/components/SettingBooleanComponent.tsx index 99c1eae80..0aaafa049 100644 --- a/src/components/PluginSettings/components/SettingBooleanComponent.tsx +++ b/src/components/PluginSettings/components/SettingBooleanComponent.tsx @@ -16,8 +16,9 @@ * along with this program. If not, see . */ -import { PluginOptionBoolean } from "../../../utils/types"; -import { Forms, React, Select } from "../../../webpack/common"; +import { PluginOptionBoolean } from "@utils/types"; +import { Forms, React, Select } from "@webpack/common"; + import { ISettingElementProps } from "."; export function SettingBooleanComponent({ option, pluginSettings, id, onChange, onError }: ISettingElementProps) { diff --git a/src/components/PluginSettings/components/SettingCustomComponent.tsx b/src/components/PluginSettings/components/SettingCustomComponent.tsx index dd704bf39..af7192f3f 100644 --- a/src/components/PluginSettings/components/SettingCustomComponent.tsx +++ b/src/components/PluginSettings/components/SettingCustomComponent.tsx @@ -16,7 +16,8 @@ * along with this program. If not, see . */ -import { PluginOptionComponent } from "../../../utils/types"; +import { PluginOptionComponent } from "@utils/types"; + import { ISettingElementProps } from "."; export function SettingCustomComponent({ option, onChange, onError }: ISettingElementProps) { diff --git a/src/components/PluginSettings/components/SettingNumericComponent.tsx b/src/components/PluginSettings/components/SettingNumericComponent.tsx index 01e72dc7f..3457783e9 100644 --- a/src/components/PluginSettings/components/SettingNumericComponent.tsx +++ b/src/components/PluginSettings/components/SettingNumericComponent.tsx @@ -16,8 +16,9 @@ * along with this program. If not, see . */ -import { OptionType, PluginOptionNumber } from "../../../utils/types"; -import { Forms, React, TextInput } from "../../../webpack/common"; +import { OptionType, PluginOptionNumber } from "@utils/types"; +import { Forms, React, TextInput } from "@webpack/common"; + import { ISettingElementProps } from "."; const MAX_SAFE_NUMBER = BigInt(Number.MAX_SAFE_INTEGER); diff --git a/src/components/PluginSettings/components/SettingSelectComponent.tsx b/src/components/PluginSettings/components/SettingSelectComponent.tsx index ce35675c7..8a5bee1cd 100644 --- a/src/components/PluginSettings/components/SettingSelectComponent.tsx +++ b/src/components/PluginSettings/components/SettingSelectComponent.tsx @@ -16,8 +16,9 @@ * along with this program. If not, see . */ -import { PluginOptionSelect } from "../../../utils/types"; -import { Forms, React, Select } from "../../../webpack/common"; +import { PluginOptionSelect } from "@utils/types"; +import { Forms, React, Select } from "@webpack/common"; + import { ISettingElementProps } from "."; export function SettingSelectComponent({ option, pluginSettings, onChange, onError, id }: ISettingElementProps) { diff --git a/src/components/PluginSettings/components/SettingSliderComponent.tsx b/src/components/PluginSettings/components/SettingSliderComponent.tsx index ff1c491d4..2d3169679 100644 --- a/src/components/PluginSettings/components/SettingSliderComponent.tsx +++ b/src/components/PluginSettings/components/SettingSliderComponent.tsx @@ -16,8 +16,9 @@ * along with this program. If not, see . */ -import { PluginOptionSlider } from "../../../utils/types"; -import { Forms, React, Slider } from "../../../webpack/common"; +import { PluginOptionSlider } from "@utils/types"; +import { Forms, React, Slider } from "@webpack/common"; + import { ISettingElementProps } from "."; export function makeRange(start: number, end: number, step = 1) { diff --git a/src/components/PluginSettings/components/SettingTextComponent.tsx b/src/components/PluginSettings/components/SettingTextComponent.tsx index f76bd5874..b92fceccf 100644 --- a/src/components/PluginSettings/components/SettingTextComponent.tsx +++ b/src/components/PluginSettings/components/SettingTextComponent.tsx @@ -16,8 +16,9 @@ * along with this program. If not, see . */ -import { PluginOptionString } from "../../../utils/types"; -import { Forms, React, TextInput } from "../../../webpack/common"; +import { PluginOptionString } from "@utils/types"; +import { Forms, React, TextInput } from "@webpack/common"; + import { ISettingElementProps } from "."; export function SettingTextComponent({ option, pluginSettings, id, onChange, onError }: ISettingElementProps) { diff --git a/src/components/PluginSettings/components/index.ts b/src/components/PluginSettings/components/index.ts index 507b53a5d..9e7506816 100644 --- a/src/components/PluginSettings/components/index.ts +++ b/src/components/PluginSettings/components/index.ts @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import { PluginOptionBase } from "../../../utils/types"; +import { PluginOptionBase } from "@utils/types"; export interface ISettingElementProps { option: T; @@ -35,3 +35,4 @@ export * from "./SettingNumericComponent"; export * from "./SettingSelectComponent"; export * from "./SettingSliderComponent"; export * from "./SettingTextComponent"; + diff --git a/src/components/PluginSettings/index.tsx b/src/components/PluginSettings/index.tsx index 2de93621f..5ee9cc941 100644 --- a/src/components/PluginSettings/index.tsx +++ b/src/components/PluginSettings/index.tsx @@ -16,28 +16,29 @@ * along with this program. If not, see . */ +import { showNotice } from "@api/Notices"; +import { Settings, useSettings } from "@api/settings"; +import ErrorBoundary from "@components/ErrorBoundary"; +import { ErrorCard } from "@components/ErrorCard"; +import { Flex } from "@components/Flex"; +import { handleComponentFailed } from "@components/handleComponentFailed"; +import { ChangeList } from "@utils/ChangeList"; +import Logger from "@utils/Logger"; +import { classes, LazyComponent } from "@utils/misc"; +import { openModalLazy } from "@utils/modal"; +import { Plugin } from "@utils/types"; +import { findByCode, findByPropsLazy } from "@webpack"; +import { Alerts, Button, Forms, Margins, Parser, React, Select, Switch, Text, TextInput, Toasts, Tooltip } from "@webpack/common"; + import Plugins from "~plugins"; -import { showNotice } from "../../api/Notices"; -import { Settings, useSettings } from "../../api/settings"; import { startDependenciesRecursive, startPlugin, stopPlugin } from "../../plugins"; -import { ChangeList } from "../../utils/ChangeList"; -import Logger from "../../utils/Logger"; -import { classes, LazyComponent, lazyWebpack } from "../../utils/misc"; -import { openModalLazy } from "../../utils/modal"; -import { Plugin } from "../../utils/types"; -import { filters, findByCode } from "../../webpack"; -import { Alerts, Button, Forms, Margins, Parser, React, Select, Switch, Text, TextInput, Toasts, Tooltip } from "../../webpack/common"; -import ErrorBoundary from "../ErrorBoundary"; -import { ErrorCard } from "../ErrorCard"; -import { Flex } from "../Flex"; -import { handleComponentFailed } from "../handleComponentFailed"; import PluginModal from "./PluginModal"; import * as styles from "./styles"; const logger = new Logger("PluginSettings", "#a6d189"); -const InputStyles = lazyWebpack(filters.byProps("inputDefault", "inputWrapper")); +const InputStyles = findByPropsLazy("inputDefault", "inputWrapper"); const CogWheel = LazyComponent(() => findByCode("18.564C15.797 19.099 14.932 19.498 14 19.738V22H10V19.738C9.069")); const InfoIcon = LazyComponent(() => findByCode("4.4408921e-16 C4.4771525,-1.77635684e-15 4.4408921e-16")); @@ -243,9 +244,9 @@ export default ErrorBoundary.wrap(function Settings() { }; return ( - + - Plugins + Filters @@ -268,6 +269,8 @@ export default ErrorBoundary.wrap(function Settings() { + Plugins +
{sortedPlugins?.length ? sortedPlugins .filter(a => !a.required && !dependencyCheck(a.name, depMap).length && pluginFilter(a)) @@ -302,7 +305,7 @@ export default ErrorBoundary.wrap(function Settings() { changes.add(name)} + onRestartNeeded={name => changes.handleChange(name)} disabled={plugin.required || !!dependency} plugin={plugin} /> diff --git a/src/components/Settings.tsx b/src/components/Settings.tsx deleted file mode 100644 index e2abff2e3..000000000 --- a/src/components/Settings.tsx +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Vencord, a modification for Discord's desktop app - * Copyright (c) 2022 Vendicated and contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . -*/ - -import { useSettings } from "../api/settings"; -import { ChangeList } from "../utils/ChangeList"; -import IpcEvents from "../utils/IpcEvents"; -import { useAwaiter } from "../utils/misc"; -import { downloadSettingsBackup, uploadSettingsBackup } from "../utils/settingsSync"; -import { Alerts, Button, Card, Forms, Margins, Parser, React, Switch } from "../webpack/common"; -import DonateButton from "./DonateButton"; -import ErrorBoundary from "./ErrorBoundary"; -import { Flex } from "./Flex"; -import { handleComponentFailed } from "./handleComponentFailed"; - -export default ErrorBoundary.wrap(function Settings() { - const [settingsDir, , settingsDirPending] = useAwaiter(() => VencordNative.ipc.invoke(IpcEvents.GET_SETTINGS_DIR), "Loading..."); - const settings = useSettings(); - const changes = React.useMemo(() => new ChangeList(), []); - - React.useEffect(() => { - return () => void (changes.hasChanges && Alerts.show({ - title: "Restart required", - body: ( - <> -

The following plugins require a restart:

-
{changes.map((s, i) => ( - <> - {i > 0 && ", "} - {Parser.parse("`" + s + "`")} - - ))}
- - ), - confirmText: "Restart now", - cancelText: "Later!", - onConfirm: () => location.reload() - })); - }, []); - - return ( - - -
- Support the Project - - Please consider supporting the Development of Vencord by donating! - - -
- -
- - - Settings - - - - Settings Directory: {settingsDir} - - - {!IS_WEB && - - - - } - - {IS_WEB && } - - - settings.useQuickCss = v} - note="Loads styles from your QuickCss file" - > - Use QuickCss - - {!IS_WEB && settings.enableReactDevtools = v} - note="Requires a full restart" - > - Enable React Developer Tools - } - {!IS_WEB && settings.notifyAboutUpdates = v} - note="Shows a Toast on StartUp" - > - Get notified about new Updates - } - - - Settings Sync - - - - -
- ); -}, { - message: "Failed to render the Settings. If this persists, try using the installer to reinstall!", - onError: handleComponentFailed, -}); diff --git a/src/components/VencordSettings/BackupRestoreTab.tsx b/src/components/VencordSettings/BackupRestoreTab.tsx new file mode 100644 index 000000000..f0730b345 --- /dev/null +++ b/src/components/VencordSettings/BackupRestoreTab.tsx @@ -0,0 +1,69 @@ +/* + * Vencord, a modification for Discord's desktop app + * Copyright (c) 2022 Vendicated and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . +*/ + +import ErrorBoundary from "@components/ErrorBoundary"; +import { Flex } from "@components/Flex"; +import { downloadSettingsBackup, uploadSettingsBackup } from "@utils/settingsSync"; +import { Button, Card, Forms, Margins, Text } from "@webpack/common"; + +function BackupRestoreTab() { + return ( + + + + Warning + Importing a settings file will overwrite your current settings. + + + + You can import and export your Vencord settings as a JSON file. + This allows you to easily transfer your settings to another device, + or recover your settings after reinstalling Vencord or Discord. + + + Settings Export contains: +
    +
  • — Custom QuickCSS
  • +
  • — Plugin Settings
  • +
+
+ + + + +
+ ); +} + +export default ErrorBoundary.wrap(BackupRestoreTab); diff --git a/src/components/VencordSettings/PluginsTab.tsx b/src/components/VencordSettings/PluginsTab.tsx new file mode 100644 index 000000000..04b5dc26f --- /dev/null +++ b/src/components/VencordSettings/PluginsTab.tsx @@ -0,0 +1,22 @@ +/* + * Vencord, a modification for Discord's desktop app + * Copyright (c) 2022 Vendicated and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . +*/ + +import ErrorBoundary from "@components/ErrorBoundary"; +import PluginSettings from "@components/PluginSettings"; + +export default ErrorBoundary.wrap(PluginSettings); diff --git a/src/components/Updater.tsx b/src/components/VencordSettings/Updater.tsx similarity index 94% rename from src/components/Updater.tsx rename to src/components/VencordSettings/Updater.tsx index 8abdf288f..bb344f5e8 100644 --- a/src/components/Updater.tsx +++ b/src/components/VencordSettings/Updater.tsx @@ -16,16 +16,16 @@ * along with this program. If not, see . */ -import gitHash from "~git-hash"; +import ErrorBoundary from "@components/ErrorBoundary"; +import { ErrorCard } from "@components/ErrorCard"; +import { Flex } from "@components/Flex"; +import { handleComponentFailed } from "@components/handleComponentFailed"; +import { Link } from "@components/Link"; +import { classes, useAwaiter } from "@utils/misc"; +import { changes, checkForUpdates, getRepo, isNewer, rebuild, update, updateError, UpdateLogger } from "@utils/updater"; +import { Alerts, Button, Card, Forms, Margins, Parser, React, Toasts } from "@webpack/common"; -import { classes, useAwaiter } from "../utils/misc"; -import { changes, checkForUpdates, getRepo, isNewer, rebuild, update, updateError, UpdateLogger } from "../utils/updater"; -import { Alerts, Button, Card, Forms, Margins, Parser, React, Toasts } from "../webpack/common"; -import ErrorBoundary from "./ErrorBoundary"; -import { ErrorCard } from "./ErrorCard"; -import { Flex } from "./Flex"; -import { handleComponentFailed } from "./handleComponentFailed"; -import { Link } from "./Link"; +import gitHash from "~git-hash"; function withDispatcher(dispatcher: React.Dispatch>, action: () => any) { return async () => { @@ -192,7 +192,7 @@ function Updater() { }; return ( - + Repo {repoPending ? repo : err ? "Failed to retrieve - check console" : ( diff --git a/src/components/VencordSettings/VencordTab.tsx b/src/components/VencordSettings/VencordTab.tsx new file mode 100644 index 000000000..04fb057f0 --- /dev/null +++ b/src/components/VencordSettings/VencordTab.tsx @@ -0,0 +1,134 @@ +/* + * Vencord, a modification for Discord's desktop app + * Copyright (c) 2022 Vendicated and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . +*/ + + +import { useSettings } from "@api/settings"; +import DonateButton from "@components/DonateButton"; +import ErrorBoundary from "@components/ErrorBoundary"; +import IpcEvents from "@utils/IpcEvents"; +import { useAwaiter } from "@utils/misc"; +import { Button, Card, Forms, React, Switch } from "@webpack/common"; + +const st = (style: string) => `vcSettings${style}`; + +function VencordSettings() { + const [settingsDir, , settingsDirPending] = useAwaiter(() => VencordNative.ipc.invoke(IpcEvents.GET_SETTINGS_DIR), "Loading..."); + const settings = useSettings(); + + return ( + + + + + {IS_WEB ? ( + + ) : ( + + + + + + + )} + + + + + + + settings.useQuickCss = v} + note="Loads styles from your QuickCss file"> + Use QuickCss + + {!IS_WEB && ( + + settings.enableReactDevtools = v} + note="Requires a full restart"> + Enable React Developer Tools + + settings.notifyAboutUpdates = v} + note="Shows a Toast on StartUp"> + Get notified about new Updates + + + )} + + + + ); +} + + + +function DonateCard() { + return ( + +
+ Support the Project + + Please consider supporting the Development of Vencord by donating! + + +
+ +
+ ); +} + +export default ErrorBoundary.wrap(VencordSettings); diff --git a/src/components/VencordSettings/index.tsx b/src/components/VencordSettings/index.tsx new file mode 100644 index 000000000..37dab8f50 --- /dev/null +++ b/src/components/VencordSettings/index.tsx @@ -0,0 +1,91 @@ +/* + * Vencord, a modification for Discord's desktop app + * Copyright (c) 2022 Vendicated and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . +*/ + +import ErrorBoundary from "@components/ErrorBoundary"; +import { findByCodeLazy } from "@webpack"; +import { Forms, Router, Text } from "@webpack/common"; + +import cssText from "~fileContent/settingsStyles.css"; + +import BackupRestoreTab from "./BackupRestoreTab"; +import PluginsTab from "./PluginsTab"; +import Updater from "./Updater"; +import VencordSettings from "./VencordTab"; + +const style = document.createElement("style"); +style.textContent = cssText; +document.head.appendChild(style); + +const st = (style: string) => `vcSettings${style}`; + +const TabBar = findByCodeLazy('[role="tab"][aria-disabled="false"]'); + +interface SettingsProps { + tab: string; +} + +interface SettingsTab { + name: string; + component?: React.ComponentType; +} + +const SettingsTabs: Record = { + VencordSettings: { name: "Vencord", component: () => }, + VencordPlugins: { name: "Plugins", component: () => }, + VencordThemes: { name: "Themes", component: () => Coming soon to a Vencord near you! }, + VencordUpdater: { name: "Updater" }, // Only show updater if IS_WEB is false + VencordSettingsSync: { name: "Backup & Restore", component: () => }, +}; + +if (!IS_WEB) SettingsTabs.VencordUpdater.component = () => Updater && ; + +function Settings(props: SettingsProps) { + const { tab = "VencordSettings" } = props; + + const CurrentTab = SettingsTabs[tab]?.component; + + return + Vencord Settings + + + {Object.entries(SettingsTabs).map(([key, { name, component }]) => { + if (!component) return null; + return + {name} + ; + })} + + + {CurrentTab && } + ; +} + +export default function (props: SettingsProps) { + return + + ; +} diff --git a/src/components/VencordSettings/settingsStyles.css b/src/components/VencordSettings/settingsStyles.css new file mode 100644 index 000000000..e90ef141b --- /dev/null +++ b/src/components/VencordSettings/settingsStyles.css @@ -0,0 +1,23 @@ +.vcSettingsTabBar { + margin-top: 20px; + margin-bottom: -2px; + border-bottom: 2px solid var(--background-modifier-accent); +} + +.vcSettingsTabBarItem { + margin-right: 32px; + padding-bottom: 16px; + margin-bottom: -2px; +} + +.vcSettingsQuickActionCard { + padding: 1em; + display: flex; + gap: 1em; + align-items: center; + justify-content: space-between; + flex-wrap: wrap; + flex-grow: 1; + flex-direction: row; + margin-bottom: 1em; +} diff --git a/src/components/handleComponentFailed.ts b/src/components/handleComponentFailed.ts index 34f3ab9b2..020e8ef21 100644 --- a/src/components/handleComponentFailed.ts +++ b/src/components/handleComponentFailed.ts @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import { isOutdated, rebuild, update } from "../utils/updater"; +import { isOutdated, rebuild, update } from "@utils/updater"; export async function handleComponentFailed() { if (isOutdated) { diff --git a/src/components/index.ts b/src/components/index.ts index 80d2cd129..3ee53b02c 100644 --- a/src/components/index.ts +++ b/src/components/index.ts @@ -18,5 +18,4 @@ export { default as PatchHelper } from "./PatchHelper"; export { default as PluginSettings } from "./PluginSettings"; -export { default as Settings } from "./Settings"; -export { default as Updater } from "./Updater"; +export { default as VencordSettings } from "./VencordSettings"; diff --git a/src/debug/Tracer.ts b/src/debug/Tracer.ts index 4e17143fe..185915a97 100644 --- a/src/debug/Tracer.ts +++ b/src/debug/Tracer.ts @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import Logger from "../utils/Logger"; +import Logger from "@utils/Logger"; if (IS_DEV) { var traces = {} as Record; diff --git a/src/ipcMain/index.ts b/src/ipcMain/index.ts index 8a60bc6ed..ba85eeb0b 100644 --- a/src/ipcMain/index.ts +++ b/src/ipcMain/index.ts @@ -18,6 +18,9 @@ import "./updater"; +import { debounce } from "@utils/debounce"; +import IpcEvents from "@utils/IpcEvents"; +import { Queue } from "@utils/Queue"; import { BrowserWindow, desktopCapturer, ipcMain, shell } from "electron"; import { mkdirSync, readFileSync, watch } from "fs"; import { open, readFile, writeFile } from "fs/promises"; @@ -25,9 +28,6 @@ import { join } from "path"; import monacoHtml from "~fileContent/../components/monacoWin.html;base64"; -import { debounce } from "../utils/debounce"; -import IpcEvents from "../utils/IpcEvents"; -import { Queue } from "../utils/Queue"; import { ALLOWED_PROTOCOLS, QUICKCSS_PATH, SETTINGS_DIR, SETTINGS_FILE } from "./constants"; mkdirSync(SETTINGS_DIR, { recursive: true }); @@ -66,14 +66,14 @@ const settingsWriteQueue = new Queue(); ipcMain.handle(IpcEvents.GET_QUICK_CSS, () => readCss()); ipcMain.handle(IpcEvents.SET_QUICK_CSS, (_, css) => - cssWriteQueue.add(() => writeFile(QUICKCSS_PATH, css)) + cssWriteQueue.push(() => writeFile(QUICKCSS_PATH, css)) ); ipcMain.handle(IpcEvents.GET_SETTINGS_DIR, () => SETTINGS_DIR); ipcMain.on(IpcEvents.GET_SETTINGS, e => e.returnValue = readSettings()); ipcMain.handle(IpcEvents.SET_SETTINGS, (_, s) => { - settingsWriteQueue.add(() => writeFile(SETTINGS_FILE, s)); + settingsWriteQueue.push(() => writeFile(SETTINGS_FILE, s)); }); diff --git a/src/ipcMain/updater/git.ts b/src/ipcMain/updater/git.ts index 7e4176a86..07c94cb56 100644 --- a/src/ipcMain/updater/git.ts +++ b/src/ipcMain/updater/git.ts @@ -16,12 +16,12 @@ * along with this program. If not, see . */ +import IpcEvents from "@utils/IpcEvents"; import { execFile as cpExecFile } from "child_process"; import { ipcMain } from "electron"; import { join } from "path"; import { promisify } from "util"; -import IpcEvents from "../../utils/IpcEvents"; import { calculateHashes, serializeErrors } from "./common"; const VENCORD_SRC_DIR = join(__dirname, ".."); diff --git a/src/ipcMain/updater/http.ts b/src/ipcMain/updater/http.ts index 523340f4c..902d644a3 100644 --- a/src/ipcMain/updater/http.ts +++ b/src/ipcMain/updater/http.ts @@ -16,6 +16,8 @@ * along with this program. If not, see . */ +import { VENCORD_USER_AGENT } from "@utils/constants"; +import IpcEvents from "@utils/IpcEvents"; import { ipcMain } from "electron"; import { writeFile } from "fs/promises"; import { join } from "path"; @@ -23,8 +25,6 @@ import { join } from "path"; import gitHash from "~git-hash"; import gitRemote from "~git-remote"; -import { VENCORD_USER_AGENT } from "../../utils/constants"; -import IpcEvents from "../../utils/IpcEvents"; import { get } from "../simpleGet"; import { calculateHashes, serializeErrors } from "./common"; diff --git a/src/modules.d.ts b/src/modules.d.ts index 78cc9a520..6901260ae 100644 --- a/src/modules.d.ts +++ b/src/modules.d.ts @@ -20,7 +20,7 @@ /// declare module "~plugins" { - const plugins: Record; + const plugins: Record; export default plugins; } diff --git a/src/patcher.ts b/src/patcher.ts index 28910b7af..12cefc018 100644 --- a/src/patcher.ts +++ b/src/patcher.ts @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +import { onceDefined } from "@utils/onceDefined"; import electron, { app, BrowserWindowConstructorOptions } from "electron"; import { readFileSync } from "fs"; import { dirname, join } from "path"; @@ -23,7 +24,6 @@ import { dirname, join } from "path"; import { initIpc } from "./ipcMain"; import { installExt } from "./ipcMain/extensions"; import { readSettings } from "./ipcMain/index"; -import { onceDefined } from "./utils/onceDefined"; console.log("[Vencord] Starting up..."); diff --git a/src/plugins/BetterNotes.ts b/src/plugins/BetterNotes.ts index 15282b6a0..41842590f 100644 --- a/src/plugins/BetterNotes.ts +++ b/src/plugins/BetterNotes.ts @@ -16,10 +16,10 @@ * along with this program. If not, see . */ -import { Settings } from "../api/settings"; -import { Devs } from "../utils/constants"; -import { makeLazy } from "../utils/misc"; -import definePlugin, { OptionType } from "../utils/types"; +import { Settings } from "@api/settings"; +import { Devs } from "@utils/constants"; +import { makeLazy } from "@utils/misc"; +import definePlugin, { OptionType } from "@utils/types"; export default definePlugin({ name: "BetterNotesBox", diff --git a/src/plugins/HideAttachments.tsx b/src/plugins/HideAttachments.tsx index 067b4f010..2c1a0d4de 100644 --- a/src/plugins/HideAttachments.tsx +++ b/src/plugins/HideAttachments.tsx @@ -16,14 +16,13 @@ * along with this program. If not, see . */ +import { get, set } from "@api/DataStore"; +import { Devs } from "@utils/constants"; +import Logger from "@utils/Logger"; +import definePlugin from "@utils/types"; +import { ChannelStore, FluxDispatcher } from "@webpack/common"; import { Message } from "discord-types/general"; -import { get, set } from "../api/DataStore"; -import { Devs } from "../utils/constants"; -import Logger from "../utils/Logger"; -import definePlugin from "../utils/types"; -import { ChannelStore, FluxDispatcher } from "../webpack/common"; - let style: HTMLStyleElement; const KEY = "HideAttachments_HiddenIds"; @@ -99,7 +98,7 @@ export default definePlugin({ icon: isHidden ? ImageVisible : ImageInvisible, message: msg, channel: ChannelStore.getChannel(msg.channel_id), - onClick: () => this.toggleHide(msg) + onClick: () => this.toggleHide(msg.id) }); } catch (err) { new Logger("HideAttachments").error(err); @@ -107,10 +106,10 @@ export default definePlugin({ } }, - async toggleHide(message: Message) { + async toggleHide(id: string) { const ids = await getHiddenMessages(); - if (!ids.delete(message.id)) - ids.add(message.id); + if (!ids.delete(id)) + ids.add(id); await saveHiddenMessages(ids); await this.buildCss(); @@ -118,7 +117,7 @@ export default definePlugin({ // update is necessary to rerender the PopOver FluxDispatcher.dispatch({ type: "MESSAGE_UPDATE", - message + message: { id } }); } }); diff --git a/src/plugins/TimeBarAllActivities.ts b/src/plugins/TimeBarAllActivities.ts index d4fe63975..223f1828c 100644 --- a/src/plugins/TimeBarAllActivities.ts +++ b/src/plugins/TimeBarAllActivities.ts @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; export default definePlugin({ name: "TimeBarAllActivities", diff --git a/src/plugins/anonymiseFileNames.ts b/src/plugins/anonymiseFileNames.ts index c7c3ed585..f953a144e 100644 --- a/src/plugins/anonymiseFileNames.ts +++ b/src/plugins/anonymiseFileNames.ts @@ -16,9 +16,9 @@ * along with this program. If not, see . */ -import { Devs } from "../utils/constants"; -import definePlugin, { OptionType } from "../utils/types"; -import { Settings } from "../Vencord"; +import { Settings } from "@api/settings"; +import { Devs } from "@utils/constants"; +import definePlugin, { OptionType } from "@utils/types"; enum Methods { Random, diff --git a/src/plugins/apiBadges.tsx b/src/plugins/apiBadges.tsx index 831bf86ca..77ea46ea1 100644 --- a/src/plugins/apiBadges.tsx +++ b/src/plugins/apiBadges.tsx @@ -16,17 +16,17 @@ * along with this program. If not, see . */ -import { BadgePosition, ProfileBadge } from "../api/Badges"; -import DonateButton from "../components/DonateButton"; -import ErrorBoundary from "../components/ErrorBoundary"; -import { Flex } from "../components/Flex"; -import { Heart } from "../components/Heart"; -import { Devs } from "../utils/constants"; -import IpcEvents from "../utils/IpcEvents"; -import Logger from "../utils/Logger"; -import { closeModal, Modals, openModal } from "../utils/modal"; -import definePlugin from "../utils/types"; -import { Forms, Margins } from "../webpack/common"; +import { BadgePosition, ProfileBadge } from "@api/Badges"; +import DonateButton from "@components/DonateButton"; +import ErrorBoundary from "@components/ErrorBoundary"; +import { Flex } from "@components/Flex"; +import { Heart } from "@components/Heart"; +import { Devs } from "@utils/constants"; +import IpcEvents from "@utils/IpcEvents"; +import Logger from "@utils/Logger"; +import { closeModal, Modals, openModal } from "@utils/modal"; +import definePlugin from "@utils/types"; +import { Forms, Margins } from "@webpack/common"; const CONTRIBUTOR_BADGE = "https://media.discordapp.net/stickers/1026517526106087454.webp"; diff --git a/src/plugins/apiCommands.ts b/src/plugins/apiCommands.ts index 4136deb62..e92b904e7 100644 --- a/src/plugins/apiCommands.ts +++ b/src/plugins/apiCommands.ts @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; export default definePlugin({ name: "CommandsAPI", diff --git a/src/plugins/apiMenuItemDeobfuscator.ts b/src/plugins/apiMenuItemDeobfuscator.ts index 40d53f199..5703456bb 100644 --- a/src/plugins/apiMenuItemDeobfuscator.ts +++ b/src/plugins/apiMenuItemDeobfuscator.ts @@ -16,9 +16,9 @@ * along with this program. If not, see . */ -import { migratePluginSettings } from "../api/settings"; -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; +import { migratePluginSettings } from "@api/settings"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; // duplicate values have multiple branches with different types. Just include all to be safe const nameMap = { diff --git a/src/plugins/apiMessageAccessories.ts b/src/plugins/apiMessageAccessories.ts index ee3ee900c..0b30b58e2 100644 --- a/src/plugins/apiMessageAccessories.ts +++ b/src/plugins/apiMessageAccessories.ts @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; export default definePlugin({ name: "MessageAccessoriesAPI", diff --git a/src/plugins/apiMessageEvents.ts b/src/plugins/apiMessageEvents.ts index bf7c7f58d..13fbc4c34 100644 --- a/src/plugins/apiMessageEvents.ts +++ b/src/plugins/apiMessageEvents.ts @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; export default definePlugin({ name: "MessageEventsAPI", diff --git a/src/plugins/apiNotices.ts b/src/plugins/apiNotices.ts index f53c5351f..a93334bd1 100644 --- a/src/plugins/apiNotices.ts +++ b/src/plugins/apiNotices.ts @@ -16,9 +16,9 @@ * along with this program. If not, see . */ -import { migratePluginSettings } from "../api/settings"; -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; +import { migratePluginSettings } from "@api/settings"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; migratePluginSettings("NoticesAPI", "NoticesApi"); diff --git a/src/plugins/apiServerList.ts b/src/plugins/apiServerList.ts index 134870e26..77498ac81 100644 --- a/src/plugins/apiServerList.ts +++ b/src/plugins/apiServerList.ts @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; export default definePlugin({ name: "ServerListAPI", diff --git a/src/plugins/arRPC.tsx b/src/plugins/arRPC.tsx index 081ea4819..cba3504af 100644 --- a/src/plugins/arRPC.tsx +++ b/src/plugins/arRPC.tsx @@ -16,13 +16,12 @@ * along with this program. If not, see . */ -import { popNotice, showNotice } from "../api/Notices"; -import { Link } from "../components/Link"; -import { Devs } from "../utils/constants"; -import { lazyWebpack } from "../utils/misc"; -import definePlugin from "../utils/types"; -import { filters, mapMangledModuleLazy } from "../webpack"; -import { FluxDispatcher, Forms, Toasts } from "../webpack/common"; +import { popNotice, showNotice } from "@api/Notices"; +import { Link } from "@components/Link"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; +import { filters, findByCodeLazy, mapMangledModuleLazy } from "@webpack"; +import { FluxDispatcher, Forms, Toasts } from "@webpack/common"; const assetManager = mapMangledModuleLazy( "getAssetImage: size must === [number, number] for Twitch", @@ -31,7 +30,7 @@ const assetManager = mapMangledModuleLazy( } ); -const rpcManager = lazyWebpack(filters.byCode(".APPLICATION_RPC(")); +const rpcManager = findByCodeLazy(".APPLICATION_RPC("); async function lookupAsset(applicationId: string, key: string): Promise { return (await assetManager.getAsset(applicationId, [key, undefined]))[0]; diff --git a/src/plugins/banger.ts b/src/plugins/banger.ts index 626322481..68163cbd6 100644 --- a/src/plugins/banger.ts +++ b/src/plugins/banger.ts @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -import { Devs } from "../utils/constants"; -import definePlugin, { OptionType } from "../utils/types"; +import { Devs } from "@utils/constants"; +import definePlugin, { OptionType } from "@utils/types"; export default definePlugin({ name: "BANger", diff --git a/src/plugins/betterGifAltText.ts b/src/plugins/betterGifAltText.ts index 56d7b5474..686ef0a55 100644 --- a/src/plugins/betterGifAltText.ts +++ b/src/plugins/betterGifAltText.ts @@ -17,8 +17,8 @@ */ -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; export default definePlugin({ name: "BetterGifAltText", diff --git a/src/plugins/betterRoleDot.ts b/src/plugins/betterRoleDot.ts index 37a2ea73f..3b2ac39f8 100644 --- a/src/plugins/betterRoleDot.ts +++ b/src/plugins/betterRoleDot.ts @@ -16,10 +16,10 @@ * along with this program. If not, see . */ -import { migratePluginSettings, Settings } from "../api/settings"; -import { Devs } from "../utils/constants"; -import definePlugin, { OptionType } from "../utils/types"; -import { Clipboard, Toasts } from "../webpack/common"; +import { migratePluginSettings, Settings } from "@api/settings"; +import { Devs } from "@utils/constants"; +import definePlugin, { OptionType } from "@utils/types"; +import { Clipboard, Toasts } from "@webpack/common"; migratePluginSettings("BetterRoleDot", "ClickableRoleDot"); export default definePlugin({ diff --git a/src/plugins/betterUploadButton.ts b/src/plugins/betterUploadButton.ts index 94c1f4946..64a378502 100644 --- a/src/plugins/betterUploadButton.ts +++ b/src/plugins/betterUploadButton.ts @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; export default definePlugin({ name: "BetterUploadButton", diff --git a/src/plugins/blurNsfw.ts b/src/plugins/blurNsfw.ts new file mode 100644 index 000000000..552189776 --- /dev/null +++ b/src/plugins/blurNsfw.ts @@ -0,0 +1,77 @@ +/* + * Vencord, a modification for Discord's desktop app + * Copyright (c) 2022 Vendicated and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . +*/ + +import { Settings } from "@api/settings"; +import { Devs } from "@utils/constants"; +import definePlugin, { OptionType } from "@utils/types"; + +let style: HTMLStyleElement; + +function setCss() { + style.textContent = ` + .vc-nsfw-img [class^=imageWrapper] img, + .vc-nsfw-img [class^=wrapperPaused] video { + filter: blur(${Settings.plugins.BlurNSFW.blurAmount}px); + transition: filter 0.2s; + } + .vc-nsfw-img [class^=imageWrapper]:hover img, + .vc-nsfw-img [class^=wrapperPaused]:hover video { + filter: unset; + } + `; +} + +export default definePlugin({ + name: "BlurNSFW", + description: "Blur attachments in NSFW channels until hovered", + authors: [Devs.Ven], + + patches: [ + { + find: "().embedWrapper,embed", + replacement: [{ + match: /(\.renderEmbed=.+?(.)=.\.props)(.+?\(\)\.embedWrapper)/g, + replace: "$1,vcProps=$2$3+(vcProps.channel.nsfw?' vc-nsfw-img':'')" + }, { + match: /(\.renderAttachments=.+?(.)=this\.props)(.+?\(\)\.embedWrapper)/g, + replace: "$1,vcProps=$2$3+(vcProps.channel.nsfw?' vc-nsfw-img':'')" + }] + } + ], + + options: { + blurAmount: { + type: OptionType.NUMBER, + description: "Blur Amount", + default: 10, + onChange: setCss + } + }, + + start() { + style = document.createElement("style"); + style.id = "VcBlurNsfw"; + document.head.appendChild(style); + + setCss(); + }, + + stop() { + style?.remove(); + } +}); diff --git a/src/plugins/callTimer.ts b/src/plugins/callTimer.ts deleted file mode 100644 index d58b428cb..000000000 --- a/src/plugins/callTimer.ts +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Vencord, a modification for Discord's desktop app - * Copyright (c) 2022 Vendicated and contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . -*/ - -import { Settings } from "../api/settings"; -import { Devs } from "../utils/constants"; -import definePlugin, { OptionType } from "../utils/types"; -import { FluxDispatcher } from "../webpack/common"; - -export default definePlugin({ - name: "CallTimer", - description: "Adds a timer to vcs", - authors: [Devs.Ven], - - style: void 0 as HTMLStyleElement | undefined, - startTime: 0, - interval: void 0 as NodeJS.Timeout | undefined, - - options: { - format: { - type: OptionType.SELECT, - description: "The timer format. This can be any valid moment.js format", - options: [ - { - label: "30d 23:00:42", - value: "stopwatch", - default: true - }, - { - label: "30d 23h 00m 42s", - value: "human" - } - ] - } - }, - - - formatDuration(ms: number) { - // here be dragons (moment fucking sucks) - const human = Settings.plugins.CallTimer.format === "human"; - - const format = (n: number) => human ? n : n.toString().padStart(2, "0"); - const unit = (s: string) => human ? s : ""; - const delim = human ? " " : ":"; - - // thx copilot - const d = Math.floor(ms / 86400000); - const h = Math.floor((ms % 86400000) / 3600000); - const m = Math.floor(((ms % 86400000) % 3600000) / 60000); - const s = Math.floor((((ms % 86400000) % 3600000) % 60000) / 1000); - - let res = ""; - if (d) res += `${d}d `; - if (h || res) res += `${format(h)}${unit("h")}${delim}`; - if (m || res || !human) res += `${format(m)}${unit("m")}${delim}`; - res += `${format(s)}${unit("s")}`; - - return res; - }, - - setTimer(ms: number) { - if (!this.style) return; - - this.style.textContent = ` - [class*="connection-"] [class*="channel-"]::after { - content: "Connected for ${this.formatDuration(ms)}"; - display: block; - } - `; - }, - - start() { - const style = this.style = document.createElement("style"); - style.id = "VencordCallTimer"; - document.head.appendChild(style); - - this.setTimer(0); - - this.handleRtcConnectionState = this.handleRtcConnectionState.bind(this); - FluxDispatcher.subscribe("RTC_CONNECTION_STATE", this.handleRtcConnectionState); - }, - - handleRtcConnectionState(e: { state: string; }) { - if (e.state === "RTC_CONNECTED" || e.state === "RTC_DISCONNECTED") { - clearInterval(this.interval); - if (e.state === "RTC_CONNECTED") { - this.startTime = Date.now(); - this.interval = setInterval( - () => this.setTimer(Math.round(Date.now() - this.startTime)), - 1000 - ); - } else this.startTime = 0; - this.setTimer(0); - } - }, - - stop() { - FluxDispatcher.unsubscribe("RCT_CONNECTION_STATE", this.handleRtcConnectionState); - this.style?.remove(); - clearInterval(this.interval); - } -}); diff --git a/src/plugins/callTimer.tsx b/src/plugins/callTimer.tsx new file mode 100644 index 000000000..6a1d357cd --- /dev/null +++ b/src/plugins/callTimer.tsx @@ -0,0 +1,101 @@ +/* + * Vencord, a modification for Discord's desktop app + * Copyright (c) 2022 Vendicated and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . +*/ + +import { Settings } from "@api/settings"; +import ErrorBoundary from "@components/ErrorBoundary"; +import { Devs } from "@utils/constants"; +import definePlugin, { OptionType } from "@utils/types"; +import { React } from "@webpack/common"; + +function formatDuration(ms: number) { + // here be dragons (moment fucking sucks) + const human = Settings.plugins.CallTimer.format === "human"; + + const format = (n: number) => human ? n : n.toString().padStart(2, "0"); + const unit = (s: string) => human ? s : ""; + const delim = human ? " " : ":"; + + // thx copilot + const d = Math.floor(ms / 86400000); + const h = Math.floor((ms % 86400000) / 3600000); + const m = Math.floor(((ms % 86400000) % 3600000) / 60000); + const s = Math.floor((((ms % 86400000) % 3600000) % 60000) / 1000); + + let res = ""; + if (d) res += `${d}d `; + if (h || res) res += `${format(h)}${unit("h")}${delim}`; + if (m || res || !human) res += `${format(m)}${unit("m")}${delim}`; + res += `${format(s)}${unit("s")}`; + + return res; +} + +export default definePlugin({ + name: "CallTimer", + description: "Adds a timer to vcs", + authors: [Devs.Ven], + + startTime: 0, + interval: void 0 as NodeJS.Timeout | undefined, + + options: { + format: { + type: OptionType.SELECT, + description: "The timer format. This can be any valid moment.js format", + options: [ + { + label: "30d 23:00:42", + value: "stopwatch", + default: true + }, + { + label: "30d 23h 00m 42s", + value: "human" + } + ] + } + }, + + patches: [{ + find: ".renderConnectionStatus=", + replacement: { + match: /(?<=renderConnectionStatus=.+\(\)\.channel,children:)\w/, + replace: "[$&, Vencord.Plugins.plugins.CallTimer.renderTimer(this.props.channel.id)]" + } + }], + renderTimer(channelId: string) { + return + + ; + }, + + Timer({ channelId }: { channelId: string; }) { + const [time, setTime] = React.useState(0); + const startTime = React.useMemo(() => Date.now(), [channelId]); + + React.useEffect(() => { + const interval = setInterval(() => setTime(Date.now() - startTime), 1000); + return () => { + clearInterval(interval); + setTime(0); + }; + }, [channelId]); + + return

Connected for {formatDuration(time)}

; + } +}); diff --git a/src/plugins/clearURLs/index.ts b/src/plugins/clearURLs/index.ts index f5b890996..178a0e11f 100644 --- a/src/plugins/clearURLs/index.ts +++ b/src/plugins/clearURLs/index.ts @@ -22,10 +22,11 @@ import { MessageObject, removePreEditListener, removePreSendListener -} from "../../api/MessageEvents"; -import { migratePluginSettings } from "../../api/settings"; -import { Devs } from "../../utils/constants"; -import definePlugin from "../../utils/types"; +} from "@api/MessageEvents"; +import { migratePluginSettings } from "@api/settings"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; + import { defaultRules } from "./defaultRules"; // From lodash diff --git a/src/plugins/consoleShortcuts.ts b/src/plugins/consoleShortcuts.ts index eeb5d8dcb..ae0de9f83 100644 --- a/src/plugins/consoleShortcuts.ts +++ b/src/plugins/consoleShortcuts.ts @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; const WEB_ONLY = (f: string) => () => { throw new Error(`'${f}' is Discord Desktop only.`); diff --git a/src/plugins/corruptMp4s.ts b/src/plugins/corruptMp4s.ts index 05cdf5f1e..5ae25eef6 100644 --- a/src/plugins/corruptMp4s.ts +++ b/src/plugins/corruptMp4s.ts @@ -16,12 +16,12 @@ * along with this program. If not, see . */ -import { ApplicationCommandOptionType, sendBotMessage } from "../api/Commands"; -import { findOption } from "../api/Commands/commandHelpers"; -import { ApplicationCommandInputType } from "../api/Commands/types"; -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; -import { findByCode, findByProps } from "../webpack"; +import { ApplicationCommandOptionType, sendBotMessage } from "@api/Commands"; +import { findOption } from "@api/Commands/commandHelpers"; +import { ApplicationCommandInputType } from "@api/Commands/types"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; +import { findByCode, findByProps } from "@webpack"; const DRAFT_TYPE = 0; diff --git a/src/plugins/dictionary.ts b/src/plugins/dictionary.ts index 547636d00..14ee37b90 100644 --- a/src/plugins/dictionary.ts +++ b/src/plugins/dictionary.ts @@ -16,10 +16,10 @@ * along with this program. If not, see . */ -import { ApplicationCommandOptionType, sendBotMessage } from "../api/Commands"; -import { ApplicationCommandInputType } from "../api/Commands/types"; -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; +import { ApplicationCommandOptionType, sendBotMessage } from "@api/Commands"; +import { ApplicationCommandInputType } from "@api/Commands/types"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; export default definePlugin({ name: "UrbanDictionary", diff --git a/src/plugins/emoteCloner.tsx b/src/plugins/emoteCloner.tsx index 0b1190bec..36b283e14 100644 --- a/src/plugins/emoteCloner.tsx +++ b/src/plugins/emoteCloner.tsx @@ -16,20 +16,20 @@ * along with this program. If not, see . */ -import { migratePluginSettings, Settings } from "../api/settings"; -import { CheckedTextInput } from "../components/CheckedTextInput"; -import { Devs } from "../utils/constants"; -import Logger from "../utils/Logger"; -import { lazyWebpack, makeLazy } from "../utils/misc"; -import { ModalContent, ModalHeader, ModalRoot, openModal } from "../utils/modal"; -import definePlugin from "../utils/types"; -import { filters } from "../webpack"; -import { Forms, GuildStore, Margins, Menu, PermissionStore, React, Toasts, Tooltip, UserStore } from "../webpack/common"; +import { migratePluginSettings, Settings } from "@api/settings"; +import { CheckedTextInput } from "@components/CheckedTextInput"; +import { Devs } from "@utils/constants"; +import Logger from "@utils/Logger"; +import { makeLazy } from "@utils/misc"; +import { ModalContent, ModalHeader, ModalRoot, openModal } from "@utils/modal"; +import definePlugin from "@utils/types"; +import { findByCodeLazy, findByPropsLazy } from "@webpack"; +import { Forms, GuildStore, Margins, Menu, PermissionStore, React, Toasts, Tooltip, UserStore } from "@webpack/common"; const MANAGE_EMOJIS_AND_STICKERS = 1n << 30n; -const GuildEmojiStore = lazyWebpack(filters.byProps("getGuilds", "getGuildEmoji")); -const uploadEmoji = lazyWebpack(filters.byCode('"EMOJI_UPLOAD_START"', "GUILD_EMOJIS(")); +const GuildEmojiStore = findByPropsLazy("getGuilds", "getGuildEmoji"); +const uploadEmoji = findByCodeLazy('"EMOJI_UPLOAD_START"', "GUILD_EMOJIS("); function getGuildCandidates(isAnimated: boolean) { const meId = UserStore.getCurrentUser().id; diff --git a/src/plugins/experiments.tsx b/src/plugins/experiments.tsx index 4f83c5a23..3019e64d7 100644 --- a/src/plugins/experiments.tsx +++ b/src/plugins/experiments.tsx @@ -16,14 +16,13 @@ * along with this program. If not, see . */ -import { Devs } from "../utils/constants"; -import { lazyWebpack } from "../utils/misc"; -import definePlugin, { OptionType } from "../utils/types"; -import { Settings } from "../Vencord"; -import { filters } from "../webpack"; -import { Forms, React } from "../webpack/common"; +import { Settings } from "@api/settings"; +import { Devs } from "@utils/constants"; +import definePlugin, { OptionType } from "@utils/types"; +import { findByPropsLazy } from "@webpack"; +import { Forms, React } from "@webpack/common"; -const KbdStyles = lazyWebpack(filters.byProps("key", "removeBuildOverride")); +const KbdStyles = findByPropsLazy("key", "removeBuildOverride"); export default definePlugin({ name: "Experiments", diff --git a/src/plugins/fakeNitro.ts b/src/plugins/fakeNitro.ts index c6823249c..0a1985a45 100644 --- a/src/plugins/fakeNitro.ts +++ b/src/plugins/fakeNitro.ts @@ -16,18 +16,16 @@ * along with this program. If not, see . */ -import { addPreEditListener, addPreSendListener, removePreEditListener, removePreSendListener } from "../api/MessageEvents"; -import { migratePluginSettings } from "../api/settings"; -import { Devs } from "../utils/constants"; -import { ApngDisposeOp, getGifEncoder, importApngJs } from "../utils/dependencies"; -import { lazyWebpack } from "../utils/misc"; -import definePlugin, { OptionType } from "../utils/types"; -import { Settings } from "../Vencord"; -import { filters } from "../webpack"; -import { ChannelStore, UserStore } from "../webpack/common"; +import { addPreEditListener, addPreSendListener, removePreEditListener, removePreSendListener } from "@api/MessageEvents"; +import { migratePluginSettings, Settings } from "@api/settings"; +import { Devs } from "@utils/constants"; +import { ApngDisposeOp, getGifEncoder, importApngJs } from "@utils/dependencies"; +import definePlugin, { OptionType } from "@utils/types"; +import { findByCodeLazy, findByPropsLazy } from "@webpack"; +import { ChannelStore, UserStore } from "@webpack/common"; const DRAFT_TYPE = 0; -const promptToUpload = lazyWebpack(filters.byCode("UPLOAD_FILE_LIMIT_ERROR")); +const promptToUpload = findByCodeLazy("UPLOAD_FILE_LIMIT_ERROR"); interface BaseSticker { available: boolean; @@ -225,8 +223,8 @@ export default definePlugin({ return; } - const EmojiStore = lazyWebpack(filters.byProps("getCustomEmojiById")); - const StickerStore = lazyWebpack(filters.byProps("getAllGuildStickers")) as { + const EmojiStore = findByPropsLazy("getCustomEmojiById"); + const StickerStore = findByPropsLazy("getAllGuildStickers") as { getPremiumPacks(): StickerPack[]; getAllGuildStickers(): Map; getStickerById(id: string): Sticker | undefined; diff --git a/src/plugins/fart.ts b/src/plugins/fart.ts index 88e95af03..9404b39b0 100644 --- a/src/plugins/fart.ts +++ b/src/plugins/fart.ts @@ -16,11 +16,11 @@ * along with this program. If not, see . */ -import { ApplicationCommandOptionType } from "../api/Commands"; -import { makeRange } from "../components/PluginSettings/components"; -import { Devs } from "../utils/constants"; -import definePlugin, { OptionType } from "../utils/types"; -import { Settings } from "../Vencord"; +import { ApplicationCommandOptionType } from "@api/Commands"; +import { Settings } from "@api/settings"; +import { makeRange } from "@components/PluginSettings/components"; +import { Devs } from "@utils/constants"; +import definePlugin, { OptionType } from "@utils/types"; export default definePlugin({ name: "Fart2", diff --git a/src/plugins/forceOwnerCrown.ts b/src/plugins/forceOwnerCrown.ts index a26e6e202..9345ea75b 100644 --- a/src/plugins/forceOwnerCrown.ts +++ b/src/plugins/forceOwnerCrown.ts @@ -16,9 +16,9 @@ * along with this program. If not, see . */ -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; -import { waitFor } from "../webpack"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; +import { waitFor } from "@webpack"; let GuildStore; waitFor(["getGuild"], m => GuildStore = m); diff --git a/src/plugins/friendInvites.ts b/src/plugins/friendInvites.ts index 24ca50a92..73dffd126 100644 --- a/src/plugins/friendInvites.ts +++ b/src/plugins/friendInvites.ts @@ -16,10 +16,10 @@ * along with this program. If not, see . */ -import { ApplicationCommandInputType, sendBotMessage } from "../api/Commands"; -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; -import { findByProps } from "../webpack"; +import { ApplicationCommandInputType, sendBotMessage } from "@api/Commands"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; +import { findByProps } from "@webpack"; export default definePlugin({ name: "FriendInvites", diff --git a/src/plugins/fxTwitter.ts b/src/plugins/fxTwitter.ts index 4bb00d9cd..efe1ebc7f 100644 --- a/src/plugins/fxTwitter.ts +++ b/src/plugins/fxTwitter.ts @@ -16,9 +16,9 @@ * along with this program. If not, see . */ -import { addPreSendListener, MessageObject, removePreSendListener } from "../api/MessageEvents"; -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; +import { addPreSendListener, MessageObject, removePreSendListener } from "@api/MessageEvents"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; const re = /https?:\/\/twitter\.com(?=\/\w+?\/status\/)/g; diff --git a/src/plugins/iLoveSpam.ts b/src/plugins/iLoveSpam.ts index 7f390f342..79b2e3fb0 100644 --- a/src/plugins/iLoveSpam.ts +++ b/src/plugins/iLoveSpam.ts @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; export default definePlugin({ name: "iLoveSpam", diff --git a/src/plugins/ignoreActivities.ts b/src/plugins/ignoreActivities.ts index d33d5cc28..a39b02677 100644 --- a/src/plugins/ignoreActivities.ts +++ b/src/plugins/ignoreActivities.ts @@ -16,11 +16,10 @@ * along with this program. If not, see . */ -import { DataStore } from "../api"; -import { Devs } from "../utils/constants"; -import { lazyWebpack } from "../utils/misc"; -import definePlugin from "../utils/types"; -import { filters } from "../webpack"; +import * as DataStore from "@api/DataStore"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; +import { findByPropsLazy } from "@webpack"; interface MatchAndReplace { match: RegExp; @@ -28,7 +27,7 @@ interface MatchAndReplace { } /** Used to re-render the Registered Games tab to update how our button looks like */ -const RunningGameStoreModule = lazyWebpack(filters.byProps("IgnoreActivities_reRenderGames")); +const RunningGameStoreModule = findByPropsLazy("IgnoreActivities_reRenderGames"); let ignoredActivitiesCache: string[] = []; diff --git a/src/plugins/index.ts b/src/plugins/index.ts index 68a76cb25..c0325d41d 100644 --- a/src/plugins/index.ts +++ b/src/plugins/index.ts @@ -16,13 +16,14 @@ * along with this program. If not, see . */ +import { registerCommand, unregisterCommand } from "@api/Commands"; +import { Settings } from "@api/settings"; +import Logger from "@utils/Logger"; +import { Patch, Plugin } from "@utils/types"; + import Plugins from "~plugins"; -import { registerCommand, unregisterCommand } from "../api/Commands"; -import { Settings } from "../api/settings"; import { traceFunction } from "../debug/Tracer"; -import Logger from "../utils/Logger"; -import { Patch, Plugin } from "../utils/types"; const logger = new Logger("PluginManager", "#a6d189"); diff --git a/src/plugins/keepCurrentChannel.ts b/src/plugins/keepCurrentChannel.ts index 395fd7689..0d7147c76 100644 --- a/src/plugins/keepCurrentChannel.ts +++ b/src/plugins/keepCurrentChannel.ts @@ -16,10 +16,10 @@ * along with this program. If not, see . */ -import { DataStore } from "../api"; -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; -import { ChannelStore, FluxDispatcher, NavigationRouter, SelectedChannelStore, SelectedGuildStore } from "../webpack/common"; +import * as DataStore from "@api/DataStore"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; +import { ChannelStore, FluxDispatcher, NavigationRouter, SelectedChannelStore, SelectedGuildStore } from "@webpack/common"; export interface LogoutEvent { type: "LOGOUT"; diff --git a/src/plugins/lastfm.tsx b/src/plugins/lastfm.tsx index 280c0ee39..bf3f63c9e 100644 --- a/src/plugins/lastfm.tsx +++ b/src/plugins/lastfm.tsx @@ -16,43 +16,43 @@ * along with this program. If not, see . */ -import { Link } from "../components/Link"; -import { Devs } from "../utils/constants"; -import { lazyWebpack } from "../utils/misc"; -import definePlugin, { OptionType } from "../utils/types"; -import { Settings, Webpack } from "../Vencord"; -import { FluxDispatcher, Forms } from "../webpack/common"; +import { Settings } from "@api/settings"; +import { Link } from "@components/Link"; +import { Devs } from "@utils/constants"; +import definePlugin, { OptionType } from "@utils/types"; +import { filters, findByPropsLazy, mapMangledModuleLazy } from "@webpack"; +import { FluxDispatcher, Forms } from "@webpack/common"; interface ActivityAssets { - large_image?: string - large_text?: string - small_image?: string - small_text?: string + large_image?: string; + large_text?: string; + small_image?: string; + small_text?: string; } interface Activity { - state: string - details?: string + state: string; + details?: string; timestamps?: { - start?: Number - } - assets?: ActivityAssets - buttons?: Array - name: string - application_id: string + start?: Number; + }; + assets?: ActivityAssets; + buttons?: Array; + name: string; + application_id: string; metadata?: { - button_urls?: Array - } - type: Number - flags: Number + button_urls?: Array; + }; + type: Number; + flags: Number; } interface TrackData { - name: string - album: string - artist: string - url: string - imageUrl?: string + name: string; + album: string; + artist: string; + url: string; + imageUrl?: string; } // only relevant enum values @@ -67,11 +67,11 @@ enum ActivityFlag { const applicationId = "1043533871037284423"; -const presenceStore = lazyWebpack(Webpack.filters.byProps("getLocalPresence")); -const assetManager = Webpack.mapMangledModuleLazy( +const presenceStore = findByPropsLazy("getLocalPresence"); +const assetManager = mapMangledModuleLazy( "getAssetImage: size must === [number, number] for Twitch", { - getAsset: Webpack.filters.byCode("apply("), + getAsset: filters.byCode("apply("), } ); @@ -196,9 +196,9 @@ export default definePlugin({ state: hideAlbumName ? trackData.artist : `${trackData.artist} - ${trackData.album}`, assets, - buttons: [ "Open in Last.fm" ], + buttons: ["Open in Last.fm"], metadata: { - button_urls: [ trackData.url ] + button_urls: [trackData.url] }, type: this.settings.useListeningStatus ? ActivityType.LISTENING : ActivityType.PLAYING, diff --git a/src/plugins/loadingQuotes.ts b/src/plugins/loadingQuotes.ts index 7ee55d8ef..052bfe6ec 100644 --- a/src/plugins/loadingQuotes.ts +++ b/src/plugins/loadingQuotes.ts @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; // These are Xor encrypted to prevent you from spoiling yourself when you read the source code. // don't worry about it :P diff --git a/src/plugins/messageActions.ts b/src/plugins/messageActions.ts index 05d792f18..df4d01611 100644 --- a/src/plugins/messageActions.ts +++ b/src/plugins/messageActions.ts @@ -16,13 +16,12 @@ * along with this program. If not, see . */ -import { addClickListener, removeClickListener } from "../api/MessageEvents"; -import { migratePluginSettings } from "../api/settings"; -import { Devs } from "../utils/constants"; -import { lazyWebpack } from "../utils/misc"; -import definePlugin from "../utils/types"; -import { filters } from "../webpack"; -import { UserStore } from "../webpack/common"; +import { addClickListener, removeClickListener } from "@api/MessageEvents"; +import { migratePluginSettings } from "@api/settings"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; +import { findByPropsLazy, findLazy } from "@webpack"; +import { UserStore } from "@webpack/common"; let isDeletePressed = false; const keydown = (e: KeyboardEvent) => e.key === "Backspace" && (isDeletePressed = true); @@ -37,10 +36,10 @@ export default definePlugin({ dependencies: ["MessageEventsAPI"], start() { - const MessageActions = lazyWebpack(filters.byProps("deleteMessage", "startEditMessage")); - const PermissionStore = lazyWebpack(filters.byProps("can", "initialize")); - const Permissions = lazyWebpack(m => typeof m.MANAGE_MESSAGES === "bigint"); - const EditStore = lazyWebpack(filters.byProps("isEditing", "isEditingAny")); + const MessageActions = findByPropsLazy("deleteMessage", "startEditMessage"); + const PermissionStore = findByPropsLazy("can", "initialize"); + const Permissions = findLazy(m => typeof m.MANAGE_MESSAGES === "bigint"); + const EditStore = findByPropsLazy("isEditing", "isEditingAny"); document.addEventListener("keydown", keydown); document.addEventListener("keyup", keyup); diff --git a/src/plugins/messageLogger/index.tsx b/src/plugins/messageLogger/index.tsx index 7b6bf56bb..5a1ac92e6 100644 --- a/src/plugins/messageLogger/index.tsx +++ b/src/plugins/messageLogger/index.tsx @@ -16,14 +16,13 @@ * along with this program. If not, see . */ -import { Settings } from "../../api/settings"; -import ErrorBoundary from "../../components/ErrorBoundary"; -import { Devs } from "../../utils/constants"; -import Logger from "../../utils/Logger"; -import { lazyWebpack } from "../../utils/misc"; -import definePlugin, { OptionType } from "../../utils/types"; -import { filters } from "../../webpack"; -import { Parser, UserStore } from "../../webpack/common"; +import { Settings } from "@api/settings"; +import ErrorBoundary from "@components/ErrorBoundary"; +import { Devs } from "@utils/constants"; +import Logger from "@utils/Logger"; +import definePlugin, { OptionType } from "@utils/types"; +import { findByPropsLazy } from "@webpack"; +import { Parser, UserStore } from "@webpack/common"; function addDeleteStyleClass() { if (Settings.plugins.MessageLogger.deleteStyle === "text") { @@ -74,8 +73,8 @@ export default definePlugin({ `, start() { - this.moment = lazyWebpack(filters.byProps("relativeTimeRounding", "relativeTimeThreshold")); - this.timestampModule = lazyWebpack(filters.byProps("messageLogger_TimestampComponent")); + this.moment = findByPropsLazy("relativeTimeRounding", "relativeTimeThreshold"); + this.timestampModule = findByPropsLazy("messageLogger_TimestampComponent"); const style = this.style = document.createElement("style"); style.textContent = this.css; diff --git a/src/plugins/messageTags.ts b/src/plugins/messageTags.ts index bf01cad26..490edc342 100644 --- a/src/plugins/messageTags.ts +++ b/src/plugins/messageTags.ts @@ -16,11 +16,11 @@ * along with this program. If not, see . */ -import { DataStore } from "../api"; -import { ApplicationCommandInputType, ApplicationCommandOptionType, findOption, registerCommand, sendBotMessage, unregisterCommand } from "../api/Commands"; -import { Settings } from "../api/settings"; -import { Devs } from "../utils/constants"; -import definePlugin, { OptionType } from "../utils/types"; +import { ApplicationCommandInputType, ApplicationCommandOptionType, findOption, registerCommand, sendBotMessage, unregisterCommand } from "@api/Commands"; +import * as DataStore from "@api/DataStore"; +import { Settings } from "@api/settings"; +import { Devs } from "@utils/constants"; +import definePlugin, { OptionType } from "@utils/types"; const EMOTE = "<:luna:1035316192220553236>"; const DATA_KEY = "MessageTags_TAGS"; diff --git a/src/plugins/moreCommands.ts b/src/plugins/moreCommands.ts index 0a23aafbb..61312acc1 100644 --- a/src/plugins/moreCommands.ts +++ b/src/plugins/moreCommands.ts @@ -16,9 +16,9 @@ * along with this program. If not, see . */ -import { ApplicationCommandInputType, findOption, OptionalMessageOption, RequiredMessageOption, sendBotMessage } from "../api/Commands"; -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; +import { ApplicationCommandInputType, findOption, OptionalMessageOption, RequiredMessageOption, sendBotMessage } from "@api/Commands"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; function mock(input: string): string { diff --git a/src/plugins/moreKaomoji.ts b/src/plugins/moreKaomoji.ts index ef6dc0fd8..a5e40d22d 100644 --- a/src/plugins/moreKaomoji.ts +++ b/src/plugins/moreKaomoji.ts @@ -16,10 +16,10 @@ * along with this program. If not, see . */ -import { findOption, OptionalMessageOption } from "../api/Commands"; -import { migratePluginSettings } from "../api/settings"; -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; +import { findOption, OptionalMessageOption } from "@api/Commands"; +import { migratePluginSettings } from "@api/settings"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; migratePluginSettings("MoreKaomoji", "moarKaomojis"); export default definePlugin({ diff --git a/src/plugins/moyai.ts b/src/plugins/moyai.ts index 5427fed62..fabc97fb4 100644 --- a/src/plugins/moyai.ts +++ b/src/plugins/moyai.ts @@ -16,15 +16,14 @@ * along with this program. If not, see . */ +import { Settings } from "@api/settings"; +import { makeRange } from "@components/PluginSettings/components/SettingSliderComponent"; +import { Devs } from "@utils/constants"; +import { sleep } from "@utils/misc"; +import definePlugin, { OptionType } from "@utils/types"; +import { FluxDispatcher, SelectedChannelStore, UserStore } from "@webpack/common"; import { Message, ReactionEmoji } from "discord-types/general"; -import { makeRange } from "../components/PluginSettings/components/SettingSliderComponent"; -import { Devs } from "../utils/constants"; -import { sleep } from "../utils/misc"; -import definePlugin, { OptionType } from "../utils/types"; -import { Settings } from "../Vencord"; -import { FluxDispatcher, SelectedChannelStore, UserStore } from "../webpack/common"; - interface IMessageCreate { type: "MESSAGE_CREATE"; optimistic: boolean; diff --git a/src/plugins/muteNewGuild.ts b/src/plugins/muteNewGuild.ts index e4ca1d5dc..12b9b60f8 100644 --- a/src/plugins/muteNewGuild.ts +++ b/src/plugins/muteNewGuild.ts @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; export default definePlugin({ name: "MuteNewGuild", diff --git a/src/plugins/noBlockedMessages.ts b/src/plugins/noBlockedMessages.ts index e46e7c3fd..bd72ce5fb 100644 --- a/src/plugins/noBlockedMessages.ts +++ b/src/plugins/noBlockedMessages.ts @@ -16,12 +16,12 @@ * along with this program. If not, see . */ -import { Devs } from "../utils/constants"; -import { lazyWebpack } from "../utils/misc"; -import definePlugin, { OptionType } from "../utils/types"; -import { Settings } from "../Vencord"; -import { filters } from "../webpack"; -const RelationshipStore = lazyWebpack(filters.byProps("getRelationships", "isBlocked")); +import { Settings } from "@api/settings"; +import { Devs } from "@utils/constants"; +import definePlugin, { OptionType } from "@utils/types"; +import { findByPropsLazy } from "@webpack"; + +const RelationshipStore = findByPropsLazy("getRelationships", "isBlocked"); export default definePlugin({ name: "NoBlockedMessages", diff --git a/src/plugins/noCanaryMessageLinks.ts b/src/plugins/noCanaryMessageLinks.ts index 67c917620..ebd6782d9 100644 --- a/src/plugins/noCanaryMessageLinks.ts +++ b/src/plugins/noCanaryMessageLinks.ts @@ -16,10 +16,10 @@ * along with this program. If not, see . */ -import { addPreSendListener, MessageObject, removePreSendListener } from "../api/MessageEvents"; -import { Devs } from "../utils/constants"; -import definePlugin, { OptionType } from "../utils/types"; -import { Settings } from "../Vencord"; +import { addPreSendListener, MessageObject, removePreSendListener } from "@api/MessageEvents"; +import { Settings } from "@api/settings"; +import { Devs } from "@utils/constants"; +import definePlugin, { OptionType } from "@utils/types"; export default definePlugin({ name: "NoCanaryMessageLinks", diff --git a/src/plugins/noDevtoolsWarning.ts b/src/plugins/noDevtoolsWarning.ts index 2ceb0c3f7..8980ed8f0 100644 --- a/src/plugins/noDevtoolsWarning.ts +++ b/src/plugins/noDevtoolsWarning.ts @@ -16,9 +16,9 @@ * along with this program. If not, see . */ -import { migratePluginSettings } from "../api/settings"; -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; +import { migratePluginSettings } from "@api/settings"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; migratePluginSettings("NoDevtoolsWarning", "STFU"); diff --git a/src/plugins/noF1.ts b/src/plugins/noF1.ts index 22e351a52..5c23b73ca 100644 --- a/src/plugins/noF1.ts +++ b/src/plugins/noF1.ts @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; export default definePlugin({ name: "No F1", diff --git a/src/plugins/noRPC.ts b/src/plugins/noRPC.ts index ca82c2bda..e56c7af5e 100644 --- a/src/plugins/noRPC.ts +++ b/src/plugins/noRPC.ts @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; export default definePlugin({ name: "No RPC", diff --git a/src/plugins/noReplyMention.ts b/src/plugins/noReplyMention.ts index 2e5e96959..620274c68 100644 --- a/src/plugins/noReplyMention.ts +++ b/src/plugins/noReplyMention.ts @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; export default definePlugin({ name: "NoReplyMention", diff --git a/src/plugins/noSystemBadge.ts b/src/plugins/noSystemBadge.ts index 2571be5ac..e487a9745 100644 --- a/src/plugins/noSystemBadge.ts +++ b/src/plugins/noSystemBadge.ts @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; export default definePlugin({ name: "NoSystemBadge", diff --git a/src/plugins/noTrack.ts b/src/plugins/noTrack.ts index a86e0afff..27ff430bd 100644 --- a/src/plugins/noTrack.ts +++ b/src/plugins/noTrack.ts @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; export default definePlugin({ name: "NoTrack", diff --git a/src/plugins/noUnblockToJump.ts b/src/plugins/noUnblockToJump.ts index e0194ca21..15f602b59 100644 --- a/src/plugins/noUnblockToJump.ts +++ b/src/plugins/noUnblockToJump.ts @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; export default definePlugin({ diff --git a/src/plugins/oneko.ts b/src/plugins/oneko.ts index 67db2d76d..ef2f5d682 100644 --- a/src/plugins/oneko.ts +++ b/src/plugins/oneko.ts @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; export default definePlugin({ name: "oneko", diff --git a/src/plugins/petpet.ts b/src/plugins/petpet.ts index 7a794fd47..a8281d06d 100644 --- a/src/plugins/petpet.ts +++ b/src/plugins/petpet.ts @@ -16,12 +16,12 @@ * along with this program. If not, see . */ -import { ApplicationCommandInputType, ApplicationCommandOptionType, Argument, CommandContext, findOption, sendBotMessage } from "../api/Commands"; -import { Devs } from "../utils/constants"; -import { getGifEncoder } from "../utils/dependencies"; -import { lazyWebpack, makeLazy } from "../utils/misc"; -import definePlugin from "../utils/types"; -import { filters } from "../webpack"; +import { ApplicationCommandInputType, ApplicationCommandOptionType, Argument, CommandContext, findOption, sendBotMessage } from "@api/Commands"; +import { Devs } from "@utils/constants"; +import { getGifEncoder } from "@utils/dependencies"; +import { makeLazy } from "@utils/misc"; +import definePlugin from "@utils/types"; +import { findByCodeLazy, findByPropsLazy } from "@webpack"; const DRAFT_TYPE = 0; const DEFAULT_DELAY = 20; @@ -35,9 +35,9 @@ const getFrames = makeLazy(() => Promise.all( )) ); -const fetchUser = lazyWebpack(filters.byCode(".USER(")); -const promptToUpload = lazyWebpack(filters.byCode("UPLOAD_FILE_LIMIT_ERROR")); -const UploadStore = lazyWebpack(filters.byProps("getUploads")); +const fetchUser = findByCodeLazy(".USER("); +const promptToUpload = findByCodeLazy("UPLOAD_FILE_LIMIT_ERROR"); +const UploadStore = findByPropsLazy("getUploads"); function loadImage(source: File | string) { const isFile = source instanceof File; diff --git a/src/plugins/plainFolderIcon.ts b/src/plugins/plainFolderIcon.ts index 35f903fa3..5c01ea932 100644 --- a/src/plugins/plainFolderIcon.ts +++ b/src/plugins/plainFolderIcon.ts @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; export default definePlugin({ name: "PlainFolderIcon", diff --git a/src/plugins/platformIndicators.tsx b/src/plugins/platformIndicators.tsx index 1c9bbf170..5cae38f04 100644 --- a/src/plugins/platformIndicators.tsx +++ b/src/plugins/platformIndicators.tsx @@ -16,16 +16,14 @@ * along with this program. If not, see . */ +import { Settings } from "@api/settings"; +import ErrorBoundary from "@components/ErrorBoundary"; +import { Devs } from "@utils/constants"; +import definePlugin, { OptionType } from "@utils/types"; +import { findByCodeLazy } from "@webpack"; +import { PresenceStore, Tooltip } from "@webpack/common"; import { User } from "discord-types/general"; -import { Settings } from "../api/settings"; -import ErrorBoundary from "../components/ErrorBoundary"; -import { Devs } from "../utils/constants"; -import { lazyWebpack } from "../utils/misc"; -import definePlugin, { OptionType } from "../utils/types"; -import { filters } from "../webpack"; -import { PresenceStore, Tooltip } from "../webpack/common"; - function Icon(path: string, viewBox = "0 0 24 24") { return ({ color, tooltip }: { color: string; tooltip: string; }) => ( @@ -52,7 +50,7 @@ const Icons = { }; type Platform = keyof typeof Icons; -const getStatusColor = lazyWebpack(filters.byCode("STATUS_YELLOW", "TWITCH", "STATUS_GREY")); +const getStatusColor = findByCodeLazy("STATUS_YELLOW", "TWITCH", "STATUS_GREY"); const PlatformIcon = ({ platform, status }: { platform: Platform, status: string; }) => { const tooltip = platform[0].toUpperCase() + platform.slice(1); diff --git a/src/plugins/pronoundb/components/PronounsAboutComponent.tsx b/src/plugins/pronoundb/components/PronounsAboutComponent.tsx index 3f288d5ed..255c6d35b 100644 --- a/src/plugins/pronoundb/components/PronounsAboutComponent.tsx +++ b/src/plugins/pronoundb/components/PronounsAboutComponent.tsx @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -import { Link } from "../../../components/Link"; -import { Forms, React } from "../../../webpack/common"; +import { Link } from "@components/Link"; +import { Forms, React } from "@webpack/common"; export default function PronounsAboutComponent() { return ( diff --git a/src/plugins/pronoundb/components/PronounsChatComponent.tsx b/src/plugins/pronoundb/components/PronounsChatComponent.tsx index 57033ccbb..9225fc52b 100644 --- a/src/plugins/pronoundb/components/PronounsChatComponent.tsx +++ b/src/plugins/pronoundb/components/PronounsChatComponent.tsx @@ -16,16 +16,16 @@ * along with this program. If not, see . */ +import { Settings } from "@api/settings"; +import { classes, useAwaiter } from "@utils/misc"; +import { findByPropsLazy } from "@webpack"; +import { UserStore } from "@webpack/common"; import { Message } from "discord-types/general"; -import { classes, lazyWebpack, useAwaiter } from "../../../utils/misc"; -import { Settings } from "../../../Vencord"; -import { filters } from "../../../webpack"; -import { UserStore } from "../../../webpack/common"; import { fetchPronouns, formatPronouns } from "../pronoundbUtils"; import { PronounMapping } from "../types"; -const styles: Record = lazyWebpack(filters.byProps("timestampInline")); +const styles: Record = findByPropsLazy("timestampInline"); export default function PronounsChatComponentWrapper({ message }: { message: Message; }) { // Don't bother fetching bot or system users diff --git a/src/plugins/pronoundb/components/PronounsProfileWrapper.tsx b/src/plugins/pronoundb/components/PronounsProfileWrapper.tsx index b39f4ed3d..9540bb9e6 100644 --- a/src/plugins/pronoundb/components/PronounsProfileWrapper.tsx +++ b/src/plugins/pronoundb/components/PronounsProfileWrapper.tsx @@ -16,9 +16,10 @@ * along with this program. If not, see . */ -import { useAwaiter } from "../../../utils/misc"; -import { Settings } from "../../../Vencord"; -import { UserStore } from "../../../webpack/common"; +import { Settings } from "@api/settings"; +import { useAwaiter } from "@utils/misc"; +import { UserStore } from "@webpack/common"; + import { fetchPronouns, formatPronouns } from "../pronoundbUtils"; import { PronounMapping, UserProfilePronounsProps, UserProfileProps } from "../types"; diff --git a/src/plugins/pronoundb/index.ts b/src/plugins/pronoundb/index.ts index 39637e2e9..49b25f754 100644 --- a/src/plugins/pronoundb/index.ts +++ b/src/plugins/pronoundb/index.ts @@ -16,8 +16,9 @@ * along with this program. If not, see . */ -import { Devs } from "../../utils/constants"; -import definePlugin, { OptionType } from "../../utils/types"; +import { Devs } from "@utils/constants"; +import definePlugin, { OptionType } from "@utils/types"; + import PronounsAboutComponent from "./components/PronounsAboutComponent"; import PronounsChatComponent from "./components/PronounsChatComponent"; import PronounsProfileWrapper from "./components/PronounsProfileWrapper"; diff --git a/src/plugins/pronoundb/pronoundbUtils.ts b/src/plugins/pronoundb/pronoundbUtils.ts index 73ec7b6cb..afeea9584 100644 --- a/src/plugins/pronoundb/pronoundbUtils.ts +++ b/src/plugins/pronoundb/pronoundbUtils.ts @@ -16,9 +16,10 @@ * along with this program. If not, see . */ -import { VENCORD_USER_AGENT } from "../../utils/constants"; -import { debounce } from "../../utils/debounce"; -import { Settings } from "../../Vencord"; +import { Settings } from "@api/settings"; +import { VENCORD_USER_AGENT } from "@utils/constants"; +import { debounce } from "@utils/debounce"; + import { PronounsFormat } from "."; import { PronounCode, PronounMapping, PronounsResponse } from "./types"; diff --git a/src/plugins/quickMention.tsx b/src/plugins/quickMention.tsx index 0f8410b88..1c0a6c6ca 100644 --- a/src/plugins/quickMention.tsx +++ b/src/plugins/quickMention.tsx @@ -16,11 +16,11 @@ * along with this program. If not, see . */ -import { Devs } from "../utils/constants"; -import { lazyWebpack } from "../utils/misc"; -import definePlugin from "../utils/types"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; +import { findLazy } from "@webpack"; -const ComponentDispatch = lazyWebpack(m => m.emitter?._events?.INSERT_TEXT); +const ComponentDispatch = findLazy(m => m.emitter?._events?.INSERT_TEXT); export default definePlugin({ name: "QuickMention", diff --git a/src/plugins/quickReply.ts b/src/plugins/quickReply.ts index 2903b398b..a499ea412 100644 --- a/src/plugins/quickReply.ts +++ b/src/plugins/quickReply.ts @@ -16,16 +16,14 @@ * along with this program. If not, see . */ +import { migratePluginSettings } from "@api/settings"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; +import { findByPropsLazy } from "@webpack"; +import { ChannelStore, FluxDispatcher as Dispatcher, MessageStore, SelectedChannelStore, UserStore } from "@webpack/common"; import { Message } from "discord-types/general"; -import { migratePluginSettings } from "../api/settings"; -import { Devs } from "../utils/constants"; -import { lazyWebpack } from "../utils/misc"; -import definePlugin from "../utils/types"; -import { filters } from "../webpack"; -import { ChannelStore, FluxDispatcher as Dispatcher, MessageStore, SelectedChannelStore, UserStore } from "../webpack/common"; - -const Kangaroo = lazyWebpack(filters.byProps("jumpToMessage")); +const Kangaroo = findByPropsLazy("jumpToMessage"); const isMac = navigator.platform.includes("Mac"); // bruh let replyIdx = -1; diff --git a/src/plugins/readAllNotificationsButton.tsx b/src/plugins/readAllNotificationsButton.tsx index 615702b4e..ee6ecde39 100644 --- a/src/plugins/readAllNotificationsButton.tsx +++ b/src/plugins/readAllNotificationsButton.tsx @@ -16,10 +16,10 @@ * along with this program. If not, see . */ -import { addServerListElement, removeServerListElement, ServerListRenderPosition } from "../api/ServerList"; -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; -import { Button, FluxDispatcher, GuildChannelStore, GuildStore, React, ReadStateStore } from "../webpack/common"; +import { addServerListElement, removeServerListElement, ServerListRenderPosition } from "@api/ServerList"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; +import { Button, FluxDispatcher, GuildChannelStore, GuildStore, React, ReadStateStore } from "@webpack/common"; function onClick() { const channels: Array = []; diff --git a/src/plugins/reverseImageSearch.tsx b/src/plugins/reverseImageSearch.tsx index 804ac0489..26e10038d 100644 --- a/src/plugins/reverseImageSearch.tsx +++ b/src/plugins/reverseImageSearch.tsx @@ -16,9 +16,9 @@ * along with this program. If not, see . */ -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; -import { Menu } from "../webpack/common"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; +import { Menu } from "@webpack/common"; const Engines = { Google: "https://www.google.com/searchbyimage?image_url=", diff --git a/src/plugins/reviewDB/Utils/ReviewDBAPI.ts b/src/plugins/reviewDB/Utils/ReviewDBAPI.ts index 71e6e81c4..a4c8dbfdb 100644 --- a/src/plugins/reviewDB/Utils/ReviewDBAPI.ts +++ b/src/plugins/reviewDB/Utils/ReviewDBAPI.ts @@ -16,7 +16,8 @@ * along with this program. If not, see . */ -import { Settings } from "../../../Vencord"; +import { Settings } from "@api/settings"; + import { Review } from "../entities/Review"; import { authorize, showToast } from "./Utils"; diff --git a/src/plugins/reviewDB/Utils/Utils.tsx b/src/plugins/reviewDB/Utils/Utils.tsx index 1093c9567..79d768c8b 100644 --- a/src/plugins/reviewDB/Utils/Utils.tsx +++ b/src/plugins/reviewDB/Utils/Utils.tsx @@ -16,12 +16,13 @@ * along with this program. If not, see . */ -import { Devs } from "../../../utils/constants"; -import Logger from "../../../utils/Logger"; -import { openModal } from "../../../utils/modal"; -import { Settings } from "../../../Vencord"; -import { findByProps } from "../../../webpack"; -import { FluxDispatcher, React, SelectedChannelStore, Toasts, UserUtils } from "../../../webpack/common"; +import { Settings } from "@api/settings"; +import { Devs } from "@utils/constants"; +import Logger from "@utils/Logger"; +import { openModal } from "@utils/modal"; +import { findByProps } from "@webpack"; +import { FluxDispatcher, React, SelectedChannelStore, Toasts, UserUtils } from "@webpack/common"; + import { Review } from "../entities/Review"; export async function openUserProfileModal(userId: string) { diff --git a/src/plugins/reviewDB/components/MessageButton.tsx b/src/plugins/reviewDB/components/MessageButton.tsx index 7d16630c0..c334ddd31 100644 --- a/src/plugins/reviewDB/components/MessageButton.tsx +++ b/src/plugins/reviewDB/components/MessageButton.tsx @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -import { classes, LazyComponent } from "../../../utils/misc"; -import { findByProps } from "../../../webpack"; +import { classes, LazyComponent } from "@utils/misc"; +import { findByProps } from "@webpack"; export default LazyComponent(() => { const { button, dangerous } = findByProps("button", "wrapper", "disabled"); diff --git a/src/plugins/reviewDB/components/ReviewComponent.tsx b/src/plugins/reviewDB/components/ReviewComponent.tsx index 06a9f72eb..ddb49223d 100644 --- a/src/plugins/reviewDB/components/ReviewComponent.tsx +++ b/src/plugins/reviewDB/components/ReviewComponent.tsx @@ -16,9 +16,10 @@ * along with this program. If not, see . */ -import { classes, LazyComponent } from "../../../utils/misc"; -import { filters, findBulk } from "../../../webpack"; -import { Alerts, UserStore } from "../../../webpack/common"; +import { classes, LazyComponent } from "@utils/misc"; +import { filters, findBulk } from "@webpack"; +import { Alerts, UserStore } from "@webpack/common"; + import { Review } from "../entities/Review"; import { deleteReview, reportReview } from "../Utils/ReviewDBAPI"; import { canDeleteReview, openUserProfileModal, showToast } from "../Utils/Utils"; diff --git a/src/plugins/reviewDB/components/ReviewsView.tsx b/src/plugins/reviewDB/components/ReviewsView.tsx index 561490f24..71a6e7e9d 100644 --- a/src/plugins/reviewDB/components/ReviewsView.tsx +++ b/src/plugins/reviewDB/components/ReviewsView.tsx @@ -16,14 +16,15 @@ * along with this program. If not, see . */ +import { classes, useAwaiter } from "@utils/misc"; +import { findLazy } from "@webpack"; +import { Forms, Text, UserStore } from "@webpack/common"; import type { KeyboardEvent } from "react"; -import { classes, lazyWebpack, useAwaiter } from "../../../utils/misc"; -import { Forms, Text, UserStore } from "../../../webpack/common"; import { addReview, getReviews } from "../Utils/ReviewDBAPI"; import ReviewComponent from "./ReviewComponent"; -const Classes = lazyWebpack(m => typeof m.textarea === "string"); +const Classes = findLazy(m => typeof m.textarea === "string"); export default function ReviewsView({ userId }: { userId: string; }) { const [reviews, _, isLoading, refetch] = useAwaiter(() => getReviews(userId), []); diff --git a/src/plugins/reviewDB/index.tsx b/src/plugins/reviewDB/index.tsx index 0349ea9d0..744c2d620 100644 --- a/src/plugins/reviewDB/index.tsx +++ b/src/plugins/reviewDB/index.tsx @@ -16,13 +16,13 @@ * along with this program. If not, see . */ +import { Settings } from "@api/settings"; +import ErrorBoundary from "@components/ErrorBoundary"; +import { Devs } from "@utils/constants"; +import definePlugin, { OptionType } from "@utils/types"; +import { Button, UserStore } from "@webpack/common"; import { User } from "discord-types/general"; -import ErrorBoundary from "../../components/ErrorBoundary"; -import { Devs } from "../../utils/constants"; -import definePlugin, { OptionType } from "../../utils/types"; -import { Settings } from "../../Vencord"; -import { Button, UserStore } from "../../webpack/common"; import ReviewsView from "./components/ReviewsView"; import { getLastReviewID } from "./Utils/ReviewDBAPI"; import { authorize, showToast } from "./Utils/Utils"; diff --git a/src/plugins/settings.tsx b/src/plugins/settings.tsx index ec4295667..975c3992c 100644 --- a/src/plugins/settings.tsx +++ b/src/plugins/settings.tsx @@ -16,10 +16,13 @@ * along with this program. If not, see . */ +import { Devs } from "@utils/constants"; +import { LazyComponent } from "@utils/misc"; +import definePlugin from "@utils/types"; + import gitHash from "~git-hash"; -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; +const SettingsComponent = LazyComponent(() => require("../components/VencordSettings").default); export default definePlugin({ name: "Settings", @@ -42,13 +45,15 @@ export default definePlugin({ replacement: { match: /\{section:(.{1,2})\.ID\.HEADER,\s*label:(.{1,2})\..{1,2}\.Messages\.ACTIVITY_SETTINGS\}/, replace: (m, mod) => { - const updater = !IS_WEB ? '{section:"VencordUpdater",label:"Updater",element:Vencord.Components.Updater},' : ""; - const patchHelper = IS_DEV ? '{section:"VencordPatchHelper",label:"PatchHelper",element:Vencord.Components.PatchHelper},' : ""; + const updater = !IS_WEB ? '{section:"VencordUpdater",label:"Updater",element:Vencord.Plugins.plugins.Settings.tabs.updater},' : ""; + const patchHelper = IS_DEV ? '{section:"VencordPatchHelper",label:"Patch Helper",element:Vencord.Components.PatchHelper},' : ""; return ( `{section:${mod}.ID.HEADER,label:"Vencord"},` + - '{section:"VencordSetting",label:"Vencord",element:Vencord.Components.Settings},' + - '{section:"VencordPlugins",label:"Plugins",element:Vencord.Components.PluginSettings},' + + '{section:"VencordSettings",label:"Vencord",element:Vencord.Plugins.plugins.Settings.tabs.vencord},' + + '{section:"VencordPlugins",label:"Plugins",element:Vencord.Plugins.plugins.Settings.tabs.plugins},' + + '{section:"VencordThemes",label:"Themes",element:Vencord.Plugins.plugins.Settings.tabs.themes},' + updater + + '{section:"VencordSettingsSync",label:"Backup & Restore",element:Vencord.Plugins.plugins.Settings.tabs.sync},' + patchHelper + `{section:${mod}.ID.DIVIDER},${m}` ); @@ -56,6 +61,14 @@ export default definePlugin({ } }], + tabs: { + vencord: () => , + plugins: () => , + themes: () => , + updater: () => , + sync: () => + }, + get electronVersion() { return VencordNative.getVersions().electron || window.armcord?.electron || null; }, diff --git a/src/plugins/showHiddenChannels.tsx b/src/plugins/showHiddenChannels.tsx index 8dc92bfec..70b8406f0 100644 --- a/src/plugins/showHiddenChannels.tsx +++ b/src/plugins/showHiddenChannels.tsx @@ -17,13 +17,13 @@ */ -import { Flex } from "../components/Flex"; -import { Devs } from "../utils/constants"; -import { ModalContent, ModalFooter, ModalHeader, ModalRoot, ModalSize, openModal } from "../utils/modal"; -import definePlugin, { OptionType } from "../utils/types"; -import { Settings } from "../Vencord"; -import { waitFor } from "../webpack"; -import { Button, ChannelStore, Text } from "../webpack/common"; +import { Settings } from "@api/settings"; +import { Flex } from "@components/Flex"; +import { Devs } from "@utils/constants"; +import { ModalContent, ModalFooter, ModalHeader, ModalRoot, ModalSize, openModal } from "@utils/modal"; +import definePlugin, { OptionType } from "@utils/types"; +import { waitFor } from "@webpack"; +import { Button, ChannelStore, Text } from "@webpack/common"; const CONNECT = 1048576n; const VIEW_CHANNEL = 1024n; diff --git a/src/plugins/silentTyping.ts b/src/plugins/silentTyping.ts index 1f791251b..8680a8667 100644 --- a/src/plugins/silentTyping.ts +++ b/src/plugins/silentTyping.ts @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; export default definePlugin({ name: "SilentTyping", diff --git a/src/plugins/spotifyControls/PlayerComponent.tsx b/src/plugins/spotifyControls/PlayerComponent.tsx index 6396e0203..24394c6f8 100644 --- a/src/plugins/spotifyControls/PlayerComponent.tsx +++ b/src/plugins/spotifyControls/PlayerComponent.tsx @@ -16,13 +16,14 @@ * along with this program. If not, see . */ -import ErrorBoundary from "../../components/ErrorBoundary"; -import { Flex } from "../../components/Flex"; -import { Link } from "../../components/Link"; -import { debounce } from "../../utils/debounce"; -import { classes, LazyComponent, lazyWebpack } from "../../utils/misc"; -import { ContextMenu, FluxDispatcher, Forms, Menu, React } from "../../webpack/common"; -import { filters, find } from "../../webpack/webpack"; +import ErrorBoundary from "@components/ErrorBoundary"; +import { Flex } from "@components/Flex"; +import { Link } from "@components/Link"; +import { debounce } from "@utils/debounce"; +import { classes, LazyComponent } from "@utils/misc"; +import { filters, find, findByCodeLazy } from "@webpack"; +import { ContextMenu, FluxDispatcher, Forms, Menu, React } from "@webpack/common"; + import { SpotifyStore, Track } from "./SpotifyStore"; const cl = (className: string) => `vc-spotify-${className}`; @@ -40,7 +41,7 @@ const useStateFromStores: ( idk?: null, compare?: (old: T, newer: T) => boolean ) => T - = lazyWebpack(filters.byCode("useStateFromStores")); + = findByCodeLazy("useStateFromStores"); function Svg(path: string, label: string) { return () => ( diff --git a/src/plugins/spotifyControls/SpotifyStore.ts b/src/plugins/spotifyControls/SpotifyStore.ts index 0dad5038b..75448dc2b 100644 --- a/src/plugins/spotifyControls/SpotifyStore.ts +++ b/src/plugins/spotifyControls/SpotifyStore.ts @@ -16,13 +16,12 @@ * along with this program. If not, see . */ -import cssText from "~fileContent/styles.css"; +import IpcEvents from "@utils/IpcEvents"; +import { proxyLazy } from "@utils/proxyLazy"; +import { findByPropsLazy } from "@webpack"; +import { Flux, FluxDispatcher } from "@webpack/common"; -import IpcEvents from "../../utils/IpcEvents"; -import { lazyWebpack } from "../../utils/misc"; -import { proxyLazy } from "../../utils/proxyLazy"; -import { filters } from "../../webpack"; -import { Flux, FluxDispatcher } from "../../webpack/common"; +import cssText from "~fileContent/spotifyStyles.css"; export interface Track { id: string; @@ -78,8 +77,8 @@ export const SpotifyStore = proxyLazy(() => { // For some reason ts hates extends Flux.Store const { Store } = Flux; - const SpotifySocket = lazyWebpack(filters.byProps("getActiveSocketAndDevice")); - const SpotifyAPI = lazyWebpack(filters.byProps("SpotifyAPIMarker")); + const SpotifySocket = findByPropsLazy("getActiveSocketAndDevice"); + const SpotifyAPI = findByPropsLazy("SpotifyAPIMarker"); const API_BASE = "https://api.spotify.com/v1/me/player"; diff --git a/src/plugins/spotifyControls/index.tsx b/src/plugins/spotifyControls/index.tsx index 14c7a9396..7ab1e3701 100644 --- a/src/plugins/spotifyControls/index.tsx +++ b/src/plugins/spotifyControls/index.tsx @@ -16,8 +16,9 @@ * along with this program. If not, see . */ -import { Devs } from "../../utils/constants"; -import definePlugin from "../../utils/types"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; + import { Player } from "./PlayerComponent"; export default definePlugin({ diff --git a/src/plugins/spotifyControls/styles.css b/src/plugins/spotifyControls/spotifyStyles.css similarity index 100% rename from src/plugins/spotifyControls/styles.css rename to src/plugins/spotifyControls/spotifyStyles.css diff --git a/src/plugins/spotifyCrack.ts b/src/plugins/spotifyCrack.ts index b9f68ed7c..c64154aaf 100644 --- a/src/plugins/spotifyCrack.ts +++ b/src/plugins/spotifyCrack.ts @@ -16,10 +16,9 @@ * along with this program. If not, see . */ -import { migratePluginSettings } from "../api/settings"; -import { Devs } from "../utils/constants"; -import definePlugin, { OptionType } from "../utils/types"; -import { Settings } from "../Vencord"; +import { migratePluginSettings, Settings } from "@api/settings"; +import { Devs } from "@utils/constants"; +import definePlugin, { OptionType } from "@utils/types"; migratePluginSettings("SpotifyCrack", "Ify"); export default definePlugin({ diff --git a/src/plugins/spotifyShareCommands.ts b/src/plugins/spotifyShareCommands.ts index e5b247b38..ce29b7503 100644 --- a/src/plugins/spotifyShareCommands.ts +++ b/src/plugins/spotifyShareCommands.ts @@ -16,13 +16,12 @@ * along with this program. If not, see . */ -import { ApplicationCommandInputType, sendBotMessage } from "../api/Commands"; -import { migratePluginSettings } from "../api/settings"; -import { Devs } from "../utils/constants"; -import { lazyWebpack } from "../utils/misc"; -import definePlugin from "../utils/types"; -import { filters } from "../webpack"; -import { FluxDispatcher } from "../webpack/common"; +import { ApplicationCommandInputType, sendBotMessage } from "@api/Commands"; +import { migratePluginSettings } from "@api/settings"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; +import { findByPropsLazy } from "@webpack"; +import { FluxDispatcher } from "@webpack/common"; interface Album { id: string; @@ -54,9 +53,9 @@ interface Track { name: string; } -const Spotify = lazyWebpack(filters.byProps("getPlayerState")); -const MessageCreator = lazyWebpack(filters.byProps("getSendMessageOptionsForReply", "sendMessage")); -const PendingReplyStore = lazyWebpack(filters.byProps("getPendingReply")); +const Spotify = findByPropsLazy("getPlayerState"); +const MessageCreator = findByPropsLazy("getSendMessageOptionsForReply", "sendMessage"); +const PendingReplyStore = findByPropsLazy("getPendingReply"); function sendMessage(channelId, message) { message = { diff --git a/src/plugins/startupTimings/StartupTimingPage.tsx b/src/plugins/startupTimings/StartupTimingPage.tsx index f0c14ed57..c8cf51da2 100644 --- a/src/plugins/startupTimings/StartupTimingPage.tsx +++ b/src/plugins/startupTimings/StartupTimingPage.tsx @@ -16,11 +16,10 @@ * along with this program. If not, see . */ -import ErrorBoundary from "../../components/ErrorBoundary"; -import { Flex } from "../../components/Flex"; -import { lazyWebpack } from "../../utils/misc"; -import { Forms, React } from "../../webpack/common"; -import { filters } from "../../webpack/webpack"; +import ErrorBoundary from "@components/ErrorBoundary"; +import { Flex } from "@components/Flex"; +import { findByPropsLazy } from "@webpack"; +import { Forms, React } from "@webpack/common"; interface AppStartPerformance { prefix: string; @@ -46,7 +45,7 @@ interface Log { delta?: number; } -const AppStartPerformance = lazyWebpack(filters.byProps("markWithDelta", "markAndLog", "markAt")) as AppStartPerformance; +const AppStartPerformance = findByPropsLazy("markWithDelta", "markAndLog", "markAt") as AppStartPerformance; interface TimerItemProps extends Log { instance: { diff --git a/src/plugins/startupTimings/index.tsx b/src/plugins/startupTimings/index.tsx index d5493c122..1dd71395e 100644 --- a/src/plugins/startupTimings/index.tsx +++ b/src/plugins/startupTimings/index.tsx @@ -17,9 +17,9 @@ */ -import { Devs } from "../../utils/constants"; -import { LazyComponent } from "../../utils/misc"; -import definePlugin from "../../utils/types"; +import { Devs } from "@utils/constants"; +import { LazyComponent } from "@utils/misc"; +import definePlugin from "@utils/types"; export default definePlugin({ name: "StartupTimings", diff --git a/src/plugins/unindent.ts b/src/plugins/unindent.ts index 0206095e9..a197ef4e9 100644 --- a/src/plugins/unindent.ts +++ b/src/plugins/unindent.ts @@ -16,9 +16,9 @@ * along with this program. If not, see . */ -import { addPreEditListener, addPreSendListener, MessageObject, removePreEditListener,removePreSendListener } from "../api/MessageEvents"; -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; +import { addPreEditListener, addPreSendListener, MessageObject, removePreEditListener, removePreSendListener } from "@api/MessageEvents"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; export default definePlugin({ name: "Unindent", diff --git a/src/plugins/unminifyErrors.ts b/src/plugins/unminifyErrors.ts index f0ee77cf5..2332d457c 100644 --- a/src/plugins/unminifyErrors.ts +++ b/src/plugins/unminifyErrors.ts @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; let ERROR_CODES: any; const CODES_URL = diff --git a/src/plugins/uwuify.ts b/src/plugins/uwuify.ts index 804c7417d..1c7d2cb37 100644 --- a/src/plugins/uwuify.ts +++ b/src/plugins/uwuify.ts @@ -16,9 +16,9 @@ * along with this program. If not, see . */ -import { findOption, RequiredMessageOption } from "../api/Commands"; -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; +import { findOption, RequiredMessageOption } from "@api/Commands"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; const endings = [ "owo", "UwU", ">w<", "^w^", "ā—wā—", "ā˜†wā˜†", "š—Øš˜„š—Ø", "(į—’į—Øį—•)", "(ā–°Ė˜vĖ˜ā–°)", diff --git a/src/plugins/vcDoubleClick.ts b/src/plugins/vcDoubleClick.ts index 68dc48050..de573f1c4 100644 --- a/src/plugins/vcDoubleClick.ts +++ b/src/plugins/vcDoubleClick.ts @@ -16,10 +16,10 @@ * along with this program. If not, see . */ -import { migratePluginSettings } from "../api/settings"; -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; -import { SelectedChannelStore } from "../webpack/common"; +import { migratePluginSettings } from "@api/settings"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; +import { SelectedChannelStore } from "@webpack/common"; const timers = {} as Record. */ +import { Devs } from "@utils/constants"; +import { LazyComponent } from "@utils/misc"; +import { ModalRoot, ModalSize, openModal } from "@utils/modal"; +import { PluginDef } from "@utils/types"; +import { find, findByPropsLazy } from "@webpack"; +import { Menu } from "@webpack/common"; import type { Guild } from "discord-types/general"; -import { Devs } from "../utils/constants"; -import { LazyComponent, lazyWebpack } from "../utils/misc"; -import { ModalRoot, ModalSize, openModal } from "../utils/modal"; -import { PluginDef } from "../utils/types"; -import { filters, find } from "../webpack"; -import { Menu } from "../webpack/common"; - const ImageModal = LazyComponent(() => find(m => m.prototype?.render?.toString().includes("OPEN_ORIGINAL_IMAGE"))); const MaskedLink = LazyComponent(() => find(m => m.type?.toString().includes("MASKED_LINK)"))); -const GuildBannerStore = lazyWebpack(filters.byProps("getGuildBannerURL")); +const GuildBannerStore = findByPropsLazy("getGuildBannerURL"); const OPEN_URL = "Vencord.Plugins.plugins.ViewIcons.openImage("; export default new class ViewIcons implements PluginDef { diff --git a/src/plugins/volumeBooster.ts b/src/plugins/volumeBooster.ts index fddf65017..dab6b930f 100644 --- a/src/plugins/volumeBooster.ts +++ b/src/plugins/volumeBooster.ts @@ -16,9 +16,9 @@ * along with this program. If not, see . */ -import { makeRange } from "../components/PluginSettings/components/SettingSliderComponent"; -import { Devs } from "../utils/constants"; -import definePlugin, { OptionType } from "../utils/types"; +import { makeRange } from "@components/PluginSettings/components/SettingSliderComponent"; +import { Devs } from "@utils/constants"; +import definePlugin, { OptionType } from "@utils/types"; export default definePlugin({ name: "VolumeBooster", diff --git a/src/plugins/webContextMenus.ts b/src/plugins/webContextMenus.ts index 71790822d..6419cfd91 100644 --- a/src/plugins/webContextMenus.ts +++ b/src/plugins/webContextMenus.ts @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; export default definePlugin({ name: "WebContextMenus", diff --git a/src/plugins/webhookTags.ts b/src/plugins/webhookTags.ts index e02895af6..51d68fa3b 100644 --- a/src/plugins/webhookTags.ts +++ b/src/plugins/webhookTags.ts @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; export default definePlugin({ name: "Webhook Tags", diff --git a/src/plugins/whoReacted.tsx b/src/plugins/whoReacted.tsx index 00799831b..685d95421 100644 --- a/src/plugins/whoReacted.tsx +++ b/src/plugins/whoReacted.tsx @@ -16,19 +16,54 @@ * along with this program. If not, see . */ -import { User } from "discord-types/general"; - -import ErrorBoundary from "../components/ErrorBoundary"; -import { Devs } from "../utils/constants"; -import { LazyComponent, lazyWebpack } from "../utils/misc"; -import definePlugin from "../utils/types"; -import { filters, findByCode } from "../webpack"; -import { ChannelStore, React, Tooltip } from "../webpack/common"; +import ErrorBoundary from "@components/ErrorBoundary"; +import { Devs } from "@utils/constants"; +import { LazyComponent, sleep, useForceUpdater } from "@utils/misc"; +import { Queue } from "@utils/Queue"; +import definePlugin from "@utils/types"; +import { findByCode, findByPropsLazy } from "@webpack"; +import { ChannelStore, FluxDispatcher, React, RestAPI, Tooltip } from "@webpack/common"; +import { ReactionEmoji, User } from "discord-types/general"; const UserSummaryItem = LazyComponent(() => findByCode("defaultRenderUser", "showDefaultAvatarsForNullUsers")); -const AvatarStyles = lazyWebpack(filters.byProps("moreUsers", "emptyUser", "avatarContainer", "clickableAvatar")); +const AvatarStyles = findByPropsLazy("moreUsers", "emptyUser", "avatarContainer", "clickableAvatar"); -const ReactionStore = lazyWebpack(filters.byProps("getReactions")); +const ReactionStore = findByPropsLazy("getReactions"); + +const queue = new Queue(); + +function fetchReactions(msg: Message, emoji: ReactionEmoji) { + const key = emoji.name + (emoji.id ? `:${emoji.id}` : ""); + return RestAPI.get({ + url: `/channels/${msg.channel_id}/messages/${msg.id}/reactions/${key}`, + query: { + limit: 100 + }, + oldFormErrors: true + }) + .then(res => FluxDispatcher.dispatch({ + type: "MESSAGE_REACTION_ADD_USERS", + channelId: msg.channel_id, + messageId: msg.id, + users: res.body, + emoji + })) + .catch(console.error) + .finally(() => sleep(250)); +} + +function getReactionsWithQueue(msg: Message, e: ReactionEmoji) { + const key = `${msg.id}:${e.name}:${e.id ?? ""}`; + const cache = ReactionStore.__getLocalVars().reactions[key] ??= { fetched: false, users: {} }; + if (!cache.fetched) { + queue.unshift(() => + fetchReactions(msg, e) + ); + cache.fetched = true; + } + + return cache.users; +} function makeRenderMoreUsers(users: User[]) { return function renderMoreUsers(_label: string, _count: number) { @@ -62,7 +97,7 @@ export default definePlugin({ }], renderUsers(props: RootObject) { - return ( + return props.message.reactions.length > 10 ? null : ( @@ -70,8 +105,19 @@ export default definePlugin({ }, _renderUsers({ message, emoji }: RootObject) { - const reactions = ReactionStore.getReactions(message.channel_id, message.id, emoji); - const users = Object.values(reactions) as User[]; + const forceUpdate = useForceUpdater(); + React.useEffect(() => { + const cb = (e: any) => { + if (e.messageId === message.id) + forceUpdate(); + }; + FluxDispatcher.subscribe("MESSAGE_REACTION_ADD_USERS", cb); + + return () => FluxDispatcher.unsubscribe("MESSAGE_REACTION_ADD_USERS", cb); + }, [message.id]); + + const reactions = getReactionsWithQueue(message, emoji); + const users = Object.values(reactions).filter(Boolean) as User[]; return (
. */ +import { debounce } from "@utils/debounce"; +import IpcEvents from "@utils/IpcEvents"; import electron, { contextBridge, ipcRenderer, webFrame } from "electron"; import { readFileSync } from "fs"; import { join } from "path"; -import { debounce } from "./utils/debounce"; -import IpcEvents from "./utils/IpcEvents"; import VencordNative from "./VencordNative"; if (electron.desktopCapturer === void 0) { diff --git a/src/utils/Queue.ts b/src/utils/Queue.ts index 46959a0d1..86eb79196 100644 --- a/src/utils/Queue.ts +++ b/src/utils/Queue.ts @@ -18,10 +18,66 @@ import { Promisable } from "type-fest"; +/** + * A queue that can be used to run tasks consecutively. + * Highly recommended for things like fetching data from Discord + */ export class Queue { - private promise: Promise = Promise.resolve(); + /** + * @param maxSize The maximum amount of functions that can be queued at once. + * If the queue is full, the oldest function will be removed. + */ + constructor(public maxSize = Infinity) { } - add(func: (lastValue: unknown) => Promisable): Promise { - return (this.promise = this.promise.then(func)); + private queue = [] as Array<() => Promisable>; + + private promise?: Promise; + + private next() { + const func = this.queue.shift(); + if (func) + this.promise = Promise.resolve() + .then(func) + .finally(() => this.next()); + else + this.promise = undefined; + } + + private run() { + if (!this.promise) + this.next(); + } + + /** + * Append a task at the end of the queue. This task will be executed after all other tasks + * If the queue exceeds the specified maxSize, the first task in queue will be removed. + * @param func Task + */ + push(func: () => Promisable) { + if (this.size >= this.maxSize) + this.queue.shift(); + + this.queue.push(func); + this.run(); + } + + /** + * Prepend a task at the beginning of the queue. This task will be executed next + * If the queue exceeds the specified maxSize, the last task in queue will be removed. + * @param func Task + */ + unshift(func: () => Promisable) { + if (this.size >= this.maxSize) + this.queue.pop(); + + this.queue.unshift(func); + this.run(); + } + + /** + * The amount of tasks in the queue + */ + get size() { + return this.queue.length; } } diff --git a/src/utils/debounce.ts b/src/utils/debounce.ts index d9e19defc..6e5bba661 100644 --- a/src/utils/debounce.ts +++ b/src/utils/debounce.ts @@ -16,6 +16,13 @@ * along with this program. If not, see . */ +/** + * Returns a new function that will call the wrapped function + * after the specified delay. If the function is called again + * within the delay, the timer will be reset. + * @param func The function to wrap + * @param delay The delay in milliseconds + */ export function debounce(func: T, delay = 300): T { let timeout: NodeJS.Timeout; return function (...args: any[]) { diff --git a/src/utils/discord.ts b/src/utils/discord.ts index 7fc5064a7..f1a1f8a5a 100644 --- a/src/utils/discord.ts +++ b/src/utils/discord.ts @@ -16,10 +16,9 @@ * along with this program. If not, see . */ +import { ChannelStore, GuildStore, PrivateChannelsStore, SelectedChannelStore } from "@webpack/common"; import { Guild } from "discord-types/general"; -import { ChannelStore, GuildStore, PrivateChannelsStore, SelectedChannelStore } from "../webpack/common"; - export function getCurrentChannel() { return ChannelStore.getChannel(SelectedChannelStore.getChannelId()); } diff --git a/src/utils/misc.tsx b/src/utils/misc.tsx index 005bcc084..4ae3fd504 100644 --- a/src/utils/misc.tsx +++ b/src/utils/misc.tsx @@ -16,9 +16,7 @@ * along with this program. If not, see . */ -import { FilterFn, find } from "../webpack"; -import { React } from "../webpack/common"; -import { proxyLazy } from "./proxyLazy"; +import { React } from "@webpack/common"; /** * Makes a lazy function. On first call, the value is computed. @@ -29,16 +27,6 @@ export function makeLazy(factory: () => T): () => T { let cache: T; return () => cache ?? (cache = factory()); } -export const lazy = makeLazy; - -/** - * Do a lazy webpack search. Searches the module on first property access - * @param filter Filter function - * @returns A proxy to the webpack module. Not all traps are implemented, may produce unexpected results. - */ -export function lazyWebpack(filter: FilterFn): T { - return proxyLazy(() => find(filter)); -} type AwaiterRes = [T, any, boolean, () => void]; /** @@ -70,6 +58,14 @@ export function useAwaiter(factory: () => Promise, fallbackValue: T | null return [state.value, state.error, state.pending, () => setSignal(signal + 1)]; } +/** + * Returns a function that can be used to force rerender react components + */ +export function useForceUpdater() { + const [, set] = React.useState(0); + return () => set(s => s + 1); +} + /** * A lazy component. The factory method is called on first render. For example useful * for const Component = LazyComponent(() => findByDisplayName("...").default) @@ -139,6 +135,9 @@ export function classes(...classes: string[]) { return classes.join(" "); } +/** + * Returns a promise that resolves after the specified amount of time + */ export function sleep(ms: number): Promise { return new Promise(r => setTimeout(r, ms)); } diff --git a/src/utils/modal.tsx b/src/utils/modal.tsx index 2affbd7d1..9a90460b3 100644 --- a/src/utils/modal.tsx +++ b/src/utils/modal.tsx @@ -16,8 +16,7 @@ * along with this program. If not, see . */ -import { filters } from "../webpack"; -import { mapMangledModuleLazy } from "../webpack/webpack"; +import { filters, mapMangledModuleLazy } from "@webpack"; export enum ModalSize { SMALL = "small", @@ -76,14 +75,26 @@ const ModalAPI = mapMangledModuleLazy("onCloseRequest:null!=", { openModalLazy: m => m?.length === 1 && filters.byCode(".apply(this,arguments)")(m), }); +/** + * Wait for the render promise to resolve, then open a modal with it. + * This is equivalent to render().then(openModal) + * You should use the Modal components exported by this file + */ export function openModalLazy(render: () => Promise, options?: ModalOptions & { contextKey?: string; }): Promise { return ModalAPI.openModalLazy(render, options); } +/** + * Open a Modal with the given render function. + * You should use the Modal components exported by this file + */ export function openModal(render: RenderFunction, options?: ModalOptions, contextKey?: string): string { return ModalAPI.openModal(render, options, contextKey); } +/** + * Close a modal by its key + */ export function closeModal(modalKey: string, contextKey?: string): void { return ModalAPI.closeModal(modalKey, contextKey); } diff --git a/src/utils/proxyLazy.ts b/src/utils/proxyLazy.ts index 364dd5697..42b5a91d3 100644 --- a/src/utils/proxyLazy.ts +++ b/src/utils/proxyLazy.ts @@ -63,7 +63,7 @@ handler.getOwnPropertyDescriptor = (target, p) => { * @param factory lazy factory * @returns Proxy * - * Note that the example below exists already as an api, see {@link lazyWebpack} + * Note that the example below exists already as an api, see {@link findByPropsLazy} * @example const mod = proxyLazy(() => findByProps("blah")); console.log(mod.blah); */ export function proxyLazy(factory: () => T): T { diff --git a/src/utils/quickCss.ts b/src/utils/quickCss.ts index 0ce1f588e..1f9f235f5 100644 --- a/src/utils/quickCss.ts +++ b/src/utils/quickCss.ts @@ -16,7 +16,8 @@ * along with this program. If not, see . */ -import { addSettingsListener, Settings } from "../api/settings"; +import { addSettingsListener, Settings } from "@api/settings"; + import IpcEvents from "./IpcEvents"; let style: HTMLStyleElement; diff --git a/src/utils/settingsSync.ts b/src/utils/settingsSync.ts index ecf66652a..5cd81e7e4 100644 --- a/src/utils/settingsSync.ts +++ b/src/utils/settingsSync.ts @@ -16,7 +16,8 @@ * along with this program. If not, see . */ -import { Toasts } from "../webpack/common"; +import { Toasts } from "@webpack/common"; + import IpcEvents from "./IpcEvents"; import Logger from "./Logger"; diff --git a/src/utils/types.ts b/src/utils/types.ts index 30c603f4d..310fbea08 100644 --- a/src/utils/types.ts +++ b/src/utils/types.ts @@ -16,10 +16,9 @@ * along with this program. If not, see . */ +import { Command } from "@api/Commands"; import { Promisable } from "type-fest"; -import { Command } from "../api/Commands"; - // exists to export default definePlugin({...}) export default function definePlugin

(p: P & Record) { return p; diff --git a/src/webpack/common.tsx b/src/webpack/common.tsx index 426b183df..318cd02fe 100644 --- a/src/webpack/common.tsx +++ b/src/webpack/common.tsx @@ -16,30 +16,35 @@ * along with this program. If not, see . */ +import { LazyComponent } from "@utils/misc"; +import { proxyLazy } from "@utils/proxyLazy"; +import { + _resolveReady, + filters, findByCode, findByCodeLazy, findByPropsLazy, mapMangledModule, mapMangledModuleLazy, waitFor +} from "@webpack"; import type Components from "discord-types/components"; import { User } from "discord-types/general"; import type Other from "discord-types/other"; import type Stores from "discord-types/stores"; -import { LazyComponent, lazyWebpack } from "../utils/misc"; -import { proxyLazy } from "../utils/proxyLazy"; -import { _resolveReady, filters, findByCode, mapMangledModule, mapMangledModuleLazy, waitFor } from "./webpack"; - -export const Margins = lazyWebpack(filters.byProps("marginTop20")); +export const Margins = findByPropsLazy("marginTop20"); export let FluxDispatcher: Other.FluxDispatcher; -export const Flux = lazyWebpack(filters.byProps("connectStores")); +export const Flux = findByPropsLazy("connectStores"); export let React: typeof import("react"); -export const ReactDOM: typeof import("react-dom") = lazyWebpack(filters.byProps("createPortal", "render")); +export const ReactDOM: typeof import("react-dom") = findByPropsLazy("createPortal", "render"); -export const moment: typeof import("moment") = lazyWebpack(filters.byProps("parseTwoDigitYear")); +export const RestAPI = findByPropsLazy("getAPIBaseURL", "get"); +export const moment: typeof import("moment") = findByPropsLazy("parseTwoDigitYear"); -export const MessageStore = lazyWebpack(filters.byProps("getRawMessages")) as Omit & { getMessages(chanId: string): any; }; -export const PermissionStore = lazyWebpack(filters.byProps("can", "getGuildPermissions")); -export const PrivateChannelsStore = lazyWebpack(filters.byProps("openPrivateChannel")); -export const GuildChannelStore = lazyWebpack(filters.byProps("getChannels")); -export const ReadStateStore = lazyWebpack(filters.byProps("lastMessageId")); -export const PresenceStore = lazyWebpack(filters.byProps("setCurrentUserOnConnectionOpen")); +export const MessageStore = findByPropsLazy("getRawMessages") as Omit & { + getMessages(chanId: string): any; +}; +export const PermissionStore = findByPropsLazy("can", "getGuildPermissions"); +export const PrivateChannelsStore = findByPropsLazy("openPrivateChannel"); +export const GuildChannelStore = findByPropsLazy("getChannels"); +export const ReadStateStore = findByPropsLazy("lastMessageId"); +export const PresenceStore = findByPropsLazy("setCurrentUserOnConnectionOpen"); export let GuildStore: Stores.GuildStore; export let UserStore: Stores.UserStore; export let SelectedChannelStore: Stores.SelectedChannelStore; @@ -120,7 +125,7 @@ export const Toasts = { }; export const UserUtils = { - fetchUser: lazyWebpack(filters.byCode(".USER(", "getUser")) as (id: string) => Promise, + fetchUser: findByCodeLazy(".USER(", "getUser") as (id: string) => Promise, }; export const Clipboard = mapMangledModuleLazy('document.queryCommandEnabled("copy")||document.queryCommandSupported("copy")', { @@ -194,7 +199,7 @@ export type TextProps = React.PropsWithChildren & { className?: string; }; -export type TextVariant = "heading-sm/normal" | "heading-sm/medium" | "heading-sm/bold" | "heading-md/normal" | "heading-md/medium" | "heading-md/bold" | "heading-lg/normal" | "heading-lg/medium" | "heading-lg/bold" | "heading-xl/normal" | "heading-xl/medium" | "heading-xl/bold" | "heading-xxl/normal" | "heading-xxl/medium" | "heading-xxl/bold" | "eyebrow" | "heading-deprecated-14/normal" | "heading-deprecated-14/medium" | "heading-deprecated-14/bold" | "text-xxs/normal" | "text-xxs/medium" | "text-xxs/semibold" | "text-xxs/bold" | "text-xs/normal" | "text-xs/medium" | "text-xs/semibold" | "text-xs/bold" | "text-sm/normal" | "text-sm/medium" | "text-sm/semibold" | "text-sm/bold" | "text-md/normal" | "text-md/medium" | "text-md/semibold" | "text-md/bold" | "text-lg/normal" | "text-lg/medium" | "text-lg/semibold" | "text-lg/bold" | "display-md" | "display-lg" | "code"; +export type TextVariant = "heading-sm/normal" | "heading-sm/medium" | "heading-sm/bold" | "heading-md/normal" | "heading-md/medium" | "heading-md/bold" | "heading-lg/normal" | "heading-lg/medium" | "heading-lg/bold" | "heading-xl/normal" | "heading-xl/medium" | "heading-xl/bold" | "heading-xxl/normal" | "heading-xxl/medium" | "heading-xxl/bold" | "eyebrow" | "heading-deprecated-14/normal" | "heading-deprecated-14/medium" | "heading-deprecated-14/bold" | "text-xxs/normal" | "text-xxs/medium" | "text-xxs/semibold" | "text-xxs/bold" | "text-xs/normal" | "text-xs/medium" | "text-xs/semibold" | "text-xs/bold" | "text-sm/normal" | "text-sm/medium" | "text-sm/semibold" | "text-sm/bold" | "text-md/normal" | "text-md/medium" | "text-md/semibold" | "text-md/bold" | "text-lg/normal" | "text-lg/medium" | "text-lg/semibold" | "text-lg/bold" | "display-sm" | "display-md" | "display-lg" | "code"; type RC = React.ComponentType>>; interface Menu { diff --git a/src/webpack/patchWebpack.ts b/src/webpack/patchWebpack.ts index e17ddfcfc..273a0623f 100644 --- a/src/webpack/patchWebpack.ts +++ b/src/webpack/patchWebpack.ts @@ -16,8 +16,9 @@ * along with this program. If not, see . */ -import { WEBPACK_CHUNK } from "../utils/constants"; -import Logger from "../utils/Logger"; +import { WEBPACK_CHUNK } from "@utils/constants"; +import Logger from "@utils/Logger"; + import { _initWebpack } from "."; let webpackChunk: any[]; diff --git a/src/webpack/webpack.ts b/src/webpack/webpack.ts index 1231d9e4c..0bbd81506 100644 --- a/src/webpack/webpack.ts +++ b/src/webpack/webpack.ts @@ -16,11 +16,11 @@ * along with this program. If not, see . */ +import Logger from "@utils/Logger"; +import { proxyLazy } from "@utils/proxyLazy"; import type { WebpackInstance } from "discord-types/other"; import { traceFunction } from "../debug/Tracer"; -import Logger from "../utils/Logger"; -import { proxyLazy } from "../utils/proxyLazy"; const logger = new Logger("Webpack"); @@ -42,8 +42,6 @@ export const filters = { ? m => m[props[0]] !== void 0 : m => props.every(p => m[p] !== void 0), - byDisplayName: (deezNuts: string): FilterFn => m => m.default?.displayName === deezNuts, - byCode: (...code: string[]): FilterFn => m => { if (typeof m !== "function") return false; const s = Function.prototype.toString.call(m); @@ -75,6 +73,9 @@ if (IS_DEV && !IS_WEB) { }, 0); } +/** + * Find the first module that matches the filter + */ export const find = traceFunction("find", function find(filter: FilterFn, getDefault = true, isWaitFor = false) { if (typeof filter !== "function") throw new Error("Invalid filter. Expected a function got " + typeof filter); @@ -112,6 +113,13 @@ export const find = traceFunction("find", function find(filter: FilterFn, getDef return null; }); +/** + * find but lazy + */ +export function findLazy(filter: FilterFn, getDefault = true) { + return proxyLazy(() => find(filter, getDefault)); +} + export function findAll(filter: FilterFn, getDefault = true) { if (typeof filter !== "function") throw new Error("Invalid filter. Expected a function got " + typeof filter); @@ -283,22 +291,45 @@ export function mapMangledModuleLazy(code: string, mappers: Re return proxyLazy(() => mapMangledModule(code, mappers)); } +/** + * Find the first module that has the specified properties + */ export function findByProps(...props: string[]) { return find(filters.byProps(...props)); } +/** + * findByProps but lazy + */ +export function findByPropsLazy(...props: string[]) { + return findLazy(filters.byProps(...props)); +} + +/** + * Find all modules that have the specified properties + */ export function findAllByProps(...props: string[]) { return findAll(filters.byProps(...props)); } +/** + * Find a function by its code + */ export function findByCode(...code: string[]) { return find(filters.byCode(...code)); } -export function findByDisplayName(deezNuts: string) { - return find(filters.byDisplayName(deezNuts)); +/** + * findByCode but lazy + */ +export function findByCodeLazy(...code: string[]) { + return findLazy(filters.byCode(...code)); } +/** + * Wait for a module that matches the provided filter to be registered, + * then call the callback with the module as the first argument + */ export function waitFor(filter: string | string[] | FilterFn, callback: CallbackFn) { if (typeof filter === "string") filter = filters.byProps(filter); diff --git a/tsconfig.json b/tsconfig.json index aa1253296..a55c1fe36 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -14,7 +14,16 @@ "strict": true, "noImplicitAny": false, "target": "ESNEXT", - "jsx": "preserve" + "jsx": "preserve", + + "baseUrl": "./src/", + "paths": { + "@webpack": ["./webpack"], + "@webpack/common": ["./webpack/common"], + "@utils/*": ["./utils/*"], + "@api/*": ["./api/*"], + "@components/*": ["./components/*"] + } }, "include": ["src/**/*"] }