feat: deprecate `ipcRenderer.sendTo()` (#39091)

* feat: deprecate ipcRenderer.sendTo()

* docs: add _Deprecated_ to ipcRenderer.sendTo()
This commit is contained in:
Milan Burda 2023-07-21 11:16:44 +02:00 коммит произвёл GitHub
Родитель 3a5e2dd90c
Коммит ada8eb33b2
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
5 изменённых файлов: 11 добавлений и 2 удалений

Просмотреть файл

@ -192,7 +192,7 @@ ipcMain.on('port', (e, msg) => {
For more information on using `MessagePort` and `MessageChannel`, see the [MDN
documentation](https://developer.mozilla.org/en-US/docs/Web/API/MessageChannel).
### `ipcRenderer.sendTo(webContentsId, channel, ...args)`
### `ipcRenderer.sendTo(webContentsId, channel, ...args)` _Deprecated_
* `webContentsId` number
* `channel` string

Просмотреть файл

@ -4,5 +4,5 @@
* `senderId` Integer - The `webContents.id` that sent the message, you can call `event.sender.sendTo(event.senderId, ...)` to reply to the message, see [ipcRenderer.sendTo][ipc-renderer-sendto] for more information. This only applies to messages sent from a different renderer. Messages sent directly from the main process set `event.senderId` to `0`.
* `ports` [MessagePort][][] - A list of MessagePorts that were transferred with this message
[ipc-renderer-sendto]: ../ipc-renderer.md#ipcrenderersendtowebcontentsid-channel-args
[ipc-renderer-sendto]: ../ipc-renderer.md#ipcrenderersendtowebcontentsid-channel-args-deprecated
[MessagePort]: https://developer.mozilla.org/en-US/docs/Web/API/MessagePort

Просмотреть файл

@ -21,6 +21,10 @@ macOS 10.13 (High Sierra) and macOS 10.14 (Mojave) are no longer supported by [C
Older versions of Electron will continue to run on these operating systems, but macOS 10.15 (Catalina)
or later will be required to run Electron v27.0.0 and higher.
### Deprecated: `ipcRenderer.sendTo()`
The `ipcRenderer.sendTo()` API has been deprecated. It should be replaced by setting up a [`MessageChannel`](tutorial/message-ports.md#setting-up-a-messagechannel-between-two-renderers) between the renderers.
## Planned Breaking API Changes (25.0)
### Deprecated: `protocol.{register,intercept}{Buffer,String,Stream,File,Http}Protocol`

Просмотреть файл

@ -143,6 +143,7 @@ auto_filenames = {
sandbox_bundle_deps = [
"lib/common/api/native-image.ts",
"lib/common/define-properties.ts",
"lib/common/deprecate.ts",
"lib/common/ipc-messages.ts",
"lib/common/web-view-methods.ts",
"lib/common/webpack-globals-provider.ts",
@ -268,6 +269,7 @@ auto_filenames = {
"lib/common/api/native-image.ts",
"lib/common/api/shell.ts",
"lib/common/define-properties.ts",
"lib/common/deprecate.ts",
"lib/common/init.ts",
"lib/common/ipc-messages.ts",
"lib/common/reset-search-paths.ts",
@ -306,6 +308,7 @@ auto_filenames = {
"lib/common/api/native-image.ts",
"lib/common/api/shell.ts",
"lib/common/define-properties.ts",
"lib/common/deprecate.ts",
"lib/common/init.ts",
"lib/common/ipc-messages.ts",
"lib/common/reset-search-paths.ts",

Просмотреть файл

@ -1,4 +1,5 @@
import { EventEmitter } from 'events';
import * as deprecate from '@electron/internal/common/deprecate';
const { ipc } = process._linkedBinding('electron_renderer_ipc');
@ -18,6 +19,7 @@ ipcRenderer.sendToHost = function (channel, ...args) {
};
ipcRenderer.sendTo = function (webContentsId, channel, ...args) {
deprecate.warnOnce('ipcRenderer.sendTo');
return ipc.sendTo(webContentsId, channel, args);
};