Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/latest/.sha
Original file line number Diff line number Diff line change
@@ -1 +1 @@
633448a4c19d7c7f8b29a953df14c06d5e6900ee
5147ac2d278f105ec0801c1ef021709979f6d428
26 changes: 18 additions & 8 deletions docs/latest/api/dialog.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ added:
* `window` [BaseWindow](base-window.md) (optional)
* `options` Object
* `title` string (optional)
* `defaultPath` string (optional)
* `defaultPath` string (optional) - Absolute directory path, absolute file
path, or file name to use by default. If not provided, the dialog will
default to the user's Downloads folder, or their home directory if Downloads
doesn't exist.
* `buttonLabel` string (optional) - Custom label for the confirmation button, when
left empty the default label will be used.
* `filters` [FileFilter[]](structures/file-filter.md) (optional)
Expand All @@ -42,7 +45,7 @@ added:
* `openFile` - Allow files to be selected.
* `openDirectory` - Allow directories to be selected.
* `multiSelections` - Allow multiple paths to be selected.
* `showHiddenFiles` _macOS_ _Windows_ _Deprecated_ - Show hidden files in dialog. Deprecated on Linux.
* `showHiddenFiles` _macOS_ _Windows_ - Show hidden files in dialog.
* `createDirectory` _macOS_ - Allow creating new directories from dialog.
* `promptToCreate` _Windows_ - Prompt for creation if the file path entered
in the dialog does not exist. This does not actually create the file at
Expand Down Expand Up @@ -112,7 +115,10 @@ changes:
* `window` [BaseWindow](base-window.md) (optional)
* `options` Object
* `title` string (optional)
* `defaultPath` string (optional)
* `defaultPath` string (optional) - Absolute directory path, absolute file
path, or file name to use by default. If not provided, the dialog will
default to the user's Downloads folder, or their home directory if Downloads
doesn't exist.
* `buttonLabel` string (optional) - Custom label for the confirmation button, when
left empty the default label will be used.
* `filters` [FileFilter[]](structures/file-filter.md) (optional)
Expand All @@ -121,7 +127,7 @@ changes:
* `openFile` - Allow files to be selected.
* `openDirectory` - Allow directories to be selected.
* `multiSelections` - Allow multiple paths to be selected.
* `showHiddenFiles` _macOS_ _Windows_ _Deprecated_ - Show hidden files in dialog. Deprecated on Linux.
* `showHiddenFiles` _macOS_ _Windows_ - Show hidden files in dialog.
* `createDirectory` _macOS_ - Allow creating new directories from dialog.
* `promptToCreate` _Windows_ - Prompt for creation if the file path entered
in the dialog does not exist. This does not actually create the file at
Expand Down Expand Up @@ -199,7 +205,9 @@ added:
* `options` Object
* `title` string (optional) - The dialog title. Cannot be displayed on some _Linux_ desktop environments.
* `defaultPath` string (optional) - Absolute directory path, absolute file
path, or file name to use by default.
path, or file name to use by default. If not provided, the dialog will
default to the user's Downloads folder, or their home directory if Downloads
doesn't exist.
* `buttonLabel` string (optional) - Custom label for the confirmation button, when
left empty the default label will be used.
* `filters` [FileFilter[]](structures/file-filter.md) (optional)
Expand All @@ -209,7 +217,7 @@ added:
* `showsTagField` boolean (optional) _macOS_ - Show the tags input box,
defaults to `true`.
* `properties` string[] (optional)
* `showHiddenFiles` _macOS_ _Windows_ _Deprecated_ - Show hidden files in dialog. Deprecated on Linux.
* `showHiddenFiles` _macOS_ _Windows_ - Show hidden files in dialog.
* `createDirectory` _macOS_ - Allow creating new directories from dialog.
* `treatPackageAsDirectory` _macOS_ - Treat packages, such as `.app` folders,
as a directory instead of a file.
Expand Down Expand Up @@ -237,7 +245,9 @@ changes:
* `options` Object
* `title` string (optional) - The dialog title. Cannot be displayed on some _Linux_ desktop environments.
* `defaultPath` string (optional) - Absolute directory path, absolute file
path, or file name to use by default.
path, or file name to use by default. If not provided, the dialog will
default to the user's Downloads folder, or their home directory if Downloads
doesn't exist.
* `buttonLabel` string (optional) - Custom label for the confirmation button, when
left empty the default label will be used.
* `filters` [FileFilter[]](structures/file-filter.md) (optional)
Expand All @@ -246,7 +256,7 @@ changes:
displayed in front of the filename text field.
* `showsTagField` boolean (optional) _macOS_ - Show the tags input box, defaults to `true`.
* `properties` string[] (optional)
* `showHiddenFiles` _macOS_ _Windows_ _Deprecated_ - Show hidden files in dialog. Deprecated on Linux.
* `showHiddenFiles` _macOS_ _Windows_ - Show hidden files in dialog.
* `createDirectory` _macOS_ - Allow creating new directories from dialog.
* `treatPackageAsDirectory` _macOS_ - Treat packages, such as `.app` folders,
as a directory instead of a file.
Expand Down
3 changes: 3 additions & 0 deletions docs/latest/api/dock.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ Returns `string` - The badge string of the dock.

