Compare commits

...

183 Commits

Author SHA1 Message Date
Shelley Vohr
8608d442e3 wip 2025-07-13 10:50:20 +02:00
John Kleinschmidt
137d4ec329 build: cleanup symlinks in cache (#47727)
* build: cleanup symlinks in cache

* build: ignore broken links

* try --ignore-failed-read

* build: dont deref symlinks

* build: add flag to 7zip to resolve symlink error

Needed to ignore Dangerous symbolic link path was ignored errors

* Revert "build: cleanup symlinks in cache"

This reverts commit 69e53cdc88.
2025-07-11 16:13:12 -04:00
David Sanders
624d085632 build: deep update brace-expansion to resolve an audit alert (#47692) 2025-07-11 09:57:41 +02:00
Robo
600b6b3315 build: reenable v8_enable_temporal_support (#47699)
* build: reenable v8_enable_temporal_support

* ci: test with increased vm map count

* chore: backport PA use fewer vmas by default on linux

* chore: update patches

* Revert "ci: test with increased vm map count"

This reverts commit b626c9a5ab7ad3f01e17d77c330abfd8096a8b02.

* ci: remove logs

---------

Co-authored-by: patchup[bot] <73610968+patchup[bot]@users.noreply.github.com>
2025-07-11 02:49:54 +09:00
David Sanders
9e67bd3508 ci: update audit CI workflow dependencies (#47691)
* ci: update audit CI workflow dependencies

* ci: bump to @electron/fiddle-core@2.0.1
2025-07-10 19:19:36 +02:00
Shelley Vohr
909fd3d55a ci: set git core.longpaths to true (#47695)
ci: set git core.longpaths to true
2025-07-10 19:13:39 +02:00
Niklas Wenzel
f2429c31c1 build: ask bug reporters to check if it is a Chromium issue (#47702)
* build: ask bug reporters to check if it is a Chromium issue

Inspiration: https://github.com/electron/electron/issues/47672#issuecomment-3051298922

* build: fix options
2025-07-10 08:47:04 -07:00
Shelley Vohr
fbb83be785 refactor: use dbus_thread_linux::GetSharedSessionBus() (#47685)
refactor: use dbus_thread_linux::GetSharedSessionBus()
2025-07-10 10:17:34 +02:00
Shelley Vohr
1eab19fc7c build: remove unused script (#47642) 2025-07-09 10:35:04 -04:00
Shelley Vohr
02f2feabe6 docs: update build prerequisites (#47680) 2025-07-09 12:07:24 +02:00
David Sanders
712262597d build: drop eslint-plugin-unicorn (#47676) 2025-07-08 15:20:56 +02:00
Shelley Vohr
31bc5ca903 fix: default to system accent color on invalid user color (#47660)
fix: default to system accent color on invalid user color"
2025-07-08 11:15:13 +02:00
Shelley Vohr
03a02fc31e fix: fullscreen for windows without rounded corners (#47664) 2025-07-08 11:14:14 +02:00
Shelley Vohr
5ef6897bc7 fix: accent color should reflect system settings without restart (#47629)
fix: accentColor should reflect system settings without restart
2025-07-03 18:13:39 +02:00
Charles Kerr
bc585b6a3f refactor: avoid a few unnecessary strings (#47644)
* perf: replace string temporary with string_view in GetXdgAppId()

* perf: replace string temporary with string_view in ToV8(WindowOpenDisposition)

* perf: replace string temporary with string_view in ToV8(electron::api::WebContents::Type)
2025-07-03 11:08:59 -05:00
David Sanders
4c460df0a4 ci: fix audit workflow alerting on stale results (#47643) 2025-07-03 14:42:04 +02:00
Shelley Vohr
cf193b279b fix: crash on source capture with empty thumbnail size (#47641) 2025-07-03 14:41:19 +02:00
Shelley Vohr
655037fbdf fix: window.open popups are always resizable (#47540)
fix: window.open popups are always resizable

Closes https://github.com/electron/electron/issues/43591.

Per current WHATWG spec, the `window.open` API should always
create a resizable popup window. This change updates the
`parseFeaturesString` function to ensure that windows opened
with `window.open` are always resizable, regardless of the
`resizable` feature string.
2025-07-02 15:02:59 +02:00
Samuel Attard
07338bb1cf build: update yarn to 1.22.22 (#47635) 2025-07-02 12:11:42 +02:00
reito
fb0b77b731 feat: add ColorSpace (#47314) 2025-07-02 00:09:09 -07:00
Keeley Hammond
499e987c77 build: set the minimum macOS SDK to 10.15 (#47634)
* build: set the minumum macOS SDK to 10.15

* build: revert "Update mac_sdk_min to match minimum required SDK version"

This reverts commit 3d4654fc18.
2025-07-01 18:51:08 -07:00
Cas_
f7138344d8 docs: discoverability of chromium switches (#44947)
* docs: document discoverability of chromium switches

* docs: fixed typo

* docs: reference chromium endorsed list of swithes

* docs: reorder command-line-switches

* fix: address review

* fix: typo

* fix: wording

* Update command-line-switches.md

fix: lint space

* fix: Update docs/api/command-line-switches.md

Co-authored-by: Keeley Hammond <vertedinde@electronjs.org>

---------

Co-authored-by: Keeley Hammond <vertedinde@electronjs.org>
2025-07-01 14:31:49 -07:00
dependabot[bot]
b9248e6782 build(deps): bump github/codeql-action from 3.29.0 to 3.29.2 (#47622) 2025-07-01 11:12:15 +02:00
Shelley Vohr
af39dcfb09 refactor: use non-deprecated macOS API in RemoveAsDefaultProtocolClient (#47506)
refactor: use non-deprecated macOS API in RemoveAsDefaultProtocolClient
2025-07-01 10:19:28 +02:00
Samuel Attard
d347632046 build: write abi version to published npm package (#47598) 2025-06-30 15:01:09 -07:00
electron-roller[bot]
4f69c5835e chore: bump chromium to 140.0.7261.0 (main) (#47561)
* chore: bump chromium in DEPS to 140.0.7259.0

* chore: update patches

* Add fade in animation to Picture-in-Picture windows

https://chromium-review.googlesource.com/c/chromium/src/+/6538268

* [v8] Use V8 Apis that don't return JSGlobalObject

Refs https://issues.chromium.org/issues/333672197

* chore: IWYU

* chore: bump chromium in DEPS to 140.0.7261.0

* chore: update patches

* revert: update to siso-chromium image

* [v8] Use v8::Object::WrapGlobal()

Refs https://chromium-review.googlesource.com/c/chromium/src/+/6650977

* chore: IWYU

* chore: fix --trace-startup spec

---------

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: deepak1556 <hop2deep@gmail.com>
2025-06-30 12:30:05 -04:00
Taiki Komoda
fa15332587 docs: update automated-testing.md (#47017)
* Update automated-testing.md

* fixed lint error
2025-06-30 10:56:48 +02:00
Shelley Vohr
e299a1d098 feat: support complete WebUSB device properties (#47459)
* feat: support complete WebUSB device properties

* docs: correct type consistency
2025-06-30 10:28:21 +02:00
Charles Kerr
c2302960a8 refactor: reduce scope of temporaries when getting dictionary values (#47581)
refactor: reduce scale of temporaries when getting dictionary values
2025-06-29 21:58:18 +02:00
Charles Kerr
5e862f398e fix: Reland "[accessibility] Platform node lifetime cleanups" (#47590)
Reland "[accessibility] Platform node lifetime cleanups"

https://chromium-review.googlesource.com/c/chromium/src/+/6462552
2025-06-29 21:57:48 +02:00
Shelley Vohr
61c245761c test: fix nan tests on macOS (#47583) 2025-06-29 21:57:44 +02:00
Charles Kerr
7c55b24be2 refactor: avoid copies of large objects in range based for loops (#47588)
* Avoid copies of large objects in range-based for-loops.

Xref: https://chromium-review.googlesource.com/c/chromium/src/+/6527689

* Avoid copies of large objects in range-based for-loops in Browser::ShowAboutPanel()
2025-06-29 21:32:26 +02:00
Charles Kerr
4af248f2b6 perf: avoid copying a vector when calling ConvertToWeakPtrVector() (#47593) 2025-06-29 21:32:03 +02:00
Erick Zhao
69e9b653ba docs: update example apps (#47597) 2025-06-29 21:31:42 +02:00
electron-roller[bot]
4dccccadbb chore: bump node to v22.17.0 (main) (#47557)
* chore: bump node in DEPS to v22.17.0

* build: use //third_party/simdutf by default in GN

https://github.com/nodejs/node/pull/58115

* chore: adjust crypto specs:

- https://github.com/nodejs/node/pull/58117
- https://github.com/nodejs/node/pull/58387

* deps: update libuv to 1.51.0

https://github.com/nodejs/node/pull/58124

* test: fix test-buffer-tostring-range on allocation failure

https://github.com/nodejs/node/pull/58416

* build: use FILE_OFFSET_BITS=64 esp. on 32-bit arch

https://github.com/nodejs/node/pull/58090

* build: use //third_party/simdutf by default in GN

https://github.com/nodejs/node/pull/58115

* inspector: add protocol method Network.dataReceived

https://github.com/nodejs/node/pull/58001

* test: force slow JSON.stringify path for overflow

https://github.com/nodejs/node/pull/58181

* chore: fixup patch indices

* 6049967: Remove protocol::Maybe and roll inspector_protocol

https://chromium-review.googlesource.com/c/chromium/src/+/6049967

* chore: fixup crypto test patch

* src: fix module buffer allocation

https://github.com/nodejs/node/pull/57738

* crypto: expose process.features.openssl_is_boringssl

https://github.com/nodejs/node/pull/58387

* util: add internal assignFunctionName() function

https://github.com/nodejs/node/pull/57916

* build: fix pointer compression builds

https://github.com/nodejs/node/pull/58171

* chore: put back config options

* fixup! deps: update libuv to 1.51.0

---------

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2025-06-28 16:33:09 +02:00
Charles Kerr
79cd6a2614 refactor: sync IsKillURL() with upstream impl in extension_tab_util.cc (#47580)
Use base::MakeFixedFlatSet()
2025-06-27 15:49:41 -05:00
Charles Kerr
2ba8fe9140 refactor: extract-constant static Windows registry keys in Browser code (#47569)
* refactor: extract-constant for registry key in GetProcessExecPath()

* refactor: extract-constant for registry key in Browser::SetLoginItemSettings()

* refactor: extract-constant for registry key in Browser::SetLoginItemSettings()

* refactor: extract-constant for registry key in Browser::GetLoginItemSettings()

* chore: document the symbolic constants

* refactor: prefer base::wcstring_view::c_str() to data() to make zero-termination clearer
2025-06-27 10:34:55 -05:00
Charles Kerr
b21c4b0f88 refactor: make context bridge's private keys hidden, constexpr string_views (#47562)
* refactor: local functions GetPrivate(), SetPrivate() now take std::string_views

* refactor: make local keys std::string_views instead of C-style char arrays

* refactor: make local keys constexpr

* refactor: move local keys into local anonymous namespace
2025-06-27 09:29:53 -05:00
Charles Kerr
f50ad3d022 refactor: remove stray .c_str() calls for absl::StrFormat() (#47548)
refactor: remove stray .c_str() calls for absl::StrFormat()

StrFormat() understands std::string, std::string_view
2025-06-26 11:41:30 +02:00
Keeley Hammond
7a274a711c fix: revert upstream MacOS mouse event routing (#47560)
* fix: revert upstream MacOS mouse event routing

* fix: reduce patch surface area

* chore: update patches
2025-06-26 11:41:11 +02:00
Niklas Wenzel
bc499ffb8a docs: fix --experimental-network-inspection spelling (#47565)
doc: fix `--experimental-network-inspection` spelling
2025-06-26 11:40:55 +02:00
Niklas Wenzel
0a74e91580 docs: update asar integrity fuse availability (#47528) 2025-06-25 23:15:59 +02:00
electron-roller[bot]
035879357e chore: bump chromium to 139.0.7256.0 (main) (#47481)
* chore: bump chromium in DEPS to 139.0.7242.0

* chore: update render_widget_host_view_mac.patch

no code changes; just updating patch context

Do a cleanup pass on the history swiper code | https://chromium-review.googlesource.com/c/chromium/src/+/6604367

* chore: update mas_avoid_private_macos_api_usage.patch.patch

no code changes; just updating patch context

[tracing] Delete base/trace_event/base_tracing.h | https://chromium-review.googlesource.com/c/chromium/src/+/6624012

* chore: update chore_provide_iswebcontentscreationoverridden_with_full_params.patch

no manual changes; just updating patch context

[ActorFramework] Refactor Actor Task Management | https://chromium-review.googlesource.com/c/chromium/src/+/6618684

* chore: update fix_move_autopipsettingshelper_behind_branding_buildflag.patch

[pip] Tuck picture-in-picture windows when a file dialog is open | https://chromium-review.googlesource.com/c/chromium/src/+/6449682

Reland "[document pip] Restrict the size that a website can request" | https://chromium-review.googlesource.com/c/chromium/src/+/6372104

* chore: update feat_corner_smoothing_css_rule_and_blink_painting.patch

Xref: corner-shape: constraint radii based on opposite corner overlap | https://chromium-review.googlesource.com/c/chromium/src/+/6592572

* chore: update revert_code_health_clean_up_stale_macwebcontentsocclusion.patch

no manual changes; just updating patch context

* chore: update fix_rename_sqlite_win32_exports_to_avoid_conflicts_with_node_js.patch

no code changes; just updating patch context

* chore: e patches all

* Plumb Verify2QwacBinding and hook it up in QwacWebContentsObserver

https://chromium-review.googlesource.com/c/chromium/src/+/6624719

* [Extensions] Remove host delegate OnMainFrameCreatedForBackgroundPage

https://chromium-review.googlesource.com/c/chromium/src/+/6631123

* Extensions: Rename GetResourceURL to ResolveExtensionURL

https://chromium-review.googlesource.com/c/chromium/src/+/6625053

* [NonClientFrameView] Consolidate NativeFrameViewMac

https://chromium-review.googlesource.com/c/chromium/src/+/6614239

* ICWYU

* [views-ax] Remove dead code WidgetAXTreeIDMap

https://chromium-review.googlesource.com/c/chromium/src/+/6619701

* Reland "extensions: Add `WillPrepareForEvaluation` to setup MojoJS"

https://chromium-review.googlesource.com/c/chromium/src/+/6630056

* NavigationThrottleRunner2: Remove MaybeAddThrottle

https://chromium-review.googlesource.com/c/chromium/src/+/6628079

* [pip] Tuck picture-in-picture windows when a file dialog is open

https://chromium-review.googlesource.com/c/chromium/src/+/6449682

* build: fix snapshot_blob.bin build error

xref: https://issues.chromium.org/issues/416540976

* chore: e patches all

* build: freeup disk space on macos

* chore: bump chromium in DEPS to 139.0.7244.0

* chore: update printing.patch

no manual changes; just updating patch context

* chore: remove upstreamed ignore_parse_errors_for_resolveshortcutproperties.patch

Prevent Windows crash on unexpected shortcut type | https://chromium-review.googlesource.com/c/chromium/src/+/6633298

* chore: e patches all

* Revert "Reland "extensions: Add `WillPrepareForEvaluation` to setup MojoJS""

This reverts commit 77c4f967a6.

Revert CL for the high confidence crash culprit for http://crash/28f897bb9743dfe0 | https://chromium-review.googlesource.com/c/chromium/src/+/6641819

* Fix spec's expected base64-encoded PNG strings to match upstream changes.

[rust png] Enable by default. | https://chromium-review.googlesource.com/c/chromium/src/+/6085801

* chore: bump chromium in DEPS to 139.0.7246.0

* chore: e patches all

* chore: bump chromium in DEPS to 139.0.7248.0

* chore: update patches

* siso: Enable Siso by default for non-Google builds

https://chromium-review.googlesource.com/c/chromium/src/+/6638830

Disabling for now until we are ready to build siso on all platforms.

* Revert "revert Don't use static variable for UseExternalPopupMenus"

This reverts commit e91e3894e6.

* Update mac_sdk_min to match minimum required SDK version

https://chromium-review.googlesource.com/c/chromium/src/+/6493969
(cherry picked from commit 3e7cbe912d)

* [video pip] Use default window styling on Mac

https://chromium-review.googlesource.com/c/chromium/src/+/6648665

* Reland "Force the unintentional renderer process creation check by default"

https://chromium-review.googlesource.com/c/chromium/src/+/6626905

* fixup: Reland "Force the unintentional renderer process creation check by default

https://chromium-review.googlesource.com/c/chromium/src/+/6626905

* chore: bump chromium in DEPS to 139.0.7249.0

* fixup: Reland "Force the unintentional renderer process creation check by default

https://chromium-review.googlesource.com/c/chromium/src/+/6626905

* chore: update patches

* chore: bump chromium in DEPS to 139.0.7250.0

* chore: bump chromium in DEPS to 139.0.7252.0

* chore: bump chromium in DEPS to 139.0.7254.0

* 6638187: browser level TOCTOU check for coordinate target

https://chromium-review.googlesource.com/c/chromium/src/+/6638187

* chore: fixup patch indices

* chore: add missing base/notimplemented includes

* 6652910: [Frame Cleanup] Push down/hide implementation-specific API

https://chromium-review.googlesource.com/c/chromium/src/+/6652910

* chore: bump chromium in DEPS to 139.0.7256.0

* chore: fix lint

* fixup! 6652910: [Frame Cleanup] Push down/hide implementation-specific API

* fix: move HandleScope location

* chore: bump chromium in DEPS to 139.0.7258.0

* fixup! [NonClientFrameView] Consolidate NativeFrameViewMac

* Revert "chore: bump chromium in DEPS to 139.0.7258.0"

This reverts commit 264b2e934f.

---------

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
Co-authored-by: deepak1556 <hop2deep@gmail.com>
2025-06-26 00:12:49 +09:00
Felix Rieseberg
e4c37e4b38 docs: Add C++/Linux tutorial (#46822) 2025-06-25 12:57:43 +02:00
Calvin
828fc84e60 build: update NMV to 139 (#47529) 2025-06-24 12:24:17 -04:00
Shelley Vohr
51fbc964a6 fix: ensure /dev/null fd is closed on failure (#47525)
* fix: ensure /dev/null fd is closed on failure

* chore: ignore closehandle for windows

---------

Co-authored-by: Robo <hop2deep@gmail.com>
2025-06-24 17:44:50 +02:00
Shelley Vohr
3e8e87d186 feat: support customizing window accent color on Windows (#47285) 2025-06-24 14:43:02 +02:00
Samuel Attard
498f4bc98c build: rewrite push-patch to use the github API instead of local git commits to ensure commits are signed (#47401)
* build: rewrite push-patch to use the github API instead of local git commits to ensure commits are signed

* again

(cherry picked from commit a21afc3e45)

* use pr head ref

(cherry picked from commit 0edcc985fa)
2025-06-23 22:26:43 -07:00
Michaela Laurencin
a6ad5a6e60 docs: update timelines for E38 (#47488)
Update electron-timelines.md
2025-06-23 15:50:22 +02:00
Shelley Vohr
93d5152a25 fix: chrome://accessibility loading correctly (#47497)
fix: chrome://accessibility loading correctly
2025-06-23 14:38:29 +02:00
Shelley Vohr
fb65124234 chore: fix nightly issues getting unsupported label comment (#47503)
* chore: fix nightly issues getting unsupported label comment

* chore: address review feedback
2025-06-23 14:22:41 +02:00
dependabot[bot]
93f4b3cf9f build(deps): bump github/codeql-action from 3.28.19 to 3.29.0 (#47486)
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.28.19 to 3.29.0.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](fca7ace96b...ce28f5bb42)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: 3.29.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-06-23 11:24:18 +02:00
Charles Kerr
bb22eaccec refactor: simplify titlebar overlay initialization (#47480) 2025-06-23 11:24:05 +02:00
David Sanders
90a14299fd ci: fix sending Slack message in CI audit workflow (#47494) 2025-06-23 11:23:39 +02:00
Shelley Vohr
60924690d9 build: combine dependent libc patch (#47491) 2025-06-23 11:22:35 +02:00
John Kleinschmidt
9b158238dc build: update cache action to latest (#47501) 2025-06-23 11:22:14 +02:00
Samuel Attard
dac5e0cd1a build: add siso backend.star (#47509) 2025-06-20 11:25:27 -07:00
Robo
626895848e fix: utilityProcess running user script after process.exit is called (#47469)
* fix: utilityProcess running user script after process.exit is called

* docs: update breaking changes

* chore: update spec

* chore: update spec/api-utility-process-spec.ts

Co-authored-by: David Sanders <dsanders11@ucsbalum.com>

* chore: remove interface bound checks

---------

Co-authored-by: Niklas Wenzel <dev@nikwen.de>
Co-authored-by: David Sanders <dsanders11@ucsbalum.com>
2025-06-18 04:36:22 +09:00
Keeley Hammond
3536d4976a fix: revert moving IsClosed() and IsClosable() into NativeWindow::Close() (#47482)
Revert "refactor: move `IsClosed()` and `IsClosable()` tests into `NativeWindow::Close()` (#46888)"

This reverts commit 3faddd5ae2.
2025-06-16 16:41:19 -07:00
Shelley Vohr
2ad762e075 feat: support HIDDevice.collections (#47391)
* feat: support HIDDevice.collections

* Update docs/api/structures/hid-device.md

Co-authored-by: Erick Zhao <ezhao@slack-corp.com>

---------

Co-authored-by: Erick Zhao <ezhao@slack-corp.com>
2025-06-16 15:56:08 -04:00
electron-roller[bot]
6779769d22 chore: bump chromium to 139.0.7219.0 (main) (#47348)
* chore: bump chromium in DEPS to 139.0.7205.0

* 6543986: Mac: decouple deserializing and applying sandbox policy

Refs https://chromium-review.googlesource.com/c/chromium/src/+/6543986

* 6580079: Reland 'Remove the third-party blocking feature'
Refs https://chromium-review.googlesource.com/c/chromium/src/+/6580079

* 6505716: guest-contents: Add components/guest_contents
Refs https://chromium-review.googlesource.com/c/chromium/src/+/6505716

* 6572556: Move LogMessageManager out of gpu_service_impl.cc.
Refs https://chromium-review.googlesource.com/c/chromium/src/+/6572556

* 6566111: Change UtilityProcessHost to manage its instance internally
Refs https://chromium-review.googlesource.com/c/chromium/src/+/6566111

* 6550237: Rename ReconnectEventObserver to ConnectionChangeObserverClient
Refs https://chromium-review.googlesource.com/c/chromium/src/+/6550237

* 6565918: Validate path is valid UTF8 in SelectFileDialogLinuxPortal
Refs https://chromium-review.googlesource.com/c/chromium/src/+/6565918

* 6579713: Remove base::NotFatalUntil::M130 usage
6566111: Change UtilityProcessHost to manage its instance internally
Refs
https://chromium-review.googlesource.com/c/chromium/src/+/6579713
https://chromium-review.googlesource.com/c/chromium/src/+/6566111

* chore: update chromium patches

* chore: update remaining patches

* fixup! 6566111: Change UtilityProcessHost to manage its instance internally Refs https://chromium-review.googlesource.com/c/chromium/src/+/6566111

* 6577970: Remove superfluous includes for base/strings/stringprintf.h in headers
Refs https://chromium-review.googlesource.com/c/chromium/src/+/6577970

* 6568811: Add FunctionCall structured metrics event for DevTools
Refs https://chromium-review.googlesource.com/c/chromium/src/+/6568811

* [PDF Ink Signatures] Support PdfAnnotationsEnabled policy
https://chromium-review.googlesource.com/c/chromium/src/+/6558970

* build: disable libcxx modules for rbe

* chore: bump chromium in DEPS to 139.0.7217.0

* chore: bump chromium in DEPS to 139.0.7218.0

* chore: update patches

fix_use_delegated_generic_capturer_when_available.patch was updated to handle a small change:
6582142: Use content::Create*Capturer in DesktopCaptureDevice. | https://chromium-review.googlesource.com/c/chromium/src/+/6582142

* chore: bump chromium in DEPS to 139.0.7219.0

* chore: update patches

* 6594615: Change Chromium's deployment target to macOS 12
https://chromium-review.googlesource.com/c/chromium/src/+/6594615

Updated the assertion message to match the docs structure now too. I removed the callout to the supported versions doc because it has moved and doesn't contain minimum platform version information.

* 6606232: [views] Remove DesktopWindowTreeHostWin::window_enlargement_
https://chromium-review.googlesource.com/c/chromium/src/+/6606232

|NativeWindow::GetContentMinimumSize| and |NativeWindow::GetContentMaximumSize| may be good opportunities for a refactor now.

* add squirrel.mac patch for removed function

This was triggered by the macOS 12.0 deployment upgrade change.

See: https://developer.apple.com/documentation/coreservices/1444079-uttypeconformsto?language=objc

* 6582142: Use content::Create*Capturer in DesktopCaptureDevice.
https://chromium-review.googlesource.com/c/chromium/src/+/6582142

* 6579732: Two minor API "quality of life" cleanups in OSCrypt Async
https://chromium-review.googlesource.com/c/chromium/src/+/6579732

* chore: add include for base::SingleThreadTaskRunner

Not sure what change caused this, I expect it would be a removed include somewhere else, but it's likely not important to track down.

* chore: update libcxx filenames

* chore: update CI build-tools commit target for macOS SDK 15.4

The following change uses an API that was added in the macOS 15.4 SDK. Support for that SDK version was added later than the current build-tools commit target.

6575804: Use a quick-and-dirty solution to avoid glitching with paste-and-go | https://chromium-review.googlesource.com/c/chromium/src/+/6575804

See: https://developer.apple.com/documentation/appkit/nspasteboard/accessbehavior-swift.enum?language=objc

* fixup! 6606232: [views] Remove DesktopWindowTreeHostWin::window_enlargement_ https://chromium-review.googlesource.com/c/chromium/src/+/6606232

* chore: bump chromium in DEPS to 139.0.7220.0

* chore: update patches

Minor changes due to:

6613978: pwa: let events fall through in the transparent area of TopContainerView | https://chromium-review.googlesource.com/c/chromium/src/+/6613978
6614778: Refactor auto pip tab observer for Android support | https://chromium-review.googlesource.com/c/chromium/src/+/6614778

* 6543986: Mac: decouple deserializing and applying sandbox policy
https://chromium-review.googlesource.com/c/chromium/src/+/6543986

The DecodeVarInt and DecodeString functions look benign from a MAS perspective. I suspect they were patched out to avoid "unused function" errors. Their complements for encoding are unpatched, supporting this idea.

The code that uses these functions was refactored out of the section that we patch out. Instead of patching out that new function, I decided to treat it the same as the serialization function that is unpatched.

* chore: bump chromium in DEPS to 139.0.7222.0

* chore: bump chromium in DEPS to 139.0.7224.0

* chore: bump chromium in DEPS to 139.0.7226.0

* chore: bump chromium in DEPS to 139.0.7228.0

* chore: update patches

* Don't use static variable for UseExternalPopupMenus

https://chromium-review.googlesource.com/c/chromium/src/+/6534657

* Reland "Roll libc++ from a01c02c9d4ac to a9cc573e7c59

https://chromium-review.googlesource.com/c/chromium/src/+/6607589

* chore: bump chromium in DEPS to 139.0.7219.0

* chore: update patches

* revert Don't use static variable for UseExternalPopupMenus

* tls: remove deprecated tls.createSecurePair and SecurePair

https://github.com/nodejs/node/pull/57361

* Revert "Reland "Roll libc++ from a01c02c9d4ac to a9cc573e7c59"

This reverts commit 33e1436a0c.

* test: cleanup api-desktop-capturer-spec.ts

* test: more cleanup of api-desktop-capturer-spec.ts

* chore: debug dcheck error in webrtc on linux

* fixup patch

* add debugging to desktop capturer spec

* test: fixup api-desktop-capturer-spec.ts for linux

* chore: remove debugging patch

* Revert "fixup! 6606232: [views] Remove DesktopWindowTreeHostWin::window_enlargement_ https://chromium-review.googlesource.com/c/chromium/src/+/6606232"

This reverts commit 32e75651c1.

* Revert "6606232: [views] Remove DesktopWindowTreeHostWin::window_enlargement_"

This reverts commit 89c51aa1c7.

* [views] Remove DesktopWindowTreeHostWin::window_enlargement_

https://chromium-review.googlesource.com/c/chromium/src/+/6606232

Reverting as we need this functionality for now.

* fixup: remove patch that was accidentally added back

---------

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: Samuel Maddock <smaddock@slack-corp.com>
Co-authored-by: deepak1556 <hop2deep@gmail.com>
Co-authored-by: clavin <clavin@electronjs.org>
Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
2025-06-16 12:46:06 -05:00
Shelley Vohr
96fcc2f8c8 chore: exempt upgrade-follow-up issues from stale (#47460)
chore: exempt upgrade-follow-upissues from stale
2025-06-14 21:43:57 -07:00
Charles Kerr
3c9b8475a2 refactor: move gin::Converter<PreloadScript> impl to a .cc file (#47445)
refactor: move gin::Converter<PreloadScript> impl to a .cc file
2025-06-13 10:15:32 +02:00
Charles Kerr
6f915e85e2 refactor: have ShowSaveDialogSync() return a std::optional<base::FilePath> (#47428)
* refactor: have ShowSaveDialogSync() return a std::optional<base::FilePath>

* fixup! refactor: have ShowSaveDialogSync() return a std::optional<base::FilePath>
2025-06-12 12:25:40 +02:00
Anny Yang
0259abe920 docs: update remaining references to electron-quick-start (#47405)
* chore: udpate remaining references to electron-quick-start

* chore: Update docs/tutorial/tutorial-1-prerequisites.md

Co-authored-by: Niklas Wenzel <dev@nikwen.de>

* chore: Update docs/tutorial/tutorial-3-preload.md

Co-authored-by: Niklas Wenzel <dev@nikwen.de>

* chore: Update docs/tutorial/tutorial-2-first-app.md

Co-authored-by: Niklas Wenzel <dev@nikwen.de>

* chore: linebreak

* chore: swap minimal-repro for npx create-electron-app

* chore: add back code commands

* chore: add whitespace

* chore: remove reference to repo containing old quick start

---------

Co-authored-by: Niklas Wenzel <dev@nikwen.de>
2025-06-12 10:32:17 +02:00
Shelley Vohr
38fe14041d fix: crash calling Fetch.continueResponse with WebContentsView (#47434)
fix: crash calling Fetch.continueResponse with WebContentsView
2025-06-11 15:43:47 +02:00
dependabot[bot]
996945d3e3 build(deps): bump github/codeql-action from 3.28.18 to 3.28.19 (#47426)
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.28.18 to 3.28.19.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](ff0a06e83c...fca7ace96b)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: 3.28.19
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-06-11 11:24:03 +02:00
Niklas Wenzel
d7ef8b79ae docs: mention kwallet6 command line option (#47427) 2025-06-10 16:12:31 -04:00
Erick Zhao
6aa3665b96 docs: no class inheritance (#47403) 2025-06-10 10:00:06 +02:00
Robo
c964296ec3 feat: add support for --no-experimental-global-navigator (#47370)
chore: add support for --no-experimental-global-navigator
2025-06-09 14:57:27 +09:00
David Sanders
6f48e3ab12 ci: fix up branch CI audit workflow (#47404) 2025-06-07 09:58:48 +02:00
Shelley Vohr
06bc59be88 fix: rework lifetime mgmt of ClearDataTask/ClearDataOperation (#47361)
* fix: rework lifetime mgmt of ClearDataTask/ClearDataOperation

* Update shell/browser/api/electron_api_session.cc

Co-authored-by: Robo <hop2deep@gmail.com>

* Update shell/browser/api/electron_api_session.cc

Co-authored-by: Robo <hop2deep@gmail.com>

* Update shell/browser/api/electron_api_session.cc

Co-authored-by: Robo <hop2deep@gmail.com>

* Update shell/browser/api/electron_api_session.cc

Co-authored-by: Robo <hop2deep@gmail.com>

---------

Co-authored-by: Robo <hop2deep@gmail.com>
2025-06-07 08:00:30 +02:00
David Sanders
0b84c68229 ci: ignore network-related error annotations in audit (#47333)
* ci: ignore network-related error annotation in audit

* chore: add another error message
2025-06-06 16:52:25 -04:00
Shelley Vohr
09a0926c5b fix: printing PDF via webContents.print() (#47377)
fix: printing PDF via webContents.print()
2025-06-06 14:20:37 -04:00
Shelley Vohr
6606230813 fix: silent printing of PDFs with webContents.print (#47378)
fix: silent printing
2025-06-06 14:19:08 -04:00
David Sanders
a42afaa866 chore: fix docs lint (#47389) 2025-06-06 10:01:26 +02:00
John Kleinschmidt
b1f0ab11c5 build: cache gitcache dir (#47328)
* revert build: migrate to new chromium git auth

* build: cache gitcache dir
2025-06-05 17:00:21 -04:00
David Sanders
4c3e2eb560 build(deps-dev): bump husky and lint-staged (#47291) 2025-06-05 20:23:55 +02:00
Niklas Wenzel
72340e79e8 docs: remove electron-quick-start from README (#47359)
Refs https://github.com/electron/.permissions/pull/293

The repo was renamed to `minimal-repro` and is no longer intended to be used as a way to start new projects (see PR above).

Since we really want bugs in `electron/electron` to be reported with a Fiddle gist instead of a standalone repo (makes reproducing and bisecting sooo much easier and safer!), I removed the repo from the README completely instead of mentioning as an issue reproduction starting point.
2025-06-05 20:12:21 +02:00
Niklas Wenzel
7196a28d3a docs: mention Azure Trusted Signing (#47323) 2025-06-05 19:13:39 +02:00
Shelley Vohr
6c96979b6c chore: remove unused spec-chromium (#47367)
chore: remove unused spec-chromium
2025-06-05 15:50:19 +02:00
Felix Rieseberg
5cbab906c9 docs: Add Swift/macOS tutorial (#46697)
Co-authored-by: Felix Rieseberg <fr@makenotion.com>
2025-06-05 15:45:04 +02:00
Erick Zhao
2a51a997eb docs: update link to runAsNode fuse (#47350) 2025-06-05 10:03:58 +02:00
Shelley Vohr
fbb3fa7503 feat: allow intercepting mouse events (#47280)
* feat: allow intercepting mouse events

* test: add specs

* Update spec/api-web-contents-spec.ts

Co-authored-by: David Sanders <dsanders11@ucsbalum.com>

---------

Co-authored-by: David Sanders <dsanders11@ucsbalum.com>
2025-06-04 14:10:33 +02:00
Shelley Vohr
c22f94037a docs: document possible print failureReasons (#47337)
docs: document possible print failureReasons
2025-06-04 14:09:24 +02:00
John Kleinschmidt
ba7c3bbdf7 chore: update patches (#47346) 2025-06-03 13:52:17 -04:00
electron-roller[bot]
53fd879043 chore: bump chromium to 138.0.7190.0 (main) (#47107)
* chore: bump chromium in DEPS to 138.0.7180.0

* 6546797: Add a metric for the overall success of the "safe storage" item retrieval.

Refs https://chromium-review.googlesource.com/c/chromium/src/+/6546797

* 6548078: extensions: Fix TODO in ScriptInjectionTracker for desktop Android

Refs https://chromium-review.googlesource.com/c/chromium/src/+/6548078

* 6544950: Revert "FSA: Only normalize the hardcoded rules once during initialization"

Refs https://chromium-review.googlesource.com/c/chromium/src/+/6544950

* chore: bump chromium in DEPS to 138.0.7181.0

* chore: update patches

* fix: correctly clamp HSL shift values between 0 and 1

* chore: bump DEPS to 138.0.7183.0

* 6553142: Remove SelectFileDialogLinuxKde | https://chromium-review.googlesource.com/c/chromium/src/+/6553142

* chore: update patches

* chore: bump chromium in DEPS to 138.0.7184.0

* chore: bump chromium in DEPS to 138.0.7186.0

* chore: bump chromium in DEPS to 138.0.7190.0

* chore: update patches

* 6547778: Remove some superfluous //ui/gfx includes from //chrome headers | https://chromium-review.googlesource.com/c/chromium/src/+/6547778

* 6556022: Reland FSA: Only normalize the hardcoded rules once during initialization | https://chromium-review.googlesource.com/c/chromium/src/+/6556022

* fix: remove pdf_extension_util::AddAdditionalData
https://chromium-review.googlesource.com/c/chromium/src/+/4099130

This was removed 2 years ago in Chrome.

* fix: provide BrowserContext to pdf_extension_util::AddAdditionalData
https://chromium-review.googlesource.com/c/chromium/src/+/6558173

* fixup! 6556022: Reland FSA: Only normalize the hardcoded rules once during initialization | https://chromium-review.googlesource.com/c/chromium/src/+/6556022

* fix: pass in navigation throttle registry
https://chromium-review.googlesource.com/c/chromium/src/+/6536175

* fixup! 6556022: Reland "FSA: Only normalize the hardcoded rules once during initialization" | https://chromium-review.googlesource.com/c/chromium/src/+/6556022

This partially reverts commit 20d709dd15ba0ff332e24ee314149d642dc5d47c.

* 6545984: corner-shape: render dashed & dotted borders
Refs https://chromium-review.googlesource.com/c/chromium/src/+/6545984

* Update corner smoothing expected images

* Apply "future" revert commit to fix windows build

> Reason for revert: Multiple eng reporting that this is causing build failures due to too-long pathnames, with no immediate feasible workaround

This issue also affects our CI builds.

Problematic CL in current roll: 6494836: [webgl] Add stub WebGL[2]RenderingContextWebGPU | https://chromium-review.googlesource.com/c/chromium/src/+/6494836
"Future" revert CL: 6565622: Revert "[webgl] Add stub WebGL[2]RenderingContextWebGPU" | https://chromium-review.googlesource.com/c/chromium/src/+/6565622

This patch should automatically disappear when we roll the revert.

* 6533919: win: don't add WS_CAPTION style to popup windows
https://chromium-review.googlesource.com/c/chromium/src/+/6533919

This mirrors the change made earlier to the code ours is based on: 6374074: [headless] Provide headless aware window metrics on Windows | https://chromium-review.googlesource.com/c/chromium/src/+/6374074

---------

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: David Sanders <dsanders11@ucsbalum.com>
Co-authored-by: Keeley Hammond <khammond@slack-corp.com>
Co-authored-by: Samuel Maddock <smaddock@slack-corp.com>
Co-authored-by: clavin <clavin@electronjs.org>
2025-06-03 11:19:20 -04:00
Shelley Vohr
5f5e8d012d fix: add back fallback wasm-trap handling (#47186)
* fix: add back fallback wasm-trap handling

Refs https://chromium-review.googlesource.com/c/chromium/src/+/5372409

This change sets up wasm-trap handling for the case where content_shell
has not enabled crash reporting but moves the responsibility to
ElectronRendererClient. The default ContentRendererClient assumes
that crash reporting is enabled (crashpad enabled by default) and does
not set up its own handler.

* chore: fix build

---------

Co-authored-by: deepak1556 <hop2deep@gmail.com>
2025-06-03 15:31:23 +02:00
Calvin
508c601996 fix: do not load source for electron module in ESM loader synchronous flow (#46810) 2025-06-03 12:50:17 +02:00
Sta Zhu
158176f0f3 fix: addChildView() crashes when adding a closed WebContentsView (#47099)
fix: addChildView() crashes when add a closed WebContentsView
2025-06-03 10:53:25 +02:00
dependabot[bot]
d1e64c37a2 build(deps): bump ossf/scorecard-action from 2.4.1 to 2.4.2 (#47329)
Bumps [ossf/scorecard-action](https://github.com/ossf/scorecard-action) from 2.4.1 to 2.4.2.
- [Release notes](https://github.com/ossf/scorecard-action/releases)
- [Changelog](https://github.com/ossf/scorecard-action/blob/main/RELEASE.md)
- [Commits](f49aabe0b5...05b42c6244)

---
updated-dependencies:
- dependency-name: ossf/scorecard-action
  dependency-version: 2.4.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-06-03 10:18:03 +02:00
Shelley Vohr
17ba863f69 docs: correct 'select-bluetooth-device' requirement (#47325) 2025-06-03 10:16:16 +02:00
electron-roller[bot]
82a59d9894 chore: bump node to v22.16.0 (main) (#47217)
* chore: bump node in DEPS to v22.16.0

* crypto: remove BoringSSL dh-primes addition

https://github.com/nodejs/node/pull/57023

* tools: enable linter in test/fixtures/test\-runner/output

https://github.com/nodejs/node/pull/57698

* src: improve thread safety of TaskQueue

https://github.com/nodejs/node/pull/57910

* buffer: define global v8::CFunction objects as const

https://github.com/nodejs/node/pull/57676

* src: disable abseil deadlock detection

https://github.com/nodejs/node/pull/57582

* zlib: fix pointer alignment

https://github.com/nodejs/node/pull/57727

* chore: fixup patch indices

* src: set default config as node.config.json

https://github.com/nodejs/node/pull/57171

* src: update std::vector<v8::Local<T>> to use v8::LocalVector<T>

https://github.com/nodejs/node/pull/57578

* test: disable chmod tests failing in Docker

https://github.com/nodejs/node/issues/58326

---------

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2025-06-02 17:30:15 -04:00
David Sanders
55006fe9a8 ci: change patches stats DataDog metric type to gauge (#47319) 2025-06-02 14:49:44 -04:00
zeeker999
dc5efca0f6 feat: [net] add "priority" option to net.request (#42628)
document the default value of priority option

Update the priority test to not use the httpbin.org as server

Fixed the lint errors

Fixed the build error
2025-05-30 15:28:13 -04:00
David Sanders
cf6c662702 ci: upload stats about patches to DataDog (#47206) 2025-05-30 11:14:57 -04:00
Shelley Vohr
c84e8c6c22 feat: expose win.isContentProtected() (#47242)
* feat: expose win.isContentProtected()

* chore: remove stray _isContentProtected
2025-05-30 11:00:13 +02:00
John Kleinschmidt
46921d3652 docs: document commit signing requirement (#47290) 2025-05-30 10:59:29 +02:00
David Sanders
b303413a04 build: drop shx dependency (#47293) 2025-05-30 10:59:11 +02:00
David Sanders
83524adf17 chore: fix lint for ImageView doc (#47304) 2025-05-29 17:10:41 -04:00
David Sanders
14b3183eb5 ci: add a problem matcher for ESLint output (#47303) 2025-05-29 16:58:17 -04:00
David Sanders
0d70389ccb chore: lint code blocks in docs with ESLint (#42113) 2025-05-29 12:45:26 -07:00
Niklas Wenzel
4e61f5b26f fix: Squirrel.Mac crash when zip extraction fails (#47271)
* fix: Squirrel.Mac crash when zip extraction process fails to launch

* chore: add end-to-end test
2025-05-29 10:31:46 -07:00
Will Anderson
5b5f900e34 docs: add documentation for ImageView (#46760)
* docs: Add documentation for ImageView

* docs: Add ImageView main process module list in README.md

* test: Add some basic tests for ImageView

* test: Fill out Window embedding tests to better reflect how someone might use an ImageView

* docs: Add notes about using ImageView as a splash screen

Co-authored-by: Niklas Wenzel <dev@nikwen.de>

* docs: Update ImageView example to show a more complete splash screen example

* docs: Remove view resizing logic since the ImageView automatically gets resized

---------

Co-authored-by: Niklas Wenzel <dev@nikwen.de>
2025-05-29 10:24:16 -07:00
David Sanders
2e0b4eca94 build: remove unnecessary eslint-plugin-standard package (#47283) 2025-05-28 13:58:14 +02:00
David Sanders
3a32f25750 ci: audit important branches for CI errors (#47207)
* ci: audit important branches for CI errors

* chore: move message to Slack workflow
2025-05-27 11:35:33 -04:00
Erick Zhao
f6b8ee0731 chore: add .eslintrc.json for docs/fiddles (#47269) 2025-05-27 09:13:10 -05:00
Robo
5ccbfa2faf fix: regression with directory selection in macOS dialogs (#47259) 2025-05-27 19:08:11 +09:00
Shelley Vohr
f89c2a0ef4 fix: titlebar showing in content protected window (#47241)
Closes https://github.com/electron/electron/issues/47152.
2025-05-26 09:46:04 +02:00
Shelley Vohr
c6f368acc6 chore: debug crash on DevTools SetOwnerWindow (#47243) 2025-05-26 09:45:43 +02:00
David Sanders
5e3b5ef04c chore: update @electron/lint-roller to 3.1.1 (#47202)
* chore: update @electron/lint-roller to 3.1.1

* docs: fix broken link in breaking-changes.md

* chore: fix for Node.js versions without require(esm)
2025-05-25 07:58:55 -05:00
John Kleinschmidt
ac5e3c76f3 build: migrate to new chromium git auth (#47230) 2025-05-25 07:57:20 -05:00
Gellert Hegyi
b9b96a96f7 feat: add menu item role palette and header (#45538)
* feat: add menu item role `palette` and `header`

* adds comments

* refactors new role items to new item types

* docs: custom type

* docs: note types only available on mac 14+

---------

Co-authored-by: Samuel Maddock <smaddock@slack-corp.com>
2025-05-23 12:43:49 -04:00
Charles Kerr
2248de847d refactor: use base::fixed_flat_set in NativeWindowViews::SetAlwaysOnTop() (#47201)
refactor: use base::fixed_flat_set in NativeWindowViews::SetAlwaysOnTop()
2025-05-22 18:20:39 -05:00
Charles Kerr
38e7ff944e refactor: make NativeWindow::has_frame_ const (#47200)
* refactor: make NativeWindow::is_modal_ const

* refactor: make NativeWindow::title_bar_style_ const and private

* refactor: make NativeWindow::has_client_frame() protected

refactor: make NativeWindow::transparent() protected

* refactor: make NativeWindow::enable_larger_than_screen() protected

* refactor: make NativeWindow::has_frame_ const

* fixup! refactor: make NativeWindow::has_client_frame() protected

fix: GetExpandedWindowSize()
2025-05-22 17:32:46 -05:00
David Sanders
8f09d7037b ci: add problem matcher for patch conflict output (#47183) 2025-05-22 09:27:23 -04:00
David Sanders
d0102ff392 ci: add problem matcher for clang output (#46577) 2025-05-22 09:25:57 -04:00
Keeley Hammond
274e1df1ca build: revert bump @octokit/rest from 20.1.1 to 21.1.1 (#47208)
Revert "build(deps-dev): bump @octokit/rest from 20.1.1 to 21.1.1 (#47159)"

This reverts commit 517f5c15b9.
2025-05-21 18:39:24 -07:00
John Kleinschmidt
b2d0074cc6 build: fix depot tool pathing on Windows (#47194)
build: properly set depot_tools pathing for Windows
2025-05-21 16:05:50 -07:00
Charles Kerr
2e8fc17f07 refactor: pass views::Widget* into constructors of our TreeHosts and NativeWidgets (#47177)
* refactor: remove unnecessary downcast in MenuViews::PopupAt()

* refactor: pass a views::Widget as an arg to the ElectronDesktopWindowTreeHostLinux ctor

* refactor: pass a views::Widget as an arg to the ElectronDesktopNativeWidgetAura ctor

* refactor: pass a views::Widget as an arg to the ElectronDesktopWindowTreeHostWin ctor

* refactor: create desktop_window_tree_host_ in the ElectronDesktopNativeWidgetAura constructor

* fixup! refactor: create desktop_window_tree_host_ in the ElectronDesktopNativeWidgetAura constructor

fix: tyop
2025-05-21 16:02:55 -05:00
Charles Kerr
4af0c5d762 refactor: make NativeWindow::transparent_ const (#47172)
* refactor: use in-class member initialization for NativeWindow::widget_

* refactor: make NativeWindow::transparent_ const

refactor: make NativeWindow::enable_larger_than_screen_ const

* chore: make linter happy after rebase
2025-05-21 19:42:08 +02:00
Charles Kerr
a7a3e10300 refactor: prefer base::circular_deque over std::deque (#47171)
* refactor: use base::circular_deque in ResolveProxyHelper

* refactor: use base::circular_deque in GetExtraCrashKeys()

refactor: reduce visibility of kMaxCrashKeyValueSize

This change is to match Chromium's usage advice from
base/containers/README.md: `base:circular_deque` is preferred over
`std::deque` to provide consistent performance across platforms.
2025-05-21 12:04:36 -05:00
Shelley Vohr
7b77a24211 fix: remove extra 'suspend'/'resume' handling from powerMonitor (#47162)
fix: remove extra 'suspend'/'resume' handling from powerMonitor
2025-05-21 10:00:38 -05:00
David Sanders
7112c592c9 test: strip color output in ESM spec (#47185) 2025-05-21 10:50:06 +02:00
Charles Kerr
d6638f9564 refactor: make NativeWindow::pending_transitions_ a base::queue (#47157)
refactor: make NativeWindow::pending_transitions a base::queue

Follow the base/containers/README.md advice that "Chromium code should
always use `base::circular_deque` or `base::queue` in preference to
`std::deque` or `std::queue` due to memory usage and platform variation."
2025-05-20 17:35:51 -05:00
Charles Kerr
9f8bcc4d98 refactor: make NativeWindow::has_client_frame_ const (#47156) 2025-05-20 17:14:28 -05:00
Charles Kerr
21155679a0 refactor: add NativeWindowViews::GetClientFrameViewLinux() (#47130)
* refactor: add NativeWindowViews::GetClientFrameViewLinux()

* chore: clarify code comment
2025-05-20 14:15:06 -05:00
Charles Kerr
211faed848 refactor: add NativeWindow::IsActive() (#47148)
this was already present on macOS; use in NativeWindowViews too
2025-05-20 11:08:44 -04:00
Shelley Vohr
296e39456a refactor: match upstream macOS a11y handling (#47144) 2025-05-20 11:06:57 -04:00
John Kleinschmidt
a19198d784 build: update_depot_tools on initial install (#47160)
this ensures that python is setup for proper use from depot_tools
2025-05-20 10:40:48 -04:00
reito
263c76df09 fix: prevent gc monitor 2nd pass crash (#46987) 2025-05-20 22:54:03 +09:00
dependabot[bot]
517f5c15b9 build(deps-dev): bump @octokit/rest from 20.1.1 to 21.1.1 (#47159)
Bumps [@octokit/rest](https://github.com/octokit/rest.js) from 20.1.1 to 21.1.1.
- [Release notes](https://github.com/octokit/rest.js/releases)
- [Commits](https://github.com/octokit/rest.js/compare/v20.1.1...v21.1.1)

---
updated-dependencies:
- dependency-name: "@octokit/rest"
  dependency-version: 21.1.1
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-05-20 09:57:30 +02:00
dependabot[bot]
d29293556d build(deps): bump github/codeql-action from 3.28.15 to 3.28.18 (#47158)
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.28.15 to 3.28.18.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](45775bd823...ff0a06e83c)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: 3.28.18
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-05-20 09:56:54 +02:00
Shelley Vohr
e0ea069859 build: remove fix_linter_error.patch (#47150)
build: remove fix_linter_error.patch
2025-05-19 22:52:01 +02:00
electron-roller[bot]
7cc76c094a chore: bump node to v22.15.1 (main) (#47105)
* chore: bump node in DEPS to v22.15.1

* chore: fixup patch indices

* src: fix error handling on async crypto operations

https://github.com/nodejs-private/node-private/pull/709

---------

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2025-05-19 16:12:48 -04:00
Charles Kerr
3660432f42 refactor: NativeWindows should prefer widget() over GetWidget() for internal use (#47133) 2025-05-19 21:43:16 +02:00
Charles Kerr
687e50b4f3 refactor: add NativeWindowViews::SetTitleBarOverlay() (#47126)
* refactor: move SetTitleBarOverlay() impl to NativeWindowViews

* refactor: make NativeWindowViews::set_overlay_button_color() private

refactor: make NativeWindowViews::set_overlay_symbol_color() private

refactor: make NativeWindow::set_titlebar_overlay_height() protected

* refactor: simplify downcasting in NativeWindowViews::SetTitleBarOverlay()
2025-05-19 08:19:03 -05:00
David Sanders
d426667a01 build(dev-deps): update @electron/lint-roller and markdownlint-cli2 (#47082) 2025-05-19 14:19:04 +02:00
Charles Kerr
208bbc0504 refactor: add NativeWindow::SetShape() (#47131)
use NativeWindow::SetShape() in api::BaseWindow
2025-05-19 10:29:29 +02:00
dependabot[bot]
e2f496cfbc build(deps-dev): bump @typescript-eslint/eslint-plugin from 8.7.0 to 8.32.1 (#47135)
build(deps-dev): bump @typescript-eslint/eslint-plugin

Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 8.7.0 to 8.32.1.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v8.32.1/packages/eslint-plugin)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/eslint-plugin"
  dependency-version: 8.32.1
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-05-19 10:27:22 +02:00
Charles Kerr
1da150f9a3 chore: remove gclient sync macOS CI hack patch (#47123)
chore: remove hack_to_allow_gclient_sync_with_host_os_mac_on_linux_in_ci.patch
2025-05-19 10:26:58 +02:00
Calvin
5dd6481e53 fix: explicit microtask scope DCHECK condition (#47134) 2025-05-19 12:08:59 +09:00
dependabot[bot]
d72e622a3f build(deps): bump slackapi/slack-github-action from 2.0.0 to 2.1.0 (#47060)
Bumps [slackapi/slack-github-action](https://github.com/slackapi/slack-github-action) from 2.0.0 to 2.1.0.
- [Release notes](https://github.com/slackapi/slack-github-action/releases)
- [Commits](485a9d42d3...b0fa283ad8)

---
updated-dependencies:
- dependency-name: slackapi/slack-github-action
  dependency-version: 2.1.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-05-16 12:55:00 -05:00
Charles Kerr
8efd24c339 perf: don't create unused menuitem icons (#47100)
GTK >= 3.90.0 removed support for menuitem icons. When Electron is
built with GTK >= 3.90.0, our code builds these icons and then throws
them away unused. Instead, let's just not build them.

Our gtk_util::GdkPixbufFromSkBitmap utility uses BGRAToRGBA and is
expensive to call.
2025-05-16 02:43:03 -05:00
Erick Zhao
dc34e8732c docs: add note on DIP and DPI (#47080) 2025-05-15 16:51:49 -05:00
Charles Kerr
77c58658c5 refactor: decouple NativeWindowViews and GlobalMenuBarX11 (#47094)
The GlobalMenuBar used to hold a raw_ptr reference to its NativeWindow;
but since it doesn't use it & only wants the gfx::AcceleratedWidget info,
let's remove the NativeWindowViews reference.

AFAICT, GlobalMenuBarX11::window_ has never been used
2025-05-15 16:10:56 -05:00
Charles Kerr
d720aea700 refactor: make TrackableObject::weak_map_id() constexpr (#47092)
* refactor: make TrackableObject::weak_map_id() constexpr

refactor: make BaseWindow::GetID() inline and constexpr

* refactor: make NativeWindow::window_id() constexpr too
2025-05-15 16:10:33 -05:00
Charles Kerr
e2bcd8f0aa test: fix desktopCapturer mocha syntax (#47088)
* test: fix desktopCapturer mocha syntax

do not nest `it` calls in desktopCapturer specs

* empty commit
2025-05-15 16:54:49 -04:00
Robo
99a3e360ec fix: opening package paths as directory on macOS (#47077) 2025-05-15 12:47:46 -05:00
electron-roller[bot]
883f48b9b4 chore: bump chromium to 138.0.7178.0 (main) (#47086)
* chore: bump chromium in DEPS to 138.0.7178.0

* 6351556: [source-phase-imports] Support Wasm Source Phase Imports

Refs https://chromium-review.googlesource.com/c/chromium/src/+/6351556

* chore: update patches

* 6509682: extensions: Use ChromeExtensionsBrowserClient on desktop Android, part 2

Refs https://chromium-review.googlesource.com/c/chromium/src/+/6509682

---------

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: David Sanders <dsanders11@ucsbalum.com>
2025-05-15 12:47:07 -05:00
Charles Kerr
9a7b73b533 refactor: use kKeyModifiers in IsAltModifier() (#47066)
We probably didn't use this before because IsAltModifier() was written
two years before the KeyModifiers mask was added upstream in 98ec378a.
2025-05-14 11:00:00 -04:00
Charles Kerr
6170a5af40 chore: combine all the "patch out Profiles" changes into a single patch (#47063)
* chore: fold the profile patches into one patch

* chore: e patches all

* chore: patch out ProfileSelections::ApplyProfileSelection()

Another profile reference. Referenced iff making a debug build.
2025-05-14 09:21:11 -05:00
electron-roller[bot]
d65a856bf3 chore: bump chromium to 138.0.7177.0 (main) (#47081)
* chore: bump chromium in DEPS to 138.0.7177.0

* 6530423: [WebContents] Fix IsNeverComposited() calls during initialization

Refs https://chromium-review.googlesource.com/c/chromium/src/+/6530423

* 6512551: [ios] Enable -Wobjc-property-assign-on-object-type

Refs https://chromium-review.googlesource.com/c/chromium/src/+/6512551

* chore: update patches

---------

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: David Sanders <dsanders11@ucsbalum.com>
2025-05-14 10:08:31 -04:00
Shelley Vohr
f2639d13cc refactor: remove CreateViewForWidget patch (#46981)
* refactor: remove CreateViewForWidget patch

* chore: rm unintended osr change

* Trigger CI

---------

Co-authored-by: deepak1556 <hop2deep@gmail.com>
Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
2025-05-14 21:43:23 +09:00
Charles Kerr
11fa915724 refactor: remove introduce_ozoneplatform_electron_can_call_x11_property.patch (#47075)
* refactor: use x11_util::IsX11() in BuildSubmenuFromModel()

* refactor: use x11_util::IsX11() in ElectronDesktopWindowTreeHostLinux::OnBoundsChanged()

* refactor: use skia_can_fall_back_to_x11 in x11_util::IsX11()

it is identical in practice to electron_can_call_x11 and does not require a Chromium patch

* chore: remove introduce_ozoneplatform_electron_can_call_x11_property.patch

* refactor: use ui::GetOzonePlatformId() to test for x11
2025-05-14 13:38:35 +09:00
David Sanders
9aacc473e6 build: remove patch that landed upstream (#47079) 2025-05-13 20:10:48 -05:00
Charles Kerr
c218128675 chore: remove disable_unload_metrics.patch (#47059) 2025-05-13 14:55:59 -04:00
electron-roller[bot]
e3e647d21e chore: bump chromium to 138.0.7175.0 (main) (#46986)
* chore: bump chromium in DEPS to 138.0.7166.0

* chore: bump chromium in DEPS to 138.0.7166.2

* 6508373: Add WebContents, Tab getters for future Clank navigation capture rework

https://chromium-review.googlesource.com/c/chromium/src/+/6508373

* 6470924: Introduce auto-populated Search Engine icons.

https://chromium-review.googlesource.com/c/chromium/src/+/6470924

* 6502977: Force same tab navigation while actor coordinator is acting on a tab

https://chromium-review.googlesource.com/c/chromium/src/+/6502977

* chore: bump chromium in DEPS to 138.0.7168.0

* chore: update patches

* fix grit patch

* chore: bump Chromium to 138.0.7169.2

* fixup! 6508373: Add WebContents, Tab getters for future Clank navigation capture rework

* 6493688: NavigationThrottleRunner2: void CreateThrottlesForNavigation

https://chromium-review.googlesource.com/c/chromium/src/+/6493688

* 6488755: Reland "WebSQL: Remove WebPreference"

https://chromium-review.googlesource.com/c/chromium/src/+/6488755

* 6428707: FSA: Only normalize the hardcoded rules once during initialization

https://chromium-review.googlesource.com/c/chromium/src/+/6428707

* chore: fixup patch indices

* chore: bump chromium in DEPS to 138.0.7170.0

* 6514121: Remove origin calculation debug info and related methods

 https://chromium-review.googlesource.com/c/chromium/src/+/6514121

* chore: bump chromium in DEPS to 138.0.7172.0

* chore: bump chromium in DEPS to 138.0.7173.0

* chore: bump chromium in DEPS to 138.0.7175.0

* fixup! 6514121: Remove origin calculation debug info and related methods

Refs https://chromium-review.googlesource.com/c/chromium/src/+/6514121

* 6531585: Don't retry LayerTreeSink creation on the high priority queue

Refs https://chromium-review.googlesource.com/c/chromium/src/+/6531585

* 6512253: Modernize base::apple's base bundle ID

Refs https://chromium-review.googlesource.com/c/chromium/src/+/6512253

* fixup! 6428707: FSA: Only normalize the hardcoded rules once during initialization

Refs https://chromium-review.googlesource.com/c/chromium/src/+/6428707

* fixup! 6508373: Add WebContents, Tab getters for future Clank navigation capture rework

Refs https://chromium-review.googlesource.com/c/chromium/src/+/6508373

* chore: update patches

---------

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
Co-authored-by: David Sanders <dsanders11@ucsbalum.com>
2025-05-13 14:51:20 -04:00
Shelley Vohr
7ab032f594 fix: white window flicker on window creation (#47022) 2025-05-10 18:24:35 -05:00
Erick Zhao
2493e530d0 docs: unify [!NOTE] structure (#46893)
* docs: unify [!NOTE] structure

* Update docs/api/command-line.md

Co-authored-by: Niklas Wenzel <dev@nikwen.de>

* Update docs/api/browser-window.md

Co-authored-by: Niklas Wenzel <dev@nikwen.de>

* Update docs/api/download-item.md

Co-authored-by: Niklas Wenzel <dev@nikwen.de>

* Update docs/api/global-shortcut.md

Co-authored-by: Niklas Wenzel <dev@nikwen.de>

* revert line break

---------

Co-authored-by: Niklas Wenzel <dev@nikwen.de>
2025-05-09 14:36:42 -07:00
Michaela Laurencin
10e4f9ad37 feat: enable secondary label for macOS menu (#46887)
* feat: enable secondary label for macOS menu

* Update shell/browser/ui/cocoa/electron_menu_controller.mm

Co-authored-by: Robo <hop2deep@gmail.com>

* fix for lint

* update docs for sublabel

---------

Co-authored-by: Robo <hop2deep@gmail.com>
2025-05-09 12:05:26 -04:00
Michaela Laurencin
b9f0aebb2f feat: enable innerWidth and innerHeight for window open (#46749)
* feat: enable innerWidth and innerHeight for window open

* update comment for added special innerWidth and innerHeight

* update 100 min spec requirement handling

* update testing to include getContentSize

* update macOS min requirement handling

* adjust refactored consts

* update const values from nativewindowviews
2025-05-09 12:03:45 -04:00
Shelley Vohr
8ecd731e96 fix: webview crash on focus (#46979) 2025-05-09 17:56:22 +02:00
Shelley Vohr
75cf8ea96d fix: restore previous Windows screenshotting (#47020)
Fixes https://github.com/electron/electron/issues/45990

We previously made a change in https://github.com/electron/electron/pull/45868
to fix content protection being lost on hide and re-show. However, this
cause a breaking change where protected windows were made opaque black
instead of being hidden as before. This overrides relevant methods in
ElectronDesktopWindowTreeHostWin to restore the previous behavior.
without regressing the original issue.
2025-05-09 09:38:27 -05:00
Aman Karmani
376634c75a feat: add support for --experimental-network-inspection (#46690)
* feat: add support for `--experimental-network-inspection`

* docs: fix minor formatting issues

visible on both GH[1] and the docs site[2]

[1] https://github.com/electron/electron/blob/main/docs/api/command-line-switches.md#nodejs-flags
[2] https://www.electronjs.org/docs/latest/api/command-line-switches#--inspect-brkhostport

* docs: add entry for new nodejs flag
2025-05-09 09:44:14 -04:00
Robo
8e8d3a4f3e fix: use-after-move of bus connection in xdg portal detection (#47008) 2025-05-09 18:32:08 +09:00
Charles Kerr
2cbd968da5 refactor: use gin_helper::Dictionary::ValueOrDefault() (#46982)
* refactor: use ValueOrDefault() in electron_api_web_contents.cc

* refactor: use ValueOrDefault() in electron_api_url_loader.cc

* refactor: use ValueOrDefault() in electron_download_manager_delegate.cc

* refactor: use ValueOrDefault() in electron_touch_bar.mm

* refactor: use ValueOrDefault() in electron_url_loader_factory.cc

* refactor: use ValueOrDefault() in electron_browser_context.cc

* refactor: use ValueOrDefault() in electron_touch_bar.mm

* refactor: use ValueOrDefault() in blink_converter.cc

* feat: add ValueOrDefault() to PersistentDictionary

* empty commit

* refactor: use ValueOrDefault() in blink_converter.cc

* refactor: inline the rectangle base::Value::Dict

* refactor: remove has_scroll temporary

---------

Co-authored-by: Deepak Mohan <hop2deep@gmail.com>
2025-05-08 14:17:22 -05:00
Keeley Hammond
aea7b4ae8c build: update hasher return value (#47009) 2025-05-08 11:34:21 -07:00
Charles Kerr
9f8a629126 refactor: reduce use of NativeWidgetPrivate (#46942)
* refactor: do not use native_widget_private() in NativeWindowViews::SetContentProtection()

refactor: do not use native_widget_private() in NativeWindowViews::IsContentProtected()

* refactor: do not use native_widget_private() in NativeWindowViews::Show()

* chore: remove native_widget_private #include from native_window_views_win

Not needed since Feb 2025: 9199d5c6
2025-05-08 09:02:19 -05:00
Charles Kerr
d4ca829069 test: enable hasShadow tests on Linux (#46984)
refactor: enable hasShadow tests on Linux
2025-05-08 10:07:10 +02:00
Charles Kerr
54a6bbb4cb build: remove skip_atk_toolchain_check.patch (#46988)
chore: remove skip_atk_toolchain_check.patch
2025-05-08 10:06:55 +02:00
Charles Kerr
24f1f7ed57 build: remove deps_add_v8_object_setinternalfieldfornodecore.patch (#46992)
chore: remove deps_add_v8_object_setinternalfieldfornodecore.patch

This was a Node 20-specific workaround that's no longer needed in Node 22.

Xref: https://github.com/nodejs/node/pull/49874.
2025-05-08 09:39:58 +02:00
Keeley Hammond
153dae5b48 build: move release script to new hasher function (#46989)
build: move to new hasher function
2025-05-08 01:15:08 -05:00
Calvin
580fa57a29 refactor: Node.js temporary "explicit" microtask policy scope pattern (#46973)
refactor: Node.js explicit microtask scope pattern
2025-05-08 10:21:39 +09:00
Calvin
37639b5400 refactor: replace gin_helper::MicrotasksScope with v8::MicrotasksScope (#46963)
* Remove microtasks_scope.h and microtasks_scope.cc

* Use v8::MicrotasksScope when ignoring browser checkpoint

These call always skip the browser checkpoint, so they are equivalent to using v8::MicrotasksScope directly (modulo the optional wrapper behavior).

* Remove MicrotasksScope from node_bindings.cc

This code seems contradictory: it explicitly specifies "do not run microtasks" yet runs a microtask checkpoint in the browser process.

Looking at its history, it [was introduced][1] with the intention to not run microtasks, but a [subtle C++ language behavior][2] caused it to do the opposite later in the same roll. Since the original intention was to not run microtasks, and since that is also the simplest explanation, we can assume `ignore_browser_checkpoint` should be true and migrate this to `v8::MicrotasksScope` as it is equivalent (modulo the optional wrapper behavior).

[1]: a4ea80dd47 (diff-efe58cf03c97028f37f801db044d396a5f428686da6595d2c692f1c052bbd09c)
[2]: https://github.com/electron/electron/pull/43185

* Migrate gin_helper/promise.h and gin_helper/promise.cc to v8::MicrotasksScope

Restores the [original][1] behavior of running the microtask checkpoint at destruction, but preserves the behavior of running microtasks in the browser process. This had last changed in the migration to gin_helper::MicroTasks.

[1]: https://github.com/electron/electron/pull/16401
2025-05-07 14:10:34 -05:00
electron-roller[bot]
a8695d4387 chore: bump chromium to 138.0.7166.0 (main) (#46975)
* chore: bump chromium in DEPS to 138.0.7165.0

* 6492127: Add new less invasive context menu mode for mobile interesttarget

https://chromium-review.googlesource.com/c/chromium/src/+/6492127

* chore: fixup patch indices

---------

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2025-05-07 13:04:15 -04:00
Charles Kerr
924a8da940 refactor: use WidgetDelegate::SetAccessibleTitle() (#46765)
* refactor: use WidgetDelegate::SetAccessibleTitle()

* test: add window.accessibleTitle tests
2025-05-07 10:44:53 -05:00
Shelley Vohr
c16ea8d54e fix: printing when no mediaSize specified (#46937)
fix: printing when no mediaSize specified
2025-05-06 19:12:25 -05:00
Charles Kerr
b7ae162716 refactor: add gin_helper::Dictionary::ValueOrDefault() (#46939)
* feat: add gin_helper::Dictionary::ValueOrDefault()

A convenience function for using a default value if the
specified key isn't present in the dictionary.

* refactor: use ValueOrDefault() in native_window.cc

* refactor: use ValueOrDefault() in native_window_mac.mm

* refactor: use ValueOrDefault() in native_window_views.cc

* refactor: use ValueOrDefault() in electron_api_native_image.cc
2025-05-06 15:20:12 -05:00
Shelley Vohr
e876cecbc7 test: test menu rendering accelerators (#44634)
* test: test menu rendering accelerators

* Update spec/api-menu-spec.ts

Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>

---------

Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
2025-05-06 14:09:35 -04:00
electron-roller[bot]
c4ac192aa4 chore: bump chromium to 138.0.7164.0 (main) (#46948)
* chore: bump chromium in DEPS to 138.0.7164.0

* 6508870: Add missing PermissionType mapping and remove default case.

https://chromium-review.googlesource.com/c/chromium/src/+/6508870

* chore: fixup patch indices

---------

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2025-05-06 14:01:37 -04:00
Charles Kerr
8308ac29c8 refactor: pass gfx::ResizeEdge by value (#46935)
refactor: pass gfx::ResizeEdge by value

It is an enum class, so no reason to pass by reference
2025-05-06 11:57:53 -05:00
Shelley Vohr
206544cbc0 fix: crash on macOS dialog after window-all-closed (#46927)
fix: crash on dialog after window-all-closed
2025-05-06 07:47:50 -05:00
516 changed files with 12783 additions and 6365 deletions

View File

@@ -58,6 +58,15 @@ body:
label: Last Known Working Electron version
description: What is the last version of Electron this worked in, if applicable?
placeholder: 16.0.0
- type: dropdown
attributes:
label: Does the issue also appear in Chromium / Google Chrome?
description: If it does, please report the issue in the [Chromium issue tracker](https://issues.chromium.org/issues), not against Electron. Electron will inherit the fix once Chromium resolves the issue.
options:
- "Yes"
- "No"
validations:
required: true
- type: textarea
attributes:
label: Expected Behavior

View File

@@ -38,6 +38,9 @@ runs:
run: |
GN_APPENDED_ARGS="$GN_EXTRA_ARGS target_cpu=\"x64\" v8_snapshot_toolchain=\"//build/toolchain/mac:clang_x64\""
echo "GN_EXTRA_ARGS=$GN_APPENDED_ARGS" >> $GITHUB_ENV
- name: Add Clang problem matcher
shell: bash
run: echo "::add-matcher::src/electron/.github/problem-matchers/clang.json"
- name: Build Electron ${{ inputs.step-suffix }}
shell: bash
run: |
@@ -199,6 +202,9 @@ runs:
e build --target electron:libcxx_headers_zip -j $NUMBER_OF_NINJA_PROCESSES
e build --target electron:libcxxabi_headers_zip -j $NUMBER_OF_NINJA_PROCESSES
e build --target electron:libcxx_objects_zip -j $NUMBER_OF_NINJA_PROCESSES
- name: Remove Clang problem matcher
shell: bash
run: echo "::remove-matcher owner=clang::"
- name: Generate TypeScript Definitions ${{ inputs.step-suffix }}
if: ${{ inputs.is-release == 'true' }}
shell: bash

View File

@@ -0,0 +1,83 @@
name: 'Build Git Cache'
description: 'Runs a gclient sync to build the git cache for Electron'
inputs:
target-platform:
description: 'Target platform, should be linux, win, macos'
runs:
using: "composite"
steps:
- name: Set GIT_CACHE_PATH to make gclient to use the cache
shell: bash
run: |
echo "GIT_CACHE_PATH=$(pwd)/git-cache" >> $GITHUB_ENV
- name: Set Chromium Git Cookie
uses: ./src/electron/.github/actions/set-chromium-cookie
- name: Install Build Tools
uses: ./src/electron/.github/actions/install-build-tools
- name: Set up cache drive
shell: bash
run: |
if [ "${{ inputs.target-platform }}" = "win" ]; then
echo "CACHE_DRIVE=/mnt/win-cache" >> $GITHUB_ENV
else
echo "CACHE_DRIVE=/mnt/cross-instance-cache" >> $GITHUB_ENV
fi
- name: Check cross instance cache disk space
shell: bash
run: |
# if there is less than 35 GB free space then creating the cache might fail so exit early
freespace=`df -m $CACHE_DRIVE | grep -w $CACHE_DRIVE | awk '{print $4}'`
freespace_human=`df -h $CACHE_DRIVE | grep -w $CACHE_DRIVE | awk '{print $4}'`
if [ $freespace -le 35000 ]; then
echo "The cross mount cache has $freespace_human free space which is not enough - exiting"
exit 1
else
echo "The cross mount cache has $freespace_human free space - continuing"
fi
- name: Restore gitcache
shell: bash
run: |
GIT_CACHE_TAR="$CACHE_DRIVE/gitcache.tar"
if [ ! -f "$GIT_CACHE_TAR" ]; then
echo "Git cache tar file does not exist, skipping restore"
exit 0
fi
echo "Restoring git cache from $GIT_CACHE_TAR to $GIT_CACHE_PATH"
mkdir -p $GIT_CACHE_PATH
tar -xf $GIT_CACHE_TAR -C $GIT_CACHE_PATH
- name: Gclient Sync
shell: bash
run: |
e d gclient config \
--name "src/electron" \
--unmanaged \
${GCLIENT_EXTRA_ARGS} \
"$GITHUB_SERVER_URL/$GITHUB_REPOSITORY"
if [ "$TARGET_OS" != "" ]; then
echo "target_os=['$TARGET_OS']" >> ./.gclient
fi
ELECTRON_USE_THREE_WAY_MERGE_FOR_PATCHES=1 e d gclient sync --with_branch_heads --with_tags --nohooks -vv
- name: Compress Git Cache Directory
shell: bash
run: |
echo "Uncompressed gitcache size: $(du -sh $GIT_CACHE_PATH | cut -f1 -d' ')"
cd $GIT_CACHE_PATH
tar -cf ../gitcache.tar .
cd ..
echo "Compressed gitcache to $(du -sh gitcache.tar | cut -f1 -d' ')"
# remove the old cache file if it exists
if [ -f $CACHE_DRIVE/gitcache.tar ]; then
echo "Removing old gitcache.tar from $CACHE_DRIVE"
rm $CACHE_DRIVE/gitcache.tar
fi
cp ./gitcache.tar $CACHE_DRIVE/
- name: Wait for active SSH sessions
shell: bash
if: always() && !cancelled()
run: |
while [ -f /var/.ssh-lock ]
do
sleep 60
done

View File

@@ -43,7 +43,7 @@ runs:
curl --unix-socket /var/run/sas/sas.sock --fail "http://foo/$CACHE_FILE?platform=${{ inputs.target-platform }}" > sas-token
- name: Save SAS Key
if: ${{ inputs.generate-sas-token == 'true' }}
uses: actions/cache/save@d4323d4df104b026a6aa633fdb11d772146be0bf
uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
with:
path: sas-token
key: sas-key-${{ inputs.target-platform }}-${{ github.run_number }}-${{ github.run_attempt }}
@@ -80,6 +80,21 @@ runs:
else
echo "The cross mount cache has $freespace_human free space - continuing"
fi
- name: Add patch conflict problem matcher
shell: bash
run: echo "::add-matcher::src/electron/.github/problem-matchers/patch-conflict.json"
- name: Restore gitcache
if: steps.check-cache.outputs.cache_exists == 'false'
shell: bash
run: |
GIT_CACHE_TAR="$CACHE_DRIVE/gitcache.tar"
if [ ! -f "$GIT_CACHE_TAR" ]; then
echo "Git cache tar file does not exist, skipping restore"
exit 0
fi
echo "Restoring git cache from $GIT_CACHE_TAR to $GIT_CACHE_PATH"
mkdir -p $GIT_CACHE_PATH
tar -xf $GIT_CACHE_TAR -C $GIT_CACHE_PATH
- name: Gclient Sync
if: steps.check-cache.outputs.cache_exists == 'false'
shell: bash
@@ -102,12 +117,7 @@ runs:
git update-index --refresh || true
if ! git diff-index --quiet HEAD --; then
# There are changes to the patches. Make a git commit with the updated patches
git add patches
GIT_COMMITTER_NAME="PatchUp" GIT_COMMITTER_EMAIL="73610968+patchup[bot]@users.noreply.github.com" git commit -m "chore: update patches" --author="PatchUp <73610968+patchup[bot]@users.noreply.github.com>"
# Export it
mkdir -p ../../patches
git format-patch -1 --stdout --keep-subject --no-stat --full-index > ../../patches/update-patches.patch
if node ./script/push-patch.js; then
if node ./script/patch-up.js; then
echo
echo "======================================================================"
echo "Changes to the patches when applying, we have auto-pushed the diff to the current branch"
@@ -115,6 +125,11 @@ runs:
echo "======================================================================"
exit 1
else
git add patches
GIT_COMMITTER_NAME="PatchUp" GIT_COMMITTER_EMAIL="73610968+patchup[bot]@users.noreply.github.com" git commit -m "chore: update patches" --author="PatchUp <73610968+patchup[bot]@users.noreply.github.com>"
# Export it
mkdir -p ../../patches
git format-patch -1 --stdout --keep-subject --no-stat --full-index > ../../patches/update-patches.patch
echo
echo "======================================================================"
echo "There were changes to the patches when applying."
@@ -128,7 +143,16 @@ runs:
echo "No changes to patches detected"
fi
fi
- name: Remove patch conflict problem matcher
shell: bash
run: |
echo "::remove-matcher owner=merge-conflict::"
echo "::remove-matcher owner=patch-conflict::"
- name: Upload patches stats
if: ${{ inputs.target-platform == 'linux' && github.ref == 'refs/heads/main' }}
shell: bash
run: |
npx node src/electron/script/patches-stats.mjs --upload-stats || true
# delete all .git directories under src/ except for
# third_party/angle/ and third_party/dawn/ because of build time generation of files
# gen/angle/commit.h depends on third_party/angle/.git/HEAD

View File

@@ -57,8 +57,19 @@ runs:
sudo rm -rf $TMPDIR/del-target
sudo rm -rf /Applications/Safari.app
sudo rm -rf /Applications/Xcode_16.1.app
sudo rm -rf /Applications/Xcode_16.3.app
sudo rm -rf /Applications/Xcode_16.2.app
sudo rm -rf /Applications/Google Chrome.app
sudo rm -rf /Applications/Xcode_16.4.app
sudo rm -rf /Applications/Google Chrome for Testing.app
sudo rm -rf /Applications/Firefox.app
sudo rm -rf ~/project/src/third_party/catapult/tracing/test_data
sudo rm -rf ~/project/src/third_party/angle/third_party/VK-GL-CTS
sudo rm -rf /Users/runner/Library/Android
sudo rm -rf $JAVA_HOME_11_arm64
sudo rm -rf $JAVA_HOME_17_arm64
sudo rm -rf $JAVA_HOME_21_arm64
# lipo off some huge binaries arm64 versions to save space
strip_universal_deep $(xcode-select -p)/../SharedFrameworks

View File

@@ -11,15 +11,21 @@ runs:
git config --global core.autocrlf false
git config --global branch.autosetuprebase always
git config --global core.fscache true
git config --global core.longpaths true
git config --global core.preloadindex true
fi
export BUILD_TOOLS_SHA=6e8526315ea3b4828882497e532b8340e64e053c
export BUILD_TOOLS_SHA=0a7f6bef9453ceee45612442660ca16d2c40171b
npm i -g @electron/build-tools
# Update depot_tools to ensure python
e d update_depot_tools
e auto-update disable
# Disable further updates of depot_tools
e d auto-update disable
if [ "$(expr substr $(uname -s) 1 10)" == "MSYS_NT-10" ]; then
e d cipd.bat --version
cp "C:\Python311\python.exe" "C:\Python311\python3.exe"
fi
echo "$HOME/.electron_build_tools/third_party/depot_tools" >> $GITHUB_PATH
echo "$HOME/.electron_build_tools/third_party/depot_tools/python-bin" >> $GITHUB_PATH
echo "C:\Users\ContainerAdministrator\.electron_build_tools\third_party\depot_tools" >> $GITHUB_PATH
else
echo "$HOME/.electron_build_tools/third_party/depot_tools" >> $GITHUB_PATH
echo "$HOME/.electron_build_tools/third_party/depot_tools/python-bin" >> $GITHUB_PATH
fi

View File

@@ -7,7 +7,7 @@ runs:
shell: bash
id: yarn-cache-dir-path
run: echo "dir=$(node src/electron/script/yarn cache dir)" >> $GITHUB_OUTPUT
- uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57
- uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}

View File

@@ -8,14 +8,14 @@ runs:
steps:
- name: Obtain SAS Key
continue-on-error: true
uses: actions/cache/restore@d4323d4df104b026a6aa633fdb11d772146be0bf
uses: actions/cache/restore@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
with:
path: sas-token
key: sas-key-${{ inputs.target-platform }}-${{ github.run_number }}-1
enableCrossOsArchive: true
- name: Obtain SAS Key
continue-on-error: true
uses: actions/cache/restore@d4323d4df104b026a6aa633fdb11d772146be0bf
uses: actions/cache/restore@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
with:
path: sas-token
key: sas-key-${{ inputs.target-platform }}-${{ github.run_number }}-${{ github.run_attempt }}
@@ -32,7 +32,7 @@ runs:
shell: bash
command: |
sas_token=$(cat sas-token)
if [ -z $sas-token ]; then
if [ -z "$sas_token" ]; then
echo "SAS Token not found; exiting src cache download early..."
exit 1
else
@@ -96,7 +96,7 @@ runs:
$TEMP_DIR=New-Item -ItemType Directory -Path temp-cache
$TEMP_DIR_PATH = $TEMP_DIR.FullName
C:\ProgramData\Chocolatey\bin\7z.exe -y x $src_cache -o"$TEMP_DIR_PATH"
C:\ProgramData\Chocolatey\bin\7z.exe -y -snld x $src_cache -o"$TEMP_DIR_PATH"
- name: Move Src Cache (Windows)
if: ${{ inputs.target-platform == 'win' }}

18
.github/problem-matchers/clang.json vendored Normal file
View File

@@ -0,0 +1,18 @@
{
"problemMatcher": [
{
"owner": "clang",
"fromPath": "src/out/Default/args.gn",
"pattern": [
{
"regexp": "^(.+)[(:](\\d+)[:,](\\d+)\\)?:\\s+(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
]
}
]
}

View File

@@ -0,0 +1,22 @@
{
"problemMatcher": [
{
"owner": "eslint-stylish",
"pattern": [
{
"regexp": "^\\s*([^\\s].*)$",
"file": 1
},
{
"regexp": "^\\s+(\\d+):(\\d+)\\s+(error|warning|info)\\s+(.*)\\s\\s+(.*)$",
"line": 1,
"column": 2,
"severity": 3,
"message": 4,
"code": 5,
"loop": true
}
]
}
]
}

View File

@@ -0,0 +1,24 @@
{
"problemMatcher": [
{
"owner": "merge-conflict",
"pattern": [
{
"regexp": "^CONFLICT\\s\\(\\S+\\): (Merge conflict in \\S+)$",
"message": 1
}
]
},
{
"owner": "patch-conflict",
"pattern": [
{
"regexp": "^error: (patch failed: (\\S+):(\\d+))$",
"message": 1,
"file": 2,
"line": 3
}
]
}
]
}

View File

@@ -15,7 +15,7 @@ jobs:
- name: Setup Node.js/npm
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020
with:
node-version: 20.11.x
node-version: 20.19.x
- name: Setting Up Dig Site
run: |
echo "remote: ${{ github.event.pull_request.head.repo.clone_url }}"

149
.github/workflows/audit-branch-ci.yml vendored Normal file
View File

@@ -0,0 +1,149 @@
name: Audit CI on Branches
on:
workflow_dispatch:
schedule:
# Run every 2 hours
- cron: '0 */2 * * *'
permissions: {}
jobs:
audit_branch_ci:
name: Audit CI on Branches
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Setup Node.js
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: 22.17.x
- run: npm install @actions/cache@4.0.3 @electron/fiddle-core@2.0.1
- uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
id: audit-errors
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const cache = require('@actions/cache');
const { ElectronVersions } = require('@electron/fiddle-core');
const runsWithErrors = [];
// Only want the most recent workflow run that wasn't skipped or cancelled
const isValidWorkflowRun = (run) => !['skipped', 'cancelled'].includes(run.conclusion);
const versions = await ElectronVersions.create({ ignoreCache: true });
const branches = versions.supportedMajors.map((branch) => `${branch}-x-y`);
for (const branch of ["main", ...branches]) {
const latestCheckRuns = new Map();
const allCheckRuns = await github.paginate(github.rest.checks.listForRef, {
owner: "electron",
repo: "electron",
ref: branch,
status: 'completed',
});
// Sort the check runs by completed_at so that multiple check runs on the
// same ref (like a scheduled workflow) only looks at the most recent one
for (const checkRun of allCheckRuns.filter(
(run) => !['skipped', 'cancelled'].includes(run.conclusion),
).sort((a, b) => new Date(b.completed_at) - new Date(a.completed_at))) {
if (!latestCheckRuns.has(checkRun.name)) {
latestCheckRuns.set(checkRun.name, checkRun);
}
}
// Check for runs which had error annotations
for (const checkRun of Array.from(latestCheckRuns.values())) {
if (checkRun.name === "Audit CI on Branches") {
continue; // Skip the audit workflow itself
}
const annotations = (await github.rest.checks.listAnnotations({
owner: "electron",
repo: "electron",
check_run_id: checkRun.id,
})).data ?? [];
if (
annotations.find(
({ annotation_level, message }) =>
annotation_level === "failure" &&
!message.startsWith("Process completed with exit code") &&
!message.startsWith("Response status code does not indicate success") &&
!/Unable to make request/.test(message) &&
!/The requested URL returned error/.test(message),
)
) {
checkRun.hasErrorAnnotations = true;
} else {
continue;
}
// Check if this is a known failure from a previous audit run
const cacheKey = `check-run-error-annotations-${checkRun.id}`;
const cacheHit =
(await cache.restoreCache(['/dev/null'], cacheKey, undefined, {
lookupOnly: true,
})) !== undefined;
if (cacheHit) {
checkRun.isStale = true;
}
checkRun.branch = branch;
runsWithErrors.push(checkRun);
// Create a cache entry (only the name matters) to keep track of
// failures we've seen from previous runs to mark them as stale
if (!cacheHit) {
await cache.saveCache(['/dev/null'], cacheKey);
}
}
}
if (runsWithErrors.length > 0) {
core.summary.addHeading('⚠️ Runs with Errors');
core.summary.addTable([
[
{ data: 'Branch', header: true },
{ data: 'Workflow Run', header: true },
{ data: 'Status', header: true },
],
...runsWithErrors
.sort(
(a, b) =>
a.branch.localeCompare(b.branch) ||
a.name.localeCompare(b.name),
)
.map((run) => [
run.branch,
`<a href="${run.html_url}">${run.name}</a>`,
run.isStale
? '📅 Stale'
: run.hasErrorAnnotations
? '⚠️ Errors'
: '✅ Succeeded',
]),
]);
// Set this as failed so it's easy to scan runs to find failures
if (runsWithErrors.find((run) => !run.isStale)) {
core.setOutput('errorsFound', true);
process.exitCode = 1;
}
} else {
core.summary.addRaw('🎉 No runs with errors');
}
await core.summary.write();
- name: Send Slack message if errors
if: ${{ always() && steps.audit-errors.outputs.errorsFound && github.ref == 'refs/heads/main' }}
uses: slackapi/slack-github-action@b0fa283ad8fea605de13dc3f449259339835fc52 # v2.1.0
with:
payload: |
link: "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
webhook: ${{ secrets.CI_ERRORS_SLACK_WEBHOOK_URL }}
webhook-type: webhook-trigger

74
.github/workflows/build-git-cache.yml vendored Normal file
View File

@@ -0,0 +1,74 @@
name: Build Git Cache
# This workflow updates git cache on the cross-instance cache volumes
# It runs daily at midnight.
on:
schedule:
- cron: "0 0 * * *"
jobs:
build-git-cache-linux:
runs-on: electron-arc-linux-amd64-32core
container:
image: ghcr.io/electron/build:bc2f48b2415a670de18d13605b1cf0eb5fdbaae1
options: --user root
volumes:
- /mnt/cross-instance-cache:/mnt/cross-instance-cache
env:
CHROMIUM_GIT_COOKIE: ${{ secrets.CHROMIUM_GIT_COOKIE }}
GCLIENT_EXTRA_ARGS: '--custom-var=checkout_arm=True --custom-var=checkout_arm64=True'
steps:
- name: Checkout Electron
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
path: src/electron
fetch-depth: 0
- name: Build Git Cache
uses: ./src/electron/.github/actions/build-git-cache
with:
target-platform: linux
build-git-cache-windows:
runs-on: electron-arc-linux-amd64-32core
container:
image: ghcr.io/electron/build:bc2f48b2415a670de18d13605b1cf0eb5fdbaae1
options: --user root --device /dev/fuse --cap-add SYS_ADMIN
volumes:
- /mnt/win-cache:/mnt/win-cache
env:
CHROMIUM_GIT_COOKIE: ${{ secrets.CHROMIUM_GIT_COOKIE }}
GCLIENT_EXTRA_ARGS: '--custom-var=checkout_win=True'
TARGET_OS: 'win'
steps:
- name: Checkout Electron
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
path: src/electron
fetch-depth: 0
- name: Build Git Cache
uses: ./src/electron/.github/actions/build-git-cache
with:
target-platform: win
build-git-cache-macos:
runs-on: electron-arc-linux-amd64-32core
# This job updates the same git cache as linux, so it needs to run after the linux one.
needs: build-git-cache-linux
container:
image: ghcr.io/electron/build:bc2f48b2415a670de18d13605b1cf0eb5fdbaae1
options: --user root
volumes:
- /mnt/cross-instance-cache:/mnt/cross-instance-cache
env:
CHROMIUM_GIT_COOKIE: ${{ secrets.CHROMIUM_GIT_COOKIE }}
GCLIENT_EXTRA_ARGS: '--custom-var=checkout_mac=True --custom-var=host_os=mac'
steps:
- name: Checkout Electron
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
path: src/electron
fetch-depth: 0
- name: Build Git Cache
uses: ./src/electron/.github/actions/build-git-cache
with:
target-platform: macos

View File

@@ -129,6 +129,7 @@ jobs:
- /var/run/sas:/var/run/sas
env:
CHROMIUM_GIT_COOKIE: ${{ secrets.CHROMIUM_GIT_COOKIE }}
DD_API_KEY: ${{ secrets.DD_API_KEY }}
GCLIENT_EXTRA_ARGS: '--custom-var=checkout_arm=True --custom-var=checkout_arm64=True'
PATCH_UP_APP_CREDS: ${{ secrets.PATCH_UP_APP_CREDS }}
outputs:
@@ -142,6 +143,8 @@ jobs:
ref: ${{ github.event.pull_request.head.sha }}
- name: Checkout & Sync & Save
uses: ./src/electron/.github/actions/checkout
with:
target-platform: linux
checkout-windows:
needs: setup

View File

@@ -60,6 +60,8 @@ jobs:
// It's possible for multiple versions to be listed -
// for now check for comma or space separated version.
const versions = electronVersion.split(/, | /);
let hasSupportedVersion = false;
for (const version of versions) {
const major = semver.coerce(version, { loose: true })?.major;
if (major) {
@@ -75,19 +77,20 @@ jobs:
labelExists = true;
} catch {}
if (labelExists) {
// Check if it's an unsupported major
const { ElectronVersions } = await import('${{ github.workspace }}/node_modules/@electron/fiddle-core/dist/index.js');
const versions = await ElectronVersions.create(undefined, { ignoreCache: true });
const { ElectronVersions } = await import('${{ github.workspace }}/node_modules/@electron/fiddle-core/dist/index.js');
const electronVersions = await ElectronVersions.create(undefined, { ignoreCache: true });
const validVersions = [...electronVersions.supportedMajors, ...electronVersions.prereleaseMajors];
const validVersions = [...versions.supportedMajors, ...versions.prereleaseMajors];
if (validVersions.includes(major)) {
if (validVersions.includes(major)) {
hasSupportedVersion = true;
if (labelExists) {
labels.push(versionLabel);
}
}
}
}
if (labels.length === 0) {
if (!hasSupportedVersion) {
core.setOutput('unsupportedMajor', true);
labels.push('blocked/need-info ❌');
}

View File

@@ -61,6 +61,9 @@ jobs:
curl -sL "https://chromium.googlesource.com/chromium/src/+/${chromium_revision}/buildtools/DEPS?format=TEXT" | base64 -d > src/buildtools/DEPS
gclient sync --spec="solutions=[{'name':'src/buildtools','url':None,'deps_file':'DEPS','custom_vars':{'process_deps':True},'managed':False}]"
- name: Add ESLint problem matcher
shell: bash
run: echo "::add-matcher::src/electron/.github/problem-matchers/eslint-stylish.json"
- name: Run Lint
shell: bash
run: |

View File

@@ -104,7 +104,7 @@ jobs:
if: ${{ inputs.target-platform == 'macos' }}
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020
with:
node-version: 20.11.x
node-version: 20.19.x
cache: yarn
cache-dependency-path: src/electron/yarn.lock
- name: Install Dependencies

View File

@@ -81,7 +81,7 @@ jobs:
if: ${{ inputs.target-platform == 'win' }}
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020
with:
node-version: 20.11.x
node-version: 20.19.x
- name: Add TCC permissions on macOS
if: ${{ inputs.target-platform == 'macos' }}
run: |
@@ -135,6 +135,7 @@ jobs:
git config --global core.autocrlf false
git config --global branch.autosetuprebase always
git config --global core.fscache true
git config --global core.longpaths true
git config --global core.preloadindex true
git clone --filter=tree:0 https://chromium.googlesource.com/chromium/tools/depot_tools.git
# Ensure depot_tools does not update.

View File

@@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Trigger Slack workflow
uses: slackapi/slack-github-action@485a9d42d3a73031f12ec201c457e2162c45d02d # v2.0.0
uses: slackapi/slack-github-action@b0fa283ad8fea605de13dc3f449259339835fc52 # v2.1.0
with:
webhook: ${{ secrets.BACKPORT_REQUESTED_SLACK_WEBHOOK_URL }}
webhook-type: webhook-trigger

View File

@@ -28,7 +28,7 @@ jobs:
# This is a pre-submit / pre-release.
- name: "Run analysis"
uses: ossf/scorecard-action@f49aabe0b5af0936a0987cfb85d86b75731b0186 # v2.4.1
uses: ossf/scorecard-action@05b42c624433fc40578a4040d5cf5e36ddca8cde # v2.4.2
with:
results_file: results.sarif
results_format: sarif
@@ -50,6 +50,6 @@ jobs:
# Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@45775bd8235c68ba998cffa5171334d58593da47 # v3.28.15
uses: github/codeql-action/upload-sarif@181d5eefc20863364f96762470ba6f862bdef56b # v3.29.2
with:
sarif_file: results.sarif

View File

@@ -27,7 +27,7 @@ jobs:
This issue has been automatically marked as stale. **If this issue is still affecting you, please leave any comment** (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the [latest version of Electron](https://www.electronjs.org/releases/stable) or in the [beta](https://www.electronjs.org/releases/beta)—please include it with your comment!
close-issue-message: >
This issue has been closed due to inactivity, and will not be monitored. If this is a bug and you can reproduce this issue on a [supported version of Electron](https://www.electronjs.org/docs/latest/tutorial/electron-timelines#timeline) please open a new issue and include instructions for reproducing the issue.
exempt-issue-labels: "discussion,security \U0001F512,enhancement :sparkles:,status/confirmed,stale-exempt"
exempt-issue-labels: "discussion,security \U0001F512,enhancement :sparkles:,status/confirmed,stale-exempt,upgrade-follow-up"
only-pr-labels: not-a-real-label
pending-repro:
runs-on: ubuntu-latest

View File

@@ -1,4 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
npm run precommit

View File

@@ -1,4 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
npm run prepack

View File

@@ -1,6 +1,7 @@
{
"config": {
"extends": "@electron/lint-roller/configs/markdownlint.json",
"descriptive-link-text": false,
"link-image-style": {
"autolink": false,
"shortcut": false
@@ -26,6 +27,6 @@
"no-newline-in-links": true
},
"customRules": [
"@electron/lint-roller/markdownlint-rules/"
"./node_modules/@electron/lint-roller/markdownlint-rules/index.mjs"
]
}

View File

@@ -38,8 +38,8 @@ if (is_mac) {
import("build/rules.gni")
assert(
mac_deployment_target == "11.0",
"Chromium has updated the mac_deployment_target, please update this assert, update the supported versions documentation (docs/tutorial/support.md) and flag this as a breaking change")
mac_deployment_target == "12.0",
"Chromium has updated the mac_deployment_target, please update this assert and flag this as a breaking change (docs/breaking-changes.md)")
}
if (is_linux) {

6
DEPS
View File

@@ -2,9 +2,9 @@ gclient_gn_args_from = 'src'
vars = {
'chromium_version':
'138.0.7160.0',
'140.0.7261.0',
'node_version':
'v22.15.0',
'v22.17.0',
'nan_version':
'e14bdcd1f72d62bca1d541b66da43130384ec213',
'squirrel.mac_version':
@@ -31,7 +31,7 @@ vars = {
'sysroots_json_path': 'electron/script/sysroots.json',
# KEEP IN SYNC WITH utils.js FILE
'yarn_version': '1.15.2',
'yarn_version': '1.22.22',
# To be able to build clean Chromium from sources.
'apply_patches': True,

View File

@@ -44,29 +44,17 @@ Each Electron release provides binaries for macOS, Windows, and Linux.
* Fedora 32 and newer
* Debian 10 and newer
## Quick start & Electron Fiddle
## Electron Fiddle
Use [`Electron Fiddle`](https://github.com/electron/fiddle)
to build, run, and package small Electron experiments, to see code examples for all of Electron's APIs, and
to try out different versions of Electron. It's designed to make the start of your journey with
Electron easier.
Alternatively, clone and run the
[electron/electron-quick-start](https://github.com/electron/electron-quick-start)
repository to see a minimal Electron app in action:
```sh
git clone https://github.com/electron/electron-quick-start
cd electron-quick-start
npm install
npm start
```
## Resources for learning Electron
* [electronjs.org/docs](https://electronjs.org/docs) - All of Electron's documentation
* [electron/fiddle](https://github.com/electron/fiddle) - A tool to build, run, and package small Electron experiments
* [electron/electron-quick-start](https://github.com/electron/electron-quick-start) - A very basic starter Electron app
* [electronjs.org/community#boilerplates](https://electronjs.org/community#boilerplates) - Sample starter apps created by the community
## Programmatic usage

View File

@@ -1,8 +1,8 @@
{
"plugins": [
"unicorn"
"import"
],
"rules": {
"unicorn/prefer-node-protocol": "error"
"import/enforce-node-protocol-usage": ["error", "always"]
}
}

View File

@@ -2,7 +2,7 @@ is_electron_build = true
root_extra_deps = [ "//electron" ]
# Registry of NMVs --> https://github.com/nodejs/node/blob/main/doc/abi_version_registry.json
node_module_version = 136
node_module_version = 139
v8_promise_internal_field_count = 1
v8_embedder_string = "-electron.0"
@@ -73,3 +73,7 @@ enterprise_cloud_content_analysis = false
# TODO: remove dependency on legacy ipc
# https://issues.chromium.org/issues/40943039
content_enable_legacy_ipc = true
# Disable siso until we are ready to use it.
# https://chromium-review.googlesource.com/c/chromium/src/+/6638830
use_siso = false

21
build/siso/backend.star Normal file
View File

@@ -0,0 +1,21 @@
# -*- bazel-starlark -*-
load("@builtin//struct.star", "module")
def __platform_properties(ctx):
container_image = "docker://gcr.io/chops-public-images-prod/rbe/siso-chromium/linux@sha256:ef35d347f4a4a2d32b76fd908e66e96f59bf8ba7379fd5626548244c45343b2b"
return {
"default": {
"OSFamily": "Linux",
"container-image": container_image,
},
"large": {
"OSFamily": "Linux",
"container-image": container_image,
},
}
backend = module(
"backend",
platform_properties = __platform_properties,
)

View File

@@ -66,6 +66,8 @@ static_library("chrome") {
"//chrome/browser/picture_in_picture/picture_in_picture_occlusion_tracker.h",
"//chrome/browser/picture_in_picture/picture_in_picture_occlusion_tracker_observer.cc",
"//chrome/browser/picture_in_picture/picture_in_picture_occlusion_tracker_observer.h",
"//chrome/browser/picture_in_picture/picture_in_picture_widget_fade_animator.cc",
"//chrome/browser/picture_in_picture/picture_in_picture_widget_fade_animator.h",
"//chrome/browser/picture_in_picture/picture_in_picture_window_manager.cc",
"//chrome/browser/picture_in_picture/picture_in_picture_window_manager.h",
"//chrome/browser/picture_in_picture/picture_in_picture_window_manager_uma_helper.cc",
@@ -142,8 +144,14 @@ static_library("chrome") {
"//chrome/browser/ui/views/overlay/toggle_camera_button.h",
"//chrome/browser/ui/views/overlay/toggle_microphone_button.cc",
"//chrome/browser/ui/views/overlay/toggle_microphone_button.h",
"//chrome/browser/ui/views/overlay/video_overlay_window_native_widget_mac.h",
"//chrome/browser/ui/views/overlay/video_overlay_window_native_widget_mac.mm",
"//chrome/browser/ui/views/overlay/video_overlay_window_views.cc",
"//chrome/browser/ui/views/overlay/video_overlay_window_views.h",
"//chrome/browser/ui/views/picture_in_picture/picture_in_picture_bounds_change_animation.cc",
"//chrome/browser/ui/views/picture_in_picture/picture_in_picture_bounds_change_animation.h",
"//chrome/browser/ui/views/picture_in_picture/picture_in_picture_tucker.cc",
"//chrome/browser/ui/views/picture_in_picture/picture_in_picture_tucker.h",
"//chrome/browser/ui/webui/accessibility/accessibility_ui.cc",
"//chrome/browser/ui/webui/accessibility/accessibility_ui.h",
"//chrome/browser/usb/usb_blocklist.cc",

View File

@@ -1,8 +1,8 @@
{
"plugins": [
"unicorn"
"import"
],
"rules": {
"unicorn/prefer-node-protocol": "error"
"import/enforce-node-protocol-usage": ["error", "always"]
}
}

35
docs/.eslintrc.json Normal file
View File

@@ -0,0 +1,35 @@
{
"extends": "standard",
"plugins": [
"import",
"markdown"
],
"overrides": [
{
"files": ["*.md", "**/*.md"],
"processor": "markdown/markdown"
}
],
"rules": {
"@typescript-eslint/no-unused-vars": "off",
"import/order": ["error", {
"alphabetize": {
"order": "asc"
},
"newlines-between": "always",
"pathGroups": [
{
"pattern": "{electron,electron/**}",
"group": "builtin",
"position": "before"
}
],
"pathGroupsExcludedImportTypes": []
}],
"n/no-callback-literal": "off",
"no-undef": "off",
"no-unused-expressions": "off",
"no-unused-vars": "off",
"import/enforce-node-protocol-usage": ["error", "always"]
}
}

View File

@@ -113,6 +113,7 @@ These individual tutorials expand on topics discussed in the guide above.
* [dialog](api/dialog.md)
* [globalShortcut](api/global-shortcut.md)
* [inAppPurchase](api/in-app-purchase.md)
* [ImageView](api/image-view.md)
* [ipcMain](api/ipc-main.md)
* [Menu](api/menu.md)
* [MenuItem](api/menu-item.md)

View File

@@ -9,6 +9,7 @@ closed:
```js
const { app } = require('electron')
app.on('window-all-closed', () => {
app.quit()
})
@@ -41,9 +42,10 @@ that was used to open the application, if it was launched from Notification Cent
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.
**Note**: The `ready` event is only fired after the main process has finished running the first
tick of the event loop. If an Electron API needs to be called before the `ready` event, ensure
that it is called synchronously in the top-level context of the main process.
> [!NOTE]
> The `ready` event is only fired after the main process has finished running the first
> tick of the event loop. If an Electron API needs to be called before the `ready` event, ensure
> that it is called synchronously in the top-level context of the main process.
### Event: 'window-all-closed'
@@ -66,12 +68,14 @@ 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]
> 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.
> [!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.
### Event: 'will-quit'
@@ -86,8 +90,9 @@ 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.
> [!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.
### Event: 'quit'
@@ -98,8 +103,9 @@ Returns:
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.
> [!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.
### Event: 'open-file' _macOS_
@@ -470,24 +476,28 @@ and `workingDirectory` is its current working directory. Usually
applications respond to this by making their primary window focused and
non-minimized.
**Note:** `argv` will not be exactly the same list of arguments as those passed
to the second instance. The order might change and additional arguments might be appended.
If you need to maintain the exact same arguments, it's advised to use `additionalData` instead.
> [!NOTE]
> `argv` will not be exactly the same list of arguments as those passed
> to the second instance. The order might change and additional arguments might be appended.
> If you need to maintain the exact same arguments, it's advised to use `additionalData` instead.
**Note:** If the second instance is started by a different user than the first, the `argv` array will not include the arguments.
> [!NOTE]
> If the second instance is started by a different user than the first, the `argv` array will not include the arguments.
This event is guaranteed to be emitted after the `ready` event of `app`
gets emitted.
**Note:** Extra command line arguments might be added by Chromium,
such as `--original-process-start-time`.
> [!NOTE]
> Extra command line arguments might be added by Chromium,
> such as `--original-process-start-time`.
## Methods
The `app` object has the following methods:
**Note:** Some methods are only available on specific operating systems and are
labeled as such.
> [!NOTE]
> Some methods are only available on specific operating systems and are
> labeled as such.
### `app.quit()`
@@ -679,7 +689,8 @@ preferred over `name` by Electron.
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.
> [!NOTE]
> This function overrides the name used internally by Electron; it does not affect the name that the OS uses.
### `app.getLocale()`
@@ -688,18 +699,22 @@ Possible return values are documented [here](https://source.chromium.org/chromiu
To set the locale, you'll want to use a command line switch at app startup, which may be found [here](command-line-switches.md).
**Note:** When distributing your packaged app, you have to also ship the
`locales` folder.
> [!NOTE]
> When distributing your packaged app, you have to also ship the
> `locales` folder.
**Note:** This API must be called after the `ready` event is emitted.
> [!NOTE]
> This API must be called after the `ready` event is emitted.
**Note:** To see example return values of this API compared to other locale and language APIs, see [`app.getPreferredSystemLanguages()`](#appgetpreferredsystemlanguages).
> [!NOTE]
> To see example return values of this API compared to other locale and language APIs, see [`app.getPreferredSystemLanguages()`](#appgetpreferredsystemlanguages).
### `app.getLocaleCountryCode()`
Returns `string` - User operating system's locale two-letter [ISO 3166](https://www.iso.org/iso-3166-country-codes.html) country code. The value is taken from native OS APIs.
**Note:** When unable to detect locale country code, it returns empty string.
> [!NOTE]
> When unable to detect locale country code, it returns empty string.
### `app.getSystemLocale()`
@@ -712,9 +727,11 @@ Different operating systems also use the regional data differently:
Therefore, this API can be used for purposes such as choosing a format for rendering dates and times in a calendar app, especially when the developer wants the format to be consistent with the OS.
**Note:** This API must be called after the `ready` event is emitted.
> [!NOTE]
> This API must be called after the `ready` event is emitted.
**Note:** To see example return values of this API compared to other locale and language APIs, see [`app.getPreferredSystemLanguages()`](#appgetpreferredsystemlanguages).
> [!NOTE]
> To see example return values of this API compared to other locale and language APIs, see [`app.getPreferredSystemLanguages()`](#appgetpreferredsystemlanguages).
### `app.getPreferredSystemLanguages()`
@@ -777,16 +794,18 @@ 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-forge],
[Electron Packager][electron-packager], or by editing `info.plist` with a text
editor. Please refer to [Apple's documentation][CFBundleURLTypes] for details.
> [!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-forge],
> [Electron Packager][electron-packager], or by editing `info.plist` with a text
> editor. Please refer to [Apple's documentation][CFBundleURLTypes] 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](https://learn.microsoft.com/en-us/uwp/schemas/appxpackage/uapmanifestschema/element-uap-protocol).
> [!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](https://learn.microsoft.com/en-us/uwp/schemas/appxpackage/uapmanifestschema/element-uap-protocol).
The API uses the Windows Registry and `LSSetDefaultHandlerForURLScheme` internally.
@@ -810,11 +829,12 @@ protocol (aka URI scheme). If so, it will remove the app as the default handler.
Returns `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][LSCopyDefaultHandlerForURLScheme] for details.
> [!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][LSCopyDefaultHandlerForURLScheme] for details.
The API uses the Windows Registry and `LSCopyDefaultHandlerForURLScheme` internally.
@@ -858,8 +878,9 @@ Adds `tasks` to the [Tasks][tasks] category of the Jump List on Windows.
Returns `boolean` - Whether the call succeeded.
**Note:** If you'd like to customize the Jump List even more use
`app.setJumpList(categories)` instead.
> [!NOTE]
> If you'd like to customize the Jump List even more use
> `app.setJumpList(categories)` instead.
### `app.getJumpListSettings()` _Windows_
@@ -897,21 +918,24 @@ following strings:
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
> [!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]
> 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.
> [!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:
@@ -1000,6 +1024,7 @@ starts:
```js
const { app, BrowserWindow } = require('electron')
let myWindow = null
const additionalData = { myKey: 'myValue' }
@@ -1188,7 +1213,8 @@ Returns [`ProcessMetric[]`](structures/process-metric.md): Array of `ProcessMetr
Returns [`GPUFeatureStatus`](structures/gpu-feature-status.md) - The Graphics Feature Status from `chrome://gpu/`.
**Note:** This information is only usable after the `gpu-info-update` event is emitted.
> [!NOTE]
> This information is only usable after the `gpu-info-update` event is emitted.
### `app.getGPUInfo(infoType)`
@@ -1202,6 +1228,8 @@ For `infoType` equal to `complete`:
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:
<!-- eslint-skip -->
```js
{
auxAttributes:
@@ -1242,11 +1270,13 @@ 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][unity-requirement].
> [!NOTE]
> Unity launcher requires a `.desktop` file to work. For more information,
> please read the [Unity integration documentation][unity-requirement].
**Note:** On macOS, you need to ensure that your application has the permission
to display notifications for this method to work.
> [!NOTE]
> On macOS, you need to ensure that your application has the permission
> to display notifications for this method to work.
### `app.getBadgeCount()` _Linux_ _macOS_
@@ -1313,6 +1343,7 @@ latest version.
``` js
const { app } = require('electron')
const path = require('node:path')
const appFolder = path.dirname(process.execPath)
@@ -1348,7 +1379,8 @@ 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.
> [!NOTE]
> Rendering accessibility tree can significantly affect the performance of your app. It should not be enabled by default.
### `app.showAboutPanel()`
@@ -1386,6 +1418,7 @@ Returns `Function` - This function **must** be called once you have finished acc
```js
const { app, dialog } = require('electron')
const fs = require('node:fs')
let filepath
@@ -1476,7 +1509,8 @@ By using this API, important information such as password and other sensitive in
See [Apple's documentation](https://developer.apple.com/library/archive/technotes/tn2150/_index.html) for more
details.
**Note:** Enable `Secure Keyboard Entry` only when it is needed and disable it when it is no longer needed.
> [!NOTE]
> Enable `Secure Keyboard Entry` only when it is needed and disable it when it is no longer needed.
### `app.setProxy(config)`
@@ -1538,7 +1572,8 @@ See [Chromium's accessibility docs](https://www.chromium.org/developers/design-d
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.
> [!NOTE]
> Rendering accessibility tree can significantly affect the performance of your app. It should not be enabled by default.
### `app.applicationMenu`
@@ -1551,11 +1586,13 @@ An `Integer` property that returns the badge count for current app. Setting the
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][unity-requirement].
> [!NOTE]
> Unity launcher requires a `.desktop` file to work. For more information,
> please read the [Unity integration documentation][unity-requirement].
**Note:** On macOS, you need to ensure that your application has the permission
to display notifications for this property to take effect.
> [!NOTE]
> On macOS, you need to ensure that your application has the permission
> to display notifications for this property to take effect.
### `app.commandLine` _Readonly_

View File

@@ -26,8 +26,9 @@ requirements, you can read [Server Support][server-support]. Note that
update process. Apps that need to disable ATS can add the
`NSAllowsArbitraryLoads` key to their app's plist.
**Note:** Your application must be signed for automatic updates on macOS.
This is a requirement of `Squirrel.Mac`.
> [!IMPORTANT]
> Your application must be signed for automatic updates on macOS.
> This is a requirement of `Squirrel.Mac`.
### Windows
@@ -93,8 +94,9 @@ 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.
> [!NOTE]
> It is not strictly necessary to handle this event. A successfully
> downloaded update will still be applied the next time the application starts.
### Event: 'before-quit-for-update'
@@ -125,8 +127,9 @@ Returns `string` - The current update feed URL.
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.
> [!NOTE]
> If an update is available it will be downloaded automatically.
> Calling `autoUpdater.checkForUpdates()` twice will download the update two times.
### `autoUpdater.quitAndInstall()`
@@ -137,9 +140,10 @@ 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.
> [!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.
[squirrel-mac]: https://github.com/Squirrel/Squirrel.Mac
[server-support]: https://github.com/Squirrel/Squirrel.Mac#server-support

View File

@@ -4,7 +4,7 @@
Process: [Main](../glossary.md#main-process)
> **Note**
> [!NOTE]
> `BaseWindow` provides a flexible way to compose multiple web views in a
> single window. For windows with only a single, full-size web view, the
> [`BrowserWindow`](browser-window.md) class may be a simpler option.
@@ -99,6 +99,10 @@ Process: [Main](../glossary.md#main-process)
It creates a new `BaseWindow` with native properties as set by the `options`.
> [!WARNING]
> Electron's built-in classes cannot be subclassed in user code.
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
### `new BaseWindow([options])`
* `options` [BaseWindowConstructorOptions](structures/base-window-options.md?inline) (optional)
@@ -107,8 +111,9 @@ It creates a new `BaseWindow` with native properties as set by the `options`.
Objects created with `new BaseWindow` emit the following events:
**Note:** Some events are only available on specific operating systems and are
labeled as such.
> [!NOTE]
> Some events are only available on specific operating systems and are
> labeled as such.
#### Event: 'close'
@@ -137,7 +142,11 @@ window.onbeforeunload = (e) => {
}
```
_**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._
> [!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.
#### Event: 'closed'
@@ -252,7 +261,8 @@ Emitted when the window is being moved to a new position.
Emitted once when the window is moved to a new position.
**Note**: On macOS this event is an alias of `move`.
> [!NOTE]
> On macOS, this event is an alias of `move`.
#### Event: 'enter-full-screen'
@@ -288,6 +298,7 @@ e.g. `APPCOMMAND_BROWSER_BACKWARD` is emitted as `browser-backward`.
```js
const { BaseWindow } = require('electron')
const win = new BaseWindow()
win.on('app-command', (e, cmd) => {
// Navigate the window back when the user hits their mouse back button
@@ -421,7 +432,8 @@ A `boolean` property that determines whether the window is focusable.
A `boolean` property that determines whether the window is visible on all workspaces.
**Note:** Always returns false on Windows.
> [!NOTE]
> Always returns false on Windows.
#### `win.shadow`
@@ -431,7 +443,8 @@ A `boolean` property that determines whether the window has a shadow.
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.
> [!NOTE]
> If the menu bar is auto-hide, users can still bring up the menu bar by pressing the single `Alt` key.
#### `win.kiosk`
@@ -452,7 +465,8 @@ and the icon of the file will show in window's title bar.
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.
> [!NOTE]
> The title of the web page can be different from the title of the native window.
#### `win.minimizable` _macOS_ _Windows_
@@ -493,6 +507,7 @@ A `boolean` property that determines whether the window is excluded from the app
```js @ts-expect-error=[12]
const { Menu, BaseWindow } = require('electron')
const win = new BaseWindow({ height: 600, width: 600 })
const template = [
@@ -521,8 +536,9 @@ A `boolean` property that indicates whether the window is arranged via [Snap.](h
Objects created with `new BaseWindow` have the following instance methods:
**Note:** Some methods are only available on specific operating systems and are
labeled as such.
> [!NOTE]
> Some methods are only available on specific operating systems and are
> labeled as such.
#### `win.setContentView(view)`
@@ -614,7 +630,8 @@ Returns `boolean` - Whether the window is minimized.
Sets whether the window should be in fullscreen mode.
**Note:** On macOS, fullscreen transitions take place asynchronously. If further actions depend on the fullscreen state, use the ['enter-full-screen'](base-window.md#event-enter-full-screen) or ['leave-full-screen'](base-window.md#event-leave-full-screen) events.
> [!NOTE]
> On macOS, fullscreen transitions take place asynchronously. If further actions depend on the fullscreen state, use the ['enter-full-screen'](base-window.md#event-enter-full-screen) or > ['leave-full-screen'](base-window.md#event-leave-full-screen) events.
#### `win.isFullScreen()`
@@ -716,6 +733,7 @@ Resizes and moves the window to the supplied bounds. Any properties that are not
```js
const { BaseWindow } = require('electron')
const win = new BaseWindow()
// set all bounds properties
@@ -728,13 +746,15 @@ win.setBounds({ width: 100 })
console.log(win.getBounds())
```
**Note:** On macOS, the y-coordinate value cannot be smaller than the [Tray](tray.md) height. The tray height has changed over time and depends on the operating system, but is between 20-40px. Passing a value lower than the tray height will result in a window that is flush to the tray.
> [!NOTE]
> On macOS, the y-coordinate value cannot be smaller than the [Tray](tray.md) height. The tray height has changed over time and depends on the operating system, but is between 20-40px. Passing a value lower than the tray height will result in a window that is flush to the tray.
#### `win.getBounds()`
Returns [`Rectangle`](structures/rectangle.md) - The `bounds` of the window as `Object`.
**Note:** On macOS, the y-coordinate value returned will be at minimum the [Tray](tray.md) height. For example, calling `win.setBounds({ x: 25, y: 20, width: 800, height: 600 })` with a tray height of 38 means that `win.getBounds()` will return `{ x: 25, y: 38, width: 800, height: 600 }`.
> [!NOTE]
> On macOS, the y-coordinate value returned will be at minimum the [Tray](tray.md) height. For example, calling `win.setBounds({ x: 25, y: 20, width: 800, height: 600 })` with a tray height of 38 means that `win.getBounds()` will return `{ x: 25, y: 38, width: 800, height: 600 }`.
#### `win.getBackgroundColor()`
@@ -742,7 +762,8 @@ Returns `string` - Gets the background color of the window in Hex (`#RRGGBB`) fo
See [Setting `backgroundColor`](browser-window.md#setting-the-backgroundcolor-property).
**Note:** The alpha value is _not_ returned alongside the red, green, and blue values.
> [!NOTE]
> The alpha value is _not_ returned alongside the red, green, and blue values.
#### `win.setContentBounds(bounds[, animate])`
@@ -760,7 +781,8 @@ Returns [`Rectangle`](structures/rectangle.md) - The `bounds` of the window's cl
Returns [`Rectangle`](structures/rectangle.md) - 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`](structures/rectangle.md).
> [!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`](structures/rectangle.md).
#### `win.setEnabled(enable)`
@@ -957,8 +979,9 @@ Changes the title of native window to `title`.
Returns `string` - The title of the native window.
**Note:** The title of the web page can be different from the title of the native
window.
> [!NOTE]
> The title of the web page can be different from the title of the native
> window.
#### `win.setSheetOffset(offsetY[, offsetX])` _macOS_
@@ -971,6 +994,7 @@ a HTML-rendered toolbar. For example:
```js
const { BaseWindow } = require('electron')
const win = new BaseWindow()
const toolbarRect = document.getElementById('toolbar').getBoundingClientRect()
@@ -1232,8 +1256,9 @@ in the taskbar.
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.
> [!NOTE]
> `relaunchCommand` and `relaunchDisplayName` must always be set
> together. If one of those properties is not set, then neither will be used.
#### `win.setIcon(icon)` _Windows_ _Linux_
@@ -1293,13 +1318,15 @@ maximize button, or by dragging it to the edges of the screen.
Sets whether the window should be visible on all workspaces.
**Note:** This API does nothing on Windows.
> [!NOTE]
> This API does nothing on Windows.
#### `win.isVisibleOnAllWorkspaces()` _macOS_ _Linux_
Returns `boolean` - Whether the window is visible on all workspaces.
**Note:** This API always returns false on Windows.
> [!NOTE]
> This API always returns false on Windows.
#### `win.setIgnoreMouseEvents(ignore[, options])`
@@ -1327,6 +1354,10 @@ 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.
#### `win.isContentProtected()` _macOS_ _Windows_
Returns `boolean` - whether or not content protection is currently enabled.
#### `win.setFocusable(focusable)` _macOS_ _Windows_
* `focusable` boolean
@@ -1416,7 +1447,8 @@ This method sets the browser window's system-drawn background material, includin
See the [Windows documentation](https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/ne-dwmapi-dwm_systembackdrop_type) for more details.
**Note:** This method is only supported on Windows 11 22H2 and up.
> [!NOTE]
> This method is only supported on Windows 11 22H2 and up.
#### `win.setWindowButtonPosition(position)` _macOS_
@@ -1438,8 +1470,9 @@ 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.
**Note:** The TouchBar API is currently experimental and may change or be
removed in future Electron releases.
> [!NOTE]
> The TouchBar API is currently experimental and may change or be
> removed in future Electron releases.
#### `win.setTitleBarOverlay(options)` _Windows_ _Linux_

View File

@@ -8,7 +8,7 @@ deprecated:
```
-->
> **Note**
> [!NOTE]
> The `BrowserView` class is deprecated, and replaced by the new
> [`WebContentsView`](web-contents-view.md) class.
@@ -29,7 +29,7 @@ deprecated:
> Create and control views.
> **Note**
> [!NOTE]
> The `BrowserView` class is deprecated, and replaced by the new
> [`WebContentsView`](web-contents-view.md) class.
@@ -38,6 +38,10 @@ Process: [Main](../glossary.md#main-process)
This module cannot be used until the `ready` event of the `app`
module is emitted.
> [!WARNING]
> Electron's built-in classes cannot be subclassed in user code.
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
### Example
```js
@@ -176,4 +180,5 @@ Examples of valid `color` values:
* 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_ `RRGGBBAA` or `RGB`.
> [!NOTE]
> Hex format with alpha takes `AARRGGBB` or `ARGB`, _not_ `RRGGBBAA` or `RGB`.

View File

@@ -40,6 +40,7 @@ the window after this event will have no visual flash:
```js
const { BrowserWindow } = require('electron')
const win = new BrowserWindow({ show: false })
win.once('ready-to-show', () => {
win.show()
@@ -150,6 +151,10 @@ Process: [Main](../glossary.md#main-process)
It creates a new `BrowserWindow` with native properties as set by the `options`.
> [!WARNING]
> Electron's built-in classes cannot be subclassed in user code.
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
### `new BrowserWindow([options])`
* `options` [BrowserWindowConstructorOptions](structures/browser-window-options.md?inline) (optional)
@@ -158,7 +163,8 @@ It creates a new `BrowserWindow` with native properties as set by the `options`.
Objects created with `new BrowserWindow` emit the following events:
**Note:** Some events are only available on specific operating systems and are
> [!NOTE]
> Some events are only available on specific operating systems and are
labeled as such.
#### Event: 'page-title-updated'
@@ -200,7 +206,11 @@ window.onbeforeunload = (e) => {
}
```
_**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._
> [!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.
#### Event: 'closed'
@@ -323,7 +333,8 @@ Emitted when the window is being moved to a new position.
Emitted once when the window is moved to a new position.
**Note**: On macOS this event is an alias of `move`.
> [!NOTE]
> On macOS, this event is an alias of `move`.
#### Event: 'enter-full-screen'
@@ -367,6 +378,7 @@ e.g. `APPCOMMAND_BROWSER_BACKWARD` is emitted as `browser-backward`.
```js
const { BrowserWindow } = require('electron')
const win = new BrowserWindow()
win.on('app-command', (e, cmd) => {
// Navigate the window back when the user hits their mouse back button
@@ -460,7 +472,7 @@ or `null` if the contents are not owned by a window.
* `browserView` [BrowserView](browser-view.md)
> **Note**
> [!NOTE]
> The `BrowserView` class is deprecated, and replaced by the new
> [`WebContentsView`](web-contents-view.md) class.
@@ -522,7 +534,8 @@ A `boolean` property that determines whether the window is focusable.
A `boolean` property that determines whether the window is visible on all workspaces.
**Note:** Always returns false on Windows.
> [!NOTE]
> Always returns false on Windows.
#### `win.shadow`
@@ -532,7 +545,8 @@ A `boolean` property that determines whether the window has a shadow.
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.
> [!NOTE]
> If the menu bar is auto-hide, users can still bring up the menu bar by pressing the single `Alt` key.
#### `win.kiosk`
@@ -553,7 +567,8 @@ and the icon of the file will show in window's title bar.
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.
> [!NOTE]
> The title of the web page can be different from the title of the native window.
#### `win.minimizable` _macOS_ _Windows_
@@ -621,8 +636,9 @@ A `boolean` property that indicates whether the window is arranged via [Snap.](h
Objects created with `new BrowserWindow` have the following instance methods:
**Note:** Some methods are only available on specific operating systems and are
labeled as such.
> [!NOTE]
> Some methods are only available on specific operating systems and are
> labeled as such.
#### `win.destroy()`
@@ -704,13 +720,15 @@ Returns `boolean` - Whether the window is minimized.
Sets whether the window should be in fullscreen mode.
**Note:** On macOS, fullscreen transitions take place asynchronously. If further actions depend on the fullscreen state, use the ['enter-full-screen'](browser-window.md#event-enter-full-screen) or ['leave-full-screen'](browser-window.md#event-leave-full-screen) events.
> [!NOTE]
> On macOS, fullscreen transitions take place asynchronously. If further actions depend on the fullscreen state, use the ['enter-full-screen'](browser-window.md#event-enter-full-screen) or ['leave-full-screen'](browser-window.md#event-leave-full-screen) events.
#### `win.isFullScreen()`
Returns `boolean` - Whether the window is in fullscreen mode.
**Note:** On macOS, fullscreen transitions take place asynchronously. When querying for a BrowserWindow's fullscreen status, you should ensure that either the ['enter-full-screen'](browser-window.md#event-enter-full-screen) or ['leave-full-screen'](browser-window.md#event-leave-full-screen) events have been emitted.
> [!NOTE]
> On macOS, fullscreen transitions take place asynchronously. When querying for a BrowserWindow's fullscreen status, you should ensure that either the ['enter-full-screen'](browser-window.md#event-enter-full-screen) or ['leave-full-screen'](browser-window.md#event-leave-full-screen) events have been emitted.
#### `win.setSimpleFullScreen(flag)` _macOS_
@@ -808,6 +826,7 @@ Resizes and moves the window to the supplied bounds. Any properties that are not
```js
const { BrowserWindow } = require('electron')
const win = new BrowserWindow()
// set all bounds properties
@@ -820,13 +839,15 @@ win.setBounds({ width: 100 })
console.log(win.getBounds())
```
**Note:** On macOS, the y-coordinate value cannot be smaller than the [Tray](tray.md) height. The tray height has changed over time and depends on the operating system, but is between 20-40px. Passing a value lower than the tray height will result in a window that is flush to the tray.
> [!NOTE]
> On macOS, the y-coordinate value cannot be smaller than the [Tray](tray.md) height. The tray height has changed over time and depends on the operating system, but is between 20-40px. Passing a value lower than the tray height will result in a window that is flush to the tray.
#### `win.getBounds()`
Returns [`Rectangle`](structures/rectangle.md) - The `bounds` of the window as `Object`.
**Note:** On macOS, the y-coordinate value returned will be at minimum the [Tray](tray.md) height. For example, calling `win.setBounds({ x: 25, y: 20, width: 800, height: 600 })` with a tray height of 38 means that `win.getBounds()` will return `{ x: 25, y: 38, width: 800, height: 600 }`.
> [!NOTE]
> On macOS, the y-coordinate value returned will be at minimum the [Tray](tray.md) height. For example, calling `win.setBounds({ x: 25, y: 20, width: 800, height: 600 })` with a tray height of 38 means that `win.getBounds()` will return `{ x: 25, y: 38, width: 800, height: 600 }`.
#### `win.getBackgroundColor()`
@@ -834,7 +855,8 @@ Returns `string` - Gets the background color of the window in Hex (`#RRGGBB`) fo
See [Setting `backgroundColor`](#setting-the-backgroundcolor-property).
**Note:** The alpha value is _not_ returned alongside the red, green, and blue values.
> [!NOTE]
> The alpha value is _not_ returned alongside the red, green, and blue values.
#### `win.setContentBounds(bounds[, animate])`
@@ -852,7 +874,8 @@ Returns [`Rectangle`](structures/rectangle.md) - The `bounds` of the window's cl
Returns [`Rectangle`](structures/rectangle.md) - 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`](structures/rectangle.md).
> [!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` return the same [`Rectangle`](structures/rectangle.md).
#### `win.setEnabled(enable)`
@@ -1049,8 +1072,9 @@ Changes the title of native window to `title`.
Returns `string` - The title of the native window.
**Note:** The title of the web page can be different from the title of the native
window.
> [!NOTE]
> The title of the web page can be different from the title of the native
> window.
#### `win.setSheetOffset(offsetY[, offsetX])` _macOS_
@@ -1063,6 +1087,7 @@ a HTML-rendered toolbar. For example:
```js
const { BrowserWindow } = require('electron')
const win = new BrowserWindow()
const toolbarRect = document.getElementById('toolbar').getBoundingClientRect()
@@ -1215,9 +1240,10 @@ method:
```js
const { BrowserWindow } = require('electron')
const win = new BrowserWindow()
const url = require('url').format({
const url = require('node:url').format({
protocol: 'file',
slashes: true,
pathname: require('node:path').join(__dirname, 'index.html')
@@ -1231,6 +1257,7 @@ the following:
```js
const { BrowserWindow } = require('electron')
const win = new BrowserWindow()
win.loadURL('http://localhost:8000/post', {
@@ -1409,8 +1436,9 @@ in the taskbar.
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.
> [!NOTE]
> `relaunchCommand` and `relaunchDisplayName` must always be set
> together. If one of those properties is not set, then neither will be used.
#### `win.showDefinitionForSelection()` _macOS_
@@ -1474,13 +1502,15 @@ maximize button, or by dragging it to the edges of the screen.
Sets whether the window should be visible on all workspaces.
**Note:** This API does nothing on Windows.
> [!NOTE]
> This API does nothing on Windows.
#### `win.isVisibleOnAllWorkspaces()` _macOS_ _Linux_
Returns `boolean` - Whether the window is visible on all workspaces.
**Note:** This API always returns false on Windows.
> [!NOTE]
> This API always returns false on Windows.
#### `win.setIgnoreMouseEvents(ignore[, options])`
@@ -1508,6 +1538,10 @@ 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.
#### `win.isContentProtected()` _macOS_ _Windows_
Returns `boolean` - whether or not content protection is currently enabled.
#### `win.setFocusable(focusable)` _macOS_ _Windows_
* `focusable` boolean
@@ -1601,7 +1635,8 @@ This method sets the browser window's system-drawn background material, includin
See the [Windows documentation](https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/ne-dwmapi-dwm_systembackdrop_type) for more details.
**Note:** This method is only supported on Windows 11 22H2 and up.
> [!NOTE]
> This method is only supported on Windows 11 22H2 and up.
#### `win.setWindowButtonPosition(position)` _macOS_
@@ -1623,8 +1658,9 @@ 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.
**Note:** The TouchBar API is currently experimental and may change or be
removed in future Electron releases.
> [!NOTE]
> The TouchBar API is currently experimental and may change or be
> removed in future Electron releases.
#### `win.setBrowserView(browserView)` _Experimental_ _Deprecated_
@@ -1632,7 +1668,7 @@ removed in future Electron releases.
If there are other `BrowserView`s attached, they will be removed from
this window.
> **Note**
> [!WARNING]
> The `BrowserView` class is deprecated, and replaced by the new
> [`WebContentsView`](web-contents-view.md) class.
@@ -1641,7 +1677,7 @@ this window.
Returns `BrowserView | null` - The `BrowserView` attached to `win`. Returns `null`
if one is not attached. Throws an error if multiple `BrowserView`s are attached.
> **Note**
> [!WARNING]
> The `BrowserView` class is deprecated, and replaced by the new
> [`WebContentsView`](web-contents-view.md) class.
@@ -1651,7 +1687,7 @@ if one is not attached. Throws an error if multiple `BrowserView`s are attached.
Replacement API for setBrowserView supporting work with multi browser views.
> **Note**
> [!WARNING]
> The `BrowserView` class is deprecated, and replaced by the new
> [`WebContentsView`](web-contents-view.md) class.
@@ -1659,7 +1695,7 @@ Replacement API for setBrowserView supporting work with multi browser views.
* `browserView` [BrowserView](browser-view.md)
> **Note**
> [!WARNING]
> The `BrowserView` class is deprecated, and replaced by the new
> [`WebContentsView`](web-contents-view.md) class.
@@ -1670,7 +1706,7 @@ Replacement API for setBrowserView supporting work with multi browser views.
Raises `browserView` above other `BrowserView`s attached to `win`.
Throws an error if `browserView` is not attached to `win`.
> **Note**
> [!WARNING]
> The `BrowserView` class is deprecated, and replaced by the new
> [`WebContentsView`](web-contents-view.md) class.
@@ -1679,7 +1715,7 @@ Throws an error if `browserView` is not attached to `win`.
Returns `BrowserView[]` - a sorted by z-index array of all BrowserViews that have been attached
with `addBrowserView` or `setBrowserView`. The top-most BrowserView is the last element of the array.
> **Note**
> [!WARNING]
> The `BrowserView` class is deprecated, and replaced by the new
> [`WebContentsView`](web-contents-view.md) class.

View File

@@ -60,6 +60,10 @@ following properties:
`strict-origin-when-cross-origin`.
* `cache` string (optional) - can be `default`, `no-store`, `reload`,
`no-cache`, `force-cache` or `only-if-cached`.
* `priority` string (optional) - can be `throttled`, `idle`, `lowest`,
`low`, `medium`, or `highest`. Defaults to `idle`.
* `priorityIncremental` boolean (optional) - the incremental loading flag as part
of HTTP extensible priorities (RFC 9218). Default is `true`.
`options` properties such as `protocol`, `host`, `hostname`, `port` and `path`
strictly follow the Node.js model as described in the

View File

@@ -18,7 +18,8 @@ console.log(clipboard.readText('selection'))
The `clipboard` module has the following methods:
**Note:** Experimental APIs are marked as such and could be removed in future.
> [!NOTE]
> Experimental APIs are marked as such and could be removed in future.
### `clipboard.readText([type])`
@@ -141,9 +142,10 @@ bookmark is unavailable. The `title` value will always be empty on Windows.
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.
> [!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.
```js
const { clipboard } = require('electron')

View File

@@ -8,6 +8,7 @@ is emitted:
```js
const { app } = require('electron')
app.commandLine.appendSwitch('remote-debugging-port', '8315')
app.commandLine.appendSwitch('host-rules', 'MAP * 127.0.0.1')
@@ -73,7 +74,8 @@ Passing `--enable-logging=file` will result in logs being saved to the file
specified by `--log-file=...`, or to `electron_debug.log` in the user-data
directory if `--log-file` is not specified.
> **Note:** On Windows, logs from child processes cannot be sent to stderr.
> [!NOTE]
> On Windows, logs from child processes cannot be sent to stderr.
> Logging to a file is the most reliable way to collect logs on Windows.
See also `--log-file`, `--log-level`, `--v`, and `--vmodule`.
@@ -187,6 +189,7 @@ For example:
```js
const { app } = require('electron')
app.commandLine.appendSwitch('proxy-bypass-list', '<local>;*.google.com;*foo.com;1.2.3.4:5678')
```
@@ -252,9 +255,10 @@ the required version is unavailable. Current default is set to `3`.
Electron supports some of the [CLI flags][node-cli] supported by Node.js.
**Note:** Passing unsupported command line switches to Electron when it is not running in `ELECTRON_RUN_AS_NODE` will have no effect.
> [!NOTE]
> Passing unsupported command line switches to Electron when it is not running in `ELECTRON_RUN_AS_NODE` will have no effect.
### `--inspect-brk\[=\[host:]port]`
### `--inspect-brk[=[host:]port]`
Activate inspector on host:port and break at start of user script. Default host:port is 127.0.0.1:9229.
@@ -266,13 +270,13 @@ Activate inspector on `host:port` and break at start of the first internal
JavaScript script executed when the inspector is available.
Default `host:port` is `127.0.0.1:9229`.
### `--inspect-port=\[host:]port`
### `--inspect-port=[host:]port`
Set the `host:port` to be used when the inspector is activated. Useful when activating the inspector by sending the SIGUSR1 signal. Default host is `127.0.0.1`.
Aliased to `--debug-port=[host:]port`.
### `--inspect\[=\[host:]port]`
### `--inspect[=[host:]port]`
Activate inspector on `host:port`. Default is `127.0.0.1:9229`.
@@ -288,6 +292,10 @@ Specify ways of the inspector web socket url exposure.
By default inspector websocket url is available in stderr and under /json/list endpoint on `http://host:port/json/list`.
### `--experimental-network-inspection`
Enable support for devtools network inspector events, for visibility into requests made by the nodejs `http` and `https` modules.
### `--no-deprecation`
Silence deprecation warnings.
@@ -319,6 +327,26 @@ Set the directory to which all Node.js diagnostic output files are written. Defa
Affects the default output directory of [v8.setHeapSnapshotNearHeapLimit](https://nodejs.org/docs/latest/api/v8.html#v8setheapsnapshotnearheaplimitlimit).
### `--no-experimental-global-navigator`
Disable exposition of [Navigator API][] on the global scope from Node.js.
## Chromium Flags
There isn't a documented list of all Chromium switches, but there are a few ways to find them.
The easiest way is through Chromium's flags page, which you can access at `about://flags`. These flags don't directly match switch names, but they show up in the process's command-line arguments.
To see these arguments, enable a flag in `about://flags`, then go to `about://version` in Chromium. You'll find a list of command-line arguments, including `--flag-switches-begin --your --list --flag-switches-end`, which contains the list of your flag enabled switches.
Most flags are included as part of `--enable-features=`, but some are standalone switches, like `--enable-experimental-web-platform-features`.
A complete list of flags exists in [Chromium's flag metadata page](https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/flag-metadata.json), but this list includes platform, environment and GPU specific, expired and potentially non-functional flags, so many of them might not always work in every situation.
Keep in mind that standalone switches can sometimes be split into individual features, so there's no fully complete list of switches.
Finally, you'll need to ensure that the version of Chromium in Electron matches the version of the browser you're using to cross-reference the switches.
[app]: app.md
[append-switch]: command-line.md#commandlineappendswitchswitch-value
[debugging-main-process]: ../tutorial/debugging-main-process.md
@@ -327,3 +355,4 @@ Affects the default output directory of [v8.setHeapSnapshotNearHeapLimit](https:
[play-silent-audio]: https://github.com/atom/atom/pull/9485/files
[ready]: app.md#event-ready
[severities]: https://source.chromium.org/chromium/chromium/src/+/main:base/logging.h?q=logging::LogSeverity&ss=chromium
[Navigator API]: https://github.com/nodejs/node/blob/main/doc/api/globals.md#navigator

View File

@@ -9,6 +9,7 @@ The following example shows how to check if the `--disable-gpu` flag is set.
```js
const { app } = require('electron')
app.commandLine.hasSwitch('disable-gpu')
```
@@ -25,8 +26,9 @@ document.
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.
> [!NOTE]
> This will not affect `process.argv`. The intended usage of this function is to
> control Chromium's behavior.
```js
const { app } = require('electron')
@@ -49,8 +51,9 @@ const { app } = require('electron')
app.commandLine.appendArgument('--enable-experimental-web-platform-features')
```
**Note:** This will not affect `process.argv`. The intended usage of this function is to
control Chromium's behavior.
> [!NOTE]
> This will not affect `process.argv`. The intended usage of this function is to
> control Chromium's behavior.
#### `commandLine.hasSwitch(switch)`
@@ -84,7 +87,8 @@ const portValue = app.commandLine.getSwitchValue('remote-debugging-port')
console.log(portValue) // '8315'
```
**Note:** When the switch is not present or has no value, it returns empty string.
> [!NOTE]
> When the switch is not present or has no value, it returns empty string.
#### `commandLine.removeSwitch(switch)`
@@ -102,5 +106,6 @@ app.commandLine.removeSwitch('remote-debugging-port')
console.log(app.commandLine.hasSwitch('remote-debugging-port')) // false
```
**Note:** This will not affect `process.argv`. The intended usage of this function is to
control Chromium's behavior.
> [!NOTE]
> This will not affect `process.argv`. The intended usage of this function is to
> control Chromium's behavior.

View File

@@ -7,8 +7,9 @@ Process: [Main](../glossary.md#main-process)
This module does not include a web interface. To view recorded traces, use
[trace viewer][], available at `chrome://tracing` in Chrome.
**Note:** You should not use this module until the `ready` event of the app
module is emitted.
> [!NOTE]
> You should not use this module until the `ready` event of the app
> module is emitted.
```js
const { app, contentTracing } = require('electron')

View File

@@ -189,7 +189,9 @@ Be very cautious about which globals and APIs you expose to untrusted remote con
```js
const { contextBridge } = require('electron')
const crypto = require('node:crypto')
contextBridge.exposeInMainWorld('nodeCrypto', {
sha256sum (data) {
const hash = crypto.createHash('sha256')

View File

@@ -19,7 +19,8 @@ following projects:
* [socorro](https://github.com/mozilla-services/socorro)
* [mini-breakpad-server](https://github.com/electron/mini-breakpad-server)
> **Note:** Electron uses Crashpad, not Breakpad, to collect and upload
> [!NOTE]
> Electron uses Crashpad, not Breakpad, to collect and upload
> crashes, but for the time being, the [upload protocol is the same](https://chromium.googlesource.com/crashpad/crashpad/+/HEAD/doc/overview_design.md#Upload-to-collection-server).
Or use a 3rd party hosted solution:
@@ -84,19 +85,23 @@ 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]
> 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]
> 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]
> 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.
> [!NOTE]
> This method is only available in the main process.
### `crashReporter.getLastCrashReport()`
@@ -105,7 +110,8 @@ 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.
> [!NOTE]
> This method is only available in the main process.
### `crashReporter.getUploadedReports()`
@@ -114,14 +120,16 @@ Returns [`CrashReport[]`](structures/crash-report.md):
Returns all uploaded crash reports. Each report contains the date and uploaded
ID.
**Note:** This method is only available in the main process.
> [!NOTE]
> This method is only available in the main process.
### `crashReporter.getUploadToServer()`
Returns `boolean` - 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.
> [!NOTE]
> This method is only available in the main process.
### `crashReporter.setUploadToServer(uploadToServer)`
@@ -130,7 +138,8 @@ the `start` method or `setUploadToServer`.
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.
> [!NOTE]
> This method is only available in the main process.
### `crashReporter.addExtraParameter(key, value)`
@@ -148,10 +157,11 @@ 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.
> [!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.
### `crashReporter.removeExtraParameter(key)`

View File

@@ -10,6 +10,7 @@ runtime that allows interacting with pages and instrumenting them.
```js
const { BrowserWindow } = require('electron')
const win = new BrowserWindow()
try {

View File

@@ -70,8 +70,9 @@ stopButton.addEventListener('click', () => {
See [`navigator.mediaDevices.getDisplayMedia`](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getDisplayMedia) for more information.
**Note:** `navigator.mediaDevices.getDisplayMedia` does not permit the use of `deviceId` for
selection of a source - see [specification](https://w3c.github.io/mediacapture-screen-share/#constraints).
> [!NOTE]
> `navigator.mediaDevices.getDisplayMedia` does not permit the use of `deviceId` for
> selection of a source - see [specification](https://w3c.github.io/mediacapture-screen-share/#constraints).
## Methods
@@ -92,8 +93,9 @@ The `desktopCapturer` module has the following methods:
Returns `Promise<DesktopCapturerSource[]>` - Resolves with an array of [`DesktopCapturerSource`](structures/desktop-capturer-source.md) 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`][].
> [!NOTE]
> Capturing the screen contents requires user consent on macOS 10.15 Catalina or higher,
> which can detected by [`systemPreferences.getMediaAccessStatus`][].
[`navigator.mediaDevices.getUserMedia`]: https://developer.mozilla.org/en/docs/Web/API/MediaDevices/getUserMedia
[`systemPreferences.getMediaAccessStatus`]: system-preferences.md#systempreferencesgetmediaaccessstatusmediatype-windows-macos

View File

@@ -8,6 +8,7 @@ An example of showing a dialog to select multiple files:
```js
const { dialog } = require('electron')
console.log(dialog.showOpenDialog({ properties: ['openFile', 'multiSelections'] }))
```
@@ -52,6 +53,8 @@ The `window` argument allows the dialog to attach itself to a parent window, mak
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:
<!-- eslint-skip -->
```js
{
filters: [
@@ -67,10 +70,11 @@ 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.
> [!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.
```js @ts-type={mainWindow:Electron.BaseWindow}
dialog.showOpenDialogSync(mainWindow, {
@@ -78,10 +82,11 @@ dialog.showOpenDialogSync(mainWindow, {
})
```
**Note:** On Linux `defaultPath` is not supported when using portal file chooser
dialogs unless the portal backend is version 4 or higher. You can use `--xdg-portal-required-version`
[command-line switch](./command-line-switches.md#--xdg-portal-required-versionversion)
to force gtk or kde dialogs.
> [!NOTE]
> On Linux `defaultPath` is not supported when using portal file chooser
> dialogs unless the portal backend is version 4 or higher. You can use `--xdg-portal-required-version`
> [command-line switch](./command-line-switches.md#--xdg-portal-required-versionversion)
> to force gtk or kde dialogs.
### `dialog.showOpenDialog([window, ]options)`
@@ -124,6 +129,8 @@ The `window` argument allows the dialog to attach itself to a parent window, mak
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:
<!-- eslint-skip -->
```js
{
filters: [
@@ -139,10 +146,11 @@ 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.
> [!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.
```js @ts-type={mainWindow:Electron.BaseWindow}
dialog.showOpenDialog(mainWindow, {
@@ -155,10 +163,11 @@ dialog.showOpenDialog(mainWindow, {
})
```
**Note:** On Linux `defaultPath` is not supported when using portal file chooser
dialogs unless the portal backend is version 4 or higher. You can use `--xdg-portal-required-version`
[command-line switch](./command-line-switches.md#--xdg-portal-required-versionversion)
to force gtk or kde dialogs.
> [!NOTE]
> On Linux `defaultPath` is not supported when using portal file chooser
> dialogs unless the portal backend is version 4 or higher. You can use `--xdg-portal-required-version`
> [command-line switch](./command-line-switches.md#--xdg-portal-required-versionversion)
> to force gtk or kde dialogs.
### `dialog.showSaveDialogSync([window, ]options)`
@@ -225,8 +234,9 @@ The `window` argument allows the dialog to attach itself to a parent window, mak
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.
> [!NOTE]
> On macOS, using the asynchronous version is recommended to avoid issues when
> expanding and collapsing the dialog.
### `dialog.showMessageBoxSync([window, ]options)`

View File

@@ -9,6 +9,7 @@ The following example shows how to bounce your icon on the dock.
```js
const { app } = require('electron')
app.dock?.bounce()
```
@@ -28,7 +29,8 @@ 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.
> [!NOTE]
> This method can only be used while the app is not focused; when the app is focused it will return -1.
#### `dock.cancelBounce(id)` _macOS_

View File

@@ -12,6 +12,7 @@ control the download item.
```js
// In the main process.
const { BrowserWindow } = require('electron')
const win = new BrowserWindow()
win.webContents.session.on('will-download', (event, item, webContents) => {
// Set the save path, making Electron not to prompt a save dialog.
@@ -115,7 +116,8 @@ Returns `boolean` - Whether the download is paused.
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.
> [!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.
#### `downloadItem.canResume()`
@@ -141,9 +143,10 @@ Returns `boolean` - Whether the download has user gesture.
Returns `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.
> [!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.
#### `downloadItem.getCurrentBytesPerSecond()`
@@ -172,8 +175,9 @@ header.
Returns `string` - 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.
> [!NOTE]
> The following methods are useful specifically to resume a
> `cancelled` item when session is restarted.
#### `downloadItem.getURLChain()`

View File

@@ -104,7 +104,7 @@ you would when running the normal Node.js executable, with the exception of the
These flags are disabled owing to the fact that Electron uses BoringSSL instead of OpenSSL when building Node.js'
`crypto` module, and so will not work as designed.
If the [`runAsNode` fuse](../tutorial/fuses.md#L13) is disabled, `ELECTRON_RUN_AS_NODE` will be ignored.
If the [`runAsNode` fuse](../tutorial/fuses.md#runasnode) is disabled, `ELECTRON_RUN_AS_NODE` will be ignored.
### `ELECTRON_NO_ATTACH_CONSOLE` _Windows_

View File

@@ -77,6 +77,7 @@ extension to be loaded.
```js
const { app, session } = require('electron')
const path = require('node:path')
app.whenReady().then(async () => {
@@ -92,11 +93,13 @@ app.whenReady().then(async () => {
This API does not support loading packed (.crx) extensions.
**Note:** This API cannot be called before the `ready` event of the `app` module
is emitted.
> [!NOTE]
> This API cannot be called before the `ready` event of the `app` module
> is emitted.
**Note:** Loading extensions into in-memory (non-persistent) sessions is not
supported and will throw an error.
> [!NOTE]
> Loading extensions into in-memory (non-persistent) sessions is not
> supported and will throw an error.
#### `extensions.removeExtension(extensionId)`
@@ -104,8 +107,9 @@ supported and will throw an error.
Unloads an extension.
**Note:** This API cannot be called before the `ready` event of the `app` module
is emitted.
> [!NOTE]
> This API cannot be called before the `ready` event of the `app` module
> is emitted.
#### `extensions.getExtension(extensionId)`
@@ -113,12 +117,14 @@ is emitted.
Returns `Extension | null` - The loaded extension with the given ID.
**Note:** This API cannot be called before the `ready` event of the `app` module
is emitted.
> [!NOTE]
> This API cannot be called before the `ready` event of the `app` module
> is emitted.
#### `extensions.getAllExtensions()`
Returns `Extension[]` - A list of all loaded extensions.
**Note:** This API cannot be called before the `ready` event of the `app` module
is emitted.
> [!NOTE]
> This API cannot be called before the `ready` event of the `app` module
> is emitted.

View File

@@ -6,7 +6,8 @@ but it also happens to support some other extension capabilities.
[chrome-extensions-api-index]: https://developer.chrome.com/extensions/api_index
> **Note:** Electron does not support arbitrary Chrome extensions from the
> [!NOTE]
> Electron does not support arbitrary Chrome extensions from the
> store, and it is a **non-goal** of the Electron project to be perfectly
> compatible with Chrome's implementation of Extensions.
@@ -160,7 +161,8 @@ The following methods of `chrome.tabs` are supported:
- `chrome.tabs.update` (partial support)
- supported properties: `url`, `muted`.
> **Note:** In Chrome, passing `-1` as a tab ID signifies the "currently active
> [!NOTE]
> In Chrome, passing `-1` as a tab ID signifies the "currently active
> tab". Since Electron has no such concept, passing `-1` as a tab ID is not
> supported and will raise an error.
@@ -170,6 +172,7 @@ See [official documentation](https://developer.chrome.com/docs/extensions/refere
All features of this API are supported.
> **NOTE:** Electron's [`webRequest`](web-request.md) module takes precedence over `chrome.webRequest` if there are conflicting handlers.
> [!NOTE]
> Electron's [`webRequest`](web-request.md) module takes precedence over `chrome.webRequest` if there are conflicting handlers.
See [official documentation](https://developer.chrome.com/docs/extensions/reference/webRequest) for more information.

View File

@@ -8,13 +8,13 @@ The `globalShortcut` module can register/unregister a global keyboard shortcut
with the operating system so that you can customize the operations for various
shortcuts.
**Note:** The shortcut is global; it will work even if the app does
not have the keyboard focus. This module cannot be used before the `ready`
event of the app module is emitted.
Please also note that it is also possible to use Chromium's
`GlobalShortcutsPortal` implementation, which allows apps to bind global
shortcuts when running within a Wayland session.
> [!NOTE]
> The shortcut is global; it will work even if the app does
> not have the keyboard focus. This module cannot be used before the `ready`
> event of the app module is emitted.
> Please also note that it is also possible to use Chromium's
> `GlobalShortcutsPortal` implementation, which allows apps to bind global
> shortcuts when running within a Wayland session.
```js
const { app, globalShortcut } = require('electron')

66
docs/api/image-view.md Normal file
View File

@@ -0,0 +1,66 @@
# ImageView
> A View that displays an image.
Process: [Main](../glossary.md#main-process)
This module cannot be used until the `ready` event of the `app`
module is emitted.
Useful for showing splash screens that will be swapped for `WebContentsView`s
when the content finishes loading.
Note that `ImageView` is experimental and may be changed or removed in the future.
```js
const { BaseWindow, ImageView, nativeImage, WebContentsView } = require('electron')
const path = require('node:path')
const win = new BaseWindow({ width: 800, height: 600 })
// Create a "splash screen" image to display while the WebContentsView loads
const splashView = new ImageView()
const splashImage = nativeImage.createFromPath(path.join(__dirname, 'loading.png'))
splashView.setImage(splashImage)
win.setContentView(splashView)
const webContentsView = new WebContentsView()
webContentsView.webContents.once('did-finish-load', () => {
// Now that the WebContentsView has loaded, swap out the "splash screen" ImageView
win.setContentView(webContentsView)
})
webContentsView.webContents.loadURL('https://electronjs.org')
```
## Class: ImageView extends `View`
> A View that displays an image.
Process: [Main](../glossary.md#main-process)
`ImageView` inherits from [`View`](view.md).
`ImageView` is an [EventEmitter][event-emitter].
> [!WARNING]
> Electron's built-in classes cannot be subclassed in user code.
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
### `new ImageView()` _Experimental_
Creates an ImageView.
### Instance Methods
The following methods are available on instances of the `ImageView` class, in
addition to those inherited from [View](view.md):
#### `image.setImage(image)` _Experimental_
* `image` NativeImage
Sets the image for this `ImageView`. Note that only image formats supported by
`NativeImage` can be used with an `ImageView`.
[event-emitter]: https://nodejs.org/api/events.html#events_class_eventemitter

View File

@@ -11,6 +11,10 @@ Process: [Main](../glossary.md#main-process)
<!-- TODO(samuelmaddock): refactor doc gen to allow generics to reduce duplication -->
> [!WARNING]
> Electron's built-in classes cannot be subclassed in user code.
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
### Instance Methods
#### `ipcMainServiceWorker.on(channel, listener)`

View File

@@ -156,7 +156,7 @@ If you need to transfer a [`MessagePort`][] to the main process, use [`ipcRender
If you do not need a response to the message, consider using [`ipcRenderer.send`](#ipcrenderersendchannel-args).
> **Note**
> [!NOTE]
> Sending non-standard JavaScript types such as DOM objects or
> special Electron objects will throw an exception.
>
@@ -165,7 +165,7 @@ If you do not need a response to the message, consider using [`ipcRenderer.send`
> 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.
> **Note**
> [!NOTE]
> If the handler in the main process throws an error,
> the promise returned by `invoke` will reject.
> However, the `Error` object in the renderer process
@@ -195,7 +195,8 @@ throw an exception.
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
> [!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).

View File

@@ -6,6 +6,10 @@ Process: [Main](../glossary.md#main-process)
See [`Menu`](menu.md) for examples.
> [!WARNING]
> Electron's built-in classes cannot be subclassed in user code.
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
### `new MenuItem(options)`
* `options` Object
@@ -16,10 +20,16 @@ See [`Menu`](menu.md) for examples.
* `event` [KeyboardEvent](structures/keyboard-event.md)
* `role` string (optional) - 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`, `showSubstitutions`, `toggleSmartQuotes`, `toggleSmartDashes`, `toggleTextReplacement`, `startSpeaking`, `stopSpeaking`, `zoom`, `front`, `appMenu`, `fileMenu`, `editMenu`, `viewMenu`, `shareMenu`, `recentDocuments`, `toggleTabBar`, `selectNextTab`, `selectPreviousTab`, `showAllTabs`, `mergeAllWindows`, `clearRecentDocuments`, `moveTabToNewWindow` or `windowMenu` - Define the action of the menu item, when specified the
`click` property will be ignored. See [roles](#roles).
* `type` string (optional) - Can be `normal`, `separator`, `submenu`, `checkbox` or
`radio`.
* `type` string (optional)
* `normal`
* `separator`
* `submenu`
* `checkbox`
* `radio`
* `header` - Only available on macOS 14 and up.
* `palette` - Only available on macOS 14 and up.
* `label` string (optional)
* `sublabel` string (optional)
* `sublabel` string (optional) _macOS_ - Available in macOS >= 14.4
* `toolTip` string (optional) _macOS_ - Hover text for this menu item.
* `accelerator` [Accelerator](accelerator.md) (optional)
* `icon` ([NativeImage](native-image.md) | string) (optional)
@@ -51,7 +61,8 @@ See [`Menu`](menu.md) for examples.
the placement of their containing group after the containing group of the item
with the specified id.
**Note:** `acceleratorWorksWhenHidden` is specified as being macOS-only because accelerators always work when items are hidden on Windows and Linux. The option is exposed to users to give them the option to turn it off, as this is possible in native macOS development.
> [!NOTE]
> `acceleratorWorksWhenHidden` is specified as being macOS-only because accelerators always work when items are hidden on Windows and Linux. The option is exposed to users to give them the option to turn it off, as this is possible in native macOS development.
### Roles
@@ -125,7 +136,8 @@ When specifying a `role` on macOS, `label` and `accelerator` are the only
options that will affect the menu item. All other options will be ignored.
Lowercase `role`, e.g. `toggledevtools`, is still supported.
**Note:** The `enabled` and `visibility` properties are not available for top-level menu items in the tray on macOS.
> [!NOTE]
> The `enabled` and `visibility` properties are not available for top-level menu items in the tray on macOS.
### Instance Properties
@@ -156,7 +168,10 @@ item's submenu, if present.
#### `menuItem.type`
A `string` indicating the type of the item. Can be `normal`, `separator`, `submenu`, `checkbox` or `radio`.
A `string` indicating the type of the item. Can be `normal`, `separator`, `submenu`, `checkbox`, `radio`, `header` or `palette`.
> [!NOTE]
> `header` and `palette` are only available on macOS 14 and up.
#### `menuItem.role`
@@ -170,7 +185,8 @@ An `Accelerator` (optional) indicating the item's accelerator, if set.
An `Accelerator | null` indicating the item's [user-assigned accelerator](https://developer.apple.com/documentation/appkit/nsmenuitem/1514850-userkeyequivalent?language=objc) 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`.
> [!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`.
#### `menuItem.icon`

View File

@@ -6,6 +6,10 @@
Process: [Main](../glossary.md#main-process)
> [!WARNING]
> Electron's built-in classes cannot be subclassed in user code.
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
### `new Menu()`
Creates a new menu.
@@ -32,16 +36,18 @@ In order to escape the `&` character in an item name, add a proceeding `&`. For
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`.
> [!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`.
#### `Menu.getApplicationMenu()`
Returns `Menu | null` - 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](#instance-properties) can still
be dynamically modified.
> [!NOTE]
> The returned `Menu` instance doesn't support dynamic addition or
> removal of menu items. [Instance properties](#instance-properties) can still
> be dynamically modified.
#### `Menu.sendActionToFirstResponder(action)` _macOS_
@@ -119,8 +125,9 @@ Inserts the `menuItem` to the `pos` position of the menu.
Objects created with `new Menu` or returned by `Menu.buildFromTemplate` emit the following events:
**Note:** Some events are only available on specific operating systems and are
labeled as such.
> [!NOTE]
> Some events are only available on specific operating systems and are
> labeled as such.
#### Event: 'menu-will-show'
@@ -329,6 +336,27 @@ name, no matter what label you set. To change it, modify your app bundle's
[About Information Property List Files][AboutInformationPropertyListFiles]
for more information.
### Menu Sublabels
Menu sublabels, or [subtitles](https://developer.apple.com/documentation/appkit/nsmenuitem/subtitle?language=objc), can be added to menu items using the `sublabel` option. Below is an example based on the renderer example above:
```js @ts-expect-error=[12]
// main
ipcMain.on('show-context-menu', (event) => {
const template = [
{
label: 'Menu Item 1',
sublabel: 'Subtitle 1',
click: () => { event.sender.send('context-menu-command', 'menu-item-1') }
},
{ type: 'separator' },
{ label: 'Menu Item 2', sublabel: 'Subtitle 2', type: 'checkbox', checked: true }
]
const menu = Menu.buildFromTemplate(template)
menu.popup({ window: BrowserWindow.fromWebContents(event.sender) })
})
```
## Setting Menu for Specific Browser Window (_Linux_ _Windows_)
The [`setMenu` method][setMenu] of browser windows can set the menu of certain

View File

@@ -15,9 +15,12 @@ Process: [Main](../glossary.md#main-process)
Example:
<!-- eslint-disable import/order -->
```js
// Main process
const { BrowserWindow, MessageChannelMain } = require('electron')
const w = new BrowserWindow()
const { port1, port2 } = new MessageChannelMain()
w.webContents.postMessage('port', null, [port2])
@@ -25,6 +28,7 @@ port1.postMessage({ some: 'message' })
// Renderer process
const { ipcRenderer } = require('electron')
ipcRenderer.on('port', (e) => {
// e.ports is a list of ports sent along with this message
e.ports[0].onmessage = (messageEvent) => {
@@ -33,6 +37,10 @@ ipcRenderer.on('port', (e) => {
})
```
> [!WARNING]
> Electron's built-in classes cannot be subclassed in user code.
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
### Instance Properties
#### `channel.port1`

View File

@@ -86,6 +86,7 @@ images/
```js title='Main Process'
const { Tray } = require('electron')
const appTray = new Tray('/Users/somebody/images/icon.png')
```
@@ -134,7 +135,8 @@ Creates an empty `NativeImage` instance.
Returns `Promise<NativeImage>` - fulfilled with the file's thumbnail preview image, which is a [NativeImage](native-image.md).
Note: The Windows implementation will ignore `size.height` and scale the height according to `size.width`.
> [!NOTE]
> Windows implementation will ignore `size.height` and scale the height according to `size.width`.
### `nativeImage.createFromPath(path)`

View File

@@ -17,8 +17,9 @@ app.whenReady().then(async () => {
See [`--log-net-log`](command-line-switches.md#--log-net-logpath) to log network events throughout the app's lifecycle.
**Note:** All methods unless specified can only be used after the `ready` event
of the `app` module gets emitted.
> [!NOTE]
> All methods unless specified can only be used after the `ready` event
> of the `app` module gets emitted.
## Methods

View File

@@ -28,6 +28,7 @@ Example usage:
```js
const { app } = require('electron')
app.whenReady().then(() => {
const { net } = require('electron')
const request = net.request('https://github.com')
@@ -117,8 +118,9 @@ protocol.handle('https', (req) => {
})
```
Note: in the [utility process](../glossary.md#utility-process) custom protocols
are not supported.
> [!NOTE]
> In the [utility process](../glossary.md#utility-process), custom protocols
> are not supported.
### `net.isOnline()`

View File

@@ -4,12 +4,9 @@
Process: [Main](../glossary.md#main-process)
:::info Renderer process notifications
If you want to show notifications from a renderer process you should use the
[web Notifications API](../tutorial/notifications.md)
:::
> [!NOTE]
> If you want to show notifications from a renderer process you should use the
> [web Notifications API](../tutorial/notifications.md)
## Class: Notification
@@ -21,6 +18,10 @@ Process: [Main](../glossary.md#main-process)
It creates a new `Notification` with native properties as set by the `options`.
> [!WARNING]
> Electron's built-in classes cannot be subclassed in user code.
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
### Static Methods
The `Notification` class has the following static methods:

View File

@@ -33,10 +33,11 @@ Returns `Integer` - 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`.
> [!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`

View File

@@ -233,7 +233,8 @@ console.log(version)
// On Linux -> '4.15.0-45-generic'
```
**Note:** It returns the actual operating system version instead of kernel version on macOS unlike `os.release()`.
> [!NOTE]
> It returns the actual operating system version instead of kernel version on macOS unlike `os.release()`.
### `process.takeHeapSnapshot(filePath)`

View File

@@ -9,6 +9,7 @@ An example of implementing a protocol that has the same effect as the
```js
const { app, protocol, net } = require('electron')
const path = require('node:path')
const url = require('node:url')
@@ -20,8 +21,9 @@ app.whenReady().then(() => {
})
```
**Note:** All methods unless specified can only be used after the `ready` event
of the `app` module gets emitted.
> [!NOTE]
> All methods unless specified can only be used after the `ready` event
> of the `app` module gets emitted.
## Using `protocol` with a custom `partition` or `session`
@@ -37,8 +39,9 @@ to register it to that session explicitly.
```js
const { app, BrowserWindow, net, protocol, session } = require('electron')
const path = require('node:path')
const url = require('url')
const url = require('node:url')
app.whenReady().then(() => {
const partition = 'persist:example'
@@ -61,8 +64,9 @@ The `protocol` module has the following methods:
* `customSchemes` [CustomScheme[]](structures/custom-scheme.md)
**Note:** This method can only be used before the `ready` event of the `app`
module gets emitted and can be called only once.
> [!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, streaming
@@ -74,6 +78,7 @@ Policy:
```js
const { protocol } = require('electron')
protocol.registerSchemesAsPrivileged([
{ scheme: 'foo', privileges: { bypassCSP: true } }
])
@@ -126,8 +131,9 @@ Example:
```js
const { app, net, protocol } = require('electron')
const path = require('node:path')
const { pathToFileURL } = require('url')
const { pathToFileURL } = require('node:url')
protocol.registerSchemesAsPrivileged([
{
@@ -328,7 +334,8 @@ Example:
```js
const { protocol } = require('electron')
const { PassThrough } = require('stream')
const { PassThrough } = require('node:stream')
function createStream (text) {
const rv = new PassThrough() // PassThrough is also a Readable stream

View File

@@ -73,5 +73,6 @@ command line flag is provided `--password-store="basic"`.
is provided `--password-store="kwallet"`.
* `kwallet5` - When the desktop session is `kde5` or if the following command line flag
is provided `--password-store="kwallet5"`.
* `kwallet6` - When the desktop session is `kde6`.
* `kwallet6` - When the desktop session is `kde6` or if the following command line flag
is provided `--password-store="kwallet6"`.
* `unknown` - When the function is called before app has emitted the `ready` event.

View File

@@ -9,8 +9,9 @@ module is emitted.
`screen` is an [EventEmitter][event-emitter].
**Note:** In the renderer / DevTools, `window.screen` is a reserved DOM
property, so writing `let { screen } = require('electron')` will not work.
> [!NOTE]
> In the renderer / DevTools, `window.screen` is a reserved DOM
> property, so writing `let { screen } = require('electron')` will not work.
An example of creating a window that fills the whole screen:
@@ -57,6 +58,14 @@ app.whenReady().then(() => {
})
```
> [!NOTE]
> Screen coordinates used by this module are [`Point`](structures/point.md) structures.
> There are two kinds of coordinates available to the process:
>
> * **Physical screen points** are raw hardware pixels on a display.
> * **Device-independent pixel (DIP) points** are virtualized screen points scaled based on the DPI
> (dots per inch) of the display.
## Events
The `screen` module emits the following events:
@@ -101,7 +110,8 @@ Returns [`Point`](structures/point.md)
The current absolute position of the mouse pointer.
**Note:** The return value is a DIP point, not a screen physical point.
> [!NOTE]
> The return value is a DIP point, not a screen physical point.
### `screen.getPrimaryDisplay()`

View File

@@ -109,6 +109,7 @@ Starts the service worker or does nothing if already running.
```js
const { app, session } = require('electron')
const { serviceWorkers } = session.defaultSession
// Collect service workers scopes

View File

@@ -79,6 +79,7 @@ You can create a `Session` object in the `session` module:
```js
const { session } = require('electron')
const ses = session.fromPartition('persist:name')
console.log(ses.getUserAgent())
```
@@ -100,8 +101,9 @@ Emitted when Electron is about to download `item` in `webContents`.
Calling `event.preventDefault()` will cancel the download and `item` will not be
available from next tick of the process.
```js @ts-expect-error=[4]
```js @ts-expect-error=[5]
const { session } = require('electron')
session.defaultSession.on('will-download', (event, item, webContents) => {
event.preventDefault()
require('got')(item.getURL()).then((response) => {
@@ -762,7 +764,8 @@ Preconnects the given number of sockets to an origin.
Returns `Promise<void>` - Resolves when all connections are closed.
**Note:** It will terminate / fail all requests currently in flight.
> [!NOTE]
> It will terminate / fail all requests currently in flight.
#### `ses.fetch(input[, init])`
@@ -851,6 +854,7 @@ verify proc.
```js
const { BrowserWindow } = require('electron')
const win = new BrowserWindow()
win.webContents.session.setCertificateVerifyProc((request, callback) => {
@@ -902,6 +906,7 @@ Most web APIs do a permission check and then make a permission request if the ch
```js
const { session } = require('electron')
session.fromPartition('some-partition').setPermissionRequestHandler((webContents, permission, callback) => {
if (webContents.getURL() === 'some-host' && permission === 'notifications') {
return callback(false) // denied.
@@ -951,7 +956,9 @@ To clear the handler, call `setPermissionCheckHandler(null)`.
```js
const { session } = require('electron')
const url = require('url')
const url = require('node:url')
session.fromPartition('some-partition').setPermissionCheckHandler((webContents, permission, requestingOrigin) => {
if (new URL(requestingOrigin).hostname === 'some-host' && permission === 'notifications') {
return true // granted
@@ -1188,6 +1195,7 @@ automatically. To clear the handler, call `setBluetoothPairingHandler(null)`.
```js
const { app, BrowserWindow, session } = require('electron')
const path = require('node:path')
function createWindow () {
@@ -1305,8 +1313,9 @@ Initiates a download of the resource at `url`.
The API will generate a [DownloadItem](download-item.md) that can be accessed
with the [will-download](#event-will-download) event.
**Note:** This does not perform any security checks that relate to a page's origin,
unlike [`webContents.downloadURL`](web-contents.md#contentsdownloadurlurl-options).
> [!NOTE]
> This does not perform any security checks that relate to a page's origin,
> unlike [`webContents.downloadURL`](web-contents.md#contentsdownloadurlurl-options).
#### `ses.createInterruptedDownload(options)`
@@ -1434,7 +1443,8 @@ The built in spellchecker does not automatically detect what language a user is
spell checker to correctly check their words you must call this API with an array of language codes. You can
get the list of supported language codes with the `ses.availableSpellCheckerLanguages` property.
**Note:** On macOS the OS spellchecker is used and will detect your language automatically. This API is a no-op on macOS.
> [!NOTE]
> On macOS, the OS spellchecker is used and will detect your language automatically. This API is a no-op on macOS.
#### `ses.getSpellCheckerLanguages()`
@@ -1442,7 +1452,8 @@ 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. On macOS, this API will return whichever languages have been configured by the OS.
> [!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)`
@@ -1460,7 +1471,8 @@ If the files present in `hunspell_dictionaries.zip` are available at `https://ex
then you should call this api with `ses.setSpellCheckerDictionaryDownloadURL('https://example.com/dictionaries/')`. Please
note the trailing slash. The URL to the dictionaries is formed as `${url}${filename}`.
**Note:** On macOS the OS spellchecker is used and therefore we do not download any dictionary files. This API is a no-op on macOS.
> [!NOTE]
> On macOS, the OS spellchecker is used and therefore we do not download any dictionary files. This API is a no-op on macOS.
#### `ses.listWordsInSpellCheckerDictionary()`
@@ -1474,7 +1486,8 @@ Resolves when the full dictionary is loaded from disk.
Returns `boolean` - Whether the word was successfully written to the custom dictionary. This API
will not work on non-persistent (in-memory) sessions.
**Note:** On macOS and Windows 10 this word will be written to the OS custom dictionary as well
> [!NOTE]
> On macOS and Windows, this word will be written to the OS custom dictionary as well.
#### `ses.removeWordFromSpellCheckerDictionary(word)`
@@ -1483,7 +1496,8 @@ will not work on non-persistent (in-memory) sessions.
Returns `boolean` - Whether the word was successfully removed from the custom dictionary. This API
will not work on non-persistent (in-memory) sessions.
**Note:** On macOS and Windows 10 this word will be removed from the OS custom dictionary as well
> [!NOTE]
> On macOS and Windows, this word will be removed from the OS custom dictionary as well.
#### `ses.loadExtension(path[, options])` _Deprecated_
@@ -1511,6 +1525,7 @@ extension to be loaded.
```js
const { app, session } = require('electron')
const path = require('node:path')
app.whenReady().then(async () => {
@@ -1526,11 +1541,13 @@ app.whenReady().then(async () => {
This API does not support loading packed (.crx) extensions.
**Note:** This API cannot be called before the `ready` event of the `app` module
is emitted.
> [!NOTE]
> This API cannot be called before the `ready` event of the `app` module
> is emitted.
**Note:** Loading extensions into in-memory (non-persistent) sessions is not
supported and will throw an error.
> [!NOTE]
> Loading extensions into in-memory (non-persistent) sessions is not
> supported and will throw an error.
**Deprecated:** Use the new `ses.extensions.loadExtension` API.
@@ -1540,8 +1557,9 @@ supported and will throw an error.
Unloads an extension.
**Note:** This API cannot be called before the `ready` event of the `app` module
is emitted.
> [!NOTE]
> This API cannot be called before the `ready` event of the `app` module
> is emitted.
**Deprecated:** Use the new `ses.extensions.removeExtension` API.
@@ -1551,8 +1569,9 @@ is emitted.
Returns `Extension | null` - The loaded extension with the given ID.
**Note:** This API cannot be called before the `ready` event of the `app` module
is emitted.
> [!NOTE]
> This API cannot be called before the `ready` event of the `app` module
> is emitted.
**Deprecated:** Use the new `ses.extensions.getExtension` API.
@@ -1560,8 +1579,9 @@ is emitted.
Returns `Extension[]` - A list of all loaded extensions.
**Note:** This API cannot be called before the `ready` event of the `app` module
is emitted.
> [!NOTE]
> This API cannot be called before the `ready` event of the `app` module
> is emitted.
**Deprecated:** Use the new `ses.extensions.getAllExtensions` API.
@@ -1599,9 +1619,11 @@ Clears various different types of data.
This method clears more types of data and is more thorough than the
`clearStorageData` method.
**Note:** Cookies are stored at a broader scope than origins. When removing cookies and filtering by `origins` (or `excludeOrigins`), the cookies will be removed at the [registrable domain](https://url.spec.whatwg.org/#host-registrable-domain) level. For example, clearing cookies for the origin `https://really.specific.origin.example.com/` will end up clearing all cookies for `example.com`. Clearing cookies for the origin `https://my.website.example.co.uk/` will end up clearing all cookies for `example.co.uk`.
> [!NOTE]
> Cookies are stored at a broader scope than origins. When removing cookies and filtering by `origins` (or `excludeOrigins`), the cookies will be removed at the [registrable domain](https://url.spec.whatwg.org/#host-registrable-domain) level. For example, clearing cookies for the origin `https://really.specific.origin.example.com/` will end up clearing all cookies for `example.com`. Clearing cookies for the origin `https://my.website.example.co.uk/` will end up clearing all cookies for `example.co.uk`.
**Note:** Clearing cache data will also clear the shared dictionary cache. This means that any dictionaries used for compression may be reloaded after clearing the cache. If you wish to clear the shared dictionary cache but leave other cached data intact, you may want to use the `clearSharedDictionaryCache` method.
> [!NOTE]
> Clearing cache data will also clear the shared dictionary cache. This means that any dictionaries used for compression may be reloaded after clearing the cache. If you wish to clear the shared dictionary cache but leave other cached data intact, you may want to use the `clearSharedDictionaryCache` method.
For more information, refer to Chromium's [`BrowsingDataRemover` interface][browsing-data-remover].
@@ -1645,6 +1667,7 @@ A [`Protocol`](protocol.md) object for this session.
```js
const { app, session } = require('electron')
const path = require('node:path')
app.whenReady().then(() => {

View File

@@ -13,6 +13,10 @@ For including the share menu as a submenu of other menus, please use the
Process: [Main](../glossary.md#main-process)
> [!WARNING]
> Electron's built-in classes cannot be subclassed in user code.
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
### `new ShareMenu(sharingItem)`
* `sharingItem` SharingItem - The item to share.

View File

@@ -14,7 +14,8 @@ const { shell } = require('electron')
shell.openExternal('https://github.com')
```
**Note:** While the `shell` module can be used in the renderer process, it will not function in a sandboxed renderer.
> [!WARNING]
> While the `shell` module can be used in the renderer process, it will not function in a sandboxed renderer.
## Methods

View File

@@ -95,6 +95,7 @@
* `color` String (optional) _Windows_ _Linux_ - The CSS color of the Window Controls Overlay when enabled. Default is the system color.
* `symbolColor` String (optional) _Windows_ _Linux_ - The CSS color of the symbols on the Window Controls Overlay when enabled. Default is the system color.
* `height` Integer (optional) - The height of the title bar and Window Controls Overlay in pixels. Default is system height.
* `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

View File

@@ -0,0 +1,195 @@
# ColorSpace Object
* `primaries` string - The color primaries of the color space. Can be one of the following values:
* `bt709` - BT709 primaries (also used for sRGB)
* `bt470m` - BT470M primaries
* `bt470bg` - BT470BG primaries
* `smpte170m` - SMPTE170M primaries
* `smpte240m` - SMPTE240M primaries
* `film` - Film primaries
* `bt2020` - BT2020 primaries
* `smptest428-1` - SMPTEST428-1 primaries
* `smptest431-2` - SMPTEST431-2 primaries
* `p3` - P3 primaries
* `xyz-d50` - XYZ D50 primaries
* `adobe-rgb` - Adobe RGB primaries
* `apple-generic-rgb` - Apple Generic RGB primaries
* `wide-gamut-color-spin` - Wide Gamut Color Spin primaries
* `ebu-3213-e` - EBU 3213-E primaries
* `custom` - Custom primaries
* `invalid` - Invalid primaries
* `transfer` string - The transfer function of the color space. Can be one of the following values:
* `bt709` - BT709 transfer function
* `bt709-apple` - BT709 Apple transfer function
* `gamma18` - Gamma 1.8 transfer function
* `gamma22` - Gamma 2.2 transfer function
* `gamma24` - Gamma 2.4 transfer function
* `gamma28` - Gamma 2.8 transfer function
* `smpte170m` - SMPTE170M transfer function
* `smpte240m` - SMPTE240M transfer function
* `linear` - Linear transfer function
* `log` - Log transfer function
* `log-sqrt` - Log Square Root transfer function
* `iec61966-2-4` - IEC61966-2-4 transfer function
* `bt1361-ecg` - BT1361 ECG transfer function
* `srgb` - sRGB transfer function
* `bt2020-10` - BT2020-10 transfer function
* `bt2020-12` - BT2020-12 transfer function
* `pq` - PQ (Perceptual Quantizer) transfer function
* `smptest428-1` - SMPTEST428-1 transfer function
* `hlg` - HLG (Hybrid Log-Gamma) transfer function
* `srgb-hdr` - sRGB HDR transfer function
* `linear-hdr` - Linear HDR transfer function
* `custom` - Custom transfer function
* `custom-hdr` - Custom HDR transfer function
* `scrgb-linear-80-nits` - scRGB Linear 80 nits transfer function
* `invalid` - Invalid transfer function
* `matrix` string - The color matrix of the color space. Can be one of the following values:
* `rgb` - RGB matrix
* `bt709` - BT709 matrix
* `fcc` - FCC matrix
* `bt470bg` - BT470BG matrix
* `smpte170m` - SMPTE170M matrix
* `smpte240m` - SMPTE240M matrix
* `ycocg` - YCoCg matrix
* `bt2020-ncl` - BT2020 NCL matrix
* `ydzdx` - YDzDx matrix
* `gbr` - GBR matrix
* `invalid` - Invalid matrix
* `range` string - The color range of the color space. Can be one of the following values:
* `limited` - Limited color range (RGB values ranging from 16 to 235)
* `full` - Full color range (RGB values from 0 to 255)
* `derived` - Range defined by the transfer function and matrix
* `invalid` - Invalid range
## Common `ColorSpace` definitions
### Standard Color Spaces
**sRGB**:
```js
const cs = {
primaries: 'bt709',
transfer: 'srgb',
matrix: 'rgb',
range: 'full'
}
```
**Display P3**:
```js
const cs = {
primaries: 'p3',
transfer: 'srgb',
matrix: 'rgb',
range: 'full'
}
```
**XYZ D50**:
```js
const cs = {
primaries: 'xyz-d50',
transfer: 'linear',
matrix: 'rgb',
range: 'full'
}
```
### HDR Color Spaces
**Extended sRGB** (extends sRGB to all real values):
```js
const cs = {
primaries: 'bt709',
transfer: 'srgb-hdr',
matrix: 'rgb',
range: 'full'
}
```
**scRGB Linear** (linear transfer function for all real values):
```js
const cs = {
primaries: 'bt709',
transfer: 'linear-hdr',
matrix: 'rgb',
range: 'full'
}
```
**scRGB Linear 80 Nits** (with an SDR white level of 80 nits):
```js
const cs = {
primaries: 'bt709',
transfer: 'scrgb-linear-80-nits',
matrix: 'rgb',
range: 'full'
}
```
**HDR10** (BT.2020 primaries with PQ transfer function):
```js
const cs = {
primaries: 'bt2020',
transfer: 'pq',
matrix: 'rgb',
range: 'full'
}
```
**HLG** (BT.2020 primaries with HLG transfer function):
```js
const cs = {
primaries: 'bt2020',
transfer: 'hlg',
matrix: 'rgb',
range: 'full'
}
```
### Video Color Spaces
**Rec. 601** (SDTV):
```js
const cs = {
primaries: 'smpte170m',
transfer: 'smpte170m',
matrix: 'smpte170m',
range: 'limited'
}
```
**Rec. 709** (HDTV):
```js
const cs = {
primaries: 'bt709',
transfer: 'bt709',
matrix: 'bt709',
range: 'limited'
}
```
**JPEG** (typical color space for JPEG images):
```js
const cs = {
primaries: 'bt709',
transfer: 'srgb',
matrix: 'smpte170m',
range: 'full'
}
```

View File

@@ -6,3 +6,11 @@
* `productId` Integer - The USB product ID.
* `serialNumber` string (optional) - The USB device serial number.
* `guid` string (optional) - Unique identifier for the HID interface. A device may have multiple HID interfaces.
* `collections` Object[] - an array of report formats. See [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/API/HIDDevice/collections) for more.
* `usage` Integer - An integer representing the usage ID component of the HID usage associated with this collection.
* `usagePage` Integer - An integer representing the usage page component of the HID usage associated with this collection.
* `type` Integer - An 8-bit value representing the collection type, which describes a different relationship between the grouped items.
* `children` Object[] - An array of sub-collections which takes the same format as a top-level collection.
* `inputReports` Object[] - An array of inputReport items which represent individual input reports described in this collection.
* `outputReports` Object[] - An array of outputReport items which represent individual output reports described in this collection.
* `featureReports` Object[] - An array of featureReport items which represent individual feature reports described in this collection.

View File

@@ -15,11 +15,13 @@
* `items` JumpListItem[] (optional) - Array of [`JumpListItem`](jump-list-item.md) objects if `type` is `tasks` or
`custom`, otherwise it should be omitted.
**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]
> 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:** 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.
> [!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.

View File

@@ -3,6 +3,7 @@
* `x` number
* `y` number
**Note:** Both `x` and `y` must be whole integers, when providing a point object
as input to an Electron API we will automatically round your `x` and `y` values
to the nearest whole integer.
> [!NOTE]
> Both `x` and `y` must be whole integers, when providing a point object
> as input to an Electron API we will automatically round your `x` and `y` values
> to the nearest whole integer.

View File

@@ -12,6 +12,8 @@ The number represented by `status` means different things on different platforms
Below is an example of some of the additional options that may be set which
may be different on each platform.
<!-- eslint-skip -->
```js
{
name: 'Austin_4th_Floor_Printer___C02XK13BJHD4',

View File

@@ -26,6 +26,8 @@
An example TraceConfig that roughly matches what Chrome DevTools records:
<!-- eslint-skip -->
```js
{
recording_mode: 'record-until-full',

View File

@@ -1,17 +1,35 @@
# USBDevice Object
* `configuration` Object (optional) - A [USBConfiguration](https://developer.mozilla.org/en-US/docs/Web/API/USBConfiguration) object containing information about the currently selected configuration of a USB device.
* `configurationValue` Integer - the configuration value of this configuration.
* `configurationName` string - the name provided by the device to describe this configuration.
* `interfaces` Object[] - An array of [USBInterface](https://developer.mozilla.org/en-US/docs/Web/API/USBInterface) objects containing information about an interface provided by the USB device.
* `interfaceNumber` Integer - the interface number of this interface.
* `alternate` Object - the currently selected alternative configuration of this interface.
* `alternateSetting` Integer - the alternate setting number of this interface.
* `interfaceClass` Integer - the class of this interface. See [USB.org](https://www.usb.org/defined-class-codes) for class code descriptions.
* `interfaceSubclass` Integer - the subclass of this interface.
* `interfaceProtocol` Integer - the protocol supported by this interface.
* `interfaceName` string (optional) - the name of the interface, if one is provided by the device.
* `endpoints` Object[] - an array containing instances of the [USBEndpoint interface](https://developer.mozilla.org/en-US/docs/Web/API/USBEndpoint) describing each of the endpoints that are part of this interface.
* `endpointNumber` Integer - this endpoint's "endpoint number" which is a value from 1 to 15.
* `direction` string - the direction in which this endpoint transfers data - can be either 'in' or 'out'.
* `type` string - the type of this endpoint - can be either 'bulk', 'interrupt', or 'isochronous'.
* `packetSize` Integer - the size of the packets that data sent through this endpoint will be divided into.
* `alternates` Object[] - an array containing instances of the [USBAlternateInterface](https://developer.mozilla.org/en-US/docs/Web/API/USBAlternateInterface) interface describing each of the alternative configurations possible for this interface.
* `configurations` Object[] - An array of [USBConfiguration](https://developer.mozilla.org/en-US/docs/Web/API/USBConfiguration) interfaces for controlling a paired USB device.
* `deviceClass` Integer - The device class for the communication interface supported by the device.
* `deviceId` string - Unique identifier for the device.
* `vendorId` Integer - The USB vendor ID.
* `productId` Integer - The USB product ID.
* `productName` string (optional) - Name of the device.
* `serialNumber` string (optional) - The USB device serial number.
* `manufacturerName` string (optional) - The manufacturer name of the device.
* `usbVersionMajor` Integer - The USB protocol major version supported by the device
* `usbVersionMinor` Integer - The USB protocol minor version supported by the device
* `usbVersionSubminor` Integer - The USB protocol subminor version supported by the device
* `deviceClass` Integer - The device class for the communication interface supported by the device
* `deviceSubclass` Integer - The device subclass for the communication interface supported by the device
* `deviceProtocol` Integer - The device protocol for the communication interface supported by the device
* `deviceProtocol` Integer - The device protocol for the communication interface supported by the device.
* `deviceSubclass` Integer - The device subclass for the communication interface supported by the device.
* `deviceVersionMajor` Integer - The major version number of the device as defined by the device manufacturer.
* `deviceVersionMinor` Integer - The minor version number of the device as defined by the device manufacturer.
* `deviceVersionSubminor` Integer - The subminor version number of the device as defined by the device manufacturer.
* `manufacturerName` string (optional) - The manufacturer name of the device.
* `productId` Integer - The USB product ID.
* `productName` string (optional) - Name of the device.
* `serialNumber` string (optional) - The USB device serial number.
* `usbVersionMajor` Integer - The USB protocol major version supported by the device.
* `usbVersionMinor` Integer - The USB protocol minor version supported by the device.
* `usbVersionSubminor` Integer - The USB protocol subminor version supported by the device.
* `vendorId` Integer - The USB vendor ID.

View File

@@ -6,6 +6,7 @@ Process: [Main](../glossary.md#main-process), [Utility](../glossary.md#utility-p
```js
const { systemPreferences } = require('electron')
console.log(systemPreferences.getEffectiveAppearance())
```

View File

@@ -4,8 +4,9 @@
> from Chromium at the space indicated by the proxy. By default, this proxy is added
> to each TouchBar at the end of the input. For more information, see the AppKit docs on
> [NSTouchBarItemIdentifierOtherItemsProxy](https://developer.apple.com/documentation/appkit/nstouchbaritemidentifierotheritemsproxy)
>
> Note: Only one instance of this class can be added per TouchBar.
> [!NOTE]
> Only one instance of this class can be added per TouchBar.
Process: [Main](../glossary.md#main-process)<br />
_This class is not exported from the `'electron'` module. It is only available as a return value of other methods in the Electron API._

View File

@@ -1,5 +1,9 @@
# TouchBar
> [!WARNING]
> Electron's built-in classes cannot be subclassed in user code.
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
## Class: TouchBar
> Create TouchBar layouts for native macOS applications
@@ -15,12 +19,14 @@ Process: [Main](../glossary.md#main-process)
Creates a new touch bar with the specified items. Use
`BrowserWindow.setTouchBar` to add the `TouchBar` to a window.
**Note:** The TouchBar API is currently experimental and may change or be
removed in future Electron releases.
> [!NOTE]
> The TouchBar API is currently experimental and may change or be
> removed in future Electron releases.
**Tip:** If you don't have a MacBook with Touch Bar, you can use
[Touch Bar Simulator](https://github.com/sindresorhus/touch-bar-simulator)
to test Touch Bar usage in your app.
> [!TIP]
> If you don't have a MacBook with Touch Bar, you can use
> [Touch Bar Simulator](https://github.com/sindresorhus/touch-bar-simulator)
> to test Touch Bar usage in your app.
### Static Properties

View File

@@ -25,6 +25,10 @@ app.whenReady().then(() => {
})
```
> [!WARNING]
> Electron's built-in classes cannot be subclassed in user code.
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
**Platform Considerations**
**Linux**
@@ -176,7 +180,8 @@ Returns:
Emitted when the mouse is released from clicking the tray icon.
Note: This will not be emitted if you have set a context menu for your Tray using `tray.setContextMenu`, as a result of macOS-level constraints.
> [!NOTE]
> This will not be emitted if you have set a context menu for your Tray using `tray.setContextMenu`, as a result of macOS-level constraints.
#### Event: 'mouse-down' _macOS_

View File

@@ -44,7 +44,8 @@ Process: [Main](../glossary.md#main-process)<br />
Returns [`UtilityProcess`](utility-process.md#class-utilityprocess)
**Note:** `utilityProcess.fork` can only be called after the `ready` event has been emitted on `App`.
> [!NOTE]
> `utilityProcess.fork` can only be called after the `ready` event has been emitted on `App`.
## Class: UtilityProcess
@@ -108,7 +109,8 @@ child.on('exit', () => {
})
```
**Note:** You can use the `pid` to determine if the process is currently running.
> [!NOTE]
> You can use the `pid` to determine if the process is currently running.
#### `child.stdout`

View File

@@ -9,6 +9,7 @@ module is emitted.
```js
const { BaseWindow, View } = require('electron')
const win = new BaseWindow()
const view = new View()
@@ -25,6 +26,10 @@ Process: [Main](../glossary.md#main-process)
`View` is an [EventEmitter][event-emitter].
> [!WARNING]
> Electron's built-in classes cannot be subclassed in user code.
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
### `new View()`
Creates a new `View`.
@@ -94,13 +99,15 @@ Examples of valid `color` values:
* 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_ `RRGGBBAA` or `RGB`.
> [!NOTE]
> Hex format with alpha takes `AARRGGBB` or `ARGB`, _not_ `RRGGBBAA` or `RGB`.
#### `view.setBorderRadius(radius)`
* `radius` Integer - Border radius size in pixels.
**Note:** The area cutout of the view's border still captures clicks.
> [!NOTE]
> The area cutout of the view's border still captures clicks.
#### `view.setVisible(visible)`

View File

@@ -9,6 +9,7 @@ module is emitted.
```js
const { BaseWindow, WebContentsView } = require('electron')
const win = new BaseWindow({ width: 800, height: 400 })
const view1 = new WebContentsView()
@@ -32,6 +33,10 @@ Process: [Main](../glossary.md#main-process)
`WebContentsView` is an [EventEmitter][event-emitter].
> [!WARNING]
> Electron's built-in classes cannot be subclassed in user code.
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
### `new WebContentsView([options])`
* `options` Object (optional)
@@ -52,6 +57,7 @@ Use this to interact with the `WebContents`, for instance to load a URL.
```js
const { WebContentsView } = require('electron')
const view = new WebContentsView()
view.webContents.loadURL('https://electronjs.org/')
```

View File

@@ -55,6 +55,7 @@ These methods can be accessed from the `webContents` module:
```js
const { webContents } = require('electron')
console.log(webContents)
```
@@ -446,6 +447,7 @@ and allow the page to be unloaded.
```js
const { BrowserWindow, dialog } = require('electron')
const win = new BrowserWindow({ width: 800, height: 600 })
win.webContents.on('will-prevent-unload', (event) => {
const choice = dialog.showMessageBoxSync(win, {
@@ -463,7 +465,8 @@ win.webContents.on('will-prevent-unload', (event) => {
})
```
**Note:** This will be emitted for `BrowserViews` but will _not_ be respected - this is because we have chosen not to tie the `BrowserView` lifecycle to its owning BrowserWindow should one exist per the [specification](https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeunload_event).
> [!NOTE]
> This will be emitted for `BrowserViews` but will _not_ be respected - this is because we have chosen not to tie the `BrowserView` lifecycle to its owning BrowserWindow should one exist per the [specification](https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeunload_event).
#### Event: 'render-process-gone'
@@ -533,14 +536,55 @@ To only prevent the menu shortcuts, use
[`setIgnoreMenuShortcuts`](#contentssetignoremenushortcutsignore):
```js
const { BrowserWindow } = require('electron')
const { app, BrowserWindow } = require('electron')
const win = new BrowserWindow({ width: 800, height: 600 })
app.whenReady().then(() => {
const win = new BrowserWindow({ width: 800, height: 600 })
win.webContents.on('before-input-event', (event, input) => {
// For example, only enable application menu keyboard shortcuts when
// Ctrl/Cmd are down.
win.webContents.setIgnoreMenuShortcuts(!input.control && !input.meta)
win.webContents.on('before-input-event', (event, input) => {
// Enable application menu keyboard shortcuts when Ctrl/Cmd are down.
win.webContents.setIgnoreMenuShortcuts(!input.control && !input.meta)
})
})
```
#### Event: 'before-mouse-event'
Returns:
* `event` Event
* `mouse` [MouseInputEvent](structures/mouse-input-event.md)
Emitted before dispatching mouse events in the page.
Calling `event.preventDefault` will prevent the page mouse events.
```js
const { app, BrowserWindow } = require('electron')
app.whenReady().then(() => {
const win = new BrowserWindow({ width: 800, height: 600 })
win.webContents.on('before-mouse-event', (event, mouse) => {
// Prevent mouseDown events.
if (mouse.type === 'mouseDown') {
console.log(mouse)
/*
{
type: 'mouseDown',
clickCount: 1,
movementX: 0,
movementY: 0,
button: 'left',
x: 632.359375,
y: 480.6875,
globalX: 168.359375,
globalY: 193.6875
}
*/
event.preventDefault()
}
})
})
```
@@ -838,9 +882,10 @@ Emitted when a bluetooth device needs to be selected when a call to
the `deviceId` of the device to be selected. Passing an empty string to
`callback` will cancel the request.
If an event listener is not added for this event, or if `event.preventDefault`
is not called when handling this event, the first available device will be
automatically selected.
If no event listener is added for this event, all bluetooth requests will be cancelled.
If `event.preventDefault` is not called when handling this event, the first available
device will be automatically selected.
Due to the nature of bluetooth, scanning for devices when
`navigator.bluetooth.requestDevice` is called may take time and will cause
@@ -1102,6 +1147,7 @@ Returns `string` - The URL of the current web page.
```js
const { BrowserWindow } = require('electron')
const win = new BrowserWindow({ width: 800, height: 600 })
win.loadURL('https://github.com').then(() => {
const currentURL = win.webContents.getURL()
@@ -1491,7 +1537,8 @@ increment above or below represents zooming 20% larger or smaller to default
limits of 300% and 50% of original size, respectively. The formula for this is
`scale := 1.2 ^ level`.
> **NOTE**: The zoom policy at the Chromium level is same-origin, meaning that the
> [!NOTE]
> The zoom policy at the Chromium level is same-origin, meaning that the
> zoom level for a specific domain propagates across all instances of windows with
> the same domain. Differentiating the window URLs will make zoom work per-window.
@@ -1508,7 +1555,8 @@ Returns `Promise<void>`
Sets the maximum and minimum pinch-to-zoom level.
> **NOTE**: Visual zoom is disabled by default in Electron. To re-enable it, call:
> [!NOTE]
> Visual zoom is disabled by default in Electron. To re-enable it, call:
>
> ```js
> const win = new BrowserWindow()
@@ -1719,6 +1767,12 @@ When a custom `pageSize` is passed, Chromium attempts to validate platform speci
Prints window's web page. When `silent` is set to `true`, Electron will pick
the system's default printer if `deviceName` is empty and the default settings for printing.
Some possible `failureReason`s for print failure include:
* "Invalid printer settings"
* "Print job canceled"
* "Print job failed"
Use `page-break-before: always;` CSS style to force to print to a new page.
Example usage:
@@ -1769,9 +1823,10 @@ An example of `webContents.printToPDF`:
```js
const { app, BrowserWindow } = require('electron')
const fs = require('node:fs')
const path = require('node:path')
const os = require('node:os')
const path = require('node:path')
app.whenReady().then(() => {
const win = new BrowserWindow()
@@ -1803,6 +1858,7 @@ creation:
```js
const { BrowserWindow } = require('electron')
const win = new BrowserWindow()
win.webContents.on('devtools-opened', () => {
win.webContents.addWorkSpace(__dirname)
@@ -1869,6 +1925,7 @@ An example of showing devtools in a `<webview>` tag:
```js
// Main process
const { ipcMain, webContents } = require('electron')
ipcMain.on('open-devtools', (event, targetContentsId, devtoolsContentsId) => {
const target = webContents.fromId(targetContentsId)
const devtools = webContents.fromId(devtoolsContentsId)
@@ -2076,7 +2133,9 @@ Disable device emulation enabled by `webContents.enableDeviceEmulation`.
* `inputEvent` [MouseInputEvent](structures/mouse-input-event.md) | [MouseWheelInputEvent](structures/mouse-wheel-input-event.md) | [KeyboardInputEvent](structures/keyboard-input-event.md)
Sends an input `event` to the page.
**Note:** The [`BrowserWindow`](browser-window.md) containing the contents needs to be focused for
> [!NOTE]
> The [`BrowserWindow`](browser-window.md) containing the contents needs to be focused for
`sendInputEvent()` to work.
#### `contents.beginFrameSubscription([onlyDirty ,]callback)`
@@ -2126,6 +2185,7 @@ Returns `Promise<void>` - resolves if the page is saved.
```js
const { BrowserWindow } = require('electron')
const win = new BrowserWindow()
win.loadURL('https://github.com')
@@ -2218,7 +2278,9 @@ By default this value is `{ min: 0, max: 0 }` , which would apply no restriction
* `max` Integer - The maximum UDP port number that WebRTC should use.
Setting the WebRTC UDP Port Range allows you to restrict the udp port range used by WebRTC. By default the port range is unrestricted.
**Note:** To reset to an unrestricted port range this value should be set to `{ min: 0, max: 0 }`.
> [!NOTE]
> To reset to an unrestricted port range this value should be set to `{ min: 0, max: 0 }`.
#### `contents.getMediaSourceId(requestWebContents)`
@@ -2364,8 +2426,9 @@ A [`WebContents`](web-contents.md) instance that might own this `WebContents`.
A `WebContents | null` property that represents the of DevTools `WebContents` associated with a given `WebContents`.
**Note:** Users should never store this object because it may become `null`
when the DevTools has been closed.
> [!NOTE]
> Users should never store this object because it may become `null`
> when the DevTools has been closed.
#### `contents.debugger` _Readonly_

View File

@@ -41,7 +41,8 @@ Changes the zoom level to the specified level. The original size is 0 and each
increment above or below represents zooming 20% larger or smaller to default
limits of 300% and 50% of original size, respectively.
> **NOTE**: The zoom policy at the Chromium level is same-origin, meaning that the
> [!NOTE]
> The zoom policy at the Chromium level is same-origin, meaning that the
> zoom level for a specific domain propagates across all instances of windows with
> the same domain. Differentiating the window URLs will make zoom work per-window.
@@ -56,13 +57,15 @@ Returns `number` - The current zoom level.
Sets the maximum and minimum pinch-to-zoom level.
> **NOTE**: Visual zoom is disabled by default in Electron. To re-enable it, call:
> [!NOTE]
> Visual zoom is disabled by default in Electron. To re-enable it, call:
>
> ```js
> webFrame.setVisualZoomLevelLimits(1, 3)
> ```
> **NOTE**: Visual zoom only applies to pinch-to-zoom behavior. Cmd+/-/0 zoom shortcuts are
> [!NOTE]
> Visual zoom only applies to pinch-to-zoom behavior. Cmd+/-/0 zoom shortcuts are
> controlled by the 'zoomIn', 'zoomOut', and 'resetZoom' MenuItem roles in the application
> Menu. To disable shortcuts, manually [define the Menu](./menu.md#examples) and omit zoom roles
> from the definition.
@@ -96,9 +99,11 @@ with an array of misspelt words when complete.
An example of using [node-spellchecker][spellchecker] as provider:
```js @ts-expect-error=[2,6]
```js @ts-expect-error=[3,8]
const { webFrame } = require('electron')
const spellChecker = require('spellchecker')
webFrame.setSpellCheckProvider('en-US', {
spellCheck (words, callback) {
setTimeout(() => {
@@ -189,7 +194,9 @@ dispatch errors of isolated worlds to foreign worlds.
* `name` string (optional) - Name for isolated world. Useful in devtools.
Set the security origin, content security policy and name of the isolated world.
Note: If the `csp` is specified, then the `securityOrigin` also has to be specified.
> [!NOTE]
> If the `csp` is specified, then the `securityOrigin` also has to be specified.
### `webFrame.getResourceUsage()`
@@ -207,11 +214,14 @@ caches.
```js
const { webFrame } = require('electron')
console.log(webFrame.getResourceUsage())
```
This will generate:
<!-- eslint-skip -->
```js
{
images: {

View File

@@ -22,5 +22,6 @@ const oldPath = document.querySelector('input').files[0].path
// After
const { webUtils } = require('electron')
const newPath = webUtils.getPathForFile(document.querySelector('input').files[0])
```

View File

@@ -30,8 +30,10 @@ rendered.
Unlike an `iframe`, the `webview` runs in a separate process than your
app. It doesn't have the same permissions as your web page and all interactions
between your app and embedded content will be asynchronous. This keeps your app
safe from the embedded content. **Note:** Most methods called on the
webview from the host page require a synchronous call to the main process.
safe from the embedded content.
> [!NOTE]
> Most methods called on the webview from the host page require a synchronous call to the main process.
## Example
@@ -252,7 +254,8 @@ The full list of supported feature strings can be found in the
The `webview` tag has the following methods:
**Note:** The webview element must be loaded before using the methods.
> [!NOTE]
> The webview element must be loaded before using the methods.
**Example**
@@ -679,7 +682,8 @@ increment above or below represents zooming 20% larger or smaller to default
limits of 300% and 50% of original size, respectively. The formula for this is
`scale := 1.2 ^ level`.
> **NOTE**: The zoom policy at the Chromium level is same-origin, meaning that the
> [!NOTE]
> The zoom policy at the Chromium level is same-origin, meaning that the
> zoom level for a specific domain propagates across all instances of windows with
> the same domain. Differentiating the window URLs will make zoom work per-window.
@@ -983,6 +987,7 @@ webview.send('ping')
```js
// In guest page.
const { ipcRenderer } = require('electron')
ipcRenderer.on('ping', () => {
ipcRenderer.sendToHost('pong')
})

View File

@@ -12,6 +12,32 @@ This document uses the following convention to categorize breaking changes:
* **Deprecated:** An API was marked as deprecated. The API will continue to function, but will emit a deprecation warning, and will be removed in a future release.
* **Removed:** An API or feature was removed, and is no longer supported by Electron.
## Planned Breaking API Changes (38.0)
### Removed: macOS 11 support
macOS 11 (Big Sur) is no longer supported by [Chromium](https://chromium-review.googlesource.com/c/chromium/src/+/6594615).
Older versions of Electron will continue to run on Big Sur, but macOS 12 (Monterey)
or later will be required to run Electron v38.0.0 and higher.
### Behavior Changed: window.open popups are always resizable
Per current [WHATWG spec](https://html.spec.whatwg.org/multipage/nav-history-apis.html#dom-open-dev), the `window.open` API will now always create a resizable popup window.
To restore previous behavior:
```js
webContents.setWindowOpenHandler((details) => {
return {
action: 'allow',
overrideBrowserWindowOptions: {
resizable: details.features.includes('resizable=yes')
}
}
})
```
## Planned Breaking API Changes (37.0)
### Utility Process unhandled rejection behavior change
@@ -27,6 +53,16 @@ process.on('unhandledRejection', () => {
})
```
### Behavior Changed: `process.exit()` kills utility process synchronously
Calling `process.exit()` in a utility process will now kill the utility process synchronously.
This brings the behavior of `process.exit()` in line with Node.js behavior.
Please refer to the
[Node.js docs](https://nodejs.org/docs/latest-v22.x/api/process.html#processexitcode) and
[PR #45690](https://github.com/electron/electron/pull/45690) to understand the potential
implications of that, e.g., when calling `console.log()` before `process.exit()`.
### Behavior Changed: WebUSB and WebSerial Blocklist Support
[WebUSB](https://developer.mozilla.org/en-US/docs/Web/API/WebUSB_API) and [Web Serial](https://developer.mozilla.org/en-US/docs/Web/API/Web_Serial_API) now support the [WebUSB Blocklist](https://wicg.github.io/webusb/#blocklist) and [Web Serial Blocklist](https://wicg.github.io/serial/#blocklist) used by Chromium and outlined in their respective specifications.
@@ -141,7 +177,7 @@ On Linux, the required portal version for file dialogs has been reverted
to 3 from 4. Using the `defaultPath` option of the Dialog API is not
supported when using portal file chooser dialogs unless the portal
backend is version 4 or higher. The `--xdg-portal-required-version`
[command-line switch](/api/command-line-switches.md#--xdg-portal-required-versionversion)
[command-line switch](api/command-line-switches.md#--xdg-portal-required-versionversion)
can be used to force a required version for your application.
See [#44426](https://github.com/electron/electron/pull/44426) for more details.

View File

@@ -155,7 +155,8 @@ $ gn gen out/Release --args="import(\"//electron/build/args/release.gn\")"
$ gn gen out/Release --args="import(\`"//electron/build/args/release.gn\`")"
```
**Note:** This will generate a `out/Testing` or `out/Release` build directory under `src/` with the testing or release build depending upon the configuration passed above. You can replace `Testing|Release` with another names, but it should be a subdirectory of `out`.
> [!NOTE]
> This will generate a `out/Testing` or `out/Release` build directory under `src/` with the testing or release build depending upon the configuration passed above. You can replace `Testing|Release` with another names, but it should be a subdirectory of `out`.
Also you shouldn't have to run `gn gen` again—if you want to change the build arguments, you can run `gn args out/Testing` to bring up an editor. To see the list of available build configuration options, run `gn args out/Testing --list`.

View File

@@ -7,11 +7,8 @@ Follow the guidelines below for building **Electron itself** on Linux, for the p
## Prerequisites
* At least 25GB disk space and 8GB RAM.
* Python >= 3.7.
* Node.js. There are various ways to install Node. You can download
source code from [nodejs.org](https://nodejs.org) and compile it.
Doing so permits installing Node on your own home directory as a standard user.
Or try repositories such as [NodeSource](https://nodesource.com/blog/nodejs-v012-iojs-and-the-nodesource-linux-repositories).
* Python >= 3.9.
* [Node.js](https://nodejs.org/download/) >= 22.12.0
* [clang](https://clang.llvm.org/get_started.html) 3.4 or later.
* Development headers of GTK 3 and libnotify.

View File

@@ -10,8 +10,8 @@ Follow the guidelines below for building **Electron itself** on macOS, for the p
* [Xcode](https://developer.apple.com/technologies/tools/). The exact version
needed depends on what branch you are building, but the latest version of
Xcode is generally a good bet for building `main`.
* [node.js](https://nodejs.org) (external)
* Python >= 3.7
* Python >= 3.9
* [Node.js](https://nodejs.org/download/) >= 22.12.0
### Arm64-specific prerequisites

View File

@@ -14,7 +14,7 @@ Follow the guidelines below for building **Electron itself** on Windows, for the
set a few environment variables to point the toolchains to your installation path.
* `vs2022_install = DRIVE:\path\to\Microsoft Visual Studio\2022\Community`, replacing `2022` and `Community` with your installed versions and replacing `DRIVE:` with the drive that Visual Studio is on. Often, this will be `C:`.
* `WINDOWSSDKDIR = DRIVE:\path\to\Windows Kits\10`, replacing `DRIVE:` with the drive that Windows Kits is on. Often, this will be `C:`.
* [Node.js](https://nodejs.org/download/)
* [Node.js](https://nodejs.org/download/) >= 22.12.0
* [Git](https://git-scm.com)
* Debugging Tools for Windows of Windows SDK 10.0.15063.468 if you plan on
creating a full distribution since `symstore.exe` is used for creating a symbol
@@ -39,8 +39,9 @@ Building Electron is done entirely with command-line scripts and cannot be done
with Visual Studio. You can develop Electron with any editor but support for
building with Visual Studio will come in the future.
**Note:** Even though Visual Studio is not used for building, it's still
**required** because we need the build toolchains it provides.
> [!NOTE]
> Even though Visual Studio is not used for building, it's still
> **required** because we need the build toolchains it provides.
## Exclude source tree from Windows Security

View File

@@ -148,7 +148,8 @@ In your [`shell/common/node_bindings.cc`](https://github.com/electron/electron/b
V(electron_browser_{api_name})
```
> Note: More technical details on how Node links with Electron can be found on [our blog](https://www.electronjs.org/blog/electron-internals-using-node-as-a-library#link-node-with-electron).
> [!NOTE]
> More technical details on how Node links with Electron can be found on [our blog](https://www.electronjs.org/blog/electron-internals-using-node-as-a-library#link-node-with-electron).
## Expose your API to TypeScript
@@ -164,8 +165,10 @@ An example of the contents of this file can be found [here](https://github.com/e
Add your module to the module list found at `"lib/browser/api/module-list.ts"` like so:
<!-- eslint-disable semi -->
```ts title='lib/browser/api/module-list.ts' @ts-nocheck
export const browserModuleList: ElectronInternal.ModuleEntry[] = [
{ name: 'apiName', loader: () => require('./api-name') },
{ name: 'apiName', loader: () => require('./api-name') }
];
```

Some files were not shown because too many files have changed in this diff Show More