Update index.ts
This commit is contained in:
parent
d879be824d
commit
e08c54f3ba
|
|
@ -1,5 +1,6 @@
|
|||
import { contextBridge, ipcRenderer } from 'electron'
|
||||
import { electronAPI } from '@electron-toolkit/preload'
|
||||
import { umbraApi } from '../main/services/api.js'
|
||||
|
||||
// Custom APIs for renderer
|
||||
const api = {}
|
||||
|
|
@ -15,6 +16,18 @@ if (process.contextIsolated) {
|
|||
onAppStatus: (callback) => ipcRenderer.on('app-status', (event, status) => callback(status))
|
||||
})
|
||||
contextBridge.exposeInMainWorld('api', api)
|
||||
|
||||
|
||||
let safeUmbraApi = {};
|
||||
for (let key in umbraApi) {
|
||||
safeUmbraApi[key] = (args) => ipcRenderer.invoke(umbraApi[key], args);
|
||||
}
|
||||
safeUmbraApi = {
|
||||
...safeUmbraApi,
|
||||
"startGame": (id, path) => ipcRenderer.send('startGame', { id, path }),
|
||||
"onAppStatus": (callback) => ipcRenderer.on('app-status', (event, status) => callback(status))
|
||||
}
|
||||
contextBridge.exposeInMainWorld('Umbra', safeUmbraApi);
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue