2019-02-06 18:27:20 +00:00
|
|
|
/// <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
|
|
|
|
*/
|
|
|
|
|
|
|
|
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 {
|
2019-04-16 18:22:51 +00:00
|
|
|
_setDefaultAppPaths(packagePath: string | null): void;
|
2019-02-06 18:27:20 +00:00
|
|
|
setVersion(version: string): void;
|
|
|
|
setDesktopName(name: string): void;
|
|
|
|
setAppPath(path: string | null): void;
|
|
|
|
}
|
2019-02-14 07:05:49 +00:00
|
|
|
|
2020-05-11 20:41:42 +00:00
|
|
|
interface ContextBridge {
|
|
|
|
internalContextBridge: {
|
|
|
|
contextIsolationEnabled: boolean;
|
|
|
|
overrideGlobalValueFromIsolatedWorld(keys: string[], value: any): void;
|
|
|
|
overrideGlobalValueWithDynamicPropsFromIsolatedWorld(keys: string[], value: any): void;
|
|
|
|
overrideGlobalPropertyFromIsolatedWorld(keys: string[], getter: Function, setter?: Function): void;
|
|
|
|
isInMainWorld(): boolean;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-17 17:23:52 +00:00
|
|
|
interface WebContents {
|
|
|
|
_getURL(): string;
|
2020-07-06 17:50:03 +00:00
|
|
|
_loadURL(url: string, options: Electron.LoadURLOptions): void;
|
|
|
|
_stop(): void;
|
|
|
|
_goBack(): void;
|
|
|
|
_goForward(): void;
|
|
|
|
_goToOffset(offset: number): void;
|
2019-07-17 17:23:52 +00:00
|
|
|
getOwnerBrowserWindow(): Electron.BrowserWindow;
|
2020-07-06 17:50:03 +00:00
|
|
|
getWebPreferences(): Electron.WebPreferences;
|
2020-06-25 17:19:08 +00:00
|
|
|
getLastWebPreferences(): Electron.WebPreferences;
|
|
|
|
_getPreloadPaths(): string[];
|
2020-06-29 01:22:55 +00:00
|
|
|
equal(other: WebContents): boolean;
|
2020-06-25 17:19:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
interface WebPreferences {
|
|
|
|
guestInstanceId?: number;
|
|
|
|
openerId?: number;
|
2019-07-17 17:23:52 +00:00
|
|
|
}
|
|
|
|
|
2019-02-14 07:05:49 +00:00
|
|
|
interface SerializedError {
|
|
|
|
message: string;
|
|
|
|
stack?: string,
|
|
|
|
name: string,
|
|
|
|
from: Electron.ProcessType,
|
|
|
|
cause: SerializedError,
|
|
|
|
__ELECTRON_SERIALIZED_ERROR__: true
|
|
|
|
}
|
2019-02-14 22:29:20 +00:00
|
|
|
|
2019-07-17 17:23:52 +00:00
|
|
|
interface ErrorWithCause extends Error {
|
|
|
|
from?: string;
|
|
|
|
cause?: ErrorWithCause;
|
|
|
|
}
|
|
|
|
|
2019-02-18 12:47:07 +00:00
|
|
|
interface InjectionBase {
|
|
|
|
url: string;
|
|
|
|
code: string
|
|
|
|
}
|
|
|
|
|
|
|
|
interface ContentScript {
|
|
|
|
js: Array<InjectionBase>;
|
|
|
|
css: Array<InjectionBase>;
|
|
|
|
runAt: string;
|
|
|
|
matches: {
|
|
|
|
some: (input: (pattern: string) => boolean | RegExpMatchArray | null) => boolean;
|
|
|
|
}
|
2019-03-08 23:53:25 +00:00
|
|
|
/**
|
|
|
|
* Whether to match all frames, or only the top one.
|
|
|
|
* https://developer.chrome.com/extensions/content_scripts#frames
|
|
|
|
*/
|
|
|
|
allFrames: boolean
|
2019-02-18 12:47:07 +00:00
|
|
|
}
|
|
|
|
|
2019-06-19 15:23:44 +00:00
|
|
|
type ContentScriptEntry = {
|
|
|
|
extensionId: string;
|
|
|
|
contentScripts: ContentScript[];
|
|
|
|
}
|
|
|
|
|
2019-02-15 01:24:25 +00:00
|
|
|
interface IpcRendererInternal extends Electron.IpcRenderer {
|
2019-08-23 22:45:50 +00:00
|
|
|
invoke<T>(channel: string, ...args: any[]): Promise<T>;
|
2019-02-15 01:24:25 +00:00
|
|
|
sendToAll(webContentsId: number, channel: string, ...args: any[]): void
|
|
|
|
}
|
|
|
|
|
2019-03-13 19:03:17 +00:00
|
|
|
interface WebContentsInternal extends Electron.WebContents {
|
2020-07-06 17:50:03 +00:00
|
|
|
_send(internal: boolean, sendToAll: boolean, channel: string, args: any): boolean;
|
|
|
|
_sendToFrame(internal: boolean, sendToAll: boolean, frameId: number, channel: string, args: any): boolean;
|
|
|
|
_sendToFrameInternal(frameId: number, channel: string, args: any): boolean;
|
|
|
|
_postMessage(channel: string, message: any, transfer?: any[]): void;
|
2019-03-13 19:03:17 +00:00
|
|
|
_sendInternal(channel: string, ...args: any[]): void;
|
2019-03-26 02:38:35 +00:00
|
|
|
_sendInternalToAll(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[];
|
|
|
|
_init(): void;
|
|
|
|
canGoToIndex(index: number): boolean;
|
|
|
|
getActiveIndex(): number;
|
|
|
|
length(): number;
|
2019-03-13 19:03:17 +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;
|
|
|
|
_callMenuWillShow(): void;
|
|
|
|
_executeCommand(event: any, id: number): void;
|
|
|
|
_menuWillShow(): void;
|
|
|
|
commandsMap: Record<string, MenuItem>;
|
|
|
|
groupsMap: Record<string, {
|
|
|
|
checked: boolean;
|
|
|
|
}[]>;
|
|
|
|
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;
|
|
|
|
getAcceleratorTextAt(index: number): string;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface MenuItem {
|
|
|
|
overrideReadOnlyProperty(property: string, value: any): void;
|
|
|
|
groupId: number;
|
|
|
|
getDefaultRoleAccelerator(): Accelerator | undefined;
|
|
|
|
acceleratorWorksWhenHidden?: boolean;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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-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;
|
2019-07-09 01:01:35 +00:00
|
|
|
removeFunction(fn: Function, removedName: string): Function;
|
2019-09-04 18:13:37 +00:00
|
|
|
renameFunction(fn: Function, newName: string | Function): Function;
|
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-03-19 18:35:11 +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
|
|
|
}
|
|
|
|
|
2019-11-21 12:32:31 +00:00
|
|
|
interface KeyWeakMap<K, V> {
|
|
|
|
set(key: K, value: V): void;
|
|
|
|
get(key: K): V | undefined;
|
|
|
|
has(key: K): boolean;
|
|
|
|
remove(key: K): void;
|
|
|
|
}
|
|
|
|
|
2019-02-19 09:24:19 +00:00
|
|
|
// Internal IPC has _replyInternal and NO reply method
|
|
|
|
interface IpcMainInternalEvent extends Omit<Electron.IpcMainEvent, 'reply'> {
|
|
|
|
_replyInternal(...args: any[]): void;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2019-08-23 09:18:58 +00:00
|
|
|
type ModuleLoader = () => any;
|
|
|
|
|
|
|
|
interface ModuleEntry {
|
|
|
|
name: string;
|
|
|
|
private?: boolean;
|
|
|
|
loader: ModuleLoader;
|
|
|
|
}
|
|
|
|
|
2019-03-07 23:26:23 +00:00
|
|
|
interface WebFrameInternal extends Electron.WebFrame {
|
|
|
|
getWebFrameId(window: Window): number;
|
|
|
|
allowGuestViewElementDefinition(window: Window, context: any): void;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface WebFrameResizeEvent extends Electron.Event {
|
|
|
|
newWidth: number;
|
|
|
|
newHeight: number;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface WebViewEvent extends Event {
|
|
|
|
url: string;
|
|
|
|
isMainFrame: boolean;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
public connectedCallback(): void;
|
|
|
|
public attributeChangedCallback(): void;
|
|
|
|
public disconnectedCallback(): void;
|
|
|
|
|
|
|
|
// 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
|
|
|
}
|
2019-02-06 18:27:20 +00:00
|
|
|
}
|
2019-02-19 13:09:44 +00:00
|
|
|
|
|
|
|
declare namespace Chrome {
|
|
|
|
namespace Tabs {
|
|
|
|
// https://developer.chrome.com/extensions/tabs#method-executeScript
|
|
|
|
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;
|
|
|
|
|
|
|
|
// https://developer.chrome.com/extensions/tabs#method-sendMessage
|
|
|
|
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;
|
|
|
|
}
|