jitsi-meet-electron/app/preload/preload.js

43 lines
1.2 KiB
JavaScript
Raw Normal View History

/* global process */
2020-04-07 11:55:54 +02:00
const createElectronStorage = require('redux-persist-electron-storage');
const { ipcRenderer } = require('electron');
2020-04-07 11:55:54 +02:00
const os = require('os');
const jitsiMeetElectronUtils = require('@jitsi/electron-sdk');
2020-06-30 11:16:21 +02:00
const { openExternalLink } = require('../features/utils/openExternalLink');
2020-04-07 11:55:54 +02:00
const whitelistedIpcChannels = [ 'protocol-data-msg', 'renderer-ready' ];
2020-04-07 11:55:54 +02:00
window.jitsiNodeAPI = {
createElectronStorage,
osUserInfo: os.userInfo,
openExternalLink,
platform: process.platform,
jitsiMeetElectronUtils,
electronStoreExists: ipcRenderer.sendSync('electron-store-exists'),
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);
}
}
2020-04-07 11:55:54 +02:00
};