21 lines
915 B
TypeScript
21 lines
915 B
TypeScript
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<CustomGame, 'id' | 'source'>) => 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<string | null>,
|
|
pickImage: () => ipcRenderer.invoke('dialog:pick-image') as Promise<string | null>,
|
|
onAdminOpen: (cb: () => void) => {
|
|
ipcRenderer.on('admin:open', cb)
|
|
return () => ipcRenderer.removeListener('admin:open', cb)
|
|
},
|
|
}
|
|
|
|
contextBridge.exposeInMainWorld('launcher', launcher)
|
|
|
|
export type LauncherAPI = typeof launcher
|