diff --git a/patches/arrpc@3.5.0.patch b/patches/arrpc@3.5.0.patch index 8dfd9f64..90ceb427 100644 --- a/patches/arrpc@3.5.0.patch +++ b/patches/arrpc@3.5.0.patch @@ -1,14 +1,50 @@ diff --git a/src/process/index.js b/src/process/index.js -index 97ea6514b54dd9c5df588c78f0397d31ab5f882a..c2bdbd6aaa5611bc6ff1d993beeb380b1f5ec575 100644 +index 97ea651..29e964e 100644 --- a/src/process/index.js +++ b/src/process/index.js -@@ -5,8 +5,7 @@ import fs from 'node:fs'; - import { dirname, join } from 'path'; - import { fileURLToPath } from 'url'; +@@ -1,12 +1,7 @@ + const rgb = (r, g, b, msg) => `\x1b[38;2;${r};${g};${b}m${msg}\x1b[0m`; + const log = (...args) => console.log(`[${rgb(88, 101, 242, 'arRPC')} > ${rgb(237, 66, 69, 'process')}]`, ...args); +-import fs from 'node:fs'; +-import { dirname, join } from 'path'; +-import { fileURLToPath } from 'url'; +- -const __dirname = dirname(fileURLToPath(import.meta.url)); -const DetectableDB = JSON.parse(fs.readFileSync(join(__dirname, 'detectable.json'), 'utf8')); +const DetectableDB = require('./detectable.json'); import * as Natives from './native/index.js'; const Native = Natives[process.platform]; +diff --git a/update_db.js b/update_db.js +index ed94923..24deace 100644 +--- a/update_db.js ++++ b/update_db.js +@@ -1,5 +1,5 @@ + #!/usr/bin/env node +-import { createWriteStream, readFileSync } from 'fs'; ++import { createWriteStream, readFileSync, writeFileSync } from 'fs'; + import { get } from 'https'; + + import { dirname, join } from 'path'; +@@ -25,5 +25,19 @@ get('https://discord.com/api/v9/applications/detectable', res => { + const oldNames = current.map(x => x.name); + const newNames = updated.map(x => x.name); + console.log(newNames.filter(x => !oldNames.includes(x))); ++ ++ // append obs for auto streammode ++ updated.push({ ++ aliases: ["Obs"], ++ executables: [ ++ { is_launcher: false, name: "obs", os: "linux" }, ++ { is_launcher: false, name: "obs.exe", os: "win32" }, ++ { is_launcher: false, name: "obs.app", os: "darwin" } ++ ], ++ hook: true, ++ id: "STREAMERMODE", ++ name: "OBS" ++ }); ++ writeFileSync(path, JSON.stringify(updated), 'utf8'); + }) + }); +\ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 18e57ff2..1462ba1a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -6,7 +6,7 @@ settings: patchedDependencies: arrpc@3.5.0: - hash: biyukfa6dww2wxujy4eyvkhrti + hash: 5y62pyz5uz22dpw2tkbo3xeuo4 path: patches/arrpc@3.5.0.patch importers: @@ -15,7 +15,7 @@ importers: dependencies: arrpc: specifier: github:OpenAsar/arrpc#5aadc307cb9bf4479f0a12364a253b07a77ace22 - version: https://codeload.github.com/OpenAsar/arrpc/tar.gz/5aadc307cb9bf4479f0a12364a253b07a77ace22(patch_hash=biyukfa6dww2wxujy4eyvkhrti) + version: https://codeload.github.com/OpenAsar/arrpc/tar.gz/5aadc307cb9bf4479f0a12364a253b07a77ace22(patch_hash=5y62pyz5uz22dpw2tkbo3xeuo4) electron-updater: specifier: ^6.3.4 version: 6.3.4 @@ -3214,7 +3214,7 @@ snapshots: app-builder-bin@5.0.0-alpha.7: {} - app-builder-lib@25.0.5(dmg-builder@25.0.5(electron-builder-squirrel-windows@25.0.5(dmg-builder@25.0.5)))(electron-builder-squirrel-windows@25.0.5(dmg-builder@25.0.5)): + app-builder-lib@25.0.5(dmg-builder@25.0.5(electron-builder-squirrel-windows@25.0.5))(electron-builder-squirrel-windows@25.0.5(dmg-builder@25.0.5)): dependencies: '@develar/schema-utils': 2.6.5 '@electron/notarize': 2.3.2 @@ -3229,7 +3229,7 @@ snapshots: builder-util-runtime: 9.2.5 chromium-pickle-js: 0.2.0 debug: 4.3.7 - dmg-builder: 25.0.5(electron-builder-squirrel-windows@25.0.5(dmg-builder@25.0.5)) + dmg-builder: 25.0.5(electron-builder-squirrel-windows@25.0.5) ejs: 3.1.10 electron-builder-squirrel-windows: 25.0.5(dmg-builder@25.0.5) electron-publish: 25.0.3 @@ -3350,7 +3350,7 @@ snapshots: is-array-buffer: 3.0.4 is-shared-array-buffer: 1.0.3 - arrpc@https://codeload.github.com/OpenAsar/arrpc/tar.gz/5aadc307cb9bf4479f0a12364a253b07a77ace22(patch_hash=biyukfa6dww2wxujy4eyvkhrti): + arrpc@https://codeload.github.com/OpenAsar/arrpc/tar.gz/5aadc307cb9bf4479f0a12364a253b07a77ace22(patch_hash=5y62pyz5uz22dpw2tkbo3xeuo4): dependencies: ws: 8.18.0 transitivePeerDependencies: @@ -3744,9 +3744,9 @@ snapshots: '@types/react': 17.0.2 moment: 2.30.1 - dmg-builder@25.0.5(electron-builder-squirrel-windows@25.0.5(dmg-builder@25.0.5)): + dmg-builder@25.0.5(electron-builder-squirrel-windows@25.0.5): dependencies: - app-builder-lib: 25.0.5(dmg-builder@25.0.5(electron-builder-squirrel-windows@25.0.5(dmg-builder@25.0.5)))(electron-builder-squirrel-windows@25.0.5(dmg-builder@25.0.5)) + app-builder-lib: 25.0.5(dmg-builder@25.0.5(electron-builder-squirrel-windows@25.0.5))(electron-builder-squirrel-windows@25.0.5(dmg-builder@25.0.5)) builder-util: 25.0.3 builder-util-runtime: 9.2.5 fs-extra: 10.1.0 @@ -3789,7 +3789,7 @@ snapshots: electron-builder-squirrel-windows@25.0.5(dmg-builder@25.0.5): dependencies: - app-builder-lib: 25.0.5(dmg-builder@25.0.5(electron-builder-squirrel-windows@25.0.5(dmg-builder@25.0.5)))(electron-builder-squirrel-windows@25.0.5(dmg-builder@25.0.5)) + app-builder-lib: 25.0.5(dmg-builder@25.0.5(electron-builder-squirrel-windows@25.0.5))(electron-builder-squirrel-windows@25.0.5(dmg-builder@25.0.5)) archiver: 5.3.2 builder-util: 25.0.3 fs-extra: 10.1.0 @@ -3800,11 +3800,11 @@ snapshots: electron-builder@25.0.5(electron-builder-squirrel-windows@25.0.5(dmg-builder@25.0.5)): dependencies: - app-builder-lib: 25.0.5(dmg-builder@25.0.5(electron-builder-squirrel-windows@25.0.5(dmg-builder@25.0.5)))(electron-builder-squirrel-windows@25.0.5(dmg-builder@25.0.5)) + app-builder-lib: 25.0.5(dmg-builder@25.0.5(electron-builder-squirrel-windows@25.0.5))(electron-builder-squirrel-windows@25.0.5(dmg-builder@25.0.5)) builder-util: 25.0.3 builder-util-runtime: 9.2.5 chalk: 4.1.2 - dmg-builder: 25.0.5(electron-builder-squirrel-windows@25.0.5(dmg-builder@25.0.5)) + dmg-builder: 25.0.5(electron-builder-squirrel-windows@25.0.5) fs-extra: 10.1.0 is-ci: 3.0.1 lazy-val: 1.0.5 diff --git a/scripts/build/build.mts b/scripts/build/build.mts index 243381ba..ebb40d0b 100644 --- a/scripts/build/build.mts +++ b/scripts/build/build.mts @@ -4,6 +4,7 @@ * Copyright (c) 2023 Vendicated and Vencord contributors */ +import { execSync } from "child_process"; import { BuildContext, BuildOptions, context } from "esbuild"; import { copyFile } from "fs/promises"; @@ -49,8 +50,15 @@ async function copyVenmic() { ]).catch(() => console.warn("Failed to copy venmic. Building without venmic support")); } +async function updateArrpcDb() { + return Promise.all([execSync("node node_modules/arrpc/update_db.js")]).catch(() => + console.warn("Error running update_db.js Auto streamermode will not work.") + ); +} + await Promise.all([ copyVenmic(), + updateArrpcDb(), createContext({ ...NodeCommonOpts, entryPoints: ["src/main/index.ts"], diff --git a/src/renderer/index.ts b/src/renderer/index.ts index e8ad31ca..9af3b216 100644 --- a/src/renderer/index.ts +++ b/src/renderer/index.ts @@ -12,7 +12,7 @@ import "./themedSplash"; console.log("read if cute :3"); export * as Components from "./components"; -import { findByPropsLazy, onceReady } from "@vencord/types/webpack"; +import { findByPropsLazy, findStore, onceReady } from "@vencord/types/webpack"; import { Alerts, FluxDispatcher } from "@vencord/types/webpack/common"; import SettingsUi from "./components/settings/Settings"; @@ -56,8 +56,14 @@ VesktopNative.arrpc.onActivity(async data => { if (!Settings.store.arRPC) return; await onceReady; - - arRPC.handleEvent(new MessageEvent("message", { data })); + const StreamerModeStore = findStore("StreamerModeStore"); + if (JSON.parse(data).socketId === "STREAMERMODE" && StreamerModeStore.autoToggle) { + FluxDispatcher.dispatch({ + type: "STREAMER_MODE_UPDATE", + key: "enabled", + value: JSON.parse(data).activity?.application_id === "STREAMERMODE" + }); + } else arRPC.handleEvent(new MessageEvent("message", { data })); }); // TODO: remove soon diff --git a/src/renderer/patches/index.ts b/src/renderer/patches/index.ts index aabff3e0..6e5c9129 100644 --- a/src/renderer/patches/index.ts +++ b/src/renderer/patches/index.ts @@ -12,3 +12,4 @@ import "./hideVenmicInput"; import "./screenShareFixes"; import "./spellCheck"; import "./windowsTitleBar"; +import "./streamerMode"; diff --git a/src/renderer/patches/streamerMode.ts b/src/renderer/patches/streamerMode.ts new file mode 100644 index 00000000..10bcc845 --- /dev/null +++ b/src/renderer/patches/streamerMode.ts @@ -0,0 +1,20 @@ +/* + * 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 { addPatch } from "./shared"; + +addPatch({ + patches: [ + { + find: ".STREAMER_MODE_ENABLE,", + replacement: { + // eslint-disable-next-line no-useless-escape + match: /\i\.isPlatformEmbedded/g, + replace: "true" + } + } + ] +});