mirror of
https://github.com/electron/electron.git
synced 2026-02-19 03:14:51 -05:00
Compare commits
626 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8a89ff06c9 | ||
|
|
7c2df8860b | ||
|
|
56e45baeb8 | ||
|
|
5f712fa325 | ||
|
|
ba8915242a | ||
|
|
c9eb3deab5 | ||
|
|
58fd8825d2 | ||
|
|
6a8b70639b | ||
|
|
1766511e34 | ||
|
|
28eda03aba | ||
|
|
7685f27b31 | ||
|
|
463586a6c5 | ||
|
|
a39c0ee659 | ||
|
|
0b0a8a5ef3 | ||
|
|
986becdb4d | ||
|
|
75ea294b6f | ||
|
|
18717ee62d | ||
|
|
73e33bc876 | ||
|
|
c8544e25df | ||
|
|
9c7086074e | ||
|
|
d7e4bb6608 | ||
|
|
706653d5e4 | ||
|
|
65952abc99 | ||
|
|
50ce02c312 | ||
|
|
fb6b92076e | ||
|
|
d6c04a3787 | ||
|
|
2791474a01 | ||
|
|
f6e8a42c48 | ||
|
|
650ef9a51c | ||
|
|
a1c44a18e2 | ||
|
|
ec9c8476fe | ||
|
|
470a14d8d4 | ||
|
|
5bff0fe342 | ||
|
|
16aec702b4 | ||
|
|
ac040bf734 | ||
|
|
aceb432f45 | ||
|
|
d182794179 | ||
|
|
ab185c058f | ||
|
|
2324c4d8fd | ||
|
|
792037b338 | ||
|
|
0b44f433c8 | ||
|
|
5fa9dee68a | ||
|
|
75bad34131 | ||
|
|
0a064cece9 | ||
|
|
f6e8544ef6 | ||
|
|
029127a8b6 | ||
|
|
e71a56d11e | ||
|
|
65901f4c6a | ||
|
|
feb804cea8 | ||
|
|
34b79c15c2 | ||
|
|
d9ba26273a | ||
|
|
c96bb9958f | ||
|
|
d76a35afe4 | ||
|
|
c5b20eeb13 | ||
|
|
4cc0f6fb78 | ||
|
|
f27b034045 | ||
|
|
54d8402a6c | ||
|
|
89659fa9c9 | ||
|
|
89117fdd99 | ||
|
|
0b0707145b | ||
|
|
7858921a1f | ||
|
|
ac031bf8de | ||
|
|
b8ac798344 | ||
|
|
2182202e8e | ||
|
|
e66c1f6c56 | ||
|
|
9280b79112 | ||
|
|
2e79f34c84 | ||
|
|
f30fbebb98 | ||
|
|
f0ad357af2 | ||
|
|
5078cae861 | ||
|
|
b5997a012d | ||
|
|
f369b144d6 | ||
|
|
f2f83a73fc | ||
|
|
d42a94ddde | ||
|
|
3bdc7ce64a | ||
|
|
48e14bc54e | ||
|
|
83760bd5c6 | ||
|
|
e14964ccd0 | ||
|
|
33000c4b42 | ||
|
|
33e66b5cd0 | ||
|
|
2affecd4dd | ||
|
|
381c955bca | ||
|
|
35969939a1 | ||
|
|
a8999bc529 | ||
|
|
522bba3dc6 | ||
|
|
ddc7e3ebb3 | ||
|
|
2481f94b4e | ||
|
|
e1d63794e5 | ||
|
|
bfa58df7c9 | ||
|
|
c1898c39bf | ||
|
|
3102a257af | ||
|
|
90865fa97d | ||
|
|
3a91d1f1e1 | ||
|
|
09190085c0 | ||
|
|
9937a2bbe8 | ||
|
|
95bf9d8adb | ||
|
|
c75e193a3e | ||
|
|
0621f39296 | ||
|
|
aeb89b143b | ||
|
|
213388cd87 | ||
|
|
8374b9c2ad | ||
|
|
00746e662b | ||
|
|
31dfde7fa6 | ||
|
|
dd8df3b0c4 | ||
|
|
b04ce6a5c8 | ||
|
|
fce9ed65d6 | ||
|
|
a4a3ba9341 | ||
|
|
9d6d606192 | ||
|
|
1eb398b328 | ||
|
|
f7a7085019 | ||
|
|
0c45d160d6 | ||
|
|
22429e2112 | ||
|
|
1d20ec5b99 | ||
|
|
22c359ac4f | ||
|
|
c3036d4557 | ||
|
|
bee5d94886 | ||
|
|
ef5d5f888d | ||
|
|
127584dc37 | ||
|
|
8e3dcc8b17 | ||
|
|
5d11c30720 | ||
|
|
813853297d | ||
|
|
dbff7bb531 | ||
|
|
effafdf498 | ||
|
|
9eeef55469 | ||
|
|
1b3e4dae8d | ||
|
|
d5f31c2208 | ||
|
|
d166182865 | ||
|
|
cf658b700d | ||
|
|
08bbff5361 | ||
|
|
117d5310f5 | ||
|
|
f16dffccd0 | ||
|
|
255064659f | ||
|
|
11600c5f96 | ||
|
|
1ce2fdd63d | ||
|
|
c4d417b6f6 | ||
|
|
0f49868234 | ||
|
|
70508b5273 | ||
|
|
a0effaf9b8 | ||
|
|
d9329042e2 | ||
|
|
0425454687 | ||
|
|
d24d8f1f78 | ||
|
|
ab08803959 | ||
|
|
5e59ddca1a | ||
|
|
1b3c63145c | ||
|
|
814735cb72 | ||
|
|
dcf1c65426 | ||
|
|
24c9cbcc0a | ||
|
|
eecfaec8c9 | ||
|
|
8f4f82618c | ||
|
|
1548a2f9fb | ||
|
|
3d45429667 | ||
|
|
67523a47b4 | ||
|
|
330c775252 | ||
|
|
dc707ee938 | ||
|
|
1eb6e45a36 | ||
|
|
2e0517c0ad | ||
|
|
c5b9f766f3 | ||
|
|
6d0e8044eb | ||
|
|
f8b05bc127 | ||
|
|
e6931a788f | ||
|
|
e96b1613a4 | ||
|
|
fe93f69e5a | ||
|
|
c5e50e4882 | ||
|
|
7686d1c379 | ||
|
|
303b707fbf | ||
|
|
aaae2abf20 | ||
|
|
0eef6c67d1 | ||
|
|
1f19a74417 | ||
|
|
c8f7a0e052 | ||
|
|
b2c62d6ad1 | ||
|
|
cfc0826b65 | ||
|
|
8e5bb4949b | ||
|
|
724f90a2a7 | ||
|
|
68701c4c3c | ||
|
|
2b283724ce | ||
|
|
6df392162f | ||
|
|
c9bae5da8e | ||
|
|
8dea783805 | ||
|
|
695fcf3cb2 | ||
|
|
fa5b1be6f3 | ||
|
|
38c3d8df29 | ||
|
|
12548294c0 | ||
|
|
455f57322f | ||
|
|
77cc1d6ffa | ||
|
|
e543126957 | ||
|
|
1231f0a734 | ||
|
|
cd408a826c | ||
|
|
3df6d337f3 | ||
|
|
09e6e4b9a7 | ||
|
|
2caf08059e | ||
|
|
1ca3a7d3c9 | ||
|
|
2c52eb7e1c | ||
|
|
9cd5de7588 | ||
|
|
a83f9c06d7 | ||
|
|
b66449add5 | ||
|
|
ada8eb33b2 | ||
|
|
3a5e2dd90c | ||
|
|
6688b0f31a | ||
|
|
565705bd1d | ||
|
|
e02cf8674d | ||
|
|
3e7c904f02 | ||
|
|
f2b32af1f6 | ||
|
|
cc39ddb728 | ||
|
|
bbdd037219 | ||
|
|
ee4460ac68 | ||
|
|
00d96970cb | ||
|
|
139774ce48 | ||
|
|
47951cc95b | ||
|
|
8874306dc0 | ||
|
|
4ab0a5ade4 | ||
|
|
626f46f75a | ||
|
|
9645f7f6d8 | ||
|
|
f61425efdb | ||
|
|
34e7c3696a | ||
|
|
dc671804da | ||
|
|
b14b876d50 | ||
|
|
a8622aed7b | ||
|
|
da3475998f | ||
|
|
9d1a16b2e6 | ||
|
|
b142fce229 | ||
|
|
f959fb0c96 | ||
|
|
905e41bbdd | ||
|
|
3e3152008f | ||
|
|
f3f3f53904 | ||
|
|
117a700724 | ||
|
|
c7bdd907d7 | ||
|
|
56b5c00312 | ||
|
|
040e9a027a | ||
|
|
a97028bacf | ||
|
|
cc7d724a3b | ||
|
|
c7a64ab994 | ||
|
|
5a77c75753 | ||
|
|
ec4c9024b9 | ||
|
|
3fa15ebb7e | ||
|
|
52fe76ca28 | ||
|
|
e991c1868e | ||
|
|
ccd4531bfb | ||
|
|
499d893040 | ||
|
|
607e71d563 | ||
|
|
09669f9d21 | ||
|
|
ff6d0df2d5 | ||
|
|
81a454d148 | ||
|
|
acba6d79fb | ||
|
|
327af3b03c | ||
|
|
ef6569b7d3 | ||
|
|
e900f6ecc3 | ||
|
|
9226cc662b | ||
|
|
abec9ead06 | ||
|
|
395b608dd5 | ||
|
|
1eb19f3078 | ||
|
|
a00a25376d | ||
|
|
ce6fe040fe | ||
|
|
e73edb5481 | ||
|
|
74d73166d9 | ||
|
|
6bd02bf181 | ||
|
|
a595044989 | ||
|
|
f6bbc34658 | ||
|
|
2b3902e526 | ||
|
|
93024be3b2 | ||
|
|
b693f88491 | ||
|
|
97132ece33 | ||
|
|
41ab5f327f | ||
|
|
7219142a54 | ||
|
|
46fb0d8f5f | ||
|
|
d78f37ec8f | ||
|
|
bf1ba4a857 | ||
|
|
bb4e9b27b5 | ||
|
|
30579859c4 | ||
|
|
5ad8b4b7d1 | ||
|
|
f7c0a29d89 | ||
|
|
10852b3fd5 | ||
|
|
dc2e822dc7 | ||
|
|
46458ab517 | ||
|
|
9aefe5db33 | ||
|
|
167c2b250e | ||
|
|
1621fcf5d3 | ||
|
|
18d484f39c | ||
|
|
e37111edcc | ||
|
|
80a3ba5c68 | ||
|
|
678d1aa37d | ||
|
|
f5869b6fb9 | ||
|
|
ab49e98401 | ||
|
|
fa6d14c22d | ||
|
|
5d123765d9 | ||
|
|
fd5e6fbc14 | ||
|
|
a3448376a1 | ||
|
|
c0d9764de9 | ||
|
|
e8fd5fd3a8 | ||
|
|
d95ae19edf | ||
|
|
12b85a77a8 | ||
|
|
38dc43f649 | ||
|
|
43f5cf1eae | ||
|
|
2a81b2aea3 | ||
|
|
05d39d8313 | ||
|
|
806f00285c | ||
|
|
534bf77d9b | ||
|
|
9d8da7839e | ||
|
|
95d6a932ca | ||
|
|
4956bcc6bd | ||
|
|
c8bdd014c8 | ||
|
|
5ee890fb6f | ||
|
|
9a9d8ae5ea | ||
|
|
0294debc31 | ||
|
|
933544d449 | ||
|
|
bbfba4fc24 | ||
|
|
be45614f6f | ||
|
|
1f08e46bca | ||
|
|
714402b08e | ||
|
|
08ab45535d | ||
|
|
69790f4b2a | ||
|
|
c5972ba43c | ||
|
|
86824c070e | ||
|
|
5931f69f18 | ||
|
|
80246cf97f | ||
|
|
28332c94bf | ||
|
|
5c1321b20a | ||
|
|
7982c6cee2 | ||
|
|
b2059f288a | ||
|
|
bb2ba35b51 | ||
|
|
8d689c565a | ||
|
|
905aad9cb6 | ||
|
|
4c89061e0e | ||
|
|
8fdd7de3d2 | ||
|
|
83d023747c | ||
|
|
05db963f87 | ||
|
|
f247ca3f62 | ||
|
|
d818f35ad4 | ||
|
|
9ffffdb6ef | ||
|
|
c14f7b7d0b | ||
|
|
74b8133a93 | ||
|
|
57147d1b8d | ||
|
|
67f273a6d6 | ||
|
|
b454f8c7c1 | ||
|
|
663497dc6b | ||
|
|
115d37477e | ||
|
|
2c742cfadb | ||
|
|
40e724e5dd | ||
|
|
13f9e2db40 | ||
|
|
a769b48164 | ||
|
|
b4ec363b3d | ||
|
|
71fb19ea14 | ||
|
|
a6f7c7690d | ||
|
|
0203bd3305 | ||
|
|
9640ac441d | ||
|
|
b233d0805a | ||
|
|
56138d879e | ||
|
|
ddcec84ace | ||
|
|
185180a8e2 | ||
|
|
470b1d9e9d | ||
|
|
a20896f519 | ||
|
|
64045fd058 | ||
|
|
294f196907 | ||
|
|
82af000a37 | ||
|
|
1c075e5ea0 | ||
|
|
ec85be3fb0 | ||
|
|
06cc9caeaa | ||
|
|
13fae292a7 | ||
|
|
c4c17d7534 | ||
|
|
a043a60b89 | ||
|
|
2f8e68f8b3 | ||
|
|
16cd486356 | ||
|
|
f07b040cb9 | ||
|
|
b6ef4a3929 | ||
|
|
dec9a1d9db | ||
|
|
b6c80ba646 | ||
|
|
30e992dec4 | ||
|
|
e7b8bb4766 | ||
|
|
aebcd3a8c4 | ||
|
|
395abf5620 | ||
|
|
508d7c1353 | ||
|
|
826c29abcc | ||
|
|
2acb97aa85 | ||
|
|
642950a00e | ||
|
|
b35ec4a23c | ||
|
|
e138f5f915 | ||
|
|
a22635bd9f | ||
|
|
683235daf0 | ||
|
|
32d8f84cad | ||
|
|
ad07712561 | ||
|
|
9902e01d2c | ||
|
|
e08c583dea | ||
|
|
2a16c73834 | ||
|
|
c7ca29e80f | ||
|
|
fa81f77f40 | ||
|
|
c05051e307 | ||
|
|
8b63a3fc8a | ||
|
|
e83197669c | ||
|
|
9bd9d312f8 | ||
|
|
042663e190 | ||
|
|
e19500fa03 | ||
|
|
c2d7164021 | ||
|
|
a1b2dae68e | ||
|
|
c591ecf518 | ||
|
|
d1c5e623fa | ||
|
|
9ac4787325 | ||
|
|
6645f49a9d | ||
|
|
e7fc1a422d | ||
|
|
eeb1e7d499 | ||
|
|
0149ae72e6 | ||
|
|
88a9962e22 | ||
|
|
3dbc0a365f | ||
|
|
141175c723 | ||
|
|
95cd84f140 | ||
|
|
894e056e6b | ||
|
|
2806feede2 | ||
|
|
13e309e1fb | ||
|
|
f432245456 | ||
|
|
0212c264ca | ||
|
|
9ccf2275d2 | ||
|
|
911900eae9 | ||
|
|
7a03509b71 | ||
|
|
a6c9aefb4a | ||
|
|
13be6dc8b4 | ||
|
|
3a7cfe300a | ||
|
|
88710612a3 | ||
|
|
58d49927a3 | ||
|
|
534e90c2a6 | ||
|
|
35a03a6bc1 | ||
|
|
a7adbae543 | ||
|
|
f8d534f33e | ||
|
|
ec75172d68 | ||
|
|
bb490161fb | ||
|
|
bc957e3945 | ||
|
|
ee1e6aab3e | ||
|
|
7f5364f98d | ||
|
|
a8c0ed890f | ||
|
|
a26343f3e0 | ||
|
|
d95f9d2c63 | ||
|
|
c548f8f59e | ||
|
|
7c482518bf | ||
|
|
a2d35e9cf5 | ||
|
|
ba8887f586 | ||
|
|
f35b9b3f06 | ||
|
|
a0a44f07dd | ||
|
|
08593fd2bd | ||
|
|
fe5cdd39d6 | ||
|
|
05faabe9e8 | ||
|
|
9d525f9861 | ||
|
|
e823869bb0 | ||
|
|
f4b7e59b2d | ||
|
|
a0a1a3645b | ||
|
|
9b41ab1e53 | ||
|
|
141f65b291 | ||
|
|
b626be5e33 | ||
|
|
964934c161 | ||
|
|
f727da4a74 | ||
|
|
cf4c46c8e0 | ||
|
|
0240f6664e | ||
|
|
f12e12b341 | ||
|
|
7e715b66ae | ||
|
|
ba835ddac1 | ||
|
|
b2411e05a8 | ||
|
|
de192c2db2 | ||
|
|
941153be32 | ||
|
|
32afdda9ee | ||
|
|
f4b172b9ec | ||
|
|
7a6af1a529 | ||
|
|
1ffe7ee76b | ||
|
|
c857c9b7e2 | ||
|
|
f0e1848a5e | ||
|
|
d1cddf2517 | ||
|
|
c7ea887227 | ||
|
|
fa3379a5d5 | ||
|
|
cdace75389 | ||
|
|
e84bcb39e7 | ||
|
|
fceeb64e7c | ||
|
|
f03315ad4d | ||
|
|
6f2ab392ab | ||
|
|
33a625d0ee | ||
|
|
2ad1324b9d | ||
|
|
fef1b04238 | ||
|
|
908bef7ca9 | ||
|
|
c326b0068e | ||
|
|
c01dff8d89 | ||
|
|
c65632d404 | ||
|
|
adb1172066 | ||
|
|
e929b2140d | ||
|
|
82442239bc | ||
|
|
3c0c4d5c27 | ||
|
|
6958668448 | ||
|
|
1e206deec3 | ||
|
|
e8c87859c4 | ||
|
|
83e186fdbc | ||
|
|
9563b5f98b | ||
|
|
251e567eff | ||
|
|
6bfef67aae | ||
|
|
db27b9f433 | ||
|
|
be32740991 | ||
|
|
b8a21dbcd7 | ||
|
|
58f3c0ee37 | ||
|
|
3f42040a1b | ||
|
|
e9d5c3517c | ||
|
|
91f62ae73f | ||
|
|
4c8583c365 | ||
|
|
0b4ef2b1e5 | ||
|
|
4ba5723aed | ||
|
|
652d603e69 | ||
|
|
f40bd2da23 | ||
|
|
e31f101712 | ||
|
|
4415b7638a | ||
|
|
f7c6545eab | ||
|
|
ef657bdc9d | ||
|
|
6012172187 | ||
|
|
a75b892e90 | ||
|
|
7c4f4c537e | ||
|
|
4ca6fb3c4e | ||
|
|
3fa03977c7 | ||
|
|
75919e28b8 | ||
|
|
ac58607605 | ||
|
|
835ace243c | ||
|
|
8f3ef39f1e | ||
|
|
48e13fde80 | ||
|
|
bb6648b79e | ||
|
|
2b9dae4b06 | ||
|
|
2e1f803f37 | ||
|
|
4c6092e151 | ||
|
|
b72f81ab5b | ||
|
|
97b19a7946 | ||
|
|
b27e4cae21 | ||
|
|
1e106c8aa4 | ||
|
|
fda8ea9277 | ||
|
|
6a6908c4c8 | ||
|
|
42e7cd9b3f | ||
|
|
8cf03f5661 | ||
|
|
916861036d | ||
|
|
52481bc923 | ||
|
|
5023b49713 | ||
|
|
2ac9ff1f20 | ||
|
|
46d3c4e04f | ||
|
|
0f77fec9d9 | ||
|
|
94f701edb8 | ||
|
|
caa5989eed | ||
|
|
e0c348a2f8 | ||
|
|
eb613ef3d4 | ||
|
|
7ed3c7a359 | ||
|
|
64b39dce14 | ||
|
|
5261e08d0c | ||
|
|
9611b641c9 | ||
|
|
095f9067a7 | ||
|
|
b8f970c1c7 | ||
|
|
48d0b09ad9 | ||
|
|
c5fc5efc00 | ||
|
|
6dc46e5bcf | ||
|
|
061e2e5e73 | ||
|
|
bf1cc1aeb2 | ||
|
|
e480cb7103 | ||
|
|
3b69a542fb | ||
|
|
82456c6915 | ||
|
|
e58f0411d9 | ||
|
|
e61728beb9 | ||
|
|
feaf18e371 | ||
|
|
8ee58e18fd | ||
|
|
f33bf2a271 | ||
|
|
77bd80dfb2 | ||
|
|
0d3aee26b9 | ||
|
|
efde7a140b | ||
|
|
4e85bb921b | ||
|
|
512e56baf7 | ||
|
|
c8f715f9a1 | ||
|
|
829fb4f586 | ||
|
|
17ccb3c6ec | ||
|
|
6bd9ee6988 | ||
|
|
76c825d619 | ||
|
|
692876c737 | ||
|
|
c3f06ef037 | ||
|
|
9b20b3a722 | ||
|
|
8f2917db01 | ||
|
|
49df19214e | ||
|
|
5e25d23794 | ||
|
|
8fb0f43030 | ||
|
|
1f390119fe | ||
|
|
87f2a1d572 | ||
|
|
2e03bdb9b6 | ||
|
|
3a5ae28c95 | ||
|
|
ed7b5c44a2 | ||
|
|
edf887bdc5 | ||
|
|
1ff7f098f1 | ||
|
|
fb100e8f49 | ||
|
|
3384908da1 | ||
|
|
73bd9a3155 | ||
|
|
e27905c765 | ||
|
|
a3e3efe4c4 | ||
|
|
46c8b9c728 | ||
|
|
6395898a79 | ||
|
|
32c60b29bb | ||
|
|
868676aa5c | ||
|
|
85cf56d80b | ||
|
|
a92fd2aa05 | ||
|
|
ee966ad6ec | ||
|
|
872d1fe05a | ||
|
|
63f94f2359 | ||
|
|
67a6fbf265 | ||
|
|
f97d68c4bf | ||
|
|
969665eaa2 | ||
|
|
0d8dd61257 | ||
|
|
cf10c19c33 | ||
|
|
fcfbcbc7e1 | ||
|
|
e34cc6f48c | ||
|
|
ee87438d28 | ||
|
|
0de1012280 | ||
|
|
0a5e634736 | ||
|
|
73b7aac6a4 | ||
|
|
ea848bc1c5 | ||
|
|
a44e76fb70 | ||
|
|
3138acc377 | ||
|
|
beed240454 | ||
|
|
fdab0799fe | ||
|
|
17ea7f42fc | ||
|
|
d0cf9c4b08 | ||
|
|
fe7c535a3f | ||
|
|
8eee4f2df1 | ||
|
|
4d6f230d21 | ||
|
|
889859df5b | ||
|
|
cb03c6516b | ||
|
|
2e8114aea3 | ||
|
|
a38b711fb1 | ||
|
|
3972073116 | ||
|
|
8c986ff194 | ||
|
|
71944f2c3b | ||
|
|
8b3e498436 | ||
|
|
cf80994729 | ||
|
|
01f1522cbd | ||
|
|
a37f572388 | ||
|
|
3180312595 | ||
|
|
ff60fe25c1 | ||
|
|
12ed401ca2 |
@@ -62,9 +62,12 @@ jobs:
|
||||
cd .circleci/config
|
||||
yarn
|
||||
export CIRCLECI_BINARY="$HOME/circleci"
|
||||
curl -fLSs https://raw.githubusercontent.com/CircleCI-Public/circleci-cli/master/install.sh | DESTDIR=$CIRCLECI_BINARY bash
|
||||
curl -fLSs https://raw.githubusercontent.com/CircleCI-Public/circleci-cli/main/install.sh | DESTDIR=$CIRCLECI_BINARY bash
|
||||
node build.js
|
||||
name: Pack config.yml
|
||||
- run:
|
||||
name: Set params
|
||||
command: node .circleci/config/params.js
|
||||
- continuation/continue:
|
||||
configuration_path: .circleci/config-staging/built.yml
|
||||
parameters: /tmp/pipeline-parameters.json
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
12
.circleci/config/params.js
Normal file
12
.circleci/config/params.js
Normal file
@@ -0,0 +1,12 @@
|
||||
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));
|
||||
@@ -3,5 +3,6 @@
|
||||
set -e
|
||||
|
||||
mkdir -p ~/.ssh
|
||||
echo "|1|B3r+7aO0/x90IdefihIjxIoJrrk=|OJddGDfhbuLFc1bUyy84hhIw57M= ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==
|
||||
|1|rGlEvW55DtzNZp+pzw9gvyOyKi4=|LLWr+7qlkAlw3YGGVfLHHxB/kR0= ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==" >> ~/.ssh/known_hosts
|
||||
echo "github.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl
|
||||
github.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg=
|
||||
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
|
||||
|
||||
4
.clang-tidy
Normal file
4
.clang-tidy
Normal file
@@ -0,0 +1,4 @@
|
||||
---
|
||||
Checks: '-modernize-use-nullptr'
|
||||
InheritParentConfig: true
|
||||
...
|
||||
@@ -4,37 +4,6 @@
|
||||
"onCreateCommand": ".devcontainer/on-create-command.sh",
|
||||
"updateContentCommand": ".devcontainer/update-content-command.sh",
|
||||
"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],
|
||||
"portsAttributes": {
|
||||
"8088": {
|
||||
@@ -60,6 +29,38 @@
|
||||
"openFiles": [
|
||||
".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"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,8 @@ ln -s $buildtools_configs $buildtools/configs
|
||||
|
||||
# Write the gclient config if it does not already exist
|
||||
if [ ! -f $gclient_root/.gclient ]; then
|
||||
echo "Creating gclient config"
|
||||
|
||||
echo "solutions = [
|
||||
{ \"name\" : \"src/electron\",
|
||||
\"url\" : \"https://github.com/electron/electron\",
|
||||
@@ -32,11 +34,18 @@ fi
|
||||
# Write the default buildtools config file if it does
|
||||
# not already exist
|
||||
if [ ! -f $buildtools/configs/evm.testing.json ]; then
|
||||
echo "Creating build-tools testing config"
|
||||
|
||||
write_config() {
|
||||
echo "
|
||||
{
|
||||
\"root\": \"/workspaces/gclient\",
|
||||
\"goma\": \"$1\",
|
||||
\"root\": \"/workspaces/gclient\",
|
||||
\"remotes\": {
|
||||
\"electron\": {
|
||||
\"origin\": \"https://github.com/electron/electron.git\"
|
||||
}
|
||||
},
|
||||
\"gen\": {
|
||||
\"args\": [
|
||||
\"import(\\\"//electron/build/args/testing.gn\\\")\",
|
||||
@@ -48,11 +57,7 @@ if [ ! -f $buildtools/configs/evm.testing.json ]; then
|
||||
\"CHROMIUM_BUILDTOOLS_PATH\": \"/workspaces/gclient/src/buildtools\",
|
||||
\"GIT_CACHE_PATH\": \"/workspaces/gclient/.git-cache\"
|
||||
},
|
||||
\"remotes\": {
|
||||
\"electron\": {
|
||||
\"origin\": \"https://github.com/electron/electron.git\"
|
||||
}
|
||||
}
|
||||
\"\$schema\": \"file:///home/builduser/.electron_build_tools/evm-config.schema.json\"
|
||||
}
|
||||
" >$buildtools/configs/evm.testing.json
|
||||
}
|
||||
@@ -66,10 +71,12 @@ if [ ! -f $buildtools/configs/evm.testing.json ]; then
|
||||
# if it works we can use the goma cluster
|
||||
export NOTGOMA_CODESPACES_TOKEN=$GITHUB_TOKEN
|
||||
if e d goma_auth login; then
|
||||
echo "$GITHUB_USER has GOMA access - switching to cluster mode"
|
||||
write_config cluster
|
||||
fi
|
||||
else
|
||||
# Even if the config file existed we still need to re-auth with the goma
|
||||
# cluster
|
||||
echo "build-tools testing config already exists"
|
||||
|
||||
# Re-auth with the goma cluster regardless.
|
||||
NOTGOMA_CODESPACES_TOKEN=$GITHUB_TOKEN e d goma_auth login || true
|
||||
fi
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
"semi": ["error", "always"],
|
||||
"no-var": "error",
|
||||
"no-unused-vars": "off",
|
||||
"no-global-assign": "off",
|
||||
"guard-for-in": "error",
|
||||
"@typescript-eslint/no-unused-vars": ["error", {
|
||||
"vars": "all",
|
||||
@@ -20,20 +19,13 @@
|
||||
"prefer-const": ["error", {
|
||||
"destructuring": "all"
|
||||
}],
|
||||
"standard/no-callback-literal": "off",
|
||||
"node/no-deprecated-api": "off"
|
||||
"standard/no-callback-literal": "off"
|
||||
},
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 6,
|
||||
"sourceType": "module"
|
||||
},
|
||||
"overrides": [
|
||||
{
|
||||
"files": "*.js",
|
||||
"rules": {
|
||||
"@typescript-eslint/no-unused-vars": "off"
|
||||
}
|
||||
},
|
||||
{
|
||||
"files": "*.ts",
|
||||
"rules": {
|
||||
|
||||
24
.gitattributes
vendored
24
.gitattributes
vendored
@@ -4,11 +4,27 @@
|
||||
patches/**/.patches merge=union
|
||||
|
||||
# Source code and markdown files should always use LF as line ending.
|
||||
*.c text eol=lf
|
||||
*.cc text eol=lf
|
||||
*.mm 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
|
||||
*.js text eol=lf
|
||||
*.ts 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
|
||||
*.mojom text eol=lf
|
||||
*.proto text eol=lf
|
||||
*.py text eol=lf
|
||||
*.ps1 text eol=lf
|
||||
*.md text eol=lf
|
||||
*.sh text eol=lf
|
||||
*.ts text eol=lf
|
||||
*.txt text eol=lf
|
||||
|
||||
2
.github/CODEOWNERS
vendored
2
.github/CODEOWNERS
vendored
@@ -8,12 +8,12 @@
|
||||
DEPS @electron/wg-upgrades
|
||||
|
||||
# Releases WG
|
||||
/docs/breaking-changes.md @electron/wg-releases
|
||||
/npm/ @electron/wg-releases
|
||||
/script/release @electron/wg-releases
|
||||
|
||||
# Security WG
|
||||
/lib/browser/devtools.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/renderer/security-warnings.ts @electron/wg-security
|
||||
|
||||
1
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
1
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
@@ -2,6 +2,7 @@ name: Bug Report
|
||||
description: Report an Electron bug
|
||||
title: "[Bug]: "
|
||||
labels: "bug :beetle:"
|
||||
projects: ["electron/90"]
|
||||
body:
|
||||
- type: checkboxes
|
||||
attributes:
|
||||
|
||||
14
.github/config.yml
vendored
14
.github/config.yml
vendored
@@ -25,17 +25,3 @@ newPRWelcomeComment: |
|
||||
# Comment to be posted to on pull requests merged by a first time user
|
||||
firstPRMergeComment: >
|
||||
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
|
||||
|
||||
165
.github/workflows/branch-created.yml
vendored
Normal file
165
.github/workflows/branch-created.yml
vendored
Normal file
@@ -0,0 +1,165 @@
|
||||
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') }}
|
||||
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@cc6751b3b5e4edc5b9a4ad0a021ac455653b6dc8 # v1.0.0
|
||||
id: generate-token
|
||||
with:
|
||||
creds: ${{ secrets.RELEASE_BOARD_GH_APP_CREDS }}
|
||||
org: electron
|
||||
- name: Create Release Project Board
|
||||
if: ${{ steps.check-major-version.outputs.MAJOR }}
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
|
||||
MAJOR: ${{ steps.check-major-version.outputs.MAJOR }}
|
||||
ELECTRON_ORG_ID: "O_kgDOAMybxg"
|
||||
ELECTRON_REPO_ID: "R_kgDOAI8xSw"
|
||||
TEMPLATE_PROJECT_ID: "PVT_kwDOAMybxs4AQvib"
|
||||
run: |
|
||||
# Copy template to create new project board
|
||||
PROJECT_ID=$(gh api graphql -f query='mutation ($ownerId: ID!, $projectId: ID!, $title: String!) {
|
||||
copyProjectV2(input: {
|
||||
includeDraftIssues: true,
|
||||
ownerId: $ownerId,
|
||||
projectId: $projectId,
|
||||
title: $title
|
||||
}) {
|
||||
projectV2 {
|
||||
id
|
||||
}
|
||||
}
|
||||
}' -f ownerId=$ELECTRON_ORG_ID -f projectId=$TEMPLATE_PROJECT_ID -f title="${MAJOR}-x-y" | jq -r '.data.copyProjectV2.projectV2.id')
|
||||
|
||||
# Make the new project public
|
||||
gh api graphql -f query='mutation ($projectId: ID!) {
|
||||
updateProjectV2(input: {
|
||||
projectId: $projectId,
|
||||
public: true,
|
||||
}) {
|
||||
projectV2 {
|
||||
id
|
||||
}
|
||||
}
|
||||
}' -f projectId=$PROJECT_ID
|
||||
|
||||
# Link the new project to the Electron repository
|
||||
gh api graphql -f query='mutation ($projectId: ID!, $repositoryId: ID!) {
|
||||
linkProjectV2ToRepository(input: {
|
||||
projectId: $projectId,
|
||||
repositoryId: $repositoryId
|
||||
}) {
|
||||
clientMutationId
|
||||
}
|
||||
}' -f projectId=$PROJECT_ID -f repositoryId=$ELECTRON_REPO_ID
|
||||
|
||||
# Get all draft issues on the new project board
|
||||
gh api graphql -f query='query ($id: ID!) {
|
||||
node(id: $id) {
|
||||
... on ProjectV2 {
|
||||
items(first: 100) {
|
||||
nodes {
|
||||
... on ProjectV2Item {
|
||||
id
|
||||
content {
|
||||
... on DraftIssue { id title
|
||||
body
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}' -f id=$PROJECT_ID > issues.json
|
||||
PROJECT_ITEMS=$(jq '.data.node.items.nodes[] | select(.content.id != null) | .id' issues.json)
|
||||
|
||||
#
|
||||
# Do template replacement for draft issues
|
||||
#
|
||||
echo "{\"major\": $MAJOR, \"next-major\": $((MAJOR + 1)), \"prev-major\": $((MAJOR - 1))}" > variables.json
|
||||
|
||||
# npx mustache is annoyingly slow, so install mustache directly
|
||||
yarn add -D mustache
|
||||
|
||||
for PROJECT_ITEM_ID in $PROJECT_ITEMS; do
|
||||
# These are done with the raw output flag and sent to file to better retain formatting
|
||||
jq -r ".data.node.items.nodes[] | select(.id == $PROJECT_ITEM_ID) | .content.title" issues.json > title.txt
|
||||
jq -r ".data.node.items.nodes[] | select(.id == $PROJECT_ITEM_ID) | .content.body" issues.json > body.txt
|
||||
|
||||
./node_modules/.bin/mustache variables.json title.txt new_title.txt
|
||||
./node_modules/.bin/mustache variables.json body.txt new_body.txt
|
||||
|
||||
# Only update draft issues which had content change when interpolated
|
||||
if ! cmp --silent -- new_title.txt title.txt || ! cmp --silent -- new_body.txt body.txt; then
|
||||
DRAFT_ISSUE_ID=$(jq ".data.node.items.nodes[] | select(.id == $PROJECT_ITEM_ID) | .content.id" issues.json)
|
||||
gh api graphql -f query='mutation ($draftIssueId: ID!, $title: String!, $body: String!) {
|
||||
updateProjectV2DraftIssue(input: {
|
||||
draftIssueId: $draftIssueId,
|
||||
title: $title,
|
||||
body: $body
|
||||
}) {
|
||||
draftIssue {
|
||||
id
|
||||
}
|
||||
}
|
||||
}' -f draftIssueId=$DRAFT_ISSUE_ID -f title="$(cat new_title.txt)" -f body="$(cat new_body.txt)"
|
||||
fi
|
||||
done
|
||||
26
.github/workflows/issue-commented.yml
vendored
Normal file
26
.github/workflows/issue-commented.yml
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
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'
|
||||
52
.github/workflows/issue-labeled.yml
vendored
52
.github/workflows/issue-labeled.yml
vendored
@@ -8,21 +8,63 @@ permissions: # added using https://github.com/step-security/secure-workflows
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
issue-labeled:
|
||||
issue-labeled-blocked:
|
||||
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: github/update-project-action@2d475e08804f11f4022df7e21f5816531e97cb64 # v2
|
||||
with:
|
||||
github_token: ${{ steps.generate-token.outputs.token }}
|
||||
organization: electron
|
||||
project_number: 90
|
||||
content_id: ${{ github.event.issue.node_id }}
|
||||
field: Status
|
||||
value: 🛑 Blocked
|
||||
issue-labeled-blocked-need-repro:
|
||||
name: blocked/need-repro label added
|
||||
if: github.event.label.name == 'blocked/need-repro'
|
||||
permissions:
|
||||
issues: write # for actions-cool/issues-helper to update issues
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: blocked/need-repro label added
|
||||
if: github.event.label.name == 'blocked/need-repro'
|
||||
uses: actions-cool/issues-helper@dad28fdb88da5f082c04659b7373d85790f9b135 # v3.3.0
|
||||
- name: Check if comment needed
|
||||
id: check-for-comment
|
||||
env:
|
||||
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:
|
||||
actions: 'create-comment'
|
||||
token: ${{ steps.generate-token.outputs.token }}
|
||||
body: |
|
||||
<!-- blocked/need-repro -->
|
||||
|
||||
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.
|
||||
|
||||
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 `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.
|
||||
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.
|
||||
|
||||
40
.github/workflows/issue-unlabeled.yml
vendored
Normal file
40
.github/workflows/issue-unlabeled.yml
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
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: github/update-project-action@2d475e08804f11f4022df7e21f5816531e97cb64 # v2
|
||||
with:
|
||||
github_token: ${{ steps.generate-token.outputs.token }}
|
||||
organization: electron
|
||||
project_number: 90
|
||||
content_id: ${{ github.event.issue.node_id }}
|
||||
field: Status
|
||||
value: 📥 Was Blocked
|
||||
30
.github/workflows/pull-request-labeled.yml
vendored
Normal file
30
.github/workflows/pull-request-labeled.yml
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
name: Pull Request Labeled
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [labeled]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
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/update-project-action@7ade91760df70df76770a238abee7a4869e01cf8
|
||||
with:
|
||||
github_token: ${{ steps.generate-token.outputs.token }}
|
||||
organization: electron
|
||||
project_number: 94
|
||||
content_id: ${{ github.event.pull_request.node_id }}
|
||||
field: Status
|
||||
value: ✅ Reviewed
|
||||
@@ -1,33 +0,0 @@
|
||||
name: Trigger Major Release Dependency Updates
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
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-9]+\.[0-9]+$ ]]; 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 }}"
|
||||
fi
|
||||
|
||||
trigger_mksnapshot:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # tag: v3
|
||||
- name: Trigger New mksnapshot Release
|
||||
run: |
|
||||
if [[ ${{ github.event.release.tag_name }} =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||
gh api /repos/:owner/mksnapshot/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 }}"
|
||||
fi
|
||||
2
.github/workflows/semantic.yml
vendored
2
.github/workflows/semantic.yml
vendored
@@ -1,7 +1,7 @@
|
||||
name: "Check Semantic Commit"
|
||||
|
||||
on:
|
||||
pull_request_target:
|
||||
pull_request:
|
||||
types:
|
||||
- opened
|
||||
- edited
|
||||
|
||||
18
.github/workflows/stale.yml
vendored
18
.github/workflows/stale.yml
vendored
@@ -5,15 +5,20 @@ on:
|
||||
# 1:30am every day
|
||||
- cron: '30 1 * * *'
|
||||
|
||||
permissions:
|
||||
issues: write
|
||||
permissions: {}
|
||||
|
||||
jobs:
|
||||
stale:
|
||||
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 }}
|
||||
- uses: actions/stale@5ebf00ea0e4c1561e9b43a292ed34424fb1d4578 # tag: v6.0.1
|
||||
with:
|
||||
repo-token: ${{ steps.generate-token.outputs.token }}
|
||||
days-before-stale: 90
|
||||
days-before-close: 30
|
||||
stale-issue-label: stale
|
||||
@@ -22,17 +27,24 @@ jobs:
|
||||
This issue has been automatically marked as stale. **If this issue is still affecting you, please leave any comment** (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the [latest version of Electron](https://www.electronjs.org/releases/stable) or in the [beta](https://www.electronjs.org/releases/beta)—please include it with your comment!
|
||||
close-issue-message: >
|
||||
This issue has been closed due to inactivity, and will not be monitored. If this is a bug and you can reproduce this issue on a [supported version of Electron](https://www.electronjs.org/docs/latest/tutorial/electron-timelines#timeline) please open a new issue and include instructions for reproducing the issue.
|
||||
exempt-issue-labels: "discussion,security \U0001F512,enhancement :sparkles:"
|
||||
exempt-issue-labels: "discussion,security \U0001F512,enhancement :sparkles:,status/confirmed"
|
||||
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
|
||||
|
||||
15
.github/workflows/update_appveyor_image.yml
vendored
15
.github/workflows/update_appveyor_image.yml
vendored
@@ -40,13 +40,21 @@ jobs:
|
||||
if: ${{ env.APPVEYOR_IMAGE_VERSION }}
|
||||
uses: mikefarah/yq@1c7dc0e88aad311c89889bc5ce5d8f96931a1bd0 # v4.27.2
|
||||
with:
|
||||
cmd: yq '.image = "${{ env.APPVEYOR_IMAGE_VERSION }}"' "appveyor.yml" > "appveyor2.yml"
|
||||
cmd: |
|
||||
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
|
||||
if: ${{ env.APPVEYOR_IMAGE_VERSION }}
|
||||
run: |
|
||||
diff -w -B appveyor.yml appveyor2.yml > appveyor.diff || true
|
||||
patch -f appveyor.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
|
||||
if: ${{ env.APPVEYOR_IMAGE_VERSION }}
|
||||
uses: peter-evans/create-pull-request@2b011faafdcbc9ceb11414d64d0573f37c774b04 # v4.2.3
|
||||
@@ -58,6 +66,9 @@ jobs:
|
||||
signoff: false
|
||||
branch: bump-appveyor-image
|
||||
delete-branch: true
|
||||
reviewers: electron/wg-releases
|
||||
title: 'build: update appveyor image to latest version'
|
||||
labels: semver/none,no-backport
|
||||
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
|
||||
|
||||
@@ -1,29 +1,3 @@
|
||||
{
|
||||
"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,
|
||||
"emphasis-style": false,
|
||||
"strong-style": false
|
||||
}
|
||||
{
|
||||
"extends": "@electron/lint-roller/configs/markdownlint.json"
|
||||
}
|
||||
|
||||
168
BUILD.gn
168
BUILD.gn
@@ -1,7 +1,7 @@
|
||||
import("//build/config/locales.gni")
|
||||
import("//build/config/ui.gni")
|
||||
import("//build/config/win/manifest.gni")
|
||||
import("//components/os_crypt/features.gni")
|
||||
import("//components/os_crypt/sync/features.gni")
|
||||
import("//components/spellcheck/spellcheck_build_features.gni")
|
||||
import("//content/public/app/mac_helpers.gni")
|
||||
import("//extensions/buildflags/buildflags.gni")
|
||||
@@ -9,6 +9,7 @@ import("//pdf/features.gni")
|
||||
import("//ppapi/buildflags/buildflags.gni")
|
||||
import("//printing/buildflags/buildflags.gni")
|
||||
import("//testing/test.gni")
|
||||
import("//third_party/electron_node/node.gni")
|
||||
import("//third_party/ffmpeg/ffmpeg_options.gni")
|
||||
import("//tools/generate_library_loader/generate_library_loader.gni")
|
||||
import("//tools/grit/grit_rule.gni")
|
||||
@@ -37,7 +38,7 @@ if (is_mac) {
|
||||
import("build/rules.gni")
|
||||
|
||||
assert(
|
||||
mac_deployment_target == "10.13",
|
||||
mac_deployment_target == "10.15",
|
||||
"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")
|
||||
}
|
||||
|
||||
@@ -99,10 +100,6 @@ if (is_linux) {
|
||||
}
|
||||
}
|
||||
|
||||
declare_args() {
|
||||
use_prebuilt_v8_context_snapshot = false
|
||||
}
|
||||
|
||||
branding = read_file("shell/app/BRANDING.json", "json")
|
||||
electron_project_name = branding.project_name
|
||||
electron_product_name = branding.product_name
|
||||
@@ -433,7 +430,7 @@ source_set("electron_lib") {
|
||||
"//components/network_hints/renderer",
|
||||
"//components/network_session_configurator/common",
|
||||
"//components/omnibox/browser:buildflags",
|
||||
"//components/os_crypt",
|
||||
"//components/os_crypt/sync",
|
||||
"//components/pref_registry",
|
||||
"//components/prefs",
|
||||
"//components/security_state/content",
|
||||
@@ -461,6 +458,7 @@ source_set("electron_lib") {
|
||||
"//services/proxy_resolver:lib",
|
||||
"//services/video_capture/public/mojom:constants",
|
||||
"//services/viz/privileged/mojom/compositing",
|
||||
"//services/viz/public/mojom",
|
||||
"//skia",
|
||||
"//third_party/blink/public:blink",
|
||||
"//third_party/blink/public:blink_devtools_inspector_resources",
|
||||
@@ -474,6 +472,7 @@ source_set("electron_lib") {
|
||||
"//third_party/widevine/cdm:headers",
|
||||
"//third_party/zlib/google:zip",
|
||||
"//ui/base/idle",
|
||||
"//ui/compositor",
|
||||
"//ui/events:dom_keycode_converter",
|
||||
"//ui/gl",
|
||||
"//ui/native_theme",
|
||||
@@ -555,6 +554,7 @@ source_set("electron_lib") {
|
||||
}
|
||||
|
||||
frameworks = [
|
||||
"AuthenticationServices.framework",
|
||||
"AVFoundation.framework",
|
||||
"Carbon.framework",
|
||||
"LocalAuthentication.framework",
|
||||
@@ -671,46 +671,6 @@ 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) {
|
||||
sources += [
|
||||
"shell/browser/api/views/electron_api_image_view.cc",
|
||||
@@ -770,8 +730,10 @@ source_set("electron_lib") {
|
||||
"//pdf",
|
||||
]
|
||||
sources += [
|
||||
"shell/browser/electron_pdf_web_contents_helper_client.cc",
|
||||
"shell/browser/electron_pdf_web_contents_helper_client.h",
|
||||
"shell/browser/electron_pdf_document_helper_client.cc",
|
||||
"shell/browser/electron_pdf_document_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",
|
||||
]
|
||||
}
|
||||
|
||||
@@ -801,15 +763,6 @@ if (is_mac) {
|
||||
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") {
|
||||
public_deps = [ ":packed_resources" ]
|
||||
sources = []
|
||||
@@ -820,13 +773,8 @@ if (is_mac) {
|
||||
if (v8_use_external_startup_data) {
|
||||
public_deps += [ "//v8" ]
|
||||
if (use_v8_context_snapshot) {
|
||||
if (use_prebuilt_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" ]
|
||||
}
|
||||
sources += [ "$root_out_dir/$v8_context_snapshot_filename" ]
|
||||
public_deps += [ "//tools/v8_context_snapshot" ]
|
||||
} else {
|
||||
sources += [ "$root_out_dir/snapshot_blob.bin" ]
|
||||
}
|
||||
@@ -926,11 +874,7 @@ if (is_mac) {
|
||||
|
||||
include_dirs = [ "." ]
|
||||
sources = filenames.framework_sources
|
||||
frameworks = []
|
||||
|
||||
if (enable_osr) {
|
||||
frameworks += [ "IOSurface.framework" ]
|
||||
}
|
||||
frameworks = [ "IOSurface.framework" ]
|
||||
|
||||
ldflags = [
|
||||
"-Wl,-install_name,@rpath/$output_name.framework/$output_name",
|
||||
@@ -962,13 +906,13 @@ if (is_mac) {
|
||||
output_name = electron_helper_name + invoker.helper_name_suffix
|
||||
deps = [
|
||||
":electron_framework+link",
|
||||
"//base/allocator:early_zone_registration_mac",
|
||||
"//base/allocator:early_zone_registration_apple",
|
||||
]
|
||||
if (!is_mas_build) {
|
||||
deps += [ "//sandbox/mac:seatbelt" ]
|
||||
}
|
||||
defines = [ "HELPER_EXECUTABLE" ]
|
||||
extra_configs = [ "//electron/build/config:mas_build" ]
|
||||
configs += [ "//electron/build/config:mas_build" ]
|
||||
sources = [
|
||||
"shell/app/electron_main_mac.cc",
|
||||
"shell/app/uv_stdio_fix.cc",
|
||||
@@ -1124,7 +1068,7 @@ if (is_mac) {
|
||||
":electron_app_plist",
|
||||
":electron_app_resources",
|
||||
":electron_fuses",
|
||||
"//base/allocator:early_zone_registration_mac",
|
||||
"//base/allocator:early_zone_registration_apple",
|
||||
"//electron/buildflags",
|
||||
]
|
||||
if (is_mas_build) {
|
||||
@@ -1139,7 +1083,7 @@ if (is_mac) {
|
||||
"-rpath",
|
||||
"@executable_path/../Frameworks",
|
||||
]
|
||||
extra_configs = [ "//electron/build/config:mas_build" ]
|
||||
configs += [ "//electron/build/config:mas_build" ]
|
||||
}
|
||||
|
||||
if (enable_dsyms) {
|
||||
@@ -1277,7 +1221,7 @@ if (is_mac) {
|
||||
]
|
||||
|
||||
deps += [
|
||||
"//components/browser_watcher:browser_watcher_client",
|
||||
"//chrome/app:exit_code_watcher",
|
||||
"//components/crash/core/app:run_as_crashpad_handler",
|
||||
]
|
||||
|
||||
@@ -1533,8 +1477,9 @@ dist_zip("libcxx_headers_zip") {
|
||||
data_deps = [ ":libcxx_headers" ]
|
||||
deps = data_deps
|
||||
flatten = true
|
||||
flatten_relative_to = rebase_path(
|
||||
"$target_gen_dir/electron_libcxx_include/buildtools/third_party/libc++/trunk",
|
||||
flatten_relative_to =
|
||||
rebase_path(
|
||||
"$target_gen_dir/electron_libcxx_include/third_party/libc++/src",
|
||||
"$root_out_dir")
|
||||
|
||||
outputs = [ "$root_build_dir/libcxx_headers.zip" ]
|
||||
@@ -1550,7 +1495,7 @@ dist_zip("libcxxabi_headers_zip") {
|
||||
deps = data_deps
|
||||
flatten = true
|
||||
flatten_relative_to = rebase_path(
|
||||
"$target_gen_dir/electron_libcxxabi_include/buildtools/third_party/libc++abi/trunk",
|
||||
"$target_gen_dir/electron_libcxxabi_include/third_party/libc++abi/src",
|
||||
"$root_out_dir")
|
||||
|
||||
outputs = [ "$root_build_dir/libcxxabi_headers.zip" ]
|
||||
@@ -1566,3 +1511,70 @@ action("libcxx_objects_zip") {
|
||||
group("electron") {
|
||||
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" ]
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ _If an issue has been closed and you still feel it's relevant, feel free to ping
|
||||
|
||||
### 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.
|
||||
Anyone may post the translated reply.
|
||||
In most cases, a quick pass through translation software is sufficient.
|
||||
@@ -60,6 +60,10 @@ dependencies, and tools contained in the `electron/electron` repository.
|
||||
* [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)
|
||||
|
||||
### 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
|
||||
|
||||
See [Coding Style](https://electronjs.org/docs/development/coding-style) for information about which standards Electron adheres to in different parts of its codebase.
|
||||
|
||||
20
DEPS
20
DEPS
@@ -2,13 +2,17 @@ gclient_gn_args_from = 'src'
|
||||
|
||||
vars = {
|
||||
'chromium_version':
|
||||
'111.0.5560.0',
|
||||
'119.0.6019.2',
|
||||
'node_version':
|
||||
'v18.14.0',
|
||||
'v18.18.0',
|
||||
'nan_version':
|
||||
'16fa32231e2ccd89d2804b3f765319128b20c4ac',
|
||||
'e14bdcd1f72d62bca1d541b66da43130384ec213',
|
||||
'squirrel.mac_version':
|
||||
'0e5d146ba13101a1302d59ea6e6e0b3cace4ae38',
|
||||
'reactiveobjc_version':
|
||||
'74ab5baccc6f7202c8ac69a8d1e152c29dc1ea76',
|
||||
'mantle_version':
|
||||
'78d3966b3c331292ea29ec38661b25df0a245948',
|
||||
|
||||
'pyyaml_version': '3.12',
|
||||
|
||||
@@ -17,6 +21,11 @@ vars = {
|
||||
'nodejs_git': 'https://github.com/nodejs',
|
||||
'yaml_git': 'https://github.com/yaml',
|
||||
'squirrel_git': 'https://github.com/Squirrel',
|
||||
'reactiveobjc_git': 'https://github.com/ReactiveCocoa',
|
||||
'mantle_git': 'https://github.com/Mantle',
|
||||
|
||||
# The path of the sysroots.json file.
|
||||
'sysroots_json_path': 'electron/script/sysroots.json',
|
||||
|
||||
# KEEP IN SYNC WITH utils.js FILE
|
||||
'yarn_version': '1.15.2',
|
||||
@@ -87,11 +96,11 @@ deps = {
|
||||
'condition': 'process_deps',
|
||||
},
|
||||
'src/third_party/squirrel.mac/vendor/ReactiveObjC': {
|
||||
'url': 'https://github.com/ReactiveCocoa/ReactiveObjC.git@74ab5baccc6f7202c8ac69a8d1e152c29dc1ea76',
|
||||
'url': Var("reactiveobjc_git") + '/ReactiveObjC.git@' + Var("reactiveobjc_version"),
|
||||
'condition': 'process_deps'
|
||||
},
|
||||
'src/third_party/squirrel.mac/vendor/Mantle': {
|
||||
'url': 'https://github.com/Mantle/Mantle.git@78d3966b3c331292ea29ec38661b25df0a245948',
|
||||
'url': Var("mantle_git") + '/Mantle.git@' + Var("mantle_version"),
|
||||
'condition': 'process_deps',
|
||||
}
|
||||
}
|
||||
@@ -149,5 +158,4 @@ hooks = [
|
||||
|
||||
recursedeps = [
|
||||
'src',
|
||||
'src/third_party/squirrel.mac',
|
||||
]
|
||||
|
||||
@@ -38,7 +38,7 @@ For more installation options and troubleshooting tips, see
|
||||
|
||||
Each Electron release provides binaries for macOS, Windows, and Linux.
|
||||
|
||||
* macOS (High Sierra and up): Electron provides 64-bit Intel and ARM binaries for macOS. Apple Silicon support was added in Electron 11.
|
||||
* macOS (Catalina 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).
|
||||
* Linux: The prebuilt binaries of Electron are built on Ubuntu 20.04. They have also been verified to work on:
|
||||
* Ubuntu 14.04 and newer
|
||||
@@ -78,7 +78,7 @@ binary. Use this to spawn Electron from Node scripts:
|
||||
|
||||
```javascript
|
||||
const electron = require('electron')
|
||||
const proc = require('child_process')
|
||||
const proc = require('node:child_process')
|
||||
|
||||
// will print something similar to /Users/maf/.../Electron
|
||||
console.log(electron)
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
version: 1.0.{build}
|
||||
build_cloud: electronhq-16-core
|
||||
image: e-110.0.5451.0
|
||||
image: e-112.0.5607.0-vs2022
|
||||
environment:
|
||||
GIT_CACHE_PATH: C:\Users\appveyor\libcc_cache
|
||||
ELECTRON_OUT_DIR: Default
|
||||
@@ -16,22 +16,58 @@ environment:
|
||||
GOMA_FALLBACK_ON_AUTH_FAILURE: true
|
||||
DEPOT_TOOLS_WIN_TOOLCHAIN: 0
|
||||
PYTHONIOENCODING: UTF-8
|
||||
# Uncomment these lines and set APPVEYOR_RDP_PASSWORD in project settings to enable RDP before bake begins
|
||||
# install:
|
||||
# - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
|
||||
|
||||
# The following lines are needed when baking from a completely new image (eg MicrosoftWindowsServer:WindowsServer:2019-Datacenter:latest via image: base-windows-server2019)
|
||||
# init:
|
||||
# - 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:
|
||||
# Uncomment/change the following line if the hard drive/partition size needs to change
|
||||
# - ps: Resize-Partition -DriveLetter C -Size (256GB) # ensure initial partition size
|
||||
# The following lines are needed when baking from a completely new image (eg MicrosoftWindowsServer:WindowsServer:2019-Datacenter:latest via image: base-windows-server2019)
|
||||
# - ps: .\init_server.ps1
|
||||
# - 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
|
||||
- cd ..
|
||||
- ps: >-
|
||||
if (-not (Test-Path -Path .\src)) {
|
||||
New-Item -Path .\src -ItemType Directory
|
||||
if (-not (Test-Path -Path C:\projects\src)) {
|
||||
New-Item -Path C:\projects\src -ItemType Directory
|
||||
}
|
||||
- ps: git clone --depth=1 https://chromium.googlesource.com/chromium/tools/depot_tools.git
|
||||
- cd C:\projects\
|
||||
- git clone -q --branch=%APPVEYOR_REPO_BRANCH% https://github.com/electron/electron.git C:\projects\src\electron
|
||||
- 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
|
||||
- ps: Move-Item $env:APPVEYOR_BUILD_FOLDER -Destination src\electron
|
||||
# Uncomment the following line if windows deps change
|
||||
# - src\electron\script\setup-win-for-dev.bat
|
||||
- >-
|
||||
@@ -46,21 +82,27 @@ build_script:
|
||||
- ps: Copy-Item -path .\.depshash -destination ..\.depshash
|
||||
- ps: cd ..\..
|
||||
- gclient sync --with_branch_heads --with_tags --nohooks
|
||||
- ps: regsvr32 /s "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\DIA SDK\bin\amd64\msdia140.dll"
|
||||
- ps: |
|
||||
$env:appveyor_user = "appveyor"
|
||||
- ps: regsvr32 /s "C:\Program Files\Microsoft Visual Studio\2022\Community\DIA SDK\bin\amd64\msdia140.dll"
|
||||
- ps: set vs2022_install="C:\Program Files\Microsoft Visual Studio\2022\Community"
|
||||
|
||||
$env:appveyor_password = [Guid]::NewGuid().ToString('B')
|
||||
# The following lines are needed when baking from a completely new image (eg MicrosoftWindowsServer:WindowsServer:2019-Datacenter:latest via image: base-windows-server2019)
|
||||
# # Restart VM
|
||||
# - ps: Start-Sleep -s 5; Restart-Computer
|
||||
# - ps: Start-Sleep -s 5
|
||||
|
||||
Set-LocalUser -Name $env:appveyor_user -Password (ConvertTo-SecureString -AsPlainText $env:appveyor_password -Force) -PasswordNeverExpires:$true
|
||||
|
||||
iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/build-images/master/scripts/Windows/enable_autologon.ps1'))
|
||||
# - cd %USERPROFILE%\image-bake-scripts
|
||||
# - appveyor version
|
||||
# - ps: .\optimize_dotnet_runtime.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:
|
||||
- ps: >-
|
||||
echo "Baking image: $env:APPVEYOR_BAKE_IMAGE at dir $PWD"
|
||||
- ps: Remove-Item -Recurse -Force $pwd\depot_tools
|
||||
- ps: Remove-Item -Recurse -Force $pwd\src\electron
|
||||
- ps: Remove-Item -Recurse -Force C:\projects\depot_tools
|
||||
- ps: Remove-Item -Recurse -Force C:\projects\src\electron
|
||||
# Uncomment these lines and set APPVEYOR_RDP_PASSWORD in project settings to enable RDP after bake is done
|
||||
#on_finish:
|
||||
# - ps: >-
|
||||
# $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
|
||||
# # on_finish:
|
||||
# - ps: >-
|
||||
# $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
|
||||
@@ -6,7 +6,7 @@
|
||||
# - "GN_CONFIG" Build type. One of {'testing', 'release'}.
|
||||
# - "GN_EXTRA_ARGS" Additional gn arguments for a build config,
|
||||
# e.g. 'target_cpu="x86"' to build for a 32bit platform.
|
||||
# https://gn.googlesource.com/gn/+/master/docs/reference.md#target_cpu
|
||||
# https://gn.googlesource.com/gn/+/main/docs/reference.md#var_target_cpu
|
||||
# Don't forget to set up "NPM_CONFIG_ARCH" and "TARGET_ARCH" accordingly
|
||||
# if you pass a custom value for 'target_cpu'.
|
||||
# - "ELECTRON_RELEASE" Set it to '1' upload binaries on success.
|
||||
@@ -29,16 +29,18 @@
|
||||
|
||||
version: 1.0.{build}
|
||||
build_cloud: electronhq-16-core
|
||||
image: e-111.0.5518.0
|
||||
image: e-119.0.6019.2
|
||||
environment:
|
||||
GIT_CACHE_PATH: C:\Users\appveyor\libcc_cache
|
||||
ELECTRON_OUT_DIR: Default
|
||||
ELECTRON_ENABLE_STACK_DUMPING: 1
|
||||
ELECTRON_ALSO_LOG_TO_STDERR: 1
|
||||
MOCHA_REPORTER: mocha-multi-reporters
|
||||
MOCHA_MULTI_REPORTERS: mocha-appveyor-reporter, tap
|
||||
MOCHA_MULTI_REPORTERS: "@marshallofsound/mocha-appveyor-reporter, tap"
|
||||
GOMA_FALLBACK_ON_AUTH_FAILURE: true
|
||||
DEPOT_TOOLS_WIN_TOOLCHAIN: 0
|
||||
DEPOT_TOOLS_WIN_TOOLCHAIN: 1
|
||||
DEPOT_TOOLS_WIN_TOOLCHAIN_BASE_URL: "https://dev-cdn.electronjs.org/windows-toolchains/_"
|
||||
GYP_MSVS_HASH_27370823e7: 28622d16b1
|
||||
PYTHONIOENCODING: UTF-8
|
||||
|
||||
matrix:
|
||||
@@ -49,6 +51,11 @@ environment:
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: base-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
|
||||
|
||||
skip_branch_with_pr: true
|
||||
@@ -66,11 +73,15 @@ for:
|
||||
build_script:
|
||||
- ps: |
|
||||
node script/yarn.js install --frozen-lockfile
|
||||
node script/doc-only-change.js --prNumber=$env:APPVEYOR_PULL_REQUEST_NUMBER --prBranch=$env:APPVEYOR_REPO_BRANCH
|
||||
node script/doc-only-change.js --prNumber=$env:APPVEYOR_PULL_REQUEST_NUMBER
|
||||
$env:SHOULD_SKIP_ARTIFACT_VALIDATION = "false"
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
Write-warning "Skipping build for doc only change"; Exit-AppveyorBuild
|
||||
Write-warning "Skipping build for doc-only change"
|
||||
$env:SHOULD_SKIP_ARTIFACT_VALIDATION = "true"
|
||||
Exit-AppveyorBuild
|
||||
} else {
|
||||
$global:LASTEXITCODE = 0
|
||||
}
|
||||
$global:LASTEXITCODE = 0
|
||||
- cd ..
|
||||
- ps: Write-Host "Building $env:GN_CONFIG build"
|
||||
- git config --global core.longpaths true
|
||||
@@ -82,7 +93,9 @@ for:
|
||||
if (Test-Path -Path "$pwd\build-tools") {
|
||||
Remove-Item -Recurse -Force $pwd\build-tools
|
||||
}
|
||||
- ps: git clone --depth=1 https://chromium.googlesource.com/chromium/tools/depot_tools.git
|
||||
- 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: >-
|
||||
if (Test-Path -Path "$pwd\src\electron") {
|
||||
@@ -105,7 +118,7 @@ for:
|
||||
- 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
|
||||
$goma_login = python3 $env:LOCAL_GOMA_DIR\goma_auth.py info
|
||||
if ($goma_login -eq 'Login as Fermi Planck') {
|
||||
Write-warning "Goma authentication is correct";
|
||||
} else {
|
||||
@@ -154,8 +167,8 @@ for:
|
||||
- cd ..\..
|
||||
- ninja -C out/Default electron:hunspell_dictionaries_zip
|
||||
- ninja -C out/Default electron:electron_chromedriver_zip
|
||||
- ninja -C out/Default third_party/electron_node:headers
|
||||
- python %LOCAL_GOMA_DIR%\goma_ctl.py stat
|
||||
- ninja -C out/Default electron:node_headers
|
||||
- python3 %LOCAL_GOMA_DIR%\goma_ctl.py stat
|
||||
- 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
|
||||
- python3 electron/build/profile_toolchain.py --output-json=out/Default/windows_toolchain_profile.json
|
||||
@@ -176,6 +189,31 @@ for:
|
||||
7z a pdb.zip out\Default\*.pdb
|
||||
}
|
||||
- python3 electron/script/zip_manifests/check-zip-manifest.py out/Default/dist.zip electron/script/zip_manifests/dist_zip.win.%TARGET_ARCH%.manifest
|
||||
- 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','shell_browser_ui_unittests.exe','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:
|
||||
- cd electron
|
||||
@@ -201,7 +239,7 @@ for:
|
||||
- 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\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: >-
|
||||
if ((Test-Path "pdb.zip") -And ($env:GN_CONFIG -ne 'release')) {
|
||||
appveyor-retry appveyor PushArtifact pdb.zip
|
||||
@@ -220,11 +258,13 @@ for:
|
||||
build_script:
|
||||
- ps: |
|
||||
node script/yarn.js install --frozen-lockfile
|
||||
node script/doc-only-change.js --prNumber=$env:APPVEYOR_PULL_REQUEST_NUMBER --prBranch=$env:APPVEYOR_REPO_BRANCH
|
||||
node script/doc-only-change.js --prNumber=$env:APPVEYOR_PULL_REQUEST_NUMBER
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
Write-warning "Skipping build for doc only change"; Exit-AppveyorBuild
|
||||
Write-warning "Skipping build for doc only change"
|
||||
Exit-AppveyorBuild
|
||||
} else {
|
||||
$global:LASTEXITCODE = 0
|
||||
}
|
||||
$global:LASTEXITCODE = 0
|
||||
- cd ..
|
||||
- mkdir out\Default
|
||||
- cd ..
|
||||
@@ -232,7 +272,7 @@ for:
|
||||
# Download build artifacts
|
||||
$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"
|
||||
$artifacts_to_download = @('dist.zip','ffmpeg.zip','node_headers.zip','pdb.zip','electron.lib')
|
||||
$artifacts_to_download = @('dist.zip','ffmpeg.zip','node_headers.zip','electron.lib')
|
||||
foreach ($job in $build_info.build.jobs) {
|
||||
if ($job.name -eq "Build Arm on X64 Windows") {
|
||||
$jobId = $job.jobId
|
||||
@@ -244,10 +284,13 @@ for:
|
||||
}
|
||||
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: |
|
||||
$out_default_zips = @('dist.zip','pdb.zip')
|
||||
$out_default_zips = @('dist.zip')
|
||||
foreach($zip_name in $out_default_zips) {
|
||||
7z x -y -osrc\out\Default $zip_name
|
||||
}
|
||||
@@ -276,4 +319,4 @@ for:
|
||||
on_finish:
|
||||
# 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'))
|
||||
- if exist electron\electron.log ( appveyor-retry appveyor PushArtifact electron\electron.log )
|
||||
- if exist electron\electron.log ( appveyor-retry appveyor PushArtifact electron\electron.log )
|
||||
|
||||
75
appveyor.yml
75
appveyor.yml
@@ -6,7 +6,7 @@
|
||||
# - "GN_CONFIG" Build type. One of {'testing', 'release'}.
|
||||
# - "GN_EXTRA_ARGS" Additional gn arguments for a build config,
|
||||
# e.g. 'target_cpu="x86"' to build for a 32bit platform.
|
||||
# https://gn.googlesource.com/gn/+/master/docs/reference.md#target_cpu
|
||||
# https://gn.googlesource.com/gn/+/main/docs/reference.md#var_target_cpu
|
||||
# Don't forget to set up "NPM_CONFIG_ARCH" and "TARGET_ARCH" accordingly
|
||||
# if you pass a custom value for 'target_cpu'.
|
||||
# - "ELECTRON_RELEASE" Set it to '1' upload binaries on success.
|
||||
@@ -29,16 +29,18 @@
|
||||
|
||||
version: 1.0.{build}
|
||||
build_cloud: electronhq-16-core
|
||||
image: e-111.0.5560.0
|
||||
image: e-119.0.6019.2
|
||||
environment:
|
||||
GIT_CACHE_PATH: C:\Users\appveyor\libcc_cache
|
||||
ELECTRON_OUT_DIR: Default
|
||||
ELECTRON_ENABLE_STACK_DUMPING: 1
|
||||
ELECTRON_ALSO_LOG_TO_STDERR: 1
|
||||
MOCHA_REPORTER: mocha-multi-reporters
|
||||
MOCHA_MULTI_REPORTERS: mocha-appveyor-reporter, tap
|
||||
MOCHA_MULTI_REPORTERS: "@marshallofsound/mocha-appveyor-reporter, tap"
|
||||
GOMA_FALLBACK_ON_AUTH_FAILURE: true
|
||||
DEPOT_TOOLS_WIN_TOOLCHAIN: 0
|
||||
DEPOT_TOOLS_WIN_TOOLCHAIN: 1
|
||||
DEPOT_TOOLS_WIN_TOOLCHAIN_BASE_URL: "https://dev-cdn.electronjs.org/windows-toolchains/_"
|
||||
GYP_MSVS_HASH_27370823e7: 28622d16b1
|
||||
PYTHONIOENCODING: UTF-8
|
||||
|
||||
matrix:
|
||||
@@ -47,6 +49,11 @@ environment:
|
||||
- job_name: Test
|
||||
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
|
||||
|
||||
skip_branch_with_pr: true
|
||||
@@ -64,11 +71,15 @@ for:
|
||||
build_script:
|
||||
- ps: |
|
||||
node script/yarn.js install --frozen-lockfile
|
||||
node script/doc-only-change.js --prNumber=$env:APPVEYOR_PULL_REQUEST_NUMBER --prBranch=$env:APPVEYOR_REPO_BRANCH
|
||||
node script/doc-only-change.js --prNumber=$env:APPVEYOR_PULL_REQUEST_NUMBER
|
||||
$env:SHOULD_SKIP_ARTIFACT_VALIDATION = "false"
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
Write-warning "Skipping build for doc only change"; Exit-AppveyorBuild
|
||||
Write-warning "Skipping build for doc-only change"
|
||||
$env:SHOULD_SKIP_ARTIFACT_VALIDATION = "true"
|
||||
Exit-AppveyorBuild
|
||||
} else {
|
||||
$global:LASTEXITCODE = 0
|
||||
}
|
||||
$global:LASTEXITCODE = 0
|
||||
- cd ..
|
||||
- ps: Write-Host "Building $env:GN_CONFIG build"
|
||||
- git config --global core.longpaths true
|
||||
@@ -80,7 +91,9 @@ for:
|
||||
if (Test-Path -Path "$pwd\build-tools") {
|
||||
Remove-Item -Recurse -Force $pwd\build-tools
|
||||
}
|
||||
- ps: git clone --depth=1 https://chromium.googlesource.com/chromium/tools/depot_tools.git
|
||||
- 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: >-
|
||||
if (Test-Path -Path "$pwd\src\electron") {
|
||||
@@ -103,7 +116,7 @@ for:
|
||||
- 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
|
||||
$goma_login = python3 $env:LOCAL_GOMA_DIR\goma_auth.py info
|
||||
if ($goma_login -eq 'Login as Fermi Planck') {
|
||||
Write-warning "Goma authentication is correct";
|
||||
} else {
|
||||
@@ -152,8 +165,8 @@ for:
|
||||
- cd ..\..
|
||||
- ninja -C out/Default electron:hunspell_dictionaries_zip
|
||||
- ninja -C out/Default electron:electron_chromedriver_zip
|
||||
- ninja -C out/Default third_party/electron_node:headers
|
||||
- python %LOCAL_GOMA_DIR%\goma_ctl.py stat
|
||||
- ninja -C out/Default electron:node_headers
|
||||
- python3 %LOCAL_GOMA_DIR%\goma_ctl.py stat
|
||||
- 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
|
||||
- python3 electron/build/profile_toolchain.py --output-json=out/Default/windows_toolchain_profile.json
|
||||
@@ -174,6 +187,31 @@ for:
|
||||
7z a pdb.zip out\Default\*.pdb
|
||||
}
|
||||
- python3 electron/script/zip_manifests/check-zip-manifest.py out/Default/dist.zip electron/script/zip_manifests/dist_zip.win.%TARGET_ARCH%.manifest
|
||||
- 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','shell_browser_ui_unittests.exe','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:
|
||||
- cd electron
|
||||
@@ -199,7 +237,7 @@ for:
|
||||
- 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\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: >-
|
||||
if ((Test-Path "pdb.zip") -And ($env:GN_CONFIG -ne 'release')) {
|
||||
appveyor-retry appveyor PushArtifact pdb.zip
|
||||
@@ -216,11 +254,13 @@ for:
|
||||
build_script:
|
||||
- ps: |
|
||||
node script/yarn.js install --frozen-lockfile
|
||||
node script/doc-only-change.js --prNumber=$env:APPVEYOR_PULL_REQUEST_NUMBER --prBranch=$env:APPVEYOR_REPO_BRANCH
|
||||
node script/doc-only-change.js --prNumber=$env:APPVEYOR_PULL_REQUEST_NUMBER
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
Write-warning "Skipping build for doc only change"; Exit-AppveyorBuild
|
||||
Write-warning "Skipping build for doc only change"
|
||||
Exit-AppveyorBuild
|
||||
} else {
|
||||
$global:LASTEXITCODE = 0
|
||||
}
|
||||
$global:LASTEXITCODE = 0
|
||||
- cd ..
|
||||
- mkdir out\Default
|
||||
- cd ..
|
||||
@@ -240,6 +280,9 @@ for:
|
||||
}
|
||||
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: |
|
||||
@@ -276,4 +319,4 @@ for:
|
||||
on_finish:
|
||||
# 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'))
|
||||
- if exist electron\electron.log ( appveyor-retry appveyor PushArtifact electron\electron.log )
|
||||
- if exist electron\electron.log ( appveyor-retry appveyor PushArtifact electron\electron.log )
|
||||
|
||||
8
build/.eslintrc.json
Normal file
8
build/.eslintrc.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"plugins": [
|
||||
"unicorn"
|
||||
],
|
||||
"rules": {
|
||||
"unicorn/prefer-node-protocol": "error"
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
is_electron_build = true
|
||||
root_extra_deps = [ "//electron" ]
|
||||
|
||||
# Registry of NMVs --> https://github.com/nodejs/node/blob/master/doc/abi_version_registry.json
|
||||
node_module_version = 114
|
||||
# Registry of NMVs --> https://github.com/nodejs/node/blob/main/doc/abi_version_registry.json
|
||||
node_module_version = 118
|
||||
|
||||
v8_promise_internal_field_count = 1
|
||||
v8_embedder_string = "-electron.0"
|
||||
@@ -45,3 +45,18 @@ is_cfi = false
|
||||
|
||||
# TODO: fix this once sysroots have been updated.
|
||||
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
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
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])
|
||||
@@ -4,7 +4,7 @@ import sys
|
||||
|
||||
DEFINE_EXTRACT_REGEX = re.compile('^ *# *define (\w*)', re.MULTILINE)
|
||||
|
||||
def main(outDir, headers):
|
||||
def main(out_dir, headers):
|
||||
defines = []
|
||||
for filename in headers:
|
||||
with open(filename, 'r') as f:
|
||||
@@ -15,13 +15,13 @@ def main(outDir, headers):
|
||||
for define in defines:
|
||||
push_and_undef += '#pragma push_macro("%s")\n' % define
|
||||
push_and_undef += '#undef %s\n' % define
|
||||
with open(os.path.join(outDir, 'push_and_undef_node_defines.h'), 'w') as o:
|
||||
with open(os.path.join(out_dir, 'push_and_undef_node_defines.h'), 'w') as o:
|
||||
o.write(push_and_undef)
|
||||
|
||||
pop = ''
|
||||
for define in defines:
|
||||
pop += '#pragma pop_macro("%s")\n' % define
|
||||
with open(os.path.join(outDir, 'pop_node_defines.h'), 'w') as o:
|
||||
with open(os.path.join(out_dir, 'pop_node_defines.h'), 'w') as o:
|
||||
o.write(pop)
|
||||
|
||||
def read_defines(content):
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
const webpack = require('webpack');
|
||||
const TerserPlugin = require('terser-webpack-plugin');
|
||||
const WrapperPlugin = require('wrapper-webpack-plugin');
|
||||
@@ -53,14 +53,6 @@ module.exports = ({
|
||||
|
||||
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') {
|
||||
ignoredModules.push(
|
||||
'@electron/internal/browser/api/views/image-view.js'
|
||||
|
||||
10
build/zip.py
10
build/zip.py
@@ -10,7 +10,13 @@ EXTENSIONS_TO_SKIP = [
|
||||
'.mojom.js',
|
||||
'.mojom-lite.js',
|
||||
'.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 = [
|
||||
@@ -34,7 +40,7 @@ PATHS_TO_SKIP = [
|
||||
# Skip because these are outputs that we don't need.
|
||||
'resources/inspector',
|
||||
'gen/third_party/devtools-frontend/src',
|
||||
'gen/ui/webui'
|
||||
'gen/ui/webui',
|
||||
]
|
||||
|
||||
def skip_path(dep, dist_zip, target_cpu):
|
||||
|
||||
@@ -44,4 +44,4 @@ def main(argv):
|
||||
z.write(object_file, os.path.relpath(object_file, base_path_libcxxabi))
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main(sys.argv[1:]))
|
||||
sys.exit(main(sys.argv[1:]))
|
||||
|
||||
@@ -9,16 +9,10 @@ buildflag_header("buildflags") {
|
||||
header = "buildflags.h"
|
||||
|
||||
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_PDF_VIEWER=$enable_pdf_viewer",
|
||||
"ENABLE_TTS=$enable_tts",
|
||||
"ENABLE_COLOR_CHOOSER=$enable_color_chooser",
|
||||
"ENABLE_ELECTRON_EXTENSIONS=$enable_electron_extensions",
|
||||
"ENABLE_BUILTIN_SPELLCHECKER=$enable_builtin_spellchecker",
|
||||
"ENABLE_PICTURE_IN_PICTURE=$enable_picture_in_picture",
|
||||
"OVERRIDE_LOCATION_PROVIDER=$enable_fake_location_provider",
|
||||
]
|
||||
}
|
||||
|
||||
@@ -3,23 +3,10 @@
|
||||
# found in the LICENSE file.
|
||||
|
||||
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_pdf_viewer = true
|
||||
|
||||
enable_tts = true
|
||||
|
||||
enable_color_chooser = true
|
||||
|
||||
enable_picture_in_picture = true
|
||||
|
||||
# Provide a fake location provider for mocking
|
||||
# the geolocation responses. Disable it if you
|
||||
# need to test with chromium's location provider.
|
||||
|
||||
@@ -37,12 +37,28 @@ static_library("chrome") {
|
||||
"//chrome/browser/icon_loader.h",
|
||||
"//chrome/browser/icon_manager.cc",
|
||||
"//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.h",
|
||||
"//chrome/browser/net/proxy_config_monitor.cc",
|
||||
"//chrome/browser/net/proxy_config_monitor.h",
|
||||
"//chrome/browser/net/proxy_service_factory.cc",
|
||||
"//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_window_manager.cc",
|
||||
"//chrome/browser/picture_in_picture/picture_in_picture_window_manager.h",
|
||||
"//chrome/browser/platform_util.cc",
|
||||
"//chrome/browser/platform_util.h",
|
||||
"//chrome/browser/predictors/preconnect_manager.cc",
|
||||
@@ -86,6 +102,28 @@ static_library("chrome") {
|
||||
"//chrome/browser/ui/views/eye_dropper/eye_dropper.h",
|
||||
"//chrome/browser/ui/views/eye_dropper/eye_dropper_view.cc",
|
||||
"//chrome/browser/ui/views/eye_dropper/eye_dropper_view.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",
|
||||
"//extensions/browser/app_window/size_constraints.cc",
|
||||
"//extensions/browser/app_window/size_constraints.h",
|
||||
"//ui/views/native_window_tracker.h",
|
||||
@@ -95,23 +133,6 @@ static_library("chrome") {
|
||||
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) {
|
||||
sources += [
|
||||
"//chrome/browser/extensions/global_shortcut_listener_win.cc",
|
||||
@@ -146,6 +167,7 @@ static_library("chrome") {
|
||||
|
||||
public_deps = [
|
||||
"//chrome/browser:dev_ui_browser_resources",
|
||||
"//chrome/browser/resources/accessibility:resources",
|
||||
"//chrome/browser/ui/color:mixers",
|
||||
"//chrome/common",
|
||||
"//chrome/common:version_header",
|
||||
@@ -157,7 +179,15 @@ static_library("chrome") {
|
||||
"//services/strings",
|
||||
]
|
||||
|
||||
deps = [ "//chrome/browser:resource_prefetch_predictor_proto" ]
|
||||
deps = [
|
||||
"//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 (is_linux) {
|
||||
sources += [ "//chrome/browser/icon_loader_auralinux.cc" ]
|
||||
@@ -188,18 +218,21 @@ static_library("chrome") {
|
||||
public_deps += [ "//chrome/services/util_win:lib" ]
|
||||
}
|
||||
|
||||
if (enable_desktop_capturer) {
|
||||
if (is_mac) {
|
||||
sources += [
|
||||
"//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/window_icon_util.h",
|
||||
"//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",
|
||||
]
|
||||
deps += [ "//ui/snapshot" ]
|
||||
}
|
||||
|
||||
if (enable_widevine) {
|
||||
@@ -273,41 +306,6 @@ 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) {
|
||||
sources += [
|
||||
"//chrome/browser/extensions/chrome_url_request_util.cc",
|
||||
|
||||
8
default_app/.eslintrc.json
Normal file
8
default_app/.eslintrc.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"plugins": [
|
||||
"unicorn"
|
||||
],
|
||||
"rules": {
|
||||
"unicorn/prefer-node-protocol": "error"
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import { shell } from 'electron/common';
|
||||
import { app, dialog, BrowserWindow, ipcMain } from 'electron/main';
|
||||
import * as path from 'path';
|
||||
import * as url from 'url';
|
||||
import * as path from 'node:path';
|
||||
import * as url from 'node:url';
|
||||
|
||||
let mainWindow: BrowserWindow | null = null;
|
||||
|
||||
@@ -51,16 +51,17 @@ async function createWindow (backgroundColor?: string) {
|
||||
autoHideMenuBar: true,
|
||||
backgroundColor,
|
||||
webPreferences: {
|
||||
preload: path.resolve(__dirname, 'preload.js'),
|
||||
preload: url.fileURLToPath(new URL('preload.js', import.meta.url)),
|
||||
contextIsolation: true,
|
||||
sandbox: true
|
||||
sandbox: true,
|
||||
nodeIntegration: false
|
||||
},
|
||||
useContentSize: true,
|
||||
show: false
|
||||
};
|
||||
|
||||
if (process.platform === 'linux') {
|
||||
options.icon = path.join(__dirname, 'icon.png');
|
||||
options.icon = url.fileURLToPath(new URL('icon.png', import.meta.url));
|
||||
}
|
||||
|
||||
mainWindow = new BrowserWindow(options);
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import * as electron from 'electron/main';
|
||||
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import * as url from 'url';
|
||||
import * as fs from 'node:fs';
|
||||
import { Module } from 'node:module';
|
||||
import * as path from 'node:path';
|
||||
import * as url from 'node:url';
|
||||
const { app, dialog } = electron;
|
||||
|
||||
type DefaultAppOptions = {
|
||||
@@ -15,8 +16,6 @@ type DefaultAppOptions = {
|
||||
modules: string[];
|
||||
}
|
||||
|
||||
const Module = require('module');
|
||||
|
||||
// Parse command line options.
|
||||
const argv = process.argv.slice(1);
|
||||
|
||||
@@ -71,10 +70,10 @@ if (nextArgIsRequire) {
|
||||
|
||||
// Set up preload modules
|
||||
if (option.modules.length > 0) {
|
||||
Module._preloadModules(option.modules);
|
||||
(Module as any)._preloadModules(option.modules);
|
||||
}
|
||||
|
||||
function loadApplicationPackage (packagePath: string) {
|
||||
async function loadApplicationPackage (packagePath: string) {
|
||||
// Add a flag indicating app is started from default app.
|
||||
Object.defineProperty(process, 'defaultApp', {
|
||||
configurable: false,
|
||||
@@ -89,11 +88,19 @@ function loadApplicationPackage (packagePath: string) {
|
||||
let appPath;
|
||||
if (fs.existsSync(packageJsonPath)) {
|
||||
let packageJson;
|
||||
const emitWarning = process.emitWarning;
|
||||
try {
|
||||
packageJson = require(packageJsonPath);
|
||||
process.emitWarning = () => {};
|
||||
packageJson = (await import(url.pathToFileURL(packageJsonPath).toString(), {
|
||||
assert: {
|
||||
type: 'json'
|
||||
}
|
||||
})).default;
|
||||
} catch (e) {
|
||||
showErrorMessage(`Unable to parse ${packageJsonPath}\n\n${(e as Error).message}`);
|
||||
return;
|
||||
} finally {
|
||||
process.emitWarning = emitWarning;
|
||||
}
|
||||
|
||||
if (packageJson.version) {
|
||||
@@ -112,13 +119,15 @@ function loadApplicationPackage (packagePath: string) {
|
||||
// Set v8 flags, deliberately lazy load so that apps that do not use this
|
||||
// feature do not pay the price
|
||||
if (packageJson.v8Flags) {
|
||||
require('v8').setFlagsFromString(packageJson.v8Flags);
|
||||
(await import('node:v8')).setFlagsFromString(packageJson.v8Flags);
|
||||
}
|
||||
appPath = packagePath;
|
||||
}
|
||||
|
||||
let filePath: string;
|
||||
|
||||
try {
|
||||
const filePath = Module._resolveFilename(packagePath, module, true);
|
||||
filePath = (Module as any)._resolveFilename(packagePath, null, true);
|
||||
app.setAppPath(appPath || path.dirname(filePath));
|
||||
} catch (e) {
|
||||
showErrorMessage(`Unable to find Electron app at ${packagePath}\n\n${(e as Error).message}`);
|
||||
@@ -126,7 +135,7 @@ function loadApplicationPackage (packagePath: string) {
|
||||
}
|
||||
|
||||
// Run the app.
|
||||
Module._load(packagePath, module, true);
|
||||
await import(url.pathToFileURL(filePath).toString());
|
||||
} catch (e) {
|
||||
console.error('App threw an error during load');
|
||||
console.error((e as Error).stack || e);
|
||||
@@ -141,16 +150,16 @@ function showErrorMessage (message: string) {
|
||||
}
|
||||
|
||||
async function loadApplicationByURL (appUrl: string) {
|
||||
const { loadURL } = await import('./default_app');
|
||||
const { loadURL } = await import('./default_app.js');
|
||||
loadURL(appUrl);
|
||||
}
|
||||
|
||||
async function loadApplicationByFile (appPath: string) {
|
||||
const { loadFile } = await import('./default_app');
|
||||
const { loadFile } = await import('./default_app.js');
|
||||
loadFile(appPath);
|
||||
}
|
||||
|
||||
function startRepl () {
|
||||
async function startRepl () {
|
||||
if (process.platform === 'win32') {
|
||||
console.error('Electron REPL not currently supported on Windows');
|
||||
process.exit(1);
|
||||
@@ -171,8 +180,8 @@ function startRepl () {
|
||||
Using: Node.js ${nodeVersion} and Electron.js ${electronVersion}
|
||||
`);
|
||||
|
||||
const { REPLServer } = require('repl');
|
||||
const repl = new REPLServer({
|
||||
const { start } = await import('node:repl');
|
||||
const repl = start({
|
||||
prompt: '> '
|
||||
}).on('exit', () => {
|
||||
process.exit(0);
|
||||
@@ -225,8 +234,8 @@ function startRepl () {
|
||||
|
||||
const electronBuiltins = [...Object.keys(electron), 'original-fs', 'electron'];
|
||||
|
||||
const defaultComplete = repl.completer;
|
||||
repl.completer = (line: string, callback: Function) => {
|
||||
const defaultComplete: Function = repl.completer;
|
||||
(repl as any).completer = (line: string, callback: Function) => {
|
||||
const lastSpace = line.lastIndexOf(' ');
|
||||
const currentSymbol = line.substring(lastSpace + 1, repl.cursor);
|
||||
|
||||
@@ -249,11 +258,11 @@ if (option.file && !option.webdriver) {
|
||||
const protocol = url.parse(file).protocol;
|
||||
const extension = path.extname(file);
|
||||
if (protocol === 'http:' || protocol === 'https:' || protocol === 'file:' || protocol === 'chrome:') {
|
||||
loadApplicationByURL(file);
|
||||
await loadApplicationByURL(file);
|
||||
} else if (extension === '.html' || extension === '.htm') {
|
||||
loadApplicationByFile(path.resolve(file));
|
||||
await loadApplicationByFile(path.resolve(file));
|
||||
} else {
|
||||
loadApplicationPackage(file);
|
||||
await loadApplicationPackage(file);
|
||||
}
|
||||
} else if (option.version) {
|
||||
console.log('v' + process.versions.electron);
|
||||
@@ -262,7 +271,7 @@ if (option.file && !option.webdriver) {
|
||||
console.log(process.versions.modules);
|
||||
process.exit(0);
|
||||
} else if (option.interactive) {
|
||||
startRepl();
|
||||
await startRepl();
|
||||
} else {
|
||||
if (!option.noHelp) {
|
||||
const welcomeMessage = `
|
||||
@@ -285,5 +294,5 @@ Options:
|
||||
console.log(welcomeMessage);
|
||||
}
|
||||
|
||||
loadApplicationByFile('index.html');
|
||||
await loadApplicationByFile('index.html');
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"name": "electron",
|
||||
"productName": "Electron",
|
||||
"main": "main.js"
|
||||
"main": "main.js",
|
||||
"type": "module"
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ipcRenderer, contextBridge } from 'electron/renderer';
|
||||
const { ipcRenderer, contextBridge } = require('electron/renderer');
|
||||
|
||||
const policy = window.trustedTypes.createPolicy('electron-default-app', {
|
||||
// we trust the SVG contents
|
||||
|
||||
@@ -90,7 +90,6 @@ These individual tutorials expand on topics discussed in the guide above.
|
||||
|
||||
## API References
|
||||
|
||||
* [Synopsis](api/synopsis.md)
|
||||
* [Process Object](api/process.md)
|
||||
* [Supported Command Line Switches](api/command-line-switches.md)
|
||||
* [Environment Variables](api/environment-variables.md)
|
||||
|
||||
@@ -55,7 +55,7 @@ The `Super` (or `Meta`) key is mapped to the `Windows` key on Windows and Linux
|
||||
* `0` to `9`
|
||||
* `A` to `Z`
|
||||
* `F1` to `F24`
|
||||
* Punctuation like `~`, `!`, `@`, `#`, `$`, etc.
|
||||
* Various Punctuation: `)`, `!`, `@`, `#`, `$`, `%`, `^`, `&`, `*`, `(`, `:`, `;`, `:`, `+`, `=`, `<`, `,`, `_`, `-`, `>`, `.`, `?`, `/`, `~`, `` ` ``, `{`, `]`, `[`, `|`, `\`, `}`, `"`
|
||||
* `Plus`
|
||||
* `Space`
|
||||
* `Tab`
|
||||
|
||||
148
docs/api/app.md
148
docs/api/app.md
@@ -7,7 +7,7 @@ Process: [Main](../glossary.md#main-process)
|
||||
The following example shows how to quit the application when the last window is
|
||||
closed:
|
||||
|
||||
```javascript
|
||||
```js
|
||||
const { app } = require('electron')
|
||||
app.on('window-all-closed', () => {
|
||||
app.quit()
|
||||
@@ -23,8 +23,7 @@ The `app` object emits the following events:
|
||||
Emitted when the application has finished basic startup. On Windows and Linux,
|
||||
the `will-finish-launching` event is the same as the `ready` event; on macOS,
|
||||
this event represents the `applicationWillFinishLaunching` notification of
|
||||
`NSApplication`. You would usually set up listeners for the `open-file` and
|
||||
`open-url` events here, and start the crash reporter and auto updater.
|
||||
`NSApplication`.
|
||||
|
||||
In most cases, you should do everything in the `ready` event handler.
|
||||
|
||||
@@ -64,7 +63,7 @@ Calling `event.preventDefault()` will prevent the default behavior, which is
|
||||
terminating the application.
|
||||
|
||||
**Note:** If application quit was initiated by `autoUpdater.quitAndInstall()`,
|
||||
then `before-quit` is emitted *after* emitting `close` event on all windows and
|
||||
then `before-quit` is emitted _after_ emitting `close` event on all windows and
|
||||
closing them.
|
||||
|
||||
**Note:** On Windows, this event will not be emitted if the app is closed due
|
||||
@@ -128,12 +127,9 @@ 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
|
||||
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`
|
||||
event early in your application startup to detect if the the application being
|
||||
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 early in your application startup to detect if the 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_
|
||||
|
||||
@@ -153,9 +149,20 @@ Returns:
|
||||
|
||||
* `event` Event
|
||||
|
||||
Emitted when mac application become active. Difference from `activate` event is
|
||||
Emitted when the application becomes active. This differs from the `activate` event in
|
||||
that `did-become-active` is emitted every time the app becomes active, not only
|
||||
when Dock icon is clicked or application is re-launched.
|
||||
when Dock icon is clicked or application is re-launched. It is also emitted when a user
|
||||
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 doesn’t 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_
|
||||
|
||||
@@ -288,7 +295,7 @@ Emitted when failed to verify the `certificate` for `url`, to trust the
|
||||
certificate you should prevent the default behavior with
|
||||
`event.preventDefault()` and call `callback(true)`.
|
||||
|
||||
```javascript
|
||||
```js
|
||||
const { app } = require('electron')
|
||||
|
||||
app.on('certificate-error', (event, webContents, url, error, certificate, callback) => {
|
||||
@@ -320,7 +327,7 @@ and `callback` can be called with an entry filtered from the list. Using
|
||||
`event.preventDefault()` prevents the application from using the first
|
||||
certificate from the store.
|
||||
|
||||
```javascript
|
||||
```js
|
||||
const { app } = require('electron')
|
||||
|
||||
app.on('select-client-certificate', (event, webContents, url, list, callback) => {
|
||||
@@ -353,7 +360,7 @@ The default behavior is to cancel all authentications. To override this you
|
||||
should prevent the default behavior with `event.preventDefault()` and call
|
||||
`callback(username, password)` with the credentials.
|
||||
|
||||
```javascript
|
||||
```js
|
||||
const { app } = require('electron')
|
||||
|
||||
app.on('login', (event, webContents, details, authInfo, callback) => {
|
||||
@@ -405,18 +412,7 @@ Returns:
|
||||
|
||||
* `event` Event
|
||||
* `webContents` [WebContents](web-contents.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.
|
||||
* `details` [RenderProcessGoneDetails](structures/render-process-gone-details.md)
|
||||
|
||||
Emitted when the renderer process unexpectedly disappears. This is normally
|
||||
because it was crashed or killed.
|
||||
@@ -473,7 +469,7 @@ Returns:
|
||||
|
||||
Emitted when Electron has created a new `session`.
|
||||
|
||||
```javascript
|
||||
```js
|
||||
const { app } = require('electron')
|
||||
|
||||
app.on('session-created', (session) => {
|
||||
@@ -558,7 +554,7 @@ started after current instance exited.
|
||||
An example of restarting current instance immediately and adding a new command
|
||||
line argument to the new instance:
|
||||
|
||||
```javascript
|
||||
```js
|
||||
const { app } = require('electron')
|
||||
|
||||
app.relaunch({ args: process.argv.slice(1).concat(['--relaunch']) })
|
||||
@@ -754,14 +750,21 @@ 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:
|
||||
|
||||
* 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'`
|
||||
* `app.getSystemLocale()` returns `'fi-FI'`
|
||||
* `app.getPreferredSystemLanguages()` returns `['fr-CA', 'en-US', 'zh-Hans-CN', 'fi', 'es-419']`
|
||||
* 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.getLocale()` returns `'de'`
|
||||
* `app.getSystemLocale()` returns `'fr-FI'`
|
||||
* `app.getPreferredSystemLanguages()` returns `['fr-CA', 'en-US', 'zh-Hans-FI', 'es-419']`
|
||||
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):
|
||||
|
||||
```js
|
||||
app.getLocale() // 'de'
|
||||
app.getSystemLocale() // 'fi-FI'
|
||||
app.getPreferredSystemLanguages() // ['fr-CA', 'en-US', 'zh-Hans-CN', '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.
|
||||
|
||||
@@ -807,7 +810,7 @@ editor. Please refer to [Apple's documentation][CFBundleURLTypes] for details.
|
||||
**Note:** In a Windows Store environment (when packaged as an `appx`) this API
|
||||
will return `true` for all calls but the registry key it sets won't be accessible
|
||||
by other applications. In order to register your Windows Store application
|
||||
as a default protocol handler you must [declare the protocol in your manifest](https://docs.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://learn.microsoft.com/en-us/uwp/schemas/appxpackage/uapmanifestschema/element-uap-protocol).
|
||||
|
||||
The API uses the Windows Registry and `LSSetDefaultHandlerForURLScheme` internally.
|
||||
|
||||
@@ -936,7 +939,7 @@ List, nor will it be displayed.
|
||||
|
||||
Here's a very simple example of creating a custom Jump List:
|
||||
|
||||
```javascript
|
||||
```js
|
||||
const { app } = require('electron')
|
||||
|
||||
app.setJumpList([
|
||||
@@ -956,7 +959,7 @@ app.setJumpList([
|
||||
title: 'Tool A',
|
||||
program: process.execPath,
|
||||
args: '--run-tool-a',
|
||||
icon: process.execPath,
|
||||
iconPath: process.execPath,
|
||||
iconIndex: 0,
|
||||
description: 'Runs Tool A'
|
||||
},
|
||||
@@ -965,7 +968,7 @@ app.setJumpList([
|
||||
title: 'Tool B',
|
||||
program: process.execPath,
|
||||
args: '--run-tool-b',
|
||||
icon: process.execPath,
|
||||
iconPath: process.execPath,
|
||||
iconIndex: 0,
|
||||
description: 'Runs Tool B'
|
||||
}
|
||||
@@ -1019,8 +1022,8 @@ use this method to ensure single instance.
|
||||
An example of activating the window of primary instance when a second instance
|
||||
starts:
|
||||
|
||||
```javascript
|
||||
const { app } = require('electron')
|
||||
```js
|
||||
const { app, BrowserWindow } = require('electron')
|
||||
let myWindow = null
|
||||
|
||||
const additionalData = { myKey: 'myValue' }
|
||||
@@ -1040,9 +1043,9 @@ if (!gotTheLock) {
|
||||
}
|
||||
})
|
||||
|
||||
// Create myWindow, load the rest of the app, etc...
|
||||
app.whenReady().then(() => {
|
||||
myWindow = createWindow()
|
||||
myWindow = new BrowserWindow({})
|
||||
myWindow.loadURL('https://electronjs.org')
|
||||
})
|
||||
}
|
||||
```
|
||||
@@ -1165,11 +1168,15 @@ case the user's DNS configuration does not include a provider that supports
|
||||
DoH.
|
||||
|
||||
```js
|
||||
app.configureHostResolver({
|
||||
secureDnsMode: 'secure',
|
||||
secureDnsServers: [
|
||||
'https://cloudflare-dns.com/dns-query'
|
||||
]
|
||||
const { app } = require('electron')
|
||||
|
||||
app.whenReady().then(() => {
|
||||
app.configureHostResolver({
|
||||
secureDnsMode: 'secure',
|
||||
secureDnsServers: [
|
||||
'https://cloudflare-dns.com/dns-query'
|
||||
]
|
||||
})
|
||||
})
|
||||
```
|
||||
|
||||
@@ -1257,6 +1264,9 @@ On macOS, it shows on the dock icon. On Linux, it only works for Unity launcher.
|
||||
**Note:** Unity launcher requires a `.desktop` file to work. For more information,
|
||||
please read the [Unity integration documentation][unity-requirement].
|
||||
|
||||
**Note:** On macOS, you need to ensure that your application has the permission
|
||||
to display notifications for this method to work.
|
||||
|
||||
### `app.getBadgeCount()` _Linux_ _macOS_
|
||||
|
||||
Returns `Integer` - The current value displayed in the counter badge.
|
||||
@@ -1321,7 +1331,10 @@ To work with Electron's `autoUpdater` on Windows, which uses [Squirrel][Squirrel
|
||||
you'll want to set the launch path to Update.exe, and pass arguments that specify your
|
||||
application name. For example:
|
||||
|
||||
``` javascript
|
||||
``` js
|
||||
const { app } = require('electron')
|
||||
const path = require('node:path')
|
||||
|
||||
const appFolder = path.dirname(process.execPath)
|
||||
const updateExe = path.resolve(appFolder, '..', 'Update.exe')
|
||||
const exeName = path.basename(process.execPath)
|
||||
@@ -1331,7 +1344,7 @@ app.setLoginItemSettings({
|
||||
path: updateExe,
|
||||
args: [
|
||||
'--processStart', `"${exeName}"`,
|
||||
'--process-start-args', `"--hidden"`
|
||||
'--process-start-args', '"--hidden"'
|
||||
]
|
||||
})
|
||||
```
|
||||
@@ -1357,7 +1370,7 @@ This API must be called after the `ready` event is emitted.
|
||||
|
||||
### `app.showAboutPanel()`
|
||||
|
||||
Show the app's about panel options. These options can be overridden with `app.setAboutPanelOptions(options)`.
|
||||
Show the app's about panel options. These options can be overridden with `app.setAboutPanelOptions(options)`. This function runs asynchronously.
|
||||
|
||||
### `app.setAboutPanelOptions(options)`
|
||||
|
||||
@@ -1390,11 +1403,22 @@ 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.
|
||||
|
||||
```js
|
||||
// Start accessing the file.
|
||||
const stopAccessingSecurityScopedResource = app.startAccessingSecurityScopedResource(data)
|
||||
// You can now access the file outside of the sandbox 🎉
|
||||
const { app, dialog } = require('electron')
|
||||
const fs = require('node:fs')
|
||||
|
||||
// Remember to stop accessing the file once you've finished with it.
|
||||
let filepath
|
||||
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()
|
||||
```
|
||||
|
||||
@@ -1402,7 +1426,7 @@ Start accessing a security scoped resource. With this method Electron applicatio
|
||||
|
||||
### `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.
|
||||
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).
|
||||
|
||||
This method can only be called before app is ready.
|
||||
|
||||
@@ -1435,6 +1459,8 @@ By default, if an app of the same name as the one being moved exists in the Appl
|
||||
For example:
|
||||
|
||||
```js
|
||||
const { app, dialog } = require('electron')
|
||||
|
||||
app.moveToApplicationsFolder({
|
||||
conflictHandler: (conflictType) => {
|
||||
if (conflictType === 'exists') {
|
||||
@@ -1513,18 +1539,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.
|
||||
|
||||
[tasks]:https://msdn.microsoft.com/en-us/library/windows/desktop/dd378460(v=vs.85).aspx#tasks
|
||||
[app-user-model-id]: https://msdn.microsoft.com/en-us/library/windows/desktop/dd378459(v=vs.85).aspx
|
||||
[tasks]:https://learn.microsoft.com/en-us/windows/win32/shell/taskbar-extensions#tasks
|
||||
[app-user-model-id]: https://learn.microsoft.com/en-us/windows/win32/shell/appids
|
||||
[electron-forge]: https://www.electronforge.io/
|
||||
[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
|
||||
[LSCopyDefaultHandlerForURLScheme]: https://developer.apple.com/library/mac/documentation/Carbon/Reference/LaunchServicesReference/#//apple_ref/c/func/LSCopyDefaultHandlerForURLScheme
|
||||
[LSCopyDefaultHandlerForURLScheme]: https://developer.apple.com/documentation/coreservices/1441725-lscopydefaulthandlerforurlscheme?language=objc
|
||||
[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
|
||||
[unity-requirement]: https://help.ubuntu.com/community/UnityLaunchersAndDesktopFiles#Adding_shortcuts_to_a_launcher
|
||||
[mas-builds]: ../tutorial/mac-app-store-submission-guide.md
|
||||
[Squirrel-Windows]: https://github.com/Squirrel/Squirrel.Windows
|
||||
[JumpListBeginListMSDN]: https://msdn.microsoft.com/en-us/library/windows/desktop/dd378398(v=vs.85).aspx
|
||||
[JumpListBeginListMSDN]: https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-icustomdestinationlist-beginlist
|
||||
[about-panel-options]: https://developer.apple.com/reference/appkit/nsapplication/1428479-orderfrontstandardaboutpanelwith?language=objc
|
||||
|
||||
### `app.name`
|
||||
|
||||
@@ -137,8 +137,8 @@ application starts.
|
||||
[squirrel-mac]: https://github.com/Squirrel/Squirrel.Mac
|
||||
[server-support]: https://github.com/Squirrel/Squirrel.Mac#server-support
|
||||
[squirrel-windows]: https://github.com/Squirrel/Squirrel.Windows
|
||||
[installer]: https://github.com/electron/grunt-electron-installer
|
||||
[installer]: https://github.com/electron-archive/grunt-electron-installer
|
||||
[installer-lib]: https://github.com/electron/windows-installer
|
||||
[electron-forge-lib]: https://github.com/electron/forge
|
||||
[app-user-model-id]: https://msdn.microsoft.com/en-us/library/windows/desktop/dd378459(v=vs.85).aspx
|
||||
[app-user-model-id]: https://learn.microsoft.com/en-us/windows/win32/shell/appids
|
||||
[event-emitter]: https://nodejs.org/api/events.html#events_class_eventemitter
|
||||
|
||||
@@ -33,7 +33,7 @@ app.whenReady().then(() => {
|
||||
### `new BrowserView([options])` _Experimental_
|
||||
|
||||
* `options` Object (optional)
|
||||
* `webPreferences` Object (optional) - See [BrowserWindow](browser-window.md).
|
||||
* `webPreferences` [WebPreferences](structures/web-preferences.md?inline) (optional) - Settings of web page's features.
|
||||
|
||||
### Instance Properties
|
||||
|
||||
|
||||
@@ -104,6 +104,7 @@ window, you have to set both `parent` and `modal` options:
|
||||
```javascript
|
||||
const { BrowserWindow } = require('electron')
|
||||
|
||||
const top = new BrowserWindow()
|
||||
const child = new BrowserWindow({ parent: top, modal: true, show: false })
|
||||
child.loadURL('https://github.com')
|
||||
child.once('ready-to-show', () => {
|
||||
@@ -151,294 +152,7 @@ It creates a new `BrowserWindow` with native properties as set by the `options`.
|
||||
|
||||
### `new BrowserWindow([options])`
|
||||
|
||||
* `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`.
|
||||
* `options` [BrowserWindowConstructorOptions](structures/browser-window-options.md?inline) (optional)
|
||||
|
||||
### Instance Events
|
||||
|
||||
@@ -595,7 +309,7 @@ Emitted when the window is being moved to a new position.
|
||||
|
||||
Emitted once when the window is moved to a new position.
|
||||
|
||||
__Note__: On macOS this event is an alias of `move`.
|
||||
**Note**: On macOS this event is an alias of `move`.
|
||||
|
||||
#### Event: 'enter-full-screen'
|
||||
|
||||
@@ -629,7 +343,7 @@ Returns:
|
||||
* `event` Event
|
||||
* `command` string
|
||||
|
||||
Emitted when an [App Command](https://msdn.microsoft.com/en-us/library/windows/desktop/ms646275(v=vs.85).aspx)
|
||||
Emitted when an [App Command](https://learn.microsoft.com/en-us/windows/win32/inputdev/wm-appcommand)
|
||||
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.
|
||||
|
||||
@@ -653,36 +367,6 @@ The following app commands are explicitly supported on Linux:
|
||||
* `browser-backward`
|
||||
* `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`](./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`](./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`](./web-contents.md#event-input-event) event.
|
||||
|
||||
#### Event: 'swipe' _macOS_
|
||||
|
||||
Returns:
|
||||
@@ -884,7 +568,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 application’s Windows menu. `false` by default.
|
||||
|
||||
```js
|
||||
```js @ts-expect-error=[11]
|
||||
const win = new BrowserWindow({ height: 600, width: 600 })
|
||||
|
||||
const template = [
|
||||
@@ -954,7 +638,7 @@ Hides the window.
|
||||
|
||||
#### `win.isVisible()`
|
||||
|
||||
Returns `boolean` - Whether the window is visible to the user.
|
||||
Returns `boolean` - Whether the window is visible to the user in the foreground of the app.
|
||||
|
||||
#### `win.isModal()`
|
||||
|
||||
@@ -992,6 +676,8 @@ Returns `boolean` - Whether the window is minimized.
|
||||
|
||||
Sets whether the window should be in fullscreen mode.
|
||||
|
||||
**Note:** On macOS, fullscreen transitions take place asynchronously. If further actions depend on the fullscreen state, use the ['enter-full-screen'](browser-window.md#event-enter-full-screen) or ['leave-full-screen'](browser-window.md#event-leave-full-screen) events.
|
||||
|
||||
#### `win.isFullScreen()`
|
||||
|
||||
Returns `boolean` - Whether the window is in fullscreen mode.
|
||||
@@ -1104,10 +790,14 @@ win.setBounds({ width: 100 })
|
||||
console.log(win.getBounds())
|
||||
```
|
||||
|
||||
**Note:** On macOS, the y-coordinate value cannot be smaller than the [Tray](tray.md) height. The tray height has changed over time and depends on the operating system, but is between 20-40px. Passing a value lower than the tray height will result in a window that is flush to the tray.
|
||||
|
||||
#### `win.getBounds()`
|
||||
|
||||
Returns [`Rectangle`](structures/rectangle.md) - The `bounds` of the window as `Object`.
|
||||
|
||||
**Note:** On macOS, the y-coordinate value returned will be at minimum the [Tray](tray.md) height. For example, calling `win.setBounds({ x: 25, y: 20, width: 800, height: 600 })` with a tray height of 38 means that `win.getBounds()` will return `{ x: 25, y: 38, width: 800, height: 600 }`.
|
||||
|
||||
#### `win.getBackgroundColor()`
|
||||
|
||||
Returns `string` - Gets the background color of the window in Hex (`#RRGGBB`) format.
|
||||
@@ -1485,10 +1175,13 @@ Node's [`url.format`](https://nodejs.org/api/url.html#url_url_format_urlobject)
|
||||
method:
|
||||
|
||||
```javascript
|
||||
const { BrowserWindow } = require('electron')
|
||||
const win = new BrowserWindow()
|
||||
|
||||
const url = require('url').format({
|
||||
protocol: 'file',
|
||||
slashes: true,
|
||||
pathname: require('path').join(__dirname, 'index.html')
|
||||
pathname: require('node:path').join(__dirname, 'index.html')
|
||||
})
|
||||
|
||||
win.loadURL(url)
|
||||
@@ -1498,6 +1191,9 @@ You can load a URL using a `POST` request with URL-encoded data by doing
|
||||
the following:
|
||||
|
||||
```javascript
|
||||
const { BrowserWindow } = require('electron')
|
||||
const win = new BrowserWindow()
|
||||
|
||||
win.loadURL('http://localhost:8000/post', {
|
||||
postData: [{
|
||||
type: 'rawData',
|
||||
@@ -1664,13 +1360,13 @@ in the taskbar.
|
||||
#### `win.setAppDetails(options)` _Windows_
|
||||
|
||||
* `options` Object
|
||||
* `appId` string (optional) - Window's [App User Model ID](https://msdn.microsoft.com/en-us/library/windows/desktop/dd391569(v=vs.85).aspx).
|
||||
* `appId` string (optional) - Window's [App User Model ID](https://learn.microsoft.com/en-us/windows/win32/shell/appids).
|
||||
It has to be set, otherwise the other options will have no effect.
|
||||
* `appIconPath` string (optional) - Window's [Relaunch Icon](https://msdn.microsoft.com/en-us/library/windows/desktop/dd391573(v=vs.85).aspx).
|
||||
* `appIconPath` string (optional) - Window's [Relaunch Icon](https://learn.microsoft.com/en-us/windows/win32/properties/props-system-appusermodel-relaunchiconresource).
|
||||
* `appIconIndex` Integer (optional) - Index of the icon in `appIconPath`.
|
||||
Ignored when `appIconPath` is not set. Default is `0`.
|
||||
* `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://msdn.microsoft.com/en-us/library/windows/desktop/dd391572(v=vs.85).aspx).
|
||||
* `relaunchCommand` string (optional) - Window's [Relaunch Command](https://learn.microsoft.com/en-us/windows/win32/properties/props-system-appusermodel-relaunchcommand).
|
||||
* `relaunchDisplayName` string (optional) - Window's [Relaunch Display Name](https://learn.microsoft.com/en-us/windows/win32/properties/props-system-appusermodel-relaunchdisplaynameresource).
|
||||
|
||||
Sets the properties for the window's taskbar button.
|
||||
|
||||
@@ -1776,7 +1472,7 @@ On macOS it does not remove the focus from the window.
|
||||
|
||||
#### `win.isFocusable()` _macOS_ _Windows_
|
||||
|
||||
Returns whether the window can be focused.
|
||||
Returns `boolean` - Whether the window can be focused.
|
||||
|
||||
#### `win.setParentWindow(parent)`
|
||||
|
||||
@@ -1809,6 +1505,10 @@ tabs in the window.
|
||||
Selects the next tab when native tabs are enabled and there are other
|
||||
tabs in the window.
|
||||
|
||||
#### `win.showAllTabs()` _macOS_
|
||||
|
||||
Shows or hides the tab overview when native tabs are enabled.
|
||||
|
||||
#### `win.mergeAllWindows()` _macOS_
|
||||
|
||||
Merges all windows into one window with multiple tabs when native tabs
|
||||
@@ -1832,26 +1532,38 @@ Adds a window as a tab on this window, after the tab for the window instance.
|
||||
|
||||
#### `win.setVibrancy(type)` _macOS_
|
||||
|
||||
* `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
|
||||
* `type` string | null - Can be `titlebar`, `selection`, `menu`, `popover`, `sidebar`, `header`, `sheet`, `window`, `hud`, `fullscreen-ui`, `tooltip`, `content`, `under-window`, or `under-page`. See
|
||||
the [macOS documentation][vibrancy-docs] for more details.
|
||||
|
||||
Adds a vibrancy effect to the browser window. Passing `null` or an empty string
|
||||
will remove the vibrancy effect on the window.
|
||||
|
||||
Note that `appearance-based`, `light`, `dark`, `medium-light`, and `ultra-dark` have been
|
||||
deprecated and will be removed in an upcoming version of macOS.
|
||||
#### `win.setBackgroundMaterial(material)` _Windows_
|
||||
|
||||
#### `win.setTrafficLightPosition(position)` _macOS_
|
||||
* `material` string
|
||||
* `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.
|
||||
|
||||
* `position` [Point](structures/point.md)
|
||||
This method sets the browser window's system-drawn background material, including behind the non-client area.
|
||||
|
||||
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.
|
||||
Passing `null` will reset the position to default.
|
||||
|
||||
#### `win.getTrafficLightPosition()` _macOS_
|
||||
#### `win.getWindowButtonPosition()` _macOS_
|
||||
|
||||
Returns `Point` - The custom position for the traffic light buttons in
|
||||
frameless window.
|
||||
Returns `Point | null` - The custom position for the traffic light buttons in
|
||||
frameless window, `null` will be returned when there is no custom position.
|
||||
|
||||
#### `win.setTouchBar(touchBar)` _macOS_
|
||||
|
||||
@@ -1859,7 +1571,7 @@ frameless window.
|
||||
|
||||
Sets the touchBar layout for the current window. Specifying `null` or
|
||||
`undefined` clears the touch bar. This method only has an effect if the
|
||||
machine has a touch bar and is running on macOS 10.12.1+.
|
||||
machine has a touch bar.
|
||||
|
||||
**Note:** The TouchBar API is currently experimental and may change or be
|
||||
removed in future Electron releases.
|
||||
@@ -1894,8 +1606,8 @@ Throws an error if `browserView` is not attached to `win`.
|
||||
|
||||
#### `win.getBrowserViews()` _Experimental_
|
||||
|
||||
Returns `BrowserView[]` - an array of all BrowserViews that have been attached
|
||||
with `addBrowserView` or `setBrowserView`.
|
||||
Returns `BrowserView[]` - a sorted by z-index array of all BrowserViews that have been attached
|
||||
with `addBrowserView` or `setBrowserView`. The top-most BrowserView is the last element of the array.
|
||||
|
||||
**Note:** The BrowserView API is currently experimental and may change or be
|
||||
removed in future Electron releases.
|
||||
@@ -1905,17 +1617,13 @@ removed in future Electron releases.
|
||||
* `options` Object
|
||||
* `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.
|
||||
* `height` Integer (optional) _Windows_ - The height of the title bar and Window Controls Overlay in pixels.
|
||||
* `height` Integer (optional) _macOS_ _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
|
||||
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
|
||||
[quick-look]: https://en.wikipedia.org/wiki/Quick_Look
|
||||
[vibrancy-docs]: https://developer.apple.com/documentation/appkit/nsvisualeffectview?preferredLanguage=objc
|
||||
[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
|
||||
[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
|
||||
|
||||
@@ -23,12 +23,14 @@ following properties:
|
||||
with which the request is associated. Defaults to the empty string. The
|
||||
`session` option supersedes `partition`. Thus if a `session` is explicitly
|
||||
specified, `partition` is ignored.
|
||||
* `credentials` string (optional) - Can be `include` or `omit`. Whether to
|
||||
send [credentials](https://fetch.spec.whatwg.org/#credentials) with this
|
||||
* `credentials` string (optional) - Can be `include`, `omit` or
|
||||
`same-origin`. Whether to send
|
||||
[credentials](https://fetch.spec.whatwg.org/#credentials) with this
|
||||
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
|
||||
with the request (and the `'login'` event will not be triggered in the
|
||||
event of a 401). This matches the behavior of the
|
||||
event of a 401). If set to `same-origin`, `origin` must also be specified.
|
||||
This matches the behavior of the
|
||||
[fetch](https://fetch.spec.whatwg.org/#concept-request-credentials-mode)
|
||||
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
|
||||
@@ -49,6 +51,13 @@ following properties:
|
||||
[`request.followRedirect`](#requestfollowredirect) is invoked synchronously
|
||||
during the [`redirect`](#event-redirect) event. Defaults to `follow`.
|
||||
* `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`
|
||||
strictly follow the Node.js model as described in the
|
||||
@@ -56,7 +65,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:
|
||||
|
||||
```JavaScript
|
||||
```javascript
|
||||
const request = net.request({
|
||||
method: 'GET',
|
||||
protocol: 'https:',
|
||||
@@ -95,7 +104,7 @@ The `callback` function is expected to be called back with user credentials:
|
||||
* `username` string
|
||||
* `password` string
|
||||
|
||||
```JavaScript
|
||||
```javascript @ts-type={request:Electron.ClientRequest}
|
||||
request.on('login', (authInfo, callback) => {
|
||||
callback('username', 'password')
|
||||
})
|
||||
@@ -104,9 +113,9 @@ request.on('login', (authInfo, callback) => {
|
||||
Providing empty credentials will cancel the request and report an authentication
|
||||
error on the response object:
|
||||
|
||||
```JavaScript
|
||||
```javascript @ts-type={request:Electron.ClientRequest}
|
||||
request.on('response', (response) => {
|
||||
console.log(`STATUS: ${response.statusCode}`);
|
||||
console.log(`STATUS: ${response.statusCode}`)
|
||||
response.on('error', (error) => {
|
||||
console.log(`ERROR: ${JSON.stringify(error)}`)
|
||||
})
|
||||
@@ -234,6 +243,8 @@ it is not allowed to add or remove a custom header.
|
||||
* `encoding` string (optional)
|
||||
* `callback` Function (optional)
|
||||
|
||||
Returns `this`.
|
||||
|
||||
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.
|
||||
|
||||
|
||||
@@ -148,10 +148,7 @@ clipboard.
|
||||
```js
|
||||
const { clipboard } = require('electron')
|
||||
|
||||
clipboard.writeBookmark({
|
||||
text: 'https://electronjs.org',
|
||||
bookmark: 'Electron Homepage'
|
||||
})
|
||||
clipboard.writeBookmark('Electron Homepage', 'https://electronjs.org')
|
||||
```
|
||||
|
||||
### `clipboard.readFindText()` _macOS_
|
||||
@@ -226,7 +223,7 @@ clipboard.writeBuffer('public/utf8-plain-text', buffer)
|
||||
|
||||
const ret = clipboard.readBuffer('public/utf8-plain-text')
|
||||
|
||||
console.log(buffer.equals(out))
|
||||
console.log(buffer.equals(ret))
|
||||
// true
|
||||
```
|
||||
|
||||
|
||||
@@ -116,14 +116,20 @@ Ignore the connections limit for `domains` list separated by `,`.
|
||||
|
||||
### --js-flags=`flags`
|
||||
|
||||
Specifies the flags passed to the Node.js engine. It has to be passed when starting
|
||||
Electron if you want to enable the `flags` in the main process.
|
||||
Specifies the flags passed to the [V8 engine](https://v8.dev). In order to enable the `flags` in the main process,
|
||||
this switch must be passed on startup.
|
||||
|
||||
```sh
|
||||
$ electron --js-flags="--harmony_proxies --harmony_collections" your-app
|
||||
```
|
||||
|
||||
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.
|
||||
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.
|
||||
|
||||
For example, to trace V8 optimization and deoptimization:
|
||||
|
||||
```sh
|
||||
$ electron --js-flags="--trace-opt --trace-deopt" your-app
|
||||
```
|
||||
|
||||
### --lang
|
||||
|
||||
@@ -241,19 +247,25 @@ 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.
|
||||
|
||||
### --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.
|
||||
|
||||
Aliased to `--debug-brk=[host:]port`.
|
||||
|
||||
### --inspect-port=\[host:]port
|
||||
#### `--inspect-brk-node[=[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`.
|
||||
|
||||
Aliased to `--debug-port=[host:]port`.
|
||||
|
||||
### --inspect\[=\[host:]port]
|
||||
### `--inspect\[=\[host:]port]`
|
||||
|
||||
Activate inspector on `host:port`. Default is `127.0.0.1:9229`.
|
||||
|
||||
@@ -263,12 +275,37 @@ See the [Debugging the Main Process][debugging-main-process] guide for more deta
|
||||
|
||||
Aliased to `--debug[=[host:]port`.
|
||||
|
||||
### --inspect-publish-uid=stderr,http
|
||||
### `--inspect-publish-uid=stderr,http`
|
||||
|
||||
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.
|
||||
|
||||
### `--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
|
||||
[append-switch]: command-line.md#commandlineappendswitchswitch-value
|
||||
[debugging-main-process]: ../tutorial/debugging-main-process.md
|
||||
|
||||
@@ -18,7 +18,7 @@ contextBridge.exposeInMainWorld(
|
||||
)
|
||||
```
|
||||
|
||||
```javascript
|
||||
```javascript @ts-nocheck
|
||||
// Renderer (Main World)
|
||||
|
||||
window.electron.doThing()
|
||||
@@ -104,7 +104,7 @@ contextBridge.exposeInIsolatedWorld(
|
||||
)
|
||||
```
|
||||
|
||||
```javascript
|
||||
```javascript @ts-nocheck
|
||||
// Renderer (In isolated world id1004)
|
||||
|
||||
window.electron.doThing()
|
||||
@@ -147,7 +147,7 @@ Be very cautious about which globals and APIs you expose to untrusted remote con
|
||||
|
||||
```javascript
|
||||
const { contextBridge } = require('electron')
|
||||
const crypto = require('crypto')
|
||||
const crypto = require('node:crypto')
|
||||
contextBridge.exposeInMainWorld('nodeCrypto', {
|
||||
sha256sum (data) {
|
||||
const hash = crypto.createHash('sha256')
|
||||
|
||||
@@ -22,7 +22,7 @@ session.defaultSession.cookies.get({})
|
||||
})
|
||||
|
||||
// Query all cookies associated with a specific url.
|
||||
session.defaultSession.cookies.get({ url: 'http://www.github.com' })
|
||||
session.defaultSession.cookies.get({ url: 'https://www.github.com' })
|
||||
.then((cookies) => {
|
||||
console.log(cookies)
|
||||
}).catch((error) => {
|
||||
@@ -31,7 +31,7 @@ session.defaultSession.cookies.get({ url: 'http://www.github.com' })
|
||||
|
||||
// Set a cookie with the given cookie data;
|
||||
// may overwrite equivalent cookies if they exist.
|
||||
const cookie = { url: 'http://www.github.com', name: 'dummy_name', value: 'dummy' }
|
||||
const cookie = { url: 'https://www.github.com', name: 'dummy_name', value: 'dummy' }
|
||||
session.defaultSession.cookies.set(cookie)
|
||||
.then(() => {
|
||||
// success
|
||||
@@ -78,6 +78,7 @@ The following methods are available on instances of `Cookies`:
|
||||
* `path` string (optional) - Retrieves cookies whose path matches `path`.
|
||||
* `secure` boolean (optional) - Filters cookies by their Secure property.
|
||||
* `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.
|
||||
|
||||
@@ -118,4 +119,8 @@ Removes the cookies matching `url` and `name`
|
||||
|
||||
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.
|
||||
|
||||
@@ -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
|
||||
following projects:
|
||||
|
||||
* [socorro](https://github.com/mozilla/socorro)
|
||||
* [socorro](https://github.com/mozilla-services/socorro)
|
||||
* [mini-breakpad-server](https://github.com/electron/mini-breakpad-server)
|
||||
|
||||
> **Note:** Electron uses Crashpad, not Breakpad, to collect and upload
|
||||
|
||||
@@ -10,7 +10,9 @@ title is `Electron`:
|
||||
|
||||
```javascript
|
||||
// In the main process.
|
||||
const { desktopCapturer } = require('electron')
|
||||
const { BrowserWindow, desktopCapturer } = require('electron')
|
||||
|
||||
const mainWindow = new BrowserWindow()
|
||||
|
||||
desktopCapturer.getSources({ types: ['window', 'screen'] }).then(async sources => {
|
||||
for (const source of sources) {
|
||||
@@ -22,7 +24,7 @@ desktopCapturer.getSources({ types: ['window', 'screen'] }).then(async sources =
|
||||
})
|
||||
```
|
||||
|
||||
```javascript
|
||||
```javascript @ts-nocheck
|
||||
// In the preload script.
|
||||
const { ipcRenderer } = require('electron')
|
||||
|
||||
@@ -89,7 +91,7 @@ The `desktopCapturer` module has the following methods:
|
||||
|
||||
* `options` Object
|
||||
* `types` string[] - An array of strings that lists the types of desktop sources
|
||||
to be captured, available types are `screen` and `window`.
|
||||
to be captured, available types can be `screen` and `window`.
|
||||
* `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
|
||||
the thumbnails. This will save the processing time required for capturing the content of each
|
||||
|
||||
@@ -72,7 +72,7 @@ and a directory selector, so if you set `properties` to
|
||||
`['openFile', 'openDirectory']` on these platforms, a directory selector will be
|
||||
shown.
|
||||
|
||||
```js
|
||||
```js @ts-type={mainWindow:Electron.BrowserWindow}
|
||||
dialog.showOpenDialogSync(mainWindow, {
|
||||
properties: ['openFile', 'openDirectory']
|
||||
})
|
||||
@@ -139,7 +139,7 @@ and a directory selector, so if you set `properties` to
|
||||
`['openFile', 'openDirectory']` on these platforms, a directory selector will be
|
||||
shown.
|
||||
|
||||
```js
|
||||
```js @ts-type={mainWindow:Electron.BrowserWindow}
|
||||
dialog.showOpenDialog(mainWindow, {
|
||||
properties: ['openFile', 'openDirectory']
|
||||
}).then(result => {
|
||||
@@ -223,10 +223,10 @@ expanding and collapsing the dialog.
|
||||
* `browserWindow` [BrowserWindow](browser-window.md) (optional)
|
||||
* `options` Object
|
||||
* `message` string - Content of the message box.
|
||||
* `type` string (optional) - Can be `"none"`, `"info"`, `"error"`, `"question"` or
|
||||
`"warning"`. On Windows, `"question"` displays the same icon as `"info"`, unless
|
||||
you set an icon using the `"icon"` option. On macOS, both `"warning"` and
|
||||
`"error"` display the same warning icon.
|
||||
* `type` string (optional) - Can be `none`, `info`, `error`, `question` or
|
||||
`warning`. On Windows, `question` displays the same icon as `info`, unless
|
||||
you set an icon using the `icon` option. On macOS, both `warning` and
|
||||
`error` display the same warning icon.
|
||||
* `buttons` string[] (optional) - Array of texts for buttons. On Windows, an empty array
|
||||
will result in one button labeled "OK".
|
||||
* `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)
|
||||
* `options` Object
|
||||
* `message` string - Content of the message box.
|
||||
* `type` string (optional) - Can be `"none"`, `"info"`, `"error"`, `"question"` or
|
||||
`"warning"`. On Windows, `"question"` displays the same icon as `"info"`, unless
|
||||
you set an icon using the `"icon"` option. On macOS, both `"warning"` and
|
||||
`"error"` display the same warning icon.
|
||||
* `type` string (optional) - Can be `none`, `info`, `error`, `question` or
|
||||
`warning`. On Windows, `question` displays the same icon as `info`, unless
|
||||
you set an icon using the `icon` option. On macOS, both `warning` and
|
||||
`error` display the same warning icon.
|
||||
* `buttons` string[] (optional) - Array of texts for buttons. On Windows, an empty array
|
||||
will result in one button labeled "OK".
|
||||
* `defaultId` Integer (optional) - Index of the button in the buttons array which will
|
||||
|
||||
@@ -111,6 +111,16 @@ Options:
|
||||
* `kioclient5`
|
||||
* `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
|
||||
|
||||
The following environment variables are intended primarily for development and
|
||||
|
||||
@@ -40,18 +40,41 @@ We support the following extensions APIs, with some caveats. Other APIs may
|
||||
additionally be supported, but support for any APIs not listed here is
|
||||
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`
|
||||
|
||||
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`
|
||||
|
||||
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`
|
||||
|
||||
All features of this API are supported.
|
||||
|
||||
See [official documentation](https://developer.chrome.com/docs/extensions/reference/devtools_panels) for more information.
|
||||
|
||||
### `chrome.extension`
|
||||
|
||||
The following properties of `chrome.extension` are supported:
|
||||
@@ -63,6 +86,25 @@ The following methods of `chrome.extension` are supported:
|
||||
- `chrome.extension.getURL`
|
||||
- `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`
|
||||
|
||||
The following properties of `chrome.runtime` are supported:
|
||||
@@ -89,10 +131,23 @@ The following events of `chrome.runtime` are supported:
|
||||
- `chrome.runtime.onConnect`
|
||||
- `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`
|
||||
|
||||
Only `chrome.storage.local` is supported; `chrome.storage.sync` and
|
||||
`chrome.storage.managed` are not.
|
||||
The following methods of `chrome.storage` are supported:
|
||||
|
||||
- `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`
|
||||
|
||||
@@ -101,6 +156,8 @@ The following methods of `chrome.tabs` are supported:
|
||||
- `chrome.tabs.sendMessage`
|
||||
- `chrome.tabs.reload`
|
||||
- `chrome.tabs.executeScript`
|
||||
- `chrome.tabs.query` (partial support)
|
||||
- supported properties: `url`, `title`, `audible`, `active`, `muted`.
|
||||
- `chrome.tabs.update` (partial support)
|
||||
- supported properties: `url`, `muted`.
|
||||
|
||||
@@ -108,20 +165,12 @@ The following methods of `chrome.tabs` are supported:
|
||||
> tab". Since Electron has no such concept, passing `-1` as a tab ID is not
|
||||
> supported and will raise an error.
|
||||
|
||||
### `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`
|
||||
See [official documentation](https://developer.chrome.com/docs/extensions/reference/tabs) for more information.
|
||||
|
||||
### `chrome.webRequest`
|
||||
|
||||
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.
|
||||
|
||||
See [official documentation](https://developer.chrome.com/docs/extensions/reference/webRequest) for more information.
|
||||
|
||||
@@ -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
|
||||
duplicates are not merged.
|
||||
|
||||
```javascript
|
||||
```javascript @ts-type={response:Electron.IncomingMessage}
|
||||
// Prints something like:
|
||||
//
|
||||
// [ 'user-agent',
|
||||
@@ -100,5 +100,5 @@ duplicates are not merged.
|
||||
// '127.0.0.1:8000',
|
||||
// 'ACCEPT',
|
||||
// '*/*' ]
|
||||
console.log(request.rawHeaders)
|
||||
console.log(response.rawHeaders)
|
||||
```
|
||||
|
||||
@@ -72,7 +72,7 @@ Removes listeners of the specified `channel`.
|
||||
### `ipcMain.handle(channel, listener)`
|
||||
|
||||
* `channel` string
|
||||
* `listener` Function<Promise\<void> | any>
|
||||
* `listener` Function<Promise\<any> | any>
|
||||
* `event` [IpcMainInvokeEvent][ipc-main-invoke-event]
|
||||
* `...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
|
||||
listener will be used as the value of the reply.
|
||||
|
||||
```js title='Main Process'
|
||||
```js title='Main Process' @ts-type={somePromise:(...args:unknown[])=>Promise<unknown>}
|
||||
ipcMain.handle('my-invokable-ipc', async (event, ...args) => {
|
||||
const result = await somePromise(...args)
|
||||
return result
|
||||
})
|
||||
```
|
||||
|
||||
```js title='Renderer Process'
|
||||
```js title='Renderer Process' @ts-type={arg1:unknown} @ts-type={arg2:unknown}
|
||||
async () => {
|
||||
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)`
|
||||
|
||||
* `channel` string
|
||||
* `listener` Function<Promise\<void> | any>
|
||||
* `event` IpcMainInvokeEvent
|
||||
* `listener` Function<Promise\<any> | any>
|
||||
* `event` [IpcMainInvokeEvent][ipc-main-invoke-event]
|
||||
* `...args` any[]
|
||||
|
||||
Handles a single `invoke`able IPC message, then removes the listener. See
|
||||
@@ -122,17 +122,6 @@ Handles a single `invoke`able IPC message, then removes the listener. See
|
||||
|
||||
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
|
||||
[event-emitter]: https://nodejs.org/api/events.html#events_class_eventemitter
|
||||
[web-contents-send]: ../api/web-contents.md#contentssendchannel-args
|
||||
|
||||
@@ -26,26 +26,45 @@ The `ipcRenderer` module has the following method to listen for events and send
|
||||
|
||||
* `channel` string
|
||||
* `listener` Function
|
||||
* `event` IpcRendererEvent
|
||||
* `event` [IpcRendererEvent][ipc-renderer-event]
|
||||
* `...args` any[]
|
||||
|
||||
Listens to `channel`, when a new message arrives `listener` would be called with
|
||||
`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)`
|
||||
|
||||
* `channel` string
|
||||
* `listener` Function
|
||||
* `event` IpcRendererEvent
|
||||
* `event` [IpcRendererEvent][ipc-renderer-event]
|
||||
* `...args` any[]
|
||||
|
||||
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.
|
||||
|
||||
### `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)`
|
||||
|
||||
* `channel` string
|
||||
* `listener` Function
|
||||
* `event` [IpcRendererEvent][ipc-renderer-event]
|
||||
* `...args` any[]
|
||||
|
||||
Removes the specified `listener` from the listener array for the specified
|
||||
@@ -101,7 +120,7 @@ The main process should listen for `channel` with
|
||||
|
||||
For example:
|
||||
|
||||
```javascript
|
||||
```javascript @ts-type={someArgument:unknown} @ts-type={doSomeWork:(arg:unknown)=>Promise<unknown>}
|
||||
// Renderer process
|
||||
ipcRenderer.invoke('some-name', someArgument).then((result) => {
|
||||
// ...
|
||||
@@ -192,14 +211,6 @@ ipcMain.on('port', (e, msg) => {
|
||||
For more information on using `MessagePort` and `MessageChannel`, see the [MDN
|
||||
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)`
|
||||
|
||||
* `channel` string
|
||||
@@ -208,12 +219,8 @@ Sends a message to a window with `webContentsId` via `channel`.
|
||||
Like `ipcRenderer.send` but the event will be sent to the `<webview>` element in
|
||||
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
|
||||
[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
|
||||
[`MessagePort`]: https://developer.mozilla.org/en-US/docs/Web/API/MessagePort
|
||||
[ipc-renderer-event]: ./structures/ipc-renderer-event.md
|
||||
|
||||
@@ -14,7 +14,7 @@ See [`Menu`](menu.md) for examples.
|
||||
* `menuItem` MenuItem
|
||||
* `browserWindow` [BrowserWindow](browser-window.md) | undefined - This will not be defined if no window is open.
|
||||
* `event` [KeyboardEvent](structures/keyboard-event.md)
|
||||
* `role` string (optional) - Can be `undo`, `redo`, `cut`, `copy`, `paste`, `pasteAndMatchStyle`, `delete`, `selectAll`, `reload`, `forceReload`, `toggleDevTools`, `resetZoom`, `zoomIn`, `zoomOut`, `toggleSpellChecker`, `togglefullscreen`, `window`, `minimize`, `close`, `help`, `about`, `services`, `hide`, `hideOthers`, `unhide`, `quit`, `showSubstitutions`, `toggleSmartQuotes`, `toggleSmartDashes`, `toggleTextReplacement`, `startSpeaking`, `stopSpeaking`, `zoom`, `front`, `appMenu`, `fileMenu`, `editMenu`, `viewMenu`, `shareMenu`, `recentDocuments`, `toggleTabBar`, `selectNextTab`, `selectPreviousTab`, `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`, `showAllTabs`, `mergeAllWindows`, `clearRecentDocuments`, `moveTabToNewWindow` or `windowMenu` - Define the action of the menu item, when specified the
|
||||
`click` property will be ignored. See [roles](#roles).
|
||||
* `type` string (optional) - Can be `normal`, `separator`, `submenu`, `checkbox` or
|
||||
`radio`.
|
||||
@@ -51,7 +51,7 @@ See [`Menu`](menu.md) for examples.
|
||||
the placement of their containing group after the containing group of the item
|
||||
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. This property is only usable on macOS High Sierra 10.13 or newer.
|
||||
**Note:** `acceleratorWorksWhenHidden` is specified as being macOS-only because accelerators always work when items are hidden on Windows and Linux. The option is exposed to users to give them the option to turn it off, as this is possible in native macOS development.
|
||||
|
||||
### Roles
|
||||
|
||||
@@ -111,11 +111,12 @@ The following additional roles are available on _macOS_:
|
||||
* `toggleTabBar` - Map to the `toggleTabBar` action.
|
||||
* `selectNextTab` - Map to the `selectNextTab` action.
|
||||
* `selectPreviousTab` - Map to the `selectPreviousTab` action.
|
||||
* `showAllTabs` - Map to the `showAllTabs` action.
|
||||
* `mergeAllWindows` - Map to the `mergeAllWindows` action.
|
||||
* `moveTabToNewWindow` - Map to the `moveTabToNewWindow` action.
|
||||
* `window` - The submenu is a "Window" menu.
|
||||
* `help` - The submenu is a "Help" menu.
|
||||
* `services` - The submenu is a ["Services"](https://developer.apple.com/documentation/appkit/nsapplication/1428608-servicesmenu?language=objc) menu. This is only intended for use in the Application Menu and is *not* the same as the "Services" submenu used in context menus in macOS apps, which is not implemented in Electron.
|
||||
* `services` - The submenu is a ["Services"](https://developer.apple.com/documentation/appkit/nsapplication/1428608-servicesmenu?language=objc) menu. This is only intended for use in the Application Menu and is _not_ the same as the "Services" submenu used in context menus in macOS apps, which is not implemented in Electron.
|
||||
* `recentDocuments` - The submenu is an "Open Recent" menu.
|
||||
* `clearRecentDocuments` - Map to the `clearRecentDocuments` action.
|
||||
* `shareMenu` - The submenu is [share menu][ShareMenu]. The `sharingItem` property must also be set to indicate the item to share.
|
||||
@@ -159,7 +160,7 @@ A `string` indicating the type of the item. Can be `normal`, `separator`, `subme
|
||||
|
||||
#### `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`, `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`, `showAllTabs`, `mergeAllWindows`, `clearRecentDocuments`, `moveTabToNewWindow` or `windowMenu`
|
||||
|
||||
#### `menuItem.accelerator`
|
||||
|
||||
|
||||
@@ -80,6 +80,10 @@ The `menu` object has the following instance methods:
|
||||
* `positioningItem` number (optional) _macOS_ - The index of the menu item to
|
||||
be positioned under the mouse cursor at the specified coordinates. Default
|
||||
is -1.
|
||||
* `sourceType` string (optional) _Windows_ _Linux_ - This should map to the `menuSourceType`
|
||||
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.
|
||||
|
||||
Pops up this menu as a context menu in the [`BrowserWindow`](browser-window.md).
|
||||
@@ -147,27 +151,29 @@ can have a submenu.
|
||||
|
||||
An example of creating the application menu with the simple template API:
|
||||
|
||||
```javascript
|
||||
```javascript @ts-expect-error=[107]
|
||||
const { app, Menu } = require('electron')
|
||||
|
||||
const isMac = process.platform === 'darwin'
|
||||
|
||||
const template = [
|
||||
// { role: 'appMenu' }
|
||||
...(isMac ? [{
|
||||
label: app.name,
|
||||
submenu: [
|
||||
{ role: 'about' },
|
||||
{ type: 'separator' },
|
||||
{ role: 'services' },
|
||||
{ type: 'separator' },
|
||||
{ role: 'hide' },
|
||||
{ role: 'hideOthers' },
|
||||
{ role: 'unhide' },
|
||||
{ type: 'separator' },
|
||||
{ role: 'quit' }
|
||||
]
|
||||
}] : []),
|
||||
...(isMac
|
||||
? [{
|
||||
label: app.name,
|
||||
submenu: [
|
||||
{ role: 'about' },
|
||||
{ type: 'separator' },
|
||||
{ role: 'services' },
|
||||
{ type: 'separator' },
|
||||
{ role: 'hide' },
|
||||
{ role: 'hideOthers' },
|
||||
{ role: 'unhide' },
|
||||
{ type: 'separator' },
|
||||
{ role: 'quit' }
|
||||
]
|
||||
}]
|
||||
: []),
|
||||
// { role: 'fileMenu' }
|
||||
{
|
||||
label: 'File',
|
||||
@@ -185,23 +191,25 @@ const template = [
|
||||
{ role: 'cut' },
|
||||
{ role: 'copy' },
|
||||
{ role: 'paste' },
|
||||
...(isMac ? [
|
||||
{ role: 'pasteAndMatchStyle' },
|
||||
{ role: 'delete' },
|
||||
{ role: 'selectAll' },
|
||||
{ type: 'separator' },
|
||||
{
|
||||
label: 'Speech',
|
||||
submenu: [
|
||||
{ role: 'startSpeaking' },
|
||||
{ role: 'stopSpeaking' }
|
||||
...(isMac
|
||||
? [
|
||||
{ role: 'pasteAndMatchStyle' },
|
||||
{ role: 'delete' },
|
||||
{ role: 'selectAll' },
|
||||
{ type: 'separator' },
|
||||
{
|
||||
label: 'Speech',
|
||||
submenu: [
|
||||
{ role: 'startSpeaking' },
|
||||
{ role: 'stopSpeaking' }
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
] : [
|
||||
{ role: 'delete' },
|
||||
{ type: 'separator' },
|
||||
{ role: 'selectAll' }
|
||||
])
|
||||
: [
|
||||
{ role: 'delete' },
|
||||
{ type: 'separator' },
|
||||
{ role: 'selectAll' }
|
||||
])
|
||||
]
|
||||
},
|
||||
// { role: 'viewMenu' }
|
||||
@@ -225,14 +233,16 @@ const template = [
|
||||
submenu: [
|
||||
{ role: 'minimize' },
|
||||
{ role: 'zoom' },
|
||||
...(isMac ? [
|
||||
{ type: 'separator' },
|
||||
{ role: 'front' },
|
||||
{ type: 'separator' },
|
||||
{ role: 'window' }
|
||||
] : [
|
||||
{ role: 'close' }
|
||||
])
|
||||
...(isMac
|
||||
? [
|
||||
{ type: 'separator' },
|
||||
{ role: 'front' },
|
||||
{ type: 'separator' },
|
||||
{ role: 'window' }
|
||||
]
|
||||
: [
|
||||
{ role: 'close' }
|
||||
])
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -261,7 +271,7 @@ menu on behalf of the renderer.
|
||||
|
||||
Below is an example of showing a menu when the user right clicks the page:
|
||||
|
||||
```js
|
||||
```js @ts-expect-error=[21]
|
||||
// renderer
|
||||
window.addEventListener('contextmenu', (e) => {
|
||||
e.preventDefault()
|
||||
@@ -283,7 +293,7 @@ ipcMain.on('show-context-menu', (event) => {
|
||||
{ label: 'Menu Item 2', type: 'checkbox', checked: true }
|
||||
]
|
||||
const menu = Menu.buildFromTemplate(template)
|
||||
menu.popup(BrowserWindow.fromWebContents(event.sender))
|
||||
menu.popup({ window: BrowserWindow.fromWebContents(event.sender) })
|
||||
})
|
||||
```
|
||||
|
||||
@@ -317,7 +327,7 @@ name, no matter what label you set. To change it, modify your app bundle's
|
||||
[About Information Property List Files][AboutInformationPropertyListFiles]
|
||||
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
|
||||
browser windows.
|
||||
|
||||
@@ -17,7 +17,8 @@ Example:
|
||||
|
||||
```js
|
||||
// Main process
|
||||
const { MessageChannelMain } = require('electron')
|
||||
const { BrowserWindow, MessageChannelMain } = require('electron')
|
||||
const w = new BrowserWindow()
|
||||
const { port1, port2 } = new MessageChannelMain()
|
||||
w.webContents.postMessage('port', null, [port2])
|
||||
port1.postMessage({ some: 'message' })
|
||||
@@ -26,9 +27,9 @@ port1.postMessage({ some: 'message' })
|
||||
const { ipcRenderer } = require('electron')
|
||||
ipcRenderer.on('port', (e) => {
|
||||
// e.ports is a list of ports sent along with this message
|
||||
e.ports[0].on('message', (messageEvent) => {
|
||||
e.ports[0].onmessage = (messageEvent) => {
|
||||
console.log(messageEvent.data)
|
||||
})
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
@@ -47,9 +47,9 @@ quality, it is recommended to include at least the following sizes in the:
|
||||
* 64x64 (200% DPI scale)
|
||||
* 256x256
|
||||
|
||||
Check the *Size requirements* section in [this article][icons].
|
||||
Check the _Size requirements_ section in [this article][icons].
|
||||
|
||||
[icons]:https://msdn.microsoft.com/en-us/library/windows/desktop/dn742485(v=vs.85).aspx
|
||||
[icons]: https://learn.microsoft.com/en-us/windows/win32/uxguide/vis-icons
|
||||
|
||||
## High Resolution Image
|
||||
|
||||
@@ -119,13 +119,15 @@ Returns `NativeImage`
|
||||
|
||||
Creates an empty `NativeImage` instance.
|
||||
|
||||
### `nativeImage.createThumbnailFromPath(path, maxSize)` _macOS_ _Windows_
|
||||
### `nativeImage.createThumbnailFromPath(path, size)` _macOS_ _Windows_
|
||||
|
||||
* `path` string - path to a file that we intend to construct a thumbnail out of.
|
||||
* `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`.
|
||||
* `size` [Size](structures/size.md) - the desired width and height (positive numbers) of the thumbnail.
|
||||
|
||||
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)`
|
||||
|
||||
* `path` string
|
||||
@@ -304,7 +306,7 @@ Returns `NativeImage` - The cropped image.
|
||||
* `width` Integer (optional) - Defaults to the image's width.
|
||||
* `height` Integer (optional) - Defaults to the image's height.
|
||||
* `quality` string (optional) - The desired quality of the resize image.
|
||||
Possible values are `good`, `better`, or `best`. The default is `best`.
|
||||
Possible values include `good`, `better`, or `best`. The default is `best`.
|
||||
These values express a desired quality/speed tradeoff. They are translated
|
||||
into an algorithm-specific method that depends on the capabilities
|
||||
(CPU, GPU) of the underlying platform. It is possible for all three methods
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
Process: [Main](../glossary.md#main-process)
|
||||
|
||||
```javascript
|
||||
const { netLog } = require('electron')
|
||||
const { app, netLog } = require('electron')
|
||||
|
||||
app.whenReady().then(async () => {
|
||||
await netLog.startLogging('/path/to/net-log')
|
||||
|
||||
@@ -63,6 +63,62 @@ Creates a [`ClientRequest`](./client-request.md) instance using the provided
|
||||
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.
|
||||
|
||||
### `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 })
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
### `net.isOnline()`
|
||||
|
||||
Returns `boolean` - Whether there is currently internet connection.
|
||||
@@ -73,6 +129,45 @@ won't be able to connect to remote sites. However, a return value of
|
||||
whether a particular connection attempt to a particular remote site
|
||||
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
|
||||
|
||||
### `net.online` _Readonly_
|
||||
|
||||
@@ -4,9 +4,12 @@
|
||||
|
||||
Process: [Main](../glossary.md#main-process)
|
||||
|
||||
## Using in the renderer process
|
||||
:::info Renderer process notifications
|
||||
|
||||
If you want to show Notifications from a renderer process you should use the [HTML5 Notification API](../tutorial/notifications.md)
|
||||
If you want to show notifications from a renderer process you should use the
|
||||
[web Notifications API](../tutorial/notifications.md)
|
||||
|
||||
:::
|
||||
|
||||
## Class: Notification
|
||||
|
||||
@@ -29,10 +32,10 @@ Returns `boolean` - Whether or not desktop notifications are supported on the cu
|
||||
### `new Notification([options])`
|
||||
|
||||
* `options` Object (optional)
|
||||
* `title` string (optional) - A title for the notification, which will be shown at the top of the notification window when it is shown.
|
||||
* `title` string (optional) - A title for the notification, which will be displayed 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.
|
||||
* `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 emit an OS notification noise when showing the notification.
|
||||
* `silent` boolean (optional) - Whether or not to suppress the OS notification noise when showing 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.
|
||||
* `timeoutType` string (optional) _Linux_ _Windows_ - The timeout duration of the notification. Can be 'default' or 'never'.
|
||||
@@ -47,8 +50,11 @@ Returns `boolean` - Whether or not desktop notifications are supported on the cu
|
||||
|
||||
Objects created with `new Notification` emit the following events:
|
||||
|
||||
**Note:** Some events are only available on specific operating systems and are
|
||||
labeled as such.
|
||||
:::info
|
||||
|
||||
Some events are only available on specific operating systems and are labeled as such.
|
||||
|
||||
:::
|
||||
|
||||
#### Event: 'show'
|
||||
|
||||
@@ -56,7 +62,7 @@ Returns:
|
||||
|
||||
* `event` Event
|
||||
|
||||
Emitted when the notification is shown to the user, note this could be fired
|
||||
Emitted when the notification is shown to the user. Note that this event can be fired
|
||||
multiple times as a notification can be shown multiple times through the
|
||||
`show()` method.
|
||||
|
||||
@@ -106,14 +112,13 @@ Emitted when an error is encountered while creating and showing the native notif
|
||||
|
||||
### Instance Methods
|
||||
|
||||
Objects created with `new Notification` have the following instance methods:
|
||||
Objects created with the `new Notification()` constructor have the following instance methods:
|
||||
|
||||
#### `notification.show()`
|
||||
|
||||
Immediately shows the notification to the user, please note this means unlike the
|
||||
HTML5 Notification implementation, instantiating a `new Notification` does
|
||||
not immediately show it to the user, you need to call this method before the OS
|
||||
will display it.
|
||||
Immediately shows the notification to the user. Unlike the web notification API,
|
||||
instantiating a `new Notification()` does not immediately show it to the user. Instead, you need to
|
||||
call this method before the OS will display it.
|
||||
|
||||
If the notification has been shown before, this method will dismiss the previously
|
||||
shown notification and create a new one with identical properties.
|
||||
@@ -160,7 +165,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'.
|
||||
|
||||
Default is 'low' - see [NotifyUrgency](https://developer.gnome.org/notification-spec/#urgency-levels) for more information.
|
||||
Default is 'low' - see [NotifyUrgency](https://developer-old.gnome.org/notification-spec/#urgency-levels) for more information.
|
||||
|
||||
#### `notification.timeoutType` _Linux_ _Windows_
|
||||
|
||||
|
||||
@@ -24,6 +24,30 @@ Emitted when the system changes to AC 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_
|
||||
|
||||
Emitted when the system is about to reboot or shut down. If the event handler
|
||||
@@ -55,7 +79,7 @@ The `powerMonitor` module has the following methods:
|
||||
|
||||
* `idleThreshold` Integer
|
||||
|
||||
Returns `string` - The system's current state. Can be `active`, `idle`, `locked` or `unknown`.
|
||||
Returns `string` - The system's current idle state. Can be `active`, `idle`, `locked` or `unknown`.
|
||||
|
||||
Calculate the system idle state. `idleThreshold` is the amount of time (in seconds)
|
||||
before considered idle. `locked` is available on supported systems only.
|
||||
@@ -66,6 +90,10 @@ Returns `Integer` - 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()`
|
||||
|
||||
Returns `boolean` - Whether the system is on battery power.
|
||||
|
||||
@@ -49,6 +49,8 @@ is used.
|
||||
|
||||
Stops the specified power save blocker.
|
||||
|
||||
Returns `boolean` - Whether the specified `powerSaveBlocker` has been stopped.
|
||||
|
||||
### `powerSaveBlocker.isStarted(id)`
|
||||
|
||||
* `id` Integer - The power save blocker id returned by `powerSaveBlocker.start`.
|
||||
|
||||
@@ -49,8 +49,11 @@ beginning to load the web page or the main script.
|
||||
|
||||
### `process.defaultApp` _Readonly_
|
||||
|
||||
A `boolean`. When app is started by being passed as parameter to the default app, this
|
||||
A `boolean`. When the app is started by being passed as parameter to the default Electron executable, this
|
||||
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_
|
||||
|
||||
|
||||
@@ -8,15 +8,11 @@ An example of implementing a protocol that has the same effect as the
|
||||
`file://` protocol:
|
||||
|
||||
```javascript
|
||||
const { app, protocol } = require('electron')
|
||||
const path = require('path')
|
||||
const url = require('url')
|
||||
const { app, protocol, net } = require('electron')
|
||||
|
||||
app.whenReady().then(() => {
|
||||
protocol.registerFileProtocol('atom', (request, callback) => {
|
||||
const filePath = url.fileURLToPath('file://' + request.url.slice('atom://'.length))
|
||||
callback(filePath)
|
||||
})
|
||||
protocol.handle('atom', (request) =>
|
||||
net.fetch('file://' + request.url.slice('atom://'.length)))
|
||||
})
|
||||
```
|
||||
|
||||
@@ -36,19 +32,20 @@ To have your custom protocol work in combination with a custom session, you need
|
||||
to register it to that session explicitly.
|
||||
|
||||
```javascript
|
||||
const { session, app, protocol } = require('electron')
|
||||
const path = require('path')
|
||||
const { app, BrowserWindow, net, protocol, session } = require('electron')
|
||||
const path = require('node:path')
|
||||
const url = require('url')
|
||||
|
||||
app.whenReady().then(() => {
|
||||
const partition = 'persist:example'
|
||||
const ses = session.fromPartition(partition)
|
||||
|
||||
ses.protocol.registerFileProtocol('atom', (request, callback) => {
|
||||
const url = request.url.substr(7)
|
||||
callback({ path: path.normalize(`${__dirname}/${url}`) })
|
||||
ses.protocol.handle('atom', (request) => {
|
||||
const filePath = request.url.slice('atom://'.length)
|
||||
return net.fetch(url.pathToFileURL(path.join(__dirname, filePath)).toString())
|
||||
})
|
||||
|
||||
mainWindow = new BrowserWindow({ webPreferences: { partition } })
|
||||
const mainWindow = new BrowserWindow({ webPreferences: { partition } })
|
||||
})
|
||||
```
|
||||
|
||||
@@ -109,7 +106,74 @@ The `<video>` and `<audio>` HTML elements expect protocols to buffer their
|
||||
responses by default. The `stream` flag configures those elements to correctly
|
||||
expect streaming responses.
|
||||
|
||||
### `protocol.registerFileProtocol(scheme, handler)`
|
||||
### `protocol.handle(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 { join } = 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 does not check for paths that escape the bundle, e.g.
|
||||
// app://bundle/../../secret_file.txt
|
||||
return net.fetch(pathToFileURL(join(__dirname, pathname)).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
|
||||
* `handler` Function
|
||||
@@ -130,7 +194,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
|
||||
from protocols that follow the "generic URI syntax" like `file:`.
|
||||
|
||||
### `protocol.registerBufferProtocol(scheme, handler)`
|
||||
### `protocol.registerBufferProtocol(scheme, handler)` _Deprecated_
|
||||
|
||||
* `scheme` string
|
||||
* `handler` Function
|
||||
@@ -154,7 +218,7 @@ protocol.registerBufferProtocol('atom', (request, callback) => {
|
||||
})
|
||||
```
|
||||
|
||||
### `protocol.registerStringProtocol(scheme, handler)`
|
||||
### `protocol.registerStringProtocol(scheme, handler)` _Deprecated_
|
||||
|
||||
* `scheme` string
|
||||
* `handler` Function
|
||||
@@ -170,7 +234,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`
|
||||
property.
|
||||
|
||||
### `protocol.registerHttpProtocol(scheme, handler)`
|
||||
### `protocol.registerHttpProtocol(scheme, handler)` _Deprecated_
|
||||
|
||||
* `scheme` string
|
||||
* `handler` Function
|
||||
@@ -185,7 +249,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`
|
||||
should be called with an object that has the `url` property.
|
||||
|
||||
### `protocol.registerStreamProtocol(scheme, handler)`
|
||||
### `protocol.registerStreamProtocol(scheme, handler)` _Deprecated_
|
||||
|
||||
* `scheme` string
|
||||
* `handler` Function
|
||||
@@ -234,7 +298,7 @@ protocol.registerStreamProtocol('atom', (request, callback) => {
|
||||
})
|
||||
```
|
||||
|
||||
### `protocol.unregisterProtocol(scheme)`
|
||||
### `protocol.unregisterProtocol(scheme)` _Deprecated_
|
||||
|
||||
* `scheme` string
|
||||
|
||||
@@ -242,13 +306,13 @@ Returns `boolean` - Whether the protocol was successfully unregistered
|
||||
|
||||
Unregisters the custom protocol of `scheme`.
|
||||
|
||||
### `protocol.isProtocolRegistered(scheme)`
|
||||
### `protocol.isProtocolRegistered(scheme)` _Deprecated_
|
||||
|
||||
* `scheme` string
|
||||
|
||||
Returns `boolean` - Whether `scheme` is already registered.
|
||||
|
||||
### `protocol.interceptFileProtocol(scheme, handler)`
|
||||
### `protocol.interceptFileProtocol(scheme, handler)` _Deprecated_
|
||||
|
||||
* `scheme` string
|
||||
* `handler` Function
|
||||
@@ -261,7 +325,7 @@ Returns `boolean` - Whether the protocol was successfully intercepted
|
||||
Intercepts `scheme` protocol and uses `handler` as the protocol's new handler
|
||||
which sends a file as a response.
|
||||
|
||||
### `protocol.interceptStringProtocol(scheme, handler)`
|
||||
### `protocol.interceptStringProtocol(scheme, handler)` _Deprecated_
|
||||
|
||||
* `scheme` string
|
||||
* `handler` Function
|
||||
@@ -274,7 +338,7 @@ Returns `boolean` - Whether the protocol was successfully intercepted
|
||||
Intercepts `scheme` protocol and uses `handler` as the protocol's new handler
|
||||
which sends a `string` as a response.
|
||||
|
||||
### `protocol.interceptBufferProtocol(scheme, handler)`
|
||||
### `protocol.interceptBufferProtocol(scheme, handler)` _Deprecated_
|
||||
|
||||
* `scheme` string
|
||||
* `handler` Function
|
||||
@@ -287,7 +351,7 @@ Returns `boolean` - Whether the protocol was successfully intercepted
|
||||
Intercepts `scheme` protocol and uses `handler` as the protocol's new handler
|
||||
which sends a `Buffer` as a response.
|
||||
|
||||
### `protocol.interceptHttpProtocol(scheme, handler)`
|
||||
### `protocol.interceptHttpProtocol(scheme, handler)` _Deprecated_
|
||||
|
||||
* `scheme` string
|
||||
* `handler` Function
|
||||
@@ -300,7 +364,7 @@ Returns `boolean` - Whether the protocol was successfully intercepted
|
||||
Intercepts `scheme` protocol and uses `handler` as the protocol's new handler
|
||||
which sends a new HTTP request as a response.
|
||||
|
||||
### `protocol.interceptStreamProtocol(scheme, handler)`
|
||||
### `protocol.interceptStreamProtocol(scheme, handler)` _Deprecated_
|
||||
|
||||
* `scheme` string
|
||||
* `handler` Function
|
||||
@@ -313,7 +377,7 @@ Returns `boolean` - Whether the protocol was successfully intercepted
|
||||
Same as `protocol.registerStreamProtocol`, except that it replaces an existing
|
||||
protocol handler.
|
||||
|
||||
### `protocol.uninterceptProtocol(scheme)`
|
||||
### `protocol.uninterceptProtocol(scheme)` _Deprecated_
|
||||
|
||||
* `scheme` string
|
||||
|
||||
@@ -321,7 +385,7 @@ Returns `boolean` - Whether the protocol was successfully unintercepted
|
||||
|
||||
Remove the interceptor installed for `scheme` and restore its original handler.
|
||||
|
||||
### `protocol.isProtocolIntercepted(scheme)`
|
||||
### `protocol.isProtocolIntercepted(scheme)` _Deprecated_
|
||||
|
||||
* `scheme` string
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ The `pushNotification` module has the following methods:
|
||||
|
||||
Returns `Promise<string>`
|
||||
|
||||
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.
|
||||
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.
|
||||
See: https://developer.apple.com/documentation/appkit/nsapplication/1428476-registerforremotenotificationtyp?language=objc
|
||||
|
||||
### `pushNotifications.unregisterForAPNSNotifications()` _macOS_
|
||||
|
||||
@@ -38,3 +38,28 @@ Returns `string` - the decrypted string. Decrypts the encrypted buffer
|
||||
obtained with `safeStorage.encryptString` back into a string.
|
||||
|
||||
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.
|
||||
|
||||
@@ -13,7 +13,7 @@ property of [`WebContents`](web-contents.md), or from the `session` module.
|
||||
const { BrowserWindow } = require('electron')
|
||||
|
||||
const win = new BrowserWindow({ width: 800, height: 600 })
|
||||
win.loadURL('http://github.com')
|
||||
win.loadURL('https://github.com')
|
||||
|
||||
const ses = win.webContents.session
|
||||
console.log(ses.getUserAgent())
|
||||
@@ -42,6 +42,22 @@ To create a `Session` with `options`, you have to ensure the `Session` with the
|
||||
`partition` has never been used before. There is no way to change the `options`
|
||||
of an existing `Session` object.
|
||||
|
||||
### `session.fromPath(path[, options])`
|
||||
|
||||
* `path` string
|
||||
* `options` Object (optional)
|
||||
* `cache` boolean - Whether to enable cache.
|
||||
|
||||
Returns `Session` - A session instance from the absolute path as specified by the `path`
|
||||
string. When there is an existing `Session` with the same absolute path, it
|
||||
will be returned; otherwise a new `Session` instance will be created with `options`. The
|
||||
call will throw an error if the path is not an absolute path. Additionally, an error will
|
||||
be thrown if an empty string is provided.
|
||||
|
||||
To create a `Session` with `options`, you have to ensure the `Session` with the
|
||||
`path` has never been used before. There is no way to change the `options`
|
||||
of an existing `Session` object.
|
||||
|
||||
## Properties
|
||||
|
||||
The `session` module has the following properties:
|
||||
@@ -82,12 +98,12 @@ Emitted when Electron is about to download `item` in `webContents`.
|
||||
Calling `event.preventDefault()` will cancel the download and `item` will not be
|
||||
available from next tick of the process.
|
||||
|
||||
```javascript
|
||||
```javascript @ts-expect-error=[4]
|
||||
const { session } = require('electron')
|
||||
session.defaultSession.on('will-download', (event, item, webContents) => {
|
||||
event.preventDefault()
|
||||
require('got')(item.getURL()).then((response) => {
|
||||
require('fs').writeFileSync('/somewhere', response.body)
|
||||
require('node:fs').writeFileSync('/somewhere', response.body)
|
||||
})
|
||||
})
|
||||
```
|
||||
@@ -198,7 +214,7 @@ cancel the request. Additionally, permissioning on `navigator.hid` can
|
||||
be further managed by using [`ses.setPermissionCheckHandler(handler)`](#sessetpermissioncheckhandlerhandler)
|
||||
and [`ses.setDevicePermissionHandler(handler)`](#sessetdevicepermissionhandlerhandler).
|
||||
|
||||
```javascript
|
||||
```javascript @ts-type={fetchGrantedDevices:()=>(Array<Electron.DevicePermissionHandlerHandlerDetails['device']>)}
|
||||
const { app, BrowserWindow } = require('electron')
|
||||
|
||||
let win = null
|
||||
@@ -237,7 +253,7 @@ app.whenReady().then(() => {
|
||||
win.webContents.session.on('select-hid-device', (event, details, callback) => {
|
||||
event.preventDefault()
|
||||
const selectedDevice = details.deviceList.find((device) => {
|
||||
return device.vendorId === '9025' && device.productId === '67'
|
||||
return device.vendorId === 9025 && device.productId === 67
|
||||
})
|
||||
callback(selectedDevice?.deviceId)
|
||||
})
|
||||
@@ -304,7 +320,7 @@ cancel the request. Additionally, permissioning on `navigator.serial` can
|
||||
be managed by using [ses.setPermissionCheckHandler(handler)](#sessetpermissioncheckhandlerhandler)
|
||||
with the `serial` permission.
|
||||
|
||||
```javascript
|
||||
```javascript @ts-type={fetchGrantedDevices:()=>(Array<Electron.DevicePermissionHandlerHandlerDetails['device']>)}
|
||||
const { app, BrowserWindow } = require('electron')
|
||||
|
||||
let win = null
|
||||
@@ -447,7 +463,7 @@ cancel the request. Additionally, permissioning on `navigator.usb` can
|
||||
be further managed by using [`ses.setPermissionCheckHandler(handler)`](#sessetpermissioncheckhandlerhandler)
|
||||
and [`ses.setDevicePermissionHandler(handler)`](#sessetdevicepermissionhandlerhandler).
|
||||
|
||||
```javascript
|
||||
```javascript @ts-type={fetchGrantedDevices:()=>(Array<Electron.DevicePermissionHandlerHandlerDetails['device']>)} @ts-type={updateGrantedDevices:(devices:Array<Electron.DevicePermissionHandlerHandlerDetails['device']>)=>void}
|
||||
const { app, BrowserWindow } = require('electron')
|
||||
|
||||
let win = null
|
||||
@@ -486,7 +502,7 @@ app.whenReady().then(() => {
|
||||
win.webContents.session.on('select-usb-device', (event, details, callback) => {
|
||||
event.preventDefault()
|
||||
const selectedDevice = details.deviceList.find((device) => {
|
||||
return device.vendorId === '9025' && device.productId === '67'
|
||||
return device.vendorId === 9025 && device.productId === 67
|
||||
})
|
||||
if (selectedDevice) {
|
||||
// Optionally, add this to the persisted devices (updateGrantedDevices needs to be implemented by developer to persist permissions)
|
||||
@@ -503,9 +519,8 @@ app.whenReady().then(() => {
|
||||
Returns:
|
||||
|
||||
* `event` Event
|
||||
* `details` Object
|
||||
* `device` [USBDevice](structures/usb-device.md)
|
||||
* `frame` [WebFrameMain](web-frame-main.md)
|
||||
* `device` [USBDevice](structures/usb-device.md)
|
||||
* `webContents` [WebContents](web-contents.md)
|
||||
|
||||
Emitted after `navigator.usb.requestDevice` has been called and
|
||||
`select-usb-device` has fired if a new device becomes available before
|
||||
@@ -518,9 +533,8 @@ with the newly added device.
|
||||
Returns:
|
||||
|
||||
* `event` Event
|
||||
* `details` Object
|
||||
* `device` [USBDevice](structures/usb-device.md)
|
||||
* `frame` [WebFrameMain](web-frame-main.md)
|
||||
* `device` [USBDevice](structures/usb-device.md)
|
||||
* `webContents` [WebContents](web-contents.md)
|
||||
|
||||
Emitted after `navigator.usb.requestDevice` has been called and
|
||||
`select-usb-device` has fired if a device has been removed before the callback
|
||||
@@ -534,7 +548,7 @@ Returns:
|
||||
|
||||
* `event` Event
|
||||
* `details` Object
|
||||
* `device` [USBDevice[]](structures/usb-device.md)
|
||||
* `device` [USBDevice](structures/usb-device.md)
|
||||
* `origin` string (optional) - The origin that the device has been revoked from.
|
||||
|
||||
Emitted after `USBDevice.forget()` has been called. This event can be used
|
||||
@@ -560,11 +574,11 @@ Clears the session’s HTTP cache.
|
||||
* `options` Object (optional)
|
||||
* `origin` string (optional) - Should follow `window.location.origin`’s representation
|
||||
`scheme://host:port`.
|
||||
* `storages` string[] (optional) - The types of storages to clear, can contain:
|
||||
* `storages` string[] (optional) - The types of storages to clear, can be
|
||||
`cookies`, `filesystem`, `indexdb`, `localstorage`,
|
||||
`shadercache`, `websql`, `serviceworkers`, `cachestorage`. If not
|
||||
specified, clear all storage types.
|
||||
* `quotas` string[] (optional) - The types of quotas to clear, can contain:
|
||||
* `quotas` string[] (optional) - The types of quotas to clear, can be
|
||||
`temporary`, `syncable`. If not specified, clear all quotas.
|
||||
|
||||
Returns `Promise<void>` - resolves when the storage data has been cleared.
|
||||
@@ -644,8 +658,8 @@ The `proxyBypassRules` is a comma separated list of rules described below:
|
||||
Match all hostnames that match the pattern HOSTNAME_PATTERN.
|
||||
|
||||
Examples:
|
||||
"foobar.com", "*foobar.com", "*.foobar.com", "*foobar.com:99",
|
||||
"https://x.*.y.com:99"
|
||||
"foobar.com", "\*foobar.com", "\*.foobar.com", "\*foobar.com:99",
|
||||
"https://x.\*.y.com:99"
|
||||
|
||||
* `"." HOSTNAME_SUFFIX_PATTERN [ ":" PORT ]`
|
||||
|
||||
@@ -674,6 +688,41 @@ The `proxyBypassRules` is a comma separated list of rules described below:
|
||||
Match local addresses. The meaning of `<local>` is whether the
|
||||
host matches one of: "127.0.0.1", "::1", "localhost".
|
||||
|
||||
#### `ses.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`.
|
||||
|
||||
#### `ses.resolveProxy(url)`
|
||||
|
||||
* `url` URL
|
||||
@@ -706,15 +755,17 @@ Sets download saving directory. By default, the download directory will be the
|
||||
Emulates network with the given configuration for the `session`.
|
||||
|
||||
```javascript
|
||||
const win = new BrowserWindow()
|
||||
|
||||
// To emulate a GPRS connection with 50kbps throughput and 500 ms latency.
|
||||
window.webContents.session.enableNetworkEmulation({
|
||||
win.webContents.session.enableNetworkEmulation({
|
||||
latency: 500,
|
||||
downloadThroughput: 6400,
|
||||
uploadThroughput: 6400
|
||||
})
|
||||
|
||||
// To emulate a network outage.
|
||||
window.webContents.session.enableNetworkEmulation({ offline: true })
|
||||
win.webContents.session.enableNetworkEmulation({ offline: true })
|
||||
```
|
||||
|
||||
#### `ses.preconnect(options)`
|
||||
@@ -731,6 +782,61 @@ Returns `Promise<void>` - Resolves when all connections are closed.
|
||||
|
||||
**Note:** It will terminate / fail all requests currently in flight.
|
||||
|
||||
#### `ses.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) (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.
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
See also [`net.fetch()`](net.md#netfetchinput-init), a convenience method which
|
||||
issues requests from the [default session](#sessiondefaultsession).
|
||||
|
||||
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 })
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
#### `ses.disableNetworkEmulation()`
|
||||
|
||||
Disables any network emulation already active for the `session`. Resets to
|
||||
@@ -785,18 +891,19 @@ win.webContents.session.setCertificateVerifyProc((request, callback) => {
|
||||
* `permission` string - The type of requested permission.
|
||||
* `clipboard-read` - Request access to read from the clipboard.
|
||||
* `clipboard-sanitized-write` - Request access to write to the clipboard.
|
||||
* `display-capture` - Request access to capture the screen via the [Screen Capture API](https://developer.mozilla.org/en-US/docs/Web/API/Screen_Capture_API).
|
||||
* `fullscreen` - Request control of the app's fullscreen state via the [Fullscreen API](https://developer.mozilla.org/en-US/docs/Web/API/Fullscreen_API).
|
||||
* `geolocation` - Request access to the user's location via the [Geolocation API](https://developer.mozilla.org/en-US/docs/Web/API/Geolocation_API)
|
||||
* `idle-detection` - Request access to the user's idle state via the [IdleDetector API](https://developer.mozilla.org/en-US/docs/Web/API/IdleDetector).
|
||||
* `media` - Request access to media devices such as camera, microphone and speakers.
|
||||
* `display-capture` - Request access to capture the screen.
|
||||
* `mediaKeySystem` - Request access to DRM protected content.
|
||||
* `geolocation` - Request access to user's current location.
|
||||
* `notifications` - Request notification creation and the ability to display them in the user's system tray.
|
||||
* `midi` - Request MIDI access in the `webmidi` API.
|
||||
* `midiSysex` - Request the use of system exclusive messages in the `webmidi` API.
|
||||
* `pointerLock` - Request to directly interpret mouse movements as an input method. Click [here](https://developer.mozilla.org/en-US/docs/Web/API/Pointer_Lock_API) to know more. These requests always appear to originate from the main frame.
|
||||
* `fullscreen` - Request for the app to enter fullscreen mode.
|
||||
* `midi` - Request MIDI access in the [Web MIDI API](https://developer.mozilla.org/en-US/docs/Web/API/Web_MIDI_API).
|
||||
* `midiSysex` - Request the use of system exclusive messages in the [Web MIDI API](https://developer.mozilla.org/en-US/docs/Web/API/Web_MIDI_API).
|
||||
* `notifications` - Request notification creation and the ability to display them in the user's system tray using the [Notifications API](https://developer.mozilla.org/en-US/docs/Web/API/notification)
|
||||
* `pointerLock` - Request to directly interpret mouse movements as an input method via the [Pointer Lock API](https://developer.mozilla.org/en-US/docs/Web/API/Pointer_Lock_API). These requests always appear to originate from the main frame.
|
||||
* `openExternal` - Request to open links in external applications.
|
||||
* `window-management` - Request access to enumerate screens using the [`getScreenDetails`](https://developer.chrome.com/en/articles/multi-screen-window-placement/) API.
|
||||
* `unknown` - An unrecognized permission request
|
||||
* `unknown` - An unrecognized permission request.
|
||||
* `callback` Function
|
||||
* `permissionGranted` boolean - Allow or deny the permission.
|
||||
* `details` Object - Some properties are only available on certain permission types.
|
||||
@@ -828,7 +935,22 @@ session.fromPartition('some-partition').setPermissionRequestHandler((webContents
|
||||
|
||||
* `handler` Function\<boolean> | null
|
||||
* `webContents` ([WebContents](web-contents.md) | null) - WebContents checking the permission. Please note that if the request comes from a subframe you should use `requestingUrl` to check the request origin. All cross origin sub frames making permission checks will pass a `null` webContents to this handler, while certain other permission checks such as `notifications` checks will always pass `null`. You should use `embeddingOrigin` and `requestingOrigin` to determine what origin the owning frame and the requesting frame are on respectively.
|
||||
* `permission` string - Type of permission check. Valid values are `midiSysex`, `notifications`, `geolocation`, `media`,`mediaKeySystem`,`midi`, `pointerLock`, `fullscreen`, `openExternal`, `hid`, `serial`, or `usb`.
|
||||
* `permission` string - Type of permission check.
|
||||
* `clipboard-read` - Request access to read from the clipboard.
|
||||
* `clipboard-sanitized-write` - Request access to write to the clipboard.
|
||||
* `geolocation` - Access the user's geolocation data via the [Geolocation API](https://developer.mozilla.org/en-US/docs/Web/API/Geolocation_API)
|
||||
* `fullscreen` - Control of the app's fullscreen state via the [Fullscreen API](https://developer.mozilla.org/en-US/docs/Web/API/Fullscreen_API).
|
||||
* `hid` - Access the HID protocol to manipulate HID devices via the [WebHID API](https://developer.mozilla.org/en-US/docs/Web/API/WebHID_API).
|
||||
* `idle-detection` - Access the user's idle state via the [IdleDetector API](https://developer.mozilla.org/en-US/docs/Web/API/IdleDetector).
|
||||
* `media` - Access to media devices such as camera, microphone and speakers.
|
||||
* `mediaKeySystem` - Access to DRM protected content.
|
||||
* `midi` - Enable MIDI access in the [Web MIDI API](https://developer.mozilla.org/en-US/docs/Web/API/Web_MIDI_API).
|
||||
* `midiSysex` - Use system exclusive messages in the [Web MIDI API](https://developer.mozilla.org/en-US/docs/Web/API/Web_MIDI_API).
|
||||
* `notifications` - Configure and display desktop notifications to the user with the [Notifications API](https://developer.mozilla.org/en-US/docs/Web/API/notification).
|
||||
* `openExternal` - Open links in external applications.
|
||||
* `pointerLock` - Directly interpret mouse movements as an input method via the [Pointer Lock API](https://developer.mozilla.org/en-US/docs/Web/API/Pointer_Lock_API). These requests always appear to originate from the main frame.
|
||||
* `serial` - Read from and write to serial devices with the [Web Serial API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Serial_API).
|
||||
* `usb` - Expose non-standard Universal Serial Bus (USB) compatible devices services to the web with the [WebUSB API](https://developer.mozilla.org/en-US/docs/Web/API/WebUSB_API).
|
||||
* `requestingOrigin` string - The origin URL of the permission check
|
||||
* `details` Object - Some properties are only available on certain permission types.
|
||||
* `embeddingOrigin` string (optional) - The origin of the frame embedding the frame that made the permission check. Only set for cross-origin sub frames making permission checks.
|
||||
@@ -879,6 +1001,10 @@ session.fromPartition('some-partition').setPermissionCheckHandler((webContents,
|
||||
Specifying a loopback device will capture system audio, and is
|
||||
currently only supported on Windows. If a WebFrameMain is specified,
|
||||
will capture audio from that frame.
|
||||
* `enableLocalEcho` Boolean (optional) - If `audio` is a [WebFrameMain](web-frame-main.md)
|
||||
and this is set to `true`, then local playback of audio will not be muted (e.g. using `MediaRecorder`
|
||||
to record `WebFrameMain` with this flag set to `true` will allow audio to pass through to the speakers
|
||||
while recording). Default is `false`.
|
||||
|
||||
This handler will be called when web content requests access to display media
|
||||
via the `navigator.mediaDevices.getDisplayMedia` API. Use the
|
||||
@@ -916,7 +1042,7 @@ Passing `null` instead of a function resets the handler to its default state.
|
||||
* `details` Object
|
||||
* `deviceType` string - The type of device that permission is being requested on, can be `hid`, `serial`, or `usb`.
|
||||
* `origin` string - The origin URL of the device permission check.
|
||||
* `device` [HIDDevice](structures/hid-device.md) | [SerialPort](structures/serial-port.md)- the device that permission is being requested for.
|
||||
* `device` [HIDDevice](structures/hid-device.md) | [SerialPort](structures/serial-port.md) | [USBDevice](structures/usb-device.md) - the device that permission is being requested for.
|
||||
|
||||
Sets the handler which can be used to respond to device permission checks for the `session`.
|
||||
Returning `true` will allow the device to be permitted and `false` will reject it.
|
||||
@@ -928,7 +1054,7 @@ Additionally, the default behavior of Electron is to store granted device permis
|
||||
If longer term storage is needed, a developer can store granted device
|
||||
permissions (eg when handling the `select-hid-device` event) and then read from that storage with `setDevicePermissionHandler`.
|
||||
|
||||
```javascript
|
||||
```javascript @ts-type={fetchGrantedDevices:()=>(Array<Electron.DevicePermissionHandlerHandlerDetails['device']>)}
|
||||
const { app, BrowserWindow } = require('electron')
|
||||
|
||||
let win = null
|
||||
@@ -976,9 +1102,58 @@ app.whenReady().then(() => {
|
||||
win.webContents.session.on('select-hid-device', (event, details, callback) => {
|
||||
event.preventDefault()
|
||||
const selectedDevice = details.deviceList.find((device) => {
|
||||
return device.vendorId === '9025' && device.productId === '67'
|
||||
return device.vendorId === 9025 && device.productId === 67
|
||||
})
|
||||
callback(selectedDevice?.deviceId)
|
||||
})
|
||||
})
|
||||
```
|
||||
|
||||
#### `ses.setUSBProtectedClassesHandler(handler)`
|
||||
|
||||
* `handler` Function\<string[]> | null
|
||||
* `details` Object
|
||||
* `protectedClasses` string[] - The current list of protected USB classes. Possible class values include:
|
||||
* `audio`
|
||||
* `audio-video`
|
||||
* `hid`
|
||||
* `mass-storage`
|
||||
* `smart-card`
|
||||
* `video`
|
||||
* `wireless`
|
||||
|
||||
Sets the handler which can be used to override which [USB classes are protected](https://wicg.github.io/webusb/#usbinterface-interface).
|
||||
The return value for the handler is a string array of USB classes which should be considered protected (eg not available in the renderer). Valid values for the array are:
|
||||
|
||||
* `audio`
|
||||
* `audio-video`
|
||||
* `hid`
|
||||
* `mass-storage`
|
||||
* `smart-card`
|
||||
* `video`
|
||||
* `wireless`
|
||||
|
||||
Returning an empty string array from the handler will allow all USB classes; returning the passed in array will maintain the default list of protected USB classes (this is also the default behavior if a handler is not defined).
|
||||
To clear the handler, call `setUSBProtectedClassesHandler(null)`.
|
||||
|
||||
```javascript
|
||||
const { app, BrowserWindow } = require('electron')
|
||||
|
||||
let win = null
|
||||
|
||||
app.whenReady().then(() => {
|
||||
win = new BrowserWindow()
|
||||
|
||||
win.webContents.session.setUSBProtectedClassesHandler((details) => {
|
||||
// Allow all classes:
|
||||
// return []
|
||||
// Keep the current set of protected classes:
|
||||
// return details.protectedClasses
|
||||
// Selectively remove classes:
|
||||
return details.protectedClasses.filter((usbClass) => {
|
||||
// Exclude classes except for audio classes
|
||||
return usbClass.indexOf('audio') === -1
|
||||
})
|
||||
callback(selectedPort?.deviceId)
|
||||
})
|
||||
})
|
||||
```
|
||||
@@ -1017,32 +1192,32 @@ macOS does not require a handler because macOS handles the pairing
|
||||
automatically. To clear the handler, call `setBluetoothPairingHandler(null)`.
|
||||
|
||||
```javascript
|
||||
|
||||
const { app, BrowserWindow, ipcMain, session } = require('electron')
|
||||
|
||||
let bluetoothPinCallback = null
|
||||
const { app, BrowserWindow, session } = require('electron')
|
||||
const path = require('node:path')
|
||||
|
||||
function createWindow () {
|
||||
let bluetoothPinCallback = null
|
||||
|
||||
const mainWindow = new BrowserWindow({
|
||||
webPreferences: {
|
||||
preload: path.join(__dirname, 'preload.js')
|
||||
}
|
||||
})
|
||||
|
||||
mainWindow.webContents.session.setBluetoothPairingHandler((details, callback) => {
|
||||
bluetoothPinCallback = callback
|
||||
// Send a IPC message to the renderer to prompt the user to confirm the pairing.
|
||||
// Note that this will require logic in the renderer to handle this message and
|
||||
// display a prompt to the user.
|
||||
mainWindow.webContents.send('bluetooth-pairing-request', details)
|
||||
})
|
||||
|
||||
// Listen for an IPC message from the renderer to get the response for the Bluetooth pairing.
|
||||
mainWindow.webContents.ipc.on('bluetooth-pairing-response', (event, response) => {
|
||||
bluetoothPinCallback(response)
|
||||
})
|
||||
}
|
||||
|
||||
// Listen for an IPC message from the renderer to get the response for the Bluetooth pairing.
|
||||
ipcMain.on('bluetooth-pairing-response', (event, response) => {
|
||||
bluetoothPinCallback(response)
|
||||
})
|
||||
|
||||
mainWindow.webContents.session.setBluetoothPairingHandler((details, callback) => {
|
||||
bluetoothPinCallback = callback
|
||||
// Send a IPC message to the renderer to prompt the user to confirm the pairing.
|
||||
// Note that this will require logic in the renderer to handle this message and
|
||||
// display a prompt to the user.
|
||||
mainWindow.webContents.send('bluetooth-pairing-request', details)
|
||||
})
|
||||
|
||||
app.whenReady().then(() => {
|
||||
createWindow()
|
||||
})
|
||||
@@ -1125,16 +1300,18 @@ reused for new connections.
|
||||
|
||||
Returns `Promise<Buffer>` - resolves with blob data.
|
||||
|
||||
#### `ses.downloadURL(url)`
|
||||
#### `ses.downloadURL(url[, options])`
|
||||
|
||||
* `url` string
|
||||
* `options` Object (optional)
|
||||
* `headers` Record<string, string> (optional) - HTTP request headers.
|
||||
|
||||
Initiates a download of the resource at `url`.
|
||||
The API will generate a [DownloadItem](download-item.md) that can be accessed
|
||||
with the [will-download](#event-will-download) event.
|
||||
|
||||
**Note:** This does not perform any security checks that relate to a page's origin,
|
||||
unlike [`webContents.downloadURL`](web-contents.md#contentsdownloadurlurl).
|
||||
unlike [`webContents.downloadURL`](web-contents.md#contentsdownloadurlurl-options).
|
||||
|
||||
#### `ses.createInterruptedDownload(options)`
|
||||
|
||||
@@ -1280,9 +1457,9 @@ extension to be loaded.
|
||||
|
||||
```js
|
||||
const { app, session } = require('electron')
|
||||
const path = require('path')
|
||||
const path = require('node:path')
|
||||
|
||||
app.on('ready', async () => {
|
||||
app.whenReady().then(async () => {
|
||||
await session.defaultSession.loadExtension(
|
||||
path.join(__dirname, 'react-devtools'),
|
||||
// allowFileAccess is required to load the devtools extension on file:// URLs.
|
||||
@@ -1314,7 +1491,7 @@ is emitted.
|
||||
|
||||
* `extensionId` string - ID of extension to query
|
||||
|
||||
Returns `Extension` | `null` - The loaded extension with the given ID.
|
||||
Returns `Extension | null` - The loaded extension with the given ID.
|
||||
|
||||
**Note:** This API cannot be called before the `ready` event of the `app` module
|
||||
is emitted.
|
||||
@@ -1367,13 +1544,13 @@ A [`Protocol`](protocol.md) object for this session.
|
||||
|
||||
```javascript
|
||||
const { app, session } = require('electron')
|
||||
const path = require('path')
|
||||
const path = require('node:path')
|
||||
|
||||
app.whenReady().then(() => {
|
||||
const protocol = session.fromPartition('some-partition').protocol
|
||||
if (!protocol.registerFileProtocol('atom', (request, callback) => {
|
||||
const url = request.url.substr(7)
|
||||
callback({ path: path.normalize(`${__dirname}/${url}`) })
|
||||
callback({ path: path.normalize(path.join(__dirname, url)) })
|
||||
})) {
|
||||
console.error('Failed to register protocol')
|
||||
}
|
||||
|
||||
@@ -40,6 +40,8 @@ Open the given file in the desktop's default manner.
|
||||
* `options` Object (optional)
|
||||
* `activate` boolean (optional) _macOS_ - `true` to bring the opened application to the foreground. The default is `true`.
|
||||
* `workingDirectory` string (optional) _Windows_ - The working directory.
|
||||
* `logUsage` boolean (optional) _Windows_ - Indicates a user initiated launch that enables tracking of frequently used programs and other behaviors.
|
||||
The default is `false`.
|
||||
|
||||
Returns `Promise<void>`
|
||||
|
||||
|
||||
161
docs/api/structures/browser-window-options.md
Normal file
161
docs/api/structures/browser-window-options.md
Normal file
@@ -0,0 +1,161 @@
|
||||
# BrowserWindowConstructorOptions Object
|
||||
|
||||
* `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](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.
|
||||
* `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`, `titlebar`, `selection`,
|
||||
`menu`, `popover`, `sidebar`, `header`, `sheet`, `window`, `hud`, `fullscreen-ui`,
|
||||
`tooltip`, `content`, `under-window`, or `under-page`.
|
||||
* `backgroundMaterial` string (optional) _Windows_ - Set the window's
|
||||
system-drawn background material, including behind the non-client area.
|
||||
Can be `auto`, `none`, `mica`, `acrylic` or `tabbed`. See [win.setBackgroundMaterial](../browser-window.md#winsetbackgroundmaterialmaterial-windows) for more information.
|
||||
* `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. 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` [WebPreferences](web-preferences.md?inline) (optional) - Settings of web page's features.
|
||||
* `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`.
|
||||
* The `desktop` type places the window at the desktop background window level
|
||||
(kCGDesktopWindowLevel - 1). However, note that a desktop window will not
|
||||
receive focus, keyboard, or mouse events. You can still use globalShortcut to
|
||||
receive input sparingly.
|
||||
* The `dock` type creates a dock-like window behavior.
|
||||
* The `toolbar` type creates a window with a toolbar appearance.
|
||||
* The `splash` type behaves in a specific way. It is not
|
||||
draggable, even if the CSS styling of the window's body contains
|
||||
-webkit-app-region: drag. This type is commonly used for splash screens.
|
||||
* The `notification` type creates a window that behaves like a system 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`.
|
||||
|
||||
[overlay-css-env-vars]: https://github.com/WICG/window-controls-overlay/blob/main/explainer.md#css-environment-variables
|
||||
[overlay-javascript-apis]: https://github.com/WICG/window-controls-overlay/blob/main/explainer.md#javascript-apis
|
||||
@@ -1,3 +0,0 @@
|
||||
# Event Object extends `GlobalEvent`
|
||||
|
||||
* `preventDefault` VoidFunction
|
||||
@@ -3,9 +3,9 @@
|
||||
* `processId` Integer - The internal ID of the renderer process that sent this message
|
||||
* `frameId` Integer - The ID of the renderer frame that sent this message
|
||||
* `returnValue` any - Set this to the value to be returned in a synchronous message
|
||||
* `sender` WebContents - Returns the `webContents` that sent the message
|
||||
* `senderFrame` WebFrameMain _Readonly_ - The frame that sent this message
|
||||
* `ports` MessagePortMain[] - A list of MessagePorts that were transferred with this message
|
||||
* `sender` [WebContents](../web-contents.md) - Returns the `webContents` that sent the message
|
||||
* `senderFrame` [WebFrameMain](../web-frame-main.md) _Readonly_ - The frame that sent this message
|
||||
* `ports` [MessagePortMain](../message-port-main.md)[] - A list of MessagePorts that were transferred with this message
|
||||
* `reply` Function - A function that will send an IPC message to the renderer frame that sent the original message that you are currently handling. You should use this method to "reply" to the sent message in order to guarantee the reply will go to the correct process and frame.
|
||||
* `channel` string
|
||||
* `...args` any[]
|
||||
|
||||
@@ -2,5 +2,5 @@
|
||||
|
||||
* `processId` Integer - The internal ID of the renderer process that sent this message
|
||||
* `frameId` Integer - The ID of the renderer frame that sent this message
|
||||
* `sender` WebContents - Returns the `webContents` that sent the message
|
||||
* `senderFrame` WebFrameMain _Readonly_ - The frame that sent this message
|
||||
* `sender` [WebContents](../web-contents.md) - Returns the `webContents` that sent the message
|
||||
* `senderFrame` [WebFrameMain](../web-frame-main.md) _Readonly_ - The frame that sent this message
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
# IpcRendererEvent Object extends `Event`
|
||||
|
||||
* `sender` IpcRenderer - The `IpcRenderer` instance that emitted the event originally
|
||||
* `senderId` Integer - The `webContents.id` that sent the message, you can call `event.sender.sendTo(event.senderId, ...)` to reply to the message, see [ipcRenderer.sendTo][ipc-renderer-sendto] for more information. This only applies to messages sent from a different renderer. Messages sent directly from the main process set `event.senderId` to `0`.
|
||||
* `ports` MessagePort[] - A list of MessagePorts that were transferred with this message
|
||||
* `sender` [IpcRenderer](../ipc-renderer.md) - The `IpcRenderer` instance that emitted the event originally
|
||||
* `ports` [MessagePort][][] - A list of MessagePorts that were transferred with this message
|
||||
|
||||
[ipc-renderer-sendto]: ../ipc-renderer.md#ipcrenderersendtowebcontentsid-channel-args
|
||||
[MessagePort]: https://developer.mozilla.org/en-US/docs/Web/API/MessagePort
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* `isDefault` boolean - whether or not a given printer is set as the default printer on the OS.
|
||||
* `options` Object - an object containing a variable number of platform-specific printer information.
|
||||
|
||||
The number represented by `status` means different things on different platforms: on Windows its potential values can be found [here](https://docs.microsoft.com/en-us/windows/win32/printdocs/printer-info-2), and on Linux and macOS they can be found [here](https://www.cups.org/doc/cupspm.html).
|
||||
The number represented by `status` means different things on different platforms: on Windows its potential values can be found [here](https://learn.microsoft.com/en-us/windows/win32/printdocs/printer-info-2), and on Linux and macOS they can be found [here](https://www.cups.org/doc/cupspm.html).
|
||||
|
||||
## Example
|
||||
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
* `productIdentifier` string - The string that identifies the product to the Apple App Store.
|
||||
* `localizedDescription` string - A description of the product.
|
||||
* `localizedTitle` string - The name of the product.
|
||||
* `contentVersion` string - A string that identifies the version of the content.
|
||||
* `contentLengths` number[] - The total size of the content, in bytes.
|
||||
* `price` number - The cost of the product in the local currency.
|
||||
* `formattedPrice` string - The locale formatted price of the product.
|
||||
* `currencyCode` string - 3 character code presenting a product's currency based on the ISO 4217 standard.
|
||||
|
||||
13
docs/api/structures/render-process-gone-details.md
Normal file
13
docs/api/structures/render-process-gone-details.md
Normal file
@@ -0,0 +1,13 @@
|
||||
# RenderProcessGoneDetails 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.
|
||||
7
docs/api/structures/resolved-endpoint.md
Normal file
7
docs/api/structures/resolved-endpoint.md
Normal file
@@ -0,0 +1,7 @@
|
||||
# ResolvedEndpoint Object
|
||||
|
||||
* `address` string
|
||||
* `family` string - One of the following:
|
||||
* `ipv4` - Corresponds to `AF_INET`
|
||||
* `ipv6` - Corresponds to `AF_INET6`
|
||||
* `unspec` - Corresponds to `AF_UNSPEC`
|
||||
3
docs/api/structures/resolved-host.md
Normal file
3
docs/api/structures/resolved-host.md
Normal file
@@ -0,0 +1,3 @@
|
||||
# ResolvedHost Object
|
||||
|
||||
* `endpoints` [ResolvedEndpoint[]](resolved-endpoint.md) - resolved DNS entries for the hostname
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
* `portId` string - Unique identifier for the port.
|
||||
* `portName` string - Name of the port.
|
||||
* `displayName` string - A string suitable for display to the user for describing this device.
|
||||
* `vendorId` string - Optional USB vendor ID.
|
||||
* `productId` string - Optional USB product ID.
|
||||
* `serialNumber` string - The USB device serial number.
|
||||
* `usbDriverName` string (optional) - Represents a single serial port on macOS can be enumerated by multiple drivers.
|
||||
* `deviceInstanceId` string (optional) - A stable identifier on Windows that can be used for device permissions.
|
||||
* `displayName` string (optional) - A string suitable for display to the user for describing this device.
|
||||
* `vendorId` string (optional) - The USB vendor ID.
|
||||
* `productId` string (optional) - The USB product ID.
|
||||
* `serialNumber` string (optional) - The USB device serial number.
|
||||
* `usbDriverName` string (optional) _macOS_ - Represents a single serial port on macOS can be enumerated by multiple drivers.
|
||||
* `deviceInstanceId` string (optional) _Windows_ - A stable identifier on Windows that can be used for device permissions.
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
* `type` 'file' - `file`.
|
||||
* `filePath` string - Path of file to be uploaded.
|
||||
* `offset` Integer - Defaults to `0`.
|
||||
* `length` Integer - Number of bytes to read from `offset`.
|
||||
* `offset` Integer (optional) - Defaults to `0`.
|
||||
* `length` Integer (optional) - Number of bytes to read from `offset`.
|
||||
Defaults to `0`.
|
||||
* `modificationTime` Double - Last Modification time in
|
||||
number of seconds since the UNIX epoch.
|
||||
* `modificationTime` Double (optional) - Last Modification time in
|
||||
number of seconds since the UNIX epoch. Defaults to `0`.
|
||||
|
||||
144
docs/api/structures/web-preferences.md
Normal file
144
docs/api/structures/web-preferences.md
Normal file
@@ -0,0 +1,144 @@
|
||||
# WebPreferences Object
|
||||
|
||||
* `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`.
|
||||
* `math` string (optional) - Defaults to `Latin Modern Math`.
|
||||
* `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](../browser-window.md#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`.
|
||||
|
||||
[chrome-content-scripts]: https://developer.chrome.com/extensions/content_scripts#execution-environment
|
||||
[runtime-enabled-features]: https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/platform/runtime_enabled_features.json5
|
||||
@@ -1,3 +1,4 @@
|
||||
# WebRequestFilter Object
|
||||
|
||||
* `urls` string[] - Array of [URL patterns](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Match_patterns) that will be used to filter out the requests that do not match the URL patterns.
|
||||
* `types` String[] (optional) - Array of types that will be used to filter out the requests that do not match the types. When not specified, all types will be matched. Can be `mainFrame`, `subFrame`, `stylesheet`, `script`, `image`, `font`, `object`, `xhr`, `ping`, `cspReport`, `media` or `webSocket`.
|
||||
|
||||
@@ -1,93 +0,0 @@
|
||||
# Synopsis
|
||||
|
||||
> How to use Node.js and Electron APIs.
|
||||
|
||||
All of [Node.js's built-in modules](https://nodejs.org/api/) are available in
|
||||
Electron and third-party node modules also fully supported as well (including
|
||||
the [native modules](../tutorial/using-native-node-modules.md)).
|
||||
|
||||
Electron also provides some extra built-in modules for developing native
|
||||
desktop applications. Some modules are only available in the main process, some
|
||||
are only available in the renderer process (web page), and some can be used in
|
||||
either process type.
|
||||
|
||||
The basic rule is: if a module is [GUI][gui] or low-level system related, then
|
||||
it should be only available in the main process. You need to be familiar with
|
||||
the concept of main process vs. renderer process
|
||||
scripts to be able to use those modules.
|
||||
|
||||
The main process script is like a normal Node.js script:
|
||||
|
||||
```javascript
|
||||
const { app, BrowserWindow } = require('electron')
|
||||
let win = null
|
||||
|
||||
app.whenReady().then(() => {
|
||||
win = new BrowserWindow({ width: 800, height: 600 })
|
||||
win.loadURL('https://github.com')
|
||||
})
|
||||
```
|
||||
|
||||
The renderer process is no different than a normal web page, except for the
|
||||
extra ability to use node modules if `nodeIntegration` is enabled:
|
||||
|
||||
```html
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
<script>
|
||||
const fs = require('fs')
|
||||
console.log(fs.readFileSync(__filename, 'utf8'))
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
|
||||
## Destructuring assignment
|
||||
|
||||
As of 0.37, you can use
|
||||
[destructuring assignment][destructuring-assignment] to make it easier to use
|
||||
built-in modules.
|
||||
|
||||
```javascript
|
||||
const { app, BrowserWindow } = require('electron')
|
||||
|
||||
let win
|
||||
|
||||
app.whenReady().then(() => {
|
||||
win = new BrowserWindow()
|
||||
win.loadURL('https://github.com')
|
||||
})
|
||||
```
|
||||
|
||||
If you need the entire `electron` module, you can require it and then using
|
||||
destructuring to access the individual modules from `electron`.
|
||||
|
||||
```javascript
|
||||
const electron = require('electron')
|
||||
const { app, BrowserWindow } = electron
|
||||
|
||||
let win
|
||||
|
||||
app.whenReady().then(() => {
|
||||
win = new BrowserWindow()
|
||||
win.loadURL('https://github.com')
|
||||
})
|
||||
```
|
||||
|
||||
This is equivalent to the following code:
|
||||
|
||||
```javascript
|
||||
const electron = require('electron')
|
||||
const app = electron.app
|
||||
const BrowserWindow = electron.BrowserWindow
|
||||
let win
|
||||
|
||||
app.whenReady().then(() => {
|
||||
win = new BrowserWindow()
|
||||
win.loadURL('https://github.com')
|
||||
})
|
||||
```
|
||||
|
||||
[gui]: https://en.wikipedia.org/wiki/Graphical_user_interface
|
||||
[destructuring-assignment]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment
|
||||
@@ -6,7 +6,7 @@ Process: [Main](../glossary.md#main-process)
|
||||
|
||||
```javascript
|
||||
const { systemPreferences } = require('electron')
|
||||
console.log(systemPreferences.isDarkMode())
|
||||
console.log(systemPreferences.isAeroGlassEnabled())
|
||||
```
|
||||
|
||||
## Events
|
||||
@@ -27,32 +27,8 @@ Returns:
|
||||
|
||||
* `event` Event
|
||||
|
||||
### Event: 'inverted-color-scheme-changed' _Windows_ _Deprecated_
|
||||
|
||||
Returns:
|
||||
|
||||
* `event` Event
|
||||
* `invertedColorScheme` boolean - `true` if an inverted color scheme (a high contrast color scheme with light text and dark backgrounds) is being used, `false` otherwise.
|
||||
|
||||
**Deprecated:** Should use the new [`updated`](native-theme.md#event-updated) event on the `nativeTheme` module.
|
||||
|
||||
### Event: 'high-contrast-color-scheme-changed' _Windows_ _Deprecated_
|
||||
|
||||
Returns:
|
||||
|
||||
* `event` Event
|
||||
* `highContrastColorScheme` boolean - `true` if a high contrast theme is being used, `false` otherwise.
|
||||
|
||||
**Deprecated:** Should use the new [`updated`](native-theme.md#event-updated) event on the `nativeTheme` module.
|
||||
|
||||
## Methods
|
||||
|
||||
### `systemPreferences.isDarkMode()` _macOS_ _Windows_ _Deprecated_
|
||||
|
||||
Returns `boolean` - Whether the system is in Dark Mode.
|
||||
|
||||
**Deprecated:** Should use the new [`nativeTheme.shouldUseDarkColors`](native-theme.md#nativethemeshouldusedarkcolors-readonly) API.
|
||||
|
||||
### `systemPreferences.isSwipeTrackingFromScrollEventsEnabled()` _macOS_
|
||||
|
||||
Returns `boolean` - Whether the Swipe between pages setting is on.
|
||||
@@ -228,14 +204,14 @@ const win = new BrowserWindow(browserOptions)
|
||||
|
||||
// Navigate.
|
||||
if (browserOptions.transparent) {
|
||||
win.loadURL(`file://${__dirname}/index.html`)
|
||||
win.loadFile('index.html')
|
||||
} else {
|
||||
// No transparency, so we load a fallback that uses basic styles.
|
||||
win.loadURL(`file://${__dirname}/fallback.html`)
|
||||
win.loadFile('fallback.html')
|
||||
}
|
||||
```
|
||||
|
||||
[dwm-composition]:https://msdn.microsoft.com/en-us/library/windows/desktop/aa969540.aspx
|
||||
[dwm-composition]: https://learn.microsoft.com/en-us/windows/win32/dwm/composition-ovw
|
||||
|
||||
### `systemPreferences.getAccentColor()` _Windows_ _macOS_
|
||||
|
||||
@@ -297,7 +273,6 @@ This API is only available on macOS 10.14 Mojave or newer.
|
||||
* `window-frame` - Window frame.
|
||||
* `window-text` - Text in windows.
|
||||
* On **macOS**
|
||||
* `alternate-selected-control-text` - The text on a selected surface in a list or table. _deprecated_
|
||||
* `control-background` - The background of a large interface element, such as a browser or table.
|
||||
* `control` - The surface of a control.
|
||||
* `control-text` -The text of a control that isn’t disabled.
|
||||
@@ -336,8 +311,8 @@ See the [Windows docs][windows-colors] and the [macOS docs][macos-colors] for mo
|
||||
|
||||
The following colors are only available on macOS 10.14: `find-highlight`, `selected-content-background`, `separator`, `unemphasized-selected-content-background`, `unemphasized-selected-text-background`, and `unemphasized-selected-text`.
|
||||
|
||||
[windows-colors]:https://msdn.microsoft.com/en-us/library/windows/desktop/ms724371(v=vs.85).aspx
|
||||
[macos-colors]:https://developer.apple.com/design/human-interface-guidelines/macos/visual-design/color#dynamic-system-colors
|
||||
[windows-colors]: https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getsyscolor
|
||||
[macos-colors]: https://developer.apple.com/design/human-interface-guidelines/macos/visual-design/color#dynamic-system-colors
|
||||
|
||||
### `systemPreferences.getSystemColor(color)` _macOS_
|
||||
|
||||
@@ -356,18 +331,6 @@ Returns `string` - The standard system color formatted as `#RRGGBBAA`.
|
||||
|
||||
Returns one of several standard system colors that automatically adapt to vibrancy and changes in accessibility settings like 'Increase contrast' and 'Reduce transparency'. See [Apple Documentation](https://developer.apple.com/design/human-interface-guidelines/macos/visual-design/color#system-colors) for more details.
|
||||
|
||||
### `systemPreferences.isInvertedColorScheme()` _Windows_ _Deprecated_
|
||||
|
||||
Returns `boolean` - `true` if an inverted color scheme (a high contrast color scheme with light text and dark backgrounds) is active, `false` otherwise.
|
||||
|
||||
**Deprecated:** Should use the new [`nativeTheme.shouldUseInvertedColorScheme`](native-theme.md#nativethemeshoulduseinvertedcolorscheme-macos-windows-readonly) API.
|
||||
|
||||
### `systemPreferences.isHighContrastColorScheme()` _macOS_ _Windows_ _Deprecated_
|
||||
|
||||
Returns `boolean` - `true` if a high contrast theme is active, `false` otherwise.
|
||||
|
||||
**Deprecated:** Should use the new [`nativeTheme.shouldUseHighContrastColors`](native-theme.md#nativethemeshouldusehighcontrastcolors-macos-windows-readonly) API.
|
||||
|
||||
### `systemPreferences.getEffectiveAppearance()` _macOS_
|
||||
|
||||
Returns `string` - Can be `dark`, `light` or `unknown`.
|
||||
@@ -375,27 +338,10 @@ Returns `string` - Can be `dark`, `light` or `unknown`.
|
||||
Gets the macOS appearance setting that is currently applied to your application,
|
||||
maps to [NSApplication.effectiveAppearance](https://developer.apple.com/documentation/appkit/nsapplication/2967171-effectiveappearance?language=objc)
|
||||
|
||||
### `systemPreferences.getAppLevelAppearance()` _macOS_ _Deprecated_
|
||||
|
||||
Returns `string` | `null` - Can be `dark`, `light` or `unknown`.
|
||||
|
||||
Gets the macOS appearance setting that you have declared you want for
|
||||
your application, maps to [NSApplication.appearance](https://developer.apple.com/documentation/appkit/nsapplication/2967170-appearance?language=objc).
|
||||
You can use the `setAppLevelAppearance` API to set this value.
|
||||
|
||||
### `systemPreferences.setAppLevelAppearance(appearance)` _macOS_ _Deprecated_
|
||||
|
||||
* `appearance` string | null - Can be `dark` or `light`
|
||||
|
||||
Sets the appearance setting for your application, this should override the
|
||||
system default and override the value of `getEffectiveAppearance`.
|
||||
|
||||
### `systemPreferences.canPromptTouchID()` _macOS_
|
||||
|
||||
Returns `boolean` - whether or not this device has the ability to use Touch ID.
|
||||
|
||||
**NOTE:** This API will return `false` on macOS systems older than Sierra 10.12.2.
|
||||
|
||||
### `systemPreferences.promptTouchID(reason)` _macOS_
|
||||
|
||||
* `reason` string - The reason you are asking for Touch ID authentication
|
||||
@@ -414,8 +360,6 @@ systemPreferences.promptTouchID('To get consent for a Security-Gated Thing').the
|
||||
|
||||
This API itself will not protect your user data; rather, it is a mechanism to allow you to do so. Native apps will need to set [Access Control Constants](https://developer.apple.com/documentation/security/secaccesscontrolcreateflags?language=objc) like [`kSecAccessControlUserPresence`](https://developer.apple.com/documentation/security/secaccesscontrolcreateflags/ksecaccesscontroluserpresence?language=objc) on their keychain entry so that reading it would auto-prompt for Touch ID biometric consent. This could be done with [`node-keytar`](https://github.com/atom/node-keytar), such that one would store an encryption key with `node-keytar` and only fetch it if `promptTouchID()` resolves.
|
||||
|
||||
**NOTE:** This API will return a rejected Promise on macOS systems older than Sierra 10.12.2.
|
||||
|
||||
### `systemPreferences.isTrustedAccessibilityClient(prompt)` _macOS_
|
||||
|
||||
* `prompt` boolean - whether or not the user will be informed via prompt if the current process is untrusted.
|
||||
@@ -428,7 +372,7 @@ Returns `boolean` - `true` if the current process is a trusted accessibility cli
|
||||
|
||||
Returns `string` - Can be `not-determined`, `granted`, `denied`, `restricted` or `unknown`.
|
||||
|
||||
This user consent was not required on macOS 10.13 High Sierra or lower so this method will always return `granted`.
|
||||
This user consent was not required on macOS 10.13 High Sierra so this method will always return `granted`.
|
||||
macOS 10.14 Mojave or higher requires consent for `microphone` and `camera` access.
|
||||
macOS 10.15 Catalina or higher requires consent for `screen` access.
|
||||
|
||||
@@ -443,7 +387,7 @@ Returns `Promise<boolean>` - A promise that resolves with `true` if consent was
|
||||
|
||||
**Important:** In order to properly leverage this API, you [must set](https://developer.apple.com/documentation/avfoundation/cameras_and_media_capture/requesting_authorization_for_media_capture_on_macos?language=objc) the `NSMicrophoneUsageDescription` and `NSCameraUsageDescription` strings in your app's `Info.plist` file. The values for these keys will be used to populate the permission dialogs so that the user will be properly informed as to the purpose of the permission request. See [Electron Application Distribution](../tutorial/application-distribution.md#rebranding-with-downloaded-binaries) for more information about how to set these in the context of Electron.
|
||||
|
||||
This user consent was not required until macOS 10.14 Mojave, so this method will always return `true` if your system is running 10.13 High Sierra or lower.
|
||||
This user consent was not required until macOS 10.14 Mojave, so this method will always return `true` if your system is running 10.13 High Sierra.
|
||||
|
||||
### `systemPreferences.getAnimationSettings()`
|
||||
|
||||
@@ -457,15 +401,9 @@ Returns an object with system animation settings.
|
||||
|
||||
## Properties
|
||||
|
||||
### `systemPreferences.appLevelAppearance` _macOS_
|
||||
### `systemPreferences.accessibilityDisplayShouldReduceTransparency()` _macOS_
|
||||
|
||||
A `string` property that can be `dark`, `light` or `unknown`. It determines the macOS appearance setting for
|
||||
your application. This maps to values in: [NSApplication.appearance](https://developer.apple.com/documentation/appkit/nsapplication/2967170-appearance?language=objc). Setting this will override the
|
||||
system default as well as the value of `getEffectiveAppearance`.
|
||||
|
||||
Possible values that can be set are `dark` and `light`, and possible return values are `dark`, `light`, and `unknown`.
|
||||
|
||||
This property is only available on macOS 10.14 Mojave or newer.
|
||||
A `boolean` property which determines whether the app avoids using semitransparent backgrounds. This maps to [NSWorkspace.accessibilityDisplayShouldReduceTransparency](https://developer.apple.com/documentation/appkit/nsworkspace/1533006-accessibilitydisplayshouldreduce)
|
||||
|
||||
### `systemPreferences.effectiveAppearance` _macOS_ _Readonly_
|
||||
|
||||
|
||||
@@ -87,12 +87,12 @@ const { TouchBarLabel, TouchBarButton, TouchBarSpacer } = TouchBar
|
||||
let spinning = false
|
||||
|
||||
// Reel labels
|
||||
const reel1 = new TouchBarLabel()
|
||||
const reel2 = new TouchBarLabel()
|
||||
const reel3 = new TouchBarLabel()
|
||||
const reel1 = new TouchBarLabel({ label: '' })
|
||||
const reel2 = new TouchBarLabel({ label: '' })
|
||||
const reel3 = new TouchBarLabel({ label: '' })
|
||||
|
||||
// Spin result label
|
||||
const result = new TouchBarLabel()
|
||||
const result = new TouchBarLabel({ label: '' })
|
||||
|
||||
// Spin button
|
||||
const spin = new TouchBarButton({
|
||||
|
||||
@@ -25,9 +25,9 @@ app.whenReady().then(() => {
|
||||
})
|
||||
```
|
||||
|
||||
__Platform Considerations__
|
||||
**Platform Considerations**
|
||||
|
||||
__Linux__
|
||||
**Linux**
|
||||
|
||||
* Tray icon uses [StatusNotifierItem](https://www.freedesktop.org/wiki/Specifications/StatusNotifierItem/)
|
||||
by default, when it is not available in user's desktop environment the
|
||||
@@ -58,14 +58,14 @@ app.whenReady().then(() => {
|
||||
})
|
||||
```
|
||||
|
||||
__MacOS__
|
||||
**MacOS**
|
||||
|
||||
* Icons passed to the Tray constructor should be [Template Images](native-image.md#template-image).
|
||||
* To make sure your icon isn't grainy on retina monitors, be sure your `@2x` image is 144dpi.
|
||||
* If you are bundling your application (e.g., with webpack for development), be sure that the file names are not being mangled or hashed. The filename needs to end in Template, and the `@2x` image needs to have the same filename as the standard image, or MacOS will not magically invert your image's colors or use the high density image.
|
||||
* 16x16 (72dpi) and 32x32@2x (144dpi) work well for most icons.
|
||||
|
||||
__Windows__
|
||||
**Windows**
|
||||
|
||||
* It is recommended to use `ICO` icons to get best visual effects.
|
||||
|
||||
@@ -235,7 +235,7 @@ Sets the hover text for this tray icon.
|
||||
|
||||
* `title` string
|
||||
* `options` Object (optional)
|
||||
* `fontType` string (optional) - The font family variant to display, can be `monospaced` or `monospacedDigit`. `monospaced` is available in macOS 10.15+ and `monospacedDigit` is available in macOS 10.11+. When left blank, the title uses the default system font.
|
||||
* `fontType` string (optional) - The font family variant to display, can be `monospaced` or `monospacedDigit`. `monospaced` is available in macOS 10.15+ When left blank, the title uses the default system font.
|
||||
|
||||
Sets the title displayed next to the tray icon in the status bar (Support ANSI colors).
|
||||
|
||||
@@ -269,9 +269,9 @@ Returns `boolean` - Whether double click events will be ignored.
|
||||
|
||||
Displays a tray balloon.
|
||||
|
||||
[NIIF_NOSOUND]: https://docs.microsoft.com/en-us/windows/win32/api/shellapi/ns-shellapi-notifyicondataa#niif_nosound-0x00000010
|
||||
[NIIF_LARGE_ICON]: https://docs.microsoft.com/en-us/windows/win32/api/shellapi/ns-shellapi-notifyicondataa#niif_large_icon-0x00000020
|
||||
[NIIF_RESPECT_QUIET_TIME]: https://docs.microsoft.com/en-us/windows/win32/api/shellapi/ns-shellapi-notifyicondataa#niif_respect_quiet_time-0x00000080
|
||||
[NIIF_NOSOUND]: https://learn.microsoft.com/en-us/windows/win32/api/shellapi/ns-shellapi-notifyicondataa#niif_nosound-0x00000010
|
||||
[NIIF_LARGE_ICON]: https://learn.microsoft.com/en-us/windows/win32/api/shellapi/ns-shellapi-notifyicondataa#niif_large_icon-0x00000020
|
||||
[NIIF_RESPECT_QUIET_TIME]: https://learn.microsoft.com/en-us/windows/win32/api/shellapi/ns-shellapi-notifyicondataa#niif_respect_quiet_time-0x00000080
|
||||
|
||||
#### `tray.removeBalloon()` _Windows_
|
||||
|
||||
|
||||
@@ -13,12 +13,42 @@ the [`BrowserWindow`](browser-window.md) object. An example of accessing the
|
||||
const { BrowserWindow } = require('electron')
|
||||
|
||||
const win = new BrowserWindow({ width: 800, height: 1500 })
|
||||
win.loadURL('http://github.com')
|
||||
win.loadURL('https://github.com')
|
||||
|
||||
const contents = win.webContents
|
||||
console.log(contents)
|
||||
```
|
||||
|
||||
## Navigation Events
|
||||
|
||||
Several events can be used to monitor navigations as they occur within a `webContents`.
|
||||
|
||||
### Document Navigations
|
||||
|
||||
When a `webContents` navigates to another page (as opposed to an [in-page navigation](web-contents.md#in-page-navigation)), the following events will be fired.
|
||||
|
||||
* [`did-start-navigation`](web-contents.md#event-did-start-navigation)
|
||||
* [`will-frame-navigate`](web-contents.md#event-will-frame-navigate)
|
||||
* [`will-navigate`](web-contents.md#event-will-navigate) (only fired when main frame navigates)
|
||||
* [`will-redirect`](web-contents.md#event-will-redirect) (only fired when a redirect happens during navigation)
|
||||
* [`did-redirect-navigation`](web-contents.md#event-did-redirect-navigation) (only fired when a redirect happens during navigation)
|
||||
* [`did-frame-navigate`](web-contents.md#event-did-frame-navigate)
|
||||
* [`did-navigate`](web-contents.md#event-did-navigate) (only fired when main frame navigates)
|
||||
|
||||
Subsequent events will not fire if `event.preventDefault()` is called on any of the cancellable events.
|
||||
|
||||
### In-page Navigation
|
||||
|
||||
In-page navigations don't cause the page to reload, but instead navigate to a location within the current page. These events are not cancellable. For an in-page navigations, the following events will fire in this order:
|
||||
|
||||
* [`did-start-navigation`](web-contents.md#event-did-start-navigation)
|
||||
* [`did-navigate-in-page`](web-contents.md#event-did-navigate-in-page)
|
||||
|
||||
### Frame Navigation
|
||||
|
||||
The [`will-navigate`](web-contents.md#event-will-navigate) and [`did-navigate`](web-contents.md#event-did-navigate) events only fire when the [mainFrame](web-contents.md#contentsmainframe-readonly) navigates.
|
||||
If you want to also observe navigations in `<iframe>`s, use [`will-frame-navigate`](web-contents.md#event-will-frame-navigate) and [`did-frame-navigate`](web-contents.md#event-did-frame-navigate) events.
|
||||
|
||||
## Methods
|
||||
|
||||
These methods can be accessed from the `webContents` module:
|
||||
@@ -35,28 +65,28 @@ for all windows, webviews, opened devtools, and devtools extension background pa
|
||||
|
||||
### `webContents.getFocusedWebContents()`
|
||||
|
||||
Returns `WebContents` | null - The web contents that is focused in this application, otherwise
|
||||
Returns `WebContents | null` - The web contents that is focused in this application, otherwise
|
||||
returns `null`.
|
||||
|
||||
### `webContents.fromId(id)`
|
||||
|
||||
* `id` Integer
|
||||
|
||||
Returns `WebContents` | undefined - A WebContents instance with the given ID, or
|
||||
Returns `WebContents | undefined` - A WebContents instance with the given ID, or
|
||||
`undefined` if there is no WebContents associated with the given ID.
|
||||
|
||||
### `webContents.fromFrame(frame)`
|
||||
|
||||
* `frame` WebFrameMain
|
||||
|
||||
Returns `WebContents` | undefined - A WebContents instance with the given WebFrameMain, or
|
||||
Returns `WebContents | undefined` - A WebContents instance with the given WebFrameMain, or
|
||||
`undefined` if there is no WebContents associated with the given WebFrameMain.
|
||||
|
||||
### `webContents.fromDevToolsTargetId(targetId)`
|
||||
|
||||
* `targetId` string - The Chrome DevTools Protocol [TargetID](https://chromedevtools.github.io/devtools-protocol/tot/Target/#type-TargetID) associated with the WebContents instance.
|
||||
|
||||
Returns `WebContents` | undefined - A WebContents instance with the given TargetID, or
|
||||
Returns `WebContents | undefined` - A WebContents instance with the given TargetID, or
|
||||
`undefined` if there is no WebContents associated with the given TargetID.
|
||||
|
||||
When communicating with the [Chrome DevTools Protocol](https://chromedevtools.github.io/devtools-protocol/),
|
||||
@@ -68,7 +98,7 @@ async function lookupTargetId (browserWindow) {
|
||||
await wc.debugger.attach('1.3')
|
||||
const { targetInfo } = await wc.debugger.sendCommand('Target.getTargetInfo')
|
||||
const { targetId } = targetInfo
|
||||
const targetWebContents = await webContents.fromDevToolsTargetId(targetId)
|
||||
const targetWebContents = await wc.fromDevToolsTargetId(targetId)
|
||||
}
|
||||
```
|
||||
|
||||
@@ -180,7 +210,7 @@ Returns:
|
||||
* `url` string - URL for the created window.
|
||||
* `frameName` string - Name given to the created window in the
|
||||
`window.open()` call.
|
||||
* `options` BrowserWindowConstructorOptions - The options used to create the
|
||||
* `options` [BrowserWindowConstructorOptions](structures/browser-window-options.md) - The options used to create the
|
||||
BrowserWindow. They are merged in increasing precedence: parsed options
|
||||
from the `features` string from `window.open()`, security-related
|
||||
webPreferences inherited from the parent, and options given by
|
||||
@@ -195,7 +225,7 @@ Returns:
|
||||
Only defined when the window is being created by a form that set
|
||||
`target=_blank`.
|
||||
* `disposition` string - Can be `default`, `foreground-tab`,
|
||||
`background-tab`, `new-window`, `save-to-disk` and `other`.
|
||||
`background-tab`, `new-window` or `other`.
|
||||
|
||||
Emitted _after_ successful creation of a window via `window.open` in the renderer.
|
||||
Not emitted if the creation of the window is canceled from
|
||||
@@ -207,10 +237,24 @@ See [`window.open()`](window-open.md) for more details and how to use this in co
|
||||
|
||||
Returns:
|
||||
|
||||
* `event` Event
|
||||
* `url` string
|
||||
* `details` Event<>
|
||||
* `url` string - The URL the frame is navigating to.
|
||||
* `isSameDocument` boolean - This event does not fire for same document navigations using window.history api and reference fragment navigations.
|
||||
This property is always set to `false` for this event.
|
||||
* `isMainFrame` boolean - True if the navigation is taking place in a main frame.
|
||||
* `frame` WebFrameMain - The frame to be navigated.
|
||||
* `initiator` WebFrameMain (optional) - The frame which initiated the
|
||||
navigation, which can be a parent frame (e.g. via `window.open` with a
|
||||
frame's name), or null if the navigation was not initiated by a frame. This
|
||||
can also be null if the initiating frame was deleted before the event was
|
||||
emitted.
|
||||
* `url` string _Deprecated_
|
||||
* `isInPlace` boolean _Deprecated_
|
||||
* `isMainFrame` boolean _Deprecated_
|
||||
* `frameProcessId` Integer _Deprecated_
|
||||
* `frameRoutingId` Integer _Deprecated_
|
||||
|
||||
Emitted when a user or the page wants to start navigation. It can happen when
|
||||
Emitted when a user or the page wants to start navigation on the main frame. It can happen when
|
||||
the `window.location` object is changed or a user clicks a link in the page.
|
||||
|
||||
This event will not emit when the navigation is started programmatically with
|
||||
@@ -222,30 +266,81 @@ this purpose.
|
||||
|
||||
Calling `event.preventDefault()` will prevent the navigation.
|
||||
|
||||
#### Event: 'will-frame-navigate'
|
||||
|
||||
Returns:
|
||||
|
||||
* `details` Event<>
|
||||
* `url` string - The URL the frame is navigating to.
|
||||
* `isSameDocument` boolean - This event does not fire for same document navigations using window.history api and reference fragment navigations.
|
||||
This property is always set to `false` for this event.
|
||||
* `isMainFrame` boolean - True if the navigation is taking place in a main frame.
|
||||
* `frame` WebFrameMain - The frame to be navigated.
|
||||
* `initiator` WebFrameMain (optional) - The frame which initiated the
|
||||
navigation, which can be a parent frame (e.g. via `window.open` with a
|
||||
frame's name), or null if the navigation was not initiated by a frame. This
|
||||
can also be null if the initiating frame was deleted before the event was
|
||||
emitted.
|
||||
|
||||
Emitted when a user or the page wants to start navigation in any frame. It can happen when
|
||||
the `window.location` object is changed or a user clicks a link in the page.
|
||||
|
||||
Unlike `will-navigate`, `will-frame-navigate` is fired when the main frame or any of its subframes attempts to navigate. When the navigation event comes from the main frame, `isMainFrame` will be `true`.
|
||||
|
||||
This event will not emit when the navigation is started programmatically with
|
||||
APIs like `webContents.loadURL` and `webContents.back`.
|
||||
|
||||
It is also not emitted for in-page navigations, such as clicking anchor links
|
||||
or updating the `window.location.hash`. Use `did-navigate-in-page` event for
|
||||
this purpose.
|
||||
|
||||
Calling `event.preventDefault()` will prevent the navigation.
|
||||
|
||||
#### Event: 'did-start-navigation'
|
||||
|
||||
Returns:
|
||||
|
||||
* `event` Event
|
||||
* `url` string
|
||||
* `isInPlace` boolean
|
||||
* `isMainFrame` boolean
|
||||
* `frameProcessId` Integer
|
||||
* `frameRoutingId` Integer
|
||||
* `details` Event<>
|
||||
* `url` string - The URL the frame is navigating to.
|
||||
* `isSameDocument` boolean - Whether the navigation happened without changing
|
||||
document. Examples of same document navigations are reference fragment
|
||||
navigations, pushState/replaceState, and same page history navigation.
|
||||
* `isMainFrame` boolean - True if the navigation is taking place in a main frame.
|
||||
* `frame` WebFrameMain - The frame to be navigated.
|
||||
* `initiator` WebFrameMain (optional) - The frame which initiated the
|
||||
navigation, which can be a parent frame (e.g. via `window.open` with a
|
||||
frame's name), or null if the navigation was not initiated by a frame. This
|
||||
can also be null if the initiating frame was deleted before the event was
|
||||
emitted.
|
||||
* `url` string _Deprecated_
|
||||
* `isInPlace` boolean _Deprecated_
|
||||
* `isMainFrame` boolean _Deprecated_
|
||||
* `frameProcessId` Integer _Deprecated_
|
||||
* `frameRoutingId` Integer _Deprecated_
|
||||
|
||||
Emitted when any frame (including main) starts navigating. `isInPlace` will be
|
||||
`true` for in-page navigations.
|
||||
Emitted when any frame (including main) starts navigating.
|
||||
|
||||
#### Event: 'will-redirect'
|
||||
|
||||
Returns:
|
||||
|
||||
* `event` Event
|
||||
* `url` string
|
||||
* `isInPlace` boolean
|
||||
* `isMainFrame` boolean
|
||||
* `frameProcessId` Integer
|
||||
* `frameRoutingId` Integer
|
||||
* `details` Event<>
|
||||
* `url` string - The URL the frame is navigating to.
|
||||
* `isSameDocument` boolean - Whether the navigation happened without changing
|
||||
document. Examples of same document navigations are reference fragment
|
||||
navigations, pushState/replaceState, and same page history navigation.
|
||||
* `isMainFrame` boolean - True if the navigation is taking place in a main frame.
|
||||
* `frame` WebFrameMain - The frame to be navigated.
|
||||
* `initiator` WebFrameMain (optional) - The frame which initiated the
|
||||
navigation, which can be a parent frame (e.g. via `window.open` with a
|
||||
frame's name), or null if the navigation was not initiated by a frame. This
|
||||
can also be null if the initiating frame was deleted before the event was
|
||||
emitted.
|
||||
* `url` string _Deprecated_
|
||||
* `isInPlace` boolean _Deprecated_
|
||||
* `isMainFrame` boolean _Deprecated_
|
||||
* `frameProcessId` Integer _Deprecated_
|
||||
* `frameRoutingId` Integer _Deprecated_
|
||||
|
||||
Emitted when a server side redirect occurs during navigation. For example a 302
|
||||
redirect.
|
||||
@@ -260,12 +355,23 @@ redirect).
|
||||
|
||||
Returns:
|
||||
|
||||
* `event` Event
|
||||
* `url` string
|
||||
* `isInPlace` boolean
|
||||
* `isMainFrame` boolean
|
||||
* `frameProcessId` Integer
|
||||
* `frameRoutingId` Integer
|
||||
* `details` Event<>
|
||||
* `url` string - The URL the frame is navigating to.
|
||||
* `isSameDocument` boolean - Whether the navigation happened without changing
|
||||
document. Examples of same document navigations are reference fragment
|
||||
navigations, pushState/replaceState, and same page history navigation.
|
||||
* `isMainFrame` boolean - True if the navigation is taking place in a main frame.
|
||||
* `frame` WebFrameMain - The frame to be navigated.
|
||||
* `initiator` WebFrameMain (optional) - The frame which initiated the
|
||||
navigation, which can be a parent frame (e.g. via `window.open` with a
|
||||
frame's name), or null if the navigation was not initiated by a frame. This
|
||||
can also be null if the initiating frame was deleted before the event was
|
||||
emitted.
|
||||
* `url` string _Deprecated_
|
||||
* `isInPlace` boolean _Deprecated_
|
||||
* `isMainFrame` boolean _Deprecated_
|
||||
* `frameProcessId` Integer _Deprecated_
|
||||
* `frameRoutingId` Integer _Deprecated_
|
||||
|
||||
Emitted after a server side redirect occurs during navigation. For example a 302
|
||||
redirect.
|
||||
@@ -373,18 +479,7 @@ checking `reason === 'killed'` when you switch to that event.
|
||||
Returns:
|
||||
|
||||
* `event` Event
|
||||
* `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.
|
||||
* `details` [RenderProcessGoneDetails](structures/render-process-gone-details.md)
|
||||
|
||||
Emitted when the renderer process unexpectedly disappears. This is normally
|
||||
because it was crashed or killed.
|
||||
@@ -496,6 +591,7 @@ window.
|
||||
|
||||
Returns:
|
||||
|
||||
* `event` Event
|
||||
* `url` string - URL of the link that was clicked or selected.
|
||||
|
||||
Emitted when a link is clicked in DevTools or 'Open in new tab' is selected for a link in its context menu.
|
||||
@@ -588,6 +684,15 @@ Emitted when media starts playing.
|
||||
|
||||
Emitted when media is paused or done playing.
|
||||
|
||||
#### Event: 'audio-state-changed'
|
||||
|
||||
Returns:
|
||||
|
||||
* `event` Event<>
|
||||
* `audible` boolean - True if one or more frames or child `webContents` are emitting audio.
|
||||
|
||||
Emitted when media becomes audible or inaudible.
|
||||
|
||||
#### Event: 'did-change-theme-color'
|
||||
|
||||
Returns:
|
||||
@@ -622,14 +727,16 @@ Returns:
|
||||
* `size` [Size](structures/size.md) (optional) - the size of the `image`.
|
||||
* `hotspot` [Point](structures/point.md) (optional) - coordinates of the custom cursor's hotspot.
|
||||
|
||||
Emitted when the cursor's type changes. The `type` parameter can be `default`,
|
||||
`crosshair`, `pointer`, `text`, `wait`, `help`, `e-resize`, `n-resize`,
|
||||
`ne-resize`, `nw-resize`, `s-resize`, `se-resize`, `sw-resize`, `w-resize`,
|
||||
`ns-resize`, `ew-resize`, `nesw-resize`, `nwse-resize`, `col-resize`,
|
||||
`row-resize`, `m-panning`, `e-panning`, `n-panning`, `ne-panning`, `nw-panning`,
|
||||
`s-panning`, `se-panning`, `sw-panning`, `w-panning`, `move`, `vertical-text`,
|
||||
`cell`, `context-menu`, `alias`, `progress`, `nodrop`, `copy`, `none`,
|
||||
`not-allowed`, `zoom-in`, `zoom-out`, `grab`, `grabbing` or `custom`.
|
||||
Emitted when the cursor's type changes. The `type` parameter can be `pointer`,
|
||||
`crosshair`, `hand`, `text`, `wait`, `help`, `e-resize`, `n-resize`, `ne-resize`,
|
||||
`nw-resize`, `s-resize`, `se-resize`, `sw-resize`, `w-resize`, `ns-resize`, `ew-resize`,
|
||||
`nesw-resize`, `nwse-resize`, `col-resize`, `row-resize`, `m-panning`, `m-panning-vertical`,
|
||||
`m-panning-horizontal`, `e-panning`, `n-panning`, `ne-panning`, `nw-panning`, `s-panning`,
|
||||
`se-panning`, `sw-panning`, `w-panning`, `move`, `vertical-text`, `cell`, `context-menu`,
|
||||
`alias`, `progress`, `nodrop`, `copy`, `none`, `not-allowed`, `zoom-in`, `zoom-out`, `grab`,
|
||||
`grabbing`, `custom`, `null`, `drag-drop-none`, `drag-drop-move`, `drag-drop-copy`,
|
||||
`drag-drop-link`, `ns-no-resize`, `ew-no-resize`, `nesw-no-resize`, `nwse-no-resize`,
|
||||
or `default`.
|
||||
|
||||
If the `type` parameter is `custom`, the `image` parameter will hold the custom
|
||||
cursor image in a [`NativeImage`](native-image.md), and `scale`, `size` and `hotspot` will hold
|
||||
@@ -677,7 +784,7 @@ Returns:
|
||||
* `frameCharset` string - The character encoding of the frame on which the
|
||||
menu was invoked.
|
||||
* `inputFieldType` string - If the context menu was invoked on an input
|
||||
field, the type of that field. Possible values are `none`, `plainText`,
|
||||
field, the type of that field. Possible values include `none`, `plainText`,
|
||||
`password`, `other`.
|
||||
* `spellcheckEnabled` boolean - If the context is editable, whether or not spellchecking is enabled.
|
||||
* `menuSourceType` string - Input source that invoked the context menu.
|
||||
@@ -721,20 +828,24 @@ Returns:
|
||||
* `callback` Function
|
||||
* `deviceId` string
|
||||
|
||||
Emitted when bluetooth device needs to be selected on call to
|
||||
`navigator.bluetooth.requestDevice`. To use `navigator.bluetooth` api
|
||||
`webBluetooth` should be enabled. If `event.preventDefault` is not called,
|
||||
first available device will be selected. `callback` should be called with
|
||||
`deviceId` to be selected, passing empty string to `callback` will
|
||||
cancel the request.
|
||||
Emitted when a bluetooth device needs to be selected when a call to
|
||||
`navigator.bluetooth.requestDevice` is made. `callback` should be called with
|
||||
the `deviceId` of the device to be selected. Passing an empty string to
|
||||
`callback` will cancel the request.
|
||||
|
||||
If no event listener is added for this event, all bluetooth requests will be cancelled.
|
||||
If an event listener is not added for this event, or if `event.preventDefault`
|
||||
is not called when handling this event, the first available device will be
|
||||
automatically selected.
|
||||
|
||||
```javascript
|
||||
Due to the nature of bluetooth, scanning for devices when
|
||||
`navigator.bluetooth.requestDevice` is called may take time and will cause
|
||||
`select-bluetooth-device` to fire multiple times until `callback` is called
|
||||
with either a device id or an empty string to cancel the request.
|
||||
|
||||
```javascript title='main.js'
|
||||
const { app, BrowserWindow } = require('electron')
|
||||
|
||||
let win = null
|
||||
app.commandLine.appendSwitch('enable-experimental-web-platform-features')
|
||||
|
||||
app.whenReady().then(() => {
|
||||
win = new BrowserWindow({ width: 800, height: 600 })
|
||||
@@ -744,6 +855,9 @@ app.whenReady().then(() => {
|
||||
return device.deviceName === 'test'
|
||||
})
|
||||
if (!result) {
|
||||
// The device wasn't found so we need to either wait longer (eg until the
|
||||
// device is turned on) or cancel the request by calling the callback
|
||||
// with an empty string.
|
||||
callback('')
|
||||
} else {
|
||||
callback(result.deviceId)
|
||||
@@ -770,7 +884,7 @@ const win = new BrowserWindow({ webPreferences: { offscreen: true } })
|
||||
win.webContents.on('paint', (event, dirty, image) => {
|
||||
// updateBitmap(dirty, image.getBitmap())
|
||||
})
|
||||
win.loadURL('http://github.com')
|
||||
win.loadURL('https://github.com')
|
||||
```
|
||||
|
||||
#### Event: 'devtools-reload-page'
|
||||
@@ -782,7 +896,7 @@ Emitted when the devtools window instructs the webContents to reload
|
||||
Returns:
|
||||
|
||||
* `event` Event
|
||||
* `webPreferences` WebPreferences - The web preferences that will be used by the guest
|
||||
* `webPreferences` [WebPreferences](structures/web-preferences.md) - The web preferences that will be used by the guest
|
||||
page. This object can be modified to adjust the preferences for the guest
|
||||
page.
|
||||
* `params` Record<string, string> - The other `<webview>` parameters such as the `src` URL.
|
||||
@@ -831,7 +945,7 @@ Emitted when the preload script `preloadPath` throws an unhandled exception `err
|
||||
|
||||
Returns:
|
||||
|
||||
* `event` Event
|
||||
* `event` [IpcMainEvent](structures/ipc-main-event.md)
|
||||
* `channel` string
|
||||
* `...args` any[]
|
||||
|
||||
@@ -843,7 +957,7 @@ See also [`webContents.ipc`](#contentsipc-readonly), which provides an [`IpcMain
|
||||
|
||||
Returns:
|
||||
|
||||
* `event` Event
|
||||
* `event` [IpcMainEvent](structures/ipc-main-event.md)
|
||||
* `channel` string
|
||||
* `...args` any[]
|
||||
|
||||
@@ -896,9 +1010,9 @@ e.g. the `http://` or `file://`. If the load should bypass http cache then
|
||||
use the `pragma` header to achieve it.
|
||||
|
||||
```javascript
|
||||
const { webContents } = require('electron')
|
||||
const win = new BrowserWindow()
|
||||
const options = { extraHeaders: 'pragma: no-cache\n' }
|
||||
webContents.loadURL('https://github.com', options)
|
||||
win.webContents.loadURL('https://github.com', options)
|
||||
```
|
||||
|
||||
#### `contents.loadFile(filePath[, options])`
|
||||
@@ -928,12 +1042,15 @@ an app structure like this:
|
||||
Would require code like this
|
||||
|
||||
```js
|
||||
const win = new BrowserWindow()
|
||||
win.loadFile('src/index.html')
|
||||
```
|
||||
|
||||
#### `contents.downloadURL(url)`
|
||||
#### `contents.downloadURL(url[, options])`
|
||||
|
||||
* `url` string
|
||||
* `options` Object (optional)
|
||||
* `headers` Record<string, string> (optional) - HTTP request headers.
|
||||
|
||||
Initiates a download of the resource at `url` without navigating. The
|
||||
`will-download` event of `session` will be triggered.
|
||||
@@ -945,7 +1062,7 @@ Returns `string` - The URL of the current web page.
|
||||
```javascript
|
||||
const { BrowserWindow } = require('electron')
|
||||
const win = new BrowserWindow({ width: 800, height: 600 })
|
||||
win.loadURL('http://github.com').then(() => {
|
||||
win.loadURL('https://github.com').then(() => {
|
||||
const currentURL = win.webContents.getURL()
|
||||
console.log(currentURL)
|
||||
})
|
||||
@@ -1064,7 +1181,9 @@ when this process is unstable or unusable, for instance in order to recover
|
||||
from the `unresponsive` event.
|
||||
|
||||
```js
|
||||
contents.on('unresponsive', async () => {
|
||||
const win = new BrowserWindow()
|
||||
|
||||
win.webContents.on('unresponsive', async () => {
|
||||
const { response } = await dialog.showMessageBox({
|
||||
message: 'App X has become unresponsive',
|
||||
title: 'Do you want to try forcefully reloading the app?',
|
||||
@@ -1072,8 +1191,8 @@ contents.on('unresponsive', async () => {
|
||||
cancelId: 1
|
||||
})
|
||||
if (response === 0) {
|
||||
contents.forcefullyCrashRenderer()
|
||||
contents.reload()
|
||||
win.webContents.forcefullyCrashRenderer()
|
||||
win.webContents.reload()
|
||||
}
|
||||
})
|
||||
```
|
||||
@@ -1100,8 +1219,9 @@ Injects CSS into the current web page and returns a unique key for the inserted
|
||||
stylesheet.
|
||||
|
||||
```js
|
||||
contents.on('did-finish-load', () => {
|
||||
contents.insertCSS('html, body { background-color: #f00; }')
|
||||
const win = new BrowserWindow()
|
||||
win.webContents.on('did-finish-load', () => {
|
||||
win.webContents.insertCSS('html, body { background-color: #f00; }')
|
||||
})
|
||||
```
|
||||
|
||||
@@ -1115,9 +1235,11 @@ Removes the inserted CSS from the current web page. The stylesheet is identified
|
||||
by its key, which is returned from `contents.insertCSS(css)`.
|
||||
|
||||
```js
|
||||
contents.on('did-finish-load', async () => {
|
||||
const key = await contents.insertCSS('html, body { background-color: #f00; }')
|
||||
contents.removeInsertedCSS(key)
|
||||
const win = new BrowserWindow()
|
||||
|
||||
win.webContents.on('did-finish-load', async () => {
|
||||
const key = await win.webContents.insertCSS('html, body { background-color: #f00; }')
|
||||
win.webContents.removeInsertedCSS(key)
|
||||
})
|
||||
```
|
||||
|
||||
@@ -1138,7 +1260,9 @@ this limitation.
|
||||
Code execution will be suspended until web page stop loading.
|
||||
|
||||
```js
|
||||
contents.executeJavaScript('fetch("https://jsonplaceholder.typicode.com/users/1").then(resp => resp.json())', true)
|
||||
const win = new BrowserWindow()
|
||||
|
||||
win.webContents.executeJavaScript('fetch("https://jsonplaceholder.typicode.com/users/1").then(resp => resp.json())', true)
|
||||
.then((result) => {
|
||||
console.log(result) // Will be the JSON object from the fetch call
|
||||
})
|
||||
@@ -1169,7 +1293,7 @@ Ignore application menu shortcuts while this web contents is focused.
|
||||
* `frameName` string - Name of the window provided in `window.open()`
|
||||
* `features` string - Comma separated list of window features provided to `window.open()`.
|
||||
* `disposition` string - Can be `default`, `foreground-tab`, `background-tab`,
|
||||
`new-window`, `save-to-disk` or `other`.
|
||||
`new-window` or `other`.
|
||||
* `referrer` [Referrer](structures/referrer.md) - The referrer that will be
|
||||
passed to the new window. May or may not result in the `Referer` header being
|
||||
sent, depending on the referrer policy.
|
||||
@@ -1249,7 +1373,8 @@ Sets the maximum and minimum pinch-to-zoom level.
|
||||
> **NOTE**: Visual zoom is disabled by default in Electron. To re-enable it, call:
|
||||
>
|
||||
> ```js
|
||||
> contents.setVisualZoomLevelLimits(1, 3)
|
||||
> const win = new BrowserWindow()
|
||||
> win.webContents.setVisualZoomLevelLimits(1, 3)
|
||||
> ```
|
||||
|
||||
#### `contents.undo()`
|
||||
@@ -1268,6 +1393,10 @@ Executes the editing command `cut` in web page.
|
||||
|
||||
Executes the editing command `copy` in web page.
|
||||
|
||||
#### `contents.centerSelection()`
|
||||
|
||||
Centers the current text selection in web page.
|
||||
|
||||
#### `contents.copyImageAt(x, y)`
|
||||
|
||||
* `x` Integer
|
||||
@@ -1295,6 +1424,46 @@ Executes the editing command `selectAll` in web page.
|
||||
|
||||
Executes the editing command `unselect` in web page.
|
||||
|
||||
#### `contents.scrollToTop()`
|
||||
|
||||
Scrolls to the top of the current `webContents`.
|
||||
|
||||
#### `contents.scrollToBottom()`
|
||||
|
||||
Scrolls to the bottom of the current `webContents`.
|
||||
|
||||
#### `contents.adjustSelection(options)`
|
||||
|
||||
* `options` Object
|
||||
* `start` Number (optional) - Amount to shift the start index of the current selection.
|
||||
* `end` Number (optional) - Amount to shift the end index of the current selection.
|
||||
|
||||
Adjusts the current text selection starting and ending points in the focused frame by the given amounts. A negative amount moves the selection towards the beginning of the document, and a positive amount moves the selection towards the end of the document.
|
||||
|
||||
Example:
|
||||
|
||||
```js
|
||||
const win = new BrowserWindow()
|
||||
|
||||
// Adjusts the beginning of the selection 1 letter forward,
|
||||
// and the end of the selection 5 letters forward.
|
||||
win.webContents.adjustSelection({ start: 1, end: 5 })
|
||||
|
||||
// Adjusts the beginning of the selection 2 letters forward,
|
||||
// and the end of the selection 3 letters backward.
|
||||
win.webContents.adjustSelection({ start: 2, end: -3 })
|
||||
```
|
||||
|
||||
For a call of `win.webContents.adjustSelection({ start: 1, end: 5 })`
|
||||
|
||||
Before:
|
||||
|
||||
<img width="487" alt="Image Before Text Selection Adjustment" src="../images/web-contents-text-selection-before.png"/>
|
||||
|
||||
After:
|
||||
|
||||
<img width="487" alt="Image After Text Selection Adjustment" src="../images/web-contents-text-selection-after.png"/>
|
||||
|
||||
#### `contents.replace(text)`
|
||||
|
||||
* `text` string
|
||||
@@ -1340,12 +1509,12 @@ can be obtained by subscribing to [`found-in-page`](web-contents.md#event-found-
|
||||
Stops any `findInPage` request for the `webContents` with the provided `action`.
|
||||
|
||||
```javascript
|
||||
const { webContents } = require('electron')
|
||||
webContents.on('found-in-page', (event, result) => {
|
||||
if (result.finalUpdate) webContents.stopFindInPage('clearSelection')
|
||||
const win = new BrowserWindow()
|
||||
win.webContents.on('found-in-page', (event, result) => {
|
||||
if (result.finalUpdate) win.webContents.stopFindInPage('clearSelection')
|
||||
})
|
||||
|
||||
const requestId = webContents.findInPage('api')
|
||||
const requestId = win.webContents.findInPage('api')
|
||||
console.log(requestId)
|
||||
```
|
||||
|
||||
@@ -1367,14 +1536,6 @@ If you would like the page to stay hidden, you should ensure that `stayHidden` i
|
||||
Returns `boolean` - Whether this page is being captured. It returns true when the capturer count
|
||||
is large then 0.
|
||||
|
||||
#### `contents.getPrinters()` _Deprecated_
|
||||
|
||||
Get the system printer list.
|
||||
|
||||
Returns [`PrinterInfo[]`](structures/printer-info.md)
|
||||
|
||||
**Deprecated:** Should use the new [`contents.getPrintersAsync`](web-contents.md#contentsgetprintersasync) API.
|
||||
|
||||
#### `contents.getPrintersAsync()`
|
||||
|
||||
Get the system printer list.
|
||||
@@ -1409,8 +1570,8 @@ Returns `Promise<PrinterInfo[]>` - Resolves with a [`PrinterInfo[]`](structures/
|
||||
* `vertical` number (optional) - The vertical dpi.
|
||||
* `header` string (optional) - string to be printed as page header.
|
||||
* `footer` string (optional) - string to be printed as page footer.
|
||||
* `pageSize` string | Size (optional) - Specify page size of the printed document. Can be `A3`,
|
||||
`A4`, `A5`, `Legal`, `Letter`, `Tabloid` or an Object containing `height` and `width`.
|
||||
* `pageSize` string | Size (optional) - Specify page size of the printed document. Can be `A0`, `A1`, `A2`, `A3`,
|
||||
`A4`, `A5`, `A6`, `Legal`, `Letter`, `Tabloid` or an Object containing `height` and `width`.
|
||||
* `callback` Function (optional)
|
||||
* `success` boolean - Indicates success of the print call.
|
||||
* `failureReason` string - Error description called back if the print fails.
|
||||
@@ -1425,6 +1586,7 @@ Use `page-break-before: always;` CSS style to force to print to a new page.
|
||||
Example usage:
|
||||
|
||||
```js
|
||||
const win = new BrowserWindow()
|
||||
const options = {
|
||||
silent: true,
|
||||
deviceName: 'My-Printer',
|
||||
@@ -1452,10 +1614,11 @@ win.webContents.print(options, (success, errorType) => {
|
||||
* `bottom` number (optional) - Bottom margin in inches. Defaults to 1cm (~0.4 inches).
|
||||
* `left` number (optional) - Left margin in inches. Defaults to 1cm (~0.4 inches).
|
||||
* `right` number (optional) - Right margin in inches. Defaults to 1cm (~0.4 inches).
|
||||
* `pageRanges` string (optional) - Paper ranges to print, e.g., '1-5, 8, 11-13'. Defaults to the empty string, which means print all pages.
|
||||
* `pageRanges` string (optional) - Page ranges to print, e.g., '1-5, 8, 11-13'. Defaults to the empty string, which means print all pages.
|
||||
* `headerTemplate` string (optional) - HTML template for the print header. Should be valid HTML markup with following classes used to inject printing values into them: `date` (formatted print date), `title` (document title), `url` (document location), `pageNumber` (current page number) and `totalPages` (total pages in the document). For example, `<span class=title></span>` would generate span containing the title.
|
||||
* `footerTemplate` string (optional) - HTML template for the print footer. Should use the same format as the `headerTemplate`.
|
||||
* `preferCSSPageSize` boolean (optional) - Whether or not to prefer page size as defined by css. Defaults to false, in which case the content will be scaled to fit the paper size.
|
||||
* `generateTaggedPDF` boolean (optional) _Experimental_ - Whether or not to generate a tagged (accessible) PDF. Defaults to false. As this property is experimental, the generated PDF may not adhere fully to PDF/UA and WCAG standards.
|
||||
|
||||
Returns `Promise<Buffer>` - Resolves with the generated PDF data.
|
||||
|
||||
@@ -1467,12 +1630,12 @@ An example of `webContents.printToPDF`:
|
||||
|
||||
```javascript
|
||||
const { BrowserWindow } = require('electron')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const os = require('os')
|
||||
const fs = require('node:fs')
|
||||
const path = require('node:path')
|
||||
const os = require('node:os')
|
||||
|
||||
const win = new BrowserWindow()
|
||||
win.loadURL('http://github.com')
|
||||
win.loadURL('https://github.com')
|
||||
|
||||
win.webContents.on('did-finish-load', () => {
|
||||
// Use default printing options
|
||||
@@ -1575,7 +1738,7 @@ ipcMain.on('open-devtools', (event, targetContentsId, devtoolsContentsId) => {
|
||||
|
||||
An example of showing devtools in a `BrowserWindow`:
|
||||
|
||||
```js
|
||||
```js title='main.js'
|
||||
const { app, BrowserWindow } = require('electron')
|
||||
|
||||
let win = null
|
||||
@@ -1598,6 +1761,7 @@ app.whenReady().then(() => {
|
||||
In `undocked` mode it's possible to dock back. In `detach` mode it's not.
|
||||
* `activate` boolean (optional) - Whether to bring the opened devtools window
|
||||
to the foreground. The default is `true`.
|
||||
* `title` string (optional) - A title for the DevTools window (only in `undocked` or `detach` mode).
|
||||
|
||||
Opens the devtools.
|
||||
|
||||
@@ -1618,6 +1782,18 @@ Returns `boolean` - Whether the devtools is opened.
|
||||
|
||||
Returns `boolean` - Whether the devtools view is focused .
|
||||
|
||||
#### `contents.getDevToolsTitle()`
|
||||
|
||||
Returns `string` - the current title of the DevTools window. This will only be visible
|
||||
if DevTools is opened in `undocked` or `detach` mode.
|
||||
|
||||
#### `contents.setDevToolsTitle(title)`
|
||||
|
||||
* `title` string
|
||||
|
||||
Changes the title of the DevTools window to `title`. This will only be visible if DevTools is
|
||||
opened in `undocked` or `detach` mode.
|
||||
|
||||
#### `contents.toggleDevTools()`
|
||||
|
||||
Toggles the developer tools.
|
||||
@@ -1658,40 +1834,14 @@ Algorithm][SCA], just like [`postMessage`][], so prototype chains will not be
|
||||
included. Sending Functions, Promises, Symbols, WeakMaps, or WeakSets will
|
||||
throw an exception.
|
||||
|
||||
> **NOTE**: Sending non-standard JavaScript types such as DOM objects or
|
||||
> special Electron objects will throw an exception.
|
||||
:::warning
|
||||
|
||||
The renderer process can handle the message by listening to `channel` with the
|
||||
[`ipcRenderer`](ipc-renderer.md) module.
|
||||
Sending non-standard JavaScript types such as DOM objects or
|
||||
special Electron objects will throw an exception.
|
||||
|
||||
An example of sending messages from the main process to the renderer process:
|
||||
:::
|
||||
|
||||
```javascript
|
||||
// In the main process.
|
||||
const { app, BrowserWindow } = require('electron')
|
||||
let win = null
|
||||
|
||||
app.whenReady().then(() => {
|
||||
win = new BrowserWindow({ width: 800, height: 600 })
|
||||
win.loadURL(`file://${__dirname}/index.html`)
|
||||
win.webContents.on('did-finish-load', () => {
|
||||
win.webContents.send('ping', 'whoooooooh!')
|
||||
})
|
||||
})
|
||||
```
|
||||
|
||||
```html
|
||||
<!-- index.html -->
|
||||
<html>
|
||||
<body>
|
||||
<script>
|
||||
require('electron').ipcRenderer.on('ping', (event, message) => {
|
||||
console.log(message) // Prints 'whoooooooh!'
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
For additional reading, refer to [Electron's IPC guide](../tutorial/ipc.md).
|
||||
|
||||
#### `contents.sendToFrame(frameId, channel, ...args)`
|
||||
|
||||
@@ -1747,8 +1897,9 @@ For example:
|
||||
|
||||
```js
|
||||
// Main process
|
||||
const win = new BrowserWindow()
|
||||
const { port1, port2 } = new MessageChannelMain()
|
||||
webContents.postMessage('port', { message: 'hello' }, [port1])
|
||||
win.webContents.postMessage('port', { message: 'hello' }, [port1])
|
||||
|
||||
// Renderer process
|
||||
ipcRenderer.on('port', (e, msg) => {
|
||||
@@ -1853,36 +2004,36 @@ Shows pop-up dictionary that searches the selected word on the page.
|
||||
|
||||
#### `contents.isOffscreen()`
|
||||
|
||||
Returns `boolean` - Indicates whether *offscreen rendering* is enabled.
|
||||
Returns `boolean` - Indicates whether _offscreen rendering_ is enabled.
|
||||
|
||||
#### `contents.startPainting()`
|
||||
|
||||
If *offscreen rendering* is enabled and not painting, start painting.
|
||||
If _offscreen rendering_ is enabled and not painting, start painting.
|
||||
|
||||
#### `contents.stopPainting()`
|
||||
|
||||
If *offscreen rendering* is enabled and painting, stop painting.
|
||||
If _offscreen rendering_ is enabled and painting, stop painting.
|
||||
|
||||
#### `contents.isPainting()`
|
||||
|
||||
Returns `boolean` - If *offscreen rendering* is enabled returns whether it is currently painting.
|
||||
Returns `boolean` - If _offscreen rendering_ is enabled returns whether it is currently painting.
|
||||
|
||||
#### `contents.setFrameRate(fps)`
|
||||
|
||||
* `fps` Integer
|
||||
|
||||
If *offscreen rendering* is enabled sets the frame rate to the specified number.
|
||||
If _offscreen rendering_ is enabled sets the frame rate to the specified number.
|
||||
Only values between 1 and 240 are accepted.
|
||||
|
||||
#### `contents.getFrameRate()`
|
||||
|
||||
Returns `Integer` - If *offscreen rendering* is enabled returns the current frame rate.
|
||||
Returns `Integer` - If _offscreen rendering_ is enabled returns the current frame rate.
|
||||
|
||||
#### `contents.invalidate()`
|
||||
|
||||
Schedules a full repaint of the window this web contents is in.
|
||||
|
||||
If *offscreen rendering* is enabled invalidates the frame and generates a new
|
||||
If _offscreen rendering_ is enabled invalidates the frame and generates a new
|
||||
one through the `'paint'` event.
|
||||
|
||||
#### `contents.getWebRTCIPHandlingPolicy()`
|
||||
@@ -1910,6 +2061,24 @@ Setting the WebRTC IP handling policy allows you to control which IPs are
|
||||
exposed via WebRTC. See [BrowserLeaks](https://browserleaks.com/webrtc) for
|
||||
more details.
|
||||
|
||||
#### `contents.getWebRTCUDPPortRange()`
|
||||
|
||||
Returns `Object`:
|
||||
|
||||
* `min` Integer - The minimum UDP port number that WebRTC should use.
|
||||
* `max` Integer - The maximum UDP port number that WebRTC should use.
|
||||
|
||||
By default this value is `{ min: 0, max: 0 }` , which would apply no restriction on the udp port range.
|
||||
|
||||
#### `contents.setWebRTCUDPPortRange(udpPortRange)`
|
||||
|
||||
* `udpPortRange` Object
|
||||
* `min` Integer - The minimum UDP port number that WebRTC should use.
|
||||
* `max` Integer - The maximum UDP port number that WebRTC should use.
|
||||
|
||||
Setting the WebRTC UDP Port Range allows you to restrict the udp port range used by WebRTC. By default the port range is unrestricted.
|
||||
**Note:** To reset to an unrestricted port range this value should be set to `{ min: 0, max: 0 }`.
|
||||
|
||||
#### `contents.getMediaSourceId(requestWebContents)`
|
||||
|
||||
* `requestWebContents` WebContents - Web contents that the id will be registered to.
|
||||
@@ -2023,7 +2192,7 @@ The zoom factor is the zoom percent divided by 100, so 300% = 3.0.
|
||||
An `Integer` property that sets the frame rate of the web contents to the specified number.
|
||||
Only values between 1 and 240 are accepted.
|
||||
|
||||
Only applicable if *offscreen rendering* is enabled.
|
||||
Only applicable if _offscreen rendering_ is enabled.
|
||||
|
||||
#### `contents.id` _Readonly_
|
||||
|
||||
|
||||
@@ -128,8 +128,9 @@ For example:
|
||||
|
||||
```js
|
||||
// Main process
|
||||
const win = new BrowserWindow()
|
||||
const { port1, port2 } = new MessageChannelMain()
|
||||
webContents.mainFrame.postMessage('port', { message: 'hello' }, [port1])
|
||||
win.webContents.mainFrame.postMessage('port', { message: 'hello' }, [port1])
|
||||
|
||||
// Renderer process
|
||||
ipcRenderer.on('port', (e, msg) => {
|
||||
|
||||
@@ -96,13 +96,12 @@ with an array of misspelt words when complete.
|
||||
|
||||
An example of using [node-spellchecker][spellchecker] as provider:
|
||||
|
||||
```javascript
|
||||
```javascript @ts-expect-error=[2,6]
|
||||
const { webFrame } = require('electron')
|
||||
const spellChecker = require('spellchecker')
|
||||
webFrame.setSpellCheckProvider('en-US', {
|
||||
spellCheck (words, callback) {
|
||||
setTimeout(() => {
|
||||
const spellchecker = require('spellchecker')
|
||||
const misspelled = words.filter(x => spellchecker.isMisspelled(x))
|
||||
callback(misspelled)
|
||||
}, 0)
|
||||
|
||||
@@ -112,7 +112,7 @@ The `src` attribute can also accept data URLs, such as
|
||||
### `nodeintegration`
|
||||
|
||||
```html
|
||||
<webview src="http://www.google.com/" nodeintegration></webview>
|
||||
<webview src="https://www.google.com/" nodeintegration></webview>
|
||||
```
|
||||
|
||||
A `boolean`. When this attribute is present the guest page in `webview` will have node
|
||||
@@ -123,7 +123,7 @@ page.
|
||||
### `nodeintegrationinsubframes`
|
||||
|
||||
```html
|
||||
<webview src="http://www.google.com/" nodeintegrationinsubframes></webview>
|
||||
<webview src="https://www.google.com/" nodeintegrationinsubframes></webview>
|
||||
```
|
||||
|
||||
A `boolean` for the experimental option for enabling NodeJS support in sub-frames such as iframes
|
||||
@@ -161,7 +161,7 @@ after this script has finished executing.
|
||||
### `httpreferrer`
|
||||
|
||||
```html
|
||||
<webview src="https://www.github.com/" httpreferrer="http://cheng.guru"></webview>
|
||||
<webview src="https://www.github.com/" httpreferrer="https://example.com/"></webview>
|
||||
```
|
||||
|
||||
A `string` that sets the referrer URL for the guest page.
|
||||
@@ -184,6 +184,8 @@ page is loaded, use the `setUserAgent` method to change the user agent.
|
||||
A `boolean`. When this attribute is present the guest page will have web security disabled.
|
||||
Web security is enabled by default.
|
||||
|
||||
This value can only be modified before the first navigation.
|
||||
|
||||
### `partition`
|
||||
|
||||
```html
|
||||
@@ -253,7 +255,7 @@ The `webview` tag has the following methods:
|
||||
|
||||
**Example**
|
||||
|
||||
```javascript
|
||||
```javascript @ts-expect-error=[3]
|
||||
const webview = document.querySelector('webview')
|
||||
webview.addEventListener('dom-ready', () => {
|
||||
webview.openDevTools()
|
||||
@@ -278,9 +280,11 @@ if the page fails to load (see
|
||||
Loads the `url` in the webview, the `url` must contain the protocol prefix,
|
||||
e.g. the `http://` or `file://`.
|
||||
|
||||
### `<webview>.downloadURL(url)`
|
||||
### `<webview>.downloadURL(url[, options])`
|
||||
|
||||
* `url` string
|
||||
* `options` Object (optional)
|
||||
* `headers` Record<string, string> (optional) - HTTP request headers.
|
||||
|
||||
Initiates a download of the resource at `url` without navigating.
|
||||
|
||||
@@ -463,6 +467,10 @@ Executes editing command `cut` in page.
|
||||
|
||||
Executes editing command `copy` in page.
|
||||
|
||||
#### `<webview>.centerSelection()`
|
||||
|
||||
Centers the current text selection in page.
|
||||
|
||||
### `<webview>.paste()`
|
||||
|
||||
Executes editing command `paste` in page.
|
||||
@@ -483,6 +491,25 @@ Executes editing command `selectAll` in page.
|
||||
|
||||
Executes editing command `unselect` in page.
|
||||
|
||||
#### `<webview>.scrollToTop()`
|
||||
|
||||
Scrolls to the top of the current `<webview>`.
|
||||
|
||||
#### `<webview>.scrollToBottom()`
|
||||
|
||||
Scrolls to the bottom of the current `<webview>`.
|
||||
|
||||
#### `<webview>.adjustSelection(options)`
|
||||
|
||||
* `options` Object
|
||||
* `start` Number (optional) - Amount to shift the start index of the current selection.
|
||||
* `end` Number (optional) - Amount to shift the end index of the current selection.
|
||||
|
||||
Adjusts the current text selection starting and ending points in the focused frame by the given amounts. A negative amount moves the selection towards the beginning of the document, and a positive amount moves the selection towards the end of the document.
|
||||
|
||||
See [`webContents.adjustSelection`](web-contents.md#contentsadjustselectionoptions) for
|
||||
examples.
|
||||
|
||||
### `<webview>.replace(text)`
|
||||
|
||||
* `text` string
|
||||
@@ -576,10 +603,11 @@ Prints `webview`'s web page. Same as `webContents.print([options])`.
|
||||
* `bottom` number (optional) - Bottom margin in inches. Defaults to 1cm (~0.4 inches).
|
||||
* `left` number (optional) - Left margin in inches. Defaults to 1cm (~0.4 inches).
|
||||
* `right` number (optional) - Right margin in inches. Defaults to 1cm (~0.4 inches).
|
||||
* `pageRanges` string (optional) - Paper ranges to print, e.g., '1-5, 8, 11-13'. Defaults to the empty string, which means print all pages.
|
||||
* `pageRanges` string (optional) - Page ranges to print, e.g., '1-5, 8, 11-13'. Defaults to the empty string, which means print all pages.
|
||||
* `headerTemplate` string (optional) - HTML template for the print header. Should be valid HTML markup with following classes used to inject printing values into them: `date` (formatted print date), `title` (document title), `url` (document location), `pageNumber` (current page number) and `totalPages` (total pages in the document). For example, `<span class=title></span>` would generate span containing the title.
|
||||
* `footerTemplate` string (optional) - HTML template for the print footer. Should use the same format as the `headerTemplate`.
|
||||
* `preferCSSPageSize` boolean (optional) - Whether or not to prefer page size as defined by css. Defaults to false, in which case the content will be scaled to fit the paper size.
|
||||
* `generateTaggedPDF` boolean (optional) _Experimental_ - Whether or not to generate a tagged (accessible) PDF. Defaults to false. As this property is experimental, the generated PDF may not adhere fully to PDF/UA and WCAG standards.
|
||||
|
||||
Returns `Promise<Uint8Array>` - Resolves with the generated PDF data.
|
||||
|
||||
@@ -774,7 +802,7 @@ Fired when the guest window logs a console message.
|
||||
The following example code forwards all log messages to the embedder's console
|
||||
without regard for log level or other properties.
|
||||
|
||||
```javascript
|
||||
```javascript @ts-expect-error=[3]
|
||||
const webview = document.querySelector('webview')
|
||||
webview.addEventListener('console-message', (e) => {
|
||||
console.log('Guest page logged a message:', e.message)
|
||||
@@ -795,7 +823,7 @@ Returns:
|
||||
Fired when a result is available for
|
||||
[`webview.findInPage`](#webviewfindinpagetext-options) request.
|
||||
|
||||
```javascript
|
||||
```javascript @ts-expect-error=[3,6]
|
||||
const webview = document.querySelector('webview')
|
||||
webview.addEventListener('found-in-page', (e) => {
|
||||
webview.stopFindInPage('keepSelection')
|
||||
@@ -821,7 +849,29 @@ It is also not emitted during in-page navigation, such as clicking anchor links
|
||||
or updating the `window.location.hash`. Use `did-navigate-in-page` event for
|
||||
this purpose.
|
||||
|
||||
Calling `event.preventDefault()` does __NOT__ have any effect.
|
||||
Calling `event.preventDefault()` does **NOT** have any effect.
|
||||
|
||||
### Event: 'will-frame-navigate'
|
||||
|
||||
Returns:
|
||||
|
||||
* `url` string
|
||||
* `isMainFrame` boolean
|
||||
* `frameProcessId` Integer
|
||||
* `frameRoutingId` Integer
|
||||
|
||||
Emitted when a user or the page wants to start navigation anywhere in the `<webview>`
|
||||
or any frames embedded within. It can happen when the `window.location` object is
|
||||
changed or a user clicks a link in the page.
|
||||
|
||||
This event will not emit when the navigation is started programmatically with
|
||||
APIs like `<webview>.loadURL` and `<webview>.back`.
|
||||
|
||||
It is also not emitted during in-page navigation, such as clicking anchor links
|
||||
or updating the `window.location.hash`. Use `did-navigate-in-page` event for
|
||||
this purpose.
|
||||
|
||||
Calling `event.preventDefault()` does **NOT** have any effect.
|
||||
|
||||
### Event: 'did-start-navigation'
|
||||
|
||||
@@ -898,7 +948,7 @@ Fired when the guest page attempts to close itself.
|
||||
The following example code navigates the `webview` to `about:blank` when the
|
||||
guest attempts to close itself.
|
||||
|
||||
```javascript
|
||||
```javascript @ts-expect-error=[3]
|
||||
const webview = document.querySelector('webview')
|
||||
webview.addEventListener('close', () => {
|
||||
webview.src = 'about:blank'
|
||||
@@ -918,7 +968,7 @@ Fired when the guest page has sent an asynchronous message to embedder page.
|
||||
With `sendToHost` method and `ipc-message` event you can communicate
|
||||
between guest page and embedder page:
|
||||
|
||||
```javascript
|
||||
```javascript @ts-expect-error=[4,7]
|
||||
// In embedder page.
|
||||
const webview = document.querySelector('webview')
|
||||
webview.addEventListener('ipc-message', (event) => {
|
||||
@@ -936,9 +986,22 @@ ipcRenderer.on('ping', () => {
|
||||
})
|
||||
```
|
||||
|
||||
### Event: 'crashed'
|
||||
### Event: 'crashed' _Deprecated_
|
||||
|
||||
Fired when the renderer process is crashed.
|
||||
Fired when the renderer process 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.
|
||||
|
||||
### Event: 'render-process-gone'
|
||||
|
||||
Returns:
|
||||
|
||||
* `details` [RenderProcessGoneDetails](structures/render-process-gone-details.md)
|
||||
|
||||
Fired when the renderer process unexpectedly disappears. This is normally
|
||||
because it was crashed or killed.
|
||||
|
||||
### Event: 'plugin-crashed'
|
||||
|
||||
@@ -1001,7 +1064,7 @@ Emitted when DevTools is closed.
|
||||
|
||||
Emitted when DevTools is focused / opened.
|
||||
|
||||
[runtime-enabled-features]: https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/runtime_enabled_features.json5?l=70
|
||||
[runtime-enabled-features]: https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/platform/runtime_enabled_features.json5
|
||||
[chrome-webview]: https://developer.chrome.com/docs/extensions/reference/webviewTag/
|
||||
|
||||
### Event: 'context-menu'
|
||||
@@ -1044,7 +1107,7 @@ Returns:
|
||||
* `frameCharset` string - The character encoding of the frame on which the
|
||||
menu was invoked.
|
||||
* `inputFieldType` string - If the context menu was invoked on an input
|
||||
field, the type of that field. Possible values are `none`, `plainText`,
|
||||
field, the type of that field. Possible values include `none`, `plainText`,
|
||||
`password`, `other`.
|
||||
* `spellcheckEnabled` boolean - If the context is editable, whether or not spellchecking is enabled.
|
||||
* `menuSourceType` string - Input source that invoked the context menu.
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user