mirror of
https://github.com/vrcx-team/VRCX.git
synced 2026-04-06 00:32:02 +02:00
* refactor: merge two overlay offScreenBrowser into one * Electron support for shared overlay * Separate overlay into its own process * fix: invalid overlay texture size * Handle duplicate processes * Remove logging --------- Co-authored-by: pa <maplenagisa@gmail.com> Co-authored-by: rs189 <35667100+rs189@users.noreply.github.com>
60 lines
2.1 KiB
JavaScript
60 lines
2.1 KiB
JavaScript
/**
|
|
* The preload script runs before `index.html` is loaded
|
|
* in the renderer. It has access to web APIs as well as
|
|
* Electron's renderer process modules and some polyfilled
|
|
* Node.js functions.
|
|
*
|
|
* https://www.electronjs.org/docs/latest/tutorial/sandbox
|
|
*/
|
|
const { contextBridge, ipcRenderer, app } = require('electron');
|
|
|
|
contextBridge.exposeInMainWorld('interopApi', {
|
|
callDotNetMethod: (className, methodName, args) => {
|
|
return ipcRenderer.invoke(
|
|
'callDotNetMethod',
|
|
className,
|
|
methodName,
|
|
args
|
|
);
|
|
}
|
|
});
|
|
|
|
const validChannels = ['launch-command'];
|
|
|
|
contextBridge.exposeInMainWorld('electron', {
|
|
getArch: () => ipcRenderer.invoke('app:getArch'),
|
|
getClipboardText: () => ipcRenderer.invoke('app:getClipboardText'),
|
|
getNoUpdater: () => ipcRenderer.invoke('app:getNoUpdater'),
|
|
setTrayIconNotification: (notify) =>
|
|
ipcRenderer.invoke('app:setTrayIconNotification', notify),
|
|
openFileDialog: () => ipcRenderer.invoke('dialog:openFile'),
|
|
openDirectoryDialog: () => ipcRenderer.invoke('dialog:openDirectory'),
|
|
onWindowPositionChanged: (callback) =>
|
|
ipcRenderer.on('setWindowPosition', callback),
|
|
onWindowSizeChanged: (callback) =>
|
|
ipcRenderer.on('setWindowSize', callback),
|
|
onWindowStateChange: (callback) =>
|
|
ipcRenderer.on('setWindowState', callback),
|
|
onBrowserFocus: (callback) => ipcRenderer.on('onBrowserFocus', callback),
|
|
desktopNotification: (title, body, icon) =>
|
|
ipcRenderer.invoke('notification:showNotification', title, body, icon),
|
|
restartApp: () => ipcRenderer.invoke('app:restart'),
|
|
getOverlayWindow: () => ipcRenderer.invoke('app:getOverlayWindow'),
|
|
updateVr: (active, hmdOverlay, wristOverlay, menuButton, overlayHand) =>
|
|
ipcRenderer.invoke(
|
|
'app:updateVr',
|
|
active,
|
|
hmdOverlay,
|
|
wristOverlay,
|
|
menuButton,
|
|
overlayHand
|
|
),
|
|
ipcRenderer: {
|
|
on(channel, func) {
|
|
if (validChannels.includes(channel)) {
|
|
ipcRenderer.on(channel, (event, ...args) => func(...args));
|
|
}
|
|
}
|
|
}
|
|
});
|