electron.d.ts 193.1 KB
Newer Older
J
Joao Moreno 已提交
1
// Type definitions for Electron v1.4.6
B
Benjamin Pasero 已提交
2
// Project: http://electron.atom.io/
J
Joao Moreno 已提交
3
// Definitions by: jedmao <https://github.com/jedmao/>, rhysd <https://rhysd.github.io>, Milan Burda <https://github.com/miniak/>, aliib <https://github.com/aliib>
B
Benjamin Pasero 已提交
4 5 6 7
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped

/// <reference path="./node.d.ts" />

B
Benjamin Pasero 已提交
8 9 10 11
declare namespace Electron {

	interface Event {
		preventDefault: Function;
J
Joao Moreno 已提交
12
		sender: NodeJS.EventEmitter;
B
Benjamin Pasero 已提交
13 14
	}

B
Benjamin Pasero 已提交
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
	type Point = {
		x: number;
		y: number;
	}

	type Size = {
		width: number;
		height: number;
	}

	type Rectangle = {
		x: number;
		y: number;
		width: number;
		height: number;
	}

32 33 34 35 36 37 38 39 40 41 42
	interface Destroyable {
		/**
		 * Destroys the object.
		 */
		destroy(): void;
		/**
		 * @returns Whether the object is destroyed.
		 */
		isDestroyed(): boolean;
	}

B
Benjamin Pasero 已提交
43 44
	// https://github.com/electron/electron/blob/master/docs/api/app.md

B
Benjamin Pasero 已提交
45
	/**
B
Benjamin Pasero 已提交
46
	 * The app module is responsible for controlling the application's lifecycle.
B
Benjamin Pasero 已提交
47
	 */
B
Benjamin Pasero 已提交
48 49 50 51 52 53 54 55 56 57
	interface App extends NodeJS.EventEmitter {
		/**
		 * Emitted when the application has finished basic startup.
		 * On Windows and Linux, the will-finish-launching event
		 * is the same as the ready event; on macOS, this event represents
		 * the applicationWillFinishLaunching notification of NSApplication.
		 * You would usually set up listeners for the open-file and open-url events here,
		 * and start the crash reporter and auto updater.
		 *
		 * In most cases, you should just do everything in the ready event handler.
B
Benjamin Pasero 已提交
58
		 */
B
Benjamin Pasero 已提交
59
		on(event: 'will-finish-launching', listener: Function): this;
B
Benjamin Pasero 已提交
60
		/**
B
Benjamin Pasero 已提交
61
		 * Emitted when Electron has finished initialization.
B
Benjamin Pasero 已提交
62
		 */
63
		on(event: 'ready', listener: (event: Event, launchInfo: Object) => void): this;
B
Benjamin Pasero 已提交
64
		/**
B
Benjamin Pasero 已提交
65 66 67 68 69 70 71 72
		 * Emitted when all windows have been closed.
		 *
		 * If you do not subscribe to this event and all windows are closed,
		 * the default behavior is to quit the app; however, if you subscribe,
		 * you control whether the app quits or not.
		 * If the user pressed Cmd + Q, or the developer called app.quit(),
		 * Electron will first try to close all the windows and then emit the will-quit event,
		 * and in this case the window-all-closed event would not be emitted.
B
Benjamin Pasero 已提交
73
		 */
B
Benjamin Pasero 已提交
74
		on(event: 'window-all-closed', listener: Function): this;
B
Benjamin Pasero 已提交
75
		/**
B
Benjamin Pasero 已提交
76 77
		 * Emitted before the application starts closing its windows.
		 * Calling event.preventDefault() will prevent the default behaviour, which is terminating the application.
B
Benjamin Pasero 已提交
78
		 */
B
Benjamin Pasero 已提交
79
		on(event: 'before-quit', listener: (event: Event) => void): this;
B
Benjamin Pasero 已提交
80
		/**
B
Benjamin Pasero 已提交
81 82
		 * Emitted when all windows have been closed and the application will quit.
		 * Calling event.preventDefault() will prevent the default behaviour, which is terminating the application.
B
Benjamin Pasero 已提交
83
		 */
B
Benjamin Pasero 已提交
84
		on(event: 'will-quit', listener: (event: Event) => void): this;
B
Benjamin Pasero 已提交
85
		/**
B
Benjamin Pasero 已提交
86
		 * Emitted when the application is quitting.
B
Benjamin Pasero 已提交
87
		 */
B
Benjamin Pasero 已提交
88
		on(event: 'quit', listener: (event: Event, exitCode: number) => void): this;
B
Benjamin Pasero 已提交
89
		/**
B
Benjamin Pasero 已提交
90 91 92 93 94 95 96 97 98 99
		 * 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 to reuse the application to open the file.
		 * open-file is also emitted when a file is dropped onto the dock and the application
		 * is not yet running. Make sure to listen for the open-file event very early
		 * in your application startup to handle this case (even before the ready event is emitted).
		 *
		 * You should call event.preventDefault() if you want to handle this event.
		 *
		 * Note: This is only implemented on macOS.
B
Benjamin Pasero 已提交
100
		 */
B
Benjamin Pasero 已提交
101
		on(event: 'open-file', listener: (event: Event, url: string) => void): this;
B
Benjamin Pasero 已提交
102
		/**
B
Benjamin Pasero 已提交
103 104 105 106 107 108
		 * Emitted when the user wants to open a URL with the application.
		 * The URL scheme must be registered to be opened by your application.
		 *
		 * You should call event.preventDefault() if you want to handle this event.
		 *
		 * Note: This is only implemented on macOS.
B
Benjamin Pasero 已提交
109
		 */
B
Benjamin Pasero 已提交
110
		on(event: 'open-url', listener: (event: Event, url: string) => void): this;
B
Benjamin Pasero 已提交
111
		/**
B
Benjamin Pasero 已提交
112 113
		 * Emitted when the application is activated, which usually happens when clicks on the applications’s dock icon.
		 * Note: This is only implemented on macOS.
B
Benjamin Pasero 已提交
114
		 */
B
Benjamin Pasero 已提交
115
		on(event: 'activate', listener: Function): this;
B
Benjamin Pasero 已提交
116
		/**
B
Benjamin Pasero 已提交
117 118
		 * Emitted during Handoff when an activity from a different device wants to be resumed.
		 * You should call event.preventDefault() if you want to handle this event.
B
Benjamin Pasero 已提交
119
		 */
B
Benjamin Pasero 已提交
120
		on(event: 'continue-activity', listener: (event: Event, type: string, userInfo: Object) => void): this;
B
Benjamin Pasero 已提交
121
		/**
B
Benjamin Pasero 已提交
122
		 * Emitted when a browserWindow gets blurred.
B
Benjamin Pasero 已提交
123
		 */
B
Benjamin Pasero 已提交
124
		on(event: 'browser-window-blur', listener: (event: Event, browserWindow: BrowserWindow) => void): this;
B
Benjamin Pasero 已提交
125
		/**
B
Benjamin Pasero 已提交
126
		 * Emitted when a browserWindow gets focused.
B
Benjamin Pasero 已提交
127
		 */
B
Benjamin Pasero 已提交
128
		on(event: 'browser-window-focus', listener: (event: Event, browserWindow: BrowserWindow) => void): this;
B
Benjamin Pasero 已提交
129
		/**
B
Benjamin Pasero 已提交
130
		 * Emitted when a new browserWindow is created.
B
Benjamin Pasero 已提交
131
		 */
B
Benjamin Pasero 已提交
132
		on(event: 'browser-window-created', listener: (event: Event, browserWindow: BrowserWindow) => void): this;
B
Benjamin Pasero 已提交
133
		/**
B
Benjamin Pasero 已提交
134
		 * Emitted when a new webContents is created.
B
Benjamin Pasero 已提交
135
		 */
B
Benjamin Pasero 已提交
136
		on(event: 'web-contents-created', listener: (event: Event, webContents: WebContents) => void): this;
B
Benjamin Pasero 已提交
137
		/**
B
Benjamin Pasero 已提交
138 139
		 * Emitted when failed to verify the certificate for url, to trust the certificate
		 * you should prevent the default behavior with event.preventDefault() and call callback(true).
B
Benjamin Pasero 已提交
140
		 */
B
Benjamin Pasero 已提交
141 142 143 144 145 146 147
		on(event: 'certificate-error', listener: (event: Event,
			webContents: WebContents,
			url: string,
			error: string,
			certificate: Certificate,
			callback: (trust: boolean) => void
		) => void): this;
B
Benjamin Pasero 已提交
148
		/**
B
Benjamin Pasero 已提交
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
		 * Emitted when a client certificate is requested.
		 *
		 * The url corresponds to the navigation entry requesting the client certificate
		 * and callback needs to be called with an entry filtered from the list.
		 * Using event.preventDefault() prevents the application from using the first certificate from the store.
		 */
		on(event: 'select-client-certificate', listener: (event: Event,
			webContents: WebContents,
			url: string,
			certificateList: Certificate[],
			callback: (certificate: Certificate) => void
		) => void): this;
		/**
		 * Emitted when webContents wants to do basic auth.
		 *
		 * The default behavior is to cancel all authentications, to override this
		 * you should prevent the default behavior with event.preventDefault()
		 * and call callback(username, password) with the credentials.
B
Benjamin Pasero 已提交
167
		 */
B
Benjamin Pasero 已提交
168 169 170 171 172 173
		on(event: 'login', listener: (event: Event,
			webContents: WebContents,
			request: LoginRequest,
			authInfo: LoginAuthInfo,
			callback: (username: string, password: string) => void
		) => void): this;
B
Benjamin Pasero 已提交
174
		/**
B
Benjamin Pasero 已提交
175
		 * Emitted when the gpu process crashes.
B
Benjamin Pasero 已提交
176
		 */
177
		on(event: 'gpu-process-crashed', listener: (event: Event, killed: boolean) => void): this;
B
Benjamin Pasero 已提交
178 179 180 181 182 183
		/**
		 * Emitted when Chrome's accessibility support changes.
		 *
		 * Note: This API is only available on macOS and Windows.
		 */
		on(event: 'accessibility-support-changed', listener: (event: Event, accessibilitySupportEnabled: boolean) => void): this;
B
Benjamin Pasero 已提交
184
		on(event: string, listener: Function): this;
B
Benjamin Pasero 已提交
185
		/**
B
Benjamin Pasero 已提交
186 187 188 189 190 191 192
		 * Try to close all windows. The before-quit event will first be emitted.
		 * If all windows are successfully closed, the will-quit event will be emitted
		 * and by default the application would be terminated.
		 *
		 * This method guarantees all beforeunload and unload handlers are correctly
		 * executed. It is possible that a window cancels the quitting by returning
		 * false in beforeunload handler.
B
Benjamin Pasero 已提交
193
		 */
B
Benjamin Pasero 已提交
194
		quit(): void;
B
Benjamin Pasero 已提交
195
		/**
B
Benjamin Pasero 已提交
196 197 198
		 * Exits immediately with exitCode.
		 * All windows will be closed immediately without asking user
		 * and the before-quit and will-quit events will not be emitted.
B
Benjamin Pasero 已提交
199
		 */
B
Benjamin Pasero 已提交
200
		exit(exitCode?: number): void;
B
Benjamin Pasero 已提交
201
		/**
B
Benjamin Pasero 已提交
202 203 204 205 206 207 208 209 210 211 212 213
		 * Relaunches the app when current instance exits.
		 *
		 * By default the new instance will use the same working directory
		 * and command line arguments with current instance.
		 * When args is specified, the args will be passed as command line arguments instead.
		 * When execPath is specified, the execPath will be executed for relaunch instead of current app.
		 *
		 * Note that this method does not quit the app when executed, you have to call app.quit
		 * or app.exit after calling app.relaunch to make the app restart.
		 *
		 * When app.relaunch is called for multiple times, multiple instances
		 * will be started after current instance exited.
B
Benjamin Pasero 已提交
214
		 */
B
Benjamin Pasero 已提交
215 216 217 218
		relaunch(options?: {
			args?: string[],
			execPath?: string
		}): void;
219 220 221 222
		/**
		 * @returns Whether Electron has finished initializing.
		 */
		isReady(): boolean;
B
Benjamin Pasero 已提交
223
		/**
B
Benjamin Pasero 已提交
224 225 226
		 * On Linux, focuses on the first visible window.
		 * On macOS, makes the application the active app.
		 * On Windows, focuses on the application’s first window.
B
Benjamin Pasero 已提交
227
		 */
B
Benjamin Pasero 已提交
228
		focus(): void;
B
Benjamin Pasero 已提交
229
		/**
B
Benjamin Pasero 已提交
230 231
		 * Hides all application windows without minimizing them.
		 * Note: This is only implemented on macOS.
B
Benjamin Pasero 已提交
232
		 */
B
Benjamin Pasero 已提交
233
		hide(): void;
B
Benjamin Pasero 已提交
234
		/**
B
Benjamin Pasero 已提交
235 236
		 * Shows application windows after they were hidden. Does not automatically focus them.
		 * Note: This is only implemented on macOS.
B
Benjamin Pasero 已提交
237
		 */
B
Benjamin Pasero 已提交
238
		show(): void;
B
Benjamin Pasero 已提交
239
		/**
B
Benjamin Pasero 已提交
240
		 * Returns the current application directory.
B
Benjamin Pasero 已提交
241
		 */
B
Benjamin Pasero 已提交
242
		getAppPath(): string;
B
Benjamin Pasero 已提交
243
		/**
B
Benjamin Pasero 已提交
244 245
		 * @returns The path to a special directory or file associated with name.
		 * On failure an Error would throw.
B
Benjamin Pasero 已提交
246
		 */
B
Benjamin Pasero 已提交
247
		getPath(name: AppPathName): string;
B
Benjamin Pasero 已提交
248
		/**
B
Benjamin Pasero 已提交
249 250 251 252 253 254 255 256 257
		 * Overrides the path to a special directory or file associated with name.
		 * If the path specifies a directory that does not exist, the directory will
		 * be created by this method. On failure an Error would throw.
		 *
		 * You can only override paths of names defined in app.getPath.
		 *
		 * By default web pages' cookies and caches will be stored under userData
		 * directory, if you want to change this location, you have to override the
		 * userData path before the ready event of app module gets emitted.
B
Benjamin Pasero 已提交
258
		 */
B
Benjamin Pasero 已提交
259
		setPath(name: AppPathName, path: string): void;
B
Benjamin Pasero 已提交
260
		/**
B
Benjamin Pasero 已提交
261 262
		 * @returns The version of loaded application, if no version is found in
		 * application's package.json, the version of current bundle or executable.
B
Benjamin Pasero 已提交
263
		 */
B
Benjamin Pasero 已提交
264
		getVersion(): string;
B
Benjamin Pasero 已提交
265
		/**
B
Benjamin Pasero 已提交
266 267 268 269 270
		 * @returns The current application's name, the name in package.json would be used.
		 * Usually the name field of package.json is a short lowercased name, according to
		 * the spec of npm modules. So usually you should also specify a productName field,
		 * which is your application's full capitalized name, and it will be preferred over
		 * name by Electron.
B
Benjamin Pasero 已提交
271
		 */
B
Benjamin Pasero 已提交
272
		getName(): string;
B
Benjamin Pasero 已提交
273
		/**
B
Benjamin Pasero 已提交
274
		 * Overrides the current application's name.
B
Benjamin Pasero 已提交
275
		 */
B
Benjamin Pasero 已提交
276
		setName(name: string): void;
B
Benjamin Pasero 已提交
277
		/**
B
Benjamin Pasero 已提交
278 279 280
		  * @returns The current application locale.
		  */
		getLocale(): string;
B
Benjamin Pasero 已提交
281
		/**
B
Benjamin Pasero 已提交
282 283 284 285 286 287
		 * Adds path to recent documents list.
		 *
		 * This list is managed by the system, on Windows you can visit the list from
		 * task bar, and on macOS you can visit it from dock menu.
		 *
		 * Note: This is only implemented on macOS and Windows.
B
Benjamin Pasero 已提交
288
		 */
B
Benjamin Pasero 已提交
289
		addRecentDocument(path: string): void;
B
Benjamin Pasero 已提交
290
		/**
B
Benjamin Pasero 已提交
291 292 293
		 * Clears the recent documents list.
		 *
		 * Note: This is only implemented on macOS and Windows.
B
Benjamin Pasero 已提交
294
		 */
B
Benjamin Pasero 已提交
295
		clearRecentDocuments(): void;
B
Benjamin Pasero 已提交
296
		/**
B
Benjamin Pasero 已提交
297 298 299 300
		 * Sets the current executable as the default handler for a protocol (aka URI scheme).
		 * Once registered, all links with your-protocol:// will be opened with the current executable.
		 * The whole link, including protocol, will be passed to your application as a parameter.
		 *
B
Benjamin Pasero 已提交
301 302 303 304 305 306 307
		 * On Windows you can provide optional parameters path, the path to your executable,
		 * and args, an array of arguments to be passed to your executable when it launches.
		 *
		 * @param protocol The name of your protocol, without ://.
		 * @param path Defaults to process.execPath.
		 * @param args Defaults to an empty array.
		 *
B
Benjamin Pasero 已提交
308 309
		 * Note: This is only implemented on macOS and Windows.
		 *       On macOS, you can only register protocols that have been added to your app's info.plist.
B
Benjamin Pasero 已提交
310
		 */
B
Benjamin Pasero 已提交
311
		setAsDefaultProtocolClient(protocol: string, path?: string, args?: string[]): boolean;
B
Benjamin Pasero 已提交
312
		/**
B
Benjamin Pasero 已提交
313 314
		 * Removes the current executable as the default handler for a protocol (aka URI scheme).
		 *
B
Benjamin Pasero 已提交
315 316 317 318
		 * @param protocol The name of your protocol, without ://.
		 * @param path Defaults to process.execPath.
		 * @param args Defaults to an empty array.
		 *
B
Benjamin Pasero 已提交
319
		 * Note: This is only implemented on macOS and Windows.
B
Benjamin Pasero 已提交
320
		 */
B
Benjamin Pasero 已提交
321
		removeAsDefaultProtocolClient(protocol: string, path?: string, args?: string[]): boolean;
B
Benjamin Pasero 已提交
322
		/**
B
Benjamin Pasero 已提交
323 324 325 326
		 * @param protocol The name of your protocol, without ://.
		 * @param path Defaults to process.execPath.
		 * @param args Defaults to an empty array.
		 *
B
Benjamin Pasero 已提交
327 328 329
		 * @returns Whether the current executable is the default handler for a protocol (aka URI scheme).
		 *
		 * Note: This is only implemented on macOS and Windows.
B
Benjamin Pasero 已提交
330
		 */
B
Benjamin Pasero 已提交
331
		isDefaultProtocolClient(protocol: string, path?: string, args?: string[]): boolean;
B
Benjamin Pasero 已提交
332
		/**
B
Benjamin Pasero 已提交
333 334 335
		 * Adds tasks to the Tasks category of JumpList on Windows.
		 *
		 * Note: This API is only available on Windows.
B
Benjamin Pasero 已提交
336
		 */
B
Benjamin Pasero 已提交
337
		setUserTasks(tasks: Task[]): boolean;
B
Benjamin Pasero 已提交
338 339 340 341 342 343 344 345 346 347 348 349 350
		/**
		 * Note: This API is only available on Windows.
		 */
		getJumpListSettings(): JumpListSettings;
		/**
		 * Sets or removes a custom Jump List for the application.
		 *
		 * If categories is null the previously set custom Jump List (if any) will be replaced
		 * by the standard Jump List for the app (managed by Windows).
		 *
		 * Note: This API is only available on Windows.
		 */
		setJumpList(categories: JumpListCategory[]): SetJumpListResult;
B
Benjamin Pasero 已提交
351
		/**
B
Benjamin Pasero 已提交
352 353 354
		 * 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 single instance
		 * of your app is running, and other instances signal this instance and exit.
B
Benjamin Pasero 已提交
355
		 */
B
Benjamin Pasero 已提交
356
		makeSingleInstance(callback: (args: string[], workingDirectory: string) => void): boolean;
B
Benjamin Pasero 已提交
357
		/**
B
Benjamin Pasero 已提交
358 359
		 * Releases all locks that were created by makeSingleInstance. This will allow
		 * multiple instances of the application to once again run side by side.
B
Benjamin Pasero 已提交
360
		 */
B
Benjamin Pasero 已提交
361
		releaseSingleInstance(): void;
B
Benjamin Pasero 已提交
362
		/**
B
Benjamin Pasero 已提交
363 364 365 366 367 368 369 370 371
		 * Creates an NSUserActivity and sets it as the current activity.
		 * The activity is eligible for Handoff to another device afterward.
		 *
		 * @param type Uniquely identifies the activity. Maps to NSUserActivity.activityType.
		 * @param userInfo App-specific state to store for use by another device.
		 * @param webpageURL The webpage to load in a browser if no suitable app is
		 * 					 installed on the resuming device. The scheme must be http or https.
		 *
		 * Note: This API is only available on macOS.
B
Benjamin Pasero 已提交
372
		 */
B
Benjamin Pasero 已提交
373
		setUserActivity(type: string, userInfo: Object, webpageURL?: string): void;
B
Benjamin Pasero 已提交
374
		/**
B
Benjamin Pasero 已提交
375 376 377
		 * @returns The type of the currently running activity.
		 *
		 * Note: This API is only available on macOS.
B
Benjamin Pasero 已提交
378
		 */
B
Benjamin Pasero 已提交
379
		getCurrentActivityType(): string;
B
Benjamin Pasero 已提交
380
		/**
B
Benjamin Pasero 已提交
381
		 * Changes the Application User Model ID to id.
B
Benjamin Pasero 已提交
382 383
		 *
		 * Note: This is only implemented on Windows.
B
Benjamin Pasero 已提交
384
		 */
B
Benjamin Pasero 已提交
385
		setAppUserModelId(id: string): void;
B
Benjamin Pasero 已提交
386
		/**
B
Benjamin Pasero 已提交
387 388 389 390 391
		 * Imports the certificate in pkcs12 format into the platform certificate store.
		 * @param callback Called with the result of import operation, a value of 0 indicates success
		 * while any other value indicates failure according to chromium net_error_list.
		 *
		 * Note: This API is only available on Linux.
B
Benjamin Pasero 已提交
392
		 */
B
Benjamin Pasero 已提交
393
		importCertificate(options: ImportCertificateOptions, callback: (result: number) => void): void;
B
Benjamin Pasero 已提交
394
		/**
B
Benjamin Pasero 已提交
395 396
		 * Disables hardware acceleration for current app.
		 * This method can only be called before app is ready.
B
Benjamin Pasero 已提交
397
		 */
B
Benjamin Pasero 已提交
398
		disableHardwareAcceleration(): void;
B
Benjamin Pasero 已提交
399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425
		/**
		 * @returns whether current desktop environment is Unity launcher. (Linux)
		 *
		 * Note: This API is only available on Linux.
		 */
		isUnityRunning(): boolean;
		/**
		 * Returns a Boolean, true if Chrome's accessibility support is enabled, false otherwise.
		 * This API will return true if the use of assistive technologies, such as screen readers,
		 * has been detected.
		 * See https://www.chromium.org/developers/design-documents/accessibility for more details.
		 *
		 * Note: This API is only available on macOS and Windows.
		 */
		isAccessibilitySupportEnabled(): boolean;
		/**
		 * @returns an Object with the login item settings of the app.
		 *
		 * Note: This API is only available on macOS and Windows.
		 */
		getLoginItemSettings(): LoginItemSettings;
		/**
		 * Set the app's login item settings.
		 *
		 * Note: This API is only available on macOS and Windows.
		 */
		setLoginItemSettings(settings: LoginItemSettings): void;
426 427 428 429 430 431 432
		/**
		 * Set the about panel options. This will override the values defined in the app's .plist file.
		 * See the Apple docs for more details.
		 *
		 * Note: This API is only available on macOS.
		 */
		setAboutPanelOptions(options: AboutPanelOptions): void;
B
Benjamin Pasero 已提交
433
		commandLine: CommandLine;
B
Benjamin Pasero 已提交
434
		/**
B
Benjamin Pasero 已提交
435
		 * Note: This API is only available on macOS.
B
Benjamin Pasero 已提交
436
		 */
B
Benjamin Pasero 已提交
437 438 439
		dock: Dock;
	}

J
Joao Moreno 已提交
440
	type AppPathName = 'home' | 'appData' | 'userData' | 'temp' | 'exe' | 'module' | 'desktop' | 'documents' | 'downloads' | 'music' | 'pictures' | 'videos' | 'pepperFlashSystemPlugin';
B
Benjamin Pasero 已提交
441 442

	interface ImportCertificateOptions {
B
Benjamin Pasero 已提交
443
		/**
B
Benjamin Pasero 已提交
444
		 * Path for the pkcs12 file.
B
Benjamin Pasero 已提交
445
		 */
B
Benjamin Pasero 已提交
446
		certificate: string;
B
Benjamin Pasero 已提交
447
		/**
B
Benjamin Pasero 已提交
448
		 * Passphrase for the certificate.
B
Benjamin Pasero 已提交
449
		 */
B
Benjamin Pasero 已提交
450 451 452 453
		password: string;
	}

	interface CommandLine {
B
Benjamin Pasero 已提交
454
		/**
B
Benjamin Pasero 已提交
455 456 457 458
		 * Append a switch [with optional value] to Chromium's command line.
		 *
		 * Note: This will not affect process.argv, and is mainly used by developers
		 * to control some low-level Chromium behaviors.
B
Benjamin Pasero 已提交
459
		 */
B
Benjamin Pasero 已提交
460
		appendSwitch(_switch: string, value?: string): void;
B
Benjamin Pasero 已提交
461
		/**
B
Benjamin Pasero 已提交
462 463 464
		 * Append an argument to Chromium's command line. The argument will quoted properly.
		 *
		 * Note: This will not affect process.argv.
B
Benjamin Pasero 已提交
465
		 */
B
Benjamin Pasero 已提交
466 467 468 469
		appendArgument(value: string): void;
	}

	interface Dock {
B
Benjamin Pasero 已提交
470
		/**
B
Benjamin Pasero 已提交
471 472 473 474 475 476 477 478 479
		 * When critical is passed, the dock icon will bounce until either the
		 * application becomes active or the request is canceled.
		 *
		 * When informational is passed, the dock icon will bounce for one second.
		 * However, the request remains active until either the application becomes
		 * active or the request is canceled.
		 *
		 * @param type The default is informational.
		 * @returns An ID representing the request.
B
Benjamin Pasero 已提交
480
		 */
B
Benjamin Pasero 已提交
481
		bounce(type?: 'critical' | 'informational'): number;
B
Benjamin Pasero 已提交
482
		/**
B
Benjamin Pasero 已提交
483 484 485
		 * Cancel the bounce of id.
		 *
		 * Note: This API is only available on macOS.
B
Benjamin Pasero 已提交
486
		 */
B
Benjamin Pasero 已提交
487
		cancelBounce(id: number): void;
B
Benjamin Pasero 已提交
488
		/**
B
Benjamin Pasero 已提交
489 490 491
		 * Bounces the Downloads stack if the filePath is inside the Downloads folder.
		 *
		 * Note: This API is only available on macOS.
B
Benjamin Pasero 已提交
492
		 */
B
Benjamin Pasero 已提交
493
		downloadFinished(filePath: string): void;
B
Benjamin Pasero 已提交
494
		/**
B
Benjamin Pasero 已提交
495 496 497
		 * Sets the string to be displayed in the dock’s badging area.
		 *
		 * Note: This API is only available on macOS.
B
Benjamin Pasero 已提交
498
		 */
B
Benjamin Pasero 已提交
499
		setBadge(text: string): void;
B
Benjamin Pasero 已提交
500
		/**
B
Benjamin Pasero 已提交
501 502 503
		 * Returns the badge string of the dock.
		 *
		 * Note: This API is only available on macOS.
B
Benjamin Pasero 已提交
504
		 */
B
Benjamin Pasero 已提交
505
		getBadge(): string;
B
Benjamin Pasero 已提交
506 507 508 509 510 511 512 513 514 515 516 517 518 519
		/**
		 * Sets the counter badge for current app. Setting the count to 0 will hide the badge.
		 *
		 * @returns True when the call succeeded, otherwise returns false.
		 *
		 * Note: This API is only available on macOS and Linux.
		 */
		setBadgeCount(count: number): boolean;
		/**
		 * @returns The current value displayed in the counter badge.
		 *
		 * Note: This API is only available on macOS and Linux.
		 */
		getBadgeCount(): number;
B
Benjamin Pasero 已提交
520
		/**
B
Benjamin Pasero 已提交
521 522 523
		 * Hides the dock icon.
		 *
		 * Note: This API is only available on macOS.
B
Benjamin Pasero 已提交
524
		 */
B
Benjamin Pasero 已提交
525
		hide(): void;
B
Benjamin Pasero 已提交
526
		/**
B
Benjamin Pasero 已提交
527 528 529
		 * Shows the dock icon.
		 *
		 * Note: This API is only available on macOS.
B
Benjamin Pasero 已提交
530
		 */
B
Benjamin Pasero 已提交
531
		show(): void;
B
Benjamin Pasero 已提交
532 533 534 535 536 537 538
		/**
		 * @returns Whether the dock icon is visible.
		 * The app.dock.show() call is asynchronous so this method might not return true immediately after that call.
		 *
		 * Note: This API is only available on macOS.
		 */
		isVisible(): boolean;
B
Benjamin Pasero 已提交
539
		/**
B
Benjamin Pasero 已提交
540 541 542
		 * Sets the application dock menu.
		 *
		 * Note: This API is only available on macOS.
B
Benjamin Pasero 已提交
543
		 */
B
Benjamin Pasero 已提交
544
		setMenu(menu: Menu): void;
B
Benjamin Pasero 已提交
545
		/**
B
Benjamin Pasero 已提交
546 547 548
		 * Sets the image associated with this dock icon.
		 *
		 * Note: This API is only available on macOS.
B
Benjamin Pasero 已提交
549
		 */
B
Benjamin Pasero 已提交
550 551 552 553
		setIcon(icon: NativeImage | string): void;
	}

	interface Task {
B
Benjamin Pasero 已提交
554
		/**
B
Benjamin Pasero 已提交
555 556
		 * Path of the program to execute, usually you should specify process.execPath
		 * which opens current program.
B
Benjamin Pasero 已提交
557
		 */
B
Benjamin Pasero 已提交
558
		program: string;
B
Benjamin Pasero 已提交
559
		/**
B
Benjamin Pasero 已提交
560
		 * The arguments of command line when program is executed.
B
Benjamin Pasero 已提交
561
		 */
B
Benjamin Pasero 已提交
562
		arguments: string;
B
Benjamin Pasero 已提交
563
		/**
B
Benjamin Pasero 已提交
564
		 * The string to be displayed in a JumpList.
B
Benjamin Pasero 已提交
565
		 */
B
Benjamin Pasero 已提交
566
		title: string;
B
Benjamin Pasero 已提交
567
		/**
B
Benjamin Pasero 已提交
568
		 * Description of this task.
B
Benjamin Pasero 已提交
569
		 */
B
Benjamin Pasero 已提交
570
		description?: string;
B
Benjamin Pasero 已提交
571
		/**
B
Benjamin Pasero 已提交
572 573 574
		 * The absolute path to an icon to be displayed in a JumpList, it can be
		 * arbitrary resource file that contains an icon, usually you can specify
		 * process.execPath to show the icon of the program.
B
Benjamin Pasero 已提交
575
		 */
B
Benjamin Pasero 已提交
576
		iconPath: string;
B
Benjamin Pasero 已提交
577
		/**
B
Benjamin Pasero 已提交
578 579 580
		 * The icon index in the icon file. If an icon file consists of two or more
		 * icons, set this value to identify the icon. If an icon file consists of
		 * one icon, this value is 0.
B
Benjamin Pasero 已提交
581
		 */
B
Benjamin Pasero 已提交
582 583 584
		iconIndex?: number;
	}

B
Benjamin Pasero 已提交
585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667
	/**
	 * ok - Nothing went wrong.
	 * error - One or more errors occured, enable runtime logging to figure out the likely cause.
	 * invalidSeparatorError - An attempt was made to add a separator to a custom category in the Jump List.
	 *                         Separators are only allowed in the standard Tasks category.
	 * fileTypeRegistrationError - An attempt was made to add a file link to the Jump List
	 *                             for a file type the app isn't registered to handle.
	 * customCategoryAccessDeniedError - Custom categories can't be added to the Jump List
	 *                                   due to user privacy or group policy settings.
	 */
	type SetJumpListResult = 'ok' | 'error' | 'invalidSeparatorError' | 'fileTypeRegistrationError' | 'customCategoryAccessDeniedError';

	interface JumpListSettings {
		/**
		 * The minimum number of items that will be shown in the Jump List.
		 */
		minItems: number;
		/**
		 * Items that the user has explicitly removed from custom categories in the Jump List.
		 */
		removedItems: JumpListItem[];
	}

	interface JumpListCategory {
		/**
		 * tasks - Items in this category will be placed into the standard Tasks category.
		 * frequent - Displays a list of files frequently opened by the app, the name of the category and its items are set by Windows.
		 * recent - Displays a list of files recently opened by the app, the name of the category and its items are set by Windows.
		 * custom - Displays tasks or file links, name must be set by the app.
		 */
		type?: 'tasks' | 'frequent' | 'recent' | 'custom';
		/**
		 * Must be set if type is custom, otherwise it should be omitted.
		 */
		name?: string;
		/**
		 * Array of JumpListItem objects if type is tasks or custom, otherwise it should be omitted.
		 */
		items?: JumpListItem[];
	}

	interface JumpListItem {
		/**
		 * task - A task will launch an app with specific arguments.
		 * separator - Can be used to separate items in the standard Tasks category.
		 * file - A file link will open a file using the app that created the Jump List.
		 */
		type: 'task' | 'separator' | 'file';
		/**
		 * Path of the file to open, should only be set if type is file.
		 */
		path?: string;
		/**
		 * Path of the program to execute, usually you should specify process.execPath which opens the current program.
		 * Should only be set if type is task.
		 */
		program?: string;
		/**
		 * The command line arguments when program is executed. Should only be set if type is task.
		 */
		args?: string;
		/**
		 * The text to be displayed for the item in the Jump List. Should only be set if type is task.
		 */
		title?: string;
		/**
		 * Description of the task (displayed in a tooltip). Should only be set if type is task.
		 */
		description?: string;
		/**
		 * The absolute path to an icon to be displayed in a Jump List, which can be an arbitrary
		 * resource file that contains an icon (e.g. .ico, .exe, .dll).
		 * You can usually specify process.execPath to show the program icon.
		 */
		iconPath?: string;
		/**
		 * The index of the icon in the resource file. If a resource file contains multiple icons
		 * this value can be used to specify the zero-based index of the icon that should be displayed
		 * for this task. If a resource file contains only one icon, this property should be set to zero.
		 */
		iconIndex?: number;
	}

B
Benjamin Pasero 已提交
668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693
	interface LoginItemSettings {
		/**
		 * True if the app is set to open at login.
		 */
		openAtLogin: boolean;
		/**
		 * True if the app is set to open as hidden at login. This setting is only supported on macOS.
		 */
		openAsHidden: boolean;
		/**
		 * True if the app was opened at login automatically. This setting is only supported on macOS.
		 */
		wasOpenedAtLogin?: boolean;
		/**
		 * True if the app was opened as a hidden login item. This indicates that the app should not
		 * open any windows at startup. This setting is only supported on macOS.
		 */
		wasOpenedAsHidden?: boolean;
		/**
		 * True if the app was opened as a login item that should restore the state from the previous session.
		 * This indicates that the app should restore the windows that were open the last time the app was closed.
		 * This setting is only supported on macOS.
		 */
		restoreState?: boolean;
	}

694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716
	interface AboutPanelOptions {
		/**
		 * The app's name.
		 */
		applicationName?: string;
		/**
		 * The app's version.
		 */
		applicationVersion?: string;
		/**
		 * Copyright information.
		 */
		copyright?: string;
		/**
		 * Credit information.
		 */
		credits?: string;
		/**
		 * The app's build version number.
		 */
		version?: string;
	}

B
Benjamin Pasero 已提交
717 718 719 720 721
	// https://github.com/electron/electron/blob/master/docs/api/auto-updater.md

	/**
	 * This module provides an interface for the Squirrel auto-updater framework.
	 */
J
Joao Moreno 已提交
722
	interface AutoUpdater extends NodeJS.EventEmitter {
B
Benjamin Pasero 已提交
723
		/**
B
Benjamin Pasero 已提交
724
		 * Emitted when there is an error while updating.
B
Benjamin Pasero 已提交
725
		 */
B
Benjamin Pasero 已提交
726
		on(event: 'error', listener: (error: Error) => void): this;
B
Benjamin Pasero 已提交
727
		/**
B
Benjamin Pasero 已提交
728
		 * Emitted when checking if an update has started.
B
Benjamin Pasero 已提交
729
		 */
B
Benjamin Pasero 已提交
730
		on(event: 'checking-for-update', listener: Function): this;
B
Benjamin Pasero 已提交
731
		/**
B
Benjamin Pasero 已提交
732
		 * Emitted when there is an available update. The update is downloaded automatically.
B
Benjamin Pasero 已提交
733
		 */
B
Benjamin Pasero 已提交
734
		on(event: 'update-available', listener: Function): this;
B
Benjamin Pasero 已提交
735
		/**
B
Benjamin Pasero 已提交
736
		 * Emitted when there is no available update.
B
Benjamin Pasero 已提交
737
		 */
B
Benjamin Pasero 已提交
738
		on(event: 'update-not-available', listener: Function): this;
B
Benjamin Pasero 已提交
739
		/**
B
Benjamin Pasero 已提交
740 741
		 * Emitted when an update has been downloaded.
		 * Note: On Windows only releaseName is available.
B
Benjamin Pasero 已提交
742
		 */
B
Benjamin Pasero 已提交
743 744
		on(event: 'update-downloaded', listener: (event: Event, releaseNotes: string, releaseName: string, releaseDate: Date, updateURL: string) => void): this;
		on(event: string, listener: Function): this;
B
Benjamin Pasero 已提交
745
		/**
B
Benjamin Pasero 已提交
746
		 * Set the url and initialize the auto updater.
B
Benjamin Pasero 已提交
747
		 */
B
Benjamin Pasero 已提交
748
		setFeedURL(url: string, requestHeaders?: Headers): void;
B
Benjamin Pasero 已提交
749 750 751 752
		/**
		 * @returns The current update feed URL.
		 */
		getFeedURL(): string;
B
Benjamin Pasero 已提交
753
		/**
B
Benjamin Pasero 已提交
754 755
		 * Ask the server whether there is an update, you have to call setFeedURL
		 * before using this API
B
Benjamin Pasero 已提交
756
		 */
B
Benjamin Pasero 已提交
757
		checkForUpdates(): void;
B
Benjamin Pasero 已提交
758
		/**
B
Benjamin Pasero 已提交
759 760
		 * Restarts the app and installs the update after it has been downloaded.
		 * It should only be called after update-downloaded has been emitted.
B
Benjamin Pasero 已提交
761
		 */
B
Benjamin Pasero 已提交
762 763 764 765 766 767 768 769 770
		quitAndInstall(): void;
	}

	// https://github.com/electron/electron/blob/master/docs/api/browser-window.md

	/**
	 * The BrowserWindow class gives you ability to create a browser window.
	 * You can also create a window without chrome by using Frameless Window API.
	 */
J
Joao Moreno 已提交
771
	class BrowserWindow extends NodeJS.EventEmitter implements Destroyable {
B
Benjamin Pasero 已提交
772
		/**
B
Benjamin Pasero 已提交
773 774
		 * Emitted when the document changed its title,
		 * calling event.preventDefault() would prevent the native window’s title to change.
B
Benjamin Pasero 已提交
775
		 */
B
Benjamin Pasero 已提交
776
		on(event: 'page-title-updated', listener: (event: Event, title: string) => void): this;
B
Benjamin Pasero 已提交
777
		/**
B
Benjamin Pasero 已提交
778 779
		 * Emitted when the window is going to be closed. It’s emitted before the beforeunload
		 * and unload event of the DOM. Calling event.preventDefault() will cancel the close.
B
Benjamin Pasero 已提交
780
		 */
B
Benjamin Pasero 已提交
781
		on(event: 'close', listener: (event: Event) => void): this;
B
Benjamin Pasero 已提交
782
		/**
B
Benjamin Pasero 已提交
783 784
		 * Emitted when the window is closed. After you have received this event
		 * you should remove the reference to the window and avoid using it anymore.
B
Benjamin Pasero 已提交
785
		 */
B
Benjamin Pasero 已提交
786
		on(event: 'closed', listener: Function): this;
B
Benjamin Pasero 已提交
787
		/**
B
Benjamin Pasero 已提交
788
		 * Emitted when the web page becomes unresponsive.
B
Benjamin Pasero 已提交
789
		 */
B
Benjamin Pasero 已提交
790
		on(event: 'unresponsive', listener: Function): this;
B
Benjamin Pasero 已提交
791
		/**
B
Benjamin Pasero 已提交
792
		 * Emitted when the unresponsive web page becomes responsive again.
B
Benjamin Pasero 已提交
793
		 */
B
Benjamin Pasero 已提交
794
		on(event: 'responsive', listener: Function): this;
B
Benjamin Pasero 已提交
795
		/**
B
Benjamin Pasero 已提交
796
		 * Emitted when the window loses focus.
B
Benjamin Pasero 已提交
797
		 */
B
Benjamin Pasero 已提交
798
		on(event: 'blur', listener: Function): this;
B
Benjamin Pasero 已提交
799
		/**
B
Benjamin Pasero 已提交
800
		 * Emitted when the window gains focus.
B
Benjamin Pasero 已提交
801
		 */
B
Benjamin Pasero 已提交
802
		on(event: 'focus', listener: Function): this;
B
Benjamin Pasero 已提交
803
		/**
B
Benjamin Pasero 已提交
804
		 * Emitted when the window is shown.
B
Benjamin Pasero 已提交
805
		 */
B
Benjamin Pasero 已提交
806
		on(event: 'show', listener: Function): this;
B
Benjamin Pasero 已提交
807
		/**
B
Benjamin Pasero 已提交
808
		 * Emitted when the window is hidden.
B
Benjamin Pasero 已提交
809
		 */
B
Benjamin Pasero 已提交
810
		on(event: 'hide', listener: Function): this;
B
Benjamin Pasero 已提交
811
		/**
B
Benjamin Pasero 已提交
812
		 * Emitted when the web page has been rendered and window can be displayed without visual flash.
B
Benjamin Pasero 已提交
813
		 */
B
Benjamin Pasero 已提交
814
		on(event: 'ready-to-show', listener: Function): this;
B
Benjamin Pasero 已提交
815
		/**
B
Benjamin Pasero 已提交
816
		 * Emitted when window is maximized.
B
Benjamin Pasero 已提交
817
		 */
B
Benjamin Pasero 已提交
818
		on(event: 'maximize', listener: Function): this;
B
Benjamin Pasero 已提交
819
		/**
B
Benjamin Pasero 已提交
820
		 * Emitted when the window exits from maximized state.
B
Benjamin Pasero 已提交
821
		 */
B
Benjamin Pasero 已提交
822
		on(event: 'unmaximize', listener: Function): this;
B
Benjamin Pasero 已提交
823
		/**
B
Benjamin Pasero 已提交
824
		 * Emitted when the window is minimized.
B
Benjamin Pasero 已提交
825
		 */
B
Benjamin Pasero 已提交
826
		on(event: 'minimize', listener: Function): this;
B
Benjamin Pasero 已提交
827
		/**
B
Benjamin Pasero 已提交
828
		 * Emitted when the window is restored from minimized state.
B
Benjamin Pasero 已提交
829
		 */
B
Benjamin Pasero 已提交
830
		on(event: 'restore', listener: Function): this;
831
		/**
B
Benjamin Pasero 已提交
832
		 * Emitted when the window is getting resized.
833
		 */
B
Benjamin Pasero 已提交
834
		on(event: 'resize', listener: Function): this;
B
Benjamin Pasero 已提交
835
		/**
B
Benjamin Pasero 已提交
836
		 * Emitted when the window is getting moved to a new position.
B
Benjamin Pasero 已提交
837
		 */
B
Benjamin Pasero 已提交
838
		on(event: 'move', listener: Function): this;
B
Benjamin Pasero 已提交
839
		/**
B
Benjamin Pasero 已提交
840
		 * Emitted when the window enters full screen state.
B
Benjamin Pasero 已提交
841
		 */
B
Benjamin Pasero 已提交
842
		on(event: 'enter-full-screen', listener: Function): this;
B
Benjamin Pasero 已提交
843
		/**
B
Benjamin Pasero 已提交
844
		 * Emitted when the window leaves full screen state.
B
Benjamin Pasero 已提交
845
		 */
B
Benjamin Pasero 已提交
846
		on(event: 'leave-full-screen', listener: Function): this;
B
Benjamin Pasero 已提交
847
		/**
B
Benjamin Pasero 已提交
848
		 * Emitted when the window enters full screen state triggered by HTML API.
B
Benjamin Pasero 已提交
849
		 */
B
Benjamin Pasero 已提交
850
		on(event: 'enter-html-full-screen', listener: Function): this;
B
Benjamin Pasero 已提交
851
		/**
B
Benjamin Pasero 已提交
852
		 * Emitted when the window leaves full screen state triggered by HTML API.
B
Benjamin Pasero 已提交
853
		 */
B
Benjamin Pasero 已提交
854
		on(event: 'leave-html-full-screen', listener: Function): this;
B
Benjamin Pasero 已提交
855
		/**
B
Benjamin Pasero 已提交
856 857 858 859
		 * Emitted when an App Command is invoked. These are typically related
		 * to keyboard media keys or browser commands, as well as the "Back" /
		 * "Forward" buttons built into some mice on Windows.
		 * Note: This is only implemented on Windows.
B
Benjamin Pasero 已提交
860
		 */
B
Benjamin Pasero 已提交
861
		on(event: 'app-command', listener: (event: Event, command: string) => void): this;
B
Benjamin Pasero 已提交
862
		/**
B
Benjamin Pasero 已提交
863 864
		 * Emitted when scroll wheel event phase has begun.
		 * Note: This is only implemented on macOS.
B
Benjamin Pasero 已提交
865
		 */
B
Benjamin Pasero 已提交
866
		on(event: 'scroll-touch-begin', listener: Function): this;
B
Benjamin Pasero 已提交
867
		/**
B
Benjamin Pasero 已提交
868 869
		 * Emitted when scroll wheel event phase has ended.
		 * Note: This is only implemented on macOS.
B
Benjamin Pasero 已提交
870
		 */
B
Benjamin Pasero 已提交
871
		on(event: 'scroll-touch-end', listener: Function): this;
872 873 874 875 876
		/**
		 * Emitted when scroll wheel event phase filed upon reaching the edge of element.
		 * Note: This is only implemented on macOS.
		 */
		on(event: 'scroll-touch-edge', listener: Function): this;
B
Benjamin Pasero 已提交
877
		/**
B
Benjamin Pasero 已提交
878 879
		 * Emitted on 3-finger swipe.
		 * Note: This is only implemented on macOS.
B
Benjamin Pasero 已提交
880
		 */
B
Benjamin Pasero 已提交
881 882
		on(event: 'swipe', listener: (event: Event, direction: SwipeDirection) => void): this;
		on(event: string, listener: Function): this;
B
Benjamin Pasero 已提交
883 884 885
		/**
		 * Creates a new BrowserWindow with native properties as set by the options.
		 */
B
Benjamin Pasero 已提交
886
		constructor(options?: BrowserWindowOptions);
B
Benjamin Pasero 已提交
887
		/**
B
Benjamin Pasero 已提交
888
		 * @returns All opened browser windows.
B
Benjamin Pasero 已提交
889
		 */
B
Benjamin Pasero 已提交
890
		static getAllWindows(): BrowserWindow[];
B
Benjamin Pasero 已提交
891
		/**
B
Benjamin Pasero 已提交
892
		 * @returns The window that is focused in this application.
B
Benjamin Pasero 已提交
893
		 */
B
Benjamin Pasero 已提交
894
		static getFocusedWindow(): BrowserWindow;
B
Benjamin Pasero 已提交
895
		/**
B
Benjamin Pasero 已提交
896
		 * Find a window according to the webContents it owns.
B
Benjamin Pasero 已提交
897
		 */
B
Benjamin Pasero 已提交
898
		static fromWebContents(webContents: WebContents): BrowserWindow;
B
Benjamin Pasero 已提交
899
		/**
B
Benjamin Pasero 已提交
900
		 * Find a window according to its ID.
B
Benjamin Pasero 已提交
901
		 */
B
Benjamin Pasero 已提交
902
		static fromId(id: number): BrowserWindow;
B
Benjamin Pasero 已提交
903
		/**
B
Benjamin Pasero 已提交
904 905 906 907 908
		 * Adds devtools extension located at path. The extension will be remembered
		 * so you only need to call this API once, this API is not for programming use.
		 * @returns The extension's name.
		 *
		 * Note: This API cannot be called before the ready event of the app module is emitted.
B
Benjamin Pasero 已提交
909
		 */
B
Benjamin Pasero 已提交
910
		static addDevToolsExtension(path: string): string;
B
Benjamin Pasero 已提交
911
		/**
B
Benjamin Pasero 已提交
912 913 914 915
		 * Remove a devtools extension.
		 * @param name The name of the devtools extension to remove.
		 *
		 * Note: This API cannot be called before the ready event of the app module is emitted.
B
Benjamin Pasero 已提交
916
		 */
B
Benjamin Pasero 已提交
917
		static removeDevToolsExtension(name: string): void;
B
Benjamin Pasero 已提交
918
		/**
B
Benjamin Pasero 已提交
919 920 921
		 * @returns devtools extensions.
		 *
		 * Note: This API cannot be called before the ready event of the app module is emitted.
B
Benjamin Pasero 已提交
922
		 */
B
Benjamin Pasero 已提交
923
		static getDevToolsExtensions(): DevToolsExtensions;
B
Benjamin Pasero 已提交
924
		/**
B
Benjamin Pasero 已提交
925 926 927 928
		 * The WebContents object this window owns, all web page related events and
		 * operations would be done via it.
		 * Note: Users should never store this object because it may become null when
		 * the renderer process (web page) has crashed.
B
Benjamin Pasero 已提交
929
		 */
B
Benjamin Pasero 已提交
930
		webContents: WebContents;
B
Benjamin Pasero 已提交
931
		/**
B
Benjamin Pasero 已提交
932
		 * Get the unique ID of this window.
B
Benjamin Pasero 已提交
933
		 */
B
Benjamin Pasero 已提交
934
		id: number;
B
Benjamin Pasero 已提交
935
		/**
B
Benjamin Pasero 已提交
936 937 938 939
		 * Force closing the window, the unload and beforeunload event won't be emitted
		 * for the web page, and close event would also not be emitted for this window,
		 * but it would guarantee the closed event to be emitted.
		 * You should only use this method when the renderer process (web page) has crashed.
B
Benjamin Pasero 已提交
940
		 */
B
Benjamin Pasero 已提交
941
		destroy(): void;
B
Benjamin Pasero 已提交
942
		/**
B
Benjamin Pasero 已提交
943 944 945
		 * Try to close the window, this has the same effect with user manually clicking
		 * the close button of the window. The web page may cancel the close though,
		 * see the close event.
B
Benjamin Pasero 已提交
946
		 */
B
Benjamin Pasero 已提交
947
		close(): void;
B
Benjamin Pasero 已提交
948
		/**
B
Benjamin Pasero 已提交
949
		 * Focus on the window.
B
Benjamin Pasero 已提交
950
		 */
B
Benjamin Pasero 已提交
951
		focus(): void;
B
Benjamin Pasero 已提交
952
		/**
B
Benjamin Pasero 已提交
953
		 * Remove focus on the window.
B
Benjamin Pasero 已提交
954
		 */
B
Benjamin Pasero 已提交
955
		blur(): void;
B
Benjamin Pasero 已提交
956
		/**
B
Benjamin Pasero 已提交
957
		 * @returns Whether the window is focused.
B
Benjamin Pasero 已提交
958
		 */
B
Benjamin Pasero 已提交
959
		isFocused(): boolean;
B
Benjamin Pasero 已提交
960 961 962 963
		/**
		 * @returns Whether the window is destroyed.
		 */
		isDestroyed(): boolean;
B
Benjamin Pasero 已提交
964
		/**
B
Benjamin Pasero 已提交
965
		 * Shows and gives focus to the window.
B
Benjamin Pasero 已提交
966
		 */
B
Benjamin Pasero 已提交
967
		show(): void;
B
Benjamin Pasero 已提交
968
		/**
B
Benjamin Pasero 已提交
969
		 * Shows the window but doesn't focus on it.
B
Benjamin Pasero 已提交
970
		 */
B
Benjamin Pasero 已提交
971
		showInactive(): void;
B
Benjamin Pasero 已提交
972
		/**
B
Benjamin Pasero 已提交
973
		 * Hides the window.
B
Benjamin Pasero 已提交
974
		 */
B
Benjamin Pasero 已提交
975
		hide(): void;
B
Benjamin Pasero 已提交
976
		/**
B
Benjamin Pasero 已提交
977
		 * @returns Whether the window is visible to the user.
B
Benjamin Pasero 已提交
978
		 */
B
Benjamin Pasero 已提交
979
		isVisible(): boolean;
B
Benjamin Pasero 已提交
980
		/**
B
Benjamin Pasero 已提交
981
		 * @returns Whether the window is a modal window.
B
Benjamin Pasero 已提交
982
		 */
B
Benjamin Pasero 已提交
983
		isModal(): boolean;
B
Benjamin Pasero 已提交
984
		/**
B
Benjamin Pasero 已提交
985
		 * Maximizes the window.
B
Benjamin Pasero 已提交
986
		 */
B
Benjamin Pasero 已提交
987
		maximize(): void;
B
Benjamin Pasero 已提交
988
		/**
B
Benjamin Pasero 已提交
989
		 * Unmaximizes the window.
B
Benjamin Pasero 已提交
990
		 */
B
Benjamin Pasero 已提交
991
		unmaximize(): void;
B
Benjamin Pasero 已提交
992
		/**
B
Benjamin Pasero 已提交
993
		 * @returns Whether the window is maximized.
B
Benjamin Pasero 已提交
994
		 */
B
Benjamin Pasero 已提交
995
		isMaximized(): boolean;
B
Benjamin Pasero 已提交
996
		/**
B
Benjamin Pasero 已提交
997 998
		 * Minimizes the window. On some platforms the minimized window will be
		 * shown in the Dock.
B
Benjamin Pasero 已提交
999
		 */
B
Benjamin Pasero 已提交
1000
		minimize(): void;
B
Benjamin Pasero 已提交
1001
		/**
B
Benjamin Pasero 已提交
1002
		 * Restores the window from minimized state to its previous state.
B
Benjamin Pasero 已提交
1003
		 */
B
Benjamin Pasero 已提交
1004
		restore(): void;
B
Benjamin Pasero 已提交
1005
		/**
B
Benjamin Pasero 已提交
1006
		 * @returns Whether the window is minimized.
B
Benjamin Pasero 已提交
1007
		 */
B
Benjamin Pasero 已提交
1008
		isMinimized(): boolean;
B
Benjamin Pasero 已提交
1009
		/**
B
Benjamin Pasero 已提交
1010
		 * Sets whether the window should be in fullscreen mode.
B
Benjamin Pasero 已提交
1011
		 */
B
Benjamin Pasero 已提交
1012
		setFullScreen(flag: boolean): void;
B
Benjamin Pasero 已提交
1013
		/**
B
Benjamin Pasero 已提交
1014
		 * @returns Whether the window is in fullscreen mode.
B
Benjamin Pasero 已提交
1015
		 */
B
Benjamin Pasero 已提交
1016
		isFullScreen(): boolean;
B
Benjamin Pasero 已提交
1017
		/**
B
Benjamin Pasero 已提交
1018 1019 1020 1021 1022 1023
		 * This will have a window maintain an aspect ratio.
		 * The extra size allows a developer to have space, specified in pixels,
		 * not included within the aspect ratio calculations.
		 * This API already takes into account the difference between a window’s size and its content size.
		 *
		 * Note: This API is available only on macOS.
B
Benjamin Pasero 已提交
1024
		 */
B
Benjamin Pasero 已提交
1025
		setAspectRatio(aspectRatio: number, extraSize?: Size): void;
J
Joao Moreno 已提交
1026 1027 1028 1029 1030 1031 1032 1033
		/**
		 * Uses Quick Look to preview a file at a given path.
		 *
		 * @param path The absolute path to the file to preview with QuickLook.
		 * @param displayName The name of the file to display on the Quick Look modal view.
		 * Note: This API is available only on macOS.
		 */
		previewFile(path: string, displayName?: string): void;
B
Benjamin Pasero 已提交
1034
		/**
B
Benjamin Pasero 已提交
1035
		 * Resizes and moves the window to width, height, x, y.
B
Benjamin Pasero 已提交
1036
		 */
B
Benjamin Pasero 已提交
1037
		setBounds(options: Rectangle, animate?: boolean): void;
B
Benjamin Pasero 已提交
1038
		/**
B
Benjamin Pasero 已提交
1039
		 * @returns The window's width, height, x and y values.
B
Benjamin Pasero 已提交
1040
		 */
B
Benjamin Pasero 已提交
1041
		getBounds(): Rectangle;
B
Benjamin Pasero 已提交
1042 1043 1044 1045 1046 1047 1048 1049
		/**
		 * Resizes and moves the window's client area (e.g. the web page) to width, height, x, y.
		 */
		setContentBounds(options: Rectangle, animate?: boolean): void;
		/**
		 * @returns The window's client area (e.g. the web page) width, height, x and y values.
		 */
		getContentBounds(): Rectangle;
B
Benjamin Pasero 已提交
1050
		/**
B
Benjamin Pasero 已提交
1051
		 * Resizes the window to width and height.
B
Benjamin Pasero 已提交
1052
		 */
B
Benjamin Pasero 已提交
1053
		setSize(width: number, height: number, animate?: boolean): void;
1054
		/**
B
Benjamin Pasero 已提交
1055
		 * @returns The window's width and height.
1056
		 */
B
Benjamin Pasero 已提交
1057
		getSize(): number[];
B
Benjamin Pasero 已提交
1058
		/**
B
Benjamin Pasero 已提交
1059
		 * Resizes the window's client area (e.g. the web page) to width and height.
B
Benjamin Pasero 已提交
1060
		 */
B
Benjamin Pasero 已提交
1061
		setContentSize(width: number, height: number, animate?: boolean): void;
B
Benjamin Pasero 已提交
1062
		/**
B
Benjamin Pasero 已提交
1063
		 * @returns The window's client area's width and height.
B
Benjamin Pasero 已提交
1064
		 */
B
Benjamin Pasero 已提交
1065
		getContentSize(): number[];
B
Benjamin Pasero 已提交
1066
		/**
B
Benjamin Pasero 已提交
1067
		 * Sets the minimum size of window to width and height.
B
Benjamin Pasero 已提交
1068
		 */
B
Benjamin Pasero 已提交
1069
		setMinimumSize(width: number, height: number): void;
B
Benjamin Pasero 已提交
1070
		/**
B
Benjamin Pasero 已提交
1071
		 * @returns The window's minimum width and height.
B
Benjamin Pasero 已提交
1072
		 */
B
Benjamin Pasero 已提交
1073
		getMinimumSize(): number[];
B
Benjamin Pasero 已提交
1074
		/**
B
Benjamin Pasero 已提交
1075
		 * Sets the maximum size of window to width and height.
B
Benjamin Pasero 已提交
1076
		 */
B
Benjamin Pasero 已提交
1077
		setMaximumSize(width: number, height: number): void;
B
Benjamin Pasero 已提交
1078
		/**
B
Benjamin Pasero 已提交
1079
		 * @returns The window's maximum width and height.
B
Benjamin Pasero 已提交
1080
		 */
B
Benjamin Pasero 已提交
1081
		getMaximumSize(): number[];
B
Benjamin Pasero 已提交
1082
		/**
B
Benjamin Pasero 已提交
1083
		 * Sets whether the window can be manually resized by user.
B
Benjamin Pasero 已提交
1084
		 */
B
Benjamin Pasero 已提交
1085
		setResizable(resizable: boolean): void;
B
Benjamin Pasero 已提交
1086
		/**
B
Benjamin Pasero 已提交
1087
		 * @returns Whether the window can be manually resized by user.
B
Benjamin Pasero 已提交
1088
		 */
B
Benjamin Pasero 已提交
1089
		isResizable(): boolean;
B
Benjamin Pasero 已提交
1090
		/**
B
Benjamin Pasero 已提交
1091 1092
		 * Sets whether the window can be moved by user. On Linux does nothing.
		 * Note: This API is available only on macOS and Windows.
B
Benjamin Pasero 已提交
1093
		 */
B
Benjamin Pasero 已提交
1094
		setMovable(movable: boolean): void;
B
Benjamin Pasero 已提交
1095
		/**
B
Benjamin Pasero 已提交
1096 1097
		 * Note: This API is available only on macOS and Windows.
		 * @returns Whether the window can be moved by user. On Linux always returns true.
B
Benjamin Pasero 已提交
1098
		 */
B
Benjamin Pasero 已提交
1099
		isMovable(): boolean;
B
Benjamin Pasero 已提交
1100
		/**
B
Benjamin Pasero 已提交
1101 1102
		 * Sets whether the window can be manually minimized by user. On Linux does nothing.
		 * Note: This API is available only on macOS and Windows.
B
Benjamin Pasero 已提交
1103
		 */
B
Benjamin Pasero 已提交
1104
		setMinimizable(minimizable: boolean): void;
B
Benjamin Pasero 已提交
1105
		/**
B
Benjamin Pasero 已提交
1106 1107
		 * Note: This API is available only on macOS and Windows.
		 * @returns Whether the window can be manually minimized by user. On Linux always returns true.
B
Benjamin Pasero 已提交
1108
		 */
B
Benjamin Pasero 已提交
1109
		isMinimizable(): boolean;
B
Benjamin Pasero 已提交
1110
		/**
B
Benjamin Pasero 已提交
1111 1112
		 * Sets whether the window can be manually maximized by user. On Linux does nothing.
		 * Note: This API is available only on macOS and Windows.
B
Benjamin Pasero 已提交
1113
		 */
B
Benjamin Pasero 已提交
1114
		setMaximizable(maximizable: boolean): void;
B
Benjamin Pasero 已提交
1115
		/**
B
Benjamin Pasero 已提交
1116 1117
		 * Note: This API is available only on macOS and Windows.
		 * @returns Whether the window can be manually maximized by user. On Linux always returns true.
B
Benjamin Pasero 已提交
1118
		 */
B
Benjamin Pasero 已提交
1119
		isMaximizable(): boolean;
B
Benjamin Pasero 已提交
1120
		/**
B
Benjamin Pasero 已提交
1121
		 * Sets whether the maximize/zoom window button toggles fullscreen mode or maximizes the window.
B
Benjamin Pasero 已提交
1122
		 */
B
Benjamin Pasero 已提交
1123
		setFullScreenable(fullscreenable: boolean): void;
B
Benjamin Pasero 已提交
1124
		/**
B
Benjamin Pasero 已提交
1125
		 * @returns Whether the maximize/zoom window button toggles fullscreen mode or maximizes the window.
B
Benjamin Pasero 已提交
1126
		 */
B
Benjamin Pasero 已提交
1127
		isFullScreenable(): boolean;
B
Benjamin Pasero 已提交
1128
		/**
B
Benjamin Pasero 已提交
1129 1130
		 * Sets whether the window can be manually closed by user. On Linux does nothing.
		 * Note: This API is available only on macOS and Windows.
B
Benjamin Pasero 已提交
1131
		 */
B
Benjamin Pasero 已提交
1132
		setClosable(closable: boolean): void;
B
Benjamin Pasero 已提交
1133
		/**
B
Benjamin Pasero 已提交
1134 1135
		 * Note: This API is available only on macOS and Windows.
		 * @returns Whether the window can be manually closed by user. On Linux always returns true.
B
Benjamin Pasero 已提交
1136
		 */
B
Benjamin Pasero 已提交
1137
		isClosable(): boolean;
B
Benjamin Pasero 已提交
1138
		/**
B
Benjamin Pasero 已提交
1139 1140 1141
		 * Sets whether the window should show always on top of other windows. After
		 * setting this, the window is still a normal window, not a toolbox window
		 * which can not be focused on.
B
Benjamin Pasero 已提交
1142
		 */
1143
		setAlwaysOnTop(flag: boolean, level?: WindowLevel): void;
B
Benjamin Pasero 已提交
1144
		/**
B
Benjamin Pasero 已提交
1145
		 * @returns Whether the window is always on top of other windows.
B
Benjamin Pasero 已提交
1146
		 */
B
Benjamin Pasero 已提交
1147
		isAlwaysOnTop(): boolean;
B
Benjamin Pasero 已提交
1148
		/**
B
Benjamin Pasero 已提交
1149
		 * Moves window to the center of the screen.
B
Benjamin Pasero 已提交
1150
		 */
B
Benjamin Pasero 已提交
1151
		center(): void;
B
Benjamin Pasero 已提交
1152
		/**
B
Benjamin Pasero 已提交
1153
		 * Moves window to x and y.
B
Benjamin Pasero 已提交
1154
		 */
B
Benjamin Pasero 已提交
1155
		setPosition(x: number, y: number, animate?: boolean): void;
B
Benjamin Pasero 已提交
1156
		/**
B
Benjamin Pasero 已提交
1157
		 * @returns The window's current position.
B
Benjamin Pasero 已提交
1158
		 */
B
Benjamin Pasero 已提交
1159
		getPosition(): number[];
B
Benjamin Pasero 已提交
1160
		/**
B
Benjamin Pasero 已提交
1161
		 * Changes the title of native window to title.
B
Benjamin Pasero 已提交
1162
		 */
B
Benjamin Pasero 已提交
1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244
		setTitle(title: string): void;
		/**
		 * Note: The title of web page can be different from the title of the native window.
		 * @returns The title of the native window.
		 */
		getTitle(): string;
		/**
		 * Changes the attachment point for sheets on macOS.
		 * Note: This API is available only on macOS.
		 */
		setSheetOffset(offsetY: number, offsetX?: number): void;
		/**
		 * Starts or stops flashing the window to attract user's attention.
		 */
		flashFrame(flag: boolean): void;
		/**
		 * Makes the window do not show in Taskbar.
		 */
		setSkipTaskbar(skip: boolean): void;
		/**
		 * Enters or leaves the kiosk mode.
		 */
		setKiosk(flag: boolean): void;
		/**
		 * @returns Whether the window is in kiosk mode.
		 */
		isKiosk(): boolean;
		/**
		 * The native type of the handle is HWND on Windows, NSView* on macOS,
		 * and Window (unsigned long) on Linux.
		 * @returns The platform-specific handle of the window as Buffer.
		 */
		getNativeWindowHandle(): Buffer;
		/**
		 * Hooks a windows message. The callback is called when the message is received in the WndProc.
		 * Note: This API is available only on Windows.
		 */
		hookWindowMessage(message: number, callback: Function): void;
		/**
		 * @returns Whether the message is hooked.
		 */
		isWindowMessageHooked(message: number): boolean;
		/**
		 * Unhook the window message.
		 */
		unhookWindowMessage(message: number): void;
		/**
		 * Unhooks all of the window messages.
		 */
		unhookAllWindowMessages(): void;
		/**
		 * Sets the pathname of the file the window represents, and the icon of the
		 * file will show in window's title bar.
		 * Note: This API is available only on macOS.
		 */
		setRepresentedFilename(filename: string): void;
		/**
		 * Note: This API is available only on macOS.
		 * @returns The pathname of the file the window represents.
		 */
		getRepresentedFilename(): string;
		/**
		 * Specifies whether the window’s document has been edited, and the icon in
		 * title bar will become grey when set to true.
		 * Note: This API is available only on macOS.
		 */
		setDocumentEdited(edited: boolean): void;
		/**
		 * Note: This API is available only on macOS.
		 * @returns Whether the window's document has been edited.
		 */
		isDocumentEdited(): boolean;
		focusOnWebView(): void;
		blurWebView(): void;
		/**
		 * Captures the snapshot of page within rect, upon completion the callback
		 * will be called. Omitting the rect would capture the whole visible page.
		 * Note: Be sure to read documents on remote buffer in remote if you are going
		 * to use this API in renderer process.
		 * @param callback Supplies the image that stores data of the snapshot.
		 */
		capturePage(rect: Rectangle, callback: (image: NativeImage) => void): void;
B
Benjamin Pasero 已提交
1245 1246 1247 1248 1249 1250 1251
		/**
		 * Captures the snapshot of page within rect, upon completion the callback
		 * will be called. Omitting the rect would capture the whole visible page.
		 * Note: Be sure to read documents on remote buffer in remote if you are going
		 * to use this API in renderer process.
		 * @param callback Supplies the image that stores data of the snapshot.
		 */
B
Benjamin Pasero 已提交
1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273
		capturePage(callback: (image: NativeImage) => void): void;
		/**
		 * Same as webContents.loadURL(url).
		 */
		loadURL(url: string, options?: LoadURLOptions): void;
		/**
		 * Same as webContents.reload.
		 */
		reload(): void;
		/**
		 * Sets the menu as the window top menu.
		 * Note: This API is not available on macOS.
		 */
		setMenu(menu: Menu): void;
		/**
		 * Sets the progress value in the progress bar.
		 * On Linux platform, only supports Unity desktop environment, you need to
		 * specify the *.desktop file name to desktopName field in package.json.
		 * By default, it will assume app.getName().desktop.
		 * @param progress Valid range is [0, 1.0]. If < 0, the progress bar is removed.
		 * If greater than 0, it becomes indeterminate.
		 */
B
Benjamin Pasero 已提交
1274 1275 1276 1277 1278 1279 1280
		setProgressBar(progress: number, options?: {
			/**
			 * Mode for the progress bar.
			 * Note: This is only implemented on Windows.
			 */
			mode: 'none' | 'normal' | 'indeterminate' | 'error' | 'paused'
		}): void;
B
Benjamin Pasero 已提交
1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303
		/**
		 * Sets a 16px overlay onto the current Taskbar icon, usually used to convey
		 * some sort of application status or to passively notify the user.
		 * Note: This API is only available on Windows 7 or above.
		 * @param overlay The icon to display on the bottom right corner of the Taskbar
		 * icon. If this parameter is null, the overlay is cleared
		 * @param description Provided to Accessibility screen readers.
		 */
		setOverlayIcon(overlay: NativeImage, description: string): void;
		/**
		 * Sets whether the window should have a shadow. On Windows and Linux does nothing.
		 * Note: This API is available only on macOS.
		 */
		setHasShadow(hasShadow: boolean): void;
		/**
		 * Note: This API is available only on macOS.
		 * @returns whether the window has a shadow. On Windows and Linux always returns true.
		 */
		hasShadow(): boolean;
		/**
		 * Add a thumbnail toolbar with a specified set of buttons to the thumbnail image
		 * of a window in a taskbar button layout.
		 * @returns Whether the thumbnail has been added successfully.
B
Benjamin Pasero 已提交
1304 1305
		 *
		 * Note: This API is available only on Windows.
B
Benjamin Pasero 已提交
1306 1307
		 */
		setThumbarButtons(buttons: ThumbarButton[]): boolean;
B
Benjamin Pasero 已提交
1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320
		/**
		 * Sets the region of the window to show as the thumbnail image displayed when hovering
		 * over the window in the taskbar. You can reset the thumbnail to be the entire window
		 * by specifying an empty region: {x: 0, y: 0, width: 0, height: 0}.
		 *
		 * Note: This API is available only on Windows.
		 */
		setThumbnailClip(region: Rectangle): boolean;
		/**
		 * Sets the toolTip that is displayed when hovering over the window thumbnail in the taskbar.
		 * Note: This API is available only on Windows.
		 */
		setThumbnailToolTip(toolTip: string): boolean;
B
Benjamin Pasero 已提交
1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395
		/**
		 * Same as webContents.showDefinitionForSelection().
		 * Note: This API is available only on macOS.
		 */
		showDefinitionForSelection(): void;
		/**
		 * Changes window icon.
		 * Note: This API is not available on macOS.
		 */
		setIcon(icon: NativeImage): void;
		/**
		 * Sets whether the window menu bar should hide itself automatically. Once set
		 * the menu bar will only show when users press the single Alt key.
		 * If the menu bar is already visible, calling setAutoHideMenuBar(true) won't
		 * hide it immediately.
		 */
		setAutoHideMenuBar(hide: boolean): void;
		/**
		 * @returns Whether menu bar automatically hides itself.
		 */
		isMenuBarAutoHide(): boolean;
		/**
		 * Sets whether the menu bar should be visible. If the menu bar is auto-hide,
		 * users can still bring up the menu bar by pressing the single Alt key.
		 */
		setMenuBarVisibility(visibile: boolean): void;
		/**
		 * @returns Whether the menu bar is visible.
		 */
		isMenuBarVisible(): boolean;
		/**
		 * Sets whether the window should be visible on all workspaces.
		 * Note: This API does nothing on Windows.
		 */
		setVisibleOnAllWorkspaces(visible: boolean): void;
		/**
		 * Note: This API always returns false on Windows.
		 * @returns Whether the window is visible on all workspaces.
		 */
		isVisibleOnAllWorkspaces(): boolean;
		/**
		 * Makes the window ignore all mouse events.
		 *
		 * All mouse events happened in this window will be passed to the window below this window,
		 * but if this window has focus, it will still receive keyboard events.
		 */
		setIgnoreMouseEvents(ignore: boolean): void;
		/**
		 * Prevents the window contents from being captured by other apps.
		 *
		 * On macOS it sets the NSWindow's sharingType to NSWindowSharingNone.
		 * On Windows it calls SetWindowDisplayAffinity with WDA_MONITOR.
		 */
		setContentProtection(enable: boolean): void;
		/**
		 * Changes whether the window can be focused.
		 * Note: This API is available only on Windows.
		 */
		setFocusable(focusable: boolean): void;
		/**
		 * Sets parent as current window's parent window,
		 * passing null will turn current window into a top-level window.
		 * Note: This API is not available on Windows.
		 */
		setParentWindow(parent: BrowserWindow): void;
		/**
		 * @returns The parent window.
		 */
		getParentWindow(): BrowserWindow;
		/**
		 * @returns All child windows.
		 */
		getChildWindows(): BrowserWindow[];
	}

1396
	type WindowLevel = 'normal' | 'floating' | 'torn-off-menu' | 'modal-panel' | 'main-menu' | 'status' | 'pop-up-menu' | 'screen-saver' | 'dock';
B
Benjamin Pasero 已提交
1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414
	type SwipeDirection = 'up' | 'right' | 'down' | 'left';
	type ThumbarButtonFlags = 'enabled' | 'disabled' | 'dismissonclick' | 'nobackground' | 'hidden' | 'noninteractive';

	interface ThumbarButton {
		icon: NativeImage | string;
		click: Function;
		tooltip?: string;
		flags?: ThumbarButtonFlags[];
	}

	interface DevToolsExtensions {
		[name: string]: {
			name: string;
			value: string;
		}
	}

	interface WebPreferences {
1415 1416 1417 1418 1419 1420
		/**
		 * Whether to enable DevTools.
		 * If it is set to false, can not use BrowserWindow.webContents.openDevTools() to open DevTools.
		 * Default: true.
		 */
		devTools?: boolean;
B
Benjamin Pasero 已提交
1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568
		/**
		 * Whether node integration is enabled.
		 * Default: true.
		 */
		nodeIntegration?: boolean;
		/**
		 * Specifies a script that will be loaded before other scripts run in the page.
		 * This script will always have access to node APIs no matter whether node integration is turned on or off.
		 * The value should be the absolute file path to the script.
		 * When node integration is turned off, the preload script can reintroduce
		 * Node global symbols back to the global scope.
		 */
		preload?: string;
		/**
		 * Sets the session used by the page. Instead of passing the Session object directly,
		 * you can also choose to use the partition option instead, which accepts a partition string.
		 * When both session and partition are provided, session would be preferred.
		 * Default: the default session.
		 */
		session?: Session;
		/**
		 * Sets the session used by the page according to the session’s partition string.
		 * If partition starts with persist:, the page will use a persistent session available
		 * to all pages in the app with the same partition. if there is no persist: prefix,
		 * the page will use an in-memory session. By assigning the same partition,
		 * multiple pages can share the same session.
		 * Default: the default session.
		 */
		partition?: string;
		/**
		 * The default zoom factor of the page, 3.0 represents 300%.
		 * Default: 1.0.
		 */
		zoomFactor?: number;
		/**
		 * Enables JavaScript support.
		 * Default: true.
		 */
		javascript?: boolean;
		/**
		 * When setting false, it will disable the same-origin policy (Usually using testing
		 * websites by people), and set allowDisplayingInsecureContent and allowRunningInsecureContent
		 * to true if these two options are not set by user.
		 * Default: true.
		 */
		webSecurity?: boolean;
		/**
		 * Allow an https page to display content like images from http URLs.
		 * Default: false.
		 */
		allowDisplayingInsecureContent?: boolean;
		/**
		 * Allow a https page to run JavaScript, CSS or plugins from http URLs.
		 * Default: false.
		 */
		allowRunningInsecureContent?: boolean;
		/**
		 * Enables image support.
		 * Default: true.
		 */
		images?: boolean;
		/**
		 * Make TextArea elements resizable.
		 * Default: true.
		 */
		textAreasAreResizable?: boolean;
		/**
		 * Enables WebGL support.
		 * Default: true.
		 */
		webgl?: boolean;
		/**
		 * Enables WebAudio support.
		 * Default: true.
		 */
		webaudio?: boolean;
		/**
		 * Whether plugins should be enabled.
		 * Default: false.
		 */
		plugins?: boolean;
		/**
		 * Enables Chromium’s experimental features.
		 * Default: false.
		 */
		experimentalFeatures?: boolean;
		/**
		 * Enables Chromium’s experimental canvas features.
		 * Default: false.
		 */
		experimentalCanvasFeatures?: boolean;
		/**
		 * Enables DirectWrite font rendering system on Windows.
		 * Default: true.
		 */
		directWrite?: boolean;
		/**
		 * Enables scroll bounce (rubber banding) effect on macOS.
		 * Default: false.
		 */
		scrollBounce?: boolean;
		/**
		 * A list of feature strings separated by ",", like CSSVariables,KeyboardEventKey to enable.
		 */
		blinkFeatures?: string;
		/**
		 * A list of feature strings separated by ",", like CSSVariables,KeyboardEventKey to disable.
		 */
		disableBlinkFeatures?: string;
		/**
		 * Sets the default font for the font-family.
		 */
		defaultFontFamily?: {
			/**
			 * Default: Times New Roman.
			 */
			standard?: string;
			/**
			 * Default: Times New Roman.
			 */
			serif?: string;
			/**
			 * Default: Arial.
			 */
			sansSerif?: string;
			/**
			 * Default: Courier New.
			 */
			monospace?: string;
		};
		/**
		 * Default: 16.
		 */
		defaultFontSize?: number;
		/**
		 * Default: 13.
		 */
		defaultMonospaceFontSize?: number;
		/**
		 * Default: 0.
		 */
		minimumFontSize?: number;
		/**
		 * Default: ISO-8859-1.
		 */
		defaultEncoding?: string;
		/**
		 * Whether to throttle animations and timers when the page becomes background.
B
Benjamin Pasero 已提交
1569
		 * Default: true.
B
Benjamin Pasero 已提交
1570 1571
		 */
		backgroundThrottling?: boolean;
B
Benjamin Pasero 已提交
1572 1573 1574 1575 1576
		/**
		 * Whether to enable offscreen rendering for the browser window.
		 * Default: false.
		 */
		offscreen?: boolean;
1577 1578 1579 1580 1581
		/**
		 * Whether to enable Chromium OS-level sandbox.
		 * Default: false.
		 */
		sandbox?: boolean;
B
Benjamin Pasero 已提交
1582 1583
	}

B
Benjamin Pasero 已提交
1584
	interface BrowserWindowOptions {
B
Benjamin Pasero 已提交
1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707
		/**
		 * Window’s width in pixels.
		 * Default: 800.
		 */
		width?: number;
		/**
		 * Window’s height in pixels.
		 * Default: 600.
		 */
		height?: number;
		/**
		 * Window’s left offset from screen.
		 * Default: center the window.
		 */
		x?: number;
		/**
		 * Window’s top offset from screen.
		 * Default: center the window.
		 */
		y?: number;
		/**
		 * The width and height would be used as web page’s size, which means
		 * the actual window’s size will include window frame’s size and be slightly larger.
		 * Default: false.
		 */
		useContentSize?: boolean;
		/**
		 * Show window in the center of the screen.
		 * Default: true
		 */
		center?: boolean;
		/**
		 * Window’s minimum width.
		 * Default: 0.
		 */
		minWidth?: number;
		/**
		 * Window’s minimum height.
		 * Default: 0.
		 */
		minHeight?: number;
		/**
		 * Window’s maximum width.
		 * Default: no limit.
		 */
		maxWidth?: number;
		/**
		 * Window’s maximum height.
		 * Default: no limit.
		 */
		maxHeight?: number;
		/**
		 * Whether window is resizable.
		 * Default: true.
		 */
		resizable?: boolean;
		/**
		 * Whether window is movable.
		 * Note: This is not implemented on Linux.
		 * Default: true.
		 */
		movable?: boolean;
		/**
		 * Whether window is minimizable.
		 * Note: This is not implemented on Linux.
		 * Default: true.
		 */
		minimizable?: boolean;
		/**
		 * Whether window is maximizable.
		 * Note: This is not implemented on Linux.
		 * Default: true.
		 */
		maximizable?: boolean;
		/**
		 * Whether window is closable.
		 * Note: This is not implemented on Linux.
		 * Default: true.
		 */
		closable?: boolean;
		/**
		 * Whether the window can be focused.
		 * On Windows setting focusable: false also implies setting skipTaskbar: true.
		 * On Linux setting focusable: false makes the window stop interacting with wm,
		 * so the window will always stay on top in all workspaces.
		 * Default: true.
		 */
		focusable?: boolean;
		/**
		 * Whether the window should always stay on top of other windows.
		 * Default: false.
		 */
		alwaysOnTop?: boolean;
		/**
		 * Whether the window should show in fullscreen.
		 * When explicitly set to false the fullscreen button will be hidden or disabled on macOS.
		 * Default: false.
		 */
		fullscreen?: boolean;
		/**
		 * Whether the window can be put into fullscreen mode.
		 * On macOS, also whether the maximize/zoom button should toggle full screen mode or maximize window.
		 * Default: true.
		 */
		fullscreenable?: boolean;
		/**
		 * Whether to show the window in taskbar.
		 * Default: false.
		 */
		skipTaskbar?: boolean;
		/**
		 * The kiosk mode.
		 * Default: false.
		 */
		kiosk?: boolean;
		/**
		 * Default window title.
		 * Default: "Electron".
		 */
		title?: string;
		/**
		 * The window icon, when omitted on Windows the executable’s icon would be used as window icon.
		 */
J
Joao Moreno 已提交
1708
		icon?: NativeImage | string;
B
Benjamin Pasero 已提交
1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778
		/**
		 * Whether window should be shown when created.
		 * Default: true.
		 */
		show?: boolean;
		/**
		 * Specify false to create a Frameless Window.
		 * Default: true.
		 */
		frame?: boolean;
		/**
		 * Specify parent window.
		 * Default: null.
		 */
		parent?: BrowserWindow;
		/**
		 * Whether this is a modal window. This only works when the window is a child window.
		 * Default: false.
		 */
		modal?: boolean;
		/**
		 * Whether the web view accepts a single mouse-down event that simultaneously activates the window.
		 * Default: false.
		 */
		acceptFirstMouse?: boolean;
		/**
		 * Whether to hide cursor when typing.
		 * Default: false.
		 */
		disableAutoHideCursor?: boolean;
		/**
		 * Auto hide the menu bar unless the Alt key is pressed.
		 * Default: true.
		 */
		autoHideMenuBar?: boolean;
		/**
		 * Enable the window to be resized larger than screen.
		 * Default: false.
		 */
		enableLargerThanScreen?: boolean;
		/**
		 * Window’s background color as Hexadecimal value, like #66CD00 or #FFF or #80FFFFFF (alpha is supported).
		 * Default: #FFF (white).
		 */
		backgroundColor?: string;
		/**
		 * Whether window should have a shadow.
		 * Note: This is only implemented on macOS.
		 * Default: true.
		 */
		hasShadow?: boolean;
		/**
		 * Forces using dark theme for the window.
		 * Note: Only works on some GTK+3 desktop environments.
		 * Default: false.
		 */
		darkTheme?: boolean;
		/**
		 * Makes the window transparent.
		 * Default: false.
		 */
		transparent?: boolean;
		/**
		 * The type of window, default is normal window.
		 */
		type?: BrowserWindowType;
		/**
		 * The style of window title bar.
		 */
		titleBarStyle?: 'default' | 'hidden' | 'hidden-inset';
B
Benjamin Pasero 已提交
1779 1780 1781 1782
		/**
		 * Use WS_THICKFRAME style for frameless windows on Windows
		 */
		thickFrame?: boolean;
B
Benjamin Pasero 已提交
1783 1784 1785 1786 1787 1788
		/**
		 * Settings of web page’s features.
		 */
		webPreferences?: WebPreferences;
	}

B
Benjamin Pasero 已提交
1789
	type BrowserWindowType = BrowserWindowTypeLinux | BrowserWindowTypeMac | BrowserWindowTypeWindows;
B
Benjamin Pasero 已提交
1790 1791
	type BrowserWindowTypeLinux = 'desktop' | 'dock' | 'toolbar' | 'splash' | 'notification';
	type BrowserWindowTypeMac = 'desktop' | 'textured';
B
Benjamin Pasero 已提交
1792
	type BrowserWindowTypeWindows = 'toolbar';
B
Benjamin Pasero 已提交
1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859

	// https://github.com/electron/electron/blob/master/docs/api/clipboard.md

	/**
	 * The clipboard module provides methods to perform copy and paste operations.
	 */
	interface Clipboard {
		/**
		 * @returns The contents of the clipboard as plain text.
		 */
		readText(type?: ClipboardType): string;
		/**
		 * Writes the text into the clipboard as plain text.
		 */
		writeText(text: string, type?: ClipboardType): void;
		/**
		 * @returns The contents of the clipboard as markup.
		 */
		readHTML(type?: ClipboardType): string;
		/**
		 * Writes markup to the clipboard.
		 */
		writeHTML(markup: string, type?: ClipboardType): void;
		/**
		 * @returns The contents of the clipboard as a NativeImage.
		 */
		readImage(type?: ClipboardType): NativeImage;
		/**
		 * Writes the image into the clipboard.
		 */
		writeImage(image: NativeImage, type?: ClipboardType): void;
		/**
		 * @returns The contents of the clipboard as RTF.
		 */
		readRTF(type?: ClipboardType): string;
		/**
		 * Writes the text into the clipboard in RTF.
		 */
		writeRTF(text: string, type?: ClipboardType): void;
		/**
		 * Clears everything in clipboard.
		 */
		clear(type?: ClipboardType): void;
		/**
		 * @returns Array available formats for the clipboard type.
		 */
		availableFormats(type?: ClipboardType): string[];
		/**
		 * Returns whether the clipboard supports the format of specified data.
		 * Note: This API is experimental and could be removed in future.
		 * @returns Whether the clipboard has data in the specified format.
		 */
		has(format: string, type?: ClipboardType): boolean;
		/**
		 * Reads the data in the clipboard of the specified format.
		 * Note: This API is experimental and could be removed in future.
		 */
		read(format: string, type?: ClipboardType): string | NativeImage;
		/**
		 * Writes data to the clipboard.
		 */
		write(data: {
			text?: string;
			rtf?: string;
			html?: string;
			image?: NativeImage;
		}, type?: ClipboardType): void;
B
Benjamin Pasero 已提交
1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871
		/**
		 * @returns An Object containing title and url keys representing the bookmark in the clipboard.
		 *
		 * Note: This API is available on macOS and Windows.
		 */
		readBookmark(): Bookmark;
		/**
		 * Writes the title and url into the clipboard as a bookmark.
		 *
		 * Note: This API is available on macOS and Windows.
		 */
		writeBookmark(title: string, url: string, type?: ClipboardType): void;
J
Joao Moreno 已提交
1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885
		/**
		 * The text on the find pasteboard. This method uses synchronous IPC when called from the renderer process.
		 * The cached value is reread from the find pasteboard whenever the application is activated.
		 *
		 * Note: This API is available on macOS.
		 */
		readFindText(): string;
		/**
		 * Writes the text into the find pasteboard as plain text.
		 * This method uses synchronous IPC when called from the renderer process.
		 *
		 * Note: This API is available on macOS.
		 */
		writeFindText(text: string): void;
B
Benjamin Pasero 已提交
1886 1887 1888 1889
	}

	type ClipboardType = '' | 'selection';

B
Benjamin Pasero 已提交
1890 1891 1892 1893 1894
	interface Bookmark {
		title: string;
		url: string;
	}

B
Benjamin Pasero 已提交
1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029
	// https://github.com/electron/electron/blob/master/docs/api/content-tracing.md

	/**
	 * The content-tracing module is used to collect tracing data generated by the underlying Chromium content module.
	 * This module does not include a web interface so you need to open chrome://tracing/
	 * in a Chrome browser and load the generated file to view the result.
	 */
	interface ContentTracing {
		/**
		 * Get a set of category groups. The category groups can change as new code paths are reached.
		 *
		 * @param callback Called once all child processes have acknowledged the getCategories request.
		 */
		getCategories(callback: (categoryGroups: string[]) => void): void;
		/**
		 * Start recording on all processes. Recording begins immediately locally and asynchronously
		 * on child processes as soon as they receive the EnableRecording request.
		 *
		 * @param callback Called once all child processes have acknowledged the startRecording request.
		 */
		startRecording(options: ContentTracingOptions, callback: Function): void;
		/**
		 * Stop recording on all processes. Child processes typically are caching trace data and
		 * only rarely flush and send trace data back to the main process. That is because it may
		 * be an expensive operation to send the trace data over IPC, and we would like to avoid
		 * much runtime overhead of tracing. So, to end tracing, we must asynchronously ask all
		 * child processes to flush any pending trace data.
		 *
		 * @param resultFilePath Trace data will be written into this file if it is not empty,
		 * or into a temporary file.
		 * @param callback Called once all child processes have acknowledged the stopRecording request.
		 */
		stopRecording(resultFilePath: string, callback: (filePath: string) => void): void;
		/**
		 * Start monitoring on all processes. Monitoring begins immediately locally and asynchronously
		 * on child processes as soon as they receive the startMonitoring request.
		 *
		 * @param callback Called once all child processes have acked to the startMonitoring request.
		 */
		startMonitoring(options: ContentTracingOptions, callback: Function): void;
		/**
		 * Stop monitoring on all processes.
		 *
		 * @param callback Called once all child processes have acknowledged the stopMonitoring request.
		 */
		stopMonitoring(callback: Function): void;
		/**
		 * Get the current monitoring traced data. Child processes typically are caching trace data
		 * and only rarely flush and send trace data back to the main process. That is because it may
		 * be an expensive operation to send the trace data over IPC, and we would like to avoid much
		 * runtime overhead of tracing. So, to end tracing, we must asynchronously ask all child
		 * processes to flush any pending trace data.
		 *
		 * @param callback Called once all child processes have acknowledged the captureMonitoringSnapshot request.
		 */
		captureMonitoringSnapshot(resultFilePath: string, callback: (filePath: string) => void): void;
		/**
		 * Get the maximum usage across processes of trace buffer as a percentage of the full state.
		 *
		 * @param callback Called when the TraceBufferUsage value is determined.
		 */
		getTraceBufferUsage(callback: Function): void;
		/**
		 * @param callback Called every time the given event occurs on any process.
		 */
		setWatchEvent(categoryName: string, eventName: string, callback: Function): void;
		/**
		 * Cancel the watch event. This may lead to a race condition with the watch event callback if tracing is enabled.
		 */
		cancelWatchEvent(): void;
	}

	interface ContentTracingOptions {
		/**
		 * Filter to control what category groups should be traced.
		 * A filter can have an optional - prefix to exclude category groups
		 * that contain a matching category. Having both included and excluded
		 * category patterns in the same list is not supported.
		 *
		 * Examples:
		 *   test_MyTest*
		 *   test_MyTest*,test_OtherStuff
		 *   -excluded_category1,-excluded_category2
		 */
		categoryFilter: string;
		/**
		 * Controls what kind of tracing is enabled, it is a comma-delimited list.
		 *
		 * Possible options are:
		 *   record-until-full
		 *   record-continuously
		 *   trace-to-console
		 *   enable-sampling
		 *   enable-systrace
		 *
		 * The first 3 options are trace recoding modes and hence mutually exclusive.
		 * If more than one trace recording modes appear in the traceOptions string,
		 * the last one takes precedence. If none of the trace recording modes are specified,
		 * recording mode is record-until-full.
		 *
		 * The trace option will first be reset to the default option (record_mode set
		 * to record-until-full, enable_sampling and enable_systrace set to false)
		 * before options parsed from traceOptions are applied on it.
		 */
		traceOptions: string;
	}

	// https://github.com/electron/electron/blob/master/docs/api/crash-reporter.md

	/**
	 * The crash-reporter module enables sending your app's crash reports.
	 */
	interface CrashReporter {
		/**
		 * You are required to call this method before using other crashReporter APIs.
		 *
		 * Note: On macOS, Electron uses a new crashpad client, which is different from breakpad
		 * on Windows and Linux. To enable the crash collection feature, you are required to call
		 * the crashReporter.start API to initialize crashpad in the main process and in each
		 * renderer process from which you wish to collect crash reports.
		 */
		start(options: CrashReporterStartOptions): void;
		/**
		 * @returns The crash report. When there was no crash report
		 * sent or the crash reporter is not started, null will be returned.
		 */
		getLastCrashReport(): CrashReport;
		/**
		 * @returns All uploaded crash reports.
		 */
		getUploadedReports(): CrashReport[];
	}

	interface CrashReporterStartOptions {
		/**
2030
		 * Default: app.getName()
B
Benjamin Pasero 已提交
2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050
		 */
		productName?: string;
		companyName: string;
		/**
		 * URL that crash reports would be sent to as POST.
		 */
		submitURL: string;
		/**
		 * Send the crash report without user interaction.
		 * Default: true.
		 */
		autoSubmit?: boolean;
		/**
		 * Default: false.
		 */
		ignoreSystemCrashHandler?: boolean;
		/**
		 * An object you can define that will be sent along with the report.
		 * Only string properties are sent correctly, nested objects are not supported.
		 */
J
Joao Moreno 已提交
2051
		extra?: { [prop: string]: string };
B
Benjamin Pasero 已提交
2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083
	}

	interface CrashReport {
		id: string;
		date: Date;
	}

	// https://github.com/electron/electron/blob/master/docs/api/desktop-capturer.md

	/**
	 * The desktopCapturer module can be used to get available sources
	 * that can be used to be captured with getUserMedia.
	 */
	interface DesktopCapturer {
		/**
		 * Starts a request to get all desktop sources.
		 *
		 * Note: There is no guarantee that the size of source.thumbnail is always
		 * the same as the thumnbailSize in options. It also depends on the scale of the screen or window.
		 */
		getSources(options: DesktopCapturerOptions, callback: (error: Error, sources: DesktopCapturerSource[]) => any): void;
	}

	interface DesktopCapturerOptions {
		/**
		 * The types of desktop sources to be captured.
		 */
		types?: ('screen' | 'window')[];
		/**
		 * The suggested size that thumbnail should be scaled.
		 * Default: {width: 150, height: 150}
		 */
B
Benjamin Pasero 已提交
2084
		thumbnailSize?: Size;
B
Benjamin Pasero 已提交
2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185
	}

	interface DesktopCapturerSource {
		/**
		 * The id of the captured window or screen used in navigator.webkitGetUserMedia.
		 * The format looks like window:XX or screen:XX where XX is a random generated number.
		 */
		id: string;
		/**
		 * The described name of the capturing screen or window.
		 * If the source is a screen, the name will be Entire Screen or Screen <index>;
		 * if it is a window, the name will be the window’s title.
		 */
		name: string;
		/**
		 * A thumbnail image.
		 */
		thumbnail: NativeImage;
	}

	// https://github.com/electron/electron/blob/master/docs/api/dialog.md

	/**
	 * The dialog module provides APIs to show native system dialogs, such as opening files or alerting,
	 * so web applications can deliver the same user experience as native applications.
	 */
	interface Dialog {
		/**
		 * Note: On Windows and Linux an open dialog can not be both a file selector and a directory selector,
		 * so if you set properties to ['openFile', 'openDirectory'] on these platforms, a directory selector will be shown.
		 *
		 * @param callback If supplied, the API call will be asynchronous.
		 * @returns On success, returns an array of file paths chosen by the user,
		 * otherwise returns undefined.
		 */
		showOpenDialog(browserWindow: BrowserWindow, options: OpenDialogOptions, callback?: (fileNames: string[]) => void): string[];
		/**
		 * Note: On Windows and Linux an open dialog can not be both a file selector and a directory selector,
		 * so if you set properties to ['openFile', 'openDirectory'] on these platforms, a directory selector will be shown.
		 *
		 * @param callback If supplied, the API call will be asynchronous.
		 * @returns On success, returns an array of file paths chosen by the user,
		 * otherwise returns undefined.
		 */
		showOpenDialog(options: OpenDialogOptions, callback?: (fileNames: string[]) => void): string[];
		/**
		 * @param callback If supplied, the API call will be asynchronous.
		 * @returns On success, returns the path of file chosen by the user, otherwise
		 * returns undefined.
		 */
		showSaveDialog(browserWindow: BrowserWindow, options: SaveDialogOptions, callback?: (fileName: string) => void): string;
		/**
		 * @param callback If supplied, the API call will be asynchronous.
		 * @returns On success, returns the path of file chosen by the user, otherwise
		 * returns undefined.
		 */
		showSaveDialog(options: SaveDialogOptions, callback?: (fileName: string) => void): string;
		/**
		 * Shows a message box. It will block until the message box is closed.
		 * @param callback If supplied, the API call will be asynchronous.
		 * @returns The index of the clicked button.
		 */
		showMessageBox(browserWindow: BrowserWindow, options: ShowMessageBoxOptions, callback?: (response: number) => void): number;
		/**
		 * Shows a message box. It will block until the message box is closed.
		 * @param callback If supplied, the API call will be asynchronous.
		 * @returns The index of the clicked button.
		 */
		showMessageBox(options: ShowMessageBoxOptions, callback?: (response: number) => void): number;
		/**
		 * Displays a modal dialog that shows an error message.
		 *
		 * This API can be called safely before the ready event the app module emits,
		 * it is usually used to report errors in early stage of startup.
		 * If called before the app readyevent on Linux, the message will be emitted to stderr,
		 * and no GUI dialog will appear.
		 */
		showErrorBox(title: string, content: string): void;
	}

	interface OpenDialogOptions {
		title?: string;
		defaultPath?: string;
		/**
		 * Custom label for the confirmation button, when left empty the default label will be used.
		 */
		buttonLabel?: string;
		/**
		 * File types that can be displayed or selected.
		 */
		filters?: {
			name: string;
			/**
			 * Extensions without wildcards or dots (e.g. 'png' is good but '.png' and '*.png' are bad).
			 * To show all files, use the '*' wildcard (no other wildcard is supported).
			 */
			extensions: string[];
		}[];
		/**
		 * Contains which features the dialog should use.
		 */
B
Benjamin Pasero 已提交
2186
		properties?: ('openFile' | 'openDirectory' | 'multiSelections' | 'createDirectory' | 'showHiddenFiles')[];
B
Benjamin Pasero 已提交
2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269
	}

	interface SaveDialogOptions {
		title?: string;
		defaultPath?: string;
		/**
		 * Custom label for the confirmation button, when left empty the default label will be used.
		 */
		buttonLabel?: string;
		/**
		 * File types that can be displayed, see dialog.showOpenDialog for an example.
		 */
		filters?: {
			name: string;
			extensions: string[];
		}[];
	}

	interface ShowMessageBoxOptions {
		/**
		 * On Windows, "question" displays the same icon as "info", unless you set an icon using the "icon" option.
		 */
		type?: 'none' | 'info' | 'error' | 'question' | 'warning';
		/**
		 * Texts for buttons. On Windows, an empty array will result in one button labeled "OK".
		 */
		buttons?: string[];
		/**
		 * Index of the button in the buttons array which will be selected by default when the message box opens.
		 */
		defaultId?: number;
		/**
		 * Title of the message box (some platforms will not show it).
		 */
		title?: string;
		/**
		 * Contents of the message box.
		 */
		message?: string;
		/**
		 * Extra information of the message.
		 */
		detail?: string;
		icon?: NativeImage;
		/**
		 * The value will be returned when user cancels the dialog instead of clicking the buttons of the dialog.
		 * By default it is the index of the buttons that have "cancel" or "no" as label,
		 * or 0 if there is no such buttons. On macOS and Windows the index of "Cancel" button
		 * will always be used as cancelId, not matter whether it is already specified.
		 */
		cancelId?: number;
		/**
		 * On Windows Electron will try to figure out which one of the buttons are common buttons
		 * (like "Cancel" or "Yes"), and show the others as command links in the dialog.
		 * This can make the dialog appear in the style of modern Windows apps.
		 * If you don’t like this behavior, you can set noLink to true.
		 */
		noLink?: boolean;
	}

	// https://github.com/electron/electron/blob/master/docs/api/download-item.md

	/**
	 * DownloadItem represents a download item in Electron.
	 */
	interface DownloadItem extends NodeJS.EventEmitter {
		/**
		 * Emitted when the download has been updated and is not done.
		 */
		on(event: 'updated', listener: (event: Event, state: 'progressing' | 'interrupted') => void): this;
		/**
		 * Emits when the download is in a terminal state. This includes a completed download,
		 * a cancelled download (via downloadItem.cancel()), and interrupted download that can’t be resumed.
		 */
		on(event: 'done', listener: (event: Event, state: 'completed' | 'cancelled' | 'interrupted') => void): this;
		on(event: string, listener: Function): this;
		/**
		 * Set the save file path of the download item.
		 * Note: The API is only available in session’s will-download callback function.
		 * If user doesn’t set the save path via the API, Electron will use the original
		 * routine to determine the save path (Usually prompts a save dialog).
		 */
		setSavePath(path: string): void;
B
Benjamin Pasero 已提交
2270 2271 2272 2273 2274
		/**
		 * @returns The save path of the download item.
		 * This will be either the path set via downloadItem.setSavePath(path) or the path selected from the shown save dialog.
		 */
		getSavePath(): string;
B
Benjamin Pasero 已提交
2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449
		/**
		 * Pauses the download.
		 */
		pause(): void;
		/**
		 * @returns Whether the download is paused.
		 */
		isPaused(): boolean;
		/**
		 * Resumes the download that has been paused.
		 */
		resume(): void;
		/**
		 * @returns Whether the download can resume.
		 */
		canResume(): boolean;
		/**
		 * Cancels the download operation.
		 */
		cancel(): void;
		/**
		 * @returns The origin url where the item is downloaded from.
		 */
		getURL(): string;
		/**
		 * @returns The mime type.
		 */
		getMimeType(): string;
		/**
		 * @returns Whether the download has user gesture.
		 */
		hasUserGesture(): boolean;
		/**
		 * @returns The file name of the download item.
		 * Note: The file name is not always the same as the actual one saved in local disk.
		 * If user changes the file name in a prompted download saving dialog,
		 * the actual name of saved file will be different.
		 */
		getFilename(): string;
		/**
		 * @returns The total size in bytes of the download item. If the size is unknown, it returns 0.
		 */
		getTotalBytes(): number;
		/**
		 * @returns The received bytes of the download item.
		 */
		getReceivedBytes(): number;
		/**
		 * @returns The Content-Disposition field from the response header.
		 */
		getContentDisposition(): string;
		/**
		 * @returns The current state.
		 */
		getState(): 'progressing' | 'completed' | 'cancelled' | 'interrupted';
	}

	// https://github.com/electron/electron/blob/master/docs/api/global-shortcut.md

	/**
	 * The globalShortcut module can register/unregister a global keyboard shortcut
	 * with the operating system so that you can customize the operations for various shortcuts.
	 * Note: The shortcut is global; it will work even if the app does not have the keyboard focus.
	 * You should not use this module until the ready event of the app module is emitted.
	 */
	interface GlobalShortcut {
		/**
		 * Registers a global shortcut of accelerator.
		 * @param accelerator Represents a keyboard shortcut. It can contain modifiers
		 * and key codes, combined by the "+" character.
		 * @param callback Called when the registered shortcut is pressed by the user.
		 */
		register(accelerator: string, callback: Function): void;
		/**
		 * @param accelerator Represents a keyboard shortcut. It can contain modifiers
		 * and key codes, combined by the "+" character.
		 * @returns Whether the accelerator is registered.
		 */
		isRegistered(accelerator: string): boolean;
		/**
		 * Unregisters the global shortcut of keycode.
		 * @param accelerator Represents a keyboard shortcut. It can contain modifiers
		 * and key codes, combined by the "+" character.
		 */
		unregister(accelerator: string): void;
		/**
		 * Unregisters all the global shortcuts.
		 */
		unregisterAll(): void;
	}

	// https://github.com/electron/electron/blob/master/docs/api/ipc-main.md

	/**
	 * The ipcMain module handles asynchronous and synchronous messages
	 * sent from a renderer process (web page).
	 * Messages sent from a renderer will be emitted to this module.
	 */
	interface IpcMain extends NodeJS.EventEmitter {
		addListener(channel: string, listener: IpcMainEventListener): this;
		on(channel: string, listener: IpcMainEventListener): this;
		once(channel: string, listener: IpcMainEventListener): this;
		removeListener(channel: string, listener: IpcMainEventListener): this;
		removeAllListeners(channel?: string): this;
	}

	type IpcMainEventListener = (event: IpcMainEvent, ...args: any[]) => void;

	interface IpcMainEvent {
		/**
		 * Set this to the value to be returned in a synchronous message.
		 */
		returnValue?: any;
		/**
		 * Returns the webContents that sent the message, you can call sender.send
		 * to reply to the asynchronous message.
		 */
		sender: WebContents;
	}

	// https://github.com/electron/electron/blob/master/docs/api/ipc-renderer.md

	/**
	 * The ipcRenderer module provides a few methods so you can send synchronous
	 * and asynchronous messages from the render process (web page) to the main process.
	 * You can also receive replies from the main process.
	 */
	interface IpcRenderer extends NodeJS.EventEmitter {
		addListener(channel: string, listener: IpcRendererEventListener): this;
		on(channel: string, listener: IpcRendererEventListener): this;
		once(channel: string, listener: IpcRendererEventListener): this;
		removeListener(channel: string, listener: IpcRendererEventListener): this;
		removeAllListeners(channel?: string): this;
		/**
		 * Send ...args to the renderer via channel in asynchronous message, the main
		 * process can handle it by listening to the channel event of ipc module.
		 */
		send(channel: string, ...args: any[]): void;
		/**
		 * Send ...args to the renderer via channel in synchronous message, and returns
		 * the result sent from main process. The main process can handle it by listening
		 * to the channel event of ipc module, and returns by setting event.returnValue.
		 * Note: Usually developers should never use this API, since sending synchronous
		 * message would block the whole renderer process.
		 * @returns The result sent from the main process.
		 */
		sendSync(channel: string, ...args: any[]): any;
		/**
		 * Like ipc.send but the message will be sent to the host page instead of the main process.
		 * This is mainly used by the page in <webview> to communicate with host page.
		 */
		sendToHost(channel: string, ...args: any[]): void;
	}

	type IpcRendererEventListener = (event: IpcRendererEvent, ...args: any[]) => void;

	interface IpcRendererEvent {
		/**
		 * You can call sender.send to reply to the asynchronous message.
		 */
		sender: IpcRenderer;
	}

	// https://github.com/electron/electron/blob/master/docs/api/menu-item.md
	// https://github.com/electron/electron/blob/master/docs/api/accelerator.md

	/**
	 * The MenuItem allows you to add items to an application or context menu.
	 */
	class MenuItem {
		/**
		 * Create a new menu item.
		 */
		constructor(options: MenuItemOptions);

J
Joao Moreno 已提交
2450
		click: (menuItem: MenuItem, browserWindow: BrowserWindow, event: Event & Modifiers) => void;
B
Benjamin Pasero 已提交
2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479
		/**
		 * Read-only property.
		 */
		type: MenuItemType;
		/**
		 * Read-only property.
		 */
		role: MenuItemRole | MenuItemRoleMac;
		/**
		 * Read-only property.
		 */
		accelerator: string;
		/**
		 * Read-only property.
		 */
		icon: NativeImage | string;
		/**
		 * Read-only property.
		 */
		submenu: Menu | MenuItemOptions[];

		label: string;
		sublabel: string;
		enabled: boolean;
		visible: boolean;
		checked: boolean;
	}

	type MenuItemType = 'normal' | 'separator' | 'submenu' | 'checkbox' | 'radio';
B
Benjamin Pasero 已提交
2480 2481
	type MenuItemRole = 'undo' | 'redo' | 'cut' | 'copy' | 'paste' | 'pasteandmatchstyle' | 'selectall' | 'delete' | 'minimize' | 'close' | 'quit' | 'togglefullscreen' | 'resetzoom' | 'zoomin' | 'zoomout';
	type MenuItemRoleMac = 'about' | 'hide' | 'hideothers' | 'unhide' | 'startspeaking' | 'stopspeaking' | 'front' | 'zoom' | 'window' | 'help' | 'services';
B
Benjamin Pasero 已提交
2482 2483 2484 2485 2486

	interface MenuItemOptions {
		/**
		 * Callback when the menu item is clicked.
		 */
J
Joao Moreno 已提交
2487
		click?: (menuItem: MenuItem, browserWindow: BrowserWindow, event: Event & Modifiers) => void;
B
Benjamin Pasero 已提交
2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546
		/**
		 * Can be normal, separator, submenu, checkbox or radio.
		 */
		type?: MenuItemType;
		label?: string;
		sublabel?: string;
		/**
		 * An accelerator is string that represents a keyboard shortcut, it can contain
		 * multiple modifiers and key codes, combined by the + character.
		 *
		 * Examples:
		 *   CommandOrControl+A
		 *   CommandOrControl+Shift+Z
		 *
		 * Platform notice:
		 *   On Linux and Windows, the Command key would not have any effect,
		 *   you can use CommandOrControl which represents Command on macOS and Control on
		 *   Linux and Windows to define some accelerators.
		 *
		 *   Use Alt instead of Option. The Option key only exists on macOS, whereas
		 *   the Alt key is available on all platforms.
		 *
		 *   The Super key is mapped to the Windows key on Windows and Linux and Cmd on macOS.
		 *
		 * Available modifiers:
		 *   Command (or Cmd for short)
		 *   Control (or Ctrl for short)
		 *   CommandOrControl (or CmdOrCtrl for short)
		 *   Alt
		 *   Option
		 *   AltGr
		 *   Shift
		 *   Super
		 *
		 * Available key codes:
		 *   0 to 9
		 *   A to Z
		 *   F1 to F24
		 *   Punctuations like ~, !, @, #, $, etc.
		 *   Plus
		 *   Space
		 *   Tab
		 *   Backspace
		 *   Delete
		 *   Insert
		 *   Return (or Enter as alias)
		 *   Up, Down, Left and Right
		 *   Home and End
		 *   PageUp and PageDown
		 *   Escape (or Esc for short)
		 *   VolumeUp, VolumeDown and VolumeMute
		 *   MediaNextTrack, MediaPreviousTrack, MediaStop and MediaPlayPause
		 *   PrintScreen
		 */
		accelerator?: string;
		/**
		 * In Electron for the APIs that take images, you can pass either file paths
		 * or NativeImage instances. When passing null, an empty image will be used.
		 */
J
Joao Moreno 已提交
2547
		icon?: NativeImage | string;
B
Benjamin Pasero 已提交
2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563
		/**
		 * If false, the menu item will be greyed out and unclickable.
		 */
		enabled?: boolean;
		/**
		 * If false, the menu item will be entirely hidden.
		 */
		visible?: boolean;
		/**
		 * Should only be specified for 'checkbox' or 'radio' type menu items.
		 */
		checked?: boolean;
		/**
		 * Should be specified for submenu type menu item, when it's specified the
		 * type: 'submenu' can be omitted for the menu item
		 */
J
Joao Moreno 已提交
2564
		submenu?: Menu | MenuItemOptions[];
B
Benjamin Pasero 已提交
2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589
		/**
		 * Unique within a single menu. If defined then it can be used as a reference
		 * to this item by the position attribute.
		 */
		id?: string;
		/**
		 * This field allows fine-grained definition of the specific location within
		 * a given menu.
		 */
		position?: string;
		/**
		 * Define the action of the menu item, when specified the click property will be ignored
		 */
		role?: MenuItemRole | MenuItemRoleMac;
	}

	// https://github.com/electron/electron/blob/master/docs/api/menu.md

	/**
	 * The Menu class is used to create native menus that can be used as application
	 * menus and context menus. This module is a main process module which can be used
	 * in a render process via the remote module.
	 *
	 * Each menu consists of multiple menu items, and each menu item can have a submenu.
	 */
J
Joao Moreno 已提交
2590
	class Menu extends NodeJS.EventEmitter {
B
Benjamin Pasero 已提交
2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624
		/**
		 * Creates a new menu.
		 */
		constructor();
		/**
		 * Sets menu as the application menu on macOS. On Windows and Linux, the menu
		 * will be set as each window's top menu.
		 */
		static setApplicationMenu(menu: Menu): void;
		/**
		 * @returns The application menu if set, or null if not set.
		 */
		static getApplicationMenu(): Menu;
		/**
		 * Sends the action to the first responder of application.
		 * This is used for emulating default Cocoa menu behaviors,
		 * usually you would just use the role property of MenuItem.
		 *
		 * Note: This method is macOS only.
		 */
		static sendActionToFirstResponder(action: string): void;
		/**
		 * @param template Generally, just an array of options for constructing MenuItem.
		 * You can also attach other fields to element of the template, and they will
		 * become properties of the constructed menu items.
		 */
		static buildFromTemplate(template: MenuItemOptions[]): Menu;
		/**
		 * Pops up this menu as a context menu in the browserWindow. You can optionally
		 * provide a (x,y) coordinate to place the menu at, otherwise it will be placed
		 * at the current mouse cursor position.
		 * @param x Horizontal coordinate where the menu will be placed.
		 * @param y Vertical coordinate where the menu will be placed.
		 */
B
Benjamin Pasero 已提交
2625
		popup(browserWindow?: BrowserWindow, x?: number, y?: number): void;
B
Benjamin Pasero 已提交
2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651
		/**
		 * Appends the menuItem to the menu.
		 */
		append(menuItem: MenuItem): void;
		/**
		 * Inserts the menuItem to the pos position of the menu.
		 */
		insert(position: number, menuItem: MenuItem): void;
		/**
		 * @returns an array containing the menu’s items.
		 */
		items: MenuItem[];
	}

	// https://github.com/electron/electron/blob/master/docs/api/native-image.md

	/**
	 * This class is used to represent an image.
	 */
	class NativeImage {
		/**
		 * Creates an empty NativeImage instance.
		 */
		static createEmpty(): NativeImage;
		/**
		 * Creates a new NativeImage instance from file located at path.
2652
		 * This method returns an empty image if the path does not exist, cannot be read, or is not a valid image.
B
Benjamin Pasero 已提交
2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664
		 */
		static createFromPath(path: string): NativeImage;
		/**
		 * Creates a new NativeImage instance from buffer.
		 * @param scaleFactor 1.0 by default.
		 */
		static createFromBuffer(buffer: Buffer, scaleFactor?: number): NativeImage;
		/**
		 * Creates a new NativeImage instance from dataURL
		 */
		static createFromDataURL(dataURL: string): NativeImage;
		/**
B
Benjamin Pasero 已提交
2665
		 * @returns Buffer that contains the image's PNG encoded data.
B
Benjamin Pasero 已提交
2666 2667 2668
		 */
		toPNG(): Buffer;
		/**
B
Benjamin Pasero 已提交
2669
		 * @returns Buffer that contains the image's JPEG encoded data.
B
Benjamin Pasero 已提交
2670 2671
		 */
		toJPEG(quality: number): Buffer;
B
Benjamin Pasero 已提交
2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683
		/**
		 * @returns Buffer that contains a copy of the image's raw bitmap pixel data.
		 */
		toBitmap(): Buffer;
		/**
		 * @returns Buffer that contains the image's raw bitmap pixel data.
		 *
		 * The difference between getBitmap() and toBitmap() is, getBitmap() does not copy the bitmap data,
		 * so you have to use the returned Buffer immediately in current event loop tick,
		 * otherwise the data might be changed or destroyed.
		 */
		getBitmap(): Buffer;
B
Benjamin Pasero 已提交
2684
		/**
2685
		 * @returns The data URL of the image.
B
Benjamin Pasero 已提交
2686 2687 2688 2689 2690 2691 2692 2693 2694
		 */
		toDataURL(): string;
		/**
		 * The native type of the handle is NSImage* on macOS.
		 * Note: This is only implemented on macOS.
		 * @returns The platform-specific handle of the image as Buffer.
		 */
		getNativeHandle(): Buffer;
		/**
2695
		 * @returns Whether the image is empty.
B
Benjamin Pasero 已提交
2696 2697 2698
		 */
		isEmpty(): boolean;
		/**
2699
		 * @returns The size of the image.
B
Benjamin Pasero 已提交
2700
		 */
B
Benjamin Pasero 已提交
2701
		getSize(): Size;
B
Benjamin Pasero 已提交
2702 2703 2704 2705 2706 2707 2708 2709
		/**
		 * Marks the image as template image.
		 */
		setTemplateImage(option: boolean): void;
		/**
		 * Returns a boolean whether the image is a template image.
		 */
		isTemplateImage(): boolean;
J
Joao Moreno 已提交
2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736
	}

	// https://github.com/electron/electron/blob/master/docs/api/net.md

	/**
	 * The net module is a client-side API for issuing HTTP(S) requests.
	 * It is similar to the HTTP and HTTPS modules of Node.js but uses Chromium’s native
	 * networking library instead of the Node.js implementation, offering better support
	 * for web proxies.
	 * The following is a non-exhaustive list of why you may consider using the net module
	 * instead of the native Node.js modules:
	 * - Automatic management of system proxy configuration, support of the wpad protocol
	 * and proxy pac configuration files.
	 * - Automatic tunneling of HTTPS requests.
	 * - Support for authenticating proxies using basic, digest, NTLM, Kerberos or negotiate
	 * authentication schemes.
	 * - Support for traffic monitoring proxies: Fiddler-like proxies used for access control
	 * and monitoring.
	 *
	 * The net module API has been specifically designed to mimic, as closely as possible,
	 * the familiar Node.js API. The API components including classes, methods,
	 * properties and event names are similar to those commonly used in Node.js.
	 *
	 * The net API can be used only after the application emits the ready event.
	 * Trying to use the module before the ready event will throw an error.
	 */
	interface Net extends NodeJS.EventEmitter {
2737
		/**
J
Joao Moreno 已提交
2738 2739 2740 2741 2742
		 * @param options The ClientRequest constructor options.
		 * @param callback A one time listener for the response event.
		 *
		 * @returns a ClientRequest instance using the provided options which are directly
		 * forwarded to the ClientRequest constructor.
2743
		 */
J
Joao Moreno 已提交
2744 2745 2746 2747 2748 2749 2750
		request(options: string | RequestOptions, callback?: (response: IncomingMessage) => void): ClientRequest;
	}

	/**
	 * The RequestOptions interface allows to define various options for an HTTP request.
	 */
	interface RequestOptions {
2751
		/**
J
Joao Moreno 已提交
2752
		 * The HTTP request method. Defaults to the GET method.
2753
		 */
J
Joao Moreno 已提交
2754
		method?: string;
2755
		/**
J
Joao Moreno 已提交
2756 2757
		 * The request URL. Must be provided in the absolute form with the protocol
		 * scheme specified as http or https.
2758
		 */
J
Joao Moreno 已提交
2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950
		url?: string;
		/**
		 * The Session instance with which the request is associated.
		 */
		session?: Session;
		/**
		 * The name of the partition with which the request is associated.
		 * Defaults to the empty string. The session option prevails on partition.
		 * Thus if a session is explicitly specified, partition is ignored.
		 */
		partition?: string;
		/**
		 * The protocol scheme in the form ‘scheme:’. Currently supported values are ‘http:’ or ‘https:’.
		 * Defaults to ‘http:’.
		 */
		Protocol?: 'http:' | 'https:';
		/**
		 * The server host provided as a concatenation of the hostname and the port number ‘hostname:port’.
		 */
		host?: string;
		/**
		 * The server host name.
		 */
		hostname?: string;
		/**
		 * The server’s listening port number.
		 */
		port?: number;
		/**
		 * The path part of the request URL.
		 */
		path?: string;
		/**
		 * A map specifying extra HTTP header name/value.
		 */
		headers?: { [key: string]: any };
	}

	/**
	 * The ClientRequest class represents an HTTP request.
	 */
	class ClientRequest extends NodeJS.EventEmitter {
		/**
		 * Emitted when an HTTP response is received for the request.
		 */
		on(event: 'response', listener: (response: IncomingMessage) => void): this;
		/**
		 * Emitted when an authenticating proxy is asking for user credentials.
		 * The callback function is expected to be called back with user credentials.
		 * Providing empty credentials will cancel the request and report an authentication
		 * error on the response object.
		 */
		on(event: 'login', listener: (authInfo: LoginAuthInfo, callback: (username?: string, password?: string) => void) => void): this;
		/**
		 * Emitted just after the last chunk of the request’s data has been written into
		 * the request object.
		 */
		on(event: 'finish', listener: () => void): this;
		/**
		 * Emitted when the request is aborted. The abort event will not be fired if the
		 * request is already closed.
		 */
		on(event: 'abort', listener: () => void): this;
		/**
		 * Emitted when the net module fails to issue a network request.
		 * Typically when the request object emits an error event, a close event will
		 * subsequently follow and no response object will be provided.
		 */
		on(event: 'error', listener: (error: Error) => void): this;
		/**
		 * Emitted as the last event in the HTTP request-response transaction.
		 * The close event indicates that no more events will be emitted on either the
		 * request or response objects.
		 */
		on(event: 'close', listener: () => void): this;
		on(event: string, listener: Function): this;
		/**
		 * A Boolean specifying whether the request will use HTTP chunked transfer encoding or not.
		 * Defaults to false. The property is readable and writable, however it can be set only before
		 * the first write operation as the HTTP headers are not yet put on the wire.
		 * Trying to set the chunkedEncoding property after the first write will throw an error.
		 *
		 * Using chunked encoding is strongly recommended if you need to send a large request
		 * body as data will be streamed in small chunks instead of being internally buffered
		 * inside Electron process memory.
		 */
		chunkedEncoding: boolean;
		/**
		 * @param options If options is a String, it is interpreted as the request URL.
		 * If it is an object, it is expected to be a RequestOptions.
		 * @param callback A one time listener for the response event.
		 */
		constructor(options: string | RequestOptions, callback?: (response: IncomingMessage) => void);
		/**
		 * Adds an extra HTTP header. The header name will issued as it is without lowercasing.
		 * It can be called only before first write. Calling this method after the first write
		 * will throw an error.
		 * @param name An extra HTTP header name.
		 * @param value An extra HTTP header value.
		 */
		setHeader(name: string, value: string): void;
		/**
		 * @param name Specify an extra header name.
		 * @returns The value of a previously set extra header name.
		 */
		getHeader(name: string): string;
		/**
		 * Removes a previously set extra header name. This method can be called only before first write.
		 * Trying to call it after the first write will throw an error.
		 * @param name Specify an extra header name.
		 */
		removeHeader(name: string): void;
		/**
		 * Adds a chunk of data to the request body. The first write operation may cause the
		 * request headers to be issued on the wire.
		 * After the first write operation, it is not allowed to add or remove a custom header.
		 * @param chunk A chunk of the request body’s data. If it is a string, it is converted
		 * into a Buffer using the specified encoding.
		 * @param encoding Used to convert string chunks into Buffer objects. Defaults to ‘utf-8’.
		 * @param callback Called after the write operation ends.
		 */
		write(chunk: string | Buffer, encoding?: string, callback?: Function): boolean;
		/**
		 * Sends the last chunk of the request data. Subsequent write or end operations will not be allowed.
		 * The finish event is emitted just after the end operation.
		 * @param chunk A chunk of the request body’s data. If it is a string, it is converted into
		 * a Buffer using the specified encoding.
		 * @param encoding Used to convert string chunks into Buffer objects. Defaults to ‘utf-8’.
		 * @param callback Called after the write operation ends.
		 *
		 */
		end(chunk?: string | Buffer, encoding?: string, callback?: Function): boolean;
		/**
		 * Cancels an ongoing HTTP transaction. If the request has already emitted the close event,
		 * the abort operation will have no effect.
		 * Otherwise an ongoing event will emit abort and close events.
		 * Additionally, if there is an ongoing response object,it will emit the aborted event.
		 */
		abort(): void
	}

	/**
	 * An IncomingMessage represents an HTTP response.
	 */
	interface IncomingMessage extends NodeJS.ReadableStream {
		/**
		 * The data event is the usual method of transferring response data into applicative code.
		 */
		on(event: 'data', listener: (chunk: Buffer) => void): this;
		/**
		 * Indicates that response body has ended.
		 */
		on(event: 'end', listener: () => void): this;
		/**
		 * Emitted when a request has been canceled during an ongoing HTTP transaction.
		 */
		on(event: 'aborted', listener: () => void): this;
		/**
		 * Emitted when an error was encountered while streaming response data events.
		 * For instance, if the server closes the underlying while the response is still
		 * streaming, an error event will be emitted on the response object and a close
		 * event will subsequently follow on the request object.
		 */
		on(event: 'error', listener: (error: Error) => void): this;
		on(event: string, listener: Function): this;
		/**
		 * An Integer indicating the HTTP response status code.
		 */
		statusCode: number;
		/**
		 * A String representing the HTTP status message.
		 */
		statusMessage: string;
		/**
		 * An object representing the response HTTP headers. The headers object is formatted as follows:
		 * - All header names are lowercased.
		 * - Each header name produces an array-valued property on the headers object.
		 * - Each header value is pushed into the array associated with its header name.
		 */
		headers: Headers;
		/**
		 * A string indicating the HTTP protocol version number. Typical values are ‘1.0’ or ‘1.1’.
		 */
		httpVersion: string;
		/**
		 * An integer-valued read-only property that returns the HTTP major version number.
		 */
		httpVersionMajor: number;
		/**
		 * An integer-valued read-only property that returns the HTTP minor version number.
		 */
		httpVersionMinor: number;
B
Benjamin Pasero 已提交
2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987
	}

	// https://github.com/electron/electron/blob/master/docs/api/power-monitor.md

	/**
	 * The power-monitor module is used to monitor power state changes.
	 * You should not use this module until the ready event of the app module is emitted.
	 */
	interface PowerMonitor extends NodeJS.EventEmitter {
		/**
		 * Emitted when the system is suspending.
		 */
		on(event: 'suspend', listener: Function): this;
		/**
		 * Emitted when system is resuming.
		 */
		on(event: 'resume', listener: Function): this;
		/**
		 * Emitted when the system changes to AC power.
		 */
		on(event: 'on-ac', listener: Function): this;
		/**
		 * Emitted when system changes to battery power.
		 */
		on(event: 'on-battery', listener: Function): this;
		on(event: string, listener: Function): this;
	}

	// https://github.com/electron/electron/blob/master/docs/api/power-save-blocker.md

	/**
	 * The powerSaveBlocker module is used to block the system from entering
	 * low-power (sleep) mode and thus allowing the app to keep the system and screen active.
	 */
	interface PowerSaveBlocker {
		/**
		 * Starts preventing the system from entering lower-power mode.
2988
		 * @returns The blocker ID that is assigned to this power blocker.
B
Benjamin Pasero 已提交
2989 2990 2991 2992 2993 2994 2995 2996 2997 2998
		 * Note: prevent-display-sleep has higher has precedence over prevent-app-suspension.
		 */
		start(type: 'prevent-app-suspension' | 'prevent-display-sleep'): number;
		/**
		 * @param id The power save blocker id returned by powerSaveBlocker.start.
		 * Stops the specified power save blocker.
		 */
		stop(id: number): void;
		/**
		 * @param id The power save blocker id returned by powerSaveBlocker.start.
2999
		 * @returns Whether the corresponding powerSaveBlocker has started.
B
Benjamin Pasero 已提交
3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073
		 */
		isStarted(id: number): boolean;
	}

	// https://github.com/electron/electron/blob/master/docs/api/protocol.md

	/**
	 * The protocol module can register a custom protocol or intercept an existing protocol.
	 */
	interface Protocol {
		/**
		 * Registers custom schemes as standard schemes.
		 */
		registerStandardSchemes(schemes: string[]): void;
		/**
		 * Registers custom schemes to handle service workers.
		 */
		registerServiceWorkerSchemes(schemes: string[]): void;
		/**
		 * Registers a protocol of scheme that will send the file as a response.
		 */
		registerFileProtocol(scheme: string, handler: FileProtocolHandler, completion?: (error: Error) => void): void;
		/**
		 * Registers a protocol of scheme that will send a Buffer as a response.
		 */
		registerBufferProtocol(scheme: string, handler: BufferProtocolHandler, completion?: (error: Error) => void): void;
		/**
		 * Registers a protocol of scheme that will send a String as a response.
		 */
		registerStringProtocol(scheme: string, handler: StringProtocolHandler, completion?: (error: Error) => void): void;
		/**
		 * Registers a protocol of scheme that will send an HTTP request as a response.
		 */
		registerHttpProtocol(scheme: string, handler: HttpProtocolHandler, completion?: (error: Error) => void): void;
		/**
		 * Unregisters the custom protocol of scheme.
		 */
		unregisterProtocol(scheme: string, completion?: (error: Error) => void): void;
		/**
		 * The callback will be called with a boolean that indicates whether there is already a handler for scheme.
		 */
		isProtocolHandled(scheme: string, callback: (handled: boolean) => void): void;
		/**
		 * Intercepts scheme protocol and uses handler as the protocol’s new handler which sends a file as a response.
		 */
		interceptFileProtocol(scheme: string, handler: FileProtocolHandler, completion?: (error: Error) => void): void;
		/**
		 * Intercepts scheme protocol and uses handler as the protocol’s new handler which sends a Buffer as a response.
		 */
		interceptBufferProtocol(scheme: string, handler: BufferProtocolHandler, completion?: (error: Error) => void): void;
		/**
		 * Intercepts scheme protocol and uses handler as the protocol’s new handler which sends a String as a response.
		 */
		interceptStringProtocol(scheme: string, handler: StringProtocolHandler, completion?: (error: Error) => void): void;
		/**
		 * Intercepts scheme protocol and uses handler as the protocol’s new handler which sends a new HTTP request as a response.
		 */
		interceptHttpProtocol(scheme: string, handler: HttpProtocolHandler, completion?: (error: Error) => void): void;
		/**
		 * Remove the interceptor installed for scheme and restore its original handler.
		 */
		uninterceptProtocol(scheme: string, completion?: (error: Error) => void): void;
	}

	type FileProtocolHandler = (request: ProtocolRequest, callback: FileProtocolCallback) => void;
	type BufferProtocolHandler = (request: ProtocolRequest, callback: BufferProtocolCallback) => void;
	type StringProtocolHandler = (request: ProtocolRequest, callback: StringProtocolCallback) => void;
	type HttpProtocolHandler = (request: ProtocolRequest, callback: HttpProtocolCallback) => void;

	interface ProtocolRequest {
		url: string;
		referrer: string;
		method: string;
		uploadData?: {
3074 3075 3076
			/**
			 * Content being sent.
			 */
B
Benjamin Pasero 已提交
3077
			bytes: Buffer,
3078 3079 3080 3081 3082 3083 3084 3085
			/**
			 * Path of file being uploaded.
			 */
			file: string,
			/**
			 * UUID of blob data. Use session.getBlobData method to retrieve the data.
			 */
			blobUUID: string;
B
Benjamin Pasero 已提交
3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115
		}[];
	}

	interface ProtocolCallback {
		(error: number): void;
		(obj: {
			error: number
		}): void;
		(): void;
	}

	interface FileProtocolCallback extends ProtocolCallback {
		(filePath: string): void;
		(obj: {
			path: string
		}): void;
	}

	interface BufferProtocolCallback extends ProtocolCallback {
		(buffer: Buffer): void;
		(obj: {
			data: Buffer,
			mimeType: string,
			charset?: string
		}): void;
	}

	interface StringProtocolCallback extends ProtocolCallback {
		(str: string): void;
		(obj: {
J
Joao Moreno 已提交
3116
			data: string,
B
Benjamin Pasero 已提交
3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174
			mimeType: string,
			charset?: string
		}): void;
	}

	interface HttpProtocolCallback extends ProtocolCallback {
		(redirectRequest: {
			url: string;
			method: string;
			session?: Object;
			uploadData?: {
				contentType: string;
				data: string;
			};
		}): void;
	}

	// https://github.com/electron/electron/blob/master/docs/api/remote.md

	/**
	 * The remote module provides a simple way to do inter-process communication (IPC)
	 * between the renderer process (web page) and the main process.
	 */
	interface Remote extends CommonElectron {
		/**
		 * @returns The object returned by require(module) in the main process.
		 */
		require(module: string): any;
		/**
		 * @returns The BrowserWindow object which this web page belongs to.
		 */
		getCurrentWindow(): BrowserWindow;
		/**
		 * @returns The WebContents object of this web page.
		 */
		getCurrentWebContents(): WebContents;
		/**
		 * @returns The global variable of name (e.g. global[name]) in the main process.
		 */
		getGlobal(name: string): any;
		/**
		 * Returns the process object in the main process. This is the same as
		 * remote.getGlobal('process'), but gets cached.
		 */
		process: NodeJS.Process;
	}

	// https://github.com/electron/electron/blob/master/docs/api/screen.md

	/**
	 * The Display object represents a physical display connected to the system.
	 * A fake Display may exist on a headless system, or a Display may correspond to a remote, virtual display.
	 */
	interface Display {
		/**
		 * Unique identifier associated with the display.
		 */
		id: number;
B
Benjamin Pasero 已提交
3175 3176 3177 3178
		bounds: Rectangle;
		workArea: Rectangle;
		size: Size;
		workAreaSize: Size;
B
Benjamin Pasero 已提交
3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228
		/**
		 * Output device’s pixel scale factor.
		 */
		scaleFactor: number;
		/**
		 * Can be 0, 90, 180, 270, represents screen rotation in clock-wise degrees.
		 */
		rotation: number;
		touchSupport: 'available' | 'unavailable' | 'unknown';
	}

	type DisplayMetrics = 'bounds' | 'workArea' | 'scaleFactor' | 'rotation';

	/**
	 * The screen module retrieves information about screen size, displays, cursor position, etc.
	 * You can not use this module until the ready event of the app module is emitted.
	 */
	interface Screen extends NodeJS.EventEmitter {
		/**
		 * Emitted when newDisplay has been added.
		 */
		on(event: 'display-added', listener: (event: Event, newDisplay: Display) => void): this;
		/**
		 * Emitted when oldDisplay has been removed.
		 */
		on(event: 'display-removed', listener: (event: Event, oldDisplay: Display) => void): this;
		/**
		 * Emitted when one or more metrics change in a display.
		 */
		on(event: 'display-metrics-changed', listener: (event: Event, display: Display, changedMetrics: DisplayMetrics[]) => void): this;
		on(event: string, listener: Function): this;
		/**
		 * @returns The current absolute position of the mouse pointer.
		 */
		getCursorScreenPoint(): Point;
		/**
		 * @returns The primary display.
		 */
		getPrimaryDisplay(): Display;
		/**
		 * @returns An array of displays that are currently available.
		 */
		getAllDisplays(): Display[];
		/**
		 * @returns The display nearest the specified point.
		 */
		getDisplayNearestPoint(point: Point): Display;
		/**
		 * @returns The display that most closely intersects the provided bounds.
		 */
B
Benjamin Pasero 已提交
3229
		getDisplayMatching(rect: Rectangle): Display;
B
Benjamin Pasero 已提交
3230 3231 3232 3233 3234 3235 3236 3237 3238
	}

	// https://github.com/electron/electron/blob/master/docs/api/session.md

	/**
	 * The session module can be used to create new Session objects.
	 * You can also access the session of existing pages by using
	 * the session property of webContents which is a property of BrowserWindow.
	 */
J
Joao Moreno 已提交
3239
	class Session extends NodeJS.EventEmitter {
B
Benjamin Pasero 已提交
3240 3241 3242
		/**
		 * @returns a new Session instance from partition string.
		 */
B
Benjamin Pasero 已提交
3243
		static fromPartition(partition: string, options?: FromPartitionOptions): Session;
B
Benjamin Pasero 已提交
3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281
		/**
		 * @returns the default session object of the app.
		 */
		static defaultSession: Session;
		/**
		 * Emitted when Electron is about to download item in webContents.
		 * Calling event.preventDefault() will cancel the download
		 * and item will not be available from next tick of the process.
		 */
		on(event: 'will-download', listener: (event: Event, item: DownloadItem, webContents: WebContents) => void): this;
		on(event: string, listener: Function): this;
		/**
		 * The cookies gives you ability to query and modify cookies.
		 */
		cookies: SessionCookies;
		/**
		 * @returns the session’s current cache size.
		 */
		getCacheSize(callback: (size: number) => void): void;
		/**
		 * Clears the session’s HTTP cache.
		 */
		clearCache(callback: Function): void;
		/**
		 * Clears the data of web storages.
		 */
		clearStorageData(callback: Function): void;
		/**
		 * Clears the data of web storages.
		 */
		clearStorageData(options: ClearStorageDataOptions, callback: Function): void;
		/**
		 * Writes any unwritten DOMStorage data to disk.
		 */
		flushStorageData(): void;
		/**
		 * Sets the proxy settings.
		 */
B
Benjamin Pasero 已提交
3282
		setProxy(config: ProxyConfig, callback: Function): void;
B
Benjamin Pasero 已提交
3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330
		/**
		 * Resolves the proxy information for url.
		 */
		resolveProxy(url: URL, callback: (proxy: string) => void): void;
		/**
		 * Sets download saving directory.
		 * By default, the download directory will be the Downloads under the respective app folder.
		 */
		setDownloadPath(path: string): void;
		/**
		 * Emulates network with the given configuration for the session.
		 */
		enableNetworkEmulation(options: NetworkEmulationOptions): void;
		/**
		 * Disables any network emulation already active for the session.
		 * Resets to the original network configuration.
		 */
		disableNetworkEmulation(): void;
		/**
		 * Sets the certificate verify proc for session, the proc will be called
		 * whenever a server certificate verification is requested.
		 *
		 * Calling setCertificateVerifyProc(null) will revert back to default certificate verify proc.
		 */
		setCertificateVerifyProc(proc: (hostname: string, cert: Certificate, callback: (accepted: boolean) => void) => void): void;
		/**
		 * Sets the handler which can be used to respond to permission requests for the session.
		 */
		setPermissionRequestHandler(handler: (webContents: WebContents, permission: Permission, callback: (allow: boolean) => void) => void): void;
		/**
		 * Clears the host resolver cache.
		 */
		clearHostResolverCache(callback: Function): void;
		/**
		 * Dynamically sets whether to always send credentials for HTTP NTLM or Negotiate authentication.
		 * @param domains Comma-seperated list of servers for which integrated authentication is enabled.
		 */
		allowNTLMCredentialsForDomains(domains: string): void;
		/**
		 * Overrides the userAgent and acceptLanguages for this session.
		 * The acceptLanguages must a comma separated ordered list of language codes, for example "en-US,fr,de,ko,zh-CN,ja".
		 * This doesn't affect existing WebContents, and each WebContents can use webContents.setUserAgent to override the session-wide user agent.
		 */
		setUserAgent(userAgent: string, acceptLanguages?: string): void;
		/**
		 * @returns The user agent for this session.
		 */
		getUserAgent(): string;
3331 3332 3333 3334
		/**
		 * Returns the blob data associated with the identifier.
		 */
		getBlobData(identifier: string, callback: (result: Buffer) => void): void;
B
Benjamin Pasero 已提交
3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346
		/**
		 * The webRequest API set allows to intercept and modify contents of a request at various stages of its lifetime.
		 */
		webRequest: WebRequest;
		/**
		 * @returns An instance of protocol module for this session.
		 */
		protocol: Protocol;
	}

	type Permission = 'media' | 'geolocation' | 'notifications' | 'midiSysex' | 'pointerLock' | 'fullscreen' | 'openExternal';

B
Benjamin Pasero 已提交
3347 3348 3349 3350 3351 3352 3353
	interface FromPartitionOptions {
		/**
		 * Whether to enable cache.
		 */
		cache?: boolean;
	}

B
Benjamin Pasero 已提交
3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368
	interface ClearStorageDataOptions {
		/**
		 * Should follow window.location.origin’s representation scheme://host:port.
		 */
		origin?: string;
		/**
		 *  The types of storages to clear.
		 */
		storages?: ('appcache' | 'cookies' | 'filesystem' | 'indexdb' | 'localstorage' | 'shadercache' | 'websql' | 'serviceworkers')[];
		/**
		 * The types of quotas to clear.
		 */
		quotas?: ('temporary' | 'persistent' | 'syncable')[];
	}

B
Benjamin Pasero 已提交
3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383
	interface ProxyConfig {
		/**
		 * The URL associated with the PAC file.
		 */
		pacScript: string;
		/**
		 * Rules indicating which proxies to use.
		 */
		proxyRules: string;
		/**
		 * Rules indicating which URLs should bypass the proxy settings.
		 */
		proxyBypassRules: string;
	}

B
Benjamin Pasero 已提交
3384 3385 3386
	interface NetworkEmulationOptions {
		/**
		 * Whether to emulate network outage.
B
Benjamin Pasero 已提交
3387
		 * Default: false.
B
Benjamin Pasero 已提交
3388 3389 3390 3391
		 */
		offline?: boolean;
		/**
		 * RTT in ms.
B
Benjamin Pasero 已提交
3392
		 * Default: 0, which will disable latency throttling.
B
Benjamin Pasero 已提交
3393 3394 3395 3396
		 */
		latency?: number;
		/**
		 * Download rate in Bps.
B
Benjamin Pasero 已提交
3397
		 * Default: 0, which will disable download throttling.
B
Benjamin Pasero 已提交
3398 3399 3400 3401
		 */
		downloadThroughput?: number;
		/**
		 * Upload rate in Bps.
B
Benjamin Pasero 已提交
3402
		 * Default: 0, which will disable upload throttling.
B
Benjamin Pasero 已提交
3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434
		 */
		uploadThroughput?: number;
	}

	interface CookieFilter {
		/**
		 * Retrieves cookies which are associated with url. Empty implies retrieving cookies of all urls.
		 */
		url?: string;
		/**
		 * Filters cookies by name.
		 */
		name?: string;
		/**
		 * Retrieves cookies whose domains match or are subdomains of domains.
		 */
		domain?: string;
		/**
		 * Retrieves cookies whose path matches path.
		 */
		path?: string;
		/**
		 * Filters cookies by their Secure property.
		 */
		secure?: boolean;
		/**
		 * Filters out session or persistent cookies.
		 */
		session?: boolean;
	}

	interface Cookie {
3435 3436 3437 3438 3439
		/**
		 * 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;
B
Benjamin Pasero 已提交
3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478
		/**
		 * The name of the cookie.
		 */
		name: string;
		/**
		 * The value of the cookie.
		 */
		value: string;
		/**
		 * The domain of the cookie.
		 */
		domain: string;
		/**
		 * Whether the cookie is a host-only cookie.
		 */
		hostOnly: string;
		/**
		 * The path of the cookie.
		 */
		path: string;
		/**
		 * Whether the cookie is marked as secure.
		 */
		secure: boolean;
		/**
		 * Whether the cookie is marked as HTTP only.
		 */
		httpOnly: boolean;
		/**
		 * Whether the cookie is a session cookie or a persistent cookie with an expiration date.
		 */
		session: boolean;
		/**
		 * The expiration date of the cookie as the number of seconds since the UNIX epoch.
		 * Not provided for session cookies.
		 */
		expirationDate?: number;
	}

3479 3480
	type CookieChangedCause = 'explicit' | 'overwrite' | 'expired' | 'evicted' | 'expired-overwrite';

B
Benjamin Pasero 已提交
3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642
	interface CookieDetails {
		/**
		 * The URL associated with the cookie.
		 */
		url: string;
		/**
		 * The name of the cookie.
		 * Default: empty.
		 */
		name?: string;
		/**
		 * The value of the cookie.
		 * Default: empty.
		 */
		value?: string;
		/**
		 * The domain of the cookie.
		 * Default: empty.
		 */
		domain?: string;
		/**
		 * The path of the cookie.
		 * Default: empty.
		 */
		path?: string;
		/**
		 * Whether the cookie should be marked as secure.
		 * Default: false.
		 */
		secure?: boolean;
		/**
		 * Whether the cookie should be marked as HTTP only.
		 * Default: false.
		 */
		httpOnly?: boolean;
		/**
		 * The expiration date of the cookie as the number of seconds since the UNIX epoch.
		 * If omitted, the cookie becomes a session cookie.
		 */
		expirationDate?: number;
	}

	interface SessionCookies {
		/**
		 * Sends a request to get all cookies matching filter.
		 */
		get(filter: CookieFilter, callback: (error: Error, cookies: Cookie[]) => void): void;
		/**
		 * Sets the cookie with details.
		 */
		set(details: CookieDetails, callback: (error: Error) => void): void;
		/**
		 * Removes the cookies matching url and name.
		 */
		remove(url: string, name: string, callback: (error: Error) => void): void;
	}

	/**
	 * Each API accepts an optional filter and a listener, the listener will be called when the API's event has happened.
	 * Passing null as listener will unsubscribe from the event.
	 *
	 * The filter will be used to filter out the requests that do not match the URL patterns.
	 * If the filter is omitted then all requests will be matched.
	 *
	 * For certain events the listener is passed with a callback,
	 * which should be called with an response object when listener has done its work.
	 */
	interface WebRequest {
		/**
		 * The listener will be called when a request is about to occur.
		 */
		onBeforeRequest(listener: (details: WebRequest.BeforeRequestDetails, callback: WebRequest.BeforeRequestCallback) => void): void;
		/**
		 * The listener will be called when a request is about to occur.
		 */
		onBeforeRequest(filter: WebRequest.Filter, listener: (details: WebRequest.BeforeRequestDetails, callback: WebRequest.BeforeRequestCallback) => void): void;
		/**
		 * The listener will be called before sending an HTTP request, once the request headers are available.
		 * This may occur after a TCP connection is made to the server, but before any http data is sent.
		 */
		onBeforeSendHeaders(listener: (details: WebRequest.BeforeSendHeadersDetails, callback: WebRequest.BeforeSendHeadersCallback) => void): void;
		/**
		 * The listener will be called before sending an HTTP request, once the request headers are available.
		 * This may occur after a TCP connection is made to the server, but before any http data is sent.
		 */
		onBeforeSendHeaders(filter: WebRequest.Filter, listener: (details: WebRequest.BeforeSendHeadersDetails, callback: WebRequest.BeforeSendHeadersCallback) => void): void;
		/**
		 * The listener will be called just before a request is going to be sent to the server,
		 * modifications of previous onBeforeSendHeaders response are visible by the time this listener is fired.
		 */
		onSendHeaders(listener: (details: WebRequest.SendHeadersDetails) => void): void;
		/**
		 * The listener will be called just before a request is going to be sent to the server,
		 * modifications of previous onBeforeSendHeaders response are visible by the time this listener is fired.
		 */
		onSendHeaders(filter: WebRequest.Filter, listener: (details: WebRequest.SendHeadersDetails) => void): void;
		/**
		 * The listener will be called when HTTP response headers of a request have been received.
		 */
		onHeadersReceived(listener: (details: WebRequest.HeadersReceivedDetails, callback: WebRequest.HeadersReceivedCallback) => void): void;
		/**
		 * The listener will be called when HTTP response headers of a request have been received.
		 */
		onHeadersReceived(filter: WebRequest.Filter, listener: (details: WebRequest.HeadersReceivedDetails, callback: WebRequest.HeadersReceivedCallback) => void): void;
		/**
		 * The listener will be called when first byte of the response body is received.
		 * For HTTP requests, this means that the status line and response headers are available.
		 */
		onResponseStarted(listener: (details: WebRequest.ResponseStartedDetails) => void): void;
		/**
		 * The listener will be called when first byte of the response body is received.
		 * For HTTP requests, this means that the status line and response headers are available.
		 */
		onResponseStarted(filter: WebRequest.Filter, listener: (details: WebRequest.ResponseStartedDetails) => void): void;
		/**
		 * The listener will be called when a server initiated redirect is about to occur.
		 */
		onBeforeRedirect(listener: (details: WebRequest.BeforeRedirectDetails) => void): void;
		/**
		 * The listener will be called when a server initiated redirect is about to occur.
		 */
		onBeforeRedirect(filter: WebRequest.Filter, listener: (details: WebRequest.BeforeRedirectDetails) => void): void;
		/**
		 * The listener will be called when a request is completed.
		 */
		onCompleted(listener: (details: WebRequest.CompletedDetails) => void): void;
		/**
		 * The listener will be called when a request is completed.
		 */
		onCompleted(filter: WebRequest.Filter, listener: (details: WebRequest.CompletedDetails) => void): void;
		/**
		 * The listener will be called when an error occurs.
		 */
		onErrorOccurred(listener: (details: WebRequest.ErrorOccurredDetails) => void): void;
		/**
		 * The listener will be called when an error occurs.
		 */
		onErrorOccurred(filter: WebRequest.Filter, listener: (details: WebRequest.ErrorOccurredDetails) => void): void;
	}

	namespace WebRequest {
		interface Filter {
			urls: string[];
		}

		interface Details {
			id: number;
			url: string;
			method: string;
			resourceType: string;
			timestamp: number;
		}

		interface UploadData {
			/**
			 * Content being sent.
			 */
			bytes: Buffer;
			/**
			 * Path of file being uploaded.
			 */
			file: string;
3643 3644 3645 3646
			/**
			 * UUID of blob data. Use session.getBlobData method to retrieve the data.
			 */
			blobUUID: string;
B
Benjamin Pasero 已提交
3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731
		}

		interface BeforeRequestDetails extends Details {
			uploadData?: UploadData[];
		}

		type BeforeRequestCallback = (response: {
			cancel?: boolean;
			/**
			 * The original request is prevented from being sent or completed, and is instead redirected to the given URL.
			 */
			redirectURL?: string;
		}) => void;

		interface BeforeSendHeadersDetails extends Details {
			requestHeaders: Headers;
		}

		type BeforeSendHeadersCallback = (response: {
			cancel?: boolean;
			/**
			 * When provided, request will be made with these headers.
			 */
			requestHeaders?: Headers;
		}) => void;

		interface SendHeadersDetails extends Details {
			requestHeaders: Headers;
		}

		interface HeadersReceivedDetails extends Details {
			statusLine: string;
			statusCode: number;
			responseHeaders: Headers;
		}

		type HeadersReceivedCallback = (response: {
			cancel?: boolean;
			/**
			 * When provided, the server is assumed to have responded with these headers.
			 */
			responseHeaders?: Headers;
			/**
			 * Should be provided when overriding responseHeaders to change header status
			 * otherwise original response header's status will be used.
			 */
			statusLine?: string;
		}) => void;

		interface ResponseStartedDetails extends Details {
			responseHeaders: Headers;
			fromCache: boolean;
			statusCode: number;
			statusLine: string;
		}

		interface BeforeRedirectDetails extends Details {
			redirectURL: string;
			statusCode: number;
			ip?: string;
			fromCache: boolean;
			responseHeaders: Headers;
		}

		interface CompletedDetails extends Details {
			responseHeaders: Headers;
			fromCache: boolean;
			statusCode: number;
			statusLine: string;
		}

		interface ErrorOccurredDetails extends Details {
			fromCache: boolean;
			error: string;
		}
	}

	// https://github.com/electron/electron/blob/master/docs/api/shell.md

	/**
	 * The shell module provides functions related to desktop integration.
	 */
	interface Shell {
		/**
		 * Show the given file in a file manager. If possible, select the file.
3732
		 * @returns Whether the item was successfully shown.
B
Benjamin Pasero 已提交
3733
		 */
3734
		showItemInFolder(fullPath: string): boolean;
B
Benjamin Pasero 已提交
3735 3736
		/**
		 * Open the given file in the desktop's default manner.
3737
		 * @returns Whether the item was successfully shown.
B
Benjamin Pasero 已提交
3738
		 */
3739
		openItem(fullPath: string): boolean;
B
Benjamin Pasero 已提交
3740 3741 3742
		/**
		 * Open the given external protocol URL in the desktop's default manner
		 * (e.g., mailto: URLs in the default mail user agent).
3743
		 * @returns Whether an application was available to open the URL.
B
Benjamin Pasero 已提交
3744 3745 3746 3747 3748 3749 3750 3751 3752 3753
		 */
		openExternal(url: string, options?: {
			/**
			 * Bring the opened application to the foreground.
			 * Default: true.
			 */
			activate: boolean;
		}): boolean;
		/**
		 * Move the given file to trash.
3754
		 * @returns Whether the item was successfully moved to the trash.
B
Benjamin Pasero 已提交
3755 3756 3757 3758 3759 3760
		 */
		moveItemToTrash(fullPath: string): boolean;
		/**
		 * Play the beep sound.
		 */
		beep(): void;
B
Benjamin Pasero 已提交
3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816
		/**
		 * Creates or updates a shortcut link at shortcutPath.
		 *
		 * Note: This API is available only on Windows.
		 */
		writeShortcutLink(shortcutPath: string, options: ShortcutLinkOptions): boolean;
		/**
		 * Creates or updates a shortcut link at shortcutPath.
		 *
		 * Note: This API is available only on Windows.
		 */
		writeShortcutLink(shortcutPath: string, operation: 'create' | 'update' | 'replace', options: ShortcutLinkOptions): boolean;
		/**
		 * Resolves the shortcut link at shortcutPath.
		 * An exception will be thrown when any error happens.
		 *
		 * Note: This API is available only on Windows.
		 */
		readShortcutLink(shortcutPath: string): ShortcutLinkOptions;
	}

	interface ShortcutLinkOptions {
		/**
		 * The target to launch from this shortcut.
		 */
		target: string;
		/**
		 * The working directory.
		 * Default: empty.
		 */
		cwd?: string;
		/**
		 * The arguments to be applied to target when launching from this shortcut.
		 * Default: empty.
		 */
		args?: string;
		/**
		 * The description of the shortcut.
		 * Default: empty.
		 */
		description?: string;
		/**
		 * The path to the icon, can be a DLL or EXE. icon and iconIndex have to be set together.
		 * Default: empty, which uses the target's icon.
		 */
		icon?: string;
		/**
		 * The resource ID of icon when icon is a DLL or EXE.
		 * Default: 0.
		 */
		iconIndex?: number;
		/**
		 * The Application User Model ID.
		 * Default: empty.
		 */
		appUserModelId?: string;
B
Benjamin Pasero 已提交
3817 3818 3819 3820
	}

