This commit is contained in:
Kevin Sawicki 2017-06-28 15:18:59 -07:00
Родитель d7ee2068c5
Коммит 97d0c6e505
1 изменённых файлов: 201 добавлений и 39 удалений

240
npm/electron.d.ts поставляемый
Просмотреть файл

@ -1,4 +1,4 @@
// Type definitions for Electron 1.7.3 // Type definitions for Electron 1.7.4
// Project: http://electron.atom.io/ // Project: http://electron.atom.io/
// Definitions by: The Electron Team <https://github.com/electron/electron> // Definitions by: The Electron Team <https://github.com/electron/electron>
// Definitions: https://github.com/electron/electron-typescript-definitions // Definitions: https://github.com/electron/electron-typescript-definitions
@ -333,6 +333,14 @@ declare namespace Electron {
request: Request, request: Request,
authInfo: AuthInfo, authInfo: AuthInfo,
callback: (username: string, password: string) => void) => void): this; callback: (username: string, password: string) => void) => void): this;
/**
* Emitted when the user clicks the native macOS new tab button. The new tab button
* is only visible if the current BrowserWindow has a tabbingIdentifier
*/
on(event: 'new-window-for-tab', listener: (event: Event) => void): this;
once(event: 'new-window-for-tab', listener: (event: Event) => void): this;
addListener(event: 'new-window-for-tab', listener: (event: Event) => void): this;
removeListener(event: 'new-window-for-tab', listener: (event: Event) => void): this;
/** /**
* Emitted when the user wants to open a file with the application. The open-file * Emitted when the user wants to open a file with the application. The open-file
* event is usually emitted when the application is already open and the OS wants * event is usually emitted when the application is already open and the OS wants
@ -472,6 +480,11 @@ declare namespace Electron {
* before app is ready. * before app is ready.
*/ */
disableHardwareAcceleration(): void; disableHardwareAcceleration(): void;
/**
* Enables mixed sandbox mode on the app. This method can only be called before app
* is ready.
*/
enableMixedSandbox(): void;
/** /**
* Exits immediately with exitCode. exitCode defaults to 0. All windows will be * Exits immediately with exitCode. exitCode defaults to 0. All windows will be
* closed immediately without asking user and the before-quit and will-quit events * closed immediately without asking user and the before-quit and will-quit events
@ -552,20 +565,21 @@ declare namespace Electron {
* This method makes your application a Single Instance Application - instead of * This method makes your application a Single Instance Application - instead of
* allowing multiple instances of your app to run, this will ensure that only a * allowing multiple instances of your app to run, this will ensure that only a
* single instance of your app is running, and other instances signal this instance * single instance of your app is running, and other instances signal this instance
* and exit. callback will be called with callback(argv, workingDirectory) when a * and exit. callback will be called by the first instance with callback(argv,
* second instance has been executed. argv is an Array of the second instance's * workingDirectory) when a second instance has been executed. argv is an Array of
* command line arguments, and workingDirectory is its current working directory. * the second instance's command line arguments, and workingDirectory is its
* Usually applications respond to this by making their primary window focused and * current working directory. Usually applications respond to this by making their
* non-minimized. The callback is guaranteed to be executed after the ready event * primary window focused and non-minimized. The callback is guaranteed to be
* of app gets emitted. This method returns false if your process is the primary * executed after the ready event of app gets emitted. This method returns false if
* instance of the application and your app should continue loading. And returns * your process is the primary instance of the application and your app should
* true if your process has sent its parameters to another instance, and you should * continue loading. And returns true if your process has sent its parameters to
* immediately quit. On macOS the system enforces single instance automatically * another instance, and you should immediately quit. On macOS the system enforces
* when users try to open a second instance of your app in Finder, and the * single instance automatically when users try to open a second instance of your
* open-file and open-url events will be emitted for that. However when users start * app in Finder, and the open-file and open-url events will be emitted for that.
* your app in command line the system's single instance mechanism will be bypassed * However when users start your app in command line the system's single instance
* and you have to use this method to ensure single instance. An example of * mechanism will be bypassed and you have to use this method to ensure single
* activating the window of primary instance when a second instance starts: * instance. An example of activating the window of primary instance when a second
* instance starts:
*/ */
makeSingleInstance(callback: (argv: string[], workingDirectory: string) => void): boolean; makeSingleInstance(callback: (argv: string[], workingDirectory: string) => void): boolean;
/** /**
@ -653,7 +667,7 @@ declare namespace Electron {
* and pass arguments that specify your application name. For example: Note: This * and pass arguments that specify your application name. For example: Note: This
* API has no effect on MAS builds. * API has no effect on MAS builds.
*/ */
setLoginItemSettings(settings: Settings, path?: string, args?: string[]): void; setLoginItemSettings(settings: Settings): void;
/** /**
* Overrides the current application's name. * Overrides the current application's name.
*/ */
@ -905,6 +919,13 @@ declare namespace Electron {
once(event: 'moved', listener: Function): this; once(event: 'moved', listener: Function): this;
addListener(event: 'moved', listener: Function): this; addListener(event: 'moved', listener: Function): this;
removeListener(event: 'moved', listener: Function): this; removeListener(event: 'moved', listener: Function): this;
/**
* Emitted when the native new tab button is clicked.
*/
on(event: 'new-window-for-tab', listener: Function): this;
once(event: 'new-window-for-tab', listener: Function): this;
addListener(event: 'new-window-for-tab', listener: Function): this;
removeListener(event: 'new-window-for-tab', listener: Function): this;
/** /**
* Emitted when the document changed its title, calling event.preventDefault() will * Emitted when the document changed its title, calling event.preventDefault() will
* prevent the native window's title from changing. * prevent the native window's title from changing.
@ -1996,11 +2017,11 @@ declare namespace Electron {
*/ */
getUploadToServer(): boolean; getUploadToServer(): boolean;
/** /**
* Set an extra parameter to set be sent with the crash report. The values * Set an extra parameter to be sent with the crash report. The values specified
* specified here will be sent in addition to any values set via the extra option * here will be sent in addition to any values set via the extra option when start
* when start was called. This API is only available on macOS, if you need to * was called. This API is only available on macOS, if you need to add/update extra
* add/update extra parameters on Linux and Windows after your first call to start * parameters on Linux and Windows after your first call to start you can call
* you can call start again with the updated extra options. * start again with the updated extra options.
*/ */
setExtraParameter(key: string, value: string): void; setExtraParameter(key: string, value: string): void;
/** /**
@ -2611,7 +2632,7 @@ declare namespace Electron {
* event.returnValue. Note: Sending a synchronous message will block the whole * event.returnValue. Note: Sending a synchronous message will block the whole
* renderer process, unless you know what you are doing you should never use it. * renderer process, unless you know what you are doing you should never use it.
*/ */
sendSync(channel: string, ...args: any[]): void; sendSync(channel: string, ...args: any[]): any;
/** /**
* Like ipcRenderer.send but the event will be sent to the <webview> element in the * Like ipcRenderer.send but the event will be sent to the <webview> element in the
* host page instead of the main process. * host page instead of the main process.
@ -2690,6 +2711,7 @@ declare namespace Electron {
/** /**
* The maximum amount of memory that has ever been pinned to actual physical RAM. * The maximum amount of memory that has ever been pinned to actual physical RAM.
* On macOS its value will always be 0.
*/ */
peakWorkingSetSize: number; peakWorkingSetSize: number;
/** /**
@ -2874,6 +2896,26 @@ declare namespace Electron {
// Docs: http://electron.atom.io/docs/api/notification // Docs: http://electron.atom.io/docs/api/notification
on(event: 'action', listener: (event: Event,
/**
* The index of the action that was activated
*/
index: number) => void): this;
once(event: 'action', listener: (event: Event,
/**
* The index of the action that was activated
*/
index: number) => void): this;
addListener(event: 'action', listener: (event: Event,
/**
* The index of the action that was activated
*/
index: number) => void): this;
removeListener(event: 'action', listener: (event: Event,
/**
* The index of the action that was activated
*/
index: number) => void): this;
/** /**
* Emitted when the notification is clicked by the user. * Emitted when the notification is clicked by the user.
*/ */
@ -2934,6 +2976,20 @@ declare namespace Electron {
show(): void; show(): void;
} }
interface NotificationAction {
// Docs: http://electron.atom.io/docs/api/structures/notification-action
/**
* The label for the given action.
*/
text?: string;
/**
* The type of action, can be button.
*/
type: ('button');
}
interface Point { interface Point {
// Docs: http://electron.atom.io/docs/api/structures/point // Docs: http://electron.atom.io/docs/api/structures/point
@ -3130,14 +3186,20 @@ declare namespace Electron {
// Docs: http://electron.atom.io/docs/api/structures/rectangle // Docs: http://electron.atom.io/docs/api/structures/rectangle
/**
* The height of the rectangle (must be an integer)
*/
height: number; height: number;
/**
* The width of the rectangle (must be an integer)
*/
width: number; width: number;
/** /**
* The x coordinate of the origin of the rectangle * The x coordinate of the origin of the rectangle (must be an integer)
*/ */
x: number; x: number;
/** /**
* The y coordinate of the origin of the rectangle * The y coordinate of the origin of the rectangle (must be an integer)
*/ */
y: number; y: number;
} }
@ -3913,6 +3975,52 @@ declare namespace Electron {
* the dropped text string * the dropped text string
*/ */
text: string) => void): this; text: string) => void): this;
/**
* Emitted when the mouse enters the tray icon.
*/
on(event: 'mouse-enter', listener: (event: Event,
/**
* The position of the event
*/
position: Point) => void): this;
once(event: 'mouse-enter', listener: (event: Event,
/**
* The position of the event
*/
position: Point) => void): this;
addListener(event: 'mouse-enter', listener: (event: Event,
/**
* The position of the event
*/
position: Point) => void): this;
removeListener(event: 'mouse-enter', listener: (event: Event,
/**
* The position of the event
*/
position: Point) => void): this;
/**
* Emitted when the mouse exits the tray icon.
*/
on(event: 'mouse-leave', listener: (event: Event,
/**
* The position of the event
*/
position: Point) => void): this;
once(event: 'mouse-leave', listener: (event: Event,
/**
* The position of the event
*/
position: Point) => void): this;
addListener(event: 'mouse-leave', listener: (event: Event,
/**
* The position of the event
*/
position: Point) => void): this;
removeListener(event: 'mouse-leave', listener: (event: Event,
/**
* The position of the event
*/
position: Point) => void): this;
/** /**
* Emitted when the tray icon is right clicked. * Emitted when the tray icon is right clicked.
*/ */
@ -4091,8 +4199,8 @@ declare namespace Electron {
static getFocusedWebContents(): WebContents; static getFocusedWebContents(): WebContents;
/** /**
* Emitted before dispatching the keydown and keyup events in the page. Calling * Emitted before dispatching the keydown and keyup events in the page. Calling
* event.preventDefault will prevent the page keydown/keyup events from being * event.preventDefault will prevent the page keydown/keyup events and the menu
* dispatched. * shortcuts. To only prevent the menu shortcuts, use setIgnoreMenuShortcuts:
*/ */
on(event: 'before-input-event', listener: (event: Event, on(event: 'before-input-event', listener: (event: Event,
/** /**
@ -4814,13 +4922,13 @@ declare namespace Electron {
* called with callback(image). The image is an instance of NativeImage that stores * called with callback(image). The image is an instance of NativeImage that stores
* data of the snapshot. Omitting rect will capture the whole visible page. * data of the snapshot. Omitting rect will capture the whole visible page.
*/ */
capturePage(callback: (image: NativeImage) => void): void; capturePage(rect: Rectangle, callback: (image: NativeImage) => void): void;
/** /**
* Captures a snapshot of the page within rect. Upon completion callback will be * Captures a snapshot of the page within rect. Upon completion callback will be
* called with callback(image). The image is an instance of NativeImage that stores * called with callback(image). The image is an instance of NativeImage that stores
* data of the snapshot. Omitting rect will capture the whole visible page. * data of the snapshot. Omitting rect will capture the whole visible page.
*/ */
capturePage(rect: Rectangle, callback: (image: NativeImage) => void): void; capturePage(callback: (image: NativeImage) => void): void;
/** /**
* Clears the navigation history. * Clears the navigation history.
*/ */
@ -4877,6 +4985,10 @@ declare namespace Electron {
* request can be obtained by subscribing to found-in-page event. * request can be obtained by subscribing to found-in-page event.
*/ */
findInPage(text: string, options?: FindInPageOptions): void; findInPage(text: string, options?: FindInPageOptions): void;
/**
* Focuses the web page.
*/
focus(): void;
getFrameRate(): number; getFrameRate(): number;
getOSProcessId(): number; getOSProcessId(): number;
/** /**
@ -5040,6 +5152,10 @@ declare namespace Electron {
* Only values between 1 and 60 are accepted. * Only values between 1 and 60 are accepted.
*/ */
setFrameRate(fps: number): void; setFrameRate(fps: number): void;
/**
* Ignore application menu shortcuts while this web contents is focused.
*/
setIgnoreMenuShortcuts(ignore: boolean): void;
/** /**
* Sets the maximum and minimum layout-based (i.e. non-visual) zoom level. * Sets the maximum and minimum layout-based (i.e. non-visual) zoom level.
*/ */
@ -6034,7 +6150,9 @@ declare namespace Electron {
zoomToPageWidth?: boolean; zoomToPageWidth?: boolean;
/** /**
* Tab group name, allows opening the window as a native tab on macOS 10.12+. * Tab group name, allows opening the window as a native tab on macOS 10.12+.
* Windows with the same tabbing identifier will be grouped together. * Windows with the same tabbing identifier will be grouped together. This also
* adds a native new tab button to your window's tab bar and allows your app and
* window to receive the new-window-for-tab event.
*/ */
tabbingIdentifier?: string; tabbingIdentifier?: string;
/** /**
@ -6067,16 +6185,16 @@ declare namespace Electron {
/** /**
* Should follow window.location.origins representation scheme://host:port. * Should follow window.location.origins representation scheme://host:port.
*/ */
origin: string; origin?: string;
/** /**
* The types of storages to clear, can contain: appcache, cookies, filesystem, * The types of storages to clear, can contain: appcache, cookies, filesystem,
* indexdb, localstorage, shadercache, websql, serviceworkers * indexdb, localstorage, shadercache, websql, serviceworkers
*/ */
storages: string[]; storages?: string[];
/** /**
* The types of quotas to clear, can contain: temporary, persistent, syncable. * The types of quotas to clear, can contain: temporary, persistent, syncable.
*/ */
quotas: string[]; quotas?: string[];
} }
interface CommandLine { interface CommandLine {
@ -6216,7 +6334,8 @@ declare namespace Electron {
ignoreSystemCrashHandler?: boolean; ignoreSystemCrashHandler?: boolean;
/** /**
* An object you can define that will be sent along with the report. Only string * An object you can define that will be sent along with the report. Only string
* properties are sent correctly. Nested objects are not supported. * properties are sent correctly. Nested objects are not supported and the property
* names and values must be less than 64 characters long.
*/ */
extra?: Extra; extra?: Extra;
} }
@ -6827,6 +6946,11 @@ declare namespace Electron {
* The placeholder to write in the inline reply input field. * The placeholder to write in the inline reply input field.
*/ */
replyPlaceholder?: string; replyPlaceholder?: string;
/**
* Actions to add to the notification. Please read the available actions and
* limitations in the NotificationAction documentation
*/
actions: NotificationAction[];
} }
interface OnBeforeRedirectDetails { interface OnBeforeRedirectDetails {
@ -7085,11 +7209,11 @@ declare namespace Electron {
/** /**
* Don't ask user for print settings. Default is false. * Don't ask user for print settings. Default is false.
*/ */
silent: boolean; silent?: boolean;
/** /**
* Also prints the background color and image of the web page. Default is false. * Also prints the background color and image of the web page. Default is false.
*/ */
printBackground: boolean; printBackground?: boolean;
/** /**
* Set the printer device name to use. Default is ''. * Set the printer device name to use. Default is ''.
*/ */
@ -7292,6 +7416,9 @@ declare namespace Electron {
interface SaveDialogOptions { interface SaveDialogOptions {
title?: string; title?: string;
/**
* Absolute directory path, absolute file path, or file name to use by default.
*/
defaultPath?: string; defaultPath?: string;
/** /**
* Custom label for the confirmation button, when left empty the default label will * Custom label for the confirmation button, when left empty the default label will
@ -7326,6 +7453,15 @@ declare namespace Electron {
* opened to know the current value. This setting is only supported on macOS. * opened to know the current value. This setting is only supported on macOS.
*/ */
openAsHidden?: boolean; openAsHidden?: boolean;
/**
* The executable to launch at login. Defaults to process.execPath.
*/
path?: string;
/**
* The command-line arguments to pass to the executable. Defaults to an empty
* array. Take care to wrap paths in quotes.
*/
args?: string[];
} }
interface SizeOptions { interface SizeOptions {
@ -7569,14 +7705,14 @@ declare namespace Electron {
} }
interface Versions { interface Versions {
/**
* A String representing Electron's version string.
*/
electron?: string;
/** /**
* A String representing Chrome's version string. * A String representing Chrome's version string.
*/ */
chrome?: string; chrome?: string;
/**
* A String representing Electron's version string.
*/
electron?: string;
} }
interface WillNavigateEvent extends Event { interface WillNavigateEvent extends Event {
@ -7966,10 +8102,36 @@ declare namespace NodeJS {
* true will disable the support for asar archives in Node's built-in modules. * true will disable the support for asar archives in Node's built-in modules.
*/ */
noAsar?: boolean; noAsar?: boolean;
/**
* A Boolean that controls whether or not deprecation warnings are printed to
* stderr. Setting this to true will silence deprecation warnings. This property
* is used instead of the --no-deprecation command line flag.
*/
noDeprecation?: boolean;
/** /**
* A String representing the path to the resources directory. * A String representing the path to the resources directory.
*/ */
resourcesPath?: string; resourcesPath?: string;
/**
* A Boolean that controls whether or not deprecation warnings will be thrown as
* exceptions. Setting this to true will throw errors for deprecations. This
* property is used instead of the --throw-deprecation command line flag.
*/
throwDeprecation?: boolean;
/**
* A Boolean that controls whether or not deprecations printed to stderr include
* their stack trace. Setting this to true will print stack traces for
* deprecations. This property is instead of the --trace-deprecation command line
* flag.
*/
traceDeprecation?: boolean;
/**
* A Boolean that controls whether or not process warnings printed to stderr
* include their stack trace. Setting this to true will print stack traces for
* process warnings (including deprecations). This property is instead of the
* --trace-warnings command line flag.
*/
traceProcessWarnings?: boolean;
/** /**
* A String representing the current process's type, can be "browser" (i.e. main * A String representing the current process's type, can be "browser" (i.e. main
* process) or "renderer". * process) or "renderer".