Add arRPC integration

This commit is contained in:
V 2023-06-09 22:47:59 +02:00
parent aae4223294
commit 39cc30de53
No known key found for this signature in database
GPG key ID: A1DC0CFB5615D905
7 changed files with 75 additions and 6 deletions

View file

@ -82,11 +82,11 @@
"mac": {
"target": [
{
"target": "default",
"arch": [
"x64",
"arm64"
]
"target": "default",
"arch": [
"x64",
"arm64"
]
}
],
"category": "Network"
@ -105,5 +105,8 @@
"provider": "github",
"releaseType": "release"
}
},
"dependencies": {
"arrpc": "^3.1.0"
}
}

View file

@ -1,5 +1,10 @@
lockfileVersion: '6.0'
dependencies:
arrpc:
specifier: ^3.1.0
version: 3.1.0
devDependencies:
'@fal-works/esbuild-plugin-global-externals':
specifier: ^2.1.2
@ -889,6 +894,15 @@ packages:
es-shim-unscopables: 1.0.0
dev: true
/arrpc@3.1.0:
resolution: {integrity: sha512-QKagtB5fUDqDXT31tTUzcG3+rFxsMlrjKb3iE68/b2NbT1c6+0WYkkrJh4GaVPqH0Tlqy13sEgPW3XJ/VNmBDQ==}
dependencies:
ws: 8.13.0
transitivePeerDependencies:
- bufferutil
- utf-8-validate
dev: false
/asar@3.2.0:
resolution: {integrity: sha512-COdw2ZQvKdFGFxXwX3oYh2/sOsJWJegrdJCGxnN4MZ7IULgRBp9P6665aqj9z1v9VwP4oP1hRBojRDQ//IGgAg==}
engines: {node: '>=10.12.0'}
@ -3785,6 +3799,19 @@ packages:
resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==}
dev: true
/ws@8.13.0:
resolution: {integrity: sha512-x9vcZYTrFPC7aSIbj7sRCYo7L/Xb8Iy+pW0ng0wt2vCJv7M9HOMy0UoN3rr+IFC7hb7vXoqS+P9ktyLLLhO+LA==}
engines: {node: '>=10.0.0'}
peerDependencies:
bufferutil: ^4.0.1
utf-8-validate: '>=5.0.2'
peerDependenciesMeta:
bufferutil:
optional: true
utf-8-validate:
optional: true
dev: false
/xmlbuilder@15.1.1:
resolution: {integrity: sha512-yMqGBqtXyeN1e3TGYvgNgDVZ3j84W4cwkOXQswghol6APgZWaff9lnbvN7MHYJOiXsvGPXtjTYJEiC9J2wv9Eg==}
engines: {node: '>=8.0'}

21
src/main/arrpc.ts Normal file
View file

@ -0,0 +1,21 @@
/*
* SPDX-License-Identifier: GPL-3.0
* Vencord Desktop, a desktop app aiming to give you a snappier Discord Experience
* Copyright (c) 2023 Vendicated and Vencord contributors
*/
import Server from "arrpc";
import { send as sendToBridge } from "arrpc/src/bridge";
import { Settings } from "./settings";
let server: any;
export async function initArRPC() {
if (server || !Settings.store.arRPC) return;
server = await new Server();
server.on("activity", sendToBridge);
}
Settings.addChangeListener("arRPC", initArRPC);

View file

@ -12,6 +12,7 @@ import { checkUpdates } from "updater/main";
import { ICON_PATH } from "../shared/paths";
import { once } from "../shared/utils/once";
import { initArRPC } from "./arrpc";
import { DATA_DIR, VENCORD_FILES_DIR } from "./constants";
import { createMainWindow } from "./mainWindow";
import { Settings } from "./settings";
@ -94,6 +95,8 @@ async function createWindows() {
mainWin!.maximize();
}
});
initArRPC();
}
app.on("window-all-closed", () => {

View file

@ -22,6 +22,7 @@ export default function SettingsUi() {
true,
() => Settings.tray ?? true
],
["arRPC", "Rich Presence", "Enables Rich Presence via arRPC", false],
[
"disableMinSize",
"Disable minimum window size",

View file

@ -9,4 +9,17 @@ import "./fixes";
console.log("read if cute :3");
export * as Components from "./components";
export { Settings } from "./settings";
import { Settings } from "./settings";
export { Settings };
const arRPC = Vencord.Plugins.plugins["WebRichPresence (arRPC)"];
arRPC.required = !!Settings.store.arRPC;
Settings.addChangeListener("arRPC", v => {
arRPC.required = !!v;
if (v && !arRPC.started) Vencord.Plugins.startPlugin(arRPC);
else if (arRPC.started) {
Vencord.Plugins.stopPlugin(arRPC);
}
});

View file

@ -18,4 +18,5 @@ export interface Settings {
minimizeToTray?: boolean;
skippedUpdate?: string;
staticTitle?: boolean;
arRPC?: boolean;
}