From 955232f4d617079e81b2cefb4479197bfc580fc8 Mon Sep 17 00:00:00 2001 From: programminglaboratorys Date: Fri, 26 Apr 2024 14:46:13 +0300 Subject: [PATCH 01/22] adding the api --- src/api/Tablist.tsx | 67 +++++++++++++++++++++++++++++++++++++ src/api/index.ts | 6 ++++ src/plugins/_api/tablist.ts | 24 +++++++++++++ src/utils/constants.ts | 4 +++ 4 files changed, 101 insertions(+) create mode 100644 src/api/Tablist.tsx create mode 100644 src/plugins/_api/tablist.ts diff --git a/src/api/Tablist.tsx b/src/api/Tablist.tsx new file mode 100644 index 000000000..db21cb9b0 --- /dev/null +++ b/src/api/Tablist.tsx @@ -0,0 +1,67 @@ +import { Channel } from "discord-types/general"; +//import { Logger } from "@utils/Logger"; + +//const logger = new Logger("Tablist"); useless + +export interface ExpressionMate { + CHAT_INPUT_BUTTON_CLASSNAME: string; + expressionPickerViewType: object; + expressionPickerWidths: { MIN: "min", MAX: "max"; }; + MIN_EXPRESSION_PICKER_WIDTH: number; // what's really matter here +} + +export interface TablistButtonProps { + id?: string; + "aria-controls": string; + "aria-selected": boolean; + isActive: boolean; + viewType: string; + children: string | JSX.Element; + autoFocus?: boolean; + [key: string]: any; +} + +export interface TablistPanelProps { + selectedTab: string; + channel: Channel; + expressionMate: ExpressionMate; +} + +export type TablistButtonComponent = (props: TablistButtonProps) => JSX.Element | null; +export type TablistPanelComponent = (props: TablistPanelProps) => JSX.Element | null; + + +export interface TablistItem { + tab: string, + Component: TablistPanelComponent; + autoFocus?: boolean; +} + +const TablistComponents = new Map(); + + +export const addTablistButton = (id: string, tab: string, PanelComponent: TablistPanelComponent, autoFocus?: boolean) => TablistComponents.set(id, { tab: tab, Component: PanelComponent, autoFocus: autoFocus }); +export const removeTablistButton = (id: string) => TablistComponents.delete(id); + + +export function* RenderButtons(TablistButtonComponent: TablistButtonComponent, selectedTab: string, expressionMate: ExpressionMate) { + for (const tab in TablistComponents) { + yield ({TablistComponents[tab].tab} + ); + } +} + +export function* TabPanels(selectedTab: string, expressionMate: ExpressionMate, channel: Channel) { + for (const tab in TablistComponents) { + if (tab !== selectedTab) { continue; } + let PanelComponent: TablistPanelComponent = TablistComponents[tab].Component; + yield (); + } +} diff --git a/src/api/index.ts b/src/api/index.ts index 5dca63105..b9e022fcc 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -31,6 +31,7 @@ import * as $Notifications from "./Notifications"; import * as $ServerList from "./ServerList"; import * as $Settings from "./Settings"; import * as $Styles from "./Styles"; +import * as $Tablist from "./Tablist"; /** * An API allowing you to listen to Message Clicks or run your own logic @@ -110,3 +111,8 @@ export const ContextMenu = $ContextMenu; * An API allowing you to add buttons to the chat input */ export const ChatButtons = $ChatButtons; + +/** + * An API allowing you to add panels to the expression picker + */ +export const Tablist = $Tablist; diff --git a/src/plugins/_api/tablist.ts b/src/plugins/_api/tablist.ts new file mode 100644 index 000000000..2a1181e9a --- /dev/null +++ b/src/plugins/_api/tablist.ts @@ -0,0 +1,24 @@ +import definePlugin from "@utils/types"; +import { Devs } from "@utils/constants"; + + +export default definePlugin({ + name: "TablistApi", + description: "API to add panels to the expression picker", + authors: [Devs.iamme], + patches: [ + { + find: ".EXPRESSION_PICKER_CATEGORIES_A11Y_LABEL", + replacement: [ + { + match: /\.jsx)\((\i),\{id:\i\.\i,.+?,"aria-selected":(\i)===.+?,viewType:(\i).+?\}\)/,//\] + replace: "$&,...Vencord.Api.Tablist.RenderButtons($1, $2, $3)" + }, + { + match: /null,(\i)===(\i)\.ExpressionPickerViewType\.EMOJI\?.{0,55}channel:(\i),.+?\):null/, + replace: "$&,...Vencord.Api.Tablist.TabPanels($1, $2, $3)" + } + ] + } + ] +}); diff --git a/src/utils/constants.ts b/src/utils/constants.ts index 8ab0bffb3..0e8e16743 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -438,6 +438,10 @@ export const Devs = /* #__PURE__*/ Object.freeze({ name: "Sqaaakoi", id: 259558259491340288n }, + iamme: { + name: "i am me", + id: 984392761929256980n + }, Byron: { name: "byeoon", id: 1167275288036655133n From c7244d8b26e6df0306f858b7c4f115631ebdd8f6 Mon Sep 17 00:00:00 2001 From: programminglaboratorys Date: Sat, 27 Apr 2024 19:48:20 +0300 Subject: [PATCH 02/22] fixing some bugs to adapt with the new TablistComponents data type --- src/api/Tablist.tsx | 27 +++++++++++++-------------- src/plugins/_api/tablist.ts | 4 ++-- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/api/Tablist.tsx b/src/api/Tablist.tsx index db21cb9b0..a9271b627 100644 --- a/src/api/Tablist.tsx +++ b/src/api/Tablist.tsx @@ -1,4 +1,5 @@ import { Channel } from "discord-types/general"; +import ErrorBoundary from "@components/ErrorBoundary"; //import { Logger } from "@utils/Logger"; //const logger = new Logger("Tablist"); useless @@ -44,24 +45,22 @@ export const addTablistButton = (id: string, tab: string, PanelComponent: Tablis export const removeTablistButton = (id: string) => TablistComponents.delete(id); -export function* RenderButtons(TablistButtonComponent: TablistButtonComponent, selectedTab: string, expressionMate: ExpressionMate) { - for (const tab in TablistComponents) { +export function* RenderButtons(TablistButtonComponent: TablistButtonComponent, selectedTab: string) { + for (const [id, { tab }] of TablistComponents) { yield ({TablistComponents[tab].tab} - ); + id={id + "-picker-tab"} + aria-controls={id + "-picker-tab-panel"} + aria-selected={id === selectedTab} + viewType={id} + isActive={id === selectedTab} + >{tab}); } } export function* TabPanels(selectedTab: string, expressionMate: ExpressionMate, channel: Channel) { - for (const tab in TablistComponents) { - if (tab !== selectedTab) { continue; } - let PanelComponent: TablistPanelComponent = TablistComponents[tab].Component; - yield (); + for (const [id, { Component }] of TablistComponents) { + if (id !== selectedTab) { continue; } + let PanelComponent: TablistPanelComponent = Component; + yield (); } } diff --git a/src/plugins/_api/tablist.ts b/src/plugins/_api/tablist.ts index 2a1181e9a..02b2f9cef 100644 --- a/src/plugins/_api/tablist.ts +++ b/src/plugins/_api/tablist.ts @@ -11,8 +11,8 @@ export default definePlugin({ find: ".EXPRESSION_PICKER_CATEGORIES_A11Y_LABEL", replacement: [ { - match: /\.jsx)\((\i),\{id:\i\.\i,.+?,"aria-selected":(\i)===.+?,viewType:(\i).+?\}\)/,//\] - replace: "$&,...Vencord.Api.Tablist.RenderButtons($1, $2, $3)" + match: /\.jsx\)\((\i),\{id:\i\.E\i,.+?,"aria-selected":(\i)===\i\.\i\.EMOJI.+?,viewType:(\i).+?\}\)/, + replace: "$&,...Vencord.Api.Tablist.RenderButtons($1, $2)" }, { match: /null,(\i)===(\i)\.ExpressionPickerViewType\.EMOJI\?.{0,55}channel:(\i),.+?\):null/, From 2b252c4011a6ea82c5a8654331bdf7cf3323de73 Mon Sep 17 00:00:00 2001 From: programminglaboratorys <107296738+programminglaboratorys@users.noreply.github.com> Date: Mon, 20 May 2024 20:15:39 +0300 Subject: [PATCH 03/22] name update, and added ErrorBoundary to RenderTabButtons --- src/api/{Tablist.tsx => ExpressionPickerTabs.tsx} | 6 +++--- src/api/index.ts | 4 ++-- src/plugins/_api/{tablist.ts => expressionPickerTabs.ts} | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) rename src/api/{Tablist.tsx => ExpressionPickerTabs.tsx} (90%) rename src/plugins/_api/{tablist.ts => expressionPickerTabs.ts} (67%) diff --git a/src/api/Tablist.tsx b/src/api/ExpressionPickerTabs.tsx similarity index 90% rename from src/api/Tablist.tsx rename to src/api/ExpressionPickerTabs.tsx index a9271b627..e7ba82533 100644 --- a/src/api/Tablist.tsx +++ b/src/api/ExpressionPickerTabs.tsx @@ -45,15 +45,15 @@ export const addTablistButton = (id: string, tab: string, PanelComponent: Tablis export const removeTablistButton = (id: string) => TablistComponents.delete(id); -export function* RenderButtons(TablistButtonComponent: TablistButtonComponent, selectedTab: string) { +export function* RenderTabButtons(TablistButtonComponent: TablistButtonComponent, selectedTab: string) { for (const [id, { tab }] of TablistComponents) { - yield ({tab}); + >{tab}); } } diff --git a/src/api/index.ts b/src/api/index.ts index b9e022fcc..fa081819f 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -31,7 +31,7 @@ import * as $Notifications from "./Notifications"; import * as $ServerList from "./ServerList"; import * as $Settings from "./Settings"; import * as $Styles from "./Styles"; -import * as $Tablist from "./Tablist"; +import * as $ExpressionPickerTabs from "./ExpressionPickerTabs"; /** * An API allowing you to listen to Message Clicks or run your own logic @@ -115,4 +115,4 @@ export const ChatButtons = $ChatButtons; /** * An API allowing you to add panels to the expression picker */ -export const Tablist = $Tablist; +export const ExpressionPickerTabs = $ExpressionPickerTabs; diff --git a/src/plugins/_api/tablist.ts b/src/plugins/_api/expressionPickerTabs.ts similarity index 67% rename from src/plugins/_api/tablist.ts rename to src/plugins/_api/expressionPickerTabs.ts index 02b2f9cef..3af0e4304 100644 --- a/src/plugins/_api/tablist.ts +++ b/src/plugins/_api/expressionPickerTabs.ts @@ -3,8 +3,8 @@ import { Devs } from "@utils/constants"; export default definePlugin({ - name: "TablistApi", - description: "API to add panels to the expression picker", + name: "ExpressionPickerTabsAPI", + description: "an API to add panels to the expression picker", authors: [Devs.iamme], patches: [ { @@ -12,11 +12,11 @@ export default definePlugin({ replacement: [ { match: /\.jsx\)\((\i),\{id:\i\.E\i,.+?,"aria-selected":(\i)===\i\.\i\.EMOJI.+?,viewType:(\i).+?\}\)/, - replace: "$&,...Vencord.Api.Tablist.RenderButtons($1, $2)" + replace: "$&,...Vencord.Api.ExpressionPickerTabs.RenderTabButtons($1, $2)" }, { match: /null,(\i)===(\i)\.ExpressionPickerViewType\.EMOJI\?.{0,55}channel:(\i),.+?\):null/, - replace: "$&,...Vencord.Api.Tablist.TabPanels($1, $2, $3)" + replace: "$&,...Vencord.Api.ExpressionPickerTabs.TabPanels($1, $2, $3)" } ] } From 743c279adc38a0dd1fd9bb01fa5e387504dd6004 Mon Sep 17 00:00:00 2001 From: programminglaboratorys Date: Thu, 23 May 2024 07:55:55 +0300 Subject: [PATCH 04/22] following linter rules, and renaming functions/components to match the new name of the api --- src/api/ExpressionPickerTabs.tsx | 53 +++++++++++------------- src/api/index.ts | 2 +- src/plugins/_api/expressionPickerTabs.ts | 12 ++++-- 3 files changed, 34 insertions(+), 33 deletions(-) diff --git a/src/api/ExpressionPickerTabs.tsx b/src/api/ExpressionPickerTabs.tsx index e7ba82533..8b220f0b5 100644 --- a/src/api/ExpressionPickerTabs.tsx +++ b/src/api/ExpressionPickerTabs.tsx @@ -1,17 +1,13 @@ -import { Channel } from "discord-types/general"; +/* + * Vencord, a Discord client mod + * Copyright (c) 2024 Vendicated and contributors + * SPDX-License-Identifier: GPL-3.0-or-later + */ + import ErrorBoundary from "@components/ErrorBoundary"; -//import { Logger } from "@utils/Logger"; +import { Channel } from "discord-types/general"; -//const logger = new Logger("Tablist"); useless - -export interface ExpressionMate { - CHAT_INPUT_BUTTON_CLASSNAME: string; - expressionPickerViewType: object; - expressionPickerWidths: { MIN: "min", MAX: "max"; }; - MIN_EXPRESSION_PICKER_WIDTH: number; // what's really matter here -} - -export interface TablistButtonProps { +export interface ExpressionPickerButtonProps { id?: string; "aria-controls": string; "aria-selected": boolean; @@ -22,45 +18,44 @@ export interface TablistButtonProps { [key: string]: any; } -export interface TablistPanelProps { +export interface ExpressionPickerPanelProps { selectedTab: string; channel: Channel; - expressionMate: ExpressionMate; } -export type TablistButtonComponent = (props: TablistButtonProps) => JSX.Element | null; -export type TablistPanelComponent = (props: TablistPanelProps) => JSX.Element | null; +export type ExpressionPickerButtonComponent = (props: ExpressionPickerButtonProps) => JSX.Element | null; +export type ExpressionPickerPanelComponent = (props: ExpressionPickerPanelProps) => JSX.Element | null; -export interface TablistItem { +export interface ExpressionPickerTabItem { tab: string, - Component: TablistPanelComponent; + Component: ExpressionPickerPanelComponent; autoFocus?: boolean; } -const TablistComponents = new Map(); +const ExpressionPickerComponents = new Map(); -export const addTablistButton = (id: string, tab: string, PanelComponent: TablistPanelComponent, autoFocus?: boolean) => TablistComponents.set(id, { tab: tab, Component: PanelComponent, autoFocus: autoFocus }); -export const removeTablistButton = (id: string) => TablistComponents.delete(id); +export const addExpressionPickerTabButton = (id: string, tab: string, PanelComponent: ExpressionPickerPanelComponent, autoFocus?: boolean) => ExpressionPickerComponents.set(id, { tab: tab, Component: PanelComponent, autoFocus: autoFocus }); +export const removeExpressionPickerTabButton = (id: string) => ExpressionPickerComponents.delete(id); -export function* RenderTabButtons(TablistButtonComponent: TablistButtonComponent, selectedTab: string) { - for (const [id, { tab }] of TablistComponents) { - yield ({tab}); + >{tab}); } } -export function* TabPanels(selectedTab: string, expressionMate: ExpressionMate, channel: Channel) { - for (const [id, { Component }] of TablistComponents) { +export function* TabPanels(selectedTab: string, channel: Channel) { + for (const [id, { Component }] of ExpressionPickerComponents) { if (id !== selectedTab) { continue; } - let PanelComponent: TablistPanelComponent = Component; - yield (); + const PanelComponent: ExpressionPickerPanelComponent = Component; + yield (); } } diff --git a/src/api/index.ts b/src/api/index.ts index fa081819f..de6e7865b 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -21,6 +21,7 @@ import * as $ChatButtons from "./ChatButtons"; import * as $Commands from "./Commands"; import * as $ContextMenu from "./ContextMenu"; import * as $DataStore from "./DataStore"; +import * as $ExpressionPickerTabs from "./ExpressionPickerTabs"; import * as $MemberListDecorators from "./MemberListDecorators"; import * as $MessageAccessories from "./MessageAccessories"; import * as $MessageDecorations from "./MessageDecorations"; @@ -31,7 +32,6 @@ import * as $Notifications from "./Notifications"; import * as $ServerList from "./ServerList"; import * as $Settings from "./Settings"; import * as $Styles from "./Styles"; -import * as $ExpressionPickerTabs from "./ExpressionPickerTabs"; /** * An API allowing you to listen to Message Clicks or run your own logic diff --git a/src/plugins/_api/expressionPickerTabs.ts b/src/plugins/_api/expressionPickerTabs.ts index 3af0e4304..e75836a47 100644 --- a/src/plugins/_api/expressionPickerTabs.ts +++ b/src/plugins/_api/expressionPickerTabs.ts @@ -1,5 +1,11 @@ -import definePlugin from "@utils/types"; +/* + * Vencord, a Discord client mod + * Copyright (c) 2024 Vendicated and contributors + * SPDX-License-Identifier: GPL-3.0-or-later + */ + import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; export default definePlugin({ @@ -15,8 +21,8 @@ export default definePlugin({ replace: "$&,...Vencord.Api.ExpressionPickerTabs.RenderTabButtons($1, $2)" }, { - match: /null,(\i)===(\i)\.ExpressionPickerViewType\.EMOJI\?.{0,55}channel:(\i),.+?\):null/, - replace: "$&,...Vencord.Api.ExpressionPickerTabs.TabPanels($1, $2, $3)" + match: /null,(\i)===\i\.ExpressionPickerViewType\.EMOJI\?.{0,55}channel:(\i),.+?\):null/, + replace: "$&,...Vencord.Api.ExpressionPickerTabs.TabPanels($1, $3)" } ] } From 5daddac821c690c413daf20ee338cc4a9a38dfa9 Mon Sep 17 00:00:00 2001 From: programminglaboratorys Date: Thu, 23 May 2024 10:27:38 +0300 Subject: [PATCH 05/22] fix a patch --- src/plugins/_api/expressionPickerTabs.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/_api/expressionPickerTabs.ts b/src/plugins/_api/expressionPickerTabs.ts index e75836a47..33b1ef477 100644 --- a/src/plugins/_api/expressionPickerTabs.ts +++ b/src/plugins/_api/expressionPickerTabs.ts @@ -22,7 +22,7 @@ export default definePlugin({ }, { match: /null,(\i)===\i\.ExpressionPickerViewType\.EMOJI\?.{0,55}channel:(\i),.+?\):null/, - replace: "$&,...Vencord.Api.ExpressionPickerTabs.TabPanels($1, $3)" + replace: "$&,...Vencord.Api.ExpressionPickerTabs.TabPanels($1, $2)" } ] } From 78fd37a4c682ccc54085e5eb91f51b03a6b952ef Mon Sep 17 00:00:00 2001 From: Vendicated Date: Sat, 1 Jun 2024 19:13:27 +0200 Subject: [PATCH 06/22] fix(css): brand-experiment is now brand-500 --- src/api/Notifications/NotificationComponent.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/Notifications/NotificationComponent.tsx b/src/api/Notifications/NotificationComponent.tsx index caa4b64ef..d07143c45 100644 --- a/src/api/Notifications/NotificationComponent.tsx +++ b/src/api/Notifications/NotificationComponent.tsx @@ -113,7 +113,7 @@ export default ErrorBoundary.wrap(function NotificationComponent({ {timeout !== 0 && !permanent && (
)} From d8524b087c850443cee954d8582f18de98a6806e Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Sat, 1 Jun 2024 18:39:01 -0300 Subject: [PATCH 07/22] Add shortcut for lazy loading chunks --- scripts/generateReport.ts | 13 +- src/api/Settings.ts | 2 +- src/debug/loadLazyChunks.ts | 167 ++++++++++++++++++++++++++ src/debug/runReporter.ts | 163 ++----------------------- src/plugins/consoleShortcuts/index.ts | 2 + src/plugins/index.ts | 1 - src/plugins/partyMode/index.ts | 3 +- src/utils/Logger.ts | 2 +- 8 files changed, 191 insertions(+), 162 deletions(-) create mode 100644 src/debug/loadLazyChunks.ts diff --git a/scripts/generateReport.ts b/scripts/generateReport.ts index 0fde48637..cf4210779 100644 --- a/scripts/generateReport.ts +++ b/scripts/generateReport.ts @@ -241,17 +241,26 @@ page.on("console", async e => { error: await maybeGetError(e.args()[3]) ?? "Unknown error" }); + break; + case "LazyChunkLoader:": + console.error(await getText()); + + switch (message) { + case "A fatal error occurred:": + process.exit(1); + } + break; case "Reporter:": console.error(await getText()); switch (message) { + case "A fatal error occurred:": + process.exit(1); case "Webpack Find Fail:": process.exitCode = 1; report.badWebpackFinds.push(otherMessage); break; - case "A fatal error occurred:": - process.exit(1); case "Finished test": await browser.close(); await printReport(); diff --git a/src/api/Settings.ts b/src/api/Settings.ts index b94e6a3fd..70ba0bd4a 100644 --- a/src/api/Settings.ts +++ b/src/api/Settings.ts @@ -129,7 +129,7 @@ export const SettingsStore = new SettingsStoreClass(settings, { if (path === "plugins" && key in plugins) return target[key] = { - enabled: plugins[key].required ?? plugins[key].enabledByDefault ?? false + enabled: IS_REPORTER ?? plugins[key].required ?? plugins[key].enabledByDefault ?? false }; // Since the property is not set, check if this is a plugin's setting and if so, try to resolve diff --git a/src/debug/loadLazyChunks.ts b/src/debug/loadLazyChunks.ts new file mode 100644 index 000000000..d8f84335c --- /dev/null +++ b/src/debug/loadLazyChunks.ts @@ -0,0 +1,167 @@ +/* + * Vencord, a Discord client mod + * Copyright (c) 2024 Vendicated and contributors + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +import { Logger } from "@utils/Logger"; +import { canonicalizeMatch } from "@utils/patches"; +import * as Webpack from "@webpack"; +import { wreq } from "@webpack"; + +const LazyChunkLoaderLogger = new Logger("LazyChunkLoader"); + +export async function loadLazyChunks() { + try { + LazyChunkLoaderLogger.log("Loading all chunks..."); + + const validChunks = new Set(); + const invalidChunks = new Set(); + const deferredRequires = new Set(); + + let chunksSearchingResolve: (value: void | PromiseLike) => void; + const chunksSearchingDone = new Promise(r => chunksSearchingResolve = r); + + // True if resolved, false otherwise + const chunksSearchPromises = [] as Array<() => boolean>; + + const LazyChunkRegex = canonicalizeMatch(/(?:(?:Promise\.all\(\[)?(\i\.e\("[^)]+?"\)[^\]]*?)(?:\]\))?)\.then\(\i\.bind\(\i,"([^)]+?)"\)\)/g); + + async function searchAndLoadLazyChunks(factoryCode: string) { + const lazyChunks = factoryCode.matchAll(LazyChunkRegex); + const validChunkGroups = new Set<[chunkIds: string[], entryPoint: string]>(); + + // Workaround for a chunk that depends on the ChannelMessage component but may be be force loaded before + // the chunk containing the component + const shouldForceDefer = factoryCode.includes(".Messages.GUILD_FEED_UNFEATURE_BUTTON_TEXT"); + + await Promise.all(Array.from(lazyChunks).map(async ([, rawChunkIds, entryPoint]) => { + const chunkIds = rawChunkIds ? Array.from(rawChunkIds.matchAll(Webpack.ChunkIdsRegex)).map(m => m[1]) : []; + + if (chunkIds.length === 0) { + return; + } + + let invalidChunkGroup = false; + + for (const id of chunkIds) { + if (wreq.u(id) == null || wreq.u(id) === "undefined.js") continue; + + const isWasm = await fetch(wreq.p + wreq.u(id)) + .then(r => r.text()) + .then(t => (IS_WEB && t.includes(".module.wasm")) || !t.includes("(this.webpackChunkdiscord_app=this.webpackChunkdiscord_app||[]).push")); + + if (isWasm && IS_WEB) { + invalidChunks.add(id); + invalidChunkGroup = true; + continue; + } + + validChunks.add(id); + } + + if (!invalidChunkGroup) { + validChunkGroups.add([chunkIds, entryPoint]); + } + })); + + // Loads all found valid chunk groups + await Promise.all( + Array.from(validChunkGroups) + .map(([chunkIds]) => + Promise.all(chunkIds.map(id => wreq.e(id as any).catch(() => { }))) + ) + ); + + // Requires the entry points for all valid chunk groups + for (const [, entryPoint] of validChunkGroups) { + try { + if (shouldForceDefer) { + deferredRequires.add(entryPoint); + continue; + } + + if (wreq.m[entryPoint]) wreq(entryPoint as any); + } catch (err) { + console.error(err); + } + } + + // setImmediate to only check if all chunks were loaded after this function resolves + // We check if all chunks were loaded every time a factory is loaded + // If we are still looking for chunks in the other factories, the array will have that factory's chunk search promise not resolved + // But, if all chunk search promises are resolved, this means we found every lazy chunk loaded by Discord code and manually loaded them + setTimeout(() => { + let allResolved = true; + + for (let i = 0; i < chunksSearchPromises.length; i++) { + const isResolved = chunksSearchPromises[i](); + + if (isResolved) { + // Remove finished promises to avoid having to iterate through a huge array everytime + chunksSearchPromises.splice(i--, 1); + } else { + allResolved = false; + } + } + + if (allResolved) chunksSearchingResolve(); + }, 0); + } + + Webpack.factoryListeners.add(factory => { + let isResolved = false; + searchAndLoadLazyChunks(factory.toString()).then(() => isResolved = true); + + chunksSearchPromises.push(() => isResolved); + }); + + for (const factoryId in wreq.m) { + let isResolved = false; + searchAndLoadLazyChunks(wreq.m[factoryId].toString()).then(() => isResolved = true); + + chunksSearchPromises.push(() => isResolved); + } + + await chunksSearchingDone; + + // Require deferred entry points + for (const deferredRequire of deferredRequires) { + wreq!(deferredRequire as any); + } + + // All chunks Discord has mapped to asset files, even if they are not used anymore + const allChunks = [] as string[]; + + // Matches "id" or id: + for (const currentMatch of wreq!.u.toString().matchAll(/(?:"(\d+?)")|(?:(\d+?):)/g)) { + const id = currentMatch[1] ?? currentMatch[2]; + if (id == null) continue; + + allChunks.push(id); + } + + if (allChunks.length === 0) throw new Error("Failed to get all chunks"); + + // Chunks that are not loaded (not used) by Discord code anymore + const chunksLeft = allChunks.filter(id => { + return !(validChunks.has(id) || invalidChunks.has(id)); + }); + + await Promise.all(chunksLeft.map(async id => { + const isWasm = await fetch(wreq.p + wreq.u(id)) + .then(r => r.text()) + .then(t => (IS_WEB && t.includes(".module.wasm")) || !t.includes("(this.webpackChunkdiscord_app=this.webpackChunkdiscord_app||[]).push")); + + // Loads and requires a chunk + if (!isWasm) { + await wreq.e(id as any); + if (wreq.m[id]) wreq(id as any); + } + })); + + LazyChunkLoaderLogger.log("Finished loading all chunks!"); + } catch (e) { + LazyChunkLoaderLogger.log("A fatal error occurred:", e); + } +} diff --git a/src/debug/runReporter.ts b/src/debug/runReporter.ts index 61c9f162b..6c7a2a03f 100644 --- a/src/debug/runReporter.ts +++ b/src/debug/runReporter.ts @@ -5,171 +5,22 @@ */ import { Logger } from "@utils/Logger"; -import { canonicalizeMatch } from "@utils/patches"; import * as Webpack from "@webpack"; -import { wreq } from "@webpack"; import { patches } from "plugins"; +import { loadLazyChunks } from "./loadLazyChunks"; + const ReporterLogger = new Logger("Reporter"); async function runReporter() { - ReporterLogger.log("Starting test..."); - try { - const validChunks = new Set(); - const invalidChunks = new Set(); - const deferredRequires = new Set(); + ReporterLogger.log("Starting test..."); - let chunksSearchingResolve: (value: void | PromiseLike) => void; - const chunksSearchingDone = new Promise(r => chunksSearchingResolve = r); + let loadLazyChunksResolve: (value: void | PromiseLike) => void; + const loadLazyChunksDone = new Promise(r => loadLazyChunksResolve = r); - // True if resolved, false otherwise - const chunksSearchPromises = [] as Array<() => boolean>; - - const LazyChunkRegex = canonicalizeMatch(/(?:(?:Promise\.all\(\[)?(\i\.e\("[^)]+?"\)[^\]]*?)(?:\]\))?)\.then\(\i\.bind\(\i,"([^)]+?)"\)\)/g); - - async function searchAndLoadLazyChunks(factoryCode: string) { - const lazyChunks = factoryCode.matchAll(LazyChunkRegex); - const validChunkGroups = new Set<[chunkIds: string[], entryPoint: string]>(); - - // Workaround for a chunk that depends on the ChannelMessage component but may be be force loaded before - // the chunk containing the component - const shouldForceDefer = factoryCode.includes(".Messages.GUILD_FEED_UNFEATURE_BUTTON_TEXT"); - - await Promise.all(Array.from(lazyChunks).map(async ([, rawChunkIds, entryPoint]) => { - const chunkIds = rawChunkIds ? Array.from(rawChunkIds.matchAll(Webpack.ChunkIdsRegex)).map(m => m[1]) : []; - - if (chunkIds.length === 0) { - return; - } - - let invalidChunkGroup = false; - - for (const id of chunkIds) { - if (wreq.u(id) == null || wreq.u(id) === "undefined.js") continue; - - const isWasm = await fetch(wreq.p + wreq.u(id)) - .then(r => r.text()) - .then(t => (IS_WEB && t.includes(".module.wasm")) || !t.includes("(this.webpackChunkdiscord_app=this.webpackChunkdiscord_app||[]).push")); - - if (isWasm && IS_WEB) { - invalidChunks.add(id); - invalidChunkGroup = true; - continue; - } - - validChunks.add(id); - } - - if (!invalidChunkGroup) { - validChunkGroups.add([chunkIds, entryPoint]); - } - })); - - // Loads all found valid chunk groups - await Promise.all( - Array.from(validChunkGroups) - .map(([chunkIds]) => - Promise.all(chunkIds.map(id => wreq.e(id as any).catch(() => { }))) - ) - ); - - // Requires the entry points for all valid chunk groups - for (const [, entryPoint] of validChunkGroups) { - try { - if (shouldForceDefer) { - deferredRequires.add(entryPoint); - continue; - } - - if (wreq.m[entryPoint]) wreq(entryPoint as any); - } catch (err) { - console.error(err); - } - } - - // setImmediate to only check if all chunks were loaded after this function resolves - // We check if all chunks were loaded every time a factory is loaded - // If we are still looking for chunks in the other factories, the array will have that factory's chunk search promise not resolved - // But, if all chunk search promises are resolved, this means we found every lazy chunk loaded by Discord code and manually loaded them - setTimeout(() => { - let allResolved = true; - - for (let i = 0; i < chunksSearchPromises.length; i++) { - const isResolved = chunksSearchPromises[i](); - - if (isResolved) { - // Remove finished promises to avoid having to iterate through a huge array everytime - chunksSearchPromises.splice(i--, 1); - } else { - allResolved = false; - } - } - - if (allResolved) chunksSearchingResolve(); - }, 0); - } - - Webpack.beforeInitListeners.add(async () => { - ReporterLogger.log("Loading all chunks..."); - - Webpack.factoryListeners.add(factory => { - let isResolved = false; - searchAndLoadLazyChunks(factory.toString()).then(() => isResolved = true); - - chunksSearchPromises.push(() => isResolved); - }); - - // setImmediate to only search the initial factories after Discord initialized the app - // our beforeInitListeners are called before Discord initializes the app - setTimeout(() => { - for (const factoryId in wreq.m) { - let isResolved = false; - searchAndLoadLazyChunks(wreq.m[factoryId].toString()).then(() => isResolved = true); - - chunksSearchPromises.push(() => isResolved); - } - }, 0); - }); - - await chunksSearchingDone; - - // Require deferred entry points - for (const deferredRequire of deferredRequires) { - wreq!(deferredRequire as any); - } - - // All chunks Discord has mapped to asset files, even if they are not used anymore - const allChunks = [] as string[]; - - // Matches "id" or id: - for (const currentMatch of wreq!.u.toString().matchAll(/(?:"(\d+?)")|(?:(\d+?):)/g)) { - const id = currentMatch[1] ?? currentMatch[2]; - if (id == null) continue; - - allChunks.push(id); - } - - if (allChunks.length === 0) throw new Error("Failed to get all chunks"); - - // Chunks that are not loaded (not used) by Discord code anymore - const chunksLeft = allChunks.filter(id => { - return !(validChunks.has(id) || invalidChunks.has(id)); - }); - - await Promise.all(chunksLeft.map(async id => { - const isWasm = await fetch(wreq.p + wreq.u(id)) - .then(r => r.text()) - .then(t => (IS_WEB && t.includes(".module.wasm")) || !t.includes("(this.webpackChunkdiscord_app=this.webpackChunkdiscord_app||[]).push")); - - // Loads and requires a chunk - if (!isWasm) { - await wreq.e(id as any); - if (wreq.m[id]) wreq(id as any); - } - })); - - ReporterLogger.log("Finished loading all chunks!"); + Webpack.beforeInitListeners.add(() => loadLazyChunks().then((loadLazyChunksResolve))); + await loadLazyChunksDone; for (const patch of patches) { if (!patch.all) { diff --git a/src/plugins/consoleShortcuts/index.ts b/src/plugins/consoleShortcuts/index.ts index ee86b5fcf..0a1323e75 100644 --- a/src/plugins/consoleShortcuts/index.ts +++ b/src/plugins/consoleShortcuts/index.ts @@ -25,6 +25,7 @@ import definePlugin, { PluginNative, StartAt } from "@utils/types"; import * as Webpack from "@webpack"; import { extract, filters, findAll, findModuleId, search } from "@webpack"; import * as Common from "@webpack/common"; +import { loadLazyChunks } from "debug/loadLazyChunks"; import type { ComponentType } from "react"; const DESKTOP_ONLY = (f: string) => () => { @@ -82,6 +83,7 @@ function makeShortcuts() { wpsearch: search, wpex: extract, wpexs: (code: string) => extract(findModuleId(code)!), + loadLazyChunks: IS_DEV ? loadLazyChunks : () => { throw new Error("loadLazyChunks is dev only."); }, find, findAll: findAll, findByProps, diff --git a/src/plugins/index.ts b/src/plugins/index.ts index 53ab7983a..32bfe7e97 100644 --- a/src/plugins/index.ts +++ b/src/plugins/index.ts @@ -44,7 +44,6 @@ const settings = Settings.plugins; export function isPluginEnabled(p: string) { return ( - IS_REPORTER || Plugins[p]?.required || Plugins[p]?.isDependency || settings[p]?.enabled diff --git a/src/plugins/partyMode/index.ts b/src/plugins/partyMode/index.ts index 56c19c02c..c40f2e3c7 100644 --- a/src/plugins/partyMode/index.ts +++ b/src/plugins/partyMode/index.ts @@ -18,7 +18,7 @@ import { definePluginSettings, migratePluginSettings } from "@api/Settings"; import { Devs } from "@utils/constants"; -import definePlugin, { OptionType } from "@utils/types"; +import definePlugin, { OptionType, ReporterTestable } from "@utils/types"; import { FluxDispatcher } from "@webpack/common"; const enum Intensity { @@ -46,6 +46,7 @@ export default definePlugin({ name: "PartyMode", description: "Allows you to use party mode cause the party never ends ✨", authors: [Devs.UwUDev], + reporterTestable: ReporterTestable.None, settings, start() { diff --git a/src/utils/Logger.ts b/src/utils/Logger.ts index 5296184d4..22a381360 100644 --- a/src/utils/Logger.ts +++ b/src/utils/Logger.ts @@ -32,7 +32,7 @@ export class Logger { constructor(public name: string, public color: string = "white") { } private _log(level: "log" | "error" | "warn" | "info" | "debug", levelColor: string, args: any[], customFmt = "") { - if (IS_REPORTER) { + if (IS_REPORTER && IS_WEB) { console[level]("[Vencord]", this.name + ":", ...args); return; } From 6e6ee4db689808c380662de17f5ae9ed0d28036e Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Sat, 1 Jun 2024 23:39:58 -0300 Subject: [PATCH 08/22] NoPendingCount: Fix for message requests --- src/plugins/noPendingCount/index.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/plugins/noPendingCount/index.ts b/src/plugins/noPendingCount/index.ts index 29458df9d..57a65f52c 100644 --- a/src/plugins/noPendingCount/index.ts +++ b/src/plugins/noPendingCount/index.ts @@ -62,6 +62,16 @@ export default definePlugin({ replace: "return 0;" } }, + // New message requests hook + { + find: "useNewMessageRequestsCount:", + predicate: () => settings.store.hideMessageRequestsCount, + replacement: { + match: /getNonChannelAckId\(\i\.\i\.MESSAGE_REQUESTS\).+?return /, + replace: "$&0;" + } + }, + // Old message requests hook { find: "getMessageRequestsCount(){", predicate: () => settings.store.hideMessageRequestsCount, From d2cb9e9863bd2db4a06fac49796c693e47989fb8 Mon Sep 17 00:00:00 2001 From: programminglaboratorys <107296738+programminglaboratorys@users.noreply.github.com> Date: Mon, 3 Jun 2024 05:40:15 +0300 Subject: [PATCH 09/22] conflict resolving --- src/api/index.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/api/index.ts b/src/api/index.ts index de6e7865b..8b3a41c4d 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -116,3 +116,8 @@ export const ChatButtons = $ChatButtons; * An API allowing you to add panels to the expression picker */ export const ExpressionPickerTabs = $ExpressionPickerTabs; + +/** + * An API allowing you to update and re-render messages + */ +export const MessageUpdater = $MessageUpdater; \ No newline at end of file From 24202b0b2f4baab3f25504e4bed6a20d4c87f717 Mon Sep 17 00:00:00 2001 From: programminglaboratorys Date: Sat, 8 Jun 2024 12:38:38 +0300 Subject: [PATCH 10/22] resolving conflicts --- src/api/ExpressionPickerTabs.tsx | 61 +++++++ src/api/index.ts | 8 +- src/plugins/_api/expressionPickerTabs.ts | 30 +++ src/utils/constants.ts | 221 ++++++++++++----------- 4 files changed, 211 insertions(+), 109 deletions(-) create mode 100644 src/api/ExpressionPickerTabs.tsx create mode 100644 src/plugins/_api/expressionPickerTabs.ts diff --git a/src/api/ExpressionPickerTabs.tsx b/src/api/ExpressionPickerTabs.tsx new file mode 100644 index 000000000..8b220f0b5 --- /dev/null +++ b/src/api/ExpressionPickerTabs.tsx @@ -0,0 +1,61 @@ +/* + * Vencord, a Discord client mod + * Copyright (c) 2024 Vendicated and contributors + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +import ErrorBoundary from "@components/ErrorBoundary"; +import { Channel } from "discord-types/general"; + +export interface ExpressionPickerButtonProps { + id?: string; + "aria-controls": string; + "aria-selected": boolean; + isActive: boolean; + viewType: string; + children: string | JSX.Element; + autoFocus?: boolean; + [key: string]: any; +} + +export interface ExpressionPickerPanelProps { + selectedTab: string; + channel: Channel; +} + +export type ExpressionPickerButtonComponent = (props: ExpressionPickerButtonProps) => JSX.Element | null; +export type ExpressionPickerPanelComponent = (props: ExpressionPickerPanelProps) => JSX.Element | null; + + +export interface ExpressionPickerTabItem { + tab: string, + Component: ExpressionPickerPanelComponent; + autoFocus?: boolean; +} + +const ExpressionPickerComponents = new Map(); + + +export const addExpressionPickerTabButton = (id: string, tab: string, PanelComponent: ExpressionPickerPanelComponent, autoFocus?: boolean) => ExpressionPickerComponents.set(id, { tab: tab, Component: PanelComponent, autoFocus: autoFocus }); +export const removeExpressionPickerTabButton = (id: string) => ExpressionPickerComponents.delete(id); + + +export function* RenderTabButtons(ExpressionPickerButtonComponent: ExpressionPickerButtonComponent, selectedTab: string) { + for (const [id, { tab }] of ExpressionPickerComponents) { + yield ({tab}); + } +} + +export function* TabPanels(selectedTab: string, channel: Channel) { + for (const [id, { Component }] of ExpressionPickerComponents) { + if (id !== selectedTab) { continue; } + const PanelComponent: ExpressionPickerPanelComponent = Component; + yield (); + } +} diff --git a/src/api/index.ts b/src/api/index.ts index 02c70008a..b0742b327 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -14,13 +14,14 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see . -*/ + */ import * as $Badges from "./Badges"; import * as $ChatButtons from "./ChatButtons"; import * as $Commands from "./Commands"; import * as $ContextMenu from "./ContextMenu"; import * as $DataStore from "./DataStore"; +import * as $ExpressionPickerTabs from "./ExpressionPickerTabs"; import * as $MemberListDecorators from "./MemberListDecorators"; import * as $MessageAccessories from "./MessageAccessories"; import * as $MessageDecorations from "./MessageDecorations"; @@ -116,3 +117,8 @@ export const ChatButtons = $ChatButtons; * An API allowing you to update and re-render messages */ export const MessageUpdater = $MessageUpdater; + +/** + * An API allowing you to add panels to the expression picker + */ +export const ExpressionPickerTabs = $ExpressionPickerTabs; diff --git a/src/plugins/_api/expressionPickerTabs.ts b/src/plugins/_api/expressionPickerTabs.ts new file mode 100644 index 000000000..33b1ef477 --- /dev/null +++ b/src/plugins/_api/expressionPickerTabs.ts @@ -0,0 +1,30 @@ +/* + * Vencord, a Discord client mod + * Copyright (c) 2024 Vendicated and contributors + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; + + +export default definePlugin({ + name: "ExpressionPickerTabsAPI", + description: "an API to add panels to the expression picker", + authors: [Devs.iamme], + patches: [ + { + find: ".EXPRESSION_PICKER_CATEGORIES_A11Y_LABEL", + replacement: [ + { + match: /\.jsx\)\((\i),\{id:\i\.E\i,.+?,"aria-selected":(\i)===\i\.\i\.EMOJI.+?,viewType:(\i).+?\}\)/, + replace: "$&,...Vencord.Api.ExpressionPickerTabs.RenderTabButtons($1, $2)" + }, + { + match: /null,(\i)===\i\.ExpressionPickerViewType\.EMOJI\?.{0,55}channel:(\i),.+?\):null/, + replace: "$&,...Vencord.Api.ExpressionPickerTabs.TabPanels($1, $2)" + } + ] + } + ] +}); diff --git a/src/utils/constants.ts b/src/utils/constants.ts index ff754d5c2..b5ab291e4 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -14,7 +14,7 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see . -*/ + */ export const WEBPACK_CHUNK = "webpackChunkdiscord_app"; export const REACT_GLOBAL = "Vencord.Webpack.Common.React"; @@ -39,27 +39,27 @@ export const Devs = /* #__PURE__*/ Object.freeze({ }, Ven: { name: "Vendicated", - id: 343383572805058560n + id: 343383572805058560n, }, Arjix: { name: "ArjixWasTaken", - id: 674710789138939916n + id: 674710789138939916n, }, Cyn: { name: "Cynosphere", - id: 150745989836308480n + id: 150745989836308480n, }, Trwy: { name: "trey", - id: 354427199023218689n + id: 354427199023218689n, }, Megu: { name: "Megumin", - id: 545581357812678656n + id: 545581357812678656n, }, botato: { name: "botato", - id: 440990343899643943n + id: 440990343899643943n, }, fawn: { name: "fawn", @@ -67,11 +67,11 @@ export const Devs = /* #__PURE__*/ Object.freeze({ }, rushii: { name: "rushii", - id: 295190422244950017n + id: 295190422244950017n, }, Glitch: { name: "Glitchy", - id: 269567451199569920n + id: 269567451199569920n, }, Samu: { name: "Samu", @@ -79,19 +79,19 @@ export const Devs = /* #__PURE__*/ Object.freeze({ }, Nyako: { name: "nyako", - id: 118437263754395652n + id: 118437263754395652n, }, MaiKokain: { name: "Mai", - id: 722647978577363026n + id: 722647978577363026n, }, echo: { name: "ECHO", - id: 712639419785412668n + id: 712639419785412668n, }, katlyn: { name: "katlyn", - id: 250322741406859265n + id: 250322741406859265n, }, nea: { name: "nea", @@ -99,87 +99,87 @@ export const Devs = /* #__PURE__*/ Object.freeze({ }, Nuckyz: { name: "Nuckyz", - id: 235834946571337729n + id: 235834946571337729n, }, D3SOX: { name: "D3SOX", - id: 201052085641281538n + id: 201052085641281538n, }, Nickyux: { name: "Nickyux", - id: 427146305651998721n + id: 427146305651998721n, }, mantikafasi: { name: "mantikafasi", - id: 287555395151593473n + id: 287555395151593473n, }, Xinto: { name: "Xinto", - id: 423915768191647755n + id: 423915768191647755n, }, JacobTm: { name: "Jacob.Tm", - id: 302872992097107991n + id: 302872992097107991n, }, DustyAngel47: { name: "DustyAngel47", - id: 714583473804935238n + id: 714583473804935238n, }, BanTheNons: { name: "BanTheNons", - id: 460478012794863637n + id: 460478012794863637n, }, BigDuck: { name: "BigDuck", - id: 1024588272623681609n + id: 1024588272623681609n, }, AverageReactEnjoyer: { name: "Average React Enjoyer", - id: 1004904120056029256n + id: 1004904120056029256n, }, adryd: { name: "adryd", - id: 0n + id: 0n, }, Tyman: { name: "Tyman", - id: 487443883127472129n + id: 487443883127472129n, }, afn: { name: "afn", - id: 420043923822608384n + id: 420043923822608384n, }, KraXen72: { name: "KraXen72", - id: 379304073515499530n + id: 379304073515499530n, }, kemo: { name: "kemo", - id: 715746190813298788n + id: 715746190813298788n, }, dzshn: { name: "dzshn", - id: 310449948011528192n + id: 310449948011528192n, }, Ducko: { name: "Ducko", - id: 506482395269169153n + id: 506482395269169153n, }, jewdev: { name: "jewdev", - id: 222369866529636353n + id: 222369866529636353n, }, Luna: { name: "Luny", - id: 821472922140803112n + id: 821472922140803112n, }, Vap: { name: "Vap0r1ze", - id: 454072114492866560n + id: 454072114492866560n, }, KingFish: { name: "King Fish", - id: 499400512559382538n + id: 499400512559382538n, }, Commandtechno: { name: "Commandtechno", @@ -187,7 +187,7 @@ export const Devs = /* #__PURE__*/ Object.freeze({ }, TheSun: { name: "sunnie", - id: 406028027768733696n + id: 406028027768733696n, }, axyie: { name: "'ax", @@ -195,44 +195,44 @@ export const Devs = /* #__PURE__*/ Object.freeze({ }, pointy: { name: "pointy", - id: 99914384989519872n + id: 99914384989519872n, }, SammCheese: { name: "Samm-Cheese", - id: 372148345894076416n + id: 372148345894076416n, }, zt: { name: "zt", - id: 289556910426816513n + id: 289556910426816513n, }, captain: { name: "Captain", - id: 347366054806159360n + id: 347366054806159360n, }, nick: { name: "nick", id: 347884694408265729n, - badge: false + badge: false, }, whqwert: { name: "whqwert", - id: 586239091520176128n + id: 586239091520176128n, }, lewisakura: { name: "lewisakura", - id: 96269247411400704n + id: 96269247411400704n, }, RuiNtD: { name: "RuiNtD", - id: 157917665162297344n + id: 157917665162297344n, }, hunt: { name: "hunt-g", - id: 222800179697287168n + id: 222800179697287168n, }, cloudburst: { name: "cloudburst", - id: 892128204150685769n + id: 892128204150685769n, }, Aria: { name: "Syncxv", @@ -240,51 +240,51 @@ export const Devs = /* #__PURE__*/ Object.freeze({ }, TheKodeToad: { name: "TheKodeToad", - id: 706152404072267788n + id: 706152404072267788n, }, LordElias: { name: "LordElias", - id: 319460781567639554n + id: 319460781567639554n, }, juby: { name: "Juby210", - id: 324622488644616195n + id: 324622488644616195n, }, Alyxia: { name: "Alyxia Sother", - id: 952185386350829688n + id: 952185386350829688n, }, Remty: { name: "Remty", - id: 335055032204656642n + id: 335055032204656642n, }, skyevg: { name: "skyevg", - id: 1090310844283363348n + id: 1090310844283363348n, }, Dziurwa: { name: "Dziurwa", - id: 1001086404203389018n + id: 1001086404203389018n, }, arHSM: { name: "arHSM", - id: 841509053422632990n + id: 841509053422632990n, }, F53: { name: "F53", - id: 280411966126948353n + id: 280411966126948353n, }, AutumnVN: { name: "AutumnVN", - id: 393694671383166998n + id: 393694671383166998n, }, pylix: { name: "pylix", - id: 492949202121261067n + id: 492949202121261067n, }, Tyler: { name: "\\\\GGTyler\\\\", - id: 143117463788191746n + id: 143117463788191746n, }, RyanCaoDev: { name: "RyanCaoDev", @@ -292,27 +292,27 @@ export const Devs = /* #__PURE__*/ Object.freeze({ }, FieryFlames: { name: "Fiery", - id: 890228870559698955n + id: 890228870559698955n, }, KannaDev: { name: "Kanna", - id: 317728561106518019n + id: 317728561106518019n, }, carince: { name: "carince", - id: 818323528755314698n + id: 818323528755314698n, }, PandaNinjas: { name: "PandaNinjas", - id: 455128749071925248n + id: 455128749071925248n, }, CatNoir: { name: "CatNoir", - id: 260371016348336128n + id: 260371016348336128n, }, outfoxxed: { name: "outfoxxed", - id: 837425748435796060n + id: 837425748435796060n, }, UwUDev: { name: "UwU", @@ -320,39 +320,39 @@ export const Devs = /* #__PURE__*/ Object.freeze({ }, amia: { name: "amia", - id: 142007603549962240n + id: 142007603549962240n, }, phil: { name: "phil", - id: 305288513941667851n + id: 305288513941667851n, }, ImLvna: { name: "Luna <3", - id: 799319081723232267n + id: 799319081723232267n, }, rad: { name: "rad", - id: 610945092504780823n + id: 610945092504780823n, }, AndrewDLO: { name: "Andrew-DLO", - id: 434135504792059917n + id: 434135504792059917n, }, HypedDomi: { name: "HypedDomi", - id: 354191516979429376n + id: 354191516979429376n, }, Rini: { name: "Rini", - id: 1079479184478441643n + id: 1079479184478441643n, }, castdrian: { name: "castdrian", - id: 224617799434108928n + id: 224617799434108928n, }, Arrow: { name: "arrow", - id: 958158495302176778n + id: 958158495302176778n, }, bb010g: { name: "bb010g", @@ -372,19 +372,19 @@ export const Devs = /* #__PURE__*/ Object.freeze({ }, archeruwu: { name: "archer_uwu", - id: 160068695383736320n + id: 160068695383736320n, }, ProffDea: { name: "ProffDea", - id: 609329952180928513n + id: 609329952180928513n, }, UlyssesZhan: { name: "UlyssesZhan", - id: 586808226058862623n + id: 586808226058862623n, }, ant0n: { name: "ant0n", - id: 145224646868860928n + id: 145224646868860928n, }, Board: { name: "BoardTM", @@ -392,11 +392,11 @@ export const Devs = /* #__PURE__*/ Object.freeze({ }, philipbry: { name: "philipbry", - id: 554994003318276106n + id: 554994003318276106n, }, Korbo: { name: "Korbo", - id: 455856406420258827n + id: 455856406420258827n, }, maisymoe: { name: "maisy", @@ -404,11 +404,11 @@ export const Devs = /* #__PURE__*/ Object.freeze({ }, Lexi: { name: "Lexi", - id: 506101469787717658n + id: 506101469787717658n, }, Mopi: { name: "Mopi", - id: 1022189106614243350n + id: 1022189106614243350n, }, Grzesiek11: { name: "Grzesiek11", @@ -436,7 +436,7 @@ export const Devs = /* #__PURE__*/ Object.freeze({ }, nin0dev: { name: "nin0dev", - id: 886685857560539176n + id: 886685857560539176n, }, Elvyra: { name: "Elvyra", @@ -444,75 +444,79 @@ export const Devs = /* #__PURE__*/ Object.freeze({ }, HappyEnderman: { name: "Happy enderman", - id: 1083437693347827764n + id: 1083437693347827764n, }, Vishnya: { name: "Vishnya", - id: 282541644484575233n + id: 282541644484575233n, }, Inbestigator: { name: "Inbestigator", - id: 761777382041714690n + id: 761777382041714690n, }, newwares: { name: "newwares", - id: 421405303951851520n + id: 421405303951851520n, }, JohnyTheCarrot: { name: "JohnyTheCarrot", - id: 132819036282159104n + id: 132819036282159104n, }, puv: { name: "puv", - id: 469441552251355137n + id: 469441552251355137n, }, Kodarru: { name: "Kodarru", - id: 785227396218748949n + id: 785227396218748949n, }, nakoyasha: { name: "nakoyasha", - id: 222069018507345921n + id: 222069018507345921n, }, Sqaaakoi: { name: "Sqaaakoi", - id: 259558259491340288n + id: 259558259491340288n, + }, + iamme: { + name: "i am me", + id: 984392761929256980n, }, Byron: { name: "byeoon", - id: 1167275288036655133n + id: 1167275288036655133n, }, Kaitlyn: { name: "kaitlyn", - id: 306158896630988801n + id: 306158896630988801n, }, PolisanTheEasyNick: { name: "Oleh Polisan", - id: 242305263313485825n + id: 242305263313485825n, }, HAHALOSAH: { name: "HAHALOSAH", - id: 903418691268513883n + id: 903418691268513883n, }, GabiRP: { name: "GabiRP", - id: 507955112027750401n + id: 507955112027750401n, }, ImBanana: { name: "Im_Banana", - id: 635250116688871425n + id: 635250116688871425n, }, xocherry: { name: "xocherry", - id: 221288171013406720n + id: 221288171013406720n, }, ScattrdBlade: { name: "ScattrdBlade", - id: 678007540608532491n + id: 678007540608532491n, }, goodbee: { name: "goodbee", - id: 658968552606400512n + id: 658968552606400512n, }, Moxxie: { name: "Moxxie", @@ -524,19 +528,20 @@ export const Devs = /* #__PURE__*/ Object.freeze({ }, nyx: { name: "verticalsync", - id: 328165170536775680n + id: 328165170536775680n, }, nekohaxx: { name: "nekohaxx", - id: 1176270221628153886n - } + id: 1176270221628153886n, + }, } satisfies Record); // iife so #__PURE__ works correctly export const DevsById = /* #__PURE__*/ (() => - Object.freeze(Object.fromEntries( - Object.entries(Devs) - .filter(d => d[1].id !== 0n) - .map(([_, v]) => [v.id, v] as const) - )) -)() as Record; + Object.freeze( + Object.fromEntries( + Object.entries(Devs) + .filter((d) => d[1].id !== 0n) + .map(([_, v]) => [v.id, v] as const) + ) + ))() as Record; From f5f6f567383711dc1092d86c8d65cd5511df13b8 Mon Sep 17 00:00:00 2001 From: programminglaboratorys Date: Sat, 8 Jun 2024 13:21:05 +0300 Subject: [PATCH 11/22] resolving conflicts --- src/debug/loadLazyChunks.ts | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/src/debug/loadLazyChunks.ts b/src/debug/loadLazyChunks.ts index 38f171061..0aeae732b 100644 --- a/src/debug/loadLazyChunks.ts +++ b/src/debug/loadLazyChunks.ts @@ -47,19 +47,11 @@ export async function loadLazyChunks() { for (const id of chunkIds) { if (wreq.u(id) == null || wreq.u(id) === "undefined.js") continue; -<<<<<<< HEAD - const isWasm = await fetch(wreq.p + wreq.u(id)) - .then(r => r.text()) - .then(t => (IS_WEB && t.includes(".module.wasm")) || !t.includes("(this.webpackChunkdiscord_app=this.webpackChunkdiscord_app||[]).push")); - - if (isWasm && IS_WEB) { -======= const isWorkerAsset = await fetch(wreq.p + wreq.u(id)) .then(r => r.text()) .then(t => t.includes("importScripts(")); if (isWorkerAsset) { ->>>>>>> dev invalidChunks.add(id); invalidChunkGroup = true; continue; @@ -157,15 +149,6 @@ export async function loadLazyChunks() { }); await Promise.all(chunksLeft.map(async id => { -<<<<<<< HEAD - const isWasm = await fetch(wreq.p + wreq.u(id)) - .then(r => r.text()) - .then(t => (IS_WEB && t.includes(".module.wasm")) || !t.includes("(this.webpackChunkdiscord_app=this.webpackChunkdiscord_app||[]).push")); - - // Loads and requires a chunk - if (!isWasm) { - await wreq.e(id as any); -======= const isWorkerAsset = await fetch(wreq.p + wreq.u(id)) .then(r => r.text()) .then(t => t.includes("importScripts(")); @@ -175,7 +158,6 @@ export async function loadLazyChunks() { await wreq.e(id as any); // Technically, the id of the chunk does not match the entry point // But, still try it because we have no way to get the actual entry point ->>>>>>> dev if (wreq.m[id]) wreq(id as any); } })); From 954a3e87cfb06ab7d91078b16e819dcf8b74d750 Mon Sep 17 00:00:00 2001 From: programminglaboratorys Date: Sat, 8 Jun 2024 13:28:42 +0300 Subject: [PATCH 12/22] damnit messive mistake --- src/api/index.ts | 5 - src/utils/constants.ts | 225 ++++++++++++++++++++--------------------- 2 files changed, 108 insertions(+), 122 deletions(-) diff --git a/src/api/index.ts b/src/api/index.ts index ff5b379e5..b0742b327 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -113,11 +113,6 @@ export const ContextMenu = $ContextMenu; */ export const ChatButtons = $ChatButtons; -/** - * An API allowing you to add panels to the expression picker - */ -export const ExpressionPickerTabs = $ExpressionPickerTabs; - /** * An API allowing you to update and re-render messages */ diff --git a/src/utils/constants.ts b/src/utils/constants.ts index 8aed1b52e..ff754d5c2 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -14,7 +14,7 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see . - */ +*/ export const WEBPACK_CHUNK = "webpackChunkdiscord_app"; export const REACT_GLOBAL = "Vencord.Webpack.Common.React"; @@ -39,27 +39,27 @@ export const Devs = /* #__PURE__*/ Object.freeze({ }, Ven: { name: "Vendicated", - id: 343383572805058560n, + id: 343383572805058560n }, Arjix: { name: "ArjixWasTaken", - id: 674710789138939916n, + id: 674710789138939916n }, Cyn: { name: "Cynosphere", - id: 150745989836308480n, + id: 150745989836308480n }, Trwy: { name: "trey", - id: 354427199023218689n, + id: 354427199023218689n }, Megu: { name: "Megumin", - id: 545581357812678656n, + id: 545581357812678656n }, botato: { name: "botato", - id: 440990343899643943n, + id: 440990343899643943n }, fawn: { name: "fawn", @@ -67,11 +67,11 @@ export const Devs = /* #__PURE__*/ Object.freeze({ }, rushii: { name: "rushii", - id: 295190422244950017n, + id: 295190422244950017n }, Glitch: { name: "Glitchy", - id: 269567451199569920n, + id: 269567451199569920n }, Samu: { name: "Samu", @@ -79,19 +79,19 @@ export const Devs = /* #__PURE__*/ Object.freeze({ }, Nyako: { name: "nyako", - id: 118437263754395652n, + id: 118437263754395652n }, MaiKokain: { name: "Mai", - id: 722647978577363026n, + id: 722647978577363026n }, echo: { name: "ECHO", - id: 712639419785412668n, + id: 712639419785412668n }, katlyn: { name: "katlyn", - id: 250322741406859265n, + id: 250322741406859265n }, nea: { name: "nea", @@ -99,87 +99,87 @@ export const Devs = /* #__PURE__*/ Object.freeze({ }, Nuckyz: { name: "Nuckyz", - id: 235834946571337729n, + id: 235834946571337729n }, D3SOX: { name: "D3SOX", - id: 201052085641281538n, + id: 201052085641281538n }, Nickyux: { name: "Nickyux", - id: 427146305651998721n, + id: 427146305651998721n }, mantikafasi: { name: "mantikafasi", - id: 287555395151593473n, + id: 287555395151593473n }, Xinto: { name: "Xinto", - id: 423915768191647755n, + id: 423915768191647755n }, JacobTm: { name: "Jacob.Tm", - id: 302872992097107991n, + id: 302872992097107991n }, DustyAngel47: { name: "DustyAngel47", - id: 714583473804935238n, + id: 714583473804935238n }, BanTheNons: { name: "BanTheNons", - id: 460478012794863637n, + id: 460478012794863637n }, BigDuck: { name: "BigDuck", - id: 1024588272623681609n, + id: 1024588272623681609n }, AverageReactEnjoyer: { name: "Average React Enjoyer", - id: 1004904120056029256n, + id: 1004904120056029256n }, adryd: { name: "adryd", - id: 0n, + id: 0n }, Tyman: { name: "Tyman", - id: 487443883127472129n, + id: 487443883127472129n }, afn: { name: "afn", - id: 420043923822608384n, + id: 420043923822608384n }, KraXen72: { name: "KraXen72", - id: 379304073515499530n, + id: 379304073515499530n }, kemo: { name: "kemo", - id: 715746190813298788n, + id: 715746190813298788n }, dzshn: { name: "dzshn", - id: 310449948011528192n, + id: 310449948011528192n }, Ducko: { name: "Ducko", - id: 506482395269169153n, + id: 506482395269169153n }, jewdev: { name: "jewdev", - id: 222369866529636353n, + id: 222369866529636353n }, Luna: { name: "Luny", - id: 821472922140803112n, + id: 821472922140803112n }, Vap: { name: "Vap0r1ze", - id: 454072114492866560n, + id: 454072114492866560n }, KingFish: { name: "King Fish", - id: 499400512559382538n, + id: 499400512559382538n }, Commandtechno: { name: "Commandtechno", @@ -187,7 +187,7 @@ export const Devs = /* #__PURE__*/ Object.freeze({ }, TheSun: { name: "sunnie", - id: 406028027768733696n, + id: 406028027768733696n }, axyie: { name: "'ax", @@ -195,44 +195,44 @@ export const Devs = /* #__PURE__*/ Object.freeze({ }, pointy: { name: "pointy", - id: 99914384989519872n, + id: 99914384989519872n }, SammCheese: { name: "Samm-Cheese", - id: 372148345894076416n, + id: 372148345894076416n }, zt: { name: "zt", - id: 289556910426816513n, + id: 289556910426816513n }, captain: { name: "Captain", - id: 347366054806159360n, + id: 347366054806159360n }, nick: { name: "nick", id: 347884694408265729n, - badge: false, + badge: false }, whqwert: { name: "whqwert", - id: 586239091520176128n, + id: 586239091520176128n }, lewisakura: { name: "lewisakura", - id: 96269247411400704n, + id: 96269247411400704n }, RuiNtD: { name: "RuiNtD", - id: 157917665162297344n, + id: 157917665162297344n }, hunt: { name: "hunt-g", - id: 222800179697287168n, + id: 222800179697287168n }, cloudburst: { name: "cloudburst", - id: 892128204150685769n, + id: 892128204150685769n }, Aria: { name: "Syncxv", @@ -240,51 +240,51 @@ export const Devs = /* #__PURE__*/ Object.freeze({ }, TheKodeToad: { name: "TheKodeToad", - id: 706152404072267788n, + id: 706152404072267788n }, LordElias: { name: "LordElias", - id: 319460781567639554n, + id: 319460781567639554n }, juby: { name: "Juby210", - id: 324622488644616195n, + id: 324622488644616195n }, Alyxia: { name: "Alyxia Sother", - id: 952185386350829688n, + id: 952185386350829688n }, Remty: { name: "Remty", - id: 335055032204656642n, + id: 335055032204656642n }, skyevg: { name: "skyevg", - id: 1090310844283363348n, + id: 1090310844283363348n }, Dziurwa: { name: "Dziurwa", - id: 1001086404203389018n, + id: 1001086404203389018n }, arHSM: { name: "arHSM", - id: 841509053422632990n, + id: 841509053422632990n }, F53: { name: "F53", - id: 280411966126948353n, + id: 280411966126948353n }, AutumnVN: { name: "AutumnVN", - id: 393694671383166998n, + id: 393694671383166998n }, pylix: { name: "pylix", - id: 492949202121261067n, + id: 492949202121261067n }, Tyler: { name: "\\\\GGTyler\\\\", - id: 143117463788191746n, + id: 143117463788191746n }, RyanCaoDev: { name: "RyanCaoDev", @@ -292,27 +292,27 @@ export const Devs = /* #__PURE__*/ Object.freeze({ }, FieryFlames: { name: "Fiery", - id: 890228870559698955n, + id: 890228870559698955n }, KannaDev: { name: "Kanna", - id: 317728561106518019n, + id: 317728561106518019n }, carince: { name: "carince", - id: 818323528755314698n, + id: 818323528755314698n }, PandaNinjas: { name: "PandaNinjas", - id: 455128749071925248n, + id: 455128749071925248n }, CatNoir: { name: "CatNoir", - id: 260371016348336128n, + id: 260371016348336128n }, outfoxxed: { name: "outfoxxed", - id: 837425748435796060n, + id: 837425748435796060n }, UwUDev: { name: "UwU", @@ -320,39 +320,39 @@ export const Devs = /* #__PURE__*/ Object.freeze({ }, amia: { name: "amia", - id: 142007603549962240n, + id: 142007603549962240n }, phil: { name: "phil", - id: 305288513941667851n, + id: 305288513941667851n }, ImLvna: { name: "Luna <3", - id: 799319081723232267n, + id: 799319081723232267n }, rad: { name: "rad", - id: 610945092504780823n, + id: 610945092504780823n }, AndrewDLO: { name: "Andrew-DLO", - id: 434135504792059917n, + id: 434135504792059917n }, HypedDomi: { name: "HypedDomi", - id: 354191516979429376n, + id: 354191516979429376n }, Rini: { name: "Rini", - id: 1079479184478441643n, + id: 1079479184478441643n }, castdrian: { name: "castdrian", - id: 224617799434108928n, + id: 224617799434108928n }, Arrow: { name: "arrow", - id: 958158495302176778n, + id: 958158495302176778n }, bb010g: { name: "bb010g", @@ -372,19 +372,19 @@ export const Devs = /* #__PURE__*/ Object.freeze({ }, archeruwu: { name: "archer_uwu", - id: 160068695383736320n, + id: 160068695383736320n }, ProffDea: { name: "ProffDea", - id: 609329952180928513n, + id: 609329952180928513n }, UlyssesZhan: { name: "UlyssesZhan", - id: 586808226058862623n, + id: 586808226058862623n }, ant0n: { name: "ant0n", - id: 145224646868860928n, + id: 145224646868860928n }, Board: { name: "BoardTM", @@ -392,11 +392,11 @@ export const Devs = /* #__PURE__*/ Object.freeze({ }, philipbry: { name: "philipbry", - id: 554994003318276106n, + id: 554994003318276106n }, Korbo: { name: "Korbo", - id: 455856406420258827n, + id: 455856406420258827n }, maisymoe: { name: "maisy", @@ -404,11 +404,11 @@ export const Devs = /* #__PURE__*/ Object.freeze({ }, Lexi: { name: "Lexi", - id: 506101469787717658n, + id: 506101469787717658n }, Mopi: { name: "Mopi", - id: 1022189106614243350n, + id: 1022189106614243350n }, Grzesiek11: { name: "Grzesiek11", @@ -436,7 +436,7 @@ export const Devs = /* #__PURE__*/ Object.freeze({ }, nin0dev: { name: "nin0dev", - id: 886685857560539176n, + id: 886685857560539176n }, Elvyra: { name: "Elvyra", @@ -444,83 +444,75 @@ export const Devs = /* #__PURE__*/ Object.freeze({ }, HappyEnderman: { name: "Happy enderman", - id: 1083437693347827764n, + id: 1083437693347827764n }, Vishnya: { name: "Vishnya", - id: 282541644484575233n, + id: 282541644484575233n }, Inbestigator: { name: "Inbestigator", - id: 761777382041714690n, + id: 761777382041714690n }, newwares: { name: "newwares", - id: 421405303951851520n, + id: 421405303951851520n }, JohnyTheCarrot: { name: "JohnyTheCarrot", - id: 132819036282159104n, + id: 132819036282159104n }, puv: { name: "puv", - id: 469441552251355137n, + id: 469441552251355137n }, Kodarru: { name: "Kodarru", - id: 785227396218748949n, + id: 785227396218748949n }, nakoyasha: { name: "nakoyasha", - id: 222069018507345921n, + id: 222069018507345921n }, Sqaaakoi: { name: "Sqaaakoi", - id: 259558259491340288n, - }, - iamme: { - name: "i am me", - id: 984392761929256980n, - }, - iamme: { - name: "i am me", - id: 984392761929256980n + id: 259558259491340288n }, Byron: { name: "byeoon", - id: 1167275288036655133n, + id: 1167275288036655133n }, Kaitlyn: { name: "kaitlyn", - id: 306158896630988801n, + id: 306158896630988801n }, PolisanTheEasyNick: { name: "Oleh Polisan", - id: 242305263313485825n, + id: 242305263313485825n }, HAHALOSAH: { name: "HAHALOSAH", - id: 903418691268513883n, + id: 903418691268513883n }, GabiRP: { name: "GabiRP", - id: 507955112027750401n, + id: 507955112027750401n }, ImBanana: { name: "Im_Banana", - id: 635250116688871425n, + id: 635250116688871425n }, xocherry: { name: "xocherry", - id: 221288171013406720n, + id: 221288171013406720n }, ScattrdBlade: { name: "ScattrdBlade", - id: 678007540608532491n, + id: 678007540608532491n }, goodbee: { name: "goodbee", - id: 658968552606400512n, + id: 658968552606400512n }, Moxxie: { name: "Moxxie", @@ -532,20 +524,19 @@ export const Devs = /* #__PURE__*/ Object.freeze({ }, nyx: { name: "verticalsync", - id: 328165170536775680n, + id: 328165170536775680n }, nekohaxx: { name: "nekohaxx", - id: 1176270221628153886n, - }, + id: 1176270221628153886n + } } satisfies Record); // iife so #__PURE__ works correctly export const DevsById = /* #__PURE__*/ (() => - Object.freeze( - Object.fromEntries( - Object.entries(Devs) - .filter((d) => d[1].id !== 0n) - .map(([_, v]) => [v.id, v] as const) - ) - ))() as Record; + Object.freeze(Object.fromEntries( + Object.entries(Devs) + .filter(d => d[1].id !== 0n) + .map(([_, v]) => [v.id, v] as const) + )) +)() as Record; From 90c970c2d07143f0ab1f61f1f663806eccfbbc38 Mon Sep 17 00:00:00 2001 From: programminglaboratorys Date: Sat, 8 Jun 2024 13:33:56 +0300 Subject: [PATCH 13/22] adding me to constants --- src/utils/constants.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/utils/constants.ts b/src/utils/constants.ts index ff754d5c2..4a5839448 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -478,6 +478,10 @@ export const Devs = /* #__PURE__*/ Object.freeze({ name: "Sqaaakoi", id: 259558259491340288n }, + iamme: { + name: "i am me", + id: 984392761929256980n + }, Byron: { name: "byeoon", id: 1167275288036655133n From 23db98a4926f168674d2fe46ade4a9325a8f1091 Mon Sep 17 00:00:00 2001 From: programminglaboratorys Date: Wed, 12 Jun 2024 13:37:28 +0300 Subject: [PATCH 14/22] resolving 'Invalid header' lint error --- src/api/index.ts | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/src/api/index.ts b/src/api/index.ts index b0742b327..66634d309 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -1,19 +1,7 @@ /* - * 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 . + * Vencord, a Discord client mod + * Copyright (c) 2024 Vendicated and contributors + * SPDX-License-Identifier: GPL-3.0-or-later */ import * as $Badges from "./Badges"; From 0bce276c370d0d0f0dd770e3284046f7ec51a1a1 Mon Sep 17 00:00:00 2001 From: programminglaboratorys Date: Wed, 19 Jun 2024 19:55:47 +0300 Subject: [PATCH 15/22] patch fix and api/index.ts update --- src/api/index.ts | 23 +++++++++++++++++++---- src/plugins/_api/expressionPickerTabs.ts | 4 ++-- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/api/index.ts b/src/api/index.ts index 66634d309..0b0c9f576 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -1,8 +1,20 @@ /* - * Vencord, a Discord client mod - * Copyright (c) 2024 Vendicated and contributors - * SPDX-License-Identifier: GPL-3.0-or-later - */ + * 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 * as $Badges from "./Badges"; import * as $ChatButtons from "./ChatButtons"; @@ -20,6 +32,7 @@ import * as $Notices from "./Notices"; import * as $Notifications from "./Notifications"; import * as $ServerList from "./ServerList"; import * as $Settings from "./Settings"; +import * as $SettingsStores from "./SettingsStores"; import * as $Styles from "./Styles"; /** @@ -106,6 +119,8 @@ export const ChatButtons = $ChatButtons; */ export const MessageUpdater = $MessageUpdater; +export const SettingsStores = $SettingsStores; + /** * An API allowing you to add panels to the expression picker */ diff --git a/src/plugins/_api/expressionPickerTabs.ts b/src/plugins/_api/expressionPickerTabs.ts index 33b1ef477..6a2516641 100644 --- a/src/plugins/_api/expressionPickerTabs.ts +++ b/src/plugins/_api/expressionPickerTabs.ts @@ -21,8 +21,8 @@ export default definePlugin({ replace: "$&,...Vencord.Api.ExpressionPickerTabs.RenderTabButtons($1, $2)" }, { - match: /null,(\i)===\i\.ExpressionPickerViewType\.EMOJI\?.{0,55}channel:(\i),.+?\):null/, - replace: "$&,...Vencord.Api.ExpressionPickerTabs.TabPanels($1, $2)" + match: /null,(\i)===\i\.\i\.EMOJI\?.{0,55}channel:(\i),.+?\):null/, + replace: "$&,...Vencord.Api.Tablist.RenderButtons($1, $2, $3)" } ] } From a01ee40591f7a1e49b903b24a5ab2a6b278b34a2 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Wed, 19 Jun 2024 23:49:42 -0300 Subject: [PATCH 16/22] Clean-up related additions to mangled exports --- src/api/SettingsStores.ts | 69 --------------- src/api/UserSettingDefinitions.ts | 83 +++++++++++++++++++ src/api/index.ts | 7 +- ...gsStores.ts => userSettingsDefinitions.ts} | 21 +++-- src/plugins/betterRoleContext/index.tsx | 6 +- src/plugins/customRPC/index.tsx | 7 +- src/plugins/gameActivityToggle/index.tsx | 6 +- src/plugins/ignoreActivities/index.tsx | 6 +- src/plugins/messageLinkEmbeds/index.tsx | 6 +- src/utils/discord.tsx | 2 +- src/webpack/common/index.ts | 2 +- src/webpack/common/types/index.d.ts | 1 - src/webpack/common/types/settingsStores.ts | 11 --- src/webpack/common/types/utils.d.ts | 2 +- .../{settingsStores.ts => userSettings.ts} | 0 15 files changed, 120 insertions(+), 109 deletions(-) delete mode 100644 src/api/SettingsStores.ts create mode 100644 src/api/UserSettingDefinitions.ts rename src/plugins/_api/{settingsStores.ts => userSettingsDefinitions.ts} (52%) delete mode 100644 src/webpack/common/types/settingsStores.ts rename src/webpack/common/{settingsStores.ts => userSettings.ts} (100%) diff --git a/src/api/SettingsStores.ts b/src/api/SettingsStores.ts deleted file mode 100644 index 18139e4e6..000000000 --- a/src/api/SettingsStores.ts +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Vencord, a modification for Discord's desktop app - * Copyright (c) 2023 Vendicated and contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . -*/ - -import { proxyLazy } from "@utils/lazy"; -import { Logger } from "@utils/Logger"; -import { findModuleId, proxyLazyWebpack, wreq } from "@webpack"; - -import { Settings } from "./Settings"; - -interface Setting { - /** - * Get the setting value - */ - getSetting(): T; - /** - * Update the setting value - * @param value The new value - */ - updateSetting(value: T | ((old: T) => T)): Promise; - /** - * React hook for automatically updating components when the setting is updated - */ - useSetting(): T; - settingsStoreApiGroup: string; - settingsStoreApiName: string; -} - -export const SettingsStores: Array> | undefined = proxyLazyWebpack(() => { - const modId = findModuleId('"textAndImages","renderSpoilers"') as any; - if (modId == null) return new Logger("SettingsStoreAPI").error("Didn't find stores module."); - - const mod = wreq(modId); - if (mod == null) return; - - return Object.values(mod).filter((s: any) => s?.settingsStoreApiGroup) as any; -}); - -/** - * Get the store for a setting - * @param group The setting group - * @param name The name of the setting - */ -export function getSettingStore(group: string, name: string): Setting | undefined { - if (!Settings.plugins.SettingsStoreAPI.enabled) throw new Error("Cannot use SettingsStoreAPI without setting as dependency."); - - return SettingsStores?.find(s => s?.settingsStoreApiGroup === group && s?.settingsStoreApiName === name); -} - -/** - * getSettingStore but lazy - */ -export function getSettingStoreLazy(group: string, name: string) { - return proxyLazy(() => getSettingStore(group, name)); -} diff --git a/src/api/UserSettingDefinitions.ts b/src/api/UserSettingDefinitions.ts new file mode 100644 index 000000000..7a2ed5be9 --- /dev/null +++ b/src/api/UserSettingDefinitions.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 { proxyLazy } from "@utils/lazy"; +import { Logger } from "@utils/Logger"; +import { findModuleId, proxyLazyWebpack, wreq } from "@webpack"; + +import { Settings } from "./Settings"; + +interface UserSettingDefinition { + /** + * Get the setting value + */ + getSetting(): T; + /** + * Update the setting value + * @param value The new value + */ + updateSetting(value: T): Promise; + /** + * Update the setting value + * @param value A callback that accepts the old value as the first argument, and returns the new value + */ + updateSetting(value: (old: T) => T): Promise; + /** + * Stateful React hook for this setting value + */ + useSetting(): T; + userSettingDefinitionsAPIGroup: string; + userSettingDefinitionsAPIName: string; +} + +export const UserSettingsDefinitions: Record> | undefined = proxyLazyWebpack(() => { + const modId = findModuleId('"textAndImages","renderSpoilers"'); + if (modId == null) return new Logger("UserSettingDefinitionsAPI").error("Didn't find settings definitions module."); + + return wreq(modId as any); +}); + +/** + * Get the definition for a setting. + * + * @param group The setting group + * @param name The name of the setting + */ +export function getUserSettingDefinition(group: string, name: string): UserSettingDefinition | undefined { + if (!Settings.plugins.UserSettingDefinitionsAPI.enabled) throw new Error("Cannot use UserSettingDefinitionsAPI without setting as dependency."); + + for (const key in UserSettingsDefinitions) { + const userSettingDefinition = UserSettingsDefinitions[key]; + + if (userSettingDefinition.userSettingDefinitionsAPIGroup === group && userSettingDefinition.userSettingDefinitionsAPIName === name) { + return userSettingDefinition; + } + } +} + +/** + * {@link getUserSettingDefinition}, lazy. + * + * Get the definition for a setting. + * + * @param group The setting group + * @param name The name of the setting + */ +export function getUserSettingDefinitionLazy(group: string, name: string) { + return proxyLazy(() => getUserSettingDefinition(group, name)); +} diff --git a/src/api/index.ts b/src/api/index.ts index 737e06d60..5f8233d21 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -31,8 +31,8 @@ import * as $Notices from "./Notices"; import * as $Notifications from "./Notifications"; import * as $ServerList from "./ServerList"; import * as $Settings from "./Settings"; -import * as $SettingsStores from "./SettingsStores"; import * as $Styles from "./Styles"; +import * as $UserSettingDefinitions from "./UserSettingDefinitions"; /** * An API allowing you to listen to Message Clicks or run your own logic @@ -118,4 +118,7 @@ export const ChatButtons = $ChatButtons; */ export const MessageUpdater = $MessageUpdater; -export const SettingsStores = $SettingsStores; +/** + * An API allowing you to get the definition for an user setting + */ +export const UserSettingDefinitions = $UserSettingDefinitions; diff --git a/src/plugins/_api/settingsStores.ts b/src/plugins/_api/userSettingsDefinitions.ts similarity index 52% rename from src/plugins/_api/settingsStores.ts rename to src/plugins/_api/userSettingsDefinitions.ts index a888532ee..5577a1723 100644 --- a/src/plugins/_api/settingsStores.ts +++ b/src/plugins/_api/userSettingsDefinitions.ts @@ -20,23 +20,30 @@ import { Devs } from "@utils/constants"; import definePlugin from "@utils/types"; export default definePlugin({ - name: "SettingsStoreAPI", - description: "Patches Discord's SettingsStores to expose their group and name", + name: "UserSettingDefinitionsAPI", + description: "Patches Discord's UserSettingDefinitions to expose their group and name.", authors: [Devs.Nuckyz], patches: [ { find: ",updateSetting:", replacement: [ + // Main setting definition { - match: /(?<=INFREQUENT_USER_ACTION.{0,20}),useSetting:/, - replace: ",settingsStoreApiGroup:arguments[0],settingsStoreApiName:arguments[1]$&" + match: /(?<=INFREQUENT_USER_ACTION.{0,20},)useSetting:/, + replace: "userSettingDefinitionsAPIGroup:arguments[0],userSettingDefinitionsAPIName:arguments[1],$&" }, - // some wrapper. just make it copy the group and name + // Selective wrapper { - match: /updateSetting:.{0,20}shouldSync/, - replace: "settingsStoreApiGroup:arguments[0].settingsStoreApiGroup,settingsStoreApiName:arguments[0].settingsStoreApiName,$&" + match: /updateSetting:.{0,100}SELECTIVELY_SYNCED_USER_SETTINGS_UPDATE/, + replace: "userSettingDefinitionsAPIGroup:arguments[0].userSettingDefinitionsAPIGroup,userSettingDefinitionsAPIName:arguments[0].userSettingDefinitionsAPIName,$&" + }, + // Override wrapper + { + match: /updateSetting:.{0,60}USER_SETTINGS_OVERRIDE_CLEAR/, + replace: "userSettingDefinitionsAPIGroup:arguments[0].userSettingDefinitionsAPIGroup,userSettingDefinitionsAPIName:arguments[0].userSettingDefinitionsAPIName,$&" } + ] } ] diff --git a/src/plugins/betterRoleContext/index.tsx b/src/plugins/betterRoleContext/index.tsx index d69e188c0..77be0e2b0 100644 --- a/src/plugins/betterRoleContext/index.tsx +++ b/src/plugins/betterRoleContext/index.tsx @@ -5,7 +5,7 @@ */ import { definePluginSettings } from "@api/Settings"; -import { getSettingStoreLazy } from "@api/SettingsStores"; +import { getUserSettingDefinitionLazy } from "@api/UserSettingDefinitions"; import { ImageIcon } from "@components/Icons"; import { Devs } from "@utils/constants"; import { getCurrentGuild, openImageModal } from "@utils/discord"; @@ -15,7 +15,7 @@ import { Clipboard, GuildStore, Menu, PermissionStore } from "@webpack/common"; const GuildSettingsActions = findByPropsLazy("open", "selectRole", "updateGuild"); -const DeveloperMode = getSettingStoreLazy("appearance", "developerMode")!; +const DeveloperMode = getUserSettingDefinitionLazy("appearance", "developerMode")!; function PencilIcon() { return ( @@ -65,7 +65,7 @@ export default definePlugin({ name: "BetterRoleContext", description: "Adds options to copy role color / edit role / view role icon when right clicking roles in the user profile", authors: [Devs.Ven, Devs.goodbee], - dependencies: ["SettingsStoreAPI"], + dependencies: ["UserSettingDefinitionsAPI"], settings, diff --git a/src/plugins/customRPC/index.tsx b/src/plugins/customRPC/index.tsx index 7e4e9a938..ed2de9b4d 100644 --- a/src/plugins/customRPC/index.tsx +++ b/src/plugins/customRPC/index.tsx @@ -17,7 +17,7 @@ */ import { definePluginSettings, Settings } from "@api/Settings"; -import { getSettingStoreLazy } from "@api/SettingsStores"; +import { getUserSettingDefinitionLazy } from "@api/UserSettingDefinitions"; import { ErrorCard } from "@components/ErrorCard"; import { Link } from "@components/Link"; import { Devs } from "@utils/constants"; @@ -33,8 +33,7 @@ const useProfileThemeStyle = findByCodeLazy("profileThemeStyle:", "--profile-gra const ActivityComponent = findComponentByCodeLazy("onOpenGameProfile"); const ActivityClassName = findByPropsLazy("activity", "buttonColor"); -const ShowCurrentGame = getSettingStoreLazy("status", "showCurrentGame")!; - +const ShowCurrentGame = getUserSettingDefinitionLazy("status", "showCurrentGame")!; async function getApplicationAsset(key: string): Promise { if (/https?:\/\/(cdn|media)\.discordapp\.(com|net)\/attachments\//.test(key)) return "mp:" + key.replace(/https?:\/\/(cdn|media)\.discordapp\.(com|net)\//, ""); @@ -394,7 +393,7 @@ export default definePlugin({ name: "CustomRPC", description: "Allows you to set a custom rich presence.", authors: [Devs.captain, Devs.AutumnVN, Devs.nin0dev], - dependencies: ["SettingsStoreAPI"], + dependencies: ["UserSettingDefinitionsAPI"], start: setRpc, stop: () => setRpc(true), settings, diff --git a/src/plugins/gameActivityToggle/index.tsx b/src/plugins/gameActivityToggle/index.tsx index 4e2a390d6..e7353a5d9 100644 --- a/src/plugins/gameActivityToggle/index.tsx +++ b/src/plugins/gameActivityToggle/index.tsx @@ -17,8 +17,8 @@ */ import { definePluginSettings } from "@api/Settings"; -import { getSettingStoreLazy } from "@api/SettingsStores"; import { disableStyle, enableStyle } from "@api/Styles"; +import { getUserSettingDefinitionLazy } from "@api/UserSettingDefinitions"; import ErrorBoundary from "@components/ErrorBoundary"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; @@ -28,7 +28,7 @@ import style from "./style.css?managed"; const Button = findComponentByCodeLazy("Button.Sizes.NONE,disabled:"); -const ShowCurrentGame = getSettingStoreLazy("status", "showCurrentGame")!; +const ShowCurrentGame = getUserSettingDefinitionLazy("status", "showCurrentGame")!; function makeIcon(showCurrentGame?: boolean) { const { oldIcon } = settings.use(["oldIcon"]); @@ -87,7 +87,7 @@ export default definePlugin({ name: "GameActivityToggle", description: "Adds a button next to the mic and deafen button to toggle game activity.", authors: [Devs.Nuckyz, Devs.RuukuLada], - dependencies: ["SettingsStoreAPI"], + dependencies: ["UserSettingDefinitionsAPI"], settings, patches: [ diff --git a/src/plugins/ignoreActivities/index.tsx b/src/plugins/ignoreActivities/index.tsx index 6e34c79f3..431cd3e04 100644 --- a/src/plugins/ignoreActivities/index.tsx +++ b/src/plugins/ignoreActivities/index.tsx @@ -6,7 +6,7 @@ import * as DataStore from "@api/DataStore"; import { definePluginSettings, Settings } from "@api/Settings"; -import { getSettingStoreLazy } from "@api/SettingsStores"; +import { getUserSettingDefinitionLazy } from "@api/UserSettingDefinitions"; import ErrorBoundary from "@components/ErrorBoundary"; import { Flex } from "@components/Flex"; import { Devs } from "@utils/constants"; @@ -28,7 +28,7 @@ interface IgnoredActivity { const RunningGameStore = findStoreLazy("RunningGameStore"); -const ShowCurrentGame = getSettingStoreLazy("status", "showCurrentGame")!; +const ShowCurrentGame = getUserSettingDefinitionLazy("status", "showCurrentGame")!; function ToggleIcon(activity: IgnoredActivity, tooltipText: string, path: string, fill: string) { return ( @@ -208,7 +208,7 @@ export default definePlugin({ name: "IgnoreActivities", authors: [Devs.Nuckyz], description: "Ignore activities from showing up on your status ONLY. You can configure which ones are specifically ignored from the Registered Games and Activities tabs, or use the general settings below.", - dependencies: ["SettingsStoreAPI"], + dependencies: ["UserSettingDefinitionsAPI"], settings, diff --git a/src/plugins/messageLinkEmbeds/index.tsx b/src/plugins/messageLinkEmbeds/index.tsx index 70681fb28..9fefc82a2 100644 --- a/src/plugins/messageLinkEmbeds/index.tsx +++ b/src/plugins/messageLinkEmbeds/index.tsx @@ -19,7 +19,7 @@ import { addAccessory, removeAccessory } from "@api/MessageAccessories"; import { updateMessage } from "@api/MessageUpdater"; import { definePluginSettings } from "@api/Settings"; -import { getSettingStoreLazy } from "@api/SettingsStores"; +import { getUserSettingDefinitionLazy } from "@api/UserSettingDefinitions"; import ErrorBoundary from "@components/ErrorBoundary"; import { Devs } from "@utils/constants.js"; import { classes } from "@utils/misc"; @@ -54,7 +54,7 @@ const ChannelMessage = findComponentByCodeLazy("childrenExecutedCommand:", ".hid const SearchResultClasses = findByPropsLazy("message", "searchResult"); const EmbedClasses = findByPropsLazy("embedAuthorIcon", "embedAuthor", "embedAuthor"); -const MessageDisplayCompact = getSettingStoreLazy("textAndImages", "messageDisplayCompact")!; +const MessageDisplayCompact = getUserSettingDefinitionLazy("textAndImages", "messageDisplayCompact")!; const messageLinkRegex = /(? } - // FIXME: wtf is this? do we need to pass some proper component?? + // Don't render forward message button renderForwardComponent={() => null} shouldHideMediaOptions={false} shouldAnimate diff --git a/src/webpack/common/index.ts b/src/webpack/common/index.ts index 5da3cc68b..4193330cb 100644 --- a/src/webpack/common/index.ts +++ b/src/webpack/common/index.ts @@ -20,9 +20,9 @@ export * from "./classes"; export * from "./components"; export * from "./menu"; export * from "./react"; -export * from "./settingsStores"; export * from "./stores"; export * as ComponentTypes from "./types/components.d"; export * as MenuTypes from "./types/menu.d"; export * as UtilTypes from "./types/utils.d"; +export * from "./userSettings"; export * from "./utils"; diff --git a/src/webpack/common/types/index.d.ts b/src/webpack/common/types/index.d.ts index 01c968553..a536cdcf1 100644 --- a/src/webpack/common/types/index.d.ts +++ b/src/webpack/common/types/index.d.ts @@ -21,6 +21,5 @@ export * from "./components"; export * from "./fluxEvents"; export * from "./i18nMessages"; export * from "./menu"; -export * from "./settingsStores"; export * from "./stores"; export * from "./utils"; diff --git a/src/webpack/common/types/settingsStores.ts b/src/webpack/common/types/settingsStores.ts deleted file mode 100644 index 5453ca352..000000000 --- a/src/webpack/common/types/settingsStores.ts +++ /dev/null @@ -1,11 +0,0 @@ -/* - * Vencord, a Discord client mod - * Copyright (c) 2024 Vendicated and contributors - * SPDX-License-Identifier: GPL-3.0-or-later - */ - -export interface SettingsStore { - getSetting(): T; - updateSetting(value: T): void; - useSetting(): T; -} diff --git a/src/webpack/common/types/utils.d.ts b/src/webpack/common/types/utils.d.ts index 7f6249be6..ee3f69944 100644 --- a/src/webpack/common/types/utils.d.ts +++ b/src/webpack/common/types/utils.d.ts @@ -82,7 +82,7 @@ interface RestRequestData { retries?: number; } -export type RestAPI = Record<"delete" | "get" | "patch" | "post" | "put", (data: RestRequestData) => Promise>; +export type RestAPI = Record<"del" | "get" | "patch" | "post" | "put", (data: RestRequestData) => Promise>; export type Permissions = "CREATE_INSTANT_INVITE" | "KICK_MEMBERS" diff --git a/src/webpack/common/settingsStores.ts b/src/webpack/common/userSettings.ts similarity index 100% rename from src/webpack/common/settingsStores.ts rename to src/webpack/common/userSettings.ts From ceaaf9ab8a3bb87494573a8442f31cc4a2396bbf Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Thu, 20 Jun 2024 01:00:07 -0300 Subject: [PATCH 17/22] Reporter: Test mapMangledModule --- src/debug/runReporter.ts | 15 ++++++++++++--- src/webpack/webpack.ts | 4 +++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/debug/runReporter.ts b/src/debug/runReporter.ts index 6c7a2a03f..ddd5e5f18 100644 --- a/src/debug/runReporter.ts +++ b/src/debug/runReporter.ts @@ -39,9 +39,8 @@ async function runReporter() { } if (searchType === "waitForStore") method = "findStore"; + let result: any; try { - let result: any; - if (method === "proxyLazyWebpack" || method === "LazyComponentWebpack") { const [factory] = args; result = factory(); @@ -50,16 +49,26 @@ async function runReporter() { result = await Webpack.extractAndLoadChunks(code, matcher); if (result === false) result = null; + } else if (method === "mapMangledModule") { + const [code, mapper] = args; + + result = Webpack.mapMangledModule(code, mapper); + if (Object.keys(result).length !== Object.keys(mapper).length) throw new Error("Webpack Find Fail"); } else { // @ts-ignore result = Webpack[method](...args); } - if (result == null || (result.$$vencordInternal != null && result.$$vencordInternal() == null)) throw "a rock at ben shapiro"; + if (result == null || (result.$$vencordInternal != null && result.$$vencordInternal() == null)) throw new Error("Webpack Find Fail"); } catch (e) { let logMessage = searchType; if (method === "find" || method === "proxyLazyWebpack" || method === "LazyComponentWebpack") logMessage += `(${args[0].toString().slice(0, 147)}...)`; else if (method === "extractAndLoadChunks") logMessage += `([${args[0].map(arg => `"${arg}"`).join(", ")}], ${args[1].toString()})`; + else if (method === "mapMangledModule") { + const failedMappings = Object.keys(args[1]).filter(key => result?.[key] == null); + + logMessage += `("${args[0]}", {\n${failedMappings.map(mapping => `\t${mapping}: ${args[1][mapping].toString().slice(0, 147)}...`).join(",\n")}\n})`; + } else logMessage += `(${args.map(arg => `"${arg}"`).join(", ")})`; ReporterLogger.log("Webpack Find Fail:", logMessage); diff --git a/src/webpack/webpack.ts b/src/webpack/webpack.ts index b536063e8..f776ab1c3 100644 --- a/src/webpack/webpack.ts +++ b/src/webpack/webpack.ts @@ -279,7 +279,7 @@ export function findModuleFactory(...code: string[]) { return wreq.m[id]; } -export const lazyWebpackSearchHistory = [] as Array<["find" | "findByProps" | "findByCode" | "findStore" | "findComponent" | "findComponentByCode" | "findExportedComponent" | "waitFor" | "waitForComponent" | "waitForStore" | "proxyLazyWebpack" | "LazyComponentWebpack" | "extractAndLoadChunks", any[]]>; +export const lazyWebpackSearchHistory = [] as Array<["find" | "findByProps" | "findByCode" | "findStore" | "findComponent" | "findComponentByCode" | "findExportedComponent" | "waitFor" | "waitForComponent" | "waitForStore" | "proxyLazyWebpack" | "LazyComponentWebpack" | "extractAndLoadChunks" | "mapMangledModule", any[]]>; /** * This is just a wrapper around {@link proxyLazy} to make our reporter test for your webpack finds. @@ -483,6 +483,8 @@ export const mapMangledModule = traceFunction("mapMangledModule", function mapMa * }) */ export function mapMangledModuleLazy(code: string, mappers: Record): Record { + if (IS_REPORTER) lazyWebpackSearchHistory.push(["mapMangledModule", [code, mappers]]); + return proxyLazy(() => mapMangledModule(code, mappers)); } From 6cca09e5716b2bbc02e56deab305f1acae79ae8e Mon Sep 17 00:00:00 2001 From: programminglaboratorys <107296738+programminglaboratorys@users.noreply.github.com> Date: Mon, 24 Jun 2024 04:48:55 +0300 Subject: [PATCH 18/22] resolving conflict affects --- src/plugins/_api/userSettingsDefinitions.ts | 12 ++++++------ src/plugins/betterRoleContext/index.tsx | 5 +++-- src/plugins/ignoreActivities/index.tsx | 3 ++- src/plugins/messageLinkEmbeds/index.tsx | 3 ++- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/plugins/_api/userSettingsDefinitions.ts b/src/plugins/_api/userSettingsDefinitions.ts index 5577a1723..a7ae53499 100644 --- a/src/plugins/_api/userSettingsDefinitions.ts +++ b/src/plugins/_api/userSettingsDefinitions.ts @@ -20,8 +20,8 @@ import { Devs } from "@utils/constants"; import definePlugin from "@utils/types"; export default definePlugin({ - name: "UserSettingDefinitionsAPI", - description: "Patches Discord's UserSettingDefinitions to expose their group and name.", + name: "UserSettingsAPI", + description: "Patches Discord's UserSettings to expose their group and name.", authors: [Devs.Nuckyz], patches: [ @@ -31,20 +31,20 @@ export default definePlugin({ // Main setting definition { match: /(?<=INFREQUENT_USER_ACTION.{0,20},)useSetting:/, - replace: "userSettingDefinitionsAPIGroup:arguments[0],userSettingDefinitionsAPIName:arguments[1],$&" + replace: "userSettingsAPIGroup:arguments[0],userSettingsAPIName:arguments[1],$&" }, // Selective wrapper { match: /updateSetting:.{0,100}SELECTIVELY_SYNCED_USER_SETTINGS_UPDATE/, - replace: "userSettingDefinitionsAPIGroup:arguments[0].userSettingDefinitionsAPIGroup,userSettingDefinitionsAPIName:arguments[0].userSettingDefinitionsAPIName,$&" + replace: "userSettingsAPIGroup:arguments[0].userSettingsAPIGroup,userSettingsAPIName:arguments[0].userSettingsAPIName,$&" }, // Override wrapper { match: /updateSetting:.{0,60}USER_SETTINGS_OVERRIDE_CLEAR/, - replace: "userSettingDefinitionsAPIGroup:arguments[0].userSettingDefinitionsAPIGroup,userSettingDefinitionsAPIName:arguments[0].userSettingDefinitionsAPIName,$&" + replace: "userSettingsAPIGroup:arguments[0].userSettingsAPIGroup,userSettingsAPIName:arguments[0].userSettingsAPIName,$&" } ] } ] -}); +}); \ No newline at end of file diff --git a/src/plugins/betterRoleContext/index.tsx b/src/plugins/betterRoleContext/index.tsx index 92a2d9d70..89b000ea5 100644 --- a/src/plugins/betterRoleContext/index.tsx +++ b/src/plugins/betterRoleContext/index.tsx @@ -66,8 +66,9 @@ export default definePlugin({ description: "Adds options to copy role color / edit role / view role icon when right clicking roles in the user profile", authors: [Devs.Ven, Devs.goodbee], dependencies: ["UserSettingsAPI"], + settings, - + start() { // DeveloperMode needs to be enabled for the context menu to be shown DeveloperMode.updateSetting(true); @@ -121,4 +122,4 @@ export default definePlugin({ } } } -}); +}); \ No newline at end of file diff --git a/src/plugins/ignoreActivities/index.tsx b/src/plugins/ignoreActivities/index.tsx index 292cf2e28..5602a09b3 100644 --- a/src/plugins/ignoreActivities/index.tsx +++ b/src/plugins/ignoreActivities/index.tsx @@ -209,6 +209,7 @@ export default definePlugin({ authors: [Devs.Nuckyz], description: "Ignore activities from showing up on your status ONLY. You can configure which ones are specifically ignored from the Registered Games and Activities tabs, or use the general settings below.", dependencies: ["UserSettingsAPI"], + settings, patches: [ @@ -306,4 +307,4 @@ export default definePlugin({ ); } -}); +}); \ No newline at end of file diff --git a/src/plugins/messageLinkEmbeds/index.tsx b/src/plugins/messageLinkEmbeds/index.tsx index f147b4cbe..114af4171 100644 --- a/src/plugins/messageLinkEmbeds/index.tsx +++ b/src/plugins/messageLinkEmbeds/index.tsx @@ -367,6 +367,7 @@ export default definePlugin({ description: "Adds a preview to messages that link another message", authors: [Devs.TheSun, Devs.Ven, Devs.RyanCaoDev], dependencies: ["MessageAccessoriesAPI", "MessageUpdaterAPI", "UserSettingsAPI"], + settings, start() { @@ -390,4 +391,4 @@ export default definePlugin({ stop() { removeAccessory("messageLinkEmbed"); } -}); +}); \ No newline at end of file From c268a3d88543eed0240eef531c4ef61608d4f014 Mon Sep 17 00:00:00 2001 From: programminglaboratorys <107296738+programminglaboratorys@users.noreply.github.com> Date: Mon, 24 Jun 2024 04:49:08 +0300 Subject: [PATCH 19/22] fix patch --- src/plugins/_api/expressionPickerTabs.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/_api/expressionPickerTabs.ts b/src/plugins/_api/expressionPickerTabs.ts index 6a2516641..19182f3d4 100644 --- a/src/plugins/_api/expressionPickerTabs.ts +++ b/src/plugins/_api/expressionPickerTabs.ts @@ -22,7 +22,7 @@ export default definePlugin({ }, { match: /null,(\i)===\i\.\i\.EMOJI\?.{0,55}channel:(\i),.+?\):null/, - replace: "$&,...Vencord.Api.Tablist.RenderButtons($1, $2, $3)" + replace: "$&,...Vencord.Api.ExpressionPickerTabs.TabPanels($1, $2)" } ] } From efbcbec34903517e651396917f02c99261793315 Mon Sep 17 00:00:00 2001 From: programminglaboratorys Date: Fri, 28 Jun 2024 17:27:17 +0300 Subject: [PATCH 20/22] resolving conflicts --- package.json | 2 +- src/plugins/betterRoleContext/index.tsx | 2 +- src/plugins/ignoreActivities/index.tsx | 2 +- src/plugins/messageLinkEmbeds/index.tsx | 2 +- src/plugins/textReplace/index.tsx | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index f2f5e3a2e..dc90a646c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "vencord", "private": "true", - "version": "1.9.2", + "version": "1.9.3", "description": "The cutest Discord client mod", "homepage": "https://github.com/Vendicated/Vencord#readme", "bugs": { diff --git a/src/plugins/betterRoleContext/index.tsx b/src/plugins/betterRoleContext/index.tsx index 89b000ea5..bf4cf0f37 100644 --- a/src/plugins/betterRoleContext/index.tsx +++ b/src/plugins/betterRoleContext/index.tsx @@ -122,4 +122,4 @@ export default definePlugin({ } } } -}); \ No newline at end of file +}); diff --git a/src/plugins/ignoreActivities/index.tsx b/src/plugins/ignoreActivities/index.tsx index 5602a09b3..bab69d89b 100644 --- a/src/plugins/ignoreActivities/index.tsx +++ b/src/plugins/ignoreActivities/index.tsx @@ -307,4 +307,4 @@ export default definePlugin({ ); } -}); \ No newline at end of file +}); diff --git a/src/plugins/messageLinkEmbeds/index.tsx b/src/plugins/messageLinkEmbeds/index.tsx index 114af4171..cf180d0d4 100644 --- a/src/plugins/messageLinkEmbeds/index.tsx +++ b/src/plugins/messageLinkEmbeds/index.tsx @@ -391,4 +391,4 @@ export default definePlugin({ stop() { removeAccessory("messageLinkEmbed"); } -}); \ No newline at end of file +}); diff --git a/src/plugins/textReplace/index.tsx b/src/plugins/textReplace/index.tsx index 416ce83fb..615477d07 100644 --- a/src/plugins/textReplace/index.tsx +++ b/src/plugins/textReplace/index.tsx @@ -77,7 +77,7 @@ const settings = definePluginSettings({ }); function stringToRegex(str: string) { - const match = str.match(/^(\/)?(.+?)(?:\/([gimsuy]*))?$/); // Regex to match regex + const match = str.match(/^(\/)?(.+?)(?:\/([gimsuyv]*))?$/); // Regex to match regex return match ? new RegExp( match[2], // Pattern From 2ae278942e288c09709c71a0237285688c657586 Mon Sep 17 00:00:00 2001 From: programminglaboratorys Date: Fri, 28 Jun 2024 17:35:41 +0300 Subject: [PATCH 21/22] following lint --- src/plugins/_api/userSettingsDefinitions.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/_api/userSettingsDefinitions.ts b/src/plugins/_api/userSettingsDefinitions.ts index a7ae53499..3a00bc116 100644 --- a/src/plugins/_api/userSettingsDefinitions.ts +++ b/src/plugins/_api/userSettingsDefinitions.ts @@ -47,4 +47,4 @@ export default definePlugin({ ] } ] -}); \ No newline at end of file +}); From fddccea8b84012e377d9ebf187c90fae6c689443 Mon Sep 17 00:00:00 2001 From: programminglaboratorys Date: Fri, 28 Jun 2024 17:41:53 +0300 Subject: [PATCH 22/22] removing UserSettingDefinitions --- src/api/UserSettingDefinitions.ts | 83 --------------------- src/plugins/_api/userSettingsDefinitions.ts | 50 ------------- 2 files changed, 133 deletions(-) delete mode 100644 src/api/UserSettingDefinitions.ts delete mode 100644 src/plugins/_api/userSettingsDefinitions.ts diff --git a/src/api/UserSettingDefinitions.ts b/src/api/UserSettingDefinitions.ts deleted file mode 100644 index 7a2ed5be9..000000000 --- a/src/api/UserSettingDefinitions.ts +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Vencord, a modification for Discord's desktop app - * Copyright (c) 2023 Vendicated and contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . -*/ - -import { proxyLazy } from "@utils/lazy"; -import { Logger } from "@utils/Logger"; -import { findModuleId, proxyLazyWebpack, wreq } from "@webpack"; - -import { Settings } from "./Settings"; - -interface UserSettingDefinition { - /** - * Get the setting value - */ - getSetting(): T; - /** - * Update the setting value - * @param value The new value - */ - updateSetting(value: T): Promise; - /** - * Update the setting value - * @param value A callback that accepts the old value as the first argument, and returns the new value - */ - updateSetting(value: (old: T) => T): Promise; - /** - * Stateful React hook for this setting value - */ - useSetting(): T; - userSettingDefinitionsAPIGroup: string; - userSettingDefinitionsAPIName: string; -} - -export const UserSettingsDefinitions: Record> | undefined = proxyLazyWebpack(() => { - const modId = findModuleId('"textAndImages","renderSpoilers"'); - if (modId == null) return new Logger("UserSettingDefinitionsAPI").error("Didn't find settings definitions module."); - - return wreq(modId as any); -}); - -/** - * Get the definition for a setting. - * - * @param group The setting group - * @param name The name of the setting - */ -export function getUserSettingDefinition(group: string, name: string): UserSettingDefinition | undefined { - if (!Settings.plugins.UserSettingDefinitionsAPI.enabled) throw new Error("Cannot use UserSettingDefinitionsAPI without setting as dependency."); - - for (const key in UserSettingsDefinitions) { - const userSettingDefinition = UserSettingsDefinitions[key]; - - if (userSettingDefinition.userSettingDefinitionsAPIGroup === group && userSettingDefinition.userSettingDefinitionsAPIName === name) { - return userSettingDefinition; - } - } -} - -/** - * {@link getUserSettingDefinition}, lazy. - * - * Get the definition for a setting. - * - * @param group The setting group - * @param name The name of the setting - */ -export function getUserSettingDefinitionLazy(group: string, name: string) { - return proxyLazy(() => getUserSettingDefinition(group, name)); -} diff --git a/src/plugins/_api/userSettingsDefinitions.ts b/src/plugins/_api/userSettingsDefinitions.ts deleted file mode 100644 index 3a00bc116..000000000 --- a/src/plugins/_api/userSettingsDefinitions.ts +++ /dev/null @@ -1,50 +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 { Devs } from "@utils/constants"; -import definePlugin from "@utils/types"; - -export default definePlugin({ - name: "UserSettingsAPI", - description: "Patches Discord's UserSettings to expose their group and name.", - authors: [Devs.Nuckyz], - - patches: [ - { - find: ",updateSetting:", - replacement: [ - // Main setting definition - { - match: /(?<=INFREQUENT_USER_ACTION.{0,20},)useSetting:/, - replace: "userSettingsAPIGroup:arguments[0],userSettingsAPIName:arguments[1],$&" - }, - // Selective wrapper - { - match: /updateSetting:.{0,100}SELECTIVELY_SYNCED_USER_SETTINGS_UPDATE/, - replace: "userSettingsAPIGroup:arguments[0].userSettingsAPIGroup,userSettingsAPIName:arguments[0].userSettingsAPIName,$&" - }, - // Override wrapper - { - match: /updateSetting:.{0,60}USER_SETTINGS_OVERRIDE_CLEAR/, - replace: "userSettingsAPIGroup:arguments[0].userSettingsAPIGroup,userSettingsAPIName:arguments[0].userSettingsAPIName,$&" - } - - ] - } - ] -});