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 {
|
|
|
|
setVersion(version: string): void;
|
|
|
|
setDesktopName(name: string): void;
|
|
|
|
setAppPath(path: string | null): void;
|
|
|
|
}
|
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-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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
interface RendererProcessPreference {
|
|
|
|
contentScripts: Array<ContentScript>
|
|
|
|
extensionId: string;
|
|
|
|
}
|
|
|
|
|
2019-02-15 01:24:25 +00:00
|
|
|
interface IpcRendererInternal extends Electron.IpcRenderer {
|
|
|
|
sendToAll(webContentsId: number, channel: string, ...args: any[]): void
|
|
|
|
}
|
|
|
|
|
2019-02-14 22:29:20 +00:00
|
|
|
const deprecate: ElectronInternal.DeprecationUtil;
|
|
|
|
}
|
|
|
|
|
|
|
|
declare namespace ElectronInternal {
|
|
|
|
type DeprecationHandler = (message: string) => void;
|
|
|
|
interface DeprecationUtil {
|
|
|
|
setHandler(handler: DeprecationHandler): void;
|
|
|
|
getHandler(): DeprecationHandler | null;
|
|
|
|
warn(oldName: string, newName: string): void;
|
|
|
|
log(message: string): void;
|
|
|
|
function(fn: Function, newName: string): Function;
|
|
|
|
event(emitter: NodeJS.EventEmitter, oldName: string, newName: string): void;
|
|
|
|
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;
|
|
|
|
|
|
|
|
promisify<T extends (...args: any[]) => any>(fn: T): T;
|
|
|
|
promisifyMultiArg<T extends (...args: any[]) => any>(fn: T): T;
|
|
|
|
}
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface IpcMainInternal extends Electron.EventEmitter {
|
|
|
|
on(channel: string, listener: (event: IpcMainInternalEvent, ...args: any[]) => void): this;
|
|
|
|
once(channel: string, listener: (event: IpcMainInternalEvent, ...args: any[]) => void): this;
|
|
|
|
}
|
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;
|
|
|
|
}
|