Update to Electron 1.4.2 (#11766)

* Update to Electron 1.4.2

* Use NodeJS.EventEmitter class
This commit is contained in:
Milan Burda
2016-10-06 18:38:13 +02:00
committed by Mohamed Hegazy
parent e1a08ca895
commit 934e9171de
2 changed files with 47 additions and 33 deletions

View File

@@ -1,4 +1,4 @@
// Type definitions for Electron v1.4.1
// Type definitions for Electron v1.4.2
// Project: http://electron.atom.io/
// Definitions by: jedmao <https://github.com/jedmao/>, rhysd <https://rhysd.github.io>, Milan Burda <https://github.com/miniak/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@@ -7,22 +7,9 @@
declare namespace Electron {
class EventEmitter extends NodeJS.EventEmitter {
addListener(event: string, listener: Function): this;
on(event: string, listener: Function): this;
once(event: string, listener: Function): this;
removeListener(event: string, listener: Function): this;
removeAllListeners(event?: string): this;
setMaxListeners(n: number): this;
getMaxListeners(): number;
listeners(event: string): Function[];
emit(event: string, ...args: any[]): boolean;
listenerCount(type: string): number;
}
interface Event {
preventDefault: Function;
sender: EventEmitter;
sender: NodeJS.EventEmitter;
}
type Point = {
@@ -42,6 +29,17 @@ declare namespace Electron {
height: number;
}
interface Destroyable {
/**
* Destroys the object.
*/
destroy(): void;
/**
* @returns Whether the object is destroyed.
*/
isDestroyed(): boolean;
}
// https://github.com/electron/electron/blob/master/docs/api/app.md
/**
@@ -740,7 +738,7 @@ declare namespace Electron {
* The BrowserWindow class gives you ability to create a browser window.
* You can also create a window without chrome by using Frameless Window API.
*/
class BrowserWindow extends EventEmitter {
class BrowserWindow extends NodeJS.EventEmitter implements Destroyable {
/**
* Emitted when the document changed its title,
* calling event.preventDefault() would prevent the native windows title to change.
@@ -1104,7 +1102,7 @@ declare namespace Electron {
* setting this, the window is still a normal window, not a toolbox window
* which can not be focused on.
*/
setAlwaysOnTop(flag: boolean): void;
setAlwaysOnTop(flag: boolean, level?: WindowLevel): void;
/**
* @returns Whether the window is always on top of other windows.
*/
@@ -1357,8 +1355,8 @@ declare namespace Electron {
getChildWindows(): BrowserWindow[];
}
type WindowLevel = 'normal' | 'floating' | 'torn-off-menu' | 'modal-panel' | 'main-menu' | 'status' | 'pop-up-menu' | 'screen-saver' | 'dock';
type SwipeDirection = 'up' | 'right' | 'down' | 'left';
type ThumbarButtonFlags = 'enabled' | 'disabled' | 'dismissonclick' | 'nobackground' | 'hidden' | 'noninteractive';
interface ThumbarButton {
@@ -1538,6 +1536,11 @@ declare namespace Electron {
* Default: false.
*/
offscreen?: boolean;
/**
* Whether to enable Chromium OS-level sandbox.
* Default: false.
*/
sandbox?: boolean;
}
interface BrowserWindowOptions {
@@ -2532,7 +2535,7 @@ declare namespace Electron {
*
* Each menu consists of multiple menu items, and each menu item can have a submenu.
*/
class Menu extends EventEmitter {
class Menu extends NodeJS.EventEmitter {
/**
* Creates a new menu.
*/
@@ -2627,7 +2630,7 @@ declare namespace Electron {
*/
getBitmap(): Buffer;
/**
* @returns string The data URL of the image.
* @returns The data URL of the image.
*/
toDataURL(): string;
/**
@@ -2637,11 +2640,11 @@ declare namespace Electron {
*/
getNativeHandle(): Buffer;
/**
* @returns boolean Whether the image is empty.
* @returns Whether the image is empty.
*/
isEmpty(): boolean;
/**
* @returns {} The size of the image.
* @returns The size of the image.
*/
getSize(): Size;
/**
@@ -2689,7 +2692,7 @@ declare namespace Electron {
interface PowerSaveBlocker {
/**
* Starts preventing the system from entering lower-power mode.
* @returns an integer identifying the power save blocker.
* @returns The blocker ID that is assigned to this power blocker.
* Note: prevent-display-sleep has higher has precedence over prevent-app-suspension.
*/
start(type: 'prevent-app-suspension' | 'prevent-display-sleep'): number;
@@ -2700,7 +2703,7 @@ declare namespace Electron {
stop(id: number): void;
/**
* @param id The power save blocker id returned by powerSaveBlocker.start.
* @returns a boolean whether the corresponding powerSaveBlocker has started.
* @returns Whether the corresponding powerSaveBlocker has started.
*/
isStarted(id: number): boolean;
}
@@ -2940,7 +2943,7 @@ declare namespace Electron {
* You can also access the session of existing pages by using
* the session property of webContents which is a property of BrowserWindow.
*/
class Session extends EventEmitter {
class Session extends NodeJS.EventEmitter {
/**
* @returns a new Session instance from partition string.
*/
@@ -3136,6 +3139,11 @@ declare namespace Electron {
}
interface Cookie {
/**
* Emitted when a cookie is changed because it was added, edited, removed, or expired.
*/
on(event: 'changed', listener: (event: Event, cookie: Cookie, cause: CookieChangedCause) => void): this;
on(event: string, listener: Function): this;
/**
* The name of the cookie.
*/
@@ -3175,6 +3183,8 @@ declare namespace Electron {
expirationDate?: number;
}
type CookieChangedCause = 'explicit' | 'overwrite' | 'expired' | 'evicted' | 'expired-overwrite';
interface CookieDetails {
/**
* The URL associated with the cookie.
@@ -3525,13 +3535,13 @@ declare namespace Electron {
on(event: 'accent-color-changed', listener: (event: Event, newColor: string) => void): this;
on(event: string, listener: Function): this;
/**
* @returns If the system is in Dark Mode.
* @returns Whether the system is in Dark Mode.
*
* Note: This is only implemented on macOS.
*/
isDarkMode(): boolean;
/**
* @returns If the Swipe between pages setting is on.
* @returns Whether the Swipe between pages setting is on.
*
* Note: This is only implemented on macOS.
*/
@@ -3596,7 +3606,7 @@ declare namespace Electron {
/**
* A Tray represents an icon in an operating system's notification area.
*/
interface Tray extends NodeJS.EventEmitter {
class Tray extends NodeJS.EventEmitter implements Destroyable {
/**
* Emitted when the tray icon is clicked.
* Note: The bounds payload is only implemented on macOS and Windows.
@@ -3661,7 +3671,7 @@ declare namespace Electron {
/**
* Creates a new tray icon associated with the image.
*/
new(image: NativeImage|string): Tray;
constructor(image: NativeImage|string);
/**
* Destroys the tray icon immediately.
*/
@@ -3712,6 +3722,10 @@ declare namespace Electron {
* @returns The bounds of this tray icon.
*/
getBounds(): Rectangle;
/**
* @returns Whether the tray icon is destroyed.
*/
isDestroyed(): boolean;
}
interface Modifiers {
@@ -5465,7 +5479,7 @@ declare namespace Electron {
screen: Electron.Screen;
session: typeof Electron.Session;
systemPreferences: Electron.SystemPreferences;
Tray: Electron.Tray;
Tray: typeof Electron.Tray;
webContents: Electron.WebContentsStatic;
}