feat: WebContents extends EventEmitter

This commit is contained in:
clavin
2025-12-25 01:15:19 -07:00
parent 3df3a6a736
commit 33b0a3512e

View File

@@ -8,6 +8,7 @@ import { IPC_MESSAGES } from '@electron/internal/common/ipc-messages';
import { app, session, webFrameMain, dialog } from 'electron/main';
import type { BrowserWindowConstructorOptions, MessageBoxOptions, NavigationEntry } from 'electron/main';
import { EventEmitter } from 'events';
import * as path from 'path';
import * as url from 'url';
@@ -118,6 +119,8 @@ const binding = process._linkedBinding('electron_browser_web_contents');
const printing = process._linkedBinding('electron_browser_printing');
const { WebContents } = binding as { WebContents: { prototype: Electron.WebContents } };
Object.setPrototypeOf(WebContents.prototype, EventEmitter.prototype);
WebContents.prototype.postMessage = function (...args) {
return this.mainFrame.postMessage(...args);
};