mirror of
https://github.com/electron/electron.git
synced 2026-02-26 03:01:17 -05:00
Compare commits
322 Commits
refactor/a
...
v36.7.3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0af4b6c1ed | ||
|
|
a2d43f4a39 | ||
|
|
b180cfee6c | ||
|
|
4a81ae7954 | ||
|
|
ef9212a112 | ||
|
|
1c0cec1872 | ||
|
|
440fb9a73e | ||
|
|
8c974c022a | ||
|
|
ea4d43d59e | ||
|
|
d4ccd31264 | ||
|
|
d342296f81 | ||
|
|
3c75d600bf | ||
|
|
9d7adf22af | ||
|
|
8c747d82e1 | ||
|
|
99cda5805d | ||
|
|
4e86467751 | ||
|
|
f4bc4c2999 | ||
|
|
b4a439fb4f | ||
|
|
ed82dba57e | ||
|
|
3c396a674e | ||
|
|
1169e25f9d | ||
|
|
c9c4c36a72 | ||
|
|
e39cf315dc | ||
|
|
ceefcd1d32 | ||
|
|
729ceb4360 | ||
|
|
fd131e30aa | ||
|
|
da2f4eb2a9 | ||
|
|
37be7b0f63 | ||
|
|
387394e084 | ||
|
|
668ded5ea3 | ||
|
|
78f78bf8be | ||
|
|
5eb6cec6e9 | ||
|
|
bddc661684 | ||
|
|
33d23f5e00 | ||
|
|
e90282d57a | ||
|
|
13ceef30b7 | ||
|
|
c2a3d240c3 | ||
|
|
d4a93c896d | ||
|
|
cd42e9ba05 | ||
|
|
c15c6d9118 | ||
|
|
2d9cb53a86 | ||
|
|
abda6bfda5 | ||
|
|
20dc3dbc3a | ||
|
|
f9cba35a25 | ||
|
|
8d2654c47e | ||
|
|
e98530ab7d | ||
|
|
573c8aa656 | ||
|
|
ddee51eb9e | ||
|
|
351e6e36f4 | ||
|
|
55557dd3a6 | ||
|
|
5e9f4eaa3c | ||
|
|
e3939f2e60 | ||
|
|
cac475579e | ||
|
|
47caba64ab | ||
|
|
15e536b14b | ||
|
|
b328de39e5 | ||
|
|
ec1704a1dd | ||
|
|
a997e6e53a | ||
|
|
bb09671746 | ||
|
|
b66cc92391 | ||
|
|
a0633d9e25 | ||
|
|
92dd952757 | ||
|
|
8e93599b53 | ||
|
|
62fbb1d67a | ||
|
|
63c7215cd1 | ||
|
|
2336cd67b7 | ||
|
|
492589670b | ||
|
|
8988a372da | ||
|
|
2a707ffbd8 | ||
|
|
1487f5d8b4 | ||
|
|
d647bb4bd0 | ||
|
|
6e22f50bf8 | ||
|
|
14ba395d45 | ||
|
|
dd054ea748 | ||
|
|
3da28fd115 | ||
|
|
45542e197b | ||
|
|
6a884abe6b | ||
|
|
0c226d8d79 | ||
|
|
38e990c6e0 | ||
|
|
5bfea79b67 | ||
|
|
1c132a3fdb | ||
|
|
9b624e143e | ||
|
|
fc2df39c33 | ||
|
|
bbb000e896 | ||
|
|
5d098dfc82 | ||
|
|
0755f426c6 | ||
|
|
a4c32b1f3d | ||
|
|
15ff33a92c | ||
|
|
2d71d65415 | ||
|
|
a4dfd9b6f3 | ||
|
|
6dea52b6c0 | ||
|
|
cadaaaf714 | ||
|
|
ef6a71a0c6 | ||
|
|
6350b7535f | ||
|
|
577ea02d64 | ||
|
|
ef9a67e00b | ||
|
|
0bd0c54cea | ||
|
|
7d73997d5f | ||
|
|
8f908ffce2 | ||
|
|
ae232703de | ||
|
|
747b2f62e0 | ||
|
|
6eac8d8af9 | ||
|
|
4f9bca79d3 | ||
|
|
12528c6739 | ||
|
|
9c3331ea83 | ||
|
|
6a0e31633a | ||
|
|
8b2b155c5d | ||
|
|
de81d8a4a6 | ||
|
|
748977b1d8 | ||
|
|
bc553af826 | ||
|
|
615b65b2a2 | ||
|
|
7030816fe1 | ||
|
|
f5bb2f480d | ||
|
|
07c0357366 | ||
|
|
c7d9fb602e | ||
|
|
be43a76440 | ||
|
|
de7cf88f17 | ||
|
|
12dd4d91bd | ||
|
|
3c9e7f97a1 | ||
|
|
b822478057 | ||
|
|
366daf192a | ||
|
|
7779b6a4ad | ||
|
|
695448e142 | ||
|
|
fdc322c93f | ||
|
|
13fe994d0d | ||
|
|
7240a14126 | ||
|
|
3f23f01762 | ||
|
|
5223225fb5 | ||
|
|
5045ba29a5 | ||
|
|
c27bd7bb3c | ||
|
|
aada99e53d | ||
|
|
1b596f6261 | ||
|
|
bac01a33cd | ||
|
|
bb4ab67e52 | ||
|
|
17e1ff2675 | ||
|
|
1687b95849 | ||
|
|
3d4a4b9343 | ||
|
|
c24f330b45 | ||
|
|
ee65ab75f5 | ||
|
|
77b945dd0a | ||
|
|
643b35503f | ||
|
|
98380468bb | ||
|
|
069ca16b9e | ||
|
|
dcd8224c15 | ||
|
|
65081e8939 | ||
|
|
6bb07bf277 | ||
|
|
698bff0efa | ||
|
|
34adb976b6 | ||
|
|
5c2f70c1d5 | ||
|
|
3981c173ef | ||
|
|
61d6872dcf | ||
|
|
1a797beeea | ||
|
|
66f55ead4e | ||
|
|
108fdac02c | ||
|
|
d52670c749 | ||
|
|
5dab95335b | ||
|
|
c4302ab58c | ||
|
|
197444181d | ||
|
|
02e4e109d5 | ||
|
|
08a4c333a3 | ||
|
|
5a4ef1cc33 | ||
|
|
4e8c09f46a | ||
|
|
fc319e0ea3 | ||
|
|
2629b31c19 | ||
|
|
11c820c537 | ||
|
|
07a7ebb714 | ||
|
|
b0d4c12247 | ||
|
|
8f40f8126e | ||
|
|
b821cf1adc | ||
|
|
3f8340d9f3 | ||
|
|
0e30f5e2a1 | ||
|
|
fdc6a3b108 | ||
|
|
3348ac08b4 | ||
|
|
e8188ef271 | ||
|
|
2960f93ea5 | ||
|
|
361753f61f | ||
|
|
ec75ddd715 | ||
|
|
301f7b4e64 | ||
|
|
7b66361ca8 | ||
|
|
f8a55100cc | ||
|
|
c785b40703 | ||
|
|
339e0040ef | ||
|
|
e825107f8a | ||
|
|
53633fcaeb | ||
|
|
285d347b51 | ||
|
|
a2ee5547e0 | ||
|
|
b518e4ad36 | ||
|
|
9d3696e4b3 | ||
|
|
22b6eefc50 | ||
|
|
70fd706ea4 | ||
|
|
8b3c52f242 | ||
|
|
33fafd508c | ||
|
|
28eb0e6f3d | ||
|
|
b234733555 | ||
|
|
ffb4f0f812 | ||
|
|
33964528e1 | ||
|
|
4f54c91ee2 | ||
|
|
3fdcd38b8b | ||
|
|
feaa9ec5b9 | ||
|
|
de933233e6 | ||
|
|
1046842f73 | ||
|
|
2dd4b77ae0 | ||
|
|
5942ac580b | ||
|
|
ec34d8ee49 | ||
|
|
64c9afcf77 | ||
|
|
4392cb9434 | ||
|
|
c3b5e5527f | ||
|
|
31e3c84843 | ||
|
|
42514326ca | ||
|
|
7be433c0b7 | ||
|
|
c92412761d | ||
|
|
4e3baa4d8e | ||
|
|
10fb533bc3 | ||
|
|
3d8df7684b | ||
|
|
5a6ed32592 | ||
|
|
99c3728a93 | ||
|
|
e0a24f08a1 | ||
|
|
0cb42911ea | ||
|
|
8fec7adfa6 | ||
|
|
30ccda8ba0 | ||
|
|
3acd5774da | ||
|
|
a0ac690881 | ||
|
|
7299dd1501 | ||
|
|
92b03cb91f | ||
|
|
01ce103ae1 | ||
|
|
58b2c2e651 | ||
|
|
4db5a2a2b2 | ||
|
|
6126cc2bfe | ||
|
|
33eff16e9a | ||
|
|
e2b9cedf0f | ||
|
|
75e44e5f05 | ||
|
|
71e53c925e | ||
|
|
17487df08d | ||
|
|
6b1d1bf893 | ||
|
|
8327ed0eea | ||
|
|
7e80e8f610 | ||
|
|
33df588e8e | ||
|
|
45c78deff8 | ||
|
|
b647c8935d | ||
|
|
11c35626da | ||
|
|
f78a66d988 | ||
|
|
200550da3c | ||
|
|
cb7335b4f0 | ||
|
|
b4fc140f1a | ||
|
|
c89bebdee1 | ||
|
|
4df1063e30 | ||
|
|
8b05b6e59b | ||
|
|
71f17fcf5b | ||
|
|
bf87315ae8 | ||
|
|
dde045db9c | ||
|
|
3ff5c4ea5f | ||
|
|
32c352bff5 | ||
|
|
3e2aa2f443 | ||
|
|
12d11c09a1 | ||
|
|
06ad763412 | ||
|
|
5b9f71602d | ||
|
|
bb882b4f3d | ||
|
|
9efacb6147 | ||
|
|
5cddcdf190 | ||
|
|
25e5055065 | ||
|
|
6f3c9fcf99 | ||
|
|
7ee88bbdcb | ||
|
|
96197d9597 | ||
|
|
7d2c27c83e | ||
|
|
32a341288c | ||
|
|
2466232460 | ||
|
|
a5579fb71f | ||
|
|
76fa5b7af1 | ||
|
|
e1b2b8ef0c | ||
|
|
243016b31e | ||
|
|
5f0be2e153 | ||
|
|
6d2c7c2ab3 | ||
|
|
c4e0cae3ee | ||
|
|
7e0d84f19c | ||
|
|
dea35330c0 | ||
|
|
7f85c85b71 | ||
|
|
4b0d49898f | ||
|
|
6927f649ee | ||
|
|
33bde96d73 | ||
|
|
3772e267c3 | ||
|
|
b7a28f31d8 | ||
|
|
1ba56c8696 | ||
|
|
cee2c2ceeb | ||
|
|
b3526da28e | ||
|
|
d23aaadcd5 | ||
|
|
ef22986d1d | ||
|
|
b0d207e384 | ||
|
|
1424da9131 | ||
|
|
29ead1bc25 | ||
|
|
859cff24ec | ||
|
|
0ba2441963 | ||
|
|
7ea2daf456 | ||
|
|
bc9389df9a | ||
|
|
9716b6623e | ||
|
|
56fced3d0d | ||
|
|
3faedae91c | ||
|
|
463e0d0ab7 | ||
|
|
c5310fff80 | ||
|
|
4b72738b41 | ||
|
|
585075d776 | ||
|
|
c87fd357fc | ||
|
|
a1ec212049 | ||
|
|
a3af41674f | ||
|
|
5c73799f52 | ||
|
|
8275f7e402 | ||
|
|
0ea8decb0a | ||
|
|
515f5847e1 | ||
|
|
1fc3a60655 | ||
|
|
3e5cabde39 | ||
|
|
98adbbb593 | ||
|
|
c62db7d49d | ||
|
|
313aee6cbb | ||
|
|
9f0fb54918 | ||
|
|
c39683b2cb | ||
|
|
0e8300399d | ||
|
|
ca91235c51 | ||
|
|
f90de88c63 | ||
|
|
d41ed8a118 | ||
|
|
daa37826f8 | ||
|
|
e74e1ab4c5 | ||
|
|
7d0f24420f | ||
|
|
d1663a5ac6 |
@@ -2,7 +2,7 @@ version: '3'
|
|||||||
|
|
||||||
services:
|
services:
|
||||||
buildtools:
|
buildtools:
|
||||||
image: ghcr.io/electron/devcontainer:77262e58c37631ab082482f42c33cdf68c6c394b
|
image: ghcr.io/electron/devcontainer:424eedbf277ad9749ffa9219068aa72ed4a5e373
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
- ..:/workspaces/gclient/src/electron:cached
|
- ..:/workspaces/gclient/src/electron:cached
|
||||||
|
|||||||
2
.github/PULL_REQUEST_TEMPLATE.md
vendored
2
.github/PULL_REQUEST_TEMPLATE.md
vendored
@@ -13,7 +13,7 @@ Contributors guide: https://github.com/electron/electron/blob/main/CONTRIBUTING.
|
|||||||
- [ ] PR description included and stakeholders cc'd
|
- [ ] PR description included and stakeholders cc'd
|
||||||
- [ ] `npm test` passes
|
- [ ] `npm test` passes
|
||||||
- [ ] tests are [changed or added](https://github.com/electron/electron/blob/main/docs/development/testing.md)
|
- [ ] tests are [changed or added](https://github.com/electron/electron/blob/main/docs/development/testing.md)
|
||||||
- [ ] relevant documentation, tutorials, templates and examples are changed or added
|
- [ ] relevant API documentation, tutorials, and examples are updated and follow the [documentation style guide](https://github.com/electron/electron/blob/main/docs/development/style-guide.md)
|
||||||
- [ ] [PR release notes](https://github.com/electron/clerk/blob/main/README.md) describe the change in a way relevant to app developers, and are [capitalized, punctuated, and past tense](https://github.com/electron/clerk/blob/main/README.md#examples).
|
- [ ] [PR release notes](https://github.com/electron/clerk/blob/main/README.md) describe the change in a way relevant to app developers, and are [capitalized, punctuated, and past tense](https://github.com/electron/clerk/blob/main/README.md#examples).
|
||||||
|
|
||||||
#### Release Notes
|
#### Release Notes
|
||||||
|
|||||||
14
.github/actions/build-electron/action.yml
vendored
14
.github/actions/build-electron/action.yml
vendored
@@ -38,6 +38,15 @@ runs:
|
|||||||
run: |
|
run: |
|
||||||
GN_APPENDED_ARGS="$GN_EXTRA_ARGS target_cpu=\"x64\" v8_snapshot_toolchain=\"//build/toolchain/mac:clang_x64\""
|
GN_APPENDED_ARGS="$GN_EXTRA_ARGS target_cpu=\"x64\" v8_snapshot_toolchain=\"//build/toolchain/mac:clang_x64\""
|
||||||
echo "GN_EXTRA_ARGS=$GN_APPENDED_ARGS" >> $GITHUB_ENV
|
echo "GN_EXTRA_ARGS=$GN_APPENDED_ARGS" >> $GITHUB_ENV
|
||||||
|
- name: Set GN_EXTRA_ARGS for Windows
|
||||||
|
shell: bash
|
||||||
|
if: ${{inputs.target-arch != 'x64' && inputs.target-platform == 'win' }}
|
||||||
|
run: |
|
||||||
|
GN_APPENDED_ARGS="$GN_EXTRA_ARGS target_cpu=\"${{ inputs.target-arch }}\""
|
||||||
|
echo "GN_EXTRA_ARGS=$GN_APPENDED_ARGS" >> $GITHUB_ENV
|
||||||
|
- name: Add Clang problem matcher
|
||||||
|
shell: bash
|
||||||
|
run: echo "::add-matcher::src/electron/.github/problem-matchers/clang.json"
|
||||||
- name: Build Electron ${{ inputs.step-suffix }}
|
- name: Build Electron ${{ inputs.step-suffix }}
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
@@ -181,8 +190,8 @@ runs:
|
|||||||
electron/script/zip-symbols.py -b $BUILD_PATH
|
electron/script/zip-symbols.py -b $BUILD_PATH
|
||||||
fi
|
fi
|
||||||
- name: Generate FFMpeg ${{ inputs.step-suffix }}
|
- name: Generate FFMpeg ${{ inputs.step-suffix }}
|
||||||
shell: bash
|
|
||||||
if: ${{ inputs.is-release == 'true' }}
|
if: ${{ inputs.is-release == 'true' }}
|
||||||
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
cd src
|
cd src
|
||||||
gn gen out/ffmpeg --args="import(\"//electron/build/args/ffmpeg.gn\") use_remoteexec=true $GN_EXTRA_ARGS"
|
gn gen out/ffmpeg --args="import(\"//electron/build/args/ffmpeg.gn\") use_remoteexec=true $GN_EXTRA_ARGS"
|
||||||
@@ -199,6 +208,9 @@ runs:
|
|||||||
e build --target electron:libcxx_headers_zip -j $NUMBER_OF_NINJA_PROCESSES
|
e build --target electron:libcxx_headers_zip -j $NUMBER_OF_NINJA_PROCESSES
|
||||||
e build --target electron:libcxxabi_headers_zip -j $NUMBER_OF_NINJA_PROCESSES
|
e build --target electron:libcxxabi_headers_zip -j $NUMBER_OF_NINJA_PROCESSES
|
||||||
e build --target electron:libcxx_objects_zip -j $NUMBER_OF_NINJA_PROCESSES
|
e build --target electron:libcxx_objects_zip -j $NUMBER_OF_NINJA_PROCESSES
|
||||||
|
- name: Remove Clang problem matcher
|
||||||
|
shell: bash
|
||||||
|
run: echo "::remove-matcher owner=clang::"
|
||||||
- name: Generate TypeScript Definitions ${{ inputs.step-suffix }}
|
- name: Generate TypeScript Definitions ${{ inputs.step-suffix }}
|
||||||
if: ${{ inputs.is-release == 'true' }}
|
if: ${{ inputs.is-release == 'true' }}
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|||||||
83
.github/actions/build-git-cache/action.yml
vendored
Normal file
83
.github/actions/build-git-cache/action.yml
vendored
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
name: 'Build Git Cache'
|
||||||
|
description: 'Runs a gclient sync to build the git cache for Electron'
|
||||||
|
inputs:
|
||||||
|
target-platform:
|
||||||
|
description: 'Target platform, should be linux, win, macos'
|
||||||
|
runs:
|
||||||
|
using: "composite"
|
||||||
|
steps:
|
||||||
|
- name: Set GIT_CACHE_PATH to make gclient to use the cache
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
echo "GIT_CACHE_PATH=$(pwd)/git-cache" >> $GITHUB_ENV
|
||||||
|
- name: Set Chromium Git Cookie
|
||||||
|
uses: ./src/electron/.github/actions/set-chromium-cookie
|
||||||
|
- name: Install Build Tools
|
||||||
|
uses: ./src/electron/.github/actions/install-build-tools
|
||||||
|
- name: Set up cache drive
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
if [ "${{ inputs.target-platform }}" = "win" ]; then
|
||||||
|
echo "CACHE_DRIVE=/mnt/win-cache" >> $GITHUB_ENV
|
||||||
|
else
|
||||||
|
echo "CACHE_DRIVE=/mnt/cross-instance-cache" >> $GITHUB_ENV
|
||||||
|
fi
|
||||||
|
- name: Check cross instance cache disk space
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
# if there is less than 35 GB free space then creating the cache might fail so exit early
|
||||||
|
freespace=`df -m $CACHE_DRIVE | grep -w $CACHE_DRIVE | awk '{print $4}'`
|
||||||
|
freespace_human=`df -h $CACHE_DRIVE | grep -w $CACHE_DRIVE | awk '{print $4}'`
|
||||||
|
if [ $freespace -le 35000 ]; then
|
||||||
|
echo "The cross mount cache has $freespace_human free space which is not enough - exiting"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "The cross mount cache has $freespace_human free space - continuing"
|
||||||
|
fi
|
||||||
|
- name: Restore gitcache
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
GIT_CACHE_TAR="$CACHE_DRIVE/gitcache.tar"
|
||||||
|
if [ ! -f "$GIT_CACHE_TAR" ]; then
|
||||||
|
echo "Git cache tar file does not exist, skipping restore"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
echo "Restoring git cache from $GIT_CACHE_TAR to $GIT_CACHE_PATH"
|
||||||
|
mkdir -p $GIT_CACHE_PATH
|
||||||
|
tar -xf $GIT_CACHE_TAR -C $GIT_CACHE_PATH
|
||||||
|
- name: Gclient Sync
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
e d gclient config \
|
||||||
|
--name "src/electron" \
|
||||||
|
--unmanaged \
|
||||||
|
${GCLIENT_EXTRA_ARGS} \
|
||||||
|
"$GITHUB_SERVER_URL/$GITHUB_REPOSITORY"
|
||||||
|
|
||||||
|
if [ "$TARGET_OS" != "" ]; then
|
||||||
|
echo "target_os=['$TARGET_OS']" >> ./.gclient
|
||||||
|
fi
|
||||||
|
|
||||||
|
ELECTRON_USE_THREE_WAY_MERGE_FOR_PATCHES=1 e d gclient sync --with_branch_heads --with_tags --nohooks -vv
|
||||||
|
- name: Compress Git Cache Directory
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
echo "Uncompressed gitcache size: $(du -sh $GIT_CACHE_PATH | cut -f1 -d' ')"
|
||||||
|
cd $GIT_CACHE_PATH
|
||||||
|
tar -cf ../gitcache.tar .
|
||||||
|
cd ..
|
||||||
|
echo "Compressed gitcache to $(du -sh gitcache.tar | cut -f1 -d' ')"
|
||||||
|
# remove the old cache file if it exists
|
||||||
|
if [ -f $CACHE_DRIVE/gitcache.tar ]; then
|
||||||
|
echo "Removing old gitcache.tar from $CACHE_DRIVE"
|
||||||
|
rm $CACHE_DRIVE/gitcache.tar
|
||||||
|
fi
|
||||||
|
cp ./gitcache.tar $CACHE_DRIVE/
|
||||||
|
- name: Wait for active SSH sessions
|
||||||
|
shell: bash
|
||||||
|
if: always() && !cancelled()
|
||||||
|
run: |
|
||||||
|
while [ -f /var/.ssh-lock ]
|
||||||
|
do
|
||||||
|
sleep 60
|
||||||
|
done
|
||||||
97
.github/actions/checkout/action.yml
vendored
97
.github/actions/checkout/action.yml
vendored
@@ -9,6 +9,8 @@ inputs:
|
|||||||
description: 'Whether to persist the cache to the shared drive'
|
description: 'Whether to persist the cache to the shared drive'
|
||||||
required: false
|
required: false
|
||||||
default: 'true'
|
default: 'true'
|
||||||
|
target-platform:
|
||||||
|
description: 'Target platform, should be linux, win, macos'
|
||||||
runs:
|
runs:
|
||||||
using: "composite"
|
using: "composite"
|
||||||
steps:
|
steps:
|
||||||
@@ -18,40 +20,34 @@ runs:
|
|||||||
echo "GIT_CACHE_PATH=$(pwd)/git-cache" >> $GITHUB_ENV
|
echo "GIT_CACHE_PATH=$(pwd)/git-cache" >> $GITHUB_ENV
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
uses: ./src/electron/.github/actions/install-dependencies
|
uses: ./src/electron/.github/actions/install-dependencies
|
||||||
- name: Install Build Tools
|
|
||||||
uses: ./src/electron/.github/actions/install-build-tools
|
|
||||||
- name: Set Chromium Git Cookie
|
- name: Set Chromium Git Cookie
|
||||||
uses: ./src/electron/.github/actions/set-chromium-cookie
|
uses: ./src/electron/.github/actions/set-chromium-cookie
|
||||||
- name: Get Depot Tools
|
- name: Install Build Tools
|
||||||
shell: bash
|
uses: ./src/electron/.github/actions/install-build-tools
|
||||||
run: |
|
|
||||||
if [[ ! -d depot_tools ]]; then
|
|
||||||
git clone --depth=1 https://chromium.googlesource.com/chromium/tools/depot_tools.git
|
|
||||||
|
|
||||||
# Ensure depot_tools does not update.
|
|
||||||
test -d depot_tools && cd depot_tools
|
|
||||||
touch .disable_auto_update
|
|
||||||
fi
|
|
||||||
- name: Add Depot Tools to PATH
|
|
||||||
shell: bash
|
|
||||||
run: echo "$(pwd)/depot_tools" >> $GITHUB_PATH
|
|
||||||
- name: Generate DEPS Hash
|
- name: Generate DEPS Hash
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
node src/electron/script/generate-deps-hash.js
|
node src/electron/script/generate-deps-hash.js
|
||||||
echo "DEPSHASH=v1-src-cache-$(cat src/electron/.depshash)" >> $GITHUB_ENV
|
DEPSHASH="v1-src-cache-$(cat src/electron/.depshash)"
|
||||||
|
echo "DEPSHASH=$DEPSHASH" >> $GITHUB_ENV
|
||||||
|
echo "CACHE_FILE=$DEPSHASH.tar" >> $GITHUB_ENV
|
||||||
|
if [ "${{ inputs.target-platform }}" = "win" ]; then
|
||||||
|
echo "CACHE_DRIVE=/mnt/win-cache" >> $GITHUB_ENV
|
||||||
|
else
|
||||||
|
echo "CACHE_DRIVE=/mnt/cross-instance-cache" >> $GITHUB_ENV
|
||||||
|
fi
|
||||||
- name: Generate SAS Key
|
- name: Generate SAS Key
|
||||||
if: ${{ inputs.generate-sas-token == 'true' }}
|
if: ${{ inputs.generate-sas-token == 'true' }}
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
curl --unix-socket /var/run/sas/sas.sock --fail "http://foo/$DEPSHASH.tar" > sas-token
|
curl --unix-socket /var/run/sas/sas.sock --fail "http://foo/$CACHE_FILE?platform=${{ inputs.target-platform }}" > sas-token
|
||||||
- name: Save SAS Key
|
- name: Save SAS Key
|
||||||
if: ${{ inputs.generate-sas-token == 'true' }}
|
if: ${{ inputs.generate-sas-token == 'true' }}
|
||||||
uses: actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57
|
uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
|
||||||
with:
|
with:
|
||||||
path: |
|
path: sas-token
|
||||||
sas-token
|
key: sas-key-${{ inputs.target-platform }}-${{ github.run_number }}-${{ github.run_attempt }}
|
||||||
key: sas-key-${{ github.run_number }}-${{ github.run_attempt }}
|
enableCrossOsArchive: true
|
||||||
- name: Check If Cache Exists
|
- name: Check If Cache Exists
|
||||||
id: check-cache
|
id: check-cache
|
||||||
shell: bash
|
shell: bash
|
||||||
@@ -60,7 +56,7 @@ runs:
|
|||||||
echo "Not using cache this time..."
|
echo "Not using cache this time..."
|
||||||
echo "cache_exists=false" >> $GITHUB_OUTPUT
|
echo "cache_exists=false" >> $GITHUB_OUTPUT
|
||||||
else
|
else
|
||||||
cache_path=/mnt/cross-instance-cache/$DEPSHASH.tar
|
cache_path=$CACHE_DRIVE/$CACHE_FILE
|
||||||
echo "Using cache key: $DEPSHASH"
|
echo "Using cache key: $DEPSHASH"
|
||||||
echo "Checking for cache in: $cache_path"
|
echo "Checking for cache in: $cache_path"
|
||||||
if [ ! -f "$cache_path" ] || [ `du $cache_path | cut -f1` = "0" ]; then
|
if [ ! -f "$cache_path" ] || [ `du $cache_path | cut -f1` = "0" ]; then
|
||||||
@@ -76,14 +72,29 @@ runs:
|
|||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
# if there is less than 35 GB free space then creating the cache might fail so exit early
|
# if there is less than 35 GB free space then creating the cache might fail so exit early
|
||||||
freespace=`df -m /mnt/cross-instance-cache | grep -w /mnt/cross-instance-cache | awk '{print $4}'`
|
freespace=`df -m $CACHE_DRIVE | grep -w $CACHE_DRIVE | awk '{print $4}'`
|
||||||
freespace_human=`df -h /mnt/cross-instance-cache | grep -w /mnt/cross-instance-cache | awk '{print $4}'`
|
freespace_human=`df -h $CACHE_DRIVE | grep -w $CACHE_DRIVE | awk '{print $4}'`
|
||||||
if [ $freespace -le 35000 ]; then
|
if [ $freespace -le 35000 ]; then
|
||||||
echo "The cross mount cache has $freespace_human free space which is not enough - exiting"
|
echo "The cross mount cache has $freespace_human free space which is not enough - exiting"
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
echo "The cross mount cache has $freespace_human free space - continuing"
|
echo "The cross mount cache has $freespace_human free space - continuing"
|
||||||
fi
|
fi
|
||||||
|
- name: Add patch conflict problem matcher
|
||||||
|
shell: bash
|
||||||
|
run: echo "::add-matcher::src/electron/.github/problem-matchers/patch-conflict.json"
|
||||||
|
- name: Restore gitcache
|
||||||
|
if: steps.check-cache.outputs.cache_exists == 'false'
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
GIT_CACHE_TAR="$CACHE_DRIVE/gitcache.tar"
|
||||||
|
if [ ! -f "$GIT_CACHE_TAR" ]; then
|
||||||
|
echo "Git cache tar file does not exist, skipping restore"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
echo "Restoring git cache from $GIT_CACHE_TAR to $GIT_CACHE_PATH"
|
||||||
|
mkdir -p $GIT_CACHE_PATH
|
||||||
|
tar -xf $GIT_CACHE_TAR -C $GIT_CACHE_PATH
|
||||||
- name: Gclient Sync
|
- name: Gclient Sync
|
||||||
if: steps.check-cache.outputs.cache_exists == 'false'
|
if: steps.check-cache.outputs.cache_exists == 'false'
|
||||||
shell: bash
|
shell: bash
|
||||||
@@ -99,19 +110,14 @@ runs:
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
ELECTRON_USE_THREE_WAY_MERGE_FOR_PATCHES=1 e d gclient sync --with_branch_heads --with_tags -vv
|
ELECTRON_USE_THREE_WAY_MERGE_FOR_PATCHES=1 e d gclient sync --with_branch_heads --with_tags -vv
|
||||||
if [ "${{ inputs.is-release }}" != "true" && -n "${{ env.PATCH_UP_APP_CREDS }}" ]; then
|
if [[ "${{ inputs.is-release }}" != "true" ]]; then
|
||||||
# Re-export all the patches to check if there were changes.
|
# Re-export all the patches to check if there were changes.
|
||||||
python3 src/electron/script/export_all_patches.py src/electron/patches/config.json
|
python3 src/electron/script/export_all_patches.py src/electron/patches/config.json
|
||||||
cd src/electron
|
cd src/electron
|
||||||
git update-index --refresh || true
|
git update-index --refresh || true
|
||||||
if ! git diff-index --quiet HEAD --; then
|
if ! git diff-index --quiet HEAD --; then
|
||||||
# There are changes to the patches. Make a git commit with the updated patches
|
# There are changes to the patches. Make a git commit with the updated patches
|
||||||
git add patches
|
if node ./script/patch-up.js; then
|
||||||
GIT_COMMITTER_NAME="PatchUp" GIT_COMMITTER_EMAIL="73610968+patchup[bot]@users.noreply.github.com" git commit -m "chore: update patches" --author="PatchUp <73610968+patchup[bot]@users.noreply.github.com>"
|
|
||||||
# Export it
|
|
||||||
mkdir -p ../../patches
|
|
||||||
git format-patch -1 --stdout --keep-subject --no-stat --full-index > ../../patches/update-patches.patch
|
|
||||||
if node ./script/push-patch.js; then
|
|
||||||
echo
|
echo
|
||||||
echo "======================================================================"
|
echo "======================================================================"
|
||||||
echo "Changes to the patches when applying, we have auto-pushed the diff to the current branch"
|
echo "Changes to the patches when applying, we have auto-pushed the diff to the current branch"
|
||||||
@@ -119,6 +125,11 @@ runs:
|
|||||||
echo "======================================================================"
|
echo "======================================================================"
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
|
git add patches
|
||||||
|
GIT_COMMITTER_NAME="PatchUp" GIT_COMMITTER_EMAIL="73610968+patchup[bot]@users.noreply.github.com" git commit -m "chore: update patches" --author="PatchUp <73610968+patchup[bot]@users.noreply.github.com>"
|
||||||
|
# Export it
|
||||||
|
mkdir -p ../../patches
|
||||||
|
git format-patch -1 --stdout --keep-subject --no-stat --full-index > ../../patches/update-patches.patch
|
||||||
echo
|
echo
|
||||||
echo "======================================================================"
|
echo "======================================================================"
|
||||||
echo "There were changes to the patches when applying."
|
echo "There were changes to the patches when applying."
|
||||||
@@ -128,9 +139,15 @@ runs:
|
|||||||
cat ../../patches/update-patches.patch
|
cat ../../patches/update-patches.patch
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
echo "No changes to patches detected"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
- name: Remove patch conflict problem matcher
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
echo "::remove-matcher owner=merge-conflict::"
|
||||||
|
echo "::remove-matcher owner=patch-conflict::"
|
||||||
# delete all .git directories under src/ except for
|
# delete all .git directories under src/ except for
|
||||||
# third_party/angle/ and third_party/dawn/ because of build time generation of files
|
# third_party/angle/ and third_party/dawn/ because of build time generation of files
|
||||||
# gen/angle/commit.h depends on third_party/angle/.git/HEAD
|
# gen/angle/commit.h depends on third_party/angle/.git/HEAD
|
||||||
@@ -165,14 +182,14 @@ runs:
|
|||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
echo "Uncompressed src size: $(du -sh src | cut -f1 -d' ')"
|
echo "Uncompressed src size: $(du -sh src | cut -f1 -d' ')"
|
||||||
tar -cf $DEPSHASH.tar src
|
tar -cf $CACHE_FILE src
|
||||||
echo "Compressed src to $(du -sh $DEPSHASH.tar | cut -f1 -d' ')"
|
echo "Compressed src to $(du -sh $CACHE_FILE | cut -f1 -d' ')"
|
||||||
cp ./$DEPSHASH.tar /mnt/cross-instance-cache/
|
cp ./$CACHE_FILE $CACHE_DRIVE/
|
||||||
- name: Persist Src Cache
|
- name: Persist Src Cache
|
||||||
if: ${{ steps.check-cache.outputs.cache_exists == 'false' && inputs.use-cache == 'true' }}
|
if: ${{ steps.check-cache.outputs.cache_exists == 'false' && inputs.use-cache == 'true' }}
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
final_cache_path=/mnt/cross-instance-cache/$DEPSHASH.tar
|
final_cache_path=$CACHE_DRIVE/$CACHE_FILE
|
||||||
echo "Using cache key: $DEPSHASH"
|
echo "Using cache key: $DEPSHASH"
|
||||||
echo "Checking path: $final_cache_path"
|
echo "Checking path: $final_cache_path"
|
||||||
if [ ! -f "$final_cache_path" ]; then
|
if [ ! -f "$final_cache_path" ]; then
|
||||||
@@ -181,3 +198,11 @@ runs:
|
|||||||
else
|
else
|
||||||
echo "Cache key persisted in $final_cache_path"
|
echo "Cache key persisted in $final_cache_path"
|
||||||
fi
|
fi
|
||||||
|
- name: Wait for active SSH sessions
|
||||||
|
shell: bash
|
||||||
|
if: always() && !cancelled()
|
||||||
|
run: |
|
||||||
|
while [ -f /var/.ssh-lock ]
|
||||||
|
do
|
||||||
|
sleep 60
|
||||||
|
done
|
||||||
|
|||||||
40
.github/actions/cipd-install/action.yml
vendored
Normal file
40
.github/actions/cipd-install/action.yml
vendored
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
name: 'CIPD install'
|
||||||
|
description: 'Installs the specified CIPD package'
|
||||||
|
inputs:
|
||||||
|
cipd-root-prefix-path:
|
||||||
|
description: 'Path to prepend to installation directory'
|
||||||
|
default: ''
|
||||||
|
dependency:
|
||||||
|
description: 'Name of dependency to install'
|
||||||
|
deps-file:
|
||||||
|
description: 'Location of DEPS file that defines the dependency'
|
||||||
|
installation-dir:
|
||||||
|
description: 'Location to install dependency'
|
||||||
|
target-platform:
|
||||||
|
description: 'Target platform, should be linux, win, macos'
|
||||||
|
package:
|
||||||
|
description: 'Package to install'
|
||||||
|
runs:
|
||||||
|
using: "composite"
|
||||||
|
steps:
|
||||||
|
- name: Delete wrong ${{ inputs.dependency }}
|
||||||
|
shell: bash
|
||||||
|
run : |
|
||||||
|
rm -rf ${{ inputs.cipd-root-prefix-path }}${{ inputs.installation-dir }}
|
||||||
|
- name: Create ensure file for ${{ inputs.dependency }}
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
echo '${{ inputs.package }}' `e d gclient getdep --deps-file=${{ inputs.deps-file }} -r '${{ inputs.installation-dir }}:${{ inputs.package }}'` > ${{ inputs.dependency }}_ensure_file
|
||||||
|
cat ${{ inputs.dependency }}_ensure_file
|
||||||
|
- name: CIPD installation of ${{ inputs.dependency }} (macOS)
|
||||||
|
if: ${{ inputs.target-platform == 'macos' }}
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
echo "ensuring ${{ inputs.dependency }} on macOS"
|
||||||
|
e d cipd ensure --root ${{ inputs.cipd-root-prefix-path }}${{ inputs.installation-dir }} -ensure-file ${{ inputs.dependency }}_ensure_file
|
||||||
|
- name: CIPD installation of ${{ inputs.dependency }} (Windows)
|
||||||
|
if: ${{ inputs.target-platform == 'win' }}
|
||||||
|
shell: powershell
|
||||||
|
run: |
|
||||||
|
echo "ensuring ${{ inputs.dependency }} on Windows"
|
||||||
|
e d cipd ensure --root ${{ inputs.cipd-root-prefix-path }}${{ inputs.installation-dir }} -ensure-file ${{ inputs.dependency }}_ensure_file
|
||||||
61
.github/actions/fix-sync-macos/action.yml
vendored
61
.github/actions/fix-sync-macos/action.yml
vendored
@@ -1,61 +0,0 @@
|
|||||||
name: 'Fix Sync macOS'
|
|
||||||
description: 'Checks out Electron and stores it in the AKS Cache'
|
|
||||||
runs:
|
|
||||||
using: "composite"
|
|
||||||
steps:
|
|
||||||
- name: Fix Sync
|
|
||||||
shell: bash
|
|
||||||
# This step is required to correct for differences between "gclient sync"
|
|
||||||
# on Linux and the expected state on macOS. This requires:
|
|
||||||
# 1. Fixing Clang Install (wrong binary)
|
|
||||||
# 2. Fixing esbuild (wrong binary)
|
|
||||||
# 3. Fixing rustc (wrong binary)
|
|
||||||
# 4. Fixing gn (wrong binary)
|
|
||||||
# 5. Fix reclient (wrong binary)
|
|
||||||
# 6. Fixing dsymutil (wrong binary)
|
|
||||||
# 7. Ensuring we are using the correct ninja and adding it to PATH
|
|
||||||
# 8. Fixing angle (wrong remote)
|
|
||||||
run : |
|
|
||||||
SEDOPTION="-i ''"
|
|
||||||
rm -rf src/third_party/llvm-build
|
|
||||||
python3 src/tools/clang/scripts/update.py
|
|
||||||
|
|
||||||
echo 'infra/3pp/tools/esbuild/${platform}' `gclient getdep --deps-file=src/third_party/devtools-frontend/src/DEPS -r 'third_party/esbuild:infra/3pp/tools/esbuild/${platform}'` > esbuild_ensure_file
|
|
||||||
# Remove extra output from calling gclient getdep which always calls update_depot_tools
|
|
||||||
sed -i '' "s/Updating depot_tools... //g" esbuild_ensure_file
|
|
||||||
cipd ensure --root src/third_party/devtools-frontend/src/third_party/esbuild -ensure-file esbuild_ensure_file
|
|
||||||
|
|
||||||
rm -rf src/third_party/rust-toolchain
|
|
||||||
python3 src/tools/rust/update_rust.py
|
|
||||||
|
|
||||||
# Prevent calling gclient getdep which always calls update_depot_tools
|
|
||||||
echo 'gn/gn/mac-${arch}' `gclient getdep --deps-file=src/DEPS -r 'src/buildtools/mac:gn/gn/mac-${arch}'` > gn_ensure_file
|
|
||||||
sed -i '' "s/Updating depot_tools... //g" gn_ensure_file
|
|
||||||
cipd ensure --root src/buildtools/mac -ensure-file gn_ensure_file
|
|
||||||
|
|
||||||
# Prevent calling gclient getdep which always calls update_depot_tools
|
|
||||||
echo 'infra/rbe/client/${platform}' `gclient getdep --deps-file=src/DEPS -r 'src/buildtools/reclient:infra/rbe/client/${platform}'` > gn_ensure_file
|
|
||||||
sed -i '' "s/Updating depot_tools... //g" gn_ensure_file
|
|
||||||
cipd ensure --root src/buildtools/reclient -ensure-file gn_ensure_file
|
|
||||||
python3 src/buildtools/reclient_cfgs/configure_reclient_cfgs.py --rbe_instance "projects/rbe-chrome-untrusted/instances/default_instance" --reproxy_cfg_template reproxy.cfg.template --rewrapper_cfg_project "" --skip_remoteexec_cfg_fetch
|
|
||||||
|
|
||||||
if [ "${{ env.TARGET_ARCH }}" == "arm64" ]; then
|
|
||||||
DSYM_SHA_FILE=src/tools/clang/dsymutil/bin/dsymutil.arm64.sha1
|
|
||||||
else
|
|
||||||
DSYM_SHA_FILE=src/tools/clang/dsymutil/bin/dsymutil.x64.sha1
|
|
||||||
fi
|
|
||||||
python3 src/third_party/depot_tools/download_from_google_storage.py --no_resume --no_auth --bucket chromium-browser-clang -s $DSYM_SHA_FILE -o src/tools/clang/dsymutil/bin/dsymutil
|
|
||||||
|
|
||||||
echo 'infra/3pp/tools/ninja/${platform}' `gclient getdep --deps-file=src/DEPS -r 'src/third_party/ninja:infra/3pp/tools/ninja/${platform}'` > ninja_ensure_file
|
|
||||||
sed $SEDOPTION "s/Updating depot_tools... //g" ninja_ensure_file
|
|
||||||
cipd ensure --root src/third_party/ninja -ensure-file ninja_ensure_file
|
|
||||||
|
|
||||||
echo "$(pwd)/src/third_party/ninja" >> $GITHUB_PATH
|
|
||||||
|
|
||||||
cd src/third_party/angle
|
|
||||||
rm -f .git/objects/info/alternates
|
|
||||||
git remote set-url origin https://chromium.googlesource.com/angle/angle.git
|
|
||||||
cp .git/config .git/config.backup
|
|
||||||
git remote remove origin
|
|
||||||
mv .git/config.backup .git/config
|
|
||||||
git fetch
|
|
||||||
120
.github/actions/fix-sync/action.yml
vendored
Normal file
120
.github/actions/fix-sync/action.yml
vendored
Normal file
@@ -0,0 +1,120 @@
|
|||||||
|
name: 'Fix Sync'
|
||||||
|
description: 'Ensures proper binaries are in place'
|
||||||
|
# This action is required to correct for differences between "gclient sync"
|
||||||
|
# on Linux and the expected state on macOS/windows. This requires:
|
||||||
|
# 1. Fixing Clang Install (wrong binary)
|
||||||
|
# 2. Fixing esbuild (wrong binary)
|
||||||
|
# 3. Fixing rustc (wrong binary)
|
||||||
|
# 4. Fixing gn (wrong binary)
|
||||||
|
# 5. Fix reclient (wrong binary)
|
||||||
|
# 6. Fixing dsymutil (wrong binary)
|
||||||
|
# 7. Ensuring we are using the correct ninja and adding it to PATH
|
||||||
|
# 8. Fixing angle (wrong remote)
|
||||||
|
# 9. Install windows toolchain on Windows
|
||||||
|
# 10. Fix node binary on Windows
|
||||||
|
# 11. Fix rc binary on Windows
|
||||||
|
inputs:
|
||||||
|
target-platform:
|
||||||
|
description: 'Target platform, should be linux, win, macos'
|
||||||
|
runs:
|
||||||
|
using: "composite"
|
||||||
|
steps:
|
||||||
|
- name: Fix clang
|
||||||
|
shell: bash
|
||||||
|
run : |
|
||||||
|
rm -rf src/third_party/llvm-build
|
||||||
|
python3 src/tools/clang/scripts/update.py
|
||||||
|
- name: Fix esbuild
|
||||||
|
uses: ./src/electron/.github/actions/cipd-install
|
||||||
|
with:
|
||||||
|
cipd-root-prefix-path: src/third_party/devtools-frontend/src/
|
||||||
|
dependency: esbuild
|
||||||
|
deps-file: src/third_party/devtools-frontend/src/DEPS
|
||||||
|
installation-dir: third_party/esbuild
|
||||||
|
target-platform: ${{ inputs.target-platform }}
|
||||||
|
package: infra/3pp/tools/esbuild/${platform}
|
||||||
|
- name: Fix rustc
|
||||||
|
shell: bash
|
||||||
|
run : |
|
||||||
|
rm -rf src/third_party/rust-toolchain
|
||||||
|
python3 src/tools/rust/update_rust.py
|
||||||
|
- name: Fix gn (macOS)
|
||||||
|
if: ${{ inputs.target-platform == 'macos' }}
|
||||||
|
uses: ./src/electron/.github/actions/cipd-install
|
||||||
|
with:
|
||||||
|
dependency: gn
|
||||||
|
deps-file: src/DEPS
|
||||||
|
installation-dir: src/buildtools/mac
|
||||||
|
target-platform: ${{ inputs.target-platform }}
|
||||||
|
package: gn/gn/mac-${arch}
|
||||||
|
- name: Fix gn (Windows)
|
||||||
|
if: ${{ inputs.target-platform == 'win' }}
|
||||||
|
uses: ./src/electron/.github/actions/cipd-install
|
||||||
|
with:
|
||||||
|
dependency: gn
|
||||||
|
deps-file: src/DEPS
|
||||||
|
installation-dir: src/buildtools/win
|
||||||
|
target-platform: ${{ inputs.target-platform }}
|
||||||
|
package: gn/gn/windows-amd64
|
||||||
|
- name: Fix reclient
|
||||||
|
uses: ./src/electron/.github/actions/cipd-install
|
||||||
|
with:
|
||||||
|
dependency: reclient
|
||||||
|
deps-file: src/DEPS
|
||||||
|
installation-dir: src/buildtools/reclient
|
||||||
|
target-platform: ${{ inputs.target-platform }}
|
||||||
|
package: infra/rbe/client/${platform}
|
||||||
|
- name: Configure reclient configs
|
||||||
|
shell: bash
|
||||||
|
run : |
|
||||||
|
python3 src/buildtools/reclient_cfgs/configure_reclient_cfgs.py --rbe_instance "projects/rbe-chrome-untrusted/instances/default_instance" --reproxy_cfg_template reproxy.cfg.template --rewrapper_cfg_project "" --skip_remoteexec_cfg_fetch
|
||||||
|
- name: Fix dsymutil (macOS)
|
||||||
|
if: ${{ inputs.target-platform == 'macos' }}
|
||||||
|
shell: bash
|
||||||
|
run : |
|
||||||
|
# Fix dsymutil
|
||||||
|
if [ "${{ inputs.target-platform }}" = "macos" ]; then
|
||||||
|
if [ "${{ env.TARGET_ARCH }}" == "arm64" ]; then
|
||||||
|
DSYM_SHA_FILE=src/tools/clang/dsymutil/bin/dsymutil.arm64.sha1
|
||||||
|
else
|
||||||
|
DSYM_SHA_FILE=src/tools/clang/dsymutil/bin/dsymutil.x64.sha1
|
||||||
|
fi
|
||||||
|
python3 src/third_party/depot_tools/download_from_google_storage.py --no_resume --no_auth --bucket chromium-browser-clang -s $DSYM_SHA_FILE -o src/tools/clang/dsymutil/bin/dsymutil
|
||||||
|
fi
|
||||||
|
- name: Fix ninja
|
||||||
|
uses: ./src/electron/.github/actions/cipd-install
|
||||||
|
with:
|
||||||
|
dependency: ninja
|
||||||
|
deps-file: src/DEPS
|
||||||
|
installation-dir: src/third_party/ninja
|
||||||
|
target-platform: ${{ inputs.target-platform }}
|
||||||
|
package: infra/3pp/tools/ninja/${platform}
|
||||||
|
- name: Set ninja in path
|
||||||
|
shell: bash
|
||||||
|
run : |
|
||||||
|
echo "$(pwd)/src/third_party/ninja" >> $GITHUB_PATH
|
||||||
|
- name: Fixup angle git
|
||||||
|
shell: bash
|
||||||
|
run : |
|
||||||
|
cd src/third_party/angle
|
||||||
|
rm -f .git/objects/info/alternates
|
||||||
|
git remote set-url origin https://chromium.googlesource.com/angle/angle.git
|
||||||
|
cp .git/config .git/config.backup
|
||||||
|
git remote remove origin
|
||||||
|
mv .git/config.backup .git/config
|
||||||
|
git fetch
|
||||||
|
- name: Get Windows toolchain
|
||||||
|
if: ${{ inputs.target-platform == 'win' }}
|
||||||
|
shell: powershell
|
||||||
|
run: e d vpython3 src\build\vs_toolchain.py update --force
|
||||||
|
- name: Download nodejs
|
||||||
|
if: ${{ inputs.target-platform == 'win' }}
|
||||||
|
shell: powershell
|
||||||
|
run: |
|
||||||
|
$nodedeps = e d gclient getdep --deps-file=src/DEPS -r src/third_party/node/win | ConvertFrom-JSON
|
||||||
|
python3 src\third_party\depot_tools\download_from_google_storage.py --no_resume --no_auth --bucket chromium-nodejs -o src\third_party\node\win\node.exe $nodedeps.object_name
|
||||||
|
- name: Install rc
|
||||||
|
if: ${{ inputs.target-platform == 'win' }}
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
python3 src/third_party/depot_tools/download_from_google_storage.py --no_resume --no_auth --bucket chromium-browser-clang/rc -s src/build/toolchain/win/rc/win/rc.exe.sha1
|
||||||
15
.github/actions/install-build-tools/action.yml
vendored
15
.github/actions/install-build-tools/action.yml
vendored
@@ -10,11 +10,22 @@ runs:
|
|||||||
git config --global core.filemode false
|
git config --global core.filemode false
|
||||||
git config --global core.autocrlf false
|
git config --global core.autocrlf false
|
||||||
git config --global branch.autosetuprebase always
|
git config --global branch.autosetuprebase always
|
||||||
|
git config --global core.fscache true
|
||||||
|
git config --global core.longpaths true
|
||||||
|
git config --global core.preloadindex true
|
||||||
fi
|
fi
|
||||||
export BUILD_TOOLS_SHA=8246e57791b0af4ae5975eb96f09855f9269b1cd
|
export BUILD_TOOLS_SHA=6e8526315ea3b4828882497e532b8340e64e053c
|
||||||
npm i -g @electron/build-tools
|
npm i -g @electron/build-tools
|
||||||
|
# Update depot_tools to ensure python
|
||||||
|
e d update_depot_tools
|
||||||
e auto-update disable
|
e auto-update disable
|
||||||
|
# Disable further updates of depot_tools
|
||||||
|
e d auto-update disable
|
||||||
if [ "$(expr substr $(uname -s) 1 10)" == "MSYS_NT-10" ]; then
|
if [ "$(expr substr $(uname -s) 1 10)" == "MSYS_NT-10" ]; then
|
||||||
e d cipd.bat --version
|
e d cipd.bat --version
|
||||||
cp "C:\Python311\python.exe" "C:\Python311\python3.exe"
|
cp "C:\Python311\python.exe" "C:\Python311\python3.exe"
|
||||||
fi
|
echo "C:\Users\ContainerAdministrator\.electron_build_tools\third_party\depot_tools" >> $GITHUB_PATH
|
||||||
|
else
|
||||||
|
echo "$HOME/.electron_build_tools/third_party/depot_tools" >> $GITHUB_PATH
|
||||||
|
echo "$HOME/.electron_build_tools/third_party/depot_tools/python-bin" >> $GITHUB_PATH
|
||||||
|
fi
|
||||||
@@ -7,7 +7,7 @@ runs:
|
|||||||
shell: bash
|
shell: bash
|
||||||
id: yarn-cache-dir-path
|
id: yarn-cache-dir-path
|
||||||
run: echo "dir=$(node src/electron/script/yarn cache dir)" >> $GITHUB_OUTPUT
|
run: echo "dir=$(node src/electron/script/yarn cache dir)" >> $GITHUB_OUTPUT
|
||||||
- uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57
|
- uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
|
||||||
id: yarn-cache
|
id: yarn-cache
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
||||||
|
|||||||
10
.github/actions/restore-cache-aks/action.yml
vendored
10
.github/actions/restore-cache-aks/action.yml
vendored
@@ -1,12 +1,20 @@
|
|||||||
name: 'Restore Cache AKS'
|
name: 'Restore Cache AKS'
|
||||||
description: 'Restores Electron src cache via AKS'
|
description: 'Restores Electron src cache via AKS'
|
||||||
|
inputs:
|
||||||
|
target-platform:
|
||||||
|
description: 'Target platform, should be linux, win, macos'
|
||||||
runs:
|
runs:
|
||||||
using: "composite"
|
using: "composite"
|
||||||
steps:
|
steps:
|
||||||
- name: Restore and Ensure Src Cache
|
- name: Restore and Ensure Src Cache
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
cache_path=/mnt/cross-instance-cache/$DEPSHASH.tar
|
if [ "${{ inputs.target-platform }}" = "win" ]; then
|
||||||
|
cache_path=/mnt/win-cache/$DEPSHASH.tar
|
||||||
|
else
|
||||||
|
cache_path=/mnt/cross-instance-cache/$DEPSHASH.tar
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Using cache key: $DEPSHASH"
|
echo "Using cache key: $DEPSHASH"
|
||||||
echo "Checking for cache in: $cache_path"
|
echo "Checking for cache in: $cache_path"
|
||||||
if [ ! -f "$cache_path" ]; then
|
if [ ! -f "$cache_path" ]; then
|
||||||
|
|||||||
77
.github/actions/restore-cache-azcopy/action.yml
vendored
77
.github/actions/restore-cache-azcopy/action.yml
vendored
@@ -1,22 +1,25 @@
|
|||||||
name: 'Restore Cache AZCopy'
|
name: 'Restore Cache AZCopy'
|
||||||
description: 'Restores Electron src cache via AZCopy'
|
description: 'Restores Electron src cache via AZCopy'
|
||||||
|
inputs:
|
||||||
|
target-platform:
|
||||||
|
description: 'Target platform, should be linux, win, macos'
|
||||||
runs:
|
runs:
|
||||||
using: "composite"
|
using: "composite"
|
||||||
steps:
|
steps:
|
||||||
- name: Obtain SAS Key
|
- name: Obtain SAS Key
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57
|
uses: actions/cache/restore@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
|
||||||
with:
|
with:
|
||||||
path: |
|
path: sas-token
|
||||||
sas-token
|
key: sas-key-${{ inputs.target-platform }}-${{ github.run_number }}-1
|
||||||
key: sas-key-${{ github.run_number }}-1
|
enableCrossOsArchive: true
|
||||||
- name: Obtain SAS Key
|
- name: Obtain SAS Key
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57
|
uses: actions/cache/restore@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
|
||||||
with:
|
with:
|
||||||
path: |
|
path: sas-token
|
||||||
sas-token
|
key: sas-key-${{ inputs.target-platform }}-${{ github.run_number }}-${{ github.run_attempt }}
|
||||||
key: sas-key-${{ github.run_number }}-${{ github.run_attempt }}
|
enableCrossOsArchive: true
|
||||||
- name: Download Src Cache from AKS
|
- name: Download Src Cache from AKS
|
||||||
# The cache will always exist here as a result of the checkout job
|
# The cache will always exist here as a result of the checkout job
|
||||||
# Either it was uploaded to Azure in the checkout job for this commit
|
# Either it was uploaded to Azure in the checkout job for this commit
|
||||||
@@ -26,21 +29,30 @@ runs:
|
|||||||
timeout_minutes: 30
|
timeout_minutes: 30
|
||||||
max_attempts: 3
|
max_attempts: 3
|
||||||
retry_on: error
|
retry_on: error
|
||||||
|
shell: bash
|
||||||
command: |
|
command: |
|
||||||
sas_token=$(cat sas-token)
|
sas_token=$(cat sas-token)
|
||||||
if [ -z $sas-token ]; then
|
if [ -z "$sas_token" ]; then
|
||||||
echo "SAS Token not found; exiting src cache download early..."
|
echo "SAS Token not found; exiting src cache download early..."
|
||||||
exit 1
|
exit 1
|
||||||
|
else
|
||||||
|
if [ "${{ inputs.target-platform }}" = "win" ]; then
|
||||||
|
azcopy copy --log-level=ERROR \
|
||||||
|
"https://${{ env.AZURE_AKS_CACHE_STORAGE_ACCOUNT }}.file.core.windows.net/${{ env.AZURE_AKS_WIN_CACHE_SHARE_NAME }}/${{ env.CACHE_PATH }}?$sas_token" $DEPSHASH.tar
|
||||||
|
else
|
||||||
|
azcopy copy --log-level=ERROR \
|
||||||
|
"https://${{ env.AZURE_AKS_CACHE_STORAGE_ACCOUNT }}.file.core.windows.net/${{ env.AZURE_AKS_CACHE_SHARE_NAME }}/${{ env.CACHE_PATH }}?$sas_token" $DEPSHASH.tar
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
azcopy copy --log-level=ERROR \
|
|
||||||
"https://${{ env.AZURE_AKS_CACHE_STORAGE_ACCOUNT }}.file.core.windows.net/${{ env.AZURE_AKS_CACHE_SHARE_NAME }}/${{ env.CACHE_PATH }}?$sas_token" $DEPSHASH.tar
|
|
||||||
env:
|
env:
|
||||||
AZURE_AKS_CACHE_STORAGE_ACCOUNT: f723719aa87a34622b5f7f3
|
AZURE_AKS_CACHE_STORAGE_ACCOUNT: f723719aa87a34622b5f7f3
|
||||||
AZURE_AKS_CACHE_SHARE_NAME: pvc-f6a4089f-b082-4bee-a3f9-c3e1c0c02d8f
|
AZURE_AKS_CACHE_SHARE_NAME: pvc-f6a4089f-b082-4bee-a3f9-c3e1c0c02d8f
|
||||||
|
AZURE_AKS_WIN_CACHE_SHARE_NAME: pvc-71dec4f2-0d44-4fd1-a2c3-add049d70bdf
|
||||||
- name: Clean SAS Key
|
- name: Clean SAS Key
|
||||||
shell: bash
|
shell: bash
|
||||||
run: rm -f sas-token
|
run: rm -f sas-token
|
||||||
- name: Unzip and Ensure Src Cache
|
- name: Unzip and Ensure Src Cache
|
||||||
|
if: ${{ inputs.target-platform == 'macos' }}
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
echo "Downloaded cache is $(du -sh $DEPSHASH.tar | cut -f1)"
|
echo "Downloaded cache is $(du -sh $DEPSHASH.tar | cut -f1)"
|
||||||
@@ -68,4 +80,45 @@ runs:
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Wiping Electron Directory"
|
echo "Wiping Electron Directory"
|
||||||
rm -rf src/electron
|
rm -rf src/electron
|
||||||
|
|
||||||
|
- name: Unzip and Ensure Src Cache (Windows)
|
||||||
|
if: ${{ inputs.target-platform == 'win' }}
|
||||||
|
shell: powershell
|
||||||
|
run: |
|
||||||
|
$src_cache = "$env:DEPSHASH.tar"
|
||||||
|
$cache_size = $(Get-Item $src_cache).length
|
||||||
|
Write-Host "Downloaded cache is $cache_size"
|
||||||
|
if ($cache_size -eq 0) {
|
||||||
|
Write-Host "Cache is empty - exiting"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
$TEMP_DIR=New-Item -ItemType Directory -Path temp-cache
|
||||||
|
$TEMP_DIR_PATH = $TEMP_DIR.FullName
|
||||||
|
C:\ProgramData\Chocolatey\bin\7z.exe -y -snld x $src_cache -o"$TEMP_DIR_PATH"
|
||||||
|
|
||||||
|
- name: Move Src Cache (Windows)
|
||||||
|
if: ${{ inputs.target-platform == 'win' }}
|
||||||
|
uses: nick-fields/retry@7152eba30c6575329ac0576536151aca5a72780e # v3.0.0
|
||||||
|
with:
|
||||||
|
timeout_minutes: 30
|
||||||
|
max_attempts: 3
|
||||||
|
retry_on: error
|
||||||
|
shell: powershell
|
||||||
|
command: |
|
||||||
|
if (Test-Path "temp-cache\src") {
|
||||||
|
Write-Host "Relocating Cache"
|
||||||
|
Remove-Item -Recurse -Force src
|
||||||
|
Move-Item temp-cache\src src
|
||||||
|
|
||||||
|
Write-Host "Deleting zip file"
|
||||||
|
Remove-Item -Force $src_cache
|
||||||
|
}
|
||||||
|
if (-Not (Test-Path "src\third_party\blink")) {
|
||||||
|
Write-Host "Cache was not correctly restored - exiting"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "Wiping Electron Directory"
|
||||||
|
Remove-Item -Recurse -Force src\electron
|
||||||
|
|||||||
36
.github/actions/set-chromium-cookie/action.yml
vendored
36
.github/actions/set-chromium-cookie/action.yml
vendored
@@ -4,9 +4,14 @@ runs:
|
|||||||
using: "composite"
|
using: "composite"
|
||||||
steps:
|
steps:
|
||||||
- name: Set the git cookie from chromium.googlesource.com (Unix)
|
- name: Set the git cookie from chromium.googlesource.com (Unix)
|
||||||
if: ${{ runner.os != 'Windows' && env.CHROMIUM_GIT_COOKIE }}
|
if: ${{ runner.os != 'Windows' }}
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
|
if [[ -z "${{ env.CHROMIUM_GIT_COOKIE }}" ]]; then
|
||||||
|
echo "CHROMIUM_GIT_COOKIE is not set - cannot authenticate."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
eval 'set +o history' 2>/dev/null || setopt HIST_IGNORE_SPACE 2>/dev/null
|
eval 'set +o history' 2>/dev/null || setopt HIST_IGNORE_SPACE 2>/dev/null
|
||||||
touch ~/.gitcookies
|
touch ~/.gitcookies
|
||||||
chmod 0600 ~/.gitcookies
|
chmod 0600 ~/.gitcookies
|
||||||
@@ -17,10 +22,37 @@ runs:
|
|||||||
${{ env.CHROMIUM_GIT_COOKIE }}
|
${{ env.CHROMIUM_GIT_COOKIE }}
|
||||||
__END__
|
__END__
|
||||||
eval 'set -o history' 2>/dev/null || unsetopt HIST_IGNORE_SPACE 2>/dev/null
|
eval 'set -o history' 2>/dev/null || unsetopt HIST_IGNORE_SPACE 2>/dev/null
|
||||||
|
|
||||||
|
RESPONSE=$(curl -s -b ~/.gitcookies https://chromium-review.googlesource.com/a/accounts/self)
|
||||||
|
if [[ $RESPONSE == ")]}'"* ]]; then
|
||||||
|
# Extract account email for verification
|
||||||
|
EMAIL=$(echo "$RESPONSE" | tail -c +5 | jq -r '.email // "No email found"')
|
||||||
|
echo "Cookie authentication successful - authenticated as: $EMAIL"
|
||||||
|
else
|
||||||
|
echo "Cookie authentication failed - ensure CHROMIUM_GIT_COOKIE is set correctly"
|
||||||
|
echo $RESPONSE
|
||||||
|
fi
|
||||||
- name: Set the git cookie from chromium.googlesource.com (Windows)
|
- name: Set the git cookie from chromium.googlesource.com (Windows)
|
||||||
if: ${{ runner.os == 'Windows' && env.CHROMIUM_GIT_COOKIE_WINDOWS_STRING }}
|
if: ${{ runner.os == 'Windows' }}
|
||||||
shell: cmd
|
shell: cmd
|
||||||
run: |
|
run: |
|
||||||
|
if "%CHROMIUM_GIT_COOKIE_WINDOWS_STRING%"=="" (
|
||||||
|
echo CHROMIUM_GIT_COOKIE_WINDOWS_STRING is not set - cannot authenticate.
|
||||||
|
exit /b 0
|
||||||
|
)
|
||||||
|
|
||||||
git config --global http.cookiefile "%USERPROFILE%\.gitcookies"
|
git config --global http.cookiefile "%USERPROFILE%\.gitcookies"
|
||||||
powershell -noprofile -nologo -command Write-Output "${{ env.CHROMIUM_GIT_COOKIE_WINDOWS_STRING }}" >>"%USERPROFILE%\.gitcookies"
|
powershell -noprofile -nologo -command Write-Output "${{ env.CHROMIUM_GIT_COOKIE_WINDOWS_STRING }}" >>"%USERPROFILE%\.gitcookies"
|
||||||
|
|
||||||
|
curl -s -b "%USERPROFILE%\.gitcookies" https://chromium-review.googlesource.com/a/accounts/self > response.txt
|
||||||
|
|
||||||
|
findstr /B /C:")]}'" response.txt > nul
|
||||||
|
if %ERRORLEVEL% EQU 0 (
|
||||||
|
echo Cookie authentication successful
|
||||||
|
powershell -NoProfile -Command "& {$content = Get-Content -Raw response.txt; $content = $content.Substring(4); try { $json = ConvertFrom-Json $content; if($json.email) { Write-Host 'Authenticated as:' $json.email } else { Write-Host 'No email found in response' } } catch { Write-Host 'Error parsing JSON:' $_ }}"
|
||||||
|
) else (
|
||||||
|
echo Cookie authentication failed - ensure CHROMIUM_GIT_COOKIE_WINDOWS_STRING is set correctly
|
||||||
|
type response.txt
|
||||||
|
)
|
||||||
|
|
||||||
|
del response.txt
|
||||||
|
|||||||
18
.github/problem-matchers/clang.json
vendored
Normal file
18
.github/problem-matchers/clang.json
vendored
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"problemMatcher": [
|
||||||
|
{
|
||||||
|
"owner": "clang",
|
||||||
|
"fromPath": "src/out/Default/args.gn",
|
||||||
|
"pattern": [
|
||||||
|
{
|
||||||
|
"regexp": "^(.+)[(:](\\d+)[:,](\\d+)\\)?:\\s+(warning|error):\\s+(.*)$",
|
||||||
|
"file": 1,
|
||||||
|
"line": 2,
|
||||||
|
"column": 3,
|
||||||
|
"severity": 4,
|
||||||
|
"message": 5
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
22
.github/problem-matchers/eslint-stylish.json
vendored
Normal file
22
.github/problem-matchers/eslint-stylish.json
vendored
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"problemMatcher": [
|
||||||
|
{
|
||||||
|
"owner": "eslint-stylish",
|
||||||
|
"pattern": [
|
||||||
|
{
|
||||||
|
"regexp": "^\\s*([^\\s].*)$",
|
||||||
|
"file": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"regexp": "^\\s+(\\d+):(\\d+)\\s+(error|warning|info)\\s+(.*)\\s\\s+(.*)$",
|
||||||
|
"line": 1,
|
||||||
|
"column": 2,
|
||||||
|
"severity": 3,
|
||||||
|
"message": 4,
|
||||||
|
"code": 5,
|
||||||
|
"loop": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
24
.github/problem-matchers/patch-conflict.json
vendored
Normal file
24
.github/problem-matchers/patch-conflict.json
vendored
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"problemMatcher": [
|
||||||
|
{
|
||||||
|
"owner": "merge-conflict",
|
||||||
|
"pattern": [
|
||||||
|
{
|
||||||
|
"regexp": "^CONFLICT\\s\\(\\S+\\): (Merge conflict in \\S+)$",
|
||||||
|
"message": 1
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"owner": "patch-conflict",
|
||||||
|
"pattern": [
|
||||||
|
{
|
||||||
|
"regexp": "^error: (patch failed: (\\S+):(\\d+))$",
|
||||||
|
"message": 1,
|
||||||
|
"file": 2,
|
||||||
|
"line": 3
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
2
.github/workflows/archaeologist-dig.yml
vendored
2
.github/workflows/archaeologist-dig.yml
vendored
@@ -15,7 +15,7 @@ jobs:
|
|||||||
- name: Setup Node.js/npm
|
- name: Setup Node.js/npm
|
||||||
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a
|
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a
|
||||||
with:
|
with:
|
||||||
node-version: 20.11.x
|
node-version: 20.19.x
|
||||||
- name: Setting Up Dig Site
|
- name: Setting Up Dig Site
|
||||||
run: |
|
run: |
|
||||||
echo "remote: ${{ github.event.pull_request.head.repo.clone_url }}"
|
echo "remote: ${{ github.event.pull_request.head.repo.clone_url }}"
|
||||||
|
|||||||
74
.github/workflows/build-git-cache.yml
vendored
Normal file
74
.github/workflows/build-git-cache.yml
vendored
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
name: Build Git Cache
|
||||||
|
# This workflow updates git cache on the cross-instance cache volumes
|
||||||
|
# It runs daily at midnight.
|
||||||
|
|
||||||
|
on:
|
||||||
|
schedule:
|
||||||
|
- cron: "0 0 * * *"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-git-cache-linux:
|
||||||
|
runs-on: electron-arc-linux-amd64-32core
|
||||||
|
container:
|
||||||
|
image: ghcr.io/electron/build:bc2f48b2415a670de18d13605b1cf0eb5fdbaae1
|
||||||
|
options: --user root
|
||||||
|
volumes:
|
||||||
|
- /mnt/cross-instance-cache:/mnt/cross-instance-cache
|
||||||
|
env:
|
||||||
|
CHROMIUM_GIT_COOKIE: ${{ secrets.CHROMIUM_GIT_COOKIE }}
|
||||||
|
GCLIENT_EXTRA_ARGS: '--custom-var=checkout_arm=True --custom-var=checkout_arm64=True'
|
||||||
|
steps:
|
||||||
|
- name: Checkout Electron
|
||||||
|
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
|
||||||
|
with:
|
||||||
|
path: src/electron
|
||||||
|
fetch-depth: 0
|
||||||
|
- name: Build Git Cache
|
||||||
|
uses: ./src/electron/.github/actions/build-git-cache
|
||||||
|
with:
|
||||||
|
target-platform: linux
|
||||||
|
|
||||||
|
build-git-cache-windows:
|
||||||
|
runs-on: electron-arc-linux-amd64-32core
|
||||||
|
container:
|
||||||
|
image: ghcr.io/electron/build:bc2f48b2415a670de18d13605b1cf0eb5fdbaae1
|
||||||
|
options: --user root --device /dev/fuse --cap-add SYS_ADMIN
|
||||||
|
volumes:
|
||||||
|
- /mnt/win-cache:/mnt/win-cache
|
||||||
|
env:
|
||||||
|
CHROMIUM_GIT_COOKIE: ${{ secrets.CHROMIUM_GIT_COOKIE }}
|
||||||
|
GCLIENT_EXTRA_ARGS: '--custom-var=checkout_win=True'
|
||||||
|
TARGET_OS: 'win'
|
||||||
|
steps:
|
||||||
|
- name: Checkout Electron
|
||||||
|
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
|
||||||
|
with:
|
||||||
|
path: src/electron
|
||||||
|
fetch-depth: 0
|
||||||
|
- name: Build Git Cache
|
||||||
|
uses: ./src/electron/.github/actions/build-git-cache
|
||||||
|
with:
|
||||||
|
target-platform: win
|
||||||
|
|
||||||
|
build-git-cache-macos:
|
||||||
|
runs-on: electron-arc-linux-amd64-32core
|
||||||
|
# This job updates the same git cache as linux, so it needs to run after the linux one.
|
||||||
|
needs: build-git-cache-linux
|
||||||
|
container:
|
||||||
|
image: ghcr.io/electron/build:bc2f48b2415a670de18d13605b1cf0eb5fdbaae1
|
||||||
|
options: --user root
|
||||||
|
volumes:
|
||||||
|
- /mnt/cross-instance-cache:/mnt/cross-instance-cache
|
||||||
|
env:
|
||||||
|
CHROMIUM_GIT_COOKIE: ${{ secrets.CHROMIUM_GIT_COOKIE }}
|
||||||
|
GCLIENT_EXTRA_ARGS: '--custom-var=checkout_mac=True --custom-var=host_os=mac'
|
||||||
|
steps:
|
||||||
|
- name: Checkout Electron
|
||||||
|
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
|
||||||
|
with:
|
||||||
|
path: src/electron
|
||||||
|
fetch-depth: 0
|
||||||
|
- name: Build Git Cache
|
||||||
|
uses: ./src/electron/.github/actions/build-git-cache
|
||||||
|
with:
|
||||||
|
target-platform: macos
|
||||||
21
.github/workflows/build.yml
vendored
21
.github/workflows/build.yml
vendored
@@ -6,7 +6,7 @@ on:
|
|||||||
build-image-sha:
|
build-image-sha:
|
||||||
type: string
|
type: string
|
||||||
description: 'SHA for electron/build image'
|
description: 'SHA for electron/build image'
|
||||||
default: 'bc2f48b2415a670de18d13605b1cf0eb5fdbaae1'
|
default: '424eedbf277ad9749ffa9219068aa72ed4a5e373'
|
||||||
required: true
|
required: true
|
||||||
skip-macos:
|
skip-macos:
|
||||||
type: boolean
|
type: boolean
|
||||||
@@ -64,7 +64,7 @@ jobs:
|
|||||||
id: set-output
|
id: set-output
|
||||||
run: |
|
run: |
|
||||||
if [ -z "${{ inputs.build-image-sha }}" ]; then
|
if [ -z "${{ inputs.build-image-sha }}" ]; then
|
||||||
echo "build-image-sha=bc2f48b2415a670de18d13605b1cf0eb5fdbaae1" >> "$GITHUB_OUTPUT"
|
echo "build-image-sha=424eedbf277ad9749ffa9219068aa72ed4a5e373" >> "$GITHUB_OUTPUT"
|
||||||
else
|
else
|
||||||
echo "build-image-sha=${{ inputs.build-image-sha }}" >> "$GITHUB_OUTPUT"
|
echo "build-image-sha=${{ inputs.build-image-sha }}" >> "$GITHUB_OUTPUT"
|
||||||
fi
|
fi
|
||||||
@@ -115,6 +115,7 @@ jobs:
|
|||||||
uses: ./src/electron/.github/actions/checkout
|
uses: ./src/electron/.github/actions/checkout
|
||||||
with:
|
with:
|
||||||
generate-sas-token: 'true'
|
generate-sas-token: 'true'
|
||||||
|
target-platform: macos
|
||||||
|
|
||||||
checkout-linux:
|
checkout-linux:
|
||||||
needs: setup
|
needs: setup
|
||||||
@@ -127,7 +128,7 @@ jobs:
|
|||||||
- /mnt/cross-instance-cache:/mnt/cross-instance-cache
|
- /mnt/cross-instance-cache:/mnt/cross-instance-cache
|
||||||
- /var/run/sas:/var/run/sas
|
- /var/run/sas:/var/run/sas
|
||||||
env:
|
env:
|
||||||
CHROMIUM_GIT_COOKIE: ${{ secrets.CHROMIUM_GIT_COOKIE }}
|
CHROMIUM_GIT_COOKIE: ${{ secrets.CHROMIUM_GIT_COOKIE }}
|
||||||
GCLIENT_EXTRA_ARGS: '--custom-var=checkout_arm=True --custom-var=checkout_arm64=True'
|
GCLIENT_EXTRA_ARGS: '--custom-var=checkout_arm=True --custom-var=checkout_arm64=True'
|
||||||
PATCH_UP_APP_CREDS: ${{ secrets.PATCH_UP_APP_CREDS }}
|
PATCH_UP_APP_CREDS: ${{ secrets.PATCH_UP_APP_CREDS }}
|
||||||
outputs:
|
outputs:
|
||||||
@@ -150,7 +151,8 @@ jobs:
|
|||||||
image: ghcr.io/electron/build:${{ needs.setup.outputs.build-image-sha }}
|
image: ghcr.io/electron/build:${{ needs.setup.outputs.build-image-sha }}
|
||||||
options: --user root --device /dev/fuse --cap-add SYS_ADMIN
|
options: --user root --device /dev/fuse --cap-add SYS_ADMIN
|
||||||
volumes:
|
volumes:
|
||||||
- /mnt/cross-instance-cache:/mnt/cross-instance-cache
|
- /mnt/win-cache:/mnt/win-cache
|
||||||
|
- /var/run/sas:/var/run/sas
|
||||||
env:
|
env:
|
||||||
CHROMIUM_GIT_COOKIE: ${{ secrets.CHROMIUM_GIT_COOKIE }}
|
CHROMIUM_GIT_COOKIE: ${{ secrets.CHROMIUM_GIT_COOKIE }}
|
||||||
CHROMIUM_GIT_COOKIE_WINDOWS_STRING: ${{ secrets.CHROMIUM_GIT_COOKIE_WINDOWS_STRING }}
|
CHROMIUM_GIT_COOKIE_WINDOWS_STRING: ${{ secrets.CHROMIUM_GIT_COOKIE_WINDOWS_STRING }}
|
||||||
@@ -168,6 +170,9 @@ jobs:
|
|||||||
ref: ${{ github.event.pull_request.head.sha }}
|
ref: ${{ github.event.pull_request.head.sha }}
|
||||||
- name: Checkout & Sync & Save
|
- name: Checkout & Sync & Save
|
||||||
uses: ./src/electron/.github/actions/checkout
|
uses: ./src/electron/.github/actions/checkout
|
||||||
|
with:
|
||||||
|
generate-sas-token: 'true'
|
||||||
|
target-platform: win
|
||||||
|
|
||||||
# GN Check Jobs
|
# GN Check Jobs
|
||||||
macos-gn-check:
|
macos-gn-check:
|
||||||
@@ -198,7 +203,7 @@ jobs:
|
|||||||
target-platform: win
|
target-platform: win
|
||||||
target-archs: x64 x86 arm64
|
target-archs: x64 x86 arm64
|
||||||
check-runs-on: electron-arc-linux-amd64-8core
|
check-runs-on: electron-arc-linux-amd64-8core
|
||||||
check-container: '{"image":"ghcr.io/electron/build:${{ needs.checkout-windows.outputs.build-image-sha }}","options":"--user root --device /dev/fuse --cap-add SYS_ADMIN","volumes":["/mnt/cross-instance-cache:/mnt/cross-instance-cache"]}'
|
check-container: '{"image":"ghcr.io/electron/build:${{ needs.checkout-windows.outputs.build-image-sha }}","options":"--user root --device /dev/fuse --cap-add SYS_ADMIN","volumes":["/mnt/win-cache:/mnt/win-cache"]}'
|
||||||
gn-build-type: testing
|
gn-build-type: testing
|
||||||
secrets: inherit
|
secrets: inherit
|
||||||
|
|
||||||
@@ -326,7 +331,7 @@ jobs:
|
|||||||
issues: read
|
issues: read
|
||||||
pull-requests: read
|
pull-requests: read
|
||||||
uses: ./.github/workflows/pipeline-electron-build-and-test.yml
|
uses: ./.github/workflows/pipeline-electron-build-and-test.yml
|
||||||
needs: setup
|
needs: checkout-windows
|
||||||
if: ${{ needs.setup.outputs.src == 'true' && !inputs.skip-windows }}
|
if: ${{ needs.setup.outputs.src == 'true' && !inputs.skip-windows }}
|
||||||
with:
|
with:
|
||||||
build-runs-on: electron-arc-windows-amd64-16core
|
build-runs-on: electron-arc-windows-amd64-16core
|
||||||
@@ -345,7 +350,7 @@ jobs:
|
|||||||
issues: read
|
issues: read
|
||||||
pull-requests: read
|
pull-requests: read
|
||||||
uses: ./.github/workflows/pipeline-electron-build-and-test.yml
|
uses: ./.github/workflows/pipeline-electron-build-and-test.yml
|
||||||
needs: setup
|
needs: checkout-windows
|
||||||
if: ${{ needs.setup.outputs.src == 'true' && !inputs.skip-windows }}
|
if: ${{ needs.setup.outputs.src == 'true' && !inputs.skip-windows }}
|
||||||
with:
|
with:
|
||||||
build-runs-on: electron-arc-windows-amd64-16core
|
build-runs-on: electron-arc-windows-amd64-16core
|
||||||
@@ -364,7 +369,7 @@ jobs:
|
|||||||
issues: read
|
issues: read
|
||||||
pull-requests: read
|
pull-requests: read
|
||||||
uses: ./.github/workflows/pipeline-electron-build-and-test.yml
|
uses: ./.github/workflows/pipeline-electron-build-and-test.yml
|
||||||
needs: setup
|
needs: checkout-windows
|
||||||
if: ${{ needs.setup.outputs.src == 'true' && !inputs.skip-windows }}
|
if: ${{ needs.setup.outputs.src == 'true' && !inputs.skip-windows }}
|
||||||
with:
|
with:
|
||||||
build-runs-on: electron-arc-windows-amd64-16core
|
build-runs-on: electron-arc-windows-amd64-16core
|
||||||
|
|||||||
4
.github/workflows/clean-src-cache.yml
vendored
4
.github/workflows/clean-src-cache.yml
vendored
@@ -16,6 +16,7 @@ jobs:
|
|||||||
options: --user root
|
options: --user root
|
||||||
volumes:
|
volumes:
|
||||||
- /mnt/cross-instance-cache:/mnt/cross-instance-cache
|
- /mnt/cross-instance-cache:/mnt/cross-instance-cache
|
||||||
|
- /mnt/win-cache:/mnt/win-cache
|
||||||
steps:
|
steps:
|
||||||
- name: Cleanup Source Cache
|
- name: Cleanup Source Cache
|
||||||
shell: bash
|
shell: bash
|
||||||
@@ -23,3 +24,6 @@ jobs:
|
|||||||
df -h /mnt/cross-instance-cache
|
df -h /mnt/cross-instance-cache
|
||||||
find /mnt/cross-instance-cache -type f -mtime +15 -delete
|
find /mnt/cross-instance-cache -type f -mtime +15 -delete
|
||||||
df -h /mnt/cross-instance-cache
|
df -h /mnt/cross-instance-cache
|
||||||
|
df -h /mnt/win-cache
|
||||||
|
find /mnt/win-cache -type f -mtime +15 -delete
|
||||||
|
df -h /mnt/win-cache
|
||||||
|
|||||||
3
.github/workflows/linux-publish.yml
vendored
3
.github/workflows/linux-publish.yml
vendored
@@ -6,7 +6,7 @@ on:
|
|||||||
build-image-sha:
|
build-image-sha:
|
||||||
type: string
|
type: string
|
||||||
description: 'SHA for electron/build image'
|
description: 'SHA for electron/build image'
|
||||||
default: 'bc2f48b2415a670de18d13605b1cf0eb5fdbaae1'
|
default: '424eedbf277ad9749ffa9219068aa72ed4a5e373'
|
||||||
upload-to-storage:
|
upload-to-storage:
|
||||||
description: 'Uploads to Azure storage'
|
description: 'Uploads to Azure storage'
|
||||||
required: false
|
required: false
|
||||||
@@ -27,6 +27,7 @@ jobs:
|
|||||||
- /mnt/cross-instance-cache:/mnt/cross-instance-cache
|
- /mnt/cross-instance-cache:/mnt/cross-instance-cache
|
||||||
- /var/run/sas:/var/run/sas
|
- /var/run/sas:/var/run/sas
|
||||||
env:
|
env:
|
||||||
|
CHROMIUM_GIT_COOKIE: ${{ secrets.CHROMIUM_GIT_COOKIE }}
|
||||||
GCLIENT_EXTRA_ARGS: '--custom-var=checkout_arm=True --custom-var=checkout_arm64=True'
|
GCLIENT_EXTRA_ARGS: '--custom-var=checkout_arm=True --custom-var=checkout_arm64=True'
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Electron
|
- name: Checkout Electron
|
||||||
|
|||||||
4
.github/workflows/macos-publish.yml
vendored
4
.github/workflows/macos-publish.yml
vendored
@@ -6,7 +6,7 @@ on:
|
|||||||
build-image-sha:
|
build-image-sha:
|
||||||
type: string
|
type: string
|
||||||
description: 'SHA for electron/build image'
|
description: 'SHA for electron/build image'
|
||||||
default: 'bc2f48b2415a670de18d13605b1cf0eb5fdbaae1'
|
default: '424eedbf277ad9749ffa9219068aa72ed4a5e373'
|
||||||
required: true
|
required: true
|
||||||
upload-to-storage:
|
upload-to-storage:
|
||||||
description: 'Uploads to Azure storage'
|
description: 'Uploads to Azure storage'
|
||||||
@@ -28,6 +28,7 @@ jobs:
|
|||||||
- /mnt/cross-instance-cache:/mnt/cross-instance-cache
|
- /mnt/cross-instance-cache:/mnt/cross-instance-cache
|
||||||
- /var/run/sas:/var/run/sas
|
- /var/run/sas:/var/run/sas
|
||||||
env:
|
env:
|
||||||
|
CHROMIUM_GIT_COOKIE: ${{ secrets.CHROMIUM_GIT_COOKIE }}
|
||||||
GCLIENT_EXTRA_ARGS: '--custom-var=checkout_mac=True --custom-var=host_os=mac'
|
GCLIENT_EXTRA_ARGS: '--custom-var=checkout_mac=True --custom-var=host_os=mac'
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Electron
|
- name: Checkout Electron
|
||||||
@@ -39,6 +40,7 @@ jobs:
|
|||||||
uses: ./src/electron/.github/actions/checkout
|
uses: ./src/electron/.github/actions/checkout
|
||||||
with:
|
with:
|
||||||
generate-sas-token: 'true'
|
generate-sas-token: 'true'
|
||||||
|
target-platform: macos
|
||||||
|
|
||||||
publish-x64-darwin:
|
publish-x64-darwin:
|
||||||
uses: ./.github/workflows/pipeline-segment-electron-build.yml
|
uses: ./.github/workflows/pipeline-segment-electron-build.yml
|
||||||
|
|||||||
3
.github/workflows/pipeline-electron-lint.yml
vendored
3
.github/workflows/pipeline-electron-lint.yml
vendored
@@ -61,6 +61,9 @@ jobs:
|
|||||||
curl -sL "https://chromium.googlesource.com/chromium/src/+/${chromium_revision}/buildtools/DEPS?format=TEXT" | base64 -d > src/buildtools/DEPS
|
curl -sL "https://chromium.googlesource.com/chromium/src/+/${chromium_revision}/buildtools/DEPS?format=TEXT" | base64 -d > src/buildtools/DEPS
|
||||||
|
|
||||||
gclient sync --spec="solutions=[{'name':'src/buildtools','url':None,'deps_file':'DEPS','custom_vars':{'process_deps':True},'managed':False}]"
|
gclient sync --spec="solutions=[{'name':'src/buildtools','url':None,'deps_file':'DEPS','custom_vars':{'process_deps':True},'managed':False}]"
|
||||||
|
- name: Add ESLint problem matcher
|
||||||
|
shell: bash
|
||||||
|
run: echo "::add-matcher::src/electron/.github/problem-matchers/eslint-stylish.json"
|
||||||
- name: Run Lint
|
- name: Run Lint
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ jobs:
|
|||||||
if: ${{ inputs.target-platform == 'macos' }}
|
if: ${{ inputs.target-platform == 'macos' }}
|
||||||
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a
|
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a
|
||||||
with:
|
with:
|
||||||
node-version: 20.11.x
|
node-version: 20.19.x
|
||||||
cache: yarn
|
cache: yarn
|
||||||
cache-dependency-path: src/electron/yarn.lock
|
cache-dependency-path: src/electron/yarn.lock
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
@@ -129,24 +129,8 @@ jobs:
|
|||||||
echo "GN_EXTRA_ARGS=$GN_EXTRA_ARGS" >> $GITHUB_ENV
|
echo "GN_EXTRA_ARGS=$GN_EXTRA_ARGS" >> $GITHUB_ENV
|
||||||
- name: Set Chromium Git Cookie
|
- name: Set Chromium Git Cookie
|
||||||
uses: ./src/electron/.github/actions/set-chromium-cookie
|
uses: ./src/electron/.github/actions/set-chromium-cookie
|
||||||
- name: Get Depot Tools
|
- name: Install Build Tools
|
||||||
timeout-minutes: 5
|
uses: ./src/electron/.github/actions/install-build-tools
|
||||||
run: |
|
|
||||||
git clone --filter=tree:0 https://chromium.googlesource.com/chromium/tools/depot_tools.git
|
|
||||||
|
|
||||||
SEDOPTION="-i"
|
|
||||||
if [ "`uname`" = "Darwin" ]; then
|
|
||||||
SEDOPTION="-i ''"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# remove ninjalog_uploader_wrapper.py from autoninja since we don't use it and it causes problems
|
|
||||||
sed $SEDOPTION '/ninjalog_uploader_wrapper.py/d' ./depot_tools/autoninja
|
|
||||||
|
|
||||||
# Ensure depot_tools does not update.
|
|
||||||
test -d depot_tools && cd depot_tools
|
|
||||||
touch .disable_auto_update
|
|
||||||
- name: Add Depot Tools to PATH
|
|
||||||
run: echo "$(pwd)/depot_tools" >> $GITHUB_PATH
|
|
||||||
- name: Generate DEPS Hash
|
- name: Generate DEPS Hash
|
||||||
run: |
|
run: |
|
||||||
node src/electron/script/generate-deps-hash.js
|
node src/electron/script/generate-deps-hash.js
|
||||||
@@ -154,24 +138,26 @@ jobs:
|
|||||||
echo "DEPSHASH=$DEPSHASH" >> $GITHUB_ENV
|
echo "DEPSHASH=$DEPSHASH" >> $GITHUB_ENV
|
||||||
echo "CACHE_PATH=$DEPSHASH.tar" >> $GITHUB_ENV
|
echo "CACHE_PATH=$DEPSHASH.tar" >> $GITHUB_ENV
|
||||||
- name: Restore src cache via AZCopy
|
- name: Restore src cache via AZCopy
|
||||||
if: ${{ inputs.target-platform == 'macos' }}
|
if: ${{ inputs.target-platform != 'linux' }}
|
||||||
uses: ./src/electron/.github/actions/restore-cache-azcopy
|
uses: ./src/electron/.github/actions/restore-cache-azcopy
|
||||||
|
with:
|
||||||
|
target-platform: ${{ inputs.target-platform }}
|
||||||
- name: Restore src cache via AKS
|
- name: Restore src cache via AKS
|
||||||
if: ${{ inputs.target-platform == 'linux' }}
|
if: ${{ inputs.target-platform == 'linux' }}
|
||||||
uses: ./src/electron/.github/actions/restore-cache-aks
|
uses: ./src/electron/.github/actions/restore-cache-aks
|
||||||
- name: Checkout src via gclient sync
|
|
||||||
if: ${{ inputs.target-platform == 'win' }}
|
|
||||||
uses: ./src/electron/.github/actions/checkout
|
|
||||||
with:
|
|
||||||
use-cache: 'false'
|
|
||||||
- name: Checkout Electron
|
- name: Checkout Electron
|
||||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
|
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
|
||||||
with:
|
with:
|
||||||
path: src/electron
|
path: src/electron
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
ref: ${{ github.event.pull_request.head.sha }}
|
ref: ${{ github.event.pull_request.head.sha }}
|
||||||
- name: Install Build Tools
|
- name: Fix Sync
|
||||||
uses: ./src/electron/.github/actions/install-build-tools
|
if: ${{ inputs.target-platform != 'linux' }}
|
||||||
|
uses: ./src/electron/.github/actions/fix-sync
|
||||||
|
with:
|
||||||
|
target-platform: ${{ inputs.target-platform }}
|
||||||
|
env:
|
||||||
|
ELECTRON_DEPOT_TOOLS_DISABLE_LOG: true
|
||||||
- name: Init Build Tools
|
- name: Init Build Tools
|
||||||
run: |
|
run: |
|
||||||
e init -f --root=$(pwd) --out=Default ${{ inputs.gn-build-type }} --import ${{ inputs.gn-build-type }} --target-cpu ${{ inputs.target-arch }}
|
e init -f --root=$(pwd) --out=Default ${{ inputs.gn-build-type }} --import ${{ inputs.gn-build-type }} --target-cpu ${{ inputs.target-arch }}
|
||||||
@@ -184,9 +170,6 @@ jobs:
|
|||||||
echo "DEPSHASH=$(cat src/electron/.depshash)" >> $GITHUB_ENV
|
echo "DEPSHASH=$(cat src/electron/.depshash)" >> $GITHUB_ENV
|
||||||
- name: Add CHROMIUM_BUILDTOOLS_PATH to env
|
- name: Add CHROMIUM_BUILDTOOLS_PATH to env
|
||||||
run: echo "CHROMIUM_BUILDTOOLS_PATH=$(pwd)/src/buildtools" >> $GITHUB_ENV
|
run: echo "CHROMIUM_BUILDTOOLS_PATH=$(pwd)/src/buildtools" >> $GITHUB_ENV
|
||||||
- name: Fix Sync (macOS)
|
|
||||||
if: ${{ inputs.target-platform == 'macos' }}
|
|
||||||
uses: ./src/electron/.github/actions/fix-sync-macos
|
|
||||||
- name: Setup Number of Ninja Processes
|
- name: Setup Number of Ninja Processes
|
||||||
run: |
|
run: |
|
||||||
echo "NUMBER_OF_NINJA_PROCESSES=${{ inputs.target-platform != 'macos' && '300' || '200' }}" >> $GITHUB_ENV
|
echo "NUMBER_OF_NINJA_PROCESSES=${{ inputs.target-platform != 'macos' && '300' || '200' }}" >> $GITHUB_ENV
|
||||||
|
|||||||
@@ -65,7 +65,9 @@ jobs:
|
|||||||
sudo rm -rf $TMPDIR/del-target
|
sudo rm -rf $TMPDIR/del-target
|
||||||
- name: Check disk space after freeing up space
|
- name: Check disk space after freeing up space
|
||||||
if: ${{ inputs.target-platform == 'macos' }}
|
if: ${{ inputs.target-platform == 'macos' }}
|
||||||
run: df -h
|
run: df -h
|
||||||
|
- name: Set Chromium Git Cookie
|
||||||
|
uses: ./src/electron/.github/actions/set-chromium-cookie
|
||||||
- name: Install Build Tools
|
- name: Install Build Tools
|
||||||
uses: ./src/electron/.github/actions/install-build-tools
|
uses: ./src/electron/.github/actions/install-build-tools
|
||||||
- name: Enable windows toolchain
|
- name: Enable windows toolchain
|
||||||
@@ -81,9 +83,13 @@ jobs:
|
|||||||
- name: Restore src cache via AZCopy
|
- name: Restore src cache via AZCopy
|
||||||
if: ${{ inputs.target-platform == 'macos' }}
|
if: ${{ inputs.target-platform == 'macos' }}
|
||||||
uses: ./src/electron/.github/actions/restore-cache-azcopy
|
uses: ./src/electron/.github/actions/restore-cache-azcopy
|
||||||
|
with:
|
||||||
|
target-platform: ${{ inputs.target-platform }}
|
||||||
- name: Restore src cache via AKS
|
- name: Restore src cache via AKS
|
||||||
if: ${{ inputs.target-platform == 'linux' || inputs.target-platform == 'win' }}
|
if: ${{ inputs.target-platform == 'linux' || inputs.target-platform == 'win' }}
|
||||||
uses: ./src/electron/.github/actions/restore-cache-aks
|
uses: ./src/electron/.github/actions/restore-cache-aks
|
||||||
|
with:
|
||||||
|
target-platform: ${{ inputs.target-platform }}
|
||||||
- name: Run Electron Only Hooks
|
- name: Run Electron Only Hooks
|
||||||
run: |
|
run: |
|
||||||
echo "solutions=[{'name':'src/electron','url':None,'deps_file':'DEPS','custom_vars':{'process_deps':False},'managed':False}]" > tmpgclient
|
echo "solutions=[{'name':'src/electron','url':None,'deps_file':'DEPS','custom_vars':{'process_deps':False},'managed':False}]" > tmpgclient
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ jobs:
|
|||||||
if: ${{ inputs.target-platform == 'win' }}
|
if: ${{ inputs.target-platform == 'win' }}
|
||||||
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a
|
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a
|
||||||
with:
|
with:
|
||||||
node-version: 20.11.x
|
node-version: 20.19.x
|
||||||
- name: Add TCC permissions on macOS
|
- name: Add TCC permissions on macOS
|
||||||
if: ${{ inputs.target-platform == 'macos' }}
|
if: ${{ inputs.target-platform == 'macos' }}
|
||||||
run: |
|
run: |
|
||||||
@@ -100,9 +100,9 @@ jobs:
|
|||||||
}
|
}
|
||||||
|
|
||||||
userValuesArray=(
|
userValuesArray=(
|
||||||
"'kTCCServiceMicrophone','/usr/local/opt/runner/provisioner/provisioner',1,2,4,1,NULL,NULL,0,'UNUSED',NULL,0,1687786159"
|
|
||||||
"'kTCCServiceCamera','/usr/local/opt/runner/provisioner/provisioner',1,2,4,1,NULL,NULL,0,'UNUSED',NULL,0,1687786159"
|
"'kTCCServiceCamera','/usr/local/opt/runner/provisioner/provisioner',1,2,4,1,NULL,NULL,0,'UNUSED',NULL,0,1687786159"
|
||||||
"'kTCCServiceBluetoothAlways','/usr/local/opt/runner/provisioner/provisioner',1,2,4,1,NULL,NULL,0,'UNUSED',NULL,0,1687786159"
|
"'kTCCServiceBluetoothAlways','/usr/local/opt/runner/provisioner/provisioner',1,2,4,1,NULL,NULL,0,'UNUSED',NULL,0,1687786159"
|
||||||
|
"'kTCCServiceAppleEvents','/usr/local/opt/runner/provisioner/provisioner',1,2,4,1,NULL,NULL,0,'UNUSED',NULL,0,1687786159"
|
||||||
)
|
)
|
||||||
for values in "${userValuesArray[@]}"; do
|
for values in "${userValuesArray[@]}"; do
|
||||||
# Sonoma and higher have a few extra values
|
# Sonoma and higher have a few extra values
|
||||||
@@ -134,6 +134,9 @@ jobs:
|
|||||||
git config --global core.filemode false
|
git config --global core.filemode false
|
||||||
git config --global core.autocrlf false
|
git config --global core.autocrlf false
|
||||||
git config --global branch.autosetuprebase always
|
git config --global branch.autosetuprebase always
|
||||||
|
git config --global core.fscache true
|
||||||
|
git config --global core.longpaths true
|
||||||
|
git config --global core.preloadindex true
|
||||||
git clone --filter=tree:0 https://chromium.googlesource.com/chromium/tools/depot_tools.git
|
git clone --filter=tree:0 https://chromium.googlesource.com/chromium/tools/depot_tools.git
|
||||||
# Ensure depot_tools does not update.
|
# Ensure depot_tools does not update.
|
||||||
test -d depot_tools && cd depot_tools
|
test -d depot_tools && cd depot_tools
|
||||||
@@ -190,7 +193,6 @@ jobs:
|
|||||||
MOCHA_REPORTER: mocha-multi-reporters
|
MOCHA_REPORTER: mocha-multi-reporters
|
||||||
MOCHA_MULTI_REPORTERS: mocha-junit-reporter, tap
|
MOCHA_MULTI_REPORTERS: mocha-junit-reporter, tap
|
||||||
ELECTRON_DISABLE_SECURITY_WARNINGS: 1
|
ELECTRON_DISABLE_SECURITY_WARNINGS: 1
|
||||||
ELECTRON_SKIP_NATIVE_MODULE_TESTS: true
|
|
||||||
DISPLAY: ':99.0'
|
DISPLAY: ':99.0'
|
||||||
NPM_CONFIG_MSVS_VERSION: '2022'
|
NPM_CONFIG_MSVS_VERSION: '2022'
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@@ -51,6 +51,8 @@ jobs:
|
|||||||
path: src/electron
|
path: src/electron
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
ref: ${{ github.event.pull_request.head.sha }}
|
ref: ${{ github.event.pull_request.head.sha }}
|
||||||
|
- name: Set Chromium Git Cookie
|
||||||
|
uses: ./src/electron/.github/actions/set-chromium-cookie
|
||||||
- name: Install Build Tools
|
- name: Install Build Tools
|
||||||
uses: ./src/electron/.github/actions/install-build-tools
|
uses: ./src/electron/.github/actions/install-build-tools
|
||||||
- name: Init Build Tools
|
- name: Init Build Tools
|
||||||
@@ -58,17 +60,6 @@ jobs:
|
|||||||
e init -f --root=$(pwd) --out=Default ${{ inputs.gn-build-type }} --import ${{ inputs.gn-build-type }} --target-cpu ${{ inputs.target-arch }}
|
e init -f --root=$(pwd) --out=Default ${{ inputs.gn-build-type }} --import ${{ inputs.gn-build-type }} --target-cpu ${{ inputs.target-arch }}
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
uses: ./src/electron/.github/actions/install-dependencies
|
uses: ./src/electron/.github/actions/install-dependencies
|
||||||
- name: Set Chromium Git Cookie
|
|
||||||
uses: ./src/electron/.github/actions/set-chromium-cookie
|
|
||||||
- name: Get Depot Tools
|
|
||||||
timeout-minutes: 5
|
|
||||||
run: |
|
|
||||||
git clone --filter=tree:0 https://chromium.googlesource.com/chromium/tools/depot_tools.git
|
|
||||||
# Ensure depot_tools does not update.
|
|
||||||
test -d depot_tools && cd depot_tools
|
|
||||||
touch .disable_auto_update
|
|
||||||
- name: Add Depot Tools to PATH
|
|
||||||
run: echo "$(pwd)/depot_tools" >> $GITHUB_PATH
|
|
||||||
- name: Download Generated Artifacts
|
- name: Download Generated Artifacts
|
||||||
uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806
|
uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806
|
||||||
with:
|
with:
|
||||||
@@ -114,6 +105,8 @@ jobs:
|
|||||||
path: src/electron
|
path: src/electron
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
ref: ${{ github.event.pull_request.head.sha }}
|
ref: ${{ github.event.pull_request.head.sha }}
|
||||||
|
- name: Set Chromium Git Cookie
|
||||||
|
uses: ./src/electron/.github/actions/set-chromium-cookie
|
||||||
- name: Install Build Tools
|
- name: Install Build Tools
|
||||||
uses: ./src/electron/.github/actions/install-build-tools
|
uses: ./src/electron/.github/actions/install-build-tools
|
||||||
- name: Init Build Tools
|
- name: Init Build Tools
|
||||||
@@ -121,17 +114,6 @@ jobs:
|
|||||||
e init -f --root=$(pwd) --out=Default ${{ inputs.gn-build-type }}
|
e init -f --root=$(pwd) --out=Default ${{ inputs.gn-build-type }}
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
uses: ./src/electron/.github/actions/install-dependencies
|
uses: ./src/electron/.github/actions/install-dependencies
|
||||||
- name: Set Chromium Git Cookie
|
|
||||||
uses: ./src/electron/.github/actions/set-chromium-cookie
|
|
||||||
- name: Get Depot Tools
|
|
||||||
timeout-minutes: 5
|
|
||||||
run: |
|
|
||||||
git clone --filter=tree:0 https://chromium.googlesource.com/chromium/tools/depot_tools.git
|
|
||||||
# Ensure depot_tools does not update.
|
|
||||||
test -d depot_tools && cd depot_tools
|
|
||||||
touch .disable_auto_update
|
|
||||||
- name: Add Depot Tools to PATH
|
|
||||||
run: echo "$(pwd)/depot_tools" >> $GITHUB_PATH
|
|
||||||
- name: Download Generated Artifacts
|
- name: Download Generated Artifacts
|
||||||
uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806
|
uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806
|
||||||
with:
|
with:
|
||||||
|
|||||||
9
.github/workflows/windows-publish.yml
vendored
9
.github/workflows/windows-publish.yml
vendored
@@ -6,7 +6,7 @@ on:
|
|||||||
build-image-sha:
|
build-image-sha:
|
||||||
type: string
|
type: string
|
||||||
description: 'SHA for electron/build image'
|
description: 'SHA for electron/build image'
|
||||||
default: 'bc2f48b2415a670de18d13605b1cf0eb5fdbaae1'
|
default: '424eedbf277ad9749ffa9219068aa72ed4a5e373'
|
||||||
required: true
|
required: true
|
||||||
upload-to-storage:
|
upload-to-storage:
|
||||||
description: 'Uploads to Azure storage'
|
description: 'Uploads to Azure storage'
|
||||||
@@ -25,8 +25,10 @@ jobs:
|
|||||||
image: ghcr.io/electron/build:${{ inputs.build-image-sha }}
|
image: ghcr.io/electron/build:${{ inputs.build-image-sha }}
|
||||||
options: --user root --device /dev/fuse --cap-add SYS_ADMIN
|
options: --user root --device /dev/fuse --cap-add SYS_ADMIN
|
||||||
volumes:
|
volumes:
|
||||||
- /mnt/cross-instance-cache:/mnt/cross-instance-cache
|
- /mnt/win-cache:/mnt/win-cache
|
||||||
|
- /var/run/sas:/var/run/sas
|
||||||
env:
|
env:
|
||||||
|
CHROMIUM_GIT_COOKIE_WINDOWS_STRING: ${{ secrets.CHROMIUM_GIT_COOKIE_WINDOWS_STRING }}
|
||||||
GCLIENT_EXTRA_ARGS: '--custom-var=checkout_win=True'
|
GCLIENT_EXTRA_ARGS: '--custom-var=checkout_win=True'
|
||||||
TARGET_OS: 'win'
|
TARGET_OS: 'win'
|
||||||
ELECTRON_DEPOT_TOOLS_WIN_TOOLCHAIN: '1'
|
ELECTRON_DEPOT_TOOLS_WIN_TOOLCHAIN: '1'
|
||||||
@@ -40,6 +42,9 @@ jobs:
|
|||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- name: Checkout & Sync & Save
|
- name: Checkout & Sync & Save
|
||||||
uses: ./src/electron/.github/actions/checkout
|
uses: ./src/electron/.github/actions/checkout
|
||||||
|
with:
|
||||||
|
generate-sas-token: 'true'
|
||||||
|
target-platform: win
|
||||||
|
|
||||||
publish-x64-win:
|
publish-x64-win:
|
||||||
uses: ./.github/workflows/pipeline-segment-electron-build.yml
|
uses: ./.github/workflows/pipeline-segment-electron-build.yml
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"config": {
|
"config": {
|
||||||
"extends": "@electron/lint-roller/configs/markdownlint.json",
|
"extends": "@electron/lint-roller/configs/markdownlint.json",
|
||||||
|
"descriptive-link-text": false,
|
||||||
"link-image-style": {
|
"link-image-style": {
|
||||||
"autolink": false,
|
"autolink": false,
|
||||||
"shortcut": false
|
"shortcut": false
|
||||||
@@ -26,6 +27,6 @@
|
|||||||
"no-newline-in-links": true
|
"no-newline-in-links": true
|
||||||
},
|
},
|
||||||
"customRules": [
|
"customRules": [
|
||||||
"@electron/lint-roller/markdownlint-rules/"
|
"./node_modules/@electron/lint-roller/markdownlint-rules/index.mjs"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
4
BUILD.gn
4
BUILD.gn
@@ -670,6 +670,8 @@ source_set("electron_lib") {
|
|||||||
sources += [
|
sources += [
|
||||||
"shell/browser/certificate_manager_model.cc",
|
"shell/browser/certificate_manager_model.cc",
|
||||||
"shell/browser/certificate_manager_model.h",
|
"shell/browser/certificate_manager_model.h",
|
||||||
|
"shell/browser/linux/x11_util.cc",
|
||||||
|
"shell/browser/linux/x11_util.h",
|
||||||
"shell/browser/ui/gtk_util.cc",
|
"shell/browser/ui/gtk_util.cc",
|
||||||
"shell/browser/ui/gtk_util.h",
|
"shell/browser/ui/gtk_util.h",
|
||||||
]
|
]
|
||||||
@@ -1246,7 +1248,7 @@ if (is_mac) {
|
|||||||
"//components/crash/core/app:run_as_crashpad_handler",
|
"//components/crash/core/app:run_as_crashpad_handler",
|
||||||
]
|
]
|
||||||
|
|
||||||
ldflags = []
|
ldflags = [ "/DELAYLOAD:ffmpeg.dll" ]
|
||||||
|
|
||||||
libs = [
|
libs = [
|
||||||
"comctl32.lib",
|
"comctl32.lib",
|
||||||
|
|||||||
6
DEPS
6
DEPS
@@ -2,9 +2,9 @@ gclient_gn_args_from = 'src'
|
|||||||
|
|
||||||
vars = {
|
vars = {
|
||||||
'chromium_version':
|
'chromium_version':
|
||||||
'135.0.7049.5',
|
'136.0.7103.177',
|
||||||
'node_version':
|
'node_version':
|
||||||
'v22.14.0',
|
'v22.17.1',
|
||||||
'nan_version':
|
'nan_version':
|
||||||
'e14bdcd1f72d62bca1d541b66da43130384ec213',
|
'e14bdcd1f72d62bca1d541b66da43130384ec213',
|
||||||
'squirrel.mac_version':
|
'squirrel.mac_version':
|
||||||
@@ -31,7 +31,7 @@ vars = {
|
|||||||
'sysroots_json_path': 'electron/script/sysroots.json',
|
'sysroots_json_path': 'electron/script/sysroots.json',
|
||||||
|
|
||||||
# KEEP IN SYNC WITH utils.js FILE
|
# KEEP IN SYNC WITH utils.js FILE
|
||||||
'yarn_version': '1.15.2',
|
'yarn_version': '1.22.22',
|
||||||
|
|
||||||
# To be able to build clean Chromium from sources.
|
# To be able to build clean Chromium from sources.
|
||||||
'apply_patches': True,
|
'apply_patches': True,
|
||||||
|
|||||||
14
README.md
14
README.md
@@ -44,29 +44,17 @@ Each Electron release provides binaries for macOS, Windows, and Linux.
|
|||||||
* Fedora 32 and newer
|
* Fedora 32 and newer
|
||||||
* Debian 10 and newer
|
* Debian 10 and newer
|
||||||
|
|
||||||
## Quick start & Electron Fiddle
|
## Electron Fiddle
|
||||||
|
|
||||||
Use [`Electron Fiddle`](https://github.com/electron/fiddle)
|
Use [`Electron Fiddle`](https://github.com/electron/fiddle)
|
||||||
to build, run, and package small Electron experiments, to see code examples for all of Electron's APIs, and
|
to build, run, and package small Electron experiments, to see code examples for all of Electron's APIs, and
|
||||||
to try out different versions of Electron. It's designed to make the start of your journey with
|
to try out different versions of Electron. It's designed to make the start of your journey with
|
||||||
Electron easier.
|
Electron easier.
|
||||||
|
|
||||||
Alternatively, clone and run the
|
|
||||||
[electron/electron-quick-start](https://github.com/electron/electron-quick-start)
|
|
||||||
repository to see a minimal Electron app in action:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
git clone https://github.com/electron/electron-quick-start
|
|
||||||
cd electron-quick-start
|
|
||||||
npm install
|
|
||||||
npm start
|
|
||||||
```
|
|
||||||
|
|
||||||
## Resources for learning Electron
|
## Resources for learning Electron
|
||||||
|
|
||||||
* [electronjs.org/docs](https://electronjs.org/docs) - All of Electron's documentation
|
* [electronjs.org/docs](https://electronjs.org/docs) - All of Electron's documentation
|
||||||
* [electron/fiddle](https://github.com/electron/fiddle) - A tool to build, run, and package small Electron experiments
|
* [electron/fiddle](https://github.com/electron/fiddle) - A tool to build, run, and package small Electron experiments
|
||||||
* [electron/electron-quick-start](https://github.com/electron/electron-quick-start) - A very basic starter Electron app
|
|
||||||
* [electronjs.org/community#boilerplates](https://electronjs.org/community#boilerplates) - Sample starter apps created by the community
|
* [electronjs.org/community#boilerplates](https://electronjs.org/community#boilerplates) - Sample starter apps created by the community
|
||||||
|
|
||||||
## Programmatic usage
|
## Programmatic usage
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"plugins": [
|
"plugins": [
|
||||||
"unicorn"
|
"import"
|
||||||
],
|
],
|
||||||
"rules": {
|
"rules": {
|
||||||
"unicorn/prefer-node-protocol": "error"
|
"import/enforce-node-protocol-usage": ["error", "always"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"plugins": [
|
"plugins": [
|
||||||
"unicorn"
|
"import"
|
||||||
],
|
],
|
||||||
"rules": {
|
"rules": {
|
||||||
"unicorn/prefer-node-protocol": "error"
|
"import/enforce-node-protocol-usage": ["error", "always"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,8 +96,9 @@ These individual tutorials expand on topics discussed in the guide above.
|
|||||||
* [Chrome Extensions Support](api/extensions.md)
|
* [Chrome Extensions Support](api/extensions.md)
|
||||||
* [Breaking API Changes](breaking-changes.md)
|
* [Breaking API Changes](breaking-changes.md)
|
||||||
|
|
||||||
### Custom DOM Elements:
|
### Custom Web Features:
|
||||||
|
|
||||||
|
* [`-electron-corner-smoothing` CSS Rule](api/corner-smoothing-css.md)
|
||||||
* [`<webview>` Tag](api/webview-tag.md)
|
* [`<webview>` Tag](api/webview-tag.md)
|
||||||
* [`window.open` Function](api/window-open.md)
|
* [`window.open` Function](api/window-open.md)
|
||||||
|
|
||||||
@@ -112,6 +113,7 @@ These individual tutorials expand on topics discussed in the guide above.
|
|||||||
* [dialog](api/dialog.md)
|
* [dialog](api/dialog.md)
|
||||||
* [globalShortcut](api/global-shortcut.md)
|
* [globalShortcut](api/global-shortcut.md)
|
||||||
* [inAppPurchase](api/in-app-purchase.md)
|
* [inAppPurchase](api/in-app-purchase.md)
|
||||||
|
* [ImageView](api/image-view.md)
|
||||||
* [ipcMain](api/ipc-main.md)
|
* [ipcMain](api/ipc-main.md)
|
||||||
* [Menu](api/menu.md)
|
* [Menu](api/menu.md)
|
||||||
* [MenuItem](api/menu-item.md)
|
* [MenuItem](api/menu-item.md)
|
||||||
|
|||||||
177
docs/api/app.md
177
docs/api/app.md
@@ -41,9 +41,10 @@ that was used to open the application, if it was launched from Notification Cent
|
|||||||
You can also call `app.isReady()` to check if this event has already fired and `app.whenReady()`
|
You can also call `app.isReady()` to check if this event has already fired and `app.whenReady()`
|
||||||
to get a Promise that is fulfilled when Electron is initialized.
|
to get a Promise that is fulfilled when Electron is initialized.
|
||||||
|
|
||||||
**Note**: The `ready` event is only fired after the main process has finished running the first
|
> [!NOTE]
|
||||||
tick of the event loop. If an Electron API needs to be called before the `ready` event, ensure
|
> The `ready` event is only fired after the main process has finished running the first
|
||||||
that it is called synchronously in the top-level context of the main process.
|
> tick of the event loop. If an Electron API needs to be called before the `ready` event, ensure
|
||||||
|
> that it is called synchronously in the top-level context of the main process.
|
||||||
|
|
||||||
### Event: 'window-all-closed'
|
### Event: 'window-all-closed'
|
||||||
|
|
||||||
@@ -66,12 +67,14 @@ Emitted before the application starts closing its windows.
|
|||||||
Calling `event.preventDefault()` will prevent the default behavior, which is
|
Calling `event.preventDefault()` will prevent the default behavior, which is
|
||||||
terminating the application.
|
terminating the application.
|
||||||
|
|
||||||
**Note:** If application quit was initiated by `autoUpdater.quitAndInstall()`,
|
> [!NOTE]
|
||||||
then `before-quit` is emitted _after_ emitting `close` event on all windows and
|
> If application quit was initiated by `autoUpdater.quitAndInstall()`,
|
||||||
closing them.
|
> 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
|
> [!NOTE]
|
||||||
to a shutdown/restart of the system or a user logout.
|
> On Windows, this event will not be emitted if the app is closed due
|
||||||
|
> to a shutdown/restart of the system or a user logout.
|
||||||
|
|
||||||
### Event: 'will-quit'
|
### Event: 'will-quit'
|
||||||
|
|
||||||
@@ -86,8 +89,9 @@ terminating the application.
|
|||||||
See the description of the `window-all-closed` event for the differences between
|
See the description of the `window-all-closed` event for the differences between
|
||||||
the `will-quit` and `window-all-closed` events.
|
the `will-quit` and `window-all-closed` events.
|
||||||
|
|
||||||
**Note:** On Windows, this event will not be emitted if the app is closed due
|
> [!NOTE]
|
||||||
to a shutdown/restart of the system or a user logout.
|
> On Windows, this event will not be emitted if the app is closed due
|
||||||
|
> to a shutdown/restart of the system or a user logout.
|
||||||
|
|
||||||
### Event: 'quit'
|
### Event: 'quit'
|
||||||
|
|
||||||
@@ -98,8 +102,9 @@ Returns:
|
|||||||
|
|
||||||
Emitted when the application is quitting.
|
Emitted when the application is quitting.
|
||||||
|
|
||||||
**Note:** On Windows, this event will not be emitted if the app is closed due
|
> [!NOTE]
|
||||||
to a shutdown/restart of the system or a user logout.
|
> On Windows, this event will not be emitted if the app is closed due
|
||||||
|
> to a shutdown/restart of the system or a user logout.
|
||||||
|
|
||||||
### Event: 'open-file' _macOS_
|
### Event: 'open-file' _macOS_
|
||||||
|
|
||||||
@@ -470,24 +475,28 @@ and `workingDirectory` is its current working directory. Usually
|
|||||||
applications respond to this by making their primary window focused and
|
applications respond to this by making their primary window focused and
|
||||||
non-minimized.
|
non-minimized.
|
||||||
|
|
||||||
**Note:** `argv` will not be exactly the same list of arguments as those passed
|
> [!NOTE]
|
||||||
to the second instance. The order might change and additional arguments might be appended.
|
> `argv` will not be exactly the same list of arguments as those passed
|
||||||
If you need to maintain the exact same arguments, it's advised to use `additionalData` instead.
|
> to the second instance. The order might change and additional arguments might be appended.
|
||||||
|
> If you need to maintain the exact same arguments, it's advised to use `additionalData` instead.
|
||||||
|
|
||||||
**Note:** If the second instance is started by a different user than the first, the `argv` array will not include the arguments.
|
> [!NOTE]
|
||||||
|
> If the second instance is started by a different user than the first, the `argv` array will not include the arguments.
|
||||||
|
|
||||||
This event is guaranteed to be emitted after the `ready` event of `app`
|
This event is guaranteed to be emitted after the `ready` event of `app`
|
||||||
gets emitted.
|
gets emitted.
|
||||||
|
|
||||||
**Note:** Extra command line arguments might be added by Chromium,
|
> [!NOTE]
|
||||||
such as `--original-process-start-time`.
|
> Extra command line arguments might be added by Chromium,
|
||||||
|
> such as `--original-process-start-time`.
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
|
|
||||||
The `app` object has the following methods:
|
The `app` object has the following methods:
|
||||||
|
|
||||||
**Note:** Some methods are only available on specific operating systems and are
|
> [!NOTE]
|
||||||
labeled as such.
|
> Some methods are only available on specific operating systems and are
|
||||||
|
> labeled as such.
|
||||||
|
|
||||||
### `app.quit()`
|
### `app.quit()`
|
||||||
|
|
||||||
@@ -679,7 +688,8 @@ preferred over `name` by Electron.
|
|||||||
|
|
||||||
Overrides the current application's name.
|
Overrides the current application's name.
|
||||||
|
|
||||||
**Note:** This function overrides the name used internally by Electron; it does not affect the name that the OS uses.
|
> [!NOTE]
|
||||||
|
> This function overrides the name used internally by Electron; it does not affect the name that the OS uses.
|
||||||
|
|
||||||
### `app.getLocale()`
|
### `app.getLocale()`
|
||||||
|
|
||||||
@@ -688,18 +698,22 @@ Possible return values are documented [here](https://source.chromium.org/chromiu
|
|||||||
|
|
||||||
To set the locale, you'll want to use a command line switch at app startup, which may be found [here](command-line-switches.md).
|
To set the locale, you'll want to use a command line switch at app startup, which may be found [here](command-line-switches.md).
|
||||||
|
|
||||||
**Note:** When distributing your packaged app, you have to also ship the
|
> [!NOTE]
|
||||||
`locales` folder.
|
> When distributing your packaged app, you have to also ship the
|
||||||
|
> `locales` folder.
|
||||||
|
|
||||||
**Note:** This API must be called after the `ready` event is emitted.
|
> [!NOTE]
|
||||||
|
> This API must be called after the `ready` event is emitted.
|
||||||
|
|
||||||
**Note:** To see example return values of this API compared to other locale and language APIs, see [`app.getPreferredSystemLanguages()`](#appgetpreferredsystemlanguages).
|
> [!NOTE]
|
||||||
|
> To see example return values of this API compared to other locale and language APIs, see [`app.getPreferredSystemLanguages()`](#appgetpreferredsystemlanguages).
|
||||||
|
|
||||||
### `app.getLocaleCountryCode()`
|
### `app.getLocaleCountryCode()`
|
||||||
|
|
||||||
Returns `string` - User operating system's locale two-letter [ISO 3166](https://www.iso.org/iso-3166-country-codes.html) country code. The value is taken from native OS APIs.
|
Returns `string` - User operating system's locale two-letter [ISO 3166](https://www.iso.org/iso-3166-country-codes.html) country code. The value is taken from native OS APIs.
|
||||||
|
|
||||||
**Note:** When unable to detect locale country code, it returns empty string.
|
> [!NOTE]
|
||||||
|
> When unable to detect locale country code, it returns empty string.
|
||||||
|
|
||||||
### `app.getSystemLocale()`
|
### `app.getSystemLocale()`
|
||||||
|
|
||||||
@@ -712,9 +726,11 @@ Different operating systems also use the regional data differently:
|
|||||||
|
|
||||||
Therefore, this API can be used for purposes such as choosing a format for rendering dates and times in a calendar app, especially when the developer wants the format to be consistent with the OS.
|
Therefore, this API can be used for purposes such as choosing a format for rendering dates and times in a calendar app, especially when the developer wants the format to be consistent with the OS.
|
||||||
|
|
||||||
**Note:** This API must be called after the `ready` event is emitted.
|
> [!NOTE]
|
||||||
|
> This API must be called after the `ready` event is emitted.
|
||||||
|
|
||||||
**Note:** To see example return values of this API compared to other locale and language APIs, see [`app.getPreferredSystemLanguages()`](#appgetpreferredsystemlanguages).
|
> [!NOTE]
|
||||||
|
> To see example return values of this API compared to other locale and language APIs, see [`app.getPreferredSystemLanguages()`](#appgetpreferredsystemlanguages).
|
||||||
|
|
||||||
### `app.getPreferredSystemLanguages()`
|
### `app.getPreferredSystemLanguages()`
|
||||||
|
|
||||||
@@ -777,16 +793,18 @@ Once registered, all links with `your-protocol://` will be opened with the
|
|||||||
current executable. The whole link, including protocol, will be passed to your
|
current executable. The whole link, including protocol, will be passed to your
|
||||||
application as a parameter.
|
application as a parameter.
|
||||||
|
|
||||||
**Note:** On macOS, you can only register protocols that have been added to
|
> [!NOTE]
|
||||||
your app's `info.plist`, which cannot be modified at runtime. However, you can
|
> On macOS, you can only register protocols that have been added to
|
||||||
change the file during build time via [Electron Forge][electron-forge],
|
> your app's `info.plist`, which cannot be modified at runtime. However, you can
|
||||||
[Electron Packager][electron-packager], or by editing `info.plist` with a text
|
> change the file during build time via [Electron Forge][electron-forge],
|
||||||
editor. Please refer to [Apple's documentation][CFBundleURLTypes] for details.
|
> [Electron Packager][electron-packager], or by editing `info.plist` with a text
|
||||||
|
> editor. Please refer to [Apple's documentation][CFBundleURLTypes] for details.
|
||||||
|
|
||||||
**Note:** In a Windows Store environment (when packaged as an `appx`) this API
|
> [!NOTE]
|
||||||
will return `true` for all calls but the registry key it sets won't be accessible
|
> In a Windows Store environment (when packaged as an `appx`) this API
|
||||||
by other applications. In order to register your Windows Store application
|
> will return `true` for all calls but the registry key it sets won't be accessible
|
||||||
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).
|
> by other applications. In order to register your Windows Store application
|
||||||
|
> as a default protocol handler you must [declare the protocol in your manifest](https://learn.microsoft.com/en-us/uwp/schemas/appxpackage/uapmanifestschema/element-uap-protocol).
|
||||||
|
|
||||||
The API uses the Windows Registry and `LSSetDefaultHandlerForURLScheme` internally.
|
The API uses the Windows Registry and `LSSetDefaultHandlerForURLScheme` internally.
|
||||||
|
|
||||||
@@ -810,11 +828,12 @@ protocol (aka URI scheme). If so, it will remove the app as the default handler.
|
|||||||
Returns `boolean` - Whether the current executable is the default handler for a
|
Returns `boolean` - Whether the current executable is the default handler for a
|
||||||
protocol (aka URI scheme).
|
protocol (aka URI scheme).
|
||||||
|
|
||||||
**Note:** On macOS, you can use this method to check if the app has been
|
> [!NOTE]
|
||||||
registered as the default protocol handler for a protocol. You can also verify
|
> On macOS, you can use this method to check if the app has been
|
||||||
this by checking `~/Library/Preferences/com.apple.LaunchServices.plist` on the
|
> registered as the default protocol handler for a protocol. You can also verify
|
||||||
macOS machine. Please refer to
|
> this by checking `~/Library/Preferences/com.apple.LaunchServices.plist` on the
|
||||||
[Apple's documentation][LSCopyDefaultHandlerForURLScheme] for details.
|
> macOS machine. Please refer to
|
||||||
|
> [Apple's documentation][LSCopyDefaultHandlerForURLScheme] for details.
|
||||||
|
|
||||||
The API uses the Windows Registry and `LSCopyDefaultHandlerForURLScheme` internally.
|
The API uses the Windows Registry and `LSCopyDefaultHandlerForURLScheme` internally.
|
||||||
|
|
||||||
@@ -858,8 +877,9 @@ Adds `tasks` to the [Tasks][tasks] category of the Jump List on Windows.
|
|||||||
|
|
||||||
Returns `boolean` - Whether the call succeeded.
|
Returns `boolean` - Whether the call succeeded.
|
||||||
|
|
||||||
**Note:** If you'd like to customize the Jump List even more use
|
> [!NOTE]
|
||||||
`app.setJumpList(categories)` instead.
|
> If you'd like to customize the Jump List even more use
|
||||||
|
> `app.setJumpList(categories)` instead.
|
||||||
|
|
||||||
### `app.getJumpListSettings()` _Windows_
|
### `app.getJumpListSettings()` _Windows_
|
||||||
|
|
||||||
@@ -897,21 +917,24 @@ following strings:
|
|||||||
If `categories` is `null` the previously set custom Jump List (if any) will be
|
If `categories` is `null` the previously set custom Jump List (if any) will be
|
||||||
replaced by the standard Jump List for the app (managed by Windows).
|
replaced by the standard Jump List for the app (managed by Windows).
|
||||||
|
|
||||||
**Note:** If a `JumpListCategory` object has neither the `type` nor the `name`
|
> [!NOTE]
|
||||||
property set then its `type` is assumed to be `tasks`. If the `name` property
|
> If a `JumpListCategory` object has neither the `type` nor the `name`
|
||||||
|
> property set then its `type` is assumed to be `tasks`. If the `name` property
|
||||||
is set but the `type` property is omitted then the `type` is assumed to be
|
is set but the `type` property is omitted then the `type` is assumed to be
|
||||||
`custom`.
|
`custom`.
|
||||||
|
|
||||||
**Note:** Users can remove items from custom categories, and Windows will not
|
> [!NOTE]
|
||||||
allow a removed item to be added back into a custom category until **after**
|
> Users can remove items from custom categories, and Windows will not
|
||||||
the next successful call to `app.setJumpList(categories)`. Any attempt to
|
> allow a removed item to be added back into a custom category until **after**
|
||||||
re-add a removed item to a custom category earlier than that will result in the
|
> the next successful call to `app.setJumpList(categories)`. Any attempt to
|
||||||
entire custom category being omitted from the Jump List. The list of removed
|
> re-add a removed item to a custom category earlier than that will result in the
|
||||||
items can be obtained using `app.getJumpListSettings()`.
|
> entire custom category being omitted from the Jump List. The list of removed
|
||||||
|
> items can be obtained using `app.getJumpListSettings()`.
|
||||||
|
|
||||||
**Note:** The maximum length of a Jump List item's `description` property is
|
> [!NOTE]
|
||||||
260 characters. Beyond this limit, the item will not be added to the Jump
|
> The maximum length of a Jump List item's `description` property is
|
||||||
List, nor will it be displayed.
|
> 260 characters. Beyond this limit, the item will not be added to the Jump
|
||||||
|
> List, nor will it be displayed.
|
||||||
|
|
||||||
Here's a very simple example of creating a custom Jump List:
|
Here's a very simple example of creating a custom Jump List:
|
||||||
|
|
||||||
@@ -1110,6 +1133,11 @@ indicates success while any other value indicates failure according to Chromium
|
|||||||
resolver will attempt to use the system's DNS settings to do DNS lookups
|
resolver will attempt to use the system's DNS settings to do DNS lookups
|
||||||
itself. Enabled by default on macOS, disabled by default on Windows and
|
itself. Enabled by default on macOS, disabled by default on Windows and
|
||||||
Linux.
|
Linux.
|
||||||
|
* `enableHappyEyeballs` boolean (optional) - Whether the
|
||||||
|
[Happy Eyeballs V3][happy-eyeballs-v3] algorithm should be used in creating
|
||||||
|
network connections. When enabled, hostnames resolving to multiple IP
|
||||||
|
addresses will be attempted in parallel to have a chance at establishing a
|
||||||
|
connection more quickly.
|
||||||
* `secureDnsMode` string (optional) - Can be 'off', 'automatic' or 'secure'.
|
* `secureDnsMode` string (optional) - Can be 'off', 'automatic' or 'secure'.
|
||||||
Configures the DNS-over-HTTP mode. When 'off', no DoH lookups will be
|
Configures the DNS-over-HTTP mode. When 'off', no DoH lookups will be
|
||||||
performed. When 'automatic', DoH lookups will be performed first if DoH is
|
performed. When 'automatic', DoH lookups will be performed first if DoH is
|
||||||
@@ -1183,7 +1211,8 @@ Returns [`ProcessMetric[]`](structures/process-metric.md): Array of `ProcessMetr
|
|||||||
|
|
||||||
Returns [`GPUFeatureStatus`](structures/gpu-feature-status.md) - The Graphics Feature Status from `chrome://gpu/`.
|
Returns [`GPUFeatureStatus`](structures/gpu-feature-status.md) - The Graphics Feature Status from `chrome://gpu/`.
|
||||||
|
|
||||||
**Note:** This information is only usable after the `gpu-info-update` event is emitted.
|
> [!NOTE]
|
||||||
|
> This information is only usable after the `gpu-info-update` event is emitted.
|
||||||
|
|
||||||
### `app.getGPUInfo(infoType)`
|
### `app.getGPUInfo(infoType)`
|
||||||
|
|
||||||
@@ -1237,11 +1266,13 @@ badge.
|
|||||||
|
|
||||||
On macOS, it shows on the dock icon. On Linux, it only works for Unity launcher.
|
On macOS, it shows on the dock icon. On Linux, it only works for Unity launcher.
|
||||||
|
|
||||||
**Note:** Unity launcher requires a `.desktop` file to work. For more information,
|
> [!NOTE]
|
||||||
please read the [Unity integration documentation][unity-requirement].
|
> 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
|
> [!NOTE]
|
||||||
to display notifications for this method to work.
|
> On macOS, you need to ensure that your application has the permission
|
||||||
|
> to display notifications for this method to work.
|
||||||
|
|
||||||
### `app.getBadgeCount()` _Linux_ _macOS_
|
### `app.getBadgeCount()` _Linux_ _macOS_
|
||||||
|
|
||||||
@@ -1343,7 +1374,8 @@ details. Disabled by default.
|
|||||||
|
|
||||||
This API must be called after the `ready` event is emitted.
|
This API must be called after the `ready` event is emitted.
|
||||||
|
|
||||||
**Note:** Rendering accessibility tree can significantly affect the performance of your app. It should not be enabled by default.
|
> [!NOTE]
|
||||||
|
> Rendering accessibility tree can significantly affect the performance of your app. It should not be enabled by default.
|
||||||
|
|
||||||
### `app.showAboutPanel()`
|
### `app.showAboutPanel()`
|
||||||
|
|
||||||
@@ -1471,7 +1503,8 @@ By using this API, important information such as password and other sensitive in
|
|||||||
See [Apple's documentation](https://developer.apple.com/library/archive/technotes/tn2150/_index.html) for more
|
See [Apple's documentation](https://developer.apple.com/library/archive/technotes/tn2150/_index.html) for more
|
||||||
details.
|
details.
|
||||||
|
|
||||||
**Note:** Enable `Secure Keyboard Entry` only when it is needed and disable it when it is no longer needed.
|
> [!NOTE]
|
||||||
|
> Enable `Secure Keyboard Entry` only when it is needed and disable it when it is no longer needed.
|
||||||
|
|
||||||
### `app.setProxy(config)`
|
### `app.setProxy(config)`
|
||||||
|
|
||||||
@@ -1485,7 +1518,7 @@ and internal requests made by the runtime (ex: geolocation queries).
|
|||||||
|
|
||||||
This method can only be called after app is ready.
|
This method can only be called after app is ready.
|
||||||
|
|
||||||
#### `app.resolveProxy(url)`
|
### `app.resolveProxy(url)`
|
||||||
|
|
||||||
* `url` URL
|
* `url` URL
|
||||||
|
|
||||||
@@ -1533,7 +1566,8 @@ See [Chromium's accessibility docs](https://www.chromium.org/developers/design-d
|
|||||||
|
|
||||||
This API must be called after the `ready` event is emitted.
|
This API must be called after the `ready` event is emitted.
|
||||||
|
|
||||||
**Note:** Rendering accessibility tree can significantly affect the performance of your app. It should not be enabled by default.
|
> [!NOTE]
|
||||||
|
> Rendering accessibility tree can significantly affect the performance of your app. It should not be enabled by default.
|
||||||
|
|
||||||
### `app.applicationMenu`
|
### `app.applicationMenu`
|
||||||
|
|
||||||
@@ -1546,11 +1580,13 @@ An `Integer` property that returns the badge count for current app. Setting the
|
|||||||
|
|
||||||
On macOS, setting this with any nonzero integer shows on the dock icon. On Linux, this property only works for Unity launcher.
|
On macOS, setting this with any nonzero integer shows on the dock icon. On Linux, this property only works for Unity launcher.
|
||||||
|
|
||||||
**Note:** Unity launcher requires a `.desktop` file to work. For more information,
|
> [!NOTE]
|
||||||
please read the [Unity integration documentation][unity-requirement].
|
> 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
|
> [!NOTE]
|
||||||
to display notifications for this property to take effect.
|
> On macOS, you need to ensure that your application has the permission
|
||||||
|
> to display notifications for this property to take effect.
|
||||||
|
|
||||||
### `app.commandLine` _Readonly_
|
### `app.commandLine` _Readonly_
|
||||||
|
|
||||||
@@ -1559,8 +1595,8 @@ command line arguments that Chromium uses.
|
|||||||
|
|
||||||
### `app.dock` _macOS_ _Readonly_
|
### `app.dock` _macOS_ _Readonly_
|
||||||
|
|
||||||
A [`Dock`](./dock.md) `| undefined` object that allows you to perform actions on your app icon in the user's
|
A `Dock | undefined` property ([`Dock`](./dock.md) on macOS, `undefined` on all other
|
||||||
dock on macOS.
|
platforms) that allows you to perform actions on your app icon in the user's dock.
|
||||||
|
|
||||||
### `app.isPackaged` _Readonly_
|
### `app.isPackaged` _Readonly_
|
||||||
|
|
||||||
@@ -1579,6 +1615,7 @@ A `boolean` property that returns `true` if the app is packaged, `false` otherw
|
|||||||
[Squirrel-Windows]: https://github.com/Squirrel/Squirrel.Windows
|
[Squirrel-Windows]: https://github.com/Squirrel/Squirrel.Windows
|
||||||
[JumpListBeginListMSDN]: https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-icustomdestinationlist-beginlist
|
[JumpListBeginListMSDN]: https://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
|
[about-panel-options]: https://developer.apple.com/reference/appkit/nsapplication/1428479-orderfrontstandardaboutpanelwith?language=objc
|
||||||
|
[happy-eyeballs-v3]: https://datatracker.ietf.org/doc/draft-pauly-happy-happyeyeballs-v3/
|
||||||
|
|
||||||
### `app.name`
|
### `app.name`
|
||||||
|
|
||||||
|
|||||||
@@ -26,8 +26,9 @@ requirements, you can read [Server Support][server-support]. Note that
|
|||||||
update process. Apps that need to disable ATS can add the
|
update process. Apps that need to disable ATS can add the
|
||||||
`NSAllowsArbitraryLoads` key to their app's plist.
|
`NSAllowsArbitraryLoads` key to their app's plist.
|
||||||
|
|
||||||
**Note:** Your application must be signed for automatic updates on macOS.
|
> [!IMPORTANT]
|
||||||
This is a requirement of `Squirrel.Mac`.
|
> Your application must be signed for automatic updates on macOS.
|
||||||
|
> This is a requirement of `Squirrel.Mac`.
|
||||||
|
|
||||||
### Windows
|
### Windows
|
||||||
|
|
||||||
@@ -93,8 +94,9 @@ Emitted when an update has been downloaded.
|
|||||||
|
|
||||||
On Windows only `releaseName` is available.
|
On Windows only `releaseName` is available.
|
||||||
|
|
||||||
**Note:** It is not strictly necessary to handle this event. A successfully
|
> [!NOTE]
|
||||||
downloaded update will still be applied the next time the application starts.
|
> It is not strictly necessary to handle this event. A successfully
|
||||||
|
> downloaded update will still be applied the next time the application starts.
|
||||||
|
|
||||||
### Event: 'before-quit-for-update'
|
### Event: 'before-quit-for-update'
|
||||||
|
|
||||||
@@ -125,8 +127,9 @@ Returns `string` - The current update feed URL.
|
|||||||
Asks the server whether there is an update. You must call `setFeedURL` before
|
Asks the server whether there is an update. You must call `setFeedURL` before
|
||||||
using this API.
|
using this API.
|
||||||
|
|
||||||
**Note:** If an update is available it will be downloaded automatically.
|
> [!NOTE]
|
||||||
Calling `autoUpdater.checkForUpdates()` twice will download the update two times.
|
> If an update is available it will be downloaded automatically.
|
||||||
|
> Calling `autoUpdater.checkForUpdates()` twice will download the update two times.
|
||||||
|
|
||||||
### `autoUpdater.quitAndInstall()`
|
### `autoUpdater.quitAndInstall()`
|
||||||
|
|
||||||
@@ -137,9 +140,10 @@ Under the hood calling `autoUpdater.quitAndInstall()` will close all application
|
|||||||
windows first, and automatically call `app.quit()` after all windows have been
|
windows first, and automatically call `app.quit()` after all windows have been
|
||||||
closed.
|
closed.
|
||||||
|
|
||||||
**Note:** It is not strictly necessary to call this function to apply an update,
|
> [!NOTE]
|
||||||
as a successfully downloaded update will always be applied the next time the
|
> It is not strictly necessary to call this function to apply an update,
|
||||||
application starts.
|
> as a successfully downloaded update will always be applied the next time the
|
||||||
|
> application starts.
|
||||||
|
|
||||||
[squirrel-mac]: https://github.com/Squirrel/Squirrel.Mac
|
[squirrel-mac]: https://github.com/Squirrel/Squirrel.Mac
|
||||||
[server-support]: https://github.com/Squirrel/Squirrel.Mac#server-support
|
[server-support]: https://github.com/Squirrel/Squirrel.Mac#server-support
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
Process: [Main](../glossary.md#main-process)
|
Process: [Main](../glossary.md#main-process)
|
||||||
|
|
||||||
> **Note**
|
> [!NOTE]
|
||||||
> `BaseWindow` provides a flexible way to compose multiple web views in a
|
> `BaseWindow` provides a flexible way to compose multiple web views in a
|
||||||
> single window. For windows with only a single, full-size web view, the
|
> single window. For windows with only a single, full-size web view, the
|
||||||
> [`BrowserWindow`](browser-window.md) class may be a simpler option.
|
> [`BrowserWindow`](browser-window.md) class may be a simpler option.
|
||||||
@@ -99,6 +99,10 @@ Process: [Main](../glossary.md#main-process)
|
|||||||
|
|
||||||
It creates a new `BaseWindow` with native properties as set by the `options`.
|
It creates a new `BaseWindow` with native properties as set by the `options`.
|
||||||
|
|
||||||
|
> [!WARNING]
|
||||||
|
> Electron's built-in classes cannot be subclassed in user code.
|
||||||
|
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
|
||||||
|
|
||||||
### `new BaseWindow([options])`
|
### `new BaseWindow([options])`
|
||||||
|
|
||||||
* `options` [BaseWindowConstructorOptions](structures/base-window-options.md?inline) (optional)
|
* `options` [BaseWindowConstructorOptions](structures/base-window-options.md?inline) (optional)
|
||||||
@@ -107,8 +111,9 @@ It creates a new `BaseWindow` with native properties as set by the `options`.
|
|||||||
|
|
||||||
Objects created with `new BaseWindow` emit the following events:
|
Objects created with `new BaseWindow` emit the following events:
|
||||||
|
|
||||||
**Note:** Some events are only available on specific operating systems and are
|
> [!NOTE]
|
||||||
labeled as such.
|
> Some events are only available on specific operating systems and are
|
||||||
|
> labeled as such.
|
||||||
|
|
||||||
#### Event: 'close'
|
#### Event: 'close'
|
||||||
|
|
||||||
@@ -137,7 +142,11 @@ window.onbeforeunload = (e) => {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
_**Note**: There is a subtle difference between the behaviors of `window.onbeforeunload = handler` and `window.addEventListener('beforeunload', handler)`. It is recommended to always set the `event.returnValue` explicitly, instead of only returning a value, as the former works more consistently within Electron._
|
> [!NOTE]
|
||||||
|
> There is a subtle difference between the behaviors of `window.onbeforeunload = handler` and
|
||||||
|
> `window.addEventListener('beforeunload', handler)`. It is recommended to always set the
|
||||||
|
> `event.returnValue` explicitly, instead of only returning a value, as the former works more
|
||||||
|
> consistently within Electron.
|
||||||
|
|
||||||
#### Event: 'closed'
|
#### Event: 'closed'
|
||||||
|
|
||||||
@@ -252,7 +261,8 @@ Emitted when the window is being moved to a new position.
|
|||||||
|
|
||||||
Emitted once when the window is moved to a new position.
|
Emitted once when the window is moved to a new position.
|
||||||
|
|
||||||
**Note**: On macOS this event is an alias of `move`.
|
> [!NOTE]
|
||||||
|
> On macOS, this event is an alias of `move`.
|
||||||
|
|
||||||
#### Event: 'enter-full-screen'
|
#### Event: 'enter-full-screen'
|
||||||
|
|
||||||
@@ -342,12 +352,12 @@ Emitted when the window has closed a sheet.
|
|||||||
|
|
||||||
Emitted when the native new tab button is clicked.
|
Emitted when the native new tab button is clicked.
|
||||||
|
|
||||||
#### Event: 'system-context-menu' _Windows_
|
#### Event: 'system-context-menu' _Windows_ _Linux_
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
* `event` Event
|
* `event` Event
|
||||||
* `point` [Point](structures/point.md) - The screen coordinates the context menu was triggered at
|
* `point` [Point](structures/point.md) - The screen coordinates where the context menu was triggered.
|
||||||
|
|
||||||
Emitted when the system context menu is triggered on the window, this is
|
Emitted when the system context menu is triggered on the window, this is
|
||||||
normally only triggered when the user right clicks on the non-client area
|
normally only triggered when the user right clicks on the non-client area
|
||||||
@@ -356,6 +366,8 @@ as `-webkit-app-region: drag` in a frameless window.
|
|||||||
|
|
||||||
Calling `event.preventDefault()` will prevent the menu from being displayed.
|
Calling `event.preventDefault()` will prevent the menu from being displayed.
|
||||||
|
|
||||||
|
To convert `point` to DIP, use [`screen.screenToDipPoint(point)`](./screen.md#screenscreentodippointpoint-windows-linux).
|
||||||
|
|
||||||
### Static Methods
|
### Static Methods
|
||||||
|
|
||||||
The `BaseWindow` class has the following static methods:
|
The `BaseWindow` class has the following static methods:
|
||||||
@@ -396,7 +408,7 @@ A `View` property for the content view of the window.
|
|||||||
|
|
||||||
A `string` (optional) property that is equal to the `tabbingIdentifier` passed to the `BrowserWindow` constructor or `undefined` if none was set.
|
A `string` (optional) property that is equal to the `tabbingIdentifier` passed to the `BrowserWindow` constructor or `undefined` if none was set.
|
||||||
|
|
||||||
#### `win.autoHideMenuBar`
|
#### `win.autoHideMenuBar` _Linux_ _Windows_
|
||||||
|
|
||||||
A `boolean` property that determines whether the window menu bar should hide itself automatically. Once set, the menu bar will only show when users press the single `Alt` key.
|
A `boolean` property that determines whether the window menu bar should hide itself automatically. Once set, the menu bar will only show when users press the single `Alt` key.
|
||||||
|
|
||||||
@@ -419,7 +431,8 @@ A `boolean` property that determines whether the window is focusable.
|
|||||||
|
|
||||||
A `boolean` property that determines whether the window is visible on all workspaces.
|
A `boolean` property that determines whether the window is visible on all workspaces.
|
||||||
|
|
||||||
**Note:** Always returns false on Windows.
|
> [!NOTE]
|
||||||
|
> Always returns false on Windows.
|
||||||
|
|
||||||
#### `win.shadow`
|
#### `win.shadow`
|
||||||
|
|
||||||
@@ -429,7 +442,8 @@ A `boolean` property that determines whether the window has a shadow.
|
|||||||
|
|
||||||
A `boolean` property that determines whether the menu bar should be visible.
|
A `boolean` property that determines whether the menu bar should be visible.
|
||||||
|
|
||||||
**Note:** If the menu bar is auto-hide, users can still bring up the menu bar by pressing the single `Alt` key.
|
> [!NOTE]
|
||||||
|
> If the menu bar is auto-hide, users can still bring up the menu bar by pressing the single `Alt` key.
|
||||||
|
|
||||||
#### `win.kiosk`
|
#### `win.kiosk`
|
||||||
|
|
||||||
@@ -450,7 +464,8 @@ and the icon of the file will show in window's title bar.
|
|||||||
|
|
||||||
A `string` property that determines the title of the native window.
|
A `string` property that determines the title of the native window.
|
||||||
|
|
||||||
**Note:** The title of the web page can be different from the title of the native window.
|
> [!NOTE]
|
||||||
|
> The title of the web page can be different from the title of the native window.
|
||||||
|
|
||||||
#### `win.minimizable` _macOS_ _Windows_
|
#### `win.minimizable` _macOS_ _Windows_
|
||||||
|
|
||||||
@@ -511,12 +526,17 @@ A `string` property that defines an alternative title provided only to
|
|||||||
accessibility tools such as screen readers. This string is not directly
|
accessibility tools such as screen readers. This string is not directly
|
||||||
visible to users.
|
visible to users.
|
||||||
|
|
||||||
|
#### `win.snapped` _Windows_ _Readonly_
|
||||||
|
|
||||||
|
A `boolean` property that indicates whether the window is arranged via [Snap.](https://support.microsoft.com/en-us/windows/snap-your-windows-885a9b1e-a983-a3b1-16cd-c531795e6241)
|
||||||
|
|
||||||
### Instance Methods
|
### Instance Methods
|
||||||
|
|
||||||
Objects created with `new BaseWindow` have the following instance methods:
|
Objects created with `new BaseWindow` have the following instance methods:
|
||||||
|
|
||||||
**Note:** Some methods are only available on specific operating systems and are
|
> [!NOTE]
|
||||||
labeled as such.
|
> Some methods are only available on specific operating systems and are
|
||||||
|
> labeled as such.
|
||||||
|
|
||||||
#### `win.setContentView(view)`
|
#### `win.setContentView(view)`
|
||||||
|
|
||||||
@@ -608,7 +628,8 @@ Returns `boolean` - Whether the window is minimized.
|
|||||||
|
|
||||||
Sets whether the window should be in fullscreen mode.
|
Sets whether the window should be in fullscreen mode.
|
||||||
|
|
||||||
**Note:** On macOS, fullscreen transitions take place asynchronously. If further actions depend on the fullscreen state, use the ['enter-full-screen'](base-window.md#event-enter-full-screen) or ['leave-full-screen'](base-window.md#event-leave-full-screen) events.
|
> [!NOTE]
|
||||||
|
> On macOS, fullscreen transitions take place asynchronously. If further actions depend on the fullscreen state, use the ['enter-full-screen'](base-window.md#event-enter-full-screen) or > ['leave-full-screen'](base-window.md#event-leave-full-screen) events.
|
||||||
|
|
||||||
#### `win.isFullScreen()`
|
#### `win.isFullScreen()`
|
||||||
|
|
||||||
@@ -722,13 +743,15 @@ win.setBounds({ width: 100 })
|
|||||||
console.log(win.getBounds())
|
console.log(win.getBounds())
|
||||||
```
|
```
|
||||||
|
|
||||||
**Note:** On macOS, the y-coordinate value cannot be smaller than the [Tray](tray.md) height. The tray height has changed over time and depends on the operating system, but is between 20-40px. Passing a value lower than the tray height will result in a window that is flush to the tray.
|
> [!NOTE]
|
||||||
|
> On macOS, the y-coordinate value cannot be smaller than the [Tray](tray.md) height. The tray height has changed over time and depends on the operating system, but is between 20-40px. Passing a value lower than the tray height will result in a window that is flush to the tray.
|
||||||
|
|
||||||
#### `win.getBounds()`
|
#### `win.getBounds()`
|
||||||
|
|
||||||
Returns [`Rectangle`](structures/rectangle.md) - The `bounds` of the window as `Object`.
|
Returns [`Rectangle`](structures/rectangle.md) - The `bounds` of the window as `Object`.
|
||||||
|
|
||||||
**Note:** On macOS, the y-coordinate value returned will be at minimum the [Tray](tray.md) height. For example, calling `win.setBounds({ x: 25, y: 20, width: 800, height: 600 })` with a tray height of 38 means that `win.getBounds()` will return `{ x: 25, y: 38, width: 800, height: 600 }`.
|
> [!NOTE]
|
||||||
|
> On macOS, the y-coordinate value returned will be at minimum the [Tray](tray.md) height. For example, calling `win.setBounds({ x: 25, y: 20, width: 800, height: 600 })` with a tray height of 38 means that `win.getBounds()` will return `{ x: 25, y: 38, width: 800, height: 600 }`.
|
||||||
|
|
||||||
#### `win.getBackgroundColor()`
|
#### `win.getBackgroundColor()`
|
||||||
|
|
||||||
@@ -736,7 +759,8 @@ Returns `string` - Gets the background color of the window in Hex (`#RRGGBB`) fo
|
|||||||
|
|
||||||
See [Setting `backgroundColor`](browser-window.md#setting-the-backgroundcolor-property).
|
See [Setting `backgroundColor`](browser-window.md#setting-the-backgroundcolor-property).
|
||||||
|
|
||||||
**Note:** The alpha value is _not_ returned alongside the red, green, and blue values.
|
> [!NOTE]
|
||||||
|
> The alpha value is _not_ returned alongside the red, green, and blue values.
|
||||||
|
|
||||||
#### `win.setContentBounds(bounds[, animate])`
|
#### `win.setContentBounds(bounds[, animate])`
|
||||||
|
|
||||||
@@ -754,7 +778,8 @@ Returns [`Rectangle`](structures/rectangle.md) - The `bounds` of the window's cl
|
|||||||
|
|
||||||
Returns [`Rectangle`](structures/rectangle.md) - Contains the window bounds of the normal state
|
Returns [`Rectangle`](structures/rectangle.md) - Contains the window bounds of the normal state
|
||||||
|
|
||||||
**Note:** whatever the current state of the window : maximized, minimized or in fullscreen, this function always returns the position and size of the window in normal state. In normal state, getBounds and getNormalBounds returns the same [`Rectangle`](structures/rectangle.md).
|
> [!NOTE]
|
||||||
|
> Whatever the current state of the window : maximized, minimized or in fullscreen, this function always returns the position and size of the window in normal state. In normal state, getBounds and getNormalBounds returns the same [`Rectangle`](structures/rectangle.md).
|
||||||
|
|
||||||
#### `win.setEnabled(enable)`
|
#### `win.setEnabled(enable)`
|
||||||
|
|
||||||
@@ -951,8 +976,9 @@ Changes the title of native window to `title`.
|
|||||||
|
|
||||||
Returns `string` - The title of the native window.
|
Returns `string` - The title of the native window.
|
||||||
|
|
||||||
**Note:** The title of the web page can be different from the title of the native
|
> [!NOTE]
|
||||||
window.
|
> The title of the web page can be different from the title of the native
|
||||||
|
> window.
|
||||||
|
|
||||||
#### `win.setSheetOffset(offsetY[, offsetX])` _macOS_
|
#### `win.setSheetOffset(offsetY[, offsetX])` _macOS_
|
||||||
|
|
||||||
@@ -1226,8 +1252,9 @@ in the taskbar.
|
|||||||
|
|
||||||
Sets the properties for the window's taskbar button.
|
Sets the properties for the window's taskbar button.
|
||||||
|
|
||||||
**Note:** `relaunchCommand` and `relaunchDisplayName` must always be set
|
> [!NOTE]
|
||||||
together. If one of those properties is not set, then neither will be used.
|
> `relaunchCommand` and `relaunchDisplayName` must always be set
|
||||||
|
> together. If one of those properties is not set, then neither will be used.
|
||||||
|
|
||||||
#### `win.setIcon(icon)` _Windows_ _Linux_
|
#### `win.setIcon(icon)` _Windows_ _Linux_
|
||||||
|
|
||||||
@@ -1264,6 +1291,13 @@ Sets whether the menu bar should be visible. If the menu bar is auto-hide, users
|
|||||||
|
|
||||||
Returns `boolean` - Whether the menu bar is visible.
|
Returns `boolean` - Whether the menu bar is visible.
|
||||||
|
|
||||||
|
#### `win.isSnapped()` _Windows_
|
||||||
|
|
||||||
|
Returns `boolean` - whether the window is arranged via [Snap.](https://support.microsoft.com/en-us/windows/snap-your-windows-885a9b1e-a983-a3b1-16cd-c531795e6241)
|
||||||
|
|
||||||
|
The window is snapped via buttons shown when the mouse is hovered over window
|
||||||
|
maximize button, or by dragging it to the edges of the screen.
|
||||||
|
|
||||||
#### `win.setVisibleOnAllWorkspaces(visible[, options])` _macOS_ _Linux_
|
#### `win.setVisibleOnAllWorkspaces(visible[, options])` _macOS_ _Linux_
|
||||||
|
|
||||||
* `visible` boolean
|
* `visible` boolean
|
||||||
@@ -1280,13 +1314,15 @@ Returns `boolean` - Whether the menu bar is visible.
|
|||||||
|
|
||||||
Sets whether the window should be visible on all workspaces.
|
Sets whether the window should be visible on all workspaces.
|
||||||
|
|
||||||
**Note:** This API does nothing on Windows.
|
> [!NOTE]
|
||||||
|
> This API does nothing on Windows.
|
||||||
|
|
||||||
#### `win.isVisibleOnAllWorkspaces()` _macOS_ _Linux_
|
#### `win.isVisibleOnAllWorkspaces()` _macOS_ _Linux_
|
||||||
|
|
||||||
Returns `boolean` - Whether the window is visible on all workspaces.
|
Returns `boolean` - Whether the window is visible on all workspaces.
|
||||||
|
|
||||||
**Note:** This API always returns false on Windows.
|
> [!NOTE]
|
||||||
|
> This API always returns false on Windows.
|
||||||
|
|
||||||
#### `win.setIgnoreMouseEvents(ignore[, options])`
|
#### `win.setIgnoreMouseEvents(ignore[, options])`
|
||||||
|
|
||||||
@@ -1314,6 +1350,10 @@ On Windows it calls SetWindowDisplayAffinity with `WDA_EXCLUDEFROMCAPTURE`.
|
|||||||
For Windows 10 version 2004 and up the window will be removed from capture entirely,
|
For Windows 10 version 2004 and up the window will be removed from capture entirely,
|
||||||
older Windows versions behave as if `WDA_MONITOR` is applied capturing a black window.
|
older Windows versions behave as if `WDA_MONITOR` is applied capturing a black window.
|
||||||
|
|
||||||
|
#### `win.isContentProtected()` _macOS_ _Windows_
|
||||||
|
|
||||||
|
Returns `boolean` - whether or not content protection is currently enabled.
|
||||||
|
|
||||||
#### `win.setFocusable(focusable)` _macOS_ _Windows_
|
#### `win.setFocusable(focusable)` _macOS_ _Windows_
|
||||||
|
|
||||||
* `focusable` boolean
|
* `focusable` boolean
|
||||||
@@ -1403,7 +1443,8 @@ This method sets the browser window's system-drawn background material, includin
|
|||||||
|
|
||||||
See the [Windows documentation](https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/ne-dwmapi-dwm_systembackdrop_type) for more details.
|
See the [Windows documentation](https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/ne-dwmapi-dwm_systembackdrop_type) for more details.
|
||||||
|
|
||||||
**Note:** This method is only supported on Windows 11 22H2 and up.
|
> [!NOTE]
|
||||||
|
> This method is only supported on Windows 11 22H2 and up.
|
||||||
|
|
||||||
#### `win.setWindowButtonPosition(position)` _macOS_
|
#### `win.setWindowButtonPosition(position)` _macOS_
|
||||||
|
|
||||||
@@ -1425,8 +1466,9 @@ Sets the touchBar layout for the current window. Specifying `null` or
|
|||||||
`undefined` clears the touch bar. This method only has an effect if the
|
`undefined` clears the touch bar. This method only has an effect if the
|
||||||
machine has a touch bar.
|
machine has a touch bar.
|
||||||
|
|
||||||
**Note:** The TouchBar API is currently experimental and may change or be
|
> [!NOTE]
|
||||||
removed in future Electron releases.
|
> The TouchBar API is currently experimental and may change or be
|
||||||
|
> removed in future Electron releases.
|
||||||
|
|
||||||
#### `win.setTitleBarOverlay(options)` _Windows_ _Linux_
|
#### `win.setTitleBarOverlay(options)` _Windows_ _Linux_
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ deprecated:
|
|||||||
```
|
```
|
||||||
-->
|
-->
|
||||||
|
|
||||||
> **Note**
|
> [!NOTE]
|
||||||
> The `BrowserView` class is deprecated, and replaced by the new
|
> The `BrowserView` class is deprecated, and replaced by the new
|
||||||
> [`WebContentsView`](web-contents-view.md) class.
|
> [`WebContentsView`](web-contents-view.md) class.
|
||||||
|
|
||||||
@@ -29,7 +29,7 @@ deprecated:
|
|||||||
|
|
||||||
> Create and control views.
|
> Create and control views.
|
||||||
|
|
||||||
> **Note**
|
> [!NOTE]
|
||||||
> The `BrowserView` class is deprecated, and replaced by the new
|
> The `BrowserView` class is deprecated, and replaced by the new
|
||||||
> [`WebContentsView`](web-contents-view.md) class.
|
> [`WebContentsView`](web-contents-view.md) class.
|
||||||
|
|
||||||
@@ -38,6 +38,10 @@ Process: [Main](../glossary.md#main-process)
|
|||||||
This module cannot be used until the `ready` event of the `app`
|
This module cannot be used until the `ready` event of the `app`
|
||||||
module is emitted.
|
module is emitted.
|
||||||
|
|
||||||
|
> [!WARNING]
|
||||||
|
> Electron's built-in classes cannot be subclassed in user code.
|
||||||
|
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
|
||||||
|
|
||||||
### Example
|
### Example
|
||||||
|
|
||||||
```js
|
```js
|
||||||
@@ -176,4 +180,5 @@ Examples of valid `color` values:
|
|||||||
* Similar to CSS Color Module Level 3 keywords, but case-sensitive.
|
* Similar to CSS Color Module Level 3 keywords, but case-sensitive.
|
||||||
* e.g. `blueviolet` or `red`
|
* e.g. `blueviolet` or `red`
|
||||||
|
|
||||||
**Note:** Hex format with alpha takes `AARRGGBB` or `ARGB`, _not_ `RRGGBBAA` or `RGB`.
|
> [!NOTE]
|
||||||
|
> Hex format with alpha takes `AARRGGBB` or `ARGB`, _not_ `RRGGBBAA` or `RGB`.
|
||||||
|
|||||||
@@ -150,6 +150,10 @@ Process: [Main](../glossary.md#main-process)
|
|||||||
|
|
||||||
It creates a new `BrowserWindow` with native properties as set by the `options`.
|
It creates a new `BrowserWindow` with native properties as set by the `options`.
|
||||||
|
|
||||||
|
> [!WARNING]
|
||||||
|
> Electron's built-in classes cannot be subclassed in user code.
|
||||||
|
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
|
||||||
|
|
||||||
### `new BrowserWindow([options])`
|
### `new BrowserWindow([options])`
|
||||||
|
|
||||||
* `options` [BrowserWindowConstructorOptions](structures/browser-window-options.md?inline) (optional)
|
* `options` [BrowserWindowConstructorOptions](structures/browser-window-options.md?inline) (optional)
|
||||||
@@ -158,7 +162,8 @@ It creates a new `BrowserWindow` with native properties as set by the `options`.
|
|||||||
|
|
||||||
Objects created with `new BrowserWindow` emit the following events:
|
Objects created with `new BrowserWindow` emit the following events:
|
||||||
|
|
||||||
**Note:** Some events are only available on specific operating systems and are
|
> [!NOTE]
|
||||||
|
> Some events are only available on specific operating systems and are
|
||||||
labeled as such.
|
labeled as such.
|
||||||
|
|
||||||
#### Event: 'page-title-updated'
|
#### Event: 'page-title-updated'
|
||||||
@@ -200,7 +205,11 @@ window.onbeforeunload = (e) => {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
_**Note**: There is a subtle difference between the behaviors of `window.onbeforeunload = handler` and `window.addEventListener('beforeunload', handler)`. It is recommended to always set the `event.returnValue` explicitly, instead of only returning a value, as the former works more consistently within Electron._
|
> [!NOTE]
|
||||||
|
> There is a subtle difference between the behaviors of `window.onbeforeunload = handler` and
|
||||||
|
> `window.addEventListener('beforeunload', handler)`. It is recommended to always set the
|
||||||
|
> `event.returnValue` explicitly, instead of only returning a value, as the former works more
|
||||||
|
> consistently within Electron.
|
||||||
|
|
||||||
#### Event: 'closed'
|
#### Event: 'closed'
|
||||||
|
|
||||||
@@ -323,7 +332,8 @@ Emitted when the window is being moved to a new position.
|
|||||||
|
|
||||||
Emitted once when the window is moved to a new position.
|
Emitted once when the window is moved to a new position.
|
||||||
|
|
||||||
**Note**: On macOS this event is an alias of `move`.
|
> [!NOTE]
|
||||||
|
> On macOS, this event is an alias of `move`.
|
||||||
|
|
||||||
#### Event: 'enter-full-screen'
|
#### Event: 'enter-full-screen'
|
||||||
|
|
||||||
@@ -421,12 +431,12 @@ Emitted when the window has closed a sheet.
|
|||||||
|
|
||||||
Emitted when the native new tab button is clicked.
|
Emitted when the native new tab button is clicked.
|
||||||
|
|
||||||
#### Event: 'system-context-menu' _Windows_
|
#### Event: 'system-context-menu' _Windows_ _Linux_
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
* `event` Event
|
* `event` Event
|
||||||
* `point` [Point](structures/point.md) - The screen coordinates the context menu was triggered at
|
* `point` [Point](structures/point.md) - The screen coordinates where the context menu was triggered.
|
||||||
|
|
||||||
Emitted when the system context menu is triggered on the window, this is
|
Emitted when the system context menu is triggered on the window, this is
|
||||||
normally only triggered when the user right clicks on the non-client area
|
normally only triggered when the user right clicks on the non-client area
|
||||||
@@ -435,6 +445,8 @@ as `-webkit-app-region: drag` in a frameless window.
|
|||||||
|
|
||||||
Calling `event.preventDefault()` will prevent the menu from being displayed.
|
Calling `event.preventDefault()` will prevent the menu from being displayed.
|
||||||
|
|
||||||
|
To convert `point` to DIP, use [`screen.screenToDipPoint(point)`](./screen.md#screenscreentodippointpoint-windows-linux).
|
||||||
|
|
||||||
### Static Methods
|
### Static Methods
|
||||||
|
|
||||||
The `BrowserWindow` class has the following static methods:
|
The `BrowserWindow` class has the following static methods:
|
||||||
@@ -458,7 +470,7 @@ or `null` if the contents are not owned by a window.
|
|||||||
|
|
||||||
* `browserView` [BrowserView](browser-view.md)
|
* `browserView` [BrowserView](browser-view.md)
|
||||||
|
|
||||||
> **Note**
|
> [!NOTE]
|
||||||
> The `BrowserView` class is deprecated, and replaced by the new
|
> The `BrowserView` class is deprecated, and replaced by the new
|
||||||
> [`WebContentsView`](web-contents-view.md) class.
|
> [`WebContentsView`](web-contents-view.md) class.
|
||||||
|
|
||||||
@@ -497,7 +509,7 @@ A `Integer` property representing the unique ID of the window. Each ID is unique
|
|||||||
|
|
||||||
A `string` (optional) property that is equal to the `tabbingIdentifier` passed to the `BrowserWindow` constructor or `undefined` if none was set.
|
A `string` (optional) property that is equal to the `tabbingIdentifier` passed to the `BrowserWindow` constructor or `undefined` if none was set.
|
||||||
|
|
||||||
#### `win.autoHideMenuBar`
|
#### `win.autoHideMenuBar` _Linux_ _Windows_
|
||||||
|
|
||||||
A `boolean` property that determines whether the window menu bar should hide itself automatically. Once set, the menu bar will only show when users press the single `Alt` key.
|
A `boolean` property that determines whether the window menu bar should hide itself automatically. Once set, the menu bar will only show when users press the single `Alt` key.
|
||||||
|
|
||||||
@@ -520,7 +532,8 @@ A `boolean` property that determines whether the window is focusable.
|
|||||||
|
|
||||||
A `boolean` property that determines whether the window is visible on all workspaces.
|
A `boolean` property that determines whether the window is visible on all workspaces.
|
||||||
|
|
||||||
**Note:** Always returns false on Windows.
|
> [!NOTE]
|
||||||
|
> Always returns false on Windows.
|
||||||
|
|
||||||
#### `win.shadow`
|
#### `win.shadow`
|
||||||
|
|
||||||
@@ -530,7 +543,8 @@ A `boolean` property that determines whether the window has a shadow.
|
|||||||
|
|
||||||
A `boolean` property that determines whether the menu bar should be visible.
|
A `boolean` property that determines whether the menu bar should be visible.
|
||||||
|
|
||||||
**Note:** If the menu bar is auto-hide, users can still bring up the menu bar by pressing the single `Alt` key.
|
> [!NOTE]
|
||||||
|
> If the menu bar is auto-hide, users can still bring up the menu bar by pressing the single `Alt` key.
|
||||||
|
|
||||||
#### `win.kiosk`
|
#### `win.kiosk`
|
||||||
|
|
||||||
@@ -551,7 +565,8 @@ and the icon of the file will show in window's title bar.
|
|||||||
|
|
||||||
A `string` property that determines the title of the native window.
|
A `string` property that determines the title of the native window.
|
||||||
|
|
||||||
**Note:** The title of the web page can be different from the title of the native window.
|
> [!NOTE]
|
||||||
|
> The title of the web page can be different from the title of the native window.
|
||||||
|
|
||||||
#### `win.minimizable` _macOS_ _Windows_
|
#### `win.minimizable` _macOS_ _Windows_
|
||||||
|
|
||||||
@@ -611,12 +626,17 @@ A `string` property that defines an alternative title provided only to
|
|||||||
accessibility tools such as screen readers. This string is not directly
|
accessibility tools such as screen readers. This string is not directly
|
||||||
visible to users.
|
visible to users.
|
||||||
|
|
||||||
|
#### `win.snapped` _Windows_ _Readonly_
|
||||||
|
|
||||||
|
A `boolean` property that indicates whether the window is arranged via [Snap.](https://support.microsoft.com/en-us/windows/snap-your-windows-885a9b1e-a983-a3b1-16cd-c531795e6241)
|
||||||
|
|
||||||
### Instance Methods
|
### Instance Methods
|
||||||
|
|
||||||
Objects created with `new BrowserWindow` have the following instance methods:
|
Objects created with `new BrowserWindow` have the following instance methods:
|
||||||
|
|
||||||
**Note:** Some methods are only available on specific operating systems and are
|
> [!NOTE]
|
||||||
labeled as such.
|
> Some methods are only available on specific operating systems and are
|
||||||
|
> labeled as such.
|
||||||
|
|
||||||
#### `win.destroy()`
|
#### `win.destroy()`
|
||||||
|
|
||||||
@@ -698,13 +718,15 @@ Returns `boolean` - Whether the window is minimized.
|
|||||||
|
|
||||||
Sets whether the window should be in fullscreen mode.
|
Sets whether the window should be in fullscreen mode.
|
||||||
|
|
||||||
**Note:** On macOS, fullscreen transitions take place asynchronously. If further actions depend on the fullscreen state, use the ['enter-full-screen'](browser-window.md#event-enter-full-screen) or ['leave-full-screen'](browser-window.md#event-leave-full-screen) events.
|
> [!NOTE]
|
||||||
|
> On macOS, fullscreen transitions take place asynchronously. If further actions depend on the fullscreen state, use the ['enter-full-screen'](browser-window.md#event-enter-full-screen) or ['leave-full-screen'](browser-window.md#event-leave-full-screen) events.
|
||||||
|
|
||||||
#### `win.isFullScreen()`
|
#### `win.isFullScreen()`
|
||||||
|
|
||||||
Returns `boolean` - Whether the window is in fullscreen mode.
|
Returns `boolean` - Whether the window is in fullscreen mode.
|
||||||
|
|
||||||
**Note:** On macOS, fullscreen transitions take place asynchronously. When querying for a BrowserWindow's fullscreen status, you should ensure that either the ['enter-full-screen'](browser-window.md#event-enter-full-screen) or ['leave-full-screen'](browser-window.md#event-leave-full-screen) events have been emitted.
|
> [!NOTE]
|
||||||
|
> On macOS, fullscreen transitions take place asynchronously. When querying for a BrowserWindow's fullscreen status, you should ensure that either the ['enter-full-screen'](browser-window.md#event-enter-full-screen) or ['leave-full-screen'](browser-window.md#event-leave-full-screen) events have been emitted.
|
||||||
|
|
||||||
#### `win.setSimpleFullScreen(flag)` _macOS_
|
#### `win.setSimpleFullScreen(flag)` _macOS_
|
||||||
|
|
||||||
@@ -814,13 +836,15 @@ win.setBounds({ width: 100 })
|
|||||||
console.log(win.getBounds())
|
console.log(win.getBounds())
|
||||||
```
|
```
|
||||||
|
|
||||||
**Note:** On macOS, the y-coordinate value cannot be smaller than the [Tray](tray.md) height. The tray height has changed over time and depends on the operating system, but is between 20-40px. Passing a value lower than the tray height will result in a window that is flush to the tray.
|
> [!NOTE]
|
||||||
|
> On macOS, the y-coordinate value cannot be smaller than the [Tray](tray.md) height. The tray height has changed over time and depends on the operating system, but is between 20-40px. Passing a value lower than the tray height will result in a window that is flush to the tray.
|
||||||
|
|
||||||
#### `win.getBounds()`
|
#### `win.getBounds()`
|
||||||
|
|
||||||
Returns [`Rectangle`](structures/rectangle.md) - The `bounds` of the window as `Object`.
|
Returns [`Rectangle`](structures/rectangle.md) - The `bounds` of the window as `Object`.
|
||||||
|
|
||||||
**Note:** On macOS, the y-coordinate value returned will be at minimum the [Tray](tray.md) height. For example, calling `win.setBounds({ x: 25, y: 20, width: 800, height: 600 })` with a tray height of 38 means that `win.getBounds()` will return `{ x: 25, y: 38, width: 800, height: 600 }`.
|
> [!NOTE]
|
||||||
|
> On macOS, the y-coordinate value returned will be at minimum the [Tray](tray.md) height. For example, calling `win.setBounds({ x: 25, y: 20, width: 800, height: 600 })` with a tray height of 38 means that `win.getBounds()` will return `{ x: 25, y: 38, width: 800, height: 600 }`.
|
||||||
|
|
||||||
#### `win.getBackgroundColor()`
|
#### `win.getBackgroundColor()`
|
||||||
|
|
||||||
@@ -828,7 +852,8 @@ Returns `string` - Gets the background color of the window in Hex (`#RRGGBB`) fo
|
|||||||
|
|
||||||
See [Setting `backgroundColor`](#setting-the-backgroundcolor-property).
|
See [Setting `backgroundColor`](#setting-the-backgroundcolor-property).
|
||||||
|
|
||||||
**Note:** The alpha value is _not_ returned alongside the red, green, and blue values.
|
> [!NOTE]
|
||||||
|
> The alpha value is _not_ returned alongside the red, green, and blue values.
|
||||||
|
|
||||||
#### `win.setContentBounds(bounds[, animate])`
|
#### `win.setContentBounds(bounds[, animate])`
|
||||||
|
|
||||||
@@ -846,7 +871,8 @@ Returns [`Rectangle`](structures/rectangle.md) - The `bounds` of the window's cl
|
|||||||
|
|
||||||
Returns [`Rectangle`](structures/rectangle.md) - Contains the window bounds of the normal state
|
Returns [`Rectangle`](structures/rectangle.md) - Contains the window bounds of the normal state
|
||||||
|
|
||||||
**Note:** whatever the current state of the window : maximized, minimized or in fullscreen, this function always returns the position and size of the window in normal state. In normal state, getBounds and getNormalBounds returns the same [`Rectangle`](structures/rectangle.md).
|
> [!NOTE]
|
||||||
|
> Whatever the current state of the window (maximized, minimized or in fullscreen), this function always returns the position and size of the window in normal state. In normal state, `getBounds` and `getNormalBounds` return the same [`Rectangle`](structures/rectangle.md).
|
||||||
|
|
||||||
#### `win.setEnabled(enable)`
|
#### `win.setEnabled(enable)`
|
||||||
|
|
||||||
@@ -1043,8 +1069,9 @@ Changes the title of native window to `title`.
|
|||||||
|
|
||||||
Returns `string` - The title of the native window.
|
Returns `string` - The title of the native window.
|
||||||
|
|
||||||
**Note:** The title of the web page can be different from the title of the native
|
> [!NOTE]
|
||||||
window.
|
> The title of the web page can be different from the title of the native
|
||||||
|
> window.
|
||||||
|
|
||||||
#### `win.setSheetOffset(offsetY[, offsetX])` _macOS_
|
#### `win.setSheetOffset(offsetY[, offsetX])` _macOS_
|
||||||
|
|
||||||
@@ -1403,8 +1430,9 @@ in the taskbar.
|
|||||||
|
|
||||||
Sets the properties for the window's taskbar button.
|
Sets the properties for the window's taskbar button.
|
||||||
|
|
||||||
**Note:** `relaunchCommand` and `relaunchDisplayName` must always be set
|
> [!NOTE]
|
||||||
together. If one of those properties is not set, then neither will be used.
|
> `relaunchCommand` and `relaunchDisplayName` must always be set
|
||||||
|
> together. If one of those properties is not set, then neither will be used.
|
||||||
|
|
||||||
#### `win.showDefinitionForSelection()` _macOS_
|
#### `win.showDefinitionForSelection()` _macOS_
|
||||||
|
|
||||||
@@ -1445,6 +1473,13 @@ Sets whether the menu bar should be visible. If the menu bar is auto-hide, users
|
|||||||
|
|
||||||
Returns `boolean` - Whether the menu bar is visible.
|
Returns `boolean` - Whether the menu bar is visible.
|
||||||
|
|
||||||
|
#### `win.isSnapped()` _Windows_
|
||||||
|
|
||||||
|
Returns `boolean` - whether the window is arranged via [Snap.](https://support.microsoft.com/en-us/windows/snap-your-windows-885a9b1e-a983-a3b1-16cd-c531795e6241)
|
||||||
|
|
||||||
|
The window is snapped via buttons shown when the mouse is hovered over window
|
||||||
|
maximize button, or by dragging it to the edges of the screen.
|
||||||
|
|
||||||
#### `win.setVisibleOnAllWorkspaces(visible[, options])` _macOS_ _Linux_
|
#### `win.setVisibleOnAllWorkspaces(visible[, options])` _macOS_ _Linux_
|
||||||
|
|
||||||
* `visible` boolean
|
* `visible` boolean
|
||||||
@@ -1461,13 +1496,15 @@ Returns `boolean` - Whether the menu bar is visible.
|
|||||||
|
|
||||||
Sets whether the window should be visible on all workspaces.
|
Sets whether the window should be visible on all workspaces.
|
||||||
|
|
||||||
**Note:** This API does nothing on Windows.
|
> [!NOTE]
|
||||||
|
> This API does nothing on Windows.
|
||||||
|
|
||||||
#### `win.isVisibleOnAllWorkspaces()` _macOS_ _Linux_
|
#### `win.isVisibleOnAllWorkspaces()` _macOS_ _Linux_
|
||||||
|
|
||||||
Returns `boolean` - Whether the window is visible on all workspaces.
|
Returns `boolean` - Whether the window is visible on all workspaces.
|
||||||
|
|
||||||
**Note:** This API always returns false on Windows.
|
> [!NOTE]
|
||||||
|
> This API always returns false on Windows.
|
||||||
|
|
||||||
#### `win.setIgnoreMouseEvents(ignore[, options])`
|
#### `win.setIgnoreMouseEvents(ignore[, options])`
|
||||||
|
|
||||||
@@ -1495,6 +1532,10 @@ On Windows it calls SetWindowDisplayAffinity with `WDA_EXCLUDEFROMCAPTURE`.
|
|||||||
For Windows 10 version 2004 and up the window will be removed from capture entirely,
|
For Windows 10 version 2004 and up the window will be removed from capture entirely,
|
||||||
older Windows versions behave as if `WDA_MONITOR` is applied capturing a black window.
|
older Windows versions behave as if `WDA_MONITOR` is applied capturing a black window.
|
||||||
|
|
||||||
|
#### `win.isContentProtected()` _macOS_ _Windows_
|
||||||
|
|
||||||
|
Returns `boolean` - whether or not content protection is currently enabled.
|
||||||
|
|
||||||
#### `win.setFocusable(focusable)` _macOS_ _Windows_
|
#### `win.setFocusable(focusable)` _macOS_ _Windows_
|
||||||
|
|
||||||
* `focusable` boolean
|
* `focusable` boolean
|
||||||
@@ -1588,7 +1629,8 @@ This method sets the browser window's system-drawn background material, includin
|
|||||||
|
|
||||||
See the [Windows documentation](https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/ne-dwmapi-dwm_systembackdrop_type) for more details.
|
See the [Windows documentation](https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/ne-dwmapi-dwm_systembackdrop_type) for more details.
|
||||||
|
|
||||||
**Note:** This method is only supported on Windows 11 22H2 and up.
|
> [!NOTE]
|
||||||
|
> This method is only supported on Windows 11 22H2 and up.
|
||||||
|
|
||||||
#### `win.setWindowButtonPosition(position)` _macOS_
|
#### `win.setWindowButtonPosition(position)` _macOS_
|
||||||
|
|
||||||
@@ -1610,8 +1652,9 @@ Sets the touchBar layout for the current window. Specifying `null` or
|
|||||||
`undefined` clears the touch bar. This method only has an effect if the
|
`undefined` clears the touch bar. This method only has an effect if the
|
||||||
machine has a touch bar.
|
machine has a touch bar.
|
||||||
|
|
||||||
**Note:** The TouchBar API is currently experimental and may change or be
|
> [!NOTE]
|
||||||
removed in future Electron releases.
|
> The TouchBar API is currently experimental and may change or be
|
||||||
|
> removed in future Electron releases.
|
||||||
|
|
||||||
#### `win.setBrowserView(browserView)` _Experimental_ _Deprecated_
|
#### `win.setBrowserView(browserView)` _Experimental_ _Deprecated_
|
||||||
|
|
||||||
@@ -1619,7 +1662,7 @@ removed in future Electron releases.
|
|||||||
If there are other `BrowserView`s attached, they will be removed from
|
If there are other `BrowserView`s attached, they will be removed from
|
||||||
this window.
|
this window.
|
||||||
|
|
||||||
> **Note**
|
> [!WARNING]
|
||||||
> The `BrowserView` class is deprecated, and replaced by the new
|
> The `BrowserView` class is deprecated, and replaced by the new
|
||||||
> [`WebContentsView`](web-contents-view.md) class.
|
> [`WebContentsView`](web-contents-view.md) class.
|
||||||
|
|
||||||
@@ -1628,7 +1671,7 @@ this window.
|
|||||||
Returns `BrowserView | null` - The `BrowserView` attached to `win`. Returns `null`
|
Returns `BrowserView | null` - The `BrowserView` attached to `win`. Returns `null`
|
||||||
if one is not attached. Throws an error if multiple `BrowserView`s are attached.
|
if one is not attached. Throws an error if multiple `BrowserView`s are attached.
|
||||||
|
|
||||||
> **Note**
|
> [!WARNING]
|
||||||
> The `BrowserView` class is deprecated, and replaced by the new
|
> The `BrowserView` class is deprecated, and replaced by the new
|
||||||
> [`WebContentsView`](web-contents-view.md) class.
|
> [`WebContentsView`](web-contents-view.md) class.
|
||||||
|
|
||||||
@@ -1638,7 +1681,7 @@ if one is not attached. Throws an error if multiple `BrowserView`s are attached.
|
|||||||
|
|
||||||
Replacement API for setBrowserView supporting work with multi browser views.
|
Replacement API for setBrowserView supporting work with multi browser views.
|
||||||
|
|
||||||
> **Note**
|
> [!WARNING]
|
||||||
> The `BrowserView` class is deprecated, and replaced by the new
|
> The `BrowserView` class is deprecated, and replaced by the new
|
||||||
> [`WebContentsView`](web-contents-view.md) class.
|
> [`WebContentsView`](web-contents-view.md) class.
|
||||||
|
|
||||||
@@ -1646,7 +1689,7 @@ Replacement API for setBrowserView supporting work with multi browser views.
|
|||||||
|
|
||||||
* `browserView` [BrowserView](browser-view.md)
|
* `browserView` [BrowserView](browser-view.md)
|
||||||
|
|
||||||
> **Note**
|
> [!WARNING]
|
||||||
> The `BrowserView` class is deprecated, and replaced by the new
|
> The `BrowserView` class is deprecated, and replaced by the new
|
||||||
> [`WebContentsView`](web-contents-view.md) class.
|
> [`WebContentsView`](web-contents-view.md) class.
|
||||||
|
|
||||||
@@ -1657,7 +1700,7 @@ Replacement API for setBrowserView supporting work with multi browser views.
|
|||||||
Raises `browserView` above other `BrowserView`s attached to `win`.
|
Raises `browserView` above other `BrowserView`s attached to `win`.
|
||||||
Throws an error if `browserView` is not attached to `win`.
|
Throws an error if `browserView` is not attached to `win`.
|
||||||
|
|
||||||
> **Note**
|
> [!WARNING]
|
||||||
> The `BrowserView` class is deprecated, and replaced by the new
|
> The `BrowserView` class is deprecated, and replaced by the new
|
||||||
> [`WebContentsView`](web-contents-view.md) class.
|
> [`WebContentsView`](web-contents-view.md) class.
|
||||||
|
|
||||||
@@ -1666,7 +1709,7 @@ Throws an error if `browserView` is not attached to `win`.
|
|||||||
Returns `BrowserView[]` - a sorted by z-index array of all BrowserViews that have been attached
|
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.
|
with `addBrowserView` or `setBrowserView`. The top-most BrowserView is the last element of the array.
|
||||||
|
|
||||||
> **Note**
|
> [!WARNING]
|
||||||
> The `BrowserView` class is deprecated, and replaced by the new
|
> The `BrowserView` class is deprecated, and replaced by the new
|
||||||
> [`WebContentsView`](web-contents-view.md) class.
|
> [`WebContentsView`](web-contents-view.md) class.
|
||||||
|
|
||||||
|
|||||||
@@ -60,6 +60,10 @@ following properties:
|
|||||||
`strict-origin-when-cross-origin`.
|
`strict-origin-when-cross-origin`.
|
||||||
* `cache` string (optional) - can be `default`, `no-store`, `reload`,
|
* `cache` string (optional) - can be `default`, `no-store`, `reload`,
|
||||||
`no-cache`, `force-cache` or `only-if-cached`.
|
`no-cache`, `force-cache` or `only-if-cached`.
|
||||||
|
* `priority` string (optional) - can be `throttled`, `idle`, `lowest`,
|
||||||
|
`low`, `medium`, or `highest`. Defaults to `idle`.
|
||||||
|
* `priorityIncremental` boolean (optional) - the incremental loading flag as part
|
||||||
|
of HTTP extensible priorities (RFC 9218). Default is `true`.
|
||||||
|
|
||||||
`options` properties such as `protocol`, `host`, `hostname`, `port` and `path`
|
`options` properties such as `protocol`, `host`, `hostname`, `port` and `path`
|
||||||
strictly follow the Node.js model as described in the
|
strictly follow the Node.js model as described in the
|
||||||
|
|||||||
@@ -18,7 +18,8 @@ console.log(clipboard.readText('selection'))
|
|||||||
|
|
||||||
The `clipboard` module has the following methods:
|
The `clipboard` module has the following methods:
|
||||||
|
|
||||||
**Note:** Experimental APIs are marked as such and could be removed in future.
|
> [!NOTE]
|
||||||
|
> Experimental APIs are marked as such and could be removed in future.
|
||||||
|
|
||||||
### `clipboard.readText([type])`
|
### `clipboard.readText([type])`
|
||||||
|
|
||||||
@@ -141,9 +142,10 @@ bookmark is unavailable. The `title` value will always be empty on Windows.
|
|||||||
|
|
||||||
Writes the `title` (macOS only) and `url` into the clipboard as a bookmark.
|
Writes the `title` (macOS only) and `url` into the clipboard as a bookmark.
|
||||||
|
|
||||||
**Note:** Most apps on Windows don't support pasting bookmarks into them so
|
> [!NOTE]
|
||||||
you can use `clipboard.write` to write both a bookmark and fallback text to the
|
> Most apps on Windows don't support pasting bookmarks into them so
|
||||||
clipboard.
|
> you can use `clipboard.write` to write both a bookmark and fallback text to the
|
||||||
|
> clipboard.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const { clipboard } = require('electron')
|
const { clipboard } = require('electron')
|
||||||
|
|||||||
@@ -73,7 +73,8 @@ Passing `--enable-logging=file` will result in logs being saved to the file
|
|||||||
specified by `--log-file=...`, or to `electron_debug.log` in the user-data
|
specified by `--log-file=...`, or to `electron_debug.log` in the user-data
|
||||||
directory if `--log-file` is not specified.
|
directory if `--log-file` is not specified.
|
||||||
|
|
||||||
> **Note:** On Windows, logs from child processes cannot be sent to stderr.
|
> [!NOTE]
|
||||||
|
> On Windows, logs from child processes cannot be sent to stderr.
|
||||||
> Logging to a file is the most reliable way to collect logs on Windows.
|
> Logging to a file is the most reliable way to collect logs on Windows.
|
||||||
|
|
||||||
See also `--log-file`, `--log-level`, `--v`, and `--vmodule`.
|
See also `--log-file`, `--log-level`, `--v`, and `--vmodule`.
|
||||||
@@ -252,9 +253,10 @@ the required version is unavailable. Current default is set to `3`.
|
|||||||
|
|
||||||
Electron supports some of the [CLI flags][node-cli] supported by Node.js.
|
Electron supports some of the [CLI flags][node-cli] supported by Node.js.
|
||||||
|
|
||||||
**Note:** Passing unsupported command line switches to Electron when it is not running in `ELECTRON_RUN_AS_NODE` will have no effect.
|
> [!NOTE]
|
||||||
|
> Passing unsupported command line switches to Electron when it is not running in `ELECTRON_RUN_AS_NODE` will have no effect.
|
||||||
|
|
||||||
### `--inspect-brk\[=\[host:]port]`
|
### `--inspect-brk[=[host:]port]`
|
||||||
|
|
||||||
Activate inspector on host:port and break at start of user script. Default host:port is 127.0.0.1:9229.
|
Activate inspector on host:port and break at start of user script. Default host:port is 127.0.0.1:9229.
|
||||||
|
|
||||||
@@ -266,13 +268,13 @@ Activate inspector on `host:port` and break at start of the first internal
|
|||||||
JavaScript script executed when the inspector is available.
|
JavaScript script executed when the inspector is available.
|
||||||
Default `host:port` is `127.0.0.1:9229`.
|
Default `host:port` is `127.0.0.1:9229`.
|
||||||
|
|
||||||
### `--inspect-port=\[host:]port`
|
### `--inspect-port=[host:]port`
|
||||||
|
|
||||||
Set the `host:port` to be used when the inspector is activated. Useful when activating the inspector by sending the SIGUSR1 signal. Default host is `127.0.0.1`.
|
Set the `host:port` to be used when the inspector is activated. Useful when activating the inspector by sending the SIGUSR1 signal. Default host is `127.0.0.1`.
|
||||||
|
|
||||||
Aliased to `--debug-port=[host:]port`.
|
Aliased to `--debug-port=[host:]port`.
|
||||||
|
|
||||||
### `--inspect\[=\[host:]port]`
|
### `--inspect[=[host:]port]`
|
||||||
|
|
||||||
Activate inspector on `host:port`. Default is `127.0.0.1:9229`.
|
Activate inspector on `host:port`. Default is `127.0.0.1:9229`.
|
||||||
|
|
||||||
@@ -288,6 +290,10 @@ Specify ways of the inspector web socket url exposure.
|
|||||||
|
|
||||||
By default inspector websocket url is available in stderr and under /json/list endpoint on `http://host:port/json/list`.
|
By default inspector websocket url is available in stderr and under /json/list endpoint on `http://host:port/json/list`.
|
||||||
|
|
||||||
|
### `--experimental-network-inspector`
|
||||||
|
|
||||||
|
Enable support for devtools network inspector events, for visibility into requests made by the nodejs `http` and `https` modules.
|
||||||
|
|
||||||
### `--no-deprecation`
|
### `--no-deprecation`
|
||||||
|
|
||||||
Silence deprecation warnings.
|
Silence deprecation warnings.
|
||||||
@@ -319,6 +325,10 @@ Set the directory to which all Node.js diagnostic output files are written. Defa
|
|||||||
|
|
||||||
Affects the default output directory of [v8.setHeapSnapshotNearHeapLimit](https://nodejs.org/docs/latest/api/v8.html#v8setheapsnapshotnearheaplimitlimit).
|
Affects the default output directory of [v8.setHeapSnapshotNearHeapLimit](https://nodejs.org/docs/latest/api/v8.html#v8setheapsnapshotnearheaplimitlimit).
|
||||||
|
|
||||||
|
### `--no-experimental-global-navigator`
|
||||||
|
|
||||||
|
Disable exposition of [Navigator API][] on the global scope from Node.js.
|
||||||
|
|
||||||
[app]: app.md
|
[app]: app.md
|
||||||
[append-switch]: command-line.md#commandlineappendswitchswitch-value
|
[append-switch]: command-line.md#commandlineappendswitchswitch-value
|
||||||
[debugging-main-process]: ../tutorial/debugging-main-process.md
|
[debugging-main-process]: ../tutorial/debugging-main-process.md
|
||||||
@@ -327,3 +337,4 @@ Affects the default output directory of [v8.setHeapSnapshotNearHeapLimit](https:
|
|||||||
[play-silent-audio]: https://github.com/atom/atom/pull/9485/files
|
[play-silent-audio]: https://github.com/atom/atom/pull/9485/files
|
||||||
[ready]: app.md#event-ready
|
[ready]: app.md#event-ready
|
||||||
[severities]: https://source.chromium.org/chromium/chromium/src/+/main:base/logging.h?q=logging::LogSeverity&ss=chromium
|
[severities]: https://source.chromium.org/chromium/chromium/src/+/main:base/logging.h?q=logging::LogSeverity&ss=chromium
|
||||||
|
[Navigator API]: https://github.com/nodejs/node/blob/main/doc/api/globals.md#navigator
|
||||||
|
|||||||
@@ -20,45 +20,91 @@ document.
|
|||||||
|
|
||||||
#### `commandLine.appendSwitch(switch[, value])`
|
#### `commandLine.appendSwitch(switch[, value])`
|
||||||
|
|
||||||
* `switch` string - A command-line switch, without the leading `--`
|
* `switch` string - A command-line switch, without the leading `--`.
|
||||||
* `value` string (optional) - A value for the given switch
|
* `value` string (optional) - A value for the given switch.
|
||||||
|
|
||||||
Append a switch (with optional `value`) to Chromium's command line.
|
Append a switch (with optional `value`) to Chromium's command line.
|
||||||
|
|
||||||
**Note:** This will not affect `process.argv`. The intended usage of this function is to
|
> [!NOTE]
|
||||||
control Chromium's behavior.
|
> This will not affect `process.argv`. The intended usage of this function is to
|
||||||
|
> control Chromium's behavior.
|
||||||
|
|
||||||
|
```js
|
||||||
|
const { app } = require('electron')
|
||||||
|
|
||||||
|
app.commandLine.appendSwitch('remote-debugging-port', '8315')
|
||||||
|
```
|
||||||
|
|
||||||
#### `commandLine.appendArgument(value)`
|
#### `commandLine.appendArgument(value)`
|
||||||
|
|
||||||
* `value` string - The argument to append to the command line
|
* `value` string - The argument to append to the command line.
|
||||||
|
|
||||||
Append an argument to Chromium's command line. The argument will be quoted
|
Append an argument to Chromium's command line. The argument will be quoted
|
||||||
correctly. Switches will precede arguments regardless of appending order.
|
correctly. Switches will precede arguments regardless of appending order.
|
||||||
|
|
||||||
If you're appending an argument like `--switch=value`, consider using `appendSwitch('switch', 'value')` instead.
|
If you're appending an argument like `--switch=value`, consider using `appendSwitch('switch', 'value')` instead.
|
||||||
|
|
||||||
**Note:** This will not affect `process.argv`. The intended usage of this function is to
|
```js
|
||||||
control Chromium's behavior.
|
const { app } = require('electron')
|
||||||
|
|
||||||
|
app.commandLine.appendArgument('--enable-experimental-web-platform-features')
|
||||||
|
```
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
|
> This will not affect `process.argv`. The intended usage of this function is to
|
||||||
|
> control Chromium's behavior.
|
||||||
|
|
||||||
#### `commandLine.hasSwitch(switch)`
|
#### `commandLine.hasSwitch(switch)`
|
||||||
|
|
||||||
* `switch` string - A command-line switch
|
* `switch` string - A command-line switch.
|
||||||
|
|
||||||
Returns `boolean` - Whether the command-line switch is present.
|
Returns `boolean` - Whether the command-line switch is present.
|
||||||
|
|
||||||
|
```js
|
||||||
|
const { app } = require('electron')
|
||||||
|
|
||||||
|
app.commandLine.appendSwitch('remote-debugging-port', '8315')
|
||||||
|
const hasPort = app.commandLine.hasSwitch('remote-debugging-port')
|
||||||
|
console.log(hasPort) // true
|
||||||
|
```
|
||||||
|
|
||||||
#### `commandLine.getSwitchValue(switch)`
|
#### `commandLine.getSwitchValue(switch)`
|
||||||
|
|
||||||
* `switch` string - A command-line switch
|
* `switch` string - A command-line switch.
|
||||||
|
|
||||||
Returns `string` - The command-line switch value.
|
Returns `string` - The command-line switch value.
|
||||||
|
|
||||||
**Note:** When the switch is not present or has no value, it returns empty string.
|
This function is meant to obtain Chromium command line switches. It is not
|
||||||
|
meant to be used for application-specific command line arguments. For the
|
||||||
|
latter, please use `process.argv`.
|
||||||
|
|
||||||
|
```js
|
||||||
|
const { app } = require('electron')
|
||||||
|
|
||||||
|
app.commandLine.appendSwitch('remote-debugging-port', '8315')
|
||||||
|
const portValue = app.commandLine.getSwitchValue('remote-debugging-port')
|
||||||
|
console.log(portValue) // '8315'
|
||||||
|
```
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
|
> When the switch is not present or has no value, it returns empty string.
|
||||||
|
|
||||||
#### `commandLine.removeSwitch(switch)`
|
#### `commandLine.removeSwitch(switch)`
|
||||||
|
|
||||||
* `switch` string - A command-line switch
|
* `switch` string - A command-line switch.
|
||||||
|
|
||||||
Removes the specified switch from Chromium's command line.
|
Removes the specified switch from Chromium's command line.
|
||||||
|
|
||||||
**Note:** This will not affect `process.argv`. The intended usage of this function is to
|
```js
|
||||||
control Chromium's behavior.
|
const { app } = require('electron')
|
||||||
|
|
||||||
|
app.commandLine.appendSwitch('remote-debugging-port', '8315')
|
||||||
|
console.log(app.commandLine.hasSwitch('remote-debugging-port')) // true
|
||||||
|
|
||||||
|
app.commandLine.removeSwitch('remote-debugging-port')
|
||||||
|
console.log(app.commandLine.hasSwitch('remote-debugging-port')) // false
|
||||||
|
```
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
|
> This will not affect `process.argv`. The intended usage of this function is to
|
||||||
|
> control Chromium's behavior.
|
||||||
|
|||||||
@@ -7,8 +7,9 @@ Process: [Main](../glossary.md#main-process)
|
|||||||
This module does not include a web interface. To view recorded traces, use
|
This module does not include a web interface. To view recorded traces, use
|
||||||
[trace viewer][], available at `chrome://tracing` in Chrome.
|
[trace viewer][], available at `chrome://tracing` in Chrome.
|
||||||
|
|
||||||
**Note:** You should not use this module until the `ready` event of the app
|
> [!NOTE]
|
||||||
module is emitted.
|
> You should not use this module until the `ready` event of the app
|
||||||
|
> module is emitted.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const { app, contentTracing } = require('electron')
|
const { app, contentTracing } = require('electron')
|
||||||
|
|||||||
78
docs/api/corner-smoothing-css.md
Normal file
78
docs/api/corner-smoothing-css.md
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
## CSS Rule: `-electron-corner-smoothing`
|
||||||
|
|
||||||
|
> Smoothes out the corner rounding of the `border-radius` CSS rule.
|
||||||
|
|
||||||
|
The rounded corners of elements with [the `border-radius` CSS rule](https://developer.mozilla.org/en-US/docs/Web/CSS/border-radius) can be smoothed out using the `-electron-corner-smoothing` CSS rule. This smoothness is very similar to Apple's "continuous" rounded corners in SwiftUI and Figma's "corner smoothing" control on design elements.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Integrating with the operating system and its design language is important to many desktop applications. The shape of a rounded corner can be a subtle detail to many users. However, aligning closely to the system's design language that users are familiar with makes the application's design feel familiar too. Beyond matching the design language of macOS, designers may decide to use smoother round corners for many other reasons.
|
||||||
|
|
||||||
|
`-electron-corner-smoothing` affects the shape of borders, outlines, and shadows on the target element. Mirroring the behavior of `border-radius`, smoothing will gradually back off if an element's size is too small for the chosen value.
|
||||||
|
|
||||||
|
The `-electron-corner-smoothing` CSS rule is **only implemented for Electron** and has no effect in browsers. Avoid using this rule outside of Electron. This CSS rule is considered experimental and may require migration in the future if replaced by a CSS standard.
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
The following example shows the effect of corner smoothing at different percents.
|
||||||
|
|
||||||
|
```css
|
||||||
|
.box {
|
||||||
|
width: 128px;
|
||||||
|
height: 128px;
|
||||||
|
background-color: cornflowerblue;
|
||||||
|
border-radius: 24px;
|
||||||
|
-electron-corner-smoothing: var(--percent); /* Column header in table below. */
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
| 0% | 30% | 60% | 100% |
|
||||||
|
| --- | --- | --- | --- |
|
||||||
|
|  |  |  |  |
|
||||||
|
|
||||||
|
### Matching the system UI
|
||||||
|
|
||||||
|
Use the `system-ui` keyword to match the smoothness to the OS design language.
|
||||||
|
|
||||||
|
```css
|
||||||
|
.box {
|
||||||
|
width: 128px;
|
||||||
|
height: 128px;
|
||||||
|
background-color: cornflowerblue;
|
||||||
|
border-radius: 24px;
|
||||||
|
-electron-corner-smoothing: system-ui; /* Match the system UI design. */
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
| OS: | macOS | Windows, Linux |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| Value: | `60%` | `0%` |
|
||||||
|
| Example: |  |  |
|
||||||
|
|
||||||
|
### Controlling availibility
|
||||||
|
|
||||||
|
This CSS rule can be disabled by setting [the `cornerSmoothingCSS` web preference](./structures/web-preferences.md) to `false`.
|
||||||
|
|
||||||
|
```js
|
||||||
|
const myWindow = new BrowserWindow({
|
||||||
|
// [...]
|
||||||
|
webPreferences: {
|
||||||
|
enableCornerSmoothingCSS: false // Disables the `-electron-corner-smoothing` CSS rule
|
||||||
|
}
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
The CSS rule will still parse, but will have no visual effect.
|
||||||
|
|
||||||
|
### Formal reference
|
||||||
|
|
||||||
|
* **Initial value**: `0%`
|
||||||
|
* **Inherited**: No
|
||||||
|
* **Animatable**: No
|
||||||
|
* **Computed value**: As specified
|
||||||
|
|
||||||
|
```css
|
||||||
|
-electron-corner-smoothing =
|
||||||
|
<percentage [0,100]> |
|
||||||
|
system-ui
|
||||||
|
```
|
||||||
@@ -19,7 +19,8 @@ following projects:
|
|||||||
* [socorro](https://github.com/mozilla-services/socorro)
|
* [socorro](https://github.com/mozilla-services/socorro)
|
||||||
* [mini-breakpad-server](https://github.com/electron/mini-breakpad-server)
|
* [mini-breakpad-server](https://github.com/electron/mini-breakpad-server)
|
||||||
|
|
||||||
> **Note:** Electron uses Crashpad, not Breakpad, to collect and upload
|
> [!NOTE]
|
||||||
|
> Electron uses Crashpad, not Breakpad, to collect and upload
|
||||||
> crashes, but for the time being, the [upload protocol is the same](https://chromium.googlesource.com/crashpad/crashpad/+/HEAD/doc/overview_design.md#Upload-to-collection-server).
|
> crashes, but for the time being, the [upload protocol is the same](https://chromium.googlesource.com/crashpad/crashpad/+/HEAD/doc/overview_design.md#Upload-to-collection-server).
|
||||||
|
|
||||||
Or use a 3rd party hosted solution:
|
Or use a 3rd party hosted solution:
|
||||||
@@ -84,19 +85,23 @@ before `app.on('ready')`. If the crash reporter is not initialized at the time
|
|||||||
a renderer process is created, then that renderer process will not be monitored
|
a renderer process is created, then that renderer process will not be monitored
|
||||||
by the crash reporter.
|
by the crash reporter.
|
||||||
|
|
||||||
**Note:** You can test out the crash reporter by generating a crash using
|
> [!NOTE]
|
||||||
`process.crash()`.
|
> You can test out the crash reporter by generating a crash using
|
||||||
|
> `process.crash()`.
|
||||||
|
|
||||||
**Note:** If you need to send additional/updated `extra` parameters after your
|
> [!NOTE]
|
||||||
first call `start` you can call `addExtraParameter`.
|
> If you need to send additional/updated `extra` parameters after your
|
||||||
|
> first call `start` you can call `addExtraParameter`.
|
||||||
|
|
||||||
**Note:** Parameters passed in `extra`, `globalExtra` or set with
|
> [!NOTE]
|
||||||
`addExtraParameter` have limits on the length of the keys and values. Key names
|
> Parameters passed in `extra`, `globalExtra` or set with
|
||||||
must be at most 39 bytes long, and values must be no longer than 127 bytes.
|
> `addExtraParameter` have limits on the length of the keys and values. Key names
|
||||||
Keys with names longer than the maximum will be silently ignored. Key values
|
> must be at most 39 bytes long, and values must be no longer than 127 bytes.
|
||||||
longer than the maximum length will be truncated.
|
> Keys with names longer than the maximum will be silently ignored. Key values
|
||||||
|
> longer than the maximum length will be truncated.
|
||||||
|
|
||||||
**Note:** This method is only available in the main process.
|
> [!NOTE]
|
||||||
|
> This method is only available in the main process.
|
||||||
|
|
||||||
### `crashReporter.getLastCrashReport()`
|
### `crashReporter.getLastCrashReport()`
|
||||||
|
|
||||||
@@ -105,7 +110,8 @@ last crash report. Only crash reports that have been uploaded will be returned;
|
|||||||
even if a crash report is present on disk it will not be returned until it is
|
even if a crash report is present on disk it will not be returned until it is
|
||||||
uploaded. In the case that there are no uploaded reports, `null` is returned.
|
uploaded. In the case that there are no uploaded reports, `null` is returned.
|
||||||
|
|
||||||
**Note:** This method is only available in the main process.
|
> [!NOTE]
|
||||||
|
> This method is only available in the main process.
|
||||||
|
|
||||||
### `crashReporter.getUploadedReports()`
|
### `crashReporter.getUploadedReports()`
|
||||||
|
|
||||||
@@ -114,14 +120,16 @@ Returns [`CrashReport[]`](structures/crash-report.md):
|
|||||||
Returns all uploaded crash reports. Each report contains the date and uploaded
|
Returns all uploaded crash reports. Each report contains the date and uploaded
|
||||||
ID.
|
ID.
|
||||||
|
|
||||||
**Note:** This method is only available in the main process.
|
> [!NOTE]
|
||||||
|
> This method is only available in the main process.
|
||||||
|
|
||||||
### `crashReporter.getUploadToServer()`
|
### `crashReporter.getUploadToServer()`
|
||||||
|
|
||||||
Returns `boolean` - Whether reports should be submitted to the server. Set through
|
Returns `boolean` - Whether reports should be submitted to the server. Set through
|
||||||
the `start` method or `setUploadToServer`.
|
the `start` method or `setUploadToServer`.
|
||||||
|
|
||||||
**Note:** This method is only available in the main process.
|
> [!NOTE]
|
||||||
|
> This method is only available in the main process.
|
||||||
|
|
||||||
### `crashReporter.setUploadToServer(uploadToServer)`
|
### `crashReporter.setUploadToServer(uploadToServer)`
|
||||||
|
|
||||||
@@ -130,7 +138,8 @@ the `start` method or `setUploadToServer`.
|
|||||||
This would normally be controlled by user preferences. This has no effect if
|
This would normally be controlled by user preferences. This has no effect if
|
||||||
called before `start` is called.
|
called before `start` is called.
|
||||||
|
|
||||||
**Note:** This method is only available in the main process.
|
> [!NOTE]
|
||||||
|
> This method is only available in the main process.
|
||||||
|
|
||||||
### `crashReporter.addExtraParameter(key, value)`
|
### `crashReporter.addExtraParameter(key, value)`
|
||||||
|
|
||||||
@@ -148,10 +157,11 @@ with crashes from renderer or other child processes. Similarly, adding extra
|
|||||||
parameters in a renderer process will not result in those parameters being sent
|
parameters in a renderer process will not result in those parameters being sent
|
||||||
with crashes that occur in other renderer processes or in the main process.
|
with crashes that occur in other renderer processes or in the main process.
|
||||||
|
|
||||||
**Note:** Parameters have limits on the length of the keys and values. Key
|
> [!NOTE]
|
||||||
names must be no longer than 39 bytes, and values must be no longer than 20320
|
> Parameters have limits on the length of the keys and values. Key
|
||||||
bytes. Keys with names longer than the maximum will be silently ignored. Key
|
> names must be no longer than 39 bytes, and values must be no longer than 20320
|
||||||
values longer than the maximum length will be truncated.
|
> bytes. Keys with names longer than the maximum will be silently ignored. Key
|
||||||
|
> values longer than the maximum length will be truncated.
|
||||||
|
|
||||||
### `crashReporter.removeExtraParameter(key)`
|
### `crashReporter.removeExtraParameter(key)`
|
||||||
|
|
||||||
|
|||||||
@@ -70,8 +70,9 @@ stopButton.addEventListener('click', () => {
|
|||||||
|
|
||||||
See [`navigator.mediaDevices.getDisplayMedia`](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getDisplayMedia) for more information.
|
See [`navigator.mediaDevices.getDisplayMedia`](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getDisplayMedia) for more information.
|
||||||
|
|
||||||
**Note:** `navigator.mediaDevices.getDisplayMedia` does not permit the use of `deviceId` for
|
> [!NOTE]
|
||||||
selection of a source - see [specification](https://w3c.github.io/mediacapture-screen-share/#constraints).
|
> `navigator.mediaDevices.getDisplayMedia` does not permit the use of `deviceId` for
|
||||||
|
> selection of a source - see [specification](https://w3c.github.io/mediacapture-screen-share/#constraints).
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
|
|
||||||
@@ -92,8 +93,9 @@ The `desktopCapturer` module has the following methods:
|
|||||||
|
|
||||||
Returns `Promise<DesktopCapturerSource[]>` - Resolves with an array of [`DesktopCapturerSource`](structures/desktop-capturer-source.md) objects, each `DesktopCapturerSource` represents a screen or an individual window that can be captured.
|
Returns `Promise<DesktopCapturerSource[]>` - Resolves with an array of [`DesktopCapturerSource`](structures/desktop-capturer-source.md) objects, each `DesktopCapturerSource` represents a screen or an individual window that can be captured.
|
||||||
|
|
||||||
**Note** Capturing the screen contents requires user consent on macOS 10.15 Catalina or higher,
|
> [!NOTE]
|
||||||
which can detected by [`systemPreferences.getMediaAccessStatus`][].
|
> Capturing the screen contents requires user consent on macOS 10.15 Catalina or higher,
|
||||||
|
> which can detected by [`systemPreferences.getMediaAccessStatus`][].
|
||||||
|
|
||||||
[`navigator.mediaDevices.getUserMedia`]: https://developer.mozilla.org/en/docs/Web/API/MediaDevices/getUserMedia
|
[`navigator.mediaDevices.getUserMedia`]: https://developer.mozilla.org/en/docs/Web/API/MediaDevices/getUserMedia
|
||||||
[`systemPreferences.getMediaAccessStatus`]: system-preferences.md#systempreferencesgetmediaaccessstatusmediatype-windows-macos
|
[`systemPreferences.getMediaAccessStatus`]: system-preferences.md#systempreferencesgetmediaaccessstatusmediatype-windows-macos
|
||||||
|
|||||||
@@ -67,10 +67,11 @@ The `extensions` array should contain extensions without wildcards or dots (e.g.
|
|||||||
`'png'` is good but `'.png'` and `'*.png'` are bad). To show all files, use the
|
`'png'` is good but `'.png'` and `'*.png'` are bad). To show all files, use the
|
||||||
`'*'` wildcard (no other wildcard is supported).
|
`'*'` wildcard (no other wildcard is supported).
|
||||||
|
|
||||||
**Note:** On Windows and Linux an open dialog can not be both a file selector
|
> [!NOTE]
|
||||||
and a directory selector, so if you set `properties` to
|
> On Windows and Linux an open dialog can not be both a file selector
|
||||||
`['openFile', 'openDirectory']` on these platforms, a directory selector will be
|
> and a directory selector, so if you set `properties` to
|
||||||
shown.
|
> `['openFile', 'openDirectory']` on these platforms, a directory selector will be
|
||||||
|
> shown.
|
||||||
|
|
||||||
```js @ts-type={mainWindow:Electron.BaseWindow}
|
```js @ts-type={mainWindow:Electron.BaseWindow}
|
||||||
dialog.showOpenDialogSync(mainWindow, {
|
dialog.showOpenDialogSync(mainWindow, {
|
||||||
@@ -78,10 +79,11 @@ dialog.showOpenDialogSync(mainWindow, {
|
|||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
**Note:** On Linux `defaultPath` is not supported when using portal file chooser
|
> [!NOTE]
|
||||||
dialogs unless the portal backend is version 4 or higher. You can use `--xdg-portal-required-version`
|
> On Linux `defaultPath` is not supported when using portal file chooser
|
||||||
[command-line switch](./command-line-switches.md#--xdg-portal-required-versionversion)
|
> dialogs unless the portal backend is version 4 or higher. You can use `--xdg-portal-required-version`
|
||||||
to force gtk or kde dialogs.
|
> [command-line switch](./command-line-switches.md#--xdg-portal-required-versionversion)
|
||||||
|
> to force gtk or kde dialogs.
|
||||||
|
|
||||||
### `dialog.showOpenDialog([window, ]options)`
|
### `dialog.showOpenDialog([window, ]options)`
|
||||||
|
|
||||||
@@ -139,10 +141,11 @@ The `extensions` array should contain extensions without wildcards or dots (e.g.
|
|||||||
`'png'` is good but `'.png'` and `'*.png'` are bad). To show all files, use the
|
`'png'` is good but `'.png'` and `'*.png'` are bad). To show all files, use the
|
||||||
`'*'` wildcard (no other wildcard is supported).
|
`'*'` wildcard (no other wildcard is supported).
|
||||||
|
|
||||||
**Note:** On Windows and Linux an open dialog can not be both a file selector
|
> [!NOTE]
|
||||||
and a directory selector, so if you set `properties` to
|
> On Windows and Linux an open dialog can not be both a file selector
|
||||||
`['openFile', 'openDirectory']` on these platforms, a directory selector will be
|
> and a directory selector, so if you set `properties` to
|
||||||
shown.
|
> `['openFile', 'openDirectory']` on these platforms, a directory selector will be
|
||||||
|
> shown.
|
||||||
|
|
||||||
```js @ts-type={mainWindow:Electron.BaseWindow}
|
```js @ts-type={mainWindow:Electron.BaseWindow}
|
||||||
dialog.showOpenDialog(mainWindow, {
|
dialog.showOpenDialog(mainWindow, {
|
||||||
@@ -155,10 +158,11 @@ dialog.showOpenDialog(mainWindow, {
|
|||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
**Note:** On Linux `defaultPath` is not supported when using portal file chooser
|
> [!NOTE]
|
||||||
dialogs unless the portal backend is version 4 or higher. You can use `--xdg-portal-required-version`
|
> On Linux `defaultPath` is not supported when using portal file chooser
|
||||||
[command-line switch](./command-line-switches.md#--xdg-portal-required-versionversion)
|
> dialogs unless the portal backend is version 4 or higher. You can use `--xdg-portal-required-version`
|
||||||
to force gtk or kde dialogs.
|
> [command-line switch](./command-line-switches.md#--xdg-portal-required-versionversion)
|
||||||
|
> to force gtk or kde dialogs.
|
||||||
|
|
||||||
### `dialog.showSaveDialogSync([window, ]options)`
|
### `dialog.showSaveDialogSync([window, ]options)`
|
||||||
|
|
||||||
@@ -225,8 +229,9 @@ The `window` argument allows the dialog to attach itself to a parent window, mak
|
|||||||
The `filters` specifies an array of file types that can be displayed, see
|
The `filters` specifies an array of file types that can be displayed, see
|
||||||
`dialog.showOpenDialog` for an example.
|
`dialog.showOpenDialog` for an example.
|
||||||
|
|
||||||
**Note:** On macOS, using the asynchronous version is recommended to avoid issues when
|
> [!NOTE]
|
||||||
expanding and collapsing the dialog.
|
> On macOS, using the asynchronous version is recommended to avoid issues when
|
||||||
|
> expanding and collapsing the dialog.
|
||||||
|
|
||||||
### `dialog.showMessageBoxSync([window, ]options)`
|
### `dialog.showMessageBoxSync([window, ]options)`
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ The following example shows how to bounce your icon on the dock.
|
|||||||
|
|
||||||
```js
|
```js
|
||||||
const { app } = require('electron')
|
const { app } = require('electron')
|
||||||
app.dock.bounce()
|
app.dock?.bounce()
|
||||||
```
|
```
|
||||||
|
|
||||||
### Instance Methods
|
### Instance Methods
|
||||||
@@ -28,7 +28,8 @@ When `informational` is passed, the dock icon will bounce for one second.
|
|||||||
However, the request remains active until either the application becomes active
|
However, the request remains active until either the application becomes active
|
||||||
or the request is canceled.
|
or the request is canceled.
|
||||||
|
|
||||||
**Note:** This method can only be used while the app is not focused; when the app is focused it will return -1.
|
> [!NOTE]
|
||||||
|
> This method can only be used while the app is not focused; when the app is focused it will return -1.
|
||||||
|
|
||||||
#### `dock.cancelBounce(id)` _macOS_
|
#### `dock.cancelBounce(id)` _macOS_
|
||||||
|
|
||||||
|
|||||||
@@ -115,7 +115,8 @@ Returns `boolean` - Whether the download is paused.
|
|||||||
|
|
||||||
Resumes the download that has been paused.
|
Resumes the download that has been paused.
|
||||||
|
|
||||||
**Note:** To enable resumable downloads the server you are downloading from must support range requests and provide both `Last-Modified` and `ETag` header values. Otherwise `resume()` will dismiss previously received bytes and restart the download from the beginning.
|
> [!NOTE]
|
||||||
|
> To enable resumable downloads the server you are downloading from must support range requests and provide both `Last-Modified` and `ETag` header values. Otherwise `resume()` will dismiss previously received bytes and restart the download from the beginning.
|
||||||
|
|
||||||
#### `downloadItem.canResume()`
|
#### `downloadItem.canResume()`
|
||||||
|
|
||||||
@@ -141,9 +142,10 @@ Returns `boolean` - Whether the download has user gesture.
|
|||||||
|
|
||||||
Returns `string` - The file name of the download item.
|
Returns `string` - The file name of the download item.
|
||||||
|
|
||||||
**Note:** The file name is not always the same as the actual one saved in local
|
> [!NOTE]
|
||||||
disk. If user changes the file name in a prompted download saving dialog, the
|
> The file name is not always the same as the actual one saved in local
|
||||||
actual name of saved file will be different.
|
> disk. If user changes the file name in a prompted download saving dialog, the
|
||||||
|
> actual name of saved file will be different.
|
||||||
|
|
||||||
#### `downloadItem.getCurrentBytesPerSecond()`
|
#### `downloadItem.getCurrentBytesPerSecond()`
|
||||||
|
|
||||||
@@ -172,8 +174,9 @@ header.
|
|||||||
|
|
||||||
Returns `string` - The current state. Can be `progressing`, `completed`, `cancelled` or `interrupted`.
|
Returns `string` - The current state. Can be `progressing`, `completed`, `cancelled` or `interrupted`.
|
||||||
|
|
||||||
**Note:** The following methods are useful specifically to resume a
|
> [!NOTE]
|
||||||
`cancelled` item when session is restarted.
|
> The following methods are useful specifically to resume a
|
||||||
|
> `cancelled` item when session is restarted.
|
||||||
|
|
||||||
#### `downloadItem.getURLChain()`
|
#### `downloadItem.getURLChain()`
|
||||||
|
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ you would when running the normal Node.js executable, with the exception of the
|
|||||||
These flags are disabled owing to the fact that Electron uses BoringSSL instead of OpenSSL when building Node.js'
|
These flags are disabled owing to the fact that Electron uses BoringSSL instead of OpenSSL when building Node.js'
|
||||||
`crypto` module, and so will not work as designed.
|
`crypto` module, and so will not work as designed.
|
||||||
|
|
||||||
If the [`runAsNode` fuse](../tutorial/fuses.md#L13) is disabled, `ELECTRON_RUN_AS_NODE` will be ignored.
|
If the [`runAsNode` fuse](../tutorial/fuses.md#runasnode) is disabled, `ELECTRON_RUN_AS_NODE` will be ignored.
|
||||||
|
|
||||||
### `ELECTRON_NO_ATTACH_CONSOLE` _Windows_
|
### `ELECTRON_NO_ATTACH_CONSOLE` _Windows_
|
||||||
|
|
||||||
|
|||||||
@@ -92,11 +92,13 @@ app.whenReady().then(async () => {
|
|||||||
|
|
||||||
This API does not support loading packed (.crx) extensions.
|
This API does not support loading packed (.crx) extensions.
|
||||||
|
|
||||||
**Note:** This API cannot be called before the `ready` event of the `app` module
|
> [!NOTE]
|
||||||
is emitted.
|
> This API cannot be called before the `ready` event of the `app` module
|
||||||
|
> is emitted.
|
||||||
|
|
||||||
**Note:** Loading extensions into in-memory (non-persistent) sessions is not
|
> [!NOTE]
|
||||||
supported and will throw an error.
|
> Loading extensions into in-memory (non-persistent) sessions is not
|
||||||
|
> supported and will throw an error.
|
||||||
|
|
||||||
#### `extensions.removeExtension(extensionId)`
|
#### `extensions.removeExtension(extensionId)`
|
||||||
|
|
||||||
@@ -104,8 +106,9 @@ supported and will throw an error.
|
|||||||
|
|
||||||
Unloads an extension.
|
Unloads an extension.
|
||||||
|
|
||||||
**Note:** This API cannot be called before the `ready` event of the `app` module
|
> [!NOTE]
|
||||||
is emitted.
|
> This API cannot be called before the `ready` event of the `app` module
|
||||||
|
> is emitted.
|
||||||
|
|
||||||
#### `extensions.getExtension(extensionId)`
|
#### `extensions.getExtension(extensionId)`
|
||||||
|
|
||||||
@@ -113,12 +116,14 @@ is emitted.
|
|||||||
|
|
||||||
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
|
> [!NOTE]
|
||||||
is emitted.
|
> This API cannot be called before the `ready` event of the `app` module
|
||||||
|
> is emitted.
|
||||||
|
|
||||||
#### `extensions.getAllExtensions()`
|
#### `extensions.getAllExtensions()`
|
||||||
|
|
||||||
Returns `Extension[]` - A list of all loaded extensions.
|
Returns `Extension[]` - A list of all loaded extensions.
|
||||||
|
|
||||||
**Note:** This API cannot be called before the `ready` event of the `app` module
|
> [!NOTE]
|
||||||
is emitted.
|
> This API cannot be called before the `ready` event of the `app` module
|
||||||
|
> is emitted.
|
||||||
|
|||||||
@@ -6,7 +6,8 @@ but it also happens to support some other extension capabilities.
|
|||||||
|
|
||||||
[chrome-extensions-api-index]: https://developer.chrome.com/extensions/api_index
|
[chrome-extensions-api-index]: https://developer.chrome.com/extensions/api_index
|
||||||
|
|
||||||
> **Note:** Electron does not support arbitrary Chrome extensions from the
|
> [!NOTE]
|
||||||
|
> Electron does not support arbitrary Chrome extensions from the
|
||||||
> store, and it is a **non-goal** of the Electron project to be perfectly
|
> store, and it is a **non-goal** of the Electron project to be perfectly
|
||||||
> compatible with Chrome's implementation of Extensions.
|
> compatible with Chrome's implementation of Extensions.
|
||||||
|
|
||||||
@@ -160,7 +161,8 @@ The following methods of `chrome.tabs` are supported:
|
|||||||
- `chrome.tabs.update` (partial support)
|
- `chrome.tabs.update` (partial support)
|
||||||
- supported properties: `url`, `muted`.
|
- supported properties: `url`, `muted`.
|
||||||
|
|
||||||
> **Note:** In Chrome, passing `-1` as a tab ID signifies the "currently active
|
> [!NOTE]
|
||||||
|
> In Chrome, passing `-1` as a tab ID signifies the "currently active
|
||||||
> tab". Since Electron has no such concept, passing `-1` as a tab ID is not
|
> tab". Since Electron has no such concept, passing `-1` as a tab ID is not
|
||||||
> supported and will raise an error.
|
> supported and will raise an error.
|
||||||
|
|
||||||
@@ -170,6 +172,7 @@ See [official documentation](https://developer.chrome.com/docs/extensions/refere
|
|||||||
|
|
||||||
All features of this API are supported.
|
All features of this API are supported.
|
||||||
|
|
||||||
> **NOTE:** Electron's [`webRequest`](web-request.md) module takes precedence over `chrome.webRequest` if there are conflicting handlers.
|
> [!NOTE]
|
||||||
|
> Electron's [`webRequest`](web-request.md) module takes precedence over `chrome.webRequest` if there are conflicting handlers.
|
||||||
|
|
||||||
See [official documentation](https://developer.chrome.com/docs/extensions/reference/webRequest) for more information.
|
See [official documentation](https://developer.chrome.com/docs/extensions/reference/webRequest) for more information.
|
||||||
|
|||||||
@@ -8,13 +8,13 @@ The `globalShortcut` module can register/unregister a global keyboard shortcut
|
|||||||
with the operating system so that you can customize the operations for various
|
with the operating system so that you can customize the operations for various
|
||||||
shortcuts.
|
shortcuts.
|
||||||
|
|
||||||
**Note:** The shortcut is global; it will work even if the app does
|
> [!NOTE]
|
||||||
not have the keyboard focus. This module cannot be used before the `ready`
|
> The shortcut is global; it will work even if the app does
|
||||||
event of the app module is emitted.
|
> not have the keyboard focus. This module cannot be used before the `ready`
|
||||||
|
> event of the app module is emitted.
|
||||||
Please also note that it is also possible to use Chromium's
|
> Please also note that it is also possible to use Chromium's
|
||||||
`GlobalShortcutsPortal` implementation, which allows apps to bind global
|
> `GlobalShortcutsPortal` implementation, which allows apps to bind global
|
||||||
shortcuts when running within a Wayland session.
|
> shortcuts when running within a Wayland session.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const { app, globalShortcut } = require('electron')
|
const { app, globalShortcut } = require('electron')
|
||||||
|
|||||||
65
docs/api/image-view.md
Normal file
65
docs/api/image-view.md
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
# ImageView
|
||||||
|
|
||||||
|
> A View that displays an image.
|
||||||
|
|
||||||
|
Process: [Main](../glossary.md#main-process)
|
||||||
|
|
||||||
|
This module cannot be used until the `ready` event of the `app`
|
||||||
|
module is emitted.
|
||||||
|
|
||||||
|
Useful for showing splash screens that will be swapped for `WebContentsView`s
|
||||||
|
when the content finishes loading.
|
||||||
|
|
||||||
|
Note that `ImageView` is experimental and may be changed or removed in the future.
|
||||||
|
|
||||||
|
```js
|
||||||
|
const { BaseWindow, ImageView, nativeImage, WebContentsView } = require('electron')
|
||||||
|
const path = require('node:path')
|
||||||
|
|
||||||
|
const win = new BaseWindow({ width: 800, height: 600 })
|
||||||
|
|
||||||
|
// Create a "splash screen" image to display while the WebContentsView loads
|
||||||
|
const splashView = new ImageView()
|
||||||
|
const splashImage = nativeImage.createFromPath(path.join(__dirname, 'loading.png'))
|
||||||
|
splashView.setImage(splashImage)
|
||||||
|
win.setContentView(splashView)
|
||||||
|
|
||||||
|
const webContentsView = new WebContentsView()
|
||||||
|
webContentsView.webContents.once('did-finish-load', () => {
|
||||||
|
// Now that the WebContentsView has loaded, swap out the "splash screen" ImageView
|
||||||
|
win.setContentView(webContentsView)
|
||||||
|
})
|
||||||
|
webContentsView.webContents.loadURL('https://electronjs.org')
|
||||||
|
```
|
||||||
|
|
||||||
|
## Class: ImageView extends `View`
|
||||||
|
|
||||||
|
> A View that displays an image.
|
||||||
|
|
||||||
|
Process: [Main](../glossary.md#main-process)
|
||||||
|
|
||||||
|
`ImageView` inherits from [`View`](view.md).
|
||||||
|
|
||||||
|
`ImageView` is an [EventEmitter][event-emitter].
|
||||||
|
|
||||||
|
> [!WARNING]
|
||||||
|
> Electron's built-in classes cannot be subclassed in user code.
|
||||||
|
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
|
||||||
|
|
||||||
|
### `new ImageView()` _Experimental_
|
||||||
|
|
||||||
|
Creates an ImageView.
|
||||||
|
|
||||||
|
### Instance Methods
|
||||||
|
|
||||||
|
The following methods are available on instances of the `ImageView` class, in
|
||||||
|
addition to those inherited from [View](view.md):
|
||||||
|
|
||||||
|
#### `image.setImage(image)` _Experimental_
|
||||||
|
|
||||||
|
* `image` NativeImage
|
||||||
|
|
||||||
|
Sets the image for this `ImageView`. Note that only image formats supported by
|
||||||
|
`NativeImage` can be used with an `ImageView`.
|
||||||
|
|
||||||
|
[event-emitter]: https://nodejs.org/api/events.html#events_class_eventemitter
|
||||||
@@ -11,6 +11,10 @@ Process: [Main](../glossary.md#main-process)
|
|||||||
|
|
||||||
<!-- TODO(samuelmaddock): refactor doc gen to allow generics to reduce duplication -->
|
<!-- TODO(samuelmaddock): refactor doc gen to allow generics to reduce duplication -->
|
||||||
|
|
||||||
|
> [!WARNING]
|
||||||
|
> Electron's built-in classes cannot be subclassed in user code.
|
||||||
|
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
|
||||||
|
|
||||||
### Instance Methods
|
### Instance Methods
|
||||||
|
|
||||||
#### `ipcMainServiceWorker.on(channel, listener)`
|
#### `ipcMainServiceWorker.on(channel, listener)`
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ If you need to transfer a [`MessagePort`][] to the main process, use [`ipcRender
|
|||||||
|
|
||||||
If you do not need a response to the message, consider using [`ipcRenderer.send`](#ipcrenderersendchannel-args).
|
If you do not need a response to the message, consider using [`ipcRenderer.send`](#ipcrenderersendchannel-args).
|
||||||
|
|
||||||
> **Note**
|
> [!NOTE]
|
||||||
> Sending non-standard JavaScript types such as DOM objects or
|
> Sending non-standard JavaScript types such as DOM objects or
|
||||||
> special Electron objects will throw an exception.
|
> special Electron objects will throw an exception.
|
||||||
>
|
>
|
||||||
@@ -165,7 +165,7 @@ If you do not need a response to the message, consider using [`ipcRenderer.send`
|
|||||||
> Electron's IPC to the main process, as the main process would have no way to decode
|
> Electron's IPC to the main process, as the main process would have no way to decode
|
||||||
> them. Attempting to send such objects over IPC will result in an error.
|
> them. Attempting to send such objects over IPC will result in an error.
|
||||||
|
|
||||||
> **Note**
|
> [!NOTE]
|
||||||
> If the handler in the main process throws an error,
|
> If the handler in the main process throws an error,
|
||||||
> the promise returned by `invoke` will reject.
|
> the promise returned by `invoke` will reject.
|
||||||
> However, the `Error` object in the renderer process
|
> However, the `Error` object in the renderer process
|
||||||
@@ -195,7 +195,8 @@ throw an exception.
|
|||||||
The main process handles it by listening for `channel` with [`ipcMain`](./ipc-main.md) module,
|
The main process handles it by listening for `channel` with [`ipcMain`](./ipc-main.md) module,
|
||||||
and replies by setting `event.returnValue`.
|
and replies by setting `event.returnValue`.
|
||||||
|
|
||||||
> :warning: **WARNING**: Sending a synchronous message will block the whole
|
> [!WARNING]
|
||||||
|
> Sending a synchronous message will block the whole
|
||||||
> renderer process until the reply is received, so use this method only as a
|
> renderer process until the reply is received, so use this method only as a
|
||||||
> last resort. It's much better to use the asynchronous version,
|
> last resort. It's much better to use the asynchronous version,
|
||||||
> [`invoke()`](./ipc-renderer.md#ipcrendererinvokechannel-args).
|
> [`invoke()`](./ipc-renderer.md#ipcrendererinvokechannel-args).
|
||||||
|
|||||||
@@ -6,6 +6,10 @@ Process: [Main](../glossary.md#main-process)
|
|||||||
|
|
||||||
See [`Menu`](menu.md) for examples.
|
See [`Menu`](menu.md) for examples.
|
||||||
|
|
||||||
|
> [!WARNING]
|
||||||
|
> Electron's built-in classes cannot be subclassed in user code.
|
||||||
|
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
|
||||||
|
|
||||||
### `new MenuItem(options)`
|
### `new MenuItem(options)`
|
||||||
|
|
||||||
* `options` Object
|
* `options` Object
|
||||||
@@ -19,7 +23,7 @@ See [`Menu`](menu.md) for examples.
|
|||||||
* `type` string (optional) - Can be `normal`, `separator`, `submenu`, `checkbox` or
|
* `type` string (optional) - Can be `normal`, `separator`, `submenu`, `checkbox` or
|
||||||
`radio`.
|
`radio`.
|
||||||
* `label` string (optional)
|
* `label` string (optional)
|
||||||
* `sublabel` string (optional)
|
* `sublabel` string (optional) _macOS_ - Available in macOS >= 14.4
|
||||||
* `toolTip` string (optional) _macOS_ - Hover text for this menu item.
|
* `toolTip` string (optional) _macOS_ - Hover text for this menu item.
|
||||||
* `accelerator` [Accelerator](accelerator.md) (optional)
|
* `accelerator` [Accelerator](accelerator.md) (optional)
|
||||||
* `icon` ([NativeImage](native-image.md) | string) (optional)
|
* `icon` ([NativeImage](native-image.md) | string) (optional)
|
||||||
@@ -51,7 +55,8 @@ See [`Menu`](menu.md) for examples.
|
|||||||
the placement of their containing group after the containing group of the item
|
the placement of their containing group after the containing group of the item
|
||||||
with the specified id.
|
with the specified id.
|
||||||
|
|
||||||
**Note:** `acceleratorWorksWhenHidden` is specified as being macOS-only because accelerators always work when items are hidden on Windows and Linux. The option is exposed to users to give them the option to turn it off, as this is possible in native macOS development.
|
> [!NOTE]
|
||||||
|
> `acceleratorWorksWhenHidden` is specified as being macOS-only because accelerators always work when items are hidden on Windows and Linux. The option is exposed to users to give them the option to turn it off, as this is possible in native macOS development.
|
||||||
|
|
||||||
### Roles
|
### Roles
|
||||||
|
|
||||||
@@ -125,7 +130,8 @@ When specifying a `role` on macOS, `label` and `accelerator` are the only
|
|||||||
options that will affect the menu item. All other options will be ignored.
|
options that will affect the menu item. All other options will be ignored.
|
||||||
Lowercase `role`, e.g. `toggledevtools`, is still supported.
|
Lowercase `role`, e.g. `toggledevtools`, is still supported.
|
||||||
|
|
||||||
**Note:** The `enabled` and `visibility` properties are not available for top-level menu items in the tray on macOS.
|
> [!NOTE]
|
||||||
|
> The `enabled` and `visibility` properties are not available for top-level menu items in the tray on macOS.
|
||||||
|
|
||||||
### Instance Properties
|
### Instance Properties
|
||||||
|
|
||||||
@@ -170,7 +176,8 @@ An `Accelerator` (optional) indicating the item's accelerator, if set.
|
|||||||
|
|
||||||
An `Accelerator | null` indicating the item's [user-assigned accelerator](https://developer.apple.com/documentation/appkit/nsmenuitem/1514850-userkeyequivalent?language=objc) for the menu item.
|
An `Accelerator | null` indicating the item's [user-assigned accelerator](https://developer.apple.com/documentation/appkit/nsmenuitem/1514850-userkeyequivalent?language=objc) for the menu item.
|
||||||
|
|
||||||
**Note:** This property is only initialized after the `MenuItem` has been added to a `Menu`. Either via `Menu.buildFromTemplate` or via `Menu.append()/insert()`. Accessing before initialization will just return `null`.
|
> [!NOTE]
|
||||||
|
> This property is only initialized after the `MenuItem` has been added to a `Menu`. Either via `Menu.buildFromTemplate` or via `Menu.append()/insert()`. Accessing before initialization will just return `null`.
|
||||||
|
|
||||||
#### `menuItem.icon`
|
#### `menuItem.icon`
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,10 @@
|
|||||||
|
|
||||||
Process: [Main](../glossary.md#main-process)
|
Process: [Main](../glossary.md#main-process)
|
||||||
|
|
||||||
|
> [!WARNING]
|
||||||
|
> Electron's built-in classes cannot be subclassed in user code.
|
||||||
|
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
|
||||||
|
|
||||||
### `new Menu()`
|
### `new Menu()`
|
||||||
|
|
||||||
Creates a new menu.
|
Creates a new menu.
|
||||||
@@ -32,16 +36,18 @@ In order to escape the `&` character in an item name, add a proceeding `&`. For
|
|||||||
Passing `null` will suppress the default menu. On Windows and Linux,
|
Passing `null` will suppress the default menu. On Windows and Linux,
|
||||||
this has the additional effect of removing the menu bar from the window.
|
this has the additional effect of removing the menu bar from the window.
|
||||||
|
|
||||||
**Note:** The default menu will be created automatically if the app does not set one.
|
> [!NOTE]
|
||||||
It contains standard items such as `File`, `Edit`, `View`, `Window` and `Help`.
|
> The default menu will be created automatically if the app does not set one.
|
||||||
|
> It contains standard items such as `File`, `Edit`, `View`, `Window` and `Help`.
|
||||||
|
|
||||||
#### `Menu.getApplicationMenu()`
|
#### `Menu.getApplicationMenu()`
|
||||||
|
|
||||||
Returns `Menu | null` - The application menu, if set, or `null`, if not set.
|
Returns `Menu | null` - The application menu, if set, or `null`, if not set.
|
||||||
|
|
||||||
**Note:** The returned `Menu` instance doesn't support dynamic addition or
|
> [!NOTE]
|
||||||
removal of menu items. [Instance properties](#instance-properties) can still
|
> The returned `Menu` instance doesn't support dynamic addition or
|
||||||
be dynamically modified.
|
> removal of menu items. [Instance properties](#instance-properties) can still
|
||||||
|
> be dynamically modified.
|
||||||
|
|
||||||
#### `Menu.sendActionToFirstResponder(action)` _macOS_
|
#### `Menu.sendActionToFirstResponder(action)` _macOS_
|
||||||
|
|
||||||
@@ -73,6 +79,8 @@ The `menu` object has the following instance methods:
|
|||||||
|
|
||||||
* `options` Object (optional)
|
* `options` Object (optional)
|
||||||
* `window` [BaseWindow](base-window.md) (optional) - Default is the focused window.
|
* `window` [BaseWindow](base-window.md) (optional) - Default is the focused window.
|
||||||
|
* `frame` [WebFrameMain](web-frame-main.md) (optional) - Provide the relevant frame
|
||||||
|
if you want certain OS-level features such as Writing Tools on macOS to function correctly. Typically, this should be `params.frame` from the [`context-menu` event](web-contents.md#event-context-menu) on a WebContents, or the [`focusedFrame` property](web-contents.md#contentsfocusedframe-readonly) of a WebContents.
|
||||||
* `x` number (optional) - Default is the current mouse cursor position.
|
* `x` number (optional) - Default is the current mouse cursor position.
|
||||||
Must be declared if `y` is declared.
|
Must be declared if `y` is declared.
|
||||||
* `y` number (optional) - Default is the current mouse cursor position.
|
* `y` number (optional) - Default is the current mouse cursor position.
|
||||||
@@ -117,8 +125,9 @@ Inserts the `menuItem` to the `pos` position of the menu.
|
|||||||
|
|
||||||
Objects created with `new Menu` or returned by `Menu.buildFromTemplate` emit the following events:
|
Objects created with `new Menu` or returned by `Menu.buildFromTemplate` emit the following events:
|
||||||
|
|
||||||
**Note:** Some events are only available on specific operating systems and are
|
> [!NOTE]
|
||||||
labeled as such.
|
> Some events are only available on specific operating systems and are
|
||||||
|
> labeled as such.
|
||||||
|
|
||||||
#### Event: 'menu-will-show'
|
#### Event: 'menu-will-show'
|
||||||
|
|
||||||
@@ -327,6 +336,27 @@ name, no matter what label you set. To change it, modify your app bundle's
|
|||||||
[About Information Property List Files][AboutInformationPropertyListFiles]
|
[About Information Property List Files][AboutInformationPropertyListFiles]
|
||||||
for more information.
|
for more information.
|
||||||
|
|
||||||
|
### Menu Sublabels
|
||||||
|
|
||||||
|
Menu sublabels, or [subtitles](https://developer.apple.com/documentation/appkit/nsmenuitem/subtitle?language=objc), can be added to menu items using the `sublabel` option. Below is an example based on the renderer example above:
|
||||||
|
|
||||||
|
```js @ts-expect-error=[12]
|
||||||
|
// main
|
||||||
|
ipcMain.on('show-context-menu', (event) => {
|
||||||
|
const template = [
|
||||||
|
{
|
||||||
|
label: 'Menu Item 1',
|
||||||
|
sublabel: 'Subtitle 1',
|
||||||
|
click: () => { event.sender.send('context-menu-command', 'menu-item-1') }
|
||||||
|
},
|
||||||
|
{ type: 'separator' },
|
||||||
|
{ label: 'Menu Item 2', sublabel: 'Subtitle 2', type: 'checkbox', checked: true }
|
||||||
|
]
|
||||||
|
const menu = Menu.buildFromTemplate(template)
|
||||||
|
menu.popup({ window: BrowserWindow.fromWebContents(event.sender) })
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
## Setting Menu for Specific Browser Window (_Linux_ _Windows_)
|
## Setting Menu for Specific Browser Window (_Linux_ _Windows_)
|
||||||
|
|
||||||
The [`setMenu` method][setMenu] of browser windows can set the menu of certain
|
The [`setMenu` method][setMenu] of browser windows can set the menu of certain
|
||||||
|
|||||||
@@ -33,6 +33,10 @@ ipcRenderer.on('port', (e) => {
|
|||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
|
> [!WARNING]
|
||||||
|
> Electron's built-in classes cannot be subclassed in user code.
|
||||||
|
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
|
||||||
|
|
||||||
### Instance Properties
|
### Instance Properties
|
||||||
|
|
||||||
#### `channel.port1`
|
#### `channel.port1`
|
||||||
|
|||||||
@@ -134,7 +134,8 @@ Creates an empty `NativeImage` instance.
|
|||||||
|
|
||||||
Returns `Promise<NativeImage>` - fulfilled with the file's thumbnail preview image, which is a [NativeImage](native-image.md).
|
Returns `Promise<NativeImage>` - fulfilled with the file's thumbnail preview image, which is a [NativeImage](native-image.md).
|
||||||
|
|
||||||
Note: The Windows implementation will ignore `size.height` and scale the height according to `size.width`.
|
> [!NOTE]
|
||||||
|
> Windows implementation will ignore `size.height` and scale the height according to `size.width`.
|
||||||
|
|
||||||
### `nativeImage.createFromPath(path)`
|
### `nativeImage.createFromPath(path)`
|
||||||
|
|
||||||
@@ -142,8 +143,8 @@ Note: The Windows implementation will ignore `size.height` and scale the height
|
|||||||
|
|
||||||
Returns `NativeImage`
|
Returns `NativeImage`
|
||||||
|
|
||||||
Creates a new `NativeImage` instance from a file located at `path`. This method
|
Creates a new `NativeImage` instance from an image file (e.g., PNG or JPEG) located at `path`.
|
||||||
returns an empty image if the `path` does not exist, cannot be read, or is not
|
This method returns an empty image if the `path` does not exist, cannot be read, or is not
|
||||||
a valid image.
|
a valid image.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
@@ -271,16 +272,12 @@ changes:
|
|||||||
|
|
||||||
Returns `string` - The [Data URL][data-url] of the image.
|
Returns `string` - The [Data URL][data-url] of the image.
|
||||||
|
|
||||||
#### `image.getBitmap([options])`
|
#### `image.getBitmap([options])` _Deprecated_
|
||||||
|
|
||||||
* `options` Object (optional)
|
* `options` Object (optional)
|
||||||
* `scaleFactor` Number (optional) - Defaults to 1.0.
|
* `scaleFactor` Number (optional) - Defaults to 1.0.
|
||||||
|
|
||||||
Returns `Buffer` - A [Buffer][buffer] that contains the image's raw bitmap pixel data.
|
Legacy alias for `image.toBitmap()`.
|
||||||
|
|
||||||
The difference between `getBitmap()` and `toBitmap()` is that `getBitmap()` does not
|
|
||||||
copy the bitmap data, so you have to use the returned Buffer immediately in
|
|
||||||
current event loop tick; otherwise the data might be changed or destroyed.
|
|
||||||
|
|
||||||
#### `image.getNativeHandle()` _macOS_
|
#### `image.getNativeHandle()` _macOS_
|
||||||
|
|
||||||
|
|||||||
@@ -63,6 +63,14 @@ Your application should then always use `shouldUseDarkColors` to determine what
|
|||||||
A `boolean` for if the OS / Chromium currently has high-contrast mode enabled
|
A `boolean` for if the OS / Chromium currently has high-contrast mode enabled
|
||||||
or is being instructed to show a high-contrast UI.
|
or is being instructed to show a high-contrast UI.
|
||||||
|
|
||||||
|
### `nativeTheme.shouldUseDarkColorsForSystemIntegratedUI` _macOS_ _Windows_ _Readonly_
|
||||||
|
|
||||||
|
A `boolean` property indicating whether or not the system theme has been set to dark or light.
|
||||||
|
|
||||||
|
On Windows this property distinguishes between system and app light/dark theme, returning
|
||||||
|
`true` if the system theme is set to dark theme and `false` otherwise. On macOS the return
|
||||||
|
value will be the same as `nativeTheme.shouldUseDarkColors`.
|
||||||
|
|
||||||
### `nativeTheme.shouldUseInvertedColorScheme` _macOS_ _Windows_ _Readonly_
|
### `nativeTheme.shouldUseInvertedColorScheme` _macOS_ _Windows_ _Readonly_
|
||||||
|
|
||||||
A `boolean` for if the OS / Chromium currently has an inverted color scheme
|
A `boolean` for if the OS / Chromium currently has an inverted color scheme
|
||||||
|
|||||||
@@ -17,8 +17,9 @@ app.whenReady().then(async () => {
|
|||||||
|
|
||||||
See [`--log-net-log`](command-line-switches.md#--log-net-logpath) to log network events throughout the app's lifecycle.
|
See [`--log-net-log`](command-line-switches.md#--log-net-logpath) to log network events throughout the app's lifecycle.
|
||||||
|
|
||||||
**Note:** All methods unless specified can only be used after the `ready` event
|
> [!NOTE]
|
||||||
of the `app` module gets emitted.
|
> All methods unless specified can only be used after the `ready` event
|
||||||
|
> of the `app` module gets emitted.
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
|
|
||||||
|
|||||||
@@ -117,8 +117,9 @@ protocol.handle('https', (req) => {
|
|||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
Note: in the [utility process](../glossary.md#utility-process) custom protocols
|
> [!NOTE]
|
||||||
are not supported.
|
> In the [utility process](../glossary.md#utility-process), custom protocols
|
||||||
|
> are not supported.
|
||||||
|
|
||||||
### `net.isOnline()`
|
### `net.isOnline()`
|
||||||
|
|
||||||
|
|||||||
@@ -4,12 +4,9 @@
|
|||||||
|
|
||||||
Process: [Main](../glossary.md#main-process)
|
Process: [Main](../glossary.md#main-process)
|
||||||
|
|
||||||
:::info Renderer process notifications
|
> [!NOTE]
|
||||||
|
> If you want to show notifications from a renderer process you should use the
|
||||||
If you want to show notifications from a renderer process you should use the
|
> [web Notifications API](../tutorial/notifications.md)
|
||||||
[web Notifications API](../tutorial/notifications.md)
|
|
||||||
|
|
||||||
:::
|
|
||||||
|
|
||||||
## Class: Notification
|
## Class: Notification
|
||||||
|
|
||||||
@@ -21,6 +18,10 @@ Process: [Main](../glossary.md#main-process)
|
|||||||
|
|
||||||
It creates a new `Notification` with native properties as set by the `options`.
|
It creates a new `Notification` with native properties as set by the `options`.
|
||||||
|
|
||||||
|
> [!WARNING]
|
||||||
|
> Electron's built-in classes cannot be subclassed in user code.
|
||||||
|
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
|
||||||
|
|
||||||
### Static Methods
|
### Static Methods
|
||||||
|
|
||||||
The `Notification` class has the following static methods:
|
The `Notification` class has the following static methods:
|
||||||
|
|||||||
@@ -33,10 +33,11 @@ Returns `Integer` - The blocker ID that is assigned to this power blocker.
|
|||||||
Starts preventing the system from entering lower-power mode. Returns an integer
|
Starts preventing the system from entering lower-power mode. Returns an integer
|
||||||
identifying the power save blocker.
|
identifying the power save blocker.
|
||||||
|
|
||||||
**Note:** `prevent-display-sleep` has higher precedence over
|
> [!NOTE]
|
||||||
`prevent-app-suspension`. Only the highest precedence type takes effect. In
|
> `prevent-display-sleep` has higher precedence over
|
||||||
other words, `prevent-display-sleep` always takes precedence over
|
> `prevent-app-suspension`. Only the highest precedence type takes effect. In
|
||||||
`prevent-app-suspension`.
|
> other words, `prevent-display-sleep` always takes precedence over
|
||||||
|
> `prevent-app-suspension`.
|
||||||
|
|
||||||
For example, an API calling A requests for `prevent-app-suspension`, and
|
For example, an API calling A requests for `prevent-app-suspension`, and
|
||||||
another calling B requests for `prevent-display-sleep`. `prevent-display-sleep`
|
another calling B requests for `prevent-display-sleep`. `prevent-display-sleep`
|
||||||
|
|||||||
@@ -233,7 +233,8 @@ console.log(version)
|
|||||||
// On Linux -> '4.15.0-45-generic'
|
// On Linux -> '4.15.0-45-generic'
|
||||||
```
|
```
|
||||||
|
|
||||||
**Note:** It returns the actual operating system version instead of kernel version on macOS unlike `os.release()`.
|
> [!NOTE]
|
||||||
|
> It returns the actual operating system version instead of kernel version on macOS unlike `os.release()`.
|
||||||
|
|
||||||
### `process.takeHeapSnapshot(filePath)`
|
### `process.takeHeapSnapshot(filePath)`
|
||||||
|
|
||||||
|
|||||||
@@ -20,8 +20,9 @@ app.whenReady().then(() => {
|
|||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
**Note:** All methods unless specified can only be used after the `ready` event
|
> [!NOTE]
|
||||||
of the `app` module gets emitted.
|
> All methods unless specified can only be used after the `ready` event
|
||||||
|
> of the `app` module gets emitted.
|
||||||
|
|
||||||
## Using `protocol` with a custom `partition` or `session`
|
## Using `protocol` with a custom `partition` or `session`
|
||||||
|
|
||||||
@@ -61,8 +62,9 @@ The `protocol` module has the following methods:
|
|||||||
|
|
||||||
* `customSchemes` [CustomScheme[]](structures/custom-scheme.md)
|
* `customSchemes` [CustomScheme[]](structures/custom-scheme.md)
|
||||||
|
|
||||||
**Note:** This method can only be used before the `ready` event of the `app`
|
> [!NOTE]
|
||||||
module gets emitted and can be called only once.
|
> This method can only be used before the `ready` event of the `app`
|
||||||
|
> module gets emitted and can be called only once.
|
||||||
|
|
||||||
Registers the `scheme` as standard, secure, bypasses content security policy for
|
Registers the `scheme` as standard, secure, bypasses content security policy for
|
||||||
resources, allows registering ServiceWorker, supports fetch API, streaming
|
resources, allows registering ServiceWorker, supports fetch API, streaming
|
||||||
|
|||||||
@@ -46,4 +46,7 @@ See: https://developer.apple.com/documentation/appkit/nsapplication/1428476-regi
|
|||||||
### `pushNotifications.unregisterForAPNSNotifications()` _macOS_
|
### `pushNotifications.unregisterForAPNSNotifications()` _macOS_
|
||||||
|
|
||||||
Unregisters the app from notifications received from APNS.
|
Unregisters the app from notifications received from APNS.
|
||||||
|
|
||||||
|
Apps unregistered through this method can always reregister.
|
||||||
|
|
||||||
See: https://developer.apple.com/documentation/appkit/nsapplication/1428747-unregisterforremotenotifications?language=objc
|
See: https://developer.apple.com/documentation/appkit/nsapplication/1428747-unregisterforremotenotifications?language=objc
|
||||||
|
|||||||
@@ -73,5 +73,6 @@ command line flag is provided `--password-store="basic"`.
|
|||||||
is provided `--password-store="kwallet"`.
|
is provided `--password-store="kwallet"`.
|
||||||
* `kwallet5` - When the desktop session is `kde5` or if the following command line flag
|
* `kwallet5` - When the desktop session is `kde5` or if the following command line flag
|
||||||
is provided `--password-store="kwallet5"`.
|
is provided `--password-store="kwallet5"`.
|
||||||
* `kwallet6` - When the desktop session is `kde6`.
|
* `kwallet6` - When the desktop session is `kde6` or if the following command line flag
|
||||||
|
is provided `--password-store="kwallet6"`.
|
||||||
* `unknown` - When the function is called before app has emitted the `ready` event.
|
* `unknown` - When the function is called before app has emitted the `ready` event.
|
||||||
|
|||||||
@@ -9,8 +9,9 @@ module is emitted.
|
|||||||
|
|
||||||
`screen` is an [EventEmitter][event-emitter].
|
`screen` is an [EventEmitter][event-emitter].
|
||||||
|
|
||||||
**Note:** In the renderer / DevTools, `window.screen` is a reserved DOM
|
> [!NOTE]
|
||||||
property, so writing `let { screen } = require('electron')` will not work.
|
> In the renderer / DevTools, `window.screen` is a reserved DOM
|
||||||
|
> property, so writing `let { screen } = require('electron')` will not work.
|
||||||
|
|
||||||
An example of creating a window that fills the whole screen:
|
An example of creating a window that fills the whole screen:
|
||||||
|
|
||||||
@@ -57,6 +58,14 @@ app.whenReady().then(() => {
|
|||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
|
> Screen coordinates used by this module are [`Point`](structures/point.md) structures.
|
||||||
|
> There are two kinds of coordinates available to the process:
|
||||||
|
>
|
||||||
|
> * **Physical screen points** are raw hardware pixels on a display.
|
||||||
|
> * **Device-independent pixel (DIP) points** are virtualized screen points scaled based on the DPI
|
||||||
|
> (dots per inch) of the display.
|
||||||
|
|
||||||
## Events
|
## Events
|
||||||
|
|
||||||
The `screen` module emits the following events:
|
The `screen` module emits the following events:
|
||||||
@@ -101,7 +110,8 @@ Returns [`Point`](structures/point.md)
|
|||||||
|
|
||||||
The current absolute position of the mouse pointer.
|
The current absolute position of the mouse pointer.
|
||||||
|
|
||||||
**Note:** The return value is a DIP point, not a screen physical point.
|
> [!NOTE]
|
||||||
|
> The return value is a DIP point, not a screen physical point.
|
||||||
|
|
||||||
### `screen.getPrimaryDisplay()`
|
### `screen.getPrimaryDisplay()`
|
||||||
|
|
||||||
@@ -124,7 +134,7 @@ Returns [`Display`](structures/display.md) - The display nearest the specified p
|
|||||||
Returns [`Display`](structures/display.md) - The display that most closely
|
Returns [`Display`](structures/display.md) - The display that most closely
|
||||||
intersects the provided bounds.
|
intersects the provided bounds.
|
||||||
|
|
||||||
### `screen.screenToDipPoint(point)` _Windows_
|
### `screen.screenToDipPoint(point)` _Windows_ _Linux_
|
||||||
|
|
||||||
* `point` [Point](structures/point.md)
|
* `point` [Point](structures/point.md)
|
||||||
|
|
||||||
@@ -133,7 +143,10 @@ Returns [`Point`](structures/point.md)
|
|||||||
Converts a screen physical point to a screen DIP point.
|
Converts a screen physical point to a screen DIP point.
|
||||||
The DPI scale is performed relative to the display containing the physical point.
|
The DPI scale is performed relative to the display containing the physical point.
|
||||||
|
|
||||||
### `screen.dipToScreenPoint(point)` _Windows_
|
Not currently supported on Wayland - if used there it will return the point passed
|
||||||
|
in with no changes.
|
||||||
|
|
||||||
|
### `screen.dipToScreenPoint(point)` _Windows_ _Linux_
|
||||||
|
|
||||||
* `point` [Point](structures/point.md)
|
* `point` [Point](structures/point.md)
|
||||||
|
|
||||||
@@ -142,6 +155,8 @@ Returns [`Point`](structures/point.md)
|
|||||||
Converts a screen DIP point to a screen physical point.
|
Converts a screen DIP point to a screen physical point.
|
||||||
The DPI scale is performed relative to the display containing the DIP point.
|
The DPI scale is performed relative to the display containing the DIP point.
|
||||||
|
|
||||||
|
Not currently supported on Wayland.
|
||||||
|
|
||||||
### `screen.screenToDipRect(window, rect)` _Windows_
|
### `screen.screenToDipRect(window, rect)` _Windows_
|
||||||
|
|
||||||
* `window` [BrowserWindow](browser-window.md) | null
|
* `window` [BrowserWindow](browser-window.md) | null
|
||||||
|
|||||||
@@ -651,7 +651,7 @@ Clears the session’s HTTP cache.
|
|||||||
`shadercache`, `websql`, `serviceworkers`, `cachestorage`. If not
|
`shadercache`, `websql`, `serviceworkers`, `cachestorage`. If not
|
||||||
specified, clear all storage types.
|
specified, clear all storage types.
|
||||||
* `quotas` string[] (optional) - The types of quotas to clear, can be
|
* `quotas` string[] (optional) - The types of quotas to clear, can be
|
||||||
`temporary`, `syncable`. If not specified, clear all quotas.
|
`temporary`. If not specified, clear all quotas.
|
||||||
|
|
||||||
Returns `Promise<void>` - resolves when the storage data has been cleared.
|
Returns `Promise<void>` - resolves when the storage data has been cleared.
|
||||||
|
|
||||||
@@ -762,7 +762,8 @@ Preconnects the given number of sockets to an origin.
|
|||||||
|
|
||||||
Returns `Promise<void>` - Resolves when all connections are closed.
|
Returns `Promise<void>` - Resolves when all connections are closed.
|
||||||
|
|
||||||
**Note:** It will terminate / fail all requests currently in flight.
|
> [!NOTE]
|
||||||
|
> It will terminate / fail all requests currently in flight.
|
||||||
|
|
||||||
#### `ses.fetch(input[, init])`
|
#### `ses.fetch(input[, init])`
|
||||||
|
|
||||||
@@ -1305,8 +1306,9 @@ Initiates a download of the resource at `url`.
|
|||||||
The API will generate a [DownloadItem](download-item.md) that can be accessed
|
The API will generate a [DownloadItem](download-item.md) that can be accessed
|
||||||
with the [will-download](#event-will-download) event.
|
with the [will-download](#event-will-download) event.
|
||||||
|
|
||||||
**Note:** This does not perform any security checks that relate to a page's origin,
|
> [!NOTE]
|
||||||
unlike [`webContents.downloadURL`](web-contents.md#contentsdownloadurlurl-options).
|
> This does not perform any security checks that relate to a page's origin,
|
||||||
|
> unlike [`webContents.downloadURL`](web-contents.md#contentsdownloadurlurl-options).
|
||||||
|
|
||||||
#### `ses.createInterruptedDownload(options)`
|
#### `ses.createInterruptedDownload(options)`
|
||||||
|
|
||||||
@@ -1434,7 +1436,8 @@ The built in spellchecker does not automatically detect what language a user is
|
|||||||
spell checker to correctly check their words you must call this API with an array of language codes. You can
|
spell checker to correctly check their words you must call this API with an array of language codes. You can
|
||||||
get the list of supported language codes with the `ses.availableSpellCheckerLanguages` property.
|
get the list of supported language codes with the `ses.availableSpellCheckerLanguages` property.
|
||||||
|
|
||||||
**Note:** On macOS the OS spellchecker is used and will detect your language automatically. This API is a no-op on macOS.
|
> [!NOTE]
|
||||||
|
> On macOS, the OS spellchecker is used and will detect your language automatically. This API is a no-op on macOS.
|
||||||
|
|
||||||
#### `ses.getSpellCheckerLanguages()`
|
#### `ses.getSpellCheckerLanguages()`
|
||||||
|
|
||||||
@@ -1442,7 +1445,8 @@ Returns `string[]` - An array of language codes the spellchecker is enabled for.
|
|||||||
will fallback to using `en-US`. By default on launch if this setting is an empty list Electron will try to populate this
|
will fallback to using `en-US`. By default on launch if this setting is an empty list Electron will try to populate this
|
||||||
setting with the current OS locale. This setting is persisted across restarts.
|
setting with the current OS locale. This setting is persisted across restarts.
|
||||||
|
|
||||||
**Note:** On macOS the OS spellchecker is used and has its own list of languages. On macOS, this API will return whichever languages have been configured by the OS.
|
> [!NOTE]
|
||||||
|
> On macOS, the OS spellchecker is used and has its own list of languages. On macOS, this API will return whichever languages have been configured by the OS.
|
||||||
|
|
||||||
#### `ses.setSpellCheckerDictionaryDownloadURL(url)`
|
#### `ses.setSpellCheckerDictionaryDownloadURL(url)`
|
||||||
|
|
||||||
@@ -1460,7 +1464,8 @@ If the files present in `hunspell_dictionaries.zip` are available at `https://ex
|
|||||||
then you should call this api with `ses.setSpellCheckerDictionaryDownloadURL('https://example.com/dictionaries/')`. Please
|
then you should call this api with `ses.setSpellCheckerDictionaryDownloadURL('https://example.com/dictionaries/')`. Please
|
||||||
note the trailing slash. The URL to the dictionaries is formed as `${url}${filename}`.
|
note the trailing slash. The URL to the dictionaries is formed as `${url}${filename}`.
|
||||||
|
|
||||||
**Note:** On macOS the OS spellchecker is used and therefore we do not download any dictionary files. This API is a no-op on macOS.
|
> [!NOTE]
|
||||||
|
> On macOS, the OS spellchecker is used and therefore we do not download any dictionary files. This API is a no-op on macOS.
|
||||||
|
|
||||||
#### `ses.listWordsInSpellCheckerDictionary()`
|
#### `ses.listWordsInSpellCheckerDictionary()`
|
||||||
|
|
||||||
@@ -1474,7 +1479,8 @@ Resolves when the full dictionary is loaded from disk.
|
|||||||
Returns `boolean` - Whether the word was successfully written to the custom dictionary. This API
|
Returns `boolean` - Whether the word was successfully written to the custom dictionary. This API
|
||||||
will not work on non-persistent (in-memory) sessions.
|
will not work on non-persistent (in-memory) sessions.
|
||||||
|
|
||||||
**Note:** On macOS and Windows 10 this word will be written to the OS custom dictionary as well
|
> [!NOTE]
|
||||||
|
> On macOS and Windows, this word will be written to the OS custom dictionary as well.
|
||||||
|
|
||||||
#### `ses.removeWordFromSpellCheckerDictionary(word)`
|
#### `ses.removeWordFromSpellCheckerDictionary(word)`
|
||||||
|
|
||||||
@@ -1483,7 +1489,8 @@ will not work on non-persistent (in-memory) sessions.
|
|||||||
Returns `boolean` - Whether the word was successfully removed from the custom dictionary. This API
|
Returns `boolean` - Whether the word was successfully removed from the custom dictionary. This API
|
||||||
will not work on non-persistent (in-memory) sessions.
|
will not work on non-persistent (in-memory) sessions.
|
||||||
|
|
||||||
**Note:** On macOS and Windows 10 this word will be removed from the OS custom dictionary as well
|
> [!NOTE]
|
||||||
|
> On macOS and Windows, this word will be removed from the OS custom dictionary as well.
|
||||||
|
|
||||||
#### `ses.loadExtension(path[, options])` _Deprecated_
|
#### `ses.loadExtension(path[, options])` _Deprecated_
|
||||||
|
|
||||||
@@ -1526,11 +1533,13 @@ app.whenReady().then(async () => {
|
|||||||
|
|
||||||
This API does not support loading packed (.crx) extensions.
|
This API does not support loading packed (.crx) extensions.
|
||||||
|
|
||||||
**Note:** This API cannot be called before the `ready` event of the `app` module
|
> [!NOTE]
|
||||||
is emitted.
|
> This API cannot be called before the `ready` event of the `app` module
|
||||||
|
> is emitted.
|
||||||
|
|
||||||
**Note:** Loading extensions into in-memory (non-persistent) sessions is not
|
> [!NOTE]
|
||||||
supported and will throw an error.
|
> Loading extensions into in-memory (non-persistent) sessions is not
|
||||||
|
> supported and will throw an error.
|
||||||
|
|
||||||
**Deprecated:** Use the new `ses.extensions.loadExtension` API.
|
**Deprecated:** Use the new `ses.extensions.loadExtension` API.
|
||||||
|
|
||||||
@@ -1540,8 +1549,9 @@ supported and will throw an error.
|
|||||||
|
|
||||||
Unloads an extension.
|
Unloads an extension.
|
||||||
|
|
||||||
**Note:** This API cannot be called before the `ready` event of the `app` module
|
> [!NOTE]
|
||||||
is emitted.
|
> This API cannot be called before the `ready` event of the `app` module
|
||||||
|
> is emitted.
|
||||||
|
|
||||||
**Deprecated:** Use the new `ses.extensions.removeExtension` API.
|
**Deprecated:** Use the new `ses.extensions.removeExtension` API.
|
||||||
|
|
||||||
@@ -1551,8 +1561,9 @@ is emitted.
|
|||||||
|
|
||||||
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
|
> [!NOTE]
|
||||||
is emitted.
|
> This API cannot be called before the `ready` event of the `app` module
|
||||||
|
> is emitted.
|
||||||
|
|
||||||
**Deprecated:** Use the new `ses.extensions.getExtension` API.
|
**Deprecated:** Use the new `ses.extensions.getExtension` API.
|
||||||
|
|
||||||
@@ -1560,8 +1571,9 @@ is emitted.
|
|||||||
|
|
||||||
Returns `Extension[]` - A list of all loaded extensions.
|
Returns `Extension[]` - A list of all loaded extensions.
|
||||||
|
|
||||||
**Note:** This API cannot be called before the `ready` event of the `app` module
|
> [!NOTE]
|
||||||
is emitted.
|
> This API cannot be called before the `ready` event of the `app` module
|
||||||
|
> is emitted.
|
||||||
|
|
||||||
**Deprecated:** Use the new `ses.extensions.getAllExtensions` API.
|
**Deprecated:** Use the new `ses.extensions.getAllExtensions` API.
|
||||||
|
|
||||||
@@ -1599,9 +1611,11 @@ Clears various different types of data.
|
|||||||
This method clears more types of data and is more thorough than the
|
This method clears more types of data and is more thorough than the
|
||||||
`clearStorageData` method.
|
`clearStorageData` method.
|
||||||
|
|
||||||
**Note:** Cookies are stored at a broader scope than origins. When removing cookies and filtering by `origins` (or `excludeOrigins`), the cookies will be removed at the [registrable domain](https://url.spec.whatwg.org/#host-registrable-domain) level. For example, clearing cookies for the origin `https://really.specific.origin.example.com/` will end up clearing all cookies for `example.com`. Clearing cookies for the origin `https://my.website.example.co.uk/` will end up clearing all cookies for `example.co.uk`.
|
> [!NOTE]
|
||||||
|
> Cookies are stored at a broader scope than origins. When removing cookies and filtering by `origins` (or `excludeOrigins`), the cookies will be removed at the [registrable domain](https://url.spec.whatwg.org/#host-registrable-domain) level. For example, clearing cookies for the origin `https://really.specific.origin.example.com/` will end up clearing all cookies for `example.com`. Clearing cookies for the origin `https://my.website.example.co.uk/` will end up clearing all cookies for `example.co.uk`.
|
||||||
|
|
||||||
**Note:** Clearing cache data will also clear the shared dictionary cache. This means that any dictionaries used for compression may be reloaded after clearing the cache. If you wish to clear the shared dictionary cache but leave other cached data intact, you may want to use the `clearSharedDictionaryCache` method.
|
> [!NOTE]
|
||||||
|
> Clearing cache data will also clear the shared dictionary cache. This means that any dictionaries used for compression may be reloaded after clearing the cache. If you wish to clear the shared dictionary cache but leave other cached data intact, you may want to use the `clearSharedDictionaryCache` method.
|
||||||
|
|
||||||
For more information, refer to Chromium's [`BrowsingDataRemover` interface][browsing-data-remover].
|
For more information, refer to Chromium's [`BrowsingDataRemover` interface][browsing-data-remover].
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,10 @@ For including the share menu as a submenu of other menus, please use the
|
|||||||
|
|
||||||
Process: [Main](../glossary.md#main-process)
|
Process: [Main](../glossary.md#main-process)
|
||||||
|
|
||||||
|
> [!WARNING]
|
||||||
|
> Electron's built-in classes cannot be subclassed in user code.
|
||||||
|
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
|
||||||
|
|
||||||
### `new ShareMenu(sharingItem)`
|
### `new ShareMenu(sharingItem)`
|
||||||
|
|
||||||
* `sharingItem` SharingItem - The item to share.
|
* `sharingItem` SharingItem - The item to share.
|
||||||
|
|||||||
@@ -14,7 +14,8 @@ const { shell } = require('electron')
|
|||||||
shell.openExternal('https://github.com')
|
shell.openExternal('https://github.com')
|
||||||
```
|
```
|
||||||
|
|
||||||
**Note:** While the `shell` module can be used in the renderer process, it will not function in a sandboxed renderer.
|
> [!WARNING]
|
||||||
|
> While the `shell` module can be used in the renderer process, it will not function in a sandboxed renderer.
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
|
|
||||||
|
|||||||
@@ -58,8 +58,8 @@
|
|||||||
`false` on macOS. This option is not configurable on other platforms.
|
`false` on macOS. This option is not configurable on other platforms.
|
||||||
* `disableAutoHideCursor` boolean (optional) - Whether to hide cursor when typing.
|
* `disableAutoHideCursor` boolean (optional) - Whether to hide cursor when typing.
|
||||||
Default is `false`.
|
Default is `false`.
|
||||||
* `autoHideMenuBar` boolean (optional) - Auto hide the menu bar unless the `Alt`
|
* `autoHideMenuBar` boolean (optional) _Linux_ _Windows_ - Auto hide the menu bar
|
||||||
key is pressed. Default is `false`.
|
unless the `Alt` key is pressed. Default is `false`.
|
||||||
* `enableLargerThanScreen` boolean (optional) _macOS_ - Enable the window to
|
* `enableLargerThanScreen` boolean (optional) _macOS_ - Enable the window to
|
||||||
be resized larger than screen. Only relevant for macOS, as other OSes
|
be resized larger than screen. Only relevant for macOS, as other OSes
|
||||||
allow larger-than-screen windows by default. Default is `false`.
|
allow larger-than-screen windows by default. Default is `false`.
|
||||||
@@ -93,8 +93,9 @@
|
|||||||
**Note:** This option is currently experimental.
|
**Note:** This option is currently experimental.
|
||||||
* `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`.
|
* `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_ _Linux_ - The CSS color of the Window Controls Overlay when enabled. Default is the system color.
|
* `color` String (optional) _Windows_ _Linux_ - 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.
|
* `symbolColor` String (optional) _Windows_ _Linux_ - The CSS color of the symbols on the Window Controls Overlay when enabled. Default is the system color.
|
||||||
* `height` Integer (optional) - The height of the title bar and Window Controls Overlay in pixels. Default is system height.
|
* `height` Integer (optional) - The height of the title bar and Window Controls Overlay in pixels. Default is system height.
|
||||||
|
* `accentColor` boolean | string (optional) _Windows_ - The accent color for the window. By default, follows user preference in System Settings. Set to `false` to explicitly disable, or set the color in Hex, RGB, RGBA, HSL, HSLA or named CSS color format. Alpha values will be ignored.
|
||||||
* `trafficLightPosition` [Point](point.md) (optional) _macOS_ -
|
* `trafficLightPosition` [Point](point.md) (optional) _macOS_ -
|
||||||
Set a custom position for the traffic light buttons in frameless windows.
|
Set a custom position for the traffic light buttons in frameless windows.
|
||||||
* `roundedCorners` boolean (optional) _macOS_ _Windows_ - Whether frameless window
|
* `roundedCorners` boolean (optional) _macOS_ _Windows_ - Whether frameless window
|
||||||
|
|||||||
@@ -6,3 +6,11 @@
|
|||||||
* `productId` Integer - The USB product ID.
|
* `productId` Integer - The USB product ID.
|
||||||
* `serialNumber` string (optional) - The USB device serial number.
|
* `serialNumber` string (optional) - The USB device serial number.
|
||||||
* `guid` string (optional) - Unique identifier for the HID interface. A device may have multiple HID interfaces.
|
* `guid` string (optional) - Unique identifier for the HID interface. A device may have multiple HID interfaces.
|
||||||
|
* `collections` Object[] - an array of report formats. See [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/API/HIDDevice/collections) for more.
|
||||||
|
* `usage` Integer - An integer representing the usage ID component of the HID usage associated with this collection.
|
||||||
|
* `usagePage` Integer - An integer representing the usage page component of the HID usage associated with this collection.
|
||||||
|
* `type` Integer - An 8-bit value representing the collection type, which describes a different relationship between the grouped items.
|
||||||
|
* `children` Object[] - An array of sub-collections which takes the same format as a top-level collection.
|
||||||
|
* `inputReports` Object[] - An array of inputReport items which represent individual input reports described in this collection.
|
||||||
|
* `outputReports` Object[] - An array of outputReport items which represent individual output reports described in this collection.
|
||||||
|
* `featureReports` Object[] - An array of featureReport items which represent individual feature reports described in this collection.
|
||||||
|
|||||||
@@ -12,6 +12,6 @@
|
|||||||
`pointerDown`, `pointerUp`, `pointerMove`, `pointerRawUpdate`,
|
`pointerDown`, `pointerUp`, `pointerMove`, `pointerRawUpdate`,
|
||||||
`pointerCancel` or `pointerCausedUaAction`.
|
`pointerCancel` or `pointerCausedUaAction`.
|
||||||
* `modifiers` string[] (optional) - An array of modifiers of the event, can
|
* `modifiers` string[] (optional) - An array of modifiers of the event, can
|
||||||
be `shift`, `control`, `ctrl`, `alt`, `meta`, `command`, `cmd`, `isKeypad`,
|
be `shift`, `control`, `ctrl`, `alt`, `meta`, `command`, `cmd`, `iskeypad`,
|
||||||
`isAutoRepeat`, `leftButtonDown`, `middleButtonDown`, `rightButtonDown`,
|
`isautorepeat`, `leftbuttondown`, `middlebuttondown`, `rightbuttondown`,
|
||||||
`capsLock`, `numLock`, `left`, `right`.
|
`capslock`, `numlock`, `left`, `right`.
|
||||||
|
|||||||
@@ -15,11 +15,13 @@
|
|||||||
* `items` JumpListItem[] (optional) - Array of [`JumpListItem`](jump-list-item.md) objects if `type` is `tasks` or
|
* `items` JumpListItem[] (optional) - Array of [`JumpListItem`](jump-list-item.md) objects if `type` is `tasks` or
|
||||||
`custom`, otherwise it should be omitted.
|
`custom`, otherwise it should be omitted.
|
||||||
|
|
||||||
**Note:** If a `JumpListCategory` object has neither the `type` nor the `name`
|
> [!NOTE]
|
||||||
property set then its `type` is assumed to be `tasks`. If the `name` property
|
> If a `JumpListCategory` object has neither the `type` nor the `name`
|
||||||
is set but the `type` property is omitted then the `type` is assumed to be
|
> property set then its `type` is assumed to be `tasks`. If the `name` property
|
||||||
`custom`.
|
> is set but the `type` property is omitted then the `type` is assumed to be
|
||||||
|
> `custom`.
|
||||||
|
|
||||||
**Note:** The maximum length of a Jump List item's `description` property is
|
> [!NOTE]
|
||||||
260 characters. Beyond this limit, the item will not be added to the Jump
|
> The maximum length of a Jump List item's `description` property is
|
||||||
List, nor will it be displayed.
|
> 260 characters. Beyond this limit, the item will not be added to the Jump
|
||||||
|
> List, nor will it be displayed.
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
* `x` number
|
* `x` number
|
||||||
* `y` number
|
* `y` number
|
||||||
|
|
||||||
**Note:** Both `x` and `y` must be whole integers, when providing a point object
|
> [!NOTE]
|
||||||
as input to an Electron API we will automatically round your `x` and `y` values
|
> Both `x` and `y` must be whole integers, when providing a point object
|
||||||
to the nearest whole integer.
|
> as input to an Electron API we will automatically round your `x` and `y` values
|
||||||
|
> to the nearest whole integer.
|
||||||
|
|||||||
@@ -149,6 +149,7 @@
|
|||||||
`WebContents` when the preferred size changes. Default is `false`.
|
`WebContents` when the preferred size changes. Default is `false`.
|
||||||
* `transparent` boolean (optional) - Whether to enable background transparency for the guest page. Default is `true`. **Note:** The guest page's text and background colors are derived from the [color scheme](https://developer.mozilla.org/en-US/docs/Web/CSS/color-scheme) of its root element. When transparency is enabled, the text color will still change accordingly but the background will remain transparent.
|
* `transparent` boolean (optional) - Whether to enable background transparency for the guest page. Default is `true`. **Note:** The guest page's text and background colors are derived from the [color scheme](https://developer.mozilla.org/en-US/docs/Web/CSS/color-scheme) of its root element. When transparency is enabled, the text color will still change accordingly but the background will remain transparent.
|
||||||
* `enableDeprecatedPaste` boolean (optional) _Deprecated_ - Whether to enable the `paste` [execCommand](https://developer.mozilla.org/en-US/docs/Web/API/Document/execCommand). Default is `false`.
|
* `enableDeprecatedPaste` boolean (optional) _Deprecated_ - Whether to enable the `paste` [execCommand](https://developer.mozilla.org/en-US/docs/Web/API/Document/execCommand). Default is `false`.
|
||||||
|
* `enableCornerSmoothingCSS` boolean (optional) _Experimental_ - Whether the [`-electron-corner-smoothing` CSS rule](../corner-smoothing-css.md) is enabled. Default is `true`.
|
||||||
|
|
||||||
[chrome-content-scripts]: https://developer.chrome.com/extensions/content_scripts#execution-environment
|
[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
|
[runtime-enabled-features]: https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/platform/runtime_enabled_features.json5
|
||||||
|
|||||||
@@ -4,8 +4,9 @@
|
|||||||
> from Chromium at the space indicated by the proxy. By default, this proxy is added
|
> from Chromium at the space indicated by the proxy. By default, this proxy is added
|
||||||
> to each TouchBar at the end of the input. For more information, see the AppKit docs on
|
> to each TouchBar at the end of the input. For more information, see the AppKit docs on
|
||||||
> [NSTouchBarItemIdentifierOtherItemsProxy](https://developer.apple.com/documentation/appkit/nstouchbaritemidentifierotheritemsproxy)
|
> [NSTouchBarItemIdentifierOtherItemsProxy](https://developer.apple.com/documentation/appkit/nstouchbaritemidentifierotheritemsproxy)
|
||||||
>
|
|
||||||
> Note: Only one instance of this class can be added per TouchBar.
|
> [!NOTE]
|
||||||
|
> Only one instance of this class can be added per TouchBar.
|
||||||
|
|
||||||
Process: [Main](../glossary.md#main-process)<br />
|
Process: [Main](../glossary.md#main-process)<br />
|
||||||
_This class is not exported from the `'electron'` module. It is only available as a return value of other methods in the Electron API._
|
_This class is not exported from the `'electron'` module. It is only available as a return value of other methods in the Electron API._
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
# TouchBar
|
# TouchBar
|
||||||
|
|
||||||
|
> [!WARNING]
|
||||||
|
> Electron's built-in classes cannot be subclassed in user code.
|
||||||
|
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
|
||||||
|
|
||||||
## Class: TouchBar
|
## Class: TouchBar
|
||||||
|
|
||||||
> Create TouchBar layouts for native macOS applications
|
> Create TouchBar layouts for native macOS applications
|
||||||
@@ -15,12 +19,14 @@ Process: [Main](../glossary.md#main-process)
|
|||||||
Creates a new touch bar with the specified items. Use
|
Creates a new touch bar with the specified items. Use
|
||||||
`BrowserWindow.setTouchBar` to add the `TouchBar` to a window.
|
`BrowserWindow.setTouchBar` to add the `TouchBar` to a window.
|
||||||
|
|
||||||
**Note:** The TouchBar API is currently experimental and may change or be
|
> [!NOTE]
|
||||||
removed in future Electron releases.
|
> The TouchBar API is currently experimental and may change or be
|
||||||
|
> removed in future Electron releases.
|
||||||
|
|
||||||
**Tip:** If you don't have a MacBook with Touch Bar, you can use
|
> [!TIP]
|
||||||
[Touch Bar Simulator](https://github.com/sindresorhus/touch-bar-simulator)
|
> If you don't have a MacBook with Touch Bar, you can use
|
||||||
to test Touch Bar usage in your app.
|
> [Touch Bar Simulator](https://github.com/sindresorhus/touch-bar-simulator)
|
||||||
|
> to test Touch Bar usage in your app.
|
||||||
|
|
||||||
### Static Properties
|
### Static Properties
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,10 @@ app.whenReady().then(() => {
|
|||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
|
> [!WARNING]
|
||||||
|
> Electron's built-in classes cannot be subclassed in user code.
|
||||||
|
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
|
||||||
|
|
||||||
**Platform Considerations**
|
**Platform Considerations**
|
||||||
|
|
||||||
**Linux**
|
**Linux**
|
||||||
@@ -176,7 +180,8 @@ Returns:
|
|||||||
|
|
||||||
Emitted when the mouse is released from clicking the tray icon.
|
Emitted when the mouse is released from clicking the tray icon.
|
||||||
|
|
||||||
Note: This will not be emitted if you have set a context menu for your Tray using `tray.setContextMenu`, as a result of macOS-level constraints.
|
> [!NOTE]
|
||||||
|
> This will not be emitted if you have set a context menu for your Tray using `tray.setContextMenu`, as a result of macOS-level constraints.
|
||||||
|
|
||||||
#### Event: 'mouse-down' _macOS_
|
#### Event: 'mouse-down' _macOS_
|
||||||
|
|
||||||
@@ -238,7 +243,7 @@ Sets the `image` associated with this tray icon when pressed on macOS.
|
|||||||
|
|
||||||
* `toolTip` string
|
* `toolTip` string
|
||||||
|
|
||||||
Sets the hover text for this tray icon.
|
Sets the hover text for this tray icon. Setting the text to an empty string will remove the tooltip.
|
||||||
|
|
||||||
#### `tray.setTitle(title[, options])` _macOS_
|
#### `tray.setTitle(title[, options])` _macOS_
|
||||||
|
|
||||||
|
|||||||
@@ -44,6 +44,9 @@ Process: [Main](../glossary.md#main-process)<br />
|
|||||||
|
|
||||||
Returns [`UtilityProcess`](utility-process.md#class-utilityprocess)
|
Returns [`UtilityProcess`](utility-process.md#class-utilityprocess)
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
|
> `utilityProcess.fork` can only be called after the `ready` event has been emitted on `App`.
|
||||||
|
|
||||||
## Class: UtilityProcess
|
## Class: UtilityProcess
|
||||||
|
|
||||||
> Instances of the `UtilityProcess` represent the Chromium spawned child process
|
> Instances of the `UtilityProcess` represent the Chromium spawned child process
|
||||||
@@ -106,7 +109,8 @@ child.on('exit', () => {
|
|||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
**Note:** You can use the `pid` to determine if the process is currently running.
|
> [!NOTE]
|
||||||
|
> You can use the `pid` to determine if the process is currently running.
|
||||||
|
|
||||||
#### `child.stdout`
|
#### `child.stdout`
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,10 @@ Process: [Main](../glossary.md#main-process)
|
|||||||
|
|
||||||
`View` is an [EventEmitter][event-emitter].
|
`View` is an [EventEmitter][event-emitter].
|
||||||
|
|
||||||
|
> [!WARNING]
|
||||||
|
> Electron's built-in classes cannot be subclassed in user code.
|
||||||
|
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
|
||||||
|
|
||||||
### `new View()`
|
### `new View()`
|
||||||
|
|
||||||
Creates a new `View`.
|
Creates a new `View`.
|
||||||
@@ -94,13 +98,15 @@ Examples of valid `color` values:
|
|||||||
* Similar to CSS Color Module Level 3 keywords, but case-sensitive.
|
* Similar to CSS Color Module Level 3 keywords, but case-sensitive.
|
||||||
* e.g. `blueviolet` or `red`
|
* e.g. `blueviolet` or `red`
|
||||||
|
|
||||||
**Note:** Hex format with alpha takes `AARRGGBB` or `ARGB`, _not_ `RRGGBBAA` or `RGB`.
|
> [!NOTE]
|
||||||
|
> Hex format with alpha takes `AARRGGBB` or `ARGB`, _not_ `RRGGBBAA` or `RGB`.
|
||||||
|
|
||||||
#### `view.setBorderRadius(radius)`
|
#### `view.setBorderRadius(radius)`
|
||||||
|
|
||||||
* `radius` Integer - Border radius size in pixels.
|
* `radius` Integer - Border radius size in pixels.
|
||||||
|
|
||||||
**Note:** The area cutout of the view's border still captures clicks.
|
> [!NOTE]
|
||||||
|
> The area cutout of the view's border still captures clicks.
|
||||||
|
|
||||||
#### `view.setVisible(visible)`
|
#### `view.setVisible(visible)`
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,10 @@ Process: [Main](../glossary.md#main-process)
|
|||||||
|
|
||||||
`WebContentsView` is an [EventEmitter][event-emitter].
|
`WebContentsView` is an [EventEmitter][event-emitter].
|
||||||
|
|
||||||
|
> [!WARNING]
|
||||||
|
> Electron's built-in classes cannot be subclassed in user code.
|
||||||
|
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
|
||||||
|
|
||||||
### `new WebContentsView([options])`
|
### `new WebContentsView([options])`
|
||||||
|
|
||||||
* `options` Object (optional)
|
* `options` Object (optional)
|
||||||
|
|||||||
@@ -463,7 +463,8 @@ win.webContents.on('will-prevent-unload', (event) => {
|
|||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
**Note:** This will be emitted for `BrowserViews` but will _not_ be respected - this is because we have chosen not to tie the `BrowserView` lifecycle to its owning BrowserWindow should one exist per the [specification](https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeunload_event).
|
> [!NOTE]
|
||||||
|
> This will be emitted for `BrowserViews` but will _not_ be respected - this is because we have chosen not to tie the `BrowserView` lifecycle to its owning BrowserWindow should one exist per the [specification](https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeunload_event).
|
||||||
|
|
||||||
#### Event: 'render-process-gone'
|
#### Event: 'render-process-gone'
|
||||||
|
|
||||||
@@ -533,14 +534,55 @@ To only prevent the menu shortcuts, use
|
|||||||
[`setIgnoreMenuShortcuts`](#contentssetignoremenushortcutsignore):
|
[`setIgnoreMenuShortcuts`](#contentssetignoremenushortcutsignore):
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const { BrowserWindow } = require('electron')
|
const { app, BrowserWindow } = require('electron')
|
||||||
|
|
||||||
const win = new BrowserWindow({ width: 800, height: 600 })
|
app.whenReady().then(() => {
|
||||||
|
const win = new BrowserWindow({ width: 800, height: 600 })
|
||||||
|
|
||||||
win.webContents.on('before-input-event', (event, input) => {
|
win.webContents.on('before-input-event', (event, input) => {
|
||||||
// For example, only enable application menu keyboard shortcuts when
|
// Enable application menu keyboard shortcuts when Ctrl/Cmd are down.
|
||||||
// Ctrl/Cmd are down.
|
win.webContents.setIgnoreMenuShortcuts(!input.control && !input.meta)
|
||||||
win.webContents.setIgnoreMenuShortcuts(!input.control && !input.meta)
|
})
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Event: 'before-mouse-event'
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
* `event` Event
|
||||||
|
* `mouse` [MouseInputEvent](structures/mouse-input-event.md)
|
||||||
|
|
||||||
|
Emitted before dispatching mouse events in the page.
|
||||||
|
|
||||||
|
Calling `event.preventDefault` will prevent the page mouse events.
|
||||||
|
|
||||||
|
```js
|
||||||
|
const { app, BrowserWindow } = require('electron')
|
||||||
|
|
||||||
|
app.whenReady().then(() => {
|
||||||
|
const win = new BrowserWindow({ width: 800, height: 600 })
|
||||||
|
|
||||||
|
win.webContents.on('before-mouse-event', (event, mouse) => {
|
||||||
|
// Prevent mouseDown events.
|
||||||
|
if (mouse.type === 'mouseDown') {
|
||||||
|
console.log(mouse)
|
||||||
|
/*
|
||||||
|
{
|
||||||
|
type: 'mouseDown',
|
||||||
|
clickCount: 1,
|
||||||
|
movementX: 0,
|
||||||
|
movementY: 0,
|
||||||
|
button: 'left',
|
||||||
|
x: 632.359375,
|
||||||
|
y: 480.6875,
|
||||||
|
globalX: 168.359375,
|
||||||
|
globalY: 193.6875
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
event.preventDefault()
|
||||||
|
}
|
||||||
|
})
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -838,9 +880,10 @@ Emitted when a bluetooth device needs to be selected when a call to
|
|||||||
the `deviceId` of the device to be selected. Passing an empty string to
|
the `deviceId` of the device to be selected. Passing an empty string to
|
||||||
`callback` will cancel the request.
|
`callback` will cancel the request.
|
||||||
|
|
||||||
If an event listener is not added for this event, or if `event.preventDefault`
|
If no event listener is added for this event, all bluetooth requests will be cancelled.
|
||||||
is not called when handling this event, the first available device will be
|
|
||||||
automatically selected.
|
If `event.preventDefault` is not called when handling this event, the first available
|
||||||
|
device will be automatically selected.
|
||||||
|
|
||||||
Due to the nature of bluetooth, scanning for devices when
|
Due to the nature of bluetooth, scanning for devices when
|
||||||
`navigator.bluetooth.requestDevice` is called may take time and will cause
|
`navigator.bluetooth.requestDevice` is called may take time and will cause
|
||||||
@@ -887,7 +930,7 @@ const { BrowserWindow } = require('electron')
|
|||||||
|
|
||||||
const win = new BrowserWindow({ webPreferences: { offscreen: true } })
|
const win = new BrowserWindow({ webPreferences: { offscreen: true } })
|
||||||
win.webContents.on('paint', (event, dirty, image) => {
|
win.webContents.on('paint', (event, dirty, image) => {
|
||||||
// updateBitmap(dirty, image.getBitmap())
|
// updateBitmap(dirty, image.toBitmap())
|
||||||
})
|
})
|
||||||
win.loadURL('https://github.com')
|
win.loadURL('https://github.com')
|
||||||
```
|
```
|
||||||
@@ -1491,7 +1534,8 @@ increment above or below represents zooming 20% larger or smaller to default
|
|||||||
limits of 300% and 50% of original size, respectively. The formula for this is
|
limits of 300% and 50% of original size, respectively. The formula for this is
|
||||||
`scale := 1.2 ^ level`.
|
`scale := 1.2 ^ level`.
|
||||||
|
|
||||||
> **NOTE**: The zoom policy at the Chromium level is same-origin, meaning that the
|
> [!NOTE]
|
||||||
|
> The zoom policy at the Chromium level is same-origin, meaning that the
|
||||||
> zoom level for a specific domain propagates across all instances of windows with
|
> zoom level for a specific domain propagates across all instances of windows with
|
||||||
> the same domain. Differentiating the window URLs will make zoom work per-window.
|
> the same domain. Differentiating the window URLs will make zoom work per-window.
|
||||||
|
|
||||||
@@ -1508,7 +1552,8 @@ Returns `Promise<void>`
|
|||||||
|
|
||||||
Sets the maximum and minimum pinch-to-zoom level.
|
Sets the maximum and minimum pinch-to-zoom level.
|
||||||
|
|
||||||
> **NOTE**: Visual zoom is disabled by default in Electron. To re-enable it, call:
|
> [!NOTE]
|
||||||
|
> Visual zoom is disabled by default in Electron. To re-enable it, call:
|
||||||
>
|
>
|
||||||
> ```js
|
> ```js
|
||||||
> const win = new BrowserWindow()
|
> const win = new BrowserWindow()
|
||||||
@@ -2076,7 +2121,9 @@ Disable device emulation enabled by `webContents.enableDeviceEmulation`.
|
|||||||
* `inputEvent` [MouseInputEvent](structures/mouse-input-event.md) | [MouseWheelInputEvent](structures/mouse-wheel-input-event.md) | [KeyboardInputEvent](structures/keyboard-input-event.md)
|
* `inputEvent` [MouseInputEvent](structures/mouse-input-event.md) | [MouseWheelInputEvent](structures/mouse-wheel-input-event.md) | [KeyboardInputEvent](structures/keyboard-input-event.md)
|
||||||
|
|
||||||
Sends an input `event` to the page.
|
Sends an input `event` to the page.
|
||||||
**Note:** The [`BrowserWindow`](browser-window.md) containing the contents needs to be focused for
|
|
||||||
|
> [!NOTE]
|
||||||
|
> The [`BrowserWindow`](browser-window.md) containing the contents needs to be focused for
|
||||||
`sendInputEvent()` to work.
|
`sendInputEvent()` to work.
|
||||||
|
|
||||||
#### `contents.beginFrameSubscription([onlyDirty ,]callback)`
|
#### `contents.beginFrameSubscription([onlyDirty ,]callback)`
|
||||||
@@ -2218,7 +2265,9 @@ By default this value is `{ min: 0, max: 0 }` , which would apply no restriction
|
|||||||
* `max` Integer - The maximum UDP port number that WebRTC should use.
|
* `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.
|
Setting the WebRTC UDP Port Range allows you to restrict the udp port range used by WebRTC. By default the port range is unrestricted.
|
||||||
**Note:** To reset to an unrestricted port range this value should be set to `{ min: 0, max: 0 }`.
|
|
||||||
|
> [!NOTE]
|
||||||
|
> To reset to an unrestricted port range this value should be set to `{ min: 0, max: 0 }`.
|
||||||
|
|
||||||
#### `contents.getMediaSourceId(requestWebContents)`
|
#### `contents.getMediaSourceId(requestWebContents)`
|
||||||
|
|
||||||
@@ -2364,8 +2413,9 @@ A [`WebContents`](web-contents.md) instance that might own this `WebContents`.
|
|||||||
|
|
||||||
A `WebContents | null` property that represents the of DevTools `WebContents` associated with a given `WebContents`.
|
A `WebContents | null` property that represents the of DevTools `WebContents` associated with a given `WebContents`.
|
||||||
|
|
||||||
**Note:** Users should never store this object because it may become `null`
|
> [!NOTE]
|
||||||
when the DevTools has been closed.
|
> Users should never store this object because it may become `null`
|
||||||
|
> when the DevTools has been closed.
|
||||||
|
|
||||||
#### `contents.debugger` _Readonly_
|
#### `contents.debugger` _Readonly_
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,8 @@ Changes the zoom level to the specified level. The original size is 0 and each
|
|||||||
increment above or below represents zooming 20% larger or smaller to default
|
increment above or below represents zooming 20% larger or smaller to default
|
||||||
limits of 300% and 50% of original size, respectively.
|
limits of 300% and 50% of original size, respectively.
|
||||||
|
|
||||||
> **NOTE**: The zoom policy at the Chromium level is same-origin, meaning that the
|
> [!NOTE]
|
||||||
|
> The zoom policy at the Chromium level is same-origin, meaning that the
|
||||||
> zoom level for a specific domain propagates across all instances of windows with
|
> zoom level for a specific domain propagates across all instances of windows with
|
||||||
> the same domain. Differentiating the window URLs will make zoom work per-window.
|
> the same domain. Differentiating the window URLs will make zoom work per-window.
|
||||||
|
|
||||||
@@ -56,13 +57,15 @@ Returns `number` - The current zoom level.
|
|||||||
|
|
||||||
Sets the maximum and minimum pinch-to-zoom level.
|
Sets the maximum and minimum pinch-to-zoom level.
|
||||||
|
|
||||||
> **NOTE**: Visual zoom is disabled by default in Electron. To re-enable it, call:
|
> [!NOTE]
|
||||||
|
> Visual zoom is disabled by default in Electron. To re-enable it, call:
|
||||||
>
|
>
|
||||||
> ```js
|
> ```js
|
||||||
> webFrame.setVisualZoomLevelLimits(1, 3)
|
> webFrame.setVisualZoomLevelLimits(1, 3)
|
||||||
> ```
|
> ```
|
||||||
|
|
||||||
> **NOTE**: Visual zoom only applies to pinch-to-zoom behavior. Cmd+/-/0 zoom shortcuts are
|
> [!NOTE]
|
||||||
|
> Visual zoom only applies to pinch-to-zoom behavior. Cmd+/-/0 zoom shortcuts are
|
||||||
> controlled by the 'zoomIn', 'zoomOut', and 'resetZoom' MenuItem roles in the application
|
> controlled by the 'zoomIn', 'zoomOut', and 'resetZoom' MenuItem roles in the application
|
||||||
> Menu. To disable shortcuts, manually [define the Menu](./menu.md#examples) and omit zoom roles
|
> Menu. To disable shortcuts, manually [define the Menu](./menu.md#examples) and omit zoom roles
|
||||||
> from the definition.
|
> from the definition.
|
||||||
@@ -189,7 +192,9 @@ dispatch errors of isolated worlds to foreign worlds.
|
|||||||
* `name` string (optional) - Name for isolated world. Useful in devtools.
|
* `name` string (optional) - Name for isolated world. Useful in devtools.
|
||||||
|
|
||||||
Set the security origin, content security policy and name of the isolated world.
|
Set the security origin, content security policy and name of the isolated world.
|
||||||
Note: If the `csp` is specified, then the `securityOrigin` also has to be specified.
|
|
||||||
|
> [!NOTE]
|
||||||
|
> If the `csp` is specified, then the `securityOrigin` also has to be specified.
|
||||||
|
|
||||||
### `webFrame.getResourceUsage()`
|
### `webFrame.getResourceUsage()`
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ Returns `string` - The file system path that this `File` object points to. In th
|
|||||||
|
|
||||||
This method superseded the previous augmentation to the `File` object with the `path` property. An example is included below.
|
This method superseded the previous augmentation to the `File` object with the `path` property. An example is included below.
|
||||||
|
|
||||||
```js
|
```js @ts-nocheck
|
||||||
// Before
|
// Before
|
||||||
const oldPath = document.querySelector('input').files[0].path
|
const oldPath = document.querySelector('input').files[0].path
|
||||||
|
|
||||||
|
|||||||
@@ -30,8 +30,10 @@ rendered.
|
|||||||
Unlike an `iframe`, the `webview` runs in a separate process than your
|
Unlike an `iframe`, the `webview` runs in a separate process than your
|
||||||
app. It doesn't have the same permissions as your web page and all interactions
|
app. It doesn't have the same permissions as your web page and all interactions
|
||||||
between your app and embedded content will be asynchronous. This keeps your app
|
between your app and embedded content will be asynchronous. This keeps your app
|
||||||
safe from the embedded content. **Note:** Most methods called on the
|
safe from the embedded content.
|
||||||
webview from the host page require a synchronous call to the main process.
|
|
||||||
|
> [!NOTE]
|
||||||
|
> Most methods called on the webview from the host page require a synchronous call to the main process.
|
||||||
|
|
||||||
## Example
|
## Example
|
||||||
|
|
||||||
@@ -252,7 +254,8 @@ The full list of supported feature strings can be found in the
|
|||||||
|
|
||||||
The `webview` tag has the following methods:
|
The `webview` tag has the following methods:
|
||||||
|
|
||||||
**Note:** The webview element must be loaded before using the methods.
|
> [!NOTE]
|
||||||
|
> The webview element must be loaded before using the methods.
|
||||||
|
|
||||||
**Example**
|
**Example**
|
||||||
|
|
||||||
@@ -679,7 +682,8 @@ increment above or below represents zooming 20% larger or smaller to default
|
|||||||
limits of 300% and 50% of original size, respectively. The formula for this is
|
limits of 300% and 50% of original size, respectively. The formula for this is
|
||||||
`scale := 1.2 ^ level`.
|
`scale := 1.2 ^ level`.
|
||||||
|
|
||||||
> **NOTE**: The zoom policy at the Chromium level is same-origin, meaning that the
|
> [!NOTE]
|
||||||
|
> The zoom policy at the Chromium level is same-origin, meaning that the
|
||||||
> zoom level for a specific domain propagates across all instances of windows with
|
> zoom level for a specific domain propagates across all instances of windows with
|
||||||
> the same domain. Differentiating the window URLs will make zoom work per-window.
|
> the same domain. Differentiating the window URLs will make zoom work per-window.
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,34 @@ This document uses the following convention to categorize breaking changes:
|
|||||||
* **Deprecated:** An API was marked as deprecated. The API will continue to function, but will emit a deprecation warning, and will be removed in a future release.
|
* **Deprecated:** An API was marked as deprecated. The API will continue to function, but will emit a deprecation warning, and will be removed in a future release.
|
||||||
* **Removed:** An API or feature was removed, and is no longer supported by Electron.
|
* **Removed:** An API or feature was removed, and is no longer supported by Electron.
|
||||||
|
|
||||||
|
## Planned Breaking API Changes (37.0)
|
||||||
|
|
||||||
|
### Behavior Changed: `BrowserWindow.IsVisibleOnAllWorkspaces()` on Linux
|
||||||
|
|
||||||
|
`BrowserWindow.IsVisibleOnAllWorkspaces()` will now return false on Linux if the
|
||||||
|
window is not currently visible.
|
||||||
|
|
||||||
|
### Behavior Changes: `app.commandLine`
|
||||||
|
|
||||||
|
`app.commandLine` will convert upper-cases switches and arguments to lowercase.
|
||||||
|
|
||||||
|
`app.commandLine` was only meant to handle chromium switches (which aren't case-sensitive) and switches passed via `app.commandLine` will not be passed down to any of the child processes.
|
||||||
|
|
||||||
|
If you were using `app.commandLine` to control the behavior of the main process, you should do this via `process.argv`.
|
||||||
|
|
||||||
|
### Deprecated: `NativeImage.getBitmap()`
|
||||||
|
|
||||||
|
`NativeImage.toBitmap()` returns a newly-allocated copy of the bitmap. `NativeImage.getBitmap()` was originally an alternative function that returned the original instead of a copy. This changed when sandboxing was introduced, so both return a copy and are functionally equivalent.
|
||||||
|
|
||||||
|
Client code should call `NativeImage.toBitmap()` instead:
|
||||||
|
|
||||||
|
```js
|
||||||
|
// Deprecated
|
||||||
|
bitmap = image.getBitmap()
|
||||||
|
// Use this instead
|
||||||
|
bitmap = image.toBitmap()
|
||||||
|
```
|
||||||
|
|
||||||
## Planned Breaking API Changes (36.0)
|
## Planned Breaking API Changes (36.0)
|
||||||
|
|
||||||
### Removed:`isDefault` and `status` properties on `PrinterInfo`
|
### Removed:`isDefault` and `status` properties on `PrinterInfo`
|
||||||
@@ -19,6 +47,29 @@ This document uses the following convention to categorize breaking changes:
|
|||||||
These properties have been removed from the PrinterInfo Object
|
These properties have been removed from the PrinterInfo Object
|
||||||
because they have been removed from upstream Chromium.
|
because they have been removed from upstream Chromium.
|
||||||
|
|
||||||
|
### Removed: `quota` type `syncable` in `Session.clearStorageData(options)`
|
||||||
|
|
||||||
|
When calling `Session.clearStorageData(options)`, the `options.quota` type
|
||||||
|
`syncable` is no longer supported because it has been
|
||||||
|
[removed](https://chromium-review.googlesource.com/c/chromium/src/+/6309405)
|
||||||
|
from upstream Chromium.
|
||||||
|
|
||||||
|
### Deprecated: `quota` property in `Session.clearStorageData(options)`
|
||||||
|
|
||||||
|
When calling `Session.clearStorageData(options)`, the `options.quota`
|
||||||
|
property is deprecated. Since the `syncable` type was removed, there
|
||||||
|
is only type left -- `'temporary'` -- so specifying it is unnecessary.
|
||||||
|
|
||||||
|
### Deprecated: `null` value for `session` property in `ProtocolResponse`
|
||||||
|
|
||||||
|
Previously, setting the ProtocolResponse.session property to `null`
|
||||||
|
Would create a random independent session. This is no longer supported.
|
||||||
|
|
||||||
|
Using single-purpose sessions here is discouraged due to overhead costs;
|
||||||
|
however, old code that needs to preserve this behavior can emulate it by
|
||||||
|
creating a random session with `session.fromPartition(some_random_string)`
|
||||||
|
and then using it in `ProtocolResponse.session`.
|
||||||
|
|
||||||
### Deprecated: Extension methods and events on `session`
|
### Deprecated: Extension methods and events on `session`
|
||||||
|
|
||||||
`session.loadExtension`, `session.removeExtension`, `session.getExtension`,
|
`session.loadExtension`, `session.removeExtension`, `session.getExtension`,
|
||||||
@@ -33,6 +84,24 @@ It has been always returning `true` since Electron 23, which only supports Windo
|
|||||||
|
|
||||||
https://learn.microsoft.com/en-us/windows/win32/dwm/composition-ovw#disabling-dwm-composition-windows7-and-earlier
|
https://learn.microsoft.com/en-us/windows/win32/dwm/composition-ovw#disabling-dwm-composition-windows7-and-earlier
|
||||||
|
|
||||||
|
### Changed: GTK 4 is default when running GNOME
|
||||||
|
|
||||||
|
After an [upstream change](https://chromium-review.googlesource.com/c/chromium/src/+/6310469), GTK 4 is now the default when running GNOME.
|
||||||
|
|
||||||
|
In rare cases, this may cause some applications or configurations to [error](https://github.com/electron/electron/issues/46538) with the following message:
|
||||||
|
|
||||||
|
```stderr
|
||||||
|
Gtk-ERROR **: 11:30:38.382: GTK 2/3 symbols detected. Using GTK 2/3 and GTK 4 in the same process is not supported
|
||||||
|
```
|
||||||
|
|
||||||
|
Affected users can work around this by specifying the `gtk-version` command-line flag:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
$ electron --gtk-version=3 # or --gtk-version=2
|
||||||
|
```
|
||||||
|
|
||||||
|
The same can be done with the [`app.commandLine.appendSwitch`](https://www.electronjs.org/docs/latest/api/command-line#commandlineappendswitchswitch-value) function.
|
||||||
|
|
||||||
## Planned Breaking API Changes (35.0)
|
## Planned Breaking API Changes (35.0)
|
||||||
|
|
||||||
### Behavior Changed: Dialog API's `defaultPath` option on Linux
|
### Behavior Changed: Dialog API's `defaultPath` option on Linux
|
||||||
@@ -41,7 +110,7 @@ On Linux, the required portal version for file dialogs has been reverted
|
|||||||
to 3 from 4. Using the `defaultPath` option of the Dialog API is not
|
to 3 from 4. Using the `defaultPath` option of the Dialog API is not
|
||||||
supported when using portal file chooser dialogs unless the portal
|
supported when using portal file chooser dialogs unless the portal
|
||||||
backend is version 4 or higher. The `--xdg-portal-required-version`
|
backend is version 4 or higher. The `--xdg-portal-required-version`
|
||||||
[command-line switch](/api/command-line-switches.md#--xdg-portal-required-versionversion)
|
[command-line switch](api/command-line-switches.md#--xdg-portal-required-versionversion)
|
||||||
can be used to force a required version for your application.
|
can be used to force a required version for your application.
|
||||||
See [#44426](https://github.com/electron/electron/pull/44426) for more details.
|
See [#44426](https://github.com/electron/electron/pull/44426) for more details.
|
||||||
|
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ Verify that the Pull Request is correct and make a corresponding entry in the
|
|||||||
API History:
|
API History:
|
||||||
|
|
||||||
> [!NOTE]
|
> [!NOTE]
|
||||||
> Refer to the [API History section of `styleguide.md`](../styleguide.md#api-history)
|
> Refer to the [API History section of `style-guide.md`](./style-guide.md#api-history)
|
||||||
for information on how to create API History blocks.
|
for information on how to create API History blocks.
|
||||||
|
|
||||||
`````markdown
|
`````markdown
|
||||||
|
|||||||
@@ -155,7 +155,8 @@ $ gn gen out/Release --args="import(\"//electron/build/args/release.gn\")"
|
|||||||
$ gn gen out/Release --args="import(\`"//electron/build/args/release.gn\`")"
|
$ gn gen out/Release --args="import(\`"//electron/build/args/release.gn\`")"
|
||||||
```
|
```
|
||||||
|
|
||||||
**Note:** This will generate a `out/Testing` or `out/Release` build directory under `src/` with the testing or release build depending upon the configuration passed above. You can replace `Testing|Release` with another names, but it should be a subdirectory of `out`.
|
> [!NOTE]
|
||||||
|
> This will generate a `out/Testing` or `out/Release` build directory under `src/` with the testing or release build depending upon the configuration passed above. You can replace `Testing|Release` with another names, but it should be a subdirectory of `out`.
|
||||||
|
|
||||||
Also you shouldn't have to run `gn gen` again—if you want to change the build arguments, you can run `gn args out/Testing` to bring up an editor. To see the list of available build configuration options, run `gn args out/Testing --list`.
|
Also you shouldn't have to run `gn gen` again—if you want to change the build arguments, you can run `gn args out/Testing` to bring up an editor. To see the list of available build configuration options, run `gn args out/Testing --list`.
|
||||||
|
|
||||||
|
|||||||
@@ -7,11 +7,8 @@ Follow the guidelines below for building **Electron itself** on Linux, for the p
|
|||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
* At least 25GB disk space and 8GB RAM.
|
* At least 25GB disk space and 8GB RAM.
|
||||||
* Python >= 3.7.
|
* Python >= 3.9.
|
||||||
* Node.js. There are various ways to install Node. You can download
|
* [Node.js](https://nodejs.org/download/) >= 22.12.0
|
||||||
source code from [nodejs.org](https://nodejs.org) and compile it.
|
|
||||||
Doing so permits installing Node on your own home directory as a standard user.
|
|
||||||
Or try repositories such as [NodeSource](https://nodesource.com/blog/nodejs-v012-iojs-and-the-nodesource-linux-repositories).
|
|
||||||
* [clang](https://clang.llvm.org/get_started.html) 3.4 or later.
|
* [clang](https://clang.llvm.org/get_started.html) 3.4 or later.
|
||||||
* Development headers of GTK 3 and libnotify.
|
* Development headers of GTK 3 and libnotify.
|
||||||
|
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ Follow the guidelines below for building **Electron itself** on macOS, for the p
|
|||||||
* [Xcode](https://developer.apple.com/technologies/tools/). The exact version
|
* [Xcode](https://developer.apple.com/technologies/tools/). The exact version
|
||||||
needed depends on what branch you are building, but the latest version of
|
needed depends on what branch you are building, but the latest version of
|
||||||
Xcode is generally a good bet for building `main`.
|
Xcode is generally a good bet for building `main`.
|
||||||
* [node.js](https://nodejs.org) (external)
|
* Python >= 3.9
|
||||||
* Python >= 3.7
|
* [Node.js](https://nodejs.org/download/) >= 22.12.0
|
||||||
|
|
||||||
### Arm64-specific prerequisites
|
### Arm64-specific prerequisites
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ Follow the guidelines below for building **Electron itself** on Windows, for the
|
|||||||
set a few environment variables to point the toolchains to your installation path.
|
set a few environment variables to point the toolchains to your installation path.
|
||||||
* `vs2022_install = DRIVE:\path\to\Microsoft Visual Studio\2022\Community`, replacing `2022` and `Community` with your installed versions and replacing `DRIVE:` with the drive that Visual Studio is on. Often, this will be `C:`.
|
* `vs2022_install = DRIVE:\path\to\Microsoft Visual Studio\2022\Community`, replacing `2022` and `Community` with your installed versions and replacing `DRIVE:` with the drive that Visual Studio is on. Often, this will be `C:`.
|
||||||
* `WINDOWSSDKDIR = DRIVE:\path\to\Windows Kits\10`, replacing `DRIVE:` with the drive that Windows Kits is on. Often, this will be `C:`.
|
* `WINDOWSSDKDIR = DRIVE:\path\to\Windows Kits\10`, replacing `DRIVE:` with the drive that Windows Kits is on. Often, this will be `C:`.
|
||||||
* [Node.js](https://nodejs.org/download/)
|
* [Node.js](https://nodejs.org/download/) >= 22.12.0
|
||||||
* [Git](https://git-scm.com)
|
* [Git](https://git-scm.com)
|
||||||
* Debugging Tools for Windows of Windows SDK 10.0.15063.468 if you plan on
|
* Debugging Tools for Windows of Windows SDK 10.0.15063.468 if you plan on
|
||||||
creating a full distribution since `symstore.exe` is used for creating a symbol
|
creating a full distribution since `symstore.exe` is used for creating a symbol
|
||||||
@@ -39,8 +39,9 @@ Building Electron is done entirely with command-line scripts and cannot be done
|
|||||||
with Visual Studio. You can develop Electron with any editor but support for
|
with Visual Studio. You can develop Electron with any editor but support for
|
||||||
building with Visual Studio will come in the future.
|
building with Visual Studio will come in the future.
|
||||||
|
|
||||||
**Note:** Even though Visual Studio is not used for building, it's still
|
> [!NOTE]
|
||||||
**required** because we need the build toolchains it provides.
|
> Even though Visual Studio is not used for building, it's still
|
||||||
|
> **required** because we need the build toolchains it provides.
|
||||||
|
|
||||||
## Exclude source tree from Windows Security
|
## Exclude source tree from Windows Security
|
||||||
|
|
||||||
|
|||||||
@@ -148,7 +148,8 @@ In your [`shell/common/node_bindings.cc`](https://github.com/electron/electron/b
|
|||||||
V(electron_browser_{api_name})
|
V(electron_browser_{api_name})
|
||||||
```
|
```
|
||||||
|
|
||||||
> Note: More technical details on how Node links with Electron can be found on [our blog](https://www.electronjs.org/blog/electron-internals-using-node-as-a-library#link-node-with-electron).
|
> [!NOTE]
|
||||||
|
> More technical details on how Node links with Electron can be found on [our blog](https://www.electronjs.org/blog/electron-internals-using-node-as-a-library#link-node-with-electron).
|
||||||
|
|
||||||
## Expose your API to TypeScript
|
## Expose your API to TypeScript
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,8 @@ $ git commit
|
|||||||
$ ../../electron/script/git-export-patches -o ../../electron/patches/node
|
$ ../../electron/script/git-export-patches -o ../../electron/patches/node
|
||||||
```
|
```
|
||||||
|
|
||||||
> **NOTE**: `git-export-patches` ignores any uncommitted files, so you must create a commit if you want your changes to be exported. The subject line of the commit message will be used to derive the patch file name, and the body of the commit message should include the reason for the patch's existence.
|
> [!NOTE]
|
||||||
|
> `git-export-patches` ignores any uncommitted files, so you must create a commit if you want your changes to be exported. The subject line of the commit message will be used to derive the patch file name, and the body of the commit message should include the reason for the patch's existence.
|
||||||
|
|
||||||
Re-exporting patches will sometimes cause shasums in unrelated patches to change. This is generally harmless and can be ignored (but go ahead and add those changes to your PR, it'll stop them from showing up for other people).
|
Re-exporting patches will sometimes cause shasums in unrelated patches to change. This is generally harmless and can be ignored (but go ahead and add those changes to your PR, it'll stop them from showing up for other people).
|
||||||
|
|
||||||
|
|||||||
@@ -195,7 +195,7 @@ required[, optional]
|
|||||||
More detailed information on each of the arguments is noted in an unordered list
|
More detailed information on each of the arguments is noted in an unordered list
|
||||||
below the method. The type of argument is notated by either JavaScript primitives
|
below the method. The type of argument is notated by either JavaScript primitives
|
||||||
(e.g. `string`, `Promise`, or `Object`), a custom API structure like Electron's
|
(e.g. `string`, `Promise`, or `Object`), a custom API structure like Electron's
|
||||||
[`Cookie`](api/structures/cookie.md), or the wildcard `any`.
|
[`Cookie`](../api/structures/cookie.md), or the wildcard `any`.
|
||||||
|
|
||||||
If the argument is of type `Array`, use `[]` shorthand with the type of value
|
If the argument is of type `Array`, use `[]` shorthand with the type of value
|
||||||
inside the array (for example,`any[]` or `string[]`).
|
inside the array (for example,`any[]` or `string[]`).
|
||||||
@@ -290,7 +290,7 @@ The purpose of the API History block is to describe when/where/how/why an API wa
|
|||||||
Each API change listed in the block should include a link to the
|
Each API change listed in the block should include a link to the
|
||||||
PR where that change was made along with an optional short description of the
|
PR where that change was made along with an optional short description of the
|
||||||
change. If applicable, include the [heading id](https://gist.github.com/asabaylus/3071099)
|
change. If applicable, include the [heading id](https://gist.github.com/asabaylus/3071099)
|
||||||
for that change from the [breaking changes documentation](./breaking-changes.md).
|
for that change from the [breaking changes documentation](../breaking-changes.md).
|
||||||
|
|
||||||
The [API History linting script][api-history-linting-script] (`lint:api-history`)
|
The [API History linting script][api-history-linting-script] (`lint:api-history`)
|
||||||
validates API History blocks in the Electron documentation against the schema and
|
validates API History blocks in the Electron documentation against the schema and
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user