added discord rpc

This commit is contained in:
2026-11-05 19:22:42 -08:00
parent a506a2efb4
commit ec5950b6ca
14 changed files with 640 additions and 10 deletions

10
main.js
View File

@@ -6,6 +6,7 @@ const ServiceManager = require('./service-manager');
const Patcher = require('./patcher');
const UpdateClient = require('./update-client');
const FileUpdater = require('./file-updater');
const VylaPresence = require('./discord-rpc');
function getDefaultAppData() {
if (process.platform === 'darwin') {
@@ -43,6 +44,12 @@ function sendToTauri(event, data) {
}
process.stdin.resume();
require('readline').createInterface({ input: process.stdin }).on('line', (line) => {
try {
const msg = JSON.parse(line);
if (msg && msg.type === 'presence') presence.report(msg.payload);
} catch (e) { }
});
process.stdin.on('end', () => {
debugLog('stdin closed - parent died. Self-terminating...');
process.exit(0);
@@ -88,6 +95,7 @@ function liveReposEnabled() {
}
const updateClient = new UpdateClient(APPDATA_DIR);
const presence = new VylaPresence({ getConfig: getEnvConfig, log: debugLog });
const fileUpdater = new FileUpdater(APPDATA_DIR, updateClient);
fileUpdater.onNotice = (message) => sendToTauri('notice', { message });
let lastFilePercent = -1;
@@ -436,6 +444,7 @@ async function start() {
throw new Error(`${e.message}. Check logs in ${LOGS_DIR}`);
}
debugLog("Ports 3000 and 4890 are ready.");
try { presence.start(); } catch (e) { debugLog(`Presence start failed: ${e.message}`); }
sendToTauri('status', { message: 'All backend services running and healthy.' });
debugLog("Sending READY to Tauri.");
@@ -448,6 +457,7 @@ async function start() {
}
process.on('exit', () => {
try { presence.stop(); } catch (e) { }
if (serviceManager) {
serviceManager.stopAll();
}