diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 725af1e2f..a9e8c3e8d 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -16,5 +16,6 @@ DON'T Repetitive violations of these guidelines might get your access to the repository restricted. - -If you feel like a user is violating these guidelines or feel treated unfairly, please refrain from publicly challenging them and instead contact a Moderator on our Discord server or send an email to vendicated+conduct@riseup.net! +If you feel like a user is violating these guidelines or feel treated unfairly, please refrain from vigilantism +and instead report the issue to a moderator! The best way is joining our [official Discord community](https://vencord.dev/discord) +and opening a modmail ticket. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 680f8375e..6c133225c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,82 +1,55 @@ -# Contribution Guide +# Contributing to Vencord -First of all, thank you for contributing! :3 +Vencord is a community project and welcomes any kind of contribution from anyone! -To ensure your contribution is robust, please follow the below guide! +We have development documentation for new contributors, which can be found at . -For a friendly introduction to plugins, see [Megu's Plugin Guide!](docs/2_PLUGINS.md) +All contributions should be made in accordance with our [Code of Conduct](./CODE_OF_CONDUCT.md). -## Style Guide +## How to contribute -- This project has a very minimal .editorconfig. Make sure your editor supports this! - If you are using VSCode, it should automatically recommend you the extension; If not, - please install the Editorconfig extension -- Try to follow the formatting in the rest of the project and stay consistent -- Follow the file naming convention. File names should usually be camelCase, unless they export a Class - or React Component, in which case they should be PascalCase +Contributions can be sent via pull requests. If you're new to Git, check [this guide](https://opensource.com/article/19/7/create-pull-request-github). -## Contributing a Plugin +Pull requests can be made either to the `main` or the `dev` branch. However, unless you're an advanced user, I recommend sticking to `main`. This is because the dev branch might contain unstable changes and be force pushed frequently, which could cause conflicts in your pull request. -Because plugins modify code directly, incompatibilities are a problem. +## Write a plugin -Thus, 3rd party plugins are not supported, instead all plugins are part of Vencord itself. -This way we can ensure compatibility and high quality patches. +Writing a plugin is the primary way to contribute. -Follow the below guide to make your first plugin! +Before starting your plugin: +- Check existing pull requests to see if someone is already working on a similar plugin +- Check our [plugin requests tracker](https://github.com/Vencord/plugin-requests/issues) to see if there is an existing request, or if the same idea has been rejected +- If there isn't an existing request, [open one](https://github.com/Vencord/plugin-requests/issues/new?assignees=&labels=&projects=&template=request.yml) yourself + and include that you'd like to work on this yourself. Then wait for feedback to see if the idea even has any chance of being accepted. Or maybe others have some ideas to improve it! +- Familarise yourself with our plugin rules below to ensure your plugin is not banned -### Finding the right module to patch +### Plugin Rules -If the thing you want to patch is an action performed when interacting with a part of the UI, use React DevTools. -They come preinstalled and can be found as the "Components" tab in DevTools. -Use the Selector (top left) to select the UI Element. Now you can see all callbacks, props or jump to the source -directly. +- No simple slash command plugins like `/cat`. Instead, make a [user installable Discord bot](https://discord.com/developers/docs/change-log#userinstallable-apps-preview) +- No simple text replace plugins like Let me Google that for you. The TextReplace plugin can do this +- No raw DOM manipulation. Use proper patches and React +- No FakeDeafen or FakeMute +- No StereoMic +- No plugins that simply hide or redesign ui elements. This can be done with CSS +- No selfbots or API spam (animated status, message pruner, auto reply, nitro snipers, etc) +- No untrusted third party APIs. Popular services like Google or GitHub are fine, but absolutely no self hosted ones +- No plugins that require the user to enter their own API key +- Do not introduce new dependencies unless absolutely necessary and warranted -If it is anything else, or you're too lazy to use React DevTools, hit `CTRL + Shift + F` while in DevTools and -enter a search term, for example "getUser" to search all source files. -Look at the results until you find something promising. Set a breakpoint and trigger the execution of that part of Code to inspect arguments, locals, etc... +## Improve Vencord itself -### Writing a robust patch +If you have any ideas on how to improve Vencord itself, or want to propose a new plugin API, feel free to open a feature request so we can discuss. -##### "find" +Or if you notice any bugs or typos, feel free to fix them! -First you need to find a good `find` value. This should be a string that is unique to your module. -If you want to patch the `getUser` function, usually a good first try is `getUser:` or `function getUser()`, -depending on how the module is structured. Again, make sure this string is unique to your module and is not -found in any other module. To verify this, search for it in all bundles (CTRL + Shift + F) +## Contribute to our Documentation -##### "match" +The source code of our documentation is available at -This is the regex that will operate on the module found with "find". Just like in find, you should make sure -this only matches exactly the part you want to patch and no other parts in the file. +If you see anything outdated, incorrect or lacking, please fix it! +If you think a new page should be added, feel free to suggest it via an issue and we can discuss. -The easiest way to write and test your regex is the following: +## Help out users in our Discord community -- Get the ID of the module you want to patch. To do this, go to it in the sources tab and scroll up until you - see something like `447887: (e,t,n)=>{` (Obviously the number will differ). -- Now paste the following into the console: `Vencord.Webpack.wreq.m[447887].toString()` (Changing the number to your ID) -- Now either test regexes on this string in the console or use a tool like https://regex101.com - -Also pay attention to the following: - -- Never hardcode variable or parameter names or any other minified names. They will change in the future. The only Exception to this rule - are the react props parameter which seems to always be `e`, but even then only rely on this if it is necessary. - Instead, use one of the following approaches where applicable: - - Match 1 or 2 of any character: `.{1,2}`, for example to match the variable name in `var a=b`, `var (.{1,2})=` - - Match any but a guaranteed terminating character: `[^;]+`, for example to match the entire assigned value in `var a=b||c||func();`, - `var .{1,2}=([^;]+);` - - If you don't care about that part, just match a bunch of chars: `.{0,50}`, for example to extract the variable "b" in `createElement("div",{a:"foo",c:"bar"},b)`, `createElement\("div".{0,30},(.{1,2})\),`. Note the `.{0,30}`, this is essentially the same as `.+`, but safer as you can't end up accidently eating thousands of characters -- Additionally, as you might have noticed, all of the above approaches use regex groups (`(...)`) to capture the variable name. You can then use those groups in your replacement to access those variables dynamically - -#### "replace" - -This is the replacement for the match. This is the second argument to [String.replace](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace), so refer to those docs for info. - -Never hardcode minified variable or parameter names here. Instead, use capture groups in your regex to capture the variable names -and use those in your replacement - -Make sure your replacement does not introduce any whitespace. While this might seem weird, random whitespace may mess up other patches. -This includes spaces, tabs and especially newlines - ---- - -And that's it! Now open a Pull Request with your Plugin +We have an open support channel in our [Discord community](https://vencord.dev/discord). +Helping out users there is always appreciated! The more, the merrier. diff --git a/README.md b/README.md index e67db93a2..61575d4bb 100644 --- a/README.md +++ b/README.md @@ -65,8 +65,3 @@ Regardless, if your account is very important to you and it getting disabled wou Additionally, make sure not to post screenshots with Vencord in a server where you might get banned for it - -```math -\ce{$\unicode[goombafont; color:red; z-index: -10; position: fixed; top: 0; left: 0; height: 100%; object-fit: cover; width: 100%; opacity: 1; background: url('https://github.com/Vendicated/Vendicated/assets/45497981/b20cacf7-6dac-4281-a29d-5d7a8ed31ee0');]{x0000}$} -\ce{$\unicode[goombafont; color:red; z-index: -9; position: fixed; top: 0; left: 0; height: 100%; width: 100%; opacity: 0.9; background: var(--bgColor-default);]{x0000}$} -``` diff --git a/browser/content.js b/browser/content.js index 4810fe3c8..57964af64 100644 --- a/browser/content.js +++ b/browser/content.js @@ -2,23 +2,22 @@ if (typeof browser === "undefined") { var browser = chrome; } -const script = document.createElement("script"); -script.src = browser.runtime.getURL("dist/Vencord.js"); -script.id = "vencord-script"; -Object.assign(script.dataset, { - extensionBaseUrl: browser.runtime.getURL(""), - version: browser.runtime.getManifest().version -}); - const style = document.createElement("link"); style.type = "text/css"; style.rel = "stylesheet"; style.href = browser.runtime.getURL("dist/Vencord.css"); -document.documentElement.append(script); - document.addEventListener( "DOMContentLoaded", - () => document.documentElement.append(style), + () => { + document.documentElement.append(style); + window.postMessage({ + type: "vencord:meta", + meta: { + EXTENSION_VERSION: browser.runtime.getManifest().version, + EXTENSION_BASE_URL: browser.runtime.getURL(""), + } + }); + }, { once: true } ); diff --git a/browser/manifest.json b/browser/manifest.json index 69bf0cec0..357312b09 100644 --- a/browser/manifest.json +++ b/browser/manifest.json @@ -1,6 +1,6 @@ { "manifest_version": 3, - "minimum_chrome_version": "91", + "minimum_chrome_version": "111", "name": "Vencord Web", "description": "The cutest Discord mod now in your browser", @@ -22,7 +22,15 @@ "run_at": "document_start", "matches": ["*://*.discord.com/*"], "js": ["content.js"], - "all_frames": true + "all_frames": true, + "world": "ISOLATED" + }, + { + "run_at": "document_start", + "matches": ["*://*.discord.com/*"], + "js": ["dist/Vencord.js"], + "all_frames": true, + "world": "MAIN" } ], diff --git a/browser/manifestv2.json b/browser/manifestv2.json index 3cac9450a..0cb7cb32a 100644 --- a/browser/manifestv2.json +++ b/browser/manifestv2.json @@ -22,7 +22,15 @@ "run_at": "document_start", "matches": ["*://*.discord.com/*"], "js": ["content.js"], - "all_frames": true + "all_frames": true, + "world": "ISOLATED" + }, + { + "run_at": "document_start", + "matches": ["*://*.discord.com/*"], + "js": ["dist/Vencord.js"], + "all_frames": true, + "world": "MAIN" } ], @@ -35,7 +43,7 @@ "browser_specific_settings": { "gecko": { "id": "vencord-firefox@vendicated.dev", - "strict_min_version": "91.0" + "strict_min_version": "128.0" } } } diff --git a/docs/1_INSTALLING.md b/docs/1_INSTALLING.md deleted file mode 100644 index edeed4eb5..000000000 --- a/docs/1_INSTALLING.md +++ /dev/null @@ -1,97 +0,0 @@ -> [!WARNING] -> These instructions are only for advanced users. If you're not a Developer, you should use our [graphical installer](https://github.com/Vendicated/VencordInstaller#usage) instead. -> No support will be provided for installing in this fashion. If you cannot figure it out, you should just stick to a regular install. - -# Installation Guide - -Welcome to Megu's Installation Guide! In this file, you will learn about how to download, install, and uninstall Vencord! - -## Sections - -- [Installation Guide](#installation-guide) - - [Sections](#sections) - - [Dependencies](#dependencies) - - [Installing Vencord](#installing-vencord) - - [Updating Vencord](#updating-vencord) - - [Uninstalling Vencord](#uninstalling-vencord) - -## Dependencies - -- Install Git from https://git-scm.com/download -- Install Node.JS LTS from here: https://nodejs.dev/en/ - -## Installing Vencord - -Install `pnpm`: - -> :exclamation: This next command may need to be run as admin/root depending on your system, and you may need to close and reopen your terminal for pnpm to be in your PATH. - -```shell -npm i -g pnpm -``` - -> :exclamation: **IMPORTANT** Make sure you aren't using an admin/root terminal from here onwards. It **will** mess up your Discord/Vencord instance and you **will** most likely have to reinstall. - -Clone Vencord: - -```shell -git clone https://github.com/Vendicated/Vencord -cd Vencord -``` - -Install dependencies: - -```shell -pnpm install --frozen-lockfile -``` - -Build Vencord: - -```shell -pnpm build -``` - -Inject vencord into your client: - -```shell -pnpm inject -``` - -Then fully close Discord from your taskbar or task manager, and restart it. Vencord should be injected - you can check this by looking for the Vencord section in Discord settings. - -## Updating Vencord - -If you're using Discord already, go into the `Updater` tab in settings. - -Sometimes it may be necessary to manually update if the GUI updater fails. - -To pull latest changes: - -```shell -git pull -``` - -If this fails, you likely need to reset your local changes to vencord to resolve merge errors: - -> :exclamation: This command will remove any local changes you've made to vencord. Make sure you back up if you made any code changes you don't want to lose! - -```shell -git reset --hard -git pull -``` - -and then to build the changes: - -```shell -pnpm build -``` - -Then just refresh your client - -## Uninstalling Vencord - -Simply run: - -```shell -pnpm uninject -``` diff --git a/docs/2_PLUGINS.md b/docs/2_PLUGINS.md deleted file mode 100644 index 705ea89d6..000000000 --- a/docs/2_PLUGINS.md +++ /dev/null @@ -1,111 +0,0 @@ -# Plugins Guide - -Welcome to Megu's Plugin Guide! In this file, you will learn about how to write your own plugin! - -You don't need to run `pnpm build` every time you make a change. Instead, use `pnpm watch` - this will auto-compile Vencord whenever you make a change. If using code patches (recommended), you will need to CTRL+R to load the changes. - -## Plugin Entrypoint - -> If it doesn't already exist, create a folder called `userplugins` in the `src` directory of this repo. - -1. Create a folder in `src/userplugins/` with the name of your plugin. For example, `src/userplugins/epicPlugin/` - All of your plugin files will go here. - -2. Create a file in that folder called `index.ts` - -3. In `index.ts`, copy-paste the following template code: - -```ts -import definePlugin from "@utils/types"; - -export default definePlugin({ - name: "Epic Plugin", - description: "This plugin is absolutely epic", - authors: [ - { - id: 12345n, - name: "Your Name", - }, - ], - patches: [], - // Delete these two below if you are only using code patches - start() {}, - stop() {}, -}); -``` - -Change the name, description, and authors to your own information. - -Replace `12345n` with your user ID ending in `n` (e.g., `545581357812678656n`). If you don't want to share your Discord account, use `0n` instead! - -## How Plugins Work In Vencord - -Vencord uses a different way of making mods than you're used to. -Instead of monkeypatching webpack, we directly modify the code before Discord loads it. - -This is _significantly_ more efficient than monkeypatching webpack, and is surprisingly easy, but it may be confusing at first. - -## Making your patch - -For an in-depth guide into patching code, see [CONTRIBUTING.md](../CONTRIBUTING.md) - -in the `index.ts` file we made earlier, you'll see a `patches` array. - -> You'll see examples of how patches are used in all the existing plugins, and it'll be easier to understand by looking at those examples, so do that first, and then return here! - -> For a good example of a plugin using code patches AND runtime patching, check `src/plugins/unindent.ts`, which uses code patches to run custom runtime code. - -One of the patches in the `isStaff` plugin, looks like this: - -```ts -{ - match: /(\w+)\.isStaff=function\(\){return\s*!1};/, - replace: "$1.isStaff=function(){return true};", -}, -``` - -The above regex matches the string in discord that will look something like: - -```js -abc.isStaff = function () { - return !1; -}; -``` - -Remember that Discord code is minified, so there won't be any newlines, and there will only be spaces where necessary. So the source code looks something like: - -``` -abc.isStaff=function(){return!1;} -``` - -You can find these snippets by opening the devtools (`ctrl+shift+i`) and pressing `ctrl+shift+f`, searching for what you're looking to modify in there, and beautifying the file to make it more readable. - -In the `match` regex in the example shown above, you'll notice at the start there is a `(\w+)`. -Anything in the brackets will be accessible in the `replace` string using `$`. e.g., the first pair of brackets will be `$1`, the second will be `$2`, etc. - -The replacement string we used is: - -``` -"$1.isStaff=function(){return true;};" -``` - -Which, using the above example, would replace the code with: - -> **Note** -> In this example, `$1` becomes `abc` - -```js -abc.isStaff = function () { - return true; -}; -``` - -The match value _can_ be a string, rather than regex, however usually regex will be better suited, as it can work with unknown values, whereas strings must be exact matches. - -Once you've made your plugin, make sure you run `pnpm test` and make sure your code is nice and clean! - -If you want to publish your plugin into the Vencord repo, move your plugin from `src/userplugins` into the `src/plugins` folder and open a PR! - -> **Warning** -> Make sure you've read [CONTRIBUTING.md](../CONTRIBUTING.md) before opening a PR - -If you need more help, ask in the support channel in our [Discord Server](https://discord.gg/D9uwnFnqmd). diff --git a/package.json b/package.json index e80c3970a..dc90a646c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "vencord", "private": "true", - "version": "1.9.0", + "version": "1.9.3", "description": "The cutest Discord client mod", "homepage": "https://github.com/Vendicated/Vencord#readme", "bugs": { @@ -13,9 +13,6 @@ }, "license": "GPL-3.0-or-later", "author": "Vendicated", - "directories": { - "doc": "docs" - }, "scripts": { "build": "node --require=./scripts/suppressExperimentalWarnings.js scripts/build/build.mjs", "buildStandalone": "pnpm build --standalone", @@ -43,7 +40,7 @@ "eslint-plugin-simple-header": "^1.0.2", "fflate": "^0.7.4", "gifenc": "github:mattdesl/gifenc#64842fca317b112a8590f8fef2bf3825da8f6fe3", - "monaco-editor": "^0.43.0", + "monaco-editor": "^0.50.0", "nanoid": "^4.0.2", "virtual-merge": "^1.0.1" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b03585799..19295325f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -35,8 +35,8 @@ importers: specifier: github:mattdesl/gifenc#64842fca317b112a8590f8fef2bf3825da8f6fe3 version: https://codeload.github.com/mattdesl/gifenc/tar.gz/64842fca317b112a8590f8fef2bf3825da8f6fe3 monaco-editor: - specifier: ^0.43.0 - version: 0.43.0 + specifier: ^0.50.0 + version: 0.50.0 nanoid: specifier: ^4.0.2 version: 4.0.2 @@ -1531,6 +1531,10 @@ packages: is-core-module@2.13.1: resolution: {integrity: sha512-hHrIjvZsftOsvKSn2TRYl63zvxsgE0K+0mYMoH6gD4omR5IWB2KynivBQczo3+wF1cCkjzvptnI9Q0sPU66ilw==} + is-core-module@2.14.0: + resolution: {integrity: sha512-a5dFJih5ZLYlRtDc0dZWP7RiKr6xIKzmn/oAYCDvdLThadVgyJwlaoQPmRtMSpz+rk0OGAgIu+TcM9HUF0fk1A==} + engines: {node: '>= 0.4'} + is-data-descriptor@0.1.4: resolution: {integrity: sha512-+w9D5ulSoBNlmw9OHn3U2v51SyoCd0he+bB3xMl62oijhrspxowjU+AIcDY0N3iEJbUEkB15IlMASQsxYigvXg==} engines: {node: '>=0.10.0'} @@ -1791,8 +1795,8 @@ packages: moment@2.29.4: resolution: {integrity: sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w==} - monaco-editor@0.43.0: - resolution: {integrity: sha512-cnoqwQi/9fml2Szamv1XbSJieGJ1Dc8tENVMD26Kcfl7xGQWp7OBKMjlwKVGYFJ3/AXJjSOGvcqK7Ry/j9BM1Q==} + monaco-editor@0.50.0: + resolution: {integrity: sha512-8CclLCmrRRh+sul7C08BmPBP3P8wVWfBHomsTcndxg5NRCEPfu/mc2AGU8k37ajjDVXcXFc12ORAMUkmk+lkFA==} ms@2.0.0: resolution: {integrity: sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==} @@ -3463,7 +3467,7 @@ snapshots: eslint-import-resolver-node@0.3.9: dependencies: debug: 3.2.7 - is-core-module: 2.13.1 + is-core-module: 2.14.0 resolve: 1.22.8 transitivePeerDependencies: - supports-color @@ -3490,7 +3494,7 @@ snapshots: eslint-import-resolver-node: 0.3.9 eslint-module-utils: 2.8.1(@typescript-eslint/parser@5.59.1(eslint@8.46.0(patch_hash=xm46kqcmdgzlmm4aifkfpxaho4))(typescript@5.4.5))(eslint-import-resolver-node@0.3.9)(eslint@8.46.0(patch_hash=xm46kqcmdgzlmm4aifkfpxaho4)) hasown: 2.0.2 - is-core-module: 2.13.1 + is-core-module: 2.14.0 is-glob: 4.0.3 minimatch: 3.1.2 object.fromentries: 2.0.8 @@ -3934,6 +3938,10 @@ snapshots: dependencies: hasown: 2.0.2 + is-core-module@2.14.0: + dependencies: + hasown: 2.0.2 + is-data-descriptor@0.1.4: dependencies: kind-of: 3.2.2 @@ -4169,7 +4177,7 @@ snapshots: moment@2.29.4: {} - monaco-editor@0.43.0: {} + monaco-editor@0.50.0: {} ms@2.0.0: {} diff --git a/scripts/build/build.mjs b/scripts/build/build.mjs index fcf56f66c..817c2cec3 100755 --- a/scripts/build/build.mjs +++ b/scripts/build/build.mjs @@ -21,7 +21,7 @@ import esbuild from "esbuild"; import { readdir } from "fs/promises"; import { join } from "path"; -import { BUILD_TIMESTAMP, commonOpts, exists, globPlugins, IS_DEV, IS_REPORTER, IS_STANDALONE, IS_UPDATER_DISABLED, VERSION, watch } from "./common.mjs"; +import { BUILD_TIMESTAMP, commonOpts, exists, globPlugins, IS_DEV, IS_REPORTER, IS_STANDALONE, IS_UPDATER_DISABLED, resolvePluginName, VERSION, watch } from "./common.mjs"; const defines = { IS_STANDALONE, @@ -76,22 +76,20 @@ const globNativesPlugin = { for (const dir of pluginDirs) { const dirPath = join("src", dir); if (!await exists(dirPath)) continue; - const plugins = await readdir(dirPath); - for (const p of plugins) { - const nativePath = join(dirPath, p, "native.ts"); - const indexNativePath = join(dirPath, p, "native/index.ts"); + const plugins = await readdir(dirPath, { withFileTypes: true }); + for (const file of plugins) { + const fileName = file.name; + const nativePath = join(dirPath, fileName, "native.ts"); + const indexNativePath = join(dirPath, fileName, "native/index.ts"); if (!(await exists(nativePath)) && !(await exists(indexNativePath))) continue; - const nameParts = p.split("."); - const namePartsWithoutTarget = nameParts.length === 1 ? nameParts : nameParts.slice(0, -1); - // pluginName.thing.desktop -> PluginName.thing - const cleanPluginName = p[0].toUpperCase() + namePartsWithoutTarget.join(".").slice(1); + const pluginName = await resolvePluginName(dirPath, file); const mod = `p${i}`; - code += `import * as ${mod} from "./${dir}/${p}/native";\n`; - natives += `${JSON.stringify(cleanPluginName)}:${mod},\n`; + code += `import * as ${mod} from "./${dir}/${fileName}/native";\n`; + natives += `${JSON.stringify(pluginName)}:${mod},\n`; i++; } } diff --git a/scripts/build/common.mjs b/scripts/build/common.mjs index cdbb26eec..c46a559a7 100644 --- a/scripts/build/common.mjs +++ b/scripts/build/common.mjs @@ -53,6 +53,32 @@ export const banner = { `.trim() }; +const PluginDefinitionNameMatcher = /definePlugin\(\{\s*(["'])?name\1:\s*(["'`])(.+?)\2/; +/** + * @param {string} base + * @param {import("fs").Dirent} dirent + */ +export async function resolvePluginName(base, dirent) { + const fullPath = join(base, dirent.name); + const content = dirent.isFile() + ? await readFile(fullPath, "utf-8") + : await (async () => { + for (const file of ["index.ts", "index.tsx"]) { + try { + return await readFile(join(fullPath, file), "utf-8"); + } catch { + continue; + } + } + throw new Error(`Invalid plugin ${fullPath}: could not resolve entry point`); + })(); + + return PluginDefinitionNameMatcher.exec(content)?.[3] + ?? (() => { + throw new Error(`Invalid plugin ${fullPath}: must contain definePlugin call with simple string name property as first property`); + })(); +} + export async function exists(path) { return await access(path, FsConstants.F_OK) .then(() => true) @@ -88,31 +114,48 @@ export const globPlugins = kind => ({ build.onLoad({ filter, namespace: "import-plugins" }, async () => { const pluginDirs = ["plugins/_api", "plugins/_core", "plugins", "userplugins"]; let code = ""; - let plugins = "\n"; + let pluginsCode = "\n"; + let metaCode = "\n"; + let excludedCode = "\n"; let i = 0; for (const dir of pluginDirs) { - if (!await exists(`./src/${dir}`)) continue; - const files = await readdir(`./src/${dir}`); - for (const file of files) { - if (file.startsWith("_") || file.startsWith(".")) continue; - if (file === "index.ts") continue; + const userPlugin = dir === "userplugins"; + + const fullDir = `./src/${dir}`; + if (!await exists(fullDir)) continue; + const files = await readdir(fullDir, { withFileTypes: true }); + for (const file of files) { + const fileName = file.name; + if (fileName.startsWith("_") || fileName.startsWith(".")) continue; + if (fileName === "index.ts") continue; + + const target = getPluginTarget(fileName); - const target = getPluginTarget(file); if (target && !IS_REPORTER) { - if (target === "dev" && !watch) continue; - if (target === "web" && kind === "discordDesktop") continue; - if (target === "desktop" && kind === "web") continue; - if (target === "discordDesktop" && kind !== "discordDesktop") continue; - if (target === "vencordDesktop" && kind !== "vencordDesktop") continue; + const excluded = + (target === "dev" && !IS_DEV) || + (target === "web" && kind === "discordDesktop") || + (target === "desktop" && kind === "web") || + (target === "discordDesktop" && kind !== "discordDesktop") || + (target === "vencordDesktop" && kind !== "vencordDesktop"); + + if (excluded) { + const name = await resolvePluginName(fullDir, file); + excludedCode += `${JSON.stringify(name)}:${JSON.stringify(target)},\n`; + continue; + } } + const folderName = `src/${dir}/${fileName}`.replace(/^src\/plugins\//, ""); + const mod = `p${i}`; - code += `import ${mod} from "./${dir}/${file.replace(/\.tsx?$/, "")}";\n`; - plugins += `[${mod}.name]:${mod},\n`; + code += `import ${mod} from "./${dir}/${fileName.replace(/\.tsx?$/, "")}";\n`; + pluginsCode += `[${mod}.name]:${mod},\n`; + metaCode += `[${mod}.name]:${JSON.stringify({ folderName, userPlugin })},\n`; // TODO: add excluded plugins to display in the UI? i++; } } - code += `export default {${plugins}};`; + code += `export default {${pluginsCode}};export const PluginMeta={${metaCode}};export const ExcludedPlugins={${excludedCode}};`; return { contents: code, resolveDir: "./src" diff --git a/scripts/generatePluginList.ts b/scripts/generatePluginList.ts index e8aa33a46..3d7c16c01 100644 --- a/scripts/generatePluginList.ts +++ b/scripts/generatePluginList.ts @@ -39,7 +39,7 @@ interface PluginData { hasCommands: boolean; required: boolean; enabledByDefault: boolean; - target: "discordDesktop" | "vencordDesktop" | "web" | "dev"; + target: "discordDesktop" | "vencordDesktop" | "desktop" | "web" | "dev"; filePath: string; } diff --git a/scripts/generateReport.ts b/scripts/generateReport.ts index d8cbb44a0..9ffe6fb08 100644 --- a/scripts/generateReport.ts +++ b/scripts/generateReport.ts @@ -136,7 +136,6 @@ async function printReport() { body: JSON.stringify({ description: "Here's the latest Vencord Report!", username: "Vencord Reporter" + (CANARY ? " (Canary)" : ""), - avatar_url: "https://cdn.discordapp.com/avatars/1017176847865352332/c312b6b44179ae6817de7e4b09e9c6af.webp?size=512", embeds: [ { title: "Bad Patches", @@ -290,6 +289,8 @@ page.on("console", async e => { page.on("error", e => console.error("[Error]", e.message)); page.on("pageerror", e => { + if (e.message.includes("Sentry successfully disabled")) return; + if (!e.message.startsWith("Object") && !e.message.includes("Cannot find module")) { console.error("[Page Error]", e.message); report.otherErrors.push(e.message); diff --git a/src/api/Badges.ts b/src/api/Badges.ts index 24c68c4ed..7a041f1ee 100644 --- a/src/api/Badges.ts +++ b/src/api/Badges.ts @@ -44,6 +44,11 @@ export interface ProfileBadge { position?: BadgePosition; /** The badge name to display, Discord uses this. Required for component badges */ key?: string; + + /** + * Allows dynamically returning multiple badges + */ + getBadges?(userInfo: BadgeUserArgs): ProfileBadge[]; } const Badges = new Set(); @@ -73,9 +78,16 @@ export function _getBadges(args: BadgeUserArgs) { const badges = [] as ProfileBadge[]; for (const badge of Badges) { if (!badge.shouldShow || badge.shouldShow(args)) { + const b = badge.getBadges + ? badge.getBadges(args).map(b => { + b.component &&= ErrorBoundary.wrap(b.component, { noop: true }); + return b; + }) + : [{ ...badge, ...args }]; + badge.position === BadgePosition.START - ? badges.unshift({ ...badge, ...args }) - : badges.push({ ...badge, ...args }); + ? badges.unshift(...b) + : badges.push(...b); } } const donorBadges = (Plugins.BadgeAPI as unknown as typeof import("../plugins/_api/badges").default).getDonorBadges(args.userId); diff --git a/src/api/Notifications/notificationLog.tsx b/src/api/Notifications/notificationLog.tsx index 6f79ef70a..5df31d4cd 100644 --- a/src/api/Notifications/notificationLog.tsx +++ b/src/api/Notifications/notificationLog.tsx @@ -19,6 +19,8 @@ import * as DataStore from "@api/DataStore"; import { Settings } from "@api/Settings"; import { classNameFactory } from "@api/Styles"; +import { Flex } from "@components/Flex"; +import { openNotificationSettingsModal } from "@components/VencordSettings/NotificationSettings"; import { closeModal, ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, ModalSize, openModal } from "@utils/modal"; import { useAwaiter } from "@utils/react"; import { Alerts, Button, Forms, React, Text, Timestamp, useEffect, useReducer, useState } from "@webpack/common"; @@ -170,24 +172,31 @@ function LogModal({ modalProps, close }: { modalProps: ModalProps; close(): void - + + + + + ); diff --git a/src/api/Settings.ts b/src/api/Settings.ts index 70ba0bd4a..88337a917 100644 --- a/src/api/Settings.ts +++ b/src/api/Settings.ts @@ -129,7 +129,7 @@ export const SettingsStore = new SettingsStoreClass(settings, { if (path === "plugins" && key in plugins) return target[key] = { - enabled: IS_REPORTER ?? plugins[key].required ?? plugins[key].enabledByDefault ?? false + enabled: IS_REPORTER || plugins[key].required || plugins[key].enabledByDefault || false }; // Since the property is not set, check if this is a plugin's setting and if so, try to resolve diff --git a/src/api/SettingsStores.ts b/src/api/SettingsStores.ts deleted file mode 100644 index 18139e4e6..000000000 --- a/src/api/SettingsStores.ts +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Vencord, a modification for Discord's desktop app - * Copyright (c) 2023 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 { proxyLazy } from "@utils/lazy"; -import { Logger } from "@utils/Logger"; -import { findModuleId, proxyLazyWebpack, wreq } from "@webpack"; - -import { Settings } from "./Settings"; - -interface Setting { - /** - * Get the setting value - */ - getSetting(): T; - /** - * Update the setting value - * @param value The new value - */ - updateSetting(value: T | ((old: T) => T)): Promise; - /** - * React hook for automatically updating components when the setting is updated - */ - useSetting(): T; - settingsStoreApiGroup: string; - settingsStoreApiName: string; -} - -export const SettingsStores: Array> | undefined = proxyLazyWebpack(() => { - const modId = findModuleId('"textAndImages","renderSpoilers"') as any; - if (modId == null) return new Logger("SettingsStoreAPI").error("Didn't find stores module."); - - const mod = wreq(modId); - if (mod == null) return; - - return Object.values(mod).filter((s: any) => s?.settingsStoreApiGroup) as any; -}); - -/** - * Get the store for a setting - * @param group The setting group - * @param name The name of the setting - */ -export function getSettingStore(group: string, name: string): Setting | undefined { - if (!Settings.plugins.SettingsStoreAPI.enabled) throw new Error("Cannot use SettingsStoreAPI without setting as dependency."); - - return SettingsStores?.find(s => s?.settingsStoreApiGroup === group && s?.settingsStoreApiName === name); -} - -/** - * getSettingStore but lazy - */ -export function getSettingStoreLazy(group: string, name: string) { - return proxyLazy(() => getSettingStore(group, name)); -} diff --git a/src/api/UserSettings.ts b/src/api/UserSettings.ts new file mode 100644 index 000000000..4de92a81a --- /dev/null +++ b/src/api/UserSettings.ts @@ -0,0 +1,81 @@ +/* + * Vencord, a modification for Discord's desktop app + * Copyright (c) 2023 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 { proxyLazy } from "@utils/lazy"; +import { Logger } from "@utils/Logger"; +import { findModuleId, proxyLazyWebpack, wreq } from "@webpack"; + +interface UserSettingDefinition { + /** + * Get the setting value + */ + getSetting(): T; + /** + * Update the setting value + * @param value The new value + */ + updateSetting(value: T): Promise; + /** + * Update the setting value + * @param value A callback that accepts the old value as the first argument, and returns the new value + */ + updateSetting(value: (old: T) => T): Promise; + /** + * Stateful React hook for this setting value + */ + useSetting(): T; + userSettingsAPIGroup: string; + userSettingsAPIName: string; +} + +export const UserSettings: Record> | undefined = proxyLazyWebpack(() => { + const modId = findModuleId('"textAndImages","renderSpoilers"'); + if (modId == null) return new Logger("UserSettingsAPI ").error("Didn't find settings module."); + + return wreq(modId as any); +}); + +/** + * Get the setting with the given setting group and name. + * + * @param group The setting group + * @param name The name of the setting + */ +export function getUserSetting(group: string, name: string): UserSettingDefinition | undefined { + if (!Vencord.Plugins.isPluginEnabled("UserSettingsAPI")) throw new Error("Cannot use UserSettingsAPI without setting as dependency."); + + for (const key in UserSettings) { + const userSetting = UserSettings[key]; + + if (userSetting.userSettingsAPIGroup === group && userSetting.userSettingsAPIName === name) { + return userSetting; + } + } +} + +/** + * {@link getUserSettingDefinition}, lazy. + * + * Get the setting with the given setting group and name. + * + * @param group The setting group + * @param name The name of the setting + */ +export function getUserSettingLazy(group: string, name: string) { + return proxyLazy(() => getUserSetting(group, name)); +} diff --git a/src/api/index.ts b/src/api/index.ts index 737e06d60..d4d7b4614 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -31,8 +31,8 @@ import * as $Notices from "./Notices"; import * as $Notifications from "./Notifications"; import * as $ServerList from "./ServerList"; import * as $Settings from "./Settings"; -import * as $SettingsStores from "./SettingsStores"; import * as $Styles from "./Styles"; +import * as $UserSettings from "./UserSettings"; /** * An API allowing you to listen to Message Clicks or run your own logic @@ -118,4 +118,7 @@ export const ChatButtons = $ChatButtons; */ export const MessageUpdater = $MessageUpdater; -export const SettingsStores = $SettingsStores; +/** + * An API allowing you to get an user setting + */ +export const UserSettings = $UserSettings; diff --git a/src/components/ExpandableHeader.tsx b/src/components/ExpandableHeader.tsx index 84b065862..473dffaa0 100644 --- a/src/components/ExpandableHeader.tsx +++ b/src/components/ExpandableHeader.tsx @@ -31,10 +31,20 @@ export interface ExpandableHeaderProps { headerText: string; children: React.ReactNode; buttons?: React.ReactNode[]; + forceOpen?: boolean; } -export function ExpandableHeader({ children, onMoreClick, buttons, moreTooltipText, defaultState = false, onDropDownClick, headerText }: ExpandableHeaderProps) { - const [showContent, setShowContent] = useState(defaultState); +export function ExpandableHeader({ + children, + onMoreClick, + buttons, + moreTooltipText, + onDropDownClick, + headerText, + defaultState = false, + forceOpen = false, +}: ExpandableHeaderProps) { + const [showContent, setShowContent] = useState(defaultState || forceOpen); return ( <> @@ -90,6 +100,7 @@ export function ExpandableHeader({ children, onMoreClick, buttons, moreTooltipTe setShowContent(v => !v); onDropDownClick?.(showContent); }} + disabled={forceOpen} > + {props.children} + + ); +} diff --git a/src/components/Icons.tsx b/src/components/Icons.tsx index 2eb83d4ef..d82ce0b00 100644 --- a/src/components/Icons.tsx +++ b/src/components/Icons.tsx @@ -18,19 +18,17 @@ import "./iconStyles.css"; +import { getTheme, Theme } from "@utils/discord"; import { classes } from "@utils/misc"; import { i18n } from "@webpack/common"; -import type { PropsWithChildren, SVGProps } from "react"; +import type { PropsWithChildren } from "react"; interface BaseIconProps extends IconProps { viewBox: string; } -interface IconProps extends SVGProps { - className?: string; - height?: string | number; - width?: string | number; -} +type IconProps = JSX.IntrinsicElements["svg"]; +type ImageProps = JSX.IntrinsicElements["img"]; function Icon({ height = 24, width = 24, className, children, viewBox, ...svgProps }: PropsWithChildren) { return ( @@ -290,3 +288,127 @@ export function NoEntrySignIcon(props: IconProps) { ); } + +export function SafetyIcon(props: IconProps) { + return ( + + + + + ); +} + +export function NotesIcon(props: IconProps) { + return ( + + + + + ); +} + +export function FolderIcon(props: IconProps) { + return ( + + + + ); +} + +export function LogIcon(props: IconProps) { + return ( + + + + ); +} + +export function RestartIcon(props: IconProps) { + return ( + + + + ); +} + +export function PaintbrushIcon(props: IconProps) { + return ( + + + + ); +} + +const WebsiteIconDark = "/assets/e1e96d89e192de1997f73730db26e94f.svg"; +const WebsiteIconLight = "/assets/730f58bcfd5a57a5e22460c445a0c6cf.svg"; +const GithubIconLight = "/assets/3ff98ad75ac94fa883af5ed62d17c459.svg"; +const GithubIconDark = "/assets/6a853b4c87fce386cbfef4a2efbacb09.svg"; + +export function GithubIcon(props: ImageProps) { + const src = getTheme() === Theme.Light + ? GithubIconLight + : GithubIconDark; + + return ; +} + +export function WebsiteIcon(props: ImageProps) { + const src = getTheme() === Theme.Light + ? WebsiteIconLight + : WebsiteIconDark; + + return ; +} diff --git a/src/components/PluginSettings/ContributorModal.tsx b/src/components/PluginSettings/ContributorModal.tsx index 99a8da168..c3c36f1e6 100644 --- a/src/components/PluginSettings/ContributorModal.tsx +++ b/src/components/PluginSettings/ContributorModal.tsx @@ -11,20 +11,16 @@ import { classNameFactory } from "@api/Styles"; import ErrorBoundary from "@components/ErrorBoundary"; import { Link } from "@components/Link"; import { DevsById } from "@utils/constants"; -import { fetchUserProfile, getTheme, Theme } from "@utils/discord"; -import { pluralise } from "@utils/misc"; +import { fetchUserProfile } from "@utils/discord"; +import { classes, pluralise } from "@utils/misc"; import { ModalContent, ModalRoot, openModal } from "@utils/modal"; -import { Forms, MaskedLink, showToast, Tooltip, useEffect, useMemo, UserProfileStore, useStateFromStores } from "@webpack/common"; +import { Forms, showToast, useEffect, useMemo, UserProfileStore, useStateFromStores } from "@webpack/common"; import { User } from "discord-types/general"; import Plugins from "~plugins"; import { PluginCard } from "."; - -const WebsiteIconDark = "/assets/e1e96d89e192de1997f73730db26e94f.svg"; -const WebsiteIconLight = "/assets/730f58bcfd5a57a5e22460c445a0c6cf.svg"; -const GithubIconLight = "/assets/3ff98ad75ac94fa883af5ed62d17c459.svg"; -const GithubIconDark = "/assets/6a853b4c87fce386cbfef4a2efbacb09.svg"; +import { GithubButton, WebsiteButton } from "./LinkIconButton"; const cl = classNameFactory("vc-author-modal-"); @@ -40,16 +36,6 @@ export function openContributorModal(user: User) { ); } -function GithubIcon() { - const src = getTheme() === Theme.Light ? GithubIconLight : GithubIconDark; - return GitHub; -} - -function WebsiteIcon() { - const src = getTheme() === Theme.Light ? WebsiteIconLight : WebsiteIconDark; - return Website; -} - function ContributorModal({ user }: { user: User; }) { useSettings(); @@ -86,24 +72,18 @@ function ContributorModal({ user }: { user: User; }) { /> {user.username} -
+
{website && ( - - {props => ( - - - - )} - + )} {githubName && ( - - {props => ( - - - - )} - + )}
diff --git a/src/components/PluginSettings/LinkIconButton.css b/src/components/PluginSettings/LinkIconButton.css new file mode 100644 index 000000000..1055d6c70 --- /dev/null +++ b/src/components/PluginSettings/LinkIconButton.css @@ -0,0 +1,12 @@ +.vc-settings-modal-link-icon { + height: 32px; + width: 32px; + border-radius: 50%; + border: 4px solid var(--background-tertiary); + box-sizing: border-box +} + +.vc-settings-modal-links { + display: flex; + gap: 0.2em; +} diff --git a/src/components/PluginSettings/LinkIconButton.tsx b/src/components/PluginSettings/LinkIconButton.tsx new file mode 100644 index 000000000..dd840f52e --- /dev/null +++ b/src/components/PluginSettings/LinkIconButton.tsx @@ -0,0 +1,39 @@ +/* + * Vencord, a Discord client mod + * Copyright (c) 2024 Vendicated and contributors + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +import "./LinkIconButton.css"; + +import { MaskedLink, Tooltip } from "@webpack/common"; + +import { GithubIcon, WebsiteIcon } from ".."; + +export function GithubLinkIcon() { + return ; +} + +export function WebsiteLinkIcon() { + return ; +} + +interface Props { + text: string; + href: string; +} + +function LinkIcon({ text, href, Icon }: Props & { Icon: React.ComponentType; }) { + return ( + + {props => ( + + + + )} + + ); +} + +export const WebsiteButton = (props: Props) => ; +export const GithubButton = (props: Props) => ; diff --git a/src/components/PluginSettings/PluginModal.css b/src/components/PluginSettings/PluginModal.css new file mode 100644 index 000000000..1f4b9aaad --- /dev/null +++ b/src/components/PluginSettings/PluginModal.css @@ -0,0 +1,7 @@ +.vc-plugin-modal-info { + align-items: center; +} + +.vc-plugin-modal-description { + flex-grow: 1; +} diff --git a/src/components/PluginSettings/PluginModal.tsx b/src/components/PluginSettings/PluginModal.tsx index 34de43c2d..8b14283b8 100644 --- a/src/components/PluginSettings/PluginModal.tsx +++ b/src/components/PluginSettings/PluginModal.tsx @@ -16,20 +16,26 @@ * along with this program. If not, see . */ +import "./PluginModal.css"; + import { generateId } from "@api/Commands"; import { useSettings } from "@api/Settings"; +import { classNameFactory } from "@api/Styles"; import ErrorBoundary from "@components/ErrorBoundary"; import { Flex } from "@components/Flex"; +import { gitRemote } from "@shared/vencordUserAgent"; import { proxyLazy } from "@utils/lazy"; import { Margins } from "@utils/margins"; import { classes, isObjectEmpty } from "@utils/misc"; -import { ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, ModalSize } from "@utils/modal"; +import { ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, ModalSize, openModal } from "@utils/modal"; import { OptionType, Plugin } from "@utils/types"; import { findByPropsLazy, findComponentByCodeLazy } from "@webpack"; import { Button, Clickable, FluxDispatcher, Forms, React, Text, Tooltip, UserStore, UserUtils } from "@webpack/common"; import { User } from "discord-types/general"; import { Constructor } from "type-fest"; +import { PluginMeta } from "~plugins"; + import { ISettingElementProps, SettingBooleanComponent, @@ -40,6 +46,9 @@ import { SettingTextComponent } from "./components"; import { openContributorModal } from "./ContributorModal"; +import { GithubButton, WebsiteButton } from "./LinkIconButton"; + +const cl = classNameFactory("vc-plugin-modal-"); const UserSummaryItem = findComponentByCodeLazy("defaultRenderUser", "showDefaultAvatarsForNullUsers"); const AvatarStyles = findByPropsLazy("moreUsers", "emptyUser", "avatarContainer", "clickableAvatar"); @@ -180,16 +189,54 @@ export default function PluginModal({ plugin, onRestartNeeded, onClose, transiti ); } + /* + function switchToPopout() { + onClose(); + + const PopoutKey = `DISCORD_VENCORD_PLUGIN_SETTINGS_MODAL_${plugin.name}`; + PopoutActions.open( + PopoutKey, + () => PopoutActions.close(PopoutKey)} + /> + ); + } + */ + + const pluginMeta = PluginMeta[plugin.name]; + return ( {plugin.name} + + {/* + + */} - About {plugin.name} - {plugin.description} + + {plugin.description} + {!pluginMeta.userPlugin && ( +
+ + +
+ )} +
Authors
); } + +export function openPluginModal(plugin: Plugin, onRestartNeeded?: (pluginName: string) => void) { + openModal(modalProps => ( + onRestartNeeded?.(plugin.name)} + /> + )); +} diff --git a/src/components/PluginSettings/contributorModal.css b/src/components/PluginSettings/contributorModal.css index ad2f1330c..3a698e2c4 100644 --- a/src/components/PluginSettings/contributorModal.css +++ b/src/components/PluginSettings/contributorModal.css @@ -42,16 +42,6 @@ .vc-author-modal-links { margin-left: auto; - display: flex; - gap: 0.2em; -} - -.vc-author-modal-links img { - height: 32px; - width: 32px; - border-radius: 50%; - border: 4px solid var(--background-tertiary); - box-sizing: border-box } .vc-author-modal-plugins { diff --git a/src/components/PluginSettings/index.tsx b/src/components/PluginSettings/index.tsx index 978d2e85a..38ddc4a90 100644 --- a/src/components/PluginSettings/index.tsx +++ b/src/components/PluginSettings/index.tsx @@ -23,7 +23,7 @@ import { showNotice } from "@api/Notices"; import { Settings, useSettings } from "@api/Settings"; import { classNameFactory } from "@api/Styles"; import { CogWheel, InfoIcon } from "@components/Icons"; -import PluginModal from "@components/PluginSettings/PluginModal"; +import { openPluginModal } from "@components/PluginSettings/PluginModal"; import { AddonCard } from "@components/VencordSettings/AddonCard"; import { SettingsTab } from "@components/VencordSettings/shared"; import { ChangeList } from "@utils/ChangeList"; @@ -31,13 +31,12 @@ import { proxyLazy } from "@utils/lazy"; import { Logger } from "@utils/Logger"; import { Margins } from "@utils/margins"; import { classes, isObjectEmpty } from "@utils/misc"; -import { openModalLazy } from "@utils/modal"; import { useAwaiter } from "@utils/react"; import { Plugin } from "@utils/types"; import { findByPropsLazy } from "@webpack"; -import { Alerts, Button, Card, Forms, lodash, Parser, React, Select, Text, TextInput, Toasts, Tooltip } from "@webpack/common"; +import { Alerts, Button, Card, Forms, lodash, Parser, React, Select, Text, TextInput, Toasts, Tooltip, useMemo } from "@webpack/common"; -import Plugins from "~plugins"; +import Plugins, { ExcludedPlugins } from "~plugins"; // Avoid circular dependency const { startDependenciesRecursive, startPlugin, stopPlugin } = proxyLazy(() => require("../../plugins")); @@ -45,7 +44,7 @@ const { startDependenciesRecursive, startPlugin, stopPlugin } = proxyLazy(() => const cl = classNameFactory("vc-plugins-"); const logger = new Logger("PluginSettings", "#a6d189"); -const InputStyles = findByPropsLazy("inputDefault", "inputWrapper"); +const InputStyles = findByPropsLazy("inputWrapper", "inputDefault", "error"); const ButtonClasses = findByPropsLazy("button", "disabled", "enabled"); @@ -96,14 +95,6 @@ export function PluginCard({ plugin, disabled, onRestartNeeded, onMouseEnter, on const isEnabled = () => settings.enabled ?? false; - function openModal() { - openModalLazy(async () => { - return modalProps => { - return onRestartNeeded(plugin.name)} />; - }; - }); - } - function toggleEnabled() { const wasEnabled = isEnabled(); @@ -160,7 +151,11 @@ export function PluginCard({ plugin, disabled, onRestartNeeded, onMouseEnter, on onMouseEnter={onMouseEnter} onMouseLeave={onMouseLeave} infoButton={ -