From 9e3d83a2ee3a05cf84040e84ef53252ae7e29a96 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Sat, 29 Jun 2024 12:36:49 +0200 Subject: [PATCH 1/8] build: arm64 on windows, universal on mac --- package.json | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 67571bd..91554bc 100644 --- a/package.json +++ b/package.json @@ -118,8 +118,7 @@ { "target": "default", "arch": [ - "x64", - "arm64" + "universal" ] } ], @@ -158,8 +157,20 @@ }, "win": { "target": [ - "nsis", - "zip" + { + "target": "nsis", + "arch": [ + "x64", + "arm64" + ] + }, + { + "target": "zip", + "arch": [ + "x64", + "arm64" + ] + } ] }, "publish": { From 5d5b38b259fda7020238d91541c1f0a725b85f35 Mon Sep 17 00:00:00 2001 From: Lionir Date: Wed, 3 Jul 2024 21:34:17 -0400 Subject: [PATCH 2/8] meta: Use Network category instead of AudioVideo (#721) --- meta/dev.vencord.Vesktop.metainfo.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/meta/dev.vencord.Vesktop.metainfo.xml b/meta/dev.vencord.Vesktop.metainfo.xml index 889b9fc..2c94c9e 100644 --- a/meta/dev.vencord.Vesktop.metainfo.xml +++ b/meta/dev.vencord.Vesktop.metainfo.xml @@ -182,7 +182,7 @@ https://github.com/Vencord/Vesktop InstantMessaging - AudioVideo + Network pointing @@ -208,4 +208,4 @@ Privacy Mod - \ No newline at end of file + From 9c44da0cae00bb251add45aec1d089e67e7d1e9c Mon Sep 17 00:00:00 2001 From: Vendicated Date: Thu, 4 Jul 2024 17:46:41 +0200 Subject: [PATCH 3/8] update workflow actions --- .github/workflows/meta.yml | 42 +++++++++++++++++------------------ .github/workflows/release.yml | 12 +++++----- .github/workflows/test.yml | 10 ++++----- 3 files changed, 32 insertions(+), 32 deletions(-) diff --git a/.github/workflows/meta.yml b/.github/workflows/meta.yml index 5287c23..2ebc5a3 100644 --- a/.github/workflows/meta.yml +++ b/.github/workflows/meta.yml @@ -11,28 +11,28 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: pnpm/action-setup@v2 # Install pnpm using packageManager key in package.json + - uses: actions/checkout@v4 + - uses: pnpm/action-setup@v4 # Install pnpm using packageManager key in package.json - - name: Use Node.js 18.18.2 - uses: actions/setup-node@v3 - with: - node-version: 18.18.2 + - name: Use Node.js 20 + uses: actions/setup-node@v4 + with: + node-version: 20 - - name: Install dependencies - run: pnpm i + - name: Install dependencies + run: pnpm i - - name: Update metainfo - run: pnpm updateMeta + - name: Update metainfo + run: pnpm updateMeta - - name: Commit and merge in changes - run: | - git config user.name "github-actions[bot]" - git config user.email "41898282+github-actions[bot]@users.noreply.github.com" - git checkout -b ci/meta-update - git add meta/dev.vencord.Vesktop.metainfo.xml - git commit -m "Insert release changes for ${{ github.event.release.tag_name }}" - git push origin ci/meta-update - gh pr create -B main -H ci/meta-update -t "Metainfo for ${{ github.event.release.tag_name }}" -b "This PR updates the metainfo for release ${{ github.event.release.tag_name }}. @lewisakura @Vendicated" - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + - name: Commit and merge in changes + run: | + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git checkout -b ci/meta-update + git add meta/dev.vencord.Vesktop.metainfo.xml + git commit -m "Insert release changes for ${{ github.event.release.tag_name }}" + git push origin ci/meta-update + gh pr create -B main -H ci/meta-update -t "Metainfo for ${{ github.event.release.tag_name }}" -b "This PR updates the metainfo for release ${{ github.event.release.tag_name }}. @lewisakura @Vendicated" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6968b73..9de1bc5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -22,13 +22,13 @@ jobs: platform: windows steps: - - uses: actions/checkout@v3 - - uses: pnpm/action-setup@v2 # Install pnpm using packageManager key in package.json + - uses: actions/checkout@v4 + - uses: pnpm/action-setup@v4 # Install pnpm using packageManager key in package.json - - name: Use Node.js 18.18.2 - uses: actions/setup-node@v3 + - name: Use Node.js 20 + uses: actions/setup-node@v4 with: - node-version: 18.18.2 + node-version: 20 cache: "pnpm" - name: Install dependencies @@ -43,7 +43,7 @@ jobs: pnpm electron-builder --${{ matrix.platform }} --publish always env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - + - name: Run Electron Builder if: ${{ matrix.platform == 'mac' }} run: | diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6d88280..daa62a5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,13 +11,13 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: pnpm/action-setup@v2 # Install pnpm using packageManager key in package.json + - uses: actions/checkout@v4 + - uses: pnpm/action-setup@v4 # Install pnpm using packageManager key in package.json - - name: Use Node.js 18.18.2 - uses: actions/setup-node@v3 + - name: Use Node.js 20 + uses: actions/setup-node@v4 with: - node-version: 18.18.2 + node-version: 20 cache: "pnpm" - name: Install dependencies From 05014f747ac4786936bd0da0b46029f26454d70b Mon Sep 17 00:00:00 2001 From: Vendicated Date: Thu, 4 Jul 2024 17:54:38 +0200 Subject: [PATCH 4/8] fix incorrectly packaging node_modules --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 91554bc..7e45ce0 100644 --- a/package.json +++ b/package.json @@ -65,6 +65,7 @@ "productName": "Vesktop", "files": [ "!*", + "!node_modules", "dist/js", "static", "package.json", From ec3d83f7ca398dff3e0db5d2c8b0578e71117850 Mon Sep 17 00:00:00 2001 From: kittykel <95729061+kittykel@users.noreply.github.com> Date: Thu, 4 Jul 2024 09:04:57 -0700 Subject: [PATCH 5/8] fix: specify framerate in constraints (#703) --- src/renderer/components/ScreenSharePicker.tsx | 2 +- src/renderer/patches/screenShareFixes.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/renderer/components/ScreenSharePicker.tsx b/src/renderer/components/ScreenSharePicker.tsx index e0cff77..c7403b9 100644 --- a/src/renderer/components/ScreenSharePicker.tsx +++ b/src/renderer/components/ScreenSharePicker.tsx @@ -721,7 +721,7 @@ function ModalComponent({ const constraints = { ...track.getConstraints(), - frameRate, + frameRate: { min: frameRate, ideal: frameRate }, width: { min: 640, ideal: width, max: width }, height: { min: 480, ideal: height, max: height }, advanced: [{ width: width, height: height }], diff --git a/src/renderer/patches/screenShareFixes.ts b/src/renderer/patches/screenShareFixes.ts index 66e4b14..00487d3 100644 --- a/src/renderer/patches/screenShareFixes.ts +++ b/src/renderer/patches/screenShareFixes.ts @@ -36,7 +36,7 @@ if (isLinux) { const constraints = { ...track.getConstraints(), - frameRate, + frameRate: { min: frameRate, ideal: frameRate }, width: { min: 640, ideal: width, max: width }, height: { min: 480, ideal: height, max: height }, advanced: [{ width: width, height: height }], From 1f12d270ec94a6e78dd1a0ae4f0511e1ddfb0e83 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Thu, 4 Jul 2024 18:40:04 +0200 Subject: [PATCH 6/8] fix potential sandbox escape via custom vencordDir --- src/main/constants.ts | 6 ++-- src/main/ipc.ts | 16 +++++++++-- src/main/utils/vencordLoader.ts | 15 +++++++--- src/preload/VesktopNative.ts | 4 +-- .../settings/VencordLocationPicker.tsx | 28 ++++++++++++++----- src/renderer/index.ts | 18 +++++++++++- src/shared/IpcEvents.ts | 1 + src/shared/settings.d.ts | 3 +- src/shared/utils/SettingsStore.ts | 13 +++++++++ 9 files changed, 84 insertions(+), 20 deletions(-) diff --git a/src/main/constants.ts b/src/main/constants.ts index 1bce303..78f9187 100644 --- a/src/main/constants.ts +++ b/src/main/constants.ts @@ -37,7 +37,8 @@ if (existsSync(LEGACY_DATA_DIR)) { console.error("Migration failed", e); } } -app.setPath("sessionData", join(DATA_DIR, "sessionData")); +const SESSION_DATA_DIR = join(DATA_DIR, "sessionData"); +app.setPath("sessionData", SESSION_DATA_DIR); export const VENCORD_SETTINGS_DIR = join(DATA_DIR, "settings"); export const VENCORD_QUICKCSS_FILE = join(VENCORD_SETTINGS_DIR, "quickCss.css"); @@ -47,7 +48,8 @@ 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 export const VENCORD_FILES_DIR = - (require("./settings") as typeof import("./settings")).Settings.store.vencordDir || join(DATA_DIR, "vencordDist"); + (require("./settings") as typeof import("./settings")).State.store.vencordDir || + join(SESSION_DATA_DIR, "vencordFiles"); export const USER_AGENT = `Vesktop/${app.getVersion()} (https://github.com/Vencord/Vesktop)`; diff --git a/src/main/ipc.ts b/src/main/ipc.ts index 3404d34..70b461b 100644 --- a/src/main/ipc.ts +++ b/src/main/ipc.ts @@ -19,7 +19,7 @@ import { setBadgeCount } from "./appBadge"; import { autoStart } from "./autoStart"; import { VENCORD_FILES_DIR, VENCORD_QUICKCSS_FILE, VENCORD_THEMES_DIR } from "./constants"; import { mainWin } from "./mainWindow"; -import { Settings } from "./settings"; +import { Settings, State } from "./settings"; import { handle, handleSync } from "./utils/ipcWrappers"; import { PopoutWindows } from "./utils/popout"; import { isDeckGameMode, showGamePage } from "./utils/steamOS"; @@ -105,7 +105,15 @@ handle(IpcEvents.SPELLCHECK_ADD_TO_DICTIONARY, (e, word: string) => { e.sender.session.addWordToSpellCheckerDictionary(word); }); -handle(IpcEvents.SELECT_VENCORD_DIR, async () => { +handleSync(IpcEvents.GET_VENCORD_DIR, e => (e.returnValue = State.store.vencordDir)); + +handle(IpcEvents.SELECT_VENCORD_DIR, async (_e, value?: null) => { + console.log(value); + if (value === null) { + delete State.store.vencordDir; + return "ok"; + } + const res = await dialog.showOpenDialog(mainWin!, { properties: ["openDirectory"] }); @@ -114,7 +122,9 @@ handle(IpcEvents.SELECT_VENCORD_DIR, async () => { const dir = res.filePaths[0]; if (!isValidVencordInstall(dir)) return "invalid"; - return dir; + State.store.vencordDir = dir; + + return "ok"; }); handle(IpcEvents.SET_BADGE_COUNT, (_, count: number) => setBadgeCount(count)); diff --git a/src/main/utils/vencordLoader.ts b/src/main/utils/vencordLoader.ts index 1bac37a..c0bac6a 100644 --- a/src/main/utils/vencordLoader.ts +++ b/src/main/utils/vencordLoader.ts @@ -4,7 +4,8 @@ * Copyright (c) 2023 Vendicated and Vencord contributors */ -import { existsSync, mkdirSync } from "fs"; +import { mkdirSync } from "fs"; +import { access, constants as FsConstants } from "fs/promises"; import { join } from "path"; import { USER_AGENT, VENCORD_FILES_DIR } from "../constants"; @@ -56,12 +57,18 @@ export async function downloadVencordFiles() { ); } -export function isValidVencordInstall(dir: string) { - return FILES_TO_DOWNLOAD.every(f => existsSync(join(dir, f))); +const existsAsync = (path: string) => + access(path, FsConstants.F_OK) + .then(() => true) + .catch(() => false); + +export async function isValidVencordInstall(dir: string) { + return Promise.all(FILES_TO_DOWNLOAD.map(f => existsAsync(join(dir, f)))).then(arr => !arr.includes(false)); } export async function ensureVencordFiles() { - if (isValidVencordInstall(VENCORD_FILES_DIR)) return; + if (await isValidVencordInstall(VENCORD_FILES_DIR)) return; + mkdirSync(VENCORD_FILES_DIR, { recursive: true }); await downloadVencordFiles(); diff --git a/src/preload/VesktopNative.ts b/src/preload/VesktopNative.ts index c8fc13f..7a8b977 100644 --- a/src/preload/VesktopNative.ts +++ b/src/preload/VesktopNative.ts @@ -7,7 +7,6 @@ import { Node } from "@vencord/venmic"; import { ipcRenderer } from "electron"; import type { Settings } from "shared/settings"; -import type { LiteralUnion } from "type-fest"; import { IpcEvents } from "../shared/IpcEvents"; import { invoke, sendSync } from "./typedIpc"; @@ -34,7 +33,8 @@ export const VesktopNative = { }, fileManager: { showItemInFolder: (path: string) => invoke(IpcEvents.SHOW_ITEM_IN_FOLDER, path), - selectVencordDir: () => invoke>(IpcEvents.SELECT_VENCORD_DIR) + getVencordDir: () => sendSync(IpcEvents.GET_VENCORD_DIR), + selectVencordDir: (value?: null) => invoke<"cancelled" | "invalid" | "ok">(IpcEvents.SELECT_VENCORD_DIR, value) }, settings: { get: () => sendSync(IpcEvents.GET_SETTINGS), diff --git a/src/renderer/components/settings/VencordLocationPicker.tsx b/src/renderer/components/settings/VencordLocationPicker.tsx index 3759ae2..9af4711 100644 --- a/src/renderer/components/settings/VencordLocationPicker.tsx +++ b/src/renderer/components/settings/VencordLocationPicker.tsx @@ -4,24 +4,28 @@ * Copyright (c) 2023 Vendicated and Vencord contributors */ +import { useForceUpdater } from "@vencord/types/utils"; import { Button, Forms, Toasts } from "@vencord/types/webpack/common"; import { SettingsComponent } from "./Settings"; export const VencordLocationPicker: SettingsComponent = ({ settings }) => { + const forceUpdate = useForceUpdater(); + const vencordDir = VesktopNative.fileManager.getVencordDir(); + return ( <> Vencord files are loaded from{" "} - {settings.vencordDir ? ( + {vencordDir ? ( { e.preventDefault(); - VesktopNative.fileManager.showItemInFolder(settings.vencordDir!); + VesktopNative.fileManager.showItemInFolder(vencordDir!); }} > - {settings.vencordDir} + {vencordDir} ) : ( "the default location" @@ -34,7 +38,14 @@ export const VencordLocationPicker: SettingsComponent = ({ settings }) => { const choice = await VesktopNative.fileManager.selectVencordDir(); switch (choice) { case "cancelled": - return; + break; + case "ok": + Toasts.show({ + message: "Vencord install changed. Fully restart Vesktop to apply.", + id: Toasts.genId(), + type: Toasts.Type.SUCCESS + }); + break; case "invalid": Toasts.show({ message: @@ -42,9 +53,9 @@ export const VencordLocationPicker: SettingsComponent = ({ settings }) => { id: Toasts.genId(), type: Toasts.Type.FAILURE }); - return; + break; } - settings.vencordDir = choice; + forceUpdate(); }} > Change @@ -52,7 +63,10 @@ export const VencordLocationPicker: SettingsComponent = ({ settings }) => { diff --git a/src/renderer/index.ts b/src/renderer/index.ts index 99dca25..a708962 100644 --- a/src/renderer/index.ts +++ b/src/renderer/index.ts @@ -13,7 +13,7 @@ console.log("read if cute :3"); export * as Components from "./components"; import { findByPropsLazy, onceReady } from "@vencord/types/webpack"; -import { FluxDispatcher } from "@vencord/types/webpack/common"; +import { Alerts, FluxDispatcher } from "@vencord/types/webpack/common"; import SettingsUi from "./components/settings/Settings"; import { Settings } from "./settings"; @@ -59,3 +59,19 @@ VesktopNative.arrpc.onActivity(async data => { arRPC.handleEvent(new MessageEvent("message", { data })); }); + +// TODO: remove soon +const vencordDir = "vencordDir" as keyof typeof Settings.store; +if (Settings.store[vencordDir]) { + onceReady.then(() => + setTimeout( + () => + Alerts.show({ + title: "Custom Vencord Location", + body: "Due to changes in Vesktop, your custom Vencord location had to bee reset. Please set it again in the settings.", + onConfirm: () => delete Settings.store[vencordDir] + }), + 5000 + ) + ); +} diff --git a/src/shared/IpcEvents.ts b/src/shared/IpcEvents.ts index ea632fb..51d2a28 100644 --- a/src/shared/IpcEvents.ts +++ b/src/shared/IpcEvents.ts @@ -23,6 +23,7 @@ export const enum IpcEvents { GET_SETTINGS = "VCD_GET_SETTINGS", SET_SETTINGS = "VCD_SET_SETTINGS", + GET_VENCORD_DIR = "VCD_GET_VENCORD_DIR", SELECT_VENCORD_DIR = "VCD_SELECT_VENCORD_DIR", UPDATER_GET_DATA = "VCD_UPDATER_GET_DATA", diff --git a/src/shared/settings.d.ts b/src/shared/settings.d.ts index 3eb96a0..ae19668 100644 --- a/src/shared/settings.d.ts +++ b/src/shared/settings.d.ts @@ -8,7 +8,6 @@ import type { Rectangle } from "electron"; export interface Settings { discordBranch?: "stable" | "canary" | "ptb"; - vencordDir?: string; transparencyOption?: "none" | "mica" | "tabbed" | "acrylic"; tray?: boolean; minimizeToTray?: boolean; @@ -54,4 +53,6 @@ export interface State { firstLaunch?: boolean; steamOSLayoutVersion?: number; + + vencordDir?: string; } diff --git a/src/shared/utils/SettingsStore.ts b/src/shared/utils/SettingsStore.ts index 22dd145..6aa7771 100644 --- a/src/shared/utils/SettingsStore.ts +++ b/src/shared/utils/SettingsStore.ts @@ -59,6 +59,19 @@ export class SettingsStore { self.pathListeners.get(setPath)?.forEach(cb => cb(value)); return true; + }, + deleteProperty(target, key: string) { + if (!(key in target)) return true; + + const res = Reflect.deleteProperty(target, key); + if (!res) return false; + + const setPath = `${path}${path && "."}${key}`; + + self.globalListeners.forEach(cb => cb(root, setPath)); + self.pathListeners.get(setPath)?.forEach(cb => cb(undefined)); + + return res; } }); } From 0d203ac21d60599eb278f35245be72623a905978 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Thu, 4 Jul 2024 18:41:03 +0200 Subject: [PATCH 7/8] remove silly console.log --- src/main/ipc.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/ipc.ts b/src/main/ipc.ts index 70b461b..4fa662c 100644 --- a/src/main/ipc.ts +++ b/src/main/ipc.ts @@ -108,7 +108,6 @@ handle(IpcEvents.SPELLCHECK_ADD_TO_DICTIONARY, (e, word: string) => { handleSync(IpcEvents.GET_VENCORD_DIR, e => (e.returnValue = State.store.vencordDir)); handle(IpcEvents.SELECT_VENCORD_DIR, async (_e, value?: null) => { - console.log(value); if (value === null) { delete State.store.vencordDir; return "ok"; From f341c5e5bb440df0756280efd9cde580f7179bce Mon Sep 17 00:00:00 2001 From: Vendicated Date: Thu, 4 Jul 2024 18:47:33 +0200 Subject: [PATCH 8/8] specify that it's for security so users don't get annoyed --- src/renderer/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/renderer/index.ts b/src/renderer/index.ts index a708962..e8ad31c 100644 --- a/src/renderer/index.ts +++ b/src/renderer/index.ts @@ -68,7 +68,7 @@ if (Settings.store[vencordDir]) { () => Alerts.show({ title: "Custom Vencord Location", - body: "Due to changes in Vesktop, your custom Vencord location had to bee reset. Please set it again in the settings.", + body: "Due to security hardening changes in Vesktop, your custom Vencord location had to be reset. Please configure it again in the settings.", onConfirm: () => delete Settings.store[vencordDir] }), 5000