remove legacy code
This commit is contained in:
@@ -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")
|
||||
);
|
||||
|
||||
@@ -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"),
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
+4
-10
@@ -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(
|
||||
// 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));
|
||||
}
|
||||
)(require, Buffer, process, clearImmediate, setImmediate);
|
||||
|
||||
webFrame.executeJavaScript(ipcRenderer.sendSync(IpcEvents.GET_VENCORD_RENDERER_SCRIPT));
|
||||
webFrame.executeJavaScript(ipcRenderer.sendSync(IpcEvents.GET_VESKTOP_RENDERER_SCRIPT));
|
||||
|
||||
@@ -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 (
|
||||
<svg {...props} viewBox="0 0 24 24">
|
||||
<path
|
||||
fill="currentColor"
|
||||
d="M18.157.056a1.224 1.224 0 0 0-.709.628c-.105.229-.114.305-.115 1.081v.836l-.351.176a5.545 5.545 0 0 0-.586.342l-.233.167-.543-.311c-.899-.515-.944-.535-1.293-.539-.562-.004-1.018.352-1.17.917-.07.262-.021.567.138.858.151.28.21.325 1.02.794l.606.35v1.38l-.606.35c-.81.469-.869.514-1.02.793-.16.291-.208.597-.137.859.151.564.607.92 1.17.916.347-.004.393-.023 1.289-.537l.54-.308.313.21c.172.116.438.262.588.325l.275.114v.85c.001.793.009.87.115 1.098a1.19 1.19 0 0 0 1.969.282c.269-.307.292-.412.292-1.37v-.869l.315-.148c.173-.081.435-.228.582-.325l.266-.177.706.4c.796.45 1.029.523 1.408.438.882-.198 1.235-1.287.635-1.96-.085-.097-.457-.348-.827-.56l-.67-.385V5.359l.67-.386c.37-.212.742-.463.827-.56.6-.672.247-1.762-.635-1.96-.38-.084-.612-.012-1.405.437l-.7.397-.235-.18a3.792 3.792 0 0 0-.586-.344l-.35-.163v-.848c0-.935-.023-1.044-.292-1.35a1.2 1.2 0 0 0-1.26-.346M4.007 1.25a4.15 4.15 0 0 0-1.21.44c-.354.207-1.102.955-1.309 1.309-.199.34-.374.837-.441 1.252-.07.434-.07 10.426 0 10.86.127.792.42 1.343 1.039 1.963.477.478.81.697 1.317.874.59.204.818.216 4.125.217h3.163v2.42l-1.975.014c-2.202.015-2.148.008-2.5.362-.255.253-.346.474-.346.84s.09.587.345.84c.376.376-.09.348 5.688.348 5.75 0 5.309.025 5.67-.327a1.1 1.1 0 0 0 .362-.86c.002-.367-.09-.586-.344-.84-.353-.355-.3-.348-2.5-.363l-1.976-.014v-2.42h3.164c3.306-.001 3.535-.013 4.124-.217.508-.177.84-.396 1.318-.874.882-.882 1.113-1.57 1.082-3.213-.018-.956-.047-1.068-.364-1.384-.253-.255-.474-.346-.84-.346s-.586.091-.84.346c-.317.316-.343.42-.372 1.47-.023.846-.036.966-.13 1.14a1.22 1.22 0 0 1-.597.553c-.217.098-.276.098-7.757.098-7.48 0-7.54 0-7.757-.098a1.153 1.153 0 0 1-.612-.602l-.114-.242V9.68c.001-5.041.003-5.119.1-5.333.122-.27.3-.462.553-.599.19-.103.242-.104 2.958-.128 3.08-.027 2.927-.01 3.288-.372.255-.254.345-.474.345-.84s-.09-.587-.345-.84c-.364-.365-.204-.347-3.288-.355-1.52-.004-2.881.012-3.024.036m15.047 3.693c.207.108.452.361.57.59.143.278.143.755 0 1.028-.285.54-1.08.81-1.636.556a1.357 1.357 0 0 1-.59-.625c-.107-.255-.092-.7.032-.956.121-.251.46-.568.69-.645.213-.073.755-.043.934.052"
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
+11
-20
@@ -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
|
||||
});
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user