chore: remove deprecated ipcRenderer.sendTo() (#39087)

chore: remove deprecated ipcRenderer.sendTo()
This commit is contained in:
Milan Burda 2023-08-28 16:29:27 +02:00 committed by GitHub
parent b5997a012d
commit 5078cae861
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 20 additions and 207 deletions

View file

@ -1,5 +1,4 @@
import { EventEmitter } from 'events';
import * as deprecate from '@electron/internal/common/deprecate';
const { ipc } = process._linkedBinding('electron_renderer_ipc');
@ -18,12 +17,6 @@ ipcRenderer.sendToHost = function (channel, ...args) {
return ipc.sendToHost(channel, args);
};
const sendToDeprecated = deprecate.warnOnce('ipcRenderer.sendTo');
ipcRenderer.sendTo = function (webContentsId, channel, ...args) {
sendToDeprecated();
return ipc.sendTo(webContentsId, channel, args);
};
ipcRenderer.invoke = async function (channel, ...args) {
const { error, result } = await ipc.invoke(internal, channel, args);
if (error) {

View file

@ -17,13 +17,9 @@ const isWebView = mainFrame.getWebPreference('isWebView');
// ElectronApiServiceImpl will look for the "ipcNative" hidden object when
// invoking the 'onMessage' callback.
v8Util.setHiddenValue(global, 'ipcNative', {
onMessage (internal: boolean, channel: string, ports: MessagePort[], args: any[], senderId: number, senderIsMainFrame: boolean) {
if (internal && senderId !== 0) {
console.error(`Message ${channel} sent by unexpected WebContents (${senderId})`);
return;
}
onMessage (internal: boolean, channel: string, ports: MessagePort[], args: any[]) {
const sender = internal ? ipcRendererInternal : ipcRenderer;
sender.emit(channel, { sender, senderId, ...(senderId ? { senderIsMainFrame } : {}), ports }, ...args);
sender.emit(channel, { sender, ports }, ...args);
}
});