const { contextBridge, ipcRenderer } = require('electron'); // Expose protected methods that allow the renderer process to use // the ipcRenderer without exposing the entire object contextBridge.exposeInMainWorld('electronAPI', { getDevices: (params) => ipcRenderer.invoke('api-get-devices', params), getAuthInfo: (params) => ipcRenderer.invoke('api-get-auth-info', params), // Camera proxy functionality launchCookieCameraProxy: (params) => ipcRenderer.invoke('camera-proxy-cookie-launch', params), stopCameraProxy: (processId) => ipcRenderer.invoke('camera-proxy-stop', { processId }), // Extension cookie bridge (push from main process) onExtensionCookie: (callback) => { ipcRenderer.on('extension-cookie-received', (event, data) => { try { callback(data); } catch (error) { console.error('Extension cookie handler error:', error); } }); }, // Self-update functionality checkForUpdates: () => ipcRenderer.invoke('check-for-updates'), downloadAndInstallUpdate: (params) => ipcRenderer.invoke('download-and-install-update', params), getCurrentVersion: () => ipcRenderer.invoke('get-current-version'), onUpdateDownloadProgress: (callback) => { ipcRenderer.on('update-download-progress', (event, data) => { try { callback(data); } catch (error) { console.error('Update download progress handler error:', error); } }); } });