From bad96b78879f296d5b9e7adacb03756b0f58427a Mon Sep 17 00:00:00 2001 From: Ven Date: Mon, 28 Nov 2022 13:37:55 +0100 Subject: [PATCH] Path aliases, better lazyWebpack (#268) --- browser/VencordNativeStub.ts | 2 +- docs/2_PLUGINS.md | 2 +- src/VencordNative.ts | 3 +- src/api/Commands/commandHelpers.ts | 8 +-- src/api/Commands/index.ts | 3 +- src/api/MessageEvents.ts | 5 +- src/api/Notices.ts | 2 +- src/api/ServerList.ts | 2 +- src/api/settings.ts | 12 ++-- src/components/CheckedTextInput.tsx | 2 +- src/components/DonateButton.tsx | 5 +- src/components/ErrorBoundary.tsx | 7 +- src/components/ErrorCard.tsx | 2 +- src/components/Flex.tsx | 2 +- src/components/Link.tsx | 2 +- src/components/Monaco.ts | 10 +-- src/components/PatchHelper.tsx | 9 +-- src/components/PluginSettings/PluginModal.tsx | 18 +++--- .../components/SettingBooleanComponent.tsx | 5 +- .../components/SettingCustomComponent.tsx | 3 +- .../components/SettingNumericComponent.tsx | 5 +- .../components/SettingSelectComponent.tsx | 5 +- .../components/SettingSliderComponent.tsx | 5 +- .../components/SettingTextComponent.tsx | 5 +- .../PluginSettings/components/index.ts | 3 +- src/components/PluginSettings/index.tsx | 21 +++--- .../VencordSettings/BackupRestoreTab.tsx | 5 +- src/components/VencordSettings/Updater.tsx | 7 +- src/components/VencordSettings/VencordTab.tsx | 9 +-- src/components/VencordSettings/index.tsx | 8 +-- src/components/handleComponentFailed.ts | 2 +- src/debug/Tracer.ts | 2 +- src/ipcMain/index.ts | 6 +- src/ipcMain/updater/git.ts | 2 +- src/ipcMain/updater/http.ts | 4 +- src/modules.d.ts | 2 +- src/patcher.ts | 2 +- src/plugins/BetterNotes.ts | 8 +-- src/plugins/HideAttachments.tsx | 11 ++-- src/plugins/TimeBarAllActivities.ts | 4 +- src/plugins/anonymiseFileNames.ts | 6 +- src/plugins/apiBadges.tsx | 22 +++---- src/plugins/apiCommands.ts | 4 +- src/plugins/apiMenuItemDeobfuscator.ts | 6 +- src/plugins/apiMessageAccessories.ts | 4 +- src/plugins/apiMessageEvents.ts | 4 +- src/plugins/apiNotices.ts | 6 +- src/plugins/apiServerList.ts | 4 +- src/plugins/arRPC.tsx | 15 ++--- src/plugins/banger.ts | 4 +- src/plugins/betterGifAltText.ts | 4 +- src/plugins/betterRoleDot.ts | 8 +-- src/plugins/betterUploadButton.ts | 4 +- src/plugins/blurNsfw.ts | 6 +- src/plugins/callTimer.tsx | 10 +-- src/plugins/clearURLs/index.ts | 9 +-- src/plugins/consoleShortcuts.ts | 4 +- src/plugins/corruptMp4s.ts | 12 ++-- src/plugins/dictionary.ts | 8 +-- src/plugins/emoteCloner.tsx | 22 +++---- src/plugins/experiments.tsx | 13 ++-- src/plugins/fakeNitro.ts | 22 +++---- src/plugins/fart.ts | 10 +-- src/plugins/forceOwnerCrown.ts | 6 +- src/plugins/friendInvites.ts | 8 +-- src/plugins/fxTwitter.ts | 6 +- src/plugins/iLoveSpam.ts | 4 +- src/plugins/ignoreActivities.ts | 11 ++-- src/plugins/index.ts | 9 +-- src/plugins/keepCurrentChannel.ts | 8 +-- src/plugins/lastfm.tsx | 64 +++++++++---------- src/plugins/loadingQuotes.ts | 4 +- src/plugins/messageActions.ts | 21 +++--- src/plugins/messageLogger/index.tsx | 19 +++--- src/plugins/messageTags.ts | 10 +-- src/plugins/moreCommands.ts | 6 +- src/plugins/moreKaomoji.ts | 8 +-- src/plugins/moyai.ts | 13 ++-- src/plugins/muteNewGuild.ts | 4 +- src/plugins/noBlockedMessages.ts | 12 ++-- src/plugins/noCanaryMessageLinks.ts | 8 +-- src/plugins/noDevtoolsWarning.ts | 6 +- src/plugins/noF1.ts | 4 +- src/plugins/noRPC.ts | 4 +- src/plugins/noReplyMention.ts | 4 +- src/plugins/noSystemBadge.ts | 4 +- src/plugins/noTrack.ts | 4 +- src/plugins/noUnblockToJump.ts | 4 +- src/plugins/oneko.ts | 4 +- src/plugins/petpet.ts | 18 +++--- src/plugins/plainFolderIcon.ts | 4 +- src/plugins/platformIndicators.tsx | 16 ++--- .../components/PronounsAboutComponent.tsx | 4 +- .../components/PronounsChatComponent.tsx | 10 +-- .../components/PronounsProfileWrapper.tsx | 7 +- src/plugins/pronoundb/index.ts | 5 +- src/plugins/pronoundb/pronoundbUtils.ts | 7 +- src/plugins/quickMention.tsx | 8 +-- src/plugins/quickReply.ts | 14 ++-- src/plugins/readAllNotificationsButton.tsx | 8 +-- src/plugins/reverseImageSearch.tsx | 6 +- src/plugins/reviewDB/Utils/ReviewDBAPI.ts | 3 +- src/plugins/reviewDB/Utils/Utils.tsx | 13 ++-- .../reviewDB/components/MessageButton.tsx | 4 +- .../reviewDB/components/ReviewComponent.tsx | 7 +- .../reviewDB/components/ReviewsView.tsx | 7 +- src/plugins/reviewDB/index.tsx | 10 +-- src/plugins/settings.tsx | 8 +-- src/plugins/showHiddenChannels.tsx | 14 ++-- src/plugins/silentTyping.ts | 4 +- .../spotifyControls/PlayerComponent.tsx | 17 ++--- src/plugins/spotifyControls/SpotifyStore.ts | 15 ++--- src/plugins/spotifyControls/index.tsx | 5 +- src/plugins/spotifyCrack.ts | 7 +- src/plugins/spotifyShareCommands.ts | 19 +++--- .../startupTimings/StartupTimingPage.tsx | 11 ++-- src/plugins/startupTimings/index.tsx | 6 +- src/plugins/unindent.ts | 6 +- src/plugins/unminifyErrors.ts | 4 +- src/plugins/uwuify.ts | 6 +- src/plugins/vcDoubleClick.ts | 8 +-- src/plugins/viewIcons.tsx | 15 ++--- src/plugins/volumeBooster.ts | 6 +- src/plugins/webContextMenus.ts | 4 +- src/plugins/webhookTags.ts | 4 +- src/plugins/whoReacted.tsx | 19 +++--- src/preload.ts | 4 +- src/utils/discord.ts | 3 +- src/utils/misc.tsx | 14 +--- src/utils/modal.tsx | 3 +- src/utils/proxyLazy.ts | 2 +- src/utils/quickCss.ts | 3 +- src/utils/settingsSync.ts | 3 +- src/utils/types.ts | 3 +- src/webpack/common.tsx | 32 +++++----- src/webpack/patchWebpack.ts | 5 +- src/webpack/webpack.ts | 25 +++++++- tsconfig.json | 11 +++- 138 files changed, 572 insertions(+), 547 deletions(-) diff --git a/browser/VencordNativeStub.ts b/browser/VencordNativeStub.ts index dca7da82..ef3923ba 100644 --- a/browser/VencordNativeStub.ts +++ b/browser/VencordNativeStub.ts @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -import IpcEvents from "../src/utils/IpcEvents"; import * as DataStore from "../src/api/DataStore"; +import IpcEvents from "../src/utils/IpcEvents"; // Discord deletes this so need to store in variable const { localStorage } = window; diff --git a/docs/2_PLUGINS.md b/docs/2_PLUGINS.md index 6ac4b246..705ea89d 100644 --- a/docs/2_PLUGINS.md +++ b/docs/2_PLUGINS.md @@ -15,7 +15,7 @@ You don't need to run `pnpm build` every time you make a change. Instead, use `p 3. In `index.ts`, copy-paste the following template code: ```ts -import definePlugin from "../../utils/types"; +import definePlugin from "@utils/types"; export default definePlugin({ name: "Epic Plugin", diff --git a/src/VencordNative.ts b/src/VencordNative.ts index c9848707..3cd53e18 100644 --- a/src/VencordNative.ts +++ b/src/VencordNative.ts @@ -16,10 +16,9 @@ * along with this program. If not, see . */ +import IPC_EVENTS from "@utils/IpcEvents"; import { IpcRenderer, ipcRenderer } from "electron"; -import IPC_EVENTS from "./utils/IpcEvents"; - function assertEventAllowed(event: string) { if (!(event in IPC_EVENTS)) throw new Error(`Event ${event} not allowed.`); } diff --git a/src/api/Commands/commandHelpers.ts b/src/api/Commands/commandHelpers.ts index 8986248d..d363d6ed 100644 --- a/src/api/Commands/commandHelpers.ts +++ b/src/api/Commands/commandHelpers.ts @@ -16,15 +16,15 @@ * along with this program. If not, see . */ +import { mergeDefaults } from "@utils/misc"; +import { findByCodeLazy, findByPropsLazy, waitFor } from "@webpack"; import { Message } from "discord-types/general"; import type { PartialDeep } from "type-fest"; -import { lazyWebpack, mergeDefaults } from "../../utils/misc"; -import { filters, waitFor } from "../../webpack"; import { Argument } from "./types"; -const createBotMessage = lazyWebpack(filters.byCode('username:"Clyde"')); -const MessageSender = lazyWebpack(filters.byProps("receiveMessage")); +const createBotMessage = findByCodeLazy('username:"Clyde"'); +const MessageSender = findByPropsLazy("receiveMessage"); let SnowflakeUtils: any; waitFor("fromTimestamp", m => SnowflakeUtils = m); diff --git a/src/api/Commands/index.ts b/src/api/Commands/index.ts index f31043c4..88139d4d 100644 --- a/src/api/Commands/index.ts +++ b/src/api/Commands/index.ts @@ -16,7 +16,8 @@ * along with this program. If not, see . */ -import { makeCodeblock } from "../../utils/misc"; +import { makeCodeblock } from "@utils/misc"; + import { sendBotMessage } from "./commandHelpers"; import { ApplicationCommandInputType, ApplicationCommandOptionType, ApplicationCommandType, Argument, Command, CommandContext, Option } from "./types"; diff --git a/src/api/MessageEvents.ts b/src/api/MessageEvents.ts index 02638b2b..1bf6b0bc 100644 --- a/src/api/MessageEvents.ts +++ b/src/api/MessageEvents.ts @@ -16,11 +16,10 @@ * along with this program. If not, see . */ +import Logger from "@utils/Logger"; +import { MessageStore } from "@webpack/common"; import type { Channel, Message } from "discord-types/general"; -import Logger from "../utils/Logger"; -import { MessageStore } from "../webpack/common"; - const MessageEventsLogger = new Logger("MessageEvents", "#e5c890"); export interface Emoji { diff --git a/src/api/Notices.ts b/src/api/Notices.ts index 4364ca5a..6d20087a 100644 --- a/src/api/Notices.ts +++ b/src/api/Notices.ts @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import { waitFor } from "../webpack"; +import { waitFor } from "@webpack"; let NoticesModule: any; waitFor(m => m.show && m.dismiss && !m.suppressAll, m => NoticesModule = m); diff --git a/src/api/ServerList.ts b/src/api/ServerList.ts index d3a9a110..c98b1740 100644 --- a/src/api/ServerList.ts +++ b/src/api/ServerList.ts @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import Logger from "../utils/Logger"; +import Logger from "@utils/Logger"; const logger = new Logger("ServerListAPI"); diff --git a/src/api/settings.ts b/src/api/settings.ts index dd8692a2..b7499d1b 100644 --- a/src/api/settings.ts +++ b/src/api/settings.ts @@ -16,13 +16,13 @@ * along with this program. If not, see . */ -import plugins from "~plugins"; +import IpcEvents from "@utils/IpcEvents"; +import Logger from "@utils/Logger"; +import { mergeDefaults } from "@utils/misc"; +import { OptionType } from "@utils/types"; +import { React } from "@webpack/common"; -import IpcEvents from "../utils/IpcEvents"; -import Logger from "../utils/Logger"; -import { mergeDefaults } from "../utils/misc"; -import { OptionType } from "../utils/types"; -import { React } from "../webpack/common"; +import plugins from "~plugins"; const logger = new Logger("Settings"); export interface Settings { diff --git a/src/components/CheckedTextInput.tsx b/src/components/CheckedTextInput.tsx index e97519dd..cf4aa119 100644 --- a/src/components/CheckedTextInput.tsx +++ b/src/components/CheckedTextInput.tsx @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import { React, TextInput } from "../webpack/common"; +import { React, TextInput } from "@webpack/common"; // TODO: Refactor settings to use this as well interface TextInputProps { diff --git a/src/components/DonateButton.tsx b/src/components/DonateButton.tsx index 6aae8ad0..49f079b4 100644 --- a/src/components/DonateButton.tsx +++ b/src/components/DonateButton.tsx @@ -16,8 +16,9 @@ * along with this program. If not, see . */ -import IpcEvents from "../utils/IpcEvents"; -import { Button } from "../webpack/common"; +import IpcEvents from "@utils/IpcEvents"; +import { Button } from "@webpack/common"; + import { Heart } from "./Heart"; export default function DonateButton(props: any) { diff --git a/src/components/ErrorBoundary.tsx b/src/components/ErrorBoundary.tsx index 86a59464..8ebc61bb 100644 --- a/src/components/ErrorBoundary.tsx +++ b/src/components/ErrorBoundary.tsx @@ -16,9 +16,10 @@ * along with this program. If not, see . */ -import Logger from "../utils/Logger"; -import { LazyComponent } from "../utils/misc"; -import { Margins, React } from "../webpack/common"; +import Logger from "@utils/Logger"; +import { LazyComponent } from "@utils/misc"; +import { Margins, React } from "@webpack/common"; + import { ErrorCard } from "./ErrorCard"; interface Props { diff --git a/src/components/ErrorCard.tsx b/src/components/ErrorCard.tsx index f83be383..e749ea4b 100644 --- a/src/components/ErrorCard.tsx +++ b/src/components/ErrorCard.tsx @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import { Card } from "../webpack/common"; +import { Card } from "@webpack/common"; interface Props { style?: React.CSSProperties; diff --git a/src/components/Flex.tsx b/src/components/Flex.tsx index 1987faba..430d8576 100644 --- a/src/components/Flex.tsx +++ b/src/components/Flex.tsx @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import type { React } from "../webpack/common"; +import type { React } from "@webpack/common"; export function Flex(props: React.PropsWithChildren<{ flexDirection?: React.CSSProperties["flexDirection"]; diff --git a/src/components/Link.tsx b/src/components/Link.tsx index 2400ea67..0f4eb07d 100644 --- a/src/components/Link.tsx +++ b/src/components/Link.tsx @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import { React } from "../webpack/common"; +import { React } from "@webpack/common"; interface Props extends React.DetailedHTMLProps, HTMLAnchorElement> { disabled?: boolean; diff --git a/src/components/Monaco.ts b/src/components/Monaco.ts index 6d16c76b..aa98f998 100644 --- a/src/components/Monaco.ts +++ b/src/components/Monaco.ts @@ -16,12 +16,12 @@ * along with this program. If not, see . */ -import monacoHtml from "~fileContent/monacoWin.html"; +import { debounce } from "@utils/debounce"; +import IpcEvents from "@utils/IpcEvents"; +import { Queue } from "@utils/Queue"; +import { find } from "@webpack"; -import { debounce } from "../utils/debounce"; -import IpcEvents from "../utils/IpcEvents"; -import { Queue } from "../utils/Queue"; -import { find } from "../webpack/webpack"; +import monacoHtml from "~fileContent/monacoWin.html"; const queue = new Queue(); const setCss = debounce((css: string) => { diff --git a/src/components/PatchHelper.tsx b/src/components/PatchHelper.tsx index 0314de89..22c2b4dc 100644 --- a/src/components/PatchHelper.tsx +++ b/src/components/PatchHelper.tsx @@ -16,10 +16,11 @@ * along with this program. If not, see . */ -import { debounce } from "../utils/debounce"; -import { makeCodeblock } from "../utils/misc"; -import { Button, Clipboard, Forms, Margins, Parser, React, Switch, Text, TextInput } from "../webpack/common"; -import { search } from "../webpack/webpack"; +import { debounce } from "@utils/debounce"; +import { makeCodeblock } from "@utils/misc"; +import { search } from "@webpack"; +import { Button, Clipboard, Forms, Margins, Parser, React, Switch, Text, TextInput } from "@webpack/common"; + import { CheckedTextInput } from "./CheckedTextInput"; import ErrorBoundary from "./ErrorBoundary"; diff --git a/src/components/PluginSettings/PluginModal.tsx b/src/components/PluginSettings/PluginModal.tsx index 7331fffa..275d3701 100644 --- a/src/components/PluginSettings/PluginModal.tsx +++ b/src/components/PluginSettings/PluginModal.tsx @@ -16,17 +16,17 @@ * along with this program. If not, see . */ +import { generateId } from "@api/Commands"; +import { useSettings } from "@api/settings"; +import { LazyComponent } from "@utils/misc"; +import { ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, ModalSize } from "@utils/modal"; +import { proxyLazy } from "@utils/proxyLazy"; +import { OptionType, Plugin } from "@utils/types"; +import { findByCode, findByPropsLazy } from "@webpack"; +import { Button, FluxDispatcher, Forms, React, Text, Tooltip, UserStore, UserUtils } from "@webpack/common"; import { User } from "discord-types/general"; import { Constructor } from "type-fest"; -import { generateId } from "../../api/Commands"; -import { useSettings } from "../../api/settings"; -import { LazyComponent, lazyWebpack } from "../../utils/misc"; -import { ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, ModalSize } from "../../utils/modal"; -import { proxyLazy } from "../../utils/proxyLazy"; -import { OptionType, Plugin } from "../../utils/types"; -import { filters, findByCode } from "../../webpack"; -import { Button, FluxDispatcher, Forms, React, Text, Tooltip, UserStore, UserUtils } from "../../webpack/common"; import ErrorBoundary from "../ErrorBoundary"; import { Flex } from "../Flex"; import { @@ -40,7 +40,7 @@ import { } from "./components"; const UserSummaryItem = LazyComponent(() => findByCode("defaultRenderUser", "showDefaultAvatarsForNullUsers")); -const AvatarStyles = lazyWebpack(filters.byProps("moreUsers", "emptyUser", "avatarContainer", "clickableAvatar")); +const AvatarStyles = findByPropsLazy("moreUsers", "emptyUser", "avatarContainer", "clickableAvatar"); const UserRecord: Constructor> = proxyLazy(() => UserStore.getCurrentUser().constructor) as any; interface PluginModalProps extends ModalProps { diff --git a/src/components/PluginSettings/components/SettingBooleanComponent.tsx b/src/components/PluginSettings/components/SettingBooleanComponent.tsx index 99c1eae8..0aaafa04 100644 --- a/src/components/PluginSettings/components/SettingBooleanComponent.tsx +++ b/src/components/PluginSettings/components/SettingBooleanComponent.tsx @@ -16,8 +16,9 @@ * along with this program. If not, see . */ -import { PluginOptionBoolean } from "../../../utils/types"; -import { Forms, React, Select } from "../../../webpack/common"; +import { PluginOptionBoolean } from "@utils/types"; +import { Forms, React, Select } from "@webpack/common"; + import { ISettingElementProps } from "."; export function SettingBooleanComponent({ option, pluginSettings, id, onChange, onError }: ISettingElementProps) { diff --git a/src/components/PluginSettings/components/SettingCustomComponent.tsx b/src/components/PluginSettings/components/SettingCustomComponent.tsx index dd704bf3..af7192f3 100644 --- a/src/components/PluginSettings/components/SettingCustomComponent.tsx +++ b/src/components/PluginSettings/components/SettingCustomComponent.tsx @@ -16,7 +16,8 @@ * along with this program. If not, see . */ -import { PluginOptionComponent } from "../../../utils/types"; +import { PluginOptionComponent } from "@utils/types"; + import { ISettingElementProps } from "."; export function SettingCustomComponent({ option, onChange, onError }: ISettingElementProps) { diff --git a/src/components/PluginSettings/components/SettingNumericComponent.tsx b/src/components/PluginSettings/components/SettingNumericComponent.tsx index 01e72dc7..3457783e 100644 --- a/src/components/PluginSettings/components/SettingNumericComponent.tsx +++ b/src/components/PluginSettings/components/SettingNumericComponent.tsx @@ -16,8 +16,9 @@ * along with this program. If not, see . */ -import { OptionType, PluginOptionNumber } from "../../../utils/types"; -import { Forms, React, TextInput } from "../../../webpack/common"; +import { OptionType, PluginOptionNumber } from "@utils/types"; +import { Forms, React, TextInput } from "@webpack/common"; + import { ISettingElementProps } from "."; const MAX_SAFE_NUMBER = BigInt(Number.MAX_SAFE_INTEGER); diff --git a/src/components/PluginSettings/components/SettingSelectComponent.tsx b/src/components/PluginSettings/components/SettingSelectComponent.tsx index ce35675c..8a5bee1c 100644 --- a/src/components/PluginSettings/components/SettingSelectComponent.tsx +++ b/src/components/PluginSettings/components/SettingSelectComponent.tsx @@ -16,8 +16,9 @@ * along with this program. If not, see . */ -import { PluginOptionSelect } from "../../../utils/types"; -import { Forms, React, Select } from "../../../webpack/common"; +import { PluginOptionSelect } from "@utils/types"; +import { Forms, React, Select } from "@webpack/common"; + import { ISettingElementProps } from "."; export function SettingSelectComponent({ option, pluginSettings, onChange, onError, id }: ISettingElementProps) { diff --git a/src/components/PluginSettings/components/SettingSliderComponent.tsx b/src/components/PluginSettings/components/SettingSliderComponent.tsx index ff1c491d..2d316967 100644 --- a/src/components/PluginSettings/components/SettingSliderComponent.tsx +++ b/src/components/PluginSettings/components/SettingSliderComponent.tsx @@ -16,8 +16,9 @@ * along with this program. If not, see . */ -import { PluginOptionSlider } from "../../../utils/types"; -import { Forms, React, Slider } from "../../../webpack/common"; +import { PluginOptionSlider } from "@utils/types"; +import { Forms, React, Slider } from "@webpack/common"; + import { ISettingElementProps } from "."; export function makeRange(start: number, end: number, step = 1) { diff --git a/src/components/PluginSettings/components/SettingTextComponent.tsx b/src/components/PluginSettings/components/SettingTextComponent.tsx index f76bd587..b92fcecc 100644 --- a/src/components/PluginSettings/components/SettingTextComponent.tsx +++ b/src/components/PluginSettings/components/SettingTextComponent.tsx @@ -16,8 +16,9 @@ * along with this program. If not, see . */ -import { PluginOptionString } from "../../../utils/types"; -import { Forms, React, TextInput } from "../../../webpack/common"; +import { PluginOptionString } from "@utils/types"; +import { Forms, React, TextInput } from "@webpack/common"; + import { ISettingElementProps } from "."; export function SettingTextComponent({ option, pluginSettings, id, onChange, onError }: ISettingElementProps) { diff --git a/src/components/PluginSettings/components/index.ts b/src/components/PluginSettings/components/index.ts index 507b53a5..9e750681 100644 --- a/src/components/PluginSettings/components/index.ts +++ b/src/components/PluginSettings/components/index.ts @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import { PluginOptionBase } from "../../../utils/types"; +import { PluginOptionBase } from "@utils/types"; export interface ISettingElementProps { option: T; @@ -35,3 +35,4 @@ export * from "./SettingNumericComponent"; export * from "./SettingSelectComponent"; export * from "./SettingSliderComponent"; export * from "./SettingTextComponent"; + diff --git a/src/components/PluginSettings/index.tsx b/src/components/PluginSettings/index.tsx index f16d55c4..495a5099 100644 --- a/src/components/PluginSettings/index.tsx +++ b/src/components/PluginSettings/index.tsx @@ -16,18 +16,19 @@ * along with this program. If not, see . */ +import { showNotice } from "@api/Notices"; +import { Settings, useSettings } from "@api/settings"; +import { ChangeList } from "@utils/ChangeList"; +import Logger from "@utils/Logger"; +import { classes, LazyComponent } from "@utils/misc"; +import { openModalLazy } from "@utils/modal"; +import { Plugin } from "@utils/types"; +import { findByCode, findByPropsLazy } from "@webpack"; +import { Alerts, Button, Forms, Margins, Parser, React, Select, Switch, Text, TextInput, Toasts, Tooltip } from "@webpack/common"; + import Plugins from "~plugins"; -import { showNotice } from "../../api/Notices"; -import { Settings, useSettings } from "../../api/settings"; import { startDependenciesRecursive, startPlugin, stopPlugin } from "../../plugins"; -import { ChangeList } from "../../utils/ChangeList"; -import Logger from "../../utils/Logger"; -import { classes, LazyComponent, lazyWebpack } from "../../utils/misc"; -import { openModalLazy } from "../../utils/modal"; -import { Plugin } from "../../utils/types"; -import { filters, findByCode } from "../../webpack"; -import { Alerts, Button, Forms, Margins, Parser, React, Select, Switch, Text, TextInput, Toasts, Tooltip } from "../../webpack/common"; import ErrorBoundary from "../ErrorBoundary"; import { ErrorCard } from "../ErrorCard"; import { Flex } from "../Flex"; @@ -37,7 +38,7 @@ import * as styles from "./styles"; const logger = new Logger("PluginSettings", "#a6d189"); -const InputStyles = lazyWebpack(filters.byProps("inputDefault", "inputWrapper")); +const InputStyles = findByPropsLazy("inputDefault", "inputWrapper"); const CogWheel = LazyComponent(() => findByCode("18.564C15.797 19.099 14.932 19.498 14 19.738V22H10V19.738C9.069")); const InfoIcon = LazyComponent(() => findByCode("4.4408921e-16 C4.4771525,-1.77635684e-15 4.4408921e-16")); diff --git a/src/components/VencordSettings/BackupRestoreTab.tsx b/src/components/VencordSettings/BackupRestoreTab.tsx index ce0bdaa6..73a1309a 100644 --- a/src/components/VencordSettings/BackupRestoreTab.tsx +++ b/src/components/VencordSettings/BackupRestoreTab.tsx @@ -16,8 +16,9 @@ * along with this program. If not, see . */ -import { downloadSettingsBackup, uploadSettingsBackup } from "../../utils/settingsSync"; -import { Button, Card, Forms, Margins, Text } from "../../webpack/common"; +import { downloadSettingsBackup, uploadSettingsBackup } from "@utils/settingsSync"; +import { Button, Card, Forms, Margins, Text } from "@webpack/common"; + import ErrorBoundary from "../ErrorBoundary"; import { Flex } from "../Flex"; diff --git a/src/components/VencordSettings/Updater.tsx b/src/components/VencordSettings/Updater.tsx index 8f2b75be..7abfad90 100644 --- a/src/components/VencordSettings/Updater.tsx +++ b/src/components/VencordSettings/Updater.tsx @@ -16,11 +16,12 @@ * along with this program. If not, see . */ +import { classes, useAwaiter } from "@utils/misc"; +import { changes, checkForUpdates, getRepo, isNewer, rebuild, update, updateError, UpdateLogger } from "@utils/updater"; +import { Alerts, Button, Card, Forms, Margins, Parser, React, Toasts } from "@webpack/common"; + import gitHash from "~git-hash"; -import { classes, useAwaiter } from "../../utils/misc"; -import { changes, checkForUpdates, getRepo, isNewer, rebuild, update, updateError, UpdateLogger } from "../../utils/updater"; -import { Alerts, Button, Card, Forms, Margins, Parser, React, Toasts } from "../../webpack/common"; import ErrorBoundary from "../ErrorBoundary"; import { ErrorCard } from "../ErrorCard"; import { Flex } from "../Flex"; diff --git a/src/components/VencordSettings/VencordTab.tsx b/src/components/VencordSettings/VencordTab.tsx index 0e5846ff..3a3f45fd 100644 --- a/src/components/VencordSettings/VencordTab.tsx +++ b/src/components/VencordSettings/VencordTab.tsx @@ -17,10 +17,11 @@ */ -import { useSettings } from "../../api/settings"; -import IpcEvents from "../../utils/IpcEvents"; -import { useAwaiter } from "../../utils/misc"; -import { Button, Card, Forms, React, Switch } from "../../webpack/common"; +import { useSettings } from "@api/settings"; +import IpcEvents from "@utils/IpcEvents"; +import { useAwaiter } from "@utils/misc"; +import { Button, Card, Forms, React, Switch } from "@webpack/common"; + import DonateButton from "../DonateButton"; import ErrorBoundary from "../ErrorBoundary"; diff --git a/src/components/VencordSettings/index.tsx b/src/components/VencordSettings/index.tsx index 028bd5e5..4b6fb4eb 100644 --- a/src/components/VencordSettings/index.tsx +++ b/src/components/VencordSettings/index.tsx @@ -16,11 +16,11 @@ * along with this program. If not, see . */ +import { findByCodeLazy } from "@webpack"; +import { Forms, Router, Text } from "@webpack/common"; + import cssText from "~fileContent/settingsStyles.css"; -import { lazyWebpack } from "../../utils/misc"; -import { filters } from "../../webpack"; -import { Forms, React, Router, Text } from "../../webpack/common"; import ErrorBoundary from "../ErrorBoundary"; import BackupRestoreTab from "./BackupRestoreTab"; import PluginsTab from "./PluginsTab"; @@ -33,7 +33,7 @@ document.head.appendChild(style); const st = (style: string) => `vcSettings${style}`; -const TabBar = lazyWebpack(filters.byCode('[role="tab"][aria-disabled="false"]')); +const TabBar = findByCodeLazy('[role="tab"][aria-disabled="false"]'); interface SettingsProps { tab: string; diff --git a/src/components/handleComponentFailed.ts b/src/components/handleComponentFailed.ts index 34f3ab9b..020e8ef2 100644 --- a/src/components/handleComponentFailed.ts +++ b/src/components/handleComponentFailed.ts @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import { isOutdated, rebuild, update } from "../utils/updater"; +import { isOutdated, rebuild, update } from "@utils/updater"; export async function handleComponentFailed() { if (isOutdated) { diff --git a/src/debug/Tracer.ts b/src/debug/Tracer.ts index 4e17143f..185915a9 100644 --- a/src/debug/Tracer.ts +++ b/src/debug/Tracer.ts @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import Logger from "../utils/Logger"; +import Logger from "@utils/Logger"; if (IS_DEV) { var traces = {} as Record; diff --git a/src/ipcMain/index.ts b/src/ipcMain/index.ts index 535c005d..ba85eeb0 100644 --- a/src/ipcMain/index.ts +++ b/src/ipcMain/index.ts @@ -18,6 +18,9 @@ import "./updater"; +import { debounce } from "@utils/debounce"; +import IpcEvents from "@utils/IpcEvents"; +import { Queue } from "@utils/Queue"; import { BrowserWindow, desktopCapturer, ipcMain, shell } from "electron"; import { mkdirSync, readFileSync, watch } from "fs"; import { open, readFile, writeFile } from "fs/promises"; @@ -25,9 +28,6 @@ import { join } from "path"; import monacoHtml from "~fileContent/../components/monacoWin.html;base64"; -import { debounce } from "../utils/debounce"; -import IpcEvents from "../utils/IpcEvents"; -import { Queue } from "../utils/Queue"; import { ALLOWED_PROTOCOLS, QUICKCSS_PATH, SETTINGS_DIR, SETTINGS_FILE } from "./constants"; mkdirSync(SETTINGS_DIR, { recursive: true }); diff --git a/src/ipcMain/updater/git.ts b/src/ipcMain/updater/git.ts index 7e4176a8..07c94cb5 100644 --- a/src/ipcMain/updater/git.ts +++ b/src/ipcMain/updater/git.ts @@ -16,12 +16,12 @@ * along with this program. If not, see . */ +import IpcEvents from "@utils/IpcEvents"; import { execFile as cpExecFile } from "child_process"; import { ipcMain } from "electron"; import { join } from "path"; import { promisify } from "util"; -import IpcEvents from "../../utils/IpcEvents"; import { calculateHashes, serializeErrors } from "./common"; const VENCORD_SRC_DIR = join(__dirname, ".."); diff --git a/src/ipcMain/updater/http.ts b/src/ipcMain/updater/http.ts index 523340f4..902d644a 100644 --- a/src/ipcMain/updater/http.ts +++ b/src/ipcMain/updater/http.ts @@ -16,6 +16,8 @@ * along with this program. If not, see . */ +import { VENCORD_USER_AGENT } from "@utils/constants"; +import IpcEvents from "@utils/IpcEvents"; import { ipcMain } from "electron"; import { writeFile } from "fs/promises"; import { join } from "path"; @@ -23,8 +25,6 @@ import { join } from "path"; import gitHash from "~git-hash"; import gitRemote from "~git-remote"; -import { VENCORD_USER_AGENT } from "../../utils/constants"; -import IpcEvents from "../../utils/IpcEvents"; import { get } from "../simpleGet"; import { calculateHashes, serializeErrors } from "./common"; diff --git a/src/modules.d.ts b/src/modules.d.ts index 78cc9a52..6901260a 100644 --- a/src/modules.d.ts +++ b/src/modules.d.ts @@ -20,7 +20,7 @@ /// declare module "~plugins" { - const plugins: Record; + const plugins: Record; export default plugins; } diff --git a/src/patcher.ts b/src/patcher.ts index 28910b7a..12cefc01 100644 --- a/src/patcher.ts +++ b/src/patcher.ts @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +import { onceDefined } from "@utils/onceDefined"; import electron, { app, BrowserWindowConstructorOptions } from "electron"; import { readFileSync } from "fs"; import { dirname, join } from "path"; @@ -23,7 +24,6 @@ import { dirname, join } from "path"; import { initIpc } from "./ipcMain"; import { installExt } from "./ipcMain/extensions"; import { readSettings } from "./ipcMain/index"; -import { onceDefined } from "./utils/onceDefined"; console.log("[Vencord] Starting up..."); diff --git a/src/plugins/BetterNotes.ts b/src/plugins/BetterNotes.ts index 15282b6a..41842590 100644 --- a/src/plugins/BetterNotes.ts +++ b/src/plugins/BetterNotes.ts @@ -16,10 +16,10 @@ * along with this program. If not, see . */ -import { Settings } from "../api/settings"; -import { Devs } from "../utils/constants"; -import { makeLazy } from "../utils/misc"; -import definePlugin, { OptionType } from "../utils/types"; +import { Settings } from "@api/settings"; +import { Devs } from "@utils/constants"; +import { makeLazy } from "@utils/misc"; +import definePlugin, { OptionType } from "@utils/types"; export default definePlugin({ name: "BetterNotesBox", diff --git a/src/plugins/HideAttachments.tsx b/src/plugins/HideAttachments.tsx index 0789214d..2c1a0d4d 100644 --- a/src/plugins/HideAttachments.tsx +++ b/src/plugins/HideAttachments.tsx @@ -16,14 +16,13 @@ * along with this program. If not, see . */ +import { get, set } from "@api/DataStore"; +import { Devs } from "@utils/constants"; +import Logger from "@utils/Logger"; +import definePlugin from "@utils/types"; +import { ChannelStore, FluxDispatcher } from "@webpack/common"; import { Message } from "discord-types/general"; -import { get, set } from "../api/DataStore"; -import { Devs } from "../utils/constants"; -import Logger from "../utils/Logger"; -import definePlugin from "../utils/types"; -import { ChannelStore, FluxDispatcher } from "../webpack/common"; - let style: HTMLStyleElement; const KEY = "HideAttachments_HiddenIds"; diff --git a/src/plugins/TimeBarAllActivities.ts b/src/plugins/TimeBarAllActivities.ts index d4fe6397..223f1828 100644 --- a/src/plugins/TimeBarAllActivities.ts +++ b/src/plugins/TimeBarAllActivities.ts @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; export default definePlugin({ name: "TimeBarAllActivities", diff --git a/src/plugins/anonymiseFileNames.ts b/src/plugins/anonymiseFileNames.ts index c7c3ed58..f953a144 100644 --- a/src/plugins/anonymiseFileNames.ts +++ b/src/plugins/anonymiseFileNames.ts @@ -16,9 +16,9 @@ * along with this program. If not, see . */ -import { Devs } from "../utils/constants"; -import definePlugin, { OptionType } from "../utils/types"; -import { Settings } from "../Vencord"; +import { Settings } from "@api/settings"; +import { Devs } from "@utils/constants"; +import definePlugin, { OptionType } from "@utils/types"; enum Methods { Random, diff --git a/src/plugins/apiBadges.tsx b/src/plugins/apiBadges.tsx index 831bf86c..77ea46ea 100644 --- a/src/plugins/apiBadges.tsx +++ b/src/plugins/apiBadges.tsx @@ -16,17 +16,17 @@ * along with this program. If not, see . */ -import { BadgePosition, ProfileBadge } from "../api/Badges"; -import DonateButton from "../components/DonateButton"; -import ErrorBoundary from "../components/ErrorBoundary"; -import { Flex } from "../components/Flex"; -import { Heart } from "../components/Heart"; -import { Devs } from "../utils/constants"; -import IpcEvents from "../utils/IpcEvents"; -import Logger from "../utils/Logger"; -import { closeModal, Modals, openModal } from "../utils/modal"; -import definePlugin from "../utils/types"; -import { Forms, Margins } from "../webpack/common"; +import { BadgePosition, ProfileBadge } from "@api/Badges"; +import DonateButton from "@components/DonateButton"; +import ErrorBoundary from "@components/ErrorBoundary"; +import { Flex } from "@components/Flex"; +import { Heart } from "@components/Heart"; +import { Devs } from "@utils/constants"; +import IpcEvents from "@utils/IpcEvents"; +import Logger from "@utils/Logger"; +import { closeModal, Modals, openModal } from "@utils/modal"; +import definePlugin from "@utils/types"; +import { Forms, Margins } from "@webpack/common"; const CONTRIBUTOR_BADGE = "https://media.discordapp.net/stickers/1026517526106087454.webp"; diff --git a/src/plugins/apiCommands.ts b/src/plugins/apiCommands.ts index 4136deb6..e92b904e 100644 --- a/src/plugins/apiCommands.ts +++ b/src/plugins/apiCommands.ts @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; export default definePlugin({ name: "CommandsAPI", diff --git a/src/plugins/apiMenuItemDeobfuscator.ts b/src/plugins/apiMenuItemDeobfuscator.ts index 40d53f19..5703456b 100644 --- a/src/plugins/apiMenuItemDeobfuscator.ts +++ b/src/plugins/apiMenuItemDeobfuscator.ts @@ -16,9 +16,9 @@ * along with this program. If not, see . */ -import { migratePluginSettings } from "../api/settings"; -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; +import { migratePluginSettings } from "@api/settings"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; // duplicate values have multiple branches with different types. Just include all to be safe const nameMap = { diff --git a/src/plugins/apiMessageAccessories.ts b/src/plugins/apiMessageAccessories.ts index ee3ee900..0b30b58e 100644 --- a/src/plugins/apiMessageAccessories.ts +++ b/src/plugins/apiMessageAccessories.ts @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; export default definePlugin({ name: "MessageAccessoriesAPI", diff --git a/src/plugins/apiMessageEvents.ts b/src/plugins/apiMessageEvents.ts index bf7c7f58..13fbc4c3 100644 --- a/src/plugins/apiMessageEvents.ts +++ b/src/plugins/apiMessageEvents.ts @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; export default definePlugin({ name: "MessageEventsAPI", diff --git a/src/plugins/apiNotices.ts b/src/plugins/apiNotices.ts index f53c5351..a93334bd 100644 --- a/src/plugins/apiNotices.ts +++ b/src/plugins/apiNotices.ts @@ -16,9 +16,9 @@ * along with this program. If not, see . */ -import { migratePluginSettings } from "../api/settings"; -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; +import { migratePluginSettings } from "@api/settings"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; migratePluginSettings("NoticesAPI", "NoticesApi"); diff --git a/src/plugins/apiServerList.ts b/src/plugins/apiServerList.ts index 134870e2..77498ac8 100644 --- a/src/plugins/apiServerList.ts +++ b/src/plugins/apiServerList.ts @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; export default definePlugin({ name: "ServerListAPI", diff --git a/src/plugins/arRPC.tsx b/src/plugins/arRPC.tsx index 081ea481..cba3504a 100644 --- a/src/plugins/arRPC.tsx +++ b/src/plugins/arRPC.tsx @@ -16,13 +16,12 @@ * along with this program. If not, see . */ -import { popNotice, showNotice } from "../api/Notices"; -import { Link } from "../components/Link"; -import { Devs } from "../utils/constants"; -import { lazyWebpack } from "../utils/misc"; -import definePlugin from "../utils/types"; -import { filters, mapMangledModuleLazy } from "../webpack"; -import { FluxDispatcher, Forms, Toasts } from "../webpack/common"; +import { popNotice, showNotice } from "@api/Notices"; +import { Link } from "@components/Link"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; +import { filters, findByCodeLazy, mapMangledModuleLazy } from "@webpack"; +import { FluxDispatcher, Forms, Toasts } from "@webpack/common"; const assetManager = mapMangledModuleLazy( "getAssetImage: size must === [number, number] for Twitch", @@ -31,7 +30,7 @@ const assetManager = mapMangledModuleLazy( } ); -const rpcManager = lazyWebpack(filters.byCode(".APPLICATION_RPC(")); +const rpcManager = findByCodeLazy(".APPLICATION_RPC("); async function lookupAsset(applicationId: string, key: string): Promise { return (await assetManager.getAsset(applicationId, [key, undefined]))[0]; diff --git a/src/plugins/banger.ts b/src/plugins/banger.ts index 62632248..68163cbd 100644 --- a/src/plugins/banger.ts +++ b/src/plugins/banger.ts @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -import { Devs } from "../utils/constants"; -import definePlugin, { OptionType } from "../utils/types"; +import { Devs } from "@utils/constants"; +import definePlugin, { OptionType } from "@utils/types"; export default definePlugin({ name: "BANger", diff --git a/src/plugins/betterGifAltText.ts b/src/plugins/betterGifAltText.ts index 56d7b547..686ef0a5 100644 --- a/src/plugins/betterGifAltText.ts +++ b/src/plugins/betterGifAltText.ts @@ -17,8 +17,8 @@ */ -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; export default definePlugin({ name: "BetterGifAltText", diff --git a/src/plugins/betterRoleDot.ts b/src/plugins/betterRoleDot.ts index 37a2ea73..3b2ac39f 100644 --- a/src/plugins/betterRoleDot.ts +++ b/src/plugins/betterRoleDot.ts @@ -16,10 +16,10 @@ * along with this program. If not, see . */ -import { migratePluginSettings, Settings } from "../api/settings"; -import { Devs } from "../utils/constants"; -import definePlugin, { OptionType } from "../utils/types"; -import { Clipboard, Toasts } from "../webpack/common"; +import { migratePluginSettings, Settings } from "@api/settings"; +import { Devs } from "@utils/constants"; +import definePlugin, { OptionType } from "@utils/types"; +import { Clipboard, Toasts } from "@webpack/common"; migratePluginSettings("BetterRoleDot", "ClickableRoleDot"); export default definePlugin({ diff --git a/src/plugins/betterUploadButton.ts b/src/plugins/betterUploadButton.ts index 94c1f494..64a37850 100644 --- a/src/plugins/betterUploadButton.ts +++ b/src/plugins/betterUploadButton.ts @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; export default definePlugin({ name: "BetterUploadButton", diff --git a/src/plugins/blurNsfw.ts b/src/plugins/blurNsfw.ts index 8f4178f1..55218977 100644 --- a/src/plugins/blurNsfw.ts +++ b/src/plugins/blurNsfw.ts @@ -16,9 +16,9 @@ * along with this program. If not, see . */ -import { Settings } from "../api/settings"; -import { Devs } from "../utils/constants"; -import definePlugin, { OptionType } from "../utils/types"; +import { Settings } from "@api/settings"; +import { Devs } from "@utils/constants"; +import definePlugin, { OptionType } from "@utils/types"; let style: HTMLStyleElement; diff --git a/src/plugins/callTimer.tsx b/src/plugins/callTimer.tsx index 40aa1608..6a1d357c 100644 --- a/src/plugins/callTimer.tsx +++ b/src/plugins/callTimer.tsx @@ -16,11 +16,11 @@ * along with this program. If not, see . */ -import { Settings } from "../api/settings"; -import ErrorBoundary from "../components/ErrorBoundary"; -import { Devs } from "../utils/constants"; -import definePlugin, { OptionType } from "../utils/types"; -import { React } from "../webpack/common"; +import { Settings } from "@api/settings"; +import ErrorBoundary from "@components/ErrorBoundary"; +import { Devs } from "@utils/constants"; +import definePlugin, { OptionType } from "@utils/types"; +import { React } from "@webpack/common"; function formatDuration(ms: number) { // here be dragons (moment fucking sucks) diff --git a/src/plugins/clearURLs/index.ts b/src/plugins/clearURLs/index.ts index f5b89099..178a0e11 100644 --- a/src/plugins/clearURLs/index.ts +++ b/src/plugins/clearURLs/index.ts @@ -22,10 +22,11 @@ import { MessageObject, removePreEditListener, removePreSendListener -} from "../../api/MessageEvents"; -import { migratePluginSettings } from "../../api/settings"; -import { Devs } from "../../utils/constants"; -import definePlugin from "../../utils/types"; +} from "@api/MessageEvents"; +import { migratePluginSettings } from "@api/settings"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; + import { defaultRules } from "./defaultRules"; // From lodash diff --git a/src/plugins/consoleShortcuts.ts b/src/plugins/consoleShortcuts.ts index eeb5d8dc..ae0de9f8 100644 --- a/src/plugins/consoleShortcuts.ts +++ b/src/plugins/consoleShortcuts.ts @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; const WEB_ONLY = (f: string) => () => { throw new Error(`'${f}' is Discord Desktop only.`); diff --git a/src/plugins/corruptMp4s.ts b/src/plugins/corruptMp4s.ts index 05cdf5f1..5ae25eef 100644 --- a/src/plugins/corruptMp4s.ts +++ b/src/plugins/corruptMp4s.ts @@ -16,12 +16,12 @@ * along with this program. If not, see . */ -import { ApplicationCommandOptionType, sendBotMessage } from "../api/Commands"; -import { findOption } from "../api/Commands/commandHelpers"; -import { ApplicationCommandInputType } from "../api/Commands/types"; -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; -import { findByCode, findByProps } from "../webpack"; +import { ApplicationCommandOptionType, sendBotMessage } from "@api/Commands"; +import { findOption } from "@api/Commands/commandHelpers"; +import { ApplicationCommandInputType } from "@api/Commands/types"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; +import { findByCode, findByProps } from "@webpack"; const DRAFT_TYPE = 0; diff --git a/src/plugins/dictionary.ts b/src/plugins/dictionary.ts index 547636d0..14ee37b9 100644 --- a/src/plugins/dictionary.ts +++ b/src/plugins/dictionary.ts @@ -16,10 +16,10 @@ * along with this program. If not, see . */ -import { ApplicationCommandOptionType, sendBotMessage } from "../api/Commands"; -import { ApplicationCommandInputType } from "../api/Commands/types"; -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; +import { ApplicationCommandOptionType, sendBotMessage } from "@api/Commands"; +import { ApplicationCommandInputType } from "@api/Commands/types"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; export default definePlugin({ name: "UrbanDictionary", diff --git a/src/plugins/emoteCloner.tsx b/src/plugins/emoteCloner.tsx index 0b1190be..36b283e1 100644 --- a/src/plugins/emoteCloner.tsx +++ b/src/plugins/emoteCloner.tsx @@ -16,20 +16,20 @@ * along with this program. If not, see . */ -import { migratePluginSettings, Settings } from "../api/settings"; -import { CheckedTextInput } from "../components/CheckedTextInput"; -import { Devs } from "../utils/constants"; -import Logger from "../utils/Logger"; -import { lazyWebpack, makeLazy } from "../utils/misc"; -import { ModalContent, ModalHeader, ModalRoot, openModal } from "../utils/modal"; -import definePlugin from "../utils/types"; -import { filters } from "../webpack"; -import { Forms, GuildStore, Margins, Menu, PermissionStore, React, Toasts, Tooltip, UserStore } from "../webpack/common"; +import { migratePluginSettings, Settings } from "@api/settings"; +import { CheckedTextInput } from "@components/CheckedTextInput"; +import { Devs } from "@utils/constants"; +import Logger from "@utils/Logger"; +import { makeLazy } from "@utils/misc"; +import { ModalContent, ModalHeader, ModalRoot, openModal } from "@utils/modal"; +import definePlugin from "@utils/types"; +import { findByCodeLazy, findByPropsLazy } from "@webpack"; +import { Forms, GuildStore, Margins, Menu, PermissionStore, React, Toasts, Tooltip, UserStore } from "@webpack/common"; const MANAGE_EMOJIS_AND_STICKERS = 1n << 30n; -const GuildEmojiStore = lazyWebpack(filters.byProps("getGuilds", "getGuildEmoji")); -const uploadEmoji = lazyWebpack(filters.byCode('"EMOJI_UPLOAD_START"', "GUILD_EMOJIS(")); +const GuildEmojiStore = findByPropsLazy("getGuilds", "getGuildEmoji"); +const uploadEmoji = findByCodeLazy('"EMOJI_UPLOAD_START"', "GUILD_EMOJIS("); function getGuildCandidates(isAnimated: boolean) { const meId = UserStore.getCurrentUser().id; diff --git a/src/plugins/experiments.tsx b/src/plugins/experiments.tsx index 4f83c5a2..3019e64d 100644 --- a/src/plugins/experiments.tsx +++ b/src/plugins/experiments.tsx @@ -16,14 +16,13 @@ * along with this program. If not, see . */ -import { Devs } from "../utils/constants"; -import { lazyWebpack } from "../utils/misc"; -import definePlugin, { OptionType } from "../utils/types"; -import { Settings } from "../Vencord"; -import { filters } from "../webpack"; -import { Forms, React } from "../webpack/common"; +import { Settings } from "@api/settings"; +import { Devs } from "@utils/constants"; +import definePlugin, { OptionType } from "@utils/types"; +import { findByPropsLazy } from "@webpack"; +import { Forms, React } from "@webpack/common"; -const KbdStyles = lazyWebpack(filters.byProps("key", "removeBuildOverride")); +const KbdStyles = findByPropsLazy("key", "removeBuildOverride"); export default definePlugin({ name: "Experiments", diff --git a/src/plugins/fakeNitro.ts b/src/plugins/fakeNitro.ts index c6823249..0a1985a4 100644 --- a/src/plugins/fakeNitro.ts +++ b/src/plugins/fakeNitro.ts @@ -16,18 +16,16 @@ * along with this program. If not, see . */ -import { addPreEditListener, addPreSendListener, removePreEditListener, removePreSendListener } from "../api/MessageEvents"; -import { migratePluginSettings } from "../api/settings"; -import { Devs } from "../utils/constants"; -import { ApngDisposeOp, getGifEncoder, importApngJs } from "../utils/dependencies"; -import { lazyWebpack } from "../utils/misc"; -import definePlugin, { OptionType } from "../utils/types"; -import { Settings } from "../Vencord"; -import { filters } from "../webpack"; -import { ChannelStore, UserStore } from "../webpack/common"; +import { addPreEditListener, addPreSendListener, removePreEditListener, removePreSendListener } from "@api/MessageEvents"; +import { migratePluginSettings, Settings } from "@api/settings"; +import { Devs } from "@utils/constants"; +import { ApngDisposeOp, getGifEncoder, importApngJs } from "@utils/dependencies"; +import definePlugin, { OptionType } from "@utils/types"; +import { findByCodeLazy, findByPropsLazy } from "@webpack"; +import { ChannelStore, UserStore } from "@webpack/common"; const DRAFT_TYPE = 0; -const promptToUpload = lazyWebpack(filters.byCode("UPLOAD_FILE_LIMIT_ERROR")); +const promptToUpload = findByCodeLazy("UPLOAD_FILE_LIMIT_ERROR"); interface BaseSticker { available: boolean; @@ -225,8 +223,8 @@ export default definePlugin({ return; } - const EmojiStore = lazyWebpack(filters.byProps("getCustomEmojiById")); - const StickerStore = lazyWebpack(filters.byProps("getAllGuildStickers")) as { + const EmojiStore = findByPropsLazy("getCustomEmojiById"); + const StickerStore = findByPropsLazy("getAllGuildStickers") as { getPremiumPacks(): StickerPack[]; getAllGuildStickers(): Map; getStickerById(id: string): Sticker | undefined; diff --git a/src/plugins/fart.ts b/src/plugins/fart.ts index 88e95af0..9404b39b 100644 --- a/src/plugins/fart.ts +++ b/src/plugins/fart.ts @@ -16,11 +16,11 @@ * along with this program. If not, see . */ -import { ApplicationCommandOptionType } from "../api/Commands"; -import { makeRange } from "../components/PluginSettings/components"; -import { Devs } from "../utils/constants"; -import definePlugin, { OptionType } from "../utils/types"; -import { Settings } from "../Vencord"; +import { ApplicationCommandOptionType } from "@api/Commands"; +import { Settings } from "@api/settings"; +import { makeRange } from "@components/PluginSettings/components"; +import { Devs } from "@utils/constants"; +import definePlugin, { OptionType } from "@utils/types"; export default definePlugin({ name: "Fart2", diff --git a/src/plugins/forceOwnerCrown.ts b/src/plugins/forceOwnerCrown.ts index a26e6e20..9345ea75 100644 --- a/src/plugins/forceOwnerCrown.ts +++ b/src/plugins/forceOwnerCrown.ts @@ -16,9 +16,9 @@ * along with this program. If not, see . */ -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; -import { waitFor } from "../webpack"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; +import { waitFor } from "@webpack"; let GuildStore; waitFor(["getGuild"], m => GuildStore = m); diff --git a/src/plugins/friendInvites.ts b/src/plugins/friendInvites.ts index 24ca50a9..73dffd12 100644 --- a/src/plugins/friendInvites.ts +++ b/src/plugins/friendInvites.ts @@ -16,10 +16,10 @@ * along with this program. If not, see . */ -import { ApplicationCommandInputType, sendBotMessage } from "../api/Commands"; -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; -import { findByProps } from "../webpack"; +import { ApplicationCommandInputType, sendBotMessage } from "@api/Commands"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; +import { findByProps } from "@webpack"; export default definePlugin({ name: "FriendInvites", diff --git a/src/plugins/fxTwitter.ts b/src/plugins/fxTwitter.ts index 4bb00d9c..efe1ebc7 100644 --- a/src/plugins/fxTwitter.ts +++ b/src/plugins/fxTwitter.ts @@ -16,9 +16,9 @@ * along with this program. If not, see . */ -import { addPreSendListener, MessageObject, removePreSendListener } from "../api/MessageEvents"; -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; +import { addPreSendListener, MessageObject, removePreSendListener } from "@api/MessageEvents"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; const re = /https?:\/\/twitter\.com(?=\/\w+?\/status\/)/g; diff --git a/src/plugins/iLoveSpam.ts b/src/plugins/iLoveSpam.ts index 7f390f34..79b2e3fb 100644 --- a/src/plugins/iLoveSpam.ts +++ b/src/plugins/iLoveSpam.ts @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; export default definePlugin({ name: "iLoveSpam", diff --git a/src/plugins/ignoreActivities.ts b/src/plugins/ignoreActivities.ts index d33d5cc2..a39b0267 100644 --- a/src/plugins/ignoreActivities.ts +++ b/src/plugins/ignoreActivities.ts @@ -16,11 +16,10 @@ * along with this program. If not, see . */ -import { DataStore } from "../api"; -import { Devs } from "../utils/constants"; -import { lazyWebpack } from "../utils/misc"; -import definePlugin from "../utils/types"; -import { filters } from "../webpack"; +import * as DataStore from "@api/DataStore"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; +import { findByPropsLazy } from "@webpack"; interface MatchAndReplace { match: RegExp; @@ -28,7 +27,7 @@ interface MatchAndReplace { } /** Used to re-render the Registered Games tab to update how our button looks like */ -const RunningGameStoreModule = lazyWebpack(filters.byProps("IgnoreActivities_reRenderGames")); +const RunningGameStoreModule = findByPropsLazy("IgnoreActivities_reRenderGames"); let ignoredActivitiesCache: string[] = []; diff --git a/src/plugins/index.ts b/src/plugins/index.ts index 68a76cb2..c0325d41 100644 --- a/src/plugins/index.ts +++ b/src/plugins/index.ts @@ -16,13 +16,14 @@ * along with this program. If not, see . */ +import { registerCommand, unregisterCommand } from "@api/Commands"; +import { Settings } from "@api/settings"; +import Logger from "@utils/Logger"; +import { Patch, Plugin } from "@utils/types"; + import Plugins from "~plugins"; -import { registerCommand, unregisterCommand } from "../api/Commands"; -import { Settings } from "../api/settings"; import { traceFunction } from "../debug/Tracer"; -import Logger from "../utils/Logger"; -import { Patch, Plugin } from "../utils/types"; const logger = new Logger("PluginManager", "#a6d189"); diff --git a/src/plugins/keepCurrentChannel.ts b/src/plugins/keepCurrentChannel.ts index 395fd768..0d7147c7 100644 --- a/src/plugins/keepCurrentChannel.ts +++ b/src/plugins/keepCurrentChannel.ts @@ -16,10 +16,10 @@ * along with this program. If not, see . */ -import { DataStore } from "../api"; -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; -import { ChannelStore, FluxDispatcher, NavigationRouter, SelectedChannelStore, SelectedGuildStore } from "../webpack/common"; +import * as DataStore from "@api/DataStore"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; +import { ChannelStore, FluxDispatcher, NavigationRouter, SelectedChannelStore, SelectedGuildStore } from "@webpack/common"; export interface LogoutEvent { type: "LOGOUT"; diff --git a/src/plugins/lastfm.tsx b/src/plugins/lastfm.tsx index 280c0ee3..bf3f63c9 100644 --- a/src/plugins/lastfm.tsx +++ b/src/plugins/lastfm.tsx @@ -16,43 +16,43 @@ * along with this program. If not, see . */ -import { Link } from "../components/Link"; -import { Devs } from "../utils/constants"; -import { lazyWebpack } from "../utils/misc"; -import definePlugin, { OptionType } from "../utils/types"; -import { Settings, Webpack } from "../Vencord"; -import { FluxDispatcher, Forms } from "../webpack/common"; +import { Settings } from "@api/settings"; +import { Link } from "@components/Link"; +import { Devs } from "@utils/constants"; +import definePlugin, { OptionType } from "@utils/types"; +import { filters, findByPropsLazy, mapMangledModuleLazy } from "@webpack"; +import { FluxDispatcher, Forms } from "@webpack/common"; interface ActivityAssets { - large_image?: string - large_text?: string - small_image?: string - small_text?: string + large_image?: string; + large_text?: string; + small_image?: string; + small_text?: string; } interface Activity { - state: string - details?: string + state: string; + details?: string; timestamps?: { - start?: Number - } - assets?: ActivityAssets - buttons?: Array - name: string - application_id: string + start?: Number; + }; + assets?: ActivityAssets; + buttons?: Array; + name: string; + application_id: string; metadata?: { - button_urls?: Array - } - type: Number - flags: Number + button_urls?: Array; + }; + type: Number; + flags: Number; } interface TrackData { - name: string - album: string - artist: string - url: string - imageUrl?: string + name: string; + album: string; + artist: string; + url: string; + imageUrl?: string; } // only relevant enum values @@ -67,11 +67,11 @@ enum ActivityFlag { const applicationId = "1043533871037284423"; -const presenceStore = lazyWebpack(Webpack.filters.byProps("getLocalPresence")); -const assetManager = Webpack.mapMangledModuleLazy( +const presenceStore = findByPropsLazy("getLocalPresence"); +const assetManager = mapMangledModuleLazy( "getAssetImage: size must === [number, number] for Twitch", { - getAsset: Webpack.filters.byCode("apply("), + getAsset: filters.byCode("apply("), } ); @@ -196,9 +196,9 @@ export default definePlugin({ state: hideAlbumName ? trackData.artist : `${trackData.artist} - ${trackData.album}`, assets, - buttons: [ "Open in Last.fm" ], + buttons: ["Open in Last.fm"], metadata: { - button_urls: [ trackData.url ] + button_urls: [trackData.url] }, type: this.settings.useListeningStatus ? ActivityType.LISTENING : ActivityType.PLAYING, diff --git a/src/plugins/loadingQuotes.ts b/src/plugins/loadingQuotes.ts index 7ee55d8e..052bfe6e 100644 --- a/src/plugins/loadingQuotes.ts +++ b/src/plugins/loadingQuotes.ts @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; // These are Xor encrypted to prevent you from spoiling yourself when you read the source code. // don't worry about it :P diff --git a/src/plugins/messageActions.ts b/src/plugins/messageActions.ts index 05d792f1..df4d0161 100644 --- a/src/plugins/messageActions.ts +++ b/src/plugins/messageActions.ts @@ -16,13 +16,12 @@ * along with this program. If not, see . */ -import { addClickListener, removeClickListener } from "../api/MessageEvents"; -import { migratePluginSettings } from "../api/settings"; -import { Devs } from "../utils/constants"; -import { lazyWebpack } from "../utils/misc"; -import definePlugin from "../utils/types"; -import { filters } from "../webpack"; -import { UserStore } from "../webpack/common"; +import { addClickListener, removeClickListener } from "@api/MessageEvents"; +import { migratePluginSettings } from "@api/settings"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; +import { findByPropsLazy, findLazy } from "@webpack"; +import { UserStore } from "@webpack/common"; let isDeletePressed = false; const keydown = (e: KeyboardEvent) => e.key === "Backspace" && (isDeletePressed = true); @@ -37,10 +36,10 @@ export default definePlugin({ dependencies: ["MessageEventsAPI"], start() { - const MessageActions = lazyWebpack(filters.byProps("deleteMessage", "startEditMessage")); - const PermissionStore = lazyWebpack(filters.byProps("can", "initialize")); - const Permissions = lazyWebpack(m => typeof m.MANAGE_MESSAGES === "bigint"); - const EditStore = lazyWebpack(filters.byProps("isEditing", "isEditingAny")); + const MessageActions = findByPropsLazy("deleteMessage", "startEditMessage"); + const PermissionStore = findByPropsLazy("can", "initialize"); + const Permissions = findLazy(m => typeof m.MANAGE_MESSAGES === "bigint"); + const EditStore = findByPropsLazy("isEditing", "isEditingAny"); document.addEventListener("keydown", keydown); document.addEventListener("keyup", keyup); diff --git a/src/plugins/messageLogger/index.tsx b/src/plugins/messageLogger/index.tsx index 7b6bf56b..5a1ac92e 100644 --- a/src/plugins/messageLogger/index.tsx +++ b/src/plugins/messageLogger/index.tsx @@ -16,14 +16,13 @@ * along with this program. If not, see . */ -import { Settings } from "../../api/settings"; -import ErrorBoundary from "../../components/ErrorBoundary"; -import { Devs } from "../../utils/constants"; -import Logger from "../../utils/Logger"; -import { lazyWebpack } from "../../utils/misc"; -import definePlugin, { OptionType } from "../../utils/types"; -import { filters } from "../../webpack"; -import { Parser, UserStore } from "../../webpack/common"; +import { Settings } from "@api/settings"; +import ErrorBoundary from "@components/ErrorBoundary"; +import { Devs } from "@utils/constants"; +import Logger from "@utils/Logger"; +import definePlugin, { OptionType } from "@utils/types"; +import { findByPropsLazy } from "@webpack"; +import { Parser, UserStore } from "@webpack/common"; function addDeleteStyleClass() { if (Settings.plugins.MessageLogger.deleteStyle === "text") { @@ -74,8 +73,8 @@ export default definePlugin({ `, start() { - this.moment = lazyWebpack(filters.byProps("relativeTimeRounding", "relativeTimeThreshold")); - this.timestampModule = lazyWebpack(filters.byProps("messageLogger_TimestampComponent")); + this.moment = findByPropsLazy("relativeTimeRounding", "relativeTimeThreshold"); + this.timestampModule = findByPropsLazy("messageLogger_TimestampComponent"); const style = this.style = document.createElement("style"); style.textContent = this.css; diff --git a/src/plugins/messageTags.ts b/src/plugins/messageTags.ts index bf01cad2..490edc34 100644 --- a/src/plugins/messageTags.ts +++ b/src/plugins/messageTags.ts @@ -16,11 +16,11 @@ * along with this program. If not, see . */ -import { DataStore } from "../api"; -import { ApplicationCommandInputType, ApplicationCommandOptionType, findOption, registerCommand, sendBotMessage, unregisterCommand } from "../api/Commands"; -import { Settings } from "../api/settings"; -import { Devs } from "../utils/constants"; -import definePlugin, { OptionType } from "../utils/types"; +import { ApplicationCommandInputType, ApplicationCommandOptionType, findOption, registerCommand, sendBotMessage, unregisterCommand } from "@api/Commands"; +import * as DataStore from "@api/DataStore"; +import { Settings } from "@api/settings"; +import { Devs } from "@utils/constants"; +import definePlugin, { OptionType } from "@utils/types"; const EMOTE = "<:luna:1035316192220553236>"; const DATA_KEY = "MessageTags_TAGS"; diff --git a/src/plugins/moreCommands.ts b/src/plugins/moreCommands.ts index 0a23aafb..61312acc 100644 --- a/src/plugins/moreCommands.ts +++ b/src/plugins/moreCommands.ts @@ -16,9 +16,9 @@ * along with this program. If not, see . */ -import { ApplicationCommandInputType, findOption, OptionalMessageOption, RequiredMessageOption, sendBotMessage } from "../api/Commands"; -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; +import { ApplicationCommandInputType, findOption, OptionalMessageOption, RequiredMessageOption, sendBotMessage } from "@api/Commands"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; function mock(input: string): string { diff --git a/src/plugins/moreKaomoji.ts b/src/plugins/moreKaomoji.ts index ef6dc0fd..a5e40d22 100644 --- a/src/plugins/moreKaomoji.ts +++ b/src/plugins/moreKaomoji.ts @@ -16,10 +16,10 @@ * along with this program. If not, see . */ -import { findOption, OptionalMessageOption } from "../api/Commands"; -import { migratePluginSettings } from "../api/settings"; -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; +import { findOption, OptionalMessageOption } from "@api/Commands"; +import { migratePluginSettings } from "@api/settings"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; migratePluginSettings("MoreKaomoji", "moarKaomojis"); export default definePlugin({ diff --git a/src/plugins/moyai.ts b/src/plugins/moyai.ts index 5427fed6..fabc97fb 100644 --- a/src/plugins/moyai.ts +++ b/src/plugins/moyai.ts @@ -16,15 +16,14 @@ * along with this program. If not, see . */ +import { Settings } from "@api/settings"; +import { makeRange } from "@components/PluginSettings/components/SettingSliderComponent"; +import { Devs } from "@utils/constants"; +import { sleep } from "@utils/misc"; +import definePlugin, { OptionType } from "@utils/types"; +import { FluxDispatcher, SelectedChannelStore, UserStore } from "@webpack/common"; import { Message, ReactionEmoji } from "discord-types/general"; -import { makeRange } from "../components/PluginSettings/components/SettingSliderComponent"; -import { Devs } from "../utils/constants"; -import { sleep } from "../utils/misc"; -import definePlugin, { OptionType } from "../utils/types"; -import { Settings } from "../Vencord"; -import { FluxDispatcher, SelectedChannelStore, UserStore } from "../webpack/common"; - interface IMessageCreate { type: "MESSAGE_CREATE"; optimistic: boolean; diff --git a/src/plugins/muteNewGuild.ts b/src/plugins/muteNewGuild.ts index e4ca1d5d..12b9b60f 100644 --- a/src/plugins/muteNewGuild.ts +++ b/src/plugins/muteNewGuild.ts @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; export default definePlugin({ name: "MuteNewGuild", diff --git a/src/plugins/noBlockedMessages.ts b/src/plugins/noBlockedMessages.ts index e46e7c3f..bd72ce5f 100644 --- a/src/plugins/noBlockedMessages.ts +++ b/src/plugins/noBlockedMessages.ts @@ -16,12 +16,12 @@ * along with this program. If not, see . */ -import { Devs } from "../utils/constants"; -import { lazyWebpack } from "../utils/misc"; -import definePlugin, { OptionType } from "../utils/types"; -import { Settings } from "../Vencord"; -import { filters } from "../webpack"; -const RelationshipStore = lazyWebpack(filters.byProps("getRelationships", "isBlocked")); +import { Settings } from "@api/settings"; +import { Devs } from "@utils/constants"; +import definePlugin, { OptionType } from "@utils/types"; +import { findByPropsLazy } from "@webpack"; + +const RelationshipStore = findByPropsLazy("getRelationships", "isBlocked"); export default definePlugin({ name: "NoBlockedMessages", diff --git a/src/plugins/noCanaryMessageLinks.ts b/src/plugins/noCanaryMessageLinks.ts index 67c91762..ebd6782d 100644 --- a/src/plugins/noCanaryMessageLinks.ts +++ b/src/plugins/noCanaryMessageLinks.ts @@ -16,10 +16,10 @@ * along with this program. If not, see . */ -import { addPreSendListener, MessageObject, removePreSendListener } from "../api/MessageEvents"; -import { Devs } from "../utils/constants"; -import definePlugin, { OptionType } from "../utils/types"; -import { Settings } from "../Vencord"; +import { addPreSendListener, MessageObject, removePreSendListener } from "@api/MessageEvents"; +import { Settings } from "@api/settings"; +import { Devs } from "@utils/constants"; +import definePlugin, { OptionType } from "@utils/types"; export default definePlugin({ name: "NoCanaryMessageLinks", diff --git a/src/plugins/noDevtoolsWarning.ts b/src/plugins/noDevtoolsWarning.ts index 2ceb0c3f..8980ed8f 100644 --- a/src/plugins/noDevtoolsWarning.ts +++ b/src/plugins/noDevtoolsWarning.ts @@ -16,9 +16,9 @@ * along with this program. If not, see . */ -import { migratePluginSettings } from "../api/settings"; -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; +import { migratePluginSettings } from "@api/settings"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; migratePluginSettings("NoDevtoolsWarning", "STFU"); diff --git a/src/plugins/noF1.ts b/src/plugins/noF1.ts index 22e351a5..5c23b73c 100644 --- a/src/plugins/noF1.ts +++ b/src/plugins/noF1.ts @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; export default definePlugin({ name: "No F1", diff --git a/src/plugins/noRPC.ts b/src/plugins/noRPC.ts index ca82c2bd..e56c7af5 100644 --- a/src/plugins/noRPC.ts +++ b/src/plugins/noRPC.ts @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; export default definePlugin({ name: "No RPC", diff --git a/src/plugins/noReplyMention.ts b/src/plugins/noReplyMention.ts index 2e5e9695..620274c6 100644 --- a/src/plugins/noReplyMention.ts +++ b/src/plugins/noReplyMention.ts @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; export default definePlugin({ name: "NoReplyMention", diff --git a/src/plugins/noSystemBadge.ts b/src/plugins/noSystemBadge.ts index 2571be5a..e487a974 100644 --- a/src/plugins/noSystemBadge.ts +++ b/src/plugins/noSystemBadge.ts @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; export default definePlugin({ name: "NoSystemBadge", diff --git a/src/plugins/noTrack.ts b/src/plugins/noTrack.ts index a86e0aff..27ff430b 100644 --- a/src/plugins/noTrack.ts +++ b/src/plugins/noTrack.ts @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; export default definePlugin({ name: "NoTrack", diff --git a/src/plugins/noUnblockToJump.ts b/src/plugins/noUnblockToJump.ts index e0194ca2..15f602b5 100644 --- a/src/plugins/noUnblockToJump.ts +++ b/src/plugins/noUnblockToJump.ts @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; export default definePlugin({ diff --git a/src/plugins/oneko.ts b/src/plugins/oneko.ts index 67db2d76..ef2f5d68 100644 --- a/src/plugins/oneko.ts +++ b/src/plugins/oneko.ts @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; export default definePlugin({ name: "oneko", diff --git a/src/plugins/petpet.ts b/src/plugins/petpet.ts index 7a794fd4..a8281d06 100644 --- a/src/plugins/petpet.ts +++ b/src/plugins/petpet.ts @@ -16,12 +16,12 @@ * along with this program. If not, see . */ -import { ApplicationCommandInputType, ApplicationCommandOptionType, Argument, CommandContext, findOption, sendBotMessage } from "../api/Commands"; -import { Devs } from "../utils/constants"; -import { getGifEncoder } from "../utils/dependencies"; -import { lazyWebpack, makeLazy } from "../utils/misc"; -import definePlugin from "../utils/types"; -import { filters } from "../webpack"; +import { ApplicationCommandInputType, ApplicationCommandOptionType, Argument, CommandContext, findOption, sendBotMessage } from "@api/Commands"; +import { Devs } from "@utils/constants"; +import { getGifEncoder } from "@utils/dependencies"; +import { makeLazy } from "@utils/misc"; +import definePlugin from "@utils/types"; +import { findByCodeLazy, findByPropsLazy } from "@webpack"; const DRAFT_TYPE = 0; const DEFAULT_DELAY = 20; @@ -35,9 +35,9 @@ const getFrames = makeLazy(() => Promise.all( )) ); -const fetchUser = lazyWebpack(filters.byCode(".USER(")); -const promptToUpload = lazyWebpack(filters.byCode("UPLOAD_FILE_LIMIT_ERROR")); -const UploadStore = lazyWebpack(filters.byProps("getUploads")); +const fetchUser = findByCodeLazy(".USER("); +const promptToUpload = findByCodeLazy("UPLOAD_FILE_LIMIT_ERROR"); +const UploadStore = findByPropsLazy("getUploads"); function loadImage(source: File | string) { const isFile = source instanceof File; diff --git a/src/plugins/plainFolderIcon.ts b/src/plugins/plainFolderIcon.ts index 35f903fa..5c01ea93 100644 --- a/src/plugins/plainFolderIcon.ts +++ b/src/plugins/plainFolderIcon.ts @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; export default definePlugin({ name: "PlainFolderIcon", diff --git a/src/plugins/platformIndicators.tsx b/src/plugins/platformIndicators.tsx index 1c9bbf17..5cae38f0 100644 --- a/src/plugins/platformIndicators.tsx +++ b/src/plugins/platformIndicators.tsx @@ -16,16 +16,14 @@ * along with this program. If not, see . */ +import { Settings } from "@api/settings"; +import ErrorBoundary from "@components/ErrorBoundary"; +import { Devs } from "@utils/constants"; +import definePlugin, { OptionType } from "@utils/types"; +import { findByCodeLazy } from "@webpack"; +import { PresenceStore, Tooltip } from "@webpack/common"; import { User } from "discord-types/general"; -import { Settings } from "../api/settings"; -import ErrorBoundary from "../components/ErrorBoundary"; -import { Devs } from "../utils/constants"; -import { lazyWebpack } from "../utils/misc"; -import definePlugin, { OptionType } from "../utils/types"; -import { filters } from "../webpack"; -import { PresenceStore, Tooltip } from "../webpack/common"; - function Icon(path: string, viewBox = "0 0 24 24") { return ({ color, tooltip }: { color: string; tooltip: string; }) => ( @@ -52,7 +50,7 @@ const Icons = { }; type Platform = keyof typeof Icons; -const getStatusColor = lazyWebpack(filters.byCode("STATUS_YELLOW", "TWITCH", "STATUS_GREY")); +const getStatusColor = findByCodeLazy("STATUS_YELLOW", "TWITCH", "STATUS_GREY"); const PlatformIcon = ({ platform, status }: { platform: Platform, status: string; }) => { const tooltip = platform[0].toUpperCase() + platform.slice(1); diff --git a/src/plugins/pronoundb/components/PronounsAboutComponent.tsx b/src/plugins/pronoundb/components/PronounsAboutComponent.tsx index 3f288d5e..255c6d35 100644 --- a/src/plugins/pronoundb/components/PronounsAboutComponent.tsx +++ b/src/plugins/pronoundb/components/PronounsAboutComponent.tsx @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -import { Link } from "../../../components/Link"; -import { Forms, React } from "../../../webpack/common"; +import { Link } from "@components/Link"; +import { Forms, React } from "@webpack/common"; export default function PronounsAboutComponent() { return ( diff --git a/src/plugins/pronoundb/components/PronounsChatComponent.tsx b/src/plugins/pronoundb/components/PronounsChatComponent.tsx index 57033ccb..9225fc52 100644 --- a/src/plugins/pronoundb/components/PronounsChatComponent.tsx +++ b/src/plugins/pronoundb/components/PronounsChatComponent.tsx @@ -16,16 +16,16 @@ * along with this program. If not, see . */ +import { Settings } from "@api/settings"; +import { classes, useAwaiter } from "@utils/misc"; +import { findByPropsLazy } from "@webpack"; +import { UserStore } from "@webpack/common"; import { Message } from "discord-types/general"; -import { classes, lazyWebpack, useAwaiter } from "../../../utils/misc"; -import { Settings } from "../../../Vencord"; -import { filters } from "../../../webpack"; -import { UserStore } from "../../../webpack/common"; import { fetchPronouns, formatPronouns } from "../pronoundbUtils"; import { PronounMapping } from "../types"; -const styles: Record = lazyWebpack(filters.byProps("timestampInline")); +const styles: Record = findByPropsLazy("timestampInline"); export default function PronounsChatComponentWrapper({ message }: { message: Message; }) { // Don't bother fetching bot or system users diff --git a/src/plugins/pronoundb/components/PronounsProfileWrapper.tsx b/src/plugins/pronoundb/components/PronounsProfileWrapper.tsx index b39f4ed3..9540bb9e 100644 --- a/src/plugins/pronoundb/components/PronounsProfileWrapper.tsx +++ b/src/plugins/pronoundb/components/PronounsProfileWrapper.tsx @@ -16,9 +16,10 @@ * along with this program. If not, see . */ -import { useAwaiter } from "../../../utils/misc"; -import { Settings } from "../../../Vencord"; -import { UserStore } from "../../../webpack/common"; +import { Settings } from "@api/settings"; +import { useAwaiter } from "@utils/misc"; +import { UserStore } from "@webpack/common"; + import { fetchPronouns, formatPronouns } from "../pronoundbUtils"; import { PronounMapping, UserProfilePronounsProps, UserProfileProps } from "../types"; diff --git a/src/plugins/pronoundb/index.ts b/src/plugins/pronoundb/index.ts index 39637e2e..49b25f75 100644 --- a/src/plugins/pronoundb/index.ts +++ b/src/plugins/pronoundb/index.ts @@ -16,8 +16,9 @@ * along with this program. If not, see . */ -import { Devs } from "../../utils/constants"; -import definePlugin, { OptionType } from "../../utils/types"; +import { Devs } from "@utils/constants"; +import definePlugin, { OptionType } from "@utils/types"; + import PronounsAboutComponent from "./components/PronounsAboutComponent"; import PronounsChatComponent from "./components/PronounsChatComponent"; import PronounsProfileWrapper from "./components/PronounsProfileWrapper"; diff --git a/src/plugins/pronoundb/pronoundbUtils.ts b/src/plugins/pronoundb/pronoundbUtils.ts index 73ec7b6c..afeea958 100644 --- a/src/plugins/pronoundb/pronoundbUtils.ts +++ b/src/plugins/pronoundb/pronoundbUtils.ts @@ -16,9 +16,10 @@ * along with this program. If not, see . */ -import { VENCORD_USER_AGENT } from "../../utils/constants"; -import { debounce } from "../../utils/debounce"; -import { Settings } from "../../Vencord"; +import { Settings } from "@api/settings"; +import { VENCORD_USER_AGENT } from "@utils/constants"; +import { debounce } from "@utils/debounce"; + import { PronounsFormat } from "."; import { PronounCode, PronounMapping, PronounsResponse } from "./types"; diff --git a/src/plugins/quickMention.tsx b/src/plugins/quickMention.tsx index 0f8410b8..1c0a6c6c 100644 --- a/src/plugins/quickMention.tsx +++ b/src/plugins/quickMention.tsx @@ -16,11 +16,11 @@ * along with this program. If not, see . */ -import { Devs } from "../utils/constants"; -import { lazyWebpack } from "../utils/misc"; -import definePlugin from "../utils/types"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; +import { findLazy } from "@webpack"; -const ComponentDispatch = lazyWebpack(m => m.emitter?._events?.INSERT_TEXT); +const ComponentDispatch = findLazy(m => m.emitter?._events?.INSERT_TEXT); export default definePlugin({ name: "QuickMention", diff --git a/src/plugins/quickReply.ts b/src/plugins/quickReply.ts index 2903b398..a499ea41 100644 --- a/src/plugins/quickReply.ts +++ b/src/plugins/quickReply.ts @@ -16,16 +16,14 @@ * along with this program. If not, see . */ +import { migratePluginSettings } from "@api/settings"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; +import { findByPropsLazy } from "@webpack"; +import { ChannelStore, FluxDispatcher as Dispatcher, MessageStore, SelectedChannelStore, UserStore } from "@webpack/common"; import { Message } from "discord-types/general"; -import { migratePluginSettings } from "../api/settings"; -import { Devs } from "../utils/constants"; -import { lazyWebpack } from "../utils/misc"; -import definePlugin from "../utils/types"; -import { filters } from "../webpack"; -import { ChannelStore, FluxDispatcher as Dispatcher, MessageStore, SelectedChannelStore, UserStore } from "../webpack/common"; - -const Kangaroo = lazyWebpack(filters.byProps("jumpToMessage")); +const Kangaroo = findByPropsLazy("jumpToMessage"); const isMac = navigator.platform.includes("Mac"); // bruh let replyIdx = -1; diff --git a/src/plugins/readAllNotificationsButton.tsx b/src/plugins/readAllNotificationsButton.tsx index 615702b4..ee6ecde3 100644 --- a/src/plugins/readAllNotificationsButton.tsx +++ b/src/plugins/readAllNotificationsButton.tsx @@ -16,10 +16,10 @@ * along with this program. If not, see . */ -import { addServerListElement, removeServerListElement, ServerListRenderPosition } from "../api/ServerList"; -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; -import { Button, FluxDispatcher, GuildChannelStore, GuildStore, React, ReadStateStore } from "../webpack/common"; +import { addServerListElement, removeServerListElement, ServerListRenderPosition } from "@api/ServerList"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; +import { Button, FluxDispatcher, GuildChannelStore, GuildStore, React, ReadStateStore } from "@webpack/common"; function onClick() { const channels: Array = []; diff --git a/src/plugins/reverseImageSearch.tsx b/src/plugins/reverseImageSearch.tsx index 804ac048..26e10038 100644 --- a/src/plugins/reverseImageSearch.tsx +++ b/src/plugins/reverseImageSearch.tsx @@ -16,9 +16,9 @@ * along with this program. If not, see . */ -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; -import { Menu } from "../webpack/common"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; +import { Menu } from "@webpack/common"; const Engines = { Google: "https://www.google.com/searchbyimage?image_url=", diff --git a/src/plugins/reviewDB/Utils/ReviewDBAPI.ts b/src/plugins/reviewDB/Utils/ReviewDBAPI.ts index 71e6e81c..a4c8dbfd 100644 --- a/src/plugins/reviewDB/Utils/ReviewDBAPI.ts +++ b/src/plugins/reviewDB/Utils/ReviewDBAPI.ts @@ -16,7 +16,8 @@ * along with this program. If not, see . */ -import { Settings } from "../../../Vencord"; +import { Settings } from "@api/settings"; + import { Review } from "../entities/Review"; import { authorize, showToast } from "./Utils"; diff --git a/src/plugins/reviewDB/Utils/Utils.tsx b/src/plugins/reviewDB/Utils/Utils.tsx index 1093c956..79d768c8 100644 --- a/src/plugins/reviewDB/Utils/Utils.tsx +++ b/src/plugins/reviewDB/Utils/Utils.tsx @@ -16,12 +16,13 @@ * along with this program. If not, see . */ -import { Devs } from "../../../utils/constants"; -import Logger from "../../../utils/Logger"; -import { openModal } from "../../../utils/modal"; -import { Settings } from "../../../Vencord"; -import { findByProps } from "../../../webpack"; -import { FluxDispatcher, React, SelectedChannelStore, Toasts, UserUtils } from "../../../webpack/common"; +import { Settings } from "@api/settings"; +import { Devs } from "@utils/constants"; +import Logger from "@utils/Logger"; +import { openModal } from "@utils/modal"; +import { findByProps } from "@webpack"; +import { FluxDispatcher, React, SelectedChannelStore, Toasts, UserUtils } from "@webpack/common"; + import { Review } from "../entities/Review"; export async function openUserProfileModal(userId: string) { diff --git a/src/plugins/reviewDB/components/MessageButton.tsx b/src/plugins/reviewDB/components/MessageButton.tsx index 7d16630c..c334ddd3 100644 --- a/src/plugins/reviewDB/components/MessageButton.tsx +++ b/src/plugins/reviewDB/components/MessageButton.tsx @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -import { classes, LazyComponent } from "../../../utils/misc"; -import { findByProps } from "../../../webpack"; +import { classes, LazyComponent } from "@utils/misc"; +import { findByProps } from "@webpack"; export default LazyComponent(() => { const { button, dangerous } = findByProps("button", "wrapper", "disabled"); diff --git a/src/plugins/reviewDB/components/ReviewComponent.tsx b/src/plugins/reviewDB/components/ReviewComponent.tsx index ecd12dac..8808ccd5 100644 --- a/src/plugins/reviewDB/components/ReviewComponent.tsx +++ b/src/plugins/reviewDB/components/ReviewComponent.tsx @@ -16,9 +16,10 @@ * along with this program. If not, see . */ -import { classes, LazyComponent } from "../../../utils/misc"; -import { filters, findBulk } from "../../../webpack"; -import { Alerts, UserStore } from "../../../webpack/common"; +import { classes, LazyComponent } from "@utils/misc"; +import { filters, findBulk } from "@webpack"; +import { Alerts, UserStore } from "@webpack/common"; + import { Review } from "../entities/Review"; import { deleteReview, reportReview } from "../Utils/ReviewDBAPI"; import { canDeleteReview, openUserProfileModal, showToast } from "../Utils/Utils"; diff --git a/src/plugins/reviewDB/components/ReviewsView.tsx b/src/plugins/reviewDB/components/ReviewsView.tsx index 363b6249..999b9700 100644 --- a/src/plugins/reviewDB/components/ReviewsView.tsx +++ b/src/plugins/reviewDB/components/ReviewsView.tsx @@ -16,14 +16,15 @@ * along with this program. If not, see . */ +import { classes, useAwaiter } from "@utils/misc"; +import { findLazy } from "@webpack"; +import { Forms, Text, UserStore } from "@webpack/common"; import type { KeyboardEvent } from "react"; -import { classes, lazyWebpack, useAwaiter } from "../../../utils/misc"; -import { Forms, Text, UserStore } from "../../../webpack/common"; import { addReview, getReviews } from "../Utils/ReviewDBAPI"; import ReviewComponent from "./ReviewComponent"; -const Classes = lazyWebpack(m => typeof m.textarea === "string"); +const Classes = findLazy(m => typeof m.textarea === "string"); export default function ReviewsView({ userId }: { userId: string; }) { const [reviews, _, isLoading, refetch] = useAwaiter(() => getReviews(userId), []); diff --git a/src/plugins/reviewDB/index.tsx b/src/plugins/reviewDB/index.tsx index 0349ea9d..744c2d62 100644 --- a/src/plugins/reviewDB/index.tsx +++ b/src/plugins/reviewDB/index.tsx @@ -16,13 +16,13 @@ * along with this program. If not, see . */ +import { Settings } from "@api/settings"; +import ErrorBoundary from "@components/ErrorBoundary"; +import { Devs } from "@utils/constants"; +import definePlugin, { OptionType } from "@utils/types"; +import { Button, UserStore } from "@webpack/common"; import { User } from "discord-types/general"; -import ErrorBoundary from "../../components/ErrorBoundary"; -import { Devs } from "../../utils/constants"; -import definePlugin, { OptionType } from "../../utils/types"; -import { Settings } from "../../Vencord"; -import { Button, UserStore } from "../../webpack/common"; import ReviewsView from "./components/ReviewsView"; import { getLastReviewID } from "./Utils/ReviewDBAPI"; import { authorize, showToast } from "./Utils/Utils"; diff --git a/src/plugins/settings.tsx b/src/plugins/settings.tsx index 27775725..975c3992 100644 --- a/src/plugins/settings.tsx +++ b/src/plugins/settings.tsx @@ -16,11 +16,11 @@ * along with this program. If not, see . */ -import gitHash from "~git-hash"; +import { Devs } from "@utils/constants"; +import { LazyComponent } from "@utils/misc"; +import definePlugin from "@utils/types"; -import { Devs } from "../utils/constants"; -import { LazyComponent } from "../utils/misc"; -import definePlugin from "../utils/types"; +import gitHash from "~git-hash"; const SettingsComponent = LazyComponent(() => require("../components/VencordSettings").default); diff --git a/src/plugins/showHiddenChannels.tsx b/src/plugins/showHiddenChannels.tsx index 8dc92bfe..70b8406f 100644 --- a/src/plugins/showHiddenChannels.tsx +++ b/src/plugins/showHiddenChannels.tsx @@ -17,13 +17,13 @@ */ -import { Flex } from "../components/Flex"; -import { Devs } from "../utils/constants"; -import { ModalContent, ModalFooter, ModalHeader, ModalRoot, ModalSize, openModal } from "../utils/modal"; -import definePlugin, { OptionType } from "../utils/types"; -import { Settings } from "../Vencord"; -import { waitFor } from "../webpack"; -import { Button, ChannelStore, Text } from "../webpack/common"; +import { Settings } from "@api/settings"; +import { Flex } from "@components/Flex"; +import { Devs } from "@utils/constants"; +import { ModalContent, ModalFooter, ModalHeader, ModalRoot, ModalSize, openModal } from "@utils/modal"; +import definePlugin, { OptionType } from "@utils/types"; +import { waitFor } from "@webpack"; +import { Button, ChannelStore, Text } from "@webpack/common"; const CONNECT = 1048576n; const VIEW_CHANNEL = 1024n; diff --git a/src/plugins/silentTyping.ts b/src/plugins/silentTyping.ts index 1f791251..8680a866 100644 --- a/src/plugins/silentTyping.ts +++ b/src/plugins/silentTyping.ts @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; export default definePlugin({ name: "SilentTyping", diff --git a/src/plugins/spotifyControls/PlayerComponent.tsx b/src/plugins/spotifyControls/PlayerComponent.tsx index 6396e020..24394c6f 100644 --- a/src/plugins/spotifyControls/PlayerComponent.tsx +++ b/src/plugins/spotifyControls/PlayerComponent.tsx @@ -16,13 +16,14 @@ * along with this program. If not, see . */ -import ErrorBoundary from "../../components/ErrorBoundary"; -import { Flex } from "../../components/Flex"; -import { Link } from "../../components/Link"; -import { debounce } from "../../utils/debounce"; -import { classes, LazyComponent, lazyWebpack } from "../../utils/misc"; -import { ContextMenu, FluxDispatcher, Forms, Menu, React } from "../../webpack/common"; -import { filters, find } from "../../webpack/webpack"; +import ErrorBoundary from "@components/ErrorBoundary"; +import { Flex } from "@components/Flex"; +import { Link } from "@components/Link"; +import { debounce } from "@utils/debounce"; +import { classes, LazyComponent } from "@utils/misc"; +import { filters, find, findByCodeLazy } from "@webpack"; +import { ContextMenu, FluxDispatcher, Forms, Menu, React } from "@webpack/common"; + import { SpotifyStore, Track } from "./SpotifyStore"; const cl = (className: string) => `vc-spotify-${className}`; @@ -40,7 +41,7 @@ const useStateFromStores: ( idk?: null, compare?: (old: T, newer: T) => boolean ) => T - = lazyWebpack(filters.byCode("useStateFromStores")); + = findByCodeLazy("useStateFromStores"); function Svg(path: string, label: string) { return () => ( diff --git a/src/plugins/spotifyControls/SpotifyStore.ts b/src/plugins/spotifyControls/SpotifyStore.ts index 14f23318..75448dc2 100644 --- a/src/plugins/spotifyControls/SpotifyStore.ts +++ b/src/plugins/spotifyControls/SpotifyStore.ts @@ -16,13 +16,12 @@ * along with this program. If not, see . */ -import cssText from "~fileContent/spotifyStyles.css"; +import IpcEvents from "@utils/IpcEvents"; +import { proxyLazy } from "@utils/proxyLazy"; +import { findByPropsLazy } from "@webpack"; +import { Flux, FluxDispatcher } from "@webpack/common"; -import IpcEvents from "../../utils/IpcEvents"; -import { lazyWebpack } from "../../utils/misc"; -import { proxyLazy } from "../../utils/proxyLazy"; -import { filters } from "../../webpack"; -import { Flux, FluxDispatcher } from "../../webpack/common"; +import cssText from "~fileContent/spotifyStyles.css"; export interface Track { id: string; @@ -78,8 +77,8 @@ export const SpotifyStore = proxyLazy(() => { // For some reason ts hates extends Flux.Store const { Store } = Flux; - const SpotifySocket = lazyWebpack(filters.byProps("getActiveSocketAndDevice")); - const SpotifyAPI = lazyWebpack(filters.byProps("SpotifyAPIMarker")); + const SpotifySocket = findByPropsLazy("getActiveSocketAndDevice"); + const SpotifyAPI = findByPropsLazy("SpotifyAPIMarker"); const API_BASE = "https://api.spotify.com/v1/me/player"; diff --git a/src/plugins/spotifyControls/index.tsx b/src/plugins/spotifyControls/index.tsx index 14c7a939..7ab1e370 100644 --- a/src/plugins/spotifyControls/index.tsx +++ b/src/plugins/spotifyControls/index.tsx @@ -16,8 +16,9 @@ * along with this program. If not, see . */ -import { Devs } from "../../utils/constants"; -import definePlugin from "../../utils/types"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; + import { Player } from "./PlayerComponent"; export default definePlugin({ diff --git a/src/plugins/spotifyCrack.ts b/src/plugins/spotifyCrack.ts index b9f68ed7..c64154aa 100644 --- a/src/plugins/spotifyCrack.ts +++ b/src/plugins/spotifyCrack.ts @@ -16,10 +16,9 @@ * along with this program. If not, see . */ -import { migratePluginSettings } from "../api/settings"; -import { Devs } from "../utils/constants"; -import definePlugin, { OptionType } from "../utils/types"; -import { Settings } from "../Vencord"; +import { migratePluginSettings, Settings } from "@api/settings"; +import { Devs } from "@utils/constants"; +import definePlugin, { OptionType } from "@utils/types"; migratePluginSettings("SpotifyCrack", "Ify"); export default definePlugin({ diff --git a/src/plugins/spotifyShareCommands.ts b/src/plugins/spotifyShareCommands.ts index e5b247b3..ce29b750 100644 --- a/src/plugins/spotifyShareCommands.ts +++ b/src/plugins/spotifyShareCommands.ts @@ -16,13 +16,12 @@ * along with this program. If not, see . */ -import { ApplicationCommandInputType, sendBotMessage } from "../api/Commands"; -import { migratePluginSettings } from "../api/settings"; -import { Devs } from "../utils/constants"; -import { lazyWebpack } from "../utils/misc"; -import definePlugin from "../utils/types"; -import { filters } from "../webpack"; -import { FluxDispatcher } from "../webpack/common"; +import { ApplicationCommandInputType, sendBotMessage } from "@api/Commands"; +import { migratePluginSettings } from "@api/settings"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; +import { findByPropsLazy } from "@webpack"; +import { FluxDispatcher } from "@webpack/common"; interface Album { id: string; @@ -54,9 +53,9 @@ interface Track { name: string; } -const Spotify = lazyWebpack(filters.byProps("getPlayerState")); -const MessageCreator = lazyWebpack(filters.byProps("getSendMessageOptionsForReply", "sendMessage")); -const PendingReplyStore = lazyWebpack(filters.byProps("getPendingReply")); +const Spotify = findByPropsLazy("getPlayerState"); +const MessageCreator = findByPropsLazy("getSendMessageOptionsForReply", "sendMessage"); +const PendingReplyStore = findByPropsLazy("getPendingReply"); function sendMessage(channelId, message) { message = { diff --git a/src/plugins/startupTimings/StartupTimingPage.tsx b/src/plugins/startupTimings/StartupTimingPage.tsx index f0c14ed5..c8cf51da 100644 --- a/src/plugins/startupTimings/StartupTimingPage.tsx +++ b/src/plugins/startupTimings/StartupTimingPage.tsx @@ -16,11 +16,10 @@ * along with this program. If not, see . */ -import ErrorBoundary from "../../components/ErrorBoundary"; -import { Flex } from "../../components/Flex"; -import { lazyWebpack } from "../../utils/misc"; -import { Forms, React } from "../../webpack/common"; -import { filters } from "../../webpack/webpack"; +import ErrorBoundary from "@components/ErrorBoundary"; +import { Flex } from "@components/Flex"; +import { findByPropsLazy } from "@webpack"; +import { Forms, React } from "@webpack/common"; interface AppStartPerformance { prefix: string; @@ -46,7 +45,7 @@ interface Log { delta?: number; } -const AppStartPerformance = lazyWebpack(filters.byProps("markWithDelta", "markAndLog", "markAt")) as AppStartPerformance; +const AppStartPerformance = findByPropsLazy("markWithDelta", "markAndLog", "markAt") as AppStartPerformance; interface TimerItemProps extends Log { instance: { diff --git a/src/plugins/startupTimings/index.tsx b/src/plugins/startupTimings/index.tsx index d5493c12..1dd71395 100644 --- a/src/plugins/startupTimings/index.tsx +++ b/src/plugins/startupTimings/index.tsx @@ -17,9 +17,9 @@ */ -import { Devs } from "../../utils/constants"; -import { LazyComponent } from "../../utils/misc"; -import definePlugin from "../../utils/types"; +import { Devs } from "@utils/constants"; +import { LazyComponent } from "@utils/misc"; +import definePlugin from "@utils/types"; export default definePlugin({ name: "StartupTimings", diff --git a/src/plugins/unindent.ts b/src/plugins/unindent.ts index 0206095e..a197ef4e 100644 --- a/src/plugins/unindent.ts +++ b/src/plugins/unindent.ts @@ -16,9 +16,9 @@ * along with this program. If not, see . */ -import { addPreEditListener, addPreSendListener, MessageObject, removePreEditListener,removePreSendListener } from "../api/MessageEvents"; -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; +import { addPreEditListener, addPreSendListener, MessageObject, removePreEditListener, removePreSendListener } from "@api/MessageEvents"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; export default definePlugin({ name: "Unindent", diff --git a/src/plugins/unminifyErrors.ts b/src/plugins/unminifyErrors.ts index f0ee77cf..2332d457 100644 --- a/src/plugins/unminifyErrors.ts +++ b/src/plugins/unminifyErrors.ts @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; let ERROR_CODES: any; const CODES_URL = diff --git a/src/plugins/uwuify.ts b/src/plugins/uwuify.ts index 804c7417..1c7d2cb3 100644 --- a/src/plugins/uwuify.ts +++ b/src/plugins/uwuify.ts @@ -16,9 +16,9 @@ * along with this program. If not, see . */ -import { findOption, RequiredMessageOption } from "../api/Commands"; -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; +import { findOption, RequiredMessageOption } from "@api/Commands"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; const endings = [ "owo", "UwU", ">w<", "^w^", "ā—wā—", "ā˜†wā˜†", "š—Øš˜„š—Ø", "(į—’į—Øį—•)", "(ā–°Ė˜vĖ˜ā–°)", diff --git a/src/plugins/vcDoubleClick.ts b/src/plugins/vcDoubleClick.ts index 68dc4805..de573f1c 100644 --- a/src/plugins/vcDoubleClick.ts +++ b/src/plugins/vcDoubleClick.ts @@ -16,10 +16,10 @@ * along with this program. If not, see . */ -import { migratePluginSettings } from "../api/settings"; -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; -import { SelectedChannelStore } from "../webpack/common"; +import { migratePluginSettings } from "@api/settings"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; +import { SelectedChannelStore } from "@webpack/common"; const timers = {} as Record. */ +import { Devs } from "@utils/constants"; +import { LazyComponent } from "@utils/misc"; +import { ModalRoot, ModalSize, openModal } from "@utils/modal"; +import { PluginDef } from "@utils/types"; +import { find, findByPropsLazy } from "@webpack"; +import { Menu } from "@webpack/common"; import type { Guild } from "discord-types/general"; -import { Devs } from "../utils/constants"; -import { LazyComponent, lazyWebpack } from "../utils/misc"; -import { ModalRoot, ModalSize, openModal } from "../utils/modal"; -import { PluginDef } from "../utils/types"; -import { filters, find } from "../webpack"; -import { Menu } from "../webpack/common"; - const ImageModal = LazyComponent(() => find(m => m.prototype?.render?.toString().includes("OPEN_ORIGINAL_IMAGE"))); const MaskedLink = LazyComponent(() => find(m => m.type?.toString().includes("MASKED_LINK)"))); -const GuildBannerStore = lazyWebpack(filters.byProps("getGuildBannerURL")); +const GuildBannerStore = findByPropsLazy("getGuildBannerURL"); const OPEN_URL = "Vencord.Plugins.plugins.ViewIcons.openImage("; export default new class ViewIcons implements PluginDef { diff --git a/src/plugins/volumeBooster.ts b/src/plugins/volumeBooster.ts index fddf6501..dab6b930 100644 --- a/src/plugins/volumeBooster.ts +++ b/src/plugins/volumeBooster.ts @@ -16,9 +16,9 @@ * along with this program. If not, see . */ -import { makeRange } from "../components/PluginSettings/components/SettingSliderComponent"; -import { Devs } from "../utils/constants"; -import definePlugin, { OptionType } from "../utils/types"; +import { makeRange } from "@components/PluginSettings/components/SettingSliderComponent"; +import { Devs } from "@utils/constants"; +import definePlugin, { OptionType } from "@utils/types"; export default definePlugin({ name: "VolumeBooster", diff --git a/src/plugins/webContextMenus.ts b/src/plugins/webContextMenus.ts index 71790822..6419cfd9 100644 --- a/src/plugins/webContextMenus.ts +++ b/src/plugins/webContextMenus.ts @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; export default definePlugin({ name: "WebContextMenus", diff --git a/src/plugins/webhookTags.ts b/src/plugins/webhookTags.ts index e02895af..51d68fa3 100644 --- a/src/plugins/webhookTags.ts +++ b/src/plugins/webhookTags.ts @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; export default definePlugin({ name: "Webhook Tags", diff --git a/src/plugins/whoReacted.tsx b/src/plugins/whoReacted.tsx index b1fb27d5..685d9542 100644 --- a/src/plugins/whoReacted.tsx +++ b/src/plugins/whoReacted.tsx @@ -16,20 +16,19 @@ * along with this program. If not, see . */ +import ErrorBoundary from "@components/ErrorBoundary"; +import { Devs } from "@utils/constants"; +import { LazyComponent, sleep, useForceUpdater } from "@utils/misc"; +import { Queue } from "@utils/Queue"; +import definePlugin from "@utils/types"; +import { findByCode, findByPropsLazy } from "@webpack"; +import { ChannelStore, FluxDispatcher, React, RestAPI, Tooltip } from "@webpack/common"; import { ReactionEmoji, User } from "discord-types/general"; -import ErrorBoundary from "../components/ErrorBoundary"; -import { Devs } from "../utils/constants"; -import { LazyComponent, lazyWebpack, sleep, useForceUpdater } from "../utils/misc"; -import { Queue } from "../utils/Queue"; -import definePlugin from "../utils/types"; -import { filters, findByCode } from "../webpack"; -import { ChannelStore, FluxDispatcher, React, RestAPI, Tooltip } from "../webpack/common"; - const UserSummaryItem = LazyComponent(() => findByCode("defaultRenderUser", "showDefaultAvatarsForNullUsers")); -const AvatarStyles = lazyWebpack(filters.byProps("moreUsers", "emptyUser", "avatarContainer", "clickableAvatar")); +const AvatarStyles = findByPropsLazy("moreUsers", "emptyUser", "avatarContainer", "clickableAvatar"); -const ReactionStore = lazyWebpack(filters.byProps("getReactions")); +const ReactionStore = findByPropsLazy("getReactions"); const queue = new Queue(); diff --git a/src/preload.ts b/src/preload.ts index fccc0249..dcf2554f 100644 --- a/src/preload.ts +++ b/src/preload.ts @@ -16,12 +16,12 @@ * along with this program. If not, see . */ +import { debounce } from "@utils/debounce"; +import IpcEvents from "@utils/IpcEvents"; import electron, { contextBridge, ipcRenderer, webFrame } from "electron"; import { readFileSync } from "fs"; import { join } from "path"; -import { debounce } from "./utils/debounce"; -import IpcEvents from "./utils/IpcEvents"; import VencordNative from "./VencordNative"; if (electron.desktopCapturer === void 0) { diff --git a/src/utils/discord.ts b/src/utils/discord.ts index 7fc5064a..f1a1f8a5 100644 --- a/src/utils/discord.ts +++ b/src/utils/discord.ts @@ -16,10 +16,9 @@ * along with this program. If not, see . */ +import { ChannelStore, GuildStore, PrivateChannelsStore, SelectedChannelStore } from "@webpack/common"; import { Guild } from "discord-types/general"; -import { ChannelStore, GuildStore, PrivateChannelsStore, SelectedChannelStore } from "../webpack/common"; - export function getCurrentChannel() { return ChannelStore.getChannel(SelectedChannelStore.getChannelId()); } diff --git a/src/utils/misc.tsx b/src/utils/misc.tsx index 7389cc2c..4ae3fd50 100644 --- a/src/utils/misc.tsx +++ b/src/utils/misc.tsx @@ -16,9 +16,7 @@ * along with this program. If not, see . */ -import { FilterFn, find } from "../webpack"; -import { React } from "../webpack/common"; -import { proxyLazy } from "./proxyLazy"; +import { React } from "@webpack/common"; /** * Makes a lazy function. On first call, the value is computed. @@ -29,16 +27,6 @@ export function makeLazy(factory: () => T): () => T { let cache: T; return () => cache ?? (cache = factory()); } -export const lazy = makeLazy; - -/** - * Do a lazy webpack search. Searches the module on first property access - * @param filter Filter function - * @returns A proxy to the webpack module. Not all traps are implemented, may produce unexpected results. - */ -export function lazyWebpack(filter: FilterFn): T { - return proxyLazy(() => find(filter)); -} type AwaiterRes = [T, any, boolean, () => void]; /** diff --git a/src/utils/modal.tsx b/src/utils/modal.tsx index 886e325d..9a90460b 100644 --- a/src/utils/modal.tsx +++ b/src/utils/modal.tsx @@ -16,8 +16,7 @@ * along with this program. If not, see . */ -import { filters } from "../webpack"; -import { mapMangledModuleLazy } from "../webpack/webpack"; +import { filters, mapMangledModuleLazy } from "@webpack"; export enum ModalSize { SMALL = "small", diff --git a/src/utils/proxyLazy.ts b/src/utils/proxyLazy.ts index 364dd569..42b5a91d 100644 --- a/src/utils/proxyLazy.ts +++ b/src/utils/proxyLazy.ts @@ -63,7 +63,7 @@ handler.getOwnPropertyDescriptor = (target, p) => { * @param factory lazy factory * @returns Proxy * - * Note that the example below exists already as an api, see {@link lazyWebpack} + * 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(factory: () => T): T { diff --git a/src/utils/quickCss.ts b/src/utils/quickCss.ts index 0ce1f588..1f9f235f 100644 --- a/src/utils/quickCss.ts +++ b/src/utils/quickCss.ts @@ -16,7 +16,8 @@ * along with this program. If not, see . */ -import { addSettingsListener, Settings } from "../api/settings"; +import { addSettingsListener, Settings } from "@api/settings"; + import IpcEvents from "./IpcEvents"; let style: HTMLStyleElement; diff --git a/src/utils/settingsSync.ts b/src/utils/settingsSync.ts index ecf66652..5cd81e7e 100644 --- a/src/utils/settingsSync.ts +++ b/src/utils/settingsSync.ts @@ -16,7 +16,8 @@ * along with this program. If not, see . */ -import { Toasts } from "../webpack/common"; +import { Toasts } from "@webpack/common"; + import IpcEvents from "./IpcEvents"; import Logger from "./Logger"; diff --git a/src/utils/types.ts b/src/utils/types.ts index 30c603f4..310fbea0 100644 --- a/src/utils/types.ts +++ b/src/utils/types.ts @@ -16,10 +16,9 @@ * along with this program. If not, see . */ +import { Command } from "@api/Commands"; import { Promisable } from "type-fest"; -import { Command } from "../api/Commands"; - // exists to export default definePlugin({...}) export default function definePlugin

(p: P & Record) { return p; diff --git a/src/webpack/common.tsx b/src/webpack/common.tsx index 32f47e66..e606f168 100644 --- a/src/webpack/common.tsx +++ b/src/webpack/common.tsx @@ -16,31 +16,33 @@ * along with this program. If not, see . */ +import { LazyComponent } from "@utils/misc"; +import { proxyLazy } from "@utils/proxyLazy"; import type Components from "discord-types/components"; import { User } from "discord-types/general"; import type Other from "discord-types/other"; import type Stores from "discord-types/stores"; -import { LazyComponent, lazyWebpack } from "../utils/misc"; -import { proxyLazy } from "../utils/proxyLazy"; -import { _resolveReady, filters, findByCode, mapMangledModule, mapMangledModuleLazy, waitFor } from "./webpack"; +import { _resolveReady, filters, findByCode, findByCodeLazy, findByPropsLazy, mapMangledModule, mapMangledModuleLazy, waitFor } from "./webpack"; -export const Margins = lazyWebpack(filters.byProps("marginTop20")); +export const Margins = findByPropsLazy("marginTop20"); export let FluxDispatcher: Other.FluxDispatcher; -export const Flux = lazyWebpack(filters.byProps("connectStores")); +export const Flux = findByPropsLazy("connectStores"); export let React: typeof import("react"); -export const ReactDOM: typeof import("react-dom") = lazyWebpack(filters.byProps("createPortal", "render")); +export const ReactDOM: typeof import("react-dom") = findByPropsLazy("createPortal", "render"); -export const RestAPI = lazyWebpack(filters.byProps("getAPIBaseURL", "get")); -export const moment: typeof import("moment") = lazyWebpack(filters.byProps("parseTwoDigitYear")); +export const RestAPI = findByPropsLazy("getAPIBaseURL", "get"); +export const moment: typeof import("moment") = findByPropsLazy("parseTwoDigitYear"); -export const MessageStore = lazyWebpack(filters.byProps("getRawMessages")) as Omit & { getMessages(chanId: string): any; }; -export const PermissionStore = lazyWebpack(filters.byProps("can", "getGuildPermissions")); -export const PrivateChannelsStore = lazyWebpack(filters.byProps("openPrivateChannel")); -export const GuildChannelStore = lazyWebpack(filters.byProps("getChannels")); -export const ReadStateStore = lazyWebpack(filters.byProps("lastMessageId")); -export const PresenceStore = lazyWebpack(filters.byProps("setCurrentUserOnConnectionOpen")); +export const MessageStore = findByPropsLazy("getRawMessages") as Omit & { + getMessages(chanId: string): any; +}; +export const PermissionStore = findByPropsLazy("can", "getGuildPermissions"); +export const PrivateChannelsStore = findByPropsLazy("openPrivateChannel"); +export const GuildChannelStore = findByPropsLazy("getChannels"); +export const ReadStateStore = findByPropsLazy("lastMessageId"); +export const PresenceStore = findByPropsLazy("setCurrentUserOnConnectionOpen"); export let GuildStore: Stores.GuildStore; export let UserStore: Stores.UserStore; export let SelectedChannelStore: Stores.SelectedChannelStore; @@ -121,7 +123,7 @@ export const Toasts = { }; export const UserUtils = { - fetchUser: lazyWebpack(filters.byCode(".USER(", "getUser")) as (id: string) => Promise, + fetchUser: findByCodeLazy(".USER(", "getUser") as (id: string) => Promise, }; export const Clipboard = mapMangledModuleLazy('document.queryCommandEnabled("copy")||document.queryCommandSupported("copy")', { diff --git a/src/webpack/patchWebpack.ts b/src/webpack/patchWebpack.ts index e17ddfcf..273a0623 100644 --- a/src/webpack/patchWebpack.ts +++ b/src/webpack/patchWebpack.ts @@ -16,8 +16,9 @@ * along with this program. If not, see . */ -import { WEBPACK_CHUNK } from "../utils/constants"; -import Logger from "../utils/Logger"; +import { WEBPACK_CHUNK } from "@utils/constants"; +import Logger from "@utils/Logger"; + import { _initWebpack } from "."; let webpackChunk: any[]; diff --git a/src/webpack/webpack.ts b/src/webpack/webpack.ts index bd06b030..0bbd8150 100644 --- a/src/webpack/webpack.ts +++ b/src/webpack/webpack.ts @@ -16,11 +16,11 @@ * along with this program. If not, see . */ +import Logger from "@utils/Logger"; +import { proxyLazy } from "@utils/proxyLazy"; import type { WebpackInstance } from "discord-types/other"; import { traceFunction } from "../debug/Tracer"; -import Logger from "../utils/Logger"; -import { proxyLazy } from "../utils/proxyLazy"; const logger = new Logger("Webpack"); @@ -113,6 +113,13 @@ export const find = traceFunction("find", function find(filter: FilterFn, getDef return null; }); +/** + * find but lazy + */ +export function findLazy(filter: FilterFn, getDefault = true) { + return proxyLazy(() => find(filter, getDefault)); +} + export function findAll(filter: FilterFn, getDefault = true) { if (typeof filter !== "function") throw new Error("Invalid filter. Expected a function got " + typeof filter); @@ -291,6 +298,13 @@ export function findByProps(...props: string[]) { return find(filters.byProps(...props)); } +/** + * findByProps but lazy + */ +export function findByPropsLazy(...props: string[]) { + return findLazy(filters.byProps(...props)); +} + /** * Find all modules that have the specified properties */ @@ -305,6 +319,13 @@ export function findByCode(...code: string[]) { return find(filters.byCode(...code)); } +/** + * findByCode but lazy + */ +export function findByCodeLazy(...code: string[]) { + return findLazy(filters.byCode(...code)); +} + /** * Wait for a module that matches the provided filter to be registered, * then call the callback with the module as the first argument diff --git a/tsconfig.json b/tsconfig.json index aa125329..a55c1fe3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -14,7 +14,16 @@ "strict": true, "noImplicitAny": false, "target": "ESNEXT", - "jsx": "preserve" + "jsx": "preserve", + + "baseUrl": "./src/", + "paths": { + "@webpack": ["./webpack"], + "@webpack/common": ["./webpack/common"], + "@utils/*": ["./utils/*"], + "@api/*": ["./api/*"], + "@components/*": ["./components/*"] + } }, "include": ["src/**/*"] }