import { contextBridge, ipcRenderer } from 'electron' import type { CustomGame } from './config' const launcher = { getGames: () => ipcRenderer.invoke('games:get-all'), launchGame: (id: string) => ipcRenderer.invoke('games:launch', id), addCustomGame: (game: Omit) => ipcRenderer.invoke('admin:add-game', game), removeGame: (id: string) => ipcRenderer.invoke('admin:remove-game', id), updateGame: (game: CustomGame) => ipcRenderer.invoke('admin:update-game', game), pickExe: () => ipcRenderer.invoke('dialog:pick-exe') as Promise, pickImage: () => ipcRenderer.invoke('dialog:pick-image') as Promise, onAdminOpen: (cb: () => void) => { ipcRenderer.on('admin:open', cb) return () => ipcRenderer.removeListener('admin:open', cb) }, } contextBridge.exposeInMainWorld('launcher', launcher) export type LauncherAPI = typeof launcher