2023-08-19 20:43:21 +12:00
|
|
|
/**
|
|
|
|
* This file is used specifically for security reasons.
|
|
|
|
* Here you can access Nodejs stuff and inject functionality into
|
|
|
|
* the renderer thread (accessible there through the "window" object)
|
|
|
|
*
|
|
|
|
* WARNING!
|
|
|
|
* If you import anything from node_modules, then make sure that the package is specified
|
|
|
|
* in package.json > dependencies and NOT in devDependencies
|
|
|
|
*
|
|
|
|
* Example (injects window.myAPI.doAThing() into renderer thread):
|
|
|
|
*
|
|
|
|
* import { contextBridge } from 'electron'
|
|
|
|
*
|
|
|
|
* contextBridge.exposeInMainWorld('myAPI', {
|
|
|
|
* doAThing: () => {}
|
|
|
|
* })
|
|
|
|
*
|
|
|
|
* WARNING!
|
|
|
|
* If accessing Node functionality (like importing @electron/remote) then in your
|
|
|
|
* electron-main.ts you will need to set the following when you instantiate BrowserWindow:
|
|
|
|
*
|
|
|
|
* mainWindow = new BrowserWindow({
|
|
|
|
* // ...
|
|
|
|
* webPreferences: {
|
|
|
|
* // ...
|
|
|
|
* sandbox: false // <-- to be able to import @electron/remote in preload script
|
|
|
|
* }
|
|
|
|
* }
|
|
|
|
*/
|
|
|
|
|
|
|
|
import { contextBridge } from 'electron'
|
|
|
|
|
2023-09-09 09:54:44 +12:00
|
|
|
import { faWindowControlAPI } from 'src-electron/customContentBridgeAPIs/faWindowControlAPI'
|
|
|
|
import { extraEnvVariablesAPI } from 'src-electron/customContentBridgeAPIs/extraEnvVariablesAPI'
|
2023-09-13 07:20:26 +12:00
|
|
|
import { faDevToolsControlAPI } from 'src-electron/customContentBridgeAPIs/faDevToolsControlAPI'
|
2023-10-15 03:41:36 +13:00
|
|
|
import { faExternalLinksManagerAPI } from 'app/src-electron/customContentBridgeAPIs/faExternalLinksManagerAPI'
|
2023-08-28 04:52:26 +12:00
|
|
|
|
|
|
|
contextBridge.exposeInMainWorld('faWindowControlAPI', faWindowControlAPI)
|
2023-09-13 07:20:26 +12:00
|
|
|
contextBridge.exposeInMainWorld('faDevToolsControlAPI', faDevToolsControlAPI)
|
2023-10-15 03:41:36 +13:00
|
|
|
contextBridge.exposeInMainWorld('faExternalLinksManagerAPI', faExternalLinksManagerAPI)
|
2023-09-09 09:54:44 +12:00
|
|
|
contextBridge.exposeInMainWorld('extraEnvVariables', extraEnvVariablesAPI)
|