Immediate finds
This commit is contained in:
parent
86b53b24a6
commit
75fa0ff708
|
@ -400,7 +400,7 @@ async function runtime(token: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Vencord.Webpack.waitFor(
|
Vencord.Webpack.waitFor(
|
||||||
"loginToken",
|
Vencord.Webpack.filters.byProps("loginToken"),
|
||||||
m => {
|
m => {
|
||||||
console.log("[PUP_DEBUG]", "Logging in with token...");
|
console.log("[PUP_DEBUG]", "Logging in with token...");
|
||||||
m.loginToken(token);
|
m.loginToken(token);
|
||||||
|
@ -471,39 +471,62 @@ async function runtime(token: string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const [searchType, args] of Vencord.Webpack.lazyWebpackSearchHistory) {
|
for (const [searchType, args] of [...Vencord.Webpack.webpackSearchHistory]) {
|
||||||
let method = searchType;
|
let method = searchType as string;
|
||||||
|
|
||||||
if (searchType === "findComponent") method = "find";
|
if (searchType === "waitFor") method = "cacheFind";
|
||||||
if (searchType === "findExportedComponent") method = "findByProps";
|
|
||||||
if (searchType === "waitFor" || searchType === "waitForComponent") {
|
|
||||||
if (typeof args[0] === "string") method = "findByProps";
|
|
||||||
else method = "find";
|
|
||||||
}
|
|
||||||
if (searchType === "waitForStore") method = "findStore";
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let result: any;
|
let result: any;
|
||||||
|
|
||||||
if (method === "proxyLazyWebpack" || method === "LazyComponentWebpack") {
|
if (method === "webpackDependantLazy" || method === "webpackDependantLazyComponent") {
|
||||||
const [factory] = args;
|
const [factory] = args;
|
||||||
result = factory();
|
result = factory();
|
||||||
|
if (result != null && "$$vencordGetter" in result) result = result.$$vencordGetter();
|
||||||
} else if (method === "extractAndLoadChunks") {
|
} else if (method === "extractAndLoadChunks") {
|
||||||
const [code, matcher] = args;
|
const [code, matcher] = args;
|
||||||
|
|
||||||
const module = Vencord.Webpack.findModuleFactory(...code);
|
const module = Vencord.Webpack.findModuleFactory(...code);
|
||||||
if (module) result = module.toString().match(canonicalizeMatch(matcher));
|
if (module) result = module.toString().match(Vencord.Util.canonicalizeMatch(matcher));
|
||||||
} else {
|
} else {
|
||||||
// @ts-ignore
|
|
||||||
result = Vencord.Webpack[method](...args);
|
result = Vencord.Webpack[method](...args);
|
||||||
|
|
||||||
|
// If the result is our Proxy or ComponentWrapper, this means the search failed
|
||||||
|
if (result != null && result[Vencord.Util.proxyInnerGet] != null) result = undefined;
|
||||||
|
if (result != null && "$$vencordGetter" in result) result = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result == null || ("$$vencordInternal" in result && result.$$vencordInternal() == null)) throw "a rock at ben shapiro";
|
if (result == null) throw "find failed";
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
let logMessage = searchType;
|
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()})`;
|
let filterName = "";
|
||||||
else logMessage += `(${args.map(arg => `"${arg}"`).join(", ")})`;
|
let parsedArgs = args;
|
||||||
|
if ("$$vencordProps" in args[0]) {
|
||||||
|
if (
|
||||||
|
searchType === "find" ||
|
||||||
|
searchType === "findComponent" ||
|
||||||
|
searchType === "waitFor"
|
||||||
|
) {
|
||||||
|
filterName = args[0].$$vencordProps[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
parsedArgs = args[0].$$vencordProps.slice(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
parsedArgs === args && searchType === "waitFor" ||
|
||||||
|
searchType === "find" ||
|
||||||
|
searchType === "findComponent" ||
|
||||||
|
searchType === "webpackDependantLazy" ||
|
||||||
|
searchType === "webpackDependantLazyComponent"
|
||||||
|
) {
|
||||||
|
logMessage += `(${parsedArgs[0].toString().slice(0, 147)}...)`;
|
||||||
|
} else if (searchType === "extractAndLoadChunks") {
|
||||||
|
logMessage += `([${parsedArgs[0].map((arg: any) => `"${arg}"`).join(", ")}], ${parsedArgs[1].toString()})`;
|
||||||
|
} else {
|
||||||
|
logMessage += `(${filterName.length ? `${filterName}(` : ""}${parsedArgs.map(arg => `"${arg}"`).join(", ")})${filterName.length ? ")" : ""}`;
|
||||||
|
}
|
||||||
|
|
||||||
console.log("[PUP_WEBPACK_FIND_FAIL]", logMessage);
|
console.log("[PUP_WEBPACK_FIND_FAIL]", logMessage);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,13 +8,12 @@ import "./ChatButton.css";
|
||||||
|
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { Logger } from "@utils/Logger";
|
import { Logger } from "@utils/Logger";
|
||||||
import { waitFor } from "@webpack";
|
import { findByProps } from "@webpack";
|
||||||
import { Button, ButtonLooks, ButtonWrapperClasses, Tooltip } from "@webpack/common";
|
import { Button, ButtonLooks, ButtonWrapperClasses, Tooltip } from "@webpack/common";
|
||||||
import { Channel } from "discord-types/general";
|
import { Channel } from "discord-types/general";
|
||||||
import { HTMLProps, MouseEventHandler, ReactNode } from "react";
|
import { HTMLProps, MouseEventHandler, ReactNode } from "react";
|
||||||
|
|
||||||
let ChannelTextAreaClasses: Record<"button" | "buttonContainer", string>;
|
const ChannelTextAreaClasses = findByProps<Record<"button" | "buttonContainer", string>>("buttonContainer", "channelTextArea");
|
||||||
waitFor(["buttonContainer", "channelTextArea"], m => ChannelTextAreaClasses = m);
|
|
||||||
|
|
||||||
export interface ChatBarProps {
|
export interface ChatBarProps {
|
||||||
channel: Channel;
|
channel: Channel;
|
||||||
|
|
|
@ -17,14 +17,14 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { mergeDefaults } from "@utils/misc";
|
import { mergeDefaults } from "@utils/misc";
|
||||||
import { findByPropsLazy } from "@webpack";
|
import { findByProps } from "@webpack";
|
||||||
import { MessageActions, SnowflakeUtils } from "@webpack/common";
|
import { MessageActions, SnowflakeUtils } from "@webpack/common";
|
||||||
import { Message } from "discord-types/general";
|
import { Message } from "discord-types/general";
|
||||||
import type { PartialDeep } from "type-fest";
|
import type { PartialDeep } from "type-fest";
|
||||||
|
|
||||||
import { Argument } from "./types";
|
import { Argument } from "./types";
|
||||||
|
|
||||||
const MessageCreator = findByPropsLazy("createBotMessage");
|
const MessageCreator = findByProps("createBotMessage");
|
||||||
|
|
||||||
export function generateId() {
|
export function generateId() {
|
||||||
return `-${SnowflakeUtils.fromTimestamp(Date.now())}`;
|
return `-${SnowflakeUtils.fromTimestamp(Date.now())}`;
|
||||||
|
|
|
@ -16,10 +16,9 @@
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { waitFor } from "@webpack";
|
import { find } from "@webpack";
|
||||||
|
|
||||||
let NoticesModule: any;
|
const NoticesModule = find(m => m.show && m.dismiss && !m.suppressAll, m => m);
|
||||||
waitFor(m => m.show && m.dismiss && !m.suppressAll, m => NoticesModule = m);
|
|
||||||
|
|
||||||
export const noticesQueue = [] as any[];
|
export const noticesQueue = [] as any[];
|
||||||
export let currentNotice: any = null;
|
export let currentNotice: any = null;
|
||||||
|
|
|
@ -4,10 +4,10 @@
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { findByPropsLazy } from "@webpack";
|
import { findByProps } from "@webpack";
|
||||||
import { Parser } from "@webpack/common";
|
import { Parser } from "@webpack/common";
|
||||||
|
|
||||||
const CodeContainerClasses = findByPropsLazy("markup", "codeContainer");
|
const CodeContainerClasses = findByProps("markup", "codeContainer");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renders code in a Discord codeblock
|
* Renders code in a Discord codeblock
|
||||||
|
|
|
@ -25,7 +25,7 @@ import { Margins } from "@utils/margins";
|
||||||
import { classes, isObjectEmpty } from "@utils/misc";
|
import { classes, isObjectEmpty } from "@utils/misc";
|
||||||
import { ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, ModalSize } from "@utils/modal";
|
import { ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, ModalSize } from "@utils/modal";
|
||||||
import { OptionType, Plugin } from "@utils/types";
|
import { OptionType, Plugin } from "@utils/types";
|
||||||
import { findByPropsLazy, findComponentByCodeLazy } from "@webpack";
|
import { findByProps,findComponentByCode } from "@webpack";
|
||||||
import { Button, Clickable, FluxDispatcher, Forms, React, Text, Tooltip, UserStore, UserUtils } from "@webpack/common";
|
import { Button, Clickable, FluxDispatcher, Forms, React, Text, Tooltip, UserStore, UserUtils } from "@webpack/common";
|
||||||
import { User } from "discord-types/general";
|
import { User } from "discord-types/general";
|
||||||
import { Constructor } from "type-fest";
|
import { Constructor } from "type-fest";
|
||||||
|
@ -41,8 +41,8 @@ import {
|
||||||
} from "./components";
|
} from "./components";
|
||||||
import { openContributorModal } from "./ContributorModal";
|
import { openContributorModal } from "./ContributorModal";
|
||||||
|
|
||||||
const UserSummaryItem = findComponentByCodeLazy("defaultRenderUser", "showDefaultAvatarsForNullUsers");
|
const UserSummaryItem = findComponentByCode("defaultRenderUser", "showDefaultAvatarsForNullUsers");
|
||||||
const AvatarStyles = findByPropsLazy("moreUsers", "emptyUser", "avatarContainer", "clickableAvatar");
|
const AvatarStyles = findByProps("moreUsers", "emptyUser", "avatarContainer", "clickableAvatar");
|
||||||
const UserRecord: Constructor<Partial<User>> = proxyLazy(() => UserStore.getCurrentUser().constructor) as any;
|
const UserRecord: Constructor<Partial<User>> = proxyLazy(() => UserStore.getCurrentUser().constructor) as any;
|
||||||
|
|
||||||
interface PluginModalProps extends ModalProps {
|
interface PluginModalProps extends ModalProps {
|
||||||
|
|
|
@ -33,7 +33,7 @@ import { classes, isObjectEmpty } from "@utils/misc";
|
||||||
import { openModalLazy } from "@utils/modal";
|
import { openModalLazy } from "@utils/modal";
|
||||||
import { useAwaiter } from "@utils/react";
|
import { useAwaiter } from "@utils/react";
|
||||||
import { Plugin } from "@utils/types";
|
import { Plugin } from "@utils/types";
|
||||||
import { findByPropsLazy } from "@webpack";
|
import { findByProps } from "@webpack";
|
||||||
import { Alerts, Button, Card, Forms, lodash, Parser, React, Select, Text, TextInput, Toasts, Tooltip } from "@webpack/common";
|
import { Alerts, Button, Card, Forms, lodash, Parser, React, Select, Text, TextInput, Toasts, Tooltip } from "@webpack/common";
|
||||||
|
|
||||||
import Plugins from "~plugins";
|
import Plugins from "~plugins";
|
||||||
|
@ -44,8 +44,8 @@ import { startDependenciesRecursive, startPlugin, stopPlugin } from "../../plugi
|
||||||
const cl = classNameFactory("vc-plugins-");
|
const cl = classNameFactory("vc-plugins-");
|
||||||
const logger = new Logger("PluginSettings", "#a6d189");
|
const logger = new Logger("PluginSettings", "#a6d189");
|
||||||
|
|
||||||
const InputStyles = findByPropsLazy("inputDefault", "inputWrapper");
|
const InputStyles = findByProps("inputDefault", "inputWrapper");
|
||||||
const ButtonClasses = findByPropsLazy("button", "disabled", "enabled");
|
const ButtonClasses = findByProps("button", "disabled", "enabled");
|
||||||
|
|
||||||
|
|
||||||
function showErrorToast(message: string) {
|
function showErrorToast(message: string) {
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
import "./Switch.css";
|
import "./Switch.css";
|
||||||
|
|
||||||
import { classes } from "@utils/misc";
|
import { classes } from "@utils/misc";
|
||||||
import { findByPropsLazy } from "@webpack";
|
import { findByProps } from "@webpack";
|
||||||
|
|
||||||
interface SwitchProps {
|
interface SwitchProps {
|
||||||
checked: boolean;
|
checked: boolean;
|
||||||
|
@ -29,7 +29,7 @@ interface SwitchProps {
|
||||||
|
|
||||||
const SWITCH_ON = "var(--green-360)";
|
const SWITCH_ON = "var(--green-360)";
|
||||||
const SWITCH_OFF = "var(--primary-400)";
|
const SWITCH_OFF = "var(--primary-400)";
|
||||||
const SwitchClasses = findByPropsLazy("slider", "input", "container");
|
const SwitchClasses = findByProps("slider", "input", "container");
|
||||||
|
|
||||||
export function Switch({ checked, onChange, disabled }: SwitchProps) {
|
export function Switch({ checked, onChange, disabled }: SwitchProps) {
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -29,23 +29,22 @@ import { classes } from "@utils/misc";
|
||||||
import { openModal } from "@utils/modal";
|
import { openModal } from "@utils/modal";
|
||||||
import { showItemInFolder } from "@utils/native";
|
import { showItemInFolder } from "@utils/native";
|
||||||
import { useAwaiter } from "@utils/react";
|
import { useAwaiter } from "@utils/react";
|
||||||
import { findByPropsLazy, findLazy } from "@webpack";
|
import { find, findComponent } from "@webpack";
|
||||||
import { Button, Card, Forms, React, showToast, TabBar, TextArea, useEffect, useRef, useState } from "@webpack/common";
|
import { Button, Card, Forms, React, showToast, TabBar, TextArea, useEffect, useRef, useState } from "@webpack/common";
|
||||||
import type { ComponentType, Ref, SyntheticEvent } from "react";
|
import type { Ref, SyntheticEvent } from "react";
|
||||||
|
|
||||||
import { AddonCard } from "./AddonCard";
|
import { AddonCard } from "./AddonCard";
|
||||||
import { SettingsTab, wrapTab } from "./shared";
|
import { SettingsTab, wrapTab } from "./shared";
|
||||||
|
|
||||||
type FileInput = ComponentType<{
|
type FileInputProps = {
|
||||||
ref: Ref<HTMLInputElement>;
|
ref: Ref<HTMLInputElement>;
|
||||||
onChange: (e: SyntheticEvent<HTMLInputElement>) => void;
|
onChange: (e: SyntheticEvent<HTMLInputElement>) => void;
|
||||||
multiple?: boolean;
|
multiple?: boolean;
|
||||||
filters?: { name?: string; extensions: string[]; }[];
|
filters?: { name?: string; extensions: string[]; }[];
|
||||||
}>;
|
};
|
||||||
|
|
||||||
const InviteActions = findByPropsLazy("resolveInvite");
|
const FileInput = findComponent<FileInputProps>(m => m.prototype?.activateUploadDialogue && m.prototype.setRef);
|
||||||
const FileInput: FileInput = findLazy(m => m.prototype?.activateUploadDialogue && m.prototype.setRef);
|
const TextAreaProps = find(m => typeof m.textarea === "string");
|
||||||
const TextAreaProps = findLazy(m => typeof m.textarea === "string");
|
|
||||||
|
|
||||||
const cl = classNameFactory("vc-settings-theme-");
|
const cl = classNameFactory("vc-settings-theme-");
|
||||||
|
|
||||||
|
|
|
@ -21,12 +21,12 @@ import { definePluginSettings } from "@api/Settings";
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { findByCodeLazy, findByPropsLazy } from "@webpack";
|
import { findByCode, findByProps } from "@webpack";
|
||||||
|
|
||||||
type AnonUpload = Upload & { anonymise?: boolean; };
|
type AnonUpload = Upload & { anonymise?: boolean; };
|
||||||
|
|
||||||
const ActionBarIcon = findByCodeLazy(".actionBarIcon)");
|
const ActionBarIcon = findByCode(".actionBarIcon)");
|
||||||
const UploadDraft = findByPropsLazy("popFirstFile", "update");
|
const UploadDraft = findByProps("popFirstFile", "update");
|
||||||
|
|
||||||
const enum Methods {
|
const enum Methods {
|
||||||
Random,
|
Random,
|
||||||
|
|
|
@ -20,10 +20,10 @@ import { popNotice, showNotice } from "@api/Notices";
|
||||||
import { Link } from "@components/Link";
|
import { Link } from "@components/Link";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
import { findByPropsLazy } from "@webpack";
|
import { findByProps } from "@webpack";
|
||||||
import { ApplicationAssetUtils, FluxDispatcher, Forms, Toasts } from "@webpack/common";
|
import { ApplicationAssetUtils, FluxDispatcher, Forms, Toasts } from "@webpack/common";
|
||||||
|
|
||||||
const RpcUtils = findByPropsLazy("fetchApplicationsRPC", "getRemoteIconURL");
|
const RpcUtils = findByProps("fetchApplicationsRPC", "getRemoteIconURL");
|
||||||
|
|
||||||
async function lookupAsset(applicationId: string, key: string): Promise<string> {
|
async function lookupAsset(applicationId: string, key: string): Promise<string> {
|
||||||
return (await ApplicationAssetUtils.fetchAssetIds(applicationId, [key]))[0];
|
return (await ApplicationAssetUtils.fetchAssetIds(applicationId, [key]))[0];
|
||||||
|
|
|
@ -17,15 +17,15 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { findByPropsLazy, findComponentByCodeLazy, findStoreLazy } from "@webpack";
|
import { findByProps, findComponentByCode, findStore } from "@webpack";
|
||||||
import { useStateFromStores } from "@webpack/common";
|
import { useStateFromStores } from "@webpack/common";
|
||||||
import type { CSSProperties } from "react";
|
import type { CSSProperties } from "react";
|
||||||
|
|
||||||
import { ExpandedGuildFolderStore, settings } from ".";
|
import { ExpandedGuildFolderStore, settings } from ".";
|
||||||
|
|
||||||
const ChannelRTCStore = findStoreLazy("ChannelRTCStore");
|
const ChannelRTCStore = findStore("ChannelRTCStore");
|
||||||
const Animations = findByPropsLazy("a", "animated", "useTransition");
|
const Animations = findByProps("a", "animated", "useTransition");
|
||||||
const GuildsBar = findComponentByCodeLazy('("guildsnav")');
|
const GuildsBar = findComponentByCode('("guildsnav")');
|
||||||
|
|
||||||
export default ErrorBoundary.wrap(guildsBarProps => {
|
export default ErrorBoundary.wrap(guildsBarProps => {
|
||||||
const expandedFolders = useStateFromStores([ExpandedGuildFolderStore], () => ExpandedGuildFolderStore.getExpandedFolders());
|
const expandedFolders = useStateFromStores([ExpandedGuildFolderStore], () => ExpandedGuildFolderStore.getExpandedFolders());
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
import { definePluginSettings } from "@api/Settings";
|
import { definePluginSettings } from "@api/Settings";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { findByPropsLazy, findStoreLazy } from "@webpack";
|
import { findByProps, findStore } from "@webpack";
|
||||||
import { FluxDispatcher, i18n } from "@webpack/common";
|
import { FluxDispatcher, i18n } from "@webpack/common";
|
||||||
|
|
||||||
import FolderSideBar from "./FolderSideBar";
|
import FolderSideBar from "./FolderSideBar";
|
||||||
|
@ -30,10 +30,10 @@ enum FolderIconDisplay {
|
||||||
MoreThanOneFolderExpanded
|
MoreThanOneFolderExpanded
|
||||||
}
|
}
|
||||||
|
|
||||||
const { GuildsTree } = findByPropsLazy("GuildsTree");
|
const { GuildsTree } = findByProps("GuildsTree");
|
||||||
const SortedGuildStore = findStoreLazy("SortedGuildStore");
|
const SortedGuildStore = findStore("SortedGuildStore");
|
||||||
export const ExpandedGuildFolderStore = findStoreLazy("ExpandedGuildFolderStore");
|
export const ExpandedGuildFolderStore = findStore("ExpandedGuildFolderStore");
|
||||||
const FolderUtils = findByPropsLazy("move", "toggleGuildFolderExpand");
|
const FolderUtils = findByProps("move", "toggleGuildFolderExpand");
|
||||||
|
|
||||||
let lastGuildId = null as string | null;
|
let lastGuildId = null as string | null;
|
||||||
let dispatchingFoldersClose = false;
|
let dispatchingFoldersClose = false;
|
||||||
|
|
|
@ -20,9 +20,9 @@ import { Settings } from "@api/Settings";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import { canonicalizeMatch } from "@utils/patches";
|
import { canonicalizeMatch } from "@utils/patches";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { findByPropsLazy } from "@webpack";
|
import { findByProps } from "@webpack";
|
||||||
|
|
||||||
const UserPopoutSectionCssClasses = findByPropsLazy("section", "lastSection");
|
const UserPopoutSectionCssClasses = findByProps("section", "lastSection");
|
||||||
|
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "BetterNotesBox",
|
name: "BetterNotesBox",
|
||||||
|
|
|
@ -7,10 +7,10 @@
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import { getCurrentGuild } from "@utils/discord";
|
import { getCurrentGuild } from "@utils/discord";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
import { findByPropsLazy } from "@webpack";
|
import { findByProps } from "@webpack";
|
||||||
import { Clipboard, GuildStore, Menu, PermissionStore, TextAndImagesSettingsStores } from "@webpack/common";
|
import { Clipboard, GuildStore, Menu, PermissionStore, TextAndImagesSettingsStores } from "@webpack/common";
|
||||||
|
|
||||||
const GuildSettingsActions = findByPropsLazy("open", "selectRole", "updateGuild");
|
const GuildSettingsActions = findByProps("open", "selectRole", "updateGuild");
|
||||||
|
|
||||||
function PencilIcon() {
|
function PencilIcon() {
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -21,20 +21,20 @@ import { definePluginSettings } from "@api/Settings";
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { findByPropsLazy, findExportedComponentLazy, findStoreLazy } from "@webpack";
|
import { findByProps, findExportedComponent, findStore } from "@webpack";
|
||||||
import { React, RestAPI, Tooltip } from "@webpack/common";
|
import { React, RestAPI, Tooltip } from "@webpack/common";
|
||||||
|
|
||||||
import { RenameButton } from "./components/RenameButton";
|
import { RenameButton } from "./components/RenameButton";
|
||||||
import { Session, SessionInfo } from "./types";
|
import { Session, SessionInfo } from "./types";
|
||||||
import { fetchNamesFromDataStore, getDefaultName, GetOsColor, GetPlatformIcon, savedSessionsCache, saveSessionsToDataStore } from "./utils";
|
import { fetchNamesFromDataStore, getDefaultName, GetOsColor, GetPlatformIcon, savedSessionsCache, saveSessionsToDataStore } from "./utils";
|
||||||
|
|
||||||
const AuthSessionsStore = findStoreLazy("AuthSessionsStore");
|
const AuthSessionsStore = findStore("AuthSessionsStore");
|
||||||
const UserSettingsModal = findByPropsLazy("saveAccountChanges", "open");
|
const UserSettingsModal = findByProps("saveAccountChanges", "open");
|
||||||
|
|
||||||
const TimestampClasses = findByPropsLazy("timestampTooltip", "blockquoteContainer");
|
const TimestampClasses = findByProps("timestampTooltip", "blockquoteContainer");
|
||||||
const SessionIconClasses = findByPropsLazy("sessionIcon");
|
const SessionIconClasses = findByProps("sessionIcon");
|
||||||
|
|
||||||
const BlobMask = findExportedComponentLazy("BlobMask");
|
const BlobMask = findExportedComponent("BlobMask");
|
||||||
|
|
||||||
const settings = definePluginSettings({
|
const settings = definePluginSettings({
|
||||||
backgroundCheck: {
|
backgroundCheck: {
|
||||||
|
|
|
@ -9,14 +9,14 @@ import { classNameFactory } from "@api/Styles";
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { findByPropsLazy } from "@webpack";
|
import { findByProps } from "@webpack";
|
||||||
import { ComponentDispatch, FocusLock, i18n, Menu, useEffect, useRef } from "@webpack/common";
|
import { ComponentDispatch, FocusLock, i18n, Menu, useEffect, useRef } from "@webpack/common";
|
||||||
import type { HTMLAttributes, ReactElement } from "react";
|
import type { HTMLAttributes, ReactElement } from "react";
|
||||||
|
|
||||||
type SettingsEntry = { section: string, label: string; };
|
type SettingsEntry = { section: string, label: string; };
|
||||||
|
|
||||||
const cl = classNameFactory("");
|
const cl = classNameFactory("");
|
||||||
const Classes = findByPropsLazy("animating", "baseLayer", "bg", "layer", "layers");
|
const Classes = findByProps("animating", "baseLayer", "bg", "layer", "layers");
|
||||||
|
|
||||||
const settings = definePluginSettings({
|
const settings = definePluginSettings({
|
||||||
disableFade: {
|
disableFade: {
|
||||||
|
|
|
@ -16,9 +16,9 @@
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { findStoreLazy } from "@webpack";
|
import { findStore } from "@webpack";
|
||||||
|
|
||||||
import * as t from "./types/stores";
|
import * as t from "./types/stores";
|
||||||
|
|
||||||
export const ApplicationStreamPreviewStore: t.ApplicationStreamPreviewStore = findStoreLazy("ApplicationStreamPreviewStore");
|
export const ApplicationStreamPreviewStore: t.ApplicationStreamPreviewStore = findStore("ApplicationStreamPreviewStore");
|
||||||
export const ApplicationStreamingStore: t.ApplicationStreamingStore = findStoreLazy("ApplicationStreamingStore");
|
export const ApplicationStreamingStore: t.ApplicationStreamingStore = findStore("ApplicationStreamingStore");
|
||||||
|
|
|
@ -11,10 +11,10 @@ import { Devs } from "@utils/constants";
|
||||||
import { Margins } from "@utils/margins";
|
import { Margins } from "@utils/margins";
|
||||||
import { classes } from "@utils/misc";
|
import { classes } from "@utils/misc";
|
||||||
import definePlugin, { OptionType, StartAt } from "@utils/types";
|
import definePlugin, { OptionType, StartAt } from "@utils/types";
|
||||||
import { findByPropsLazy, findComponentByCodeLazy, findStoreLazy } from "@webpack";
|
import { findByProps, findComponentByCode, findStore } from "@webpack";
|
||||||
import { Button, Forms, useStateFromStores } from "@webpack/common";
|
import { Button, Forms, useStateFromStores } from "@webpack/common";
|
||||||
|
|
||||||
const ColorPicker = findComponentByCodeLazy(".Messages.USER_SETTINGS_PROFILE_COLOR_SELECT_COLOR", ".BACKGROUND_PRIMARY)");
|
const ColorPicker = findComponentByCode(".Messages.USER_SETTINGS_PROFILE_COLOR_SELECT_COLOR", ".BACKGROUND_PRIMARY)");
|
||||||
|
|
||||||
const colorPresets = [
|
const colorPresets = [
|
||||||
"#1E1514", "#172019", "#13171B", "#1C1C28", "#402D2D",
|
"#1E1514", "#172019", "#13171B", "#1C1C28", "#402D2D",
|
||||||
|
@ -30,14 +30,14 @@ function onPickColor(color: number) {
|
||||||
updateColorVars(hexColor);
|
updateColorVars(hexColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
const { saveClientTheme } = findByPropsLazy("saveClientTheme");
|
const { saveClientTheme } = findByProps("saveClientTheme");
|
||||||
|
|
||||||
function setTheme(theme: string) {
|
function setTheme(theme: string) {
|
||||||
saveClientTheme({ theme });
|
saveClientTheme({ theme });
|
||||||
}
|
}
|
||||||
|
|
||||||
const ThemeStore = findStoreLazy("ThemeStore");
|
const ThemeStore = findStore("ThemeStore");
|
||||||
const NitroThemeStore = findStoreLazy("ClientThemesBackgroundStore");
|
const NitroThemeStore = findStore("ClientThemesBackgroundStore");
|
||||||
|
|
||||||
function ThemeSettings() {
|
function ThemeSettings() {
|
||||||
const theme = useStateFromStores([ThemeStore], () => ThemeStore.theme);
|
const theme = useStateFromStores([ThemeStore], () => ThemeStore.theme);
|
||||||
|
|
|
@ -21,7 +21,7 @@ import { relaunch } from "@utils/native";
|
||||||
import { canonicalizeMatch, canonicalizeReplace, canonicalizeReplacement } from "@utils/patches";
|
import { canonicalizeMatch, canonicalizeReplace, canonicalizeReplacement } from "@utils/patches";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
import * as Webpack from "@webpack";
|
import * as Webpack from "@webpack";
|
||||||
import { extract, filters, findAll, search } from "@webpack";
|
import { cacheFindAll, extract, filters, search } from "@webpack";
|
||||||
import { React, ReactDOM } from "@webpack/common";
|
import { React, ReactDOM } from "@webpack/common";
|
||||||
import type { ComponentType } from "react";
|
import type { ComponentType } from "react";
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ export default definePlugin({
|
||||||
const cacheKey = String(filterProps);
|
const cacheKey = String(filterProps);
|
||||||
if (cache.has(cacheKey)) return cache.get(cacheKey);
|
if (cache.has(cacheKey)) return cache.get(cacheKey);
|
||||||
|
|
||||||
const matches = findAll(filterFactory(...filterProps));
|
const matches = cacheFindAll(filterFactory(...filterProps));
|
||||||
|
|
||||||
const result = (() => {
|
const result = (() => {
|
||||||
switch (matches.length) {
|
switch (matches.length) {
|
||||||
|
@ -73,13 +73,13 @@ export default definePlugin({
|
||||||
wpex: extract,
|
wpex: extract,
|
||||||
wpexs: (code: string) => extract(Webpack.findModuleId(code)!),
|
wpexs: (code: string) => extract(Webpack.findModuleId(code)!),
|
||||||
find,
|
find,
|
||||||
findAll,
|
findAll: cacheFindAll,
|
||||||
findByProps,
|
findByProps,
|
||||||
findAllByProps: (...props: string[]) => findAll(filters.byProps(...props)),
|
findAllByProps: (...props: string[]) => cacheFindAll(filters.byProps(...props)),
|
||||||
findByCode: newFindWrapper(filters.byCode),
|
findByCode: newFindWrapper(filters.byCode),
|
||||||
findAllByCode: (code: string) => findAll(filters.byCode(code)),
|
findAllByCode: (code: string) => cacheFindAll(filters.byCode(code)),
|
||||||
findComponentByCode: newFindWrapper(filters.componentByCode),
|
findComponentByCode: newFindWrapper(filters.componentByCode),
|
||||||
findAllComponentsByCode: (...code: string[]) => findAll(filters.componentByCode(...code)),
|
findAllComponentsByCode: (...code: string[]) => cacheFindAll(filters.componentByCode(...code)),
|
||||||
findExportedComponent: (...props: string[]) => findByProps(...props)[props[0]],
|
findExportedComponent: (...props: string[]) => findByProps(...props)[props[0]],
|
||||||
findStore: newFindWrapper(filters.byStoreName),
|
findStore: newFindWrapper(filters.byStoreName),
|
||||||
PluginsApi: Vencord.Plugins,
|
PluginsApi: Vencord.Plugins,
|
||||||
|
|
|
@ -23,25 +23,14 @@ import { Logger } from "@utils/Logger";
|
||||||
import { closeAllModals } from "@utils/modal";
|
import { closeAllModals } from "@utils/modal";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { maybePromptToUpdate } from "@utils/updater";
|
import { maybePromptToUpdate } from "@utils/updater";
|
||||||
import { filters, findBulk, proxyLazyWebpack } from "@webpack";
|
import { findByProps } from "@webpack";
|
||||||
import { FluxDispatcher, NavigationRouter, SelectedChannelStore } from "@webpack/common";
|
import { FluxDispatcher, NavigationRouter, SelectedChannelStore } from "@webpack/common";
|
||||||
|
|
||||||
const CrashHandlerLogger = new Logger("CrashHandler");
|
const CrashHandlerLogger = new Logger("CrashHandler");
|
||||||
const { ModalStack, DraftManager, DraftType, closeExpressionPicker } = proxyLazyWebpack(() => {
|
const ModalStack = findByProps("pushLazy", "popAll");
|
||||||
const modules = findBulk(
|
const DraftManager = findByProps("clearDraft", "saveDraft");
|
||||||
filters.byProps("pushLazy", "popAll"),
|
const { DraftType } = findByProps("DraftType");
|
||||||
filters.byProps("clearDraft", "saveDraft"),
|
const { closeExpressionPicker } = findByProps("closeExpressionPicker", "openExpressionPicker");
|
||||||
filters.byProps("DraftType"),
|
|
||||||
filters.byProps("closeExpressionPicker", "openExpressionPicker"),
|
|
||||||
);
|
|
||||||
|
|
||||||
return {
|
|
||||||
ModalStack: modules[0],
|
|
||||||
DraftManager: modules[1],
|
|
||||||
DraftType: modules[2]?.DraftType,
|
|
||||||
closeExpressionPicker: modules[3]?.closeExpressionPicker,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
const settings = definePluginSettings({
|
const settings = definePluginSettings({
|
||||||
attemptToPreventCrashes: {
|
attemptToPreventCrashes: {
|
||||||
|
|
|
@ -22,12 +22,12 @@ import { Devs } from "@utils/constants";
|
||||||
import { isTruthy } from "@utils/guards";
|
import { isTruthy } from "@utils/guards";
|
||||||
import { useAwaiter } from "@utils/react";
|
import { useAwaiter } from "@utils/react";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { findByCodeLazy, findByPropsLazy, findComponentByCodeLazy } from "@webpack";
|
import { findByCode, findByProps, findComponentByCode } from "@webpack";
|
||||||
import { ApplicationAssetUtils, FluxDispatcher, Forms, GuildStore, React, SelectedChannelStore, SelectedGuildStore, UserStore } from "@webpack/common";
|
import { ApplicationAssetUtils, FluxDispatcher, Forms, GuildStore, React, SelectedChannelStore, SelectedGuildStore, UserStore } from "@webpack/common";
|
||||||
|
|
||||||
const useProfileThemeStyle = findByCodeLazy("profileThemeStyle:", "--profile-gradient-primary-color");
|
const useProfileThemeStyle = findByCode("profileThemeStyle:", "--profile-gradient-primary-color");
|
||||||
const ActivityComponent = findComponentByCodeLazy("onOpenGameProfile");
|
const ActivityComponent = findComponentByCode("onOpenGameProfile");
|
||||||
const ActivityClassName = findByPropsLazy("activity", "buttonColor");
|
const ActivityClassName = findByProps("activity", "buttonColor");
|
||||||
|
|
||||||
async function getApplicationAsset(key: string): Promise<string> {
|
async function getApplicationAsset(key: string): Promise<string> {
|
||||||
if (/https?:\/\/(cdn|media)\.discordapp\.(com|net)\/attachments\//.test(key)) return "mp:" + key.replace(/https?:\/\/(cdn|media)\.discordapp\.(com|net)\//, "");
|
if (/https?:\/\/(cdn|media)\.discordapp\.(com|net)\/attachments\//.test(key)) return "mp:" + key.replace(/https?:\/\/(cdn|media)\.discordapp\.(com|net)\//, "");
|
||||||
|
|
|
@ -9,7 +9,7 @@ import "./ui/styles.css";
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
import { findByPropsLazy } from "@webpack";
|
import { findByProps } from "@webpack";
|
||||||
import { UserStore } from "@webpack/common";
|
import { UserStore } from "@webpack/common";
|
||||||
|
|
||||||
import { CDN_URL, RAW_SKU_ID, SKU_ID } from "./lib/constants";
|
import { CDN_URL, RAW_SKU_ID, SKU_ID } from "./lib/constants";
|
||||||
|
@ -20,7 +20,7 @@ import { settings } from "./settings";
|
||||||
import { setDecorationGridDecoration, setDecorationGridItem } from "./ui/components";
|
import { setDecorationGridDecoration, setDecorationGridItem } from "./ui/components";
|
||||||
import DecorSection from "./ui/components/DecorSection";
|
import DecorSection from "./ui/components/DecorSection";
|
||||||
|
|
||||||
const { isAnimatedAvatarDecoration } = findByPropsLazy("isAnimatedAvatarDecoration");
|
const { isAnimatedAvatarDecoration } = findByProps("isAnimatedAvatarDecoration");
|
||||||
export interface AvatarDecoration {
|
export interface AvatarDecoration {
|
||||||
asset: string;
|
asset: string;
|
||||||
skuId: string;
|
skuId: string;
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Flex } from "@components/Flex";
|
import { Flex } from "@components/Flex";
|
||||||
import { findByCodeLazy } from "@webpack";
|
import { findByCode } from "@webpack";
|
||||||
import { Button, useEffect } from "@webpack/common";
|
import { Button, useEffect } from "@webpack/common";
|
||||||
|
|
||||||
import { useAuthorizationStore } from "../../lib/stores/AuthorizationStore";
|
import { useAuthorizationStore } from "../../lib/stores/AuthorizationStore";
|
||||||
|
@ -13,7 +13,7 @@ import { useCurrentUserDecorationsStore } from "../../lib/stores/CurrentUserDeco
|
||||||
import { cl } from "../";
|
import { cl } from "../";
|
||||||
import { openChangeDecorationModal } from "../modals/ChangeDecorationModal";
|
import { openChangeDecorationModal } from "../modals/ChangeDecorationModal";
|
||||||
|
|
||||||
const CustomizationSection = findByCodeLazy(".customizationSectionBackground");
|
const CustomizationSection = findByCode(".customizationSectionBackground");
|
||||||
|
|
||||||
interface DecorSectionProps {
|
interface DecorSectionProps {
|
||||||
hideTitle?: boolean;
|
hideTitle?: boolean;
|
||||||
|
|
|
@ -5,13 +5,13 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { classes } from "@utils/misc";
|
import { classes } from "@utils/misc";
|
||||||
import { findByPropsLazy } from "@webpack";
|
import { findByProps } from "@webpack";
|
||||||
import { React } from "@webpack/common";
|
import { React } from "@webpack/common";
|
||||||
|
|
||||||
import { cl } from "../";
|
import { cl } from "../";
|
||||||
import Grid, { GridProps } from "./Grid";
|
import Grid, { GridProps } from "./Grid";
|
||||||
|
|
||||||
const ScrollerClasses = findByPropsLazy("managedReactiveScroller");
|
const ScrollerClasses = findByProps("managedReactiveScroller");
|
||||||
|
|
||||||
type Section<SectionT, ItemT> = SectionT & {
|
type Section<SectionT, ItemT> = SectionT & {
|
||||||
items: Array<ItemT>;
|
items: Array<ItemT>;
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { findComponentByCode, LazyComponentWebpack } from "@webpack";
|
import { filters, findComponent } from "@webpack";
|
||||||
import { React } from "@webpack/common";
|
import { React } from "@webpack/common";
|
||||||
import type { ComponentType, HTMLProps, PropsWithChildren } from "react";
|
import type { ComponentType, HTMLProps, PropsWithChildren } from "react";
|
||||||
|
|
||||||
|
@ -18,8 +18,7 @@ type DecorationGridItemComponent = ComponentType<PropsWithChildren<HTMLProps<HTM
|
||||||
export let DecorationGridItem: DecorationGridItemComponent;
|
export let DecorationGridItem: DecorationGridItemComponent;
|
||||||
export const setDecorationGridItem = v => DecorationGridItem = v;
|
export const setDecorationGridItem = v => DecorationGridItem = v;
|
||||||
|
|
||||||
export const AvatarDecorationModalPreview = LazyComponentWebpack(() => {
|
export const AvatarDecorationModalPreview = findComponent(filters.componentByCode(".shopPreviewBanner"), component => {
|
||||||
const component = findComponentByCode(".shopPreviewBanner");
|
|
||||||
return React.memo(component);
|
return React.memo(component);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -5,10 +5,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { classNameFactory } from "@api/Styles";
|
import { classNameFactory } from "@api/Styles";
|
||||||
import { extractAndLoadChunksLazy, findByPropsLazy } from "@webpack";
|
import { extractAndLoadChunksLazy, findByProps } from "@webpack";
|
||||||
|
|
||||||
export const cl = classNameFactory("vc-decor-");
|
export const cl = classNameFactory("vc-decor-");
|
||||||
export const DecorationModalStyles = findByPropsLazy("modalFooterShopButton");
|
export const DecorationModalStyles = findByProps("modalFooterShopButton");
|
||||||
|
|
||||||
export const requireAvatarDecorationModal = extractAndLoadChunksLazy(["openAvatarDecorationModal:"]);
|
export const requireAvatarDecorationModal = extractAndLoadChunksLazy(["openAvatarDecorationModal:"]);
|
||||||
export const requireCreateStickerModal = extractAndLoadChunksLazy(["stickerInspected]:"]);
|
export const requireCreateStickerModal = extractAndLoadChunksLazy(["stickerInspected]:"]);
|
||||||
|
|
|
@ -10,7 +10,7 @@ import { openInviteModal } from "@utils/discord";
|
||||||
import { Margins } from "@utils/margins";
|
import { Margins } from "@utils/margins";
|
||||||
import { classes } from "@utils/misc";
|
import { classes } from "@utils/misc";
|
||||||
import { closeAllModals, ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, ModalSize, openModal } from "@utils/modal";
|
import { closeAllModals, ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, ModalSize, openModal } from "@utils/modal";
|
||||||
import { findComponentByCodeLazy } from "@webpack";
|
import { findComponentByCode } from "@webpack";
|
||||||
import { Alerts, Button, FluxDispatcher, Forms, GuildStore, NavigationRouter, Parser, Text, Tooltip, useEffect, UserStore, UserUtils, useState } from "@webpack/common";
|
import { Alerts, Button, FluxDispatcher, Forms, GuildStore, NavigationRouter, Parser, Text, Tooltip, useEffect, UserStore, UserUtils, useState } from "@webpack/common";
|
||||||
import { User } from "discord-types/general";
|
import { User } from "discord-types/general";
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ import SectionedGridList from "../components/SectionedGridList";
|
||||||
import { openCreateDecorationModal } from "./CreateDecorationModal";
|
import { openCreateDecorationModal } from "./CreateDecorationModal";
|
||||||
import { openGuidelinesModal } from "./GuidelinesModal";
|
import { openGuidelinesModal } from "./GuidelinesModal";
|
||||||
|
|
||||||
const UserSummaryItem = findComponentByCodeLazy("defaultRenderUser", "showDefaultAvatarsForNullUsers");
|
const UserSummaryItem = findComponentByCode("defaultRenderUser", "showDefaultAvatarsForNullUsers");
|
||||||
|
|
||||||
function usePresets() {
|
function usePresets() {
|
||||||
const [presets, setPresets] = useState<Preset[]>([]);
|
const [presets, setPresets] = useState<Preset[]>([]);
|
||||||
|
|
|
@ -9,7 +9,7 @@ import { Link } from "@components/Link";
|
||||||
import { openInviteModal } from "@utils/discord";
|
import { openInviteModal } from "@utils/discord";
|
||||||
import { Margins } from "@utils/margins";
|
import { Margins } from "@utils/margins";
|
||||||
import { closeAllModals, ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, ModalSize, openModal } from "@utils/modal";
|
import { closeAllModals, ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, ModalSize, openModal } from "@utils/modal";
|
||||||
import { findByPropsLazy, findComponentByCodeLazy } from "@webpack";
|
import { findByProps, findComponentByCode } from "@webpack";
|
||||||
import { Button, FluxDispatcher, Forms, GuildStore, NavigationRouter, Text, TextInput, useEffect, useMemo, UserStore, useState } from "@webpack/common";
|
import { Button, FluxDispatcher, Forms, GuildStore, NavigationRouter, Text, TextInput, useEffect, useMemo, UserStore, useState } from "@webpack/common";
|
||||||
|
|
||||||
import { GUILD_ID, INVITE_KEY, RAW_SKU_ID } from "../../lib/constants";
|
import { GUILD_ID, INVITE_KEY, RAW_SKU_ID } from "../../lib/constants";
|
||||||
|
@ -17,9 +17,9 @@ import { useCurrentUserDecorationsStore } from "../../lib/stores/CurrentUserDeco
|
||||||
import { cl, DecorationModalStyles, requireAvatarDecorationModal, requireCreateStickerModal } from "../";
|
import { cl, DecorationModalStyles, requireAvatarDecorationModal, requireCreateStickerModal } from "../";
|
||||||
import { AvatarDecorationModalPreview } from "../components";
|
import { AvatarDecorationModalPreview } from "../components";
|
||||||
|
|
||||||
const FileUpload = findComponentByCodeLazy("fileUploadInput,");
|
const FileUpload = findComponentByCode("fileUploadInput,");
|
||||||
|
|
||||||
const { default: HelpMessage, HelpMessageTypes } = findByPropsLazy("HelpMessageTypes");
|
const { default: HelpMessage, HelpMessageTypes } = findByProps("HelpMessageTypes");
|
||||||
|
|
||||||
function useObjectURL(object: Blob | MediaSource | null) {
|
function useObjectURL(object: Blob | MediaSource | null) {
|
||||||
const [url, setUrl] = useState<string | null>(null);
|
const [url, setUrl] = useState<string | null>(null);
|
||||||
|
|
|
@ -22,7 +22,7 @@ import { Devs } from "@utils/constants";
|
||||||
import { Logger } from "@utils/Logger";
|
import { Logger } from "@utils/Logger";
|
||||||
import { canonicalizeMatch, canonicalizeReplace } from "@utils/patches";
|
import { canonicalizeMatch, canonicalizeReplace } from "@utils/patches";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { filters, findAll, search } from "@webpack";
|
import { cacheFind, filters, search } from "@webpack";
|
||||||
|
|
||||||
const PORT = 8485;
|
const PORT = 8485;
|
||||||
const NAV_ID = "dev-companion-reconnect";
|
const NAV_ID = "dev-companion-reconnect";
|
||||||
|
@ -201,22 +201,22 @@ function initWs(isManual = false) {
|
||||||
let results: any[];
|
let results: any[];
|
||||||
switch (type.replace("find", "").replace("Lazy", "")) {
|
switch (type.replace("find", "").replace("Lazy", "")) {
|
||||||
case "":
|
case "":
|
||||||
results = findAll(parsedArgs[0]);
|
results = cacheFind(parsedArgs[0]);
|
||||||
break;
|
break;
|
||||||
case "ByProps":
|
case "ByProps":
|
||||||
results = findAll(filters.byProps(...parsedArgs));
|
results = cacheFind(filters.byProps(...parsedArgs));
|
||||||
break;
|
break;
|
||||||
case "Store":
|
case "Store":
|
||||||
results = findAll(filters.byStoreName(parsedArgs[0]));
|
results = cacheFind(filters.byStoreName(parsedArgs[0]));
|
||||||
break;
|
break;
|
||||||
case "ByCode":
|
case "ByCode":
|
||||||
results = findAll(filters.byCode(...parsedArgs));
|
results = cacheFind(filters.byCode(...parsedArgs));
|
||||||
break;
|
break;
|
||||||
case "ModuleId":
|
case "ModuleId":
|
||||||
results = Object.keys(search(parsedArgs[0]));
|
results = Object.keys(search(parsedArgs[0]));
|
||||||
break;
|
break;
|
||||||
case "ComponentByCode":
|
case "ComponentByCode":
|
||||||
results = findAll(filters.componentByCode(...parsedArgs));
|
results = cacheFind(filters.componentByCode(...parsedArgs));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return reply("Unknown Find Type " + type);
|
return reply("Unknown Find Type " + type);
|
||||||
|
|
|
@ -23,12 +23,12 @@ import { Logger } from "@utils/Logger";
|
||||||
import { Margins } from "@utils/margins";
|
import { Margins } from "@utils/margins";
|
||||||
import { ModalContent, ModalHeader, ModalRoot, openModalLazy } from "@utils/modal";
|
import { ModalContent, ModalHeader, ModalRoot, openModalLazy } from "@utils/modal";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
import { findByPropsLazy, findStoreLazy } from "@webpack";
|
import { findByProps, findStore } from "@webpack";
|
||||||
import { EmojiStore, FluxDispatcher, Forms, GuildStore, Menu, PermissionsBits, PermissionStore, React, RestAPI, Toasts, Tooltip, UserStore } from "@webpack/common";
|
import { EmojiStore, FluxDispatcher, Forms, GuildStore, Menu, PermissionsBits, PermissionStore, React, RestAPI, Toasts, Tooltip, UserStore } from "@webpack/common";
|
||||||
import { Promisable } from "type-fest";
|
import { Promisable } from "type-fest";
|
||||||
|
|
||||||
const StickersStore = findStoreLazy("StickersStore");
|
const StickersStore = findStore("StickersStore");
|
||||||
const EmojiManager = findByPropsLazy("fetchEmoji", "uploadEmoji", "deleteEmoji");
|
const EmojiManager = findByProps("fetchEmoji", "uploadEmoji", "deleteEmoji");
|
||||||
|
|
||||||
interface Sticker {
|
interface Sticker {
|
||||||
t: "Sticker";
|
t: "Sticker";
|
||||||
|
|
|
@ -22,10 +22,10 @@ import { ErrorCard } from "@components/ErrorCard";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import { Margins } from "@utils/margins";
|
import { Margins } from "@utils/margins";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { findByPropsLazy } from "@webpack";
|
import { findByProps } from "@webpack";
|
||||||
import { Forms, React } from "@webpack/common";
|
import { Forms, React } from "@webpack/common";
|
||||||
|
|
||||||
const KbdStyles = findByPropsLazy("key", "removeBuildOverride");
|
const KbdStyles = findByProps("key", "removeBuildOverride");
|
||||||
|
|
||||||
const settings = definePluginSettings({
|
const settings = definePluginSettings({
|
||||||
enableIsStaff: {
|
enableIsStaff: {
|
||||||
|
|
|
@ -23,7 +23,7 @@ import { ApngBlendOp, ApngDisposeOp, importApngJs } from "@utils/dependencies";
|
||||||
import { getCurrentGuild } from "@utils/discord";
|
import { getCurrentGuild } from "@utils/discord";
|
||||||
import { Logger } from "@utils/Logger";
|
import { Logger } from "@utils/Logger";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { findByPropsLazy, findStoreLazy, proxyLazyWebpack } from "@webpack";
|
import { findByProps, findStore, webpackDependantLazy } from "@webpack";
|
||||||
import { Alerts, ChannelStore, EmojiStore, FluxDispatcher, Forms, IconUtils, lodash, Parser, PermissionsBits, PermissionStore, UploadHandler, UserSettingsActionCreators, UserStore } from "@webpack/common";
|
import { Alerts, ChannelStore, EmojiStore, FluxDispatcher, Forms, IconUtils, lodash, Parser, PermissionsBits, PermissionStore, UploadHandler, UserSettingsActionCreators, UserStore } from "@webpack/common";
|
||||||
import type { CustomEmoji } from "@webpack/types";
|
import type { CustomEmoji } from "@webpack/types";
|
||||||
import type { Message } from "discord-types/general";
|
import type { Message } from "discord-types/general";
|
||||||
|
@ -31,14 +31,14 @@ import { applyPalette, GIFEncoder, quantize } from "gifenc";
|
||||||
import type { ReactElement, ReactNode } from "react";
|
import type { ReactElement, ReactNode } from "react";
|
||||||
|
|
||||||
const DRAFT_TYPE = 0;
|
const DRAFT_TYPE = 0;
|
||||||
const StickerStore = findStoreLazy("StickersStore") as {
|
const StickerStore = findStore("StickersStore") as {
|
||||||
getPremiumPacks(): StickerPack[];
|
getPremiumPacks(): StickerPack[];
|
||||||
getAllGuildStickers(): Map<string, Sticker[]>;
|
getAllGuildStickers(): Map<string, Sticker[]>;
|
||||||
getStickerById(id: string): Sticker | undefined;
|
getStickerById(id: string): Sticker | undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
const UserSettingsProtoStore = findStoreLazy("UserSettingsProtoStore");
|
const UserSettingsProtoStore = findStore("UserSettingsProtoStore");
|
||||||
const ProtoUtils = findByPropsLazy("BINARY_READ_OPTIONS");
|
const ProtoUtils = findByProps("BINARY_READ_OPTIONS");
|
||||||
|
|
||||||
function searchProtoClassField(localName: string, protoClass: any) {
|
function searchProtoClassField(localName: string, protoClass: any) {
|
||||||
const field = protoClass?.fields?.find((field: any) => field.localName === localName);
|
const field = protoClass?.fields?.find((field: any) => field.localName === localName);
|
||||||
|
@ -48,9 +48,9 @@ function searchProtoClassField(localName: string, protoClass: any) {
|
||||||
return fieldGetter?.();
|
return fieldGetter?.();
|
||||||
}
|
}
|
||||||
|
|
||||||
const PreloadedUserSettingsActionCreators = proxyLazyWebpack(() => UserSettingsActionCreators.PreloadedUserSettingsActionCreators);
|
const PreloadedUserSettingsActionCreators = webpackDependantLazy(() => UserSettingsActionCreators.PreloadedUserSettingsActionCreators);
|
||||||
const AppearanceSettingsActionCreators = proxyLazyWebpack(() => searchProtoClassField("appearance", PreloadedUserSettingsActionCreators.ProtoClass));
|
const AppearanceSettingsActionCreators = webpackDependantLazy(() => searchProtoClassField("appearance", PreloadedUserSettingsActionCreators.ProtoClass));
|
||||||
const ClientThemeSettingsActionsCreators = proxyLazyWebpack(() => searchProtoClassField("clientThemeSettings", AppearanceSettingsActionCreators));
|
const ClientThemeSettingsActionsCreators = webpackDependantLazy(() => searchProtoClassField("clientThemeSettings", AppearanceSettingsActionCreators));
|
||||||
|
|
||||||
|
|
||||||
const enum EmojiIntentions {
|
const enum EmojiIntentions {
|
||||||
|
|
|
@ -20,7 +20,7 @@ import { definePluginSettings } from "@api/Settings";
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { findByPropsLazy } from "@webpack";
|
import { findByProps } from "@webpack";
|
||||||
import { useCallback, useEffect, useRef, useState } from "@webpack/common";
|
import { useCallback, useEffect, useRef, useState } from "@webpack/common";
|
||||||
|
|
||||||
interface SearchBarComponentProps {
|
interface SearchBarComponentProps {
|
||||||
|
@ -35,7 +35,7 @@ interface SearchBarComponentProps {
|
||||||
}
|
}
|
||||||
|
|
||||||
type TSearchBarComponent =
|
type TSearchBarComponent =
|
||||||
React.FC<SearchBarComponentProps> & { Sizes: Record<"SMALL" | "MEDIUM" | "LARGE", string>; };
|
React.ComponentType<SearchBarComponentProps> & { Sizes: Record<"SMALL" | "MEDIUM" | "LARGE", string>; };
|
||||||
|
|
||||||
interface Gif {
|
interface Gif {
|
||||||
format: number;
|
format: number;
|
||||||
|
@ -60,7 +60,7 @@ interface Instance {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const containerClasses: { searchBar: string; } = findByPropsLazy("searchBar", "searchBarFullRow");
|
const containerClasses: { searchBar: string; } = findByProps("searchBar", "searchBarFullRow");
|
||||||
|
|
||||||
export const settings = definePluginSettings({
|
export const settings = definePluginSettings({
|
||||||
searchOption: {
|
searchOption: {
|
||||||
|
|
|
@ -19,11 +19,11 @@
|
||||||
import { ApplicationCommandInputType, ApplicationCommandOptionType, findOption, sendBotMessage } from "@api/Commands";
|
import { ApplicationCommandInputType, ApplicationCommandOptionType, findOption, sendBotMessage } from "@api/Commands";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
import { findByPropsLazy } from "@webpack";
|
import { findByProps } from "@webpack";
|
||||||
import { RestAPI, UserStore } from "@webpack/common";
|
import { RestAPI, UserStore } from "@webpack/common";
|
||||||
|
|
||||||
const FriendInvites = findByPropsLazy("createFriendInvite");
|
const FriendInvites = findByProps("createFriendInvite");
|
||||||
const { uuid4 } = findByPropsLazy("uuid4");
|
const { uuid4 } = findByProps("uuid4");
|
||||||
|
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "FriendInvites",
|
name: "FriendInvites",
|
||||||
|
|
|
@ -8,14 +8,14 @@ import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import { getCurrentChannel } from "@utils/discord";
|
import { getCurrentChannel } from "@utils/discord";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
import { findByPropsLazy } from "@webpack";
|
import { findByProps } from "@webpack";
|
||||||
import { Heading, React, RelationshipStore, Text } from "@webpack/common";
|
import { Heading, React, RelationshipStore, Text } from "@webpack/common";
|
||||||
|
|
||||||
const container = findByPropsLazy("memberSinceWrapper");
|
const container = findByProps("memberSinceWrapper");
|
||||||
const { getCreatedAtDate } = findByPropsLazy("getCreatedAtDate");
|
const { getCreatedAtDate } = findByProps("getCreatedAtDate");
|
||||||
const clydeMoreInfo = findByPropsLazy("clydeMoreInfo");
|
const clydeMoreInfo = findByProps("clydeMoreInfo");
|
||||||
const locale = findByPropsLazy("getLocale");
|
const locale = findByProps("getLocale");
|
||||||
const lastSection = findByPropsLazy("lastSection");
|
const lastSection = findByProps("lastSection");
|
||||||
|
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "FriendsSince",
|
name: "FriendsSince",
|
||||||
|
|
|
@ -21,12 +21,12 @@ import { disableStyle, enableStyle } from "@api/Styles";
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { findComponentByCodeLazy } from "@webpack";
|
import { findComponentByCode } from "@webpack";
|
||||||
import { StatusSettingsStores } from "@webpack/common";
|
import { StatusSettingsStores } from "@webpack/common";
|
||||||
|
|
||||||
import style from "./style.css?managed";
|
import style from "./style.css?managed";
|
||||||
|
|
||||||
const Button = findComponentByCodeLazy("Button.Sizes.NONE,disabled:");
|
const Button = findComponentByCode("Button.Sizes.NONE,disabled:");
|
||||||
|
|
||||||
function makeIcon(showCurrentGame?: boolean) {
|
function makeIcon(showCurrentGame?: boolean) {
|
||||||
const { oldIcon } = settings.use(["oldIcon"]);
|
const { oldIcon } = settings.use(["oldIcon"]);
|
||||||
|
|
|
@ -19,9 +19,9 @@
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import { insertTextIntoChatInputBox } from "@utils/discord";
|
import { insertTextIntoChatInputBox } from "@utils/discord";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
import { findByPropsLazy } from "@webpack";
|
import { findByProps } from "@webpack";
|
||||||
|
|
||||||
const { closeExpressionPicker } = findByPropsLazy("closeExpressionPicker");
|
const { closeExpressionPicker } = findByProps("closeExpressionPicker");
|
||||||
|
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "GifPaste",
|
name: "GifPaste",
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
import { definePluginSettings } from "@api/Settings";
|
import { definePluginSettings } from "@api/Settings";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { findByPropsLazy } from "@webpack";
|
import { findByProps } from "@webpack";
|
||||||
import { ContextMenuApi, FluxDispatcher, Menu, MessageActions } from "@webpack/common";
|
import { ContextMenuApi, FluxDispatcher, Menu, MessageActions } from "@webpack/common";
|
||||||
import { Channel, Message } from "discord-types/general";
|
import { Channel, Message } from "discord-types/general";
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ const settings = definePluginSettings({
|
||||||
unholyMultiGreetEnabled?: boolean;
|
unholyMultiGreetEnabled?: boolean;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const { WELCOME_STICKERS } = findByPropsLazy("WELCOME_STICKERS");
|
const { WELCOME_STICKERS } = findByProps("WELCOME_STICKERS");
|
||||||
|
|
||||||
function greet(channel: Channel, message: Message, stickers: string[]) {
|
function greet(channel: Channel, message: Message, stickers: string[]) {
|
||||||
const options = MessageActions.getSendMessageOptionsForReply({
|
const options = MessageActions.getSendMessageOptionsForReply({
|
||||||
|
|
|
@ -11,7 +11,7 @@ import { Flex } from "@components/Flex";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import { Margins } from "@utils/margins";
|
import { Margins } from "@utils/margins";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { findStoreLazy } from "@webpack";
|
import { findStore } from "@webpack";
|
||||||
import { Button, Forms, showToast, StatusSettingsStores, TextInput, Toasts, Tooltip, useEffect, useState } from "webpack/common";
|
import { Button, Forms, showToast, StatusSettingsStores, TextInput, Toasts, Tooltip, useEffect, useState } from "webpack/common";
|
||||||
|
|
||||||
const enum ActivitiesTypes {
|
const enum ActivitiesTypes {
|
||||||
|
@ -25,7 +25,7 @@ interface IgnoredActivity {
|
||||||
type: ActivitiesTypes;
|
type: ActivitiesTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
const RunningGameStore = findStoreLazy("RunningGameStore");
|
const RunningGameStore = findStore("RunningGameStore");
|
||||||
|
|
||||||
function ToggleIcon(activity: IgnoredActivity, tooltipText: string, path: string, fill: string) {
|
function ToggleIcon(activity: IgnoredActivity, tooltipText: string, path: string, fill: string) {
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -36,7 +36,7 @@ export interface MagnifierProps {
|
||||||
|
|
||||||
const cl = classNameFactory("vc-imgzoom-");
|
const cl = classNameFactory("vc-imgzoom-");
|
||||||
|
|
||||||
export const Magnifier: React.FC<MagnifierProps> = ({ instance, size: initialSize, zoom: initalZoom }) => {
|
export const Magnifier: React.ComponentType<MagnifierProps> = ({ instance, size: initialSize, zoom: initalZoom }) => {
|
||||||
const [ready, setReady] = useState(false);
|
const [ready, setReady] = useState(false);
|
||||||
|
|
||||||
const [lensPosition, setLensPosition] = useState<Vec2>({ x: 0, y: 0 });
|
const [lensPosition, setLensPosition] = useState<Vec2>({ x: 0, y: 0 });
|
||||||
|
|
|
@ -19,11 +19,11 @@
|
||||||
import { definePluginSettings } from "@api/Settings";
|
import { definePluginSettings } from "@api/Settings";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { findByProps, findStoreLazy } from "@webpack";
|
import { findByProps, findStore } from "@webpack";
|
||||||
import { ChannelStore, FluxDispatcher, GuildStore, RelationshipStore, SnowflakeUtils, UserStore } from "@webpack/common";
|
import { ChannelStore, FluxDispatcher, GuildStore, RelationshipStore, SnowflakeUtils, UserStore } from "@webpack/common";
|
||||||
import { Settings } from "Vencord";
|
import { Settings } from "Vencord";
|
||||||
|
|
||||||
const UserAffinitiesStore = findStoreLazy("UserAffinitiesStore");
|
const UserAffinitiesStore = findStore("UserAffinitiesStore");
|
||||||
|
|
||||||
interface UserAffinity {
|
interface UserAffinity {
|
||||||
user_id: string;
|
user_id: string;
|
||||||
|
|
|
@ -21,7 +21,7 @@ import { Link } from "@components/Link";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import { Logger } from "@utils/Logger";
|
import { Logger } from "@utils/Logger";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { findByPropsLazy } from "@webpack";
|
import { findByProps } from "@webpack";
|
||||||
import { ApplicationAssetUtils, FluxDispatcher, Forms } from "@webpack/common";
|
import { ApplicationAssetUtils, FluxDispatcher, Forms } from "@webpack/common";
|
||||||
|
|
||||||
interface ActivityAssets {
|
interface ActivityAssets {
|
||||||
|
@ -85,7 +85,7 @@ const placeholderId = "2a96cbd8b46e442fc41c2b86b821562f";
|
||||||
|
|
||||||
const logger = new Logger("LastFMRichPresence");
|
const logger = new Logger("LastFMRichPresence");
|
||||||
|
|
||||||
const presenceStore = findByPropsLazy("getLocalPresence");
|
const presenceStore = findByProps("getLocalPresence");
|
||||||
|
|
||||||
async function getApplicationAsset(key: string): Promise<string> {
|
async function getApplicationAsset(key: string): Promise<string> {
|
||||||
return (await ApplicationAssetUtils.fetchAssetIds(applicationId, [key]))[0];
|
return (await ApplicationAssetUtils.fetchAssetIds(applicationId, [key]))[0];
|
||||||
|
|
|
@ -23,13 +23,13 @@ import { classNameFactory } from "@api/Styles";
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { findStoreLazy } from "@webpack";
|
import { findStore } from "@webpack";
|
||||||
import { FluxStore } from "@webpack/types";
|
import { FluxStore } from "@webpack/types";
|
||||||
|
|
||||||
import { MemberCount } from "./MemberCount";
|
import { MemberCount } from "./MemberCount";
|
||||||
|
|
||||||
export const GuildMemberCountStore = findStoreLazy("GuildMemberCountStore") as FluxStore & { getMemberCount(guildId: string): number | null; };
|
export const GuildMemberCountStore = findStore("GuildMemberCountStore") as FluxStore & { getMemberCount(guildId: string): number | null; };
|
||||||
export const ChannelMemberStore = findStoreLazy("ChannelMemberStore") as FluxStore & {
|
export const ChannelMemberStore = findStore("ChannelMemberStore") as FluxStore & {
|
||||||
getProps(guildId: string, channelId: string): { groups: { count: number; id: string; }[]; };
|
getProps(guildId: string, channelId: string): { groups: { count: number; id: string; }[]; };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ import { addClickListener, removeClickListener } from "@api/MessageEvents";
|
||||||
import { definePluginSettings, Settings } from "@api/Settings";
|
import { definePluginSettings, Settings } from "@api/Settings";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { findByPropsLazy } from "@webpack";
|
import { findByProps } from "@webpack";
|
||||||
import { FluxDispatcher, PermissionsBits, PermissionStore, UserStore } from "@webpack/common";
|
import { FluxDispatcher, PermissionsBits, PermissionStore, UserStore } from "@webpack/common";
|
||||||
|
|
||||||
let isDeletePressed = false;
|
let isDeletePressed = false;
|
||||||
|
@ -60,8 +60,8 @@ export default definePlugin({
|
||||||
settings,
|
settings,
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
const MessageActions = findByPropsLazy("deleteMessage", "startEditMessage");
|
const MessageActions = findByProps("deleteMessage", "startEditMessage");
|
||||||
const EditStore = findByPropsLazy("isEditing", "isEditingAny");
|
const EditStore = findByProps("isEditing", "isEditingAny");
|
||||||
|
|
||||||
document.addEventListener("keydown", keydown);
|
document.addEventListener("keydown", keydown);
|
||||||
document.addEventListener("keyup", keyup);
|
document.addEventListener("keyup", keyup);
|
||||||
|
|
|
@ -23,7 +23,7 @@ import { Devs } from "@utils/constants.js";
|
||||||
import { classes } from "@utils/misc";
|
import { classes } from "@utils/misc";
|
||||||
import { Queue } from "@utils/Queue";
|
import { Queue } from "@utils/Queue";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { findByPropsLazy, findComponentByCodeLazy } from "@webpack";
|
import { findByProps,findComponentByCode } from "@webpack";
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
ChannelStore,
|
ChannelStore,
|
||||||
|
@ -46,12 +46,12 @@ const messageCache = new Map<string, {
|
||||||
fetched: boolean;
|
fetched: boolean;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const Embed = findComponentByCodeLazy(".inlineMediaEmbed");
|
const Embed = findComponentByCode(".inlineMediaEmbed");
|
||||||
const AutoModEmbed = findComponentByCodeLazy(".withFooter]:", "childrenMessageContent:");
|
const AutoModEmbed = findComponentByCode(".withFooter]:", "childrenMessageContent:");
|
||||||
const ChannelMessage = findComponentByCodeLazy("renderSimpleAccessories)");
|
const ChannelMessage = findComponentByCode("renderSimpleAccessories)");
|
||||||
|
|
||||||
const SearchResultClasses = findByPropsLazy("message", "searchResult");
|
const SearchResultClasses = findByProps("message", "searchResult");
|
||||||
const EmbedClasses = findByPropsLazy("embedAuthorIcon", "embedAuthor", "embedAuthor");
|
const EmbedClasses = findByProps("embedAuthorIcon", "embedAuthor", "embedAuthor");
|
||||||
|
|
||||||
const messageLinkRegex = /(?<!<)https?:\/\/(?:\w+\.)?discord(?:app)?\.com\/channels\/(?:\d{17,20}|@me)\/(\d{17,20})\/(\d{17,20})/g;
|
const messageLinkRegex = /(?<!<)https?:\/\/(?:\w+\.)?discord(?:app)?\.com\/channels\/(?:\d{17,20}|@me)\/(\d{17,20})\/(\d{17,20})/g;
|
||||||
const tenorRegex = /^https:\/\/(?:www\.)?tenor\.com\//;
|
const tenorRegex = /^https:\/\/(?:www\.)?tenor\.com\//;
|
||||||
|
|
|
@ -25,13 +25,13 @@ import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import { Logger } from "@utils/Logger";
|
import { Logger } from "@utils/Logger";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { findByPropsLazy } from "@webpack";
|
import { findByProps } from "@webpack";
|
||||||
import { ChannelStore, FluxDispatcher, i18n, Menu, Parser, Timestamp, UserStore } from "@webpack/common";
|
import { ChannelStore, FluxDispatcher, i18n, Menu, Parser, Timestamp, UserStore } from "@webpack/common";
|
||||||
|
|
||||||
import overlayStyle from "./deleteStyleOverlay.css?managed";
|
import overlayStyle from "./deleteStyleOverlay.css?managed";
|
||||||
import textStyle from "./deleteStyleText.css?managed";
|
import textStyle from "./deleteStyleText.css?managed";
|
||||||
|
|
||||||
const styles = findByPropsLazy("edited", "communicationDisabled", "isSystemMessage");
|
const styles = findByProps("edited", "communicationDisabled", "isSystemMessage");
|
||||||
|
|
||||||
function addDeleteStyle() {
|
function addDeleteStyle() {
|
||||||
if (Settings.plugins.MessageLogger.deleteStyle === "text") {
|
if (Settings.plugins.MessageLogger.deleteStyle === "text") {
|
||||||
|
|
|
@ -21,7 +21,7 @@ import { Flex } from "@components/Flex";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import { Margins } from "@utils/margins";
|
import { Margins } from "@utils/margins";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { findByPropsLazy, findLazy } from "@webpack";
|
import { find, findByProps } from "@webpack";
|
||||||
import { Card, ChannelStore, Forms, GuildStore, PermissionsBits, Switch, TextInput, Tooltip, useState } from "@webpack/common";
|
import { Card, ChannelStore, Forms, GuildStore, PermissionsBits, Switch, TextInput, Tooltip, useState } from "@webpack/common";
|
||||||
import { RC } from "@webpack/types";
|
import { RC } from "@webpack/types";
|
||||||
import { Channel, Message, User } from "discord-types/general";
|
import { Channel, Message, User } from "discord-types/general";
|
||||||
|
@ -54,11 +54,11 @@ interface TagSettings {
|
||||||
}
|
}
|
||||||
|
|
||||||
// PermissionStore.computePermissions is not the same function and doesn't work here
|
// PermissionStore.computePermissions is not the same function and doesn't work here
|
||||||
const PermissionUtil = findByPropsLazy("computePermissions", "canEveryoneRole") as {
|
const PermissionUtil = findByProps("computePermissions", "canEveryoneRole") as {
|
||||||
computePermissions({ ...args }): bigint;
|
computePermissions({ ...args }): bigint;
|
||||||
};
|
};
|
||||||
|
|
||||||
const Tag = findLazy(m => m.Types?.[0] === "BOT") as RC<{ type?: number, className?: string, useRemSizes?: boolean; }> & { Types: Record<string, number>; };
|
const Tag = find(m => m.Types?.[0] === "BOT") as RC<{ type?: number, className?: string, useRemSizes?: boolean; }> & { Types: Record<string, number>; };
|
||||||
|
|
||||||
const isWebhook = (message: Message, user: User) => !!message?.webhookId && user.isNonUserBot();
|
const isWebhook = (message: Message, user: User) => !!message?.webhookId && user.isNonUserBot();
|
||||||
|
|
||||||
|
|
|
@ -19,15 +19,15 @@
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import { isNonNullish } from "@utils/guards";
|
import { isNonNullish } from "@utils/guards";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
import { findByPropsLazy } from "@webpack";
|
import { findByProps } from "@webpack";
|
||||||
import { Avatar, ChannelStore, Clickable, IconUtils, RelationshipStore, ScrollerThin, UserStore } from "@webpack/common";
|
import { Avatar, ChannelStore, Clickable, IconUtils, RelationshipStore, ScrollerThin, UserStore } from "@webpack/common";
|
||||||
import { Channel, User } from "discord-types/general";
|
import { Channel, User } from "discord-types/general";
|
||||||
|
|
||||||
const SelectedChannelActionCreators = findByPropsLazy("selectPrivateChannel");
|
const SelectedChannelActionCreators = findByProps("selectPrivateChannel");
|
||||||
const UserUtils = findByPropsLazy("getGlobalName");
|
const UserUtils = findByProps("getGlobalName");
|
||||||
|
|
||||||
const ProfileListClasses = findByPropsLazy("emptyIconFriends", "emptyIconGuilds");
|
const ProfileListClasses = findByProps("emptyIconFriends", "emptyIconGuilds");
|
||||||
const GuildLabelClasses = findByPropsLazy("guildNick", "guildAvatarWithoutIcon");
|
const GuildLabelClasses = findByProps("guildNick", "guildAvatarWithoutIcon");
|
||||||
|
|
||||||
function getGroupDMName(channel: Channel) {
|
function getGroupDMName(channel: Channel) {
|
||||||
return channel.name ||
|
return channel.name ||
|
||||||
|
|
|
@ -16,14 +16,14 @@
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { definePluginSettings,migratePluginSettings } from "@api/Settings";
|
import { definePluginSettings, migratePluginSettings } from "@api/Settings";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { findByPropsLazy } from "@webpack";
|
import { findByProps } from "@webpack";
|
||||||
|
|
||||||
const { updateGuildNotificationSettings } = findByPropsLazy("updateGuildNotificationSettings");
|
const { updateGuildNotificationSettings } = findByProps("updateGuildNotificationSettings");
|
||||||
const { toggleShowAllChannels } = findByPropsLazy("toggleShowAllChannels");
|
const { toggleShowAllChannels } = findByProps("toggleShowAllChannels");
|
||||||
const { isOptInEnabledForGuild } = findByPropsLazy("isOptInEnabledForGuild");
|
const { isOptInEnabledForGuild } = findByProps("isOptInEnabledForGuild");
|
||||||
|
|
||||||
const settings = definePluginSettings({
|
const settings = definePluginSettings({
|
||||||
guild: {
|
guild: {
|
||||||
|
|
|
@ -19,9 +19,9 @@
|
||||||
import { Settings } from "@api/Settings";
|
import { Settings } from "@api/Settings";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { findByPropsLazy } from "@webpack";
|
import { findByProps } from "@webpack";
|
||||||
|
|
||||||
const RelationshipStore = findByPropsLazy("getRelationships", "isBlocked");
|
const RelationshipStore = findByProps("getRelationships", "isBlocked");
|
||||||
|
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "NoBlockedMessages",
|
name: "NoBlockedMessages",
|
||||||
|
|
|
@ -19,9 +19,9 @@
|
||||||
import { definePluginSettings } from "@api/Settings";
|
import { definePluginSettings } from "@api/Settings";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { findByPropsLazy } from "@webpack";
|
import { findByProps } from "@webpack";
|
||||||
|
|
||||||
const MessageRequestStore = findByPropsLazy("getMessageRequestsCount");
|
const MessageRequestStore = findByProps("getMessageRequestsCount");
|
||||||
|
|
||||||
const settings = definePluginSettings({
|
const settings = definePluginSettings({
|
||||||
hideFriendRequestsCount: {
|
hideFriendRequestsCount: {
|
||||||
|
|
|
@ -18,11 +18,11 @@
|
||||||
|
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
import { findByPropsLazy } from "@webpack";
|
import { findByProps } from "@webpack";
|
||||||
import { GuildStore, RestAPI } from "@webpack/common";
|
import { GuildStore, RestAPI } from "@webpack/common";
|
||||||
|
|
||||||
const Messages = findByPropsLazy("GUILD_INVITE_DISABLE_ACTION_SHEET_DESCRIPTION");
|
const Messages = findByProps("GUILD_INVITE_DISABLE_ACTION_SHEET_DESCRIPTION");
|
||||||
const { InvitesDisabledExperiment } = findByPropsLazy("InvitesDisabledExperiment");
|
const { InvitesDisabledExperiment } = findByProps("InvitesDisabledExperiment");
|
||||||
|
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "PauseInvitesForever",
|
name: "PauseInvitesForever",
|
||||||
|
|
|
@ -18,8 +18,9 @@
|
||||||
|
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import ExpandableHeader from "@components/ExpandableHeader";
|
import ExpandableHeader from "@components/ExpandableHeader";
|
||||||
|
import { proxyLazy } from "@utils/lazy";
|
||||||
import { classes } from "@utils/misc";
|
import { classes } from "@utils/misc";
|
||||||
import { filters, findBulk, proxyLazyWebpack } from "@webpack";
|
import { findByProps } from "@webpack";
|
||||||
import { i18n, PermissionsBits, Text, Tooltip, useMemo, UserStore } from "@webpack/common";
|
import { i18n, PermissionsBits, Text, Tooltip, useMemo, UserStore } from "@webpack/common";
|
||||||
import type { Guild, GuildMember } from "discord-types/general";
|
import type { Guild, GuildMember } from "discord-types/general";
|
||||||
|
|
||||||
|
@ -35,13 +36,11 @@ interface UserPermission {
|
||||||
|
|
||||||
type UserPermissions = Array<UserPermission>;
|
type UserPermissions = Array<UserPermission>;
|
||||||
|
|
||||||
const Classes = proxyLazyWebpack(() =>
|
const RoleClasses1 = findByProps("roles", "rolePill", "rolePillBorder");
|
||||||
Object.assign({}, ...findBulk(
|
const RoleClasses2 = findByProps("roleCircle", "dotBorderBase", "dotBorderColor");
|
||||||
filters.byProps("roles", "rolePill", "rolePillBorder"),
|
const RoleClasses3 = findByProps("roleNameOverflow", "root", "roleName", "roleRemoveButton");
|
||||||
filters.byProps("roleCircle", "dotBorderBase", "dotBorderColor"),
|
|
||||||
filters.byProps("roleNameOverflow", "root", "roleName", "roleRemoveButton")
|
const Classes = proxyLazy(() => Object.assign({}, RoleClasses1, RoleClasses2, RoleClasses3));
|
||||||
))
|
|
||||||
) as Record<"roles" | "rolePill" | "rolePillBorder" | "desaturateUserColors" | "flex" | "alignCenter" | "justifyCenter" | "svg" | "background" | "dot" | "dotBorderColor" | "roleCircle" | "dotBorderBase" | "flex" | "alignCenter" | "justifyCenter" | "wrap" | "root" | "role" | "roleRemoveButton" | "roleDot" | "roleFlowerStar" | "roleRemoveIcon" | "roleRemoveIconFocused" | "roleVerifiedIcon" | "roleName" | "roleNameOverflow" | "actionButton" | "overflowButton" | "addButton" | "addButtonIcon" | "overflowRolesPopout" | "overflowRolesPopoutArrowWrapper" | "overflowRolesPopoutArrow" | "popoutBottom" | "popoutTop" | "overflowRolesPopoutHeader" | "overflowRolesPopoutHeaderIcon" | "overflowRolesPopoutHeaderText" | "roleIcon", string>;
|
|
||||||
|
|
||||||
function UserPermissionsComponent({ guild, guildMember, showBorder }: { guild: Guild; guildMember: GuildMember; showBorder: boolean; }) {
|
function UserPermissionsComponent({ guild, guildMember, showBorder }: { guild: Guild; guildMember: GuildMember; showBorder: boolean; }) {
|
||||||
const stns = settings.use(["permissionsSortOrder"]);
|
const stns = settings.use(["permissionsSortOrder"]);
|
||||||
|
|
|
@ -20,7 +20,7 @@ import { ApplicationCommandInputType, ApplicationCommandOptionType, Argument, Co
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import { makeLazy } from "@utils/lazy";
|
import { makeLazy } from "@utils/lazy";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
import { findByPropsLazy } from "@webpack";
|
import { findByProps } from "@webpack";
|
||||||
import { UploadHandler, UserUtils } from "@webpack/common";
|
import { UploadHandler, UserUtils } from "@webpack/common";
|
||||||
import { applyPalette, GIFEncoder, quantize } from "gifenc";
|
import { applyPalette, GIFEncoder, quantize } from "gifenc";
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ const getFrames = makeLazy(() => Promise.all(
|
||||||
))
|
))
|
||||||
);
|
);
|
||||||
|
|
||||||
const UploadStore = findByPropsLazy("getUploads");
|
const UploadStore = findByProps("getUploads");
|
||||||
|
|
||||||
function loadImage(source: File | string) {
|
function loadImage(source: File | string) {
|
||||||
const isFile = source instanceof File;
|
const isFile = source instanceof File;
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
import { classNameFactory } from "@api/Styles";
|
import { classNameFactory } from "@api/Styles";
|
||||||
import { ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, openModalLazy } from "@utils/modal";
|
import { ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, openModalLazy } from "@utils/modal";
|
||||||
import { extractAndLoadChunksLazy, findComponentByCodeLazy } from "@webpack";
|
import { extractAndLoadChunksLazy, findComponentByCode } from "@webpack";
|
||||||
import { Button, Forms, Text, TextInput, Toasts, useEffect, useState } from "@webpack/common";
|
import { Button, Forms, Text, TextInput, Toasts, useEffect, useState } from "@webpack/common";
|
||||||
|
|
||||||
import { DEFAULT_COLOR, SWATCHES } from "../constants";
|
import { DEFAULT_COLOR, SWATCHES } from "../constants";
|
||||||
|
@ -30,8 +30,8 @@ interface ColorPickerWithSwatchesProps {
|
||||||
renderCustomButton?: () => React.ReactNode;
|
renderCustomButton?: () => React.ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ColorPicker = findComponentByCodeLazy<ColorPickerProps>(".Messages.USER_SETTINGS_PROFILE_COLOR_SELECT_COLOR", ".BACKGROUND_PRIMARY)");
|
const ColorPicker = findComponentByCode<ColorPickerProps>(".Messages.USER_SETTINGS_PROFILE_COLOR_SELECT_COLOR", ".BACKGROUND_PRIMARY)");
|
||||||
const ColorPickerWithSwatches = findComponentByCodeLazy<ColorPickerWithSwatchesProps>("presets,", "customColor:");
|
const ColorPickerWithSwatches = findComponentByCode<ColorPickerWithSwatchesProps>("presets,", "customColor:");
|
||||||
|
|
||||||
export const requireSettingsMenu = extractAndLoadChunksLazy(['name:"UserSettings"'], /createPromise:.{0,20}Promise\.all\((\[\i\.\i\(".+?"\).+?\])\).then\(\i\.bind\(\i,"(.+?)"\)\).{0,50}"UserSettings"/);
|
export const requireSettingsMenu = extractAndLoadChunksLazy(['name:"UserSettings"'], /createPromise:.{0,20}Promise\.all\((\[\i\.\i\(".+?"\).+?\])\).then\(\i\.bind\(\i,"(.+?)"\)\).{0,50}"UserSettings"/);
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import { classes } from "@utils/misc";
|
import { classes } from "@utils/misc";
|
||||||
import definePlugin, { OptionType, StartAt } from "@utils/types";
|
import definePlugin, { OptionType, StartAt } from "@utils/types";
|
||||||
import { findByPropsLazy, findStoreLazy } from "@webpack";
|
import { findByProps, findStore } from "@webpack";
|
||||||
import { ContextMenuApi, FluxDispatcher, Menu, React } from "@webpack/common";
|
import { ContextMenuApi, FluxDispatcher, Menu, React } from "@webpack/common";
|
||||||
import { Channel } from "discord-types/general";
|
import { Channel } from "discord-types/general";
|
||||||
|
|
||||||
|
@ -27,9 +27,9 @@ interface ChannelComponentProps {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const headerClasses = findByPropsLazy("privateChannelsHeaderContainer");
|
const headerClasses = findByProps("privateChannelsHeaderContainer");
|
||||||
|
|
||||||
export const PrivateChannelSortStore = findStoreLazy("PrivateChannelSortStore") as { getPrivateChannelIds: () => string[]; };
|
export const PrivateChannelSortStore = findStore("PrivateChannelSortStore") as { getPrivateChannelIds: () => string[]; };
|
||||||
|
|
||||||
export let instance: any;
|
export let instance: any;
|
||||||
export const forceUpdate = () => instance?.props?._forceUpdate?.();
|
export const forceUpdate = () => instance?.props?._forceUpdate?.();
|
||||||
|
|
94
src/plugins/pinDms/settings.ts
Normal file
94
src/plugins/pinDms/settings.ts
Normal file
|
@ -0,0 +1,94 @@
|
||||||
|
/*
|
||||||
|
* 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 <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { definePluginSettings, Settings, useSettings } from "@api/Settings";
|
||||||
|
import { OptionType } from "@utils/types";
|
||||||
|
import { findStore } from "@webpack";
|
||||||
|
|
||||||
|
export const enum PinOrder {
|
||||||
|
LastMessage,
|
||||||
|
Custom
|
||||||
|
}
|
||||||
|
|
||||||
|
export const settings = definePluginSettings({
|
||||||
|
pinOrder: {
|
||||||
|
type: OptionType.SELECT,
|
||||||
|
description: "Which order should pinned DMs be displayed in?",
|
||||||
|
options: [
|
||||||
|
{ label: "Most recent message", value: PinOrder.LastMessage, default: true },
|
||||||
|
{ label: "Custom (right click channels to reorder)", value: PinOrder.Custom }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const PrivateChannelSortStore = findStore("PrivateChannelSortStore");
|
||||||
|
|
||||||
|
export let snapshotArray: string[];
|
||||||
|
let snapshot: Set<string> | undefined;
|
||||||
|
|
||||||
|
const getArray = () => (Settings.plugins.PinDMs.pinnedDMs || void 0)?.split(",") as string[] | undefined;
|
||||||
|
const save = (pins: string[]) => {
|
||||||
|
snapshot = void 0;
|
||||||
|
Settings.plugins.PinDMs.pinnedDMs = pins.join(",");
|
||||||
|
};
|
||||||
|
const takeSnapshot = () => {
|
||||||
|
snapshotArray = getArray() ?? [];
|
||||||
|
return snapshot = new Set<string>(snapshotArray);
|
||||||
|
};
|
||||||
|
const requireSnapshot = () => snapshot ?? takeSnapshot();
|
||||||
|
|
||||||
|
export function usePinnedDms() {
|
||||||
|
useSettings(["plugins.PinDMs.pinnedDMs"]);
|
||||||
|
|
||||||
|
return requireSnapshot();
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isPinned(id: string) {
|
||||||
|
return requireSnapshot().has(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function togglePin(id: string) {
|
||||||
|
const snapshot = requireSnapshot();
|
||||||
|
if (!snapshot.delete(id)) {
|
||||||
|
snapshot.add(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
save([...snapshot]);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function sortedSnapshot() {
|
||||||
|
requireSnapshot();
|
||||||
|
if (settings.store.pinOrder === PinOrder.LastMessage)
|
||||||
|
return PrivateChannelSortStore.getPrivateChannelIds().filter(isPinned);
|
||||||
|
|
||||||
|
return snapshotArray;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getPinAt(idx: number) {
|
||||||
|
return sortedSnapshot()[idx];
|
||||||
|
}
|
||||||
|
|
||||||
|
export function movePin(id: string, direction: -1 | 1) {
|
||||||
|
const pins = getArray()!;
|
||||||
|
const a = pins.indexOf(id);
|
||||||
|
const b = a + direction;
|
||||||
|
|
||||||
|
[pins[a], pins[b]] = [pins[b], pins[a]];
|
||||||
|
|
||||||
|
save(pins);
|
||||||
|
}
|
|
@ -23,11 +23,11 @@ import { Settings } from "@api/Settings";
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { findByPropsLazy, findStoreLazy } from "@webpack";
|
import { findByProps, findStore } from "@webpack";
|
||||||
import { PresenceStore, Tooltip, UserStore } from "@webpack/common";
|
import { PresenceStore, Tooltip, UserStore } from "@webpack/common";
|
||||||
import { User } from "discord-types/general";
|
import { User } from "discord-types/general";
|
||||||
|
|
||||||
const SessionsStore = findStoreLazy("SessionsStore");
|
const SessionsStore = findStore("SessionsStore");
|
||||||
|
|
||||||
function Icon(path: string, opts?: { viewBox?: string; width?: number; height?: number; }) {
|
function Icon(path: string, opts?: { viewBox?: string; width?: number; height?: number; }) {
|
||||||
return ({ color, tooltip, small }: { color: string; tooltip: string; small: boolean; }) => (
|
return ({ color, tooltip, small }: { color: string; tooltip: string; small: boolean; }) => (
|
||||||
|
@ -55,7 +55,7 @@ const Icons = {
|
||||||
};
|
};
|
||||||
type Platform = keyof typeof Icons;
|
type Platform = keyof typeof Icons;
|
||||||
|
|
||||||
const StatusUtils = findByPropsLazy("useStatusFillColor", "StatusTypes");
|
const StatusUtils = findByProps("useStatusFillColor", "StatusTypes");
|
||||||
|
|
||||||
const PlatformIcon = ({ platform, status, small }: { platform: Platform, status: string; small: boolean; }) => {
|
const PlatformIcon = ({ platform, status, small }: { platform: Platform, status: string; small: boolean; }) => {
|
||||||
const tooltip = platform[0].toUpperCase() + platform.slice(1);
|
const tooltip = platform[0].toUpperCase() + platform.slice(1);
|
||||||
|
|
|
@ -20,11 +20,11 @@ import { addChatBarButton, ChatBarButton, removeChatBarButton } from "@api/ChatB
|
||||||
import { generateId, sendBotMessage } from "@api/Commands";
|
import { generateId, sendBotMessage } from "@api/Commands";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin, { StartAt } from "@utils/types";
|
import definePlugin, { StartAt } from "@utils/types";
|
||||||
import { findByPropsLazy } from "@webpack";
|
import { findByProps } from "@webpack";
|
||||||
import { DraftStore, DraftType, SelectedChannelStore, UserStore, useStateFromStores } from "@webpack/common";
|
import { DraftStore, DraftType, SelectedChannelStore, UserStore, useStateFromStores } from "@webpack/common";
|
||||||
import { MessageAttachment } from "discord-types/general";
|
import { MessageAttachment } from "discord-types/general";
|
||||||
|
|
||||||
const UploadStore = findByPropsLazy("getUploads");
|
const UploadStore = findByProps("getUploads");
|
||||||
|
|
||||||
const getDraft = (channelId: string) => DraftStore.getDraft(channelId, DraftType.ChannelMessage);
|
const getDraft = (channelId: string) => DraftStore.getDraft(channelId, DraftType.ChannelMessage);
|
||||||
|
|
||||||
|
|
|
@ -18,14 +18,14 @@
|
||||||
|
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { classes } from "@utils/misc";
|
import { classes } from "@utils/misc";
|
||||||
import { findByPropsLazy } from "@webpack";
|
import { findByProps } from "@webpack";
|
||||||
import { UserStore } from "@webpack/common";
|
import { UserStore } from "@webpack/common";
|
||||||
import { Message } from "discord-types/general";
|
import { Message } from "discord-types/general";
|
||||||
|
|
||||||
import { useFormattedPronouns } from "../pronoundbUtils";
|
import { useFormattedPronouns } from "../pronoundbUtils";
|
||||||
import { settings } from "../settings";
|
import { settings } from "../settings";
|
||||||
|
|
||||||
const styles: Record<string, string> = findByPropsLazy("timestampInline");
|
const styles: Record<string, string> = findByProps("timestampInline");
|
||||||
|
|
||||||
const AUTO_MODERATION_ACTION = 24;
|
const AUTO_MODERATION_ACTION = 24;
|
||||||
|
|
||||||
|
|
|
@ -19,11 +19,11 @@
|
||||||
import { definePluginSettings, Settings } from "@api/Settings";
|
import { definePluginSettings, Settings } from "@api/Settings";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { findByPropsLazy } from "@webpack";
|
import { findByProps } from "@webpack";
|
||||||
import { ChannelStore, FluxDispatcher as Dispatcher, MessageStore, PermissionsBits, PermissionStore, SelectedChannelStore, UserStore } from "@webpack/common";
|
import { ChannelStore, FluxDispatcher as Dispatcher, MessageStore, PermissionsBits, PermissionStore, SelectedChannelStore, UserStore } from "@webpack/common";
|
||||||
import { Message } from "discord-types/general";
|
import { Message } from "discord-types/general";
|
||||||
|
|
||||||
const Kangaroo = findByPropsLazy("jumpToMessage");
|
const Kangaroo = findByProps("jumpToMessage");
|
||||||
|
|
||||||
const isMac = navigator.platform.includes("Mac"); // bruh
|
const isMac = navigator.platform.includes("Mac"); // bruh
|
||||||
let replyIdx = -1;
|
let replyIdx = -1;
|
||||||
|
|
|
@ -21,10 +21,10 @@ import { definePluginSettings } from "@api/Settings";
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { findByPropsLazy } from "@webpack";
|
import { findByProps } from "@webpack";
|
||||||
import { Button, Menu, Tooltip, useEffect, useState } from "@webpack/common";
|
import { Button, Menu, Tooltip, useEffect, useState } from "@webpack/common";
|
||||||
|
|
||||||
const ChannelRowClasses = findByPropsLazy("modeConnected", "modeLocked", "icon");
|
const ChannelRowClasses = findByProps("modeConnected", "modeLocked", "icon");
|
||||||
|
|
||||||
let currentShouldViewServerHome = false;
|
let currentShouldViewServerHome = false;
|
||||||
const shouldViewServerHomeStates = new Set<React.Dispatch<React.SetStateAction<boolean>>>();
|
const shouldViewServerHomeStates = new Set<React.Dispatch<React.SetStateAction<boolean>>>();
|
||||||
|
|
|
@ -18,10 +18,10 @@
|
||||||
|
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
import { findByPropsLazy } from "@webpack";
|
import { findByProps } from "@webpack";
|
||||||
|
|
||||||
const SpoilerClasses = findByPropsLazy("spoilerContent");
|
const SpoilerClasses = findByProps("spoilerContent");
|
||||||
const MessagesClasses = findByPropsLazy("messagesWrapper", "messages");
|
const MessagesClasses = findByProps("messagesWrapper", "messages");
|
||||||
|
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "RevealAllSpoilers",
|
name: "RevealAllSpoilers",
|
||||||
|
|
|
@ -7,14 +7,14 @@
|
||||||
import { DataStore } from "@api/index";
|
import { DataStore } from "@api/index";
|
||||||
import { Logger } from "@utils/Logger";
|
import { Logger } from "@utils/Logger";
|
||||||
import { openModal } from "@utils/modal";
|
import { openModal } from "@utils/modal";
|
||||||
import { findByPropsLazy } from "@webpack";
|
import { findByProps } from "@webpack";
|
||||||
import { showToast, Toasts, UserStore } from "@webpack/common";
|
import { showToast, Toasts, UserStore } from "@webpack/common";
|
||||||
|
|
||||||
import { ReviewDBAuth } from "./entities";
|
import { ReviewDBAuth } from "./entities";
|
||||||
|
|
||||||
const DATA_STORE_KEY = "rdb-auth";
|
const DATA_STORE_KEY = "rdb-auth";
|
||||||
|
|
||||||
const { OAuth2AuthorizeModal } = findByPropsLazy("OAuth2AuthorizeModal");
|
const { OAuth2AuthorizeModal } = findByProps("OAuth2AuthorizeModal");
|
||||||
|
|
||||||
export let Auth: ReviewDBAuth = {};
|
export let Auth: ReviewDBAuth = {};
|
||||||
|
|
||||||
|
|
|
@ -18,10 +18,10 @@
|
||||||
|
|
||||||
import { DeleteIcon } from "@components/Icons";
|
import { DeleteIcon } from "@components/Icons";
|
||||||
import { classes } from "@utils/misc";
|
import { classes } from "@utils/misc";
|
||||||
import { findByPropsLazy } from "@webpack";
|
import { findByProps } from "@webpack";
|
||||||
import { Tooltip } from "@webpack/common";
|
import { Tooltip } from "@webpack/common";
|
||||||
|
|
||||||
const iconClasses = findByPropsLazy("button", "wrapper", "disabled", "separator");
|
const iconClasses = findByProps("button", "wrapper", "disabled", "separator");
|
||||||
|
|
||||||
export function DeleteButton({ onClick }: { onClick(): void; }) {
|
export function DeleteButton({ onClick }: { onClick(): void; }) {
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -18,8 +18,7 @@
|
||||||
|
|
||||||
import { openUserProfile } from "@utils/discord";
|
import { openUserProfile } from "@utils/discord";
|
||||||
import { classes } from "@utils/misc";
|
import { classes } from "@utils/misc";
|
||||||
import { LazyComponent } from "@utils/react";
|
import { findByProps } from "@webpack";
|
||||||
import { filters, findBulk } from "@webpack";
|
|
||||||
import { Alerts, Parser, Timestamp, useState } from "@webpack/common";
|
import { Alerts, Parser, Timestamp, useState } from "@webpack/common";
|
||||||
|
|
||||||
import { Auth, getToken } from "../auth";
|
import { Auth, getToken } from "../auth";
|
||||||
|
@ -31,161 +30,150 @@ import { openBlockModal } from "./BlockedUserModal";
|
||||||
import { BlockButton, DeleteButton, ReportButton } from "./MessageButton";
|
import { BlockButton, DeleteButton, ReportButton } from "./MessageButton";
|
||||||
import ReviewBadge from "./ReviewBadge";
|
import ReviewBadge from "./ReviewBadge";
|
||||||
|
|
||||||
export default LazyComponent(() => {
|
const { cozyMessage, message, groupStart, buttons, buttonsInner } = findByProps("cozyMessage");
|
||||||
// this is terrible, blame mantika
|
const { container, isHeader } = findByProps("container", "isHeader");
|
||||||
const p = filters.byProps;
|
const { wrapper, cozy, avatar, clickable, username } = findByProps("avatar", "zalgo");
|
||||||
const [
|
const buttonClasses = findByProps("button", "wrapper", "selected");
|
||||||
{ cozyMessage, buttons, message, buttonsInner, groupStart },
|
const botTag = findByProps("botTag", "botTagRegular");
|
||||||
{ container, isHeader },
|
|
||||||
{ avatar, clickable, username, wrapper, cozy },
|
|
||||||
buttonClasses,
|
|
||||||
botTag
|
|
||||||
] = findBulk(
|
|
||||||
p("cozyMessage"),
|
|
||||||
p("container", "isHeader"),
|
|
||||||
p("avatar", "zalgo"),
|
|
||||||
p("button", "wrapper", "selected"),
|
|
||||||
p("botTag", "botTagRegular")
|
|
||||||
);
|
|
||||||
|
|
||||||
const dateFormat = new Intl.DateTimeFormat();
|
const dateFormat = new Intl.DateTimeFormat();
|
||||||
|
|
||||||
return function ReviewComponent({ review, refetch, profileId }: { review: Review; refetch(): void; profileId: string; }) {
|
export default function ReviewComponent({ review, refetch, profileId }: { review: Review; refetch(): void; profileId: string; }) {
|
||||||
const [showAll, setShowAll] = useState(false);
|
const [showAll, setShowAll] = useState(false);
|
||||||
|
|
||||||
function openModal() {
|
function openModal() {
|
||||||
openUserProfile(review.sender.discordID);
|
openUserProfile(review.sender.discordID);
|
||||||
}
|
}
|
||||||
|
|
||||||
function delReview() {
|
function delReview() {
|
||||||
Alerts.show({
|
Alerts.show({
|
||||||
title: "Are you sure?",
|
title: "Are you sure?",
|
||||||
body: "Do you really want to delete this review?",
|
body: "Do you really want to delete this review?",
|
||||||
confirmText: "Delete",
|
confirmText: "Delete",
|
||||||
cancelText: "Nevermind",
|
cancelText: "Nevermind",
|
||||||
onConfirm: async () => {
|
onConfirm: async () => {
|
||||||
if (!(await getToken())) {
|
if (!(await getToken())) {
|
||||||
return showToast("You must be logged in to delete reviews.");
|
return showToast("You must be logged in to delete reviews.");
|
||||||
} else {
|
} else {
|
||||||
deleteReview(review.id).then(res => {
|
deleteReview(review.id).then(res => {
|
||||||
if (res) {
|
if (res) {
|
||||||
refetch();
|
refetch();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function reportRev() {
|
function reportRev() {
|
||||||
Alerts.show({
|
Alerts.show({
|
||||||
title: "Are you sure?",
|
title: "Are you sure?",
|
||||||
body: "Do you really you want to report this review?",
|
body: "Do you really you want to report this review?",
|
||||||
confirmText: "Report",
|
confirmText: "Report",
|
||||||
cancelText: "Nevermind",
|
cancelText: "Nevermind",
|
||||||
// confirmColor: "red", this just adds a class name and breaks the submit button guh
|
// confirmColor: "red", this just adds a class name and breaks the submit button guh
|
||||||
onConfirm: async () => {
|
onConfirm: async () => {
|
||||||
if (!(await getToken())) {
|
if (!(await getToken())) {
|
||||||
return showToast("You must be logged in to report reviews.");
|
return showToast("You must be logged in to report reviews.");
|
||||||
} else {
|
} else {
|
||||||
reportReview(review.id);
|
reportReview(review.id);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const isAuthorBlocked = Auth?.user?.blockedUsers?.includes(review.sender.discordID) ?? false;
|
const isAuthorBlocked = Auth?.user?.blockedUsers?.includes(review.sender.discordID) ?? false;
|
||||||
|
|
||||||
function blockReviewSender() {
|
function blockReviewSender() {
|
||||||
if (isAuthorBlocked)
|
if (isAuthorBlocked)
|
||||||
return unblockUser(review.sender.discordID);
|
return unblockUser(review.sender.discordID);
|
||||||
|
|
||||||
Alerts.show({
|
Alerts.show({
|
||||||
title: "Are you sure?",
|
title: "Are you sure?",
|
||||||
body: "Do you really you want to block this user? They will be unable to leave further reviews on your profile. You can unblock users in the plugin settings.",
|
body: "Do you really you want to block this user? They will be unable to leave further reviews on your profile. You can unblock users in the plugin settings.",
|
||||||
confirmText: "Block",
|
confirmText: "Block",
|
||||||
cancelText: "Nevermind",
|
cancelText: "Nevermind",
|
||||||
// confirmColor: "red", this just adds a class name and breaks the submit button guh
|
// confirmColor: "red", this just adds a class name and breaks the submit button guh
|
||||||
onConfirm: async () => {
|
onConfirm: async () => {
|
||||||
if (!(await getToken())) {
|
if (!(await getToken())) {
|
||||||
return showToast("You must be logged in to block users.");
|
return showToast("You must be logged in to block users.");
|
||||||
} else {
|
} else {
|
||||||
blockUser(review.sender.discordID);
|
blockUser(review.sender.discordID);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classes(cl("review"), cozyMessage, wrapper, message, groupStart, cozy)} style={
|
<div className={classes(cl("review"), cozyMessage, wrapper, message, groupStart, cozy)} style={
|
||||||
{
|
{
|
||||||
marginLeft: "0px",
|
marginLeft: "0px",
|
||||||
paddingLeft: "52px", // wth is this
|
paddingLeft: "52px", // wth is this
|
||||||
// nobody knows anymore
|
// nobody knows anymore
|
||||||
}
|
}
|
||||||
}>
|
}>
|
||||||
|
|
||||||
<img
|
<img
|
||||||
className={classes(avatar, clickable)}
|
className={classes(avatar, clickable)}
|
||||||
onClick={openModal}
|
onClick={openModal}
|
||||||
src={review.sender.profilePhoto || "/assets/1f0bfc0865d324c2587920a7d80c609b.png?size=128"}
|
src={review.sender.profilePhoto || "/assets/1f0bfc0865d324c2587920a7d80c609b.png?size=128"}
|
||||||
style={{ left: "0px", zIndex: 0 }}
|
style={{ left: "0px", zIndex: 0 }}
|
||||||
/>
|
/>
|
||||||
<div style={{ display: "inline-flex", justifyContent: "center", alignItems: "center" }}>
|
<div style={{ display: "inline-flex", justifyContent: "center", alignItems: "center" }}>
|
||||||
|
<span
|
||||||
|
className={classes(clickable, username)}
|
||||||
|
style={{ color: "var(--channels-default)", fontSize: "14px" }}
|
||||||
|
onClick={() => openModal()}
|
||||||
|
>
|
||||||
|
{review.sender.username}
|
||||||
|
</span>
|
||||||
|
|
||||||
|
{review.type === ReviewType.System && (
|
||||||
<span
|
<span
|
||||||
className={classes(clickable, username)}
|
className={classes(botTag.botTagVerified, botTag.botTagRegular, botTag.botTag, botTag.px, botTag.rem)}
|
||||||
style={{ color: "var(--channels-default)", fontSize: "14px" }}
|
style={{ marginLeft: "4px" }}>
|
||||||
onClick={() => openModal()}
|
<span className={botTag.botText}>
|
||||||
>
|
System
|
||||||
{review.sender.username}
|
|
||||||
</span>
|
|
||||||
|
|
||||||
{review.type === ReviewType.System && (
|
|
||||||
<span
|
|
||||||
className={classes(botTag.botTagVerified, botTag.botTagRegular, botTag.botTag, botTag.px, botTag.rem)}
|
|
||||||
style={{ marginLeft: "4px" }}>
|
|
||||||
<span className={botTag.botText}>
|
|
||||||
System
|
|
||||||
</span>
|
|
||||||
</span>
|
</span>
|
||||||
)}
|
</span>
|
||||||
</div>
|
|
||||||
{isAuthorBlocked && (
|
|
||||||
<ReviewBadge
|
|
||||||
name="You have blocked this user"
|
|
||||||
description="You have blocked this user"
|
|
||||||
icon="/assets/aaee57e0090991557b66.svg"
|
|
||||||
type={0}
|
|
||||||
onClick={() => openBlockModal()}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
{review.sender.badges.map(badge => <ReviewBadge {...badge} />)}
|
|
||||||
|
|
||||||
{
|
|
||||||
!settings.store.hideTimestamps && review.type !== ReviewType.System && (
|
|
||||||
<Timestamp timestamp={new Date(review.timestamp * 1000)} >
|
|
||||||
{dateFormat.format(review.timestamp * 1000)}
|
|
||||||
</Timestamp>)
|
|
||||||
}
|
|
||||||
|
|
||||||
<div className={cl("review-comment")}>
|
|
||||||
{(review.comment.length > 200 && !showAll)
|
|
||||||
? [Parser.parseGuildEventDescription(review.comment.substring(0, 200)), "...", <br />, (<a onClick={() => setShowAll(true)}>Read more</a>)]
|
|
||||||
: Parser.parseGuildEventDescription(review.comment)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{review.id !== 0 && (
|
|
||||||
<div className={classes(container, isHeader, buttons)} style={{
|
|
||||||
padding: "0px",
|
|
||||||
}}>
|
|
||||||
<div className={classes(buttonClasses.wrapper, buttonsInner)} >
|
|
||||||
{canReportReview(review) && <ReportButton onClick={reportRev} />}
|
|
||||||
{canBlockReviewAuthor(profileId, review) && <BlockButton isBlocked={isAuthorBlocked} onClick={blockReviewSender} />}
|
|
||||||
{canDeleteReview(profileId, review) && <DeleteButton onClick={delReview} />}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
{isAuthorBlocked && (
|
||||||
};
|
<ReviewBadge
|
||||||
});
|
name="You have blocked this user"
|
||||||
|
description="You have blocked this user"
|
||||||
|
icon="/assets/aaee57e0090991557b66.svg"
|
||||||
|
type={0}
|
||||||
|
onClick={() => openBlockModal()}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{review.sender.badges.map(badge => <ReviewBadge {...badge} />)}
|
||||||
|
|
||||||
|
{
|
||||||
|
!settings.store.hideTimestamps && review.type !== ReviewType.System && (
|
||||||
|
<Timestamp timestamp={new Date(review.timestamp * 1000)} >
|
||||||
|
{dateFormat.format(review.timestamp * 1000)}
|
||||||
|
</Timestamp>)
|
||||||
|
}
|
||||||
|
|
||||||
|
<div className={cl("review-comment")}>
|
||||||
|
{(review.comment.length > 200 && !showAll)
|
||||||
|
? [Parser.parseGuildEventDescription(review.comment.substring(0, 200)), "...", <br />, (<a onClick={() => setShowAll(true)}>Read more</a>)]
|
||||||
|
: Parser.parseGuildEventDescription(review.comment)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{review.id !== 0 && (
|
||||||
|
<div className={classes(container, isHeader, buttons)} style={{
|
||||||
|
padding: "0px",
|
||||||
|
}}>
|
||||||
|
<div className={classes(buttonClasses.wrapper, buttonsInner)} >
|
||||||
|
{canReportReview(review) && <ReportButton onClick={reportRev} />}
|
||||||
|
{canBlockReviewAuthor(profileId, review) && <BlockButton isBlocked={isAuthorBlocked} onClick={blockReviewSender} />}
|
||||||
|
{canDeleteReview(profileId, review) && <DeleteButton onClick={delReview} />}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { useAwaiter, useForceUpdater } from "@utils/react";
|
import { useAwaiter, useForceUpdater } from "@utils/react";
|
||||||
import { findByPropsLazy, findComponentByCodeLazy } from "@webpack";
|
import { findByProps, findComponentByCode } from "@webpack";
|
||||||
import { Forms, React, RelationshipStore, useRef, UserStore } from "@webpack/common";
|
import { Forms, React, RelationshipStore, useRef, UserStore } from "@webpack/common";
|
||||||
|
|
||||||
import { Auth, authorize } from "../auth";
|
import { Auth, authorize } from "../auth";
|
||||||
|
@ -28,11 +28,11 @@ import { cl, showToast } from "../utils";
|
||||||
import ReviewComponent from "./ReviewComponent";
|
import ReviewComponent from "./ReviewComponent";
|
||||||
|
|
||||||
|
|
||||||
const { Editor, Transforms } = findByPropsLazy("Editor", "Transforms");
|
const { Editor, Transforms } = findByProps("Editor", "Transforms");
|
||||||
const { ChatInputTypes } = findByPropsLazy("ChatInputTypes");
|
const { ChatInputTypes } = findByProps("ChatInputTypes");
|
||||||
|
|
||||||
const InputComponent = findComponentByCodeLazy("default.CHANNEL_TEXT_AREA", "input");
|
const InputComponent = findComponentByCode("default.CHANNEL_TEXT_AREA", "input");
|
||||||
const { createChannelRecordFromServer } = findByPropsLazy("createChannelRecordFromServer");
|
const { createChannelRecordFromServer } = findByProps("createChannelRecordFromServer");
|
||||||
|
|
||||||
interface UserProps {
|
interface UserProps {
|
||||||
discordId: string;
|
discordId: string;
|
||||||
|
|
|
@ -20,12 +20,12 @@ import { findGroupChildrenByChildId, NavContextMenuPatchCallback } from "@api/Co
|
||||||
import { ReplyIcon } from "@components/Icons";
|
import { ReplyIcon } from "@components/Icons";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
import { findByPropsLazy } from "@webpack";
|
import { findByProps } from "@webpack";
|
||||||
import { ChannelStore, i18n, Menu, PermissionsBits, PermissionStore, SelectedChannelStore } from "@webpack/common";
|
import { ChannelStore, i18n, Menu, PermissionsBits, PermissionStore, SelectedChannelStore } from "@webpack/common";
|
||||||
import { Message } from "discord-types/general";
|
import { Message } from "discord-types/general";
|
||||||
|
|
||||||
|
|
||||||
const messageUtils = findByPropsLazy("replyToMessage");
|
const messageUtils = findByProps("replyToMessage");
|
||||||
|
|
||||||
const messageContextMenuPatch: NavContextMenuPatchCallback = (children, { message }: { message: Message; }) => {
|
const messageContextMenuPatch: NavContextMenuPatchCallback = (children, { message }: { message: Message; }) => {
|
||||||
// make sure the message is in the selected channel
|
// make sure the message is in the selected channel
|
||||||
|
|
|
@ -11,12 +11,12 @@ import { openImageModal, openUserProfile } from "@utils/discord";
|
||||||
import { classes } from "@utils/misc";
|
import { classes } from "@utils/misc";
|
||||||
import { ModalRoot, ModalSize, openModal } from "@utils/modal";
|
import { ModalRoot, ModalSize, openModal } from "@utils/modal";
|
||||||
import { useAwaiter } from "@utils/react";
|
import { useAwaiter } from "@utils/react";
|
||||||
import { findByPropsLazy, findExportedComponentLazy } from "@webpack";
|
import { findByProps,findExportedComponent } from "@webpack";
|
||||||
import { FluxDispatcher, Forms, GuildChannelStore, GuildMemberStore, GuildStore, IconUtils, Parser, PresenceStore, RelationshipStore, ScrollerThin, SnowflakeUtils, TabBar, Timestamp, useEffect, UserStore, UserUtils, useState, useStateFromStores } from "@webpack/common";
|
import { FluxDispatcher, Forms, GuildChannelStore, GuildMemberStore, GuildStore, IconUtils, Parser, PresenceStore, RelationshipStore, ScrollerThin, SnowflakeUtils, TabBar, Timestamp, useEffect, UserStore, UserUtils, useState, useStateFromStores } from "@webpack/common";
|
||||||
import { Guild, User } from "discord-types/general";
|
import { Guild, User } from "discord-types/general";
|
||||||
|
|
||||||
const IconClasses = findByPropsLazy("icon", "acronym", "childWrapper");
|
const IconClasses = findByProps("icon", "acronym", "childWrapper");
|
||||||
const FriendRow = findExportedComponentLazy("FriendRow");
|
const FriendRow = findExportedComponent("FriendRow");
|
||||||
|
|
||||||
const cl = classNameFactory("vc-gp-");
|
const cl = classNameFactory("vc-gp-");
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ import React from "react";
|
||||||
const handleClick = async () =>
|
const handleClick = async () =>
|
||||||
console.log((await import("@webpack/common")).Clipboard.copy("\u200b"));
|
console.log((await import("@webpack/common")).Clipboard.copy("\u200b"));
|
||||||
|
|
||||||
export const Example: React.FC<{
|
export const Example: React.ComponentType<{
|
||||||
real: boolean,
|
real: boolean,
|
||||||
shigged?: number,
|
shigged?: number,
|
||||||
}> = ({ real, shigged }) => <>
|
}> = ({ real, shigged }) => <>
|
||||||
|
|
|
@ -16,11 +16,11 @@
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { findComponentByCodeLazy, findLazy } from "@webpack";
|
import { find, findComponentByCode } from "@webpack";
|
||||||
import { i18n, useToken } from "@webpack/common";
|
import { i18n, useToken } from "@webpack/common";
|
||||||
|
|
||||||
const ColorMap = findLazy(m => m.colors?.INTERACTIVE_MUTED?.css);
|
const ColorMap = find(m => m.colors?.INTERACTIVE_MUTED?.css);
|
||||||
const VerifiedIconComponent = findComponentByCodeLazy(".CONNECTIONS_ROLE_OFFICIAL_ICON_TOOLTIP");
|
const VerifiedIconComponent = findComponentByCode(".CONNECTIONS_ROLE_OFFICIAL_ICON_TOOLTIP");
|
||||||
|
|
||||||
export function VerifiedIcon() {
|
export function VerifiedIcon() {
|
||||||
const color = useToken(ColorMap.colors.INTERACTIVE_MUTED).hex();
|
const color = useToken(ColorMap.colors.INTERACTIVE_MUTED).hex();
|
||||||
|
|
|
@ -25,17 +25,17 @@ import { CopyIcon, LinkIcon } from "@components/Icons";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import { copyWithToast } from "@utils/misc";
|
import { copyWithToast } from "@utils/misc";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { findByCodeLazy, findByPropsLazy, findComponentByCodeLazy, findStoreLazy } from "@webpack";
|
import { findByCode, findByProps, findComponentByCode, findStore } from "@webpack";
|
||||||
import { Text, Tooltip, UserProfileStore } from "@webpack/common";
|
import { Text, Tooltip, UserProfileStore } from "@webpack/common";
|
||||||
import { User } from "discord-types/general";
|
import { User } from "discord-types/general";
|
||||||
|
|
||||||
import { VerifiedIcon } from "./VerifiedIcon";
|
import { VerifiedIcon } from "./VerifiedIcon";
|
||||||
|
|
||||||
const Section = findComponentByCodeLazy(".lastSection", "children:");
|
const Section = findComponentByCode(".lastSection", "children:");
|
||||||
const ThemeStore = findStoreLazy("ThemeStore");
|
const ThemeStore = findStore("ThemeStore");
|
||||||
const platformHooks: { useLegacyPlatformType(platform: string): string; } = findByPropsLazy("useLegacyPlatformType");
|
const platformHooks: { useLegacyPlatformType(platform: string): string; } = findByProps("useLegacyPlatformType");
|
||||||
const platforms: { get(type: string): ConnectionPlatform; } = findByPropsLazy("isSupported", "getByUrl");
|
const platforms: { get(type: string): ConnectionPlatform; } = findByProps("isSupported", "getByUrl");
|
||||||
const getProfileThemeProps = findByCodeLazy(".getPreviewThemeColors", "primaryColor:");
|
const getProfileThemeProps = findByCode(".getPreviewThemeColors", "primaryColor:");
|
||||||
|
|
||||||
const enum Spacing {
|
const enum Spacing {
|
||||||
COMPACT,
|
COMPACT,
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
import { Settings } from "@api/Settings";
|
import { Settings } from "@api/Settings";
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { formatDuration } from "@utils/text";
|
import { formatDuration } from "@utils/text";
|
||||||
import { findByPropsLazy, findComponentByCodeLazy, findComponentLazy } from "@webpack";
|
import { findByProps,findComponent, findComponentByCode } from "@webpack";
|
||||||
import { EmojiStore, FluxDispatcher, GuildMemberStore, GuildStore, Parser, PermissionsBits, PermissionStore, SnowflakeUtils, Text, Timestamp, Tooltip, useEffect, useState } from "@webpack/common";
|
import { EmojiStore, FluxDispatcher, GuildMemberStore, GuildStore, Parser, PermissionsBits, PermissionStore, SnowflakeUtils, Text, Timestamp, Tooltip, useEffect, useState } from "@webpack/common";
|
||||||
import type { Channel } from "discord-types/general";
|
import type { Channel } from "discord-types/general";
|
||||||
|
|
||||||
|
@ -78,10 +78,10 @@ const enum ChannelFlags {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const ChatScrollClasses = findByPropsLazy("auto", "content", "scrollerBase");
|
const ChatScrollClasses = findByProps("auto", "content", "scrollerBase");
|
||||||
const ChatClasses = findByPropsLazy("chat", "content", "noChat", "chatContent");
|
const ChatClasses = findByProps("chat", "content", "noChat", "chatContent");
|
||||||
const ChannelBeginHeader = findComponentByCodeLazy(".Messages.ROLE_REQUIRED_SINGLE_USER_MESSAGE");
|
const ChannelBeginHeader = findComponentByCode(".Messages.ROLE_REQUIRED_SINGLE_USER_MESSAGE");
|
||||||
const TagComponent = findComponentLazy(m => {
|
const TagComponent = findComponent(m => {
|
||||||
if (typeof m !== "function") return false;
|
if (typeof m !== "function") return false;
|
||||||
|
|
||||||
const code = Function.prototype.toString.call(m);
|
const code = Function.prototype.toString.call(m);
|
||||||
|
@ -89,8 +89,8 @@ const TagComponent = findComponentLazy(m => {
|
||||||
return code.includes(".Messages.FORUM_TAG_A11Y_FILTER_BY_TAG") && !code.includes("increasedActivityPill");
|
return code.includes(".Messages.FORUM_TAG_A11Y_FILTER_BY_TAG") && !code.includes("increasedActivityPill");
|
||||||
});
|
});
|
||||||
|
|
||||||
const EmojiParser = findByPropsLazy("convertSurrogateToName");
|
const EmojiParser = findByProps("convertSurrogateToName");
|
||||||
const EmojiUtils = findByPropsLazy("getURL", "getEmojiColors");
|
const EmojiUtils = findByProps("getURL", "getEmojiColors");
|
||||||
|
|
||||||
const ChannelTypesToChannelNames = {
|
const ChannelTypesToChannelNames = {
|
||||||
[ChannelTypes.GUILD_TEXT]: "text",
|
[ChannelTypes.GUILD_TEXT]: "text",
|
||||||
|
|
|
@ -23,13 +23,13 @@ import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import { canonicalizeMatch } from "@utils/patches";
|
import { canonicalizeMatch } from "@utils/patches";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { findByPropsLazy } from "@webpack";
|
import { findByProps } from "@webpack";
|
||||||
import { ChannelStore, PermissionsBits, PermissionStore, Tooltip } from "@webpack/common";
|
import { ChannelStore, PermissionsBits, PermissionStore, Tooltip } from "@webpack/common";
|
||||||
import type { Channel, Role } from "discord-types/general";
|
import type { Channel, Role } from "discord-types/general";
|
||||||
|
|
||||||
import HiddenChannelLockScreen from "./components/HiddenChannelLockScreen";
|
import HiddenChannelLockScreen from "./components/HiddenChannelLockScreen";
|
||||||
|
|
||||||
const ChannelListClasses = findByPropsLazy("modeMuted", "modeSelected", "unread", "icon");
|
const ChannelListClasses = findByProps("modeMuted", "modeSelected", "unread", "icon");
|
||||||
|
|
||||||
const enum ShowMode {
|
const enum ShowMode {
|
||||||
LockIcon,
|
LockIcon,
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Settings } from "@api/Settings";
|
import { Settings } from "@api/Settings";
|
||||||
import { findByProps, proxyLazyWebpack } from "@webpack";
|
import { findByProps, webpackDependantLazy } from "@webpack";
|
||||||
import { Flux, FluxDispatcher } from "@webpack/common";
|
import { Flux, FluxDispatcher } from "@webpack/common";
|
||||||
|
|
||||||
export interface Track {
|
export interface Track {
|
||||||
|
@ -64,14 +64,14 @@ interface Device {
|
||||||
|
|
||||||
type Repeat = "off" | "track" | "context";
|
type Repeat = "off" | "track" | "context";
|
||||||
|
|
||||||
|
const SpotifySocket = findByProps("getActiveSocketAndDevice");
|
||||||
|
const SpotifyUtils = findByProps("SpotifyAPI");
|
||||||
|
|
||||||
// Don't wanna run before Flux and Dispatcher are ready!
|
// Don't wanna run before Flux and Dispatcher are ready!
|
||||||
export const SpotifyStore = proxyLazyWebpack(() => {
|
export const SpotifyStore = webpackDependantLazy(() => {
|
||||||
// For some reason ts hates extends Flux.Store
|
// For some reason ts hates extends Flux.Store
|
||||||
const { Store } = Flux;
|
const { Store } = Flux;
|
||||||
|
|
||||||
const SpotifySocket = findByProps("getActiveSocketAndDevice");
|
|
||||||
const SpotifyUtils = findByProps("SpotifyAPI");
|
|
||||||
|
|
||||||
const API_BASE = "https://api.spotify.com/v1/me/player";
|
const API_BASE = "https://api.spotify.com/v1/me/player";
|
||||||
|
|
||||||
class SpotifyStore extends Store {
|
class SpotifyStore extends Store {
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
import { ApplicationCommandInputType, sendBotMessage } from "@api/Commands";
|
import { ApplicationCommandInputType, sendBotMessage } from "@api/Commands";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
import { findByPropsLazy } from "@webpack";
|
import { findByProps } from "@webpack";
|
||||||
import { FluxDispatcher, MessageActions } from "@webpack/common";
|
import { FluxDispatcher, MessageActions } from "@webpack/common";
|
||||||
|
|
||||||
interface Album {
|
interface Album {
|
||||||
|
@ -52,8 +52,8 @@ interface Track {
|
||||||
name: string;
|
name: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Spotify = findByPropsLazy("getPlayerState");
|
const Spotify = findByProps("getPlayerState");
|
||||||
const PendingReplyStore = findByPropsLazy("getPendingReply");
|
const PendingReplyStore = findByProps("getPendingReply");
|
||||||
|
|
||||||
function sendMessage(channelId, message) {
|
function sendMessage(channelId, message) {
|
||||||
message = {
|
message = {
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { Flex } from "@components/Flex";
|
import { Flex } from "@components/Flex";
|
||||||
import { findByPropsLazy } from "@webpack";
|
import { findByProps } from "@webpack";
|
||||||
import { Forms, React } from "@webpack/common";
|
import { Forms, React } from "@webpack/common";
|
||||||
|
|
||||||
interface AppStartPerformance {
|
interface AppStartPerformance {
|
||||||
|
@ -45,7 +45,7 @@ interface Log {
|
||||||
delta?: number;
|
delta?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
const AppStartPerformance = findByPropsLazy("markWithDelta", "markAndLog", "markAt") as AppStartPerformance;
|
const AppStartPerformance = findByProps("markWithDelta", "markAndLog", "markAt") as AppStartPerformance;
|
||||||
|
|
||||||
interface TimerItemProps extends Log {
|
interface TimerItemProps extends Log {
|
||||||
instance: {
|
instance: {
|
||||||
|
|
|
@ -22,16 +22,16 @@ import { definePluginSettings, Settings } from "@api/Settings";
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { findComponentByCodeLazy, findExportedComponentLazy, findStoreLazy } from "@webpack";
|
import { findComponentByCode, findExportedComponent, findStore } from "@webpack";
|
||||||
import { ChannelStore, GuildMemberStore, i18n, RelationshipStore, SelectedChannelStore, Tooltip, UserStore, useStateFromStores } from "@webpack/common";
|
import { ChannelStore, GuildMemberStore, i18n, RelationshipStore, SelectedChannelStore, Tooltip, UserStore, useStateFromStores } from "@webpack/common";
|
||||||
|
|
||||||
import { buildSeveralUsers } from "../typingTweaks";
|
import { buildSeveralUsers } from "../typingTweaks";
|
||||||
|
|
||||||
const ThreeDots = findExportedComponentLazy("Dots", "AnimatedDots");
|
const ThreeDots = findExportedComponent("Dots", "AnimatedDots");
|
||||||
const UserSummaryItem = findComponentByCodeLazy("defaultRenderUser", "showDefaultAvatarsForNullUsers");
|
const UserSummaryItem = findComponentByCode("defaultRenderUser", "showDefaultAvatarsForNullUsers");
|
||||||
|
|
||||||
const TypingStore = findStoreLazy("TypingStore");
|
const TypingStore = findStore("TypingStore");
|
||||||
const UserGuildSettingsStore = findStoreLazy("UserGuildSettingsStore");
|
const UserGuildSettingsStore = findStore("UserGuildSettingsStore");
|
||||||
|
|
||||||
const enum IndicatorMode {
|
const enum IndicatorMode {
|
||||||
Dots = 1 << 0,
|
Dots = 1 << 0,
|
||||||
|
|
|
@ -18,12 +18,12 @@
|
||||||
|
|
||||||
import "./VoiceChannelSection.css";
|
import "./VoiceChannelSection.css";
|
||||||
|
|
||||||
import { findByCodeLazy, findByPropsLazy } from "@webpack";
|
import { findByCode,findByProps } from "@webpack";
|
||||||
import { Button, Forms, PermissionStore, Toasts } from "@webpack/common";
|
import { Button, Forms, PermissionStore, Toasts } from "@webpack/common";
|
||||||
import { Channel } from "discord-types/general";
|
import { Channel } from "discord-types/general";
|
||||||
|
|
||||||
const ChannelActions = findByPropsLazy("selectChannel", "selectVoiceChannel");
|
const ChannelActions = findByProps("selectChannel", "selectVoiceChannel");
|
||||||
const UserPopoutSection = findByCodeLazy(".lastSection", "children:");
|
const UserPopoutSection = findByCode(".lastSection", "children:");
|
||||||
|
|
||||||
const CONNECT = 1n << 20n;
|
const CONNECT = 1n << 20n;
|
||||||
|
|
||||||
|
|
|
@ -20,13 +20,13 @@ import { definePluginSettings } from "@api/Settings";
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { findStoreLazy } from "@webpack";
|
import { findStore } from "@webpack";
|
||||||
import { ChannelStore, GuildStore, UserStore } from "@webpack/common";
|
import { ChannelStore, GuildStore, UserStore } from "@webpack/common";
|
||||||
import { User } from "discord-types/general";
|
import { User } from "discord-types/general";
|
||||||
|
|
||||||
import { VoiceChannelSection } from "./components/VoiceChannelSection";
|
import { VoiceChannelSection } from "./components/VoiceChannelSection";
|
||||||
|
|
||||||
const VoiceStateStore = findStoreLazy("VoiceStateStore");
|
const VoiceStateStore = findStore("VoiceStateStore");
|
||||||
|
|
||||||
const settings = definePluginSettings({
|
const settings = definePluginSettings({
|
||||||
showInUserProfileModal: {
|
showInUserProfileModal: {
|
||||||
|
|
|
@ -23,7 +23,7 @@ import { Logger } from "@utils/Logger";
|
||||||
import { Margins } from "@utils/margins";
|
import { Margins } from "@utils/margins";
|
||||||
import { wordsToTitle } from "@utils/text";
|
import { wordsToTitle } from "@utils/text";
|
||||||
import definePlugin, { OptionType, PluginOptionsItem } from "@utils/types";
|
import definePlugin, { OptionType, PluginOptionsItem } from "@utils/types";
|
||||||
import { findByPropsLazy } from "@webpack";
|
import { findByProps } from "@webpack";
|
||||||
import { Button, ChannelStore, Forms, GuildMemberStore, SelectedChannelStore, SelectedGuildStore, useMemo, UserStore } from "@webpack/common";
|
import { Button, ChannelStore, Forms, GuildMemberStore, SelectedChannelStore, SelectedGuildStore, useMemo, UserStore } from "@webpack/common";
|
||||||
|
|
||||||
interface VoiceState {
|
interface VoiceState {
|
||||||
|
@ -36,7 +36,7 @@ interface VoiceState {
|
||||||
selfMute: boolean;
|
selfMute: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const VoiceStateStore = findByPropsLazy("getVoiceStatesForChannel", "getCurrentClientVoiceChannelId");
|
const VoiceStateStore = findByProps("getVoiceStatesForChannel", "getCurrentClientVoiceChannelId");
|
||||||
|
|
||||||
// Mute/Deaf for other people than you is commented out, because otherwise someone can spam it and it will be annoying
|
// Mute/Deaf for other people than you is commented out, because otherwise someone can spam it and it will be annoying
|
||||||
// Filtering out events is not as simple as just dropping duplicates, as otherwise mute, unmute, mute would
|
// Filtering out events is not as simple as just dropping duplicates, as otherwise mute, unmute, mute would
|
||||||
|
|
|
@ -23,11 +23,11 @@ import { Settings, useSettings } from "@api/Settings";
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
import { findExportedComponentLazy } from "@webpack";
|
import { findExportedComponent } from "@webpack";
|
||||||
import { Menu, Popout, useState } from "@webpack/common";
|
import { Menu, Popout, useState } from "@webpack/common";
|
||||||
import type { ReactNode } from "react";
|
import type { ReactNode } from "react";
|
||||||
|
|
||||||
const HeaderBarIcon = findExportedComponentLazy("Icon", "Divider");
|
const HeaderBarIcon = findExportedComponent("Icon", "Divider");
|
||||||
|
|
||||||
function VencordPopout(onClose: () => void) {
|
function VencordPopout(onClose: () => void) {
|
||||||
const { useQuickCss } = useSettings(["useQuickCss"]);
|
const { useQuickCss } = useSettings(["useQuickCss"]);
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { useTimer } from "@utils/react";
|
import { useTimer } from "@utils/react";
|
||||||
import { findComponentByCodeLazy } from "@webpack";
|
import { findComponentByCode } from "@webpack";
|
||||||
|
|
||||||
import { cl } from "./utils";
|
import { cl } from "./utils";
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ interface VoiceMessageProps {
|
||||||
src: string;
|
src: string;
|
||||||
waveform: string;
|
waveform: string;
|
||||||
}
|
}
|
||||||
const VoiceMessage = findComponentByCodeLazy<VoiceMessageProps>("waveform:", "onVolumeChange");
|
const VoiceMessage = findComponentByCode<VoiceMessageProps>("waveform:", "onVolumeChange");
|
||||||
|
|
||||||
export type VoicePreviewOptions = {
|
export type VoicePreviewOptions = {
|
||||||
src?: string;
|
src?: string;
|
||||||
|
|
|
@ -27,7 +27,7 @@ import { ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, openModa
|
||||||
import { useAwaiter } from "@utils/react";
|
import { useAwaiter } from "@utils/react";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
import { chooseFile } from "@utils/web";
|
import { chooseFile } from "@utils/web";
|
||||||
import { findByPropsLazy, findStoreLazy } from "@webpack";
|
import { findByProps, findStore } from "@webpack";
|
||||||
import { Button, Card, FluxDispatcher, Forms, lodash, Menu, MessageActions, PermissionsBits, PermissionStore, RestAPI, SelectedChannelStore, showToast, SnowflakeUtils, Toasts, useEffect, useState } from "@webpack/common";
|
import { Button, Card, FluxDispatcher, Forms, lodash, Menu, MessageActions, PermissionsBits, PermissionStore, RestAPI, SelectedChannelStore, showToast, SnowflakeUtils, Toasts, useEffect, useState } from "@webpack/common";
|
||||||
import { ComponentType } from "react";
|
import { ComponentType } from "react";
|
||||||
|
|
||||||
|
@ -37,9 +37,9 @@ import { cl } from "./utils";
|
||||||
import { VoicePreview } from "./VoicePreview";
|
import { VoicePreview } from "./VoicePreview";
|
||||||
import { VoiceRecorderWeb } from "./WebRecorder";
|
import { VoiceRecorderWeb } from "./WebRecorder";
|
||||||
|
|
||||||
const CloudUtils = findByPropsLazy("CloudUpload");
|
const CloudUtils = findByProps("CloudUpload");
|
||||||
const PendingReplyStore = findStoreLazy("PendingReplyStore");
|
const PendingReplyStore = findStore("PendingReplyStore");
|
||||||
const OptionClasses = findByPropsLazy("optionName", "optionIcon", "optionLabel");
|
const OptionClasses = findByProps("optionName", "optionIcon", "optionLabel");
|
||||||
|
|
||||||
export type VoiceRecorder = ComponentType<{
|
export type VoiceRecorder = ComponentType<{
|
||||||
setAudioBlob(blob: Blob): void;
|
setAudioBlob(blob: Blob): void;
|
||||||
|
|
|
@ -20,10 +20,10 @@ import { definePluginSettings } from "@api/Settings";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { saveFile } from "@utils/web";
|
import { saveFile } from "@utils/web";
|
||||||
import { findByPropsLazy } from "@webpack";
|
import { findByProps } from "@webpack";
|
||||||
import { Clipboard, ComponentDispatch } from "@webpack/common";
|
import { Clipboard, ComponentDispatch } from "@webpack/common";
|
||||||
|
|
||||||
const ctxMenuCallbacks = findByPropsLazy("contextMenuCallbackNative");
|
const ctxMenuCallbacks = findByProps("contextMenuCallbackNative");
|
||||||
|
|
||||||
async function fetchImage(url: string) {
|
async function fetchImage(url: string) {
|
||||||
const res = await fetch(url);
|
const res = await fetch(url);
|
||||||
|
|
|
@ -18,10 +18,10 @@
|
||||||
|
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
import { findByPropsLazy } from "@webpack";
|
import { findByProps } from "@webpack";
|
||||||
import { ComponentDispatch, FluxDispatcher, NavigationRouter, SelectedGuildStore, SettingsRouter } from "@webpack/common";
|
import { ComponentDispatch, FluxDispatcher, NavigationRouter, SelectedGuildStore, SettingsRouter } from "@webpack/common";
|
||||||
|
|
||||||
const KeyBinds = findByPropsLazy("JUMP_TO_GUILD", "SERVER_NEXT");
|
const KeyBinds = findByProps("JUMP_TO_GUILD", "SERVER_NEXT");
|
||||||
|
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "WebKeybinds",
|
name: "WebKeybinds",
|
||||||
|
|
|
@ -22,14 +22,15 @@ import { sleep } from "@utils/misc";
|
||||||
import { Queue } from "@utils/Queue";
|
import { Queue } from "@utils/Queue";
|
||||||
import { useForceUpdater } from "@utils/react";
|
import { useForceUpdater } from "@utils/react";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
import { findByPropsLazy, findComponentByCodeLazy } from "@webpack";
|
import { findByProps, findComponentByCode } from "@webpack";
|
||||||
import { ChannelStore, FluxDispatcher, React, RestAPI, Tooltip } from "@webpack/common";
|
import { ChannelStore, FluxDispatcher, React, RestAPI, Tooltip } from "@webpack/common";
|
||||||
import { CustomEmoji } from "@webpack/types";
|
import { CustomEmoji } from "@webpack/types";
|
||||||
import { Message, ReactionEmoji, User } from "discord-types/general";
|
import { Message, ReactionEmoji, User } from "discord-types/general";
|
||||||
|
|
||||||
const UserSummaryItem = findComponentByCodeLazy("defaultRenderUser", "showDefaultAvatarsForNullUsers");
|
const UserSummaryItem = findComponentByCode("defaultRenderUser", "showDefaultAvatarsForNullUsers");
|
||||||
const AvatarStyles = findByPropsLazy("moreUsers", "emptyUser", "avatarContainer", "clickableAvatar");
|
const AvatarStyles = findByProps("moreUsers", "emptyUser", "avatarContainer", "clickableAvatar");
|
||||||
let Scroll: any = null;
|
let Scroll: any = null;
|
||||||
|
|
||||||
const queue = new Queue();
|
const queue = new Queue();
|
||||||
let reactions: Record<string, ReactionCacheEntry>;
|
let reactions: Record<string, ReactionCacheEntry>;
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ import { makeRange } from "@components/PluginSettings/components";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import { Logger } from "@utils/Logger";
|
import { Logger } from "@utils/Logger";
|
||||||
import definePlugin, { OptionType, PluginNative } from "@utils/types";
|
import definePlugin, { OptionType, PluginNative } from "@utils/types";
|
||||||
import { findByPropsLazy } from "@webpack";
|
import { findByProps } from "@webpack";
|
||||||
import { ChannelStore, GuildStore, UserStore } from "@webpack/common";
|
import { ChannelStore, GuildStore, UserStore } from "@webpack/common";
|
||||||
import type { Channel, Embed, GuildMember, MessageAttachment, User } from "discord-types/general";
|
import type { Channel, Embed, GuildMember, MessageAttachment, User } from "discord-types/general";
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ interface Call {
|
||||||
ringing: string[];
|
ringing: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
const MuteStore = findByPropsLazy("isSuppressEveryoneEnabled");
|
const MuteStore = findByProps("isSuppressEveryoneEnabled");
|
||||||
const XSLog = new Logger("XSOverlay");
|
const XSLog = new Logger("XSOverlay");
|
||||||
|
|
||||||
const settings = definePluginSettings({
|
const settings = definePluginSettings({
|
||||||
|
|
|
@ -20,7 +20,7 @@ import { MessageObject } from "@api/MessageEvents";
|
||||||
import { ChannelStore, ComponentDispatch, FluxDispatcher, GuildStore, InviteActions, MaskedLink, MessageActions, ModalImageClasses, PrivateChannelsStore, RestAPI, SelectedChannelStore, SelectedGuildStore, UserProfileActions, UserProfileStore, UserSettingsActionCreators, UserUtils } from "@webpack/common";
|
import { ChannelStore, ComponentDispatch, FluxDispatcher, GuildStore, InviteActions, MaskedLink, MessageActions, ModalImageClasses, PrivateChannelsStore, RestAPI, SelectedChannelStore, SelectedGuildStore, UserProfileActions, UserProfileStore, UserSettingsActionCreators, UserUtils } from "@webpack/common";
|
||||||
import { Guild, Message, User } from "discord-types/general";
|
import { Guild, Message, User } from "discord-types/general";
|
||||||
|
|
||||||
import { ImageModal, ModalRoot, ModalSize, openModal } from "./modal";
|
import { ImageModal, ImageModalProps, ModalRoot, ModalSize, openModal } from "./modal";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Open the invite modal
|
* Open the invite modal
|
||||||
|
@ -108,7 +108,7 @@ export function sendMessage(
|
||||||
return MessageActions.sendMessage(channelId, messageData, waitForChannelReady, extra);
|
return MessageActions.sendMessage(channelId, messageData, waitForChannelReady, extra);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function openImageModal(url: string, props?: Partial<React.ComponentProps<ImageModal>>): string {
|
export function openImageModal(url: string, props?: Partial<ImageModalProps>): string {
|
||||||
return openModal(modalProps => (
|
return openModal(modalProps => (
|
||||||
<ModalRoot
|
<ModalRoot
|
||||||
{...modalProps}
|
{...modalProps}
|
||||||
|
|
|
@ -30,6 +30,7 @@ export * from "./misc";
|
||||||
export * from "./modal";
|
export * from "./modal";
|
||||||
export * from "./onlyOnce";
|
export * from "./onlyOnce";
|
||||||
export * from "./patches";
|
export * from "./patches";
|
||||||
|
export * from "./proxyInner";
|
||||||
export * from "./Queue";
|
export * from "./Queue";
|
||||||
export * from "./react";
|
export * from "./react";
|
||||||
export * from "./text";
|
export * from "./text";
|
||||||
|
|
|
@ -1,20 +1,8 @@
|
||||||
/*
|
/*
|
||||||
* Vencord, a modification for Discord's desktop app
|
* Vencord, a Discord client mod
|
||||||
* Copyright (c) 2022 Vendicated and contributors
|
* Copyright (c) 2024 Vendicated and contributors
|
||||||
*
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
* 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 <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
export function makeLazy<T>(factory: () => T, attempts = 5): () => T {
|
export function makeLazy<T>(factory: () => T, attempts = 5): () => T {
|
||||||
let tries = 0;
|
let tries = 0;
|
||||||
|
@ -22,8 +10,9 @@ export function makeLazy<T>(factory: () => T, attempts = 5): () => T {
|
||||||
return () => {
|
return () => {
|
||||||
if (!cache && attempts > tries++) {
|
if (!cache && attempts > tries++) {
|
||||||
cache = factory();
|
cache = factory();
|
||||||
if (!cache && attempts === tries)
|
if (!cache && attempts === tries) {
|
||||||
console.error("Lazy factory failed:", factory);
|
console.error(`Lazy factory failed:\n${factory}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return cache;
|
return cache;
|
||||||
};
|
};
|
||||||
|
@ -33,94 +22,81 @@ export function makeLazy<T>(factory: () => T, attempts = 5): () => T {
|
||||||
// will always return the function default for them.
|
// will always return the function default for them.
|
||||||
const unconfigurable = ["arguments", "caller", "prototype"];
|
const unconfigurable = ["arguments", "caller", "prototype"];
|
||||||
|
|
||||||
const handler: ProxyHandler<any> = {};
|
const handler: ProxyHandler<any> = {
|
||||||
|
...Object.fromEntries(Object.getOwnPropertyNames(Reflect).map(propName =>
|
||||||
|
[propName, (target: any, ...args: any[]) => Reflect[propName](target[proxyLazyGet](), ...args)]
|
||||||
|
)),
|
||||||
|
ownKeys: target => {
|
||||||
|
const keys = Reflect.ownKeys(target[proxyLazyGet]());
|
||||||
|
for (const key of unconfigurable) {
|
||||||
|
if (!keys.includes(key)) keys.push(key);
|
||||||
|
}
|
||||||
|
return keys;
|
||||||
|
},
|
||||||
|
getOwnPropertyDescriptor: (target, p) => {
|
||||||
|
if (typeof p === "string" && unconfigurable.includes(p))
|
||||||
|
return Reflect.getOwnPropertyDescriptor(target, p);
|
||||||
|
|
||||||
const kGET = Symbol.for("vencord.lazy.get");
|
const descriptor = Reflect.getOwnPropertyDescriptor(target[proxyLazyGet](), p);
|
||||||
const kCACHE = Symbol.for("vencord.lazy.cached");
|
if (descriptor) Object.defineProperty(target, p, descriptor);
|
||||||
|
return descriptor;
|
||||||
for (const method of [
|
|
||||||
"apply",
|
|
||||||
"construct",
|
|
||||||
"defineProperty",
|
|
||||||
"deleteProperty",
|
|
||||||
"getOwnPropertyDescriptor",
|
|
||||||
"getPrototypeOf",
|
|
||||||
"has",
|
|
||||||
"isExtensible",
|
|
||||||
"ownKeys",
|
|
||||||
"preventExtensions",
|
|
||||||
"set",
|
|
||||||
"setPrototypeOf"
|
|
||||||
]) {
|
|
||||||
handler[method] =
|
|
||||||
(target: any, ...args: any[]) => Reflect[method](target[kGET](), ...args);
|
|
||||||
}
|
|
||||||
|
|
||||||
handler.ownKeys = target => {
|
|
||||||
const v = target[kGET]();
|
|
||||||
const keys = Reflect.ownKeys(v);
|
|
||||||
for (const key of unconfigurable) {
|
|
||||||
if (!keys.includes(key)) keys.push(key);
|
|
||||||
}
|
}
|
||||||
return keys;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
handler.getOwnPropertyDescriptor = (target, p) => {
|
const proxyLazyGet = Symbol.for("vencord.lazy.get");
|
||||||
if (typeof p === "string" && unconfigurable.includes(p))
|
const proxyLazyCache = Symbol.for("vencord.lazy.cached");
|
||||||
return Reflect.getOwnPropertyDescriptor(target, p);
|
|
||||||
|
|
||||||
const descriptor = Reflect.getOwnPropertyDescriptor(target[kGET](), p);
|
|
||||||
|
|
||||||
if (descriptor) Object.defineProperty(target, p, descriptor);
|
|
||||||
return descriptor;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wraps the result of {@link makeLazy} in a Proxy you can consume as if it wasn't lazy.
|
* Wraps the result of factory in a Proxy you can consume as if it wasn't lazy.
|
||||||
* On first property access, the lazy is evaluated
|
* On first property access, the factory is evaluated
|
||||||
* @param factory lazy factory
|
* @param factory Factory returning the result
|
||||||
* @param attempts how many times to try to evaluate the lazy before giving up
|
* @param attempts How many times to try to evaluate the factory before giving up
|
||||||
* @returns Proxy
|
* @returns Result of factory function
|
||||||
*
|
|
||||||
* Note that the example below exists already as an api, see {@link findByPropsLazy}
|
|
||||||
* @example const mod = proxyLazy(() => findByProps("blah")); console.log(mod.blah);
|
|
||||||
*/
|
*/
|
||||||
export function proxyLazy<T>(factory: () => T, attempts = 5, isChild = false): T {
|
export function proxyLazy<T = any>(factory: () => T, attempts = 5, isChild = false): T {
|
||||||
let isSameTick = true;
|
const get = makeLazy(factory, attempts);
|
||||||
if (!isChild)
|
|
||||||
setTimeout(() => isSameTick = false, 0);
|
|
||||||
|
|
||||||
let tries = 0;
|
let isSameTick = true;
|
||||||
|
if (!isChild) setTimeout(() => isSameTick = false, 0);
|
||||||
|
|
||||||
|
let failed = false;
|
||||||
const proxyDummy = Object.assign(function () { }, {
|
const proxyDummy = Object.assign(function () { }, {
|
||||||
[kCACHE]: void 0 as T | undefined,
|
[proxyLazyGet]() {
|
||||||
[kGET]() {
|
if (!proxyDummy[proxyLazyCache] && !failed) {
|
||||||
if (!proxyDummy[kCACHE] && attempts > tries++) {
|
proxyDummy[proxyLazyCache] = get();
|
||||||
proxyDummy[kCACHE] = factory();
|
|
||||||
if (!proxyDummy[kCACHE] && attempts === tries)
|
if (!proxyDummy[proxyLazyCache]) {
|
||||||
console.error("Lazy factory failed:", factory);
|
failed = true;
|
||||||
|
throw new Error(`proxyLazy factory failed:\n${factory}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return proxyDummy[kCACHE];
|
|
||||||
}
|
return proxyDummy[proxyLazyCache];
|
||||||
|
},
|
||||||
|
[proxyLazyCache]: void 0 as T | undefined
|
||||||
});
|
});
|
||||||
|
|
||||||
return new Proxy(proxyDummy, {
|
return new Proxy(proxyDummy, {
|
||||||
...handler,
|
...handler,
|
||||||
get(target, p, receiver) {
|
get(target, p, receiver) {
|
||||||
// if we're still in the same tick, it means the lazy was immediately used.
|
// If we're still in the same tick, it means the lazy was immediately used.
|
||||||
// thus, we lazy proxy the get access to make things like destructuring work as expected
|
// thus, we lazy proxy the get access to make things like destructuring work as expected
|
||||||
// meow here will also be a lazy
|
// meow here will also be a lazy
|
||||||
// `const { meow } = findByPropsLazy("meow");`
|
// `const { meow } = findByPropsLazy("meow");`
|
||||||
if (!isChild && isSameTick)
|
if (!isChild && isSameTick) {
|
||||||
return proxyLazy(
|
return proxyLazy(
|
||||||
() => Reflect.get(target[kGET](), p, receiver),
|
() => Reflect.get(target[proxyLazyGet](), p, receiver),
|
||||||
attempts,
|
attempts,
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
const lazyTarget = target[kGET]();
|
}
|
||||||
|
|
||||||
|
const lazyTarget = target[proxyLazyGet]();
|
||||||
if (typeof lazyTarget === "object" || typeof lazyTarget === "function") {
|
if (typeof lazyTarget === "object" || typeof lazyTarget === "function") {
|
||||||
return Reflect.get(lazyTarget, p, receiver);
|
return Reflect.get(lazyTarget, p, receiver);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new Error("proxyLazy called on a primitive value");
|
throw new Error("proxyLazy called on a primitive value");
|
||||||
}
|
}
|
||||||
}) as any;
|
}) as T;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,22 +8,32 @@ import { ComponentType } from "react";
|
||||||
|
|
||||||
import { makeLazy } from "./lazy";
|
import { makeLazy } from "./lazy";
|
||||||
|
|
||||||
const NoopComponent = () => null;
|
export const NoopComponent = () => null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A lazy component. The factory method is called on first render.
|
* A lazy component. The factory method is called on first render.
|
||||||
* @param factory Function returning a Component
|
* @param factory Function returning a component
|
||||||
* @param attempts How many times to try to get the component before giving up
|
* @param attempts How many times to try to get the component before giving up
|
||||||
* @returns Result of factory function
|
* @returns Result of factory function
|
||||||
*/
|
*/
|
||||||
export function LazyComponent<T extends object = any>(factory: () => React.ComponentType<T>, attempts = 5) {
|
export function LazyComponent<T extends object = any>(factory: () => React.ComponentType<T>, attempts = 5) {
|
||||||
const get = makeLazy(factory, attempts);
|
const get = makeLazy(factory, attempts);
|
||||||
|
|
||||||
|
let failed = false;
|
||||||
const LazyComponent = (props: T) => {
|
const LazyComponent = (props: T) => {
|
||||||
const Component = get() ?? NoopComponent;
|
const Component = get() ?? (() => {
|
||||||
|
if (!failed) {
|
||||||
|
failed = true;
|
||||||
|
console.error(`LazyComponent factory failed:\n${factory}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
return NoopComponent;
|
||||||
|
})();
|
||||||
|
|
||||||
return <Component {...props} />;
|
return <Component {...props} />;
|
||||||
};
|
};
|
||||||
|
|
||||||
LazyComponent.$$vencordInternal = get;
|
LazyComponent.$$vencordGetter = get;
|
||||||
|
|
||||||
return LazyComponent as ComponentType<T>;
|
return LazyComponent as ComponentType<T>;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,10 +16,9 @@
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { findByPropsLazy, findExportedComponentLazy } from "@webpack";
|
import { filters, find, findByProps, findExportedComponent } from "@webpack";
|
||||||
import type { ComponentType, PropsWithChildren, ReactNode, Ref } from "react";
|
import type { ComponentType, PropsWithChildren, ReactNode, Ref } from "react";
|
||||||
|
|
||||||
import { LazyComponent } from "./react";
|
|
||||||
|
|
||||||
export const enum ModalSize {
|
export const enum ModalSize {
|
||||||
SMALL = "small",
|
SMALL = "small",
|
||||||
|
@ -49,7 +48,7 @@ export interface ModalOptions {
|
||||||
|
|
||||||
type RenderFunction = (props: ModalProps) => ReactNode;
|
type RenderFunction = (props: ModalProps) => ReactNode;
|
||||||
|
|
||||||
export const Modals = findByPropsLazy("ModalRoot", "ModalCloseButton") as {
|
type Modals = {
|
||||||
ModalRoot: ComponentType<PropsWithChildren<{
|
ModalRoot: ComponentType<PropsWithChildren<{
|
||||||
transitionState: ModalTransitionState;
|
transitionState: ModalTransitionState;
|
||||||
size?: ModalSize;
|
size?: ModalSize;
|
||||||
|
@ -101,7 +100,19 @@ export const Modals = findByPropsLazy("ModalRoot", "ModalCloseButton") as {
|
||||||
}>;
|
}>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ImageModal = ComponentType<{
|
|
||||||
|
export let ModalRoot: Modals["ModalRoot"];
|
||||||
|
export let ModalHeader: Modals["ModalHeader"];
|
||||||
|
export let ModalContent: Modals["ModalContent"];
|
||||||
|
export let ModalFooter: Modals["ModalFooter"];
|
||||||
|
export let ModalCloseButton: Modals["ModalCloseButton"];
|
||||||
|
|
||||||
|
export const Modals = find<Modals>(filters.byProps("ModalRoot", "ModalCloseButton"), m => {
|
||||||
|
({ ModalRoot, ModalHeader, ModalContent, ModalFooter, ModalCloseButton } = m);
|
||||||
|
return m;
|
||||||
|
});
|
||||||
|
|
||||||
|
export type ImageModalProps = {
|
||||||
className?: string;
|
className?: string;
|
||||||
src: string;
|
src: string;
|
||||||
placeholder: string;
|
placeholder: string;
|
||||||
|
@ -116,17 +127,11 @@ export type ImageModal = ComponentType<{
|
||||||
shouldAnimate?: boolean;
|
shouldAnimate?: boolean;
|
||||||
onClose?(): void;
|
onClose?(): void;
|
||||||
shouldHideMediaOptions?: boolean;
|
shouldHideMediaOptions?: boolean;
|
||||||
}>;
|
};
|
||||||
|
|
||||||
export const ImageModal = findExportedComponentLazy("ImageModal") as ImageModal;
|
export const ImageModal = findExportedComponent<ImageModalProps>("ImageModal");
|
||||||
|
|
||||||
export const ModalRoot = LazyComponent(() => Modals.ModalRoot);
|
const ModalAPI = findByProps("openModalLazy");
|
||||||
export const ModalHeader = LazyComponent(() => Modals.ModalHeader);
|
|
||||||
export const ModalContent = LazyComponent(() => Modals.ModalContent);
|
|
||||||
export const ModalFooter = LazyComponent(() => Modals.ModalFooter);
|
|
||||||
export const ModalCloseButton = LazyComponent(() => Modals.ModalCloseButton);
|
|
||||||
|
|
||||||
const ModalAPI = findByPropsLazy("openModalLazy");
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wait for the render promise to resolve, then open a modal with it.
|
* Wait for the render promise to resolve, then open a modal with it.
|
||||||
|
|
91
src/utils/proxyInner.ts
Normal file
91
src/utils/proxyInner.ts
Normal file
|
@ -0,0 +1,91 @@
|
||||||
|
/*
|
||||||
|
* Vencord, a Discord client mod
|
||||||
|
* Copyright (c) 2024 Vendicated and contributors
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
export const proxyInnerGet = Symbol.for("vencord.proxyInner.get");
|
||||||
|
export const proxyInnerValue = Symbol.for("vencord.proxyInner.innerValue");
|
||||||
|
|
||||||
|
// Proxies demand that these properties be unmodified, so proxyInner
|
||||||
|
// will always return the function default for them.
|
||||||
|
const unconfigurable = ["arguments", "caller", "prototype"];
|
||||||
|
|
||||||
|
const handler: ProxyHandler<any> = {
|
||||||
|
...Object.fromEntries(Object.getOwnPropertyNames(Reflect).map(propName =>
|
||||||
|
[propName, (target: any, ...args: any[]) => Reflect[propName](target[proxyInnerGet](), ...args)]
|
||||||
|
)),
|
||||||
|
ownKeys: target => {
|
||||||
|
const keys = Reflect.ownKeys(target[proxyInnerGet]());
|
||||||
|
for (const key of unconfigurable) {
|
||||||
|
if (!keys.includes(key)) keys.push(key);
|
||||||
|
}
|
||||||
|
return keys;
|
||||||
|
},
|
||||||
|
getOwnPropertyDescriptor: (target, p) => {
|
||||||
|
if (typeof p === "string" && unconfigurable.includes(p))
|
||||||
|
return Reflect.getOwnPropertyDescriptor(target, p);
|
||||||
|
|
||||||
|
const descriptor = Reflect.getOwnPropertyDescriptor(target[proxyInnerGet](), p);
|
||||||
|
if (descriptor) Object.defineProperty(target, p, descriptor);
|
||||||
|
return descriptor;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A proxy which has an inner value that can be set later.
|
||||||
|
* When a property is accessed, the proxy looks for the property value in its inner value, and errors if it's not set.
|
||||||
|
* @param err The error to throw when the inner value is not set
|
||||||
|
* @returns A proxy which will act like the inner value when accessed
|
||||||
|
*/
|
||||||
|
export function proxyInner<T = any>(err = new Error("Proxy inner value is undefined, setInnerValue was never called."), isChild = false): [proxy: T, setInnerValue: (innerValue: T) => void] {
|
||||||
|
let isSameTick = true;
|
||||||
|
if (!isChild) setTimeout(() => isSameTick = false, 0);
|
||||||
|
|
||||||
|
const proxyDummy = Object.assign(function () { }, {
|
||||||
|
[proxyInnerGet]: function () {
|
||||||
|
if (proxyDummy[proxyInnerValue] == null) {
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
|
||||||
|
return proxyDummy[proxyInnerValue];
|
||||||
|
},
|
||||||
|
[proxyInnerValue]: void 0 as T | undefined
|
||||||
|
});
|
||||||
|
|
||||||
|
const recursiveSetInnerValues = [] as Array<(innerValue: T) => void>;
|
||||||
|
|
||||||
|
function setInnerValue(innerValue: T) {
|
||||||
|
proxyDummy[proxyInnerValue] = innerValue;
|
||||||
|
recursiveSetInnerValues.forEach(setInnerValue => setInnerValue(innerValue));
|
||||||
|
}
|
||||||
|
|
||||||
|
return [new Proxy(proxyDummy, {
|
||||||
|
...handler,
|
||||||
|
get(target, p, receiver) {
|
||||||
|
if (p === proxyInnerValue) return target[proxyInnerValue];
|
||||||
|
if (p === proxyInnerGet) return target[proxyInnerGet];
|
||||||
|
|
||||||
|
// If we're still in the same tick, it means the proxy was immediately used.
|
||||||
|
// thus, we proxy the get access to make things like destructuring work as expected
|
||||||
|
// meow here will also be a proxy
|
||||||
|
// `const { meow } = findByProps("meow");`
|
||||||
|
if (!isChild && isSameTick) {
|
||||||
|
const [recursiveProxy, recursiveSetInnerValue] = proxyInner(err, true);
|
||||||
|
recursiveSetInnerValues.push((innerValue: T) => {
|
||||||
|
recursiveSetInnerValue(Reflect.get(innerValue as object, p, receiver));
|
||||||
|
});
|
||||||
|
|
||||||
|
return recursiveProxy;
|
||||||
|
}
|
||||||
|
|
||||||
|
const innerTarget = target[proxyInnerGet]();
|
||||||
|
if (typeof innerTarget === "object" || typeof innerTarget === "function") {
|
||||||
|
return Reflect.get(innerTarget, p, receiver);
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new Error("proxyInner called on a primitive value");
|
||||||
|
|
||||||
|
}
|
||||||
|
}) as T, setInnerValue];
|
||||||
|
}
|
|
@ -16,9 +16,9 @@
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { findByPropsLazy, findLazy } from "@webpack";
|
import { find, findByProps } from "@webpack";
|
||||||
|
|
||||||
import * as t from "./types/classes";
|
import * as t from "./types/classes";
|
||||||
|
|
||||||
export const ModalImageClasses: t.ImageModalClasses = findLazy(m => m.image && m.modal && !m.applicationIcon);
|
export const ModalImageClasses: t.ImageModalClasses = find(m => m.image && m.modal && !m.applicationIcon);
|
||||||
export const ButtonWrapperClasses: t.ButtonWrapperClasses = findByPropsLazy("buttonWrapper", "buttonContent");
|
export const ButtonWrapperClasses: t.ButtonWrapperClasses = findByProps("buttonWrapper", "buttonContent");
|
||||||
|
|
|
@ -17,9 +17,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// eslint-disable-next-line path-alias/no-relative
|
// eslint-disable-next-line path-alias/no-relative
|
||||||
import { filters, findByPropsLazy, waitFor } from "@webpack";
|
import { filters, findComponent, findExportedComponent, waitFor } from "@webpack";
|
||||||
|
|
||||||
import { waitForComponent } from "./internal";
|
|
||||||
import * as t from "./types/components";
|
import * as t from "./types/components";
|
||||||
|
|
||||||
export let Forms = {} as {
|
export let Forms = {} as {
|
||||||
|
@ -53,13 +52,14 @@ export let FocusLock: t.FocusLock;
|
||||||
/** css colour resolver stuff, no clue what exactly this does, just copied usage from Discord */
|
/** css colour resolver stuff, no clue what exactly this does, just copied usage from Discord */
|
||||||
export let useToken: t.useToken;
|
export let useToken: t.useToken;
|
||||||
|
|
||||||
export const MaskedLink = waitForComponent<t.MaskedLink>("MaskedLink", filters.componentByCode("MASKED_LINK)"));
|
export const MaskedLink = findComponent<t.MaskedLinkProps>(filters.componentByCode("MASKED_LINK)"));
|
||||||
export const Timestamp = waitForComponent<t.Timestamp>("Timestamp", filters.byCode(".Messages.MESSAGE_EDITED_TIMESTAMP_A11Y_LABEL.format"));
|
export const Timestamp = findComponent<t.TimestampProps>(filters.componentByCode(".Messages.MESSAGE_EDITED_TIMESTAMP_A11Y_LABEL.format"));
|
||||||
export const Flex = waitForComponent<t.Flex>("Flex", ["Justify", "Align", "Wrap"]);
|
export const Flex = findComponent<t.FlexProps>(filters.byProps("Justify", "Align", "Wrap"));
|
||||||
|
|
||||||
export const { OAuth2AuthorizeModal } = findByPropsLazy("OAuth2AuthorizeModal");
|
export const OAuth2AuthorizeModal = findExportedComponent("OAuth2AuthorizeModal");
|
||||||
|
|
||||||
waitFor(["FormItem", "Button"], m => {
|
waitFor(filters.byProps("FormItem", "Button"), m => {
|
||||||
|
Forms = m;
|
||||||
({
|
({
|
||||||
useToken,
|
useToken,
|
||||||
Card,
|
Card,
|
||||||
|
@ -83,5 +83,4 @@ waitFor(["FormItem", "Button"], m => {
|
||||||
FocusLock,
|
FocusLock,
|
||||||
Heading
|
Heading
|
||||||
} = m);
|
} = m);
|
||||||
Forms = m;
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,44 +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 <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { LazyComponent } from "@utils/react";
|
|
||||||
|
|
||||||
// eslint-disable-next-line path-alias/no-relative
|
|
||||||
import { FilterFn, filters, lazyWebpackSearchHistory, waitFor } from "../webpack";
|
|
||||||
|
|
||||||
export function waitForComponent<T extends React.ComponentType<any> = React.ComponentType<any> & Record<string, any>>(name: string, filter: FilterFn | string | string[]): T {
|
|
||||||
if (IS_DEV) lazyWebpackSearchHistory.push(["waitForComponent", Array.isArray(filter) ? filter : [filter]]);
|
|
||||||
|
|
||||||
let myValue: T = function () {
|
|
||||||
throw new Error(`Vencord could not find the ${name} Component`);
|
|
||||||
} as any;
|
|
||||||
|
|
||||||
const lazyComponent = LazyComponent(() => myValue) as T;
|
|
||||||
waitFor(filter, (v: any) => {
|
|
||||||
myValue = v;
|
|
||||||
Object.assign(lazyComponent, v);
|
|
||||||
}, { isIndirect: true });
|
|
||||||
|
|
||||||
return lazyComponent;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function waitForStore(name: string, cb: (v: any) => void) {
|
|
||||||
if (IS_DEV) lazyWebpackSearchHistory.push(["waitForStore", [name]]);
|
|
||||||
|
|
||||||
waitFor(filters.byStoreName(name), cb, { isIndirect: true });
|
|
||||||
}
|
|
|
@ -17,12 +17,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// eslint-disable-next-line path-alias/no-relative
|
// eslint-disable-next-line path-alias/no-relative
|
||||||
import { findByPropsLazy, waitFor } from "../webpack";
|
import { findByProps } from "../webpack";
|
||||||
import type * as t from "./types/menu";
|
import type * as t from "./types/menu";
|
||||||
|
|
||||||
export let Menu = {} as t.Menu;
|
export const Menu = findByProps<t.Menu>("MenuItem", "MenuSliderControl");
|
||||||
|
|
||||||
waitFor(["MenuItem", "MenuSliderControl"], m => Menu = m);
|
export const ContextMenuApi = findByProps<t.ContextMenuApi>("closeContextMenu", "openContextMenu");
|
||||||
|
|
||||||
export const ContextMenuApi: t.ContextMenuApi = findByPropsLazy("closeContextMenu", "openContextMenu");
|
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// eslint-disable-next-line path-alias/no-relative
|
// eslint-disable-next-line path-alias/no-relative
|
||||||
import { findByPropsLazy, waitFor } from "../webpack";
|
import { filters, findByProps,waitFor } from "../webpack";
|
||||||
|
|
||||||
export let React: typeof import("react");
|
export let React: typeof import("react");
|
||||||
export let useState: typeof React.useState;
|
export let useState: typeof React.useState;
|
||||||
|
@ -27,9 +27,9 @@ export let useRef: typeof React.useRef;
|
||||||
export let useReducer: typeof React.useReducer;
|
export let useReducer: typeof React.useReducer;
|
||||||
export let useCallback: typeof React.useCallback;
|
export let useCallback: typeof React.useCallback;
|
||||||
|
|
||||||
export const ReactDOM: typeof import("react-dom") & typeof import("react-dom/client") = findByPropsLazy("createPortal", "render");
|
export const ReactDOM = findByProps<typeof import("react-dom") & typeof import("react-dom/client")>("createPortal", "render");
|
||||||
|
|
||||||
waitFor("useState", m => {
|
waitFor(filters.byProps("useState"), m => {
|
||||||
React = m;
|
React = m;
|
||||||
({ useEffect, useState, useMemo, useRef, useReducer, useCallback } = React);
|
({ useEffect, useState, useMemo, useRef, useReducer, useCallback } = React);
|
||||||
});
|
});
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue