` is defined in the HTML file loaded by `loadURL()`, this property will be ignored.
* `icon` ([NativeImage](native-image.md) | string) (optional) - The window icon. On Windows it is
@@ -201,27 +205,30 @@ It creates a new `BrowserWindow` with native properties as set by the `options`.
* `parent` BrowserWindow (optional) - Specify parent window. Default is `null`.
* `modal` boolean (optional) - Whether this is a modal window. This only works when the
window is a child window. Default is `false`.
- * `acceptFirstMouse` boolean (optional) - Whether clicking an inactive window will also
- click through to the web contents. Default is `false` on macOS. This option is not
- configurable on other platforms.
+ * `acceptFirstMouse` boolean (optional) _macOS_ - Whether clicking an
+ inactive window will also click through to the web contents. Default is
+ `false` on macOS. This option is not configurable on other platforms.
* `disableAutoHideCursor` boolean (optional) - Whether to hide cursor when typing.
Default is `false`.
* `autoHideMenuBar` boolean (optional) - Auto hide the menu bar unless the `Alt`
key is pressed. Default is `false`.
- * `enableLargerThanScreen` boolean (optional) - Enable the window to be resized larger
- than screen. Only relevant for macOS, as other OSes allow
- larger-than-screen windows by default. Default is `false`.
+ * `enableLargerThanScreen` boolean (optional) _macOS_ - Enable the window to
+ be resized larger than screen. Only relevant for macOS, as other OSes
+ allow larger-than-screen windows by default. Default is `false`.
* `backgroundColor` string (optional) - The window's background color in Hex, RGB, RGBA, HSL, HSLA or named CSS color format. Alpha in #AARRGGBB format is supported if `transparent` is set to `true`. Default is `#FFF` (white). See [win.setBackgroundColor](browser-window.md#winsetbackgroundcolorbackgroundcolor) for more information.
* `hasShadow` boolean (optional) - Whether window should have a shadow. Default is `true`.
- * `opacity` number (optional) - Set the initial opacity of the window, between 0.0 (fully
- transparent) and 1.0 (fully opaque). This is only implemented on Windows and macOS.
+ * `opacity` number (optional) _macOS_ _Windows_ - Set the initial opacity of
+ the window, between 0.0 (fully transparent) and 1.0 (fully opaque). This
+ is only implemented on Windows and macOS.
* `darkTheme` boolean (optional) - Forces using dark theme for the window, only works on
some GTK+3 desktop environments. Default is `false`.
* `transparent` boolean (optional) - Makes the window [transparent](../tutorial/window-customization.md#create-transparent-windows).
Default is `false`. On Windows, does not work unless the window is frameless.
* `type` string (optional) - The type of window, default is normal window. See more about
this below.
- * `visualEffectState` string (optional) - Specify how the material appearance should reflect window activity state on macOS. Must be used with the `vibrancy` property. Possible values are:
+ * `visualEffectState` string (optional) _macOS_ - Specify how the material
+ appearance should reflect window activity state on macOS. Must be used
+ with the `vibrancy` property. Possible values are:
* `followWindow` - The backdrop should automatically appear active when the window is active, and inactive when it is not. This is the default.
* `active` - The backdrop should always appear active.
* `inactive` - The backdrop should always appear inactive.
@@ -229,36 +236,42 @@ It creates a new `BrowserWindow` with native properties as set by the `options`.
Default is `default`. Possible values are:
* `default` - Results in the standard title bar for macOS or Windows respectively.
* `hidden` - Results in a hidden title bar and a full size content window. On macOS, the window still has the standard window controls (βtraffic lightsβ) in the top left. On Windows, when combined with `titleBarOverlay: true` it will activate the Window Controls Overlay (see `titleBarOverlay` for more information), otherwise no window controls will be shown.
- * `hiddenInset` - Only on macOS, results in a hidden title bar with an alternative look
- where the traffic light buttons are slightly more inset from the window edge.
- * `customButtonsOnHover` - Only on macOS, results in a hidden title bar and a full size
- content window, the traffic light buttons will display when being hovered
- over in the top left of the window. **Note:** This option is currently
- experimental.
- * `trafficLightPosition` [Point](structures/point.md) (optional) - Set a
- custom position for the traffic light buttons in frameless windows.
- * `roundedCorners` boolean (optional) - Whether frameless window should have
- rounded corners on macOS. Default is `true`.
- * `fullscreenWindowTitle` boolean (optional) _Deprecated_ - Shows the title in
- the title bar in full screen mode on macOS for `hiddenInset` titleBarStyle.
- Default is `false`.
+ * `hiddenInset` _macOS_ - Only on macOS, results in a hidden title bar
+ with an alternative look where the traffic light buttons are slightly
+ more inset from the window edge.
+ * `customButtonsOnHover` _macOS_ - Only on macOS, results in a hidden
+ title bar and a full size content window, the traffic light buttons will
+ display when being hovered over in the top left of the window.
+ **Note:** This option is currently experimental.
+ * `trafficLightPosition` [Point](structures/point.md) (optional) _macOS_ -
+ Set a custom position for the traffic light buttons in frameless windows.
+ * `roundedCorners` boolean (optional) _macOS_ - Whether frameless window
+ should have rounded corners on macOS. Default is `true`. Setting this property
+ to `false` will prevent the window from being fullscreenable.
+ * `fullscreenWindowTitle` boolean (optional) _macOS_ _Deprecated_ - Shows
+ the title in the title bar in full screen mode on macOS for `hiddenInset`
+ titleBarStyle. Default is `false`.
* `thickFrame` boolean (optional) - Use `WS_THICKFRAME` style for frameless windows on
Windows, which adds standard window frame. Setting it to `false` will remove
window shadow and window animations. Default is `true`.
- * `vibrancy` string (optional) - Add a type of vibrancy effect to the window, only on
- macOS. Can be `appearance-based`, `light`, `dark`, `titlebar`, `selection`,
- `menu`, `popover`, `sidebar`, `medium-light`, `ultra-dark`, `header`, `sheet`, `window`, `hud`, `fullscreen-ui`, `tooltip`, `content`, `under-window`, or `under-page`. Please note that `appearance-based`, `light`, `dark`, `medium-light`, and `ultra-dark` are deprecated and have been removed in macOS Catalina (10.15).
- * `zoomToPageWidth` boolean (optional) - Controls the behavior on macOS when
- option-clicking the green stoplight button on the toolbar or by clicking the
- Window > Zoom menu item. If `true`, the window will grow to the preferred
- width of the web page when zoomed, `false` will cause it to zoom to the
- width of the screen. This will also affect the behavior when calling
- `maximize()` directly. Default is `false`.
- * `tabbingIdentifier` string (optional) - Tab group name, allows opening the
- window as a native tab on macOS 10.12+. Windows with the same tabbing
- identifier will be grouped together. This also adds a native new tab button
- to your window's tab bar and allows your `app` and window to receive the
- `new-window-for-tab` event.
+ * `vibrancy` string (optional) _macOS_ - Add a type of vibrancy effect to
+ the window, only on macOS. Can be `appearance-based`, `light`, `dark`,
+ `titlebar`, `selection`, `menu`, `popover`, `sidebar`, `medium-light`,
+ `ultra-dark`, `header`, `sheet`, `window`, `hud`, `fullscreen-ui`,
+ `tooltip`, `content`, `under-window`, or `under-page`. Please note that
+ `appearance-based`, `light`, `dark`, `medium-light`, and `ultra-dark` are
+ deprecated and have been removed in macOS Catalina (10.15).
+ * `zoomToPageWidth` boolean (optional) _macOS_ - Controls the behavior on
+ macOS when option-clicking the green stoplight button on the toolbar or by
+ clicking the Window > Zoom menu item. If `true`, the window will grow to
+ the preferred width of the web page when zoomed, `false` will cause it to
+ zoom to the width of the screen. This will also affect the behavior when
+ calling `maximize()` directly. Default is `false`.
+ * `tabbingIdentifier` string (optional) _macOS_ - Tab group name, allows
+ opening the window as a native tab on macOS 10.12+. Windows with the same
+ tabbing identifier will be grouped together. This also adds a native new
+ tab button to your window's tab bar and allows your `app` and window to
+ receive the `new-window-for-tab` event.
* `webPreferences` Object (optional) - Settings of web page's features.
* `devTools` boolean (optional) - Whether to enable DevTools. If it is set to `false`, can not use `BrowserWindow.webContents.openDevTools()` to open DevTools. Default is `true`.
* `nodeIntegration` boolean (optional) - Whether node integration is enabled.
@@ -310,8 +323,8 @@ It creates a new `BrowserWindow` with native properties as set by the `options`.
* `plugins` boolean (optional) - Whether plugins should be enabled. Default is `false`.
* `experimentalFeatures` boolean (optional) - Enables Chromium's experimental features.
Default is `false`.
- * `scrollBounce` boolean (optional) - Enables scroll bounce (rubber banding) effect on
- macOS. Default is `false`.
+ * `scrollBounce` boolean (optional) _macOS_ - Enables scroll bounce
+ (rubber banding) effect on macOS. Default is `false`.
* `enableBlinkFeatures` string (optional) - A list of feature strings separated by `,`, like
`CSSVariables,KeyboardEventKey` to enable. The full list of supported feature
strings can be found in the [RuntimeEnabledFeatures.json5][runtime-enabled-features]
@@ -413,13 +426,17 @@ Possible values are:
* On Linux, possible types are `desktop`, `dock`, `toolbar`, `splash`,
`notification`.
-* On macOS, possible types are `desktop`, `textured`.
+* On macOS, possible types are `desktop`, `textured`, `panel`.
* The `textured` type adds metal gradient appearance
- (`NSTexturedBackgroundWindowMask`).
+ (`NSWindowStyleMaskTexturedBackground`).
* The `desktop` type places the window at the desktop background window level
(`kCGDesktopWindowLevel - 1`). Note that desktop window will not receive
focus, keyboard or mouse events, but you can use `globalShortcut` to receive
input sparingly.
+ * The `panel` type enables the window to float on top of full-screened apps
+ by adding the `NSWindowStyleMaskNonactivatingPanel` style mask,normally
+ reserved for NSPanel, at runtime. Also, the window will appear on all
+ spaces (desktops).
* On Windows, possible type is `toolbar`.
### Instance Events
@@ -774,7 +791,7 @@ A `boolean` property that determines whether the window is in fullscreen mode.
A `boolean` property that determines whether the window is focusable.
-#### `win.visibleOnAllWorkspaces`
+#### `win.visibleOnAllWorkspaces` _macOS_ _Linux_
A `boolean` property that determines whether the window is visible on all workspaces.
@@ -811,13 +828,13 @@ 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.
-#### `win.minimizable`
+#### `win.minimizable` _macOS_ _Windows_
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`.
-#### `win.maximizable`
+#### `win.maximizable` _macOS_ _Windows_
A `boolean` property that determines whether the window can be manually maximized by user.
@@ -832,13 +849,13 @@ maximizes the window.
A `boolean` property that determines whether the window can be manually resized by user.
-#### `win.closable`
+#### `win.closable` _macOS_ _Windows_
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`.
-#### `win.movable`
+#### `win.movable` _macOS_ _Windows_
A `boolean` property that determines Whether the window can be moved by user.
@@ -1307,7 +1324,7 @@ win.setSheetOffset(toolbarRect.height)
Starts or stops flashing the window to attract user's attention.
-#### `win.setSkipTaskbar(skip)`
+#### `win.setSkipTaskbar(skip)` _macOS_ _Windows_
* `skip` boolean
@@ -1635,7 +1652,7 @@ Changes window icon.
Sets whether the window traffic light buttons should be visible.
-#### `win.setAutoHideMenuBar(hide)`
+#### `win.setAutoHideMenuBar(hide)` _Windows_ _Linux_
* `hide` boolean
@@ -1644,7 +1661,7 @@ 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.
-#### `win.isMenuBarAutoHide()`
+#### `win.isMenuBarAutoHide()` _Windows_ _Linux_
Returns `boolean` - Whether menu bar automatically hides itself.
@@ -1654,11 +1671,11 @@ Returns `boolean` - Whether menu bar automatically hides itself.
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.
-#### `win.isMenuBarVisible()`
+#### `win.isMenuBarVisible()` _Windows_ _Linux_
Returns `boolean` - Whether the menu bar is visible.
-#### `win.setVisibleOnAllWorkspaces(visible[, options])`
+#### `win.setVisibleOnAllWorkspaces(visible[, options])` _macOS_ _Linux_
* `visible` boolean
* `options` Object (optional)
@@ -1676,7 +1693,7 @@ Sets whether the window should be visible on all workspaces.
**Note:** This API does nothing on Windows.
-#### `win.isVisibleOnAllWorkspaces()`
+#### `win.isVisibleOnAllWorkspaces()` _macOS_ _Linux_
Returns `boolean` - Whether the window is visible on all workspaces.
diff --git a/docs/api/client-request.md b/docs/api/client-request.md
index 12f1ce1157e5b..81410a281816f 100644
--- a/docs/api/client-request.md
+++ b/docs/api/client-request.md
@@ -185,7 +185,7 @@ the first write will throw an error. If the passed value is not a `string`, its
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](https://source.chromium.org/chromium/chromium/src/+/master:services/network/public/cpp/header_util.cc;drc=1562cab3f1eda927938f8f4a5a91991fefde66d3;bpv=1;bpt=1;l=22).
+[Chromium's header utils](https://source.chromium.org/chromium/chromium/src/+/main:services/network/public/cpp/header_util.cc;drc=1562cab3f1eda927938f8f4a5a91991fefde66d3;bpv=1;bpt=1;l=22).
* `Content-Length`
* `Host`
diff --git a/docs/api/command-line-switches.md b/docs/api/command-line-switches.md
index f395379c063fa..d628b0549c1dd 100644
--- a/docs/api/command-line-switches.md
+++ b/docs/api/command-line-switches.md
@@ -274,8 +274,8 @@ By default inspector websocket url is available in stderr and under /json/list e
[ready]: app.md#event-ready
[play-silent-audio]: https://github.com/atom/atom/pull/9485/files
[debugging-main-process]: ../tutorial/debugging-main-process.md
-[logging]: https://source.chromium.org/chromium/chromium/src/+/master:base/logging.h
+[logging]: https://source.chromium.org/chromium/chromium/src/+/main:base/logging.h
[node-cli]: https://nodejs.org/api/cli.html
[play-silent-audio]: https://github.com/atom/atom/pull/9485/files
[ready]: app.md#event-ready
-[severities]: https://source.chromium.org/chromium/chromium/src/+/master:base/logging.h?q=logging::LogSeverity&ss=chromium
+[severities]: https://source.chromium.org/chromium/chromium/src/+/main:base/logging.h?q=logging::LogSeverity&ss=chromium
diff --git a/docs/api/content-tracing.md b/docs/api/content-tracing.md
index 91e3ca43a2560..ec8e3f7979701 100644
--- a/docs/api/content-tracing.md
+++ b/docs/api/content-tracing.md
@@ -36,7 +36,7 @@ Returns `Promise` - resolves with an array of category groups once all
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](https://chromium.googlesource.com/chromium/src/+/master/base/trace_event/builtin_categories.h).
+categories](https://chromium.googlesource.com/chromium/src/+/main/base/trace_event/builtin_categories.h).
> **NOTE:** Electron adds a non-default tracing category called `"electron"`.
> This category can be used to capture Electron-specific tracing events.
diff --git a/docs/api/context-bridge.md b/docs/api/context-bridge.md
index c816b43ab64d8..5d62220bd6070 100644
--- a/docs/api/context-bridge.md
+++ b/docs/api/context-bridge.md
@@ -35,7 +35,7 @@ page you load in your renderer executes code in this world.
When `contextIsolation` is enabled in your `webPreferences` (this is the default behavior since Electron 12.0.0), your `preload` scripts run in an
"Isolated World". You can read more about context isolation and what it affects in the
-[security](../tutorial/security.md#3-enable-context-isolation-for-remote-content) docs.
+[security](../tutorial/security.md#3-enable-context-isolation) docs.
## Methods
diff --git a/docs/api/environment-variables.md b/docs/api/environment-variables.md
index 09b12e3124fb6..ba3d5cf99e6de 100644
--- a/docs/api/environment-variables.md
+++ b/docs/api/environment-variables.md
@@ -139,8 +139,7 @@ green and non-draggable regions will be colored red to aid debugging.
### `ELECTRON_DEBUG_NOTIFICATIONS`
-Adds extra logs to [`Notification`](./notification.md) lifecycles on macOS to aid in debugging. Extra logging will be displayed when new Notifications are created or activated. They will also be displayed when common a
-tions are taken: a notification is shown, dismissed, its button is clicked, or it is replied to.
+Adds extra logs to [`Notification`](./notification.md) lifecycles on macOS to aid in debugging. Extra logging will be displayed when new Notifications are created or activated. They will also be displayed when common actions are taken: a notification is shown, dismissed, its button is clicked, or it is replied to.
Sample output:
diff --git a/docs/api/ipc-main.md b/docs/api/ipc-main.md
index f55e848c16398..e7c9800a25b50 100644
--- a/docs/api/ipc-main.md
+++ b/docs/api/ipc-main.md
@@ -1,3 +1,10 @@
+---
+title: "ipcMain"
+description: "Communicate asynchronously from the main process to renderer processes."
+slug: ipc-main
+hide_title: false
+---
+
# ipcMain
> Communicate asynchronously from the main process to renderer processes.
@@ -9,7 +16,9 @@ process, it handles asynchronous and synchronous messages sent from a renderer
process (web page). Messages sent from a renderer will be emitted to this
module.
-## Sending Messages
+For usage examples, check out the [IPC tutorial].
+
+## Sending messages
It is also possible to send messages from the main process to the renderer
process, see [webContents.send][web-contents-send] for more information.
@@ -21,36 +30,6 @@ process, see [webContents.send][web-contents-send] for more information.
coming from frames that aren't the main frame (e.g. iframes) whereas
`event.sender.send(...)` will always send to the main frame.
-An example of sending and handling messages between the render and main
-processes:
-
-```javascript
-// In main process.
-const { ipcMain } = require('electron')
-ipcMain.on('asynchronous-message', (event, arg) => {
- console.log(arg) // prints "ping"
- event.reply('asynchronous-reply', 'pong')
-})
-
-ipcMain.on('synchronous-message', (event, arg) => {
- console.log(arg) // prints "ping"
- event.returnValue = 'pong'
-})
-```
-
-```javascript
-// In renderer process (web page).
-// NB. Electron APIs are only accessible from preload, unless contextIsolation is disabled.
-// See https://www.electronjs.org/docs/tutorial/process-model#preload-scripts for more details.
-const { ipcRenderer } = require('electron')
-console.log(ipcRenderer.sendSync('synchronous-message', 'ping')) // prints "pong"
-
-ipcRenderer.on('asynchronous-reply', (event, arg) => {
- console.log(arg) // prints "pong"
-})
-ipcRenderer.send('asynchronous-message', 'ping')
-```
-
## Methods
The `ipcMain` module has the following method to listen for events:
@@ -59,7 +38,7 @@ The `ipcMain` module has the following method to listen for events:
* `channel` string
* `listener` Function
- * `event` IpcMainEvent
+ * `event` [IpcMainEvent][ipc-main-event]
* `...args` any[]
Listens to `channel`, when a new message arrives `listener` would be called with
@@ -69,7 +48,7 @@ Listens to `channel`, when a new message arrives `listener` would be called with
* `channel` string
* `listener` Function
- * `event` IpcMainEvent
+ * `event` [IpcMainEvent][ipc-main-event]
* `...args` any[]
Adds a one time `listener` function for the event. This `listener` is invoked
@@ -93,8 +72,8 @@ Removes listeners of the specified `channel`.
### `ipcMain.handle(channel, listener)`
* `channel` string
-* `listener` Function | any>
- * `event` IpcMainInvokeEvent
+* `listener` Function {
const result = await somePromise(...args)
return result
})
+```
-// Renderer process
+```js title='Renderer Process'
async () => {
const result = await ipcRenderer.invoke('my-invokable-ipc', arg1, arg2)
// ...
@@ -130,7 +109,7 @@ provided to the renderer process. Please refer to
### `ipcMain.handleOnce(channel, listener)`
* `channel` string
-* `listener` Function | any>
+* `listener` Function Communicate asynchronously from a renderer process to the main process.
@@ -9,7 +16,7 @@ methods so you can send synchronous and asynchronous messages from the render
process (web page) to the main process. You can also receive replies from the
main process.
-See [ipcMain](ipc-main.md) for code examples.
+See [IPC tutorial](../tutorial/ipc.md) for code examples.
## Methods
@@ -70,7 +77,7 @@ throw an exception.
> 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`](ipc-main.md) module.
+[`ipcMain`](./ipc-main.md) module.
If you need to transfer a [`MessagePort`][] to the main process, use [`ipcRenderer.postMessage`](#ipcrendererpostmessagechannel-message-transfer).
@@ -98,7 +105,7 @@ throw an exception.
> them. Attempting to send such objects over IPC will result in an error.
The main process should listen for `channel` with
-[`ipcMain.handle()`](ipc-main.md#ipcmainhandlechannel-listener).
+[`ipcMain.handle()`](./ipc-main.md#ipcmainhandlechannel-listener).
For example:
@@ -124,11 +131,11 @@ If you do not need a response to the message, consider using [`ipcRenderer.send`
* `channel` string
* `...args` any[]
-Returns `any` - The value sent back by the [`ipcMain`](ipc-main.md) handler.
+Returns `any` - The value sent back by the [`ipcMain`](./ipc-main.md) handler.
Send a message to the main process via `channel` and expect a result
synchronously. Arguments will be serialized with the [Structured Clone
-Algorithm][SCA], just like [`window.postMessage`][], so prototype chains will not be
+Algorithm][SCA], just like [`window.postMessage`], so prototype chains will not be
included. Sending Functions, Promises, Symbols, WeakMaps, or WeakSets will
throw an exception.
@@ -140,13 +147,13 @@ throw an exception.
> 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`](ipc-main.md) module,
+The main process handles it by listening for `channel` with [`ipcMain`](./ipc-main.md) 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()`](ipc-renderer.md#ipcrendererinvokechannel-args).
+> [`invoke()`](./ipc-renderer.md#ipcrendererinvokechannel-args).
### `ipcRenderer.postMessage(channel, message, [transfer])`
@@ -158,7 +165,7 @@ 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`](message-port-main.md) objects by accessing the `ports`
+[`MessagePortMain`](./message-port-main.md) objects by accessing the `ports`
property of the emitted event.
For example:
@@ -197,7 +204,7 @@ the host page instead of the main process.
## Event object
The documentation for the `event` object passed to the `callback` can be found
-in the [`ipc-renderer-event`](structures/ipc-renderer-event.md) structure docs.
+in the [`ipc-renderer-event`](./structures/ipc-renderer-event.md) structure docs.
[event-emitter]: https://nodejs.org/api/events.html#events_class_eventemitter
[SCA]: https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm
diff --git a/docs/api/native-image.md b/docs/api/native-image.md
index a4d969d094e27..0ad349bb081a4 100644
--- a/docs/api/native-image.md
+++ b/docs/api/native-image.md
@@ -149,7 +149,7 @@ console.log(image)
* `options` Object
* `width` Integer
* `height` Integer
- * `scaleFactor` Double (optional) - Defaults to 1.0.
+ * `scaleFactor` Number (optional) - Defaults to 1.0.
Returns `NativeImage`
@@ -162,7 +162,7 @@ pixel data returned by `toBitmap()`. The specific format is platform-dependent.
* `options` Object (optional)
* `width` Integer (optional) - Required for bitmap buffers.
* `height` Integer (optional) - Required for bitmap buffers.
- * `scaleFactor` Double (optional) - Defaults to 1.0.
+ * `scaleFactor` Number (optional) - Defaults to 1.0.
Returns `NativeImage`
@@ -225,7 +225,7 @@ The following methods are available on instances of the `NativeImage` class:
#### `image.toPNG([options])`
* `options` Object (optional)
- * `scaleFactor` Double (optional) - Defaults to 1.0.
+ * `scaleFactor` Number (optional) - Defaults to 1.0.
Returns `Buffer` - A [Buffer][buffer] that contains the image's `PNG` encoded data.
@@ -238,7 +238,7 @@ Returns `Buffer` - A [Buffer][buffer] that contains the image's `JPEG` encoded d
#### `image.toBitmap([options])`
* `options` Object (optional)
- * `scaleFactor` Double (optional) - Defaults to 1.0.
+ * `scaleFactor` Number (optional) - Defaults to 1.0.
Returns `Buffer` - A [Buffer][buffer] that contains a copy of the image's raw bitmap pixel
data.
@@ -246,14 +246,14 @@ data.
#### `image.toDataURL([options])`
* `options` Object (optional)
- * `scaleFactor` Double (optional) - Defaults to 1.0.
+ * `scaleFactor` Number (optional) - Defaults to 1.0.
Returns `string` - The data URL of the image.
#### `image.getBitmap([options])`
* `options` Object (optional)
- * `scaleFactor` Double (optional) - Defaults to 1.0.
+ * `scaleFactor` Number (optional) - Defaults to 1.0.
Returns `Buffer` - A [Buffer][buffer] that contains the image's raw bitmap pixel data.
@@ -276,7 +276,7 @@ Returns `boolean` - Whether the image is empty.
#### `image.getSize([scaleFactor])`
-* `scaleFactor` Double (optional) - Defaults to 1.0.
+* `scaleFactor` Number (optional) - Defaults to 1.0.
Returns [`Size`](structures/size.md).
@@ -317,20 +317,20 @@ will be preserved in the resized image.
#### `image.getAspectRatio([scaleFactor])`
-* `scaleFactor` Double (optional) - Defaults to 1.0.
+* `scaleFactor` Number (optional) - Defaults to 1.0.
-Returns `Float` - The image's aspect ratio.
+Returns `Number` - 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.
#### `image.getScaleFactors()`
-Returns `Float[]` - An array of all scale factors corresponding to representations for a given nativeImage.
+Returns `Number[]` - An array of all scale factors corresponding to representations for a given nativeImage.
#### `image.addRepresentation(options)`
* `options` Object
- * `scaleFactor` Double - The scale factor to add the image representation for.
+ * `scaleFactor` Number (optional) - The scale factor to add the image representation for.
* `width` Integer (optional) - Defaults to 0. Required if a bitmap buffer
is specified as `buffer`.
* `height` Integer (optional) - Defaults to 0. Required if a bitmap buffer
diff --git a/docs/api/protocol.md b/docs/api/protocol.md
index 7a2b334016191..8b0d2fbc89906 100644
--- a/docs/api/protocol.md
+++ b/docs/api/protocol.md
@@ -10,11 +10,12 @@ An example of implementing a protocol that has the same effect as the
```javascript
const { app, protocol } = require('electron')
const path = require('path')
+const url = require('url')
app.whenReady().then(() => {
protocol.registerFileProtocol('atom', (request, callback) => {
- const url = request.url.substr(7)
- callback({ path: path.normalize(`${__dirname}/${url}`) })
+ const filePath = url.fileURLToPath('file://' + request.url.slice('atom://'.length))
+ callback(filePath)
})
})
```
@@ -175,7 +176,7 @@ property.
* `handler` Function
* `request` [ProtocolRequest](structures/protocol-request.md)
* `callback` Function
- * `response` ProtocolResponse
+ * `response` [ProtocolResponse](structures/protocol-response.md)
Returns `boolean` - Whether the protocol was successfully registered
diff --git a/docs/api/push-notifications.md b/docs/api/push-notifications.md
new file mode 100644
index 0000000000000..cad396bc03d56
--- /dev/null
+++ b/docs/api/push-notifications.md
@@ -0,0 +1,48 @@
+# pushNotifications
+
+Process: [Main](../glossary.md#main-process)
+
+> Register for and receive notifications from remote push notification services
+
+For example, when registering for push notifications via Apple push notification services (APNS):
+
+```javascript
+const { pushNotifications, Notification } = require('electron')
+
+pushNotifications.registerForAPNSNotifications().then((token) => {
+ // forward token to your remote notification server
+})
+
+pushNotifications.on('received-apns-notification', (event, userInfo) => {
+ // generate a new Notification object with the relevant userInfo fields
+})
+```
+
+## Events
+
+The `pushNotification` module emits the following events:
+
+#### Event: 'received-apns-notification' _macOS_
+
+Returns:
+
+* `userInfo` Record
+
+Emitted when the app receives a remote notification while running.
+See: https://developer.apple.com/documentation/appkit/nsapplicationdelegate/1428430-application?language=objc
+
+## Methods
+
+The `pushNotification` module has the following methods:
+
+### `pushNotifications.registerForAPNSNotifications()` _macOS_
+
+Returns `Promise`
+
+Registers the app with Apple Push Notification service (APNS) to receive [Badge, Sound, and Alert](https://developer.apple.com/documentation/appkit/sremotenotificationtype?language=objc) notifications. If registration is successful, the promise will be resolved with the APNS device token. Otherwise, the promise will be rejected with an error message.
+See: https://developer.apple.com/documentation/appkit/nsapplication/1428476-registerforremotenotificationtyp?language=objc
+
+### `pushNotifications.unregisterForAPNSNotifications()` _macOS_
+
+Unregisters the app from notifications received from APNS.
+See: https://developer.apple.com/documentation/appkit/nsapplication/1428747-unregisterforremotenotifications?language=objc
diff --git a/docs/api/safe-storage.md b/docs/api/safe-storage.md
index e96c18bbf0795..471351c9c1cd3 100644
--- a/docs/api/safe-storage.md
+++ b/docs/api/safe-storage.md
@@ -18,8 +18,8 @@ The `safeStorage` module has the following methods:
Returns `boolean` - Whether encryption is available.
-On Linux, returns true if the secret key is
-available. On MacOS, returns true if Keychain is available.
+On Linux, returns true if the app has emitted the `ready` event and the secret key is available.
+On MacOS, returns true if Keychain is available.
On Windows, returns true once the app has emitted the `ready` event.
### `safeStorage.encryptString(plainText)`
diff --git a/docs/api/session.md b/docs/api/session.md
index 8bb1ad5ab3c5c..ee1c3e7a8b347 100644
--- a/docs/api/session.md
+++ b/docs/api/session.md
@@ -253,9 +253,11 @@ Returns:
* `device` [HIDDevice[]](structures/hid-device.md)
* `frame` [WebFrameMain](web-frame-main.md)
-Emitted when a new HID device becomes available. For example, when a new USB device is plugged in.
-
-This event will only be emitted after `navigator.hid.requestDevice` has been called and `select-hid-device` has fired.
+Emitted after `navigator.hid.requestDevice` has been called and
+`select-hid-device` has fired if a new device becomes available before
+the callback from `select-hid-device` is called. This event is intended for
+use when using a UI to ask users to pick a device so that the UI can be updated
+with the newly added device.
#### Event: 'hid-device-removed'
@@ -266,9 +268,24 @@ Returns:
* `device` [HIDDevice[]](structures/hid-device.md)
* `frame` [WebFrameMain](web-frame-main.md)
-Emitted when a HID device has been removed. For example, this event will fire when a USB device is unplugged.
+Emitted after `navigator.hid.requestDevice` has been called and
+`select-hid-device` has fired if a device has been removed before the callback
+from `select-hid-device` is called. This event is intended for use when using
+a UI to ask users to pick a device so that the UI can be updated to remove the
+specified device.
+
+#### Event: 'hid-device-revoked'
+
+Returns:
+
+* `event` Event
+* `details` Object
+ * `device` [HIDDevice[]](structures/hid-device.md)
+ * `origin` string (optional) - The origin that the device has been revoked from.
-This event will only be emitted after `navigator.hid.requestDevice` has been called and `select-hid-device` has fired.
+Emitted after `HIDDevice.forget()` has been called. This event can be used
+to help maintain persistent storage of permissions when
+`setDevicePermissionHandler` is used.
#### Event: 'select-serial-port'
@@ -348,7 +365,11 @@ Returns:
* `port` [SerialPort](structures/serial-port.md)
* `webContents` [WebContents](web-contents.md)
-Emitted after `navigator.serial.requestPort` has been called and `select-serial-port` has fired if a new serial port becomes available. For example, this event will fire when a new USB device is plugged in.
+Emitted after `navigator.serial.requestPort` has been called and
+`select-serial-port` has fired if a new serial port becomes available before
+the callback from `select-serial-port` is called. This event is intended for
+use when using a UI to ask users to pick a port so that the UI can be updated
+with the newly added port.
#### Event: 'serial-port-removed'
@@ -358,7 +379,11 @@ Returns:
* `port` [SerialPort](structures/serial-port.md)
* `webContents` [WebContents](web-contents.md)
-Emitted after `navigator.serial.requestPort` has been called and `select-serial-port` has fired if a serial port has been removed. For example, this event will fire when a USB device is unplugged.
+Emitted after `navigator.serial.requestPort` has been called and
+`select-serial-port` has fired if a serial port has been removed before the
+callback from `select-serial-port` is called. This event is intended for use
+when using a UI to ask users to pick a port so that the UI can be updated
+to remove the specified port.
### Instance Methods
@@ -567,7 +592,7 @@ the original network configuration.
* `errorCode` Integer - Error code.
* `callback` Function
* `verificationResult` Integer - Value can be one of certificate error codes
- from [here](https://source.chromium.org/chromium/chromium/src/+/master:net/base/net_error_list.h).
+ from [here](https://source.chromium.org/chromium/chromium/src/+/main:net/base/net_error_list.h).
Apart from the certificate error codes, the following special codes can be used.
* `0` - Indicates success and disables Certificate Transparency verification.
* `-2` - Indicates failure.
@@ -610,7 +635,7 @@ win.webContents.session.setCertificateVerifyProc((request, callback) => {
* `notifications` - Request notification creation and the ability to display them in the user's system tray.
* `midi` - Request MIDI access in the `webmidi` API.
* `midiSysex` - Request the use of system exclusive messages in the `webmidi` API.
- * `pointerLock` - Request to directly interpret mouse movements as an input method. Click [here](https://developer.mozilla.org/en-US/docs/Web/API/Pointer_Lock_API) to know more.
+ * `pointerLock` - Request to directly interpret mouse movements as an input method. Click [here](https://developer.mozilla.org/en-US/docs/Web/API/Pointer_Lock_API) to know more. These requests always appear to originate from the main frame.
* `fullscreen` - Request for the app to enter fullscreen mode.
* `openExternal` - Request to open links in external applications.
* `unknown` - An unrecognized permission request
@@ -680,7 +705,6 @@ session.fromPartition('some-partition').setPermissionCheckHandler((webContents,
* `deviceType` string - The type of device that permission is being requested on, can be `hid` or `serial`.
* `origin` string - The origin URL of the device permission check.
* `device` [HIDDevice](structures/hid-device.md) | [SerialPort](structures/serial-port.md)- the device that permission is being requested for.
- * `frame` [WebFrameMain](web-frame-main.md) - WebFrameMain checking the device permission.
Sets the handler which can be used to respond to device permission checks for the `session`.
Returning `true` will allow the device to be permitted and `false` will reject it.
@@ -688,8 +712,8 @@ To clear the handler, call `setDevicePermissionHandler(null)`.
This handler can be used to provide default permissioning to devices without first calling for permission
to devices (eg via `navigator.hid.requestDevice`). If this handler is not defined, the default device
permissions as granted through device selection (eg via `navigator.hid.requestDevice`) will be used.
-Additionally, the default behavior of Electron is to store granted device permision through the lifetime
-of the corresponding WebContents. If longer term storage is needed, a developer can store granted device
+Additionally, the default behavior of Electron is to store granted device permision in memory.
+If longer term storage is needed, a developer can store granted device
permissions (eg when handling the `select-hid-device` event) and then read from that storage with `setDevicePermissionHandler`.
```javascript
@@ -745,6 +769,71 @@ app.whenReady().then(() => {
})
```
+#### `ses.setBluetoothPairingHandler(handler)` _Windows_ _Linux_
+
+* `handler` Function | null
+ * `details` Object
+ * `deviceId` string
+ * `pairingKind` string - The type of pairing prompt being requested.
+ One of the following values:
+ * `confirm`
+ This prompt is requesting confirmation that the Bluetooth device should
+ be paired.
+ * `confirmPin`
+ This prompt is requesting confirmation that the provided PIN matches the
+ pin displayed on the device.
+ * `providePin`
+ This prompt is requesting that a pin be provided for the device.
+ * `frame` [WebFrameMain](web-frame-main.md)
+ * `pin` string (optional) - The pin value to verify if `pairingKind` is `confirmPin`.
+ * `callback` Function
+ * `response` Object
+ * `confirmed` boolean - `false` should be passed in if the dialog is canceled.
+ If the `pairingKind` is `confirm` or `confirmPin`, this value should indicate
+ if the pairing is confirmed. If the `pairingKind` is `providePin` the value
+ should be `true` when a value is provided.
+ * `pin` string | null (optional) - When the `pairingKind` is `providePin`
+ this value should be the required pin for the Bluetooth device.
+
+Sets a handler to respond to Bluetooth pairing requests. This handler
+allows developers to handle devices that require additional validation
+before pairing. When a handler is not defined, any pairing on Linux or Windows
+that requires additional validation will be automatically cancelled.
+macOS does not require a handler because macOS handles the pairing
+automatically. To clear the handler, call `setBluetoothPairingHandler(null)`.
+
+```javascript
+
+const { app, BrowserWindow, ipcMain, session } = require('electron')
+
+let bluetoothPinCallback = null
+
+function createWindow () {
+ const mainWindow = new BrowserWindow({
+ webPreferences: {
+ preload: path.join(__dirname, 'preload.js')
+ }
+ })
+}
+
+// Listen for an IPC message from the renderer to get the response for the Bluetooth pairing.
+ipcMain.on('bluetooth-pairing-response', (event, response) => {
+ bluetoothPinCallback(response)
+})
+
+mainWindow.webContents.session.setBluetoothPairingHandler((details, callback) => {
+ bluetoothPinCallback = callback
+ // Send a IPC message to the renderer to prompt the user to confirm the pairing.
+ // Note that this will require logic in the renderer to handle this message and
+ // display a prompt to the user.
+ mainWindow.webContents.send('bluetooth-pairing-request', details)
+})
+
+app.whenReady().then(() => {
+ createWindow()
+})
+```
+
#### `ses.clearHostResolverCache()`
Returns `Promise` - Resolves when the operation is complete.
@@ -908,7 +997,7 @@ Returns `string[]` - An array of language codes the spellchecker is enabled for.
will fallback to using `en-US`. By default on launch if this setting is an empty list Electron will try to populate this
setting with the current OS locale. This setting is persisted across restarts.
-**Note:** On macOS the OS spellchecker is used and has its own list of languages. This API is a no-op on macOS.
+**Note:** On macOS the OS spellchecker is used and has its own list of languages. On macOS, this API will return whichever languages have been configured by the OS.
#### `ses.setSpellCheckerDictionaryDownloadURL(url)`
@@ -1025,7 +1114,7 @@ is emitted.
#### `ses.getStoragePath()`
-A `string | null` indicating the absolute file system path where data for this
+Returns `string | null` - The absolute file system path where data for this
session is persisted on disk. For in memory sessions this returns `null`.
### Instance Properties
diff --git a/docs/api/structures/protocol-response.md b/docs/api/structures/protocol-response.md
index a20873ebb3b46..21a863240fabb 100644
--- a/docs/api/structures/protocol-response.md
+++ b/docs/api/structures/protocol-response.md
@@ -31,4 +31,4 @@
* `uploadData` [ProtocolResponseUploadData](protocol-response-upload-data.md) (optional) - The data used as upload data. This is only
used for URL responses when `method` is `"POST"`.
-[net-error]: https://source.chromium.org/chromium/chromium/src/+/master:net/base/net_error_list.h
+[net-error]: https://source.chromium.org/chromium/chromium/src/+/main:net/base/net_error_list.h
diff --git a/docs/api/structures/trace-config.md b/docs/api/structures/trace-config.md
index d5b3795f228fd..4160b7121ca57 100644
--- a/docs/api/structures/trace-config.md
+++ b/docs/api/structures/trace-config.md
@@ -8,7 +8,7 @@
* `enable_argument_filter` boolean (optional) - if true, filter event data
according to a specific list of events that have been manually vetted to not
include any PII. See [the implementation in
- Chromium][trace_event_args_whitelist.cc] for specifics.
+ Chromium][trace_event_args_allowlist.cc] for specifics.
* `included_categories` string[] (optional) - a list of tracing categories to
include. Can include glob-like patterns using `*` at the end of the category
name. See [tracing categories][] for the list of categories.
@@ -45,7 +45,7 @@ An example TraceConfig that roughly matches what Chrome DevTools records:
}
```
-[tracing categories]: https://chromium.googlesource.com/chromium/src/+/master/base/trace_event/builtin_categories.h
-[memory-infra docs]: https://chromium.googlesource.com/chromium/src/+/master/docs/memory-infra/memory_infra_startup_tracing.md#the-advanced-way
-[trace_event_args_whitelist.cc]: https://chromium.googlesource.com/chromium/src/+/master/services/tracing/public/cpp/trace_event_args_whitelist.cc
+[tracing categories]: https://chromium.googlesource.com/chromium/src/+/main/base/trace_event/builtin_categories.h
+[memory-infra docs]: https://chromium.googlesource.com/chromium/src/+/main/docs/memory-infra/memory_infra_startup_tracing.md#the-advanced-way
+[trace_event_args_allowlist.cc]: https://chromium.googlesource.com/chromium/src/+/main/services/tracing/public/cpp/trace_event_args_allowlist.cc
[histogram]: https://chromium.googlesource.com/chromium/src.git/+/HEAD/tools/metrics/histograms/README.md
diff --git a/docs/api/system-preferences.md b/docs/api/system-preferences.md
index 69124edda9f87..6c0a6a388fb46 100644
--- a/docs/api/system-preferences.md
+++ b/docs/api/system-preferences.md
@@ -183,11 +183,11 @@ Some popular `key` and `type`s are:
* `NSPreferredWebServices`: `dictionary`
* `NSUserDictionaryReplacementItems`: `array`
-### `systemPreferences.setUserDefault(key, type, value)` _macOS_
+### `systemPreferences.setUserDefault(key, type, value)` _macOS_
* `key` string
-* `type` string - Can be `string`, `boolean`, `integer`, `float`, `double`, `url`, `array` or `dictionary`.
-* `value` string
+* `type` Type - Can be `string`, `boolean`, `integer`, `float`, `double`, `url`, `array` or `dictionary`.
+* `value` UserDefaultTypes[Type]
Set the value of `key` in `NSUserDefaults`.
diff --git a/docs/api/tray.md b/docs/api/tray.md
index d8dac322f769d..0cb995ce2fb3d 100644
--- a/docs/api/tray.md
+++ b/docs/api/tray.md
@@ -25,15 +25,20 @@ app.whenReady().then(() => {
})
```
-__Platform limitations:__
+__Platform Considerations__
+
+If you want to keep exact same behaviors on all platforms, you should not
+rely on the `click` event; instead, always attach a context menu to the tray icon.
+
+__Linux__
-* On Linux the app indicator will be used if it is supported, otherwise
- `GtkStatusIcon` will be used instead.
* On Linux distributions that only have app indicator support, you have to
install `libappindicator1` to make the tray icon work.
+* The app indicator will be used if it is supported, otherwise
+ `GtkStatusIcon` will be used instead.
* App indicator will only be shown when it has a context menu.
-* When app indicator is used on Linux, the `click` event is ignored.
-* On Linux in order for changes made to individual `MenuItem`s to take effect,
+* The `click` event is ignored when using the app indicator.
+* In order for changes made to individual `MenuItem`s to take effect,
you have to call `setContextMenu` again. For example:
```javascript
@@ -55,10 +60,16 @@ app.whenReady().then(() => {
})
```
-* On Windows it is recommended to use `ICO` icons to get best visual effects.
+__MacOS__
-If you want to keep exact same behaviors on all platforms, you should not
-rely on the `click` event and always attach a context menu to the tray icon.
+* Icons passed to the Tray constructor should be [Template Images](native-image.md#template-image).
+* To make sure your icon isn't grainy on retina monitors, be sure your `@2x` image is 144dpi.
+* If you are bundling your application (e.g., with webpack for development), be sure that the file names are not being mangled or hashed. The filename needs to end in Template, and the `@2x` image needs to have the same filename as the standard image, or MacOS will not magically invert your image's colors or use the high density image.
+* 16x16 (72dpi) and 32x32@2x (144dpi) work well for most icons.
+
+__Windows__
+
+* It is recommended to use `ICO` icons to get best visual effects.
### `new Tray(image, [guid])`
diff --git a/docs/api/web-contents.md b/docs/api/web-contents.md
index d4a1233c5976a..37e5137340a23 100644
--- a/docs/api/web-contents.md
+++ b/docs/api/web-contents.md
@@ -35,7 +35,7 @@ for all windows, webviews, opened devtools, and devtools extension background pa
### `webContents.getFocusedWebContents()`
-Returns `WebContents` - The web contents that is focused in this application, otherwise
+Returns `WebContents` | null - The web contents that is focused in this application, otherwise
returns `null`.
### `webContents.fromId(id)`
@@ -45,6 +45,13 @@ returns `null`.
Returns `WebContents` | undefined - A WebContents instance with the given ID, or
`undefined` if there is no WebContents associated with the given ID.
+### `webContents.fromFrame(frame)`
+
+* `frame` WebFrameMain
+
+Returns `WebContents` | undefined - A WebContents instance with the given WebFrameMain, or
+`undefined` if there is no WebContents associated with the given WebFrameMain.
+
### `webContents.fromDevToolsTargetId(targetId)`
* `targetId` string - The Chrome DevTools Protocol [TargetID](https://chromedevtools.github.io/devtools-protocol/tot/Target/#type-TargetID) associated with the WebContents instance.
@@ -92,7 +99,7 @@ Returns:
* `frameRoutingId` Integer
This event is like `did-finish-load` but emitted when the load failed.
-The full list of error codes and their meaning is available [here](https://source.chromium.org/chromium/chromium/src/+/master:net/base/net_error_list.h).
+The full list of error codes and their meaning is available [here](https://source.chromium.org/chromium/chromium/src/+/main:net/base/net_error_list.h).
#### Event: 'did-fail-provisional-load'
@@ -820,9 +827,6 @@ This event can be used to configure `webPreferences` for the `webContents`
of a `` before it's loaded, and provides the ability to set settings
that can't be set via `` attributes.
-**Note:** The specified `preload` script option will appear as `preloadURL`
-(not `preload`) in the `webPreferences` object emitted with this event.
-
#### Event: 'did-attach-webview'
Returns:
@@ -865,6 +869,8 @@ Returns:
Emitted when the renderer process sends an asynchronous message via `ipcRenderer.send()`.
+See also [`webContents.ipc`](#contentsipc-readonly), which provides an [`IpcMain`](ipc-main.md)-like interface for responding to IPC messages specifically from this WebContents.
+
#### Event: 'ipc-message-sync'
Returns:
@@ -875,6 +881,8 @@ Returns:
Emitted when the renderer process sends a synchronous message via `ipcRenderer.sendSync()`.
+See also [`webContents.ipc`](#contentsipc-readonly), which provides an [`IpcMain`](ipc-main.md)-like interface for responding to IPC messages specifically from this WebContents.
+
#### Event: 'preferred-size-changed'
Returns:
@@ -1431,7 +1439,7 @@ Returns `Promise` - Resolves with a [`PrinterInfo[]`](structures/
* `header` string (optional) - string to be printed as page header.
* `footer` string (optional) - string to be printed as page footer.
* `pageSize` string | Size (optional) - Specify page size of the printed document. Can be `A3`,
- `A4`, `A5`, `Legal`, `Letter`, `Tabloid` or an Object containing `height`.
+ `A4`, `A5`, `Legal`, `Letter`, `Tabloid` or an Object containing `height` and `width`.
* `callback` Function (optional)
* `success` boolean - Indicates success of the print call.
* `failureReason` string - Error description called back if the print fails.
@@ -1462,43 +1470,28 @@ win.webContents.print(options, (success, errorType) => {
#### `contents.printToPDF(options)`
* `options` Object
- * `headerFooter` Record (optional) - the header and footer for the PDF.
- * `title` string - The title for the PDF header.
- * `url` string - the url for the PDF footer.
- * `landscape` boolean (optional) - `true` for landscape, `false` for portrait.
- * `marginsType` Integer (optional) - Specifies the type of margins to use. Uses 0 for
- default margin, 1 for no margin, and 2 for minimum margin.
- * `scaleFactor` number (optional) - The scale factor of the web page. Can range from 0 to 100.
- * `pageRanges` Record (optional) - The page range to print.
- * `from` number - Index of the first page to print (0-based).
- * `to` number - Index of the last page to print (inclusive) (0-based).
- * `pageSize` string | Size (optional) - Specify page size of the generated PDF. Can be `A3`,
- `A4`, `A5`, `Legal`, `Letter`, `Tabloid` or an Object containing `height` and `width` in microns.
- * `printBackground` boolean (optional) - Whether to print CSS backgrounds.
- * `printSelectionOnly` boolean (optional) - Whether to print selection only.
+ * `landscape` boolean (optional) - Paper orientation.`true` for landscape, `false` for portrait. Defaults to false.
+ * `displayHeaderFooter` boolean (optional) - Whether to display header and footer. Defaults to false.
+ * `printBackground` boolean (optional) - Whether to print background graphics. Defaults to false.
+ * `scale` number(optional) - Scale of the webpage rendering. Defaults to 1.
+ * `pageSize` string | Size (optional) - Specify page size of the generated PDF. Can be `A0`, `A1`, `A2`, `A3`,
+ `A4`, `A5`, `A6`, `Legal`, `Letter`, `Tabloid`, `Ledger`, or an Object containing `height` and `width` in inches. Defaults to `Letter`.
+ * `margins` Object (optional)
+ * `top` number (optional) - Top margin in inches. Defaults to 1cm (~0.4 inches).
+ * `bottom` number (optional) - Bottom margin in inches. Defaults to 1cm (~0.4 inches).
+ * `left` number (optional) - Left margin in inches. Defaults to 1cm (~0.4 inches).
+ * `right` number (optional) - Right margin in inches. Defaults to 1cm (~0.4 inches).
+ * `pageRanges` string (optional) - Paper ranges to print, e.g., '1-5, 8, 11-13'. Defaults to the empty string, which means print all pages.
+ * `headerTemplate` string (optional) - HTML template for the print header. Should be valid HTML markup with following classes used to inject printing values into them: `date` (formatted print date), `title` (document title), `url` (document location), `pageNumber` (current page number) and `totalPages` (total pages in the document). For example, `` would generate span containing the title.
+ * `footerTemplate` string (optional) - HTML template for the print footer. Should use the same format as the `headerTemplate`.
+ * `preferCSSPageSize` boolean (optional) - Whether or not to prefer page size as defined by css. Defaults to false, in which case the content will be scaled to fit the paper size.
Returns `Promise` - Resolves with the generated PDF data.
-Prints window's web page as PDF with Chromium's preview printing custom
-settings.
+Prints the window's web page as PDF.
The `landscape` will be ignored if `@page` CSS at-rule is used in the web page.
-By default, an empty `options` will be regarded as:
-
-```javascript
-{
- marginsType: 0,
- printBackground: false,
- printSelectionOnly: false,
- landscape: false,
- pageSize: 'A4',
- scaleFactor: 100
-}
-```
-
-Use `page-break-before: always;` CSS style to force to print to a new page.
-
An example of `webContents.printToPDF`:
```javascript
@@ -1507,7 +1500,7 @@ const fs = require('fs')
const path = require('path')
const os = require('os')
-const win = new BrowserWindow({ width: 800, height: 600 })
+const win = new BrowserWindow()
win.loadURL('http://github.com')
win.webContents.on('did-finish-load', () => {
@@ -1524,6 +1517,8 @@ win.webContents.on('did-finish-load', () => {
})
```
+See [Page.printToPdf](https://chromedevtools.github.io/devtools-protocol/tot/Page/#method-printToPDF) for more information.
+
#### `contents.addWorkSpace(path)`
* `path` string
@@ -1638,6 +1633,8 @@ Opens the devtools.
When `contents` is a `` tag, the `mode` would be `detach` by default,
explicitly passing an empty `mode` can force using last used dock state.
+On Windows, if Windows Control Overlay is enabled, Devtools will be opened with `mode: 'detach'`.
+
#### `contents.closeDevTools()`
Closes the devtools.
@@ -2001,6 +1998,35 @@ This corresponds to the [animationPolicy][] accessibility feature in Chromium.
### Instance Properties
+#### `contents.ipc` _Readonly_
+
+An [`IpcMain`](ipc-main.md) scoped to just IPC messages sent from this
+WebContents.
+
+IPC messages sent with `ipcRenderer.send`, `ipcRenderer.sendSync` or
+`ipcRenderer.postMessage` will be delivered in the following order:
+
+1. `contents.on('ipc-message')`
+2. `contents.mainFrame.on(channel)`
+3. `contents.ipc.on(channel)`
+4. `ipcMain.on(channel)`
+
+Handlers registered with `invoke` will be checked in the following order. The
+first one that is defined will be called, the rest will be ignored.
+
+1. `contents.mainFrame.handle(channel)`
+2. `contents.handle(channel)`
+3. `ipcMain.handle(channel)`
+
+A handler or event listener registered on the WebContents will receive IPC
+messages sent from any frame, including child frames. In most cases, only the
+main frame can send IPC messages. However, if the `nodeIntegrationInSubFrames`
+option is enabled, it is possible for child frames to send IPC messages also.
+In that case, handlers should check the `senderFrame` property of the IPC event
+to ensure that the message is coming from the expected frame. Alternatively,
+register handlers on the appropriate frame directly using the
+[`WebFrameMain.ipc`](web-frame-main.md#frameipc-readonly) interface.
+
#### `contents.audioMuted`
A `boolean` property that determines whether this page is muted.
@@ -2060,6 +2086,11 @@ when the page becomes backgrounded. This also affects the Page Visibility API.
A [`WebFrameMain`](web-frame-main.md) property that represents the top frame of the page's frame hierarchy.
+#### `contents.opener` _Readonly_
+
+A [`WebFrameMain`](web-frame-main.md) property that represents the frame that opened this WebContents, either
+with open(), or by navigating a link with a target attribute.
+
[keyboardevent]: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent
[event-emitter]: https://nodejs.org/api/events.html#events_class_eventemitter
[SCA]: https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm
diff --git a/docs/api/web-frame-main.md b/docs/api/web-frame-main.md
index a3fd055d80134..3d3b87b354028 100644
--- a/docs/api/web-frame-main.md
+++ b/docs/api/web-frame-main.md
@@ -16,7 +16,7 @@ win.loadURL('https://twitter.com')
win.webContents.on(
'did-frame-navigate',
- (event, url, isMainFrame, frameProcessId, frameRoutingId) => {
+ (event, url, httpResponseCode, httpStatusText, isMainFrame, frameProcessId, frameRoutingId) => {
const frame = webFrameMain.fromId(frameProcessId, frameRoutingId)
if (frame) {
const code = 'document.body.innerHTML = document.body.innerHTML.replaceAll("heck", "h*ck")'
@@ -140,10 +140,45 @@ ipcRenderer.on('port', (e, msg) => {
### Instance Properties
+#### `frame.ipc` _Readonly_
+
+An [`IpcMain`](ipc-main.md) instance scoped to the frame.
+
+IPC messages sent with `ipcRenderer.send`, `ipcRenderer.sendSync` or
+`ipcRenderer.postMessage` will be delivered in the following order:
+
+1. `contents.on('ipc-message')`
+2. `contents.mainFrame.on(channel)`
+3. `contents.ipc.on(channel)`
+4. `ipcMain.on(channel)`
+
+Handlers registered with `invoke` will be checked in the following order. The
+first one that is defined will be called, the rest will be ignored.
+
+1. `contents.mainFrame.handle(channel)`
+2. `contents.handle(channel)`
+3. `ipcMain.handle(channel)`
+
+In most cases, only the main frame of a WebContents can send or receive IPC
+messages. However, if the `nodeIntegrationInSubFrames` option is enabled, it is
+possible for child frames to send and receive IPC messages also. The
+[`WebContents.ipc`](web-contents.md#contentsipc-readonly) interface may be more
+convenient when `nodeIntegrationInSubFrames` is not enabled.
+
#### `frame.url` _Readonly_
A `string` representing the current URL of the frame.
+#### `frame.origin` _Readonly_
+
+A `string` representing the current origin of the frame, serialized according
+to [RFC 6454](https://www.rfc-editor.org/rfc/rfc6454). This may be different
+from the URL. For instance, if the frame is a child window opened to
+`about:blank`, then `frame.origin` will return the parent frame's origin, while
+`frame.url` will return the empty string. Pages without a scheme/host/port
+triple origin will have the serialized origin of `"null"` (that is, the string
+containing the letters n, u, l, l).
+
#### `frame.top` _Readonly_
A `WebFrameMain | null` representing top frame in the frame hierarchy to which `frame`
@@ -195,3 +230,6 @@ have the same `routingId`.
A `string` representing the [visibility state](https://developer.mozilla.org/en-US/docs/Web/API/Document/visibilityState) of the frame.
See also how the [Page Visibility API](browser-window.md#page-visibility) is affected by other Electron APIs.
+
+[SCA]: https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm
+[`postMessage`]: https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage
diff --git a/docs/api/web-frame.md b/docs/api/web-frame.md
index b59d98c54cb60..06bf313547d01 100644
--- a/docs/api/web-frame.md
+++ b/docs/api/web-frame.md
@@ -110,7 +110,7 @@ webFrame.setSpellCheckProvider('en-US', {
})
```
-#### `webFrame.insertCSS(css[, options])`
+### `webFrame.insertCSS(css[, options])`
* `css` string
* `options` Object (optional)
diff --git a/docs/api/webview-tag.md b/docs/api/webview-tag.md
index fd90e8b5d5660..cc86a05d5be4d 100644
--- a/docs/api/webview-tag.md
+++ b/docs/api/webview-tag.md
@@ -158,9 +158,6 @@ When the guest page doesn't have node integration this script will still have
access to all Node APIs, but global objects injected by Node will be deleted
after this script has finished executing.
-**Note:** This option will appear as `preloadURL` (not `preload`) in
-the `webPreferences` specified to the `will-attach-webview` event.
-
### `httpreferrer`
```html
@@ -559,7 +556,7 @@ Stops any `findInPage` request for the `webview` with the provided `action`.
* `header` string (optional) - string to be printed as page header.
* `footer` string (optional) - string to be printed as page footer.
* `pageSize` string | Size (optional) - Specify page size of the printed document. Can be `A3`,
- `A4`, `A5`, `Legal`, `Letter`, `Tabloid` or an Object containing `height`.
+ `A4`, `A5`, `Legal`, `Letter`, `Tabloid` or an Object containing `height` in microns.
Returns `Promise`
@@ -568,21 +565,21 @@ Prints `webview`'s web page. Same as `webContents.print([options])`.
### `.printToPDF(options)`
* `options` Object
- * `headerFooter` Record (optional) - the header and footer for the PDF.
- * `title` string - The title for the PDF header.
- * `url` string - the url for the PDF footer.
- * `landscape` boolean (optional) - `true` for landscape, `false` for portrait.
- * `marginsType` Integer (optional) - Specifies the type of margins to use. Uses 0 for
- default margin, 1 for no margin, and 2 for minimum margin.
- and `width` in microns.
- * `scaleFactor` number (optional) - The scale factor of the web page. Can range from 0 to 100.
- * `pageRanges` Record (optional) - The page range to print. On macOS, only the first range is honored.
- * `from` number - Index of the first page to print (0-based).
- * `to` number - Index of the last page to print (inclusive) (0-based).
- * `pageSize` string | Size (optional) - Specify page size of the generated PDF. Can be `A3`,
- `A4`, `A5`, `Legal`, `Letter`, `Tabloid` or an Object containing `height`
- * `printBackground` boolean (optional) - Whether to print CSS backgrounds.
- * `printSelectionOnly` boolean (optional) - Whether to print selection only.
+ * `landscape` boolean (optional) - Paper orientation.`true` for landscape, `false` for portrait. Defaults to false.
+ * `displayHeaderFooter` boolean (optional) - Whether to display header and footer. Defaults to false.
+ * `printBackground` boolean (optional) - Whether to print background graphics. Defaults to false.
+ * `scale` number(optional) - Scale of the webpage rendering. Defaults to 1.
+ * `pageSize` string | Size (optional) - Specify page size of the generated PDF. Can be `A0`, `A1`, `A2`, `A3`,
+ `A4`, `A5`, `A6`, `Legal`, `Letter`, `Tabloid`, `Ledger`, or an Object containing `height` and `width` in inches. Defaults to `Letter`.
+ * `margins` Object (optional)
+ * `top` number (optional) - Top margin in inches. Defaults to 1cm (~0.4 inches).
+ * `bottom` number (optional) - Bottom margin in inches. Defaults to 1cm (~0.4 inches).
+ * `left` number (optional) - Left margin in inches. Defaults to 1cm (~0.4 inches).
+ * `right` number (optional) - Right margin in inches. Defaults to 1cm (~0.4 inches).
+ * `pageRanges` string (optional) - Paper ranges to print, e.g., '1-5, 8, 11-13'. Defaults to the empty string, which means print all pages.
+ * `headerTemplate` string (optional) - HTML template for the print header. Should be valid HTML markup with following classes used to inject printing values into them: `date` (formatted print date), `title` (document title), `url` (document location), `pageNumber` (current page number) and `totalPages` (total pages in the document). For example, `` would generate span containing the title.
+ * `footerTemplate` string (optional) - HTML template for the print footer. Should use the same format as the `headerTemplate`.
+ * `preferCSSPageSize` boolean (optional) - Whether or not to prefer page size as defined by css. Defaults to false, in which case the content will be scaled to fit the paper size.
Returns `Promise` - Resolves with the generated PDF data.
diff --git a/docs/api/window-open.md b/docs/api/window-open.md
index a2cb76a2a569e..1925a5d1e7e5d 100644
--- a/docs/api/window-open.md
+++ b/docs/api/window-open.md
@@ -73,6 +73,11 @@ creating the window. Note that this is more powerful than passing options
through the feature string, as the renderer has more limited privileges in
deciding security preferences than the main process.
+In addition to passing in `action` and `overrideBrowserWindowOptions`,
+`outlivesOpener` can be passed like: `{ action: 'allow', outlivesOpener: true,
+overrideBrowserWindowOptions: { ... } }`. If set to `true`, the newly created
+window will not close when the opener window closes. The default value is `false`.
+
### Native `Window` example
```javascript
diff --git a/docs/breaking-changes.md b/docs/breaking-changes.md
index c448a5303836e..c6c511b32bb18 100644
--- a/docs/breaking-changes.md
+++ b/docs/breaking-changes.md
@@ -14,6 +14,68 @@ This document uses the following convention to categorize breaking changes:
## Planned Breaking API Changes (20.0)
+### Behavior Changed: V8 Memory Cage enabled
+
+The V8 memory cage has been enabled, which has implications for native modules
+which wrap non-V8 memory with `ArrayBuffer` or `Buffer`. See the [blog post
+about the V8 memory cage](https://www.electronjs.org/blog/v8-memory-cage) for
+more details.
+
+### API Changed: `webContents.printToPDF()`
+
+`webContents.printToPDF()` has been modified to conform to [`Page.printToPDF`](https://chromedevtools.github.io/devtools-protocol/tot/Page/#method-printToPDF) in the Chrome DevTools Protocol. This has been changes in order to
+address changes upstream that made our previous implementation untenable and rife with bugs.
+
+**Arguments Changed**
+
+* `pageRanges`
+
+**Arguments Removed**
+
+* `printSelectionOnly`
+* `marginsType`
+* `headerFooter`
+* `scaleFactor`
+
+**Arguments Added**
+
+* `headerTemplate`
+* `footerTemplate`
+* `displayHeaderFooter`
+* `margins`
+* `scale`
+* `preferCSSPageSize`
+
+```js
+// Main process
+const { webContents } = require('electron')
+
+webContents.printToPDF({
+ landscape: true,
+ displayHeaderFooter: true,
+ printBackground: true,
+ scale: 2,
+ pageSize: 'Ledger',
+ margins: {
+ top: 2,
+ bottom: 2,
+ left: 2,
+ right: 2
+ },
+ pageRanges: '1-5, 8, 11-13',
+ headerTemplate: '
Title
',
+ footerTemplate: '
',
+ preferCSSPageSize: true
+}).then(data => {
+ fs.writeFile(pdfPath, data, (error) => {
+ if (error) throw error
+ console.log(`Wrote PDF successfully to ${pdfPath}`)
+ })
+}).catch(error => {
+ console.log(`Failed to write PDF to ${pdfPath}: `, error)
+})
+```
+
### Default Changed: renderers without `nodeIntegration: true` are sandboxed by default
Previously, renderers that specified a preload script defaulted to being
@@ -34,9 +96,19 @@ window manager. There is not a direct equivalent for Wayland, and the known
workarounds have unacceptable tradeoffs (e.g. Window.is_skip_taskbar in GNOME
requires unsafe mode), so Electron is unable to support this feature on Linux.
+### API Changed: `session.setDevicePermissionHandler(handler)`
+
+The handler invoked when `session.setDevicePermissionHandler(handler)` is used
+has a change to its arguments. This handler no longer is passed a frame
+`[WebFrameMain](api/web-frame-main.md)`, but instead is passed the `origin`, which
+is the origin that is checking for device permission.
+
## Planned Breaking API Changes (19.0)
-*None (yet)*
+### Removed: IA32 Linux binaries
+
+This is a result of Chromium 102.0.4999.0 dropping support for IA32 Linux.
+This concludes the [removal of support for IA32 Linux](#removed-ia32-linux-support).
## Planned Breaking API Changes (18.0)
@@ -372,7 +444,7 @@ value.
In Electron 12, `contextIsolation` will be enabled by default. To restore
the previous behavior, `contextIsolation: false` must be specified in WebPreferences.
-We [recommend having contextIsolation enabled](tutorial/security.md#3-enable-context-isolation-for-remote-content) for the security of your application.
+We [recommend having contextIsolation enabled](tutorial/security.md#3-enable-context-isolation) for the security of your application.
Another implication is that `require()` cannot be used in the renderer process unless
`nodeIntegration` is `true` and `contextIsolation` is `false`.
@@ -1203,6 +1275,10 @@ not present, then the native module will fail to load on Windows, with an error
message like `Cannot find module`. See the [native module
guide](/docs/tutorial/using-native-node-modules.md) for more.
+### Removed: IA32 Linux support
+
+Electron 18 will no longer run on 32-bit Linux systems. See [discontinuing support for 32-bit Linux](https://www.electronjs.org/blog/linux-32bit-support) for more information.
+
## Breaking API Changes (3.0)
The following list includes the breaking API changes in Electron 3.0.
diff --git a/docs/development/Electronite/ElectroniteBuildNotes.md b/docs/development/Electronite/ElectroniteBuildNotes.md
index f1ba71ad9c76f..dca7aab1fb4fb 100644
--- a/docs/development/Electronite/ElectroniteBuildNotes.md
+++ b/docs/development/Electronite/ElectroniteBuildNotes.md
@@ -26,7 +26,7 @@ The simplest way to update Electronite is to pull down the branch from upstream
Updating Electronite is pretty straight forward.
1. Get the version of Electron that you want to update to, e.g. `git checkout upstream v12.0.5`.
-2. Branch from Electron `git checkout -b electronite-12.0.5`
+2. Create new electronite branch from Electron `git checkout -b electronite-v12.0.5`
3. Apply the [Graphite Patch](https://github.com/unfoldingWord/electronite/wiki/Graphite-Patch) `git am add-graphite-to-electron.patch` (you might need to manually apply it if there are conflicting changes from upstream).
4. Build and test the Electronite branch (see below).
5. If everything is working properly, push the branch and tag the release using the proper naming convention, and create a new release based on your new tag with the compiled binaries attached to it.
@@ -34,7 +34,7 @@ Updating Electronite is pretty straight forward.
# Building
-[Build Notes](https://github.com/unfoldingWord/electronite/blob/v18.2.1-graphite/docs/development/Electronite/ElectroniteCurrentVersionBuildNotes.md)
+[Build Notes](ElectroniteCurrentVersionBuildNotes.md)
# Other Electronite Steps
diff --git a/docs/development/Electronite/ElectroniteCurrentVersionBuildNotes.md b/docs/development/Electronite/ElectroniteCurrentVersionBuildNotes.md
index f117f24968d7c..e65ddab30cbe8 100644
--- a/docs/development/Electronite/ElectroniteCurrentVersionBuildNotes.md
+++ b/docs/development/Electronite/ElectroniteCurrentVersionBuildNotes.md
@@ -6,9 +6,9 @@ Based on wiki notes for `electronite-v12.0.5` from: https://github.com/unfolding
# Building
-- Windows build notes: https://github.com/unfoldingWord/electronite/blob/v18.2.1-graphite/docs/development/Electronite/WindowsBuildNotes.md
-- MacOS build notes: https://github.com/unfoldingWord/electronite/blob/v18.2.1-graphite/docs/development/Electronite/MacBuildNotes.md
-- Linux build notes: https://github.com/unfoldingWord/electronite/blob/v18.2.1-graphite/docs/development/Electronite/LinuxBuildNotes.md
+- [Windows build notes](WindowsBuildNotes.md)
+- [MacOS build notes](MacBuildNotes.md)
+- [Linux build notes](LinuxBuildNotes.md)
Running the scripts without arguments will display the following commands which you will generally want to execute in order:
1. `get ` fetches all of the code. Where `` is a branch or tag.
diff --git a/docs/development/Electronite/LinuxBuildNotes.md b/docs/development/Electronite/LinuxBuildNotes.md
index e2d5a2dcf7dc2..6ba6ebe0286c2 100644
--- a/docs/development/Electronite/LinuxBuildNotes.md
+++ b/docs/development/Electronite/LinuxBuildNotes.md
@@ -1,8 +1,8 @@
## Building Electronite on Linux
### Setup on Clean Linux VM
-- Configured my VM using these notes as a reference: https://github.com/unfoldingWord/electronite/blob/v18.2.1-graphite/docs/development/build-instructions-linux.md
+- Configured my VM using these notes as a reference: [build-instructions-linux](../build-instructions-linux.md)
- Make sure the VM has a lot of disk space - I ran out of disk space with 60GB of storage configured. Rather than starting over with a new VM. I added a second Virtual Hard Drive with 100GB and then used that drive for the builds.
-- if you have trouble building with these notes, you could try the older Chromium Build tools: https://github.com/unfoldingWord/electronite/blob/v18.2.1-graphite/docs/development/Electronite/LinuxBuildNotesChromeTools.md
+- if you have trouble building with these notes, you could try the older Chromium Build tools: [LinuxBuildNotesChromeTools](LinuxBuildNotesChromeTools.md)
- if you get warning that you need to upgrade to newer g++, here's an example of how to upgrade to g++ 10:
```
sudo apt install build-essential
@@ -13,154 +13,80 @@ g++ --version
- to create `arm64` and `arm` builds, you must have installed the arm dependencies mentioned in the Linux build instructions above. Then run:
- install and configure python:
```
-sudo apt install python python3.9
+sudo apt install python python3 python3-pip
pip3 install --user --upgrade pip
pip3 install --user pyobjc
+pip3 install importlib-metadata
```
+- use node v16 (had build problems with latest v18)
- installed electron build-tools (https://github.com/electron/build-tools):
```
+npm i -g yarn
npm i -g @electron/build-tools
```
+
- if e commands donβt work, try this and then initialization seemed to work:
```
git clone https://github.com/electron/build-tools ~/.electron_build_tools && (cd ~/.electron_build_tools && npm install)
```
-#### Monitoring Goma status
-- if you browse to http://localhost:8088 on your local machine you can monitor compile jobs as they flow through the goma system.
+- note 32-bit builds for Linux no longer supported.
### Build Electronite
-#### Build x64
-- open terminal and initialize build configuration (note that if you have a slow or unreliable internet connection, it is better to change the goma setting from `cache-only` to `none`):
-```
-e init --root=~/Develop/Electronite-Build -o x64 x64 -i release --goma cache-only --fork unfoldingWord/electronite --use-https -f
-```
-
-- edit `~/.electron_build_tools/configs/evm.x64.json`
- and add option to args: `"target_cpu = \"x64\""`
-- get the base Electron source code (this can take many hours the first time as the git cache is loaded):
-```
-e sync
-```
-
-- checkout the correct Electronite tag
-```
-cd ~/Develop/Electronite-Build/src/electron
-git fetch --all
-git checkout tags/v18.2.1-graphite -b v18.2.1-graphite
-cd ../..
-```
+- first make sure you have downloaded the current version of electronite-tools-2.sh. There may have been changes from other electronite versions.
-- now get the Electronite sources
+#### Build x64
+- get the Electronite source code for branch (this can take many hours the first time as the git cache is loaded):
```
-e sync
+export PATH=$PATH:~/.electron_build_tools/third_party/depot_tools:~/.electron_build_tools/src
+e init --root=~/Develop/Electronite-Build -o x64 x64 -i release --goma none --fork unfoldingWord/electronite --use-https -f
+./electronite-tools-2.sh get electronite-v21.2.0-beta
```
- Do build (takes a long time)
```
-e use x64
-export NINJA_STATUS="[%r processes, %f/%t @ %o/s : %es] "
-e build electron
+./electronite-tools-2.sh build x64
+./electronite-tools-2.sh release x64
```
-- Make the release to ~/Develop/Electronite-Build/src/out/x64/dist.zip
-```
-./src/electron/script/strip-binaries.py -d src/out/x64
-e build electron:dist
-```
-
-#### Build x86
-- open terminal and initialize build configuration (note that if you have a slow or unreliable internet connection, it is better to change the goma setting from `cache-only` to `none`):
-```
-sudo apt-get install ia32-libs-gtk ia32-libs
-e init --root=~/Develop/Electronite-Build -o x86 x86 -i release --goma cache-only --fork unfoldingWord/electronite --use-https -f
-```
+- Test the build.
+ - Do `cd src/out/Release-x64 && ./electron`.
+ - Open the developer console by typing`Control-Shift-I`.
+ - in console execute `window.location="https://scripts.sil.org/cms/scripts/page.php?site_id=projects&item_id=graphite_fontdemo"`
+ - Ensure all the tests pass by visually inspecting the rendered fonts and comparing against the image samples on the site.
+ - The example for Padauk from server will not be correct with the triangles. So need to:
+ Open elements tab, select body of html, do Control-F to search, and search for `padauk_ttf`, and apply attribute `font-feature-settings: "wtri" 1;`. The triangles should now be rendered correctly.
-- edit `~/.electron_build_tools/configs/evm.x86.json`
- and add option to args: `"target_cpu = \"x86\""`
-- get the base Electron source code (this can take many hours the first time as the git cache is loaded):
-```
-e sync
-```
-
-- to create `x86` builds, you must have installed the x86 dependencies mentioned in the Linux build instructions above. Then run:
-```
-cd ./src
-build/linux/sysroot_scripts/install-sysroot.py --arch=x86
-cd ..
-```
-
-- checkout the correct Electronite tag
-```
-cd ~/Develop/Electronite-Build/src/electron
-git fetch --all
-git checkout tags/v18.2.1-graphite -b v18.2.1-graphite
-cd ../..
-```
-
-- now get the Electronite sources
-```
-e sync
-```
-
-- Do build (takes a long time)
-```
-e use x86
-export NINJA_STATUS="[%r processes, %f/%t @ %o/s : %es] "
-e build electron
-```
-
-- Make the release to ~/Develop/Electronite-Build/src/out/x86/dist.zip
-```
-./src/electron/script/strip-binaries.py --target-cpu=x86 -d src/out/x86
-e build electron:dist
-```
+- The release is at ~/Develop/Electronite-Build/src/out/Release-x64/dist.zip
#### Build Arm64
- open terminal and initialize build configuration (note that if you have a slow or unreliable internet connection, it is better to change the goma setting from `cache-only` to `none`):
```
sudo apt-get install binutils-aarch64-linux-gnu
-e init --root=~/Develop/Electronite-Build -o arm64 arm64 -i release --goma cache-only --fork unfoldingWord/electronite --use-https -f
```
-- edit `~/.electron_build_tools/configs/evm.arm64.json`
- and add option to args: `"target_cpu = \"arm64\""`
-- get the base Electron source code (this can take many hours the first time as the git cache is loaded):
+- if Electronite source already checked out, then skip to `Build Init` step.
+
+- get the Electronite source code for branch (this can take many hours the first time as the git cache is loaded):
```
-e sync
+export PATH=$PATH:~/.electron_build_tools/third_party/depot_tools:~/.electron_build_tools/src
+e init --root=~/Develop/Electronite-Build -o x64 x64 -i release --goma none --fork unfoldingWord/electronite --use-https -f
+./electronite-tools-2.sh get electronite-v21.2.0-beta
```
-- to create `arm64` builds, you must have installed the arm64 dependencies mentioned in the Linux build instructions above. Then run:
+- Build Init: to create `arm64` builds, you must have installed the arm64 dependencies mentioned in the Linux build instructions above. Then run:
```
cd ./src
build/linux/sysroot_scripts/install-sysroot.py --arch=arm64
cd ..
```
-- checkout the correct Electronite tag
-```
-cd ~/Develop/Electronite-Build/src/electron
-git fetch --all
-git checkout tags/v18.2.1-graphite -b v18.2.1-graphite
-cd ../..
-```
-
-- now get the Electronite sources
-```
-e sync
-```
-
- Do build (takes a long time)
```
-e use arm64
-export NINJA_STATUS="[%r processes, %f/%t @ %o/s : %es] "
-e build electron
+./electronite-tools-2.sh build arm64
+./electronite-tools-2.sh release arm64
```
-- Make the release to ~/Develop/Electronite-Build/src/out/arm64/dist.zip
-```
-./src/electron/script/strip-binaries.py --target-cpu=arm64 -d src/out/arm64
-e build electron:dist
-```
+- The release is at ~/Develop/Electronite-Build/src/out/Release-arm64/dist.zip
diff --git a/docs/development/Electronite/LinuxBuildNotesChromeTools.md b/docs/development/Electronite/LinuxBuildNotesChromeTools.md
index d781478a95c6e..910c0b476d497 100644
--- a/docs/development/Electronite/LinuxBuildNotesChromeTools.md
+++ b/docs/development/Electronite/LinuxBuildNotesChromeTools.md
@@ -1,12 +1,12 @@
## Building Electronite on Linux
### Setup on Linux VM
-- Configured my VM using these notes as a reference: https://github.com/unfoldingWord/electronite/blob/v17.3.1-graphite/docs/development/build-instructions-linux.md
+- Configured my VM using these notes as a reference: [build-instructions-linux](../build-instructions-linux.md){
- Make sure the VM has a lot of disk space - I ran out of disk space with 60GB of storage configured. Rather than starting over with a new VM. I added a second Virtual Hard Drive with 100GB and then used that drive for the builds.
### Build Electronite
- open terminal and cd to the folder you will use for build
- install the depot_tools here: `git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git`
-- download build script to this folder from: https://github.com/unfoldingWord/electronite/blob/v17.3.1-graphite/docs/development/Electronite/electronite-tools.sh
+- download build script to this folder from: [electronite-tools](electronite-tools.sh)
- set execute permission on script: `chmod +x ./electronite-tools.sh`
- before build do: `export PATH=/path/to/depot_tools:$PATH`
- get source files (this can take several hours the first time as the git cache is loaded): `./electronite-tools.sh get <>`
@@ -25,7 +25,12 @@ cd ../..
- builds can take over 20 hours on a VM.
- build Electronite for Intel 64-bit:
- build for 64-bit: `./electronite-tools.sh build x64`
- - create release for 32-bit: `./electronite-tools.sh release x64`
+ - create release for 64-bit: `./electronite-tools.sh release x64`
+
+- build Electronite for Intel 32-bit:
+ - initialize build configuration: `sudo apt-get install ia32-libs-gtk ia32-libs`
+ - build for 32-bit: `./electronite-tools.sh build x86`
+ - create release for 32-bit: `./electronite-tools.sh release x86`
- build Electronite for Arm 64-bit:
- build for arm 64-bit: `./electronite-tools.sh build arm64`
diff --git a/docs/development/Electronite/MacBuildNotes.md b/docs/development/Electronite/MacBuildNotes.md
index c5d22c6c5cb90..975ea40b4ad6a 100644
--- a/docs/development/Electronite/MacBuildNotes.md
+++ b/docs/development/Electronite/MacBuildNotes.md
@@ -1,17 +1,18 @@
## Building Electronite on MacOS
-### Setup on MacOS Monterey
-- Configured using these notes as a reference: https://github.com/unfoldingWord/electronite/blob/v18.2.1-graphite/docs/development/build-instructions-macos.md
+### Setup on MacOS Big Sur
+- Configured using these notes as a reference: [build-instructions-macos](../build-instructions-macos.md)
+- Can build on Monterey
- Building for x64 does not work on M1 Silicon Macs, only for Arm64. On Intel based Macs can build for both Arm64 and Intel x64
- Make sure you have a lot of free disk space - need over 150GB free.
-- if you have trouble building with these notes, you could try the older Chromium Build tools: https://github.com/unfoldingWord/electronite/blob/v18.2.1-graphite/docs/development/Electronite/MacBuildNotesChromeTools.md
+- if you have trouble building with these notes, you could try the older Chromium Build tools: [MacBuildNotesChromeTools](MacBuildNotesChromeTools.md)
- installed node using nvm
- install nvm: `curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash`
- restart terminal
- - install latest stable node:
+ - install v16 (had build problems with latest v18):
```
-nvm install --lts
-nvm use --lts
+nvm install v16
+nvm use v16
node --version
```
- installed homebrew: `/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"`
@@ -20,9 +21,12 @@ node --version
```
pip3 install --user --upgrade pip
pip3 install --user pyobjc
+pip3 install importlib-metadata
```
- installed electron build-tools (https://github.com/electron/build-tools):
```
+xcode-select --install
+npm i -g yarn
sudo npm i -g @electron/build-tools
```
@@ -36,79 +40,46 @@ git clone https://github.com/electron/build-tools ~/.electron_build_tools && (cd
### Build Electronite
-#### Build Arm64
-- open terminal and initialize build (on M1 Mac, had to use `--goma none`, and it may be faster if you have a slow or unreliable internet connection):
-```
-e init --root=~/Develop/Electronite-Build -o arm64 arm64 -i release --goma cache-only --fork unfoldingWord/electronite --use-https -f
-```
-
-- edit `~/.electron_build_tools/configs/evm.arm64.json`
-and add option to args: `"target_cpu = \"arm64\""`
-- get the base Electron source code (this can take many hours the first time as the git cache is loaded):
-```
-e sync
-```
+- first make sure you have downloaded the current version of electronite-tools-2.sh. There may have been changes from other electronite versions.
-- checkout the correct Electronite tag
-```
-cd ~/Develop/Electronite-Build/src/electron
-git fetch --all
-git checkout tags/v18.2.1-graphite -b v18.2.1-graphite
-cd ../..
-```
-
-- now get the Electronite sources
+#### Build Intel x64
+- get the Electronite source code for branch (this can take many hours the first time as the git cache is loaded):
```
-e sync
+export PATH=$PATH:~/.electron_build_tools/third_party/depot_tools:~/.electron_build_tools/src
+e init --root=~/Develop/Electronite-Build -o x64 x64 -i release --goma none --fork unfoldingWord/electronite --use-https -f
+./electronite-tools-2.sh get electronite-v21.2.0-beta
```
- Do build (takes a long time)
```
-e use arm64
-export NINJA_STATUS="[%r processes, %f/%t @ %o/s : %es] "
-e build electron
-```
-
-- Make the release to ~/Develop/Electronite-Build/src/out/arm64/dist.zip
-```
-e build electron:dist
+./electronite-tools-2.sh build x64
+./electronite-tools-2.sh release x64
```
-#### Build Intel x64
-- open terminal and initialize build (on M1 Mac, had to use `--goma none`):
-```
-e init --root=~/Develop/Electronite-Build -o x64 x64 -i release --goma cache-only --fork unfoldingWord/electronite --use-https -f
-```
+- Test the build.
+ - Do `e start`. (or `open ./src/out/Release-x64/Electron.app`)
+ - Open the developer console by typing`Command-Alt-I`.
+ - in console execute `window.location="https://scripts.sil.org/cms/scripts/page.php?site_id=projects&item_id=graphite_fontdemo"`
+ - Ensure all the tests pass by visually inspecting the rendered fonts and comparing against the image samples on the site.
+ - The example for Padauk from server will not be correct with the triangles. So need to:
+Open elements tab, select body of html, do command-F to search, and search for `padauk_ttf`, and apply attribute `font-feature-settings: "wtri" 1;`. The triangles should now be rendered correctly.
-- edit `~/.electron_build_tools/configs/evm.x64.json`
- and add option to args: `"target_cpu = \"x64\""`
-- get the base Electron source code (this can take many hours the first time as the git cache is loaded):
-```
-e sync
-```
+- The release is at ~/Develop/Electronite-Build/src/out/Release-x64/dist.zip
-- checkout the correct Electronite tag
-```
-cd ~/Develop/Electronite-Build/src/electron
-git fetch --all
-git checkout tags/v18.2.1-graphite -b v18.2.1-graphite
-cd ../..
-```
+#### Build Arm64
+- if Electronite source already checked out, then skip to `Do build` step:
-- now get the Electronite sources
+- get the Electronite source code for branch (this can take many hours the first time as the git cache is loaded):
```
-e sync
+export PATH=$PATH:~/.electron_build_tools/third_party/depot_tools:~/.electron_build_tools/src
+e init --root=~/Develop/Electronite-Build -o x64 x64 -i release --goma none --fork unfoldingWord/electronite --use-https -f
+./electronite-tools-2.sh get electronite-v21.2.0-beta
```
- Do build (takes a long time)
```
-e use x64
-export NINJA_STATUS="[%r processes, %f/%t @ %o/s : %es] "
-e build electron
-```
-
-- Make the release to ~/Develop/Electronite-Build/src/out/x64/dist.zip
-```
-e build electron:dist
+./electronite-tools-2.sh build arm64
+./electronite-tools-2.sh release arm64
```
+- The release is at ~/Develop/Electronite-Build/src/out/Release-arm64/dist.zip
diff --git a/docs/development/Electronite/MacBuildNotesChromeTools.md b/docs/development/Electronite/MacBuildNotesChromeTools.md
index c637113969ad8..9558db03dc1a6 100644
--- a/docs/development/Electronite/MacBuildNotesChromeTools.md
+++ b/docs/development/Electronite/MacBuildNotesChromeTools.md
@@ -1,6 +1,6 @@
## Building Electronite on MacOS
### Setup on MacOS Catalina VM
-- Configured my VM using these notes as a reference: https:https://github.com/unfoldingWord/electronite/blob/v17.3.1-graphite/docs/development/build-instructions-macos.md
+- Configured my VM using these notes as a reference: [build-instructions-macos](../build-instructions-macos.md)
- Make sure the VM has a lot of disk space - I was able to build with 120GB of storage configured. But only had 13GB of space at end of build, so that may not be enough in the future.
- Installed xcode 12.4.
- installed node using nvm
@@ -23,7 +23,7 @@ pip3 install --user pyobjc
### Build Electronite
- open terminal and cd to the folder you will use for build
- install the depot_tools here: `git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git`
-- download build script to this folder from: https://github.com/unfoldingWord/electronite/blob/v17.3.1-graphite/docs/development/Electronite/electronite-tools.sh
+- download build script to this folder from: [electronite-tools](electronite-tools.sh)
- set execute permission on script: `chmod +x ./electronite-tools.sh`
- before build do: `export PATH=/path/to/depot_tools:$PATH`
- get source files (this can take several hours the first time as the git cache is loaded): `./electronite-tools.sh get <>`
diff --git a/docs/development/Electronite/WindowsBuildNotes.md b/docs/development/Electronite/WindowsBuildNotes.md
index 0f2c5f99f577c..b2221d5dda703 100644
--- a/docs/development/Electronite/WindowsBuildNotes.md
+++ b/docs/development/Electronite/WindowsBuildNotes.md
@@ -2,9 +2,9 @@
### Setup on Clean Windows 10 VM
- Configured my VM using these notes as a reference:
- https://chromium.googlesource.com/chromium/src/+/main/docs/windows_build_instructions.md#visual-studio
- - https://github.com/unfoldingWord/electronite/blob/v18.2.1-graphite/docs/development/build-instructions-windows.md
+ - [build-instructions-windows](../build-instructions-windows.md)
- Make sure the VM has a lot of disk space - I configured with 220GB of storage.
-- if you have trouble building with these notes, you could try the older Chromium Build tools: https://github.com/unfoldingWord/electronite/blob/v18.2.1-graphite/docs/development/Electronite/WindowsBuildNotesChromeTools.md
+- if you have trouble building with these notes, you could try the older Chromium Build tools: [WindowsBuildNotesChromeTools](WindowsBuildNotesChromeTools.md)
- Make sure to add exception to the build folder for Windows defender, or it will delete a couple of the build files.
- Go to Start button > Settings > Update & Security > Windows Security > Virus & threat protection.
- Under Virus & threat protection settings, select Manage settings, and then under Exclusions, select Add or remove exclusions.
@@ -26,7 +26,7 @@ WINDOWSSDKDIR=C:\Program Files (x86)\Windows Kits\10
- installed: https://chocolatey.org/install
-- Setup Build tools (using command prompt, not powershell). Install using didn't work for me:
+- Setup Build tools (using command prompt, not powershell). Install using powershell didn't work for me:
```
npm i -g @electron/build-tools
C:
@@ -40,120 +40,64 @@ npm i
- if you browse to http://localhost:8088 on your local machine you can monitor compile jobs as they flow through the goma system.
### Build Electronite
-#### Build Intel x64
-- open command prompt and initialize build configuration (note that if you have a slow or unreliable internet connection, it is better to change the goma setting from `cache-only` to `none`):
-```
-e init --root=.\Build-Electron -o x64 x64 -i release --goma cache-only --fork unfoldingWord/electronite --use-https -f
-```
+- first make sure you have downloaded the current version of electronite-tools-2.bat. There may have been changes from other electronite versions.
-- edit `~\.electron_build_tools\configs\evm.x64.json`
-and add option to args: `"target_cpu = \"x64\""`
-
-- get the base Electron source code (this can take many hours the first time as the git cache is loaded):
-```
-e sync
-```
-
-- checkout the correct Electronite tag
+#### Build Intel x64
+- open command prompt, cd to the build directory, and initialize build configuration:
```
-cd .\Build-Electron\src\electron
-git fetch --all
-git checkout tags/v18.2.1-graphite -b v18.2.1-graphite
-cd ..\..
+e init --root=. -o x64 x64 -i release --goma none --fork unfoldingWord/electronite --use-https -f
```
-- now get the Electronite sources
+- get the Electronite source code (this can take many hours the first time as the git cache is loaded), checkout the correct Electronite tag and get build sources
```
-e sync
+.\electronite-tools-2.bat get electronite-v21.2.0-beta
```
- Do build (takes a long time)
```
-e use x64
-set NINJA_STATUS="[%r processes, %f/%t @ %o/s : %es] "
-e build electron
+.\electronite-tools-2.bat build x64
+.\electronite-tools-2.bat release x64
```
-- Make the release to .\Build-Electron\src\out\x64\dist.zip
-```
-e build electron:dist
-```
-
-#### Build Intel x86 (32 bit)
-- open command prompt and initialize build configuration (note that if you have a slow or unreliable internet connection, it is better to change the goma setting from `cache-only` to `none`):
-```
-e init --root=.\Build-Electron -o x86 x86 -i release --goma cache-only --fork unfoldingWord/electronite --use-https -f
-```
-
-- edit `~\.electron_build_tools\configs\evm.x86.json`
- and add option to args: `"target_cpu = \"x86\""`
+- Test the build.
+ - Do `e start`. Or open electron.exe in finder.
+ - Open the developer console by typing`Control-Shift-I`.
+ - in console execute `window.location="https://scripts.sil.org/cms/scripts/page.php?site_id=projects&item_id=graphite_fontdemo"`
+ - Ensure all the tests pass by visually inspecting the rendered fonts and comparing against the image samples on the site.
+ - The example for Padauk from server will not be correct with the triangles. So need to:
+ Open elements tab, select body of html, do Control-F to search, and search for `padauk_ttf`, and apply attribute `font-feature-settings: "wtri" 1;`. The triangles should now be rendered correctly.
-- get the base Electron source code (this can take many hours the first time as the git cache is loaded):
-```
-e sync
-```
+- The release is at .\Build-Electron\src\out\Release-x64\dist.zip
-- checkout the correct Electronite tag
-```
-cd .\Build-Electron\src\electron
-git fetch --all
-git checkout tags/v18.2.1-graphite -b v18.2.1-graphite
-cd ..\..
-```
+#### Build Intel x86 (32 bit)
+- if Electronite source already checked out, then skip to `Do build` step.
-- now get the Electronite sources
+- get the Electronite source code (this can take many hours the first time as the git cache is loaded), checkout the correct Electronite tag and get build sources
```
-e sync
+.\electronite-tools-2.bat get electronite-v21.2.0-beta
```
- Do build (takes a long time)
```
-e use x86
-set NINJA_STATUS="[%r processes, %f/%t @ %o/s : %es] "
-e build electron
+.\electronite-tools-2.bat build x86
+.\electronite-tools-2.bat release x86
```
-- Make the release to .\Build-Electron\src\out\x86\dist.zip
-```
-e build electron:dist
-```
+- The release is at .\Build-Electron\src\out\Release-x86\dist.zip
#### Build Intel arm64
-- open command prompt and initialize build configuration (note that if you have a slow or unreliable internet connection, it is better to change the goma setting from `cache-only` to `none`):
-```
-e init --root=.\Build-Electron -o arm64 arm64 -i release --goma cache-only --fork unfoldingWord/electronite --use-https -f
-```
-
-- edit `~\.electron_build_tools\configs\evm.arm64.json`
- and add option to args: `"target_cpu = \"arm64\""`
+- if Electronite source already checked out, then skip to `Do build` step.
-- get the base Electron source code (this can take many hours the first time as the git cache is loaded):
+-- get the Electronite source code (this can take many hours the first time as the git cache is loaded), checkout the correct Electronite tag and get build sources
```
-e sync
-```
-
-- checkout the correct Electronite tag
-```
-cd .\Build-Electron\src\electron
-git fetch --all
-git checkout tags/v18.2.1-graphite -b v18.2.1-graphite
-cd ..\..
-```
-
-- now get the Electronite sources
-```
-e sync
+.\electronite-tools-2.bat get electronite-v21.2.0-beta
```
- Do build (takes a long time)
```
-e use arm64
-set NINJA_STATUS="[%r processes, %f/%t @ %o/s : %es] "
-e build electron
+.\electronite-tools-2.bat build arm64
+.\electronite-tools-2.bat release arm64
```
-- Make the release to .\Build-Electron\src\out\arm64\dist.zip
-```
-e build electron:dist
-```
+- The release is at .\Build-Electron\src\out\Release-arm64\dist.zip
diff --git a/docs/development/Electronite/WindowsBuildNotesChromeTools.md b/docs/development/Electronite/WindowsBuildNotesChromeTools.md
index 823b2426a4425..94affab40bb12 100644
--- a/docs/development/Electronite/WindowsBuildNotesChromeTools.md
+++ b/docs/development/Electronite/WindowsBuildNotesChromeTools.md
@@ -2,7 +2,7 @@
### Setup on Clean Windows 10 VM
- Configured my VM using these notes as a reference:
- https://chromium.googlesource.com/chromium/src/+/main/docs/windows_build_instructions.md#visual-studio
- - https://github.com/unfoldingWord/electronite/blob/v17.3.1-graphite/docs/development/build-instructions-windows.md
+ - [build-instructions-windows](../build-instructions-windows.md)
- Make sure the VM has a lot of disk space - I ran out of disk space with 120GB of storage configured. Rather than starting over with a new VM. I added a second Virtual Hard Drive with 100GB and then used that drive for the builds.
- Make sure to add exception to the build folder for Windows defender, or it will delete a couple of the build files.
- Add to git support for long file names: `git config --system core.longpaths true`
@@ -24,7 +24,7 @@ WINDOWSSDKDIR=C:\Program Files (x86)\Windows Kits\10
- _**Note:** Use command prompt, not powershell as it will cause problems._
- cd to the folder you will use for build
- unzip the depot_tools here
-- download build script to this folder from: https://github.com/unfoldingWord/electronite/blob/v17.3.1-graphite/docs/development/Electronite/electronite-tools.bat
+- download build script to this folder from: [electronite-tools](electronite-tools.bat)
- before build do: `set PATH=%cd%\depot_tools;%PATH%`
- get source files (this can take several hours the first time as the git cache is loaded): `.\electronite-tools.bat get <>`
- builds can take over 20 hours on a VM.
diff --git a/docs/development/Electronite/add_graphite_cpp_std_iterator.patch b/docs/development/Electronite/add_graphite_cpp_std_iterator.patch
new file mode 100755
index 0000000000000..19bb14da416d8
--- /dev/null
+++ b/docs/development/Electronite/add_graphite_cpp_std_iterator.patch
@@ -0,0 +1,30 @@
+From 0000000000000000000000000000000000000000 Thu Nov 3 15:48:39 2022
+From: Bruce
+Date: Thu Nov 3 2022 15:48:39 -0700
+Subject: [PATCH] fix C++ std::iterator in graphite to be compatible with latest standard -- patched for v21.2.0
+
+diff --git a/third_party/graphite/graphite2/src/GlyphCache.cpp b/third_party/graphite/graphite2/src/GlyphCache.cpp
+index 282bdc18..336de3f1 100644
+--- a/third_party/graphite/graphite2/src/GlyphCache.cpp
++++ b/third_party/graphite/graphite2/src/GlyphCache.cpp
+@@ -44,12 +44,18 @@ namespace
+ // variable length structures.
+
+ template
+- class _glat_iterator : public std::iterator >
++ class _glat_iterator
+ {
+ unsigned short key() const { return uint16(be::peek(_e) + _n); }
+ unsigned int run() const { return be::peek(_e+sizeof(W)); }
+ void advance_entry() { _n = 0; _e = _v; be::skip(_v,2); }
+ public:
++ using iterator_category = std::input_iterator_tag;
++ using value_type = std::pair;
++ using difference_type = std::pair;
++ using pointer = std::pair*;
++ using reference = std::pair&;
++
+ _glat_iterator(const void * glat=0) : _e(reinterpret_cast(glat)), _v(_e+2*sizeof(W)), _n(0) {}
+
+ _glat_iterator & operator ++ () {
+
diff --git a/docs/development/Electronite/electron.d.ts b/docs/development/Electronite/electron.d.ts
index bc46d191bc13b..b6af4acc2218b 100644
--- a/docs/development/Electronite/electron.d.ts
+++ b/docs/development/Electronite/electron.d.ts
@@ -1,4 +1,4 @@
-// Type definitions for Electron 18.2.1
+// Type definitions for Electron 21.2.0
// Project: http://electronjs.org/
// Definitions by: The Electron Team
// Definitions: https://github.com/electron/electron-typescript-definitions
@@ -8,17786 +8,18115 @@
type GlobalEvent = Event & { returnValue: any };
declare namespace Electron {
- const NodeEventEmitter: typeof import('events').EventEmitter;
+ const NodeEventEmitter: typeof import('events').EventEmitter;
- class Accelerator extends String {
+ class Accelerator extends String {
- }
- interface App extends NodeJS.EventEmitter {
+ }
+ interface App extends NodeJS.EventEmitter {
- // Docs: https://electronjs.org/docs/api/app
+ // 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,
+ /**
+ * 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,
/**
- * A string identifying the activity. Maps to `NSUserActivity.activityType`.
+ * `true` when Chrome's accessibility support is enabled, `false` otherwise.
*/
- type: string,
+ accessibilitySupportEnabled: boolean) => void): this;
+ once(event: 'accessibility-support-changed', listener: (event: Event,
/**
- * A string with the error's localized description.
+ * `true` when Chrome's accessibility support is enabled, `false` otherwise.
*/
- 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;
- /**
- * This event will be emitted within the second instance during the call to
- * `app.requestSingleInstanceLock()`, when the first instance calls the
- * `ackCallback` provided by the `second-instance` event handler.
- */
- on(event: 'first-instance-ack', listener: (event: Event,
+ 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 JSON object of additional data passed from the first instance, in response to
- * the first instance's `second-instance` event.
+ * A string identifying the activity. Maps to `NSUserActivity.activityType`.
*/
- additionalData: unknown) => void): this;
- once(event: 'first-instance-ack', listener: (event: Event,
- /**
- * A JSON object of additional data passed from the first instance, in response to
- * the first instance's `second-instance` event.
- */
- additionalData: unknown) => void): this;
- addListener(event: 'first-instance-ack', listener: (event: Event,
- /**
- * A JSON object of additional data passed from the first instance, in response to
- * the first instance's `second-instance` event.
- */
- additionalData: unknown) => void): this;
- removeListener(event: 'first-instance-ack', listener: (event: Event,
- /**
- * A JSON object of additional data passed from the first instance, in response to
- * the first instance's `second-instance` event.
- */
- additionalData: unknown) => 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.
- *
- * **Note:** `ackCallback` allows the user to send data back to the second instance
- * during the `app.requestSingleInstanceLock()` flow. This callback can be used for
- * cases where the second instance needs to obtain additional information from the
- * first instance before quitting.
- *
- * Currently, the limit on the message size is kMaxMessageLength, or around 32kB.
- * To be safe, keep the amount of data passed to 31kB at most.
- *
- * In order to call the callback, `event.preventDefault()` must be called, first.
- * If the callback is not called in either case, `null` will be sent back. If
- * `event.preventDefault()` is not called, but `ackCallback` is called by the user
- * in the event, then the behaviour is undefined.
- *
- * 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,
- /**
- * A function that can be used to send data back to the second instance
- */
- ackCallback: 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,
- /**
- * A function that can be used to send data back to the second instance
- */
- ackCallback: 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,
- /**
- * A function that can be used to send data back to the second instance
- */
- ackCallback: 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,
- /**
- * A function that can be used to send data back to the second instance
- */
- ackCallback: 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' | 'cache' | '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;
- /**
- * 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 `userData`
- * directory. If you want to change this location, you have to override the
- * `userData` 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,
+ type: string,
/**
- * Location the window is being moved to.
+ * Contains app-specific state stored by the activity.
*/
- 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,
+ 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,
/**
- * Size the window is being resized to.
+ * The error code
*/
- 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.
- */
- isMenuBarAutoHide(): boolean;
- /**
- * Whether the menu bar is visible.
- */
- 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.
- */
- 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.
- */
- 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.
- */
- 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.
- */
- 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`.
- */
- 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`.
- */
- 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`.
- */
- 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`.
- */
- 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.
- */
- 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,
+ 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,
/**
- * The cause of the change with one of the following values:
+ * A string identifying the activity. Maps to `NSUserActivity.activityType`.
*/
- cause: ('explicit' | 'overwrite' | 'expired' | 'evicted' | 'expired-overwrite'),
+ type: string,
/**
- * `true` if the cookie was removed, `false` otherwise.
+ * A string with the error's localized description.
*/
- 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,
+ error: string) => void): this;
+ once(event: 'continue-activity-error', listener: (event: Event,
/**
- * Method name.
+ * A string identifying the activity. Maps to `NSUserActivity.activityType`.
*/
- method: string,
+ type: string,
/**
- * Event parameters defined by the 'parameters' attribute in the remote debugging
- * protocol.
+ * A string with the error's localized description.
*/
- params: any,
+ error: string) => void): this;
+ addListener(event: 'continue-activity-error', listener: (event: Event,
/**
- * Unique identifier of attached debugging session, will match the value sent from
- * `debugger.sendCommand`.
+ * A string identifying the activity. Maps to `NSUserActivity.activityType`.
*/
- 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,
+ type: string,
/**
- * Can be `progressing` or `interrupted`.
+ * A string with the error's localized description.
*/
- 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 `