mirror of
https://github.com/Vendicated/Vencord.git
synced 2024-09-19 22:20:34 +00:00
Compare commits
19 commits
ecbd6ceb1d
...
c274698b90
Author | SHA1 | Date | |
---|---|---|---|
|
c274698b90 | ||
|
06d5bda9e5 | ||
|
754802e212 | ||
|
f20de977b3 | ||
|
6c2222e295 | ||
|
8afd79dd50 | ||
|
65c5897dc3 | ||
|
fce53b9535 | ||
|
fa3f53930c | ||
|
6cce8a8bc4 | ||
|
1848b16536 | ||
|
c572116b97 | ||
|
e26986f66a | ||
|
f12335a371 | ||
|
640d99dcda | ||
|
bcfef05a8a | ||
|
f17b92c2fd | ||
|
292f7d71d3 | ||
|
b822542352 |
44 changed files with 622 additions and 495 deletions
|
@ -407,36 +407,6 @@ export function PencilIcon(props: IconProps) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function PreviewVisible(props: IconProps) {
|
|
||||||
return (
|
|
||||||
<Icon
|
|
||||||
{...props}
|
|
||||||
className={classes(props.className, "vc-preview-visible")}
|
|
||||||
viewBox="0 0 226 226"
|
|
||||||
>
|
|
||||||
<path
|
|
||||||
fill="currentColor"
|
|
||||||
d="M113,37.66667c-75.33333,0 -103.58333,75.33333 -103.58333,75.33333c0,0 28.25,75.33333 103.58333,75.33333c75.33333,0 103.58333,-75.33333 103.58333,-75.33333c0,0 -28.25,-75.33333 -103.58333,-75.33333zM113,65.91667c25.99942,0 47.08333,21.08392 47.08333,47.08333c0,25.99942 -21.08392,47.08333 -47.08333,47.08333c-25.99942,0 -47.08333,-21.08392 -47.08333,-47.08333c0,-25.99942 21.08392,-47.08333 47.08333,-47.08333zM113,84.75c-15.60204,0 -28.25,12.64796 -28.25,28.25c0,15.60204 12.64796,28.25 28.25,28.25c15.60204,0 28.25,-12.64796 28.25,-28.25c0,-15.60204 -12.64796,-28.25 -28.25,-28.25z"
|
|
||||||
/>
|
|
||||||
</Icon>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function PreviewInvisible(props: IconProps) {
|
|
||||||
return (
|
|
||||||
<Icon
|
|
||||||
{...props}
|
|
||||||
className={classes(props.className, "vc-preview-invisible")}
|
|
||||||
viewBox="0 0 226 226"
|
|
||||||
>
|
|
||||||
<path
|
|
||||||
fill="currentColor"
|
|
||||||
d="M37.57471,28.15804c-3.83186,0.00101 -7.28105,2.32361 -8.72295,5.87384c-1.4419,3.55022 -0.58897,7.62011 2.15703,10.29267l16.79183,16.79183c-18.19175,14.60996 -29.9888,32.52303 -35.82747,43.03711c-3.12633,5.63117 -3.02363,12.41043 0.03678,18.07927c10.87625,20.13283 42.14532,66.10058 100.99007,66.10058c19.54493,0 35.83986,-5.13463 49.36394,-12.65365l19.31152,19.31152c2.36186,2.46002 5.8691,3.45098 9.16909,2.5907c3.3,-0.86028 5.87708,-3.43736 6.73736,-6.73736c0.86028,-3.3 -0.13068,-6.80724 -2.5907,-9.16909l-150.66666,-150.66667c-1.77289,-1.82243 -4.20732,-2.8506 -6.74984,-2.85075zM113,37.66667c-11.413,0 -21.60375,1.88068 -30.91683,4.81869l24.11182,24.11182c2.23175,-0.32958 4.47909,-0.6805 6.80501,-0.6805c25.99942,0 47.08333,21.08392 47.08333,47.08333c0,2.32592 -0.35092,4.57326 -0.6805,6.80501l32.29623,32.29623c10.1135,-11.22467 17.51573,-22.61015 21.94157,-30.18115c3.3335,-5.68767 3.32011,-12.67425 0.16553,-18.4655c-11.00808,-20.27408 -42.2439,-65.78792 -100.80615,-65.78792zM73.77002,87.08577l13.77555,13.77556c-1.77707,3.67147 -2.79557,7.77466 -2.79557,12.13867c0,15.60342 12.64658,28.25 28.25,28.25c4.364,0 8.46719,-1.01851 12.13867,-2.79557l13.79395,13.79395c-9.356,6.20362 -21.03043,9.17606 -33.4733,7.24642c-19.75617,-3.06983 -35.88427,-19.19794 -38.9541,-38.9541c-1.92879,-12.43739 1.0665,-24.10096 7.26481,-33.45491z"
|
|
||||||
/>
|
|
||||||
</Icon>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const WebsiteIconDark = "/assets/e1e96d89e192de1997f73730db26e94f.svg";
|
const WebsiteIconDark = "/assets/e1e96d89e192de1997f73730db26e94f.svg";
|
||||||
const WebsiteIconLight = "/assets/730f58bcfd5a57a5e22460c445a0c6cf.svg";
|
const WebsiteIconLight = "/assets/730f58bcfd5a57a5e22460c445a0c6cf.svg";
|
||||||
const GithubIconLight = "/assets/3ff98ad75ac94fa883af5ed62d17c459.svg";
|
const GithubIconLight = "/assets/3ff98ad75ac94fa883af5ed62d17c459.svg";
|
||||||
|
|
|
@ -292,10 +292,10 @@ export default function PluginSettings() {
|
||||||
|
|
||||||
if (!pluginFilter(p)) continue;
|
if (!pluginFilter(p)) continue;
|
||||||
|
|
||||||
const isRequired = p.required || depMap[p.name]?.some(d => settings.plugins[d].enabled);
|
const isRequired = p.required || p.isDependency || depMap[p.name]?.some(d => settings.plugins[d].enabled);
|
||||||
|
|
||||||
if (isRequired) {
|
if (isRequired) {
|
||||||
const tooltipText = p.required
|
const tooltipText = p.required || !depMap[p.name]
|
||||||
? "This plugin is required for Vencord to function."
|
? "This plugin is required for Vencord to function."
|
||||||
: makeDependencyList(depMap[p.name]?.filter(d => settings.plugins[d].enabled));
|
: makeDependencyList(depMap[p.name]?.filter(d => settings.plugins[d].enabled));
|
||||||
|
|
||||||
|
|
|
@ -142,7 +142,7 @@ export default definePlugin({
|
||||||
required: true,
|
required: true,
|
||||||
description: "Helps us provide support to you",
|
description: "Helps us provide support to you",
|
||||||
authors: [Devs.Ven],
|
authors: [Devs.Ven],
|
||||||
dependencies: ["CommandsAPI", "UserSettingsAPI", "MessageAccessoriesAPI"],
|
dependencies: ["UserSettingsAPI", "MessageAccessoriesAPI"],
|
||||||
|
|
||||||
settings,
|
settings,
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ interface ActivityButton {
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Activity {
|
interface Activity {
|
||||||
state: string;
|
state?: string;
|
||||||
details?: string;
|
details?: string;
|
||||||
timestamps?: {
|
timestamps?: {
|
||||||
start?: number;
|
start?: number;
|
||||||
|
@ -52,8 +52,8 @@ const enum ActivityFlag {
|
||||||
|
|
||||||
export interface TrackData {
|
export interface TrackData {
|
||||||
name: string;
|
name: string;
|
||||||
album: string;
|
album?: string;
|
||||||
artist: string;
|
artist?: string;
|
||||||
|
|
||||||
appleMusicLink?: string;
|
appleMusicLink?: string;
|
||||||
songLink?: string;
|
songLink?: string;
|
||||||
|
@ -61,8 +61,8 @@ export interface TrackData {
|
||||||
albumArtwork?: string;
|
albumArtwork?: string;
|
||||||
artistArtwork?: string;
|
artistArtwork?: string;
|
||||||
|
|
||||||
playerPosition: number;
|
playerPosition?: number;
|
||||||
duration: number;
|
duration?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
const enum AssetImageType {
|
const enum AssetImageType {
|
||||||
|
@ -120,7 +120,7 @@ const settings = definePluginSettings({
|
||||||
stateString: {
|
stateString: {
|
||||||
type: OptionType.STRING,
|
type: OptionType.STRING,
|
||||||
description: "Activity state format string",
|
description: "Activity state format string",
|
||||||
default: "{artist}"
|
default: "{artist} · {album}"
|
||||||
},
|
},
|
||||||
largeImageType: {
|
largeImageType: {
|
||||||
type: OptionType.SELECT,
|
type: OptionType.SELECT,
|
||||||
|
@ -155,8 +155,8 @@ const settings = definePluginSettings({
|
||||||
function customFormat(formatStr: string, data: TrackData) {
|
function customFormat(formatStr: string, data: TrackData) {
|
||||||
return formatStr
|
return formatStr
|
||||||
.replaceAll("{name}", data.name)
|
.replaceAll("{name}", data.name)
|
||||||
.replaceAll("{album}", data.album)
|
.replaceAll("{album}", data.album ?? "")
|
||||||
.replaceAll("{artist}", data.artist);
|
.replaceAll("{artist}", data.artist ?? "");
|
||||||
}
|
}
|
||||||
|
|
||||||
function getImageAsset(type: AssetImageType, data: TrackData) {
|
function getImageAsset(type: AssetImageType, data: TrackData) {
|
||||||
|
@ -212,14 +212,16 @@ export default definePlugin({
|
||||||
|
|
||||||
const assets: ActivityAssets = {};
|
const assets: ActivityAssets = {};
|
||||||
|
|
||||||
|
const isRadio = Number.isNaN(trackData.duration) && (trackData.playerPosition === 0);
|
||||||
|
|
||||||
if (settings.store.largeImageType !== AssetImageType.Disabled) {
|
if (settings.store.largeImageType !== AssetImageType.Disabled) {
|
||||||
assets.large_image = largeImageAsset;
|
assets.large_image = largeImageAsset;
|
||||||
assets.large_text = customFormat(settings.store.largeTextString, trackData);
|
if (!isRadio) assets.large_text = customFormat(settings.store.largeTextString, trackData);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (settings.store.smallImageType !== AssetImageType.Disabled) {
|
if (settings.store.smallImageType !== AssetImageType.Disabled) {
|
||||||
assets.small_image = smallImageAsset;
|
assets.small_image = smallImageAsset;
|
||||||
assets.small_text = customFormat(settings.store.smallTextString, trackData);
|
if (!isRadio) assets.small_text = customFormat(settings.store.smallTextString, trackData);
|
||||||
}
|
}
|
||||||
|
|
||||||
const buttons: ActivityButton[] = [];
|
const buttons: ActivityButton[] = [];
|
||||||
|
@ -243,17 +245,17 @@ export default definePlugin({
|
||||||
|
|
||||||
name: customFormat(settings.store.nameString, trackData),
|
name: customFormat(settings.store.nameString, trackData),
|
||||||
details: customFormat(settings.store.detailsString, trackData),
|
details: customFormat(settings.store.detailsString, trackData),
|
||||||
state: customFormat(settings.store.stateString, trackData),
|
state: isRadio ? undefined : customFormat(settings.store.stateString, trackData),
|
||||||
|
|
||||||
timestamps: (settings.store.enableTimestamps ? {
|
timestamps: (trackData.playerPosition && trackData.duration && settings.store.enableTimestamps) ? {
|
||||||
start: Date.now() - (trackData.playerPosition * 1000),
|
start: Date.now() - (trackData.playerPosition * 1000),
|
||||||
end: Date.now() - (trackData.playerPosition * 1000) + (trackData.duration * 1000),
|
end: Date.now() - (trackData.playerPosition * 1000) + (trackData.duration * 1000),
|
||||||
} : undefined),
|
} : undefined,
|
||||||
|
|
||||||
assets,
|
assets,
|
||||||
|
|
||||||
buttons: buttons.length ? buttons.map(v => v.label) : undefined,
|
buttons: !isRadio && buttons.length ? buttons.map(v => v.label) : undefined,
|
||||||
metadata: { button_urls: buttons.map(v => v.url) || undefined, },
|
metadata: !isRadio && buttons.length ? { button_urls: buttons.map(v => v.url) } : undefined,
|
||||||
|
|
||||||
type: settings.store.activityType,
|
type: settings.store.activityType,
|
||||||
flags: ActivityFlag.INSTANCE,
|
flags: ActivityFlag.INSTANCE,
|
||||||
|
|
|
@ -11,37 +11,11 @@ import type { TrackData } from ".";
|
||||||
|
|
||||||
const exec = promisify(execFile);
|
const exec = promisify(execFile);
|
||||||
|
|
||||||
// function exec(file: string, args: string[] = []) {
|
|
||||||
// return new Promise<{ code: number | null, stdout: string | null, stderr: string | null; }>((resolve, reject) => {
|
|
||||||
// const process = spawn(file, args, { stdio: [null, "pipe", "pipe"] });
|
|
||||||
|
|
||||||
// let stdout: string | null = null;
|
|
||||||
// process.stdout.on("data", (chunk: string) => { stdout ??= ""; stdout += chunk; });
|
|
||||||
// let stderr: string | null = null;
|
|
||||||
// process.stderr.on("data", (chunk: string) => { stdout ??= ""; stderr += chunk; });
|
|
||||||
|
|
||||||
// process.on("exit", code => { resolve({ code, stdout, stderr }); });
|
|
||||||
// process.on("error", err => reject(err));
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
async function applescript(cmds: string[]) {
|
async function applescript(cmds: string[]) {
|
||||||
const { stdout } = await exec("osascript", cmds.map(c => ["-e", c]).flat());
|
const { stdout } = await exec("osascript", cmds.map(c => ["-e", c]).flat());
|
||||||
return stdout;
|
return stdout;
|
||||||
}
|
}
|
||||||
|
|
||||||
function makeSearchUrl(type: string, query: string) {
|
|
||||||
const url = new URL("https://tools.applemediaservices.com/api/apple-media/music/US/search.json");
|
|
||||||
url.searchParams.set("types", type);
|
|
||||||
url.searchParams.set("limit", "1");
|
|
||||||
url.searchParams.set("term", query);
|
|
||||||
return url;
|
|
||||||
}
|
|
||||||
|
|
||||||
const requestOptions: RequestInit = {
|
|
||||||
headers: { "user-agent": "Mozilla/5.0 (Windows NT 10.0; rv:125.0) Gecko/20100101 Firefox/125.0" },
|
|
||||||
};
|
|
||||||
|
|
||||||
interface RemoteData {
|
interface RemoteData {
|
||||||
appleMusicLink?: string,
|
appleMusicLink?: string,
|
||||||
songLink?: string,
|
songLink?: string,
|
||||||
|
@ -51,6 +25,24 @@ interface RemoteData {
|
||||||
|
|
||||||
let cachedRemoteData: { id: string, data: RemoteData; } | { id: string, failures: number; } | null = null;
|
let cachedRemoteData: { id: string, data: RemoteData; } | { id: string, failures: number; } | null = null;
|
||||||
|
|
||||||
|
const APPLE_MUSIC_BUNDLE_REGEX = /<script type="module" crossorigin src="([a-zA-Z0-9.\-/]+)"><\/script>/;
|
||||||
|
const APPLE_MUSIC_TOKEN_REGEX = /\w+="([A-Za-z0-9-_]*\.[A-Za-z0-9-_]*\.[A-Za-z0-9-_]*)",\w+="x-apple-jingle-correlation-key"/;
|
||||||
|
|
||||||
|
let cachedToken: string | undefined = undefined;
|
||||||
|
|
||||||
|
const getToken = async () => {
|
||||||
|
if (cachedToken) return cachedToken;
|
||||||
|
|
||||||
|
const html = await fetch("https://music.apple.com/").then(r => r.text());
|
||||||
|
const bundleUrl = new URL(html.match(APPLE_MUSIC_BUNDLE_REGEX)![1], "https://music.apple.com/");
|
||||||
|
|
||||||
|
const bundle = await fetch(bundleUrl).then(r => r.text());
|
||||||
|
const token = bundle.match(APPLE_MUSIC_TOKEN_REGEX)![1];
|
||||||
|
|
||||||
|
cachedToken = token;
|
||||||
|
return token;
|
||||||
|
};
|
||||||
|
|
||||||
async function fetchRemoteData({ id, name, artist, album }: { id: string, name: string, artist: string, album: string; }) {
|
async function fetchRemoteData({ id, name, artist, album }: { id: string, name: string, artist: string, album: string; }) {
|
||||||
if (id === cachedRemoteData?.id) {
|
if (id === cachedRemoteData?.id) {
|
||||||
if ("data" in cachedRemoteData) return cachedRemoteData.data;
|
if ("data" in cachedRemoteData) return cachedRemoteData.data;
|
||||||
|
@ -58,21 +50,39 @@ async function fetchRemoteData({ id, name, artist, album }: { id: string, name:
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const [songData, artistData] = await Promise.all([
|
const dataUrl = new URL("https://amp-api-edge.music.apple.com/v1/catalog/us/search");
|
||||||
fetch(makeSearchUrl("songs", artist + " " + album + " " + name), requestOptions).then(r => r.json()),
|
dataUrl.searchParams.set("platform", "web");
|
||||||
fetch(makeSearchUrl("artists", artist.split(/ *[,&] */)[0]), requestOptions).then(r => r.json())
|
dataUrl.searchParams.set("l", "en-US");
|
||||||
]);
|
dataUrl.searchParams.set("limit", "1");
|
||||||
|
dataUrl.searchParams.set("with", "serverBubbles");
|
||||||
|
dataUrl.searchParams.set("types", "songs");
|
||||||
|
dataUrl.searchParams.set("term", `${name} ${artist} ${album}`);
|
||||||
|
dataUrl.searchParams.set("include[songs]", "artists");
|
||||||
|
|
||||||
const appleMusicLink = songData?.songs?.data[0]?.attributes.url;
|
const token = await getToken();
|
||||||
const songLink = songData?.songs?.data[0]?.id ? `https://song.link/i/${songData?.songs?.data[0]?.id}` : undefined;
|
|
||||||
|
|
||||||
const albumArtwork = songData?.songs?.data[0]?.attributes.artwork.url.replace("{w}", "512").replace("{h}", "512");
|
const songData = await fetch(dataUrl, {
|
||||||
const artistArtwork = artistData?.artists?.data[0]?.attributes.artwork.url.replace("{w}", "512").replace("{h}", "512");
|
headers: {
|
||||||
|
"accept": "*/*",
|
||||||
|
"accept-language": "en-US,en;q=0.9",
|
||||||
|
"authorization": `Bearer ${token}`,
|
||||||
|
"user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36",
|
||||||
|
"origin": "https://music.apple.com",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.then(r => r.json())
|
||||||
|
.then(data => data.results.song.data[0]);
|
||||||
|
|
||||||
cachedRemoteData = {
|
cachedRemoteData = {
|
||||||
id,
|
id,
|
||||||
data: { appleMusicLink, songLink, albumArtwork, artistArtwork }
|
data: {
|
||||||
|
appleMusicLink: songData.attributes.url,
|
||||||
|
songLink: `https://song.link/i/${songData.id}`,
|
||||||
|
albumArtwork: songData.attributes.artwork.url.replace("{w}x{h}", "512x512"),
|
||||||
|
artistArtwork: songData.relationships.artists.data[0].attributes.artwork.url.replace("{w}x{h}", "512x512"),
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return cachedRemoteData.data;
|
return cachedRemoteData.data;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("[AppleMusicRichPresence] Failed to fetch remote data:", e);
|
console.error("[AppleMusicRichPresence] Failed to fetch remote data:", e);
|
||||||
|
|
11
src/plugins/betterFolders/README.md
Normal file
11
src/plugins/betterFolders/README.md
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
# Better Folders
|
||||||
|
|
||||||
|
Better Folders offers a variety of options to improve your folder experience
|
||||||
|
|
||||||
|
Always show the folder icon, regardless of if the folder is open or not
|
||||||
|
|
||||||
|
Only have one folder open at a time
|
||||||
|
|
||||||
|
Open folders in a sidebar:
|
||||||
|
|
||||||
|
![A folder open in a separate sidebar](https://github.com/user-attachments/assets/432d3146-8091-4bae-9c1e-c19046c72947)
|
|
@ -30,9 +30,9 @@ enum FolderIconDisplay {
|
||||||
MoreThanOneFolderExpanded
|
MoreThanOneFolderExpanded
|
||||||
}
|
}
|
||||||
|
|
||||||
const GuildsTree = findLazy(m => m.prototype?.moveNextTo);
|
|
||||||
const SortedGuildStore = findStoreLazy("SortedGuildStore");
|
|
||||||
export const ExpandedGuildFolderStore = findStoreLazy("ExpandedGuildFolderStore");
|
export const ExpandedGuildFolderStore = findStoreLazy("ExpandedGuildFolderStore");
|
||||||
|
const SortedGuildStore = findStoreLazy("SortedGuildStore");
|
||||||
|
const GuildsTree = findLazy(m => m.prototype?.moveNextTo);
|
||||||
const FolderUtils = findByPropsLazy("move", "toggleGuildFolderExpand");
|
const FolderUtils = findByPropsLazy("move", "toggleGuildFolderExpand");
|
||||||
|
|
||||||
let lastGuildId = null as string | null;
|
let lastGuildId = null as string | null;
|
||||||
|
@ -118,17 +118,17 @@ export default definePlugin({
|
||||||
// If we are rendering the Better Folders sidebar, we filter out guilds that are not in folders and unexpanded folders
|
// If we are rendering the Better Folders sidebar, we filter out guilds that are not in folders and unexpanded folders
|
||||||
{
|
{
|
||||||
match: /\[(\i)\]=(\(0,\i\.\i\).{0,40}getGuildsTree\(\).+?}\))(?=,)/,
|
match: /\[(\i)\]=(\(0,\i\.\i\).{0,40}getGuildsTree\(\).+?}\))(?=,)/,
|
||||||
replace: (_, originalTreeVar, rest) => `[betterFoldersOriginalTree]=${rest},${originalTreeVar}=$self.getGuildTree(!!arguments[0].isBetterFolders,betterFoldersOriginalTree,arguments[0].betterFoldersExpandedIds)`
|
replace: (_, originalTreeVar, rest) => `[betterFoldersOriginalTree]=${rest},${originalTreeVar}=$self.getGuildTree(!!arguments[0]?.isBetterFolders,betterFoldersOriginalTree,arguments[0]?.betterFoldersExpandedIds)`
|
||||||
},
|
},
|
||||||
// If we are rendering the Better Folders sidebar, we filter out everything but the servers and folders from the GuildsBar Guild List children
|
// If we are rendering the Better Folders sidebar, we filter out everything but the servers and folders from the GuildsBar Guild List children
|
||||||
{
|
{
|
||||||
match: /lastTargetNode:\i\[\i\.length-1\].+?Fragment.+?\]}\)\]/,
|
match: /lastTargetNode:\i\[\i\.length-1\].+?Fragment.+?\]}\)\]/,
|
||||||
replace: "$&.filter($self.makeGuildsBarGuildListFilter(!!arguments[0].isBetterFolders))"
|
replace: "$&.filter($self.makeGuildsBarGuildListFilter(!!arguments[0]?.isBetterFolders))"
|
||||||
},
|
},
|
||||||
// If we are rendering the Better Folders sidebar, we filter out everything but the scroller for the guild list from the GuildsBar Tree children
|
// If we are rendering the Better Folders sidebar, we filter out everything but the scroller for the guild list from the GuildsBar Tree children
|
||||||
{
|
{
|
||||||
match: /unreadMentionsIndicatorBottom,.+?}\)\]/,
|
match: /unreadMentionsIndicatorBottom,.+?}\)\]/,
|
||||||
replace: "$&.filter($self.makeGuildsBarTreeFilter(!!arguments[0].isBetterFolders))"
|
replace: "$&.filter($self.makeGuildsBarTreeFilter(!!arguments[0]?.isBetterFolders))"
|
||||||
},
|
},
|
||||||
// Export the isBetterFolders variable to the folders component
|
// Export the isBetterFolders variable to the folders component
|
||||||
{
|
{
|
||||||
|
@ -167,31 +167,31 @@ export default definePlugin({
|
||||||
{
|
{
|
||||||
predicate: () => settings.store.keepIcons,
|
predicate: () => settings.store.keepIcons,
|
||||||
match: /(?<=let{folderNode:\i,setNodeRef:\i,.+?expanded:(\i),.+?;)(?=let)/,
|
match: /(?<=let{folderNode:\i,setNodeRef:\i,.+?expanded:(\i),.+?;)(?=let)/,
|
||||||
replace: (_, isExpanded) => `${isExpanded}=!!arguments[0].isBetterFolders&&${isExpanded};`
|
replace: (_, isExpanded) => `${isExpanded}=!!arguments[0]?.isBetterFolders&&${isExpanded};`
|
||||||
},
|
},
|
||||||
// Disable expanding and collapsing folders transition in the normal GuildsBar sidebar
|
// Disable expanding and collapsing folders transition in the normal GuildsBar sidebar
|
||||||
{
|
{
|
||||||
predicate: () => !settings.store.keepIcons,
|
predicate: () => !settings.store.keepIcons,
|
||||||
match: /(?<=\.Messages\.SERVER_FOLDER_PLACEHOLDER.+?useTransition\)\()/,
|
match: /(?<=\.Messages\.SERVER_FOLDER_PLACEHOLDER.+?useTransition\)\()/,
|
||||||
replace: "!!arguments[0].isBetterFolders&&"
|
replace: "$self.shouldShowTransition(arguments[0])&&"
|
||||||
},
|
},
|
||||||
// If we are rendering the normal GuildsBar sidebar, we avoid rendering guilds from folders that are expanded
|
// If we are rendering the normal GuildsBar sidebar, we avoid rendering guilds from folders that are expanded
|
||||||
{
|
{
|
||||||
predicate: () => !settings.store.keepIcons,
|
predicate: () => !settings.store.keepIcons,
|
||||||
match: /expandedFolderBackground,.+?,(?=\i\(\(\i,\i,\i\)=>{let{key.{0,45}ul)(?<=selected:\i,expanded:(\i),.+?)/,
|
match: /expandedFolderBackground,.+?,(?=\i\(\(\i,\i,\i\)=>{let{key.{0,45}ul)(?<=selected:\i,expanded:(\i),.+?)/,
|
||||||
replace: (m, isExpanded) => `${m}!arguments[0].isBetterFolders&&${isExpanded}?null:`
|
replace: (m, isExpanded) => `${m}$self.shouldRenderContents(arguments[0],${isExpanded})?null:`
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// Decide if we should render the expanded folder background if we are rendering the Better Folders sidebar
|
// Decide if we should render the expanded folder background if we are rendering the Better Folders sidebar
|
||||||
predicate: () => settings.store.showFolderIcon !== FolderIconDisplay.Always,
|
predicate: () => settings.store.showFolderIcon !== FolderIconDisplay.Always,
|
||||||
match: /(?<=\.wrapper,children:\[)/,
|
match: /(?<=\.wrapper,children:\[)/,
|
||||||
replace: "$self.shouldShowFolderIconAndBackground(!!arguments[0].isBetterFolders,arguments[0].betterFoldersExpandedIds)&&"
|
replace: "$self.shouldShowFolderIconAndBackground(!!arguments[0]?.isBetterFolders,arguments[0]?.betterFoldersExpandedIds)&&"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// Decide if we should render the expanded folder icon if we are rendering the Better Folders sidebar
|
// Decide if we should render the expanded folder icon if we are rendering the Better Folders sidebar
|
||||||
predicate: () => settings.store.showFolderIcon !== FolderIconDisplay.Always,
|
predicate: () => settings.store.showFolderIcon !== FolderIconDisplay.Always,
|
||||||
match: /(?<=\.expandedFolderBackground.+?}\),)(?=\i,)/,
|
match: /(?<=\.expandedFolderBackground.+?}\),)(?=\i,)/,
|
||||||
replace: "!$self.shouldShowFolderIconAndBackground(!!arguments[0].isBetterFolders,arguments[0].betterFoldersExpandedIds)?null:"
|
replace: "!$self.shouldShowFolderIconAndBackground(!!arguments[0]?.isBetterFolders,arguments[0]?.betterFoldersExpandedIds)?null:"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -201,7 +201,7 @@ export default definePlugin({
|
||||||
replacement: {
|
replacement: {
|
||||||
// Render the Better Folders sidebar
|
// Render the Better Folders sidebar
|
||||||
match: /(?<=({className:\i\.guilds,themeOverride:\i})\))/,
|
match: /(?<=({className:\i\.guilds,themeOverride:\i})\))/,
|
||||||
replace: ",$self.FolderSideBar($1)"
|
replace: ",$self.FolderSideBar({...$1})"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -306,7 +306,20 @@ export default definePlugin({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
FolderSideBar: guildsBarProps => <FolderSideBar {...guildsBarProps} />,
|
shouldShowTransition(props: any) {
|
||||||
|
// Pending guilds
|
||||||
|
if (props?.folderNode?.id === 1) return true;
|
||||||
|
|
||||||
closeFolders
|
return !!props?.isBetterFolders;
|
||||||
|
},
|
||||||
|
|
||||||
|
shouldRenderContents(props: any, isExpanded: boolean) {
|
||||||
|
// Pending guilds
|
||||||
|
if (props?.folderNode?.id === 1) return false;
|
||||||
|
|
||||||
|
return !props?.isBetterFolders && isExpanded;
|
||||||
|
},
|
||||||
|
|
||||||
|
FolderSideBar,
|
||||||
|
closeFolders,
|
||||||
});
|
});
|
||||||
|
|
68
src/plugins/betterSettings/PluginsSubmenu.tsx
Normal file
68
src/plugins/betterSettings/PluginsSubmenu.tsx
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
/*
|
||||||
|
* Vencord, a Discord client mod
|
||||||
|
* Copyright (c) 2024 Vendicated and contributors
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { openPluginModal } from "@components/PluginSettings/PluginModal";
|
||||||
|
import { isObjectEmpty } from "@utils/misc";
|
||||||
|
import { Alerts, i18n, Menu, useMemo, useState } from "@webpack/common";
|
||||||
|
|
||||||
|
import Plugins from "~plugins";
|
||||||
|
|
||||||
|
function onRestartNeeded() {
|
||||||
|
Alerts.show({
|
||||||
|
title: "Restart required",
|
||||||
|
body: <p>You have changed settings that require a restart.</p>,
|
||||||
|
confirmText: "Restart now",
|
||||||
|
cancelText: "Later!",
|
||||||
|
onConfirm: () => location.reload()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function PluginsSubmenu() {
|
||||||
|
const sortedPlugins = useMemo(() => Object.values(Plugins)
|
||||||
|
.sort((a, b) => a.name.localeCompare(b.name)), []);
|
||||||
|
const [query, setQuery] = useState("");
|
||||||
|
|
||||||
|
const search = query.toLowerCase();
|
||||||
|
const include = (p: typeof Plugins[keyof typeof Plugins]) => (
|
||||||
|
Vencord.Plugins.isPluginEnabled(p.name)
|
||||||
|
&& p.options && !isObjectEmpty(p.options)
|
||||||
|
&& (
|
||||||
|
p.name.toLowerCase().includes(search)
|
||||||
|
|| p.description.toLowerCase().includes(search)
|
||||||
|
|| p.tags?.some(t => t.toLowerCase().includes(search))
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
const plugins = sortedPlugins.filter(include);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Menu.MenuControlItem
|
||||||
|
id="vc-plugins-search"
|
||||||
|
control={(props, ref) => (
|
||||||
|
<Menu.MenuSearchControl
|
||||||
|
{...props}
|
||||||
|
query={query}
|
||||||
|
onChange={setQuery}
|
||||||
|
ref={ref}
|
||||||
|
placeholder={i18n.Messages.SEARCH}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{!!plugins.length && <Menu.MenuSeparator />}
|
||||||
|
|
||||||
|
{plugins.map(p => (
|
||||||
|
<Menu.MenuItem
|
||||||
|
key={p.name}
|
||||||
|
id={p.name}
|
||||||
|
label={p.name}
|
||||||
|
action={() => openPluginModal(p, onRestartNeeded)}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
|
@ -13,6 +13,8 @@ import { waitFor } from "@webpack";
|
||||||
import { ComponentDispatch, FocusLock, i18n, Menu, useEffect, useRef } from "@webpack/common";
|
import { ComponentDispatch, FocusLock, i18n, Menu, useEffect, useRef } from "@webpack/common";
|
||||||
import type { HTMLAttributes, ReactElement } from "react";
|
import type { HTMLAttributes, ReactElement } from "react";
|
||||||
|
|
||||||
|
import PluginsSubmenu from "./PluginsSubmenu";
|
||||||
|
|
||||||
type SettingsEntry = { section: string, label: string; };
|
type SettingsEntry = { section: string, label: string; };
|
||||||
|
|
||||||
const cl = classNameFactory("");
|
const cl = classNameFactory("");
|
||||||
|
@ -118,13 +120,21 @@ export default definePlugin({
|
||||||
},
|
},
|
||||||
{ // Settings cog context menu
|
{ // Settings cog context menu
|
||||||
find: "Messages.USER_SETTINGS_ACTIONS_MENU_LABEL",
|
find: "Messages.USER_SETTINGS_ACTIONS_MENU_LABEL",
|
||||||
replacement: {
|
replacement: [
|
||||||
match: /(EXPERIMENTS:.+?)(\(0,\i.\i\)\(\))(?=\.filter\(\i=>\{let\{section:\i\}=)/,
|
{
|
||||||
replace: "$1$self.wrapMenu($2)"
|
match: /(EXPERIMENTS:.+?)(\(0,\i.\i\)\(\))(?=\.filter\(\i=>\{let\{section:\i\}=)/,
|
||||||
}
|
replace: "$1$self.wrapMenu($2)"
|
||||||
}
|
},
|
||||||
|
{
|
||||||
|
match: /case \i\.\i\.DEVELOPER_OPTIONS:return \i;/,
|
||||||
|
replace: "$&case 'VencordPlugins':return $self.PluginsSubmenu();"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
],
|
],
|
||||||
|
|
||||||
|
PluginsSubmenu,
|
||||||
|
|
||||||
// This is the very outer layer of the entire ui, so we can't wrap this in an ErrorBoundary
|
// This is the very outer layer of the entire ui, so we can't wrap this in an ErrorBoundary
|
||||||
// without possibly also catching unrelated errors of children.
|
// without possibly also catching unrelated errors of children.
|
||||||
//
|
//
|
||||||
|
|
|
@ -126,7 +126,7 @@ export default definePlugin({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
find: '"Handling ping: "',
|
find: '"_handleLocalVideoDisabled: ',
|
||||||
predicate: () => settings.store.disableNoisyLoggers,
|
predicate: () => settings.store.disableNoisyLoggers,
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /new \i\.\i\("RTCConnection\("\.concat.+?\)\)(?=,)/,
|
match: /new \i\.\i\("RTCConnection\("\.concat.+?\)\)(?=,)/,
|
||||||
|
|
|
@ -23,12 +23,13 @@ import { ErrorCard } from "@components/ErrorCard";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import { Margins } from "@utils/margins";
|
import { Margins } from "@utils/margins";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { findByPropsLazy } from "@webpack";
|
import { findByPropsLazy, findLazy } from "@webpack";
|
||||||
import { Forms, React } from "@webpack/common";
|
import { Forms, React } from "@webpack/common";
|
||||||
|
|
||||||
import hideBugReport from "./hideBugReport.css?managed";
|
import hideBugReport from "./hideBugReport.css?managed";
|
||||||
|
|
||||||
const KbdStyles = findByPropsLazy("key", "combo");
|
const KbdStyles = findByPropsLazy("key", "combo");
|
||||||
|
const BugReporterExperiment = findLazy(m => m?.definition?.id === "2024-09_bug_reporter");
|
||||||
|
|
||||||
const settings = definePluginSettings({
|
const settings = definePluginSettings({
|
||||||
toolbarDevMenu: {
|
toolbarDevMenu: {
|
||||||
|
@ -78,8 +79,8 @@ export default definePlugin({
|
||||||
{
|
{
|
||||||
find: "toolbar:function",
|
find: "toolbar:function",
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /\i\.isStaff\(\)/,
|
match: /hasBugReporterAccess:(\i)/,
|
||||||
replace: "true"
|
replace: "_hasBugReporterAccess:$1=true"
|
||||||
},
|
},
|
||||||
predicate: () => settings.store.toolbarDevMenu
|
predicate: () => settings.store.toolbarDevMenu
|
||||||
},
|
},
|
||||||
|
@ -91,10 +92,18 @@ export default definePlugin({
|
||||||
match: /\i\.isDM\(\)\|\|\i\.isThread\(\)/,
|
match: /\i\.isDM\(\)\|\|\i\.isThread\(\)/,
|
||||||
replace: "false",
|
replace: "false",
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
// enable option to always record clips even if you are not streaming
|
||||||
|
{
|
||||||
|
find: "isDecoupledGameClippingEnabled(){",
|
||||||
|
replacement: {
|
||||||
|
match: /\i\.isStaff\(\)/,
|
||||||
|
replace: "true"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
start: () => enableStyle(hideBugReport),
|
start: () => !BugReporterExperiment.getCurrentConfig().hasBugReporterAccess && enableStyle(hideBugReport),
|
||||||
stop: () => disableStyle(hideBugReport),
|
stop: () => disableStyle(hideBugReport),
|
||||||
|
|
||||||
settingsAboutComponent: () => {
|
settingsAboutComponent: () => {
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
# FileViewer
|
|
||||||
|
|
||||||
Allows you to Preview PDF Files without having to download them
|
|
|
@ -1,28 +0,0 @@
|
||||||
/*
|
|
||||||
* Vencord, a Discord client mod
|
|
||||||
* Copyright (c) 2024 Vendicated and contributors
|
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { IpcMainInvokeEvent } from "electron";
|
|
||||||
import { request } from "https";
|
|
||||||
|
|
||||||
export async function getBufferResponse(_: IpcMainInvokeEvent, url: string) {
|
|
||||||
return new Promise<Buffer>((resolve, reject) => {
|
|
||||||
const req = request(new URL(url), { method: "GET" }, res => {
|
|
||||||
const chunks: Uint8Array[] = [];
|
|
||||||
|
|
||||||
res.on("data", function (chunk) {
|
|
||||||
chunks.push(chunk);
|
|
||||||
});
|
|
||||||
|
|
||||||
res.on("end", function () {
|
|
||||||
const body = Buffer.concat(chunks);
|
|
||||||
resolve(body);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
req.on("error", reject);
|
|
||||||
req.end();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
|
@ -27,7 +27,6 @@ export default definePlugin({
|
||||||
name: "FriendInvites",
|
name: "FriendInvites",
|
||||||
description: "Create and manage friend invite links via slash commands (/create friend invite, /view friend invites, /revoke friend invites).",
|
description: "Create and manage friend invite links via slash commands (/create friend invite, /view friend invites, /revoke friend invites).",
|
||||||
authors: [Devs.afn, Devs.Dziurwa],
|
authors: [Devs.afn, Devs.Dziurwa],
|
||||||
dependencies: ["CommandsAPI"],
|
|
||||||
commands: [
|
commands: [
|
||||||
{
|
{
|
||||||
name: "create friend invite",
|
name: "create friend invite",
|
||||||
|
|
|
@ -105,6 +105,11 @@ for (const p of pluginsValues) if (isPluginEnabled(p.name)) {
|
||||||
settings[d].enabled = true;
|
settings[d].enabled = true;
|
||||||
dep.isDependency = true;
|
dep.isDependency = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (p.commands?.length) {
|
||||||
|
Plugins.CommandsAPI.isDependency = true;
|
||||||
|
settings.CommandsAPI.enabled = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const p of pluginsValues) {
|
for (const p of pluginsValues) {
|
||||||
|
|
|
@ -82,7 +82,6 @@ export default definePlugin({
|
||||||
default: true
|
default: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
dependencies: ["CommandsAPI"],
|
|
||||||
|
|
||||||
async start() {
|
async start() {
|
||||||
for (const tag of await getTags()) createTagCommand(tag);
|
for (const tag of await getTags()) createTagCommand(tag);
|
||||||
|
|
|
@ -33,7 +33,6 @@ export default definePlugin({
|
||||||
name: "MoreCommands",
|
name: "MoreCommands",
|
||||||
description: "echo, lenny, mock",
|
description: "echo, lenny, mock",
|
||||||
authors: [Devs.Arjix, Devs.echo, Devs.Samu],
|
authors: [Devs.Arjix, Devs.echo, Devs.Samu],
|
||||||
dependencies: ["CommandsAPI"],
|
|
||||||
commands: [
|
commands: [
|
||||||
{
|
{
|
||||||
name: "echo",
|
name: "echo",
|
||||||
|
|
|
@ -24,7 +24,6 @@ export default definePlugin({
|
||||||
name: "MoreKaomoji",
|
name: "MoreKaomoji",
|
||||||
description: "Adds more Kaomoji to discord. ヽ(´▽`)/",
|
description: "Adds more Kaomoji to discord. ヽ(´▽`)/",
|
||||||
authors: [Devs.JacobTm],
|
authors: [Devs.JacobTm],
|
||||||
dependencies: ["CommandsAPI"],
|
|
||||||
commands: [
|
commands: [
|
||||||
{ name: "dissatisfaction", description: " >﹏<" },
|
{ name: "dissatisfaction", description: " >﹏<" },
|
||||||
{ name: "smug", description: "ಠ_ಠ" },
|
{ name: "smug", description: "ಠ_ಠ" },
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
# NoDefaultHangStatus
|
|
||||||
|
|
||||||
Disable the default hang status when joining voice channels
|
|
||||||
|
|
||||||
![Visualization](https://github.com/Vendicated/Vencord/assets/24937357/329a9742-236f-48f7-94ff-c3510eca505a)
|
|
|
@ -1,24 +0,0 @@
|
||||||
/*
|
|
||||||
* Vencord, a Discord client mod
|
|
||||||
* Copyright (c) 2024 Vendicated and contributors
|
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { Devs } from "@utils/constants";
|
|
||||||
import definePlugin from "@utils/types";
|
|
||||||
|
|
||||||
export default definePlugin({
|
|
||||||
name: "NoDefaultHangStatus",
|
|
||||||
description: "Disable the default hang status when joining voice channels",
|
|
||||||
authors: [Devs.D3SOX],
|
|
||||||
|
|
||||||
patches: [
|
|
||||||
{
|
|
||||||
find: ".CHILLING)",
|
|
||||||
replacement: {
|
|
||||||
match: /{enableHangStatus:(\i),/,
|
|
||||||
replace: "{_enableHangStatus:$1=false,"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
});
|
|
|
@ -33,7 +33,7 @@ interface URLReplacementRule {
|
||||||
// Do not forget to add protocols to the ALLOWED_PROTOCOLS constant
|
// Do not forget to add protocols to the ALLOWED_PROTOCOLS constant
|
||||||
const UrlReplacementRules: Record<string, URLReplacementRule> = {
|
const UrlReplacementRules: Record<string, URLReplacementRule> = {
|
||||||
spotify: {
|
spotify: {
|
||||||
match: /^https:\/\/open\.spotify\.com\/(?:intl-[a-z]{2}\/)?(track|album|artist|playlist|user|episode)\/(.+)(?:\?.+?)?$/,
|
match: /^https:\/\/open\.spotify\.com\/(?:intl-[a-z]{2}\/)?(track|album|artist|playlist|user|episode|prerelease)\/(.+)(?:\?.+?)?$/,
|
||||||
replace: (_, type, id) => `spotify://${type}/${id}`,
|
replace: (_, type, id) => `spotify://${type}/${id}`,
|
||||||
description: "Open Spotify links in the Spotify app",
|
description: "Open Spotify links in the Spotify app",
|
||||||
shortlinkMatch: /^https:\/\/spotify\.link\/.+$/,
|
shortlinkMatch: /^https:\/\/spotify\.link\/.+$/,
|
||||||
|
|
5
src/plugins/pdfViewer.desktop/README.md
Normal file
5
src/plugins/pdfViewer.desktop/README.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
# PdfViewer
|
||||||
|
|
||||||
|
Allows you to Preview PDF Files without having to download them
|
||||||
|
|
||||||
|
![](https://github.com/user-attachments/assets/f403dff5-5edc-4e57-8503-73f709df4842)
|
|
@ -4,15 +4,13 @@
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Logger } from "@utils/Logger";
|
|
||||||
|
|
||||||
export class LRUCache {
|
export class LRUCache {
|
||||||
private cache: Map<string, string>;
|
private cache: Map<string, string>;
|
||||||
private maxSize: number;
|
private maxSize: number;
|
||||||
|
|
||||||
constructor() {
|
constructor(maxSize: number) {
|
||||||
this.cache = new Map();
|
this.cache = new Map();
|
||||||
this.maxSize = 50;
|
this.maxSize = maxSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
get(key: string): string | undefined {
|
get(key: string): string | undefined {
|
||||||
|
@ -47,16 +45,4 @@ export class LRUCache {
|
||||||
}
|
}
|
||||||
this.cache.clear();
|
this.cache.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
setMaxSize(maxSize: number) {
|
|
||||||
if (maxSize < 1) {
|
|
||||||
new Logger("FileViewer").error("Cache size must be at least 1");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.maxSize = maxSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
getMaxSize() {
|
|
||||||
return this.maxSize;
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -4,22 +4,20 @@
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import "./fileViewer.css";
|
import "./pdfViewer.css";
|
||||||
|
|
||||||
import { get, set } from "@api/DataStore";
|
import { get, set } from "@api/DataStore";
|
||||||
import { addAccessory, removeAccessory } from "@api/MessageAccessories";
|
import { addAccessory, removeAccessory } from "@api/MessageAccessories";
|
||||||
import { updateMessage } from "@api/MessageUpdater";
|
import { updateMessage } from "@api/MessageUpdater";
|
||||||
import { definePluginSettings } from "@api/Settings";
|
import { definePluginSettings } from "@api/Settings";
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { PreviewInvisible, PreviewVisible } from "@components/Icons";
|
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import { Logger } from "@utils/Logger";
|
|
||||||
import definePlugin, { OptionType, PluginNative } from "@utils/types";
|
import definePlugin, { OptionType, PluginNative } from "@utils/types";
|
||||||
import { Tooltip, useEffect, useState } from "@webpack/common";
|
import { Icons, Spinner, Tooltip, useEffect, useState } from "@webpack/common";
|
||||||
|
|
||||||
import { LRUCache } from "./cache";
|
import { LRUCache } from "./cache";
|
||||||
|
|
||||||
const Native = VencordNative.pluginHelpers.FileViewer as PluginNative<typeof import("./native")>;
|
const Native = VencordNative.pluginHelpers.PdfViewer as PluginNative<typeof import("./native")>;
|
||||||
|
|
||||||
const settings = definePluginSettings({
|
const settings = definePluginSettings({
|
||||||
autoEmptyCache: {
|
autoEmptyCache: {
|
||||||
|
@ -32,20 +30,10 @@ const settings = definePluginSettings({
|
||||||
description: "Persist the state of opened/closed File Previews across channel switches and reloads.",
|
description: "Persist the state of opened/closed File Previews across channel switches and reloads.",
|
||||||
default: false
|
default: false
|
||||||
},
|
},
|
||||||
cacheSize: {
|
|
||||||
type: OptionType.SLIDER,
|
|
||||||
description: "Maximum number of PDF files to cache (after that, the least recently used file will be removed). Lower this value if you're running out of memory.",
|
|
||||||
default: 50,
|
|
||||||
restartNeeded: true,
|
|
||||||
markers: [10, 20, 30, 40, 50, 75, 100],
|
|
||||||
stickToMarkers: true,
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const objectUrlsCache = new LRUCache();
|
const objectUrlsCache = new LRUCache(20);
|
||||||
const STORE_KEY = "FileViewer_PersistVisible";
|
const STORE_KEY = "PdfViewer_PersistVisible";
|
||||||
|
|
||||||
let style: HTMLStyleElement;
|
|
||||||
|
|
||||||
interface Attachment {
|
interface Attachment {
|
||||||
id: string;
|
id: string;
|
||||||
|
@ -58,25 +46,19 @@ interface Attachment {
|
||||||
title: string;
|
title: string;
|
||||||
spoiler: boolean;
|
spoiler: boolean;
|
||||||
previewBlobUrl?: string;
|
previewBlobUrl?: string;
|
||||||
|
previewVisible?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const stripLink = (url: string) => url.replace("https://cdn.discordapp.com/attachments/", "").split("/").slice(0, 2).join("-");
|
|
||||||
function FilePreview({ attachment }: { attachment: Attachment; }) {
|
function FilePreview({ attachment }: { attachment: Attachment; }) {
|
||||||
const { previewBlobUrl } = attachment;
|
const { previewBlobUrl, previewVisible } = attachment;
|
||||||
|
|
||||||
if (!previewBlobUrl) return null;
|
if (!previewVisible) return null;
|
||||||
|
|
||||||
return <div className={"file-viewer container"} id={`file-viewer-${stripLink(attachment.url)}`}><embed src={previewBlobUrl} className="file-viewer preview" title={attachment.filename} /></div>;
|
return (
|
||||||
}
|
<div className={"vc-pdf-viewer-container"}>
|
||||||
|
{previewBlobUrl ? <embed src={previewBlobUrl} className="vc-pdf-viewer-preview" title={attachment.filename} /> : <div style={{ display: "flex" }}><Spinner /></div>}
|
||||||
async function buildCss() {
|
</div>
|
||||||
const visiblePreviews: Set<string> | undefined = await get(STORE_KEY);
|
);
|
||||||
const elements = [...(visiblePreviews || [])].map(url => `#file-viewer-${stripLink(url)}`).join(",");
|
|
||||||
style.textContent = `
|
|
||||||
:is(${elements}) {
|
|
||||||
display: flex !important;
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function PreviewButton({ attachment, channelId, messageId }: { attachment: Attachment; channelId: string; messageId: string; }) {
|
function PreviewButton({ attachment, channelId, messageId }: { attachment: Attachment; channelId: string; messageId: string; }) {
|
||||||
|
@ -92,6 +74,7 @@ function PreviewButton({ attachment, channelId, messageId }: { attachment: Attac
|
||||||
try {
|
try {
|
||||||
const buffer = await Native.getBufferResponse(attachment.url);
|
const buffer = await Native.getBufferResponse(attachment.url);
|
||||||
const file = new File([buffer], attachment.filename, { type: attachment.content_type });
|
const file = new File([buffer], attachment.filename, { type: attachment.content_type });
|
||||||
|
|
||||||
const blobUrl = URL.createObjectURL(file);
|
const blobUrl = URL.createObjectURL(file);
|
||||||
objectUrlsCache.set(attachment.url, blobUrl);
|
objectUrlsCache.set(attachment.url, blobUrl);
|
||||||
setUrl(blobUrl);
|
setUrl(blobUrl);
|
||||||
|
@ -100,24 +83,31 @@ function PreviewButton({ attachment, channelId, messageId }: { attachment: Attac
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const updateVisibility = async () => {
|
||||||
|
const data: Set<string> = await get(STORE_KEY) ?? new Set();
|
||||||
|
|
||||||
|
if (visible === null) {
|
||||||
|
setVisible(settings.store.persistPreviewState ? data.has(attachment.url) : false);
|
||||||
|
} else {
|
||||||
|
if (visible) data.add(attachment.url);
|
||||||
|
else data.delete(attachment.url);
|
||||||
|
|
||||||
|
await set(STORE_KEY, data);
|
||||||
|
|
||||||
|
attachment.previewVisible = visible;
|
||||||
|
updateMessage(channelId, messageId);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
get(STORE_KEY).then(async data => {
|
updateVisibility();
|
||||||
if (visible === null) {
|
|
||||||
setVisible(settings.store.persistPreviewState ? (data ?? new Set()).has(attachment.url) : false);
|
|
||||||
} else {
|
|
||||||
const persistSet = (data ?? new Set());
|
|
||||||
if (visible) persistSet.add(attachment.url);
|
|
||||||
else persistSet.delete(attachment.url);
|
|
||||||
await set(STORE_KEY, persistSet);
|
|
||||||
buildCss();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (visible && !url) initPdfData();
|
if (visible && !url) initPdfData();
|
||||||
}, [visible]);
|
}, [visible]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
attachment.previewBlobUrl = url;
|
attachment.previewBlobUrl = url;
|
||||||
updateMessage(channelId, messageId,);
|
updateMessage(channelId, messageId);
|
||||||
return () => {
|
return () => {
|
||||||
if (url && settings.store.autoEmptyCache) {
|
if (url && settings.store.autoEmptyCache) {
|
||||||
objectUrlsCache.delete(attachment.url);
|
objectUrlsCache.delete(attachment.url);
|
||||||
|
@ -129,20 +119,20 @@ function PreviewButton({ attachment, channelId, messageId }: { attachment: Attac
|
||||||
{tooltipProps => (
|
{tooltipProps => (
|
||||||
<div
|
<div
|
||||||
{...tooltipProps}
|
{...tooltipProps}
|
||||||
className="file-viewer toggle"
|
className="vc-pdf-viewer-toggle"
|
||||||
role="button"
|
role="button"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setVisible(v => !v);
|
setVisible(v => !v);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{visible ? <PreviewInvisible /> : <PreviewVisible />}
|
{visible ? <Icons.EyeSlashIcon /> : <Icons.EyeIcon />}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</Tooltip>;
|
</Tooltip>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "FileViewer",
|
name: "PdfViewer",
|
||||||
description: "Preview PDF Files without having to download them",
|
description: "Preview PDF Files without having to download them",
|
||||||
authors: [Devs.AGreenPig],
|
authors: [Devs.AGreenPig],
|
||||||
dependencies: ["MessageAccessoriesAPI", "MessageUpdaterAPI",],
|
dependencies: ["MessageAccessoriesAPI", "MessageUpdaterAPI",],
|
||||||
|
@ -157,9 +147,7 @@ export default definePlugin({
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
start() {
|
start() {
|
||||||
objectUrlsCache.setMaxSize(Math.round(settings.store.cacheSize));
|
addAccessory("pdfViewer", props => {
|
||||||
new Logger("FileViewer").info(`Initialized LRU Cache with size ${objectUrlsCache.getMaxSize()}`);
|
|
||||||
addAccessory("fileViewer", props => {
|
|
||||||
const pdfAttachments = props.message.attachments.filter(a => a.content_type === "application/pdf");
|
const pdfAttachments = props.message.attachments.filter(a => a.content_type === "application/pdf");
|
||||||
if (!pdfAttachments.length) return null;
|
if (!pdfAttachments.length) return null;
|
||||||
|
|
||||||
|
@ -171,18 +159,13 @@ export default definePlugin({
|
||||||
</ErrorBoundary>
|
</ErrorBoundary>
|
||||||
);
|
);
|
||||||
}, -1);
|
}, -1);
|
||||||
|
|
||||||
style = document.createElement("style");
|
|
||||||
style.id = "VencordFileViewer";
|
|
||||||
document.head.appendChild(style);
|
|
||||||
},
|
},
|
||||||
renderPreviewButton(e) {
|
renderPreviewButton: ErrorBoundary.wrap(e => {
|
||||||
if (e.item.originalItem.content_type !== "application/pdf") return null;
|
if (e.item.originalItem.content_type !== "application/pdf") return null;
|
||||||
return <PreviewButton attachment={e.item.originalItem} channelId={e.message.channel_id} messageId={e.message.id} />;
|
return <PreviewButton attachment={e.item.originalItem} channelId={e.message.channel_id} messageId={e.message.id} />;
|
||||||
},
|
}),
|
||||||
stop() {
|
stop() {
|
||||||
objectUrlsCache.clear();
|
objectUrlsCache.clear();
|
||||||
removeAccessory("fileViewer");
|
removeAccessory("pdfViewer");
|
||||||
style.remove();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
28
src/plugins/pdfViewer.desktop/native.ts
Normal file
28
src/plugins/pdfViewer.desktop/native.ts
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
/*
|
||||||
|
* Vencord, a Discord client mod
|
||||||
|
* Copyright (c) 2024 Vendicated and contributors
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { IpcMainInvokeEvent } from "electron";
|
||||||
|
|
||||||
|
const urlChecks = [
|
||||||
|
(url: URL) => url.host === "cdn.discordapp.com",
|
||||||
|
(url: URL) => url.pathname.startsWith("/attachments/"),
|
||||||
|
(url: URL) => url.pathname.endsWith(".pdf")
|
||||||
|
];
|
||||||
|
|
||||||
|
export async function getBufferResponse(_: IpcMainInvokeEvent, url: string): Promise<Buffer> {
|
||||||
|
const urlObj = new URL(url);
|
||||||
|
if (!urlChecks.every(check => check(urlObj))) {
|
||||||
|
throw new Error("Invalid URL");
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await fetch(url);
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error(`Failed to fetch: ${response.statusText}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const arrayBuffer = await response.arrayBuffer();
|
||||||
|
return Buffer.from(arrayBuffer);
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
.file-viewer.container {
|
.vc-pdf-viewer-container {
|
||||||
resize: both;
|
resize: both;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
|
@ -6,16 +6,17 @@
|
||||||
max-height: 80vh;
|
max-height: 80vh;
|
||||||
min-height: 500px;
|
min-height: 500px;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
display: none; /* Will be set with buildCss */
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.file-viewer.preview {
|
.vc-pdf-viewer-preview {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
border: none;
|
border: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.file-viewer.toggle {
|
.vc-pdf-viewer-toggle {
|
||||||
justify-self: center;
|
justify-self: center;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
@ -24,6 +25,6 @@
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
.file-viewer.toggle:hover {
|
.vc-pdf-viewer-toggle:hover {
|
||||||
color: var(--interactive-hover);
|
color: var(--interactive-hover);
|
||||||
}
|
}
|
|
@ -88,7 +88,6 @@ export default definePlugin({
|
||||||
name: "petpet",
|
name: "petpet",
|
||||||
description: "Adds a /petpet slash command to create headpet gifs from any image",
|
description: "Adds a /petpet slash command to create headpet gifs from any image",
|
||||||
authors: [Devs.Ven],
|
authors: [Devs.Ven],
|
||||||
dependencies: ["CommandsAPI"],
|
|
||||||
commands: [
|
commands: [
|
||||||
{
|
{
|
||||||
inputType: ApplicationCommandInputType.BUILT_IN,
|
inputType: ApplicationCommandInputType.BUILT_IN,
|
||||||
|
|
|
@ -91,7 +91,7 @@ export default definePlugin({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
find: ".PANEL,isInteractionSource:",
|
find: ".PANEL,interactionType:",
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /{profileType:\i\.\i\.PANEL,children:\[/,
|
match: /{profileType:\i\.\i\.PANEL,children:\[/,
|
||||||
replace: "$&$self.BiteSizeReviewsButton({user:arguments[0].user}),"
|
replace: "$&$self.BiteSizeReviewsButton({user:arguments[0].user}),"
|
||||||
|
|
|
@ -88,7 +88,7 @@ export default definePlugin({
|
||||||
name: "SilentTyping",
|
name: "SilentTyping",
|
||||||
authors: [Devs.Ven, Devs.Rini, Devs.ImBanana],
|
authors: [Devs.Ven, Devs.Rini, Devs.ImBanana],
|
||||||
description: "Hide that you are typing",
|
description: "Hide that you are typing",
|
||||||
dependencies: ["CommandsAPI", "ChatInputButtonAPI"],
|
dependencies: ["ChatInputButtonAPI"],
|
||||||
settings,
|
settings,
|
||||||
contextMenus: {
|
contextMenus: {
|
||||||
"textarea-context": ChatBarContextCheckbox
|
"textarea-context": ChatBarContextCheckbox
|
||||||
|
|
|
@ -76,7 +76,6 @@ export default definePlugin({
|
||||||
name: "SpotifyShareCommands",
|
name: "SpotifyShareCommands",
|
||||||
description: "Share your current Spotify track, album or artist via slash command (/track, /album, /artist)",
|
description: "Share your current Spotify track, album or artist via slash command (/track, /album, /artist)",
|
||||||
authors: [Devs.katlyn],
|
authors: [Devs.katlyn],
|
||||||
dependencies: ["CommandsAPI"],
|
|
||||||
commands: [
|
commands: [
|
||||||
{
|
{
|
||||||
name: "track",
|
name: "track",
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
# TimeBarAllActivities
|
|
||||||
|
|
||||||
Adds the Spotify time bar to all activities if they have start and end timestamps.
|
|
||||||
|
|
||||||
![](https://github.com/user-attachments/assets/9fbbe33c-8218-43c9-8b8d-f907a4e809fe)
|
|
|
@ -1,84 +0,0 @@
|
||||||
/*
|
|
||||||
* Vencord, a Discord client mod
|
|
||||||
* Copyright (c) 2024 Vendicated and contributors
|
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { definePluginSettings } from "@api/Settings";
|
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
|
||||||
import { Devs } from "@utils/constants";
|
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
|
||||||
import { findComponentByCodeLazy } from "@webpack";
|
|
||||||
import { RequiredDeep } from "type-fest";
|
|
||||||
|
|
||||||
interface Activity {
|
|
||||||
timestamps?: ActivityTimestamps;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ActivityTimestamps {
|
|
||||||
start?: string;
|
|
||||||
end?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface TimebarComponentProps {
|
|
||||||
activity: Activity;
|
|
||||||
}
|
|
||||||
|
|
||||||
const ActivityTimeBar = findComponentByCodeLazy<ActivityTimestamps>(".bar", ".progress", "(100*");
|
|
||||||
|
|
||||||
function isActivityTimestamped(activity: Activity): activity is RequiredDeep<Activity> {
|
|
||||||
return activity.timestamps != null && activity.timestamps.start != null && activity.timestamps.end != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const settings = definePluginSettings({
|
|
||||||
hideActivityDetailText: {
|
|
||||||
type: OptionType.BOOLEAN,
|
|
||||||
description: "Hide the large title text next to the activity",
|
|
||||||
default: true,
|
|
||||||
},
|
|
||||||
hideActivityTimerBadges: {
|
|
||||||
type: OptionType.BOOLEAN,
|
|
||||||
description: "Hide the timer badges next to the activity",
|
|
||||||
default: true,
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
export default definePlugin({
|
|
||||||
name: "TimeBarAllActivities",
|
|
||||||
description: "Adds the Spotify time bar to all activities if they have start and end timestamps",
|
|
||||||
authors: [Devs.fawn, Devs.niko],
|
|
||||||
settings,
|
|
||||||
patches: [
|
|
||||||
{
|
|
||||||
find: ".gameState,children:",
|
|
||||||
replacement: [
|
|
||||||
// Insert Spotify time bar component
|
|
||||||
{
|
|
||||||
match: /\(0,.{0,30}activity:(\i),className:\i\.badges\}\)/g,
|
|
||||||
replace: "$&,$self.TimebarComponent({activity:$1})"
|
|
||||||
},
|
|
||||||
// Hide the large title on listening activities, to make them look more like Spotify (also visible from hovering over the large icon)
|
|
||||||
{
|
|
||||||
match: /(\i).type===(\i\.\i)\.WATCHING/,
|
|
||||||
replace: "($self.settings.store.hideActivityDetailText&&$self.isActivityTimestamped($1)&&$1.type===$2.LISTENING)||$&"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
// Hide the "badge" timers that count the time since the activity starts
|
|
||||||
{
|
|
||||||
find: ".TvIcon).otherwise",
|
|
||||||
replacement: {
|
|
||||||
match: /null!==\(\i=null===\(\i=(\i)\.timestamps\).{0,50}created_at/,
|
|
||||||
replace: "($self.settings.store.hideActivityTimerBadges&&$self.isActivityTimestamped($1))?null:$&"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
|
|
||||||
isActivityTimestamped,
|
|
||||||
|
|
||||||
TimebarComponent: ErrorBoundary.wrap(({ activity }: TimebarComponentProps) => {
|
|
||||||
if (!isActivityTimestamped(activity)) return null;
|
|
||||||
|
|
||||||
return <ActivityTimeBar start={activity.timestamps.start} end={activity.timestamps.end} />;
|
|
||||||
}, { noop: true })
|
|
||||||
});
|
|
7
src/plugins/userVoiceShow/README.md
Normal file
7
src/plugins/userVoiceShow/README.md
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
# User Voice Show
|
||||||
|
|
||||||
|
Shows an indicator when a user is in a Voice Channel
|
||||||
|
|
||||||
|
![a preview of the indicator in the user profile](https://github.com/user-attachments/assets/48f825e4-fad5-40d7-bb4f-41d5e595aae0)
|
||||||
|
|
||||||
|
![a preview of the indicator in the member list](https://github.com/user-attachments/assets/51be081d-7bbb-45c5-8533-d565228e50c1)
|
170
src/plugins/userVoiceShow/components.tsx
Normal file
170
src/plugins/userVoiceShow/components.tsx
Normal file
|
@ -0,0 +1,170 @@
|
||||||
|
/*
|
||||||
|
* Vencord, a Discord client mod
|
||||||
|
* Copyright (c) 2024 Vendicated and contributors
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { classNameFactory } from "@api/Styles";
|
||||||
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
|
import { classes } from "@utils/misc";
|
||||||
|
import { findByPropsLazy, findComponentByCodeLazy, findStoreLazy } from "@webpack";
|
||||||
|
import { ChannelStore, GuildStore, IconUtils, NavigationRouter, PermissionsBits, PermissionStore, showToast, Text, Toasts, Tooltip, useCallback, useMemo, UserStore, useStateFromStores } from "@webpack/common";
|
||||||
|
import { Channel } from "discord-types/general";
|
||||||
|
|
||||||
|
const cl = classNameFactory("vc-uvs-");
|
||||||
|
|
||||||
|
const { selectVoiceChannel } = findByPropsLazy("selectChannel", "selectVoiceChannel");
|
||||||
|
const VoiceStateStore = findStoreLazy("VoiceStateStore");
|
||||||
|
const UserSummaryItem = findComponentByCodeLazy("defaultRenderUser", "showDefaultAvatarsForNullUsers");
|
||||||
|
|
||||||
|
interface IconProps extends React.HTMLAttributes<HTMLDivElement> {
|
||||||
|
size?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
function SpeakerIcon(props: IconProps) {
|
||||||
|
props.size ??= 16;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
{...props}
|
||||||
|
role={props.onClick != null ? "button" : undefined}
|
||||||
|
className={classes(cl("speaker"), props.onClick != null ? cl("clickable") : undefined)}
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
width={props.size}
|
||||||
|
height={props.size}
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
fill="currentColor"
|
||||||
|
>
|
||||||
|
<path d="M12 3a1 1 0 0 0-1-1h-.06a1 1 0 0 0-.74.32L5.92 7H3a1 1 0 0 0-1 1v8a1 1 0 0 0 1 1h2.92l4.28 4.68a1 1 0 0 0 .74.32H11a1 1 0 0 0 1-1V3ZM15.1 20.75c-.58.14-1.1-.33-1.1-.92v-.03c0-.5.37-.92.85-1.05a7 7 0 0 0 0-13.5A1.11 1.11 0 0 1 14 4.2v-.03c0-.6.52-1.06 1.1-.92a9 9 0 0 1 0 17.5Z" />
|
||||||
|
<path d="M15.16 16.51c-.57.28-1.16-.2-1.16-.83v-.14c0-.43.28-.8.63-1.02a3 3 0 0 0 0-5.04c-.35-.23-.63-.6-.63-1.02v-.14c0-.63.59-1.1 1.16-.83a5 5 0 0 1 0 9.02Z" />
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function LockedSpeakerIcon(props: IconProps) {
|
||||||
|
props.size ??= 16;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
{...props}
|
||||||
|
role={props.onClick != null ? "button" : undefined}
|
||||||
|
className={classes(cl("speaker"), props.onClick != null ? cl("clickable") : undefined)}
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
width={props.size}
|
||||||
|
height={props.size}
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
fill="currentColor"
|
||||||
|
>
|
||||||
|
<path fillRule="evenodd" clipRule="evenodd" d="M16 4h.5v-.5a2.5 2.5 0 0 1 5 0V4h.5a1 1 0 0 1 1 1v4a1 1 0 0 1-1 1h-6a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1Zm4-.5V4h-2v-.5a1 1 0 1 1 2 0Z" />
|
||||||
|
<path d="M11 2a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1h-.06a1 1 0 0 1-.74-.32L5.92 17H3a1 1 0 0 1-1-1V8a1 1 0 0 1 1-1h2.92l4.28-4.68a1 1 0 0 1 .74-.32H11ZM20.5 12c-.28 0-.5.22-.52.5a7 7 0 0 1-5.13 6.25c-.48.13-.85.55-.85 1.05v.03c0 .6.52 1.06 1.1.92a9 9 0 0 0 6.89-8.25.48.48 0 0 0-.49-.5h-1ZM16.5 12c-.28 0-.5.23-.54.5a3 3 0 0 1-1.33 2.02c-.35.23-.63.6-.63 1.02v.14c0 .63.59 1.1 1.16.83a5 5 0 0 0 2.82-4.01c.02-.28-.2-.5-.48-.5h-1Z" />
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
interface VoiceChannelTooltipProps {
|
||||||
|
channel: Channel;
|
||||||
|
}
|
||||||
|
|
||||||
|
function VoiceChannelTooltip({ channel }: VoiceChannelTooltipProps) {
|
||||||
|
const voiceStates = useStateFromStores([VoiceStateStore], () => VoiceStateStore.getVoiceStatesForChannel(channel.id));
|
||||||
|
const users = useMemo(
|
||||||
|
() => Object.values<any>(voiceStates).map(voiceState => UserStore.getUser(voiceState.userId)).filter(user => user != null),
|
||||||
|
[voiceStates]
|
||||||
|
);
|
||||||
|
|
||||||
|
const guild = useMemo(
|
||||||
|
() => channel.getGuildId() == null ? undefined : GuildStore.getGuild(channel.getGuildId()),
|
||||||
|
[channel]
|
||||||
|
);
|
||||||
|
|
||||||
|
const guildIcon = useMemo(() => {
|
||||||
|
return guild?.icon == null ? undefined : IconUtils.getGuildIconURL({
|
||||||
|
id: guild.id,
|
||||||
|
icon: guild.icon,
|
||||||
|
size: 30
|
||||||
|
});
|
||||||
|
}, [guild]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{guild != null && (
|
||||||
|
<div className={cl("guild-name")}>
|
||||||
|
{guildIcon != null && <img className={cl("guild-icon")} src={guildIcon} alt="" />}
|
||||||
|
<Text variant="text-sm/bold">{guild.name}</Text>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
<Text variant="text-sm/semibold">{channel.name}</Text>
|
||||||
|
<div className={cl("vc-members")}>
|
||||||
|
<SpeakerIcon size={18} />
|
||||||
|
<UserSummaryItem
|
||||||
|
users={users}
|
||||||
|
renderIcon={false}
|
||||||
|
max={7}
|
||||||
|
size={18}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
interface VoiceChannelIndicatorProps {
|
||||||
|
userId: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const clickTimers = {} as Record<string, any>;
|
||||||
|
|
||||||
|
export const VoiceChannelIndicator = ErrorBoundary.wrap(({ userId }: VoiceChannelIndicatorProps) => {
|
||||||
|
const channelId = useStateFromStores([VoiceStateStore], () => VoiceStateStore.getVoiceStateForUser(userId)?.channelId as string | undefined);
|
||||||
|
const channel = useMemo(() => channelId == null ? undefined : ChannelStore.getChannel(channelId), [channelId]);
|
||||||
|
|
||||||
|
const onClick = useCallback((e: React.MouseEvent) => {
|
||||||
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
|
if (channel == null || channelId == null) return;
|
||||||
|
|
||||||
|
if (!PermissionStore.can(PermissionsBits.VIEW_CHANNEL, channel)) {
|
||||||
|
showToast("You cannot view the user's Voice Channel", Toasts.Type.FAILURE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
clearTimeout(clickTimers[channelId]);
|
||||||
|
delete clickTimers[channelId];
|
||||||
|
|
||||||
|
if (e.detail > 1) {
|
||||||
|
if (!PermissionStore.can(PermissionsBits.CONNECT, channel)) {
|
||||||
|
showToast("You cannot join the user's Voice Channel", Toasts.Type.FAILURE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
selectVoiceChannel(channelId);
|
||||||
|
} else {
|
||||||
|
clickTimers[channelId] = setTimeout(() => {
|
||||||
|
NavigationRouter.transitionTo(`/channels/${channel.getGuildId() ?? "@me"}/${channelId}`);
|
||||||
|
delete clickTimers[channelId];
|
||||||
|
}, 250);
|
||||||
|
}
|
||||||
|
}, [channelId]);
|
||||||
|
|
||||||
|
const isLocked = useMemo(() => {
|
||||||
|
return !PermissionStore.can(PermissionsBits.VIEW_CHANNEL, channel) || !PermissionStore.can(PermissionsBits.CONNECT, channel);
|
||||||
|
}, [channelId]);
|
||||||
|
|
||||||
|
if (channel == null) return null;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Tooltip
|
||||||
|
text={<VoiceChannelTooltip channel={channel} />}
|
||||||
|
tooltipClassName={cl("tooltip-container")}
|
||||||
|
>
|
||||||
|
{props =>
|
||||||
|
isLocked ?
|
||||||
|
<LockedSpeakerIcon {...props} onClick={onClick} />
|
||||||
|
: <SpeakerIcon {...props} onClick={onClick} />
|
||||||
|
}
|
||||||
|
</Tooltip>
|
||||||
|
);
|
||||||
|
}, { noop: true });
|
|
@ -1,27 +0,0 @@
|
||||||
.vc-uvs-button>div {
|
|
||||||
white-space: normal !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.vc-uvs-button {
|
|
||||||
width: 100%;
|
|
||||||
margin: auto;
|
|
||||||
height: unset;
|
|
||||||
}
|
|
||||||
|
|
||||||
.vc-uvs-header {
|
|
||||||
color: var(--header-primary);
|
|
||||||
margin-bottom: 6px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.vc-uvs-modal-margin {
|
|
||||||
margin: 0 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.vc-uvs-modal-margin div {
|
|
||||||
margin-bottom: 0 !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.vc-uvs-popout-margin-self>[class^="section"] {
|
|
||||||
padding-top: 0;
|
|
||||||
padding-bottom: 12px;
|
|
||||||
}
|
|
|
@ -1,61 +0,0 @@
|
||||||
/*
|
|
||||||
* Vencord, a modification for Discord's desktop app
|
|
||||||
* Copyright (c) 2023 Vendicated and contributors
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import "./VoiceChannelSection.css";
|
|
||||||
|
|
||||||
import { findByPropsLazy } from "@webpack";
|
|
||||||
import { Button, Forms, PermissionStore, Toasts } from "@webpack/common";
|
|
||||||
import { Channel } from "discord-types/general";
|
|
||||||
|
|
||||||
const ChannelActions = findByPropsLazy("selectChannel", "selectVoiceChannel");
|
|
||||||
|
|
||||||
const CONNECT = 1n << 20n;
|
|
||||||
|
|
||||||
interface VoiceChannelFieldProps {
|
|
||||||
channel: Channel;
|
|
||||||
label: string;
|
|
||||||
showHeader: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const VoiceChannelSection = ({ channel, label, showHeader }: VoiceChannelFieldProps) => (
|
|
||||||
// @TODO The div is supposed to be a UserPopoutSection
|
|
||||||
<div>
|
|
||||||
{showHeader && <Forms.FormTitle className="vc-uvs-header">In a voice channel</Forms.FormTitle>}
|
|
||||||
<Button
|
|
||||||
className="vc-uvs-button"
|
|
||||||
color={Button.Colors.TRANSPARENT}
|
|
||||||
size={Button.Sizes.SMALL}
|
|
||||||
|
|
||||||
onClick={() => {
|
|
||||||
if (PermissionStore.can(CONNECT, channel))
|
|
||||||
ChannelActions.selectVoiceChannel(channel.id);
|
|
||||||
else
|
|
||||||
Toasts.show({
|
|
||||||
message: "Insufficient permissions to enter the channel.",
|
|
||||||
id: "user-voice-show-insufficient-permissions",
|
|
||||||
type: Toasts.Type.FAILURE,
|
|
||||||
options: {
|
|
||||||
position: Toasts.Position.BOTTOM,
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{label}
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
);
|
|
|
@ -16,85 +16,85 @@
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import "./style.css";
|
||||||
|
|
||||||
|
import { addDecorator, removeDecorator } from "@api/MemberListDecorators";
|
||||||
import { definePluginSettings } from "@api/Settings";
|
import { definePluginSettings } from "@api/Settings";
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { findStoreLazy } from "@webpack";
|
|
||||||
import { ChannelStore, GuildStore, UserStore } from "@webpack/common";
|
|
||||||
import { User } from "discord-types/general";
|
|
||||||
|
|
||||||
import { VoiceChannelSection } from "./components/VoiceChannelSection";
|
import { VoiceChannelIndicator } from "./components";
|
||||||
|
|
||||||
const VoiceStateStore = findStoreLazy("VoiceStateStore");
|
|
||||||
|
|
||||||
const settings = definePluginSettings({
|
const settings = definePluginSettings({
|
||||||
showInUserProfileModal: {
|
showInUserProfileModal: {
|
||||||
type: OptionType.BOOLEAN,
|
type: OptionType.BOOLEAN,
|
||||||
description: "Show a user's voice channel in their profile modal",
|
description: "Show a user's Voice Channel indicator in their profile next to the name",
|
||||||
default: true,
|
default: true,
|
||||||
|
restartNeeded: true
|
||||||
},
|
},
|
||||||
showVoiceChannelSectionHeader: {
|
showInVoiceMemberList: {
|
||||||
type: OptionType.BOOLEAN,
|
type: OptionType.BOOLEAN,
|
||||||
description: 'Whether to show "IN A VOICE CHANNEL" above the join button',
|
description: "Show a user's Voice Channel indicator in the member and DMs list",
|
||||||
default: true,
|
default: true,
|
||||||
|
restartNeeded: true
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
interface UserProps {
|
|
||||||
user: User;
|
|
||||||
}
|
|
||||||
|
|
||||||
const VoiceChannelField = ErrorBoundary.wrap(({ user }: UserProps) => {
|
|
||||||
const { channelId } = VoiceStateStore.getVoiceStateForUser(user.id) ?? {};
|
|
||||||
if (!channelId) return null;
|
|
||||||
|
|
||||||
const channel = ChannelStore.getChannel(channelId);
|
|
||||||
if (!channel) return null;
|
|
||||||
|
|
||||||
const guild = GuildStore.getGuild(channel.guild_id);
|
|
||||||
|
|
||||||
if (!guild) return null; // When in DM call
|
|
||||||
|
|
||||||
const result = `${guild.name} | ${channel.name}`;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<VoiceChannelSection
|
|
||||||
channel={channel}
|
|
||||||
label={result}
|
|
||||||
showHeader={settings.store.showVoiceChannelSectionHeader}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "UserVoiceShow",
|
name: "UserVoiceShow",
|
||||||
description: "Shows whether a User is currently in a voice channel somewhere in their profile",
|
description: "Shows an indicator when a user is in a Voice Channel",
|
||||||
authors: [Devs.LordElias],
|
authors: [Devs.LordElias, Devs.Nuckyz],
|
||||||
settings,
|
settings,
|
||||||
|
|
||||||
patchModal({ user }: UserProps) {
|
|
||||||
if (!settings.store.showInUserProfileModal)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="vc-uvs-modal-margin">
|
|
||||||
<VoiceChannelField user={user} />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
},
|
|
||||||
|
|
||||||
patchProfilePopout: ({ user }: UserProps) => {
|
|
||||||
const isSelfUser = user.id === UserStore.getCurrentUser().id;
|
|
||||||
return (
|
|
||||||
<div className={isSelfUser ? "vc-uvs-popout-margin-self" : ""}>
|
|
||||||
<VoiceChannelField user={user} />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
},
|
|
||||||
|
|
||||||
patches: [
|
patches: [
|
||||||
// @TODO Maybe patch UserVoiceShow in simplified profile popout
|
// User Popout, Full Size Profile, Direct Messages Side Profile
|
||||||
// @TODO Patch new profile modal
|
{
|
||||||
|
find: ".Messages.USER_PROFILE_LOAD_ERROR",
|
||||||
|
replacement: {
|
||||||
|
match: /(\.fetchError.+?\?)null/,
|
||||||
|
replace: (_, rest) => `${rest}$self.VoiceChannelIndicator({userId:arguments[0]?.userId})`
|
||||||
|
},
|
||||||
|
predicate: () => settings.store.showInUserProfileModal
|
||||||
|
},
|
||||||
|
// To use without the MemberList decorator API
|
||||||
|
/* // Guild Members List
|
||||||
|
{
|
||||||
|
find: ".lostPermission)",
|
||||||
|
replacement: {
|
||||||
|
match: /\.lostPermission\).+?(?=avatar:)/,
|
||||||
|
replace: "$&children:[$self.VoiceChannelIndicator({userId:arguments[0]?.user?.id})],"
|
||||||
|
},
|
||||||
|
predicate: () => settings.store.showVoiceChannelIndicator
|
||||||
|
},
|
||||||
|
// Direct Messages List
|
||||||
|
{
|
||||||
|
find: "PrivateChannel.renderAvatar",
|
||||||
|
replacement: {
|
||||||
|
match: /\.Messages\.CLOSE_DM.+?}\)(?=])/,
|
||||||
|
replace: "$&,$self.VoiceChannelIndicator({userId:arguments[0]?.user?.id})"
|
||||||
|
},
|
||||||
|
predicate: () => settings.store.showVoiceChannelIndicator
|
||||||
|
}, */
|
||||||
|
// Friends List
|
||||||
|
{
|
||||||
|
find: ".avatar,animate:",
|
||||||
|
replacement: {
|
||||||
|
match: /\.subtext,children:.+?}\)\]}\)(?=])/,
|
||||||
|
replace: "$&,$self.VoiceChannelIndicator({userId:arguments[0]?.user?.id})"
|
||||||
|
},
|
||||||
|
predicate: () => settings.store.showInVoiceMemberList
|
||||||
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
|
start() {
|
||||||
|
if (settings.store.showInVoiceMemberList) {
|
||||||
|
addDecorator("UserVoiceShow", ({ user }) => user == null ? null : <VoiceChannelIndicator userId={user.id} />);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
stop() {
|
||||||
|
removeDecorator("UserVoiceShow");
|
||||||
|
},
|
||||||
|
|
||||||
|
VoiceChannelIndicator
|
||||||
});
|
});
|
||||||
|
|
37
src/plugins/userVoiceShow/style.css
Normal file
37
src/plugins/userVoiceShow/style.css
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
.vc-uvs-speaker {
|
||||||
|
color: var(--interactive-normal);
|
||||||
|
padding: 0 4px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vc-uvs-clickable {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vc-uvs-clickable:hover {
|
||||||
|
color: var(--interactive-hover);
|
||||||
|
}
|
||||||
|
|
||||||
|
.vc-uvs-tooltip-container {
|
||||||
|
max-width: 200px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vc-uvs-guild-name {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vc-uvs-guild-icon {
|
||||||
|
border-radius: 100%;
|
||||||
|
align-self: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vc-uvs-vc-members {
|
||||||
|
display: flex;
|
||||||
|
margin: 8px 0;
|
||||||
|
flex-direction: row;
|
||||||
|
gap: 6px;
|
||||||
|
}
|
|
@ -268,7 +268,7 @@ export const Devs = /* #__PURE__*/ Object.freeze({
|
||||||
id: 841509053422632990n
|
id: 841509053422632990n
|
||||||
},
|
},
|
||||||
F53: {
|
F53: {
|
||||||
name: "F53",
|
name: "Cassie (Code)",
|
||||||
id: 280411966126948353n
|
id: 280411966126948353n
|
||||||
},
|
},
|
||||||
AutumnVN: {
|
AutumnVN: {
|
||||||
|
|
|
@ -72,13 +72,13 @@ export interface PluginDef {
|
||||||
stop?(): void;
|
stop?(): void;
|
||||||
patches?: Omit<Patch, "plugin">[];
|
patches?: Omit<Patch, "plugin">[];
|
||||||
/**
|
/**
|
||||||
* List of commands. If you specify these, you must add CommandsAPI to dependencies
|
* List of commands that your plugin wants to register
|
||||||
*/
|
*/
|
||||||
commands?: Command[];
|
commands?: Command[];
|
||||||
/**
|
/**
|
||||||
* A list of other plugins that your plugin depends on.
|
* A list of other plugins that your plugin depends on.
|
||||||
* These will automatically be enabled and loaded before your plugin
|
* These will automatically be enabled and loaded before your plugin
|
||||||
* Common examples are CommandsAPI, MessageEventsAPI...
|
* Generally these will be API plugins
|
||||||
*/
|
*/
|
||||||
dependencies?: string[],
|
dependencies?: string[],
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -28,6 +28,8 @@ export let Forms = {} as {
|
||||||
FormText: t.FormText,
|
FormText: t.FormText,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export let Icons = {} as t.Icons;
|
||||||
|
|
||||||
export let Card: t.Card;
|
export let Card: t.Card;
|
||||||
export let Button: t.Button;
|
export let Button: t.Button;
|
||||||
export let Switch: t.Switch;
|
export let Switch: t.Switch;
|
||||||
|
@ -49,6 +51,8 @@ export let ScrollerThin: t.ScrollerThin;
|
||||||
export let Clickable: t.Clickable;
|
export let Clickable: t.Clickable;
|
||||||
export let Avatar: t.Avatar;
|
export let Avatar: t.Avatar;
|
||||||
export let FocusLock: t.FocusLock;
|
export let FocusLock: t.FocusLock;
|
||||||
|
export let Spinner: t.Spinner;
|
||||||
|
export let SpinnerType: t.SpinnerType;
|
||||||
// token lagger real
|
// token lagger real
|
||||||
/** css colour resolver stuff, no clue what exactly this does, just copied usage from Discord */
|
/** css colour resolver stuff, no clue what exactly this does, just copied usage from Discord */
|
||||||
export let useToken: t.useToken;
|
export let useToken: t.useToken;
|
||||||
|
@ -82,7 +86,10 @@ waitFor(["FormItem", "Button"], m => {
|
||||||
Clickable,
|
Clickable,
|
||||||
Avatar,
|
Avatar,
|
||||||
FocusLock,
|
FocusLock,
|
||||||
Heading
|
Heading,
|
||||||
|
Spinner,
|
||||||
|
SpinnerType,
|
||||||
} = m);
|
} = m);
|
||||||
Forms = m;
|
Forms = m;
|
||||||
|
Icons = m;
|
||||||
});
|
});
|
||||||
|
|
31
src/webpack/common/types/components.d.ts
vendored
31
src/webpack/common/types/components.d.ts
vendored
|
@ -18,6 +18,8 @@
|
||||||
|
|
||||||
import type { ComponentType, CSSProperties, FunctionComponent, HtmlHTMLAttributes, HTMLProps, KeyboardEvent, MouseEvent, PropsWithChildren, PropsWithRef, ReactNode, Ref } from "react";
|
import type { ComponentType, CSSProperties, FunctionComponent, HtmlHTMLAttributes, HTMLProps, KeyboardEvent, MouseEvent, PropsWithChildren, PropsWithRef, ReactNode, Ref } from "react";
|
||||||
|
|
||||||
|
import { IconNames } from "./iconNames";
|
||||||
|
|
||||||
export type TextVariant = "heading-sm/normal" | "heading-sm/medium" | "heading-sm/semibold" | "heading-sm/bold" | "heading-md/normal" | "heading-md/medium" | "heading-md/semibold" | "heading-md/bold" | "heading-lg/normal" | "heading-lg/medium" | "heading-lg/semibold" | "heading-lg/bold" | "heading-xl/normal" | "heading-xl/medium" | "heading-xl/bold" | "heading-xxl/normal" | "heading-xxl/medium" | "heading-xxl/bold" | "eyebrow" | "heading-deprecated-14/normal" | "heading-deprecated-14/medium" | "heading-deprecated-14/bold" | "text-xxs/normal" | "text-xxs/medium" | "text-xxs/semibold" | "text-xxs/bold" | "text-xs/normal" | "text-xs/medium" | "text-xs/semibold" | "text-xs/bold" | "text-sm/normal" | "text-sm/medium" | "text-sm/semibold" | "text-sm/bold" | "text-md/normal" | "text-md/medium" | "text-md/semibold" | "text-md/bold" | "text-lg/normal" | "text-lg/medium" | "text-lg/semibold" | "text-lg/bold" | "display-sm" | "display-md" | "display-lg" | "code";
|
export type TextVariant = "heading-sm/normal" | "heading-sm/medium" | "heading-sm/semibold" | "heading-sm/bold" | "heading-md/normal" | "heading-md/medium" | "heading-md/semibold" | "heading-md/bold" | "heading-lg/normal" | "heading-lg/medium" | "heading-lg/semibold" | "heading-lg/bold" | "heading-xl/normal" | "heading-xl/medium" | "heading-xl/bold" | "heading-xxl/normal" | "heading-xxl/medium" | "heading-xxl/bold" | "eyebrow" | "heading-deprecated-14/normal" | "heading-deprecated-14/medium" | "heading-deprecated-14/bold" | "text-xxs/normal" | "text-xxs/medium" | "text-xxs/semibold" | "text-xxs/bold" | "text-xs/normal" | "text-xs/medium" | "text-xs/semibold" | "text-xs/bold" | "text-sm/normal" | "text-sm/medium" | "text-sm/semibold" | "text-sm/bold" | "text-md/normal" | "text-md/medium" | "text-md/semibold" | "text-md/bold" | "text-lg/normal" | "text-lg/medium" | "text-lg/semibold" | "text-lg/bold" | "display-sm" | "display-md" | "display-lg" | "code";
|
||||||
export type FormTextTypes = Record<"DEFAULT" | "INPUT_PLACEHOLDER" | "DESCRIPTION" | "LABEL_BOLD" | "LABEL_SELECTED" | "LABEL_DESCRIPTOR" | "ERROR" | "SUCCESS", string>;
|
export type FormTextTypes = Record<"DEFAULT" | "INPUT_PLACEHOLDER" | "DESCRIPTION" | "LABEL_BOLD" | "LABEL_SELECTED" | "LABEL_DESCRIPTOR" | "ERROR" | "SUCCESS", string>;
|
||||||
export type HeadingTag = `h${1 | 2 | 3 | 4 | 5 | 6}`;
|
export type HeadingTag = `h${1 | 2 | 3 | 4 | 5 | 6}`;
|
||||||
|
@ -69,7 +71,7 @@ export type FormText = ComponentType<PropsWithChildren<{
|
||||||
}> & TextProps> & { Types: FormTextTypes; };
|
}> & TextProps> & { Types: FormTextTypes; };
|
||||||
|
|
||||||
export type Tooltip = ComponentType<{
|
export type Tooltip = ComponentType<{
|
||||||
text: ReactNode;
|
text: ReactNode | ComponentType;
|
||||||
children: FunctionComponent<{
|
children: FunctionComponent<{
|
||||||
onClick(): void;
|
onClick(): void;
|
||||||
onMouseEnter(): void;
|
onMouseEnter(): void;
|
||||||
|
@ -502,3 +504,30 @@ export type Avatar = ComponentType<PropsWithChildren<{
|
||||||
type FocusLock = ComponentType<PropsWithChildren<{
|
type FocusLock = ComponentType<PropsWithChildren<{
|
||||||
containerRef: RefObject<HTMLElement>;
|
containerRef: RefObject<HTMLElement>;
|
||||||
}>>;
|
}>>;
|
||||||
|
|
||||||
|
export declare enum SpinnerType {
|
||||||
|
WANDERING_CUBES = "wanderingCubes",
|
||||||
|
CHASING_DOTS = "chasingDots",
|
||||||
|
PULSING_ELLIPSIS = "pulsingEllipsis",
|
||||||
|
SPINNING_CIRCLE = "spinningCircle",
|
||||||
|
SPINNING_CIRCLE_SIMPLE = "spinningCircleSimple",
|
||||||
|
LOW_MOTION = "lowMotion",
|
||||||
|
}
|
||||||
|
|
||||||
|
export type Spinner = ComponentType<{
|
||||||
|
type?: SpinnerType;
|
||||||
|
animated?: boolean;
|
||||||
|
className?: string;
|
||||||
|
itemClassName?: string;
|
||||||
|
"aria-label"?: string;
|
||||||
|
}> & {
|
||||||
|
Type: typeof SpinnerType;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type Icon = ComponentType<JSX.IntrinsicElements["svg"] & {
|
||||||
|
size?: string;
|
||||||
|
colorClass?: string;
|
||||||
|
} & Record<string, any>>;
|
||||||
|
|
||||||
|
export type Icons = Record<IconNames, Icon>;
|
||||||
|
|
||||||
|
|
14
src/webpack/common/types/iconNames.d.ts
vendored
Normal file
14
src/webpack/common/types/iconNames.d.ts
vendored
Normal file
File diff suppressed because one or more lines are too long
5
src/webpack/common/types/menu.d.ts
vendored
5
src/webpack/common/types/menu.d.ts
vendored
|
@ -72,6 +72,11 @@ export interface Menu {
|
||||||
onChange(value: number): void,
|
onChange(value: number): void,
|
||||||
renderValue?(value: number): string,
|
renderValue?(value: number): string,
|
||||||
}>;
|
}>;
|
||||||
|
MenuSearchControl: RC<{
|
||||||
|
query: string
|
||||||
|
onChange(query: string): void;
|
||||||
|
placeholder?: string;
|
||||||
|
}>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ContextMenuApi {
|
export interface ContextMenuApi {
|
||||||
|
|
Loading…
Reference in a new issue