Hides the dock icon.

> [!IMPORTANT]
> **Known issue:** Calling `dock.hide()` within one second of a previous call will have no effect. As a workaround, ensure at least one second has elapsed between calls — for example, by deferring with a `setTimeout` of 1100ms or more after a previous call.

#### `dock.show()` _macOS_

Returns `Promise<void>` - Resolves when the dock icon is shown.
Expand Down
21 changes: 15 additions & 6 deletions docs/latest/api/environment-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,13 +210,22 @@ the one downloaded by `npm install`. Usage:
export ELECTRON_OVERRIDE_DIST_PATH=/Users/username/projects/electron/out/Testing
```

### `ELECTRON_SKIP_BINARY_DOWNLOAD`
### `ELECTRON_INSTALL_PLATFORM`

If you want to install your project's dependencies but don't need to use Electron functionality,
you can set the `ELECTRON_SKIP_BINARY_DOWNLOAD` environment variable to prevent the binary from being
downloaded. For instance, this feature can be useful in continuous integration environments when
running unit tests that mock out the `electron` module.
Manually overrides platform used by `electron` package during an install.
This can be useful if you are on one platform (e.g macOS) but want to
download binaries for another platform (e.g Windows or Linux). Usage:

```sh
ELECTRON_SKIP_BINARY_DOWNLOAD=1 npm install
ELECTRON_INSTALL_PLATFORM=darwin npm install
```

### `ELECTRON_INSTALL_ARCH`

Manually overrides architecture used by `electron` package during an install.
This can be useful if you are on one arch (e.g `arm64`) but want to download
binaries meant for another arch. Note that this will not work under Rosetta. Usage:

```sh
ELECTRON_INSTALL_ARCH=arm64 npm install
```
7 changes: 7 additions & 0 deletions docs/latest/api/menu-item.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ See [`Menu`](menu.md) for examples.
* `header` - Only available on macOS 14 and up.
* `palette` - Only available on macOS 14 and up.
* `label` string (optional)
* `accessibilityLabel` string (optional) _macOS_
* `sublabel` string (optional) _macOS_ - Available in macOS >= 14.4
* `toolTip` string (optional) _macOS_ - Hover text for this menu item.
* `accelerator` string (optional) - An [Accelerator](../tutorial/keyboard-shortcuts.md#accelerators) string.
Expand Down Expand Up @@ -90,6 +91,12 @@ A `string` indicating the item's visible label.

This property can be dynamically changed.

#### `menuItem.accessibilityLabel` _macOS_

A `string` indicating the item's accessibility label (used by assistive technology), if set.

This property can be dynamically changed.

#### `menuItem.click`

A `Function` that is fired when the MenuItem receives a click event.
Expand Down
46 changes: 44 additions & 2 deletions docs/latest/api/native-image.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,15 @@ Returns `NativeImage`

Creates a new `NativeImage` instance from `dataUrl`, a base 64 encoded [Data URL][data-url] string.

### `nativeImage.createFromNamedImage(imageName[, hslShift])` _macOS_
### `nativeImage.createFromNamedImage(imageName[, options])` _macOS_

* `imageName` string
* `hslShift` number[] (optional)
* `options` Object | number[] (optional) - If `options` is a number array (_Deprecated_), it is interpreted as `hslShift`. If it is an object, the
following properties can be specified:
* `hslShift` number[] (optional)
* `pointSize` Number (optional) - Defaults to `30.0`.
* `weight` 'ultralight' | 'thin' | 'light' | 'regular' | 'medium' | 'semibold' | 'bold' | 'heavy' | 'black' (optional) - Defaults to `regular`.
* `scale` 'small' | 'medium' | 'large' (optional) - Defaults to `medium`.

Returns `NativeImage`

Expand Down Expand Up @@ -246,6 +251,23 @@ const image = nativeImage.createFromNamedImage('square.and.pencil')
where `'square.and.pencil'` is the symbol name from the
[SF Symbols app](https://developer.apple.com/sf-symbols/).

### `nativeImage.createMenuSymbol(imageName)` _macOS_

* `imageName` string

Returns `NativeImage`

Creates a new `NativeImage` instance from an SF Symbol for use in a native [Menu](./menu.md). See [SF Symbols](https://developer.apple.com/sf-symbols/) for a list of possible values.

```js
const { nativeImage, MenuItem } = require('electron')

