mirror of
https://github.com/Kvan7/Exiled-Exchange-2.git
synced 2026-10-02 17:37:50 +00:00
25 lines
755 B
TypeScript
25 lines
755 B
TypeScript
import { contextBridge, ipcRenderer } from 'electron'
|
|
import type { IpcGetConfig, IpcImportFile } from './ipc-event'
|
|
import type { PreloadExposed } from './types'
|
|
|
|
const api: PreloadExposed = {
|
|
sendEvent (event) {
|
|
ipcRenderer.send(event.name, event.payload)
|
|
},
|
|
onEvent (cb) {
|
|
ipcRenderer.on('named-event', (_e, data) => {
|
|
cb(data)
|
|
})
|
|
},
|
|
getConfig () {
|
|
const name: IpcGetConfig['name'] = 'OVERLAY->MAIN::get-config'
|
|
return ipcRenderer.sendSync(name) as IpcGetConfig['payload']
|
|
},
|
|
importFile (filePath: string) {
|
|
const name: IpcImportFile['name'] = 'OVERLAY->MAIN::import-file'
|
|
return ipcRenderer.sendSync(name, filePath) as IpcImportFile['payload']
|
|
}
|
|
}
|
|
|
|
contextBridge.exposeInMainWorld('electronAPI', api)
|