feat: service worker preload scripts for improved extensions support (#44411)

* feat: preload scripts for service workers

* feat: service worker IPC

* test: service worker preload scripts and ipc
This commit is contained in:
Sam Maddock 2025-01-31 09:32:45 -05:00 committed by GitHub
parent bc22ee7897
commit 26da3c5d6e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
67 changed files with 2103 additions and 298 deletions

View file

@ -72,11 +72,15 @@ declare namespace Electron {
}
interface ServiceWorkerMain {
_send(internal: boolean, channel: string, args: any): void;
_startExternalRequest(hasTimeout: boolean): { id: string, ok: boolean };
_finishExternalRequest(uuid: string): void;
_countExternalRequests(): number;
}
interface Session {
_init(): void;
}
interface TouchBar {
_removeFromWindow: (win: BaseWindow) => void;
@ -196,6 +200,14 @@ declare namespace Electron {
frameTreeNodeId?: number;
}
interface IpcMainServiceWorkerEvent {
_replyChannel: ReplyChannel;
}
interface IpcMainServiceWorkerInvokeEvent {
_replyChannel: ReplyChannel;
}
// Deprecated / undocumented BrowserWindow methods
interface BrowserWindow {
getURL(): string;
@ -271,11 +283,11 @@ declare namespace ElectronInternal {
invoke<T>(channel: string, ...args: any[]): Promise<T>;
}
interface IpcMainInternalEvent extends Omit<Electron.IpcMainEvent, 'reply'> {
}
type IpcMainInternalEvent = Omit<Electron.IpcMainEvent, 'reply'> | Omit<Electron.IpcMainServiceWorkerEvent, 'reply'>;
type IpcMainInternalInvokeEvent = Electron.IpcMainInvokeEvent | Electron.IpcMainServiceWorkerInvokeEvent;
interface IpcMainInternal extends NodeJS.EventEmitter {
handle(channel: string, listener: (event: Electron.IpcMainInvokeEvent, ...args: any[]) => Promise<any> | any): void;
handle(channel: string, listener: (event: IpcMainInternalInvokeEvent, ...args: any[]) => Promise<any> | any): void;
on(channel: string, listener: (event: IpcMainInternalEvent, ...args: any[]) => void): this;
once(channel: string, listener: (event: IpcMainInternalEvent, ...args: any[]) => void): this;
}