2018-09-22 12:28:50 +00:00
|
|
|
'use strict'
|
|
|
|
|
2018-09-20 03:43:26 +00:00
|
|
|
const ipcRenderer = require('@electron/internal/renderer/api/ipc-renderer')
|
2017-02-27 17:14:36 +00:00
|
|
|
|
|
|
|
const v8Util = process.atomBinding('v8_util')
|
|
|
|
const ipcNative = process.atomBinding('ipc')
|
|
|
|
|
|
|
|
// AtomSandboxedRendererClient will look for the "ipcNative" hidden object when
|
|
|
|
// invoking the `onMessage`/`onExit` callbacks. We could reuse "ipc" and assign
|
|
|
|
// `onMessage`/`onExit` directly to `ipcRenderer`, but it is better to separate
|
|
|
|
// private/public APIs.
|
|
|
|
v8Util.setHiddenValue(global, 'ipcNative', ipcNative)
|
|
|
|
|
2018-09-01 01:13:51 +00:00
|
|
|
ipcNative.onMessage = function (channel, args, senderId) {
|
2018-09-13 16:10:51 +00:00
|
|
|
ipcRenderer.emit(channel, { sender: ipcRenderer, senderId }, ...args)
|
2017-02-27 17:14:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ipcNative.onExit = function () {
|
|
|
|
process.emit('exit')
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = ipcRenderer
|