Compare commits

..

59 Commits

Author SHA1 Message Date
trop[bot]
53ab44b1f2 ci: fixup ninja for release (#37084)
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
2023-01-31 11:31:46 -05:00
trop[bot]
13549bbc7b ci: ensure correct ninja is used (#37072)
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
2023-01-30 18:15:57 -05:00
trop[bot]
e69270a600 fix: resizing borders in nondraggable regions (#37037)
* fix: resizing borders in nondraggable regions

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

* chore: remove frame handling from ShouldDescendIntoChildForEventHandling

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>
2023-01-30 11:50:01 +01:00
trop[bot]
39203e93c0 docs: updated deep link docs (#37031) 2023-01-30 10:58:26 +01:00
electron-roller[bot]
961cc47948 chore: bump chromium to 110.0.5481.52 (23-x-y) (#37035)
* chore: bump chromium in DEPS to 110.0.5481.52

* chore: update patches

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com>
2023-01-26 16:40:43 -05:00
trop[bot]
9c614be4f8 fix: fallback to GtkStatusIcon when app indicator is not supported (#37033)
* chore: get ready for multi backend tray

Co-authored-by: Cheng Zhao <zcbenz@gmail.com>

* fix: fallback to GtkStatusIcon when app indicator is not supported

Co-authored-by: Cheng Zhao <zcbenz@gmail.com>

* chore: use smart pointers

Co-authored-by: Cheng Zhao <zcbenz@gmail.com>

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Cheng Zhao <zcbenz@gmail.com>
2023-01-26 13:39:23 +01:00
trop[bot]
e5da0b5c59 chore: fix memory leak in v8.serialize() (#37030)
chore: fix memory leak in v8.serialize()

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>
2023-01-26 13:03:12 +01:00
trop[bot]
7db9895214 chore: remove crashpad related sandbox policy (#37026)
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>
2023-01-26 19:12:00 +09:00
trop[bot]
d706649da8 chore: call ListenerDestroyed() in FileSelectHelper::RunFileChooserEnd() (#37020)
chore: call ListenerDestroyed() in FileSelectHelper::RunFileChooserEnd()

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>
2023-01-26 17:27:51 +09:00
trop[bot]
51ac59e1eb chore: update README.md (#37029)
Update README.md

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

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Milan Burda <milan.burda@gmail.com>
2023-01-26 16:19:38 +09:00
trop[bot]
7623604030 fix: do not error on null exports in ESM loader (#37024)
Co-authored-by: Samuel Attard <marshallofsound@electronjs.org>

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Samuel Attard <marshallofsound@electronjs.org>
2023-01-26 16:19:07 +09:00
trop[bot]
ab2d2dc625 fix: treat maxWidth/Height<=0 as unlimited (#36511)
Co-authored-by: Jeremy Rose <jeremya@chromium.org>

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Jeremy Rose <jeremya@chromium.org>
2023-01-25 13:06:25 -08:00
David Sanders
0e8b10beba test: support running tests against Electron releases (#36969)
Co-authored-by: Charles Kerr <charles@charleskerr.com>

Co-authored-by: Charles Kerr <charles@charleskerr.com>
2023-01-24 12:00:21 -05:00
trop[bot]
e1dce7c1f7 test: add a <datalist> spec for time type (#36996)
spec: add a datalist spec for time type

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>
2023-01-24 09:07:00 +01:00
trop[bot]
266c471680 chore: cleanup autofill agent shutdown sequence (#36976)
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>
2023-01-23 13:13:56 +01:00
trop[bot]
2bc14c9b7e fix: make plugin helper executable unconditional (#36977)
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>
2023-01-21 21:41:33 +09:00
trop[bot]
b8c4a71cd7 test: fix nativeTheme test when system in dark mode (#36966)
Co-authored-by: David Sanders <dsanders11@ucsbalum.com>

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: David Sanders <dsanders11@ucsbalum.com>
2023-01-20 14:34:52 -08:00
trop[bot]
1403a48add fix: <datalist> dropdown positioning (#36959)
fix: datalist dropdown positioning

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>
2023-01-20 10:10:11 +01:00
trop[bot]
7c5430a47f docs: update clipboard fiddles (#36962)
Co-authored-by: David Sanders <dsanders11@ucsbalum.com>

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: David Sanders <dsanders11@ucsbalum.com>
2023-01-19 18:05:47 -05:00
trop[bot]
0dd5d57423 docs: Change factuality and word choice in app.runningUnderARM64Translation (#36963)
Change factuality and word choice.

Added "or WOW" to the phrase, "when they are running the x64 version under Rosetta", to reflect the use of a supported platform, Windows, as a possible scenario.
Changed the wording of that same sentence to make it appear clearer. "incorrectly" to "mistakenly" and moved this word to before the verb instead of the end of the sentence.

Co-authored-by: GGIEnrike <52293637+GGIEnrike@users.noreply.github.com>

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: GGIEnrike <52293637+GGIEnrike@users.noreply.github.com>
2023-01-19 18:03:48 -05:00
electron-roller[bot]
a49593580d chore: bump chromium to 110.0.5481.38 (23-x-y) (#36955)
* chore: bump chromium in DEPS to 110.0.5481.38

* chore: update patches

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com>
2023-01-19 12:45:11 -05:00
trop[bot]
0a6a3fd812 fix: webview background color on reload (#36938)
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2023-01-19 12:15:27 +01:00
trop[bot]
56d28dce94 feat: add label property to Display objects (#36933)
Co-authored-by: Milan Burda <milan.burda@gmail.com>

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Milan Burda <milan.burda@gmail.com>
Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
2023-01-19 15:59:12 +09:00
trop[bot]
857ce18e17 test: fix test for USB device.forget() (#36950)
Co-authored-by: David Sanders <dsanders11@ucsbalum.com>

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: David Sanders <dsanders11@ucsbalum.com>
2023-01-19 09:53:26 +09:00
electron-roller[bot]
56f042f5e5 chore: bump chromium to 110.0.5481.30 (23-x-y) (#36819)
* chore: bump chromium in DEPS to 110.0.5481.24

* chore: update patches

* 4098946: Migrate Extension::Create() argument to base::Value::Dict (part 4 of 4)

https://chromium-review.googlesource.com/c/chromium/src/+/4098946
(cherry picked from commit 716a0f66f6)

* chore: bump chromium in DEPS to 110.0.5481.30

* chore: update patches

* chore: cleanup password from keychain after test

(cherry picked from commit 6c3b0f84c5)

* 4143761: [110] Disable SwiftShader for WebGL on M1 Macs.

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

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: clavin <clavin@electronjs.org>
Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com>
2023-01-18 12:13:25 +01:00
John Kleinschmidt
ce36849a3d ci: run WOA tests on AppVeyor (23-x-y) (#36926)
ci: run WOA tests on AppVeyor
2023-01-18 12:12:42 +01:00
trop[bot]
3483a341de fix: Cmd+Tab not working when exiting kiosk mode (#36917)
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>
2023-01-17 12:15:23 +01:00
trop[bot]
e8cc2f613e chore: fix typo in promise rejection (#36896)
Co-Authored-By: Eugene Nesvetaev <github@nesvet.ru>
Co-Authored-By: David Sanders <dsanders11@ucsbalum.com>

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Eugene Nesvetaev <github@nesvet.ru>
Co-authored-by: David Sanders <dsanders11@ucsbalum.com>
2023-01-13 15:16:14 +09:00
Robo
6749f8f065 fix: missing libcxx headers (#36864)
* chore: add libcxx script to precommit hook

* chore: run gen-libc++-filename.js
2023-01-12 11:58:39 +01:00
trop[bot]
10fba52f73 build: migrate patch-up to use app creds (#36866)
Co-authored-by: Samuel Attard <samuel.r.attard@gmail.com>

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Samuel Attard <samuel.r.attard@gmail.com>
2023-01-11 17:59:32 -05:00
trop[bot]
f2daab093c fix: RTL WindowButtonsProxy buttons (#36850)
* fix: RTL WindowButtonsProxy buttons

Co-authored-by: Shelley Vohr <shelley.vohr@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: Shelley Vohr <shelley.vohr@gmail.com>
2023-01-11 20:29:41 +01:00
trop[bot]
89763c9042 fix: getUserMedia duplicate permissions call (#36874)
* fix: getUserMedia duplicate permissions call

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

* test: add regression test

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>
2023-01-11 20:21:52 +01:00
trop[bot]
c506624807 fix: handle null/undefined options for fs.readdir (#36848)
fix: handle null/undefined options for fs.readdir (#34764)

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

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: David Sanders <dsanders11@ucsbalum.com>
2023-01-11 11:56:52 +01:00
trop[bot]
3f344e91bb build: update release deps workflow (#36853)
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>
2023-01-10 21:55:48 -08:00
trop[bot]
d9533135d0 docs: add missing window-management permission value to setPermissionRequestHandler() (#36845) 2023-01-10 14:26:34 +01:00
trop[bot]
b8df68d7f4 docs: fix link in breaking-changes.md (#36838)
Co-authored-by: David Sanders <dsanders11@ucsbalum.com>

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: David Sanders <dsanders11@ucsbalum.com>
2023-01-10 09:37:07 +09:00
trop[bot]
79b07b9c70 docs: update links (#36771)
Co-authored-by: David Sanders <dsanders11@ucsbalum.com>

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: David Sanders <dsanders11@ucsbalum.com>
2023-01-10 09:34:07 +09:00
trop[bot]
bb88737b9c docs: update code highlights in tutorial (#36767)
docs: fix code highlighting in preload tutorial

The highlighted lines in the code snippets were unaligned,
which could cause a newcomer unneeded confusion on what
lines need to be changed.

Co-authored-by: Roger Zurawicki <zurawiki@users.noreply.github.com>

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Roger Zurawicki <zurawiki@users.noreply.github.com>
2023-01-10 09:33:37 +09:00
trop[bot]
6494e41306 fix: focus rings with multiple buttons in showMessageBox (#36803)
fix: focus rings with multiple buttons in messageBox

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>
2023-01-09 16:40:58 +09:00
electron-roller[bot]
5a5ea4845e chore: bump chromium to 110.0.5478.5 (23-x-y) (#36574)
* chore: bump chromium in DEPS to 110.0.5461.0

* chore: bump chromium in DEPS to 110.0.5463.0

* chore: bump chromium in DEPS to 110.0.5465.0

* chore: bump chromium in DEPS to 110.0.5467.0

* chore: bump chromium in DEPS to 110.0.5469.0

* chore: bump chromium in DEPS to 110.0.5471.0

* chore: bump chromium in DEPS to 110.0.5473.0

* chore: bump chromium in DEPS to 110.0.5475.0

* chore: bump chromium in DEPS to 110.0.5477.0

* chore: bump chromium in DEPS to 110.0.5479.0

* chore: bump chromium in DEPS to 110.0.5481.0

* chore: bump chromium in DEPS to 110.0.5481.4

* chore: bump chromium in DEPS to 110.0.5478.5

* chore: update patches

* 4074449: Add gl::FrameData to software path

https://chromium-review.googlesource.com/c/chromium/src/+/4074449
(cherry picked from commit 1f61be81384b3e22b8af8f9221a7e5ef9a4d95cb)

* fixup! 4074449: Add gl::FrameData to software path

(cherry picked from commit 2316ec931ec9cb1d4ade43df2f3663ef155c5a61)

* 4074449: Add gl::FrameData to software path

This commit also reformatted the two files in this patch. The only
change here is the addition of the |data| arg to |OnSwapBuffers|.

https://chromium-review.googlesource.com/c/chromium/src/+/4074449
(cherry picked from commit aa2504ee6b4e3a2eaf3348eb535ef8121dd6cc3b)

* 4081108: task posting v3: remove task_runner_util{.h,_unittest.cc}

https://chromium-review.googlesource.com/c/chromium/src/+/4081108
(cherry picked from commit fce317513ee15138351f8b1bdf062250d97f57b9)

* 4081108: task posting v3: remove task_runner_util{.h,_unittest.cc}

https://chromium-review.googlesource.com/c/chromium/src/+/4081108
(cherry picked from commit cb14d9f5df300020a3b8d11078656763b428789e)

* chore: add missing RefCountedMemory include

(cherry picked from commit 893a1da1ed5a461e0e46abecab2a2de545ab543b)

* 4025927: [Code Health] Migrate e/c/manifest.cc to base::Value::Dict interface

https://chromium-review.googlesource.com/c/chromium/src/+/4025927
(cherry picked from commit f9e1ce44bdbe1c199881daef2799164737e2d39d)

* 4072471: Rename Mixed Download Blocking to Insecure Download Blocking

https://chromium-review.googlesource.com/c/chromium/src/+/4072471
(cherry picked from commit e191d7526d3821ace54717ce7c8a5e95df542135)

* 4060548: Remove base::Value::GetListDeprecated().

https://chromium-review.googlesource.com/c/chromium/src/+/4060548
(cherry picked from commit f76cb2bcb4d1772c596c7e8dc5be27024e2b9cfe)

* 4032656: hid: Abstract HidSystemTrayIcon class for profiles' HID connections

https://chromium-review.googlesource.com/c/chromium/src/+/4032656
(cherry picked from commit 9737692d016d726f277c7a6ac6ec919b18820cba)

* 3903024: hid: Add connection count tracking methods for HidDelegate

https://chromium-review.googlesource.com/c/chromium/src/+/3903024
(cherry picked from commit a0299046cd3cedb1c84b4ecf867089fce9304861)

* 4076211: Turn FrameTreeNode::frame_tree into raw_ref.

https://chromium-review.googlesource.com/c/chromium/src/+/4076211
(cherry picked from commit 6cca422b421013ce166779cc9687d50301ac3280)

* 4112537: Remove DictionaryPrefUpdate.
https://chromium-review.googlesource.com/c/chromium/src/+/4112537

(cherry picked from commit ec8e8f75deed5da760c75267c5575509923ae7e4)

* 3835037: Add new slides media session actions to Picture-in-Picture window

https://chromium-review.googlesource.com/c/chromium/src/+/3835037
(cherry picked from commit 7dc35729bce450b365b8d211536a275e8e3f0a08)

* 4065264: [Extensions] Add a new side panel view type

https://chromium-review.googlesource.com/c/chromium/src/+/4065264
(cherry picked from commit c6c3c3ff8289c87a6ca831ff23100b3dde74eddf)

* 4085814: [Test Automation] Move NativeWindowTracker to ui/views

https://chromium-review.googlesource.com/c/chromium/src/+/4085814
(cherry picked from commit ffbe5437139752f507bef4c66cc958e6dcef3bce)

* chore: disable Microtask queues per WindowAgent.

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

(cherry picked from commit 0ffa9df410a27236ed73b07d5b36c84783b0f9d1)

* fixup: disable Microtask queues per WindowAgent.

(cherry picked from commit 438be771dd)

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: Shelley Vohr <shelley.vohr@gmail.com>
Co-authored-by: Calvin Watford <cwatford@slack-corp.com>
Co-authored-by: clavin <clavin@electronjs.org>
Co-authored-by: Jeremy Rose <jeremya@chromium.org>
2023-01-05 21:35:45 -05:00
trop[bot]
4076f06036 docs: Add note about argv getting modified (#36805)
Add note about argv getting modified

See https://github.com/electron/electron/issues/20322

Co-authored-by: Mikael Finstad <finstaden@gmail.com>

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Mikael Finstad <finstaden@gmail.com>
2023-01-05 12:10:25 -05:00
trop[bot]
169136c69c fix: rename WebSwapCGLLayer to WebSwapCGLLayerChromium (#36799) 2023-01-05 10:37:06 +01:00
trop[bot]
63e59a196a docs: fix broken links (#36561)
* docs: fix broken links

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

* docs: change link to navigator.getUserMedia

Co-authored-by: Jeremy Rose <nornagon@nornagon.net>

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

* docs: fix link in examples.md

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

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: David Sanders <dsanders11@ucsbalum.com>
2023-01-02 11:26:23 +01:00
trop[bot]
4d8d8f56cc docs: Fix incorrect highlight in an example snippet (#36713)
Fix incorrect highlight in an example snippet

At the moment, the "Communicating between processes" `main.js` snippet highlights the line containing `})` when the relevant line is `ipcMain.handle('ping', () => 'pong')`.

Co-authored-by: MAPGarrett <19568204+MAPGarrett@users.noreply.github.com>

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: MAPGarrett <19568204+MAPGarrett@users.noreply.github.com>
2023-01-02 10:33:43 +01:00
trop[bot]
7b7b4941fe docs: update visual studio min version (#36732)
Co-authored-by: George Xu <george.xu99@hotmail.com>

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: George Xu <george.xu99@hotmail.com>
2022-12-30 22:16:43 -08:00
trop[bot]
9537370cf6 ci: pin action shas (#36565)
Signed-off-by: StepSecurity Bot <bot@stepsecurity.io>

Co-authored-by: StepSecurity Bot <bot@stepsecurity.io>

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: StepSecurity Bot <bot@stepsecurity.io>
2022-12-20 10:17:45 -08:00
trop[bot]
8edbb1d4ae fix: blend node and blink code generation policy when both are loaded (#36667)
Co-authored-by: Jeremy Rose <jeremya@chromium.org>
2022-12-19 11:20:53 -08:00
trop[bot]
f8c0682b6e test: replace (webContents as any).destroy() with webContents.destroy() (#36669) 2022-12-19 11:17:47 -08:00
Samuel Attard
8a10a90ebf chore: cherry-pick 09ae62b from node (#36623)
* chore: cherry-pick 09ae62b from node

* chore: update patches

Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com>
Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
2022-12-14 16:07:02 -05:00
trop[bot]
2255705c70 fix: use the process cache to reduce the memory for asar file (#36665)
* fix: use the process cache to reduce the memory for asar file

Co-authored-by: webster.xu <webster.xu@ringcentral.com>

* Update shell/common/api/electron_api_asar.cc

Co-authored-by: Jeremy Rose <nornagon@nornagon.net>

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: webster.xu <webster.xu@ringcentral.com>
Co-authored-by: Jeremy Rose <nornagon@nornagon.net>
2022-12-14 16:05:10 -05:00
trop[bot]
74d5ddcd28 fix: strip branded binaries (#36656)
When creating branded release builds and using scripts/strip-binaries.py
on Linux, the final artifacts end up unstripped due to the static set of
binaries considered for stripping.
With this patch the name of the electron binary is taken from the
BRANDING.json `project_name` key.

Signed-off-by: Robert Günzler <r@gnzler.io>

Co-authored-by: Robert Günzler <r@gnzler.io>

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Robert Günzler <r@gnzler.io>
2022-12-14 11:50:53 -05:00
trop[bot]
bb9badc41a chore: update AppVeyor image to include latest Windows updates (#36652)
clenaup

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

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: VerteDinde <vertedinde@electronjs.org>
2022-12-13 16:58:37 -05:00
trop[bot]
10632e3f54 docs: link net.request options to ClientRequestConstructorOptions (#36570)
Co-authored-by: Samuel Attard <samuel.r.attard@gmail.com>

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Samuel Attard <samuel.r.attard@gmail.com>
2022-12-13 10:53:49 -08:00
trop[bot]
6010ac6c76 docs: add mdn link to web-request-filter.md (#36616)
* Add MDN link to web-request-filter.md

When I was using the Electron docs I wanted to know how to use [webRequest.onBeforeSendHeaders](https://www.electronjs.org/docs/latest/api/web-request#webrequestonbeforesendheadersfilter-listener) but I was unable to correctly guess the correct format for the `WebRequestFilter` URL strings, and there was no explanation in the Electron docs. Eventually I googled it and found the MDN article which helped me.

Co-authored-by: Hugh Davey <9026053+hughjdavey@users.noreply.github.com>

* Update docs/api/structures/web-request-filter.md

Co-authored-by: Black-Hole <158blackhole@gmail.com>

Co-authored-by: Hugh Davey <9026053+hughjdavey@users.noreply.github.com>

* Update docs/api/structures/web-request-filter.md

Co-authored-by: Black-Hole <158blackhole@gmail.com>

Co-authored-by: Hugh Davey <9026053+hughjdavey@users.noreply.github.com>

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Hugh Davey <9026053+hughjdavey@users.noreply.github.com>
2022-12-08 14:55:35 -08:00
trop[bot]
1c1a0cdead chore: bump chromium to 110.0.5451.0 (23-x-y) (#36568)
chore: bump chromium to 110.0.5451.0 (main) (#36394)

* chore: bump chromium in DEPS to 110.0.5425.0

* chore: bump chromium in DEPS to 110.0.5427.0

* chore: bump chromium in DEPS to 110.0.5429.0

* chore: bump chromium in DEPS to 110.0.5431.0

* chore: update patches/chromium/picture-in-picture.patch to fix upstream code shear

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

* chore: sync patch w/upstream shear: remove_usage_of_incognito_apis_in_the_spellchecker.patch

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

* chore: sync patch w/upstream shear: feat_expose_raw_response_headers_from_urlloader.patch

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

* chore: sync patch w/upstream shear: chromium/custom_protocols_plzserviceworker.patch

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

* build: update references to core_api_provider; its location was moved upstream

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

* build: remove back_to_tab_image_button from our enable_picture_in_picture deps

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

back_to_tab_image_button has been removed upstream

* chore: update patches

* chore: bump chromium in DEPS to 110.0.5433.0

* chore: sync patch w/upstream shear: chromium/printing.patch

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

* chore: sync patch w/trivial upstream shear: chromium/process_singleton.patch

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

* refactor: remove kAutofillCenterAlignedSuggestions feature flag check.

This behavior had been an experiment behind a feature flag. The
experiment was a success so the feature was kept & the flag was removed.

Xref: https://chromium-review.googlesource.com/c/chromium/src/+/3870616
moves from disabled-by-default to enabled-by-default

Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4030556
removed the feature flag

* chore: update patches

* chore: bump chromium in DEPS to 110.0.5435.0

* chore: update patches

* chore: sync code with upstream change: AXLMode method name

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

* 3841761: Adapting code to support kSystemProfileSelectionDefaultNone experiment

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

* chore: bump chromium in DEPS to 110.0.5437.0

* 4040140: Pip 2.0: Merge VideoOverlayWindowViews and OverlayWindowViews

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

* 4045567: Fix a crash opening a popup from tab capture fullscreen

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

* chore: fixup patch indices

* 4048263: Remove deprecated Value calls in frame_tracker_unittest.cc.

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

* 4004606: [intl] Migrate to ICU 72

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

* chore: bump chromium in DEPS to 110.0.5439.0

* 3890670: Prerender: Add first implementation of prerender-in-new-tab mode

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

* chore: fixup patch indices

* chore: bump chromium in DEPS to 110.0.5441.0

* chore: update patches

* chore: bump chromium in DEPS to 110.0.5443.0

* 4035451: Remove remaining uses of ScopedNestableTaskAllower.

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

* chore: bump chromium in DEPS to 110.0.5445.0

* chore: update patches

* fixup! 3890670: Prerender: Add first implementation of prerender-in-new-tab mode

* test: disable parallel/test-worker-init-failure

Refs https://chromium-review.googlesource.com/c/v8/v8/+/4017512
Refs https://github.com/nodejs/node-v8/issues/246

* chore: disable parallel/test-fetch

Test is flaky on Linux CI, but runs fine locally.

* chore: bump chromium in DEPS to 110.0.5451.0

* chore: update patches

* chore: cleanup patch

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: PatchUp <73610968+patchup[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
Co-authored-by: electron-patch-conflict-fixer[bot] <83340002+electron-patch-conflict-fixer[bot]@users.noreply.github.com>
Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.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>
2022-12-05 22:20:25 -05:00
trop[bot]
af0a995bb2 docs: document outlivesOpener option in window open handler (#36509)
* docs: document outlivesOpener option in window open handler

Co-authored-by: Jeremy Rose <jeremya@chromium.org>

* outlivesOpener is optional

Co-authored-by: Jeremy Rose <jeremya@chromium.org>

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Jeremy Rose <jeremya@chromium.org>
2022-12-05 12:07:16 -05:00
trop[bot]
a0efada13b refactor: make StatusIconType an enum class (#36554)
Co-authored-by: Milan Burda <miburda@microsoft.com>

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Milan Burda <miburda@microsoft.com>
2022-12-05 10:39:37 -05:00
trop[bot]
8635029f47 build: fixup mksnapshot args on linux (#36534)
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>
2022-12-01 19:27:00 -05:00
trop[bot]
ac0ba48736 chore: drop support for Windows 7 / 8 / 8.1 (#36513)
* chore: drop support for Windows 7 & 8

Co-authored-by: Milan Burda <miburda@microsoft.com>

* chore: remove disable-redraw-lock.patch

Co-authored-by: Milan Burda <miburda@microsoft.com>

* chore: update patches

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

* Update docs/breaking-changes.md

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

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

* Update docs/breaking-changes.md

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

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

* fix breaking-changes.md

Co-authored-by: Milan Burda <miburda@microsoft.com>

* chore: note last supported version

Co-authored-by: Jeremy Rose <jeremya@chromium.org>

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

* chore: add link to deprecation policy

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

* Update docs/breaking-changes.md

Co-authored-by: Jeremy Rose <jeremya@chromium.org>

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

* update README.md

Co-authored-by: Milan Burda <miburda@microsoft.com>

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Milan Burda <miburda@microsoft.com>
Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com>
Co-authored-by: Milan Burda <milan.burda@gmail.com>
Co-authored-by: Keeley Hammond <vertedinde@electronjs.org>
2022-11-30 20:53:40 -08:00
1657 changed files with 35384 additions and 57590 deletions

View File

@@ -13,7 +13,7 @@ parameters:
run-docs-only: run-docs-only:
type: boolean type: boolean
default: false default: false
upload-to-storage: upload-to-storage:
type: string type: string
default: '1' default: '1'
@@ -62,12 +62,9 @@ jobs:
cd .circleci/config cd .circleci/config
yarn yarn
export CIRCLECI_BINARY="$HOME/circleci" export CIRCLECI_BINARY="$HOME/circleci"
curl -fLSs https://raw.githubusercontent.com/CircleCI-Public/circleci-cli/main/install.sh | DESTDIR=$CIRCLECI_BINARY bash curl -fLSs https://raw.githubusercontent.com/CircleCI-Public/circleci-cli/master/install.sh | DESTDIR=$CIRCLECI_BINARY bash
node build.js node build.js
name: Pack config.yml name: Pack config.yml
- run:
name: Set params
command: node .circleci/config/params.js
- continuation/continue: - continuation/continue:
configuration_path: .circleci/config-staging/built.yml configuration_path: .circleci/config-staging/built.yml
parameters: /tmp/pipeline-parameters.json parameters: /tmp/pipeline-parameters.json

File diff suppressed because it is too large Load Diff

View File

@@ -1,12 +0,0 @@
const fs = require('fs');
const PARAMS_PATH = '/tmp/pipeline-parameters.json';
const content = JSON.parse(fs.readFileSync(PARAMS_PATH, 'utf-8'));
// Choose resource class for linux hosts
const currentBranch = process.env.CIRCLE_BRANCH || '';
content['large-linux-executor'] = /^pull\/[0-9-]+$/.test(currentBranch) ? '2xlarge' : 'electronjs/aks-linux-large';
content['medium-linux-executor'] = /^pull\/[0-9-]+$/.test(currentBranch) ? 'medium' : 'electronjs/aks-linux-medium';
fs.writeFileSync(PARAMS_PATH, JSON.stringify(content));

View File

@@ -3,6 +3,5 @@
set -e set -e
mkdir -p ~/.ssh mkdir -p ~/.ssh
echo "github.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl echo "|1|B3r+7aO0/x90IdefihIjxIoJrrk=|OJddGDfhbuLFc1bUyy84hhIw57M= ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==
github.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg= |1|rGlEvW55DtzNZp+pzw9gvyOyKi4=|LLWr+7qlkAlw3YGGVfLHHxB/kR0= ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==" >> ~/.ssh/known_hosts
github.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCj7ndNxQowgcQnjshcLrqPEiiphnt+VTTvDP6mHBL9j1aNUkY4Ue1gvwnGLVlOhGeYrnZaMgRK6+PKCUXaDbC7qtbW8gIkhL7aGCsOr/C56SJMy/BCZfxd1nWzAOxSDPgVsmerOBYfNqltV9/hWCqBywINIR+5dIg6JTJ72pcEpEjcYgXkE2YEFXV1JHnsKgbLWNlhScqb2UmyRkQyytRLtL+38TGxkxCflmO+5Z8CSSNY7GidjMIZ7Q4zMjA2n1nGrlTDkzwDCsw+wqFPGQA179cnfGWOWRVruj16z6XyvxvjJwbz0wQZ75XK5tKSb7FNyeIEs4TT4jk+S4dhPeAUC5y+bDYirYgM4GC7uEnztnZyaVWQ7B381AK4Qdrwt51ZqExKbQpTUNn+EjqoTwvqNj4kqx5QUCI0ThS/YkOxJCXmPUWZbhjpCg56i+2aB6CmK2JGhn57K5mj0MNdBXA4/WnwH6XoPWJzK5Nyu2zB3nAZp+S5hpQs+p1vN1/wsjk=" >> ~/.ssh/known_hosts

View File

@@ -1,4 +0,0 @@
---
Checks: '-modernize-use-nullptr'
InheritParentConfig: true
...

View File

@@ -4,6 +4,37 @@
"onCreateCommand": ".devcontainer/on-create-command.sh", "onCreateCommand": ".devcontainer/on-create-command.sh",
"updateContentCommand": ".devcontainer/update-content-command.sh", "updateContentCommand": ".devcontainer/update-content-command.sh",
"workspaceFolder": "/workspaces/gclient/src/electron", "workspaceFolder": "/workspaces/gclient/src/electron",
"extensions": [
"joeleinbinder.mojom-language",
"rafaelmaiolla.diff",
"surajbarkale.ninja",
"ms-vscode.cpptools",
"mutantdino.resourcemonitor",
"dbaeumer.vscode-eslint",
"shakram02.bash-beautify",
"marshallofsound.gnls-electron",
"CircleCI.circleci"
],
"settings": {
"editor.tabSize": 2,
"bashBeautify.tabSize": 2,
"typescript.tsdk": "node_modules/typescript/lib",
"[gn]": {
"editor.formatOnSave": true
},
"[javascript]": {
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
}
},
"[typescript]": {
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
}
},
"javascript.preferences.quoteStyle": "single",
"typescript.preferences.quoteStyle": "single"
},
"forwardPorts": [8088, 6080, 5901], "forwardPorts": [8088, 6080, 5901],
"portsAttributes": { "portsAttributes": {
"8088": { "8088": {
@@ -29,38 +60,6 @@
"openFiles": [ "openFiles": [
".devcontainer/README.md" ".devcontainer/README.md"
] ]
},
"vscode": {
"extensions": ["joeleinbinder.mojom-language",
"rafaelmaiolla.diff",
"surajbarkale.ninja",
"ms-vscode.cpptools",
"mutantdino.resourcemonitor",
"dbaeumer.vscode-eslint",
"shakram02.bash-beautify",
"marshallofsound.gnls-electron",
"CircleCI.circleci"
],
"settings": {
"editor.tabSize": 2,
"bashBeautify.tabSize": 2,
"typescript.tsdk": "node_modules/typescript/lib",
"[gn]": {
"editor.formatOnSave": true
},
"[javascript]": {
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
}
},
"[typescript]": {
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
}
},
"javascript.preferences.quoteStyle": "single",
"typescript.preferences.quoteStyle": "single"
}
} }
} }
} }

View File

@@ -7,9 +7,9 @@ services:
volumes: volumes:
- ..:/workspaces/gclient/src/electron:cached - ..:/workspaces/gclient/src/electron:cached
- /var/run/docker.sock:/var/run/docker.sock - /var/run/docker.sock:/var/run/docker.sock
command: /bin/sh -c "while sleep 1000; do :; done" command: /bin/sh -c "while sleep 1000; do :; done"
user: builduser user: builduser

View File

@@ -16,8 +16,6 @@ ln -s $buildtools_configs $buildtools/configs
# Write the gclient config if it does not already exist # Write the gclient config if it does not already exist
if [ ! -f $gclient_root/.gclient ]; then if [ ! -f $gclient_root/.gclient ]; then
echo "Creating gclient config"
echo "solutions = [ echo "solutions = [
{ \"name\" : \"src/electron\", { \"name\" : \"src/electron\",
\"url\" : \"https://github.com/electron/electron\", \"url\" : \"https://github.com/electron/electron\",
@@ -34,18 +32,11 @@ fi
# Write the default buildtools config file if it does # Write the default buildtools config file if it does
# not already exist # not already exist
if [ ! -f $buildtools/configs/evm.testing.json ]; then if [ ! -f $buildtools/configs/evm.testing.json ]; then
echo "Creating build-tools testing config"
write_config() { write_config() {
echo " echo "
{ {
\"goma\": \"$1\",
\"root\": \"/workspaces/gclient\", \"root\": \"/workspaces/gclient\",
\"remotes\": { \"goma\": \"$1\",
\"electron\": {
\"origin\": \"https://github.com/electron/electron.git\"
}
},
\"gen\": { \"gen\": {
\"args\": [ \"args\": [
\"import(\\\"//electron/build/args/testing.gn\\\")\", \"import(\\\"//electron/build/args/testing.gn\\\")\",
@@ -57,7 +48,11 @@ if [ ! -f $buildtools/configs/evm.testing.json ]; then
\"CHROMIUM_BUILDTOOLS_PATH\": \"/workspaces/gclient/src/buildtools\", \"CHROMIUM_BUILDTOOLS_PATH\": \"/workspaces/gclient/src/buildtools\",
\"GIT_CACHE_PATH\": \"/workspaces/gclient/.git-cache\" \"GIT_CACHE_PATH\": \"/workspaces/gclient/.git-cache\"
}, },
\"\$schema\": \"file:///home/builduser/.electron_build_tools/evm-config.schema.json\" \"remotes\": {
\"electron\": {
\"origin\": \"https://github.com/electron/electron.git\"
}
}
} }
" >$buildtools/configs/evm.testing.json " >$buildtools/configs/evm.testing.json
} }
@@ -71,12 +66,10 @@ if [ ! -f $buildtools/configs/evm.testing.json ]; then
# if it works we can use the goma cluster # if it works we can use the goma cluster
export NOTGOMA_CODESPACES_TOKEN=$GITHUB_TOKEN export NOTGOMA_CODESPACES_TOKEN=$GITHUB_TOKEN
if e d goma_auth login; then if e d goma_auth login; then
echo "$GITHUB_USER has GOMA access - switching to cluster mode"
write_config cluster write_config cluster
fi fi
else else
echo "build-tools testing config already exists" # Even if the config file existed we still need to re-auth with the goma
# cluster
# Re-auth with the goma cluster regardless.
NOTGOMA_CODESPACES_TOKEN=$GITHUB_TOKEN e d goma_auth login || true NOTGOMA_CODESPACES_TOKEN=$GITHUB_TOKEN e d goma_auth login || true
fi fi

View File

@@ -10,6 +10,7 @@
"semi": ["error", "always"], "semi": ["error", "always"],
"no-var": "error", "no-var": "error",
"no-unused-vars": "off", "no-unused-vars": "off",
"no-global-assign": "off",
"guard-for-in": "error", "guard-for-in": "error",
"@typescript-eslint/no-unused-vars": ["error", { "@typescript-eslint/no-unused-vars": ["error", {
"vars": "all", "vars": "all",
@@ -19,13 +20,20 @@
"prefer-const": ["error", { "prefer-const": ["error", {
"destructuring": "all" "destructuring": "all"
}], }],
"standard/no-callback-literal": "off" "standard/no-callback-literal": "off",
"node/no-deprecated-api": "off"
}, },
"parserOptions": { "parserOptions": {
"ecmaVersion": 6, "ecmaVersion": 6,
"sourceType": "module" "sourceType": "module"
}, },
"overrides": [ "overrides": [
{
"files": "*.js",
"rules": {
"@typescript-eslint/no-unused-vars": "off"
}
},
{ {
"files": "*.ts", "files": "*.ts",
"rules": { "rules": {

24
.gitattributes vendored
View File

@@ -4,27 +4,11 @@
patches/**/.patches merge=union patches/**/.patches merge=union
# Source code and markdown files should always use LF as line ending. # Source code and markdown files should always use LF as line ending.
*.c text eol=lf
*.cc text eol=lf *.cc text eol=lf
*.cpp text eol=lf
*.csv text eol=lf
*.grd text eol=lf
*.grdp text eol=lf
*.gn text eol=lf
*.gni text eol=lf
*.h text eol=lf
*.html text eol=lf
*.idl text eol=lf
*.in text eol=lf
*.js text eol=lf
*.json text eol=lf
*.json5 text eol=lf
*.md text eol=lf
*.mm text eol=lf *.mm text eol=lf
*.mojom text eol=lf *.h text eol=lf
*.proto text eol=lf *.js text eol=lf
*.ts text eol=lf
*.py text eol=lf *.py text eol=lf
*.ps1 text eol=lf *.ps1 text eol=lf
*.sh text eol=lf *.md text eol=lf
*.ts text eol=lf
*.txt text eol=lf

2
.github/CODEOWNERS vendored
View File

@@ -8,12 +8,12 @@
DEPS @electron/wg-upgrades DEPS @electron/wg-upgrades
# Releases WG # Releases WG
/docs/breaking-changes.md @electron/wg-releases
/npm/ @electron/wg-releases /npm/ @electron/wg-releases
/script/release @electron/wg-releases /script/release @electron/wg-releases
# Security WG # Security WG
/lib/browser/devtools.ts @electron/wg-security /lib/browser/devtools.ts @electron/wg-security
/lib/browser/guest-view-manager.ts @electron/wg-security /lib/browser/guest-view-manager.ts @electron/wg-security
/lib/browser/guest-window-proxy.ts @electron/wg-security
/lib/browser/rpc-server.ts @electron/wg-security /lib/browser/rpc-server.ts @electron/wg-security
/lib/renderer/security-warnings.ts @electron/wg-security /lib/renderer/security-warnings.ts @electron/wg-security

View File

@@ -19,7 +19,7 @@ body:
label: Electron Version label: Electron Version
description: | description: |
What version of Electron are you using? What version of Electron are you using?
Note: Please only report issues for [currently supported versions of Electron](https://www.electronjs.org/docs/latest/tutorial/support#currently-supported-versions). Note: Please only report issues for [currently supported versions of Electron](https://www.electronjs.org/docs/latest/tutorial/support#currently-supported-versions).
placeholder: 17.0.0 placeholder: 17.0.0
validations: validations:

View File

@@ -29,7 +29,7 @@ body:
- type: textarea - type: textarea
attributes: attributes:
label: Alternatives Considered label: Alternatives Considered
description: A clear and concise description of any alternative solutions or features you've considered. description: A clear and concise description of any alternative solutions or features you've considered.
validations: validations:
required: true required: true
- type: textarea - type: textarea

View File

@@ -14,8 +14,8 @@ Contributors guide: https://github.com/electron/electron/blob/main/CONTRIBUTING.
- [ ] `npm test` passes - [ ] `npm test` passes
- [ ] tests are [changed or added](https://github.com/electron/electron/blob/main/docs/development/testing.md) - [ ] tests are [changed or added](https://github.com/electron/electron/blob/main/docs/development/testing.md)
- [ ] relevant documentation, tutorials, templates and examples are changed or added - [ ] relevant documentation, tutorials, templates and examples are changed or added
- [ ] [PR release notes](https://github.com/electron/clerk/blob/main/README.md) describe the change in a way relevant to app developers, and are [capitalized, punctuated, and past tense](https://github.com/electron/clerk/blob/main/README.md#examples). - [ ] [PR release notes](https://github.com/electron/clerk/blob/master/README.md) describe the change in a way relevant to app developers, and are [capitalized, punctuated, and past tense](https://github.com/electron/clerk/blob/master/README.md#examples).
#### Release Notes #### Release Notes
Notes: <!-- Please add a one-line description for app developers to read in the release notes, or 'none' if no notes relevant to app developers. Examples and help on special cases: https://github.com/electron/clerk/blob/main/README.md#examples --> Notes: <!-- Please add a one-line description for app developers to read in the release notes, or 'none' if no notes relevant to app developers. Examples and help on special cases: https://github.com/electron/clerk/blob/master/README.md#examples -->

14
.github/config.yml vendored
View File

@@ -25,3 +25,17 @@ newPRWelcomeComment: |
# Comment to be posted to on pull requests merged by a first time user # Comment to be posted to on pull requests merged by a first time user
firstPRMergeComment: > firstPRMergeComment: >
Congrats on merging your first pull request! 🎉🎉🎉 Congrats on merging your first pull request! 🎉🎉🎉
# Users authorized to run manual trop backports
authorizedUsers:
- alexeykuzmin
- ckerr
- codebytere
- deepak1556
- jkleinsc
- loc
- MarshallOfSound
- miniak
- mlaurencin
- nornagon
- zcbenz

View File

@@ -1,115 +0,0 @@
name: Branch Created
on:
create:
permissions: {}
jobs:
release-branch-created:
name: Release Branch Created
if: ${{ github.event.ref_type == 'branch' && endsWith(github.event.ref, '-x-y') && !startsWith(github.event.ref, 'roller') }}
permissions:
contents: read
pull-requests: write
repository-projects: write # Required for labels
runs-on: ubuntu-latest
steps:
- name: Determine Major Version
id: check-major-version
run: |
if [[ ${{ github.event.ref }} =~ ^([0-9]+)-x-y$ ]]; then
echo "MAJOR=${BASH_REMATCH[1]}" >> "$GITHUB_OUTPUT"
else
echo "Not a release branch: ${{ github.event.ref }}"
fi
- name: New Release Branch Tasks
if: ${{ steps.check-major-version.outputs.MAJOR }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: electron/electron
MAJOR: ${{ steps.check-major-version.outputs.MAJOR }}
NUM_SUPPORTED_VERSIONS: 3
run: |
PREVIOUS_MAJOR=$((MAJOR - 1))
UNSUPPORTED_MAJOR=$((MAJOR - NUM_SUPPORTED_VERSIONS - 1))
# Create new labels
gh label create $MAJOR-x-y --color 8d9ee8 || true
gh label create target/$MAJOR-x-y --color ad244f --description "PR should also be added to the \"${MAJOR}-x-y\" branch." || true
gh label create merged/$MAJOR-x-y --color 61a3c6 --description "PR was merged to the \"${MAJOR}-x-y\" branch." || true
gh label create in-flight/$MAJOR-x-y --color db69a6 || true
gh label create needs-manual-bp/$MAJOR-x-y --color 8b5dba || true
# Change color of old labels
gh label edit $UNSUPPORTED_MAJOR-x-y --color ededed || true
gh label edit target/$UNSUPPORTED_MAJOR-x-y --color ededed || true
gh label edit merged/$UNSUPPORTED_MAJOR-x-y --color ededed || true
gh label edit in-flight/$UNSUPPORTED_MAJOR-x-y --color ededed || true
gh label edit needs-manual-bp/$UNSUPPORTED_MAJOR-x-y --color ededed || true
# Add the new target label to any PRs which:
# * target the previous major
# * are in-flight for the previous major
# * need manual backport for the previous major
for PREVIOUS_MAJOR_LABEL in target/$PREVIOUS_MAJOR-x-y in-flight/$PREVIOUS_MAJOR-x-y needs-manual-bp/$PREVIOUS_MAJOR-x-y; do
PULL_REQUESTS=$(gh pr list --label $PREVIOUS_MAJOR_LABEL --jq .[].number --json number --limit 500)
if [[ $PULL_REQUESTS ]]; then
echo $PULL_REQUESTS | xargs -n 1 gh pr edit --add-label target/$MAJOR-x-y || true
fi
done
- name: Generate GitHub App token
if: ${{ steps.check-major-version.outputs.MAJOR }}
uses: electron/github-app-auth-action@384fd19694fe7b6dcc9a684746c6976ad78228ae # v1.1.1
id: generate-token
with:
creds: ${{ secrets.RELEASE_BOARD_GH_APP_CREDS }}
org: electron
- name: Generate Release Project Board Metadata
if: ${{ steps.check-major-version.outputs.MAJOR }}
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.1
id: generate-project-metadata
with:
script: |
const major = ${{ steps.check-major-version.outputs.MAJOR }}
const nextMajor = major + 1
const prevMajor = major - 1
core.setOutput("major", major)
core.setOutput("next-major", nextMajor)
core.setOutput("prev-major", prevMajor)
core.setOutput("prev-prev-major", prevMajor - 1)
core.setOutput("template-view", JSON.stringify({
major,
"next-major": nextMajor,
"prev-major": prevMajor,
}))
- name: Create Release Project Board
if: ${{ steps.check-major-version.outputs.MAJOR }}
uses: dsanders11/project-actions/copy-project@3a81985616963f32fae17d1d1b406c631f3201a1 # v1.1.0
id: create-release-board
with:
drafts: true
project-number: 64
# TODO - Set to public once GitHub fixes their GraphQL bug
# public: true
link-to-repository: electron/electron
template-view: ${{ steps.generate-project-metadata.outputs.template-view }}
title: ${{ steps.generate-project-metadata.outputs.major }}-x-y
token: ${{ steps.generate-token.outputs.token }}
- name: Dump Release Project Board Contents
if: ${{ steps.check-major-version.outputs.MAJOR }}
run: gh project item-list ${{ steps.create-release-board.outputs.number }} --owner electron --format json | jq
env:
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
- name: Find Previous Release Project Board
if: ${{ steps.check-major-version.outputs.MAJOR }}
uses: dsanders11/project-actions/find-project@3a81985616963f32fae17d1d1b406c631f3201a1 # v1.1.0
id: find-prev-release-board
with:
title: ${{ steps.generate-project-metadata.outputs.prev-prev-major }}-x-y
- name: Close Previous Release Project Board
if: ${{ steps.check-major-version.outputs.MAJOR }}
uses: dsanders11/project-actions/close-project@3a81985616963f32fae17d1d1b406c631f3201a1 # v1.1.0
with:
project-number: ${{ steps.find-prev-release-board.outputs.number }}

View File

@@ -1,26 +0,0 @@
name: Issue Commented
on:
issue_comment:
types:
- created
permissions: {}
jobs:
issue-commented:
name: Remove blocked/need-repro on comment
if: ${{ contains(github.event.issue.labels.*.name, 'blocked/need-repro') && !contains(fromJSON('["MEMBER", "OWNER"]'), github.event.comment.author_association) && github.event.comment.user.type != 'Bot' }}
runs-on: ubuntu-latest
steps:
- name: Generate GitHub App token
uses: electron/github-app-auth-action@cc6751b3b5e4edc5b9a4ad0a021ac455653b6dc8 # v1.0.0
id: generate-token
with:
creds: ${{ secrets.ISSUE_TRIAGE_GH_APP_CREDS }}
- name: Remove label
env:
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
ISSUE_URL: ${{ github.event.issue.html_url }}
run: |
gh issue edit $ISSUE_URL --remove-label 'blocked/need-repro'

View File

@@ -8,61 +8,23 @@ permissions: # added using https://github.com/step-security/secure-workflows
contents: read contents: read
jobs: jobs:
issue-labeled-blocked: issue-labeled:
name: blocked/* label added
if: startsWith(github.event.label.name, 'blocked/')
runs-on: ubuntu-latest
steps:
- name: Generate GitHub App token
uses: electron/github-app-auth-action@cc6751b3b5e4edc5b9a4ad0a021ac455653b6dc8 # v1.0.0
id: generate-token
with:
creds: ${{ secrets.ISSUE_TRIAGE_GH_APP_CREDS }}
org: electron
- name: Set status
uses: dsanders11/project-actions/edit-item@a24415515fa60a22f71f9d9d00e36ca82660cde9 # v1.0.1
with:
token: ${{ steps.generate-token.outputs.token }}
project-number: 90
field: Status
field-value: 🛑 Blocked
issue-labeled-blocked-need-repro:
name: blocked/need-repro label added
if: github.event.label.name == 'blocked/need-repro'
permissions: permissions:
issues: write # for actions-cool/issues-helper to update issues issues: write # for actions-cool/issues-helper to update issues
pull-requests: write # for actions-cool/issues-helper to update PRs
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Check if comment needed - name: blocked/need-repro
id: check-for-comment if: github.event.label.name == 'blocked/need-repro'
env: uses: actions-cool/issues-helper@dad28fdb88da5f082c04659b7373d85790f9b135 # v3.3.0
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: electron/electron
run: |
set -eo pipefail
COMMENT_COUNT=$(gh issue view ${{ github.event.issue.number }} --comments --json comments | jq '[ .comments[] | select(.author.login == "electron-issue-triage" or .authorAssociation == "OWNER" or .authorAssociation == "MEMBER") | select(.body | startswith("<!-- blocked/need-repro -->")) ] | length')
if [[ $COMMENT_COUNT -eq 0 ]]; then
echo "SHOULD_COMMENT=1" >> "$GITHUB_OUTPUT"
fi
- name: Generate GitHub App token
if: ${{ steps.check-for-comment.outputs.SHOULD_COMMENT }}
uses: electron/github-app-auth-action@cc6751b3b5e4edc5b9a4ad0a021ac455653b6dc8 # v1.0.0
id: generate-token
with:
creds: ${{ secrets.ISSUE_TRIAGE_GH_APP_CREDS }}
- name: Create comment
if: ${{ steps.check-for-comment.outputs.SHOULD_COMMENT }}
uses: actions-cool/issues-helper@275328970dbc3bfc3bc43f5fe741bf3638300c0a # v3.3.3
with: with:
actions: 'create-comment' actions: 'create-comment'
token: ${{ steps.generate-token.outputs.token }}
body: | body: |
<!-- blocked/need-repro -->
Hello @${{ github.event.issue.user.login }}. Thanks for reporting this and helping to make Electron better! Hello @${{ github.event.issue.user.login }}. Thanks for reporting this and helping to make Electron better!
Would it be possible for you to make a standalone testcase with only the code necessary to reproduce the issue? For example, [Electron Fiddle](https://www.electronjs.org/fiddle) is a great tool for making small test cases and makes it easy to publish your test case to a [gist](https://gist.github.com) that Electron maintainers can use. Would it be possible for you to make a standalone testcase with only the code necessary to reproduce the issue? For example, [Electron Fiddle](https://www.electronjs.org/fiddle) is a great tool for making small test cases and makes it easy to publish your test case to a [gist](https://gist.github.com) that Electron maintainers can use.
Stand-alone test cases make fixing issues go more smoothly: it ensure everyone's looking at the same issue, it removes all unnecessary variables from the equation, and it can also provide the basis for automated regression tests. Stand-alone test cases make fixing issues go more smoothly: it ensure everyone's looking at the same issue, it removes all unnecessary variables from the equation, and it can also provide the basis for automated regression tests.
Now adding the https://github.com/electron/electron/labels/blocked%2Fneed-repro label for this reason. After you make a test case, please link to it in a followup comment. This issue will be closed in 10 days if the above is not addressed. Now adding the `blocked/need-repro` label for this reason. After you make a test case, please link to it in a followup comment. This issue will be closed in 10 days if the above is not addressed.

View File

@@ -1,27 +0,0 @@
name: Issue Opened
on:
issues:
types:
- opened
permissions: {}
jobs:
add-to-issue-triage:
if: ${{ contains(github.event.issue.labels.*.name, 'bug :beetle:') }}
runs-on: ubuntu-latest
steps:
- name: Generate GitHub App token
uses: electron/github-app-auth-action@384fd19694fe7b6dcc9a684746c6976ad78228ae # v1.1.1
id: generate-token
with:
creds: ${{ secrets.ISSUE_TRIAGE_GH_APP_CREDS }}
org: electron
- name: Add to Issue Triage
uses: dsanders11/project-actions/add-item@a24415515fa60a22f71f9d9d00e36ca82660cde9 # v1.0.1
with:
field: Reporter
field-value: ${{ github.event.issue.user.login }}
project-number: 90
token: ${{ steps.generate-token.outputs.token }}

View File

@@ -1,38 +0,0 @@
name: Issue Unlabeled
on:
issues:
types: [unlabeled]
permissions:
contents: read
jobs:
issue-unlabeled-blocked:
name: All blocked/* labels removed
if: startsWith(github.event.label.name, 'blocked/') && github.event.issue.state == 'open'
runs-on: ubuntu-latest
steps:
- name: Check for any blocked labels
id: check-for-blocked-labels
run: |
set -eo pipefail
BLOCKED_LABEL_COUNT=$(echo '${{ toJSON(github.event.issue.labels.*.name) }}' | jq '[ .[] | select(startswith("blocked/")) ] | length')
if [[ $BLOCKED_LABEL_COUNT -eq 0 ]]; then
echo "NOT_BLOCKED=1" >> "$GITHUB_OUTPUT"
fi
- name: Generate GitHub App token
if: ${{ steps.check-for-blocked-labels.outputs.NOT_BLOCKED }}
uses: electron/github-app-auth-action@cc6751b3b5e4edc5b9a4ad0a021ac455653b6dc8 # v1.0.0
id: generate-token
with:
creds: ${{ secrets.ISSUE_TRIAGE_GH_APP_CREDS }}
org: electron
- name: Set status
if: ${{ steps.check-for-blocked-labels.outputs.NOT_BLOCKED }}
uses: dsanders11/project-actions/edit-item@a24415515fa60a22f71f9d9d00e36ca82660cde9 # v1.0.1
with:
token: ${{ steps.generate-token.outputs.token }}
project-number: 90
field: Status
field-value: 📥 Was Blocked

View File

@@ -1,41 +0,0 @@
name: Pull Request Labeled
on:
pull_request_target:
types: [labeled]
permissions: {}
jobs:
pull-request-labeled-backport-requested:
name: backport/requested label added
if: github.event.label.name == 'backport/requested 🗳'
runs-on: ubuntu-latest
steps:
- name: Trigger Slack workflow
uses: slackapi/slack-github-action@e28cf165c92ffef168d23c5c9000cffc8a25e117 # v1.24.0
with:
payload: |
{
"url": "${{ github.event.pull_request.html_url }}"
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.BACKPORT_REQUESTED_SLACK_WEBHOOK_URL }}
pull-request-labeled-deprecation-review-complete:
name: deprecation-review/complete label added
if: github.event.label.name == 'deprecation-review/complete ✅'
runs-on: ubuntu-latest
steps:
- name: Generate GitHub App token
uses: electron/github-app-auth-action@cc6751b3b5e4edc5b9a4ad0a021ac455653b6dc8 # v1.0.0
id: generate-token
with:
creds: ${{ secrets.RELEASE_BOARD_GH_APP_CREDS }}
org: electron
- name: Set status
uses: dsanders11/project-actions/edit-item@a24415515fa60a22f71f9d9d00e36ca82660cde9 # v1.0.1
with:
token: ${{ steps.generate-token.outputs.token }}
project-number: 94
field: Status
field-value: ✅ Reviewed

View File

@@ -0,0 +1,32 @@
name: Trigger Major Release Dependency Updates
on:
release:
types: [published]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
permissions: # added using https://github.com/step-security/secure-workflows
contents: read
jobs:
trigger_chromedriver:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # tag: v3
- name: Trigger New chromedriver Release
run: |
if [[ ${{ github.event.release.tag_name }} =~ ^v[0-9]+\.0\.0$ ]]; then
gh api /repos/:owner/chromedriver/actions/workflows/release.yml/dispatches --input - <<< '{"ref":"main","inputs":{"version":"${{ github.event.release.tag_name }}"}}'
else
echo "Not releasing for version ${{ github.event.release.tag_name }}: requires major version change"
fi
trigger_mksnapshot:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # tag: v3
- name: Trigger New mksnapshot Release
run: |
gh api /repos/:owner/mksnapshot/actions/workflows/release.yml/dispatches --input - <<< '{"ref":"main","inputs":{"version":"${{ github.event.release.tag_name }}"}}'

View File

@@ -22,12 +22,12 @@ jobs:
steps: steps:
- name: "Checkout code" - name: "Checkout code"
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # tag=v3.1.0 uses: actions/checkout@a12a3943b4bdde767164f792f33f40b04645d846 # tag=v3.0.0
with: with:
persist-credentials: false persist-credentials: false
- name: "Run analysis" - name: "Run analysis"
uses: ossf/scorecard-action@e38b1902ae4f44df626f11ba0734b14fb91f8f86 # tag=v2.1.2 uses: ossf/scorecard-action@99c53751e09b9529366343771cc321ec74e9bd3d # tag=v2.0.6
with: with:
results_file: results.sarif results_file: results.sarif
results_format: sarif results_format: sarif
@@ -41,7 +41,7 @@ jobs:
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF # Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
# format to the repository Actions tab. # format to the repository Actions tab.
- name: "Upload artifact" - name: "Upload artifact"
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # tag=v3.1.2 uses: actions/upload-artifact@6673cd052c4cd6fcf4b4e6e60ea986c889389535 # tag=v3.0.0
with: with:
name: SARIF file name: SARIF file
path: results.sarif path: results.sarif
@@ -49,6 +49,6 @@ jobs:
# Upload the results to GitHub's code scanning dashboard. # Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning" - name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@959cbb7472c4d4ad70cdfe6f4976053fe48ab394 # tag=v2.1.27 uses: github/codeql-action/upload-sarif@5f532563584d71fdef14ee64d17bafb34f751ce5 # tag=v1.0.26
with: with:
sarif_file: results.sarif sarif_file: results.sarif

View File

@@ -1,7 +1,7 @@
name: "Check Semantic Commit" name: "Check Semantic Commit"
on: on:
pull_request: pull_request_target:
types: types:
- opened - opened
- edited - edited
@@ -19,7 +19,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: semantic-pull-request - name: semantic-pull-request
uses: amannn/action-semantic-pull-request@01d5fd8a8ebb9aafe902c40c53f0f4744f7381eb # tag: v5 uses: amannn/action-semantic-pull-request@505e44b4f33b4c801f063838b3f053990ee46ea7 # tag: v4
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with: with:

View File

@@ -1,35 +0,0 @@
name: Check Stable Prep Items
on:
schedule:
- cron: '0 */12 * * *'
workflow_dispatch:
permissions: {}
jobs:
check-stable-prep-items:
name: Check Stable Prep Items
runs-on: ubuntu-latest
steps:
- name: Generate GitHub App token
uses: electron/github-app-auth-action@384fd19694fe7b6dcc9a684746c6976ad78228ae # v1.1.1
id: generate-token
with:
creds: ${{ secrets.RELEASE_BOARD_GH_APP_CREDS }}
org: electron
- name: Find Newest Release Project Board
id: find-project-number
env:
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
run: |
set -eo pipefail
PROJECT_NUMBER=$(gh project list --owner electron --format json | jq -r '.projects | map(select(.title | test("^[0-9]+-x-y$"))) | max_by(.number) | .number')
echo "PROJECT_NUMBER=$PROJECT_NUMBER" >> "$GITHUB_OUTPUT"
- name: Update Completed Stable Prep Items
uses: dsanders11/project-actions/completed-by@a24415515fa60a22f71f9d9d00e36ca82660cde9 # v1.0.1
with:
field: Prep Status
field-value: ✅ Complete
project-number: ${{ steps.find-project-number.outputs.PROJECT_NUMBER }}
token: ${{ steps.generate-token.outputs.token }}

View File

@@ -1,24 +1,18 @@
name: 'Close stale issues' name: 'Close stale issues'
on: on:
workflow_dispatch:
schedule: schedule:
# 1:30am every day # 1:30am every day
- cron: '30 1 * * *' - cron: '30 1 * * *'
permissions: {} permissions:
issues: write
jobs: jobs:
stale: stale:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Generate GitHub App token - uses: actions/stale@3de2653986ebd134983c79fe2be5d45cc3d9f4e1
uses: electron/github-app-auth-action@cc6751b3b5e4edc5b9a4ad0a021ac455653b6dc8 # v1.0.0
id: generate-token
with: with:
creds: ${{ secrets.ISSUE_TRIAGE_GH_APP_CREDS }}
- uses: actions/stale@5ebf00ea0e4c1561e9b43a292ed34424fb1d4578 # tag: v6.0.1
with:
repo-token: ${{ steps.generate-token.outputs.token }}
days-before-stale: 90 days-before-stale: 90
days-before-close: 30 days-before-close: 30
stale-issue-label: stale stale-issue-label: stale
@@ -27,26 +21,5 @@ jobs:
This issue has been automatically marked as stale. **If this issue is still affecting you, please leave any comment** (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the [latest version of Electron](https://www.electronjs.org/releases/stable) or in the [beta](https://www.electronjs.org/releases/beta)—please include it with your comment! This issue has been automatically marked as stale. **If this issue is still affecting you, please leave any comment** (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the [latest version of Electron](https://www.electronjs.org/releases/stable) or in the [beta](https://www.electronjs.org/releases/beta)—please include it with your comment!
close-issue-message: > close-issue-message: >
This issue has been closed due to inactivity, and will not be monitored. If this is a bug and you can reproduce this issue on a [supported version of Electron](https://www.electronjs.org/docs/latest/tutorial/electron-timelines#timeline) please open a new issue and include instructions for reproducing the issue. This issue has been closed due to inactivity, and will not be monitored. If this is a bug and you can reproduce this issue on a [supported version of Electron](https://www.electronjs.org/docs/latest/tutorial/electron-timelines#timeline) please open a new issue and include instructions for reproducing the issue.
exempt-issue-labels: "discussion,security \U0001F512,enhancement :sparkles:,status/confirmed" exempt-issue-labels: "discussion,security \U0001F512,enhancement :sparkles:"
only-pr-labels: not-a-real-label only-pr-labels: not-a-real-label
pending-repro:
runs-on: ubuntu-latest
if: ${{ always() }}
needs: stale
steps:
- name: Generate GitHub App token
uses: electron/github-app-auth-action@cc6751b3b5e4edc5b9a4ad0a021ac455653b6dc8 # v1.0.0
id: generate-token
with:
creds: ${{ secrets.ISSUE_TRIAGE_GH_APP_CREDS }}
- uses: actions/stale@5ebf00ea0e4c1561e9b43a292ed34424fb1d4578 # tag: v6.0.1
with:
repo-token: ${{ steps.generate-token.outputs.token }}
days-before-stale: -1
days-before-close: 10
remove-stale-when-updated: false
stale-issue-label: blocked/need-repro
stale-pr-label: not-a-real-label
operations-per-run: 1750
close-issue-message: >
Unfortunately, without a way to reproduce this issue, we're unable to continue investigation. This issue has been closed and will not be monitored further. If you're able to provide a minimal test case that reproduces this issue on a [supported version of Electron](https://www.electronjs.org/docs/latest/tutorial/electron-timelines#timeline) please open a new issue and include instructions for reproducing the issue.

View File

@@ -2,7 +2,6 @@ name: Update AppVeyor Image
# Run chron daily Mon-Fri # Run chron daily Mon-Fri
on: on:
workflow_dispatch:
schedule: schedule:
- cron: '0 8 * * 1-5' # runs 8:00 every business day (see https://crontab.guru) - cron: '0 8 * * 1-5' # runs 8:00 every business day (see https://crontab.guru)
@@ -40,35 +39,24 @@ jobs:
if: ${{ env.APPVEYOR_IMAGE_VERSION }} if: ${{ env.APPVEYOR_IMAGE_VERSION }}
uses: mikefarah/yq@1c7dc0e88aad311c89889bc5ce5d8f96931a1bd0 # v4.27.2 uses: mikefarah/yq@1c7dc0e88aad311c89889bc5ce5d8f96931a1bd0 # v4.27.2
with: with:
cmd: | cmd: yq '.image = "${{ env.APPVEYOR_IMAGE_VERSION }}"' "appveyor.yml" > "appveyor2.yml"
yq '.image = "${{ env.APPVEYOR_IMAGE_VERSION }}"' "appveyor.yml" > "appveyor2.yml"
yq '.image = "${{ env.APPVEYOR_IMAGE_VERSION }}"' "appveyor-woa.yml" > "appveyor-woa2.yml"
- name: (Optionally) Generate Commit Diff - name: (Optionally) Generate Commit Diff
if: ${{ env.APPVEYOR_IMAGE_VERSION }} if: ${{ env.APPVEYOR_IMAGE_VERSION }}
run: | run: |
diff -w -B appveyor.yml appveyor2.yml > appveyor.diff || true diff -w -B appveyor.yml appveyor2.yml > appveyor.diff || true
patch -f appveyor.yml < appveyor.diff patch -f appveyor.yml < appveyor.diff
rm appveyor2.yml appveyor.diff rm appveyor2.yml appveyor.diff
- name: (Optionally) Generate Commit Diff for WOA
if: ${{ env.APPVEYOR_IMAGE_VERSION }}
run: |
diff -w -B appveyor-woa.yml appveyor-woa2.yml > appveyor-woa.diff || true
patch -f appveyor-woa.yml < appveyor-woa.diff
rm appveyor-woa2.yml appveyor-woa.diff
- name: (Optionally) Commit and Pull Request - name: (Optionally) Commit and Pull Request
if: ${{ env.APPVEYOR_IMAGE_VERSION }} if: ${{ env.APPVEYOR_IMAGE_VERSION }}
uses: peter-evans/create-pull-request@2b011faafdcbc9ceb11414d64d0573f37c774b04 # v4.2.3 uses: peter-evans/create-pull-request@2b011faafdcbc9ceb11414d64d0573f37c774b04 # v4.2.3
with: with:
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.ACTIONS_GITHUB_TOKEN }}
commit-message: 'build: update appveyor image to latest version' commit-message: 'build: update appveyor image to latest version'
committer: GitHub <noreply@github.com> committer: GitHub <noreply@github.com>
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com> author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
signoff: false signoff: false
branch: bump-appveyor-image branch: bump-appveyor-image
delete-branch: true delete-branch: true
reviewers: electron/wg-releases
title: 'build: update appveyor image to latest version' title: 'build: update appveyor image to latest version'
labels: semver/none,no-backport
body: | body: |
This PR updates appveyor.yml to the latest baked image, ${{ env.APPVEYOR_IMAGE_VERSION }}. This PR updates appveyor.yml to the latest baked image, ${{ env.APPVEYOR_IMAGE_VERSION }}.
Notes: none

View File

@@ -1,3 +1,27 @@
{ {
"extends": "@electron/lint-roller/configs/markdownlint.json" "commands-show-output": false,
} "first-line-h1": false,
"header-increment": false,
"line-length": {
"code_blocks": false,
"tables": false,
"stern": true,
"line_length": -1
},
"no-bare-urls": false,
"no-blanks-blockquote": false,
"no-duplicate-header": {
"allow_different_nesting": true
},
"no-emphasis-as-header": false,
"no-hard-tabs": {
"code_blocks": false
},
"no-space-in-emphasis": false,
"no-trailing-punctuation": false,
"no-trailing-spaces": {
"br_spaces": 0
},
"single-h1": false,
"no-inline-html": false
}

260
BUILD.gn
View File

@@ -1,7 +1,7 @@
import("//build/config/locales.gni") import("//build/config/locales.gni")
import("//build/config/ui.gni") import("//build/config/ui.gni")
import("//build/config/win/manifest.gni") import("//build/config/win/manifest.gni")
import("//components/os_crypt/sync/features.gni") import("//components/os_crypt/features.gni")
import("//components/spellcheck/spellcheck_build_features.gni") import("//components/spellcheck/spellcheck_build_features.gni")
import("//content/public/app/mac_helpers.gni") import("//content/public/app/mac_helpers.gni")
import("//extensions/buildflags/buildflags.gni") import("//extensions/buildflags/buildflags.gni")
@@ -9,7 +9,6 @@ import("//pdf/features.gni")
import("//ppapi/buildflags/buildflags.gni") import("//ppapi/buildflags/buildflags.gni")
import("//printing/buildflags/buildflags.gni") import("//printing/buildflags/buildflags.gni")
import("//testing/test.gni") import("//testing/test.gni")
import("//third_party/electron_node/node.gni")
import("//third_party/ffmpeg/ffmpeg_options.gni") import("//third_party/ffmpeg/ffmpeg_options.gni")
import("//tools/generate_library_loader/generate_library_loader.gni") import("//tools/generate_library_loader/generate_library_loader.gni")
import("//tools/grit/grit_rule.gni") import("//tools/grit/grit_rule.gni")
@@ -29,7 +28,6 @@ import("filenames.gni")
import("filenames.hunspell.gni") import("filenames.hunspell.gni")
import("filenames.libcxx.gni") import("filenames.libcxx.gni")
import("filenames.libcxxabi.gni") import("filenames.libcxxabi.gni")
import("js2c_toolchain.gni")
if (is_mac) { if (is_mac) {
import("//build/config/mac/rules.gni") import("//build/config/mac/rules.gni")
@@ -39,7 +37,7 @@ if (is_mac) {
import("build/rules.gni") import("build/rules.gni")
assert( assert(
mac_deployment_target == "10.15", mac_deployment_target == "10.13",
"Chromium has updated the mac_deployment_target, please update this assert, update the supported versions documentation (docs/tutorial/support.md) and flag this as a breaking change") "Chromium has updated the mac_deployment_target, please update this assert, update the supported versions documentation (docs/tutorial/support.md) and flag this as a breaking change")
} }
@@ -101,30 +99,22 @@ if (is_linux) {
} }
} }
declare_args() {
use_prebuilt_v8_context_snapshot = false
}
branding = read_file("shell/app/BRANDING.json", "json") branding = read_file("shell/app/BRANDING.json", "json")
electron_project_name = branding.project_name electron_project_name = branding.project_name
electron_product_name = branding.product_name electron_product_name = branding.product_name
electron_mac_bundle_id = branding.mac_bundle_id electron_mac_bundle_id = branding.mac_bundle_id
electron_version = exec_script("script/print-version.py",
if (override_electron_version != "") { [],
electron_version = override_electron_version "trim string",
} else { [
# When building from source code tarball there is no git tag available and ".git/packed-refs",
# builders must explicitly pass override_electron_version in gn args. ".git/HEAD",
# This read_file call will assert if there is no git information, without it "script/lib/get-version.js",
# gn will generate a malformed build configuration and ninja will get into ])
# infinite loop.
read_file(".git/packed-refs", "string")
# Set electron version from git tag.
electron_version = exec_script("script/get-git-version.py",
[],
"trim string",
[
".git/packed-refs",
".git/HEAD",
])
}
if (is_mas_build) { if (is_mas_build) {
assert(is_mac, assert(is_mac,
@@ -166,6 +156,15 @@ npm_action("build_electron_definitions") {
outputs = [ "$target_gen_dir/tsc/typings/electron.d.ts" ] outputs = [ "$target_gen_dir/tsc/typings/electron.d.ts" ]
} }
webpack_build("electron_asar_bundle") {
deps = [ ":build_electron_definitions" ]
inputs = auto_filenames.asar_bundle_deps
config_file = "//electron/build/webpack/webpack.config.asar.js"
out_file = "$target_gen_dir/js2c/asar_bundle.js"
}
webpack_build("electron_browser_bundle") { webpack_build("electron_browser_bundle") {
deps = [ ":build_electron_definitions" ] deps = [ ":build_electron_definitions" ]
@@ -211,15 +210,6 @@ webpack_build("electron_isolated_renderer_bundle") {
out_file = "$target_gen_dir/js2c/isolated_bundle.js" out_file = "$target_gen_dir/js2c/isolated_bundle.js"
} }
webpack_build("electron_node_bundle") {
deps = [ ":build_electron_definitions" ]
inputs = auto_filenames.node_bundle_deps
config_file = "//electron/build/webpack/webpack.config.node.js"
out_file = "$target_gen_dir/js2c/node_init.js"
}
webpack_build("electron_utility_bundle") { webpack_build("electron_utility_bundle") {
deps = [ ":build_electron_definitions" ] deps = [ ":build_electron_definitions" ]
@@ -231,37 +221,32 @@ webpack_build("electron_utility_bundle") {
action("electron_js2c") { action("electron_js2c") {
deps = [ deps = [
":electron_asar_bundle",
":electron_browser_bundle", ":electron_browser_bundle",
":electron_isolated_renderer_bundle", ":electron_isolated_renderer_bundle",
":electron_node_bundle",
":electron_renderer_bundle", ":electron_renderer_bundle",
":electron_sandboxed_renderer_bundle", ":electron_sandboxed_renderer_bundle",
":electron_utility_bundle", ":electron_utility_bundle",
":electron_worker_bundle", ":electron_worker_bundle",
"//third_party/electron_node:node_js2c($electron_js2c_toolchain)",
] ]
sources = [ sources = [
"$target_gen_dir/js2c/asar_bundle.js",
"$target_gen_dir/js2c/browser_init.js", "$target_gen_dir/js2c/browser_init.js",
"$target_gen_dir/js2c/isolated_bundle.js", "$target_gen_dir/js2c/isolated_bundle.js",
"$target_gen_dir/js2c/node_init.js",
"$target_gen_dir/js2c/renderer_init.js", "$target_gen_dir/js2c/renderer_init.js",
"$target_gen_dir/js2c/sandbox_bundle.js", "$target_gen_dir/js2c/sandbox_bundle.js",
"$target_gen_dir/js2c/utility_init.js", "$target_gen_dir/js2c/utility_init.js",
"$target_gen_dir/js2c/worker_init.js", "$target_gen_dir/js2c/worker_init.js",
] ]
inputs = sources inputs = sources + [ "//third_party/electron_node/tools/js2c.py" ]
outputs = [ "$root_gen_dir/electron_natives.cc" ] outputs = [ "$root_gen_dir/electron_natives.cc" ]
script = "build/js2c.py" script = "build/js2c.py"
out_dir = args = [ rebase_path("//third_party/electron_node") ] +
get_label_info(":anything($electron_js2c_toolchain)", "root_out_dir") rebase_path(outputs, root_build_dir) +
args = [ rebase_path(sources, root_build_dir)
rebase_path("$out_dir/node_js2c"),
rebase_path("$root_gen_dir"),
] + rebase_path(outputs, root_gen_dir) +
rebase_path(sources, root_gen_dir)
} }
action("generate_config_gypi") { action("generate_config_gypi") {
@@ -440,7 +425,6 @@ source_set("electron_lib") {
"//chrome/app/resources:platform_locale_settings", "//chrome/app/resources:platform_locale_settings",
"//components/autofill/core/common:features", "//components/autofill/core/common:features",
"//components/certificate_transparency", "//components/certificate_transparency",
"//components/compose:buildflags",
"//components/embedder_support:browser_util", "//components/embedder_support:browser_util",
"//components/language/core/browser", "//components/language/core/browser",
"//components/net_log", "//components/net_log",
@@ -449,9 +433,7 @@ source_set("electron_lib") {
"//components/network_hints/renderer", "//components/network_hints/renderer",
"//components/network_session_configurator/common", "//components/network_session_configurator/common",
"//components/omnibox/browser:buildflags", "//components/omnibox/browser:buildflags",
"//components/os_crypt/async/browser", "//components/os_crypt",
"//components/os_crypt/async/browser:key_provider_interface",
"//components/os_crypt/sync",
"//components/pref_registry", "//components/pref_registry",
"//components/prefs", "//components/prefs",
"//components/security_state/content", "//components/security_state/content",
@@ -479,7 +461,6 @@ source_set("electron_lib") {
"//services/proxy_resolver:lib", "//services/proxy_resolver:lib",
"//services/video_capture/public/mojom:constants", "//services/video_capture/public/mojom:constants",
"//services/viz/privileged/mojom/compositing", "//services/viz/privileged/mojom/compositing",
"//services/viz/public/mojom",
"//skia", "//skia",
"//third_party/blink/public:blink", "//third_party/blink/public:blink",
"//third_party/blink/public:blink_devtools_inspector_resources", "//third_party/blink/public:blink_devtools_inspector_resources",
@@ -492,9 +473,7 @@ source_set("electron_lib") {
"//third_party/webrtc_overrides:webrtc_component", "//third_party/webrtc_overrides:webrtc_component",
"//third_party/widevine/cdm:headers", "//third_party/widevine/cdm:headers",
"//third_party/zlib/google:zip", "//third_party/zlib/google:zip",
"//ui/base:ozone_buildflags",
"//ui/base/idle", "//ui/base/idle",
"//ui/compositor",
"//ui/events:dom_keycode_converter", "//ui/events:dom_keycode_converter",
"//ui/gl", "//ui/gl",
"//ui/native_theme", "//ui/native_theme",
@@ -567,7 +546,7 @@ source_set("electron_lib") {
deps += [ deps += [
"//components/remote_cocoa/app_shim", "//components/remote_cocoa/app_shim",
"//components/remote_cocoa/browser", "//components/remote_cocoa/browser",
"//content/browser:mac_helpers", "//content/common:mac_helpers",
"//ui/accelerated_widget_mac", "//ui/accelerated_widget_mac",
] ]
@@ -576,7 +555,6 @@ source_set("electron_lib") {
} }
frameworks = [ frameworks = [
"AuthenticationServices.framework",
"AVFoundation.framework", "AVFoundation.framework",
"Carbon.framework", "Carbon.framework",
"LocalAuthentication.framework", "LocalAuthentication.framework",
@@ -693,6 +671,46 @@ source_set("electron_lib") {
] ]
} }
if (enable_run_as_node) {
sources += [
"shell/app/node_main.cc",
"shell/app/node_main.h",
]
}
if (enable_osr) {
sources += [
"shell/browser/osr/osr_host_display_client.cc",
"shell/browser/osr/osr_host_display_client.h",
"shell/browser/osr/osr_render_widget_host_view.cc",
"shell/browser/osr/osr_render_widget_host_view.h",
"shell/browser/osr/osr_video_consumer.cc",
"shell/browser/osr/osr_video_consumer.h",
"shell/browser/osr/osr_view_proxy.cc",
"shell/browser/osr/osr_view_proxy.h",
"shell/browser/osr/osr_web_contents_view.cc",
"shell/browser/osr/osr_web_contents_view.h",
]
if (is_mac) {
sources += [
"shell/browser/osr/osr_host_display_client_mac.mm",
"shell/browser/osr/osr_web_contents_view_mac.mm",
]
}
deps += [
"//components/viz/service",
"//services/viz/public/mojom",
"//ui/compositor",
]
}
if (enable_desktop_capturer) {
sources += [
"shell/browser/api/electron_api_desktop_capturer.cc",
"shell/browser/api/electron_api_desktop_capturer.h",
]
}
if (enable_views_api) { if (enable_views_api) {
sources += [ sources += [
"shell/browser/api/views/electron_api_image_view.cc", "shell/browser/api/views/electron_api_image_view.cc",
@@ -723,7 +741,6 @@ source_set("electron_lib") {
"shell/common/extensions/api", "shell/common/extensions/api",
"shell/common/extensions/api:extensions_features", "shell/common/extensions/api:extensions_features",
"//chrome/browser/resources:component_extension_resources", "//chrome/browser/resources:component_extension_resources",
"//components/guest_view/common:mojom",
"//components/update_client:update_client", "//components/update_client:update_client",
"//components/zoom", "//components/zoom",
"//extensions/browser", "//extensions/browser",
@@ -753,10 +770,8 @@ source_set("electron_lib") {
"//pdf", "//pdf",
] ]
sources += [ sources += [
"shell/browser/electron_pdf_document_helper_client.cc", "shell/browser/electron_pdf_web_contents_helper_client.cc",
"shell/browser/electron_pdf_document_helper_client.h", "shell/browser/electron_pdf_web_contents_helper_client.h",
"shell/browser/extensions/api/pdf_viewer_private/pdf_viewer_private_api.cc",
"shell/browser/extensions/api/pdf_viewer_private/pdf_viewer_private_api.h",
] ]
} }
@@ -786,6 +801,15 @@ if (is_mac) {
sources = [ "shell/common/resources/mac/MainMenu.xib" ] sources = [ "shell/common/resources/mac/MainMenu.xib" ]
} }
action("fake_v8_context_snapshot_generator") {
script = "build/fake_v8_context_snapshot_generator.py"
args = [
rebase_path("$root_out_dir/$v8_context_snapshot_filename"),
rebase_path("$root_out_dir/fake/$v8_context_snapshot_filename"),
]
outputs = [ "$root_out_dir/fake/$v8_context_snapshot_filename" ]
}
bundle_data("electron_framework_resources") { bundle_data("electron_framework_resources") {
public_deps = [ ":packed_resources" ] public_deps = [ ":packed_resources" ]
sources = [] sources = []
@@ -796,8 +820,13 @@ if (is_mac) {
if (v8_use_external_startup_data) { if (v8_use_external_startup_data) {
public_deps += [ "//v8" ] public_deps += [ "//v8" ]
if (use_v8_context_snapshot) { if (use_v8_context_snapshot) {
sources += [ "$root_out_dir/$v8_context_snapshot_filename" ] if (use_prebuilt_v8_context_snapshot) {
public_deps += [ "//tools/v8_context_snapshot" ] sources += [ "$root_out_dir/fake/$v8_context_snapshot_filename" ]
public_deps += [ ":fake_v8_context_snapshot_generator" ]
} else {
sources += [ "$root_out_dir/$v8_context_snapshot_filename" ]
public_deps += [ "//tools/v8_context_snapshot" ]
}
} else { } else {
sources += [ "$root_out_dir/snapshot_blob.bin" ] sources += [ "$root_out_dir/snapshot_blob.bin" ]
} }
@@ -897,7 +926,11 @@ if (is_mac) {
include_dirs = [ "." ] include_dirs = [ "." ]
sources = filenames.framework_sources sources = filenames.framework_sources
frameworks = [ "IOSurface.framework" ] frameworks = []
if (enable_osr) {
frameworks += [ "IOSurface.framework" ]
}
ldflags = [ ldflags = [
"-Wl,-install_name,@rpath/$output_name.framework/$output_name", "-Wl,-install_name,@rpath/$output_name.framework/$output_name",
@@ -927,12 +960,15 @@ if (is_mac) {
assert(defined(invoker.helper_name_suffix)) assert(defined(invoker.helper_name_suffix))
output_name = electron_helper_name + invoker.helper_name_suffix output_name = electron_helper_name + invoker.helper_name_suffix
deps = [ ":electron_framework+link" ] deps = [
":electron_framework+link",
"//base/allocator:early_zone_registration_mac",
]
if (!is_mas_build) { if (!is_mas_build) {
deps += [ "//sandbox/mac:seatbelt" ] deps += [ "//sandbox/mac:seatbelt" ]
} }
defines = [ "HELPER_EXECUTABLE" ] defines = [ "HELPER_EXECUTABLE" ]
configs += [ "//electron/build/config:mas_build" ] extra_configs = [ "//electron/build/config:mas_build" ]
sources = [ sources = [
"shell/app/electron_main_mac.cc", "shell/app/electron_main_mac.cc",
"shell/app/uv_stdio_fix.cc", "shell/app/uv_stdio_fix.cc",
@@ -1088,6 +1124,7 @@ if (is_mac) {
":electron_app_plist", ":electron_app_plist",
":electron_app_resources", ":electron_app_resources",
":electron_fuses", ":electron_fuses",
"//base/allocator:early_zone_registration_mac",
"//electron/buildflags", "//electron/buildflags",
] ]
if (is_mas_build) { if (is_mas_build) {
@@ -1102,7 +1139,7 @@ if (is_mac) {
"-rpath", "-rpath",
"@executable_path/../Frameworks", "@executable_path/../Frameworks",
] ]
configs += [ "//electron/build/config:mas_build" ] extra_configs = [ "//electron/build/config:mas_build" ]
} }
if (enable_dsyms) { if (enable_dsyms) {
@@ -1240,7 +1277,7 @@ if (is_mac) {
] ]
deps += [ deps += [
"//chrome/app:exit_code_watcher", "//components/browser_watcher:browser_watcher_client",
"//components/crash/core/app:run_as_crashpad_handler", "//components/crash/core/app:run_as_crashpad_handler",
] ]
@@ -1339,6 +1376,25 @@ if (is_mac) {
} }
} }
test("shell_browser_ui_unittests") {
sources = [
"//electron/shell/browser/ui/accelerator_util_unittests.cc",
"//electron/shell/browser/ui/run_all_unittests.cc",
]
configs += [ ":electron_lib_config" ]
deps = [
":electron_lib",
"//base",
"//base/test:test_support",
"//testing/gmock",
"//testing/gtest",
"//ui/base",
"//ui/strings",
]
}
template("dist_zip") { template("dist_zip") {
_runtime_deps_target = "${target_name}__deps" _runtime_deps_target = "${target_name}__deps"
_runtime_deps_file = _runtime_deps_file =
@@ -1477,9 +1533,8 @@ dist_zip("libcxx_headers_zip") {
data_deps = [ ":libcxx_headers" ] data_deps = [ ":libcxx_headers" ]
deps = data_deps deps = data_deps
flatten = true flatten = true
flatten_relative_to = flatten_relative_to = rebase_path(
rebase_path( "$target_gen_dir/electron_libcxx_include/buildtools/third_party/libc++/trunk",
"$target_gen_dir/electron_libcxx_include/third_party/libc++/src",
"$root_out_dir") "$root_out_dir")
outputs = [ "$root_build_dir/libcxx_headers.zip" ] outputs = [ "$root_build_dir/libcxx_headers.zip" ]
@@ -1495,7 +1550,7 @@ dist_zip("libcxxabi_headers_zip") {
deps = data_deps deps = data_deps
flatten = true flatten = true
flatten_relative_to = rebase_path( flatten_relative_to = rebase_path(
"$target_gen_dir/electron_libcxxabi_include/third_party/libc++abi/src", "$target_gen_dir/electron_libcxxabi_include/buildtools/third_party/libc++abi/trunk",
"$root_out_dir") "$root_out_dir")
outputs = [ "$root_build_dir/libcxxabi_headers.zip" ] outputs = [ "$root_build_dir/libcxxabi_headers.zip" ]
@@ -1511,70 +1566,3 @@ action("libcxx_objects_zip") {
group("electron") { group("electron") {
public_deps = [ ":electron_app" ] public_deps = [ ":electron_app" ]
} }
##### node_headers
node_dir = "../third_party/electron_node"
node_files = read_file("$node_dir/filenames.json", "json")
node_headers_dir = "$root_gen_dir/node_headers"
header_group_index = 0
header_groups = []
foreach(header_group, node_files.headers) {
copy("node_headers_${header_group_index}") {
sources = rebase_path(header_group.files, ".", node_dir)
outputs =
[ "$node_headers_dir/${header_group.dest_dir}/{{source_file_part}}" ]
}
header_groups += [ ":node_headers_${header_group_index}" ]
header_group_index += 1
}
copy("zlib_headers") {
sources = [
"$node_dir/deps/zlib/zconf.h",
"$node_dir/deps/zlib/zlib.h",
]
outputs = [ "$node_headers_dir/include/node/{{source_file_part}}" ]
}
copy("node_gypi_headers") {
deps = [ ":generate_config_gypi" ]
sources = [
"$node_dir/common.gypi",
"$root_gen_dir/config.gypi",
]
outputs = [ "$node_headers_dir/include/node/{{source_file_part}}" ]
}
action("node_version_header") {
inputs = [ "$node_dir/src/node_version.h" ]
outputs = [ "$node_headers_dir/include/node/node_version.h" ]
script = "script/generate_node_version_header.py"
args = rebase_path(inputs) + rebase_path(outputs)
if (node_module_version != "") {
args += [ "$node_module_version" ]
}
}
action("tar_node_headers") {
deps = [ ":copy_node_headers" ]
outputs = [ "$root_gen_dir/node_headers.tar.gz" ]
script = "script/tar.py"
args = [
rebase_path("$root_gen_dir/node_headers"),
rebase_path(outputs[0]),
]
}
group("copy_node_headers") {
public_deps = header_groups + [
":node_gypi_headers",
":node_version_header",
":zlib_headers",
]
}
group("node_headers") {
public_deps = [ ":tar_node_headers" ]
}

View File

@@ -28,7 +28,7 @@ _If an issue has been closed and you still feel it's relevant, feel free to ping
### Languages ### Languages
We accept issues in _any_ language. We accept issues in *any* language.
When an issue is posted in a language besides English, it is acceptable and encouraged to post an English-translated copy as a reply. When an issue is posted in a language besides English, it is acceptable and encouraged to post an English-translated copy as a reply.
Anyone may post the translated reply. Anyone may post the translated reply.
In most cases, a quick pass through translation software is sufficient. In most cases, a quick pass through translation software is sufficient.
@@ -60,10 +60,6 @@ dependencies, and tools contained in the `electron/electron` repository.
* [Step 11: Landing](https://electronjs.org/docs/development/pull-requests#step-11-landing) * [Step 11: Landing](https://electronjs.org/docs/development/pull-requests#step-11-landing)
* [Continuous Integration Testing](https://electronjs.org/docs/development/pull-requests#continuous-integration-testing) * [Continuous Integration Testing](https://electronjs.org/docs/development/pull-requests#continuous-integration-testing)
### Dependencies Upgrades Policy
Dependencies in Electron's `package.json` or `yarn.lock` files should only be altered by maintainers. For security reasons, we will not accept PRs that alter our `package.json` or `yarn.lock` files. We invite contributors to make requests updating these files in our issue tracker. If the change is significantly complicated, draft PRs are welcome, with the understanding that these PRs will be closed in favor of a duplicate PR submitted by an Electron maintainer.
## Style Guides ## Style Guides
See [Coding Style](https://electronjs.org/docs/development/coding-style) for information about which standards Electron adheres to in different parts of its codebase. See [Coding Style](https://electronjs.org/docs/development/coding-style) for information about which standards Electron adheres to in different parts of its codebase.

27
DEPS
View File

@@ -2,19 +2,13 @@ gclient_gn_args_from = 'src'
vars = { vars = {
'chromium_version': 'chromium_version':
'122.0.6261.39', '110.0.5481.52',
'node_version': 'node_version':
'v20.9.0', 'v18.12.1',
'nan_version': 'nan_version':
'e14bdcd1f72d62bca1d541b66da43130384ec213', '16fa32231e2ccd89d2804b3f765319128b20c4ac',
'squirrel.mac_version': 'squirrel.mac_version':
'0e5d146ba13101a1302d59ea6e6e0b3cace4ae38', '0e5d146ba13101a1302d59ea6e6e0b3cace4ae38',
'reactiveobjc_version':
'74ab5baccc6f7202c8ac69a8d1e152c29dc1ea76',
'mantle_version':
'78d3966b3c331292ea29ec38661b25df0a245948',
'engflow_reclient_configs_version':
'955335c30a752e9ef7bff375baab5e0819b6c00d',
'pyyaml_version': '3.12', 'pyyaml_version': '3.12',
@@ -23,12 +17,6 @@ vars = {
'nodejs_git': 'https://github.com/nodejs', 'nodejs_git': 'https://github.com/nodejs',
'yaml_git': 'https://github.com/yaml', 'yaml_git': 'https://github.com/yaml',
'squirrel_git': 'https://github.com/Squirrel', 'squirrel_git': 'https://github.com/Squirrel',
'reactiveobjc_git': 'https://github.com/ReactiveCocoa',
'mantle_git': 'https://github.com/Mantle',
'engflow_git': 'https://github.com/EngFlow',
# The path of the sysroots.json file.
'sysroots_json_path': 'electron/script/sysroots.json',
# KEEP IN SYNC WITH utils.js FILE # KEEP IN SYNC WITH utils.js FILE
'yarn_version': '1.15.2', 'yarn_version': '1.15.2',
@@ -99,16 +87,12 @@ deps = {
'condition': 'process_deps', 'condition': 'process_deps',
}, },
'src/third_party/squirrel.mac/vendor/ReactiveObjC': { 'src/third_party/squirrel.mac/vendor/ReactiveObjC': {
'url': Var("reactiveobjc_git") + '/ReactiveObjC.git@' + Var("reactiveobjc_version"), 'url': 'https://github.com/ReactiveCocoa/ReactiveObjC.git@74ab5baccc6f7202c8ac69a8d1e152c29dc1ea76',
'condition': 'process_deps' 'condition': 'process_deps'
}, },
'src/third_party/squirrel.mac/vendor/Mantle': { 'src/third_party/squirrel.mac/vendor/Mantle': {
'url': Var("mantle_git") + '/Mantle.git@' + Var("mantle_version"), 'url': 'https://github.com/Mantle/Mantle.git@78d3966b3c331292ea29ec38661b25df0a245948',
'condition': 'process_deps', 'condition': 'process_deps',
},
'src/third_party/engflow-reclient-configs': {
'url': Var("engflow_git") + '/reclient-configs.git@' + Var("engflow_reclient_configs_version"),
'condition': 'process_deps'
} }
} }
@@ -165,4 +149,5 @@ hooks = [
recursedeps = [ recursedeps = [
'src', 'src',
'src/third_party/squirrel.mac',
] ]

View File

@@ -9,8 +9,8 @@ View these docs in other languages on our [Crowdin](https://crowdin.com/project/
The Electron framework lets you write cross-platform desktop applications The Electron framework lets you write cross-platform desktop applications
using JavaScript, HTML and CSS. It is based on [Node.js](https://nodejs.org/) and using JavaScript, HTML and CSS. It is based on [Node.js](https://nodejs.org/) and
[Chromium](https://www.chromium.org) and is used by the [Visual Studio [Chromium](https://www.chromium.org) and is used by the [Atom
Code](https://github.com/Microsoft/vscode/) and many other [apps](https://electronjs.org/apps). editor](https://github.com/atom/atom) and many other [apps](https://electronjs.org/apps).
Follow [@electronjs](https://twitter.com/electronjs) on Twitter for important Follow [@electronjs](https://twitter.com/electronjs) on Twitter for important
announcements. announcements.
@@ -38,12 +38,12 @@ For more installation options and troubleshooting tips, see
Each Electron release provides binaries for macOS, Windows, and Linux. Each Electron release provides binaries for macOS, Windows, and Linux.
* macOS (Catalina and up): Electron provides 64-bit Intel and ARM binaries for macOS. Apple Silicon support was added in Electron 11. * macOS (High Sierra and up): Electron provides 64-bit Intel and ARM binaries for macOS. Apple Silicon support was added in Electron 11.
* Windows (Windows 10 and up): Electron provides `ia32` (`x86`), `x64` (`amd64`), and `arm64` binaries for Windows. Windows on ARM support was added in Electron 5.0.8. Support for Windows 7, 8 and 8.1 was [removed in Electron 23, in line with Chromium's Windows deprecation policy](https://www.electronjs.org/blog/windows-7-to-8-1-deprecation-notice). * Windows (Windows 10 and up): Electron provides `ia32` (`x86`), `x64` (`amd64`), and `arm64` binaries for Windows. Windows on ARM support was added in Electron 5.0.8. Support for Windows 7, 8 and 8.1 was [removed in Electron 23, in line with Chromium's Windows deprecation policy](https://www.electronjs.org/blog/windows-7-to-8-1-deprecation-notice).
* Linux: The prebuilt binaries of Electron are built on Ubuntu 20.04. They have also been verified to work on: * Linux: The prebuilt binaries of Electron are built on Ubuntu 20.04. They have also been verified to work on:
* Ubuntu 18.04 and newer * Ubuntu 14.04 and newer
* Fedora 32 and newer * Fedora 24 and newer
* Debian 10 and newer * Debian 8 and newer
## Quick start & Electron Fiddle ## Quick start & Electron Fiddle
@@ -78,7 +78,7 @@ binary. Use this to spawn Electron from Node scripts:
```javascript ```javascript
const electron = require('electron') const electron = require('electron')
const proc = require('node:child_process') const proc = require('child_process')
// will print something similar to /Users/maf/.../Electron // will print something similar to /Users/maf/.../Electron
console.log(electron) console.log(electron)

View File

@@ -6,67 +6,32 @@
version: 1.0.{build} version: 1.0.{build}
build_cloud: electronhq-16-core build_cloud: electronhq-16-core
image: base-bake-image image: e-110.0.5451.0
environment: environment:
GIT_CACHE_PATH: C:\Users\appveyor\libcc_cache GIT_CACHE_PATH: C:\Users\appveyor\libcc_cache
ELECTRON_OUT_DIR: Default ELECTRON_OUT_DIR: Default
ELECTRON_ENABLE_STACK_DUMPING: 1 ELECTRON_ENABLE_STACK_DUMPING: 1
MOCHA_REPORTER: mocha-multi-reporters MOCHA_REPORTER: mocha-multi-reporters
MOCHA_MULTI_REPORTERS: mocha-appveyor-reporter, tap MOCHA_MULTI_REPORTERS: mocha-appveyor-reporter, tap
GOMA_FALLBACK_ON_AUTH_FAILURE: true
DEPOT_TOOLS_WIN_TOOLCHAIN: 0 DEPOT_TOOLS_WIN_TOOLCHAIN: 0
PYTHONIOENCODING: UTF-8 PYTHONIOENCODING: UTF-8
# Uncomment these lines and set APPVEYOR_RDP_PASSWORD in project settings to enable RDP before bake begins
# The following lines are needed when baking from a completely new image (eg MicrosoftWindowsServer:WindowsServer:2019-Datacenter:latest via image: base-windows-server2019) # install:
# init: # - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
# - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
# - appveyor version
# - ps: $ErrorActionPreference = 'Stop'
# - ps: 'Write-Host "OS Build: $((Get-CimInstance Win32_OperatingSystem).BuildNumber)"'
# clone_folder: '%USERPROFILE%\image-bake-scripts'
# clone_script:
# - ps: Invoke-WebRequest "https://github.com/appveyor/build-images/archive/1f90d94e74c8243c909a09b994e527584dfcb838.zip" -OutFile "$env:temp\scripts.zip"
# - ps: Expand-Archive -Path "$env:temp\scripts.zip" -DestinationPath "$env:temp\scripts" -Force
# - ps: Copy-Item -Path "$env:temp\scripts\build-images-1f90d94e74c8243c909a09b994e527584dfcb838\scripts\Windows\*" -Destination $env:APPVEYOR_BUILD_FOLDER -Recurse
build_script: build_script:
# The following lines are needed when baking from a completely new image (eg MicrosoftWindowsServer:WindowsServer:2019-Datacenter:latest via image: base-windows-server2019) # Uncomment/change the following line if the hard drive/partition size needs to change
# - ps: .\init_server.ps1 # - ps: Resize-Partition -DriveLetter C -Size (256GB) # ensure initial partition size
# - ps: .\extend_system_volume.ps1
# # Restart VM
# - ps: Start-Sleep -s 5; Restart-Computer
# - ps: Start-Sleep -s 5
# - appveyor version
# - ps: .\install_path_utils.ps1
# - ps: .\install_powershell_core.ps1
# - ps: .\install_powershell_get.ps1
# - ps: .\install_7zip.ps1
# - ps: .\install_chocolatey.ps1
# - ps: .\install_webpi.ps1
# - ps: .\install_nuget.ps1
# - ps: .\install_pstools.ps1
# - ps: .\install_git.ps1
# - ps: .\install_git_lfs.ps1
# # Restart VM
# - ps: Start-Sleep -s 5; Restart-Computer
# - ps: Start-Sleep -s 5
# END LINES FOR COMPLETELY NEW IMAGE
- git config --global core.longpaths true - git config --global core.longpaths true
- cd ..
- ps: >- - ps: >-
if (-not (Test-Path -Path C:\projects\src)) { if (-not (Test-Path -Path .\src)) {
New-Item -Path C:\projects\src -ItemType Directory New-Item -Path .\src -ItemType Directory
} }
- cd C:\projects\ - ps: git clone --depth=1 https://chromium.googlesource.com/chromium/tools/depot_tools.git
- git clone -q --branch=%APPVEYOR_REPO_BRANCH% https://github.com/electron/electron.git C:\projects\src\electron - ps: $env:PATH="$pwd\depot_tools;$env:PATH"
- git clone --depth=1 https://chromium.googlesource.com/chromium/tools/depot_tools.git
- ps: $env:PATH="$pwd\depot_tools;$env:PATH"
- update_depot_tools.bat - update_depot_tools.bat
- ps: Move-Item $env:APPVEYOR_BUILD_FOLDER -Destination src\electron
# Uncomment the following line if windows deps change # Uncomment the following line if windows deps change
# - src\electron\script\setup-win-for-dev.bat # - src\electron\script\setup-win-for-dev.bat
- >- - >-
@@ -81,27 +46,21 @@ build_script:
- ps: Copy-Item -path .\.depshash -destination ..\.depshash - ps: Copy-Item -path .\.depshash -destination ..\.depshash
- ps: cd ..\.. - ps: cd ..\..
- gclient sync --with_branch_heads --with_tags --nohooks - gclient sync --with_branch_heads --with_tags --nohooks
- ps: regsvr32 /s "C:\Program Files\Microsoft Visual Studio\2022\Community\DIA SDK\bin\amd64\msdia140.dll" - ps: regsvr32 /s "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\DIA SDK\bin\amd64\msdia140.dll"
- ps: set vs2022_install="C:\Program Files\Microsoft Visual Studio\2022\Community" - ps: |
$env:appveyor_user = "appveyor"
# The following lines are needed when baking from a completely new image (eg MicrosoftWindowsServer:WindowsServer:2019-Datacenter:latest via image: base-windows-server2019) $env:appveyor_password = [Guid]::NewGuid().ToString('B')
# # Restart VM
# - ps: Start-Sleep -s 5; Restart-Computer
# - ps: Start-Sleep -s 5
# - cd %USERPROFILE%\image-bake-scripts Set-LocalUser -Name $env:appveyor_user -Password (ConvertTo-SecureString -AsPlainText $env:appveyor_password -Force) -PasswordNeverExpires:$true
# - appveyor version
# - ps: .\optimize_dotnet_runtime.ps1 iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/build-images/master/scripts/Windows/enable_autologon.ps1'))
# - ps: .\disable_windows_background_services.ps1
# - ps: .\enforce_windows_firewall.ps1
# - ps: .\cleanup_windows.ps1
# END LINES FOR COMPLETELY NEW IMAGE
on_image_bake: on_image_bake:
- ps: >- - ps: >-
echo "Baking image: $env:APPVEYOR_BAKE_IMAGE at dir $PWD" echo "Baking image: $env:APPVEYOR_BAKE_IMAGE at dir $PWD"
- ps: Remove-Item -Recurse -Force C:\projects\depot_tools - ps: Remove-Item -Recurse -Force $pwd\depot_tools
- ps: Remove-Item -Recurse -Force C:\projects\src\electron - ps: Remove-Item -Recurse -Force $pwd\src\electron
# Uncomment these lines and set APPVEYOR_RDP_PASSWORD in project settings to enable RDP after bake is done # Uncomment these lines and set APPVEYOR_RDP_PASSWORD in project settings to enable RDP after bake is done
# # on_finish: #on_finish:
# - ps: >- # - ps: >-
# $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) # $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))

View File

@@ -1,18 +1,18 @@
# NOTE IF CHANGING THIS FILE, ALSO APPLY THE CHANGE TO appveyor.yml # NOTE IF CHANGING THIS FILE, ALSO APPLY THE CHANGE TO appveyor.yml
# IF APPLICABLE!!!! # IF APPLICABLE!!!!
# #
# #
# The config expects the following environment variables to be set: # The config expects the following environment variables to be set:
# - "GN_CONFIG" Build type. One of {'testing', 'release'}. # - "GN_CONFIG" Build type. One of {'testing', 'release'}.
# - "GN_EXTRA_ARGS" Additional gn arguments for a build config, # - "GN_EXTRA_ARGS" Additional gn arguments for a build config,
# e.g. 'target_cpu="x86"' to build for a 32bit platform. # e.g. 'target_cpu="x86"' to build for a 32bit platform.
# https://gn.googlesource.com/gn/+/main/docs/reference.md#var_target_cpu # https://gn.googlesource.com/gn/+/master/docs/reference.md#target_cpu
# Don't forget to set up "NPM_CONFIG_ARCH" and "TARGET_ARCH" accordingly # Don't forget to set up "NPM_CONFIG_ARCH" and "TARGET_ARCH" accordingly
# if you pass a custom value for 'target_cpu'. # if you pass a custom value for 'target_cpu'.
# - "ELECTRON_RELEASE" Set it to '1' upload binaries on success. # - "ELECTRON_RELEASE" Set it to '1' upload binaries on success.
# - "NPM_CONFIG_ARCH" E.g. 'x86'. Is used to build native Node.js modules. # - "NPM_CONFIG_ARCH" E.g. 'x86'. Is used to build native Node.js modules.
# Must match 'target_cpu' passed to "GN_EXTRA_ARGS" and "TARGET_ARCH" value. # Must match 'target_cpu' passed to "GN_EXTRA_ARGS" and "TARGET_ARCH" value.
# - "TARGET_ARCH" Choose from {'ia32', 'x64', 'arm', 'arm64'}. # - "TARGET_ARCH" Choose from {'ia32', 'x64', 'arm', 'arm64', 'mips64el'}.
# Is used in some publishing scripts, but does NOT affect the Electron binary. # Is used in some publishing scripts, but does NOT affect the Electron binary.
# Must match 'target_cpu' passed to "GN_EXTRA_ARGS" and "NPM_CONFIG_ARCH" value. # Must match 'target_cpu' passed to "GN_EXTRA_ARGS" and "NPM_CONFIG_ARCH" value.
# - "UPLOAD_TO_STORAGE" Set it to '1' upload a release to the Azure bucket. # - "UPLOAD_TO_STORAGE" Set it to '1' upload a release to the Azure bucket.
@@ -29,17 +29,16 @@
version: 1.0.{build} version: 1.0.{build}
build_cloud: electronhq-16-core build_cloud: electronhq-16-core
image: e-121.0.6116.0 image: e-110.0.5478.5
environment: environment:
GIT_CACHE_PATH: C:\Users\appveyor\libcc_cache GIT_CACHE_PATH: C:\Users\appveyor\libcc_cache
ELECTRON_OUT_DIR: Default ELECTRON_OUT_DIR: Default
ELECTRON_ENABLE_STACK_DUMPING: 1 ELECTRON_ENABLE_STACK_DUMPING: 1
ELECTRON_ALSO_LOG_TO_STDERR: 1 ELECTRON_ALSO_LOG_TO_STDERR: 1
MOCHA_REPORTER: mocha-multi-reporters MOCHA_REPORTER: mocha-multi-reporters
MOCHA_MULTI_REPORTERS: "@marshallofsound/mocha-appveyor-reporter, tap" MOCHA_MULTI_REPORTERS: mocha-appveyor-reporter, tap
DEPOT_TOOLS_WIN_TOOLCHAIN: 1 GOMA_FALLBACK_ON_AUTH_FAILURE: true
DEPOT_TOOLS_WIN_TOOLCHAIN_BASE_URL: "https://dev-cdn.electronjs.org/windows-toolchains/_" DEPOT_TOOLS_WIN_TOOLCHAIN: 0
GYP_MSVS_HASH_27370823e7: 28622d16b1
PYTHONIOENCODING: UTF-8 PYTHONIOENCODING: UTF-8
matrix: matrix:
@@ -50,11 +49,6 @@ environment:
APPVEYOR_BUILD_WORKER_IMAGE: base-woa APPVEYOR_BUILD_WORKER_IMAGE: base-woa
APPVEYOR_BUILD_WORKER_CLOUD: electronhq-woa APPVEYOR_BUILD_WORKER_CLOUD: electronhq-woa
clone_script:
- ps: git clone -q $("--branch=" + $Env:APPVEYOR_REPO_BRANCH) $("https://github.com/" + $Env:APPVEYOR_REPO_NAME + ".git") $Env:APPVEYOR_BUILD_FOLDER
- ps: if (!$Env:APPVEYOR_PULL_REQUEST_NUMBER) {$("git checkout -qf " + $Env:APPVEYOR_REPO_COMMIT)}
- ps: if ($Env:APPVEYOR_PULL_REQUEST_NUMBER) {git fetch -q origin +refs/pull/$($Env:APPVEYOR_PULL_REQUEST_NUMBER)/head; git checkout -qf FETCH_HEAD}
clone_folder: C:\projects\src\electron clone_folder: C:\projects\src\electron
skip_branch_with_pr: true skip_branch_with_pr: true
@@ -72,15 +66,11 @@ for:
build_script: build_script:
- ps: | - ps: |
node script/yarn.js install --frozen-lockfile node script/yarn.js install --frozen-lockfile
node script/doc-only-change.js --prNumber=$env:APPVEYOR_PULL_REQUEST_NUMBER node script/doc-only-change.js --prNumber=$env:APPVEYOR_PULL_REQUEST_NUMBER --prBranch=$env:APPVEYOR_REPO_BRANCH
$env:SHOULD_SKIP_ARTIFACT_VALIDATION = "false"
if ($LASTEXITCODE -eq 0) { if ($LASTEXITCODE -eq 0) {
Write-warning "Skipping build for doc-only change" Write-warning "Skipping build for doc only change"; Exit-AppveyorBuild
$env:SHOULD_SKIP_ARTIFACT_VALIDATION = "true"
Exit-AppveyorBuild
} else {
$global:LASTEXITCODE = 0
} }
$global:LASTEXITCODE = 0
- cd .. - cd ..
- ps: Write-Host "Building $env:GN_CONFIG build" - ps: Write-Host "Building $env:GN_CONFIG build"
- git config --global core.longpaths true - git config --global core.longpaths true
@@ -92,37 +82,44 @@ for:
if (Test-Path -Path "$pwd\build-tools") { if (Test-Path -Path "$pwd\build-tools") {
Remove-Item -Recurse -Force $pwd\build-tools Remove-Item -Recurse -Force $pwd\build-tools
} }
- git clone --depth=1 https://chromium.googlesource.com/chromium/tools/depot_tools.git - ps: git clone --depth=1 https://chromium.googlesource.com/chromium/tools/depot_tools.git
- ps: New-Item -Name depot_tools\.disable_auto_update -ItemType File
- depot_tools\bootstrap\win_tools.bat
- ps: $env:PATH="$pwd\depot_tools;$env:PATH" - ps: $env:PATH="$pwd\depot_tools;$env:PATH"
- ps: >- - ps: >-
if (Test-Path -Path "$pwd\src\electron") { if (Test-Path -Path "$pwd\src\electron") {
Remove-Item -Recurse -Force $pwd\src\electron Remove-Item -Recurse -Force $pwd\src\electron
} }
- ps: >-
if (Test-Path 'env:RAW_GOMA_AUTH') {
$env:GOMA_OAUTH2_CONFIG_FILE = "$pwd\.goma_oauth2_config"
$env:RAW_GOMA_AUTH | Set-Content $env:GOMA_OAUTH2_CONFIG_FILE
}
- git clone https://github.com/electron/build-tools.git - git clone https://github.com/electron/build-tools.git
- cd build-tools - cd build-tools
- npx yarn --ignore-engines - npm install
- mkdir third_party - mkdir third_party
- ps: >- - ps: >-
node -e "require('./src/utils/reclient.js').downloadAndPrepare({})" node -e "require('./src/utils/goma.js').downloadAndPrepare({ gomaOneForAll: true })"
- ps: $env:RECLIENT_HELPER = node -p "require('./src/utils/reclient.js').helperPath({})" - ps: $env:GN_GOMA_FILE = node -e "console.log(require('./src/utils/goma.js').gnFilePath)"
- ps: >- - ps: $env:LOCAL_GOMA_DIR = node -e "console.log(require('./src/utils/goma.js').dir)"
& $env:RECLIENT_HELPER login
- ps: >-
$env:RBE_service = node -e "console.log(require('./src/utils/reclient.js').serviceAddress)"
- ps: >-
$env:RBE_experimental_credentials_helper = $env:RECLIENT_HELPER
- ps: >-
$env:RBE_experimental_credentials_helper_args = "print"
- cd ..\.. - cd ..\..
- ps: .\src\electron\script\start-goma.ps1 -gomaDir $env:LOCAL_GOMA_DIR
- ps: >-
if (Test-Path 'env:RAW_GOMA_AUTH') {
$goma_login = python $env:LOCAL_GOMA_DIR\goma_auth.py info
if ($goma_login -eq 'Login as Fermi Planck') {
Write-warning "Goma authentication is correct";
} else {
Write-warning "WARNING!!!!!! Goma authentication is incorrect; please update Goma auth token.";
$host.SetShouldExit(1)
}
}
- ps: $env:CHROMIUM_BUILDTOOLS_PATH="$pwd\src\buildtools" - ps: $env:CHROMIUM_BUILDTOOLS_PATH="$pwd\src\buildtools"
- ps: >- - ps: >-
if ($env:GN_CONFIG -ne 'release') { if ($env:GN_CONFIG -ne 'release') {
$env:NINJA_STATUS="[%r processes, %f/%t @ %o/s : %es] " $env:NINJA_STATUS="[%r processes, %f/%t @ %o/s : %es] "
} }
- gclient config --name "src\electron" --unmanaged %GCLIENT_EXTRA_ARGS% "https://github.com/electron/electron" - gclient config --name "src\electron" --unmanaged %GCLIENT_EXTRA_ARGS% "https://github.com/electron/electron"
# Patches are applied in the image bake. Check depshash to see if patches have changed. # Patches are applied in the image bake. Check depshash to see if patches have changed.
- ps: $env:RUN_GCLIENT_SYNC="false" - ps: $env:RUN_GCLIENT_SYNC="false"
- ps: $depshash_baked = Get-Content .\src\.depshash -Raw - ps: $depshash_baked = Get-Content .\src\.depshash -Raw
- ps: cd src\electron - ps: cd src\electron
@@ -137,36 +134,37 @@ for:
- cd src - cd src
- ps: $env:PATH="$pwd\third_party\ninja;$env:PATH" - ps: $env:PATH="$pwd\third_party\ninja;$env:PATH"
- set BUILD_CONFIG_PATH=//electron/build/args/%GN_CONFIG%.gn - set BUILD_CONFIG_PATH=//electron/build/args/%GN_CONFIG%.gn
- gn gen out/Default "--args=import(\"%BUILD_CONFIG_PATH%\") use_remoteexec=true %GN_EXTRA_ARGS% " - gn gen out/Default "--args=import(\"%BUILD_CONFIG_PATH%\") import(\"%GN_GOMA_FILE%\") %GN_EXTRA_ARGS% "
- gn check out/Default //electron:electron_lib - gn check out/Default //electron:electron_lib
- gn check out/Default //electron:electron_app - gn check out/Default //electron:electron_app
- gn check out/Default //electron/shell/common/api:mojo - gn check out/Default //electron/shell/common/api:mojo
- if DEFINED ELECTRON_RBE_JWT (autoninja -j 300 -C out/Default electron:electron_app) else (autoninja -C out/Default electron:electron_app) - if DEFINED GN_GOMA_FILE (ninja -j 300 -C out/Default electron:electron_app) else (ninja -C out/Default electron:electron_app)
- if "%GN_CONFIG%"=="testing" ( python C:\depot_tools\post_build_ninja_summary.py -C out\Default ) - if "%GN_CONFIG%"=="testing" ( python C:\depot_tools\post_build_ninja_summary.py -C out\Default )
- gn gen out/ffmpeg "--args=import(\"//electron/build/args/ffmpeg.gn\") use_remoteexec=true %GN_EXTRA_ARGS%" - gn gen out/ffmpeg "--args=import(\"//electron/build/args/ffmpeg.gn\") %GN_EXTRA_ARGS%"
- autoninja -C out/ffmpeg electron:electron_ffmpeg_zip - ninja -C out/ffmpeg electron:electron_ffmpeg_zip
- autoninja -C out/Default electron:electron_dist_zip - ninja -C out/Default electron:electron_dist_zip
- ninja -C out/Default shell_browser_ui_unittests
- gn desc out/Default v8:run_mksnapshot_default args > out/Default/default_mksnapshot_args - gn desc out/Default v8:run_mksnapshot_default args > out/Default/default_mksnapshot_args
# Remove unused args from mksnapshot_args # Remove unused args from mksnapshot_args
- ps: >- - ps: >-
Get-Content out/Default/default_mksnapshot_args | Where-Object { -not $_.Contains('--turbo-profiling-input') -And -not $_.Contains('builtins-pgo') -And -not $_.Contains('The gn arg use_goma=true') } | Set-Content out/Default/mksnapshot_args Get-Content out/Default/default_mksnapshot_args | Where-Object { -not $_.Contains('--turbo-profiling-input') -And -not $_.Contains('builtins-pgo') } | Set-Content out/Default/mksnapshot_args
- autoninja -C out/Default electron:electron_mksnapshot_zip - ninja -C out/Default electron:electron_mksnapshot_zip
- cd out\Default - cd out\Default
- 7z a mksnapshot.zip mksnapshot_args gen\v8\embedded.S - 7z a mksnapshot.zip mksnapshot_args gen\v8\embedded.S
- cd ..\.. - cd ..\..
- autoninja -C out/Default electron:hunspell_dictionaries_zip - ninja -C out/Default electron:hunspell_dictionaries_zip
- autoninja -C out/Default electron:electron_chromedriver_zip - ninja -C out/Default electron:electron_chromedriver_zip
- autoninja -C out/Default electron:node_headers - ninja -C out/Default third_party/electron_node:headers
- python %LOCAL_GOMA_DIR%\goma_ctl.py stat
- ps: >- - ps: >-
Get-CimInstance -Namespace root\cimv2 -Class Win32_product | Select vendor, description, @{l='install_location';e='InstallLocation'}, @{l='install_date';e='InstallDate'}, @{l='install_date_2';e='InstallDate2'}, caption, version, name, @{l='sku_number';e='SKUNumber'} | ConvertTo-Json | Out-File -Encoding utf8 -FilePath .\installed_software.json Get-CimInstance -Namespace root\cimv2 -Class Win32_product | Select vendor, description, @{l='install_location';e='InstallLocation'}, @{l='install_date';e='InstallDate'}, @{l='install_date_2';e='InstallDate2'}, caption, version, name, @{l='sku_number';e='SKUNumber'} | ConvertTo-Json | Out-File -Encoding utf8 -FilePath .\installed_software.json
- python3 electron/build/profile_toolchain.py --output-json=out/Default/windows_toolchain_profile.json - python3 electron/build/profile_toolchain.py --output-json=out/Default/windows_toolchain_profile.json
- 7z a node_headers.zip out\Default\gen\node_headers - 7z a node_headers.zip out\Default\gen\node_headers
- 7z a nan.zip third_party\nan
- ps: >- - ps: >-
if ($env:GN_CONFIG -eq 'release') { if ($env:GN_CONFIG -eq 'release') {
# Needed for msdia140.dll on 64-bit windows # Needed for msdia140.dll on 64-bit windows
$env:Path += ";$pwd\third_party\llvm-build\Release+Asserts\bin" $env:Path += ";$pwd\third_party\llvm-build\Release+Asserts\bin"
autoninja -C out/Default electron:electron_symbols ninja -C out/Default electron:electron_symbols
} }
- ps: >- - ps: >-
if ($env:GN_CONFIG -eq 'release') { if ($env:GN_CONFIG -eq 'release') {
@@ -177,40 +175,7 @@ for:
# built on CI. # built on CI.
7z a pdb.zip out\Default\*.pdb 7z a pdb.zip out\Default\*.pdb
} }
- ps: | - python3 electron/script/zip_manifests/check-zip-manifest.py out/Default/dist.zip electron/script/zip_manifests/dist_zip.win.%TARGET_ARCH%.manifest
$manifest_file = "electron/script/zip_manifests/dist_zip.win.$env:TARGET_ARCH.manifest"
python3 electron/script/zip_manifests/check-zip-manifest.py out/Default/dist.zip $manifest_file
if ($LASTEXITCODE -ne 0) {
throw "Zip contains files not listed in the manifest $manifest_file"
}
- ps: |
cd C:\projects\src
$missing_artifacts = $false
if ($env:SHOULD_SKIP_ARTIFACT_VALIDATION -eq 'true') {
Write-warning "Skipping artifact validation for doc-only $env:APPVEYOR_PROJECT_NAME"
} else {
$artifacts_to_validate = 'dist.zip','windows_toolchain_profile.json','chromedriver.zip','ffmpeg.zip','node_headers.zip','mksnapshot.zip','electron.lib','hunspell_dictionaries.zip','nan.zip'
foreach($artifact_name in $artifacts_to_validate) {
if ($artifact_name -eq 'ffmpeg.zip') {
$artifact_file = "out\ffmpeg\ffmpeg.zip"
} elseif (
$artifact_name -eq 'node_headers.zip') {
$artifact_file = $artifact_name
} elseif (
$artifact_name -eq 'nan.zip') {
$artifact_file = $artifact_name
} else {
$artifact_file = "out\Default\$artifact_name"
}
if (-not(Test-Path $artifact_file)) {
Write-warning "$artifact_name is missing and cannot be added to artifacts"
$missing_artifacts = $true
}
}
}
if ($missing_artifacts) {
throw "Build failed due to missing artifacts"
}
deploy_script: deploy_script:
- cd electron - cd electron
@@ -230,13 +195,13 @@ for:
- cd C:\projects\src - cd C:\projects\src
- if exist out\Default\windows_toolchain_profile.json ( appveyor-retry appveyor PushArtifact out\Default\windows_toolchain_profile.json ) - if exist out\Default\windows_toolchain_profile.json ( appveyor-retry appveyor PushArtifact out\Default\windows_toolchain_profile.json )
- if exist out\Default\dist.zip (appveyor-retry appveyor PushArtifact out\Default\dist.zip) - if exist out\Default\dist.zip (appveyor-retry appveyor PushArtifact out\Default\dist.zip)
- if exist out\Default\shell_browser_ui_unittests.exe (appveyor-retry appveyor PushArtifact out\Default\shell_browser_ui_unittests.exe)
- if exist out\Default\chromedriver.zip (appveyor-retry appveyor PushArtifact out\Default\chromedriver.zip) - if exist out\Default\chromedriver.zip (appveyor-retry appveyor PushArtifact out\Default\chromedriver.zip)
- if exist out\ffmpeg\ffmpeg.zip (appveyor-retry appveyor PushArtifact out\ffmpeg\ffmpeg.zip) - if exist out\ffmpeg\ffmpeg.zip (appveyor-retry appveyor PushArtifact out\ffmpeg\ffmpeg.zip)
- if exist node_headers.zip (appveyor-retry appveyor PushArtifact node_headers.zip) - if exist node_headers.zip (appveyor-retry appveyor PushArtifact node_headers.zip)
- if exist nan.zip (appveyor-retry appveyor PushArtifact nan.zip)
- if exist out\Default\mksnapshot.zip (appveyor-retry appveyor PushArtifact out\Default\mksnapshot.zip) - if exist out\Default\mksnapshot.zip (appveyor-retry appveyor PushArtifact out\Default\mksnapshot.zip)
- if exist out\Default\hunspell_dictionaries.zip (appveyor-retry appveyor PushArtifact out\Default\hunspell_dictionaries.zip) - if exist out\Default\hunspell_dictionaries.zip (appveyor-retry appveyor PushArtifact out\Default\hunspell_dictionaries.zip)
- if exist out\Default\electron.lib (appveyor-retry appveyor PushArtifact out\Default\electron.lib) - if exist out\Default\electron.lib (appveyor-retry appveyor PushArtifact out\Default\electron.lib)
- ps: >- - ps: >-
if ((Test-Path "pdb.zip") -And ($env:GN_CONFIG -ne 'release')) { if ((Test-Path "pdb.zip") -And ($env:GN_CONFIG -ne 'release')) {
appveyor-retry appveyor PushArtifact pdb.zip appveyor-retry appveyor PushArtifact pdb.zip
@@ -255,13 +220,11 @@ for:
build_script: build_script:
- ps: | - ps: |
node script/yarn.js install --frozen-lockfile node script/yarn.js install --frozen-lockfile
node script/doc-only-change.js --prNumber=$env:APPVEYOR_PULL_REQUEST_NUMBER node script/doc-only-change.js --prNumber=$env:APPVEYOR_PULL_REQUEST_NUMBER --prBranch=$env:APPVEYOR_REPO_BRANCH
if ($LASTEXITCODE -eq 0) { if ($LASTEXITCODE -eq 0) {
Write-warning "Skipping build for doc only change" Write-warning "Skipping build for doc only change"; Exit-AppveyorBuild
Exit-AppveyorBuild
} else {
$global:LASTEXITCODE = 0
} }
$global:LASTEXITCODE = 0
- cd .. - cd ..
- mkdir out\Default - mkdir out\Default
- cd .. - cd ..
@@ -269,31 +232,27 @@ for:
# Download build artifacts # Download build artifacts
$apiUrl = 'https://ci.appveyor.com/api' $apiUrl = 'https://ci.appveyor.com/api'
$build_info = Invoke-RestMethod -Method Get -Uri "$apiUrl/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/builds/$env:APPVEYOR_BUILD_ID" $build_info = Invoke-RestMethod -Method Get -Uri "$apiUrl/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/builds/$env:APPVEYOR_BUILD_ID"
$artifacts_to_download = @('dist.zip','ffmpeg.zip','node_headers.zip','electron.lib', 'nan.zip') $artifacts_to_download = @('dist.zip','ffmpeg.zip','node_headers.zip','pdb.zip','electron.lib')
foreach ($job in $build_info.build.jobs) { foreach ($job in $build_info.build.jobs) {
if ($job.name -eq "Build Arm on X64 Windows") { if ($job.name -eq "Build Arm on X64 Windows") {
$jobId = $job.jobId $jobId = $job.jobId
foreach($artifact_name in $artifacts_to_download) { foreach($artifact_name in $artifacts_to_download) {
if ($artifact_name -eq 'electron.lib') { if ($artifact_name -eq 'shell_browser_ui_unittests.exe' -Or $artifact_name -eq 'electron.lib') {
$outfile = "src\out\Default\$artifact_name" $outfile = "src\out\Default\$artifact_name"
} else { } else {
$outfile = $artifact_name $outfile = $artifact_name
} }
Invoke-RestMethod -Method Get -Uri "$apiUrl/buildjobs/$jobId/artifacts/$artifact_name" -OutFile $outfile Invoke-RestMethod -Method Get -Uri "$apiUrl/buildjobs/$jobId/artifacts/$artifact_name" -OutFile $outfile
} }
# Uncomment the following lines to download the pdb.zip to show real stacktraces when crashes happen during testing
# Invoke-RestMethod -Method Get -Uri "$apiUrl/buildjobs/$jobId/artifacts/pdb.zip" -OutFile pdb.zip
# 7z x -y -osrc pdb.zip
} }
} }
- ps: | - ps: |
$out_default_zips = @('dist.zip') $out_default_zips = @('dist.zip','pdb.zip')
foreach($zip_name in $out_default_zips) { foreach($zip_name in $out_default_zips) {
7z x -y -osrc\out\Default $zip_name 7z x -y -osrc\out\Default $zip_name
} }
- ps: 7z x -y -osrc\out\ffmpeg ffmpeg.zip - ps: 7z x -y -osrc\out\ffmpeg ffmpeg.zip
- ps: 7z x -y -osrc node_headers.zip - ps: 7z x -y -osrc node_headers.zip
- ps: 7z x -y -osrc nan.zip
test_script: test_script:
# Workaround for https://github.com/appveyor/ci/issues/2420 # Workaround for https://github.com/appveyor/ci/issues/2420
@@ -302,7 +261,7 @@ for:
cd src cd src
New-Item .\out\Default\gen\node_headers\Release -Type directory New-Item .\out\Default\gen\node_headers\Release -Type directory
Copy-Item -path .\out\Default\electron.lib -destination .\out\Default\gen\node_headers\Release\node.lib Copy-Item -path .\out\Default\electron.lib -destination .\out\Default\gen\node_headers\Release\node.lib
- set npm_config_nodedir=%cd%\out\Default\gen\node_headers - set npm_config_nodedir=%cd%\out\Default\gen\node_headers
- set npm_config_arch=arm64 - set npm_config_arch=arm64
- cd electron - cd electron
# Explicitly set npm_config_arch because the .env doesn't persist # Explicitly set npm_config_arch because the .env doesn't persist
@@ -313,8 +272,8 @@ for:
- echo Running main test suite & node script/yarn test --runners=main --enable-logging --disable-features=CalculateNativeWinOcclusion - echo Running main test suite & node script/yarn test --runners=main --enable-logging --disable-features=CalculateNativeWinOcclusion
- cd .. - cd ..
- echo Verifying non proprietary ffmpeg & python electron\script\verify-ffmpeg.py --build-dir out\Default --source-root %cd% --ffmpeg-path out\ffmpeg - echo Verifying non proprietary ffmpeg & python electron\script\verify-ffmpeg.py --build-dir out\Default --source-root %cd% --ffmpeg-path out\ffmpeg
on_finish: on_finish:
# Uncomment these lines to enable RDP # Uncomment these lines to enable RDP
# - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) # - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
- if exist electron\electron.log ( appveyor-retry appveyor PushArtifact electron\electron.log ) - if exist electron\electron.log ( appveyor-retry appveyor PushArtifact electron\electron.log )

View File

@@ -1,18 +1,18 @@
# NOTE IF CHANGING THIS FILE, ALSO APPLY THE CHANGE TO appveyor-woa.yml # NOTE IF CHANGING THIS FILE, ALSO APPLY THE CHANGE TO appveyor-woa.yml
# IF APPLICABLE!!!! # IF APPLICABLE!!!!
# #
# #
# The config expects the following environment variables to be set: # The config expects the following environment variables to be set:
# - "GN_CONFIG" Build type. One of {'testing', 'release'}. # - "GN_CONFIG" Build type. One of {'testing', 'release'}.
# - "GN_EXTRA_ARGS" Additional gn arguments for a build config, # - "GN_EXTRA_ARGS" Additional gn arguments for a build config,
# e.g. 'target_cpu="x86"' to build for a 32bit platform. # e.g. 'target_cpu="x86"' to build for a 32bit platform.
# https://gn.googlesource.com/gn/+/main/docs/reference.md#var_target_cpu # https://gn.googlesource.com/gn/+/master/docs/reference.md#target_cpu
# Don't forget to set up "NPM_CONFIG_ARCH" and "TARGET_ARCH" accordingly # Don't forget to set up "NPM_CONFIG_ARCH" and "TARGET_ARCH" accordingly
# if you pass a custom value for 'target_cpu'. # if you pass a custom value for 'target_cpu'.
# - "ELECTRON_RELEASE" Set it to '1' upload binaries on success. # - "ELECTRON_RELEASE" Set it to '1' upload binaries on success.
# - "NPM_CONFIG_ARCH" E.g. 'x86'. Is used to build native Node.js modules. # - "NPM_CONFIG_ARCH" E.g. 'x86'. Is used to build native Node.js modules.
# Must match 'target_cpu' passed to "GN_EXTRA_ARGS" and "TARGET_ARCH" value. # Must match 'target_cpu' passed to "GN_EXTRA_ARGS" and "TARGET_ARCH" value.
# - "TARGET_ARCH" Choose from {'ia32', 'x64', 'arm', 'arm64'}. # - "TARGET_ARCH" Choose from {'ia32', 'x64', 'arm', 'arm64', 'mips64el'}.
# Is used in some publishing scripts, but does NOT affect the Electron binary. # Is used in some publishing scripts, but does NOT affect the Electron binary.
# Must match 'target_cpu' passed to "GN_EXTRA_ARGS" and "NPM_CONFIG_ARCH" value. # Must match 'target_cpu' passed to "GN_EXTRA_ARGS" and "NPM_CONFIG_ARCH" value.
# - "UPLOAD_TO_STORAGE" Set it to '1' upload a release to the Azure bucket. # - "UPLOAD_TO_STORAGE" Set it to '1' upload a release to the Azure bucket.
@@ -29,17 +29,16 @@
version: 1.0.{build} version: 1.0.{build}
build_cloud: electronhq-16-core build_cloud: electronhq-16-core
image: e-121.0.6116.0 image: e-110.0.5478.5
environment: environment:
GIT_CACHE_PATH: C:\Users\appveyor\libcc_cache GIT_CACHE_PATH: C:\Users\appveyor\libcc_cache
ELECTRON_OUT_DIR: Default ELECTRON_OUT_DIR: Default
ELECTRON_ENABLE_STACK_DUMPING: 1 ELECTRON_ENABLE_STACK_DUMPING: 1
ELECTRON_ALSO_LOG_TO_STDERR: 1 ELECTRON_ALSO_LOG_TO_STDERR: 1
MOCHA_REPORTER: mocha-multi-reporters MOCHA_REPORTER: mocha-multi-reporters
MOCHA_MULTI_REPORTERS: "@marshallofsound/mocha-appveyor-reporter, tap" MOCHA_MULTI_REPORTERS: mocha-appveyor-reporter, tap
DEPOT_TOOLS_WIN_TOOLCHAIN: 1 GOMA_FALLBACK_ON_AUTH_FAILURE: true
DEPOT_TOOLS_WIN_TOOLCHAIN_BASE_URL: "https://dev-cdn.electronjs.org/windows-toolchains/_" DEPOT_TOOLS_WIN_TOOLCHAIN: 0
GYP_MSVS_HASH_27370823e7: 28622d16b1
PYTHONIOENCODING: UTF-8 PYTHONIOENCODING: UTF-8
matrix: matrix:
@@ -48,11 +47,6 @@ environment:
- job_name: Test - job_name: Test
job_depends_on: Build job_depends_on: Build
clone_script:
- ps: git clone -q $("--branch=" + $Env:APPVEYOR_REPO_BRANCH) $("https://github.com/" + $Env:APPVEYOR_REPO_NAME + ".git") $Env:APPVEYOR_BUILD_FOLDER
- ps: if (!$Env:APPVEYOR_PULL_REQUEST_NUMBER) {$("git checkout -qf " + $Env:APPVEYOR_REPO_COMMIT)}
- ps: if ($Env:APPVEYOR_PULL_REQUEST_NUMBER) {git fetch -q origin +refs/pull/$($Env:APPVEYOR_PULL_REQUEST_NUMBER)/head; git checkout -qf FETCH_HEAD}
clone_folder: C:\projects\src\electron clone_folder: C:\projects\src\electron
skip_branch_with_pr: true skip_branch_with_pr: true
@@ -70,15 +64,11 @@ for:
build_script: build_script:
- ps: | - ps: |
node script/yarn.js install --frozen-lockfile node script/yarn.js install --frozen-lockfile
node script/doc-only-change.js --prNumber=$env:APPVEYOR_PULL_REQUEST_NUMBER node script/doc-only-change.js --prNumber=$env:APPVEYOR_PULL_REQUEST_NUMBER --prBranch=$env:APPVEYOR_REPO_BRANCH
$env:SHOULD_SKIP_ARTIFACT_VALIDATION = "false"
if ($LASTEXITCODE -eq 0) { if ($LASTEXITCODE -eq 0) {
Write-warning "Skipping build for doc-only change" Write-warning "Skipping build for doc only change"; Exit-AppveyorBuild
$env:SHOULD_SKIP_ARTIFACT_VALIDATION = "true"
Exit-AppveyorBuild
} else {
$global:LASTEXITCODE = 0
} }
$global:LASTEXITCODE = 0
- cd .. - cd ..
- ps: Write-Host "Building $env:GN_CONFIG build" - ps: Write-Host "Building $env:GN_CONFIG build"
- git config --global core.longpaths true - git config --global core.longpaths true
@@ -90,37 +80,44 @@ for:
if (Test-Path -Path "$pwd\build-tools") { if (Test-Path -Path "$pwd\build-tools") {
Remove-Item -Recurse -Force $pwd\build-tools Remove-Item -Recurse -Force $pwd\build-tools
} }
- git clone --depth=1 https://chromium.googlesource.com/chromium/tools/depot_tools.git - ps: git clone --depth=1 https://chromium.googlesource.com/chromium/tools/depot_tools.git
- ps: New-Item -Name depot_tools\.disable_auto_update -ItemType File
- depot_tools\bootstrap\win_tools.bat
- ps: $env:PATH="$pwd\depot_tools;$env:PATH" - ps: $env:PATH="$pwd\depot_tools;$env:PATH"
- ps: >- - ps: >-
if (Test-Path -Path "$pwd\src\electron") { if (Test-Path -Path "$pwd\src\electron") {
Remove-Item -Recurse -Force $pwd\src\electron Remove-Item -Recurse -Force $pwd\src\electron
} }
- ps: >-
if (Test-Path 'env:RAW_GOMA_AUTH') {
$env:GOMA_OAUTH2_CONFIG_FILE = "$pwd\.goma_oauth2_config"
$env:RAW_GOMA_AUTH | Set-Content $env:GOMA_OAUTH2_CONFIG_FILE
}
- git clone https://github.com/electron/build-tools.git - git clone https://github.com/electron/build-tools.git
- cd build-tools - cd build-tools
- npx yarn --ignore-engines - npm install
- mkdir third_party - mkdir third_party
- ps: >- - ps: >-
node -e "require('./src/utils/reclient.js').downloadAndPrepare({})" node -e "require('./src/utils/goma.js').downloadAndPrepare({ gomaOneForAll: true })"
- ps: $env:RECLIENT_HELPER = node -p "require('./src/utils/reclient.js').helperPath({})" - ps: $env:GN_GOMA_FILE = node -e "console.log(require('./src/utils/goma.js').gnFilePath)"
- ps: >- - ps: $env:LOCAL_GOMA_DIR = node -e "console.log(require('./src/utils/goma.js').dir)"
& $env:RECLIENT_HELPER login
- ps: >-
$env:RBE_service = node -e "console.log(require('./src/utils/reclient.js').serviceAddress)"
- ps: >-
$env:RBE_experimental_credentials_helper = $env:RECLIENT_HELPER
- ps: >-
$env:RBE_experimental_credentials_helper_args = "print"
- cd ..\.. - cd ..\..
- ps: .\src\electron\script\start-goma.ps1 -gomaDir $env:LOCAL_GOMA_DIR
- ps: >-
if (Test-Path 'env:RAW_GOMA_AUTH') {
$goma_login = python $env:LOCAL_GOMA_DIR\goma_auth.py info
if ($goma_login -eq 'Login as Fermi Planck') {
Write-warning "Goma authentication is correct";
} else {
Write-warning "WARNING!!!!!! Goma authentication is incorrect; please update Goma auth token.";
$host.SetShouldExit(1)
}
}
- ps: $env:CHROMIUM_BUILDTOOLS_PATH="$pwd\src\buildtools" - ps: $env:CHROMIUM_BUILDTOOLS_PATH="$pwd\src\buildtools"
- ps: >- - ps: >-
if ($env:GN_CONFIG -ne 'release') { if ($env:GN_CONFIG -ne 'release') {
$env:NINJA_STATUS="[%r processes, %f/%t @ %o/s : %es] " $env:NINJA_STATUS="[%r processes, %f/%t @ %o/s : %es] "
} }
- gclient config --name "src\electron" --unmanaged %GCLIENT_EXTRA_ARGS% "https://github.com/electron/electron" - gclient config --name "src\electron" --unmanaged %GCLIENT_EXTRA_ARGS% "https://github.com/electron/electron"
# Patches are applied in the image bake. Check depshash to see if patches have changed. # Patches are applied in the image bake. Check depshash to see if patches have changed.
- ps: $env:RUN_GCLIENT_SYNC="false" - ps: $env:RUN_GCLIENT_SYNC="false"
- ps: $depshash_baked = Get-Content .\src\.depshash -Raw - ps: $depshash_baked = Get-Content .\src\.depshash -Raw
- ps: cd src\electron - ps: cd src\electron
@@ -135,26 +132,28 @@ for:
- cd src - cd src
- ps: $env:PATH="$pwd\third_party\ninja;$env:PATH" - ps: $env:PATH="$pwd\third_party\ninja;$env:PATH"
- set BUILD_CONFIG_PATH=//electron/build/args/%GN_CONFIG%.gn - set BUILD_CONFIG_PATH=//electron/build/args/%GN_CONFIG%.gn
- gn gen out/Default "--args=import(\"%BUILD_CONFIG_PATH%\") use_remoteexec=true %GN_EXTRA_ARGS% " - gn gen out/Default "--args=import(\"%BUILD_CONFIG_PATH%\") import(\"%GN_GOMA_FILE%\") %GN_EXTRA_ARGS% "
- gn check out/Default //electron:electron_lib - gn check out/Default //electron:electron_lib
- gn check out/Default //electron:electron_app - gn check out/Default //electron:electron_app
- gn check out/Default //electron/shell/common/api:mojo - gn check out/Default //electron/shell/common/api:mojo
- if DEFINED ELECTRON_RBE_JWT (autoninja -j 300 -C out/Default electron:electron_app) else (autoninja -C out/Default electron:electron_app) - if DEFINED GN_GOMA_FILE (ninja -j 300 -C out/Default electron:electron_app) else (ninja -C out/Default electron:electron_app)
- if "%GN_CONFIG%"=="testing" ( python C:\depot_tools\post_build_ninja_summary.py -C out\Default ) - if "%GN_CONFIG%"=="testing" ( python C:\depot_tools\post_build_ninja_summary.py -C out\Default )
- gn gen out/ffmpeg "--args=import(\"//electron/build/args/ffmpeg.gn\") use_remoteexec=true %GN_EXTRA_ARGS%" - gn gen out/ffmpeg "--args=import(\"//electron/build/args/ffmpeg.gn\") %GN_EXTRA_ARGS%"
- autoninja -C out/ffmpeg electron:electron_ffmpeg_zip - ninja -C out/ffmpeg electron:electron_ffmpeg_zip
- autoninja -C out/Default electron:electron_dist_zip - ninja -C out/Default electron:electron_dist_zip
- ninja -C out/Default shell_browser_ui_unittests
- gn desc out/Default v8:run_mksnapshot_default args > out/Default/default_mksnapshot_args - gn desc out/Default v8:run_mksnapshot_default args > out/Default/default_mksnapshot_args
# Remove unused args from mksnapshot_args # Remove unused args from mksnapshot_args
- ps: >- - ps: >-
Get-Content out/Default/default_mksnapshot_args | Where-Object { -not $_.Contains('--turbo-profiling-input') -And -not $_.Contains('builtins-pgo') -And -not $_.Contains('The gn arg use_goma=true') } | Set-Content out/Default/mksnapshot_args Get-Content out/Default/default_mksnapshot_args | Where-Object { -not $_.Contains('--turbo-profiling-input') -And -not $_.Contains('builtins-pgo') } | Set-Content out/Default/mksnapshot_args
- autoninja -C out/Default electron:electron_mksnapshot_zip - ninja -C out/Default electron:electron_mksnapshot_zip
- cd out\Default - cd out\Default
- 7z a mksnapshot.zip mksnapshot_args gen\v8\embedded.S - 7z a mksnapshot.zip mksnapshot_args gen\v8\embedded.S
- cd ..\.. - cd ..\..
- autoninja -C out/Default electron:hunspell_dictionaries_zip - ninja -C out/Default electron:hunspell_dictionaries_zip
- autoninja -C out/Default electron:electron_chromedriver_zip - ninja -C out/Default electron:electron_chromedriver_zip
- autoninja -C out/Default electron:node_headers - ninja -C out/Default third_party/electron_node:headers
- python %LOCAL_GOMA_DIR%\goma_ctl.py stat
- ps: >- - ps: >-
Get-CimInstance -Namespace root\cimv2 -Class Win32_product | Select vendor, description, @{l='install_location';e='InstallLocation'}, @{l='install_date';e='InstallDate'}, @{l='install_date_2';e='InstallDate2'}, caption, version, name, @{l='sku_number';e='SKUNumber'} | ConvertTo-Json | Out-File -Encoding utf8 -FilePath .\installed_software.json Get-CimInstance -Namespace root\cimv2 -Class Win32_product | Select vendor, description, @{l='install_location';e='InstallLocation'}, @{l='install_date';e='InstallDate'}, @{l='install_date_2';e='InstallDate2'}, caption, version, name, @{l='sku_number';e='SKUNumber'} | ConvertTo-Json | Out-File -Encoding utf8 -FilePath .\installed_software.json
- python3 electron/build/profile_toolchain.py --output-json=out/Default/windows_toolchain_profile.json - python3 electron/build/profile_toolchain.py --output-json=out/Default/windows_toolchain_profile.json
@@ -163,7 +162,7 @@ for:
if ($env:GN_CONFIG -eq 'release') { if ($env:GN_CONFIG -eq 'release') {
# Needed for msdia140.dll on 64-bit windows # Needed for msdia140.dll on 64-bit windows
$env:Path += ";$pwd\third_party\llvm-build\Release+Asserts\bin" $env:Path += ";$pwd\third_party\llvm-build\Release+Asserts\bin"
autoninja -C out/Default electron:electron_symbols ninja -C out/Default electron:electron_symbols
} }
- ps: >- - ps: >-
if ($env:GN_CONFIG -eq 'release') { if ($env:GN_CONFIG -eq 'release') {
@@ -174,37 +173,7 @@ for:
# built on CI. # built on CI.
7z a pdb.zip out\Default\*.pdb 7z a pdb.zip out\Default\*.pdb
} }
- ps: | - python3 electron/script/zip_manifests/check-zip-manifest.py out/Default/dist.zip electron/script/zip_manifests/dist_zip.win.%TARGET_ARCH%.manifest
$manifest_file = "electron/script/zip_manifests/dist_zip.win.$env:TARGET_ARCH.manifest"
python3 electron/script/zip_manifests/check-zip-manifest.py out/Default/dist.zip $manifest_file
if ($LASTEXITCODE -ne 0) {
throw "Zip contains files not listed in the manifest $manifest_file"
}
- ps: |
cd C:\projects\src
$missing_artifacts = $false
if ($env:SHOULD_SKIP_ARTIFACT_VALIDATION -eq 'true') {
Write-warning "Skipping artifact validation for doc-only $env:APPVEYOR_PROJECT_NAME"
} else {
$artifacts_to_validate = 'dist.zip','windows_toolchain_profile.json','chromedriver.zip','ffmpeg.zip','node_headers.zip','mksnapshot.zip','electron.lib','hunspell_dictionaries.zip'
foreach($artifact_name in $artifacts_to_validate) {
if ($artifact_name -eq 'ffmpeg.zip') {
$artifact_file = "out\ffmpeg\ffmpeg.zip"
} elseif (
$artifact_name -eq 'node_headers.zip') {
$artifact_file = $artifact_name
} else {
$artifact_file = "out\Default\$artifact_name"
}
if (-not(Test-Path $artifact_file)) {
Write-warning "$artifact_name is missing and cannot be added to artifacts"
$missing_artifacts = $true
}
}
}
if ($missing_artifacts) {
throw "Build failed due to missing artifacts"
}
deploy_script: deploy_script:
- cd electron - cd electron
@@ -224,12 +193,13 @@ for:
- cd C:\projects\src - cd C:\projects\src
- if exist out\Default\windows_toolchain_profile.json ( appveyor-retry appveyor PushArtifact out\Default\windows_toolchain_profile.json ) - if exist out\Default\windows_toolchain_profile.json ( appveyor-retry appveyor PushArtifact out\Default\windows_toolchain_profile.json )
- if exist out\Default\dist.zip (appveyor-retry appveyor PushArtifact out\Default\dist.zip) - if exist out\Default\dist.zip (appveyor-retry appveyor PushArtifact out\Default\dist.zip)
- if exist out\Default\shell_browser_ui_unittests.exe (appveyor-retry appveyor PushArtifact out\Default\shell_browser_ui_unittests.exe)
- if exist out\Default\chromedriver.zip (appveyor-retry appveyor PushArtifact out\Default\chromedriver.zip) - if exist out\Default\chromedriver.zip (appveyor-retry appveyor PushArtifact out\Default\chromedriver.zip)
- if exist out\ffmpeg\ffmpeg.zip (appveyor-retry appveyor PushArtifact out\ffmpeg\ffmpeg.zip) - if exist out\ffmpeg\ffmpeg.zip (appveyor-retry appveyor PushArtifact out\ffmpeg\ffmpeg.zip)
- if exist node_headers.zip (appveyor-retry appveyor PushArtifact node_headers.zip) - if exist node_headers.zip (appveyor-retry appveyor PushArtifact node_headers.zip)
- if exist out\Default\mksnapshot.zip (appveyor-retry appveyor PushArtifact out\Default\mksnapshot.zip) - if exist out\Default\mksnapshot.zip (appveyor-retry appveyor PushArtifact out\Default\mksnapshot.zip)
- if exist out\Default\hunspell_dictionaries.zip (appveyor-retry appveyor PushArtifact out\Default\hunspell_dictionaries.zip) - if exist out\Default\hunspell_dictionaries.zip (appveyor-retry appveyor PushArtifact out\Default\hunspell_dictionaries.zip)
- if exist out\Default\electron.lib (appveyor-retry appveyor PushArtifact out\Default\electron.lib) - if exist out\Default\electron.lib (appveyor-retry appveyor PushArtifact out\Default\electron.lib)
- ps: >- - ps: >-
if ((Test-Path "pdb.zip") -And ($env:GN_CONFIG -ne 'release')) { if ((Test-Path "pdb.zip") -And ($env:GN_CONFIG -ne 'release')) {
appveyor-retry appveyor PushArtifact pdb.zip appveyor-retry appveyor PushArtifact pdb.zip
@@ -246,13 +216,11 @@ for:
build_script: build_script:
- ps: | - ps: |
node script/yarn.js install --frozen-lockfile node script/yarn.js install --frozen-lockfile
node script/doc-only-change.js --prNumber=$env:APPVEYOR_PULL_REQUEST_NUMBER node script/doc-only-change.js --prNumber=$env:APPVEYOR_PULL_REQUEST_NUMBER --prBranch=$env:APPVEYOR_REPO_BRANCH
if ($LASTEXITCODE -eq 0) { if ($LASTEXITCODE -eq 0) {
Write-warning "Skipping build for doc only change" Write-warning "Skipping build for doc only change"; Exit-AppveyorBuild
Exit-AppveyorBuild
} else {
$global:LASTEXITCODE = 0
} }
$global:LASTEXITCODE = 0
- cd .. - cd ..
- mkdir out\Default - mkdir out\Default
- cd .. - cd ..
@@ -260,21 +228,18 @@ for:
# Download build artifacts # Download build artifacts
$apiUrl = 'https://ci.appveyor.com/api' $apiUrl = 'https://ci.appveyor.com/api'
$build_info = Invoke-RestMethod -Method Get -Uri "$apiUrl/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/builds/$env:APPVEYOR_BUILD_ID" $build_info = Invoke-RestMethod -Method Get -Uri "$apiUrl/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/builds/$env:APPVEYOR_BUILD_ID"
$artifacts_to_download = @('dist.zip','chromedriver.zip','ffmpeg.zip','node_headers.zip','mksnapshot.zip','electron.lib') $artifacts_to_download = @('dist.zip','shell_browser_ui_unittests.exe','chromedriver.zip','ffmpeg.zip','node_headers.zip','mksnapshot.zip','electron.lib')
foreach ($job in $build_info.build.jobs) { foreach ($job in $build_info.build.jobs) {
if ($job.name -eq "Build") { if ($job.name -eq "Build") {
$jobId = $job.jobId $jobId = $job.jobId
foreach($artifact_name in $artifacts_to_download) { foreach($artifact_name in $artifacts_to_download) {
if ($artifact_name -eq 'electron.lib') { if ($artifact_name -eq 'shell_browser_ui_unittests.exe' -Or $artifact_name -eq 'electron.lib') {
$outfile = "src\out\Default\$artifact_name" $outfile = "src\out\Default\$artifact_name"
} else { } else {
$outfile = $artifact_name $outfile = $artifact_name
} }
Invoke-RestMethod -Method Get -Uri "$apiUrl/buildjobs/$jobId/artifacts/$artifact_name" -OutFile $outfile Invoke-RestMethod -Method Get -Uri "$apiUrl/buildjobs/$jobId/artifacts/$artifact_name" -OutFile $outfile
} }
# Uncomment the following lines to download the pdb.zip to show real stacktraces when crashes happen during testing
# Invoke-RestMethod -Method Get -Uri "$apiUrl/buildjobs/$jobId/artifacts/pdb.zip" -OutFile pdb.zip
# 7z x -y -osrc pdb.zip
} }
} }
- ps: | - ps: |
@@ -299,6 +264,7 @@ for:
$env:npm_config_arch = "ia32" $env:npm_config_arch = "ia32"
} }
- echo Running main test suite & node script/yarn test -- --trace-uncaught --runners=main --enable-logging=file --log-file=%cd%\electron.log - echo Running main test suite & node script/yarn test -- --trace-uncaught --runners=main --enable-logging=file --log-file=%cd%\electron.log
- echo Running native test suite & node script/yarn test -- --trace-uncaught --runners=native --enable-logging=file --log-file=%cd%\electron.log
- cd .. - cd ..
- echo Verifying non proprietary ffmpeg & python electron\script\verify-ffmpeg.py --build-dir out\Default --source-root %cd% --ffmpeg-path out\ffmpeg - echo Verifying non proprietary ffmpeg & python electron\script\verify-ffmpeg.py --build-dir out\Default --source-root %cd% --ffmpeg-path out\ffmpeg
- echo "About to verify mksnapshot" - echo "About to verify mksnapshot"
@@ -306,8 +272,8 @@ for:
- echo "Done verifying mksnapshot" - echo "Done verifying mksnapshot"
- echo Verifying chromedriver & python electron\script\verify-chromedriver.py --build-dir out\Default --source-root %cd% - echo Verifying chromedriver & python electron\script\verify-chromedriver.py --build-dir out\Default --source-root %cd%
- echo "Done verifying chromedriver" - echo "Done verifying chromedriver"
on_finish: on_finish:
# Uncomment these lines to enable RDP # Uncomment these lines to enable RDP
# - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) # - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
- if exist electron\electron.log ( appveyor-retry appveyor PushArtifact electron\electron.log ) - if exist electron\electron.log ( appveyor-retry appveyor PushArtifact electron\electron.log )

View File

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

View File

@@ -1,8 +1,8 @@
is_electron_build = true is_electron_build = true
root_extra_deps = [ "//electron" ] root_extra_deps = [ "//electron" ]
# Registry of NMVs --> https://github.com/nodejs/node/blob/main/doc/abi_version_registry.json # Registry of NMVs --> https://github.com/nodejs/node/blob/master/doc/abi_version_registry.json
node_module_version = 121 node_module_version = 113
v8_promise_internal_field_count = 1 v8_promise_internal_field_count = 1
v8_embedder_string = "-electron.0" v8_embedder_string = "-electron.0"
@@ -10,6 +10,9 @@ v8_embedder_string = "-electron.0"
# TODO: this breaks mksnapshot # TODO: this breaks mksnapshot
v8_enable_snapshot_native_code_counters = false v8_enable_snapshot_native_code_counters = false
# TODO(codebytere): remove when Node.js handles https://chromium-review.googlesource.com/c/v8/v8/+/3211575
v8_scriptormodule_legacy_lifetime = true
# we use this api # we use this api
v8_enable_javascript_promise_hooks = true v8_enable_javascript_promise_hooks = true
@@ -24,10 +27,6 @@ enable_printing = true
angle_enable_vulkan_validation_layers = false angle_enable_vulkan_validation_layers = false
dawn_enable_vulkan_validation_layers = false dawn_enable_vulkan_validation_layers = false
# Removes dxc dll's that are only used experimentally.
# See https://bugs.chromium.org/p/chromium/issues/detail?id=1474897
dawn_use_built_dxc = false
# These are disabled because they cause the zip manifest to differ between # These are disabled because they cause the zip manifest to differ between
# testing and release builds. # testing and release builds.
# See https://chromium-review.googlesource.com/c/chromium/src/+/2774898. # See https://chromium-review.googlesource.com/c/chromium/src/+/2774898.
@@ -49,21 +48,3 @@ is_cfi = false
# TODO: fix this once sysroots have been updated. # TODO: fix this once sysroots have been updated.
use_qt = false use_qt = false
# https://chromium-review.googlesource.com/c/chromium/src/+/4365718
# TODO(codebytere): fix perfetto incompatibility with Node.js.
use_perfetto_client_library = false
# Disables the builtins PGO for V8
v8_builtins_profiling_log_file = ""
# https://chromium.googlesource.com/chromium/src/+/main/docs/dangling_ptr.md
# TODO(vertedinde): hunt down dangling pointers on Linux
enable_dangling_raw_ptr_checks = false
# This flag speeds up the performance of fork/execve on linux systems.
# Ref: https://chromium-review.googlesource.com/c/v8/v8/+/4602858
v8_enable_private_mapping_fork_optimization = true
# Expose public V8 symbols for native modules.
v8_expose_public_symbols = true

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python3 from __future__ import print_function
import collections import collections
import os import os

View File

@@ -0,0 +1,8 @@
import os
import shutil
import sys
if os.path.exists(sys.argv[2]):
os.remove(sys.argv[2])
shutil.copy(sys.argv[1], sys.argv[2])

View File

@@ -32,13 +32,6 @@ extern const volatile char kFuseWire[];
TEMPLATE_CC = """ TEMPLATE_CC = """
#include "electron/fuses.h" #include "electron/fuses.h"
#include "base/dcheck_is_on.h"
#if DCHECK_IS_ON()
#include "base/command_line.h"
#include "base/strings/string_util.h"
#include <string>
#endif
namespace electron::fuses { namespace electron::fuses {
@@ -73,20 +66,9 @@ for fuse in fuses:
getters_h += "FUSE_EXPORT bool Is{name}Enabled();\n".replace("{name}", name) getters_h += "FUSE_EXPORT bool Is{name}Enabled();\n".replace("{name}", name)
getters_cc += """ getters_cc += """
bool Is{name}Enabled() { bool Is{name}Enabled() {
#if DCHECK_IS_ON()
// RunAsNode is checked so early that base::CommandLine isn't yet
// initialized, so guard here to avoid a CHECK.
if (base::CommandLine::InitializedForCurrentProcess()) {
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
if (command_line->HasSwitch("{switch_name}")) {
std::string switch_value = command_line->GetSwitchValueASCII("{switch_name}");
return switch_value == "1";
}
}
#endif
return kFuseWire[{index}] == '1'; return kFuseWire[{index}] == '1';
} }
""".replace("{name}", name).replace("{switch_name}", f"set-fuse-{fuse.lower()}").replace("{index}", str(index)) """.replace("{name}", name).replace("{index}", str(index))
def c_hex(n): def c_hex(n):
s = hex(n)[2:] s = hex(n)[2:]

View File

@@ -8,6 +8,5 @@
"node_cli_inspect": "1", "node_cli_inspect": "1",
"embedded_asar_integrity_validation": "0", "embedded_asar_integrity_validation": "0",
"only_load_app_from_asar": "0", "only_load_app_from_asar": "0",
"load_browser_process_specific_v8_snapshot": "0", "load_browser_process_specific_v8_snapshot": "0"
"grant_file_protocol_extra_privileges": "1"
} }

View File

@@ -4,7 +4,7 @@ import sys
DEFINE_EXTRACT_REGEX = re.compile('^ *# *define (\w*)', re.MULTILINE) DEFINE_EXTRACT_REGEX = re.compile('^ *# *define (\w*)', re.MULTILINE)
def main(out_dir, headers): def main(outDir, headers):
defines = [] defines = []
for filename in headers: for filename in headers:
with open(filename, 'r') as f: with open(filename, 'r') as f:
@@ -15,13 +15,13 @@ def main(out_dir, headers):
for define in defines: for define in defines:
push_and_undef += '#pragma push_macro("%s")\n' % define push_and_undef += '#pragma push_macro("%s")\n' % define
push_and_undef += '#undef %s\n' % define push_and_undef += '#undef %s\n' % define
with open(os.path.join(out_dir, 'push_and_undef_node_defines.h'), 'w') as o: with open(os.path.join(outDir, 'push_and_undef_node_defines.h'), 'w') as o:
o.write(push_and_undef) o.write(push_and_undef)
pop = '' pop = ''
for define in defines: for define in defines:
pop += '#pragma pop_macro("%s")\n' % define pop += '#pragma pop_macro("%s")\n' % define
with open(os.path.join(out_dir, 'pop_node_defines.h'), 'w') as o: with open(os.path.join(outDir, 'pop_node_defines.h'), 'w') as o:
o.write(pop) o.write(pop)
def read_defines(content): def read_defines(content):

32
build/js2c.py Normal file → Executable file
View File

@@ -4,14 +4,32 @@ import os
import subprocess import subprocess
import sys import sys
def main(): TEMPLATE = """
js2c = sys.argv[1] #include "node_native_module.h"
root = sys.argv[2] #include "node_internals.h"
natives = sys.argv[3]
js_source_files = sys.argv[4:]
namespace node::native_module {{
{definitions}
void NativeModuleLoader::LoadEmbedderJavaScriptSource() {{
{initializers}
}}
}} // namespace node::native_module
"""
def main():
node_path = os.path.abspath(sys.argv[1])
natives = os.path.abspath(sys.argv[2])
js_source_files = sys.argv[3:]
js2c = os.path.join(node_path, 'tools', 'js2c.py')
subprocess.check_call( subprocess.check_call(
[js2c, natives] + js_source_files + ['--only-js', "--root", root]) [sys.executable, js2c] +
js_source_files +
['--only-js', '--target', natives])
if __name__ == '__main__': if __name__ == '__main__':
sys.exit(main()) sys.exit(main())

View File

@@ -1,5 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
from __future__ import print_function
import os import os
import subprocess import subprocess
import sys import sys

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python3 from __future__ import unicode_literals
import contextlib import contextlib
import sys import sys

View File

@@ -1,11 +1,10 @@
import sys import sys
import os import os
import subprocess
def main(argv): def main(argv):
os.chdir(argv[1]) cwd = argv[1]
p = subprocess.Popen(argv[2:]) os.chdir(cwd)
return p.wait() os.execv(sys.executable, [sys.executable] + argv[2:])
if __name__ == '__main__': if __name__ == '__main__':
sys.exit(main(sys.argv)) main(sys.argv)

View File

@@ -0,0 +1,5 @@
module.exports = require('./webpack.config.base')({
target: 'asar',
alwaysHasNode: true,
targetDeletesNodeGlobals: true
});

View File

@@ -1,5 +1,5 @@
const fs = require('node:fs'); const fs = require('fs');
const path = require('node:path'); const path = require('path');
const webpack = require('webpack'); const webpack = require('webpack');
const TerserPlugin = require('terser-webpack-plugin'); const TerserPlugin = require('terser-webpack-plugin');
const WrapperPlugin = require('wrapper-webpack-plugin'); const WrapperPlugin = require('wrapper-webpack-plugin');
@@ -53,6 +53,14 @@ module.exports = ({
const ignoredModules = []; const ignoredModules = [];
if (defines.ENABLE_DESKTOP_CAPTURER === 'false') {
ignoredModules.push(
'@electron/internal/browser/desktop-capturer',
'@electron/internal/browser/api/desktop-capturer',
'@electron/internal/renderer/api/desktop-capturer'
);
}
if (defines.ENABLE_VIEWS_API === 'false') { if (defines.ENABLE_VIEWS_API === 'false') {
ignoredModules.push( ignoredModules.push(
'@electron/internal/browser/api/views/image-view.js' '@electron/internal/browser/api/views/image-view.js'

View File

@@ -1,4 +0,0 @@
module.exports = require('./webpack.config.base')({
target: 'node',
alwaysHasNode: true
});

View File

@@ -1,5 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
from __future__ import print_function
import os import os
import subprocess import subprocess
import sys import sys
@@ -10,13 +10,7 @@ EXTENSIONS_TO_SKIP = [
'.mojom.js', '.mojom.js',
'.mojom-lite.js', '.mojom-lite.js',
'.info', '.info',
'.m.js', '.m.js'
# These are only needed for Chromium tests we don't run. Listed in
# 'extensions' because the mksnapshot zip has these under a subdirectory, and
# the PATHS_TO_SKIP is checked with |startswith|.
'dbgcore.dll',
'dbghelp.dll',
] ]
PATHS_TO_SKIP = [ PATHS_TO_SKIP = [
@@ -40,7 +34,7 @@ PATHS_TO_SKIP = [
# Skip because these are outputs that we don't need. # Skip because these are outputs that we don't need.
'resources/inspector', 'resources/inspector',
'gen/third_party/devtools-frontend/src', 'gen/third_party/devtools-frontend/src',
'gen/ui/webui', 'gen/ui/webui'
] ]
def skip_path(dep, dist_zip, target_cpu): def skip_path(dep, dist_zip, target_cpu):

View File

@@ -1,5 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
from __future__ import print_function
import os import os
import subprocess import subprocess
import sys import sys
@@ -44,4 +44,4 @@ def main(argv):
z.write(object_file, os.path.relpath(object_file, base_path_libcxxabi)) z.write(object_file, os.path.relpath(object_file, base_path_libcxxabi))
if __name__ == '__main__': if __name__ == '__main__':
sys.exit(main(sys.argv[1:])) sys.exit(main(sys.argv[1:]))

View File

@@ -9,21 +9,16 @@ buildflag_header("buildflags") {
header = "buildflags.h" header = "buildflags.h"
flags = [ flags = [
"ENABLE_DESKTOP_CAPTURER=$enable_desktop_capturer",
"ENABLE_RUN_AS_NODE=$enable_run_as_node",
"ENABLE_OSR=$enable_osr",
"ENABLE_VIEWS_API=$enable_views_api", "ENABLE_VIEWS_API=$enable_views_api",
"ENABLE_PDF_VIEWER=$enable_pdf_viewer", "ENABLE_PDF_VIEWER=$enable_pdf_viewer",
"ENABLE_TTS=$enable_tts",
"ENABLE_COLOR_CHOOSER=$enable_color_chooser",
"ENABLE_ELECTRON_EXTENSIONS=$enable_electron_extensions", "ENABLE_ELECTRON_EXTENSIONS=$enable_electron_extensions",
"ENABLE_BUILTIN_SPELLCHECKER=$enable_builtin_spellchecker", "ENABLE_BUILTIN_SPELLCHECKER=$enable_builtin_spellchecker",
"ENABLE_PICTURE_IN_PICTURE=$enable_picture_in_picture",
"OVERRIDE_LOCATION_PROVIDER=$enable_fake_location_provider", "OVERRIDE_LOCATION_PROVIDER=$enable_fake_location_provider",
] ]
if (electron_vendor_version != "") {
result = string_split(electron_vendor_version, ":")
flags += [
"HAS_VENDOR_VERSION=true",
"VENDOR_VERSION_NAME=\"${result[0]}\"",
"VENDOR_VERSION_VALUE=\"${result[1]}\"",
]
} else {
flags += [ "HAS_VENDOR_VERSION=false" ]
}
} }

View File

@@ -3,10 +3,23 @@
# found in the LICENSE file. # found in the LICENSE file.
declare_args() { declare_args() {
enable_desktop_capturer = true
# Allow running Electron as a node binary.
enable_run_as_node = true
enable_osr = true
enable_views_api = true enable_views_api = true
enable_pdf_viewer = true enable_pdf_viewer = true
enable_tts = true
enable_color_chooser = true
enable_picture_in_picture = true
# Provide a fake location provider for mocking # Provide a fake location provider for mocking
# the geolocation responses. Disable it if you # the geolocation responses. Disable it if you
# need to test with chromium's location provider. # need to test with chromium's location provider.
@@ -18,15 +31,4 @@ declare_args() {
# Enable Spellchecker support # Enable Spellchecker support
enable_builtin_spellchecker = true enable_builtin_spellchecker = true
# The version of Electron.
# Packagers and vendor builders should set this in gn args to avoid running
# the script that reads git tag.
override_electron_version = ""
# Define an extra item that will show in process.versions, the value must
# be in the format of "key:value".
# Packagers and vendor builders can set this in gn args to attach extra info
# about the build in the binary.
electron_vendor_version = ""
} }

View File

@@ -31,42 +31,18 @@ static_library("chrome") {
"//chrome/browser/devtools/devtools_file_system_indexer.cc", "//chrome/browser/devtools/devtools_file_system_indexer.cc",
"//chrome/browser/devtools/devtools_file_system_indexer.h", "//chrome/browser/devtools/devtools_file_system_indexer.h",
"//chrome/browser/devtools/devtools_settings.h", "//chrome/browser/devtools/devtools_settings.h",
"//chrome/browser/devtools/visual_logging.cc",
"//chrome/browser/devtools/visual_logging.h",
"//chrome/browser/extensions/global_shortcut_listener.cc", "//chrome/browser/extensions/global_shortcut_listener.cc",
"//chrome/browser/extensions/global_shortcut_listener.h", "//chrome/browser/extensions/global_shortcut_listener.h",
"//chrome/browser/icon_loader.cc", "//chrome/browser/icon_loader.cc",
"//chrome/browser/icon_loader.h", "//chrome/browser/icon_loader.h",
"//chrome/browser/icon_manager.cc", "//chrome/browser/icon_manager.cc",
"//chrome/browser/icon_manager.h", "//chrome/browser/icon_manager.h",
"//chrome/browser/media/webrtc/desktop_capturer_wrapper.cc",
"//chrome/browser/media/webrtc/desktop_capturer_wrapper.h",
"//chrome/browser/media/webrtc/desktop_media_list.cc",
"//chrome/browser/media/webrtc/desktop_media_list.h",
"//chrome/browser/media/webrtc/desktop_media_list_base.cc",
"//chrome/browser/media/webrtc/desktop_media_list_base.h",
"//chrome/browser/media/webrtc/desktop_media_list_observer.h",
"//chrome/browser/media/webrtc/native_desktop_media_list.cc",
"//chrome/browser/media/webrtc/native_desktop_media_list.h",
"//chrome/browser/media/webrtc/thumbnail_capturer.cc",
"//chrome/browser/media/webrtc/thumbnail_capturer.h",
"//chrome/browser/media/webrtc/window_icon_util.h",
"//chrome/browser/net/chrome_mojo_proxy_resolver_factory.cc", "//chrome/browser/net/chrome_mojo_proxy_resolver_factory.cc",
"//chrome/browser/net/chrome_mojo_proxy_resolver_factory.h", "//chrome/browser/net/chrome_mojo_proxy_resolver_factory.h",
"//chrome/browser/net/proxy_config_monitor.cc", "//chrome/browser/net/proxy_config_monitor.cc",
"//chrome/browser/net/proxy_config_monitor.h", "//chrome/browser/net/proxy_config_monitor.h",
"//chrome/browser/net/proxy_service_factory.cc", "//chrome/browser/net/proxy_service_factory.cc",
"//chrome/browser/net/proxy_service_factory.h", "//chrome/browser/net/proxy_service_factory.h",
"//chrome/browser/picture_in_picture/picture_in_picture_bounds_cache.cc",
"//chrome/browser/picture_in_picture/picture_in_picture_bounds_cache.h",
"//chrome/browser/picture_in_picture/picture_in_picture_occlusion_tracker.cc",
"//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_window_manager.cc",
"//chrome/browser/picture_in_picture/picture_in_picture_window_manager.h",
"//chrome/browser/picture_in_picture/scoped_picture_in_picture_occlusion_observation.cc",
"//chrome/browser/picture_in_picture/scoped_picture_in_picture_occlusion_observation.h",
"//chrome/browser/platform_util.cc", "//chrome/browser/platform_util.cc",
"//chrome/browser/platform_util.h", "//chrome/browser/platform_util.h",
"//chrome/browser/predictors/preconnect_manager.cc", "//chrome/browser/predictors/preconnect_manager.cc",
@@ -108,28 +84,8 @@ static_library("chrome") {
"//chrome/browser/ui/ui_features.h", "//chrome/browser/ui/ui_features.h",
"//chrome/browser/ui/views/eye_dropper/eye_dropper.cc", "//chrome/browser/ui/views/eye_dropper/eye_dropper.cc",
"//chrome/browser/ui/views/eye_dropper/eye_dropper.h", "//chrome/browser/ui/views/eye_dropper/eye_dropper.h",
"//chrome/browser/ui/views/overlay/back_to_tab_label_button.cc", "//chrome/browser/ui/views/eye_dropper/eye_dropper_view.cc",
"//chrome/browser/ui/views/overlay/close_image_button.cc", "//chrome/browser/ui/views/eye_dropper/eye_dropper_view.h",
"//chrome/browser/ui/views/overlay/close_image_button.h",
"//chrome/browser/ui/views/overlay/constants.h",
"//chrome/browser/ui/views/overlay/hang_up_button.cc",
"//chrome/browser/ui/views/overlay/hang_up_button.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/playback_image_button.cc",
"//chrome/browser/ui/views/overlay/playback_image_button.h",
"//chrome/browser/ui/views/overlay/resize_handle_button.cc",
"//chrome/browser/ui/views/overlay/resize_handle_button.h",
"//chrome/browser/ui/views/overlay/simple_overlay_window_image_button.cc",
"//chrome/browser/ui/views/overlay/simple_overlay_window_image_button.h",
"//chrome/browser/ui/views/overlay/skip_ad_label_button.cc",
"//chrome/browser/ui/views/overlay/skip_ad_label_button.h",
"//chrome/browser/ui/views/overlay/toggle_camera_button.cc",
"//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_views.cc",
"//chrome/browser/ui/views/overlay/video_overlay_window_views.h",
"//extensions/browser/app_window/size_constraints.cc", "//extensions/browser/app_window/size_constraints.cc",
"//extensions/browser/app_window/size_constraints.h", "//extensions/browser/app_window/size_constraints.h",
"//ui/views/native_window_tracker.h", "//ui/views/native_window_tracker.h",
@@ -139,6 +95,23 @@ static_library("chrome") {
sources += [ "//chrome/browser/process_singleton_posix.cc" ] sources += [ "//chrome/browser/process_singleton_posix.cc" ]
} }
if (is_mac) {
sources += [
"//chrome/browser/extensions/global_shortcut_listener_mac.h",
"//chrome/browser/extensions/global_shortcut_listener_mac.mm",
"//chrome/browser/icon_loader_mac.mm",
"//chrome/browser/media/webrtc/system_media_capture_permissions_mac.h",
"//chrome/browser/media/webrtc/system_media_capture_permissions_mac.mm",
"//chrome/browser/media/webrtc/system_media_capture_permissions_stats_mac.h",
"//chrome/browser/media/webrtc/system_media_capture_permissions_stats_mac.mm",
"//chrome/browser/media/webrtc/window_icon_util_mac.mm",
"//chrome/browser/platform_util_mac.mm",
"//chrome/browser/process_singleton_mac.mm",
"//chrome/browser/ui/views/eye_dropper/eye_dropper_view_mac.h",
"//chrome/browser/ui/views/eye_dropper/eye_dropper_view_mac.mm",
]
}
if (is_win) { if (is_win) {
sources += [ sources += [
"//chrome/browser/extensions/global_shortcut_listener_win.cc", "//chrome/browser/extensions/global_shortcut_listener_win.cc",
@@ -162,9 +135,17 @@ static_library("chrome") {
sources += [ "//chrome/browser/media/webrtc/window_icon_util_ozone.cc" ] sources += [ "//chrome/browser/media/webrtc/window_icon_util_ozone.cc" ]
} }
if (use_aura) {
sources += [
"//chrome/browser/platform_util_aura.cc",
"//chrome/browser/ui/views/eye_dropper/eye_dropper_view_aura.cc",
"//ui/views/native_window_tracker_aura.cc",
"//ui/views/native_window_tracker_aura.h",
]
}
public_deps = [ public_deps = [
"//chrome/browser:dev_ui_browser_resources", "//chrome/browser:dev_ui_browser_resources",
"//chrome/browser/resources/accessibility:resources",
"//chrome/browser/ui/color:mixers", "//chrome/browser/ui/color:mixers",
"//chrome/common", "//chrome/common",
"//chrome/common:version_header", "//chrome/common:version_header",
@@ -176,25 +157,7 @@ static_library("chrome") {
"//services/strings", "//services/strings",
] ]
deps = [ deps = [ "//chrome/browser:resource_prefetch_predictor_proto" ]
"//chrome/app/vector_icons",
"//chrome/browser:resource_prefetch_predictor_proto",
"//chrome/browser/resource_coordinator:mojo_bindings",
"//chrome/browser/web_applications/mojom:mojom_web_apps_enum",
"//components/vector_icons:vector_icons",
"//ui/snapshot",
"//ui/views/controls/webview",
]
if (use_aura) {
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",
]
deps += [ "//components/eye_dropper" ]
}
if (is_linux) { if (is_linux) {
sources += [ "//chrome/browser/icon_loader_auralinux.cc" ] sources += [ "//chrome/browser/icon_loader_auralinux.cc" ]
@@ -211,10 +174,6 @@ static_library("chrome") {
"//chrome/browser/ui/views/status_icons/status_icon_linux_dbus.cc", "//chrome/browser/ui/views/status_icons/status_icon_linux_dbus.cc",
"//chrome/browser/ui/views/status_icons/status_icon_linux_dbus.h", "//chrome/browser/ui/views/status_icons/status_icon_linux_dbus.h",
] ]
sources += [
"//chrome/browser/ui/views/dark_mode_manager_linux.cc",
"//chrome/browser/ui/views/dark_mode_manager_linux.h",
]
public_deps += [ public_deps += [
"//components/dbus/menu", "//components/dbus/menu",
"//components/dbus/thread_linux", "//components/dbus/thread_linux",
@@ -226,30 +185,21 @@ static_library("chrome") {
"//chrome/browser/win/icon_reader_service.cc", "//chrome/browser/win/icon_reader_service.cc",
"//chrome/browser/win/icon_reader_service.h", "//chrome/browser/win/icon_reader_service.h",
] ]
public_deps += [ public_deps += [ "//chrome/services/util_win:lib" ]
"//chrome/browser/web_applications/proto",
"//chrome/services/util_win:lib",
"//components/webapps/common:mojo_bindings",
]
} }
if (is_mac) { if (enable_desktop_capturer) {
sources += [ sources += [
"//chrome/browser/extensions/global_shortcut_listener_mac.h", "//chrome/browser/media/webrtc/desktop_media_list.cc",
"//chrome/browser/extensions/global_shortcut_listener_mac.mm", "//chrome/browser/media/webrtc/desktop_media_list.h",
"//chrome/browser/icon_loader_mac.mm", "//chrome/browser/media/webrtc/desktop_media_list_base.cc",
"//chrome/browser/media/webrtc/system_media_capture_permissions_mac.h", "//chrome/browser/media/webrtc/desktop_media_list_base.h",
"//chrome/browser/media/webrtc/system_media_capture_permissions_mac.mm", "//chrome/browser/media/webrtc/desktop_media_list_observer.h",
"//chrome/browser/media/webrtc/system_media_capture_permissions_stats_mac.h", "//chrome/browser/media/webrtc/native_desktop_media_list.cc",
"//chrome/browser/media/webrtc/system_media_capture_permissions_stats_mac.mm", "//chrome/browser/media/webrtc/native_desktop_media_list.h",
"//chrome/browser/media/webrtc/thumbnail_capturer_mac.h", "//chrome/browser/media/webrtc/window_icon_util.h",
"//chrome/browser/media/webrtc/thumbnail_capturer_mac.mm",
"//chrome/browser/media/webrtc/window_icon_util_mac.mm",
"//chrome/browser/platform_util_mac.mm",
"//chrome/browser/process_singleton_mac.mm",
"//chrome/browser/ui/views/eye_dropper/eye_dropper_view_mac.h",
"//chrome/browser/ui/views/eye_dropper/eye_dropper_view_mac.mm",
] ]
deps += [ "//ui/snapshot" ]
} }
if (enable_widevine) { if (enable_widevine) {
@@ -266,8 +216,6 @@ static_library("chrome") {
sources += [ sources += [
"//chrome/browser/bad_message.cc", "//chrome/browser/bad_message.cc",
"//chrome/browser/bad_message.h", "//chrome/browser/bad_message.h",
"//chrome/browser/printing/prefs_util.cc",
"//chrome/browser/printing/prefs_util.h",
"//chrome/browser/printing/print_job.cc", "//chrome/browser/printing/print_job.cc",
"//chrome/browser/printing/print_job.h", "//chrome/browser/printing/print_job.h",
"//chrome/browser/printing/print_job_manager.cc", "//chrome/browser/printing/print_job_manager.cc",
@@ -280,8 +228,6 @@ static_library("chrome") {
"//chrome/browser/printing/print_view_manager_base.h", "//chrome/browser/printing/print_view_manager_base.h",
"//chrome/browser/printing/printer_query.cc", "//chrome/browser/printing/printer_query.cc",
"//chrome/browser/printing/printer_query.h", "//chrome/browser/printing/printer_query.h",
"//chrome/browser/printing/printer_query_oop.cc",
"//chrome/browser/printing/printer_query_oop.h",
"//chrome/browser/printing/printing_service.cc", "//chrome/browser/printing/printing_service.cc",
"//chrome/browser/printing/printing_service.h", "//chrome/browser/printing/printing_service.h",
"//components/printing/browser/print_to_pdf/pdf_print_job.cc", "//components/printing/browser/print_to_pdf/pdf_print_job.cc",
@@ -325,6 +271,41 @@ static_library("chrome") {
} }
} }
if (enable_picture_in_picture) {
sources += [
"//chrome/browser/picture_in_picture/picture_in_picture_window_manager.cc",
"//chrome/browser/picture_in_picture/picture_in_picture_window_manager.h",
"//chrome/browser/ui/views/overlay/back_to_tab_label_button.cc",
"//chrome/browser/ui/views/overlay/close_image_button.cc",
"//chrome/browser/ui/views/overlay/close_image_button.h",
"//chrome/browser/ui/views/overlay/constants.h",
"//chrome/browser/ui/views/overlay/hang_up_button.cc",
"//chrome/browser/ui/views/overlay/hang_up_button.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/playback_image_button.cc",
"//chrome/browser/ui/views/overlay/playback_image_button.h",
"//chrome/browser/ui/views/overlay/resize_handle_button.cc",
"//chrome/browser/ui/views/overlay/resize_handle_button.h",
"//chrome/browser/ui/views/overlay/simple_overlay_window_image_button.cc",
"//chrome/browser/ui/views/overlay/simple_overlay_window_image_button.h",
"//chrome/browser/ui/views/overlay/skip_ad_label_button.cc",
"//chrome/browser/ui/views/overlay/skip_ad_label_button.h",
"//chrome/browser/ui/views/overlay/toggle_camera_button.cc",
"//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_views.cc",
"//chrome/browser/ui/views/overlay/video_overlay_window_views.h",
]
deps += [
"//chrome/app/vector_icons",
"//components/vector_icons:vector_icons",
"//ui/views/controls/webview",
]
}
if (enable_electron_extensions) { if (enable_electron_extensions) {
sources += [ sources += [
"//chrome/browser/extensions/chrome_url_request_util.cc", "//chrome/browser/extensions/chrome_url_request_util.cc",
@@ -345,8 +326,6 @@ static_library("chrome") {
"//chrome/browser/pdf/pdf_extension_util.h", "//chrome/browser/pdf/pdf_extension_util.h",
"//chrome/browser/pdf/pdf_frame_util.cc", "//chrome/browser/pdf/pdf_frame_util.cc",
"//chrome/browser/pdf/pdf_frame_util.h", "//chrome/browser/pdf/pdf_frame_util.h",
"//chrome/browser/pdf/pdf_viewer_stream_manager.cc",
"//chrome/browser/pdf/pdf_viewer_stream_manager.h",
"//chrome/browser/plugins/pdf_iframe_navigation_throttle.cc", "//chrome/browser/plugins/pdf_iframe_navigation_throttle.cc",
"//chrome/browser/plugins/pdf_iframe_navigation_throttle.h", "//chrome/browser/plugins/pdf_iframe_navigation_throttle.h",
] ]
@@ -355,34 +334,6 @@ static_library("chrome") {
"//components/pdf/renderer", "//components/pdf/renderer",
] ]
} }
} else {
# These are required by the webRequest module.
sources += [
"//extensions/browser/api/declarative_net_request/request_action.cc",
"//extensions/browser/api/declarative_net_request/request_action.h",
"//extensions/browser/api/web_request/form_data_parser.cc",
"//extensions/browser/api/web_request/form_data_parser.h",
"//extensions/browser/api/web_request/upload_data_presenter.cc",
"//extensions/browser/api/web_request/upload_data_presenter.h",
"//extensions/browser/api/web_request/web_request_api_constants.cc",
"//extensions/browser/api/web_request/web_request_api_constants.h",
"//extensions/browser/api/web_request/web_request_info.cc",
"//extensions/browser/api/web_request/web_request_info.h",
"//extensions/browser/api/web_request/web_request_resource_type.cc",
"//extensions/browser/api/web_request/web_request_resource_type.h",
"//extensions/browser/extension_api_frame_id_map.cc",
"//extensions/browser/extension_api_frame_id_map.h",
"//extensions/browser/extension_navigation_ui_data.cc",
"//extensions/browser/extension_navigation_ui_data.h",
"//extensions/browser/extensions_browser_client.cc",
"//extensions/browser/extensions_browser_client.h",
"//extensions/browser/guest_view/web_view/web_view_renderer_state.cc",
"//extensions/browser/guest_view/web_view/web_view_renderer_state.h",
]
public_deps += [
"//extensions/browser/api/declarative_net_request/flat:extension_ruleset",
]
} }
if (!is_mas_build) { if (!is_mas_build) {
@@ -454,8 +405,6 @@ source_set("chrome_spellchecker") {
"//chrome/browser/profiles/profile_selections.h", "//chrome/browser/profiles/profile_selections.h",
"//chrome/browser/spellchecker/spell_check_host_chrome_impl.cc", "//chrome/browser/spellchecker/spell_check_host_chrome_impl.cc",
"//chrome/browser/spellchecker/spell_check_host_chrome_impl.h", "//chrome/browser/spellchecker/spell_check_host_chrome_impl.h",
"//chrome/browser/spellchecker/spell_check_initialization_host_impl.cc",
"//chrome/browser/spellchecker/spell_check_initialization_host_impl.h",
"//chrome/browser/spellchecker/spellcheck_custom_dictionary.cc", "//chrome/browser/spellchecker/spellcheck_custom_dictionary.cc",
"//chrome/browser/spellchecker/spellcheck_custom_dictionary.h", "//chrome/browser/spellchecker/spellcheck_custom_dictionary.h",
"//chrome/browser/spellchecker/spellcheck_factory.cc", "//chrome/browser/spellchecker/spellcheck_factory.cc",

View File

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

View File

@@ -1,7 +1,7 @@
import { shell } from 'electron/common'; import { shell } from 'electron/common';
import { app, dialog, BrowserWindow, ipcMain } from 'electron/main'; import { app, dialog, BrowserWindow, ipcMain } from 'electron/main';
import * as path from 'node:path'; import * as path from 'path';
import * as url from 'node:url'; import * as url from 'url';
let mainWindow: BrowserWindow | null = null; let mainWindow: BrowserWindow | null = null;
@@ -51,17 +51,16 @@ async function createWindow (backgroundColor?: string) {
autoHideMenuBar: true, autoHideMenuBar: true,
backgroundColor, backgroundColor,
webPreferences: { webPreferences: {
preload: url.fileURLToPath(new URL('preload.js', import.meta.url)), preload: path.resolve(__dirname, 'preload.js'),
contextIsolation: true, contextIsolation: true,
sandbox: true, sandbox: true
nodeIntegration: false
}, },
useContentSize: true, useContentSize: true,
show: false show: false
}; };
if (process.platform === 'linux') { if (process.platform === 'linux') {
options.icon = url.fileURLToPath(new URL('icon.png', import.meta.url)); options.icon = path.join(__dirname, 'icon.png');
} }
mainWindow = new BrowserWindow(options); mainWindow = new BrowserWindow(options);

View File

@@ -1,9 +1,8 @@
import * as electron from 'electron/main'; import * as electron from 'electron/main';
import * as fs from 'node:fs'; import * as fs from 'fs';
import { Module } from 'node:module'; import * as path from 'path';
import * as path from 'node:path'; import * as url from 'url';
import * as url from 'node:url';
const { app, dialog } = electron; const { app, dialog } = electron;
type DefaultAppOptions = { type DefaultAppOptions = {
@@ -16,6 +15,8 @@ type DefaultAppOptions = {
modules: string[]; modules: string[];
} }
const Module = require('module');
// Parse command line options. // Parse command line options.
const argv = process.argv.slice(1); const argv = process.argv.slice(1);
@@ -70,10 +71,10 @@ if (nextArgIsRequire) {
// Set up preload modules // Set up preload modules
if (option.modules.length > 0) { if (option.modules.length > 0) {
(Module as any)._preloadModules(option.modules); Module._preloadModules(option.modules);
} }
async function loadApplicationPackage (packagePath: string) { function loadApplicationPackage (packagePath: string) {
// Add a flag indicating app is started from default app. // Add a flag indicating app is started from default app.
Object.defineProperty(process, 'defaultApp', { Object.defineProperty(process, 'defaultApp', {
configurable: false, configurable: false,
@@ -88,19 +89,11 @@ async function loadApplicationPackage (packagePath: string) {
let appPath; let appPath;
if (fs.existsSync(packageJsonPath)) { if (fs.existsSync(packageJsonPath)) {
let packageJson; let packageJson;
const emitWarning = process.emitWarning;
try { try {
process.emitWarning = () => {}; packageJson = require(packageJsonPath);
packageJson = (await import(url.pathToFileURL(packageJsonPath).toString(), {
assert: {
type: 'json'
}
})).default;
} catch (e) { } catch (e) {
showErrorMessage(`Unable to parse ${packageJsonPath}\n\n${(e as Error).message}`); showErrorMessage(`Unable to parse ${packageJsonPath}\n\n${(e as Error).message}`);
return; return;
} finally {
process.emitWarning = emitWarning;
} }
if (packageJson.version) { if (packageJson.version) {
@@ -119,15 +112,13 @@ async function loadApplicationPackage (packagePath: string) {
// Set v8 flags, deliberately lazy load so that apps that do not use this // Set v8 flags, deliberately lazy load so that apps that do not use this
// feature do not pay the price // feature do not pay the price
if (packageJson.v8Flags) { if (packageJson.v8Flags) {
(await import('node:v8')).setFlagsFromString(packageJson.v8Flags); require('v8').setFlagsFromString(packageJson.v8Flags);
} }
appPath = packagePath; appPath = packagePath;
} }
let filePath: string;
try { try {
filePath = (Module as any)._resolveFilename(packagePath, null, true); const filePath = Module._resolveFilename(packagePath, module, true);
app.setAppPath(appPath || path.dirname(filePath)); app.setAppPath(appPath || path.dirname(filePath));
} catch (e) { } catch (e) {
showErrorMessage(`Unable to find Electron app at ${packagePath}\n\n${(e as Error).message}`); showErrorMessage(`Unable to find Electron app at ${packagePath}\n\n${(e as Error).message}`);
@@ -135,7 +126,7 @@ async function loadApplicationPackage (packagePath: string) {
} }
// Run the app. // Run the app.
await import(url.pathToFileURL(filePath).toString()); Module._load(packagePath, module, true);
} catch (e) { } catch (e) {
console.error('App threw an error during load'); console.error('App threw an error during load');
console.error((e as Error).stack || e); console.error((e as Error).stack || e);
@@ -150,16 +141,16 @@ function showErrorMessage (message: string) {
} }
async function loadApplicationByURL (appUrl: string) { async function loadApplicationByURL (appUrl: string) {
const { loadURL } = await import('./default_app.js'); const { loadURL } = await import('./default_app');
loadURL(appUrl); loadURL(appUrl);
} }
async function loadApplicationByFile (appPath: string) { async function loadApplicationByFile (appPath: string) {
const { loadFile } = await import('./default_app.js'); const { loadFile } = await import('./default_app');
loadFile(appPath); loadFile(appPath);
} }
async function startRepl () { function startRepl () {
if (process.platform === 'win32') { if (process.platform === 'win32') {
console.error('Electron REPL not currently supported on Windows'); console.error('Electron REPL not currently supported on Windows');
process.exit(1); process.exit(1);
@@ -180,8 +171,8 @@ async function startRepl () {
Using: Node.js ${nodeVersion} and Electron.js ${electronVersion} Using: Node.js ${nodeVersion} and Electron.js ${electronVersion}
`); `);
const { start } = await import('node:repl'); const { REPLServer } = require('repl');
const repl = start({ const repl = new REPLServer({
prompt: '> ' prompt: '> '
}).on('exit', () => { }).on('exit', () => {
process.exit(0); process.exit(0);
@@ -234,8 +225,8 @@ async function startRepl () {
const electronBuiltins = [...Object.keys(electron), 'original-fs', 'electron']; const electronBuiltins = [...Object.keys(electron), 'original-fs', 'electron'];
const defaultComplete: Function = repl.completer; const defaultComplete = repl.completer;
(repl as any).completer = (line: string, callback: Function) => { repl.completer = (line: string, callback: Function) => {
const lastSpace = line.lastIndexOf(' '); const lastSpace = line.lastIndexOf(' ');
const currentSymbol = line.substring(lastSpace + 1, repl.cursor); const currentSymbol = line.substring(lastSpace + 1, repl.cursor);
@@ -258,11 +249,11 @@ if (option.file && !option.webdriver) {
const protocol = url.parse(file).protocol; const protocol = url.parse(file).protocol;
const extension = path.extname(file); const extension = path.extname(file);
if (protocol === 'http:' || protocol === 'https:' || protocol === 'file:' || protocol === 'chrome:') { if (protocol === 'http:' || protocol === 'https:' || protocol === 'file:' || protocol === 'chrome:') {
await loadApplicationByURL(file); loadApplicationByURL(file);
} else if (extension === '.html' || extension === '.htm') { } else if (extension === '.html' || extension === '.htm') {
await loadApplicationByFile(path.resolve(file)); loadApplicationByFile(path.resolve(file));
} else { } else {
await loadApplicationPackage(file); loadApplicationPackage(file);
} }
} else if (option.version) { } else if (option.version) {
console.log('v' + process.versions.electron); console.log('v' + process.versions.electron);
@@ -271,7 +262,7 @@ if (option.file && !option.webdriver) {
console.log(process.versions.modules); console.log(process.versions.modules);
process.exit(0); process.exit(0);
} else if (option.interactive) { } else if (option.interactive) {
await startRepl(); startRepl();
} else { } else {
if (!option.noHelp) { if (!option.noHelp) {
const welcomeMessage = ` const welcomeMessage = `
@@ -294,5 +285,5 @@ Options:
console.log(welcomeMessage); console.log(welcomeMessage);
} }
await loadApplicationByFile('index.html'); loadApplicationByFile('index.html');
} }

View File

@@ -1,6 +1,5 @@
{ {
"name": "electron", "name": "electron",
"productName": "Electron", "productName": "Electron",
"main": "main.js", "main": "main.js"
"type": "module"
} }

View File

@@ -1,4 +1,4 @@
const { ipcRenderer, contextBridge } = require('electron/renderer'); import { ipcRenderer, contextBridge } from 'electron/renderer';
const policy = window.trustedTypes.createPolicy('electron-default-app', { const policy = window.trustedTypes.createPolicy('electron-default-app', {
// we trust the SVG contents // we trust the SVG contents

View File

@@ -90,6 +90,7 @@ These individual tutorials expand on topics discussed in the guide above.
## API References ## API References
* [Synopsis](api/synopsis.md)
* [Process Object](api/process.md) * [Process Object](api/process.md)
* [Supported Command Line Switches](api/command-line-switches.md) * [Supported Command Line Switches](api/command-line-switches.md)
* [Environment Variables](api/environment-variables.md) * [Environment Variables](api/environment-variables.md)
@@ -109,7 +110,6 @@ These individual tutorials expand on topics discussed in the guide above.
* [BrowserView](api/browser-view.md) * [BrowserView](api/browser-view.md)
* [BrowserWindow](api/browser-window.md) * [BrowserWindow](api/browser-window.md)
* [contentTracing](api/content-tracing.md) * [contentTracing](api/content-tracing.md)
* [desktopCapturer](api/desktop-capturer.md)
* [dialog](api/dialog.md) * [dialog](api/dialog.md)
* [globalShortcut](api/global-shortcut.md) * [globalShortcut](api/global-shortcut.md)
* [inAppPurchase](api/in-app-purchase.md) * [inAppPurchase](api/in-app-purchase.md)
@@ -118,22 +118,19 @@ These individual tutorials expand on topics discussed in the guide above.
* [MenuItem](api/menu-item.md) * [MenuItem](api/menu-item.md)
* [MessageChannelMain](api/message-channel-main.md) * [MessageChannelMain](api/message-channel-main.md)
* [MessagePortMain](api/message-port-main.md) * [MessagePortMain](api/message-port-main.md)
* [nativeTheme](api/native-theme.md)
* [net](api/net.md) * [net](api/net.md)
* [netLog](api/net-log.md) * [netLog](api/net-log.md)
* [nativeTheme](api/native-theme.md)
* [Notification](api/notification.md) * [Notification](api/notification.md)
* [powerMonitor](api/power-monitor.md) * [powerMonitor](api/power-monitor.md)
* [powerSaveBlocker](api/power-save-blocker.md) * [powerSaveBlocker](api/power-save-blocker.md)
* [protocol](api/protocol.md) * [protocol](api/protocol.md)
* [pushNotifications](api/push-notifications.md)
* [safeStorage](api/safe-storage.md)
* [screen](api/screen.md) * [screen](api/screen.md)
* [session](api/session.md) * [session](api/session.md)
* [ShareMenu](api/share-menu.md) * [ShareMenu](api/share-menu.md)
* [systemPreferences](api/system-preferences.md) * [systemPreferences](api/system-preferences.md)
* [TouchBar](api/touch-bar.md) * [TouchBar](api/touch-bar.md)
* [Tray](api/tray.md) * [Tray](api/tray.md)
* [utilityProcess](api/utility-process.md)
* [webContents](api/web-contents.md) * [webContents](api/web-contents.md)
* [webFrameMain](api/web-frame-main.md) * [webFrameMain](api/web-frame-main.md)
@@ -145,10 +142,11 @@ These individual tutorials expand on topics discussed in the guide above.
### Modules for Both Processes: ### Modules for Both Processes:
* [clipboard](api/clipboard.md) (non-sandboxed renderers only) * [clipboard](api/clipboard.md)
* [crashReporter](api/crash-reporter.md) * [crashReporter](api/crash-reporter.md)
* [desktopCapturer](api/desktop-capturer.md)
* [nativeImage](api/native-image.md) * [nativeImage](api/native-image.md)
* [shell](api/shell.md) (non-sandboxed renderers only) * [shell](api/shell.md)
## Development ## Development

View File

@@ -15,7 +15,7 @@ Shortcuts are registered with the [`globalShortcut`](global-shortcut.md) module
using the [`register`](global-shortcut.md#globalshortcutregisteraccelerator-callback) using the [`register`](global-shortcut.md#globalshortcutregisteraccelerator-callback)
method, i.e. method, i.e.
```js ```javascript
const { app, globalShortcut } = require('electron') const { app, globalShortcut } = require('electron')
app.whenReady().then(() => { app.whenReady().then(() => {
@@ -55,7 +55,7 @@ The `Super` (or `Meta`) key is mapped to the `Windows` key on Windows and Linux
* `0` to `9` * `0` to `9`
* `A` to `Z` * `A` to `Z`
* `F1` to `F24` * `F1` to `F24`
* Various Punctuation: `)`, `!`, `@`, `#`, `$`, `%`, `^`, `&`, `*`, `(`, `:`, `;`, `:`, `+`, `=`, `<`, `,`, `_`, `-`, `>`, `.`, `?`, `/`, `~`, `` ` ``, `{`, `]`, `[`, `|`, `\`, `}`, `"` * Punctuation like `~`, `!`, `@`, `#`, `$`, etc.
* `Plus` * `Plus`
* `Space` * `Space`
* `Tab` * `Tab`

View File

@@ -7,7 +7,7 @@ Process: [Main](../glossary.md#main-process)
The following example shows how to quit the application when the last window is The following example shows how to quit the application when the last window is
closed: closed:
```js ```javascript
const { app } = require('electron') const { app } = require('electron')
app.on('window-all-closed', () => { app.on('window-all-closed', () => {
app.quit() app.quit()
@@ -23,7 +23,8 @@ The `app` object emits the following events:
Emitted when the application has finished basic startup. On Windows and Linux, Emitted when the application has finished basic startup. On Windows and Linux,
the `will-finish-launching` event is the same as the `ready` event; on macOS, the `will-finish-launching` event is the same as the `ready` event; on macOS,
this event represents the `applicationWillFinishLaunching` notification of this event represents the `applicationWillFinishLaunching` notification of
`NSApplication`. `NSApplication`. You would usually set up listeners for the `open-file` and
`open-url` events here, and start the crash reporter and auto updater.
In most cases, you should do everything in the `ready` event handler. In most cases, you should do everything in the `ready` event handler.
@@ -63,7 +64,7 @@ Calling `event.preventDefault()` will prevent the default behavior, which is
terminating the application. terminating the application.
**Note:** If application quit was initiated by `autoUpdater.quitAndInstall()`, **Note:** If application quit was initiated by `autoUpdater.quitAndInstall()`,
then `before-quit` is emitted _after_ emitting `close` event on all windows and then `before-quit` is emitted *after* emitting `close` event on all windows and
closing them. closing them.
**Note:** On Windows, this event will not be emitted if the app is closed due **Note:** On Windows, this event will not be emitted if the app is closed due
@@ -127,9 +128,12 @@ Emitted when the user wants to open a URL with the application. Your application
`Info.plist` file must define the URL scheme within the `CFBundleURLTypes` key, and `Info.plist` file must define the URL scheme within the `CFBundleURLTypes` key, and
set `NSPrincipalClass` to `AtomApplication`. set `NSPrincipalClass` to `AtomApplication`.
You should call `event.preventDefault()` if you want to handle this event.
As with the `open-file` event, be sure to register a listener for the `open-url` As with the `open-file` event, be sure to register a listener for the `open-url`
event early in your application startup to detect if the application is being opened to handle a URL. event early in your application startup to detect if the the application being
If you register the listener in response to a `ready` event, you'll miss URLs that trigger the launch of your application. is being opened to handle a URL. If you register the listener in response to a
`ready` event, you'll miss URLs that trigger the launch of your application.
### Event: 'activate' _macOS_ ### Event: 'activate' _macOS_
@@ -149,20 +153,9 @@ Returns:
* `event` Event * `event` Event
Emitted when the application becomes active. This differs from the `activate` event in Emitted when mac application become active. Difference from `activate` event is
that `did-become-active` is emitted every time the app becomes active, not only that `did-become-active` is emitted every time the app becomes active, not only
when Dock icon is clicked or application is re-launched. It is also emitted when a user when Dock icon is clicked or application is re-launched.
switches to the app via the macOS App Switcher.
### Event: 'did-resign-active' _macOS_
Returns:
* `event` Event
Emitted when the app is no longer active and doesnt have focus. This can be triggered,
for example, by clicking on another application or by using the macOS App Switcher to
switch to another application.
### Event: 'continue-activity' _macOS_ ### Event: 'continue-activity' _macOS_
@@ -295,7 +288,7 @@ Emitted when failed to verify the `certificate` for `url`, to trust the
certificate you should prevent the default behavior with certificate you should prevent the default behavior with
`event.preventDefault()` and call `callback(true)`. `event.preventDefault()` and call `callback(true)`.
```js ```javascript
const { app } = require('electron') const { app } = require('electron')
app.on('certificate-error', (event, webContents, url, error, certificate, callback) => { app.on('certificate-error', (event, webContents, url, error, certificate, callback) => {
@@ -327,7 +320,7 @@ and `callback` can be called with an entry filtered from the list. Using
`event.preventDefault()` prevents the application from using the first `event.preventDefault()` prevents the application from using the first
certificate from the store. certificate from the store.
```js ```javascript
const { app } = require('electron') const { app } = require('electron')
app.on('select-client-certificate', (event, webContents, url, list, callback) => { app.on('select-client-certificate', (event, webContents, url, list, callback) => {
@@ -360,7 +353,7 @@ The default behavior is to cancel all authentications. To override this you
should prevent the default behavior with `event.preventDefault()` and call should prevent the default behavior with `event.preventDefault()` and call
`callback(username, password)` with the credentials. `callback(username, password)` with the credentials.
```js ```javascript
const { app } = require('electron') const { app } = require('electron')
app.on('login', (event, webContents, details, authInfo, callback) => { app.on('login', (event, webContents, details, authInfo, callback) => {
@@ -377,13 +370,53 @@ page.
Emitted whenever there is a GPU info update. Emitted whenever there is a GPU info update.
### Event: 'gpu-process-crashed' _Deprecated_
Returns:
* `event` Event
* `killed` boolean
Emitted when the GPU process crashes or is killed.
**Deprecated:** This event is superceded by the `child-process-gone` event
which contains more information about why the child process disappeared. It
isn't always because it crashed. The `killed` boolean can be replaced by
checking `reason === 'killed'` when you switch to that event.
### Event: 'renderer-process-crashed' _Deprecated_
Returns:
* `event` Event
* `webContents` [WebContents](web-contents.md)
* `killed` boolean
Emitted when the renderer process of `webContents` crashes or is killed.
**Deprecated:** This event is superceded by the `render-process-gone` event
which contains more information about why the render process disappeared. It
isn't always because it crashed. The `killed` boolean can be replaced by
checking `reason === 'killed'` when you switch to that event.
### Event: 'render-process-gone' ### Event: 'render-process-gone'
Returns: Returns:
* `event` Event * `event` Event
* `webContents` [WebContents](web-contents.md) * `webContents` [WebContents](web-contents.md)
* `details` [RenderProcessGoneDetails](structures/render-process-gone-details.md) * `details` Object
* `reason` string - The reason the render process is gone. Possible values:
* `clean-exit` - Process exited with an exit code of zero
* `abnormal-exit` - Process exited with a non-zero exit code
* `killed` - Process was sent a SIGTERM or otherwise killed externally
* `crashed` - Process crashed
* `oom` - Process ran out of memory
* `launch-failed` - Process never successfully launched
* `integrity-failure` - Windows code integrity checks failed
* `exitCode` Integer - The exit code of the process, unless `reason` is
`launch-failed`, in which case `exitCode` will be a platform-specific
launch failure error code.
Emitted when the renderer process unexpectedly disappears. This is normally Emitted when the renderer process unexpectedly disappears. This is normally
because it was crashed or killed. because it was crashed or killed.
@@ -440,7 +473,7 @@ Returns:
Emitted when Electron has created a new `session`. Emitted when Electron has created a new `session`.
```js ```javascript
const { app } = require('electron') const { app } = require('electron')
app.on('session-created', (session) => { app.on('session-created', (session) => {
@@ -525,7 +558,7 @@ started after current instance exited.
An example of restarting current instance immediately and adding a new command An example of restarting current instance immediately and adding a new command
line argument to the new instance: line argument to the new instance:
```js ```javascript
const { app } = require('electron') const { app } = require('electron')
app.relaunch({ args: process.argv.slice(1).concat(['--relaunch']) }) app.relaunch({ args: process.argv.slice(1).concat(['--relaunch']) })
@@ -721,21 +754,14 @@ This API can be used for purposes such as deciding what language to present the
Here are some examples of return values of the various language and locale APIs with different configurations: Here are some examples of return values of the various language and locale APIs with different configurations:
On Windows, given application locale is German, the regional format is Finnish (Finland), and the preferred system languages from most to least preferred are French (Canada), English (US), Simplified Chinese (China), Finnish, and Spanish (Latin America): * For Windows, where the application locale is German, the regional format is Finnish (Finland), and the preferred system languages from most to least preferred are French (Canada), English (US), Simplified Chinese (China), Finnish, and Spanish (Latin America):
* `app.getLocale()` returns `'de'`
```js * `app.getSystemLocale()` returns `'fi-FI'`
app.getLocale() // 'de' * `app.getPreferredSystemLanguages()` returns `['fr-CA', 'en-US', 'zh-Hans-CN', 'fi', 'es-419']`
app.getSystemLocale() // 'fi-FI' * On macOS, where the application locale is German, the region is Finland, and the preferred system languages from most to least preferred are French (Canada), English (US), Simplified Chinese, and Spanish (Latin America):
app.getPreferredSystemLanguages() // ['fr-CA', 'en-US', 'zh-Hans-CN', 'fi', 'es-419'] * `app.getLocale()` returns `'de'`
``` * `app.getSystemLocale()` returns `'fr-FI'`
* `app.getPreferredSystemLanguages()` returns `['fr-CA', 'en-US', 'zh-Hans-FI', 'es-419']`
On macOS, given the application locale is German, the region is Finland, and the preferred system languages from most to least preferred are French (Canada), English (US), Simplified Chinese, and Spanish (Latin America):
```js
app.getLocale() // 'de'
app.getSystemLocale() // 'fr-FI'
app.getPreferredSystemLanguages() // ['fr-CA', 'en-US', 'zh-Hans-FI', 'es-419']
```
Both the available languages and regions and the possible return values differ between the two operating systems. Both the available languages and regions and the possible return values differ between the two operating systems.
@@ -781,7 +807,7 @@ editor. Please refer to [Apple's documentation][CFBundleURLTypes] for details.
**Note:** In a Windows Store environment (when packaged as an `appx`) this API **Note:** In a Windows Store environment (when packaged as an `appx`) this API
will return `true` for all calls but the registry key it sets won't be accessible will return `true` for all calls but the registry key it sets won't be accessible
by other applications. In order to register your Windows Store application by other applications. In order to register your Windows Store application
as a default protocol handler you must [declare the protocol in your manifest](https://learn.microsoft.com/en-us/uwp/schemas/appxpackage/uapmanifestschema/element-uap-protocol). as a default protocol handler you must [declare the protocol in your manifest](https://docs.microsoft.com/en-us/uwp/schemas/appxpackage/uapmanifestschema/element-uap-protocol).
The API uses the Windows Registry and `LSSetDefaultHandlerForURLScheme` internally. The API uses the Windows Registry and `LSSetDefaultHandlerForURLScheme` internally.
@@ -910,7 +936,7 @@ List, nor will it be displayed.
Here's a very simple example of creating a custom Jump List: Here's a very simple example of creating a custom Jump List:
```js ```javascript
const { app } = require('electron') const { app } = require('electron')
app.setJumpList([ app.setJumpList([
@@ -930,7 +956,7 @@ app.setJumpList([
title: 'Tool A', title: 'Tool A',
program: process.execPath, program: process.execPath,
args: '--run-tool-a', args: '--run-tool-a',
iconPath: process.execPath, icon: process.execPath,
iconIndex: 0, iconIndex: 0,
description: 'Runs Tool A' description: 'Runs Tool A'
}, },
@@ -939,7 +965,7 @@ app.setJumpList([
title: 'Tool B', title: 'Tool B',
program: process.execPath, program: process.execPath,
args: '--run-tool-b', args: '--run-tool-b',
iconPath: process.execPath, icon: process.execPath,
iconIndex: 0, iconIndex: 0,
description: 'Runs Tool B' description: 'Runs Tool B'
} }
@@ -993,8 +1019,8 @@ use this method to ensure single instance.
An example of activating the window of primary instance when a second instance An example of activating the window of primary instance when a second instance
starts: starts:
```js ```javascript
const { app, BrowserWindow } = require('electron') const { app } = require('electron')
let myWindow = null let myWindow = null
const additionalData = { myKey: 'myValue' } const additionalData = { myKey: 'myValue' }
@@ -1014,9 +1040,9 @@ if (!gotTheLock) {
} }
}) })
// Create myWindow, load the rest of the app, etc...
app.whenReady().then(() => { app.whenReady().then(() => {
myWindow = new BrowserWindow({}) myWindow = createWindow()
myWindow.loadURL('https://electronjs.org')
}) })
} }
``` ```
@@ -1105,11 +1131,11 @@ indicates success while any other value indicates failure according to Chromium
resolver will attempt to use the system's DNS settings to do DNS lookups resolver will attempt to use the system's DNS settings to do DNS lookups
itself. Enabled by default on macOS, disabled by default on Windows and itself. Enabled by default on macOS, disabled by default on Windows and
Linux. Linux.
* `secureDnsMode` string (optional) - Can be 'off', 'automatic' or 'secure'. * `secureDnsMode` string (optional) - Can be "off", "automatic" or "secure".
Configures the DNS-over-HTTP mode. When 'off', no DoH lookups will be Configures the DNS-over-HTTP mode. When "off", no DoH lookups will be
performed. When 'automatic', DoH lookups will be performed first if DoH is performed. When "automatic", DoH lookups will be performed first if DoH is
available, and insecure DNS lookups will be performed as a fallback. When available, and insecure DNS lookups will be performed as a fallback. When
'secure', only DoH lookups will be performed. Defaults to 'automatic'. "secure", only DoH lookups will be performed. Defaults to "automatic".
* `secureDnsServers` string[]&#32;(optional) - A list of DNS-over-HTTP * `secureDnsServers` string[]&#32;(optional) - A list of DNS-over-HTTP
server templates. See [RFC8484 § 3][] for details on the template format. server templates. See [RFC8484 § 3][] for details on the template format.
Most servers support the POST method; the template for such servers is Most servers support the POST method; the template for such servers is
@@ -1139,15 +1165,11 @@ case the user's DNS configuration does not include a provider that supports
DoH. DoH.
```js ```js
const { app } = require('electron') app.configureHostResolver({
secureDnsMode: 'secure',
app.whenReady().then(() => { secureDnsServers: [
app.configureHostResolver({ 'https://cloudflare-dns.com/dns-query'
secureDnsMode: 'secure', ]
secureDnsServers: [
'https://cloudflare-dns.com/dns-query'
]
})
}) })
``` ```
@@ -1235,9 +1257,6 @@ On macOS, it shows on the dock icon. On Linux, it only works for Unity launcher.
**Note:** Unity launcher requires a `.desktop` file to work. For more information, **Note:** Unity launcher requires a `.desktop` file to work. For more information,
please read the [Unity integration documentation][unity-requirement]. please read the [Unity integration documentation][unity-requirement].
**Note:** On macOS, you need to ensure that your application has the permission
to display notifications for this method to work.
### `app.getBadgeCount()` _Linux_ _macOS_ ### `app.getBadgeCount()` _Linux_ _macOS_
Returns `Integer` - The current value displayed in the counter badge. Returns `Integer` - The current value displayed in the counter badge.
@@ -1249,10 +1268,10 @@ Returns `boolean` - Whether the current desktop environment is Unity launcher.
### `app.getLoginItemSettings([options])` _macOS_ _Windows_ ### `app.getLoginItemSettings([options])` _macOS_ _Windows_
* `options` Object (optional) * `options` Object (optional)
* `type` string (optional) _macOS_ - Can be one of `mainAppService`, `agentService`, `daemonService`, or `loginItemService`. Defaults to `mainAppService`. Only available on macOS 13 and up. See [app.setLoginItemSettings](app.md#appsetloginitemsettingssettings-macos-windows) for more information about each type. * `path` string (optional) _Windows_ - The executable path to compare against.
* `serviceName` string (optional) _macOS_ - The name of the service. Required if `type` is non-default. Only available on macOS 13 and up. Defaults to `process.execPath`.
* `path` string (optional) _Windows_ - The executable path to compare against. Defaults to `process.execPath`. * `args` string[] (optional) _Windows_ - The command-line arguments to compare
* `args` string[] (optional) _Windows_ - The command-line arguments to compare against. Defaults to an empty array. against. Defaults to an empty array.
If you provided `path` and `args` options to `app.setLoginItemSettings`, then you If you provided `path` and `args` options to `app.setLoginItemSettings`, then you
need to pass the same arguments here for `openAtLogin` to be set correctly. need to pass the same arguments here for `openAtLogin` to be set correctly.
@@ -1260,11 +1279,17 @@ need to pass the same arguments here for `openAtLogin` to be set correctly.
Returns `Object`: Returns `Object`:
* `openAtLogin` boolean - `true` if the app is set to open at login. * `openAtLogin` boolean - `true` if the app is set to open at login.
* `openAsHidden` boolean _macOS_ _Deprecated_ - `true` if the app is set to open as hidden at login. This does not work on macOS 13 and up. * `openAsHidden` boolean _macOS_ - `true` if the app is set to open as hidden at login.
* `wasOpenedAtLogin` boolean _macOS_ _Deprecated_ - `true` if the app was opened at login automatically. This setting is not available on [MAS builds][mas-builds] or on macOS 13 and up. This setting is not available on [MAS builds][mas-builds].
* `wasOpenedAsHidden` boolean _macOS_ _Deprecated_ - `true` if the app was opened as a hidden login item. This indicates that the app should not open any windows at startup. This setting is not available on [MAS builds][mas-builds] or on macOS 13 and up. * `wasOpenedAtLogin` boolean _macOS_ - `true` if the app was opened at login
* `restoreState` boolean _macOS_ _Deprecated_ - `true` if the app was opened as a login item that should restore the state from the previous session. This indicates that the app should restore the windows that were open the last time the app was closed. This setting is not available on [MAS builds][mas-builds] or on macOS 13 and up. automatically. This setting is not available on [MAS builds][mas-builds].
* `status` string _macOS_ - can be one of `not-registered`, `enabled`, `requires-approval`, or `not-found`. * `wasOpenedAsHidden` boolean _macOS_ - `true` if the app was opened as a hidden login
item. This indicates that the app should not open any windows at startup.
This setting is not available on [MAS builds][mas-builds].
* `restoreState` boolean _macOS_ - `true` if the app was opened as a login item that
should restore the state from the previous session. This indicates that the
app should restore the windows that were open the last time the app was
closed. This setting is not available on [MAS builds][mas-builds].
* `executableWillLaunchAtLogin` boolean _Windows_ - `true` if app is set to open at login and its run key is not deactivated. This differs from `openAtLogin` as it ignores the `args` option, this property will be true if the given executable would be launched at login with **any** arguments. * `executableWillLaunchAtLogin` boolean _Windows_ - `true` if app is set to open at login and its run key is not deactivated. This differs from `openAtLogin` as it ignores the `args` option, this property will be true if the given executable would be launched at login with **any** arguments.
* `launchItems` Object[] _Windows_ * `launchItems` Object[] _Windows_
* `name` string _Windows_ - name value of a registry entry. * `name` string _Windows_ - name value of a registry entry.
@@ -1278,14 +1303,10 @@ Returns `Object`:
* `settings` Object * `settings` Object
* `openAtLogin` boolean (optional) - `true` to open the app at login, `false` to remove * `openAtLogin` boolean (optional) - `true` to open the app at login, `false` to remove
the app as a login item. Defaults to `false`. the app as a login item. Defaults to `false`.
* `openAsHidden` boolean (optional) _macOS_ _Deprecated_ - `true` to open the app as hidden. Defaults to `false`. The user can edit this setting from the System Preferences so `app.getLoginItemSettings().wasOpenedAsHidden` should be checked when the app is opened to know the current value. This setting is not available on [MAS build * `openAsHidden` boolean (optional) _macOS_ - `true` to open the app as hidden. Defaults to
s][mas-builds] or on macOS 13 and up. `false`. The user can edit this setting from the System Preferences so
* `type` string (optional) _macOS_ - The type of service to add as a login item. Defaults to `mainAppService`. Only available on macOS 13 and up. `app.getLoginItemSettings().wasOpenedAsHidden` should be checked when the app
* `mainAppService` - The primary application. is opened to know the current value. This setting is not available on [MAS builds][mas-builds].
* `agentService` - The property list name for a launch agent. The property list name must correspond to a property list in the apps `Contents/Library/LaunchAgents` directory.
* `daemonService` string (optional) _macOS_ - The property list name for a launch agent. The property list name must correspond to a property list in the apps `Contents/Library/LaunchDaemons` directory.
* `loginItemService` string (optional) _macOS_ - The property list name for a login item service. The property list name must correspond to a property list in the apps `Contents/Library/LoginItems` directory.
* `serviceName` string (optional) _macOS_ - The name of the service. Required if `type` is non-default. Only available on macOS 13 and up.
* `path` string (optional) _Windows_ - The executable to launch at login. * `path` string (optional) _Windows_ - The executable to launch at login.
Defaults to `process.execPath`. Defaults to `process.execPath`.
* `args` string[] (optional) _Windows_ - The command-line arguments to pass to * `args` string[] (optional) _Windows_ - The command-line arguments to pass to
@@ -1294,17 +1315,13 @@ s][mas-builds] or on macOS 13 and up.
* `enabled` boolean (optional) _Windows_ - `true` will change the startup approved registry key and `enable / disable` the App in Task Manager and Windows Settings. * `enabled` boolean (optional) _Windows_ - `true` will change the startup approved registry key and `enable / disable` the App in Task Manager and Windows Settings.
Defaults to `true`. Defaults to `true`.
* `name` string (optional) _Windows_ - value name to write into registry. Defaults to the app's AppUserModelId(). * `name` string (optional) _Windows_ - value name to write into registry. Defaults to the app's AppUserModelId().
Set the app's login item settings. Set the app's login item settings.
To work with Electron's `autoUpdater` on Windows, which uses [Squirrel][Squirrel-Windows], To work with Electron's `autoUpdater` on Windows, which uses [Squirrel][Squirrel-Windows],
you'll want to set the launch path to Update.exe, and pass arguments that specify your you'll want to set the launch path to Update.exe, and pass arguments that specify your
application name. For example: application name. For example:
``` js ``` javascript
const { app } = require('electron')
const path = require('node:path')
const appFolder = path.dirname(process.execPath) const appFolder = path.dirname(process.execPath)
const updateExe = path.resolve(appFolder, '..', 'Update.exe') const updateExe = path.resolve(appFolder, '..', 'Update.exe')
const exeName = path.basename(process.execPath) const exeName = path.basename(process.execPath)
@@ -1314,13 +1331,11 @@ app.setLoginItemSettings({
path: updateExe, path: updateExe,
args: [ args: [
'--processStart', `"${exeName}"`, '--processStart', `"${exeName}"`,
'--process-start-args', '"--hidden"' '--process-start-args', `"--hidden"`
] ]
}) })
``` ```
For more information about setting different services as login items on macOS 13 and up, see [`SMAppService`](https://developer.apple.com/documentation/servicemanagement/smappservice?language=objc).
### `app.isAccessibilitySupportEnabled()` _macOS_ _Windows_ ### `app.isAccessibilitySupportEnabled()` _macOS_ _Windows_
Returns `boolean` - `true` if Chrome's accessibility support is enabled, Returns `boolean` - `true` if Chrome's accessibility support is enabled,
@@ -1342,7 +1357,7 @@ This API must be called after the `ready` event is emitted.
### `app.showAboutPanel()` ### `app.showAboutPanel()`
Show the app's about panel options. These options can be overridden with `app.setAboutPanelOptions(options)`. This function runs asynchronously. Show the app's about panel options. These options can be overridden with `app.setAboutPanelOptions(options)`.
### `app.setAboutPanelOptions(options)` ### `app.setAboutPanelOptions(options)`
@@ -1375,22 +1390,11 @@ Show the platform's native emoji picker.
Returns `Function` - This function **must** be called once you have finished accessing the security scoped file. If you do not remember to stop accessing the bookmark, [kernel resources will be leaked](https://developer.apple.com/reference/foundation/nsurl/1417051-startaccessingsecurityscopedreso?language=objc) and your app will lose its ability to reach outside the sandbox completely, until your app is restarted. Returns `Function` - This function **must** be called once you have finished accessing the security scoped file. If you do not remember to stop accessing the bookmark, [kernel resources will be leaked](https://developer.apple.com/reference/foundation/nsurl/1417051-startaccessingsecurityscopedreso?language=objc) and your app will lose its ability to reach outside the sandbox completely, until your app is restarted.
```js ```js
const { app, dialog } = require('electron') // Start accessing the file.
const fs = require('node:fs') const stopAccessingSecurityScopedResource = app.startAccessingSecurityScopedResource(data)
// You can now access the file outside of the sandbox 🎉
let filepath // Remember to stop accessing the file once you've finished with it.
let bookmark
dialog.showOpenDialog(null, { securityScopedBookmarks: true }).then(({ filePaths, bookmarks }) => {
filepath = filePaths[0]
bookmark = bookmarks[0]
fs.readFileSync(filepath)
})
// ... restart app ...
const stopAccessingSecurityScopedResource = app.startAccessingSecurityScopedResource(bookmark)
fs.readFileSync(filepath)
stopAccessingSecurityScopedResource() stopAccessingSecurityScopedResource()
``` ```
@@ -1398,7 +1402,7 @@ Start accessing a security scoped resource. With this method Electron applicatio
### `app.enableSandbox()` ### `app.enableSandbox()`
Enables full sandbox mode on the app. This means that all renderers will be launched sandboxed, regardless of the value of the `sandbox` flag in [`WebPreferences`](structures/web-preferences.md). Enables full sandbox mode on the app. This means that all renderers will be launched sandboxed, regardless of the value of the `sandbox` flag in WebPreferences.
This method can only be called before app is ready. This method can only be called before app is ready.
@@ -1431,8 +1435,6 @@ By default, if an app of the same name as the one being moved exists in the Appl
For example: For example:
```js ```js
const { app, dialog } = require('electron')
app.moveToApplicationsFolder({ app.moveToApplicationsFolder({
conflictHandler: (conflictType) => { conflictHandler: (conflictType) => {
if (conflictType === 'exists') { if (conflictType === 'exists') {
@@ -1511,18 +1513,18 @@ dock on macOS.
A `boolean` property that returns `true` if the app is packaged, `false` otherwise. For many apps, this property can be used to distinguish development and production environments. A `boolean` property that returns `true` if the app is packaged, `false` otherwise. For many apps, this property can be used to distinguish development and production environments.
[tasks]:https://learn.microsoft.com/en-us/windows/win32/shell/taskbar-extensions#tasks [tasks]:https://msdn.microsoft.com/en-us/library/windows/desktop/dd378460(v=vs.85).aspx#tasks
[app-user-model-id]: https://learn.microsoft.com/en-us/windows/win32/shell/appids [app-user-model-id]: https://msdn.microsoft.com/en-us/library/windows/desktop/dd378459(v=vs.85).aspx
[electron-forge]: https://www.electronforge.io/ [electron-forge]: https://www.electronforge.io/
[electron-packager]: https://github.com/electron/packager [electron-packager]: https://github.com/electron/electron-packager
[CFBundleURLTypes]: https://developer.apple.com/library/ios/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html#//apple_ref/doc/uid/TP40009249-102207-TPXREF115 [CFBundleURLTypes]: https://developer.apple.com/library/ios/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html#//apple_ref/doc/uid/TP40009249-102207-TPXREF115
[LSCopyDefaultHandlerForURLScheme]: https://developer.apple.com/documentation/coreservices/1441725-lscopydefaulthandlerforurlscheme?language=objc [LSCopyDefaultHandlerForURLScheme]: https://developer.apple.com/library/mac/documentation/Carbon/Reference/LaunchServicesReference/#//apple_ref/c/func/LSCopyDefaultHandlerForURLScheme
[handoff]: https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/Handoff/HandoffFundamentals/HandoffFundamentals.html [handoff]: https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/Handoff/HandoffFundamentals/HandoffFundamentals.html
[activity-type]: https://developer.apple.com/library/ios/documentation/Foundation/Reference/NSUserActivity_Class/index.html#//apple_ref/occ/instp/NSUserActivity/activityType [activity-type]: https://developer.apple.com/library/ios/documentation/Foundation/Reference/NSUserActivity_Class/index.html#//apple_ref/occ/instp/NSUserActivity/activityType
[unity-requirement]: https://help.ubuntu.com/community/UnityLaunchersAndDesktopFiles#Adding_shortcuts_to_a_launcher [unity-requirement]: https://help.ubuntu.com/community/UnityLaunchersAndDesktopFiles#Adding_shortcuts_to_a_launcher
[mas-builds]: ../tutorial/mac-app-store-submission-guide.md [mas-builds]: ../tutorial/mac-app-store-submission-guide.md
[Squirrel-Windows]: https://github.com/Squirrel/Squirrel.Windows [Squirrel-Windows]: https://github.com/Squirrel/Squirrel.Windows
[JumpListBeginListMSDN]: https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-icustomdestinationlist-beginlist [JumpListBeginListMSDN]: https://msdn.microsoft.com/en-us/library/windows/desktop/dd378398(v=vs.85).aspx
[about-panel-options]: https://developer.apple.com/reference/appkit/nsapplication/1428479-orderfrontstandardaboutpanelwith?language=objc [about-panel-options]: https://developer.apple.com/reference/appkit/nsapplication/1428479-orderfrontstandardaboutpanelwith?language=objc
### `app.name` ### `app.name`
@@ -1543,6 +1545,19 @@ This is the user agent that will be used when no user agent is set at the
app has the same user agent. Set to a custom value as early as possible app has the same user agent. Set to a custom value as early as possible
in your app's initialization to ensure that your overridden value is used. in your app's initialization to ensure that your overridden value is used.
### `app.runningUnderRosettaTranslation` _macOS_ _Readonly_ _Deprecated_
A `boolean` which when `true` indicates that the app is currently running
under the [Rosetta Translator Environment](https://en.wikipedia.org/wiki/Rosetta_(software)).
You can use this property to prompt users to download the arm64 version of
your application when they are running the x64 version under Rosetta
incorrectly.
**Deprecated:** This property is superceded by the `runningUnderARM64Translation`
property which detects when the app is being translated to ARM64 in both macOS
and Windows.
### `app.runningUnderARM64Translation` _Readonly_ _macOS_ _Windows_ ### `app.runningUnderARM64Translation` _Readonly_ _macOS_ _Windows_
A `boolean` which when `true` indicates that the app is currently running under A `boolean` which when `true` indicates that the app is currently running under

View File

@@ -137,8 +137,8 @@ application starts.
[squirrel-mac]: https://github.com/Squirrel/Squirrel.Mac [squirrel-mac]: https://github.com/Squirrel/Squirrel.Mac
[server-support]: https://github.com/Squirrel/Squirrel.Mac#server-support [server-support]: https://github.com/Squirrel/Squirrel.Mac#server-support
[squirrel-windows]: https://github.com/Squirrel/Squirrel.Windows [squirrel-windows]: https://github.com/Squirrel/Squirrel.Windows
[installer]: https://github.com/electron-archive/grunt-electron-installer [installer]: https://github.com/electron/grunt-electron-installer
[installer-lib]: https://github.com/electron/windows-installer [installer-lib]: https://github.com/electron/windows-installer
[electron-forge-lib]: https://github.com/electron/forge [electron-forge-lib]: https://github.com/electron/forge
[app-user-model-id]: https://learn.microsoft.com/en-us/windows/win32/shell/appids [app-user-model-id]: https://msdn.microsoft.com/en-us/library/windows/desktop/dd378459(v=vs.85).aspx
[event-emitter]: https://nodejs.org/api/events.html#events_class_eventemitter [event-emitter]: https://nodejs.org/api/events.html#events_class_eventemitter

View File

@@ -16,7 +16,7 @@ module is emitted.
### Example ### Example
```js ```javascript
// In the main process. // In the main process.
const { app, BrowserView, BrowserWindow } = require('electron') const { app, BrowserView, BrowserWindow } = require('electron')
@@ -33,7 +33,7 @@ app.whenReady().then(() => {
### `new BrowserView([options])` _Experimental_ ### `new BrowserView([options])` _Experimental_
* `options` Object (optional) * `options` Object (optional)
* `webPreferences` [WebPreferences](structures/web-preferences.md?inline) (optional) - Settings of web page's features. * `webPreferences` Object (optional) - See [BrowserWindow](browser-window.md).
### Instance Properties ### Instance Properties
@@ -84,16 +84,16 @@ Examples of valid `color` values:
* #ffffff (RRGGBB) * #ffffff (RRGGBB)
* #ffffffff (AARRGGBB) * #ffffffff (AARRGGBB)
* RGB * RGB
* rgb\((\[\d]+),\s*(\[\d]+),\s*(\[\d]+)\) * rgb\(([\d]+),\s*([\d]+),\s*([\d]+)\)
* e.g. rgb(255, 255, 255) * e.g. rgb(255, 255, 255)
* RGBA * RGBA
* rgba\((\[\d]+),\s*(\[\d]+),\s*(\[\d]+),\s*(\[\d.]+)\) * rgba\(([\d]+),\s*([\d]+),\s*([\d]+),\s*([\d.]+)\)
* e.g. rgba(255, 255, 255, 1.0) * e.g. rgba(255, 255, 255, 1.0)
* HSL * HSL
* hsl\((-?\[\d.]+),\s*(\[\d.]+)%,\s*(\[\d.]+)%\) * hsl\((-?[\d.]+),\s*([\d.]+)%,\s*([\d.]+)%\)
* e.g. hsl(200, 20%, 50%) * e.g. hsl(200, 20%, 50%)
* HSLA * HSLA
* hsla\((-?\[\d.]+),\s*(\[\d.]+)%,\s*(\[\d.]+)%,\s*(\[\d.]+)\) * hsla\((-?[\d.]+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)
* e.g. hsla(200, 20%, 50%, 0.5) * e.g. hsla(200, 20%, 50%, 0.5)
* Color name * Color name
* Options are listed in [SkParseColor.cpp](https://source.chromium.org/chromium/chromium/src/+/main:third_party/skia/src/utils/SkParseColor.cpp;l=11-152;drc=eea4bf52cb0d55e2a39c828b017c80a5ee054148) * Options are listed in [SkParseColor.cpp](https://source.chromium.org/chromium/chromium/src/+/main:third_party/skia/src/utils/SkParseColor.cpp;l=11-152;drc=eea4bf52cb0d55e2a39c828b017c80a5ee054148)

View File

@@ -7,7 +7,7 @@ Process: [Main](../glossary.md#main-process)
This module cannot be used until the `ready` event of the `app` This module cannot be used until the `ready` event of the `app`
module is emitted. module is emitted.
```js ```javascript
// In the main process. // In the main process.
const { BrowserWindow } = require('electron') const { BrowserWindow } = require('electron')
@@ -38,7 +38,7 @@ While loading the page, the `ready-to-show` event will be emitted when the rende
process has rendered the page for the first time if the window has not been shown yet. Showing process has rendered the page for the first time if the window has not been shown yet. Showing
the window after this event will have no visual flash: the window after this event will have no visual flash:
```js ```javascript
const { BrowserWindow } = require('electron') const { BrowserWindow } = require('electron')
const win = new BrowserWindow({ show: false }) const win = new BrowserWindow({ show: false })
win.once('ready-to-show', () => { win.once('ready-to-show', () => {
@@ -59,7 +59,7 @@ For a complex app, the `ready-to-show` event could be emitted too late, making
the app feel slow. In this case, it is recommended to show the window the app feel slow. In this case, it is recommended to show the window
immediately, and use a `backgroundColor` close to your app's background: immediately, and use a `backgroundColor` close to your app's background:
```js ```javascript
const { BrowserWindow } = require('electron') const { BrowserWindow } = require('electron')
const win = new BrowserWindow({ backgroundColor: '#2e2c29' }) const win = new BrowserWindow({ backgroundColor: '#2e2c29' })
@@ -85,7 +85,7 @@ For more information about these color types see valid options in [win.setBackgr
By using `parent` option, you can create child windows: By using `parent` option, you can create child windows:
```js ```javascript
const { BrowserWindow } = require('electron') const { BrowserWindow } = require('electron')
const top = new BrowserWindow() const top = new BrowserWindow()
@@ -101,10 +101,9 @@ The `child` window will always show on top of the `top` window.
A modal window is a child window that disables parent window, to create a modal A modal window is a child window that disables parent window, to create a modal
window, you have to set both `parent` and `modal` options: window, you have to set both `parent` and `modal` options:
```js ```javascript
const { BrowserWindow } = require('electron') const { BrowserWindow } = require('electron')
const top = new BrowserWindow()
const child = new BrowserWindow({ parent: top, modal: true, show: false }) const child = new BrowserWindow({ parent: top, modal: true, show: false })
child.loadURL('https://github.com') child.loadURL('https://github.com')
child.once('ready-to-show', () => { child.once('ready-to-show', () => {
@@ -152,7 +151,294 @@ It creates a new `BrowserWindow` with native properties as set by the `options`.
### `new BrowserWindow([options])` ### `new BrowserWindow([options])`
* `options` [BrowserWindowConstructorOptions](structures/browser-window-options.md?inline) (optional) * `options` Object (optional)
* `width` Integer (optional) - Window's width in pixels. Default is `800`.
* `height` Integer (optional) - Window's height in pixels. Default is `600`.
* `x` Integer (optional) - (**required** if y is used) Window's left offset from screen.
Default is to center the window.
* `y` Integer (optional) - (**required** if x is used) Window's top offset from screen.
Default is to center the window.
* `useContentSize` boolean (optional) - The `width` and `height` would be used as web
page's size, which means the actual window's size will include window
frame's size and be slightly larger. Default is `false`.
* `center` boolean (optional) - Show window in the center of the screen. Default is `false`.
* `minWidth` Integer (optional) - Window's minimum width. Default is `0`.
* `minHeight` Integer (optional) - Window's minimum height. Default is `0`.
* `maxWidth` Integer (optional) - Window's maximum width. Default is no limit.
* `maxHeight` Integer (optional) - Window's maximum height. Default is no limit.
* `resizable` boolean (optional) - Whether window is resizable. Default is `true`.
* `movable` boolean (optional) _macOS_ _Windows_ - Whether window is
movable. This is not implemented on Linux. Default is `true`.
* `minimizable` boolean (optional) _macOS_ _Windows_ - Whether window is
minimizable. This is not implemented on Linux. Default is `true`.
* `maximizable` boolean (optional) _macOS_ _Windows_ - Whether window is
maximizable. This is not implemented on Linux. Default is `true`.
* `closable` boolean (optional) _macOS_ _Windows_ - Whether window is
closable. This is not implemented on Linux. Default is `true`.
* `focusable` boolean (optional) - Whether the window can be focused. Default is
`true`. On Windows setting `focusable: false` also implies setting
`skipTaskbar: true`. On Linux setting `focusable: false` makes the window
stop interacting with wm, so the window will always stay on top in all
workspaces.
* `alwaysOnTop` boolean (optional) - Whether the window should always stay on top of
other windows. Default is `false`.
* `fullscreen` boolean (optional) - Whether the window should show in fullscreen. When
explicitly set to `false` the fullscreen button will be hidden or disabled
on macOS. Default is `false`.
* `fullscreenable` boolean (optional) - Whether the window can be put into fullscreen
mode. On macOS, also whether the maximize/zoom button should toggle full
screen mode or maximize window. Default is `true`.
* `simpleFullscreen` boolean (optional) _macOS_ - Use pre-Lion fullscreen on
macOS. Default is `false`.
* `skipTaskbar` boolean (optional) _macOS_ _Windows_ - Whether to show the window in taskbar.
Default is `false`.
* `hiddenInMissionControl` boolean (optional) _macOS_ - Whether window should be hidden when the user toggles into mission control.
* `kiosk` boolean (optional) - Whether the window is in kiosk mode. Default is `false`.
* `title` string (optional) - Default window title. Default is `"Electron"`. If the HTML tag `<title>` is defined in the HTML file loaded by `loadURL()`, this property will be ignored.
* `icon` ([NativeImage](native-image.md) | string) (optional) - The window icon. On Windows it is
recommended to use `ICO` icons to get best visual effects, you can also
leave it undefined so the executable's icon will be used.
* `show` boolean (optional) - Whether window should be shown when created. Default is
`true`.
* `paintWhenInitiallyHidden` boolean (optional) - Whether the renderer should be active when `show` is `false` and it has just been created. In order for `document.visibilityState` to work correctly on first load with `show: false` you should set this to `false`. Setting this to `false` will cause the `ready-to-show` event to not fire. Default is `true`.
* `frame` boolean (optional) - Specify `false` to create a
[frameless window](../tutorial/window-customization.md#create-frameless-windows). Default is `true`.
* `parent` BrowserWindow (optional) - Specify parent window. Default is `null`.
* `modal` boolean (optional) - Whether this is a modal window. This only works when the
window is a child window. Default is `false`.
* `acceptFirstMouse` boolean (optional) _macOS_ - Whether clicking an
inactive window will also click through to the web contents. Default is
`false` on macOS. This option is not configurable on other platforms.
* `disableAutoHideCursor` boolean (optional) - Whether to hide cursor when typing.
Default is `false`.
* `autoHideMenuBar` boolean (optional) - Auto hide the menu bar unless the `Alt`
key is pressed. Default is `false`.
* `enableLargerThanScreen` boolean (optional) _macOS_ - Enable the window to
be resized larger than screen. Only relevant for macOS, as other OSes
allow larger-than-screen windows by default. Default is `false`.
* `backgroundColor` string (optional) - The window's background color in Hex, RGB, RGBA, HSL, HSLA or named CSS color format. Alpha in #AARRGGBB format is supported if `transparent` is set to `true`. Default is `#FFF` (white). See [win.setBackgroundColor](browser-window.md#winsetbackgroundcolorbackgroundcolor) for more information.
* `hasShadow` boolean (optional) - Whether window should have a shadow. Default is `true`.
* `opacity` number (optional) _macOS_ _Windows_ - Set the initial opacity of
the window, between 0.0 (fully transparent) and 1.0 (fully opaque). This
is only implemented on Windows and macOS.
* `darkTheme` boolean (optional) - Forces using dark theme for the window, only works on
some GTK+3 desktop environments. Default is `false`.
* `transparent` boolean (optional) - Makes the window [transparent](../tutorial/window-customization.md#create-transparent-windows).
Default is `false`. On Windows, does not work unless the window is frameless.
* `type` string (optional) - The type of window, default is normal window. See more about
this below.
* `visualEffectState` string (optional) _macOS_ - Specify how the material
appearance should reflect window activity state on macOS. Must be used
with the `vibrancy` property. Possible values are:
* `followWindow` - The backdrop should automatically appear active when the window is active, and inactive when it is not. This is the default.
* `active` - The backdrop should always appear active.
* `inactive` - The backdrop should always appear inactive.
* `titleBarStyle` string (optional) _macOS_ _Windows_ - The style of window title bar.
Default is `default`. Possible values are:
* `default` - Results in the standard title bar for macOS or Windows respectively.
* `hidden` - Results in a hidden title bar and a full size content window. On macOS, the window still has the standard window controls (“traffic lights”) in the top left. On Windows, when combined with `titleBarOverlay: true` it will activate the Window Controls Overlay (see `titleBarOverlay` for more information), otherwise no window controls will be shown.
* `hiddenInset` _macOS_ - Only on macOS, results in a hidden title bar
with an alternative look where the traffic light buttons are slightly
more inset from the window edge.
* `customButtonsOnHover` _macOS_ - Only on macOS, results in a hidden
title bar and a full size content window, the traffic light buttons will
display when being hovered over in the top left of the window.
**Note:** This option is currently experimental.
* `trafficLightPosition` [Point](structures/point.md) (optional) _macOS_ -
Set a custom position for the traffic light buttons in frameless windows.
* `roundedCorners` boolean (optional) _macOS_ - Whether frameless window
should have rounded corners on macOS. Default is `true`. Setting this property
to `false` will prevent the window from being fullscreenable.
* `fullscreenWindowTitle` boolean (optional) _macOS_ _Deprecated_ - Shows
the title in the title bar in full screen mode on macOS for `hiddenInset`
titleBarStyle. Default is `false`.
* `thickFrame` boolean (optional) - Use `WS_THICKFRAME` style for frameless windows on
Windows, which adds standard window frame. Setting it to `false` will remove
window shadow and window animations. Default is `true`.
* `vibrancy` string (optional) _macOS_ - Add a type of vibrancy effect to
the window, only on macOS. Can be `appearance-based`, `light`, `dark`,
`titlebar`, `selection`, `menu`, `popover`, `sidebar`, `medium-light`,
`ultra-dark`, `header`, `sheet`, `window`, `hud`, `fullscreen-ui`,
`tooltip`, `content`, `under-window`, or `under-page`. Please note that
`appearance-based`, `light`, `dark`, `medium-light`, and `ultra-dark` are
deprecated and have been removed in macOS Catalina (10.15).
* `zoomToPageWidth` boolean (optional) _macOS_ - Controls the behavior on
macOS when option-clicking the green stoplight button on the toolbar or by
clicking the Window > Zoom menu item. If `true`, the window will grow to
the preferred width of the web page when zoomed, `false` will cause it to
zoom to the width of the screen. This will also affect the behavior when
calling `maximize()` directly. Default is `false`.
* `tabbingIdentifier` string (optional) _macOS_ - Tab group name, allows
opening the window as a native tab on macOS 10.12+. Windows with the same
tabbing identifier will be grouped together. This also adds a native new
tab button to your window's tab bar and allows your `app` and window to
receive the `new-window-for-tab` event.
* `webPreferences` Object (optional) - Settings of web page's features.
* `devTools` boolean (optional) - Whether to enable DevTools. If it is set to `false`, can not use `BrowserWindow.webContents.openDevTools()` to open DevTools. Default is `true`.
* `nodeIntegration` boolean (optional) - Whether node integration is enabled.
Default is `false`.
* `nodeIntegrationInWorker` boolean (optional) - Whether node integration is
enabled in web workers. Default is `false`. More about this can be found
in [Multithreading](../tutorial/multithreading.md).
* `nodeIntegrationInSubFrames` boolean (optional) - Experimental option for
enabling Node.js support in sub-frames such as iframes and child windows. All your preloads will load for
every iframe, you can use `process.isMainFrame` to determine if you are
in the main frame or not.
* `preload` string (optional) - Specifies a script that will be loaded before other
scripts run in the page. This script will always have access to node APIs
no matter whether node integration is turned on or off. The value should
be the absolute file path to the script.
When node integration is turned off, the preload script can reintroduce
Node global symbols back to the global scope. See example
[here](context-bridge.md#exposing-node-global-symbols).
* `sandbox` boolean (optional) - If set, this will sandbox the renderer
associated with the window, making it compatible with the Chromium
OS-level sandbox and disabling the Node.js engine. This is not the same as
the `nodeIntegration` option and the APIs available to the preload script
are more limited. Read more about the option [here](../tutorial/sandbox.md).
* `session` [Session](session.md#class-session) (optional) - Sets the session used by the
page. Instead of passing the Session object directly, you can also choose to
use the `partition` option instead, which accepts a partition string. When
both `session` and `partition` are provided, `session` will be preferred.
Default is the default session.
* `partition` string (optional) - Sets the session used by the page according to the
session's partition string. If `partition` starts with `persist:`, the page
will use a persistent session available to all pages in the app with the
same `partition`. If there is no `persist:` prefix, the page will use an
in-memory session. By assigning the same `partition`, multiple pages can share
the same session. Default is the default session.
* `zoomFactor` number (optional) - The default zoom factor of the page, `3.0` represents
`300%`. Default is `1.0`.
* `javascript` boolean (optional) - Enables JavaScript support. Default is `true`.
* `webSecurity` boolean (optional) - When `false`, it will disable the
same-origin policy (usually using testing websites by people), and set
`allowRunningInsecureContent` to `true` if this options has not been set
by user. Default is `true`.
* `allowRunningInsecureContent` boolean (optional) - Allow an https page to run
JavaScript, CSS or plugins from http URLs. Default is `false`.
* `images` boolean (optional) - Enables image support. Default is `true`.
* `imageAnimationPolicy` string (optional) - Specifies how to run image animations (E.g. GIFs). Can be `animate`, `animateOnce` or `noAnimation`. Default is `animate`.
* `textAreasAreResizable` boolean (optional) - Make TextArea elements resizable. Default
is `true`.
* `webgl` boolean (optional) - Enables WebGL support. Default is `true`.
* `plugins` boolean (optional) - Whether plugins should be enabled. Default is `false`.
* `experimentalFeatures` boolean (optional) - Enables Chromium's experimental features.
Default is `false`.
* `scrollBounce` boolean (optional) _macOS_ - Enables scroll bounce
(rubber banding) effect on macOS. Default is `false`.
* `enableBlinkFeatures` string (optional) - A list of feature strings separated by `,`, like
`CSSVariables,KeyboardEventKey` to enable. The full list of supported feature
strings can be found in the [RuntimeEnabledFeatures.json5][runtime-enabled-features]
file.
* `disableBlinkFeatures` string (optional) - A list of feature strings separated by `,`,
like `CSSVariables,KeyboardEventKey` to disable. The full list of supported
feature strings can be found in the
[RuntimeEnabledFeatures.json5][runtime-enabled-features] file.
* `defaultFontFamily` Object (optional) - Sets the default font for the font-family.
* `standard` string (optional) - Defaults to `Times New Roman`.
* `serif` string (optional) - Defaults to `Times New Roman`.
* `sansSerif` string (optional) - Defaults to `Arial`.
* `monospace` string (optional) - Defaults to `Courier New`.
* `cursive` string (optional) - Defaults to `Script`.
* `fantasy` string (optional) - Defaults to `Impact`.
* `defaultFontSize` Integer (optional) - Defaults to `16`.
* `defaultMonospaceFontSize` Integer (optional) - Defaults to `13`.
* `minimumFontSize` Integer (optional) - Defaults to `0`.
* `defaultEncoding` string (optional) - Defaults to `ISO-8859-1`.
* `backgroundThrottling` boolean (optional) - Whether to throttle animations and timers
when the page becomes background. This also affects the
[Page Visibility API](#page-visibility). Defaults to `true`.
* `offscreen` boolean (optional) - Whether to enable offscreen rendering for the browser
window. Defaults to `false`. See the
[offscreen rendering tutorial](../tutorial/offscreen-rendering.md) for
more details.
* `contextIsolation` boolean (optional) - Whether to run Electron APIs and
the specified `preload` script in a separate JavaScript context. Defaults
to `true`. The context that the `preload` script runs in will only have
access to its own dedicated `document` and `window` globals, as well as
its own set of JavaScript builtins (`Array`, `Object`, `JSON`, etc.),
which are all invisible to the loaded content. The Electron API will only
be available in the `preload` script and not the loaded page. This option
should be used when loading potentially untrusted remote content to ensure
the loaded content cannot tamper with the `preload` script and any
Electron APIs being used. This option uses the same technique used by
[Chrome Content Scripts][chrome-content-scripts]. You can access this
context in the dev tools by selecting the 'Electron Isolated Context'
entry in the combo box at the top of the Console tab.
* `webviewTag` boolean (optional) - Whether to enable the [`<webview>` tag](webview-tag.md).
Defaults to `false`. **Note:** The
`preload` script configured for the `<webview>` will have node integration
enabled when it is executed so you should ensure remote/untrusted content
is not able to create a `<webview>` tag with a possibly malicious `preload`
script. You can use the `will-attach-webview` event on [webContents](web-contents.md)
to strip away the `preload` script and to validate or alter the
`<webview>`'s initial settings.
* `additionalArguments` string[] (optional) - A list of strings that will be appended
to `process.argv` in the renderer process of this app. Useful for passing small
bits of data down to renderer process preload scripts.
* `safeDialogs` boolean (optional) - Whether to enable browser style
consecutive dialog protection. Default is `false`.
* `safeDialogsMessage` string (optional) - The message to display when
consecutive dialog protection is triggered. If not defined the default
message would be used, note that currently the default message is in
English and not localized.
* `disableDialogs` boolean (optional) - Whether to disable dialogs
completely. Overrides `safeDialogs`. Default is `false`.
* `navigateOnDragDrop` boolean (optional) - Whether dragging and dropping a
file or link onto the page causes a navigation. Default is `false`.
* `autoplayPolicy` string (optional) - Autoplay policy to apply to
content in the window, can be `no-user-gesture-required`,
`user-gesture-required`, `document-user-activation-required`. Defaults to
`no-user-gesture-required`.
* `disableHtmlFullscreenWindowResize` boolean (optional) - Whether to
prevent the window from resizing when entering HTML Fullscreen. Default
is `false`.
* `accessibleTitle` string (optional) - An alternative title string provided only
to accessibility tools such as screen readers. This string is not directly
visible to users.
* `spellcheck` boolean (optional) - Whether to enable the builtin spellchecker.
Default is `true`.
* `enableWebSQL` boolean (optional) - Whether to enable the [WebSQL api](https://www.w3.org/TR/webdatabase/).
Default is `true`.
* `v8CacheOptions` string (optional) - Enforces the v8 code caching policy
used by blink. Accepted values are
* `none` - Disables code caching
* `code` - Heuristic based code caching
* `bypassHeatCheck` - Bypass code caching heuristics but with lazy compilation
* `bypassHeatCheckAndEagerCompile` - Same as above except compilation is eager.
Default policy is `code`.
* `enablePreferredSizeMode` boolean (optional) - Whether to enable
preferred size mode. The preferred size is the minimum size needed to
contain the layout of the document—without requiring scrolling. Enabling
this will cause the `preferred-size-changed` event to be emitted on the
`WebContents` when the preferred size changes. Default is `false`.
* `titleBarOverlay` Object | Boolean (optional) - When using a frameless window in conjunction with `win.setWindowButtonVisibility(true)` on macOS or using a `titleBarStyle` so that the standard window controls ("traffic lights" on macOS) are visible, this property enables the Window Controls Overlay [JavaScript APIs][overlay-javascript-apis] and [CSS Environment Variables][overlay-css-env-vars]. Specifying `true` will result in an overlay with default system colors. Default is `false`.
* `color` String (optional) _Windows_ - The CSS color of the Window Controls Overlay when enabled. Default is the system color.
* `symbolColor` String (optional) _Windows_ - The CSS color of the symbols on the Window Controls Overlay when enabled. Default is the system color.
* `height` Integer (optional) _macOS_ _Windows_ - The height of the title bar and Window Controls Overlay in pixels. Default is system height.
When setting minimum or maximum window size with `minWidth`/`maxWidth`/
`minHeight`/`maxHeight`, it only constrains the users. It won't prevent you from
passing a size that does not follow size constraints to `setBounds`/`setSize` or
to the constructor of `BrowserWindow`.
The possible values and behaviors of the `type` option are platform dependent.
Possible values are:
* On Linux, possible types are `desktop`, `dock`, `toolbar`, `splash`,
`notification`.
* On macOS, possible types are `desktop`, `textured`, `panel`.
* The `textured` type adds metal gradient appearance
(`NSWindowStyleMaskTexturedBackground`).
* The `desktop` type places the window at the desktop background window level
(`kCGDesktopWindowLevel - 1`). Note that desktop window will not receive
focus, keyboard or mouse events, but you can use `globalShortcut` to receive
input sparingly.
* The `panel` type enables the window to float on top of full-screened apps
by adding the `NSWindowStyleMaskNonactivatingPanel` style mask,normally
reserved for NSPanel, at runtime. Also, the window will appear on all
spaces (desktops).
* On Windows, possible type is `toolbar`.
### Instance Events ### Instance Events
@@ -188,7 +474,7 @@ window should be closed, which will also be called when the window is
reloaded. In Electron, returning any value other than `undefined` would cancel the reloaded. In Electron, returning any value other than `undefined` would cancel the
close. For example: close. For example:
```js ```javascript
window.onbeforeunload = (e) => { window.onbeforeunload = (e) => {
console.log('I do not want to be closed') console.log('I do not want to be closed')
@@ -309,7 +595,7 @@ Emitted when the window is being moved to a new position.
Emitted once when the window is moved to a new position. Emitted once when the window is moved to a new position.
**Note**: On macOS this event is an alias of `move`. __Note__: On macOS this event is an alias of `move`.
#### Event: 'enter-full-screen' #### Event: 'enter-full-screen'
@@ -343,7 +629,7 @@ Returns:
* `event` Event * `event` Event
* `command` string * `command` string
Emitted when an [App Command](https://learn.microsoft.com/en-us/windows/win32/inputdev/wm-appcommand) Emitted when an [App Command](https://msdn.microsoft.com/en-us/library/windows/desktop/ms646275(v=vs.85).aspx)
is invoked. These are typically related to keyboard media keys or browser is invoked. These are typically related to keyboard media keys or browser
commands, as well as the "Back" button built into some mice on Windows. commands, as well as the "Back" button built into some mice on Windows.
@@ -351,7 +637,7 @@ Commands are lowercased, underscores are replaced with hyphens, and the
`APPCOMMAND_` prefix is stripped off. `APPCOMMAND_` prefix is stripped off.
e.g. `APPCOMMAND_BROWSER_BACKWARD` is emitted as `browser-backward`. e.g. `APPCOMMAND_BROWSER_BACKWARD` is emitted as `browser-backward`.
```js ```javascript
const { BrowserWindow } = require('electron') const { BrowserWindow } = require('electron')
const win = new BrowserWindow() const win = new BrowserWindow()
win.on('app-command', (e, cmd) => { win.on('app-command', (e, cmd) => {
@@ -367,6 +653,36 @@ The following app commands are explicitly supported on Linux:
* `browser-backward` * `browser-backward`
* `browser-forward` * `browser-forward`
#### Event: 'scroll-touch-begin' _macOS_ _Deprecated_
Emitted when scroll wheel event phase has begun.
> **Note**
> This event is deprecated beginning in Electron 22.0.0. See [Breaking
> Changes](breaking-changes.md#deprecated-browserwindow-scroll-touch--events)
> for details of how to migrate to using the [WebContents
> `input-event`](api/web-contents.md#event-input-event) event.
#### Event: 'scroll-touch-end' _macOS_ _Deprecated_
Emitted when scroll wheel event phase has ended.
> **Note**
> This event is deprecated beginning in Electron 22.0.0. See [Breaking
> Changes](breaking-changes.md#deprecated-browserwindow-scroll-touch--events)
> for details of how to migrate to using the [WebContents
> `input-event`](api/web-contents.md#event-input-event) event.
#### Event: 'scroll-touch-edge' _macOS_ _Deprecated_
Emitted when scroll wheel event phase filed upon reaching the edge of element.
> **Note**
> This event is deprecated beginning in Electron 22.0.0. See [Breaking
> Changes](breaking-changes.md#deprecated-browserwindow-scroll-touch--events)
> for details of how to migrate to using the [WebContents
> `input-event`](api/web-contents.md#event-input-event) event.
#### Event: 'swipe' _macOS_ #### Event: 'swipe' _macOS_
Returns: Returns:
@@ -456,7 +772,7 @@ Returns `BrowserWindow | null` - The window with the given `id`.
Objects created with `new BrowserWindow` have the following properties: Objects created with `new BrowserWindow` have the following properties:
```js ```javascript
const { BrowserWindow } = require('electron') const { BrowserWindow } = require('electron')
// In this example `win` is our instance // In this example `win` is our instance
const win = new BrowserWindow({ width: 800, height: 600 }) const win = new BrowserWindow({ width: 800, height: 600 })
@@ -475,10 +791,6 @@ events.
A `Integer` property representing the unique ID of the window. Each ID is unique among all `BrowserWindow` instances of the entire Electron application. A `Integer` property representing the unique ID of the window. Each ID is unique among all `BrowserWindow` instances of the entire Electron application.
#### `win.tabbingIdentifier` _macOS_ _Readonly_
A `string` (optional) property that is equal to the `tabbingIdentifier` passed to the `BrowserWindow` constructor or `undefined` if none was set.
#### `win.autoHideMenuBar` #### `win.autoHideMenuBar`
A `boolean` property that determines whether the window menu bar should hide itself automatically. Once set, the menu bar will only show when users press the single `Alt` key. A `boolean` property that determines whether the window menu bar should hide itself automatically. Once set, the menu bar will only show when users press the single `Alt` key.
@@ -572,7 +884,7 @@ On Linux the setter is a no-op, although the getter returns `true`.
A `boolean` property that determines whether the window is excluded from the applications Windows menu. `false` by default. A `boolean` property that determines whether the window is excluded from the applications Windows menu. `false` by default.
```js @ts-expect-error=[11] ```js
const win = new BrowserWindow({ height: 600, width: 600 }) const win = new BrowserWindow({ height: 600, width: 600 })
const template = [ const template = [
@@ -642,7 +954,7 @@ Hides the window.
#### `win.isVisible()` #### `win.isVisible()`
Returns `boolean` - Whether the window is visible to the user in the foreground of the app. Returns `boolean` - Whether the window is visible to the user.
#### `win.isModal()` #### `win.isModal()`
@@ -680,8 +992,6 @@ Returns `boolean` - Whether the window is minimized.
Sets whether the window should be in fullscreen mode. Sets whether the window should be in fullscreen mode.
**Note:** On macOS, fullscreen transitions take place asynchronously. If further actions depend on the fullscreen state, use the ['enter-full-screen'](browser-window.md#event-enter-full-screen) or ['leave-full-screen'](browser-window.md#event-leave-full-screen) events.
#### `win.isFullScreen()` #### `win.isFullScreen()`
Returns `boolean` - Whether the window is in fullscreen mode. Returns `boolean` - Whether the window is in fullscreen mode.
@@ -726,8 +1036,6 @@ height areas you have within the overall content view.
The aspect ratio is not respected when window is resized programmatically with The aspect ratio is not respected when window is resized programmatically with
APIs like `win.setSize`. APIs like `win.setSize`.
To reset an aspect ratio, pass 0 as the `aspectRatio` value: `win.setAspectRatio(0)`.
#### `win.setBackgroundColor(backgroundColor)` #### `win.setBackgroundColor(backgroundColor)`
* `backgroundColor` string - Color in Hex, RGB, RGBA, HSL, HSLA or named CSS color format. The alpha channel is optional for the hex type. * `backgroundColor` string - Color in Hex, RGB, RGBA, HSL, HSLA or named CSS color format. The alpha channel is optional for the hex type.
@@ -740,16 +1048,16 @@ Examples of valid `backgroundColor` values:
* #ffffff (RGB) * #ffffff (RGB)
* #ffffffff (ARGB) * #ffffffff (ARGB)
* RGB * RGB
* rgb\((\[\d]+),\s*(\[\d]+),\s*(\[\d]+)\) * rgb\(([\d]+),\s*([\d]+),\s*([\d]+)\)
* e.g. rgb(255, 255, 255) * e.g. rgb(255, 255, 255)
* RGBA * RGBA
* rgba\((\[\d]+),\s*(\[\d]+),\s*(\[\d]+),\s*(\[\d.]+)\) * rgba\(([\d]+),\s*([\d]+),\s*([\d]+),\s*([\d.]+)\)
* e.g. rgba(255, 255, 255, 1.0) * e.g. rgba(255, 255, 255, 1.0)
* HSL * HSL
* hsl\((-?\[\d.]+),\s*(\[\d.]+)%,\s*(\[\d.]+)%\) * hsl\((-?[\d.]+),\s*([\d.]+)%,\s*([\d.]+)%\)
* e.g. hsl(200, 20%, 50%) * e.g. hsl(200, 20%, 50%)
* HSLA * HSLA
* hsla\((-?\[\d.]+),\s*(\[\d.]+)%,\s*(\[\d.]+)%,\s*(\[\d.]+)\) * hsla\((-?[\d.]+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)
* e.g. hsla(200, 20%, 50%, 0.5) * e.g. hsla(200, 20%, 50%, 0.5)
* Color name * Color name
* Options are listed in [SkParseColor.cpp](https://source.chromium.org/chromium/chromium/src/+/main:third_party/skia/src/utils/SkParseColor.cpp;l=11-152;drc=eea4bf52cb0d55e2a39c828b017c80a5ee054148) * Options are listed in [SkParseColor.cpp](https://source.chromium.org/chromium/chromium/src/+/main:third_party/skia/src/utils/SkParseColor.cpp;l=11-152;drc=eea4bf52cb0d55e2a39c828b017c80a5ee054148)
@@ -780,7 +1088,7 @@ Closes the currently open [Quick Look][quick-look] panel.
Resizes and moves the window to the supplied bounds. Any properties that are not supplied will default to their current values. Resizes and moves the window to the supplied bounds. Any properties that are not supplied will default to their current values.
```js ```javascript
const { BrowserWindow } = require('electron') const { BrowserWindow } = require('electron')
const win = new BrowserWindow() const win = new BrowserWindow()
@@ -794,14 +1102,10 @@ win.setBounds({ width: 100 })
console.log(win.getBounds()) console.log(win.getBounds())
``` ```
**Note:** On macOS, the y-coordinate value cannot be smaller than the [Tray](tray.md) height. The tray height has changed over time and depends on the operating system, but is between 20-40px. Passing a value lower than the tray height will result in a window that is flush to the tray.
#### `win.getBounds()` #### `win.getBounds()`
Returns [`Rectangle`](structures/rectangle.md) - The `bounds` of the window as `Object`. Returns [`Rectangle`](structures/rectangle.md) - The `bounds` of the window as `Object`.
**Note:** On macOS, the y-coordinate value returned will be at minimum the [Tray](tray.md) height. For example, calling `win.setBounds({ x: 25, y: 20, width: 800, height: 600 })` with a tray height of 38 means that `win.getBounds()` will return `{ x: 25, y: 38, width: 800, height: 600 }`.
#### `win.getBackgroundColor()` #### `win.getBackgroundColor()`
Returns `string` - Gets the background color of the window in Hex (`#RRGGBB`) format. Returns `string` - Gets the background color of the window in Hex (`#RRGGBB`) format.
@@ -1035,7 +1339,7 @@ Changes the attachment point for sheets on macOS. By default, sheets are
attached just below the window frame, but you may want to display them beneath attached just below the window frame, but you may want to display them beneath
a HTML-rendered toolbar. For example: a HTML-rendered toolbar. For example:
```js ```javascript
const { BrowserWindow } = require('electron') const { BrowserWindow } = require('electron')
const win = new BrowserWindow() const win = new BrowserWindow()
@@ -1096,8 +1400,8 @@ The native type of the handle is `HWND` on Windows, `NSView*` on macOS, and
* `message` Integer * `message` Integer
* `callback` Function * `callback` Function
* `wParam` Buffer - The `wParam` provided to the WndProc * `wParam` any - The `wParam` provided to the WndProc
* `lParam` Buffer - The `lParam` provided to the WndProc * `lParam` any - The `lParam` provided to the WndProc
Hooks a windows message. The `callback` is called when Hooks a windows message. The `callback` is called when
the message is received in the WndProc. the message is received in the WndProc.
@@ -1178,14 +1482,11 @@ To ensure that file URLs are properly formatted, it is recommended to use
Node's [`url.format`](https://nodejs.org/api/url.html#url_url_format_urlobject) Node's [`url.format`](https://nodejs.org/api/url.html#url_url_format_urlobject)
method: method:
```js ```javascript
const { BrowserWindow } = require('electron')
const win = new BrowserWindow()
const url = require('url').format({ const url = require('url').format({
protocol: 'file', protocol: 'file',
slashes: true, slashes: true,
pathname: require('node:path').join(__dirname, 'index.html') pathname: require('path').join(__dirname, 'index.html')
}) })
win.loadURL(url) win.loadURL(url)
@@ -1194,10 +1495,7 @@ win.loadURL(url)
You can load a URL using a `POST` request with URL-encoded data by doing You can load a URL using a `POST` request with URL-encoded data by doing
the following: the following:
```js ```javascript
const { BrowserWindow } = require('electron')
const win = new BrowserWindow()
win.loadURL('http://localhost:8000/post', { win.loadURL('http://localhost:8000/post', {
postData: [{ postData: [{
type: 'rawData', type: 'rawData',
@@ -1243,7 +1541,7 @@ Remove the window's menu bar.
* `options` Object (optional) * `options` Object (optional)
* `mode` string _Windows_ - Mode for the progress bar. Can be `none`, `normal`, `indeterminate`, `error` or `paused`. * `mode` string _Windows_ - Mode for the progress bar. Can be `none`, `normal`, `indeterminate`, `error` or `paused`.
Sets progress value in progress bar. Valid range is \[0, 1.0]. Sets progress value in progress bar. Valid range is [0, 1.0].
Remove progress bar when progress < 0; Remove progress bar when progress < 0;
Change to indeterminate mode when progress > 1. Change to indeterminate mode when progress > 1.
@@ -1267,13 +1565,6 @@ screen readers
Sets a 16 x 16 pixel overlay onto the current taskbar icon, usually used to Sets a 16 x 16 pixel overlay onto the current taskbar icon, usually used to
convey some sort of application status or to passively notify the user. convey some sort of application status or to passively notify the user.
#### `win.invalidateShadow()` _macOS_
Invalidates the window shadow so that it is recomputed based on the current window shape.
`BrowserWindows` that are transparent can sometimes leave behind visual artifacts on macOS.
This method can be used to clear these artifacts when, for example, performing an animation.
#### `win.setHasShadow(hasShadow)` #### `win.setHasShadow(hasShadow)`
* `hasShadow` boolean * `hasShadow` boolean
@@ -1289,7 +1580,7 @@ Returns `boolean` - Whether the window has a shadow.
* `opacity` number - between 0.0 (fully transparent) and 1.0 (fully opaque) * `opacity` number - between 0.0 (fully transparent) and 1.0 (fully opaque)
Sets the opacity of the window. On Linux, does nothing. Out of bound number Sets the opacity of the window. On Linux, does nothing. Out of bound number
values are clamped to the \[0, 1] range. values are clamped to the [0, 1] range.
#### `win.getOpacity()` #### `win.getOpacity()`
@@ -1364,13 +1655,13 @@ in the taskbar.
#### `win.setAppDetails(options)` _Windows_ #### `win.setAppDetails(options)` _Windows_
* `options` Object * `options` Object
* `appId` string (optional) - Window's [App User Model ID](https://learn.microsoft.com/en-us/windows/win32/shell/appids). * `appId` string (optional) - Window's [App User Model ID](https://msdn.microsoft.com/en-us/library/windows/desktop/dd391569(v=vs.85).aspx).
It has to be set, otherwise the other options will have no effect. It has to be set, otherwise the other options will have no effect.
* `appIconPath` string (optional) - Window's [Relaunch Icon](https://learn.microsoft.com/en-us/windows/win32/properties/props-system-appusermodel-relaunchiconresource). * `appIconPath` string (optional) - Window's [Relaunch Icon](https://msdn.microsoft.com/en-us/library/windows/desktop/dd391573(v=vs.85).aspx).
* `appIconIndex` Integer (optional) - Index of the icon in `appIconPath`. * `appIconIndex` Integer (optional) - Index of the icon in `appIconPath`.
Ignored when `appIconPath` is not set. Default is `0`. Ignored when `appIconPath` is not set. Default is `0`.
* `relaunchCommand` string (optional) - Window's [Relaunch Command](https://learn.microsoft.com/en-us/windows/win32/properties/props-system-appusermodel-relaunchcommand). * `relaunchCommand` string (optional) - Window's [Relaunch Command](https://msdn.microsoft.com/en-us/library/windows/desktop/dd391571(v=vs.85).aspx).
* `relaunchDisplayName` string (optional) - Window's [Relaunch Display Name](https://learn.microsoft.com/en-us/windows/win32/properties/props-system-appusermodel-relaunchdisplaynameresource). * `relaunchDisplayName` string (optional) - Window's [Relaunch Display Name](https://msdn.microsoft.com/en-us/library/windows/desktop/dd391572(v=vs.85).aspx).
Sets the properties for the window's taskbar button. Sets the properties for the window's taskbar button.
@@ -1476,7 +1767,7 @@ On macOS it does not remove the focus from the window.
#### `win.isFocusable()` _macOS_ _Windows_ #### `win.isFocusable()` _macOS_ _Windows_
Returns `boolean` - Whether the window can be focused. Returns whether the window can be focused.
#### `win.setParentWindow(parent)` #### `win.setParentWindow(parent)`
@@ -1509,10 +1800,6 @@ tabs in the window.
Selects the next tab when native tabs are enabled and there are other Selects the next tab when native tabs are enabled and there are other
tabs in the window. tabs in the window.
#### `win.showAllTabs()` _macOS_
Shows or hides the tab overview when native tabs are enabled.
#### `win.mergeAllWindows()` _macOS_ #### `win.mergeAllWindows()` _macOS_
Merges all windows into one window with multiple tabs when native tabs Merges all windows into one window with multiple tabs when native tabs
@@ -1536,38 +1823,26 @@ Adds a window as a tab on this window, after the tab for the window instance.
#### `win.setVibrancy(type)` _macOS_ #### `win.setVibrancy(type)` _macOS_
* `type` string | null - Can be `titlebar`, `selection`, `menu`, `popover`, `sidebar`, `header`, `sheet`, `window`, `hud`, `fullscreen-ui`, `tooltip`, `content`, `under-window`, or `under-page`. See * `type` string | null - Can be `appearance-based`, `light`, `dark`, `titlebar`,
`selection`, `menu`, `popover`, `sidebar`, `medium-light`, `ultra-dark`, `header`, `sheet`, `window`, `hud`, `fullscreen-ui`, `tooltip`, `content`, `under-window`, or `under-page`. See
the [macOS documentation][vibrancy-docs] for more details. the [macOS documentation][vibrancy-docs] for more details.
Adds a vibrancy effect to the browser window. Passing `null` or an empty string Adds a vibrancy effect to the browser window. Passing `null` or an empty string
will remove the vibrancy effect on the window. will remove the vibrancy effect on the window.
#### `win.setBackgroundMaterial(material)` _Windows_ Note that `appearance-based`, `light`, `dark`, `medium-light`, and `ultra-dark` have been
deprecated and will be removed in an upcoming version of macOS.
* `material` string #### `win.setTrafficLightPosition(position)` _macOS_
* `auto` - Let the Desktop Window Manager (DWM) automatically decide the system-drawn backdrop material for this window. This is the default.
* `none` - Don't draw any system backdrop.
* `mica` - Draw the backdrop material effect corresponding to a long-lived window.
* `acrylic` - Draw the backdrop material effect corresponding to a transient window.
* `tabbed` - Draw the backdrop material effect corresponding to a window with a tabbed title bar.
This method sets the browser window's system-drawn background material, including behind the non-client area. * `position` [Point](structures/point.md)
See the [Windows documentation](https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/ne-dwmapi-dwm_systembackdrop_type) for more details.
**Note:** This method is only supported on Windows 11 22H2 and up.
#### `win.setWindowButtonPosition(position)` _macOS_
* `position` [Point](structures/point.md) | null
Set a custom position for the traffic light buttons in frameless window. Set a custom position for the traffic light buttons in frameless window.
Passing `null` will reset the position to default.
#### `win.getWindowButtonPosition()` _macOS_ #### `win.getTrafficLightPosition()` _macOS_
Returns `Point | null` - The custom position for the traffic light buttons in Returns `Point` - The custom position for the traffic light buttons in
frameless window, `null` will be returned when there is no custom position. frameless window.
#### `win.setTouchBar(touchBar)` _macOS_ #### `win.setTouchBar(touchBar)` _macOS_
@@ -1575,7 +1850,7 @@ frameless window, `null` will be returned when there is no custom position.
Sets the touchBar layout for the current window. Specifying `null` or Sets the touchBar layout for the current window. Specifying `null` or
`undefined` clears the touch bar. This method only has an effect if the `undefined` clears the touch bar. This method only has an effect if the
machine has a touch bar. machine has a touch bar and is running on macOS 10.12.1+.
**Note:** The TouchBar API is currently experimental and may change or be **Note:** The TouchBar API is currently experimental and may change or be
removed in future Electron releases. removed in future Electron releases.
@@ -1610,8 +1885,8 @@ Throws an error if `browserView` is not attached to `win`.
#### `win.getBrowserViews()` _Experimental_ #### `win.getBrowserViews()` _Experimental_
Returns `BrowserView[]` - a sorted by z-index array of all BrowserViews that have been attached Returns `BrowserView[]` - an array of all BrowserViews that have been attached
with `addBrowserView` or `setBrowserView`. The top-most BrowserView is the last element of the array. with `addBrowserView` or `setBrowserView`.
**Note:** The BrowserView API is currently experimental and may change or be **Note:** The BrowserView API is currently experimental and may change or be
removed in future Electron releases. removed in future Electron releases.
@@ -1621,13 +1896,17 @@ removed in future Electron releases.
* `options` Object * `options` Object
* `color` String (optional) _Windows_ - The CSS color of the Window Controls Overlay when enabled. * `color` String (optional) _Windows_ - The CSS color of the Window Controls Overlay when enabled.
* `symbolColor` String (optional) _Windows_ - The CSS color of the symbols on the Window Controls Overlay when enabled. * `symbolColor` String (optional) _Windows_ - The CSS color of the symbols on the Window Controls Overlay when enabled.
* `height` Integer (optional) _macOS_ _Windows_ - The height of the title bar and Window Controls Overlay in pixels. * `height` Integer (optional) _Windows_ - The height of the title bar and Window Controls Overlay in pixels.
On a Window with Window Controls Overlay already enabled, this method updates On a Window with Window Controls Overlay already enabled, this method updates
the style of the title bar overlay. the style of the title bar overlay.
[runtime-enabled-features]: https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/runtime_enabled_features.json5?l=70
[page-visibility-api]: https://developer.mozilla.org/en-US/docs/Web/API/Page_Visibility_API [page-visibility-api]: https://developer.mozilla.org/en-US/docs/Web/API/Page_Visibility_API
[quick-look]: https://en.wikipedia.org/wiki/Quick_Look [quick-look]: https://en.wikipedia.org/wiki/Quick_Look
[vibrancy-docs]: https://developer.apple.com/documentation/appkit/nsvisualeffectview?preferredLanguage=objc [vibrancy-docs]: https://developer.apple.com/documentation/appkit/nsvisualeffectview?preferredLanguage=objc
[window-levels]: https://developer.apple.com/documentation/appkit/nswindow/level [window-levels]: https://developer.apple.com/documentation/appkit/nswindow/level
[chrome-content-scripts]: https://developer.chrome.com/extensions/content_scripts#execution-environment
[event-emitter]: https://nodejs.org/api/events.html#events_class_eventemitter [event-emitter]: https://nodejs.org/api/events.html#events_class_eventemitter
[overlay-javascript-apis]: https://github.com/WICG/window-controls-overlay/blob/main/explainer.md#javascript-apis
[overlay-css-env-vars]: https://github.com/WICG/window-controls-overlay/blob/main/explainer.md#css-environment-variables

View File

@@ -2,7 +2,7 @@
> Make HTTP/HTTPS requests. > Make HTTP/HTTPS requests.
Process: [Main](../glossary.md#main-process), [Utility](../glossary.md#utility-process)<br /> 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._ _This class is not exported from the `'electron'` module. It is only available as a return value of other methods in the Electron API._
`ClientRequest` implements the [Writable Stream](https://nodejs.org/api/stream.html#stream_writable_streams) `ClientRequest` implements the [Writable Stream](https://nodejs.org/api/stream.html#stream_writable_streams)
@@ -23,14 +23,12 @@ following properties:
with which the request is associated. Defaults to the empty string. The with which the request is associated. Defaults to the empty string. The
`session` option supersedes `partition`. Thus if a `session` is explicitly `session` option supersedes `partition`. Thus if a `session` is explicitly
specified, `partition` is ignored. specified, `partition` is ignored.
* `credentials` string (optional) - Can be `include`, `omit` or * `credentials` string (optional) - Can be `include` or `omit`. Whether to
`same-origin`. Whether to send send [credentials](https://fetch.spec.whatwg.org/#credentials) with this
[credentials](https://fetch.spec.whatwg.org/#credentials) with this
request. If set to `include`, credentials from the session associated with request. If set to `include`, credentials from the session associated with
the request will be used. If set to `omit`, credentials will not be sent the request will be used. If set to `omit`, credentials will not be sent
with the request (and the `'login'` event will not be triggered in the with the request (and the `'login'` event will not be triggered in the
event of a 401). If set to `same-origin`, `origin` must also be specified. event of a 401). This matches the behavior of the
This matches the behavior of the
[fetch](https://fetch.spec.whatwg.org/#concept-request-credentials-mode) [fetch](https://fetch.spec.whatwg.org/#concept-request-credentials-mode)
option of the same name. If this option is not specified, authentication option of the same name. If this option is not specified, authentication
data from the session will be sent, and cookies will not be sent (unless data from the session will be sent, and cookies will not be sent (unless
@@ -51,13 +49,6 @@ following properties:
[`request.followRedirect`](#requestfollowredirect) is invoked synchronously [`request.followRedirect`](#requestfollowredirect) is invoked synchronously
during the [`redirect`](#event-redirect) event. Defaults to `follow`. during the [`redirect`](#event-redirect) event. Defaults to `follow`.
* `origin` string (optional) - The origin URL of the request. * `origin` string (optional) - The origin URL of the request.
* `referrerPolicy` string (optional) - can be `""`, `no-referrer`,
`no-referrer-when-downgrade`, `origin`, `origin-when-cross-origin`,
`unsafe-url`, `same-origin`, `strict-origin`, or
`strict-origin-when-cross-origin`. Defaults to
`strict-origin-when-cross-origin`.
* `cache` string (optional) - can be `default`, `no-store`, `reload`,
`no-cache`, `force-cache` or `only-if-cached`.
`options` properties such as `protocol`, `host`, `hostname`, `port` and `path` `options` properties such as `protocol`, `host`, `hostname`, `port` and `path`
strictly follow the Node.js model as described in the strictly follow the Node.js model as described in the
@@ -65,7 +56,7 @@ strictly follow the Node.js model as described in the
For instance, we could have created the same request to 'github.com' as follows: For instance, we could have created the same request to 'github.com' as follows:
```js ```JavaScript
const request = net.request({ const request = net.request({
method: 'GET', method: 'GET',
protocol: 'https:', protocol: 'https:',
@@ -104,7 +95,7 @@ The `callback` function is expected to be called back with user credentials:
* `username` string * `username` string
* `password` string * `password` string
```js @ts-type={request:Electron.ClientRequest} ```JavaScript
request.on('login', (authInfo, callback) => { request.on('login', (authInfo, callback) => {
callback('username', 'password') callback('username', 'password')
}) })
@@ -113,9 +104,9 @@ request.on('login', (authInfo, callback) => {
Providing empty credentials will cancel the request and report an authentication Providing empty credentials will cancel the request and report an authentication
error on the response object: error on the response object:
```js @ts-type={request:Electron.ClientRequest} ```JavaScript
request.on('response', (response) => { request.on('response', (response) => {
console.log(`STATUS: ${response.statusCode}`) console.log(`STATUS: ${response.statusCode}`);
response.on('error', (error) => { response.on('error', (error) => {
console.log(`ERROR: ${JSON.stringify(error)}`) console.log(`ERROR: ${JSON.stringify(error)}`)
}) })
@@ -243,8 +234,6 @@ it is not allowed to add or remove a custom header.
* `encoding` string (optional) * `encoding` string (optional)
* `callback` Function (optional) * `callback` Function (optional)
Returns `this`.
Sends the last chunk of the request data. Subsequent write or end operations Sends the last chunk of the request data. Subsequent write or end operations
will not be allowed. The `finish` event is emitted just after the end operation. will not be allowed. The `finish` event is emitted just after the end operation.

View File

@@ -7,7 +7,7 @@ Process: [Main](../glossary.md#main-process), [Renderer](../glossary.md#renderer
On Linux, there is also a `selection` clipboard. To manipulate it On Linux, there is also a `selection` clipboard. To manipulate it
you need to pass `selection` to each method: you need to pass `selection` to each method:
```js ```javascript
const { clipboard } = require('electron') const { clipboard } = require('electron')
clipboard.writeText('Example string', 'selection') clipboard.writeText('Example string', 'selection')
@@ -148,7 +148,10 @@ clipboard.
```js ```js
const { clipboard } = require('electron') const { clipboard } = require('electron')
clipboard.writeBookmark('Electron Homepage', 'https://electronjs.org') clipboard.writeBookmark({
text: 'https://electronjs.org',
bookmark: 'Electron Homepage'
})
``` ```
### `clipboard.readFindText()` _macOS_ ### `clipboard.readFindText()` _macOS_
@@ -223,7 +226,7 @@ clipboard.writeBuffer('public/utf8-plain-text', buffer)
const ret = clipboard.readBuffer('public/utf8-plain-text') const ret = clipboard.readBuffer('public/utf8-plain-text')
console.log(buffer.equals(ret)) console.log(buffer.equals(out))
// true // true
``` ```

View File

@@ -6,7 +6,7 @@ You can use [app.commandLine.appendSwitch][append-switch] to append them in
your app's main script before the [ready][ready] event of the [app][app] module your app's main script before the [ready][ready] event of the [app][app] module
is emitted: is emitted:
```js ```javascript
const { app } = require('electron') const { app } = require('electron')
app.commandLine.appendSwitch('remote-debugging-port', '8315') app.commandLine.appendSwitch('remote-debugging-port', '8315')
app.commandLine.appendSwitch('host-rules', 'MAP * 127.0.0.1') app.commandLine.appendSwitch('host-rules', 'MAP * 127.0.0.1')
@@ -61,7 +61,7 @@ throttling in one window, you can take the hack of
Forces the maximum disk space to be used by the disk cache, in bytes. Forces the maximum disk space to be used by the disk cache, in bytes.
### --enable-logging\[=file] ### --enable-logging[=file]
Prints Chromium's logging to stderr (or a log file). Prints Chromium's logging to stderr (or a log file).
@@ -116,20 +116,14 @@ Ignore the connections limit for `domains` list separated by `,`.
### --js-flags=`flags` ### --js-flags=`flags`
Specifies the flags passed to the [V8 engine](https://v8.dev). In order to enable the `flags` in the main process, Specifies the flags passed to the Node.js engine. It has to be passed when starting
this switch must be passed on startup. Electron if you want to enable the `flags` in the main process.
```sh ```sh
$ electron --js-flags="--harmony_proxies --harmony_collections" your-app $ electron --js-flags="--harmony_proxies --harmony_collections" your-app
``` ```
Run `node --v8-options` or `electron --js-flags="--help"` in your terminal for the list of available flags. These can be used to enable early-stage JavaScript features, or log and manipulate garbage collection, among other things. See the [Node.js documentation][node-cli] or run `node --help` in your terminal for a list of available flags. Additionally, run `node --v8-options` to see a list of flags that specifically refer to Node.js's V8 JavaScript engine.
For example, to trace V8 optimization and deoptimization:
```sh
$ electron --js-flags="--trace-opt --trace-deopt" your-app
```
### --lang ### --lang
@@ -185,7 +179,7 @@ list of hosts. This flag has an effect only if used in tandem with
For example: For example:
```js ```javascript
const { app } = require('electron') const { app } = require('electron')
app.commandLine.appendSwitch('proxy-bypass-list', '<local>;*.google.com;*foo.com;1.2.3.4:5678') app.commandLine.appendSwitch('proxy-bypass-list', '<local>;*.google.com;*foo.com;1.2.3.4:5678')
``` ```
@@ -247,25 +241,19 @@ Electron supports some of the [CLI flags][node-cli] supported by Node.js.
**Note:** Passing unsupported command line switches to Electron when it is not running in `ELECTRON_RUN_AS_NODE` will have no effect. **Note:** Passing unsupported command line switches to Electron when it is not running in `ELECTRON_RUN_AS_NODE` will have no effect.
### `--inspect-brk\[=\[host:]port]` ### --inspect-brk[=[host:]port]
Activate inspector on host:port and break at start of user script. Default host:port is 127.0.0.1:9229. Activate inspector on host:port and break at start of user script. Default host:port is 127.0.0.1:9229.
Aliased to `--debug-brk=[host:]port`. Aliased to `--debug-brk=[host:]port`.
#### `--inspect-brk-node[=[host:]port]` ### --inspect-port=[host:]port
Activate inspector on `host:port` and break at start of the first internal
JavaScript script executed when the inspector is available.
Default `host:port` is `127.0.0.1:9229`.
### `--inspect-port=\[host:]port`
Set the `host:port` to be used when the inspector is activated. Useful when activating the inspector by sending the SIGUSR1 signal. Default host is `127.0.0.1`. Set the `host:port` to be used when the inspector is activated. Useful when activating the inspector by sending the SIGUSR1 signal. Default host is `127.0.0.1`.
Aliased to `--debug-port=[host:]port`. Aliased to `--debug-port=[host:]port`.
### `--inspect\[=\[host:]port]` ### --inspect[=[host:]port]
Activate inspector on `host:port`. Default is `127.0.0.1:9229`. Activate inspector on `host:port`. Default is `127.0.0.1:9229`.
@@ -275,39 +263,16 @@ See the [Debugging the Main Process][debugging-main-process] guide for more deta
Aliased to `--debug[=[host:]port`. Aliased to `--debug[=[host:]port`.
### `--inspect-publish-uid=stderr,http` ### --inspect-publish-uid=stderr,http
Specify ways of the inspector web socket url exposure. 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. By default inspector websocket url is available in stderr and under /json/list endpoint on http://host:port/json/list.
### `--no-deprecation`
Silence deprecation warnings.
### `--throw-deprecation`
Throw errors for deprecations.
### `--trace-deprecation`
Print stack traces for deprecations.
### `--trace-warnings`
Print stack traces for process warnings (including deprecations).
### `--dns-result-order=order`
Set the default value of the `verbatim` parameter in the Node.js [`dns.lookup()`](https://nodejs.org/api/dns.html#dnslookuphostname-options-callback) and [`dnsPromises.lookup()`](https://nodejs.org/api/dns.html#dnspromiseslookuphostname-options) functions. The value could be:
* `ipv4first`: sets default `verbatim` `false`.
* `verbatim`: sets default `verbatim` `true`.
The default is `verbatim` and `dns.setDefaultResultOrder()` have higher priority than `--dns-result-order`.
[app]: app.md [app]: app.md
[append-switch]: command-line.md#commandlineappendswitchswitch-value [append-switch]: command-line.md#commandlineappendswitchswitch-value
[ready]: app.md#event-ready
[play-silent-audio]: https://github.com/atom/atom/pull/9485/files
[debugging-main-process]: ../tutorial/debugging-main-process.md [debugging-main-process]: ../tutorial/debugging-main-process.md
[logging]: https://source.chromium.org/chromium/chromium/src/+/main:base/logging.h [logging]: https://source.chromium.org/chromium/chromium/src/+/main:base/logging.h
[node-cli]: https://nodejs.org/api/cli.html [node-cli]: https://nodejs.org/api/cli.html

View File

@@ -7,7 +7,7 @@ _This class is not exported from the `'electron'` module. It is only available a
The following example shows how to check if the `--disable-gpu` flag is set. The following example shows how to check if the `--disable-gpu` flag is set.
```js ```javascript
const { app } = require('electron') const { app } = require('electron')
app.commandLine.hasSwitch('disable-gpu') app.commandLine.hasSwitch('disable-gpu')
``` ```

View File

@@ -10,7 +10,7 @@ This module does not include a web interface. To view recorded traces, use
**Note:** You should not use this module until the `ready` event of the app **Note:** You should not use this module until the `ready` event of the app
module is emitted. module is emitted.
```js ```javascript
const { app, contentTracing } = require('electron') const { app, contentTracing } = require('electron')
app.whenReady().then(() => { app.whenReady().then(() => {

View File

@@ -6,7 +6,7 @@ Process: [Renderer](../glossary.md#renderer-process)
An example of exposing an API to a renderer from an isolated preload script is given below: An example of exposing an API to a renderer from an isolated preload script is given below:
```js ```javascript
// Preload (Isolated World) // Preload (Isolated World)
const { contextBridge, ipcRenderer } = require('electron') const { contextBridge, ipcRenderer } = require('electron')
@@ -18,7 +18,7 @@ contextBridge.exposeInMainWorld(
) )
``` ```
```js @ts-nocheck ```javascript
// Renderer (Main World) // Renderer (Main World)
window.electron.doThing() window.electron.doThing()
@@ -64,8 +64,8 @@ the API become immutable and updates on either side of the bridge do not result
An example of a complex API is shown below: An example of a complex API is shown below:
```js ```javascript
const { contextBridge, ipcRenderer } = require('electron') const { contextBridge } = require('electron')
contextBridge.exposeInMainWorld( contextBridge.exposeInMainWorld(
'electron', 'electron',
@@ -92,7 +92,7 @@ contextBridge.exposeInMainWorld(
An example of `exposeInIsolatedWorld` is shown below: An example of `exposeInIsolatedWorld` is shown below:
```js ```javascript
const { contextBridge, ipcRenderer } = require('electron') const { contextBridge, ipcRenderer } = require('electron')
contextBridge.exposeInIsolatedWorld( contextBridge.exposeInIsolatedWorld(
@@ -104,7 +104,7 @@ contextBridge.exposeInIsolatedWorld(
) )
``` ```
```js @ts-nocheck ```javascript
// Renderer (In isolated world id1004) // Renderer (In isolated world id1004)
window.electron.doThing() window.electron.doThing()
@@ -145,9 +145,9 @@ The table of supported types described above also applies to Node APIs that you
Please note that many Node APIs grant access to local system resources. Please note that many Node APIs grant access to local system resources.
Be very cautious about which globals and APIs you expose to untrusted remote content. Be very cautious about which globals and APIs you expose to untrusted remote content.
```js ```javascript
const { contextBridge } = require('electron') const { contextBridge } = require('electron')
const crypto = require('node:crypto') const crypto = require('crypto')
contextBridge.exposeInMainWorld('nodeCrypto', { contextBridge.exposeInMainWorld('nodeCrypto', {
sha256sum (data) { sha256sum (data) {
const hash = crypto.createHash('sha256') const hash = crypto.createHash('sha256')

View File

@@ -10,7 +10,7 @@ a `Session`.
For example: For example:
```js ```javascript
const { session } = require('electron') const { session } = require('electron')
// Query all cookies. // Query all cookies.
@@ -22,7 +22,7 @@ session.defaultSession.cookies.get({})
}) })
// Query all cookies associated with a specific url. // Query all cookies associated with a specific url.
session.defaultSession.cookies.get({ url: 'https://www.github.com' }) session.defaultSession.cookies.get({ url: 'http://www.github.com' })
.then((cookies) => { .then((cookies) => {
console.log(cookies) console.log(cookies)
}).catch((error) => { }).catch((error) => {
@@ -31,7 +31,7 @@ session.defaultSession.cookies.get({ url: 'https://www.github.com' })
// Set a cookie with the given cookie data; // Set a cookie with the given cookie data;
// may overwrite equivalent cookies if they exist. // may overwrite equivalent cookies if they exist.
const cookie = { url: 'https://www.github.com', name: 'dummy_name', value: 'dummy' } const cookie = { url: 'http://www.github.com', name: 'dummy_name', value: 'dummy' }
session.defaultSession.cookies.set(cookie) session.defaultSession.cookies.set(cookie)
.then(() => { .then(() => {
// success // success
@@ -78,7 +78,6 @@ The following methods are available on instances of `Cookies`:
* `path` string (optional) - Retrieves cookies whose path matches `path`. * `path` string (optional) - Retrieves cookies whose path matches `path`.
* `secure` boolean (optional) - Filters cookies by their Secure property. * `secure` boolean (optional) - Filters cookies by their Secure property.
* `session` boolean (optional) - Filters out session or persistent cookies. * `session` boolean (optional) - Filters out session or persistent cookies.
* `httpOnly` boolean (optional) - Filters cookies by httpOnly.
Returns `Promise<Cookie[]>` - A promise which resolves an array of cookie objects. Returns `Promise<Cookie[]>` - A promise which resolves an array of cookie objects.
@@ -119,8 +118,4 @@ Removes the cookies matching `url` and `name`
Returns `Promise<void>` - A promise which resolves when the cookie store has been flushed Returns `Promise<void>` - A promise which resolves when the cookie store has been flushed
Writes any unwritten cookies data to disk Writes any unwritten cookies data to disk.
Cookies written by any method will not be written to disk immediately, but will be written every 30 seconds or 512 operations
Calling this method can cause the cookie to be written to disk immediately.

View File

@@ -7,7 +7,7 @@ Process: [Main](../glossary.md#main-process), [Renderer](../glossary.md#renderer
The following is an example of setting up Electron to automatically submit The following is an example of setting up Electron to automatically submit
crash reports to a remote server: crash reports to a remote server:
```js ```javascript
const { crashReporter } = require('electron') const { crashReporter } = require('electron')
crashReporter.start({ submitURL: 'https://your-domain.com/url-to-submit' }) crashReporter.start({ submitURL: 'https://your-domain.com/url-to-submit' })
@@ -16,7 +16,7 @@ crashReporter.start({ submitURL: 'https://your-domain.com/url-to-submit' })
For setting up a server to accept and process crash reports, you can use For setting up a server to accept and process crash reports, you can use
following projects: following projects:
* [socorro](https://github.com/mozilla-services/socorro) * [socorro](https://github.com/mozilla/socorro)
* [mini-breakpad-server](https://github.com/electron/mini-breakpad-server) * [mini-breakpad-server](https://github.com/electron/mini-breakpad-server)
> **Note:** Electron uses Crashpad, not Breakpad, to collect and upload > **Note:** Electron uses Crashpad, not Breakpad, to collect and upload
@@ -100,7 +100,7 @@ longer than the maximum length will be truncated.
### `crashReporter.getLastCrashReport()` ### `crashReporter.getLastCrashReport()`
Returns [`CrashReport | null`](structures/crash-report.md) - The date and ID of the Returns [`CrashReport`](structures/crash-report.md) - The date and ID of the
last crash report. Only crash reports that have been uploaded will be returned; last crash report. Only crash reports that have been uploaded will be returned;
even if a crash report is present on disk it will not be returned until it is even if a crash report is present on disk it will not be returned until it is
uploaded. In the case that there are no uploaded reports, `null` is returned. uploaded. In the case that there are no uploaded reports, `null` is returned.

View File

@@ -8,7 +8,7 @@ _This class is not exported from the `'electron'` module. It is only available a
Chrome Developer Tools has a [special binding][rdp] available at JavaScript Chrome Developer Tools has a [special binding][rdp] available at JavaScript
runtime that allows interacting with pages and instrumenting them. runtime that allows interacting with pages and instrumenting them.
```js ```javascript
const { BrowserWindow } = require('electron') const { BrowserWindow } = require('electron')
const win = new BrowserWindow() const win = new BrowserWindow()
@@ -59,6 +59,7 @@ Returns:
Emitted whenever the debugging target issues an instrumentation event. Emitted whenever the debugging target issues an instrumentation event.
[rdp]: https://chromedevtools.github.io/devtools-protocol/ [rdp]: https://chromedevtools.github.io/devtools-protocol/
[`webContents.findInPage`]: web-contents.md#contentsfindinpagetext-options
### Instance Methods ### Instance Methods

View File

@@ -1,18 +1,16 @@
# desktopCapturer # desktopCapturer
> Access information about media sources that can be used to capture audio and > Access information about media sources that can be used to capture audio and
> video from the desktop using the [`navigator.mediaDevices.getUserMedia`][] API. > video from the desktop using the [`navigator.mediaDevices.getUserMedia`] API.
Process: [Main](../glossary.md#main-process) Process: [Main](../glossary.md#main-process)
The following example shows how to capture video from a desktop window whose The following example shows how to capture video from a desktop window whose
title is `Electron`: title is `Electron`:
```js ```javascript
// In the main process. // In the main process.
const { BrowserWindow, desktopCapturer } = require('electron') const { desktopCapturer } = require('electron')
const mainWindow = new BrowserWindow()
desktopCapturer.getSources({ types: ['window', 'screen'] }).then(async sources => { desktopCapturer.getSources({ types: ['window', 'screen'] }).then(async sources => {
for (const source of sources) { for (const source of sources) {
@@ -24,7 +22,7 @@ desktopCapturer.getSources({ types: ['window', 'screen'] }).then(async sources =
}) })
``` ```
```js @ts-nocheck ```javascript
// In the preload script. // In the preload script.
const { ipcRenderer } = require('electron') const { ipcRenderer } = require('electron')
@@ -61,14 +59,14 @@ function handleError (e) {
``` ```
To capture video from a source provided by `desktopCapturer` the constraints To capture video from a source provided by `desktopCapturer` the constraints
passed to [`navigator.mediaDevices.getUserMedia`][] must include passed to [`navigator.mediaDevices.getUserMedia`] must include
`chromeMediaSource: 'desktop'`, and `audio: false`. `chromeMediaSource: 'desktop'`, and `audio: false`.
To capture both audio and video from the entire desktop the constraints passed To capture both audio and video from the entire desktop the constraints passed
to [`navigator.mediaDevices.getUserMedia`][] must include `chromeMediaSource: 'desktop'`, to [`navigator.mediaDevices.getUserMedia`] must include `chromeMediaSource: 'desktop'`,
for both `audio` and `video`, but should not include a `chromeMediaSourceId` constraint. for both `audio` and `video`, but should not include a `chromeMediaSourceId` constraint.
```js ```javascript
const constraints = { const constraints = {
audio: { audio: {
mandatory: { mandatory: {
@@ -91,7 +89,7 @@ The `desktopCapturer` module has the following methods:
* `options` Object * `options` Object
* `types` string[] - An array of strings that lists the types of desktop sources * `types` string[] - An array of strings that lists the types of desktop sources
to be captured, available types can be `screen` and `window`. to be captured, available types are `screen` and `window`.
* `thumbnailSize` [Size](structures/size.md) (optional) - The size that the media source thumbnail * `thumbnailSize` [Size](structures/size.md) (optional) - The size that the media source thumbnail
should be scaled to. Default is `150` x `150`. Set width or height to 0 when you do not need should be scaled to. Default is `150` x `150`. Set width or height to 0 when you do not need
the thumbnails. This will save the processing time required for capturing the content of each the thumbnails. This will save the processing time required for capturing the content of each
@@ -103,7 +101,7 @@ The `desktopCapturer` module has the following methods:
Returns `Promise<DesktopCapturerSource[]>` - Resolves with an array of [`DesktopCapturerSource`](structures/desktop-capturer-source.md) objects, each `DesktopCapturerSource` represents a screen or an individual window that can be captured. Returns `Promise<DesktopCapturerSource[]>` - Resolves with an array of [`DesktopCapturerSource`](structures/desktop-capturer-source.md) objects, each `DesktopCapturerSource` represents a screen or an individual window that can be captured.
**Note** Capturing the screen contents requires user consent on macOS 10.15 Catalina or higher, **Note** Capturing the screen contents requires user consent on macOS 10.15 Catalina or higher,
which can detected by [`systemPreferences.getMediaAccessStatus`][]. which can detected by [`systemPreferences.getMediaAccessStatus`].
[`navigator.mediaDevices.getUserMedia`]: https://developer.mozilla.org/en/docs/Web/API/MediaDevices/getUserMedia [`navigator.mediaDevices.getUserMedia`]: https://developer.mozilla.org/en/docs/Web/API/MediaDevices/getUserMedia
[`systemPreferences.getMediaAccessStatus`]: system-preferences.md#systempreferencesgetmediaaccessstatusmediatype-windows-macos [`systemPreferences.getMediaAccessStatus`]: system-preferences.md#systempreferencesgetmediaaccessstatusmediatype-windows-macos

View File

@@ -6,7 +6,7 @@ Process: [Main](../glossary.md#main-process)
An example of showing a dialog to select multiple files: An example of showing a dialog to select multiple files:
```js ```javascript
const { dialog } = require('electron') const { dialog } = require('electron')
console.log(dialog.showOpenDialog({ properties: ['openFile', 'multiSelections'] })) console.log(dialog.showOpenDialog({ properties: ['openFile', 'multiSelections'] }))
``` ```
@@ -52,7 +52,7 @@ The `browserWindow` argument allows the dialog to attach itself to a parent wind
The `filters` specifies an array of file types that can be displayed or The `filters` specifies an array of file types that can be displayed or
selected when you want to limit the user to a specific type. For example: selected when you want to limit the user to a specific type. For example:
```js ```javascript
{ {
filters: [ filters: [
{ name: 'Images', extensions: ['jpg', 'png', 'gif'] }, { name: 'Images', extensions: ['jpg', 'png', 'gif'] },
@@ -72,7 +72,7 @@ and a directory selector, so if you set `properties` to
`['openFile', 'openDirectory']` on these platforms, a directory selector will be `['openFile', 'openDirectory']` on these platforms, a directory selector will be
shown. shown.
```js @ts-type={mainWindow:Electron.BrowserWindow} ```js
dialog.showOpenDialogSync(mainWindow, { dialog.showOpenDialogSync(mainWindow, {
properties: ['openFile', 'openDirectory'] properties: ['openFile', 'openDirectory']
}) })
@@ -119,7 +119,7 @@ The `browserWindow` argument allows the dialog to attach itself to a parent wind
The `filters` specifies an array of file types that can be displayed or The `filters` specifies an array of file types that can be displayed or
selected when you want to limit the user to a specific type. For example: selected when you want to limit the user to a specific type. For example:
```js ```javascript
{ {
filters: [ filters: [
{ name: 'Images', extensions: ['jpg', 'png', 'gif'] }, { name: 'Images', extensions: ['jpg', 'png', 'gif'] },
@@ -139,7 +139,7 @@ and a directory selector, so if you set `properties` to
`['openFile', 'openDirectory']` on these platforms, a directory selector will be `['openFile', 'openDirectory']` on these platforms, a directory selector will be
shown. shown.
```js @ts-type={mainWindow:Electron.BrowserWindow} ```js
dialog.showOpenDialog(mainWindow, { dialog.showOpenDialog(mainWindow, {
properties: ['openFile', 'openDirectory'] properties: ['openFile', 'openDirectory']
}).then(result => { }).then(result => {
@@ -223,10 +223,10 @@ expanding and collapsing the dialog.
* `browserWindow` [BrowserWindow](browser-window.md) (optional) * `browserWindow` [BrowserWindow](browser-window.md) (optional)
* `options` Object * `options` Object
* `message` string - Content of the message box. * `message` string - Content of the message box.
* `type` string (optional) - Can be `none`, `info`, `error`, `question` or * `type` string (optional) - Can be `"none"`, `"info"`, `"error"`, `"question"` or
`warning`. On Windows, `question` displays the same icon as `info`, unless `"warning"`. On Windows, `"question"` displays the same icon as `"info"`, unless
you set an icon using the `icon` option. On macOS, both `warning` and you set an icon using the `"icon"` option. On macOS, both `"warning"` and
`error` display the same warning icon. `"error"` display the same warning icon.
* `buttons` string[]&#32;(optional) - Array of texts for buttons. On Windows, an empty array * `buttons` string[]&#32;(optional) - Array of texts for buttons. On Windows, an empty array
will result in one button labeled "OK". will result in one button labeled "OK".
* `defaultId` Integer (optional) - Index of the button in the buttons array which will * `defaultId` Integer (optional) - Index of the button in the buttons array which will
@@ -266,10 +266,10 @@ If `browserWindow` is not shown dialog will not be attached to it. In such case
* `browserWindow` [BrowserWindow](browser-window.md) (optional) * `browserWindow` [BrowserWindow](browser-window.md) (optional)
* `options` Object * `options` Object
* `message` string - Content of the message box. * `message` string - Content of the message box.
* `type` string (optional) - Can be `none`, `info`, `error`, `question` or * `type` string (optional) - Can be `"none"`, `"info"`, `"error"`, `"question"` or
`warning`. On Windows, `question` displays the same icon as `info`, unless `"warning"`. On Windows, `"question"` displays the same icon as `"info"`, unless
you set an icon using the `icon` option. On macOS, both `warning` and you set an icon using the `"icon"` option. On macOS, both `"warning"` and
`error` display the same warning icon. `"error"` display the same warning icon.
* `buttons` string[]&#32;(optional) - Array of texts for buttons. On Windows, an empty array * `buttons` string[]&#32;(optional) - Array of texts for buttons. On Windows, an empty array
will result in one button labeled "OK". will result in one button labeled "OK".
* `defaultId` Integer (optional) - Index of the button in the buttons array which will * `defaultId` Integer (optional) - Index of the button in the buttons array which will

View File

@@ -7,7 +7,7 @@ _This class is not exported from the `'electron'` module. It is only available a
The following example shows how to bounce your icon on the dock. The following example shows how to bounce your icon on the dock.
```js ```javascript
const { app } = require('electron') const { app } = require('electron')
app.dock.bounce() app.dock.bounce()
``` ```

View File

@@ -9,7 +9,7 @@ _This class is not exported from the `'electron'` module. It is only available a
It is used in `will-download` event of `Session` class, and allows users to It is used in `will-download` event of `Session` class, and allows users to
control the download item. control the download item.
```js ```javascript
// In the main process. // In the main process.
const { BrowserWindow } = require('electron') const { BrowserWindow } = require('electron')
const win = new BrowserWindow() const win = new BrowserWindow()

View File

@@ -59,7 +59,7 @@ geolocation webservice. To enable this feature, acquire a
and place the following code in your main process file, before opening any and place the following code in your main process file, before opening any
browser windows that will make geolocation requests: browser windows that will make geolocation requests:
```js ```javascript
process.env.GOOGLE_API_KEY = 'YOUR_KEY_HERE' process.env.GOOGLE_API_KEY = 'YOUR_KEY_HERE'
``` ```
@@ -111,16 +111,6 @@ Options:
* `kioclient5` * `kioclient5`
* `kioclient` * `kioclient`
### `ELECTRON_OZONE_PLATFORM_HINT` _Linux_
Selects the preferred platform backend used on Linux. The default one is `x11`. `auto` selects Wayland if possible, X11 otherwise.
Options:
* `auto`
* `wayland`
* `x11`
## Development Variables ## Development Variables
The following environment variables are intended primarily for development and The following environment variables are intended primarily for development and

View File

@@ -40,41 +40,18 @@ We support the following extensions APIs, with some caveats. Other APIs may
additionally be supported, but support for any APIs not listed here is additionally be supported, but support for any APIs not listed here is
provisional and may be removed. provisional and may be removed.
### Supported Manifest Keys
- `name`
- `version`
- `author`
- `permissions`
- `content_scripts`
- `default_locale`
- `devtools_page`
- `short_name`
- `host_permissions` (Manifest V3)
- `manifest_version`
- `background` (Manifest V2)
- `minimum_chrome_version`
See [Manifest file format](https://developer.chrome.com/docs/extensions/mv3/manifest/) for more information about the purpose of each possible key.
### `chrome.devtools.inspectedWindow` ### `chrome.devtools.inspectedWindow`
All features of this API are supported. All features of this API are supported.
See [official documentation](https://developer.chrome.com/docs/extensions/reference/devtools_inspectedWindow) for more information.
### `chrome.devtools.network` ### `chrome.devtools.network`
All features of this API are supported. All features of this API are supported.
See [official documentation](https://developer.chrome.com/docs/extensions/reference/devtools_network) for more information.
### `chrome.devtools.panels` ### `chrome.devtools.panels`
All features of this API are supported. All features of this API are supported.
See [official documentation](https://developer.chrome.com/docs/extensions/reference/devtools_panels) for more information.
### `chrome.extension` ### `chrome.extension`
The following properties of `chrome.extension` are supported: The following properties of `chrome.extension` are supported:
@@ -86,25 +63,6 @@ The following methods of `chrome.extension` are supported:
- `chrome.extension.getURL` - `chrome.extension.getURL`
- `chrome.extension.getBackgroundPage` - `chrome.extension.getBackgroundPage`
See [official documentation](https://developer.chrome.com/docs/extensions/reference/extension) for more information.
### `chrome.management`
The following methods of `chrome.management` are supported:
- `chrome.management.getAll`
- `chrome.management.get`
- `chrome.management.getSelf`
- `chrome.management.getPermissionWarningsById`
- `chrome.management.getPermissionWarningsByManifest`
The following events of `chrome.management` are supported:
- `chrome.management.onEnabled`
- `chrome.management.onDisabled`
See [official documentation](https://developer.chrome.com/docs/extensions/reference/management) for more information.
### `chrome.runtime` ### `chrome.runtime`
The following properties of `chrome.runtime` are supported: The following properties of `chrome.runtime` are supported:
@@ -131,23 +89,10 @@ The following events of `chrome.runtime` are supported:
- `chrome.runtime.onConnect` - `chrome.runtime.onConnect`
- `chrome.runtime.onMessage` - `chrome.runtime.onMessage`
See [official documentation](https://developer.chrome.com/docs/extensions/reference/runtime) for more information.
### `chrome.scripting`
All features of this API are supported.
See [official documentation](https://developer.chrome.com/docs/extensions/reference/scripting) for more information.
### `chrome.storage` ### `chrome.storage`
The following methods of `chrome.storage` are supported: Only `chrome.storage.local` is supported; `chrome.storage.sync` and
`chrome.storage.managed` are not.
- `chrome.storage.local`
`chrome.storage.sync` and `chrome.storage.managed` are **not** supported.
See [official documentation](https://developer.chrome.com/docs/extensions/reference/storage) for more information.
### `chrome.tabs` ### `chrome.tabs`
@@ -156,8 +101,6 @@ The following methods of `chrome.tabs` are supported:
- `chrome.tabs.sendMessage` - `chrome.tabs.sendMessage`
- `chrome.tabs.reload` - `chrome.tabs.reload`
- `chrome.tabs.executeScript` - `chrome.tabs.executeScript`
- `chrome.tabs.query` (partial support)
- supported properties: `url`, `title`, `audible`, `active`, `muted`.
- `chrome.tabs.update` (partial support) - `chrome.tabs.update` (partial support)
- supported properties: `url`, `muted`. - supported properties: `url`, `muted`.
@@ -165,12 +108,20 @@ The following methods of `chrome.tabs` are supported:
> tab". Since Electron has no such concept, passing `-1` as a tab ID is not > tab". Since Electron has no such concept, passing `-1` as a tab ID is not
> supported and will raise an error. > supported and will raise an error.
See [official documentation](https://developer.chrome.com/docs/extensions/reference/tabs) for more information. ### `chrome.management`
The following methods of `chrome.management` are supported:
- `chrome.management.getAll`
- `chrome.management.get`
- `chrome.management.getSelf`
- `chrome.management.getPermissionWarningsById`
- `chrome.management.getPermissionWarningsByManifest`
- `chrome.management.onEnabled`
- `chrome.management.onDisabled`
### `chrome.webRequest` ### `chrome.webRequest`
All features of this API are supported. All features of this API are supported.
> **NOTE:** Electron's [`webRequest`](web-request.md) module takes precedence over `chrome.webRequest` if there are conflicting handlers. > **NOTE:** Electron's [`webRequest`](web-request.md) module takes precedence over `chrome.webRequest` if there are conflicting handlers.
See [official documentation](https://developer.chrome.com/docs/extensions/reference/webRequest) for more information.

View File

@@ -2,11 +2,6 @@
> Use the HTML5 `File` API to work natively with files on the filesystem. > Use the HTML5 `File` API to work natively with files on the filesystem.
> **Warning**
> The `path` property that Electron adds to the `File` interface is deprecated
> and **will** be removed in a future Electron release. We recommend you
> use `webUtils.getPathForFile` instead.
The DOM's File interface provides abstraction around native files in order to The DOM's File interface provides abstraction around native files in order to
let users work on native files directly with the HTML5 file API. Electron has let users work on native files directly with the HTML5 file API. Electron has
added a `path` attribute to the `File` interface which exposes the file's real added a `path` attribute to the `File` interface which exposes the file's real

View File

@@ -12,7 +12,7 @@ shortcuts.
not have the keyboard focus. This module cannot be used before the `ready` not have the keyboard focus. This module cannot be used before the `ready`
event of the app module is emitted. event of the app module is emitted.
```js ```javascript
const { app, globalShortcut } = require('electron') const { app, globalShortcut } = require('electron')
app.whenReady().then(() => { app.whenReady().then(() => {
@@ -66,7 +66,7 @@ the app has been authorized as a [trusted accessibility client](https://develope
### `globalShortcut.registerAll(accelerators, callback)` ### `globalShortcut.registerAll(accelerators, callback)`
* `accelerators` [Accelerator](accelerator.md)[] - an array of [Accelerator](accelerator.md)s. * `accelerators` string[] - an array of [Accelerator](accelerator.md)s.
* `callback` Function * `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. 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.

View File

@@ -21,12 +21,10 @@ Returns:
The `inAppPurchase` module has the following methods: The `inAppPurchase` module has the following methods:
### `inAppPurchase.purchaseProduct(productID[, opts])` ### `inAppPurchase.purchaseProduct(productID[, quantity])`
* `productID` string * `productID` string - The identifiers of the product to purchase. (The identifier of `com.example.app.product1` is `product1`).
* `opts` Integer | Object (optional) - If specified as an integer, defines the quantity. * `quantity` Integer (optional) - The number of items the user wants to purchase.
* `quantity` Integer (optional) - The number of items the user wants to purchase.
* `username` string (optional) - The string that associates the transaction with a user account on your service (applicationUsername).
Returns `Promise<boolean>` - Returns `true` if the product is valid and added to the payment queue. Returns `Promise<boolean>` - Returns `true` if the product is valid and added to the payment queue.

View File

@@ -2,7 +2,7 @@
> Handle responses to HTTP/HTTPS requests. > Handle responses to HTTP/HTTPS requests.
Process: [Main](../glossary.md#main-process), [Utility](../glossary.md#utility-process)<br /> 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._ _This class is not exported from the `'electron'` module. It is only available as a return value of other methods in the Electron API._
`IncomingMessage` implements the [Readable Stream](https://nodejs.org/api/stream.html#stream_readable_streams) `IncomingMessage` implements the [Readable Stream](https://nodejs.org/api/stream.html#stream_readable_streams)
@@ -89,7 +89,7 @@ tuples. So, the even-numbered offsets are key values, and the odd-numbered
offsets are the associated values. Header names are not lowercased, and offsets are the associated values. Header names are not lowercased, and
duplicates are not merged. duplicates are not merged.
```js @ts-type={response:Electron.IncomingMessage} ```javascript
// Prints something like: // Prints something like:
// //
// [ 'user-agent', // [ 'user-agent',
@@ -100,5 +100,5 @@ duplicates are not merged.
// '127.0.0.1:8000', // '127.0.0.1:8000',
// 'ACCEPT', // 'ACCEPT',
// '*/*' ] // '*/*' ]
console.log(response.rawHeaders) console.log(request.rawHeaders)
``` ```

View File

@@ -16,7 +16,7 @@ process, it handles asynchronous and synchronous messages sent from a renderer
process (web page). Messages sent from a renderer will be emitted to this process (web page). Messages sent from a renderer will be emitted to this
module. module.
For usage examples, check out the [IPC tutorial][]. For usage examples, check out the [IPC tutorial].
## Sending messages ## Sending messages
@@ -72,7 +72,7 @@ Removes listeners of the specified `channel`.
### `ipcMain.handle(channel, listener)` ### `ipcMain.handle(channel, listener)`
* `channel` string * `channel` string
* `listener` Function<Promise\<any&#62; | any&#62; * `listener` Function<Promise\<void&#62; | any&#62;
* `event` [IpcMainInvokeEvent][ipc-main-invoke-event] * `event` [IpcMainInvokeEvent][ipc-main-invoke-event]
* `...args` any[] * `...args` any[]
@@ -83,14 +83,14 @@ If `listener` returns a Promise, the eventual result of the promise will be
returned as a reply to the remote caller. Otherwise, the return value of the returned as a reply to the remote caller. Otherwise, the return value of the
listener will be used as the value of the reply. listener will be used as the value of the reply.
```js title='Main Process' @ts-type={somePromise:(...args:unknown[])=>Promise<unknown>} ```js title='Main Process'
ipcMain.handle('my-invokable-ipc', async (event, ...args) => { ipcMain.handle('my-invokable-ipc', async (event, ...args) => {
const result = await somePromise(...args) const result = await somePromise(...args)
return result return result
}) })
``` ```
```js title='Renderer Process' @ts-type={arg1:unknown} @ts-type={arg2:unknown} ```js title='Renderer Process'
async () => { async () => {
const result = await ipcRenderer.invoke('my-invokable-ipc', arg1, arg2) const result = await ipcRenderer.invoke('my-invokable-ipc', arg1, arg2)
// ... // ...
@@ -109,8 +109,8 @@ provided to the renderer process. Please refer to
### `ipcMain.handleOnce(channel, listener)` ### `ipcMain.handleOnce(channel, listener)`
* `channel` string * `channel` string
* `listener` Function<Promise\<any&#62; | any&#62; * `listener` Function<Promise\<void&#62; | any&#62;
* `event` [IpcMainInvokeEvent][ipc-main-invoke-event] * `event` IpcMainInvokeEvent
* `...args` any[] * `...args` any[]
Handles a single `invoke`able IPC message, then removes the listener. See Handles a single `invoke`able IPC message, then removes the listener. See
@@ -122,6 +122,17 @@ Handles a single `invoke`able IPC message, then removes the listener. See
Removes any handler for `channel`, if present. Removes any handler for `channel`, if present.
## IpcMainEvent object
The documentation for the `event` object passed to the `callback` can be found
in the [`ipc-main-event`][ipc-main-event] structure docs.
## IpcMainInvokeEvent object
The documentation for the `event` object passed to `handle` callbacks can be
found in the [`ipc-main-invoke-event`][ipc-main-invoke-event]
structure docs.
[IPC tutorial]: ../tutorial/ipc.md [IPC tutorial]: ../tutorial/ipc.md
[event-emitter]: https://nodejs.org/api/events.html#events_class_eventemitter [event-emitter]: https://nodejs.org/api/events.html#events_class_eventemitter
[web-contents-send]: ../api/web-contents.md#contentssendchannel-args [web-contents-send]: ../api/web-contents.md#contentssendchannel-args

View File

@@ -26,45 +26,26 @@ The `ipcRenderer` module has the following method to listen for events and send
* `channel` string * `channel` string
* `listener` Function * `listener` Function
* `event` [IpcRendererEvent][ipc-renderer-event] * `event` IpcRendererEvent
* `...args` any[] * `...args` any[]
Listens to `channel`, when a new message arrives `listener` would be called with Listens to `channel`, when a new message arrives `listener` would be called with
`listener(event, args...)`. `listener(event, args...)`.
### `ipcRenderer.off(channel, listener)`
* `channel` string
* `listener` Function
* `event` [IpcRendererEvent][ipc-renderer-event]
* `...args` any[]
Alias for [`ipcRenderer.removeListener`](#ipcrendererremovelistenerchannel-listener).
### `ipcRenderer.once(channel, listener)` ### `ipcRenderer.once(channel, listener)`
* `channel` string * `channel` string
* `listener` Function * `listener` Function
* `event` [IpcRendererEvent][ipc-renderer-event] * `event` IpcRendererEvent
* `...args` any[] * `...args` any[]
Adds a one time `listener` function for the event. This `listener` is invoked Adds a one time `listener` function for the event. This `listener` is invoked
only the next time a message is sent to `channel`, after which it is removed. only the next time a message is sent to `channel`, after which it is removed.
### `ipcRenderer.addListener(channel, listener)`
* `channel` string
* `listener` Function
* `event` [IpcRendererEvent][ipc-renderer-event]
* `...args` any[]
Alias for [`ipcRenderer.on`](#ipcrendereronchannel-listener).
### `ipcRenderer.removeListener(channel, listener)` ### `ipcRenderer.removeListener(channel, listener)`
* `channel` string * `channel` string
* `listener` Function * `listener` Function
* `event` [IpcRendererEvent][ipc-renderer-event]
* `...args` any[] * `...args` any[]
Removes the specified `listener` from the listener array for the specified Removes the specified `listener` from the listener array for the specified
@@ -120,7 +101,7 @@ The main process should listen for `channel` with
For example: For example:
```js @ts-type={someArgument:unknown} @ts-type={doSomeWork:(arg:unknown)=>Promise<unknown>} ```javascript
// Renderer process // Renderer process
ipcRenderer.invoke('some-name', someArgument).then((result) => { ipcRenderer.invoke('some-name', someArgument).then((result) => {
// ... // ...
@@ -161,7 +142,7 @@ Returns `any` - The value sent back by the [`ipcMain`](./ipc-main.md) handler.
Send a message to the main process via `channel` and expect a result Send a message to the main process via `channel` and expect a result
synchronously. Arguments will be serialized with the [Structured Clone synchronously. Arguments will be serialized with the [Structured Clone
Algorithm][SCA], just like [`window.postMessage`][], so prototype chains will not be Algorithm][SCA], just like [`window.postMessage`], so prototype chains will not be
included. Sending Functions, Promises, Symbols, WeakMaps, or WeakSets will included. Sending Functions, Promises, Symbols, WeakMaps, or WeakSets will
throw an exception. throw an exception.
@@ -211,6 +192,14 @@ ipcMain.on('port', (e, msg) => {
For more information on using `MessagePort` and `MessageChannel`, see the [MDN For more information on using `MessagePort` and `MessageChannel`, see the [MDN
documentation](https://developer.mozilla.org/en-US/docs/Web/API/MessageChannel). documentation](https://developer.mozilla.org/en-US/docs/Web/API/MessageChannel).
### `ipcRenderer.sendTo(webContentsId, channel, ...args)`
* `webContentsId` number
* `channel` string
* `...args` any[]
Sends a message to a window with `webContentsId` via `channel`.
### `ipcRenderer.sendToHost(channel, ...args)` ### `ipcRenderer.sendToHost(channel, ...args)`
* `channel` string * `channel` string
@@ -219,8 +208,12 @@ documentation](https://developer.mozilla.org/en-US/docs/Web/API/MessageChannel).
Like `ipcRenderer.send` but the event will be sent to the `<webview>` element in Like `ipcRenderer.send` but the event will be sent to the `<webview>` element in
the host page instead of the main process. the host page instead of the main process.
## Event object
The documentation for the `event` object passed to the `callback` can be found
in the [`ipc-renderer-event`](./structures/ipc-renderer-event.md) structure docs.
[event-emitter]: https://nodejs.org/api/events.html#events_class_eventemitter [event-emitter]: https://nodejs.org/api/events.html#events_class_eventemitter
[SCA]: https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm [SCA]: https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm
[`window.postMessage`]: https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage [`window.postMessage`]: https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage
[`MessagePort`]: https://developer.mozilla.org/en-US/docs/Web/API/MessagePort [`MessagePort`]: https://developer.mozilla.org/en-US/docs/Web/API/MessagePort
[ipc-renderer-event]: ./structures/ipc-renderer-event.md

View File

@@ -14,7 +14,7 @@ See [`Menu`](menu.md) for examples.
* `menuItem` MenuItem * `menuItem` MenuItem
* `browserWindow` [BrowserWindow](browser-window.md) | undefined - This will not be defined if no window is open. * `browserWindow` [BrowserWindow](browser-window.md) | undefined - This will not be defined if no window is open.
* `event` [KeyboardEvent](structures/keyboard-event.md) * `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 * `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`, `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](#roles).
* `type` string (optional) - Can be `normal`, `separator`, `submenu`, `checkbox` or * `type` string (optional) - Can be `normal`, `separator`, `submenu`, `checkbox` or
`radio`. `radio`.
@@ -25,7 +25,7 @@ See [`Menu`](menu.md) for examples.
* `icon` ([NativeImage](native-image.md) | string) (optional) * `icon` ([NativeImage](native-image.md) | string) (optional)
* `enabled` boolean (optional) - If false, the menu item will be greyed out and * `enabled` boolean (optional) - If false, the menu item will be greyed out and
unclickable. unclickable.
* `acceleratorWorksWhenHidden` boolean (optional) _macOS_ - default is `true`, and when `false` will prevent the accelerator from triggering the item if the item is not visible. * `acceleratorWorksWhenHidden` boolean (optional) _macOS_ - default is `true`, and when `false` will prevent the accelerator from triggering the item if the item is not visible`.
* `visible` boolean (optional) - If false, the menu item will be entirely hidden. * `visible` boolean (optional) - If false, the menu item will be entirely hidden.
* `checked` boolean (optional) - Should only be specified for `checkbox` or `radio` type * `checked` boolean (optional) - Should only be specified for `checkbox` or `radio` type
menu items. menu items.
@@ -51,7 +51,7 @@ See [`Menu`](menu.md) for examples.
the placement of their containing group after the containing group of the item the placement of their containing group after the containing group of the item
with the specified label. with the specified label.
**Note:** `acceleratorWorksWhenHidden` is specified as being macOS-only because accelerators always work when items are hidden on Windows and Linux. The option is exposed to users to give them the option to turn it off, as this is possible in native macOS development. **Note:** `acceleratorWorksWhenHidden` is specified as being macOS-only because accelerators always work when items are hidden on Windows and Linux. The option is exposed to users to give them the option to turn it off, as this is possible in native macOS development. This property is only usable on macOS High Sierra 10.13 or newer.
### Roles ### Roles
@@ -111,12 +111,11 @@ The following additional roles are available on _macOS_:
* `toggleTabBar` - Map to the `toggleTabBar` action. * `toggleTabBar` - Map to the `toggleTabBar` action.
* `selectNextTab` - Map to the `selectNextTab` action. * `selectNextTab` - Map to the `selectNextTab` action.
* `selectPreviousTab` - Map to the `selectPreviousTab` action. * `selectPreviousTab` - Map to the `selectPreviousTab` action.
* `showAllTabs` - Map to the `showAllTabs` action.
* `mergeAllWindows` - Map to the `mergeAllWindows` action. * `mergeAllWindows` - Map to the `mergeAllWindows` action.
* `moveTabToNewWindow` - Map to the `moveTabToNewWindow` action. * `moveTabToNewWindow` - Map to the `moveTabToNewWindow` action.
* `window` - The submenu is a "Window" menu. * `window` - The submenu is a "Window" menu.
* `help` - The submenu is a "Help" 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. * `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. * `recentDocuments` - The submenu is an "Open Recent" menu.
* `clearRecentDocuments` - Map to the `clearRecentDocuments` action. * `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. * `shareMenu` - The submenu is [share menu][ShareMenu]. The `sharingItem` property must also be set to indicate the item to share.
@@ -160,7 +159,7 @@ A `string` indicating the type of the item. Can be `normal`, `separator`, `subme
#### `menuItem.role` #### `menuItem.role`
A `string` (optional) indicating the item's role, if set. Can be `undo`, `redo`, `cut`, `copy`, `paste`, `pasteAndMatchStyle`, `delete`, `selectAll`, `reload`, `forceReload`, `toggleDevTools`, `resetZoom`, `zoomIn`, `zoomOut`, `toggleSpellChecker`, `togglefullscreen`, `window`, `minimize`, `close`, `help`, `about`, `services`, `hide`, `hideOthers`, `unhide`, `quit`, `startSpeaking`, `stopSpeaking`, `zoom`, `front`, `appMenu`, `fileMenu`, `editMenu`, `viewMenu`, `shareMenu`, `recentDocuments`, `toggleTabBar`, `selectNextTab`, `selectPreviousTab`, `showAllTabs`, `mergeAllWindows`, `clearRecentDocuments`, `moveTabToNewWindow` or `windowMenu` A `string` (optional) indicating the item's role, if set. Can be `undo`, `redo`, `cut`, `copy`, `paste`, `pasteAndMatchStyle`, `delete`, `selectAll`, `reload`, `forceReload`, `toggleDevTools`, `resetZoom`, `zoomIn`, `zoomOut`, `toggleSpellChecker`, `togglefullscreen`, `window`, `minimize`, `close`, `help`, `about`, `services`, `hide`, `hideOthers`, `unhide`, `quit`, `startSpeaking`, `stopSpeaking`, `zoom`, `front`, `appMenu`, `fileMenu`, `editMenu`, `viewMenu`, `shareMenu`, `recentDocuments`, `toggleTabBar`, `selectNextTab`, `selectPreviousTab`, `mergeAllWindows`, `clearRecentDocuments`, `moveTabToNewWindow` or `windowMenu`
#### `menuItem.accelerator` #### `menuItem.accelerator`

View File

@@ -80,10 +80,6 @@ The `menu` object has the following instance methods:
* `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 be positioned under the mouse cursor at the specified coordinates. Default
is -1. is -1.
* `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 [`BrowserWindow`](browser-window.md). Pops up this menu as a context menu in the [`BrowserWindow`](browser-window.md).
@@ -151,29 +147,27 @@ can have a submenu.
An example of creating the application menu with the simple template API: An example of creating the application menu with the simple template API:
```js @ts-expect-error=[107] ```javascript
const { app, Menu } = require('electron') const { app, Menu } = require('electron')
const isMac = process.platform === 'darwin' const isMac = process.platform === 'darwin'
const template = [ const template = [
// { role: 'appMenu' } // { role: 'appMenu' }
...(isMac ...(isMac ? [{
? [{ label: app.name,
label: app.name, submenu: [
submenu: [ { role: 'about' },
{ role: 'about' }, { type: 'separator' },
{ type: 'separator' }, { role: 'services' },
{ role: 'services' }, { type: 'separator' },
{ type: 'separator' }, { role: 'hide' },
{ role: 'hide' }, { role: 'hideOthers' },
{ role: 'hideOthers' }, { role: 'unhide' },
{ role: 'unhide' }, { type: 'separator' },
{ type: 'separator' }, { role: 'quit' }
{ role: 'quit' } ]
] }] : []),
}]
: []),
// { role: 'fileMenu' } // { role: 'fileMenu' }
{ {
label: 'File', label: 'File',
@@ -191,25 +185,23 @@ const template = [
{ role: 'cut' }, { role: 'cut' },
{ role: 'copy' }, { role: 'copy' },
{ role: 'paste' }, { role: 'paste' },
...(isMac ...(isMac ? [
? [ { role: 'pasteAndMatchStyle' },
{ role: 'pasteAndMatchStyle' }, { role: 'delete' },
{ role: 'delete' }, { role: 'selectAll' },
{ role: 'selectAll' }, { type: 'separator' },
{ type: 'separator' }, {
{ label: 'Speech',
label: 'Speech', submenu: [
submenu: [ { role: 'startSpeaking' },
{ role: 'startSpeaking' }, { role: 'stopSpeaking' }
{ role: 'stopSpeaking' }
]
}
] ]
: [ }
{ role: 'delete' }, ] : [
{ type: 'separator' }, { role: 'delete' },
{ role: 'selectAll' } { type: 'separator' },
]) { role: 'selectAll' }
])
] ]
}, },
// { role: 'viewMenu' } // { role: 'viewMenu' }
@@ -233,16 +225,14 @@ const template = [
submenu: [ submenu: [
{ role: 'minimize' }, { role: 'minimize' },
{ role: 'zoom' }, { role: 'zoom' },
...(isMac ...(isMac ? [
? [ { type: 'separator' },
{ type: 'separator' }, { role: 'front' },
{ role: 'front' }, { type: 'separator' },
{ type: 'separator' }, { role: 'window' }
{ role: 'window' } ] : [
] { role: 'close' }
: [ ])
{ role: 'close' }
])
] ]
}, },
{ {
@@ -271,7 +261,7 @@ menu on behalf of the renderer.
Below is an example of showing a menu when the user right clicks the page: Below is an example of showing a menu when the user right clicks the page:
```js @ts-expect-error=[21] ```js
// renderer // renderer
window.addEventListener('contextmenu', (e) => { window.addEventListener('contextmenu', (e) => {
e.preventDefault() e.preventDefault()
@@ -293,7 +283,7 @@ ipcMain.on('show-context-menu', (event) => {
{ label: 'Menu Item 2', type: 'checkbox', checked: true } { label: 'Menu Item 2', type: 'checkbox', checked: true }
] ]
const menu = Menu.buildFromTemplate(template) const menu = Menu.buildFromTemplate(template)
menu.popup({ window: BrowserWindow.fromWebContents(event.sender) }) menu.popup(BrowserWindow.fromWebContents(event.sender))
}) })
``` ```
@@ -327,7 +317,7 @@ name, no matter what label you set. To change it, modify your app bundle's
[About Information Property List Files][AboutInformationPropertyListFiles] [About Information Property List Files][AboutInformationPropertyListFiles]
for more information. for more information.
## Setting Menu for Specific Browser Window (_Linux_ _Windows_) ## Setting Menu for Specific Browser Window (*Linux* *Windows*)
The [`setMenu` method][setMenu] of browser windows can set the menu of certain The [`setMenu` method][setMenu] of browser windows can set the menu of certain
browser windows. browser windows.
@@ -353,7 +343,7 @@ By default, items will be inserted in the order they exist in the template unles
Template: Template:
```js ```javascript
[ [
{ id: '1', label: 'one' }, { id: '1', label: 'one' },
{ id: '2', label: 'two' }, { id: '2', label: 'two' },
@@ -373,7 +363,7 @@ Menu:
Template: Template:
```js ```javascript
[ [
{ id: '1', label: 'one' }, { id: '1', label: 'one' },
{ type: 'separator' }, { type: 'separator' },
@@ -397,7 +387,7 @@ Menu:
Template: Template:
```js ```javascript
[ [
{ id: '1', label: 'one', after: ['3'] }, { id: '1', label: 'one', after: ['3'] },
{ id: '2', label: 'two', before: ['1'] }, { id: '2', label: 'two', before: ['1'] },

View File

@@ -17,8 +17,7 @@ Example:
```js ```js
// Main process // Main process
const { BrowserWindow, MessageChannelMain } = require('electron') const { MessageChannelMain } = require('electron')
const w = new BrowserWindow()
const { port1, port2 } = new MessageChannelMain() const { port1, port2 } = new MessageChannelMain()
w.webContents.postMessage('port', null, [port2]) w.webContents.postMessage('port', null, [port2])
port1.postMessage({ some: 'message' }) port1.postMessage({ some: 'message' })
@@ -27,9 +26,9 @@ port1.postMessage({ some: 'message' })
const { ipcRenderer } = require('electron') const { ipcRenderer } = require('electron')
ipcRenderer.on('port', (e) => { ipcRenderer.on('port', (e) => {
// e.ports is a list of ports sent along with this message // e.ports is a list of ports sent along with this message
e.ports[0].onmessage = (messageEvent) => { e.ports[0].on('message', (messageEvent) => {
console.log(messageEvent.data) console.log(messageEvent.data)
} })
}) })
``` ```

View File

@@ -10,7 +10,7 @@ In Electron, for the APIs that take images, you can pass either file paths or
For example, when creating a tray or setting a window's icon, you can pass an For example, when creating a tray or setting a window's icon, you can pass an
image file path as a `string`: image file path as a `string`:
```js ```javascript
const { BrowserWindow, Tray } = require('electron') const { BrowserWindow, Tray } = require('electron')
const appIcon = new Tray('/Users/somebody/images/icon.png') const appIcon = new Tray('/Users/somebody/images/icon.png')
@@ -20,7 +20,7 @@ console.log(appIcon, win)
Or read the image from the clipboard, which returns a `NativeImage`: Or read the image from the clipboard, which returns a `NativeImage`:
```js ```javascript
const { clipboard, Tray } = require('electron') const { clipboard, Tray } = require('electron')
const image = clipboard.readImage() const image = clipboard.readImage()
const appIcon = new Tray(image) const appIcon = new Tray(image)
@@ -47,16 +47,9 @@ quality, it is recommended to include at least the following sizes in the:
* 64x64 (200% DPI scale) * 64x64 (200% DPI scale)
* 256x256 * 256x256
Check the _Size requirements_ section in [this article][icons]. Check the *Size requirements* section in [this article][icons].
[icons]: https://learn.microsoft.com/en-us/windows/win32/uxguide/vis-icons [icons]:https://msdn.microsoft.com/en-us/library/windows/desktop/dn742485(v=vs.85).aspx
:::note
EXIF metadata is currently not supported and will not be taken into account during
image encoding and decoding.
:::
## High Resolution Image ## High Resolution Image
@@ -78,7 +71,7 @@ images/
└── icon@3x.png └── icon@3x.png
``` ```
```js ```javascript
const { Tray } = require('electron') const { Tray } = require('electron')
const appIcon = new Tray('/Users/somebody/images/icon.png') const appIcon = new Tray('/Users/somebody/images/icon.png')
console.log(appIcon) console.log(appIcon)
@@ -126,15 +119,13 @@ Returns `NativeImage`
Creates an empty `NativeImage` instance. Creates an empty `NativeImage` instance.
### `nativeImage.createThumbnailFromPath(path, size)` _macOS_ _Windows_ ### `nativeImage.createThumbnailFromPath(path, maxSize)` _macOS_ _Windows_
* `path` string - path to a file that we intend to construct a thumbnail out of. * `path` string - path to a file that we intend to construct a thumbnail out of.
* `size` [Size](structures/size.md) - the desired width and height (positive numbers) of the thumbnail. * `maxSize` [Size](structures/size.md) - the maximum width and height (positive numbers) the thumbnail returned can be. The Windows implementation will ignore `maxSize.height` and scale the height according to `maxSize.width`.
Returns `Promise<NativeImage>` - fulfilled with the file's thumbnail preview image, which is a [NativeImage](native-image.md). Returns `Promise<NativeImage>` - fulfilled with the file's thumbnail preview image, which is a [NativeImage](native-image.md).
Note: The Windows implementation will ignore `size.height` and scale the height according to `size.width`.
### `nativeImage.createFromPath(path)` ### `nativeImage.createFromPath(path)`
* `path` string * `path` string
@@ -145,7 +136,7 @@ Creates a new `NativeImage` instance from a file located at `path`. This method
returns an empty image if the `path` does not exist, cannot be read, or is not returns an empty image if the `path` does not exist, cannot be read, or is not
a valid image. a valid image.
```js ```javascript
const nativeImage = require('electron').nativeImage const nativeImage = require('electron').nativeImage
const image = nativeImage.createFromPath('/Users/somebody/images/icon.png') const image = nativeImage.createFromPath('/Users/somebody/images/icon.png')
@@ -313,7 +304,7 @@ Returns `NativeImage` - The cropped image.
* `width` Integer (optional) - Defaults to the image's width. * `width` Integer (optional) - Defaults to the image's width.
* `height` Integer (optional) - Defaults to the image's height. * `height` Integer (optional) - Defaults to the image's height.
* `quality` string (optional) - The desired quality of the resize image. * `quality` string (optional) - The desired quality of the resize image.
Possible values include `good`, `better`, or `best`. The default is `best`. Possible values are `good`, `better`, or `best`. The default is `best`.
These values express a desired quality/speed tradeoff. They are translated These values express a desired quality/speed tradeoff. They are translated
into an algorithm-specific method that depends on the capabilities into an algorithm-specific method that depends on the capabilities
(CPU, GPU) of the underlying platform. It is possible for all three methods (CPU, GPU) of the underlying platform. It is possible for all three methods

View File

@@ -4,8 +4,8 @@
Process: [Main](../glossary.md#main-process) Process: [Main](../glossary.md#main-process)
```js ```javascript
const { app, netLog } = require('electron') const { netLog } = require('electron')
app.whenReady().then(async () => { app.whenReady().then(async () => {
await netLog.startLogging('/path/to/net-log') await netLog.startLogging('/path/to/net-log')

View File

@@ -2,7 +2,7 @@
> Issue HTTP/HTTPS requests using Chromium's native networking library > Issue HTTP/HTTPS requests using Chromium's native networking library
Process: [Main](../glossary.md#main-process), [Utility](../glossary.md#utility-process) Process: [Main](../glossary.md#main-process)
The `net` module is a client-side API for issuing HTTP(S) requests. It is The `net` module is a client-side API for issuing HTTP(S) requests. It is
similar to the [HTTP](https://nodejs.org/api/http.html) and similar to the [HTTP](https://nodejs.org/api/http.html) and
@@ -26,7 +26,7 @@ Node.js.
Example usage: Example usage:
```js ```javascript
const { app } = require('electron') const { app } = require('electron')
app.whenReady().then(() => { app.whenReady().then(() => {
const { net } = require('electron') const { net } = require('electron')
@@ -63,65 +63,6 @@ Creates a [`ClientRequest`](./client-request.md) instance using the provided
The `net.request` method would be used to issue both secure and insecure HTTP The `net.request` method would be used to issue both secure and insecure HTTP
requests according to the specified protocol scheme in the `options` object. requests according to the specified protocol scheme in the `options` object.
### `net.fetch(input[, init])`
* `input` string | [GlobalRequest](https://nodejs.org/api/globals.html#request)
* `init` [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/fetch#options) & { bypassCustomProtocolHandlers?: boolean } (optional)
Returns `Promise<GlobalResponse>` - see [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response).
Sends a request, similarly to how `fetch()` works in the renderer, using
Chrome's network stack. This differs from Node's `fetch()`, which uses
Node.js's HTTP stack.
Example:
```js
async function example () {
const response = await net.fetch('https://my.app')
if (response.ok) {
const body = await response.json()
// ... use the result.
}
}
```
This method will issue requests from the [default
session](session.md#sessiondefaultsession). To send a `fetch` request from
another session, use [ses.fetch()](session.md#sesfetchinput-init).
See the MDN documentation for
[`fetch()`](https://developer.mozilla.org/en-US/docs/Web/API/fetch) for more
details.
Limitations:
* `net.fetch()` does not support the `data:` or `blob:` schemes.
* The value of the `integrity` option is ignored.
* The `.type` and `.url` values of the returned `Response` object are
incorrect.
By default, requests made with `net.fetch` can be made to [custom
protocols](protocol.md) as well as `file:`, and will trigger
[webRequest](web-request.md) handlers if present. When the non-standard
`bypassCustomProtocolHandlers` option is set in RequestInit, custom protocol
handlers will not be called for this request. This allows forwarding an
intercepted request to the built-in handler. [webRequest](web-request.md)
handlers will still be triggered when bypassing custom protocols.
```js
protocol.handle('https', (req) => {
if (req.url === 'https://my-app.com') {
return new Response('<body>my app</body>')
} else {
return net.fetch(req, { bypassCustomProtocolHandlers: true })
}
})
```
Note: in the [utility process](../glossary.md#utility-process) custom protocols
are not supported.
### `net.isOnline()` ### `net.isOnline()`
Returns `boolean` - Whether there is currently internet connection. Returns `boolean` - Whether there is currently internet connection.
@@ -132,45 +73,6 @@ won't be able to connect to remote sites. However, a return value of
whether a particular connection attempt to a particular remote site whether a particular connection attempt to a particular remote site
will be successful. will be successful.
#### `net.resolveHost(host, [options])`
* `host` string - Hostname to resolve.
* `options` Object (optional)
* `queryType` string (optional) - Requested DNS query type. If unspecified,
resolver will pick A or AAAA (or both) based on IPv4/IPv6 settings:
* `A` - Fetch only A records
* `AAAA` - Fetch only AAAA records.
* `source` string (optional) - The source to use for resolved addresses.
Default allows the resolver to pick an appropriate source. Only affects use
of big external sources (e.g. calling the system for resolution or using
DNS). Even if a source is specified, results can still come from cache,
resolving "localhost" or IP literals, etc. One of the following values:
* `any` (default) - Resolver will pick an appropriate source. Results could
come from DNS, MulticastDNS, HOSTS file, etc
* `system` - Results will only be retrieved from the system or OS, e.g. via
the `getaddrinfo()` system call
* `dns` - Results will only come from DNS queries
* `mdns` - Results will only come from Multicast DNS queries
* `localOnly` - No external sources will be used. Results will only come
from fast local sources that are available no matter the source setting,
e.g. cache, hosts file, IP literal resolution, etc.
* `cacheUsage` string (optional) - Indicates what DNS cache entries, if any,
can be used to provide a response. One of the following values:
* `allowed` (default) - Results may come from the host cache if non-stale
* `staleAllowed` - Results may come from the host cache even if stale (by
expiration or network changes)
* `disallowed` - Results will not come from the host cache.
* `secureDnsPolicy` string (optional) - Controls the resolver's Secure DNS
behavior for this request. One of the following values:
* `allow` (default)
* `disable`
Returns [`Promise<ResolvedHost>`](structures/resolved-host.md) - Resolves with the resolved IP addresses for the `host`.
This method will resolve hosts from the [default
session](session.md#sessiondefaultsession). To resolve a host from
another session, use [ses.resolveHost()](session.md#sesresolvehosthost-options).
## Properties ## Properties
### `net.online` _Readonly_ ### `net.online` _Readonly_

View File

@@ -4,12 +4,9 @@
Process: [Main](../glossary.md#main-process) Process: [Main](../glossary.md#main-process)
:::info Renderer process notifications ## Using in the renderer process
If you want to show notifications from a renderer process you should use the If you want to show Notifications from a renderer process you should use the [HTML5 Notification API](../tutorial/notifications.md)
[web Notifications API](../tutorial/notifications.md)
:::
## Class: Notification ## Class: Notification
@@ -32,10 +29,10 @@ Returns `boolean` - Whether or not desktop notifications are supported on the cu
### `new Notification([options])` ### `new Notification([options])`
* `options` Object (optional) * `options` Object (optional)
* `title` string (optional) - A title for the notification, which will be displayed at the top of the notification window when it is shown. * `title` string (optional) - A title for the notification, which will be shown at the top of the notification window when it is shown.
* `subtitle` string (optional) _macOS_ - A subtitle for the notification, which will be displayed below the title. * `subtitle` string (optional) _macOS_ - A subtitle for the notification, which will be displayed below the title.
* `body` string (optional) - The body text of the notification, which will be displayed below the title or subtitle. * `body` string (optional) - The body text of the notification, which will be displayed below the title or subtitle.
* `silent` boolean (optional) - Whether or not to suppress the OS notification noise when showing the notification. * `silent` boolean (optional) - Whether or not to emit an OS notification noise when showing the notification.
* `icon` (string | [NativeImage](native-image.md)) (optional) - An icon to use in the notification. * `icon` (string | [NativeImage](native-image.md)) (optional) - An icon to use in the notification.
* `hasReply` boolean (optional) _macOS_ - Whether or not to add an inline reply option to the notification. * `hasReply` boolean (optional) _macOS_ - Whether or not to add an inline reply option to the notification.
* `timeoutType` string (optional) _Linux_ _Windows_ - The timeout duration of the notification. Can be 'default' or 'never'. * `timeoutType` string (optional) _Linux_ _Windows_ - The timeout duration of the notification. Can be 'default' or 'never'.
@@ -50,11 +47,8 @@ Returns `boolean` - Whether or not desktop notifications are supported on the cu
Objects created with `new Notification` emit the following events: Objects created with `new Notification` emit the following events:
:::info **Note:** Some events are only available on specific operating systems and are
labeled as such.
Some events are only available on specific operating systems and are labeled as such.
:::
#### Event: 'show' #### Event: 'show'
@@ -62,7 +56,7 @@ Returns:
* `event` Event * `event` Event
Emitted when the notification is shown to the user. Note that this event can be fired Emitted when the notification is shown to the user, note this could be fired
multiple times as a notification can be shown multiple times through the multiple times as a notification can be shown multiple times through the
`show()` method. `show()` method.
@@ -85,8 +79,6 @@ Emitted when the notification is closed by manual intervention from the user.
This event is not guaranteed to be emitted in all cases where the notification This event is not guaranteed to be emitted in all cases where the notification
is closed. is closed.
On Windows, the `close` event can be emitted in one of three ways: programmatic dismissal with `notification.close()`, by the user closing the notification, or via system timeout. If a notification is in the Action Center after the initial `close` event is emitted, a call to `notification.close()` will remove the notification from the action center but the `close` event will not be emitted again.
#### Event: 'reply' _macOS_ #### Event: 'reply' _macOS_
Returns: Returns:
@@ -114,13 +106,14 @@ Emitted when an error is encountered while creating and showing the native notif
### Instance Methods ### Instance Methods
Objects created with the `new Notification()` constructor have the following instance methods: Objects created with `new Notification` have the following instance methods:
#### `notification.show()` #### `notification.show()`
Immediately shows the notification to the user. Unlike the web notification API, Immediately shows the notification to the user, please note this means unlike the
instantiating a `new Notification()` does not immediately show it to the user. Instead, you need to HTML5 Notification implementation, instantiating a `new Notification` does
call this method before the OS will display it. not immediately show it to the user, you need to call this method before the OS
will display it.
If the notification has been shown before, this method will dismiss the previously If the notification has been shown before, this method will dismiss the previously
shown notification and create a new one with identical properties. shown notification and create a new one with identical properties.
@@ -129,8 +122,6 @@ shown notification and create a new one with identical properties.
Dismisses the notification. Dismisses the notification.
On Windows, calling `notification.close()` while the notification is visible on screen will dismiss the notification and remove it from the Action Center. If `notification.close()` is called after the notification is no longer visible on screen, calling `notification.close()` will try remove it from the Action Center.
### Instance Properties ### Instance Properties
#### `notification.title` #### `notification.title`
@@ -169,7 +160,7 @@ A `boolean` property representing whether the notification has a reply action.
A `string` property representing the urgency level of the notification. Can be 'normal', 'critical', or 'low'. A `string` property representing the urgency level of the notification. Can be 'normal', 'critical', or 'low'.
Default is 'low' - see [NotifyUrgency](https://developer-old.gnome.org/notification-spec/#urgency-levels) for more information. Default is 'low' - see [NotifyUrgency](https://developer.gnome.org/notification-spec/#urgency-levels) for more information.
#### `notification.timeoutType` _Linux_ _Windows_ #### `notification.timeoutType` _Linux_ _Windows_

View File

@@ -24,30 +24,6 @@ Emitted when the system changes to AC power.
Emitted when system changes to battery power. Emitted when system changes to battery power.
### Event: 'thermal-state-change' _macOS_
* `state` string - The system's new thermal state. Can be `unknown`, `nominal`, `fair`, `serious`, `critical`.
Emitted when the thermal state of the system changes. Notification of a change
in the thermal status of the system, such as entering a critical temperature
range. Depending on the severity, the system might take steps to reduce said
temperature, for example, throttling the CPU or switching on the fans if
available.
Apps may react to the new state by reducing expensive computing tasks (e.g.
video encoding), or notifying the user. The same state might be received
repeatedly.
See https://developer.apple.com/library/archive/documentation/Performance/Conceptual/power_efficiency_guidelines_osx/RespondToThermalStateChanges.html
### Event: 'speed-limit-change' _macOS_ _Windows_
* `limit` number - The operating system's advertised speed limit for CPUs, in percent.
Notification of a change in the operating system's advertised speed limit for
CPUs, in percent. Values below 100 indicate that the system is impairing
processing power due to thermal management.
### Event: 'shutdown' _Linux_ _macOS_ ### Event: 'shutdown' _Linux_ _macOS_
Emitted when the system is about to reboot or shut down. If the event handler Emitted when the system is about to reboot or shut down. If the event handler
@@ -79,7 +55,7 @@ The `powerMonitor` module has the following methods:
* `idleThreshold` Integer * `idleThreshold` Integer
Returns `string` - The system's current idle state. Can be `active`, `idle`, `locked` or `unknown`. Returns `string` - The system's current state. Can be `active`, `idle`, `locked` or `unknown`.
Calculate the system idle state. `idleThreshold` is the amount of time (in seconds) Calculate the system idle state. `idleThreshold` is the amount of time (in seconds)
before considered idle. `locked` is available on supported systems only. before considered idle. `locked` is available on supported systems only.
@@ -90,10 +66,6 @@ Returns `Integer` - Idle time in seconds
Calculate system idle time in seconds. Calculate system idle time in seconds.
### `powerMonitor.getCurrentThermalState()` _macOS_
Returns `string` - The system's current thermal state. Can be `unknown`, `nominal`, `fair`, `serious`, or `critical`.
### `powerMonitor.isOnBatteryPower()` ### `powerMonitor.isOnBatteryPower()`
Returns `boolean` - Whether the system is on battery power. Returns `boolean` - Whether the system is on battery power.

View File

@@ -6,7 +6,7 @@ Process: [Main](../glossary.md#main-process)
For example: For example:
```js ```javascript
const { powerSaveBlocker } = require('electron') const { powerSaveBlocker } = require('electron')
const id = powerSaveBlocker.start('prevent-display-sleep') const id = powerSaveBlocker.start('prevent-display-sleep')
@@ -49,8 +49,6 @@ is used.
Stops the specified power save blocker. Stops the specified power save blocker.
Returns `boolean` - Whether the specified `powerSaveBlocker` has been stopped.
### `powerSaveBlocker.isStarted(id)` ### `powerSaveBlocker.isStarted(id)`
* `id` Integer - The power save blocker id returned by `powerSaveBlocker.start`. * `id` Integer - The power save blocker id returned by `powerSaveBlocker.start`.

View File

@@ -49,11 +49,8 @@ beginning to load the web page or the main script.
### `process.defaultApp` _Readonly_ ### `process.defaultApp` _Readonly_
A `boolean`. When the app is started by being passed as parameter to the default Electron executable, this A `boolean`. When app is started by being passed as parameter to the default app, this
property is `true` in the main process, otherwise it is `undefined`. property is `true` in the main process, otherwise it is `undefined`.
For example when running the app with `electron .`, it is `true`,
even if the app is packaged ([`isPackaged`](app.md#appispackaged-readonly)) is `true`.
This can be useful to determine how many arguments will need to be sliced off from `process.argv`.
### `process.isMainFrame` _Readonly_ ### `process.isMainFrame` _Readonly_

View File

@@ -7,12 +7,16 @@ Process: [Main](../glossary.md#main-process)
An example of implementing a protocol that has the same effect as the An example of implementing a protocol that has the same effect as the
`file://` protocol: `file://` protocol:
```js ```javascript
const { app, protocol, net } = require('electron') const { app, protocol } = require('electron')
const path = require('path')
const url = require('url')
app.whenReady().then(() => { app.whenReady().then(() => {
protocol.handle('atom', (request) => protocol.registerFileProtocol('atom', (request, callback) => {
net.fetch('file://' + request.url.slice('atom://'.length))) const filePath = url.fileURLToPath('file://' + request.url.slice('atom://'.length))
callback(filePath)
})
}) })
``` ```
@@ -31,21 +35,20 @@ a different session and your custom protocol will not work if you just use
To have your custom protocol work in combination with a custom session, you need To have your custom protocol work in combination with a custom session, you need
to register it to that session explicitly. to register it to that session explicitly.
```js ```javascript
const { app, BrowserWindow, net, protocol, session } = require('electron') const { session, app, protocol } = require('electron')
const path = require('node:path') const path = require('path')
const url = require('url')
app.whenReady().then(() => { app.whenReady().then(() => {
const partition = 'persist:example' const partition = 'persist:example'
const ses = session.fromPartition(partition) const ses = session.fromPartition(partition)
ses.protocol.handle('atom', (request) => { ses.protocol.registerFileProtocol('atom', (request, callback) => {
const filePath = request.url.slice('atom://'.length) const url = request.url.substr(7)
return net.fetch(url.pathToFileURL(path.join(__dirname, filePath)).toString()) callback({ path: path.normalize(`${__dirname}/${url}`) })
}) })
const mainWindow = new BrowserWindow({ webPreferences: { partition } }) mainWindow = new BrowserWindow({ webPreferences: { partition } })
}) })
``` ```
@@ -61,14 +64,13 @@ The `protocol` module has the following methods:
module gets emitted and can be called only once. module gets emitted and can be called only once.
Registers the `scheme` as standard, secure, bypasses content security policy for Registers the `scheme` as standard, secure, bypasses content security policy for
resources, allows registering ServiceWorker, supports fetch API, streaming resources, allows registering ServiceWorker, supports fetch API, and streaming
video/audio, and V8 code cache. Specify a privilege with the value of `true` to video/audio. Specify a privilege with the value of `true` to enable the capability.
enable the capability.
An example of registering a privileged scheme, that bypasses Content Security An example of registering a privileged scheme, that bypasses Content Security
Policy: Policy:
```js ```javascript
const { protocol } = require('electron') const { protocol } = require('electron')
protocol.registerSchemesAsPrivileged([ protocol.registerSchemesAsPrivileged([
{ scheme: 'foo', privileges: { bypassCSP: true } } { scheme: 'foo', privileges: { bypassCSP: true } }
@@ -107,84 +109,7 @@ The `<video>` and `<audio>` HTML elements expect protocols to buffer their
responses by default. The `stream` flag configures those elements to correctly responses by default. The `stream` flag configures those elements to correctly
expect streaming responses. expect streaming responses.
### `protocol.handle(scheme, handler)` ### `protocol.registerFileProtocol(scheme, handler)`
* `scheme` string - scheme to handle, for example `https` or `my-app`. This is
the bit before the `:` in a URL.
* `handler` Function<[GlobalResponse](https://nodejs.org/api/globals.html#response) | Promise<GlobalResponse>>
* `request` [GlobalRequest](https://nodejs.org/api/globals.html#request)
Register a protocol handler for `scheme`. Requests made to URLs with this
scheme will delegate to this handler to determine what response should be sent.
Either a `Response` or a `Promise<Response>` can be returned.
Example:
```js
const { app, net, protocol } = require('electron')
const path = require('node:path')
const { pathToFileURL } = require('url')
protocol.registerSchemesAsPrivileged([
{
scheme: 'app',
privileges: {
standard: true,
secure: true,
supportFetchAPI: true
}
}
])
app.whenReady().then(() => {
protocol.handle('app', (req) => {
const { host, pathname } = new URL(req.url)
if (host === 'bundle') {
if (pathname === '/') {
return new Response('<h1>hello, world</h1>', {
headers: { 'content-type': 'text/html' }
})
}
// NB, this checks for paths that escape the bundle, e.g.
// app://bundle/../../secret_file.txt
const pathToServe = path.resolve(__dirname, pathname)
const relativePath = path.relative(__dirname, pathToServe)
const isSafe = relativePath && !relativePath.startsWith('..') && !path.isAbsolute(relativePath)
if (!isSafe) {
return new Response('bad', {
status: 400,
headers: { 'content-type': 'text/html' }
})
}
return net.fetch(pathToFileURL(pathToServe).toString())
} else if (host === 'api') {
return net.fetch('https://api.my-server.com/' + pathname, {
method: req.method,
headers: req.headers,
body: req.body
})
}
})
})
```
See the MDN docs for [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request) and [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response) for more details.
### `protocol.unhandle(scheme)`
* `scheme` string - scheme for which to remove the handler.
Removes a protocol handler registered with `protocol.handle`.
### `protocol.isProtocolHandled(scheme)`
* `scheme` string
Returns `boolean` - Whether `scheme` is already handled.
### `protocol.registerFileProtocol(scheme, handler)` _Deprecated_
* `scheme` string * `scheme` string
* `handler` Function * `handler` Function
@@ -205,7 +130,7 @@ path or an object that has a `path` property, e.g. `callback(filePath)` or
By default the `scheme` is treated like `http:`, which is parsed differently By default the `scheme` is treated like `http:`, which is parsed differently
from protocols that follow the "generic URI syntax" like `file:`. from protocols that follow the "generic URI syntax" like `file:`.
### `protocol.registerBufferProtocol(scheme, handler)` _Deprecated_ ### `protocol.registerBufferProtocol(scheme, handler)`
* `scheme` string * `scheme` string
* `handler` Function * `handler` Function
@@ -223,13 +148,13 @@ property.
Example: Example:
```js ```javascript
protocol.registerBufferProtocol('atom', (request, callback) => { protocol.registerBufferProtocol('atom', (request, callback) => {
callback({ mimeType: 'text/html', data: Buffer.from('<h5>Response</h5>') }) callback({ mimeType: 'text/html', data: Buffer.from('<h5>Response</h5>') })
}) })
``` ```
### `protocol.registerStringProtocol(scheme, handler)` _Deprecated_ ### `protocol.registerStringProtocol(scheme, handler)`
* `scheme` string * `scheme` string
* `handler` Function * `handler` Function
@@ -245,7 +170,7 @@ The usage is the same with `registerFileProtocol`, except that the `callback`
should be called with either a `string` or an object that has the `data` should be called with either a `string` or an object that has the `data`
property. property.
### `protocol.registerHttpProtocol(scheme, handler)` _Deprecated_ ### `protocol.registerHttpProtocol(scheme, handler)`
* `scheme` string * `scheme` string
* `handler` Function * `handler` Function
@@ -260,7 +185,7 @@ Registers a protocol of `scheme` that will send an HTTP request as a response.
The usage is the same with `registerFileProtocol`, except that the `callback` The usage is the same with `registerFileProtocol`, except that the `callback`
should be called with an object that has the `url` property. should be called with an object that has the `url` property.
### `protocol.registerStreamProtocol(scheme, handler)` _Deprecated_ ### `protocol.registerStreamProtocol(scheme, handler)`
* `scheme` string * `scheme` string
* `handler` Function * `handler` Function
@@ -278,7 +203,7 @@ has the `data` property.
Example: Example:
```js ```javascript
const { protocol } = require('electron') const { protocol } = require('electron')
const { PassThrough } = require('stream') const { PassThrough } = require('stream')
@@ -303,13 +228,13 @@ protocol.registerStreamProtocol('atom', (request, callback) => {
It is possible to pass any object that implements the readable stream API (emits It is possible to pass any object that implements the readable stream API (emits
`data`/`end`/`error` events). For example, here's how a file could be returned: `data`/`end`/`error` events). For example, here's how a file could be returned:
```js ```javascript
protocol.registerStreamProtocol('atom', (request, callback) => { protocol.registerStreamProtocol('atom', (request, callback) => {
callback(fs.createReadStream('index.html')) callback(fs.createReadStream('index.html'))
}) })
``` ```
### `protocol.unregisterProtocol(scheme)` _Deprecated_ ### `protocol.unregisterProtocol(scheme)`
* `scheme` string * `scheme` string
@@ -317,13 +242,13 @@ Returns `boolean` - Whether the protocol was successfully unregistered
Unregisters the custom protocol of `scheme`. Unregisters the custom protocol of `scheme`.
### `protocol.isProtocolRegistered(scheme)` _Deprecated_ ### `protocol.isProtocolRegistered(scheme)`
* `scheme` string * `scheme` string
Returns `boolean` - Whether `scheme` is already registered. Returns `boolean` - Whether `scheme` is already registered.
### `protocol.interceptFileProtocol(scheme, handler)` _Deprecated_ ### `protocol.interceptFileProtocol(scheme, handler)`
* `scheme` string * `scheme` string
* `handler` Function * `handler` Function
@@ -336,7 +261,7 @@ Returns `boolean` - Whether the protocol was successfully intercepted
Intercepts `scheme` protocol and uses `handler` as the protocol's new handler Intercepts `scheme` protocol and uses `handler` as the protocol's new handler
which sends a file as a response. which sends a file as a response.
### `protocol.interceptStringProtocol(scheme, handler)` _Deprecated_ ### `protocol.interceptStringProtocol(scheme, handler)`
* `scheme` string * `scheme` string
* `handler` Function * `handler` Function
@@ -349,7 +274,7 @@ Returns `boolean` - Whether the protocol was successfully intercepted
Intercepts `scheme` protocol and uses `handler` as the protocol's new handler Intercepts `scheme` protocol and uses `handler` as the protocol's new handler
which sends a `string` as a response. which sends a `string` as a response.
### `protocol.interceptBufferProtocol(scheme, handler)` _Deprecated_ ### `protocol.interceptBufferProtocol(scheme, handler)`
* `scheme` string * `scheme` string
* `handler` Function * `handler` Function
@@ -362,7 +287,7 @@ Returns `boolean` - Whether the protocol was successfully intercepted
Intercepts `scheme` protocol and uses `handler` as the protocol's new handler Intercepts `scheme` protocol and uses `handler` as the protocol's new handler
which sends a `Buffer` as a response. which sends a `Buffer` as a response.
### `protocol.interceptHttpProtocol(scheme, handler)` _Deprecated_ ### `protocol.interceptHttpProtocol(scheme, handler)`
* `scheme` string * `scheme` string
* `handler` Function * `handler` Function
@@ -375,7 +300,7 @@ Returns `boolean` - Whether the protocol was successfully intercepted
Intercepts `scheme` protocol and uses `handler` as the protocol's new handler Intercepts `scheme` protocol and uses `handler` as the protocol's new handler
which sends a new HTTP request as a response. which sends a new HTTP request as a response.
### `protocol.interceptStreamProtocol(scheme, handler)` _Deprecated_ ### `protocol.interceptStreamProtocol(scheme, handler)`
* `scheme` string * `scheme` string
* `handler` Function * `handler` Function
@@ -388,7 +313,7 @@ Returns `boolean` - Whether the protocol was successfully intercepted
Same as `protocol.registerStreamProtocol`, except that it replaces an existing Same as `protocol.registerStreamProtocol`, except that it replaces an existing
protocol handler. protocol handler.
### `protocol.uninterceptProtocol(scheme)` _Deprecated_ ### `protocol.uninterceptProtocol(scheme)`
* `scheme` string * `scheme` string
@@ -396,7 +321,7 @@ Returns `boolean` - Whether the protocol was successfully unintercepted
Remove the interceptor installed for `scheme` and restore its original handler. Remove the interceptor installed for `scheme` and restore its original handler.
### `protocol.isProtocolIntercepted(scheme)` _Deprecated_ ### `protocol.isProtocolIntercepted(scheme)`
* `scheme` string * `scheme` string

View File

@@ -6,7 +6,7 @@ Process: [Main](../glossary.md#main-process)
For example, when registering for push notifications via Apple push notification services (APNS): For example, when registering for push notifications via Apple push notification services (APNS):
```js ```javascript
const { pushNotifications, Notification } = require('electron') const { pushNotifications, Notification } = require('electron')
pushNotifications.registerForAPNSNotifications().then((token) => { pushNotifications.registerForAPNSNotifications().then((token) => {
@@ -26,7 +26,6 @@ The `pushNotification` module emits the following events:
Returns: Returns:
* `event` Event
* `userInfo` Record<String, any> * `userInfo` Record<String, any>
Emitted when the app receives a remote notification while running. Emitted when the app receives a remote notification while running.
@@ -40,7 +39,7 @@ The `pushNotification` module has the following methods:
Returns `Promise<string>` Returns `Promise<string>`
Registers the app with Apple Push Notification service (APNS) to receive [Badge, Sound, and Alert](https://developer.apple.com/documentation/appkit/nsremotenotificationtype?language=objc) notifications. If registration is successful, the promise will be resolved with the APNS device token. Otherwise, the promise will be rejected with an error message. Registers the app with Apple Push Notification service (APNS) to receive [Badge, Sound, and Alert](https://developer.apple.com/documentation/appkit/sremotenotificationtype?language=objc) notifications. If registration is successful, the promise will be resolved with the APNS device token. Otherwise, the promise will be rejected with an error message.
See: https://developer.apple.com/documentation/appkit/nsapplication/1428476-registerforremotenotificationtyp?language=objc See: https://developer.apple.com/documentation/appkit/nsapplication/1428476-registerforremotenotificationtyp?language=objc
### `pushNotifications.unregisterForAPNSNotifications()` _macOS_ ### `pushNotifications.unregisterForAPNSNotifications()` _macOS_

View File

@@ -38,28 +38,3 @@ Returns `string` - the decrypted string. Decrypts the encrypted buffer
obtained with `safeStorage.encryptString` back into a string. obtained with `safeStorage.encryptString` back into a string.
This function will throw an error if decryption fails. This function will throw an error if decryption fails.
### `safeStorage.setUsePlainTextEncryption(usePlainText)`
* `usePlainText` boolean
This function on Linux will force the module to use an in memory password for creating
symmetric key that is used for encrypt/decrypt functions when a valid OS password
manager cannot be determined for the current active desktop environment. This function
is a no-op on Windows and MacOS.
### `safeStorage.getSelectedStorageBackend()` _Linux_
Returns `string` - User friendly name of the password manager selected on Linux.
This function will return one of the following values:
* `basic_text` - When the desktop environment is not recognised or if the following
command line flag is provided `--password-store="basic"`.
* `gnome_libsecret` - When the desktop environment is `X-Cinnamon`, `Deepin`, `GNOME`, `Pantheon`, `XFCE`, `UKUI`, `unity` or if the following command line flag is provided `--password-store="gnome-libsecret"`.
* `kwallet` - When the desktop session is `kde4` or if the following command line flag
is provided `--password-store="kwallet"`.
* `kwallet5` - When the desktop session is `kde5` or if the following command line flag
is provided `--password-store="kwallet5"`.
* `kwallet6` - When the desktop session is `kde6`.
* `unknown` - When the function is called before app has emitted the `ready` event.

View File

@@ -14,29 +14,20 @@ property, so writing `let { screen } = require('electron')` will not work.
An example of creating a window that fills the whole screen: An example of creating a window that fills the whole screen:
```fiddle docs/fiddles/screen/fit-screen ```javascript fiddle='docs/fiddles/screen/fit-screen'
// Retrieve information about screen size, displays, cursor position, etc. const { app, BrowserWindow, screen } = require('electron')
//
// For more info, see:
// https://www.electronjs.org/docs/latest/api/screen
const { app, BrowserWindow, screen } = require('electron/main')
let mainWindow = null
let win
app.whenReady().then(() => { app.whenReady().then(() => {
// Create a window that fills the screen's available work area. const { width, height } = screen.getPrimaryDisplay().workAreaSize
const primaryDisplay = screen.getPrimaryDisplay() win = new BrowserWindow({ width, height })
const { width, height } = primaryDisplay.workAreaSize win.loadURL('https://github.com')
mainWindow = new BrowserWindow({ width, height })
mainWindow.loadURL('https://electronjs.org')
}) })
``` ```
Another example of creating a window in the external display: Another example of creating a window in the external display:
```js ```javascript
const { app, BrowserWindow, screen } = require('electron') const { app, BrowserWindow, screen } = require('electron')
let win let win

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