2019-02-06 18:27:20 +00:00
|
|
|
/// <reference path="../electron.d.ts" />
|
|
|
|
|
2020-10-13 01:29:08 +00:00
|
|
|
/**
|
2019-02-06 18:27:20 +00: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 07:05:49 +00:00
|
|
|
enum ProcessType {
|
|
|
|
browser = 'browser',
|
|
|
|
renderer = 'renderer',
|
|
|
|
worker = 'worker'
|
|
|
|
}
|
|
|
|
|
2019-02-06 18:27:20 +00:00
|
|
|
interface App {
|
|
|
|
setVersion(version: string): void;
|
|
|
|
setDesktopName(name: string): void;
|
|
|
|
setAppPath(path: string | null): void;
|
|
|
|
}
|
2019-02-14 07:05:49 +00:00
|
|
|
|
2020-07-16 18:37:38 +00:00
|
|
|
type TouchBarItemType = NonNullable<Electron.TouchBarConstructorOptions['items']>[0];
|
|
|
|
|
2020-10-08 01:01:23 +00:00
|
|
|
interface BaseWindow {
|
|
|
|
_init(): void;
|
|
|
|
}
|
|
|
|
|
2020-07-16 18:37:38 +00:00
|
|
|
interface BrowserWindow {
|
2020-10-08 01:01:23 +00:00
|
|
|
_init(): void;
|
2020-07-16 18:37:38 +00:00
|
|
|
_touchBar: Electron.TouchBar | null;
|
|
|
|
_setTouchBarItems: (items: TouchBarItemType[]) => void;
|
|
|
|
_setEscapeTouchBarItem: (item: TouchBarItemType | {}) => void;
|
|
|
|
_refreshTouchBarItem: (itemID: string) => void;
|
2021-01-19 10:12:09 +00:00
|
|
|
_getWindowButtonVisibility: () => boolean;
|
2020-10-02 18:18:42 +00:00
|
|
|
frameName: string;
|
2020-07-16 18:37:38 +00: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;
|
|
|
|
}
|
|
|
|
|
2021-01-29 20:41:59 +00:00
|
|
|
interface BrowserWindowConstructorOptions {
|
|
|
|
webContents?: WebContents;
|
|
|
|
}
|
|
|
|
|
2020-05-11 20:41:42 +00:00
|
|
|
interface ContextBridge {
|
2021-01-29 20:41:59 +00:00
|
|
|
internalContextBridge?: {
|
2020-05-11 20:41:42 +00: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 18:37:38 +00:00
|
|
|
interface TouchBar {
|
|
|
|
_removeFromWindow: (win: BrowserWindow) => void;
|
|
|
|
}
|
|
|
|
|
2019-07-17 17:23:52 +00:00
|
|
|
interface WebContents {
|
2020-10-08 01:01:23 +00:00
|
|
|
_loadURL(url: string, options: ElectronInternal.LoadURLOptions): void;
|
2021-07-27 05:48:12 +00:00
|
|
|
getOwnerBrowserWindow(): Electron.BrowserWindow | null;
|
|
|
|
getLastWebPreferences(): Electron.WebPreferences | null;
|
2021-10-05 22:30:31 +00:00
|
|
|
_getProcessMemoryInfo(): Electron.ProcessMemoryInfo;
|
2020-06-25 17:19:08 +00:00
|
|
|
_getPreloadPaths(): string[];
|
2020-06-29 01:22:55 +00:00
|
|
|
equal(other: WebContents): boolean;
|
2020-10-02 18:18:42 +00:00
|
|
|
browserWindowOptions: BrowserWindowConstructorOptions;
|
2021-04-13 19:35:27 +00:00
|
|
|
_windowOpenHandler: ((details: Electron.HandlerDetails) => any) | null;
|
|
|
|
_callWindowOpenHandler(event: any, details: Electron.HandlerDetails): Electron.BrowserWindowConstructorOptions | null;
|
2020-11-10 17:06:03 +00:00
|
|
|
_setNextChildWebPreferences(prefs: Partial<Electron.BrowserWindowConstructorOptions['webPreferences']> & Pick<Electron.BrowserWindowConstructorOptions, 'backgroundColor'>): void;
|
2020-12-03 06:55:50 +00:00
|
|
|
_send(internal: boolean, channel: string, args: any): boolean;
|
2020-12-09 20:48:16 +00:00
|
|
|
_sendToFrameInternal(frameId: number | [number, number], channel: string, ...args: any[]): boolean;
|
2019-03-13 19:03:17 +00:00
|
|
|
_sendInternal(channel: string, ...args: any[]): void;
|
2020-07-06 17:50:03 +00:00
|
|
|
_printToPDF(options: any): Promise<Buffer>;
|
|
|
|
_print(options: any, callback?: (success: boolean, failureReason: string) => void): void;
|
|
|
|
_getPrinters(): Electron.PrinterInfo[];
|
2021-10-25 18:16:58 +00:00
|
|
|
_getPrintersAsync(): Promise<Electron.PrinterInfo[]>;
|
2020-07-06 17:50:03 +00:00
|
|
|
_init(): void;
|
|
|
|
canGoToIndex(index: number): boolean;
|
|
|
|
getActiveIndex(): number;
|
|
|
|
length(): number;
|
2020-10-13 01:29:08 +00:00
|
|
|
destroy(): void;
|
|
|
|
// <webview>
|
|
|
|
attachToIframe(embedderWebContents: Electron.WebContents, embedderFrameId: number): void;
|
|
|
|
detachFromOuterFrame(): void;
|
|
|
|
setEmbedder(embedder: Electron.WebContents): void;
|
2022-01-12 07:41:20 +00:00
|
|
|
attachParams?: { instanceId: number; src: string, opts: LoadURLOptions };
|
2020-10-13 01:29:08 +00:00
|
|
|
viewInstanceId: number;
|
2019-03-13 19:03:17 +00:00
|
|
|
}
|
|
|
|
|
2021-01-15 00:00:37 +00: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-25 21:11:24 +00:00
|
|
|
interface WebFrame {
|
|
|
|
_isEvalAllowed(): boolean;
|
|
|
|
}
|
|
|
|
|
2020-10-02 02:52:29 +00:00
|
|
|
interface WebPreferences {
|
2020-10-13 01:29:08 +00:00
|
|
|
disablePopups?: boolean;
|
|
|
|
preloadURL?: string;
|
|
|
|
embedder?: Electron.WebContents;
|
|
|
|
type?: 'backgroundPage' | 'window' | 'browserView' | 'remote' | 'webview' | 'offscreen';
|
2020-10-02 02:52:29 +00:00
|
|
|
}
|
|
|
|
|
2020-07-06 20:24:54 +00: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 01:33:06 +00:00
|
|
|
_getSharingItemForCommandId(id: string): SharingItem | null;
|
2020-07-06 20:24:54 +00:00
|
|
|
_callMenuWillShow(): void;
|
|
|
|
_executeCommand(event: any, id: number): void;
|
|
|
|
_menuWillShow(): void;
|
|
|
|
commandsMap: Record<string, MenuItem>;
|
2021-06-03 05:59:56 +00:00
|
|
|
groupsMap: Record<string, MenuItem[]>;
|
2020-07-06 20:24:54 +00:00
|
|
|
getItemCount(): number;
|
|
|
|
popupAt(window: BaseWindow, x: number, y: number, positioning: number, callback: () => void): void;
|
|
|
|
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 14:58:03 +00:00
|
|
|
_getAcceleratorTextAt(index: number): string;
|
2020-07-06 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
interface MenuItem {
|
|
|
|
overrideReadOnlyProperty(property: string, value: any): void;
|
|
|
|
groupId: number;
|
|
|
|
getDefaultRoleAccelerator(): Accelerator | undefined;
|
2020-11-11 15:29:18 +00:00
|
|
|
getCheckStatus(): boolean;
|
2020-07-06 20:24:54 +00:00
|
|
|
acceleratorWorksWhenHidden?: boolean;
|
|
|
|
}
|
|
|
|
|
2021-01-29 20:41:59 +00:00
|
|
|
interface IpcMainEvent {
|
|
|
|
sendReply(value: any): void;
|
|
|
|
}
|
|
|
|
|
2020-10-08 01:01:23 +00:00
|
|
|
interface IpcMainInvokeEvent {
|
2021-01-29 20:41:59 +00:00
|
|
|
sendReply(value: any): void;
|
2020-10-08 01:01:23 +00:00
|
|
|
_reply(value: any): void;
|
2021-01-29 20:41:59 +00:00
|
|
|
_throw(error: Error | string): void;
|
2020-10-08 01:01:23 +00:00
|
|
|
}
|
2020-07-06 20:24:54 +00:00
|
|
|
|
2019-02-14 22:29:20 +00:00
|
|
|
const deprecate: ElectronInternal.DeprecationUtil;
|
2020-04-07 00:04:09 +00:00
|
|
|
|
|
|
|
namespace Main {
|
|
|
|
const deprecate: ElectronInternal.DeprecationUtil;
|
|
|
|
}
|
2020-05-22 19:46:22 +00:00
|
|
|
|
|
|
|
class View {}
|
2020-10-02 02:52:29 +00:00
|
|
|
|
2020-06-29 01:22:55 +00:00
|
|
|
// Experimental views API
|
2020-06-29 07:06:20 +00:00
|
|
|
class BaseWindow {
|
2020-06-29 01:22:55 +00:00
|
|
|
constructor(args: {show: boolean})
|
|
|
|
setContentView(view: View): void
|
2020-06-29 07:06:20 +00:00
|
|
|
static fromId(id: number): BaseWindow;
|
|
|
|
static getAllWindows(): BaseWindow[];
|
2020-06-29 01:22:55 +00:00
|
|
|
isFocused(): boolean;
|
2020-06-29 07:06:20 +00:00
|
|
|
static getFocusedWindow(): BaseWindow | undefined;
|
2020-07-06 20:24:54 +00:00
|
|
|
setMenu(menu: Menu): void;
|
2020-06-29 01:22:55 +00:00
|
|
|
}
|
|
|
|
class WebContentsView {
|
|
|
|
constructor(options: BrowserWindowConstructorOptions)
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace Main {
|
2020-06-29 07:06:20 +00:00
|
|
|
class BaseWindow extends Electron.BaseWindow {}
|
2020-06-29 01:22:55 +00:00
|
|
|
class View extends Electron.View {}
|
|
|
|
class WebContentsView extends Electron.WebContentsView {}
|
|
|
|
}
|
2019-02-14 22:29:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
declare namespace ElectronInternal {
|
|
|
|
type DeprecationHandler = (message: string) => void;
|
|
|
|
interface DeprecationUtil {
|
2019-05-23 22:31:38 +00:00
|
|
|
warnOnce(oldName: string, newName?: string): () => void;
|
2019-09-04 18:13:37 +00:00
|
|
|
setHandler(handler: DeprecationHandler | null): void;
|
2019-02-14 22:29:20 +00:00
|
|
|
getHandler(): DeprecationHandler | null;
|
|
|
|
warn(oldName: string, newName: string): void;
|
|
|
|
log(message: string): void;
|
2020-10-08 01:01:23 +00:00
|
|
|
removeFunction<T extends Function>(fn: T, removedName: string): T;
|
|
|
|
renameFunction<T extends Function>(fn: T, newName: string): T;
|
2019-02-14 22:29:20 +00:00
|
|
|
event(emitter: NodeJS.EventEmitter, oldName: string, newName: string): void;
|
2020-02-26 22:03:52 +00:00
|
|
|
removeProperty<T, K extends (keyof T & string)>(object: T, propertyName: K, onlyForValues?: any[]): T;
|
2019-02-14 22:29:20 +00:00
|
|
|
renameProperty<T, K extends (keyof T & string)>(object: T, oldName: string, newName: K): T;
|
2020-06-30 19:49:08 +00:00
|
|
|
moveAPI<T extends Function>(fn: T, oldUsage: string, newUsage: string): T;
|
2019-02-14 22:29:20 +00:00
|
|
|
}
|
2019-02-19 09:24:19 +00:00
|
|
|
|
2019-06-15 10:44:18 +00:00
|
|
|
interface DesktopCapturer {
|
|
|
|
startHandling(captureWindow: boolean, captureScreen: boolean, thumbnailSize: Electron.Size, fetchWindowIcons: boolean): void;
|
2020-08-24 18:23:25 +00:00
|
|
|
_onerror?: (error: string) => void;
|
|
|
|
_onfinished?: (sources: Electron.DesktopCapturerSource[], fetchWindowIcons: boolean) => void;
|
2019-06-15 10:44:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
interface GetSourcesOptions {
|
|
|
|
captureWindow: boolean;
|
|
|
|
captureScreen: boolean;
|
|
|
|
thumbnailSize: Electron.Size;
|
|
|
|
fetchWindowIcons: boolean;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface GetSourcesResult {
|
|
|
|
id: string;
|
|
|
|
name: string;
|
2020-05-13 17:05:53 +00:00
|
|
|
thumbnail: Electron.NativeImage;
|
2019-06-15 10:44:18 +00:00
|
|
|
display_id: string;
|
2020-05-13 17:05:53 +00:00
|
|
|
appIcon: Electron.NativeImage | null;
|
2019-06-15 10:44:18 +00:00
|
|
|
}
|
|
|
|
|
2021-06-18 04:26:18 +00:00
|
|
|
interface IpcRendererInternal extends NodeJS.EventEmitter, Pick<Electron.IpcRenderer, 'send' | 'sendSync' | 'invoke'> {
|
2020-10-02 02:52:29 +00:00
|
|
|
invoke<T>(channel: string, ...args: any[]): Promise<T>;
|
2019-11-21 12:32:31 +00:00
|
|
|
}
|
|
|
|
|
2019-02-19 09:24:19 +00:00
|
|
|
interface IpcMainInternalEvent extends Omit<Electron.IpcMainEvent, 'reply'> {
|
|
|
|
}
|
|
|
|
|
2019-05-06 15:29:01 +00:00
|
|
|
interface IpcMainInternal extends NodeJS.EventEmitter {
|
2019-08-23 22:45:50 +00:00
|
|
|
handle(channel: string, listener: (event: Electron.IpcMainInvokeEvent, ...args: any[]) => Promise<any> | any): void;
|
2019-02-19 09:24:19 +00:00
|
|
|
on(channel: string, listener: (event: IpcMainInternalEvent, ...args: any[]) => void): this;
|
|
|
|
once(channel: string, listener: (event: IpcMainInternalEvent, ...args: any[]) => void): this;
|
|
|
|
}
|
2019-03-07 23:26:23 +00:00
|
|
|
|
2021-01-29 20:41:59 +00:00
|
|
|
interface Event extends Electron.Event {
|
|
|
|
sender: WebContents;
|
|
|
|
}
|
|
|
|
|
2020-10-08 01:01:23 +00:00
|
|
|
interface LoadURLOptions extends Electron.LoadURLOptions {
|
|
|
|
reloadIgnoringCache?: boolean;
|
|
|
|
}
|
|
|
|
|
2021-01-29 20:41:59 +00:00
|
|
|
interface WebContentsPrintOptions extends Electron.WebContentsPrintOptions {
|
|
|
|
mediaSize?: MediaSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
type MediaSize = {
|
|
|
|
name: string,
|
|
|
|
custom_display_name: string,
|
|
|
|
height_microns: number,
|
|
|
|
width_microns: number,
|
|
|
|
is_default?: 'true',
|
|
|
|
}
|
|
|
|
|
2019-08-23 09:18:58 +00:00
|
|
|
type ModuleLoader = () => any;
|
|
|
|
|
|
|
|
interface ModuleEntry {
|
|
|
|
name: string;
|
|
|
|
private?: boolean;
|
|
|
|
loader: ModuleLoader;
|
|
|
|
}
|
|
|
|
|
2020-03-19 23:55:49 +00:00
|
|
|
class WebViewElement extends HTMLElement {
|
2019-03-07 23:26:23 +00:00
|
|
|
static observedAttributes: Array<string>;
|
|
|
|
|
|
|
|
public contentWindow: Window;
|
|
|
|
|
2020-08-24 18:23:25 +00:00
|
|
|
public connectedCallback?(): void;
|
|
|
|
public attributeChangedCallback?(): void;
|
|
|
|
public disconnectedCallback?(): void;
|
2019-03-07 23:26:23 +00:00
|
|
|
|
|
|
|
// Created in web-view-impl
|
2019-03-26 01:57:27 +00:00
|
|
|
public getWebContentsId(): number;
|
2019-11-12 20:56:17 +00:00
|
|
|
public capturePage(rect?: Electron.Rectangle): Promise<Electron.NativeImage>;
|
2019-03-07 23:26:23 +00:00
|
|
|
}
|
2020-10-13 01:29:08 +00:00
|
|
|
|
|
|
|
class WebContents extends Electron.WebContents {
|
|
|
|
static create(opts: Electron.WebPreferences): Electron.WebContents;
|
|
|
|
}
|
2019-02-06 18:27:20 +00:00
|
|
|
}
|
2019-02-19 13:09:44 +00:00
|
|
|
|
|
|
|
declare namespace Chrome {
|
|
|
|
namespace Tabs {
|
2021-09-17 01:53:28 +00:00
|
|
|
// https://developer.chrome.com/docs/extensions/tabs#method-executeScript
|
2019-02-19 13:09:44 +00: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 01:53:28 +00:00
|
|
|
// https://developer.chrome.com/docs/extensions/tabs#method-sendMessage
|
2019-02-19 13:09:44 +00:00
|
|
|
interface SendMessageDetails {
|
|
|
|
frameId?: number;
|
|
|
|
}
|
|
|
|
|
|
|
|
type SendMessageCallback = (result: any) => void;
|
|
|
|
}
|
|
|
|
}
|
2019-02-19 17:05:14 +00:00
|
|
|
|
|
|
|
interface Global extends NodeJS.Global {
|
|
|
|
require: NodeRequire;
|
|
|
|
module: NodeModule;
|
|
|
|
__filename: string;
|
|
|
|
__dirname: string;
|
|
|
|
}
|