feat: add webFrameMain.send() / webFrameMain.postMessage() (#26807)
This commit is contained in:
parent
28b6579538
commit
2be3d03630
14 changed files with 340 additions and 209 deletions
|
@ -1,4 +1,29 @@
|
|||
const { fromId } = process._linkedBinding('electron_browser_web_frame_main');
|
||||
import { MessagePortMain } from '@electron/internal/browser/message-port-main';
|
||||
|
||||
const { WebFrameMain, fromId } = process._linkedBinding('electron_browser_web_frame_main');
|
||||
|
||||
WebFrameMain.prototype.send = function (channel, ...args) {
|
||||
if (typeof channel !== 'string') {
|
||||
throw new Error('Missing required channel argument');
|
||||
}
|
||||
|
||||
return this._send(false /* internal */, channel, args);
|
||||
};
|
||||
|
||||
WebFrameMain.prototype._sendInternal = function (channel, ...args) {
|
||||
if (typeof channel !== 'string') {
|
||||
throw new Error('Missing required channel argument');
|
||||
}
|
||||
|
||||
return this._send(true /* internal */, channel, args);
|
||||
};
|
||||
|
||||
WebFrameMain.prototype.postMessage = function (...args) {
|
||||
if (Array.isArray(args[2])) {
|
||||
args[2] = args[2].map(o => o instanceof MessagePortMain ? o._internalPort : o);
|
||||
}
|
||||
this._postMessage(...args);
|
||||
};
|
||||
|
||||
export default {
|
||||
fromId
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue