ElectronNET.Host: Fix TS compilation error webcontents.ts

The crashed event has been removed in Electron 29 - just let TS ignore
that error
This commit is contained in:
softworkz
2025-10-13 14:04:36 +02:00
parent 77efea50ed
commit 1e93d91e66

View File

@@ -6,10 +6,13 @@ let electronSocket;
export = (socket: Socket) => {
electronSocket = socket;
// The crashed event has been removed in Electron 29
socket.on('register-webContents-crashed', (id) => {
const browserWindow = getWindowById(id);
browserWindow.webContents.removeAllListeners('crashed');
// @ts-expect-error No overload matches this call
browserWindow.webContents.on('crashed', (event, killed) => {
electronSocket.emit('webContents-crashed' + id, killed);
});
@@ -246,6 +249,19 @@ export = (socket: Socket) => {
browserWindow.webContents.session.setUserAgent(userAgent, acceptLanguages);
});
socket.on('register-webContents-session-webRequest-onBeforeRequest', (id, filter) => {
const browserWindow = getWindowById(id);
const session = browserWindow.webContents.session;
session.webRequest.onBeforeRequest(filter, (details, callback) => {
socket.emit(`webContents-session-webRequest-onBeforeRequest${id}`, details);
// Listen for a response from C# to continue the request
electronSocket.once(`webContents-session-webRequest-onBeforeRequest-response${id}`, (response) => {
callback(response);
});
});
});
socket.on('register-webContents-session-cookies-changed', (id) => {
const browserWindow = getWindowById(id);