diff --git a/src/equicordplugins/homeTyping/index.tsx b/src/equicordplugins/homeTyping/index.tsx index f54ef98f..e35936ed 100644 --- a/src/equicordplugins/homeTyping/index.tsx +++ b/src/equicordplugins/homeTyping/index.tsx @@ -6,14 +6,10 @@ import { Devs } from "@utils/constants"; import definePlugin from "@utils/types"; -import { findExportedComponentLazy, findStoreLazy } from "@webpack"; -import { useStateFromStores } from "@webpack/common"; +import { findExportedComponentLazy } from "@webpack"; +import { PrivateChannelSortStore, TypingStore, useStateFromStores } from "@webpack/common"; const ThreeDots = findExportedComponentLazy("Dots", "AnimatedDots"); -const TypingStore = findStoreLazy("TypingStore"); - -const PrivateChannelSortStore = findStoreLazy("PrivateChannelSortStore") as { getPrivateChannelIds: () => string[]; }; - export default definePlugin({ name: "HomeTyping", description: "Changes the home button to a typing indicator if someone in your dms is typing", diff --git a/src/equicordplugins/messageLoggerEnhanced/utils/index.ts b/src/equicordplugins/messageLoggerEnhanced/utils/index.ts index 3c19b59d..18298eb1 100644 --- a/src/equicordplugins/messageLoggerEnhanced/utils/index.ts +++ b/src/equicordplugins/messageLoggerEnhanced/utils/index.ts @@ -17,8 +17,7 @@ */ import { Settings } from "@api/Settings"; -import { findStoreLazy } from "@webpack"; -import { ChannelStore, SelectedChannelStore, UserStore } from "@webpack/common"; +import { ChannelStore, SelectedChannelStore, UserGuildSettingsStore, UserStore } from "@webpack/common"; import { settings } from "../index"; import { loggedMessages } from "../LoggedMessageManager"; @@ -80,8 +79,6 @@ interface ShouldIgnoreArguments { const EPHEMERAL = 64; -const UserGuildSettingsStore = findStoreLazy("UserGuildSettingsStore"); - /** * the function `shouldIgnore` evaluates whether a message should be ignored or kept, following a priority hierarchy: User > Channel > Server. * In this hierarchy, whitelisting takes priority; if any element (User, Channel, or Server) is whitelisted, the message is kept. diff --git a/src/equicordplugins/notifyUserChanges/index.tsx b/src/equicordplugins/notifyUserChanges/index.tsx index 170e41bf..5a098622 100644 --- a/src/equicordplugins/notifyUserChanges/index.tsx +++ b/src/equicordplugins/notifyUserChanges/index.tsx @@ -9,8 +9,8 @@ import { showNotification } from "@api/Notifications"; import { definePluginSettings, Settings } from "@api/Settings"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; -import { findByPropsLazy, findStoreLazy } from "@webpack"; -import { Menu, PresenceStore, React, SelectedChannelStore, Tooltip, UserStore } from "@webpack/common"; +import { findByPropsLazy } from "@webpack"; +import { Menu, PresenceStore, React, SelectedChannelStore, SessionsStore, Tooltip, UserStore } from "@webpack/common"; import type { Channel, User } from "discord-types/general"; import { CSSProperties } from "react"; @@ -66,8 +66,6 @@ function shouldBeNative() { return false; } -const SessionsStore = findStoreLazy("SessionsStore"); - const StatusUtils = findByPropsLazy("useStatusFillColor", "StatusTypes"); function Icon(path: string, opts?: { viewBox?: string; width?: number; height?: number; }) { diff --git a/src/equicordplugins/vencordRPC/index.ts b/src/equicordplugins/vencordRPC/index.ts index 5a0cba47..b143e7f8 100644 --- a/src/equicordplugins/vencordRPC/index.ts +++ b/src/equicordplugins/vencordRPC/index.ts @@ -8,16 +8,10 @@ import { definePluginSettings } from "@api/Settings"; import { Devs } from "@utils/constants"; import { isTruthy } from "@utils/guards"; import definePlugin, { OptionType } from "@utils/types"; -import { findByPropsLazy, findStoreLazy } from "@webpack"; -import { ApplicationAssetUtils, ChannelStore, FluxDispatcher, GuildStore, PresenceStore, RelationshipStore, SelectedChannelStore, SelectedGuildStore, UserStore } from "@webpack/common"; -import { FluxStore } from "@webpack/types"; +import { findByPropsLazy } from "@webpack"; +import { ApplicationAssetUtils, ChannelMemberStore, ChannelStore, FluxDispatcher, GuildMemberCountStore, GuildStore, PresenceStore, RelationshipStore, SelectedChannelStore, SelectedGuildStore, UserStore, useStateFromStores } from "@webpack/common"; import { Channel } from "discord-types/general"; -const presenceStore = findByPropsLazy("getLocalPresence"); -const GuildMemberCountStore = findStoreLazy("GuildMemberCountStore") as FluxStore & { getMemberCount(guildId: string): number | null; }; -const ChannelMemberStore = findStoreLazy("ChannelMemberStore") as FluxStore & { - getProps(guildId: string, channelId: string): { groups: { count: number; id: string; }[]; }; -}; const VoiceStates = findByPropsLazy("getVoiceStatesForChannel"); const chino = "https://i.imgur.com/Dsa2rQy.png"; const wysi = "https://i.imgur.com/uKtXde9.gif"; @@ -412,7 +406,9 @@ async function createActivity(): Promise { let timeout: NodeJS.Timeout | null = null; async function setRpc(disable?: boolean) { - const activities: any = presenceStore.getActivities(); + const activities = useStateFromStores( + [PresenceStore], () => PresenceStore.getActivities() + ); const activity: Activity | undefined = !activities.length || (activities.length === 1 && activities[0].application_id === settings.store.appID) ? await createActivity() : undefined; FluxDispatcher.dispatch({ diff --git a/src/equicordplugins/voiceChatUtils/index.tsx b/src/equicordplugins/voiceChatUtils/index.tsx index e40d79c3..601e91ed 100644 --- a/src/equicordplugins/voiceChatUtils/index.tsx +++ b/src/equicordplugins/voiceChatUtils/index.tsx @@ -9,12 +9,9 @@ import { definePluginSettings } from "@api/Settings"; import { makeRange } from "@components/PluginSettings/components"; import { Devs, EquicordDevs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; -import { findStoreLazy } from "@webpack"; -import { GuildChannelStore, Menu, React, RestAPI, UserStore } from "@webpack/common"; +import { GuildChannelStore, Menu, React, RestAPI, UserStore, VoiceStateStore } from "@webpack/common"; import type { Channel } from "discord-types/general"; -const VoiceStateStore = findStoreLazy("VoiceStateStore"); - async function runSequential(promises: Promise[]): Promise { const results: T[] = []; diff --git a/src/equicordplugins/whosWatching/index.tsx b/src/equicordplugins/whosWatching/index.tsx index ae1a0627..75924bd4 100644 --- a/src/equicordplugins/whosWatching/index.tsx +++ b/src/equicordplugins/whosWatching/index.tsx @@ -13,8 +13,8 @@ import { openUserProfile } from "@utils/discord"; import { Margins } from "@utils/margins"; import { classes } from "@utils/misc"; import definePlugin, { OptionType } from "@utils/types"; -import { findByPropsLazy, findComponentByCodeLazy, findStoreLazy } from "@webpack"; -import { Clickable, Forms, i18n, RelationshipStore, Tooltip, UserStore, useStateFromStores } from "@webpack/common"; +import { findByPropsLazy, findComponentByCodeLazy } from "@webpack"; +import { ApplicationStreamingStore, Clickable, Forms, i18n, RelationshipStore, Tooltip, UserStore, useStateFromStores } from "@webpack/common"; import { User } from "discord-types/general"; interface WatchingProps { @@ -73,8 +73,6 @@ function Watching({ userIds, guildId }: WatchingProps): JSX.Element { ); } -const ApplicationStreamingStore = findStoreLazy("ApplicationStreamingStore"); - const UserSummaryItem = findComponentByCodeLazy("defaultRenderUser", "showDefaultAvatarsForNullUsers"); const AvatarStyles = findByPropsLazy("moreUsers", "emptyUser", "avatarContainer", "clickableAvatar"); @@ -105,7 +103,7 @@ export default definePlugin({ if (!stream) return
{props.children}
; - const userIds = ApplicationStreamingStore.getViewerIds(encodeStreamKey(stream)); + const userIds = ApplicationStreamingStore.getViewerIds(stream); let missingUsers = 0; const users = userIds.map(id => UserStore.getUser(id)).filter(user => Boolean(user) ? true : (missingUsers += 1, false)); @@ -167,7 +165,7 @@ export default definePlugin({ component: function ({ OriginalComponent }) { return ErrorBoundary.wrap((props: any) => { const stream = useStateFromStores([ApplicationStreamingStore], () => ApplicationStreamingStore.getCurrentUserActiveStream()); - const viewers = ApplicationStreamingStore.getViewerIds(encodeStreamKey(stream)); + const viewers = ApplicationStreamingStore.getViewerIds(stream); return }> {({ onMouseEnter, onMouseLeave }) => (
diff --git a/src/plugins/betterFolders/FolderSideBar.tsx b/src/plugins/betterFolders/FolderSideBar.tsx index 53d24ed9..2fc1c237 100644 --- a/src/plugins/betterFolders/FolderSideBar.tsx +++ b/src/plugins/betterFolders/FolderSideBar.tsx @@ -17,13 +17,11 @@ */ import ErrorBoundary from "@components/ErrorBoundary"; -import { findByPropsLazy, findComponentByCodeLazy, findStoreLazy } from "@webpack"; -import { useStateFromStores } from "@webpack/common"; +import { findByPropsLazy, findComponentByCodeLazy } from "@webpack"; +import { ChannelRTCStore, ExpandedGuildFolderStore, useStateFromStores } from "@webpack/common"; import type { CSSProperties } from "react"; -import { ExpandedGuildFolderStore, settings } from "."; - -const ChannelRTCStore = findStoreLazy("ChannelRTCStore"); +import { settings } from "."; const Animations = findByPropsLazy("a", "animated", "useTransition"); const GuildsBar = findComponentByCodeLazy('("guildsnav")'); diff --git a/src/plugins/betterFolders/index.tsx b/src/plugins/betterFolders/index.tsx index d0e8cf34..141b116c 100644 --- a/src/plugins/betterFolders/index.tsx +++ b/src/plugins/betterFolders/index.tsx @@ -19,8 +19,8 @@ import { definePluginSettings } from "@api/Settings"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; -import { findByPropsLazy, findLazy, findStoreLazy } from "@webpack"; -import { FluxDispatcher, i18n, useMemo } from "@webpack/common"; +import { findByPropsLazy, findLazy } from "@webpack"; +import { ExpandedGuildFolderStore, FluxDispatcher, i18n, SortedGuildStore, useMemo } from "@webpack/common"; import FolderSideBar from "./FolderSideBar"; @@ -31,8 +31,6 @@ enum FolderIconDisplay { } const GuildsTree = findLazy(m => m.prototype?.moveNextTo); -const SortedGuildStore = findStoreLazy("SortedGuildStore"); -export const ExpandedGuildFolderStore = findStoreLazy("ExpandedGuildFolderStore"); const FolderUtils = findByPropsLazy("move", "toggleGuildFolderExpand"); let lastGuildId = null as string | null; diff --git a/src/plugins/betterSessions/index.tsx b/src/plugins/betterSessions/index.tsx index 598e0104..b23ead72 100644 --- a/src/plugins/betterSessions/index.tsx +++ b/src/plugins/betterSessions/index.tsx @@ -21,14 +21,13 @@ import { definePluginSettings } from "@api/Settings"; import ErrorBoundary from "@components/ErrorBoundary"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; -import { findByPropsLazy, findExportedComponentLazy, findStoreLazy } from "@webpack"; -import { Constants, React, RestAPI, Tooltip } from "@webpack/common"; +import { findByPropsLazy, findExportedComponentLazy } from "@webpack"; +import { AuthSessionsStore, Constants, React, RestAPI, Tooltip } from "@webpack/common"; import { RenameButton } from "./components/RenameButton"; import { Session, SessionInfo } from "./types"; import { fetchNamesFromDataStore, getDefaultName, GetOsColor, GetPlatformIcon, savedSessionsCache, saveSessionsToDataStore } from "./utils"; -const AuthSessionsStore = findStoreLazy("AuthSessionsStore"); const UserSettingsModal = findByPropsLazy("saveAccountChanges", "open"); const TimestampClasses = findByPropsLazy("timestampTooltip", "blockquoteContainer"); diff --git a/src/plugins/biggerStreamPreview/index.tsx b/src/plugins/biggerStreamPreview/index.tsx index a86e3fca..035a316f 100644 --- a/src/plugins/biggerStreamPreview/index.tsx +++ b/src/plugins/biggerStreamPreview/index.tsx @@ -21,12 +21,10 @@ import { ScreenshareIcon } from "@components/Icons"; import { Devs } from "@utils/constants"; import { openImageModal } from "@utils/discord"; import definePlugin from "@utils/types"; -import { Menu } from "@webpack/common"; +import { ApplicationStreamingStore, ApplicationStreamPreviewStore, Menu } from "@webpack/common"; +import { ApplicationStream, Stream } from "@webpack/types"; import { Channel, User } from "discord-types/general"; -import { ApplicationStreamingStore, ApplicationStreamPreviewStore } from "./webpack/stores"; -import { ApplicationStream, Stream } from "./webpack/types/stores"; - export interface UserContextProps { channel: Channel, channelSelected: boolean, diff --git a/src/plugins/biggerStreamPreview/webpack/stores.ts b/src/plugins/biggerStreamPreview/webpack/stores.ts deleted file mode 100644 index ba5227ba..00000000 --- a/src/plugins/biggerStreamPreview/webpack/stores.ts +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Vencord, a modification for Discord's desktop app - * Copyright (c) 2023 Vendicated and contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . -*/ - -import { findStoreLazy } from "@webpack"; - -import * as t from "./types/stores"; - -export const ApplicationStreamPreviewStore: t.ApplicationStreamPreviewStore = findStoreLazy("ApplicationStreamPreviewStore"); -export const ApplicationStreamingStore: t.ApplicationStreamingStore = findStoreLazy("ApplicationStreamingStore"); diff --git a/src/plugins/biggerStreamPreview/webpack/types/stores.ts b/src/plugins/biggerStreamPreview/webpack/types/stores.ts deleted file mode 100644 index 0265986f..00000000 --- a/src/plugins/biggerStreamPreview/webpack/types/stores.ts +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Vencord, a modification for Discord's desktop app - * Copyright (c) 2023 Vendicated and contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . -*/ - -import { FluxStore } from "@webpack/types"; - -export interface ApplicationStreamPreviewStore extends FluxStore { - getIsPreviewLoading: (guildId: string | bigint | null, channelId: string | bigint, ownerId: string | bigint) => boolean; - getPreviewURL: (guildId: string | bigint | null, channelId: string | bigint, ownerId: string | bigint) => Promise; - getPreviewURLForStreamKey: (streamKey: string) => ReturnType; -} - -export interface ApplicationStream { - streamType: string; - guildId: string | null; - channelId: string; - ownerId: string; -} - -export interface Stream extends ApplicationStream { - state: string; -} - -export interface RTCStream { - region: string, - streamKey: string, - viewerIds: string[]; -} - -export interface StreamMetadata { - id: string | null, - pid: number | null, - sourceName: string | null; -} - -export interface StreamingStoreState { - activeStreams: [string, Stream][]; - rtcStreams: { [key: string]: RTCStream; }; - streamerActiveStreamMetadatas: { [key: string]: StreamMetadata | null; }; - streamsByUserAndGuild: { [key: string]: { [key: string]: ApplicationStream; }; }; -} - -/** - * example how a stream key could look like: `call(type of connection):1116549917987192913(channelId):305238513941667851(ownerId)` - */ -export interface ApplicationStreamingStore extends FluxStore { - getActiveStreamForApplicationStream: (stream: ApplicationStream) => Stream | null; - getActiveStreamForStreamKey: (streamKey: string) => Stream | null; - getActiveStreamForUser: (userId: string | bigint, guildId?: string | bigint | null) => Stream | null; - getAllActiveStreams: () => Stream[]; - getAllApplicationStreams: () => ApplicationStream[]; - getAllApplicationStreamsForChannel: (channelId: string | bigint) => ApplicationStream[]; - getAllActiveStreamsForChannel: (channelId: string | bigint) => Stream[]; - getAnyStreamForUser: (userId: string | bigint) => Stream | ApplicationStream | null; - getStreamForUser: (userId: string | bigint, guildId?: string | bigint | null) => Stream | null; - getCurrentUserActiveStream: () => Stream | null; - getLastActiveStream: () => Stream | null; - getState: () => StreamingStoreState; - getRTCStream: (streamKey: string) => RTCStream | null; - getStreamerActiveStreamMetadata: () => StreamMetadata; - getViewerIds: (stream: ApplicationStream) => string[]; - isSelfStreamHidden: (channelId: string | bigint | null) => boolean; -} diff --git a/src/plugins/clientTheme/index.tsx b/src/plugins/clientTheme/index.tsx index b36a2cb8..259d2147 100644 --- a/src/plugins/clientTheme/index.tsx +++ b/src/plugins/clientTheme/index.tsx @@ -11,8 +11,8 @@ import { Devs } from "@utils/constants"; import { Margins } from "@utils/margins"; import { classes } from "@utils/misc"; import definePlugin, { OptionType, StartAt } from "@utils/types"; -import { findByCodeLazy, findComponentByCodeLazy, findStoreLazy } from "@webpack"; -import { Button, Forms, useStateFromStores } from "@webpack/common"; +import { findByCodeLazy, findComponentByCodeLazy } from "@webpack"; +import { Button, Forms, NitroThemeStore, ThemeStore, useStateFromStores } from "@webpack/common"; const ColorPicker = findComponentByCodeLazy(".Messages.USER_SETTINGS_PROFILE_COLOR_SELECT_COLOR", ".BACKGROUND_PRIMARY)"); @@ -36,9 +36,6 @@ function setTheme(theme: string) { saveClientTheme({ theme }); } -const ThemeStore = findStoreLazy("ThemeStore"); -const NitroThemeStore = findStoreLazy("ClientThemesBackgroundStore"); - function ThemeSettings() { const theme = useStateFromStores([ThemeStore], () => ThemeStore.theme); const isLightTheme = theme === "light"; diff --git a/src/plugins/emoteCloner/index.tsx b/src/plugins/emoteCloner/index.tsx index 6dd3eb30..608a7164 100644 --- a/src/plugins/emoteCloner/index.tsx +++ b/src/plugins/emoteCloner/index.tsx @@ -23,11 +23,9 @@ import { Logger } from "@utils/Logger"; import { Margins } from "@utils/margins"; import { ModalContent, ModalHeader, ModalRoot, openModalLazy } from "@utils/modal"; import definePlugin from "@utils/types"; -import { findByCodeLazy, findStoreLazy } from "@webpack"; -import { Constants, EmojiStore, FluxDispatcher, Forms, GuildStore, Menu, PermissionsBits, PermissionStore, React, RestAPI, Toasts, Tooltip, UserStore } from "@webpack/common"; +import { findByCodeLazy } from "@webpack"; +import { Constants, EmojiStore, FluxDispatcher, Forms, GuildStore, Menu, PermissionsBits, PermissionStore, React, RestAPI, StickerStore, Toasts, Tooltip, UserStore } from "@webpack/common"; import { Promisable } from "type-fest"; - -const StickersStore = findStoreLazy("StickersStore"); const uploadEmoji = findByCodeLazy(".GUILD_EMOJIS(", "EMOJI_UPLOAD_START"); interface Sticker { @@ -60,7 +58,7 @@ function getUrl(data: Data) { } async function fetchSticker(id: string) { - const cached = StickersStore.getStickerById(id); + const cached = StickerStore.getStickerById(id); if (cached) return cached; const { body } = await RestAPI.get({ diff --git a/src/plugins/fakeNitro/index.tsx b/src/plugins/fakeNitro/index.tsx index 5f7429d0..874e6dfd 100644 --- a/src/plugins/fakeNitro/index.tsx +++ b/src/plugins/fakeNitro/index.tsx @@ -23,21 +23,13 @@ import { ApngBlendOp, ApngDisposeOp, importApngJs } from "@utils/dependencies"; import { getCurrentGuild } from "@utils/discord"; import { Logger } from "@utils/Logger"; import definePlugin, { OptionType } from "@utils/types"; -import { findByCodeLazy, findByPropsLazy, findStoreLazy, proxyLazyWebpack } from "@webpack"; -import { Alerts, ChannelStore, DraftType, EmojiStore, FluxDispatcher, Forms, GuildMemberStore, IconUtils, lodash, Parser, PermissionsBits, PermissionStore, UploadHandler, UserSettingsActionCreators, UserStore } from "@webpack/common"; +import { findByCodeLazy, findByPropsLazy, proxyLazyWebpack } from "@webpack"; +import { Alerts, ChannelStore, DraftType, EmojiStore, FluxDispatcher, Forms, GuildMemberStore, IconUtils, lodash, Parser, PermissionsBits, PermissionStore, StickerStore, UploadHandler, UserSettingsActionCreators, UserSettingsProtoStore, UserStore } from "@webpack/common"; import type { Emoji } from "@webpack/types"; import type { Message } from "discord-types/general"; import { applyPalette, GIFEncoder, quantize } from "gifenc"; import type { ReactElement, ReactNode } from "react"; -const StickerStore = findStoreLazy("StickersStore") as { - getPremiumPacks(): StickerPack[]; - getAllGuildStickers(): Map; - getStickerById(id: string): Sticker | undefined; -}; - -const UserSettingsProtoStore = findStoreLazy("UserSettingsProtoStore"); - const BINARY_READ_OPTIONS = findByPropsLazy("readerFactory"); function searchProtoClassField(localName: string, protoClass: any) { diff --git a/src/plugins/ignoreActivities/index.tsx b/src/plugins/ignoreActivities/index.tsx index bab69d89..7377d961 100644 --- a/src/plugins/ignoreActivities/index.tsx +++ b/src/plugins/ignoreActivities/index.tsx @@ -12,8 +12,7 @@ import { Flex } from "@components/Flex"; import { Devs } from "@utils/constants"; import { Margins } from "@utils/margins"; import definePlugin, { OptionType } from "@utils/types"; -import { findStoreLazy } from "@webpack"; -import { Button, Forms, showToast, TextInput, Toasts, Tooltip, useEffect, useState } from "webpack/common"; +import { Button, Forms, RunningGameStore, showToast, TextInput, Toasts, Tooltip, useEffect, useState } from "webpack/common"; const enum ActivitiesTypes { Game, @@ -26,8 +25,6 @@ interface IgnoredActivity { type: ActivitiesTypes; } -const RunningGameStore = findStoreLazy("RunningGameStore"); - const ShowCurrentGame = getUserSettingLazy("status", "showCurrentGame")!; function ToggleIcon(activity: IgnoredActivity, tooltipText: string, path: string, fill: string) { diff --git a/src/plugins/implicitRelationships/index.ts b/src/plugins/implicitRelationships/index.ts index 7d8c9748..fd2d864e 100644 --- a/src/plugins/implicitRelationships/index.ts +++ b/src/plugins/implicitRelationships/index.ts @@ -19,12 +19,9 @@ import { definePluginSettings } from "@api/Settings"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; -import { findStoreLazy } from "@webpack"; -import { ChannelStore, Constants, FluxDispatcher, GuildStore, RelationshipStore, SnowflakeUtils, UserStore } from "@webpack/common"; +import { ChannelStore, Constants, FluxDispatcher, GuildStore, RelationshipStore, SnowflakeUtils, UserAffinitiesStore, UserStore } from "@webpack/common"; import { Settings } from "Vencord"; -const UserAffinitiesStore = findStoreLazy("UserAffinitiesStore"); - export default definePlugin({ name: "ImplicitRelationships", description: "Shows your implicit relationships in the Friends tab.", diff --git a/src/plugins/memberCount/MemberCount.tsx b/src/plugins/memberCount/MemberCount.tsx index 3231d01c..e5eeeb02 100644 --- a/src/plugins/memberCount/MemberCount.tsx +++ b/src/plugins/memberCount/MemberCount.tsx @@ -5,9 +5,9 @@ */ import { getCurrentChannel } from "@utils/discord"; -import { SelectedChannelStore, Tooltip, useEffect, useStateFromStores } from "@webpack/common"; +import { ChannelMemberStore, GuildMemberCountStore, SelectedChannelStore, Tooltip, useEffect, useStateFromStores } from "@webpack/common"; -import { ChannelMemberStore, cl, GuildMemberCountStore, numberFormat } from "."; +import { cl, numberFormat } from "."; import { OnlineMemberCountStore } from "./OnlineMemberCountStore"; export function MemberCount({ isTooltip, tooltipGuildId }: { isTooltip?: true; tooltipGuildId?: string; }) { diff --git a/src/plugins/memberCount/index.tsx b/src/plugins/memberCount/index.tsx index 28ecb9db..22a4d164 100644 --- a/src/plugins/memberCount/index.tsx +++ b/src/plugins/memberCount/index.tsx @@ -23,16 +23,9 @@ import { classNameFactory } from "@api/Styles"; import ErrorBoundary from "@components/ErrorBoundary"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; -import { findStoreLazy } from "@webpack"; -import { FluxStore } from "@webpack/types"; import { MemberCount } from "./MemberCount"; -export const GuildMemberCountStore = findStoreLazy("GuildMemberCountStore") as FluxStore & { getMemberCount(guildId: string): number | null; }; -export const ChannelMemberStore = findStoreLazy("ChannelMemberStore") as FluxStore & { - getProps(guildId: string, channelId: string): { groups: { count: number; id: string; }[]; }; -}; - const settings = definePluginSettings({ toolTip: { type: OptionType.BOOLEAN, diff --git a/src/plugins/pinDms/data.ts b/src/plugins/pinDms/data.ts index a4e40dde..6d86104e 100644 --- a/src/plugins/pinDms/data.ts +++ b/src/plugins/pinDms/data.ts @@ -6,10 +6,10 @@ import * as DataStore from "@api/DataStore"; import { Settings } from "@api/Settings"; -import { UserStore } from "@webpack/common"; +import { PrivateChannelSortStore, UserStore } from "@webpack/common"; import { DEFAULT_COLOR } from "./constants"; -import { forceUpdate, PinOrder, PrivateChannelSortStore, settings } from "./index"; +import { forceUpdate, PinOrder, settings } from "./index"; export interface Category { id: string; diff --git a/src/plugins/pinDms/index.tsx b/src/plugins/pinDms/index.tsx index 620a615a..92632f11 100644 --- a/src/plugins/pinDms/index.tsx +++ b/src/plugins/pinDms/index.tsx @@ -11,8 +11,8 @@ import ErrorBoundary from "@components/ErrorBoundary"; import { Devs } from "@utils/constants"; import { classes } from "@utils/misc"; import definePlugin, { OptionType, StartAt } from "@utils/types"; -import { findByPropsLazy, findStoreLazy } from "@webpack"; -import { ContextMenuApi, FluxDispatcher, Menu, React } from "@webpack/common"; +import { findByPropsLazy } from "@webpack"; +import { ContextMenuApi, FluxDispatcher, Menu, PrivateChannelSortStore, React } from "@webpack/common"; import { Channel } from "discord-types/general"; import { contextMenus } from "./components/contextMenu"; @@ -29,8 +29,6 @@ interface ChannelComponentProps { const headerClasses = findByPropsLazy("privateChannelsHeaderContainer"); -export const PrivateChannelSortStore = findStoreLazy("PrivateChannelSortStore") as { getPrivateChannelIds: () => string[]; }; - export let instance: any; export const forceUpdate = () => instance?.props?._forceUpdate?.(); diff --git a/src/plugins/platformIndicators/index.tsx b/src/plugins/platformIndicators/index.tsx index 5e479080..21131aaa 100644 --- a/src/plugins/platformIndicators/index.tsx +++ b/src/plugins/platformIndicators/index.tsx @@ -25,25 +25,10 @@ import { Settings } from "@api/Settings"; import ErrorBoundary from "@components/ErrorBoundary"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; -import { findByPropsLazy, findStoreLazy } from "@webpack"; -import { PresenceStore, Tooltip, UserStore } from "@webpack/common"; +import { findByPropsLazy } from "@webpack"; +import { PresenceStore, SessionsStore, Tooltip, UserStore } from "@webpack/common"; import { User } from "discord-types/general"; -export interface Session { - sessionId: string; - status: string; - active: boolean; - clientInfo: { - version: number; - os: string; - client: string; - }; -} - -const SessionsStore = findStoreLazy("SessionsStore") as { - getSessions(): Record; -}; - function Icon(path: string, opts?: { viewBox?: string; width?: number; height?: number; }) { return ({ color, tooltip, small }: { color: string; tooltip: string; small: boolean; }) => ( diff --git a/src/plugins/relationshipNotifier/functions.ts b/src/plugins/relationshipNotifier/functions.ts index 5bff474b..0ce68bfc 100644 --- a/src/plugins/relationshipNotifier/functions.ts +++ b/src/plugins/relationshipNotifier/functions.ts @@ -17,11 +17,11 @@ */ import { getUniqueUsername, openUserProfile } from "@utils/discord"; -import { UserUtils } from "@webpack/common"; +import { GuildAvailabilityStore, UserUtils } from "@webpack/common"; import settings from "./settings"; import { ChannelDelete, ChannelType, GuildDelete, RelationshipRemove, RelationshipType } from "./types"; -import { deleteGroup, deleteGuild, getGroup, getGuild, GuildAvailabilityStore, notify } from "./utils"; +import { deleteGroup, deleteGuild, getGroup, getGuild, notify } from "./utils"; let manuallyRemovedFriend: string | undefined; let manuallyRemovedGuild: string | undefined; diff --git a/src/plugins/relationshipNotifier/utils.ts b/src/plugins/relationshipNotifier/utils.ts index 053cff83..33f0ea30 100644 --- a/src/plugins/relationshipNotifier/utils.ts +++ b/src/plugins/relationshipNotifier/utils.ts @@ -19,20 +19,11 @@ import { DataStore, Notices } from "@api/index"; import { showNotification } from "@api/Notifications"; import { getUniqueUsername, openUserProfile } from "@utils/discord"; -import { findStoreLazy } from "@webpack"; -import { ChannelStore, GuildMemberStore, GuildStore, RelationshipStore, UserStore, UserUtils } from "@webpack/common"; -import { FluxStore } from "@webpack/types"; +import { ChannelStore, GuildAvailabilityStore, GuildMemberStore, GuildStore, RelationshipStore, UserStore, UserUtils } from "@webpack/common"; import settings from "./settings"; import { ChannelType, RelationshipType, SimpleGroupChannel, SimpleGuild } from "./types"; -export const GuildAvailabilityStore = findStoreLazy("GuildAvailabilityStore") as FluxStore & { - totalGuilds: number; - totalUnavailableGuilds: number; - unavailableGuilds: string[]; - isUnavailable(guildId: string): boolean; -}; - const guilds = new Map(); const groups = new Map(); const friends = { diff --git a/src/plugins/showConnections/index.tsx b/src/plugins/showConnections/index.tsx index d6909dc9..304a0909 100644 --- a/src/plugins/showConnections/index.tsx +++ b/src/plugins/showConnections/index.tsx @@ -25,14 +25,13 @@ import { CopyIcon, LinkIcon } from "@components/Icons"; import { Devs } from "@utils/constants"; import { copyWithToast } from "@utils/misc"; import definePlugin, { OptionType } from "@utils/types"; -import { findByCodeLazy, findByPropsLazy, findComponentByCodeLazy, findStoreLazy } from "@webpack"; -import { Text, Tooltip, UserProfileStore } from "@webpack/common"; +import { findByCodeLazy, findByPropsLazy, findComponentByCodeLazy } from "@webpack"; +import { Text, ThemeStore, Tooltip, UserProfileStore } from "@webpack/common"; import { User } from "discord-types/general"; import { VerifiedIcon } from "./VerifiedIcon"; const Section = findComponentByCodeLazy(".lastSection", "children:"); -const ThemeStore = findStoreLazy("ThemeStore"); const useLegacyPlatformType: (platform: string) => string = findByCodeLazy(".TWITTER_LEGACY:"); const platforms: { get(type: string): ConnectionPlatform; } = findByPropsLazy("isSupported", "getByUrl"); diff --git a/src/plugins/typingIndicator/index.tsx b/src/plugins/typingIndicator/index.tsx index ef770a71..e1e29242 100644 --- a/src/plugins/typingIndicator/index.tsx +++ b/src/plugins/typingIndicator/index.tsx @@ -22,15 +22,13 @@ import { definePluginSettings, Settings } from "@api/Settings"; import ErrorBoundary from "@components/ErrorBoundary"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; -import { findComponentByCodeLazy, findExportedComponentLazy, findStoreLazy } from "@webpack"; -import { ChannelStore, GuildMemberStore, i18n, RelationshipStore, SelectedChannelStore, Tooltip, UserStore, useStateFromStores } from "@webpack/common"; +import { findComponentByCodeLazy, findExportedComponentLazy } from "@webpack"; +import { ChannelStore, GuildMemberStore, i18n, RelationshipStore, SelectedChannelStore, Tooltip, TypingStore, UserGuildSettingsStore, UserStore, useStateFromStores } from "@webpack/common"; import { buildSeveralUsers } from "../typingTweaks"; const ThreeDots = findExportedComponentLazy("Dots", "AnimatedDots"); const UserSummaryItem = findComponentByCodeLazy("defaultRenderUser", "showDefaultAvatarsForNullUsers"); -const TypingStore = findStoreLazy("TypingStore"); -const UserGuildSettingsStore = findStoreLazy("UserGuildSettingsStore"); const enum IndicatorMode { Dots = 1 << 0, diff --git a/src/plugins/userVoiceShow/index.tsx b/src/plugins/userVoiceShow/index.tsx index 7d640171..7d7bc2bc 100644 --- a/src/plugins/userVoiceShow/index.tsx +++ b/src/plugins/userVoiceShow/index.tsx @@ -20,14 +20,11 @@ import { definePluginSettings } from "@api/Settings"; import ErrorBoundary from "@components/ErrorBoundary"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; -import { findStoreLazy } from "@webpack"; -import { ChannelStore, GuildStore, UserStore } from "@webpack/common"; +import { ChannelStore, GuildStore, UserStore, VoiceStateStore } from "@webpack/common"; import { User } from "discord-types/general"; import { VoiceChannelSection } from "./components/VoiceChannelSection"; -const VoiceStateStore = findStoreLazy("VoiceStateStore"); - const settings = definePluginSettings({ showInUserProfileModal: { type: OptionType.BOOLEAN, diff --git a/src/webpack/common/types/stores.d.ts b/src/webpack/common/types/stores.d.ts index 037b2d81..03c7e3a5 100644 --- a/src/webpack/common/types/stores.d.ts +++ b/src/webpack/common/types/stores.d.ts @@ -17,6 +17,7 @@ */ import { DraftType } from "@webpack/common"; +import { FluxStore } from "@webpack/types"; import { Channel, Guild, Role } from "discord-types/general"; import { FluxDispatcher, FluxEvents } from "./utils"; diff --git a/src/webpack/common/types/utils.d.ts b/src/webpack/common/types/utils.d.ts index ce1e3e26..ffb8ed4b 100644 --- a/src/webpack/common/types/utils.d.ts +++ b/src/webpack/common/types/utils.d.ts @@ -316,3 +316,69 @@ export interface DisplayProfileUtils { getDisplayProfile(userId: string, guildId?: string, customStores?: any): DisplayProfile | null; useDisplayProfile(userId: string, guildId?: string, customStores?: any): DisplayProfile | null; } + +export interface ApplicationStreamPreviewStore extends FluxStore { + getIsPreviewLoading: (guildId: string | bigint | null, channelId: string | bigint, ownerId: string | bigint) => boolean; + getPreviewURL: (guildId: string | bigint | null, channelId: string | bigint, ownerId: string | bigint) => Promise; + getPreviewURLForStreamKey: (streamKey: string) => ReturnType; +} + +export interface ApplicationStream { + streamType: string; + guildId: string; + channelId: string; + ownerId: string; +} + +export interface Stream extends ApplicationStream { + state: string; +} + +export interface RTCStream { + region: string, + streamKey: string, + viewerIds: string[]; +} + +export interface StreamMetadata { + id: string | null, + pid: number | null, + sourceName: string | null; +} + +export interface StreamingStoreState { + activeStreams: [string, Stream][]; + rtcStreams: { [key: string]: RTCStream; }; + streamerActiveStreamMetadatas: { [key: string]: StreamMetadata | null; }; + streamsByUserAndGuild: { [key: string]: { [key: string]: ApplicationStream; }; }; +} + +export interface ApplicationStreamingStore extends FluxStore { + getActiveStreamForApplicationStream: (stream: ApplicationStream) => Stream | null; + getActiveStreamForStreamKey: (streamKey: string) => Stream | null; + getActiveStreamForUser: (userId: string | bigint, guildId?: string | bigint | null) => Stream | null; + getAllActiveStreams: () => Stream[]; + getAllApplicationStreams: () => ApplicationStream[]; + getAllApplicationStreamsForChannel: (channelId: string | bigint) => ApplicationStream[]; + getAllActiveStreamsForChannel: (channelId: string | bigint) => Stream[]; + getAnyStreamForUser: (userId: string | bigint) => Stream | ApplicationStream | null; + getStreamForUser: (userId: string | bigint, guildId?: string | bigint | null) => Stream | null; + getCurrentUserActiveStream: () => Stream; + getLastActiveStream: () => Stream | null; + getState: () => StreamingStoreState; + getRTCStream: (streamKey: string) => RTCStream | null; + getStreamerActiveStreamMetadata: () => StreamMetadata; + getViewerIds: (stream: ApplicationStream) => string[]; + isSelfStreamHidden: (channelId: string | bigint | null) => boolean; +} + +export interface Session { + sessionId: string; + status: string; + active: boolean; + clientInfo: { + version: number; + os: string; + client: string; + }; +} diff --git a/src/webpack/common/utils.ts b/src/webpack/common/utils.ts index 2aba23dd..c98207e9 100644 --- a/src/webpack/common/utils.ts +++ b/src/webpack/common/utils.ts @@ -19,7 +19,8 @@ import { canonicalizeMatch } from "@utils/patches"; import type { Channel } from "discord-types/general"; -import { _resolveReady, filters, findByCodeLazy, findByPropsLazy, findLazy, mapMangledModuleLazy, waitFor } from "../webpack"; +import { _resolveReady, filters, findByCodeLazy, findByPropsLazy, findLazy, findStoreLazy, mapMangledModuleLazy, waitFor } from "../webpack"; +import { FluxStore } from "./types/stores"; import type * as t from "./types/utils"; export let FluxDispatcher: t.FluxDispatcher; @@ -160,13 +161,6 @@ export const InviteActions = findByPropsLazy("resolveInvite"); export const IconUtils: t.IconUtils = findByPropsLazy("getGuildBannerURL", "getUserAvatarURL"); -const openExpressionPickerMatcher = canonicalizeMatch(/setState\({activeView:\i,activeViewType:/); -// TODO: type -export const ExpressionPickerStore: t.ExpressionPickerStore = mapMangledModuleLazy("expression-picker-last-active-view", { - closeExpressionPicker: filters.byCode("setState({activeView:null"), - openExpressionPicker: m => typeof m === "function" && openExpressionPickerMatcher.test(m.toString()), -}); - export const PopoutActions: t.PopoutActions = mapMangledModuleLazy('type:"POPOUT_WINDOW_OPEN"', { open: filters.byCode('type:"POPOUT_WINDOW_OPEN"'), close: filters.byCode('type:"POPOUT_WINDOW_CLOSE"'), @@ -178,3 +172,41 @@ export const DisplayProfileUtils: t.DisplayProfileUtils = mapMangledModuleLazy(/ getDisplayProfile: filters.byCode(".getGuildMemberProfile("), useDisplayProfile: filters.byCode(/\[\i\.\i,\i\.\i],\(\)=>/) }); + +const openExpressionPickerMatcher = canonicalizeMatch(/setState\({activeView:\i,activeViewType:/); + +// findStoreLazy Stores +export const ExpressionPickerStore: t.ExpressionPickerStore = mapMangledModuleLazy("expression-picker-last-active-view", { + closeExpressionPicker: filters.byCode("setState({activeView:null"), + openExpressionPicker: m => typeof m === "function" && openExpressionPickerMatcher.test(m.toString()), +}); +export const ApplicationStreamPreviewStore: t.ApplicationStreamPreviewStore = findStoreLazy("ApplicationStreamPreviewStore"); +export const ApplicationStreamingStore: t.ApplicationStreamingStore = findStoreLazy("ApplicationStreamingStore"); +export const VoiceStateStore = findStoreLazy("VoiceStateStore"); +export const RunningGameStore = findStoreLazy("RunningGameStore"); +export const TypingStore = findStoreLazy("TypingStore"); +export const PrivateChannelSortStore = findStoreLazy("PrivateChannelSortStore") as { getPrivateChannelIds: () => string[]; }; +export const UserGuildSettingsStore = findStoreLazy("UserGuildSettingsStore"); +export const SessionsStore = findStoreLazy("SessionsStore") as { + getSessions(): Record; +}; +export const GuildMemberCountStore = findStoreLazy("GuildMemberCountStore") as FluxStore & { getMemberCount(guildId: string): number | null; }; +export const ChannelMemberStore = findStoreLazy("ChannelMemberStore") as FluxStore & { + getProps(guildId: string, channelId: string): { groups: { count: number; id: string; }[]; }; +}; +export const ChannelRTCStore = findStoreLazy("ChannelRTCStore"); +export const SortedGuildStore = findStoreLazy("SortedGuildStore"); +export const ExpandedGuildFolderStore = findStoreLazy("ExpandedGuildFolderStore"); +export const ThemeStore = findStoreLazy("ThemeStore"); +export const NitroThemeStore = findStoreLazy("ClientThemesBackgroundStore"); +export const AuthSessionsStore = findStoreLazy("AuthSessionsStore"); +export const StickerStore = findStoreLazy("StickersStore"); +export const UserSettingsProtoStore = findStoreLazy("UserSettingsProtoStore"); +export const UserAffinitiesStore = findStoreLazy("UserAffinitiesStore"); +export const GuildAvailabilityStore = findStoreLazy("GuildAvailabilityStore") as FluxStore & { + totalGuilds: number; + totalUnavailableGuilds: number; + unavailableGuilds: string[]; + isUnavailable(guildId: string): boolean; +}; +export const MediaEngineStore = findStoreLazy("MediaEngineStore");