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
|
|
|
|
2019-07-17 17:23:52 +00:00
|
|
|
interface WebContents {
|
|
|
|
_getURL(): string;
|
|
|
|
getOwnerBrowserWindow(): Electron.BrowserWindow;
|
|
|
|
}
|
|
|
|
|
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-16 00:32:04 +00:00
|
|
|
interface RemoteInternal extends Electron.Remote {
|
|
|
|
getGuestWebContents(guestInstanceId: number): Electron.WebContents;
|
|
|
|
}
|
|
|
|
|
2019-03-13 19:03:17 +00:00
|
|
|
interface WebContentsInternal extends Electron.WebContents {
|
|
|
|
_sendInternal(channel: string, ...args: any[]): void;
|
2019-03-26 02:38:35 +00:00
|
|
|
_sendInternalToAll(channel: string, ...args: any[]): void;
|
2019-03-13 19:03:17 +00:00
|
|
|
}
|
|
|
|
|
2019-02-14 22:29:20 +00:00
|
|
|
const deprecate: ElectronInternal.DeprecationUtil;
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
2019-08-14 20:42:55 +00:00
|
|
|
fnToProperty(module: any, prop: string, getter: string, setter?: string): void;
|
2019-02-14 22:29:20 +00:00
|
|
|
removeProperty<T, K extends (keyof T & string)>(object: T, propertyName: K): T;
|
|
|
|
renameProperty<T, K extends (keyof T & string)>(object: T, oldName: string, newName: K): T;
|
2019-08-14 20:42:55 +00:00
|
|
|
moveAPI(fn: Function, oldUsage: string, newUsage: string): Function;
|
2019-02-14 22:29:20 +00:00
|
|
|
|
|
|
|
promisify<T extends (...args: any[]) => any>(fn: T): T;
|
2019-03-07 20:56:02 +00:00
|
|
|
|
|
|
|
// convertPromiseValue: Temporarily disabled until it's used
|
|
|
|
promisifyMultiArg<T extends (...args: any[]) => any>(fn: T, /*convertPromiseValue: (v: any) => any*/): 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;
|
|
|
|
emit: typeof NodeJS.EventEmitter.prototype.emit | null;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface GetSourcesOptions {
|
|
|
|
captureWindow: boolean;
|
|
|
|
captureScreen: boolean;
|
|
|
|
thumbnailSize: Electron.Size;
|
|
|
|
fetchWindowIcons: boolean;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface GetSourcesResult {
|
|
|
|
id: string;
|
|
|
|
name: string;
|
|
|
|
thumbnail: string;
|
|
|
|
display_id: string;
|
|
|
|
appIcon: string | null;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
abstract class WebViewElement extends HTMLElement {
|
|
|
|
static observedAttributes: Array<string>;
|
|
|
|
|
|
|
|
public contentWindow: Window;
|
|
|
|
|
|
|
|
public connectedCallback(): void;
|
|
|
|
public attributeChangedCallback(): void;
|
|
|
|
public disconnectedCallback(): void;
|
|
|
|
|
|
|
|
// Created in web-view-impl
|
|
|
|
public getWebContents(): Electron.WebContents;
|
2019-03-26 01:57:27 +00:00
|
|
|
public getWebContentsId(): number;
|
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;
|
|
|
|
}
|