import { contextBridge, ipcRenderer } from 'electron'; import { Command, Query } from './cqrs/types'; export interface ElectronAPI { // Window controls minimizeWindow: () => void; maximizeWindow: () => void; closeWindow: () => void; // System utilities openExternal: (url: string) => Promise; getSources: () => Promise<{ id: string; name: string; thumbnail: string }[]>; getAppDataPath: () => Promise; readFile: (filePath: string) => Promise; writeFile: (filePath: string, data: string) => Promise; fileExists: (filePath: string) => Promise; ensureDir: (dirPath: string) => Promise; // CQRS database operations command: (command: Command) => Promise; query: (query: Query) => Promise; } const electronAPI: ElectronAPI = { minimizeWindow: () => ipcRenderer.send('window-minimize'), maximizeWindow: () => ipcRenderer.send('window-maximize'), closeWindow: () => ipcRenderer.send('window-close'), openExternal: (url) => ipcRenderer.invoke('open-external', url), getSources: () => ipcRenderer.invoke('get-sources'), getAppDataPath: () => ipcRenderer.invoke('get-app-data-path'), readFile: (filePath) => ipcRenderer.invoke('read-file', filePath), writeFile: (filePath, data) => ipcRenderer.invoke('write-file', filePath, data), fileExists: (filePath) => ipcRenderer.invoke('file-exists', filePath), ensureDir: (dirPath) => ipcRenderer.invoke('ensure-dir', dirPath), command: (command) => ipcRenderer.invoke('cqrs:command', command), query: (query) => ipcRenderer.invoke('cqrs:query', query) }; contextBridge.exposeInMainWorld('electronAPI', electronAPI); declare global { interface Window { electronAPI: ElectronAPI; } }