	// https://github.com/electron/electron/blob/master/docs/api/system-preferences.md

3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850
	type SystemColor =
		'3d-dark-shadow' |            // Dark shadow for three-dimensional display elements.
		'3d-face' |                   // Face color for three-dimensional display elements and for dialog box backgrounds.
		'3d-highlight' |              // Highlight color for three-dimensional display elements.
		'3d-light' |                  // Light color for three-dimensional display elements.
		'3d-shadow' |                 // Shadow color for three-dimensional display elements.
		'active-border' |             // Active window border.
		'active-caption' |            // Active window title bar. Specifies the left side color in the color gradient of an active window's title bar if the gradient effect is enabled.
		'active-caption-gradient' |   // Right side color in the color gradient of an active window's title bar.
		'app-workspace' |             // Background color of multiple document interface (MDI) applications.
		'button-text' |               // Text on push buttons.
		'caption-text' |              // Text in caption, size box, and scroll bar arrow box.
		'desktop' |                   // Desktop background color.
		'disabled-text' |             // Grayed (disabled) text.
		'highlight' |                 // Item(s) selected in a control.
		'highlight-text' |            // Text of item(s) selected in a control.
		'hotlight' |                  // Color for a hyperlink or hot-tracked item.
		'inactive-border' |           // Inactive window border.
		'inactive-caption' |          // Inactive window caption. Specifies the left side color in the color gradient of an inactive window's title bar if the gradient effect is enabled.
		'inactive-caption-gradient' | // Right side color in the color gradient of an inactive window's title bar.
		'inactive-caption-text' |     // Color of text in an inactive caption.
		'info-background' |           // Background color for tooltip controls.
		'info-text' |                 // Text color for tooltip controls.
		'menu' |                      // Menu background.
		'menu-highlight' |            // The color used to highlight menu items when the menu appears as a flat menu.
		'menubar' |                   // The background color for the menu bar when menus appear as flat menus.
		'menu-text' |                 // Text in menus.
		'scrollbar' |                 // Scroll bar gray area.
		'window' |                    // Window background.
		'window-frame' |              // Window frame.
J
Joao Moreno 已提交
3851
		'window-text'; // Text in windows.
3852

B
Benjamin Pasero 已提交
3853 3854 3855 3856 3857
	/**
	 * Get system preferences.
	 */
	interface SystemPreferences {
		/**
3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877
		 * Note: This is only implemented on Windows.
		 */
		on(event: 'accent-color-changed', listener: (event: Event, newColor: string) => void): this;
		/**
		 * Note: This is only implemented on Windows.
		 */
		on(event: 'color-changed', listener: (event: Event) => void): this;
		/**
		 * Note: This is only implemented on Windows.
		 */
		on(event: 'inverted-color-scheme-changed', listener: (
			event: Event,
			/**
			 * @param invertedColorScheme true if an inverted color scheme, such as a high contrast theme, is being used, false otherwise.
			 */
			invertedColorScheme: boolean
		) => void): this;
		on(event: string, listener: Function): this;
		/**
		 * @returns Whether the system is in Dark Mode.
B
Benjamin Pasero 已提交
3878 3879 3880 3881
		 *
		 * Note: This is only implemented on macOS.
		 */
		isDarkMode(): boolean;
B
Benjamin Pasero 已提交
3882
		/**
3883
		 * @returns Whether the Swipe between pages setting is on.
B
Benjamin Pasero 已提交
3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901
		 *
		 * Note: This is only implemented on macOS.
		 */
		isSwipeTrackingFromScrollEventsEnabled(): boolean;
		/**
		 * Posts event as native notifications of macOS.
		 * The userInfo contains the user information dictionary sent along with the notification.
		 *
		 * Note: This is only implemented on macOS.
		 */
		postNotification(event: string, userInfo: Object): void;
		/**
		 * Posts event as native notifications of macOS.
		 * The userInfo contains the user information dictionary sent along with the notification.
		 *
		 * Note: This is only implemented on macOS.
		 */
		postLocalNotification(event: string, userInfo: Object): void;
B
Benjamin Pasero 已提交
3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929
		/**
		 * Subscribes to native notifications of macOS, callback will be called when the corresponding event happens.
		 * The id of the subscriber is returned, which can be used to unsubscribe the event.
		 *
		 * Note: This is only implemented on macOS.
		 */
		subscribeNotification(event: string, callback: (event: Event, userInfo: Object) => void): number;
		/**
		 * Removes the subscriber with id.
		 *
		 * Note: This is only implemented on macOS.
		 */
		unsubscribeNotification(id: number): void;
		/**
		 * Same as subscribeNotification, but uses NSNotificationCenter for local defaults.
		 */
		subscribeLocalNotification(event: string, callback: (event: Event, userInfo: Object) => void): number;
		/**
		 * Same as unsubscribeNotification, but removes the subscriber from NSNotificationCenter.
		 */
		unsubscribeLocalNotification(id: number): void;
		/**
		 * Get the value of key in system preferences.
		 *
		 * Note: This is only implemented on macOS.
		 */
		getUserDefault(key: string, type: 'string' | 'boolean' | 'integer' | 'float' | 'double' | 'url' | 'array' | 'dictionary'): any;
		/**
3930
		 * @returns Whether DWM composition (Aero Glass) is enabled.
B
Benjamin Pasero 已提交
3931 3932 3933 3934
		 *
		 * Note: This is only implemented on Windows.
		 */
		isAeroGlassEnabled(): boolean;
3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952
		/**
		 * @returns The users current system wide color preference in the form of an RGBA hexadecimal string.
		 *
		 * Note: This is only implemented on Windows.
		 */
		getAccentColor(): string;
		/**
		 * @returns true if an inverted color scheme, such as a high contrast theme, is active, false otherwise.
		 *
		 * Note: This is only implemented on Windows.
		 */
		isInvertedColorScheme(): boolean;
		/**
		 * @returns The system color setting in RGB hexadecimal form (#ABCDEF). See the Windows docs for more details.
		 *
		 * Note: This is only implemented on Windows.
		 */
		getColor(color: SystemColor): string;
B
Benjamin Pasero 已提交
3953 3954 3955 3956 3957 3958 3959
	}

	// https://github.com/electron/electron/blob/master/docs/api/tray.md

	/**
	 * A Tray represents an icon in an operating system's notification area.
	 */
J
Joao Moreno 已提交
3960
	class Tray extends NodeJS.EventEmitter implements Destroyable {
B
Benjamin Pasero 已提交
3961 3962 3963 3964
		/**
		 * Emitted when the tray icon is clicked.
		 * Note: The bounds payload is only implemented on macOS and Windows.
		 */
B
Benjamin Pasero 已提交
3965
		on(event: 'click', listener: (modifiers: Modifiers, bounds: Rectangle) => void): this;
B
Benjamin Pasero 已提交
3966 3967 3968 3969
		/**
		 * Emitted when the tray icon is right clicked.
		 * Note: This is only implemented on macOS and Windows.
		 */
B
Benjamin Pasero 已提交
3970
		on(event: 'right-click', listener: (modifiers: Modifiers, bounds: Rectangle) => void): this;
B
Benjamin Pasero 已提交
3971 3972 3973 3974
		/**
		 * Emitted when the tray icon is double clicked.
		 * Note: This is only implemented on macOS and Windows.
		 */
B
Benjamin Pasero 已提交
3975
		on(event: 'double-click', listener: (modifiers: Modifiers, bounds: Rectangle) => void): this;
B
Benjamin Pasero 已提交
3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000
		/**
		 * Emitted when the tray balloon shows.
		 * Note: This is only implemented on Windows.
		 */
		on(event: 'balloon-show', listener: Function): this;
		/**
		 * Emitted when the tray balloon is clicked.
		 * Note: This is only implemented on Windows.
		 */
		on(event: 'balloon-click', listener: Function): this;
		/**
		 * Emitted when the tray balloon is closed because of timeout or user manually closes it.
		 * Note: This is only implemented on Windows.
		 */
		on(event: 'balloon-closed', listener: Function): this;
		/**
		 * Emitted when any dragged items are dropped on the tray icon.
		 * Note: This is only implemented on macOS.
		 */
		on(event: 'drop', listener: Function): this;
		/**
		 * Emitted when dragged files are dropped in the tray icon.
		 * Note: This is only implemented on macOS
		 */
		on(event: 'drop-files', listener: (event: Event, files: string[]) => void): this;
B
Benjamin Pasero 已提交
4001 4002 4003 4004 4005
		/**
		 * Emitted when dragged text is dropped in the tray icon.
		 * Note: This is only implemented on macOS
		 */
		on(event: 'drop-text', listener: (event: Event, text: string) => void): this;
B
Benjamin Pasero 已提交
4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024
		/**
		 * Emitted when a drag operation enters the tray icon.
		 * Note: This is only implemented on macOS
		 */
		on(event: 'drag-enter', listener: Function): this;
		/**
		 * Emitted when a drag operation exits the tray icon.
		 * Note: This is only implemented on macOS
		 */
		on(event: 'drag-leave', listener: Function): this;
		/**
		 * Emitted when a drag operation ends on the tray or ends at another location.
		 * Note: This is only implemented on macOS
		 */
		on(event: 'drag-end', listener: Function): this;
		on(event: string, listener: Function): this;
		/**
		 * Creates a new tray icon associated with the image.
		 */
J
Joao Moreno 已提交
4025
		constructor(image: NativeImage | string);
B
Benjamin Pasero 已提交
4026 4027 4028 4029 4030 4031 4032
		/**
		 * Destroys the tray icon immediately.
		 */
		destroy(): void;
		/**
		 * Sets the image associated with this tray icon.
		 */
J
Joao Moreno 已提交
4033
		setImage(image: NativeImage | string): void;
B
Benjamin Pasero 已提交
4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047
		/**
		 * Sets the image associated with this tray icon when pressed.
		 */
		setPressedImage(image: NativeImage): void;
		/**
		 * Sets the hover text for this tray icon.
		 */
		setToolTip(toolTip: string): void;
		/**
		 * Sets the title displayed aside of the tray icon in the status bar.
		 * Note: This is only implemented on macOS.
		 */
		setTitle(title: string): void;
		/**
B
Benjamin Pasero 已提交
4048
		 * Sets when the tray's icon background becomes highlighted.
B
Benjamin Pasero 已提交
4049 4050
		 * Note: This is only implemented on macOS.
		 */
B
Benjamin Pasero 已提交
4051
		setHighlightMode(mode: 'selection' | 'always' | 'never'): void;
B
Benjamin Pasero 已提交
4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074
		/**
		 * Displays a tray balloon.
		 * Note: This is only implemented on Windows.
		 */
		displayBalloon(options?: {
			icon?: NativeImage;
			title?: string;
			content?: string;
		}): void;
		/**
		 * Pops up the context menu of tray icon. When menu is passed,
		 * the menu will showed instead of the tray's context menu.
		 * The position is only available on Windows, and it is (0, 0) by default.
		 * Note: This is only implemented on macOS and Windows.
		 */
		popUpContextMenu(menu?: Menu, position?: Point): void;
		/**
		 * Sets the context menu for this icon.
		 */
		setContextMenu(menu: Menu): void;
		/**
		 * @returns The bounds of this tray icon.
		 */
B
Benjamin Pasero 已提交
4075
		getBounds(): Rectangle;
4076 4077 4078 4079
		/**
		 * @returns Whether the tray icon is destroyed.
		 */
		isDestroyed(): boolean;
B
Benjamin Pasero 已提交
4080 4081 4082 4083 4084 4085 4086 4087 4088
	}

	interface Modifiers {
		altKey: boolean;
		shiftKey: boolean;
		ctrlKey: boolean;
		metaKey: boolean;
	}

B
Benjamin Pasero 已提交
4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099
	interface DragItem {
		/**
		* The absolute path of the file to be dragged
		*/
		file: string;
		/**
		* The image showing under the cursor when dragging.
		*/
		icon: NativeImage;
	}

B
Benjamin Pasero 已提交
4100 4101
	// https://github.com/electron/electron/blob/master/docs/api/web-contents.md

B
Benjamin Pasero 已提交
4102 4103
	interface WebContentsStatic {
		/**
B
Benjamin Pasero 已提交
4104
		 * @returns An array of all WebContents instances. This will contain web contents for all windows,
B
Benjamin Pasero 已提交
4105 4106 4107 4108 4109 4110 4111
		 * webviews, opened devtools, and devtools extension background pages.
		 */
		getAllWebContents(): WebContents[];
		/**
		 * @returns The web contents that is focused in this application, otherwise returns null.
		 */
		getFocusedWebContents(): WebContents;
B
Benjamin Pasero 已提交
4112 4113 4114 4115
		/**
		 * Find a WebContents instance according to its ID.
		 */
		fromId(id: number): WebContents;
B
Benjamin Pasero 已提交
4116 4117
	}

B
Benjamin Pasero 已提交
4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185
	/**
	 * A WebContents is responsible for rendering and controlling a web page.
	 */
	interface WebContents extends NodeJS.EventEmitter {
		/**
		 * Emitted when the navigation is done, i.e. the spinner of the tab has stopped spinning,
		 * and the onload event was dispatched.
		 */
		on(event: 'did-finish-load', listener: Function): this;
		/**
		 * This event is like did-finish-load but emitted when the load failed or was cancelled,
		 * e.g. window.stop() is invoked.
		 */
		on(event: 'did-fail-load', listener: (event: Event, errorCode: number, errorDescription: string, validatedURL: string, isMainFrame: boolean) => void): this;
		/**
		 * Emitted when a frame has done navigation.
		 */
		on(event: 'did-frame-finish-load', listener: (event: Event, isMainFrame: boolean) => void): this;
		/**
		 * Corresponds to the points in time when the spinner of the tab started spinning.
		 */
		on(event: 'did-start-loading', listener: Function): this;
		/**
		 * Corresponds to the points in time when the spinner of the tab stopped spinning.
		 */
		on(event: 'did-stop-loading', listener: Function): this;
		/**
		 * Emitted when details regarding a requested resource are available.
		 * status indicates the socket connection to download the resource.
		 */
		on(event: 'did-get-response-details', listener: (event: Event,
			status: boolean,
			newURL: string,
			originalURL: string,
			httpResponseCode: number,
			requestMethod: string,
			referrer: string,
			headers: Headers,
			resourceType: string
		) => void): this;
		/**
		 * Emitted when a redirect is received while requesting a resource.
		 */
		on(event: 'did-get-redirect-request', listener: (event: Event,
			oldURL: string,
			newURL: string,
			isMainFrame: boolean,
			httpResponseCode: number,
			requestMethod: string,
			referrer: string,
			headers: Headers
		) => void): this;
		/**
		 * Emitted when the document in the given frame is loaded.
		 */
		on(event: 'dom-ready', listener: (event: Event) => void): this;
		/**
		 * Emitted when page receives favicon URLs.
		 */
		on(event: 'page-favicon-updated', listener: (event: Event, favicons: string[]) => void): this;
		/**
		 * Emitted when the page requests to open a new window for a url.
		 * It could be requested by window.open or an external link like <a target='_blank'>.
		 *
		 * By default a new BrowserWindow will be created for the url.
		 *
		 * Calling event.preventDefault() will prevent creating new windows.
		 */
J
Joao Moreno 已提交
4186
		on(event: 'new-window', listener: (event: Event,
B
Benjamin Pasero 已提交
4187 4188 4189
			url: string,
			frameName: string,
			disposition: NewWindowDisposition,
J
Joao Moreno 已提交
4190
			options: BrowserWindowOptions
B
Benjamin Pasero 已提交
4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218
		) => void): this;
		/**
		 * Emitted when a user or the page wants to start navigation.
		 * It can happen when the window.location object is changed or a user clicks a link in the page.
		 *
		 * This event will not emit when the navigation is started programmatically with APIs like
		 * webContents.loadURL and webContents.back.
		 *
		 * It is also not emitted for in-page navigations, such as clicking anchor links
		 * or updating the window.location.hash. Use did-navigate-in-page event for this purpose.
		 *
		 * Calling event.preventDefault() will prevent the navigation.
		 */
		on(event: 'will-navigate', listener: (event: Event, url: string) => void): this;
		/**
		 * Emitted when a navigation is done.
		 *
		 * This event is not emitted for in-page navigations, such as clicking anchor links
		 * or updating the window.location.hash. Use did-navigate-in-page event for this purpose.
		 */
		on(event: 'did-navigate', listener: (event: Event, url: string) => void): this;
		/**
		 * Emitted when an in-page navigation happened.
		 *
		 * When in-page navigation happens, the page URL changes but does not cause
		 * navigation outside of the page. Examples of this occurring are when anchor links
		 * are clicked or when the DOM hashchange event is triggered.
		 */
B
Benjamin Pasero 已提交
4219
		on(event: 'did-navigate-in-page', listener: (event: Event, url: string, isMainFrame: boolean) => void): this;
B
Benjamin Pasero 已提交
4220 4221 4222
		/**
		 * Emitted when the renderer process has crashed.
		 */
4223
		on(event: 'crashed', listener: (event: Event, killed: boolean) => void): this;
B
Benjamin Pasero 已提交
4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295
		/**
		 * Emitted when a plugin process has crashed.
		 */
		on(event: 'plugin-crashed', listener: (event: Event, name: string, version: string) => void): this;
		/**
		 * Emitted when webContents is destroyed.
		 */
		on(event: 'destroyed', listener: Function): this;
		/**
		 * Emitted when DevTools is opened.
		 */
		on(event: 'devtools-opened', listener: Function): this;
		/**
		 * Emitted when DevTools is closed.
		 */
		on(event: 'devtools-closed', listener: Function): this;
		/**
		 * Emitted when DevTools is focused / opened.
		 */
		on(event: 'devtools-focused', listener: Function): this;
		/**
		 * Emitted when failed to verify the certificate for url.
		 * The usage is the same with the "certificate-error" event of app.
		 */
		on(event: 'certificate-error', listener: (event: Event,
			url: string,
			error: string,
			certificate: Certificate,
			callback: (trust: boolean) => void
		) => void): this;
		/**
		 * Emitted when a client certificate is requested.
		 * The usage is the same with the "select-client-certificate" event of app.
		 */
		on(event: 'select-client-certificate', listener: (event: Event,
			url: string,
			certificateList: Certificate[],
			callback: (certificate: Certificate) => void
		) => void): this;
		/**
		 * Emitted when webContents wants to do basic auth.
		 * The usage is the same with the "login" event of app.
		 */
		on(event: 'login', listener: (event: Event,
			request: LoginRequest,
			authInfo: LoginAuthInfo,
			callback: (username: string, password: string) => void
		) => void): this;
		/**
		 * Emitted when a result is available for webContents.findInPage request.
		 */
		on(event: 'found-in-page', listener: (event: Event, result: FoundInPageResult) => void): this;
		/**
		 * Emitted when media starts playing.
		 */
		on(event: 'media-started-playing', listener: Function): this;
		/**
		 * Emitted when media is paused or done playing.
		 */
		on(event: 'media-paused', listener: Function): this;
		/**
		 * Emitted when a page’s theme color changes. This is usually due to encountering a meta tag:
		 * <meta name='theme-color' content='#ff0000'>
		 */
		on(event: 'did-change-theme-color', listener: Function): this;
		/**
		 * Emitted when mouse moves over a link or the keyboard moves the focus to a link.
		 */
		on(event: 'update-target-url', listener: (event: Event, url: string) => void): this;
		/**
		 * Emitted when the cursor’s type changes.
		 * If the type parameter is custom, the image parameter will hold the custom cursor image
B
Benjamin Pasero 已提交
4296
		 * in a NativeImage, and scale, size and hotspot will hold additional information about the custom cursor.
B
Benjamin Pasero 已提交
4297
		 */
B
Benjamin Pasero 已提交
4298
		on(event: 'cursor-changed', listener: (event: Event, type: CursorType, image?: NativeImage, scale?: number, size?: Size, hotspot?: Point) => void): this;
B
Benjamin Pasero 已提交
4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310
		/**
		 * Emitted when there is a new context menu that needs to be handled.
		 */
		on(event: 'context-menu', listener: (event: Event, params: ContextMenuParams) => void): this;
		/**
		 * Emitted when bluetooth device needs to be selected on call to navigator.bluetooth.requestDevice.
		 * To use navigator.bluetooth api webBluetooth should be enabled.
		 * If event.preventDefault is not called, first available device will be selected.
		 * callback should be called with deviceId to be selected,
		 * passing empty string to callback will cancel the request.
		 */
		on(event: 'select-bluetooth-device', listener: (event: Event, deviceList: BluetoothDevice[], callback: (deviceId: string) => void) => void): this;
B
Benjamin Pasero 已提交
4311 4312 4313 4314
		/**
		 * Emitted when a new frame is generated. Only the dirty area is passed in the buffer.
		 */
		on(event: 'paint', listener: (event: Event, dirtyRect: Rectangle, image: NativeImage) => void): this;
B
Benjamin Pasero 已提交
4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334
		on(event: string, listener: Function): this;
		/**
		 * Loads the url in the window.
		 * @param url Must contain the protocol prefix (e.g., the http:// or file://).
		 */
		loadURL(url: string, options?: LoadURLOptions): void;
		/**
		 * Initiates a download of the resource at url without navigating.
		 * The will-download event of session will be triggered.
		 */
		downloadURL(url: string): void;
		/**
		 * @returns The URL of current web page.
		 */
		getURL(): string;
		/**
		 * @returns The title of web page.
		 */
		getTitle(): string;
		/**
J
Joao Moreno 已提交
4335 4336 4337 4338 4339
		 * @returns Whether the web page is destroyed.
		 */
		isDestroyed(): boolean;
		/**
		 * @returns Whether the web page is focused.
B
Benjamin Pasero 已提交
4340
		 */
J
Joao Moreno 已提交
4341
		isFocused(): boolean;
B
Benjamin Pasero 已提交
4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417
		/**
		 * @returns Whether web page is still loading resources.
		 */
		isLoading(): boolean;
		/**
		 * @returns Whether the main frame (and not just iframes or frames within it) is still loading.
		 */
		isLoadingMainFrame(): boolean;
		/**
		 * @returns Whether web page is waiting for a first-response for the main
		 * resource of the page.
		 */
		isWaitingForResponse(): boolean;
		/**
		 * Stops any pending navigation.
		 */
		stop(): void;
		/**
		 * Reloads current page.
		 */
		reload(): void;
		/**
		 * Reloads current page and ignores cache.
		 */
		reloadIgnoringCache(): void;
		/**
		 * @returns Whether the web page can go back.
		 */
		canGoBack(): boolean;
		/**
		 * @returns Whether the web page can go forward.
		 */
		canGoForward(): boolean;
		/**
		 * @returns Whether the web page can go to offset.
		 */
		canGoToOffset(offset: number): boolean;
		/**
		 * Clears the navigation history.
		 */
		clearHistory(): void;
		/**
		 * Makes the web page go back.
		 */
		goBack(): void;
		/**
		 * Makes the web page go forward.
		 */
		goForward(): void;
		/**
		 * Navigates to the specified absolute index.
		 */
		goToIndex(index: number): void;
		/**
		 * Navigates to the specified offset from the "current entry".
		 */
		goToOffset(offset: number): void;
		/**
		 * @returns Whether the renderer process has crashed.
		 */
		isCrashed(): boolean;
		/**
		 * Overrides the user agent for this page.
		 */
		setUserAgent(userAgent: string): void;
		/**
		 * @returns The user agent for this web page.
		 */
		getUserAgent(): string;
		/**
		 * Injects CSS into this page.
		 */
		insertCSS(css: string): void;
		/**
		 * Evaluates code in page.
		 * @param code Code to evaluate.
J
Joao Moreno 已提交
4418 4419
		 *
		 * @returns Promise
B
Benjamin Pasero 已提交
4420
		 */
J
Joao Moreno 已提交
4421
		executeJavaScript(code: string, userGesture?: boolean, callback?: (result: any) => void): Promise<any>;
B
Benjamin Pasero 已提交
4422 4423 4424 4425 4426 4427 4428 4429 4430
		/**
		 * Mute the audio on the current web page.
		 */
		setAudioMuted(muted: boolean): void;
		/**
		 * @returns Whether this page has been muted.
		 */
		isAudioMuted(): boolean;
		/**
B
Benjamin Pasero 已提交
4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454
		 * Changes the zoom factor to the specified factor.
		 * Zoom factor is zoom percent divided by 100, so 300% = 3.0.
		 */
		setZoomFactor(factor: number): void;
		/**
		 * Sends a request to get current zoom factor.
		 */
		getZoomFactor(callback: (zoomFactor: number) => void): void;
		/**
		 * Changes the zoom level to the specified level.
		 * The original size is 0 and each increment above or below represents
		 * zooming 20% larger or smaller to default limits of 300% and 50% of original size, respectively.
		 */
		setZoomLevel(level: number): void;
		/**
		 * Sends a request to get current zoom level.
		 */
		getZoomLevel(callback: (zoomLevel: number) => void): void;
		/**
		 * Sets the maximum and minimum zoom level.
		 */
		setZoomLevelLimits(minimumLevel: number, maximumLevel: number): void;
		/**
		 * Executes the editing command undo in web page.
B
Benjamin Pasero 已提交
4455 4456 4457
		 */
		undo(): void;
		/**
B
Benjamin Pasero 已提交
4458
		 * Executes the editing command redo in web page.
B
Benjamin Pasero 已提交
4459 4460 4461
		 */
		redo(): void;
		/**
B
Benjamin Pasero 已提交
4462
		 * Executes the editing command cut in web page.
B
Benjamin Pasero 已提交
4463 4464 4465
		 */
		cut(): void;
		/**
B
Benjamin Pasero 已提交
4466
		 * Executes the editing command copy in web page.
B
Benjamin Pasero 已提交
4467 4468 4469
		 */
		copy(): void;
		/**
B
Benjamin Pasero 已提交
4470 4471 4472 4473 4474
		 * Copy the image at the given position to the clipboard.
		 */
		copyImageAt(x: number, y: number): void;
		/**
		 * Executes the editing command paste in web page.
B
Benjamin Pasero 已提交
4475 4476 4477
		 */
		paste(): void;
		/**
B
Benjamin Pasero 已提交
4478
		 * Executes the editing command pasteAndMatchStyle in web page.
B
Benjamin Pasero 已提交
4479 4480 4481
		 */
		pasteAndMatchStyle(): void;
		/**
B
Benjamin Pasero 已提交
4482
		 * Executes the editing command delete in web page.
B
Benjamin Pasero 已提交
4483 4484 4485
		 */
		delete(): void;
		/**
B
Benjamin Pasero 已提交
4486
		 * Executes the editing command selectAll in web page.
B
Benjamin Pasero 已提交
4487 4488 4489
		 */
		selectAll(): void;
		/**
B
Benjamin Pasero 已提交
4490
		 * Executes the editing command unselect in web page.
B
Benjamin Pasero 已提交
4491 4492 4493
		 */
		unselect(): void;
		/**
B
Benjamin Pasero 已提交
4494
		 * Executes the editing command replace in web page.
B
Benjamin Pasero 已提交
4495 4496 4497
		 */
		replace(text: string): void;
		/**
B
Benjamin Pasero 已提交
4498
		 * Executes the editing command replaceMisspelling in web page.
B
Benjamin Pasero 已提交
4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599
		 */
		replaceMisspelling(text: string): void;
		/**
		 * Inserts text to the focused element.
		 */
		insertText(text: string): void;
		/**
		 * Starts a request to find all matches for the text in the web page.
		 * The result of the request can be obtained by subscribing to found-in-page event.
		 * @returns The request id used for the request.
		 */
		findInPage(text: string, options?: FindInPageOptions): number;
		/**
		 * Stops any findInPage request for the webContents with the provided action.
		 */
		stopFindInPage(action: StopFindInPageAtion): void;
		/**
		 * Checks if any serviceworker is registered.
		 */
		hasServiceWorker(callback: (hasServiceWorker: boolean) => void): void;
		/**
		 * Unregisters any serviceworker if present.
		 */
		unregisterServiceWorker(callback: (isFulfilled: boolean) => void): void;
		/**
		 * Prints window's web page. When silent is set to false, Electron will pick up system's default printer and default settings for printing.
		 * Calling window.print() in web page is equivalent to call WebContents.print({silent: false, printBackground: false}).
		 * Note: On Windows, the print API relies on pdf.dll. If your application doesn't need print feature, you can safely remove pdf.dll in saving binary size.
		 */
		print(options?: PrintOptions): void;
		/**
		 * Prints windows' web page as PDF with Chromium's preview printing custom settings.
		 */
		printToPDF(options: PrintToPDFOptions, callback: (error: Error, data: Buffer) => void): void;
		/**
		 * Adds the specified path to DevTools workspace.
		 */
		addWorkSpace(path: string): void;
		/**
		 * Removes the specified path from DevTools workspace.
		 */
		removeWorkSpace(path: string): void;
		/**
		 * Opens the developer tools.
		 */
		openDevTools(options?: {
			/**
			 * Opens the devtools with specified dock state. Defaults to last used dock state.
			 */
			mode?: 'right' | 'bottom' | 'undocked' | 'detach'
		}): void;
		/**
		 * Closes the developer tools.
		 */
		closeDevTools(): void;
		/**
		 * Returns whether the developer tools are opened.
		 */
		isDevToolsOpened(): boolean;
		/**
		 * Returns whether the developer tools are focussed.
		 */
		isDevToolsFocused(): boolean;
		/**
		 * Toggle the developer tools.
		 */
		toggleDevTools(): void;
		/**
		 * Starts inspecting element at position (x, y).
		 */
		inspectElement(x: number, y: number): void;
		/**
		 * Opens the developer tools for the service worker context.
		 */
		inspectServiceWorker(): void;
		/**
		 * Send args.. to the web page via channel in asynchronous message, the web page
		 * can handle it by listening to the channel event of ipc module.
		 * Note:
		 *   1. The IPC message handler in web pages do not have a event parameter,
		 *      which is different from the handlers on the main process.
		 *   2. There is no way to send synchronous messages from the main process
		 *      to a renderer process, because it would be very easy to cause dead locks.
		 */
		send(channel: string, ...args: any[]): void;
		/**
		 * Enable device emulation with the given parameters.
		 */
		enableDeviceEmulation(parameters: DeviceEmulationParameters): void;
		/**
		 * Disable device emulation.
		 */
		disableDeviceEmulation(): void;
		/**
		 * Sends an input event to the page.
		 */
		sendInputEvent(event: SendInputEvent): void;
		/**
		 * Begin subscribing for presentation events and captured frames,
		 * The callback will be called when there is a presentation event.
		 */
B
Benjamin Pasero 已提交
4600 4601 4602 4603 4604 4605
		beginFrameSubscription(onlyDirty: boolean, callback: BeginFrameSubscriptionCallback): void;
		/**
		 * Begin subscribing for presentation events and captured frames,
		 * The callback will be called when there is a presentation event.
		 */
		beginFrameSubscription(callback: BeginFrameSubscriptionCallback): void;
B
Benjamin Pasero 已提交
4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618
		/**
		 * End subscribing for frame presentation events.
		 */
		endFrameSubscription(): void;
		/**
		 * @returns If the process of saving page has been initiated successfully.
		 */
		savePage(fullPath: string, saveType: 'HTMLOnly' | 'HTMLComplete' | 'MHTML', callback?: (eror: Error) => void): boolean;
		/**
		 * Shows pop-up dictionary that searches the selected word on the page.
		 * Note: This API is available only on macOS.
		 */
		showDefinitionForSelection(): void;
B
Benjamin Pasero 已提交
4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643
		/**
		 * @returns Whether offscreen rendering is enabled.
		 */
		isOffscreen(): boolean;
		/**
		 * If offscreen rendering is enabled and not painting, start painting.
		 */
		startPainting(): void;
		/**
		 * If offscreen rendering is enabled and painting, stop painting.
		 */
		stopPainting(): void;
		/**
		 * If offscreen rendering is enabled returns whether it is currently painting.
		 */
		isPainting(): boolean;
		/**
		 * If offscreen rendering is enabled sets the frame rate to the specified number.
		 * Only values between 1 and 60 are accepted.
		 */
		setFrameRate(fps: number): void;
		/**
		 * If offscreen rendering is enabled returns the current frame rate.
		 */
		getFrameRate(): number;
4644 4645 4646 4647
		/**
		 * If offscreen rendering is enabled invalidates the frame and generates a new one through the 'paint' event.
		 */
		invalidate(): void;
B
Benjamin Pasero 已提交
4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659
		/**
		 * Sets the item as dragging item for current drag-drop operation.
		 */
		startDrag(item: DragItem): void;
		/**
		 * Captures a snapshot of the page within rect.
		 */
		capturePage(callback: (image: NativeImage) => void): void;
		/**
		 * Captures a snapshot of the page within rect.
		 */
		capturePage(rect: Rectangle, callback: (image: NativeImage) => void): void;
B
Benjamin Pasero 已提交
4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683
		/**
		 * @returns The unique ID of this WebContents.
		 */
		id: number;
		/**
		 * @returns The session object used by this webContents.
		 */
		session: Session;
		/**
		 * @returns The WebContents that might own this WebContents.
		 */
		hostWebContents: WebContents;
		/**
		 * @returns The WebContents of DevTools for this WebContents.
		 * Note: Users should never store this object because it may become null
		 * when the DevTools has been closed.
		 */
		devToolsWebContents: WebContents;
		/**
		 * @returns Debugger API
		 */
		debugger: Debugger;
	}

B
Benjamin Pasero 已提交
4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701
	interface BeginFrameSubscriptionCallback {
		(
			/**
			 * The frameBuffer is a Buffer that contains raw pixel data.
			 * On most machines, the pixel data is effectively stored in 32bit BGRA format,
			 * but the actual representation depends on the endianness of the processor
			 * (most modern processors are little-endian, on machines with big-endian
			 * processors the data is in 32bit ARGB format).
			 */
			frameBuffer: Buffer,
			/**
			 * The dirtyRect is an object with x, y, width, height properties that describes which part of the page was repainted.
			 * If onlyDirty is set to true, frameBuffer will only contain the repainted area. onlyDirty defaults to false.
			 */
			dirtyRect?: Rectangle
		): void
	}

B
Benjamin Pasero 已提交
4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740
	interface ContextMenuParams {
		/**
		 * x coordinate
		 */
		x: number;
		/**
		 * y coordinate
		 */
		y: number;
		/**
		 * URL of the link that encloses the node the context menu was invoked on.
		 */
		linkURL: string;
		/**
		 * Text associated with the link. May be an empty string if the contents of the link are an image.
		 */
		linkText: string;
		/**
		 * URL of the top level page that the context menu was invoked on.
		 */
		pageURL: string;
		/**
		 * URL of the subframe that the context menu was invoked on.
		 */
		frameURL: string;
		/**
		 * Source URL for the element that the context menu was invoked on.
		 * Elements with source URLs are images, audio and video.
		 */
		srcURL: string;
		/**
		 * Type of the node the context menu was invoked on.
		 */
		mediaType: 'none' | 'image' | 'audio' | 'video' | 'canvas' | 'file' | 'plugin';
		/**
		 * Parameters for the media element the context menu was invoked on.
		 */
		mediaFlags: {
			/**
B
Benjamin Pasero 已提交
4741
			 * Whether the media element has crashed.
B
Benjamin Pasero 已提交
4742 4743 4744
			 */
			inError: boolean;
			/**
B
Benjamin Pasero 已提交
4745
			 * Whether the media element is paused.
B
Benjamin Pasero 已提交
4746 4747 4748
			 */
			isPaused: boolean;
			/**
B
Benjamin Pasero 已提交
4749
			 * Whether the media element is muted.
B
Benjamin Pasero 已提交
4750 4751 4752
			 */
			isMuted: boolean;
			/**
B
Benjamin Pasero 已提交
4753
			 * Whether the media element has audio.
B
Benjamin Pasero 已提交
4754 4755 4756
			 */
			hasAudio: boolean;
			/**
B
Benjamin Pasero 已提交
4757
			 * Whether the media element is looping.
B
Benjamin Pasero 已提交
4758 4759 4760
			 */
			isLooping: boolean;
			/**
B
Benjamin Pasero 已提交
4761
			 * Whether the media element's controls are visible.
B
Benjamin Pasero 已提交
4762 4763 4764
			 */
			isControlsVisible: boolean;
			/**
B
Benjamin Pasero 已提交
4765
			 * Whether the media element's controls are toggleable.
B
Benjamin Pasero 已提交
4766 4767 4768
			 */
			canToggleControls: boolean;
			/**
B
Benjamin Pasero 已提交
4769
			 * Whether the media element can be rotated.
B
Benjamin Pasero 已提交
4770 4771 4772 4773
			 */
			canRotate: boolean;
		}
		/**
B
Benjamin Pasero 已提交
4774
		 * Whether the context menu was invoked on an image which has non-empty contents.
B
Benjamin Pasero 已提交
4775 4776 4777
		 */
		hasImageContents: boolean;
		/**
B
Benjamin Pasero 已提交
4778
		 * Whether the context is editable.
B
Benjamin Pasero 已提交
4779 4780 4781
		 */
		isEditable: boolean;
		/**
B
Benjamin Pasero 已提交
4782
		 * These flags indicate whether the renderer believes it is able to perform the corresponding action.
B
Benjamin Pasero 已提交
4783 4784 4785
		 */
		editFlags: {
			/**
B
Benjamin Pasero 已提交
4786
			 * Whether the renderer believes it can undo.
B
Benjamin Pasero 已提交
4787 4788 4789
			 */
			canUndo: boolean;
			/**
B
Benjamin Pasero 已提交
4790
			 * Whether the renderer believes it can redo.
B
Benjamin Pasero 已提交
4791 4792 4793
			 */
			canRedo: boolean;
			/**
B
Benjamin Pasero 已提交
4794
			 * Whether the renderer believes it can cut.
B
Benjamin Pasero 已提交
4795 4796 4797
			 */
			canCut: boolean;
			/**
B
Benjamin Pasero 已提交
4798
			 * Whether the renderer believes it can copy
B
Benjamin Pasero 已提交
4799 4800 4801
			 */
			canCopy: boolean;
			/**
B
Benjamin Pasero 已提交
4802
			 * Whether the renderer believes it can paste.
B
Benjamin Pasero 已提交
4803 4804 4805
			 */
			canPaste: boolean;
			/**
B
Benjamin Pasero 已提交
4806
			 * Whether the renderer believes it can delete.
B
Benjamin Pasero 已提交
4807 4808 4809
			 */
			canDelete: boolean;
			/**
B
Benjamin Pasero 已提交
4810
			 * Whether the renderer believes it can select all.
B
Benjamin Pasero 已提交
4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837
			 */
			canSelectAll: boolean;
		}
		/**
		 * Text of the selection that the context menu was invoked on.
		 */
		selectionText: string;
		/**
		 * Title or alt text of the selection that the context was invoked on.
		 */
		titleText: string;
		/**
		 * The misspelled word under the cursor, if any.
		 */
		misspelledWord: string;
		/**
		 * The character encoding of the frame on which the menu was invoked.
		 */
		frameCharset: string;
		/**
		 * If the context menu was invoked on an input field, the type of that field.
		 */
		inputFieldType: 'none' | 'plainText' | 'password' | 'other';
		/**
		 * Input source that invoked the context menu.
		 */
		menuSourceType: 'none' | 'mouse' | 'keyboard' | 'touch' | 'touchMenu';
B
Benjamin Pasero 已提交
4838 4839
	}

B
Benjamin Pasero 已提交
4840 4841 4842 4843 4844 4845 4846 4847 4848
	interface BluetoothDevice {
		deviceName: string;
		deviceId: string;
	}

	interface Headers {
		[key: string]: string;
	}

4849
	type NewWindowDisposition = 'default' | 'foreground-tab' | 'background-tab' | 'new-window' | 'save-to-disk' | 'other';
B
Benjamin Pasero 已提交
4850 4851 4852 4853 4854 4855 4856 4857 4858

	/**
	 * Specifies the action to take place when ending webContents.findInPage request.
	 * 'clearSelection' - Clear the selection.
	 * 'keepSelection' - Translate the selection into a normal selection.
	 * 'activateSelection' - Focus and click the selection node.
	 */
	type StopFindInPageAtion = 'clearSelection' | 'keepSelection' | 'activateSelection';

J
Joao Moreno 已提交
4859
	type CursorType = 'default' | 'crosshair' | 'pointer' | 'text' | 'wait' | 'help' | 'e-resize' | 'n-resize' | 'ne-resize' | 'nw-resize' | 's-resize' | 'se-resize' | 'sw-resize' | 'w-resize' | 'ns-resize' | 'ew-resize' | 'nesw-resize' | 'nwse-resize' | 'col-resize' | 'row-resize' | 'm-panning' | 'e-panning' | 'n-panning' | 'ne-panning' | 'nw-panning' | 's-panning' | 'se-panning' | 'sw-panning' | 'w-panning' | 'move' | 'vertical-text' | 'cell' | 'context-menu' | 'alias' | 'progress' | 'nodrop' | 'copy' | 'none' | 'not-allowed' | 'zoom-in' | 'zoom-out' | 'grab' | 'grabbing' | 'custom';
B
Benjamin Pasero 已提交
4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901

	interface LoadURLOptions {
		/**
		 * HTTP Referrer URL.
		 */
		httpReferrer?: string;
		/**
		 * User agent originating the request.
		 */
		userAgent?: string;
		/**
		 * Extra headers separated by "\n"
		 */
		extraHeaders?: string;
	}

	interface PrintOptions {
		/**
		 * Don't ask user for print settings.
		 * Defaults: false.
		 */
		silent?: boolean;
		/**
		 * Also prints the background color and image of the web page.
		 * Defaults: false.
		 */
		printBackground?: boolean;
	}

	interface PrintToPDFOptions {
		/**
		 * Specify the type of margins to use.
		 *   0 - default
		 *   1 - none
		 *   2 - minimum
		 * Default: 0
		 */
		marginsType?: number;
		/**
		 * Specify page size of the generated PDF.
		 * Default: A4.
		 */
B
Benjamin Pasero 已提交
4902
		pageSize?: 'A3' | 'A4' | 'A5' | 'Legal' | 'Letter' | 'Tabloid' | Size;
B
Benjamin Pasero 已提交
4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921
		/**
		 * Whether to print CSS backgrounds.
		 * Default: false.
		 */
		printBackground?: boolean;
		/**
		 * Whether to print selection only.
		 * Default: false.
		 */
		printSelectionOnly?: boolean;
		/**
		 * true for landscape, false for portrait.
		 * Default: false.
		 */
		landscape?: boolean;
	}

	interface Certificate {
		/**
B
Benjamin Pasero 已提交
4922 4923 4924 4925 4926
		 * PEM encoded data.
		 */
		data: string;
		/**
		 * Issuer's Common Name.
B
Benjamin Pasero 已提交
4927 4928
		 */
		issuerName: string;
B
Benjamin Pasero 已提交
4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948
		/**
		 * Subject's Common Name.
		 */
		subjectName: string;
		/**
		 * Hex value represented string.
		 */
		serialNumber: string;
		/**
		 * Start date of the certificate being valid in seconds.
		 */
		validStart: number;
		/**
		 * End date of the certificate being valid in seconds.
		 */
		validExpiry: number;
		/**
		 * Fingerprint of the certificate.
		 */
		fingerprint: string;
B
Benjamin Pasero 已提交
4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006
	}

	interface LoginRequest {
		method: string;
		url: string;
		referrer: string;
	}

	interface LoginAuthInfo {
		isProxy: boolean;
		scheme: string;
		host: string;
		port: number;
		realm: string;
	}

	interface FindInPageOptions {
		/**
		 * Whether to search forward or backward, defaults to true
		 */
		forward?: boolean;
		/**
		 * Whether the operation is first request or a follow up, defaults to false.
		 */
		findNext?: boolean;
		/**
		 * Whether search should be case-sensitive, defaults to false.
		 */
		matchCase?: boolean;
		/**
		 * Whether to look only at the start of words. defaults to false.
		 */
		wordStart?: boolean;
		/**
		 * When combined with wordStart, accepts a match in the middle of a word
		 * if the match begins with an uppercase letter followed by a lowercase
		 * or non-letter. Accepts several other intra-word matches, defaults to false.
		 */
		medialCapitalAsWordStart?: boolean;
	}

	interface FoundInPageResult {
		requestId: number;
		/**
		 * Indicates if more responses are to follow.
		 */
		finalUpdate: boolean;
		/**
		 * Position of the active match.
		 */
		activeMatchOrdinal?: number;
		/**
		 * Number of Matches.
		 */
		matches?: number;
		/**
		 * Coordinates of first match region.
		 */
B
Benjamin Pasero 已提交
5007
		selectionArea?: Rectangle;
B
Benjamin Pasero 已提交
5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018
	}

	interface DeviceEmulationParameters {
		/**
		 * Specify the screen type to emulated
		 * Default: desktop
		 */
		screenPosition?: 'desktop' | 'mobile';
		/**
		 * Set the emulated screen size (screenPosition == mobile)
		 */
B
Benjamin Pasero 已提交
5019
		screenSize?: Size;
B
Benjamin Pasero 已提交
5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032
		/**
		 * Position the view on the screen (screenPosition == mobile)
		 * Default: {x: 0, y: 0}
		 */
		viewPosition?: Point;
		/**
		 * Set the device scale factor (if zero defaults to original device scale factor)
		 * Default: 0
		 */
		deviceScaleFactor: number;
		/**
		 * Set the emulated view size (empty means no override).
		 */
B
Benjamin Pasero 已提交
5033
		viewSize?: Size;
B
Benjamin Pasero 已提交
5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077
		/**
		 * Whether emulated view should be scaled down if necessary to fit into available space
		 * Default: false
		 */
		fitToView?: boolean;
		/**
		 * Offset of the emulated view inside available space (not in fit to view mode)
		 * Default: {x: 0, y: 0}
		 */
		offset?: Point;
		/**
		 * Scale of emulated view inside available space (not in fit to view mode)
		 * Default: 1
		 */
		scale: number;
	}

	interface SendInputEvent {
		type: 'mouseDown' | 'mouseUp' | 'mouseEnter' | 'mouseLeave' | 'contextMenu' | 'mouseWheel' | 'mouseMove' | 'keyDown' | 'keyUp' | 'char';
		modifiers: ('shift' | 'control' | 'alt' | 'meta' | 'isKeypad' | 'isAutoRepeat' | 'leftButtonDown' | 'middleButtonDown' | 'rightButtonDown' | 'capsLock' | 'numLock' | 'left' | 'right')[];
	}

	interface SendInputKeyboardEvent extends SendInputEvent {
		keyCode: string;
	}

	interface SendInputMouseEvent extends SendInputEvent {
		x: number;
		y: number;
		button?: 'left' | 'middle' | 'right';
		globalX?: number;
		globalY?: number;
		movementX?: number;
		movementY?: number;
		clickCount?: number;
	}

	interface SendInputMouseWheelEvent extends SendInputEvent {
		deltaX?: number;
		deltaY?: number;
		wheelTicksX?: number;
		wheelTicksY?: number;
		accelerationRatioX?: number;
		accelerationRatioY?: number;
B
Benjamin Pasero 已提交
5078
		hasPreciseScrollingDeltas?: boolean;
B
Benjamin Pasero 已提交
5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115
		canScroll?: boolean;
	}

	/**
	 * Debugger API serves as an alternate transport for remote debugging protocol.
	 */
	interface Debugger extends NodeJS.EventEmitter {
		/**
		 * Attaches the debugger to the webContents.
		 * @param protocolVersion Requested debugging protocol version.
		 */
		attach(protocolVersion?: string): void;
		/**
		 * @returns Whether a debugger is attached to the webContents.
		 */
		isAttached(): boolean;
		/**
		 * Detaches the debugger from the webContents.
		 */
		detach(): void;
		/**
		 * Send given command to the debugging target.
		 * @param method Method name, should be one of the methods defined by the remote debugging protocol.
		 * @param commandParams JSON object with request parameters.
		 * @param callback Response defined by the ‘returns’ attribute of the command description in the remote debugging protocol.
		 */
		sendCommand(method: string, commandParams?: any, callback?: (error: Error, result: any) => void): void;
		/**
		 * Emitted when debugging session is terminated. This happens either when
		 * webContents is closed or devtools is invoked for the attached webContents.
		 */
		on(event: 'detach', listener: (event: Event, reason: string) => void): this;
		/**
		 * Emitted whenever debugging target issues instrumentation event.
		 * Event parameters defined by the ‘parameters’ attribute in the remote debugging protocol.
		 */
		on(event: 'message', listener: (event: Event, method: string, params: any) => void): this;
B
Benjamin Pasero 已提交
5116
		on(event: string, listener: Function): this;
B
Benjamin Pasero 已提交
5117 5118 5119 5120 5121 5122 5123 5124
	}

	// https://github.com/electron/electron/blob/master/docs/api/web-frame.md

	/**
	 * The web-frame module allows you to customize the rendering of the current web page.
	 */
	interface WebFrame {
B
Benjamin Pasero 已提交
5125
		/**
B
Benjamin Pasero 已提交
5126 5127
		 * Changes the zoom factor to the specified factor, zoom factor is
		 * zoom percent / 100, so 300% = 3.0.
B
Benjamin Pasero 已提交
5128
		 */
B
Benjamin Pasero 已提交
5129
		setZoomFactor(factor: number): void;
B
Benjamin Pasero 已提交
5130
		/**
B
Benjamin Pasero 已提交
5131
		 * @returns The current zoom factor.
B
Benjamin Pasero 已提交
5132
		 */
B
Benjamin Pasero 已提交
5133
		getZoomFactor(): number;
B
Benjamin Pasero 已提交
5134
		/**
B
Benjamin Pasero 已提交
5135 5136 5137
		 * Changes the zoom level to the specified level, 0 is "original size", and each
		 * increment above or below represents zooming 20% larger or smaller to default
		 * limits of 300% and 50% of original size, respectively.
B
Benjamin Pasero 已提交
5138
		 */
B
Benjamin Pasero 已提交
5139
		setZoomLevel(level: number): void;
B
Benjamin Pasero 已提交
5140
		/**
B
Benjamin Pasero 已提交
5141
		 * @returns The current zoom level.
B
Benjamin Pasero 已提交
5142
		 */
B
Benjamin Pasero 已提交
5143
		getZoomLevel(): number;
B
Benjamin Pasero 已提交
5144
		/**
B
Benjamin Pasero 已提交
5145
		 * Sets the maximum and minimum zoom level.
B
Benjamin Pasero 已提交
5146
		 */
B
Benjamin Pasero 已提交
5147
		setZoomLevelLimits(minimumLevel: number, maximumLevel: number): void;
B
Benjamin Pasero 已提交
5148
		/**
B
Benjamin Pasero 已提交
5149
		 * Sets a provider for spell checking in input fields and text areas.
B
Benjamin Pasero 已提交
5150
		 */
B
Benjamin Pasero 已提交
5151 5152 5153 5154 5155 5156
		setSpellCheckProvider(language: string, autoCorrectWord: boolean, provider: {
			/**
			 * @returns Whether the word passed is correctly spelled.
			 */
			spellCheck: (text: string) => boolean;
		}): void;
B
Benjamin Pasero 已提交
5157
		/**
B
Benjamin Pasero 已提交
5158 5159 5160
		 * Sets the scheme as secure scheme. Secure schemes do not trigger mixed content
		 * warnings. For example, https and data are secure schemes because they cannot be
		 * corrupted by active network attackers.
B
Benjamin Pasero 已提交
5161
		 */
B
Benjamin Pasero 已提交
5162
		registerURLSchemeAsSecure(scheme: string): void;
B
Benjamin Pasero 已提交
5163
		/**
B
Benjamin Pasero 已提交
5164
		 * Resources will be loaded from this scheme regardless of the current page’s Content Security Policy.
B
Benjamin Pasero 已提交
5165
		 */
B
Benjamin Pasero 已提交
5166
		registerURLSchemeAsBypassingCSP(scheme: string): void;
B
Benjamin Pasero 已提交
5167
		/**
B
Benjamin Pasero 已提交
5168 5169
		 * Registers the scheme as secure, bypasses content security policy for resources,
		 * allows registering ServiceWorker and supports fetch API.
B
Benjamin Pasero 已提交
5170
		 */
J
Joao Moreno 已提交
5171
		registerURLSchemeAsPrivileged(scheme: string, options?: RegisterURLSchemeOptions): void;
B
Benjamin Pasero 已提交
5172
		/**
B
Benjamin Pasero 已提交
5173
		 * Inserts text to the focused element.
B
Benjamin Pasero 已提交
5174
		 */
B
Benjamin Pasero 已提交
5175
		insertText(text: string): void;
B
Benjamin Pasero 已提交
5176
		/**
B
Benjamin Pasero 已提交
5177 5178 5179 5180
		 * Evaluates `code` in page.
		 * In the browser window some HTML APIs like `requestFullScreen` can only be
		 * invoked by a gesture from the user. Setting `userGesture` to `true` will remove
		 * this limitation.
J
Joao Moreno 已提交
5181 5182
		 *
		 * @returns Promise
B
Benjamin Pasero 已提交
5183
		 */
J
Joao Moreno 已提交
5184
		executeJavaScript(code: string, userGesture?: boolean, callback?: (result: any) => void): Promise<any>;
B
Benjamin Pasero 已提交
5185
		/**
B
Benjamin Pasero 已提交
5186
		 * @returns Object describing usage information of Blink’s internal memory caches.
B
Benjamin Pasero 已提交
5187
		 */
B
Benjamin Pasero 已提交
5188 5189 5190 5191 5192
		getResourceUsage(): ResourceUsages;
		/**
		 * Attempts to free memory that is no longer being used (like images from a previous navigation).
		 */
		clearCache(): void;
B
Benjamin Pasero 已提交
5193 5194
	}

B
Benjamin Pasero 已提交
5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212
	interface ResourceUsages {
		fonts: ResourceUsage;
		images: ResourceUsage;
		cssStyleSheets: ResourceUsage;
		xslStyleSheets: ResourceUsage;
		scripts: ResourceUsage;
		other: ResourceUsage;
	}

	interface ResourceUsage {
		count: number;
		decodedSize: number;
		liveSize: number;
		purgeableSize: number;
		purgedSize: number;
		size: number;
	}

J
Joao Moreno 已提交
5213 5214 5215 5216 5217 5218 5219 5220
	interface RegisterURLSchemeOptions {
		secure?: boolean;
		bypassCSP?: boolean;
		allowServiceWorkers?: boolean;
		supportFetchAPI?: boolean;
		corsEnabled?: boolean;
	}

B
Benjamin Pasero 已提交
5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232
	// https://github.com/electron/electron/blob/master/docs/api/web-view-tag.md

	/**
	 * Use the webview tag to embed 'guest' content (such as web pages) in your Electron app.
	 * The guest content is contained within the webview container.
	 * An embedded page within your app controls how the guest content is laid out and rendered.
	 *
	 * Unlike an iframe, the webview runs in a separate process than your app.
	 * It doesn't have the same permissions as your web page and all interactions between your app
	 * and embedded content will be asynchronous. This keeps your app safe from the embedded content.
	 */
	interface WebViewElement extends HTMLElement {
B
Benjamin Pasero 已提交
5233
		/**
B
Benjamin Pasero 已提交
5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259
		 * Returns the visible URL. Writing to this attribute initiates top-level navigation.
		 * Assigning src its own value will reload the current page.
		 * The src attribute can also accept data URLs, such as data:text/plain,Hello, world!.
		 */
		src: string;
		/**
		 * If "on", the webview container will automatically resize within the bounds specified
		 * by the attributes minwidth, minheight, maxwidth, and maxheight.
		 * These constraints do not impact the webview unless autosize is enabled.
		 * When autosize is enabled, the webview container size cannot be less than
		 * the minimum values or greater than the maximum.
		 */
		autosize: string;
		/**
		 * If "on", the guest page in webview will have node integration and can use node APIs
		 * like require and process to access low level system resources.
		 */
		nodeintegration: string;
		/**
		 * If "on", the guest page in webview will be able to use browser plugins.
		 */
		plugins: string;
		/**
		 * Specifies a script that will be loaded before other scripts run in the guest page.
		 * The protocol of script's URL must be either file: or asar:,
		 * because it will be loaded by require in guest page under the hood.
B
Benjamin Pasero 已提交
5260
		 *
B
Benjamin Pasero 已提交
5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293
		 * When the guest page doesn't have node integration this script will still have access to all Node APIs,
		 * but global objects injected by Node will be deleted after this script has finished executing.
		 */
		preload: string;
		/**
		 * Sets the referrer URL for the guest page.
		 */
		httpreferrer: string;
		/**
		 * Sets the user agent for the guest page before the page is navigated to.
		 * Once the page is loaded, use the setUserAgent method to change the user agent.
		 */
		useragent: string;
		/**
		 * If "on", the guest page will have web security disabled.
		 */
		disablewebsecurity: string;
		/**
		 * Sets the session used by the page. If partition starts with persist:,
		 * the page will use a persistent session available to all pages in the app with the same partition.
		 * If there is no persist: prefix, the page will use an in-memory session.
		 * By assigning the same partition, multiple pages can share the same session.
		 * If the partition is unset then default session of the app will be used.
		 *
		 * This value can only be modified before the first navigation,
		 * since the session of an active renderer process cannot change.
		 * Subsequent attempts to modify the value will fail with a DOM exception.
		 */
		partition: string;
		/**
		 * If "on", the guest page will be allowed to open new windows.
		 */
		allowpopups: string;
J
Joao Moreno 已提交
5294 5295 5296 5297
		/**
		 * A list of strings which specifies the web preferences to be set on the webview, separated by ,.
		 */
		webpreferences: string;
B
Benjamin Pasero 已提交
5298 5299 5300 5301 5302 5303 5304 5305
		/**
		 * A list of strings which specifies the blink features to be enabled separated by ,.
		 */
		blinkfeatures: string;
		/**
		 * A list of strings which specifies the blink features to be disabled separated by ,.
		 */
		disableblinkfeatures: string;
5306 5307 5308 5309 5310 5311 5312 5313 5314
		/**
		 * A value that links the webview to a specific webContents.
		 * When a webview first loads a new webContents is created and this attribute is set
		 * to its instance identifier. Setting this attribute on a new or existing webview connects
		 * it to the existing webContents that currently renders in a different webview.
		 *
		 * The existing webview will see the destroy event and will then create a new webContents when a new url is loaded.
		 */
		guestinstance: string;
B
Benjamin Pasero 已提交
5315 5316 5317 5318 5319 5320
		/**
		 * Loads the url in the webview, the url must contain the protocol prefix, e.g. the http:// or file://.
		 */
		loadURL(url: string, options?: LoadURLOptions): void;
		/**
		 * @returns URL of guest page.
B
Benjamin Pasero 已提交
5321
		 */
B
Benjamin Pasero 已提交
5322
		getURL(): string;
B
Benjamin Pasero 已提交
5323
		/**
B
Benjamin Pasero 已提交
5324
		 * @returns The title of guest page.
B
Benjamin Pasero 已提交
5325
		 */
B
Benjamin Pasero 已提交
5326
		getTitle(): string;
B
Benjamin Pasero 已提交
5327 5328 5329 5330 5331 5332 5333 5334
		/**
		 * @returns Whether the web page is destroyed.
		 */
		isDestroyed(): boolean;
		/**
		 * @returns Whether the web page is focused.
		 */
		isFocused(): boolean;
B
Benjamin Pasero 已提交
5335
		/**
B
Benjamin Pasero 已提交
5336
		 * @returns Whether guest page is still loading resources.
B
Benjamin Pasero 已提交
5337
		 */
B
Benjamin Pasero 已提交
5338
		isLoading(): boolean;
B
Benjamin Pasero 已提交
5339
		/**
B
Benjamin Pasero 已提交
5340
		 * Returns a boolean whether the guest page is waiting for a first-response for the main resource of the page.
B
Benjamin Pasero 已提交
5341
		 */
B
Benjamin Pasero 已提交
5342
		isWaitingForResponse(): boolean;
B
Benjamin Pasero 已提交
5343
		/**
B
Benjamin Pasero 已提交
5344
		 * Stops any pending navigation.
B
Benjamin Pasero 已提交
5345
		 */
B
Benjamin Pasero 已提交
5346
		stop(): void;
B
Benjamin Pasero 已提交
5347
		/**
B
Benjamin Pasero 已提交
5348
		 * Reloads the guest page.
B
Benjamin Pasero 已提交
5349
		 */
B
Benjamin Pasero 已提交
5350
		reload(): void;
B
Benjamin Pasero 已提交
5351
		/**
B
Benjamin Pasero 已提交
5352
		 * Reloads the guest page and ignores cache.
B
Benjamin Pasero 已提交
5353
		 */
B
Benjamin Pasero 已提交
5354
		reloadIgnoringCache(): void;
B
Benjamin Pasero 已提交
5355
		/**
B
Benjamin Pasero 已提交
5356
		 * @returns Whether the guest page can go back.
B
Benjamin Pasero 已提交
5357
		 */
B
Benjamin Pasero 已提交
5358
		canGoBack(): boolean;
B
Benjamin Pasero 已提交
5359
		/**
B
Benjamin Pasero 已提交
5360
		 * @returns Whether the guest page can go forward.
B
Benjamin Pasero 已提交
5361
		 */
B
Benjamin Pasero 已提交
5362
		canGoForward(): boolean;
B
Benjamin Pasero 已提交
5363
		/**
B
Benjamin Pasero 已提交
5364
		 * @returns Whether the guest page can go to offset.
B
Benjamin Pasero 已提交
5365
		 */
B
Benjamin Pasero 已提交
5366
		canGoToOffset(offset: number): boolean;
B
Benjamin Pasero 已提交
5367
		/**
B
Benjamin Pasero 已提交
5368
		 * Clears the navigation history.
B
Benjamin Pasero 已提交
5369
		 */
B
Benjamin Pasero 已提交
5370
		clearHistory(): void;
5371
		/**
B
Benjamin Pasero 已提交
5372
		 * Makes the guest page go back.
5373
		 */
B
Benjamin Pasero 已提交
5374
		goBack(): void;
B
Benjamin Pasero 已提交
5375
		/**
B
Benjamin Pasero 已提交
5376
		 * Makes the guest page go forward.
B
Benjamin Pasero 已提交
5377
		 */
B
Benjamin Pasero 已提交
5378
		goForward(): void;
B
Benjamin Pasero 已提交
5379
		/**
B
Benjamin Pasero 已提交
5380
		 * Navigates to the specified absolute index.
B
Benjamin Pasero 已提交
5381
		 */
B
Benjamin Pasero 已提交
5382
		goToIndex(index: number): void;
B
Benjamin Pasero 已提交
5383
		/**
B
Benjamin Pasero 已提交
5384
		 * Navigates to the specified offset from the "current entry".
B
Benjamin Pasero 已提交
5385
		 */
B
Benjamin Pasero 已提交
5386
		goToOffset(offset: number): void;
B
Benjamin Pasero 已提交
5387
		/**
B
Benjamin Pasero 已提交
5388
		 * @returns Whether the renderer process has crashed.
B
Benjamin Pasero 已提交
5389
		 */
B
Benjamin Pasero 已提交
5390
		isCrashed(): boolean;
B
Benjamin Pasero 已提交
5391
		/**
B
Benjamin Pasero 已提交
5392
		 * Overrides the user agent for the guest page.
B
Benjamin Pasero 已提交
5393
		 */
B
Benjamin Pasero 已提交
5394
		setUserAgent(userAgent: string): void;
B
Benjamin Pasero 已提交
5395
		/**
B
Benjamin Pasero 已提交
5396
		 * @returns The user agent for guest page.
B
Benjamin Pasero 已提交
5397
		 */
B
Benjamin Pasero 已提交
5398
		getUserAgent(): string;
B
Benjamin Pasero 已提交
5399
		/**
B
Benjamin Pasero 已提交
5400
		 * Injects CSS into the guest page.
B
Benjamin Pasero 已提交
5401
		 */
B
Benjamin Pasero 已提交
5402
		insertCSS(css: string): void;
B
Benjamin Pasero 已提交
5403
		/**
B
Benjamin Pasero 已提交
5404 5405
		 * Evaluates code in page. If userGesture is set, it will create the user gesture context in the page.
		 * HTML APIs like requestFullScreen, which require user action, can take advantage of this option for automation.
J
Joao Moreno 已提交
5406 5407
		 *
		 * @returns Promise
B
Benjamin Pasero 已提交
5408
		 */
J
Joao Moreno 已提交
5409
		executeJavaScript(code: string, userGesture?: boolean, callback?: (result: any) => void): Promise<any>;
B
Benjamin Pasero 已提交
5410
		/**
B
Benjamin Pasero 已提交
5411
		 * Opens a DevTools window for guest page.
B
Benjamin Pasero 已提交
5412
		 */
B
Benjamin Pasero 已提交
5413
		openDevTools(): void;
B
Benjamin Pasero 已提交
5414
		/**
B
Benjamin Pasero 已提交
5415
		 * Closes the DevTools window of guest page.
B
Benjamin Pasero 已提交
5416
		 */
B
Benjamin Pasero 已提交
5417
		closeDevTools(): void;
B
Benjamin Pasero 已提交
5418
		/**
B
Benjamin Pasero 已提交
5419
		 * @returns Whether guest page has a DevTools window attached.
J
Joao Moreno 已提交
5420

B
Benjamin Pasero 已提交
5421
		isDevToolsOpened(): boolean;
B
Benjamin Pasero 已提交
5422
		/**
B
Benjamin Pasero 已提交
5423
		 * @returns Whether DevTools window of guest page is focused.
B
Benjamin Pasero 已提交
5424
		 */
B
Benjamin Pasero 已提交
5425
		isDevToolsFocused(): boolean;
B
Benjamin Pasero 已提交
5426
		/**
B
Benjamin Pasero 已提交
5427
		 * Starts inspecting element at position (x, y) of guest page.
B
Benjamin Pasero 已提交
5428
		 */
B
Benjamin Pasero 已提交
5429
		inspectElement(x: number, y: number): void;
B
Benjamin Pasero 已提交
5430
		/**
B
Benjamin Pasero 已提交
5431
		 * Opens the DevTools for the service worker context present in the guest page.
B
Benjamin Pasero 已提交
5432
		 */
B
Benjamin Pasero 已提交
5433
		inspectServiceWorker(): void;
B
Benjamin Pasero 已提交
5434
		/**
B
Benjamin Pasero 已提交
5435
		 * Set guest page muted.
B
Benjamin Pasero 已提交
5436
		 */
B
Benjamin Pasero 已提交
5437
		setAudioMuted(muted: boolean): void;
B
Benjamin Pasero 已提交
5438
		/**
B
Benjamin Pasero 已提交
5439
		 * @returns Whether guest page has been muted.
B
Benjamin Pasero 已提交
5440
		 */
B
Benjamin Pasero 已提交
5441
		isAudioMuted(): boolean;
B
Benjamin Pasero 已提交
5442
		/**
B
Benjamin Pasero 已提交
5443
		 * Executes editing command undo in page.
B
Benjamin Pasero 已提交
5444
		 */
B
Benjamin Pasero 已提交
5445
		undo(): void;
B
Benjamin Pasero 已提交
5446
		/**
B
Benjamin Pasero 已提交
5447 5448 5449
		 * Executes editing command redo in page.
		 */
		redo(): void;
B
Benjamin Pasero 已提交
5450
		/**
B
Benjamin Pasero 已提交
5451 5452 5453
		 * Executes editing command cut in page.
		 */
		cut(): void;
B
Benjamin Pasero 已提交
5454
		/**
B
Benjamin Pasero 已提交
5455 5456 5457
		 * Executes editing command copy in page.
		 */
		copy(): void;
B
Benjamin Pasero 已提交
5458
		/**
B
Benjamin Pasero 已提交
5459 5460 5461
		 * Executes editing command paste in page.
		 */
		paste(): void;
B
Benjamin Pasero 已提交
5462
		/**
B
Benjamin Pasero 已提交
5463 5464 5465
		 * Executes editing command pasteAndMatchStyle in page.
		 */
		pasteAndMatchStyle(): void;
B
Benjamin Pasero 已提交
5466
		/**
B
Benjamin Pasero 已提交
5467 5468 5469
		 * Executes editing command delete in page.
		 */
		delete(): void;
B
Benjamin Pasero 已提交
5470
		/**
B
Benjamin Pasero 已提交
5471 5472 5473
		 * Executes editing command selectAll in page.
		 */
		selectAll(): void;
B
Benjamin Pasero 已提交
5474
		/**
B
Benjamin Pasero 已提交
5475 5476 5477
		 * Executes editing command unselect in page.
		 */
		unselect(): void;
B
Benjamin Pasero 已提交
5478
		/**
B
Benjamin Pasero 已提交
5479 5480 5481
		 * Executes editing command replace in page.
		 */
		replace(text: string): void;
B
Benjamin Pasero 已提交
5482
		/**
B
Benjamin Pasero 已提交
5483 5484 5485
		 * Executes editing command replaceMisspelling in page.
		 */
		replaceMisspelling(text: string): void;
B
Benjamin Pasero 已提交
5486
		/**
B
Benjamin Pasero 已提交
5487 5488 5489
		 * Inserts text to the focused element.
		 */
		insertText(text: string): void;
B
Benjamin Pasero 已提交
5490
		/**
B
Benjamin Pasero 已提交
5491 5492 5493 5494 5495
		 * Starts a request to find all matches for the text in the web page.
		 * The result of the request can be obtained by subscribing to found-in-page event.
		 * @returns The request id used for the request.
		 */
		findInPage(text: string, options?: FindInPageOptions): number;
B
Benjamin Pasero 已提交
5496
		/**
B
Benjamin Pasero 已提交
5497 5498 5499
		 * Stops any findInPage request for the webview with the provided action.
		 */
		stopFindInPage(action: StopFindInPageAtion): void;
B
Benjamin Pasero 已提交
5500
		/**
B
Benjamin Pasero 已提交
5501 5502 5503
		 * Prints webview's web page. Same with webContents.print([options]).
		 */
		print(options?: PrintOptions): void;
B
Benjamin Pasero 已提交
5504
		/**
B
Benjamin Pasero 已提交
5505 5506 5507
		 * Prints webview's web page as PDF, Same with webContents.printToPDF(options, callback)
		 */
		printToPDF(options: PrintToPDFOptions, callback: (error: Error, data: Buffer) => void): void;
B
Benjamin Pasero 已提交
5508
		/**
B
Benjamin Pasero 已提交
5509 5510 5511
		 * Send an asynchronous message to renderer process via channel, you can also send arbitrary arguments.
		 * The renderer process can handle the message by listening to the channel event with the ipcRenderer module.
		 * See webContents.send for examples.
B
Benjamin Pasero 已提交
5512
		 */
B
Benjamin Pasero 已提交
5513
		send(channel: string, ...args: any[]): void;
B
Benjamin Pasero 已提交
5514
		/**
B
Benjamin Pasero 已提交
5515 5516
		 * Sends an input event to the page.
		 * See webContents.sendInputEvent for detailed description of event object.
B
Benjamin Pasero 已提交
5517
		 */
B
Benjamin Pasero 已提交
5518
		sendInputEvent(event: SendInputEvent): void
B
Benjamin Pasero 已提交
5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529
		/**
		 * Changes the zoom factor to the specified factor.
		 * Zoom factor is zoom percent divided by 100, so 300% = 3.0.
		 */
		setZoomFactor(factor: number): void;
		/**
		 * Changes the zoom level to the specified level.
		 * The original size is 0 and each increment above or below represents
		 * zooming 20% larger or smaller to default limits of 300% and 50% of original size, respectively.
		 */
		setZoomLevel(level: number): void;
B
Benjamin Pasero 已提交
5530
		/**
B
Benjamin Pasero 已提交
5531 5532
		 * Shows pop-up dictionary that searches the selected word on the page.
		 * Note: This API is available only on macOS.
B
Benjamin Pasero 已提交
5533
		 */
B
Benjamin Pasero 已提交
5534
		showDefinitionForSelection(): void;
B
Benjamin Pasero 已提交
5535
		/**
B
Benjamin Pasero 已提交
5536
		 * @returns The WebContents associated with this webview.
B
Benjamin Pasero 已提交
5537
		 */
B
Benjamin Pasero 已提交
5538
		getWebContents(): WebContents;
B
Benjamin Pasero 已提交
5539 5540 5541 5542 5543 5544 5545 5546
		/**
		 * Captures a snapshot of the webview's page. Same as webContents.capturePage([rect, ]callback).
		 */
		capturePage(callback: (image: NativeImage) => void): void;
		/**
		 * Captures a snapshot of the webview's page. Same as webContents.capturePage([rect, ]callback).
		 */
		capturePage(rect: Rectangle, callback: (image: NativeImage) => void): void;
B
Benjamin Pasero 已提交
5547
		/**
B
Benjamin Pasero 已提交
5548 5549
		 * Fired when a load has committed. This includes navigation within the current document
		 * as well as subframe document-level loads, but does not include asynchronous resource loads.
B
Benjamin Pasero 已提交
5550
		 */
B
Benjamin Pasero 已提交
5551
		addEventListener(type: 'load-commit', listener: (event: WebViewElement.LoadCommitEvent) => void, useCapture?: boolean): void;
B
Benjamin Pasero 已提交
5552
		/**
B
Benjamin Pasero 已提交
5553
		 * Fired when the navigation is done, i.e. the spinner of the tab will stop spinning, and the onload event is dispatched.
B
Benjamin Pasero 已提交
5554
		 */
B
Benjamin Pasero 已提交
5555
		addEventListener(type: 'did-finish-load', listener: (event: WebViewElement.Event) => void, useCapture?: boolean): void;
B
Benjamin Pasero 已提交
5556
		/**
B
Benjamin Pasero 已提交
5557
		 * This event is like did-finish-load, but fired when the load failed or was cancelled, e.g. window.stop() is invoked.
B
Benjamin Pasero 已提交
5558
		 */
B
Benjamin Pasero 已提交
5559
		addEventListener(type: 'did-fail-load', listener: (event: WebViewElement.DidFailLoadEvent) => void, useCapture?: boolean): void;
B
Benjamin Pasero 已提交
5560
		/**
B
Benjamin Pasero 已提交
5561
		 * Fired when a frame has done navigation.
B
Benjamin Pasero 已提交
5562
		 */
B
Benjamin Pasero 已提交
5563
		addEventListener(type: 'did-frame-finish-load', listener: (event: WebViewElement.DidFrameFinishLoadEvent) => void, useCapture?: boolean): void;
B
Benjamin Pasero 已提交
5564
		/**
B
Benjamin Pasero 已提交
5565
		 * Corresponds to the points in time when the spinner of the tab starts spinning.
B
Benjamin Pasero 已提交
5566
		 */
B
Benjamin Pasero 已提交
5567
		addEventListener(type: 'did-start-loading', listener: (event: WebViewElement.Event) => void, useCapture?: boolean): void;
B
Benjamin Pasero 已提交
5568
		/**
B
Benjamin Pasero 已提交
5569
		 * Corresponds to the points in time when the spinner of the tab stops spinning.
B
Benjamin Pasero 已提交
5570
		 */
B
Benjamin Pasero 已提交
5571
		addEventListener(type: 'did-stop-loading', listener: (event: WebViewElement.Event) => void, useCapture?: boolean): void;
B
Benjamin Pasero 已提交
5572
		/**
B
Benjamin Pasero 已提交
5573 5574
		 * Fired when details regarding a requested resource is available.
		 * status indicates socket connection to download the resource.
B
Benjamin Pasero 已提交
5575
		 */
B
Benjamin Pasero 已提交
5576
		addEventListener(type: 'did-get-response-details', listener: (event: WebViewElement.DidGetResponseDetails) => void, useCapture?: boolean): void;
B
Benjamin Pasero 已提交
5577
		/**
B
Benjamin Pasero 已提交
5578
		 * Fired when a redirect was received while requesting a resource.
B
Benjamin Pasero 已提交
5579
		 */
B
Benjamin Pasero 已提交
5580
		addEventListener(type: 'did-get-redirect-request', listener: (event: WebViewElement.DidGetRedirectRequestEvent) => void, useCapture?: boolean): void;
B
Benjamin Pasero 已提交
5581
		/**
B
Benjamin Pasero 已提交
5582
		 * Fired when document in the given frame is loaded.
B
Benjamin Pasero 已提交
5583
		 */
B
Benjamin Pasero 已提交
5584
		addEventListener(type: 'dom-ready', listener: (event: WebViewElement.Event) => void, useCapture?: boolean): void;
B
Benjamin Pasero 已提交
5585
		/**
B
Benjamin Pasero 已提交
5586
		 * Fired when page title is set during navigation. explicitSet is false when title is synthesized from file URL.
B
Benjamin Pasero 已提交
5587
		 */
B
Benjamin Pasero 已提交
5588
		addEventListener(type: 'page-title-updated', listener: (event: WebViewElement.PageTitleUpdatedEvent) => void, useCapture?: boolean): void;
B
Benjamin Pasero 已提交
5589
		/**
B
Benjamin Pasero 已提交
5590
		 * Fired when page receives favicon URLs.
B
Benjamin Pasero 已提交
5591
		 */
B
Benjamin Pasero 已提交
5592
		addEventListener(type: 'page-favicon-updated', listener: (event: WebViewElement.PageFaviconUpdatedEvent) => void, useCapture?: boolean): void;
B
Benjamin Pasero 已提交
5593
		/**
B
Benjamin Pasero 已提交
5594
		 * Fired when page enters fullscreen triggered by HTML API.
B
Benjamin Pasero 已提交
5595
		 */
B
Benjamin Pasero 已提交
5596
		addEventListener(type: 'enter-html-full-screen', listener: (event: WebViewElement.Event) => void, useCapture?: boolean): void;
B
Benjamin Pasero 已提交
5597
		/**
B
Benjamin Pasero 已提交
5598
		 * Fired when page leaves fullscreen triggered by HTML API.
B
Benjamin Pasero 已提交
5599
		 */
B
Benjamin Pasero 已提交
5600
		addEventListener(type: 'leave-html-full-screen', listener: (event: WebViewElement.Event) => void, useCapture?: boolean): void;
B
Benjamin Pasero 已提交
5601
		/**
B
Benjamin Pasero 已提交
5602
		 * Fired when the guest window logs a console message.
B
Benjamin Pasero 已提交
5603
		 */
B
Benjamin Pasero 已提交
5604
		addEventListener(type: 'console-message', listener: (event: WebViewElement.ConsoleMessageEvent) => void, useCapture?: boolean): void;
B
Benjamin Pasero 已提交
5605
		/**
B
Benjamin Pasero 已提交
5606
		 * Fired when a result is available for webview.findInPage request.
B
Benjamin Pasero 已提交
5607
		 */
B
Benjamin Pasero 已提交
5608
		addEventListener(type: 'found-in-page', listener: (event: WebViewElement.FoundInPageEvent) => void, useCapture?: boolean): void;
B
Benjamin Pasero 已提交
5609
		/**
B
Benjamin Pasero 已提交
5610
		 * Fired when the guest page attempts to open a new browser window.
B
Benjamin Pasero 已提交
5611
		 */
B
Benjamin Pasero 已提交
5612
		addEventListener(type: 'new-window', listener: (event: WebViewElement.NewWindowEvent) => void, useCapture?: boolean): void;
B
Benjamin Pasero 已提交
5613
		/**
B
Benjamin Pasero 已提交
5614 5615 5616 5617 5618 5619 5620 5621 5622 5623
		 * Emitted when a user or the page wants to start navigation.
		 * It can happen when the window.location object is changed or a user clicks a link in the page.
		 *
		 * This event will not emit when the navigation is started programmatically with APIs
		 * like <webview>.loadURL and <webview>.back.
		 *
		 * It is also not emitted during in-page navigation, such as clicking anchor links
		 * or updating the window.location.hash. Use did-navigate-in-page event for this purpose.
		 *
		 * Calling event.preventDefault() does NOT have any effect.
B
Benjamin Pasero 已提交
5624
		 */
B
Benjamin Pasero 已提交
5625
		addEventListener(type: 'will-navigate', listener: (event: WebViewElement.WillNavigateEvent) => void, useCapture?: boolean): void;
B
Benjamin Pasero 已提交
5626
		/**
B
Benjamin Pasero 已提交
5627 5628 5629 5630
		 * Emitted when a navigation is done.
		 *
		 * This event is not emitted for in-page navigations, such as clicking anchor links
		 * or updating the window.location.hash. Use did-navigate-in-page event for this purpose.
B
Benjamin Pasero 已提交
5631
		 */
B
Benjamin Pasero 已提交
5632
		addEventListener(type: 'did-navigate', listener: (event: WebViewElement.DidNavigateEvent) => void, useCapture?: boolean): void;
B
Benjamin Pasero 已提交
5633
		/**
B
Benjamin Pasero 已提交
5634 5635 5636 5637 5638
		 * Emitted when an in-page navigation happened.
		 *
		 * When in-page navigation happens, the page URL changes but does not cause
		 * navigation outside of the page. Examples of this occurring are when anchor links
		 * are clicked or when the DOM hashchange event is triggered.
B
Benjamin Pasero 已提交
5639
		 */
B
Benjamin Pasero 已提交
5640
		addEventListener(type: 'did-navigate-in-page', listener: (event: WebViewElement.DidNavigateInPageEvent) => void, useCapture?: boolean): void;
B
Benjamin Pasero 已提交
5641
		/**
B
Benjamin Pasero 已提交
5642
		 * Fired when the guest page attempts to close itself.
B
Benjamin Pasero 已提交
5643
		 */
B
Benjamin Pasero 已提交
5644
		addEventListener(type: 'close', listener: (event: WebViewElement.Event) => void, useCapture?: boolean): void;
B
Benjamin Pasero 已提交
5645
		/**
B
Benjamin Pasero 已提交
5646
		 * Fired when the guest page has sent an asynchronous message to embedder page.
B
Benjamin Pasero 已提交
5647
		 */
B
Benjamin Pasero 已提交
5648
		addEventListener(type: 'ipc-message', listener: (event: WebViewElement.IpcMessageEvent) => void, useCapture?: boolean): void;
B
Benjamin Pasero 已提交
5649
		/**
B
Benjamin Pasero 已提交
5650
		 * Fired when the renderer process is crashed.
B
Benjamin Pasero 已提交
5651
		 */
B
Benjamin Pasero 已提交
5652
		addEventListener(type: 'crashed', listener: (event: WebViewElement.Event) => void, useCapture?: boolean): void;
B
Benjamin Pasero 已提交
5653
		/**
B
Benjamin Pasero 已提交
5654
		 * Fired when the gpu process is crashed.
B
Benjamin Pasero 已提交
5655
		 */
B
Benjamin Pasero 已提交
5656
		addEventListener(type: 'gpu-crashed', listener: (event: WebViewElement.Event) => void, useCapture?: boolean): void;
B
Benjamin Pasero 已提交
5657
		/**
B
Benjamin Pasero 已提交
5658
		 * Fired when a plugin process is crashed.
B
Benjamin Pasero 已提交
5659
		 */
B
Benjamin Pasero 已提交
5660
		addEventListener(type: 'plugin-crashed', listener: (event: WebViewElement.PluginCrashedEvent) => void, useCapture?: boolean): void;
B
Benjamin Pasero 已提交
5661
		/**
B
Benjamin Pasero 已提交
5662
		 * Fired when the WebContents is destroyed.
B
Benjamin Pasero 已提交
5663
		 */
B
Benjamin Pasero 已提交
5664
		addEventListener(type: 'destroyed', listener: (event: WebViewElement.Event) => void, useCapture?: boolean): void;
B
Benjamin Pasero 已提交
5665
		/**
B
Benjamin Pasero 已提交
5666
		 * Emitted when media starts playing.
B
Benjamin Pasero 已提交
5667
		 */
B
Benjamin Pasero 已提交
5668
		addEventListener(type: 'media-started-playing', listener: (event: WebViewElement.Event) => void, useCapture?: boolean): void;
B
Benjamin Pasero 已提交
5669
		/**
B
Benjamin Pasero 已提交
5670
		 * Emitted when media is paused or done playing.
B
Benjamin Pasero 已提交
5671
		 */
B
Benjamin Pasero 已提交
5672
		addEventListener(type: 'media-paused', listener: (event: WebViewElement.Event) => void, useCapture?: boolean): void;
B
Benjamin Pasero 已提交
5673
		/**
B
Benjamin Pasero 已提交
5674 5675
		 * Emitted when a page's theme color changes. This is usually due to encountering a meta tag:
		 * <meta name='theme-color' content='#ff0000'>
B
Benjamin Pasero 已提交
5676
		 */
B
Benjamin Pasero 已提交
5677
		addEventListener(type: 'did-change-theme-color', listener: (event: WebViewElement.DidChangeThemeColorEvent) => void, useCapture?: boolean): void;
B
Benjamin Pasero 已提交
5678
		/**
B
Benjamin Pasero 已提交
5679
		 * Emitted when mouse moves over a link or the keyboard moves the focus to a link.
B
Benjamin Pasero 已提交
5680
		 */
B
Benjamin Pasero 已提交
5681
		addEventListener(type: 'update-target-url', listener: (event: WebViewElement.UpdateTargetUrlEvent) => void, useCapture?: boolean): void;
B
Benjamin Pasero 已提交
5682
		/**
B
Benjamin Pasero 已提交
5683
		 * Emitted when DevTools is opened.
B
Benjamin Pasero 已提交
5684
		 */
B
Benjamin Pasero 已提交
5685
		addEventListener(type: 'devtools-opened', listener: (event: WebViewElement.Event) => void, useCapture?: boolean): void;
B
Benjamin Pasero 已提交
5686
		/**
B
Benjamin Pasero 已提交
5687
		 * Emitted when DevTools is closed.
B
Benjamin Pasero 已提交
5688
		 */
B
Benjamin Pasero 已提交
5689
		addEventListener(type: 'devtools-closed', listener: (event: WebViewElement.Event) => void, useCapture?: boolean): void;
B
Benjamin Pasero 已提交
5690
		/**
B
Benjamin Pasero 已提交
5691
		 * Emitted when DevTools is focused / opened.
B
Benjamin Pasero 已提交
5692
		 */
B
Benjamin Pasero 已提交
5693 5694
		addEventListener(type: 'devtools-focused', listener: (event: WebViewElement.Event) => void, useCapture?: boolean): void;
		addEventListener(type: string, listener: (event: WebViewElement.Event) => void, useCapture?: boolean): void;
B
Benjamin Pasero 已提交
5695 5696
	}

B
Benjamin Pasero 已提交
5697 5698
	namespace WebViewElement {
		type Event = ElectronPrivate.GlobalEvent;
B
Benjamin Pasero 已提交
5699

J
Johannes Rieken 已提交
5700
		interface LoadCommitEvent extends Event {
B
Benjamin Pasero 已提交
5701 5702 5703
			url: string;
			isMainFrame: boolean;
		}
B
Benjamin Pasero 已提交
5704

J
Johannes Rieken 已提交
5705
		interface DidFailLoadEvent extends Event {
B
Benjamin Pasero 已提交
5706 5707 5708 5709 5710
			errorCode: number;
			errorDescription: string;
			validatedURL: string;
			isMainFrame: boolean;
		}
B
Benjamin Pasero 已提交
5711

J
Johannes Rieken 已提交
5712
		interface DidFrameFinishLoadEvent extends Event {
B
Benjamin Pasero 已提交
5713 5714
			isMainFrame: boolean;
		}
B
Benjamin Pasero 已提交
5715

J
Johannes Rieken 已提交
5716
		interface DidGetResponseDetails extends Event {
B
Benjamin Pasero 已提交
5717 5718 5719 5720 5721 5722 5723 5724 5725
			status: boolean;
			newURL: string;
			originalURL: string;
			httpResponseCode: number;
			requestMethod: string;
			referrer: string;
			headers: Headers;
			resourceType: string;
		}
B
Benjamin Pasero 已提交
5726

B
Benjamin Pasero 已提交
5727 5728 5729 5730 5731 5732 5733 5734 5735
		interface DidGetRedirectRequestEvent extends Event {
			oldURL: string;
			newURL: string;
			isMainFrame: boolean;
			httpResponseCode: number;
			requestMethod: string;
			referrer: string;
			headers: Headers;
		}
B
Benjamin Pasero 已提交
5736

B
Benjamin Pasero 已提交
5737 5738 5739 5740
		interface PageTitleUpdatedEvent extends Event {
			title: string;
			explicitSet: string;
		}
B
Benjamin Pasero 已提交
5741

B
Benjamin Pasero 已提交
5742 5743 5744
		interface PageFaviconUpdatedEvent extends Event {
			favicons: string[];
		}
B
Benjamin Pasero 已提交
5745

B
Benjamin Pasero 已提交
5746 5747 5748 5749 5750 5751
		interface ConsoleMessageEvent extends Event {
			level: number;
			message: string;
			line: number;
			sourceId: string;
		}
B
Benjamin Pasero 已提交
5752

B
Benjamin Pasero 已提交
5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763
		interface FoundInPageEvent extends Event {
			result: FoundInPageResult;
		}

		interface NewWindowEvent extends Event {
			url: string;
			frameName: string;
			disposition: NewWindowDisposition;
			options: BrowserWindowOptions;
		}

B
Benjamin Pasero 已提交
5764
		interface WillNavigateEvent extends Event {
B
Benjamin Pasero 已提交
5765 5766 5767
			url: string;
		}

B
Benjamin Pasero 已提交
5768 5769 5770 5771 5772 5773 5774 5775 5776
		interface DidNavigateEvent extends Event {
			url: string;
		}

		interface DidNavigateInPageEvent extends Event {
			url: string;
			isMainFrame: boolean;
		}

B
Benjamin Pasero 已提交
5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829
		interface IpcMessageEvent extends Event {
			channel: string;
			args: any[];
		}

		interface PluginCrashedEvent extends Event {
			name: string;
			version: string;
		}

		interface DidChangeThemeColorEvent extends Event {
			themeColor: string;
		}

		interface UpdateTargetUrlEvent extends Event {
			url: string;
		}
	}

	/**
	 * The BrowserWindowProxy object is returned from window.open and provides limited functionality with the child window.
	 */
	interface BrowserWindowProxy {
		/**
		 * Removes focus from the child window.
		 */
		blur(): void;
		/**
		 * Forcefully closes the child window without calling its unload event.
		 */
		close(): void;
		/**
		 * Set to true after the child window gets closed.
		 */
		closed: boolean;
		/**
		 * Evaluates the code in the child window.
		 */
		eval(code: string): void;
		/**
		 * Focuses the child window (brings the window to front).
		 */
		focus(): void;
		/**
		 * Sends a message to the child window with the specified origin or * for no origin preference.
		 * In addition to these methods, the child window implements window.opener object with no
		 * properties and a single method.
		 */
		postMessage(message: string, targetOrigin: string): void;
		/**
		 * Invokes the print dialog on the child window.
		 */
		print(): void;
B
Benjamin Pasero 已提交
5830 5831
	}

B
Benjamin Pasero 已提交
5832 5833
	// https://github.com/electron/electron/blob/master/docs/api/synopsis.md

B
Benjamin Pasero 已提交
5834
	interface CommonElectron {
5835 5836 5837 5838
		clipboard: Electron.Clipboard;
		crashReporter: Electron.CrashReporter;
		nativeImage: typeof Electron.NativeImage;
		shell: Electron.Shell;
B
Benjamin Pasero 已提交
5839

5840 5841 5842 5843 5844
		app: Electron.App;
		autoUpdater: Electron.AutoUpdater;
		BrowserWindow: typeof Electron.BrowserWindow;
		contentTracing: Electron.ContentTracing;
		dialog: Electron.Dialog;
B
Benjamin Pasero 已提交
5845
		ipcMain: Electron.IpcMain;
5846 5847 5848
		globalShortcut: Electron.GlobalShortcut;
		Menu: typeof Electron.Menu;
		MenuItem: typeof Electron.MenuItem;
J
Joao Moreno 已提交
5849
		net: Electron.Net;
B
Benjamin Pasero 已提交
5850
		powerMonitor: Electron.PowerMonitor;
5851 5852 5853
		powerSaveBlocker: Electron.PowerSaveBlocker;
		protocol: Electron.Protocol;
		screen: Electron.Screen;
B
Benjamin Pasero 已提交
5854 5855
		session: typeof Electron.Session;
		systemPreferences: Electron.SystemPreferences;
5856
		Tray: typeof Electron.Tray;
B
Benjamin Pasero 已提交
5857
		webContents: Electron.WebContentsStatic;
B
Benjamin Pasero 已提交
5858 5859
	}

5860 5861 5862 5863 5864
	interface ElectronMainAndRenderer extends CommonElectron {
		desktopCapturer: Electron.DesktopCapturer;
		ipcRenderer: Electron.IpcRenderer;
		remote: Electron.Remote;
		webFrame: Electron.WebFrame;
B
Benjamin Pasero 已提交
5865 5866 5867
	}
}

B
Benjamin Pasero 已提交
5868 5869 5870 5871 5872 5873 5874 5875 5876 5877
declare namespace ElectronPrivate {
	type GlobalEvent = Event;
}

interface Document {
	createElement(tagName: 'webview'): Electron.WebViewElement;
}

// https://github.com/electron/electron/blob/master/docs/api/window-open.md

B
Benjamin Pasero 已提交
5878 5879 5880 5881
interface Window {
	/**
	 * Creates a new window.
	 */
5882
	open(url: string, frameName?: string, features?: string): Electron.BrowserWindowProxy;
B
Benjamin Pasero 已提交
5883
}
B
Benjamin Pasero 已提交
5884

B
Benjamin Pasero 已提交
5885 5886
// https://github.com/electron/electron/blob/master/docs/api/file-object.md

B
Benjamin Pasero 已提交
5887 5888 5889 5890 5891 5892 5893
interface File {
	/**
	 * Exposes the real path of the filesystem.
	 */
	path: string;
}

B
Benjamin Pasero 已提交
5894 5895 5896
// https://github.com/electron/electron/blob/master/docs/api/process.md

declare namespace NodeJS {
B
Benjamin Pasero 已提交
5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908

	interface ProcessVersions {
		/**
		 * Electron's version string.
		 */
		electron: string;
		/**
		 * Chrome's version string.
		 */
		chrome: string;
	}

B
Benjamin Pasero 已提交
5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006
	interface Process {
		/**
		 * Setting this to true can disable the support for asar archives in Node's built-in modules.
		 */
		noAsar?: boolean;
		/**
		 * Process's type
		 */
		type: 'browser' | 'renderer';
		/**
		 * Path to JavaScript source code.
		 */
		resourcesPath: string;
		/**
		 * For Mac App Store build, this value is true, for other builds it is undefined.
		 */
		mas?: boolean;
		/**
		 * If the app is running as a Windows Store app (appx), this value is true, for other builds it is undefined.
		 */
		windowsStore?: boolean;
		/**
		 * When app is started by being passed as parameter to the default app,
		 * this value is true in the main process, otherwise it is undefined.
		 */
		defaultApp?: boolean;
		/**
		 * Emitted when Electron has loaded its internal initialization script
		 * and is beginning to load the web page or the main script.
		 */
		on(event: 'loaded', listener: Function): this;
		on(event: string, listener: Function): this;
		/**
		 * Causes the main thread of the current process crash;
		 */
		crash(): void;
		/**
		 * Causes the main thread of the current process hang.
		 */
		hang(): void;
		/**
		 * Sets the file descriptor soft limit to maxDescriptors or the OS hard limit,
		 * whichever is lower for the current process.
		 *
		 * Note: This API is only available on macOS and Linux.
		 */
		setFdLimit(maxDescriptors: number): void;
		/**
		 * @returns Object giving memory usage statistics about the current process.
		 * Note: All statistics are reported in Kilobytes.
		 */
		getProcessMemoryInfo(): ProcessMemoryInfo;
		/**
		 * @returns Object giving memory usage statistics about the entire system.
		 * Note: All statistics are reported in Kilobytes.
		 */
		getSystemMemoryInfo(): SystemMemoryInfo;
	}

	interface ProcessMemoryInfo {
		/**
		 * The amount of memory currently pinned to actual physical RAM.
		 */
		workingSetSize: number;
		/**
		 * The maximum amount of memory that has ever been pinned to actual physical RAM.
		 */
		peakWorkingSetSize: number;
		/**
		 * The amount of memory not shared by other processes, such as JS heap or HTML content.
		 */
		privateBytes: number;
		/**
		 * The amount of memory shared between processes, typically memory consumed by the Electron code itself.
		 */
		sharedBytes: number;
	}

	interface SystemMemoryInfo {
		/**
		 * The total amount of physical memory available to the system.
		 */
		total: number;
		/**
		 * The total amount of memory not being used by applications or disk cache.
		 */
		free: number;
		/**
		 * The total amount of swap memory available to the system.
		 */
		swapTotal: number;
		/**
		 * The free amount of swap memory available to the system.
		 */
		swapFree: number;
	}
}

B
Benjamin Pasero 已提交
6007
declare module 'electron' {
6008
	var electron: Electron.ElectronMainAndRenderer;
B
Benjamin Pasero 已提交
6009 6010 6011 6012
	export = electron;
}

// interface NodeRequireFunction {
B
Benjamin Pasero 已提交
6013
// 	(moduleName: 'electron'): Electron.ElectronMainAndRenderer;
J
Joao Moreno 已提交
6014
// }