2020-06-02 02:33:06 -07:00
|
|
|
import { EventEmitter } from 'events';
|
|
|
|
|
2020-06-22 20:32:45 -07:00
|
|
|
const { ipc } = process._linkedBinding('electron_renderer_ipc');
|
2016-01-11 18:40:23 -08:00
|
|
|
|
2020-03-20 13:28:31 -07:00
|
|
|
const internal = false;
|
2017-02-27 14:34:08 -03:00
|
|
|
|
2020-06-02 02:33:06 -07:00
|
|
|
const ipcRenderer = new EventEmitter() as Electron.IpcRenderer;
|
|
|
|
ipcRenderer.send = function (channel, ...args) {
|
|
|
|
return ipc.send(internal, channel, args);
|
|
|
|
};
|
|
|
|
|
|
|
|
ipcRenderer.sendSync = function (channel, ...args) {
|
2020-10-28 16:48:20 +01:00
|
|
|
return ipc.sendSync(internal, channel, args);
|
2020-06-02 02:33:06 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
ipcRenderer.sendToHost = function (channel, ...args) {
|
|
|
|
return ipc.sendToHost(channel, args);
|
|
|
|
};
|
|
|
|
|
|
|
|
ipcRenderer.sendTo = function (webContentsId, channel, ...args) {
|
2020-12-03 07:55:50 +01:00
|
|
|
return ipc.sendTo(internal, webContentsId, channel, args);
|
2020-06-02 02:33:06 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
ipcRenderer.invoke = async function (channel, ...args) {
|
|
|
|
const { error, result } = await ipc.invoke(internal, channel, args);
|
|
|
|
if (error) {
|
|
|
|
throw new Error(`Error invoking remote method '${channel}': ${error}`);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
};
|
|
|
|
|
|
|
|
ipcRenderer.postMessage = function (channel: string, message: any, transferables: any) {
|
|
|
|
return ipc.postMessage(channel, message, transferables);
|
|
|
|
};
|
2020-03-11 18:07:54 -07:00
|
|
|
|
2020-03-20 13:28:31 -07:00
|
|
|
export default ipcRenderer;
|