Add typed ipc

This commit is contained in:
Robert Kossessa
2024-03-02 18:09:16 +01:00
parent bee6ab1076
commit 43b384dfef
8 changed files with 89 additions and 103 deletions

View File

@@ -1,8 +1,31 @@
import { ElectronAPI } from '@electron-toolkit/preload'
export interface INanoDevicesAPI {
list_devices(): Promise<string[]>
connect(deviceid: string): Promise<string>
disconnect(deviceid: string): Promise<string>
on_event(
eventid_filter: string,
callback: (eventid: string, deviceid: string, data: any) => void
): void
send(deviceid: string, jsonstr: string): Promise<void>
}
export interface IElectronAPI {
platform: NodeJS.Platform
isDevelopment: boolean
minimizeWindow: () => void
toggleMaximizeWindow: () => void
closeWindow: () => void
openExternal: (url: string) => void
onMaximized: (callback: () => void) => void
onUnmaximized: (callback: () => void) => void
onMenu: (callback: (key: string) => void) => void
openDevTools: () => void
reload: () => void
}
declare global {
interface Window {
electron: ElectronAPI
api: unknown
nanoDevicesAPI: INanoDevicesAPI
electronAPI: IElectronAPI
}
}