mirror of
https://github.com/netzbegruenung/jitsi-meet-electron.git
synced 2024-05-02 00:34:53 +02:00
63 lines
1.5 KiB
JavaScript
63 lines
1.5 KiB
JavaScript
const createElectronStorage = require('redux-persist-electron-storage');
|
|
const { ipcRenderer, shell, remote } = require('electron');
|
|
const os = require('os');
|
|
const url = require('url');
|
|
|
|
const jitsiMeetElectronUtils = require('jitsi-meet-electron-utils');
|
|
|
|
const protocolRegex = /^https?:/i;
|
|
|
|
/**
|
|
* Opens the given link in an external browser.
|
|
*
|
|
* @param {string} link - The link (URL) that should be opened in the external browser.
|
|
* @returns {void}
|
|
*/
|
|
function openExternalLink(link) {
|
|
let u;
|
|
|
|
try {
|
|
u = url.parse(link);
|
|
} catch (e) {
|
|
return;
|
|
}
|
|
|
|
if (protocolRegex.test(u.protocol)) {
|
|
shell.openExternal(link);
|
|
}
|
|
}
|
|
|
|
const whitelistedIpcChannels = [ 'protocol-data-msg', 'renderer-ready' ];
|
|
|
|
window.jitsiNodeAPI = {
|
|
createElectronStorage,
|
|
osUserInfo: os.userInfo,
|
|
openExternalLink,
|
|
jitsiMeetElectronUtils,
|
|
shellOpenExternal: shell.openExternal,
|
|
getLocale: remote.app.getLocale,
|
|
ipc: {
|
|
on: (channel, listener) => {
|
|
if (!whitelistedIpcChannels.includes(channel)) {
|
|
return;
|
|
}
|
|
|
|
return ipcRenderer.on(channel, listener);
|
|
},
|
|
send: channel => {
|
|
if (!whitelistedIpcChannels.includes(channel)) {
|
|
return;
|
|
}
|
|
|
|
return ipcRenderer.send(channel);
|
|
},
|
|
removeListener: (channel, listener) => {
|
|
if (!whitelistedIpcChannels.includes(channel)) {
|
|
return;
|
|
}
|
|
|
|
return ipcRenderer.removeListener(channel, listener);
|
|
}
|
|
}
|
|
};
|