parent
55af40ee74
commit
e8d90d2b45
@ -0,0 +1,101 @@
|
||||
/*
|
||||
* Vencord, a modification for Discord's desktop app
|
||||
* Copyright (c) 2023 Vendicated and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { addContextMenuPatch, NavContextMenuPatchCallback, removeContextMenuPatch } from "@api/ContextMenu";
|
||||
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 { 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,
|
||||
className: string,
|
||||
config: { context: string; };
|
||||
context: string,
|
||||
onHeightUpdate: Function,
|
||||
position: string,
|
||||
target: HTMLElement,
|
||||
theme: string,
|
||||
user: User;
|
||||
}
|
||||
|
||||
export interface StreamContextProps {
|
||||
appContext: string,
|
||||
className: string,
|
||||
config: { context: string; };
|
||||
context: string,
|
||||
exitFullscreen: Function,
|
||||
onHeightUpdate: Function,
|
||||
position: string,
|
||||
target: HTMLElement,
|
||||
stream: Stream,
|
||||
theme: string,
|
||||
}
|
||||
|
||||
export const handleViewPreview = async ({ guildId, channelId, ownerId }: ApplicationStream | Stream) => {
|
||||
const previewUrl = await ApplicationStreamPreviewStore.getPreviewURL(guildId, channelId, ownerId);
|
||||
if (!previewUrl) return;
|
||||
|
||||
openImageModal(previewUrl);
|
||||
};
|
||||
|
||||
export const addViewStreamContext: NavContextMenuPatchCallback = (children, { userId }: { userId: string | bigint; }) => () => {
|
||||
const streamPreviewItemIdentifier = "view-stream-preview";
|
||||
|
||||
const stream = ApplicationStreamingStore.getAnyStreamForUser(userId);
|
||||
|
||||
const streamPreviewItem = (
|
||||
<Menu.MenuItem
|
||||
label="View Stream Preview"
|
||||
id={streamPreviewItemIdentifier}
|
||||
icon={ScreenshareIcon}
|
||||
action={() => stream && handleViewPreview(stream)}
|
||||
disabled={!stream}
|
||||
/>
|
||||
);
|
||||
|
||||
children.push(<Menu.MenuSeparator />, streamPreviewItem);
|
||||
};
|
||||
|
||||
export const streamContextPatch: NavContextMenuPatchCallback = (children, { stream }: StreamContextProps) => {
|
||||
return addViewStreamContext(children, { userId: stream.ownerId });
|
||||
};
|
||||
|
||||
export const userContextPatch: NavContextMenuPatchCallback = (children, { user }: UserContextProps) => {
|
||||
return addViewStreamContext(children, { userId: user.id });
|
||||
};
|
||||
|
||||
export default definePlugin({
|
||||
name: "BiggerStreamPreview",
|
||||
description: "This plugin allows you to enlarge stream previews",
|
||||
authors: [Devs.phil],
|
||||
start: () => {
|
||||
addContextMenuPatch("user-context", userContextPatch);
|
||||
addContextMenuPatch("stream-context", streamContextPatch);
|
||||
},
|
||||
stop: () => {
|
||||
removeContextMenuPatch("user-context", userContextPatch);
|
||||
removeContextMenuPatch("stream-context", streamContextPatch);
|
||||
}
|
||||
});
|
@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Vencord, a modification for Discord's desktop app
|
||||
* Copyright (c) 2023 Vendicated and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
import { findStoreLazy } from "@webpack";
|
||||
|
||||
import * as t from "./types/stores";
|
||||
|
||||
export const ApplicationStreamPreviewStore: t.ApplicationStreamPreviewStore = findStoreLazy("ApplicationStreamPreviewStore");
|
||||
export const ApplicationStreamingStore: t.ApplicationStreamingStore = findStoreLazy("ApplicationStreamingStore");
|
@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Vencord, a modification for Discord's desktop app
|
||||
* Copyright (c) 2023 Vendicated and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { 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<string | null>;
|
||||
getPreviewURLForStreamKey: (streamKey: string) => ReturnType<ApplicationStreamPreviewStore["getPreviewURL"]>;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Vencord, a modification for Discord's desktop app
|
||||
* Copyright (c) 2023 Vendicated and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { findByPropsLazy } from "@webpack";
|
||||
|
||||
import * as t from "./types/classes";
|
||||
|
||||
export const ModalImageClasses: t.ImageModalClasses = findByPropsLazy("image", "modal");
|
||||
export const ButtonWrapperClasses: t.ButtonWrapperClasses = findByPropsLazy("buttonWrapper", "buttonContent");
|
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Vencord, a modification for Discord's desktop app
|
||||
* Copyright (c) 2023 Vendicated and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
export interface ImageModalClasses {
|
||||
image: string,
|
||||
modal: string,
|
||||
responsiveWidthMobile: string;
|
||||
}
|
||||
|
||||
export interface ButtonWrapperClasses {
|
||||
hoverScale: string;
|
||||
buttonWrapper: string;
|
||||
button: string;
|
||||
iconMask: string;
|
||||
buttonContent: string;
|
||||
icon: string;
|
||||
pulseIcon: string;
|
||||
pulseButton: string;
|
||||
notificationDot: string;
|
||||
sparkleContainer: string;
|
||||
sparkleStar: string;
|
||||
sparklePlus: string;
|
||||
sparkle: string;
|
||||
active: string;
|
||||
}
|
Loading…
Reference in new issue