24 Commits

Author SHA1 Message Date
V
5f5febda9d bump electron for important security fixes 2023-09-25 03:12:51 +02:00
Lewis Crichton
94ba59afb5 fix: add correct WMClass to desktop file (#108)
resolves #96
2023-08-31 22:52:12 +02:00
V
566737017c ci: publish as draft 2023-08-27 22:40:37 +02:00
Lewis Crichton
196ee4e42c ci: winget (#101) 2023-08-27 22:27:23 +02:00
V
9bb02f8581 security: make ipc only allow discord origins 2023-08-25 15:32:06 +02:00
V
c76d7195a5 Bump to 0.3.0 2023-08-16 02:05:17 +02:00
V
50a103710d Add Vesktop section to Settings customSections 2023-08-16 02:02:23 +02:00
DaBluLite
e6e66e775c Fix platformClass: change "platform-windows" to "platform-win" (#94) 2023-08-14 13:55:47 +00:00
V
a5ec031a2f Fix windows titlebar on canary 2023-08-12 04:01:10 +02:00
V
4dceadbbd2 Bump to 0.2.9 (for real this time) 2023-08-12 03:15:37 +02:00
V
6ee920ff2c Show error toast when selecting invalid venchord dir 2023-08-12 03:15:21 +02:00
V
28ad4a6f73 Improve valid vencord install checks 2023-08-12 03:13:07 +02:00
V
c5ac3e64a6 Bump to 0.2.9 2023-08-12 03:09:38 +02:00
Justice Almanzar
6dc26aea6a vecord: download proper vesktop specific preload & renderer css (#90)
Co-authored-by: V <vendicated@riseup.net>
2023-08-12 03:09:14 +02:00
Hugo C
9003b94f85 mac: fix dock notification badge (#88) 2023-08-08 13:08:32 +02:00
V
f7b7931847 only pass partial info 2023-08-07 00:48:23 +02:00
V
b87bcaefe9 Wayland: Skip our screenshare screen picker 2023-08-07 00:39:38 +02:00
V
3108de7c79 Port Discord's windows title bar (#86) 2023-08-07 00:23:27 +02:00
Lewis Crichton
57006e7e52 feat: portable zip (#85) 2023-08-06 02:05:48 +02:00
Nickyux
8f1ea1f440 Update Settings Text to Vesktop (#84) 2023-08-05 17:18:12 +00:00
TymanWasTaken
26b6fb13d4 Update pnpm in package.json (#79)
Co-authored-by: V <vendicated@riseup.net>
2023-08-04 20:36:28 +02:00
V
e1971f55a0 bump arrpc; fixes false positives 2023-08-04 20:21:49 +02:00
V
ba2618878e add vencord themes watcher 2023-08-04 19:39:33 +02:00
V
87595deae7 Fix static title 2023-08-02 23:59:02 +02:00
20 changed files with 270 additions and 89 deletions

33
.github/workflows/winget-submission.yml vendored Normal file
View File

@@ -0,0 +1,33 @@
# Based on Microsoft/DevHome Winget CI, modified for use in Vencord/Vesktop.
#
# Copyright (c) Microsoft Corporation and Contributors
# Licensed under the MIT license.
name: Submit to Winget Community Repo
on:
workflow_dispatch:
release:
types: [published]
jobs:
winget:
name: Publish winget package
runs-on: windows-latest
env:
WINGET_PAT: ${{ secrets.WINGET_PAT }}
steps:
- name: Submit package to Winget Community Repo
run: |
$packageId = "Vencord.Vesktop"
# Fetching latest release from GitHub
$github = Invoke-RestMethod -uri "https://api.github.com/repos/vencord/vesktop/releases"
$targetRelease = $github | Select-Object -First 1
$installerUrl = $targetRelease | Select-Object -ExpandProperty assets -First 1 | Where-Object -Property name -match 'Vesktop-Setup.*?exe' | Select-Object -ExpandProperty browser_download_url
$packageVersion = $targetRelease.tag_name.Trim("v")
# Update package using wingetcreate
Invoke-WebRequest https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe
.\wingetcreate.exe update $packageId --version $packageVersion --urls "$installerUrl" --submit --token $env:WINGET_PAT

View File

@@ -1,6 +1,6 @@
{
"name": "VencordDesktop",
"version": "0.2.8",
"version": "0.3.1",
"private": true,
"description": "",
"keywords": [],
@@ -23,7 +23,7 @@
"watch": "pnpm build --watch"
},
"dependencies": {
"arrpc": "github:OpenAsar/arrpc#bfcba7e3d6e6f7301a5699c4a1eb10c968e7b568"
"arrpc": "github:OpenAsar/arrpc#b47fd7d498e248955c843a7857dd26478b82190a"
},
"devDependencies": {
"@fal-works/esbuild-plugin-global-externals": "^2.1.2",
@@ -33,7 +33,7 @@
"@typescript-eslint/parser": "^6.2.1",
"@vencord/types": "^0.1.2",
"dotenv": "^16.3.1",
"electron": "^25.4.0",
"electron": "^26.2.2",
"electron-builder": "^24.6.3",
"esbuild": "^0.18.17",
"eslint": "^8.46.0",
@@ -50,7 +50,7 @@
"type-fest": "^4.1.0",
"typescript": "^5.1.6"
},
"packageManager": "pnpm@8.1.1",
"packageManager": "pnpm@8.6.11",
"engines": {
"node": ">=18",
"pnpm": ">=8"
@@ -79,7 +79,8 @@
"GenericName": "Internet Messenger",
"Type": "Application",
"Categories": "Network;InstantMessaging;Chat;",
"Keywords": "discord;vencord;electron;chat;"
"Keywords": "discord;vencord;electron;chat;",
"WMClass": "VencordDesktop"
}
},
"mac": {
@@ -101,12 +102,11 @@
"win": {
"target": [
"nsis",
"portable"
"zip"
]
},
"publish": {
"provider": "github",
"releaseType": "release"
"provider": "github"
}
}
}

16
pnpm-lock.yaml generated
View File

@@ -6,8 +6,8 @@ settings:
dependencies:
arrpc:
specifier: github:OpenAsar/arrpc#bfcba7e3d6e6f7301a5699c4a1eb10c968e7b568
version: github.com/OpenAsar/arrpc/bfcba7e3d6e6f7301a5699c4a1eb10c968e7b568
specifier: github:OpenAsar/arrpc#b47fd7d498e248955c843a7857dd26478b82190a
version: github.com/OpenAsar/arrpc/b47fd7d498e248955c843a7857dd26478b82190a
devDependencies:
'@fal-works/esbuild-plugin-global-externals':
@@ -32,8 +32,8 @@ devDependencies:
specifier: ^16.3.1
version: 16.3.1
electron:
specifier: ^25.4.0
version: 25.4.0
specifier: ^26.2.2
version: 26.2.2
electron-builder:
specifier: ^24.6.3
version: 24.6.3
@@ -1764,8 +1764,8 @@ packages:
- supports-color
dev: true
/electron@25.4.0:
resolution: {integrity: sha512-VLTRxDhL4UvQbqM7pTNENnJo62cdAPZT92N+B7BZQ5Xfok1wuVPEewIjBot4K7U3EpLUuHn1veeLzho3ihiP+Q==}
/electron@26.2.2:
resolution: {integrity: sha512-Ihb3Zt4XYnHF52DYSq17ySkgFqJV4OT0VnfhUYZASAql7Vembz3VsAq7mB3OALBHXltAW34P8BxTIwTqZaMS3g==}
engines: {node: '>= 12.20.55'}
hasBin: true
requiresBuild: true
@@ -4356,8 +4356,8 @@ packages:
engines: {node: '>=10'}
dev: true
github.com/OpenAsar/arrpc/bfcba7e3d6e6f7301a5699c4a1eb10c968e7b568:
resolution: {tarball: https://codeload.github.com/OpenAsar/arrpc/tar.gz/bfcba7e3d6e6f7301a5699c4a1eb10c968e7b568}
github.com/OpenAsar/arrpc/b47fd7d498e248955c843a7857dd26478b82190a:
resolution: {tarball: https://codeload.github.com/OpenAsar/arrpc/tar.gz/b47fd7d498e248955c843a7857dd26478b82190a}
name: arrpc
version: 3.1.0
dependencies:

View File

@@ -23,11 +23,17 @@ let lastIndex: null | number = -1;
export function setBadgeCount(count: number) {
switch (process.platform) {
case "darwin":
case "linux":
if (count === -1) count = 0;
app.setBadgeCount(count);
break;
case "darwin":
if (count === 0) {
app.dock.setBadge("");
break;
}
app.dock.setBadge(count === -1 ? "•" : count.toString());
break;
case "win32":
const [index, description] = getBadgeIndexAndDescription(count);
if (lastIndex === index) break;

View File

@@ -11,6 +11,7 @@ export const DATA_DIR = process.env.VENCORD_USER_DATA_DIR || join(app.getPath("u
export const VENCORD_SETTINGS_DIR = join(DATA_DIR, "settings");
export const VENCORD_QUICKCSS_FILE = join(VENCORD_SETTINGS_DIR, "quickCss.css");
export const VENCORD_SETTINGS_FILE = join(VENCORD_SETTINGS_DIR, "settings.json");
export const VENCORD_THEMES_DIR = join(DATA_DIR, "themes");
// needs to be inline require because of circular dependency
// as otherwise "DATA_DIR" (which is used by ./settings) will be uninitialised

View File

@@ -4,8 +4,8 @@
* Copyright (c) 2023 Vendicated and Vencord contributors
*/
import { app, dialog, ipcMain, session, shell } from "electron";
import { existsSync, readFileSync, watch } from "fs";
import { app, dialog, session, shell } from "electron";
import { mkdirSync, readFileSync, watch } from "fs";
import { open, readFile } from "fs/promises";
import { release } from "os";
import { join } from "path";
@@ -14,69 +14,69 @@ import { debounce } from "shared/utils/debounce";
import { IpcEvents } from "../shared/IpcEvents";
import { setBadgeCount } from "./appBadge";
import { autoStart } from "./autoStart";
import { VENCORD_FILES_DIR, VENCORD_QUICKCSS_FILE } from "./constants";
import { VENCORD_FILES_DIR, VENCORD_QUICKCSS_FILE, VENCORD_THEMES_DIR } from "./constants";
import { mainWin } from "./mainWindow";
import { Settings } from "./settings";
import { handle, handleSync } from "./utils/ipcWrappers";
import { isValidVencordInstall } from "./utils/vencordLoader";
ipcMain.on(IpcEvents.GET_VENCORD_PRELOAD_FILE, e => {
e.returnValue = join(VENCORD_FILES_DIR, "preload.js");
});
handleSync(IpcEvents.GET_VENCORD_PRELOAD_FILE, () => join(VENCORD_FILES_DIR, "vencordDesktopPreload.js"));
handleSync(IpcEvents.GET_VENCORD_RENDERER_SCRIPT, () =>
readFileSync(join(VENCORD_FILES_DIR, "vencordDesktopRenderer.js"), "utf-8")
);
ipcMain.on(IpcEvents.GET_VENCORD_RENDERER_SCRIPT, e => {
e.returnValue = readFileSync(join(VENCORD_FILES_DIR, "vencordDesktopRenderer.js"), "utf-8");
});
handleSync(IpcEvents.GET_RENDERER_SCRIPT, () => readFileSync(join(__dirname, "renderer.js"), "utf-8"));
handleSync(IpcEvents.GET_RENDERER_CSS_FILE, () => join(__dirname, "renderer.css"));
ipcMain.on(IpcEvents.GET_RENDERER_SCRIPT, e => {
e.returnValue = readFileSync(join(__dirname, "renderer.js"), "utf-8");
});
handleSync(IpcEvents.GET_SETTINGS, () => Settings.plain);
handleSync(IpcEvents.GET_VERSION, () => app.getVersion());
ipcMain.on(IpcEvents.GET_RENDERER_CSS_FILE, e => {
e.returnValue = join(__dirname, "renderer.css");
});
handleSync(
IpcEvents.SUPPORTS_WINDOWS_TRANSPARENCY,
() => process.platform === "win32" && Number(release().split(".").pop()) >= 22621
);
ipcMain.on(IpcEvents.GET_SETTINGS, e => {
e.returnValue = Settings.plain;
});
handleSync(IpcEvents.AUTOSTART_ENABLED, () => autoStart.isEnabled());
handle(IpcEvents.ENABLE_AUTOSTART, autoStart.enable);
handle(IpcEvents.DISABLE_AUTOSTART, autoStart.disable);
ipcMain.on(IpcEvents.GET_VERSION, e => {
e.returnValue = app.getVersion();
});
ipcMain.on(IpcEvents.SUPPORTS_WINDOWS_TRANSPARENCY, e => {
e.returnValue = process.platform === "win32" && Number(release().split(".").pop()) >= 22621;
});
ipcMain.on(IpcEvents.AUTOSTART_ENABLED, e => {
e.returnValue = autoStart.isEnabled();
});
ipcMain.handle(IpcEvents.ENABLE_AUTOSTART, autoStart.enable);
ipcMain.handle(IpcEvents.DISABLE_AUTOSTART, autoStart.disable);
ipcMain.handle(IpcEvents.SET_SETTINGS, (_, settings: typeof Settings.store, path?: string) => {
handle(IpcEvents.SET_SETTINGS, (_, settings: typeof Settings.store, path?: string) => {
Settings.setData(settings, path);
});
ipcMain.handle(IpcEvents.RELAUNCH, () => {
handle(IpcEvents.RELAUNCH, () => {
app.relaunch();
app.exit();
});
ipcMain.handle(IpcEvents.SHOW_ITEM_IN_FOLDER, (_, path) => {
handle(IpcEvents.SHOW_ITEM_IN_FOLDER, (_, path) => {
shell.showItemInFolder(path);
});
ipcMain.handle(IpcEvents.FOCUS, () => {
handle(IpcEvents.FOCUS, () => {
if (process.platform === "win32") mainWin.minimize(); // Windows is weird
mainWin.restore();
mainWin.show();
});
ipcMain.handle(IpcEvents.CLOSE, e => {
e.sender.close();
handle(IpcEvents.CLOSE, e => {
mainWin.close();
});
ipcMain.handle(IpcEvents.SPELLCHECK_SET_LANGUAGES, (_, languages: string[]) => {
handle(IpcEvents.MINIMIZE, e => {
mainWin.minimize();
});
handle(IpcEvents.MAXIMIZE, e => {
if (mainWin.isMaximized()) {
mainWin.unmaximize();
} else {
mainWin.maximize();
}
});
handle(IpcEvents.SPELLCHECK_SET_LANGUAGES, (_, languages: string[]) => {
const ses = session.defaultSession;
const available = ses.availableSpellCheckerLanguages;
@@ -84,29 +84,27 @@ ipcMain.handle(IpcEvents.SPELLCHECK_SET_LANGUAGES, (_, languages: string[]) => {
if (applicable.length) ses.setSpellCheckerLanguages(applicable);
});
ipcMain.handle(IpcEvents.SPELLCHECK_REPLACE_MISSPELLING, (e, word: string) => {
handle(IpcEvents.SPELLCHECK_REPLACE_MISSPELLING, (e, word: string) => {
e.sender.replaceMisspelling(word);
});
ipcMain.handle(IpcEvents.SPELLCHECK_ADD_TO_DICTIONARY, (e, word: string) => {
handle(IpcEvents.SPELLCHECK_ADD_TO_DICTIONARY, (e, word: string) => {
e.sender.session.addWordToSpellCheckerDictionary(word);
});
ipcMain.handle(IpcEvents.SELECT_VENCORD_DIR, async () => {
handle(IpcEvents.SELECT_VENCORD_DIR, async () => {
const res = await dialog.showOpenDialog(mainWin!, {
properties: ["openDirectory"]
});
if (!res.filePaths.length) return "cancelled";
const dir = res.filePaths[0];
for (const file of ["vencordDesktopMain.js", "preload.js", "vencordDesktopRenderer.js", "renderer.css"]) {
if (!existsSync(join(dir, file))) return "invalid";
}
if (!isValidVencordInstall(dir)) return "invalid";
return dir;
});
ipcMain.handle(IpcEvents.SET_BADGE_COUNT, (_, count: number) => setBadgeCount(count));
handle(IpcEvents.SET_BADGE_COUNT, (_, count: number) => setBadgeCount(count));
function readCss() {
return readFile(VENCORD_QUICKCSS_FILE, "utf-8").catch(() => "");
@@ -122,3 +120,12 @@ open(VENCORD_QUICKCSS_FILE, "a+").then(fd => {
}, 50)
);
});
mkdirSync(VENCORD_THEMES_DIR, { recursive: true });
watch(
VENCORD_THEMES_DIR,
{ persistent: false },
debounce(() => {
mainWin?.webContents.postMessage("VencordThemeUpdate", void 0);
})
);

View File

@@ -315,8 +315,11 @@ function createMainWindow() {
removeSettingsListeners();
removeVencordSettingsListeners();
const { staticTitle, transparencyOption, enableMenu } = Settings.store;
const { staticTitle, transparencyOption, enableMenu, discordWindowsTitleBar } = Settings.store;
const { frameless, macosTranslucency } = VencordSettings.store;
const noFrame = frameless === true || (process.platform === "win32" && discordWindowsTitleBar === true);
const win = (mainWin = new BrowserWindow({
show: false,
webPreferences: {
@@ -328,7 +331,7 @@ function createMainWindow() {
spellcheck: true
},
icon: ICON_PATH,
frame: frameless !== true,
frame: !noFrame,
...(transparencyOption && transparencyOption !== "none"
? {
backgroundColor: "#00000000",
@@ -336,7 +339,7 @@ function createMainWindow() {
transparent: true
}
: {}),
...(staticTitle ? { title: "Vencord" } : {}),
...(staticTitle ? { title: "Vesktop" } : {}),
...(macosTranslucency
? {
vibrancy: "sidebar",

View File

@@ -4,12 +4,14 @@
* Copyright (c) 2023 Vendicated and Vencord contributors
*/
import { desktopCapturer, ipcMain, session, Streams } from "electron";
import { desktopCapturer, session, Streams } from "electron";
import type { StreamPick } from "renderer/components/ScreenSharePicker";
import { IpcEvents } from "shared/IpcEvents";
import { handle } from "./utils/ipcWrappers";
export function registerScreenShareHandler() {
ipcMain.handle(IpcEvents.CAPTURER_GET_LARGE_THUMBNAIL, async (_, id: string) => {
handle(IpcEvents.CAPTURER_GET_LARGE_THUMBNAIL, async (_, id: string) => {
const sources = await desktopCapturer.getSources({
types: ["window", "screen"],
thumbnailSize: {
@@ -29,12 +31,22 @@ export function registerScreenShareHandler() {
}
});
const isWayland =
process.platform === "linux" &&
(process.env.XDG_SESSION_TYPE === "wayland" || !!process.env.WAYLAND_DISPLAY);
const data = sources.map(({ id, name, thumbnail }) => ({
id,
name,
url: thumbnail.toDataURL()
}));
if (isWayland) {
const video = data[0];
callback(video ? { video } : {});
return;
}
const choice = await request.frame
.executeJavaScript(`Vesktop.Components.ScreenShare.openScreenSharePicker(${JSON.stringify(data)})`)
.then(e => e as StreamPick)

View File

@@ -0,0 +1,36 @@
/*
* SPDX-License-Identifier: GPL-3.0
* Vesktop, a desktop app aiming to give you a snappier Discord Experience
* Copyright (c) 2023 Vendicated and Vencord contributors
*/
import { ipcMain, IpcMainEvent, IpcMainInvokeEvent, WebFrameMain } from "electron";
import { IpcEvents } from "shared/IpcEvents";
export function validateSender(frame: WebFrameMain) {
const { hostname, protocol } = new URL(frame.url);
if (protocol === "file:") return;
switch (hostname) {
case "discord.com":
case "ptb.discord.com":
case "canary.discord.com":
break;
default:
throw new Error("ipc: Disallowed host " + hostname);
}
}
export function handleSync(event: IpcEvents, cb: (e: IpcMainEvent, ...args: any[]) => any) {
ipcMain.on(event, (e, ...args) => {
validateSender(e.senderFrame);
e.returnValue = cb(e, ...args);
});
}
export function handle(event: IpcEvents, cb: (e: IpcMainInvokeEvent, ...args: any[]) => any) {
ipcMain.handle(event, (e, ...args) => {
validateSender(e.senderFrame);
return cb(e, ...args);
});
}

View File

@@ -13,7 +13,12 @@ import { downloadFile, simpleGet } from "./http";
const API_BASE = "https://api.github.com";
const FILES_TO_DOWNLOAD = ["vencordDesktopMain.js", "preload.js", "vencordDesktopRenderer.js", "renderer.css"];
export const FILES_TO_DOWNLOAD = [
"vencordDesktopMain.js",
"vencordDesktopPreload.js",
"vencordDesktopRenderer.js",
"vencordDesktopRenderer.css"
];
export interface ReleaseData {
name: string;
@@ -50,8 +55,12 @@ export async function downloadVencordFiles() {
);
}
export function isValidVencordInstall(dir: string) {
return FILES_TO_DOWNLOAD.every(f => existsSync(join(dir, f)));
}
export async function ensureVencordFiles() {
if (existsSync(join(VENCORD_FILES_DIR, "vencordDesktopMain.js"))) return;
if (isValidVencordInstall(VENCORD_FILES_DIR)) return;
mkdirSync(VENCORD_FILES_DIR, { recursive: true });
await downloadVencordFiles();

View File

@@ -51,7 +51,10 @@ export const VesktopNative = {
addToDictionary: (word: string) => invoke<void>(IpcEvents.SPELLCHECK_ADD_TO_DICTIONARY, word)
},
win: {
focus: () => invoke<void>(IpcEvents.FOCUS)
focus: () => invoke<void>(IpcEvents.FOCUS),
close: () => invoke<void>(IpcEvents.CLOSE),
minimize: () => invoke<void>(IpcEvents.MINIMIZE),
maximize: () => invoke<void>(IpcEvents.MAXIMIZE)
},
capturer: {
getLargeThumbnail: (id: string) => invoke<string>(IpcEvents.CAPTURER_GET_LARGE_THUMBNAIL, id)

View File

@@ -7,10 +7,10 @@
import "./settings.css";
import { Margins } from "@vencord/types/utils";
import { Button, Forms, Select, Switch, Text, useState } from "@vencord/types/webpack/common";
import { Button, Forms, Select, Switch, Text, Toasts, useState } from "@vencord/types/webpack/common";
import { setBadge } from "renderer/appBadge";
import { useSettings } from "renderer/settings";
import { isMac } from "renderer/utils";
import { isMac, isWindows } from "renderer/utils";
import { isTruthy } from "shared/utils/guards";
export default function SettingsUi() {
@@ -21,6 +21,11 @@ export default function SettingsUi() {
const [autoStartEnabled, setAutoStartEnabled] = useState(autostart.isEnabled());
const allSwitches: Array<false | [keyof typeof Settings, string, string, boolean?, (() => boolean)?]> = [
isWindows && [
"discordWindowsTitleBar",
"Discord Titlebar",
"Use Discord's custom title bar instead of the Windows one. Requires a full restart."
],
!isMac && ["tray", "Tray Icon", "Add a tray icon for Vesktop", true],
!isMac && [
"minimizeToTray",
@@ -35,13 +40,13 @@ export default function SettingsUi() {
"Disable minimum window size",
"Allows you to make the window as small as your heart desires"
],
["staticTitle", "Static Title", 'Makes the window title "Vesktop" instead of changing to the current page'],
["enableMenu", "Enable Menu Bar", "Enables the application menu bar. Press ALT to toggle visibility."],
[
"openLinksWithElectron",
"Open Links in app (experimental)",
"Opens links in a new Vesktop window instead of your web browser"
],
["staticTitle", "Static Title", 'Makes the window title "Vencord" instead of changing to the current page'],
["enableMenu", "Enable Menu Bar", "Enables the application menu bar. Press ALT to toggle visibility."]
]
];
const switches = allSwitches.filter(isTruthy);
@@ -164,8 +169,14 @@ export default function SettingsUi() {
const choice = await VesktopNative.fileManager.selectVencordDir();
switch (choice) {
case "cancelled":
return;
case "invalid":
// TODO
Toasts.show({
message:
"You did not choose a valid Vencord install. Make sure you're selecting the dist dir!",
id: Toasts.genId(),
type: Toasts.Type.FAILURE
});
return;
}
Settings.vencordDir = choice;

View File

@@ -3,3 +3,8 @@
[class|=listItem]:has(+ [class|=listItem] [data-list-item-id=guildsnav___app-download-button]) {
display: none;
}
/* FIXME: Remove after 23/08/23 */
.vc-desktop-settings {
display: none;
}

View File

@@ -14,6 +14,7 @@ export * as Components from "./components";
import { findByPropsLazy } from "@vencord/types/webpack";
import { FluxDispatcher } from "@vencord/types/webpack/common";
import SettingsUi from "./components/Settings";
import { Settings } from "./settings";
export { Settings };
@@ -35,6 +36,17 @@ export async function openInviteModal(code: string) {
return true;
}
const customSettingsSections = (
Vencord.Plugins.plugins.Settings as any as { customSections: ((ID: Record<string, unknown>) => any)[] }
).customSections;
customSettingsSections.push(() => ({
section: "Vesktop",
label: "Vesktop Settings",
element: SettingsUi,
className: "vc-vesktop-settings"
}));
const arRPC = Vencord.Plugins.plugins["WebRichPresence (arRPC)"];
arRPC.required = !!Settings.store.arRPC;

View File

@@ -7,3 +7,4 @@
// TODO: Possibly auto generate glob if we have more patches in the future
import "./spellCheck";
import "./platformClass";
import "./windowsTitleBar";

View File

@@ -4,6 +4,9 @@
* Copyright (c) 2023 Vendicated and Vencord contributors
*/
import { Settings } from "renderer/settings";
import { isMac, isWindows } from "renderer/utils";
import { addPatch } from "./shared";
addPatch({
@@ -18,5 +21,9 @@ addPatch({
}
],
getPlatformClass: () => (navigator.platform.toLowerCase().startsWith("mac") ? "platform-osx" : "platform-web")
getPlatformClass() {
if (isMac) return "platform-osx";
if (isWindows && Settings.store.discordWindowsTitleBar) return "platform-win";
return "platform-web";
}
});

View File

@@ -0,0 +1,30 @@
/*
* SPDX-License-Identifier: GPL-3.0
* Vesktop, a desktop app aiming to give you a snappier Discord Experience
* Copyright (c) 2023 Vendicated and Vencord contributors
*/
import { Settings } from "renderer/settings";
import { addPatch } from "./shared";
if (Settings.store.discordWindowsTitleBar)
addPatch({
patches: [
{
find: ".wordmarkWindows",
replacement: [
{
// TODO: Fix eslint rule
// eslint-disable-next-line no-useless-escape
match: /case \i\.\i\.WINDOWS:/,
replace: 'case "WEB":'
},
...["close", "minimize", "maximize"].map(op => ({
match: new RegExp(String.raw`\i\.\i\.${op}\b`),
replace: `VesktopNative.win.${op}`
}))
]
}
]
});

View File

@@ -16,6 +16,8 @@ export const enum IpcEvents {
RELAUNCH = "VCD_RELAUNCH",
CLOSE = "VCD_CLOSE",
FOCUS = "VCD_FOCUS",
MINIMIZE = "VCD_MINIMIZE",
MAXIMIZE = "VCD_MAXIMIZE",
SHOW_ITEM_IN_FOLDER = "VCD_SHOW_ITEM_IN_FOLDER",
GET_SETTINGS = "VCD_GET_SETTINGS",

View File

@@ -7,21 +7,23 @@
import type { Rectangle } from "electron";
export interface Settings {
transparencyOption?: "none" | "mica" | "tabbed" | "acrylic";
maximized?: boolean;
minimized?: boolean;
windowBounds?: Rectangle;
discordBranch?: "stable" | "canary" | "ptb";
openLinksWithElectron?: boolean;
vencordDir?: string;
disableMinSize?: boolean;
transparencyOption?: "none" | "mica" | "tabbed" | "acrylic";
tray?: boolean;
minimizeToTray?: boolean;
skippedUpdate?: string;
openLinksWithElectron?: boolean;
staticTitle?: boolean;
enableMenu?: boolean;
arRPC?: boolean;
appBadge?: boolean;
discordWindowsTitleBar?: boolean;
maximized?: boolean;
minimized?: boolean;
windowBounds?: Rectangle;
disableMinSize?: boolean;
skippedUpdate?: string;
firstLaunch?: boolean;
}

View File

@@ -4,8 +4,9 @@
* Copyright (c) 2023 Vendicated and Vencord contributors
*/
import { app, BrowserWindow, ipcMain, shell } from "electron";
import { app, BrowserWindow, shell } from "electron";
import { Settings } from "main/settings";
import { handle } from "main/utils/ipcWrappers";
import { makeLinksOpenExternally } from "main/utils/makeLinksOpenExternally";
import { githubGet, ReleaseData } from "main/utils/vencordLoader";
import { join } from "path";
@@ -20,8 +21,8 @@ export interface UpdateData {
let updateData: UpdateData;
ipcMain.handle(IpcEvents.UPDATER_GET_DATA, () => updateData);
ipcMain.handle(IpcEvents.UPDATER_DOWNLOAD, () => {
handle(IpcEvents.UPDATER_GET_DATA, () => updateData);
handle(IpcEvents.UPDATER_DOWNLOAD, () => {
const portable = !!process.env.PORTABLE_EXECUTABLE_FILE;
const { assets } = updateData.release;
@@ -50,7 +51,7 @@ ipcMain.handle(IpcEvents.UPDATER_DOWNLOAD, () => {
shell.openExternal(url);
});
ipcMain.handle(IpcEvents.UPDATE_IGNORE, () => {
handle(IpcEvents.UPDATE_IGNORE, () => {
Settings.store.skippedUpdate = updateData.latestVersion;
});