import { ipcRenderer } from 'electron' import { ApiPromiseHandler, DefaultRouteShape, ThenArg, } from '@seleniumhq/side-api' const doAPI = async ( path: string, ...args: Parameters ): Promise>> => { console.debug('Emitting to server', path, 'with args', args) const result = await ipcRenderer.invoke(path, ...args) console.debug('Reply from server', path, 'with results', result) return result as ThenArg> } const Handler = () => (path: string) => { return async ( ...args: Parameters ): Promise>> => { console.debug(path, 'api called', ...(args as any)) const result = await doAPI(path, ...args) console.debug(path, 'api complete', result) return result } } export default Handler