feat(desktop): port v0.11.4-v0.15.2 from Tauri to Electron + Discord-parity audio (v0.16.0)

Chronological port of every Tauri release commit (v0.11.4 -> v0.15.2)
into the Electron rebuild, plus Discord-style audio handling that goes
beyond the Tauri original.

Highlights:
  - All 17 Tauri release commits ported (audio fixes, custom notification
    sound, Discord-style chat UX, profile banner, changelog page,
    Discord-parity call UX, screen-share echo + re-watch UX, audio-loop
    fix).
  - Native napi-rs audio-loopback addon with WASAPI process-loopback:
      * EXCLUDE_TARGET_PROCESS_TREE for full-screen shares -> peers
        never hear themselves echoed back through the capture.
      * INCLUDE_TARGET_PROCESS_TREE for window shares -> only the
        picked window's audio is captured, not the whole OS mixer
        (Discord parity).
      * HWND -> PID resolution via Win32 GetWindowThreadProcessId.
  - Discord-style screen-source picker (thumbnail grid, screens vs
    apps tabs, live-refreshing thumbnails).
  - Hash routing fix for packaged builds (file:// can't resolve
    BrowserRouter paths).
  - Tauri sources removed (apps/desktop/src-tauri).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
byGalax
2026-05-06 23:35:01 +02:00
parent 72d02e385f
commit 825160ee46
504 changed files with 14217 additions and 14366 deletions
@@ -0,0 +1,86 @@
// Global shortcuts — wraps Electron's globalShortcut, tracks registrations
// by an opaque renderer-supplied id so the same accelerator can be
// re-bound without the caller juggling state.
//
// PTT semantics are simulated: Electron's globalShortcut API only delivers
// a "pressed" callback — it has no keyup / release event. We fire
// SHORTCUT_EVT_FIRED on press, then after a 200ms timer fire
// SHORTCUT_EVT_RELEASED. Known limitation; TODO: revisit with
// `uiohook-napi` or `node-global-key-listener` if the press-and-release
// UX is too loose.
import { app, BrowserWindow, globalShortcut, ipcMain } from 'electron';
import {
CHANNELS,
type ShortcutEvent,
type ShortcutKind,
type ShortcutRegisterArgs,
} from '../ipc-types';
interface Entry {
accelerator: string;
kind: ShortcutKind;
}
const registry = new Map<string, Entry>();
export function register(mainWindow: BrowserWindow): void {
const send = (channel: string, payload: ShortcutEvent): void => {
if (mainWindow.isDestroyed()) return;
mainWindow.webContents.send(channel, payload);
};
ipcMain.handle(
CHANNELS.SHORTCUT_REGISTER,
async (_evt, args: ShortcutRegisterArgs): Promise<boolean> => {
const { id, accelerator, kind } = args;
const prev = registry.get(id);
if (prev) {
try {
globalShortcut.unregister(prev.accelerator);
} catch {
/* ignore */
}
registry.delete(id);
}
if (globalShortcut.isRegistered(accelerator)) {
return false;
}
const ok = globalShortcut.register(accelerator, () => {
const ts = Date.now();
send(CHANNELS.SHORTCUT_EVT_FIRED, { id, ts });
if (kind === 'ptt') {
setTimeout(() => {
send(CHANNELS.SHORTCUT_EVT_RELEASED, { id, ts: Date.now() });
}, 200);
}
});
if (!ok) return false;
registry.set(id, { accelerator, kind });
return true;
},
);
ipcMain.handle(CHANNELS.SHORTCUT_UNREGISTER, async (_evt, id: string): Promise<void> => {
const entry = registry.get(id);
if (!entry) return;
try {
globalShortcut.unregister(entry.accelerator);
} catch {
/* already gone */
}
registry.delete(id);
});
ipcMain.handle(CHANNELS.SHORTCUT_IS_REGISTERED, async (_evt, id: string): Promise<boolean> => {
const entry = registry.get(id);
if (!entry) return false;
return globalShortcut.isRegistered(entry.accelerator);
});
app.on('will-quit', () => {
globalShortcut.unregisterAll();
registry.clear();
});
}