const item = new MenuItem({
icon: nativeImage.createMenuSymbol('folder.badge.plus'),
label: 'Create Folder'
})
```

## Class: NativeImage

> Natively wrap images such as tray, dock, and application icons.
Expand All @@ -272,8 +294,18 @@ Returns `Buffer` - A [Buffer][buffer] that contains the image's `JPEG` encoded d

#### `image.toBitmap([options])`

```YAML history
changes:
- pr-url: https://github.com/electron/electron/pull/48178
description: "Normalized `NativeImage.toBitmap()` pixel data to sRGB by default."
breaking-changes-header: behavior-changed-nativeimagetobitmap-now-normalizes-color-space
```

* `options` Object (optional)
* `scaleFactor` Number (optional) - Defaults to 1.0.
* `colorSpace` [ColorSpace](structures/color-space.md) (optional) - The target color space
for the output pixel data. Defaults to sRGB. Pass the image's original color space to
preserve the previous behavior, or another color space to get pixel values in that space.

Returns `Buffer` - A [Buffer][buffer] that contains a copy of the image's raw bitmap pixel
data.
Expand All @@ -294,8 +326,18 @@ Returns `string` - The [Data URL][data-url] of the image.

#### `image.getBitmap([options])` _Deprecated_

```YAML history
changes:
- pr-url: https://github.com/electron/electron/pull/48178
description: "Normalized `NativeImage.toBitmap()` pixel data to sRGB by default."
breaking-changes-header: behavior-changed-nativeimagetobitmap-now-normalizes-color-space
```

* `options` Object (optional)
* `scaleFactor` Number (optional) - Defaults to 1.0.
* `colorSpace` [ColorSpace](structures/color-space.md) (optional) - The target color space
for the output pixel data. Defaults to sRGB. Pass the image's original color space to
preserve the previous behavior, or another color space to get pixel values in that space.

Legacy alias for `image.toBitmap()`.

Expand Down
2 changes: 1 addition & 1 deletion docs/latest/api/session.md
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,7 @@ Clears the session’s HTTP cache.
`scheme://host:port`.
* `storages` string[] (optional) - The types of storages to clear, can be
`cookies`, `filesystem`, `indexdb`, `localstorage`,
`shadercache`, `websql`, `serviceworkers`, `cachestorage`. If not
`shadercache`, `serviceworkers`, `cachestorage`. If not
specified, clear all storage types.

