ipc-renderer.js 675 B

123456789101112131415161718192021
  1. const ipcRenderer = require('../../renderer/api/ipc-renderer')
  2. const v8Util = process.atomBinding('v8_util')
  3. const ipcNative = process.atomBinding('ipc')
  4. // AtomSandboxedRendererClient will look for the "ipcNative" hidden object when
  5. // invoking the `onMessage`/`onExit` callbacks. We could reuse "ipc" and assign
  6. // `onMessage`/`onExit` directly to `ipcRenderer`, but it is better to separate
  7. // private/public APIs.
  8. v8Util.setHiddenValue(global, 'ipcNative', ipcNative)
  9. ipcNative.onMessage = function (channel, args) {
  10. ipcRenderer.emit(channel, {sender: ipcRenderer}, ...args)
  11. }
  12. ipcNative.onExit = function () {
  13. process.emit('exit')
  14. }
  15. module.exports = ipcRenderer