From 16b33ba8fa613a2777b912095d6965e48faaf6f8 Mon Sep 17 00:00:00 2001 From: thororen <78185467+thororen1234@users.noreply.github.com> Date: Tue, 16 Jul 2024 00:15:41 -0400 Subject: [PATCH] Vesktop Stuff --- scripts/build/build.mjs | 18 ++++++++++++------ scripts/build/buildWeb.mjs | 1 + scripts/build/common.mjs | 5 +++-- scripts/generatePluginList.ts | 4 ++-- src/components/PluginSettings/index.tsx | 3 ++- src/globals.d.ts | 1 + src/main/utils/constants.ts | 11 +++++++++-- src/modules.d.ts | 2 +- src/plugins/webContextMenus.web/index.ts | 13 ++++++------- src/preload.ts | 2 +- src/utils/settingsSync.ts | 2 +- src/utils/themes/usercss/compiler.ts | 2 +- 12 files changed, 40 insertions(+), 24 deletions(-) diff --git a/scripts/build/build.mjs b/scripts/build/build.mjs index 146d7dbb..0660f155 100755 --- a/scripts/build/build.mjs +++ b/scripts/build/build.mjs @@ -113,7 +113,8 @@ await Promise.all([ define: { ...defines, IS_DISCORD_DESKTOP: true, - IS_VESKTOP: false + IS_VESKTOP: false, + IS_EQUIBOP: false }, plugins: [ ...nodeCommonOpts.plugins, @@ -136,7 +137,8 @@ await Promise.all([ define: { ...defines, IS_DISCORD_DESKTOP: true, - IS_VESKTOP: false + IS_VESKTOP: false, + IS_EQUIBOP: false } }), esbuild.build({ @@ -148,7 +150,8 @@ await Promise.all([ define: { ...defines, IS_DISCORD_DESKTOP: true, - IS_VESKTOP: false + IS_VESKTOP: false, + IS_EQUIBOP: false } }), @@ -162,7 +165,8 @@ await Promise.all([ define: { ...defines, IS_DISCORD_DESKTOP: false, - IS_VESKTOP: true + IS_VESKTOP: true, + IS_EQUIBOP: true }, plugins: [ ...nodeCommonOpts.plugins, @@ -185,7 +189,8 @@ await Promise.all([ define: { ...defines, IS_DISCORD_DESKTOP: false, - IS_VESKTOP: true + IS_VESKTOP: true, + IS_EQUIBOP: true } }), esbuild.build({ @@ -197,7 +202,8 @@ await Promise.all([ define: { ...defines, IS_DISCORD_DESKTOP: false, - IS_VESKTOP: true + IS_VESKTOP: true, + IS_EQUIBOP: true } }), ]).catch(err => { diff --git a/scripts/build/buildWeb.mjs b/scripts/build/buildWeb.mjs index bc15ccce..a7f17af6 100644 --- a/scripts/build/buildWeb.mjs +++ b/scripts/build/buildWeb.mjs @@ -47,6 +47,7 @@ const commonOptions = { IS_REPORTER, IS_DISCORD_DESKTOP: false, IS_VESKTOP: false, + IS_EQUIBOP: false, IS_UPDATER_DISABLED: true, VERSION: JSON.stringify(VERSION), BUILD_TIMESTAMP diff --git a/scripts/build/common.mjs b/scripts/build/common.mjs index 7c4cd6e3..f0f1dc20 100644 --- a/scripts/build/common.mjs +++ b/scripts/build/common.mjs @@ -98,7 +98,7 @@ export const makeAllPackagesExternalPlugin = { }; /** - * @type {(kind: "web" | "discordDesktop" | "vencordDesktop") => import("esbuild").Plugin} + * @type {(kind: "web" | "discordDesktop" | "vencordDesktop" | "equicordDesktop") => import("esbuild").Plugin} */ export const globPlugins = kind => ({ name: "glob-plugins", @@ -137,7 +137,8 @@ export const globPlugins = kind => ({ (target === "web" && kind === "discordDesktop") || (target === "desktop" && kind === "web") || (target === "discordDesktop" && kind !== "discordDesktop") || - (target === "vencordDesktop" && kind !== "vencordDesktop"); + (target === "vencordDesktop" && kind !== "vencordDesktop") || + (target === "equicordDesktop" && kind !== "equicordDesktop"); if (excluded) { const name = await resolvePluginName(fullDir, file); diff --git a/scripts/generatePluginList.ts b/scripts/generatePluginList.ts index 8c4fb91b..2eeef917 100644 --- a/scripts/generatePluginList.ts +++ b/scripts/generatePluginList.ts @@ -39,7 +39,7 @@ interface PluginData { hasCommands: boolean; required: boolean; enabledByDefault: boolean; - target: "discordDesktop" | "vencordDesktop" | "desktop" | "web" | "dev"; + target: "discordDesktop" | "vencordDesktop" | "equicordDesktop" | "desktop" | "web" | "dev"; filePath: string; } @@ -195,7 +195,7 @@ async function parseFile(fileName: string) { const target = getPluginTarget(fileName); if (target) { - if (!["web", "discordDesktop", "vencordDesktop", "desktop", "dev"].includes(target)) throw fail(`invalid target ${target}`); + if (!["web", "discordDesktop", "vencordDesktop", "equicordDesktop", "desktop", "dev"].includes(target)) throw fail(`invalid target ${target}`); data.target = target as any; } diff --git a/src/components/PluginSettings/index.tsx b/src/components/PluginSettings/index.tsx index 071c9a88..ba7dc696 100644 --- a/src/components/PluginSettings/index.tsx +++ b/src/components/PluginSettings/index.tsx @@ -176,10 +176,11 @@ function ExcludedPluginsList({ search }: { search: string; }) { const matchingExcludedPlugins = Object.entries(ExcludedPlugins) .filter(([name]) => name.toLowerCase().includes(search)); - const ExcludedReasons: Record<"web" | "discordDesktop" | "vencordDesktop" | "desktop" | "dev", string> = { + const ExcludedReasons: Record<"web" | "discordDesktop" | "vencordDesktop" | "equicordDesktop" | "desktop" | "dev", string> = { desktop: "Discord Desktop app or Vesktop", discordDesktop: "Discord Desktop app", vencordDesktop: "Vesktop app", + equicordDesktop: "Equibop app", web: "Vesktop app and the Web version of Discord", dev: "Developer version of Equicord" }; diff --git a/src/globals.d.ts b/src/globals.d.ts index e20ca4b7..f18d3abe 100644 --- a/src/globals.d.ts +++ b/src/globals.d.ts @@ -40,6 +40,7 @@ declare global { export var IS_REPORTER: boolean; export var IS_DISCORD_DESKTOP: boolean; export var IS_VESKTOP: boolean; + export var IS_EQUIBOP: boolean; export var VERSION: string; export var BUILD_TIMESTAMP: number; diff --git a/src/main/utils/constants.ts b/src/main/utils/constants.ts index fa1e3525..bebd6d8e 100644 --- a/src/main/utils/constants.ts +++ b/src/main/utils/constants.ts @@ -24,8 +24,15 @@ export const DATA_DIR = process.env.EQUICORD_USER_DATA_DIR ?? ( ? join(process.env.DISCORD_USER_DATA_DIR, "..", "EquicordData") : join(app.getPath("userData"), "..", "Equicord") ); -export const SETTINGS_DIR = join(DATA_DIR, "settings"); -export const THEMES_DIR = join(DATA_DIR, "themes"); + +export const DATA_DIR2 = process.env.VENCORD_USER_DATA_DIR ?? ( + process.env.DISCORD_USER_DATA_DIR + ? join(process.env.DISCORD_USER_DATA_DIR, "..", "VencordData") + : join(app.getPath("userData"), "..", "Vencord") +); + +export const SETTINGS_DIR = IS_VESKTOP ? join(DATA_DIR2, "settings") : join(DATA_DIR, "settings"); +export const THEMES_DIR = IS_VESKTOP ? join(DATA_DIR2, "themes") : join(DATA_DIR, "themes"); export const QUICKCSS_PATH = join(SETTINGS_DIR, "quickCss.css"); export const SETTINGS_FILE = join(SETTINGS_DIR, "settings.json"); export const NATIVE_SETTINGS_FILE = join(SETTINGS_DIR, "native-settings.json"); diff --git a/src/modules.d.ts b/src/modules.d.ts index 7566a5bf..d5bf3e93 100644 --- a/src/modules.d.ts +++ b/src/modules.d.ts @@ -26,7 +26,7 @@ declare module "~plugins" { folderName: string; userPlugin: boolean; }>; - export const ExcludedPlugins: Record; + export const ExcludedPlugins: Record; } declare module "~pluginNatives" { diff --git a/src/plugins/webContextMenus.web/index.ts b/src/plugins/webContextMenus.web/index.ts index bae78010..50652e36 100644 --- a/src/plugins/webContextMenus.web/index.ts +++ b/src/plugins/webContextMenus.web/index.ts @@ -73,7 +73,7 @@ export default definePlugin({ description: "Re-adds context menus missing in the web version of Discord: Links & Images (Copy/Open Link/Image), Text Area (Copy, Cut, Paste, SpellCheck)", authors: [Devs.Ven], enabledByDefault: true, - required: IS_VESKTOP, + required: IS_VESKTOP || IS_EQUIBOP, settings, @@ -223,11 +223,10 @@ export default definePlugin({ // Automod add filter words { find: '("interactionUsernameProfile', - replacement: - { - match: /\i\.isPlatformEmbedded(?=.{0,50}\.tagName)/, - replace: "true" - }, + replacement: { + match: /\i\.isPlatformEmbedded(?=.{0,50}\.tagName)/, + replace: "true" + }, } ], @@ -251,7 +250,7 @@ export default definePlugin({ }); } - if (IS_VESKTOP && VesktopNative.clipboard) { + if (IS_VESKTOP && VesktopNative.clipboard || IS_EQUIBOP && VesktopNative.clipboard) { VesktopNative.clipboard.copyImage(await imageData.arrayBuffer(), url); return; } else { diff --git a/src/preload.ts b/src/preload.ts index e79eb02c..2ca49302 100644 --- a/src/preload.ts +++ b/src/preload.ts @@ -28,7 +28,7 @@ contextBridge.exposeInMainWorld("VencordNative", VencordNative); // Discord if (location.protocol !== "data:") { // #region cssInsert - const rendererCss = join(__dirname, IS_VESKTOP ? "vencordDesktopRenderer.css" : "renderer.css"); + const rendererCss = join(__dirname, IS_VESKTOP ? "vencordDesktopRenderer.css" : "renderer.css" || IS_EQUIBOP ? "vencordDesktopRenderer.css" : "renderer.css"); const style = document.createElement("style"); style.id = "vencord-css-core"; diff --git a/src/utils/settingsSync.ts b/src/utils/settingsSync.ts index 15653e50..9b1d2f99 100644 --- a/src/utils/settingsSync.ts +++ b/src/utils/settingsSync.ts @@ -49,7 +49,7 @@ export async function exportSettings({ minify }: { minify?: boolean; } = {}) { } export async function downloadSettingsBackup() { - const filename = `vencord-settings-backup-${moment().format("YYYY-MM-DD")}.json`; + const filename = `equicord-settings-backup-${moment().format("YYYY-MM-DD")}.json`; const backup = await exportSettings(); const data = new TextEncoder().encode(backup); diff --git a/src/utils/themes/usercss/compiler.ts b/src/utils/themes/usercss/compiler.ts index 2e3c9a0c..16e69677 100644 --- a/src/utils/themes/usercss/compiler.ts +++ b/src/utils/themes/usercss/compiler.ts @@ -56,7 +56,7 @@ const preprocessors: { [preprocessor: string]: (text: string, vars: Record