Compare commits
40 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1c308d0e2c | ||
|
|
7f6db5eeda | ||
|
|
10b38e5b41 | ||
|
|
28282d1d76 | ||
|
|
e1512b72f4 | ||
|
|
46a2314173 | ||
|
|
e6dc026708 | ||
|
|
cac307d1fc | ||
|
|
4b8f374856 | ||
|
|
e6cc11fc0e | ||
|
|
43ca479fc8 | ||
|
|
7b0f64a9fc | ||
|
|
573a953a2f | ||
|
|
841cdcf672 | ||
|
|
0d93e08e99 | ||
|
|
c445c6194f | ||
|
|
e29d293855 | ||
|
|
e13a4eacb1 | ||
|
|
c070761f9d | ||
|
|
ae86c28247 | ||
|
|
9c95956c96 | ||
|
|
45f56c63a0 | ||
|
|
89af4316d3 | ||
|
|
a9bfb857ae | ||
|
|
b9e411ac90 | ||
|
|
670de01938 | ||
|
|
ef064eba3d | ||
|
|
d5f63da939 | ||
|
|
2aadc61af9 | ||
|
|
061fec44af | ||
|
|
b876f450c3 | ||
|
|
5f5febda9d | ||
|
|
94ba59afb5 | ||
|
|
566737017c | ||
|
|
196ee4e42c | ||
|
|
9bb02f8581 | ||
|
|
c76d7195a5 | ||
|
|
50a103710d | ||
|
|
e6e66e775c | ||
|
|
a5ec031a2f |
@@ -4,3 +4,5 @@
|
||||
# all permissions at the defaults (public repos read only, 0 permissions):
|
||||
# https://github.com/settings/personal-access-tokens/new
|
||||
GITHUB_TOKEN=
|
||||
|
||||
ELECTRON_LAUNCH_FLAGS="--ozone-platform-hint=auto --enable-webrtc-pipewire-capturer --enable-features=WaylandWindowDecorations"
|
||||
25
.github/workflows/winget-submission.yml
vendored
Normal file
25
.github/workflows/winget-submission.yml
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
name: Submit to Winget Community Repo
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
tag:
|
||||
type: string
|
||||
description: The release tag to submit
|
||||
required: true
|
||||
|
||||
jobs:
|
||||
winget:
|
||||
name: Publish winget package
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Submit package to Winget Community Repo
|
||||
uses: vedantmgoyal2009/winget-releaser@e68d386d5d6a1cef8cb0fb5e62b77ebcb83e7d58 # v2
|
||||
with:
|
||||
identifier: Vencord.Vesktop
|
||||
token: ${{ secrets.WINGET_PAT }}
|
||||
installers-regex: '\.exe$'
|
||||
release-tag: ${{ inputs.tag || github.event.release.tag_name }}
|
||||
fork-user: shiggybot
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,3 +1,6 @@
|
||||
dist
|
||||
node_modules
|
||||
.env
|
||||
.DS_Store
|
||||
.idea/
|
||||
.pnpm-store/
|
||||
@@ -1,6 +1,6 @@
|
||||
# Vesktop
|
||||
|
||||
Vesktop is a cross platform desktop app aiming to give you a snappier Discord experience with Vencord pre-installed
|
||||
Vesktop is a cross platform desktop app aiming to give you a snappier Discord experience with [Vencord](https://github.com/Vendicated/Vencord) pre-installed
|
||||
|
||||
**Not yet supported**:
|
||||
- Global Keybinds
|
||||
|
||||
83
package.json
83
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "VencordDesktop",
|
||||
"version": "0.2.9",
|
||||
"version": "0.4.1",
|
||||
"private": true,
|
||||
"description": "",
|
||||
"keywords": [],
|
||||
@@ -23,32 +23,35 @@
|
||||
"watch": "pnpm build --watch"
|
||||
},
|
||||
"dependencies": {
|
||||
"arrpc": "github:OpenAsar/arrpc#b47fd7d498e248955c843a7857dd26478b82190a"
|
||||
"arrpc": "github:OpenAsar/arrpc#89f4da610ccfac93f461826a446a17cd3b23953d"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@vencord/venmic": "^1.4.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@fal-works/esbuild-plugin-global-externals": "^2.1.2",
|
||||
"@types/node": "^20.4.6",
|
||||
"@types/react": "^18.2.18",
|
||||
"@typescript-eslint/eslint-plugin": "^6.2.1",
|
||||
"@typescript-eslint/parser": "^6.2.1",
|
||||
"@types/node": "^20.8.4",
|
||||
"@types/react": "^18.2.28",
|
||||
"@typescript-eslint/eslint-plugin": "^6.7.5",
|
||||
"@typescript-eslint/parser": "^6.7.5",
|
||||
"@vencord/types": "^0.1.2",
|
||||
"dotenv": "^16.3.1",
|
||||
"electron": "^25.4.0",
|
||||
"electron-builder": "^24.6.3",
|
||||
"esbuild": "^0.18.17",
|
||||
"eslint": "^8.46.0",
|
||||
"eslint-config-prettier": "^8.9.0",
|
||||
"electron": "^27.0.0",
|
||||
"electron-builder": "^24.6.4",
|
||||
"esbuild": "^0.19.4",
|
||||
"eslint": "^8.51.0",
|
||||
"eslint-config-prettier": "^9.0.0",
|
||||
"eslint-import-resolver-alias": "^1.1.2",
|
||||
"eslint-plugin-license-header": "^0.6.0",
|
||||
"eslint-plugin-path-alias": "^1.0.0",
|
||||
"eslint-plugin-prettier": "^5.0.0",
|
||||
"eslint-plugin-prettier": "^5.0.1",
|
||||
"eslint-plugin-simple-import-sort": "^10.0.0",
|
||||
"eslint-plugin-unused-imports": "^3.0.0",
|
||||
"prettier": "^3.0.0",
|
||||
"prettier": "^3.0.3",
|
||||
"source-map-support": "^0.5.21",
|
||||
"tsx": "^3.12.7",
|
||||
"type-fest": "^4.1.0",
|
||||
"typescript": "^5.1.6"
|
||||
"tsx": "^3.13.0",
|
||||
"type-fest": "^4.4.0",
|
||||
"typescript": "^5.2.2"
|
||||
},
|
||||
"packageManager": "pnpm@8.6.11",
|
||||
"engines": {
|
||||
@@ -66,20 +69,47 @@
|
||||
"LICENSE"
|
||||
],
|
||||
"linux": {
|
||||
"icon": "build/icon.icns",
|
||||
"category": "Network",
|
||||
"maintainer": "vendicated+vesktop@riseup.net",
|
||||
"target": [
|
||||
"deb",
|
||||
"tar.gz",
|
||||
"rpm",
|
||||
"AppImage"
|
||||
{
|
||||
"target": "deb",
|
||||
"arch": [
|
||||
"x64",
|
||||
"arm64"
|
||||
]
|
||||
},
|
||||
{
|
||||
"target": "tar.gz",
|
||||
"arch": [
|
||||
"x64",
|
||||
"arm64"
|
||||
]
|
||||
},
|
||||
{
|
||||
"target": "rpm",
|
||||
"arch": [
|
||||
"x64",
|
||||
"arm64"
|
||||
]
|
||||
},
|
||||
{
|
||||
"target": "AppImage",
|
||||
"arch": [
|
||||
"x64",
|
||||
"arm64"
|
||||
]
|
||||
}
|
||||
],
|
||||
"desktop": {
|
||||
"Name": "Vesktop",
|
||||
"GenericName": "Internet Messenger",
|
||||
"Type": "Application",
|
||||
"Categories": "Network;InstantMessaging;Chat;",
|
||||
"Keywords": "discord;vencord;electron;chat;"
|
||||
"Keywords": "discord;vencord;electron;chat;",
|
||||
"WMClass": "VencordDesktop",
|
||||
"StartupWMClass": "VencordDesktop"
|
||||
}
|
||||
},
|
||||
"mac": {
|
||||
@@ -92,7 +122,13 @@
|
||||
]
|
||||
}
|
||||
],
|
||||
"category": "Network"
|
||||
"category": "Network",
|
||||
"extendInfo": {
|
||||
"NSMicrophoneUsageDescription": "This app needs access to the microphone",
|
||||
"NSCameraUsageDescription": "This app needs access to the camera",
|
||||
"com.apple.security.device.audio-input": true,
|
||||
"com.apple.security.device.camera": true
|
||||
}
|
||||
},
|
||||
"nsis": {
|
||||
"include": "build/installer.nsh",
|
||||
@@ -105,8 +141,7 @@
|
||||
]
|
||||
},
|
||||
"publish": {
|
||||
"provider": "github",
|
||||
"releaseType": "release"
|
||||
"provider": "github"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1575
pnpm-lock.yaml
generated
1575
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
import { BuildContext, BuildOptions, context } from "esbuild";
|
||||
import { copyFile } from "fs/promises";
|
||||
|
||||
import vencordDep from "./vencordDep.mjs";
|
||||
|
||||
@@ -34,6 +35,11 @@ async function createContext(options: BuildOptions) {
|
||||
}
|
||||
|
||||
await Promise.all([
|
||||
process.platform === "linux" &&
|
||||
copyFile(
|
||||
"./node_modules/@vencord/venmic/prebuilds/venmic-addon-linux-x64/node-napi-v7.node",
|
||||
"./static/dist/venmic.node"
|
||||
).catch(() => console.warn("Failed to copy venmic. Building without venmic support")),
|
||||
createContext({
|
||||
...NodeCommonOpts,
|
||||
entryPoints: ["src/main/index.ts"],
|
||||
@@ -65,11 +71,7 @@ await Promise.all([
|
||||
tsconfig: "./scripts/build/tsconfig.esbuild.json",
|
||||
external: ["@vencord/types/*"],
|
||||
plugins: [vencordDep],
|
||||
// TODO: remove legacy name once main Vencord codebase has migrated and some time has passed.
|
||||
// this 0 is very important. we run this script via webFrame.executeJavaScript and the last
|
||||
// expression will be the return value. Without the 0, the return value would be Vesktop which
|
||||
// leads to "An object could not be cloned"
|
||||
footer: { js: ";window.VencordDesktop=Vesktop;0 \n//# sourceURL=VCDRenderer" }
|
||||
footer: { js: "//# sourceURL=VCDRenderer" }
|
||||
})
|
||||
]);
|
||||
|
||||
|
||||
@@ -8,4 +8,4 @@ import "./utils/dotenv";
|
||||
|
||||
import { spawnNodeModuleBin } from "./utils/spawn.mjs";
|
||||
|
||||
spawnNodeModuleBin("electron", ["."]);
|
||||
spawnNodeModuleBin("electron", [".", ...(process.env.ELECTRON_LAUNCH_FLAGS?.split(" ") ?? [])]);
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
import Server from "arrpc";
|
||||
import { IpcEvents } from "shared/IpcEvents";
|
||||
|
||||
import { mainWin } from "./mainWindow";
|
||||
import { Settings } from "./settings";
|
||||
@@ -17,11 +18,8 @@ export async function initArRPC() {
|
||||
if (server || !Settings.store.arRPC) return;
|
||||
|
||||
try {
|
||||
// This module starts a server as a side effect, so it needs to be lazy imported
|
||||
const { send: sendToBridge } = await import("arrpc/src/bridge");
|
||||
|
||||
server = await new Server();
|
||||
server.on("activity", sendToBridge);
|
||||
server.on("activity", (data: any) => mainWin.webContents.send(IpcEvents.ARRPC_ACTIVITY, JSON.stringify(data)));
|
||||
server.on("invite", (invite: string, callback: (valid: boolean) => void) => {
|
||||
invite = String(invite);
|
||||
if (!inviteCodeRegex.test(invite)) return callback(false);
|
||||
|
||||
@@ -9,7 +9,7 @@ import { BrowserWindow } from "electron/main";
|
||||
import { copyFileSync, mkdirSync, readdirSync } from "fs";
|
||||
import { join } from "path";
|
||||
import { SplashProps } from "shared/browserWinProperties";
|
||||
import { VIEW_DIR } from "shared/paths";
|
||||
import { ICON_PATH, VIEW_DIR } from "shared/paths";
|
||||
|
||||
import { autoStart } from "./autoStart";
|
||||
import { DATA_DIR } from "./constants";
|
||||
@@ -31,7 +31,8 @@ export function createFirstLaunchTour() {
|
||||
frame: true,
|
||||
autoHideMenuBar: true,
|
||||
height: 470,
|
||||
width: 550
|
||||
width: 550,
|
||||
icon: ICON_PATH
|
||||
});
|
||||
|
||||
makeLinksOpenExternally(win);
|
||||
|
||||
@@ -12,6 +12,7 @@ import { checkUpdates } from "updater/main";
|
||||
import { DATA_DIR } from "./constants";
|
||||
import { createFirstLaunchTour } from "./firstLaunch";
|
||||
import { createWindows, mainWin } from "./mainWindow";
|
||||
import { registerMediaPermissionsHandler } from "./mediaPermissions";
|
||||
import { registerScreenShareHandler } from "./screenShare";
|
||||
import { Settings } from "./settings";
|
||||
|
||||
@@ -49,6 +50,8 @@ function init() {
|
||||
if (process.platform === "win32") app.setAppUserModelId("dev.vencord.desktop");
|
||||
|
||||
registerScreenShareHandler();
|
||||
registerMediaPermissionsHandler();
|
||||
|
||||
bootstrap();
|
||||
|
||||
app.on("activate", () => {
|
||||
|
||||
@@ -4,7 +4,10 @@
|
||||
* Copyright (c) 2023 Vendicated and Vencord contributors
|
||||
*/
|
||||
|
||||
import { app, dialog, ipcMain, session, shell } from "electron";
|
||||
if (process.platform === "linux") import("./virtmic");
|
||||
|
||||
import { execFile } from "child_process";
|
||||
import { app, BrowserWindow, dialog, RelaunchOptions, session, shell } from "electron";
|
||||
import { mkdirSync, readFileSync, watch } from "fs";
|
||||
import { open, readFile } from "fs/promises";
|
||||
import { release } from "os";
|
||||
@@ -17,71 +20,65 @@ 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 { handle, handleSync } from "./utils/ipcWrappers";
|
||||
import { isValidVencordInstall } from "./utils/vencordLoader";
|
||||
|
||||
ipcMain.on(IpcEvents.GET_VENCORD_PRELOAD_FILE, e => {
|
||||
e.returnValue = join(VENCORD_FILES_DIR, "vencordDesktopPreload.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, () => {
|
||||
app.relaunch();
|
||||
handle(IpcEvents.RELAUNCH, () => {
|
||||
const options: RelaunchOptions = {
|
||||
args: process.argv.slice(1).concat(["--relaunch"])
|
||||
};
|
||||
if (app.isPackaged && process.env.APPIMAGE) {
|
||||
execFile(process.env.APPIMAGE, options.args);
|
||||
} else {
|
||||
app.relaunch(options);
|
||||
}
|
||||
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 => {
|
||||
mainWin.close();
|
||||
handle(IpcEvents.CLOSE, e => {
|
||||
(BrowserWindow.fromWebContents(e.sender) ?? e.sender).close();
|
||||
});
|
||||
|
||||
ipcMain.handle(IpcEvents.MINIMIZE, e => {
|
||||
handle(IpcEvents.MINIMIZE, e => {
|
||||
mainWin.minimize();
|
||||
});
|
||||
|
||||
ipcMain.handle(IpcEvents.MAXIMIZE, e => {
|
||||
handle(IpcEvents.MAXIMIZE, e => {
|
||||
if (mainWin.isMaximized()) {
|
||||
mainWin.unmaximize();
|
||||
} else {
|
||||
@@ -89,7 +86,7 @@ ipcMain.handle(IpcEvents.MAXIMIZE, e => {
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.handle(IpcEvents.SPELLCHECK_SET_LANGUAGES, (_, languages: string[]) => {
|
||||
handle(IpcEvents.SPELLCHECK_SET_LANGUAGES, (_, languages: string[]) => {
|
||||
const ses = session.defaultSession;
|
||||
|
||||
const available = ses.availableSpellCheckerLanguages;
|
||||
@@ -97,15 +94,15 @@ 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"]
|
||||
});
|
||||
@@ -117,7 +114,7 @@ ipcMain.handle(IpcEvents.SELECT_VENCORD_DIR, async () => {
|
||||
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(() => "");
|
||||
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
dialog,
|
||||
Menu,
|
||||
MenuItemConstructorOptions,
|
||||
nativeTheme,
|
||||
Tray
|
||||
} from "electron";
|
||||
import { rm } from "fs/promises";
|
||||
@@ -147,6 +148,8 @@ async function clearData(win: BrowserWindow) {
|
||||
app.quit();
|
||||
}
|
||||
|
||||
type MenuItemList = Array<MenuItemConstructorOptions | false>;
|
||||
|
||||
function initMenuBar(win: BrowserWindow) {
|
||||
const isWindows = process.platform === "win32";
|
||||
const isDarwin = process.platform === "darwin";
|
||||
@@ -181,14 +184,38 @@ function initMenuBar(win: BrowserWindow) {
|
||||
app.quit();
|
||||
}
|
||||
},
|
||||
isDarwin && {
|
||||
label: "Hide",
|
||||
role: "hide"
|
||||
},
|
||||
isDarwin && {
|
||||
label: "Hide others",
|
||||
role: "hideOthers"
|
||||
},
|
||||
...(!isDarwin
|
||||
? []
|
||||
: ([
|
||||
{
|
||||
type: "separator"
|
||||
},
|
||||
{
|
||||
label: "Settings",
|
||||
accelerator: "CmdOrCtrl+,",
|
||||
async click() {
|
||||
mainWin.webContents.executeJavaScript(
|
||||
"Vencord.Webpack.Common.SettingsRouter.open('My Account')"
|
||||
);
|
||||
}
|
||||
},
|
||||
{
|
||||
type: "separator"
|
||||
},
|
||||
{
|
||||
label: "Hide Vesktop", // Should probably remove the label, but it says "Hide VencordDesktop" instead of "Hide Vesktop"
|
||||
role: "hide"
|
||||
},
|
||||
{
|
||||
role: "hideOthers"
|
||||
},
|
||||
{
|
||||
role: "unhide"
|
||||
},
|
||||
{
|
||||
type: "separator"
|
||||
}
|
||||
] satisfies MenuItemList)),
|
||||
{
|
||||
label: "Quit",
|
||||
accelerator: wantCtrlQ ? "CmdOrCtrl+Q" : void 0,
|
||||
@@ -213,7 +240,7 @@ function initMenuBar(win: BrowserWindow) {
|
||||
role: "zoomIn",
|
||||
visible: false
|
||||
}
|
||||
] satisfies Array<MenuItemConstructorOptions | false>;
|
||||
] satisfies MenuItemList;
|
||||
|
||||
const menu = Menu.buildFromTemplate([
|
||||
{
|
||||
@@ -251,6 +278,28 @@ function getWindowBoundsOptions(): BrowserWindowConstructorOptions {
|
||||
return options;
|
||||
}
|
||||
|
||||
function getDarwinOptions(): BrowserWindowConstructorOptions {
|
||||
const options = {
|
||||
titleBarStyle: "hiddenInset"
|
||||
} as BrowserWindowConstructorOptions;
|
||||
|
||||
const { splashTheming, splashBackground } = Settings.store;
|
||||
const { macosTranslucency } = VencordSettings.store;
|
||||
|
||||
if (macosTranslucency) {
|
||||
options.vibrancy = "sidebar";
|
||||
options.backgroundColor = "#ffffff00";
|
||||
} else {
|
||||
if (splashTheming) {
|
||||
options.backgroundColor = splashBackground;
|
||||
} else {
|
||||
options.backgroundColor = nativeTheme.shouldUseDarkColors ? "#313338" : "#ffffff";
|
||||
}
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
function initWindowBoundsListeners(win: BrowserWindow) {
|
||||
const saveState = () => {
|
||||
Settings.store.maximized = win.isMaximized();
|
||||
@@ -316,7 +365,8 @@ function createMainWindow() {
|
||||
removeVencordSettingsListeners();
|
||||
|
||||
const { staticTitle, transparencyOption, enableMenu, discordWindowsTitleBar } = Settings.store;
|
||||
const { frameless, macosTranslucency } = VencordSettings.store;
|
||||
|
||||
const { frameless } = VencordSettings.store;
|
||||
|
||||
const noFrame = frameless === true || (process.platform === "win32" && discordWindowsTitleBar === true);
|
||||
|
||||
@@ -332,21 +382,14 @@ function createMainWindow() {
|
||||
},
|
||||
icon: ICON_PATH,
|
||||
frame: !noFrame,
|
||||
...(transparencyOption && transparencyOption !== "none"
|
||||
? {
|
||||
backgroundColor: "#00000000",
|
||||
backgroundMaterial: Settings.store.transparencyOption,
|
||||
transparent: true
|
||||
}
|
||||
: {}),
|
||||
...(staticTitle ? { title: "Vesktop" } : {}),
|
||||
...(macosTranslucency
|
||||
? {
|
||||
vibrancy: "sidebar",
|
||||
backgroundColor: "#ffffff00"
|
||||
}
|
||||
: {}),
|
||||
...(process.platform === "darwin" ? { titleBarStyle: "hiddenInset" } : {}),
|
||||
...(transparencyOption &&
|
||||
transparencyOption !== "none" && {
|
||||
backgroundColor: "#00000000",
|
||||
backgroundMaterial: transparencyOption,
|
||||
transparent: true
|
||||
}),
|
||||
...(staticTitle && { title: "Vesktop" }),
|
||||
...(process.platform === "darwin" && getDarwinOptions()),
|
||||
...getWindowBoundsOptions(),
|
||||
autoHideMenuBar: enableMenu
|
||||
}));
|
||||
|
||||
24
src/main/mediaPermissions.ts
Normal file
24
src/main/mediaPermissions.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* 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 { session, systemPreferences } from "electron";
|
||||
|
||||
export function registerMediaPermissionsHandler() {
|
||||
if (process.platform !== "darwin") return;
|
||||
|
||||
session.defaultSession.setPermissionRequestHandler(async (_webContents, permission, callback, details) => {
|
||||
let granted = true;
|
||||
|
||||
if (details.mediaTypes?.includes("audio")) {
|
||||
granted = await systemPreferences.askForMediaAccess("microphone");
|
||||
}
|
||||
if (details.mediaTypes?.includes("video")) {
|
||||
granted &&= await systemPreferences.askForMediaAccess("camera");
|
||||
}
|
||||
|
||||
callback(granted);
|
||||
});
|
||||
}
|
||||
@@ -4,12 +4,17 @@
|
||||
* 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";
|
||||
|
||||
const isWayland =
|
||||
process.platform === "linux" && (process.env.XDG_SESSION_TYPE === "wayland" || !!process.env.WAYLAND_DISPLAY);
|
||||
|
||||
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: {
|
||||
@@ -21,17 +26,19 @@ export function registerScreenShareHandler() {
|
||||
});
|
||||
|
||||
session.defaultSession.setDisplayMediaRequestHandler(async (request, callback) => {
|
||||
const sources = await desktopCapturer.getSources({
|
||||
types: ["window", "screen"],
|
||||
thumbnailSize: {
|
||||
width: 176,
|
||||
height: 99
|
||||
}
|
||||
});
|
||||
// request full resolution on wayland right away because we always only end up with one result anyway
|
||||
const width = isWayland ? 1920 : 176;
|
||||
const sources = await desktopCapturer
|
||||
.getSources({
|
||||
types: ["window", "screen"],
|
||||
thumbnailSize: {
|
||||
width,
|
||||
height: width * (9 / 16)
|
||||
}
|
||||
})
|
||||
.catch(err => console.error("Error during screenshare picker", err));
|
||||
|
||||
const isWayland =
|
||||
process.platform === "linux" &&
|
||||
(process.env.XDG_SESSION_TYPE === "wayland" || !!process.env.WAYLAND_DISPLAY);
|
||||
if (!sources) return callback({});
|
||||
|
||||
const data = sources.map(({ id, name, thumbnail }) => ({
|
||||
id,
|
||||
@@ -41,14 +48,26 @@ export function registerScreenShareHandler() {
|
||||
|
||||
if (isWayland) {
|
||||
const video = data[0];
|
||||
callback(video ? { video } : {});
|
||||
if (video) {
|
||||
const stream = await request.frame
|
||||
.executeJavaScript(
|
||||
`Vesktop.Components.ScreenShare.openScreenSharePicker(${JSON.stringify([video])},true)`
|
||||
)
|
||||
.catch(() => null);
|
||||
if (stream === null) return callback({});
|
||||
}
|
||||
|
||||
callback(video ? { video: sources[0] } : {});
|
||||
return;
|
||||
}
|
||||
|
||||
const choice = await request.frame
|
||||
.executeJavaScript(`Vesktop.Components.ScreenShare.openScreenSharePicker(${JSON.stringify(data)})`)
|
||||
.then(e => e as StreamPick)
|
||||
.catch(() => null);
|
||||
.catch(e => {
|
||||
console.error("Error during screenshare picker", e);
|
||||
return null;
|
||||
});
|
||||
|
||||
if (!choice) return callback({});
|
||||
|
||||
|
||||
@@ -7,12 +7,32 @@
|
||||
import { BrowserWindow } from "electron";
|
||||
import { join } from "path";
|
||||
import { SplashProps } from "shared/browserWinProperties";
|
||||
import { VIEW_DIR } from "shared/paths";
|
||||
import { ICON_PATH, VIEW_DIR } from "shared/paths";
|
||||
|
||||
import { Settings } from "./settings";
|
||||
|
||||
export function createSplashWindow() {
|
||||
const splash = new BrowserWindow(SplashProps);
|
||||
const splash = new BrowserWindow({
|
||||
...SplashProps,
|
||||
icon: ICON_PATH
|
||||
});
|
||||
|
||||
splash.loadFile(join(VIEW_DIR, "splash.html"));
|
||||
|
||||
const { splashBackground, splashColor, splashTheming } = Settings.store;
|
||||
|
||||
if (splashTheming) {
|
||||
if (splashColor) {
|
||||
const semiTransparentSplashColor = splashColor.replace("rgb(", "rgba(").replace(")", ", 0.2)");
|
||||
|
||||
splash.webContents.insertCSS(`body { --fg: ${splashColor} !important }`);
|
||||
splash.webContents.insertCSS(`body { --fg-semi-trans: ${semiTransparentSplashColor} !important }`);
|
||||
}
|
||||
|
||||
if (splashBackground) {
|
||||
splash.webContents.insertCSS(`body { --bg: ${splashBackground} !important }`);
|
||||
}
|
||||
}
|
||||
|
||||
return splash;
|
||||
}
|
||||
|
||||
36
src/main/utils/ipcWrappers.ts
Normal file
36
src/main/utils/ipcWrappers.ts
Normal 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);
|
||||
});
|
||||
}
|
||||
69
src/main/virtmic.ts
Normal file
69
src/main/virtmic.ts
Normal file
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* 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 { app, ipcMain } from "electron";
|
||||
import { join } from "path";
|
||||
import { IpcEvents } from "shared/IpcEvents";
|
||||
import { STATIC_DIR } from "shared/paths";
|
||||
|
||||
let initialized = false;
|
||||
let patchBay: import("@vencord/venmic").PatchBay | undefined;
|
||||
|
||||
function getRendererAudioServicePid() {
|
||||
return (
|
||||
app
|
||||
.getAppMetrics()
|
||||
.find(proc => proc.name === "Audio Service")
|
||||
?.pid?.toString() ?? "owo"
|
||||
);
|
||||
}
|
||||
|
||||
function obtainVenmic() {
|
||||
if (!initialized) {
|
||||
initialized = true;
|
||||
try {
|
||||
const { PatchBay } = require(join(STATIC_DIR, "dist/venmic.node")) as typeof import("@vencord/venmic");
|
||||
patchBay = new PatchBay();
|
||||
} catch (e) {
|
||||
console.error("Failed to initialise venmic. Make sure you're using pipewire", e);
|
||||
}
|
||||
}
|
||||
|
||||
return patchBay;
|
||||
}
|
||||
|
||||
ipcMain.handle(IpcEvents.VIRT_MIC_LIST, () => {
|
||||
const audioPid = getRendererAudioServicePid();
|
||||
const list = obtainVenmic()
|
||||
?.list()
|
||||
.filter(s => s["application.process.id"] !== audioPid)
|
||||
.map(s => s["application.name"]);
|
||||
|
||||
// Remove duplicates
|
||||
return list && [...new Set(list)];
|
||||
});
|
||||
|
||||
ipcMain.handle(
|
||||
IpcEvents.VIRT_MIC_START,
|
||||
(_, target: string) =>
|
||||
obtainVenmic()?.link({
|
||||
key: "application.name",
|
||||
value: target,
|
||||
mode: "include"
|
||||
})
|
||||
);
|
||||
|
||||
ipcMain.handle(
|
||||
IpcEvents.VIRT_MIC_START_SYSTEM,
|
||||
() =>
|
||||
obtainVenmic()?.link({
|
||||
key: "application.process.id",
|
||||
value: getRendererAudioServicePid(),
|
||||
mode: "exclude"
|
||||
})
|
||||
);
|
||||
|
||||
ipcMain.handle(IpcEvents.VIRT_MIC_STOP, () => obtainVenmic()?.unlink());
|
||||
@@ -58,5 +58,17 @@ export const VesktopNative = {
|
||||
},
|
||||
capturer: {
|
||||
getLargeThumbnail: (id: string) => invoke<string>(IpcEvents.CAPTURER_GET_LARGE_THUMBNAIL, id)
|
||||
},
|
||||
/** only available on Linux. */
|
||||
virtmic: {
|
||||
list: () => invoke<string[] | null>(IpcEvents.VIRT_MIC_LIST),
|
||||
start: (target: string) => invoke<void>(IpcEvents.VIRT_MIC_START, target),
|
||||
startSystem: () => invoke<void>(IpcEvents.VIRT_MIC_START_SYSTEM),
|
||||
stop: () => invoke<void>(IpcEvents.VIRT_MIC_STOP)
|
||||
},
|
||||
arrpc: {
|
||||
onActivity(cb: (data: string) => void) {
|
||||
ipcRenderer.on(IpcEvents.ARRPC_ACTIVITY, (_, data: string) => cb(data));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -11,8 +11,6 @@ import { IpcEvents } from "../shared/IpcEvents";
|
||||
import { VesktopNative } from "./VesktopNative";
|
||||
|
||||
contextBridge.exposeInMainWorld("VesktopNative", VesktopNative);
|
||||
// TODO: remove legacy alias once main Vencord codebase has migrated and some time has passed
|
||||
contextBridge.exposeInMainWorld("VencordDesktopNative", VesktopNative);
|
||||
|
||||
require(ipcRenderer.sendSync(IpcEvents.GET_VENCORD_PRELOAD_FILE));
|
||||
|
||||
|
||||
@@ -15,15 +15,19 @@ let NotificationSettingsStore: any;
|
||||
export function setBadge() {
|
||||
if (Settings.store.appBadge === false) return;
|
||||
|
||||
const mentionCount = GuildReadStateStore.getTotalMentionCount();
|
||||
const pendingRequests = RelationshipStore.getPendingCount();
|
||||
const hasUnread = GuildReadStateStore.hasAnyUnread();
|
||||
const disableUnreadBadge = NotificationSettingsStore.getDisableUnreadBadge();
|
||||
try {
|
||||
const mentionCount = GuildReadStateStore.getTotalMentionCount();
|
||||
const pendingRequests = RelationshipStore.getPendingCount();
|
||||
const hasUnread = GuildReadStateStore.hasAnyUnread();
|
||||
const disableUnreadBadge = NotificationSettingsStore.getDisableUnreadBadge();
|
||||
|
||||
let totalCount = mentionCount + pendingRequests;
|
||||
if (!totalCount && hasUnread && !disableUnreadBadge) totalCount = -1;
|
||||
let totalCount = mentionCount + pendingRequests;
|
||||
if (!totalCount && hasUnread && !disableUnreadBadge) totalCount = -1;
|
||||
|
||||
VesktopNative.app.setBadgeCount(totalCount);
|
||||
VesktopNative.app.setBadgeCount(totalCount);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
let toFind = 3;
|
||||
|
||||
@@ -7,11 +7,21 @@
|
||||
import "./screenSharePicker.css";
|
||||
|
||||
import { closeModal, Modals, openModal, useAwaiter } from "@vencord/types/utils";
|
||||
import { findStoreLazy } from "@vencord/types/webpack";
|
||||
import { Button, Card, Forms, Switch, Text, useState } from "@vencord/types/webpack/common";
|
||||
import { findStoreLazy, onceReady } from "@vencord/types/webpack";
|
||||
import {
|
||||
Button,
|
||||
Card,
|
||||
FluxDispatcher,
|
||||
Forms,
|
||||
Select,
|
||||
Switch,
|
||||
Text,
|
||||
UserStore,
|
||||
useState
|
||||
} from "@vencord/types/webpack/common";
|
||||
import type { Dispatch, SetStateAction } from "react";
|
||||
import { addPatch } from "renderer/patches/shared";
|
||||
import { isWindows } from "renderer/utils";
|
||||
import { isLinux, isWindows } from "renderer/utils";
|
||||
|
||||
const StreamResolutions = ["480", "720", "1080", "1440"] as const;
|
||||
const StreamFps = ["15", "30", "60"] as const;
|
||||
@@ -25,6 +35,7 @@ interface StreamSettings {
|
||||
resolution: StreamResolution;
|
||||
fps: StreamFps;
|
||||
audio: boolean;
|
||||
audioSource?: string;
|
||||
}
|
||||
|
||||
export interface StreamPick extends StreamSettings {
|
||||
@@ -70,18 +81,41 @@ addPatch({
|
||||
}
|
||||
});
|
||||
|
||||
export function openScreenSharePicker(screens: Source[]) {
|
||||
if (isLinux) {
|
||||
onceReady.then(() => {
|
||||
FluxDispatcher.subscribe("VOICE_STATE_UPDATES", e => {
|
||||
for (const state of e.voiceStates) {
|
||||
if (state.userId === UserStore.getCurrentUser().id && state.oldChannelId && !state.channelId)
|
||||
VesktopNative.virtmic.stop();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function openScreenSharePicker(screens: Source[], skipPicker: boolean) {
|
||||
let didSubmit = false;
|
||||
return new Promise<StreamPick>((resolve, reject) => {
|
||||
const key = openModal(
|
||||
props => (
|
||||
<ModalComponent
|
||||
screens={screens}
|
||||
modalProps={props}
|
||||
submit={resolve}
|
||||
submit={async v => {
|
||||
didSubmit = true;
|
||||
if (v.audioSource && v.audioSource !== "None") {
|
||||
if (v.audioSource === "Entire System") {
|
||||
await VesktopNative.virtmic.startSystem();
|
||||
} else {
|
||||
await VesktopNative.virtmic.start(v.audioSource);
|
||||
}
|
||||
}
|
||||
resolve(v);
|
||||
}}
|
||||
close={() => {
|
||||
props.onClose();
|
||||
reject("Aborted");
|
||||
if (!didSubmit) reject("Aborted");
|
||||
}}
|
||||
skipPicker={skipPicker}
|
||||
/>
|
||||
),
|
||||
{
|
||||
@@ -112,16 +146,21 @@ function ScreenPicker({ screens, chooseScreen }: { screens: Source[]; chooseScre
|
||||
function StreamSettings({
|
||||
source,
|
||||
settings,
|
||||
setSettings
|
||||
setSettings,
|
||||
skipPicker
|
||||
}: {
|
||||
source: Source;
|
||||
settings: StreamSettings;
|
||||
setSettings: Dispatch<SetStateAction<StreamSettings>>;
|
||||
skipPicker: boolean;
|
||||
}) {
|
||||
const [thumb] = useAwaiter(() => VesktopNative.capturer.getLargeThumbnail(source.id), {
|
||||
fallbackValue: source.url,
|
||||
deps: [source.id]
|
||||
});
|
||||
const [thumb] = useAwaiter(
|
||||
() => (skipPicker ? Promise.resolve(source.url) : VesktopNative.capturer.getLargeThumbnail(source.id)),
|
||||
{
|
||||
fallbackValue: source.url,
|
||||
deps: [source.id]
|
||||
}
|
||||
);
|
||||
|
||||
return (
|
||||
<div>
|
||||
@@ -182,23 +221,65 @@ function StreamSettings({
|
||||
Stream With Audio
|
||||
</Switch>
|
||||
)}
|
||||
|
||||
{isLinux && (
|
||||
<AudioSourcePickerLinux
|
||||
audioSource={settings.audioSource}
|
||||
setAudioSource={source => setSettings(s => ({ ...s, audioSource: source }))}
|
||||
/>
|
||||
)}
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function AudioSourcePickerLinux({
|
||||
audioSource,
|
||||
setAudioSource
|
||||
}: {
|
||||
audioSource?: string;
|
||||
setAudioSource(s: string): void;
|
||||
}) {
|
||||
const [sources, _, loading] = useAwaiter(() => VesktopNative.virtmic.list(), { fallbackValue: [] });
|
||||
const allSources = sources ? ["None", "Entire System", ...sources] : null;
|
||||
|
||||
return (
|
||||
<section>
|
||||
<Forms.FormTitle>Audio</Forms.FormTitle>
|
||||
{loading && <Forms.FormTitle>Loading Audio sources...</Forms.FormTitle>}
|
||||
{allSources === null && (
|
||||
<Forms.FormTitle>
|
||||
Failed to retrieve Audio Sources. If you would like to stream with Audio, make sure you're using
|
||||
Pipewire, not Pulseaudio
|
||||
</Forms.FormTitle>
|
||||
)}
|
||||
|
||||
{allSources && (
|
||||
<Select
|
||||
options={allSources.map(s => ({ label: s, value: s, default: s === "None" }))}
|
||||
isSelected={s => s === audioSource}
|
||||
select={setAudioSource}
|
||||
serialize={String}
|
||||
/>
|
||||
)}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
function ModalComponent({
|
||||
screens,
|
||||
modalProps,
|
||||
submit,
|
||||
close
|
||||
close,
|
||||
skipPicker
|
||||
}: {
|
||||
screens: Source[];
|
||||
modalProps: any;
|
||||
submit: (data: StreamPick) => void;
|
||||
close: () => void;
|
||||
skipPicker: boolean;
|
||||
}) {
|
||||
const [selected, setSelected] = useState<string>();
|
||||
const [selected, setSelected] = useState<string | undefined>(skipPicker ? screens[0].id : void 0);
|
||||
const [settings, setSettings] = useState<StreamSettings>({
|
||||
resolution: "1080",
|
||||
fps: "60",
|
||||
@@ -220,6 +301,7 @@ function ModalComponent({
|
||||
source={screens.find(s => s.id === selected)!}
|
||||
settings={settings}
|
||||
setSettings={setSettings}
|
||||
skipPicker={skipPicker}
|
||||
/>
|
||||
)}
|
||||
</Modals.ModalContent>
|
||||
@@ -259,7 +341,7 @@ function ModalComponent({
|
||||
Go Live
|
||||
</Button>
|
||||
|
||||
{selected ? (
|
||||
{selected && !skipPicker ? (
|
||||
<Button color={Button.Colors.TRANSPARENT} onClick={() => setSelected(void 0)}>
|
||||
Back
|
||||
</Button>
|
||||
|
||||
@@ -42,11 +42,13 @@ export default function SettingsUi() {
|
||||
],
|
||||
["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."],
|
||||
["splashTheming", "Splash theming", "Adapt the splash window colors to your custom theme", false],
|
||||
[
|
||||
"openLinksWithElectron",
|
||||
"Open Links in app (experimental)",
|
||||
"Opens links in a new Vesktop window instead of your web browser"
|
||||
]
|
||||
],
|
||||
["checkUpdates", "Check for updates", "Automatically check for Vesktop updates", true]
|
||||
];
|
||||
|
||||
const switches = allSwitches.filter(isTruthy);
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
import "./fixes";
|
||||
import "./appBadge";
|
||||
import "./patches";
|
||||
import "./themedSplash";
|
||||
|
||||
console.log("read if cute :3");
|
||||
|
||||
@@ -14,6 +15,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,14 +37,23 @@ export async function openInviteModal(code: string) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const arRPC = Vencord.Plugins.plugins["WebRichPresence (arRPC)"];
|
||||
const customSettingsSections = (
|
||||
Vencord.Plugins.plugins.Settings as any as { customSections: ((ID: Record<string, unknown>) => any)[] }
|
||||
).customSections;
|
||||
|
||||
arRPC.required = !!Settings.store.arRPC;
|
||||
customSettingsSections.push(() => ({
|
||||
section: "Vesktop",
|
||||
label: "Vesktop Settings",
|
||||
element: SettingsUi,
|
||||
className: "vc-vesktop-settings"
|
||||
}));
|
||||
|
||||
Settings.addChangeListener("arRPC", v => {
|
||||
arRPC.required = !!v;
|
||||
if (v && !arRPC.started) Vencord.Plugins.startPlugin(arRPC);
|
||||
else if (arRPC.started) {
|
||||
Vencord.Plugins.stopPlugin(arRPC);
|
||||
}
|
||||
const arRPC = Vencord.Plugins.plugins["WebRichPresence (arRPC)"] as any as {
|
||||
handleEvent(e: MessageEvent): void;
|
||||
};
|
||||
|
||||
VesktopNative.arrpc.onActivity(data => {
|
||||
if (!Settings.store.arRPC) return;
|
||||
|
||||
arRPC.handleEvent(new MessageEvent("message", { data }));
|
||||
});
|
||||
|
||||
@@ -8,3 +8,4 @@
|
||||
import "./spellCheck";
|
||||
import "./platformClass";
|
||||
import "./windowsTitleBar";
|
||||
import "./screenShareAudio";
|
||||
|
||||
@@ -23,7 +23,7 @@ addPatch({
|
||||
|
||||
getPlatformClass() {
|
||||
if (isMac) return "platform-osx";
|
||||
if (isWindows && Settings.store.discordWindowsTitleBar) return "platform-windows";
|
||||
if (isWindows && Settings.store.discordWindowsTitleBar) return "platform-win";
|
||||
return "platform-web";
|
||||
}
|
||||
});
|
||||
|
||||
42
src/renderer/patches/screenShareAudio.ts
Normal file
42
src/renderer/patches/screenShareAudio.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* 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 { isLinux } from "renderer/utils";
|
||||
|
||||
if (isLinux) {
|
||||
const original = navigator.mediaDevices.getDisplayMedia;
|
||||
|
||||
async function getVirtmic() {
|
||||
try {
|
||||
const devices = await navigator.mediaDevices.enumerateDevices();
|
||||
const audioDevice = devices.find(({ label }) => label === "vencord-screen-share");
|
||||
return audioDevice?.deviceId;
|
||||
} catch (error) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
navigator.mediaDevices.getDisplayMedia = async function (opts) {
|
||||
const stream = await original.call(this, opts);
|
||||
const id = await getVirtmic();
|
||||
|
||||
if (id) {
|
||||
const audio = await navigator.mediaDevices.getUserMedia({
|
||||
audio: {
|
||||
deviceId: {
|
||||
exact: id
|
||||
},
|
||||
autoGainControl: false,
|
||||
echoCancellation: false,
|
||||
noiseSuppression: false
|
||||
}
|
||||
});
|
||||
audio.getAudioTracks().forEach(t => stream.addTrack(t));
|
||||
}
|
||||
|
||||
return stream;
|
||||
};
|
||||
}
|
||||
@@ -21,7 +21,7 @@ if (Settings.store.discordWindowsTitleBar)
|
||||
replace: 'case "WEB":'
|
||||
},
|
||||
...["close", "minimize", "maximize"].map(op => ({
|
||||
match: new RegExp(String.raw`\i\.default\.${op}\b`),
|
||||
match: new RegExp(String.raw`\i\.\i\.${op}\b`),
|
||||
replace: `VesktopNative.win.${op}`
|
||||
}))
|
||||
]
|
||||
|
||||
46
src/renderer/themedSplash.ts
Normal file
46
src/renderer/themedSplash.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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 "./settings";
|
||||
|
||||
function isValidColor(color: CSSStyleValue | undefined): color is CSSUnparsedValue & { [0]: string } {
|
||||
return color instanceof CSSUnparsedValue && typeof color[0] === "string" && CSS.supports("color", color[0]);
|
||||
}
|
||||
|
||||
function resolveColor(color: string) {
|
||||
const span = document.createElement("span");
|
||||
span.style.color = color;
|
||||
span.style.display = "none";
|
||||
|
||||
document.body.append(span);
|
||||
const rgbColor = getComputedStyle(span).color;
|
||||
span.remove();
|
||||
|
||||
return rgbColor;
|
||||
}
|
||||
|
||||
const updateSplashColors = () => {
|
||||
const bodyStyles = document.body.computedStyleMap();
|
||||
|
||||
const color = bodyStyles.get("--text-normal");
|
||||
const backgroundColor = bodyStyles.get("--background-primary");
|
||||
|
||||
if (isValidColor(color)) {
|
||||
Settings.store.splashColor = resolveColor(color[0]);
|
||||
}
|
||||
|
||||
if (isValidColor(backgroundColor)) {
|
||||
Settings.store.splashBackground = resolveColor(backgroundColor[0]);
|
||||
}
|
||||
};
|
||||
|
||||
if (document.readyState === "complete") {
|
||||
updateSplashColors();
|
||||
} else {
|
||||
window.addEventListener("load", updateSplashColors);
|
||||
}
|
||||
|
||||
window.addEventListener("beforeunload", updateSplashColors);
|
||||
@@ -17,3 +17,4 @@ const { platform } = navigator;
|
||||
|
||||
export const isWindows = platform.startsWith("Win");
|
||||
export const isMac = platform.startsWith("Mac");
|
||||
export const isLinux = platform.startsWith("Linux");
|
||||
|
||||
@@ -40,5 +40,12 @@ export const enum IpcEvents {
|
||||
|
||||
AUTOSTART_ENABLED = "VCD_AUTOSTART_ENABLED",
|
||||
ENABLE_AUTOSTART = "VCD_ENABLE_AUTOSTART",
|
||||
DISABLE_AUTOSTART = "VCD_DISABLE_AUTOSTART"
|
||||
DISABLE_AUTOSTART = "VCD_DISABLE_AUTOSTART",
|
||||
|
||||
VIRT_MIC_LIST = "VCD_VIRT_MIC_LIST",
|
||||
VIRT_MIC_START = "VCD_VIRT_MIC_START",
|
||||
VIRT_MIC_START_SYSTEM = "VCD_VIRT_MIC_START_ALL",
|
||||
VIRT_MIC_STOP = "VCD_VIRT_MIC_STOP",
|
||||
|
||||
ARRPC_ACTIVITY = "VCD_ARRPC_ACTIVITY"
|
||||
}
|
||||
|
||||
5
src/shared/settings.d.ts
vendored
5
src/shared/settings.d.ts
vendored
@@ -24,6 +24,11 @@ export interface Settings {
|
||||
windowBounds?: Rectangle;
|
||||
disableMinSize?: boolean;
|
||||
|
||||
checkUpdates?: boolean;
|
||||
skippedUpdate?: string;
|
||||
firstLaunch?: boolean;
|
||||
|
||||
splashTheming?: boolean;
|
||||
splashColor?: string;
|
||||
splashBackground?: string;
|
||||
}
|
||||
|
||||
@@ -4,13 +4,14 @@
|
||||
* 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";
|
||||
import { IpcEvents } from "shared/IpcEvents";
|
||||
import { VIEW_DIR } from "shared/paths";
|
||||
import { ICON_PATH, VIEW_DIR } from "shared/paths";
|
||||
|
||||
export interface UpdateData {
|
||||
currentVersion: string;
|
||||
@@ -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;
|
||||
});
|
||||
|
||||
@@ -76,7 +77,8 @@ function isOutdated(oldVersion: string, newVersion: string) {
|
||||
}
|
||||
|
||||
export async function checkUpdates() {
|
||||
// if (IS_DEV) return;
|
||||
if (Settings.store.checkUpdates === false) return;
|
||||
|
||||
try {
|
||||
const raw = await githubGet("/repos/Vencord/Vesktop/releases/latest");
|
||||
const data = JSON.parse(raw.toString("utf-8")) as ReleaseData;
|
||||
@@ -107,7 +109,8 @@ function openNewUpdateWindow() {
|
||||
nodeIntegration: false,
|
||||
contextIsolation: true,
|
||||
sandbox: true
|
||||
}
|
||||
},
|
||||
icon: ICON_PATH
|
||||
});
|
||||
|
||||
makeLinksOpenExternally(win);
|
||||
|
||||
2
static/dist/.gitignore
vendored
Normal file
2
static/dist/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
||||
BIN
static/shiggy.gif
Normal file
BIN
static/shiggy.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
@@ -51,6 +51,10 @@
|
||||
<a href="https://github.com/OpenAsar/arrpc" target="_blank">arrpc</a>
|
||||
- An open implementation of Discord's Rich Presence server
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://github.com/Soundux/rohrkabel" target="_blank">rohrkabel</a>
|
||||
- A C++ RAII Pipewire-API Wrapper
|
||||
</li>
|
||||
<li>
|
||||
And many
|
||||
<a href="https://github.com/Vencord/Vesktop/blob/main/pnpm-lock.yaml" target="_blank"
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
<div class="wrapper">
|
||||
<img
|
||||
draggable="false"
|
||||
src="https://cdn.discordapp.com/emojis/1024751291504791654.gif?size=512"
|
||||
src="../shiggy.gif"
|
||||
alt="shiggy"
|
||||
role="presentation"
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user