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:
@@ -107,4 +107,23 @@ contextBridge.exposeInMainWorld('backspace', {
|
|||||||
return () => { ipcRenderer.removeListener('keybind-hook-error', handler); };
|
return () => { ipcRenderer.removeListener('keybind-hook-error', handler); };
|
||||||
},
|
},
|
||||||
checkAccessibility: () => ipcRenderer.invoke('check-accessibility'),
|
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
@@ -1,5 +1,24 @@
|
|||||||
/** Type augmentation for the Electron IPC bridge exposed by preload.ts */
|
/** 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 {
|
interface ElectronScreenSource {
|
||||||
id: string; // "screen:0:0" or "window:12345:0"
|
id: string; // "screen:0:0" or "window:12345:0"
|
||||||
name: string; // "Entire Screen" or "Firefox"
|
name: string; // "Entire Screen" or "Firefox"
|
||||||
@@ -63,6 +82,12 @@ interface BackspaceElectronAPI {
|
|||||||
onAccessibilityStatus: (callback: (status: { trusted: boolean }) => void) => (() => void);
|
onAccessibilityStatus: (callback: (status: { trusted: boolean }) => void) => (() => void);
|
||||||
onKeybindHookError: (callback: (error: { message: string }) => void) => (() => void);
|
onKeybindHookError: (callback: (error: { message: string }) => void) => (() => void);
|
||||||
checkAccessibility: () => Promise<boolean>;
|
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 {
|
interface Window {
|
||||||
|
|||||||
Reference in New Issue
Block a user