-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpreload.ts
More file actions
21 lines (17 loc) · 769 Bytes
/
preload.ts
File metadata and controls
21 lines (17 loc) · 769 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// preload.ts
// From Electron 20 onwards, preload scripts are sandboxed by default
// and no longer have access to a full Node.js environment. Practically,
// this means that you have a polyfilled require function that only
// has access to a limited set of APIs.
// Read more: https://www.electronjs.org/docs/latest/tutorial/tutorial-preload
import { contextBridge, ipcRenderer } from 'electron';
// expose some IPC channels to the renderer process
contextBridge.exposeInMainWorld('electronAPI', {
requestProcessVersions: async () => {
return await ipcRenderer.invoke('renderer:requestProcessVersions');
}
});
// we can also expose variables, not just functions
contextBridge.exposeInMainWorld('versions', {
chrome: () => process.versions.chrome,
})