Skip to content

Commit

Permalink
feat: deprecate ipcRenderer.sendTo() (electron#39091)
Browse files Browse the repository at this point in the history
* feat: deprecate ipcRenderer.sendTo()

* docs: add _Deprecated_ to ipcRenderer.sendTo()
  • Loading branch information
miniak authored and MrHuangJser committed Dec 11, 2023
1 parent f55f2dd commit 1beb083
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/api/ipc-renderer.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/api/structures/ipc-renderer-event.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 4 additions & 0 deletions docs/breaking-changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
3 changes: 3 additions & 0 deletions filenames.auto.gni
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions lib/renderer/api/ipc-renderer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { EventEmitter } from 'events';
import * as deprecate from '@electron/internal/common/deprecate';

const { ipc } = process._linkedBinding('electron_renderer_ipc');

Expand All @@ -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);
};

Expand Down

0 comments on commit 1beb083

Please sign in to comment.