diff --git a/.eslintrc.json b/.eslintrc.json index aaaaaeb69..e45e446fc 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -62,7 +62,7 @@ "indent": ["error", 4, { "SwitchCase": 1 }], "arrow-parens": ["error", "as-needed"], "eol-last": ["error", "always"], - "func-call-spacing": ["error", "never"], + "@typescript-eslint/func-call-spacing": ["error", "never"], "no-multi-spaces": "error", "no-trailing-spaces": "error", "no-whitespace-before-property": "error", diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 83fc57c55..46d564184 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -26,5 +26,8 @@ jobs: - name: Lint & Test if desktop version compiles run: pnpm test - - name: Lint & Test if web version compiles - run: pnpm testWeb + - name: Test if web version compiles + run: pnpm buildWeb + + - name: Test if plugin structure is valid + run: pnpm generatePluginJson diff --git a/README.md b/README.md index fa754d617..e1a70c6be 100644 --- a/README.md +++ b/README.md @@ -2,21 +2,29 @@ The cutest Discord client mod + +![](https://user-images.githubusercontent.com/45497981/235015332-0453d3eb-1da6-4601-963e-ef5e454123a1.png) +*A screenshot of Vencord featuring the [ClearVision-v6 theme](https://github.com/ClearVision/ClearVision-v6) (Vencord does not come with it pre-installed, it is only an example)* + ## Features - Super easy to install (Download Installer, open, click install button, done) -- 100+ plugins built in: [See a list](https://gist.github.com/Vendicated/8696cde7b92548064a3ae92ead84d033) - - Some highlights: SpotifyControls, GameActivityToggle, Experiments, NoTrack, MessageLogger, QuickReply, Free Emotes/Stickers, CustomCommands, ShowHiddenChannels, PronounDB +- 100+ plugins built in: [See a list](https://vencord.dev/plugins) + - Some highlights: SpotifyControls, MessageLogger, Experiments, GameActivityToggle, Translate, NoTrack, QuickReply, Free Emotes/Stickers, PermissionsViewer, CustomCommands, ShowHiddenChannels, PronounDB - Fairly lightweight despite the many inbuilt plugins - Excellent Browser Support: Run Vencord in your Browser via extension or UserScript - Works on any Discord branch: Stable, Canary or PTB all work (though for the best experience I recommend stable!) - Custom CSS and Themes: Inbuilt css editor with support to import any css files (including BetterDiscord themes) - Privacy friendly, blocks Discord analytics & crash reporting out of the box and has no telemetry - Maintained very actively, broken plugins are usually fixed within 12 hours +- Settings sync: Keep your plugins and their settings synchronised between devices / apps (optional) + ## Installing / Uninstalling -[![Download and run the Installer ](https://img.shields.io/github/v/release/Vencord/Installer?label=Download%20Vencord%20Installer&style=for-the-badge)](https://github.com/Vencord/Installer#usage) +Click the below button to install Vencord to the Discord Desktop app + +[![Download and run the Installer](https://img.shields.io/github/v/release/Vencord/Installer?label=Download%20Vencord%20Installer&style=for-the-badge)](https://github.com/Vencord/Installer#vencord-installer) ## Installing on Browser @@ -24,25 +32,39 @@ The cutest Discord client mod Or use the [UserScript](https://raw.githubusercontent.com/Vencord/builds/main/Vencord.user.js) - Please note that the CSS Editor, Themes loaded from remote sources and co. will not work in the UserScript. Use the extension if you need any of those -## Building from Source +
+Alternative Downloads -See the docs folder +## Vencord Desktop -## Contributing +> **Warning** +> This is an alternative app. It currently doesn't support screensharing or keybinds. If you just want to install to the normal Discord Desktop app, scroll up -See [CONTRIBUTING.md](CONTRIBUTING.md) and [Megu's Plugin Guide!](docs/2_PLUGINS.md) -[contribute]: CONTRIBUTING.md +As an alternative to the Discord Desktop app, Vencord also has its own standalone Desktop app that is snappier and lighter than Discord's official Desktop app. It is currently in beta and we have yet to implement some features like screensharing, but you can try the beta nonetheless -[contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] +[![Download Vencord Desktop](https://img.shields.io/github/v/release/Vencord/Desktop?label=Download%20Vencord%20Desktop&style=for-the-badge)](https://github.com/Vencord/Desktop#vencord-desktop) -## Join +
-[join]: https://discord.gg/D9uwnFnqmd +## Join our Support/Community Server -[join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] +[![Vencord Discord Server](https://invidget.switchblade.xyz/D9uwnFnqmd?theme=dark)](https://discord.gg/D9uwnFnqmd) ## Disclaimer Discord is trademark of Discord Inc. and solely mentioned for the sake of descriptivity. Mention of it does not imply any affiliation with or endorsement by Discord Inc. + +
+Using Vencord violates Discord's terms of service + +Client modifications are against Discord’s Terms of Service. + +However, Discord is pretty indifferent about them and there are no known cases of users getting banned for using client mods! So you should generally be fine as long as you don’t use any plugins that implement abusive behaviour. But no worries, all inbuilt plugins are safe to use! + +Regardless, if your account is very important to you and it getting disabled would be a disaster for you, you should probably not use any client mods (not exclusive to Vencord), just to be safe + +Additionally, make sure not to post screenshots with Vencord in a server where you might get banned for it + +
diff --git a/browser/GMPolyfill.js b/browser/GMPolyfill.js index beee9156a..f8801551e 100644 --- a/browser/GMPolyfill.js +++ b/browser/GMPolyfill.js @@ -16,20 +16,6 @@ * along with this program. If not, see . */ -function fetchOptions(url) { - return new Promise((resolve, reject) => { - const opt = { - method: "OPTIONS", - url: url, - }; - opt.onload = resp => resolve(resp.responseHeaders); - opt.ontimeout = () => reject("fetch timeout"); - opt.onerror = () => reject("fetch error"); - opt.onabort = () => reject("fetch abort"); - GM_xmlhttpRequest(opt); - }); -} - function parseHeaders(headers) { if (!headers) return {}; @@ -52,19 +38,6 @@ function parseHeaders(headers) { return result; } -// returns true if CORS permits request -async function checkCors(url, method) { - const headers = parseHeaders(await fetchOptions(url)); - - const origin = headers["access-control-allow-origin"]; - if (origin !== "*" && origin !== window.location.origin) return false; - - const methods = headers["access-control-allow-methods"]?.toLowerCase().split(/,\s/g); - if (methods && !methods.includes(method.toLowerCase())) return false; - - return true; -} - function blobTo(to, blob) { if (to === "arrayBuffer" && blob.arrayBuffer) return blob.arrayBuffer(); return new Promise((resolve, reject) => { @@ -78,31 +51,25 @@ function blobTo(to, blob) { function GM_fetch(url, opt) { return new Promise((resolve, reject) => { - checkCors(url, opt?.method || "GET") - .then(can => { - if (can) { - // https://www.tampermonkey.net/documentation.php?ext=dhdg#GM_xmlhttpRequest - const options = opt || {}; - options.url = url; - options.data = options.body; - options.responseType = "blob"; - options.onload = resp => { - var blob = resp.response; - resp.blob = () => Promise.resolve(blob); - resp.arrayBuffer = () => blobTo("arrayBuffer", blob); - resp.text = () => blobTo("text", blob); - resp.json = async () => JSON.parse(await blobTo("text", blob)); - resp.headers = new Headers(parseHeaders(resp.responseHeaders)); - resolve(resp); - }; - options.ontimeout = () => reject("fetch timeout"); - options.onerror = () => reject("fetch error"); - options.onabort = () => reject("fetch abort"); - GM_xmlhttpRequest(options); - } else { - reject("CORS issue"); - } - }); + // https://www.tampermonkey.net/documentation.php?ext=dhdg#GM_xmlhttpRequest + const options = opt || {}; + options.url = url; + options.data = options.body; + options.responseType = "blob"; + options.onload = resp => { + var blob = resp.response; + resp.blob = () => Promise.resolve(blob); + resp.arrayBuffer = () => blobTo("arrayBuffer", blob); + resp.text = () => blobTo("text", blob); + resp.json = async () => JSON.parse(await blobTo("text", blob)); + resp.headers = new Headers(parseHeaders(resp.responseHeaders)); + resp.ok = resp.status >= 200 && resp.status < 300; + resolve(resp); + }; + options.ontimeout = () => reject("fetch timeout"); + options.onerror = () => reject("fetch error"); + options.onabort = () => reject("fetch abort"); + GM_xmlhttpRequest(options); }); } export const fetch = GM_fetch; diff --git a/browser/VencordNativeStub.ts b/browser/VencordNativeStub.ts index ef3923ba7..515ccc3fc 100644 --- a/browser/VencordNativeStub.ts +++ b/browser/VencordNativeStub.ts @@ -16,51 +16,70 @@ * along with this program. If not, see . */ +/// +/// + +import monacoHtml from "~fileContent/../src/components/monacoWin.html"; import * as DataStore from "../src/api/DataStore"; -import IpcEvents from "../src/utils/IpcEvents"; +import { debounce } from "../src/utils"; +import { getTheme, Theme } from "../src/utils/discord"; // Discord deletes this so need to store in variable const { localStorage } = window; // listeners for ipc.on -const listeners = {} as Record>; +const cssListeners = new Set<(css: string) => void>(); +const NOOP = () => { }; +const NOOP_ASYNC = async () => { }; -const handlers = { - [IpcEvents.GET_REPO]: () => "https://github.com/Vendicated/Vencord", // shrug - [IpcEvents.GET_SETTINGS_DIR]: () => "LocalStorage", - - [IpcEvents.GET_QUICK_CSS]: () => DataStore.get("VencordQuickCss").then(s => s ?? ""), - [IpcEvents.SET_QUICK_CSS]: (css: string) => { - DataStore.set("VencordQuickCss", css); - listeners[IpcEvents.QUICK_CSS_UPDATE]?.forEach(l => l(null, css)); - }, - - [IpcEvents.GET_SETTINGS]: () => localStorage.getItem("VencordSettings") || "{}", - [IpcEvents.SET_SETTINGS]: (s: string) => localStorage.setItem("VencordSettings", s), - - [IpcEvents.GET_UPDATES]: () => ({ ok: true, value: [] }), - - [IpcEvents.OPEN_EXTERNAL]: (url: string) => open(url, "_blank"), -}; - -function onEvent(event: string, ...args: any[]) { - const handler = handlers[event]; - if (!handler) throw new Error(`Event ${event} not implemented.`); - return handler(...args); -} +const setCssDebounced = debounce((css: string) => VencordNative.quickCss.set(css)); // probably should make this less cursed at some point window.VencordNative = { - getVersions: () => ({}), - ipc: { - send: (event: string, ...args: any[]) => void onEvent(event, ...args), - sendSync: onEvent, - on(event: string, listener: () => {}) { - (listeners[event] ??= new Set()).add(listener); - }, - off(event: string, listener: () => {}) { - return listeners[event]?.delete(listener); - }, - invoke: (event: string, ...args: any[]) => Promise.resolve(onEvent(event, ...args)) + native: { + getVersions: () => ({}), + openExternal: async (url) => void open(url, "_blank") }, + + updater: { + getRepo: async () => ({ ok: true, value: "https://github.com/Vendicated/Vencord" }), + getUpdates: async () => ({ ok: true, value: [] }), + update: async () => ({ ok: true, value: false }), + rebuild: async () => ({ ok: true, value: true }), + }, + + quickCss: { + get: () => DataStore.get("VencordQuickCss").then(s => s ?? ""), + set: async (css: string) => { + await DataStore.set("VencordQuickCss", css); + cssListeners.forEach(l => l(css)); + }, + addChangeListener(cb) { + cssListeners.add(cb); + }, + openFile: NOOP_ASYNC, + async openEditor() { + const features = `popup,width=${Math.min(window.innerWidth, 1000)},height=${Math.min(window.innerHeight, 1000)}`; + const win = open("about:blank", "VencordQuickCss", features); + if (!win) { + alert("Failed to open QuickCSS popup. Make sure to allow popups!"); + return; + } + + win.setCss = setCssDebounced; + win.getCurrentCss = () => VencordNative.quickCss.get(); + win.getTheme = () => + getTheme() === Theme.Light + ? "vs-light" + : "vs-dark"; + + win.document.write(monacoHtml); + }, + }, + + settings: { + get: () => localStorage.getItem("VencordSettings") || "{}", + set: async (s: string) => localStorage.setItem("VencordSettings", s), + getSettingsDir: async () => "LocalStorage" + } }; diff --git a/browser/background.js b/browser/background.js index 7fc4a8224..1f2d5ec17 100644 --- a/browser/background.js +++ b/browser/background.js @@ -16,7 +16,7 @@ chrome.webRequest.onHeadersReceived.addListener( // In main frame requests, the CSP needs to be removed to enable fetching of custom css // as desired by the user removeFirst(responseHeaders, h => h.name.toLowerCase() === "content-security-policy"); - } else if (type === "stylesheet" && url.startsWith("https://raw.githubusercontent.com")) { + } else if (type === "stylesheet" && url.startsWith("https://raw.githubusercontent.com/")) { // Most users will load css from GitHub, but GitHub doesn't set the correct content type, // so we fix it here removeFirst(responseHeaders, h => h.name.toLowerCase() === "content-type"); diff --git a/docs/2_PLUGINS.md b/docs/2_PLUGINS.md index 7b5e3e181..705ea89d6 100644 --- a/docs/2_PLUGINS.md +++ b/docs/2_PLUGINS.md @@ -26,10 +26,6 @@ export default definePlugin({ name: "Your Name", }, ], - // Delete `patches` if you are not using code patches, as it will make - // your plugin require restarts, and your stop() method will not be - // invoked at all. The presence of the key in the object alone is - // enough to trigger this behavior, even if the value is an empty array. patches: [], // Delete these two below if you are only using code patches start() {}, diff --git a/package.json b/package.json index 59ae57294..2f9aacc47 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "vencord", "private": "true", - "version": "1.1.9", + "version": "1.2.4", "description": "The cutest Discord client mod", "homepage": "https://github.com/Vendicated/Vencord#readme", "bugs": { @@ -32,20 +32,20 @@ }, "dependencies": { "@vap/core": "0.0.12", - "@vap/shiki": "0.10.3", + "@vap/shiki": "0.10.5", "fflate": "^0.7.4", "nanoid": "^4.0.2", "virtual-merge": "^1.0.1" }, "devDependencies": { - "@types/diff": "^5.0.2", - "@types/lodash": "^4.14.191", - "@types/node": "^18.11.18", - "@types/react": "^18.0.27", - "@types/react-dom": "^18.0.10", + "@types/diff": "^5.0.3", + "@types/lodash": "^4.14.194", + "@types/node": "^18.16.3", + "@types/react": "^18.2.0", + "@types/react-dom": "^18.2.1", "@types/yazl": "^2.4.2", - "@typescript-eslint/eslint-plugin": "^5.49.0", - "@typescript-eslint/parser": "^5.49.0", + "@typescript-eslint/eslint-plugin": "^5.59.1", + "@typescript-eslint/parser": "^5.59.1", "diff": "^5.1.0", "discord-types": "^1.3.26", "esbuild": "^0.15.18", @@ -53,17 +53,17 @@ "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-simple-import-sort": "^10.0.0", "eslint-plugin-unused-imports": "^2.0.0", "highlight.js": "10.6.0", "moment": "^2.29.4", - "puppeteer-core": "^19.6.0", + "puppeteer-core": "^19.11.1", "standalone-electron-types": "^1.0.0", - "stylelint": "^14.16.1", - "stylelint-config-standard": "^29.0.0", - "tsx": "^3.12.6", - "type-fest": "^3.5.3", - "typescript": "^4.9.4" + "stylelint": "^15.6.0", + "stylelint-config-standard": "^33.0.0", + "tsx": "^3.12.7", + "type-fest": "^3.9.0", + "typescript": "^5.0.4" }, "packageManager": "pnpm@8.1.1", "pnpm": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 73d29a53b..c43737109 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -13,8 +13,8 @@ dependencies: specifier: 0.0.12 version: 0.0.12 '@vap/shiki': - specifier: 0.10.3 - version: 0.10.3 + specifier: 0.10.5 + version: 0.10.5 fflate: specifier: ^0.7.4 version: 0.7.4 @@ -27,29 +27,29 @@ dependencies: devDependencies: '@types/diff': - specifier: ^5.0.2 - version: 5.0.2 + specifier: ^5.0.3 + version: 5.0.3 '@types/lodash': - specifier: ^4.14.191 - version: 4.14.191 + specifier: ^4.14.194 + version: 4.14.194 '@types/node': - specifier: ^18.11.18 - version: 18.11.18 + specifier: ^18.16.3 + version: 18.16.3 '@types/react': - specifier: ^18.0.27 - version: 18.0.27 + specifier: ^18.2.0 + version: 18.2.0 '@types/react-dom': - specifier: ^18.0.10 - version: 18.0.10 + specifier: ^18.2.1 + version: 18.2.1 '@types/yazl': specifier: ^2.4.2 version: 2.4.2 '@typescript-eslint/eslint-plugin': - specifier: ^5.49.0 - version: 5.49.0(@typescript-eslint/parser@5.49.0)(eslint@8.28.0)(typescript@4.9.4) + specifier: ^5.59.1 + version: 5.59.1(@typescript-eslint/parser@5.59.1)(eslint@8.28.0)(typescript@5.0.4) '@typescript-eslint/parser': - specifier: ^5.49.0 - version: 5.49.0(eslint@8.28.0)(typescript@4.9.4) + specifier: ^5.59.1 + version: 5.59.1(eslint@8.28.0)(typescript@5.0.4) diff: specifier: ^5.1.0 version: 5.1.0 @@ -72,11 +72,11 @@ devDependencies: specifier: ^1.0.0 version: 1.0.0(patch_hash=m6sma4g6bh67km3q6igf6uxaja)(eslint@8.28.0) eslint-plugin-simple-import-sort: - specifier: ^8.0.0 - version: 8.0.0(eslint@8.28.0) + specifier: ^10.0.0 + version: 10.0.0(eslint@8.28.0) eslint-plugin-unused-imports: specifier: ^2.0.0 - version: 2.0.0(@typescript-eslint/eslint-plugin@5.49.0)(eslint@8.28.0) + version: 2.0.0(@typescript-eslint/eslint-plugin@5.59.1)(eslint@8.28.0) highlight.js: specifier: 10.6.0 version: 10.6.0 @@ -84,31 +84,31 @@ devDependencies: specifier: ^2.29.4 version: 2.29.4 puppeteer-core: - specifier: ^19.6.0 - version: 19.6.0 + specifier: ^19.11.1 + version: 19.11.1(typescript@5.0.4) standalone-electron-types: specifier: ^1.0.0 version: 1.0.0 stylelint: - specifier: ^14.16.1 - version: 14.16.1 + specifier: ^15.6.0 + version: 15.6.0 stylelint-config-standard: - specifier: ^29.0.0 - version: 29.0.0(stylelint@14.16.1) + specifier: ^33.0.0 + version: 33.0.0(stylelint@15.6.0) tsx: - specifier: ^3.12.6 - version: 3.12.6 + specifier: ^3.12.7 + version: 3.12.7 type-fest: - specifier: ^3.5.3 - version: 3.5.3 + specifier: ^3.9.0 + version: 3.9.0 typescript: - specifier: ^4.9.4 - version: 4.9.4 + specifier: ^5.0.4 + version: 5.0.4 packages: - /@babel/code-frame@7.18.6: - resolution: {integrity: sha512-TDCmlK5eOvH+eH7cdAFlNXeVJqWIQ7gW9tY1GJIpUtFb6CmjVyq2VM3u71bOyR8CRihcCgMUYoDNyLXao3+70Q==} + /@babel/code-frame@7.21.4: + resolution: {integrity: sha512-LYvhNKfwWSPpocw8GI7gpK2nq3HSDuEPC/uSYaALSJu9xjsalaaYFOq0Pwt5KmVqwEbZlDu81aLXwBOmD/Fv9g==} engines: {node: '>=6.9.0'} dependencies: '@babel/highlight': 7.18.6 @@ -128,28 +128,51 @@ packages: js-tokens: 4.0.0 dev: true - /@csstools/selector-specificity@2.1.1(postcss-selector-parser@6.0.11)(postcss@8.4.21): - resolution: {integrity: sha512-jwx+WCqszn53YHOfvFMJJRd/B2GqkCBt+1MJSG6o5/s8+ytHMvDZXsJgUEWLk12UnLd7HYKac4BYU5i/Ron1Cw==} + /@csstools/css-parser-algorithms@2.1.1(@csstools/css-tokenizer@2.1.1): + resolution: {integrity: sha512-viRnRh02AgO4mwIQb2xQNJju0i+Fh9roNgmbR5xEuG7J3TGgxjnE95HnBLgsFJOJOksvcfxOUCgODcft6Y07cA==} + engines: {node: ^14 || ^16 || >=18} + peerDependencies: + '@csstools/css-tokenizer': ^2.1.1 + dependencies: + '@csstools/css-tokenizer': 2.1.1 + dev: true + + /@csstools/css-tokenizer@2.1.1: + resolution: {integrity: sha512-GbrTj2Z8MCTUv+52GE0RbFGM527xuXZ0Xa5g0Z+YN573uveS4G0qi6WNOMyz3yrFM/jaILTTwJ0+umx81EzqfA==} + engines: {node: ^14 || ^16 || >=18} + dev: true + + /@csstools/media-query-list-parser@2.0.4(@csstools/css-parser-algorithms@2.1.1)(@csstools/css-tokenizer@2.1.1): + resolution: {integrity: sha512-GyYot6jHgcSDZZ+tLSnrzkR7aJhF2ZW6d+CXH66mjy5WpAQhZD4HDke2OQ36SivGRWlZJpAz7TzbW6OKlEpxAA==} + engines: {node: ^14 || ^16 || >=18} + peerDependencies: + '@csstools/css-parser-algorithms': ^2.1.1 + '@csstools/css-tokenizer': ^2.1.1 + dependencies: + '@csstools/css-parser-algorithms': 2.1.1(@csstools/css-tokenizer@2.1.1) + '@csstools/css-tokenizer': 2.1.1 + dev: true + + /@csstools/selector-specificity@2.2.0(postcss-selector-parser@6.0.12): + resolution: {integrity: sha512-+OJ9konv95ClSTOJCmMZqpd5+YGsB2S+x6w3E1oaM8UuR5j8nTNHYSz8c9BEPGDOCMQYIEEGlVPj/VY64iTbGw==} engines: {node: ^14 || ^16 || >=18} peerDependencies: - postcss: ^8.4 postcss-selector-parser: ^6.0.10 dependencies: - postcss: 8.4.21 - postcss-selector-parser: 6.0.11 + postcss-selector-parser: 6.0.12 dev: true /@esbuild-kit/cjs-loader@2.4.2: resolution: {integrity: sha512-BDXFbYOJzT/NBEtp71cvsrGPwGAMGRB/349rwKuoxNSiKjPraNNnlK6MIIabViCjqZugu6j+xeMDlEkWdHHJSg==} dependencies: '@esbuild-kit/core-utils': 3.1.0 - get-tsconfig: 4.4.0 + get-tsconfig: 4.5.0 dev: true /@esbuild-kit/core-utils@3.1.0: resolution: {integrity: sha512-Uuk8RpCg/7fdHSceR1M6XbSZFSuMrxcePFuGgyvsBn+u339dk5OeL4jv2EojwTN2st/unJGsVm4qHWjWNmJ/tw==} dependencies: - esbuild: 0.17.12 + esbuild: 0.17.18 source-map-support: 0.5.21 dev: true @@ -157,11 +180,11 @@ packages: resolution: {integrity: sha512-Qwfvj/qoPbClxCRNuac1Du01r9gvNOT+pMYtJDapfB1eoGN1YlJ1BixLyL9WVENRx5RXgNLdfYdx/CuswlGhMw==} dependencies: '@esbuild-kit/core-utils': 3.1.0 - get-tsconfig: 4.4.0 + get-tsconfig: 4.5.0 dev: true - /@esbuild/android-arm64@0.17.12: - resolution: {integrity: sha512-WQ9p5oiXXYJ33F2EkE3r0FRDFVpEdcDiwNX3u7Xaibxfx6vQE0Sb8ytrfQsA5WO6kDn6mDfKLh6KrPBjvkk7xA==} + /@esbuild/android-arm64@0.17.18: + resolution: {integrity: sha512-/iq0aK0eeHgSC3z55ucMAHO05OIqmQehiGay8eP5l/5l+iEr4EIbh4/MI8xD9qRFjqzgkc0JkX0LculNC9mXBw==} engines: {node: '>=12'} cpu: [arm64] os: [android] @@ -178,8 +201,8 @@ packages: dev: true optional: true - /@esbuild/android-arm@0.17.12: - resolution: {integrity: sha512-E/sgkvwoIfj4aMAPL2e35VnUJspzVYl7+M1B2cqeubdBhADV4uPon0KCc8p2G+LqSJ6i8ocYPCqY3A4GGq0zkQ==} + /@esbuild/android-arm@0.17.18: + resolution: {integrity: sha512-EmwL+vUBZJ7mhFCs5lA4ZimpUH3WMAoqvOIYhVQwdIgSpHC8ImHdsRyhHAVxpDYUSm0lWvd63z0XH1IlImS2Qw==} engines: {node: '>=12'} cpu: [arm] os: [android] @@ -187,8 +210,8 @@ packages: dev: true optional: true - /@esbuild/android-x64@0.17.12: - resolution: {integrity: sha512-m4OsaCr5gT+se25rFPHKQXARMyAehHTQAz4XX1Vk3d27VtqiX0ALMBPoXZsGaB6JYryCLfgGwUslMqTfqeLU0w==} + /@esbuild/android-x64@0.17.18: + resolution: {integrity: sha512-x+0efYNBF3NPW2Xc5bFOSFW7tTXdAcpfEg2nXmxegm4mJuVeS+i109m/7HMiOQ6M12aVGGFlqJX3RhNdYM2lWg==} engines: {node: '>=12'} cpu: [x64] os: [android] @@ -196,8 +219,8 @@ packages: dev: true optional: true - /@esbuild/darwin-arm64@0.17.12: - resolution: {integrity: sha512-O3GCZghRIx+RAN0NDPhyyhRgwa19MoKlzGonIb5hgTj78krqp9XZbYCvFr9N1eUxg0ZQEpiiZ4QvsOQwBpP+lg==} + /@esbuild/darwin-arm64@0.17.18: + resolution: {integrity: sha512-6tY+djEAdF48M1ONWnQb1C+6LiXrKjmqjzPNPWXhu/GzOHTHX2nh8Mo2ZAmBFg0kIodHhciEgUBtcYCAIjGbjQ==} engines: {node: '>=12'} cpu: [arm64] os: [darwin] @@ -205,8 +228,8 @@ packages: dev: true optional: true - /@esbuild/darwin-x64@0.17.12: - resolution: {integrity: sha512-5D48jM3tW27h1qjaD9UNRuN+4v0zvksqZSPZqeSWggfMlsVdAhH3pwSfQIFJwcs9QJ9BRibPS4ViZgs3d2wsCA==} + /@esbuild/darwin-x64@0.17.18: + resolution: {integrity: sha512-Qq84ykvLvya3dO49wVC9FFCNUfSrQJLbxhoQk/TE1r6MjHo3sFF2tlJCwMjhkBVq3/ahUisj7+EpRSz0/+8+9A==} engines: {node: '>=12'} cpu: [x64] os: [darwin] @@ -214,8 +237,8 @@ packages: dev: true optional: true - /@esbuild/freebsd-arm64@0.17.12: - resolution: {integrity: sha512-OWvHzmLNTdF1erSvrfoEBGlN94IE6vCEaGEkEH29uo/VoONqPnoDFfShi41Ew+yKimx4vrmmAJEGNoyyP+OgOQ==} + /@esbuild/freebsd-arm64@0.17.18: + resolution: {integrity: sha512-fw/ZfxfAzuHfaQeMDhbzxp9mc+mHn1Y94VDHFHjGvt2Uxl10mT4CDavHm+/L9KG441t1QdABqkVYwakMUeyLRA==} engines: {node: '>=12'} cpu: [arm64] os: [freebsd] @@ -223,8 +246,8 @@ packages: dev: true optional: true - /@esbuild/freebsd-x64@0.17.12: - resolution: {integrity: sha512-A0Xg5CZv8MU9xh4a+7NUpi5VHBKh1RaGJKqjxe4KG87X+mTjDE6ZvlJqpWoeJxgfXHT7IMP9tDFu7IZ03OtJAw==} + /@esbuild/freebsd-x64@0.17.18: + resolution: {integrity: sha512-FQFbRtTaEi8ZBi/A6kxOC0V0E9B/97vPdYjY9NdawyLd4Qk5VD5g2pbWN2VR1c0xhzcJm74HWpObPszWC+qTew==} engines: {node: '>=12'} cpu: [x64] os: [freebsd] @@ -232,8 +255,8 @@ packages: dev: true optional: true - /@esbuild/linux-arm64@0.17.12: - resolution: {integrity: sha512-cK3AjkEc+8v8YG02hYLQIQlOznW+v9N+OI9BAFuyqkfQFR+DnDLhEM5N8QRxAUz99cJTo1rLNXqRrvY15gbQUg==} + /@esbuild/linux-arm64@0.17.18: + resolution: {integrity: sha512-R7pZvQZFOY2sxUG8P6A21eq6q+eBv7JPQYIybHVf1XkQYC+lT7nDBdC7wWKTrbvMXKRaGudp/dzZCwL/863mZQ==} engines: {node: '>=12'} cpu: [arm64] os: [linux] @@ -241,8 +264,8 @@ packages: dev: true optional: true - /@esbuild/linux-arm@0.17.12: - resolution: {integrity: sha512-WsHyJ7b7vzHdJ1fv67Yf++2dz3D726oO3QCu8iNYik4fb5YuuReOI9OtA+n7Mk0xyQivNTPbl181s+5oZ38gyA==} + /@esbuild/linux-arm@0.17.18: + resolution: {integrity: sha512-jW+UCM40LzHcouIaqv3e/oRs0JM76JfhHjCavPxMUti7VAPh8CaGSlS7cmyrdpzSk7A+8f0hiedHqr/LMnfijg==} engines: {node: '>=12'} cpu: [arm] os: [linux] @@ -250,8 +273,8 @@ packages: dev: true optional: true - /@esbuild/linux-ia32@0.17.12: - resolution: {integrity: sha512-jdOBXJqcgHlah/nYHnj3Hrnl9l63RjtQ4vn9+bohjQPI2QafASB5MtHAoEv0JQHVb/xYQTFOeuHnNYE1zF7tYw==} + /@esbuild/linux-ia32@0.17.18: + resolution: {integrity: sha512-ygIMc3I7wxgXIxk6j3V00VlABIjq260i967Cp9BNAk5pOOpIXmd1RFQJQX9Io7KRsthDrQYrtcx7QCof4o3ZoQ==} engines: {node: '>=12'} cpu: [ia32] os: [linux] @@ -268,8 +291,8 @@ packages: dev: true optional: true - /@esbuild/linux-loong64@0.17.12: - resolution: {integrity: sha512-GTOEtj8h9qPKXCyiBBnHconSCV9LwFyx/gv3Phw0pa25qPYjVuuGZ4Dk14bGCfGX3qKF0+ceeQvwmtI+aYBbVA==} + /@esbuild/linux-loong64@0.17.18: + resolution: {integrity: sha512-bvPG+MyFs5ZlwYclCG1D744oHk1Pv7j8psF5TfYx7otCVmcJsEXgFEhQkbhNW8otDHL1a2KDINW20cfCgnzgMQ==} engines: {node: '>=12'} cpu: [loong64] os: [linux] @@ -277,8 +300,8 @@ packages: dev: true optional: true - /@esbuild/linux-mips64el@0.17.12: - resolution: {integrity: sha512-o8CIhfBwKcxmEENOH9RwmUejs5jFiNoDw7YgS0EJTF6kgPgcqLFjgoc5kDey5cMHRVCIWc6kK2ShUePOcc7RbA==} + /@esbuild/linux-mips64el@0.17.18: + resolution: {integrity: sha512-oVqckATOAGuiUOa6wr8TXaVPSa+6IwVJrGidmNZS1cZVx0HqkTMkqFGD2HIx9H1RvOwFeWYdaYbdY6B89KUMxA==} engines: {node: '>=12'} cpu: [mips64el] os: [linux] @@ -286,8 +309,8 @@ packages: dev: true optional: true - /@esbuild/linux-ppc64@0.17.12: - resolution: {integrity: sha512-biMLH6NR/GR4z+ap0oJYb877LdBpGac8KfZoEnDiBKd7MD/xt8eaw1SFfYRUeMVx519kVkAOL2GExdFmYnZx3A==} + /@esbuild/linux-ppc64@0.17.18: + resolution: {integrity: sha512-3dLlQO+b/LnQNxgH4l9rqa2/IwRJVN9u/bK63FhOPB4xqiRqlQAU0qDU3JJuf0BmaH0yytTBdoSBHrb2jqc5qQ==} engines: {node: '>=12'} cpu: [ppc64] os: [linux] @@ -295,8 +318,8 @@ packages: dev: true optional: true - /@esbuild/linux-riscv64@0.17.12: - resolution: {integrity: sha512-jkphYUiO38wZGeWlfIBMB72auOllNA2sLfiZPGDtOBb1ELN8lmqBrlMiucgL8awBw1zBXN69PmZM6g4yTX84TA==} + /@esbuild/linux-riscv64@0.17.18: + resolution: {integrity: sha512-/x7leOyDPjZV3TcsdfrSI107zItVnsX1q2nho7hbbQoKnmoeUWjs+08rKKt4AUXju7+3aRZSsKrJtaRmsdL1xA==} engines: {node: '>=12'} cpu: [riscv64] os: [linux] @@ -304,8 +327,8 @@ packages: dev: true optional: true - /@esbuild/linux-s390x@0.17.12: - resolution: {integrity: sha512-j3ucLdeY9HBcvODhCY4b+Ds3hWGO8t+SAidtmWu/ukfLLG/oYDMaA+dnugTVAg5fnUOGNbIYL9TOjhWgQB8W5g==} + /@esbuild/linux-s390x@0.17.18: + resolution: {integrity: sha512-cX0I8Q9xQkL/6F5zWdYmVf5JSQt+ZfZD2bJudZrWD+4mnUvoZ3TDDXtDX2mUaq6upMFv9FlfIh4Gfun0tbGzuw==} engines: {node: '>=12'} cpu: [s390x] os: [linux] @@ -313,8 +336,8 @@ packages: dev: true optional: true - /@esbuild/linux-x64@0.17.12: - resolution: {integrity: sha512-uo5JL3cgaEGotaqSaJdRfFNSCUJOIliKLnDGWaVCgIKkHxwhYMm95pfMbWZ9l7GeW9kDg0tSxcy9NYdEtjwwmA==} + /@esbuild/linux-x64@0.17.18: + resolution: {integrity: sha512-66RmRsPlYy4jFl0vG80GcNRdirx4nVWAzJmXkevgphP1qf4dsLQCpSKGM3DUQCojwU1hnepI63gNZdrr02wHUA==} engines: {node: '>=12'} cpu: [x64] os: [linux] @@ -322,8 +345,8 @@ packages: dev: true optional: true - /@esbuild/netbsd-x64@0.17.12: - resolution: {integrity: sha512-DNdoRg8JX+gGsbqt2gPgkgb00mqOgOO27KnrWZtdABl6yWTST30aibGJ6geBq3WM2TIeW6COs5AScnC7GwtGPg==} + /@esbuild/netbsd-x64@0.17.18: + resolution: {integrity: sha512-95IRY7mI2yrkLlTLb1gpDxdC5WLC5mZDi+kA9dmM5XAGxCME0F8i4bYH4jZreaJ6lIZ0B8hTrweqG1fUyW7jbg==} engines: {node: '>=12'} cpu: [x64] os: [netbsd] @@ -331,8 +354,8 @@ packages: dev: true optional: true - /@esbuild/openbsd-x64@0.17.12: - resolution: {integrity: sha512-aVsENlr7B64w8I1lhHShND5o8cW6sB9n9MUtLumFlPhG3elhNWtE7M1TFpj3m7lT3sKQUMkGFjTQBrvDDO1YWA==} + /@esbuild/openbsd-x64@0.17.18: + resolution: {integrity: sha512-WevVOgcng+8hSZ4Q3BKL3n1xTv5H6Nb53cBrtzzEjDbbnOmucEVcZeGCsCOi9bAOcDYEeBZbD2SJNBxlfP3qiA==} engines: {node: '>=12'} cpu: [x64] os: [openbsd] @@ -340,8 +363,8 @@ packages: dev: true optional: true - /@esbuild/sunos-x64@0.17.12: - resolution: {integrity: sha512-qbHGVQdKSwi0JQJuZznS4SyY27tYXYF0mrgthbxXrZI3AHKuRvU+Eqbg/F0rmLDpW/jkIZBlCO1XfHUBMNJ1pg==} + /@esbuild/sunos-x64@0.17.18: + resolution: {integrity: sha512-Rzf4QfQagnwhQXVBS3BYUlxmEbcV7MY+BH5vfDZekU5eYpcffHSyjU8T0xucKVuOcdCsMo+Ur5wmgQJH2GfNrg==} engines: {node: '>=12'} cpu: [x64] os: [sunos] @@ -349,8 +372,8 @@ packages: dev: true optional: true - /@esbuild/win32-arm64@0.17.12: - resolution: {integrity: sha512-zsCp8Ql+96xXTVTmm6ffvoTSZSV2B/LzzkUXAY33F/76EajNw1m+jZ9zPfNJlJ3Rh4EzOszNDHsmG/fZOhtqDg==} + /@esbuild/win32-arm64@0.17.18: + resolution: {integrity: sha512-Kb3Ko/KKaWhjeAm2YoT/cNZaHaD1Yk/pa3FTsmqo9uFh1D1Rfco7BBLIPdDOozrObj2sahslFuAQGvWbgWldAg==} engines: {node: '>=12'} cpu: [arm64] os: [win32] @@ -358,8 +381,8 @@ packages: dev: true optional: true - /@esbuild/win32-ia32@0.17.12: - resolution: {integrity: sha512-FfrFjR4id7wcFYOdqbDfDET3tjxCozUgbqdkOABsSFzoZGFC92UK7mg4JKRc/B3NNEf1s2WHxJ7VfTdVDPN3ng==} + /@esbuild/win32-ia32@0.17.18: + resolution: {integrity: sha512-0/xUMIdkVHwkvxfbd5+lfG7mHOf2FRrxNbPiKWg9C4fFrB8H0guClmaM3BFiRUYrznVoyxTIyC/Ou2B7QQSwmw==} engines: {node: '>=12'} cpu: [ia32] os: [win32] @@ -367,8 +390,8 @@ packages: dev: true optional: true - /@esbuild/win32-x64@0.17.12: - resolution: {integrity: sha512-JOOxw49BVZx2/5tW3FqkdjSD/5gXYeVGPDcB0lvap0gLQshkh1Nyel1QazC+wNxus3xPlsYAgqU1BUmrmCvWtw==} + /@esbuild/win32-x64@0.17.18: + resolution: {integrity: sha512-qU25Ma1I3NqTSHJUOKi9sAH1/Mzuvlke0ioMJRthLXKm7JiSKVwFghlGbDLOO2sARECGhja4xYfRAZNPAkooYg==} engines: {node: '>=12'} cpu: [x64] os: [win32] @@ -376,6 +399,24 @@ packages: dev: true optional: true + /@eslint-community/eslint-utils@4.4.0(eslint@8.28.0): + resolution: {integrity: sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + peerDependencies: + eslint: ^6.0.0 || ^7.0.0 || >=8.0.0 + peerDependenciesMeta: + eslint: + optional: true + dependencies: + eslint: 8.28.0(patch_hash=7wc6icvgtg3uswirb5tpsbjnbe) + eslint-visitor-keys: 3.4.0 + dev: true + + /@eslint-community/regexpp@4.5.1: + resolution: {integrity: sha512-Z5ba73P98O1KUYCCJTUeVpja9RcGoMdncZ6T49FCUl2lN38JtCJ+3WgIDBv0AuY4WChU5PmtJmOCTlN6FZTFKQ==} + engines: {node: ^12.0.0 || ^14.0.0 || >=16.0.0} + dev: true + /@eslint/eslintrc@1.3.3: resolution: {integrity: sha512-uj3pT6Mg+3t39fvLrj8iuCIJ38zKO9FpGtJ4BBJebJhEwjoT+KLVNCcHT5QC9NGRIEi7fZ0ZR8YRb884auB4Lg==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -434,61 +475,80 @@ packages: fastq: 1.13.0 dev: true - /@types/diff@5.0.2: - resolution: {integrity: sha512-uw8eYMIReOwstQ0QKF0sICefSy8cNO/v7gOTiIy9SbwuHyEecJUm7qlgueOO5S1udZ5I/irVydHVwMchgzbKTg==} + /@puppeteer/browsers@0.5.0(typescript@5.0.4): + resolution: {integrity: sha512-Uw6oB7VvmPRLE4iKsjuOh8zgDabhNX67dzo8U/BB0f9527qx+4eeUs+korU98OhG5C4ubg7ufBgVi63XYwS6TQ==} + engines: {node: '>=14.1.0'} + hasBin: true + peerDependencies: + typescript: '>= 4.7.4' + peerDependenciesMeta: + typescript: + optional: true + dependencies: + debug: 4.3.4 + extract-zip: 2.0.1 + https-proxy-agent: 5.0.1 + progress: 2.0.3 + proxy-from-env: 1.1.0 + tar-fs: 2.1.1 + typescript: 5.0.4 + unbzip2-stream: 1.4.3 + yargs: 17.7.1 + transitivePeerDependencies: + - supports-color + dev: true + + /@types/diff@5.0.3: + resolution: {integrity: sha512-amrLbRqTU9bXMCc6uX0sWpxsQzRIo9z6MJPkH1pkez/qOxuqSZVuryJAWoBRq94CeG8JxY+VK4Le9HtjQR5T9A==} dev: true /@types/json-schema@7.0.11: resolution: {integrity: sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==} dev: true - /@types/lodash@4.14.191: - resolution: {integrity: sha512-BdZ5BCCvho3EIXw6wUCXHe7rS53AIDPLE+JzwgT+OsJk53oBfbSmZZ7CX4VaRoN78N+TJpFi9QPlfIVNmJYWxQ==} + /@types/lodash@4.14.194: + resolution: {integrity: sha512-r22s9tAS7imvBt2lyHC9B8AGwWnXaYb1tY09oyLkXDs4vArpYJzw09nj8MLx5VfciBPGIb+ZwG0ssYnEPJxn/g==} dev: true /@types/minimist@1.2.2: resolution: {integrity: sha512-jhuKLIRrhvCPLqwPcx6INqmKeiA5EWrsCOPhrlFSrbrmU4ZMPjj5Ul/oLCMDO98XRUIwVm78xICz4EPCektzeQ==} dev: true - /@types/node@18.11.18: - resolution: {integrity: sha512-DHQpWGjyQKSHj3ebjFI/wRKcqQcdR+MoFBygntYOZytCqNfkd2ZC4ARDJ2DQqhjH5p85Nnd3jhUJIXrszFX/JA==} + /@types/node@18.16.3: + resolution: {integrity: sha512-OPs5WnnT1xkCBiuQrZA4+YAV4HEJejmHneyraIaxsbev5yCEr6KMwINNFP9wQeFIw8FWcoTqF3vQsa5CDaI+8Q==} dev: true /@types/normalize-package-data@2.4.1: resolution: {integrity: sha512-Gj7cI7z+98M282Tqmp2K5EIsoouUEzbBJhQQzDE3jSIRk6r9gsz0oUokqIUR4u1R3dMHo0pDHM7sNOHyhulypw==} dev: true - /@types/parse-json@4.0.0: - resolution: {integrity: sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA==} - dev: true - /@types/prop-types@15.7.5: resolution: {integrity: sha512-JCB8C6SnDoQf0cNycqd/35A7MjcnK+ZTqE7judS6o7utxUCg6imJg3QK2qzHKszlTjcj2cn+NwMB2i96ubpj7w==} dev: true - /@types/react-dom@18.0.10: - resolution: {integrity: sha512-E42GW/JA4Qv15wQdqJq8DL4JhNpB3prJgjgapN3qJT9K2zO5IIAQh4VXvCEDupoqAwnz0cY4RlXeC/ajX5SFHg==} + /@types/react-dom@18.2.1: + resolution: {integrity: sha512-8QZEV9+Kwy7tXFmjJrp3XUKQSs9LTnE0KnoUb0YCguWBiNW0Yfb2iBMYZ08WPg35IR6P3Z0s00B15SwZnO26+w==} dependencies: - '@types/react': 18.0.27 + '@types/react': 18.2.0 dev: true /@types/react@17.0.2: resolution: {integrity: sha512-Xt40xQsrkdvjn1EyWe1Bc0dJLcil/9x2vAuW7ya+PuQip4UYUaXyhzWmAbwRsdMgwOFHpfp7/FFZebDU6Y8VHA==} dependencies: '@types/prop-types': 15.7.5 - csstype: 3.1.0 + csstype: 3.1.2 dev: true - /@types/react@18.0.27: - resolution: {integrity: sha512-3vtRKHgVxu3Jp9t718R9BuzoD4NcQ8YJ5XRzsSKxNDiDonD2MXIT1TmSkenxuCycZJoQT5d2vE8LwWJxBC1gmA==} + /@types/react@18.2.0: + resolution: {integrity: sha512-0FLj93y5USLHdnhIhABk83rm8XEGA7kH3cr+YUlvxoUGp1xNt/DINUMvqPxLyOQMzLmZe8i4RTHbvb8MC7NmrA==} dependencies: '@types/prop-types': 15.7.5 - '@types/scheduler': 0.16.2 - csstype: 3.1.0 + '@types/scheduler': 0.16.3 + csstype: 3.1.2 dev: true - /@types/scheduler@0.16.2: - resolution: {integrity: sha512-hppQEBDmlwhFAXKJX2KnWLYu5yMfi91yazPb2l+lbJiwW+wdo1gNeRA+3RgNSO39WYX2euey41KEwnqesU2Jew==} + /@types/scheduler@0.16.3: + resolution: {integrity: sha512-5cJ8CB4yAx7BH1oMvdU0Jh9lrEXyPkar6F9G/ERswkCuvP4KQZfZkSjcMbAICCpQTN4OuZn8tz0HiKv9TGZgrQ==} dev: true /@types/semver@7.3.13: @@ -499,18 +559,18 @@ packages: resolution: {integrity: sha512-Cn6WYCm0tXv8p6k+A8PvbDG763EDpBoTzHdA+Q/MF6H3sapGjCm9NzoaJncJS9tUKSuCoDs9XHxYYsQDgxR6kw==} requiresBuild: true dependencies: - '@types/node': 18.11.18 + '@types/node': 18.16.3 dev: true optional: true /@types/yazl@2.4.2: resolution: {integrity: sha512-T+9JH8O2guEjXNxqmybzQ92mJUh2oCwDDMSSimZSe1P+pceZiFROZLYmcbqkzV5EUwz6VwcKXCO2S2yUpra6XQ==} dependencies: - '@types/node': 18.11.18 + '@types/node': 18.16.3 dev: true - /@typescript-eslint/eslint-plugin@5.49.0(@typescript-eslint/parser@5.49.0)(eslint@8.28.0)(typescript@4.9.4): - resolution: {integrity: sha512-IhxabIpcf++TBaBa1h7jtOWyon80SXPRLDq0dVz5SLFC/eW6tofkw/O7Ar3lkx5z5U6wzbKDrl2larprp5kk5Q==} + /@typescript-eslint/eslint-plugin@5.59.1(@typescript-eslint/parser@5.59.1)(eslint@8.28.0)(typescript@5.0.4): + resolution: {integrity: sha512-AVi0uazY5quFB9hlp2Xv+ogpfpk77xzsgsIEWyVS7uK/c7MZ5tw7ZPbapa0SbfkqE0fsAMkz5UwtgMLVk2BQAg==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: '@typescript-eslint/parser': ^5.0.0 @@ -522,24 +582,25 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/parser': 5.49.0(eslint@8.28.0)(typescript@4.9.4) - '@typescript-eslint/scope-manager': 5.49.0 - '@typescript-eslint/type-utils': 5.49.0(eslint@8.28.0)(typescript@4.9.4) - '@typescript-eslint/utils': 5.49.0(eslint@8.28.0)(typescript@4.9.4) + '@eslint-community/regexpp': 4.5.1 + '@typescript-eslint/parser': 5.59.1(eslint@8.28.0)(typescript@5.0.4) + '@typescript-eslint/scope-manager': 5.59.1 + '@typescript-eslint/type-utils': 5.59.1(eslint@8.28.0)(typescript@5.0.4) + '@typescript-eslint/utils': 5.59.1(eslint@8.28.0)(typescript@5.0.4) debug: 4.3.4 eslint: 8.28.0(patch_hash=7wc6icvgtg3uswirb5tpsbjnbe) - ignore: 5.2.0 + grapheme-splitter: 1.0.4 + ignore: 5.2.4 natural-compare-lite: 1.4.0 - regexpp: 3.2.0 - semver: 7.3.7 - tsutils: 3.21.0(typescript@4.9.4) - typescript: 4.9.4 + semver: 7.5.0 + tsutils: 3.21.0(typescript@5.0.4) + typescript: 5.0.4 transitivePeerDependencies: - supports-color dev: true - /@typescript-eslint/parser@5.49.0(eslint@8.28.0)(typescript@4.9.4): - resolution: {integrity: sha512-veDlZN9mUhGqU31Qiv2qEp+XrJj5fgZpJ8PW30sHU+j/8/e5ruAhLaVDAeznS7A7i4ucb/s8IozpDtt9NqCkZg==} + /@typescript-eslint/parser@5.59.1(eslint@8.28.0)(typescript@5.0.4): + resolution: {integrity: sha512-nzjFAN8WEu6yPRDizIFyzAfgK7nybPodMNFGNH0M9tei2gYnYszRDqVA0xlnRjkl7Hkx2vYrEdb6fP2a21cG1g==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 @@ -550,26 +611,26 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/scope-manager': 5.49.0 - '@typescript-eslint/types': 5.49.0 - '@typescript-eslint/typescript-estree': 5.49.0(typescript@4.9.4) + '@typescript-eslint/scope-manager': 5.59.1 + '@typescript-eslint/types': 5.59.1 + '@typescript-eslint/typescript-estree': 5.59.1(typescript@5.0.4) debug: 4.3.4 eslint: 8.28.0(patch_hash=7wc6icvgtg3uswirb5tpsbjnbe) - typescript: 4.9.4 + typescript: 5.0.4 transitivePeerDependencies: - supports-color dev: true - /@typescript-eslint/scope-manager@5.49.0: - resolution: {integrity: sha512-clpROBOiMIzpbWNxCe1xDK14uPZh35u4QaZO1GddilEzoCLAEz4szb51rBpdgurs5k2YzPtJeTEN3qVbG+LRUQ==} + /@typescript-eslint/scope-manager@5.59.1: + resolution: {integrity: sha512-mau0waO5frJctPuAzcxiNWqJR5Z8V0190FTSqRw1Q4Euop6+zTwHAf8YIXNwDOT29tyUDrQ65jSg9aTU/H0omA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dependencies: - '@typescript-eslint/types': 5.49.0 - '@typescript-eslint/visitor-keys': 5.49.0 + '@typescript-eslint/types': 5.59.1 + '@typescript-eslint/visitor-keys': 5.59.1 dev: true - /@typescript-eslint/type-utils@5.49.0(eslint@8.28.0)(typescript@4.9.4): - resolution: {integrity: sha512-eUgLTYq0tR0FGU5g1YHm4rt5H/+V2IPVkP0cBmbhRyEmyGe4XvJ2YJ6sYTmONfjmdMqyMLad7SB8GvblbeESZA==} + /@typescript-eslint/type-utils@5.59.1(eslint@8.28.0)(typescript@5.0.4): + resolution: {integrity: sha512-ZMWQ+Oh82jWqWzvM3xU+9y5U7MEMVv6GLioM3R5NJk6uvP47kZ7YvlgSHJ7ERD6bOY7Q4uxWm25c76HKEwIjZw==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: eslint: '*' @@ -580,23 +641,23 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/typescript-estree': 5.49.0(typescript@4.9.4) - '@typescript-eslint/utils': 5.49.0(eslint@8.28.0)(typescript@4.9.4) + '@typescript-eslint/typescript-estree': 5.59.1(typescript@5.0.4) + '@typescript-eslint/utils': 5.59.1(eslint@8.28.0)(typescript@5.0.4) debug: 4.3.4 eslint: 8.28.0(patch_hash=7wc6icvgtg3uswirb5tpsbjnbe) - tsutils: 3.21.0(typescript@4.9.4) - typescript: 4.9.4 + tsutils: 3.21.0(typescript@5.0.4) + typescript: 5.0.4 transitivePeerDependencies: - supports-color dev: true - /@typescript-eslint/types@5.49.0: - resolution: {integrity: sha512-7If46kusG+sSnEpu0yOz2xFv5nRz158nzEXnJFCGVEHWnuzolXKwrH5Bsf9zsNlOQkyZuk0BZKKoJQI+1JPBBg==} + /@typescript-eslint/types@5.59.1: + resolution: {integrity: sha512-dg0ICB+RZwHlysIy/Dh1SP+gnXNzwd/KS0JprD3Lmgmdq+dJAJnUPe1gNG34p0U19HvRlGX733d/KqscrGC1Pg==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dev: true - /@typescript-eslint/typescript-estree@5.49.0(typescript@4.9.4): - resolution: {integrity: sha512-PBdx+V7deZT/3GjNYPVQv1Nc0U46dAHbIuOG8AZ3on3vuEKiPDwFE/lG1snN2eUB9IhF7EyF7K1hmTcLztNIsA==} + /@typescript-eslint/typescript-estree@5.59.1(typescript@5.0.4): + resolution: {integrity: sha512-lYLBBOCsFltFy7XVqzX0Ju+Lh3WPIAWxYpmH/Q7ZoqzbscLiCW00LeYCdsUnnfnj29/s1WovXKh2gwCoinHNGA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: typescript: '*' @@ -604,20 +665,20 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/types': 5.49.0 - '@typescript-eslint/visitor-keys': 5.49.0 + '@typescript-eslint/types': 5.59.1 + '@typescript-eslint/visitor-keys': 5.59.1 debug: 4.3.4 globby: 11.1.0 is-glob: 4.0.3 - semver: 7.3.8 - tsutils: 3.21.0(typescript@4.9.4) - typescript: 4.9.4 + semver: 7.5.0 + tsutils: 3.21.0(typescript@5.0.4) + typescript: 5.0.4 transitivePeerDependencies: - supports-color dev: true - /@typescript-eslint/utils@5.49.0(eslint@8.28.0)(typescript@4.9.4): - resolution: {integrity: sha512-cPJue/4Si25FViIb74sHCLtM4nTSBXtLx1d3/QT6mirQ/c65bV8arBEebBJJizfq8W2YyMoPI/WWPFWitmNqnQ==} + /@typescript-eslint/utils@5.59.1(eslint@8.28.0)(typescript@5.0.4): + resolution: {integrity: sha512-MkTe7FE+K1/GxZkP5gRj3rCztg45bEhsd8HYjczBuYm+qFHP5vtZmjx3B0yUCDotceQ4sHgTyz60Ycl225njmA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 @@ -625,26 +686,26 @@ packages: eslint: optional: true dependencies: + '@eslint-community/eslint-utils': 4.4.0(eslint@8.28.0) '@types/json-schema': 7.0.11 '@types/semver': 7.3.13 - '@typescript-eslint/scope-manager': 5.49.0 - '@typescript-eslint/types': 5.49.0 - '@typescript-eslint/typescript-estree': 5.49.0(typescript@4.9.4) + '@typescript-eslint/scope-manager': 5.59.1 + '@typescript-eslint/types': 5.59.1 + '@typescript-eslint/typescript-estree': 5.59.1(typescript@5.0.4) eslint: 8.28.0(patch_hash=7wc6icvgtg3uswirb5tpsbjnbe) eslint-scope: 5.1.1 - eslint-utils: 3.0.0(eslint@8.28.0) - semver: 7.3.8 + semver: 7.5.0 transitivePeerDependencies: - supports-color - typescript dev: true - /@typescript-eslint/visitor-keys@5.49.0: - resolution: {integrity: sha512-v9jBMjpNWyn8B6k/Mjt6VbUS4J1GvUlR4x3Y+ibnP1z7y7V4n0WRz+50DY6+Myj0UaXVSuUlHohO+eZ8IJEnkg==} + /@typescript-eslint/visitor-keys@5.59.1: + resolution: {integrity: sha512-6waEYwBTCWryx0VJmP7JaM4FpipLsFl9CvYf2foAE8Qh/Y0s+bxWysciwOs0LTBED4JCaNxTZ5rGadB14M6dwA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dependencies: - '@typescript-eslint/types': 5.49.0 - eslint-visitor-keys: 3.3.0 + '@typescript-eslint/types': 5.59.1 + eslint-visitor-keys: 3.4.0 dev: true /@vap/core@0.0.12: @@ -653,8 +714,8 @@ packages: eventemitter3: 4.0.7 dev: false - /@vap/shiki@0.10.3: - resolution: {integrity: sha512-tZPHZxDKEBlorQ2BaprytGfkbo5yKBvdxdAF144p94HCTpjO3ScJk/f319wi7GtV1NE4DV8HBQo/0XpldixWQA==} + /@vap/shiki@0.10.5: + resolution: {integrity: sha512-5BHVGvQT8qonbLSASon5aQFQ18OZU4FxSl9tLSj6oJ0sap3KdMbYcfGq25M9zFZR1g1dJN7fgjmZXBIS5omIdw==} dependencies: jsonc-parser: 3.2.0 vscode-oniguruma: 1.7.0 @@ -796,7 +857,7 @@ packages: dependencies: buffer: 5.7.1 inherits: 2.0.4 - readable-stream: 3.6.0 + readable-stream: 3.6.2 dev: true /brace-expansion@1.1.11: @@ -883,6 +944,15 @@ packages: resolution: {integrity: sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==} dev: true + /chromium-bidi@0.4.7(devtools-protocol@0.0.1107588): + resolution: {integrity: sha512-6+mJuFXwTMU6I3vYLs6IL8A1DyQTPjCfIL971X0aMPVGRbGnNfl6i6Cl0NMbxi2bRYLGESt9T2ZIMRM5PAEcIQ==} + peerDependencies: + devtools-protocol: '*' + dependencies: + devtools-protocol: 0.0.1107588 + mitt: 3.0.0 + dev: true + /class-utils@0.3.6: resolution: {integrity: sha512-qOhPa/Fj7s6TY8H8esGu5QNpMMQxz79h+urzrNYN6mn+9BnxlDGf5QZ+XeCDsxSjPqsSR56XOZOJmpeurnLMeg==} engines: {node: '>=0.10.0'} @@ -893,6 +963,15 @@ packages: static-extend: 0.1.2 dev: true + /cliui@8.0.1: + resolution: {integrity: sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==} + engines: {node: '>=12'} + dependencies: + string-width: 4.2.3 + strip-ansi: 6.0.1 + wrap-ansi: 7.0.0 + dev: true + /collection-visit@1.0.0: resolution: {integrity: sha512-lNkKvzEeMBBjUGHZ+q6z9pSJla0KWAQPvtzhEV9+iGyQYG+pBpl7xKDhxoNSOZH2hhv0v5k0y2yAM4o4SjoSkw==} engines: {node: '>=0.10.0'} @@ -939,15 +1018,14 @@ packages: engines: {node: '>=0.10.0'} dev: true - /cosmiconfig@7.1.0: - resolution: {integrity: sha512-AdmX6xUzdNASswsFtmwSt7Vj8po9IuqXm0UXz7QKPuEUmPB4XyjGfaAr2PSuELMwkRMVH1EpIkX5bTZGRB3eCA==} - engines: {node: '>=10'} + /cosmiconfig@8.1.3: + resolution: {integrity: sha512-/UkO2JKI18b5jVMJUp0lvKFMpa/Gye+ZgZjKD+DGEN9y7NRcf/nK1A0sp67ONmKtnDCNMS44E6jrk0Yc3bDuUw==} + engines: {node: '>=14'} dependencies: - '@types/parse-json': 4.0.0 import-fresh: 3.3.0 + js-yaml: 4.1.0 parse-json: 5.2.0 path-type: 4.0.0 - yaml: 1.10.2 dev: true /cross-fetch@3.1.5: @@ -972,14 +1050,22 @@ packages: engines: {node: '>=12.22'} dev: true + /css-tree@2.3.1: + resolution: {integrity: sha512-6Fv1DV/TYw//QF5IzQdqsNDjx/wc8TrMBZsqjL9eW01tWb7R7k/mq+/VXfJCl7SoD5emsJop9cOByJZfs8hYIw==} + engines: {node: ^10 || ^12.20.0 || ^14.13.0 || >=15.0.0} + dependencies: + mdn-data: 2.0.30 + source-map-js: 1.0.2 + dev: true + /cssesc@3.0.0: resolution: {integrity: sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg==} engines: {node: '>=4'} hasBin: true dev: true - /csstype@3.1.0: - resolution: {integrity: sha512-uX1KG+x9h5hIJsaKR9xHUeUraxf8IODOwq9JLNPq6BwB04a/xgpq3rcx47l5BZu5zBPlgD342tdke3Hom/nJRA==} + /csstype@3.1.2: + resolution: {integrity: sha512-I7K1Uu0MBPzaFKg4nI5Q7Vs2t+3gWWW648spaF+Rg7pI9ds18Ugn+lvg4SHczUdKlHI5LWBXyqfS8+DufyBsgQ==} dev: true /debug@2.6.9: @@ -1049,8 +1135,8 @@ packages: isobject: 3.0.1 dev: true - /devtools-protocol@0.0.1082910: - resolution: {integrity: sha512-RqoZ2GmqaNxyx+99L/RemY5CkwG9D0WEfOKxekwCRXOGrDCep62ngezEJUVMq6rISYQ+085fJnWDQqGHlxVNww==} + /devtools-protocol@0.0.1107588: + resolution: {integrity: sha512-yIR+pG9x65Xko7bErCUSQaDLrO/P1p3JUzEk7JCU4DowPcGHkTGUGQapcfcLc4qj0UaALwZ+cr0riFgiqpixcg==} dev: true /diff@5.1.0: @@ -1305,34 +1391,39 @@ packages: esbuild-windows-arm64: 0.15.18 dev: true - /esbuild@0.17.12: - resolution: {integrity: sha512-bX/zHl7Gn2CpQwcMtRogTTBf9l1nl+H6R8nUbjk+RuKqAE3+8FDulLA+pHvX7aA7Xe07Iwa+CWvy9I8Y2qqPKQ==} + /esbuild@0.17.18: + resolution: {integrity: sha512-z1lix43jBs6UKjcZVKOw2xx69ffE2aG0PygLL5qJ9OS/gy0Ewd1gW/PUQIOIQGXBHWNywSc0floSKoMFF8aK2w==} engines: {node: '>=12'} hasBin: true requiresBuild: true optionalDependencies: - '@esbuild/android-arm': 0.17.12 - '@esbuild/android-arm64': 0.17.12 - '@esbuild/android-x64': 0.17.12 - '@esbuild/darwin-arm64': 0.17.12 - '@esbuild/darwin-x64': 0.17.12 - '@esbuild/freebsd-arm64': 0.17.12 - '@esbuild/freebsd-x64': 0.17.12 - '@esbuild/linux-arm': 0.17.12 - '@esbuild/linux-arm64': 0.17.12 - '@esbuild/linux-ia32': 0.17.12 - '@esbuild/linux-loong64': 0.17.12 - '@esbuild/linux-mips64el': 0.17.12 - '@esbuild/linux-ppc64': 0.17.12 - '@esbuild/linux-riscv64': 0.17.12 - '@esbuild/linux-s390x': 0.17.12 - '@esbuild/linux-x64': 0.17.12 - '@esbuild/netbsd-x64': 0.17.12 - '@esbuild/openbsd-x64': 0.17.12 - '@esbuild/sunos-x64': 0.17.12 - '@esbuild/win32-arm64': 0.17.12 - '@esbuild/win32-ia32': 0.17.12 - '@esbuild/win32-x64': 0.17.12 + '@esbuild/android-arm': 0.17.18 + '@esbuild/android-arm64': 0.17.18 + '@esbuild/android-x64': 0.17.18 + '@esbuild/darwin-arm64': 0.17.18 + '@esbuild/darwin-x64': 0.17.18 + '@esbuild/freebsd-arm64': 0.17.18 + '@esbuild/freebsd-x64': 0.17.18 + '@esbuild/linux-arm': 0.17.18 + '@esbuild/linux-arm64': 0.17.18 + '@esbuild/linux-ia32': 0.17.18 + '@esbuild/linux-loong64': 0.17.18 + '@esbuild/linux-mips64el': 0.17.18 + '@esbuild/linux-ppc64': 0.17.18 + '@esbuild/linux-riscv64': 0.17.18 + '@esbuild/linux-s390x': 0.17.18 + '@esbuild/linux-x64': 0.17.18 + '@esbuild/netbsd-x64': 0.17.18 + '@esbuild/openbsd-x64': 0.17.18 + '@esbuild/sunos-x64': 0.17.18 + '@esbuild/win32-arm64': 0.17.18 + '@esbuild/win32-ia32': 0.17.18 + '@esbuild/win32-x64': 0.17.18 + dev: true + + /escalade@3.1.1: + resolution: {integrity: sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==} + engines: {node: '>=6'} dev: true /escape-string-regexp@1.0.5: @@ -1381,8 +1472,8 @@ packages: dev: true patched: true - /eslint-plugin-simple-import-sort@8.0.0(eslint@8.28.0): - resolution: {integrity: sha512-bXgJQ+lqhtQBCuWY/FUWdB27j4+lqcvXv5rUARkzbeWLwea+S5eBZEQrhnO+WgX3ZoJHVj0cn943iyXwByHHQw==} + /eslint-plugin-simple-import-sort@10.0.0(eslint@8.28.0): + resolution: {integrity: sha512-AeTvO9UCMSNzIHRkg8S6c3RPy5YEwKWSQPx3DYghLedo2ZQxowPFLGDN1AZ2evfg6r6mjBSZSLxLFsWSu3acsw==} peerDependencies: eslint: '>=5.0.0' peerDependenciesMeta: @@ -1392,7 +1483,7 @@ packages: eslint: 8.28.0(patch_hash=7wc6icvgtg3uswirb5tpsbjnbe) dev: true - /eslint-plugin-unused-imports@2.0.0(@typescript-eslint/eslint-plugin@5.49.0)(eslint@8.28.0): + /eslint-plugin-unused-imports@2.0.0(@typescript-eslint/eslint-plugin@5.59.1)(eslint@8.28.0): resolution: {integrity: sha512-3APeS/tQlTrFa167ThtP0Zm0vctjr4M44HMpeg1P4bK6wItarumq0Ma82xorMKdFsWpphQBlRPzw/pxiVELX1A==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -1404,7 +1495,7 @@ packages: eslint: optional: true dependencies: - '@typescript-eslint/eslint-plugin': 5.49.0(@typescript-eslint/parser@5.49.0)(eslint@8.28.0)(typescript@4.9.4) + '@typescript-eslint/eslint-plugin': 5.59.1(@typescript-eslint/parser@5.59.1)(eslint@8.28.0)(typescript@5.0.4) eslint: 8.28.0(patch_hash=7wc6icvgtg3uswirb5tpsbjnbe) eslint-rule-composer: 0.3.0 dev: true @@ -1453,6 +1544,11 @@ packages: engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dev: true + /eslint-visitor-keys@3.4.0: + resolution: {integrity: sha512-HPpKPUBQcAsZOsHAFwTtIKcYlCje62XB7SEAcxjtmW6TD1WVpkS6i6/hOVtTZIl4zGj/mBqpFVGvaDneik+VoQ==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + dev: true + /eslint@8.28.0(patch_hash=7wc6icvgtg3uswirb5tpsbjnbe): resolution: {integrity: sha512-S27Di+EVyMxcHiwDrFzk8dJYAaD+/5SoWKxL1ri/71CRHsnJnRDPNt2Kzj24+MT9FDupf4aqqyqPrvI8MvQ4VQ==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -1700,6 +1796,11 @@ packages: resolution: {integrity: sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==} dev: true + /get-caller-file@2.0.5: + resolution: {integrity: sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==} + engines: {node: 6.* || 8.* || >= 10.*} + dev: true + /get-stream@5.2.0: resolution: {integrity: sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA==} engines: {node: '>=8'} @@ -1707,8 +1808,8 @@ packages: pump: 3.0.0 dev: true - /get-tsconfig@4.4.0: - resolution: {integrity: sha512-0Gdjo/9+FzsYhXCEFueo2aY1z1tpXrxWZzP7k8ul9qt1U5o8rYJwTJYmaeHdrVosYIVYkOy2iwCJ9FdpocJhPQ==} + /get-tsconfig@4.5.0: + resolution: {integrity: sha512-MjhiaIWCJ1sAU4pIQ5i5OfOuHHxVo1oYeNsWTON7jxYkod8pHocXeh+SSbmu5OZZZK73B6cbJ2XADzXehLyovQ==} dev: true /get-value@2.0.6: @@ -1852,8 +1953,8 @@ packages: lru-cache: 6.0.0 dev: true - /html-tags@3.2.0: - resolution: {integrity: sha512-vy7ClnArOZwCnqZgvv+ddgHgJiAFXe3Ge9ML5/mBctVJoUoYPCdxVucOywjDARn6CVoh3dRSFdPHy2sX80L0Wg==} + /html-tags@3.3.1: + resolution: {integrity: sha512-ztqyC3kLto0e9WbNp0aeP+M3kTt+nbaIveGmUxAtZa+8iFgKLUOD4YKM5j+f3QD89bra7UeumolZHKuOXnTmeQ==} engines: {node: '>=8'} dev: true @@ -1941,8 +2042,8 @@ packages: resolution: {integrity: sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==} dev: true - /is-core-module@2.11.0: - resolution: {integrity: sha512-RRjxlvLDkD1YJwDbroBHMb+cukurkDWNyHx7D3oNB5x9rb5ogcksMC5wHCadcXoo67gVr/+3GFySh3134zi6rw==} + /is-core-module@2.12.0: + resolution: {integrity: sha512-RECHCBCd/viahWmwj6enj19sKbHfJrddi/6cBDsNTKbNq0f7VeaUkBo60BqzvPqo/W54ChS62Z5qyun7cfOMqQ==} dependencies: has: 1.0.3 dev: true @@ -2126,8 +2227,8 @@ packages: engines: {node: '>=0.10.0'} dev: true - /known-css-properties@0.26.0: - resolution: {integrity: sha512-5FZRzrZzNTBruuurWpvZnvP9pum+fe0HcK8z/ooo+U+Hmp4vtbyp1/QDsqmufirXy4egGzbaH/y2uCZf+6W5Kg==} + /known-css-properties@0.27.0: + resolution: {integrity: sha512-uMCj6+hZYDoffuvAJjFAPz56E9uoowFHmTkqRtRq5WyC5Q6Cu/fTZKNQpX/RbzChBYLLl3lo8CjFZBAZXq9qFg==} dev: true /levn@0.4.1: @@ -2197,6 +2298,10 @@ packages: resolution: {integrity: sha512-APMBEanjybaPzUrfqU0IMU5I0AswKMH7k8OTLs0vvV4KZpExkTkY87nR/zpbuTPj+gARop7aGUbl11pnDfW6xg==} dev: true + /mdn-data@2.0.30: + resolution: {integrity: sha512-GaqWWShW4kv/G9IEucWScBx9G1/vsFZZJUO+tD26M8J8z3Kw5RDQjaoZe03YAClgeS/SWPOcb4nkFBTEi5DUEA==} + dev: true + /meow@9.0.0: resolution: {integrity: sha512-+obSblOQmRhcyBt62furQqRAQpNyWXo8BuQ5bN7dG8wmwQ+vwHKp/rCFD4CrTP8CsDQD1sjoZ94K417XEUk8IQ==} engines: {node: '>=10'} @@ -2248,6 +2353,10 @@ packages: kind-of: 6.0.3 dev: true + /mitt@3.0.0: + resolution: {integrity: sha512-7dX2/10ITVyqh4aOSVI9gdape+t9l2/8QxHrFmUXu4EEUpdlxl6RudZUPZoc+zuY2hk1j7XxVroIVIan/pD/SQ==} + dev: true + /mixin-deep@1.3.2: resolution: {integrity: sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA==} engines: {node: '>=0.10.0'} @@ -2272,8 +2381,8 @@ packages: resolution: {integrity: sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==} dev: true - /nanoid@3.3.4: - resolution: {integrity: sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw==} + /nanoid@3.3.6: + resolution: {integrity: sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==} engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} hasBin: true dev: true @@ -2327,7 +2436,7 @@ packages: resolution: {integrity: sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==} dependencies: hosted-git-info: 2.8.9 - resolve: 1.22.1 + resolve: 1.22.2 semver: 5.7.1 validate-npm-package-license: 3.0.4 dev: true @@ -2337,8 +2446,8 @@ packages: engines: {node: '>=10'} dependencies: hosted-git-info: 4.1.0 - is-core-module: 2.11.0 - semver: 7.3.8 + is-core-module: 2.12.0 + semver: 7.5.0 validate-npm-package-license: 3.0.4 dev: true @@ -2432,7 +2541,7 @@ packages: resolution: {integrity: sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==} engines: {node: '>=8'} dependencies: - '@babel/code-frame': 7.18.6 + '@babel/code-frame': 7.21.4 error-ex: 1.3.2 json-parse-even-better-errors: 2.3.1 lines-and-columns: 1.2.4 @@ -2488,17 +2597,17 @@ packages: resolution: {integrity: sha512-HvExULSwLqHLgUy1rl3ANIqCsvMS0WHss2UOsXhXnQaZ9VCc2oBvIpXrl00IUFT5ZDITME0o6oiXeiHr2SAIfw==} dev: true - /postcss-safe-parser@6.0.0(postcss@8.4.21): + /postcss-safe-parser@6.0.0(postcss@8.4.23): resolution: {integrity: sha512-FARHN8pwH+WiS2OPCxJI8FuRJpTVnn6ZNFiqAM2aeW2LwTHWWmWgIyKC6cUo0L8aeKiF/14MNvnpls6R2PBeMQ==} engines: {node: '>=12.0'} peerDependencies: postcss: ^8.3.3 dependencies: - postcss: 8.4.21 + postcss: 8.4.23 dev: true - /postcss-selector-parser@6.0.11: - resolution: {integrity: sha512-zbARubNdogI9j7WY4nQJBiNqQf3sLS3wCP4WfOidu+p28LofJqDH1tcXypGrcmMHhDk2t9wGhCsYe/+szLTy1g==} + /postcss-selector-parser@6.0.12: + resolution: {integrity: sha512-NdxGCAZdRrwVI1sy59+Wzrh+pMMHxapGnpfenDVlMEXoOcvt4pGE0JLK9YY2F5dLxcFYA/YbVQKhcGU+FtSYQg==} engines: {node: '>=4'} dependencies: cssesc: 3.0.0 @@ -2509,11 +2618,11 @@ packages: resolution: {integrity: sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==} dev: true - /postcss@8.4.21: - resolution: {integrity: sha512-tP7u/Sn/dVxK2NnruI4H9BG+x+Wxz6oeZ1cJ8P6G/PZY0IKk4k/63TDsQf2kQq3+qoJeLm2kIBUNlZe3zgb4Zg==} + /postcss@8.4.23: + resolution: {integrity: sha512-bQ3qMcpF6A/YjR55xtoTr0jGOlnPOKAIMdOWiv0EIT6HVPEaJiJB4NLljSbiHoC2RX7DN5Uvjtpbg1NPdwv1oA==} engines: {node: ^10 || ^12 || >=14} dependencies: - nanoid: 3.3.4 + nanoid: 3.3.6 picocolors: 1.0.0 source-map-js: 1.0.2 dev: true @@ -2523,6 +2632,11 @@ packages: engines: {node: '>= 0.8.0'} dev: true + /progress@2.0.3: + resolution: {integrity: sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==} + engines: {node: '>=0.4.0'} + dev: true + /proxy-from-env@1.1.0: resolution: {integrity: sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==} dev: true @@ -2539,20 +2653,27 @@ packages: engines: {node: '>=6'} dev: true - /puppeteer-core@19.6.0: - resolution: {integrity: sha512-GvqWdHr9eY/MFR5pXf9o0apnrTmG0hhS7/TtCPfeAvCbaUS1bsLMZWxNGvI/QbviRu4xxi6HrR7VW4x/4esq1Q==} - engines: {node: '>=14.1.0'} + /puppeteer-core@19.11.1(typescript@5.0.4): + resolution: {integrity: sha512-qcuC2Uf0Fwdj9wNtaTZ2OvYRraXpAK+puwwVW8ofOhOgLPZyz1c68tsorfIZyCUOpyBisjr+xByu7BMbEYMepA==} + engines: {node: '>=14.14.0'} + peerDependencies: + typescript: '>= 4.7.4' + peerDependenciesMeta: + typescript: + optional: true dependencies: + '@puppeteer/browsers': 0.5.0(typescript@5.0.4) + chromium-bidi: 0.4.7(devtools-protocol@0.0.1107588) cross-fetch: 3.1.5 debug: 4.3.4 - devtools-protocol: 0.0.1082910 + devtools-protocol: 0.0.1107588 extract-zip: 2.0.1 https-proxy-agent: 5.0.1 proxy-from-env: 1.1.0 - rimraf: 3.0.2 tar-fs: 2.1.1 + typescript: 5.0.4 unbzip2-stream: 1.4.3 - ws: 8.11.0 + ws: 8.13.0 transitivePeerDependencies: - bufferutil - encoding @@ -2588,8 +2709,8 @@ packages: type-fest: 0.6.0 dev: true - /readable-stream@3.6.0: - resolution: {integrity: sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==} + /readable-stream@3.6.2: + resolution: {integrity: sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==} engines: {node: '>= 6'} dependencies: inherits: 2.0.4 @@ -2618,6 +2739,11 @@ packages: engines: {node: '>=8'} dev: true + /require-directory@2.1.1: + resolution: {integrity: sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==} + engines: {node: '>=0.10.0'} + dev: true + /require-from-string@2.0.2: resolution: {integrity: sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==} engines: {node: '>=0.10.0'} @@ -2638,11 +2764,11 @@ packages: deprecated: https://github.com/lydell/resolve-url#deprecated dev: true - /resolve@1.22.1: - resolution: {integrity: sha512-nBpuuYuY5jFsli/JIs1oldw6fOQCBioohqWZg/2hiaOybXOft4lonv85uDOKXdf8rhyK159cxU5cDcK/NKk8zw==} + /resolve@1.22.2: + resolution: {integrity: sha512-Sb+mjNHOULsBv818T40qSPeRiuWLyaGMa5ewydRLFimneixmVy2zdivRl+AF6jaYPC8ERxGDmFSiqui6SfPd+g==} hasBin: true dependencies: - is-core-module: 2.11.0 + is-core-module: 2.12.0 path-parse: 1.0.7 supports-preserve-symlinks-flag: 1.0.0 dev: true @@ -2685,16 +2811,8 @@ packages: hasBin: true dev: true - /semver@7.3.7: - resolution: {integrity: sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==} - engines: {node: '>=10'} - hasBin: true - dependencies: - lru-cache: 6.0.0 - dev: true - - /semver@7.3.8: - resolution: {integrity: sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==} + /semver@7.5.0: + resolution: {integrity: sha512-+XC0AD/R7Q2mPSRuy2Id0+CGTZ98+8f+KvwirxOKIEyid+XSx6HbC63p+O4IndTHuX5Z+JxQ0TghCkO5Cg/2HA==} engines: {node: '>=10'} hasBin: true dependencies: @@ -2723,8 +2841,9 @@ packages: engines: {node: '>=8'} dev: true - /signal-exit@3.0.7: - resolution: {integrity: sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==} + /signal-exit@4.0.1: + resolution: {integrity: sha512-uUWsN4aOxJAS8KOuf3QMyFtgm1pkb6I+KRZbRF/ghdf5T7sM+B1lLLzPDxswUjkmHyxQAVzEgG35E3NzDM9GVw==} + engines: {node: '>=14'} dev: true /slash@3.0.0: @@ -2795,11 +2914,11 @@ packages: engines: {node: '>=0.10.0'} dev: true - /spdx-correct@3.1.1: - resolution: {integrity: sha512-cOYcUWwhCuHCXi49RhFRCyJEK3iPj1Ziz9DpViV3tbZOwXD49QzIN3MpOLJNxh2qwq2lJJZaKMVw9qNi4jTC0w==} + /spdx-correct@3.2.0: + resolution: {integrity: sha512-kN9dJbvnySHULIluDHy32WHRUu3Og7B9sbY7tsFLctQkIqnMh3hErYgdMjTYuqmcXX+lK5T1lnUt3G7zNswmZA==} dependencies: spdx-expression-parse: 3.0.1 - spdx-license-ids: 3.0.12 + spdx-license-ids: 3.0.13 dev: true /spdx-exceptions@2.3.0: @@ -2810,11 +2929,11 @@ packages: resolution: {integrity: sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q==} dependencies: spdx-exceptions: 2.3.0 - spdx-license-ids: 3.0.12 + spdx-license-ids: 3.0.13 dev: true - /spdx-license-ids@3.0.12: - resolution: {integrity: sha512-rr+VVSXtRhO4OHbXUiAF7xW3Bo9DuuF6C5jH+q/x15j2jniycgKbxU09Hr0WqlSLUs4i4ltHGXqTe7VHclYWyA==} + /spdx-license-ids@3.0.13: + resolution: {integrity: sha512-XkD+zwiqXHikFZm4AX/7JSCXA98U5Db4AFd5XUg/+9UNtnH75+Z9KxtpYiJZx36mUDVOwH83pl7yvCer6ewM3w==} dev: true /split-string@3.1.0: @@ -2827,7 +2946,7 @@ packages: /standalone-electron-types@1.0.0: resolution: {integrity: sha512-0HOi/tlTz3mjWhsAz4uRbpQcHMZ+ifj1JzWW9nugykOHClBBG77ps8QinrzX1eow4Iw2pnC+RFaSYRgufF4BOg==} dependencies: - '@types/node': 18.11.18 + '@types/node': 18.16.3 dev: true /static-extend@0.1.2: @@ -2876,33 +2995,37 @@ packages: resolution: {integrity: sha512-Dj1Okke1C3uKKwQcetra4jSuk0DqbzbYtXipzFlFMZtowbF1x7BKJwB9AayVMyFARvU8EDrZdcax4At/452cAg==} dev: true - /stylelint-config-recommended@9.0.0(stylelint@14.16.1): - resolution: {integrity: sha512-9YQSrJq4NvvRuTbzDsWX3rrFOzOlYBmZP+o513BJN/yfEmGSr0AxdvrWs0P/ilSpVV/wisamAHu5XSk8Rcf4CQ==} + /stylelint-config-recommended@12.0.0(stylelint@15.6.0): + resolution: {integrity: sha512-x6x8QNARrGO2sG6iURkzqL+Dp+4bJorPMMRNPScdvaUK8PsynriOcMW7AFDKqkWAS5wbue/u8fUT/4ynzcmqdQ==} peerDependencies: - stylelint: ^14.10.0 + stylelint: ^15.5.0 dependencies: - stylelint: 14.16.1 + stylelint: 15.6.0 dev: true - /stylelint-config-standard@29.0.0(stylelint@14.16.1): - resolution: {integrity: sha512-uy8tZLbfq6ZrXy4JKu3W+7lYLgRQBxYTUUB88vPgQ+ZzAxdrvcaSUW9hOMNLYBnwH+9Kkj19M2DHdZ4gKwI7tg==} + /stylelint-config-standard@33.0.0(stylelint@15.6.0): + resolution: {integrity: sha512-eyxnLWoXImUn77+ODIuW9qXBDNM+ALN68L3wT1lN2oNspZ7D9NVGlNHb2QCUn4xDug6VZLsh0tF8NyoYzkgTzg==} peerDependencies: - stylelint: ^14.14.0 + stylelint: ^15.5.0 dependencies: - stylelint: 14.16.1 - stylelint-config-recommended: 9.0.0(stylelint@14.16.1) + stylelint: 15.6.0 + stylelint-config-recommended: 12.0.0(stylelint@15.6.0) dev: true - /stylelint@14.16.1: - resolution: {integrity: sha512-ErlzR/T3hhbV+a925/gbfc3f3Fep9/bnspMiJPorfGEmcBbXdS+oo6LrVtoUZ/w9fqD6o6k7PtUlCOsCRdjX/A==} - engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + /stylelint@15.6.0: + resolution: {integrity: sha512-Cqzpc8tvJm77KaM8qUbhpJ/UYK55Ia0whQXj4b9IId9dlPICO7J8Lyo15SZWiHxKjlvy3p5FQor/3n6i8ignXg==} + engines: {node: ^14.13.1 || >=16.0.0} hasBin: true dependencies: - '@csstools/selector-specificity': 2.1.1(postcss-selector-parser@6.0.11)(postcss@8.4.21) + '@csstools/css-parser-algorithms': 2.1.1(@csstools/css-tokenizer@2.1.1) + '@csstools/css-tokenizer': 2.1.1 + '@csstools/media-query-list-parser': 2.0.4(@csstools/css-parser-algorithms@2.1.1)(@csstools/css-tokenizer@2.1.1) + '@csstools/selector-specificity': 2.2.0(postcss-selector-parser@6.0.12) balanced-match: 2.0.0 colord: 2.9.3 - cosmiconfig: 7.1.0 + cosmiconfig: 8.1.3 css-functions-list: 3.1.0 + css-tree: 2.3.1 debug: 4.3.4 fast-glob: 3.2.12 fastest-levenshtein: 1.0.16 @@ -2910,32 +3033,32 @@ packages: global-modules: 2.0.0 globby: 11.1.0 globjoin: 0.1.4 - html-tags: 3.2.0 + html-tags: 3.3.1 ignore: 5.2.4 import-lazy: 4.0.0 imurmurhash: 0.1.4 is-plain-object: 5.0.0 - known-css-properties: 0.26.0 + known-css-properties: 0.27.0 mathml-tag-names: 2.1.3 meow: 9.0.0 micromatch: 4.0.5 normalize-path: 3.0.0 picocolors: 1.0.0 - postcss: 8.4.21 + postcss: 8.4.23 postcss-media-query-parser: 0.2.3 postcss-resolve-nested-selector: 0.1.1 - postcss-safe-parser: 6.0.0(postcss@8.4.21) - postcss-selector-parser: 6.0.11 + postcss-safe-parser: 6.0.0(postcss@8.4.23) + postcss-selector-parser: 6.0.12 postcss-value-parser: 4.2.0 resolve-from: 5.0.0 string-width: 4.2.3 strip-ansi: 6.0.1 style-search: 0.1.0 - supports-hyperlinks: 2.3.0 + supports-hyperlinks: 3.0.0 svg-tags: 1.0.0 table: 6.8.1 v8-compile-cache: 2.3.0 - write-file-atomic: 4.0.2 + write-file-atomic: 5.0.1 transitivePeerDependencies: - supports-color dev: true @@ -2954,9 +3077,9 @@ packages: has-flag: 4.0.0 dev: true - /supports-hyperlinks@2.3.0: - resolution: {integrity: sha512-RpsAZlpWcDwOPQA22aCH4J0t7L8JmAvsCxfOSEwm7cQs3LshN36QaTkwd70DnBOXDWGssw2eUoc8CaRWT0XunA==} - engines: {node: '>=8'} + /supports-hyperlinks@3.0.0: + resolution: {integrity: sha512-QBDPHyPQDRTy9ku4URNGY5Lah8PAaXs6tAAwp55sL5WCsSW7GIfdf6W5ixfziW+t7wh3GVvHyHHyQ1ESsoRvaA==} + engines: {node: '>=14.18'} dependencies: has-flag: 4.0.0 supports-color: 7.2.0 @@ -2999,7 +3122,7 @@ packages: end-of-stream: 1.4.4 fs-constants: 1.0.0 inherits: 2.0.4 - readable-stream: 3.6.0 + readable-stream: 3.6.2 dev: true /text-table@0.2.0: @@ -3047,18 +3170,18 @@ packages: resolution: {integrity: sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==} dev: true - /tsutils@3.21.0(typescript@4.9.4): + /tsutils@3.21.0(typescript@5.0.4): resolution: {integrity: sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==} engines: {node: '>= 6'} peerDependencies: typescript: '>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta' dependencies: tslib: 1.14.1 - typescript: 4.9.4 + typescript: 5.0.4 dev: true - /tsx@3.12.6: - resolution: {integrity: sha512-q93WgS3lBdHlPgS0h1i+87Pt6n9K/qULIMNYZo07nSeu2z5QE2CellcAZfofVXBo2tQg9av2ZcRMQ2S2i5oadQ==} + /tsx@3.12.7: + resolution: {integrity: sha512-C2Ip+jPmqKd1GWVQDvz/Eyc6QJbGfE7NrR3fx5BpEHMZsEHoIxHL1j+lKdGobr8ovEyqeNkPLSKp6SCSOt7gmw==} hasBin: true dependencies: '@esbuild-kit/cjs-loader': 2.4.2 @@ -3095,14 +3218,14 @@ packages: engines: {node: '>=8'} dev: true - /type-fest@3.5.3: - resolution: {integrity: sha512-V2+og4j/rWReWvaFrse3s9g2xvUv/K9Azm/xo6CjIuq7oeGqsoimC7+9/A3tfvNcbQf8RPSVj/HV81fB4DJrjA==} + /type-fest@3.9.0: + resolution: {integrity: sha512-hR8JP2e8UiH7SME5JZjsobBlEiatFoxpzCP+R3ZeCo7kAaG1jXQE5X/buLzogM6GJu8le9Y4OcfNuIQX0rZskA==} engines: {node: '>=14.16'} dev: true - /typescript@4.9.4: - resolution: {integrity: sha512-Uz+dTXYzxXXbsFpM86Wh3dKCxrQqUcVMxwU54orwlJjOpO3ao8L7j5lH+dWfTwgCwIuM9GQ2kvVotzYJMXTBZg==} - engines: {node: '>=4.2.0'} + /typescript@5.0.4: + resolution: {integrity: sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==} + engines: {node: '>=12.20'} hasBin: true dev: true @@ -3158,7 +3281,7 @@ packages: /validate-npm-package-license@3.0.4: resolution: {integrity: sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==} dependencies: - spdx-correct: 3.1.1 + spdx-correct: 3.2.0 spdx-expression-parse: 3.0.1 dev: true @@ -3205,24 +3328,33 @@ packages: engines: {node: '>=0.10.0'} dev: true + /wrap-ansi@7.0.0: + resolution: {integrity: sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==} + engines: {node: '>=10'} + dependencies: + ansi-styles: 4.3.0 + string-width: 4.2.3 + strip-ansi: 6.0.1 + dev: true + /wrappy@1.0.2: resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==} dev: true - /write-file-atomic@4.0.2: - resolution: {integrity: sha512-7KxauUdBmSdWnmpaGFg+ppNjKF8uNLry8LyzjauQDOVONfFLNKrKvQOxZ/VuTIcS/gge/YNahf5RIIQWTSarlg==} - engines: {node: ^12.13.0 || ^14.15.0 || >=16.0.0} + /write-file-atomic@5.0.1: + resolution: {integrity: sha512-+QU2zd6OTD8XWIJCbffaiQeH9U73qIqafo1x6V1snCWYGJf6cVE0cDR4D8xRzcEnfI21IFrUPzPGtcPf8AC+Rw==} + engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} dependencies: imurmurhash: 0.1.4 - signal-exit: 3.0.7 + signal-exit: 4.0.1 dev: true - /ws@8.11.0: - resolution: {integrity: sha512-HPG3wQd9sNQoT9xHyNCXoDUa+Xw/VevmY9FoHyQ+g+rrMn4j6FB4np7Z0OhdTgjx6MgQLK7jwSy1YecU1+4Asg==} + /ws@8.13.0: + resolution: {integrity: sha512-x9vcZYTrFPC7aSIbj7sRCYo7L/Xb8Iy+pW0ng0wt2vCJv7M9HOMy0UoN3rr+IFC7hb7vXoqS+P9ktyLLLhO+LA==} engines: {node: '>=10.0.0'} peerDependencies: bufferutil: ^4.0.1 - utf-8-validate: ^5.0.2 + utf-8-validate: '>=5.0.2' peerDependenciesMeta: bufferutil: optional: true @@ -3230,13 +3362,13 @@ packages: optional: true dev: true - /yallist@4.0.0: - resolution: {integrity: sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==} + /y18n@5.0.8: + resolution: {integrity: sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==} + engines: {node: '>=10'} dev: true - /yaml@1.10.2: - resolution: {integrity: sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==} - engines: {node: '>= 6'} + /yallist@4.0.0: + resolution: {integrity: sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==} dev: true /yargs-parser@20.2.9: @@ -3244,6 +3376,24 @@ packages: engines: {node: '>=10'} dev: true + /yargs-parser@21.1.1: + resolution: {integrity: sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==} + engines: {node: '>=12'} + dev: true + + /yargs@17.7.1: + resolution: {integrity: sha512-cwiTb08Xuv5fqF4AovYacTFNxk62th7LKJ6BL9IGUpTJrWoU7/7WdQGTP2SjKf1dUNBGzDd28p/Yfs/GI6JrLw==} + engines: {node: '>=12'} + dependencies: + cliui: 8.0.1 + escalade: 3.1.1 + get-caller-file: 2.0.5 + require-directory: 2.1.1 + string-width: 4.2.3 + y18n: 5.0.8 + yargs-parser: 21.1.1 + dev: true + /yauzl@2.10.0: resolution: {integrity: sha512-p4a9I6X6nu6IhoGmBqAcbJy1mlC4j27vEPZX9F4L4/vZT3Lyq1VkFHw/V/PUcB9Buo+DG3iHkT0x3Qya58zc3g==} dependencies: diff --git a/scripts/generatePluginList.ts b/scripts/generatePluginList.ts index e4ae20ad8..8442e4290 100644 --- a/scripts/generatePluginList.ts +++ b/scripts/generatePluginList.ts @@ -29,6 +29,7 @@ interface Dev { interface PluginData { name: string; description: string; + tags: string[]; authors: Dev[]; dependencies: string[]; hasPatches: boolean; @@ -106,6 +107,7 @@ async function parseFile(fileName: string) { hasCommands: false, enabledByDefault: false, required: false, + tags: [] as string[] } as PluginData; for (const prop of pluginObj.properties) { @@ -131,6 +133,13 @@ async function parseFile(fileName: string) { return devs[getName(e)!]; }); break; + case "tags": + if (!isArrayLiteralExpression(value)) throw fail("tags is not an array literal"); + data.tags = value.elements.map(e => { + if (!isStringLiteral(e)) throw fail("tags array contains non-string literals"); + return e.text; + }); + break; case "dependencies": if (!isArrayLiteralExpression(value)) throw fail("dependencies is not an array literal"); const { elements } = value; diff --git a/scripts/generateReport.ts b/scripts/generateReport.ts index b5e705bdc..90449657c 100644 --- a/scripts/generateReport.ts +++ b/scripts/generateReport.ts @@ -130,7 +130,7 @@ async function printReport() { }, { title: "Discord Errors", - description: toCodeBlock(report.otherErrors.join("\n")), + description: report.otherErrors.length ? toCodeBlock(report.otherErrors.join("\n")) : "None", color: report.otherErrors.length ? 0xff0000 : 0x00ff00 } ] @@ -194,9 +194,10 @@ page.on("console", async e => { return a.toString(); } }) - ).then(a => a.join(" ")); + ).then(a => a.join(" ").trim()); - if (!text.startsWith("Failed to load resource: the server responded with a status of")) { + + if (text.length && !text.startsWith("Failed to load resource: the server responded with a status of")) { console.error("Got unexpected error", text); report.otherErrors.push(text); } @@ -233,7 +234,7 @@ function runTime(token: string) { // Needs native server to run if (p.name === "WebRichPresence (arRPC)") return; - p.required = true; + Vencord.Settings.plugins[p.name].enabled = true; p.patches?.forEach(patch => { patch.plugin = p.name; delete patch.predicate; @@ -267,7 +268,7 @@ function runTime(token: string) { if (!isWasm) await wreq.e(id as any); - await new Promise(r => setTimeout(r, 500)); + await new Promise(r => setTimeout(r, 150)); } console.error("[PUP_DEBUG]", "Finished loading chunks!"); diff --git a/src/Vencord.ts b/src/Vencord.ts index ad793456e..a05ec5383 100644 --- a/src/Vencord.ts +++ b/src/Vencord.ts @@ -28,17 +28,15 @@ import "./utils/quickCss"; import "./webpack/patchWebpack"; import { showNotification } from "./api/Notifications"; -import { PlainSettings, Settings } from "./api/settings"; +import { PlainSettings, Settings } from "./api/Settings"; import { patches, PMLogger, startAllPlugins } from "./plugins"; import { localStorage } from "./utils/localStorage"; import { relaunch } from "./utils/native"; import { getCloudSettings, putCloudSettings } from "./utils/settingsSync"; -import { checkForUpdates, rebuild, update, UpdateLogger } from "./utils/updater"; +import { checkForUpdates, update, UpdateLogger } from "./utils/updater"; import { onceReady } from "./webpack"; import { SettingsRouter } from "./webpack/common"; -export let Components: any; - async function syncSettings() { if ( Settings.cloud.settingsSync && // if it's enabled @@ -65,7 +63,6 @@ async function syncSettings() { async function init() { await onceReady; startAllPlugins(); - Components = await import("./components"); syncSettings(); @@ -76,7 +73,6 @@ async function init() { if (Settings.autoUpdate) { await update(); - await rebuild(); if (Settings.autoUpdateNotification) setTimeout(() => showNotification({ title: "Vencord has been updated!", diff --git a/src/VencordNative.ts b/src/VencordNative.ts index 3cd53e188..02de74f66 100644 --- a/src/VencordNative.ts +++ b/src/VencordNative.ts @@ -16,34 +16,46 @@ * along with this program. If not, see . */ -import IPC_EVENTS from "@utils/IpcEvents"; -import { IpcRenderer, ipcRenderer } from "electron"; +import { IpcEvents } from "@utils/IpcEvents"; +import { IpcRes } from "@utils/types"; +import { ipcRenderer } from "electron"; -function assertEventAllowed(event: string) { - if (!(event in IPC_EVENTS)) throw new Error(`Event ${event} not allowed.`); +function invoke(event: IpcEvents, ...args: any[]) { + return ipcRenderer.invoke(event, ...args) as Promise; } + +export function sendSync(event: IpcEvents, ...args: any[]) { + return ipcRenderer.sendSync(event, ...args) as T; +} + export default { - getVersions: () => process.versions, - ipc: { - send(event: string, ...args: any[]) { - assertEventAllowed(event); - ipcRenderer.send(event, ...args); + updater: { + getUpdates: () => invoke[]>>(IpcEvents.GET_UPDATES), + update: () => invoke>(IpcEvents.UPDATE), + rebuild: () => invoke>(IpcEvents.BUILD), + getRepo: () => invoke>(IpcEvents.GET_REPO), + }, + + settings: { + get: () => sendSync(IpcEvents.GET_SETTINGS), + set: (settings: string) => invoke(IpcEvents.SET_SETTINGS, settings), + getSettingsDir: () => invoke(IpcEvents.GET_SETTINGS_DIR), + }, + + quickCss: { + get: () => invoke(IpcEvents.GET_QUICK_CSS), + set: (css: string) => invoke(IpcEvents.SET_QUICK_CSS, css), + + addChangeListener(cb: (newCss: string) => void) { + ipcRenderer.on(IpcEvents.QUICK_CSS_UPDATE, (_, css) => cb(css)); }, - sendSync(event: string, ...args: any[]): T { - assertEventAllowed(event); - return ipcRenderer.sendSync(event, ...args); - }, - on(event: string, listener: Parameters[1]) { - assertEventAllowed(event); - ipcRenderer.on(event, listener); - }, - off(event: string, listener: Parameters[1]) { - assertEventAllowed(event); - ipcRenderer.off(event, listener); - }, - invoke(event: string, ...args: any[]): Promise { - assertEventAllowed(event); - return ipcRenderer.invoke(event, ...args); - } - } + + openFile: () => invoke(IpcEvents.OPEN_QUICKCSS), + openEditor: () => invoke(IpcEvents.OPEN_MONACO_EDITOR), + }, + + native: { + getVersions: () => process.versions as Partial, + openExternal: (url: string) => invoke(IpcEvents.OPEN_EXTERNAL, url) + }, }; diff --git a/src/api/Badges.ts b/src/api/Badges.ts index 9abaefe2b..a0961c46d 100644 --- a/src/api/Badges.ts +++ b/src/api/Badges.ts @@ -79,8 +79,8 @@ export function _getBadges(args: BadgeUserArgs) { : badges.push({ ...badge, ...args }); } } - const donorBadge = (Plugins.BadgeAPI as any).getDonorBadge(args.user.id); - if (donorBadge) badges.unshift(donorBadge); + const donorBadges = (Plugins.BadgeAPI as unknown as typeof import("../plugins/apiBadges").default).getDonorBadges(args.user.id); + if (donorBadges) badges.unshift(...donorBadges); return badges; } diff --git a/src/api/Commands/index.ts b/src/api/Commands/index.ts index 3f639a18a..ef4db171c 100644 --- a/src/api/Commands/index.ts +++ b/src/api/Commands/index.ts @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import { makeCodeblock } from "@utils/misc"; +import { makeCodeblock } from "@utils/text"; import { sendBotMessage } from "./commandHelpers"; import { ApplicationCommandInputType, ApplicationCommandOptionType, ApplicationCommandType, Argument, Command, CommandContext, Option } from "./types"; diff --git a/src/api/ContextMenu.ts b/src/api/ContextMenu.ts index 4d1d577b4..156ae209a 100644 --- a/src/api/ContextMenu.ts +++ b/src/api/ContextMenu.ts @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import Logger from "@utils/Logger"; +import { Logger } from "@utils/Logger"; import type { ReactElement } from "react"; type ContextMenuPatchCallbackReturn = (() => void) | void; @@ -25,14 +25,14 @@ type ContextMenuPatchCallbackReturn = (() => void) | void; * @param args Any arguments passed into making the context menu, like the guild, channel, user or message for example * @returns A callback which is only ran once used to modify the context menu elements (Use to avoid duplicates) */ -export type NavContextMenuPatchCallback = (children: Array, ...args: Array) => ContextMenuPatchCallbackReturn; +export type NavContextMenuPatchCallback = (children: Array, ...args: Array) => ContextMenuPatchCallbackReturn; /** * @param navId The navId of the context menu being patched * @param children The rendered context menu elements * @param args Any arguments passed into making the context menu, like the guild, channel, user or message for example * @returns A callback which is only ran once used to modify the context menu elements (Use to avoid duplicates) */ -export type GlobalContextMenuPatchCallback = (navId: string, children: Array, ...args: Array) => ContextMenuPatchCallbackReturn; +export type GlobalContextMenuPatchCallback = (navId: string, children: Array, ...args: Array) => ContextMenuPatchCallbackReturn; const ContextMenuLogger = new Logger("ContextMenu"); @@ -89,15 +89,18 @@ export function removeGlobalContextMenuPatch(patch: GlobalContextMenuPatchCallba } /** - * A helper function for finding the children array of a group nested inside a context menu based on the id of one of its childs - * @param id The id of the child + * A helper function for finding the children array of a group nested inside a context menu based on the id(s) of its children + * @param id The id of the child. If an array is specified, all ids will be tried * @param children The context menu children */ -export function findGroupChildrenByChildId(id: string, children: Array, _itemsArray?: Array): Array | null { +export function findGroupChildrenByChildId(id: string | string[], children: Array, _itemsArray?: Array): Array | null { for (const child of children) { if (child == null) continue; - if (child.props?.id === id) return _itemsArray ?? null; + if ( + (Array.isArray(id) && id.some(id => child.props?.id === id)) + || child.props?.id === id + ) return _itemsArray ?? null; let nextChildren = child.props?.children; if (nextChildren) { @@ -117,7 +120,7 @@ export function findGroupChildrenByChildId(id: string, children: Array; navId: string; - children: Array; + children: Array; "aria-label": string; onSelect: (() => void) | undefined; onClose: (callback: (...args: Array) => any) => void; diff --git a/src/api/MessageEvents.ts b/src/api/MessageEvents.ts index aaf8d40b6..341b4e678 100644 --- a/src/api/MessageEvents.ts +++ b/src/api/MessageEvents.ts @@ -16,30 +16,61 @@ * along with this program. If not, see . */ -import Logger from "@utils/Logger"; +import { Logger } from "@utils/Logger"; import { MessageStore } from "@webpack/common"; +import { CustomEmoji } from "@webpack/types"; import type { Channel, Message } from "discord-types/general"; import type { Promisable } from "type-fest"; const MessageEventsLogger = new Logger("MessageEvents", "#e5c890"); -export interface Emoji { - require_colons: boolean, - originalName: string, - animated: boolean; - guildId: string, - name: string, - url: string, - id: string, -} - export interface MessageObject { content: string, - validNonShortcutEmojis: Emoji[]; + validNonShortcutEmojis: CustomEmoji[]; + invalidEmojis: any[]; + tts: boolean; +} + +export interface Upload { + classification: string; + currentSize: number; + description: string | null; + filename: string; + id: string; + isImage: boolean; + isVideo: boolean; + item: { + file: File; + platform: number; + }; + loaded: number; + mimeType: string; + preCompressionSize: number; + responseUrl: string; + sensitive: boolean; + showLargeMessageDialog: boolean; + spoiler: boolean; + status: "NOT_STARTED" | "STARTED" | "UPLOADING" | "ERROR" | "COMPLETED" | "CANCELLED"; + uniqueId: string; + uploadedFilename: string; +} + +export interface MessageReplyOptions { + messageReference: Message["messageReference"]; + allowedMentions?: { + parse: Array; + repliedUser: boolean; + }; } export interface MessageExtra { - stickerIds?: string[]; + stickers?: string[]; + uploads?: Upload[]; + replyOptions: MessageReplyOptions; + content: string; + channel: Channel; + type?: any; + openWarningPopout: (props: any) => any; } export type SendListener = (channelId: string, messageObj: MessageObject, extra: MessageExtra) => Promisable; @@ -48,7 +79,8 @@ export type EditListener = (channelId: string, messageId: string, messageObj: Me const sendListeners = new Set(); const editListeners = new Set(); -export async function _handlePreSend(channelId: string, messageObj: MessageObject, extra: MessageExtra) { +export async function _handlePreSend(channelId: string, messageObj: MessageObject, extra: MessageExtra, replyOptions: MessageReplyOptions) { + extra.replyOptions = replyOptions; for (const listener of sendListeners) { try { const result = await listener(channelId, messageObj, extra); diff --git a/src/api/MessagePopover.ts b/src/api/MessagePopover.ts index 85dff9cf5..3391cfb38 100644 --- a/src/api/MessagePopover.ts +++ b/src/api/MessagePopover.ts @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import Logger from "@utils/Logger"; +import { Logger } from "@utils/Logger"; import { Channel, Message } from "discord-types/general"; import type { MouseEventHandler } from "react"; diff --git a/src/api/Notifications/NotificationComponent.tsx b/src/api/Notifications/NotificationComponent.tsx index 542c29bbf..caa4b64ef 100644 --- a/src/api/Notifications/NotificationComponent.tsx +++ b/src/api/Notifications/NotificationComponent.tsx @@ -18,7 +18,7 @@ import "./styles.css"; -import { useSettings } from "@api/settings"; +import { useSettings } from "@api/Settings"; import ErrorBoundary from "@components/ErrorBoundary"; import { classes } from "@utils/misc"; import { React, useEffect, useMemo, useState, useStateFromStores, WindowStore } from "@webpack/common"; diff --git a/src/api/Notifications/Notifications.tsx b/src/api/Notifications/Notifications.tsx index 600ea63d1..602564671 100644 --- a/src/api/Notifications/Notifications.tsx +++ b/src/api/Notifications/Notifications.tsx @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import { Settings } from "@api/settings"; +import { Settings } from "@api/Settings"; import { Queue } from "@utils/Queue"; import { ReactDOM } from "@webpack/common"; import type { ReactNode } from "react"; diff --git a/src/api/Notifications/notificationLog.tsx b/src/api/Notifications/notificationLog.tsx index 72f09ac2f..9535fb62c 100644 --- a/src/api/Notifications/notificationLog.tsx +++ b/src/api/Notifications/notificationLog.tsx @@ -17,10 +17,10 @@ */ import * as DataStore from "@api/DataStore"; -import { Settings } from "@api/settings"; +import { Settings } from "@api/Settings"; import { classNameFactory } from "@api/Styles"; -import { useAwaiter } from "@utils/misc"; import { closeModal, ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, ModalSize, openModal } from "@utils/modal"; +import { useAwaiter } from "@utils/react"; import { Alerts, Button, Forms, moment, React, Text, Timestamp, useEffect, useReducer, useState } from "@webpack/common"; import { nanoid } from "nanoid"; import type { DispatchWithoutAction } from "react"; diff --git a/src/api/ServerList.ts b/src/api/ServerList.ts index c98b1740c..480441391 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 similarity index 96% rename from src/api/settings.ts rename to src/api/Settings.ts index 35381d88a..e481e48c0 100644 --- a/src/api/settings.ts +++ b/src/api/Settings.ts @@ -17,9 +17,8 @@ */ import { debounce } from "@utils/debounce"; -import IpcEvents from "@utils/IpcEvents"; import { localStorage } from "@utils/localStorage"; -import Logger from "@utils/Logger"; +import { Logger } from "@utils/Logger"; import { mergeDefaults } from "@utils/misc"; import { putCloudSettings } from "@utils/settingsSync"; import { DefinedSettings, OptionType, SettingsChecks, SettingsDefinition } from "@utils/types"; @@ -94,7 +93,7 @@ const DefaultSettings: Settings = { }; try { - var settings = JSON.parse(VencordNative.ipc.sendSync(IpcEvents.GET_SETTINGS)) as Settings; + var settings = JSON.parse(VencordNative.settings.get()) as Settings; mergeDefaults(settings, DefaultSettings); } catch (err) { var settings = mergeDefaults({} as Settings, DefaultSettings); @@ -173,7 +172,7 @@ function makeProxy(settings: any, root = settings, path = ""): Settings { PlainSettings.cloud.settingsSyncVersion = Date.now(); localStorage.Vencord_settingsDirty = true; saveSettingsOnFrequentAction(); - VencordNative.ipc.invoke(IpcEvents.SET_SETTINGS, JSON.stringify(root, null, 4)); + VencordNative.settings.set(JSON.stringify(root, null, 4)); return true; } }); @@ -249,10 +248,7 @@ export function migratePluginSettings(name: string, ...oldNames: string[]) { logger.info(`Migrating settings from old name ${oldName} to ${name}`); plugins[name] = plugins[oldName]; delete plugins[oldName]; - VencordNative.ipc.invoke( - IpcEvents.SET_SETTINGS, - JSON.stringify(settings, null, 4) - ); + VencordNative.settings.set(JSON.stringify(settings, null, 4)); break; } } diff --git a/src/api/SettingsStore.ts b/src/api/SettingsStore.ts index a5a0402cc..d9369a956 100644 --- a/src/api/SettingsStore.ts +++ b/src/api/SettingsStore.ts @@ -16,11 +16,11 @@ * along with this program. If not, see . */ -import Logger from "@utils/Logger"; -import { proxyLazy } from "@utils/proxyLazy"; +import { proxyLazy } from "@utils/lazy"; +import { Logger } from "@utils/Logger"; import { findModuleId, wreq } from "@webpack"; -import { Settings } from "./settings"; +import { Settings } from "./Settings"; interface Setting { /** diff --git a/src/api/index.ts b/src/api/index.ts index ba2978ee6..f2c47e559 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -28,6 +28,7 @@ import * as $MessagePopover from "./MessagePopover"; import * as $Notices from "./Notices"; import * as $Notifications from "./Notifications"; import * as $ServerList from "./ServerList"; +import * as $Settings from "./Settings"; import * as $SettingsStore from "./SettingsStore"; import * as $Styles from "./Styles"; @@ -86,6 +87,10 @@ export const MessageDecorations = $MessageDecorations; * An API allowing you to add components to member list users, in both DM's and servers */ export const MemberListDecorators = $MemberListDecorators; +/** + * An API allowing you to persist data + */ +export const Settings = $Settings; /** * An API allowing you to read, manipulate and automatically update components based on Discord settings */ diff --git a/src/components/DonateButton.tsx b/src/components/DonateButton.tsx index 49f079b4f..c027fcf27 100644 --- a/src/components/DonateButton.tsx +++ b/src/components/DonateButton.tsx @@ -16,7 +16,6 @@ * along with this program. If not, see . */ -import IpcEvents from "@utils/IpcEvents"; import { Button } from "@webpack/common"; import { Heart } from "./Heart"; @@ -27,9 +26,7 @@ export default function DonateButton(props: any) { {...props} look={Button.Looks.LINK} color={Button.Colors.TRANSPARENT} - onClick={() => - VencordNative.ipc.invoke(IpcEvents.OPEN_EXTERNAL, "https://github.com/sponsors/Vendicated") - } + onClick={() => VencordNative.native.openExternal("https://github.com/sponsors/Vendicated")} > Donate diff --git a/src/components/ErrorBoundary.tsx b/src/components/ErrorBoundary.tsx index c34b47d20..ea2e02b51 100644 --- a/src/components/ErrorBoundary.tsx +++ b/src/components/ErrorBoundary.tsx @@ -16,9 +16,9 @@ * along with this program. If not, see . */ -import Logger from "@utils/Logger"; +import { Logger } from "@utils/Logger"; import { Margins } from "@utils/margins"; -import { LazyComponent } from "@utils/misc"; +import { LazyComponent } from "@utils/react"; import { React } from "@webpack/common"; import { ErrorCard } from "./ErrorCard"; diff --git a/src/components/Icons.tsx b/src/components/Icons.tsx new file mode 100644 index 000000000..4227fcea2 --- /dev/null +++ b/src/components/Icons.tsx @@ -0,0 +1,148 @@ +/* + * 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 "./iconStyles.css"; + +import { classes } from "@utils/misc"; +import { i18n } from "@webpack/common"; +import type { PropsWithChildren, SVGProps } from "react"; + +interface BaseIconProps extends IconProps { + viewBox: string; +} + +interface IconProps extends SVGProps { + className?: string; + height?: number; + width?: number; +} + +function Icon({ height = 24, width = 24, className, children, viewBox, ...svgProps }: PropsWithChildren) { + return ( + + {children} + + ); +} + +/** + * Discord's link icon, as seen in the Message context menu "Copy Message Link" option + */ +export function LinkIcon({ height = 24, width = 24, className }: IconProps) { + return ( + + + + + + + ); +} + +/** + * Discord's copy icon, as seen in the user popout right of the username when clicking + * your own username in the bottom left user panel + */ +export function CopyIcon(props: IconProps) { + return ( + + + + + + + ); +} + +/** + * Discord's open external icon, as seen in the user profile connections + */ +export function OpenExternalIcon(props: IconProps) { + return ( + + + + ); +} + +export function ImageIcon(props: IconProps) { + return ( + + + + ); +} + +export function InfoIcon(props: IconProps) { + return ( + + + + ); +} + +export function OwnerCrownIcon(props: IconProps) { + return ( + + + + ); +} diff --git a/src/components/Monaco.ts b/src/components/Monaco.ts deleted file mode 100644 index 59ed7bbba..000000000 --- a/src/components/Monaco.ts +++ /dev/null @@ -1,51 +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 { debounce } from "@utils/debounce"; -import IpcEvents from "@utils/IpcEvents"; -import { Queue } from "@utils/Queue"; -import { find } from "@webpack"; - -import monacoHtml from "~fileContent/monacoWin.html"; - -const queue = new Queue(); -const setCss = debounce((css: string) => { - queue.push(() => VencordNative.ipc.invoke(IpcEvents.SET_QUICK_CSS, css)); -}); - -export async function launchMonacoEditor() { - const features = `popup,width=${Math.min(window.innerWidth, 1000)},height=${Math.min(window.innerHeight, 1000)}`; - const win = open("about:blank", "VencordQuickCss", features); - if (!win) { - alert("Failed to open QuickCSS popup. Make sure to allow popups!"); - return; - } - - win.setCss = setCss; - win.getCurrentCss = () => VencordNative.ipc.invoke(IpcEvents.GET_QUICK_CSS); - win.getTheme = () => - find(m => - m.ProtoClass?.typeName.endsWith("PreloadedUserSettings") - )?.getCurrentValue()?.appearance?.theme === 2 - ? "vs-light" - : "vs-dark"; - - win.document.write(monacoHtml); - - window.__VENCORD_MONACO_WIN__ = new WeakRef(win); -} diff --git a/src/components/PluginSettings/PluginModal.tsx b/src/components/PluginSettings/PluginModal.tsx index 6240c17ff..1818a8bcf 100644 --- a/src/components/PluginSettings/PluginModal.tsx +++ b/src/components/PluginSettings/PluginModal.tsx @@ -17,13 +17,14 @@ */ import { generateId } from "@api/Commands"; -import { useSettings } from "@api/settings"; +import { useSettings } from "@api/Settings"; import ErrorBoundary from "@components/ErrorBoundary"; import { Flex } from "@components/Flex"; +import { proxyLazy } from "@utils/lazy"; import { Margins } from "@utils/margins"; -import { classes, LazyComponent } from "@utils/misc"; +import { classes } from "@utils/misc"; import { ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, ModalSize } from "@utils/modal"; -import { proxyLazy } from "@utils/proxyLazy"; +import { LazyComponent } from "@utils/react"; import { OptionType, Plugin } from "@utils/types"; import { findByCode, findByPropsLazy } from "@webpack"; import { Button, FluxDispatcher, Forms, React, Text, Tooltip, UserStore, UserUtils } from "@webpack/common"; @@ -128,6 +129,8 @@ export default function PluginModal({ plugin, onRestartNeeded, onClose, transiti return There are no settings for this plugin.; } else { const options = Object.entries(plugin.options).map(([key, setting]) => { + if (setting.hidden) return null; + function onChange(newValue: any) { setTempSettings(s => ({ ...s, [key]: newValue })); } @@ -150,7 +153,7 @@ export default function PluginModal({ plugin, onRestartNeeded, onClose, transiti ); }); - return {options}; + return {options}; } } @@ -180,7 +183,7 @@ export default function PluginModal({ plugin, onRestartNeeded, onClose, transiti {plugin.name} - + About {plugin.name} {plugin.description} diff --git a/src/components/PluginSettings/index.tsx b/src/components/PluginSettings/index.tsx index f3a5cd386..e1b36ef25 100644 --- a/src/components/PluginSettings/index.tsx +++ b/src/components/PluginSettings/index.tsx @@ -20,19 +20,19 @@ import "./styles.css"; import * as DataStore from "@api/DataStore"; import { showNotice } from "@api/Notices"; -import { useSettings } from "@api/settings"; +import { Settings, useSettings } from "@api/Settings"; import { classNameFactory } from "@api/Styles"; -import ErrorBoundary from "@components/ErrorBoundary"; import { Flex } from "@components/Flex"; -import { handleComponentFailed } from "@components/handleComponentFailed"; import { Badge } from "@components/PluginSettings/components"; import PluginModal from "@components/PluginSettings/PluginModal"; import { Switch } from "@components/Switch"; +import { SettingsTab } from "@components/VencordSettings/shared"; import { ChangeList } from "@utils/ChangeList"; -import Logger from "@utils/Logger"; +import { Logger } from "@utils/Logger"; import { Margins } from "@utils/margins"; -import { classes, LazyComponent, useAwaiter } from "@utils/misc"; +import { classes } from "@utils/misc"; import { openModalLazy } from "@utils/modal"; +import { LazyComponent, useAwaiter } from "@utils/react"; import { Plugin } from "@utils/types"; import { findByCode, findByPropsLazy } from "@webpack"; import { Alerts, Button, Card, Forms, Parser, React, Select, Text, TextInput, Toasts, Tooltip } from "@webpack/common"; @@ -94,7 +94,7 @@ interface PluginCardProps extends React.HTMLProps { } function PluginCard({ plugin, disabled, onRestartNeeded, onMouseEnter, onMouseLeave, isNew }: PluginCardProps) { - const settings = useSettings([`plugins.${plugin.name}.enabled`]).plugins[plugin.name]; + const settings = Settings.plugins[plugin.name]; const isEnabled = () => settings.enabled ?? false; @@ -125,7 +125,7 @@ function PluginCard({ plugin, disabled, onRestartNeeded, onMouseEnter, onMouseLe } // if the plugin has patches, dont use stopPlugin/startPlugin. Wait for restart to apply changes. - if (plugin.patches) { + if (plugin.patches?.length) { settings.enabled = !wasEnabled; onRestartNeeded(plugin.name); return; @@ -177,7 +177,7 @@ enum SearchStatus { DISABLED } -export default ErrorBoundary.wrap(function PluginSettings() { +export default function PluginSettings() { const settings = useSettings(); const changes = React.useMemo(() => new ChangeList(), []); @@ -228,9 +228,12 @@ export default ErrorBoundary.wrap(function PluginSettings() { if (enabled && searchValue.status === SearchStatus.DISABLED) return false; if (!enabled && searchValue.status === SearchStatus.ENABLED) return false; if (!searchValue.value.length) return true; + + const v = searchValue.value.toLowerCase(); return ( - plugin.name.toLowerCase().includes(searchValue.value.toLowerCase()) || - plugin.description.toLowerCase().includes(searchValue.value.toLowerCase()) + plugin.name.toLowerCase().includes(v) || + plugin.description.toLowerCase().includes(v) || + plugin.tags?.some(t => t.toLowerCase().includes(v)) ); }; @@ -258,6 +261,9 @@ export default ErrorBoundary.wrap(function PluginSettings() { requiredPlugins = []; for (const p of sortedPlugins) { + if (!p.options && p.name.endsWith("API") && searchValue.value !== "API") + continue; + if (!pluginFilter(p)) continue; const isRequired = p.required || depMap[p.name]?.some(d => settings.plugins[d].enabled); @@ -298,7 +304,7 @@ export default ErrorBoundary.wrap(function PluginSettings() { } return ( - + @@ -337,12 +343,9 @@ export default ErrorBoundary.wrap(function PluginSettings() {
{requiredPlugins}
-
+ ); -}, { - message: "Failed to render the Plugin Settings. If this persists, try using the installer to reinstall!", - onError: handleComponentFailed, -}); +} function makeDependencyList(deps: string[]) { return ( diff --git a/src/components/VencordSettings/BackupRestoreTab.tsx b/src/components/VencordSettings/BackupAndRestoreTab.tsx similarity index 89% rename from src/components/VencordSettings/BackupRestoreTab.tsx rename to src/components/VencordSettings/BackupAndRestoreTab.tsx index 173747026..a9a1c9fec 100644 --- a/src/components/VencordSettings/BackupRestoreTab.tsx +++ b/src/components/VencordSettings/BackupAndRestoreTab.tsx @@ -16,16 +16,17 @@ * along with this program. If not, see . */ -import ErrorBoundary from "@components/ErrorBoundary"; import { Flex } from "@components/Flex"; import { Margins } from "@utils/margins"; import { classes } from "@utils/misc"; import { downloadSettingsBackup, uploadSettingsBackup } from "@utils/settingsSync"; -import { Button, Card, Forms, Text } from "@webpack/common"; +import { Button, Card, Text } from "@webpack/common"; + +import { SettingsTab, wrapTab } from "./shared"; function BackupRestoreTab() { return ( - + Warning @@ -59,8 +60,8 @@ function BackupRestoreTab() { Export Settings - + ); } -export default ErrorBoundary.wrap(BackupRestoreTab); +export default wrapTab(BackupRestoreTab, "Backup & Restore"); diff --git a/src/components/VencordSettings/CloudTab.tsx b/src/components/VencordSettings/CloudTab.tsx index 3452cef5a..77e5298b5 100644 --- a/src/components/VencordSettings/CloudTab.tsx +++ b/src/components/VencordSettings/CloudTab.tsx @@ -17,15 +17,16 @@ */ import { showNotification } from "@api/Notifications"; -import { Settings, useSettings } from "@api/settings"; +import { Settings, useSettings } from "@api/Settings"; import { CheckedTextInput } from "@components/CheckedTextInput"; -import ErrorBoundary from "@components/ErrorBoundary"; import { Link } from "@components/Link"; import { authorizeCloud, cloudLogger, deauthorizeCloud, getCloudAuth, getCloudUrl } from "@utils/cloud"; import { Margins } from "@utils/margins"; import { deleteCloudSettings, getCloudSettings, putCloudSettings } from "@utils/settingsSync"; import { Alerts, Button, Forms, Switch, Tooltip } from "@webpack/common"; +import { SettingsTab, wrapTab } from "./shared"; + function validateUrl(url: string) { try { new URL(url); @@ -114,7 +115,7 @@ function CloudTab() { const settings = useSettings(["cloud.authenticated", "cloud.url"]); return ( - <> + Vencord comes with a cloud integration that adds goodies like settings sync across devices. @@ -157,8 +158,8 @@ function CloudTab() { - + ); } -export default ErrorBoundary.wrap(CloudTab); +export default wrapTab(CloudTab, "Cloud"); diff --git a/src/components/PatchHelper.tsx b/src/components/VencordSettings/PatchHelperTab.tsx similarity index 95% rename from src/components/PatchHelper.tsx rename to src/components/VencordSettings/PatchHelperTab.tsx index 37782ef3f..d5bd94ce1 100644 --- a/src/components/PatchHelper.tsx +++ b/src/components/VencordSettings/PatchHelperTab.tsx @@ -16,16 +16,16 @@ * along with this program. If not, see . */ +import { CheckedTextInput } from "@components/CheckedTextInput"; import { debounce } from "@utils/debounce"; import { Margins } from "@utils/margins"; -import { makeCodeblock } from "@utils/misc"; import { canonicalizeMatch, canonicalizeReplace } from "@utils/patches"; +import { makeCodeblock } from "@utils/text"; import { ReplaceFn } from "@utils/types"; import { search } from "@webpack"; -import { Button, Clipboard, Forms, Parser, React, Switch, Text, TextInput } from "@webpack/common"; +import { Button, Clipboard, Forms, Parser, React, Switch, TextInput } from "@webpack/common"; -import { CheckedTextInput } from "./CheckedTextInput"; -import ErrorBoundary from "./ErrorBoundary"; +import { SettingsTab, wrapTab } from "./shared"; // Do not include diff in non dev builds (side effects import) if (IS_DEV) { @@ -258,8 +258,7 @@ function PatchHelper() { } return ( - - Patch Helper + find Clipboard.copy(code)}>Copy to Clipboard )} - + ); } -export default IS_DEV ? ErrorBoundary.wrap(PatchHelper) : null; +export default IS_DEV ? wrapTab(PatchHelper, "PatchHelper") : null; diff --git a/src/components/VencordSettings/PluginsTab.tsx b/src/components/VencordSettings/PluginsTab.tsx index 04b5dc26f..6a320959f 100644 --- a/src/components/VencordSettings/PluginsTab.tsx +++ b/src/components/VencordSettings/PluginsTab.tsx @@ -16,7 +16,8 @@ * along with this program. If not, see . */ -import ErrorBoundary from "@components/ErrorBoundary"; import PluginSettings from "@components/PluginSettings"; -export default ErrorBoundary.wrap(PluginSettings); +import { wrapTab } from "./shared"; + +export default wrapTab(PluginSettings, "Plugins"); diff --git a/src/components/VencordSettings/ThemesTab.tsx b/src/components/VencordSettings/ThemesTab.tsx index a3df69d2e..79ddc5099 100644 --- a/src/components/VencordSettings/ThemesTab.tsx +++ b/src/components/VencordSettings/ThemesTab.tsx @@ -16,14 +16,15 @@ * along with this program. If not, see . */ -import { useSettings } from "@api/settings"; -import ErrorBoundary from "@components/ErrorBoundary"; +import { useSettings } from "@api/Settings"; import { Link } from "@components/Link"; import { Margins } from "@utils/margins"; -import { useAwaiter } from "@utils/misc"; +import { useAwaiter } from "@utils/react"; import { findLazy } from "@webpack"; import { Card, Forms, React, TextArea } from "@webpack/common"; +import { SettingsTab, wrapTab } from "./shared"; + const TextAreaProps = findLazy(m => typeof m.textarea === "string"); function Validator({ link }: { link: string; }) { @@ -74,8 +75,8 @@ function Validators({ themeLinks }: { themeLinks: string[]; }) { ); } -export default ErrorBoundary.wrap(function () { - const settings = useSettings(); +function ThemesTab() { + const settings = useSettings(["themeLinks"]); const [themeText, setThemeText] = React.useState(settings.themeLinks.join("\n")); function onBlur() { @@ -89,11 +90,11 @@ export default ErrorBoundary.wrap(function () { } return ( - <> + Paste links to .theme.css files here One link per line - Make sure to use the raw links or github.io links! + Make sure to use the raw links or github.io links! Find Themes:
@@ -124,6 +125,8 @@ export default ErrorBoundary.wrap(function () { onBlur={onBlur} /> - + ); -}); +} + +export default wrapTab(ThemesTab, "Themes"); diff --git a/src/components/VencordSettings/Updater.tsx b/src/components/VencordSettings/UpdaterTab.tsx similarity index 93% rename from src/components/VencordSettings/Updater.tsx rename to src/components/VencordSettings/UpdaterTab.tsx index 6dffbc87c..4d0b86c95 100644 --- a/src/components/VencordSettings/Updater.tsx +++ b/src/components/VencordSettings/UpdaterTab.tsx @@ -16,20 +16,21 @@ * along with this program. If not, see . */ -import { useSettings } from "@api/settings"; -import ErrorBoundary from "@components/ErrorBoundary"; +import { useSettings } from "@api/Settings"; import { ErrorCard } from "@components/ErrorCard"; import { Flex } from "@components/Flex"; -import { handleComponentFailed } from "@components/handleComponentFailed"; import { Link } from "@components/Link"; import { Margins } from "@utils/margins"; -import { classes, useAwaiter } from "@utils/misc"; +import { classes } from "@utils/misc"; import { relaunch } from "@utils/native"; -import { changes, checkForUpdates, getRepo, isNewer, rebuild, update, updateError, UpdateLogger } from "@utils/updater"; +import { useAwaiter } from "@utils/react"; +import { changes, checkForUpdates, getRepo, isNewer, update, updateError, UpdateLogger } from "@utils/updater"; import { Alerts, Button, Card, Forms, Parser, React, Switch, Toasts } from "@webpack/common"; import gitHash from "~git-hash"; +import { SettingsTab, wrapTab } from "./shared"; + function withDispatcher(dispatcher: React.Dispatch>, action: () => any) { return async () => { dispatcher(true); @@ -125,7 +126,6 @@ function Updatable(props: CommonProps) { onClick={withDispatcher(setIsUpdating, async () => { if (await update()) { setUpdates([]); - await rebuild(); await new Promise(r => { Alerts.show({ title: "Update Success!", @@ -198,7 +198,7 @@ function Updater() { }; return ( - + Updater Settings Updates {isNewer ? : } - + ); } -export default IS_WEB ? null : ErrorBoundary.wrap(Updater, { - message: "Failed to render the Updater. If this persists, try using the installer to reinstall!", - onError: handleComponentFailed, -}); +export default IS_WEB ? null : wrapTab(Updater, "Updater"); diff --git a/src/components/VencordSettings/VencordTab.tsx b/src/components/VencordSettings/VencordTab.tsx index 751220856..1502bfabd 100644 --- a/src/components/VencordSettings/VencordTab.tsx +++ b/src/components/VencordSettings/VencordTab.tsx @@ -18,17 +18,18 @@ import { openNotificationLogModal } from "@api/Notifications/notificationLog"; -import { Settings, useSettings } from "@api/settings"; +import { Settings, useSettings } from "@api/Settings"; import { classNameFactory } from "@api/Styles"; import DonateButton from "@components/DonateButton"; -import ErrorBoundary from "@components/ErrorBoundary"; import { ErrorCard } from "@components/ErrorCard"; -import IpcEvents from "@utils/IpcEvents"; import { Margins } from "@utils/margins"; -import { identity, useAwaiter } from "@utils/misc"; +import { identity } from "@utils/misc"; import { relaunch, showItemInFolder } from "@utils/native"; +import { useAwaiter } from "@utils/react"; import { Button, Card, Forms, React, Select, Slider, Switch } from "@webpack/common"; +import { SettingsTab, wrapTab } from "./shared"; + const cl = classNameFactory("vc-settings-"); const DEFAULT_DONATE_IMAGE = "https://cdn.discordapp.com/emojis/1026533090627174460.png"; @@ -39,7 +40,7 @@ type KeysOfType = { }[keyof Object]; function VencordSettings() { - const [settingsDir, , settingsDirPending] = useAwaiter(() => VencordNative.ipc.invoke(IpcEvents.GET_SETTINGS_DIR), { + const [settingsDir, , settingsDirPending] = useAwaiter(VencordNative.settings.getSettingsDir, { fallbackValue: "Loading..." }); const settings = useSettings(); @@ -97,44 +98,39 @@ function VencordSettings() { ]; return ( - + - {IS_WEB ? ( - - ) : ( - + + {!IS_WEB && ( - + )} + + {!IS_WEB && ( - - - )} + )} + + @@ -158,7 +154,7 @@ function VencordSettings() { {typeof Notification !== "undefined" && } - + ); } @@ -268,4 +264,4 @@ function DonateCard({ image }: DonateCardProps) { ); } -export default ErrorBoundary.wrap(VencordSettings); +export default wrapTab(VencordSettings, "Vencord Settings"); diff --git a/src/components/VencordSettings/index.tsx b/src/components/VencordSettings/index.tsx deleted file mode 100644 index b2916c4a9..000000000 --- a/src/components/VencordSettings/index.tsx +++ /dev/null @@ -1,93 +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 "./settingsStyles.css"; - -import { classNameFactory } from "@api/Styles"; -import ErrorBoundary from "@components/ErrorBoundary"; -import { handleComponentFailed } from "@components/handleComponentFailed"; -import { isMobile } from "@utils/misc"; -import { Forms, SettingsRouter, TabBar, Text } from "@webpack/common"; - -import BackupRestoreTab from "./BackupRestoreTab"; -import CloudTab from "./CloudTab"; -import PluginsTab from "./PluginsTab"; -import ThemesTab from "./ThemesTab"; -import Updater from "./Updater"; -import VencordSettings from "./VencordTab"; - -const cl = classNameFactory("vc-settings-"); - -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: () => }, - VencordUpdater: { name: "Updater" }, // Only show updater if IS_WEB is false - VencordCloud: { name: "Cloud", component: () => }, - 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 ?? null; - if (isMobile) { - return CurrentTab && ; - } - - 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 index 971e9a877..26988fdb6 100644 --- a/src/components/VencordSettings/settingsStyles.css +++ b/src/components/VencordSettings/settingsStyles.css @@ -15,7 +15,7 @@ display: flex; gap: 1em; align-items: center; - justify-content: space-between; + justify-content: space-evenly; flex-grow: 1; flex-flow: row wrap; margin-bottom: 1em; @@ -29,14 +29,12 @@ .vc-settings-card { padding: 1em; margin-bottom: 1em; - margin-top: 1em; } .vc-backup-restore-card { background-color: var(--info-warning-background); border-color: var(--info-warning-foreground); color: var(--info-warning-text); - margin-top: 0; } .vc-settings-theme-links { @@ -59,7 +57,7 @@ } .vc-text-selectable, -.vc-text-selectable :not(a, button) { +.vc-text-selectable :not(a, button, a *, button *, input, input *) { /* make text selectable, silly discord makes the entirety of settings not selectable */ user-select: text; diff --git a/src/components/VencordSettings/shared.tsx b/src/components/VencordSettings/shared.tsx new file mode 100644 index 000000000..0d3910dfb --- /dev/null +++ b/src/components/VencordSettings/shared.tsx @@ -0,0 +1,51 @@ +/* + * 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 "./settingsStyles.css"; + +import ErrorBoundary from "@components/ErrorBoundary"; +import { handleComponentFailed } from "@components/handleComponentFailed"; +import { Margins } from "@utils/margins"; +import { onlyOnce } from "@utils/onlyOnce"; +import { Forms, Text } from "@webpack/common"; +import type { ComponentType, PropsWithChildren } from "react"; + +export function SettingsTab({ title, children }: PropsWithChildren<{ title: string; }>) { + return ( + + + {title} + + + {children} + + ); +} + +const onError = onlyOnce(handleComponentFailed); + +export function wrapTab(component: ComponentType, tab: string) { + return ErrorBoundary.wrap(component, { + message: `Failed to render the ${tab} tab. If this issue persists, try using the installer to reinstall!`, + onError, + }); +} diff --git a/src/components/iconStyles.css b/src/components/iconStyles.css new file mode 100644 index 000000000..ca4075da0 --- /dev/null +++ b/src/components/iconStyles.css @@ -0,0 +1,7 @@ +.vc-open-external-icon { + transform: rotate(45deg); +} + +.vc-owner-crown-icon { + color: var(--text-warning); +} diff --git a/src/components/monacoWin.html b/src/components/monacoWin.html index d9d24121f..57d321410 100644 --- a/src/components/monacoWin.html +++ b/src/components/monacoWin.html @@ -1,52 +1,66 @@ - + + + + Vencord QuickCSS Editor + + + - - - Vencord QuickCSS Editor - - - + +
+ - -
- + - - + + diff --git a/src/debug/Tracer.ts b/src/debug/Tracer.ts index 185915a97..4337e0019 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/main/ipcMain.ts b/src/main/ipcMain.ts index d60200f7a..5fcf8b7df 100644 --- a/src/main/ipcMain.ts +++ b/src/main/ipcMain.ts @@ -19,7 +19,7 @@ import "./updater"; import { debounce } from "@utils/debounce"; -import IpcEvents from "@utils/IpcEvents"; +import { IpcEvents } from "@utils/IpcEvents"; import { Queue } from "@utils/Queue"; import { BrowserWindow, ipcMain, shell } from "electron"; import { mkdirSync, readFileSync, watch } from "fs"; @@ -44,7 +44,7 @@ export function readSettings() { } } -export function getSettings(): typeof import("@api/settings").Settings { +export function getSettings(): typeof import("@api/Settings").Settings { try { return JSON.parse(readSettings()); } catch { diff --git a/src/main/updater/git.ts b/src/main/updater/git.ts index d6a29a852..c6e5cc90a 100644 --- a/src/main/updater/git.ts +++ b/src/main/updater/git.ts @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import IpcEvents from "@utils/IpcEvents"; +import { IpcEvents } from "@utils/IpcEvents"; import { execFile as cpExecFile } from "child_process"; import { ipcMain } from "electron"; import { join } from "path"; diff --git a/src/main/updater/http.ts b/src/main/updater/http.ts index e2a3520de..5653d0143 100644 --- a/src/main/updater/http.ts +++ b/src/main/updater/http.ts @@ -17,7 +17,7 @@ */ import { VENCORD_USER_AGENT } from "@utils/constants"; -import IpcEvents from "@utils/IpcEvents"; +import { IpcEvents } from "@utils/IpcEvents"; import { ipcMain } from "electron"; import { writeFile } from "fs/promises"; import { join } from "path"; diff --git a/src/plugins/anonymiseFileNames.ts b/src/plugins/anonymiseFileNames.ts index 26c423c0a..0baf099d6 100644 --- a/src/plugins/anonymiseFileNames.ts +++ b/src/plugins/anonymiseFileNames.ts @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import { Settings } from "@api/settings"; +import { Settings } from "@api/Settings"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; diff --git a/src/plugins/apiBadges.tsx b/src/plugins/apiBadges.tsx index 57c5b385a..23ed6de2b 100644 --- a/src/plugins/apiBadges.tsx +++ b/src/plugins/apiBadges.tsx @@ -22,12 +22,11 @@ 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 { Logger } from "@utils/Logger"; import { Margins } from "@utils/margins"; import { closeModal, Modals, openModal } from "@utils/modal"; import definePlugin from "@utils/types"; -import { Forms } from "@webpack/common"; +import { Forms, Toasts } from "@webpack/common"; const CONTRIBUTOR_BADGE = "https://cdn.discordapp.com/attachments/1033680203433660458/1092089947126780035/favicon.png"; @@ -48,7 +47,29 @@ const ContributorBadge: ProfileBadge = { link: "https://github.com/Vendicated/Vencord" }; -const DonorBadges = {} as Record>; +let DonorBadges = {} as Record[]>; + +async function loadBadges(noCache = false) { + DonorBadges = {}; + + const init = {} as RequestInit; + if (noCache) + init.cache = "no-cache"; + + const badges = await fetch("https://gist.githubusercontent.com/Vendicated/51a3dd775f6920429ec6e9b735ca7f01/raw/badges.csv", init) + .then(r => r.text()); + + const lines = badges.trim().split("\n"); + if (lines.shift() !== "id,tooltip,image") { + new Logger("BadgeAPI").error("Invalid badges.csv file!"); + return; + } + + for (const line of lines) { + const [id, description, image] = line.split(","); + (DonorBadges[id] ??= []).push({ image, description }); + } +} export default definePlugin({ name: "BadgeAPI", @@ -61,8 +82,8 @@ export default definePlugin({ find: "Messages.PROFILE_USER_BADGES,role:", replacement: [ { - match: /null==\i\?void 0:(\i)\.getBadges\(\)/, - replace: (_, badgesMod) => `Vencord.Api.Badges._getBadges(arguments[0]).concat(${badgesMod}?.getBadges()??[])`, + match: /(?<=(\i)\.isTryItOutFlow,)(.{0,300})null==\i\?void 0:(\i)\.getBadges\(\)/, + replace: (_, props, restCode, badgesMod) => `vencordProps=${props},${restCode}Vencord.Api.Badges._getBadges(vencordProps).concat(${badgesMod}?.getBadges()??[])`, }, { // alt: "", aria-hidden: false, src: originalSrc @@ -82,93 +103,93 @@ export default definePlugin({ } ], + toolboxActions: { + async "Refetch Badges"() { + await loadBadges(true); + Toasts.show({ + id: Toasts.genId(), + message: "Successfully refetched badges!", + type: Toasts.Type.SUCCESS + }); + } + }, + + async start() { + Vencord.Api.Badges.addBadge(ContributorBadge); + await loadBadges(); + }, + renderBadgeComponent: ErrorBoundary.wrap((badge: ProfileBadge & BadgeUserArgs) => { const Component = badge.component!; return ; }, { noop: true }), - async start() { - Vencord.Api.Badges.addBadge(ContributorBadge); - const badges = await fetch("https://gist.githubusercontent.com/Vendicated/51a3dd775f6920429ec6e9b735ca7f01/raw/badges.csv").then(r => r.text()); - const lines = badges.trim().split("\n"); - if (lines.shift() !== "id,tooltip,image") { - new Logger("BadgeAPI").error("Invalid badges.csv file!"); - return; - } - for (const line of lines) { - const [id, description, image] = line.split(","); - DonorBadges[id] = { image, description }; - } - }, - getDonorBadge(userId: string) { - const badge = DonorBadges[userId]; - if (badge) { - return { - ...badge, - position: BadgePosition.START, - props: { - style: { - borderRadius: "50%", - transform: "scale(0.9)" // The image is a bit too big compared to default badges - } - }, - onClick() { - const modalKey = openModal(props => ( - { - closeModal(modalKey); - VencordNative.ipc.invoke(IpcEvents.OPEN_EXTERNAL, "https://github.com/sponsors/Vendicated"); - }}> - - - - - - Vencord Donor - - - - - - - - -
- - This Badge is a special perk for Vencord Donors - - - Please consider supporting the development of Vencord by becoming a donor. It would mean a lot!! - -
-
- - - - - -
-
- )); - }, - }; - } + getDonorBadges(userId: string) { + return DonorBadges[userId]?.map(badge => ({ + ...badge, + position: BadgePosition.START, + props: { + style: { + borderRadius: "50%", + transform: "scale(0.9)" // The image is a bit too big compared to default badges + } + }, + onClick() { + const modalKey = openModal(props => ( + { + closeModal(modalKey); + VencordNative.native.openExternal("https://github.com/sponsors/Vendicated"); + }}> + + + + + + Vencord Donor + + + + + + + + +
+ + This Badge is a special perk for Vencord Donors + + + Please consider supporting the development of Vencord by becoming a donor. It would mean a lot!! + +
+
+ + + + + +
+
+ )); + }, + })); } }); diff --git a/src/plugins/apiMessageEvents.ts b/src/plugins/apiMessageEvents.ts index 6843200d4..fa467522c 100644 --- a/src/plugins/apiMessageEvents.ts +++ b/src/plugins/apiMessageEvents.ts @@ -22,17 +22,29 @@ import definePlugin from "@utils/types"; export default definePlugin({ name: "MessageEventsAPI", description: "Api required by anything using message events.", - authors: [Devs.Arjix, Devs.hunt], + authors: [Devs.Arjix, Devs.hunt, Devs.Ven], patches: [ { find: '"MessageActionCreators"', - replacement: [{ - match: /_sendMessage:(function\([^)]+\)){/, - replace: "_sendMessage:async $1{if(await Vencord.Api.MessageEvents._handlePreSend(...arguments))return;" - }, { - match: /\beditMessage:(function\([^)]+\)){/, + replacement: { + // editMessage: function (...) { + match: /\beditMessage:(function\(.+?\))\{/, + // editMessage: async function (...) { await handlePreEdit(...); ... replace: "editMessage:async $1{await Vencord.Api.MessageEvents._handlePreEdit(...arguments);" - }] + } + }, + { + find: ".handleSendMessage=", + replacement: { + // props.chatInputType...then((function(isMessageValid)... var parsedMessage = b.c.parse(channel,... var replyOptions = f.g.getSendMessageOptionsForReply(pendingReply); + // Lookbehind: validateMessage)({openWarningPopout:..., type: i.props.chatInputType, content: t, stickers: r, ...}).then((function(isMessageValid) + match: /(props\.chatInputType.+?\.then\(\()(function.+?var (\i)=\i\.\i\.parse\((\i),.+?var (\i)=\i\.\i\.getSendMessageOptionsForReply\(\i\);)(?<=\)\(({.+?})\)\.then.+?)/, + // props.chatInputType...then((async function(isMessageValid)... var replyOptions = f.g.getSendMessageOptionsForReply(pendingReply); if(await Vencord.api...) return { shoudClear:true, shouldRefocus:true }; + replace: (_, rest1, rest2, parsedMessage, channel, replyOptions, extra) => "" + + `${rest1}async ${rest2}` + + `if(await Vencord.Api.MessageEvents._handlePreSend(${channel}.id,${parsedMessage},${extra},${replyOptions}))` + + "return{shoudClear:true,shouldRefocus:true};" + } }, { find: '("interactionUsernameProfile', diff --git a/src/plugins/apiServerList.ts b/src/plugins/apiServerList.ts index 77498ac81..6585d3819 100644 --- a/src/plugins/apiServerList.ts +++ b/src/plugins/apiServerList.ts @@ -32,7 +32,7 @@ export default definePlugin({ } }, { - find: "Messages.SERVERS", + find: "Messages.SERVERS,children", replacement: { match: /(Messages\.SERVERS,children:)(.+?default:return null\}\}\)\))/, replace: "$1Vencord.Api.ServerList.renderAll(Vencord.Api.ServerList.ServerListRenderPosition.In).concat($2)" diff --git a/src/plugins/betterFolders/FolderSideBar.tsx b/src/plugins/betterFolders/FolderSideBar.tsx index 3e44a5806..7159f7eea 100644 --- a/src/plugins/betterFolders/FolderSideBar.tsx +++ b/src/plugins/betterFolders/FolderSideBar.tsx @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import { Settings } from "@api/settings"; +import { Settings } from "@api/Settings"; import { classNameFactory } from "@api/Styles"; import ErrorBoundary from "@components/ErrorBoundary"; import { findByPropsLazy, findStoreLazy } from "@webpack"; diff --git a/src/plugins/betterFolders/index.ts b/src/plugins/betterFolders/index.ts index d0e61c0d2..d41ba75c7 100644 --- a/src/plugins/betterFolders/index.ts +++ b/src/plugins/betterFolders/index.ts @@ -18,7 +18,7 @@ import "./betterFolders.css"; -import { definePluginSettings } from "@api/settings"; +import { definePluginSettings } from "@api/Settings"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; import { findByPropsLazy, findLazy, findStoreLazy } from "@webpack"; diff --git a/src/plugins/betterNotes.ts b/src/plugins/betterNotes.ts index 41842590f..d9c5b45c3 100644 --- a/src/plugins/betterNotes.ts +++ b/src/plugins/betterNotes.ts @@ -16,9 +16,8 @@ * along with this program. If not, see . */ -import { Settings } from "@api/settings"; +import { Settings } from "@api/Settings"; import { Devs } from "@utils/constants"; -import { makeLazy } from "@utils/misc"; import definePlugin, { OptionType } from "@utils/types"; export default definePlugin({ @@ -30,7 +29,7 @@ export default definePlugin({ { find: "hideNote:", all: true, - predicate: makeLazy(() => Vencord.Settings.plugins.BetterNotesBox.hide), + predicate: () => Vencord.Settings.plugins.BetterNotesBox.hide, replacement: { match: /hideNote:.+?(?=[,}])/g, replace: "hideNote:true", diff --git a/src/plugins/betterRoleDot.ts b/src/plugins/betterRoleDot.ts index 1fc18c370..773176d8e 100644 --- a/src/plugins/betterRoleDot.ts +++ b/src/plugins/betterRoleDot.ts @@ -16,12 +16,11 @@ * along with this program. If not, see . */ -import { migratePluginSettings, Settings } from "@api/settings"; +import { 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({ name: "BetterRoleDot", authors: [Devs.Ven], @@ -30,10 +29,10 @@ export default definePlugin({ patches: [ { - find: "M0 4C0 1.79086 1.79086 0 4 0H16C18.2091 0 20 1.79086 20 4V16C20 18.2091 18.2091 20 16 20H4C1.79086 20 0 18.2091 0 16V4Z", + find: ".dotBorderBase", replacement: { - match: /viewBox:"0 0 20 20"/, - replace: "$&,onClick:()=>$self.copyToClipBoard(e.color),style:{cursor:'pointer'}", + match: /,viewBox:"0 0 20 20"/, + replace: "$&,onClick:()=>$self.copyToClipBoard(arguments[0].color),style:{cursor:'pointer'}", }, }, { diff --git a/src/plugins/blurNsfw.ts b/src/plugins/blurNsfw.ts index b24ded93d..dadc49be5 100644 --- a/src/plugins/blurNsfw.ts +++ b/src/plugins/blurNsfw.ts @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import { Settings } from "@api/settings"; +import { Settings } from "@api/Settings"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; diff --git a/src/plugins/callTimer.tsx b/src/plugins/callTimer.tsx index f745bf625..9490eba0b 100644 --- a/src/plugins/callTimer.tsx +++ b/src/plugins/callTimer.tsx @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import { Settings } from "@api/settings"; +import { Settings } from "@api/Settings"; import ErrorBoundary from "@components/ErrorBoundary"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; diff --git a/src/plugins/clearURLs/index.ts b/src/plugins/clearURLs/index.ts index 178a0e11f..d1be6c6f5 100644 --- a/src/plugins/clearURLs/index.ts +++ b/src/plugins/clearURLs/index.ts @@ -23,7 +23,6 @@ import { removePreEditListener, removePreSendListener } from "@api/MessageEvents"; -import { migratePluginSettings } from "@api/settings"; import { Devs } from "@utils/constants"; import definePlugin from "@utils/types"; @@ -33,7 +32,6 @@ import { defaultRules } from "./defaultRules"; const reRegExpChar = /[\\^$.*+?()[\]{}|]/g; const reHasRegExpChar = RegExp(reRegExpChar.source); -migratePluginSettings("ClearURLs", "clearURLs"); export default definePlugin({ name: "ClearURLs", description: "Removes tracking garbage from URLs", diff --git a/src/plugins/crashHandler.ts b/src/plugins/crashHandler.ts index c70d467f7..f15fb8e9e 100644 --- a/src/plugins/crashHandler.ts +++ b/src/plugins/crashHandler.ts @@ -17,9 +17,9 @@ */ import { showNotification } from "@api/Notifications"; -import { definePluginSettings } from "@api/settings"; +import { definePluginSettings } from "@api/Settings"; import { Devs } from "@utils/constants"; -import Logger from "@utils/Logger"; +import { Logger } from "@utils/Logger"; import { closeAllModals } from "@utils/modal"; import definePlugin, { OptionType } from "@utils/types"; import { maybePromptToUpdate } from "@utils/updater"; diff --git a/src/plugins/customRPC.tsx b/src/plugins/customRPC.tsx index ecd77e9b2..27776ef03 100644 --- a/src/plugins/customRPC.tsx +++ b/src/plugins/customRPC.tsx @@ -16,11 +16,11 @@ * along with this program. If not, see . */ -import { definePluginSettings } from "@api/settings"; +import { definePluginSettings } from "@api/Settings"; import { Link } from "@components/Link"; import { Devs } from "@utils/constants"; import { isTruthy } from "@utils/guards"; -import { useAwaiter } from "@utils/misc"; +import { useAwaiter } from "@utils/react"; import definePlugin, { OptionType } from "@utils/types"; import { filters, findByCodeLazy, findByPropsLazy, mapMangledModuleLazy } from "@webpack"; import { diff --git a/src/plugins/devCompanion.dev.tsx b/src/plugins/devCompanion.dev.tsx index 73bf56f0f..2fa01f257 100644 --- a/src/plugins/devCompanion.dev.tsx +++ b/src/plugins/devCompanion.dev.tsx @@ -16,15 +16,13 @@ * along with this program. If not, see . */ -import { addContextMenuPatch, NavContextMenuPatchCallback, removeContextMenuPatch } from "@api/ContextMenu"; import { showNotification } from "@api/Notifications"; -import { definePluginSettings } from "@api/settings"; +import { definePluginSettings } from "@api/Settings"; import { Devs } from "@utils/constants"; -import Logger from "@utils/Logger"; +import { Logger } from "@utils/Logger"; import { canonicalizeMatch, canonicalizeReplace } from "@utils/patches"; import definePlugin, { OptionType } from "@utils/types"; import { filters, findAll, search } from "@webpack"; -import { Menu } from "@webpack/common"; const PORT = 8485; const NAV_ID = "dev-companion-reconnect"; @@ -238,33 +236,25 @@ function initWs(isManual = false) { }); } -const contextMenuPatch: NavContextMenuPatchCallback = children => () => { - children.unshift( - { - socket?.close(1000, "Reconnecting"); - initWs(true); - }} - /> - ); -}; - export default definePlugin({ name: "DevCompanion", description: "Dev Companion Plugin", authors: [Devs.Ven], settings, + toolboxActions: { + "Reconnect"() { + socket?.close(1000, "Reconnecting"); + initWs(true); + } + }, + start() { initWs(); - addContextMenuPatch("user-settings-cog", contextMenuPatch); }, stop() { socket?.close(1000, "Plugin Stopped"); socket = void 0; - removeContextMenuPatch("user-settings-cog", contextMenuPatch); } }); diff --git a/src/plugins/emoteCloner.tsx b/src/plugins/emoteCloner.tsx index 61eec8865..0900422a8 100644 --- a/src/plugins/emoteCloner.tsx +++ b/src/plugins/emoteCloner.tsx @@ -19,19 +19,103 @@ import { addContextMenuPatch, findGroupChildrenByChildId, NavContextMenuPatchCallback, removeContextMenuPatch } from "@api/ContextMenu"; import { CheckedTextInput } from "@components/CheckedTextInput"; import { Devs } from "@utils/constants"; -import Logger from "@utils/Logger"; +import { Logger } from "@utils/Logger"; import { Margins } from "@utils/margins"; -import { ModalContent, ModalHeader, ModalRoot, openModal } from "@utils/modal"; +import { ModalContent, ModalHeader, ModalRoot, openModalLazy } from "@utils/modal"; import definePlugin from "@utils/types"; -import { findByCodeLazy, findByPropsLazy } from "@webpack"; -import { Forms, GuildStore, Menu, PermissionStore, React, Toasts, Tooltip, UserStore } from "@webpack/common"; +import { findByCodeLazy, findStoreLazy } from "@webpack"; +import { EmojiStore, FluxDispatcher, Forms, GuildStore, Menu, PermissionStore, React, RestAPI, Toasts, Tooltip, UserStore } from "@webpack/common"; +import { Promisable } from "type-fest"; const MANAGE_EMOJIS_AND_STICKERS = 1n << 30n; -const GuildEmojiStore = findByPropsLazy("getGuilds", "getGuildEmoji"); +const StickersStore = findStoreLazy("StickersStore"); const uploadEmoji = findByCodeLazy('"EMOJI_UPLOAD_START"', "GUILD_EMOJIS("); -function getGuildCandidates(isAnimated: boolean) { +interface Sticker { + t: "Sticker"; + description: string; + format_type: number; + guild_id: string; + id: string; + name: string; + tags: string; + type: number; +} + +interface Emoji { + t: "Emoji"; + id: string; + name: string; + isAnimated: boolean; +} + +type Data = Emoji | Sticker; + +const StickerExt = [, "png", "png", "json", "gif"] as const; + +function getUrl(data: Data) { + if (data.t === "Emoji") + return `${location.protocol}//${window.GLOBAL_ENV.CDN_HOST}/emojis/${data.id}.${data.isAnimated ? "gif" : "png"}`; + + return `${location.origin}/stickers/${data.id}.${StickerExt[data.format_type]}`; +} + +async function fetchSticker(id: string) { + const cached = StickersStore.getStickerById(id); + if (cached) return cached; + + const { body } = await RestAPI.get({ + url: `/stickers/${id}` + }); + + FluxDispatcher.dispatch({ + type: "STICKER_FETCH_SUCCESS", + sticker: body + }); + + return body as Sticker; +} + +async function cloneSticker(guildId: string, sticker: Sticker) { + const data = new FormData(); + data.append("name", sticker.name); + data.append("tags", sticker.tags); + data.append("description", sticker.description); + data.append("file", await fetchBlob(getUrl(sticker))); + + const { body } = await RestAPI.post({ + url: `/guilds/${guildId}/stickers`, + body: data, + }); + + FluxDispatcher.dispatch({ + type: "GUILD_STICKERS_CREATE_SUCCESS", + guildId, + sticker: { + ...body, + user: UserStore.getCurrentUser() + } + }); +} + +async function cloneEmoji(guildId: string, emoji: Emoji) { + const data = await fetchBlob(getUrl(emoji)); + + const dataUrl = await new Promise(resolve => { + const reader = new FileReader(); + reader.onload = () => resolve(reader.result as string); + reader.readAsDataURL(data); + }); + + return uploadEmoji({ + guildId, + name: emoji.name.split("~")[0], + image: dataUrl + }); +} + +function getGuildCandidates(data: Data) { const meId = UserStore.getCurrentUser().id; return Object.values(GuildStore.getGuilds()).filter(g => { @@ -39,8 +123,12 @@ function getGuildCandidates(isAnimated: boolean) { BigInt(PermissionStore.getGuildPermissions({ id: g.id }) & MANAGE_EMOJIS_AND_STICKERS) === MANAGE_EMOJIS_AND_STICKERS; if (!canCreate) return false; + if (data.t === "Sticker") return true; + + const { isAnimated } = data as Emoji; + const emojiSlots = g.getMaxEmojiSlots(); - const { emojis } = GuildEmojiStore.getGuilds()[g.id]; + const { emojis } = EmojiStore.getGuilds()[g.id]; let count = 0; for (const emoji of emojis) @@ -49,33 +137,34 @@ function getGuildCandidates(isAnimated: boolean) { }).sort((a, b) => a.name.localeCompare(b.name)); } -async function doClone(guildId: string, id: string, name: string, isAnimated: boolean) { - const data = await fetch(`${location.protocol}//${window.GLOBAL_ENV.CDN_HOST}/emojis/${id}.${isAnimated ? "gif" : "png"}`) - .then(r => r.blob()); - const reader = new FileReader(); +async function fetchBlob(url: string) { + const res = await fetch(url); + if (!res.ok) + throw new Error(`Failed to fetch ${url} - ${res.status}`); - reader.onload = () => { - uploadEmoji({ - guildId, - name: name.split("~")[0], - image: reader.result - }).then(() => { - Toasts.show({ - message: `Successfully cloned ${name}!`, - type: Toasts.Type.SUCCESS, - id: Toasts.genId() - }); - }).catch((e: any) => { - new Logger("EmoteCloner").error("Failed to upload emoji", e); - Toasts.show({ - message: "Oopsie something went wrong :( Check console!!!", - type: Toasts.Type.FAILURE, - id: Toasts.genId() - }); + return res.blob(); +} + +async function doClone(guildId: string, data: Sticker | Emoji) { + try { + if (data.t === "Sticker") + await cloneSticker(guildId, data); + else + await cloneEmoji(guildId, data); + + Toasts.show({ + message: `Successfully cloned ${data.name} to ${GuildStore.getGuild(guildId)?.name ?? "your server"}!`, + type: Toasts.Type.SUCCESS, + id: Toasts.genId() }); - }; - - reader.readAsDataURL(data); + } catch (e) { + new Logger("EmoteCloner").error("Failed to clone", data.name, "to", guildId, e); + Toasts.show({ + message: "Oopsie something went wrong :( Check console!!!", + type: Toasts.Type.FAILURE, + id: Toasts.genId() + }); + } } const getFontSize = (s: string) => { @@ -86,22 +175,26 @@ const getFontSize = (s: string) => { const nameValidator = /^\w+$/i; -function CloneModal({ id, name: emojiName, isAnimated }: { id: string; name: string; isAnimated: boolean; }) { +function CloneModal({ data }: { data: Sticker | Emoji; }) { const [isCloning, setIsCloning] = React.useState(false); - const [name, setName] = React.useState(emojiName); + const [name, setName] = React.useState(data.name); const [x, invalidateMemo] = React.useReducer(x => x + 1, 0); - const guilds = React.useMemo(() => getGuildCandidates(isAnimated), [isAnimated, x]); + const guilds = React.useMemo(() => getGuildCandidates(data), [data.id, x]); return ( <> Custom Name { + data.name = v; + setName(v); + }} validate={v => - (v.length > 1 && v.length < 32 && nameValidator.test(v)) + (data.t === "Emoji" && v.length > 2 && v.length < 32 && nameValidator.test(v)) + || (data.t === "Sticker" && v.length > 2 && v.length < 30) || "Name must be between 2 and 32 characters and only contain alphanumeric characters" } /> @@ -135,7 +228,7 @@ function CloneModal({ id, name: emojiName, isAnimated }: { id: string; name: str }} onClick={isCloning ? void 0 : async () => { setIsCloning(true); - doClone(g.id, id, name, isAnimated).finally(() => { + doClone(g.id, data).finally(() => { invalidateMemo(); setIsCloning(false); }); @@ -175,32 +268,38 @@ function CloneModal({ id, name: emojiName, isAnimated }: { id: string; name: str ); } -function buildMenuItem(id: string, name: string, isAnimated: boolean) { +function buildMenuItem(type: "Emoji" | "Sticker", fetchData: () => Promisable>) { return ( - openModal(modalProps => ( - - - - Clone {name} - - - - - - )) + openModalLazy(async () => { + const res = await fetchData(); + const data = { t: type, ...res } as Sticker | Emoji; + const url = getUrl(data); + + return modalProps => ( + + + + Clone {data.name} + + + + + + ); + }) } /> ); @@ -213,28 +312,53 @@ function isGifUrl(url: string) { const messageContextMenuPatch: NavContextMenuPatchCallback = (children, props) => () => { const { favoriteableId, itemHref, itemSrc, favoriteableType } = props ?? {}; - if (!favoriteableId || favoriteableType !== "emoji") return; + if (!favoriteableId) return; - const match = props.message.content.match(RegExp(`|https://cdn\\.discordapp\\.com/emojis/${favoriteableId}\\.`)); - if (!match) return; - const name = match[1] ?? "FakeNitroEmoji"; + const menuItem = (() => { + switch (favoriteableType) { + case "emoji": + const match = props.message.content.match(RegExp(`|https://cdn\\.discordapp\\.com/emojis/${favoriteableId}\\.`)); + if (!match) return; + const name = match[1] ?? "FakeNitroEmoji"; - const group = findGroupChildrenByChildId("copy-link", children); - if (group) group.push(buildMenuItem(favoriteableId, name, isGifUrl(itemHref ?? itemSrc))); + return buildMenuItem("Emoji", () => ({ + id: favoriteableId, + name, + isAnimated: isGifUrl(itemHref ?? itemSrc) + })); + case "sticker": + const sticker = props.message.stickerItems.find(s => s.id === favoriteableId); + if (sticker?.format_type === 3 /* LOTTIE */) return; + + return buildMenuItem("Sticker", () => fetchSticker(favoriteableId)); + } + })(); + + if (menuItem) + findGroupChildrenByChildId("copy-link", children)?.push(menuItem); }; const expressionPickerPatch: NavContextMenuPatchCallback = (children, props: { target: HTMLElement; }) => () => { const { id, name, type } = props?.target?.dataset ?? {}; - if (!id || !name || type !== "emoji") return; + if (!id) return; - const firstChild = props.target.firstChild as HTMLImageElement; + if (type === "emoji" && name) { + const firstChild = props.target.firstChild as HTMLImageElement; - children.push(buildMenuItem(id, name, firstChild && isGifUrl(firstChild.src))); + children.push(buildMenuItem("Emoji", () => ({ + id, + name, + isAnimated: firstChild && isGifUrl(firstChild.src) + }))); + } else if (type === "sticker" && !props.target.className?.includes("lottieCanvas")) { + children.push(buildMenuItem("Sticker", () => fetchSticker(id))); + } }; export default definePlugin({ name: "EmoteCloner", - description: "Adds a Clone context menu item to emotes to clone them your own server", + description: "Allows you to clone Emotes & Stickers to your own server (right click them)", + tags: ["StickerCloner"], authors: [Devs.Ven, Devs.Nuckyz], start() { diff --git a/src/plugins/experiments.tsx b/src/plugins/experiments.tsx index 686b822d7..cc8309df7 100644 --- a/src/plugins/experiments.tsx +++ b/src/plugins/experiments.tsx @@ -16,8 +16,11 @@ * along with this program. If not, see . */ -import { definePluginSettings } from "@api/settings"; +import { definePluginSettings } from "@api/Settings"; +import ErrorBoundary from "@components/ErrorBoundary"; +import { ErrorCard } from "@components/ErrorCard"; import { Devs } from "@utils/constants"; +import { Margins } from "@utils/margins"; import definePlugin, { OptionType } from "@utils/types"; import { findByPropsLazy } from "@webpack"; import { Forms, React } from "@webpack/common"; @@ -87,6 +90,13 @@ export default definePlugin({ match: /"staging"===window\.GLOBAL_ENV\.RELEASE_CHANNEL/, replace: "true" } + }, + { + find: 'H1,title:"Experiments"', + replacement: { + match: 'title:"Experiments",children:[', + replace: "$&$self.WarningCard()," + } } ], @@ -109,5 +119,19 @@ export default definePlugin({ ); - } + }, + + WarningCard: ErrorBoundary.wrap(() => ( + + Hold on!! + + + Experiments are unreleased Discord features. They might not work, or even break your client or get your account disabled. + + + + Only use experiments if you know what you're doing. Vencord is not responsible for any damage caused by enabling experiments. + + + ), { noop: true }) }); diff --git a/src/plugins/fakeNitro.tsx b/src/plugins/fakeNitro.tsx index fda9b6b7c..88b2ae20f 100644 --- a/src/plugins/fakeNitro.tsx +++ b/src/plugins/fakeNitro.tsx @@ -17,14 +17,14 @@ */ import { addPreEditListener, addPreSendListener, removePreEditListener, removePreSendListener } from "@api/MessageEvents"; -import { definePluginSettings, migratePluginSettings, Settings } from "@api/settings"; +import { definePluginSettings, Settings } from "@api/Settings"; import { Devs } from "@utils/constants"; import { ApngBlendOp, ApngDisposeOp, getGifEncoder, importApngJs } from "@utils/dependencies"; import { getCurrentGuild } from "@utils/discord"; -import { proxyLazy } from "@utils/proxyLazy"; +import { proxyLazy } from "@utils/lazy"; import definePlugin, { OptionType } from "@utils/types"; import { findByCodeLazy, findByPropsLazy, findLazy, findStoreLazy } from "@webpack"; -import { ChannelStore, FluxDispatcher, Parser, PermissionStore, UserStore } from "@webpack/common"; +import { ChannelStore, EmojiStore, FluxDispatcher, Parser, PermissionStore, UserStore } from "@webpack/common"; import type { Message } from "discord-types/general"; import type { ReactNode } from "react"; @@ -38,8 +38,6 @@ const StickerStore = findStoreLazy("StickersStore") as { getAllGuildStickers(): Map; getStickerById(id: string): Sticker | undefined; }; -const EmojiStore = findStoreLazy("EmojiStore"); - function searchProtoClass(localName: string, parentProtoClass: any) { if (!parentProtoClass) return; @@ -149,8 +147,6 @@ const settings = definePluginSettings({ } }); -migratePluginSettings("FakeNitro", "NitroBypass"); - export default definePlugin({ name: "FakeNitro", authors: [Devs.Arjix, Devs.D3SOX, Devs.Ven, Devs.obscurity, Devs.captain, Devs.Nuckyz, Devs.AutumnVN], @@ -323,7 +319,7 @@ export default definePlugin({ }, handleProtoChange(proto: any, user: any) { - if ((!proto.appearance && !AppearanceSettingsProto) || !UserSettingsProtoStore) return; + if (proto == null || typeof proto === "string" || !UserSettingsProtoStore || (!proto.appearance && !AppearanceSettingsProto)) return; const premiumType: number = user?.premium_type ?? UserStore?.getCurrentUser()?.premiumType ?? 0; @@ -643,7 +639,7 @@ export default definePlugin({ if (!settings.enableStickerBypass) break stickerBypass; - const sticker = StickerStore.getStickerById(extra?.stickerIds?.[0]!); + const sticker = StickerStore.getStickerById(extra.stickers?.[0]!); if (!sticker) break stickerBypass; @@ -665,7 +661,7 @@ export default definePlugin({ link = `https://distok.top/stickers/${packId}/${sticker.id}.gif`; } - delete extra.stickerIds; + extra.stickers!.length = 0; messageObj.content += " " + link + `&name=${encodeURIComponent(sticker.name)}`; } } diff --git a/src/plugins/fakeProfileThemes.tsx b/src/plugins/fakeProfileThemes.tsx index 8a0db1d27..70003e5ab 100644 --- a/src/plugins/fakeProfileThemes.tsx +++ b/src/plugins/fakeProfileThemes.tsx @@ -17,7 +17,7 @@ */ // This plugin is a port from Alyxia's Vendetta plugin -import { definePluginSettings } from "@api/settings"; +import { definePluginSettings } from "@api/Settings"; import ErrorBoundary from "@components/ErrorBoundary"; import { Devs } from "@utils/constants"; import { Margins } from "@utils/margins"; diff --git a/src/plugins/fart.ts b/src/plugins/fart.ts index 9404b39b0..b92a41df0 100644 --- a/src/plugins/fart.ts +++ b/src/plugins/fart.ts @@ -17,7 +17,7 @@ */ import { ApplicationCommandOptionType } from "@api/Commands"; -import { Settings } from "@api/settings"; +import { Settings } from "@api/Settings"; import { makeRange } from "@components/PluginSettings/components"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; diff --git a/src/plugins/favEmojiFirst.ts b/src/plugins/favEmojiFirst.ts new file mode 100644 index 000000000..fec0b045d --- /dev/null +++ b/src/plugins/favEmojiFirst.ts @@ -0,0 +1,83 @@ +/* + * 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 { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; +import { EmojiStore } from "@webpack/common"; +import { Emoji } from "@webpack/types"; + +interface EmojiAutocompleteState { + query?: { + type: string; + typeInfo: { + sentinel: string; + }; + results: { + emojis: Emoji[] & { sliceTo?: number; }; + }; + }; +} + +export default definePlugin({ + name: "FavoriteEmojiFirst", + authors: [Devs.Aria, Devs.Ven], + description: "Puts your favorite emoji first in the emoji autocomplete.", + patches: [ + { + find: ".activeCommandOption", + replacement: [ + { + // = someFunc(a.selectedIndex); ...trackEmojiSearch({ state: theState, isInPopoutExperimental: someBool }) + match: /=\i\(\i\.selectedIndex\);(?=.+?state:(\i),isInPopoutExperiment:\i)/, + // self.sortEmojis(theState) + replace: "$&$self.sortEmojis($1);" + }, + + // set maxCount to Infinity so our sortEmojis callback gets the entire list, not just the first 10 + // and remove Discord's emojiResult slice, storing the endIndex on the array for us to use later + { + // searchEmojis(...,maxCount: stuff) ... endEmojis = emojis.slice(0, maxCount - gifResults.length) + match: /,maxCount:(\i)(.+?)=(\i)\.slice\(0,(\1-\i\.length)\)/, + // ,maxCount:Infinity ... endEmojis = (emojis.sliceTo = n, emojis) + replace: ",maxCount:Infinity$2=($3.sliceTo=$4,$3)" + } + ] + } + ], + + sortEmojis({ query }: EmojiAutocompleteState) { + if ( + query?.type !== "EMOJIS_AND_STICKERS" + || query.typeInfo?.sentinel !== ":" + || !query.results?.emojis?.length + ) return; + + const emojiContext = EmojiStore.getDisambiguatedEmojiContext(); + + query.results.emojis = query.results.emojis.sort((a, b) => { + const aIsFavorite = emojiContext.isFavoriteEmojiWithoutFetchingLatest(a); + const bIsFavorite = emojiContext.isFavoriteEmojiWithoutFetchingLatest(b); + + if (aIsFavorite && !bIsFavorite) return -1; + + if (!aIsFavorite && bIsFavorite) return 1; + + return 0; + }).slice(0, query.results.emojis.sliceTo ?? 10); + } +}); diff --git a/src/plugins/ignoreActivities.tsx b/src/plugins/ignoreActivities.tsx index f141dcef0..534b3f7f8 100644 --- a/src/plugins/ignoreActivities.tsx +++ b/src/plugins/ignoreActivities.tsx @@ -19,7 +19,7 @@ import * as DataStore from "@api/DataStore"; import ErrorBoundary from "@components/ErrorBoundary"; import { Devs } from "@utils/constants"; -import { useForceUpdater } from "@utils/misc"; +import { useForceUpdater } from "@utils/react"; import definePlugin from "@utils/types"; import { findByPropsLazy, findStoreLazy } from "@webpack"; import { Tooltip } from "webpack/common"; diff --git a/src/plugins/imageZoom/index.tsx b/src/plugins/imageZoom/index.tsx index 9007bf46b..d4adcdcae 100644 --- a/src/plugins/imageZoom/index.tsx +++ b/src/plugins/imageZoom/index.tsx @@ -17,7 +17,7 @@ */ import { addContextMenuPatch, NavContextMenuPatchCallback, removeContextMenuPatch } from "@api/ContextMenu"; -import { definePluginSettings } from "@api/settings"; +import { definePluginSettings } from "@api/Settings"; import { disableStyle, enableStyle } from "@api/Styles"; import { makeRange } from "@components/PluginSettings/components"; import { Devs } from "@utils/constants"; @@ -130,6 +130,8 @@ export default definePlugin({ name: "ImageZoom", description: "Lets you zoom in to images and gifs. Use scroll wheel to zoom in and shift + scroll wheel to increase lens radius / size", authors: [Devs.Aria], + tags: ["ImageUtilities"], + patches: [ { find: '"renderLinkComponent","maxWidth"', diff --git a/src/plugins/index.ts b/src/plugins/index.ts index ab69ca743..f6d577269 100644 --- a/src/plugins/index.ts +++ b/src/plugins/index.ts @@ -17,8 +17,8 @@ */ import { registerCommand, unregisterCommand } from "@api/Commands"; -import { Settings } from "@api/settings"; -import Logger from "@utils/Logger"; +import { Settings } from "@api/Settings"; +import { Logger } from "@utils/Logger"; import { Patch, Plugin } from "@utils/types"; import { FluxDispatcher } from "@webpack/common"; import { FluxEvents } from "@webpack/types"; @@ -99,9 +99,9 @@ export function startDependenciesRecursive(p: Plugin) { if (!Settings.plugins[dep].enabled) { startDependenciesRecursive(Plugins[dep]); // If the plugin has patches, don't start the plugin, just enable it. + Settings.plugins[dep].enabled = true; if (Plugins[dep].patches) { logger.warn(`Enabling dependency ${dep} requires restart.`); - Settings.plugins[dep].enabled = true; restartNeeded = true; return; } diff --git a/src/plugins/invisibleChat/index.tsx b/src/plugins/invisibleChat/index.tsx index 0501a182d..6f21628a3 100644 --- a/src/plugins/invisibleChat/index.tsx +++ b/src/plugins/invisibleChat/index.tsx @@ -17,12 +17,12 @@ */ import { addButton, removeButton } from "@api/MessagePopover"; -import { definePluginSettings } from "@api/settings"; +import { definePluginSettings } from "@api/Settings"; import ErrorBoundary from "@components/ErrorBoundary"; import { Devs } from "@utils/constants"; import { getStegCloak } from "@utils/dependencies"; import definePlugin, { OptionType } from "@utils/types"; -import { Button, ButtonLooks, ButtonWrapperClasses, ChannelStore, FluxDispatcher, Tooltip } from "@webpack/common"; +import { Button, ButtonLooks, ButtonWrapperClasses, ChannelStore, FluxDispatcher, RestAPI, Tooltip } from "@webpack/common"; import { Message } from "discord-types/general"; import { buildDecModal } from "./components/DecryptionModal"; @@ -64,7 +64,13 @@ function Indicator() { } -function ChatBarIcon() { +function ChatBarIcon(chatBoxProps: { + type: { + analyticsName: string; + }; +}) { + if (chatBoxProps.type.analyticsName !== "normal") return null; + return ( {({ onMouseEnter, onMouseLeave }) => ( @@ -85,7 +91,7 @@ function ChatBarIcon() { onMouseLeave={onMouseLeave} innerClassName={ButtonWrapperClasses.button} onClick={() => buildEncModal()} - style={{ padding: "0 4px" }} + style={{ padding: "0 2px", scale: "0.9" }} >
>https://embed.sammcheese.net<< to provide embeds to decrypted links!", + description: "Encrypt your Messages in a non-suspicious way!", authors: [Devs.SammCheese], dependencies: ["MessagePopoverAPI"], patches: [ @@ -133,7 +139,7 @@ export default definePlugin({ find: ".activeCommandOption", replacement: { match: /(.)\.push.{1,30}disabled:(\i),.{1,20}\},"gift"\)\)/, - replace: "$&;try{$2||$1.push($self.chatBarIcon())}catch{}", + replace: "$&;try{$2||$1.push($self.chatBarIcon(arguments[0]))}catch{}", } }, ], @@ -172,25 +178,13 @@ export default definePlugin({ // Gets the Embed of a Link async getEmbed(url: URL): Promise { - const controller = new AbortController(); - const timeout = setTimeout(() => controller.abort(), 5000); - - const options: RequestInit = { - signal: controller.signal, - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify({ - url, - }), - }; - - // AWS hosted url to discord embed object - const rawRes = await fetch(this.EMBED_API_URL, options); - clearTimeout(timeout); - - return await rawRes.json(); + const { body } = await RestAPI.post({ + url: "/unfurler/embed-urls", + body: { + urls: [url] + } + }); + return await body.embeds[0]; }, async buildEmbed(message: any, revealed: string): Promise { diff --git a/src/plugins/lastfm.tsx b/src/plugins/lastfm.tsx index c001a5977..380d1ea97 100644 --- a/src/plugins/lastfm.tsx +++ b/src/plugins/lastfm.tsx @@ -16,10 +16,10 @@ * along with this program. If not, see . */ -import { definePluginSettings } from "@api/settings"; +import { definePluginSettings } from "@api/Settings"; import { Link } from "@components/Link"; import { Devs } from "@utils/constants"; -import Logger from "@utils/Logger"; +import { Logger } from "@utils/Logger"; import definePlugin, { OptionType } from "@utils/types"; import { filters, findByPropsLazy, mapMangledModuleLazy } from "@webpack"; import { FluxDispatcher, Forms } from "@webpack/common"; diff --git a/src/plugins/memberCount.tsx b/src/plugins/memberCount.tsx index 0b5409c0c..78c10de14 100644 --- a/src/plugins/memberCount.tsx +++ b/src/plugins/memberCount.tsx @@ -20,31 +20,34 @@ import ErrorBoundary from "@components/ErrorBoundary"; import { Flex } from "@components/Flex"; import { Devs } from "@utils/constants"; import { getCurrentChannel } from "@utils/discord"; -import { useForceUpdater } from "@utils/misc"; import definePlugin from "@utils/types"; import { findStoreLazy } from "@webpack"; -import { Tooltip } from "@webpack/common"; +import { SelectedChannelStore, Tooltip, useStateFromStores } from "@webpack/common"; +import { FluxStore } from "@webpack/types"; -const counts = {} as Record; -let forceUpdate: () => void; - -const GuildMemberCountStore = findStoreLazy("GuildMemberCountStore"); +const GuildMemberCountStore = findStoreLazy("GuildMemberCountStore") as FluxStore & { getMemberCount(guildId: string): number | null; }; +const ChannelMemberStore = findStoreLazy("ChannelMemberStore") as FluxStore & { + getProps(guildId: string, channelId: string): { groups: { count: number; id: string; }[]; }; +}; function MemberCount() { - const guildId = getCurrentChannel().guild_id; - const c = counts[guildId]; + const { id: channelId, guild_id: guildId } = useStateFromStores([SelectedChannelStore], () => getCurrentChannel()); + const { groups } = useStateFromStores( + [ChannelMemberStore], + () => ChannelMemberStore.getProps(guildId, channelId) + ); + const total = useStateFromStores( + [GuildMemberCountStore], + () => GuildMemberCountStore.getMemberCount(guildId) + ); - forceUpdate = useForceUpdater(); + if (total == null) + return null; - if (!c) return null; - - let total = c[0].toLocaleString(); - if (total === "0" && c[1] > 0) { - const approx = GuildMemberCountStore.getMemberCount(guildId); - total = approx ? approx.toLocaleString() : "Loading..."; - } - - const online = c[1].toLocaleString(); + const online = + (groups.length === 1 && groups[0].id === "unknown") + ? 0 + : groups.reduce((count, curr) => count + (curr.id === "offline" ? 0 : curr.count), 0); return ( - + {props => (
)} - + {props => (
( - - - - ) + render: ErrorBoundary.wrap(MemberCount, { noop: true }) }); diff --git a/src/plugins/messageClickActions.ts b/src/plugins/messageClickActions.ts index c54a09c02..28c558e5a 100644 --- a/src/plugins/messageClickActions.ts +++ b/src/plugins/messageClickActions.ts @@ -17,11 +17,11 @@ */ import { addClickListener, removeClickListener } from "@api/MessageEvents"; -import { migratePluginSettings } from "@api/settings"; +import { definePluginSettings, Settings } from "@api/Settings"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; import { findByPropsLazy } from "@webpack"; -import { PermissionStore, UserStore } from "@webpack/common"; +import { FluxDispatcher, PermissionStore, UserStore } from "@webpack/common"; let isDeletePressed = false; const keydown = (e: KeyboardEvent) => e.key === "Backspace" && (isDeletePressed = true); @@ -29,26 +29,36 @@ const keyup = (e: KeyboardEvent) => e.key === "Backspace" && (isDeletePressed = const MANAGE_CHANNELS = 1n << 4n; -migratePluginSettings("MessageClickActions", "MessageQuickActions"); +const settings = definePluginSettings({ + enableDeleteOnClick: { + type: OptionType.BOOLEAN, + description: "Enable delete on click", + default: true + }, + enableDoubleClickToEdit: { + type: OptionType.BOOLEAN, + description: "Enable double click to edit", + default: true + }, + enableDoubleClickToReply: { + type: OptionType.BOOLEAN, + description: "Enable double click to reply", + default: true + }, + requireModifier: { + type: OptionType.BOOLEAN, + description: "Only do double click actions when shift/ctrl is held", + default: false + } +}); export default definePlugin({ name: "MessageClickActions", - description: "Hold Backspace and click to delete, double click to edit", + description: "Hold Backspace and click to delete, double click to edit/reply", authors: [Devs.Ven], dependencies: ["MessageEventsAPI"], - options: { - enableDeleteOnClick: { - type: OptionType.BOOLEAN, - description: "Enable delete on click", - default: true - }, - enableDoubleClickToEdit: { - type: OptionType.BOOLEAN, - description: "Enable double click to edit", - default: true - } - }, + settings, start() { const MessageActions = findByPropsLazy("deleteMessage", "startEditMessage"); @@ -57,15 +67,30 @@ export default definePlugin({ document.addEventListener("keydown", keydown); document.addEventListener("keyup", keyup); - this.onClick = addClickListener((msg, chan, event) => { + this.onClick = addClickListener((msg, channel, event) => { const isMe = msg.author.id === UserStore.getCurrentUser().id; if (!isDeletePressed) { - if (Vencord.Settings.plugins.MessageClickActions.enableDoubleClickToEdit && (isMe && event.detail >= 2 && !EditStore.isEditing(chan.id, msg.id))) { - MessageActions.startEditMessage(chan.id, msg.id, msg.content); + if (event.detail < 2) return; + if (settings.store.requireModifier && !event.ctrlKey && !event.shiftKey) return; + + if (isMe) { + if (!settings.store.enableDoubleClickToEdit || EditStore.isEditing(channel.id, msg.id)) return; + + MessageActions.startEditMessage(channel.id, msg.id, msg.content); event.preventDefault(); + } else { + if (!settings.store.enableDoubleClickToReply) return; + + FluxDispatcher.dispatch({ + type: "CREATE_PENDING_REPLY", + channel, + message: msg, + shouldMention: !Settings.plugins.NoReplyMention.enabled, + showMentionToggle: channel.guild_id !== null + }); } - } else if (Vencord.Settings.plugins.MessageClickActions.enableDeleteOnClick && (isMe || PermissionStore.can(MANAGE_CHANNELS, chan))) { - MessageActions.deleteMessage(chan.id, msg.id); + } else if (settings.store.enableDeleteOnClick && (isMe || PermissionStore.can(MANAGE_CHANNELS, channel))) { + MessageActions.deleteMessage(channel.id, msg.id); event.preventDefault(); } }); diff --git a/src/plugins/messageLinkEmbeds.tsx b/src/plugins/messageLinkEmbeds.tsx index e3a28a737..d1fcbf357 100644 --- a/src/plugins/messageLinkEmbeds.tsx +++ b/src/plugins/messageLinkEmbeds.tsx @@ -17,11 +17,12 @@ */ import { addAccessory } from "@api/MessageAccessories"; -import { definePluginSettings } from "@api/settings"; +import { definePluginSettings } from "@api/Settings"; import ErrorBoundary from "@components/ErrorBoundary"; import { Devs } from "@utils/constants.js"; -import { classes, LazyComponent } from "@utils/misc"; +import { classes } from "@utils/misc"; import { Queue } from "@utils/Queue"; +import { LazyComponent } from "@utils/react"; import definePlugin, { OptionType } from "@utils/types"; import { find, findByCode, findByPropsLazy } from "@webpack"; import { @@ -51,7 +52,7 @@ const SearchResultClasses = findByPropsLazy("message", "searchResult"); let AutoModEmbed: React.ComponentType = () => null; const messageLinkRegex = /(? domElement.classList.toggle("messagelogger-deleted")} + /> + )); + } + children.push(( { if (deleted) { FluxDispatcher.dispatch({ @@ -70,20 +87,6 @@ const patchMessageContextMenu: NavContextMenuPatchCallback = (children, props) = }} /> )); - - if (!deleted) return; - - const domElement = document.getElementById(`chat-messages-${channel_id}-${id}`); - if (!domElement) return; - - children.push(( - domElement.classList.toggle("messagelogger-deleted")} - /> - )); }; export default definePlugin({ diff --git a/src/plugins/messageTags.ts b/src/plugins/messageTags.ts index 02d1e529f..d65c388c3 100644 --- a/src/plugins/messageTags.ts +++ b/src/plugins/messageTags.ts @@ -18,7 +18,7 @@ import { ApplicationCommandInputType, ApplicationCommandOptionType, findOption, registerCommand, sendBotMessage, unregisterCommand } from "@api/Commands"; import * as DataStore from "@api/DataStore"; -import { Settings } from "@api/settings"; +import { Settings } from "@api/Settings"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; diff --git a/src/plugins/moreKaomoji.ts b/src/plugins/moreKaomoji.ts index 6be80d661..959910848 100644 --- a/src/plugins/moreKaomoji.ts +++ b/src/plugins/moreKaomoji.ts @@ -17,11 +17,9 @@ */ 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({ name: "MoreKaomoji", description: "Adds more Kaomoji to discord. ヽ(´▽`)/", diff --git a/src/plugins/moreUserTags.ts b/src/plugins/moreUserTags.tsx similarity index 55% rename from src/plugins/moreUserTags.ts rename to src/plugins/moreUserTags.tsx index 3fa0aa1bf..dbe8cc29f 100644 --- a/src/plugins/moreUserTags.ts +++ b/src/plugins/moreUserTags.tsx @@ -16,12 +16,14 @@ * along with this program. If not, see . */ -import { definePluginSettings } from "@api/settings"; +import { definePluginSettings } from "@api/Settings"; +import { Flex } from "@components/Flex"; import { Devs } from "@utils/constants"; -import { proxyLazy } from "@utils/proxyLazy.js"; +import { Margins } from "@utils/margins"; import definePlugin, { OptionType } from "@utils/types"; -import { find, findByPropsLazy } from "@webpack"; -import { ChannelStore, GuildStore } from "@webpack/common"; +import { findByPropsLazy, findLazy } from "@webpack"; +import { Card, ChannelStore, Forms, GuildStore, Switch, TextInput, Tooltip, useState } from "@webpack/common"; +import { RC } from "@webpack/types"; import { Channel, Message, User } from "discord-types/general"; type PermissionName = "CREATE_INSTANT_INVITE" | "KICK_MEMBERS" | "BAN_MEMBERS" | "ADMINISTRATOR" | "MANAGE_CHANNELS" | "MANAGE_GUILD" | "CHANGE_NICKNAME" | "MANAGE_NICKNAMES" | "MANAGE_ROLES" | "MANAGE_WEBHOOKS" | "MANAGE_GUILD_EXPRESSIONS" | "CREATE_GUILD_EXPRESSIONS" | "VIEW_AUDIT_LOG" | "VIEW_CHANNEL" | "VIEW_GUILD_ANALYTICS" | "VIEW_CREATOR_MONETIZATION_ANALYTICS" | "MODERATE_MEMBERS" | "SEND_MESSAGES" | "SEND_TTS_MESSAGES" | "MANAGE_MESSAGES" | "EMBED_LINKS" | "ATTACH_FILES" | "READ_MESSAGE_HISTORY" | "MENTION_EVERYONE" | "USE_EXTERNAL_EMOJIS" | "ADD_REACTIONS" | "USE_APPLICATION_COMMANDS" | "MANAGE_THREADS" | "CREATE_PUBLIC_THREADS" | "CREATE_PRIVATE_THREADS" | "USE_EXTERNAL_STICKERS" | "SEND_MESSAGES_IN_THREADS" | "CONNECT" | "SPEAK" | "MUTE_MEMBERS" | "DEAFEN_MEMBERS" | "MOVE_MEMBERS" | "USE_VAD" | "PRIORITY_SPEAKER" | "STREAM" | "USE_EMBEDDED_ACTIVITIES" | "USE_SOUNDBOARD" | "USE_EXTERNAL_SOUNDS" | "REQUEST_TO_SPEAK" | "MANAGE_EVENTS" | "CREATE_EVENTS"; @@ -36,6 +38,21 @@ interface Tag { condition?(message: Message | null, user: User, channel: Channel): boolean; } +interface TagSetting { + text: string; + showInChat: boolean; + showInNotChat: boolean; +} +interface TagSettings { + WEBHOOK: TagSetting, + OWNER: TagSetting, + ADMINISTRATOR: TagSetting, + MODERATOR_STAFF: TagSetting, + MODERATOR: TagSetting, + VOICE_MODERATOR: TagSetting, + [k: string]: TagSetting; +} + const CLYDE_ID = "1081004946872352958"; // PermissionStore.computePermissions is not the same function and doesn't work here @@ -44,7 +61,7 @@ const PermissionUtil = findByPropsLazy("computePermissions", "canEveryoneRole") }; const Permissions = findByPropsLazy("SEND_MESSAGES", "VIEW_CREATOR_MONETIZATION_ANALYTICS") as Record; -const Tags = proxyLazy(() => find(m => m.Types?.[0] === "BOT").Types) as Record; +const Tag = findLazy(m => m.Types?.[0] === "BOT") as RC<{ type?: number, className?: string, useRemSizes?: boolean; }> & { Types: Record; }; const isWebhook = (message: Message, user: User) => !!message?.webhookId && user.isNonUserBot(); @@ -81,64 +98,119 @@ const tags: Tag[] = [ permissions: ["MOVE_MEMBERS", "MUTE_MEMBERS", "DEAFEN_MEMBERS"] } ]; +const defaultSettings = Object.fromEntries( + tags.map(({ name, displayName }) => [name, { text: displayName, showInChat: true, showInNotChat: true }]) +) as TagSettings; + +function SettingsComponent(props: { setValue(v: any): void; }) { + settings.store.tagSettings ??= defaultSettings; + + const [tagSettings, setTagSettings] = useState(settings.store.tagSettings as TagSettings); + const setValue = (v: TagSettings) => { + setTagSettings(v); + props.setValue(v); + }; + + return ( + + {tags.map(t => ( + + + + {({ onMouseEnter, onMouseLeave }) => ( +
+ {t.displayName} Tag +
+ )} +
+
+ + { + tagSettings[t.name].text = v; + setValue(tagSettings); + }} + className={Margins.bottom16} + /> + + { + tagSettings[t.name].showInChat = v; + setValue(tagSettings); + }} + hideBorder + > + Show in messages + + + { + tagSettings[t.name].showInNotChat = v; + setValue(tagSettings); + }} + hideBorder + > + Show in member list and profiles + +
+ ))} +
+ ); +} const settings = definePluginSettings({ dontShowForBots: { - description: "Don't show tags (not including the webhook tag) for bots", + description: "Don't show extra tags for bots (excluding webhooks)", type: OptionType.BOOLEAN }, dontShowBotTag: { - description: "Don't show [BOT] text for bots with other tags (verified bots will still have checkmark)", + description: "Only show extra tags for bots / Hide [BOT] text", type: OptionType.BOOLEAN }, - ...Object.fromEntries(tags.map(({ name, displayName, description }) => [ - `visibility_${name}`, { - description: `Show ${displayName} tags (${description})`, - type: OptionType.SELECT, - options: [ - { - label: "Always", - value: "always", - default: true - }, { - label: "Only in chat", - value: "chat" - }, { - label: "Only in member list and profiles", - value: "not-chat" - }, { - label: "Never", - value: "never" - } - ] - } - ])) + tagSettings: { + type: OptionType.COMPONENT, + component: SettingsComponent, + description: "fill me", + } }); export default definePlugin({ name: "MoreUserTags", description: "Adds tags for webhooks and moderative roles (owner, admin, etc.)", - authors: [Devs.Cyn, Devs.TheSun, Devs.RyanCaoDev], + authors: [Devs.Cyn, Devs.TheSun, Devs.RyanCaoDev, Devs.LordElias], settings, patches: [ // add tags to the tag list { find: '.BOT=0]="BOT"', replacement: [ - // add tags to the exported tags list (the Tags variable here) + // add tags to the exported tags list (Tag.Types) { match: /(\i)\[.\.BOT=0\]="BOT";/, replace: "$&$1=$self.addTagVariants($1);" - }, + } + ] + }, + { + find: ".DISCORD_SYSTEM_MESSAGE_BOT_TAG_TOOLTIP;", + replacement: [ // make the tag show the right text { - match: /(switch\((\i)\){.+?)case (\i)\.BOT:default:(\i)=(\i\.\i\.Messages)\.BOT_TAG_BOT/, + match: /(switch\((\i)\){.+?)case (\i(?:\.\i)?)\.BOT:default:(\i)=(\i\.\i\.Messages)\.BOT_TAG_BOT/, replace: (_, origSwitch, variant, tags, displayedText, strings) => `${origSwitch}default:{${displayedText} = $self.getTagText(${tags}[${variant}], ${strings})}` }, // show OP tags correctly { - match: /(\i)=(\i)===\i\.ORIGINAL_POSTER/, + match: /(\i)=(\i)===\i(?:\.\i)?\.ORIGINAL_POSTER/, replace: "$1=$self.isOPTag($2)" }, // add HTML data attributes (for easier theming) @@ -169,15 +241,15 @@ return type!==null?$2.botTag,type" { find: ".hasAvatarForGuild(null==", replacement: { - match: /\.usernameSection,user/, - replace: ".usernameSection,moreTags_channelId:arguments[0].channelId,user" + match: /(?=usernameIcon:)/, + replace: "moreTags_channelId:arguments[0].channelId," } }, { find: 'copyMetaData:"User Tag"', replacement: { - match: /discriminatorClass:(.{1,100}),botClass:/, - replace: "discriminatorClass:$1,moreTags_channelId:arguments[0].moreTags_channelId,botClass:" + match: /(?=,botClass:)/, + replace: ",moreTags_channelId:arguments[0].moreTags_channelId" } }, // in profiles @@ -190,6 +262,37 @@ return type!==null?$2.botTag,type" }, ], + start() { + if (settings.store.tagSettings) return; + // @ts-ignore + if (!settings.store.visibility_WEBHOOK) settings.store.tagSettings = defaultSettings; + else { + const newSettings = { ...defaultSettings }; + Object.entries(Vencord.PlainSettings.plugins.MoreUserTags).forEach(([name, value]) => { + const [setting, tag] = name.split("_"); + if (setting === "visibility") { + switch (value) { + case "always": + // its the default + break; + case "chat": + newSettings[tag].showInNotChat = false; + break; + case "not-chat": + newSettings[tag].showInChat = false; + break; + case "never": + newSettings[tag].showInChat = false; + newSettings[tag].showInNotChat = false; + break; + } + } + settings.store.tagSettings = newSettings; + delete Vencord.Settings.plugins.MoreUserTags[name]; + }); + } + }, + getPermissions(user: User, channel: Channel): string[] { const guild = GuildStore.getGuild(channel?.guild_id); if (!guild) return []; @@ -202,35 +305,36 @@ return type!==null?$2.botTag,type" .filter(Boolean); }, - addTagVariants(val: any /* i cant think of a good name */) { + addTagVariants(tagConstant) { let i = 100; tags.forEach(({ name }) => { - val[name] = ++i; - val[i] = name; - val[`${name}-BOT`] = ++i; - val[i] = `${name}-BOT`; - val[`${name}-OP`] = ++i; - val[i] = `${name}-OP`; + tagConstant[name] = ++i; + tagConstant[i] = name; + tagConstant[`${name}-BOT`] = ++i; + tagConstant[i] = `${name}-BOT`; + tagConstant[`${name}-OP`] = ++i; + tagConstant[i] = `${name}-OP`; }); - return val; + return tagConstant; }, - isOPTag: (tag: number) => tag === Tags.ORIGINAL_POSTER || tags.some(t => tag === Tags[`${t.name}-OP`]), + isOPTag: (tag: number) => tag === Tag.Types.ORIGINAL_POSTER || tags.some(t => tag === Tag.Types[`${t.name}-OP`]), getTagText(passedTagName: string, strings: Record) { - if (!passedTagName) return "BOT"; + if (!passedTagName) return strings.BOT_TAG_BOT; const [tagName, variant] = passedTagName.split("-"); const tag = tags.find(({ name }) => tagName === name); - if (!tag) return "BOT"; + if (!tag) return strings.BOT_TAG_BOT; if (variant === "BOT" && tagName !== "WEBHOOK" && this.settings.store.dontShowForBots) return strings.BOT_TAG_BOT; + const tagText = settings.store.tagSettings?.[tag.name]?.text || tag.displayName; switch (variant) { case "OP": - return `${strings.BOT_TAG_FORUM_ORIGINAL_POSTER} • ${tag.displayName}`; + return `${strings.BOT_TAG_FORUM_ORIGINAL_POSTER} • ${tagText}`; case "BOT": - return `${strings.BOT_TAG_BOT} • ${tag.displayName}`; + return `${strings.BOT_TAG_BOT} • ${tagText}`; default: - return tag.displayName; + return tagText; } }, @@ -242,12 +346,12 @@ return type!==null?$2.botTag,type" channel?: Channel & { isForumPost(): boolean; }, channelId?: string; origType?: number; - location: string; + location: "chat" | "not-chat"; }): number | null { if (location === "chat" && user.id === "1") - return Tags.OFFICIAL; + return Tag.Types.OFFICIAL; if (user.id === CLYDE_ID) - return Tags.AI; + return Tag.Types.AI; let type = typeof origType === "number" ? origType : null; @@ -258,24 +362,19 @@ return type!==null?$2.botTag,type" const perms = this.getPermissions(user, channel); for (const tag of tags) { - switch (settings[`visibility_${tag.name}`]) { - case "always": - case location: - break; - default: - continue; - } + if (location === "chat" && !settings.tagSettings[tag.name].showInChat) continue; + if (location === "not-chat" && !settings.tagSettings[tag.name].showInNotChat) continue; if ( tag.permissions?.some(perm => perms.includes(perm)) || (tag.condition?.(message!, user, channel)) ) { if (channel.isForumPost() && channel.ownerId === user.id) - type = Tags[`${tag.name}-OP`]; + type = Tag.Types[`${tag.name}-OP`]; else if (user.bot && !isWebhook(message!, user) && !settings.dontShowBotTag) - type = Tags[`${tag.name}-BOT`]; + type = Tag.Types[`${tag.name}-BOT`]; else - type = Tags[tag.name]; + type = Tag.Types[tag.name]; break; } } diff --git a/src/plugins/moyai.ts b/src/plugins/moyai.ts index b32bd9928..1a48bd67b 100644 --- a/src/plugins/moyai.ts +++ b/src/plugins/moyai.ts @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import { definePluginSettings } from "@api/settings"; +import { definePluginSettings } from "@api/Settings"; import { makeRange } from "@components/PluginSettings/components/SettingSliderComponent"; import { Devs } from "@utils/constants"; import { sleep } from "@utils/misc"; diff --git a/src/plugins/muteNewGuild.tsx b/src/plugins/muteNewGuild.tsx index 9be1a674d..e5e618f7c 100644 --- a/src/plugins/muteNewGuild.tsx +++ b/src/plugins/muteNewGuild.tsx @@ -16,9 +16,10 @@ * along with this program. If not, see . */ +import { definePluginSettings } from "@api/Settings"; import { Devs } from "@utils/constants"; import { ModalContent, ModalFooter, ModalProps, ModalRoot, ModalSize, openModal } from "@utils/modal"; -import definePlugin from "@utils/types"; +import definePlugin, { OptionType } from "@utils/types"; import { findByProps, findStoreLazy } from "@webpack"; import { Button, Text } from "@webpack/common"; @@ -49,10 +50,28 @@ function NoDMNotificationsModal({ modalProps }: { modalProps: ModalProps; }) { ); } +const settings = definePluginSettings({ + guild: { + description: "Mute Guild", + type: OptionType.BOOLEAN, + default: true + }, + everyone: { + description: "Suppress @everyone and @here", + type: OptionType.BOOLEAN, + default: true + }, + role: { + description: "Suppress All Role @mentions", + type: OptionType.BOOLEAN, + default: true + }, +}); + export default definePlugin({ name: "MuteNewGuild", description: "Mutes newly joined guilds", - authors: [Devs.Glitch, Devs.Nuckyz], + authors: [Devs.Glitch, Devs.Nuckyz, Devs.carince], patches: [ { find: ",acceptInvite:function", @@ -62,10 +81,17 @@ export default definePlugin({ } } ], + settings, handleMute(guildId: string | null) { if (guildId === "@me" || guildId === "null" || guildId == null) return; - findByProps("updateGuildNotificationSettings").updateGuildNotificationSettings(guildId, { muted: true, suppress_everyone: true, suppress_roles: true }); + findByProps("updateGuildNotificationSettings").updateGuildNotificationSettings(guildId, + { + muted: settings.store.guild, + suppress_everyone: settings.store.everyone, + suppress_roles: settings.store.role + } + ); }, start() { diff --git a/src/plugins/noBlockedMessages.ts b/src/plugins/noBlockedMessages.ts index d91572a8b..54bb2d051 100644 --- a/src/plugins/noBlockedMessages.ts +++ b/src/plugins/noBlockedMessages.ts @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import { Settings } from "@api/settings"; +import { Settings } from "@api/Settings"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; import { findByPropsLazy } from "@webpack"; diff --git a/src/plugins/noCanaryMessageLinks.ts b/src/plugins/noCanaryMessageLinks.ts deleted file mode 100644 index ebd6782d9..000000000 --- a/src/plugins/noCanaryMessageLinks.ts +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Vencord, a modification for Discord's desktop app - * Copyright (c) 2022 Samu and Linnea Gräf - * - * 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 { 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", - description: "Allows you to change/remove the subdomain of discord message and channel links", - authors: [Devs.Samu, Devs.nea], - options: { - linkPrefix: { - description: "The subdomain for your discord message links", - type: OptionType.STRING, - default: "", - restartNeeded: false, - }, - alwaysUseDiscordHost: { - description: "Always use discord.com host (replace discordapp.com)", - type: OptionType.BOOLEAN, - default: false, - restartNeeded: false, - }, - }, - dependencies: ["MessageEventsAPI"], - - removeBetas(msg: MessageObject) { - const settings = Settings.plugins.NoCanaryMessageLinks; - msg.content = msg.content.replace( - /https:\/\/(?:canary\.|ptb\.)?(discord(?:app)?\.com)(\/channels\/(?:\d{17,20}|@me)\/\d{17,20}(?:\/\d{17,20})?)/g, - (_, host, path) => "https://" + (settings.linkPrefix ? settings.linkPrefix + "." : "") + (settings.alwaysUseDiscordHost ? "discord.com" : host) + path - ); - }, - - start() { - this.preSend = addPreSendListener((_, msg) => this.removeBetas(msg)); - }, - - stop() { - removePreSendListener(this.preSend); - } -}); diff --git a/src/plugins/noDevtoolsWarning.ts b/src/plugins/noDevtoolsWarning.ts index 2dd514ee5..188b8fa3f 100644 --- a/src/plugins/noDevtoolsWarning.ts +++ b/src/plugins/noDevtoolsWarning.ts @@ -16,12 +16,9 @@ * along with this program. If not, see . */ -import { migratePluginSettings } from "@api/settings"; import { Devs } from "@utils/constants"; import definePlugin from "@utils/types"; -migratePluginSettings("NoDevtoolsWarning", "STFU"); - export default definePlugin({ name: "NoDevtoolsWarning", description: "Disables the 'HOLD UP' banner in the console. As a side effect, also prevents Discord from hiding your token, which prevents random logouts.", diff --git a/src/plugins/noF1.ts b/src/plugins/noF1.ts index c951149e4..a40be5acc 100644 --- a/src/plugins/noF1.ts +++ b/src/plugins/noF1.ts @@ -16,11 +16,9 @@ * along with this program. If not, see . */ -import { migratePluginSettings } from "@api/settings"; import { Devs } from "@utils/constants"; import definePlugin from "@utils/types"; -migratePluginSettings("NoF1", "No F1"); export default definePlugin({ name: "NoF1", description: "Disables F1 help bind.", diff --git a/src/plugins/noRPC.discordDesktop.ts b/src/plugins/noRPC.discordDesktop.ts index ebd7b1a34..ebbbd5e8f 100644 --- a/src/plugins/noRPC.discordDesktop.ts +++ b/src/plugins/noRPC.discordDesktop.ts @@ -16,11 +16,9 @@ * along with this program. If not, see . */ -import { migratePluginSettings } from "@api/settings"; import { Devs } from "@utils/constants"; import definePlugin from "@utils/types"; -migratePluginSettings("NoRPC", "No RPC"); export default definePlugin({ name: "NoRPC", description: "Disables Discord's RPC server.", diff --git a/src/plugins/noReplyMention.tsx b/src/plugins/noReplyMention.tsx index 1351ec467..16b3a3e00 100644 --- a/src/plugins/noReplyMention.tsx +++ b/src/plugins/noReplyMention.tsx @@ -16,18 +16,33 @@ * along with this program. If not, see . */ -import { definePluginSettings } from "@api/settings"; +import { definePluginSettings } from "@api/Settings"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; import type { Message } from "discord-types/general"; const settings = definePluginSettings({ - exemptList: { + userList: { description: - "List of users to exempt from this plugin (separated by commas or spaces)", + "List of users to allow or exempt pings for (separated by commas or spaces)", type: OptionType.STRING, default: "1234567890123445,1234567890123445", }, + shouldPingListed: { + description: "Behaviour", + type: OptionType.SELECT, + options: [ + { + label: "Do not ping the listed users", + value: false, + }, + { + label: "Only ping the listed users", + value: true, + default: true, + }, + ], + }, inverseShiftReply: { description: "Invert Discord's shift replying behaviour (enable to make shift reply mention user)", type: OptionType.BOOLEAN, @@ -38,11 +53,12 @@ const settings = definePluginSettings({ export default definePlugin({ name: "NoReplyMention", description: "Disables reply pings by default", - authors: [Devs.DustyAngel47, Devs.axyie, Devs.pylix], + authors: [Devs.DustyAngel47, Devs.axyie, Devs.pylix, Devs.outfoxxed], settings, shouldMention(message: Message, isHoldingShift: boolean) { - const isExempt = settings.store.exemptList.includes(message.author.id); + const isListed = settings.store.userList.includes(message.author.id); + const isExempt = settings.store.shouldPingListed ? isListed : !isListed; return settings.store.inverseShiftReply ? isHoldingShift !== isExempt : !isHoldingShift && isExempt; }, diff --git a/src/plugins/permissionsViewer/components/RolesAndUsersPermissions.tsx b/src/plugins/permissionsViewer/components/RolesAndUsersPermissions.tsx new file mode 100644 index 000000000..7a65a071d --- /dev/null +++ b/src/plugins/permissionsViewer/components/RolesAndUsersPermissions.tsx @@ -0,0 +1,225 @@ +/* + * 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 ErrorBoundary from "@components/ErrorBoundary"; +import { Flex } from "@components/Flex"; +import { InfoIcon, OwnerCrownIcon } from "@components/Icons"; +import { ModalCloseButton, ModalContent, ModalHeader, ModalProps, ModalRoot, ModalSize, openModal } from "@utils/modal"; +import { ContextMenu, FluxDispatcher, GuildMemberStore, Menu, PermissionsBits, Text, Tooltip, useEffect, UserStore, useState, useStateFromStores } from "@webpack/common"; +import type { Guild } from "discord-types/general"; + +import { cl, getPermissionDescription, getPermissionString } from "../utils"; +import { PermissionAllowedIcon, PermissionDefaultIcon, PermissionDeniedIcon } from "./icons"; + +export const enum PermissionType { + Role = 0, + User = 1, + Owner = 2 +} + +export interface RoleOrUserPermission { + type: PermissionType; + id?: string; + permissions?: bigint; + overwriteAllow?: bigint; + overwriteDeny?: bigint; +} + +function openRolesAndUsersPermissionsModal(permissions: Array, guild: Guild, header: string) { + return openModal(modalProps => ( + + )); +} + +function RolesAndUsersPermissionsComponent({ permissions, guild, modalProps, header }: { permissions: Array; guild: Guild; modalProps: ModalProps; header: string; }) { + permissions.sort((a, b) => a.type - b.type); + + useStateFromStores( + [GuildMemberStore], + () => GuildMemberStore.getMemberIds(guild.id), + null, + (old, current) => old.length === current.length + ); + + useEffect(() => { + const usersToRequest = permissions + .filter(p => p.type === PermissionType.User && !GuildMemberStore.isMember(guild.id, p.id!)) + .map(({ id }) => id); + + FluxDispatcher.dispatch({ + type: "GUILD_MEMBERS_REQUEST", + guildIds: [guild.id], + userIds: usersToRequest + }); + }, []); + + const [selectedItemIndex, selectItem] = useState(0); + const selectedItem = permissions[selectedItemIndex]; + + return ( + + + {header} permissions: + + + + + {!selectedItem && ( +
+ No permissions to display! +
+ )} + + {selectedItem && ( +
+
+ {permissions.map((permission, index) => { + const user = UserStore.getUser(permission.id ?? ""); + const role = guild.roles[permission.id ?? ""]; + + return ( + + ); + })} +
+
+ {Object.entries(PermissionsBits).map(([permissionName, bit]) => ( +
+
+ {(() => { + const { permissions, overwriteAllow, overwriteDeny } = selectedItem; + + if (permissions) + return (permissions & bit) === bit + ? PermissionAllowedIcon() + : PermissionDeniedIcon(); + + if (overwriteAllow && (overwriteAllow & bit) === bit) + return PermissionAllowedIcon(); + if (overwriteDeny && (overwriteDeny & bit) === bit) + return PermissionDeniedIcon(); + + return PermissionDefaultIcon(); + })()} +
+ {getPermissionString(permissionName)} + + + {props => } + +
+ ))} +
+
+ )} +
+
+ ); +} + +function RoleContextMenu({ guild, roleId, onClose }: { guild: Guild; roleId: string; onClose: () => void; }) { + return ( + + { + const role = guild.roles[roleId]; + if (!role) return; + + onClose(); + + FluxDispatcher.dispatch({ + type: "IMPERSONATE_UPDATE", + guildId: guild.id, + data: { + type: "ROLES", + roles: { + [roleId]: role + } + } + }); + }} + /> + + ); +} + +const RolesAndUsersPermissions = ErrorBoundary.wrap(RolesAndUsersPermissionsComponent); + +export default openRolesAndUsersPermissionsModal; diff --git a/src/plugins/permissionsViewer/components/UserPermissions.tsx b/src/plugins/permissionsViewer/components/UserPermissions.tsx new file mode 100644 index 000000000..acffa787f --- /dev/null +++ b/src/plugins/permissionsViewer/components/UserPermissions.tsx @@ -0,0 +1,175 @@ +/* + * 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 ErrorBoundary from "@components/ErrorBoundary"; +import { proxyLazy } from "@utils/lazy"; +import { classes } from "@utils/misc"; +import { filters, findBulk } from "@webpack"; +import { i18n, PermissionsBits, Text, Tooltip, useMemo, UserStore, useState } from "@webpack/common"; +import type { Guild, GuildMember } from "discord-types/general"; + +import { settings } from ".."; +import { cl, getPermissionString, getSortedRoles, sortUserRoles } from "../utils"; +import openRolesAndUsersPermissionsModal, { PermissionType, type RoleOrUserPermission } from "./RolesAndUsersPermissions"; + +interface UserPermission { + permission: string; + roleColor: string; + rolePosition: number; +} + +type UserPermissions = Array; + +const Classes = proxyLazy(() => { + const modules = findBulk( + filters.byProps("roles", "rolePill", "rolePillBorder"), + filters.byProps("roleCircle", "dotBorderBase", "dotBorderColor"), + filters.byProps("roleNameOverflow", "root", "roleName", "roleRemoveButton") + ); + + return Object.assign({}, ...modules); +}) as Record<"roles" | "rolePill" | "rolePillBorder" | "desaturateUserColors" | "flex" | "alignCenter" | "justifyCenter" | "svg" | "background" | "dot" | "dotBorderColor" | "roleCircle" | "dotBorderBase" | "flex" | "alignCenter" | "justifyCenter" | "wrap" | "root" | "role" | "roleRemoveButton" | "roleDot" | "roleFlowerStar" | "roleRemoveIcon" | "roleRemoveIconFocused" | "roleVerifiedIcon" | "roleName" | "roleNameOverflow" | "actionButton" | "overflowButton" | "addButton" | "addButtonIcon" | "overflowRolesPopout" | "overflowRolesPopoutArrowWrapper" | "overflowRolesPopoutArrow" | "popoutBottom" | "popoutTop" | "overflowRolesPopoutHeader" | "overflowRolesPopoutHeaderIcon" | "overflowRolesPopoutHeaderText" | "roleIcon", string>; + +function UserPermissionsComponent({ guild, guildMember }: { guild: Guild; guildMember: GuildMember; }) { + const [viewPermissions, setViewPermissions] = useState(settings.store.defaultPermissionsDropdownState); + + const [rolePermissions, userPermissions] = useMemo(() => { + const userPermissions: UserPermissions = []; + + const userRoles = getSortedRoles(guild, guildMember); + + const rolePermissions: Array = userRoles.map(role => ({ + type: PermissionType.Role, + ...role + })); + + if (guild.ownerId === guildMember.userId) { + rolePermissions.push({ + type: PermissionType.Owner, + permissions: Object.values(PermissionsBits).reduce((prev, curr) => prev | curr, 0n) + }); + + const OWNER = i18n.Messages.GUILD_OWNER || "Server Owner"; + userPermissions.push({ + permission: OWNER, + roleColor: "var(--primary-300)", + rolePosition: Infinity + }); + } + + sortUserRoles(userRoles); + + for (const [permission, bit] of Object.entries(PermissionsBits)) { + for (const { permissions, colorString, position, name } of userRoles) { + if ((permissions & bit) === bit) { + userPermissions.push({ + permission: getPermissionString(permission), + roleColor: colorString || "var(--primary-300)", + rolePosition: position + }); + + break; + } + } + } + + userPermissions.sort((a, b) => b.rolePosition - a.rolePosition); + + return [rolePermissions, userPermissions]; + }, []); + + const { root, role, roleRemoveButton, roleNameOverflow, roles, rolePill, rolePillBorder, roleCircle, roleName } = Classes; + + return ( +
+
+ Permissions + +
+ + {tooltipProps => ( + + )} + + + + {tooltipProps => ( + + )} + +
+
+ + {viewPermissions && userPermissions.length > 0 && ( +
+ {userPermissions.map(({ permission, roleColor }) => ( +
+
+ +
+
+ + {permission} + +
+
+ ))} +
+ )} +
+ ); +} + +export default ErrorBoundary.wrap(UserPermissionsComponent, { noop: true }); diff --git a/src/plugins/permissionsViewer/components/icons.tsx b/src/plugins/permissionsViewer/components/icons.tsx new file mode 100644 index 000000000..8b58a440f --- /dev/null +++ b/src/plugins/permissionsViewer/components/icons.tsx @@ -0,0 +1,58 @@ +/* + * 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 . +*/ + +export function PermissionDeniedIcon() { + return ( + + Denied + + + ); +} + +export function PermissionAllowedIcon() { + return ( + + Allowed + + + ); +} + +export function PermissionDefaultIcon() { + return ( + + + Not overwritten + + + + ); +} diff --git a/src/plugins/permissionsViewer/index.tsx b/src/plugins/permissionsViewer/index.tsx new file mode 100644 index 000000000..208fef381 --- /dev/null +++ b/src/plugins/permissionsViewer/index.tsx @@ -0,0 +1,189 @@ +/* + * 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 "./styles.css"; + +import { addContextMenuPatch, findGroupChildrenByChildId, NavContextMenuPatchCallback, removeContextMenuPatch } from "@api/ContextMenu"; +import { definePluginSettings } from "@api/Settings"; +import { Devs } from "@utils/constants"; +import definePlugin, { OptionType } from "@utils/types"; +import { ChannelStore, GuildMemberStore, GuildStore, Menu, PermissionsBits, UserStore } from "@webpack/common"; +import type { Guild, GuildMember } from "discord-types/general"; + +import openRolesAndUsersPermissionsModal, { PermissionType, RoleOrUserPermission } from "./components/RolesAndUsersPermissions"; +import UserPermissions from "./components/UserPermissions"; +import { getSortedRoles } from "./utils"; + +export const enum PermissionsSortOrder { + HighestRole, + LowestRole +} + +const enum MenuItemParentType { + User, + Channel, + Guild +} + +export const settings = definePluginSettings({ + permissionsSortOrder: { + description: "The sort method used for defining which role grants an user a certain permission", + type: OptionType.SELECT, + options: [ + { label: "Highest Role", value: PermissionsSortOrder.HighestRole, default: true }, + { label: "Lowest Role", value: PermissionsSortOrder.LowestRole } + ], + }, + defaultPermissionsDropdownState: { + description: "Whether the permissions dropdown on user popouts should be open by default", + type: OptionType.BOOLEAN, + default: false, + } +}); + +function MenuItem(guildId: string, id?: string, type?: MenuItemParentType) { + if (type === MenuItemParentType.User && !GuildMemberStore.isMember(guildId, id!)) return null; + + return ( + { + const guild = GuildStore.getGuild(guildId); + + let permissions: RoleOrUserPermission[]; + let header: string; + + switch (type) { + case MenuItemParentType.User: { + const member = GuildMemberStore.getMember(guildId, id!); + + permissions = getSortedRoles(guild, member) + .map(role => ({ + type: PermissionType.Role, + ...role + })); + + if (guild.ownerId === id) { + permissions.push({ + type: PermissionType.Owner, + permissions: Object.values(PermissionsBits).reduce((prev, curr) => prev | curr, 0n) + }); + } + + header = member.nick ?? UserStore.getUser(member.userId).username; + + break; + } + + case MenuItemParentType.Channel: { + const channel = ChannelStore.getChannel(id!); + + permissions = Object.values(channel.permissionOverwrites).map(({ id, allow, deny, type }) => ({ + type: type as PermissionType, + id, + overwriteAllow: allow, + overwriteDeny: deny + })); + + header = channel.name; + + break; + } + + default: { + permissions = Object.values(guild.roles).map(role => ({ + type: PermissionType.Role, + ...role + })); + + header = guild.name; + + break; + } + } + + openRolesAndUsersPermissionsModal(permissions, guild, header); + }} + /> + ); +} + +function makeContextMenuPatch(childId: string | string[], type?: MenuItemParentType): NavContextMenuPatchCallback { + return (children, props) => () => { + if (!props) return children; + + const group = findGroupChildrenByChildId(childId, children); + + const item = (() => { + switch (type) { + case MenuItemParentType.User: + return MenuItem(props.guildId, props.user.id, type); + case MenuItemParentType.Channel: + return MenuItem(props.guild.id, props.channel.id, type); + case MenuItemParentType.Guild: + return MenuItem(props.guild.id); + default: + return null; + } + })(); + + if (item == null) return; + + if (group) + group.push(item); + else if (childId === "roles" && props.guildId) + // "roles" may not be present due to the member not having any roles. In that case, add it above "Copy ID" + children.splice(-1, 0, {item}); + }; +} + +export default definePlugin({ + name: "PermissionsViewer", + description: "View the permissions a user or channel has, and the roles of a server", + authors: [Devs.Nuckyz, Devs.Ven], + settings, + + patches: [ + { + find: ".Messages.BOT_PROFILE_SLASH_COMMANDS", + replacement: { + match: /showBorder:.{0,60}}\),(?<=guild:(\i),guildMember:(\i),.+?)/, + replace: (m, guild, guildMember) => `${m}$self.UserPermissions(${guild},${guildMember}),` + } + } + ], + + UserPermissions: (guild: Guild, guildMember?: GuildMember) => !!guildMember && , + + userContextMenuPatch: makeContextMenuPatch("roles", MenuItemParentType.User), + channelContextMenuPatch: makeContextMenuPatch(["mute-channel", "unmute-channel"], MenuItemParentType.Channel), + guildContextMenuPatch: makeContextMenuPatch("privacy", MenuItemParentType.Guild), + + start() { + addContextMenuPatch("user-context", this.userContextMenuPatch); + addContextMenuPatch("channel-context", this.channelContextMenuPatch); + addContextMenuPatch("guild-context", this.guildContextMenuPatch); + }, + + stop() { + removeContextMenuPatch("user-context", this.userContextMenuPatch); + removeContextMenuPatch("channel-context", this.channelContextMenuPatch); + removeContextMenuPatch("guild-context", this.guildContextMenuPatch); + }, +}); diff --git a/src/plugins/permissionsViewer/styles.css b/src/plugins/permissionsViewer/styles.css new file mode 100644 index 000000000..a6b7cfea2 --- /dev/null +++ b/src/plugins/permissionsViewer/styles.css @@ -0,0 +1,129 @@ +/* User Permissions Component */ + +.vc-permviewer-userperms-title-container { + display: flex; + justify-content: space-between; +} + +.vc-permviewer-userperms-title { + margin-top: 10px; + margin-bottom: 6px; +} + +.vc-permviewer-userperms-permdetails-btn { + all: unset; + cursor: pointer; +} + +.vc-permviewer-userperms-toggleperms-btn { + all: unset; + cursor: pointer; +} + +/* RolesAndUsersPermissions Component */ + +.vc-permviewer-perms-title { + flex-grow: 1; +} + +.vc-permviewer-perms-no-perms { + width: 100%; + height: 100%; + display: flex; + align-items: center; + justify-content: center; + text-align: center; +} + +.vc-permviewer-perms-container { + display: grid; + grid-template-columns: 1fr 2fr; + grid-template-areas: "list permissions"; + padding: 16px 0; +} + +.vc-permviewer-perms-list { + grid-area: list; + display: flex; + flex-direction: column; + border-right: 2px solid var(--background-modifier-active); +} + +.vc-permviewer-perms-list-item-btn { + all: unset; + cursor: pointer; +} + +.vc-permviewer-perms-list-item { + display: flex; + align-items: center; + padding: 8px 5px; + cursor: pointer; + width: 230px; +} + +.vc-permviewer-perms-list-item > div { + text-overflow: ellipsis; + white-space: nowrap; + overflow: hidden; +} + +.vc-permviewer-perms-list-item-active { + background-color: var(--background-modifier-selected); + border-radius: 5px; +} + +.vc-permviewer-perms-role-circle { + border-radius: 50%; + width: 12px; + height: 12px; + margin-left: 3px; + margin-right: 11px; + flex-shrink: 0; +} + +.vc-permviewer-perms-user-img { + border-radius: 50%; + width: 20px; + height: 20px; + margin-right: 6px; +} + +.vc-permviewer-perms-perms { + grid-area: permissions; + display: flex; + flex-direction: column; + margin-left: 5px; +} + +.vc-permviewer-perms-perms-item { + position: relative; + display: flex; + align-items: center; + padding: 10px; + border-bottom: 2px solid var(--background-modifier-active); +} + +.vc-permviewer-perms-perms-item:last-child { + border: 0; +} + +.vc-permviewer-perms-perms-item-icon { + border: 1px solid var(--background-modifier-selected); + width: 24px; + height: 24px; + margin-right: 5px; +} + +.vc-permviewer-perms-perms-item .vc-info-icon { + color: var(--interactive-muted); + cursor: pointer; + position: absolute; + right: 0; + scale: 0.9; + transition: color ease-in 0.1s; +} + +.vc-permviewer-perms-perms-item .vc-info-icon:hover { + color: var(--interactive-active); +} diff --git a/src/plugins/permissionsViewer/utils.ts b/src/plugins/permissionsViewer/utils.ts new file mode 100644 index 000000000..b74714797 --- /dev/null +++ b/src/plugins/permissionsViewer/utils.ts @@ -0,0 +1,84 @@ +/* + * 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 { classNameFactory } from "@api/Styles"; +import { wordsToTitle } from "@utils/text"; +import { i18n, Parser } from "@webpack/common"; +import { Guild, GuildMember, Role } from "discord-types/general"; +import type { ReactNode } from "react"; + +import { PermissionsSortOrder, settings } from "."; + +export const cl = classNameFactory("vc-permviewer-"); + +function formatPermissionWithoutMatchingString(permission: string) { + return wordsToTitle(permission.toLowerCase().split("_")); +} + +// because discord is unable to be consistent with their names +const PermissionKeyMap = { + MANAGE_GUILD: "MANAGE_SERVER", + MANAGE_GUILD_EXPRESSIONS: "MANAGE_EXPRESSIONS", + CREATE_GUILD_EXPRESSIONS: "CREATE_EXPRESSIONS", + MODERATE_MEMBERS: "MODERATE_MEMBER", // HELLOOOO ?????? + STREAM: "VIDEO", + SEND_VOICE_MESSAGES: "ROLE_PERMISSIONS_SEND_VOICE_MESSAGE", +} as const; + +export function getPermissionString(permission: string) { + permission = PermissionKeyMap[permission] || permission; + + return i18n.Messages[permission] || + // shouldn't get here but just in case + formatPermissionWithoutMatchingString(permission); +} + +export function getPermissionDescription(permission: string): ReactNode { + // DISCORD PLEEEEEEEEAAAAASE IM BEGGING YOU :( + if (permission === "USE_APPLICATION_COMMANDS") + permission = "USE_APPLICATION_COMMANDS_GUILD"; + else if (permission === "SEND_VOICE_MESSAGES") + permission = "SEND_VOICE_MESSAGE_GUILD"; + else if (permission !== "STREAM") + permission = PermissionKeyMap[permission] || permission; + + const msg = i18n.Messages[`ROLE_PERMISSIONS_${permission}_DESCRIPTION`] as any; + if (msg?.hasMarkdown) + return Parser.parse(msg.message); + + if (typeof msg === "string") return msg; + + return ""; +} + +export function getSortedRoles({ roles, id }: Guild, member: GuildMember) { + return [...member.roles, id] + .map(id => roles[id]) + .sort((a, b) => b.position - a.position); +} + +export function sortUserRoles(roles: Role[]) { + switch (settings.store.permissionsSortOrder) { + case PermissionsSortOrder.HighestRole: + return roles.sort((a, b) => b.position - a.position); + case PermissionsSortOrder.LowestRole: + return roles.sort((a, b) => a.position - b.position); + default: + return roles; + } +} diff --git a/src/plugins/petpet.ts b/src/plugins/petpet.ts index 472c6c9bb..9b1c2f162 100644 --- a/src/plugins/petpet.ts +++ b/src/plugins/petpet.ts @@ -19,7 +19,7 @@ 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 { makeLazy } from "@utils/lazy"; import definePlugin from "@utils/types"; import { findByCodeLazy, findByPropsLazy } from "@webpack"; diff --git a/src/plugins/pinDms/settings.ts b/src/plugins/pinDms/settings.ts index e8bd267a9..1e0244ed7 100644 --- a/src/plugins/pinDms/settings.ts +++ b/src/plugins/pinDms/settings.ts @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import { definePluginSettings, Settings, useSettings } from "@api/settings"; +import { definePluginSettings, Settings, useSettings } from "@api/Settings"; import { OptionType } from "@utils/types"; import { findStoreLazy } from "@webpack"; diff --git a/src/plugins/platformIndicators.tsx b/src/plugins/platformIndicators.tsx index 6ffc25999..6a7a8be74 100644 --- a/src/plugins/platformIndicators.tsx +++ b/src/plugins/platformIndicators.tsx @@ -19,7 +19,7 @@ import { addBadge, BadgePosition, ProfileBadge, removeBadge } from "@api/Badges"; import { addDecorator, removeDecorator } from "@api/MemberListDecorators"; import { addDecoration, removeDecoration } from "@api/MessageDecorations"; -import { Settings } from "@api/settings"; +import { Settings } from "@api/Settings"; import ErrorBoundary from "@components/ErrorBoundary"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; @@ -29,15 +29,15 @@ import { User } from "discord-types/general"; const SessionsStore = findStoreLazy("SessionsStore"); -function Icon(path: string, viewBox = "0 0 24 24") { +function Icon(path: string, opts?: { viewBox?: string; width?: number; height?: number; }) { return ({ color, tooltip }: { color: string; tooltip: string; }) => ( {(tooltipProps: any) => ( @@ -50,8 +50,8 @@ function Icon(path: string, viewBox = "0 0 24 24") { const Icons = { desktop: Icon("M4 2.5c-1.103 0-2 .897-2 2v11c0 1.104.897 2 2 2h7v2H7v2h10v-2h-4v-2h7c1.103 0 2-.896 2-2v-11c0-1.103-.897-2-2-2H4Zm16 2v9H4v-9h16Z"), web: Icon("M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2Zm-1 17.93c-3.95-.49-7-3.85-7-7.93 0-.62.08-1.21.21-1.79L9 15v1c0 1.1.9 2 2 2v1.93Zm6.9-2.54c-.26-.81-1-1.39-1.9-1.39h-1v-3c0-.55-.45-1-1-1H8v-2h2c.55 0 1-.45 1-1V7h2c1.1 0 2-.9 2-2v-.41c2.93 1.19 5 4.06 5 7.41 0 2.08-.8 3.97-2.1 5.39Z"), - mobile: Icon("M15.5 1h-8A2.5 2.5 0 0 0 5 3.5v17A2.5 2.5 0 0 0 7.5 23h8a2.5 2.5 0 0 0 2.5-2.5v-17A2.5 2.5 0 0 0 15.5 1zm-4 21c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5zm4.5-4H7V4h9v14z"), - console: Icon("M14.8 2.7 9 3.1V47h3.3c1.7 0 6.2.3 10 .7l6.7.6V2l-4.2.2c-2.4.1-6.9.3-10 .5zm1.8 6.4c1 1.7-1.3 3.6-2.7 2.2C12.7 10.1 13.5 8 15 8c.5 0 1.2.5 1.6 1.1zM16 33c0 6-.4 10-1 10s-1-4-1-10 .4-10 1-10 1 4 1 10zm15-8v23.3l3.8-.7c2-.3 4.7-.6 6-.6H43V3h-2.2c-1.3 0-4-.3-6-.6L31 1.7V25z", "0 0 50 50"), + mobile: Icon("M 187 0 L 813 0 C 916.277 0 1000 83.723 1000 187 L 1000 1313 C 1000 1416.277 916.277 1500 813 1500 L 187 1500 C 83.723 1500 0 1416.277 0 1313 L 0 187 C 0 83.723 83.723 0 187 0 Z M 125 1000 L 875 1000 L 875 250 L 125 250 Z M 500 1125 C 430.964 1125 375 1180.964 375 1250 C 375 1319.036 430.964 1375 500 1375 C 569.036 1375 625 1319.036 625 1250 C 625 1180.964 569.036 1125 500 1125 Z", { viewBox: "0 0 1000 1500", height: 17, width: 17 }), + console: Icon("M14.8 2.7 9 3.1V47h3.3c1.7 0 6.2.3 10 .7l6.7.6V2l-4.2.2c-2.4.1-6.9.3-10 .5zm1.8 6.4c1 1.7-1.3 3.6-2.7 2.2C12.7 10.1 13.5 8 15 8c.5 0 1.2.5 1.6 1.1zM16 33c0 6-.4 10-1 10s-1-4-1-10 .4-10 1-10 1 4 1 10zm15-8v23.3l3.8-.7c2-.3 4.7-.6 6-.6H43V3h-2.2c-1.3 0-4-.3-6-.6L31 1.7V25z", { viewBox: "0 0 50 50" }), }; type Platform = keyof typeof Icons; @@ -66,7 +66,7 @@ const PlatformIcon = ({ platform, status }: { platform: Platform, status: string const getStatus = (id: string): Record => PresenceStore.getState()?.clientStatuses?.[id]; -const PlatformIndicator = ({ user, inline = false, marginLeft = "4px" }: { user: User; inline?: boolean; marginLeft?: string; }) => { +const PlatformIndicator = ({ user, wantMargin = true, wantTopMargin = false }: { user: User; wantMargin?: boolean; wantTopMargin?: boolean; }) => { if (!user || user.bot) return null; if (user.id === UserStore.getCurrentUser().id) { @@ -105,23 +105,28 @@ const PlatformIndicator = ({ user, inline = false, marginLeft = "4px" }: { user: if (!icons.length) return null; return ( -
{icons} -
+
); }; const badge: ProfileBadge = { - component: p => , + component: p => , position: BadgePosition.START, shouldShow: userInfo => !!Object.keys(getStatus(userInfo.user.id) ?? {}).length, key: "indicator" @@ -146,7 +151,7 @@ const indicatorLocations = { description: "Inside messages", onEnable: () => addDecoration("platform-indicator", props => - + ), onDisable: () => removeDecoration("platform-indicator") @@ -156,7 +161,7 @@ const indicatorLocations = { export default definePlugin({ name: "PlatformIndicators", description: "Adds platform indicators (Desktop, Mobile, Web...) to users", - authors: [Devs.kemo, Devs.TheSun, Devs.Nuckyz], + authors: [Devs.kemo, Devs.TheSun, Devs.Nuckyz, Devs.Ven], dependencies: ["MessageDecorationsAPI", "MemberListDecoratorsAPI"], start() { diff --git a/src/plugins/pronoundb/components/PronounsChatComponent.tsx b/src/plugins/pronoundb/components/PronounsChatComponent.tsx index 70a2bf3b0..3e51544bd 100644 --- a/src/plugins/pronoundb/components/PronounsChatComponent.tsx +++ b/src/plugins/pronoundb/components/PronounsChatComponent.tsx @@ -16,66 +16,61 @@ * along with this program. If not, see . */ -import { Settings } from "@api/settings"; import { classes } from "@utils/misc"; import { findByPropsLazy } from "@webpack"; import { UserStore } from "@webpack/common"; import { Message } from "discord-types/general"; -import { awaitAndFormatPronouns } from "../pronoundbUtils"; +import { useFormattedPronouns } from "../pronoundbUtils"; +import { settings } from "../settings"; const styles: Record = findByPropsLazy("timestampInline"); +const AUTO_MODERATION_ACTION = 24; + function shouldShow(message: Message): boolean { - // Respect showInMessages - if (!Settings.plugins.PronounDB.showInMessages) + if (!settings.store.showInMessages) return false; - // Don't bother fetching bot or system users - if (message.author.bot || message.author.system) + if (message.author.bot || message.author.system || message.type === AUTO_MODERATION_ACTION) return false; - // Respect showSelf options - if (!Settings.plugins.PronounDB.showSelf && message.author.id === UserStore.getCurrentUser().id) + if (!settings.store.showSelf && message.author.id === UserStore.getCurrentUser().id) return false; return true; } export function PronounsChatComponentWrapper({ message }: { message: Message; }) { - if (!shouldShow(message)) - return null; - - return ; + return shouldShow(message) + ? + : null; } export function CompactPronounsChatComponentWrapper({ message }: { message: Message; }) { - if (!shouldShow(message)) - return null; - - return ; + return shouldShow(message) + ? + : null; } function PronounsChatComponent({ message }: { message: Message; }) { - const result = awaitAndFormatPronouns(message.author.id); - if (result != null) { - return ( + const result = useFormattedPronouns(message.author.id); + + return result + ? ( • {result} - ); - } - - return null; + ) + : null; } export function CompactPronounsChatComponent({ message }: { message: Message; }) { - const result = awaitAndFormatPronouns(message.author.id); - if (result != null) { - return ( + const result = useFormattedPronouns(message.author.id); + + return result + ? ( • {result} - ); - } - - return null; + ) + : null; } diff --git a/src/plugins/pronoundb/components/PronounsProfileWrapper.tsx b/src/plugins/pronoundb/components/PronounsProfileWrapper.tsx deleted file mode 100644 index 34cfab5a5..000000000 --- a/src/plugins/pronoundb/components/PronounsProfileWrapper.tsx +++ /dev/null @@ -1,61 +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 { UserStore } from "@webpack/common"; - -import { awaitAndFormatPronouns } from "../pronoundbUtils"; -import { UserProfilePronounsProps, UserProfileProps } from "../types"; - -export default function PronounsProfileWrapper(PronounsComponent: React.ElementType, props: UserProfilePronounsProps, profileProps: UserProfileProps) { - const user = UserStore.getUser(profileProps.userId) ?? {}; - // Respect showInProfile - if (!Settings.plugins.PronounDB.showInProfile) - return null; - // Don't bother fetching bot or system users - if (user.bot || user.system) - return null; - // Respect showSelf options - if (!Settings.plugins.PronounDB.showSelf && user.id === UserStore.getCurrentUser().id) - return null; - - return ; -} - -function ProfilePronouns( - { userId, Component, leProps }: { - userId: string; - Component: React.ElementType; - leProps: UserProfilePronounsProps; - } -) { - const result = awaitAndFormatPronouns(userId); - - // If the promise completed, the result was not "unspecified", and there is a mapping for the code, then render - if (result != null) { - // First child is the header, second is a div with the actual text - leProps.currentPronouns ||= result; - return ; - } - - return null; -} diff --git a/src/plugins/pronoundb/index.ts b/src/plugins/pronoundb/index.ts index 59ade8da8..227e07d55 100644 --- a/src/plugins/pronoundb/index.ts +++ b/src/plugins/pronoundb/index.ts @@ -19,20 +19,16 @@ import "./styles.css"; import { Devs } from "@utils/constants"; -import definePlugin, { OptionType } from "@utils/types"; +import definePlugin from "@utils/types"; import PronounsAboutComponent from "./components/PronounsAboutComponent"; import { CompactPronounsChatComponentWrapper, PronounsChatComponentWrapper } from "./components/PronounsChatComponent"; -import PronounsProfileWrapper from "./components/PronounsProfileWrapper"; - -export enum PronounsFormat { - Lowercase = "LOWERCASE", - Capitalized = "CAPITALIZED" -} +import { useProfilePronouns } from "./pronoundbUtils"; +import { settings } from "./settings"; export default definePlugin({ name: "PronounDB", - authors: [Devs.Tyman, Devs.TheKodeToad], + authors: [Devs.Tyman, Devs.TheKodeToad, Devs.Ven], description: "Adds pronouns to user messages using pronoundb", patches: [ // Add next to username (compact mode) @@ -51,59 +47,30 @@ export default definePlugin({ replace: "[$1, $self.PronounsChatComponentWrapper(e)]" } }, - // Hijack the discord pronouns section and add a wrapper around the text section + // Patch the profile popout username header to use our pronoun hook instead of Discord's pronouns { - find: ".Messages.BOT_PROFILE_SLASH_COMMANDS", + find: ".userTagNoNickname", replacement: { - match: /\(0,.\.jsx\)\((?\i\..),(?{currentPronouns.+?:(?\i)\.pronouns.+?})\)/, - replace: "$&&$self.PronounsProfileWrapper($,$,$)" + match: /=(\i)\.pronouns/, + replace: "=$self.useProfilePronouns($1.user.id)" } }, - // Force enable pronouns component ignoring the experiment value + // Patch the profile modal username header to use our pronoun hook instead of Discord's pronouns { - find: ".Messages.USER_POPOUT_PRONOUNS", + find: ".USER_PROFILE_ACTIVITY", replacement: { - match: /\.showPronouns/, - replace: ".showPronouns||true" + match: /\).showPronouns/, + replace: ").showPronouns||true;const vcPronounce=$self.useProfilePronouns(arguments[0].user.id);if(arguments[0].displayProfile)arguments[0].displayProfile.pronouns=vcPronounce" } } ], - options: { - pronounsFormat: { - type: OptionType.SELECT, - description: "The format for pronouns to appear in chat", - options: [ - { - label: "Lowercase", - value: PronounsFormat.Lowercase, - default: true - }, - { - label: "Capitalized", - value: PronounsFormat.Capitalized - } - ] - }, - showSelf: { - type: OptionType.BOOLEAN, - description: "Enable or disable showing pronouns for the current user", - default: true - }, - showInMessages: { - type: OptionType.BOOLEAN, - description: "Show in messages", - default: true - }, - showInProfile: { - type: OptionType.BOOLEAN, - description: "Show in profile", - default: true - } - }, + settings, + settingsAboutComponent: PronounsAboutComponent, + // Re-export the components on the plugin object so it is easily accessible in patches PronounsChatComponentWrapper, CompactPronounsChatComponentWrapper, - PronounsProfileWrapper + useProfilePronouns }); diff --git a/src/plugins/pronoundb/pronoundbUtils.ts b/src/plugins/pronoundb/pronoundbUtils.ts index c2354c353..6a1fb31c8 100644 --- a/src/plugins/pronoundb/pronoundbUtils.ts +++ b/src/plugins/pronoundb/pronoundbUtils.ts @@ -16,14 +16,20 @@ * along with this program. If not, see . */ -import { Settings } from "@api/settings"; +import { Settings } from "@api/Settings"; import { VENCORD_USER_AGENT } from "@utils/constants"; import { debounce } from "@utils/debounce"; -import { useAwaiter } from "@utils/misc"; +import { useAwaiter } from "@utils/react"; +import { UserStore } from "@webpack/common"; -import { PronounsFormat } from "."; +import { settings } from "./settings"; import { PronounCode, PronounMapping, PronounsResponse } from "./types"; +export const enum PronounsFormat { + Lowercase = "LOWERCASE", + Capitalized = "CAPITALIZED" +} + // A map of cached pronouns so the same request isn't sent twice const cache: Record = {}; // A map of ids and callbacks that should be triggered on fetch @@ -40,8 +46,8 @@ const bulkFetch = debounce(async () => { } }); -export function awaitAndFormatPronouns(id: string): string | null { - const [result, , isPending] = useAwaiter(() => fetchPronouns(id), { +export function useFormattedPronouns(id: string): string | null { + const [result] = useAwaiter(() => fetchPronouns(id), { fallbackValue: getCachedPronouns(id), onError: e => console.error("Fetching pronouns failed: ", e) }); @@ -53,6 +59,16 @@ export function awaitAndFormatPronouns(id: string): string | null { return null; } +export function useProfilePronouns(id: string) { + const pronouns = useFormattedPronouns(id); + + if (!settings.store.showInProfile) return null; + if (!settings.store.showSelf && id === UserStore.getCurrentUser().id) return null; + + return pronouns; +} + + // Gets the cached pronouns, if you're too impatient for a promise! export function getCachedPronouns(id: string): PronounCode | null { return cache[id] ?? null; diff --git a/src/plugins/pronoundb/settings.ts b/src/plugins/pronoundb/settings.ts new file mode 100644 index 000000000..2bd82887c --- /dev/null +++ b/src/plugins/pronoundb/settings.ts @@ -0,0 +1,55 @@ +/* + * 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 { definePluginSettings } from "@api/Settings"; +import { OptionType } from "@utils/types"; + +import { PronounsFormat } from "./pronoundbUtils"; + +export const settings = definePluginSettings({ + pronounsFormat: { + type: OptionType.SELECT, + description: "The format for pronouns to appear in chat", + options: [ + { + label: "Lowercase", + value: PronounsFormat.Lowercase, + default: true + }, + { + label: "Capitalized", + value: PronounsFormat.Capitalized + } + ] + }, + showSelf: { + type: OptionType.BOOLEAN, + description: "Enable or disable showing pronouns for the current user", + default: true + }, + showInMessages: { + type: OptionType.BOOLEAN, + description: "Show in messages", + default: true + }, + showInProfile: { + type: OptionType.BOOLEAN, + description: "Show in profile", + default: true + } +}); diff --git a/src/plugins/quickReply.ts b/src/plugins/quickReply.ts index d059b3327..d855f9e44 100644 --- a/src/plugins/quickReply.ts +++ b/src/plugins/quickReply.ts @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import { definePluginSettings, migratePluginSettings, Settings } from "@api/settings"; +import { definePluginSettings, Settings } from "@api/Settings"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; import { findByPropsLazy } from "@webpack"; @@ -29,7 +29,6 @@ const isMac = navigator.platform.includes("Mac"); // bruh let replyIdx = -1; let editIdx = -1; -migratePluginSettings("QuickReply", "InteractionKeybinds"); const enum MentionOptions { DISABLED, diff --git a/src/plugins/relationshipNotifier/settings.ts b/src/plugins/relationshipNotifier/settings.ts index 1ed36ea77..91126f201 100644 --- a/src/plugins/relationshipNotifier/settings.ts +++ b/src/plugins/relationshipNotifier/settings.ts @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import { definePluginSettings } from "@api/settings"; +import { definePluginSettings } from "@api/Settings"; import { OptionType } from "@utils/types"; export default definePluginSettings({ diff --git a/src/plugins/relationshipNotifier/utils.ts b/src/plugins/relationshipNotifier/utils.ts index 39b7fce7f..60fb0c6be 100644 --- a/src/plugins/relationshipNotifier/utils.ts +++ b/src/plugins/relationshipNotifier/utils.ts @@ -18,7 +18,7 @@ import { DataStore, Notices } from "@api/index"; import { showNotification } from "@api/Notifications"; -import { ChannelStore, GuildStore, RelationshipStore, UserStore, UserUtils } from "@webpack/common"; +import { ChannelStore, GuildMemberStore, GuildStore, RelationshipStore, UserStore, UserUtils } from "@webpack/common"; import settings from "./settings"; import { ChannelType, RelationshipType, SimpleGroupChannel, SimpleGuild } from "./types"; @@ -106,12 +106,16 @@ export function deleteGuild(id: string) { } export async function syncGuilds() { + guilds.clear(); + + const me = UserStore.getCurrentUser().id; for (const [id, { name, icon }] of Object.entries(GuildStore.getGuilds())) { - guilds.set(id, { - id, - name, - iconURL: icon && `https://cdn.discordapp.com/icons/${id}/${icon}.png` - }); + if (GuildMemberStore.isMember(id, me)) + guilds.set(id, { + id, + name, + iconURL: icon && `https://cdn.discordapp.com/icons/${id}/${icon}.png` + }); } await DataStore.set(guildsKey(), guilds); } @@ -126,6 +130,8 @@ export function deleteGroup(id: string) { } export async function syncGroups() { + groups.clear(); + for (const { type, id, name, rawRecipients, icon } of ChannelStore.getSortedPrivateChannels()) { if (type === ChannelType.GROUP_DM) groups.set(id, { diff --git a/src/plugins/reverseImageSearch.tsx b/src/plugins/reverseImageSearch.tsx index fd98d0fad..811e7ff08 100644 --- a/src/plugins/reverseImageSearch.tsx +++ b/src/plugins/reverseImageSearch.tsx @@ -17,6 +17,8 @@ */ import { addContextMenuPatch, findGroupChildrenByChildId, NavContextMenuPatchCallback, removeContextMenuPatch } from "@api/ContextMenu"; +import { Flex } from "@components/Flex"; +import { OpenExternalIcon } from "@components/Icons"; import { Devs } from "@utils/constants"; import definePlugin from "@utils/types"; import { Menu } from "@webpack/common"; @@ -28,7 +30,7 @@ const Engines = { IQDB: "https://iqdb.org/?url=", TinEye: "https://www.tineye.com/search?url=", ImgOps: "https://imgops.com/start?url=" -}; +} as const; function search(src: string, engine: string) { open(engine + encodeURIComponent(src), "_blank"); @@ -50,13 +52,28 @@ const imageContextMenuPatch: NavContextMenuPatchCallback = (children, props) => key="search-image" id="search-image" > - {Object.keys(Engines).map(engine => { + {Object.keys(Engines).map((engine, i) => { const key = "search-image-" + engine; return ( + = 3 // Do not round Google, Yandex & SauceNAO + ? "50%" + : void 0 + }} + aria-hidden="true" + height={16} + width={16} + src={new URL("/favicon.ico", Engines[engine]).toString().replace("lens.", "")} + /> + {engine} + + } action={() => search(src, Engines[engine])} /> ); @@ -64,7 +81,12 @@ const imageContextMenuPatch: NavContextMenuPatchCallback = (children, props) => + + All + + } action={() => Object.values(Engines).forEach(e => search(src, e))} /> @@ -76,6 +98,8 @@ export default definePlugin({ name: "ReverseImageSearch", description: "Adds ImageSearch to image context menus", authors: [Devs.Ven, Devs.Nuckyz], + tags: ["ImageUtilities"], + patches: [ { find: ".Messages.MESSAGE_ACTIONS_MENU_LABEL", diff --git a/src/plugins/reviewDB/Utils/ReviewDBAPI.ts b/src/plugins/reviewDB/Utils/ReviewDBAPI.ts index 74415bbec..62c89f5c9 100644 --- a/src/plugins/reviewDB/Utils/ReviewDBAPI.ts +++ b/src/plugins/reviewDB/Utils/ReviewDBAPI.ts @@ -16,9 +16,10 @@ * along with this program. If not, see . */ -import { Settings } from "@api/settings"; +import { Settings } from "@api/Settings"; import { Review } from "../entities/Review"; +import { ReviewDBUser } from "../entities/User"; import { authorize, showToast } from "./Utils"; const API_URL = "https://manti.vendicated.dev"; @@ -32,8 +33,12 @@ interface Response { updated: boolean; } +const WarningFlag = 0b00000010; + export async function getReviews(id: string): Promise { - const req = await fetch(API_URL + `/api/reviewdb/users/${id}/reviews`); + var flags = 0; + if (!Settings.plugins.ReviewDB.showWarning) flags |= WarningFlag; + const req = await fetch(API_URL + `/api/reviewdb/users/${id}/reviews?flags=${flags}`); const res = (req.status === 200) ? await req.json() as Response : { success: false, message: "An Error occured while fetching reviews. Please try again later.", reviews: [], updated: false }; if (!res.success) { @@ -43,6 +48,7 @@ export async function getReviews(id: string): Promise { id: 0, comment: "An Error occured while fetching reviews. Please try again later.", star: 0, + timestamp: 0, sender: { id: 0, username: "Error", @@ -108,8 +114,10 @@ export async function reportReview(id: number) { showToast(await res.message); } -export function getLastReviewID(id: string): Promise { - return fetch(API_URL + "/getLastReviewID?discordid=" + id) - .then(r => r.text()) - .then(Number); +export function getCurrentUserInfo(token: string): Promise { + return fetch(API_URL + "/api/reviewdb/users", { + body: JSON.stringify({ token }), + method: "POST", + }) + .then(r => r.json()); } diff --git a/src/plugins/reviewDB/Utils/Utils.tsx b/src/plugins/reviewDB/Utils/Utils.tsx index b3cb6cd89..42426b2b2 100644 --- a/src/plugins/reviewDB/Utils/Utils.tsx +++ b/src/plugins/reviewDB/Utils/Utils.tsx @@ -16,14 +16,14 @@ * along with this program. If not, see . */ -import { Settings } from "@api/settings"; -import { Devs } from "@utils/constants"; -import Logger from "@utils/Logger"; +import { Settings } from "@api/Settings"; +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"; +import { UserType } from "../entities/User"; export async function openUserProfileModal(userId: string) { await UserUtils.fetchUser(userId); @@ -44,20 +44,19 @@ export function authorize(callback?: any) { {...props} scopes={["identify"]} responseType="code" - redirectUri="https://manti.vendicated.dev/URauth" + redirectUri="https://manti.vendicated.dev/api/reviewdb/auth" permissions={0n} clientId="915703782174752809" cancelCompletesFlow={false} callback={async (u: string) => { try { const url = new URL(u); - url.searchParams.append("returnType", "json"); url.searchParams.append("clientMod", "vencord"); const res = await fetch(url, { headers: new Headers({ Accept: "application/json" }) }); - const { token, status } = await res.json(); - if (status === 0) { + const { token, success } = await res.json(); + if (success) { Settings.plugins.ReviewDB.token = token; showToast("Successfully logged in!"); callback?.(); @@ -65,7 +64,7 @@ export function authorize(callback?: any) { showToast("An Error occurred while logging in."); } } catch (e) { - new Logger("ReviewDB").error("Failed to authorise", e); + new Logger("ReviewDB").error("Failed to authorize", e); } }} /> @@ -86,10 +85,5 @@ export function showToast(text: string) { export const sleep = (ms: number) => new Promise(r => setTimeout(r, ms)); export function canDeleteReview(review: Review, userId: string) { - if (review.sender.discordID === userId) return true; - - const myId = BigInt(userId); - return myId === Devs.mantikafasi.id || - myId === Devs.Ven.id || - myId === Devs.rushii.id; + if (review.sender.discordID === userId || Settings.plugins.ReviewDB.user?.type === UserType.Admin) return true; } diff --git a/src/plugins/reviewDB/components/MessageButton.tsx b/src/plugins/reviewDB/components/MessageButton.tsx index 2e4bba749..3b8308ab1 100644 --- a/src/plugins/reviewDB/components/MessageButton.tsx +++ b/src/plugins/reviewDB/components/MessageButton.tsx @@ -16,11 +16,12 @@ * along with this program. If not, see . */ -import { classes, LazyComponent } from "@utils/misc"; +import { classes } from "@utils/misc"; +import { LazyComponent } from "@utils/react"; import { findByProps } from "@webpack"; export default LazyComponent(() => { - const { button, dangerous } = findByProps("button", "wrapper", "disabled","separator"); + const { button, dangerous } = findByProps("button", "wrapper", "disabled", "separator"); return function MessageButton(props) { return props.type === "delete" diff --git a/src/plugins/reviewDB/components/ReviewComponent.tsx b/src/plugins/reviewDB/components/ReviewComponent.tsx index 7eadeff8a..ac09b4cc5 100644 --- a/src/plugins/reviewDB/components/ReviewComponent.tsx +++ b/src/plugins/reviewDB/components/ReviewComponent.tsx @@ -16,9 +16,11 @@ * along with this program. If not, see . */ -import { classes, LazyComponent } from "@utils/misc"; +import { Settings } from "@api/Settings"; +import { classes } from "@utils/misc"; +import { LazyComponent } from "@utils/react"; import { filters, findBulk } from "@webpack"; -import { Alerts, UserStore } from "@webpack/common"; +import { Alerts, moment, Timestamp, UserStore } from "@webpack/common"; import { Review } from "../entities/Review"; import { deleteReview, reportReview } from "../Utils/ReviewDBAPI"; @@ -33,18 +35,16 @@ export default LazyComponent(() => { { cozyMessage, buttons, message, groupStart }, { container, isHeader }, { avatar, clickable, username, messageContent, wrapper, cozy }, - { contents }, buttonClasses, - { defaultColor } ] = findBulk( p("cozyMessage"), p("container", "isHeader"), p("avatar", "zalgo"), - p("contents"), p("button", "wrapper", "selected"), - p("defaultColor") ); + const dateFormat = new Intl.DateTimeFormat(); + return function ReviewComponent({ review, refetch }: { review: Review; refetch(): void; }) { function openModal() { openUserProfileModal(review.sender.discordID); @@ -87,7 +87,7 @@ export default LazyComponent(() => { } }> -
+
{ {review.sender.username} {review.sender.badges.map(badge => )} + + { + !Settings.plugins.ReviewDB.hideTimestamps && ( + + {dateFormat.format(review.timestamp * 1000)} + ) + } +

{review.comment}

diff --git a/src/plugins/reviewDB/components/ReviewsView.tsx b/src/plugins/reviewDB/components/ReviewsView.tsx index 466e9d450..ff46ccaa8 100644 --- a/src/plugins/reviewDB/components/ReviewsView.tsx +++ b/src/plugins/reviewDB/components/ReviewsView.tsx @@ -16,18 +16,21 @@ * along with this program. If not, see . */ -import { classes, useAwaiter } from "@utils/misc"; -import { findLazy } from "@webpack"; +import { Settings } from "@api/Settings"; +import { classes } from "@utils/misc"; +import { useAwaiter } from "@utils/react"; +import { findByPropsLazy } from "@webpack"; import { Forms, React, Text, UserStore } from "@webpack/common"; import type { KeyboardEvent } from "react"; import { addReview, getReviews } from "../Utils/ReviewDBAPI"; -import { showToast } from "../Utils/Utils"; +import { authorize, showToast } from "../Utils/Utils"; import ReviewComponent from "./ReviewComponent"; -const Classes = findLazy(m => typeof m.textarea === "string"); +const Classes = findByPropsLazy("inputDefault", "editable"); export default function ReviewsView({ userId }: { userId: string; }) { + const { token } = Settings.plugins.ReviewDB; const [refetchCount, setRefetchCount] = React.useState(0); const [reviews, _, isLoading] = useAwaiter(() => getReviews(userId), { fallbackValue: [], @@ -62,7 +65,7 @@ export default function ReviewsView({ userId }: { userId: string; }) { tag="h2" variant="eyebrow" style={{ - marginBottom: "12px", + marginBottom: "8px", color: "var(--header-primary)" }} > @@ -76,20 +79,40 @@ export default function ReviewsView({ userId }: { userId: string; }) { /> )} {reviews?.length === 0 && ( - + Looks like nobody reviewed this user yet. You could be the first! )}