feat(desktop): add recovery bridge methods to preload + types

- rendererReady (boot-completion ping)
- getRecoveryState / onRecoveryStateChanged (recovery.html subscribers)
- recoveryAction (button click dispatcher with enum action)

Type declarations kept ambient (no export) to preserve window.backspace
global augmentation — exporting from an ambient .d.ts converts it to a
module and breaks the Window interface extension.
This commit is contained in:
Jannis Braun
2026-05-03 11:57:51 +02:00
parent d8266e62da
commit ece81a2b71
2 changed files with 44 additions and 0 deletions
+19
View File
@@ -107,4 +107,23 @@ contextBridge.exposeInMainWorld('backspace', {
return () => { ipcRenderer.removeListener('keybind-hook-error', handler); };
},
checkAccessibility: () => ipcRenderer.invoke('check-accessibility'),
// Recovery mode bridge (Task 11)
rendererReady: (): void => {
ipcRenderer.send('renderer-ready');
},
getRecoveryState: (): Promise<unknown> => {
return ipcRenderer.invoke('get-recovery-state');
},
onRecoveryStateChanged: (cb: (state: unknown) => void): (() => void) => {
const handler = (_e: Electron.IpcRendererEvent, state: unknown) => cb(state);
ipcRenderer.on('recovery-state-changed', handler);
return () => { ipcRenderer.removeListener('recovery-state-changed', handler); };
},
recoveryAction: (action: string): void => {
ipcRenderer.send('recovery-action', action);
},
});
+25
View File
@@ -1,5 +1,24 @@
/** Type augmentation for the Electron IPC bridge exposed by preload.ts */
// Recovery mode types (Task 11)
type RecoveryReasonCode = 'load-failed' | 'render-gone' | 'unresponsive' | 'renderer-stalled';
type UpdateState = 'idle' | 'checking' | 'downloading' | 'downloaded' | 'error';
interface RecoveryState {
mode: 'normal' | 'recovery';
reason: { code: RecoveryReasonCode; detail: string } | null;
updateState: UpdateState;
updateVersion: string | null;
lastUpdateError: { message: string; code: string | null; at: number } | null;
lastCheckResult: 'up-to-date' | 'failed' | null;
}
type RecoveryAction =
| 'reload'
| 'check-update'
| 'install-update'
| 'change-instance'
| 'open-releases'
| 'quit';
interface ElectronScreenSource {
id: string; // "screen:0:0" or "window:12345:0"
name: string; // "Entire Screen" or "Firefox"
@@ -63,6 +82,12 @@ interface BackspaceElectronAPI {
onAccessibilityStatus: (callback: (status: { trusted: boolean }) => void) => (() => void);
onKeybindHookError: (callback: (error: { message: string }) => void) => (() => void);
checkAccessibility: () => Promise<boolean>;
// Recovery mode bridge (Task 11)
rendererReady: () => void;
getRecoveryState: () => Promise<RecoveryState>;
onRecoveryStateChanged: (cb: (state: RecoveryState) => void) => () => void;
recoveryAction: (action: RecoveryAction) => void;
}
interface Window {