Compare commits

...

90 Commits

Author SHA1 Message Date
trop[bot]
35b3d25ee1 docs: deprecate ELECTRON_OZONE_PLATFORM_HINT env var (#48028)
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: clavin <clavin@electronjs.org>
2025-08-11 09:43:30 +02:00
trop[bot]
03a14844b1 fix: importing from electron/utility in ESM (#48019)
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: David Sanders <dsanders11@ucsbalum.com>
2025-08-11 09:42:56 +02:00
Calvin
fffe214702 ci: update llvmobjdump package as part of fix sync (#48029)
ci: update llvmobjdump package as part of fix sync (#47858)
2025-08-10 21:08:14 -07:00
Calvin
bc56c6987f fix: offscreen mode under window.open creation (#48026)
fix: offscreen mode under `window.open` creation (#47868)

fix: offscreen mode under new window creation

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2025-08-10 21:55:40 +02:00
Calvin
e3f358a45a chore: move gin::Handle to gin_helper (#48016)
chore: move gin::Handle to gin_helper (#47959)

* chore: move gin::Handle to gin_helper

* chore: fix lint

Co-authored-by: Robo <hop2deep@gmail.com>
2025-08-10 21:46:37 +02:00
trop[bot]
89d5b6cd5b ci: cleanup use new arc cluster (#48009)
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
2025-08-09 09:46:37 +02:00
Calvin
4fff74b73e chore: move gin::DeprecatedWrappable to gin_helper (#47996)
chore: move gin::DeprecatedWrappable to gin_helper (#47958)

* chore: move gin::DeprecatedWrappable to gin_helper

This is in preparation for migrating to gin::Wrappable
based on cppgc #47922
The upstream class will be deleted soon via roller PR but
the cppgc migration should happen outside the roll, this
change retains the current functionality by copying the
implementation into //electron/shell/common/gin_helper.
The class can be deleted once the cppgc migration is complete.

* chore: fix lint:cpp

Co-authored-by: Robo <hop2deep@gmail.com>
2025-08-09 13:00:45 +09:00
trop[bot]
74ad696f98 refactor: replace webFrame.routingId with sync IPC (#47941)
* refactor: replace webFrame.routingId with sync IPC

Co-authored-by: Samuel Maddock <smaddock@slack-corp.com>

* fix: GetConstructor missing isolate

Co-authored-by: Samuel Maddock <smaddock@slack-corp.com>

* fix: missing isolate

Co-authored-by: Samuel Maddock <smaddock@slack-corp.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Samuel Maddock <smaddock@slack-corp.com>
2025-08-08 10:55:05 +02:00
trop[bot]
d05f99ff4c fix: compilation error when disabling extensions and pdf_viewer (#47993)
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Jinli Wu <wujinli@bytedance.com>
2025-08-07 16:49:37 -04:00
trop[bot]
f6a2c13740 fix: allow importing from electron/utility at runtime (#47989)
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: David Sanders <dsanders11@ucsbalum.com>
2025-08-07 12:12:42 +02:00
trop[bot]
433f9f5e8c feat: Use DIR_ASSETS path to locate resource bundles (#47950)
* feat: Use DIR_ASSETS path to locate resource bundles

Co-authored-by: Will Anderson <andersonw@dropbox.com>

* Use DIR_ASSETS for calculating ASAR relative paths

Co-authored-by: Will Anderson <andersonw@dropbox.com>

* Add test to verify 'assets' matches parent dir of 'exe'

Co-authored-by: Will Anderson <andersonw@dropbox.com>

* Add Mac-specific test for assets path (but it is failing)

Co-authored-by: Will Anderson <andersonw@dropbox.com>

* test: Update app.getPath('assets') to expect an exception on Mac

Co-authored-by: Will Anderson <andersonw@dropbox.com>

* docs: Update docs for 'assets' path to indicate that it's only available on Windows + Linux

Co-authored-by: Will Anderson <andersonw@dropbox.com>

* fix: Don't define 'assets' mapping on macOS

Co-authored-by: Will Anderson <andersonw@dropbox.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Will Anderson <andersonw@dropbox.com>
2025-08-06 19:40:11 +02:00
trop[bot]
a7b6145f3b feat: webFrameMain.fromFrameToken (#47942)
* feat: webFrameMain.fromFrameToken

Co-authored-by: Samuel Maddock <smaddock@slack-corp.com>

* refactor: return null instead of undefined

Co-authored-by: Samuel Maddock <smaddock@slack-corp.com>

* docs: mention renderer webFrame property

Co-authored-by: Samuel Maddock <smaddock@slack-corp.com>

* chore: undo null->undefined in wfm.fromId api this will be updated in another pr

Co-authored-by: Samuel Maddock <smaddock@slack-corp.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Samuel Maddock <smaddock@slack-corp.com>
2025-08-06 19:39:56 +02:00
trop[bot]
f3774d578d feat: add {get|set}AccentColor on Windows (#47939)
* feat: add setAccentColor on Windows

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

* refactor: unify GetSystemAccentColor

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

* refactor: remove redundant parsing

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

* chore: fixup documentation

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

* Update docs/api/browser-window.md

Co-authored-by: Will Anderson <andersonw@dropbox.com>

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

* Update docs/api/base-window.md

Co-authored-by: Will Anderson <andersonw@dropbox.com>

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2025-08-06 19:39:18 +02:00
trop[bot]
33f4808182 feat: add app.getRecentDocuments() (#47924)
feat: add app.getRecentDocuments()

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2025-08-06 19:35:04 +02:00
trop[bot]
eb02db5185 test: add TS smoke test for electron/utility (#47976)
chore: add TS smoke test for electron/utility

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: David Sanders <dsanders11@ucsbalum.com>
2025-08-06 14:47:42 +02:00
trop[bot]
c3f64712de refactor: avoid deprecated v8::Context::GetIsolate() pt 4 (#47973)
* refactor: remove GetIsolate() calls from SetPrivate()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: remove excess GetIsolate() calls in PassValueToOtherContextInner()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: remove GetIsolate() calls from GetPrivate()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: add a v8::Isolate* local to ProxyFunctionWrapper()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: remove error_context->GetIsolate() call from PassValueToOtherContextInner()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: remove GetIsolate() call from ProxyFunctionWrapper()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: pass source and destination isolate as arg to CreateProxyForAPI()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2025-08-05 23:32:50 -05:00
trop[bot]
df6ad9c970 chore: bump chromium to 140.0.7327.0 (38-x-y) (#47930)
* chore: bump chromium in DEPS to 140.0.7324.0

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>

* chore: bump chromium in DEPS to 140.0.7325.0

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>

* chore: remove @dsanders11's unused include patch CL: https://chromium-review.googlesource.com/c/chromium/src/+/6782507

Co-authored-by: Samuel Maddock <smaddock@slack-corp.com>

* fix: apply keychain patch to new apple subdir CL: https://chromium-review.googlesource.com/c/chromium/src/+/6736212

Co-authored-by: Samuel Maddock <smaddock@slack-corp.com>

* chore: update chromium patches

Co-authored-by: Samuel Maddock <smaddock@slack-corp.com>

* chore: update other patches

Co-authored-by: Samuel Maddock <smaddock@slack-corp.com>

* chore: bump chromium in DEPS to 140.0.7327.0

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>

* fix: mistake in reapplied patch

Co-authored-by: Samuel Maddock <smaddock@slack-corp.com>

* fixup! fix: apply keychain patch to new apple subdir CL: https://chromium-review.googlesource.com/c/chromium/src/+/6736212

Co-authored-by: Samuel Maddock <smaddock@slack-corp.com>

* chore: update patches

Co-authored-by: Samuel Maddock <smaddock@slack-corp.com>

* fix: remove OnPrivateNetworkAccessPermissionRequired override CL: https://chromium-review.googlesource.com/c/chromium/src/+/6769208

Co-authored-by: Samuel Maddock <smaddock@slack-corp.com>

* fix: update colorSpace property to use new unified value CL: https://chromium-review.googlesource.com/c/chromium/src/+/6795085

Co-authored-by: Samuel Maddock <smaddock@slack-corp.com>

* fix: include OverlayWindowLiveCaptionButton CL: https://chromium-review.googlesource.com/c/chromium/src/+/6787420

Co-authored-by: Samuel Maddock <smaddock@slack-corp.com>

* fixup! fix: apply keychain patch to new apple subdir CL: https://chromium-review.googlesource.com/c/chromium/src/+/6736212

Co-authored-by: Samuel Maddock <smaddock@slack-corp.com>

* fix: format chromium_src/BUILD.gn CL: https://chromium-review.googlesource.com/c/chromium/src/+/6787427

Co-authored-by: Samuel Maddock <smaddock@slack-corp.com>

* fix: format BUILD.gn CL: https://chromium-review.googlesource.com/c/chromium/src/+/6787427

Co-authored-by: Samuel Maddock <smaddock@slack-corp.com>

* chore: include script/ in logged path

Co-authored-by: Samuel Maddock <smaddock@slack-corp.com>

* fix: update filenames.libcxx.gni CL: https://chromium-review.googlesource.com/c/chromium/src/+/6787279

Co-authored-by: Samuel Maddock <smaddock@slack-corp.com>

* chore: update patches

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
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: clavin <clavin@electronjs.org>
2025-08-05 21:45:37 -04:00
trop[bot]
729a67d0d7 fix: video scrubbing on playback (#47965)
* fix: fix video scrubbing on playback

Co-authored-by: VerteDinde <keeleymhammond@gmail.com>

* chore: address review feedback

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: VerteDinde <keeleymhammond@gmail.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2025-08-05 15:09:23 -07:00
electron-roller[bot]
ecf905decb chore: bump node to v22.18.0 (38-x-y) (#47936)
chore: bump node to v22.18.0 (main) (#47937)

* chore: bump node in DEPS to v22.18.0

* crypto: fix inclusion of OPENSSL_IS_BORINGSSL define

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

* crypto: fix SHAKE128/256 breaking change introduced with OpenSSL 3.4

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

* permission: propagate permission model flags on spawn

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

* esm: syncify default path of ModuleLoader\.load

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

* src: remove fast API for InternalModuleStat

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

* src: simplify adding fast APIs to ExternalReferenceRegistry

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

* chore: fixup patch indices

* src: fix internalModuleStat v8 fast path

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

* test: add tests to ensure that node.1 is kept in sync with cli.md

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

* crypto: fix SHAKE128/256 breaking change introduced with OpenSSL 3.4

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

---------

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2025-08-05 18:30:41 +02:00
trop[bot]
4fea51017f fix: crash on window.close() with webContents on blur (#47952)
fix: crash on window.close with WebContentsView on blur

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2025-08-04 14:28:35 +02:00
trop[bot]
d3059897ed build: roll build-images to 933c7d6 (#47928)
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2025-07-31 22:43:47 +02:00
trop[bot]
f2d14ca29d refactor: avoid deprecated v8::Context::GetIsolate() calls pt 3 context get isolate pt 3 (#47910)
* refactor: add a v8::Isolate* arg to RendererClientBase::IsWebViewFrame()

Needed for creating gin dictionaries

refactor: add a v8::Isolate* arg to ShouldLoadPreload()

Needed for calling IsWebViewFrame()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: add a v8::Isolate* arg to electron::util::CompileAndCall()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: add a v8::Isolate* arg to OnCreatePreloadableV8Context()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: add a v8::Isolate* arg to InvokeEmitProcessEvent()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: add a v8::Isolate* arg to ServiceWorkerData's constructor

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: add a v8::Isolate* arg to RendererClientBase::SetupMainWorldOverrides()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: add a v8::Isolate* arg to RendererClientBase::WilLReleaseScriptContext()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* docs: update docs to avoid v8::Context::GetIsolate()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: add a v8::Isolate* arg to ElectronSandboxedRendererClient::InitializeBindings()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: avoid v8::Context::GetIsolate() call in PromiseBase::SettleScope::~SettleScope()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2025-07-31 14:19:10 -05:00
trop[bot]
9b1dfe90f4 fix: dark mode on Linux default themeing (#47919)
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2025-07-31 14:29:43 +02:00
trop[bot]
a41ca28b63 fix: window content protection on older Windows versions (#47886)
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2025-07-31 10:53:15 +02:00
trop[bot]
8841e4be83 ci: use new arc cluster (#47912)
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
2025-07-30 16:32:33 -04:00
trop[bot]
5c83e2b00c ci: add ability to debug SSH sessions in CI (#47874)
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2025-07-30 11:43:26 -07:00
trop[bot]
7930f4a20c chore: bump chromium to 140.0.7314.0 (38-x-y) (#47903)
* chore: bump chromium in DEPS to 140.0.7314.0

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>

* 6769821: Delegate checking whether preconnect is enabled.

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

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

* 6632993: PDF Searchify IPH: Use embedder WebContents for GuestView PDF

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

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

* 6769214: [ios blink] Set IOSurface shared memory region on all GMB handles

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

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

* chore: update patches

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

* 6769572: [soft navs]: Move AsyncSameDocumentNavigationStarted to TaskAttributionTracker

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

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

* chore: node gen-libc++-filenames.js

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

* 6765740: [SxS] Implement support for split view in extensions API

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

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

* 6769821: Delegate checking whether preconnect is enabled.

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

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

* chore: update patches

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
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: patchup[bot] <73610968+patchup[bot]@users.noreply.github.com>
2025-07-29 11:00:54 -04:00
trop[bot]
3fefa06d34 refactor: prefer GetCreationContextChecked(v8::Isolate*) over GetCreationContextChecked() (#47890)
* refactor: pass an isolate when calling GetCreationContextChecked() in V8FunctionInvoker

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: pass an isolate when calling GetCreationContextChecked() in RendererClientBase

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: pass an isolate when calling GetCreationContextChecked() in ScriptExecutionCallback::Completed()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: pass an isolate when calling GetCreationContextChecked() in ScriptExecutionCallback::CopyResultToCallingContextAndFinalize()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: pass an isolate when calling GetCreationContextChecked() in electron::GetRenderFrame()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: pass an isolate when calling GetCreationContextChecked() in gin_helper::internal::CallMethodWithArgs()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: pass an isolate when calling GetCreationContextChecked() in OverrideGlobalPropertyFromIsolatedWorld()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: pass an isolate when calling GetCreationContextChecked() in OverrideGlobalValueFromIsolatedWorld()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: pass an isolate when calling GetCreationContextChecked() in ProxyFunctionWrapper()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: pass an isolate when calling GetCreationContextChecked() in PassValueToOtherContextInner()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* fixup! refactor: pass an isolate when calling GetCreationContextChecked() in electron::GetRenderFrame()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2025-07-29 10:37:29 -04:00
trop[bot]
e1e12318e2 refactor: avoid deprecated v8::Context::GetIsolate() calls (pt 2) (#47896)
* refactor: add a v8::Isolate* arg to Constructible::GetConstructor()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: add a v8::Isolate* arg to NodeBindings::Initialize()

This is needed for the GetConstructor() call

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: avoid v8::Context::GetIsolate() call in GetIpcObject() by taking it as an arg

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: avoid v8::Context::GetIsolate() call in ipc_native::EmitIPCEvent() by taking it as an arg

Co-authored-by: Charles Kerr <charles@charleskerr.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2025-07-29 10:34:18 -04:00
trop[bot]
edccb0a7ea chore: bump chromium to 140.0.7312.0 (38-x-y) (#47881)
* chore: bump chromium in DEPS to 140.0.7312.0

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>

* 6769540: Move NetworkTrafficAnnotationTag out of PreconnectManager.

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

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

* 6771377: Roll libc++ from 3eda1e62e799 to 569aa83b4bbc (7 revisions)

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

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

* 6771398: Remove unnecessary std::optional wrappers in ResolveHostClient

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

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

* chore: update patches

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

* 6776165: Use shared session bus for MPRIS

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

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

* chore: update patches

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
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: patchup[bot] <73610968+patchup[bot]@users.noreply.github.com>
2025-07-24 09:33:14 -04:00
trop[bot]
83373c3679 fix: webContents.downloadURL() did not support referer header (#47867)
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: xufuhang <576484918@qq.com>
2025-07-23 16:45:45 +02:00
trop[bot]
9c4d783d1f chore: bump chromium to 140.0.7309.0 (38-x-y) (#47863)
* chore: bump chromium in DEPS to 140.0.7309.0

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>

* 6762172: Replace MSG_ROUTING_NONE with IPC::mojom::kRoutingIdNone.

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

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

* 6759543: [exit-time-destructors] Exclude target with warnings

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

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

* 6765167: Split PreconnectManager into interface and implementation.

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

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

* 6766775: [media] Clarify coded and visible size in FrameResources

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

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

* 6760878: Move PreconnectRequest to //content/public

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

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

* 6718973: Implement media playback trust check for the video PiP overlay window

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

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

* chore: add missing include of <iterator> in ada

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

* chore: update patches

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

* chore: node gen-libc++-filenames.js

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

* 6759633: [media] Use format from shared image in FrameResources

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

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

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: David Sanders <dsanders11@ucsbalum.com>
2025-07-23 10:12:00 +02:00
trop[bot]
139ab00d8c build: improve check-zip-manifest (#47852)
* build: improve check-zip-manifest

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

* fix: unicode on Windows

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2025-07-22 09:50:38 +02:00
trop[bot]
124bfd25f8 chore: bump chromium to 140.0.7301.0 (38-x-y) (#47849)
* chore: bump chromium in DEPS to 140.0.7296.0

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>

* chore: update patches

Co-authored-by: Keeley Hammond <khammond@slack-corp.com>

* 6702959: Remove OwnedByWidgetPassKey usage from content analysis dialog tests | https://chromium-review.googlesource.com/c/chromium/src/+/6702959

Co-authored-by: Keeley Hammond <khammond@slack-corp.com>

* 6722750: Remove un-used `stream_id` argument for `AidaCodeComplete` | https://chromium-review.googlesource.com/c/chromium/src/+/6722750

Co-authored-by: Keeley Hammond <khammond@slack-corp.com>

* 6696478: Reland Reland [video pip] Add fade in/out animation to controls visibility changes | https://chromium-review.googlesource.com/c/chromium/src/+/6696478

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

* chore: update libc++-filenames

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

* build: explicitly include cstdlib in Boyer-Moore patch

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

* chore: bump chromium in DEPS to 140.0.7297.0

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>

* chore: update patches

Co-authored-by: Keeley Hammond <khammond@slack-corp.com>

* 6729537: [FPF] Pipe flag state from the browser to the renderer | https://chromium-review.googlesource.com/c/chromium/src/+/6729537

Co-authored-by: Keeley Hammond <khammond@slack-corp.com>

* 6727996: [Win] Detect pre-IPC crashes in sandboxed utility processes | https://chromium-review.googlesource.com/c/chromium/src/+/6727996

Co-authored-by: Keeley Hammond <khammond@slack-corp.com>

* 6707182: Move wtf/cross_thread_copier*.* to "blink" namespace | https://chromium-review.googlesource.com/c/chromium/src/+/6707182

Co-authored-by: Keeley Hammond <khammond@slack-corp.com>

* 6730796: extensions: Extract safe browsing/telemetry methods to new client class | https://chromium-review.googlesource.com/c/chromium/src/+/6730796

Co-authored-by: Keeley Hammond <khammond@slack-corp.com>

* chore: bump chromium in DEPS to 140.0.7299.0

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>

* chore: update patches

Co-authored-by: patchup[bot] <73610968+patchup[bot]@users.noreply.github.com>

* chore: update main patches

Co-authored-by: Keeley Hammond <khammond@slack-corp.com>

* build: reset the minimum macOS SDK to 15 to match upstream

This reverts commit 499e987c77.

Co-authored-by: Keeley Hammond <khammond@slack-corp.com>

* 6730215: Remove IPC_MESSAGE_LOG_ENABLED ifdef blocks. | https://chromium-review.googlesource.com/c/chromium/src/+/6730215

Co-authored-by: Keeley Hammond <khammond@slack-corp.com>

* 6690442: Delete ppapi/buildflags/buildflags.h | https://chromium-review.googlesource.com/c/chromium/src/+/6690442

Co-authored-by: Keeley Hammond <khammond@slack-corp.com>

* 6667681: Use more binaries from clang toolchain in mac build | https://chromium-review.googlesource.com/c/chromium/src/+/6667681

Co-authored-by: Keeley Hammond <khammond@slack-corp.com>

* chore: bump chromium in DEPS to 140.0.7301.0

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>

* chore: update patches

Co-authored-by: Keeley Hammond <khammond@slack-corp.com>

* 6656309: extensions: Port proxy API to desktop Android | https://chromium-review.googlesource.com/c/chromium/src/+/6656309

Co-authored-by: Keeley Hammond <khammond@slack-corp.com>

* 6758510: Reland 'Move GN enable_plugins variable out of //ppapi' | https://chromium-review.googlesource.com/c/chromium/src/+/6758510

Co-authored-by: Keeley Hammond <khammond@slack-corp.com>

* 6701466: [Extensions] Remove NaCl arch info from Update Client URLs | https://chromium-review.googlesource.com/c/chromium/src/+/6701466

Co-authored-by: Keeley Hammond <khammond@slack-corp.com>

* 6735979: [FSA] Replace `request_writable` with a new enum `FileSystemAccessPermissionMode`. | https://chromium-review.googlesource.com/c/chromium/src/+/6735979

Co-authored-by: Keeley Hammond <khammond@slack-corp.com>

* 6712080: Reland "Turn on gender translation PAK generation everywhere" | https://chromium-review.googlesource.com/c/chromium/src/+/6712080

Co-authored-by: Keeley Hammond <khammond@slack-corp.com>

* 6730796: extensions: Extract safe browsing/telemetry methods to new client class | https://chromium-review.googlesource.com/c/chromium/src/+/6730796

Co-authored-by: Keeley Hammond <khammond@slack-corp.com>

* build: restore minimum macOS SDK to 10, restore patch

This reverts commit a04c579b99.

Co-authored-by: Keeley Hammond <khammond@slack-corp.com>

* fixup! 6701466: [Extensions] Remove NaCl arch info from Update Client URLs | https://chromium-review.googlesource.com/c/chromium/src/+/6701466

Co-authored-by: Keeley Hammond <khammond@slack-corp.com>

* chore: correct node patches

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

* fixup! 6667681: Use more binaries from clang toolchain in mac build | https://chromium-review.googlesource.com/c/chromium/src/+/6667681

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

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: Keeley Hammond <khammond@slack-corp.com>
Co-authored-by: Keeley Hammond <vertedinde@electronjs.org>
Co-authored-by: patchup[bot] <73610968+patchup[bot]@users.noreply.github.com>
2025-07-21 11:55:08 -07:00
trop[bot]
d5ce459cea build: fix ffmpeg generation on Windows non-x64 (#47844)
* build: fix ffmpeg generation on Windows non-x64

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

* test: ffmpeg artifact

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2025-07-21 20:30:34 +02:00
trop[bot]
ea0773c7c7 fix: dialog file filters and macOS app bundles (#47841)
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2025-07-21 19:44:16 +02:00
trop[bot]
d426b92326 refactor: avoid deprecated v8::Context::GetIsolate() calls (pt 1) (#47843)
* refactor: avoid redundant GetIsolate() calls in NodeBindings::CreateEnvironment()

Xref: https://chromium-review.googlesource.com/c/v8/v8/+/6563615

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: use v8::Isolate::GetCurrent() in Initialize() methods

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: add v8::Isolate* arg to NodeBindings::CreateEnvironment()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* fixup! refactor: use v8::Isolate::GetCurrent() in Initialize() methods

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: add v8::Isolate* arg to RendererClientBase::DidCreateScriptContext()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* fixup! refactor: add v8::Isolate* arg to NodeBindings::CreateEnvironment()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* fixup! fixup! refactor: use v8::Isolate::GetCurrent() in Initialize() methods

refactor: prefer JavascriptEnvironment::GetIsolate() in the browser layer

Co-authored-by: Charles Kerr <charles@charleskerr.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2025-07-21 13:12:24 -04:00
trop[bot]
673ec5d39e fix: window accentColor should adhere to native window behavior (#47802)
* fix: window accentColor should adhere to native window behavior

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

* fix: address review feedback

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

* chore: remove duplicate UpdateWindowAccentColor call in ctor

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2025-07-21 12:37:01 +02:00
trop[bot]
bfdc318d56 ci: remove kTCCServiceMicrophone change (#47823)
ci: remove kTCCServiceMicrophone change

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2025-07-18 16:37:33 -04:00
trop[bot]
41093c5ba6 build: update codespace on-create-command (#47820)
build: update codespace on-create-command

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2025-07-18 15:22:08 -04:00
electron-roller[bot]
22d6210c3c chore: bump node to v22.17.1 (38-x-y) (#47775)
* chore: bump node in DEPS to v22.17.1

* chore: update patches

---------

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: patchup[bot] <73610968+patchup[bot]@users.noreply.github.com>
2025-07-18 14:45:35 +02:00
trop[bot]
b20e91d86f fix: abnormal behavior of windows background material (#47814)
* fix: abnormal behavior of windows background material

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

Co-authored-by: zoy <zoy-l@outlook.com>

* chore: update patches

Co-authored-by: patchup[bot] <73610968+patchup[bot]@users.noreply.github.com>

* fix: setting background material after init

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: zoy <zoy-l@outlook.com>
Co-authored-by: patchup[bot] <73610968+patchup[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2025-07-18 10:30:37 +02:00
trop[bot]
658d52ecf1 test: re-enable native module tests (#47805)
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2025-07-17 21:52:20 +02:00
trop[bot]
53c17ea4f5 build: deep update brace-expansion to resolve an audit alert (#47720)
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: David Sanders <dsanders11@ucsbalum.com>
2025-07-17 11:40:53 -04:00
trop[bot]
71af3e452f build(dev-deps): drop unused @types/webpack dep (#47809)
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: David Sanders <dsanders11@ucsbalum.com>
2025-07-17 11:37:28 -04:00
trop[bot]
5081fbe830 fix: handle missing NativeWindowMac in ElectronNSWindow (#47812)
fix: handle missing NativeWindowMac in ElectronNSWindow

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2025-07-17 11:33:25 -04:00
trop[bot]
a4a12fb35a test: fix extensions console flake (#47791)
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2025-07-17 11:04:06 +02:00
trop[bot]
564698e27f test: cleanup RenderFrame lifespan tests (#47797)
* test: cleanup RenderFrame lifespan tests

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

* test: disable navigator.serial tests on arm64 mac

debug the hang

test: disable navigator.bluetooth on arm64 mac

Revert "test: disable navigator.bluetooth on arm64 mac"

This reverts commit 4b53a8485a5ff391832c7da93d859f1aa8722e70.

Revert "debug the hang"

This reverts commit 00338f0d49a7918224822087b4510fa9db0686c3.

Revert "test: disable navigator.serial tests on arm64 mac"

This reverts commit fb515ce447a9d42185e84b17b460e4fb6d1bf71d.

Reapply "test: disable navigator.serial tests on arm64 mac"

This reverts commit 0e5608108ffebbe8b8b27af9ea06aadae2ea85dd.

Reapply "test: disable navigator.bluetooth on arm64 mac"

This reverts commit f4c7d3fc0624a22421cba5d3d75df8c5d4367eea.

fixup

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

* test: add waitUntil for flaky test

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

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
2025-07-17 11:03:34 +02:00
trop[bot]
280f643862 docs: add Menu module tutorials (#47761)
* docs: add `Menu` module tutorials

* link API docs to new tutorials

* removed unreferenced fiddles

* add wording for new types

* fix import sort errors

* delete accelerator.md

* fixes

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Erick Zhao <ezhao@slack-corp.com>
2025-07-16 12:20:08 -07:00
trop[bot]
e2689400aa fix: deprecation warning crash when no Node.js environment available (#47769)
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2025-07-16 12:19:33 -07:00
trop[bot]
f37f8d41c0 fix: corner smoothing feature gate crash (#47785)
* fix: corner smoothing feature gate crash

Co-authored-by: clavin <clavin@electronjs.org>

* Fix ElectronCornerSmoothing::CSSValueFromComputedStyleInternal

Co-authored-by: clavin <clavin@electronjs.org>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: clavin <clavin@electronjs.org>
2025-07-16 12:15:53 -07:00
trop[bot]
7d83554d0e test: deflake clipboard read/write specs (#47787)
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2025-07-16 11:35:47 -07:00
trop[bot]
8924d682be fix: add macos memory query fallback patch to avoid crash (#47783)
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: clavin <clavin@electronjs.org>
2025-07-16 11:34:28 -07:00
trop[bot]
d6c5642155 docs: fix broken sentence in crashReporter.start() documentation (#47778)
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Pratyush <116508117+pratstick@users.noreply.github.com>
2025-07-16 15:58:16 +02:00
trop[bot]
789b4b026a fix: missing SQLite builtin support in Node.js (#47757)
https://github.com/nodejs/node/pull/58122

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2025-07-16 15:05:23 +02:00
trop[bot]
44bd560068 docs: improve win.setContentProtection() docs (#47763)
* docs: improve win.setContentProtection() docs

Co-authored-by: Milan Burda <milan.burda@gmail.com>

* docs: update Windows display affinity value

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

* docs: update Windows behavior description

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

* Revert "docs: update Windows behavior description"

This reverts commit 6d1942c53a.

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

* Revert "docs: update Windows display affinity value"

This reverts commit c15363e75d.

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

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Milan Burda <milan.burda@gmail.com>
Co-authored-by: Niklas Wenzel <dev@nikwen.de>
2025-07-15 16:54:21 -07:00
electron-roller[bot]
2783f76f1f chore: bump chromium to 140.0.7281.0 (38-x-y) (#47559)
* chore: bump chromium in DEPS to 139.0.7258.6

* chore: bump chromium in DEPS to 139.0.7258.5

* chore: bump chromium in DEPS to 140.0.7270.1

* chore: bump chromium in DEPS to 140.0.7271.1

* chore: bump chromium in DEPS to 140.0.7273.0

* chore: bump chromium in DEPS to 140.0.7273.1

* chore: bump chromium in DEPS to 140.0.7275.1

* chore: bump chromium in DEPS to 140.0.7275.4

* chore: bump chromium in DEPS to 140.0.7277.1

* chore: bump chromium in DEPS to 140.0.7279.1

* chore: bump chromium in DEPS to 140.0.7281.1

* chore: bump chromium in DEPS to 140.0.7283.1

* chore: bump chromium in DEPS to 140.0.7285.1

* chore: bump chromium in DEPS to 140.0.7287.1

* chore: bump chromium in DEPS to 140.0.7289.0

* chore: bump chromium in DEPS to 140.0.7289.1

* chore: bump chromium in DEPS to 140.0.7291.1

* chore: bump chromium in DEPS to 140.0.7293.1

* chore: bump chromium in DEPS to 140.0.7295.1

* chore: bump chromium in DEPS to 140.0.7296.0

* chore: bump chromium to 140.0.7281.0 (main) (#47616)

cherry picked from 603cafad7e

* chore: bump chromium in DEPS to 140.0.7269.2

* chore: bump chromium in DEPS to 140.0.7270.0

* chore: bump chromium in DEPS to 140.0.7271.0

* chore: bump chromium in DEPS to 140.0.7273.0

* 6516731: [ExclusiveAccessForAndroid] remove unneeded includes & deps | https://chromium-review.googlesource.com/c/chromium/src/+/6516731

* 6694809: dbus: Ensure systemd scope is started before using any portal services | https://chromium-review.googlesource.com/c/chromium/src/+/6694809

* chore: patch chromium

* chore: export patches

* chore: bump chromium in DEPS to 140.0.7275.0

* 6677511: [pepper] More pepper removal | https://chromium-review.googlesource.com/c/chromium/src/+/6677511

* 6513641: [gin] Rename gin::Wrappable to gin::DeprecatedWrappable | https://chromium-review.googlesource.com/c/chromium/src/+/6513641

* chore: export chromium patches

* 6513641: [gin] Rename gin::Wrappable to gin::DeprecatedWrappable | https://chromium-review.googlesource.com/c/chromium/src/+/6513641

* chore: bump chromium in DEPS to 140.0.7277.0

* chore: bump chromium in DEPS to 140.0.7279.0

* chore: bump chromium in DEPS to 140.0.7281.0

* 6677314: Plumb enabled client hints in the network requestion to network layer

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

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

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

* 6700077: [renderer] Avoid calls to deprecated GetIsolate methods

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

* 6692873: Reland "Reland "FSA: Only normalize the hardcoded rules once during initialization""

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

* 6686234: [gin] Cleanup NamedPropertyInterceptor for Wrappable

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

* chore: export patches

* 6667723: Remove content_enable_legacy_ipc GN arg.

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

* 6646566: ui: Move NativeWindowTracker to its own directory

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

* fix: add missing includes

* 6580522: [WAR, DNR] Fix unsafe redirect error to web accessible resource

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

* 6680477: Implement `completeCode` endpoint and expose to DevTools

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

* 6677511: [pepper] More pepper removal

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

* 6696689: Rename views::WidgetFocusManager -> NativeViewFocusManager

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

* 6702812: Move wtf/text/string_impl*.* to "blink" namespace

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

* chore: fix dialog patch

* 6702431: [animation-trigger] Parse timeline-trigger-name

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

* chore: fixup patch indices

* feat: replace webFrame.routingId with webFrame.frameToken

* feat: WebFrameMain.prototype.frameToken

* test: refactor to use replacement APIs

* chore: fixup pip patch

* test: adjust webFrame tests for frameToken changes

* 6703757: Reland "Enable -fsanitize=array-bounds in non-UBSan builds"

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

* test: switch to frameTokens

* test: routingId is fine to test in the main process

* docs: add routingId to breaking changes

* docs: update plugin-crashed event

* chore: fixup linux dialog patch

---------

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: alice <alice@makenotion.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
Co-authored-by: Samuel Maddock <smaddock@slack-corp.com>
(cherry picked from commit 603cafad7e)

---------

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
Co-authored-by: alice <alice@makenotion.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
Co-authored-by: Samuel Maddock <smaddock@slack-corp.com>
2025-07-15 12:05:29 -04:00
trop[bot]
96957aebf3 test: add response to bluetooth request possibilities (#47743)
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2025-07-15 13:49:45 +02:00
trop[bot]
e8c3b6fe66 ci: roll BUILD_TOOLS_SHA for macOS 15.5 SDK (#47742)
ci: roll BUILD_TOOLS_SHA for macOS 15.5 SDK

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2025-07-15 11:33:07 +02:00
trop[bot]
58e0a96d21 ci: add kTCCServiceAppleEvents perm override to fix AppleScript errors (#47737)
ci: add kTCCServiceAppleEvents perm override to fix AppleScript errors

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2025-07-14 11:45:37 +02:00
trop[bot]
b136dbc4cc build: cleanup symlinks in cache (#47733)
* build: cleanup symlinks in cache

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

* build: ignore broken links

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

* try --ignore-failed-read

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

* build: dont deref symlinks

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

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

Needed to ignore Dangerous symbolic link path was ignored errors

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

* Revert "build: cleanup symlinks in cache"

This reverts commit 69e53cdc88.

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

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
2025-07-13 12:24:59 +02:00
trop[bot]
2efd448a87 refactor: use dbus_thread_linux::GetSharedSessionBus() (#47707)
refactor: use dbus_thread_linux::GetSharedSessionBus()

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2025-07-12 09:54:03 +02:00
trop[bot]
31e6800314 ci: set git core.longpaths to true (#47714)
ci: set git core.longpaths to true

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2025-07-11 15:56:10 +02:00
trop[bot]
f1fef462c0 build: reenable v8_enable_temporal_support (#47715)
* build: reenable v8_enable_temporal_support

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

* ci: test with increased vm map count

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

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

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

* chore: update patches

Co-authored-by: patchup[bot] <73610968+patchup[bot]@users.noreply.github.com>

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

This reverts commit b626c9a5ab7ad3f01e17d77c330abfd8096a8b02.

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

* ci: remove logs

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

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: deepak1556 <hop2deep@gmail.com>
Co-authored-by: patchup[bot] <73610968+patchup[bot]@users.noreply.github.com>
2025-07-11 09:52:43 +02:00
trop[bot]
e08f057e91 docs: update build prerequisites (#47696)
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2025-07-09 12:31:52 +02:00
trop[bot]
f97bee6f04 build: drop eslint-plugin-unicorn (#47686)
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: David Sanders <dsanders11@ucsbalum.com>
2025-07-08 18:18:37 +02:00
trop[bot]
0b77096f2a fix: default to system accent color on invalid user color (#47684)
fix: default to system accent color on invalid user color"

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2025-07-08 15:21:44 +02:00
trop[bot]
130f00dfcd fix: fullscreen for windows without rounded corners (#47681)
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2025-07-08 15:21:13 +02:00
trop[bot]
3a6d7e0c22 refactor: avoid a few unnecessary strings (#47655)
* perf: replace string temporary with string_view in GetXdgAppId()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

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

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* perf: replace string temporary with string_view in ToV8(electron::api::WebContents::Type)

Co-authored-by: Charles Kerr <charles@charleskerr.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2025-07-04 10:58:50 +02:00
trop[bot]
7907443448 build: set the minimum macOS SDK to 10.15 (#47659)
* build: set the minumum macOS SDK to 10.15

Co-authored-by: Keeley Hammond <khammond@slack-corp.com>

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

This reverts commit 3d4654fc18.

Co-authored-by: Keeley Hammond <khammond@slack-corp.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Keeley Hammond <khammond@slack-corp.com>
2025-07-04 10:24:36 +02:00
trop[bot]
a425ddd08e fix: crash on source capture with empty thumbnail size (#47652)
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2025-07-03 22:19:43 +02:00
trop[bot]
9184541193 fix: accent color should reflect system settings without restart (#47658)
fix: accentColor should reflect system settings without restart

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2025-07-03 22:19:29 +02:00
trop[bot]
5edb807cff build: update yarn to 1.22.22 (#47637)
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Samuel Attard <sattard@anthropic.com>
2025-07-03 14:41:55 +02:00
trop[bot]
c65bfc1e5c chore: bump chromium to 140.0.7261.0 (38-x-y) (#47617)
* chore: bump chromium in DEPS to 140.0.7259.0

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>

* chore: update patches

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

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

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

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

* Use V8 Apis that don't return JSGlobalObject

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

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

* chore: IWYU

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

* chore: bump chromium in DEPS to 140.0.7261.0

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>

* chore: update patches

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

* revert: update to siso-chromium image

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

* Use v8::Object::WrapGlobal()

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

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

* chore: IWYU

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

* chore: fix --trace-startup spec

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

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: deepak1556 <hop2deep@gmail.com>
2025-06-30 17:07:00 -04:00
trop[bot]
85a8bfaa31 chore: bump chromium to 139.0.7256.0 (38-x-y) (#47615)
* chore: bump chromium in DEPS to 139.0.7242.0

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>

* 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

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* 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

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* 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

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* 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

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* 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

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* chore: update revert_code_health_clean_up_stale_macwebcontentsocclusion.patch

no manual changes; just updating patch context

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* chore: update fix_rename_sqlite_win32_exports_to_avoid_conflicts_with_node_js.patch

no code changes; just updating patch context

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* chore: e patches all

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* Plumb Verify2QwacBinding and hook it up in QwacWebContentsObserver

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

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

* Remove host delegate OnMainFrameCreatedForBackgroundPage

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

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

* Extensions: Rename GetResourceURL to ResolveExtensionURL

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

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

* Consolidate NativeFrameViewMac

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

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

* ICWYU

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

* Remove dead code WidgetAXTreeIDMap

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

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

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

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

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

* NavigationThrottleRunner2: Remove MaybeAddThrottle

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

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

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

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

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

* build: fix snapshot_blob.bin build error

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

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

* chore: e patches all

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* build: freeup disk space on macos

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

* chore: bump chromium in DEPS to 139.0.7244.0

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>

* chore: update printing.patch

no manual changes; just updating patch context

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* 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

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* chore: e patches all

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* 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

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* 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

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* chore: bump chromium in DEPS to 139.0.7246.0

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>

* chore: e patches all

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* chore: bump chromium in DEPS to 139.0.7248.0

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>

* chore: update patches

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

* 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.

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

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

This reverts commit e91e3894e6.

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

* Update mac_sdk_min to match minimum required SDK version

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

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

* Use default window styling on Mac

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

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

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

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

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

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

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

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

* chore: bump chromium in DEPS to 139.0.7249.0

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>

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

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

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

* chore: update patches

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

* chore: bump chromium in DEPS to 139.0.7250.0

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>

* chore: bump chromium in DEPS to 139.0.7252.0

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>

* chore: bump chromium in DEPS to 139.0.7254.0

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>

* 6638187: browser level TOCTOU check for coordinate target

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

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

* chore: fixup patch indices

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

* chore: add missing base/notimplemented includes

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

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

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

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

* chore: bump chromium in DEPS to 139.0.7256.0

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>

* chore: fix lint

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

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

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

* fix: move HandleScope location

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

* chore: bump chromium in DEPS to 139.0.7258.0

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>

* fixup! [NonClientFrameView] Consolidate NativeFrameViewMac

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

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

This reverts commit 264b2e934f.

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

* chore: update patches

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
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>
Co-authored-by: patchup[bot] <73610968+patchup[bot]@users.noreply.github.com>
2025-06-30 12:29:54 -04:00
electron-roller[bot]
f6d054f0fb chore: bump node to v22.17.0 (38-x-y) (#47556)
* 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

* 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: patchup[bot] <73610968+patchup[bot]@users.noreply.github.com>
2025-06-30 14:49:12 +02:00
trop[bot]
66a89ec38f refactor: reduce scope of temporaries when getting dictionary values (#47612)
refactor: reduce scale of temporaries when getting dictionary values

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2025-06-30 12:03:45 +02:00
trop[bot]
6d3eeb46e4 perf: avoid copying a vector when calling ConvertToWeakPtrVector() (#47603)
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2025-06-30 10:59:53 +02:00
trop[bot]
34dcfb5422 fix: Reland "[accessibility] Platform node lifetime cleanups" (#47610)
Reland "[accessibility] Platform node lifetime cleanups"

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

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2025-06-30 10:59:26 +02:00
trop[bot]
e84f0e164e test: fix nan tests on macOS (#47609)
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2025-06-30 10:58:56 +02:00
trop[bot]
68c769de94 refactor: avoid copies of large objects in range based for loops (#47606)
* Avoid copies of large objects in range-based for-loops.

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

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* Avoid copies of large objects in range-based for-loops in Browser::ShowAboutPanel()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2025-06-30 10:28:53 +02:00
trop[bot]
3eabf175b8 docs: update example apps (#47599)
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Erick Zhao <ezhao@slack-corp.com>
2025-06-29 21:58:10 +02:00
trop[bot]
9c0ef6f9c6 refactor: sync IsKillURL() with upstream impl in extension_tab_util.cc (#47596)
Use base::MakeFixedFlatSet()

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2025-06-27 21:07:44 -05:00
trop[bot]
c150a1e004 refactor: extract-constant static Windows registry keys in Browser code (#47589)
* refactor: extract-constant for registry key in GetProcessExecPath()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

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

Co-authored-by: Charles Kerr <charles@charleskerr.com>

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

Co-authored-by: Charles Kerr <charles@charleskerr.com>

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

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* chore: document the symbolic constants

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: prefer base::wcstring_view::c_str() to data() to make zero-termination clearer

Co-authored-by: Charles Kerr <charles@charleskerr.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2025-06-27 15:12:00 -05:00
trop[bot]
a8b8ad9ca9 refactor: make context bridge's private keys hidden, constexpr string_views (#47585)
* refactor: local functions GetPrivate(), SetPrivate() now take std::string_views

Co-authored-by: Charles Kerr <charles@charleskerr.com>

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

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: make local keys constexpr

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: move local keys into local anonymous namespace

Co-authored-by: Charles Kerr <charles@charleskerr.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2025-06-27 12:42:33 -05:00
trop[bot]
4268bf91e4 refactor: remove stray .c_str() calls for absl::StrFormat() (#47578)
refactor: remove stray .c_str() calls for absl::StrFormat()

StrFormat() understands std::string, std::string_view

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2025-06-26 11:41:48 -05:00
trop[bot]
79d6160bdc docs: fix --experimental-network-inspection spelling (#47574)
doc: fix `--experimental-network-inspection` spelling

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Niklas Wenzel <dev@nikwen.de>
2025-06-26 16:38:22 +02:00
trop[bot]
41ebb49703 fix: revert upstream MacOS mouse event routing (#47575)
* fix: revert upstream MacOS mouse event routing

Co-authored-by: Keeley Hammond <khammond@slack-corp.com>

* fix: reduce patch surface area

Co-authored-by: Keeley Hammond <khammond@slack-corp.com>

* chore: update patches

Co-authored-by: Keeley Hammond <khammond@slack-corp.com>

* chore: update patches

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Keeley Hammond <khammond@slack-corp.com>
Co-authored-by: patchup[bot] <73610968+patchup[bot]@users.noreply.github.com>
2025-06-26 16:38:10 +02:00
trop[bot]
c30eae3216 docs: update asar integrity fuse availability (#47568)
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Niklas Wenzel <dev@nikwen.de>
2025-06-25 17:06:46 -05:00
trop[bot]
b89810f374 docs: Add C++/Linux tutorial (#47552)
* docs: Add C++/Linux tutorial

Co-authored-by: Felix Rieseberg <fr@makenotion.com>

* Update docs/tutorial/native-code-and-electron-cpp-linux.md

Co-authored-by: Kilian Valkhof <kilian@kilianvalkhof.com>

Co-authored-by: Felix Rieseberg <fr@makenotion.com>

* Apply suggestions from code review

Co-authored-by: Kilian Valkhof <kilian@kilianvalkhof.com>
Co-authored-by: Erick Zhao <erick@hotmail.ca>

Co-authored-by: Felix Rieseberg <felix@felixrieseberg.com>

* Apply suggestions from code review

Co-authored-by: Erick Zhao <erick@hotmail.ca>

Co-authored-by: Felix Rieseberg <felix@felixrieseberg.com>

* Apply suggestions from code review

Co-authored-by: Erick Zhao <erick@hotmail.ca>

Co-authored-by: Felix Rieseberg <felix@felixrieseberg.com>

* Implement more feedback, lint

Co-authored-by: Felix Rieseberg <felix@felixrieseberg.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Felix Rieseberg <fr@makenotion.com>
Co-authored-by: Felix Rieseberg <felix@felixrieseberg.com>
2025-06-25 09:35:00 -04:00
542 changed files with 10957 additions and 5883 deletions

View File

@@ -2,7 +2,7 @@ version: '3'
services:
buildtools:
image: ghcr.io/electron/devcontainer:424eedbf277ad9749ffa9219068aa72ed4a5e373
image: ghcr.io/electron/devcontainer:933c7d6ff6802706875270bec2e3c891cf8add3f
volumes:
- ..:/workspaces/gclient/src/electron:cached

View File

@@ -58,13 +58,13 @@ if [ ! -f $buildtools/configs/evm.testing.json ]; then
},
\"\$schema\": \"file:///home/builduser/.electron_build_tools/evm-config.schema.json\",
\"configValidationLevel\": \"strict\",
\"reclient\": \"$1\",
\"preserveXcode\": 5
\"remoteBuild\": \"reclient\",
\"preserveSDK\": 5
}
" >$buildtools/configs/evm.testing.json
}
write_config remote_exec
write_config
e use testing
else

View File

@@ -38,6 +38,12 @@ 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: Set GN_EXTRA_ARGS for Windows
shell: bash
if: ${{inputs.target-arch != 'x64' && inputs.target-platform == 'win' }}
run: |
GN_APPENDED_ARGS="$GN_EXTRA_ARGS target_cpu=\"${{ inputs.target-arch }}\""
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"
@@ -184,8 +190,8 @@ runs:
electron/script/zip-symbols.py -b $BUILD_PATH
fi
- name: Generate FFMpeg ${{ inputs.step-suffix }}
shell: bash
if: ${{ inputs.is-release == 'true' }}
shell: bash
run: |
cd src
gn gen out/ffmpeg --args="import(\"//electron/build/args/ffmpeg.gn\") use_remoteexec=true $GN_EXTRA_ARGS"

View File

@@ -40,7 +40,7 @@ runs:
if: ${{ inputs.generate-sas-token == 'true' }}
shell: bash
run: |
curl --unix-socket /var/run/sas/sas.sock --fail "http://foo/$CACHE_FILE?platform=${{ inputs.target-platform }}" > sas-token
curl --unix-socket /var/run/sas/sas.sock --fail "http://foo/$CACHE_FILE?platform=${{ inputs.target-platform }}&getAccountName=true" > sas-token
- name: Save SAS Key
if: ${{ inputs.generate-sas-token == 'true' }}
uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3

View File

@@ -19,11 +19,13 @@ inputs:
runs:
using: "composite"
steps:
- name: Fix clang
- name: Fix llvm toolchain
shell: bash
run : |
rm -rf src/third_party/llvm-build
python3 src/tools/clang/scripts/update.py
# Refs https://chromium-review.googlesource.com/c/chromium/src/+/6667681
python3 src/tools/clang/scripts/update.py --package objdump
- name: Fix esbuild
uses: ./src/electron/.github/actions/cipd-install
with:

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,9 +11,10 @@ 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=0a7f6bef9453ceee45612442660ca16d2c40171b
export BUILD_TOOLS_SHA=274cba0474f0d1e4e6adbb66c1da48556cb0add5
npm i -g @electron/build-tools
# Update depot_tools to ensure python
e d update_depot_tools

View File

@@ -36,18 +36,19 @@ runs:
echo "SAS Token not found; exiting src cache download early..."
exit 1
else
sas_token=$(jq -r '.sasToken' sas-token)
account_name=$(jq -r '.accountName' sas-token)
if [ "${{ inputs.target-platform }}" = "win" ]; then
azcopy copy --log-level=ERROR \
"https://${{ env.AZURE_AKS_CACHE_STORAGE_ACCOUNT }}.file.core.windows.net/${{ env.AZURE_AKS_WIN_CACHE_SHARE_NAME }}/${{ env.CACHE_PATH }}?$sas_token" $DEPSHASH.tar
"https://$account_name.file.core.windows.net/${{ env.AZURE_AKS_WIN_CACHE_SHARE_NAME }}/${{ env.CACHE_PATH }}?$sas_token" $DEPSHASH.tar
else
azcopy copy --log-level=ERROR \
"https://${{ env.AZURE_AKS_CACHE_STORAGE_ACCOUNT }}.file.core.windows.net/${{ env.AZURE_AKS_CACHE_SHARE_NAME }}/${{ env.CACHE_PATH }}?$sas_token" $DEPSHASH.tar
"https://$account_name.file.core.windows.net/${{ env.AZURE_AKS_CACHE_SHARE_NAME }}/${{ env.CACHE_PATH }}?$sas_token" $DEPSHASH.tar
fi
fi
env:
AZURE_AKS_CACHE_STORAGE_ACCOUNT: f723719aa87a34622b5f7f3
AZURE_AKS_CACHE_SHARE_NAME: pvc-f6a4089f-b082-4bee-a3f9-c3e1c0c02d8f
AZURE_AKS_WIN_CACHE_SHARE_NAME: pvc-71dec4f2-0d44-4fd1-a2c3-add049d70bdf
AZURE_AKS_CACHE_SHARE_NAME: linux-cache
AZURE_AKS_WIN_CACHE_SHARE_NAME: windows-cache
- name: Clean SAS Key
shell: bash
run: rm -f sas-token
@@ -96,7 +97,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' }}

20
.github/actions/ssh-debug/action.yml vendored Normal file
View File

@@ -0,0 +1,20 @@
name: Debug via SSH
description: Setup a SSH server with a tunnel to access it to debug via SSH.
inputs:
tunnel:
description: 'Enable SSH tunneling via cloudflared'
required: true
default: 'false'
timeout:
description: 'SSH session timeout in minutes'
required: false
type: number
default: 60
runs:
using: composite
steps:
- run: $GITHUB_ACTION_PATH/setup-ssh.sh
shell: bash
env:
TUNNEL: ${{ inputs.tunnel }}
TIMEOUT: ${{ inputs.timeout }}

4
.github/actions/ssh-debug/bashrc vendored Normal file
View File

@@ -0,0 +1,4 @@
# If we're in an interactive SSH session and we're not already in tmux and there's no explicit SSH command, auto attach tmux
if [ -n "$SSH_TTY" ] && [ -z "$TMUX" ] && [ -z "$SSH_ORIGINAL_COMMAND" ]; then
exec tmux attach || exec tmux
fi

140
.github/actions/ssh-debug/setup-ssh.sh vendored Executable file
View File

@@ -0,0 +1,140 @@
#!/bin/bash -e
get_authorized_keys() {
if [ -z "$AUTHORIZED_USERS" ] || ! echo "$AUTHORIZED_USERS" | grep -q "\b$GITHUB_ACTOR\b"; then
return 1
fi
api_response=$(curl -s "https://api.github.com/users/$GITHUB_ACTOR/keys")
if echo "$api_response" | jq -e 'type == "object" and has("message")' >/dev/null; then
error_msg=$(echo "$api_response" | jq -r '.message')
echo "Error: $error_msg"
return 1
else
echo "$api_response" | jq -r '.[].key'
fi
}
authorized_keys=$(get_authorized_keys "$GITHUB_ACTOR")
if [ -n "$authorized_keys" ]; then
echo "Configured SSH key(s) for user: $GITHUB_ACTOR"
else
echo "Error: User '$GITHUB_ACTOR' is not authorized to access this debug session."
echo "Authorized users: $AUTHORIZED_USERS"
exit 1
fi
if [ "$TUNNEL" != "true" ]; then
echo "SSH tunneling is disabled. Set enable-tunnel: true to enable remote access."
echo "Local SSH server would be available on localhost:2222 if this were a local environment."
exit 0
fi
echo "SSH tunneling enabled. Setting up remote access..."
EXTERNAL_DEPS="curl jq ssh-keygen"
for dep in $EXTERNAL_DEPS; do
if ! command -v "$dep" > /dev/null 2>&1; then
echo "Command $dep not installed on the system!" >&2
exit 1
fi
done
cd "$GITHUB_ACTION_PATH"
bashrc_path=$(pwd)/bashrc
# Source `bashrc` to auto start tmux on SSH login.
if ! grep -q "$bashrc_path" ~/.bash_profile; then
echo >> ~/.bash_profile # On macOS runner there's no newline at the end of the file
echo "source \"$bashrc_path\"" >> ~/.bash_profile
fi
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
ARCH=$(uname -m)
if [ "$ARCH" = "x86_64" ]; then
ARCH="amd64"
elif [ "$ARCH" = "aarch64" ]; then
ARCH="arm64"
fi
# Install tmux on macOS runners if not present.
if [ "$OS" = "darwin" ] && ! command -v tmux > /dev/null 2>&1; then
echo "Installing tmux..."
brew install tmux
fi
if [ "$OS" = "darwin" ]; then
cloudflared_url="https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-${OS}-${ARCH}.tgz"
echo "Downloading \`cloudflared\` from <$cloudflared_url>..."
curl --location --silent --output cloudflared.tgz "$cloudflared_url"
tar xf cloudflared.tgz
rm cloudflared.tgz
else
cloudflared_url="https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-${OS}-${ARCH}"
echo "Downloading \`cloudflared\` from <$cloudflared_url>..."
curl --location --silent --output cloudflared "$cloudflared_url"
fi
chmod +x cloudflared
echo "Setting up SSH key for authorized user: $GITHUB_ACTOR"
echo "$authorized_keys" > authorized_keys
echo 'Creating SSH server key...'
ssh-keygen -q -f ssh_host_rsa_key -N ''
echo 'Creating SSH server config...'
sed "s,\$PWD,$PWD,;s,\$USER,$USER," sshd_config.template > sshd_config
echo 'Starting SSH server...'
/usr/sbin/sshd -f sshd_config -D &
sshd_pid=$!
echo 'Starting tmux session...'
(cd "$GITHUB_WORKSPACE" && tmux new-session -d -s debug)
#if no cloudflare tunnel token is provided, exit
if [ -z "$CLOUDFLARE_TUNNEL_TOKEN" ]; then
echo "Error: required CLOUDFLARE_TUNNEL_TOKEN not found"
exit 1
fi
echo 'Starting Cloudflare tunnel...'
./cloudflared tunnel --no-autoupdate run --token "$CLOUDFLARE_TUNNEL_TOKEN" 2>&1 | tee cloudflared.log | sed -u 's/^/cloudflared: /' &
cloudflared_pid=$!
url="$TUNNEL_HOSTNAME"
public_key=$(cut -d' ' -f1,2 < ssh_host_rsa_key.pub)
(
echo ' '
echo ' '
echo '🔗 SSH Debug Session Ready!'
echo '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'
echo ' '
echo '📋 Copy and run this command to connect:'
echo ' '
if [ -n "$TUNNEL_HOSTNAME" ]; then
echo "ssh-keygen -R action-ssh-debug && echo 'action-ssh-debug $public_key' >> ~/.ssh/known_hosts && ssh -o ProxyCommand='cloudflared access tcp --hostname $url' runner@action-ssh-debug"
else
echo "ssh-keygen -R action-ssh-debug && echo 'action-ssh-debug $public_key' >> ~/.ssh/known_hosts && ssh -o ProxyCommand='cloudflared access tcp --hostname $url' runner@action-ssh-debug"
fi
echo ' '
echo "⏰ Session expires automatically in $TIMEOUT minutes"
echo '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'
echo ' '
echo ' '
) | cat
echo 'Starting SSH session in background...'
./ssh-session.sh "$sshd_pid" "$cloudflared_pid" $TIMEOUT &
echo 'SSH session is running in background. GitHub Action will continue.'
echo 'Session will auto-cleanup after timeout or when processes end.'

21
.github/actions/ssh-debug/ssh-session.sh vendored Executable file
View File

@@ -0,0 +1,21 @@
#!/bin/bash
SSHD_PID=$1
CLOUDFLARED_PID=$2
SESSION_TIMEOUT=${3:-3600}
# Wait for timeout or until processes die.
sleep "$SESSION_TIMEOUT" &
SLEEP_PID=$!
# Monitor if SSH or cloudflared dies early.
while kill -0 "$SSHD_PID" 2>/dev/null && kill -0 "$CLOUDFLARED_PID" 2>/dev/null && kill -0 "$SLEEP_PID" 2>/dev/null; do
sleep 10
done
# Cleanup.
kill "$SLEEP_PID" 2>/dev/null || true
kill "$SSHD_PID" 2>/dev/null || true
kill "$CLOUDFLARED_PID" 2>/dev/null || true
echo "SSH session ended"

View File

@@ -0,0 +1,9 @@
Port 2222
HostKey $PWD/ssh_host_rsa_key
PidFile $PWD/sshd.pid
# Only allow single user
AllowUsers $USER
# Only allow those keys
AuthorizedKeysFile $PWD/authorized_keys

View File

@@ -8,7 +8,7 @@ on:
jobs:
build-git-cache-linux:
runs-on: electron-arc-linux-amd64-32core
runs-on: electron-arc-centralus-linux-amd64-32core
container:
image: ghcr.io/electron/build:bc2f48b2415a670de18d13605b1cf0eb5fdbaae1
options: --user root
@@ -29,7 +29,7 @@ jobs:
target-platform: linux
build-git-cache-windows:
runs-on: electron-arc-linux-amd64-32core
runs-on: electron-arc-centralus-linux-amd64-32core
container:
image: ghcr.io/electron/build:bc2f48b2415a670de18d13605b1cf0eb5fdbaae1
options: --user root --device /dev/fuse --cap-add SYS_ADMIN
@@ -51,7 +51,7 @@ jobs:
target-platform: win
build-git-cache-macos:
runs-on: electron-arc-linux-amd64-32core
runs-on: electron-arc-centralus-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:

View File

@@ -6,7 +6,7 @@ on:
build-image-sha:
type: string
description: 'SHA for electron/build image'
default: '424eedbf277ad9749ffa9219068aa72ed4a5e373'
default: '933c7d6ff6802706875270bec2e3c891cf8add3f'
required: true
skip-macos:
type: boolean
@@ -64,7 +64,7 @@ jobs:
id: set-output
run: |
if [ -z "${{ inputs.build-image-sha }}" ]; then
echo "build-image-sha=424eedbf277ad9749ffa9219068aa72ed4a5e373" >> "$GITHUB_OUTPUT"
echo "build-image-sha=933c7d6ff6802706875270bec2e3c891cf8add3f" >> "$GITHUB_OUTPUT"
else
echo "build-image-sha=${{ inputs.build-image-sha }}" >> "$GITHUB_OUTPUT"
fi
@@ -92,7 +92,7 @@ jobs:
checkout-macos:
needs: setup
if: ${{ needs.setup.outputs.src == 'true' && !inputs.skip-macos}}
runs-on: electron-arc-linux-amd64-32core
runs-on: electron-arc-centralus-linux-amd64-32core
container:
image: ghcr.io/electron/build:${{ needs.setup.outputs.build-image-sha }}
options: --user root
@@ -120,7 +120,7 @@ jobs:
checkout-linux:
needs: setup
if: ${{ needs.setup.outputs.src == 'true' && !inputs.skip-linux}}
runs-on: electron-arc-linux-amd64-32core
runs-on: electron-arc-centralus-linux-amd64-32core
container:
image: ghcr.io/electron/build:${{ needs.setup.outputs.build-image-sha }}
options: --user root
@@ -149,7 +149,7 @@ jobs:
checkout-windows:
needs: setup
if: ${{ needs.setup.outputs.src == 'true' && !inputs.skip-windows }}
runs-on: electron-arc-linux-amd64-32core
runs-on: electron-arc-centralus-linux-amd64-32core
container:
image: ghcr.io/electron/build:${{ needs.setup.outputs.build-image-sha }}
options: --user root --device /dev/fuse --cap-add SYS_ADMIN
@@ -194,7 +194,7 @@ jobs:
with:
target-platform: linux
target-archs: x64 arm arm64
check-runs-on: electron-arc-linux-amd64-8core
check-runs-on: electron-arc-centralus-linux-amd64-8core
check-container: '{"image":"ghcr.io/electron/build:${{ needs.checkout-linux.outputs.build-image-sha }}","options":"--user root","volumes":["/mnt/cross-instance-cache:/mnt/cross-instance-cache"]}'
gn-build-type: testing
secrets: inherit
@@ -205,7 +205,7 @@ jobs:
with:
target-platform: win
target-archs: x64 x86 arm64
check-runs-on: electron-arc-linux-amd64-8core
check-runs-on: electron-arc-centralus-linux-amd64-8core
check-container: '{"image":"ghcr.io/electron/build:${{ needs.checkout-windows.outputs.build-image-sha }}","options":"--user root --device /dev/fuse --cap-add SYS_ADMIN","volumes":["/mnt/win-cache:/mnt/win-cache"]}'
gn-build-type: testing
secrets: inherit
@@ -255,8 +255,8 @@ jobs:
uses: ./.github/workflows/pipeline-electron-build-and-test-and-nan.yml
needs: checkout-linux
with:
build-runs-on: electron-arc-linux-amd64-32core
test-runs-on: electron-arc-linux-amd64-4core
build-runs-on: electron-arc-centralus-linux-amd64-32core
test-runs-on: electron-arc-centralus-linux-amd64-4core
build-container: '{"image":"ghcr.io/electron/build:${{ needs.checkout-linux.outputs.build-image-sha }}","options":"--user root","volumes":["/mnt/cross-instance-cache:/mnt/cross-instance-cache"]}'
test-container: '{"image":"ghcr.io/electron/build:${{ needs.checkout-linux.outputs.build-image-sha }}","options":"--user root --privileged --init"}'
target-platform: linux
@@ -275,8 +275,8 @@ jobs:
uses: ./.github/workflows/pipeline-electron-build-and-test.yml
needs: checkout-linux
with:
build-runs-on: electron-arc-linux-amd64-32core
test-runs-on: electron-arc-linux-amd64-4core
build-runs-on: electron-arc-centralus-linux-amd64-32core
test-runs-on: electron-arc-centralus-linux-amd64-4core
build-container: '{"image":"ghcr.io/electron/build:${{ needs.checkout-linux.outputs.build-image-sha }}","options":"--user root","volumes":["/mnt/cross-instance-cache:/mnt/cross-instance-cache"]}'
test-container: '{"image":"ghcr.io/electron/build:${{ needs.checkout-linux.outputs.build-image-sha }}","options":"--user root --privileged --init"}'
target-platform: linux
@@ -296,8 +296,8 @@ jobs:
uses: ./.github/workflows/pipeline-electron-build-and-test.yml
needs: checkout-linux
with:
build-runs-on: electron-arc-linux-amd64-32core
test-runs-on: electron-arc-linux-arm64-4core
build-runs-on: electron-arc-centralus-linux-amd64-32core
test-runs-on: electron-arc-centralus-linux-arm64-4core
build-container: '{"image":"ghcr.io/electron/build:${{ needs.checkout-linux.outputs.build-image-sha }}","options":"--user root","volumes":["/mnt/cross-instance-cache:/mnt/cross-instance-cache"]}'
test-container: '{"image":"ghcr.io/electron/test:arm32v7-${{ needs.checkout-linux.outputs.build-image-sha }}","options":"--user root --privileged --init","volumes":["/home/runner/externals:/mnt/runner-externals"]}'
target-platform: linux
@@ -316,8 +316,8 @@ jobs:
uses: ./.github/workflows/pipeline-electron-build-and-test.yml
needs: checkout-linux
with:
build-runs-on: electron-arc-linux-amd64-32core
test-runs-on: electron-arc-linux-arm64-4core
build-runs-on: electron-arc-centralus-linux-amd64-32core
test-runs-on: electron-arc-centralus-linux-arm64-4core
build-container: '{"image":"ghcr.io/electron/build:${{ needs.checkout-linux.outputs.build-image-sha }}","options":"--user root","volumes":["/mnt/cross-instance-cache:/mnt/cross-instance-cache"]}'
test-container: '{"image":"ghcr.io/electron/test:arm64v8-${{ needs.checkout-linux.outputs.build-image-sha }}","options":"--user root --privileged --init"}'
target-platform: linux
@@ -337,7 +337,7 @@ jobs:
needs: checkout-windows
if: ${{ needs.setup.outputs.src == 'true' && !inputs.skip-windows }}
with:
build-runs-on: electron-arc-windows-amd64-16core
build-runs-on: electron-arc-centralus-windows-amd64-16core
test-runs-on: windows-latest
target-platform: win
target-arch: x64
@@ -356,7 +356,7 @@ jobs:
needs: checkout-windows
if: ${{ needs.setup.outputs.src == 'true' && !inputs.skip-windows }}
with:
build-runs-on: electron-arc-windows-amd64-16core
build-runs-on: electron-arc-centralus-windows-amd64-16core
test-runs-on: windows-latest
target-platform: win
target-arch: x86
@@ -375,7 +375,7 @@ jobs:
needs: checkout-windows
if: ${{ needs.setup.outputs.src == 'true' && !inputs.skip-windows }}
with:
build-runs-on: electron-arc-windows-amd64-16core
build-runs-on: electron-arc-centralus-windows-amd64-16core
test-runs-on: electron-hosted-windows-arm64-4core
target-platform: win
target-arch: arm64

View File

@@ -10,7 +10,7 @@ on:
jobs:
clean-src-cache:
runs-on: electron-arc-linux-amd64-32core
runs-on: electron-arc-centralus-linux-amd64-32core
container:
image: ghcr.io/electron/build:bc2f48b2415a670de18d13605b1cf0eb5fdbaae1
options: --user root

View File

@@ -6,7 +6,7 @@ on:
build-image-sha:
type: string
description: 'SHA for electron/build image'
default: '424eedbf277ad9749ffa9219068aa72ed4a5e373'
default: '933c7d6ff6802706875270bec2e3c891cf8add3f'
upload-to-storage:
description: 'Uploads to Azure storage'
required: false
@@ -19,7 +19,7 @@ on:
jobs:
checkout-linux:
runs-on: electron-arc-linux-amd64-32core
runs-on: electron-arc-centralus-linux-amd64-32core
container:
image: ghcr.io/electron/build:${{ inputs.build-image-sha }}
options: --user root
@@ -43,7 +43,7 @@ jobs:
needs: checkout-linux
with:
environment: production-release
build-runs-on: electron-arc-linux-amd64-32core
build-runs-on: electron-arc-centralus-linux-amd64-32core
build-container: '{"image":"ghcr.io/electron/build:${{ inputs.build-image-sha }}","options":"--user root","volumes":["/mnt/cross-instance-cache:/mnt/cross-instance-cache"]}'
target-platform: linux
target-arch: x64
@@ -59,7 +59,7 @@ jobs:
needs: checkout-linux
with:
environment: production-release
build-runs-on: electron-arc-linux-amd64-32core
build-runs-on: electron-arc-centralus-linux-amd64-32core
build-container: '{"image":"ghcr.io/electron/build:${{ inputs.build-image-sha }}","options":"--user root","volumes":["/mnt/cross-instance-cache:/mnt/cross-instance-cache"]}'
target-platform: linux
target-arch: arm
@@ -75,7 +75,7 @@ jobs:
needs: checkout-linux
with:
environment: production-release
build-runs-on: electron-arc-linux-amd64-32core
build-runs-on: electron-arc-centralus-linux-amd64-32core
build-container: '{"image":"ghcr.io/electron/build:${{ inputs.build-image-sha }}","options":"--user root","volumes":["/mnt/cross-instance-cache:/mnt/cross-instance-cache"]}'
target-platform: linux
target-arch: arm64

View File

@@ -6,7 +6,7 @@ on:
build-image-sha:
type: string
description: 'SHA for electron/build image'
default: '424eedbf277ad9749ffa9219068aa72ed4a5e373'
default: '933c7d6ff6802706875270bec2e3c891cf8add3f'
required: true
upload-to-storage:
description: 'Uploads to Azure storage'
@@ -20,7 +20,7 @@ on:
jobs:
checkout-macos:
runs-on: electron-arc-linux-amd64-32core
runs-on: electron-arc-centralus-linux-amd64-32core
container:
image: ghcr.io/electron/build:${{ inputs.build-image-sha }}
options: --user root

View File

@@ -15,7 +15,7 @@ concurrency:
jobs:
docs-only:
name: Docs Only Compile
runs-on: electron-arc-linux-amd64-4core
runs-on: electron-arc-centralus-linux-amd64-4core
timeout-minutes: 20
container: ${{ fromJSON(inputs.container) }}
steps:

View File

@@ -18,7 +18,7 @@ env:
jobs:
lint:
name: Lint
runs-on: electron-arc-linux-amd64-4core
runs-on: electron-arc-centralus-linux-amd64-4core
timeout-minutes: 20
container: ${{ fromJSON(inputs.container) }}
steps:

View File

@@ -73,6 +73,7 @@ env:
SUDOWOODO_EXCHANGE_TOKEN: ${{ secrets.SUDOWOODO_EXCHANGE_TOKEN }}
GCLIENT_EXTRA_ARGS: ${{ inputs.target-platform == 'macos' && '--custom-var=checkout_mac=True --custom-var=host_os=mac' || inputs.target-platform == 'win' && '--custom-var=checkout_win=True' || '--custom-var=checkout_arm=True --custom-var=checkout_arm64=True' }}
ELECTRON_OUT_DIR: Default
ACTIONS_STEP_DEBUG: ${{ secrets.ACTIONS_STEP_DEBUG }}
jobs:
build:
@@ -94,6 +95,15 @@ jobs:
path: src/electron
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: Setup SSH Debugging
if: ${{ inputs.target-platform == 'macos' && env.ACTIONS_STEP_DEBUG == 'true' }}
uses: ./src/electron/.github/actions/ssh-debug
with:
tunnel: 'true'
env:
CLOUDFLARE_TUNNEL_TOKEN: ${{ secrets.CLOUDFLARE_TUNNEL_TOKEN }}
TUNNEL_HOSTNAME: ${{ secrets.CLOUDFLARED_SSH_HOSTNAME }}
AUTHORIZED_USERS: ${{ secrets.SSH_DEBUG_AUTHORIZED_USERS }}
- name: Free up space (macOS)
if: ${{ inputs.target-platform == 'macos' }}
uses: ./src/electron/.github/actions/free-space-macos

View File

@@ -40,6 +40,7 @@ env:
CHROMIUM_GIT_COOKIE_WINDOWS_STRING: ${{ secrets.CHROMIUM_GIT_COOKIE_WINDOWS_STRING }}
ELECTRON_OUT_DIR: Default
ELECTRON_RBE_JWT: ${{ secrets.ELECTRON_RBE_JWT }}
ACTIONS_STEP_DEBUG: ${{ secrets.ACTIONS_STEP_DEBUG }}
jobs:
test:
@@ -100,9 +101,9 @@ jobs:
}
userValuesArray=(
"'kTCCServiceMicrophone','/usr/local/opt/runner/provisioner/provisioner',1,2,4,1,NULL,NULL,0,'UNUSED',NULL,0,1687786159"
"'kTCCServiceCamera','/usr/local/opt/runner/provisioner/provisioner',1,2,4,1,NULL,NULL,0,'UNUSED',NULL,0,1687786159"
"'kTCCServiceBluetoothAlways','/usr/local/opt/runner/provisioner/provisioner',1,2,4,1,NULL,NULL,0,'UNUSED',NULL,0,1687786159"
"'kTCCServiceAppleEvents','/usr/local/opt/runner/provisioner/provisioner',1,2,4,1,NULL,NULL,0,'UNUSED',NULL,0,1687786159"
)
for values in "${userValuesArray[@]}"; do
# Sonoma and higher have a few extra values
@@ -124,6 +125,15 @@ jobs:
path: src/electron
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: Setup SSH Debugging
if: ${{ inputs.target-platform == 'macos' && env.ACTIONS_STEP_DEBUG == 'true' }}
uses: ./src/electron/.github/actions/ssh-debug
with:
tunnel: 'true'
env:
CLOUDFLARE_TUNNEL_TOKEN: ${{ secrets.CLOUDFLARE_TUNNEL_TOKEN }}
TUNNEL_HOSTNAME: ${{ secrets.CLOUDFLARED_SSH_HOSTNAME }}
AUTHORIZED_USERS: ${{ secrets.SSH_DEBUG_AUTHORIZED_USERS }}
- name: Install Dependencies
uses: ./src/electron/.github/actions/install-dependencies
- name: Set Chromium Git Cookie
@@ -135,6 +145,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.
@@ -192,7 +203,6 @@ jobs:
MOCHA_REPORTER: mocha-multi-reporters
MOCHA_MULTI_REPORTERS: mocha-junit-reporter, tap
ELECTRON_DISABLE_SECURITY_WARNINGS: 1
ELECTRON_SKIP_NATIVE_MODULE_TESTS: true
DISPLAY: ':99.0'
NPM_CONFIG_MSVS_VERSION: '2022'
run: |

View File

@@ -38,7 +38,7 @@ env:
jobs:
node-tests:
name: Run Node.js Tests
runs-on: electron-arc-linux-amd64-8core
runs-on: electron-arc-centralus-linux-amd64-8core
timeout-minutes: 30
env:
TARGET_ARCH: ${{ inputs.target-arch }}
@@ -92,7 +92,7 @@ jobs:
done
nan-tests:
name: Run Nan Tests
runs-on: electron-arc-linux-amd64-4core
runs-on: electron-arc-centralus-linux-amd64-4core
timeout-minutes: 30
env:
TARGET_ARCH: ${{ inputs.target-arch }}

View File

@@ -6,7 +6,7 @@ on:
build-image-sha:
type: string
description: 'SHA for electron/build image'
default: '424eedbf277ad9749ffa9219068aa72ed4a5e373'
default: '933c7d6ff6802706875270bec2e3c891cf8add3f'
required: true
upload-to-storage:
description: 'Uploads to Azure storage'
@@ -20,7 +20,7 @@ on:
jobs:
checkout-windows:
runs-on: electron-arc-linux-amd64-32core
runs-on: electron-arc-centralus-linux-amd64-32core
container:
image: ghcr.io/electron/build:${{ inputs.build-image-sha }}
options: --user root --device /dev/fuse --cap-add SYS_ADMIN
@@ -51,7 +51,7 @@ jobs:
needs: checkout-windows
with:
environment: production-release
build-runs-on: electron-arc-windows-amd64-16core
build-runs-on: electron-arc-centralus-windows-amd64-16core
target-platform: win
target-arch: x64
is-release: true
@@ -65,7 +65,7 @@ jobs:
needs: checkout-windows
with:
environment: production-release
build-runs-on: electron-arc-windows-amd64-16core
build-runs-on: electron-arc-centralus-windows-amd64-16core
target-platform: win
target-arch: arm64
is-release: true
@@ -79,7 +79,7 @@ jobs:
needs: checkout-windows
with:
environment: production-release
build-runs-on: electron-arc-windows-amd64-16core
build-runs-on: electron-arc-centralus-windows-amd64-16core
target-platform: win
target-arch: x86
is-release: true

View File

@@ -21,7 +21,9 @@
"ul",
"unknown",
"Tabs",
"TabItem"
"TabItem",
"DocCardList",
"kbd"
]
},
"no-newline-in-links": true

View File

@@ -4,9 +4,9 @@ import("//build/config/win/manifest.gni")
import("//components/os_crypt/sync/features.gni")
import("//components/spellcheck/spellcheck_build_features.gni")
import("//content/public/app/mac_helpers.gni")
import("//content/public/common/features.gni")
import("//extensions/buildflags/buildflags.gni")
import("//pdf/features.gni")
import("//ppapi/buildflags/buildflags.gni")
import("//printing/buildflags/buildflags.gni")
import("//testing/test.gni")
import("//third_party/electron_node/node.gni")
@@ -452,7 +452,7 @@ source_set("electron_lib") {
"//components/certificate_transparency",
"//components/compose:buildflags",
"//components/embedder_support:user_agent",
"//components/input:input",
"//components/input",
"//components/language/core/browser",
"//components/net_log",
"//components/network_hints/browser",
@@ -485,7 +485,7 @@ source_set("electron_lib") {
"//net:extras",
"//net:net_resources",
"//printing/buildflags",
"//services/device/public/cpp/bluetooth:bluetooth",
"//services/device/public/cpp/bluetooth",
"//services/device/public/cpp/geolocation",
"//services/device/public/cpp/hid",
"//services/device/public/mojom",
@@ -727,7 +727,7 @@ source_set("electron_lib") {
"shell/common/extensions/api:extensions_features",
"//chrome/browser/resources:component_extension_resources",
"//components/guest_view/common:mojom",
"//components/update_client:update_client",
"//components/update_client",
"//components/zoom",
"//extensions/browser",
"//extensions/browser/api:api_provider",
@@ -815,7 +815,7 @@ if (is_mac) {
sources = []
public_deps = []
sources += [ "$root_out_dir/libffmpeg.dylib" ]
public_deps += [ "//third_party/ffmpeg:ffmpeg" ]
public_deps += [ "//third_party/ffmpeg" ]
outputs = [ "{{bundle_contents_dir}}/Libraries/{{source_file_part}}" ]
}
} else {
@@ -1230,7 +1230,7 @@ if (is_mac) {
}
if (use_v8_context_snapshot) {
public_deps = [ "//tools/v8_context_snapshot:v8_context_snapshot" ]
public_deps = [ "//tools/v8_context_snapshot" ]
}
if (is_linux) {

6
DEPS
View File

@@ -2,9 +2,9 @@ gclient_gn_args_from = 'src'
vars = {
'chromium_version':
'139.0.7219.0',
'140.0.7327.0',
'node_version':
'v22.16.0',
'v22.18.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

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

View File

@@ -70,6 +70,6 @@ v8_expose_public_symbols = true
# sensitive content by enterprise users.
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

View File

@@ -121,6 +121,7 @@ if ((globalThis.process || binding.process).argv.includes("--profile-electron-in
'electron/main$': electronAPIFile,
'electron/renderer$': electronAPIFile,
'electron/common$': electronAPIFile,
'electron/utility$': electronAPIFile,
// Force timers to resolve to our dependency that doesn't use window.postMessage
timers: path.resolve(electronRoot, 'node_modules', 'timers-browserify', 'main.js')
},

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",
@@ -76,6 +78,8 @@ static_library("chrome") {
"//chrome/browser/platform_util.h",
"//chrome/browser/predictors/preconnect_manager.cc",
"//chrome/browser/predictors/preconnect_manager.h",
"//chrome/browser/predictors/preconnect_manager_impl.cc",
"//chrome/browser/predictors/preconnect_manager_impl.h",
"//chrome/browser/predictors/predictors_features.cc",
"//chrome/browser/predictors/predictors_features.h",
"//chrome/browser/predictors/proxy_lookup_client_impl.cc",
@@ -128,8 +132,12 @@ static_library("chrome") {
"//chrome/browser/ui/views/overlay/hang_up_button.h",
"//chrome/browser/ui/views/overlay/minimize_button.cc",
"//chrome/browser/ui/views/overlay/minimize_button.h",
"//chrome/browser/ui/views/overlay/overlay_controls_fade_animation.cc",
"//chrome/browser/ui/views/overlay/overlay_controls_fade_animation.h",
"//chrome/browser/ui/views/overlay/overlay_window_image_button.cc",
"//chrome/browser/ui/views/overlay/overlay_window_image_button.h",
"//chrome/browser/ui/views/overlay/overlay_window_live_caption_button.cc",
"//chrome/browser/ui/views/overlay/overlay_window_live_caption_button.h",
"//chrome/browser/ui/views/overlay/playback_image_button.cc",
"//chrome/browser/ui/views/overlay/playback_image_button.h",
"//chrome/browser/ui/views/overlay/resize_handle_button.cc",
@@ -142,8 +150,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",
@@ -207,7 +221,7 @@ static_library("chrome") {
"//components/enterprise/common/proto:connectors_proto",
"//components/enterprise/obfuscation/core:enterprise_obfuscation",
"//components/safe_browsing/core/browser/db:safebrowsing_proto",
"//components/vector_icons:vector_icons",
"//components/vector_icons",
"//ui/base/accelerators/global_accelerator_listener",
"//ui/snapshot",
"//ui/views/controls/webview",
@@ -217,8 +231,8 @@ static_library("chrome") {
sources += [
"//chrome/browser/platform_util_aura.cc",
"//chrome/browser/ui/views/eye_dropper/eye_dropper_aura.cc",
"//ui/views/native_window_tracker_aura.cc",
"//ui/views/native_window_tracker_aura.h",
"//ui/native_window_tracker/native_window_tracker_aura.cc",
"//ui/native_window_tracker/native_window_tracker_aura.h",
]
deps += [ "//components/eye_dropper" ]
}

View File

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

View File

@@ -1,8 +1,8 @@
{
"extends": "standard",
"plugins": [
"markdown",
"unicorn"
"import",
"markdown"
],
"overrides": [
{
@@ -30,6 +30,6 @@
"no-undef": "off",
"no-unused-expressions": "off",
"no-unused-vars": "off",
"unicorn/prefer-node-protocol": "error"
"import/enforce-node-protocol-usage": ["error", "always"]
}
}

View File

@@ -1,82 +0,0 @@
# Accelerator
> Define keyboard shortcuts.
Accelerators are strings that can contain multiple modifiers and a single key code,
combined by the `+` character, and are used to define keyboard shortcuts
throughout your application. Accelerators are case insensitive.
Examples:
* `CommandOrControl+A`
* `CommandOrControl+Shift+Z`
Shortcuts are registered with the [`globalShortcut`](global-shortcut.md) module
using the [`register`](global-shortcut.md#globalshortcutregisteraccelerator-callback)
method, i.e.
```js
const { app, globalShortcut } = require('electron')
app.whenReady().then(() => {
// Register a 'CommandOrControl+Y' shortcut listener.
globalShortcut.register('CommandOrControl+Y', () => {
// Do stuff when Y and either Command/Control is pressed.
})
})
```
## Platform notice
On Linux and Windows, the `Command` key does not have any effect so
use `CommandOrControl` which represents `Command` on macOS and `Control` on
Linux and Windows to define some accelerators.
Use `Alt` instead of `Option`. The `Option` key only exists on macOS, whereas
the `Alt` key is available on all platforms.
The `Super` (or `Meta`) key is mapped to the `Windows` key on Windows and Linux and
`Cmd` on macOS.
## Available modifiers
* `Command` (or `Cmd` for short)
* `Control` (or `Ctrl` for short)
* `CommandOrControl` (or `CmdOrCtrl` for short)
* `Alt`
* `Option`
* `AltGr`
* `Shift`
* `Super`
* `Meta`
## Available key codes
* `0` to `9`
* `A` to `Z`
* `F1` to `F24`
* Various Punctuation: `)`, `!`, `@`, `#`, `$`, `%`, `^`, `&`, `*`, `(`, `:`, `;`, `:`, `+`, `=`, `<`, `,`, `_`, `-`, `>`, `.`, `?`, `/`, `~`, `` ` ``, `{`, `]`, `[`, `|`, `\`, `}`, `"`
* `Plus`
* `Space`
* `Tab`
* `Capslock`
* `Numlock`
* `Scrolllock`
* `Backspace`
* `Delete`
* `Insert`
* `Return` (or `Enter` as alias)
* `Up`, `Down`, `Left` and `Right`
* `Home` and `End`
* `PageUp` and `PageDown`
* `Escape` (or `Esc` for short)
* `VolumeUp`, `VolumeDown` and `VolumeMute`
* `MediaNextTrack`, `MediaPreviousTrack`, `MediaStop` and `MediaPlayPause`
* `PrintScreen`
* NumPad Keys
* `num0` - `num9`
* `numdec` - decimal key
* `numadd` - numpad `+` key
* `numsub` - numpad `-` key
* `nummult` - numpad `*` key
* `numdiv` - numpad `÷` key

View File

@@ -602,6 +602,7 @@ Returns `string` - The current application directory.
* `%APPDATA%` on Windows
* `$XDG_CONFIG_HOME` or `~/.config` on Linux
* `~/Library/Application Support` on macOS
* `assets` The directory where app assets such as `resources.pak` are stored. By default this is the same as the folder containing the `exe` path. Available on Windows and Linux only.
* `userData` The directory for storing your app's configuration files, which
by default is the `appData` directory appended with your app's name. By
convention files storing user data should be written to this directory, and
@@ -616,7 +617,7 @@ Returns `string` - The current application directory.
directory.
* `temp` Temporary directory.
* `exe` The current executable file.
* `module` The `libchromiumcontent` library.
* `module` The location of the Chromium module. By default this is synonymous with `exe`.
* `desktop` The current user's Desktop directory.
* `documents` Directory for a user's "My Documents".
* `downloads` Directory for a user's downloads.
@@ -776,6 +777,22 @@ bar, and on macOS, you can visit it from dock menu.
Clears the recent documents list.
### `app.getRecentDocuments()` _macOS_ _Windows_
Returns `string[]` - An array containing documents in the most recent documents list.
```js
const { app } = require('electron')
const path = require('node:path')
const file = path.join(app.getPath('desktop'), 'foo.txt')
app.addRecentDocument(file)
const recents = app.getRecentDocuments()
console.log(recents) // ['/path/to/desktop/foo.txt'}
```
### `app.setAsDefaultProtocolClient(protocol[, path, args])`
* `protocol` string - The name of your protocol, without `://`. For example,

View File

@@ -1260,6 +1260,43 @@ Sets the properties for the window's taskbar button.
> `relaunchCommand` and `relaunchDisplayName` must always be set
> together. If one of those properties is not set, then neither will be used.
#### `win.setAccentColor(accentColor)` _Windows_
* `accentColor` boolean | string - The accent color for the window. By default, follows user preference in System Settings.
Sets the system accent color and highlighting of active window border.
The `accentColor` parameter accepts the following values:
* **Color string** - Sets a custom accent color using standard CSS color formats (Hex, RGB, RGBA, HSL, HSLA, or named colors). Alpha values in RGBA/HSLA formats are ignored and the color is treated as fully opaque.
* **`true`** - Uses the system's default accent color from user preferences in System Settings.
* **`false`** - Explicitly disables accent color highlighting for the window.
Examples:
```js
const win = new BrowserWindow({ frame: false })
// Set red accent color.
win.setAccentColor('#ff0000')
// RGB format (alpha ignored if present).
win.setAccentColor('rgba(255,0,0,0.5)')
// Use system accent color.
win.setAccentColor(true)
// Disable accent color.
win.setAccentColor(false)
```
#### `win.getAccentColor()` _Windows_
Returns `string | boolean` - the system accent color and highlighting of active window border in Hex RGB format.
If a color has been set for the window that differs from the system accent color, the window accent color will
be returned. Otherwise, a boolean will be returned, with `true` indicating that the window uses the global system accent color, and `false` indicating that accent color highlighting is disabled for this window.
#### `win.setIcon(icon)` _Windows_ _Linux_
* `icon` [NativeImage](native-image.md) | string

View File

@@ -1440,6 +1440,43 @@ Sets the properties for the window's taskbar button.
> `relaunchCommand` and `relaunchDisplayName` must always be set
> together. If one of those properties is not set, then neither will be used.
#### `win.setAccentColor(accentColor)` _Windows_
* `accentColor` boolean | string - The accent color for the window. By default, follows user preference in System Settings.
Sets the system accent color and highlighting of active window border.
The `accentColor` parameter accepts the following values:
* **Color string** - Sets a custom accent color using standard CSS color formats (Hex, RGB, RGBA, HSL, HSLA, or named colors). Alpha values in RGBA/HSLA formats are ignored and the color is treated as fully opaque.
* **`true`** - Uses the system's default accent color from user preferences in System Settings.
* **`false`** - Explicitly disables accent color highlighting for the window.
Examples:
```js
const win = new BrowserWindow({ frame: false })
// Set red accent color.
win.setAccentColor('#ff0000')
// RGB format (alpha ignored if present).
win.setAccentColor('rgba(255,0,0,0.5)')
// Use system accent color.
win.setAccentColor(true)
// Disable accent color.
win.setAccentColor(false)
```
#### `win.getAccentColor()` _Windows_
Returns `string | boolean` - the system accent color and highlighting of active window border in Hex RGB format.
If a color has been set for the window that differs from the system accent color, the window accent color will
be returned. Otherwise, a boolean will be returned, with `true` indicating that the window uses the global system accent color, and `false` indicating that accent color highlighting is disabled for this window.
#### `win.showDefinitionForSelection()` _macOS_
Same as `webContents.showDefinitionForSelection()`.
@@ -1533,8 +1570,8 @@ events.
Prevents the window contents from being captured by other apps.
On macOS it sets the NSWindow's sharingType to NSWindowSharingNone.
On Windows it calls SetWindowDisplayAffinity with `WDA_EXCLUDEFROMCAPTURE`.
On macOS it sets the NSWindow's [`sharingType`](https://developer.apple.com/documentation/appkit/nswindow/sharingtype-swift.property?language=objc) to [`NSWindowSharingNone`](https://developer.apple.com/documentation/appkit/nswindow/sharingtype-swift.enum/none?language=objc).
On Windows it calls [`SetWindowDisplayAffinity`](https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-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.

View File

@@ -292,7 +292,7 @@ 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-inspector`
### `--experimental-network-inspection`
Enable support for devtools network inspector events, for visibility into requests made by the nodejs `http` and `https` modules.

View File

@@ -51,19 +51,17 @@ Use the `system-ui` keyword to match the smoothness to the OS design language.
### Controlling availibility
This CSS rule can be disabled by setting [the `cornerSmoothingCSS` web preference](./structures/web-preferences.md) to `false`.
This CSS rule can be disabled using the Blink feature flag `ElectronCSSCornerSmoothing`.
```js
const myWindow = new BrowserWindow({
// [...]
webPreferences: {
enableCornerSmoothingCSS: false // Disables the `-electron-corner-smoothing` CSS rule
disableBlinkFeatures: 'ElectronCSSCornerSmoothing' // Disables the `-electron-corner-smoothing` CSS rule
}
})
```
The CSS rule will still parse, but will have no visual effect.
### Formal reference
* **Initial value**: `0%`

View File

@@ -63,7 +63,7 @@ The `crashReporter` module has the following methods:
* `extra` Record\<string, string\> (optional) - Extra string key/value
annotations that will be sent along with crash reports that are generated
in the main process. Only string values are supported. Crashes generated in
child processes will not contain these extra
child processes will not include these extra parameters. To add extra
parameters to crash reports generated from child processes, call
[`addExtraParameter`](#crashreporteraddextraparameterkey-value) from the
child process.

View File

@@ -5,13 +5,8 @@
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._
The following example shows how to bounce your icon on the dock.
```js
const { app } = require('electron')
app.dock?.bounce()
```
> [!TIP]
> See also: [A detailed guide about how to implement Dock menus](../tutorial/macos-dock.md).
### Instance Methods
@@ -50,6 +45,9 @@ Bounces the Downloads stack if the filePath is inside the Downloads folder.
Sets the string to be displayed in the docks badging area.
> [!IMPORTANT]
> You need to ensure that your application has the permission to display notifications for this method to work.
#### `dock.getBadge()` _macOS_
Returns `string` - The badge string of the dock.

View File

@@ -125,13 +125,13 @@ Options:
* `kioclient5`
* `kioclient`
### `ELECTRON_OZONE_PLATFORM_HINT` _Linux_
### `ELECTRON_OZONE_PLATFORM_HINT` _Linux_ _Deprecated_
Selects the preferred platform backend used on Linux. The default one is `x11`. `auto` selects Wayland if possible, X11 otherwise.
Selects the preferred platform backend used on Linux. `auto` selects Wayland if possible, X11 otherwise.
Options:
* `auto`
* `auto` (Default)
* `wayland`
* `x11`

View File

@@ -46,13 +46,16 @@ app.on('will-quit', () => {
})
```
> [!TIP]
> See also: [A detailed guide on Keyboard Shortcuts](../tutorial/keyboard-shortcuts.md).
## Methods
The `globalShortcut` module has the following methods:
### `globalShortcut.register(accelerator, callback)`
* `accelerator` [Accelerator](accelerator.md)
* `accelerator` string - An [accelerator](../tutorial/keyboard-shortcuts.md#accelerators) shortcut.
* `callback` Function
Returns `boolean` - Whether or not the shortcut was registered successfully.
@@ -74,7 +77,7 @@ the app has been authorized as a [trusted accessibility client](https://develope
### `globalShortcut.registerAll(accelerators, callback)`
* `accelerators` [Accelerator](accelerator.md)[] - an array of [Accelerator](accelerator.md)s.
* `accelerators` string[] - An array of [accelerator](../tutorial/keyboard-shortcuts.md#accelerators) shortcuts.
* `callback` Function
Registers a global shortcut of all `accelerator` items in `accelerators`. The `callback` is called when any of the registered shortcuts are pressed by the user.
@@ -93,7 +96,7 @@ the app has been authorized as a [trusted accessibility client](https://develope
### `globalShortcut.isRegistered(accelerator)`
* `accelerator` [Accelerator](accelerator.md)
* `accelerator` string - An [accelerator](../tutorial/keyboard-shortcuts.md#accelerators) shortcut.
Returns `boolean` - Whether this application has registered `accelerator`.
@@ -103,7 +106,7 @@ don't want applications to fight for global shortcuts.
### `globalShortcut.unregister(accelerator)`
* `accelerator` [Accelerator](accelerator.md)
* `accelerator` string - An [accelerator](../tutorial/keyboard-shortcuts.md#accelerators) shortcut.
Unregisters the global shortcut of `accelerator`.

View File

@@ -19,7 +19,7 @@ See [`Menu`](menu.md) for examples.
* `window` [BaseWindow](base-window.md) | undefined - This will not be defined if no window is open.
* `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).
`click` property will be ignored. See [roles](../tutorial/menus.md#roles).
* `type` string (optional)
* `normal`
* `separator`
@@ -31,7 +31,7 @@ See [`Menu`](menu.md) for examples.
* `label` 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)
* `accelerator` string (optional) - An [Accelerator](../tutorial/keyboard-shortcuts.md#accelerators) string.
* `icon` ([NativeImage](native-image.md) | string) (optional)
* `enabled` boolean (optional) - If false, the menu item will be greyed out and
unclickable.
@@ -64,88 +64,13 @@ See [`Menu`](menu.md) for examples.
> [!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
Roles allow menu items to have predefined behaviors.
It is best to specify `role` for any menu item that matches a standard role,
rather than trying to manually implement the behavior in a `click` function.
The built-in `role` behavior will give the best native experience.
The `label` and `accelerator` values are optional when using a `role` and will
default to appropriate values for each platform.
Every menu item must have either a `role`, `label`, or in the case of a separator
a `type`.
The `role` property can have following values:
* `undo`
* `about` - Trigger a native about panel (custom message box on Window, which does not provide its own).
* `redo`
* `cut`
* `copy`
* `paste`
* `pasteAndMatchStyle`
* `selectAll`
* `delete`
* `minimize` - Minimize current window.
* `close` - Close current window.
* `quit` - Quit the application.
* `reload` - Reload the current window.
* `forceReload` - Reload the current window ignoring the cache.
* `toggleDevTools` - Toggle developer tools in the current window.
* `togglefullscreen` - Toggle full screen mode on the current window.
* `resetZoom` - Reset the focused page's zoom level to the original size.
* `zoomIn` - Zoom in the focused page by 10%.
* `zoomOut` - Zoom out the focused page by 10%.
* `toggleSpellChecker` - Enable/disable builtin spell checker.
* `fileMenu` - Whole default "File" menu (Close / Quit)
* `editMenu` - Whole default "Edit" menu (Undo, Copy, etc.).
* `viewMenu` - Whole default "View" menu (Reload, Toggle Developer Tools, etc.)
* `windowMenu` - Whole default "Window" menu (Minimize, Zoom, etc.).
The following additional roles are available on _macOS_:
* `appMenu` - Whole default "App" menu (About, Services, etc.)
* `hide` - Map to the `hide` action.
* `hideOthers` - Map to the `hideOtherApplications` action.
* `unhide` - Map to the `unhideAllApplications` action.
* `showSubstitutions` - Map to the `orderFrontSubstitutionsPanel` action.
* `toggleSmartQuotes` - Map to the `toggleAutomaticQuoteSubstitution` action.
* `toggleSmartDashes` - Map to the `toggleAutomaticDashSubstitution` action.
* `toggleTextReplacement` - Map to the `toggleAutomaticTextReplacement` action.
* `startSpeaking` - Map to the `startSpeaking` action.
* `stopSpeaking` - Map to the `stopSpeaking` action.
* `front` - Map to the `arrangeInFront` action.
* `zoom` - Map to the `performZoom` action.
* `toggleTabBar` - Map to the `toggleTabBar` action.
* `selectNextTab` - Map to the `selectNextTab` action.
* `selectPreviousTab` - Map to the `selectPreviousTab` action.
* `showAllTabs` - Map to the `showAllTabs` action.
* `mergeAllWindows` - Map to the `mergeAllWindows` action.
* `moveTabToNewWindow` - Map to the `moveTabToNewWindow` action.
* `window` - The submenu is a "Window" menu.
* `help` - The submenu is a "Help" menu.
* `services` - The submenu is a ["Services"](https://developer.apple.com/documentation/appkit/nsapplication/1428608-servicesmenu?language=objc) menu. This is only intended for use in the Application Menu and is _not_ the same as the "Services" submenu used in context menus in macOS apps, which is not implemented in Electron.
* `recentDocuments` - The submenu is an "Open Recent" menu.
* `clearRecentDocuments` - Map to the `clearRecentDocuments` action.
* `shareMenu` - The submenu is [share menu][ShareMenu]. The `sharingItem` property must also be set to indicate the item to share.
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.
### Instance Properties
The following properties are available on instances of `MenuItem`:
#### `menuItem.id`
A `string` indicating the item's unique id, this property can be
A `string` indicating the item's unique id. This property can be
dynamically changed.
#### `menuItem.label`
@@ -203,17 +128,17 @@ A `string` indicating the item's hover text.
#### `menuItem.enabled`
A `boolean` indicating whether the item is enabled, this property can be
A `boolean` indicating whether the item is enabled. This property can be
dynamically changed.
#### `menuItem.visible`
A `boolean` indicating whether the item is visible, this property can be
A `boolean` indicating whether the item is visible. This property can be
dynamically changed.
#### `menuItem.checked`
A `boolean` indicating whether the item is checked, this property can be
A `boolean` indicating whether the item is checked. This property can be
dynamically changed.
A `checkbox` menu item will toggle the `checked` property on and off when
@@ -244,5 +169,3 @@ A `number` indicating an item's sequential unique id.
#### `menuItem.menu`
A `Menu` that the item is a part of.
[ShareMenu]: https://developer.apple.com/design/human-interface-guidelines/macos/extensions/share-extensions/

View File

@@ -6,6 +6,9 @@
Process: [Main](../glossary.md#main-process)
> [!TIP]
> See also: [A detailed guide about how to implement menus in your application](../tutorial/menus.md).
> [!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).
@@ -20,7 +23,7 @@ The `Menu` class has the following static methods:
#### `Menu.setApplicationMenu(menu)`
* `menu` Menu | null
- `menu` Menu | null
Sets `menu` as the application menu on macOS. On Windows and Linux, the
`menu` will be set as each window's top menu.
@@ -51,18 +54,18 @@ Returns `Menu | null` - The application menu, if set, or `null`, if not set.
#### `Menu.sendActionToFirstResponder(action)` _macOS_
* `action` string
- `action` string
Sends the `action` to the first responder of application. This is used for
emulating default macOS menu behaviors. Usually you would use the
[`role`](menu-item.md#roles) property of a [`MenuItem`](menu-item.md).
[`role`](../tutorial/menus.md#roles) property of a [`MenuItem`](menu-item.md).
See the [macOS Cocoa Event Handling Guide](https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/EventOverview/EventArchitecture/EventArchitecture.html#//apple_ref/doc/uid/10000060i-CH3-SW7)
for more information on macOS' native actions.
#### `Menu.buildFromTemplate(template)`
* `template` (MenuItemConstructorOptions | MenuItem)[]
- `template` (MenuItemConstructorOptions | MenuItem)[]
Returns `Menu`
@@ -77,47 +80,50 @@ The `menu` object has the following instance methods:
#### `menu.popup([options])`
* `options` Object (optional)
* `window` [BaseWindow](base-window.md) (optional) - Default is the focused window.
* `frame` [WebFrameMain](web-frame-main.md) (optional) - Provide the relevant frame
- `options` Object (optional)
- `window` [BaseWindow](base-window.md) (optional) - Default is the focused window.
- `frame` [WebFrameMain](web-frame-main.md) (optional) - Provide the relevant frame
if you want certain OS-level features such as Writing Tools on macOS to function correctly. Typically, this should be `params.frame` from the [`context-menu` event](web-contents.md#event-context-menu) on a WebContents, or the [`focusedFrame` property](web-contents.md#contentsfocusedframe-readonly) of a WebContents.
* `x` number (optional) - Default is the current mouse cursor position.
- `x` number (optional) - Default is the current mouse cursor position.
Must be declared if `y` is declared.
* `y` number (optional) - Default is the current mouse cursor position.
- `y` number (optional) - Default is the current mouse cursor position.
Must be declared if `x` is declared.
* `positioningItem` number (optional) _macOS_ - The index of the menu item to
- `positioningItem` number (optional) _macOS_ - The index of the menu item to
be positioned under the mouse cursor at the specified coordinates. Default
is -1.
* `sourceType` string (optional) _Windows_ _Linux_ - This should map to the `menuSourceType`
- `sourceType` string (optional) _Windows_ _Linux_ - This should map to the `menuSourceType`
provided by the `context-menu` event. It is not recommended to set this value manually,
only provide values you receive from other APIs or leave it `undefined`.
Can be `none`, `mouse`, `keyboard`, `touch`, `touchMenu`, `longPress`, `longTap`, `touchHandle`, `stylus`, `adjustSelection`, or `adjustSelectionReset`.
* `callback` Function (optional) - Called when menu is closed.
- `callback` Function (optional) - Called when menu is closed.
Pops up this menu as a context menu in the [`BaseWindow`](base-window.md).
> [!TIP]
> For more details, see the [Context Menu](../tutorial/context-menu.md) guide.
#### `menu.closePopup([window])`
* `window` [BaseWindow](base-window.md) (optional) - Default is the focused window.
- `window` [BaseWindow](base-window.md) (optional) - Default is the focused window.
Closes the context menu in the `window`.
#### `menu.append(menuItem)`
* `menuItem` [MenuItem](menu-item.md)
- `menuItem` [MenuItem](menu-item.md)
Appends the `menuItem` to the menu.
#### `menu.getMenuItemById(id)`
* `id` string
- `id` string
Returns `MenuItem | null` the item with the specified `id`
#### `menu.insert(pos, menuItem)`
* `pos` Integer
* `menuItem` [MenuItem](menu-item.md)
- `pos` Integer
- `menuItem` [MenuItem](menu-item.md)
Inserts the `menuItem` to the `pos` position of the menu.
@@ -133,7 +139,7 @@ Objects created with `new Menu` or returned by `Menu.buildFromTemplate` emit the
Returns:
* `event` Event
- `event` Event
Emitted when `menu.popup()` is called.
@@ -141,7 +147,7 @@ Emitted when `menu.popup()` is called.
Returns:
* `event` Event
- `event` Event
Emitted when a popup is closed either manually or with `menu.closePopup()`.
@@ -153,296 +159,5 @@ Emitted when a popup is closed either manually or with `menu.closePopup()`.
A `MenuItem[]` array containing the menu's items.
Each `Menu` consists of multiple [`MenuItem`](menu-item.md)s and each `MenuItem`
can have a submenu.
## Examples
An example of creating the application menu with the simple template API:
```js @ts-expect-error=[107]
const { app, Menu } = require('electron')
const isMac = process.platform === 'darwin'
const template = [
// { role: 'appMenu' }
...(isMac
? [{
label: app.name,
submenu: [
{ role: 'about' },
{ type: 'separator' },
{ role: 'services' },
{ type: 'separator' },
{ role: 'hide' },
{ role: 'hideOthers' },
{ role: 'unhide' },
{ type: 'separator' },
{ role: 'quit' }
]
}]
: []),
// { role: 'fileMenu' }
{
label: 'File',
submenu: [
isMac ? { role: 'close' } : { role: 'quit' }
]
},
// { role: 'editMenu' }
{
label: 'Edit',
submenu: [
{ role: 'undo' },
{ role: 'redo' },
{ type: 'separator' },
{ role: 'cut' },
{ role: 'copy' },
{ role: 'paste' },
...(isMac
? [
{ role: 'pasteAndMatchStyle' },
{ role: 'delete' },
{ role: 'selectAll' },
{ type: 'separator' },
{
label: 'Speech',
submenu: [
{ role: 'startSpeaking' },
{ role: 'stopSpeaking' }
]
}
]
: [
{ role: 'delete' },
{ type: 'separator' },
{ role: 'selectAll' }
])
]
},
// { role: 'viewMenu' }
{
label: 'View',
submenu: [
{ role: 'reload' },
{ role: 'forceReload' },
{ role: 'toggleDevTools' },
{ type: 'separator' },
{ role: 'resetZoom' },
{ role: 'zoomIn' },
{ role: 'zoomOut' },
{ type: 'separator' },
{ role: 'togglefullscreen' }
]
},
// { role: 'windowMenu' }
{
label: 'Window',
submenu: [
{ role: 'minimize' },
{ role: 'zoom' },
...(isMac
? [
{ type: 'separator' },
{ role: 'front' },
{ type: 'separator' },
{ role: 'window' }
]
: [
{ role: 'close' }
])
]
},
{
role: 'help',
submenu: [
{
label: 'Learn More',
click: async () => {
const { shell } = require('electron')
await shell.openExternal('https://electronjs.org')
}
}
]
}
]
const menu = Menu.buildFromTemplate(template)
Menu.setApplicationMenu(menu)
```
### Render process
To create menus initiated by the renderer process, send the required
information to the main process using IPC and have the main process display the
menu on behalf of the renderer.
Below is an example of showing a menu when the user right clicks the page:
```js @ts-expect-error=[21]
// renderer
window.addEventListener('contextmenu', (e) => {
e.preventDefault()
ipcRenderer.send('show-context-menu')
})
ipcRenderer.on('context-menu-command', (e, command) => {
// ...
})
// main
ipcMain.on('show-context-menu', (event) => {
const template = [
{
label: 'Menu Item 1',
click: () => { event.sender.send('context-menu-command', 'menu-item-1') }
},
{ type: 'separator' },
{ label: 'Menu Item 2', type: 'checkbox', checked: true }
]
const menu = Menu.buildFromTemplate(template)
menu.popup({ window: BrowserWindow.fromWebContents(event.sender) })
})
```
## Notes on macOS Application Menu
macOS has a completely different style of application menu from Windows and
Linux. Here are some notes on making your app's menu more native-like.
### Standard Menus
On macOS there are many system-defined standard menus, like the [`Services`](https://developer.apple.com/documentation/appkit/nsapplication/1428608-servicesmenu?language=objc) and
`Windows` menus. To make your menu a standard menu, you should set your menu's
`role` to one of the following and Electron will recognize them and make them
become standard menus:
* `window`
* `help`
* `services`
### Standard Menu Item Actions
macOS has provided standard actions for some menu items, like `About xxx`,
`Hide xxx`, and `Hide Others`. To set the action of a menu item to a standard
action, you should set the `role` attribute of the menu item.
### Main Menu's Name
On macOS the label of the application menu's first item is always your app's
name, no matter what label you set. To change it, modify your app bundle's
`Info.plist` file. See
[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
browser windows.
## Menu Item Position
You can make use of `before`, `after`, `beforeGroupContaining`, `afterGroupContaining` and `id` to control how the item will be placed when building a menu with `Menu.buildFromTemplate`.
* `before` - Inserts this item before the item with the specified id. If the
referenced item doesn't exist the item will be inserted at the end of
the menu. Also implies that the menu item in question should be placed in the same “group” as the item.
* `after` - Inserts this item after the item with the specified id. If the
referenced item doesn't exist the item will be inserted at the end of
the menu. Also implies that the menu item in question should be placed in the same “group” as the item.
* `beforeGroupContaining` - Provides a means for a single context menu to declare
the placement of their containing group before the containing group of the item with the specified id.
* `afterGroupContaining` - Provides a means for a single context menu to declare
the placement of their containing group after the containing group of the item with the specified id.
By default, items will be inserted in the order they exist in the template unless one of the specified positioning keywords is used.
### Examples
Template:
```js
[
{ id: '1', label: 'one' },
{ id: '2', label: 'two' },
{ id: '3', label: 'three' },
{ id: '4', label: 'four' }
]
```
Menu:
```sh
- 1
- 2
- 3
- 4
```
Template:
```js
[
{ id: '1', label: 'one' },
{ type: 'separator' },
{ id: '3', label: 'three', beforeGroupContaining: ['1'] },
{ id: '4', label: 'four', afterGroupContaining: ['2'] },
{ type: 'separator' },
{ id: '2', label: 'two' }
]
```
Menu:
```sh
- 3
- 4
- ---
- 1
- ---
- 2
```
Template:
```js
[
{ id: '1', label: 'one', after: ['3'] },
{ id: '2', label: 'two', before: ['1'] },
{ id: '3', label: 'three' }
]
```
Menu:
```sh
- ---
- 3
- 2
- 1
```
[AboutInformationPropertyListFiles]: https://developer.apple.com/library/ios/documentation/general/Reference/InfoPlistKeyReference/Articles/AboutInformationPropertyListFiles.html
[setMenu]: browser-window.md#winsetmenumenu-linux-windows
Each `Menu` consists of multiple [`MenuItem`](menu-item.md) instances and each `MenuItem`
can nest a `Menu` into its `submenu` property.

View File

@@ -2,5 +2,5 @@
* `type` string - The type of the event, can be `rawKeyDown`, `keyDown`, `keyUp` or `char`.
* `keyCode` string - The character that will be sent
as the keyboard event. Should only use the valid key codes in
[Accelerator](../accelerator.md).
as the keyboard event. Should only use valid [Accelerator](../../tutorial/keyboard-shortcuts.md#accelerators)
key codes.

View File

@@ -149,7 +149,6 @@
`WebContents` when the preferred size changes. Default is `false`.
* `transparent` boolean (optional) - Whether to enable background transparency for the guest page. Default is `true`. **Note:** The guest page's text and background colors are derived from the [color scheme](https://developer.mozilla.org/en-US/docs/Web/CSS/color-scheme) of its root element. When transparency is enabled, the text color will still change accordingly but the background will remain transparent.
* `enableDeprecatedPaste` boolean (optional) _Deprecated_ - Whether to enable the `paste` [execCommand](https://developer.mozilla.org/en-US/docs/Web/API/Document/execCommand). Default is `false`.
* `enableCornerSmoothingCSS` boolean (optional) _Experimental_ - Whether the [`-electron-corner-smoothing` CSS rule](../corner-smoothing-css.md) is enabled. Default is `true`.
[chrome-content-scripts]: https://developer.chrome.com/extensions/content_scripts#execution-environment
[runtime-enabled-features]: https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/platform/runtime_enabled_features.json5

View File

@@ -8,7 +8,7 @@ Process: [Main](../glossary.md#main-process)
`Tray` is an [EventEmitter][event-emitter].
```js
```js title='Creating a basic tray menu'
const { app, Menu, Tray } = require('electron')
let tray = null
@@ -25,6 +25,9 @@ app.whenReady().then(() => {
})
```
> [!TIP]
> See also: [A detailed guide about how to implement Tray menus](../tutorial/tray.md).
> [!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).
@@ -329,3 +332,47 @@ The `bounds` of this tray icon as `Object`.
Returns `boolean` - Whether the tray icon is destroyed.
[event-emitter]: https://nodejs.org/api/events.html#events_class_eventemitter
## Platform considerations
### Linux
* Tray icon uses [StatusNotifierItem](https://www.freedesktop.org/wiki/Specifications/StatusNotifierItem/)
by default, when it is not available in user's desktop environment the
`GtkStatusIcon` will be used instead.
* The `click` event is emitted when the tray icon receives activation from
user, however the StatusNotifierItem spec does not specify which action would
cause an activation, for some environments it is left mouse click, but for
some it might be double left mouse click.
* In order for changes made to individual `MenuItem`s to take effect,
you have to call `setContextMenu` again. For example:
```js
const { app, Menu, Tray } = require('electron')
let appIcon = null
app.whenReady().then(() => {
appIcon = new Tray('/path/to/my/icon')
const contextMenu = Menu.buildFromTemplate([
{ label: 'Item1', type: 'radio' },
{ label: 'Item2', type: 'radio' }
])
// Make a change to the context menu
contextMenu.items[1].checked = false
// Call this again for Linux because we modified the context menu
appIcon.setContextMenu(contextMenu)
})
```
### macOS
* Icons passed to the Tray constructor should be [Template Images](native-image.md#template-image-macos).
* To make sure your icon isn't grainy on retina monitors, be sure your `@2x` image is 144dpi.
* If you are bundling your application (e.g., with webpack for development), be sure that the file names are not being mangled or hashed. The filename needs to end in Template, and the `@2x` image needs to have the same filename as the standard image, or MacOS will not magically invert your image's colors or use the high density image.
* 16x16 (72dpi) and 32x32@2x (144dpi) work well for most icons.
### Windows
* It is recommended to use `ICO` icons to get best visual effects.

View File

@@ -486,16 +486,6 @@ Emitted when the web page becomes unresponsive.
Emitted when the unresponsive web page becomes responsive again.
#### Event: 'plugin-crashed'
Returns:
* `event` Event
* `name` string
* `version` string
Emitted when a plugin process has crashed.
#### Event: 'destroyed'
Emitted when `webContents` is destroyed.

View File

@@ -66,6 +66,16 @@ These methods can be accessed from the `webFrameMain` module:
Returns `WebFrameMain | undefined` - A frame with the given process and routing IDs,
or `undefined` if there is no WebFrameMain associated with the given IDs.
### `webFrameMain.fromFrameToken(processId, frameToken)`
* `processId` Integer - An `Integer` representing the internal ID of the process which owns the frame.
* `frameToken` string - A `string` token identifying the unique frame. Can also
be retrieved in the renderer process via
[`webFrame.frameToken`](web-frame.md#webframeframetoken-readonly).
Returns `WebFrameMain | null` - A frame with the given process and frame token,
or `null` if there is no WebFrameMain associated with the given IDs.
## Class: WebFrameMain
Process: [Main](../glossary.md#main-process)<br />
@@ -237,6 +247,11 @@ not used again.
A `string` representing the frame name.
#### `frame.frameToken` _Readonly_
A `string` which uniquely identifies the frame within its associated renderer
process. This is equivalent to [`webFrame.frameToken`](web-frame.md#webframeframetoken-readonly).
#### `frame.osProcessId` _Readonly_
An `Integer` representing the operating system `pid` of the process which owns this frame.

View File

@@ -67,7 +67,7 @@ Sets the maximum and minimum pinch-to-zoom level.
> [!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
> Menu. To disable shortcuts, manually [define the Menu](../tutorial/menus.md) and omit zoom roles
> from the definition.
### `webFrame.setSpellCheckProvider(language, provider)`
@@ -253,7 +253,7 @@ and intend to stay there).
* `selector` string - CSS selector for a frame element.
Returns `WebFrame` - The frame element in `webFrame's` document selected by
Returns `WebFrame | null` - The frame element in `webFrame's` document selected by
`selector`, `null` would be returned if `selector` does not select a frame or
if the frame is not in the current renderer process.
@@ -261,18 +261,29 @@ if the frame is not in the current renderer process.
* `name` string
Returns `WebFrame` - A child of `webFrame` with the supplied `name`, `null`
Returns `WebFrame | null` - A child of `webFrame` with the supplied `name`, `null`
would be returned if there's no such frame or if the frame is not in the current
renderer process.
### `webFrame.findFrameByRoutingId(routingId)`
### `webFrame.findFrameByRoutingId(routingId)` _Deprecated_
* `routingId` Integer - An `Integer` representing the unique frame id in the
current renderer process. Routing IDs can be retrieved from `WebFrame`
instances (`webFrame.routingId`) and are also passed by frame
specific `WebContents` navigation events (e.g. `did-frame-navigate`)
Returns `WebFrame` - that has the supplied `routingId`, `null` if not found.
Returns `WebFrame | null` - that has the supplied `routingId`, `null` if not found.
**Deprecated:** Use the new `webFrame.findFrameByToken` API.
### `webFrame.findFrameByToken(frameToken)`
* `frameToken` string - A `string` representing the unique frame id in the
current renderer process. Frame tokens can be retrieved from `WebFrame`
instances (`webFrame.frameToken`) and can also be retrieved from
`WebFrameMain` instances using `webFrameMain.frameToken`.
Returns `WebFrame | null` - that has the supplied `frameToken`, `null` if not found.
### `webFrame.isWordMisspelled(word)`
@@ -318,8 +329,16 @@ A `WebFrame | null` representing next sibling frame, the property would be `null
`webFrame` is the last frame in its parent or if the next sibling is not in the
current renderer process.
### `webFrame.routingId` _Readonly_
### `webFrame.routingId` _Readonly_ _Deprecated_
An `Integer` representing the unique frame id in the current renderer process.
Distinct WebFrame instances that refer to the same underlying frame will have
the same `routingId`.
**Deprecated:** Use the new `webFrame.frameToken` API.
### `webFrame.frameToken` _Readonly_
A `string` representing the unique frame token in the current renderer process.
Distinct WebFrame instances that refer to the same underlying frame will have
the same `frameToken`.

View File

@@ -1002,15 +1002,6 @@ Returns:
Fired when the renderer process unexpectedly disappears. This is normally
because it was crashed or killed.
### Event: 'plugin-crashed'
Returns:
* `name` string
* `version` string
Fired when a plugin process is crashed.
### Event: 'destroyed'
Fired when the WebContents is destroyed.

View File

@@ -14,6 +14,14 @@ This document uses the following convention to categorize breaking changes:
## Planned Breaking API Changes (38.0)
### Deprecated: `ELECTRON_OZONE_PLATFORM_HINT` environment variable
The default value of the `--ozone-plaftform` flag [changed to `auto`](https://chromium-review.googlesource.com/c/chromium/src/+/6775426).
You should use the `XDG_SESSION_TYPE=wayland` environment variable instead to use Wayland.
This environment variable will be [removed soon](https://chromium-review.googlesource.com/c/chromium/src/+/6819616).
### Removed: macOS 11 support
macOS 11 (Big Sur) is no longer supported by [Chromium](https://chromium-review.googlesource.com/c/chromium/src/+/6594615).
@@ -21,6 +29,22 @@ macOS 11 (Big Sur) is no longer supported by [Chromium](https://chromium-review.
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.
### Removed: `plugin-crashed` event
The `plugin-crashed` event has been removed from `webContents`.
### Deprecated: `webFrame.routingId` property
The `routingId` property will be removed from `webFrame` objects.
You should use `webFrame.frameToken` instead.
### Deprecated: `webFrame.findFrameByRoutingId(routingId)`
The `webFrame.findFrameByRoutingId(routingId)` function will be removed.
You should use `webFrame.findFrameByToken(frameToken)` instead.
## Planned Breaking API Changes (37.0)
### Utility Process unhandled rejection behavior change

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

View File

@@ -60,12 +60,12 @@ namespace electron {
namespace api {
class ApiName : public gin::Wrappable<ApiName> {
class ApiName : public gin::DeprecatedWrappable<ApiName> {
public:
static gin::Handle<ApiName> Create(v8::Isolate* isolate);
// gin::Wrappable
static gin::WrapperInfo kWrapperInfo;
static gin::DeprecatedWrapperInfo kWrapperInfo;
gin::ObjectTemplateBuilder GetObjectTemplateBuilder(
v8::Isolate* isolate) override;
const char* GetTypeName() override;
@@ -90,7 +90,7 @@ namespace electron {
namespace api {
gin::WrapperInfo ApiName::kWrapperInfo = {gin::kEmbedderNativeGin};
gin::DeprecatedWrapperInfo ApiName::kWrapperInfo = {gin::kEmbedderNativeGin};
gin::ObjectTemplateBuilder ApiName::GetObjectTemplateBuilder(
v8::Isolate* isolate) {
@@ -117,7 +117,7 @@ void Initialize(v8::Local<v8::Object> exports,
v8::Local<v8::Value> unused,
v8::Local<v8::Context> context,
void* priv) {
v8::Isolate* isolate = context->GetIsolate();
v8::Isolate* const isolate = v8::Isolate::GetCurrent();
gin_helper::Dictionary dict(isolate, exports);
dict.Set("apiName", electron::api::ApiName::Create(isolate));
}

View File

@@ -1,12 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Hello World!</title>
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline';" />
</head>
<body>
<h1>Hello World!</h1>
<p>Hit Alt+Ctrl+I on Windows or Opt+Cmd+I on Mac to see a message printed to the console.</p>
</body>
</html>

View File

@@ -1,28 +0,0 @@
const { app, BrowserWindow, globalShortcut } = require('electron/main')
function createWindow () {
const win = new BrowserWindow({
width: 800,
height: 600
})
win.loadFile('index.html')
}
app.whenReady().then(() => {
globalShortcut.register('Alt+CommandOrControl+I', () => {
console.log('Electron loves global shortcuts!')
})
}).then(createWindow)
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
})
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow()
}
})

View File

@@ -1,12 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Hello World!</title>
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline';" />
</head>
<body>
<h1>Hello World!</h1>
<p>Hit Alt+Shift+I on Windows, or Opt+Cmd+I on mac to see a message printed to the console.</p>
</body>
</html>

View File

@@ -1,36 +0,0 @@
const { app, BrowserWindow, Menu, MenuItem } = require('electron/main')
function createWindow () {
const win = new BrowserWindow({
width: 800,
height: 600
})
win.loadFile('index.html')
}
const menu = new Menu()
menu.append(new MenuItem({
label: 'Electron',
submenu: [{
role: 'help',
accelerator: process.platform === 'darwin' ? 'Alt+Cmd+I' : 'Alt+Shift+I',
click: () => { console.log('Electron rocks!') }
}]
}))
Menu.setApplicationMenu(menu)
app.whenReady().then(createWindow)
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
})
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow()
}
})

View File

@@ -1,12 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Hello World!</title>
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline';" />
</head>
<body>
<h1>Hello World!</h1>
<p>Right click the dock icon to see the custom menu options.</p>
</body>
</html>

View File

@@ -1,40 +0,0 @@
const { app, BrowserWindow, Menu } = require('electron/main')
function createWindow () {
const win = new BrowserWindow({
width: 800,
height: 600
})
win.loadFile('index.html')
}
const dockMenu = Menu.buildFromTemplate([
{
label: 'New Window',
click () { console.log('New Window') }
}, {
label: 'New Window with Settings',
submenu: [
{ label: 'Basic' },
{ label: 'Pro' }
]
},
{ label: 'New Command...' }
])
app.whenReady().then(() => {
app.dock?.setMenu(dockMenu)
}).then(createWindow)
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
})
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow()
}
})

View File

@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'">
<title>Context Menu Demo</title>
</head>
<body>
<h1>Context Menu Demo</h1>
<!-- highlight-next-line -->
<textarea id="editable"></textarea>
</body>
</html>

View File

@@ -0,0 +1,39 @@
// Modules to control application life and create native browser window
const { app, BrowserWindow, ipcMain, Menu } = require('electron/main')
const path = require('node:path')
function createWindow () {
const mainWindow = new BrowserWindow({
webPreferences: {
preload: path.join(__dirname, 'preload.js')
}
})
mainWindow.loadFile('index.html')
const menu = Menu.buildFromTemplate([
{ role: 'copy' },
{ role: 'cut' },
{ role: 'paste' },
{ role: 'selectall' }
])
// highlight-start
ipcMain.on('context-menu', (event) => {
menu.popup({
window: BrowserWindow.fromWebContents(event.sender)
})
})
// highlight-end
}
app.whenReady().then(() => {
createWindow()
app.on('activate', function () {
if (BrowserWindow.getAllWindows().length === 0) createWindow()
})
})
app.on('window-all-closed', function () {
if (process.platform !== 'darwin') app.quit()
})

View File

@@ -0,0 +1,11 @@
const { ipcRenderer } = require('electron/renderer')
document.addEventListener('DOMContentLoaded', () => {
const textarea = document.getElementById('editable')
// highlight-start
textarea.addEventListener('contextmenu', (event) => {
event.preventDefault()
ipcRenderer.send('context-menu')
})
// highlight-end
})

View File

@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'">
<title>Context Menu Demo</title>
</head>
<body>
<h1>Context Menu Demo</h1>
<!-- highlight-next-line -->
<textarea></textarea>
</body>
</html>

View File

@@ -0,0 +1,32 @@
const { app, BrowserWindow, Menu } = require('electron/main')
function createWindow () {
const win = new BrowserWindow()
// highlight-start
const menu = Menu.buildFromTemplate([
{ role: 'copy' },
{ role: 'cut' },
{ role: 'paste' },
{ role: 'selectall' }
])
win.webContents.on('context-menu', (_event, params) => {
// only show the context menu if the element is editable
if (params.isEditable) {
menu.popup()
}
})
// highlight-end
win.loadFile('index.html')
}
app.whenReady().then(() => {
createWindow()
app.on('activate', function () {
if (BrowserWindow.getAllWindows().length === 0) createWindow()
})
})
app.on('window-all-closed', function () {
if (process.platform !== 'darwin') app.quit()
})

View File

@@ -1,124 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Customize Menus</title>
</head>
<body>
<div>
<h1>Customize Menus</h1>
<h3>
The <code>Menu</code> and <code>MenuItem</code> modules can be used to
create custom native menus.
</h3>
<p>
There are two kinds of menus: the application (top) menu and context
(right-click) menu.
</p>
<p>
Open the
<a href="https://www.electronjs.org/docs/latest/api/menu"
>full API documentation<span
>(opens in new window)</span
></a
>
in your browser.
</p>
</div>
<div>
<h2>Create an application menu</h2>
<div>
<div>
<p>
The <code>Menu</code> and <code>MenuItem</code> modules allow you to
customize your application menu. If you don't set any menu, Electron
will generate a minimal menu for your app by default.
</p>
<p>
If you click the 'View' option in the application menu and then the
'App Menu Demo', you'll see an information box displayed.
</p>
<div>
<h2>ProTip</h2>
<strong>Know operating system menu differences.</strong>
<p>
When designing an app for multiple operating systems it's
important to be mindful of the ways application menu conventions
differ on each operating system.
</p>
<p>
For instance, on Windows, accelerators are set with an
<code>&</code>. Naming conventions also vary, like between
"Settings" or "Preferences". Below are resources for learning
operating system specific standards.
</p>
<ul>
<li>
<a
href="https://developer.apple.com/design/human-interface-guidelines/the-menu-bar"
>macOS<span
>(opens in new window)</span
></a
>
</li>
<li>
<a
href="https://learn.microsoft.com/en-us/windows/apps/design/controls/menus-and-context-menus"
>Windows<span
>(opens in new window)</span
></a
>
</li>
<li>
<a
href="https://developer.gnome.org/hig/patterns/controls/menus.html"
>Linux<span
>(opens in new window)</span
></a
>
</li>
</ul>
</div>
</div>
</div>
</div>
<div>
<h2>Create a context menu</h2>
<div>
<div>
<div>
<button id="context-menu">View Demo</button>
</div>
<p>
A context, or right-click, menu can be created with the
<code>Menu</code> and <code>MenuItem</code> modules as well. You can
right-click anywhere in this app or click the demo button to see an
example context menu.
</p>
<p>
In this demo we use the <code>ipcRenderer</code> module to show the
context menu when explicitly calling it from the renderer process.
</p>
<p>
See the full
<a
href="https://www.electronjs.org/docs/latest/api/web-contents/#event-context-menu"
>context-menu event documentation</a
>
for all the available properties.
</p>
</div>
</div>
</div>
<script src="renderer.js"></script>
</body>
</html>

View File

@@ -1,368 +0,0 @@
// Modules to control application life and create native browser window
const {
BrowserWindow,
Menu,
MenuItem,
ipcMain,
app,
shell,
dialog,
autoUpdater
} = require('electron/main')
const path = require('node:path')
const menu = new Menu()
menu.append(new MenuItem({ label: 'Hello' }))
menu.append(new MenuItem({ type: 'separator' }))
menu.append(
new MenuItem({ label: 'Electron', type: 'checkbox', checked: true })
)
const template = [
{
label: 'Edit',
submenu: [
{
label: 'Undo',
accelerator: 'CmdOrCtrl+Z',
role: 'undo'
},
{
label: 'Redo',
accelerator: 'Shift+CmdOrCtrl+Z',
role: 'redo'
},
{
type: 'separator'
},
{
label: 'Cut',
accelerator: 'CmdOrCtrl+X',
role: 'cut'
},
{
label: 'Copy',
accelerator: 'CmdOrCtrl+C',
role: 'copy'
},
{
label: 'Paste',
accelerator: 'CmdOrCtrl+V',
role: 'paste'
},
{
label: 'Select All',
accelerator: 'CmdOrCtrl+A',
role: 'selectall'
}
]
},
{
label: 'View',
submenu: [
{
label: 'Reload',
accelerator: 'CmdOrCtrl+R',
click: (item, focusedWindow) => {
if (focusedWindow) {
// on reload, start fresh and close any old
// open secondary windows
if (focusedWindow.id === 1) {
for (const win of BrowserWindow.getAllWindows()) {
if (win.id > 1) win.close()
}
}
focusedWindow.reload()
}
}
},
{
label: 'Toggle Full Screen',
accelerator: (() => {
if (process.platform === 'darwin') {
return 'Ctrl+Command+F'
} else {
return 'F11'
}
})(),
click: (item, focusedWindow) => {
if (focusedWindow) {
focusedWindow.setFullScreen(!focusedWindow.isFullScreen())
}
}
},
{
label: 'Toggle Developer Tools',
accelerator: (() => {
if (process.platform === 'darwin') {
return 'Alt+Command+I'
} else {
return 'Ctrl+Shift+I'
}
})(),
click: (item, focusedWindow) => {
if (focusedWindow) {
focusedWindow.webContents.toggleDevTools()
}
}
},
{
type: 'separator'
},
{
label: 'App Menu Demo',
click: function (item, focusedWindow) {
if (focusedWindow) {
const options = {
type: 'info',
title: 'Application Menu Demo',
buttons: ['Ok'],
message:
'This demo is for the Menu section, showing how to create a clickable menu item in the application menu.'
}
dialog.showMessageBox(focusedWindow, options, function () {})
}
}
}
]
},
{
label: 'Window',
role: 'window',
submenu: [
{
label: 'Minimize',
accelerator: 'CmdOrCtrl+M',
role: 'minimize'
},
{
label: 'Close',
accelerator: 'CmdOrCtrl+W',
role: 'close'
},
{
type: 'separator'
},
{
label: 'Reopen Window',
accelerator: 'CmdOrCtrl+Shift+T',
enabled: false,
key: 'reopenMenuItem',
click: () => {
app.emit('activate')
}
}
]
},
{
label: 'Help',
role: 'help',
submenu: [
{
label: 'Learn More',
click: () => {
shell.openExternal('https://electronjs.org')
}
}
]
}
]
function addUpdateMenuItems (items, position) {
if (process.mas) return
const version = app.getVersion()
const updateItems = [
{
label: `Version ${version}`,
enabled: false
},
{
label: 'Checking for Update',
enabled: false,
key: 'checkingForUpdate'
},
{
label: 'Check for Update',
visible: false,
key: 'checkForUpdate',
click: () => {
autoUpdater.checkForUpdates()
}
},
{
label: 'Restart and Install Update',
enabled: true,
visible: false,
key: 'restartToUpdate',
click: () => {
autoUpdater.quitAndInstall()
}
}
]
items.splice.apply(items, [position, 0].concat(updateItems))
}
function findReopenMenuItem () {
const menu = Menu.getApplicationMenu()
if (!menu) return
let reopenMenuItem
for (const item of menu.items) {
if (item.submenu) {
for (const subitem of item.submenu.items) {
if (subitem.key === 'reopenMenuItem') {
reopenMenuItem = subitem
}
}
}
}
return reopenMenuItem
}
if (process.platform === 'darwin') {
const name = app.getName()
template.unshift({
label: name,
submenu: [
{
label: `About ${name}`,
role: 'about'
},
{
type: 'separator'
},
{
label: 'Services',
role: 'services',
submenu: []
},
{
type: 'separator'
},
{
label: `Hide ${name}`,
accelerator: 'Command+H',
role: 'hide'
},
{
label: 'Hide Others',
accelerator: 'Command+Alt+H',
role: 'hideothers'
},
{
label: 'Show All',
role: 'unhide'
},
{
type: 'separator'
},
{
label: 'Quit',
accelerator: 'Command+Q',
click: () => {
app.quit()
}
}
]
})
// Window menu.
template[3].submenu.push(
{
type: 'separator'
},
{
label: 'Bring All to Front',
role: 'front'
}
)
addUpdateMenuItems(template[0].submenu, 1)
}
if (process.platform === 'win32') {
const helpMenu = template[template.length - 1].submenu
addUpdateMenuItems(helpMenu, 0)
}
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let mainWindow
function createWindow () {
// Create the browser window.
mainWindow = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
preload: path.join(__dirname, 'preload.js')
}
})
// and load the index.html of the app.
mainWindow.loadFile('index.html')
// Open the DevTools.
// mainWindow.webContents.openDevTools()
// Emitted when the window is closed.
mainWindow.on('closed', function () {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
mainWindow = null
})
// Open external links in the default browser
mainWindow.webContents.on('will-navigate', (event, url) => {
event.preventDefault()
shell.openExternal(url)
})
}
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.whenReady().then(() => {
createWindow()
const menu = Menu.buildFromTemplate(template)
Menu.setApplicationMenu(menu)
})
// Quit when all windows are closed.
app.on('window-all-closed', function () {
// On macOS it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
const reopenMenuItem = findReopenMenuItem()
if (reopenMenuItem) reopenMenuItem.enabled = true
if (process.platform !== 'darwin') {
app.quit()
}
})
app.on('activate', function () {
// On macOS it is common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (mainWindow === null) {
createWindow()
}
})
app.on('browser-window-created', (event, win) => {
const reopenMenuItem = findReopenMenuItem()
if (reopenMenuItem) reopenMenuItem.enabled = false
win.webContents.on('context-menu', (e, params) => {
menu.popup(win, params.x, params.y)
})
})
ipcMain.on('show-context-menu', event => {
const win = BrowserWindow.fromWebContents(event.sender)
menu.popup(win)
})
// In this file you can include the rest of your app's specific main process
// code. You can also put them in separate files and require them here.

View File

@@ -1,5 +0,0 @@
const { contextBridge, ipcRenderer } = require('electron/renderer')
contextBridge.exposeInMainWorld('electronAPI', {
showContextMenu: () => ipcRenderer.send('show-context-menu')
})

View File

@@ -1,6 +0,0 @@
// Tell main process to show the menu when demo button is clicked
const contextMenuBtn = document.getElementById('context-menu')
contextMenuBtn.addEventListener('click', () => {
window.electronAPI.showContextMenu()
})

View File

@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'">
<title>Dock Menu Demo</title>
</head>
<body>
<h1>Dock Menu Demo</h1>
<ul>
<li>Create new BrowserWindow instances via the "New Window" option</li>
<li>Close all BrowserWindow instances via the "Close All Windows" option</li>
<li>Read the docs via the "Show Electron Docs" option</li>
</ul>
<script src="./renderer.js"></script>
</body>
</html>

View File

@@ -0,0 +1,46 @@
const { app, BrowserWindow, Menu } = require('electron/main')
const { shell } = require('electron/common')
function createWindow () {
const win = new BrowserWindow()
win.loadFile('index.html')
}
function closeAllWindows () {
const wins = BrowserWindow.getAllWindows()
for (const win of wins) {
win.close()
}
}
app.whenReady().then(() => {
createWindow()
const dockMenu = Menu.buildFromTemplate([
{
label: 'New Window',
click: () => { createWindow() }
},
{
label: 'Close All Windows',
click: () => { closeAllWindows() }
},
{
label: 'Open Electron Docs',
click: () => {
shell.openExternal('https://electronjs.org/docs')
}
}
// add more menu options to the array
])
app.dock.setMenu(dockMenu)
app.on('activate', function () {
if (BrowserWindow.getAllWindows().length === 0) createWindow()
})
})
app.on('window-all-closed', function () {
if (process.platform !== 'darwin') app.quit()
})

View File

@@ -0,0 +1 @@
document.title = `${document.title} - ${new Date()}`

View File

@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'">
<title>Tray Menu Demo</title>
</head>
<body>
<h1>Tray Menu Demo</h1>
<p>This app will stay running even after all windows are closed.</p>
<ul>
<li>Use the "Open App" menu item to focus the main window (or open one if it does not exist).</li>
<li>Change between red and green Tray icons with the "Set Green Icon" checkbox.</li>
<li>Give the Tray icon a title using the "Set Title" checkbox.</li>
<li>Quit the app using the "Quit" menu item.</li>
</ul>
</body>
</html>

View File

@@ -0,0 +1,60 @@
const { app, BrowserWindow, Menu, Tray } = require('electron/main')
const { nativeImage } = require('electron/common')
// save a reference to the Tray object globally to avoid garbage collection
let tray = null
function createWindow () {
const mainWindow = new BrowserWindow()
mainWindow.loadFile('index.html')
}
// The Tray object can only be instantiated after the 'ready' event is fired
app.whenReady().then(() => {
createWindow()
const red = nativeImage.createFromDataURL('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAACTSURBVHgBpZKBCYAgEEV/TeAIjuIIbdQIuUGt0CS1gW1iZ2jIVaTnhw+Cvs8/OYDJA4Y8kR3ZR2/kmazxJbpUEfQ/Dm/UG7wVwHkjlQdMFfDdJMFaACebnjJGyDWgcnZu1/lrCrl6NCoEHJBrDwEr5NrT6ko/UV8xdLAC2N49mlc5CylpYh8wCwqrvbBGLoKGvz8Bfq0QPWEUo/EAAAAASUVORK5CYII=')
const green = nativeImage.createFromDataURL('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAACOSURBVHgBpZLRDYAgEEOrEzgCozCCGzkCbKArOIlugJvgoRAUNcLRpvGH19TkgFQWkqIohhK8UEaKwKcsOg/+WR1vX+AlA74u6q4FqgCOSzwsGHCwbKliAF89Cv89tWmOT4VaVMoVbOBrdQUz+FrD6XItzh4LzYB1HFJ9yrEkZ4l+wvcid9pTssh4UKbPd+4vED2Nd54iAAAAAElFTkSuQmCC')
tray = new Tray(red)
tray.setToolTip('Tray Icon Demo')
const contextMenu = Menu.buildFromTemplate([
{
label: 'Open App',
click: () => {
const wins = BrowserWindow.getAllWindows()
if (wins.length === 0) {
createWindow()
} else {
wins[0].focus()
}
}
},
{
label: 'Set Green Icon',
type: 'checkbox',
click: ({ checked }) => {
checked ? tray.setImage(green) : tray.setImage(red)
}
},
{
label: 'Set Title',
type: 'checkbox',
click: ({ checked }) => {
checked ? tray.setTitle('Title') : tray.setTitle('')
}
},
{ role: 'quit' }
])
tray.setContextMenu(contextMenu)
})
app.on('window-all-closed', function () {
// This will prevent the app from closing when windows close
})
app.on('activate', function () {
if (BrowserWindow.getAllWindows().length === 0) createWindow()
})

View File

@@ -1,47 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Tray</title>
</head>
<body>
<div>
<h1>Tray</h1>
<h3>
The <code>tray</code> module allows you to create an icon in the
operating system's notification area.
</h3>
<p>This icon can also have a context menu attached.</p>
<p>
Open the
<a href="https://www.electronjs.org/docs/latest/api/tray">
full API documentation
</a>
in your browser.
</p>
</div>
<div>
<div>
<h2>ProTip</h2>
<strong>Tray support in Linux.</strong>
<p>
On Linux distributions that only have app indicator support, users
will need to install <code>libappindicator1</code> to make the
tray icon work. See the
<a href="https://www.electronjs.org/docs/latest/api/tray">
full API documentation
</a>
for more details about using Tray on Linux.
</p>
</div>
</div>
</div>
</div>
<script>
// You can also require other files to run in this process
require("./renderer.js");
</script>
</body>
</html>

View File

@@ -1,18 +0,0 @@
const { app, Tray, Menu, nativeImage } = require('electron/main')
let tray
app.whenReady().then(() => {
const icon = nativeImage.createFromDataURL('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACQAAAAkCAYAAADhAJiYAAAAAXNSR0IArs4c6QAAAAlwSFlzAAALEwAACxMBAJqcGAAAAVlpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IlhNUCBDb3JlIDUuNC4wIj4KICAgPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4KICAgICAgPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIKICAgICAgICAgICAgeG1sbnM6dGlmZj0iaHR0cDovL25zLmFkb2JlLmNvbS90aWZmLzEuMC8iPgogICAgICAgICA8dGlmZjpPcmllbnRhdGlvbj4xPC90aWZmOk9yaWVudGF0aW9uPgogICAgICA8L3JkZjpEZXNjcmlwdGlvbj4KICAgPC9yZGY6UkRGPgo8L3g6eG1wbWV0YT4KTMInWQAACsZJREFUWAmtWFlsXFcZ/u82++Jt7IyT2Em6ZFHTpAtWIzspEgjEUhA8VNAiIYEQUvuABBIUwUMkQIVKPCIoEiABLShISEBbhFJwIGRpIKRpbNeJ7bh2HHvssR3PPnPnLnzfmRlju6EQqUc+c++c8y/fv54z1uQOh+/7Glh0TD59TE/TND7lnfa4/64OKsM071QoeZpA/y9WWvk/B4XCC06TUC+Xyw8HTXNQ1+Ww6PpOrMebewXxvBueJ6/XHOdMJBL5J9Y97m2R0SS/wweE6JxkGx5dilWr1S/7dXsEa2o4+LyFmcFcaL5zbX3Y9gh5hpeWYpSB9XV5/H678V89BGYDXnHJlCsWn4gHrGc1K9CXxferOdvPOOKUfF8cH7nUyCtklQZXih/VNNlmirk3GdBSoIcRswW7/vVkLPYi5W2Uze8bh7J+4wLfh4dViFx5/nmrUi7/MhGNvrCkBfpeWqnW/7BUdadqntQ8zwr6vhUV34xpYnDynWvcmwQNaclDXsqgLMqkocPDw7fNx7d5qIX+/PmJxKGD6VdDkeh7ztyqOFfrokGCEWiiZ1mp0uITnuKAosaT7+pNxMYTyefutcQfbA+b1XLpH5fnF97/yD335Fu6mqTqsclDINBVmI4fDxw80KPAvJSt1MZtMcLiGxYUu83p4UkgnJZlqcl3LAj3WnTkIS9lUBYNPJjueVWgg7qocyOgliFqjZsg8gq5tRdiieQTf1gq15Y8CUbRZtyWOzZwc8lEqS3PTCtgqd13ieO68BQ2uNl64tXAewktrFuX2mPdkWAxn3sxnmx7sqUTJGqso8MGS9tbXFz8DMH8bblUX3T9QARVi8RV8qljfcJy0zRlaf6mzHEuzEtmekqCoZB4rqp0OmudHtUnlEWZlE0d1EWd1N3EozourcO65pw4eTIZQTW9VazJtbqvw9XwKVFQMsKDBuNhtp4uvGGFI+IDgKnpMjYyIis3ZsQMBIR7pONsIaMsyqRs6ohY1rPUSd3EQFDqo+kdZ3Fh4aupbdu+99uFQr2A1CBs4uEAjZjIFUMHi4dVxMXzCdCXQj4vBrwVCofl0ulTcv/DAxJJJBUPc8mpoyI2JDw7bFyT+ifTcSubyXytJ51+roWBxwG9Q73WWjZ7eSUU3//nXM0NI+x0PBGrTSgsLS9JFuFxHFrvSqIrJV279gi6tjiVspTza3JjZhY+0CQZj0mlWJSeHTslCro6eFqymCcVVN77kkGjs1p4sy2VOoSlOrFwT+XR+PjkgGaZ+ycKVbRTYUdVrmaImCvzk1dlFCEJdHRJ284+ie/ol0h7p7jFvExcvCCXzp2Rqem3pAMAiqWS6JGYhFI9Mjo6KjevXVUyKEuFHrKpY6JQ8TXT3D8+OTkAHBw6o6LCFo9ag3o4JtlCyTHEt5AxKvS6YUi5kJeZG3Py0NAxlLcJ9xti+K7Mjo/JfGZRuvv6Ze+9+yWEhDZAvzg3JyhX2d6/S7q6e+TimdOS7ElLKBZDwqvmj6rztayr1fVI1IoXi4PAcYZY1tPEEO1wEVlXgRFBDcmIXTqJsS+XyhKLJ5A/OpIVXXptWUYv/UvaenfIocEhMQ2EzHHErlXFCgQl3paU1eVl6QAY8sQTCSmVihKJx1V/ogvgIYF/pACdcMBhqONoHhF88/2d+bojyA6cRvje2IdFjoSjUSnBS8hgyS9lZOzKFdmPxO3o6gQIGzwuDn1dVSCtCKPy1pZXlATXqUsVYMLRmKo87vP4Y1ioqwCdCegmMYx3W/VPn8RrSDwwIMMbcEjkYo29JZVOy+ybI7K4eksODx1VSqvligpReSVLgySM/FI5h2q062jNyL3s7FtoAyGJIlx1225UmwJF6aJRJ3XzHXO9bWvsJa3jQFlBJkz6iuXdu32HzM7MyP0PPNgAU6ko4Qzp6b+flr8MD9OYJg9CwtzL5+T65ITs2bsP3mGxN/ZbBcOn0sk20gAkLQ+huXpFi8vkoY9AoyDjxTR1mbo6Ltt275HpN0dlNxQE40mVM8Ajjxx9VAGhAvQR1akZFCq799ADysMuQqOxh2FNmamEaz51ItGLfFD9+oUJoZkLowHoFA2mljUacqOMflKuVmHpfmnfvlMuvXZeStmMBIMhcWEdjgFJtrUjXI0KchAuAg0ilxLJNoRVBxhIBm0TjjKAuqjTqTs3CQZ6QUUMGFW7eiWMUg6w+yo8YMW7DqtqlZLkUDV2ISfd29KyDwk9MjYmMyOXxQIIKuShqo4VGFNBEgeDQYqVam5N5tEePFQgURIUBCsd1EWd1XrtDUUMLARD9bKaK5ytQ2Gb75g8WMiEP6VkfnZGevv6UF1vSBW5E0PFDAweFRvlfun8WVmamhDNrkmweQ0pwaPt6M4m8mgKTTFXqcrV0ZH1FKBg6qAu6qTuJiCV1Cp2Q0NDr9Uq5Ym+oMEDlSewsoRwrVBEaij7AJ4s7zrOpumxEdm15y6558GHJVe1Zezy6zJx6aJkpq5JFB4z6zVZmBiX1VWUP0IY4CFMYcpQdZ3xqIs6oftCE5DHKwd0q/tzOV8svdDb3nk8VnG9qmgQC0ZURz8Ur91alXgSByZ6ES9kZZTr/PR16UOCh+7dq0CWyyXJ4xqCQ0nKt9YQSlPue2gAeYZzD7yNLk0wmqAreb2WYSxAJ8Dget64wxtEBlDaqVOn/K5dB67t6+t5MhoMJuc8w8UPKiQ9CQR9JK5czhZAQxPt7TKF3OiAIisUViAD2Lg5d0P2HDgoKeRaW0enyqVwBJcO5fFG5dqa7h406qaeX8384uTZL5w9+UqxhYHFp0YLIYA9ddfu3T+4UJF6Rg+YAc9D0+RoIGP1ULhpWspr10evyK7+ftWTrk9PS/++A9KZSm26cih2mMOErem6n/ZsZwA2TM/MPHXs2LEftnSTbh0Q36mIIbx44cLvOnu3f+xUwbWLmoHTCUlF6g2jBQo/GnFrnGNqSHdvr+rIKGMW1KahwEBdzHft98aNwMr8zd8/NDDwccihc0hLi3GubRjY0Bm6H19fPvnZI4c/fHd7PJ2peXYZ+WQ26JufZELjQ6lbAQtnWre0d3apY8TFIdtAo+Qri6mupsB49lBMC+QXF0YefObZT8j0eKWlswVjEyCCOXHihPGb575VCvVuf3lvetsH9rXF0rla3cnhpoIGjgsUPhR3I4TMKYJQV1Z6WO02aEjHa5mNe3OPW3OPRHVrbXFh9Ocvv/KR1372owx1Pf3005uc35Ddgtd8rsf06IdS5777zZ+mUqmPzjm6TPpmvayZOq4LyATeCzkanmiy4qEuC/yXiO8CSMRzvLs1x9phepLNZl868sy3Pyen/5hd1/EfRvWmuvSWNeaRS/RkPDI4+NjE1NSXEoXlpaNB1zqo20abi59/vu/UfM2pie7WUDVq8l3wTwnskeZ+zTbIQ17KoCzKpGzq2KqX32/roRbh8ePHdUzl0s9/5Rv9n/7go19MxCKfCkZiu3V06wrO5gocxL7Dgd/IEobEMH6rejg+auXidL5Y/vWv/vTX53/y/e/MkGajTH7fOt4RUJOY1df4RdtY6ICFRzqTySOhUOA+3Ai3o31H1ZbnlXBruFmt2iMrudy5xx9//BzWV7nXDBGN2xpjbt/5oGUEdhtO3iD47xZOvm8a5CHvpsV38wsUaMwBWsz3rbK5xr0mzdv2t9Jv/f5vhsF4J+Q63IUAAAAASUVORK5CYII=')
tray = new Tray(icon)
const contextMenu = Menu.buildFromTemplate([
{ label: 'Item1', type: 'radio' },
{ label: 'Item2', type: 'radio' },
{ label: 'Item3', type: 'radio', checked: true },
{ label: 'Item4', type: 'radio' }
])
tray.setToolTip('This is my application.')
tray.setContextMenu(contextMenu)
})

View File

@@ -0,0 +1,208 @@
---
title: Application Menu
description: Customize the main application menu for your Electron app
slug: application-menu
hide_title: true
---
# Application Menu
Each Electron app has a single top-level application menu.
* On macOS, this menu is shown in the system [menu bar](https://support.apple.com/en-ca/guide/mac-help/mchlp1446/mac).
* On Windows and Linux, this menu is shown at the top of each [BaseWindow](../api/base-window.md).
## Building application menus
The application menu can be set by passing a [Menu](../api/menu.md) instance into the
[`Menu.setApplicationMenu`](../api/menu.md#menusetapplicationmenumenu) static function.
When building an application menu in Electron, each top-level array menu item **must be a submenu**.
Electron will set a default menu for your app if this API is never called. Below is an example of
that default menu being created manually using shorthand [`MenuItem` roles](./menus.md#roles).
```js title='Manually creating the default menu' @ts-expect-error=[107]
const { shell } = require('electron/common')
const { app, Menu } = require('electron/main')
const isMac = process.platform === 'darwin'
const template = [
// { role: 'appMenu' }
...(isMac
? [{
label: app.name,
submenu: [
{ role: 'about' },
{ type: 'separator' },
{ role: 'services' },
{ type: 'separator' },
{ role: 'hide' },
{ role: 'hideOthers' },
{ role: 'unhide' },
{ type: 'separator' },
{ role: 'quit' }
]
}]
: []),
// { role: 'fileMenu' }
{
label: 'File',
submenu: [
isMac ? { role: 'close' } : { role: 'quit' }
]
},
// { role: 'editMenu' }
{
label: 'Edit',
submenu: [
{ role: 'undo' },
{ role: 'redo' },
{ type: 'separator' },
{ role: 'cut' },
{ role: 'copy' },
{ role: 'paste' },
...(isMac
? [
{ role: 'pasteAndMatchStyle' },
{ role: 'delete' },
{ role: 'selectAll' },
{ type: 'separator' },
{
label: 'Speech',
submenu: [
{ role: 'startSpeaking' },
{ role: 'stopSpeaking' }
]
}
]
: [
{ role: 'delete' },
{ type: 'separator' },
{ role: 'selectAll' }
])
]
},
// { role: 'viewMenu' }
{
label: 'View',
submenu: [
{ role: 'reload' },
{ role: 'forceReload' },
{ role: 'toggleDevTools' },
{ type: 'separator' },
{ role: 'resetZoom' },
{ role: 'zoomIn' },
{ role: 'zoomOut' },
{ type: 'separator' },
{ role: 'togglefullscreen' }
]
},
// { role: 'windowMenu' }
{
label: 'Window',
submenu: [
{ role: 'minimize' },
{ role: 'zoom' },
...(isMac
? [
{ type: 'separator' },
{ role: 'front' },
{ type: 'separator' },
{ role: 'window' }
]
: [
{ role: 'close' }
])
]
},
{
role: 'help',
submenu: [
{
label: 'Learn More',
click: async () => {
const { shell } = require('electron')
await shell.openExternal('https://electronjs.org')
}
}
]
}
]
const menu = Menu.buildFromTemplate(template)
Menu.setApplicationMenu(menu)
```
> [!IMPORTANT]
> On macOS, the first submenu of the application menu will **always** have your application's name
> as its label. In general, you can populate this submenu by conditionally adding a menu item with
> the `appMenu` role.
> [!TIP]
> For additional descriptions of available roles, see the [`MenuItem` roles](./menus.md#roles)
> section of the general Menus guide.
### Using standard OS menu roles
Defining each submenu explicitly can get very verbose. If you want to re-use default submenus
in your app, you can use various submenu-related roles provided by Electron.
```js title='Using default roles for each submenu' @ts-expect-error=[26]
const { shell } = require('electron/common')
const { app, Menu } = require('electron/main')
const template = [
...(process.platform === 'darwin'
? [{ role: 'appMenu' }]
: []),
{ role: 'fileMenu' },
{ role: 'editMenu' },
{ role: 'viewMenu' },
{ role: 'windowMenu' },
{
role: 'help',
submenu: [
{
label: 'Learn More',
click: async () => {
const { shell } = require('electron')
await shell.openExternal('https://electronjs.org')
}
}
]
}
]
const menu = Menu.buildFromTemplate(template)
Menu.setApplicationMenu(menu)
```
> [!NOTE]
> On macOS, the `help` role defines a top-level Help submenu that has a search bar for
> other menu items. It requires items to be added to its `submenu` to function.
## Setting window-specific application menus _Linux_ _Windows_
Since the root application menu exists on each `BaseWindow` on Windows and Linux, you can override
it with a window-specific `Menu` instance via the [`win.setMenu`](../api/browser-window.md#winsetmenumenu-linux-windows) method.
```js title='Override a window's menu'
const { BrowserWindow, Menu } = require('electron/main')
const win = new BrowserWindow()
const menu = Menu.buildFromTemplate([
{
label: 'my custom menu',
submenu: [
{ role: 'copy' },
{ role: 'paste' }
]
}
])
win.setMenu(menu)
```
> [!TIP]
> You can remove a specific window's application menu by calling the
> [`win.removeMenu`](../api/base-window.md#winremovemenu-linux-windows) API.

View File

@@ -0,0 +1,69 @@
---
title: Context Menu
description: Configure cross-platform native OS menus with the Menu API.
slug: context-menu
hide_title: true
---
# Context Menu
Context menus are pop-up menus that appear when right-clicking (or pressing a shortcut
such as <kbd>Shift</kbd> + <kbd>F10</kbd> on Windows) somewhere in an app's interface.
No context menu will appear by default in Electron. However, context menus can be created by using
the [`menu.popup`](../api/menu.md#menupopupoptions) function on an instance of the
[Menu](../api/menu.md) class. You will need to listen for specific context menu events and set up
the trigger for `menu.popup` manually.
There are two ways of listening for context menu events in Electron: either via the main process
through [webContents](../api/web-contents.md) or in the renderer process via the
[`contextmenu`](https://developer.mozilla.org/en-US/docs/Web/API/Element/contextmenu_event) web event.
## Using the `context-menu` event (main)
Whenever a right-click is detected within the bounds of a specific `WebContents` instance, a
[`context-menu`](../api/web-contents.md#event-context-menu) event is triggered. The `params` object
passed to the listener provides an extensive list of attributes to distinguish which type of element
is receiving the event.
For example, if you want to provide a context menu for links, check for the `linkURL` parameter.
If you want to check for editable elements such as `<textarea/>`, check for the `isEditable` parameter.
```fiddle docs/fiddles/menus/context-menu/web-contents
```
## Using the `contextmenu` event (renderer)
Alternatively, you can also listen to the [`contextmenu`](https://developer.mozilla.org/en-US/docs/Web/API/Element/contextmenu_event)
event available on DOM elements in the renderer process and call the `menu.popup` function via IPC.
> [!TIP]
> To learn more about IPC basics in Electron, see the [Inter-Process Communication](./ipc.md) guide.
```fiddle docs/fiddles/menus/context-menu/dom|focus=preload.js
```
## Additional macOS menu items (e.g. Writing Tools)
On macOS, the [Writing Tools](https://support.apple.com/en-ca/guide/mac-help/mchldcd6c260/15.0/mac/15.0),
[AutoFill](https://support.apple.com/en-mz/guide/safari/ibrwf71ba236/mac), and
[Services](https://support.apple.com/en-ca/guide/mac-help/mchlp1012/mac) menu items
are disabled by default for context menus in Electron. To enable these features, pass the
[WebFrameMain](../api/web-frame-main.md) associated to the target `webContents` to the `frame`
parameter in `menu.popup`.
```js title='Associating a frame to the context menu'
const { BrowserWindow, Menu } = require('electron/main')
const menu = Menu.buildFromTemplate([{ role: 'editMenu' }])
const win = new BrowserWindow()
win.webContents.on('context-menu', (_event, params) => {
// Whether the context is editable.
if (params.isEditable) {
menu.popup({
// highlight-next-line
frame: params.frame
})
}
})
```

View File

@@ -143,7 +143,7 @@ The `electron/electron` repository also enforces squash merging, so you only nee
## Historical versioning (Electron 1.X)
Electron versions _< 2.0_ did not conform to the [SemVer](https://semver.org) spec: major versions corresponded to end-user API changes, minor versions corresponded to Chromium major releases, and patch versions corresponded to new features and bug fixes. While convenient for developers merging features, it creates problems for developers of client-facing applications. The QA testing cycles of major apps like Slack, Teams, Skype, VS Code, and GitHub Desktop can be lengthy and stability is a highly desired outcome. There is a high risk in adopting new features while trying to absorb bug fixes.
Electron versions _< 2.0_ did not conform to the [SemVer](https://semver.org) spec: major versions corresponded to end-user API changes, minor versions corresponded to Chromium major releases, and patch versions corresponded to new features and bug fixes. While convenient for developers merging features, it creates problems for developers of client-facing applications. The QA testing cycles of major apps like Slack, Teams, VS Code, and GitHub Desktop can be lengthy and stability is a highly desired outcome. There is a high risk in adopting new features while trying to absorb bug fixes.
Here is an example of the 1.x strategy:

View File

@@ -48,7 +48,7 @@ The nodeCliInspect fuse toggles whether the `--inspect`, `--inspect-brk`, etc. f
**@electron/fuses:** `FuseV1Options.EnableEmbeddedAsarIntegrityValidation`
The embeddedAsarIntegrityValidation fuse toggles an experimental feature on macOS that validates the content of the `app.asar` file when it is loaded. This feature is designed to have a minimal performance impact but may marginally slow down file reads from inside the `app.asar` archive.
The embeddedAsarIntegrityValidation fuse toggles an experimental feature on macOS and Windows that validates the content of the `app.asar` file when it is loaded. This feature is designed to have a minimal performance impact but may marginally slow down file reads from inside the `app.asar` archive.
For more information on how to use asar integrity validation please read the [Asar Integrity](asar-integrity.md) documentation.

View File

@@ -1,127 +1,170 @@
---
title: "Keyboard Shortcuts"
description: "Define accelerator strings for local and global keyboard shortcuts"
slug: keyboard-shortcuts
hide_title: false
---
# Keyboard Shortcuts
## Overview
## Accelerators
This feature allows you to configure local and global keyboard shortcuts
for your Electron application.
Accelerators are strings that can be used to represent keyboard shortcuts throughout your Electron.
These strings can contain multiple modifiers keys and a single key code joined by the `+` character.
## Example
> [!NOTE]
> Accelerators are **case-insensitive**.
### Local Shortcuts
### Available modifiers
Local keyboard shortcuts are triggered only when the application is focused.
To configure a local keyboard shortcut, you need to specify an [`accelerator`][]
property when creating a [MenuItem][] within the [Menu][] module.
* `Command` (or `Cmd` for short)
* `Control` (or `Ctrl` for short)
* `CommandOrControl` (or `CmdOrCtrl` for short)
* `Alt`
* `Option`
* `AltGr`
* `Shift`
* `Super` (or `Meta` as alias)
Starting with a working application from the
[tutorial starter code][tutorial-starter-code], update the `main.js` to be:
### Available key codes
```fiddle docs/fiddles/features/keyboard-shortcuts/local
const { app, BrowserWindow, Menu, MenuItem } = require('electron/main')
* `0` to `9`
* `A` to `Z`
* `F1` to `F24`
* Various Punctuation: `)`, `!`, `@`, `#`, `$`, `%`, `^`, `&`, `*`, `(`, `:`, `;`, `:`, `+`, `=`, `<`, `,`, `_`, `-`, `>`, `.`, `?`, `/`, `~`, `` ` ``, `{`, `]`, `[`, `|`, `\`, `}`, `"`
* `Plus`
* `Space`
* `Tab`
* `Capslock`
* `Numlock`
* `Scrolllock`
* `Backspace`
* `Delete`
* `Insert`
* `Return` (or `Enter` as alias)
* `Up`, `Down`, `Left` and `Right`
* `Home` and `End`
* `PageUp` and `PageDown`
* `Escape` (or `Esc` for short)
* `VolumeUp`, `VolumeDown` and `VolumeMute`
* `MediaNextTrack`, `MediaPreviousTrack`, `MediaStop` and `MediaPlayPause`
* `PrintScreen`
* NumPad Keys
* `num0` - `num9`
* `numdec` - decimal key
* `numadd` - numpad `+` key
* `numsub` - numpad `-` key
* `nummult` - numpad `*` key
* `numdiv` - numpad `÷` key
function createWindow () {
const win = new BrowserWindow({
width: 800,
height: 600
})
### Cross-platform modifiers
win.loadFile('index.html')
}
Many modifier accelerators map to different keys between operating systems.
| Modifier | macOS | Windows and Linux |
|------------------|-------------|----------------------|
|`CommandOrControl`| Command (⌘) | Control |
|`Command` | Command (⌘) | N/A |
|`Control` | Control (^) | Control |
|`Alt` | Option (⌥) | Alt |
|`Option` | Option (⌥) | N/A |
|`Super` (`Meta`) | Command (⌘) | Windows (⊞) |
> [!IMPORTANT]
>
> * On Linux and Windows, the `Command` modifier does not have any effect. In general, you should use
> the `CommandOrControl` modifier instead, which represents <kbd>⌘ Cmd</kbd> on macOS and <kbd>Ctrl</kbd>
> on Linux and Windows.
> * Use `Alt` instead of `Option`. The <kbd>⌥ Opt</kbd> key only exists on macOS, whereas the `Alt` will
> map to the appropriate modifier on all platforms.
#### Examples
Here are some examples of cross-platform Electron accelerators for common editing operations:
* Copy: `CommandOrControl+C`
* Paste: `CommandOrControl+V`
* Undo: `CommandOrControl+Z`
* Redo: `CommandOrControl+Shift+Z`
## Local shortcuts
**Local** keyboard shortcuts are triggered only when the application is focused. These shortcuts
map to specific menu items within the app's main [application menu](./application-menu.md).
To define a local keyboard shortcut, you need to configure the `accelerator` property when creating
a [MenuItem](../api/menu-item.md). Then, the `click` event associated to that menu item will trigger
upon using that accelerator.
```js title='Opening a dialog via accelerator (local)'
const { dialog, Menu, MenuItem } = require('electron/main')
const menu = new Menu()
menu.append(new MenuItem({
label: 'Electron',
submenu: [{
role: 'help',
accelerator: process.platform === 'darwin' ? 'Alt+Cmd+I' : 'Alt+Shift+I',
click: () => { console.log('Electron rocks!') }
}]
}))
Menu.setApplicationMenu(menu)
app.whenReady().then(createWindow)
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
})
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow()
}
})
```
> NOTE: In the code above, you can see that the accelerator differs based on the
user's operating system. For MacOS, it is `Alt+Cmd+I`, whereas for Linux and
Windows, it is `Alt+Shift+I`.
After launching the Electron application, you should see the application menu
along with the local shortcut you just defined:
![Menu with a local shortcut](../images/local-shortcut.png)
If you click `Help` or press the defined accelerator and then open the terminal
that you ran your Electron application from, you will see the message that was
generated after triggering the `click` event: "Electron rocks!".
### Global Shortcuts
To configure a global keyboard shortcut, you need to use the [globalShortcut][]
module to detect keyboard events even when the application does not have
keyboard focus.
Starting with a working application from the
[tutorial starter code][tutorial-starter-code], update the `main.js` to be:
```fiddle docs/fiddles/features/keyboard-shortcuts/global
const { app, BrowserWindow, globalShortcut } = require('electron/main')
function createWindow () {
const win = new BrowserWindow({
width: 800,
height: 600
})
win.loadFile('index.html')
// The first submenu needs to be the app menu on macOS
if (process.platform === 'darwin') {
const appMenu = new MenuItem({ role: 'appMenu' })
menu.append(appMenu)
}
app.whenReady().then(() => {
globalShortcut.register('Alt+CommandOrControl+I', () => {
console.log('Electron loves global shortcuts!')
})
}).then(createWindow)
// highlight-start
const submenu = Menu.buildFromTemplate([{
label: 'Open a Dialog',
click: () => dialog.showMessageBox({ message: 'Hello World!' }),
accelerator: 'CommandOrControl+Alt+R'
}])
menu.append(new MenuItem({ label: 'Custom Menu', submenu }))
// highlight-end
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
})
Menu.setApplicationMenu(menu)
```
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow()
}
In the above example, a native "Hello World" dialog will open when pressing <kbd>⌘ Cmd</kbd>+<kbd>⌥ Opt</kbd>+<kbd>R</kbd>
on macOS or <kbd>Ctrl</kbd>+<kbd>Alt</kbd>+<kbd>R</kbd> on other platforms.
> [!TIP]
> Accelerators can work even when menu items are hidden. On macOS, this feature can be disabled by
> setting `acceleratorWorksWhenHidden: false` when building a `MenuItem`.
> [!TIP]
> On Windows and Linux, the `registerAccelerator` property of the `MenuItem` can be set to `false`
> so that the accelerator is visible in the system menu but not enabled.
## Global shortcuts
**Global** keyboard shortcuts work even when your app is out of focus. To configure a global keyboard
shortcut, you can use the [`globalShortcut.register`](../api/global-shortcut.md#globalshortcutregisteraccelerator-callback)
function to specify shortcuts.
```js title='Opening a dialog via accelerator (global)'
const { dialog, globalShortcut } = require('electron/main')
globalShortcut.register('CommandOrControl+Alt+R', () => {
dialog.showMessageBox({ message: 'Hello World!' })
})
```
> NOTE: In the code above, the `CommandOrControl` combination uses `Command`
on macOS and `Control` on Windows/Linux.
To later unregister a shortcut, you can use the [`globalShortcut.unregisterAccelerator`](../api/global-shortcut.md#globalshortcutunregisteraccelerator)
function.
After launching the Electron application, if you press the defined key
combination then open the terminal that you ran your Electron application from,
you will see that Electron loves global shortcuts!
```js title='Opening a dialog via accelerator (global)'
const { globalShortcut } = require('electron/main')
### Shortcuts within a BrowserWindow
globalShortcut.unregister('CommandOrControl+Alt+R')
```
#### Using web APIs
> [!WARNING]
> On macOS, there's a long-standing bug with `globalShortcut` that prevents it from working with
> keyboard layouts other than QWERTY ([electron/electron#19747](https://github.com/electron/electron/issues/19747)).
If you want to handle keyboard shortcuts within a [BrowserWindow][], you can
listen for the `keyup` and `keydown` [DOM events][dom-events] inside the
renderer process using the [addEventListener() API][addEventListener-api].
## Shortcuts within a window
### In the renderer process
If you want to handle keyboard shortcuts within a [BaseWindow](../api/base-window.md), you can
listen for the [`keyup`](https://developer.mozilla.org/en-US/docs/Web/API/Element/keyup_event) and
[`keydown`](https://developer.mozilla.org/en-US/docs/Web/API/Element/keydown_event) DOM Events inside
the renderer process using the [addEventListener](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener) API.
```fiddle docs/fiddles/features/keyboard-shortcuts/web-apis|focus=renderer.js
function handleKeyPress (event) {
@@ -141,18 +184,14 @@ window.addEventListener('keyup', handleKeyPress, true)
#### Intercepting events in the main process
The [`before-input-event`](../api/web-contents.md#event-before-input-event) event
is emitted before dispatching `keydown` and `keyup` events in the page. It can
is emitted before dispatching `keydown` and `keyup` events in the renderer process. It can
be used to catch and handle custom shortcuts that are not visible in the menu.
Starting with a working application from the
[tutorial starter code][tutorial-starter-code], update the `main.js` file with the
following lines:
```fiddle docs/fiddles/features/keyboard-shortcuts/interception-from-main
```js title='Intercepting the Ctrl+I event from the main process'
const { app, BrowserWindow } = require('electron/main')
app.whenReady().then(() => {
const win = new BrowserWindow({ width: 800, height: 600 })
const win = new BrowserWindow()
win.loadFile('index.html')
win.webContents.on('before-input-event', (event, input) => {
@@ -163,49 +202,3 @@ app.whenReady().then(() => {
})
})
```
After launching the Electron application, if you open the terminal that you ran
your Electron application from and press `Ctrl+I` key combination, you will
see that this key combination was successfully intercepted.
#### Using third-party libraries
If you don't want to do manual shortcut parsing, there are libraries that do
advanced key detection, such as [mousetrap][]. Below are examples of usage of the
`mousetrap` running in the Renderer process:
```js @ts-nocheck
Mousetrap.bind('4', () => { console.log('4') })
Mousetrap.bind('?', () => { console.log('show shortcuts!') })
Mousetrap.bind('esc', () => { console.log('escape') }, 'keyup')
// combinations
Mousetrap.bind('command+shift+k', () => { console.log('command shift k') })
// map multiple combinations to the same callback
Mousetrap.bind(['command+k', 'ctrl+k'], () => {
console.log('command k or control k')
// return false to prevent default behavior and stop event from bubbling
return false
})
// gmail style sequences
Mousetrap.bind('g i', () => { console.log('go to inbox') })
Mousetrap.bind('* a', () => { console.log('select all') })
// konami code!
Mousetrap.bind('up up down down left right left right b a enter', () => {
console.log('konami code')
})
```
[Menu]: ../api/menu.md
[MenuItem]: ../api/menu-item.md
[globalShortcut]: ../api/global-shortcut.md
[`accelerator`]: ../api/accelerator.md
[BrowserWindow]: ../api/browser-window.md
[mousetrap]: https://github.com/ccampbell/mousetrap
[dom-events]: https://developer.mozilla.org/en-US/docs/Web/Events
[addEventListener-api]: https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener
[tutorial-starter-code]: tutorial-2-first-app.md#final-starter-code

View File

@@ -1,76 +1,73 @@
---
title: Dock
description: Configure your application's Dock presence on macOS.
title: Dock Menu
description: Configure your app's Dock presence on macOS.
slug: macos-dock
hide_title: true
---
# Dock
# Dock Menu
Electron has APIs to configure the app's icon in the macOS Dock. A macOS-only
API exists to create a custom dock menu, but Electron also uses the app dock
icon as the entry point for cross-platform features like
[recent documents][recent-documents] and [application progress][progress-bar].
On macOS, the [Dock](https://support.apple.com/en-ca/guide/mac-help/mh35859/mac) is an interface
element that displays open and frequently-used apps. While opened or pinned, each app has its own
icon in the Dock.
The custom dock is commonly used to add shortcuts to tasks the user wouldn't
want to open the whole app window for.
> [!NOTE]
> On macOS, the Dock is the entry point for certain cross-platform features like
> [Recent Documents](./recent-documents.md) and [Application Progress](./progress-bar.md).
> Read those guides for more details.
**Dock menu of Terminal.app:**
## Dock API
![Dock Menu][dock-menu-image]
All functionality for the Dock is exposed via the [Dock](../api/dock.md) class exposed via
[`app.dock`](../api/app.md#appdock-macos-readonly) property. There is a single `Dock` instance per
Electron application, and this property only exists on macOS.
To set your custom dock menu, you need to use the
[`app.dock.setMenu`](../api/dock.md#docksetmenumenu-macos) API,
which is only available on macOS.
One of the main uses for your app's Dock icon is to expose additional app menus. The Dock menu is
triggered by right-clicking or <kbd>Ctrl</kbd>-clicking the app icon. By default, the app's Dock menu
will come with system-provided window management utilities, including the ability to show all windows,
hide the app, and switch betweeen different open windows.
```fiddle docs/fiddles/features/macos-dock-menu
To set an app-defined custom Dock menu, pass any [Menu](../api/menu.md) instance into the
[`dock.setMenu`](../api/dock.md#docksetmenumenu-macos) API.
> [!TIP]
> For best practices to make your Dock menu feel more native, see Apple's
> [Human Interface Guidelines](https://developer.apple.com/design/human-interface-guidelines/dock-menus)
> page on Dock menus.
## Attaching a context menu
```js title='Setting a Dock menu'
const { app, BrowserWindow, Menu } = require('electron/main')
function createWindow () {
const win = new BrowserWindow({
width: 800,
height: 600
})
win.loadFile('index.html')
}
const dockMenu = Menu.buildFromTemplate([
{
label: 'New Window',
click () { console.log('New Window') }
}, {
label: 'New Window with Settings',
submenu: [
{ label: 'Basic' },
{ label: 'Pro' }
]
},
{ label: 'New Command...' }
])
// dock.setMenu only works after the 'ready' event is fired
app.whenReady().then(() => {
const dockMenu = Menu.buildFromTemplate([
{
label: 'New Window',
click: () => { const win = new BrowserWindow() }
}
// add more menu options to the array
])
// Dock is undefined on platforms outside of macOS
// highlight-next-line
app.dock?.setMenu(dockMenu)
}).then(createWindow)
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
})
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow()
}
})
```
After launching the Electron application, right click the application icon.
You should see the custom menu you just defined:
> [!NOTE]
> Unlike with regular [context menus](./context-menu.md), Dock context menus don't need to be
> manually instrumented using the `menu.popup` API. Instead, the Dock object handles click events
> for you.
![macOS dock menu](../images/macos-dock-menu.png)
> [!TIP]
> To learn more about crafting menus in Electron, see the [Menus](./menus.md#building-menus) guide.
[dock-menu-image]: https://cloud.githubusercontent.com/assets/639601/5069962/6032658a-6e9c-11e4-9953-aa84006bdfff.png
[recent-documents]: ./recent-documents.md
[progress-bar]: ./progress-bar.md
## Runnable Fiddle demo
Below is a runnable example of how you can use the Dock menu to create and close windows in your
Electron app.
```fiddle docs/fiddles/menus/dock-menu
```

348
docs/tutorial/menus.md Normal file
View File

@@ -0,0 +1,348 @@
---
title: Menus
description: Configure cross-platform native OS menus with the Menu API.
slug: menus
hide_title: true
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import DocCardList from '@theme/DocCardList';
# Menus
Electron's [Menu](../api/menu.md) class provides a standardized way to create cross-platform native
menus throughout your application.
## Available menus in Electron
The same menu API is used for multiple use cases:
* The **application menu** is the top-level menu for your application. Each app only has a single
application menu at a time.
* **Context menus** are triggered by the user when right-clicking on a portion of your app's
interface.
* The **tray menu** is a special context menu triggered when right-clicking on your app's [Tray](../api/tray.md)
instance.
* On macOS, the **dock menu** is a special context menu triggered when right-clicking on your app's
icon in the system [Dock](https://support.apple.com/en-ca/guide/mac-help/mh35859/mac).
To learn more about the various kinds of native menus you can create and how to specify keyboard
shortcuts, see the individual guides in this section:
<DocCardList />
## Building menus
Each `Menu` instance is composed of an array of [MenuItem](../api/menu-item.md) objects accessible via
the `menu.items` instance property. Menus can be nested by setting the `item.submenu` property to
another menu.
There are two ways to build a menu: either by directly calling [`menu.append`](../api/menu.md#menuappendmenuitem)
or by using the static [`Menu.buildFromTemplate`](../api/menu.md#menubuildfromtemplatetemplate)
helper function.
The helper function reduces boilerplate by allowing you to pass a collection of `MenuItem`
constructor options (or instantiated `MenuItem` instances) in a single array rather than having to
append each item in a separate function call.
Below is an example of a minimal application menu:
<Tabs>
<TabItem value="constructor" label="Constructor">
```js title='menu.js'
const submenu = new Menu()
submenu.append(new MenuItem({ label: 'Hello' }))
submenu.append(new MenuItem({ type: 'separator' }))
submenu.append(new MenuItem({ label: 'Electron', type: 'checkbox', checked: true }))
const menu = new Menu()
menu.append(new MenuItem({ label: 'Menu', submenu }))
Menu.setApplicationMenu(menu)
```
</TabItem>
<TabItem value="template" label="Template Helper">
```js title='menu.js'
const menu = Menu.buildFromTemplate([{
label: 'Menu',
submenu: [
{ label: 'Hello' },
{ type: 'separator' },
{ label: 'Electron', type: 'checkbox', checked: true }
]
}])
Menu.setApplicationMenu(menu)
```
</TabItem>
</Tabs>
> [!IMPORTANT]
> All menu items (except for the `separator` type) must have a label. Labels can either be manually
> defined using the `label` property or inherited from the item's `role`.
### Types
A menu item's type grants it a particular appearance and functionality. Some types are
automatically assigned based on other constructor options:
* By default, menu items have the `normal` type.
* Menu items that contain the `submenu` property will be assigned the `submenu` type.
Other available types, when specified, give special additional properties to the menu item:
* `checkbox` - toggles the `checked` property whenever the menu item is clicked
* `radio` - toggles the `checked` property and turns off that property for all adjacent `radio` items
* `palette` - creates a [Palette](https://developer.apple.com/documentation/appkit/nsmenu/presentationstyle-swift.enum/palette)
submenu, which aligns items horizontally (available on macOS 14 and above)
* `header` - creates a section header, which can convey groupings with labels (available on macOS 14 and above)
> [!TIP]
> Adjacent `radio` items are at the same level of submenu and not divided by a separator.
>
> ```js
> [
> { type: 'radio', label: 'Adjacent 1' },
> { type: 'radio', label: 'Adjacent 2' },
> { type: 'separator' },
> { type: 'radio', label: 'Non-adjacent' } // unaffected by the others
> ]
> ```
### Roles
Roles give `normal` type menu items predefined behaviors.
We recommend specifying the `role` attribute for any menu item that matches a standard role
rather than trying to manually implement the behavior in a `click` function.
The built-in `role` behavior will give the best native experience.
The `label` and `accelerator` values are optional when using a `role` and will
default to appropriate values for each platform.
> [!TIP]
> Role strings are **case-insensitive**. For example, `toggleDevTools`, `toggledevtools`, and
> `TOGGLEDEVTOOLS` are all equivalent roles when defining menu items.
#### Edit roles
* `undo`
* `redo`
* `cut`
* `copy`
* `paste`
* `pasteAndMatchStyle`
* `selectAll`
* `delete`
#### Window roles
* `about` - Trigger a native about panel (custom message box on Window, which does not provide its own).
* `minimize` - Minimize current window.
* `close` - Close current window.
* `quit` - Quit the application.
* `reload` - Reload the current window.
* `forceReload` - Reload the current window ignoring the cache.
* `toggleDevTools` - Toggle developer tools in the current window.
* `togglefullscreen` - Toggle full screen mode on the current window.
* `resetZoom` - Reset the focused page's zoom level to the original size.
* `zoomIn` - Zoom in the focused page by 10%.
* `zoomOut` - Zoom out the focused page by 10%.
* `toggleSpellChecker` - Enable/disable built-in spellchecker.
#### Default menu roles
* `fileMenu` - The submenu is a "File" menu (Close / Quit)
* `editMenu` - The submenu is an "Edit" menu (Undo, Copy, etc.)
* `viewMenu` - The submenu is a "View" menu (Reload, Toggle Developer Tools, etc.)
* `windowMenu` - The submenu is a "Window" menu (Minimize, Zoom, etc.)
#### macOS-only roles
macOS has a number of platform-specific menu roles available. Many of these map to underlying
[AppKit](https://developer.apple.com/documentation/appkit) APIs.
##### App management roles
* `hide` - Map to the [`hide`](https://developer.apple.com/documentation/appkit/nsapplication/hide(_:)) action.
* `hideOthers` - Map to the [`hideOtherApplications`](https://developer.apple.com/documentation/appkit/nsapplication/hideotherapplications(_:)) action.
* `unhide` - Map to the [`unhideAllApplications`](https://developer.apple.com/documentation/appkit/nsapplication/unhideallapplications(_:)) action.
* `front` - Map to the [`arrangeInFront`](https://developer.apple.com/documentation/appkit/nsapplication/arrangeinfront(_:)) action.
* `zoom` - Map to the [`performZoom`](https://developer.apple.com/documentation/appkit/nswindow/performzoom(_:)) action.
##### Edit roles
* `showSubstitutions` - Map to the [`orderFrontSubstitutionsPanel`](https://developer.apple.com/documentation/appkit/nstextview/orderfrontsubstitutionspanel(_:)) action.
* `toggleSmartQuotes` - Map to the [`toggleAutomaticQuoteSubstitution`](https://developer.apple.com/documentation/appkit/nstextview/toggleautomaticquotesubstitution(_:)) action.
* `toggleSmartDashes` - Map to the [`toggleAutomaticDashSubstitution`](https://developer.apple.com/documentation/appkit/nstextview/toggleautomaticdashsubstitution(_:)) action.
* `toggleTextReplacement` - Map to the [`toggleAutomaticTextReplacement`](https://developer.apple.com/documentation/appkit/nstextview/toggleautomatictextreplacement(_:)) action.
##### Speech roles
* `startSpeaking` - Map to the [`startSpeaking`](https://developer.apple.com/documentation/appkit/nstextview/startspeaking(_:)) action.
* `stopSpeaking` - Map to the [`stopSpeaking`](https://developer.apple.com/documentation/appkit/nstextview/stopspeaking(_:)) action.
##### Native tab roles
* `toggleTabBar` - Map to the [`toggleTabBar`](https://developer.apple.com/documentation/appkit/nswindow/toggletabbar(_:)) action.
* `selectNextTab` - Map to the [`selectNextTab`](https://developer.apple.com/documentation/appkit/nswindow/selectnexttab(_:)) action.
* `selectPreviousTab` - Map to the [`selectPreviousTab`](https://developer.apple.com/documentation/appkit/nswindow/selectprevioustab(_:)) action.
<!-- * `showAllTabs` - Map to the `showAllTabs` action. -->
* `mergeAllWindows` - Map to the [`mergeAllWindows`](https://developer.apple.com/documentation/appkit/nswindow/mergeallwindows(_:)) action.
* `moveTabToNewWindow` - Map to the [`moveTabToNewWindow`](https://developer.apple.com/documentation/appkit/nswindow/movetabtonewwindow(_:)) action.
##### Default menu roles
* `appMenu` - Whole default "App" menu (About, Services, etc.)
* `services` - The submenu is a ["Services"](https://developer.apple.com/documentation/appkit/nsapplication/1428608-servicesmenu?language=objc) menu.
* `window` - The submenu is a "Window" menu.
* `help` - The submenu is a "Help" menu.
##### Other menu roles
* `recentDocuments` - The submenu is an "Open Recent" menu.
* `clearRecentDocuments` - Map to the [`clearRecentDocuments`](https://developer.apple.com/documentation/appkit/nsdocumentcontroller/clearrecentdocuments(_:)) action.
* `shareMenu` - The submenu is [share menu][ShareMenu]. The `sharingItem` property must also be set to indicate the item to share.
> [!IMPORTANT]
> 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.
### Accelerators
The `accelerator` property allows you to define accelerator strings to map menu items to keyboard
shortcuts. For more details, see the [Keyboard Shortcuts](./keyboard-shortcuts.md) guide.
## Advanced configuration
### Programmatic item positioning
You can make use of the `before`, `after`, `beforeGroupContaining`, `afterGroupContaining` and `id` attributes
to control how menu items will be placed when building a menu with `Menu.buildFromTemplate`.
* `before` - Inserts this item before the item with the specified id. If the
referenced item doesn't exist, the item will be inserted at the end of
the menu. Also implies that the menu item in question should be placed in the same “group” as the item.
* `after` - Inserts this item after the item with the specified id. If the
referenced item doesn't exist, the item will be inserted at the end of
the menu. Also implies that the menu item in question should be placed in the same “group” as the item.
* `beforeGroupContaining` - Provides a means for a single context menu to declare
the placement of their containing group before the containing group of the item with the specified id.
* `afterGroupContaining` - Provides a means for a single context menu to declare
the placement of their containing group after the containing group of the item with the specified id.
By default, items will be inserted in the order they exist in the template unless one of the specified
positioning keywords is used.
#### Examples
Template:
```js
[
{ id: '1', label: 'one' },
{ id: '2', label: 'two' },
{ id: '3', label: 'three' },
{ id: '4', label: 'four' }
]
```
Menu:
```plaintext
- one
- two
- three
- four
```
Template:
```js
[
{ id: '1', label: 'one' },
{ type: 'separator' },
{ id: '3', label: 'three', beforeGroupContaining: ['1'] },
{ id: '4', label: 'four', afterGroupContaining: ['2'] },
{ type: 'separator' },
{ id: '2', label: 'two' }
]
```
Menu:
```plaintext
- three
- four
- ---
- one
- ---
- two
```
Template:
```js
[
{ id: '1', label: 'one', after: ['3'] },
{ id: '2', label: 'two', before: ['1'] },
{ id: '3', label: 'three' }
]
```
Menu:
```plaintext
- ---
- three
- two
- one
```
### Icons
To add visual aid to your menus, you can use the `icon` property to assign images to individual
`MenuItem` instances.
```js title='Adding a little green circle to a menu item'
const { nativeImage } = require('electron/common')
const { MenuItem } = require('electron/main')
// highlight-next-line
const green = nativeImage.createFromDataURL('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAACOSURBVHgBpZLRDYAgEEOrEzgCozCCGzkCbKArOIlugJvgoRAUNcLRpvGH19TkgFQWkqIohhK8UEaKwKcsOg/+WR1vX+AlA74u6q4FqgCOSzwsGHCwbKliAF89Cv89tWmOT4VaVMoVbOBrdQUz+FrD6XItzh4LzYB1HFJ9yrEkZ4l+wvcid9pTssh4UKbPd+4vED2Nd54iAAAAAElFTkSuQmCC')
const item = new MenuItem({
label: 'Green Circle',
// highlight-next-line
icon: green
})
```
### Sublabels _macOS_
You can add sublabels (also known as [subtitles](https://developer.apple.com/documentation/appkit/nsmenuitem/subtitle))
to menu items using the `sublabel` option on macOS 14.4 and above.
```js title='Adding descriptions via sublabel'
const { MenuItem } = require('electron/main')
const item = new MenuItem({
label: 'Log Message',
// highlight-next-line
sublabel: 'This will use the console.log utility',
click: () => { console.log('Logging via menu...') }
})
```
### Tooltips _macOS_
Tooltips are informational indicators that appear when you hover over a menu item. You can set menu
item tooltips on macOS using the `toolTip` option.
```js title='Adding additional information via tooltip'
const { MenuItem } = require('electron/main')
const item = new MenuItem({
label: 'Hover Over Me',
// highlight-next-line
toolTip: 'This is additional info that appears on hover'
})
```

File diff suppressed because it is too large Load Diff

View File

@@ -77,6 +77,11 @@ To clear the list of recent documents, use the
In this guide, the list of documents is cleared once all windows have been
closed.
#### Accessing the list of recent documents
To access the list of recent documents, use the
[app.getRecentDocuments][getrecentdocuments] API.
## Additional information
### Windows Notes
@@ -138,5 +143,6 @@ of `app` module will be emitted for it.
[dock-menu-image]: https://cloud.githubusercontent.com/assets/639601/5069610/2aa80758-6e97-11e4-8cfb-c1a414a10774.png
[addrecentdocument]: ../api/app.md#appaddrecentdocumentpath-macos-windows
[clearrecentdocuments]: ../api/app.md#appclearrecentdocuments-macos-windows
[getrecentdocuments]: ../api/app.md#appgetrecentdocuments-macos-windows
[app-registration]: https://learn.microsoft.com/en-us/windows/win32/shell/app-registration
[menu-item-image]: https://user-images.githubusercontent.com/3168941/33003655-ea601c3a-cd70-11e7-97fa-7c062149cfb1.png

View File

@@ -1,83 +1,86 @@
---
title: Tray
description: This guide will take you through the process of creating
a Tray icon with its own context menu to the system's notification area.
title: Tray Menu
description: Create a Tray icon with its own menu in the system's notification area.
slug: tray
hide_title: true
---
# Tray
# Tray Menu
## Overview
This guide will take you through the process of creating an icon with its own context menu to the
system tray.
<!-- ✍ Update this section if you want to provide more details -->
* On macOS, the icon will be located on the top right corner of your screen in the
[menu bar extras](https://developer.apple.com/design/human-interface-guidelines/the-menu-bar#Menu-bar-extras)
area.
* On Windows, the icon will be located in the [notification area](https://learn.microsoft.com/en-us/windows/win32/shell/notification-area)
at the end of the taskbar.
* On Linux, the location of the Tray will differ based on your desktop environment.
This guide will take you through the process of creating a
[Tray](../api/tray.md) icon with
its own context menu to the system's notification area.
## Creating a Tray icon
On MacOS and Ubuntu, the Tray will be located on the top
right corner of your screen, adjacent to your battery and wifi icons.
On Windows, the Tray will usually be located in the bottom right corner.
The tray icon for your Electron app needs to be created programmatically with an instance of
the [Tray](../api/tray.md#new-trayimage-guid) class. The class constructor requires a single
instance of a [NativeImage](../api/native-image.md#class-nativeimage) or a path to a compatible icon
file.
## Example
> [!NOTE]
> File formats vary per operating system. For more details, see the
> [Platform Considerations](../api/tray.md#platform-considerations) section of the Tray API documentation.
### main.js
## Minimizing to tray
First we must import `app`, `Tray`, `Menu`, `nativeImage` from `electron`.
In order to keep the app and the system tray icon alive even when all windows are closed, you need to
have a listener for the [`window-all-closed`](../api/app.md#event-window-all-closed) event on the
`app` module. The base Electron templates generally listen for this event but quit the app on
Windows and Linux to emulate standard OS behavior.
```js
const { app, Tray, Menu, nativeImage } = require('electron')
```
Next we will create our Tray. To do this, we will use a
[`NativeImage`](../api/native-image.md) icon,
which can be created through any one of these
[methods](../api/native-image.md#methods).
Note that we wrap our Tray creation code within an
[`app.whenReady`](../api/app.md#appwhenready)
as we will need to wait for our electron app to finish initializing.
```js title='main.js'
let tray
app.whenReady().then(() => {
const icon = nativeImage.createFromPath('path/to/asset.png')
tray = new Tray(icon)
// note: your contextMenu, Tooltip and Title code will go here!
```js title='Setting up minimize to tray'
app.on('window-all-closed', () => {
// having this listener active will prevent the app from quitting.
})
```
Great! Now we can start attaching a context menu to our Tray, like so:
## Attaching a context menu
```js @ts-expect-error=[8]
const contextMenu = Menu.buildFromTemplate([
{ label: 'Item1', type: 'radio' },
{ label: 'Item2', type: 'radio' },
{ label: 'Item3', type: 'radio', checked: true },
{ label: 'Item4', type: 'radio' }
])
You can attach a context menu to the Tray object by passing in a [Menu](../api/menu.md) instance
into the [`tray.setContextMenu`](../api/tray.md#traysetcontextmenumenu) function.
tray.setContextMenu(contextMenu)
> [!NOTE]
> Unlike with regular [context menus](./context-menu.md), Tray context menus don't need to be
> manually instrumented using the `menu.popup` API. Instead, the Tray object handles click events
> for you (although various click-related events exist on the API for advanced use cases).
```js title='Creating a Tray menu that can quit the app'
const { nativeImage } = require('electron/common')
const { app, Tray, Menu } = require('electron/main')
// save a reference to the Tray object globally to avoid garbage collection
let tray
// 16x16 red circle data URL
const icon = nativeImage.createFromDataURL('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAACTSURBVHgBpZKBCYAgEEV/TeAIjuIIbdQIuUGt0CS1gW1iZ2jIVaTnhw+Cvs8/OYDJA4Y8kR3ZR2/kmazxJbpUEfQ/Dm/UG7wVwHkjlQdMFfDdJMFaACebnjJGyDWgcnZu1/lrCrl6NCoEHJBrDwEr5NrT6ko/UV8xdLAC2N49mlc5CylpYh8wCwqrvbBGLoKGvz8Bfq0QPWEUo/EAAAAASUVORK5CYII=')
// The Tray can only be instantiated after the 'ready' event is fired
app.whenReady().then(() => {
tray = new Tray(icon)
const contextMenu = Menu.buildFromTemplate([
{ role: 'quit' }
])
tray.setContextMenu(contextMenu)
})
```
The code above will create 4 separate radio-type items in the context menu.
To read more about constructing native menus, click
[here](../api/menu.md#menubuildfromtemplatetemplate).
> [!TIP]
> To learn more about crafting menus in Electron, see the [Menus](./menus.md#building-menus) guide.
Finally, let's give our tray a tooltip and a title.
> [!WARNING]
> The `enabled` and `visibility` properties are not available for top-level menu items in the tray on macOS.
```js @ts-type={tray:Electron.Tray}
tray.setToolTip('This is my application')
tray.setTitle('This is my title')
```
## Conclusion
After you start your electron app, you should see the Tray residing
in either the top or bottom right of your screen, depending on your
operating system.
```fiddle docs/fiddles/native-ui/tray
## Runnable Fiddle demo
Below is a runnable example of attaching various menu items to the Tray's context menu that help
control app state and interact with the Tray API itself.
```fiddle docs/fiddles/menus/tray-menu
```

View File

@@ -14,7 +14,6 @@ Windows, and Linux.
> supports composing many web views. `BaseWindow` can be used interchangeably with `BrowserWindow`
> in the examples of the documents in this section.
<!-- markdownlint-disable-next-line MD033 -->
<DocCardList />
[`BaseWindow`]: ../api/base-window.md

View File

@@ -44,7 +44,7 @@ Electron combines Chromium, Node.js, and the ability to write custom native code
### Enterprise-grade
Electron is reliable, secure, stable, and mature. It is the premier choice for companies building their flagship product. We have a list of some of those companies on our homepage, but just among chat apps, Slack, Discord, and Skype are built with Electron. Among AI applications, both OpenAIs ChatGPT and Anthropics Claude use Electron. Visual Studio Code, Loom, Canva, Notion, Docker, and countless other leading developers of software bet on Electron.
Electron is reliable, secure, stable, and mature. It is the premier choice for companies building their flagship product. We have a list of some of those companies on our homepage, but just among chat apps, Slack, Discord, and Signal are built with Electron. Among AI applications, both OpenAIs ChatGPT and Anthropics Claude use Electron. Visual Studio Code, Loom, Canva, Notion, Docker, and countless other leading developers of software bet on Electron.
We did make it a priority to make Electron easy to work with and a delight for developers. Thats likely the main reason why Electron became as popular as it is today — but what keeps Electron alive and thriving is the maintainers focus on making Electron as stable, secure, performant, and capable of mission-critical use cases for end users as possible. Were building an Electron that is ready to be used in scenarios where unfixable bugs, unpatched security holes, and outages of any kind are worst-case scenarios.

View File

@@ -1,7 +1,6 @@
# THIS FILE IS AUTO-GENERATED, PLEASE DO NOT EDIT BY HAND
auto_filenames = {
api_docs = [
"docs/api/accelerator.md",
"docs/api/app.md",
"docs/api/auto-updater.md",
"docs/api/base-window.md",
@@ -168,6 +167,7 @@ auto_filenames = {
sandbox_bundle_deps = [
"lib/common/api/native-image.ts",
"lib/common/define-properties.ts",
"lib/common/deprecate.ts",
"lib/common/ipc-messages.ts",
"lib/common/web-view-methods.ts",
"lib/common/webpack-globals-provider.ts",
@@ -299,6 +299,7 @@ auto_filenames = {
"lib/common/api/native-image.ts",
"lib/common/api/shell.ts",
"lib/common/define-properties.ts",
"lib/common/deprecate.ts",
"lib/common/init.ts",
"lib/common/ipc-messages.ts",
"lib/common/web-view-methods.ts",
@@ -339,6 +340,7 @@ auto_filenames = {
"lib/common/api/native-image.ts",
"lib/common/api/shell.ts",
"lib/common/define-properties.ts",
"lib/common/deprecate.ts",
"lib/common/init.ts",
"lib/common/ipc-messages.ts",
"lib/common/webpack-provider.ts",

View File

@@ -380,6 +380,8 @@ filenames = {
"shell/browser/electron_navigation_throttle.h",
"shell/browser/electron_permission_manager.cc",
"shell/browser/electron_permission_manager.h",
"shell/browser/electron_preconnect_manager_delegate.cc",
"shell/browser/electron_preconnect_manager_delegate.h",
"shell/browser/electron_speech_recognition_manager_delegate.cc",
"shell/browser/electron_speech_recognition_manager_delegate.h",
"shell/browser/electron_web_contents_utility_handler_impl.cc",
@@ -651,6 +653,7 @@ filenames = {
"shell/common/gin_helper/function_template.cc",
"shell/common/gin_helper/function_template.h",
"shell/common/gin_helper/function_template_extensions.h",
"shell/common/gin_helper/handle.h",
"shell/common/gin_helper/locker.cc",
"shell/common/gin_helper/locker.h",
"shell/common/gin_helper/object_template_builder.cc",

View File

@@ -821,6 +821,7 @@ libcxx_headers = [
"//third_party/libc++/src/include/__cxx03/__utility/unreachable.h",
"//third_party/libc++/src/include/__cxx03/__variant/monostate.h",
"//third_party/libc++/src/include/__cxx03/__verbose_abort",
"//third_party/libc++/src/include/__cxx03/__verbose_trap",
"//third_party/libc++/src/include/__cxx03/algorithm",
"//third_party/libc++/src/include/__cxx03/array",
"//third_party/libc++/src/include/__cxx03/atomic",
@@ -989,6 +990,7 @@ libcxx_headers = [
"//third_party/libc++/src/include/__format/indic_conjunct_break_table.h",
"//third_party/libc++/src/include/__format/parser_std_format_spec.h",
"//third_party/libc++/src/include/__format/range_default_formatter.h",
"//third_party/libc++/src/include/__format/range_format.h",
"//third_party/libc++/src/include/__format/range_formatter.h",
"//third_party/libc++/src/include/__format/unicode.h",
"//third_party/libc++/src/include/__format/width_estimation_table.h",
@@ -1084,6 +1086,7 @@ libcxx_headers = [
"//third_party/libc++/src/include/__iterator/ostreambuf_iterator.h",
"//third_party/libc++/src/include/__iterator/permutable.h",
"//third_party/libc++/src/include/__iterator/prev.h",
"//third_party/libc++/src/include/__iterator/product_iterator.h",
"//third_party/libc++/src/include/__iterator/projected.h",
"//third_party/libc++/src/include/__iterator/ranges_iterator_traits.h",
"//third_party/libc++/src/include/__iterator/readable_traits.h",
@@ -1096,13 +1099,18 @@ libcxx_headers = [
"//third_party/libc++/src/include/__iterator/unreachable_sentinel.h",
"//third_party/libc++/src/include/__iterator/wrap_iter.h",
"//third_party/libc++/src/include/__locale",
"//third_party/libc++/src/include/__locale_dir/locale_base_api/android.h",
"//third_party/libc++/src/include/__locale_dir/check_grouping.h",
"//third_party/libc++/src/include/__locale_dir/get_c_locale.h",
"//third_party/libc++/src/include/__locale_dir/locale_base_api/bsd_locale_fallbacks.h",
"//third_party/libc++/src/include/__locale_dir/locale_base_api/ibm.h",
"//third_party/libc++/src/include/__locale_dir/locale_base_api/musl.h",
"//third_party/libc++/src/include/__locale_dir/locale_base_api/openbsd.h",
"//third_party/libc++/src/include/__locale_dir/locale_base_api.h",
"//third_party/libc++/src/include/__locale_dir/messages.h",
"//third_party/libc++/src/include/__locale_dir/money.h",
"//third_party/libc++/src/include/__locale_dir/num.h",
"//third_party/libc++/src/include/__locale_dir/pad_and_output.h",
"//third_party/libc++/src/include/__locale_dir/scan_keyword.h",
"//third_party/libc++/src/include/__locale_dir/support/apple.h",
"//third_party/libc++/src/include/__locale_dir/support/bsd_like.h",
"//third_party/libc++/src/include/__locale_dir/support/freebsd.h",
@@ -1111,6 +1119,10 @@ libcxx_headers = [
"//third_party/libc++/src/include/__locale_dir/support/no_locale/characters.h",
"//third_party/libc++/src/include/__locale_dir/support/no_locale/strtonum.h",
"//third_party/libc++/src/include/__locale_dir/support/windows.h",
"//third_party/libc++/src/include/__locale_dir/time.h",
"//third_party/libc++/src/include/__locale_dir/wbuffer_convert.h",
"//third_party/libc++/src/include/__locale_dir/wstring_convert.h",
"//third_party/libc++/src/include/__log_hardening_failure",
"//third_party/libc++/src/include/__math/abs.h",
"//third_party/libc++/src/include/__math/copysign.h",
"//third_party/libc++/src/include/__math/error_functions.h",
@@ -1292,6 +1304,7 @@ libcxx_headers = [
"//third_party/libc++/src/include/__ranges/iota_view.h",
"//third_party/libc++/src/include/__ranges/istream_view.h",
"//third_party/libc++/src/include/__ranges/join_view.h",
"//third_party/libc++/src/include/__ranges/join_with_view.h",
"//third_party/libc++/src/include/__ranges/lazy_split_view.h",
"//third_party/libc++/src/include/__ranges/movable_box.h",
"//third_party/libc++/src/include/__ranges/non_propagating_cache.h",
@@ -1312,6 +1325,7 @@ libcxx_headers = [
"//third_party/libc++/src/include/__ranges/transform_view.h",
"//third_party/libc++/src/include/__ranges/view_interface.h",
"//third_party/libc++/src/include/__ranges/views.h",
"//third_party/libc++/src/include/__ranges/zip_transform_view.h",
"//third_party/libc++/src/include/__ranges/zip_view.h",
"//third_party/libc++/src/include/__split_buffer",
"//third_party/libc++/src/include/__std_mbstate_t.h",
@@ -1355,16 +1369,14 @@ libcxx_headers = [
"//third_party/libc++/src/include/__tuple/make_tuple_types.h",
"//third_party/libc++/src/include/__tuple/sfinae_helpers.h",
"//third_party/libc++/src/include/__tuple/tuple_element.h",
"//third_party/libc++/src/include/__tuple/tuple_indices.h",
"//third_party/libc++/src/include/__tuple/tuple_like.h",
"//third_party/libc++/src/include/__tuple/tuple_like_ext.h",
"//third_party/libc++/src/include/__tuple/tuple_like_no_subrange.h",
"//third_party/libc++/src/include/__tuple/tuple_size.h",
"//third_party/libc++/src/include/__tuple/tuple_types.h",
"//third_party/libc++/src/include/__type_traits/add_cv_quals.h",
"//third_party/libc++/src/include/__type_traits/add_lvalue_reference.h",
"//third_party/libc++/src/include/__type_traits/add_pointer.h",
"//third_party/libc++/src/include/__type_traits/add_rvalue_reference.h",
"//third_party/libc++/src/include/__type_traits/add_reference.h",
"//third_party/libc++/src/include/__type_traits/aligned_storage.h",
"//third_party/libc++/src/include/__type_traits/aligned_union.h",
"//third_party/libc++/src/include/__type_traits/alignment_of.h",
@@ -1386,6 +1398,7 @@ libcxx_headers = [
"//third_party/libc++/src/include/__type_traits/extent.h",
"//third_party/libc++/src/include/__type_traits/has_unique_object_representation.h",
"//third_party/libc++/src/include/__type_traits/has_virtual_destructor.h",
"//third_party/libc++/src/include/__type_traits/integer_traits.h",
"//third_party/libc++/src/include/__type_traits/integral_constant.h",
"//third_party/libc++/src/include/__type_traits/invoke.h",
"//third_party/libc++/src/include/__type_traits/is_abstract.h",
@@ -1436,7 +1449,6 @@ libcxx_headers = [
"//third_party/libc++/src/include/__type_traits/is_same.h",
"//third_party/libc++/src/include/__type_traits/is_scalar.h",
"//third_party/libc++/src/include/__type_traits/is_signed.h",
"//third_party/libc++/src/include/__type_traits/is_signed_integer.h",
"//third_party/libc++/src/include/__type_traits/is_specialization.h",
"//third_party/libc++/src/include/__type_traits/is_standard_layout.h",
"//third_party/libc++/src/include/__type_traits/is_swappable.h",
@@ -1450,7 +1462,6 @@ libcxx_headers = [
"//third_party/libc++/src/include/__type_traits/is_unbounded_array.h",
"//third_party/libc++/src/include/__type_traits/is_union.h",
"//third_party/libc++/src/include/__type_traits/is_unsigned.h",
"//third_party/libc++/src/include/__type_traits/is_unsigned_integer.h",
"//third_party/libc++/src/include/__type_traits/is_valid_expansion.h",
"//third_party/libc++/src/include/__type_traits/is_void.h",
"//third_party/libc++/src/include/__type_traits/is_volatile.h",
@@ -1521,6 +1532,7 @@ libcxx_headers = [
"//third_party/libc++/src/include/__vector/vector_bool.h",
"//third_party/libc++/src/include/__vector/vector_bool_formatter.h",
"//third_party/libc++/src/include/__verbose_abort",
"//third_party/libc++/src/include/__verbose_trap",
"//third_party/libc++/src/include/algorithm",
"//third_party/libc++/src/include/any",
"//third_party/libc++/src/include/array",

View File

@@ -1,7 +1,7 @@
import { IpcMainImpl } from '@electron/internal/browser/ipc-main-impl';
import { MessagePortMain } from '@electron/internal/browser/message-port-main';
const { WebFrameMain, fromId } = process._linkedBinding('electron_browser_web_frame_main');
const { WebFrameMain, fromId, fromFrameToken } = process._linkedBinding('electron_browser_web_frame_main');
Object.defineProperty(WebFrameMain.prototype, 'ipc', {
get () {
@@ -43,5 +43,6 @@ WebFrameMain.prototype.postMessage = function (...args) {
};
export default {
fromId
fromId,
fromFrameToken
};

View File

@@ -80,7 +80,7 @@ function makeLoadURLOptions (params: Record<string, any>) {
}
// Create a new guest instance.
const createGuest = function (embedder: Electron.WebContents, embedderFrameId: number, elementInstanceId: number, params: Record<string, any>) {
const createGuest = function (embedder: Electron.WebContents, embedderFrameToken: string, elementInstanceId: number, params: Record<string, any>) {
const webPreferences = makeWebPreferences(embedder, params);
const event = {
sender: embedder,
@@ -198,7 +198,7 @@ const createGuest = function (embedder: Electron.WebContents, embedderFrameId: n
watchEmbedder(embedder);
webViewManager.addGuest(guestInstanceId, embedder, guest, webPreferences);
guest.attachToIframe(embedder, embedderFrameId);
guest.attachToIframe(embedder, embedderFrameToken);
return guestInstanceId;
};
@@ -286,8 +286,8 @@ const handleMessageSync = function (channel: string, handler: (event: { sender:
ipcMainUtils.handleSync(channel, makeSafeHandler(channel, handler));
};
handleMessage(IPC_MESSAGES.GUEST_VIEW_MANAGER_CREATE_AND_ATTACH_GUEST, function (event, embedderFrameId: number, elementInstanceId: number, params) {
return createGuest(event.sender, embedderFrameId, elementInstanceId, params);
handleMessage(IPC_MESSAGES.GUEST_VIEW_MANAGER_CREATE_AND_ATTACH_GUEST, function (event, embedderFrameToken: string, elementInstanceId: number, params) {
return createGuest(event.sender, embedderFrameToken, elementInstanceId, params);
});
handleMessageSync(IPC_MESSAGES.GUEST_VIEW_MANAGER_DETACH_GUEST, function (event, guestInstanceId: number) {

View File

@@ -3,6 +3,7 @@ import * as ipcMainUtils from '@electron/internal/browser/ipc-main-internal-util
import { IPC_MESSAGES } from '@electron/internal/common/ipc-messages';
import { clipboard } from 'electron/common';
import { webFrameMain } from 'electron/main';
import * as fs from 'fs';
import * as path from 'path';
@@ -109,3 +110,17 @@ ipcMainInternal.on(IPC_MESSAGES.BROWSER_PRELOAD_ERROR, function (event, preloadP
if (event.type !== 'frame') return;
event.sender?.emit('preload-error', event, preloadPath, error);
});
ipcMainUtils.handleSync(IPC_MESSAGES.BROWSER_GET_FRAME_ROUTING_ID_SYNC, function (event, frameToken: string) {
if (event.type !== 'frame') return;
const senderFrame = event.senderFrame;
if (!senderFrame || senderFrame.isDestroyed()) return;
return webFrameMain.fromFrameToken(senderFrame.processId, frameToken)?.routingId;
});
ipcMainUtils.handleSync(IPC_MESSAGES.BROWSER_GET_FRAME_TOKEN_SYNC, function (event, routingId: number) {
if (event.type !== 'frame') return;
const senderFrame = event.senderFrame;
if (!senderFrame || senderFrame.isDestroyed()) return;
return webFrameMain.fromId(senderFrame.processId, routingId)?.frameToken;
});

View File

@@ -22,7 +22,6 @@ export const webViewEvents: Record<string, readonly string[]> = {
'-focus-change': ['focus'],
close: [],
'render-process-gone': ['details'],
'plugin-crashed': ['name', 'version'],
destroyed: [],
'page-title-updated': ['title', 'explicitSet'],
'page-favicon-updated': ['favicons'],

View File

@@ -93,20 +93,23 @@ makeElectronModule('electron');
makeElectronModule('electron/common');
if (process.type === 'browser') {
makeElectronModule('electron/main');
}
if (process.type === 'renderer') {
} else if (process.type === 'renderer') {
makeElectronModule('electron/renderer');
} else if (process.type === 'utility') {
makeElectronModule('electron/utility');
}
const originalResolveFilename = Module._resolveFilename;
// 'electron/main', 'electron/renderer' and 'electron/common' are module aliases
// 'electron/{common,main,renderer,utility}' are module aliases
// of the 'electron' module for TypeScript purposes, i.e., the types for
// 'electron/main' consist of only main process modules, etc. It is intentional
// that these can be `require()`-ed from both the main process as well as the
// renderer process regardless of the names, they're superficial for TypeScript
// only.
const electronModuleNames = new Set(['electron', 'electron/main', 'electron/renderer', 'electron/common']);
const electronModuleNames = new Set([
'electron', 'electron/main', 'electron/renderer', 'electron/common', 'electron/utility'
]);
Module._resolveFilename = function (request, parent, isMain, options) {
if (electronModuleNames.has(request)) {
return 'electron';

View File

@@ -6,6 +6,8 @@ export const enum IPC_MESSAGES {
BROWSER_NONSANDBOX_LOAD = 'BROWSER_NONSANDBOX_LOAD',
BROWSER_WINDOW_CLOSE = 'BROWSER_WINDOW_CLOSE',
BROWSER_GET_PROCESS_MEMORY_INFO = 'BROWSER_GET_PROCESS_MEMORY_INFO',
BROWSER_GET_FRAME_ROUTING_ID_SYNC = 'BROWSER_GET_FRAME_ROUTING_ID_SYNC',
BROWSER_GET_FRAME_TOKEN_SYNC = 'BROWSER_GET_FRAME_TOKEN_SYNC',
GUEST_INSTANCE_VISIBILITY_CHANGE = 'GUEST_INSTANCE_VISIBILITY_CHANGE',

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