From f092f434fe48ba0db8b3c0c66524899b5a21c4f1 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Tue, 4 Apr 2023 21:09:47 +0200 Subject: Fix Vencord --- src/webpack/common/components.ts | 53 +++++++++++++++++++--------------------- src/webpack/common/menu.ts | 24 +++--------------- 2 files changed, 28 insertions(+), 49 deletions(-) (limited to 'src/webpack/common') diff --git a/src/webpack/common/components.ts b/src/webpack/common/components.ts index 4993b22..9554f95 100644 --- a/src/webpack/common/components.ts +++ b/src/webpack/common/components.ts @@ -17,40 +17,37 @@ */ // eslint-disable-next-line path-alias/no-relative -import { filters, findByPropsLazy } from "../webpack"; +import { filters, findByPropsLazy, waitFor } from "@webpack"; + import { waitForComponent } from "./internal"; import * as t from "./types/components"; -export const Forms = { - FormTitle: waitForComponent("FormTitle", filters.byCode("errorSeparator")), - FormSection: waitForComponent("FormSection", filters.byCode("titleClassName", "sectionTitle")), - FormDivider: waitForComponent("FormDivider", m => { - if (typeof m !== "function") return false; - const s = m.toString(); - return s.length < 200 && s.includes(".divider"); - }), - FormText: waitForComponent("FormText", m => m.Types?.INPUT_PLACEHOLDER), +export let Forms = {} as { + FormTitle: t.FormTitle, + FormSection: t.FormSection, + FormDivider: t.FormDivider, + FormText: t.FormText, }; -export const Card = waitForComponent("Card", m => m.Types?.PRIMARY && m.defaultProps); -export const Button = waitForComponent("Button", ["Hovers", "Looks", "Sizes"]); -export const Switch = waitForComponent("Switch", filters.byCode("tooltipNote", "ringTarget")); -export const Tooltip = waitForComponent("Tooltip", filters.byCode("shouldShowTooltip:!1", "clickableOnMobile||")); +export let Card: t.Card; +export let Button: t.Button; +export let Switch: t.Switch; +export let Tooltip: t.Tooltip; +export let TextInput: t.TextInput; +export let TextArea: t.TextArea; +export let Text: t.Text; +export let Select: t.Select; +export let SearchableSelect: t.SearchableSelect; +export let Slider: t.Slider; +export let ButtonLooks: t.ButtonLooks; +export let TabBar: any; + export const Timestamp = waitForComponent("Timestamp", filters.byCode(".Messages.MESSAGE_EDITED_TIMESTAMP_A11Y_LABEL.format")); -export const TextInput = waitForComponent("TextInput", ["defaultProps", "Sizes", "contextType"]); -export const TextArea = waitForComponent("TextArea", filters.byCode("handleSetRef", "textArea")); -export const Text = waitForComponent("Text", m => { - if (typeof m !== "function") return false; - const s = m.toString(); - return (s.length < 1500 && s.includes("data-text-variant") && s.includes("always-white")); -}); -export const Select = waitForComponent("Select", filters.byCode("optionClassName", "popoutPosition", "autoFocus", "maxVisibleItems")); -const searchableSelectFilter = filters.byCode("autoFocus", ".Messages.SELECT"); -export const SearchableSelect = waitForComponent("SearchableSelect", m => - m.render && searchableSelectFilter(m.render) -); -export const Slider = waitForComponent("Slider", filters.byCode("closestMarkerIndex", "stickToMarkers")); export const Flex = waitForComponent("Flex", ["Justify", "Align", "Wrap"]); export const ButtonWrapperClasses = findByPropsLazy("buttonWrapper", "buttonContent") as Record; -export const ButtonLooks: t.ButtonLooks = findByPropsLazy("BLANK", "FILLED", "INVERTED"); + +waitFor("FormItem", m => { + ({ Card, Button, FormSwitch: Switch, Tooltip, TextInput, TextArea, Text, Select, SearchableSelect, Slider, ButtonLooks, TabBar } = m); + Forms = m; +}); diff --git a/src/webpack/common/menu.ts b/src/webpack/common/menu.ts index 6ecd754..97d1d2f 100644 --- a/src/webpack/common/menu.ts +++ b/src/webpack/common/menu.ts @@ -16,32 +16,14 @@ * along with this program. If not, see . */ -import { proxyLazy } from "@utils/proxyLazy"; // eslint-disable-next-line path-alias/no-relative -import { filters, mapMangledModule, mapMangledModuleLazy } from "../webpack"; +import { filters, mapMangledModuleLazy, waitFor } from "../webpack"; import type * as t from "./types/menu"; -export const Menu: t.Menu = proxyLazy(() => { - const hasDeobfuscator = Vencord.Settings.plugins.MenuItemDeobfuscatorAPI.enabled; - const menuItems = ["MenuSeparator", "MenuGroup", "MenuItem", "MenuCheckboxItem", "MenuRadioItem", "MenuControlItem"]; +export let Menu = {} as t.Menu; - const map = mapMangledModule("♫ ⊂(。◕‿‿◕。⊂) ♪", { - ContextMenu: filters.byCode("getContainerProps"), - ...Object.fromEntries((hasDeobfuscator ? menuItems : []).map(s => [s, (m: any) => m.name === s])) - }) as t.Menu; - - if (!hasDeobfuscator) { - for (const m of menuItems) - Object.defineProperty(map, m, { - get() { - throw new Error("MenuItemDeobfuscator must be enabled to use this."); - } - }); - } - - return map; -}); +waitFor("MenuItem", m => Menu = m); export const ContextMenu: t.ContextMenuApi = mapMangledModuleLazy('type:"CONTEXT_MENU_OPEN"', { open: filters.byCode("stopPropagation"), -- cgit