chore: convert guest-view-manager.js to TypeScript (#25825)

This commit is contained in:
Milan Burda 2020-10-13 03:29:08 +02:00 committed by GitHub
parent d78d7b3a55
commit f827acc3be
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 86 additions and 67 deletions

View file

@ -97,6 +97,11 @@ declare namespace NodeJS {
setListeningForShutdown(listening: boolean): void;
}
interface WebViewManagerBinding {
addGuest(guestInstanceId: number, elementInstanceId: number, embedder: Electron.WebContents, guest: Electron.WebContents, webPreferences: Electron.WebPreferences): void;
removeGuest(embedder: Electron.WebContents, guestInstanceId: number): void;
}
type DataPipe = {
write: (buf: Uint8Array) => Promise<void>;
done: () => void;
@ -202,6 +207,7 @@ declare namespace NodeJS {
_linkedBinding(name: 'electron_browser_tray'): { Tray: Electron.Tray };
_linkedBinding(name: 'electron_browser_view'): { View: Electron.View };
_linkedBinding(name: 'electron_browser_web_contents_view'): { WebContentsView: typeof Electron.WebContentsView };
_linkedBinding(name: 'electron_browser_web_view_manager'): WebViewManagerBinding;
_linkedBinding(name: 'electron_renderer_crash_reporter'): Electron.CrashReporter;
_linkedBinding(name: 'electron_renderer_ipc'): { ipc: IpcRendererBinding };
log: NodeJS.WriteStream['write'];

View file

@ -1,6 +1,6 @@
/// <reference path="../electron.d.ts" />
/**
/**
* This file augments the Electron TS namespace with the internal APIs
* that are not documented but are used by Electron internally
*/
@ -77,6 +77,13 @@ declare namespace Electron {
canGoToIndex(index: number): boolean;
getActiveIndex(): number;
length(): number;
destroy(): void;
// <webview>
attachToIframe(embedderWebContents: Electron.WebContents, embedderFrameId: number): void;
detachFromOuterFrame(): void;
setEmbedder(embedder: Electron.WebContents): void;
attachParams?: Record<string, any>;
viewInstanceId: number;
}
interface WebFrame {
@ -87,7 +94,10 @@ declare namespace Electron {
interface WebPreferences {
guestInstanceId?: number;
openerId?: number;
disablePopups?: boolean
disablePopups?: boolean;
preloadURL?: string;
embedder?: Electron.WebContents;
type?: 'backgroundPage' | 'window' | 'browserView' | 'remote' | 'webview' | 'offscreen';
}
interface Menu {
@ -266,6 +276,10 @@ declare namespace ElectronInternal {
public getWebContentsId(): number;
public capturePage(rect?: Electron.Rectangle): Promise<Electron.NativeImage>;
}
class WebContents extends Electron.WebContents {
static create(opts: Electron.WebPreferences): Electron.WebContents;
}
}
declare namespace Chrome {