// Type definitions for Electron 20.1.0 // Project: http://electronjs.org/ // Definitions by: The Electron Team // Definitions: https://github.com/electron/electron-typescript-definitions /// type GlobalEvent = Event & { returnValue: any }; declare namespace Electron { const NodeEventEmitter: typeof import('events').EventEmitter; class Accelerator extends String { } interface App extends NodeJS.EventEmitter { // Docs: https://electronjs.org/docs/api/app /** * Emitted when Chrome's accessibility support changes. This event fires when * assistive technologies, such as screen readers, are enabled or disabled. See * https://www.chromium.org/developers/design-documents/accessibility for more * details. * * @platform darwin,win32 */ on(event: 'accessibility-support-changed', listener: (event: Event, /** * `true` when Chrome's accessibility support is enabled, `false` otherwise. */ accessibilitySupportEnabled: boolean) => void): this; once(event: 'accessibility-support-changed', listener: (event: Event, /** * `true` when Chrome's accessibility support is enabled, `false` otherwise. */ accessibilitySupportEnabled: boolean) => void): this; addListener(event: 'accessibility-support-changed', listener: (event: Event, /** * `true` when Chrome's accessibility support is enabled, `false` otherwise. */ accessibilitySupportEnabled: boolean) => void): this; removeListener(event: 'accessibility-support-changed', listener: (event: Event, /** * `true` when Chrome's accessibility support is enabled, `false` otherwise. */ accessibilitySupportEnabled: boolean) => void): this; /** * Emitted when the application is activated. Various actions can trigger this * event, such as launching the application for the first time, attempting to * re-launch the application when it's already running, or clicking on the * application's dock or taskbar icon. * * @platform darwin */ on(event: 'activate', listener: (event: Event, hasVisibleWindows: boolean) => void): this; once(event: 'activate', listener: (event: Event, hasVisibleWindows: boolean) => void): this; addListener(event: 'activate', listener: (event: Event, hasVisibleWindows: boolean) => void): this; removeListener(event: 'activate', listener: (event: Event, hasVisibleWindows: boolean) => void): this; /** * Emitted during Handoff after an activity from this device was successfully * resumed on another one. * * @platform darwin */ on(event: 'activity-was-continued', listener: (event: Event, /** * A string identifying the activity. Maps to `NSUserActivity.activityType`. */ type: string, /** * Contains app-specific state stored by the activity. */ userInfo: unknown) => void): this; once(event: 'activity-was-continued', listener: (event: Event, /** * A string identifying the activity. Maps to `NSUserActivity.activityType`. */ type: string, /** * Contains app-specific state stored by the activity. */ userInfo: unknown) => void): this; addListener(event: 'activity-was-continued', listener: (event: Event, /** * A string identifying the activity. Maps to `NSUserActivity.activityType`. */ type: string, /** * Contains app-specific state stored by the activity. */ userInfo: unknown) => void): this; removeListener(event: 'activity-was-continued', listener: (event: Event, /** * A string identifying the activity. Maps to `NSUserActivity.activityType`. */ type: string, /** * Contains app-specific state stored by the activity. */ userInfo: unknown) => void): this; /** * Emitted before the application starts closing its windows. Calling * `event.preventDefault()` will prevent the default behavior, which is terminating * the application. * * **Note:** If application quit was initiated by `autoUpdater.quitAndInstall()`, * then `before-quit` is emitted *after* emitting `close` event on all windows and * closing them. * * **Note:** On Windows, this event will not be emitted if the app is closed due to * a shutdown/restart of the system or a user logout. */ on(event: 'before-quit', listener: (event: Event) => void): this; once(event: 'before-quit', listener: (event: Event) => void): this; addListener(event: 'before-quit', listener: (event: Event) => void): this; removeListener(event: 'before-quit', listener: (event: Event) => void): this; /** * Emitted when a browserWindow gets blurred. */ on(event: 'browser-window-blur', listener: (event: Event, window: BrowserWindow) => void): this; once(event: 'browser-window-blur', listener: (event: Event, window: BrowserWindow) => void): this; addListener(event: 'browser-window-blur', listener: (event: Event, window: BrowserWindow) => void): this; removeListener(event: 'browser-window-blur', listener: (event: Event, window: BrowserWindow) => void): this; /** * Emitted when a new browserWindow is created. */ on(event: 'browser-window-created', listener: (event: Event, window: BrowserWindow) => void): this; once(event: 'browser-window-created', listener: (event: Event, window: BrowserWindow) => void): this; addListener(event: 'browser-window-created', listener: (event: Event, window: BrowserWindow) => void): this; removeListener(event: 'browser-window-created', listener: (event: Event, window: BrowserWindow) => void): this; /** * Emitted when a browserWindow gets focused. */ on(event: 'browser-window-focus', listener: (event: Event, window: BrowserWindow) => void): this; once(event: 'browser-window-focus', listener: (event: Event, window: BrowserWindow) => void): this; addListener(event: 'browser-window-focus', listener: (event: Event, window: BrowserWindow) => void): this; removeListener(event: 'browser-window-focus', listener: (event: Event, window: BrowserWindow) => void): this; /** * 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)`. */ on(event: 'certificate-error', listener: (event: Event, webContents: WebContents, url: string, /** * The error code */ error: string, certificate: Certificate, callback: (isTrusted: boolean) => void, isMainFrame: boolean) => void): this; once(event: 'certificate-error', listener: (event: Event, webContents: WebContents, url: string, /** * The error code */ error: string, certificate: Certificate, callback: (isTrusted: boolean) => void, isMainFrame: boolean) => void): this; addListener(event: 'certificate-error', listener: (event: Event, webContents: WebContents, url: string, /** * The error code */ error: string, certificate: Certificate, callback: (isTrusted: boolean) => void, isMainFrame: boolean) => void): this; removeListener(event: 'certificate-error', listener: (event: Event, webContents: WebContents, url: string, /** * The error code */ error: string, certificate: Certificate, callback: (isTrusted: boolean) => void, isMainFrame: boolean) => void): this; /** * Emitted when the child process unexpectedly disappears. This is normally because * it was crashed or killed. It does not include renderer processes. */ on(event: 'child-process-gone', listener: (event: Event, details: Details) => void): this; once(event: 'child-process-gone', listener: (event: Event, details: Details) => void): this; addListener(event: 'child-process-gone', listener: (event: Event, details: Details) => void): this; removeListener(event: 'child-process-gone', listener: (event: Event, details: Details) => void): this; /** * 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. * * A user activity can be continued only in an app that has the same developer Team * ID as the activity's source app and that supports the activity's type. Supported * activity types are specified in the app's `Info.plist` under the * `NSUserActivityTypes` key. * * @platform darwin */ on(event: 'continue-activity', listener: (event: Event, /** * A string identifying the activity. Maps to `NSUserActivity.activityType`. */ type: string, /** * Contains app-specific state stored by the activity on another device. */ userInfo: unknown, details: ContinueActivityDetails) => void): this; once(event: 'continue-activity', listener: (event: Event, /** * A string identifying the activity. Maps to `NSUserActivity.activityType`. */ type: string, /** * Contains app-specific state stored by the activity on another device. */ userInfo: unknown, details: ContinueActivityDetails) => void): this; addListener(event: 'continue-activity', listener: (event: Event, /** * A string identifying the activity. Maps to `NSUserActivity.activityType`. */ type: string, /** * Contains app-specific state stored by the activity on another device. */ userInfo: unknown, details: ContinueActivityDetails) => void): this; removeListener(event: 'continue-activity', listener: (event: Event, /** * A string identifying the activity. Maps to `NSUserActivity.activityType`. */ type: string, /** * Contains app-specific state stored by the activity on another device. */ userInfo: unknown, details: ContinueActivityDetails) => void): this; /** * Emitted during Handoff when an activity from a different device fails to be * resumed. * * @platform darwin */ on(event: 'continue-activity-error', listener: (event: Event, /** * A string identifying the activity. Maps to `NSUserActivity.activityType`. */ type: string, /** * A string with the error's localized description. */ error: string) => void): this; once(event: 'continue-activity-error', listener: (event: Event, /** * A string identifying the activity. Maps to `NSUserActivity.activityType`. */ type: string, /** * A string with the error's localized description. */ error: string) => void): this; addListener(event: 'continue-activity-error', listener: (event: Event, /** * A string identifying the activity. Maps to `NSUserActivity.activityType`. */ type: string, /** * A string with the error's localized description. */ error: string) => void): this; removeListener(event: 'continue-activity-error', listener: (event: Event, /** * A string identifying the activity. Maps to `NSUserActivity.activityType`. */ type: string, /** * A string with the error's localized description. */ error: string) => void): this; /** * Emitted when mac application become active. Difference from `activate` event is * that `did-become-active` is emitted every time the app becomes active, not only * when Dock icon is clicked or application is re-launched. * * @platform darwin */ on(event: 'did-become-active', listener: (event: Event) => void): this; once(event: 'did-become-active', listener: (event: Event) => void): this; addListener(event: 'did-become-active', listener: (event: Event) => void): this; removeListener(event: 'did-become-active', listener: (event: Event) => void): this; /** * Emitted whenever there is a GPU info update. */ on(event: 'gpu-info-update', listener: Function): this; once(event: 'gpu-info-update', listener: Function): this; addListener(event: 'gpu-info-update', listener: Function): this; removeListener(event: 'gpu-info-update', listener: Function): this; /** * Emitted when the GPU process crashes or is killed. * * **Deprecated:** This event is superceded by the `child-process-gone` event which * contains more information about why the child process disappeared. It isn't * always because it crashed. The `killed` boolean can be replaced by checking * `reason === 'killed'` when you switch to that event. * * @deprecated */ on(event: 'gpu-process-crashed', listener: (event: Event, killed: boolean) => void): this; once(event: 'gpu-process-crashed', listener: (event: Event, killed: boolean) => void): this; addListener(event: 'gpu-process-crashed', listener: (event: Event, killed: boolean) => void): this; removeListener(event: 'gpu-process-crashed', listener: (event: Event, killed: boolean) => 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. * * If `callback` is called without a username or password, the authentication * request will be cancelled and the authentication error will be returned to the * page. */ on(event: 'login', listener: (event: Event, webContents: WebContents, authenticationResponseDetails: AuthenticationResponseDetails, authInfo: AuthInfo, callback: (username?: string, password?: string) => void) => void): this; once(event: 'login', listener: (event: Event, webContents: WebContents, authenticationResponseDetails: AuthenticationResponseDetails, authInfo: AuthInfo, callback: (username?: string, password?: string) => void) => void): this; addListener(event: 'login', listener: (event: Event, webContents: WebContents, authenticationResponseDetails: AuthenticationResponseDetails, authInfo: AuthInfo, callback: (username?: string, password?: string) => void) => void): this; removeListener(event: 'login', listener: (event: Event, webContents: WebContents, authenticationResponseDetails: AuthenticationResponseDetails, authInfo: AuthInfo, callback: (username?: string, password?: string) => void) => void): this; /** * Emitted when the user clicks the native macOS new tab button. The new tab button * is only visible if the current `BrowserWindow` has a `tabbingIdentifier` * * @platform darwin */ on(event: 'new-window-for-tab', listener: (event: Event) => void): this; once(event: 'new-window-for-tab', listener: (event: Event) => void): this; addListener(event: 'new-window-for-tab', listener: (event: Event) => void): this; removeListener(event: 'new-window-for-tab', listener: (event: Event) => void): this; /** * Emitted when the user wants to open a file with the application. The `open-file` * 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. * * On Windows, you have to parse `process.argv` (in the main process) to get the * filepath. * * @platform darwin */ on(event: 'open-file', listener: (event: Event, path: string) => void): this; once(event: 'open-file', listener: (event: Event, path: string) => void): this; addListener(event: 'open-file', listener: (event: Event, path: string) => void): this; removeListener(event: 'open-file', listener: (event: Event, path: string) => void): this; /** * Emitted when the user wants to open a URL with the application. Your * application's `Info.plist` file must define the URL scheme within the * `CFBundleURLTypes` key, and set `NSPrincipalClass` to `AtomApplication`. * * You should call `event.preventDefault()` if you want to handle this event. * * @platform darwin */ on(event: 'open-url', listener: (event: Event, url: string) => void): this; once(event: 'open-url', listener: (event: Event, url: string) => void): this; addListener(event: 'open-url', listener: (event: Event, url: string) => void): this; removeListener(event: 'open-url', listener: (event: Event, url: string) => void): this; /** * Emitted when the application is quitting. * * **Note:** On Windows, this event will not be emitted if the app is closed due to * a shutdown/restart of the system or a user logout. */ on(event: 'quit', listener: (event: Event, exitCode: number) => void): this; once(event: 'quit', listener: (event: Event, exitCode: number) => void): this; addListener(event: 'quit', listener: (event: Event, exitCode: number) => void): this; removeListener(event: 'quit', listener: (event: Event, exitCode: number) => void): this; /** * Emitted once, when Electron has finished initializing. On macOS, `launchInfo` * holds the `userInfo` of the `NSUserNotification` or information from * `UNNotificationResponse` that was used to open the application, if it was * launched from Notification Center. You can also call `app.isReady()` to check if * this event has already fired and `app.whenReady()` to get a Promise that is * fulfilled when Electron is initialized. */ on(event: 'ready', listener: (event: Event, launchInfo: (Record) | (NotificationResponse)) => void): this; once(event: 'ready', listener: (event: Event, launchInfo: (Record) | (NotificationResponse)) => void): this; addListener(event: 'ready', listener: (event: Event, launchInfo: (Record) | (NotificationResponse)) => void): this; removeListener(event: 'ready', listener: (event: Event, launchInfo: (Record) | (NotificationResponse)) => void): this; /** * Emitted when the renderer process unexpectedly disappears. This is normally * because it was crashed or killed. */ on(event: 'render-process-gone', listener: (event: Event, webContents: WebContents, details: RenderProcessGoneDetails) => void): this; once(event: 'render-process-gone', listener: (event: Event, webContents: WebContents, details: RenderProcessGoneDetails) => void): this; addListener(event: 'render-process-gone', listener: (event: Event, webContents: WebContents, details: RenderProcessGoneDetails) => void): this; removeListener(event: 'render-process-gone', listener: (event: Event, webContents: WebContents, details: RenderProcessGoneDetails) => void): this; /** * Emitted when the renderer process of `webContents` crashes or is killed. * * **Deprecated:** This event is superceded by the `render-process-gone` event * which contains more information about why the render process disappeared. It * isn't always because it crashed. The `killed` boolean can be replaced by * checking `reason === 'killed'` when you switch to that event. * * @deprecated */ on(event: 'renderer-process-crashed', listener: (event: Event, webContents: WebContents, killed: boolean) => void): this; once(event: 'renderer-process-crashed', listener: (event: Event, webContents: WebContents, killed: boolean) => void): this; addListener(event: 'renderer-process-crashed', listener: (event: Event, webContents: WebContents, killed: boolean) => void): this; removeListener(event: 'renderer-process-crashed', listener: (event: Event, webContents: WebContents, killed: boolean) => void): this; /** * This event will be emitted inside the primary instance of your application when * a second instance has been executed and calls `app.requestSingleInstanceLock()`. * * `argv` is an Array of the second instance's command line arguments, and * `workingDirectory` is its current working directory. Usually applications * respond to this by making their primary window focused and non-minimized. * * **Note:** If the second instance is started by a different user than the first, * the `argv` array will not include the arguments. * * This event is guaranteed to be emitted after the `ready` event of `app` gets * emitted. * * **Note:** Extra command line arguments might be added by Chromium, such as * `--original-process-start-time`. */ on(event: 'second-instance', listener: (event: Event, /** * An array of the second instance's command line arguments */ argv: string[], /** * The second instance's working directory */ workingDirectory: string, /** * A JSON object of additional data passed from the second instance */ additionalData: unknown) => void): this; once(event: 'second-instance', listener: (event: Event, /** * An array of the second instance's command line arguments */ argv: string[], /** * The second instance's working directory */ workingDirectory: string, /** * A JSON object of additional data passed from the second instance */ additionalData: unknown) => void): this; addListener(event: 'second-instance', listener: (event: Event, /** * An array of the second instance's command line arguments */ argv: string[], /** * The second instance's working directory */ workingDirectory: string, /** * A JSON object of additional data passed from the second instance */ additionalData: unknown) => void): this; removeListener(event: 'second-instance', listener: (event: Event, /** * An array of the second instance's command line arguments */ argv: string[], /** * The second instance's working directory */ workingDirectory: string, /** * A JSON object of additional data passed from the second instance */ additionalData: unknown) => void): this; /** * Emitted when a client certificate is requested. * * The `url` corresponds to the navigation entry requesting the client certificate * and `callback` can 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; once(event: 'select-client-certificate', listener: (event: Event, webContents: WebContents, url: string, certificateList: Certificate[], callback: (certificate?: Certificate) => void) => void): this; addListener(event: 'select-client-certificate', listener: (event: Event, webContents: WebContents, url: string, certificateList: Certificate[], callback: (certificate?: Certificate) => void) => void): this; removeListener(event: 'select-client-certificate', listener: (event: Event, webContents: WebContents, url: string, certificateList: Certificate[], callback: (certificate?: Certificate) => void) => void): this; /** * Emitted when Electron has created a new `session`. */ on(event: 'session-created', listener: (session: Session) => void): this; once(event: 'session-created', listener: (session: Session) => void): this; addListener(event: 'session-created', listener: (session: Session) => void): this; removeListener(event: 'session-created', listener: (session: Session) => void): this; /** * Emitted when Handoff is about to be resumed on another device. If you need to * update the state to be transferred, you should call `event.preventDefault()` * immediately, construct a new `userInfo` dictionary and call * `app.updateCurrentActivity()` in a timely manner. Otherwise, the operation will * fail and `continue-activity-error` will be called. * * @platform darwin */ on(event: 'update-activity-state', listener: (event: Event, /** * A string identifying the activity. Maps to `NSUserActivity.activityType`. */ type: string, /** * Contains app-specific state stored by the activity. */ userInfo: unknown) => void): this; once(event: 'update-activity-state', listener: (event: Event, /** * A string identifying the activity. Maps to `NSUserActivity.activityType`. */ type: string, /** * Contains app-specific state stored by the activity. */ userInfo: unknown) => void): this; addListener(event: 'update-activity-state', listener: (event: Event, /** * A string identifying the activity. Maps to `NSUserActivity.activityType`. */ type: string, /** * Contains app-specific state stored by the activity. */ userInfo: unknown) => void): this; removeListener(event: 'update-activity-state', listener: (event: Event, /** * A string identifying the activity. Maps to `NSUserActivity.activityType`. */ type: string, /** * Contains app-specific state stored by the activity. */ userInfo: unknown) => void): this; /** * Emitted when a new webContents is created. */ on(event: 'web-contents-created', listener: (event: Event, webContents: WebContents) => void): this; once(event: 'web-contents-created', listener: (event: Event, webContents: WebContents) => void): this; addListener(event: 'web-contents-created', listener: (event: Event, webContents: WebContents) => void): this; removeListener(event: 'web-contents-created', listener: (event: Event, webContents: WebContents) => void): this; /** * Emitted during Handoff before an activity from a different device wants to be * resumed. You should call `event.preventDefault()` if you want to handle this * event. * * @platform darwin */ on(event: 'will-continue-activity', listener: (event: Event, /** * A string identifying the activity. Maps to `NSUserActivity.activityType`. */ type: string) => void): this; once(event: 'will-continue-activity', listener: (event: Event, /** * A string identifying the activity. Maps to `NSUserActivity.activityType`. */ type: string) => void): this; addListener(event: 'will-continue-activity', listener: (event: Event, /** * A string identifying the activity. Maps to `NSUserActivity.activityType`. */ type: string) => void): this; removeListener(event: 'will-continue-activity', listener: (event: Event, /** * A string identifying the activity. Maps to `NSUserActivity.activityType`. */ type: string) => void): this; /** * 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 do everything in the `ready` event handler. */ on(event: 'will-finish-launching', listener: Function): this; once(event: 'will-finish-launching', listener: Function): this; addListener(event: 'will-finish-launching', listener: Function): this; removeListener(event: 'will-finish-launching', listener: Function): this; /** * Emitted when all windows have been closed and the application will quit. Calling * `event.preventDefault()` will prevent the default behavior, which is terminating * the application. * * See the description of the `window-all-closed` event for the differences between * the `will-quit` and `window-all-closed` events. * * **Note:** On Windows, this event will not be emitted if the app is closed due to * a shutdown/restart of the system or a user logout. */ on(event: 'will-quit', listener: (event: Event) => void): this; once(event: 'will-quit', listener: (event: Event) => void): this; addListener(event: 'will-quit', listener: (event: Event) => void): this; removeListener(event: 'will-quit', listener: (event: Event) => void): this; /** * 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. */ on(event: 'window-all-closed', listener: Function): this; once(event: 'window-all-closed', listener: Function): this; addListener(event: 'window-all-closed', listener: Function): this; removeListener(event: 'window-all-closed', listener: Function): this; /** * Adds `path` to the recent documents list. * * This list is managed by the OS. On Windows, you can visit the list from the task * bar, and on macOS, you can visit it from dock menu. * * @platform darwin,win32 */ addRecentDocument(path: string): void; /** * Clears the recent documents list. * * @platform darwin,win32 */ clearRecentDocuments(): void; /** * Configures host resolution (DNS and DNS-over-HTTPS). By default, the following * resolvers will be used, in order: * * * DNS-over-HTTPS, if the DNS provider supports it, then * * the built-in resolver (enabled on macOS only by default), then * * the system's resolver (e.g. `getaddrinfo`). * * This can be configured to either restrict usage of non-encrypted DNS * (`secureDnsMode: "secure"`), or disable DNS-over-HTTPS (`secureDnsMode: "off"`). * It is also possible to enable or disable the built-in resolver. * * To disable insecure DNS, you can specify a `secureDnsMode` of `"secure"`. If you * do so, you should make sure to provide a list of DNS-over-HTTPS servers to use, * in case the user's DNS configuration does not include a provider that supports * DoH. * * This API must be called after the `ready` event is emitted. */ configureHostResolver(options: ConfigureHostResolverOptions): void; /** * By default, Chromium disables 3D APIs (e.g. WebGL) until restart on a per domain * basis if the GPU processes crashes too frequently. This function disables that * behavior. * * This method can only be called before app is ready. */ disableDomainBlockingFor3DAPIs(): void; /** * Disables hardware acceleration for current app. * * This method can only be called before app is ready. */ disableHardwareAcceleration(): void; /** * Enables full sandbox mode on the app. This means that all renderers will be * launched sandboxed, regardless of the value of the `sandbox` flag in * WebPreferences. * * This method can only be called before app is ready. */ enableSandbox(): void; /** * Exits immediately with `exitCode`. `exitCode` defaults to 0. * * All windows will be closed immediately without asking the user, and the * `before-quit` and `will-quit` events will not be emitted. */ exit(exitCode?: number): void; /** * 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. * * You should seek to use the `steal` option as sparingly as possible. */ focus(options?: FocusOptions): void; /** * Resolve with an object containing the following: * * * `icon` NativeImage - the display icon of the app handling the protocol. * * `path` string - installation path of the app handling the protocol. * * `name` string - display name of the app handling the protocol. * * This method returns a promise that contains the application name, icon and path * of the default handler for the protocol (aka URI scheme) of a URL. * * @platform darwin,win32 */ getApplicationInfoForProtocol(url: string): Promise; /** * Name of the application handling the protocol, or an empty string if there is no * handler. For instance, if Electron is the default handler of the URL, this could * be `Electron` on Windows and Mac. However, don't rely on the precise format * which is not guaranteed to remain unchanged. Expect a different format on Linux, * possibly with a `.desktop` suffix. * * This method returns the application name of the default handler for the protocol * (aka URI scheme) of a URL. */ getApplicationNameForProtocol(url: string): string; /** * Array of `ProcessMetric` objects that correspond to memory and CPU usage * statistics of all the processes associated with the app. */ getAppMetrics(): ProcessMetric[]; /** * The current application directory. */ getAppPath(): string; /** * The current value displayed in the counter badge. * * @platform linux,darwin */ getBadgeCount(): number; /** * The type of the currently running activity. * * @platform darwin */ getCurrentActivityType(): string; /** * fulfilled with the app's icon, which is a NativeImage. * * Fetches a path's associated icon. * * On _Windows_, there a 2 kinds of icons: * * * Icons associated with certain file extensions, like `.mp3`, `.png`, etc. * * Icons inside the file itself, like `.exe`, `.dll`, `.ico`. * * On _Linux_ and _macOS_, icons depend on the application associated with file * mime type. */ getFileIcon(path: string, options?: FileIconOptions): Promise; /** * The Graphics Feature Status from `chrome://gpu/`. * * **Note:** This information is only usable after the `gpu-info-update` event is * emitted. */ getGPUFeatureStatus(): GPUFeatureStatus; /** * For `infoType` equal to `complete`: Promise is fulfilled with `Object` * containing all the GPU Information as in chromium's GPUInfo object. This * includes the version and driver information that's shown on `chrome://gpu` page. * * For `infoType` equal to `basic`: Promise is fulfilled with `Object` containing * fewer attributes than when requested with `complete`. Here's an example of basic * response: * * Using `basic` should be preferred if only basic information like `vendorId` or * `driverId` is needed. */ getGPUInfo(infoType: 'basic' | 'complete'): Promise; /** * * `minItems` Integer - The minimum number of items that will be shown in the * Jump List (for a more detailed description of this value see the MSDN docs). * * `removedItems` JumpListItem[] - Array of `JumpListItem` objects that * correspond to items that the user has explicitly removed from custom categories * in the Jump List. These items must not be re-added to the Jump List in the * **next** call to `app.setJumpList()`, Windows will not display any custom * category that contains any of the removed items. * * @platform win32 */ getJumpListSettings(): JumpListSettings; /** * The current application locale, fetched using Chromium's `l10n_util` library. * Possible return values are documented here. * * To set the locale, you'll want to use a command line switch at app startup, * which may be found here. * * **Note:** When distributing your packaged app, you have to also ship the * `locales` folder. * * **Note:** On Windows, you have to call it after the `ready` events gets emitted. */ getLocale(): string; /** * User operating system's locale two-letter ISO 3166 country code. The value is * taken from native OS APIs. * * **Note:** When unable to detect locale country code, it returns empty string. */ getLocaleCountryCode(): string; /** * If you provided `path` and `args` options to `app.setLoginItemSettings`, then * you need to pass the same arguments here for `openAtLogin` to be set correctly. * * * * `openAtLogin` boolean - `true` if the app is set to open at login. * * `openAsHidden` boolean _macOS_ - `true` if the app is set to open as hidden at * login. This setting is not available on MAS builds. * * `wasOpenedAtLogin` boolean _macOS_ - `true` if the app was opened at login * automatically. This setting is not available on MAS builds. * * `wasOpenedAsHidden` boolean _macOS_ - `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 not available on MAS builds. * * `restoreState` boolean _macOS_ - `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 not available on MAS builds. * * `executableWillLaunchAtLogin` boolean _Windows_ - `true` if app is set to open * at login and its run key is not deactivated. This differs from `openAtLogin` as * it ignores the `args` option, this property will be true if the given executable * would be launched at login with **any** arguments. * * `launchItems` Object[] _Windows_ * * `name` string _Windows_ - name value of a registry entry. * * `path` string _Windows_ - The executable to an app that corresponds to a * registry entry. * * `args` string[] _Windows_ - the command-line arguments to pass to the * executable. * * `scope` string _Windows_ - one of `user` or `machine`. Indicates whether the * registry entry is under `HKEY_CURRENT USER` or `HKEY_LOCAL_MACHINE`. * * `enabled` boolean _Windows_ - `true` if the app registry key is startup * approved and therefore shows as `enabled` in Task Manager and Windows settings. * * @platform darwin,win32 */ getLoginItemSettings(options?: LoginItemSettingsOptions): LoginItemSettings; /** * The current application's name, which is the name in the application's * `package.json` file. * * Usually the `name` field of `package.json` is a short lowercase name, according * to the npm modules spec. You should usually also specify a `productName` field, * which is your application's full capitalized name, and which will be preferred * over `name` by Electron. */ getName(): string; /** * A path to a special directory or file associated with `name`. On failure, an * `Error` is thrown. * * If `app.getPath('logs')` is called without called `app.setAppLogsPath()` being * called first, a default log directory will be created equivalent to calling * `app.setAppLogsPath()` without a `path` parameter. */ getPath(name: 'home' | 'appData' | 'userData' | 'sessionData' | 'temp' | 'exe' | 'module' | 'desktop' | 'documents' | 'downloads' | 'music' | 'pictures' | 'videos' | 'recent' | 'logs' | 'crashDumps'): string; /** * The version of the loaded application. If no version is found in the * application's `package.json` file, the version of the current bundle or * executable is returned. */ getVersion(): string; /** * This method returns whether or not this instance of your app is currently * holding the single instance lock. You can request the lock with * `app.requestSingleInstanceLock()` and release with * `app.releaseSingleInstanceLock()` */ hasSingleInstanceLock(): boolean; /** * Hides all application windows without minimizing them. * * @platform darwin */ hide(): void; /** * Imports the certificate in pkcs12 format into the platform certificate store. * `callback` is 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. * * @platform linux */ importCertificate(options: ImportCertificateOptions, callback: (result: number) => void): void; /** * Invalidates the current Handoff user activity. * * @platform darwin */ invalidateCurrentActivity(): void; /** * `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. * * @platform darwin,win32 */ isAccessibilitySupportEnabled(): boolean; /** * Whether the current executable is the default handler for a protocol (aka URI * scheme). * * **Note:** On macOS, you can use this method to check if the app has been * registered as the default protocol handler for a protocol. You can also verify * this by checking `~/Library/Preferences/com.apple.LaunchServices.plist` on the * macOS machine. Please refer to Apple's documentation for details. * * The API uses the Windows Registry and `LSCopyDefaultHandlerForURLScheme` * internally. */ isDefaultProtocolClient(protocol: string, path?: string, args?: string[]): boolean; /** * whether or not the current OS version allows for native emoji pickers. */ isEmojiPanelSupported(): boolean; /** * `true` if the application—including all of its windows—is hidden (e.g. with * `Command-H`), `false` otherwise. * * @platform darwin */ isHidden(): boolean; /** * Whether the application is currently running from the systems Application * folder. Use in combination with `app.moveToApplicationsFolder()` * * @platform darwin */ isInApplicationsFolder(): boolean; /** * `true` if Electron has finished initializing, `false` otherwise. See also * `app.whenReady()`. */ isReady(): boolean; /** * whether `Secure Keyboard Entry` is enabled. * * By default this API will return `false`. * * @platform darwin */ isSecureKeyboardEntryEnabled(): boolean; /** * Whether the current desktop environment is Unity launcher. * * @platform linux */ isUnityRunning(): boolean; /** * Whether the move was successful. Please note that if the move is successful, * your application will quit and relaunch. * * No confirmation dialog will be presented by default. If you wish to allow the * user to confirm the operation, you may do so using the `dialog` API. * * **NOTE:** This method throws errors if anything other than the user causes the * move to fail. For instance if the user cancels the authorization dialog, this * method returns false. If we fail to perform the copy, then this method will * throw an error. The message in the error should be informative and tell you * exactly what went wrong. * * By default, if an app of the same name as the one being moved exists in the * Applications directory and is _not_ running, the existing app will be trashed * and the active app moved into its place. If it _is_ running, the pre-existing * running app will assume focus and the previously active app will quit itself. * This behavior can be changed by providing the optional conflict handler, where * the boolean returned by the handler determines whether or not the move conflict * is resolved with default behavior. i.e. returning `false` will ensure no * further action is taken, returning `true` will result in the default behavior * and the method continuing. * * For example: * * Would mean that if an app already exists in the user directory, if the user * chooses to 'Continue Move' then the function would continue with its default * behavior and the existing app will be trashed and the active app moved into its * place. * * @platform darwin */ moveToApplicationsFolder(options?: MoveToApplicationsFolderOptions): boolean; /** * Try to close all windows. The `before-quit` event will be emitted first. If all * windows are successfully closed, the `will-quit` event will be emitted and by * default the application will terminate. * * This method guarantees that all `beforeunload` and `unload` event handlers are * correctly executed. It is possible that a window cancels the quitting by * returning `false` in the `beforeunload` event handler. */ quit(): void; /** * 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. * * An example of restarting current instance immediately and adding a new command * line argument to the new instance: */ relaunch(options?: RelaunchOptions): void; /** * Releases all locks that were created by `requestSingleInstanceLock`. This will * allow multiple instances of the application to once again run side by side. */ releaseSingleInstanceLock(): void; /** * Whether the call succeeded. * * This method checks if the current executable as the default handler for a * protocol (aka URI scheme). If so, it will remove the app as the default handler. * * @platform darwin,win32 */ removeAsDefaultProtocolClient(protocol: string, path?: string, args?: string[]): boolean; /** * The return value of this method indicates whether or not this instance of your * application successfully obtained the lock. If it failed to obtain the lock, * you can assume that another instance of your application is already running with * the lock and exit immediately. * * I.e. This method returns `true` if your process is the primary instance of your * application and your app should continue loading. It returns `false` if your * process should immediately quit as it has sent its parameters to another * instance that has already acquired the lock. * * On macOS, the system enforces single instance automatically when users try to * open a second instance of your app in Finder, and the `open-file` and `open-url` * events will be emitted for that. However when users start your app in command * line, the system's single instance mechanism will be bypassed, and you have to * use this method to ensure single instance. * * An example of activating the window of primary instance when a second instance * starts: */ requestSingleInstanceLock(additionalData?: Record): boolean; /** * Marks the current Handoff user activity as inactive without invalidating it. * * @platform darwin */ resignCurrentActivity(): void; /** * Set the about panel options. This will override the values defined in the app's * `.plist` file on macOS. See the Apple docs for more details. On Linux, values * must be set in order to be shown; there are no defaults. * * If you do not set `credits` but still wish to surface them in your app, AppKit * will look for a file named "Credits.html", "Credits.rtf", and "Credits.rtfd", in * that order, in the bundle returned by the NSBundle class method main. The first * file found is used, and if none is found, the info area is left blank. See Apple * documentation for more information. */ setAboutPanelOptions(options: AboutPanelOptionsOptions): void; /** * Manually enables Chrome's accessibility support, allowing to expose * accessibility switch to users in application settings. See Chromium's * accessibility docs for more details. Disabled by default. * * This API must be called after the `ready` event is emitted. * * **Note:** Rendering accessibility tree can significantly affect the performance * of your app. It should not be enabled by default. * * @platform darwin,win32 */ setAccessibilitySupportEnabled(enabled: boolean): void; /** * Sets the activation policy for a given app. * * Activation policy types: * * * 'regular' - The application is an ordinary app that appears in the Dock and * may have a user interface. * * 'accessory' - The application doesn’t appear in the Dock and doesn’t have a * menu bar, but it may be activated programmatically or by clicking on one of its * windows. * * 'prohibited' - The application doesn’t appear in the Dock and may not create * windows or be activated. * * @platform darwin */ setActivationPolicy(policy: 'regular' | 'accessory' | 'prohibited'): void; /** * Sets or creates a directory your app's logs which can then be manipulated with * `app.getPath()` or `app.setPath(pathName, newPath)`. * * Calling `app.setAppLogsPath()` without a `path` parameter will result in this * directory being set to `~/Library/Logs/YourAppName` on _macOS_, and inside the * `userData` directory on _Linux_ and _Windows_. */ setAppLogsPath(path?: string): void; /** * Changes the Application User Model ID to `id`. * * @platform win32 */ setAppUserModelId(id: string): void; /** * Whether the call succeeded. * * Sets the current executable as the default handler for a protocol (aka URI * scheme). It allows you to integrate your app deeper into the operating system. * 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. * * **Note:** On macOS, you can only register protocols that have been added to your * app's `info.plist`, which cannot be modified at runtime. However, you can change * the file during build time via Electron Forge, Electron Packager, or by editing * `info.plist` with a text editor. Please refer to Apple's documentation for * details. * * **Note:** In a Windows Store environment (when packaged as an `appx`) this API * will return `true` for all calls but the registry key it sets won't be * accessible by other applications. In order to register your Windows Store * application as a default protocol handler you must declare the protocol in your * manifest. * * The API uses the Windows Registry and `LSSetDefaultHandlerForURLScheme` * internally. */ setAsDefaultProtocolClient(protocol: string, path?: string, args?: string[]): boolean; /** * Whether the call succeeded. * * Sets the counter badge for current app. Setting the count to `0` will hide the * badge. * * On macOS, it shows on the dock icon. On Linux, it only works for Unity launcher. * * **Note:** Unity launcher requires a `.desktop` file to work. For more * information, please read the Unity integration documentation. * * @platform linux,darwin */ setBadgeCount(count?: number): boolean; /** * Sets or removes a custom Jump List for the application, and returns one of the * following strings: * * * `ok` - Nothing went wrong. * * `error` - One or more errors occurred, 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. * * 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:** If a `JumpListCategory` object has neither the `type` nor the `name` * property set then its `type` is assumed to be `tasks`. If the `name` property is * set but the `type` property is omitted then the `type` is assumed to be * `custom`. * * **Note:** Users can remove items from custom categories, and Windows will not * allow a removed item to be added back into a custom category until **after** the * next successful call to `app.setJumpList(categories)`. Any attempt to re-add a * removed item to a custom category earlier than that will result in the entire * custom category being omitted from the Jump List. The list of removed items can * be obtained using `app.getJumpListSettings()`. * * **Note:** The maximum length of a Jump List item's `description` property is 260 * characters. Beyond this limit, the item will not be added to the Jump List, nor * will it be displayed. * * Here's a very simple example of creating a custom Jump List: * * @platform win32 */ setJumpList(categories: (JumpListCategory[]) | (null)): ('ok' | 'error' | 'invalidSeparatorError' | 'fileTypeRegistrationError' | 'customCategoryAccessDeniedError'); /** * To work with Electron's `autoUpdater` on Windows, which uses Squirrel, you'll * want to set the launch path to Update.exe, and pass arguments that specify your * application name. For example: * * @platform darwin,win32 */ setLoginItemSettings(settings: Settings): void; /** * Overrides the current application's name. * * **Note:** This function overrides the name used internally by Electron; it does * not affect the name that the OS uses. */ setName(name: string): void; /** * Overrides the `path` to a special directory or file associated with `name`. If * the path specifies a directory that does not exist, an `Error` is thrown. In * that case, the directory should be created with `fs.mkdirSync` or similar. * * You can only override paths of a `name` defined in `app.getPath`. * * By default, web pages' cookies and caches will be stored under the `sessionData` * directory. If you want to change this location, you have to override the * `sessionData` path before the `ready` event of the `app` module is emitted. */ setPath(name: string, path: string): void; /** * Set the `Secure Keyboard Entry` is enabled in your application. * * By using this API, important information such as password and other sensitive * information can be prevented from being intercepted by other processes. * * See Apple's documentation for more details. * * **Note:** Enable `Secure Keyboard Entry` only when it is needed and disable it * when it is no longer needed. * * @platform darwin */ setSecureKeyboardEntryEnabled(enabled: boolean): void; /** * Creates an `NSUserActivity` and sets it as the current activity. The activity is * eligible for Handoff to another device afterward. * * @platform darwin */ setUserActivity(type: string, userInfo: any, webpageURL?: string): void; /** * Adds `tasks` to the Tasks category of the Jump List on Windows. * * `tasks` is an array of `Task` objects. * * Whether the call succeeded. * * **Note:** If you'd like to customize the Jump List even more use * `app.setJumpList(categories)` instead. * * @platform win32 */ setUserTasks(tasks: Task[]): boolean; /** * Shows application windows after they were hidden. Does not automatically focus * them. * * @platform darwin */ show(): void; /** * Show the app's about panel options. These options can be overridden with * `app.setAboutPanelOptions(options)`. */ showAboutPanel(): void; /** * Show the platform's native emoji picker. * * @platform darwin,win32 */ showEmojiPanel(): void; /** * This function **must** be called once you have finished accessing the security * scoped file. If you do not remember to stop accessing the bookmark, kernel * resources will be leaked and your app will lose its ability to reach outside the * sandbox completely, until your app is restarted. * * Start accessing a security scoped resource. With this method Electron * applications that are packaged for the Mac App Store may reach outside their * sandbox to access files chosen by the user. See Apple's documentation for a * description of how this system works. * * @platform mas */ startAccessingSecurityScopedResource(bookmarkData: string): Function; /** * Updates the current activity if its type matches `type`, merging the entries * from `userInfo` into its current `userInfo` dictionary. * * @platform darwin */ updateCurrentActivity(type: string, userInfo: any): void; /** * fulfilled when Electron is initialized. May be used as a convenient alternative * to checking `app.isReady()` and subscribing to the `ready` event if the app is * not ready yet. */ whenReady(): Promise; /** * A `boolean` property that's `true` if Chrome's accessibility support is enabled, * `false` otherwise. This property will be `true` if the use of assistive * technologies, such as screen readers, has been detected. Setting this property * to `true` manually enables Chrome's accessibility support, allowing developers * to expose accessibility switch to users in application settings. * * See Chromium's accessibility docs for more details. Disabled by default. * * This API must be called after the `ready` event is emitted. * * **Note:** Rendering accessibility tree can significantly affect the performance * of your app. It should not be enabled by default. * * @platform darwin,win32 */ accessibilitySupportEnabled: boolean; /** * A `Menu | null` property that returns `Menu` if one has been set and `null` * otherwise. Users can pass a Menu to set this property. */ applicationMenu: (Menu) | (null); /** * An `Integer` property that returns the badge count for current app. Setting the * count to `0` will hide the badge. * * On macOS, setting this with any nonzero integer shows on the dock icon. On * Linux, this property only works for Unity launcher. * * **Note:** Unity launcher requires a `.desktop` file to work. For more * information, please read the Unity integration documentation. * * **Note:** On macOS, you need to ensure that your application has the permission * to display notifications for this property to take effect. * * @platform linux,darwin */ badgeCount: number; /** * A `CommandLine` object that allows you to read and manipulate the command line * arguments that Chromium uses. * */ readonly commandLine: CommandLine; /** * A `Dock` `| undefined` object that allows you to perform actions on your app * icon in the user's dock on macOS. * * @platform darwin */ readonly dock: Dock; /** * A `boolean` property that returns `true` if the app is packaged, `false` * otherwise. For many apps, this property can be used to distinguish development * and production environments. * */ readonly isPackaged: boolean; /** * A `string` property that indicates the current application's name, which is the * name in the application's `package.json` file. * * Usually the `name` field of `package.json` is a short lowercase name, according * to the npm modules spec. You should usually also specify a `productName` field, * which is your application's full capitalized name, and which will be preferred * over `name` by Electron. */ name: string; /** * A `boolean` which when `true` indicates that the app is currently running under * an ARM64 translator (like the macOS Rosetta Translator Environment or Windows * WOW). * * You can use this property to prompt users to download the arm64 version of your * application when they are running the x64 version under Rosetta incorrectly. * * @platform darwin,win32 */ readonly runningUnderARM64Translation: boolean; /** * A `boolean` which when `true` indicates that the app is currently running under * the Rosetta Translator Environment. * * You can use this property to prompt users to download the arm64 version of your * application when they are running the x64 version under Rosetta incorrectly. * * **Deprecated:** This property is superceded by the * `runningUnderARM64Translation` property which detects when the app is being * translated to ARM64 in both macOS and Windows. * * @deprecated * @platform darwin */ readonly runningUnderRosettaTranslation: boolean; /** * A `string` which is the user agent string Electron will use as a global * fallback. * * This is the user agent that will be used when no user agent is set at the * `webContents` or `session` level. It is useful for ensuring that your entire * app has the same user agent. Set to a custom value as early as possible in your * app's initialization to ensure that your overridden value is used. */ userAgentFallback: string; } interface AutoUpdater extends NodeJS.EventEmitter { // Docs: https://electronjs.org/docs/api/auto-updater /** * This event is emitted after a user calls `quitAndInstall()`. * * When this API is called, the `before-quit` event is not emitted before all * windows are closed. As a result you should listen to this event if you wish to * perform actions before the windows are closed while a process is quitting, as * well as listening to `before-quit`. */ on(event: 'before-quit-for-update', listener: Function): this; once(event: 'before-quit-for-update', listener: Function): this; addListener(event: 'before-quit-for-update', listener: Function): this; removeListener(event: 'before-quit-for-update', listener: Function): this; /** * Emitted when checking if an update has started. */ on(event: 'checking-for-update', listener: Function): this; once(event: 'checking-for-update', listener: Function): this; addListener(event: 'checking-for-update', listener: Function): this; removeListener(event: 'checking-for-update', listener: Function): this; /** * Emitted when there is an error while updating. */ on(event: 'error', listener: (error: Error) => void): this; once(event: 'error', listener: (error: Error) => void): this; addListener(event: 'error', listener: (error: Error) => void): this; removeListener(event: 'error', listener: (error: Error) => void): this; /** * Emitted when there is an available update. The update is downloaded * automatically. */ on(event: 'update-available', listener: Function): this; once(event: 'update-available', listener: Function): this; addListener(event: 'update-available', listener: Function): this; removeListener(event: 'update-available', listener: Function): this; /** * Emitted when an update has been downloaded. * * On Windows only `releaseName` is available. * * **Note:** It is not strictly necessary to handle this event. A successfully * downloaded update will still be applied the next time the application starts. */ on(event: 'update-downloaded', listener: (event: Event, releaseNotes: string, releaseName: string, releaseDate: Date, updateURL: string) => void): this; once(event: 'update-downloaded', listener: (event: Event, releaseNotes: string, releaseName: string, releaseDate: Date, updateURL: string) => void): this; addListener(event: 'update-downloaded', listener: (event: Event, releaseNotes: string, releaseName: string, releaseDate: Date, updateURL: string) => void): this; removeListener(event: 'update-downloaded', listener: (event: Event, releaseNotes: string, releaseName: string, releaseDate: Date, updateURL: string) => void): this; /** * Emitted when there is no available update. */ on(event: 'update-not-available', listener: Function): this; once(event: 'update-not-available', listener: Function): this; addListener(event: 'update-not-available', listener: Function): this; removeListener(event: 'update-not-available', listener: Function): this; /** * Asks the server whether there is an update. You must call `setFeedURL` before * using this API. * * **Note:** If an update is available it will be downloaded automatically. Calling * `autoUpdater.checkForUpdates()` twice will download the update two times. */ checkForUpdates(): void; /** * The current update feed URL. */ getFeedURL(): string; /** * Restarts the app and installs the update after it has been downloaded. It should * only be called after `update-downloaded` has been emitted. * * Under the hood calling `autoUpdater.quitAndInstall()` will close all application * windows first, and automatically call `app.quit()` after all windows have been * closed. * * **Note:** It is not strictly necessary to call this function to apply an update, * as a successfully downloaded update will always be applied the next time the * application starts. */ quitAndInstall(): void; /** * Sets the `url` and initialize the auto updater. */ setFeedURL(options: FeedURLOptions): void; } interface BluetoothDevice { // Docs: https://electronjs.org/docs/api/structures/bluetooth-device deviceId: string; deviceName: string; } class BrowserView { // Docs: https://electronjs.org/docs/api/browser-view /** * BrowserView */ constructor(options?: BrowserViewConstructorOptions); /** * The `bounds` of this BrowserView instance as `Object`. * * @experimental */ getBounds(): Rectangle; setAutoResize(options: AutoResizeOptions): void; /** * Examples of valid `color` values: * * * Hex * * #fff (RGB) * * #ffff (ARGB) * * #ffffff (RRGGBB) * * #ffffffff (AARRGGBB) * * RGB * * rgb(([\d]+),\s*([\d]+),\s*([\d]+)) * * e.g. rgb(255, 255, 255) * * RGBA * * rgba(([\d]+),\s*([\d]+),\s*([\d]+),\s*([\d.]+)) * * e.g. rgba(255, 255, 255, 1.0) * * HSL * * hsl((-?[\d.]+),\s*([\d.]+)%,\s*([\d.]+)%) * * e.g. hsl(200, 20%, 50%) * * HSLA * * hsla((-?[\d.]+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)) * * e.g. hsla(200, 20%, 50%, 0.5) * * Color name * * Options are listed in SkParseColor.cpp * * Similar to CSS Color Module Level 3 keywords, but case-sensitive. * * e.g. `blueviolet` or `red` * * **Note:** Hex format with alpha takes `AARRGGBB` or `ARGB`, _not_ `RRGGBBA` or * `RGA`. * * @experimental */ setBackgroundColor(color: string): void; /** * Resizes and moves the view to the supplied bounds relative to the window. * * @experimental */ setBounds(bounds: Rectangle): void; /** * A `WebContents` object owned by this view. * * @experimental */ webContents: WebContents; } class BrowserWindow extends NodeEventEmitter { // Docs: https://electronjs.org/docs/api/browser-window /** * Emitted when the window is set or unset to show always on top of other windows. */ on(event: 'always-on-top-changed', listener: (event: Event, isAlwaysOnTop: boolean) => void): this; once(event: 'always-on-top-changed', listener: (event: Event, isAlwaysOnTop: boolean) => void): this; addListener(event: 'always-on-top-changed', listener: (event: Event, isAlwaysOnTop: boolean) => void): this; removeListener(event: 'always-on-top-changed', listener: (event: Event, isAlwaysOnTop: boolean) => void): this; /** * Emitted when an App Command is invoked. These are typically related to keyboard * media keys or browser commands, as well as the "Back" button built into some * mice on Windows. * * Commands are lowercased, underscores are replaced with hyphens, and the * `APPCOMMAND_` prefix is stripped off. e.g. `APPCOMMAND_BROWSER_BACKWARD` is * emitted as `browser-backward`. * * The following app commands are explicitly supported on Linux: * * * `browser-backward` * * `browser-forward` * * @platform win32,linux */ on(event: 'app-command', listener: (event: Event, command: string) => void): this; once(event: 'app-command', listener: (event: Event, command: string) => void): this; addListener(event: 'app-command', listener: (event: Event, command: string) => void): this; removeListener(event: 'app-command', listener: (event: Event, command: string) => void): this; /** * Emitted when the window loses focus. */ on(event: 'blur', listener: Function): this; once(event: 'blur', listener: Function): this; addListener(event: 'blur', listener: Function): this; removeListener(event: 'blur', listener: Function): this; /** * 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. * * Usually you would want to use the `beforeunload` handler to decide whether the * window should be closed, which will also be called when the window is reloaded. * In Electron, returning any value other than `undefined` would cancel the close. * For example: * * _**Note**: There is a subtle difference between the behaviors of * `window.onbeforeunload = handler` and `window.addEventListener('beforeunload', * handler)`. It is recommended to always set the `event.returnValue` explicitly, * instead of only returning a value, as the former works more consistently within * Electron._ */ on(event: 'close', listener: (event: Event) => void): this; once(event: 'close', listener: (event: Event) => void): this; addListener(event: 'close', listener: (event: Event) => void): this; removeListener(event: 'close', listener: (event: Event) => void): this; /** * Emitted when the window is closed. After you have received this event you should * remove the reference to the window and avoid using it any more. */ on(event: 'closed', listener: Function): this; once(event: 'closed', listener: Function): this; addListener(event: 'closed', listener: Function): this; removeListener(event: 'closed', listener: Function): this; /** * Emitted when the window enters a full-screen state. */ on(event: 'enter-full-screen', listener: Function): this; once(event: 'enter-full-screen', listener: Function): this; addListener(event: 'enter-full-screen', listener: Function): this; removeListener(event: 'enter-full-screen', listener: Function): this; /** * Emitted when the window enters a full-screen state triggered by HTML API. */ on(event: 'enter-html-full-screen', listener: Function): this; once(event: 'enter-html-full-screen', listener: Function): this; addListener(event: 'enter-html-full-screen', listener: Function): this; removeListener(event: 'enter-html-full-screen', listener: Function): this; /** * Emitted when the window gains focus. */ on(event: 'focus', listener: Function): this; once(event: 'focus', listener: Function): this; addListener(event: 'focus', listener: Function): this; removeListener(event: 'focus', listener: Function): this; /** * Emitted when the window is hidden. */ on(event: 'hide', listener: Function): this; once(event: 'hide', listener: Function): this; addListener(event: 'hide', listener: Function): this; removeListener(event: 'hide', listener: Function): this; /** * Emitted when the window leaves a full-screen state. */ on(event: 'leave-full-screen', listener: Function): this; once(event: 'leave-full-screen', listener: Function): this; addListener(event: 'leave-full-screen', listener: Function): this; removeListener(event: 'leave-full-screen', listener: Function): this; /** * Emitted when the window leaves a full-screen state triggered by HTML API. */ on(event: 'leave-html-full-screen', listener: Function): this; once(event: 'leave-html-full-screen', listener: Function): this; addListener(event: 'leave-html-full-screen', listener: Function): this; removeListener(event: 'leave-html-full-screen', listener: Function): this; /** * Emitted when window is maximized. */ on(event: 'maximize', listener: Function): this; once(event: 'maximize', listener: Function): this; addListener(event: 'maximize', listener: Function): this; removeListener(event: 'maximize', listener: Function): this; /** * Emitted when the window is minimized. */ on(event: 'minimize', listener: Function): this; once(event: 'minimize', listener: Function): this; addListener(event: 'minimize', listener: Function): this; removeListener(event: 'minimize', listener: Function): this; /** * Emitted when the window is being moved to a new position. */ on(event: 'move', listener: Function): this; once(event: 'move', listener: Function): this; addListener(event: 'move', listener: Function): this; removeListener(event: 'move', listener: Function): this; /** * Emitted once when the window is moved to a new position. * * __Note__: On macOS this event is an alias of `move`. * * @platform darwin,win32 */ on(event: 'moved', listener: Function): this; once(event: 'moved', listener: Function): this; addListener(event: 'moved', listener: Function): this; removeListener(event: 'moved', listener: Function): this; /** * Emitted when the native new tab button is clicked. * * @platform darwin */ on(event: 'new-window-for-tab', listener: Function): this; once(event: 'new-window-for-tab', listener: Function): this; addListener(event: 'new-window-for-tab', listener: Function): this; removeListener(event: 'new-window-for-tab', listener: Function): this; /** * Emitted when the document changed its title, calling `event.preventDefault()` * will prevent the native window's title from changing. `explicitSet` is false * when title is synthesized from file URL. */ on(event: 'page-title-updated', listener: (event: Event, title: string, explicitSet: boolean) => void): this; once(event: 'page-title-updated', listener: (event: Event, title: string, explicitSet: boolean) => void): this; addListener(event: 'page-title-updated', listener: (event: Event, title: string, explicitSet: boolean) => void): this; removeListener(event: 'page-title-updated', listener: (event: Event, title: string, explicitSet: boolean) => void): this; /** * Emitted when the web page has been rendered (while not being shown) and window * can be displayed without a visual flash. * * Please note that using this event implies that the renderer will be considered * "visible" and paint even though `show` is false. This event will never fire if * you use `paintWhenInitiallyHidden: false` */ on(event: 'ready-to-show', listener: Function): this; once(event: 'ready-to-show', listener: Function): this; addListener(event: 'ready-to-show', listener: Function): this; removeListener(event: 'ready-to-show', listener: Function): this; /** * Emitted after the window has been resized. */ on(event: 'resize', listener: Function): this; once(event: 'resize', listener: Function): this; addListener(event: 'resize', listener: Function): this; removeListener(event: 'resize', listener: Function): this; /** * Emitted once when the window has finished being resized. * * This is usually emitted when the window has been resized manually. On macOS, * resizing the window with `setBounds`/`setSize` and setting the `animate` * parameter to `true` will also emit this event once resizing has finished. * * @platform darwin,win32 */ on(event: 'resized', listener: Function): this; once(event: 'resized', listener: Function): this; addListener(event: 'resized', listener: Function): this; removeListener(event: 'resized', listener: Function): this; /** * Emitted when the unresponsive web page becomes responsive again. */ on(event: 'responsive', listener: Function): this; once(event: 'responsive', listener: Function): this; addListener(event: 'responsive', listener: Function): this; removeListener(event: 'responsive', listener: Function): this; /** * Emitted when the window is restored from a minimized state. */ on(event: 'restore', listener: Function): this; once(event: 'restore', listener: Function): this; addListener(event: 'restore', listener: Function): this; removeListener(event: 'restore', listener: Function): this; /** * Emitted on trackpad rotation gesture. Continually emitted until rotation gesture * is ended. The `rotation` value on each emission is the angle in degrees rotated * since the last emission. The last emitted event upon a rotation gesture will * always be of value `0`. Counter-clockwise rotation values are positive, while * clockwise ones are negative. * * @platform darwin */ on(event: 'rotate-gesture', listener: (event: Event, rotation: number) => void): this; once(event: 'rotate-gesture', listener: (event: Event, rotation: number) => void): this; addListener(event: 'rotate-gesture', listener: (event: Event, rotation: number) => void): this; removeListener(event: 'rotate-gesture', listener: (event: Event, rotation: number) => void): this; /** * Emitted when scroll wheel event phase has begun. * * @platform darwin */ on(event: 'scroll-touch-begin', listener: Function): this; once(event: 'scroll-touch-begin', listener: Function): this; addListener(event: 'scroll-touch-begin', listener: Function): this; removeListener(event: 'scroll-touch-begin', listener: Function): this; /** * Emitted when scroll wheel event phase filed upon reaching the edge of element. * * @platform darwin */ on(event: 'scroll-touch-edge', listener: Function): this; once(event: 'scroll-touch-edge', listener: Function): this; addListener(event: 'scroll-touch-edge', listener: Function): this; removeListener(event: 'scroll-touch-edge', listener: Function): this; /** * Emitted when scroll wheel event phase has ended. * * @platform darwin */ on(event: 'scroll-touch-end', listener: Function): this; once(event: 'scroll-touch-end', listener: Function): this; addListener(event: 'scroll-touch-end', listener: Function): this; removeListener(event: 'scroll-touch-end', listener: Function): this; /** * Emitted when window session is going to end due to force shutdown or machine * restart or session log off. * * @platform win32 */ on(event: 'session-end', listener: Function): this; once(event: 'session-end', listener: Function): this; addListener(event: 'session-end', listener: Function): this; removeListener(event: 'session-end', listener: Function): this; /** * Emitted when the window opens a sheet. * * @platform darwin */ on(event: 'sheet-begin', listener: Function): this; once(event: 'sheet-begin', listener: Function): this; addListener(event: 'sheet-begin', listener: Function): this; removeListener(event: 'sheet-begin', listener: Function): this; /** * Emitted when the window has closed a sheet. * * @platform darwin */ on(event: 'sheet-end', listener: Function): this; once(event: 'sheet-end', listener: Function): this; addListener(event: 'sheet-end', listener: Function): this; removeListener(event: 'sheet-end', listener: Function): this; /** * Emitted when the window is shown. */ on(event: 'show', listener: Function): this; once(event: 'show', listener: Function): this; addListener(event: 'show', listener: Function): this; removeListener(event: 'show', listener: Function): this; /** * Emitted on 3-finger swipe. Possible directions are `up`, `right`, `down`, * `left`. * * The method underlying this event is built to handle older macOS-style trackpad * swiping, where the content on the screen doesn't move with the swipe. Most macOS * trackpads are not configured to allow this kind of swiping anymore, so in order * for it to emit properly the 'Swipe between pages' preference in `System * Preferences > Trackpad > More Gestures` must be set to 'Swipe with two or three * fingers'. * * @platform darwin */ on(event: 'swipe', listener: (event: Event, direction: string) => void): this; once(event: 'swipe', listener: (event: Event, direction: string) => void): this; addListener(event: 'swipe', listener: (event: Event, direction: string) => void): this; removeListener(event: 'swipe', listener: (event: Event, direction: string) => void): this; /** * Emitted when the system context menu is triggered on the window, this is * normally only triggered when the user right clicks on the non-client area of * your window. This is the window titlebar or any area you have declared as * `-webkit-app-region: drag` in a frameless window. * * Calling `event.preventDefault()` will prevent the menu from being displayed. * * @platform win32 */ on(event: 'system-context-menu', listener: (event: Event, /** * The screen coordinates the context menu was triggered at */ point: Point) => void): this; once(event: 'system-context-menu', listener: (event: Event, /** * The screen coordinates the context menu was triggered at */ point: Point) => void): this; addListener(event: 'system-context-menu', listener: (event: Event, /** * The screen coordinates the context menu was triggered at */ point: Point) => void): this; removeListener(event: 'system-context-menu', listener: (event: Event, /** * The screen coordinates the context menu was triggered at */ point: Point) => void): this; /** * Emitted when the window exits from a maximized state. */ on(event: 'unmaximize', listener: Function): this; once(event: 'unmaximize', listener: Function): this; addListener(event: 'unmaximize', listener: Function): this; removeListener(event: 'unmaximize', listener: Function): this; /** * Emitted when the web page becomes unresponsive. */ on(event: 'unresponsive', listener: Function): this; once(event: 'unresponsive', listener: Function): this; addListener(event: 'unresponsive', listener: Function): this; removeListener(event: 'unresponsive', listener: Function): this; /** * Emitted before the window is moved. On Windows, calling `event.preventDefault()` * will prevent the window from being moved. * * Note that this is only emitted when the window is being moved manually. Moving * the window with `setPosition`/`setBounds`/`center` will not emit this event. * * @platform darwin,win32 */ on(event: 'will-move', listener: (event: Event, /** * Location the window is being moved to. */ newBounds: Rectangle) => void): this; once(event: 'will-move', listener: (event: Event, /** * Location the window is being moved to. */ newBounds: Rectangle) => void): this; addListener(event: 'will-move', listener: (event: Event, /** * Location the window is being moved to. */ newBounds: Rectangle) => void): this; removeListener(event: 'will-move', listener: (event: Event, /** * Location the window is being moved to. */ newBounds: Rectangle) => void): this; /** * Emitted before the window is resized. Calling `event.preventDefault()` will * prevent the window from being resized. * * Note that this is only emitted when the window is being resized manually. * Resizing the window with `setBounds`/`setSize` will not emit this event. * * The possible values and behaviors of the `edge` option are platform dependent. * Possible values are: * * * On Windows, possible values are `bottom`, `top`, `left`, `right`, `top-left`, * `top-right`, `bottom-left`, `bottom-right`. * * On macOS, possible values are `bottom` and `right`. * * The value `bottom` is used to denote vertical resizing. * * The value `right` is used to denote horizontal resizing. * * @platform darwin,win32 */ on(event: 'will-resize', listener: (event: Event, /** * Size the window is being resized to. */ newBounds: Rectangle, details: WillResizeDetails) => void): this; once(event: 'will-resize', listener: (event: Event, /** * Size the window is being resized to. */ newBounds: Rectangle, details: WillResizeDetails) => void): this; addListener(event: 'will-resize', listener: (event: Event, /** * Size the window is being resized to. */ newBounds: Rectangle, details: WillResizeDetails) => void): this; removeListener(event: 'will-resize', listener: (event: Event, /** * Size the window is being resized to. */ newBounds: Rectangle, details: WillResizeDetails) => void): this; /** * BrowserWindow */ constructor(options?: BrowserWindowConstructorOptions); /** * The window that owns the given `browserView`. If the given view is not attached * to any window, returns `null`. */ static fromBrowserView(browserView: BrowserView): (BrowserWindow) | (null); /** * The window with the given `id`. */ static fromId(id: number): (BrowserWindow) | (null); /** * The window that owns the given `webContents` or `null` if the contents are not * owned by a window. */ static fromWebContents(webContents: WebContents): (BrowserWindow) | (null); /** * An array of all opened browser windows. */ static getAllWindows(): BrowserWindow[]; /** * The window that is focused in this application, otherwise returns `null`. */ static getFocusedWindow(): (BrowserWindow) | (null); /** * Replacement API for setBrowserView supporting work with multi browser views. * * @experimental */ addBrowserView(browserView: BrowserView): void; /** * Adds a window as a tab on this window, after the tab for the window instance. * * @platform darwin */ addTabbedWindow(browserWindow: BrowserWindow): void; /** * Removes focus from the window. */ blur(): void; blurWebView(): void; /** * Resolves with a NativeImage * * Captures a snapshot of the page within `rect`. Omitting `rect` will capture the * whole visible page. If the page is not visible, `rect` may be empty. */ capturePage(rect?: Rectangle): Promise; /** * Moves window to the center of the screen. */ center(): void; /** * Try to close the window. This has the same effect as a user manually clicking * the close button of the window. The web page may cancel the close though. See * the close event. */ close(): void; /** * Closes the currently open Quick Look panel. * * @platform darwin */ closeFilePreview(): void; /** * Force closing the window, the `unload` and `beforeunload` event won't be emitted * for the web page, and `close` event will also not be emitted for this window, * but it guarantees the `closed` event will be emitted. */ destroy(): void; /** * Starts or stops flashing the window to attract user's attention. */ flashFrame(flag: boolean): void; /** * Focuses on the window. */ focus(): void; focusOnWebView(): void; /** * Gets the background color of the window in Hex (`#RRGGBB`) format. * * See Setting `backgroundColor`. * * **Note:** The alpha value is _not_ returned alongside the red, green, and blue * values. */ getBackgroundColor(): string; /** * The `bounds` of the window as `Object`. */ getBounds(): Rectangle; /** * The `BrowserView` attached to `win`. Returns `null` if one is not attached. * Throws an error if multiple `BrowserView`s are attached. * * @experimental */ getBrowserView(): (BrowserView) | (null); /** * an array of all BrowserViews that have been attached with `addBrowserView` or * `setBrowserView`. * * **Note:** The BrowserView API is currently experimental and may change or be * removed in future Electron releases. * * @experimental */ getBrowserViews(): BrowserView[]; /** * All child windows. */ getChildWindows(): BrowserWindow[]; /** * The `bounds` of the window's client area as `Object`. */ getContentBounds(): Rectangle; /** * Contains the window's client area's width and height. */ getContentSize(): number[]; /** * Contains the window's maximum width and height. */ getMaximumSize(): number[]; /** * Window id in the format of DesktopCapturerSource's id. For example * "window:1324:0". * * More precisely the format is `window:id:other_id` where `id` is `HWND` on * Windows, `CGWindowID` (`uint64_t`) on macOS and `Window` (`unsigned long`) on * Linux. `other_id` is used to identify web contents (tabs) so within the same top * level window. */ getMediaSourceId(): string; /** * Contains the window's minimum width and height. */ getMinimumSize(): number[]; /** * The platform-specific handle of the window. * * The native type of the handle is `HWND` on Windows, `NSView*` on macOS, and * `Window` (`unsigned long`) on Linux. */ getNativeWindowHandle(): Buffer; /** * Contains the window bounds of the normal state * * **Note:** whatever the current state of the window : maximized, minimized or in * fullscreen, this function always returns the position and size of the window in * normal state. In normal state, getBounds and getNormalBounds returns the same * `Rectangle`. */ getNormalBounds(): Rectangle; /** * between 0.0 (fully transparent) and 1.0 (fully opaque). On Linux, always returns * 1. */ getOpacity(): number; /** * The parent window or `null` if there is no parent. */ getParentWindow(): (BrowserWindow) | (null); /** * Contains the window's current position. */ getPosition(): number[]; /** * The pathname of the file the window represents. * * @platform darwin */ getRepresentedFilename(): string; /** * Contains the window's width and height. */ getSize(): number[]; /** * The title of the native window. * * **Note:** The title of the web page can be different from the title of the * native window. */ getTitle(): string; /** * The custom position for the traffic light buttons in frameless window. * * @platform darwin */ getTrafficLightPosition(): Point; /** * Whether the window has a shadow. */ hasShadow(): boolean; /** * Hides the window. */ hide(): void; /** * Hooks a windows message. The `callback` is called when the message is received * in the WndProc. * * @platform win32 */ hookWindowMessage(message: number, callback: (wParam: any, lParam: any) => void): void; /** * Whether the window is always on top of other windows. */ isAlwaysOnTop(): boolean; /** * Whether the window can be manually closed by user. * * On Linux always returns `true`. * * @platform darwin,win32 */ isClosable(): boolean; /** * Whether the window is destroyed. */ isDestroyed(): boolean; /** * Whether the window's document has been edited. * * @platform darwin */ isDocumentEdited(): boolean; /** * whether the window is enabled. */ isEnabled(): boolean; /** * Returns whether the window can be focused. * * @platform darwin,win32 */ isFocusable(): void; /** * Whether the window is focused. */ isFocused(): boolean; /** * Whether the window is in fullscreen mode. */ isFullScreen(): boolean; /** * Whether the maximize/zoom window button toggles fullscreen mode or maximizes the * window. */ isFullScreenable(): boolean; /** * Whether the window is in kiosk mode. */ isKiosk(): boolean; /** * Whether the window can be manually maximized by user. * * On Linux always returns `true`. * * @platform darwin,win32 */ isMaximizable(): boolean; /** * Whether the window is maximized. */ isMaximized(): boolean; /** * Whether menu bar automatically hides itself. * * @platform win32,linux */ isMenuBarAutoHide(): boolean; /** * Whether the menu bar is visible. * * @platform win32,linux */ isMenuBarVisible(): boolean; /** * Whether the window can be manually minimized by the user. * * On Linux always returns `true`. * * @platform darwin,win32 */ isMinimizable(): boolean; /** * Whether the window is minimized. */ isMinimized(): boolean; /** * Whether current window is a modal window. */ isModal(): boolean; /** * Whether the window can be moved by user. * * On Linux always returns `true`. * * @platform darwin,win32 */ isMovable(): boolean; /** * Whether the window is in normal state (not maximized, not minimized, not in * fullscreen mode). */ isNormal(): boolean; /** * Whether the window can be manually resized by the user. */ isResizable(): boolean; /** * Whether the window is in simple (pre-Lion) fullscreen mode. * * @platform darwin */ isSimpleFullScreen(): boolean; /** * Whether the window is in Windows 10 tablet mode. * * Since Windows 10 users can use their PC as tablet, under this mode apps can * choose to optimize their UI for tablets, such as enlarging the titlebar and * hiding titlebar buttons. * * This API returns whether the window is in tablet mode, and the `resize` event * can be be used to listen to changes to tablet mode. * * @platform win32 */ isTabletMode(): boolean; /** * Whether the window is visible to the user. */ isVisible(): boolean; /** * Whether the window is visible on all workspaces. * * **Note:** This API always returns false on Windows. * * @platform darwin,linux */ isVisibleOnAllWorkspaces(): boolean; /** * `true` or `false` depending on whether the message is hooked. * * @platform win32 */ isWindowMessageHooked(message: number): boolean; /** * the promise will resolve when the page has finished loading (see * `did-finish-load`), and rejects if the page fails to load (see `did-fail-load`). * * Same as `webContents.loadFile`, `filePath` should be a path to an HTML file * relative to the root of your application. See the `webContents` docs for more * information. */ loadFile(filePath: string, options?: LoadFileOptions): Promise; /** * the promise will resolve when the page has finished loading (see * `did-finish-load`), and rejects if the page fails to load (see `did-fail-load`). * * Same as `webContents.loadURL(url[, options])`. * * The `url` can be a remote address (e.g. `http://`) or a path to a local HTML * file using the `file://` protocol. * * To ensure that file URLs are properly formatted, it is recommended to use Node's * `url.format` method: * * You can load a URL using a `POST` request with URL-encoded data by doing the * following: */ loadURL(url: string, options?: LoadURLOptions): Promise; /** * Maximizes the window. This will also show (but not focus) the window if it isn't * being displayed already. */ maximize(): void; /** * Merges all windows into one window with multiple tabs when native tabs are * enabled and there is more than one open window. * * @platform darwin */ mergeAllWindows(): void; /** * Minimizes the window. On some platforms the minimized window will be shown in * the Dock. */ minimize(): void; /** * Moves window above the source window in the sense of z-order. If the * `mediaSourceId` is not of type window or if the window does not exist then this * method throws an error. */ moveAbove(mediaSourceId: string): void; /** * Moves the current tab into a new window if native tabs are enabled and there is * more than one tab in the current window. * * @platform darwin */ moveTabToNewWindow(): void; /** * Moves window to top(z-order) regardless of focus */ moveTop(): void; /** * Uses Quick Look to preview a file at a given path. * * @platform darwin */ previewFile(path: string, displayName?: string): void; /** * Same as `webContents.reload`. */ reload(): void; removeBrowserView(browserView: BrowserView): void; /** * Remove the window's menu bar. * * @platform linux,win32 */ removeMenu(): void; /** * Restores the window from minimized state to its previous state. */ restore(): void; /** * Selects the next tab when native tabs are enabled and there are other tabs in * the window. * * @platform darwin */ selectNextTab(): void; /** * Selects the previous tab when native tabs are enabled and there are other tabs * in the window. * * @platform darwin */ selectPreviousTab(): void; /** * 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. */ setAlwaysOnTop(flag: boolean, level?: 'normal' | 'floating' | 'torn-off-menu' | 'modal-panel' | 'main-menu' | 'status' | 'pop-up-menu' | 'screen-saver', relativeLevel?: number): void; /** * Sets the properties for the window's taskbar button. * * **Note:** `relaunchCommand` and `relaunchDisplayName` must always be set * together. If one of those properties is not set, then neither will be used. * * @platform win32 */ setAppDetails(options: AppDetailsOptions): void; /** * This will make 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. * * Consider a normal window with an HD video player and associated controls. * Perhaps there are 15 pixels of controls on the left edge, 25 pixels of controls * on the right edge and 50 pixels of controls below the player. In order to * maintain a 16:9 aspect ratio (standard aspect ratio for HD @1920x1080) within * the player itself we would call this function with arguments of 16/9 and { * width: 40, height: 50 }. The second argument doesn't care where the extra width * and height are within the content view--only that they exist. Sum any extra * width and height areas you have within the overall content view. * * The aspect ratio is not respected when window is resized programmatically with * APIs like `win.setSize`. */ setAspectRatio(aspectRatio: number, extraSize?: Size): void; /** * Controls whether to hide cursor when typing. * * @platform darwin */ setAutoHideCursor(autoHide: boolean): 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. * * @platform win32,linux */ setAutoHideMenuBar(hide: boolean): void; /** * Examples of valid `backgroundColor` values: * * * Hex * * #fff (shorthand RGB) * * #ffff (shorthand ARGB) * * #ffffff (RGB) * * #ffffffff (ARGB) * * RGB * * rgb(([\d]+),\s*([\d]+),\s*([\d]+)) * * e.g. rgb(255, 255, 255) * * RGBA * * rgba(([\d]+),\s*([\d]+),\s*([\d]+),\s*([\d.]+)) * * e.g. rgba(255, 255, 255, 1.0) * * HSL * * hsl((-?[\d.]+),\s*([\d.]+)%,\s*([\d.]+)%) * * e.g. hsl(200, 20%, 50%) * * HSLA * * hsla((-?[\d.]+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)) * * e.g. hsla(200, 20%, 50%, 0.5) * * Color name * * Options are listed in SkParseColor.cpp * * Similar to CSS Color Module Level 3 keywords, but case-sensitive. * * e.g. `blueviolet` or `red` * * Sets the background color of the window. See Setting `backgroundColor`. */ setBackgroundColor(backgroundColor: string): void; /** * Resizes and moves the window to the supplied bounds. Any properties that are not * supplied will default to their current values. */ setBounds(bounds: Partial, animate?: boolean): void; setBrowserView(browserView: (BrowserView) | (null)): void; /** * Sets whether the window can be manually closed by user. On Linux does nothing. * * @platform darwin,win32 */ setClosable(closable: boolean): void; /** * Resizes and moves the window's client area (e.g. the web page) to the supplied * bounds. */ setContentBounds(bounds: Rectangle, animate?: 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_EXCLUDEFROMCAPTURE`. For Windows 10 * version 2004 and up the window will be removed from capture entirely, older * Windows versions behave as if `WDA_MONITOR` is applied capturing a black window. * * @platform darwin,win32 */ setContentProtection(enable: boolean): void; /** * Resizes the window's client area (e.g. the web page) to `width` and `height`. */ setContentSize(width: number, height: number, animate?: boolean): void; /** * Specifies whether the window’s document has been edited, and the icon in title * bar will become gray when set to `true`. * * @platform darwin */ setDocumentEdited(edited: boolean): void; /** * Disable or enable the window. */ setEnabled(enable: boolean): void; /** * Changes whether the window can be focused. * * On macOS it does not remove the focus from the window. * * @platform darwin,win32 */ setFocusable(focusable: boolean): void; /** * Sets whether the window should be in fullscreen mode. */ setFullScreen(flag: boolean): void; /** * Sets whether the maximize/zoom window button toggles fullscreen mode or * maximizes the window. */ setFullScreenable(fullscreenable: boolean): void; /** * Sets whether the window should have a shadow. */ setHasShadow(hasShadow: boolean): void; /** * Changes window icon. * * @platform win32,linux */ setIcon(icon: (NativeImage) | (string)): void; /** * 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, options?: IgnoreMouseEventsOptions): void; /** * Enters or leaves kiosk mode. */ setKiosk(flag: boolean): void; /** * Sets whether the window can be manually maximized by user. On Linux does * nothing. * * @platform darwin,win32 */ setMaximizable(maximizable: boolean): void; /** * Sets the maximum size of window to `width` and `height`. */ setMaximumSize(width: number, height: number): void; /** * Sets the `menu` as the window's menu bar. * * @platform linux,win32 */ setMenu(menu: (Menu) | (null)): void; /** * 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. * * @platform win32,linux */ setMenuBarVisibility(visible: boolean): void; /** * Sets whether the window can be manually minimized by user. On Linux does * nothing. * * @platform darwin,win32 */ setMinimizable(minimizable: boolean): void; /** * Sets the minimum size of window to `width` and `height`. */ setMinimumSize(width: number, height: number): void; /** * Sets whether the window can be moved by user. On Linux does nothing. * * @platform darwin,win32 */ setMovable(movable: boolean): void; /** * Sets the opacity of the window. On Linux, does nothing. Out of bound number * values are clamped to the [0, 1] range. * * @platform win32,darwin */ setOpacity(opacity: number): void; /** * Sets a 16 x 16 pixel overlay onto the current taskbar icon, usually used to * convey some sort of application status or to passively notify the user. * * @platform win32 */ setOverlayIcon(overlay: (NativeImage) | (null), description: string): void; /** * Sets `parent` as current window's parent window, passing `null` will turn * current window into a top-level window. */ setParentWindow(parent: (BrowserWindow) | (null)): void; /** * Moves window to `x` and `y`. */ setPosition(x: number, y: number, animate?: boolean): void; /** * Sets progress value in progress bar. Valid range is [0, 1.0]. * * Remove progress bar when progress < 0; Change to indeterminate mode when * progress > 1. * * 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.name}.desktop`. * * On Windows, a mode can be passed. Accepted values are `none`, `normal`, * `indeterminate`, `error`, and `paused`. If you call `setProgressBar` without a * mode set (but with a value within the valid range), `normal` will be assumed. */ setProgressBar(progress: number, options?: ProgressBarOptions): void; /** * Sets the pathname of the file the window represents, and the icon of the file * will show in window's title bar. * * @platform darwin */ setRepresentedFilename(filename: string): void; /** * Sets whether the window can be manually resized by the user. */ setResizable(resizable: boolean): void; /** * Setting a window shape determines the area within the window where the system * permits drawing and user interaction. Outside of the given region, no pixels * will be drawn and no mouse events will be registered. Mouse events outside of * the region will not be received by that window, but will fall through to * whatever is behind the window. * * @experimental * @platform win32,linux */ setShape(rects: Rectangle[]): void; /** * Changes the attachment point for sheets on macOS. By default, sheets are * attached just below the window frame, but you may want to display them beneath a * HTML-rendered toolbar. For example: * * @platform darwin */ setSheetOffset(offsetY: number, offsetX?: number): void; /** * Enters or leaves simple fullscreen mode. * * Simple fullscreen mode emulates the native fullscreen behavior found in versions * of macOS prior to Lion (10.7). * * @platform darwin */ setSimpleFullScreen(flag: boolean): void; /** * Resizes the window to `width` and `height`. If `width` or `height` are below any * set minimum size constraints the window will snap to its minimum size. */ setSize(width: number, height: number, animate?: boolean): void; /** * Makes the window not show in the taskbar. * * @platform darwin,win32 */ setSkipTaskbar(skip: boolean): void; /** * Whether the buttons were added successfully * * Add a thumbnail toolbar with a specified set of buttons to the thumbnail image * of a window in a taskbar button layout. Returns a `boolean` object indicates * whether the thumbnail has been added successfully. * * The number of buttons in thumbnail toolbar should be no greater than 7 due to * the limited room. Once you setup the thumbnail toolbar, the toolbar cannot be * removed due to the platform's limitation. But you can call the API with an empty * array to clean the buttons. * * The `buttons` is an array of `Button` objects: * * * `Button` Object * * `icon` NativeImage - The icon showing in thumbnail toolbar. * * `click` Function * * `tooltip` string (optional) - The text of the button's tooltip. * * `flags` string[] (optional) - Control specific states and behaviors of the * button. By default, it is `['enabled']`. * * The `flags` is an array that can include following `string`s: * * * `enabled` - The button is active and available to the user. * * `disabled` - The button is disabled. It is present, but has a visual state * indicating it will not respond to user action. * * `dismissonclick` - When the button is clicked, the thumbnail window closes * immediately. * * `nobackground` - Do not draw a button border, use only the image. * * `hidden` - The button is not shown to the user. * * `noninteractive` - The button is enabled but not interactive; no pressed * button state is drawn. This value is intended for instances where the button is * used in a notification. * * @platform win32 */ setThumbarButtons(buttons: ThumbarButton[]): boolean; /** * 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 * }`. * * @platform win32 */ setThumbnailClip(region: Rectangle): void; /** * Sets the toolTip that is displayed when hovering over the window thumbnail in * the taskbar. * * @platform win32 */ setThumbnailToolTip(toolTip: string): void; /** * Changes the title of native window to `title`. */ setTitle(title: string): void; /** * On a Window with Window Controls Overlay already enabled, this method updates * the style of the title bar overlay. * * @platform win32 */ setTitleBarOverlay(options: TitleBarOverlayOptions): void; /** * Raises `browserView` above other `BrowserView`s attached to `win`. Throws an * error if `browserView` is not attached to `win`. * * @experimental */ setTopBrowserView(browserView: BrowserView): void; /** * Sets the touchBar layout for the current window. Specifying `null` or * `undefined` clears the touch bar. This method only has an effect if the machine * has a touch bar and is running on macOS 10.12.1+. * * **Note:** The TouchBar API is currently experimental and may change or be * removed in future Electron releases. * * @platform darwin */ setTouchBar(touchBar: (TouchBar) | (null)): void; /** * Set a custom position for the traffic light buttons in frameless window. * * @platform darwin */ setTrafficLightPosition(position: Point): void; /** * Adds a vibrancy effect to the browser window. Passing `null` or an empty string * will remove the vibrancy effect on the window. * * Note that `appearance-based`, `light`, `dark`, `medium-light`, and `ultra-dark` * have been deprecated and will be removed in an upcoming version of macOS. * * @platform darwin */ setVibrancy(type: (('appearance-based' | 'light' | 'dark' | 'titlebar' | 'selection' | 'menu' | 'popover' | 'sidebar' | 'medium-light' | 'ultra-dark' | 'header' | 'sheet' | 'window' | 'hud' | 'fullscreen-ui' | 'tooltip' | 'content' | 'under-window' | 'under-page')) | (null)): void; /** * Sets whether the window should be visible on all workspaces. * * **Note:** This API does nothing on Windows. * * @platform darwin,linux */ setVisibleOnAllWorkspaces(visible: boolean, options?: VisibleOnAllWorkspacesOptions): void; /** * Sets whether the window traffic light buttons should be visible. * * @platform darwin */ setWindowButtonVisibility(visible: boolean): void; /** * Shows and gives focus to the window. */ show(): void; /** * Same as `webContents.showDefinitionForSelection()`. * * @platform darwin */ showDefinitionForSelection(): void; /** * Shows the window but doesn't focus on it. */ showInactive(): void; /** * Toggles the visibility of the tab bar if native tabs are enabled and there is * only one tab in the current window. * * @platform darwin */ toggleTabBar(): void; /** * Unhooks all of the window messages. * * @platform win32 */ unhookAllWindowMessages(): void; /** * Unhook the window message. * * @platform win32 */ unhookWindowMessage(message: number): void; /** * Unmaximizes the window. */ unmaximize(): void; /** * A `string` property that defines an alternative title provided only to * accessibility tools such as screen readers. This string is not directly visible * to users. */ accessibleTitle: string; /** * A `boolean` property that determines 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, setting this property to `true` won't hide * it immediately. */ autoHideMenuBar: boolean; /** * A `boolean` property that determines whether the window can be manually closed * by user. * * On Linux the setter is a no-op, although the getter returns `true`. * * @platform darwin,win32 */ closable: boolean; /** * A `boolean` property that specifies whether the window’s document has been * edited. * * The icon in title bar will become gray when set to `true`. * * @platform darwin */ documentEdited: boolean; /** * A `boolean` property that determines whether the window is excluded from the * application’s Windows menu. `false` by default. * * @platform darwin */ excludedFromShownWindowsMenu: boolean; /** * A `boolean` property that determines whether the window is focusable. * * @platform win32,darwin */ focusable: boolean; /** * A `boolean` property that determines whether the window is in fullscreen mode. */ fullScreen: boolean; /** * A `boolean` property that determines whether the maximize/zoom window button * toggles fullscreen mode or maximizes the window. */ fullScreenable: boolean; /** * A `Integer` property representing the unique ID of the window. Each ID is unique * among all `BrowserWindow` instances of the entire Electron application. * */ readonly id: number; /** * A `boolean` property that determines whether the window is in kiosk mode. */ kiosk: boolean; /** * A `boolean` property that determines whether the window can be manually * maximized by user. * * On Linux the setter is a no-op, although the getter returns `true`. * * @platform darwin,win32 */ maximizable: boolean; /** * A `boolean` property that determines whether the menu bar should be visible. * * **Note:** If the menu bar is auto-hide, users can still bring up the menu bar by * pressing the single `Alt` key. * * @platform win32,linux */ menuBarVisible: boolean; /** * A `boolean` property that determines whether the window can be manually * minimized by user. * * On Linux the setter is a no-op, although the getter returns `true`. * * @platform darwin,win32 */ minimizable: boolean; /** * A `boolean` property that determines Whether the window can be moved by user. * * On Linux the setter is a no-op, although the getter returns `true`. * * @platform darwin,win32 */ movable: boolean; /** * A `string` property that determines the pathname of the file the window * represents, and the icon of the file will show in window's title bar. * * @platform darwin */ representedFilename: string; /** * A `boolean` property that determines whether the window can be manually resized * by user. */ resizable: boolean; /** * A `boolean` property that determines whether the window has a shadow. */ shadow: boolean; /** * A `boolean` property that determines whether the window is in simple (pre-Lion) * fullscreen mode. */ simpleFullScreen: boolean; /** * A `string` property that determines the title of the native window. * * **Note:** The title of the web page can be different from the title of the * native window. */ title: string; /** * A `boolean` property that determines whether the window is visible on all * workspaces. * * **Note:** Always returns false on Windows. * * @platform darwin,linux */ visibleOnAllWorkspaces: boolean; /** * A `WebContents` object this window owns. All web page related events and * operations will be done via it. * * See the `webContents` documentation for its methods and events. * */ readonly webContents: WebContents; } interface Certificate { // Docs: https://electronjs.org/docs/api/structures/certificate /** * PEM encoded data */ data: string; /** * Fingerprint of the certificate */ fingerprint: string; /** * Issuer principal */ issuer: CertificatePrincipal; /** * Issuer certificate (if not self-signed) */ issuerCert: Certificate; /** * Issuer's Common Name */ issuerName: string; /** * Hex value represented string */ serialNumber: string; /** * Subject principal */ subject: CertificatePrincipal; /** * Subject's Common Name */ subjectName: string; /** * End date of the certificate being valid in seconds */ validExpiry: number; /** * Start date of the certificate being valid in seconds */ validStart: number; } interface CertificatePrincipal { // Docs: https://electronjs.org/docs/api/structures/certificate-principal /** * Common Name. */ commonName: string; /** * Country or region. */ country: string; /** * Locality. */ locality: string; /** * Organization names. */ organizations: string[]; /** * Organization Unit names. */ organizationUnits: string[]; /** * State or province. */ state: string; } class ClientRequest extends NodeEventEmitter { // Docs: https://electronjs.org/docs/api/client-request /** * Emitted when the `request` is aborted. The `abort` event will not be fired if * the `request` is already closed. */ on(event: 'abort', listener: Function): this; once(event: 'abort', listener: Function): this; addListener(event: 'abort', listener: Function): this; removeListener(event: 'abort', listener: Function): 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: Function): this; once(event: 'close', listener: Function): this; addListener(event: 'close', listener: Function): this; removeListener(event: 'close', listener: Function): 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: ( /** * an error object providing some information about the failure. */ error: Error) => void): this; once(event: 'error', listener: ( /** * an error object providing some information about the failure. */ error: Error) => void): this; addListener(event: 'error', listener: ( /** * an error object providing some information about the failure. */ error: Error) => void): this; removeListener(event: 'error', listener: ( /** * an error object providing some information about the failure. */ error: Error) => void): this; /** * Emitted just after the last chunk of the `request`'s data has been written into * the `request` object. */ on(event: 'finish', listener: Function): this; once(event: 'finish', listener: Function): this; addListener(event: 'finish', listener: Function): this; removeListener(event: 'finish', listener: Function): this; /** * Emitted when an authenticating proxy is asking for user credentials. * * The `callback` function is expected to be called back with user credentials: * * * `username` string * * `password` string * * Providing empty credentials will cancel the request and report an authentication * error on the response object: */ on(event: 'login', listener: (authInfo: AuthInfo, callback: (username?: string, password?: string) => void) => void): this; once(event: 'login', listener: (authInfo: AuthInfo, callback: (username?: string, password?: string) => void) => void): this; addListener(event: 'login', listener: (authInfo: AuthInfo, callback: (username?: string, password?: string) => void) => void): this; removeListener(event: 'login', listener: (authInfo: AuthInfo, callback: (username?: string, password?: string) => void) => void): this; /** * Emitted when the server returns a redirect response (e.g. 301 Moved * Permanently). Calling `request.followRedirect` will continue with the * redirection. If this event is handled, `request.followRedirect` must be called * **synchronously**, otherwise the request will be cancelled. */ on(event: 'redirect', listener: (statusCode: number, method: string, redirectUrl: string, responseHeaders: Record) => void): this; once(event: 'redirect', listener: (statusCode: number, method: string, redirectUrl: string, responseHeaders: Record) => void): this; addListener(event: 'redirect', listener: (statusCode: number, method: string, redirectUrl: string, responseHeaders: Record) => void): this; removeListener(event: 'redirect', listener: (statusCode: number, method: string, redirectUrl: string, responseHeaders: Record) => void): this; on(event: 'response', listener: ( /** * An object representing the HTTP response message. */ response: IncomingMessage) => void): this; once(event: 'response', listener: ( /** * An object representing the HTTP response message. */ response: IncomingMessage) => void): this; addListener(event: 'response', listener: ( /** * An object representing the HTTP response message. */ response: IncomingMessage) => void): this; removeListener(event: 'response', listener: ( /** * An object representing the HTTP response message. */ response: IncomingMessage) => void): this; /** * ClientRequest */ constructor(options: (ClientRequestConstructorOptions) | (string)); /** * 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; /** * 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. */ end(chunk?: (string) | (Buffer), encoding?: string, callback?: () => void): void; /** * Continues any pending redirection. Can only be called during a `'redirect'` * event. */ followRedirect(): void; /** * The value of a previously set extra header name. */ getHeader(name: string): string; /** * * `active` boolean - Whether the request is currently active. If this is false * no other properties will be set * * `started` boolean - Whether the upload has started. If this is false both * `current` and `total` will be set to 0. * * `current` Integer - The number of bytes that have been uploaded so far * * `total` Integer - The number of bytes that will be uploaded this request * * You can use this method in conjunction with `POST` requests to get the progress * of a file upload or other data transfer. */ getUploadProgress(): UploadProgress; /** * 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. */ removeHeader(name: string): void; /** * Adds an extra HTTP header. The header name will be issued as-is without * lowercasing. It can be called only before first write. Calling this method after * the first write will throw an error. If the passed value is not a `string`, its * `toString()` method will be called to obtain the final value. * * Certain headers are restricted from being set by apps. These headers are listed * below. More information on restricted headers can be found in Chromium's header * utils. * * * `Content-Length` * * `Host` * * `Trailer` or `Te` * * `Upgrade` * * `Cookie2` * * `Keep-Alive` * * `Transfer-Encoding` * * Additionally, setting the `Connection` header to the value `upgrade` is also * disallowed. */ setHeader(name: string, value: string): void; /** * `callback` is essentially a dummy function introduced in the purpose of keeping * similarity with the Node.js API. It is called asynchronously in the next tick * after `chunk` content have been delivered to the Chromium networking layer. * Contrary to the Node.js implementation, it is not guaranteed that `chunk` * content have been flushed on the wire before `callback` is called. * * 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. */ write(chunk: (string) | (Buffer), encoding?: string, callback?: () => void): void; /** * 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; } interface Clipboard { // Docs: https://electronjs.org/docs/api/clipboard /** * An array of supported formats for the clipboard `type`. */ availableFormats(type?: 'selection' | 'clipboard'): string[]; /** * Clears the clipboard content. */ clear(type?: 'selection' | 'clipboard'): void; /** * Whether the clipboard supports the specified `format`. * * @experimental */ has(format: string, type?: 'selection' | 'clipboard'): boolean; /** * Reads `format` type from the clipboard. * * `format` should contain valid ASCII characters and have `/` separator. `a/c`, * `a/bc` are valid formats while `/abc`, `abc/`, `a/`, `/a`, `a` are not valid. * * @experimental */ read(format: string): string; /** * * `title` string * * `url` string * * Returns an Object containing `title` and `url` keys representing the bookmark in * the clipboard. The `title` and `url` values will be empty strings when the * bookmark is unavailable. The `title` value will always be empty on Windows. * * @platform darwin,win32 */ readBookmark(): ReadBookmark; /** * Reads `format` type from the clipboard. * * @experimental */ readBuffer(format: string): Buffer; /** * The text on the find pasteboard, which is the pasteboard that holds information * about the current state of the active application’s find panel. * * 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. * * @platform darwin */ readFindText(): string; /** * The content in the clipboard as markup. */ readHTML(type?: 'selection' | 'clipboard'): string; /** * The image content in the clipboard. */ readImage(type?: 'selection' | 'clipboard'): NativeImage; /** * The content in the clipboard as RTF. */ readRTF(type?: 'selection' | 'clipboard'): string; /** * The content in the clipboard as plain text. */ readText(type?: 'selection' | 'clipboard'): string; /** * Writes `data` to the clipboard. */ write(data: Data, type?: 'selection' | 'clipboard'): void; /** * Writes the `title` (macOS only) and `url` into the clipboard as a bookmark. * * **Note:** Most apps on Windows don't support pasting bookmarks into them so you * can use `clipboard.write` to write both a bookmark and fallback text to the * clipboard. * * @platform darwin,win32 */ writeBookmark(title: string, url: string, type?: 'selection' | 'clipboard'): void; /** * Writes the `buffer` into the clipboard as `format`. * * @experimental */ writeBuffer(format: string, buffer: Buffer, type?: 'selection' | 'clipboard'): void; /** * Writes the `text` into the find pasteboard (the pasteboard that holds * information about the current state of the active application’s find panel) as * plain text. This method uses synchronous IPC when called from the renderer * process. * * @platform darwin */ writeFindText(text: string): void; /** * Writes `markup` to the clipboard. */ writeHTML(markup: string, type?: 'selection' | 'clipboard'): void; /** * Writes `image` to the clipboard. */ writeImage(image: NativeImage, type?: 'selection' | 'clipboard'): void; /** * Writes the `text` into the clipboard in RTF. */ writeRTF(text: string, type?: 'selection' | 'clipboard'): void; /** * Writes the `text` into the clipboard as plain text. */ writeText(text: string, type?: 'selection' | 'clipboard'): void; } class CommandLine { // Docs: https://electronjs.org/docs/api/command-line /** * Append an argument to Chromium's command line. The argument will be quoted * correctly. Switches will precede arguments regardless of appending order. * * If you're appending an argument like `--switch=value`, consider using * `appendSwitch('switch', 'value')` instead. * * **Note:** This will not affect `process.argv`. The intended usage of this * function is to control Chromium's behavior. */ appendArgument(value: string): void; /** * Append a switch (with optional `value`) to Chromium's command line. * * **Note:** This will not affect `process.argv`. The intended usage of this * function is to control Chromium's behavior. */ appendSwitch(the_switch: string, value?: string): void; /** * The command-line switch value. * * **Note:** When the switch is not present or has no value, it returns empty * string. */ getSwitchValue(the_switch: string): string; /** * Whether the command-line switch is present. */ hasSwitch(the_switch: string): boolean; /** * Removes the specified switch from Chromium's command line. * * **Note:** This will not affect `process.argv`. The intended usage of this * function is to control Chromium's behavior. */ removeSwitch(the_switch: string): void; } interface ContentTracing { // Docs: https://electronjs.org/docs/api/content-tracing /** * resolves with an array of category groups once all child processes have * acknowledged the `getCategories` request * * Get a set of category groups. The category groups can change as new code paths * are reached. See also the list of built-in tracing categories. * * > **NOTE:** Electron adds a non-default tracing category called `"electron"`. * This category can be used to capture Electron-specific tracing events. */ getCategories(): Promise; /** * Resolves with an object containing the `value` and `percentage` of trace buffer * maximum usage * * * `value` number * * `percentage` number * * Get the maximum usage across processes of trace buffer as a percentage of the * full state. */ getTraceBufferUsage(): Promise; /** * resolved once all child processes have acknowledged the `startRecording` * request. * * Start recording on all processes. * * Recording begins immediately locally and asynchronously on child processes as * soon as they receive the EnableRecording request. * * If a recording is already running, the promise will be immediately resolved, as * only one trace operation can be in progress at a time. */ startRecording(options: (TraceConfig) | (TraceCategoriesAndOptions)): Promise; /** * resolves with a path to a file that contains the traced data once all child * processes have acknowledged the `stopRecording` request * * Stop recording on all processes. * * Child processes typically cache trace data and only rarely flush and send trace * data back to the main process. This helps to minimize the runtime overhead of * tracing since sending trace data over IPC can be an expensive operation. So, to * end tracing, Chromium asynchronously asks all child processes to flush any * pending trace data. * * Trace data will be written into `resultFilePath`. If `resultFilePath` is empty * or not provided, trace data will be written to a temporary file, and the path * will be returned in the promise. */ stopRecording(resultFilePath?: string): Promise; } interface ContextBridge { // Docs: https://electronjs.org/docs/api/context-bridge exposeInMainWorld(apiKey: string, api: any): void; } interface Cookie { // Docs: https://electronjs.org/docs/api/structures/cookie /** * The domain of the cookie; this will be normalized with a preceding dot so that * it's also valid for subdomains. */ domain?: string; /** * The expiration date of the cookie as the number of seconds since the UNIX epoch. * Not provided for session cookies. */ expirationDate?: number; /** * Whether the cookie is a host-only cookie; this will only be `true` if no domain * was passed. */ hostOnly?: boolean; /** * Whether the cookie is marked as HTTP only. */ httpOnly?: boolean; /** * The name of the cookie. */ name: string; /** * The path of the cookie. */ path?: string; /** * The Same Site policy applied to this cookie. Can be `unspecified`, * `no_restriction`, `lax` or `strict`. */ sameSite: ('unspecified' | 'no_restriction' | 'lax' | 'strict'); /** * Whether the cookie is marked as secure. */ secure?: boolean; /** * Whether the cookie is a session cookie or a persistent cookie with an expiration * date. */ session?: boolean; /** * The value of the cookie. */ value: string; } class Cookies extends NodeEventEmitter { // Docs: https://electronjs.org/docs/api/cookies /** * Emitted when a cookie is changed because it was added, edited, removed, or * expired. */ on(event: 'changed', listener: (event: Event, /** * The cookie that was changed. */ cookie: Cookie, /** * The cause of the change with one of the following values: */ cause: ('explicit' | 'overwrite' | 'expired' | 'evicted' | 'expired-overwrite'), /** * `true` if the cookie was removed, `false` otherwise. */ removed: boolean) => void): this; once(event: 'changed', listener: (event: Event, /** * The cookie that was changed. */ cookie: Cookie, /** * The cause of the change with one of the following values: */ cause: ('explicit' | 'overwrite' | 'expired' | 'evicted' | 'expired-overwrite'), /** * `true` if the cookie was removed, `false` otherwise. */ removed: boolean) => void): this; addListener(event: 'changed', listener: (event: Event, /** * The cookie that was changed. */ cookie: Cookie, /** * The cause of the change with one of the following values: */ cause: ('explicit' | 'overwrite' | 'expired' | 'evicted' | 'expired-overwrite'), /** * `true` if the cookie was removed, `false` otherwise. */ removed: boolean) => void): this; removeListener(event: 'changed', listener: (event: Event, /** * The cookie that was changed. */ cookie: Cookie, /** * The cause of the change with one of the following values: */ cause: ('explicit' | 'overwrite' | 'expired' | 'evicted' | 'expired-overwrite'), /** * `true` if the cookie was removed, `false` otherwise. */ removed: boolean) => void): this; /** * A promise which resolves when the cookie store has been flushed * * Writes any unwritten cookies data to disk. */ flushStore(): Promise; /** * A promise which resolves an array of cookie objects. * * Sends a request to get all cookies matching `filter`, and resolves a promise * with the response. */ get(filter: CookiesGetFilter): Promise; /** * A promise which resolves when the cookie has been removed * * Removes the cookies matching `url` and `name` */ remove(url: string, name: string): Promise; /** * A promise which resolves when the cookie has been set * * Sets a cookie with `details`. */ set(details: CookiesSetDetails): Promise; } interface CPUUsage { // Docs: https://electronjs.org/docs/api/structures/cpu-usage /** * The number of average idle CPU wakeups per second since the last call to * getCPUUsage. First call returns 0. Will always return 0 on Windows. */ idleWakeupsPerSecond: number; /** * Percentage of CPU used since the last call to getCPUUsage. First call returns 0. */ percentCPUUsage: number; } interface CrashReport { // Docs: https://electronjs.org/docs/api/structures/crash-report date: Date; id: string; } interface CrashReporter { // Docs: https://electronjs.org/docs/api/crash-reporter /** * Set an extra parameter to be sent with the crash report. The values specified * here will be sent in addition to any values set via the `extra` option when * `start` was called. * * Parameters added in this fashion (or via the `extra` parameter to * `crashReporter.start`) are specific to the calling process. Adding extra * parameters in the main process will not cause those parameters to be sent along * with crashes from renderer or other child processes. Similarly, adding extra * parameters in a renderer process will not result in those parameters being sent * with crashes that occur in other renderer processes or in the main process. * * **Note:** Parameters have limits on the length of the keys and values. Key names * must be no longer than 39 bytes, and values must be no longer than 20320 bytes. * Keys with names longer than the maximum will be silently ignored. Key values * longer than the maximum length will be truncated. */ addExtraParameter(key: string, value: string): void; /** * The date and ID of the last crash report. Only crash reports that have been * uploaded will be returned; even if a crash report is present on disk it will not * be returned until it is uploaded. In the case that there are no uploaded * reports, `null` is returned. * * **Note:** This method is only available in the main process. */ getLastCrashReport(): CrashReport; /** * The current 'extra' parameters of the crash reporter. */ getParameters(): Record; /** * Returns all uploaded crash reports. Each report contains the date and uploaded * ID. * * **Note:** This method is only available in the main process. */ getUploadedReports(): CrashReport[]; /** * Whether reports should be submitted to the server. Set through the `start` * method or `setUploadToServer`. * * **Note:** This method is only available in the main process. */ getUploadToServer(): boolean; /** * Remove an extra parameter from the current set of parameters. Future crashes * will not include this parameter. */ removeExtraParameter(key: string): void; /** * This would normally be controlled by user preferences. This has no effect if * called before `start` is called. * * **Note:** This method is only available in the main process. */ setUploadToServer(uploadToServer: boolean): void; /** * This method must be called before using any other `crashReporter` APIs. Once * initialized this way, the crashpad handler collects crashes from all * subsequently created processes. The crash reporter cannot be disabled once * started. * * This method should be called as early as possible in app startup, preferably * before `app.on('ready')`. If the crash reporter is not initialized at the time a * renderer process is created, then that renderer process will not be monitored by * the crash reporter. * * **Note:** You can test out the crash reporter by generating a crash using * `process.crash()`. * * **Note:** If you need to send additional/updated `extra` parameters after your * first call `start` you can call `addExtraParameter`. * * **Note:** Parameters passed in `extra`, `globalExtra` or set with * `addExtraParameter` have limits on the length of the keys and values. Key names * must be at most 39 bytes long, and values must be no longer than 127 bytes. Keys * with names longer than the maximum will be silently ignored. Key values longer * than the maximum length will be truncated. * * **Note:** This method is only available in the main process. */ start(options: CrashReporterStartOptions): void; } interface CustomScheme { // Docs: https://electronjs.org/docs/api/structures/custom-scheme privileges?: Privileges; /** * Custom schemes to be registered with options. */ scheme: string; } class Debugger extends NodeEventEmitter { // Docs: https://electronjs.org/docs/api/debugger /** * Emitted when the 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 for detaching debugger. */ reason: string) => void): this; once(event: 'detach', listener: (event: Event, /** * Reason for detaching debugger. */ reason: string) => void): this; addListener(event: 'detach', listener: (event: Event, /** * Reason for detaching debugger. */ reason: string) => void): this; removeListener(event: 'detach', listener: (event: Event, /** * Reason for detaching debugger. */ reason: string) => void): this; /** * Emitted whenever the debugging target issues an instrumentation event. */ on(event: 'message', listener: (event: Event, /** * Method name. */ method: string, /** * Event parameters defined by the 'parameters' attribute in the remote debugging * protocol. */ params: any, /** * Unique identifier of attached debugging session, will match the value sent from * `debugger.sendCommand`. */ sessionId: string) => void): this; once(event: 'message', listener: (event: Event, /** * Method name. */ method: string, /** * Event parameters defined by the 'parameters' attribute in the remote debugging * protocol. */ params: any, /** * Unique identifier of attached debugging session, will match the value sent from * `debugger.sendCommand`. */ sessionId: string) => void): this; addListener(event: 'message', listener: (event: Event, /** * Method name. */ method: string, /** * Event parameters defined by the 'parameters' attribute in the remote debugging * protocol. */ params: any, /** * Unique identifier of attached debugging session, will match the value sent from * `debugger.sendCommand`. */ sessionId: string) => void): this; removeListener(event: 'message', listener: (event: Event, /** * Method name. */ method: string, /** * Event parameters defined by the 'parameters' attribute in the remote debugging * protocol. */ params: any, /** * Unique identifier of attached debugging session, will match the value sent from * `debugger.sendCommand`. */ sessionId: string) => void): this; /** * Attaches the debugger to the `webContents`. */ attach(protocolVersion?: string): void; /** * Detaches the debugger from the `webContents`. */ detach(): void; /** * Whether a debugger is attached to the `webContents`. */ isAttached(): boolean; /** * A promise that resolves with the response defined by the 'returns' attribute of * the command description in the remote debugging protocol or is rejected * indicating the failure of the command. * * Send given command to the debugging target. */ sendCommand(method: string, commandParams?: any, sessionId?: string): Promise; } interface DesktopCapturer { // Docs: https://electronjs.org/docs/api/desktop-capturer /** * Resolves with an array of `DesktopCapturerSource` objects, each * `DesktopCapturerSource` represents a screen or an individual window that can be * captured. * * **Note** Capturing the screen contents requires user consent on macOS 10.15 * Catalina or higher, which can detected by * `systemPreferences.getMediaAccessStatus`. */ getSources(options: SourcesOptions): Promise; } interface DesktopCapturerSource { // Docs: https://electronjs.org/docs/api/structures/desktop-capturer-source /** * An icon image of the application that owns the window or null if the source has * a type screen. The size of the icon is not known in advance and depends on what * the application provides. */ appIcon: NativeImage; /** * A unique identifier that will correspond to the `id` of the matching Display * returned by the Screen API. On some platforms, this is equivalent to the `XX` * portion of the `id` field above and on others it will differ. It will be an * empty string if not available. */ display_id: string; /** * The identifier of a window or screen that can be used as a `chromeMediaSourceId` * constraint when calling [`navigator.webkitGetUserMedia`]. The format of the * identifier will be `window:XX:YY` or `screen:ZZ:0`. XX is the windowID/handle. * YY is 1 for the current process, and 0 for all others. ZZ is a sequential number * that represents the screen, and it does not equal to the index in the source's * name. */ id: string; /** * A screen source will be named either `Entire Screen` or `Screen `, while * the name of a window source will match the window title. */ name: string; /** * A thumbnail image. **Note:** There is no guarantee that the size of the * thumbnail is the same as the `thumbnailSize` specified in the `options` passed * to `desktopCapturer.getSources`. The actual size depends on the scale of the * screen or window. */ thumbnail: NativeImage; } interface Dialog { // Docs: https://electronjs.org/docs/api/dialog /** * resolves when the certificate trust dialog is shown. * * On macOS, this displays a modal dialog that shows a message and certificate * information, and gives the user the option of trusting/importing the * certificate. If you provide a `browserWindow` argument the dialog will be * attached to the parent window, making it modal. * * On Windows the options are more limited, due to the Win32 APIs used: * * * The `message` argument is not used, as the OS provides its own confirmation * dialog. * * The `browserWindow` argument is ignored since it is not possible to make this * confirmation dialog modal. * * @platform darwin,win32 */ showCertificateTrustDialog(browserWindow: BrowserWindow, options: CertificateTrustDialogOptions): Promise; /** * resolves when the certificate trust dialog is shown. * * On macOS, this displays a modal dialog that shows a message and certificate * information, and gives the user the option of trusting/importing the * certificate. If you provide a `browserWindow` argument the dialog will be * attached to the parent window, making it modal. * * On Windows the options are more limited, due to the Win32 APIs used: * * * The `message` argument is not used, as the OS provides its own confirmation * dialog. * * The `browserWindow` argument is ignored since it is not possible to make this * confirmation dialog modal. * * @platform darwin,win32 */ showCertificateTrustDialog(options: CertificateTrustDialogOptions): Promise; /** * 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 `ready`event on Linux, the message will be emitted to stderr, and no GUI * dialog will appear. */ showErrorBox(title: string, content: string): void; /** * resolves with a promise containing the following properties: * * * `response` number - The index of the clicked button. * * `checkboxChecked` boolean - The checked state of the checkbox if * `checkboxLabel` was set. Otherwise `false`. * * Shows a message box. * * The `browserWindow` argument allows the dialog to attach itself to a parent * window, making it modal. */ showMessageBox(browserWindow: BrowserWindow, options: MessageBoxOptions): Promise; /** * resolves with a promise containing the following properties: * * * `response` number - The index of the clicked button. * * `checkboxChecked` boolean - The checked state of the checkbox if * `checkboxLabel` was set. Otherwise `false`. * * Shows a message box. * * The `browserWindow` argument allows the dialog to attach itself to a parent * window, making it modal. */ showMessageBox(options: MessageBoxOptions): Promise; /** * the index of the clicked button. * * Shows a message box, it will block the process until the message box is closed. * It returns the index of the clicked button. * * The `browserWindow` argument allows the dialog to attach itself to a parent * window, making it modal. If `browserWindow` is not shown dialog will not be * attached to it. In such case it will be displayed as an independent window. */ showMessageBoxSync(browserWindow: BrowserWindow, options: MessageBoxSyncOptions): number; /** * the index of the clicked button. * * Shows a message box, it will block the process until the message box is closed. * It returns the index of the clicked button. * * The `browserWindow` argument allows the dialog to attach itself to a parent * window, making it modal. If `browserWindow` is not shown dialog will not be * attached to it. In such case it will be displayed as an independent window. */ showMessageBoxSync(options: MessageBoxSyncOptions): number; /** * Resolve with an object containing the following: * * * `canceled` boolean - whether or not the dialog was canceled. * * `filePaths` string[] - An array of file paths chosen by the user. If the * dialog is cancelled this will be an empty array. * * `bookmarks` string[] (optional) _macOS_ _mas_ - An array matching the * `filePaths` array of base64 encoded strings which contains security scoped * bookmark data. `securityScopedBookmarks` must be enabled for this to be * populated. (For return values, see table here.) * * The `browserWindow` argument allows the dialog to attach itself to a parent * window, making it modal. * * The `filters` specifies an array of file types that can be displayed or selected * when you want to limit the user to a specific type. For example: * * The `extensions` array should contain 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). * * **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. */ showOpenDialog(browserWindow: BrowserWindow, options: OpenDialogOptions): Promise; /** * Resolve with an object containing the following: * * * `canceled` boolean - whether or not the dialog was canceled. * * `filePaths` string[] - An array of file paths chosen by the user. If the * dialog is cancelled this will be an empty array. * * `bookmarks` string[] (optional) _macOS_ _mas_ - An array matching the * `filePaths` array of base64 encoded strings which contains security scoped * bookmark data. `securityScopedBookmarks` must be enabled for this to be * populated. (For return values, see table here.) * * The `browserWindow` argument allows the dialog to attach itself to a parent * window, making it modal. * * The `filters` specifies an array of file types that can be displayed or selected * when you want to limit the user to a specific type. For example: * * The `extensions` array should contain 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). * * **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. */ showOpenDialog(options: OpenDialogOptions): Promise; /** * the file paths chosen by the user; if the dialog is cancelled it returns * `undefined`. * * The `browserWindow` argument allows the dialog to attach itself to a parent * window, making it modal. * * The `filters` specifies an array of file types that can be displayed or selected * when you want to limit the user to a specific type. For example: * * The `extensions` array should contain 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). * * **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. */ showOpenDialogSync(browserWindow: BrowserWindow, options: OpenDialogSyncOptions): (string[]) | (undefined); /** * the file paths chosen by the user; if the dialog is cancelled it returns * `undefined`. * * The `browserWindow` argument allows the dialog to attach itself to a parent * window, making it modal. * * The `filters` specifies an array of file types that can be displayed or selected * when you want to limit the user to a specific type. For example: * * The `extensions` array should contain 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). * * **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. */ showOpenDialogSync(options: OpenDialogSyncOptions): (string[]) | (undefined); /** * Resolve with an object containing the following: * * * `canceled` boolean - whether or not the dialog was canceled. * * `filePath` string (optional) - If the dialog is canceled, this will be * `undefined`. * * `bookmark` string (optional) _macOS_ _mas_ - Base64 encoded string which * contains the security scoped bookmark data for the saved file. * `securityScopedBookmarks` must be enabled for this to be present. (For return * values, see table here.) * * The `browserWindow` argument allows the dialog to attach itself to a parent * window, making it modal. * * The `filters` specifies an array of file types that can be displayed, see * `dialog.showOpenDialog` for an example. * * **Note:** On macOS, using the asynchronous version is recommended to avoid * issues when expanding and collapsing the dialog. */ showSaveDialog(browserWindow: BrowserWindow, options: SaveDialogOptions): Promise; /** * Resolve with an object containing the following: * * * `canceled` boolean - whether or not the dialog was canceled. * * `filePath` string (optional) - If the dialog is canceled, this will be * `undefined`. * * `bookmark` string (optional) _macOS_ _mas_ - Base64 encoded string which * contains the security scoped bookmark data for the saved file. * `securityScopedBookmarks` must be enabled for this to be present. (For return * values, see table here.) * * The `browserWindow` argument allows the dialog to attach itself to a parent * window, making it modal. * * The `filters` specifies an array of file types that can be displayed, see * `dialog.showOpenDialog` for an example. * * **Note:** On macOS, using the asynchronous version is recommended to avoid * issues when expanding and collapsing the dialog. */ showSaveDialog(options: SaveDialogOptions): Promise; /** * the path of the file chosen by the user; if the dialog is cancelled it returns * `undefined`. * * The `browserWindow` argument allows the dialog to attach itself to a parent * window, making it modal. * * The `filters` specifies an array of file types that can be displayed, see * `dialog.showOpenDialog` for an example. */ showSaveDialogSync(browserWindow: BrowserWindow, options: SaveDialogSyncOptions): (string) | (undefined); /** * the path of the file chosen by the user; if the dialog is cancelled it returns * `undefined`. * * The `browserWindow` argument allows the dialog to attach itself to a parent * window, making it modal. * * The `filters` specifies an array of file types that can be displayed, see * `dialog.showOpenDialog` for an example. */ showSaveDialogSync(options: SaveDialogSyncOptions): (string) | (undefined); } interface Display { // Docs: https://electronjs.org/docs/api/structures/display /** * Can be `available`, `unavailable`, `unknown`. */ accelerometerSupport: ('available' | 'unavailable' | 'unknown'); /** * the bounds of the display in DIP points. */ bounds: Rectangle; /** * The number of bits per pixel. */ colorDepth: number; /** * represent a color space (three-dimensional object which contains all realizable * color combinations) for the purpose of color conversions */ colorSpace: string; /** * The number of bits per color component. */ depthPerComponent: number; /** * The display refresh rate. */ displayFrequency: number; /** * Unique identifier associated with the display. */ id: number; /** * `true` for an internal display and `false` for an external display */ internal: boolean; /** * Whether or not the display is a monochrome display. */ monochrome: boolean; /** * Can be 0, 90, 180, 270, represents screen rotation in clock-wise degrees. */ rotation: number; /** * Output device's pixel scale factor. */ scaleFactor: number; size: Size; /** * Can be `available`, `unavailable`, `unknown`. */ touchSupport: ('available' | 'unavailable' | 'unknown'); /** * the work area of the display in DIP points. */ workArea: Rectangle; workAreaSize: Size; } class Dock { // Docs: https://electronjs.org/docs/api/dock /** * an ID representing the request. * * 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. * * **Note:** This method can only be used while the app is not focused; when the * app is focused it will return -1. * * @platform darwin */ bounce(type?: 'critical' | 'informational'): number; /** * Cancel the bounce of `id`. * * @platform darwin */ cancelBounce(id: number): void; /** * Bounces the Downloads stack if the filePath is inside the Downloads folder. * * @platform darwin */ downloadFinished(filePath: string): void; /** * The badge string of the dock. * * @platform darwin */ getBadge(): string; /** * The application's [dock menu][dock-menu]. * * @platform darwin */ getMenu(): (Menu) | (null); /** * Hides the dock icon. * * @platform darwin */ hide(): void; /** * Whether the dock icon is visible. * * @platform darwin */ isVisible(): boolean; /** * Sets the string to be displayed in the dock’s badging area. * * @platform darwin */ setBadge(text: string): void; /** * Sets the `image` associated with this dock icon. * * @platform darwin */ setIcon(image: (NativeImage) | (string)): void; /** * Sets the application's [dock menu][dock-menu]. * * @platform darwin */ setMenu(menu: Menu): void; /** * Resolves when the dock icon is shown. * * @platform darwin */ show(): Promise; } class DownloadItem extends NodeEventEmitter { // Docs: https://electronjs.org/docs/api/download-item /** * Emitted 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. * * The `state` can be one of following: * * * `completed` - The download completed successfully. * * `cancelled` - The download has been cancelled. * * `interrupted` - The download has interrupted and can not resume. */ on(event: 'done', listener: (event: Event, /** * Can be `completed`, `cancelled` or `interrupted`. */ state: ('completed' | 'cancelled' | 'interrupted')) => void): this; once(event: 'done', listener: (event: Event, /** * Can be `completed`, `cancelled` or `interrupted`. */ state: ('completed' | 'cancelled' | 'interrupted')) => void): this; addListener(event: 'done', listener: (event: Event, /** * Can be `completed`, `cancelled` or `interrupted`. */ state: ('completed' | 'cancelled' | 'interrupted')) => void): this; removeListener(event: 'done', listener: (event: Event, /** * Can be `completed`, `cancelled` or `interrupted`. */ state: ('completed' | 'cancelled' | 'interrupted')) => void): this; /** * Emitted when the download has been updated and is not done. * * The `state` can be one of following: * * * `progressing` - The download is in-progress. * * `interrupted` - The download has interrupted and can be resumed. */ on(event: 'updated', listener: (event: Event, /** * Can be `progressing` or `interrupted`. */ state: ('progressing' | 'interrupted')) => void): this; once(event: 'updated', listener: (event: Event, /** * Can be `progressing` or `interrupted`. */ state: ('progressing' | 'interrupted')) => void): this; addListener(event: 'updated', listener: (event: Event, /** * Can be `progressing` or `interrupted`. */ state: ('progressing' | 'interrupted')) => void): this; removeListener(event: 'updated', listener: (event: Event, /** * Can be `progressing` or `interrupted`. */ state: ('progressing' | 'interrupted')) => void): this; /** * Cancels the download operation. */ cancel(): void; /** * Whether the download can resume. */ canResume(): boolean; /** * The Content-Disposition field from the response header. */ getContentDisposition(): string; /** * ETag header value. */ getETag(): string; /** * 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; /** * Last-Modified header value. */ getLastModifiedTime(): string; /** * The files mime type. */ getMimeType(): string; /** * The received bytes of the download item. */ getReceivedBytes(): number; /** * Returns the object previously set by * `downloadItem.setSaveDialogOptions(options)`. */ getSaveDialogOptions(): SaveDialogOptions; /** * 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; /** * Number of seconds since the UNIX epoch when the download was started. */ getStartTime(): number; /** * The current state. Can be `progressing`, `completed`, `cancelled` or * `interrupted`. * * **Note:** The following methods are useful specifically to resume a `cancelled` * item when session is restarted. */ getState(): ('progressing' | 'completed' | 'cancelled' | 'interrupted'); /** * The total size in bytes of the download item. * * If the size is unknown, it returns 0. */ getTotalBytes(): number; /** * The origin URL where the item is downloaded from. */ getURL(): string; /** * The complete URL chain of the item including any redirects. */ getURLChain(): string[]; /** * Whether the download has user gesture. */ hasUserGesture(): boolean; /** * Whether the download is paused. */ isPaused(): boolean; /** * Pauses the download. */ pause(): void; /** * Resumes the download that has been paused. * * **Note:** To enable resumable downloads the server you are downloading from must * support range requests and provide both `Last-Modified` and `ETag` header * values. Otherwise `resume()` will dismiss previously received bytes and restart * the download from the beginning. */ resume(): void; /** * This API allows the user to set custom options for the save dialog that opens * for the download item by default. The API is only available in session's * `will-download` callback function. */ setSaveDialogOptions(options: SaveDialogOptions): void; /** * The API is only available in session's `will-download` callback function. If * `path` doesn't exist, Electron will try to make the directory recursively. If * user doesn't set the save path via the API, Electron will use the original * routine to determine the save path; this usually prompts a save dialog. */ setSavePath(path: string): void; /** * A `string` property that determines the save file path of the download item. * * The property is only available in session's `will-download` callback function. * If user doesn't set the save path via the property, Electron will use the * original routine to determine the save path; this usually prompts a save dialog. */ savePath: string; } interface Event extends GlobalEvent { // Docs: https://electronjs.org/docs/api/structures/event preventDefault: (() => void); } interface Extension { // Docs: https://electronjs.org/docs/api/structures/extension id: string; /** * Copy of the extension's manifest data. */ manifest: any; name: string; /** * The extension's file path. */ path: string; /** * The extension's `chrome-extension://` URL. */ url: string; version: string; } interface ExtensionInfo { // Docs: https://electronjs.org/docs/api/structures/extension-info name: string; version: string; } interface FileFilter { // Docs: https://electronjs.org/docs/api/structures/file-filter extensions: string[]; name: string; } interface FilePathWithHeaders { // Docs: https://electronjs.org/docs/api/structures/file-path-with-headers /** * Additional headers to be sent. */ headers?: Record; /** * The path to the file to send. */ path: string; } interface GlobalShortcut { // Docs: https://electronjs.org/docs/api/global-shortcut /** * Whether this application has registered `accelerator`. * * When the accelerator is already taken by other applications, this call will * still return `false`. This behavior is intended by operating systems, since they * don't want applications to fight for global shortcuts. */ isRegistered(accelerator: Accelerator): boolean; /** * Whether or not the shortcut was registered successfully. * * Registers a global shortcut of `accelerator`. The `callback` is called when the * registered shortcut is pressed by the user. * * When the accelerator is already taken by other applications, this call will * silently fail. This behavior is intended by operating systems, since they don't * want applications to fight for global shortcuts. * * The following accelerators will not be registered successfully on macOS 10.14 * Mojave unless the app has been authorized as a trusted accessibility client: * * * "Media Play/Pause" * * "Media Next Track" * * "Media Previous Track" * * "Media Stop" */ register(accelerator: Accelerator, callback: () => void): boolean; /** * Registers a global shortcut of all `accelerator` items in `accelerators`. The * `callback` is called when any of the registered shortcuts are pressed by the * user. * * When a given accelerator is already taken by other applications, this call will * silently fail. This behavior is intended by operating systems, since they don't * want applications to fight for global shortcuts. * * The following accelerators will not be registered successfully on macOS 10.14 * Mojave unless the app has been authorized as a trusted accessibility client: * * * "Media Play/Pause" * * "Media Next Track" * * "Media Previous Track" * * "Media Stop" */ registerAll(accelerators: string[], callback: () => void): void; /** * Unregisters the global shortcut of `accelerator`. */ unregister(accelerator: Accelerator): void; /** * Unregisters all of the global shortcuts. */ unregisterAll(): void; } interface GPUFeatureStatus { // Docs: https://electronjs.org/docs/api/structures/gpu-feature-status /** * Canvas. */ '2d_canvas': string; /** * Flash. */ flash_3d: string; /** * Flash Stage3D. */ flash_stage3d: string; /** * Flash Stage3D Baseline profile. */ flash_stage3d_baseline: string; /** * Compositing. */ gpu_compositing: string; /** * Multiple Raster Threads. */ multiple_raster_threads: string; /** * Native GpuMemoryBuffers. */ native_gpu_memory_buffers: string; /** * Rasterization. */ rasterization: string; /** * Video Decode. */ video_decode: string; /** * Video Encode. */ video_encode: string; /** * VPx Video Decode. */ vpx_decode: string; /** * WebGL. */ webgl: string; /** * WebGL2. */ webgl2: string; } interface HIDDevice { // Docs: https://electronjs.org/docs/api/structures/hid-device /** * Unique identifier for the device. */ deviceId: string; /** * Unique identifier for the HID interface. A device may have multiple HID * interfaces. */ guid?: string; /** * Name of the device. */ name: string; /** * The USB product ID. */ productId: number; /** * The USB device serial number. */ serialNumber?: string; /** * The USB vendor ID. */ vendorId: number; } interface InAppPurchase extends NodeJS.EventEmitter { // Docs: https://electronjs.org/docs/api/in-app-purchase on(event: 'transactions-updated', listener: Function): this; once(event: 'transactions-updated', listener: Function): this; addListener(event: 'transactions-updated', listener: Function): this; removeListener(event: 'transactions-updated', listener: Function): this; /** * whether a user can make a payment. */ canMakePayments(): boolean; /** * Completes all pending transactions. */ finishAllTransactions(): void; /** * Completes the pending transactions corresponding to the date. */ finishTransactionByDate(date: string): void; /** * Resolves with an array of `Product` objects. * * Retrieves the product descriptions. */ getProducts(productIDs: string[]): Promise; /** * the path to the receipt. */ getReceiptURL(): string; /** * Returns `true` if the product is valid and added to the payment queue. * * You should listen for the `transactions-updated` event as soon as possible and * certainly before you call `purchaseProduct`. */ purchaseProduct(productID: string, quantity?: number): Promise; /** * Restores finished transactions. This method can be called either to install * purchases on additional devices, or to restore purchases for an application that * the user deleted and reinstalled. * * The payment queue delivers a new transaction for each previously completed * transaction that can be restored. Each transaction includes a copy of the * original transaction. */ restoreCompletedTransactions(): void; } class IncomingMessage extends NodeEventEmitter { // Docs: https://electronjs.org/docs/api/incoming-message /** * Emitted when a request has been canceled during an ongoing HTTP transaction. */ on(event: 'aborted', listener: Function): this; once(event: 'aborted', listener: Function): this; addListener(event: 'aborted', listener: Function): this; removeListener(event: 'aborted', listener: Function): this; /** * The `data` event is the usual method of transferring response data into * applicative code. */ on(event: 'data', listener: ( /** * A chunk of response body's data. */ chunk: Buffer) => void): this; once(event: 'data', listener: ( /** * A chunk of response body's data. */ chunk: Buffer) => void): this; addListener(event: 'data', listener: ( /** * A chunk of response body's data. */ chunk: Buffer) => void): this; removeListener(event: 'data', listener: ( /** * A chunk of response body's data. */ chunk: Buffer) => void): this; /** * Indicates that response body has ended. Must be placed before 'data' event. */ on(event: 'end', listener: Function): this; once(event: 'end', listener: Function): this; addListener(event: 'end', listener: Function): this; removeListener(event: 'end', listener: Function): this; /** * Returns: * * `error` Error - Typically holds an error string identifying failure root cause. * * 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: Function): this; once(event: 'error', listener: Function): this; addListener(event: 'error', listener: Function): this; removeListener(event: 'error', listener: Function): this; /** * A `Record` representing the HTTP response headers. * The `headers` object is formatted as follows: * * * All header names are lowercased. * * Duplicates of `age`, `authorization`, `content-length`, `content-type`, * `etag`, `expires`, `from`, `host`, `if-modified-since`, `if-unmodified-since`, * `last-modified`, `location`, `max-forwards`, `proxy-authorization`, `referer`, * `retry-after`, `server`, or `user-agent` are discarded. * * `set-cookie` is always an array. Duplicates are added to the array. * * For duplicate `cookie` headers, the values are joined together with '; '. * * For all other headers, the values are joined together with ', '. */ headers: Record; /** * A `string` indicating the HTTP protocol version number. Typical values are '1.0' * or '1.1'. Additionally `httpVersionMajor` and `httpVersionMinor` are two * Integer-valued readable properties that return respectively the HTTP major and * minor version numbers. */ httpVersion: string; /** * An `Integer` indicating the HTTP protocol major version number. */ httpVersionMajor: number; /** * An `Integer` indicating the HTTP protocol minor version number. */ httpVersionMinor: number; /** * A `string[]` containing the raw HTTP response headers exactly as they were * received. The keys and values are in the same list. It is not a list of tuples. * So, the even-numbered offsets are key values, and the odd-numbered offsets are * the associated values. Header names are not lowercased, and duplicates are not * merged. */ rawHeaders: string[]; /** * An `Integer` indicating the HTTP response status code. */ statusCode: number; /** * A `string` representing the HTTP status message. */ statusMessage: string; } interface InputEvent { // Docs: https://electronjs.org/docs/api/structures/input-event /** * An array of modifiers of the event, can be `shift`, `control`, `ctrl`, `alt`, * `meta`, `command`, `cmd`, `isKeypad`, `isAutoRepeat`, `leftButtonDown`, * `middleButtonDown`, `rightButtonDown`, `capsLock`, `numLock`, `left`, `right`. */ modifiers?: Array<'shift' | 'control' | 'ctrl' | 'alt' | 'meta' | 'command' | 'cmd' | 'isKeypad' | 'isAutoRepeat' | 'leftButtonDown' | 'middleButtonDown' | 'rightButtonDown' | 'capsLock' | 'numLock' | 'left' | 'right'>; } interface IOCounters { // Docs: https://electronjs.org/docs/api/structures/io-counters /** * Then number of I/O other operations. */ otherOperationCount: number; /** * Then number of I/O other transfers. */ otherTransferCount: number; /** * The number of I/O read operations. */ readOperationCount: number; /** * The number of I/O read transfers. */ readTransferCount: number; /** * The number of I/O write operations. */ writeOperationCount: number; /** * The number of I/O write transfers. */ writeTransferCount: number; } interface IpcMain extends NodeJS.EventEmitter { // Docs: https://electronjs.org/docs/api/ipc-main /** * Adds a handler for an `invoke`able IPC. This handler will be called whenever a * renderer calls `ipcRenderer.invoke(channel, ...args)`. * * If `listener` returns a Promise, the eventual result of the promise will be * returned as a reply to the remote caller. Otherwise, the return value of the * listener will be used as the value of the reply. * * The `event` that is passed as the first argument to the handler is the same as * that passed to a regular event listener. It includes information about which * WebContents is the source of the invoke request. * * Errors thrown through `handle` in the main process are not transparent as they * are serialized and only the `message` property from the original error is * provided to the renderer process. Please refer to #24427 for details. */ handle(channel: string, listener: (event: IpcMainInvokeEvent, ...args: any[]) => (Promise) | (any)): void; /** * Handles a single `invoke`able IPC message, then removes the listener. See * `ipcMain.handle(channel, listener)`. */ handleOnce(channel: string, listener: (event: IpcMainInvokeEvent, ...args: any[]) => (Promise) | (any)): void; /** * Listens to `channel`, when a new message arrives `listener` would be called with * `listener(event, args...)`. */ on(channel: string, listener: (event: IpcMainEvent, ...args: any[]) => void): this; /** * Adds a one time `listener` function for the event. This `listener` is invoked * only the next time a message is sent to `channel`, after which it is removed. */ once(channel: string, listener: (event: IpcMainEvent, ...args: any[]) => void): this; /** * Removes listeners of the specified `channel`. */ removeAllListeners(channel?: string): this; /** * Removes any handler for `channel`, if present. */ removeHandler(channel: string): void; /** * Removes the specified `listener` from the listener array for the specified * `channel`. */ removeListener(channel: string, listener: (...args: any[]) => void): this; } interface IpcMainEvent extends Event { // Docs: https://electronjs.org/docs/api/structures/ipc-main-event /** * The ID of the renderer frame that sent this message */ frameId: number; /** * A list of MessagePorts that were transferred with this message */ ports: MessagePortMain[]; /** * The internal ID of the renderer process that sent this message */ processId: number; /** * A function that will send an IPC message to the renderer frame that sent the * original message that you are currently handling. You should use this method to * "reply" to the sent message in order to guarantee the reply will go to the * correct process and frame. */ reply: Function; /** * Set this to the value to be returned in a synchronous message */ returnValue: any; /** * Returns the `webContents` that sent the message */ sender: WebContents; /** * The frame that sent this message * */ readonly senderFrame: WebFrameMain; } interface IpcMainInvokeEvent extends Event { // Docs: https://electronjs.org/docs/api/structures/ipc-main-invoke-event /** * The ID of the renderer frame that sent this message */ frameId: number; /** * The internal ID of the renderer process that sent this message */ processId: number; /** * Returns the `webContents` that sent the message */ sender: WebContents; /** * The frame that sent this message * */ readonly senderFrame: WebFrameMain; } interface IpcRenderer extends NodeJS.EventEmitter { // Docs: https://electronjs.org/docs/api/ipc-renderer /** * Resolves with the response from the main process. * * Send a message to the main process via `channel` and expect a result * asynchronously. Arguments will be serialized with the Structured Clone * Algorithm, just like `window.postMessage`, so prototype chains will not be * included. Sending Functions, Promises, Symbols, WeakMaps, or WeakSets will throw * an exception. * * > **NOTE:** Sending non-standard JavaScript types such as DOM objects or special * Electron objects will throw an exception. * * Since the main process does not have support for DOM objects such as * `ImageBitmap`, `File`, `DOMMatrix` and so on, such objects cannot be sent over * Electron's IPC to the main process, as the main process would have no way to * decode them. Attempting to send such objects over IPC will result in an error. * * The main process should listen for `channel` with `ipcMain.handle()`. * * For example: * * If you need to transfer a `MessagePort` to the main process, use * `ipcRenderer.postMessage`. * * If you do not need a response to the message, consider using `ipcRenderer.send`. */ invoke(channel: string, ...args: any[]): Promise; /** * Listens to `channel`, when a new message arrives `listener` would be called with * `listener(event, args...)`. */ on(channel: string, listener: (event: IpcRendererEvent, ...args: any[]) => void): this; /** * Adds a one time `listener` function for the event. This `listener` is invoked * only the next time a message is sent to `channel`, after which it is removed. */ once(channel: string, listener: (event: IpcRendererEvent, ...args: any[]) => void): this; /** * Send a message to the main process, optionally transferring ownership of zero or * more `MessagePort` objects. * * The transferred `MessagePort` objects will be available in the main process as * `MessagePortMain` objects by accessing the `ports` property of the emitted * event. * * For example: * * For more information on using `MessagePort` and `MessageChannel`, see the MDN * documentation. */ postMessage(channel: string, message: any, transfer?: MessagePort[]): void; /** * Removes all listeners, or those of the specified `channel`. */ removeAllListeners(channel: string): this; /** * Removes the specified `listener` from the listener array for the specified * `channel`. */ removeListener(channel: string, listener: (...args: any[]) => void): this; /** * Send an asynchronous message to the main process via `channel`, along with * arguments. Arguments will be serialized with the Structured Clone Algorithm, * just like `window.postMessage`, so prototype chains will not be included. * Sending Functions, Promises, Symbols, WeakMaps, or WeakSets will throw an * exception. * * > **NOTE:** Sending non-standard JavaScript types such as DOM objects or special * Electron objects will throw an exception. * * Since the main process does not have support for DOM objects such as * `ImageBitmap`, `File`, `DOMMatrix` and so on, such objects cannot be sent over * Electron's IPC to the main process, as the main process would have no way to * decode them. Attempting to send such objects over IPC will result in an error. * * The main process handles it by listening for `channel` with the `ipcMain` * module. * * If you need to transfer a `MessagePort` to the main process, use * `ipcRenderer.postMessage`. * * If you want to receive a single response from the main process, like the result * of a method call, consider using `ipcRenderer.invoke`. */ send(channel: string, ...args: any[]): void; /** * The value sent back by the `ipcMain` handler. * * Send a message to the main process via `channel` and expect a result * synchronously. Arguments will be serialized with the Structured Clone Algorithm, * just like `window.postMessage`, so prototype chains will not be included. * Sending Functions, Promises, Symbols, WeakMaps, or WeakSets will throw an * exception. * * > **NOTE:** Sending non-standard JavaScript types such as DOM objects or special * Electron objects will throw an exception. * * Since the main process does not have support for DOM objects such as * `ImageBitmap`, `File`, `DOMMatrix` and so on, such objects cannot be sent over * Electron's IPC to the main process, as the main process would have no way to * decode them. Attempting to send such objects over IPC will result in an error. * * The main process handles it by listening for `channel` with `ipcMain` module, * and replies by setting `event.returnValue`. * * > :warning: **WARNING**: Sending a synchronous message will block the whole * renderer process until the reply is received, so use this method only as a last * resort. It's much better to use the asynchronous version, `invoke()`. */ sendSync(channel: string, ...args: any[]): any; /** * Sends a message to a window with `webContentsId` via `channel`. */ sendTo(webContentsId: number, channel: string, ...args: any[]): void; /** * Like `ipcRenderer.send` but the event will be sent to the `` element in * the host page instead of the main process. */ sendToHost(channel: string, ...args: any[]): void; } interface IpcRendererEvent extends Event { // Docs: https://electronjs.org/docs/api/structures/ipc-renderer-event /** * A list of MessagePorts that were transferred with this message */ ports: MessagePort[]; /** * The `IpcRenderer` instance that emitted the event originally */ sender: IpcRenderer; /** * The `webContents.id` that sent the message, you can call * `event.sender.sendTo(event.senderId, ...)` to reply to the message, see * ipcRenderer.sendTo for more information. This only applies to messages sent from * a different renderer. Messages sent directly from the main process set * `event.senderId` to `0`. */ senderId: number; } interface JumpListCategory { // Docs: https://electronjs.org/docs/api/structures/jump-list-category /** * Array of `JumpListItem` objects if `type` is `tasks` or `custom`, otherwise it * should be omitted. */ items?: JumpListItem[]; /** * Must be set if `type` is `custom`, otherwise it should be omitted. */ name?: string; /** * One of the following: */ type?: ('tasks' | 'frequent' | 'recent' | 'custom'); } interface JumpListItem { // Docs: https://electronjs.org/docs/api/structures/jump-list-item /** * The command line arguments when `program` is executed. Should only be set if * `type` is `task`. */ args?: string; /** * Description of the task (displayed in a tooltip). Should only be set if `type` * is `task`. Maximum length 260 characters. */ description?: 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; /** * 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; /** * 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 text to be displayed for the item in the Jump List. Should only be set if * `type` is `task`. */ title?: string; /** * One of the following: */ type?: ('task' | 'separator' | 'file'); /** * The working directory. Default is empty. */ workingDirectory?: string; } interface KeyboardEvent { // Docs: https://electronjs.org/docs/api/structures/keyboard-event /** * whether an Alt key was used in an accelerator to trigger the Event */ altKey?: boolean; /** * whether the Control key was used in an accelerator to trigger the Event */ ctrlKey?: boolean; /** * whether a meta key was used in an accelerator to trigger the Event */ metaKey?: boolean; /** * whether a Shift key was used in an accelerator to trigger the Event */ shiftKey?: boolean; /** * whether an accelerator was used to trigger the event as opposed to another user * gesture like mouse click */ triggeredByAccelerator?: boolean; } interface KeyboardInputEvent extends InputEvent { // Docs: https://electronjs.org/docs/api/structures/keyboard-input-event /** * The character that will be sent as the keyboard event. Should only use the valid * key codes in Accelerator. */ keyCode: string; /** * The type of the event, can be `keyDown`, `keyUp` or `char`. */ type: ('keyDown' | 'keyUp' | 'char'); } interface MemoryInfo { // Docs: https://electronjs.org/docs/api/structures/memory-info /** * 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. * * @platform win32 */ privateBytes?: number; /** * The amount of memory currently pinned to actual physical RAM. */ workingSetSize: number; } interface MemoryUsageDetails { // Docs: https://electronjs.org/docs/api/structures/memory-usage-details count: number; liveSize: number; size: number; } class Menu { // Docs: https://electronjs.org/docs/api/menu /** * Emitted when a popup is closed either manually or with `menu.closePopup()`. */ on(event: 'menu-will-close', listener: (event: Event) => void): this; once(event: 'menu-will-close', listener: (event: Event) => void): this; addListener(event: 'menu-will-close', listener: (event: Event) => void): this; removeListener(event: 'menu-will-close', listener: (event: Event) => void): this; /** * Emitted when `menu.popup()` is called. */ on(event: 'menu-will-show', listener: (event: Event) => void): this; once(event: 'menu-will-show', listener: (event: Event) => void): this; addListener(event: 'menu-will-show', listener: (event: Event) => void): this; removeListener(event: 'menu-will-show', listener: (event: Event) => void): this; /** * Menu */ constructor(); /** * Generally, the `template` is an array of `options` for constructing a MenuItem. * The usage can be referenced above. * * You can also attach other fields to the element of the `template` and they will * become properties of the constructed menu items. */ static buildFromTemplate(template: Array<(MenuItemConstructorOptions) | (MenuItem)>): Menu; /** * The application menu, if set, or `null`, if not set. * * **Note:** The returned `Menu` instance doesn't support dynamic addition or * removal of menu items. Instance properties can still be dynamically modified. */ static getApplicationMenu(): (Menu) | (null); /** * Sends the `action` to the first responder of application. This is used for * emulating default macOS menu behaviors. Usually you would use the `role` * property of a `MenuItem`. * * See the macOS Cocoa Event Handling Guide for more information on macOS' native * actions. * * @platform darwin */ static sendActionToFirstResponder(action: string): void; /** * Sets `menu` as the application menu on macOS. On Windows and Linux, the `menu` * will be set as each window's top menu. * * Also on Windows and Linux, you can use a `&` in the top-level item name to * indicate which letter should get a generated accelerator. For example, using * `&File` for the file menu would result in a generated `Alt-F` accelerator that * opens the associated menu. The indicated character in the button label then gets * an underline, and the `&` character is not displayed on the button label. * * In order to escape the `&` character in an item name, add a proceeding `&`. For * example, `&&File` would result in `&File` displayed on the button label. * * Passing `null` will suppress the default menu. On Windows and Linux, this has * the additional effect of removing the menu bar from the window. * * **Note:** The default menu will be created automatically if the app does not set * one. It contains standard items such as `File`, `Edit`, `View`, `Window` and * `Help`. */ static setApplicationMenu(menu: (Menu) | (null)): void; /** * Appends the `menuItem` to the menu. */ append(menuItem: MenuItem): void; /** * Closes the context menu in the `browserWindow`. */ closePopup(browserWindow?: BrowserWindow): void; /** * the item with the specified `id` */ getMenuItemById(id: string): (MenuItem) | (null); /** * Inserts the `menuItem` to the `pos` position of the menu. */ insert(pos: number, menuItem: MenuItem): void; /** * Pops up this menu as a context menu in the `BrowserWindow`. */ popup(options?: PopupOptions): void; /** * A `MenuItem[]` array containing the menu's items. * * Each `Menu` consists of multiple `MenuItem`s and each `MenuItem` can have a * submenu. */ items: MenuItem[]; } class MenuItem { // Docs: https://electronjs.org/docs/api/menu-item /** * MenuItem */ constructor(options: MenuItemConstructorOptions); /** * An `Accelerator` (optional) indicating the item's accelerator, if set. */ accelerator?: Accelerator; /** * A `boolean` indicating whether the item is checked, this property can be * dynamically changed. * * A `checkbox` menu item will toggle the `checked` property on and off when * selected. * * A `radio` menu item will turn on its `checked` property when clicked, and will * turn off that property for all adjacent items in the same menu. * * You can add a `click` function for additional behavior. */ checked: boolean; /** * A `Function` that is fired when the MenuItem receives a click event. It can be * called with `menuItem.click(event, focusedWindow, focusedWebContents)`. * * * `event` KeyboardEvent * * `focusedWindow` BrowserWindow * * `focusedWebContents` WebContents */ click: Function; /** * A `number` indicating an item's sequential unique id. */ commandId: number; /** * A `boolean` indicating whether the item is enabled, this property can be * dynamically changed. */ enabled: boolean; /** * A `NativeImage | string` (optional) indicating the item's icon, if set. */ icon?: (NativeImage) | (string); /** * A `string` indicating the item's unique id, this property can be dynamically * changed. */ id: string; /** * A `string` indicating the item's visible label. */ label: string; /** * A `Menu` that the item is a part of. */ menu: Menu; /** * A `boolean` indicating if the accelerator should be registered with the system * or just displayed. * * This property can be dynamically changed. */ registerAccelerator: boolean; /** * A `string` (optional) indicating the item's role, if set. Can be `undo`, `redo`, * `cut`, `copy`, `paste`, `pasteAndMatchStyle`, `delete`, `selectAll`, `reload`, * `forceReload`, `toggleDevTools`, `resetZoom`, `zoomIn`, `zoomOut`, * `toggleSpellChecker`, `togglefullscreen`, `window`, `minimize`, `close`, `help`, * `about`, `services`, `hide`, `hideOthers`, `unhide`, `quit`, `startSpeaking`, * `stopSpeaking`, `zoom`, `front`, `appMenu`, `fileMenu`, `editMenu`, `viewMenu`, * `shareMenu`, `recentDocuments`, `toggleTabBar`, `selectNextTab`, * `selectPreviousTab`, `mergeAllWindows`, `clearRecentDocuments`, * `moveTabToNewWindow` or `windowMenu` */ role?: ('undo' | 'redo' | 'cut' | 'copy' | 'paste' | 'pasteAndMatchStyle' | 'delete' | 'selectAll' | 'reload' | 'forceReload' | 'toggleDevTools' | 'resetZoom' | 'zoomIn' | 'zoomOut' | 'toggleSpellChecker' | 'togglefullscreen' | 'window' | 'minimize' | 'close' | 'help' | 'about' | 'services' | 'hide' | 'hideOthers' | 'unhide' | 'quit' | 'startSpeaking' | 'stopSpeaking' | 'zoom' | 'front' | 'appMenu' | 'fileMenu' | 'editMenu' | 'viewMenu' | 'shareMenu' | 'recentDocuments' | 'toggleTabBar' | 'selectNextTab' | 'selectPreviousTab' | 'mergeAllWindows' | 'clearRecentDocuments' | 'moveTabToNewWindow' | 'windowMenu'); /** * A `SharingItem` indicating the item to share when the `role` is `shareMenu`. * * This property can be dynamically changed. * * @platform darwin */ sharingItem: SharingItem; /** * A `string` indicating the item's sublabel. */ sublabel: string; /** * A `Menu` (optional) containing the menu item's submenu, if present. */ submenu?: Menu; /** * A `string` indicating the item's hover text. * * @platform darwin */ toolTip: string; /** * A `string` indicating the type of the item. Can be `normal`, `separator`, * `submenu`, `checkbox` or `radio`. */ type: ('normal' | 'separator' | 'submenu' | 'checkbox' | 'radio'); /** * An `Accelerator | null` indicating the item's user-assigned accelerator for the * menu item. * * **Note:** This property is only initialized after the `MenuItem` has been added * to a `Menu`. Either via `Menu.buildFromTemplate` or via * `Menu.append()/insert()`. Accessing before initialization will just return * `null`. * * @platform darwin */ readonly userAccelerator: (Accelerator) | (null); /** * A `boolean` indicating whether the item is visible, this property can be * dynamically changed. */ visible: boolean; } class MessageChannelMain extends NodeEventEmitter { // Docs: https://electronjs.org/docs/api/message-channel-main /** * A `MessagePortMain` property. */ port1: MessagePortMain; /** * A `MessagePortMain` property. */ port2: MessagePortMain; } class MessagePortMain extends NodeEventEmitter { // Docs: https://electronjs.org/docs/api/message-port-main /** * Emitted when the remote end of a MessagePortMain object becomes disconnected. */ on(event: 'close', listener: Function): this; once(event: 'close', listener: Function): this; addListener(event: 'close', listener: Function): this; removeListener(event: 'close', listener: Function): this; /** * Emitted when a MessagePortMain object receives a message. */ on(event: 'message', listener: (messageEvent: MessageEvent) => void): this; once(event: 'message', listener: (messageEvent: MessageEvent) => void): this; addListener(event: 'message', listener: (messageEvent: MessageEvent) => void): this; removeListener(event: 'message', listener: (messageEvent: MessageEvent) => void): this; /** * Disconnects the port, so it is no longer active. */ close(): void; /** * Sends a message from the port, and optionally, transfers ownership of objects to * other browsing contexts. */ postMessage(message: any, transfer?: MessagePortMain[]): void; /** * Starts the sending of messages queued on the port. Messages will be queued until * this method is called. */ start(): void; } interface MimeTypedBuffer { // Docs: https://electronjs.org/docs/api/structures/mime-typed-buffer /** * Charset of the buffer. */ charset?: string; /** * The actual Buffer content. */ data: Buffer; /** * MIME type of the buffer. */ mimeType?: string; } interface MouseInputEvent extends InputEvent { // Docs: https://electronjs.org/docs/api/structures/mouse-input-event /** * The button pressed, can be `left`, `middle`, `right`. */ button?: ('left' | 'middle' | 'right'); clickCount?: number; globalX?: number; globalY?: number; movementX?: number; movementY?: number; /** * The type of the event, can be `mouseDown`, `mouseUp`, `mouseEnter`, * `mouseLeave`, `contextMenu`, `mouseWheel` or `mouseMove`. */ type: ('mouseDown' | 'mouseUp' | 'mouseEnter' | 'mouseLeave' | 'contextMenu' | 'mouseWheel' | 'mouseMove'); x: number; y: number; } interface MouseWheelInputEvent extends MouseInputEvent { // Docs: https://electronjs.org/docs/api/structures/mouse-wheel-input-event accelerationRatioX?: number; accelerationRatioY?: number; canScroll?: boolean; deltaX?: number; deltaY?: number; hasPreciseScrollingDeltas?: boolean; /** * The type of the event, can be `mouseWheel`. */ type: ('mouseWheel'); wheelTicksX?: number; wheelTicksY?: number; } class NativeImage { // Docs: https://electronjs.org/docs/api/native-image /** * Creates an empty `NativeImage` instance. */ static createEmpty(): NativeImage; /** * Creates a new `NativeImage` instance from `buffer` that contains the raw bitmap * pixel data returned by `toBitmap()`. The specific format is platform-dependent. */ static createFromBitmap(buffer: Buffer, options: CreateFromBitmapOptions): NativeImage; /** * Creates a new `NativeImage` instance from `buffer`. Tries to decode as PNG or * JPEG first. */ static createFromBuffer(buffer: Buffer, options?: CreateFromBufferOptions): NativeImage; /** * Creates a new `NativeImage` instance from `dataURL`. */ static createFromDataURL(dataURL: string): NativeImage; /** * Creates a new `NativeImage` instance from the NSImage that maps to the given * image name. See `System Icons` for a list of possible values. * * The `hslShift` is applied to the image with the following rules: * * * `hsl_shift[0]` (hue): The absolute hue value for the image - 0 and 1 map to 0 * and 360 on the hue color wheel (red). * * `hsl_shift[1]` (saturation): A saturation shift for the image, with the * following key values: 0 = remove all color. 0.5 = leave unchanged. 1 = fully * saturate the image. * * `hsl_shift[2]` (lightness): A lightness shift for the image, with the * following key values: 0 = remove all lightness (make all pixels black). 0.5 = * leave unchanged. 1 = full lightness (make all pixels white). * * This means that `[-1, 0, 1]` will make the image completely white and `[-1, 1, * 0]` will make the image completely black. * * In some cases, the `NSImageName` doesn't match its string representation; one * example of this is `NSFolderImageName`, whose string representation would * actually be `NSFolder`. Therefore, you'll need to determine the correct string * representation for your image before passing it in. This can be done with the * following: * * `echo -e '#import \nint main() { NSLog(@"%@", SYSTEM_IMAGE_NAME); * }' | clang -otest -x objective-c -framework Cocoa - && ./test` * * where `SYSTEM_IMAGE_NAME` should be replaced with any value from this list. * * @platform darwin */ static createFromNamedImage(imageName: string, hslShift?: number[]): NativeImage; /** * Creates a new `NativeImage` instance from a file located at `path`. This method * returns an empty image if the `path` does not exist, cannot be read, or is not a * valid image. */ static createFromPath(path: string): NativeImage; /** * fulfilled with the file's thumbnail preview image, which is a NativeImage. * * @platform darwin,win32 */ static createThumbnailFromPath(path: string, maxSize: Size): Promise; /** * Add an image representation for a specific scale factor. This can be used to * explicitly add different scale factor representations to an image. This can be * called on empty images. */ addRepresentation(options: AddRepresentationOptions): void; /** * The cropped image. */ crop(rect: Rectangle): NativeImage; /** * The image's aspect ratio. * * If `scaleFactor` is passed, this will return the aspect ratio corresponding to * the image representation most closely matching the passed value. */ getAspectRatio(scaleFactor?: number): number; /** * A Buffer that contains the image's raw bitmap pixel data. * * The difference between `getBitmap()` and `toBitmap()` is that `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(options?: BitmapOptions): Buffer; /** * A Buffer that stores C pointer to underlying native handle of the image. On * macOS, a pointer to `NSImage` instance would be returned. * * Notice that the returned pointer is a weak pointer to the underlying native * image instead of a copy, so you _must_ ensure that the associated `nativeImage` * instance is kept around. * * @platform darwin */ getNativeHandle(): Buffer; /** * An array of all scale factors corresponding to representations for a given * nativeImage. */ getScaleFactors(): number[]; /** * If `scaleFactor` is passed, this will return the size corresponding to the image * representation most closely matching the passed value. */ getSize(scaleFactor?: number): Size; /** * Whether the image is empty. */ isEmpty(): boolean; /** * Whether the image is a template image. */ isTemplateImage(): boolean; /** * The resized image. * * If only the `height` or the `width` are specified then the current aspect ratio * will be preserved in the resized image. */ resize(options: ResizeOptions): NativeImage; /** * Marks the image as a template image. */ setTemplateImage(option: boolean): void; /** * A Buffer that contains a copy of the image's raw bitmap pixel data. */ toBitmap(options?: ToBitmapOptions): Buffer; /** * The data URL of the image. */ toDataURL(options?: ToDataURLOptions): string; /** * A Buffer that contains the image's `JPEG` encoded data. */ toJPEG(quality: number): Buffer; /** * A Buffer that contains the image's `PNG` encoded data. */ toPNG(options?: ToPNGOptions): Buffer; /** * A `boolean` property that determines whether the image is considered a template * image. * * Please note that this property only has an effect on macOS. * * @platform darwin */ isMacTemplateImage: boolean; } interface NativeTheme extends NodeJS.EventEmitter { // Docs: https://electronjs.org/docs/api/native-theme /** * Emitted when something in the underlying NativeTheme has changed. This normally * means that either the value of `shouldUseDarkColors`, * `shouldUseHighContrastColors` or `shouldUseInvertedColorScheme` has changed. You * will have to check them to determine which one has changed. */ on(event: 'updated', listener: Function): this; once(event: 'updated', listener: Function): this; addListener(event: 'updated', listener: Function): this; removeListener(event: 'updated', listener: Function): this; /** * A `boolean` indicating whether Chromium is in forced colors mode, controlled by * system accessibility settings. Currently, Windows high contrast is the only * system setting that triggers forced colors mode. * * @platform win32 */ readonly inForcedColorsMode: boolean; /** * A `boolean` for if the OS / Chromium currently has a dark mode enabled or is * being instructed to show a dark-style UI. If you want to modify this value you * should use `themeSource` below. * */ readonly shouldUseDarkColors: boolean; /** * A `boolean` for if the OS / Chromium currently has high-contrast mode enabled or * is being instructed to show a high-contrast UI. * * @platform darwin,win32 */ readonly shouldUseHighContrastColors: boolean; /** * A `boolean` for if the OS / Chromium currently has an inverted color scheme or * is being instructed to use an inverted color scheme. * * @platform darwin,win32 */ readonly shouldUseInvertedColorScheme: boolean; /** * A `string` property that can be `system`, `light` or `dark`. It is used to * override and supersede the value that Chromium has chosen to use internally. * * Setting this property to `system` will remove the override and everything will * be reset to the OS default. By default `themeSource` is `system`. * * Settings this property to `dark` will have the following effects: * * * `nativeTheme.shouldUseDarkColors` will be `true` when accessed * * Any UI Electron renders on Linux and Windows including context menus, * devtools, etc. will use the dark UI. * * Any UI the OS renders on macOS including menus, window frames, etc. will use * the dark UI. * * The `prefers-color-scheme` CSS query will match `dark` mode. * * The `updated` event will be emitted * * Settings this property to `light` will have the following effects: * * * `nativeTheme.shouldUseDarkColors` will be `false` when accessed * * Any UI Electron renders on Linux and Windows including context menus, * devtools, etc. will use the light UI. * * Any UI the OS renders on macOS including menus, window frames, etc. will use * the light UI. * * The `prefers-color-scheme` CSS query will match `light` mode. * * The `updated` event will be emitted * * The usage of this property should align with a classic "dark mode" state machine * in your application where the user has three options. * * * `Follow OS` --> `themeSource = 'system'` * * `Dark Mode` --> `themeSource = 'dark'` * * `Light Mode` --> `themeSource = 'light'` * * Your application should then always use `shouldUseDarkColors` to determine what * CSS to apply. */ themeSource: ('system' | 'light' | 'dark'); } interface Net { // Docs: https://electronjs.org/docs/api/net /** * Whether there is currently internet connection. * * A return value of `false` is a pretty strong indicator that the user won't be * able to connect to remote sites. However, a return value of `true` is * inconclusive; even if some link is up, it is uncertain whether a particular * connection attempt to a particular remote site will be successful. */ isOnline(): boolean; /** * Creates a `ClientRequest` instance using the provided `options` which are * directly forwarded to the `ClientRequest` constructor. The `net.request` method * would be used to issue both secure and insecure HTTP requests according to the * specified protocol scheme in the `options` object. */ request(options: (ClientRequestConstructorOptions) | (string)): ClientRequest; /** * A `boolean` property. Whether there is currently internet connection. * * A return value of `false` is a pretty strong indicator that the user won't be * able to connect to remote sites. However, a return value of `true` is * inconclusive; even if some link is up, it is uncertain whether a particular * connection attempt to a particular remote site will be successful. * */ readonly online: boolean; } interface NetLog { // Docs: https://electronjs.org/docs/api/net-log /** * resolves when the net log has begun recording. * * Starts recording network events to `path`. */ startLogging(path: string, options?: StartLoggingOptions): Promise; /** * resolves when the net log has been flushed to disk. * * Stops recording network events. If not called, net logging will automatically * end when app quits. */ stopLogging(): Promise; /** * A `boolean` property that indicates whether network logs are currently being * recorded. * */ readonly currentlyLogging: boolean; } interface NewWindowWebContentsEvent extends Event { // Docs: https://electronjs.org/docs/api/structures/new-window-web-contents-event newGuest?: BrowserWindow; } class Notification extends NodeEventEmitter { // Docs: https://electronjs.org/docs/api/notification on(event: 'action', listener: (event: Event, /** * The index of the action that was activated. */ index: number) => void): this; once(event: 'action', listener: (event: Event, /** * The index of the action that was activated. */ index: number) => void): this; addListener(event: 'action', listener: (event: Event, /** * The index of the action that was activated. */ index: number) => void): this; removeListener(event: 'action', listener: (event: Event, /** * The index of the action that was activated. */ index: number) => void): this; /** * Emitted when the notification is clicked by the user. */ on(event: 'click', listener: (event: Event) => void): this; once(event: 'click', listener: (event: Event) => void): this; addListener(event: 'click', listener: (event: Event) => void): this; removeListener(event: 'click', listener: (event: Event) => void): this; /** * Emitted when the notification is closed by manual intervention from the user. * * This event is not guaranteed to be emitted in all cases where the notification * is closed. */ on(event: 'close', listener: (event: Event) => void): this; once(event: 'close', listener: (event: Event) => void): this; addListener(event: 'close', listener: (event: Event) => void): this; removeListener(event: 'close', listener: (event: Event) => void): this; /** * Emitted when an error is encountered while creating and showing the native * notification. * * @platform win32 */ on(event: 'failed', listener: (event: Event, /** * The error encountered during execution of the `show()` method. */ error: string) => void): this; once(event: 'failed', listener: (event: Event, /** * The error encountered during execution of the `show()` method. */ error: string) => void): this; addListener(event: 'failed', listener: (event: Event, /** * The error encountered during execution of the `show()` method. */ error: string) => void): this; removeListener(event: 'failed', listener: (event: Event, /** * The error encountered during execution of the `show()` method. */ error: string) => void): this; /** * Emitted when the user clicks the "Reply" button on a notification with * `hasReply: true`. * * @platform darwin */ on(event: 'reply', listener: (event: Event, /** * The string the user entered into the inline reply field. */ reply: string) => void): this; once(event: 'reply', listener: (event: Event, /** * The string the user entered into the inline reply field. */ reply: string) => void): this; addListener(event: 'reply', listener: (event: Event, /** * The string the user entered into the inline reply field. */ reply: string) => void): this; removeListener(event: 'reply', listener: (event: Event, /** * The string the user entered into the inline reply field. */ reply: string) => void): this; /** * Emitted when the notification is shown to the user, note this could be fired * multiple times as a notification can be shown multiple times through the * `show()` method. */ on(event: 'show', listener: (event: Event) => void): this; once(event: 'show', listener: (event: Event) => void): this; addListener(event: 'show', listener: (event: Event) => void): this; removeListener(event: 'show', listener: (event: Event) => void): this; /** * Notification */ constructor(options?: NotificationConstructorOptions); /** * Whether or not desktop notifications are supported on the current system */ static isSupported(): boolean; /** * Dismisses the notification. */ close(): void; /** * Immediately shows the notification to the user, please note this means unlike * the HTML5 Notification implementation, instantiating a `new Notification` does * not immediately show it to the user, you need to call this method before the OS * will display it. * * If the notification has been shown before, this method will dismiss the * previously shown notification and create a new one with identical properties. */ show(): void; /** * A `NotificationAction[]` property representing the actions of the notification. */ actions: NotificationAction[]; /** * A `string` property representing the body of the notification. */ body: string; /** * A `string` property representing the close button text of the notification. */ closeButtonText: string; /** * A `boolean` property representing whether the notification has a reply action. */ hasReply: boolean; /** * A `string` property representing the reply placeholder of the notification. */ replyPlaceholder: string; /** * A `boolean` property representing whether the notification is silent. */ silent: boolean; /** * A `string` property representing the sound of the notification. */ sound: string; /** * A `string` property representing the subtitle of the notification. */ subtitle: string; /** * A `string` property representing the type of timeout duration for the * notification. Can be 'default' or 'never'. * * If `timeoutType` is set to 'never', the notification never expires. It stays * open until closed by the calling API or the user. * * @platform linux,win32 */ timeoutType: ('default' | 'never'); /** * A `string` property representing the title of the notification. */ title: string; /** * A `string` property representing the custom Toast XML of the notification. * * @platform win32 */ toastXml: string; /** * A `string` property representing the urgency level of the notification. Can be * 'normal', 'critical', or 'low'. * * Default is 'low' - see NotifyUrgency for more information. * * @platform linux */ urgency: ('normal' | 'critical' | 'low'); } interface NotificationAction { // Docs: https://electronjs.org/docs/api/structures/notification-action /** * The label for the given action. */ text?: string; /** * The type of action, can be `button`. */ type: ('button'); } interface NotificationResponse { // Docs: https://electronjs.org/docs/api/structures/notification-response /** * The identifier string of the action that the user selected. */ actionIdentifier: string; /** * The delivery date of the notification. */ date: number; /** * The unique identifier for this notification request. */ identifier: string; /** * A dictionary of custom information associated with the notification. */ userInfo: Record; /** * The text entered or chosen by the user. */ userText?: string; } interface PaymentDiscount { // Docs: https://electronjs.org/docs/api/structures/payment-discount /** * A string used to uniquely identify a discount offer for a product. */ identifier: string; /** * A string that identifies the key used to generate the signature. */ keyIdentifier: string; /** * A universally unique ID (UUID) value that you define. */ nonce: string; /** * A UTF-8 string representing the properties of a specific discount offer, * cryptographically signed. */ signature: string; /** * The date and time of the signature's creation in milliseconds, formatted in Unix * epoch time. */ timestamp: number; } interface Point { // Docs: https://electronjs.org/docs/api/structures/point x: number; y: number; } interface PostBody { // Docs: https://electronjs.org/docs/api/structures/post-body /** * The boundary used to separate multiple parts of the message. Only valid when * `contentType` is `multipart/form-data`. */ boundary?: string; /** * The `content-type` header used for the data. One of * `application/x-www-form-urlencoded` or `multipart/form-data`. Corresponds to the * `enctype` attribute of the submitted HTML form. */ contentType: string; /** * The post data to be sent to the new window. */ data: Array<(UploadRawData) | (UploadFile)>; } interface PowerMonitor extends NodeJS.EventEmitter { // Docs: https://electronjs.org/docs/api/power-monitor /** * Emitted when the system is about to lock the screen. * * @platform darwin,win32 */ on(event: 'lock-screen', listener: Function): this; once(event: 'lock-screen', listener: Function): this; addListener(event: 'lock-screen', listener: Function): this; removeListener(event: 'lock-screen', listener: Function): this; /** * Emitted when the system changes to AC power. * * @platform darwin,win32 */ on(event: 'on-ac', listener: Function): this; once(event: 'on-ac', listener: Function): this; addListener(event: 'on-ac', listener: Function): this; removeListener(event: 'on-ac', listener: Function): this; /** * Emitted when system changes to battery power. * * @platform darwin */ on(event: 'on-battery', listener: Function): this; once(event: 'on-battery', listener: Function): this; addListener(event: 'on-battery', listener: Function): this; removeListener(event: 'on-battery', listener: Function): this; /** * Emitted when system is resuming. */ on(event: 'resume', listener: Function): this; once(event: 'resume', listener: Function): this; addListener(event: 'resume', listener: Function): this; removeListener(event: 'resume', listener: Function): this; /** * Emitted when the system is about to reboot or shut down. If the event handler * invokes `e.preventDefault()`, Electron will attempt to delay system shutdown in * order for the app to exit cleanly. If `e.preventDefault()` is called, the app * should exit as soon as possible by calling something like `app.quit()`. * * @platform linux,darwin */ on(event: 'shutdown', listener: Function): this; once(event: 'shutdown', listener: Function): this; addListener(event: 'shutdown', listener: Function): this; removeListener(event: 'shutdown', listener: Function): this; /** * Emitted when the system is suspending. */ on(event: 'suspend', listener: Function): this; once(event: 'suspend', listener: Function): this; addListener(event: 'suspend', listener: Function): this; removeListener(event: 'suspend', listener: Function): this; /** * Emitted as soon as the systems screen is unlocked. * * @platform darwin,win32 */ on(event: 'unlock-screen', listener: Function): this; once(event: 'unlock-screen', listener: Function): this; addListener(event: 'unlock-screen', listener: Function): this; removeListener(event: 'unlock-screen', listener: Function): this; /** * Emitted when a login session is activated. See documentation for more * information. * * @platform darwin */ on(event: 'user-did-become-active', listener: Function): this; once(event: 'user-did-become-active', listener: Function): this; addListener(event: 'user-did-become-active', listener: Function): this; removeListener(event: 'user-did-become-active', listener: Function): this; /** * Emitted when a login session is deactivated. See documentation for more * information. * * @platform darwin */ on(event: 'user-did-resign-active', listener: Function): this; once(event: 'user-did-resign-active', listener: Function): this; addListener(event: 'user-did-resign-active', listener: Function): this; removeListener(event: 'user-did-resign-active', listener: Function): this; /** * The system's current state. Can be `active`, `idle`, `locked` or `unknown`. * * Calculate the system idle state. `idleThreshold` is the amount of time (in * seconds) before considered idle. `locked` is available on supported systems * only. */ getSystemIdleState(idleThreshold: number): ('active' | 'idle' | 'locked' | 'unknown'); /** * Idle time in seconds * * Calculate system idle time in seconds. */ getSystemIdleTime(): number; /** * Whether the system is on battery power. * * To monitor for changes in this property, use the `on-battery` and `on-ac` * events. */ isOnBatteryPower(): boolean; /** * A `boolean` property. True if the system is on battery power. * * See `powerMonitor.isOnBatteryPower()`. */ onBatteryPower: boolean; } interface PowerSaveBlocker { // Docs: https://electronjs.org/docs/api/power-save-blocker /** * Whether the corresponding `powerSaveBlocker` has started. */ isStarted(id: number): boolean; /** * The blocker ID that is assigned to this power blocker. * * Starts preventing the system from entering lower-power mode. Returns an integer * identifying the power save blocker. * * **Note:** `prevent-display-sleep` has higher precedence over * `prevent-app-suspension`. Only the highest precedence type takes effect. In * other words, `prevent-display-sleep` always takes precedence over * `prevent-app-suspension`. * * For example, an API calling A requests for `prevent-app-suspension`, and another * calling B requests for `prevent-display-sleep`. `prevent-display-sleep` will be * used until B stops its request. After that, `prevent-app-suspension` is used. */ start(type: 'prevent-app-suspension' | 'prevent-display-sleep'): number; /** * Stops the specified power save blocker. */ stop(id: number): void; } interface PrinterInfo { // Docs: https://electronjs.org/docs/api/structures/printer-info /** * a longer description of the printer's type. */ description: string; /** * the name of the printer as shown in Print Preview. */ displayName: string; /** * whether or not a given printer is set as the default printer on the OS. */ isDefault: boolean; /** * the name of the printer as understood by the OS. */ name: string; /** * an object containing a variable number of platform-specific printer information. */ options: Options; /** * the current status of the printer. */ status: number; } interface ProcessMemoryInfo { // Docs: https://electronjs.org/docs/api/structures/process-memory-info /** * The amount of memory not shared by other processes, such as JS heap or HTML * content in Kilobytes. */ private: number; /** * The amount of memory currently pinned to actual physical RAM in Kilobytes. * * @platform linux,win32 */ residentSet: number; /** * The amount of memory shared between processes, typically memory consumed by the * Electron code itself in Kilobytes. */ shared: number; } interface ProcessMetric { // Docs: https://electronjs.org/docs/api/structures/process-metric /** * CPU usage of the process. */ cpu: CPUUsage; /** * Creation time for this process. The time is represented as number of * milliseconds since epoch. Since the `pid` can be reused after a process dies, it * is useful to use both the `pid` and the `creationTime` to uniquely identify a * process. */ creationTime: number; /** * One of the following values: * * @platform win32 */ integrityLevel?: ('untrusted' | 'low' | 'medium' | 'high' | 'unknown'); /** * Memory information for the process. */ memory: MemoryInfo; /** * The name of the process. Examples for utility: `Audio Service`, `Content * Decryption Module Service`, `Network Service`, `Video Capture`, etc. */ name?: string; /** * Process id of the process. */ pid: number; /** * Whether the process is sandboxed on OS level. * * @platform darwin,win32 */ sandboxed?: boolean; /** * The non-localized name of the process. */ serviceName?: string; /** * Process type. One of the following values: */ type: ('Browser' | 'Tab' | 'Utility' | 'Zygote' | 'Sandbox helper' | 'GPU' | 'Pepper Plugin' | 'Pepper Plugin Broker' | 'Unknown'); } interface Product { // Docs: https://electronjs.org/docs/api/structures/product /** * The total size of the content, in bytes. */ contentLengths: number[]; /** * A string that identifies the version of the content. */ contentVersion: string; /** * 3 character code presenting a product's currency based on the ISO 4217 standard. */ currencyCode: string; /** * An array of discount offers */ discounts: ProductDiscount[]; /** * The total size of the content, in bytes. */ downloadContentLengths: number[]; /** * A string that identifies the version of the content. */ downloadContentVersion: string; /** * The locale formatted price of the product. */ formattedPrice: string; /** * The object containing introductory price information for the product. available * for the product. */ introductoryPrice?: ProductDiscount; /** * A boolean value that indicates whether the App Store has downloadable content * for this product. `true` if at least one file has been associated with the * product. */ isDownloadable: boolean; /** * A description of the product. */ localizedDescription: string; /** * The name of the product. */ localizedTitle: string; /** * The cost of the product in the local currency. */ price: number; /** * The string that identifies the product to the Apple App Store. */ productIdentifier: string; /** * The identifier of the subscription group to which the subscription belongs. */ subscriptionGroupIdentifier: string; /** * The period details for products that are subscriptions. */ subscriptionPeriod?: ProductSubscriptionPeriod; } interface ProductDiscount { // Docs: https://electronjs.org/docs/api/structures/product-discount /** * A string used to uniquely identify a discount offer for a product. */ identifier: string; /** * An integer that indicates the number of periods the product discount is * available. */ numberOfPeriods: number; /** * The payment mode for this product discount. Can be `payAsYouGo`, `payUpFront`, * or `freeTrial`. */ paymentMode: ('payAsYouGo' | 'payUpFront' | 'freeTrial'); /** * The discount price of the product in the local currency. */ price: number; /** * The locale used to format the discount price of the product. */ priceLocale: string; /** * An object that defines the period for the product discount. */ subscriptionPeriod?: ProductSubscriptionPeriod; /** * The type of discount offer. */ type: number; } interface ProductSubscriptionPeriod { // Docs: https://electronjs.org/docs/api/structures/product-subscription-period /** * The number of units per subscription period. */ numberOfUnits: number; /** * The increment of time that a subscription period is specified in. Can be `day`, * `week`, `month`, `year`. */ unit: ('day' | 'week' | 'month' | 'year'); } interface Protocol { // Docs: https://electronjs.org/docs/api/protocol /** * Whether the protocol was successfully intercepted * * Intercepts `scheme` protocol and uses `handler` as the protocol's new handler * which sends a `Buffer` as a response. */ interceptBufferProtocol(scheme: string, handler: (request: ProtocolRequest, callback: (response: (Buffer) | (ProtocolResponse)) => void) => void): boolean; /** * Whether the protocol was successfully intercepted * * Intercepts `scheme` protocol and uses `handler` as the protocol's new handler * which sends a file as a response. */ interceptFileProtocol(scheme: string, handler: (request: ProtocolRequest, callback: (response: (string) | (ProtocolResponse)) => void) => void): boolean; /** * Whether the protocol was successfully intercepted * * 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: (request: ProtocolRequest, callback: (response: ProtocolResponse) => void) => void): boolean; /** * Whether the protocol was successfully intercepted * * Same as `protocol.registerStreamProtocol`, except that it replaces an existing * protocol handler. */ interceptStreamProtocol(scheme: string, handler: (request: ProtocolRequest, callback: (response: (NodeJS.ReadableStream) | (ProtocolResponse)) => void) => void): boolean; /** * Whether the protocol was successfully intercepted * * Intercepts `scheme` protocol and uses `handler` as the protocol's new handler * which sends a `string` as a response. */ interceptStringProtocol(scheme: string, handler: (request: ProtocolRequest, callback: (response: (string) | (ProtocolResponse)) => void) => void): boolean; /** * Whether `scheme` is already intercepted. */ isProtocolIntercepted(scheme: string): boolean; /** * Whether `scheme` is already registered. */ isProtocolRegistered(scheme: string): boolean; /** * Whether the protocol was successfully registered * * Registers a protocol of `scheme` that will send a `Buffer` as a response. * * The usage is the same with `registerFileProtocol`, except that the `callback` * should be called with either a `Buffer` object or an object that has the `data` * property. * * Example: */ registerBufferProtocol(scheme: string, handler: (request: ProtocolRequest, callback: (response: (Buffer) | (ProtocolResponse)) => void) => void): boolean; /** * Whether the protocol was successfully registered * * Registers a protocol of `scheme` that will send a file as the response. The * `handler` will be called with `request` and `callback` where `request` is an * incoming request for the `scheme`. * * To handle the `request`, the `callback` should be called with either the file's * path or an object that has a `path` property, e.g. `callback(filePath)` or * `callback({ path: filePath })`. The `filePath` must be an absolute path. * * By default the `scheme` is treated like `http:`, which is parsed differently * from protocols that follow the "generic URI syntax" like `file:`. */ registerFileProtocol(scheme: string, handler: (request: ProtocolRequest, callback: (response: (string) | (ProtocolResponse)) => void) => void): boolean; /** * Whether the protocol was successfully registered * * Registers a protocol of `scheme` that will send an HTTP request as a response. * * The usage is the same with `registerFileProtocol`, except that the `callback` * should be called with an object that has the `url` property. */ registerHttpProtocol(scheme: string, handler: (request: ProtocolRequest, callback: (response: ProtocolResponse) => void) => void): boolean; /** * **Note:** This method can only be used before the `ready` event of the `app` * module gets emitted and can be called only once. * * Registers the `scheme` as standard, secure, bypasses content security policy for * resources, allows registering ServiceWorker, supports fetch API, and streaming * video/audio. Specify a privilege with the value of `true` to enable the * capability. * * An example of registering a privileged scheme, that bypasses Content Security * Policy: * * A standard scheme adheres to what RFC 3986 calls generic URI syntax. For example * `http` and `https` are standard schemes, while `file` is not. * * Registering a scheme as standard allows relative and absolute resources to be * resolved correctly when served. Otherwise the scheme will behave like the `file` * protocol, but without the ability to resolve relative URLs. * * For example when you load following page with custom protocol without * registering it as standard scheme, the image will not be loaded because * non-standard schemes can not recognize relative URLs: * * Registering a scheme as standard will allow access to files through the * FileSystem API. Otherwise the renderer will throw a security error for the * scheme. * * By default web storage apis (localStorage, sessionStorage, webSQL, indexedDB, * cookies) are disabled for non standard schemes. So in general if you want to * register a custom protocol to replace the `http` protocol, you have to register * it as a standard scheme. * * Protocols that use streams (http and stream protocols) should set `stream: * true`. The `