Returns `Promise<void>` - resolves when the storage data has been cleared.
Expand Down
5 changes: 3 additions & 2 deletions docs/latest/api/structures/base-window-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,11 @@ hide_title: false
* `accentColor` boolean | string (optional) _Windows_ - The accent color for the window. By default, follows user preference in System Settings. Set to `false` to explicitly disable, or set the color in Hex, RGB, RGBA, HSL, HSLA or named CSS color format. Alpha values will be ignored.
* `trafficLightPosition` [Point](point.md) (optional) _macOS_ -
Set a custom position for the traffic light buttons in frameless windows.
* `roundedCorners` boolean (optional) _macOS_ _Windows_ - Whether frameless window
* `roundedCorners` boolean (optional) - Whether a frameless window
should have rounded corners. Default is `true`. On Windows versions older than
Windows 11 Build 22000 this property has no effect, and frameless windows will
not have rounded corners.
not have rounded corners. On Linux, rounded corners are only drawn when the
desktop environment supports client-side decorations.
* `thickFrame` boolean (optional) _Windows_ - Use `WS_THICKFRAME` style for
frameless windows on Windows, which adds the standard window frame. Setting it
to `false` will remove window shadow and window animations, and disable window
Expand Down
1 change: 1 addition & 0 deletions docs/latest/api/structures/web-preferences.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ hide_title: false
The actual output pixel format and color space of the texture should refer to [`OffscreenSharedTexture`](../structures/offscreen-shared-texture.md) object in the `paint` event.
* `argb` - The requested output texture format is 8-bit unorm RGBA, with SRGB SDR color space.
* `rgbaf16` - The requested output texture format is 16-bit float RGBA, with scRGB HDR color space.
* `nv12` - The requested output texture format is 12bpp with Y plane followed by a 2x2 interleaved UV plane, with REC709 color space.
* `deviceScaleFactor` number (optional) _Experimental_ - The device scale factor of the offscreen rendering output. If not set, will use `1` as default.
* `contextIsolation` boolean (optional) - Whether to run Electron APIs and
the specified `preload` script in a separate JavaScript context. Defaults
Expand Down
2 changes: 1 addition & 1 deletion docs/latest/api/tray.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ app.whenReady().then(() => {

* Tray icon uses [StatusNotifierItem](https://www.freedesktop.org/wiki/Specifications/StatusNotifierItem/)
by default, when it is not available in user's desktop environment the
`GtkStatusIcon` will be used instead.
`GtkStatusIcon` will be used instead. If StatusNotifierItem is available, the first tray icon created will use SNI, while subsequently-created icons will use `GtkStatusIcon`.
* The `click` event is emitted when the tray icon receives activation from
user, however the StatusNotifierItem spec does not specify which action would
cause an activation, for some environments it is left mouse click, but for
Expand Down
7 changes: 7 additions & 0 deletions docs/latest/api/view.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@ Examples of valid `color` values:
> [!NOTE]
> The area cutout of the view's border still captures clicks.

#### `view.setBackgroundBlur(blurRadius)`

* `blurRadius` Integer - The radius of the background blur effect (in pixels).

> [!NOTE]
> You must set a background color with an alpha channel (e.g. `#80ffffff`) in order for the blur effect to be visible.

#### `view.setVisible(visible)`

* `visible` boolean - If false, the view will be hidden from display.
Expand Down
28 changes: 28 additions & 0 deletions docs/latest/api/web-contents.md
Original file line number Diff line number Diff line change
Expand Up @@ -1594,6 +1594,20 @@ Centers the current text selection in web page.

Copy the image at the given position to the clipboard.

#### `contents.copyVideoFrameAt(x, y)`

* `x` Integer
* `y` Integer

When executed on a video media element, copies the frame at (x, y) to the clipboard.

#### `contents.saveVideoFrameAs(x, y)`

* `x` Integer
* `y` Integer

When executed on a video media element, shows a save dialog and saves the frame at (x, y) to disk.

#### `contents.paste()`

Executes the editing command `paste` in web page.
Expand Down Expand Up @@ -2270,6 +2284,20 @@ Returns `Integer` - The Chromium internal `pid` of the associated renderer. Can
be compared to the `frameProcessId` passed by frame specific navigation events
(e.g. `did-frame-navigate`)

#### `contents.clone()`

Returns `WebContents` - A cloned WebContents instance. This method creates a copy
of the WebContents with the following attributes:

* **WebPreferences** - All preferences from the original WebContents are copied
* **SiteInstance** - Uses the same SiteInstance as the original. This means the cloned WebContents will reuse the same render process as the original when loading same-origin pages, and only spawn a new render process for cross-origin navigations. This process allocation behavior is consistent with window.open and tab duplication in Chromium. For more details, see [Chromium's Site Isolation](https://www.chromium.org/developers/design-documents/site-isolation/) design document.
* **Opener relationship** - Inherits the opener (window.opener) relationship
* **Navigation state** - Copies the navigation history and controller state

The cloned WebContents is an independent instance with its own lifecycle that can be destroyed separately and will not contain any open web pages.

This API is useful for use cases where you want to create a new WebContents that shares the same render process with the original for same-origin content, while maintaining full lifecycle independence. Additionally, reusing the existing render process can help optimize memory usage and page load speed to a certain extent, as it eliminates the overhead of spawning and initializing a new render process from scratch.

#### `contents.takeHeapSnapshot(filePath)`

* `filePath` string - Path to the output file.
Expand Down
14 changes: 14 additions & 0 deletions docs/latest/api/web-frame-main.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,20 @@ app.on('web-contents-created', (_, webContents) => {
})
```

#### `frame.copyVideoFrameAt(x, y)`

* `x` Integer
* `y` Integer

When executed on a video media element, copies the frame at (x, y) to the clipboard.

#### `frame.saveVideoFrameAs(x, y)`

* `x` Integer
* `y` Integer

When executed on a video media element, shows a save dialog and saves the frame at (x, y) to disk.

### Instance Properties

#### `frame.ipc` _Readonly_
Expand Down
Loading