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:
@@ -0,0 +1,84 @@
|
||||
// Auto-updater. Wraps electron-updater; configuration (feed URL) lives in
|
||||
// package.json's `build.publish`. In dev (`app.isPackaged === false`) we
|
||||
// short-circuit everything — the feed server is production-only and
|
||||
// hitting it every launch from a dev machine just adds noise.
|
||||
|
||||
import { app, BrowserWindow, ipcMain } from 'electron';
|
||||
import electronUpdater, {
|
||||
type ProgressInfo,
|
||||
type UpdateInfo as BuilderUpdateInfo,
|
||||
} from 'electron-updater';
|
||||
|
||||
// electron-updater is a CJS module; named ESM imports don't work. Pull
|
||||
// autoUpdater off the default export instead.
|
||||
const { autoUpdater } = electronUpdater;
|
||||
|
||||
import {
|
||||
CHANNELS,
|
||||
type UpdateCheckResult,
|
||||
type UpdateInfo,
|
||||
type UpdateProgress,
|
||||
} from '../ipc-types';
|
||||
|
||||
let cached: BuilderUpdateInfo | null = null;
|
||||
|
||||
function toPublicInfo(info: BuilderUpdateInfo | null): UpdateInfo | null {
|
||||
if (!info) return null;
|
||||
const notes = info.releaseNotes;
|
||||
let releaseNotes: string | null = null;
|
||||
if (typeof notes === 'string') releaseNotes = notes;
|
||||
else if (Array.isArray(notes)) releaseNotes = notes.map((r) => r.note).join('\n\n');
|
||||
return {
|
||||
version: info.version ?? '',
|
||||
releaseNotes,
|
||||
};
|
||||
}
|
||||
|
||||
export function register(mainWindow: BrowserWindow): void {
|
||||
autoUpdater.autoDownload = false;
|
||||
autoUpdater.autoInstallOnAppQuit = false;
|
||||
|
||||
autoUpdater.on('download-progress', (p: ProgressInfo) => {
|
||||
if (mainWindow.isDestroyed()) return;
|
||||
const payload: UpdateProgress = {
|
||||
percent: p.percent ?? 0,
|
||||
transferred: p.transferred ?? 0,
|
||||
total: p.total ?? 0,
|
||||
};
|
||||
mainWindow.webContents.send(CHANNELS.UPDATER_EVT_PROGRESS, payload);
|
||||
});
|
||||
|
||||
ipcMain.handle(CHANNELS.UPDATER_CHECK, async (): Promise<UpdateCheckResult> => {
|
||||
if (!app.isPackaged) {
|
||||
return { available: false, info: null };
|
||||
}
|
||||
try {
|
||||
const result = await autoUpdater.checkForUpdates();
|
||||
if (!result || !result.updateInfo) {
|
||||
cached = null;
|
||||
return { available: false, info: null };
|
||||
}
|
||||
const current = app.getVersion();
|
||||
const remote = result.updateInfo.version;
|
||||
if (!remote || remote === current) {
|
||||
cached = null;
|
||||
return { available: false, info: null };
|
||||
}
|
||||
cached = result.updateInfo;
|
||||
return { available: true, info: toPublicInfo(cached) };
|
||||
} catch (err: unknown) {
|
||||
const msg = err instanceof Error ? err.message : String(err);
|
||||
if (!/ENOTFOUND|ETIMEDOUT|ECONNRESET|404/i.test(msg)) {
|
||||
console.warn('[updater] check failed', err);
|
||||
}
|
||||
return { available: false, info: null };
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.handle(CHANNELS.UPDATER_DOWNLOAD_INSTALL, async (): Promise<void> => {
|
||||
if (!app.isPackaged) return;
|
||||
if (!cached) throw new Error('no pending update — call check first');
|
||||
await autoUpdater.downloadUpdate();
|
||||
autoUpdater.quitAndInstall();
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user