Move code that defines ipcRenderer methods into another file.
This commit is contained in:
Родитель
1713200084
Коммит
0f7652dc85
|
@ -61,6 +61,7 @@
|
|||
'lib/renderer/api/desktop-capturer.js',
|
||||
'lib/renderer/api/exports/electron.js',
|
||||
'lib/renderer/api/ipc-renderer.js',
|
||||
'lib/renderer/api/ipc-renderer-setup.js',
|
||||
'lib/renderer/api/remote.js',
|
||||
'lib/renderer/api/screen.js',
|
||||
'lib/renderer/api/web-frame.js',
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
module.exports = function (ipcRenderer, binding) {
|
||||
ipcRenderer.send = function (...args) {
|
||||
return binding.send('ipc-message', args)
|
||||
}
|
||||
|
||||
ipcRenderer.sendSync = function (...args) {
|
||||
return JSON.parse(binding.sendSync('ipc-message-sync', args))
|
||||
}
|
||||
|
||||
ipcRenderer.sendToHost = function (...args) {
|
||||
return binding.send('ipc-message-host', args)
|
||||
}
|
||||
|
||||
ipcRenderer.sendTo = function (webContentsId, channel, ...args) {
|
||||
if (typeof webContentsId !== 'number') {
|
||||
throw new TypeError('First argument has to be webContentsId')
|
||||
}
|
||||
|
||||
ipcRenderer.send('ELECTRON_BROWSER_SEND_TO', false, webContentsId, channel, ...args)
|
||||
}
|
||||
|
||||
ipcRenderer.sendToAll = function (webContentsId, channel, ...args) {
|
||||
if (typeof webContentsId !== 'number') {
|
||||
throw new TypeError('First argument has to be webContentsId')
|
||||
}
|
||||
|
||||
ipcRenderer.send('ELECTRON_BROWSER_SEND_TO', true, webContentsId, channel, ...args)
|
||||
}
|
||||
}
|
|
@ -5,33 +5,6 @@ const v8Util = process.atomBinding('v8_util')
|
|||
|
||||
// Created by init.js.
|
||||
const ipcRenderer = v8Util.getHiddenValue(global, 'ipc')
|
||||
|
||||
ipcRenderer.send = function (...args) {
|
||||
return binding.send('ipc-message', args)
|
||||
}
|
||||
|
||||
ipcRenderer.sendSync = function (...args) {
|
||||
return JSON.parse(binding.sendSync('ipc-message-sync', args))
|
||||
}
|
||||
|
||||
ipcRenderer.sendToHost = function (...args) {
|
||||
return binding.send('ipc-message-host', args)
|
||||
}
|
||||
|
||||
ipcRenderer.sendTo = function (webContentsId, channel, ...args) {
|
||||
if (typeof webContentsId !== 'number') {
|
||||
throw new TypeError('First argument has to be webContentsId')
|
||||
}
|
||||
|
||||
ipcRenderer.send('ELECTRON_BROWSER_SEND_TO', false, webContentsId, channel, ...args)
|
||||
}
|
||||
|
||||
ipcRenderer.sendToAll = function (webContentsId, channel, ...args) {
|
||||
if (typeof webContentsId !== 'number') {
|
||||
throw new TypeError('First argument has to be webContentsId')
|
||||
}
|
||||
|
||||
ipcRenderer.send('ELECTRON_BROWSER_SEND_TO', true, webContentsId, channel, ...args)
|
||||
}
|
||||
require('./ipc-renderer-setup')(ipcRenderer, binding)
|
||||
|
||||
module.exports = ipcRenderer
|
||||
|
|
Загрузка…
Ссылка в новой задаче