refactor: tweak bindings in typings/internal-ambient.d.ts for readability (#38411)

Co-authored-by: Milan Burda <miburda@microsoft.com>
This commit is contained in:
Milan Burda 2023-05-25 14:53:23 +02:00 коммит произвёл GitHub
Родитель 470b1d9e9d
Коммит 185180a8e2
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 46 добавлений и 38 удалений

84
typings/internal-ambient.d.ts поставляемый
Просмотреть файл

@ -34,6 +34,17 @@ declare namespace NodeJS {
triggerFatalErrorForTesting(): void;
}
type CrashReporterBinding = Omit<Electron.CrashReporter, 'start'> & {
start(submitUrl: string,
uploadToServer: boolean,
ignoreSystemCrashHandler: boolean,
rateLimit: boolean,
compress: boolean,
globalExtra: Record<string, string>,
extra: Record<string, string>,
isNodeProcess: boolean): void;
}
interface EnvironmentBinding {
getVar(name: string): string | null;
hasVar(name: string): boolean;
@ -80,16 +91,43 @@ declare namespace NodeJS {
initAsarSupport(require: NodeJS.Require): void;
}
interface NetBinding {
isOnline(): boolean;
isValidHeaderName: (headerName: string) => boolean;
isValidHeaderValue: (headerValue: string) => boolean;
fileURLToFilePath: (url: string) => string;
Net: any;
net: any;
createURLLoader(options: CreateURLLoaderOptions): URLLoader;
}
interface NotificationBinding {
isSupported(): boolean;
Notification: typeof Electron.Notification;
}
interface PowerMonitorBinding extends Electron.PowerMonitor {
createPowerMonitor(): PowerMonitorBinding;
setListeningForShutdown(listening: boolean): void;
}
interface SessionBinding {
fromPartition: typeof Electron.Session.fromPartition,
fromPath: typeof Electron.Session.fromPath,
Session: typeof Electron.Session
}
interface WebViewManagerBinding {
addGuest(guestInstanceId: number, embedder: Electron.WebContents, guest: Electron.WebContents, webPreferences: Electron.WebPreferences): void;
removeGuest(embedder: Electron.WebContents, guestInstanceId: number): void;
}
interface WebFrameMainBinding {
WebFrameMain: typeof Electron.WebFrameMain;
fromId(processId: number, routingId: number): Electron.WebFrameMain;
fromIdOrNull(processId: number, routingId: number): Electron.WebFrameMain | null;
}
interface InternalWebPreferences {
isWebView: boolean;
hiddenPage: boolean;
@ -174,58 +212,28 @@ declare namespace NodeJS {
_linkedBinding(name: 'electron_browser_app'): { app: Electron.App, App: Function };
_linkedBinding(name: 'electron_browser_auto_updater'): { autoUpdater: Electron.AutoUpdater };
_linkedBinding(name: 'electron_browser_browser_view'): { BrowserView: typeof Electron.BrowserView };
_linkedBinding(name: 'electron_browser_crash_reporter'): Omit<Electron.CrashReporter, 'start'> & {
start(submitUrl: string,
uploadToServer: boolean,
ignoreSystemCrashHandler: boolean,
rateLimit: boolean,
compress: boolean,
globalExtra: Record<string, string>,
extra: Record<string, string>,
isNodeProcess: boolean): void;
};
_linkedBinding(name: 'electron_browser_desktop_capturer'): {
createDesktopCapturer(): ElectronInternal.DesktopCapturer;
};
_linkedBinding(name: 'electron_browser_event_emitter'): {
setEventEmitterPrototype(prototype: Object): void;
};
_linkedBinding(name: 'electron_browser_crash_reporter'): CrashReporterBinding;
_linkedBinding(name: 'electron_browser_desktop_capturer'): { createDesktopCapturer(): ElectronInternal.DesktopCapturer; };
_linkedBinding(name: 'electron_browser_event_emitter'): { setEventEmitterPrototype(prototype: Object): void; };
_linkedBinding(name: 'electron_browser_global_shortcut'): { globalShortcut: Electron.GlobalShortcut };
_linkedBinding(name: 'electron_browser_image_view'): { ImageView: any };
_linkedBinding(name: 'electron_browser_in_app_purchase'): { inAppPurchase: Electron.InAppPurchase };
_linkedBinding(name: 'electron_browser_message_port'): {
createPair(): { port1: Electron.MessagePortMain, port2: Electron.MessagePortMain };
};
_linkedBinding(name: 'electron_browser_message_port'): { createPair(): { port1: Electron.MessagePortMain, port2: Electron.MessagePortMain }; };
_linkedBinding(name: 'electron_browser_native_theme'): { nativeTheme: Electron.NativeTheme };
_linkedBinding(name: 'electron_browser_net'): {
isOnline(): boolean;
isValidHeaderName: (headerName: string) => boolean;
isValidHeaderValue: (headerValue: string) => boolean;
fileURLToFilePath: (url: string) => string;
Net: any;
net: any;
createURLLoader(options: CreateURLLoaderOptions): URLLoader;
};
_linkedBinding(name: 'electron_browser_notification'): {
isSupported(): boolean;
Notification: typeof Electron.Notification;
}
_linkedBinding(name: 'electron_browser_net'): NetBinding;
_linkedBinding(name: 'electron_browser_notification'): NotificationBinding;
_linkedBinding(name: 'electron_browser_power_monitor'): PowerMonitorBinding;
_linkedBinding(name: 'electron_browser_power_save_blocker'): { powerSaveBlocker: Electron.PowerSaveBlocker };
_linkedBinding(name: 'electron_browser_push_notifications'): { pushNotifications: Electron.PushNotifications };
_linkedBinding(name: 'electron_browser_safe_storage'): { safeStorage: Electron.SafeStorage };
_linkedBinding(name: 'electron_browser_session'): {fromPartition: typeof Electron.Session.fromPartition, fromPath: typeof Electron.Session.fromPath, Session: typeof Electron.Session};
_linkedBinding(name: 'electron_browser_session'): SessionBinding;
_linkedBinding(name: 'electron_browser_screen'): { createScreen(): Electron.Screen };
_linkedBinding(name: 'electron_browser_system_preferences'): { systemPreferences: Electron.SystemPreferences };
_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_browser_web_frame_main'): {
WebFrameMain: typeof Electron.WebFrameMain;
fromId(processId: number, routingId: number): Electron.WebFrameMain;
fromIdOrNull(processId: number, routingId: number): Electron.WebFrameMain | null;
}
_linkedBinding(name: 'electron_browser_web_frame_main'): WebFrameMainBinding;
_linkedBinding(name: 'electron_renderer_crash_reporter'): Electron.CrashReporter;
_linkedBinding(name: 'electron_renderer_ipc'): { ipc: IpcRendererBinding };
_linkedBinding(name: 'electron_renderer_web_frame'): WebFrameBinding;