mirror of
https://github.com/electron/electron.git
synced 2026-02-19 03:14:51 -05:00
Compare commits
147 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
045200d662 | ||
|
|
f62d7254c4 | ||
|
|
c7aa0b537d | ||
|
|
048d620701 | ||
|
|
15cdae1cf0 | ||
|
|
bac383c219 | ||
|
|
49eb165ef9 | ||
|
|
a468ed7f10 | ||
|
|
5444738721 | ||
|
|
a6959ca97b | ||
|
|
45353ae38c | ||
|
|
f702327dce | ||
|
|
fda3a3d493 | ||
|
|
dae5dad167 | ||
|
|
940ebb6c7a | ||
|
|
793565e4be | ||
|
|
1f322ebce3 | ||
|
|
f009e077f2 | ||
|
|
fed73040e2 | ||
|
|
828fd59a72 | ||
|
|
e892840975 | ||
|
|
7373173e44 | ||
|
|
5d5e672f17 | ||
|
|
e39943bf45 | ||
|
|
f331606e07 | ||
|
|
cca55117e4 | ||
|
|
bf29d2f0bd | ||
|
|
fea1a2a987 | ||
|
|
a51c56aca9 | ||
|
|
89f25e6af3 | ||
|
|
e0db4046b2 | ||
|
|
3b9130d815 | ||
|
|
52ed4646d9 | ||
|
|
68098c317f | ||
|
|
52e0307cc1 | ||
|
|
7fffe77909 | ||
|
|
3ccb1bc0a8 | ||
|
|
0917ed5f6f | ||
|
|
a67aad0f50 | ||
|
|
ceb6d28fd3 | ||
|
|
e12ab6708e | ||
|
|
6101025368 | ||
|
|
97b0280ad4 | ||
|
|
1044fe675d | ||
|
|
42af60cc7e | ||
|
|
cadba11088 | ||
|
|
8aeee3f714 | ||
|
|
dd54e84a58 | ||
|
|
d4b7d9e9cf | ||
|
|
83a5ba1e2c | ||
|
|
13d955a73e | ||
|
|
fdf29ce838 | ||
|
|
3770bb31a7 | ||
|
|
ed4a99ba5b | ||
|
|
0e6c26096f | ||
|
|
7792ed1efa | ||
|
|
c75c390ccf | ||
|
|
4c3c3049e1 | ||
|
|
68e7b38c05 | ||
|
|
a051c7c274 | ||
|
|
53003d7af9 | ||
|
|
63d7f609cd | ||
|
|
01291623af | ||
|
|
13ed526ca7 | ||
|
|
afb0ee418c | ||
|
|
55d8b71d72 | ||
|
|
b9ceaabb85 | ||
|
|
d6c0691a63 | ||
|
|
a201d6c541 | ||
|
|
51add3e847 | ||
|
|
9dcdec5015 | ||
|
|
095e622a6a | ||
|
|
a0d983e4b5 | ||
|
|
f49a645c06 | ||
|
|
8ab5ac9069 | ||
|
|
27a8cc531b | ||
|
|
26ffc8505c | ||
|
|
3b0f35a7e8 | ||
|
|
8769d5ba9e | ||
|
|
7f8b7c3873 | ||
|
|
8bf4260e3e | ||
|
|
7a13c6f175 | ||
|
|
678fb400fd | ||
|
|
8806499904 | ||
|
|
637a504e28 | ||
|
|
40cdfdb1d1 | ||
|
|
4ca10a1056 | ||
|
|
9d05454dc7 | ||
|
|
0e862bba61 | ||
|
|
4232ed2814 | ||
|
|
e7683bdd25 | ||
|
|
bdaf3b9a2b | ||
|
|
5c98e3609f | ||
|
|
2cfccac074 | ||
|
|
03aad28412 | ||
|
|
25e2459f31 | ||
|
|
18af498cf1 | ||
|
|
9f43503b3e | ||
|
|
ecb1eb0b5d | ||
|
|
2c916cfa33 | ||
|
|
4c9ab8765b | ||
|
|
051f78dd1d | ||
|
|
c796a74467 | ||
|
|
0d0cbaf7b4 | ||
|
|
63c452dcc7 | ||
|
|
f6407b4949 | ||
|
|
06d7a51a58 | ||
|
|
2255bb620a | ||
|
|
084c6ef549 | ||
|
|
01faaa30ea | ||
|
|
c569d5e4ba | ||
|
|
670da27305 | ||
|
|
5f901174c5 | ||
|
|
b39a1fb877 | ||
|
|
2156ccb577 | ||
|
|
9e2f7065a0 | ||
|
|
51bfe07da9 | ||
|
|
4699761649 | ||
|
|
26e1bda335 | ||
|
|
cf871bce4e | ||
|
|
39cca586f6 | ||
|
|
2f4a070c39 | ||
|
|
2b098408a8 | ||
|
|
fa844268ec | ||
|
|
a29a72c3ab | ||
|
|
4601aeccde | ||
|
|
31b18c9830 | ||
|
|
895bf9103e | ||
|
|
bf51d345c8 | ||
|
|
6eef170d9a | ||
|
|
31725b4a86 | ||
|
|
ec748eb915 | ||
|
|
5feb91e2f4 | ||
|
|
5128ebeddb | ||
|
|
389927dce8 | ||
|
|
67afc10b75 | ||
|
|
f570e6967f | ||
|
|
09ab71de43 | ||
|
|
21b325b034 | ||
|
|
cc9ca4bee2 | ||
|
|
17dba93587 | ||
|
|
603cafad7e | ||
|
|
09f269426e | ||
|
|
3bbb82b42b | ||
|
|
a9504abde9 | ||
|
|
9f3636ffe2 | ||
|
|
4a89068fb7 |
@@ -2,7 +2,7 @@ version: '3'
|
||||
|
||||
services:
|
||||
buildtools:
|
||||
image: ghcr.io/electron/devcontainer:424eedbf277ad9749ffa9219068aa72ed4a5e373
|
||||
image: ghcr.io/electron/devcontainer:933c7d6ff6802706875270bec2e3c891cf8add3f
|
||||
|
||||
volumes:
|
||||
- ..:/workspaces/gclient/src/electron:cached
|
||||
|
||||
@@ -58,13 +58,13 @@ if [ ! -f $buildtools/configs/evm.testing.json ]; then
|
||||
},
|
||||
\"\$schema\": \"file:///home/builduser/.electron_build_tools/evm-config.schema.json\",
|
||||
\"configValidationLevel\": \"strict\",
|
||||
\"reclient\": \"$1\",
|
||||
\"preserveXcode\": 5
|
||||
\"remoteBuild\": \"reclient\",
|
||||
\"preserveSDK\": 5
|
||||
}
|
||||
" >$buildtools/configs/evm.testing.json
|
||||
}
|
||||
|
||||
write_config remote_exec
|
||||
write_config
|
||||
|
||||
e use testing
|
||||
else
|
||||
|
||||
1
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
1
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
@@ -63,6 +63,7 @@ body:
|
||||
label: Does the issue also appear in Chromium / Google Chrome?
|
||||
description: If it does, please report the issue in the [Chromium issue tracker](https://issues.chromium.org/issues), not against Electron. Electron will inherit the fix once Chromium resolves the issue.
|
||||
options:
|
||||
- I don't know how to test
|
||||
- "Yes"
|
||||
- "No"
|
||||
validations:
|
||||
|
||||
84
.github/actions/build-electron/action.yml
vendored
84
.github/actions/build-electron/action.yml
vendored
@@ -17,9 +17,6 @@ inputs:
|
||||
is-release:
|
||||
description: 'Is release build'
|
||||
required: true
|
||||
strip-binaries:
|
||||
description: 'Strip binaries (Linux only)'
|
||||
required: false
|
||||
generate-symbols:
|
||||
description: 'Generate symbols'
|
||||
required: true
|
||||
@@ -38,6 +35,12 @@ runs:
|
||||
run: |
|
||||
GN_APPENDED_ARGS="$GN_EXTRA_ARGS target_cpu=\"x64\" v8_snapshot_toolchain=\"//build/toolchain/mac:clang_x64\""
|
||||
echo "GN_EXTRA_ARGS=$GN_APPENDED_ARGS" >> $GITHUB_ENV
|
||||
- name: Set GN_EXTRA_ARGS for Windows
|
||||
shell: bash
|
||||
if: ${{inputs.target-arch != 'x64' && inputs.target-platform == 'win' }}
|
||||
run: |
|
||||
GN_APPENDED_ARGS="$GN_EXTRA_ARGS target_cpu=\"${{ inputs.target-arch }}\""
|
||||
echo "GN_EXTRA_ARGS=$GN_APPENDED_ARGS" >> $GITHUB_ENV
|
||||
- name: Add Clang problem matcher
|
||||
shell: bash
|
||||
run: echo "::add-matcher::src/electron/.github/problem-matchers/clang.json"
|
||||
@@ -57,22 +60,14 @@ runs:
|
||||
sudo launchctl limit maxfiles 65536 200000
|
||||
fi
|
||||
|
||||
NINJA_SUMMARIZE_BUILD=1 e build -j $NUMBER_OF_NINJA_PROCESSES
|
||||
NINJA_SUMMARIZE_BUILD=1 e build
|
||||
cp out/Default/.ninja_log out/electron_ninja_log
|
||||
node electron/script/check-symlinks.js
|
||||
- name: Strip Electron Binaries ${{ inputs.step-suffix }}
|
||||
shell: bash
|
||||
if: ${{ inputs.strip-binaries == 'true' }}
|
||||
run: |
|
||||
cd src
|
||||
electron/script/copy-debug-symbols.py --target-cpu="${{ inputs.target-arch }}" --out-dir=out/Default/debug --compress
|
||||
electron/script/strip-binaries.py --target-cpu="${{ inputs.target-arch }}" --verbose
|
||||
electron/script/add-debug-link.py --target-cpu="${{ inputs.target-arch }}" --debug-dir=out/Default/debug
|
||||
- name: Build Electron dist.zip ${{ inputs.step-suffix }}
|
||||
shell: bash
|
||||
run: |
|
||||
cd src
|
||||
e build --target electron:electron_dist_zip -j $NUMBER_OF_NINJA_PROCESSES -d explain
|
||||
e build --target electron:electron_dist_zip
|
||||
if [ "${{ inputs.is-asan }}" != "true" ]; then
|
||||
target_os=${{ inputs.target-platform == 'macos' && 'mac' || inputs.target-platform }}
|
||||
if [ "${{ inputs.artifact-platform }}" = "mas" ]; then
|
||||
@@ -84,7 +79,7 @@ runs:
|
||||
shell: bash
|
||||
run: |
|
||||
cd src
|
||||
e build --target electron:electron_mksnapshot -j $NUMBER_OF_NINJA_PROCESSES
|
||||
e build --target electron:electron_mksnapshot
|
||||
ELECTRON_DEPOT_TOOLS_DISABLE_LOG=1 e d gn desc out/Default v8:run_mksnapshot_default args > out/Default/mksnapshot_args
|
||||
# Remove unused args from mksnapshot_args
|
||||
SEDOPTION="-i"
|
||||
@@ -94,20 +89,7 @@ runs:
|
||||
sed $SEDOPTION '/.*builtins-pgo/d' out/Default/mksnapshot_args
|
||||
sed $SEDOPTION '/--turbo-profiling-input/d' out/Default/mksnapshot_args
|
||||
|
||||
if [ "${{ inputs.target-platform }}" = "linux" ]; then
|
||||
if [ "${{ inputs.target-arch }}" = "arm" ]; then
|
||||
electron/script/strip-binaries.py --file $PWD/out/Default/clang_x86_v8_arm/mksnapshot
|
||||
electron/script/strip-binaries.py --file $PWD/out/Default/clang_x86_v8_arm/v8_context_snapshot_generator
|
||||
elif [ "${{ inputs.target-arch }}" = "arm64" ]; then
|
||||
electron/script/strip-binaries.py --file $PWD/out/Default/clang_x64_v8_arm64/mksnapshot
|
||||
electron/script/strip-binaries.py --file $PWD/out/Default/clang_x64_v8_arm64/v8_context_snapshot_generator
|
||||
else
|
||||
electron/script/strip-binaries.py --file $PWD/out/Default/mksnapshot
|
||||
electron/script/strip-binaries.py --file $PWD/out/Default/v8_context_snapshot_generator
|
||||
fi
|
||||
fi
|
||||
|
||||
e build --target electron:electron_mksnapshot_zip -j $NUMBER_OF_NINJA_PROCESSES
|
||||
e build --target electron:electron_mksnapshot_zip
|
||||
if [ "${{ inputs.target-platform }}" = "win" ]; then
|
||||
cd out/Default
|
||||
powershell Compress-Archive -update mksnapshot_args mksnapshot.zip
|
||||
@@ -141,8 +123,16 @@ runs:
|
||||
shell: bash
|
||||
run: |
|
||||
cd src
|
||||
e build --target electron:electron_chromedriver -j $NUMBER_OF_NINJA_PROCESSES
|
||||
e build --target electron:electron_chromedriver
|
||||
e build --target electron:electron_chromedriver_zip
|
||||
|
||||
if [ "${{ inputs.is-asan }}" != "true" ]; then
|
||||
target_os=${{ inputs.target-platform == 'macos' && 'mac' || inputs.target-platform }}
|
||||
if [ "${{ inputs.artifact-platform }}" = "mas" ]; then
|
||||
target_os="${target_os}_mas"
|
||||
fi
|
||||
electron/script/zip_manifests/check-zip-manifest.py out/Default/chromedriver.zip electron/script/zip_manifests/chromedriver_zip.$target_os.${{ inputs.target-arch }}.manifest
|
||||
fi
|
||||
- name: Build Node.js headers ${{ inputs.step-suffix }}
|
||||
shell: bash
|
||||
run: |
|
||||
@@ -188,20 +178,20 @@ runs:
|
||||
if: ${{ inputs.is-release == 'true' }}
|
||||
run: |
|
||||
cd src
|
||||
gn gen out/ffmpeg --args="import(\"//electron/build/args/ffmpeg.gn\") use_remoteexec=true $GN_EXTRA_ARGS"
|
||||
e build --target electron:electron_ffmpeg_zip -C ../../out/ffmpeg -j $NUMBER_OF_NINJA_PROCESSES
|
||||
gn gen out/ffmpeg --args="import(\"//electron/build/args/ffmpeg.gn\") use_remoteexec=true use_siso=true $GN_EXTRA_ARGS"
|
||||
e build --target electron:electron_ffmpeg_zip -C ../../out/ffmpeg
|
||||
- name: Generate Hunspell Dictionaries ${{ inputs.step-suffix }}
|
||||
shell: bash
|
||||
if: ${{ inputs.is-release == 'true' && inputs.target-platform == 'linux' }}
|
||||
run: |
|
||||
e build --target electron:hunspell_dictionaries_zip -j $NUMBER_OF_NINJA_PROCESSES
|
||||
e build --target electron:hunspell_dictionaries_zip
|
||||
- name: Generate Libcxx ${{ inputs.step-suffix }}
|
||||
shell: bash
|
||||
if: ${{ inputs.is-release == 'true' && inputs.target-platform == 'linux' }}
|
||||
run: |
|
||||
e build --target electron:libcxx_headers_zip -j $NUMBER_OF_NINJA_PROCESSES
|
||||
e build --target electron:libcxxabi_headers_zip -j $NUMBER_OF_NINJA_PROCESSES
|
||||
e build --target electron:libcxx_objects_zip -j $NUMBER_OF_NINJA_PROCESSES
|
||||
e build --target electron:libcxx_headers_zip
|
||||
e build --target electron:libcxxabi_headers_zip
|
||||
e build --target electron:libcxx_objects_zip
|
||||
- name: Remove Clang problem matcher
|
||||
shell: bash
|
||||
run: echo "::remove-matcher owner=clang::"
|
||||
@@ -224,7 +214,29 @@ runs:
|
||||
echo 'Uploading Electron release distribution to GitHub releases'
|
||||
script/release/uploaders/upload.py --verbose
|
||||
fi
|
||||
- name: Generate siso report
|
||||
if: ${{ inputs.target-platform != 'win' && !cancelled() }}
|
||||
shell: bash
|
||||
run: |
|
||||
cd src
|
||||
e d siso report -C out/Default > siso_report.txt
|
||||
SISO_REPORT_PATH=$(grep -o '/.*siso-report-[^ ]*' siso_report.txt)
|
||||
echo "SISO_REPORT_PATH=$SISO_REPORT_PATH" >> $GITHUB_ENV
|
||||
cat siso_report.txt
|
||||
echo "SISO REPORT AT $SISO_REPORT_PATH"
|
||||
- name: Generate siso report (Windows)
|
||||
if: ${{ inputs.target-platform == 'win' && !cancelled() }}
|
||||
shell: powershell
|
||||
run: |
|
||||
cd src
|
||||
e d siso report -C out\Default > siso_report.txt
|
||||
$SISO_REPORT_PATH = Get-Content "siso_report.txt" | Select-String "report file:\s*(.+)" | ForEach-Object {
|
||||
$_.Matches.Groups[1].Value.Trim()
|
||||
}
|
||||
echo "SISO_REPORT_PATH=$SISO_REPORT_PATH"
|
||||
echo "SISO_REPORT_PATH=$SISO_REPORT_PATH" >> $env:GITHUB_ENV
|
||||
- name: Generate Artifact Key
|
||||
if: always() && !cancelled()
|
||||
shell: bash
|
||||
run: |
|
||||
if [ "${{ inputs.is-asan }}" = "true" ]; then
|
||||
@@ -236,9 +248,11 @@ runs:
|
||||
# The current generated_artifacts_<< artifact.key >> name was taken from CircleCI
|
||||
# to ensure we don't break anything, but we may be able to improve that.
|
||||
- name: Move all Generated Artifacts to Upload Folder ${{ inputs.step-suffix }}
|
||||
if: always() && !cancelled()
|
||||
shell: bash
|
||||
run: ./src/electron/script/actions/move-artifacts.sh
|
||||
- name: Upload Generated Artifacts ${{ inputs.step-suffix }}
|
||||
if: always() && !cancelled()
|
||||
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808
|
||||
with:
|
||||
name: generated_artifacts_${{ env.ARTIFACT_KEY }}
|
||||
|
||||
2
.github/actions/checkout/action.yml
vendored
2
.github/actions/checkout/action.yml
vendored
@@ -40,7 +40,7 @@ runs:
|
||||
if: ${{ inputs.generate-sas-token == 'true' }}
|
||||
shell: bash
|
||||
run: |
|
||||
curl --unix-socket /var/run/sas/sas.sock --fail "http://foo/$CACHE_FILE?platform=${{ inputs.target-platform }}" > sas-token
|
||||
curl --unix-socket /var/run/sas/sas.sock --fail "http://foo/$CACHE_FILE?platform=${{ inputs.target-platform }}&getAccountName=true" > sas-token
|
||||
- name: Save SAS Key
|
||||
if: ${{ inputs.generate-sas-token == 'true' }}
|
||||
uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
|
||||
|
||||
17
.github/actions/cipd-install/action.yml
vendored
17
.github/actions/cipd-install/action.yml
vendored
@@ -14,6 +14,9 @@ inputs:
|
||||
description: 'Target platform, should be linux, win, macos'
|
||||
package:
|
||||
description: 'Package to install'
|
||||
dependency-version:
|
||||
description: 'Version of the dependency to install'
|
||||
default: ''
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
@@ -22,15 +25,23 @@ runs:
|
||||
run : |
|
||||
rm -rf ${{ inputs.cipd-root-prefix-path }}${{ inputs.installation-dir }}
|
||||
- name: Create ensure file for ${{ inputs.dependency }}
|
||||
if: ${{ inputs.dependency-version == '' }}
|
||||
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' }}
|
||||
|
||||
- name: Create ensure file for ${{ inputs.dependency }} from dependency-version
|
||||
if: ${{ inputs.dependency-version != '' }}
|
||||
shell: bash
|
||||
run: |
|
||||
echo "ensuring ${{ inputs.dependency }} on macOS"
|
||||
echo '${{ inputs.package }} ${{ inputs.dependency-version }}' > ${{ inputs.dependency }}_ensure_file
|
||||
cat ${{ inputs.dependency }}_ensure_file
|
||||
- name: CIPD installation of ${{ inputs.dependency }} (macOS)
|
||||
if: ${{ inputs.target-platform != 'win' }}
|
||||
shell: bash
|
||||
run: |
|
||||
echo "ensuring ${{ inputs.dependency }}"
|
||||
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' }}
|
||||
|
||||
20
.github/actions/fix-sync/action.yml
vendored
20
.github/actions/fix-sync/action.yml
vendored
@@ -19,12 +19,16 @@ inputs:
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: Fix clang
|
||||
- name: Fix llvm toolchain
|
||||
if: ${{ inputs.target-platform != 'linux' }}
|
||||
shell: bash
|
||||
run : |
|
||||
rm -rf src/third_party/llvm-build
|
||||
python3 src/tools/clang/scripts/update.py
|
||||
# Refs https://chromium-review.googlesource.com/c/chromium/src/+/6667681
|
||||
python3 src/tools/clang/scripts/update.py --package objdump
|
||||
- name: Fix esbuild
|
||||
if: ${{ inputs.target-platform != 'linux' }}
|
||||
uses: ./src/electron/.github/actions/cipd-install
|
||||
with:
|
||||
cipd-root-prefix-path: src/third_party/devtools-frontend/src/
|
||||
@@ -34,6 +38,7 @@ runs:
|
||||
target-platform: ${{ inputs.target-platform }}
|
||||
package: infra/3pp/tools/esbuild/${platform}
|
||||
- name: Fix rustc
|
||||
if: ${{ inputs.target-platform != 'linux' }}
|
||||
shell: bash
|
||||
run : |
|
||||
rm -rf src/third_party/rust-toolchain
|
||||
@@ -57,6 +62,7 @@ runs:
|
||||
target-platform: ${{ inputs.target-platform }}
|
||||
package: gn/gn/windows-amd64
|
||||
- name: Fix reclient
|
||||
if: ${{ inputs.target-platform != 'linux' }}
|
||||
uses: ./src/electron/.github/actions/cipd-install
|
||||
with:
|
||||
dependency: reclient
|
||||
@@ -65,6 +71,7 @@ runs:
|
||||
target-platform: ${{ inputs.target-platform }}
|
||||
package: infra/rbe/client/${platform}
|
||||
- name: Configure reclient configs
|
||||
if: ${{ inputs.target-platform != 'linux' }}
|
||||
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
|
||||
@@ -82,6 +89,7 @@ runs:
|
||||
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
|
||||
if: ${{ inputs.target-platform != 'linux' }}
|
||||
uses: ./src/electron/.github/actions/cipd-install
|
||||
with:
|
||||
dependency: ninja
|
||||
@@ -90,10 +98,20 @@ runs:
|
||||
target-platform: ${{ inputs.target-platform }}
|
||||
package: infra/3pp/tools/ninja/${platform}
|
||||
- name: Set ninja in path
|
||||
if: ${{ inputs.target-platform != 'linux' }}
|
||||
shell: bash
|
||||
run : |
|
||||
echo "$(pwd)/src/third_party/ninja" >> $GITHUB_PATH
|
||||
- name: Fix siso
|
||||
uses: ./src/electron/.github/actions/cipd-install
|
||||
with:
|
||||
dependency: siso
|
||||
deps-file: src/DEPS
|
||||
installation-dir: src/third_party/siso/cipd
|
||||
target-platform: ${{ inputs.target-platform }}
|
||||
package: build/siso/${platform}
|
||||
- name: Fixup angle git
|
||||
if: ${{ inputs.target-platform != 'linux' }}
|
||||
shell: bash
|
||||
run : |
|
||||
cd src/third_party/angle
|
||||
|
||||
5
.github/actions/free-space-macos/action.yml
vendored
5
.github/actions/free-space-macos/action.yml
vendored
@@ -6,6 +6,8 @@ runs:
|
||||
- name: Free Space on MacOS
|
||||
shell: bash
|
||||
run: |
|
||||
echo "Disk usage before cleanup:"
|
||||
df -h
|
||||
sudo mkdir -p $TMPDIR/del-target
|
||||
|
||||
tmpify() {
|
||||
@@ -73,4 +75,5 @@ runs:
|
||||
|
||||
# lipo off some huge binaries arm64 versions to save space
|
||||
strip_universal_deep $(xcode-select -p)/../SharedFrameworks
|
||||
# strip_arm_deep /System/Volumes/Data/Library/Developer/CommandLineTools/usr
|
||||
# strip_arm_deep /System/Volumes/Data/Library/Developer/CommandLineTools/usr
|
||||
sudo mdutil -a -i off
|
||||
|
||||
@@ -13,8 +13,9 @@ runs:
|
||||
git config --global core.fscache true
|
||||
git config --global core.longpaths true
|
||||
git config --global core.preloadindex true
|
||||
git config --global core.longpaths true
|
||||
fi
|
||||
export BUILD_TOOLS_SHA=0a7f6bef9453ceee45612442660ca16d2c40171b
|
||||
export BUILD_TOOLS_SHA=c13f4bdb50e65da46a4703f8f882079dd21fd99e
|
||||
npm i -g @electron/build-tools
|
||||
# Update depot_tools to ensure python
|
||||
e d update_depot_tools
|
||||
|
||||
13
.github/actions/restore-cache-azcopy/action.yml
vendored
13
.github/actions/restore-cache-azcopy/action.yml
vendored
@@ -36,18 +36,19 @@ runs:
|
||||
echo "SAS Token not found; exiting src cache download early..."
|
||||
exit 1
|
||||
else
|
||||
sas_token=$(jq -r '.sasToken' sas-token)
|
||||
account_name=$(jq -r '.accountName' sas-token)
|
||||
if [ "${{ inputs.target-platform }}" = "win" ]; then
|
||||
azcopy copy --log-level=ERROR \
|
||||
"https://${{ env.AZURE_AKS_CACHE_STORAGE_ACCOUNT }}.file.core.windows.net/${{ env.AZURE_AKS_WIN_CACHE_SHARE_NAME }}/${{ env.CACHE_PATH }}?$sas_token" $DEPSHASH.tar
|
||||
"https://$account_name.file.core.windows.net/${{ env.AZURE_AKS_WIN_CACHE_SHARE_NAME }}/${{ env.CACHE_PATH }}?$sas_token" $DEPSHASH.tar
|
||||
else
|
||||
azcopy copy --log-level=ERROR \
|
||||
"https://${{ env.AZURE_AKS_CACHE_STORAGE_ACCOUNT }}.file.core.windows.net/${{ env.AZURE_AKS_CACHE_SHARE_NAME }}/${{ env.CACHE_PATH }}?$sas_token" $DEPSHASH.tar
|
||||
"https://$account_name.file.core.windows.net/${{ env.AZURE_AKS_CACHE_SHARE_NAME }}/${{ env.CACHE_PATH }}?$sas_token" $DEPSHASH.tar
|
||||
fi
|
||||
fi
|
||||
env:
|
||||
AZURE_AKS_CACHE_STORAGE_ACCOUNT: f723719aa87a34622b5f7f3
|
||||
AZURE_AKS_CACHE_SHARE_NAME: pvc-f6a4089f-b082-4bee-a3f9-c3e1c0c02d8f
|
||||
AZURE_AKS_WIN_CACHE_SHARE_NAME: pvc-71dec4f2-0d44-4fd1-a2c3-add049d70bdf
|
||||
AZURE_AKS_CACHE_SHARE_NAME: linux-cache
|
||||
AZURE_AKS_WIN_CACHE_SHARE_NAME: windows-cache
|
||||
- name: Clean SAS Key
|
||||
shell: bash
|
||||
run: rm -f sas-token
|
||||
@@ -96,7 +97,7 @@ runs:
|
||||
|
||||
$TEMP_DIR=New-Item -ItemType Directory -Path temp-cache
|
||||
$TEMP_DIR_PATH = $TEMP_DIR.FullName
|
||||
C:\ProgramData\Chocolatey\bin\7z.exe -y -snld x $src_cache -o"$TEMP_DIR_PATH"
|
||||
C:\ProgramData\Chocolatey\bin\7z.exe -y -snld20 x $src_cache -o"$TEMP_DIR_PATH"
|
||||
|
||||
- name: Move Src Cache (Windows)
|
||||
if: ${{ inputs.target-platform == 'win' }}
|
||||
|
||||
20
.github/actions/ssh-debug/action.yml
vendored
Normal file
20
.github/actions/ssh-debug/action.yml
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
name: Debug via SSH
|
||||
description: Setup a SSH server with a tunnel to access it to debug via SSH.
|
||||
inputs:
|
||||
tunnel:
|
||||
description: 'Enable SSH tunneling via cloudflared'
|
||||
required: true
|
||||
default: 'false'
|
||||
timeout:
|
||||
description: 'SSH session timeout in seconds'
|
||||
required: false
|
||||
type: number
|
||||
default: 3600
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- run: $GITHUB_ACTION_PATH/setup-ssh.sh
|
||||
shell: bash
|
||||
env:
|
||||
TUNNEL: ${{ inputs.tunnel }}
|
||||
TIMEOUT: ${{ inputs.timeout }}
|
||||
4
.github/actions/ssh-debug/bashrc
vendored
Normal file
4
.github/actions/ssh-debug/bashrc
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
# If we're in an interactive SSH session and we're not already in tmux and there's no explicit SSH command, auto attach tmux
|
||||
if [ -n "$SSH_TTY" ] && [ -z "$TMUX" ] && [ -z "$SSH_ORIGINAL_COMMAND" ]; then
|
||||
exec tmux attach || exec tmux
|
||||
fi
|
||||
146
.github/actions/ssh-debug/setup-ssh.sh
vendored
Executable file
146
.github/actions/ssh-debug/setup-ssh.sh
vendored
Executable file
@@ -0,0 +1,146 @@
|
||||
#!/bin/bash -e
|
||||
|
||||
if [ "${TUNNEL}" != "true" ]; then
|
||||
echo "SSH tunneling is disabled. Set enable-tunnel: true to enable remote access."
|
||||
echo "Local SSH server would be available on localhost:2222 if this were a local environment."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo ::group::Configuring Tunnel
|
||||
|
||||
echo "SSH tunneling enabled. Setting up remote access..."
|
||||
|
||||
EXTERNAL_DEPS="curl jq ssh-keygen"
|
||||
|
||||
for dep in $EXTERNAL_DEPS; do
|
||||
if ! command -v "${dep}" > /dev/null 2>&1; then
|
||||
echo "Command ${dep} not installed on the system!" >&2
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
cd "$GITHUB_ACTION_PATH"
|
||||
|
||||
bashrc_path=$(pwd)/bashrc
|
||||
|
||||
# Source `bashrc` to auto start tmux on SSH login.
|
||||
if ! grep -q "${bashrc_path}" ~/.bash_profile; then
|
||||
echo >> ~/.bash_profile # On macOS runner there's no newline at the end of the file
|
||||
echo "source \"${bashrc_path}\"" >> ~/.bash_profile
|
||||
fi
|
||||
|
||||
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
|
||||
ARCH=$(uname -m)
|
||||
|
||||
if [ "${ARCH}" = "x86_64" ]; then
|
||||
ARCH="amd64"
|
||||
elif [ "${ARCH}" = "aarch64" ]; then
|
||||
ARCH="arm64"
|
||||
fi
|
||||
|
||||
if [ "${OS}" = "darwin" ] && ! command -v tmux > /dev/null 2>&1; then
|
||||
echo "Installing tmux..."
|
||||
brew install tmux
|
||||
fi
|
||||
|
||||
if [ "$OS" = "darwin" ]; then
|
||||
cloudflared_url="https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-${OS}-${ARCH}.tgz"
|
||||
echo "Downloading \`cloudflared\` from <$cloudflared_url>..."
|
||||
curl --location --silent --output cloudflared.tgz "${cloudflared_url}"
|
||||
tar xf cloudflared.tgz
|
||||
rm cloudflared.tgz
|
||||
fi
|
||||
|
||||
chmod +x cloudflared
|
||||
|
||||
echo 'Creating SSH server key...'
|
||||
ssh-keygen -q -f ssh_host_rsa_key -N ''
|
||||
|
||||
echo 'Creating SSH server config...'
|
||||
sed "s,\$PWD,${PWD},;s,\$USER,${USER}," sshd_config.template > sshd_config
|
||||
|
||||
echo 'Starting SSH server...'
|
||||
sudo /usr/sbin/sshd -f sshd_config -D &
|
||||
sshd_pid=$!
|
||||
|
||||
echo "SSH server started successfully (PID: ${sshd_pid})"
|
||||
|
||||
echo 'Starting tmux session...'
|
||||
(cd "${GITHUB_WORKSPACE}" && tmux new-session -d -s debug)
|
||||
|
||||
mkdir ~/.cloudflared
|
||||
CLEAN_TUNNEL_CERT=$(printf '%s\n' "${CLOUDFLARE_TUNNEL_CERT}" | tr -d '\r' | sed '/^[[:space:]]*$/d')
|
||||
|
||||
echo "${CLEAN_TUNNEL_CERT}" > ~/.cloudflared/cert.pem
|
||||
|
||||
CLEAN_USER_CA_CERT=$(printf '%s\n' "${CLOUDFLARE_USER_CA_CERT}" | tr -d '\r' | sed '/^[[:space:]]*$/d')
|
||||
|
||||
echo "${CLEAN_USER_CA_CERT}" | sudo tee /etc/ssh/ca.pub > /dev/null
|
||||
sudo chmod 644 /etc/ssh/ca.pub
|
||||
|
||||
random_suffix=$(openssl rand -hex 5 | cut -c1-10)
|
||||
tunnel_name="${GITHUB_SHA}-${GITHUB_RUN_ID}-${random_suffix}"
|
||||
tunnel_url="${tunnel_name}.${CLOUDFLARE_TUNNEL_HOSTNAME}"
|
||||
|
||||
if ./cloudflared tunnel list | grep -q "${tunnel_name}"; then
|
||||
echo "Deleting existing tunnel: ${tunnel_name}"
|
||||
./cloudflared tunnel delete ${tunnel_name}
|
||||
fi
|
||||
|
||||
echo "Creating new cloudflare tunnel: ${tunnel_name}"
|
||||
./cloudflared tunnel create ${tunnel_name}
|
||||
|
||||
credentials_file=$(find ~/.cloudflared -name "*.json" | head -n 1)
|
||||
if [ -z "${credentials_file}" ]; then
|
||||
echo "Error: Could not find tunnel credentials file"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Found credentials file: ${credentials_file}"
|
||||
|
||||
echo 'Creating tunnel configuration...'
|
||||
cat > tunnel_config.yml << EOF
|
||||
tunnel: ${tunnel_name}
|
||||
credentials-file: ${credentials_file}
|
||||
|
||||
ingress:
|
||||
- hostname: ${tunnel_url}
|
||||
service: ssh://localhost:2222
|
||||
- service: http_status:404
|
||||
EOF
|
||||
|
||||
echo 'Setting up DNS routing for tunnel...'
|
||||
./cloudflared tunnel route dns ${tunnel_name} ${tunnel_url}
|
||||
|
||||
echo 'Running cloudflare tunnel...'
|
||||
./cloudflared tunnel --no-autoupdate --config tunnel_config.yml run 2>&1 | tee cloudflared.log | sed -u 's/^/cloudflared: /' &
|
||||
cloudflared_pid=$!
|
||||
|
||||
echo ::endgroup::
|
||||
|
||||
echo ::notice title=SSH Debug Session Ready::ssh ${tunnel_url}
|
||||
|
||||
|
||||
(
|
||||
echo ' '
|
||||
echo ' '
|
||||
echo '🔗 SSH Debug Session Ready!'
|
||||
echo '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'
|
||||
echo ' '
|
||||
echo '📋 Infra WG can copy and run this command to connect:'
|
||||
echo ' '
|
||||
echo "ssh ${tunnel_url}"
|
||||
echo ' '
|
||||
echo "⏰ Session expires automatically in ${TIMEOUT} seconds"
|
||||
echo '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'
|
||||
echo ' '
|
||||
echo ' '
|
||||
) | cat
|
||||
|
||||
echo ::group::Starting Background Session
|
||||
echo 'Starting SSH session in background...'
|
||||
./ssh-session.sh "${sshd_pid}" "${cloudflared_pid}" "${TIMEOUT}" "${tunnel_name}" &
|
||||
|
||||
echo 'SSH session is running in background. GitHub Action will continue.'
|
||||
echo 'Session will auto-cleanup after timeout or when processes end.'
|
||||
echo ::endgroup::
|
||||
52
.github/actions/ssh-debug/ssh-session.sh
vendored
Executable file
52
.github/actions/ssh-debug/ssh-session.sh
vendored
Executable file
@@ -0,0 +1,52 @@
|
||||
#!/bin/bash
|
||||
|
||||
SSHD_PID=$1
|
||||
CLOUDFLARED_PID=$2
|
||||
SESSION_TIMEOUT=${3:-10000}
|
||||
TUNNEL_NAME=$4
|
||||
|
||||
cleanup() {
|
||||
# Kill processes.
|
||||
for pid in "$SLEEP_PID" "$SSHD_PID" "$CLOUDFLARED_PID"; do
|
||||
if [ -n "$pid" ] && kill -0 "$pid" 2>/dev/null; then
|
||||
kill "$pid" 2>/dev/null || true
|
||||
fi
|
||||
done
|
||||
|
||||
# Clean up tunnel.
|
||||
if [ -n "$TUNNEL_NAME" ]; then
|
||||
cd "$GITHUB_ACTION_PATH"
|
||||
./cloudflared tunnel delete "$TUNNEL_NAME" 2>/dev/null || {
|
||||
echo "Failed to delete tunnel"
|
||||
}
|
||||
fi
|
||||
|
||||
echo "Session ended at $(date)"
|
||||
exit 0
|
||||
}
|
||||
|
||||
# Trap signals to ensure cleanup.
|
||||
trap cleanup SIGTERM SIGINT SIGQUIT SIGHUP EXIT
|
||||
|
||||
# Wait for timeout or until processes die.
|
||||
sleep "$SESSION_TIMEOUT" &
|
||||
SLEEP_PID=$!
|
||||
|
||||
# Monitor processes
|
||||
while kill -0 "$SLEEP_PID" 2>/dev/null; do
|
||||
# Check SSH daemon.
|
||||
if ! kill -0 "$SSHD_PID" 2>/dev/null; then
|
||||
echo "SSH daemon died at $(date)"
|
||||
break
|
||||
fi
|
||||
|
||||
# Check cloudflared,
|
||||
if ! kill -0 "$CLOUDFLARED_PID" 2>/dev/null; then
|
||||
echo "Cloudflared died at $(date)"
|
||||
break
|
||||
fi
|
||||
|
||||
sleep 10
|
||||
done
|
||||
|
||||
cleanup
|
||||
25
.github/actions/ssh-debug/sshd_config.template
vendored
Normal file
25
.github/actions/ssh-debug/sshd_config.template
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
Port 2222
|
||||
HostKey $PWD/ssh_host_rsa_key
|
||||
PidFile $PWD/sshd.pid
|
||||
|
||||
# Connection settings
|
||||
ClientAliveInterval 30
|
||||
ClientAliveCountMax 10
|
||||
MaxStartups 10
|
||||
LoginGraceTime 120
|
||||
|
||||
# Allow TCP forwarding for tunneling
|
||||
AllowTcpForwarding yes
|
||||
|
||||
# Try to prevent timeouts
|
||||
TCPKeepAlive yes
|
||||
|
||||
# Security
|
||||
TrustedUserCAKeys /etc/ssh/ca.pub
|
||||
PubkeyAuthentication yes
|
||||
PasswordAuthentication no
|
||||
|
||||
AuthorizedPrincipalsCommand /bin/bash -c "echo '%t %k' | ssh-keygen -L -f - | grep -A1 Principals"
|
||||
AuthorizedPrincipalsCommandUser nobody
|
||||
|
||||
PubkeyAcceptedKeyTypes ssh-rsa,ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519-cert-v01@openssh.com,ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,rsa-sha2-256-cert-v01@openssh.com,rsa-sha2-512-cert-v01@openssh.com
|
||||
2
.github/workflows/archaeologist-dig.yml
vendored
2
.github/workflows/archaeologist-dig.yml
vendored
@@ -13,7 +13,7 @@ jobs:
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Setup Node.js/npm
|
||||
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020
|
||||
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444
|
||||
with:
|
||||
node-version: 20.19.x
|
||||
- name: Setting Up Dig Site
|
||||
|
||||
4
.github/workflows/audit-branch-ci.yml
vendored
4
.github/workflows/audit-branch-ci.yml
vendored
@@ -16,7 +16,7 @@ jobs:
|
||||
contents: read
|
||||
steps:
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
||||
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
|
||||
with:
|
||||
node-version: 22.17.x
|
||||
- run: npm install @actions/cache@4.0.3 @electron/fiddle-core@2.0.1
|
||||
@@ -141,7 +141,7 @@ jobs:
|
||||
await core.summary.write();
|
||||
- name: Send Slack message if errors
|
||||
if: ${{ always() && steps.audit-errors.outputs.errorsFound && github.ref == 'refs/heads/main' }}
|
||||
uses: slackapi/slack-github-action@b0fa283ad8fea605de13dc3f449259339835fc52 # v2.1.0
|
||||
uses: slackapi/slack-github-action@91efab103c0de0a537f72a35f6b8cda0ee76bf0a # v2.1.1
|
||||
with:
|
||||
payload: |
|
||||
link: "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
|
||||
|
||||
6
.github/workflows/build-git-cache.yml
vendored
6
.github/workflows/build-git-cache.yml
vendored
@@ -8,7 +8,7 @@ on:
|
||||
|
||||
jobs:
|
||||
build-git-cache-linux:
|
||||
runs-on: electron-arc-linux-amd64-32core
|
||||
runs-on: electron-arc-centralus-linux-amd64-32core
|
||||
container:
|
||||
image: ghcr.io/electron/build:bc2f48b2415a670de18d13605b1cf0eb5fdbaae1
|
||||
options: --user root
|
||||
@@ -29,7 +29,7 @@ jobs:
|
||||
target-platform: linux
|
||||
|
||||
build-git-cache-windows:
|
||||
runs-on: electron-arc-linux-amd64-32core
|
||||
runs-on: electron-arc-centralus-linux-amd64-32core
|
||||
container:
|
||||
image: ghcr.io/electron/build:bc2f48b2415a670de18d13605b1cf0eb5fdbaae1
|
||||
options: --user root --device /dev/fuse --cap-add SYS_ADMIN
|
||||
@@ -51,7 +51,7 @@ jobs:
|
||||
target-platform: win
|
||||
|
||||
build-git-cache-macos:
|
||||
runs-on: electron-arc-linux-amd64-32core
|
||||
runs-on: electron-arc-centralus-linux-amd64-32core
|
||||
# This job updates the same git cache as linux, so it needs to run after the linux one.
|
||||
needs: build-git-cache-linux
|
||||
container:
|
||||
|
||||
60
.github/workflows/build.yml
vendored
60
.github/workflows/build.yml
vendored
@@ -6,7 +6,7 @@ on:
|
||||
build-image-sha:
|
||||
type: string
|
||||
description: 'SHA for electron/build image'
|
||||
default: '424eedbf277ad9749ffa9219068aa72ed4a5e373'
|
||||
default: '933c7d6ff6802706875270bec2e3c891cf8add3f'
|
||||
required: true
|
||||
skip-macos:
|
||||
type: boolean
|
||||
@@ -28,6 +28,11 @@ on:
|
||||
description: 'Skip lint check'
|
||||
default: false
|
||||
required: false
|
||||
enable-ssh:
|
||||
description: 'Enable SSH debugging'
|
||||
required: false
|
||||
type: boolean
|
||||
default: false
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
@@ -64,7 +69,7 @@ jobs:
|
||||
id: set-output
|
||||
run: |
|
||||
if [ -z "${{ inputs.build-image-sha }}" ]; then
|
||||
echo "build-image-sha=424eedbf277ad9749ffa9219068aa72ed4a5e373" >> "$GITHUB_OUTPUT"
|
||||
echo "build-image-sha=933c7d6ff6802706875270bec2e3c891cf8add3f" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "build-image-sha=${{ inputs.build-image-sha }}" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
@@ -81,18 +86,18 @@ jobs:
|
||||
|
||||
# Docs Only Jobs
|
||||
docs-only:
|
||||
needs: setup
|
||||
needs: [setup, checkout-linux]
|
||||
if: ${{ needs.setup.outputs.docs-only == 'true' }}
|
||||
uses: ./.github/workflows/pipeline-electron-docs-only.yml
|
||||
with:
|
||||
container: '{"image":"ghcr.io/electron/build:${{ needs.setup.outputs.build-image-sha }}","options":"--user root"}'
|
||||
container: '{"image":"ghcr.io/electron/build:${{ needs.checkout-linux.outputs.build-image-sha }}","options":"--user root","volumes":["/mnt/cross-instance-cache:/mnt/cross-instance-cache"]}'
|
||||
secrets: inherit
|
||||
|
||||
# Checkout Jobs
|
||||
checkout-macos:
|
||||
needs: setup
|
||||
if: ${{ needs.setup.outputs.src == 'true' && !inputs.skip-macos}}
|
||||
runs-on: electron-arc-linux-amd64-32core
|
||||
runs-on: electron-arc-centralus-linux-amd64-32core
|
||||
container:
|
||||
image: ghcr.io/electron/build:${{ needs.setup.outputs.build-image-sha }}
|
||||
options: --user root
|
||||
@@ -119,8 +124,8 @@ jobs:
|
||||
|
||||
checkout-linux:
|
||||
needs: setup
|
||||
if: ${{ needs.setup.outputs.src == 'true' && !inputs.skip-linux}}
|
||||
runs-on: electron-arc-linux-amd64-32core
|
||||
if: ${{ !inputs.skip-linux}}
|
||||
runs-on: electron-arc-centralus-linux-amd64-32core
|
||||
container:
|
||||
image: ghcr.io/electron/build:${{ needs.setup.outputs.build-image-sha }}
|
||||
options: --user root
|
||||
@@ -149,7 +154,7 @@ jobs:
|
||||
checkout-windows:
|
||||
needs: setup
|
||||
if: ${{ needs.setup.outputs.src == 'true' && !inputs.skip-windows }}
|
||||
runs-on: electron-arc-linux-amd64-32core
|
||||
runs-on: electron-arc-centralus-linux-amd64-32core
|
||||
container:
|
||||
image: ghcr.io/electron/build:${{ needs.setup.outputs.build-image-sha }}
|
||||
options: --user root --device /dev/fuse --cap-add SYS_ADMIN
|
||||
@@ -191,10 +196,11 @@ jobs:
|
||||
linux-gn-check:
|
||||
uses: ./.github/workflows/pipeline-segment-electron-gn-check.yml
|
||||
needs: checkout-linux
|
||||
if: ${{ needs.setup.outputs.src == 'true' }}
|
||||
with:
|
||||
target-platform: linux
|
||||
target-archs: x64 arm arm64
|
||||
check-runs-on: electron-arc-linux-amd64-8core
|
||||
check-runs-on: electron-arc-centralus-linux-amd64-8core
|
||||
check-container: '{"image":"ghcr.io/electron/build:${{ needs.checkout-linux.outputs.build-image-sha }}","options":"--user root","volumes":["/mnt/cross-instance-cache:/mnt/cross-instance-cache"]}'
|
||||
gn-build-type: testing
|
||||
secrets: inherit
|
||||
@@ -205,7 +211,7 @@ jobs:
|
||||
with:
|
||||
target-platform: win
|
||||
target-archs: x64 x86 arm64
|
||||
check-runs-on: electron-arc-linux-amd64-8core
|
||||
check-runs-on: electron-arc-centralus-linux-amd64-8core
|
||||
check-container: '{"image":"ghcr.io/electron/build:${{ needs.checkout-windows.outputs.build-image-sha }}","options":"--user root --device /dev/fuse --cap-add SYS_ADMIN","volumes":["/mnt/win-cache:/mnt/win-cache"]}'
|
||||
gn-build-type: testing
|
||||
secrets: inherit
|
||||
@@ -220,13 +226,14 @@ jobs:
|
||||
needs: checkout-macos
|
||||
with:
|
||||
build-runs-on: macos-14-xlarge
|
||||
test-runs-on: macos-13
|
||||
test-runs-on: macos-15-large
|
||||
target-platform: macos
|
||||
target-arch: x64
|
||||
is-release: false
|
||||
gn-build-type: testing
|
||||
generate-symbols: false
|
||||
upload-to-storage: '0'
|
||||
enable-ssh: ${{ inputs.enable-ssh || false }}
|
||||
secrets: inherit
|
||||
|
||||
macos-arm64:
|
||||
@@ -238,13 +245,14 @@ jobs:
|
||||
needs: checkout-macos
|
||||
with:
|
||||
build-runs-on: macos-14-xlarge
|
||||
test-runs-on: macos-14
|
||||
test-runs-on: macos-15
|
||||
target-platform: macos
|
||||
target-arch: arm64
|
||||
is-release: false
|
||||
gn-build-type: testing
|
||||
generate-symbols: false
|
||||
upload-to-storage: '0'
|
||||
enable-ssh: ${{ inputs.enable-ssh || false }}
|
||||
secrets: inherit
|
||||
|
||||
linux-x64:
|
||||
@@ -254,9 +262,10 @@ jobs:
|
||||
pull-requests: read
|
||||
uses: ./.github/workflows/pipeline-electron-build-and-test-and-nan.yml
|
||||
needs: checkout-linux
|
||||
if: ${{ needs.setup.outputs.src == 'true' }}
|
||||
with:
|
||||
build-runs-on: electron-arc-linux-amd64-32core
|
||||
test-runs-on: electron-arc-linux-amd64-4core
|
||||
build-runs-on: electron-arc-centralus-linux-amd64-32core
|
||||
test-runs-on: electron-arc-centralus-linux-amd64-4core
|
||||
build-container: '{"image":"ghcr.io/electron/build:${{ needs.checkout-linux.outputs.build-image-sha }}","options":"--user root","volumes":["/mnt/cross-instance-cache:/mnt/cross-instance-cache"]}'
|
||||
test-container: '{"image":"ghcr.io/electron/build:${{ needs.checkout-linux.outputs.build-image-sha }}","options":"--user root --privileged --init"}'
|
||||
target-platform: linux
|
||||
@@ -274,9 +283,10 @@ jobs:
|
||||
pull-requests: read
|
||||
uses: ./.github/workflows/pipeline-electron-build-and-test.yml
|
||||
needs: checkout-linux
|
||||
if: ${{ needs.setup.outputs.src == 'true' }}
|
||||
with:
|
||||
build-runs-on: electron-arc-linux-amd64-32core
|
||||
test-runs-on: electron-arc-linux-amd64-4core
|
||||
build-runs-on: electron-arc-centralus-linux-amd64-32core
|
||||
test-runs-on: electron-arc-centralus-linux-amd64-4core
|
||||
build-container: '{"image":"ghcr.io/electron/build:${{ needs.checkout-linux.outputs.build-image-sha }}","options":"--user root","volumes":["/mnt/cross-instance-cache:/mnt/cross-instance-cache"]}'
|
||||
test-container: '{"image":"ghcr.io/electron/build:${{ needs.checkout-linux.outputs.build-image-sha }}","options":"--user root --privileged --init"}'
|
||||
target-platform: linux
|
||||
@@ -295,9 +305,10 @@ jobs:
|
||||
pull-requests: read
|
||||
uses: ./.github/workflows/pipeline-electron-build-and-test.yml
|
||||
needs: checkout-linux
|
||||
if: ${{ needs.setup.outputs.src == 'true' }}
|
||||
with:
|
||||
build-runs-on: electron-arc-linux-amd64-32core
|
||||
test-runs-on: electron-arc-linux-arm64-4core
|
||||
build-runs-on: electron-arc-centralus-linux-amd64-32core
|
||||
test-runs-on: electron-arc-centralus-linux-arm64-4core
|
||||
build-container: '{"image":"ghcr.io/electron/build:${{ needs.checkout-linux.outputs.build-image-sha }}","options":"--user root","volumes":["/mnt/cross-instance-cache:/mnt/cross-instance-cache"]}'
|
||||
test-container: '{"image":"ghcr.io/electron/test:arm32v7-${{ needs.checkout-linux.outputs.build-image-sha }}","options":"--user root --privileged --init","volumes":["/home/runner/externals:/mnt/runner-externals"]}'
|
||||
target-platform: linux
|
||||
@@ -315,9 +326,10 @@ jobs:
|
||||
pull-requests: read
|
||||
uses: ./.github/workflows/pipeline-electron-build-and-test.yml
|
||||
needs: checkout-linux
|
||||
if: ${{ needs.setup.outputs.src == 'true' }}
|
||||
with:
|
||||
build-runs-on: electron-arc-linux-amd64-32core
|
||||
test-runs-on: electron-arc-linux-arm64-4core
|
||||
build-runs-on: electron-arc-centralus-linux-amd64-32core
|
||||
test-runs-on: ubuntu-22.04-arm
|
||||
build-container: '{"image":"ghcr.io/electron/build:${{ needs.checkout-linux.outputs.build-image-sha }}","options":"--user root","volumes":["/mnt/cross-instance-cache:/mnt/cross-instance-cache"]}'
|
||||
test-container: '{"image":"ghcr.io/electron/test:arm64v8-${{ needs.checkout-linux.outputs.build-image-sha }}","options":"--user root --privileged --init"}'
|
||||
target-platform: linux
|
||||
@@ -337,7 +349,7 @@ jobs:
|
||||
needs: checkout-windows
|
||||
if: ${{ needs.setup.outputs.src == 'true' && !inputs.skip-windows }}
|
||||
with:
|
||||
build-runs-on: electron-arc-windows-amd64-16core
|
||||
build-runs-on: electron-arc-centralus-windows-amd64-16core
|
||||
test-runs-on: windows-latest
|
||||
target-platform: win
|
||||
target-arch: x64
|
||||
@@ -356,7 +368,7 @@ jobs:
|
||||
needs: checkout-windows
|
||||
if: ${{ needs.setup.outputs.src == 'true' && !inputs.skip-windows }}
|
||||
with:
|
||||
build-runs-on: electron-arc-windows-amd64-16core
|
||||
build-runs-on: electron-arc-centralus-windows-amd64-16core
|
||||
test-runs-on: windows-latest
|
||||
target-platform: win
|
||||
target-arch: x86
|
||||
@@ -375,8 +387,8 @@ jobs:
|
||||
needs: checkout-windows
|
||||
if: ${{ needs.setup.outputs.src == 'true' && !inputs.skip-windows }}
|
||||
with:
|
||||
build-runs-on: electron-arc-windows-amd64-16core
|
||||
test-runs-on: electron-hosted-windows-arm64-4core
|
||||
build-runs-on: electron-arc-centralus-windows-amd64-16core
|
||||
test-runs-on: windows-11-arm
|
||||
target-platform: win
|
||||
target-arch: arm64
|
||||
is-release: false
|
||||
|
||||
2
.github/workflows/clean-src-cache.yml
vendored
2
.github/workflows/clean-src-cache.yml
vendored
@@ -10,7 +10,7 @@ on:
|
||||
|
||||
jobs:
|
||||
clean-src-cache:
|
||||
runs-on: electron-arc-linux-amd64-32core
|
||||
runs-on: electron-arc-centralus-linux-amd64-32core
|
||||
container:
|
||||
image: ghcr.io/electron/build:bc2f48b2415a670de18d13605b1cf0eb5fdbaae1
|
||||
options: --user root
|
||||
|
||||
11
.github/workflows/issue-commented.yml
vendored
11
.github/workflows/issue-commented.yml
vendored
@@ -10,15 +10,24 @@ permissions: {}
|
||||
jobs:
|
||||
issue-commented:
|
||||
name: Remove blocked/{need-info,need-repro} on comment
|
||||
if: ${{ (contains(github.event.issue.labels.*.name, 'blocked/need-repro') || contains(github.event.issue.labels.*.name, 'blocked/need-info ❌')) && !contains(fromJSON('["MEMBER", "OWNER", "COLLABORATOR"]'), github.event.comment.author_association) && github.event.comment.user.type != 'Bot' }}
|
||||
if: ${{ (contains(github.event.issue.labels.*.name, 'blocked/need-repro') || contains(github.event.issue.labels.*.name, 'blocked/need-info ❌')) && github.event.comment.user.type != 'Bot' }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Get author association
|
||||
id: get-author-association
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
AUTHOR_ASSOCIATION=$(gh api /repos/electron/electron/issues/comments/${{ github.event.comment.id }} --jq '.author_association')
|
||||
echo "author_association=$AUTHOR_ASSOCIATION" >> "$GITHUB_OUTPUT"
|
||||
- name: Generate GitHub App token
|
||||
uses: electron/github-app-auth-action@384fd19694fe7b6dcc9a684746c6976ad78228ae # v1.1.1
|
||||
if: ${{ !contains(fromJSON('["MEMBER", "OWNER", "COLLABORATOR"]'), steps.get-author-association.outputs.author_association) }}
|
||||
id: generate-token
|
||||
with:
|
||||
creds: ${{ secrets.ISSUE_TRIAGE_GH_APP_CREDS }}
|
||||
- name: Remove label
|
||||
if: ${{ !contains(fromJSON('["MEMBER", "OWNER", "COLLABORATOR"]'), steps.get-author-association.outputs.author_association) }}
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
|
||||
ISSUE_URL: ${{ github.event.issue.html_url }}
|
||||
|
||||
2
.github/workflows/issue-labeled.yml
vendored
2
.github/workflows/issue-labeled.yml
vendored
@@ -72,7 +72,7 @@ jobs:
|
||||
creds: ${{ secrets.ISSUE_TRIAGE_GH_APP_CREDS }}
|
||||
- name: Create comment
|
||||
if: ${{ steps.check-for-comment.outputs.SHOULD_COMMENT }}
|
||||
uses: actions-cool/issues-helper@a610082f8ac0cf03e357eb8dd0d5e2ba075e017e # v3.6.0
|
||||
uses: actions-cool/issues-helper@50068f49b7b2b3857270ead65e2d02e4459b022c # v3.6.2
|
||||
with:
|
||||
actions: 'create-comment'
|
||||
token: ${{ steps.generate-token.outputs.token }}
|
||||
|
||||
2
.github/workflows/issue-opened.yml
vendored
2
.github/workflows/issue-opened.yml
vendored
@@ -134,7 +134,7 @@ jobs:
|
||||
}
|
||||
- name: Create unsupported major comment
|
||||
if: ${{ steps.add-labels.outputs.unsupportedMajor }}
|
||||
uses: actions-cool/issues-helper@a610082f8ac0cf03e357eb8dd0d5e2ba075e017e # v3.6.0
|
||||
uses: actions-cool/issues-helper@50068f49b7b2b3857270ead65e2d02e4459b022c # v3.6.2
|
||||
with:
|
||||
actions: 'create-comment'
|
||||
token: ${{ steps.generate-token.outputs.token }}
|
||||
|
||||
13
.github/workflows/linux-publish.yml
vendored
13
.github/workflows/linux-publish.yml
vendored
@@ -6,7 +6,7 @@ on:
|
||||
build-image-sha:
|
||||
type: string
|
||||
description: 'SHA for electron/build image'
|
||||
default: '424eedbf277ad9749ffa9219068aa72ed4a5e373'
|
||||
default: '933c7d6ff6802706875270bec2e3c891cf8add3f'
|
||||
upload-to-storage:
|
||||
description: 'Uploads to Azure storage'
|
||||
required: false
|
||||
@@ -19,7 +19,7 @@ on:
|
||||
|
||||
jobs:
|
||||
checkout-linux:
|
||||
runs-on: electron-arc-linux-amd64-32core
|
||||
runs-on: electron-arc-centralus-linux-amd64-32core
|
||||
container:
|
||||
image: ghcr.io/electron/build:${{ inputs.build-image-sha }}
|
||||
options: --user root
|
||||
@@ -43,14 +43,13 @@ jobs:
|
||||
needs: checkout-linux
|
||||
with:
|
||||
environment: production-release
|
||||
build-runs-on: electron-arc-linux-amd64-32core
|
||||
build-runs-on: electron-arc-centralus-linux-amd64-32core
|
||||
build-container: '{"image":"ghcr.io/electron/build:${{ inputs.build-image-sha }}","options":"--user root","volumes":["/mnt/cross-instance-cache:/mnt/cross-instance-cache"]}'
|
||||
target-platform: linux
|
||||
target-arch: x64
|
||||
is-release: true
|
||||
gn-build-type: release
|
||||
generate-symbols: true
|
||||
strip-binaries: true
|
||||
upload-to-storage: ${{ inputs.upload-to-storage }}
|
||||
secrets: inherit
|
||||
|
||||
@@ -59,14 +58,13 @@ jobs:
|
||||
needs: checkout-linux
|
||||
with:
|
||||
environment: production-release
|
||||
build-runs-on: electron-arc-linux-amd64-32core
|
||||
build-runs-on: electron-arc-centralus-linux-amd64-32core
|
||||
build-container: '{"image":"ghcr.io/electron/build:${{ inputs.build-image-sha }}","options":"--user root","volumes":["/mnt/cross-instance-cache:/mnt/cross-instance-cache"]}'
|
||||
target-platform: linux
|
||||
target-arch: arm
|
||||
is-release: true
|
||||
gn-build-type: release
|
||||
generate-symbols: true
|
||||
strip-binaries: true
|
||||
upload-to-storage: ${{ inputs.upload-to-storage }}
|
||||
secrets: inherit
|
||||
|
||||
@@ -75,13 +73,12 @@ jobs:
|
||||
needs: checkout-linux
|
||||
with:
|
||||
environment: production-release
|
||||
build-runs-on: electron-arc-linux-amd64-32core
|
||||
build-runs-on: electron-arc-centralus-linux-amd64-32core
|
||||
build-container: '{"image":"ghcr.io/electron/build:${{ inputs.build-image-sha }}","options":"--user root","volumes":["/mnt/cross-instance-cache:/mnt/cross-instance-cache"]}'
|
||||
target-platform: linux
|
||||
target-arch: arm64
|
||||
is-release: true
|
||||
gn-build-type: release
|
||||
generate-symbols: true
|
||||
strip-binaries: true
|
||||
upload-to-storage: ${{ inputs.upload-to-storage }}
|
||||
secrets: inherit
|
||||
|
||||
4
.github/workflows/macos-publish.yml
vendored
4
.github/workflows/macos-publish.yml
vendored
@@ -6,7 +6,7 @@ on:
|
||||
build-image-sha:
|
||||
type: string
|
||||
description: 'SHA for electron/build image'
|
||||
default: '424eedbf277ad9749ffa9219068aa72ed4a5e373'
|
||||
default: '933c7d6ff6802706875270bec2e3c891cf8add3f'
|
||||
required: true
|
||||
upload-to-storage:
|
||||
description: 'Uploads to Azure storage'
|
||||
@@ -20,7 +20,7 @@ on:
|
||||
|
||||
jobs:
|
||||
checkout-macos:
|
||||
runs-on: electron-arc-linux-amd64-32core
|
||||
runs-on: electron-arc-centralus-linux-amd64-32core
|
||||
container:
|
||||
image: ghcr.io/electron/build:${{ inputs.build-image-sha }}
|
||||
options: --user root
|
||||
|
||||
@@ -1,30 +1,40 @@
|
||||
name: Check for Non-Maintainer Dependency Change
|
||||
name: Check for Disallowed Non-Maintainer Change
|
||||
|
||||
on:
|
||||
pull_request_target:
|
||||
paths:
|
||||
- 'yarn.lock'
|
||||
- 'spec/yarn.lock'
|
||||
- '.github/workflows/**'
|
||||
- '.github/actions/**'
|
||||
|
||||
permissions: {}
|
||||
|
||||
jobs:
|
||||
check-for-non-maintainer-dependency-change:
|
||||
name: Check for non-maintainer dependency change
|
||||
if: ${{ !contains(fromJSON('["MEMBER", "OWNER"]'), github.event.pull_request.author_association) && github.event.pull_request.user.type != 'Bot' && !github.event.pull_request.draft }}
|
||||
name: Check for disallowed non-maintainer change
|
||||
if: ${{ github.event.pull_request.user.type != 'Bot' && !github.event.pull_request.draft }}
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Get author association
|
||||
id: get-author-association
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
AUTHOR_ASSOCIATION=$(gh api /repos/electron/electron/pulls/${{ github.event.pull_request.number }} --jq '.author_association')
|
||||
echo "author_association=$AUTHOR_ASSOCIATION" >> "$GITHUB_OUTPUT"
|
||||
- name: Check for existing review
|
||||
id: check-for-review
|
||||
if: ${{ !contains(fromJSON('["MEMBER", "OWNER"]'), steps.get-author-association.outputs.author_association) }}
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
PR_URL: ${{ github.event.pull_request.html_url }}
|
||||
run: |
|
||||
set -eo pipefail
|
||||
REVIEW_COUNT=$(gh pr view $PR_URL --json reviews | jq '[ .reviews[] | select(.author.login == "github-actions") | select(.body | startswith("<!-- no-dependency-change -->")) ] | length')
|
||||
REVIEW_COUNT=$(gh pr view $PR_URL --json reviews | jq '[ .reviews[] | select(.author.login == "github-actions") | select(.body | startswith("<!-- disallowed-non-maintainer-change -->")) ] | length')
|
||||
if [[ $REVIEW_COUNT -eq 0 ]]; then
|
||||
echo "SHOULD_REVIEW=1" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
@@ -34,4 +44,4 @@ jobs:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
PR_URL: ${{ github.event.pull_request.html_url }}
|
||||
run: |
|
||||
printf "<!-- no-dependency-change -->\n\nHello @${{ github.event.pull_request.user.login }}! It looks like this pull request touches one of our dependency files, and per [our contribution policy](https://github.com/electron/electron/blob/main/CONTRIBUTING.md#dependencies-upgrades-policy) we do not accept these types of changes in PRs." | gh pr review $PR_URL -r --body-file=-
|
||||
printf "<!-- disallowed-non-maintainer-change -->\n\nHello @${{ github.event.pull_request.user.login }}! It looks like this pull request touches one of our dependency or CI files, and per [our contribution policy](https://github.com/electron/electron/blob/main/CONTRIBUTING.md#dependencies-upgrades-policy) we do not accept these types of changes in PRs." | gh pr review $PR_URL -r --body-file=-
|
||||
|
||||
@@ -54,6 +54,11 @@ on:
|
||||
required: false
|
||||
type: boolean
|
||||
default: false
|
||||
enable-ssh:
|
||||
description: 'Enable SSH debugging'
|
||||
required: false
|
||||
type: boolean
|
||||
default: false
|
||||
|
||||
concurrency:
|
||||
group: electron-build-and-test-${{ inputs.target-platform }}-${{ inputs.target-arch }}-${{ github.ref_protected == true && github.run_id || github.ref }}
|
||||
@@ -76,7 +81,8 @@ jobs:
|
||||
gn-build-type: ${{ inputs.gn-build-type }}
|
||||
generate-symbols: ${{ inputs.generate-symbols }}
|
||||
upload-to-storage: ${{ inputs.upload-to-storage }}
|
||||
is-asan: ${{ inputs.is-asan}}
|
||||
is-asan: ${{ inputs.is-asan }}
|
||||
enable-ssh: ${{ inputs.enable-ssh }}
|
||||
secrets: inherit
|
||||
test:
|
||||
uses: ./.github/workflows/pipeline-segment-electron-test.yml
|
||||
@@ -86,5 +92,6 @@ jobs:
|
||||
target-platform: ${{ inputs.target-platform }}
|
||||
test-runs-on: ${{ inputs.test-runs-on }}
|
||||
test-container: ${{ inputs.test-container }}
|
||||
is-asan: ${{ inputs.is-asan}}
|
||||
is-asan: ${{ inputs.is-asan }}
|
||||
enable-ssh: ${{ inputs.enable-ssh }}
|
||||
secrets: inherit
|
||||
|
||||
@@ -12,13 +12,32 @@ concurrency:
|
||||
group: electron-docs-only-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
env:
|
||||
GCLIENT_EXTRA_ARGS: --custom-var=checkout_arm=True --custom-var=checkout_arm64=True
|
||||
|
||||
jobs:
|
||||
docs-only:
|
||||
name: Docs Only Compile
|
||||
runs-on: electron-arc-linux-amd64-4core
|
||||
runs-on: electron-arc-centralus-linux-amd64-4core
|
||||
timeout-minutes: 20
|
||||
container: ${{ fromJSON(inputs.container) }}
|
||||
steps:
|
||||
- name: Checkout Electron
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
|
||||
with:
|
||||
path: src/electron
|
||||
fetch-depth: 0
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
- name: Generate DEPS Hash
|
||||
run: |
|
||||
node src/electron/script/generate-deps-hash.js
|
||||
DEPSHASH=v1-src-cache-$(cat src/electron/.depshash)
|
||||
echo "DEPSHASH=$DEPSHASH" >> $GITHUB_ENV
|
||||
echo "CACHE_PATH=$DEPSHASH.tar" >> $GITHUB_ENV
|
||||
- name: Restore src cache via AKS
|
||||
uses: ./src/electron/.github/actions/restore-cache-aks
|
||||
with:
|
||||
target-platform: linux
|
||||
- name: Checkout Electron
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
|
||||
with:
|
||||
|
||||
2
.github/workflows/pipeline-electron-lint.yml
vendored
2
.github/workflows/pipeline-electron-lint.yml
vendored
@@ -18,7 +18,7 @@ env:
|
||||
jobs:
|
||||
lint:
|
||||
name: Lint
|
||||
runs-on: electron-arc-linux-amd64-4core
|
||||
runs-on: electron-arc-centralus-linux-amd64-4core
|
||||
timeout-minutes: 20
|
||||
container: ${{ fromJSON(inputs.container) }}
|
||||
steps:
|
||||
|
||||
@@ -48,17 +48,16 @@ on:
|
||||
required: true
|
||||
type: string
|
||||
default: '0'
|
||||
strip-binaries:
|
||||
description: 'Strip the binaries before release (Linux only)'
|
||||
required: false
|
||||
type: boolean
|
||||
default: false
|
||||
is-asan:
|
||||
description: 'Building the Address Sanitizer (ASan) Linux build'
|
||||
required: false
|
||||
type: boolean
|
||||
default: false
|
||||
|
||||
enable-ssh:
|
||||
description: 'Enable SSH debugging'
|
||||
required: false
|
||||
type: boolean
|
||||
default: false
|
||||
|
||||
concurrency:
|
||||
group: electron-build-${{ inputs.target-platform }}-${{ inputs.target-arch }}-${{ inputs.target-variant }}-${{ inputs.is-asan }}-${{ github.ref_protected == true && github.run_id || github.ref }}
|
||||
@@ -73,6 +72,7 @@ env:
|
||||
SUDOWOODO_EXCHANGE_TOKEN: ${{ secrets.SUDOWOODO_EXCHANGE_TOKEN }}
|
||||
GCLIENT_EXTRA_ARGS: ${{ inputs.target-platform == 'macos' && '--custom-var=checkout_mac=True --custom-var=host_os=mac' || inputs.target-platform == 'win' && '--custom-var=checkout_win=True' || '--custom-var=checkout_arm=True --custom-var=checkout_arm64=True' }}
|
||||
ELECTRON_OUT_DIR: Default
|
||||
ACTIONS_STEP_DEBUG: ${{ secrets.ACTIONS_STEP_DEBUG }}
|
||||
|
||||
jobs:
|
||||
build:
|
||||
@@ -94,6 +94,17 @@ jobs:
|
||||
path: src/electron
|
||||
fetch-depth: 0
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
- name: Setup SSH Debugging
|
||||
if: ${{ inputs.target-platform == 'macos' && (inputs.enable-ssh || env.ACTIONS_STEP_DEBUG == 'true') }}
|
||||
uses: ./src/electron/.github/actions/ssh-debug
|
||||
with:
|
||||
tunnel: 'true'
|
||||
env:
|
||||
CLOUDFLARE_TUNNEL_CERT: ${{ secrets.CLOUDFLARE_TUNNEL_CERT }}
|
||||
CLOUDFLARE_TUNNEL_HOSTNAME: ${{ vars.CLOUDFLARE_TUNNEL_HOSTNAME }}
|
||||
CLOUDFLARE_USER_CA_CERT: ${{ secrets.CLOUDFLARE_USER_CA_CERT }}
|
||||
AUTHORIZED_USERS: ${{ secrets.SSH_DEBUG_AUTHORIZED_USERS }}
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Free up space (macOS)
|
||||
if: ${{ inputs.target-platform == 'macos' }}
|
||||
uses: ./src/electron/.github/actions/free-space-macos
|
||||
@@ -102,7 +113,7 @@ jobs:
|
||||
run: df -h
|
||||
- name: Setup Node.js/npm
|
||||
if: ${{ inputs.target-platform == 'macos' }}
|
||||
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020
|
||||
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444
|
||||
with:
|
||||
node-version: 20.19.x
|
||||
cache: yarn
|
||||
@@ -160,7 +171,7 @@ jobs:
|
||||
ELECTRON_DEPOT_TOOLS_DISABLE_LOG: true
|
||||
- name: Init Build Tools
|
||||
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 }} --remote-build siso
|
||||
- name: Run Electron Only Hooks
|
||||
run: |
|
||||
e d gclient runhooks --spec="solutions=[{'name':'src/electron','url':None,'deps_file':'DEPS','custom_vars':{'process_deps':False},'managed':False}]"
|
||||
@@ -170,9 +181,6 @@ jobs:
|
||||
echo "DEPSHASH=$(cat src/electron/.depshash)" >> $GITHUB_ENV
|
||||
- name: Add CHROMIUM_BUILDTOOLS_PATH to env
|
||||
run: echo "CHROMIUM_BUILDTOOLS_PATH=$(pwd)/src/buildtools" >> $GITHUB_ENV
|
||||
- name: Setup Number of Ninja Processes
|
||||
run: |
|
||||
echo "NUMBER_OF_NINJA_PROCESSES=${{ inputs.target-platform != 'macos' && '300' || '200' }}" >> $GITHUB_ENV
|
||||
- name: Free up space (macOS)
|
||||
if: ${{ inputs.target-platform == 'macos' }}
|
||||
uses: ./src/electron/.github/actions/free-space-macos
|
||||
@@ -185,7 +193,6 @@ jobs:
|
||||
artifact-platform: ${{ inputs.target-platform == 'macos' && 'darwin' || inputs.target-platform }}
|
||||
is-release: '${{ inputs.is-release }}'
|
||||
generate-symbols: '${{ inputs.generate-symbols }}'
|
||||
strip-binaries: '${{ inputs.strip-binaries }}'
|
||||
upload-to-storage: '${{ inputs.upload-to-storage }}'
|
||||
is-asan: '${{ inputs.is-asan }}'
|
||||
- name: Set GN_EXTRA_ARGS for MAS Build
|
||||
|
||||
@@ -25,6 +25,11 @@ on:
|
||||
required: false
|
||||
type: boolean
|
||||
default: false
|
||||
enable-ssh:
|
||||
description: 'Enable SSH debugging'
|
||||
required: false
|
||||
type: boolean
|
||||
default: false
|
||||
|
||||
concurrency:
|
||||
group: electron-test-${{ inputs.target-platform }}-${{ inputs.target-arch }}-${{ inputs.is-asan }}-${{ github.ref_protected == true && github.run_id || github.ref }}
|
||||
@@ -40,6 +45,7 @@ env:
|
||||
CHROMIUM_GIT_COOKIE_WINDOWS_STRING: ${{ secrets.CHROMIUM_GIT_COOKIE_WINDOWS_STRING }}
|
||||
ELECTRON_OUT_DIR: Default
|
||||
ELECTRON_RBE_JWT: ${{ secrets.ELECTRON_RBE_JWT }}
|
||||
ACTIONS_STEP_DEBUG: ${{ secrets.ACTIONS_STEP_DEBUG }}
|
||||
|
||||
jobs:
|
||||
test:
|
||||
@@ -62,29 +68,15 @@ jobs:
|
||||
if: ${{ inputs.target-arch == 'arm' && inputs.target-platform == 'linux' }}
|
||||
run: |
|
||||
cp $(which node) /mnt/runner-externals/node20/bin/
|
||||
- name: Install Git on Windows arm64 runners
|
||||
if: ${{ inputs.target-arch == 'arm64' && inputs.target-platform == 'win' }}
|
||||
shell: powershell
|
||||
run: |
|
||||
Set-ExecutionPolicy Bypass -Scope Process -Force
|
||||
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072
|
||||
iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
|
||||
choco install -y --no-progress git.install --params "'/GitAndUnixToolsOnPath'"
|
||||
choco install -y --no-progress git
|
||||
choco install -y --no-progress python --version 3.11.9
|
||||
choco install -y --no-progress visualstudio2022-workload-vctools --package-parameters "--add Microsoft.VisualStudio.Component.VC.Tools.ARM64"
|
||||
echo "C:\Program Files\Git\cmd" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
|
||||
echo "C:\Program Files\Git\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
|
||||
echo "C:\Python311" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
|
||||
cp "C:\Python311\python.exe" "C:\Python311\python3.exe"
|
||||
- name: Setup Node.js/npm
|
||||
if: ${{ inputs.target-platform == 'win' }}
|
||||
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020
|
||||
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444
|
||||
with:
|
||||
node-version: 20.19.x
|
||||
- name: Add TCC permissions on macOS
|
||||
if: ${{ inputs.target-platform == 'macos' }}
|
||||
run: |
|
||||
epochdate=$(($(date +'%s * 1000 + %-N / 1000000')))
|
||||
configure_user_tccdb () {
|
||||
local values=$1
|
||||
local dbPath="$HOME/Library/Application Support/com.apple.TCC/TCC.db"
|
||||
@@ -100,14 +92,17 @@ jobs:
|
||||
}
|
||||
|
||||
userValuesArray=(
|
||||
"'kTCCServiceMicrophone','/usr/local/opt/runner/provisioner/provisioner',1,2,4,1,NULL,NULL,0,'UNUSED',NULL,0,1687786159"
|
||||
"'kTCCServiceCamera','/usr/local/opt/runner/provisioner/provisioner',1,2,4,1,NULL,NULL,0,'UNUSED',NULL,0,1687786159"
|
||||
"'kTCCServiceBluetoothAlways','/usr/local/opt/runner/provisioner/provisioner',1,2,4,1,NULL,NULL,0,'UNUSED',NULL,0,1687786159"
|
||||
"'kTCCServiceAppleEvents','/usr/local/opt/runner/provisioner/provisioner',1,2,4,1,NULL,NULL,0,'UNUSED',NULL,0,1687786159"
|
||||
"'kTCCServiceCamera','/opt/hca/hosted-compute-agent',1,2,4,1,NULL,NULL,0,'UNUSED',NULL,0,1687786159"
|
||||
"'kTCCServiceBluetoothAlways','/opt/hca/hosted-compute-agent',1,2,4,1,NULL,NULL,0,'UNUSED',NULL,0,1687786159"
|
||||
"'kTCCServiceScreenCapture','/bin/bash',1,2,3,1,NULL,NULL,NULL,'UNUSED',NULL,0,$epochdate"
|
||||
)
|
||||
for values in "${userValuesArray[@]}"; do
|
||||
# Sonoma and higher have a few extra values
|
||||
# Ref: https://github.com/actions/runner-images/blob/main/images/macos/scripts/build/configure-tccdb-macos.sh
|
||||
if [ "$OSTYPE" = "darwin23" ]; then
|
||||
if [ "$OSTYPE" = "darwin23" ] || [ "$OSTYPE" = "darwin24" ]; then
|
||||
configure_user_tccdb "$values,NULL,NULL,'UNUSED',${values##*,}"
|
||||
configure_sys_tccdb "$values,NULL,NULL,'UNUSED',${values##*,}"
|
||||
else
|
||||
@@ -115,15 +110,34 @@ jobs:
|
||||
configure_sys_tccdb "$values"
|
||||
fi
|
||||
done
|
||||
|
||||
# Ref: https://github.com/getsentry/sentry-cocoa/blob/main/scripts/ci-enable-permissions.sh
|
||||
if [ "$OSTYPE" = "darwin24" ]; then
|
||||
defaults write ~/Library/Group\ Containers/group.com.apple.replayd/ScreenCaptureApprovals.plist "/bin/bash" -date "3024-09-23 12:00:00 +0000"
|
||||
fi
|
||||
- name: Turn off the unexpectedly quit dialog on macOS
|
||||
if: ${{ inputs.target-platform == 'macos' }}
|
||||
run: defaults write com.apple.CrashReporter DialogType server
|
||||
- name: Set xcode to 16.4
|
||||
if: ${{ inputs.target-platform == 'macos' }}
|
||||
run: sudo xcode-select --switch /Applications/Xcode_16.4.app
|
||||
- name: Checkout Electron
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
|
||||
with:
|
||||
path: src/electron
|
||||
fetch-depth: 0
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
- name: Setup SSH Debugging
|
||||
if: ${{ inputs.target-platform == 'macos' && (inputs.enable-ssh || env.ACTIONS_STEP_DEBUG == 'true') }}
|
||||
uses: ./src/electron/.github/actions/ssh-debug
|
||||
with:
|
||||
tunnel: 'true'
|
||||
env:
|
||||
CLOUDFLARE_TUNNEL_CERT: ${{ secrets.CLOUDFLARE_TUNNEL_CERT }}
|
||||
CLOUDFLARE_TUNNEL_HOSTNAME: ${{ vars.CLOUDFLARE_TUNNEL_HOSTNAME }}
|
||||
CLOUDFLARE_USER_CA_CERT: ${{ secrets.CLOUDFLARE_USER_CA_CERT }}
|
||||
AUTHORIZED_USERS: ${{ secrets.SSH_DEBUG_AUTHORIZED_USERS }}
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Install Dependencies
|
||||
uses: ./src/electron/.github/actions/install-dependencies
|
||||
- name: Set Chromium Git Cookie
|
||||
@@ -137,6 +151,7 @@ jobs:
|
||||
git config --global core.fscache true
|
||||
git config --global core.longpaths true
|
||||
git config --global core.preloadindex true
|
||||
git config --global core.longpaths true
|
||||
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
|
||||
@@ -150,12 +165,12 @@ jobs:
|
||||
echo "DISABLE_CRASH_REPORTER_TESTS=true" >> $GITHUB_ENV
|
||||
echo "IS_ASAN=true" >> $GITHUB_ENV
|
||||
- name: Download Generated Artifacts
|
||||
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093
|
||||
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0
|
||||
with:
|
||||
name: generated_artifacts_${{ env.ARTIFACT_KEY }}
|
||||
path: ./generated_artifacts_${{ matrix.build-type }}_${{ inputs.target-arch }}
|
||||
- name: Download Src Artifacts
|
||||
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093
|
||||
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0
|
||||
with:
|
||||
name: src_artifacts_${{ env.ARTIFACT_KEY }}
|
||||
path: ./src_artifacts_${{ matrix.build-type }}_${{ inputs.target-arch }}
|
||||
@@ -177,12 +192,12 @@ jobs:
|
||||
unzip -:o dist.zip
|
||||
unzip -:o chromedriver.zip
|
||||
unzip -:o mksnapshot.zip
|
||||
- name: Import & Trust Self-Signed Codesigning Cert on MacOS
|
||||
if: ${{ inputs.target-platform == 'macos' && inputs.target-arch == 'x64' }}
|
||||
run: |
|
||||
sudo security authorizationdb write com.apple.trust-settings.admin allow
|
||||
cd src/electron
|
||||
./script/codesign/generate-identity.sh
|
||||
#- name: Import & Trust Self-Signed Codesigning Cert on MacOS
|
||||
# if: ${{ inputs.target-platform == 'macos' && inputs.target-arch == 'x64' }}
|
||||
# run: |
|
||||
# sudo security authorizationdb write com.apple.trust-settings.admin allow
|
||||
# cd src/electron
|
||||
# ./script/codesign/generate-identity.sh
|
||||
- name: Install Datadog CLI
|
||||
run: |
|
||||
cd src/electron
|
||||
@@ -193,7 +208,6 @@ jobs:
|
||||
MOCHA_REPORTER: mocha-multi-reporters
|
||||
MOCHA_MULTI_REPORTERS: mocha-junit-reporter, tap
|
||||
ELECTRON_DISABLE_SECURITY_WARNINGS: 1
|
||||
ELECTRON_SKIP_NATIVE_MODULE_TESTS: true
|
||||
DISPLAY: ':99.0'
|
||||
NPM_CONFIG_MSVS_VERSION: '2022'
|
||||
run: |
|
||||
|
||||
@@ -38,7 +38,7 @@ env:
|
||||
jobs:
|
||||
node-tests:
|
||||
name: Run Node.js Tests
|
||||
runs-on: electron-arc-linux-amd64-8core
|
||||
runs-on: electron-arc-centralus-linux-amd64-8core
|
||||
timeout-minutes: 30
|
||||
env:
|
||||
TARGET_ARCH: ${{ inputs.target-arch }}
|
||||
@@ -61,12 +61,12 @@ jobs:
|
||||
- name: Install Dependencies
|
||||
uses: ./src/electron/.github/actions/install-dependencies
|
||||
- name: Download Generated Artifacts
|
||||
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093
|
||||
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0
|
||||
with:
|
||||
name: generated_artifacts_${{ env.BUILD_TYPE }}_${{ env.TARGET_ARCH }}
|
||||
path: ./generated_artifacts_${{ env.BUILD_TYPE }}_${{ env.TARGET_ARCH }}
|
||||
- name: Download Src Artifacts
|
||||
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093
|
||||
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0
|
||||
with:
|
||||
name: src_artifacts_linux_${{ env.TARGET_ARCH }}
|
||||
path: ./src_artifacts_linux_${{ env.TARGET_ARCH }}
|
||||
@@ -92,7 +92,7 @@ jobs:
|
||||
done
|
||||
nan-tests:
|
||||
name: Run Nan Tests
|
||||
runs-on: electron-arc-linux-amd64-4core
|
||||
runs-on: electron-arc-centralus-linux-amd64-4core
|
||||
timeout-minutes: 30
|
||||
env:
|
||||
TARGET_ARCH: ${{ inputs.target-arch }}
|
||||
@@ -115,12 +115,12 @@ jobs:
|
||||
- name: Install Dependencies
|
||||
uses: ./src/electron/.github/actions/install-dependencies
|
||||
- name: Download Generated Artifacts
|
||||
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093
|
||||
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0
|
||||
with:
|
||||
name: generated_artifacts_${{ env.BUILD_TYPE }}_${{ env.TARGET_ARCH }}
|
||||
path: ./generated_artifacts_${{ env.BUILD_TYPE }}_${{ env.TARGET_ARCH }}
|
||||
- name: Download Src Artifacts
|
||||
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093
|
||||
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0
|
||||
with:
|
||||
name: src_artifacts_linux_${{ env.TARGET_ARCH }}
|
||||
path: ./src_artifacts_linux_${{ env.TARGET_ARCH }}
|
||||
|
||||
2
.github/workflows/pull-request-labeled.yml
vendored
2
.github/workflows/pull-request-labeled.yml
vendored
@@ -13,7 +13,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Trigger Slack workflow
|
||||
uses: slackapi/slack-github-action@b0fa283ad8fea605de13dc3f449259339835fc52 # v2.1.0
|
||||
uses: slackapi/slack-github-action@91efab103c0de0a537f72a35f6b8cda0ee76bf0a # v2.1.1
|
||||
with:
|
||||
webhook: ${{ secrets.BACKPORT_REQUESTED_SLACK_WEBHOOK_URL }}
|
||||
webhook-type: webhook-trigger
|
||||
|
||||
2
.github/workflows/scorecards.yml
vendored
2
.github/workflows/scorecards.yml
vendored
@@ -50,6 +50,6 @@ jobs:
|
||||
|
||||
# Upload the results to GitHub's code scanning dashboard.
|
||||
- name: "Upload to code-scanning"
|
||||
uses: github/codeql-action/upload-sarif@181d5eefc20863364f96762470ba6f862bdef56b # v3.29.2
|
||||
uses: github/codeql-action/upload-sarif@f1f6e5f6af878fb37288ce1c627459e94dbf7d01 # v3.29.5
|
||||
with:
|
||||
sarif_file: results.sarif
|
||||
|
||||
2
.github/workflows/semantic.yml
vendored
2
.github/workflows/semantic.yml
vendored
@@ -19,7 +19,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: semantic-pull-request
|
||||
uses: amannn/action-semantic-pull-request@0723387faaf9b38adef4775cd42cfd5155ed6017 # v5.5.3
|
||||
uses: amannn/action-semantic-pull-request@48f256284bd46cdaab1048c3721360e808335d50 # v6.1.1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
|
||||
10
.github/workflows/windows-publish.yml
vendored
10
.github/workflows/windows-publish.yml
vendored
@@ -6,7 +6,7 @@ on:
|
||||
build-image-sha:
|
||||
type: string
|
||||
description: 'SHA for electron/build image'
|
||||
default: '424eedbf277ad9749ffa9219068aa72ed4a5e373'
|
||||
default: '933c7d6ff6802706875270bec2e3c891cf8add3f'
|
||||
required: true
|
||||
upload-to-storage:
|
||||
description: 'Uploads to Azure storage'
|
||||
@@ -20,7 +20,7 @@ on:
|
||||
|
||||
jobs:
|
||||
checkout-windows:
|
||||
runs-on: electron-arc-linux-amd64-32core
|
||||
runs-on: electron-arc-centralus-linux-amd64-32core
|
||||
container:
|
||||
image: ghcr.io/electron/build:${{ inputs.build-image-sha }}
|
||||
options: --user root --device /dev/fuse --cap-add SYS_ADMIN
|
||||
@@ -51,7 +51,7 @@ jobs:
|
||||
needs: checkout-windows
|
||||
with:
|
||||
environment: production-release
|
||||
build-runs-on: electron-arc-windows-amd64-16core
|
||||
build-runs-on: electron-arc-centralus-windows-amd64-16core
|
||||
target-platform: win
|
||||
target-arch: x64
|
||||
is-release: true
|
||||
@@ -65,7 +65,7 @@ jobs:
|
||||
needs: checkout-windows
|
||||
with:
|
||||
environment: production-release
|
||||
build-runs-on: electron-arc-windows-amd64-16core
|
||||
build-runs-on: electron-arc-centralus-windows-amd64-16core
|
||||
target-platform: win
|
||||
target-arch: arm64
|
||||
is-release: true
|
||||
@@ -79,7 +79,7 @@ jobs:
|
||||
needs: checkout-windows
|
||||
with:
|
||||
environment: production-release
|
||||
build-runs-on: electron-arc-windows-amd64-16core
|
||||
build-runs-on: electron-arc-centralus-windows-amd64-16core
|
||||
target-platform: win
|
||||
target-arch: x86
|
||||
is-release: true
|
||||
|
||||
@@ -21,7 +21,9 @@
|
||||
"ul",
|
||||
"unknown",
|
||||
"Tabs",
|
||||
"TabItem"
|
||||
"TabItem",
|
||||
"DocCardList",
|
||||
"kbd"
|
||||
]
|
||||
},
|
||||
"no-newline-in-links": true
|
||||
|
||||
129
BUILD.gn
129
BUILD.gn
@@ -4,9 +4,9 @@ import("//build/config/win/manifest.gni")
|
||||
import("//components/os_crypt/sync/features.gni")
|
||||
import("//components/spellcheck/spellcheck_build_features.gni")
|
||||
import("//content/public/app/mac_helpers.gni")
|
||||
import("//content/public/common/features.gni")
|
||||
import("//extensions/buildflags/buildflags.gni")
|
||||
import("//pdf/features.gni")
|
||||
import("//ppapi/buildflags/buildflags.gni")
|
||||
import("//printing/buildflags/buildflags.gni")
|
||||
import("//testing/test.gni")
|
||||
import("//third_party/electron_node/node.gni")
|
||||
@@ -44,6 +44,7 @@ if (is_mac) {
|
||||
|
||||
if (is_linux) {
|
||||
import("//build/config/linux/pkg_config.gni")
|
||||
import("//electron/build/linux/strip_binary.gni")
|
||||
import("//tools/generate_stubs/rules.gni")
|
||||
|
||||
pkg_config("gio_unix") {
|
||||
@@ -452,7 +453,7 @@ source_set("electron_lib") {
|
||||
"//components/certificate_transparency",
|
||||
"//components/compose:buildflags",
|
||||
"//components/embedder_support:user_agent",
|
||||
"//components/input:input",
|
||||
"//components/input",
|
||||
"//components/language/core/browser",
|
||||
"//components/net_log",
|
||||
"//components/network_hints/browser",
|
||||
@@ -485,7 +486,7 @@ source_set("electron_lib") {
|
||||
"//net:extras",
|
||||
"//net:net_resources",
|
||||
"//printing/buildflags",
|
||||
"//services/device/public/cpp/bluetooth:bluetooth",
|
||||
"//services/device/public/cpp/bluetooth",
|
||||
"//services/device/public/cpp/geolocation",
|
||||
"//services/device/public/cpp/hid",
|
||||
"//services/device/public/mojom",
|
||||
@@ -518,6 +519,10 @@ source_set("electron_lib") {
|
||||
"//v8:v8_libplatform",
|
||||
]
|
||||
|
||||
if (v8_use_external_startup_data && use_v8_context_snapshot) {
|
||||
deps += [ ":mksnapshot_checksum_gen" ]
|
||||
}
|
||||
|
||||
public_deps = [
|
||||
"//base",
|
||||
"//base:i18n",
|
||||
@@ -650,6 +655,7 @@ source_set("electron_lib") {
|
||||
"//ui/events/devices/x11",
|
||||
"//ui/events/platform/x11",
|
||||
"//ui/gtk:gtk_config",
|
||||
"//ui/linux:display_server_utils",
|
||||
"//ui/linux:linux_ui",
|
||||
"//ui/linux:linux_ui_factory",
|
||||
"//ui/wm",
|
||||
@@ -682,7 +688,7 @@ source_set("electron_lib") {
|
||||
deps += [
|
||||
"//components/app_launch_prefetch",
|
||||
"//components/crash/core/app:crash_export_thunks",
|
||||
"//ui/native_theme:native_theme_browser",
|
||||
"//third_party/libxml:xml_writer",
|
||||
"//ui/wm",
|
||||
"//ui/wm/public",
|
||||
]
|
||||
@@ -727,7 +733,7 @@ source_set("electron_lib") {
|
||||
"shell/common/extensions/api:extensions_features",
|
||||
"//chrome/browser/resources:component_extension_resources",
|
||||
"//components/guest_view/common:mojom",
|
||||
"//components/update_client:update_client",
|
||||
"//components/update_client",
|
||||
"//components/zoom",
|
||||
"//extensions/browser",
|
||||
"//extensions/browser/api:api_provider",
|
||||
@@ -772,6 +778,18 @@ source_set("electron_lib") {
|
||||
}
|
||||
}
|
||||
|
||||
action("mksnapshot_checksum_gen") {
|
||||
script = "build/checksum_header.py"
|
||||
|
||||
outputs = [ "$target_gen_dir/snapshot_checksum.h" ]
|
||||
inputs = [ "$root_out_dir/$v8_context_snapshot_filename" ]
|
||||
args = rebase_path(inputs)
|
||||
|
||||
args += rebase_path(outputs)
|
||||
|
||||
deps = [ "//tools/v8_context_snapshot" ]
|
||||
}
|
||||
|
||||
electron_paks("packed_resources") {
|
||||
if (is_mac) {
|
||||
output_dir = "$root_gen_dir/electron_repack"
|
||||
@@ -815,7 +833,7 @@ if (is_mac) {
|
||||
sources = []
|
||||
public_deps = []
|
||||
sources += [ "$root_out_dir/libffmpeg.dylib" ]
|
||||
public_deps += [ "//third_party/ffmpeg:ffmpeg" ]
|
||||
public_deps += [ "//third_party/ffmpeg" ]
|
||||
outputs = [ "{{bundle_contents_dir}}/Libraries/{{source_file_part}}" ]
|
||||
}
|
||||
} else {
|
||||
@@ -1230,7 +1248,7 @@ if (is_mac) {
|
||||
}
|
||||
|
||||
if (use_v8_context_snapshot) {
|
||||
public_deps = [ "//tools/v8_context_snapshot:v8_context_snapshot" ]
|
||||
public_deps = [ "//tools/v8_context_snapshot" ]
|
||||
}
|
||||
|
||||
if (is_linux) {
|
||||
@@ -1409,6 +1427,18 @@ dist_zip("electron_dist_zip") {
|
||||
":licenses",
|
||||
]
|
||||
if (is_linux) {
|
||||
if (is_official_build) {
|
||||
data_deps += [
|
||||
":strip_chrome_crashpad_handler",
|
||||
":strip_chrome_sandbox",
|
||||
":strip_electron_binary",
|
||||
":strip_libEGL_shlib",
|
||||
":strip_libGLESv2_shlib",
|
||||
":strip_libffmpeg_shlib",
|
||||
":strip_libvk_swiftshader_shlib",
|
||||
]
|
||||
}
|
||||
|
||||
data_deps += [ "//sandbox/linux:chrome_sandbox" ]
|
||||
}
|
||||
deps = data_deps
|
||||
@@ -1454,6 +1484,16 @@ group("electron_mksnapshot") {
|
||||
|
||||
dist_zip("electron_mksnapshot_zip") {
|
||||
data_deps = mksnapshot_deps
|
||||
if (is_linux && is_official_build) {
|
||||
data_deps += [
|
||||
":strip_libEGL_shlib",
|
||||
":strip_libGLESv2_shlib",
|
||||
":strip_libffmpeg_shlib",
|
||||
":strip_libvk_swiftshader_shlib",
|
||||
":strip_mksnapshot_binary",
|
||||
":strip_v8_context_snapshot_generator_binary",
|
||||
]
|
||||
}
|
||||
deps = data_deps
|
||||
outputs = [ "$root_build_dir/mksnapshot.zip" ]
|
||||
}
|
||||
@@ -1578,3 +1618,78 @@ group("copy_node_headers") {
|
||||
group("node_headers") {
|
||||
public_deps = [ ":tar_node_headers" ]
|
||||
}
|
||||
|
||||
if (is_linux && is_official_build) {
|
||||
strip_binary("strip_electron_binary") {
|
||||
binary_input = "$root_out_dir/$electron_project_name"
|
||||
symbol_output = "$root_out_dir/debug/$electron_project_name.debug"
|
||||
compress_debug_sections = true
|
||||
deps = [ ":electron_app" ]
|
||||
}
|
||||
|
||||
strip_binary("strip_chrome_crashpad_handler") {
|
||||
binary_input = "$root_out_dir/chrome_crashpad_handler"
|
||||
symbol_output = "$root_out_dir/debug/chrome_crashpad_handler.debug"
|
||||
compress_debug_sections = true
|
||||
deps = [ "//components/crash/core/app:chrome_crashpad_handler" ]
|
||||
}
|
||||
|
||||
strip_binary("strip_chrome_sandbox") {
|
||||
binary_input = "$root_out_dir/chrome_sandbox"
|
||||
symbol_output = "$root_out_dir/debug/chrome-sandbox.debug"
|
||||
compress_debug_sections = true
|
||||
deps = [ "//sandbox/linux:chrome_sandbox" ]
|
||||
}
|
||||
|
||||
strip_binary("strip_libEGL_shlib") {
|
||||
binary_input = "$root_out_dir/libEGL.so"
|
||||
symbol_output = "$root_out_dir/debug/libEGL.so.debug"
|
||||
compress_debug_sections = true
|
||||
deps = [ "//third_party/angle:libEGL" ]
|
||||
}
|
||||
|
||||
strip_binary("strip_libGLESv2_shlib") {
|
||||
binary_input = "$root_out_dir/libGLESv2.so"
|
||||
symbol_output = "$root_out_dir/debug/libGLESv2.so.debug"
|
||||
compress_debug_sections = true
|
||||
deps = [ "//third_party/angle:libGLESv2" ]
|
||||
}
|
||||
|
||||
strip_binary("strip_libffmpeg_shlib") {
|
||||
binary_input = "$root_out_dir/libffmpeg.so"
|
||||
symbol_output = "$root_out_dir/debug/libffmpeg.so.debug"
|
||||
compress_debug_sections = true
|
||||
deps = [ "//third_party/ffmpeg" ]
|
||||
}
|
||||
|
||||
strip_binary("strip_libvk_swiftshader_shlib") {
|
||||
binary_input = "$root_out_dir/libvk_swiftshader.so"
|
||||
symbol_output = "$root_out_dir/debug/libvk_swiftshader.so.debug"
|
||||
compress_debug_sections = true
|
||||
deps = [ "//third_party/swiftshader/src/Vulkan:swiftshader_libvulkan" ]
|
||||
}
|
||||
|
||||
strip_binary("strip_mksnapshot_binary") {
|
||||
_binary_path = rebase_path(
|
||||
get_label_info(
|
||||
":v8_context_snapshot_generator($v8_snapshot_toolchain)",
|
||||
"root_out_dir") + "/mksnapshot",
|
||||
root_build_dir)
|
||||
binary_input = "$root_out_dir/$_binary_path"
|
||||
symbol_output = "$root_out_dir/debug/${_binary_path}.debug"
|
||||
compress_debug_sections = true
|
||||
deps = mksnapshot_deps
|
||||
}
|
||||
|
||||
strip_binary("strip_v8_context_snapshot_generator_binary") {
|
||||
_binary_path = rebase_path(
|
||||
get_label_info(
|
||||
":v8_context_snapshot_generator($v8_snapshot_toolchain)",
|
||||
"root_out_dir") + "/v8_context_snapshot_generator",
|
||||
root_build_dir)
|
||||
binary_input = "$root_out_dir/$_binary_path"
|
||||
symbol_output = "$root_out_dir/debug/${_binary_path}.debug"
|
||||
compress_debug_sections = true
|
||||
deps = mksnapshot_deps
|
||||
}
|
||||
}
|
||||
|
||||
4
DEPS
4
DEPS
@@ -2,9 +2,9 @@ gclient_gn_args_from = 'src'
|
||||
|
||||
vars = {
|
||||
'chromium_version':
|
||||
'140.0.7261.0',
|
||||
'141.0.7390.7',
|
||||
'node_version':
|
||||
'v22.17.0',
|
||||
'v22.19.0',
|
||||
'nan_version':
|
||||
'e14bdcd1f72d62bca1d541b66da43130384ec213',
|
||||
'squirrel.mac_version':
|
||||
|
||||
@@ -2,7 +2,7 @@ is_electron_build = true
|
||||
root_extra_deps = [ "//electron" ]
|
||||
|
||||
# Registry of NMVs --> https://github.com/nodejs/node/blob/main/doc/abi_version_registry.json
|
||||
node_module_version = 139
|
||||
node_module_version = 140
|
||||
|
||||
v8_promise_internal_field_count = 1
|
||||
v8_embedder_string = "-electron.0"
|
||||
@@ -70,10 +70,5 @@ v8_expose_public_symbols = true
|
||||
# sensitive content by enterprise users.
|
||||
enterprise_cloud_content_analysis = false
|
||||
|
||||
# TODO: remove dependency on legacy ipc
|
||||
# https://issues.chromium.org/issues/40943039
|
||||
content_enable_legacy_ipc = true
|
||||
|
||||
# Disable siso until we are ready to use it.
|
||||
# https://chromium-review.googlesource.com/c/chromium/src/+/6638830
|
||||
use_siso = false
|
||||
# We don't use anything from here, and it causes target collisions
|
||||
enable_linux_installer = false
|
||||
|
||||
37
build/checksum_header.py
Normal file
37
build/checksum_header.py
Normal file
@@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import sys
|
||||
import hashlib
|
||||
|
||||
dir_path = os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
TEMPLATE_H = """
|
||||
#ifndef ELECTRON_SNAPSHOT_CHECKSUM_H_
|
||||
#define ELECTRON_SNAPSHOT_CHECKSUM_H_
|
||||
|
||||
namespace electron::snapshot_checksum {
|
||||
|
||||
inline constexpr std::string_view kChecksum = "{checksum}";
|
||||
|
||||
} // namespace electron::snapshot_checksum
|
||||
|
||||
#endif // ELECTRON_SNAPSHOT_CHECKSUM_H_
|
||||
"""
|
||||
|
||||
def calculate_sha256(filepath):
|
||||
sha256_hash = hashlib.sha256()
|
||||
with open(filepath, "rb") as f:
|
||||
for byte_block in iter(lambda: f.read(4096), b""):
|
||||
sha256_hash.update(byte_block)
|
||||
return sha256_hash.hexdigest()
|
||||
|
||||
input_file = sys.argv[1]
|
||||
output_file = sys.argv[2]
|
||||
|
||||
checksum = calculate_sha256(input_file)
|
||||
|
||||
checksum_h = TEMPLATE_H.replace("{checksum}", checksum)
|
||||
|
||||
with open(output_file, 'w') as f:
|
||||
f.write(checksum_h)
|
||||
70
build/linux/strip_binary.gni
Normal file
70
build/linux/strip_binary.gni
Normal file
@@ -0,0 +1,70 @@
|
||||
# Copyright 2021 The Chromium Authors
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
# This has been adapted from https://source.chromium.org/chromium/chromium/src/+/main:build/linux/strip_binary.gni;drc=c220a41e0422d45f1657c28146d32e99cc53640b
|
||||
# The notable difference is it has an option to compress the debug sections
|
||||
|
||||
import("//build/config/clang/clang.gni")
|
||||
import("//build/toolchain/toolchain.gni")
|
||||
|
||||
# Extracts symbols from a binary into a symbol file.
|
||||
#
|
||||
# Args:
|
||||
# binary_input: Path to the binary containing symbols to extract, e.g.:
|
||||
# "$root_out_dir/chrome"
|
||||
# symbol_output: Desired output file for symbols, e.g.:
|
||||
# "$root_out_dir/chrome.debug"
|
||||
# stripped_binary_output: Desired output file for stripped file, e.g.:
|
||||
# "$root_out_dir/chrome.stripped"
|
||||
# compress_debug_sections: If true, compress the extracted debug sections
|
||||
template("strip_binary") {
|
||||
forward_variables_from(invoker,
|
||||
[
|
||||
"deps",
|
||||
"testonly",
|
||||
])
|
||||
action("${target_name}") {
|
||||
llvm_strip_binary = "${clang_base_path}/bin/llvm-strip"
|
||||
llvm_objcopy_binary = "${clang_base_path}/bin/llvm-objcopy"
|
||||
script = "//electron/build/linux/strip_binary.py"
|
||||
|
||||
if (defined(invoker.stripped_binary_output)) {
|
||||
stripped_binary_output = invoker.stripped_binary_output
|
||||
} else {
|
||||
stripped_binary_output = invoker.binary_input + ".stripped"
|
||||
}
|
||||
if (defined(invoker.symbol_output)) {
|
||||
symbol_output = invoker.symbol_output
|
||||
} else {
|
||||
symbol_output = invoker.binary_input + ".debug"
|
||||
}
|
||||
|
||||
inputs = [
|
||||
invoker.binary_input,
|
||||
llvm_strip_binary,
|
||||
llvm_objcopy_binary,
|
||||
]
|
||||
outputs = [
|
||||
symbol_output,
|
||||
stripped_binary_output,
|
||||
]
|
||||
args = [
|
||||
"--llvm-strip-binary-path",
|
||||
rebase_path(llvm_strip_binary, root_build_dir),
|
||||
"--llvm-objcopy-binary-path",
|
||||
rebase_path(llvm_objcopy_binary, root_build_dir),
|
||||
"--symbol-output",
|
||||
rebase_path(symbol_output, root_build_dir),
|
||||
"--stripped-binary-output",
|
||||
rebase_path(stripped_binary_output, root_build_dir),
|
||||
"--binary-input",
|
||||
rebase_path(invoker.binary_input, root_build_dir),
|
||||
]
|
||||
|
||||
if (defined(invoker.compress_debug_sections) &&
|
||||
invoker.compress_debug_sections) {
|
||||
args += [ "--compress-debug-sections" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
63
build/linux/strip_binary.py
Normal file
63
build/linux/strip_binary.py
Normal file
@@ -0,0 +1,63 @@
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# Copyright 2021 The Chromium Authors
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
# This has been adapted from https://source.chromium.org/chromium/chromium/src/+/main:build/linux/strip_binary.py;drc=c220a41e0422d45f1657c28146d32e99cc53640b
|
||||
# The notable difference is it has an option to compress the debug sections
|
||||
|
||||
import argparse
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser(description="Strip binary using LLVM tools.")
|
||||
parser.add_argument("--llvm-strip-binary-path",
|
||||
help="Path to llvm-strip executable.")
|
||||
parser.add_argument("--llvm-objcopy-binary-path",
|
||||
required=True,
|
||||
help="Path to llvm-objcopy executable.")
|
||||
parser.add_argument("--binary-input", help="Input ELF binary.")
|
||||
parser.add_argument("--symbol-output",
|
||||
help="File to write extracted debug info (.debug).")
|
||||
parser.add_argument("--compress-debug-sections",
|
||||
action="store_true",
|
||||
help="Compress extracted debug info.")
|
||||
parser.add_argument("--stripped-binary-output",
|
||||
help="File to write stripped binary.")
|
||||
args = parser.parse_args()
|
||||
|
||||
# Replicate the behavior of:
|
||||
# eu-strip <binary_input> -o <stripped_binary_output> -f <symbol_output>
|
||||
|
||||
objcopy_args = [
|
||||
"--only-keep-debug",
|
||||
args.binary_input,
|
||||
args.symbol_output,
|
||||
]
|
||||
|
||||
if args.compress_debug_sections:
|
||||
objcopy_args.insert(0, "--compress-debug-sections")
|
||||
|
||||
subprocess.check_output([args.llvm_objcopy_binary_path] + objcopy_args)
|
||||
subprocess.check_output([
|
||||
args.llvm_strip_binary_path,
|
||||
"--strip-debug",
|
||||
"--strip-unneeded",
|
||||
"-o",
|
||||
args.stripped_binary_output,
|
||||
args.binary_input,
|
||||
])
|
||||
subprocess.check_output([
|
||||
args.llvm_objcopy_binary_path,
|
||||
f"--add-gnu-debuglink={args.symbol_output}",
|
||||
args.stripped_binary_output,
|
||||
])
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -67,10 +67,6 @@ template("mac_xib_bundle_data") {
|
||||
ibtool_flags = [
|
||||
"--minimum-deployment-target",
|
||||
mac_deployment_target,
|
||||
|
||||
# TODO(rsesek): Enable this once all the bots are on Xcode 7+.
|
||||
# "--target-device",
|
||||
# "mac",
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
load("@builtin//struct.star", "module")
|
||||
|
||||
def __platform_properties(ctx):
|
||||
container_image = "docker://gcr.io/chops-public-images-prod/rbe/siso-chromium/linux@sha256:ef35d347f4a4a2d32b76fd908e66e96f59bf8ba7379fd5626548244c45343b2b"
|
||||
container_image = "docker://gcr.io/chops-public-images-prod/rbe/siso-chromium/linux@sha256:d7cb1ab14a0f20aa669c23f22c15a9dead761dcac19f43985bf9dd5f41fbef3a"
|
||||
return {
|
||||
"default": {
|
||||
"OSFamily": "Linux",
|
||||
|
||||
66
build/siso/main.star
Normal file
66
build/siso/main.star
Normal file
@@ -0,0 +1,66 @@
|
||||
load("@builtin//encoding.star", "json")
|
||||
load("@builtin//path.star", "path")
|
||||
load("@builtin//runtime.star", "runtime")
|
||||
load("@builtin//struct.star", "module")
|
||||
load("@config//main.star", upstream_init = "init")
|
||||
load("@config//win_sdk.star", "win_sdk")
|
||||
load("@config//gn_logs.star", "gn_logs")
|
||||
|
||||
def init(ctx):
|
||||
mod = upstream_init(ctx)
|
||||
step_config = json.decode(mod.step_config)
|
||||
|
||||
# Buildbarn doesn't support input_root_absolute_path so disable that
|
||||
for rule in step_config["rules"]:
|
||||
input_root_absolute_path = rule.get("input_root_absolute_path", False)
|
||||
if input_root_absolute_path:
|
||||
rule.pop("input_root_absolute_path", None)
|
||||
|
||||
# Only wrap clang rules with a remote wrapper if not on Linux. These are currently only
|
||||
# needed for X-Compile builds, which run on Windows and Mac.
|
||||
if runtime.os != "linux":
|
||||
for rule in step_config["rules"]:
|
||||
if rule["name"].startswith("clang/") or rule["name"].startswith("clang-cl/"):
|
||||
rule["remote_wrapper"] = "../../buildtools/reclient_cfgs/chromium-browser-clang/clang_remote_wrapper"
|
||||
if "inputs" not in rule:
|
||||
rule["inputs"] = []
|
||||
rule["inputs"].append("buildtools/reclient_cfgs/chromium-browser-clang/clang_remote_wrapper")
|
||||
rule["inputs"].append("third_party/llvm-build/Release+Asserts_linux/bin/clang")
|
||||
|
||||
if "executables" not in step_config:
|
||||
step_config["executables"] = []
|
||||
step_config["executables"].append("buildtools/reclient_cfgs/chromium-browser-clang/clang_remote_wrapper")
|
||||
step_config["executables"].append("third_party/llvm-build/Release+Asserts_linux/bin/clang")
|
||||
|
||||
if runtime.os == "darwin":
|
||||
# Update platforms to match our default siso config instead of reclient configs.
|
||||
step_config["platforms"].update({
|
||||
"clang": step_config["platforms"]["default"],
|
||||
"clang_large": step_config["platforms"]["default"],
|
||||
})
|
||||
|
||||
if runtime.os == "windows":
|
||||
# Add additional Windows SDK headers needed by Electron
|
||||
win_toolchain_dir = win_sdk.toolchain_dir(ctx)
|
||||
if win_toolchain_dir:
|
||||
sdk_version = gn_logs.read(ctx).get("windows_sdk_version")
|
||||
step_config["input_deps"][win_toolchain_dir + ":headers"].extend([
|
||||
# third_party/electron_node/deps/uv/include/uv/win.h includes mswsock.h
|
||||
path.join(win_toolchain_dir, "Windows Kits/10/Include", sdk_version, "um/mswsock.h"),
|
||||
# third_party/electron_node/src/debug_utils.cc includes lm.h
|
||||
path.join(win_toolchain_dir, "Windows Kits/10/Include", sdk_version, "um/Lm.h"),
|
||||
])
|
||||
|
||||
# Update platforms to match our default siso config instead of reclient configs.
|
||||
step_config["platforms"].update({
|
||||
"clang-cl": step_config["platforms"]["default"],
|
||||
"clang-cl_large": step_config["platforms"]["default"],
|
||||
"lld-link": step_config["platforms"]["default"],
|
||||
})
|
||||
|
||||
return module(
|
||||
"config",
|
||||
step_config = json.encode(step_config),
|
||||
filegroups = mod.filegroups,
|
||||
handlers = mod.handlers,
|
||||
)
|
||||
@@ -121,6 +121,7 @@ if ((globalThis.process || binding.process).argv.includes("--profile-electron-in
|
||||
'electron/main$': electronAPIFile,
|
||||
'electron/renderer$': electronAPIFile,
|
||||
'electron/common$': electronAPIFile,
|
||||
'electron/utility$': electronAPIFile,
|
||||
// Force timers to resolve to our dependency that doesn't use window.postMessage
|
||||
timers: path.resolve(electronRoot, 'node_modules', 'timers-browserify', 'main.js')
|
||||
},
|
||||
@@ -143,7 +144,9 @@ if ((globalThis.process || binding.process).argv.includes("--profile-electron-in
|
||||
transpileOnly: onlyPrintingGraph,
|
||||
ignoreDiagnostics: [
|
||||
// File '{0}' is not under 'rootDir' '{1}'.
|
||||
6059
|
||||
6059,
|
||||
// Private field '{0}' must be declared in an enclosing class.
|
||||
1111
|
||||
]
|
||||
}
|
||||
}]
|
||||
|
||||
12
build/zip.py
12
build/zip.py
@@ -41,6 +41,8 @@ PATHS_TO_SKIP = [
|
||||
'resources/inspector',
|
||||
'gen/third_party/devtools-frontend/src',
|
||||
'gen/ui/webui',
|
||||
# Skip because these get zipped separately in script/zip-symbols.py
|
||||
'debug',
|
||||
]
|
||||
|
||||
def skip_path(dep, dist_zip, target_cpu):
|
||||
@@ -80,6 +82,11 @@ def main(argv):
|
||||
dep = dep.strip()
|
||||
if not skip_path(dep, dist_zip, target_cpu):
|
||||
dist_files.add(dep)
|
||||
# On Linux, filter out any files which have a .stripped companion
|
||||
if sys.platform == 'linux':
|
||||
dist_files = {
|
||||
dep for dep in dist_files if f"{dep.removeprefix('./')}.stripped" not in dist_files
|
||||
}
|
||||
if sys.platform == 'darwin' and not should_flatten:
|
||||
execute(['zip', '-r', '-y', dist_zip] + list(dist_files))
|
||||
else:
|
||||
@@ -96,10 +103,13 @@ def main(argv):
|
||||
dirname = os.path.dirname(dep)
|
||||
arcname = (
|
||||
os.path.join(dirname, 'chrome-sandbox')
|
||||
if basename == 'chrome_sandbox'
|
||||
if basename.removesuffix('.stripped') == 'chrome_sandbox'
|
||||
else dep
|
||||
)
|
||||
name_to_write = arcname
|
||||
# On Linux, strip the .stripped suffix from the name before zipping
|
||||
if sys.platform == 'linux':
|
||||
name_to_write = name_to_write.removesuffix('.stripped')
|
||||
if should_flatten:
|
||||
if flatten_relative_to:
|
||||
if name_to_write.startswith(flatten_relative_to):
|
||||
|
||||
@@ -23,6 +23,8 @@ static_library("chrome") {
|
||||
"//chrome/browser/browser_process.h",
|
||||
"//chrome/browser/devtools/devtools_contents_resizing_strategy.cc",
|
||||
"//chrome/browser/devtools/devtools_contents_resizing_strategy.h",
|
||||
"//chrome/browser/devtools/devtools_dispatch_http_request_params.cc",
|
||||
"//chrome/browser/devtools/devtools_dispatch_http_request_params.h",
|
||||
"//chrome/browser/devtools/devtools_embedder_message_dispatcher.cc",
|
||||
"//chrome/browser/devtools/devtools_embedder_message_dispatcher.h",
|
||||
"//chrome/browser/devtools/devtools_eye_dropper.cc",
|
||||
@@ -76,14 +78,8 @@ static_library("chrome") {
|
||||
"//chrome/browser/picture_in_picture/scoped_picture_in_picture_occlusion_observation.h",
|
||||
"//chrome/browser/platform_util.cc",
|
||||
"//chrome/browser/platform_util.h",
|
||||
"//chrome/browser/predictors/preconnect_manager.cc",
|
||||
"//chrome/browser/predictors/preconnect_manager.h",
|
||||
"//chrome/browser/predictors/predictors_features.cc",
|
||||
"//chrome/browser/predictors/predictors_features.h",
|
||||
"//chrome/browser/predictors/proxy_lookup_client_impl.cc",
|
||||
"//chrome/browser/predictors/proxy_lookup_client_impl.h",
|
||||
"//chrome/browser/predictors/resolve_host_client_impl.cc",
|
||||
"//chrome/browser/predictors/resolve_host_client_impl.h",
|
||||
"//chrome/browser/process_singleton.h",
|
||||
"//chrome/browser/process_singleton_internal.cc",
|
||||
"//chrome/browser/process_singleton_internal.h",
|
||||
@@ -130,8 +126,12 @@ static_library("chrome") {
|
||||
"//chrome/browser/ui/views/overlay/hang_up_button.h",
|
||||
"//chrome/browser/ui/views/overlay/minimize_button.cc",
|
||||
"//chrome/browser/ui/views/overlay/minimize_button.h",
|
||||
"//chrome/browser/ui/views/overlay/overlay_controls_fade_animation.cc",
|
||||
"//chrome/browser/ui/views/overlay/overlay_controls_fade_animation.h",
|
||||
"//chrome/browser/ui/views/overlay/overlay_window_image_button.cc",
|
||||
"//chrome/browser/ui/views/overlay/overlay_window_image_button.h",
|
||||
"//chrome/browser/ui/views/overlay/overlay_window_live_caption_button.cc",
|
||||
"//chrome/browser/ui/views/overlay/overlay_window_live_caption_button.h",
|
||||
"//chrome/browser/ui/views/overlay/playback_image_button.cc",
|
||||
"//chrome/browser/ui/views/overlay/playback_image_button.h",
|
||||
"//chrome/browser/ui/views/overlay/resize_handle_button.cc",
|
||||
@@ -144,8 +144,6 @@ static_library("chrome") {
|
||||
"//chrome/browser/ui/views/overlay/toggle_camera_button.h",
|
||||
"//chrome/browser/ui/views/overlay/toggle_microphone_button.cc",
|
||||
"//chrome/browser/ui/views/overlay/toggle_microphone_button.h",
|
||||
"//chrome/browser/ui/views/overlay/video_overlay_window_native_widget_mac.h",
|
||||
"//chrome/browser/ui/views/overlay/video_overlay_window_native_widget_mac.mm",
|
||||
"//chrome/browser/ui/views/overlay/video_overlay_window_views.cc",
|
||||
"//chrome/browser/ui/views/overlay/video_overlay_window_views.h",
|
||||
"//chrome/browser/ui/views/picture_in_picture/picture_in_picture_bounds_change_animation.cc",
|
||||
@@ -215,7 +213,7 @@ static_library("chrome") {
|
||||
"//components/enterprise/common/proto:connectors_proto",
|
||||
"//components/enterprise/obfuscation/core:enterprise_obfuscation",
|
||||
"//components/safe_browsing/core/browser/db:safebrowsing_proto",
|
||||
"//components/vector_icons:vector_icons",
|
||||
"//components/vector_icons",
|
||||
"//ui/base/accelerators/global_accelerator_listener",
|
||||
"//ui/snapshot",
|
||||
"//ui/views/controls/webview",
|
||||
@@ -225,8 +223,8 @@ static_library("chrome") {
|
||||
sources += [
|
||||
"//chrome/browser/platform_util_aura.cc",
|
||||
"//chrome/browser/ui/views/eye_dropper/eye_dropper_aura.cc",
|
||||
"//ui/views/native_window_tracker_aura.cc",
|
||||
"//ui/views/native_window_tracker_aura.h",
|
||||
"//ui/native_window_tracker/native_window_tracker_aura.cc",
|
||||
"//ui/native_window_tracker/native_window_tracker_aura.h",
|
||||
]
|
||||
deps += [ "//components/eye_dropper" ]
|
||||
}
|
||||
@@ -282,6 +280,8 @@ static_library("chrome") {
|
||||
"//chrome/browser/process_singleton_mac.mm",
|
||||
"//chrome/browser/ui/views/eye_dropper/eye_dropper_view_mac.h",
|
||||
"//chrome/browser/ui/views/eye_dropper/eye_dropper_view_mac.mm",
|
||||
"//chrome/browser/ui/views/overlay/video_overlay_window_native_widget_mac.h",
|
||||
"//chrome/browser/ui/views/overlay/video_overlay_window_native_widget_mac.mm",
|
||||
]
|
||||
deps += [ ":system_media_capture_permissions_mac_conflict" ]
|
||||
}
|
||||
@@ -504,15 +504,17 @@ source_set("chrome_spellchecker") {
|
||||
]
|
||||
}
|
||||
|
||||
# These sources create an object file conflict with one in |:chrome|, so they
|
||||
# must live in a separate target.
|
||||
# Conflicting sources:
|
||||
# //chrome/browser/media/webrtc/system_media_capture_permissions_stats_mac.mm
|
||||
# //chrome/browser/permissions/system/system_media_capture_permissions_mac.mm
|
||||
source_set("system_media_capture_permissions_mac_conflict") {
|
||||
sources = [
|
||||
"//chrome/browser/permissions/system/system_media_capture_permissions_mac.h",
|
||||
"//chrome/browser/permissions/system/system_media_capture_permissions_mac.mm",
|
||||
]
|
||||
deps = [ "//chrome/common" ]
|
||||
if (is_mac) {
|
||||
# These sources create an object file conflict with one in |:chrome|, so they
|
||||
# must live in a separate target.
|
||||
# Conflicting sources:
|
||||
# //chrome/browser/media/webrtc/system_media_capture_permissions_stats_mac.mm
|
||||
# //chrome/browser/permissions/system/system_media_capture_permissions_mac.mm
|
||||
source_set("system_media_capture_permissions_mac_conflict") {
|
||||
sources = [
|
||||
"//chrome/browser/permissions/system/system_media_capture_permissions_mac.h",
|
||||
"//chrome/browser/permissions/system/system_media_capture_permissions_mac.mm",
|
||||
]
|
||||
deps = [ "//chrome/common" ]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,82 +0,0 @@
|
||||
# Accelerator
|
||||
|
||||
> Define keyboard shortcuts.
|
||||
|
||||
Accelerators are strings that can contain multiple modifiers and a single key code,
|
||||
combined by the `+` character, and are used to define keyboard shortcuts
|
||||
throughout your application. Accelerators are case insensitive.
|
||||
|
||||
Examples:
|
||||
|
||||
* `CommandOrControl+A`
|
||||
* `CommandOrControl+Shift+Z`
|
||||
|
||||
Shortcuts are registered with the [`globalShortcut`](global-shortcut.md) module
|
||||
using the [`register`](global-shortcut.md#globalshortcutregisteraccelerator-callback)
|
||||
method, i.e.
|
||||
|
||||
```js
|
||||
const { app, globalShortcut } = require('electron')
|
||||
|
||||
app.whenReady().then(() => {
|
||||
// Register a 'CommandOrControl+Y' shortcut listener.
|
||||
globalShortcut.register('CommandOrControl+Y', () => {
|
||||
// Do stuff when Y and either Command/Control is pressed.
|
||||
})
|
||||
})
|
||||
```
|
||||
|
||||
## Platform notice
|
||||
|
||||
On Linux and Windows, the `Command` key does not have any effect so
|
||||
use `CommandOrControl` which represents `Command` on macOS and `Control` on
|
||||
Linux and Windows to define some accelerators.
|
||||
|
||||
Use `Alt` instead of `Option`. The `Option` key only exists on macOS, whereas
|
||||
the `Alt` key is available on all platforms.
|
||||
|
||||
The `Super` (or `Meta`) key is mapped to the `Windows` key on Windows and Linux and
|
||||
`Cmd` on macOS.
|
||||
|
||||
## Available modifiers
|
||||
|
||||
* `Command` (or `Cmd` for short)
|
||||
* `Control` (or `Ctrl` for short)
|
||||
* `CommandOrControl` (or `CmdOrCtrl` for short)
|
||||
* `Alt`
|
||||
* `Option`
|
||||
* `AltGr`
|
||||
* `Shift`
|
||||
* `Super`
|
||||
* `Meta`
|
||||
|
||||
## Available key codes
|
||||
|
||||
* `0` to `9`
|
||||
* `A` to `Z`
|
||||
* `F1` to `F24`
|
||||
* Various Punctuation: `)`, `!`, `@`, `#`, `$`, `%`, `^`, `&`, `*`, `(`, `:`, `;`, `:`, `+`, `=`, `<`, `,`, `_`, `-`, `>`, `.`, `?`, `/`, `~`, `` ` ``, `{`, `]`, `[`, `|`, `\`, `}`, `"`
|
||||
* `Plus`
|
||||
* `Space`
|
||||
* `Tab`
|
||||
* `Capslock`
|
||||
* `Numlock`
|
||||
* `Scrolllock`
|
||||
* `Backspace`
|
||||
* `Delete`
|
||||
* `Insert`
|
||||
* `Return` (or `Enter` as alias)
|
||||
* `Up`, `Down`, `Left` and `Right`
|
||||
* `Home` and `End`
|
||||
* `PageUp` and `PageDown`
|
||||
* `Escape` (or `Esc` for short)
|
||||
* `VolumeUp`, `VolumeDown` and `VolumeMute`
|
||||
* `MediaNextTrack`, `MediaPreviousTrack`, `MediaStop` and `MediaPlayPause`
|
||||
* `PrintScreen`
|
||||
* NumPad Keys
|
||||
* `num0` - `num9`
|
||||
* `numdec` - decimal key
|
||||
* `numadd` - numpad `+` key
|
||||
* `numsub` - numpad `-` key
|
||||
* `nummult` - numpad `*` key
|
||||
* `numdiv` - numpad `÷` key
|
||||
@@ -602,6 +602,7 @@ Returns `string` - The current application directory.
|
||||
* `%APPDATA%` on Windows
|
||||
* `$XDG_CONFIG_HOME` or `~/.config` on Linux
|
||||
* `~/Library/Application Support` on macOS
|
||||
* `assets` The directory where app assets such as `resources.pak` are stored. By default this is the same as the folder containing the `exe` path. Available on Windows and Linux only.
|
||||
* `userData` The directory for storing your app's configuration files, which
|
||||
by default is the `appData` directory appended with your app's name. By
|
||||
convention files storing user data should be written to this directory, and
|
||||
@@ -616,7 +617,7 @@ Returns `string` - The current application directory.
|
||||
directory.
|
||||
* `temp` Temporary directory.
|
||||
* `exe` The current executable file.
|
||||
* `module` The `libchromiumcontent` library.
|
||||
* `module` The location of the Chromium module. By default this is synonymous with `exe`.
|
||||
* `desktop` The current user's Desktop directory.
|
||||
* `documents` Directory for a user's "My Documents".
|
||||
* `downloads` Directory for a user's downloads.
|
||||
@@ -776,6 +777,22 @@ bar, and on macOS, you can visit it from dock menu.
|
||||
|
||||
Clears the recent documents list.
|
||||
|
||||
### `app.getRecentDocuments()` _macOS_ _Windows_
|
||||
|
||||
Returns `string[]` - An array containing documents in the most recent documents list.
|
||||
|
||||
```js
|
||||
const { app } = require('electron')
|
||||
|
||||
const path = require('node:path')
|
||||
|
||||
const file = path.join(app.getPath('desktop'), 'foo.txt')
|
||||
app.addRecentDocument(file)
|
||||
|
||||
const recents = app.getRecentDocuments()
|
||||
console.log(recents) // ['/path/to/desktop/foo.txt'}
|
||||
```
|
||||
|
||||
### `app.setAsDefaultProtocolClient(protocol[, path, args])`
|
||||
|
||||
* `protocol` string - The name of your protocol, without `://`. For example,
|
||||
|
||||
@@ -1260,6 +1260,43 @@ Sets the properties for the window's taskbar button.
|
||||
> `relaunchCommand` and `relaunchDisplayName` must always be set
|
||||
> together. If one of those properties is not set, then neither will be used.
|
||||
|
||||
#### `win.setAccentColor(accentColor)` _Windows_
|
||||
|
||||
* `accentColor` boolean | string - The accent color for the window. By default, follows user preference in System Settings.
|
||||
|
||||
Sets the system accent color and highlighting of active window border.
|
||||
|
||||
The `accentColor` parameter accepts the following values:
|
||||
|
||||
* **Color string** - Sets a custom accent color using standard CSS color formats (Hex, RGB, RGBA, HSL, HSLA, or named colors). Alpha values in RGBA/HSLA formats are ignored and the color is treated as fully opaque.
|
||||
* **`true`** - Uses the system's default accent color from user preferences in System Settings.
|
||||
* **`false`** - Explicitly disables accent color highlighting for the window.
|
||||
|
||||
Examples:
|
||||
|
||||
```js
|
||||
const win = new BrowserWindow({ frame: false })
|
||||
|
||||
// Set red accent color.
|
||||
win.setAccentColor('#ff0000')
|
||||
|
||||
// RGB format (alpha ignored if present).
|
||||
win.setAccentColor('rgba(255,0,0,0.5)')
|
||||
|
||||
// Use system accent color.
|
||||
win.setAccentColor(true)
|
||||
|
||||
// Disable accent color.
|
||||
win.setAccentColor(false)
|
||||
```
|
||||
|
||||
#### `win.getAccentColor()` _Windows_
|
||||
|
||||
Returns `string | boolean` - the system accent color and highlighting of active window border in Hex RGB format.
|
||||
|
||||
If a color has been set for the window that differs from the system accent color, the window accent color will
|
||||
be returned. Otherwise, a boolean will be returned, with `true` indicating that the window uses the global system accent color, and `false` indicating that accent color highlighting is disabled for this window.
|
||||
|
||||
#### `win.setIcon(icon)` _Windows_ _Linux_
|
||||
|
||||
* `icon` [NativeImage](native-image.md) | string
|
||||
|
||||
@@ -1440,6 +1440,43 @@ Sets the properties for the window's taskbar button.
|
||||
> `relaunchCommand` and `relaunchDisplayName` must always be set
|
||||
> together. If one of those properties is not set, then neither will be used.
|
||||
|
||||
#### `win.setAccentColor(accentColor)` _Windows_
|
||||
|
||||
* `accentColor` boolean | string - The accent color for the window. By default, follows user preference in System Settings.
|
||||
|
||||
Sets the system accent color and highlighting of active window border.
|
||||
|
||||
The `accentColor` parameter accepts the following values:
|
||||
|
||||
* **Color string** - Sets a custom accent color using standard CSS color formats (Hex, RGB, RGBA, HSL, HSLA, or named colors). Alpha values in RGBA/HSLA formats are ignored and the color is treated as fully opaque.
|
||||
* **`true`** - Uses the system's default accent color from user preferences in System Settings.
|
||||
* **`false`** - Explicitly disables accent color highlighting for the window.
|
||||
|
||||
Examples:
|
||||
|
||||
```js
|
||||
const win = new BrowserWindow({ frame: false })
|
||||
|
||||
// Set red accent color.
|
||||
win.setAccentColor('#ff0000')
|
||||
|
||||
// RGB format (alpha ignored if present).
|
||||
win.setAccentColor('rgba(255,0,0,0.5)')
|
||||
|
||||
// Use system accent color.
|
||||
win.setAccentColor(true)
|
||||
|
||||
// Disable accent color.
|
||||
win.setAccentColor(false)
|
||||
```
|
||||
|
||||
#### `win.getAccentColor()` _Windows_
|
||||
|
||||
Returns `string | boolean` - the system accent color and highlighting of active window border in Hex RGB format.
|
||||
|
||||
If a color has been set for the window that differs from the system accent color, the window accent color will
|
||||
be returned. Otherwise, a boolean will be returned, with `true` indicating that the window uses the global system accent color, and `false` indicating that accent color highlighting is disabled for this window.
|
||||
|
||||
#### `win.showDefinitionForSelection()` _macOS_
|
||||
|
||||
Same as `webContents.showDefinitionForSelection()`.
|
||||
@@ -1533,8 +1570,8 @@ events.
|
||||
|
||||
Prevents the window contents from being captured by other apps.
|
||||
|
||||
On macOS it sets the NSWindow's sharingType to NSWindowSharingNone.
|
||||
On Windows it calls SetWindowDisplayAffinity with `WDA_EXCLUDEFROMCAPTURE`.
|
||||
On macOS it sets the NSWindow's [`sharingType`](https://developer.apple.com/documentation/appkit/nswindow/sharingtype-swift.property?language=objc) to [`NSWindowSharingNone`](https://developer.apple.com/documentation/appkit/nswindow/sharingtype-swift.enum/none?language=objc).
|
||||
On Windows it calls [`SetWindowDisplayAffinity`](https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setwindowdisplayaffinity) with `WDA_EXCLUDEFROMCAPTURE`.
|
||||
For Windows 10 version 2004 and up the window will be removed from capture entirely,
|
||||
older Windows versions behave as if `WDA_MONITOR` is applied capturing a black window.
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ Field trials to be forcefully enabled or disabled.
|
||||
|
||||
For example: `WebRTC-Audio-Red-For-Opus/Enabled/`
|
||||
|
||||
### --host-rules=`rules`
|
||||
### --host-rules=`rules` _Deprecated_
|
||||
|
||||
A comma-separated list of `rules` that control how hostnames are mapped.
|
||||
|
||||
@@ -104,9 +104,23 @@ These mappings apply to the endpoint host in a net request (the TCP connect
|
||||
and host resolver in a direct connection, and the `CONNECT` in an HTTP proxy
|
||||
connection, and the endpoint host in a `SOCKS` proxy connection).
|
||||
|
||||
**Deprecated:** Use the `--host-resolver-rules` switch instead.
|
||||
|
||||
### --host-resolver-rules=`rules`
|
||||
|
||||
Like `--host-rules` but these `rules` only apply to the host resolver.
|
||||
A comma-separated list of `rules` that control how hostnames are mapped.
|
||||
|
||||
For example:
|
||||
|
||||
* `MAP * 127.0.0.1` Forces all hostnames to be mapped to 127.0.0.1
|
||||
* `MAP *.google.com proxy` Forces all google.com subdomains to be resolved to
|
||||
"proxy".
|
||||
* `MAP test.com [::1]:77` Forces "test.com" to resolve to IPv6 loopback. Will
|
||||
also force the port of the resulting socket address to be 77.
|
||||
* `MAP * baz, EXCLUDE www.google.com` Remaps everything to "baz", except for
|
||||
"www.google.com".
|
||||
|
||||
These `rules` only apply to the host resolver.
|
||||
|
||||
### --ignore-certificate-errors
|
||||
|
||||
|
||||
@@ -157,6 +157,7 @@ has been included below for completeness:
|
||||
| [Cloneable Types](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm) | Simple | ✅ | ✅ | See the linked document on cloneable types |
|
||||
| `Element` | Complex | ✅ | ✅ | Prototype modifications are dropped. Sending custom elements will not work. |
|
||||
| `Blob` | Complex | ✅ | ✅ | N/A |
|
||||
| `VideoFrame` | Complex | ✅ | ✅ | N/A |
|
||||
| `Symbol` | N/A | ❌ | ❌ | Symbols cannot be copied across contexts so they are dropped |
|
||||
|
||||
If the type you care about is not in the above table, it is probably not supported.
|
||||
|
||||
@@ -51,19 +51,17 @@ Use the `system-ui` keyword to match the smoothness to the OS design language.
|
||||
|
||||
### Controlling availibility
|
||||
|
||||
This CSS rule can be disabled by setting [the `cornerSmoothingCSS` web preference](./structures/web-preferences.md) to `false`.
|
||||
This CSS rule can be disabled using the Blink feature flag `ElectronCSSCornerSmoothing`.
|
||||
|
||||
```js
|
||||
const myWindow = new BrowserWindow({
|
||||
// [...]
|
||||
webPreferences: {
|
||||
enableCornerSmoothingCSS: false // Disables the `-electron-corner-smoothing` CSS rule
|
||||
disableBlinkFeatures: 'ElectronCSSCornerSmoothing' // Disables the `-electron-corner-smoothing` CSS rule
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
The CSS rule will still parse, but will have no visual effect.
|
||||
|
||||
### Formal reference
|
||||
|
||||
* **Initial value**: `0%`
|
||||
|
||||
@@ -63,7 +63,7 @@ The `crashReporter` module has the following methods:
|
||||
* `extra` Record\<string, string\> (optional) - Extra string key/value
|
||||
annotations that will be sent along with crash reports that are generated
|
||||
in the main process. Only string values are supported. Crashes generated in
|
||||
child processes will not contain these extra
|
||||
child processes will not include these extra parameters. To add extra
|
||||
parameters to crash reports generated from child processes, call
|
||||
[`addExtraParameter`](#crashreporteraddextraparameterkey-value) from the
|
||||
child process.
|
||||
|
||||
@@ -5,13 +5,8 @@
|
||||
Process: [Main](../glossary.md#main-process)<br />
|
||||
_This class is not exported from the `'electron'` module. It is only available as a return value of other methods in the Electron API._
|
||||
|
||||
The following example shows how to bounce your icon on the dock.
|
||||
|
||||
```js
|
||||
const { app } = require('electron')
|
||||
|
||||
app.dock?.bounce()
|
||||
```
|
||||
> [!TIP]
|
||||
> See also: [A detailed guide about how to implement Dock menus](../tutorial/macos-dock.md).
|
||||
|
||||
### Instance Methods
|
||||
|
||||
@@ -50,6 +45,9 @@ Bounces the Downloads stack if the filePath is inside the Downloads folder.
|
||||
|
||||
Sets the string to be displayed in the dock’s badging area.
|
||||
|
||||
> [!IMPORTANT]
|
||||
> You need to ensure that your application has the permission to display notifications for this method to work.
|
||||
|
||||
#### `dock.getBadge()` _macOS_
|
||||
|
||||
Returns `string` - The badge string of the dock.
|
||||
|
||||
@@ -125,16 +125,6 @@ Options:
|
||||
* `kioclient5`
|
||||
* `kioclient`
|
||||
|
||||
### `ELECTRON_OZONE_PLATFORM_HINT` _Linux_
|
||||
|
||||
Selects the preferred platform backend used on Linux. The default one is `x11`. `auto` selects Wayland if possible, X11 otherwise.
|
||||
|
||||
Options:
|
||||
|
||||
* `auto`
|
||||
* `wayland`
|
||||
* `x11`
|
||||
|
||||
## Development Variables
|
||||
|
||||
The following environment variables are intended primarily for development and
|
||||
|
||||
@@ -46,13 +46,16 @@ app.on('will-quit', () => {
|
||||
})
|
||||
```
|
||||
|
||||
> [!TIP]
|
||||
> See also: [A detailed guide on Keyboard Shortcuts](../tutorial/keyboard-shortcuts.md).
|
||||
|
||||
## Methods
|
||||
|
||||
The `globalShortcut` module has the following methods:
|
||||
|
||||
### `globalShortcut.register(accelerator, callback)`
|
||||
|
||||
* `accelerator` [Accelerator](accelerator.md)
|
||||
* `accelerator` string - An [accelerator](../tutorial/keyboard-shortcuts.md#accelerators) shortcut.
|
||||
* `callback` Function
|
||||
|
||||
Returns `boolean` - Whether or not the shortcut was registered successfully.
|
||||
@@ -74,7 +77,7 @@ the app has been authorized as a [trusted accessibility client](https://develope
|
||||
|
||||
### `globalShortcut.registerAll(accelerators, callback)`
|
||||
|
||||
* `accelerators` [Accelerator](accelerator.md)[] - an array of [Accelerator](accelerator.md)s.
|
||||
* `accelerators` string[] - An array of [accelerator](../tutorial/keyboard-shortcuts.md#accelerators) shortcuts.
|
||||
* `callback` Function
|
||||
|
||||
Registers a global shortcut of all `accelerator` items in `accelerators`. The `callback` is called when any of the registered shortcuts are pressed by the user.
|
||||
@@ -93,7 +96,7 @@ the app has been authorized as a [trusted accessibility client](https://develope
|
||||
|
||||
### `globalShortcut.isRegistered(accelerator)`
|
||||
|
||||
* `accelerator` [Accelerator](accelerator.md)
|
||||
* `accelerator` string - An [accelerator](../tutorial/keyboard-shortcuts.md#accelerators) shortcut.
|
||||
|
||||
Returns `boolean` - Whether this application has registered `accelerator`.
|
||||
|
||||
@@ -103,7 +106,7 @@ don't want applications to fight for global shortcuts.
|
||||
|
||||
### `globalShortcut.unregister(accelerator)`
|
||||
|
||||
* `accelerator` [Accelerator](accelerator.md)
|
||||
* `accelerator` string - An [accelerator](../tutorial/keyboard-shortcuts.md#accelerators) shortcut.
|
||||
|
||||
Unregisters the global shortcut of `accelerator`.
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# MenuItem
|
||||
|
||||
## Class: MenuItem
|
||||
|
||||
> Add items to native application menus and context menus.
|
||||
@@ -19,7 +21,7 @@ See [`Menu`](menu.md) for examples.
|
||||
* `window` [BaseWindow](base-window.md) | undefined - This will not be defined if no window is open.
|
||||
* `event` [KeyboardEvent](structures/keyboard-event.md)
|
||||
* `role` string (optional) - Can be `undo`, `redo`, `cut`, `copy`, `paste`, `pasteAndMatchStyle`, `delete`, `selectAll`, `reload`, `forceReload`, `toggleDevTools`, `resetZoom`, `zoomIn`, `zoomOut`, `toggleSpellChecker`, `togglefullscreen`, `window`, `minimize`, `close`, `help`, `about`, `services`, `hide`, `hideOthers`, `unhide`, `quit`, `showSubstitutions`, `toggleSmartQuotes`, `toggleSmartDashes`, `toggleTextReplacement`, `startSpeaking`, `stopSpeaking`, `zoom`, `front`, `appMenu`, `fileMenu`, `editMenu`, `viewMenu`, `shareMenu`, `recentDocuments`, `toggleTabBar`, `selectNextTab`, `selectPreviousTab`, `showAllTabs`, `mergeAllWindows`, `clearRecentDocuments`, `moveTabToNewWindow` or `windowMenu` - Define the action of the menu item, when specified the
|
||||
`click` property will be ignored. See [roles](#roles).
|
||||
`click` property will be ignored. See [roles](../tutorial/menus.md#roles).
|
||||
* `type` string (optional)
|
||||
* `normal`
|
||||
* `separator`
|
||||
@@ -31,7 +33,7 @@ See [`Menu`](menu.md) for examples.
|
||||
* `label` string (optional)
|
||||
* `sublabel` string (optional) _macOS_ - Available in macOS >= 14.4
|
||||
* `toolTip` string (optional) _macOS_ - Hover text for this menu item.
|
||||
* `accelerator` [Accelerator](accelerator.md) (optional)
|
||||
* `accelerator` string (optional) - An [Accelerator](../tutorial/keyboard-shortcuts.md#accelerators) string.
|
||||
* `icon` ([NativeImage](native-image.md) | string) (optional)
|
||||
* `enabled` boolean (optional) - If false, the menu item will be greyed out and
|
||||
unclickable.
|
||||
@@ -64,88 +66,13 @@ See [`Menu`](menu.md) for examples.
|
||||
> [!NOTE]
|
||||
> `acceleratorWorksWhenHidden` is specified as being macOS-only because accelerators always work when items are hidden on Windows and Linux. The option is exposed to users to give them the option to turn it off, as this is possible in native macOS development.
|
||||
|
||||
### Roles
|
||||
|
||||
Roles allow menu items to have predefined behaviors.
|
||||
|
||||
It is best to specify `role` for any menu item that matches a standard role,
|
||||
rather than trying to manually implement the behavior in a `click` function.
|
||||
The built-in `role` behavior will give the best native experience.
|
||||
|
||||
The `label` and `accelerator` values are optional when using a `role` and will
|
||||
default to appropriate values for each platform.
|
||||
|
||||
Every menu item must have either a `role`, `label`, or in the case of a separator
|
||||
a `type`.
|
||||
|
||||
The `role` property can have following values:
|
||||
|
||||
* `undo`
|
||||
* `about` - Trigger a native about panel (custom message box on Window, which does not provide its own).
|
||||
* `redo`
|
||||
* `cut`
|
||||
* `copy`
|
||||
* `paste`
|
||||
* `pasteAndMatchStyle`
|
||||
* `selectAll`
|
||||
* `delete`
|
||||
* `minimize` - Minimize current window.
|
||||
* `close` - Close current window.
|
||||
* `quit` - Quit the application.
|
||||
* `reload` - Reload the current window.
|
||||
* `forceReload` - Reload the current window ignoring the cache.
|
||||
* `toggleDevTools` - Toggle developer tools in the current window.
|
||||
* `togglefullscreen` - Toggle full screen mode on the current window.
|
||||
* `resetZoom` - Reset the focused page's zoom level to the original size.
|
||||
* `zoomIn` - Zoom in the focused page by 10%.
|
||||
* `zoomOut` - Zoom out the focused page by 10%.
|
||||
* `toggleSpellChecker` - Enable/disable builtin spell checker.
|
||||
* `fileMenu` - Whole default "File" menu (Close / Quit)
|
||||
* `editMenu` - Whole default "Edit" menu (Undo, Copy, etc.).
|
||||
* `viewMenu` - Whole default "View" menu (Reload, Toggle Developer Tools, etc.)
|
||||
* `windowMenu` - Whole default "Window" menu (Minimize, Zoom, etc.).
|
||||
|
||||
The following additional roles are available on _macOS_:
|
||||
|
||||
* `appMenu` - Whole default "App" menu (About, Services, etc.)
|
||||
* `hide` - Map to the `hide` action.
|
||||
* `hideOthers` - Map to the `hideOtherApplications` action.
|
||||
* `unhide` - Map to the `unhideAllApplications` action.
|
||||
* `showSubstitutions` - Map to the `orderFrontSubstitutionsPanel` action.
|
||||
* `toggleSmartQuotes` - Map to the `toggleAutomaticQuoteSubstitution` action.
|
||||
* `toggleSmartDashes` - Map to the `toggleAutomaticDashSubstitution` action.
|
||||
* `toggleTextReplacement` - Map to the `toggleAutomaticTextReplacement` action.
|
||||
* `startSpeaking` - Map to the `startSpeaking` action.
|
||||
* `stopSpeaking` - Map to the `stopSpeaking` action.
|
||||
* `front` - Map to the `arrangeInFront` action.
|
||||
* `zoom` - Map to the `performZoom` action.
|
||||
* `toggleTabBar` - Map to the `toggleTabBar` action.
|
||||
* `selectNextTab` - Map to the `selectNextTab` action.
|
||||
* `selectPreviousTab` - Map to the `selectPreviousTab` action.
|
||||
* `showAllTabs` - Map to the `showAllTabs` action.
|
||||
* `mergeAllWindows` - Map to the `mergeAllWindows` action.
|
||||
* `moveTabToNewWindow` - Map to the `moveTabToNewWindow` action.
|
||||
* `window` - The submenu is a "Window" menu.
|
||||
* `help` - The submenu is a "Help" menu.
|
||||
* `services` - The submenu is a ["Services"](https://developer.apple.com/documentation/appkit/nsapplication/1428608-servicesmenu?language=objc) menu. This is only intended for use in the Application Menu and is _not_ the same as the "Services" submenu used in context menus in macOS apps, which is not implemented in Electron.
|
||||
* `recentDocuments` - The submenu is an "Open Recent" menu.
|
||||
* `clearRecentDocuments` - Map to the `clearRecentDocuments` action.
|
||||
* `shareMenu` - The submenu is [share menu][ShareMenu]. The `sharingItem` property must also be set to indicate the item to share.
|
||||
|
||||
When specifying a `role` on macOS, `label` and `accelerator` are the only
|
||||
options that will affect the menu item. All other options will be ignored.
|
||||
Lowercase `role`, e.g. `toggledevtools`, is still supported.
|
||||
|
||||
> [!NOTE]
|
||||
> The `enabled` and `visibility` properties are not available for top-level menu items in the tray on macOS.
|
||||
|
||||
### Instance Properties
|
||||
|
||||
The following properties are available on instances of `MenuItem`:
|
||||
|
||||
#### `menuItem.id`
|
||||
|
||||
A `string` indicating the item's unique id, this property can be
|
||||
A `string` indicating the item's unique id. This property can be
|
||||
dynamically changed.
|
||||
|
||||
#### `menuItem.label`
|
||||
@@ -203,17 +130,17 @@ A `string` indicating the item's hover text.
|
||||
|
||||
#### `menuItem.enabled`
|
||||
|
||||
A `boolean` indicating whether the item is enabled, this property can be
|
||||
A `boolean` indicating whether the item is enabled. This property can be
|
||||
dynamically changed.
|
||||
|
||||
#### `menuItem.visible`
|
||||
|
||||
A `boolean` indicating whether the item is visible, this property can be
|
||||
A `boolean` indicating whether the item is visible. This property can be
|
||||
dynamically changed.
|
||||
|
||||
#### `menuItem.checked`
|
||||
|
||||
A `boolean` indicating whether the item is checked, this property can be
|
||||
A `boolean` indicating whether the item is checked. This property can be
|
||||
dynamically changed.
|
||||
|
||||
A `checkbox` menu item will toggle the `checked` property on and off when
|
||||
@@ -244,5 +171,3 @@ A `number` indicating an item's sequential unique id.
|
||||
#### `menuItem.menu`
|
||||
|
||||
A `Menu` that the item is a part of.
|
||||
|
||||
[ShareMenu]: https://developer.apple.com/design/human-interface-guidelines/macos/extensions/share-extensions/
|
||||
|
||||
339
docs/api/menu.md
339
docs/api/menu.md
@@ -6,6 +6,9 @@
|
||||
|
||||
Process: [Main](../glossary.md#main-process)
|
||||
|
||||
> [!TIP]
|
||||
> See also: [A detailed guide about how to implement menus in your application](../tutorial/menus.md).
|
||||
|
||||
> [!WARNING]
|
||||
> Electron's built-in classes cannot be subclassed in user code.
|
||||
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
|
||||
@@ -20,7 +23,7 @@ The `Menu` class has the following static methods:
|
||||
|
||||
#### `Menu.setApplicationMenu(menu)`
|
||||
|
||||
* `menu` Menu | null
|
||||
- `menu` Menu | null
|
||||
|
||||
Sets `menu` as the application menu on macOS. On Windows and Linux, the
|
||||
`menu` will be set as each window's top menu.
|
||||
@@ -51,18 +54,18 @@ Returns `Menu | null` - The application menu, if set, or `null`, if not set.
|
||||
|
||||
#### `Menu.sendActionToFirstResponder(action)` _macOS_
|
||||
|
||||
* `action` string
|
||||
- `action` string
|
||||
|
||||
Sends the `action` to the first responder of application. This is used for
|
||||
emulating default macOS menu behaviors. Usually you would use the
|
||||
[`role`](menu-item.md#roles) property of a [`MenuItem`](menu-item.md).
|
||||
[`role`](../tutorial/menus.md#roles) property of a [`MenuItem`](menu-item.md).
|
||||
|
||||
See the [macOS Cocoa Event Handling Guide](https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/EventOverview/EventArchitecture/EventArchitecture.html#//apple_ref/doc/uid/10000060i-CH3-SW7)
|
||||
for more information on macOS' native actions.
|
||||
|
||||
#### `Menu.buildFromTemplate(template)`
|
||||
|
||||
* `template` (MenuItemConstructorOptions | MenuItem)[]
|
||||
- `template` (MenuItemConstructorOptions | MenuItem)[]
|
||||
|
||||
Returns `Menu`
|
||||
|
||||
@@ -77,47 +80,50 @@ The `menu` object has the following instance methods:
|
||||
|
||||
#### `menu.popup([options])`
|
||||
|
||||
* `options` Object (optional)
|
||||
* `window` [BaseWindow](base-window.md) (optional) - Default is the focused window.
|
||||
* `frame` [WebFrameMain](web-frame-main.md) (optional) - Provide the relevant frame
|
||||
- `options` Object (optional)
|
||||
- `window` [BaseWindow](base-window.md) (optional) - Default is the focused window.
|
||||
- `frame` [WebFrameMain](web-frame-main.md) (optional) - Provide the relevant frame
|
||||
if you want certain OS-level features such as Writing Tools on macOS to function correctly. Typically, this should be `params.frame` from the [`context-menu` event](web-contents.md#event-context-menu) on a WebContents, or the [`focusedFrame` property](web-contents.md#contentsfocusedframe-readonly) of a WebContents.
|
||||
* `x` number (optional) - Default is the current mouse cursor position.
|
||||
- `x` number (optional) - Default is the current mouse cursor position.
|
||||
Must be declared if `y` is declared.
|
||||
* `y` number (optional) - Default is the current mouse cursor position.
|
||||
- `y` number (optional) - Default is the current mouse cursor position.
|
||||
Must be declared if `x` is declared.
|
||||
* `positioningItem` number (optional) _macOS_ - The index of the menu item to
|
||||
- `positioningItem` number (optional) _macOS_ - The index of the menu item to
|
||||
be positioned under the mouse cursor at the specified coordinates. Default
|
||||
is -1.
|
||||
* `sourceType` string (optional) _Windows_ _Linux_ - This should map to the `menuSourceType`
|
||||
- `sourceType` string (optional) _Windows_ _Linux_ - This should map to the `menuSourceType`
|
||||
provided by the `context-menu` event. It is not recommended to set this value manually,
|
||||
only provide values you receive from other APIs or leave it `undefined`.
|
||||
Can be `none`, `mouse`, `keyboard`, `touch`, `touchMenu`, `longPress`, `longTap`, `touchHandle`, `stylus`, `adjustSelection`, or `adjustSelectionReset`.
|
||||
* `callback` Function (optional) - Called when menu is closed.
|
||||
- `callback` Function (optional) - Called when menu is closed.
|
||||
|
||||
Pops up this menu as a context menu in the [`BaseWindow`](base-window.md).
|
||||
|
||||
> [!TIP]
|
||||
> For more details, see the [Context Menu](../tutorial/context-menu.md) guide.
|
||||
|
||||
#### `menu.closePopup([window])`
|
||||
|
||||
* `window` [BaseWindow](base-window.md) (optional) - Default is the focused window.
|
||||
- `window` [BaseWindow](base-window.md) (optional) - Default is the focused window.
|
||||
|
||||
Closes the context menu in the `window`.
|
||||
|
||||
#### `menu.append(menuItem)`
|
||||
|
||||
* `menuItem` [MenuItem](menu-item.md)
|
||||
- `menuItem` [MenuItem](menu-item.md)
|
||||
|
||||
Appends the `menuItem` to the menu.
|
||||
|
||||
#### `menu.getMenuItemById(id)`
|
||||
|
||||
* `id` string
|
||||
- `id` string
|
||||
|
||||
Returns `MenuItem | null` the item with the specified `id`
|
||||
|
||||
#### `menu.insert(pos, menuItem)`
|
||||
|
||||
* `pos` Integer
|
||||
* `menuItem` [MenuItem](menu-item.md)
|
||||
- `pos` Integer
|
||||
- `menuItem` [MenuItem](menu-item.md)
|
||||
|
||||
Inserts the `menuItem` to the `pos` position of the menu.
|
||||
|
||||
@@ -133,7 +139,7 @@ Objects created with `new Menu` or returned by `Menu.buildFromTemplate` emit the
|
||||
|
||||
Returns:
|
||||
|
||||
* `event` Event
|
||||
- `event` Event
|
||||
|
||||
Emitted when `menu.popup()` is called.
|
||||
|
||||
@@ -141,7 +147,7 @@ Emitted when `menu.popup()` is called.
|
||||
|
||||
Returns:
|
||||
|
||||
* `event` Event
|
||||
- `event` Event
|
||||
|
||||
Emitted when a popup is closed either manually or with `menu.closePopup()`.
|
||||
|
||||
@@ -153,296 +159,5 @@ Emitted when a popup is closed either manually or with `menu.closePopup()`.
|
||||
|
||||
A `MenuItem[]` array containing the menu's items.
|
||||
|
||||
Each `Menu` consists of multiple [`MenuItem`](menu-item.md)s and each `MenuItem`
|
||||
can have a submenu.
|
||||
|
||||
## Examples
|
||||
|
||||
An example of creating the application menu with the simple template API:
|
||||
|
||||
```js @ts-expect-error=[107]
|
||||
const { app, Menu } = require('electron')
|
||||
|
||||
const isMac = process.platform === 'darwin'
|
||||
|
||||
const template = [
|
||||
// { role: 'appMenu' }
|
||||
...(isMac
|
||||
? [{
|
||||
label: app.name,
|
||||
submenu: [
|
||||
{ role: 'about' },
|
||||
{ type: 'separator' },
|
||||
{ role: 'services' },
|
||||
{ type: 'separator' },
|
||||
{ role: 'hide' },
|
||||
{ role: 'hideOthers' },
|
||||
{ role: 'unhide' },
|
||||
{ type: 'separator' },
|
||||
{ role: 'quit' }
|
||||
]
|
||||
}]
|
||||
: []),
|
||||
// { role: 'fileMenu' }
|
||||
{
|
||||
label: 'File',
|
||||
submenu: [
|
||||
isMac ? { role: 'close' } : { role: 'quit' }
|
||||
]
|
||||
},
|
||||
// { role: 'editMenu' }
|
||||
{
|
||||
label: 'Edit',
|
||||
submenu: [
|
||||
{ role: 'undo' },
|
||||
{ role: 'redo' },
|
||||
{ type: 'separator' },
|
||||
{ role: 'cut' },
|
||||
{ role: 'copy' },
|
||||
{ role: 'paste' },
|
||||
...(isMac
|
||||
? [
|
||||
{ role: 'pasteAndMatchStyle' },
|
||||
{ role: 'delete' },
|
||||
{ role: 'selectAll' },
|
||||
{ type: 'separator' },
|
||||
{
|
||||
label: 'Speech',
|
||||
submenu: [
|
||||
{ role: 'startSpeaking' },
|
||||
{ role: 'stopSpeaking' }
|
||||
]
|
||||
}
|
||||
]
|
||||
: [
|
||||
{ role: 'delete' },
|
||||
{ type: 'separator' },
|
||||
{ role: 'selectAll' }
|
||||
])
|
||||
]
|
||||
},
|
||||
// { role: 'viewMenu' }
|
||||
{
|
||||
label: 'View',
|
||||
submenu: [
|
||||
{ role: 'reload' },
|
||||
{ role: 'forceReload' },
|
||||
{ role: 'toggleDevTools' },
|
||||
{ type: 'separator' },
|
||||
{ role: 'resetZoom' },
|
||||
{ role: 'zoomIn' },
|
||||
{ role: 'zoomOut' },
|
||||
{ type: 'separator' },
|
||||
{ role: 'togglefullscreen' }
|
||||
]
|
||||
},
|
||||
// { role: 'windowMenu' }
|
||||
{
|
||||
label: 'Window',
|
||||
submenu: [
|
||||
{ role: 'minimize' },
|
||||
{ role: 'zoom' },
|
||||
...(isMac
|
||||
? [
|
||||
{ type: 'separator' },
|
||||
{ role: 'front' },
|
||||
{ type: 'separator' },
|
||||
{ role: 'window' }
|
||||
]
|
||||
: [
|
||||
{ role: 'close' }
|
||||
])
|
||||
]
|
||||
},
|
||||
{
|
||||
role: 'help',
|
||||
submenu: [
|
||||
{
|
||||
label: 'Learn More',
|
||||
click: async () => {
|
||||
const { shell } = require('electron')
|
||||
await shell.openExternal('https://electronjs.org')
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
const menu = Menu.buildFromTemplate(template)
|
||||
Menu.setApplicationMenu(menu)
|
||||
```
|
||||
|
||||
### Render process
|
||||
|
||||
To create menus initiated by the renderer process, send the required
|
||||
information to the main process using IPC and have the main process display the
|
||||
menu on behalf of the renderer.
|
||||
|
||||
Below is an example of showing a menu when the user right clicks the page:
|
||||
|
||||
```js @ts-expect-error=[21]
|
||||
// renderer
|
||||
window.addEventListener('contextmenu', (e) => {
|
||||
e.preventDefault()
|
||||
ipcRenderer.send('show-context-menu')
|
||||
})
|
||||
|
||||
ipcRenderer.on('context-menu-command', (e, command) => {
|
||||
// ...
|
||||
})
|
||||
|
||||
// main
|
||||
ipcMain.on('show-context-menu', (event) => {
|
||||
const template = [
|
||||
{
|
||||
label: 'Menu Item 1',
|
||||
click: () => { event.sender.send('context-menu-command', 'menu-item-1') }
|
||||
},
|
||||
{ type: 'separator' },
|
||||
{ label: 'Menu Item 2', type: 'checkbox', checked: true }
|
||||
]
|
||||
const menu = Menu.buildFromTemplate(template)
|
||||
menu.popup({ window: BrowserWindow.fromWebContents(event.sender) })
|
||||
})
|
||||
```
|
||||
|
||||
## Notes on macOS Application Menu
|
||||
|
||||
macOS has a completely different style of application menu from Windows and
|
||||
Linux. Here are some notes on making your app's menu more native-like.
|
||||
|
||||
### Standard Menus
|
||||
|
||||
On macOS there are many system-defined standard menus, like the [`Services`](https://developer.apple.com/documentation/appkit/nsapplication/1428608-servicesmenu?language=objc) and
|
||||
`Windows` menus. To make your menu a standard menu, you should set your menu's
|
||||
`role` to one of the following and Electron will recognize them and make them
|
||||
become standard menus:
|
||||
|
||||
* `window`
|
||||
* `help`
|
||||
* `services`
|
||||
|
||||
### Standard Menu Item Actions
|
||||
|
||||
macOS has provided standard actions for some menu items, like `About xxx`,
|
||||
`Hide xxx`, and `Hide Others`. To set the action of a menu item to a standard
|
||||
action, you should set the `role` attribute of the menu item.
|
||||
|
||||
### Main Menu's Name
|
||||
|
||||
On macOS the label of the application menu's first item is always your app's
|
||||
name, no matter what label you set. To change it, modify your app bundle's
|
||||
`Info.plist` file. See
|
||||
[About Information Property List Files][AboutInformationPropertyListFiles]
|
||||
for more information.
|
||||
|
||||
### Menu Sublabels
|
||||
|
||||
Menu sublabels, or [subtitles](https://developer.apple.com/documentation/appkit/nsmenuitem/subtitle?language=objc), can be added to menu items using the `sublabel` option. Below is an example based on the renderer example above:
|
||||
|
||||
```js @ts-expect-error=[12]
|
||||
// main
|
||||
ipcMain.on('show-context-menu', (event) => {
|
||||
const template = [
|
||||
{
|
||||
label: 'Menu Item 1',
|
||||
sublabel: 'Subtitle 1',
|
||||
click: () => { event.sender.send('context-menu-command', 'menu-item-1') }
|
||||
},
|
||||
{ type: 'separator' },
|
||||
{ label: 'Menu Item 2', sublabel: 'Subtitle 2', type: 'checkbox', checked: true }
|
||||
]
|
||||
const menu = Menu.buildFromTemplate(template)
|
||||
menu.popup({ window: BrowserWindow.fromWebContents(event.sender) })
|
||||
})
|
||||
```
|
||||
|
||||
## Setting Menu for Specific Browser Window (_Linux_ _Windows_)
|
||||
|
||||
The [`setMenu` method][setMenu] of browser windows can set the menu of certain
|
||||
browser windows.
|
||||
|
||||
## Menu Item Position
|
||||
|
||||
You can make use of `before`, `after`, `beforeGroupContaining`, `afterGroupContaining` and `id` to control how the item will be placed when building a menu with `Menu.buildFromTemplate`.
|
||||
|
||||
* `before` - Inserts this item before the item with the specified id. If the
|
||||
referenced item doesn't exist the item will be inserted at the end of
|
||||
the menu. Also implies that the menu item in question should be placed in the same “group” as the item.
|
||||
* `after` - Inserts this item after the item with the specified id. If the
|
||||
referenced item doesn't exist the item will be inserted at the end of
|
||||
the menu. Also implies that the menu item in question should be placed in the same “group” as the item.
|
||||
* `beforeGroupContaining` - Provides a means for a single context menu to declare
|
||||
the placement of their containing group before the containing group of the item with the specified id.
|
||||
* `afterGroupContaining` - Provides a means for a single context menu to declare
|
||||
the placement of their containing group after the containing group of the item with the specified id.
|
||||
|
||||
By default, items will be inserted in the order they exist in the template unless one of the specified positioning keywords is used.
|
||||
|
||||
### Examples
|
||||
|
||||
Template:
|
||||
|
||||
```js
|
||||
[
|
||||
{ id: '1', label: 'one' },
|
||||
{ id: '2', label: 'two' },
|
||||
{ id: '3', label: 'three' },
|
||||
{ id: '4', label: 'four' }
|
||||
]
|
||||
```
|
||||
|
||||
Menu:
|
||||
|
||||
```sh
|
||||
- 1
|
||||
- 2
|
||||
- 3
|
||||
- 4
|
||||
```
|
||||
|
||||
Template:
|
||||
|
||||
```js
|
||||
[
|
||||
{ id: '1', label: 'one' },
|
||||
{ type: 'separator' },
|
||||
{ id: '3', label: 'three', beforeGroupContaining: ['1'] },
|
||||
{ id: '4', label: 'four', afterGroupContaining: ['2'] },
|
||||
{ type: 'separator' },
|
||||
{ id: '2', label: 'two' }
|
||||
]
|
||||
```
|
||||
|
||||
Menu:
|
||||
|
||||
```sh
|
||||
- 3
|
||||
- 4
|
||||
- ---
|
||||
- 1
|
||||
- ---
|
||||
- 2
|
||||
```
|
||||
|
||||
Template:
|
||||
|
||||
```js
|
||||
[
|
||||
{ id: '1', label: 'one', after: ['3'] },
|
||||
{ id: '2', label: 'two', before: ['1'] },
|
||||
{ id: '3', label: 'three' }
|
||||
]
|
||||
```
|
||||
|
||||
Menu:
|
||||
|
||||
```sh
|
||||
- ---
|
||||
- 3
|
||||
- 2
|
||||
- 1
|
||||
```
|
||||
|
||||
[AboutInformationPropertyListFiles]: https://developer.apple.com/library/ios/documentation/general/Reference/InfoPlistKeyReference/Articles/AboutInformationPropertyListFiles.html
|
||||
[setMenu]: browser-window.md#winsetmenumenu-linux-windows
|
||||
Each `Menu` consists of multiple [`MenuItem`](menu-item.md) instances and each `MenuItem`
|
||||
can nest a `Menu` into its `submenu` property.
|
||||
|
||||
@@ -211,6 +211,10 @@ Returns `Object`:
|
||||
system.
|
||||
* `free` Integer - The total amount of memory not being used by applications or disk
|
||||
cache.
|
||||
* `fileBacked` Integer _macOS_ - The amount of memory that currently has been paged out to storage.
|
||||
Includes memory for file caches, network buffers, and other system services.
|
||||
* `purgeable` Integer _macOS_ - The amount of memory that is marked as "purgeable". The system can reclaim it
|
||||
if memory pressure increases.
|
||||
* `swapTotal` Integer _Windows_ _Linux_ - The total amount of swap memory in Kilobytes available to the
|
||||
system.
|
||||
* `swapFree` Integer _Windows_ _Linux_ - The free amount of swap memory in Kilobytes available to the
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
# ServiceWorkerMain
|
||||
## Class: ServiceWorkerMain
|
||||
|
||||
> An instance of a Service Worker representing a version of a script for a given scope.
|
||||
|
||||
Process: [Main](../glossary.md#main-process)
|
||||
|
||||
## Class: ServiceWorkerMain
|
||||
|
||||
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._
|
||||
|
||||
|
||||
@@ -939,14 +939,18 @@ session.fromPartition('some-partition').setPermissionRequestHandler((webContents
|
||||
* `top-level-storage-access` - Allow top-level sites to request third-party cookie access on behalf of embedded content originating from another site in the same related website set using the [Storage Access API](https://developer.mozilla.org/en-US/docs/Web/API/Storage_Access_API).
|
||||
* `usb` - Expose non-standard Universal Serial Bus (USB) compatible devices services to the web with the [WebUSB API](https://developer.mozilla.org/en-US/docs/Web/API/WebUSB_API).
|
||||
* `deprecated-sync-clipboard-read` _Deprecated_ - Request access to run `document.execCommand("paste")`
|
||||
* `fileSystem` - Access to read, write, and file management capabilities using the [File System API](https://developer.mozilla.org/en-US/docs/Web/API/File_System_API).
|
||||
* `requestingOrigin` string - The origin URL of the permission check
|
||||
* `details` Object - Some properties are only available on certain permission types.
|
||||
* `embeddingOrigin` string (optional) - The origin of the frame embedding the frame that made the permission check. Only set for cross-origin sub frames making permission checks.
|
||||
* `securityOrigin` string (optional) - The security origin of the `media` check.
|
||||
* `mediaType` string (optional) - The type of media access being requested, can be `video`,
|
||||
`audio` or `unknown`
|
||||
`audio` or `unknown`.
|
||||
* `requestingUrl` string (optional) - The last URL the requesting frame loaded. This is not provided for cross-origin sub frames making permission checks.
|
||||
* `isMainFrame` boolean - Whether the frame making the request is the main frame
|
||||
* `isMainFrame` boolean - Whether the frame making the request is the main frame.
|
||||
* `filePath` string (optional) - The path of a `fileSystem` request.
|
||||
* `isDirectory` boolean (optional) - Whether a `fileSystem` request is a directory.
|
||||
* `fileAccessType` string (optional) - The access type of a `fileSystem` request. Can be `writable` or `readable`.
|
||||
|
||||
Sets the handler which can be used to respond to permission checks for the `session`.
|
||||
Returning `true` will allow the permission and `false` will reject it. Please note that
|
||||
@@ -968,6 +972,9 @@ session.fromPartition('some-partition').setPermissionCheckHandler((webContents,
|
||||
})
|
||||
```
|
||||
|
||||
> [!NOTE]
|
||||
> `isMainFrame` will always be `false` for a `fileSystem` request as a result of Chromium limitations.
|
||||
|
||||
#### `ses.setDisplayMediaRequestHandler(handler[, opts])`
|
||||
|
||||
* `handler` Function | null
|
||||
|
||||
@@ -2,5 +2,5 @@
|
||||
|
||||
* `type` string - The type of the event, can be `rawKeyDown`, `keyDown`, `keyUp` or `char`.
|
||||
* `keyCode` string - The character that will be sent
|
||||
as the keyboard event. Should only use the valid key codes in
|
||||
[Accelerator](../accelerator.md).
|
||||
as the keyboard event. Should only use valid [Accelerator](../../tutorial/keyboard-shortcuts.md#accelerators)
|
||||
key codes.
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
* `widgetType` string - The widget type of the texture. Can be `popup` or `frame`.
|
||||
* `pixelFormat` string - The pixel format of the texture. Can be `rgba` or `bgra`.
|
||||
* `codedSize` [Size](size.md) - The full dimensions of the video frame.
|
||||
* `visibleRect` [Rectangle](rectangle.md) - A subsection of [0, 0, codedSize.width(), codedSize.height()]. In OSR case, it is expected to have the full section area.
|
||||
* `colorSpace` [ColorSpace](color-space.md) - The color space of the video frame.
|
||||
* `visibleRect` [Rectangle](rectangle.md) - A subsection of [0, 0, codedSize.width, codedSize.height]. In OSR case, it is expected to have the full section area.
|
||||
* `contentRect` [Rectangle](rectangle.md) - The region of the video frame that capturer would like to populate. In OSR case, it is the same with `dirtyRect` that needs to be painted.
|
||||
* `timestamp` number - The time in microseconds since the capture start.
|
||||
* `metadata` Object - Extra metadata. See comments in src\media\base\video_frame_metadata.h for accurate details.
|
||||
@@ -12,13 +13,6 @@
|
||||
* `regionCaptureRect` [Rectangle](rectangle.md) (optional) - May reflect the frame's contents origin if region capture is used internally.
|
||||
* `sourceSize` [Rectangle](rectangle.md) (optional) - Full size of the source frame.
|
||||
* `frameCount` number (optional) - The increasing count of captured frame. May contain gaps if frames are dropped between two consecutively received frames.
|
||||
* `sharedTextureHandle` Buffer _Windows_ _macOS_ - The handle to the shared texture.
|
||||
* `planes` Object[] _Linux_ - Each plane's info of the shared texture.
|
||||
* `stride` number - The strides and offsets in bytes to be used when accessing the buffers via a memory mapping. One per plane per entry.
|
||||
* `offset` number - The strides and offsets in bytes to be used when accessing the buffers via a memory mapping. One per plane per entry.
|
||||
* `size` number - Size in bytes of the plane. This is necessary to map the buffers.
|
||||
* `fd` number - File descriptor for the underlying memory object (usually dmabuf).
|
||||
* `modifier` string _Linux_ - The modifier is retrieved from GBM library and passed to EGL driver.
|
||||
* `handle` [SharedTextureHandle](shared-texture-handle.md) - The shared texture handle data.
|
||||
* `release` Function - Release the resources. The `texture` cannot be directly passed to another process, users need to maintain texture lifecycles in
|
||||
main process, but it is safe to pass the `textureInfo` to another process. Only a limited number of textures can exist at the same time, so it's important
|
||||
that you call `texture.release()` as soon as you're done with the texture.
|
||||
main process, but it is safe to pass the `textureInfo` to another process. Only a limited number of textures can exist at the same time, so it's important that you call `texture.release()` as soon as you're done with the texture.
|
||||
|
||||
12
docs/api/structures/shared-texture-handle.md
Normal file
12
docs/api/structures/shared-texture-handle.md
Normal file
@@ -0,0 +1,12 @@
|
||||
# SharedTextureHandle Object
|
||||
|
||||
* `ntHandle` Buffer (optional) _Windows_ - NT HANDLE holds the shared texture. Note that this NT HANDLE is local to current process.
|
||||
* `ioSurface` Buffer (optional) _macOS_ - IOSurfaceRef holds the shared texture. Note that this IOSurface is local to current process (not global).
|
||||
* `nativePixmap` Object (optional) _Linux_ - Structure contains planes of shared texture.
|
||||
* `planes` Object[] _Linux_ - Each plane's info of the shared texture.
|
||||
* `stride` number - The strides and offsets in bytes to be used when accessing the buffers via a memory mapping. One per plane per entry.
|
||||
* `offset` number - The strides and offsets in bytes to be used when accessing the buffers via a memory mapping. One per plane per entry.
|
||||
* `size` number - Size in bytes of the plane. This is necessary to map the buffers.
|
||||
* `fd` number - File descriptor for the underlying memory object (usually dmabuf).
|
||||
* `modifier` string _Linux_ - The modifier is retrieved from GBM library and passed to EGL driver.
|
||||
* `supportsZeroCopyWebGpuImport` boolean _Linux_ - Indicates whether supports zero copy import to WebGPU.
|
||||
@@ -149,7 +149,6 @@
|
||||
`WebContents` when the preferred size changes. Default is `false`.
|
||||
* `transparent` boolean (optional) - Whether to enable background transparency for the guest page. Default is `true`. **Note:** The guest page's text and background colors are derived from the [color scheme](https://developer.mozilla.org/en-US/docs/Web/CSS/color-scheme) of its root element. When transparency is enabled, the text color will still change accordingly but the background will remain transparent.
|
||||
* `enableDeprecatedPaste` boolean (optional) _Deprecated_ - Whether to enable the `paste` [execCommand](https://developer.mozilla.org/en-US/docs/Web/API/Document/execCommand). Default is `false`.
|
||||
* `enableCornerSmoothingCSS` boolean (optional) _Experimental_ - Whether the [`-electron-corner-smoothing` CSS rule](../corner-smoothing-css.md) is enabled. Default is `true`.
|
||||
|
||||
[chrome-content-scripts]: https://developer.chrome.com/extensions/content_scripts#execution-environment
|
||||
[runtime-enabled-features]: https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/platform/runtime_enabled_features.json5
|
||||
|
||||
@@ -8,7 +8,7 @@ Process: [Main](../glossary.md#main-process)
|
||||
|
||||
`Tray` is an [EventEmitter][event-emitter].
|
||||
|
||||
```js
|
||||
```js title='Creating a basic tray menu'
|
||||
const { app, Menu, Tray } = require('electron')
|
||||
|
||||
let tray = null
|
||||
@@ -25,6 +25,9 @@ app.whenReady().then(() => {
|
||||
})
|
||||
```
|
||||
|
||||
> [!TIP]
|
||||
> See also: [A detailed guide about how to implement Tray menus](../tutorial/tray.md).
|
||||
|
||||
> [!WARNING]
|
||||
> Electron's built-in classes cannot be subclassed in user code.
|
||||
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
|
||||
@@ -76,7 +79,15 @@ app.whenReady().then(() => {
|
||||
### `new Tray(image, [guid])`
|
||||
|
||||
* `image` ([NativeImage](native-image.md) | string)
|
||||
* `guid` string (optional) _Windows_ - Assigns a GUID to the tray icon. If the executable is signed and the signature contains an organization in the subject line then the GUID is permanently associated with that signature. OS level settings like the position of the tray icon in the system tray will persist even if the path to the executable changes. If the executable is not code-signed then the GUID is permanently associated with the path to the executable. Changing the path to the executable will break the creation of the tray icon and a new GUID must be used. However, it is highly recommended to use the GUID parameter only in conjunction with code-signed executable. If an App defines multiple tray icons then each icon must use a separate GUID.
|
||||
* `guid` string (optional) _Windows_ _macOS_ - A unique string used to identify the tray icon. Must adhere to [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier) format.
|
||||
|
||||
**Windows**
|
||||
|
||||
On Windows, if the executable is signed and the signature contains an organization in the subject line then the GUID is permanently associated with that signature. OS level settings like the position of the tray icon in the system tray will persist even if the path to the executable changes. If the executable is not code-signed then the GUID is permanently associated with the path to the executable. Changing the path to the executable will break the creation of the tray icon and a new GUID must be used. However, it is highly recommended to use the GUID parameter only in conjunction with code-signed executable. If an App defines multiple tray icons then each icon must use a separate GUID.
|
||||
|
||||
**MacOS**
|
||||
|
||||
On macOS, the `guid` is a string used to uniquely identify the tray icon and allow it to retain its position between relaunches. Using the same string for a new tray item will create it in the same position as the previous tray item to use the string.
|
||||
|
||||
Creates a new tray icon associated with the `image`.
|
||||
|
||||
@@ -324,8 +335,56 @@ Returns [`Rectangle`](structures/rectangle.md)
|
||||
|
||||
The `bounds` of this tray icon as `Object`.
|
||||
|
||||
#### `tray.getGUID()` _macOS_ _Windows_
|
||||
|
||||
Returns `string | null` - The GUID used to uniquely identify the tray icon and allow it to retain its position between relaunches, or null if none is set.
|
||||
|
||||
#### `tray.isDestroyed()`
|
||||
|
||||
Returns `boolean` - Whether the tray icon is destroyed.
|
||||
|
||||
[event-emitter]: https://nodejs.org/api/events.html#events_class_eventemitter
|
||||
|
||||
## Platform considerations
|
||||
|
||||
### Linux
|
||||
|
||||
* Tray icon uses [StatusNotifierItem](https://www.freedesktop.org/wiki/Specifications/StatusNotifierItem/)
|
||||
by default, when it is not available in user's desktop environment the
|
||||
`GtkStatusIcon` will be used instead.
|
||||
* The `click` event is emitted when the tray icon receives activation from
|
||||
user, however the StatusNotifierItem spec does not specify which action would
|
||||
cause an activation, for some environments it is left mouse click, but for
|
||||
some it might be double left mouse click.
|
||||
* In order for changes made to individual `MenuItem`s to take effect,
|
||||
you have to call `setContextMenu` again. For example:
|
||||
|
||||
```js
|
||||
const { app, Menu, Tray } = require('electron')
|
||||
|
||||
let appIcon = null
|
||||
app.whenReady().then(() => {
|
||||
appIcon = new Tray('/path/to/my/icon')
|
||||
const contextMenu = Menu.buildFromTemplate([
|
||||
{ label: 'Item1', type: 'radio' },
|
||||
{ label: 'Item2', type: 'radio' }
|
||||
])
|
||||
|
||||
// Make a change to the context menu
|
||||
contextMenu.items[1].checked = false
|
||||
|
||||
// Call this again for Linux because we modified the context menu
|
||||
appIcon.setContextMenu(contextMenu)
|
||||
})
|
||||
```
|
||||
|
||||
### macOS
|
||||
|
||||
* Icons passed to the Tray constructor should be [Template Images](native-image.md#template-image-macos).
|
||||
* To make sure your icon isn't grainy on retina monitors, be sure your `@2x` image is 144dpi.
|
||||
* If you are bundling your application (e.g., with webpack for development), be sure that the file names are not being mangled or hashed. The filename needs to end in Template, and the `@2x` image needs to have the same filename as the standard image, or MacOS will not magically invert your image's colors or use the high density image.
|
||||
* 16x16 (72dpi) and 32x32@2x (144dpi) work well for most icons.
|
||||
|
||||
### Windows
|
||||
|
||||
* It is recommended to use `ICO` icons to get best visual effects.
|
||||
|
||||
@@ -486,16 +486,6 @@ Emitted when the web page becomes unresponsive.
|
||||
|
||||
Emitted when the unresponsive web page becomes responsive again.
|
||||
|
||||
#### Event: 'plugin-crashed'
|
||||
|
||||
Returns:
|
||||
|
||||
* `event` Event
|
||||
* `name` string
|
||||
* `version` string
|
||||
|
||||
Emitted when a plugin process has crashed.
|
||||
|
||||
#### Event: 'destroyed'
|
||||
|
||||
Emitted when `webContents` is destroyed.
|
||||
|
||||
@@ -66,6 +66,16 @@ These methods can be accessed from the `webFrameMain` module:
|
||||
Returns `WebFrameMain | undefined` - A frame with the given process and routing IDs,
|
||||
or `undefined` if there is no WebFrameMain associated with the given IDs.
|
||||
|
||||
### `webFrameMain.fromFrameToken(processId, frameToken)`
|
||||
|
||||
* `processId` Integer - An `Integer` representing the internal ID of the process which owns the frame.
|
||||
* `frameToken` string - A `string` token identifying the unique frame. Can also
|
||||
be retrieved in the renderer process via
|
||||
[`webFrame.frameToken`](web-frame.md#webframeframetoken-readonly).
|
||||
|
||||
Returns `WebFrameMain | null` - A frame with the given process and frame token,
|
||||
or `null` if there is no WebFrameMain associated with the given IDs.
|
||||
|
||||
## Class: WebFrameMain
|
||||
|
||||
Process: [Main](../glossary.md#main-process)<br />
|
||||
@@ -237,6 +247,11 @@ not used again.
|
||||
|
||||
A `string` representing the frame name.
|
||||
|
||||
#### `frame.frameToken` _Readonly_
|
||||
|
||||
A `string` which uniquely identifies the frame within its associated renderer
|
||||
process. This is equivalent to [`webFrame.frameToken`](web-frame.md#webframeframetoken-readonly).
|
||||
|
||||
#### `frame.osProcessId` _Readonly_
|
||||
|
||||
An `Integer` representing the operating system `pid` of the process which owns this frame.
|
||||
|
||||
@@ -67,7 +67,7 @@ Sets the maximum and minimum pinch-to-zoom level.
|
||||
> [!NOTE]
|
||||
> Visual zoom only applies to pinch-to-zoom behavior. Cmd+/-/0 zoom shortcuts are
|
||||
> controlled by the 'zoomIn', 'zoomOut', and 'resetZoom' MenuItem roles in the application
|
||||
> Menu. To disable shortcuts, manually [define the Menu](./menu.md#examples) and omit zoom roles
|
||||
> Menu. To disable shortcuts, manually [define the Menu](../tutorial/menus.md) and omit zoom roles
|
||||
> from the definition.
|
||||
|
||||
### `webFrame.setSpellCheckProvider(language, provider)`
|
||||
@@ -253,7 +253,7 @@ and intend to stay there).
|
||||
|
||||
* `selector` string - CSS selector for a frame element.
|
||||
|
||||
Returns `WebFrame` - The frame element in `webFrame's` document selected by
|
||||
Returns `WebFrame | null` - The frame element in `webFrame's` document selected by
|
||||
`selector`, `null` would be returned if `selector` does not select a frame or
|
||||
if the frame is not in the current renderer process.
|
||||
|
||||
@@ -261,18 +261,29 @@ if the frame is not in the current renderer process.
|
||||
|
||||
* `name` string
|
||||
|
||||
Returns `WebFrame` - A child of `webFrame` with the supplied `name`, `null`
|
||||
Returns `WebFrame | null` - A child of `webFrame` with the supplied `name`, `null`
|
||||
would be returned if there's no such frame or if the frame is not in the current
|
||||
renderer process.
|
||||
|
||||
### `webFrame.findFrameByRoutingId(routingId)`
|
||||
### `webFrame.findFrameByRoutingId(routingId)` _Deprecated_
|
||||
|
||||
* `routingId` Integer - An `Integer` representing the unique frame id in the
|
||||
current renderer process. Routing IDs can be retrieved from `WebFrame`
|
||||
instances (`webFrame.routingId`) and are also passed by frame
|
||||
specific `WebContents` navigation events (e.g. `did-frame-navigate`)
|
||||
|
||||
Returns `WebFrame` - that has the supplied `routingId`, `null` if not found.
|
||||
Returns `WebFrame | null` - that has the supplied `routingId`, `null` if not found.
|
||||
|
||||
**Deprecated:** Use the new `webFrame.findFrameByToken` API.
|
||||
|
||||
### `webFrame.findFrameByToken(frameToken)`
|
||||
|
||||
* `frameToken` string - A `string` representing the unique frame id in the
|
||||
current renderer process. Frame tokens can be retrieved from `WebFrame`
|
||||
instances (`webFrame.frameToken`) and can also be retrieved from
|
||||
`WebFrameMain` instances using `webFrameMain.frameToken`.
|
||||
|
||||
Returns `WebFrame | null` - that has the supplied `frameToken`, `null` if not found.
|
||||
|
||||
### `webFrame.isWordMisspelled(word)`
|
||||
|
||||
@@ -318,8 +329,16 @@ A `WebFrame | null` representing next sibling frame, the property would be `null
|
||||
`webFrame` is the last frame in its parent or if the next sibling is not in the
|
||||
current renderer process.
|
||||
|
||||
### `webFrame.routingId` _Readonly_
|
||||
### `webFrame.routingId` _Readonly_ _Deprecated_
|
||||
|
||||
An `Integer` representing the unique frame id in the current renderer process.
|
||||
Distinct WebFrame instances that refer to the same underlying frame will have
|
||||
the same `routingId`.
|
||||
|
||||
**Deprecated:** Use the new `webFrame.frameToken` API.
|
||||
|
||||
### `webFrame.frameToken` _Readonly_
|
||||
|
||||
A `string` representing the unique frame token in the current renderer process.
|
||||
Distinct WebFrame instances that refer to the same underlying frame will have
|
||||
the same `frameToken`.
|
||||
|
||||
@@ -1002,15 +1002,6 @@ Returns:
|
||||
Fired when the renderer process unexpectedly disappears. This is normally
|
||||
because it was crashed or killed.
|
||||
|
||||
### Event: 'plugin-crashed'
|
||||
|
||||
Returns:
|
||||
|
||||
* `name` string
|
||||
* `version` string
|
||||
|
||||
Fired when a plugin process is crashed.
|
||||
|
||||
### Event: 'destroyed'
|
||||
|
||||
Fired when the WebContents is destroyed.
|
||||
|
||||
@@ -12,14 +12,13 @@ This document uses the following convention to categorize breaking changes:
|
||||
* **Deprecated:** An API was marked as deprecated. The API will continue to function, but will emit a deprecation warning, and will be removed in a future release.
|
||||
* **Removed:** An API or feature was removed, and is no longer supported by Electron.
|
||||
|
||||
## Planned Breaking API Changes (38.0)
|
||||
## Planned Breaking API Changes (39.0)
|
||||
|
||||
### Removed: macOS 11 support
|
||||
### Deprecated: `--host-rules` command line switch
|
||||
|
||||
macOS 11 (Big Sur) is no longer supported by [Chromium](https://chromium-review.googlesource.com/c/chromium/src/+/6594615).
|
||||
Chromium is deprecating the `--host-rules` switch.
|
||||
|
||||
Older versions of Electron will continue to run on Big Sur, but macOS 12 (Monterey)
|
||||
or later will be required to run Electron v38.0.0 and higher.
|
||||
You should use `--host-resolver-rules` instead.
|
||||
|
||||
### Behavior Changed: window.open popups are always resizable
|
||||
|
||||
@@ -38,6 +37,43 @@ webContents.setWindowOpenHandler((details) => {
|
||||
})
|
||||
```
|
||||
|
||||
### Behavior Changed: shared texture OSR `paint` event data structure
|
||||
|
||||
When using shared texture offscreen rendering feature, the `paint` event now emits a more structured object.
|
||||
It moves the `sharedTextureHandle`, `planes`, `modifier` into a unified `handle` property.
|
||||
See [here](https://www.electronjs.org/docs/latest/api/structures/offscreen-shared-texture) for more details.
|
||||
|
||||
## Planned Breaking API Changes (38.0)
|
||||
|
||||
### Removed: `ELECTRON_OZONE_PLATFORM_HINT` environment variable
|
||||
|
||||
The default value of the `--ozone-plaftform` flag [changed to `auto`](https://chromium-review.googlesource.com/c/chromium/src/+/6775426).
|
||||
|
||||
You should use the `XDG_SESSION_TYPE=wayland` environment variable instead to use Wayland.
|
||||
|
||||
### Removed: macOS 11 support
|
||||
|
||||
macOS 11 (Big Sur) is no longer supported by [Chromium](https://chromium-review.googlesource.com/c/chromium/src/+/6594615).
|
||||
|
||||
Older versions of Electron will continue to run on Big Sur, but macOS 12 (Monterey)
|
||||
or later will be required to run Electron v38.0.0 and higher.
|
||||
|
||||
### Removed: `plugin-crashed` event
|
||||
|
||||
The `plugin-crashed` event has been removed from `webContents`.
|
||||
|
||||
### Deprecated: `webFrame.routingId` property
|
||||
|
||||
The `routingId` property will be removed from `webFrame` objects.
|
||||
|
||||
You should use `webFrame.frameToken` instead.
|
||||
|
||||
### Deprecated: `webFrame.findFrameByRoutingId(routingId)`
|
||||
|
||||
The `webFrame.findFrameByRoutingId(routingId)` function will be removed.
|
||||
|
||||
You should use `webFrame.findFrameByToken(frameToken)` instead.
|
||||
|
||||
## Planned Breaking API Changes (37.0)
|
||||
|
||||
### Utility Process unhandled rejection behavior change
|
||||
|
||||
@@ -191,12 +191,6 @@ $ ./out/Testing/electron
|
||||
|
||||
### Packaging
|
||||
|
||||
On linux, first strip the debugging and symbol information:
|
||||
|
||||
```sh
|
||||
$ electron/script/strip-binaries.py -d out/Release
|
||||
```
|
||||
|
||||
To package the electron build as a distributable zip file:
|
||||
|
||||
```sh
|
||||
|
||||
@@ -60,12 +60,12 @@ namespace electron {
|
||||
|
||||
namespace api {
|
||||
|
||||
class ApiName : public gin::Wrappable<ApiName> {
|
||||
class ApiName : public gin::DeprecatedWrappable<ApiName> {
|
||||
public:
|
||||
static gin::Handle<ApiName> Create(v8::Isolate* isolate);
|
||||
|
||||
// gin::Wrappable
|
||||
static gin::WrapperInfo kWrapperInfo;
|
||||
static gin::DeprecatedWrapperInfo kWrapperInfo;
|
||||
gin::ObjectTemplateBuilder GetObjectTemplateBuilder(
|
||||
v8::Isolate* isolate) override;
|
||||
const char* GetTypeName() override;
|
||||
@@ -90,7 +90,7 @@ namespace electron {
|
||||
|
||||
namespace api {
|
||||
|
||||
gin::WrapperInfo ApiName::kWrapperInfo = {gin::kEmbedderNativeGin};
|
||||
gin::DeprecatedWrapperInfo ApiName::kWrapperInfo = {gin::kEmbedderNativeGin};
|
||||
|
||||
gin::ObjectTemplateBuilder ApiName::GetObjectTemplateBuilder(
|
||||
v8::Isolate* isolate) {
|
||||
@@ -117,7 +117,7 @@ void Initialize(v8::Local<v8::Object> exports,
|
||||
v8::Local<v8::Value> unused,
|
||||
v8::Local<v8::Context> context,
|
||||
void* priv) {
|
||||
v8::Isolate* isolate = context->GetIsolate();
|
||||
v8::Isolate* const isolate = v8::Isolate::GetCurrent();
|
||||
gin_helper::Dictionary dict(isolate, exports);
|
||||
dict.Set("apiName", electron::api::ApiName::Create(isolate));
|
||||
}
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Hello World!</title>
|
||||
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline';" />
|
||||
</head>
|
||||
<body>
|
||||
<h1>Hello World!</h1>
|
||||
<p>Hit Alt+Ctrl+I on Windows or Opt+Cmd+I on Mac to see a message printed to the console.</p>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,28 +0,0 @@
|
||||
const { app, BrowserWindow, globalShortcut } = require('electron/main')
|
||||
|
||||
function createWindow () {
|
||||
const win = new BrowserWindow({
|
||||
width: 800,
|
||||
height: 600
|
||||
})
|
||||
|
||||
win.loadFile('index.html')
|
||||
}
|
||||
|
||||
app.whenReady().then(() => {
|
||||
globalShortcut.register('Alt+CommandOrControl+I', () => {
|
||||
console.log('Electron loves global shortcuts!')
|
||||
})
|
||||
}).then(createWindow)
|
||||
|
||||
app.on('window-all-closed', () => {
|
||||
if (process.platform !== 'darwin') {
|
||||
app.quit()
|
||||
}
|
||||
})
|
||||
|
||||
app.on('activate', () => {
|
||||
if (BrowserWindow.getAllWindows().length === 0) {
|
||||
createWindow()
|
||||
}
|
||||
})
|
||||
@@ -1,12 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Hello World!</title>
|
||||
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline';" />
|
||||
</head>
|
||||
<body>
|
||||
<h1>Hello World!</h1>
|
||||
<p>Hit Alt+Shift+I on Windows, or Opt+Cmd+I on mac to see a message printed to the console.</p>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,36 +0,0 @@
|
||||
const { app, BrowserWindow, Menu, MenuItem } = require('electron/main')
|
||||
|
||||
function createWindow () {
|
||||
const win = new BrowserWindow({
|
||||
width: 800,
|
||||
height: 600
|
||||
})
|
||||
|
||||
win.loadFile('index.html')
|
||||
}
|
||||
|
||||
const menu = new Menu()
|
||||
menu.append(new MenuItem({
|
||||
label: 'Electron',
|
||||
submenu: [{
|
||||
role: 'help',
|
||||
accelerator: process.platform === 'darwin' ? 'Alt+Cmd+I' : 'Alt+Shift+I',
|
||||
click: () => { console.log('Electron rocks!') }
|
||||
}]
|
||||
}))
|
||||
|
||||
Menu.setApplicationMenu(menu)
|
||||
|
||||
app.whenReady().then(createWindow)
|
||||
|
||||
app.on('window-all-closed', () => {
|
||||
if (process.platform !== 'darwin') {
|
||||
app.quit()
|
||||
}
|
||||
})
|
||||
|
||||
app.on('activate', () => {
|
||||
if (BrowserWindow.getAllWindows().length === 0) {
|
||||
createWindow()
|
||||
}
|
||||
})
|
||||
@@ -1,12 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Hello World!</title>
|
||||
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline';" />
|
||||
</head>
|
||||
<body>
|
||||
<h1>Hello World!</h1>
|
||||
<p>Right click the dock icon to see the custom menu options.</p>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,40 +0,0 @@
|
||||
const { app, BrowserWindow, Menu } = require('electron/main')
|
||||
|
||||
function createWindow () {
|
||||
const win = new BrowserWindow({
|
||||
width: 800,
|
||||
height: 600
|
||||
})
|
||||
|
||||
win.loadFile('index.html')
|
||||
}
|
||||
|
||||
const dockMenu = Menu.buildFromTemplate([
|
||||
{
|
||||
label: 'New Window',
|
||||
click () { console.log('New Window') }
|
||||
}, {
|
||||
label: 'New Window with Settings',
|
||||
submenu: [
|
||||
{ label: 'Basic' },
|
||||
{ label: 'Pro' }
|
||||
]
|
||||
},
|
||||
{ label: 'New Command...' }
|
||||
])
|
||||
|
||||
app.whenReady().then(() => {
|
||||
app.dock?.setMenu(dockMenu)
|
||||
}).then(createWindow)
|
||||
|
||||
app.on('window-all-closed', () => {
|
||||
if (process.platform !== 'darwin') {
|
||||
app.quit()
|
||||
}
|
||||
})
|
||||
|
||||
app.on('activate', () => {
|
||||
if (BrowserWindow.getAllWindows().length === 0) {
|
||||
createWindow()
|
||||
}
|
||||
})
|
||||
14
docs/fiddles/menus/context-menu/dom/index.html
Normal file
14
docs/fiddles/menus/context-menu/dom/index.html
Normal file
@@ -0,0 +1,14 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
|
||||
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'">
|
||||
<title>Context Menu Demo</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Context Menu Demo</h1>
|
||||
<!-- highlight-next-line -->
|
||||
<textarea id="editable"></textarea>
|
||||
</body>
|
||||
</html>
|
||||
39
docs/fiddles/menus/context-menu/dom/main.js
Normal file
39
docs/fiddles/menus/context-menu/dom/main.js
Normal file
@@ -0,0 +1,39 @@
|
||||
// Modules to control application life and create native browser window
|
||||
const { app, BrowserWindow, ipcMain, Menu } = require('electron/main')
|
||||
const path = require('node:path')
|
||||
|
||||
function createWindow () {
|
||||
const mainWindow = new BrowserWindow({
|
||||
webPreferences: {
|
||||
preload: path.join(__dirname, 'preload.js')
|
||||
}
|
||||
})
|
||||
|
||||
mainWindow.loadFile('index.html')
|
||||
const menu = Menu.buildFromTemplate([
|
||||
{ role: 'copy' },
|
||||
{ role: 'cut' },
|
||||
{ role: 'paste' },
|
||||
{ role: 'selectall' }
|
||||
])
|
||||
|
||||
// highlight-start
|
||||
ipcMain.on('context-menu', (event) => {
|
||||
menu.popup({
|
||||
window: BrowserWindow.fromWebContents(event.sender)
|
||||
})
|
||||
})
|
||||
// highlight-end
|
||||
}
|
||||
|
||||
app.whenReady().then(() => {
|
||||
createWindow()
|
||||
|
||||
app.on('activate', function () {
|
||||
if (BrowserWindow.getAllWindows().length === 0) createWindow()
|
||||
})
|
||||
})
|
||||
|
||||
app.on('window-all-closed', function () {
|
||||
if (process.platform !== 'darwin') app.quit()
|
||||
})
|
||||
11
docs/fiddles/menus/context-menu/dom/preload.js
Normal file
11
docs/fiddles/menus/context-menu/dom/preload.js
Normal file
@@ -0,0 +1,11 @@
|
||||
const { ipcRenderer } = require('electron/renderer')
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const textarea = document.getElementById('editable')
|
||||
// highlight-start
|
||||
textarea.addEventListener('contextmenu', (event) => {
|
||||
event.preventDefault()
|
||||
ipcRenderer.send('context-menu')
|
||||
})
|
||||
// highlight-end
|
||||
})
|
||||
14
docs/fiddles/menus/context-menu/web-contents/index.html
Normal file
14
docs/fiddles/menus/context-menu/web-contents/index.html
Normal file
@@ -0,0 +1,14 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
|
||||
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'">
|
||||
<title>Context Menu Demo</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Context Menu Demo</h1>
|
||||
<!-- highlight-next-line -->
|
||||
<textarea></textarea>
|
||||
</body>
|
||||
</html>
|
||||
32
docs/fiddles/menus/context-menu/web-contents/main.js
Normal file
32
docs/fiddles/menus/context-menu/web-contents/main.js
Normal file
@@ -0,0 +1,32 @@
|
||||
const { app, BrowserWindow, Menu } = require('electron/main')
|
||||
|
||||
function createWindow () {
|
||||
const win = new BrowserWindow()
|
||||
// highlight-start
|
||||
const menu = Menu.buildFromTemplate([
|
||||
{ role: 'copy' },
|
||||
{ role: 'cut' },
|
||||
{ role: 'paste' },
|
||||
{ role: 'selectall' }
|
||||
])
|
||||
win.webContents.on('context-menu', (_event, params) => {
|
||||
// only show the context menu if the element is editable
|
||||
if (params.isEditable) {
|
||||
menu.popup()
|
||||
}
|
||||
})
|
||||
// highlight-end
|
||||
win.loadFile('index.html')
|
||||
}
|
||||
|
||||
app.whenReady().then(() => {
|
||||
createWindow()
|
||||
|
||||
app.on('activate', function () {
|
||||
if (BrowserWindow.getAllWindows().length === 0) createWindow()
|
||||
})
|
||||
})
|
||||
|
||||
app.on('window-all-closed', function () {
|
||||
if (process.platform !== 'darwin') app.quit()
|
||||
})
|
||||
@@ -1,124 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>Customize Menus</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div>
|
||||
<h1>Customize Menus</h1>
|
||||
|
||||
<h3>
|
||||
The <code>Menu</code> and <code>MenuItem</code> modules can be used to
|
||||
create custom native menus.
|
||||
</h3>
|
||||
|
||||
<p>
|
||||
There are two kinds of menus: the application (top) menu and context
|
||||
(right-click) menu.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Open the
|
||||
<a href="https://www.electronjs.org/docs/latest/api/menu"
|
||||
>full API documentation<span
|
||||
>(opens in new window)</span
|
||||
></a
|
||||
>
|
||||
in your browser.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h2>Create an application menu</h2>
|
||||
<div>
|
||||
<div>
|
||||
<p>
|
||||
The <code>Menu</code> and <code>MenuItem</code> modules allow you to
|
||||
customize your application menu. If you don't set any menu, Electron
|
||||
will generate a minimal menu for your app by default.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
If you click the 'View' option in the application menu and then the
|
||||
'App Menu Demo', you'll see an information box displayed.
|
||||
</p>
|
||||
|
||||
<div>
|
||||
<h2>ProTip</h2>
|
||||
<strong>Know operating system menu differences.</strong>
|
||||
<p>
|
||||
When designing an app for multiple operating systems it's
|
||||
important to be mindful of the ways application menu conventions
|
||||
differ on each operating system.
|
||||
</p>
|
||||
<p>
|
||||
For instance, on Windows, accelerators are set with an
|
||||
<code>&</code>. Naming conventions also vary, like between
|
||||
"Settings" or "Preferences". Below are resources for learning
|
||||
operating system specific standards.
|
||||
</p>
|
||||
<ul>
|
||||
<li>
|
||||
<a
|
||||
href="https://developer.apple.com/design/human-interface-guidelines/the-menu-bar"
|
||||
>macOS<span
|
||||
>(opens in new window)</span
|
||||
></a
|
||||
>
|
||||
</li>
|
||||
<li>
|
||||
<a
|
||||
href="https://learn.microsoft.com/en-us/windows/apps/design/controls/menus-and-context-menus"
|
||||
>Windows<span
|
||||
>(opens in new window)</span
|
||||
></a
|
||||
>
|
||||
</li>
|
||||
<li>
|
||||
<a
|
||||
href="https://developer.gnome.org/hig/patterns/controls/menus.html"
|
||||
>Linux<span
|
||||
>(opens in new window)</span
|
||||
></a
|
||||
>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h2>Create a context menu</h2>
|
||||
<div>
|
||||
<div>
|
||||
<div>
|
||||
<button id="context-menu">View Demo</button>
|
||||
</div>
|
||||
<p>
|
||||
A context, or right-click, menu can be created with the
|
||||
<code>Menu</code> and <code>MenuItem</code> modules as well. You can
|
||||
right-click anywhere in this app or click the demo button to see an
|
||||
example context menu.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
In this demo we use the <code>ipcRenderer</code> module to show the
|
||||
context menu when explicitly calling it from the renderer process.
|
||||
</p>
|
||||
<p>
|
||||
See the full
|
||||
<a
|
||||
href="https://www.electronjs.org/docs/latest/api/web-contents/#event-context-menu"
|
||||
>context-menu event documentation</a
|
||||
>
|
||||
for all the available properties.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="renderer.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,368 +0,0 @@
|
||||
// Modules to control application life and create native browser window
|
||||
const {
|
||||
BrowserWindow,
|
||||
Menu,
|
||||
MenuItem,
|
||||
ipcMain,
|
||||
app,
|
||||
shell,
|
||||
dialog,
|
||||
autoUpdater
|
||||
} = require('electron/main')
|
||||
const path = require('node:path')
|
||||
|
||||
const menu = new Menu()
|
||||
menu.append(new MenuItem({ label: 'Hello' }))
|
||||
menu.append(new MenuItem({ type: 'separator' }))
|
||||
menu.append(
|
||||
new MenuItem({ label: 'Electron', type: 'checkbox', checked: true })
|
||||
)
|
||||
|
||||
const template = [
|
||||
{
|
||||
label: 'Edit',
|
||||
submenu: [
|
||||
{
|
||||
label: 'Undo',
|
||||
accelerator: 'CmdOrCtrl+Z',
|
||||
role: 'undo'
|
||||
},
|
||||
{
|
||||
label: 'Redo',
|
||||
accelerator: 'Shift+CmdOrCtrl+Z',
|
||||
role: 'redo'
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
label: 'Cut',
|
||||
accelerator: 'CmdOrCtrl+X',
|
||||
role: 'cut'
|
||||
},
|
||||
{
|
||||
label: 'Copy',
|
||||
accelerator: 'CmdOrCtrl+C',
|
||||
role: 'copy'
|
||||
},
|
||||
{
|
||||
label: 'Paste',
|
||||
accelerator: 'CmdOrCtrl+V',
|
||||
role: 'paste'
|
||||
},
|
||||
{
|
||||
label: 'Select All',
|
||||
accelerator: 'CmdOrCtrl+A',
|
||||
role: 'selectall'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
label: 'View',
|
||||
submenu: [
|
||||
{
|
||||
label: 'Reload',
|
||||
accelerator: 'CmdOrCtrl+R',
|
||||
click: (item, focusedWindow) => {
|
||||
if (focusedWindow) {
|
||||
// on reload, start fresh and close any old
|
||||
// open secondary windows
|
||||
if (focusedWindow.id === 1) {
|
||||
for (const win of BrowserWindow.getAllWindows()) {
|
||||
if (win.id > 1) win.close()
|
||||
}
|
||||
}
|
||||
focusedWindow.reload()
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Toggle Full Screen',
|
||||
accelerator: (() => {
|
||||
if (process.platform === 'darwin') {
|
||||
return 'Ctrl+Command+F'
|
||||
} else {
|
||||
return 'F11'
|
||||
}
|
||||
})(),
|
||||
click: (item, focusedWindow) => {
|
||||
if (focusedWindow) {
|
||||
focusedWindow.setFullScreen(!focusedWindow.isFullScreen())
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Toggle Developer Tools',
|
||||
accelerator: (() => {
|
||||
if (process.platform === 'darwin') {
|
||||
return 'Alt+Command+I'
|
||||
} else {
|
||||
return 'Ctrl+Shift+I'
|
||||
}
|
||||
})(),
|
||||
click: (item, focusedWindow) => {
|
||||
if (focusedWindow) {
|
||||
focusedWindow.webContents.toggleDevTools()
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
label: 'App Menu Demo',
|
||||
click: function (item, focusedWindow) {
|
||||
if (focusedWindow) {
|
||||
const options = {
|
||||
type: 'info',
|
||||
title: 'Application Menu Demo',
|
||||
buttons: ['Ok'],
|
||||
message:
|
||||
'This demo is for the Menu section, showing how to create a clickable menu item in the application menu.'
|
||||
}
|
||||
dialog.showMessageBox(focusedWindow, options, function () {})
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
label: 'Window',
|
||||
role: 'window',
|
||||
submenu: [
|
||||
{
|
||||
label: 'Minimize',
|
||||
accelerator: 'CmdOrCtrl+M',
|
||||
role: 'minimize'
|
||||
},
|
||||
{
|
||||
label: 'Close',
|
||||
accelerator: 'CmdOrCtrl+W',
|
||||
role: 'close'
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
label: 'Reopen Window',
|
||||
accelerator: 'CmdOrCtrl+Shift+T',
|
||||
enabled: false,
|
||||
key: 'reopenMenuItem',
|
||||
click: () => {
|
||||
app.emit('activate')
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
label: 'Help',
|
||||
role: 'help',
|
||||
submenu: [
|
||||
{
|
||||
label: 'Learn More',
|
||||
click: () => {
|
||||
shell.openExternal('https://electronjs.org')
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
function addUpdateMenuItems (items, position) {
|
||||
if (process.mas) return
|
||||
|
||||
const version = app.getVersion()
|
||||
const updateItems = [
|
||||
{
|
||||
label: `Version ${version}`,
|
||||
enabled: false
|
||||
},
|
||||
{
|
||||
label: 'Checking for Update',
|
||||
enabled: false,
|
||||
key: 'checkingForUpdate'
|
||||
},
|
||||
{
|
||||
label: 'Check for Update',
|
||||
visible: false,
|
||||
key: 'checkForUpdate',
|
||||
click: () => {
|
||||
autoUpdater.checkForUpdates()
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Restart and Install Update',
|
||||
enabled: true,
|
||||
visible: false,
|
||||
key: 'restartToUpdate',
|
||||
click: () => {
|
||||
autoUpdater.quitAndInstall()
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
items.splice.apply(items, [position, 0].concat(updateItems))
|
||||
}
|
||||
|
||||
function findReopenMenuItem () {
|
||||
const menu = Menu.getApplicationMenu()
|
||||
if (!menu) return
|
||||
|
||||
let reopenMenuItem
|
||||
for (const item of menu.items) {
|
||||
if (item.submenu) {
|
||||
for (const subitem of item.submenu.items) {
|
||||
if (subitem.key === 'reopenMenuItem') {
|
||||
reopenMenuItem = subitem
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return reopenMenuItem
|
||||
}
|
||||
|
||||
if (process.platform === 'darwin') {
|
||||
const name = app.getName()
|
||||
template.unshift({
|
||||
label: name,
|
||||
submenu: [
|
||||
{
|
||||
label: `About ${name}`,
|
||||
role: 'about'
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
label: 'Services',
|
||||
role: 'services',
|
||||
submenu: []
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
label: `Hide ${name}`,
|
||||
accelerator: 'Command+H',
|
||||
role: 'hide'
|
||||
},
|
||||
{
|
||||
label: 'Hide Others',
|
||||
accelerator: 'Command+Alt+H',
|
||||
role: 'hideothers'
|
||||
},
|
||||
{
|
||||
label: 'Show All',
|
||||
role: 'unhide'
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
label: 'Quit',
|
||||
accelerator: 'Command+Q',
|
||||
click: () => {
|
||||
app.quit()
|
||||
}
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
// Window menu.
|
||||
template[3].submenu.push(
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
label: 'Bring All to Front',
|
||||
role: 'front'
|
||||
}
|
||||
)
|
||||
|
||||
addUpdateMenuItems(template[0].submenu, 1)
|
||||
}
|
||||
|
||||
if (process.platform === 'win32') {
|
||||
const helpMenu = template[template.length - 1].submenu
|
||||
addUpdateMenuItems(helpMenu, 0)
|
||||
}
|
||||
// Keep a global reference of the window object, if you don't, the window will
|
||||
// be closed automatically when the JavaScript object is garbage collected.
|
||||
let mainWindow
|
||||
|
||||
function createWindow () {
|
||||
// Create the browser window.
|
||||
mainWindow = new BrowserWindow({
|
||||
width: 800,
|
||||
height: 600,
|
||||
webPreferences: {
|
||||
preload: path.join(__dirname, 'preload.js')
|
||||
}
|
||||
})
|
||||
|
||||
// and load the index.html of the app.
|
||||
mainWindow.loadFile('index.html')
|
||||
|
||||
// Open the DevTools.
|
||||
// mainWindow.webContents.openDevTools()
|
||||
|
||||
// Emitted when the window is closed.
|
||||
mainWindow.on('closed', function () {
|
||||
// Dereference the window object, usually you would store windows
|
||||
// in an array if your app supports multi windows, this is the time
|
||||
// when you should delete the corresponding element.
|
||||
mainWindow = null
|
||||
})
|
||||
|
||||
// Open external links in the default browser
|
||||
mainWindow.webContents.on('will-navigate', (event, url) => {
|
||||
event.preventDefault()
|
||||
shell.openExternal(url)
|
||||
})
|
||||
}
|
||||
|
||||
// This method will be called when Electron has finished
|
||||
// initialization and is ready to create browser windows.
|
||||
// Some APIs can only be used after this event occurs.
|
||||
app.whenReady().then(() => {
|
||||
createWindow()
|
||||
const menu = Menu.buildFromTemplate(template)
|
||||
Menu.setApplicationMenu(menu)
|
||||
})
|
||||
|
||||
// Quit when all windows are closed.
|
||||
app.on('window-all-closed', function () {
|
||||
// On macOS it is common for applications and their menu bar
|
||||
// to stay active until the user quits explicitly with Cmd + Q
|
||||
const reopenMenuItem = findReopenMenuItem()
|
||||
if (reopenMenuItem) reopenMenuItem.enabled = true
|
||||
|
||||
if (process.platform !== 'darwin') {
|
||||
app.quit()
|
||||
}
|
||||
})
|
||||
|
||||
app.on('activate', function () {
|
||||
// On macOS it is common to re-create a window in the app when the
|
||||
// dock icon is clicked and there are no other windows open.
|
||||
if (mainWindow === null) {
|
||||
createWindow()
|
||||
}
|
||||
})
|
||||
|
||||
app.on('browser-window-created', (event, win) => {
|
||||
const reopenMenuItem = findReopenMenuItem()
|
||||
if (reopenMenuItem) reopenMenuItem.enabled = false
|
||||
|
||||
win.webContents.on('context-menu', (e, params) => {
|
||||
menu.popup(win, params.x, params.y)
|
||||
})
|
||||
})
|
||||
|
||||
ipcMain.on('show-context-menu', event => {
|
||||
const win = BrowserWindow.fromWebContents(event.sender)
|
||||
menu.popup(win)
|
||||
})
|
||||
|
||||
// In this file you can include the rest of your app's specific main process
|
||||
// code. You can also put them in separate files and require them here.
|
||||
@@ -1,5 +0,0 @@
|
||||
const { contextBridge, ipcRenderer } = require('electron/renderer')
|
||||
|
||||
contextBridge.exposeInMainWorld('electronAPI', {
|
||||
showContextMenu: () => ipcRenderer.send('show-context-menu')
|
||||
})
|
||||
@@ -1,6 +0,0 @@
|
||||
// Tell main process to show the menu when demo button is clicked
|
||||
const contextMenuBtn = document.getElementById('context-menu')
|
||||
|
||||
contextMenuBtn.addEventListener('click', () => {
|
||||
window.electronAPI.showContextMenu()
|
||||
})
|
||||
18
docs/fiddles/menus/dock-menu/index.html
Normal file
18
docs/fiddles/menus/dock-menu/index.html
Normal file
@@ -0,0 +1,18 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
|
||||
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'">
|
||||
<title>Dock Menu Demo</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Dock Menu Demo</h1>
|
||||
<ul>
|
||||
<li>Create new BrowserWindow instances via the "New Window" option</li>
|
||||
<li>Close all BrowserWindow instances via the "Close All Windows" option</li>
|
||||
<li>Read the docs via the "Show Electron Docs" option</li>
|
||||
</ul>
|
||||
<script src="./renderer.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
46
docs/fiddles/menus/dock-menu/main.js
Normal file
46
docs/fiddles/menus/dock-menu/main.js
Normal file
@@ -0,0 +1,46 @@
|
||||
const { app, BrowserWindow, Menu } = require('electron/main')
|
||||
const { shell } = require('electron/common')
|
||||
|
||||
function createWindow () {
|
||||
const win = new BrowserWindow()
|
||||
win.loadFile('index.html')
|
||||
}
|
||||
|
||||
function closeAllWindows () {
|
||||
const wins = BrowserWindow.getAllWindows()
|
||||
for (const win of wins) {
|
||||
win.close()
|
||||
}
|
||||
}
|
||||
|
||||
app.whenReady().then(() => {
|
||||
createWindow()
|
||||
|
||||
const dockMenu = Menu.buildFromTemplate([
|
||||
{
|
||||
label: 'New Window',
|
||||
click: () => { createWindow() }
|
||||
},
|
||||
{
|
||||
label: 'Close All Windows',
|
||||
click: () => { closeAllWindows() }
|
||||
},
|
||||
{
|
||||
label: 'Open Electron Docs',
|
||||
click: () => {
|
||||
shell.openExternal('https://electronjs.org/docs')
|
||||
}
|
||||
}
|
||||
// add more menu options to the array
|
||||
])
|
||||
|
||||
app.dock.setMenu(dockMenu)
|
||||
|
||||
app.on('activate', function () {
|
||||
if (BrowserWindow.getAllWindows().length === 0) createWindow()
|
||||
})
|
||||
})
|
||||
|
||||
app.on('window-all-closed', function () {
|
||||
if (process.platform !== 'darwin') app.quit()
|
||||
})
|
||||
1
docs/fiddles/menus/dock-menu/renderer.js
Normal file
1
docs/fiddles/menus/dock-menu/renderer.js
Normal file
@@ -0,0 +1 @@
|
||||
document.title = `${document.title} - ${new Date()}`
|
||||
19
docs/fiddles/menus/tray-menu/index.html
Normal file
19
docs/fiddles/menus/tray-menu/index.html
Normal file
@@ -0,0 +1,19 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
|
||||
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'">
|
||||
<title>Tray Menu Demo</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Tray Menu Demo</h1>
|
||||
<p>This app will stay running even after all windows are closed.</p>
|
||||
<ul>
|
||||
<li>Use the "Open App" menu item to focus the main window (or open one if it does not exist).</li>
|
||||
<li>Change between red and green Tray icons with the "Set Green Icon" checkbox.</li>
|
||||
<li>Give the Tray icon a title using the "Set Title" checkbox.</li>
|
||||
<li>Quit the app using the "Quit" menu item.</li>
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
||||
60
docs/fiddles/menus/tray-menu/main.js
Normal file
60
docs/fiddles/menus/tray-menu/main.js
Normal file
@@ -0,0 +1,60 @@
|
||||
const { app, BrowserWindow, Menu, Tray } = require('electron/main')
|
||||
const { nativeImage } = require('electron/common')
|
||||
|
||||
// save a reference to the Tray object globally to avoid garbage collection
|
||||
let tray = null
|
||||
|
||||
function createWindow () {
|
||||
const mainWindow = new BrowserWindow()
|
||||
mainWindow.loadFile('index.html')
|
||||
}
|
||||
|
||||
// The Tray object can only be instantiated after the 'ready' event is fired
|
||||
app.whenReady().then(() => {
|
||||
createWindow()
|
||||
|
||||
const red = nativeImage.createFromDataURL('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAACTSURBVHgBpZKBCYAgEEV/TeAIjuIIbdQIuUGt0CS1gW1iZ2jIVaTnhw+Cvs8/OYDJA4Y8kR3ZR2/kmazxJbpUEfQ/Dm/UG7wVwHkjlQdMFfDdJMFaACebnjJGyDWgcnZu1/lrCrl6NCoEHJBrDwEr5NrT6ko/UV8xdLAC2N49mlc5CylpYh8wCwqrvbBGLoKGvz8Bfq0QPWEUo/EAAAAASUVORK5CYII=')
|
||||
const green = nativeImage.createFromDataURL('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAACOSURBVHgBpZLRDYAgEEOrEzgCozCCGzkCbKArOIlugJvgoRAUNcLRpvGH19TkgFQWkqIohhK8UEaKwKcsOg/+WR1vX+AlA74u6q4FqgCOSzwsGHCwbKliAF89Cv89tWmOT4VaVMoVbOBrdQUz+FrD6XItzh4LzYB1HFJ9yrEkZ4l+wvcid9pTssh4UKbPd+4vED2Nd54iAAAAAElFTkSuQmCC')
|
||||
|
||||
tray = new Tray(red)
|
||||
tray.setToolTip('Tray Icon Demo')
|
||||
|
||||
const contextMenu = Menu.buildFromTemplate([
|
||||
{
|
||||
label: 'Open App',
|
||||
click: () => {
|
||||
const wins = BrowserWindow.getAllWindows()
|
||||
if (wins.length === 0) {
|
||||
createWindow()
|
||||
} else {
|
||||
wins[0].focus()
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Set Green Icon',
|
||||
type: 'checkbox',
|
||||
click: ({ checked }) => {
|
||||
checked ? tray.setImage(green) : tray.setImage(red)
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Set Title',
|
||||
type: 'checkbox',
|
||||
click: ({ checked }) => {
|
||||
checked ? tray.setTitle('Title') : tray.setTitle('')
|
||||
}
|
||||
},
|
||||
{ role: 'quit' }
|
||||
])
|
||||
|
||||
tray.setContextMenu(contextMenu)
|
||||
})
|
||||
|
||||
app.on('window-all-closed', function () {
|
||||
// This will prevent the app from closing when windows close
|
||||
})
|
||||
|
||||
app.on('activate', function () {
|
||||
if (BrowserWindow.getAllWindows().length === 0) createWindow()
|
||||
})
|
||||
@@ -1,47 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>Tray</title>
|
||||
</head>
|
||||
<body>
|
||||
<div>
|
||||
<h1>Tray</h1>
|
||||
<h3>
|
||||
The <code>tray</code> module allows you to create an icon in the
|
||||
operating system's notification area.
|
||||
</h3>
|
||||
<p>This icon can also have a context menu attached.</p>
|
||||
|
||||
<p>
|
||||
Open the
|
||||
<a href="https://www.electronjs.org/docs/latest/api/tray">
|
||||
full API documentation
|
||||
</a>
|
||||
in your browser.
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
<div>
|
||||
<h2>ProTip</h2>
|
||||
<strong>Tray support in Linux.</strong>
|
||||
<p>
|
||||
On Linux distributions that only have app indicator support, users
|
||||
will need to install <code>libappindicator1</code> to make the
|
||||
tray icon work. See the
|
||||
<a href="https://www.electronjs.org/docs/latest/api/tray">
|
||||
full API documentation
|
||||
</a>
|
||||
for more details about using Tray on Linux.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// You can also require other files to run in this process
|
||||
require("./renderer.js");
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,18 +0,0 @@
|
||||
const { app, Tray, Menu, nativeImage } = require('electron/main')
|
||||
|
||||
let tray
|
||||
|
||||
app.whenReady().then(() => {
|
||||
const icon = nativeImage.createFromDataURL('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACQAAAAkCAYAAADhAJiYAAAAAXNSR0IArs4c6QAAAAlwSFlzAAALEwAACxMBAJqcGAAAAVlpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IlhNUCBDb3JlIDUuNC4wIj4KICAgPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4KICAgICAgPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIKICAgICAgICAgICAgeG1sbnM6dGlmZj0iaHR0cDovL25zLmFkb2JlLmNvbS90aWZmLzEuMC8iPgogICAgICAgICA8dGlmZjpPcmllbnRhdGlvbj4xPC90aWZmOk9yaWVudGF0aW9uPgogICAgICA8L3JkZjpEZXNjcmlwdGlvbj4KICAgPC9yZGY6UkRGPgo8L3g6eG1wbWV0YT4KTMInWQAACsZJREFUWAmtWFlsXFcZ/u82++Jt7IyT2Em6ZFHTpAtWIzspEgjEUhA8VNAiIYEQUvuABBIUwUMkQIVKPCIoEiABLShISEBbhFJwIGRpIKRpbNeJ7bh2HHvssR3PPnPnLnzfmRlju6EQqUc+c++c8y/fv54z1uQOh+/7Glh0TD59TE/TND7lnfa4/64OKsM071QoeZpA/y9WWvk/B4XCC06TUC+Xyw8HTXNQ1+Ww6PpOrMebewXxvBueJ6/XHOdMJBL5J9Y97m2R0SS/wweE6JxkGx5dilWr1S/7dXsEa2o4+LyFmcFcaL5zbX3Y9gh5hpeWYpSB9XV5/H678V89BGYDXnHJlCsWn4gHrGc1K9CXxferOdvPOOKUfF8cH7nUyCtklQZXih/VNNlmirk3GdBSoIcRswW7/vVkLPYi5W2Uze8bh7J+4wLfh4dViFx5/nmrUi7/MhGNvrCkBfpeWqnW/7BUdadqntQ8zwr6vhUV34xpYnDynWvcmwQNaclDXsqgLMqkocPDw7fNx7d5qIX+/PmJxKGD6VdDkeh7ztyqOFfrokGCEWiiZ1mp0uITnuKAosaT7+pNxMYTyefutcQfbA+b1XLpH5fnF97/yD335Fu6mqTqsclDINBVmI4fDxw80KPAvJSt1MZtMcLiGxYUu83p4UkgnJZlqcl3LAj3WnTkIS9lUBYNPJjueVWgg7qocyOgliFqjZsg8gq5tRdiieQTf1gq15Y8CUbRZtyWOzZwc8lEqS3PTCtgqd13ieO68BQ2uNl64tXAewktrFuX2mPdkWAxn3sxnmx7sqUTJGqso8MGS9tbXFz8DMH8bblUX3T9QARVi8RV8qljfcJy0zRlaf6mzHEuzEtmekqCoZB4rqp0OmudHtUnlEWZlE0d1EWd1N3EozourcO65pw4eTIZQTW9VazJtbqvw9XwKVFQMsKDBuNhtp4uvGGFI+IDgKnpMjYyIis3ZsQMBIR7pONsIaMsyqRs6ohY1rPUSd3EQFDqo+kdZ3Fh4aupbdu+99uFQr2A1CBs4uEAjZjIFUMHi4dVxMXzCdCXQj4vBrwVCofl0ulTcv/DAxJJJBUPc8mpoyI2JDw7bFyT+ifTcSubyXytJ51+roWBxwG9Q73WWjZ7eSUU3//nXM0NI+x0PBGrTSgsLS9JFuFxHFrvSqIrJV279gi6tjiVspTza3JjZhY+0CQZj0mlWJSeHTslCro6eFqymCcVVN77kkGjs1p4sy2VOoSlOrFwT+XR+PjkgGaZ+ycKVbRTYUdVrmaImCvzk1dlFCEJdHRJ284+ie/ol0h7p7jFvExcvCCXzp2Rqem3pAMAiqWS6JGYhFI9Mjo6KjevXVUyKEuFHrKpY6JQ8TXT3D8+OTkAHBw6o6LCFo9ag3o4JtlCyTHEt5AxKvS6YUi5kJeZG3Py0NAxlLcJ9xti+K7Mjo/JfGZRuvv6Ze+9+yWEhDZAvzg3JyhX2d6/S7q6e+TimdOS7ElLKBZDwqvmj6rztayr1fVI1IoXi4PAcYZY1tPEEO1wEVlXgRFBDcmIXTqJsS+XyhKLJ5A/OpIVXXptWUYv/UvaenfIocEhMQ2EzHHErlXFCgQl3paU1eVl6QAY8sQTCSmVihKJx1V/ogvgIYF/pACdcMBhqONoHhF88/2d+bojyA6cRvje2IdFjoSjUSnBS8hgyS9lZOzKFdmPxO3o6gQIGzwuDn1dVSCtCKPy1pZXlATXqUsVYMLRmKo87vP4Y1ioqwCdCegmMYx3W/VPn8RrSDwwIMMbcEjkYo29JZVOy+ybI7K4eksODx1VSqvligpReSVLgySM/FI5h2q062jNyL3s7FtoAyGJIlx1225UmwJF6aJRJ3XzHXO9bWvsJa3jQFlBJkz6iuXdu32HzM7MyP0PPNgAU6ko4Qzp6b+flr8MD9OYJg9CwtzL5+T65ITs2bsP3mGxN/ZbBcOn0sk20gAkLQ+huXpFi8vkoY9AoyDjxTR1mbo6Ltt275HpN0dlNxQE40mVM8Ajjxx9VAGhAvQR1akZFCq799ADysMuQqOxh2FNmamEaz51ItGLfFD9+oUJoZkLowHoFA2mljUacqOMflKuVmHpfmnfvlMuvXZeStmMBIMhcWEdjgFJtrUjXI0KchAuAg0ilxLJNoRVBxhIBm0TjjKAuqjTqTs3CQZ6QUUMGFW7eiWMUg6w+yo8YMW7DqtqlZLkUDV2ISfd29KyDwk9MjYmMyOXxQIIKuShqo4VGFNBEgeDQYqVam5N5tEePFQgURIUBCsd1EWd1XrtDUUMLARD9bKaK5ytQ2Gb75g8WMiEP6VkfnZGevv6UF1vSBW5E0PFDAweFRvlfun8WVmamhDNrkmweQ0pwaPt6M4m8mgKTTFXqcrV0ZH1FKBg6qAu6qTuJiCV1Cp2Q0NDr9Uq5Ym+oMEDlSewsoRwrVBEaij7AJ4s7zrOpumxEdm15y6558GHJVe1Zezy6zJx6aJkpq5JFB4z6zVZmBiX1VWUP0IY4CFMYcpQdZ3xqIs6oftCE5DHKwd0q/tzOV8svdDb3nk8VnG9qmgQC0ZURz8Ur91alXgSByZ6ES9kZZTr/PR16UOCh+7dq0CWyyXJ4xqCQ0nKt9YQSlPue2gAeYZzD7yNLk0wmqAreb2WYSxAJ8Dget64wxtEBlDaqVOn/K5dB67t6+t5MhoMJuc8w8UPKiQ9CQR9JK5czhZAQxPt7TKF3OiAIisUViAD2Lg5d0P2HDgoKeRaW0enyqVwBJcO5fFG5dqa7h406qaeX8384uTZL5w9+UqxhYHFp0YLIYA9ddfu3T+4UJF6Rg+YAc9D0+RoIGP1ULhpWspr10evyK7+ftWTrk9PS/++A9KZSm26cih2mMOErem6n/ZsZwA2TM/MPHXs2LEftnSTbh0Q36mIIbx44cLvOnu3f+xUwbWLmoHTCUlF6g2jBQo/GnFrnGNqSHdvr+rIKGMW1KahwEBdzHft98aNwMr8zd8/NDDwccihc0hLi3GubRjY0Bm6H19fPvnZI4c/fHd7PJ2peXYZ+WQ26JufZELjQ6lbAQtnWre0d3apY8TFIdtAo+Qri6mupsB49lBMC+QXF0YefObZT8j0eKWlswVjEyCCOXHihPGb575VCvVuf3lvetsH9rXF0rla3cnhpoIGjgsUPhR3I4TMKYJQV1Z6WO02aEjHa5mNe3OPW3OPRHVrbXFh9Ocvv/KR1372owx1Pf3005uc35Ddgtd8rsf06IdS5777zZ+mUqmPzjm6TPpmvayZOq4LyATeCzkanmiy4qEuC/yXiO8CSMRzvLs1x9phepLNZl868sy3Pyen/5hd1/EfRvWmuvSWNeaRS/RkPDI4+NjE1NSXEoXlpaNB1zqo20abi59/vu/UfM2pie7WUDVq8l3wTwnskeZ+zTbIQ17KoCzKpGzq2KqX32/roRbh8ePHdUzl0s9/5Rv9n/7go19MxCKfCkZiu3V06wrO5gocxL7Dgd/IEobEMH6rejg+auXidL5Y/vWv/vTX53/y/e/MkGajTH7fOt4RUJOY1df4RdtY6ICFRzqTySOhUOA+3Ai3o31H1ZbnlXBruFmt2iMrudy5xx9//BzWV7nXDBGN2xpjbt/5oGUEdhtO3iD47xZOvm8a5CHvpsV38wsUaMwBWsz3rbK5xr0mzdv2t9Jv/f5vhsF4J+Q63IUAAAAASUVORK5CYII=')
|
||||
tray = new Tray(icon)
|
||||
|
||||
const contextMenu = Menu.buildFromTemplate([
|
||||
{ label: 'Item1', type: 'radio' },
|
||||
{ label: 'Item2', type: 'radio' },
|
||||
{ label: 'Item3', type: 'radio', checked: true },
|
||||
{ label: 'Item4', type: 'radio' }
|
||||
])
|
||||
|
||||
tray.setToolTip('This is my application.')
|
||||
tray.setContextMenu(contextMenu)
|
||||
})
|
||||
208
docs/tutorial/application-menu.md
Normal file
208
docs/tutorial/application-menu.md
Normal file
@@ -0,0 +1,208 @@
|
||||
---
|
||||
title: Application Menu
|
||||
description: Customize the main application menu for your Electron app
|
||||
slug: application-menu
|
||||
hide_title: true
|
||||
---
|
||||
|
||||
# Application Menu
|
||||
|
||||
Each Electron app has a single top-level application menu.
|
||||
|
||||
* On macOS, this menu is shown in the system [menu bar](https://support.apple.com/en-ca/guide/mac-help/mchlp1446/mac).
|
||||
* On Windows and Linux, this menu is shown at the top of each [BaseWindow](../api/base-window.md).
|
||||
|
||||
## Building application menus
|
||||
|
||||
The application menu can be set by passing a [Menu](../api/menu.md) instance into the
|
||||
[`Menu.setApplicationMenu`](../api/menu.md#menusetapplicationmenumenu) static function.
|
||||
|
||||
When building an application menu in Electron, each top-level array menu item **must be a submenu**.
|
||||
|
||||
Electron will set a default menu for your app if this API is never called. Below is an example of
|
||||
that default menu being created manually using shorthand [`MenuItem` roles](./menus.md#roles).
|
||||
|
||||
```js title='Manually creating the default menu' @ts-expect-error=[107]
|
||||
const { shell } = require('electron/common')
|
||||
const { app, Menu } = require('electron/main')
|
||||
|
||||
const isMac = process.platform === 'darwin'
|
||||
const template = [
|
||||
// { role: 'appMenu' }
|
||||
...(isMac
|
||||
? [{
|
||||
label: app.name,
|
||||
submenu: [
|
||||
{ role: 'about' },
|
||||
{ type: 'separator' },
|
||||
{ role: 'services' },
|
||||
{ type: 'separator' },
|
||||
{ role: 'hide' },
|
||||
{ role: 'hideOthers' },
|
||||
{ role: 'unhide' },
|
||||
{ type: 'separator' },
|
||||
{ role: 'quit' }
|
||||
]
|
||||
}]
|
||||
: []),
|
||||
// { role: 'fileMenu' }
|
||||
{
|
||||
label: 'File',
|
||||
submenu: [
|
||||
isMac ? { role: 'close' } : { role: 'quit' }
|
||||
]
|
||||
},
|
||||
// { role: 'editMenu' }
|
||||
{
|
||||
label: 'Edit',
|
||||
submenu: [
|
||||
{ role: 'undo' },
|
||||
{ role: 'redo' },
|
||||
{ type: 'separator' },
|
||||
{ role: 'cut' },
|
||||
{ role: 'copy' },
|
||||
{ role: 'paste' },
|
||||
...(isMac
|
||||
? [
|
||||
{ role: 'pasteAndMatchStyle' },
|
||||
{ role: 'delete' },
|
||||
{ role: 'selectAll' },
|
||||
{ type: 'separator' },
|
||||
{
|
||||
label: 'Speech',
|
||||
submenu: [
|
||||
{ role: 'startSpeaking' },
|
||||
{ role: 'stopSpeaking' }
|
||||
]
|
||||
}
|
||||
]
|
||||
: [
|
||||
{ role: 'delete' },
|
||||
{ type: 'separator' },
|
||||
{ role: 'selectAll' }
|
||||
])
|
||||
]
|
||||
},
|
||||
// { role: 'viewMenu' }
|
||||
{
|
||||
label: 'View',
|
||||
submenu: [
|
||||
{ role: 'reload' },
|
||||
{ role: 'forceReload' },
|
||||
{ role: 'toggleDevTools' },
|
||||
{ type: 'separator' },
|
||||
{ role: 'resetZoom' },
|
||||
{ role: 'zoomIn' },
|
||||
{ role: 'zoomOut' },
|
||||
{ type: 'separator' },
|
||||
{ role: 'togglefullscreen' }
|
||||
]
|
||||
},
|
||||
// { role: 'windowMenu' }
|
||||
{
|
||||
label: 'Window',
|
||||
submenu: [
|
||||
{ role: 'minimize' },
|
||||
{ role: 'zoom' },
|
||||
...(isMac
|
||||
? [
|
||||
{ type: 'separator' },
|
||||
{ role: 'front' },
|
||||
{ type: 'separator' },
|
||||
{ role: 'window' }
|
||||
]
|
||||
: [
|
||||
{ role: 'close' }
|
||||
])
|
||||
]
|
||||
},
|
||||
{
|
||||
role: 'help',
|
||||
submenu: [
|
||||
{
|
||||
label: 'Learn More',
|
||||
click: async () => {
|
||||
const { shell } = require('electron')
|
||||
await shell.openExternal('https://electronjs.org')
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
const menu = Menu.buildFromTemplate(template)
|
||||
Menu.setApplicationMenu(menu)
|
||||
```
|
||||
|
||||
> [!IMPORTANT]
|
||||
> On macOS, the first submenu of the application menu will **always** have your application's name
|
||||
> as its label. In general, you can populate this submenu by conditionally adding a menu item with
|
||||
> the `appMenu` role.
|
||||
|
||||
> [!TIP]
|
||||
> For additional descriptions of available roles, see the [`MenuItem` roles](./menus.md#roles)
|
||||
> section of the general Menus guide.
|
||||
|
||||
### Using standard OS menu roles
|
||||
|
||||
Defining each submenu explicitly can get very verbose. If you want to re-use default submenus
|
||||
in your app, you can use various submenu-related roles provided by Electron.
|
||||
|
||||
```js title='Using default roles for each submenu' @ts-expect-error=[26]
|
||||
const { shell } = require('electron/common')
|
||||
const { app, Menu } = require('electron/main')
|
||||
|
||||
const template = [
|
||||
...(process.platform === 'darwin'
|
||||
? [{ role: 'appMenu' }]
|
||||
: []),
|
||||
{ role: 'fileMenu' },
|
||||
{ role: 'editMenu' },
|
||||
{ role: 'viewMenu' },
|
||||
{ role: 'windowMenu' },
|
||||
{
|
||||
role: 'help',
|
||||
submenu: [
|
||||
{
|
||||
label: 'Learn More',
|
||||
click: async () => {
|
||||
const { shell } = require('electron')
|
||||
await shell.openExternal('https://electronjs.org')
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
const menu = Menu.buildFromTemplate(template)
|
||||
Menu.setApplicationMenu(menu)
|
||||
```
|
||||
|
||||
> [!NOTE]
|
||||
> On macOS, the `help` role defines a top-level Help submenu that has a search bar for
|
||||
> other menu items. It requires items to be added to its `submenu` to function.
|
||||
|
||||
## Setting window-specific application menus _Linux_ _Windows_
|
||||
|
||||
Since the root application menu exists on each `BaseWindow` on Windows and Linux, you can override
|
||||
it with a window-specific `Menu` instance via the [`win.setMenu`](../api/browser-window.md#winsetmenumenu-linux-windows) method.
|
||||
|
||||
```js title='Override a window's menu'
|
||||
const { BrowserWindow, Menu } = require('electron/main')
|
||||
|
||||
const win = new BrowserWindow()
|
||||
const menu = Menu.buildFromTemplate([
|
||||
{
|
||||
label: 'my custom menu',
|
||||
submenu: [
|
||||
{ role: 'copy' },
|
||||
{ role: 'paste' }
|
||||
]
|
||||
}
|
||||
])
|
||||
win.setMenu(menu)
|
||||
```
|
||||
|
||||
> [!TIP]
|
||||
> You can remove a specific window's application menu by calling the
|
||||
> [`win.removeMenu`](../api/base-window.md#winremovemenu-linux-windows) API.
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user