armcord/src/preload/bridge.ts

35 lines
1.4 KiB
TypeScript
Raw Normal View History

2022-03-04 17:53:18 +00:00
import {contextBridge, ipcRenderer} from "electron";
import {getDisplayMediaSelector} from "./capturer";
import {injectTitlebar} from "./titlebar";
2021-12-24 21:56:49 +00:00
contextBridge.exposeInMainWorld("armcord", {
2022-03-04 17:53:18 +00:00
window: {
show: () => ipcRenderer.send("win-show"),
hide: () => ipcRenderer.send("win-hide"),
minimize: () => ipcRenderer.send("win-minimize"),
maximize: () => ipcRenderer.send("win-maximize")
},
titlebar: {
injectTitlebar: () => injectTitlebar(),
isTitlebar: ipcRenderer.sendSync("titlebar")
},
electron: process.versions.electron,
channel: ipcRenderer.sendSync("channel"),
2022-06-11 20:14:16 +00:00
setLang: (lang: string) => ipcRenderer.send("setLang", lang),
2022-06-12 18:59:59 +00:00
getLang: (toGet: string) =>
ipcRenderer.invoke("getLang", toGet).then((result) => {
return result;
}),
2022-03-04 17:53:18 +00:00
version: ipcRenderer.sendSync("get-app-version", "app-version"),
getDisplayMediaSelector: getDisplayMediaSelector,
openSettingsWindow: () => ipcRenderer.send("openSettingsWindow")
});
2022-01-30 19:48:32 +00:00
//to be only used inside armcord internal setup/splash etc
2022-03-04 17:53:18 +00:00
if (window.location.href.indexOf("splash.html") > -1 || window.location.href.indexOf("setup.html") > -1) {
contextBridge.exposeInMainWorld("armcordinternal", {
restart: () => ipcRenderer.send("restart"),
saveSettings: (...args: any) => ipcRenderer.send("saveSettings", ...args),
splashEnd: () => ipcRenderer.send("splashEnd")
});
}