From f96f325594bfd97c058ad9910c968db5ada53a46 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Wed, 1 Jul 2026 18:45:48 +0200 Subject: [PATCH] remove legacy code --- src/main/ipc.ts | 3 --- src/main/mainWindow.ts | 4 +-- src/main/utils/vencordLoader.ts | 15 +----------- src/preload/index.ts | 26 ++++++++------------ src/renderer/components/SettingsIcon.tsx | 18 ++++++++++++++ src/renderer/index.ts | 31 +++++++++--------------- src/shared/IpcEvents.ts | 1 - 7 files changed, 42 insertions(+), 56 deletions(-) create mode 100644 src/renderer/components/SettingsIcon.tsx diff --git a/src/main/ipc.ts b/src/main/ipc.ts index 9a17526..fde6762 100644 --- a/src/main/ipc.ts +++ b/src/main/ipc.ts @@ -35,9 +35,6 @@ import { isDeckGameMode, showGamePage } from "./utils/steamOS"; import { isValidVencordInstall } from "./utils/vencordLoader"; import { VENCORD_FILES_DIR } from "./vencordFilesDir"; -handleSync(IpcEvents.DEPRECATED_GET_VENCORD_PRELOAD_SCRIPT_PATH, () => - join(VENCORD_FILES_DIR, "vencordDesktopPreload.js") -); handleSync(IpcEvents.GET_VENCORD_PRELOAD_SCRIPT, () => readFileSync(join(VENCORD_FILES_DIR, "vencordDesktopPreload.js"), "utf-8") ); diff --git a/src/main/mainWindow.ts b/src/main/mainWindow.ts index 072d4ca..9acbe3d 100644 --- a/src/main/mainWindow.ts +++ b/src/main/mainWindow.ts @@ -34,7 +34,7 @@ import { destroyTray, initTray } from "./tray"; import { clearData } from "./utils/clearData"; import { makeLinksOpenExternally } from "./utils/makeLinksOpenExternally"; import { applyDeckKeyboardFix, askToApplySteamLayout, isDeckGameMode } from "./utils/steamOS"; -import { downloadVencordFiles, ensureVencordFiles, vencordSupportsSandboxing } from "./utils/vencordLoader"; +import { downloadVencordFiles, ensureVencordFiles } from "./utils/vencordLoader"; import { VENCORD_FILES_DIR } from "./vencordFilesDir"; let isQuitting = false; @@ -326,7 +326,7 @@ function buildBrowserWindowOptions(): BrowserWindowConstructorOptions { backgroundColor, webPreferences: { nodeIntegration: false, - sandbox: vencordSupportsSandboxing(), + sandbox: true, contextIsolation: true, devTools: true, preload: join(__dirname, "preload.js"), diff --git a/src/main/utils/vencordLoader.ts b/src/main/utils/vencordLoader.ts index 96ab1ff..25748b3 100644 --- a/src/main/utils/vencordLoader.ts +++ b/src/main/utils/vencordLoader.ts @@ -4,7 +4,7 @@ * SPDX-License-Identifier: GPL-3.0-or-later */ -import { mkdirSync, readFileSync } from "fs"; +import { mkdirSync } from "fs"; import { access, constants as FsConstants, writeFile } from "fs/promises"; import { VENCORD_FILES_DIR } from "main/vencordFilesDir"; import { join } from "path"; @@ -75,16 +75,3 @@ export async function ensureVencordFiles() { await Promise.all([downloadVencordFiles(), writeFile(join(VENCORD_FILES_DIR, "package.json"), "{}")]); } - -// TODO: remove this once enough time has passed -export function vencordSupportsSandboxing() { - const supports = readFileSync(join(VENCORD_FILES_DIR, "vencordDesktopMain.js"), "utf-8").includes( - "VencordGetRendererCss" - ); - if (!supports) { - console.warn( - "⚠️ [VencordLoader] Vencord version is outdated and does not support sandboxing. Please update Vencord to the latest version." - ); - } - return supports; -} diff --git a/src/preload/index.ts b/src/preload/index.ts index e91ffbc..6ed74f9 100644 --- a/src/preload/index.ts +++ b/src/preload/index.ts @@ -11,22 +11,16 @@ import { VesktopNative } from "./VesktopNative"; contextBridge.exposeInMainWorld("VesktopNative", VesktopNative); -// TODO: remove this legacy workaround once some time has passed -const isSandboxed = typeof __dirname === "undefined"; -if (isSandboxed) { - // While sandboxed, Electron "polyfills" these APIs as local variables. - // We have to pass them as arguments as they are not global - Function( - "require", - "Buffer", - "process", - "clearImmediate", - "setImmediate", - ipcRenderer.sendSync(IpcEvents.GET_VENCORD_PRELOAD_SCRIPT) - )(require, Buffer, process, clearImmediate, setImmediate); -} else { - require(ipcRenderer.sendSync(IpcEvents.DEPRECATED_GET_VENCORD_PRELOAD_SCRIPT_PATH)); -} +// While sandboxed, Electron "polyfills" these APIs as local variables. +// We have to pass them as arguments as they are not global +Function( + "require", + "Buffer", + "process", + "clearImmediate", + "setImmediate", + ipcRenderer.sendSync(IpcEvents.GET_VENCORD_PRELOAD_SCRIPT) +)(require, Buffer, process, clearImmediate, setImmediate); webFrame.executeJavaScript(ipcRenderer.sendSync(IpcEvents.GET_VENCORD_RENDERER_SCRIPT)); webFrame.executeJavaScript(ipcRenderer.sendSync(IpcEvents.GET_VESKTOP_RENDERER_SCRIPT)); diff --git a/src/renderer/components/SettingsIcon.tsx b/src/renderer/components/SettingsIcon.tsx new file mode 100644 index 0000000..aa572aa --- /dev/null +++ b/src/renderer/components/SettingsIcon.tsx @@ -0,0 +1,18 @@ +/* + * Vesktop, a desktop app aiming to give you a snappier Discord Experience + * Copyright (c) 2026 Vendicated and Vesktop contributors + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +import { IconProps } from "@vencord/types/utils/types"; + +export function VesktopSettingsIcon(props: IconProps) { + return ( + + + + ); +} diff --git a/src/renderer/index.ts b/src/renderer/index.ts index 34e2c20..1e6f6b5 100644 --- a/src/renderer/index.ts +++ b/src/renderer/index.ts @@ -13,32 +13,23 @@ import "__patches__"; // auto generated by the build script export * as Components from "./components"; +import { VesktopSettingsIcon } from "@vencord/types/components"; + import SettingsUi from "./components/settings/Settings"; import { VesktopLogger } from "./logger"; import { Settings } from "./settings"; export { Settings }; -import type SettingsPlugin from "@vencord/types/plugins/_core/settings"; - VesktopLogger.log("read if cute :3"); VesktopLogger.log("Vesktop v" + VesktopNative.app.getVersion()); -// TODO -const customSettingsSections = (Vencord.Plugins.plugins.Settings as typeof SettingsPlugin).customSections; +const SettingsPlugin = Vencord.Plugins.plugins + .Settings as typeof import("@vencord/types/plugins/_core/settings").default; -customSettingsSections.push(() => ({ - section: "Vesktop", - label: "Vesktop Settings", - element: SettingsUi, - className: "vc-vesktop-settings" -})); - -// TODO: remove this legacy workaround once some time has passed -if (!Vencord.Api.Styles.vencordRootNode) { - const style = document.createElement("style"); - style.id = "vesktop-css-core"; - - VesktopNative.app.getRendererCss().then(css => (style.textContent = css)); - - document.addEventListener("DOMContentLoaded", () => document.documentElement.append(style), { once: true }); -} +SettingsPlugin.customEntries.push({ + key: "vesktop", + title: "Vesktop", + panelTitle: "Vesktop Settings", + Component: SettingsUi, + Icon: VesktopSettingsIcon +}); diff --git a/src/shared/IpcEvents.ts b/src/shared/IpcEvents.ts index 075ec14..13f27b4 100644 --- a/src/shared/IpcEvents.ts +++ b/src/shared/IpcEvents.ts @@ -6,7 +6,6 @@ export const enum IpcEvents { GET_VENCORD_PRELOAD_SCRIPT = "VCD_GET_VC_PRELOAD_SCRIPT", - DEPRECATED_GET_VENCORD_PRELOAD_SCRIPT_PATH = "DEPRECATED_GET_VENCORD_PRELOAD_SCRIPT_PATH", GET_VENCORD_RENDERER_SCRIPT = "VCD_GET_VC_RENDERER_SCRIPT", GET_VESKTOP_RENDERER_SCRIPT = "VCD_GET_RENDERER_SCRIPT",