2019-02-06 21:27:20 +03:00
|
|
|
/// <reference path="../electron.d.ts" />
|
|
|
|
|
2020-10-13 04:29:08 +03:00
|
|
|
/**
|
2019-02-06 21:27:20 +03:00
|
|
|
* This file augments the Electron TS namespace with the internal APIs
|
|
|
|
* that are not documented but are used by Electron internally
|
|
|
|
*/
|
|
|
|
|
|
|
|
declare namespace Electron {
|
2019-02-14 10:05:49 +03:00
|
|
|
enum ProcessType {
|
|
|
|
browser = 'browser',
|
|
|
|
renderer = 'renderer',
|
2022-10-20 08:49:49 +03:00
|
|
|
worker = 'worker',
|
|
|
|
utility = 'utility'
|
2019-02-14 10:05:49 +03:00
|
|
|
}
|
|
|
|
|
2019-02-06 21:27:20 +03:00
|
|
|
interface App {
|
|
|
|
setVersion(version: string): void;
|
|
|
|
setDesktopName(name: string): void;
|
|
|
|
setAppPath(path: string | null): void;
|
|
|
|
}
|
2019-02-14 10:05:49 +03:00
|
|
|
|
2023-09-11 21:54:51 +03:00
|
|
|
interface AutoUpdater {
|
2023-10-25 21:02:15 +03:00
|
|
|
isVersionAllowedForUpdate?(currentVersion: string, targetVersion: string): boolean;
|
2023-09-11 21:54:51 +03:00
|
|
|
}
|
|
|
|
|
2020-07-16 21:37:38 +03:00
|
|
|
type TouchBarItemType = NonNullable<Electron.TouchBarConstructorOptions['items']>[0];
|
|
|
|
|
2020-10-08 04:01:23 +03:00
|
|
|
interface BaseWindow {
|
|
|
|
_init(): void;
|
2020-07-16 21:37:38 +03:00
|
|
|
_touchBar: Electron.TouchBar | null;
|
|
|
|
_setTouchBarItems: (items: TouchBarItemType[]) => void;
|
|
|
|
_setEscapeTouchBarItem: (item: TouchBarItemType | {}) => void;
|
|
|
|
_refreshTouchBarItem: (itemID: string) => void;
|
2024-08-22 16:43:51 +03:00
|
|
|
on(event: '-touch-bar-interaction', listener: (event: Event, itemID: string, details: any) => void): this;
|
|
|
|
removeListener(event: '-touch-bar-interaction', listener: (event: Event, itemID: string, details: any) => void): this;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface BrowserWindow extends BaseWindow {
|
|
|
|
_init(): void;
|
2021-01-19 13:12:09 +03:00
|
|
|
_getWindowButtonVisibility: () => boolean;
|
2023-09-05 05:22:41 +03:00
|
|
|
_getAlwaysOnTopLevel: () => string;
|
|
|
|
devToolsWebContents: WebContents;
|
2020-10-02 21:18:42 +03:00
|
|
|
frameName: string;
|
2024-08-22 16:43:51 +03:00
|
|
|
_browserViews: BrowserView[];
|
2020-07-16 21:37:38 +03:00
|
|
|
on(event: '-touch-bar-interaction', listener: (event: Event, itemID: string, details: any) => void): this;
|
|
|
|
removeListener(event: '-touch-bar-interaction', listener: (event: Event, itemID: string, details: any) => void): this;
|
2023-12-14 00:01:03 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
interface BrowserView {
|
|
|
|
ownerWindow: BrowserWindow | null
|
|
|
|
webContentsView: WebContentsView
|
2020-07-16 21:37:38 +03:00
|
|
|
}
|
|
|
|
|
2021-01-29 23:41:59 +03:00
|
|
|
interface BrowserWindowConstructorOptions {
|
|
|
|
webContents?: WebContents;
|
|
|
|
}
|
|
|
|
|
2020-05-11 23:41:42 +03:00
|
|
|
interface ContextBridge {
|
2021-01-29 23:41:59 +03:00
|
|
|
internalContextBridge?: {
|
2020-05-11 23:41:42 +03:00
|
|
|
contextIsolationEnabled: boolean;
|
|
|
|
overrideGlobalValueFromIsolatedWorld(keys: string[], value: any): void;
|
|
|
|
overrideGlobalValueWithDynamicPropsFromIsolatedWorld(keys: string[], value: any): void;
|
|
|
|
overrideGlobalPropertyFromIsolatedWorld(keys: string[], getter: Function, setter?: Function): void;
|
|
|
|
isInMainWorld(): boolean;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-16 21:37:38 +03:00
|
|
|
interface TouchBar {
|
2024-08-22 16:43:51 +03:00
|
|
|
_removeFromWindow: (win: BaseWindow) => void;
|
2020-07-16 21:37:38 +03:00
|
|
|
}
|
|
|
|
|
2019-07-17 20:23:52 +03:00
|
|
|
interface WebContents {
|
2020-10-08 04:01:23 +03:00
|
|
|
_loadURL(url: string, options: ElectronInternal.LoadURLOptions): void;
|
2021-07-27 08:48:12 +03:00
|
|
|
getOwnerBrowserWindow(): Electron.BrowserWindow | null;
|
|
|
|
getLastWebPreferences(): Electron.WebPreferences | null;
|
2021-10-06 01:30:31 +03:00
|
|
|
_getProcessMemoryInfo(): Electron.ProcessMemoryInfo;
|
2020-06-25 20:19:08 +03:00
|
|
|
_getPreloadPaths(): string[];
|
2020-06-29 04:22:55 +03:00
|
|
|
equal(other: WebContents): boolean;
|
2020-10-02 21:18:42 +03:00
|
|
|
browserWindowOptions: BrowserWindowConstructorOptions;
|
2021-04-13 22:35:27 +03:00
|
|
|
_windowOpenHandler: ((details: Electron.HandlerDetails) => any) | null;
|
2022-02-23 10:59:50 +03:00
|
|
|
_callWindowOpenHandler(event: any, details: Electron.HandlerDetails): {browserWindowConstructorOptions: Electron.BrowserWindowConstructorOptions | null, outlivesOpener: boolean};
|
2020-11-10 20:06:03 +03:00
|
|
|
_setNextChildWebPreferences(prefs: Partial<Electron.BrowserWindowConstructorOptions['webPreferences']> & Pick<Electron.BrowserWindowConstructorOptions, 'backgroundColor'>): void;
|
2020-12-03 09:55:50 +03:00
|
|
|
_send(internal: boolean, channel: string, args: any): boolean;
|
2019-03-13 22:03:17 +03:00
|
|
|
_sendInternal(channel: string, ...args: any[]): void;
|
2020-07-06 20:50:03 +03:00
|
|
|
_printToPDF(options: any): Promise<Buffer>;
|
|
|
|
_print(options: any, callback?: (success: boolean, failureReason: string) => void): void;
|
2021-10-25 21:16:58 +03:00
|
|
|
_getPrintersAsync(): Promise<Electron.PrinterInfo[]>;
|
2020-07-06 20:50:03 +03:00
|
|
|
_init(): void;
|
2024-04-05 20:59:46 +03:00
|
|
|
_getNavigationEntryAtIndex(index: number): Electron.EntryAtIndex | null;
|
|
|
|
_getActiveIndex(): number;
|
|
|
|
_historyLength(): number;
|
2020-07-06 20:50:03 +03:00
|
|
|
canGoToIndex(index: number): boolean;
|
2020-10-13 04:29:08 +03:00
|
|
|
destroy(): void;
|
|
|
|
// <webview>
|
|
|
|
attachToIframe(embedderWebContents: Electron.WebContents, embedderFrameId: number): void;
|
|
|
|
detachFromOuterFrame(): void;
|
|
|
|
setEmbedder(embedder: Electron.WebContents): void;
|
|
|
|
viewInstanceId: number;
|
2023-12-14 00:01:03 +03:00
|
|
|
_setOwnerWindow(w: BaseWindow | null): void;
|
2019-03-13 22:03:17 +03:00
|
|
|
}
|
|
|
|
|
2021-01-15 03:00:37 +03:00
|
|
|
interface WebFrameMain {
|
|
|
|
_send(internal: boolean, channel: string, args: any): void;
|
|
|
|
_sendInternal(channel: string, ...args: any[]): void;
|
|
|
|
_postMessage(channel: string, message: any, transfer?: any[]): void;
|
|
|
|
}
|
|
|
|
|
2021-10-26 00:11:24 +03:00
|
|
|
interface WebFrame {
|
|
|
|
_isEvalAllowed(): boolean;
|
|
|
|
}
|
|
|
|
|
2020-10-02 05:52:29 +03:00
|
|
|
interface WebPreferences {
|
2020-10-13 04:29:08 +03:00
|
|
|
disablePopups?: boolean;
|
|
|
|
embedder?: Electron.WebContents;
|
|
|
|
type?: 'backgroundPage' | 'window' | 'browserView' | 'remote' | 'webview' | 'offscreen';
|
2020-10-02 05:52:29 +03:00
|
|
|
}
|
|
|
|
|
2020-07-06 23:24:54 +03:00
|
|
|
interface Menu {
|
|
|
|
_init(): void;
|
|
|
|
_isCommandIdChecked(id: string): boolean;
|
|
|
|
_isCommandIdEnabled(id: string): boolean;
|
|
|
|
_shouldCommandIdWorkWhenHidden(id: string): boolean;
|
|
|
|
_isCommandIdVisible(id: string): boolean;
|
|
|
|
_getAcceleratorForCommandId(id: string, useDefaultAccelerator: boolean): Accelerator | undefined;
|
|
|
|
_shouldRegisterAcceleratorForCommandId(id: string): boolean;
|
2020-10-20 04:33:06 +03:00
|
|
|
_getSharingItemForCommandId(id: string): SharingItem | null;
|
2020-07-06 23:24:54 +03:00
|
|
|
_callMenuWillShow(): void;
|
2023-02-14 00:39:18 +03:00
|
|
|
_executeCommand(event: KeyboardEvent, id: number): void;
|
2020-07-06 23:24:54 +03:00
|
|
|
_menuWillShow(): void;
|
|
|
|
commandsMap: Record<string, MenuItem>;
|
2021-06-03 08:59:56 +03:00
|
|
|
groupsMap: Record<string, MenuItem[]>;
|
2020-07-06 23:24:54 +03:00
|
|
|
getItemCount(): number;
|
2023-06-30 01:54:06 +03:00
|
|
|
popupAt(window: BaseWindow, x: number, y: number, positioning: number, sourceType: Required<Electron.PopupOptions>['sourceType'], callback: () => void): void;
|
2020-07-06 23:24:54 +03:00
|
|
|
closePopupAt(id: number): void;
|
|
|
|
setSublabel(index: number, label: string): void;
|
|
|
|
setToolTip(index: number, tooltip: string): void;
|
|
|
|
setIcon(index: number, image: string | NativeImage): void;
|
|
|
|
setRole(index: number, role: string): void;
|
|
|
|
insertItem(index: number, commandId: number, label: string): void;
|
|
|
|
insertCheckItem(index: number, commandId: number, label: string): void;
|
|
|
|
insertRadioItem(index: number, commandId: number, label: string, groupId: number): void;
|
|
|
|
insertSeparator(index: number): void;
|
|
|
|
insertSubMenu(index: number, commandId: number, label: string, submenu?: Menu): void;
|
|
|
|
delegate?: any;
|
2021-09-27 17:58:03 +03:00
|
|
|
_getAcceleratorTextAt(index: number): string;
|
2020-07-06 23:24:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
interface MenuItem {
|
|
|
|
overrideReadOnlyProperty(property: string, value: any): void;
|
|
|
|
groupId: number;
|
|
|
|
getDefaultRoleAccelerator(): Accelerator | undefined;
|
2020-11-11 18:29:18 +03:00
|
|
|
getCheckStatus(): boolean;
|
2020-07-06 23:24:54 +03:00
|
|
|
acceleratorWorksWhenHidden?: boolean;
|
|
|
|
}
|
|
|
|
|
2023-02-14 00:39:18 +03:00
|
|
|
interface ReplyChannel {
|
2021-01-29 23:41:59 +03:00
|
|
|
sendReply(value: any): void;
|
|
|
|
}
|
|
|
|
|
2023-02-14 00:39:18 +03:00
|
|
|
interface IpcMainEvent {
|
|
|
|
_replyChannel: ReplyChannel;
|
|
|
|
}
|
|
|
|
|
2020-10-08 04:01:23 +03:00
|
|
|
interface IpcMainInvokeEvent {
|
2023-02-14 00:39:18 +03:00
|
|
|
_replyChannel: ReplyChannel;
|
2020-10-08 04:01:23 +03:00
|
|
|
}
|
2020-07-06 23:24:54 +03:00
|
|
|
|
2020-06-29 04:22:55 +03:00
|
|
|
// Deprecated / undocumented BrowserWindow methods
|
|
|
|
interface BrowserWindow {
|
|
|
|
getURL(): string;
|
|
|
|
send(channel: string, ...args: any[]): void;
|
|
|
|
openDevTools(options?: Electron.OpenDevToolsOptions): void;
|
|
|
|
closeDevTools(): void;
|
|
|
|
isDevToolsOpened(): void;
|
|
|
|
isDevToolsFocused(): void;
|
|
|
|
toggleDevTools(): void;
|
|
|
|
inspectElement(x: number, y: number): void;
|
|
|
|
inspectSharedWorker(): void;
|
|
|
|
inspectServiceWorker(): void;
|
|
|
|
getBackgroundThrottling(): void;
|
|
|
|
setBackgroundThrottling(allowed: boolean): void;
|
|
|
|
}
|
|
|
|
|
2023-03-27 20:00:55 +03:00
|
|
|
interface Protocol {
|
|
|
|
registerProtocol(scheme: string, handler: any): boolean;
|
|
|
|
interceptProtocol(scheme: string, handler: any): boolean;
|
|
|
|
}
|
2024-10-01 23:14:37 +03:00
|
|
|
|
|
|
|
interface WebContents {
|
|
|
|
on(event: '-new-window', listener: (event: Electron.Event, url: string, frameName: string, disposition: Electron.HandlerDetails['disposition'],
|
|
|
|
rawFeatures: string, referrer: Electron.Referrer, postData: LoadURLOptions['postData']) => void): this;
|
|
|
|
on(event: '-add-new-contents', listener: (event: Event, webContents: Electron.WebContents, disposition: string,
|
|
|
|
_userGesture: boolean, _left: number, _top: number, _width: number, _height: number, url: string, frameName: string,
|
|
|
|
referrer: Electron.Referrer, rawFeatures: string, postData: LoadURLOptions['postData']) => void): this;
|
|
|
|
on(event: '-will-add-new-contents', listener: (event: Electron.Event, url: string, frameName: string, rawFeatures: string, disposition: Electron.HandlerDetails['disposition'], referrer: Electron.Referrer, postData: LoadURLOptions['postData']) => void): this;
|
|
|
|
on(event: '-ipc-message', listener: (event: Electron.IpcMainEvent, internal: boolean, channel: string, args: any[]) => void): this;
|
|
|
|
on(event: '-ipc-message-sync', listener: (event: Electron.IpcMainEvent, internal: boolean, channel: string, args: any[]) => void): this;
|
|
|
|
on(event: '-ipc-invoke', listener: (event: Electron.IpcMainInvokeEvent, internal: boolean, channel: string, args: any[]) => void): this;
|
|
|
|
on(event: '-ipc-ports', listener: (event: Electron.IpcMainEvent, internal: boolean, channel: string, message: any, ports: any[]) => void): this;
|
|
|
|
on(event: '-run-dialog', listener: (info: {frame: WebFrameMain, dialogType: 'prompt' | 'confirm' | 'alert', messageText: string, defaultPromptText: string}, callback: (success: boolean, user_input: string) => void) => void): this;
|
|
|
|
on(event: '-cancel-dialogs', listener: () => void): this;
|
|
|
|
on(event: 'ready-to-show', listener: () => void): this;
|
|
|
|
on(event: '-before-unload-fired', listener: (event: Electron.Event, proceed: boolean) => void): this;
|
|
|
|
|
|
|
|
on(event: '-window-visibility-change', listener: (visibilityState: 'hidden' | 'visible') => void): this;
|
|
|
|
removeListener(event: '-window-visibility-change', listener: (visibilityState: 'hidden' | 'visible') => void): this;
|
|
|
|
|
|
|
|
once(event: 'destroyed', listener: (event: Electron.Event) => void): this;
|
|
|
|
}
|
2019-02-15 01:29:20 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
declare namespace ElectronInternal {
|
2019-06-15 13:44:18 +03:00
|
|
|
interface DesktopCapturer {
|
|
|
|
startHandling(captureWindow: boolean, captureScreen: boolean, thumbnailSize: Electron.Size, fetchWindowIcons: boolean): void;
|
2020-08-24 21:23:25 +03:00
|
|
|
_onerror?: (error: string) => void;
|
|
|
|
_onfinished?: (sources: Electron.DesktopCapturerSource[], fetchWindowIcons: boolean) => void;
|
2019-06-15 13:44:18 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
interface GetSourcesOptions {
|
|
|
|
captureWindow: boolean;
|
|
|
|
captureScreen: boolean;
|
|
|
|
thumbnailSize: Electron.Size;
|
|
|
|
fetchWindowIcons: boolean;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface GetSourcesResult {
|
|
|
|
id: string;
|
|
|
|
name: string;
|
2020-05-13 20:05:53 +03:00
|
|
|
thumbnail: Electron.NativeImage;
|
2019-06-15 13:44:18 +03:00
|
|
|
display_id: string;
|
2020-05-13 20:05:53 +03:00
|
|
|
appIcon: Electron.NativeImage | null;
|
2019-06-15 13:44:18 +03:00
|
|
|
}
|
|
|
|
|
2021-06-18 07:26:18 +03:00
|
|
|
interface IpcRendererInternal extends NodeJS.EventEmitter, Pick<Electron.IpcRenderer, 'send' | 'sendSync' | 'invoke'> {
|
2020-10-02 05:52:29 +03:00
|
|
|
invoke<T>(channel: string, ...args: any[]): Promise<T>;
|
2019-11-21 15:32:31 +03:00
|
|
|
}
|
|
|
|
|
2019-02-19 12:24:19 +03:00
|
|
|
interface IpcMainInternalEvent extends Omit<Electron.IpcMainEvent, 'reply'> {
|
|
|
|
}
|
|
|
|
|
2019-05-06 18:29:01 +03:00
|
|
|
interface IpcMainInternal extends NodeJS.EventEmitter {
|
2019-08-24 01:45:50 +03:00
|
|
|
handle(channel: string, listener: (event: Electron.IpcMainInvokeEvent, ...args: any[]) => Promise<any> | any): void;
|
2019-02-19 12:24:19 +03:00
|
|
|
on(channel: string, listener: (event: IpcMainInternalEvent, ...args: any[]) => void): this;
|
|
|
|
once(channel: string, listener: (event: IpcMainInternalEvent, ...args: any[]) => void): this;
|
|
|
|
}
|
2019-03-08 02:26:23 +03:00
|
|
|
|
2020-10-08 04:01:23 +03:00
|
|
|
interface LoadURLOptions extends Electron.LoadURLOptions {
|
|
|
|
reloadIgnoringCache?: boolean;
|
|
|
|
}
|
|
|
|
|
2021-01-29 23:41:59 +03:00
|
|
|
interface WebContentsPrintOptions extends Electron.WebContentsPrintOptions {
|
|
|
|
mediaSize?: MediaSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
type MediaSize = {
|
|
|
|
name: string,
|
|
|
|
custom_display_name: string,
|
|
|
|
height_microns: number,
|
|
|
|
width_microns: number,
|
2023-06-09 22:41:01 +03:00
|
|
|
imageable_area_left_microns?: number,
|
|
|
|
imageable_area_bottom_microns?: number,
|
|
|
|
imageable_area_right_microns?: number,
|
|
|
|
imageable_area_top_microns?: number,
|
2021-01-29 23:41:59 +03:00
|
|
|
is_default?: 'true',
|
|
|
|
}
|
|
|
|
|
2022-05-31 09:21:25 +03:00
|
|
|
type PageSize = {
|
|
|
|
width: number,
|
|
|
|
height: number,
|
|
|
|
}
|
|
|
|
|
2019-08-23 12:18:58 +03:00
|
|
|
type ModuleLoader = () => any;
|
|
|
|
|
|
|
|
interface ModuleEntry {
|
|
|
|
name: string;
|
|
|
|
loader: ModuleLoader;
|
|
|
|
}
|
|
|
|
|
2022-10-20 08:49:49 +03:00
|
|
|
interface UtilityProcessWrapper extends NodeJS.EventEmitter {
|
|
|
|
readonly pid: (number) | (undefined);
|
|
|
|
kill(): boolean;
|
|
|
|
postMessage(message: any, transfer?: any[]): void;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface ParentPort extends NodeJS.EventEmitter {
|
|
|
|
start(): void;
|
|
|
|
pause(): void;
|
|
|
|
postMessage(message: any): void;
|
|
|
|
}
|
|
|
|
|
2020-03-20 02:55:49 +03:00
|
|
|
class WebViewElement extends HTMLElement {
|
2019-03-08 02:26:23 +03:00
|
|
|
static observedAttributes: Array<string>;
|
|
|
|
|
|
|
|
public contentWindow: Window;
|
|
|
|
|
2020-08-24 21:23:25 +03:00
|
|
|
public connectedCallback?(): void;
|
|
|
|
public attributeChangedCallback?(): void;
|
|
|
|
public disconnectedCallback?(): void;
|
2019-03-08 02:26:23 +03:00
|
|
|
|
|
|
|
// Created in web-view-impl
|
2019-03-26 04:57:27 +03:00
|
|
|
public getWebContentsId(): number;
|
2019-11-12 23:56:17 +03:00
|
|
|
public capturePage(rect?: Electron.Rectangle): Promise<Electron.NativeImage>;
|
2019-03-08 02:26:23 +03:00
|
|
|
}
|
2020-10-13 04:29:08 +03:00
|
|
|
|
|
|
|
class WebContents extends Electron.WebContents {
|
2023-02-16 17:41:41 +03:00
|
|
|
static create(opts?: Electron.WebPreferences): Electron.WebContents;
|
2020-10-13 04:29:08 +03:00
|
|
|
}
|
2019-02-06 21:27:20 +03:00
|
|
|
}
|
2019-02-19 16:09:44 +03:00
|
|
|
|
|
|
|
declare namespace Chrome {
|
|
|
|
namespace Tabs {
|
2021-09-17 04:53:28 +03:00
|
|
|
// https://developer.chrome.com/docs/extensions/tabs#method-executeScript
|
2019-02-19 16:09:44 +03:00
|
|
|
interface ExecuteScriptDetails {
|
|
|
|
code?: string;
|
|
|
|
file?: string;
|
|
|
|
allFrames?: boolean;
|
|
|
|
frameId?: number;
|
|
|
|
matchAboutBlank?: boolean;
|
|
|
|
runAt?: 'document-start' | 'document-end' | 'document_idle';
|
|
|
|
cssOrigin: 'author' | 'user';
|
|
|
|
}
|
|
|
|
|
|
|
|
type ExecuteScriptCallback = (result: Array<any>) => void;
|
|
|
|
|
2021-09-17 04:53:28 +03:00
|
|
|
// https://developer.chrome.com/docs/extensions/tabs#method-sendMessage
|
2019-02-19 16:09:44 +03:00
|
|
|
interface SendMessageDetails {
|
|
|
|
frameId?: number;
|
|
|
|
}
|
|
|
|
|
|
|
|
type SendMessageCallback = (result: any) => void;
|
|
|
|
}
|
|
|
|
}
|
2019-02-19 20:05:14 +03:00
|
|
|
|
|
|
|
interface Global extends NodeJS.Global {
|
|
|
|
require: NodeRequire;
|
|
|
|
module: NodeModule;
|
|
|
|
__filename: string;
|
|
|
|
__dirname: string;
|
|
|
|
}
|