mirror of
https://github.com/electron/electron.git
synced 2026-02-19 03:14:51 -05:00
Compare commits
240 Commits
feat/frame
...
sckp-macos
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
589272e065 | ||
|
|
e364a20ba1 | ||
|
|
6b6ef0b9ef | ||
|
|
bb092132be | ||
|
|
0cdf1012bb | ||
|
|
eaa952361c | ||
|
|
8ef66cade3 | ||
|
|
2fb1bfec42 | ||
|
|
65864f6203 | ||
|
|
75eb7aabd6 | ||
|
|
f8aae32c6c | ||
|
|
3e6834099e | ||
|
|
3d5d5f5cb0 | ||
|
|
3268c6ba76 | ||
|
|
50f96692df | ||
|
|
53a7802e95 | ||
|
|
b6c4c727d1 | ||
|
|
4aa9773388 | ||
|
|
7b6b5bf224 | ||
|
|
bd1ed17c02 | ||
|
|
813fc3af58 | ||
|
|
e7675a1a1c | ||
|
|
729ca429b8 | ||
|
|
da56809b62 | ||
|
|
12ca8b30be | ||
|
|
56d4433e46 | ||
|
|
0ee7150832 | ||
|
|
d424c3aee7 | ||
|
|
e4d660af86 | ||
|
|
2efd75e2ca | ||
|
|
b13f05e2dc | ||
|
|
dcbab692c0 | ||
|
|
71f3ff6bf2 | ||
|
|
ff0a14a7c6 | ||
|
|
4bf99c9bea | ||
|
|
9513486bf3 | ||
|
|
bea7d618f1 | ||
|
|
4ad20ccb39 | ||
|
|
73a017577e | ||
|
|
2d8a547692 | ||
|
|
5f0603ed28 | ||
|
|
afca4e271e | ||
|
|
30d2fadb28 | ||
|
|
3271b82094 | ||
|
|
c0e180758b | ||
|
|
5817d27429 | ||
|
|
4812b4e6c2 | ||
|
|
7c0b7b417b | ||
|
|
785fe5f3b6 | ||
|
|
502a6b0166 | ||
|
|
4a28e60e89 | ||
|
|
a90d50e13f | ||
|
|
962d8b325a | ||
|
|
c813bc2a92 | ||
|
|
5ce41bac8d | ||
|
|
6bc7bde229 | ||
|
|
2de8fd7d93 | ||
|
|
dcd319cfbe | ||
|
|
cd56b96544 | ||
|
|
22262c14f1 | ||
|
|
6e056709be | ||
|
|
2f63b20acf | ||
|
|
eb126eecb0 | ||
|
|
4e1a915f1a | ||
|
|
f2b09ff0bd | ||
|
|
b0c11371e0 | ||
|
|
9b2e7db469 | ||
|
|
f04c06a0db | ||
|
|
8ac061ebe7 | ||
|
|
b30f31e1f6 | ||
|
|
288ef37b1d | ||
|
|
20414f66ca | ||
|
|
458b14b8ed | ||
|
|
530ccfe350 | ||
|
|
041ada1586 | ||
|
|
d987bee007 | ||
|
|
431a791a99 | ||
|
|
9441cf4627 | ||
|
|
bb1c3dff21 | ||
|
|
49a27cba6b | ||
|
|
99c943df23 | ||
|
|
8c11764800 | ||
|
|
54136042c6 | ||
|
|
28ed8a821a | ||
|
|
ec9b589402 | ||
|
|
2a7133b7a6 | ||
|
|
64158114aa | ||
|
|
e8631b2f3a | ||
|
|
21ad7cdda5 | ||
|
|
add374ef6a | ||
|
|
eac270bea7 | ||
|
|
36ec9d7236 | ||
|
|
3041fd66cd | ||
|
|
b504f65ace | ||
|
|
5cb87b7110 | ||
|
|
d19cac6772 | ||
|
|
eac1a7ff68 | ||
|
|
00089a951b | ||
|
|
b8d0f18ff8 | ||
|
|
96c2022483 | ||
|
|
ff05d4a96c | ||
|
|
989918a59c | ||
|
|
6c4b5d81dd | ||
|
|
7d045dcddb | ||
|
|
199f6d64db | ||
|
|
b82e4585cf | ||
|
|
9303a3fae9 | ||
|
|
9b6ba1ced1 | ||
|
|
7870ade07a | ||
|
|
9699422cd6 | ||
|
|
3ee2ec8e4f | ||
|
|
0de1e8e610 | ||
|
|
01554f39a8 | ||
|
|
69eb076bca | ||
|
|
f3259be73c | ||
|
|
698cce6707 | ||
|
|
3eab549369 | ||
|
|
3e51ee516e | ||
|
|
e3f61b465d | ||
|
|
a63f6143ea | ||
|
|
2a383e9ddd | ||
|
|
612da3ec47 | ||
|
|
6248c2436a | ||
|
|
8d58999135 | ||
|
|
324fc0f62a | ||
|
|
f62668e2e3 | ||
|
|
a15fa87558 | ||
|
|
ceaa0e26c7 | ||
|
|
4867b5dc75 | ||
|
|
340fdaf511 | ||
|
|
5ea885c87f | ||
|
|
d8baceb08c | ||
|
|
d6f4982522 | ||
|
|
9d558cec5e | ||
|
|
159e1a42b3 | ||
|
|
b50066f420 | ||
|
|
22b7403cd1 | ||
|
|
670e0ca076 | ||
|
|
ee67bc7dcb | ||
|
|
ecd7eb36ac | ||
|
|
47572286f3 | ||
|
|
6be1151ffc | ||
|
|
c0422d7cc9 | ||
|
|
e9ba5876d1 | ||
|
|
02be7c1185 | ||
|
|
7dfcec931a | ||
|
|
a329024793 | ||
|
|
137a552641 | ||
|
|
a841d6484c | ||
|
|
2af57c4b6a | ||
|
|
47dbab3856 | ||
|
|
a1e4550c9e | ||
|
|
2b8706bf44 | ||
|
|
3a3595f2af | ||
|
|
9a2ee763d0 | ||
|
|
237429bb85 | ||
|
|
50d1c803dd | ||
|
|
0d3e34d0be | ||
|
|
aa06b065c0 | ||
|
|
9f47c9a051 | ||
|
|
6fdfca6e49 | ||
|
|
196352bf0b | ||
|
|
46d316692d | ||
|
|
2f288bc7cc | ||
|
|
f5025b6246 | ||
|
|
e055ce7c39 | ||
|
|
14fe0932f0 | ||
|
|
3ba85878a5 | ||
|
|
70168c8bdc | ||
|
|
e4cd162433 | ||
|
|
4085185e2d | ||
|
|
a141f68c83 | ||
|
|
9199d5c610 | ||
|
|
96460becf9 | ||
|
|
d7c6fb8250 | ||
|
|
3db691804b | ||
|
|
4512b2b5c4 | ||
|
|
7bde100a1a | ||
|
|
d0110d897d | ||
|
|
ef34892a76 | ||
|
|
67f5ac5bbc | ||
|
|
517935cd55 | ||
|
|
326957009a | ||
|
|
213165a467 | ||
|
|
3dad07f338 | ||
|
|
6adc737a89 | ||
|
|
c0282eb9c8 | ||
|
|
471b1a873d | ||
|
|
aee8ea8b10 | ||
|
|
57cf4fc846 | ||
|
|
9fe12cd01b | ||
|
|
6486ce8191 | ||
|
|
bec6ddda70 | ||
|
|
e9d5eeb118 | ||
|
|
c147e4fa81 | ||
|
|
1d27a27813 | ||
|
|
d3bead5e0e | ||
|
|
9f1bb531ba | ||
|
|
9971087678 | ||
|
|
e7fa5c709c | ||
|
|
7a1d410e0a | ||
|
|
e2a7981dd3 | ||
|
|
26da3c5d6e | ||
|
|
bc22ee7897 | ||
|
|
784201ecee | ||
|
|
6e72cbb5e0 | ||
|
|
233b99a0a8 | ||
|
|
43e328f363 | ||
|
|
8543820d98 | ||
|
|
93f4a93e12 | ||
|
|
ecd5d0a3a4 | ||
|
|
8cf2e46c1f | ||
|
|
50387043d1 | ||
|
|
e715607178 | ||
|
|
0e388bce3e | ||
|
|
9457a56607 | ||
|
|
f9553a35d5 | ||
|
|
e2ef160beb | ||
|
|
ae56a03e33 | ||
|
|
4629e449a9 | ||
|
|
74c6669a8e | ||
|
|
5c67cd9150 | ||
|
|
f66a0c2acf | ||
|
|
a467d0684e | ||
|
|
75eac86506 | ||
|
|
996477152d | ||
|
|
e09577b123 | ||
|
|
26d228ccfe | ||
|
|
aafb1ba72c | ||
|
|
db7ef90159 | ||
|
|
863faea542 | ||
|
|
5aabb6bec5 | ||
|
|
5e05dff949 | ||
|
|
3ea623364b | ||
|
|
cf67dc8898 | ||
|
|
d7b568a1c0 | ||
|
|
fe9031eb23 | ||
|
|
f5eba67f0d | ||
|
|
e1762e6e44 | ||
|
|
9d32b6ddfc |
@@ -1,5 +1,4 @@
|
||||
# These env vars are only necessary for creating Electron releases.
|
||||
# See docs/development/releasing.md
|
||||
|
||||
APPVEYOR_CLOUD_TOKEN=
|
||||
ELECTRON_GITHUB_TOKEN=
|
||||
|
||||
4
.github/CODEOWNERS
vendored
4
.github/CODEOWNERS
vendored
@@ -8,13 +8,9 @@
|
||||
DEPS @electron/wg-upgrades
|
||||
|
||||
# Releases WG
|
||||
/.github/workflows/update_appveyor_image.yml @electron/wg-releases
|
||||
/docs/breaking-changes.md @electron/wg-releases
|
||||
/npm/ @electron/wg-releases
|
||||
/script/release @electron/wg-releases
|
||||
appveyor.yml @electron/wg-releases
|
||||
appveyor-bake.yml @electron/wg-releases
|
||||
appveyor-woa.yml @electron/wg-releases
|
||||
|
||||
# Security WG
|
||||
/lib/browser/devtools.ts @electron/wg-security
|
||||
|
||||
1
.github/ISSUE_TEMPLATE/config.yml
vendored
1
.github/ISSUE_TEMPLATE/config.yml
vendored
@@ -1,3 +1,4 @@
|
||||
blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: Discord Chat
|
||||
url: https://discord.gg/APGC3k5yaH
|
||||
|
||||
14
.github/ISSUE_TEMPLATE/maintainer_issue.yml
vendored
Normal file
14
.github/ISSUE_TEMPLATE/maintainer_issue.yml
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
name: Maintainer Issue (not for public use)
|
||||
description: Only to be created by Electron maintainers
|
||||
body:
|
||||
- type: checkboxes
|
||||
attributes:
|
||||
label: Confirmation
|
||||
options:
|
||||
- label: I am a [maintainer](https://github.com/orgs/electron/people) of the Electron project. (If not, please create a [different issue type](https://github.com/electron/electron/issues/new/).)
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Description
|
||||
validations:
|
||||
required: true
|
||||
2
.github/PULL_REQUEST_TEMPLATE.md
vendored
2
.github/PULL_REQUEST_TEMPLATE.md
vendored
@@ -13,7 +13,7 @@ Contributors guide: https://github.com/electron/electron/blob/main/CONTRIBUTING.
|
||||
- [ ] PR description included and stakeholders cc'd
|
||||
- [ ] `npm test` passes
|
||||
- [ ] tests are [changed or added](https://github.com/electron/electron/blob/main/docs/development/testing.md)
|
||||
- [ ] relevant documentation, tutorials, templates and examples are changed or added
|
||||
- [ ] relevant API documentation, tutorials, and examples are updated and follow the [documentation style guide](https://github.com/electron/electron/blob/main/docs/development/style-guide.md)
|
||||
- [ ] [PR release notes](https://github.com/electron/clerk/blob/main/README.md) describe the change in a way relevant to app developers, and are [capitalized, punctuated, and past tense](https://github.com/electron/clerk/blob/main/README.md#examples).
|
||||
|
||||
#### Release Notes
|
||||
|
||||
23
.github/actions/build-electron/action.yml
vendored
23
.github/actions/build-electron/action.yml
vendored
@@ -108,7 +108,9 @@ runs:
|
||||
if [ "${{ inputs.target-platform }}" = "win" ]; then
|
||||
cd out/Default
|
||||
powershell Compress-Archive -update mksnapshot_args mksnapshot.zip
|
||||
powershell Compress-Archive -update gen/v8/embedded.S mksnapshot.zip
|
||||
powershell mkdir mktmp\\gen\\v8
|
||||
powershell Copy-Item gen\\v8\\embedded.S mktmp\\gen\\v8
|
||||
powershell Compress-Archive -update -Path mktmp\\gen mksnapshot.zip
|
||||
else
|
||||
(cd out/Default; zip mksnapshot.zip mksnapshot_args gen/v8/embedded.S)
|
||||
fi
|
||||
@@ -143,6 +145,25 @@ runs:
|
||||
run: |
|
||||
cd src
|
||||
e build --target electron:node_headers
|
||||
- name: Create installed_software.json ${{ inputs.step-suffix }}
|
||||
shell: powershell
|
||||
if: ${{ inputs.is-release == 'true' && inputs.target-platform == 'win' }}
|
||||
run: |
|
||||
cd src
|
||||
Get-CimInstance -Namespace root\cimv2 -Class Win32_product | Select vendor, description, @{l='install_location';e='InstallLocation'}, @{l='install_date';e='InstallDate'}, @{l='install_date_2';e='InstallDate2'}, caption, version, name, @{l='sku_number';e='SKUNumber'} | ConvertTo-Json | Out-File -Encoding utf8 -FilePath .\installed_software.json
|
||||
- name: Profile Windows Toolchain ${{ inputs.step-suffix }}
|
||||
shell: bash
|
||||
if: ${{ inputs.is-release == 'true' && inputs.target-platform == 'win' }}
|
||||
run: |
|
||||
cd src
|
||||
python3 electron/build/profile_toolchain.py --output-json=out/Default/windows_toolchain_profile.json
|
||||
- name: Add msdia140.dll to Path ${{ inputs.step-suffix }}
|
||||
shell: bash
|
||||
if: ${{ inputs.is-release == 'true' && inputs.target-platform == 'win' }}
|
||||
run: |
|
||||
# Needed for msdia140.dll on 64-bit windows
|
||||
cd src
|
||||
export PATH="$PATH:$(pwd)/third_party/llvm-build/Release+Asserts/bin"
|
||||
- name: Generate & Zip Symbols ${{ inputs.step-suffix }}
|
||||
shell: bash
|
||||
run: |
|
||||
|
||||
10
.github/actions/checkout/action.yml
vendored
10
.github/actions/checkout/action.yml
vendored
@@ -18,6 +18,8 @@ runs:
|
||||
echo "GIT_CACHE_PATH=$(pwd)/git-cache" >> $GITHUB_ENV
|
||||
- name: Install Dependencies
|
||||
uses: ./src/electron/.github/actions/install-dependencies
|
||||
- name: Set Chromium Git Cookie
|
||||
uses: ./src/electron/.github/actions/set-chromium-cookie
|
||||
- name: Install Build Tools
|
||||
uses: ./src/electron/.github/actions/install-build-tools
|
||||
- name: Get Depot Tools
|
||||
@@ -73,10 +75,10 @@ runs:
|
||||
if: steps.check-cache.outputs.cache_exists == 'false' && inputs.use-cache == 'true'
|
||||
shell: bash
|
||||
run: |
|
||||
# if there is less than 20 GB free space then creating the cache might fail so exit early
|
||||
# if there is less than 35 GB free space then creating the cache might fail so exit early
|
||||
freespace=`df -m /mnt/cross-instance-cache | grep -w /mnt/cross-instance-cache | awk '{print $4}'`
|
||||
freespace_human=`df -h /mnt/cross-instance-cache | grep -w /mnt/cross-instance-cache | awk '{print $4}'`
|
||||
if [ $freespace -le 20000 ]; then
|
||||
if [ $freespace -le 35000 ]; then
|
||||
echo "The cross mount cache has $freespace_human free space which is not enough - exiting"
|
||||
exit 1
|
||||
else
|
||||
@@ -97,7 +99,7 @@ runs:
|
||||
fi
|
||||
|
||||
ELECTRON_USE_THREE_WAY_MERGE_FOR_PATCHES=1 e d gclient sync --with_branch_heads --with_tags -vv
|
||||
if [ "${{ inputs.is-release }}" != "true" && -n "${{ env.PATCH_UP_APP_CREDS }}" ]; then
|
||||
if [[ "${{ inputs.is-release }}" != "true" ]]; then
|
||||
# Re-export all the patches to check if there were changes.
|
||||
python3 src/electron/script/export_all_patches.py src/electron/patches/config.json
|
||||
cd src/electron
|
||||
@@ -126,6 +128,8 @@ runs:
|
||||
cat ../../patches/update-patches.patch
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "No changes to patches detected"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
@@ -16,5 +16,5 @@ runs:
|
||||
e auto-update disable
|
||||
if [ "$(expr substr $(uname -s) 1 10)" == "MSYS_NT-10" ]; then
|
||||
e d cipd.bat --version
|
||||
cp "C:\Python37\python.exe" "C:\Python37\python3.exe"
|
||||
cp "C:\Python311\python.exe" "C:\Python311\python3.exe"
|
||||
fi
|
||||
|
||||
26
.github/actions/set-chromium-cookie/action.yml
vendored
Normal file
26
.github/actions/set-chromium-cookie/action.yml
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
name: 'Set Chromium Git Cookie'
|
||||
description: 'Sets an authenticated cookie from Chromium to allow for a higher request limit'
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: Set the git cookie from chromium.googlesource.com (Unix)
|
||||
if: ${{ runner.os != 'Windows' && env.CHROMIUM_GIT_COOKIE }}
|
||||
shell: bash
|
||||
run: |
|
||||
eval 'set +o history' 2>/dev/null || setopt HIST_IGNORE_SPACE 2>/dev/null
|
||||
touch ~/.gitcookies
|
||||
chmod 0600 ~/.gitcookies
|
||||
|
||||
git config --global http.cookiefile ~/.gitcookies
|
||||
|
||||
tr , \\t <<\__END__ >>~/.gitcookies
|
||||
${{ env.CHROMIUM_GIT_COOKIE }}
|
||||
__END__
|
||||
eval 'set -o history' 2>/dev/null || unsetopt HIST_IGNORE_SPACE 2>/dev/null
|
||||
- name: Set the git cookie from chromium.googlesource.com (Windows)
|
||||
if: ${{ runner.os == 'Windows' && env.CHROMIUM_GIT_COOKIE_WINDOWS_STRING }}
|
||||
shell: cmd
|
||||
run: |
|
||||
git config --global http.cookiefile "%USERPROFILE%\.gitcookies"
|
||||
powershell -noprofile -nologo -command Write-Output "${{ env.CHROMIUM_GIT_COOKIE_WINDOWS_STRING }}" >>"%USERPROFILE%\.gitcookies"
|
||||
|
||||
4
.github/workflows/archaeologist-dig.yml
vendored
4
.github/workflows/archaeologist-dig.yml
vendored
@@ -13,7 +13,7 @@ jobs:
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Setup Node.js/npm
|
||||
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af
|
||||
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a
|
||||
with:
|
||||
node-version: 20.11.x
|
||||
- name: Setting Up Dig Site
|
||||
@@ -41,7 +41,7 @@ jobs:
|
||||
sha-file: .dig-old
|
||||
filename: electron.old.d.ts
|
||||
- name: Upload artifacts
|
||||
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b #v4.5.0
|
||||
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 #v4.6.1
|
||||
with:
|
||||
name: artifacts
|
||||
path: electron/artifacts
|
||||
|
||||
9
.github/workflows/branch-created.yml
vendored
9
.github/workflows/branch-created.yml
vendored
@@ -94,7 +94,7 @@ jobs:
|
||||
}))
|
||||
- name: Create Release Project Board
|
||||
if: ${{ steps.check-major-version.outputs.MAJOR }}
|
||||
uses: dsanders11/project-actions/copy-project@8bc0bd421be3a2f9e96e160c4cb703f97cd3be55 # v1.5.0
|
||||
uses: dsanders11/project-actions/copy-project@2134fe7cc71c58b7ae259c82a8e63c6058255678 # v1.7.0
|
||||
id: create-release-board
|
||||
with:
|
||||
drafts: true
|
||||
@@ -114,14 +114,15 @@ jobs:
|
||||
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
|
||||
- name: Find Previous Release Project Board
|
||||
if: ${{ steps.check-major-version.outputs.MAJOR }}
|
||||
uses: dsanders11/project-actions/find-project@8bc0bd421be3a2f9e96e160c4cb703f97cd3be55 # v1.5.0
|
||||
uses: dsanders11/project-actions/find-project@2134fe7cc71c58b7ae259c82a8e63c6058255678 # v1.7.0
|
||||
id: find-prev-release-board
|
||||
with:
|
||||
fail-if-project-not-found: false
|
||||
title: ${{ steps.generate-project-metadata.outputs.prev-prev-major }}-x-y
|
||||
token: ${{ steps.generate-token.outputs.token }}
|
||||
- name: Close Previous Release Project Board
|
||||
if: ${{ steps.check-major-version.outputs.MAJOR }}
|
||||
uses: dsanders11/project-actions/close-project@8bc0bd421be3a2f9e96e160c4cb703f97cd3be55 # v1.5.0
|
||||
if: ${{ steps.find-prev-release-board.outputs.number }}
|
||||
uses: dsanders11/project-actions/close-project@2134fe7cc71c58b7ae259c82a8e63c6058255678 # v1.7.0
|
||||
with:
|
||||
project-number: ${{ steps.find-prev-release-board.outputs.number }}
|
||||
token: ${{ steps.generate-token.outputs.token }}
|
||||
|
||||
6
.github/workflows/build.yml
vendored
6
.github/workflows/build.yml
vendored
@@ -30,7 +30,7 @@ on:
|
||||
required: false
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- sckp-macos15
|
||||
- '[1-9][0-9]-x-y'
|
||||
pull_request:
|
||||
|
||||
@@ -100,6 +100,7 @@ jobs:
|
||||
- /mnt/cross-instance-cache:/mnt/cross-instance-cache
|
||||
- /var/run/sas:/var/run/sas
|
||||
env:
|
||||
CHROMIUM_GIT_COOKIE: ${{ secrets.CHROMIUM_GIT_COOKIE }}
|
||||
GCLIENT_EXTRA_ARGS: '--custom-var=checkout_mac=True --custom-var=host_os=mac'
|
||||
outputs:
|
||||
build-image-sha: ${{ needs.setup.outputs.build-image-sha }}
|
||||
@@ -126,6 +127,7 @@ jobs:
|
||||
- /mnt/cross-instance-cache:/mnt/cross-instance-cache
|
||||
- /var/run/sas:/var/run/sas
|
||||
env:
|
||||
CHROMIUM_GIT_COOKIE: ${{ secrets.CHROMIUM_GIT_COOKIE }}
|
||||
GCLIENT_EXTRA_ARGS: '--custom-var=checkout_arm=True --custom-var=checkout_arm64=True'
|
||||
PATCH_UP_APP_CREDS: ${{ secrets.PATCH_UP_APP_CREDS }}
|
||||
outputs:
|
||||
@@ -150,6 +152,8 @@ jobs:
|
||||
volumes:
|
||||
- /mnt/cross-instance-cache:/mnt/cross-instance-cache
|
||||
env:
|
||||
CHROMIUM_GIT_COOKIE: ${{ secrets.CHROMIUM_GIT_COOKIE }}
|
||||
CHROMIUM_GIT_COOKIE_WINDOWS_STRING: ${{ secrets.CHROMIUM_GIT_COOKIE_WINDOWS_STRING }}
|
||||
GCLIENT_EXTRA_ARGS: '--custom-var=checkout_win=True'
|
||||
TARGET_OS: 'win'
|
||||
ELECTRON_DEPOT_TOOLS_WIN_TOOLCHAIN: '1'
|
||||
|
||||
8
.github/workflows/clean-src-cache.yml
vendored
8
.github/workflows/clean-src-cache.yml
vendored
@@ -1,8 +1,12 @@
|
||||
name: Clean Source Cache
|
||||
|
||||
description: |
|
||||
This workflow cleans up the source cache on the cross-instance cache volume
|
||||
to free up space. It runs daily at midnight and clears files older than 15 days.
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: "0 0 * * SUN" # Run at midnight every Sunday
|
||||
- cron: "0 0 * * *"
|
||||
|
||||
jobs:
|
||||
clean-src-cache:
|
||||
@@ -17,5 +21,5 @@ jobs:
|
||||
shell: bash
|
||||
run: |
|
||||
df -h /mnt/cross-instance-cache
|
||||
find /mnt/cross-instance-cache -type f -mtime +30 -delete
|
||||
find /mnt/cross-instance-cache -type f -mtime +15 -delete
|
||||
df -h /mnt/cross-instance-cache
|
||||
|
||||
2
.github/workflows/issue-commented.yml
vendored
2
.github/workflows/issue-commented.yml
vendored
@@ -10,7 +10,7 @@ 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"]'), 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 ❌')) && !contains(fromJSON('["MEMBER", "OWNER", "COLLABORATOR"]'), github.event.comment.author_association) && github.event.comment.user.type != 'Bot' }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Generate GitHub App token
|
||||
|
||||
4
.github/workflows/issue-labeled.yml
vendored
4
.github/workflows/issue-labeled.yml
vendored
@@ -20,7 +20,7 @@ jobs:
|
||||
creds: ${{ secrets.ISSUE_TRIAGE_GH_APP_CREDS }}
|
||||
org: electron
|
||||
- name: Set status
|
||||
uses: dsanders11/project-actions/edit-item@8bc0bd421be3a2f9e96e160c4cb703f97cd3be55 # v1.5.0
|
||||
uses: dsanders11/project-actions/edit-item@2134fe7cc71c58b7ae259c82a8e63c6058255678 # v1.7.0
|
||||
with:
|
||||
token: ${{ steps.generate-token.outputs.token }}
|
||||
project-number: 90
|
||||
@@ -39,7 +39,7 @@ jobs:
|
||||
creds: ${{ secrets.ISSUE_TRIAGE_GH_APP_CREDS }}
|
||||
org: electron
|
||||
- name: Set status
|
||||
uses: dsanders11/project-actions/edit-item@8bc0bd421be3a2f9e96e160c4cb703f97cd3be55 # v1.5.0
|
||||
uses: dsanders11/project-actions/edit-item@2134fe7cc71c58b7ae259c82a8e63c6058255678 # v1.7.0
|
||||
with:
|
||||
token: ${{ steps.generate-token.outputs.token }}
|
||||
project-number: 90
|
||||
|
||||
2
.github/workflows/issue-opened.yml
vendored
2
.github/workflows/issue-opened.yml
vendored
@@ -19,7 +19,7 @@ jobs:
|
||||
creds: ${{ secrets.ISSUE_TRIAGE_GH_APP_CREDS }}
|
||||
org: electron
|
||||
- name: Add to Issue Triage
|
||||
uses: dsanders11/project-actions/add-item@8bc0bd421be3a2f9e96e160c4cb703f97cd3be55 # v1.5.0
|
||||
uses: dsanders11/project-actions/add-item@2134fe7cc71c58b7ae259c82a8e63c6058255678 # v1.7.0
|
||||
with:
|
||||
field: Reporter
|
||||
field-value: ${{ github.event.issue.user.login }}
|
||||
|
||||
4
.github/workflows/issue-transferred.yml
vendored
4
.github/workflows/issue-transferred.yml
vendored
@@ -10,6 +10,7 @@ jobs:
|
||||
issue-transferred:
|
||||
name: Issue Transferred
|
||||
runs-on: ubuntu-latest
|
||||
if: ${{ !github.event.changes.new_repository.private }}
|
||||
steps:
|
||||
- name: Generate GitHub App token
|
||||
uses: electron/github-app-auth-action@384fd19694fe7b6dcc9a684746c6976ad78228ae # v1.1.1
|
||||
@@ -18,8 +19,9 @@ jobs:
|
||||
creds: ${{ secrets.ISSUE_TRIAGE_GH_APP_CREDS }}
|
||||
org: electron
|
||||
- name: Remove from issue triage
|
||||
uses: dsanders11/project-actions/delete-item@8bc0bd421be3a2f9e96e160c4cb703f97cd3be55 # v1.5.0
|
||||
uses: dsanders11/project-actions/delete-item@2134fe7cc71c58b7ae259c82a8e63c6058255678 # v1.7.0
|
||||
with:
|
||||
token: ${{ steps.generate-token.outputs.token }}
|
||||
project-number: 90
|
||||
item: ${{ github.event.changes.new_issue.html_url }}
|
||||
fail-if-item-not-found: false
|
||||
|
||||
2
.github/workflows/issue-unlabeled.yml
vendored
2
.github/workflows/issue-unlabeled.yml
vendored
@@ -30,7 +30,7 @@ jobs:
|
||||
org: electron
|
||||
- name: Set status
|
||||
if: ${{ steps.check-for-blocked-labels.outputs.NOT_BLOCKED }}
|
||||
uses: dsanders11/project-actions/edit-item@8bc0bd421be3a2f9e96e160c4cb703f97cd3be55 # v1.5.0
|
||||
uses: dsanders11/project-actions/edit-item@2134fe7cc71c58b7ae259c82a8e63c6058255678 # v1.7.0
|
||||
with:
|
||||
token: ${{ steps.generate-token.outputs.token }}
|
||||
project-number: 90
|
||||
|
||||
@@ -56,8 +56,8 @@ on:
|
||||
default: false
|
||||
|
||||
concurrency:
|
||||
group: electron-build-and-test-and-nan-${{ inputs.target-platform }}-${{ inputs.target-arch }}-${{ github.ref }}
|
||||
cancel-in-progress: ${{ github.ref != 'refs/heads/main' && !endsWith(github.ref, '-x-y') }}
|
||||
group: electron-build-and-test-and-nan-${{ inputs.target-platform }}-${{ inputs.target-arch }}-${{ github.ref_protected == true && github.run_id || github.ref }}
|
||||
cancel-in-progress: ${{ github.ref_protected != true }}
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
@@ -56,8 +56,8 @@ on:
|
||||
default: false
|
||||
|
||||
concurrency:
|
||||
group: electron-build-and-test-${{ inputs.target-platform }}-${{ inputs.target-arch }}-${{ github.ref }}
|
||||
cancel-in-progress: ${{ github.ref != 'refs/heads/main' && !endsWith(github.ref, '-x-y') }}
|
||||
group: electron-build-and-test-${{ inputs.target-platform }}-${{ inputs.target-arch }}-${{ github.ref_protected == true && github.run_id || github.ref }}
|
||||
cancel-in-progress: ${{ github.ref_protected != true }}
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
9
.github/workflows/pipeline-electron-lint.yml
vendored
9
.github/workflows/pipeline-electron-lint.yml
vendored
@@ -9,8 +9,11 @@ on:
|
||||
type: string
|
||||
|
||||
concurrency:
|
||||
group: electron-lint-${{ github.ref }}
|
||||
cancel-in-progress: ${{ github.ref != 'refs/heads/main' && !endsWith(github.ref, '-x-y') }}
|
||||
group: electron-lint-${{ github.ref_protected == true && github.run_id || github.ref }}
|
||||
cancel-in-progress: ${{ github.ref_protected != true }}
|
||||
|
||||
env:
|
||||
CHROMIUM_GIT_COOKIE: ${{ secrets.CHROMIUM_GIT_COOKIE }}
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
@@ -27,6 +30,8 @@ jobs:
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
- name: Install Dependencies
|
||||
uses: ./src/electron/.github/actions/install-dependencies
|
||||
- name: Set Chromium Git Cookie
|
||||
uses: ./src/electron/.github/actions/set-chromium-cookie
|
||||
- name: Setup third_party Depot Tools
|
||||
shell: bash
|
||||
run: |
|
||||
|
||||
@@ -13,7 +13,7 @@ on:
|
||||
required: true
|
||||
target-arch:
|
||||
type: string
|
||||
description: 'Arch to build for, can be x64, arm64 or arm'
|
||||
description: 'Arch to build for, can be x64, arm64, ia32 or arm'
|
||||
required: true
|
||||
target-variant:
|
||||
type: string
|
||||
@@ -61,10 +61,12 @@ on:
|
||||
|
||||
|
||||
concurrency:
|
||||
group: electron-build-${{ inputs.target-platform }}-${{ inputs.target-arch }}-${{ inputs.target-variant }}-${{ inputs.is-asan }}-${{ github.ref }}
|
||||
cancel-in-progress: ${{ github.ref != 'refs/heads/main' && !endsWith(github.ref, '-x-y') }}
|
||||
group: electron-build-${{ inputs.target-platform }}-${{ inputs.target-arch }}-${{ inputs.target-variant }}-${{ inputs.is-asan }}-${{ github.ref_protected == true && github.run_id || github.ref }}
|
||||
cancel-in-progress: ${{ github.ref_protected != true }}
|
||||
|
||||
env:
|
||||
CHROMIUM_GIT_COOKIE: ${{ secrets.CHROMIUM_GIT_COOKIE }}
|
||||
CHROMIUM_GIT_COOKIE_WINDOWS_STRING: ${{ secrets.CHROMIUM_GIT_COOKIE_WINDOWS_STRING }}
|
||||
ELECTRON_ARTIFACTS_BLOB_STORAGE: ${{ secrets.ELECTRON_ARTIFACTS_BLOB_STORAGE }}
|
||||
ELECTRON_RBE_JWT: ${{ secrets.ELECTRON_RBE_JWT }}
|
||||
SUDOWOODO_EXCHANGE_URL: ${{ secrets.SUDOWOODO_EXCHANGE_URL }}
|
||||
@@ -100,7 +102,7 @@ jobs:
|
||||
run: df -h
|
||||
- name: Setup Node.js/npm
|
||||
if: ${{ inputs.target-platform == 'macos' }}
|
||||
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af
|
||||
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a
|
||||
with:
|
||||
node-version: 20.11.x
|
||||
cache: yarn
|
||||
@@ -125,6 +127,8 @@ jobs:
|
||||
GN_EXTRA_ARGS='is_asan=true'
|
||||
fi
|
||||
echo "GN_EXTRA_ARGS=$GN_EXTRA_ARGS" >> $GITHUB_ENV
|
||||
- name: Set Chromium Git Cookie
|
||||
uses: ./src/electron/.github/actions/set-chromium-cookie
|
||||
- name: Get Depot Tools
|
||||
timeout-minutes: 5
|
||||
run: |
|
||||
|
||||
@@ -27,8 +27,8 @@ on:
|
||||
default: false
|
||||
|
||||
concurrency:
|
||||
group: electron-test-${{ inputs.target-platform }}-${{ inputs.target-arch }}-${{ inputs.is-asan }}-${{ github.ref }}
|
||||
cancel-in-progress: ${{ github.ref != 'refs/heads/main' && !endsWith(github.ref, '-x-y') }}
|
||||
group: electron-test-${{ inputs.target-platform }}-${{ inputs.target-arch }}-${{ inputs.is-asan }}-${{ github.ref_protected == true && github.run_id || github.ref }}
|
||||
cancel-in-progress: ${{ github.ref_protected != true }}
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
@@ -36,6 +36,8 @@ permissions:
|
||||
pull-requests: read
|
||||
|
||||
env:
|
||||
CHROMIUM_GIT_COOKIE: ${{ secrets.CHROMIUM_GIT_COOKIE }}
|
||||
CHROMIUM_GIT_COOKIE_WINDOWS_STRING: ${{ secrets.CHROMIUM_GIT_COOKIE_WINDOWS_STRING }}
|
||||
ELECTRON_OUT_DIR: Default
|
||||
ELECTRON_RBE_JWT: ${{ secrets.ELECTRON_RBE_JWT }}
|
||||
|
||||
@@ -74,9 +76,10 @@ jobs:
|
||||
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@39370e3970a6d050c480ffad4ff0ed4d3fdee5af
|
||||
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a
|
||||
with:
|
||||
node-version: 20.11.x
|
||||
- name: Add TCC permissions on macOS
|
||||
@@ -112,6 +115,9 @@ jobs:
|
||||
configure_sys_tccdb "$values"
|
||||
fi
|
||||
done
|
||||
- name: Turn off the unexpectedly quit dialog on macOS
|
||||
if: ${{ inputs.target-platform == 'macos' }}
|
||||
run: defaults write com.apple.CrashReporter DialogType server
|
||||
- name: Checkout Electron
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
|
||||
with:
|
||||
@@ -120,6 +126,8 @@ jobs:
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
- name: Install Dependencies
|
||||
uses: ./src/electron/.github/actions/install-dependencies
|
||||
- name: Set Chromium Git Cookie
|
||||
uses: ./src/electron/.github/actions/set-chromium-cookie
|
||||
- name: Get Depot Tools
|
||||
timeout-minutes: 5
|
||||
run: |
|
||||
@@ -139,12 +147,12 @@ jobs:
|
||||
echo "DISABLE_CRASH_REPORTER_TESTS=true" >> $GITHUB_ENV
|
||||
echo "IS_ASAN=true" >> $GITHUB_ENV
|
||||
- name: Download Generated Artifacts
|
||||
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16
|
||||
uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806
|
||||
with:
|
||||
name: generated_artifacts_${{ env.ARTIFACT_KEY }}
|
||||
path: ./generated_artifacts_${{ matrix.build-type }}_${{ inputs.target-arch }}
|
||||
- name: Download Src Artifacts
|
||||
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16
|
||||
uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806
|
||||
with:
|
||||
name: src_artifacts_${{ env.ARTIFACT_KEY }}
|
||||
path: ./src_artifacts_${{ matrix.build-type }}_${{ inputs.target-arch }}
|
||||
@@ -239,7 +247,7 @@ jobs:
|
||||
if: always() && !cancelled()
|
||||
- name: Upload Test Artifacts
|
||||
if: always() && !cancelled()
|
||||
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b
|
||||
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1
|
||||
with:
|
||||
name: test_artifacts_${{ env.ARTIFACT_KEY }}_${{ matrix.shard }}
|
||||
path: src/electron/spec/artifacts
|
||||
|
||||
@@ -27,10 +27,11 @@ on:
|
||||
default: testing
|
||||
|
||||
concurrency:
|
||||
group: electron-node-nan-test-${{ inputs.target-platform }}-${{ inputs.target-arch }}-${{ github.ref }}
|
||||
cancel-in-progress: ${{ github.ref != 'refs/heads/main' && !endsWith(github.ref, '-x-y') }}
|
||||
group: electron-node-nan-test-${{ inputs.target-platform }}-${{ inputs.target-arch }}-${{ github.ref_protected == true && github.run_id || github.ref }}
|
||||
cancel-in-progress: ${{ github.ref_protected != true }}
|
||||
|
||||
env:
|
||||
CHROMIUM_GIT_COOKIE: ${{ secrets.CHROMIUM_GIT_COOKIE }}
|
||||
ELECTRON_OUT_DIR: Default
|
||||
ELECTRON_RBE_JWT: ${{ secrets.ELECTRON_RBE_JWT }}
|
||||
|
||||
@@ -38,7 +39,7 @@ jobs:
|
||||
node-tests:
|
||||
name: Run Node.js Tests
|
||||
runs-on: electron-arc-linux-amd64-8core
|
||||
timeout-minutes: 20
|
||||
timeout-minutes: 30
|
||||
env:
|
||||
TARGET_ARCH: ${{ inputs.target-arch }}
|
||||
BUILD_TYPE: linux
|
||||
@@ -50,6 +51,8 @@ jobs:
|
||||
path: src/electron
|
||||
fetch-depth: 0
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
- name: Set Chromium Git Cookie
|
||||
uses: ./src/electron/.github/actions/set-chromium-cookie
|
||||
- name: Install Build Tools
|
||||
uses: ./src/electron/.github/actions/install-build-tools
|
||||
- name: Init Build Tools
|
||||
@@ -67,12 +70,12 @@ jobs:
|
||||
- name: Add Depot Tools to PATH
|
||||
run: echo "$(pwd)/depot_tools" >> $GITHUB_PATH
|
||||
- name: Download Generated Artifacts
|
||||
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16
|
||||
uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806
|
||||
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@fa0a91b85d4f404e444e00e005971372dc801d16
|
||||
uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806
|
||||
with:
|
||||
name: src_artifacts_linux_${{ env.TARGET_ARCH }}
|
||||
path: ./src_artifacts_linux_${{ env.TARGET_ARCH }}
|
||||
@@ -99,7 +102,7 @@ jobs:
|
||||
nan-tests:
|
||||
name: Run Nan Tests
|
||||
runs-on: electron-arc-linux-amd64-4core
|
||||
timeout-minutes: 20
|
||||
timeout-minutes: 30
|
||||
env:
|
||||
TARGET_ARCH: ${{ inputs.target-arch }}
|
||||
BUILD_TYPE: linux
|
||||
@@ -118,6 +121,8 @@ jobs:
|
||||
e init -f --root=$(pwd) --out=Default ${{ inputs.gn-build-type }}
|
||||
- name: Install Dependencies
|
||||
uses: ./src/electron/.github/actions/install-dependencies
|
||||
- name: Set Chromium Git Cookie
|
||||
uses: ./src/electron/.github/actions/set-chromium-cookie
|
||||
- name: Get Depot Tools
|
||||
timeout-minutes: 5
|
||||
run: |
|
||||
@@ -128,12 +133,12 @@ jobs:
|
||||
- name: Add Depot Tools to PATH
|
||||
run: echo "$(pwd)/depot_tools" >> $GITHUB_PATH
|
||||
- name: Download Generated Artifacts
|
||||
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16
|
||||
uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806
|
||||
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@fa0a91b85d4f404e444e00e005971372dc801d16
|
||||
uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806
|
||||
with:
|
||||
name: src_artifacts_linux_${{ env.TARGET_ARCH }}
|
||||
path: ./src_artifacts_linux_${{ env.TARGET_ARCH }}
|
||||
|
||||
6
.github/workflows/pull-request-labeled.yml
vendored
6
.github/workflows/pull-request-labeled.yml
vendored
@@ -15,12 +15,12 @@ jobs:
|
||||
- name: Trigger Slack workflow
|
||||
uses: slackapi/slack-github-action@485a9d42d3a73031f12ec201c457e2162c45d02d # v2.0.0
|
||||
with:
|
||||
webhook: ${{ secrets.BACKPORT_REQUESTED_SLACK_WEBHOOK_URL }}
|
||||
webhook-type: webhook-trigger
|
||||
payload: |
|
||||
{
|
||||
"url": "${{ github.event.pull_request.html_url }}"
|
||||
}
|
||||
env:
|
||||
SLACK_WEBHOOK_URL: ${{ secrets.BACKPORT_REQUESTED_SLACK_WEBHOOK_URL }}
|
||||
pull-request-labeled-deprecation-review-complete:
|
||||
name: deprecation-review/complete label added
|
||||
if: github.event.label.name == 'deprecation-review/complete ✅'
|
||||
@@ -33,7 +33,7 @@ jobs:
|
||||
creds: ${{ secrets.RELEASE_BOARD_GH_APP_CREDS }}
|
||||
org: electron
|
||||
- name: Set status
|
||||
uses: dsanders11/project-actions/edit-item@8bc0bd421be3a2f9e96e160c4cb703f97cd3be55 # v1.5.0
|
||||
uses: dsanders11/project-actions/edit-item@2134fe7cc71c58b7ae259c82a8e63c6058255678 # v1.7.0
|
||||
with:
|
||||
token: ${{ steps.generate-token.outputs.token }}
|
||||
project-number: 94
|
||||
|
||||
6
.github/workflows/scorecards.yml
vendored
6
.github/workflows/scorecards.yml
vendored
@@ -28,7 +28,7 @@ jobs:
|
||||
|
||||
# This is a pre-submit / pre-release.
|
||||
- name: "Run analysis"
|
||||
uses: ossf/scorecard-action@62b2cac7ed8198b15735ed49ab1e5cf35480ba46 # v2.4.0
|
||||
uses: ossf/scorecard-action@f49aabe0b5af0936a0987cfb85d86b75731b0186 # v2.4.1
|
||||
with:
|
||||
results_file: results.sarif
|
||||
results_format: sarif
|
||||
@@ -42,7 +42,7 @@ jobs:
|
||||
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
|
||||
# format to the repository Actions tab.
|
||||
- name: "Upload artifact"
|
||||
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
|
||||
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
|
||||
with:
|
||||
name: SARIF file
|
||||
path: results.sarif
|
||||
@@ -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@b6a472f63d85b9c78a3ac5e89422239fc15e9b3c # v3.28.1
|
||||
uses: github/codeql-action/upload-sarif@6bb031afdd8eb862ea3fc1848194185e076637e5 # v3.28.11
|
||||
with:
|
||||
sarif_file: results.sarif
|
||||
|
||||
2
.github/workflows/stable-prep-items.yml
vendored
2
.github/workflows/stable-prep-items.yml
vendored
@@ -27,7 +27,7 @@ jobs:
|
||||
PROJECT_NUMBER=$(gh project list --owner electron --format json | jq -r '.projects | map(select(.title | test("^[0-9]+-x-y$"))) | max_by(.number) | .number')
|
||||
echo "PROJECT_NUMBER=$PROJECT_NUMBER" >> "$GITHUB_OUTPUT"
|
||||
- name: Update Completed Stable Prep Items
|
||||
uses: dsanders11/project-actions/completed-by@8bc0bd421be3a2f9e96e160c4cb703f97cd3be55 # v1.5.0
|
||||
uses: dsanders11/project-actions/completed-by@2134fe7cc71c58b7ae259c82a8e63c6058255678 # v1.7.0
|
||||
with:
|
||||
field: Prep Status
|
||||
field-value: ✅ Complete
|
||||
|
||||
4
.github/workflows/stale.yml
vendored
4
.github/workflows/stale.yml
vendored
@@ -16,7 +16,7 @@ jobs:
|
||||
id: generate-token
|
||||
with:
|
||||
creds: ${{ secrets.ISSUE_TRIAGE_GH_APP_CREDS }}
|
||||
- uses: actions/stale@28ca1036281a5e5922ead5184a1bbf96e5fc984e # tag: v9.0.0
|
||||
- uses: actions/stale@5bef64f19d7facfb25b37b414482c7164d639639 # tag: v9.1.0
|
||||
with:
|
||||
repo-token: ${{ steps.generate-token.outputs.token }}
|
||||
days-before-stale: 90
|
||||
@@ -39,7 +39,7 @@ jobs:
|
||||
id: generate-token
|
||||
with:
|
||||
creds: ${{ secrets.ISSUE_TRIAGE_GH_APP_CREDS }}
|
||||
- uses: actions/stale@28ca1036281a5e5922ead5184a1bbf96e5fc984e # tag: v9.0.0
|
||||
- uses: actions/stale@5bef64f19d7facfb25b37b414482c7164d639639 # tag: v9.1.0
|
||||
with:
|
||||
repo-token: ${{ steps.generate-token.outputs.token }}
|
||||
days-before-stale: -1
|
||||
|
||||
78
.github/workflows/update_appveyor_image.yml
vendored
78
.github/workflows/update_appveyor_image.yml
vendored
@@ -1,78 +0,0 @@
|
||||
name: Update AppVeyor Image
|
||||
|
||||
# Run chron daily Mon-Fri
|
||||
on:
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
- cron: '0 8 * * 1-5' # runs 8:00 every business day (see https://crontab.guru)
|
||||
|
||||
permissions: {}
|
||||
|
||||
jobs:
|
||||
bake-appveyor-image:
|
||||
name: Bake AppVeyor Image
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Generate GitHub App token
|
||||
uses: electron/github-app-auth-action@384fd19694fe7b6dcc9a684746c6976ad78228ae # v1.1.1
|
||||
id: generate-token
|
||||
with:
|
||||
creds: ${{ secrets.APPVEYOR_UPDATER_GH_APP_CREDS }}
|
||||
- name: Checkout
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
token: ${{ steps.generate-token.outputs.token }}
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
|
||||
with:
|
||||
node-version: 20.11.x
|
||||
- name: Yarn install
|
||||
run: |
|
||||
node script/yarn.js install --frozen-lockfile
|
||||
- name: Set Repo for Commit
|
||||
run: git config --global --add safe.directory $GITHUB_WORKSPACE
|
||||
- name: Check AppVeyor Image
|
||||
env:
|
||||
APPVEYOR_TOKEN: ${{ secrets.APPVEYOR_TOKEN }}
|
||||
run: |
|
||||
node ./script/prepare-appveyor
|
||||
if [ -f ./image_version.txt ]; then
|
||||
echo "APPVEYOR_IMAGE_VERSION="$(cat image_version.txt)"" >> $GITHUB_ENV
|
||||
rm image_version.txt
|
||||
fi
|
||||
- name: (Optionally) Update Appveyor Image
|
||||
if: ${{ env.APPVEYOR_IMAGE_VERSION }}
|
||||
uses: mikefarah/yq@8bf425b4d1344db7cd469a8d10a390876e0c77fd # v4.45.1
|
||||
with:
|
||||
cmd: |
|
||||
yq '.image = "${{ env.APPVEYOR_IMAGE_VERSION }}"' "appveyor.yml" > "appveyor2.yml"
|
||||
yq '.image = "${{ env.APPVEYOR_IMAGE_VERSION }}"' "appveyor-woa.yml" > "appveyor-woa2.yml"
|
||||
- name: (Optionally) Generate Commit Diff
|
||||
if: ${{ env.APPVEYOR_IMAGE_VERSION }}
|
||||
run: |
|
||||
diff -w -B appveyor.yml appveyor2.yml > appveyor.diff || true
|
||||
patch -f appveyor.yml < appveyor.diff
|
||||
rm appveyor2.yml appveyor.diff
|
||||
git add appveyor.yml
|
||||
- name: (Optionally) Generate Commit Diff for WOA
|
||||
if: ${{ env.APPVEYOR_IMAGE_VERSION }}
|
||||
run: |
|
||||
diff -w -B appveyor-woa.yml appveyor-woa2.yml > appveyor-woa.diff || true
|
||||
patch -f appveyor-woa.yml < appveyor-woa.diff
|
||||
rm appveyor-woa2.yml appveyor-woa.diff
|
||||
git add appveyor-woa.yml
|
||||
- name: (Optionally) Commit to Branch
|
||||
if: ${{ env.APPVEYOR_IMAGE_VERSION }}
|
||||
uses: dsanders11/github-app-commit-action@43de6da2f4d927e997c0784c7a0b61bd19ad6aac # v1.5.0
|
||||
with:
|
||||
message: 'build: update appveyor image to latest version'
|
||||
ref: bump-appveyor-image
|
||||
token: ${{ steps.generate-token.outputs.token }}
|
||||
- name: (Optionally) Create Pull Request
|
||||
if: ${{ env.APPVEYOR_IMAGE_VERSION }}
|
||||
run: |
|
||||
printf "This PR updates appveyor.yml to the latest baked image, ${{ env.APPVEYOR_IMAGE_VERSION }}.\n\nNotes: none" | gh pr create --head bump-appveyor-image --label no-backport --label semver/none --title 'build: update appveyor image to latest version' --body-file=-
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
|
||||
84
.github/workflows/windows-publish.yml
vendored
Normal file
84
.github/workflows/windows-publish.yml
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
name: Publish Windows
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
build-image-sha:
|
||||
type: string
|
||||
description: 'SHA for electron/build image'
|
||||
default: 'bc2f48b2415a670de18d13605b1cf0eb5fdbaae1'
|
||||
required: true
|
||||
upload-to-storage:
|
||||
description: 'Uploads to Azure storage'
|
||||
required: false
|
||||
default: '1'
|
||||
type: string
|
||||
run-windows-publish:
|
||||
description: 'Run the publish jobs vs just the build jobs'
|
||||
type: boolean
|
||||
default: false
|
||||
|
||||
jobs:
|
||||
checkout-windows:
|
||||
runs-on: electron-arc-linux-amd64-32core
|
||||
container:
|
||||
image: ghcr.io/electron/build:${{ inputs.build-image-sha }}
|
||||
options: --user root --device /dev/fuse --cap-add SYS_ADMIN
|
||||
volumes:
|
||||
- /mnt/cross-instance-cache:/mnt/cross-instance-cache
|
||||
env:
|
||||
GCLIENT_EXTRA_ARGS: '--custom-var=checkout_win=True'
|
||||
TARGET_OS: 'win'
|
||||
ELECTRON_DEPOT_TOOLS_WIN_TOOLCHAIN: '1'
|
||||
outputs:
|
||||
build-image-sha: ${{ inputs.build-image-sha }}
|
||||
steps:
|
||||
- name: Checkout Electron
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
|
||||
with:
|
||||
path: src/electron
|
||||
fetch-depth: 0
|
||||
- name: Checkout & Sync & Save
|
||||
uses: ./src/electron/.github/actions/checkout
|
||||
|
||||
publish-x64-win:
|
||||
uses: ./.github/workflows/pipeline-segment-electron-build.yml
|
||||
needs: checkout-windows
|
||||
with:
|
||||
environment: production-release
|
||||
build-runs-on: electron-arc-windows-amd64-16core
|
||||
target-platform: win
|
||||
target-arch: x64
|
||||
is-release: true
|
||||
gn-build-type: release
|
||||
generate-symbols: true
|
||||
upload-to-storage: ${{ inputs.upload-to-storage }}
|
||||
secrets: inherit
|
||||
|
||||
publish-arm64-win:
|
||||
uses: ./.github/workflows/pipeline-segment-electron-build.yml
|
||||
needs: checkout-windows
|
||||
with:
|
||||
environment: production-release
|
||||
build-runs-on: electron-arc-windows-amd64-16core
|
||||
target-platform: win
|
||||
target-arch: arm64
|
||||
is-release: true
|
||||
gn-build-type: release
|
||||
generate-symbols: true
|
||||
upload-to-storage: ${{ inputs.upload-to-storage }}
|
||||
secrets: inherit
|
||||
|
||||
publish-x86-win:
|
||||
uses: ./.github/workflows/pipeline-segment-electron-build.yml
|
||||
needs: checkout-windows
|
||||
with:
|
||||
environment: production-release
|
||||
build-runs-on: electron-arc-windows-amd64-16core
|
||||
target-platform: win
|
||||
target-arch: x86
|
||||
is-release: true
|
||||
gn-build-type: release
|
||||
generate-symbols: true
|
||||
upload-to-storage: ${{ inputs.upload-to-storage }}
|
||||
secrets: inherit
|
||||
14
BUILD.gn
14
BUILD.gn
@@ -224,11 +224,21 @@ webpack_build("electron_utility_bundle") {
|
||||
out_file = "$target_gen_dir/js2c/utility_init.js"
|
||||
}
|
||||
|
||||
webpack_build("electron_preload_realm_bundle") {
|
||||
deps = [ ":build_electron_definitions" ]
|
||||
|
||||
inputs = auto_filenames.preload_realm_bundle_deps
|
||||
|
||||
config_file = "//electron/build/webpack/webpack.config.preload_realm.js"
|
||||
out_file = "$target_gen_dir/js2c/preload_realm_bundle.js"
|
||||
}
|
||||
|
||||
action("electron_js2c") {
|
||||
deps = [
|
||||
":electron_browser_bundle",
|
||||
":electron_isolated_renderer_bundle",
|
||||
":electron_node_bundle",
|
||||
":electron_preload_realm_bundle",
|
||||
":electron_renderer_bundle",
|
||||
":electron_sandboxed_renderer_bundle",
|
||||
":electron_utility_bundle",
|
||||
@@ -240,6 +250,7 @@ action("electron_js2c") {
|
||||
"$target_gen_dir/js2c/browser_init.js",
|
||||
"$target_gen_dir/js2c/isolated_bundle.js",
|
||||
"$target_gen_dir/js2c/node_init.js",
|
||||
"$target_gen_dir/js2c/preload_realm_bundle.js",
|
||||
"$target_gen_dir/js2c/renderer_init.js",
|
||||
"$target_gen_dir/js2c/sandbox_bundle.js",
|
||||
"$target_gen_dir/js2c/utility_init.js",
|
||||
@@ -430,6 +441,7 @@ source_set("electron_lib") {
|
||||
"chromium_src:chrome_spellchecker",
|
||||
"shell/common:mojo",
|
||||
"shell/common:plugin",
|
||||
"shell/common:web_contents_utility",
|
||||
"shell/services/node/public/mojom",
|
||||
"//base:base_static",
|
||||
"//base/allocator:buildflags",
|
||||
@@ -439,7 +451,7 @@ source_set("electron_lib") {
|
||||
"//components/autofill/core/common:features",
|
||||
"//components/certificate_transparency",
|
||||
"//components/compose:buildflags",
|
||||
"//components/embedder_support:browser_util",
|
||||
"//components/embedder_support:user_agent",
|
||||
"//components/input:input",
|
||||
"//components/language/core/browser",
|
||||
"//components/net_log",
|
||||
|
||||
@@ -71,4 +71,4 @@ See [Coding Style](https://electronjs.org/docs/development/coding-style) for inf
|
||||
## Further Reading
|
||||
|
||||
For more in-depth guides on developing Electron, see
|
||||
[/docs/development](/docs/development/README.md)
|
||||
[/docs/development](/docs/development/README.md).
|
||||
|
||||
10
DEPS
10
DEPS
@@ -2,9 +2,9 @@ gclient_gn_args_from = 'src'
|
||||
|
||||
vars = {
|
||||
'chromium_version':
|
||||
'133.0.6920.0',
|
||||
'136.0.7067.0',
|
||||
'node_version':
|
||||
'v22.9.0',
|
||||
'v22.14.0',
|
||||
'nan_version':
|
||||
'e14bdcd1f72d62bca1d541b66da43130384ec213',
|
||||
'squirrel.mac_version':
|
||||
@@ -62,10 +62,6 @@ vars = {
|
||||
|
||||
'checkout_nacl':
|
||||
False,
|
||||
'checkout_libaom':
|
||||
True,
|
||||
'checkout_oculus_sdk':
|
||||
False,
|
||||
'checkout_openxr':
|
||||
False,
|
||||
'build_with_chromium':
|
||||
@@ -74,8 +70,6 @@ vars = {
|
||||
False,
|
||||
'checkout_android_native_support':
|
||||
False,
|
||||
'checkout_google_benchmark':
|
||||
False,
|
||||
'checkout_clang_tidy':
|
||||
True,
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
[](https://electronjs.org)
|
||||
|
||||
[](https://github.com/electron/electron/actions/workflows/build.yml)
|
||||
[](https://ci.appveyor.com/project/electron-bot/electron-ljo26/branch/main)
|
||||
[](https://discord.gg/electronjs)
|
||||
|
||||
:memo: Available Translations: 🇨🇳 🇧🇷 🇪🇸 🇯🇵 🇷🇺 🇫🇷 🇺🇸 🇩🇪.
|
||||
|
||||
@@ -1,107 +0,0 @@
|
||||
# The config is used to bake appveyor images, not for running CI jobs.
|
||||
# The config expects the following environment variables to be set:
|
||||
# - "APPVEYOR_BAKE_IMAGE" e.g. 'electron-99.0.4767.0'. Name of the image to be baked.
|
||||
# Typically named after the Chromium version on which the image is built.
|
||||
# This can be set dynamically in the prepare-appveyor script.
|
||||
|
||||
version: 1.0.{build}
|
||||
build_cloud: electronhq-16-core
|
||||
image: base-bake-image
|
||||
environment:
|
||||
GIT_CACHE_PATH: C:\Users\appveyor\libcc_cache
|
||||
ELECTRON_OUT_DIR: Default
|
||||
ELECTRON_ENABLE_STACK_DUMPING: 1
|
||||
MOCHA_REPORTER: mocha-multi-reporters
|
||||
MOCHA_MULTI_REPORTERS: mocha-appveyor-reporter, tap
|
||||
DEPOT_TOOLS_WIN_TOOLCHAIN: 0
|
||||
PYTHONIOENCODING: UTF-8
|
||||
|
||||
# The following lines are needed when baking from a completely new image (eg MicrosoftWindowsServer:WindowsServer:2019-Datacenter:latest via image: base-windows-server2019)
|
||||
# init:
|
||||
# - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
|
||||
# - appveyor version
|
||||
# - ps: $ErrorActionPreference = 'Stop'
|
||||
# - ps: 'Write-Host "OS Build: $((Get-CimInstance Win32_OperatingSystem).BuildNumber)"'
|
||||
|
||||
# clone_folder: '%USERPROFILE%\image-bake-scripts'
|
||||
|
||||
# clone_script:
|
||||
# - ps: Invoke-WebRequest "https://github.com/appveyor/build-images/archive/1f90d94e74c8243c909a09b994e527584dfcb838.zip" -OutFile "$env:temp\scripts.zip"
|
||||
# - ps: Expand-Archive -Path "$env:temp\scripts.zip" -DestinationPath "$env:temp\scripts" -Force
|
||||
# - ps: Copy-Item -Path "$env:temp\scripts\build-images-1f90d94e74c8243c909a09b994e527584dfcb838\scripts\Windows\*" -Destination $env:APPVEYOR_BUILD_FOLDER -Recurse
|
||||
|
||||
build_script:
|
||||
# The following lines are needed when baking from a completely new image (eg MicrosoftWindowsServer:WindowsServer:2019-Datacenter:latest via image: base-windows-server2019)
|
||||
# - ps: .\init_server.ps1
|
||||
# - ps: .\extend_system_volume.ps1
|
||||
|
||||
# # Restart VM
|
||||
# - ps: Start-Sleep -s 5; Restart-Computer
|
||||
# - ps: Start-Sleep -s 5
|
||||
|
||||
# - appveyor version
|
||||
# - ps: .\install_path_utils.ps1
|
||||
# - ps: .\install_powershell_core.ps1
|
||||
# - ps: .\install_powershell_get.ps1
|
||||
# - ps: .\install_7zip.ps1
|
||||
# - ps: .\install_chocolatey.ps1
|
||||
# - ps: .\install_webpi.ps1
|
||||
# - ps: .\install_nuget.ps1
|
||||
# - ps: .\install_pstools.ps1
|
||||
|
||||
# - ps: .\install_git.ps1
|
||||
# - ps: .\install_git_lfs.ps1
|
||||
|
||||
# # Restart VM
|
||||
# - ps: Start-Sleep -s 5; Restart-Computer
|
||||
# - ps: Start-Sleep -s 5
|
||||
# END LINES FOR COMPLETELY NEW IMAGE
|
||||
|
||||
- git config --global core.longpaths true
|
||||
- ps: >-
|
||||
if (-not (Test-Path -Path C:\projects\src)) {
|
||||
New-Item -Path C:\projects\src -ItemType Directory
|
||||
}
|
||||
- cd C:\projects\
|
||||
- git clone -q --branch=%APPVEYOR_REPO_BRANCH% https://github.com/electron/electron.git C:\projects\src\electron
|
||||
- git clone --depth=1 https://chromium.googlesource.com/chromium/tools/depot_tools.git
|
||||
- ps: $env:PATH="$pwd\depot_tools;$env:PATH"
|
||||
- update_depot_tools.bat
|
||||
# Uncomment the following line if windows deps change
|
||||
- src\electron\script\setup-win-for-dev.bat
|
||||
- >-
|
||||
gclient config
|
||||
--name "src\electron"
|
||||
--unmanaged
|
||||
%GCLIENT_EXTRA_ARGS%
|
||||
"https://github.com/electron/electron"
|
||||
- ps: cd src\electron
|
||||
- ps: node script\generate-deps-hash.js
|
||||
- ps: $depshash = Get-Content .\.depshash -Raw
|
||||
- ps: Copy-Item -path .\.depshash -destination ..\.depshash
|
||||
- ps: cd ..\..
|
||||
- gclient sync --with_branch_heads --with_tags --nohooks
|
||||
- ps: regsvr32 /s "C:\Program Files\Microsoft Visual Studio\2022\Community\DIA SDK\bin\amd64\msdia140.dll"
|
||||
- ps: set vs2022_install="C:\Program Files\Microsoft Visual Studio\2022\Community"
|
||||
|
||||
# The following lines are needed when baking from a completely new image (eg MicrosoftWindowsServer:WindowsServer:2019-Datacenter:latest via image: base-windows-server2019)
|
||||
# # Restart VM
|
||||
# - ps: Start-Sleep -s 5; Restart-Computer
|
||||
# - ps: Start-Sleep -s 5
|
||||
|
||||
# - cd %USERPROFILE%\image-bake-scripts
|
||||
# - appveyor version
|
||||
# - ps: .\optimize_dotnet_runtime.ps1
|
||||
# - ps: .\disable_windows_background_services.ps1
|
||||
# - ps: .\enforce_windows_firewall.ps1
|
||||
# - ps: .\cleanup_windows.ps1
|
||||
# END LINES FOR COMPLETELY NEW IMAGE
|
||||
on_image_bake:
|
||||
- ps: >-
|
||||
echo "Baking image: $env:APPVEYOR_BAKE_IMAGE at dir $PWD"
|
||||
- ps: Remove-Item -Recurse -Force C:\projects\depot_tools
|
||||
- ps: Remove-Item -Recurse -Force C:\projects\src\electron
|
||||
# Uncomment these lines and set APPVEYOR_RDP_PASSWORD in project settings to enable RDP after bake is done
|
||||
# # on_finish:
|
||||
# - ps: >-
|
||||
# $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
|
||||
352
appveyor-woa.yml
352
appveyor-woa.yml
@@ -1,352 +0,0 @@
|
||||
# NOTE IF CHANGING THIS FILE, ALSO APPLY THE CHANGE TO appveyor.yml
|
||||
# IF APPLICABLE!!!!
|
||||
#
|
||||
#
|
||||
# The config expects the following environment variables to be set:
|
||||
# - "GN_CONFIG" Build type. One of {'testing', 'release'}.
|
||||
# - "GN_EXTRA_ARGS" Additional gn arguments for a build config,
|
||||
# e.g. 'target_cpu="x86"' to build for a 32bit platform.
|
||||
# https://gn.googlesource.com/gn/+/main/docs/reference.md#var_target_cpu
|
||||
# Don't forget to set up "NPM_CONFIG_ARCH" and "TARGET_ARCH" accordingly
|
||||
# if you pass a custom value for 'target_cpu'.
|
||||
# - "ELECTRON_RELEASE" Set it to '1' upload binaries on success.
|
||||
# - "NPM_CONFIG_ARCH" E.g. 'x86'. Is used to build native Node.js modules.
|
||||
# Must match 'target_cpu' passed to "GN_EXTRA_ARGS" and "TARGET_ARCH" value.
|
||||
# - "TARGET_ARCH" Choose from {'ia32', 'x64', 'arm', 'arm64'}.
|
||||
# Is used in some publishing scripts, but does NOT affect the Electron binary.
|
||||
# Must match 'target_cpu' passed to "GN_EXTRA_ARGS" and "NPM_CONFIG_ARCH" value.
|
||||
# - "UPLOAD_TO_STORAGE" Set it to '1' upload a release to the Azure bucket.
|
||||
# Otherwise the release will be uploaded to the GitHub Releases.
|
||||
# (The value is only checked if "ELECTRON_RELEASE" is defined.)
|
||||
#
|
||||
# The publishing scripts expect access tokens to be defined as env vars,
|
||||
# but those are not covered here.
|
||||
#
|
||||
# AppVeyor docs on variables:
|
||||
# https://www.appveyor.com/docs/environment-variables/
|
||||
# https://www.appveyor.com/docs/build-configuration/#secure-variables
|
||||
# https://www.appveyor.com/docs/build-configuration/#custom-environment-variables
|
||||
|
||||
version: 1.0.{build}
|
||||
build_cloud: electronhq-16-core
|
||||
image: e-133.0.6878.0
|
||||
environment:
|
||||
GIT_CACHE_PATH: C:\Users\appveyor\libcc_cache
|
||||
ELECTRON_OUT_DIR: Default
|
||||
ELECTRON_ENABLE_STACK_DUMPING: 1
|
||||
ELECTRON_ALSO_LOG_TO_STDERR: 1
|
||||
MOCHA_REPORTER: mocha-multi-reporters
|
||||
MOCHA_MULTI_REPORTERS: "@marshallofsound/mocha-appveyor-reporter, mocha-junit-reporter, tap"
|
||||
DEPOT_TOOLS_WIN_TOOLCHAIN: 1
|
||||
DEPOT_TOOLS_WIN_TOOLCHAIN_BASE_URL: "https://dev-cdn.electronjs.org/windows-toolchains/_"
|
||||
GYP_MSVS_HASH_7393122652: 3ba76c5c20
|
||||
PYTHONIOENCODING: UTF-8
|
||||
|
||||
matrix:
|
||||
|
||||
- job_name: Build Arm on X64 Windows
|
||||
- job_name: Test On Windows On Arm Hardware 1
|
||||
job_depends_on: Build Arm on X64 Windows
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: base-woa
|
||||
APPVEYOR_BUILD_WORKER_CLOUD: electronhq-woa
|
||||
shard: 1
|
||||
- job_name: Test On Windows On Arm Hardware 2
|
||||
job_depends_on: Build Arm on X64 Windows
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: base-woa
|
||||
APPVEYOR_BUILD_WORKER_CLOUD: electronhq-woa
|
||||
shard: 2
|
||||
|
||||
clone_script:
|
||||
- ps: git clone -q $("--branch=" + $Env:APPVEYOR_REPO_BRANCH) $("https://github.com/" + $Env:APPVEYOR_REPO_NAME + ".git") $Env:APPVEYOR_BUILD_FOLDER
|
||||
- ps: if (!$Env:APPVEYOR_PULL_REQUEST_NUMBER) {$("git checkout -qf " + $Env:APPVEYOR_REPO_COMMIT)}
|
||||
- ps: if ($Env:APPVEYOR_PULL_REQUEST_NUMBER) {git fetch -q origin +refs/pull/$($Env:APPVEYOR_PULL_REQUEST_NUMBER)/head; git checkout -qf FETCH_HEAD}
|
||||
|
||||
clone_folder: C:\projects\src\electron
|
||||
|
||||
skip_branch_with_pr: true
|
||||
|
||||
# the first failed job cancels other jobs and fails entire build
|
||||
matrix:
|
||||
fast_finish: true
|
||||
|
||||
for:
|
||||
|
||||
- matrix:
|
||||
only:
|
||||
- job_name: Build Arm on X64 Windows
|
||||
|
||||
build_script:
|
||||
# TODO: Remove --ignore-engines once WOA image is up to node 20
|
||||
- ps: |
|
||||
node script/yarn.js install --frozen-lockfile --ignore-engines
|
||||
node script/doc-only-change.js --prNumber=$env:APPVEYOR_PULL_REQUEST_NUMBER
|
||||
$env:SHOULD_SKIP_ARTIFACT_VALIDATION = "false"
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
Write-warning "Skipping build for doc-only change"
|
||||
$env:SHOULD_SKIP_ARTIFACT_VALIDATION = "true"
|
||||
Exit-AppveyorBuild
|
||||
} else {
|
||||
$global:LASTEXITCODE = 0
|
||||
}
|
||||
- cd ..
|
||||
- ps: Write-Host "Building $env:GN_CONFIG build"
|
||||
- git config --global core.longpaths true
|
||||
- ps: >-
|
||||
if (Test-Path -Path "$pwd\depot_tools") {
|
||||
Remove-Item -Recurse -Force $pwd\depot_tools
|
||||
}
|
||||
- ps: >-
|
||||
if (Test-Path -Path "$pwd\build-tools") {
|
||||
Remove-Item -Recurse -Force $pwd\build-tools
|
||||
}
|
||||
- git clone --depth=1 https://chromium.googlesource.com/chromium/tools/depot_tools.git
|
||||
- ps: New-Item -Name depot_tools\.disable_auto_update -ItemType File
|
||||
- depot_tools\bootstrap\win_tools.bat
|
||||
- ps: |
|
||||
Set-Content -Path $pwd\depot_tools\build_telemetry.cfg -Value '{"user": "info@electronjs.org", "status": "opt-out", "countdown": 10, "version": 1}'
|
||||
- ps: $env:PATH="$pwd\depot_tools;$env:PATH"
|
||||
- ps: >-
|
||||
if (Test-Path -Path "$pwd\src\electron") {
|
||||
Remove-Item -Recurse -Force $pwd\src\electron
|
||||
}
|
||||
- git clone https://github.com/electron/build-tools.git
|
||||
- cd build-tools
|
||||
- npx yarn --ignore-engines
|
||||
- mkdir third_party
|
||||
- ps: >-
|
||||
node -e "require('./src/utils/reclient.js').downloadAndPrepare({})"
|
||||
- ps: $env:RECLIENT_HELPER = node -p "require('./src/utils/reclient.js').helperPath({})"
|
||||
- ps: >-
|
||||
& $env:RECLIENT_HELPER login
|
||||
- ps: >-
|
||||
$env:RBE_service = node -e "console.log(require('./src/utils/reclient.js').serviceAddress)"
|
||||
- ps: >-
|
||||
$env:RBE_credentials_helper = $env:RECLIENT_HELPER
|
||||
- ps: >-
|
||||
$env:RBE_credentials_helper_args = "print"
|
||||
- ps: >-
|
||||
if ($env:ELECTRON_RBE_JWT -eq '') {
|
||||
$env:RBE_fail_early_min_action_count = "0"
|
||||
$env:RBE_fail_early_min_fallback_ratio = "0"
|
||||
}
|
||||
- cd ..\..
|
||||
- ps: $env:CHROMIUM_BUILDTOOLS_PATH="$pwd\src\buildtools"
|
||||
- ps: >-
|
||||
if ($env:GN_CONFIG -ne 'release') {
|
||||
$env:NINJA_STATUS="[%r processes, %f/%t @ %o/s : %es] "
|
||||
}
|
||||
- gclient config --name "src\electron" --unmanaged %GCLIENT_EXTRA_ARGS% "https://github.com/electron/electron"
|
||||
# Patches are applied in the image bake. Check depshash to see if patches have changed.
|
||||
- ps: $env:RUN_GCLIENT_SYNC="false"
|
||||
- ps: $depshash_baked = Get-Content .\src\.depshash -Raw
|
||||
- ps: cd src\electron
|
||||
- ps: node script\generate-deps-hash.js
|
||||
- ps: $depshash = Get-Content .\.depshash -Raw
|
||||
- ps: cd ..\..
|
||||
- ps: >-
|
||||
if ($depshash_baked -ne $depshash) {
|
||||
$env:RUN_GCLIENT_SYNC="true"
|
||||
}
|
||||
- if "%RUN_GCLIENT_SYNC%"=="true" ( gclient sync --with_branch_heads --with_tags ) else ( gclient runhooks )
|
||||
- cd src
|
||||
- ps: $env:PATH="$pwd\third_party\ninja;$env:PATH"
|
||||
- set BUILD_CONFIG_PATH=//electron/build/args/%GN_CONFIG%.gn
|
||||
- gn gen out/Default "--args=import(\"%BUILD_CONFIG_PATH%\") use_remoteexec=true %GN_EXTRA_ARGS% "
|
||||
- gn check out/Default //electron:electron_lib
|
||||
- gn check out/Default //electron:electron_app
|
||||
- gn check out/Default //electron/shell/common:mojo
|
||||
- gn check out/Default //electron/shell/common:plugin
|
||||
- autoninja -j 300 -C out/Default electron:electron_app
|
||||
- if "%GN_CONFIG%"=="testing" ( python C:\depot_tools\post_build_ninja_summary.py -C out\Default )
|
||||
- gn gen out/ffmpeg "--args=import(\"//electron/build/args/ffmpeg.gn\") use_remoteexec=true %GN_EXTRA_ARGS%"
|
||||
- autoninja -C out/ffmpeg electron:electron_ffmpeg_zip
|
||||
- autoninja -C out/Default electron:electron_dist_zip
|
||||
- gn desc out/Default v8:run_mksnapshot_default args > out/Default/default_mksnapshot_args
|
||||
# Remove unused args from mksnapshot_args
|
||||
- ps: >-
|
||||
Get-Content out/Default/default_mksnapshot_args | Where-Object { -not $_.Contains('--turbo-profiling-input') -And -not $_.Contains('builtins-pgo') } | Set-Content out/Default/mksnapshot_args
|
||||
- autoninja -C out/Default electron:electron_mksnapshot_zip
|
||||
- cd out\Default
|
||||
- 7z a mksnapshot.zip mksnapshot_args gen\v8\embedded.S
|
||||
- cd ..\..
|
||||
- autoninja -C out/Default electron:hunspell_dictionaries_zip
|
||||
- autoninja -C out/Default electron:electron_chromedriver_zip
|
||||
- autoninja -C out/Default electron:node_headers
|
||||
- ps: >-
|
||||
Get-CimInstance -Namespace root\cimv2 -Class Win32_product | Select vendor, description, @{l='install_location';e='InstallLocation'}, @{l='install_date';e='InstallDate'}, @{l='install_date_2';e='InstallDate2'}, caption, version, name, @{l='sku_number';e='SKUNumber'} | ConvertTo-Json | Out-File -Encoding utf8 -FilePath .\installed_software.json
|
||||
- python3 electron/build/profile_toolchain.py --output-json=out/Default/windows_toolchain_profile.json
|
||||
- 7z a node_headers.zip out\Default\gen\node_headers
|
||||
- 7z a nan.zip third_party\nan
|
||||
- ps: >-
|
||||
if ($env:GN_CONFIG -eq 'release') {
|
||||
# Needed for msdia140.dll on 64-bit windows
|
||||
$env:Path += ";$pwd\third_party\llvm-build\Release+Asserts\bin"
|
||||
}
|
||||
- if "%GN_CONFIG%"=="release" ( autoninja -C out/Default electron:electron_symbols )
|
||||
- ps: >-
|
||||
if ($env:GN_CONFIG -eq 'release') {
|
||||
python3 electron\script\zip-symbols.py
|
||||
appveyor-retry appveyor PushArtifact out/Default/symbols.zip
|
||||
} else {
|
||||
# It's useful to have pdb files when debugging testing builds that are
|
||||
# built on CI.
|
||||
7z a pdb.zip out\Default\*.pdb
|
||||
}
|
||||
- ps: |
|
||||
$manifest_file = "electron/script/zip_manifests/dist_zip.win.$env:TARGET_ARCH.manifest"
|
||||
python3 electron/script/zip_manifests/check-zip-manifest.py out/Default/dist.zip $manifest_file
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "Zip contains files not listed in the manifest $manifest_file"
|
||||
}
|
||||
- ps: |
|
||||
cd C:\projects\src
|
||||
$missing_artifacts = $false
|
||||
if ($env:SHOULD_SKIP_ARTIFACT_VALIDATION -eq 'true') {
|
||||
Write-warning "Skipping artifact validation for doc-only $env:APPVEYOR_PROJECT_NAME"
|
||||
} else {
|
||||
$artifacts_to_validate = 'dist.zip','windows_toolchain_profile.json','chromedriver.zip','ffmpeg.zip','node_headers.zip','mksnapshot.zip','electron.lib','hunspell_dictionaries.zip','nan.zip'
|
||||
foreach($artifact_name in $artifacts_to_validate) {
|
||||
if ($artifact_name -eq 'ffmpeg.zip') {
|
||||
$artifact_file = "out\ffmpeg\ffmpeg.zip"
|
||||
} elseif (
|
||||
$artifact_name -eq 'node_headers.zip') {
|
||||
$artifact_file = $artifact_name
|
||||
} elseif (
|
||||
$artifact_name -eq 'nan.zip') {
|
||||
$artifact_file = $artifact_name
|
||||
} else {
|
||||
$artifact_file = "out\Default\$artifact_name"
|
||||
}
|
||||
if (-not(Test-Path $artifact_file)) {
|
||||
Write-warning "$artifact_name is missing and cannot be added to artifacts"
|
||||
$missing_artifacts = $true
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($missing_artifacts) {
|
||||
throw "Build failed due to missing artifacts"
|
||||
}
|
||||
|
||||
deploy_script:
|
||||
- cd electron
|
||||
- ps: >-
|
||||
if (Test-Path Env:\ELECTRON_RELEASE) {
|
||||
if (Test-Path Env:\UPLOAD_TO_STORAGE) {
|
||||
Write-Output "Uploading Electron release distribution to azure"
|
||||
& python3 script\release\uploaders\upload.py --verbose --upload_to_storage
|
||||
} else {
|
||||
Write-Output "Uploading Electron release distribution to github releases"
|
||||
& python3 script\release\uploaders\upload.py --verbose
|
||||
}
|
||||
}
|
||||
on_finish:
|
||||
# Uncomment this lines to enable RDP
|
||||
# - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
|
||||
- cd C:\projects\src
|
||||
- if exist out\Default\windows_toolchain_profile.json ( appveyor-retry appveyor PushArtifact out\Default\windows_toolchain_profile.json )
|
||||
- if exist out\Default\dist.zip (appveyor-retry appveyor PushArtifact out\Default\dist.zip)
|
||||
- if exist out\Default\chromedriver.zip (appveyor-retry appveyor PushArtifact out\Default\chromedriver.zip)
|
||||
- if exist out\ffmpeg\ffmpeg.zip (appveyor-retry appveyor PushArtifact out\ffmpeg\ffmpeg.zip)
|
||||
- if exist node_headers.zip (appveyor-retry appveyor PushArtifact node_headers.zip)
|
||||
- if exist nan.zip (appveyor-retry appveyor PushArtifact nan.zip)
|
||||
- if exist out\Default\mksnapshot.zip (appveyor-retry appveyor PushArtifact out\Default\mksnapshot.zip)
|
||||
- if exist out\Default\hunspell_dictionaries.zip (appveyor-retry appveyor PushArtifact out\Default\hunspell_dictionaries.zip)
|
||||
- if exist out\Default\electron.lib (appveyor-retry appveyor PushArtifact out\Default\electron.lib)
|
||||
- ps: >-
|
||||
if ((Test-Path "pdb.zip") -And ($env:GN_CONFIG -ne 'release')) {
|
||||
appveyor-retry appveyor PushArtifact pdb.zip
|
||||
}
|
||||
- matrix:
|
||||
only:
|
||||
- job_name: Test On Windows On Arm Hardware 1
|
||||
- job_name: Test On Windows On Arm Hardware 2
|
||||
|
||||
environment:
|
||||
IGNORE_YARN_INSTALL_ERROR: 1
|
||||
ELECTRON_TEST_RESULTS_DIR: C:\projects\src\electron\junit
|
||||
MOCHA_MULTI_REPORTERS: "@marshallofsound/mocha-appveyor-reporter, mocha-junit-reporter, tap"
|
||||
MOCHA_REPORTER: mocha-multi-reporters
|
||||
ELECTRON_SKIP_NATIVE_MODULE_TESTS: true
|
||||
DD_ENV: ci
|
||||
DD_SERVICE: electron
|
||||
DD_CIVISIBILITY_LOGS_ENABLED: true
|
||||
DD_GIT_REPOSITORY_URL: "https://github.com/electron/electron.git"
|
||||
|
||||
build_script:
|
||||
- ps: |
|
||||
node script/yarn.js install --frozen-lockfile --ignore-engines
|
||||
node script/doc-only-change.js --prNumber=$env:APPVEYOR_PULL_REQUEST_NUMBER
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
Write-warning "Skipping build for doc only change"
|
||||
Exit-AppveyorBuild
|
||||
} else {
|
||||
$global:LASTEXITCODE = 0
|
||||
}
|
||||
- ps: Invoke-WebRequest -Uri "https://github.com/DataDog/datadog-ci/releases/latest/download/datadog-ci_win-x64" -OutFile "C:\projects\src\electron\datadog-ci.exe"
|
||||
- cd ..
|
||||
- mkdir out\Default
|
||||
- cd ..
|
||||
- ps: |
|
||||
# Download build artifacts
|
||||
$apiUrl = 'https://ci.appveyor.com/api'
|
||||
$build_info = Invoke-RestMethod -Method Get -Uri "$apiUrl/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/builds/$env:APPVEYOR_BUILD_ID"
|
||||
$artifacts_to_download = @('dist.zip','ffmpeg.zip','node_headers.zip','electron.lib', 'nan.zip')
|
||||
foreach ($job in $build_info.build.jobs) {
|
||||
if ($job.name -eq "Build Arm on X64 Windows") {
|
||||
$jobId = $job.jobId
|
||||
foreach($artifact_name in $artifacts_to_download) {
|
||||
if ($artifact_name -eq 'electron.lib') {
|
||||
$outfile = "src\out\Default\$artifact_name"
|
||||
} else {
|
||||
$outfile = $artifact_name
|
||||
}
|
||||
Invoke-RestMethod -Method Get -Uri "$apiUrl/buildjobs/$jobId/artifacts/$artifact_name" -OutFile $outfile
|
||||
}
|
||||
# Uncomment the following lines to download the pdb.zip to show real stacktraces when crashes happen during testing
|
||||
Invoke-RestMethod -Method Get -Uri "$apiUrl/buildjobs/$jobId/artifacts/pdb.zip" -OutFile pdb.zip
|
||||
7z x -y -osrc pdb.zip
|
||||
}
|
||||
}
|
||||
- ps: |
|
||||
$out_default_zips = @('dist.zip')
|
||||
foreach($zip_name in $out_default_zips) {
|
||||
7z x -y -osrc\out\Default $zip_name
|
||||
}
|
||||
- ps: 7z x -y -osrc\out\ffmpeg ffmpeg.zip
|
||||
- ps: 7z x -y -osrc node_headers.zip
|
||||
- ps: 7z x -y -osrc nan.zip
|
||||
|
||||
test_script:
|
||||
# Workaround for https://github.com/appveyor/ci/issues/2420
|
||||
- set "PATH=%PATH%;C:\Program Files\Git\mingw64\libexec\git-core"
|
||||
- ps: |
|
||||
cd src
|
||||
New-Item .\out\Default\gen\node_headers\Release -Type directory
|
||||
Copy-Item -path .\out\Default\electron.lib -destination .\out\Default\gen\node_headers\Release\node.lib
|
||||
- set npm_config_nodedir=%cd%\out\Default\gen\node_headers
|
||||
- set npm_config_arch=arm64
|
||||
- cd electron
|
||||
# Explicitly set npm_config_arch because the .env doesn't persist
|
||||
- ps: >-
|
||||
if ($env:TARGET_ARCH -eq 'ia32') {
|
||||
$env:npm_config_arch = "ia32"
|
||||
}
|
||||
- ps: $env:tests_files=node script\split-tests $env:shard 2
|
||||
- echo "Running shard %shard% specs %tests_files%"
|
||||
- echo Running main test suite & node script/yarn test --runners=main --enable-logging --disable-features=CalculateNativeWinOcclusion --files %tests_files%
|
||||
- cd ..
|
||||
- echo Verifying non proprietary ffmpeg & python electron\script\verify-ffmpeg.py --build-dir out\Default --source-root %cd% --ffmpeg-path out\ffmpeg
|
||||
|
||||
on_finish:
|
||||
# Uncomment these lines to enable RDP
|
||||
# - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
|
||||
- if exist electron\junit\test-results-main.xml ( appveyor-retry appveyor PushArtifact electron\junit\test-results-main.xml )
|
||||
- ps: |
|
||||
if ($env:DD_API_KEY) {
|
||||
$env:DD_GIT_COMMIT_SHA = $env:APPVEYOR_REPO_COMMIT
|
||||
$env:DD_GIT_BRANCH = $env:APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH
|
||||
$env:DD_TAGS = "os.architecture:$env:TARGET_ARCH,os.family:windows,os.platform:win32"
|
||||
if (Test-Path -Path "C:\projects\src\electron\junit\test-results-main.xml") {
|
||||
C:\projects\src\electron\datadog-ci.exe junit upload --verbose C:\projects\src\electron\junit\test-results-main.xml
|
||||
}
|
||||
}
|
||||
350
appveyor.yml
350
appveyor.yml
@@ -1,350 +0,0 @@
|
||||
# NOTE IF CHANGING THIS FILE, ALSO APPLY THE CHANGE TO appveyor-woa.yml
|
||||
# IF APPLICABLE!!!!
|
||||
#
|
||||
#
|
||||
# The config expects the following environment variables to be set:
|
||||
# - "GN_CONFIG" Build type. One of {'testing', 'release'}.
|
||||
# - "GN_EXTRA_ARGS" Additional gn arguments for a build config,
|
||||
# e.g. 'target_cpu="x86"' to build for a 32bit platform.
|
||||
# https://gn.googlesource.com/gn/+/main/docs/reference.md#var_target_cpu
|
||||
# Don't forget to set up "NPM_CONFIG_ARCH" and "TARGET_ARCH" accordingly
|
||||
# if you pass a custom value for 'target_cpu'.
|
||||
# - "ELECTRON_RELEASE" Set it to '1' upload binaries on success.
|
||||
# - "NPM_CONFIG_ARCH" E.g. 'x86'. Is used to build native Node.js modules.
|
||||
# Must match 'target_cpu' passed to "GN_EXTRA_ARGS" and "TARGET_ARCH" value.
|
||||
# - "TARGET_ARCH" Choose from {'ia32', 'x64', 'arm', 'arm64'}.
|
||||
# Is used in some publishing scripts, but does NOT affect the Electron binary.
|
||||
# Must match 'target_cpu' passed to "GN_EXTRA_ARGS" and "NPM_CONFIG_ARCH" value.
|
||||
# - "UPLOAD_TO_STORAGE" Set it to '1' upload a release to the Azure bucket.
|
||||
# Otherwise the release will be uploaded to the GitHub Releases.
|
||||
# (The value is only checked if "ELECTRON_RELEASE" is defined.)
|
||||
#
|
||||
# The publishing scripts expect access tokens to be defined as env vars,
|
||||
# but those are not covered here.
|
||||
#
|
||||
# AppVeyor docs on variables:
|
||||
# https://www.appveyor.com/docs/environment-variables/
|
||||
# https://www.appveyor.com/docs/build-configuration/#secure-variables
|
||||
# https://www.appveyor.com/docs/build-configuration/#custom-environment-variables
|
||||
|
||||
version: 1.0.{build}
|
||||
build_cloud: electronhq-16-core
|
||||
image: e-133.0.6878.0
|
||||
environment:
|
||||
GIT_CACHE_PATH: C:\Users\appveyor\libcc_cache
|
||||
ELECTRON_OUT_DIR: Default
|
||||
ELECTRON_ENABLE_STACK_DUMPING: 1
|
||||
ELECTRON_ALSO_LOG_TO_STDERR: 1
|
||||
MOCHA_REPORTER: mocha-multi-reporters
|
||||
MOCHA_MULTI_REPORTERS: "@marshallofsound/mocha-appveyor-reporter, mocha-junit-reporter, tap"
|
||||
DEPOT_TOOLS_WIN_TOOLCHAIN: 1
|
||||
DEPOT_TOOLS_WIN_TOOLCHAIN_BASE_URL: "https://dev-cdn.electronjs.org/windows-toolchains/_"
|
||||
GYP_MSVS_HASH_7393122652: 3ba76c5c20
|
||||
PYTHONIOENCODING: UTF-8
|
||||
|
||||
matrix:
|
||||
|
||||
- job_name: Build
|
||||
- job_name: Test 1
|
||||
job_depends_on: Build
|
||||
shard: 1
|
||||
- job_name: Test 2
|
||||
job_depends_on: Build
|
||||
shard: 2
|
||||
|
||||
clone_script:
|
||||
- ps: git clone -q $("--branch=" + $Env:APPVEYOR_REPO_BRANCH) $("https://github.com/" + $Env:APPVEYOR_REPO_NAME + ".git") $Env:APPVEYOR_BUILD_FOLDER
|
||||
- ps: if (!$Env:APPVEYOR_PULL_REQUEST_NUMBER) {$("git checkout -qf " + $Env:APPVEYOR_REPO_COMMIT)}
|
||||
- ps: if ($Env:APPVEYOR_PULL_REQUEST_NUMBER) {git fetch -q origin +refs/pull/$($Env:APPVEYOR_PULL_REQUEST_NUMBER)/head; git checkout -qf FETCH_HEAD}
|
||||
|
||||
clone_folder: C:\projects\src\electron
|
||||
|
||||
skip_branch_with_pr: true
|
||||
|
||||
# the first failed job cancels other jobs and fails entire build
|
||||
matrix:
|
||||
fast_finish: true
|
||||
|
||||
for:
|
||||
|
||||
- matrix:
|
||||
only:
|
||||
- job_name: Build
|
||||
|
||||
build_script:
|
||||
- ps: |
|
||||
node script/yarn.js install --frozen-lockfile
|
||||
node script/doc-only-change.js --prNumber=$env:APPVEYOR_PULL_REQUEST_NUMBER
|
||||
$env:SHOULD_SKIP_ARTIFACT_VALIDATION = "false"
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
Write-warning "Skipping build for doc-only change"
|
||||
$env:SHOULD_SKIP_ARTIFACT_VALIDATION = "true"
|
||||
Exit-AppveyorBuild
|
||||
} else {
|
||||
$global:LASTEXITCODE = 0
|
||||
}
|
||||
- cd ..
|
||||
- ps: Write-Host "Building $env:GN_CONFIG build"
|
||||
- git config --global core.longpaths true
|
||||
- ps: >-
|
||||
if (Test-Path -Path "$pwd\depot_tools") {
|
||||
Remove-Item -Recurse -Force $pwd\depot_tools
|
||||
}
|
||||
- ps: >-
|
||||
if (Test-Path -Path "$pwd\build-tools") {
|
||||
Remove-Item -Recurse -Force $pwd\build-tools
|
||||
}
|
||||
- git clone --depth=1 https://chromium.googlesource.com/chromium/tools/depot_tools.git
|
||||
- ps: New-Item -Name depot_tools\.disable_auto_update -ItemType File
|
||||
- depot_tools\bootstrap\win_tools.bat
|
||||
- ps: |
|
||||
Set-Content -Path $pwd\depot_tools\build_telemetry.cfg -Value '{"user": "info@electronjs.org", "status": "opt-out", "countdown": 10, "version": 1}'
|
||||
- ps: $env:PATH="$pwd\depot_tools;$env:PATH"
|
||||
- ps: >-
|
||||
if (Test-Path -Path "$pwd\src\electron") {
|
||||
Remove-Item -Recurse -Force $pwd\src\electron
|
||||
}
|
||||
- git clone https://github.com/electron/build-tools.git
|
||||
- cd build-tools
|
||||
- npx yarn --ignore-engines
|
||||
- mkdir third_party
|
||||
- ps: >-
|
||||
node -e "require('./src/utils/reclient.js').downloadAndPrepare({})"
|
||||
- ps: $env:RECLIENT_HELPER = node -p "require('./src/utils/reclient.js').helperPath({})"
|
||||
- ps: >-
|
||||
& $env:RECLIENT_HELPER login
|
||||
- ps: >-
|
||||
$env:RBE_service = node -e "console.log(require('./src/utils/reclient.js').serviceAddress)"
|
||||
- ps: >-
|
||||
$env:RBE_credentials_helper = $env:RECLIENT_HELPER
|
||||
- ps: >-
|
||||
$env:RBE_credentials_helper_args = "print"
|
||||
- ps: >-
|
||||
if ($env:ELECTRON_RBE_JWT -eq '') {
|
||||
$env:RBE_fail_early_min_action_count = "0"
|
||||
$env:RBE_fail_early_min_fallback_ratio = "0"
|
||||
}
|
||||
- cd ..\..
|
||||
- ps: $env:CHROMIUM_BUILDTOOLS_PATH="$pwd\src\buildtools"
|
||||
- ps: >-
|
||||
if ($env:GN_CONFIG -ne 'release') {
|
||||
$env:NINJA_STATUS="[%r processes, %f/%t @ %o/s : %es] "
|
||||
}
|
||||
- gclient config --name "src\electron" --unmanaged %GCLIENT_EXTRA_ARGS% "https://github.com/electron/electron"
|
||||
# Patches are applied in the image bake. Check depshash to see if patches have changed.
|
||||
- ps: $env:RUN_GCLIENT_SYNC="false"
|
||||
- ps: $depshash_baked = Get-Content .\src\.depshash -Raw
|
||||
- ps: cd src\electron
|
||||
- ps: node script\generate-deps-hash.js
|
||||
- ps: $depshash = Get-Content .\.depshash -Raw
|
||||
- ps: cd ..\..
|
||||
- ps: >-
|
||||
if ($depshash_baked -ne $depshash) {
|
||||
$env:RUN_GCLIENT_SYNC="true"
|
||||
}
|
||||
- if "%RUN_GCLIENT_SYNC%"=="true" ( gclient sync --with_branch_heads --with_tags ) else ( gclient runhooks )
|
||||
- cd src
|
||||
- ps: $env:PATH="$pwd\third_party\ninja;$env:PATH"
|
||||
- set BUILD_CONFIG_PATH=//electron/build/args/%GN_CONFIG%.gn
|
||||
- gn gen out/Default "--args=import(\"%BUILD_CONFIG_PATH%\") use_remoteexec=true %GN_EXTRA_ARGS% "
|
||||
- gn check out/Default //electron:electron_lib
|
||||
- gn check out/Default //electron:electron_app
|
||||
- gn check out/Default //electron/shell/common:mojo
|
||||
- gn check out/Default //electron/shell/common:plugin
|
||||
- autoninja -j 300 -C out/Default electron:electron_app
|
||||
- if "%GN_CONFIG%"=="testing" ( python C:\depot_tools\post_build_ninja_summary.py -C out\Default )
|
||||
- gn gen out/ffmpeg "--args=import(\"//electron/build/args/ffmpeg.gn\") use_remoteexec=true %GN_EXTRA_ARGS%"
|
||||
- autoninja -C out/ffmpeg electron:electron_ffmpeg_zip
|
||||
- autoninja -C out/Default electron:electron_dist_zip
|
||||
- gn desc out/Default v8:run_mksnapshot_default args > out/Default/default_mksnapshot_args
|
||||
# Remove unused args from mksnapshot_args
|
||||
- ps: >-
|
||||
Get-Content out/Default/default_mksnapshot_args | Where-Object { -not $_.Contains('--turbo-profiling-input') -And -not $_.Contains('builtins-pgo') } | Set-Content out/Default/mksnapshot_args
|
||||
- autoninja -C out/Default electron:electron_mksnapshot_zip
|
||||
- cd out\Default
|
||||
- 7z a mksnapshot.zip mksnapshot_args gen\v8\embedded.S
|
||||
- cd ..\..
|
||||
- autoninja -C out/Default electron:hunspell_dictionaries_zip
|
||||
- autoninja -C out/Default electron:electron_chromedriver_zip
|
||||
- autoninja -C out/Default electron:node_headers
|
||||
- ps: >-
|
||||
Get-CimInstance -Namespace root\cimv2 -Class Win32_product | Select vendor, description, @{l='install_location';e='InstallLocation'}, @{l='install_date';e='InstallDate'}, @{l='install_date_2';e='InstallDate2'}, caption, version, name, @{l='sku_number';e='SKUNumber'} | ConvertTo-Json | Out-File -Encoding utf8 -FilePath .\installed_software.json
|
||||
- python3 electron/build/profile_toolchain.py --output-json=out/Default/windows_toolchain_profile.json
|
||||
- 7z a node_headers.zip out\Default\gen\node_headers
|
||||
- ps: >-
|
||||
if ($env:GN_CONFIG -eq 'release') {
|
||||
# Needed for msdia140.dll on 64-bit windows
|
||||
$env:Path += ";$pwd\third_party\llvm-build\Release+Asserts\bin"
|
||||
}
|
||||
- if "%GN_CONFIG%"=="release" ( autoninja -C out/Default electron:electron_symbols )
|
||||
- ps: >-
|
||||
if ($env:GN_CONFIG -eq 'release') {
|
||||
python3 electron\script\zip-symbols.py
|
||||
appveyor-retry appveyor PushArtifact out/Default/symbols.zip
|
||||
} else {
|
||||
# It's useful to have pdb files when debugging testing builds that are
|
||||
# built on CI.
|
||||
7z a pdb.zip out\Default\*.pdb
|
||||
}
|
||||
- ps: |
|
||||
if ($env:TARGET_ARCH -eq 'ia32') {
|
||||
$env:MANIFEST_ARCH = "x86"
|
||||
} else {
|
||||
$env:MANIFEST_ARCH = $env:TARGET_ARCH
|
||||
}
|
||||
$manifest_file = "electron/script/zip_manifests/dist_zip.win.$env:MANIFEST_ARCH.manifest"
|
||||
python3 electron/script/zip_manifests/check-zip-manifest.py out/Default/dist.zip $manifest_file
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "Zip contains files not listed in the manifest $manifest_file"
|
||||
}
|
||||
- ps: |
|
||||
cd C:\projects\src
|
||||
$missing_artifacts = $false
|
||||
if ($env:SHOULD_SKIP_ARTIFACT_VALIDATION -eq 'true') {
|
||||
Write-warning "Skipping artifact validation for doc-only $env:APPVEYOR_PROJECT_NAME"
|
||||
} else {
|
||||
$artifacts_to_validate = 'dist.zip','windows_toolchain_profile.json','chromedriver.zip','ffmpeg.zip','node_headers.zip','mksnapshot.zip','electron.lib','hunspell_dictionaries.zip'
|
||||
foreach($artifact_name in $artifacts_to_validate) {
|
||||
if ($artifact_name -eq 'ffmpeg.zip') {
|
||||
$artifact_file = "out\ffmpeg\ffmpeg.zip"
|
||||
} elseif (
|
||||
$artifact_name -eq 'node_headers.zip') {
|
||||
$artifact_file = $artifact_name
|
||||
} else {
|
||||
$artifact_file = "out\Default\$artifact_name"
|
||||
}
|
||||
if (-not(Test-Path $artifact_file)) {
|
||||
Write-warning "$artifact_name is missing and cannot be added to artifacts"
|
||||
$missing_artifacts = $true
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($missing_artifacts) {
|
||||
throw "Build failed due to missing artifacts"
|
||||
}
|
||||
|
||||
deploy_script:
|
||||
- cd electron
|
||||
- ps: >-
|
||||
if (Test-Path Env:\ELECTRON_RELEASE) {
|
||||
if (Test-Path Env:\UPLOAD_TO_STORAGE) {
|
||||
Write-Output "Uploading Electron release distribution to azure"
|
||||
& python3 script\release\uploaders\upload.py --verbose --upload_to_storage
|
||||
} else {
|
||||
Write-Output "Uploading Electron release distribution to github releases"
|
||||
& python3 script\release\uploaders\upload.py --verbose
|
||||
}
|
||||
}
|
||||
on_finish:
|
||||
# Uncomment this lines to enable RDP
|
||||
# - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
|
||||
- cd C:\projects\src
|
||||
- if exist out\Default\windows_toolchain_profile.json ( appveyor-retry appveyor PushArtifact out\Default\windows_toolchain_profile.json )
|
||||
- if exist out\Default\dist.zip (appveyor-retry appveyor PushArtifact out\Default\dist.zip)
|
||||
- if exist out\Default\chromedriver.zip (appveyor-retry appveyor PushArtifact out\Default\chromedriver.zip)
|
||||
- if exist out\ffmpeg\ffmpeg.zip (appveyor-retry appveyor PushArtifact out\ffmpeg\ffmpeg.zip)
|
||||
- if exist node_headers.zip (appveyor-retry appveyor PushArtifact node_headers.zip)
|
||||
- if exist out\Default\mksnapshot.zip (appveyor-retry appveyor PushArtifact out\Default\mksnapshot.zip)
|
||||
- if exist out\Default\hunspell_dictionaries.zip (appveyor-retry appveyor PushArtifact out\Default\hunspell_dictionaries.zip)
|
||||
- if exist out\Default\electron.lib (appveyor-retry appveyor PushArtifact out\Default\electron.lib)
|
||||
- ps: >-
|
||||
if ((Test-Path "pdb.zip") -And ($env:GN_CONFIG -ne 'release')) {
|
||||
appveyor-retry appveyor PushArtifact pdb.zip
|
||||
}
|
||||
- matrix:
|
||||
only:
|
||||
- job_name: Test 1
|
||||
- job_name: Test 2
|
||||
|
||||
environment:
|
||||
DD_ENV: ci
|
||||
DD_SERVICE: electron
|
||||
DD_CIVISIBILITY_LOGS_ENABLED: true
|
||||
DD_GIT_REPOSITORY_URL: "https://github.com/electron/electron.git"
|
||||
ELECTRON_TEST_RESULTS_DIR: C:\projects\src\electron\junit
|
||||
|
||||
init:
|
||||
- ps: |
|
||||
if ($env:RUN_TESTS -ne 'true') {
|
||||
Write-warning "Skipping tests for $env:APPVEYOR_PROJECT_NAME"; Exit-AppveyorBuild
|
||||
}
|
||||
build_script:
|
||||
- ps: |
|
||||
node script/yarn.js install --frozen-lockfile
|
||||
node script/doc-only-change.js --prNumber=$env:APPVEYOR_PULL_REQUEST_NUMBER
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
Write-warning "Skipping build for doc only change"
|
||||
Exit-AppveyorBuild
|
||||
} else {
|
||||
$global:LASTEXITCODE = 0
|
||||
}
|
||||
- npm install -g @datadog/datadog-ci
|
||||
- cd ..
|
||||
- mkdir out\Default
|
||||
- cd ..
|
||||
- ps: |
|
||||
# Download build artifacts
|
||||
$apiUrl = 'https://ci.appveyor.com/api'
|
||||
$build_info = Invoke-RestMethod -Method Get -Uri "$apiUrl/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/builds/$env:APPVEYOR_BUILD_ID"
|
||||
$artifacts_to_download = @('dist.zip','chromedriver.zip','ffmpeg.zip','node_headers.zip','mksnapshot.zip','electron.lib')
|
||||
foreach ($job in $build_info.build.jobs) {
|
||||
if ($job.name -eq "Build") {
|
||||
$jobId = $job.jobId
|
||||
foreach($artifact_name in $artifacts_to_download) {
|
||||
if ($artifact_name -eq 'electron.lib') {
|
||||
$outfile = "src\out\Default\$artifact_name"
|
||||
} else {
|
||||
$outfile = $artifact_name
|
||||
}
|
||||
Invoke-RestMethod -Method Get -Uri "$apiUrl/buildjobs/$jobId/artifacts/$artifact_name" -OutFile $outfile
|
||||
}
|
||||
# Uncomment the following lines to download the pdb.zip to show real stacktraces when crashes happen during testing
|
||||
Invoke-RestMethod -Method Get -Uri "$apiUrl/buildjobs/$jobId/artifacts/pdb.zip" -OutFile pdb.zip
|
||||
7z x -y -osrc pdb.zip
|
||||
}
|
||||
}
|
||||
- ps: |
|
||||
$out_default_zips = @('dist.zip','chromedriver.zip','mksnapshot.zip')
|
||||
foreach($zip_name in $out_default_zips) {
|
||||
7z x -y -osrc\out\Default $zip_name
|
||||
}
|
||||
- ps: 7z x -y -osrc\out\ffmpeg ffmpeg.zip
|
||||
- ps: 7z x -y -osrc node_headers.zip
|
||||
|
||||
test_script:
|
||||
# Workaround for https://github.com/appveyor/ci/issues/2420
|
||||
- set "PATH=%PATH%;C:\Program Files\Git\mingw64\libexec\git-core"
|
||||
- ps: |
|
||||
cd src
|
||||
New-Item .\out\Default\gen\node_headers\Release -Type directory
|
||||
Copy-Item -path .\out\Default\electron.lib -destination .\out\Default\gen\node_headers\Release\node.lib
|
||||
- cd electron
|
||||
# Explicitly set npm_config_arch because the .env doesn't persist
|
||||
- ps: >-
|
||||
if ($env:TARGET_ARCH -eq 'ia32') {
|
||||
$env:npm_config_arch = "ia32"
|
||||
}
|
||||
- ps: $env:tests_files=node script\split-tests $env:shard 2
|
||||
- echo "Running shard %shard% specs %tests_files%"
|
||||
- echo Running main test suite & node script/yarn test -- --trace-uncaught --runners=main --enable-logging --files %tests_files%
|
||||
- cd ..
|
||||
- echo Verifying non proprietary ffmpeg & python electron\script\verify-ffmpeg.py --build-dir out\Default --source-root %cd% --ffmpeg-path out\ffmpeg
|
||||
- echo "About to verify mksnapshot"
|
||||
- echo Verifying mksnapshot & python electron\script\verify-mksnapshot.py --build-dir out\Default --source-root %cd%
|
||||
- echo "Done verifying mksnapshot"
|
||||
- echo Verifying chromedriver & python electron\script\verify-chromedriver.py --build-dir out\Default --source-root %cd%
|
||||
- echo "Done verifying chromedriver"
|
||||
|
||||
on_finish:
|
||||
# Uncomment these lines to enable RDP
|
||||
# - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
|
||||
- if exist electron\junit\test-results-main.xml ( appveyor-retry appveyor PushArtifact electron\junit\test-results-main.xml )
|
||||
- ps: |
|
||||
if ($env:RUN_TESTS -eq 'true' -And $env:DD_API_KEY) {
|
||||
$env:DD_GIT_COMMIT_SHA = $env:APPVEYOR_REPO_COMMIT
|
||||
$env:DD_GIT_BRANCH = $env:APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH
|
||||
$env:DD_TAGS = "os.architecture:$env:TARGET_ARCH,os.family:windows,os.platform:win32"
|
||||
if (Test-Path -Path "C:\projects\src\electron\junit\test-results-main.xml") {
|
||||
C:\Users\appveyor\AppData\Roaming\npm\datadog-ci.ps1 junit upload --verbose C:\projects\src\electron\junit\test-results-main.xml
|
||||
}
|
||||
}
|
||||
@@ -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 = 133
|
||||
node_module_version = 135
|
||||
|
||||
v8_promise_internal_field_count = 1
|
||||
v8_embedder_string = "-electron.0"
|
||||
@@ -14,8 +14,8 @@ v8_enable_snapshot_native_code_counters = false
|
||||
v8_enable_javascript_promise_hooks = true
|
||||
|
||||
enable_cdm_host_verification = false
|
||||
proprietary_codecs = true
|
||||
ffmpeg_branding = "Chrome"
|
||||
proprietary_codecs = true
|
||||
|
||||
enable_printing = true
|
||||
|
||||
@@ -48,7 +48,8 @@ enable_cet_shadow_stack = false
|
||||
is_cfi = false
|
||||
|
||||
# TODO: fix this once sysroots have been updated.
|
||||
use_qt = false
|
||||
use_qt5 = false
|
||||
use_qt6 = false
|
||||
|
||||
# Disables the builtins PGO for V8
|
||||
v8_builtins_profiling_log_file = ""
|
||||
@@ -65,11 +66,6 @@ v8_enable_private_mapping_fork_optimization = true
|
||||
# Expose public V8 symbols for native modules.
|
||||
v8_expose_public_symbols = true
|
||||
|
||||
# Disables unsafe-buffers-usage plugin due to incompatibilities with our reclient implementation
|
||||
# Ref: https://chromium-review.googlesource.com/c/chromium/src/+/5426599
|
||||
# Ref: https://github.com/electron/electron/commit/8e20f16ea35eeaeb149ae63bad3703d782665f6a
|
||||
clang_unsafe_buffers_paths = ""
|
||||
|
||||
# Disable snapshotting a page when printing for its content to be analyzed for
|
||||
# sensitive content by enterprise users.
|
||||
enterprise_cloud_content_analysis = false
|
||||
@@ -77,6 +73,3 @@ enterprise_cloud_content_analysis = false
|
||||
# TODO: remove dependency on legacy ipc
|
||||
# https://issues.chromium.org/issues/40943039
|
||||
content_enable_legacy_ipc = true
|
||||
|
||||
# Electron has its own unsafe-buffers enforcement directories.
|
||||
clang_unsafe_buffers_paths = "//electron/electron_unsafe_buffers_paths.txt"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import("all.gn")
|
||||
import("//electron/build/args/all.gn")
|
||||
is_component_build = false
|
||||
is_component_ffmpeg = true
|
||||
is_official_build = true
|
||||
proprietary_codecs = false
|
||||
ffmpeg_branding = "Chromium"
|
||||
enable_dsyms = false
|
||||
proprietary_codecs = false
|
||||
|
||||
@@ -1,14 +1,7 @@
|
||||
import("all.gn")
|
||||
import("//electron/build/args/all.gn")
|
||||
is_component_build = false
|
||||
is_official_build = true
|
||||
|
||||
# This may be guarded behind is_chrome_branded alongside
|
||||
# proprietary_codecs https://webrtc-review.googlesource.com/c/src/+/36321,
|
||||
# explicitly override here to build OpenH264 encoder/FFmpeg decoder.
|
||||
# The initialization of the decoder depends on whether ffmpeg has
|
||||
# been built with H.264 support.
|
||||
rtc_use_h264 = proprietary_codecs
|
||||
|
||||
# By default, Electron builds ffmpeg with proprietary codecs enabled. In order
|
||||
# to facilitate users who don't want to ship proprietary codecs in ffmpeg, or
|
||||
# who have an LGPL requirement to ship ffmpeg as a dynamically linked library,
|
||||
|
||||
@@ -1,14 +1,7 @@
|
||||
import("all.gn")
|
||||
import("//electron/build/args/all.gn")
|
||||
is_debug = false
|
||||
is_component_build = false
|
||||
is_component_ffmpeg = true
|
||||
is_official_build = false
|
||||
dcheck_always_on = true
|
||||
symbol_level = 1
|
||||
|
||||
# This may be guarded behind is_chrome_branded alongside
|
||||
# proprietary_codecs https://webrtc-review.googlesource.com/c/src/+/36321,
|
||||
# explicitly override here to build OpenH264 encoder/FFmpeg decoder.
|
||||
# The initialization of the decoder depends on whether ffmpeg has
|
||||
# been built with H.264 support.
|
||||
rtc_use_h264 = proprietary_codecs
|
||||
|
||||
@@ -45,7 +45,7 @@ def windows_profile():
|
||||
win_sdk_dir = SetEnvironmentAndGetSDKDir()
|
||||
path = NormalizePath(os.environ['GYP_MSVS_OVERRIDE_PATH'])
|
||||
|
||||
# since current windows executable are symbols path dependant,
|
||||
# since current windows executable are symbols path dependent,
|
||||
# profile the current directory too
|
||||
return {
|
||||
'pwd': os.getcwd(),
|
||||
|
||||
6
build/webpack/webpack.config.preload_realm.js
Normal file
6
build/webpack/webpack.config.preload_realm.js
Normal file
@@ -0,0 +1,6 @@
|
||||
module.exports = require('./webpack.config.base')({
|
||||
target: 'preload_realm',
|
||||
alwaysHasNode: false,
|
||||
wrapInitWithProfilingTimeout: true,
|
||||
wrapInitWithTryCatch: true
|
||||
});
|
||||
@@ -34,8 +34,6 @@ static_library("chrome") {
|
||||
"//chrome/browser/devtools/features.h",
|
||||
"//chrome/browser/devtools/visual_logging.cc",
|
||||
"//chrome/browser/devtools/visual_logging.h",
|
||||
"//chrome/browser/extensions/global_shortcut_listener.cc",
|
||||
"//chrome/browser/extensions/global_shortcut_listener.h",
|
||||
"//chrome/browser/file_system_access/file_system_access_features.cc",
|
||||
"//chrome/browser/file_system_access/file_system_access_features.h",
|
||||
"//chrome/browser/icon_loader.cc",
|
||||
@@ -70,6 +68,8 @@ static_library("chrome") {
|
||||
"//chrome/browser/picture_in_picture/picture_in_picture_occlusion_tracker_observer.h",
|
||||
"//chrome/browser/picture_in_picture/picture_in_picture_window_manager.cc",
|
||||
"//chrome/browser/picture_in_picture/picture_in_picture_window_manager.h",
|
||||
"//chrome/browser/picture_in_picture/picture_in_picture_window_manager_uma_helper.cc",
|
||||
"//chrome/browser/picture_in_picture/picture_in_picture_window_manager_uma_helper.h",
|
||||
"//chrome/browser/picture_in_picture/scoped_picture_in_picture_occlusion_observation.cc",
|
||||
"//chrome/browser/picture_in_picture/scoped_picture_in_picture_occlusion_observation.h",
|
||||
"//chrome/browser/platform_util.cc",
|
||||
@@ -146,6 +146,8 @@ static_library("chrome") {
|
||||
"//chrome/browser/ui/webui/accessibility/accessibility_ui.h",
|
||||
"//extensions/browser/app_window/size_constraints.cc",
|
||||
"//extensions/browser/app_window/size_constraints.h",
|
||||
"//ui/base/accelerators/global_accelerator_listener/global_accelerator_listener.cc",
|
||||
"//ui/base/accelerators/global_accelerator_listener/global_accelerator_listener.h",
|
||||
"//ui/views/native_window_tracker.h",
|
||||
]
|
||||
|
||||
@@ -176,7 +178,6 @@ static_library("chrome") {
|
||||
}
|
||||
|
||||
public_deps = [
|
||||
"//chrome/browser:dev_ui_browser_resources",
|
||||
"//chrome/browser/resources/accessibility:resources",
|
||||
"//chrome/browser/ui/color:color_headers",
|
||||
"//chrome/browser/ui/color:mixers",
|
||||
@@ -198,6 +199,7 @@ static_library("chrome") {
|
||||
"//chrome/browser/ui/webui/tab_search:mojo_bindings",
|
||||
"//chrome/browser/web_applications/mojom:mojom_web_apps_enum",
|
||||
"//components/enterprise/buildflags",
|
||||
"//components/enterprise/common/proto:browser_events_proto",
|
||||
"//components/enterprise/common/proto:connectors_proto",
|
||||
"//components/enterprise/obfuscation/core:enterprise_obfuscation",
|
||||
"//components/safe_browsing/core/browser/db:safebrowsing_proto",
|
||||
@@ -219,9 +221,9 @@ static_library("chrome") {
|
||||
|
||||
if (is_linux) {
|
||||
sources += [
|
||||
"//chrome/browser/extensions/global_shortcut_listener_linux.cc",
|
||||
"//chrome/browser/extensions/global_shortcut_listener_linux.h",
|
||||
"//chrome/browser/icon_loader_auralinux.cc",
|
||||
"//ui/base/accelerators/global_accelerator_listener/global_accelerator_listener_linux.cc",
|
||||
"//ui/base/accelerators/global_accelerator_listener/global_accelerator_listener_linux.h",
|
||||
]
|
||||
sources += [
|
||||
"//chrome/browser/ui/views/status_icons/concat_menu_model.cc",
|
||||
|
||||
@@ -34,18 +34,25 @@ async function loadSVG (element: HTMLSpanElement) {
|
||||
|
||||
async function initialize () {
|
||||
const electronPath = await ipcRenderer.invoke('bootstrap');
|
||||
|
||||
function replaceText (selector: string, text: string) {
|
||||
function replaceText (selector: string, text: string, link?: string) {
|
||||
const element = document.querySelector<HTMLElement>(selector);
|
||||
if (element) {
|
||||
element.innerText = text;
|
||||
if (link) {
|
||||
const anchor = document.createElement('a');
|
||||
anchor.textContent = text;
|
||||
anchor.href = link;
|
||||
anchor.target = '_blank';
|
||||
element.appendChild(anchor);
|
||||
} else {
|
||||
element.innerText = text;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
replaceText('.electron-version', `Electron v${process.versions.electron}`);
|
||||
replaceText('.chrome-version', `Chromium v${process.versions.chrome}`);
|
||||
replaceText('.node-version', `Node v${process.versions.node}`);
|
||||
replaceText('.v8-version', `v8 v${process.versions.v8}`);
|
||||
replaceText('.electron-version', `Electron v${process.versions.electron}`, 'https://electronjs.org/docs');
|
||||
replaceText('.chrome-version', `Chromium v${process.versions.chrome}`, 'https://developer.chrome.com/docs/chromium');
|
||||
replaceText('.node-version', `Node v${process.versions.node}`, `https://nodejs.org/docs/v${process.versions.node}/api`);
|
||||
replaceText('.v8-version', `v8 v${process.versions.v8}`, 'https://v8.dev/docs');
|
||||
replaceText('.command-example', `${electronPath} path-to-app`);
|
||||
|
||||
for (const element of document.querySelectorAll<HTMLSpanElement>('.octicon')) {
|
||||
|
||||
@@ -127,6 +127,7 @@ These individual tutorials expand on topics discussed in the guide above.
|
||||
* [pushNotifications](api/push-notifications.md)
|
||||
* [safeStorage](api/safe-storage.md)
|
||||
* [screen](api/screen.md)
|
||||
* [ServiceWorkerMain](api/service-worker-main.md)
|
||||
* [session](api/session.md)
|
||||
* [ShareMenu](api/share-menu.md)
|
||||
* [systemPreferences](api/system-preferences.md)
|
||||
|
||||
@@ -1559,8 +1559,8 @@ command line arguments that Chromium uses.
|
||||
|
||||
### `app.dock` _macOS_ _Readonly_
|
||||
|
||||
A [`Dock`](./dock.md) `| undefined` object that allows you to perform actions on your app icon in the user's
|
||||
dock on macOS.
|
||||
A `Dock | undefined` property ([`Dock`](./dock.md) on macOS, `undefined` on all other
|
||||
platforms) that allows you to perform actions on your app icon in the user's dock.
|
||||
|
||||
### `app.isPackaged` _Readonly_
|
||||
|
||||
|
||||
@@ -313,6 +313,12 @@ Set the default value of the `verbatim` parameter in the Node.js [`dns.lookup()`
|
||||
|
||||
The default is `verbatim` and `dns.setDefaultResultOrder()` have higher priority than `--dns-result-order`.
|
||||
|
||||
### `--diagnostic-dir=directory`
|
||||
|
||||
Set the directory to which all Node.js diagnostic output files are written. Defaults to current working directory.
|
||||
|
||||
Affects the default output directory of [v8.setHeapSnapshotNearHeapLimit](https://nodejs.org/docs/latest/api/v8.html#v8setheapsnapshotnearheaplimitlimit).
|
||||
|
||||
[app]: app.md
|
||||
[append-switch]: command-line.md#commandlineappendswitchswitch-value
|
||||
[debugging-main-process]: ../tutorial/debugging-main-process.md
|
||||
|
||||
@@ -61,6 +61,20 @@ The `contextBridge` module has the following methods:
|
||||
* `apiKey` string - The key to inject the API onto `window` with. The API will be accessible on `window[apiKey]`.
|
||||
* `api` any - Your API, more information on what this API can be and how it works is available below.
|
||||
|
||||
### `contextBridge.executeInMainWorld(executionScript)` _Experimental_
|
||||
|
||||
<!-- TODO(samuelmaddock): add generics to map the `args` types to the `func` params -->
|
||||
|
||||
* `executionScript` Object
|
||||
* `func` (...args: any[]) => any - A JavaScript function to execute. This function will be serialized which means
|
||||
that any bound parameters and execution context will be lost.
|
||||
* `args` any[] (optional) - An array of arguments to pass to the provided function. These
|
||||
arguments will be copied between worlds in accordance with
|
||||
[the table of supported types.](#parameter--error--return-type-support)
|
||||
|
||||
Returns `any` - A copy of the resulting value from executing the function in the main world.
|
||||
[Refer to the table](#parameter--error--return-type-support) on how values are copied between worlds.
|
||||
|
||||
## Usage
|
||||
|
||||
### API
|
||||
|
||||
@@ -17,7 +17,8 @@ app.whenReady().then(() => {
|
||||
|
||||
session.defaultSession.setDisplayMediaRequestHandler((request, callback) => {
|
||||
desktopCapturer.getSources({ types: ['screen'] }).then((sources) => {
|
||||
// Grant access to the first screen found.
|
||||
// Your app shows some UI, but in this example
|
||||
// grant access to the first screen found.
|
||||
callback({ video: sources[0], audio: 'loopback' })
|
||||
})
|
||||
// If true, use the system picker if available.
|
||||
@@ -42,7 +43,8 @@ startButton.addEventListener('click', () => {
|
||||
video: {
|
||||
width: 320,
|
||||
height: 240,
|
||||
frameRate: 30
|
||||
frameRate: 30,
|
||||
displaySurface: 'monitor'
|
||||
}
|
||||
}).then(stream => {
|
||||
video.srcObject = stream
|
||||
@@ -98,6 +100,16 @@ which can detected by [`systemPreferences.getMediaAccessStatus`][].
|
||||
[`navigator.mediaDevices.getUserMedia`]: https://developer.mozilla.org/en/docs/Web/API/MediaDevices/getUserMedia
|
||||
[`systemPreferences.getMediaAccessStatus`]: system-preferences.md#systempreferencesgetmediaaccessstatusmediatype-windows-macos
|
||||
|
||||
### `desktopCapturer.isDisplayMediaSystemPickerAvailable()` _Experimental_ _macOS_
|
||||
|
||||
Returns `Boolean`, whether or not requesting desktop content via
|
||||
the system picker is supported on this platform.
|
||||
|
||||
Currently this will only return `true` on macOS 14.4 and higher. When
|
||||
true, use the `getNativePickerSource` method to return the system picker's
|
||||
selected media stream. Not doing so may cause a warning dialog to your users
|
||||
on macOS 15 and higher.
|
||||
|
||||
## Caveats
|
||||
|
||||
`navigator.mediaDevices.getUserMedia` does not work on macOS for audio capture due to a fundamental limitation whereby apps that want to access the system's audio require a [signed kernel extension](https://developer.apple.com/library/archive/documentation/Security/Conceptual/System_Integrity_Protection_Guide/KernelExtensions/KernelExtensions.html). Chromium, and by extension Electron, does not provide this.
|
||||
|
||||
@@ -228,7 +228,7 @@ The `filters` specifies an array of file types that can be displayed, see
|
||||
**Note:** On macOS, using the asynchronous version is recommended to avoid issues when
|
||||
expanding and collapsing the dialog.
|
||||
|
||||
### `dialog.showMessageBoxSync([wndow, ]options)`
|
||||
### `dialog.showMessageBoxSync([window, ]options)`
|
||||
|
||||
* `window` [BaseWindow](base-window.md) (optional)
|
||||
* `options` Object
|
||||
|
||||
124
docs/api/extensions-api.md
Normal file
124
docs/api/extensions-api.md
Normal file
@@ -0,0 +1,124 @@
|
||||
## Class: Extensions
|
||||
|
||||
> Load and interact with extensions.
|
||||
|
||||
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._
|
||||
|
||||
Instances of the `Extensions` class are accessed by using `extensions` property of
|
||||
a `Session`.
|
||||
|
||||
### Instance Events
|
||||
|
||||
The following events are available on instances of `Extensions`:
|
||||
|
||||
#### Event: 'extension-loaded'
|
||||
|
||||
Returns:
|
||||
|
||||
* `event` Event
|
||||
* `extension` [Extension](structures/extension.md)
|
||||
|
||||
Emitted after an extension is loaded. This occurs whenever an extension is
|
||||
added to the "enabled" set of extensions. This includes:
|
||||
|
||||
* Extensions being loaded from `Extensions.loadExtension`.
|
||||
* Extensions being reloaded:
|
||||
* from a crash.
|
||||
* if the extension requested it ([`chrome.runtime.reload()`](https://developer.chrome.com/extensions/runtime#method-reload)).
|
||||
|
||||
#### Event: 'extension-unloaded'
|
||||
|
||||
Returns:
|
||||
|
||||
* `event` Event
|
||||
* `extension` [Extension](structures/extension.md)
|
||||
|
||||
Emitted after an extension is unloaded. This occurs when
|
||||
`Session.removeExtension` is called.
|
||||
|
||||
#### Event: 'extension-ready'
|
||||
|
||||
Returns:
|
||||
|
||||
* `event` Event
|
||||
* `extension` [Extension](structures/extension.md)
|
||||
|
||||
Emitted after an extension is loaded and all necessary browser state is
|
||||
initialized to support the start of the extension's background page.
|
||||
|
||||
### Instance Methods
|
||||
|
||||
The following methods are available on instances of `Extensions`:
|
||||
|
||||
#### `extensions.loadExtension(path[, options])`
|
||||
|
||||
* `path` string - Path to a directory containing an unpacked Chrome extension
|
||||
* `options` Object (optional)
|
||||
* `allowFileAccess` boolean - Whether to allow the extension to read local files over `file://`
|
||||
protocol and inject content scripts into `file://` pages. This is required e.g. for loading
|
||||
devtools extensions on `file://` URLs. Defaults to false.
|
||||
|
||||
Returns `Promise<Extension>` - resolves when the extension is loaded.
|
||||
|
||||
This method will raise an exception if the extension could not be loaded. If
|
||||
there are warnings when installing the extension (e.g. if the extension
|
||||
requests an API that Electron does not support) then they will be logged to the
|
||||
console.
|
||||
|
||||
Note that Electron does not support the full range of Chrome extensions APIs.
|
||||
See [Supported Extensions APIs](extensions.md#supported-extensions-apis) for
|
||||
more details on what is supported.
|
||||
|
||||
Note that in previous versions of Electron, extensions that were loaded would
|
||||
be remembered for future runs of the application. This is no longer the case:
|
||||
`loadExtension` must be called on every boot of your app if you want the
|
||||
extension to be loaded.
|
||||
|
||||
```js
|
||||
const { app, session } = require('electron')
|
||||
const path = require('node:path')
|
||||
|
||||
app.whenReady().then(async () => {
|
||||
await session.defaultSession.extensions.loadExtension(
|
||||
path.join(__dirname, 'react-devtools'),
|
||||
// allowFileAccess is required to load the devtools extension on file:// URLs.
|
||||
{ allowFileAccess: true }
|
||||
)
|
||||
// Note that in order to use the React DevTools extension, you'll need to
|
||||
// download and unzip a copy of the extension.
|
||||
})
|
||||
```
|
||||
|
||||
This API does not support loading packed (.crx) extensions.
|
||||
|
||||
**Note:** This API cannot be called before the `ready` event of the `app` module
|
||||
is emitted.
|
||||
|
||||
**Note:** Loading extensions into in-memory (non-persistent) sessions is not
|
||||
supported and will throw an error.
|
||||
|
||||
#### `extensions.removeExtension(extensionId)`
|
||||
|
||||
* `extensionId` string - ID of extension to remove
|
||||
|
||||
Unloads an extension.
|
||||
|
||||
**Note:** This API cannot be called before the `ready` event of the `app` module
|
||||
is emitted.
|
||||
|
||||
#### `extensions.getExtension(extensionId)`
|
||||
|
||||
* `extensionId` string - ID of extension to query
|
||||
|
||||
Returns `Extension | null` - The loaded extension with the given ID.
|
||||
|
||||
**Note:** This API cannot be called before the `ready` event of the `app` module
|
||||
is emitted.
|
||||
|
||||
#### `extensions.getAllExtensions()`
|
||||
|
||||
Returns `Extension[]` - A list of all loaded extensions.
|
||||
|
||||
**Note:** This API cannot be called before the `ready` event of the `app` module
|
||||
is emitted.
|
||||
@@ -14,7 +14,7 @@ but it also happens to support some other extension capabilities.
|
||||
|
||||
Electron only supports loading unpacked extensions (i.e., `.crx` files do not
|
||||
work). Extensions are installed per-`session`. To load an extension, call
|
||||
[`ses.loadExtension`](session.md#sesloadextensionpath-options):
|
||||
[`ses.extensions.loadExtension`](extensions-api.md#extensionsloadextensionpath-options):
|
||||
|
||||
```js
|
||||
const { session } = require('electron')
|
||||
|
||||
@@ -12,9 +12,17 @@ shortcuts.
|
||||
not have the keyboard focus. This module cannot be used before the `ready`
|
||||
event of the app module is emitted.
|
||||
|
||||
Please also note that it is also possible to use Chromium's
|
||||
`GlobalShortcutsPortal` implementation, which allows apps to bind global
|
||||
shortcuts when running within a Wayland session.
|
||||
|
||||
```js
|
||||
const { app, globalShortcut } = require('electron')
|
||||
|
||||
// Enable usage of Portal's globalShortcuts. This is essential for cases when
|
||||
// the app runs in a Wayland session.
|
||||
app.commandLine.appendSwitch('enable-features', 'GlobalShortcutsPortal')
|
||||
|
||||
app.whenReady().then(() => {
|
||||
// Register a 'CommandOrControl+X' shortcut listener.
|
||||
const ret = globalShortcut.register('CommandOrControl+X', () => {
|
||||
|
||||
@@ -10,13 +10,13 @@ The `inAppPurchase` module emits the following events:
|
||||
|
||||
### Event: 'transactions-updated'
|
||||
|
||||
Emitted when one or more transactions have been updated.
|
||||
|
||||
Returns:
|
||||
|
||||
* `event` Event
|
||||
* `transactions` Transaction[] - Array of [`Transaction`](structures/transaction.md) objects.
|
||||
|
||||
Emitted when one or more transactions have been updated.
|
||||
|
||||
## Methods
|
||||
|
||||
The `inAppPurchase` module has the following methods:
|
||||
|
||||
75
docs/api/ipc-main-service-worker.md
Normal file
75
docs/api/ipc-main-service-worker.md
Normal file
@@ -0,0 +1,75 @@
|
||||
## Class: IpcMainServiceWorker
|
||||
|
||||
> Communicate asynchronously from the main process to service workers.
|
||||
|
||||
Process: [Main](../glossary.md#main-process)
|
||||
|
||||
> [!NOTE]
|
||||
> This API is a subtle variation of [`IpcMain`](ipc-main.md)—targeted for
|
||||
> communicating with service workers. For communicating with web frames,
|
||||
> consult the `IpcMain` documentation.
|
||||
|
||||
<!-- TODO(samuelmaddock): refactor doc gen to allow generics to reduce duplication -->
|
||||
|
||||
### Instance Methods
|
||||
|
||||
#### `ipcMainServiceWorker.on(channel, listener)`
|
||||
|
||||
* `channel` string
|
||||
* `listener` Function
|
||||
* `event` [IpcMainServiceWorkerEvent][ipc-main-service-worker-event]
|
||||
* `...args` any[]
|
||||
|
||||
Listens to `channel`, when a new message arrives `listener` would be called with
|
||||
`listener(event, args...)`.
|
||||
|
||||
#### `ipcMainServiceWorker.once(channel, listener)`
|
||||
|
||||
* `channel` string
|
||||
* `listener` Function
|
||||
* `event` [IpcMainServiceWorkerEvent][ipc-main-service-worker-event]
|
||||
* `...args` any[]
|
||||
|
||||
Adds a one time `listener` function for the event. This `listener` is invoked
|
||||
only the next time a message is sent to `channel`, after which it is removed.
|
||||
|
||||
#### `ipcMainServiceWorker.removeListener(channel, listener)`
|
||||
|
||||
* `channel` string
|
||||
* `listener` Function
|
||||
* `...args` any[]
|
||||
|
||||
Removes the specified `listener` from the listener array for the specified
|
||||
`channel`.
|
||||
|
||||
#### `ipcMainServiceWorker.removeAllListeners([channel])`
|
||||
|
||||
* `channel` string (optional)
|
||||
|
||||
Removes listeners of the specified `channel`.
|
||||
|
||||
#### `ipcMainServiceWorker.handle(channel, listener)`
|
||||
|
||||
* `channel` string
|
||||
* `listener` Function\<Promise\<any\> | any\>
|
||||
* `event` [IpcMainServiceWorkerInvokeEvent][ipc-main-service-worker-invoke-event]
|
||||
* `...args` any[]
|
||||
|
||||
#### `ipcMainServiceWorker.handleOnce(channel, listener)`
|
||||
|
||||
* `channel` string
|
||||
* `listener` Function\<Promise\<any\> | any\>
|
||||
* `event` [IpcMainServiceWorkerInvokeEvent][ipc-main-service-worker-invoke-event]
|
||||
* `...args` any[]
|
||||
|
||||
Handles a single `invoke`able IPC message, then removes the listener. See
|
||||
`ipcMainServiceWorker.handle(channel, listener)`.
|
||||
|
||||
#### `ipcMainServiceWorker.removeHandler(channel)`
|
||||
|
||||
* `channel` string
|
||||
|
||||
Removes any handler for `channel`, if present.
|
||||
|
||||
[ipc-main-service-worker-event]:../api/structures/ipc-main-service-worker-event.md
|
||||
[ipc-main-service-worker-invoke-event]:../api/structures/ipc-main-service-worker-invoke-event.md
|
||||
@@ -41,6 +41,16 @@ The `ipcRenderer` module has the following method to listen for events and send
|
||||
Listens to `channel`, when a new message arrives `listener` would be called with
|
||||
`listener(event, args...)`.
|
||||
|
||||
:::warning
|
||||
Do not expose the `event` argument to the renderer for security reasons! Wrap any
|
||||
callback that you receive from the renderer in another function like this:
|
||||
`ipcRenderer.on('my-channel', (event, ...args) => callback(...args))`.
|
||||
Not wrapping the callback in such a function would expose dangerous Electron APIs
|
||||
to the renderer process. See the
|
||||
[security guide](../tutorial/security.md#20-do-not-expose-electron-apis-to-untrusted-web-content)
|
||||
for more info.
|
||||
:::
|
||||
|
||||
### `ipcRenderer.off(channel, listener)`
|
||||
|
||||
* `channel` string
|
||||
|
||||
@@ -5,7 +5,16 @@
|
||||
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._
|
||||
|
||||
Each navigation entry corresponds to a specific page. The indexing system follows a sequential order, where the first available navigation entry is at index 0, representing the earliest visited page, and the latest navigation entry is at index N, representing the most recent page. Maintaining this ordered list of navigation entries enables seamless navigation both backward and forward through the user's browsing history.
|
||||
Each [NavigationEntry](./structures/navigation-entry.md) corresponds to a specific visited page.
|
||||
The indexing system follows a sequential order, where the entry for the earliest visited
|
||||
page is at index 0 and the entry for the most recent visited page is at index N.
|
||||
|
||||
Some APIs in this class also accept an _offset_, which is an integer representing the relative
|
||||
position of an index from the current entry according to the above indexing system (i.e. an offset
|
||||
value of `1` would represent going forward in history by one page).
|
||||
|
||||
Maintaining this ordered list of navigation entries enables seamless navigation both backward and
|
||||
forward through the user's browsing history.
|
||||
|
||||
### Instance Methods
|
||||
|
||||
@@ -21,7 +30,7 @@ Returns `boolean` - Whether the browser can go forward to next web page.
|
||||
|
||||
* `offset` Integer
|
||||
|
||||
Returns `boolean` - Whether the web page can go to the specified `offset` from the current entry.
|
||||
Returns `boolean` - Whether the web page can go to the specified relative `offset` from the current entry.
|
||||
|
||||
#### `navigationHistory.clear()`
|
||||
|
||||
@@ -57,7 +66,7 @@ Navigates browser to the specified absolute web page index.
|
||||
|
||||
* `offset` Integer
|
||||
|
||||
Navigates to the specified offset from the current entry.
|
||||
Navigates to the specified relative offset from the current entry.
|
||||
|
||||
#### `navigationHistory.length()`
|
||||
|
||||
@@ -74,3 +83,22 @@ Returns `boolean` - Whether the navigation entry was removed from the webContent
|
||||
#### `navigationHistory.getAllEntries()`
|
||||
|
||||
Returns [`NavigationEntry[]`](structures/navigation-entry.md) - WebContents complete history.
|
||||
|
||||
#### `navigationHistory.restore(options)`
|
||||
|
||||
Restores navigation history and loads the given entry in the in stack. Will make a best effort
|
||||
to restore not just the navigation stack but also the state of the individual pages - for instance
|
||||
including HTML form values or the scroll position. It's recommended to call this API before any
|
||||
navigation entries are created, so ideally before you call `loadURL()` or `loadFile()` on the
|
||||
`webContents` object.
|
||||
|
||||
This API allows you to create common flows that aim to restore, recreate, or clone other webContents.
|
||||
|
||||
* `options` Object
|
||||
* `entries` [NavigationEntry[]](structures/navigation-entry.md) - Result of a prior `getAllEntries()` call
|
||||
* `index` Integer (optional) - Index of the stack that should be loaded. If you set it to `0`, the webContents will load the first (oldest) entry. If you leave it undefined, Electron will automatically load the last (newest) entry.
|
||||
|
||||
Returns `Promise<void>` - the promise will resolve when the page has finished loading the selected navigation entry
|
||||
(see [`did-finish-load`](web-contents.md#event-did-finish-load)), and rejects
|
||||
if the page fails to load (see
|
||||
[`did-fail-load`](web-contents.md#event-did-fail-load)). A noop rejection handler is already attached, which avoids unhandled rejection errors.
|
||||
|
||||
@@ -26,7 +26,10 @@ Emitted when system changes to battery power.
|
||||
|
||||
### Event: 'thermal-state-change' _macOS_
|
||||
|
||||
* `state` string - The system's new thermal state. Can be `unknown`, `nominal`, `fair`, `serious`, `critical`.
|
||||
Returns:
|
||||
|
||||
* `details` Event\<\>
|
||||
* `state` string - The system's new thermal state. Can be `unknown`, `nominal`, `fair`, `serious`, `critical`.
|
||||
|
||||
Emitted when the thermal state of the system changes. Notification of a change
|
||||
in the thermal status of the system, such as entering a critical temperature
|
||||
@@ -44,7 +47,8 @@ See https://developer.apple.com/library/archive/documentation/Performance/Concep
|
||||
|
||||
Returns:
|
||||
|
||||
* `limit` number - The operating system's advertised speed limit for CPUs, in percent.
|
||||
* `details` Event\<\>
|
||||
* `limit` number - The operating system's advertised speed limit for CPUs, in percent.
|
||||
|
||||
Notification of a change in the operating system's advertised speed limit for
|
||||
CPUs, in percent. Values below 100 indicate that the system is impairing
|
||||
|
||||
@@ -114,6 +114,7 @@ A `string` representing the current process's type, can be:
|
||||
|
||||
* `browser` - The main process
|
||||
* `renderer` - A renderer process
|
||||
* `service-worker` - In a service worker
|
||||
* `worker` - In a web worker
|
||||
* `utility` - In a node process launched as a service
|
||||
|
||||
|
||||
58
docs/api/service-worker-main.md
Normal file
58
docs/api/service-worker-main.md
Normal file
@@ -0,0 +1,58 @@
|
||||
# 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._
|
||||
|
||||
### Instance Methods
|
||||
|
||||
#### `serviceWorker.isDestroyed()` _Experimental_
|
||||
|
||||
Returns `boolean` - Whether the service worker has been destroyed.
|
||||
|
||||
#### `serviceWorker.send(channel, ...args)` _Experimental_
|
||||
|
||||
- `channel` string
|
||||
- `...args` any[]
|
||||
|
||||
Send an asynchronous message to the service worker process via `channel`, along with
|
||||
arguments. Arguments will be serialized with the [Structured Clone Algorithm][SCA],
|
||||
just like [`postMessage`][], so prototype chains will not be included.
|
||||
Sending Functions, Promises, Symbols, WeakMaps, or WeakSets will throw an exception.
|
||||
|
||||
The service worker process can handle the message by listening to `channel` with the
|
||||
[`ipcRenderer`](ipc-renderer.md) module.
|
||||
|
||||
#### `serviceWorker.startTask()` _Experimental_
|
||||
|
||||
Returns `Object`:
|
||||
|
||||
- `end` Function - Method to call when the task has ended. If never called, the service won't terminate while otherwise idle.
|
||||
|
||||
Initiate a task to keep the service worker alive until ended.
|
||||
|
||||
### Instance Properties
|
||||
|
||||
#### `serviceWorker.ipc` _Readonly_ _Experimental_
|
||||
|
||||
An [`IpcMainServiceWorker`](ipc-main-service-worker.md) instance scoped to the service worker.
|
||||
|
||||
#### `serviceWorker.scope` _Readonly_ _Experimental_
|
||||
|
||||
A `string` representing the scope URL of the service worker.
|
||||
|
||||
#### `serviceWorker.scriptURL` _Readonly_ _Experimental_
|
||||
|
||||
A `string` representing the script URL of the service worker.
|
||||
|
||||
#### `serviceWorker.versionId` _Readonly_ _Experimental_
|
||||
|
||||
A `number` representing the ID of the specific version of the service worker script in its scope.
|
||||
|
||||
[SCA]: https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm
|
||||
[`postMessage`]: https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage
|
||||
@@ -56,6 +56,17 @@ Returns:
|
||||
|
||||
Emitted when a service worker has been registered. Can occur after a call to [`navigator.serviceWorker.register('/sw.js')`](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/register) successfully resolves or when a Chrome extension is loaded.
|
||||
|
||||
#### Event: 'running-status-changed' _Experimental_
|
||||
|
||||
Returns:
|
||||
|
||||
* `details` Event\<\>
|
||||
* `versionId` number - ID of the updated service worker version
|
||||
* `runningStatus` string - Running status.
|
||||
Possible values include `starting`, `running`, `stopping`, or `stopped`.
|
||||
|
||||
Emitted when a service worker's running status has changed.
|
||||
|
||||
### Instance Methods
|
||||
|
||||
The following methods are available on instances of `ServiceWorkers`:
|
||||
@@ -64,10 +75,55 @@ The following methods are available on instances of `ServiceWorkers`:
|
||||
|
||||
Returns `Record<number, ServiceWorkerInfo>` - A [ServiceWorkerInfo](structures/service-worker-info.md) object where the keys are the service worker version ID and the values are the information about that service worker.
|
||||
|
||||
#### `serviceWorkers.getFromVersionID(versionId)`
|
||||
#### `serviceWorkers.getInfoFromVersionID(versionId)`
|
||||
|
||||
* `versionId` number
|
||||
* `versionId` number - ID of the service worker version
|
||||
|
||||
Returns [`ServiceWorkerInfo`](structures/service-worker-info.md) - Information about this service worker
|
||||
|
||||
If the service worker does not exist or is not running this method will throw an exception.
|
||||
|
||||
#### `serviceWorkers.getFromVersionID(versionId)` _Deprecated_
|
||||
|
||||
* `versionId` number - ID of the service worker version
|
||||
|
||||
Returns [`ServiceWorkerInfo`](structures/service-worker-info.md) - Information about this service worker
|
||||
|
||||
If the service worker does not exist or is not running this method will throw an exception.
|
||||
|
||||
**Deprecated:** Use the new `serviceWorkers.getInfoFromVersionID` API.
|
||||
|
||||
#### `serviceWorkers.getWorkerFromVersionID(versionId)` _Experimental_
|
||||
|
||||
* `versionId` number - ID of the service worker version
|
||||
|
||||
Returns [`ServiceWorkerMain | undefined`](service-worker-main.md) - Instance of the service worker associated with the given version ID. If there's no associated version, or its running status has changed to 'stopped', this will return `undefined`.
|
||||
|
||||
#### `serviceWorkers.startWorkerForScope(scope)` _Experimental_
|
||||
|
||||
* `scope` string - The scope of the service worker to start.
|
||||
|
||||
Returns `Promise<ServiceWorkerMain>` - Resolves with the service worker when it's started.
|
||||
|
||||
Starts the service worker or does nothing if already running.
|
||||
|
||||
```js
|
||||
const { app, session } = require('electron')
|
||||
const { serviceWorkers } = session.defaultSession
|
||||
|
||||
// Collect service workers scopes
|
||||
const workerScopes = Object.values(serviceWorkers.getAllRunning()).map((info) => info.scope)
|
||||
|
||||
app.on('browser-window-created', async (event, window) => {
|
||||
for (const scope of workerScopes) {
|
||||
try {
|
||||
// Ensure worker is started
|
||||
const serviceWorker = await serviceWorkers.startWorkerForScope(scope)
|
||||
serviceWorker.send('window-created', { windowId: window.id })
|
||||
} catch (error) {
|
||||
console.error(`Failed to start service worker for ${scope}`)
|
||||
console.error(error)
|
||||
}
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
@@ -651,7 +651,7 @@ Clears the session’s HTTP cache.
|
||||
`shadercache`, `websql`, `serviceworkers`, `cachestorage`. If not
|
||||
specified, clear all storage types.
|
||||
* `quotas` string[] (optional) - The types of quotas to clear, can be
|
||||
`temporary`, `syncable`. If not specified, clear all quotas.
|
||||
`temporary`. If not specified, clear all quotas.
|
||||
|
||||
Returns `Promise<void>` - resolves when the storage data has been cleared.
|
||||
|
||||
@@ -933,6 +933,7 @@ session.fromPartition('some-partition').setPermissionRequestHandler((webContents
|
||||
* `storage-access` - Allows content loaded in a third-party context to request access to third-party cookies using the [Storage Access API](https://developer.mozilla.org/en-US/docs/Web/API/Storage_Access_API).
|
||||
* `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")`
|
||||
* `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.
|
||||
@@ -970,6 +971,7 @@ session.fromPartition('some-partition').setPermissionCheckHandler((webContents,
|
||||
* `videoRequested` Boolean - true if the web content requested a video stream.
|
||||
* `audioRequested` Boolean - true if the web content requested an audio stream.
|
||||
* `userGesture` Boolean - Whether a user gesture was active when this request was triggered.
|
||||
* `preferredDisplaySurface` String - The preferred display used for sharing screen in this request.
|
||||
* `callback` Function
|
||||
* `streams` Object
|
||||
* `video` Object | [WebFrameMain](web-frame-main.md) (optional)
|
||||
@@ -1330,18 +1332,43 @@ the initial state will be `interrupted`. The download will start only when the
|
||||
|
||||
Returns `Promise<void>` - resolves when the session’s HTTP authentication cache has been cleared.
|
||||
|
||||
#### `ses.setPreloads(preloads)`
|
||||
#### `ses.setPreloads(preloads)` _Deprecated_
|
||||
|
||||
* `preloads` string[] - An array of absolute path to preload scripts
|
||||
|
||||
Adds scripts that will be executed on ALL web contents that are associated with
|
||||
this session just before normal `preload` scripts run.
|
||||
|
||||
#### `ses.getPreloads()`
|
||||
**Deprecated:** Use the new `ses.registerPreloadScript` API.
|
||||
|
||||
#### `ses.getPreloads()` _Deprecated_
|
||||
|
||||
Returns `string[]` an array of paths to preload scripts that have been
|
||||
registered.
|
||||
|
||||
**Deprecated:** Use the new `ses.getPreloadScripts` API. This will only return preload script paths
|
||||
for `frame` context types.
|
||||
|
||||
#### `ses.registerPreloadScript(script)`
|
||||
|
||||
* `script` [PreloadScriptRegistration](structures/preload-script-registration.md) - Preload script
|
||||
|
||||
Registers preload script that will be executed in its associated context type in this session. For
|
||||
`frame` contexts, this will run prior to any preload defined in the web preferences of a
|
||||
WebContents.
|
||||
|
||||
Returns `string` - The ID of the registered preload script.
|
||||
|
||||
#### `ses.unregisterPreloadScript(id)`
|
||||
|
||||
* `id` string - Preload script ID
|
||||
|
||||
Unregisters script.
|
||||
|
||||
#### `ses.getPreloadScripts()`
|
||||
|
||||
Returns [`PreloadScript[]`](structures/preload-script.md): An array of paths to preload scripts that have been registered.
|
||||
|
||||
#### `ses.setCodeCachePath(path)`
|
||||
|
||||
* `path` String - Absolute path to store the v8 generated JS code cache from the renderer.
|
||||
@@ -1459,7 +1486,7 @@ will not work on non-persistent (in-memory) sessions.
|
||||
|
||||
**Note:** On macOS and Windows 10 this word will be removed from the OS custom dictionary as well
|
||||
|
||||
#### `ses.loadExtension(path[, options])`
|
||||
#### `ses.loadExtension(path[, options])` _Deprecated_
|
||||
|
||||
* `path` string - Path to a directory containing an unpacked Chrome extension
|
||||
* `options` Object (optional)
|
||||
@@ -1506,7 +1533,9 @@ is emitted.
|
||||
**Note:** Loading extensions into in-memory (non-persistent) sessions is not
|
||||
supported and will throw an error.
|
||||
|
||||
#### `ses.removeExtension(extensionId)`
|
||||
**Deprecated:** Use the new `ses.extensions.loadExtension` API.
|
||||
|
||||
#### `ses.removeExtension(extensionId)` _Deprecated_
|
||||
|
||||
* `extensionId` string - ID of extension to remove
|
||||
|
||||
@@ -1515,7 +1544,9 @@ Unloads an extension.
|
||||
**Note:** This API cannot be called before the `ready` event of the `app` module
|
||||
is emitted.
|
||||
|
||||
#### `ses.getExtension(extensionId)`
|
||||
**Deprecated:** Use the new `ses.extensions.removeExtension` API.
|
||||
|
||||
#### `ses.getExtension(extensionId)` _Deprecated_
|
||||
|
||||
* `extensionId` string - ID of extension to query
|
||||
|
||||
@@ -1524,13 +1555,17 @@ Returns `Extension | null` - The loaded extension with the given ID.
|
||||
**Note:** This API cannot be called before the `ready` event of the `app` module
|
||||
is emitted.
|
||||
|
||||
#### `ses.getAllExtensions()`
|
||||
**Deprecated:** Use the new `ses.extensions.getExtension` API.
|
||||
|
||||
#### `ses.getAllExtensions()` _Deprecated_
|
||||
|
||||
Returns `Extension[]` - A list of all loaded extensions.
|
||||
|
||||
**Note:** This API cannot be called before the `ready` event of the `app` module
|
||||
is emitted.
|
||||
|
||||
**Deprecated:** Use the new `ses.extensions.getAllExtensions` API.
|
||||
|
||||
#### `ses.getStoragePath()`
|
||||
|
||||
Returns `string | null` - The absolute file system path where data for this
|
||||
@@ -1593,6 +1628,10 @@ session is persisted on disk. For in memory sessions this returns `null`.
|
||||
|
||||
A [`Cookies`](cookies.md) object for this session.
|
||||
|
||||
#### `ses.extensions` _Readonly_
|
||||
|
||||
A [`Extensions`](extensions-api.md) object for this session.
|
||||
|
||||
#### `ses.serviceWorkers` _Readonly_
|
||||
|
||||
A [`ServiceWorkers`](service-workers.md) object for this session.
|
||||
|
||||
@@ -97,9 +97,10 @@
|
||||
* `height` Integer (optional) - The height of the title bar and Window Controls Overlay in pixels. Default is system height.
|
||||
* `trafficLightPosition` [Point](point.md) (optional) _macOS_ -
|
||||
Set a custom position for the traffic light buttons in frameless windows.
|
||||
* `roundedCorners` boolean (optional) _macOS_ - Whether frameless window
|
||||
should have rounded corners on macOS. Default is `true`. Setting this property
|
||||
to `false` will prevent the window from being fullscreenable.
|
||||
* `roundedCorners` boolean (optional) _macOS_ _Windows_ - Whether frameless window
|
||||
should have rounded corners. Default is `true`. Setting this property
|
||||
to `false` will prevent the window from being fullscreenable on macOS.
|
||||
On Windows versions older than Windows 11 Build 22000 this property has no effect, and frameless windows will not have rounded corners.
|
||||
* `thickFrame` boolean (optional) - Use `WS_THICKFRAME` style for frameless windows on
|
||||
Windows, which adds standard window frame. Setting it to `false` will remove
|
||||
window shadow and window animations. Default is `true`.
|
||||
@@ -149,7 +150,7 @@ Possible values are:
|
||||
focus, keyboard or mouse events, but you can use `globalShortcut` to receive
|
||||
input sparingly.
|
||||
* The `panel` type enables the window to float on top of full-screened apps
|
||||
by adding the `NSWindowStyleMaskNonactivatingPanel` style mask,normally
|
||||
by adding the `NSWindowStyleMaskNonactivatingPanel` style mask, normally
|
||||
reserved for NSPanel, at runtime. Also, the window will appear on all
|
||||
spaces (desktops).
|
||||
* On Windows, possible type is `toolbar`.
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* `colorDepth` number - The number of bits per pixel.
|
||||
* `colorSpace` string - represent a color space (three-dimensional object which contains all realizable color combinations) for the purpose of color conversions.
|
||||
* `depthPerComponent` number - The number of bits per color component.
|
||||
* `detected` boolean - `true`` if the display is detected by the system.
|
||||
* `detected` boolean - `true` if the display is detected by the system.
|
||||
* `displayFrequency` number - The display refresh rate.
|
||||
* `id` number - Unique identifier associated with the display. A value of of -1 means the display is invalid or the correct `id` is not yet known, and a value of -10 means the display is a virtual display assigned to a unified desktop.
|
||||
* `internal` boolean - `true` for an internal display and `false` for an external display.
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# IpcMainEvent Object extends `Event`
|
||||
|
||||
* `type` String - Possible values include `frame`
|
||||
* `processId` Integer - The internal ID of the renderer process that sent this message
|
||||
* `frameId` Integer - The ID of the renderer frame that sent this message
|
||||
* `returnValue` any - Set this to the value to be returned in a synchronous message
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# IpcMainInvokeEvent Object extends `Event`
|
||||
|
||||
* `type` String - Possible values include `frame`
|
||||
* `processId` Integer - The internal ID of the renderer process that sent this message
|
||||
* `frameId` Integer - The ID of the renderer frame that sent this message
|
||||
* `sender` [WebContents](../web-contents.md) - Returns the `webContents` that sent the message
|
||||
|
||||
11
docs/api/structures/ipc-main-service-worker-event.md
Normal file
11
docs/api/structures/ipc-main-service-worker-event.md
Normal file
@@ -0,0 +1,11 @@
|
||||
# IpcMainServiceWorkerEvent Object extends `Event`
|
||||
|
||||
* `type` String - Possible values include `service-worker`.
|
||||
* `serviceWorker` [ServiceWorkerMain](../service-worker-main.md) _Readonly_ - The service worker that sent this message
|
||||
* `versionId` Number - The service worker version ID.
|
||||
* `session` Session - The [`Session`](../session.md) instance with which the event is associated.
|
||||
* `returnValue` any - Set this to the value to be returned in a synchronous message
|
||||
* `ports` [MessagePortMain](../message-port-main.md)[] - A list of MessagePorts that were transferred with this message
|
||||
* `reply` Function - A function that will send an IPC message to the renderer frame that sent the original message that you are currently handling. You should use this method to "reply" to the sent message in order to guarantee the reply will go to the correct process and frame.
|
||||
* `channel` string
|
||||
* `...args` any[]
|
||||
@@ -0,0 +1,6 @@
|
||||
# IpcMainServiceWorkerInvokeEvent Object extends `Event`
|
||||
|
||||
* `type` String - Possible values include `service-worker`.
|
||||
* `serviceWorker` [ServiceWorkerMain](../service-worker-main.md) _Readonly_ - The service worker that sent this message
|
||||
* `versionId` Number - The service worker version ID.
|
||||
* `session` Session - The [`Session`](../session.md) instance with which the event is associated.
|
||||
@@ -2,3 +2,6 @@
|
||||
|
||||
* `url` string
|
||||
* `title` string
|
||||
* `pageState` string (optional) - A base64 encoded data string containing Chromium page state
|
||||
including information like the current scroll position or form values. It is committed by
|
||||
Chromium before a navigation event and on a regular interval.
|
||||
|
||||
6
docs/api/structures/preload-script-registration.md
Normal file
6
docs/api/structures/preload-script-registration.md
Normal file
@@ -0,0 +1,6 @@
|
||||
# PreloadScriptRegistration Object
|
||||
|
||||
* `type` string - Context type where the preload script will be executed.
|
||||
Possible values include `frame` or `service-worker`.
|
||||
* `id` string (optional) - Unique ID of preload script. Defaults to a random UUID.
|
||||
* `filePath` string - Path of the script file. Must be an absolute path.
|
||||
6
docs/api/structures/preload-script.md
Normal file
6
docs/api/structures/preload-script.md
Normal file
@@ -0,0 +1,6 @@
|
||||
# PreloadScript Object
|
||||
|
||||
* `type` string - Context type where the preload script will be executed.
|
||||
Possible values include `frame` or `service-worker`.
|
||||
* `id` string - Unique ID of preload script.
|
||||
* `filePath` string - Path of the script file. Must be an absolute path.
|
||||
@@ -3,8 +3,6 @@
|
||||
* `name` string - the name of the printer as understood by the OS.
|
||||
* `displayName` string - the name of the printer as shown in Print Preview.
|
||||
* `description` string - a longer description of the printer's type.
|
||||
* `status` number - the current status of the printer.
|
||||
* `isDefault` boolean - whether or not a given printer is set as the default printer on the OS.
|
||||
* `options` Object - an object containing a variable number of platform-specific printer information.
|
||||
|
||||
The number represented by `status` means different things on different platforms: on Windows its potential values can be found [here](https://learn.microsoft.com/en-us/windows/win32/printdocs/printer-info-2), and on Linux and macOS they can be found [here](https://www.cups.org/doc/cupspm.html).
|
||||
@@ -19,8 +17,6 @@ may be different on each platform.
|
||||
name: 'Austin_4th_Floor_Printer___C02XK13BJHD4',
|
||||
displayName: 'Austin 4th Floor Printer @ C02XK13BJHD4',
|
||||
description: 'TOSHIBA ColorMFP',
|
||||
status: 3,
|
||||
isDefault: false,
|
||||
options: {
|
||||
copies: '1',
|
||||
'device-uri': 'dnssd://Austin%204th%20Floor%20Printer%20%40%20C02XK13BJHD4._ipps._tcp.local./?uuid=71687f1e-1147-3274-6674-22de61b110bd',
|
||||
|
||||
@@ -3,3 +3,4 @@
|
||||
* `scriptUrl` string - The full URL to the script that this service worker runs
|
||||
* `scope` string - The base URL that this service worker is active for.
|
||||
* `renderProcessId` number - The virtual ID of the process that this service worker is running in. This is not an OS level PID. This aligns with the ID set used for `webContents.getProcessId()`.
|
||||
* `versionId` number - ID of the service worker version
|
||||
|
||||
@@ -148,6 +148,7 @@
|
||||
this will cause the `preferred-size-changed` event to be emitted on the
|
||||
`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`.
|
||||
|
||||
[chrome-content-scripts]: https://developer.chrome.com/extensions/content_scripts#execution-environment
|
||||
[runtime-enabled-features]: https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/platform/runtime_enabled_features.json5
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
# WebRequestFilter Object
|
||||
|
||||
* `urls` string[] - Array of [URL patterns](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Match_patterns) that will be used to filter out the requests that do not match the URL patterns.
|
||||
* `types` String[] (optional) - Array of types that will be used to filter out the requests that do not match the types. When not specified, all types will be matched. Can be `mainFrame`, `subFrame`, `stylesheet`, `script`, `image`, `font`, `object`, `xhr`, `ping`, `cspReport`, `media` or `webSocket`.
|
||||
* `urls` string[] - Array of [URL patterns](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Match_patterns) used to include requests that match these patterns. Use the pattern `<all_urls>` to match all URLs.
|
||||
* `excludeUrls` string[] (optional) - Array of [URL patterns](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Match_patterns) used to exclude requests that match these patterns.
|
||||
* `types` string[] (optional) - Array of types that will be used to filter out the requests that do not match the types. When not specified, all types will be matched. Can be `mainFrame`, `subFrame`, `stylesheet`, `script`, `image`, `font`, `object`, `xhr`, `ping`, `cspReport`, `media` or `webSocket`.
|
||||
|
||||
@@ -6,7 +6,7 @@ Process: [Main](../glossary.md#main-process), [Utility](../glossary.md#utility-p
|
||||
|
||||
```js
|
||||
const { systemPreferences } = require('electron')
|
||||
console.log(systemPreferences.isAeroGlassEnabled())
|
||||
console.log(systemPreferences.getEffectiveAppearance())
|
||||
```
|
||||
|
||||
## Events
|
||||
@@ -181,38 +181,6 @@ Some popular `key` and `type`s are:
|
||||
Removes the `key` in `NSUserDefaults`. This can be used to restore the default
|
||||
or global value of a `key` previously set with `setUserDefault`.
|
||||
|
||||
### `systemPreferences.isAeroGlassEnabled()` _Windows_
|
||||
|
||||
Returns `boolean` - `true` if [DWM composition][dwm-composition] (Aero Glass) is
|
||||
enabled, and `false` otherwise.
|
||||
|
||||
An example of using it to determine if you should create a transparent window or
|
||||
not (transparent windows won't work correctly when DWM composition is disabled):
|
||||
|
||||
```js
|
||||
const { BrowserWindow, systemPreferences } = require('electron')
|
||||
const browserOptions = { width: 1000, height: 800 }
|
||||
|
||||
// Make the window transparent only if the platform supports it.
|
||||
if (process.platform !== 'win32' || systemPreferences.isAeroGlassEnabled()) {
|
||||
browserOptions.transparent = true
|
||||
browserOptions.frame = false
|
||||
}
|
||||
|
||||
// Create the window.
|
||||
const win = new BrowserWindow(browserOptions)
|
||||
|
||||
// Navigate.
|
||||
if (browserOptions.transparent) {
|
||||
win.loadFile('index.html')
|
||||
} else {
|
||||
// No transparency, so we load a fallback that uses basic styles.
|
||||
win.loadFile('fallback.html')
|
||||
}
|
||||
```
|
||||
|
||||
[dwm-composition]: https://learn.microsoft.com/en-us/windows/win32/dwm/composition-ovw
|
||||
|
||||
### `systemPreferences.getAccentColor()` _Windows_ _macOS_
|
||||
|
||||
Returns `string` - The users current system wide accent color preference in RGBA
|
||||
|
||||
@@ -106,6 +106,12 @@ Examples of valid `color` values:
|
||||
|
||||
* `visible` boolean - If false, the view will be hidden from display.
|
||||
|
||||
#### `view.getVisible()`
|
||||
|
||||
Returns `boolean` - Whether the view should be drawn. Note that this is
|
||||
different from whether the view is visible on screen—it may still be obscured
|
||||
or out of view.
|
||||
|
||||
### Instance Properties
|
||||
|
||||
Objects created with `new View` have the following properties:
|
||||
|
||||
@@ -898,6 +898,8 @@ copying data between CPU and GPU memory, with Chromium's hardware acceleration s
|
||||
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.
|
||||
By managing the texture lifecycle by yourself, you can safely pass the `texture.textureInfo` to other processes through IPC.
|
||||
|
||||
More details can be found in the [offscreen rendering tutorial](../tutorial/offscreen-rendering.md). To learn about how to handle the texture in native code, refer to [offscreen rendering's code documentation.](https://github.com/electron/electron/blob/main/shell/browser/osr/README.md).
|
||||
|
||||
```js
|
||||
const { BrowserWindow } = require('electron')
|
||||
|
||||
@@ -909,7 +911,7 @@ win.webContents.on('paint', async (e, dirty, image) => {
|
||||
await new Promise(resolve => setTimeout(resolve, 50))
|
||||
|
||||
// You can send the native texture handle to native code for importing into your rendering pipeline.
|
||||
// For example: https://github.com/electron/electron/tree/main/spec/fixtures/native-addon/osr-gpu
|
||||
// Read more at https://github.com/electron/electron/blob/main/shell/browser/osr/README.md
|
||||
// importTextureHandle(dirty, e.texture.textureInfo)
|
||||
|
||||
// You must call `e.texture.release()` as soon as possible, before the underlying frame pool is drained.
|
||||
@@ -2389,9 +2391,14 @@ A [`WebFrameMain`](web-frame-main.md) property that represents the top frame of
|
||||
|
||||
#### `contents.opener` _Readonly_
|
||||
|
||||
A [`WebFrameMain`](web-frame-main.md) property that represents the frame that opened this WebContents, either
|
||||
A [`WebFrameMain | null`](web-frame-main.md) property that represents the frame that opened this WebContents, either
|
||||
with open(), or by navigating a link with a target attribute.
|
||||
|
||||
#### `contents.focusedFrame` _Readonly_
|
||||
|
||||
A [`WebFrameMain | null`](web-frame-main.md) property that represents the currently focused frame in this WebContents.
|
||||
Can be the top frame, an inner `<iframe>`, or `null` if nothing is focused.
|
||||
|
||||
[keyboardevent]: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent
|
||||
[event-emitter]: https://nodejs.org/api/events.html#events_class_eventemitter
|
||||
[SCA]: https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm
|
||||
|
||||
@@ -73,6 +73,7 @@ The `callback` has to be called with an `response` object.
|
||||
Some examples of valid `urls`:
|
||||
|
||||
```js
|
||||
'<all_urls>'
|
||||
'http://foo:1234/'
|
||||
'http://foo.com/'
|
||||
'http://foo:1234/bar'
|
||||
|
||||
@@ -12,8 +12,99 @@ 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 (36.0)
|
||||
|
||||
### Utility Process unhandled rejection behavior change
|
||||
|
||||
Utility Processes will now warn with an error message when an unhandled
|
||||
rejection occurs instead of crashing the process.
|
||||
|
||||
To restore the previous behavior, you can use:
|
||||
|
||||
```js
|
||||
process.on('unhandledRejection', () => {
|
||||
process.exit(1)
|
||||
})
|
||||
```
|
||||
|
||||
### Removed:`isDefault` and `status` properties on `PrinterInfo`
|
||||
|
||||
These properties have been removed from the PrinterInfo Object
|
||||
because they have been removed from upstream Chromium.
|
||||
|
||||
### Removed: `quota` type `syncable` in `Session.clearStorageData(options)`
|
||||
|
||||
When calling `Session.clearStorageData(options)`, the `options.quota` type
|
||||
`syncable` is no longer supported because it has been
|
||||
[removed](https://chromium-review.googlesource.com/c/chromium/src/+/6309405)
|
||||
from upstream Chromium.
|
||||
|
||||
### Deprecated: `quota` property in `Session.clearStorageData(options)`
|
||||
|
||||
When calling `Session.clearStorageData(options)`, the `options.quota`
|
||||
property is deprecated. Since the `syncable` type was removed, there
|
||||
is only type left -- `'temporary'` -- so specifying it is unnecessary.
|
||||
|
||||
### Deprecated: Extension methods and events on `session`
|
||||
|
||||
`session.loadExtension`, `session.removeExtension`, `session.getExtension`,
|
||||
`session.getAllExtensions`, 'extension-loaded' event, 'extension-unloaded'
|
||||
event, and 'extension-ready' events have all moved to the new
|
||||
`session.extensions` class.
|
||||
|
||||
### Removed: `systemPreferences.isAeroGlassEnabled()`
|
||||
|
||||
The `systemPreferences.isAeroGlassEnabled()` function has been removed without replacement.
|
||||
It has been always returning `true` since Electron 23, which only supports Windows 10+, where DWM composition can no longer be disabled.
|
||||
|
||||
https://learn.microsoft.com/en-us/windows/win32/dwm/composition-ovw#disabling-dwm-composition-windows7-and-earlier
|
||||
|
||||
## Planned Breaking API Changes (35.0)
|
||||
|
||||
### Behavior Changed: Dialog API's `defaultPath` option on Linux
|
||||
|
||||
On Linux, the required portal version for file dialogs has been reverted
|
||||
to 3 from 4. Using the `defaultPath` option of the Dialog API is not
|
||||
supported when using portal file chooser dialogs unless the portal
|
||||
backend is version 4 or higher. The `--xdg-portal-required-version`
|
||||
[command-line switch](/api/command-line-switches.md#--xdg-portal-required-versionversion)
|
||||
can be used to force a required version for your application.
|
||||
See [#44426](https://github.com/electron/electron/pull/44426) for more details.
|
||||
|
||||
### Deprecated: `getFromVersionID` on `session.serviceWorkers`
|
||||
|
||||
The `session.serviceWorkers.fromVersionID(versionId)` API has been deprecated
|
||||
in favor of `session.serviceWorkers.getInfoFromVersionID(versionId)`. This was
|
||||
changed to make it more clear which object is returned with the introduction
|
||||
of the `session.serviceWorkers.getWorkerFromVersionID(versionId)` API.
|
||||
|
||||
```js
|
||||
// Deprecated
|
||||
session.serviceWorkers.fromVersionID(versionId)
|
||||
|
||||
// Replace with
|
||||
session.serviceWorkers.getInfoFromVersionID(versionId)
|
||||
```
|
||||
|
||||
### Deprecated: `setPreloads`, `getPreloads` on `Session`
|
||||
|
||||
`registerPreloadScript`, `unregisterPreloadScript`, and `getPreloadScripts` are introduced as a
|
||||
replacement for the deprecated methods. These new APIs allow third-party libraries to register
|
||||
preload scripts without replacing existing scripts. Also, the new `type` option allows for
|
||||
additional preload targets beyond `frame`.
|
||||
|
||||
```js
|
||||
// Deprecated
|
||||
session.setPreloads([path.join(__dirname, 'preload.js')])
|
||||
|
||||
// Replace with:
|
||||
session.registerPreloadScript({
|
||||
type: 'frame',
|
||||
id: 'app-preload',
|
||||
filePath: path.join(__dirname, 'preload.js')
|
||||
})
|
||||
```
|
||||
|
||||
### Deprecated: `level`, `message`, `line`, and `sourceId` arguments in `console-message` event on `WebContents`
|
||||
|
||||
The `console-message` event on `WebContents` has been updated to provide details on the `Event`
|
||||
@@ -29,6 +120,29 @@ webContents.on('console-message', ({ level, message, lineNumber, sourceId, frame
|
||||
|
||||
Additionally, `level` is now a string with possible values of `info`, `warning`, `error`, and `debug`.
|
||||
|
||||
### Behavior Changed: `urls` property of `WebRequestFilter`.
|
||||
|
||||
Previously, an empty urls array was interpreted as including all URLs. To explicitly include all URLs, developers should now use the `<all_urls>` pattern, which is a [designated URL pattern](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Match_patterns#all_urls) that matches every possible URL. This change clarifies the intent and ensures more predictable behavior.
|
||||
|
||||
```js
|
||||
// Deprecated
|
||||
const deprecatedFilter = {
|
||||
urls: []
|
||||
}
|
||||
|
||||
// Replace with
|
||||
const newFilter = {
|
||||
urls: ['<all_urls>']
|
||||
}
|
||||
```
|
||||
|
||||
### Deprecated: `systemPreferences.isAeroGlassEnabled()`
|
||||
|
||||
The `systemPreferences.isAeroGlassEnabled()` function has been deprecated without replacement.
|
||||
It has been always returning `true` since Electron 23, which only supports Windows 10+, where DWM composition can no longer be disabled.
|
||||
|
||||
https://learn.microsoft.com/en-us/windows/win32/dwm/composition-ovw#disabling-dwm-composition-windows7-and-earlier
|
||||
|
||||
## Planned Breaking API Changes (34.0)
|
||||
|
||||
### Behavior Changed: menu bar will be hidden during fullscreen on Windows
|
||||
@@ -39,6 +153,15 @@ This brings the behavior to parity with Linux. Prior behavior: Menu bar is still
|
||||
|
||||
## Planned Breaking API Changes (33.0)
|
||||
|
||||
### Deprecated: `document.execCommand("paste")`
|
||||
|
||||
The synchronous clipboard read API [document.execCommand("paste")](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Interact_with_the_clipboard) has been
|
||||
deprecated in favor of [async clipboard API](https://developer.mozilla.org/en-US/docs/Web/API/Clipboard_API). This is to align with the browser defaults.
|
||||
|
||||
The `enableDeprecatedPaste` option on `WebPreferences` that triggers the permission
|
||||
checks for this API and the associated permission type `deprecated-sync-clipboard-read`
|
||||
are also deprecated.
|
||||
|
||||
### Behavior Changed: frame properties may retrieve detached WebFrameMain instances or none at all
|
||||
|
||||
APIs which provide access to a `WebFrameMain` instance may return an instance
|
||||
@@ -56,15 +179,15 @@ immediately upon being received. Otherwise, it's not guaranteed to point to the
|
||||
same webpage as when received. To avoid misaligned expectations, Electron will
|
||||
return `null` in the case of late access where the webpage has changed.
|
||||
|
||||
```ts
|
||||
```js
|
||||
ipcMain.on('unload-event', (event) => {
|
||||
event.senderFrame; // ✅ accessed immediately
|
||||
});
|
||||
event.senderFrame // ✅ accessed immediately
|
||||
})
|
||||
|
||||
ipcMain.on('unload-event', async (event) => {
|
||||
await crossOriginNavigationPromise;
|
||||
event.senderFrame; // ❌ returns `null` due to late access
|
||||
});
|
||||
await crossOriginNavigationPromise
|
||||
event.senderFrame // ❌ returns `null` due to late access
|
||||
})
|
||||
```
|
||||
|
||||
### Behavior Changed: custom protocol URL handling on Windows
|
||||
@@ -111,6 +234,16 @@ macOS 10.15 (Catalina) is no longer supported by [Chromium](https://chromium-rev
|
||||
Older versions of Electron will continue to run on Catalina, but macOS 11 (Big Sur)
|
||||
or later will be required to run Electron v33.0.0 and higher.
|
||||
|
||||
### Behavior Changed: Native modules now require C++20
|
||||
|
||||
Due to changes made upstream, both
|
||||
[V8](https://chromium-review.googlesource.com/c/v8/v8/+/5587859) and
|
||||
[Node.js](https://github.com/nodejs/node/pull/45427) now require C++20 as a
|
||||
minimum version. Developers using native node modules should build their
|
||||
modules with `--std=c++20` rather than `--std=c++17`. Images using gcc9 or
|
||||
lower may need to update to gcc10 in order to compile. See
|
||||
[#43555](https://github.com/electron/electron/pull/43555) for more details.
|
||||
|
||||
### Deprecated: `systemPreferences.accessibilityDisplayShouldReduceTransparency`
|
||||
|
||||
The `systemPreferences.accessibilityDisplayShouldReduceTransparency` property is now deprecated in favor of the new `nativeTheme.prefersReducedTransparency`, which provides identical information and works cross-platform.
|
||||
@@ -182,6 +315,14 @@ win.webContents.navigationHistory.canGoToOffset()
|
||||
win.webContents.navigationHistory.goToOffset(index)
|
||||
```
|
||||
|
||||
### Behavior changed: Directory `databases` in `userData` will be deleted
|
||||
|
||||
If you have a directory called `databases` in the directory returned by
|
||||
`app.getPath('userData')`, it will be deleted when Electron 32 is first run.
|
||||
The `databases` directory was used by WebSQL, which was removed in Electron 31.
|
||||
Chromium now performs a cleanup that deletes this directory. See
|
||||
[issue #45396](https://github.com/electron/electron/issues/45396).
|
||||
|
||||
## Planned Breaking API Changes (31.0)
|
||||
|
||||
### Removed: `WebSQL` support
|
||||
|
||||
@@ -65,7 +65,7 @@ Verify that the Pull Request is correct and make a corresponding entry in the
|
||||
API History:
|
||||
|
||||
> [!NOTE]
|
||||
> Refer to the [API History section of `styleguide.md`](../styleguide.md#api-history)
|
||||
> Refer to the [API History section of `style-guide.md`](./style-guide.md#api-history)
|
||||
for information on how to create API History blocks.
|
||||
|
||||
`````markdown
|
||||
|
||||
@@ -195,7 +195,7 @@ required[, optional]
|
||||
More detailed information on each of the arguments is noted in an unordered list
|
||||
below the method. The type of argument is notated by either JavaScript primitives
|
||||
(e.g. `string`, `Promise`, or `Object`), a custom API structure like Electron's
|
||||
[`Cookie`](api/structures/cookie.md), or the wildcard `any`.
|
||||
[`Cookie`](../api/structures/cookie.md), or the wildcard `any`.
|
||||
|
||||
If the argument is of type `Array`, use `[]` shorthand with the type of value
|
||||
inside the array (for example,`any[]` or `string[]`).
|
||||
@@ -290,7 +290,7 @@ The purpose of the API History block is to describe when/where/how/why an API wa
|
||||
Each API change listed in the block should include a link to the
|
||||
PR where that change was made along with an optional short description of the
|
||||
change. If applicable, include the [heading id](https://gist.github.com/asabaylus/3071099)
|
||||
for that change from the [breaking changes documentation](./breaking-changes.md).
|
||||
for that change from the [breaking changes documentation](../breaking-changes.md).
|
||||
|
||||
The [API History linting script][api-history-linting-script] (`lint:api-history`)
|
||||
validates API History blocks in the Electron documentation against the schema and
|
||||
@@ -4,7 +4,7 @@ function createWindow () {
|
||||
const win = new BrowserWindow({
|
||||
// remove the default titlebar
|
||||
titleBarStyle: 'hidden',
|
||||
// expose window controlls in Windows/Linux
|
||||
// expose window controls in Windows/Linux
|
||||
...(process.platform !== 'darwin' ? { titleBarOverlay: true } : {})
|
||||
})
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ function createWindow () {
|
||||
const win = new BrowserWindow({
|
||||
// remove the default titlebar
|
||||
titleBarStyle: 'hidden',
|
||||
// expose window controlls in Windows/Linux
|
||||
// expose window controls in Windows/Linux
|
||||
...(process.platform !== 'darwin' ? { titleBarOverlay: true } : {})
|
||||
})
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ function createWindow () {
|
||||
const win = new BrowserWindow({
|
||||
// remove the default titlebar
|
||||
titleBarStyle: 'hidden',
|
||||
// expose window controlls in Windows/Linux
|
||||
// expose window controls in Windows/Linux
|
||||
...(process.platform !== 'darwin' ? { titleBarOverlay: true } : {})
|
||||
})
|
||||
win.loadURL('https://example.com')
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
Application windows have a default [chrome][] applied by the OS. Not to be confused
|
||||
with the Google Chrome browser, window _chrome_ refers to the parts of the window (e.g.
|
||||
title bar, toolbars, controls) that are not a part of the main web content. While the
|
||||
default title bar provided by the OS chrome is sufficent for simple use cases, many
|
||||
default title bar provided by the OS chrome is sufficient for simple use cases, many
|
||||
applications opt to remove it. Implementing a custom title bar can help your application
|
||||
feel more modern and consistent across platforms.
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ To create a frameless window, set the [`BaseWindowContructorOptions`][] `frame`
|
||||
|
||||
To create a fully transparent window, set the [`BaseWindowContructorOptions`][] `transparent` param in the `BrowserWindow` constructor to `true`.
|
||||
|
||||
The following fiddle takes advantage of a tranparent window and CSS styling to create
|
||||
The following fiddle takes advantage of a transparent window and CSS styling to create
|
||||
the illusion of a circular window.
|
||||
|
||||
```fiddle docs/fiddles/features/window-customization/custom-window-styles/transparent-windows
|
||||
|
||||
@@ -96,9 +96,9 @@ of the extension is not working as expected.
|
||||
[devtools-extension]: https://developer.chrome.com/extensions/devtools
|
||||
[session]: ../api/session.md
|
||||
[react-devtools]: https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi
|
||||
[load-extension]: ../api/session.md#sesloadextensionpath-options
|
||||
[load-extension]: ../api/extensions-api.md#extensionsloadextensionpath-options
|
||||
[extension-structure]: ../api/structures/extension.md
|
||||
[remove-extension]: ../api/session.md#sesremoveextensionextensionid
|
||||
[remove-extension]: ../api/extensions-api.md#extensionsremoveextensionextensionid
|
||||
[electron-devtools-installer]: https://github.com/MarshallOfSound/electron-devtools-installer
|
||||
[supported-extension-apis]: ../api/extensions.md
|
||||
[issue-tracker]: https://github.com/electron/electron/issues
|
||||
|
||||
@@ -9,10 +9,11 @@ check out our [Electron Versioning](./electron-versioning.md) doc.
|
||||
|
||||
| Electron | Alpha | Beta | Stable | EOL | Chrome | Node | Supported |
|
||||
| ------- | ----- | ------- | ------ | ------ | ---- | ---- | ---- |
|
||||
| 35.0.0 | 2025-Jan-16 | 2025-Feb-05 | 2025-Mar-04 | 2025-Sep-02 | M134 | TBD | ✅ |
|
||||
| 36.0.0 | 2025-Mar-06 | 2025-Apr-02 | 2025-Apr-29 | 2025-Oct-28 | M136 | TBD | ✅ |
|
||||
| 35.0.0 | 2025-Jan-16 | 2025-Feb-05 | 2025-Mar-04 | 2025-Sep-02 | M134 | v22.14 | ✅ |
|
||||
| 34.0.0 | 2024-Oct-17 | 2024-Nov-13 | 2025-Jan-14 | 2025-Jun-24 | M132 | v20.18 | ✅ |
|
||||
| 33.0.0 | 2024-Aug-22 | 2024-Sep-18 | 2024-Oct-15 | 2025-Apr-29 | M130 | v20.18 | ✅ |
|
||||
| 32.0.0 | 2024-Jun-14 | 2024-Jul-24 | 2024-Aug-20 | 2025-Mar-04 | M128 | v20.16 | ✅ |
|
||||
| 32.0.0 | 2024-Jun-14 | 2024-Jul-24 | 2024-Aug-20 | 2025-Mar-04 | M128 | v20.16 | 🚫 |
|
||||
| 31.0.0 | 2024-Apr-18 | 2024-May-15 | 2024-Jun-11 | 2025-Jan-14 | M126 | v20.14 | 🚫 |
|
||||
| 30.0.0 | 2024-Feb-22 | 2024-Mar-20 | 2024-Apr-16 | 2024-Oct-15 | M124 | v20.11 | 🚫 |
|
||||
| 29.0.0 | 2023-Dec-07 | 2024-Jan-24 | 2024-Feb-20 | 2024-Aug-20 | M122 | v20.9 | 🚫 |
|
||||
|
||||
380
docs/tutorial/native-code-and-electron.md
Normal file
380
docs/tutorial/native-code-and-electron.md
Normal file
@@ -0,0 +1,380 @@
|
||||
# Native Code and Electron
|
||||
|
||||
One of Electron's most powerful features is the ability to combine web technologies with native code - both for compute-intensive logic as well as for the occasional native user interface, where desired.
|
||||
|
||||
Electron does so by building on top of "Native Node.js Addons". You've probably already come across a few of them - packages like the famous [sqlite](https://www.npmjs.com/package/sqlite3) use native code to combine JavaScript and native technologies. You can use this feature to extend your Electron application with anything a fully native application can do:
|
||||
|
||||
* Access native platform APIs not available in JavaScript. Any macOS, Windows, or Linux operating system API is available to you.
|
||||
* Create UI components that interact with native desktop frameworks.
|
||||
* Integrate with existing native libraries.
|
||||
* Implement performance-critical code that runs faster than JavaScript.
|
||||
|
||||
Native Node.js addons are dynamically-linked shared objects (on Unix-like systems) or DLL files (on Windows) that can be loaded into Node.js or Electron using the `require()` or `import` functions. They behave just like regular JavaScript modules but provide an interface to code written in C++, Rust, or other languages that can compile to native code.
|
||||
|
||||
# Tutorial: Creating a Native Node.js Addon for Electron
|
||||
|
||||
This tutorial will walk you through building a basic Node.js native addon that can be used in Electron applications. We'll focus on concepts common to all platforms, using C++ as the implementation language. Once you complete this tutorial common to all native Node.js addons, you can move on to one of our platform-specific tutorials.
|
||||
|
||||
## Requirements
|
||||
|
||||
This tutorial assumes you have Node.js and npm installed, as well as the basic tools necessary for compiling code on your platform (like Visual Studio on Windows, Xcode on macOS, or GCC/Clang on Linux). You can find detailed instructions in the [`node-gyp` readme](https://github.com/nodejs/node-gyp?tab=readme-ov-file).
|
||||
|
||||
### Requirements: macOS
|
||||
|
||||
To build native Node.js addons on macOS, you'll need the Xcode Command Line Tools. These provide the necessary compilers and build tools (namely, `clang`, `clang++`, and `make`). The following command will prompt you to install the Command Line Tools if they aren't already installed.
|
||||
|
||||
```sh
|
||||
xcode-select --install
|
||||
```
|
||||
|
||||
### Requirements: Windows
|
||||
|
||||
The official Node.js installer offers the optional installation of "Tools for Native Modules", which installs everything required for the basic compilation of C++ modules - specifically, Python 3 and the "Visual Studio Desktop development with C++" workload. Alternatively, you can use `chocolatey`, `winget`, or the Windows Store.
|
||||
|
||||
### Requirements: Linux
|
||||
|
||||
* [A supported version of Python](https://devguide.python.org/versions/)
|
||||
* `make`
|
||||
* A proper C/C++ compiler toolchain, like [GCC](https://gcc.gnu.org)
|
||||
|
||||
## 1) Creating a package
|
||||
|
||||
First, create a new Node.js package that will contain your native addon:
|
||||
|
||||
```sh
|
||||
mkdir my-native-addon
|
||||
cd my-native-addon
|
||||
npm init -y
|
||||
```
|
||||
|
||||
This creates a basic `package.json` file. Next, we'll install the necessary dependencies:
|
||||
|
||||
```sh
|
||||
npm install node-addon-api bindings
|
||||
```
|
||||
|
||||
* `node-addon-api`: This is a C++ wrapper for the low-level Node.js API that makes it easier to build addons. It provides a C++ object-oriented API that's more convenient and safer to use than the raw C-style API.
|
||||
* `bindings`: A helper module that simplifies the process of loading your compiled native addon. It handles finding your compiled `.node` file automatically.
|
||||
|
||||
Now, let's update our `package.json` to include the appropriate build scripts. We will explain what these specifically do further below.
|
||||
|
||||
```json title='package.json'
|
||||
{
|
||||
"name": "my-native-addon",
|
||||
"version": "1.0.0",
|
||||
"description": "A native addon for Electron",
|
||||
"main": "js/index.js",
|
||||
"scripts": {
|
||||
"clean": "node -e \"require('fs').rmSync('build', { recursive: true, force: true })\"",
|
||||
"build": "node-gyp configure && node-gyp build"
|
||||
},
|
||||
"dependencies": {
|
||||
"bindings": "^1.5.0",
|
||||
"node-addon-api": "^8.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"node-gyp": "^11.1.0"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
These scripts will:
|
||||
|
||||
* `clean`: Remove the build directory, allowing for a fresh build
|
||||
* `build`: Run the standard node-gyp build process to compile your addon
|
||||
|
||||
## 2) Setting up the build system
|
||||
|
||||
Node.js addons use a build system called `node-gyp`, which is a cross-platform command-line tool written in Node.js. It compiles native addon modules for Node.js using platform-specific build tools behind the scenes:
|
||||
|
||||
* On Windows: Visual Studio
|
||||
* On macOS: Xcode or command-line tools
|
||||
* On Linux: GCC or similar compilers
|
||||
|
||||
### Configuring `node-gyp`
|
||||
|
||||
The `binding.gyp` file is a JSON-like configuration file that tells node-gyp how to build your native addon. It's similar to a make file or a project file but in a platform-independent format. Let's create a basic `binding.gyp` file:
|
||||
|
||||
```json title='binding.gyp'
|
||||
{
|
||||
"targets": [
|
||||
{
|
||||
"target_name": "my_addon",
|
||||
"sources": [
|
||||
"src/my_addon.cc",
|
||||
"src/cpp_code.cc"
|
||||
],
|
||||
"include_dirs": [
|
||||
"<!@(node -p \"require('node-addon-api').include\")",
|
||||
"include"
|
||||
],
|
||||
"dependencies": [
|
||||
"<!(node -p \"require('node-addon-api').gyp\")"
|
||||
],
|
||||
"defines": [
|
||||
"NODE_ADDON_API_CPP_EXCEPTIONS"
|
||||
],
|
||||
"cflags!": ["-fno-exceptions"],
|
||||
"cflags_cc!": ["-fno-exceptions"],
|
||||
"xcode_settings": {
|
||||
"GCC_ENABLE_CPP_EXCEPTIONS": "YES",
|
||||
"CLANG_CXX_LIBRARY": "libc++",
|
||||
"MACOSX_DEPLOYMENT_TARGET": "10.14"
|
||||
},
|
||||
"msvs_settings": {
|
||||
"VCCLCompilerTool": {
|
||||
"ExceptionHandling": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
Let's break down this configuration:
|
||||
|
||||
* `target_name`: The name of your addon. This determines the filename of the compiled module (my_addon.node).
|
||||
* `sources`: List of source files to compile. We'll have two files: the main addon file and our actual C++ implementation.
|
||||
* `include_dirs`: Directories to search for header files. The cryptic-looking line `<!@(node -p \"require('node-addon-api').include\")` runs a Node.js command to get the path to the node-addon-api include directory.
|
||||
* `dependencies`: The `node-addon-api` dependency. Similar to the include dirs, this executes a Node.js command to get the proper configuration.
|
||||
* `defines`: Preprocessor definitions. Here we're enabling C++ exceptions for node-addon-api.
|
||||
Platform-specific settings:
|
||||
* `cflags`! and cflags_cc!: Compiler flags for Unix-like systems
|
||||
* `xcode_settings`: Settings specific to macOS/Xcode compiler
|
||||
* `msvs_settings`: Settings specific to Microsoft Visual Studio on Windows
|
||||
|
||||
Now, create the directory structure for our project:
|
||||
|
||||
```sh
|
||||
mkdir src
|
||||
mkdir include
|
||||
mkdir js
|
||||
```
|
||||
|
||||
This creates:
|
||||
|
||||
* `src/`: Where our source files will go
|
||||
* `include/`: For header files
|
||||
* `js/`: For our JavaScript wrapper
|
||||
|
||||
## 3) "Hello World" from C++
|
||||
|
||||
Let's start by defining our C++ interface in a header file. Create `include/cpp_code.h`:
|
||||
|
||||
```cpp
|
||||
#pragma once
|
||||
#include <string>
|
||||
|
||||
namespace cpp_code {
|
||||
// A simple function that takes a string input and returns a string
|
||||
std::string hello_world(const std::string& input);
|
||||
} // namespace cpp_code
|
||||
```
|
||||
|
||||
The `#pragma once` directive is a header guard that prevents the file from being included multiple times in the same compilation unit. The actual function declaration is inside a namespace to avoid potential name conflicts.
|
||||
|
||||
Next, let's implement the function in `src/cpp_code.cc`:
|
||||
|
||||
```cpp title='src/cpp_code.cc'
|
||||
#include <string>
|
||||
#include "../include/cpp_code.h"
|
||||
|
||||
namespace cpp_code {
|
||||
std::string hello_world(const std::string& input) {
|
||||
// Simply concatenate strings and return
|
||||
return "Hello from C++! You said: " + input;
|
||||
}
|
||||
} // namespace cpp_code
|
||||
```
|
||||
|
||||
This is a simple implementation that just adds some text to the input string and returns it.
|
||||
|
||||
Now, let's create the addon code that bridges our C++ code with the Node.js/JavaScript world. Create `src/my_addon.cc`:
|
||||
|
||||
```cpp title='src/my_addon.cc'
|
||||
#include <napi.h>
|
||||
#include <string>
|
||||
#include "../include/cpp_code.h"
|
||||
|
||||
// Create a class that will be exposed to JavaScript
|
||||
class MyAddon : public Napi::ObjectWrap<MyAddon> {
|
||||
public:
|
||||
// This static method defines the class for JavaScript
|
||||
static Napi::Object Init(Napi::Env env, Napi::Object exports) {
|
||||
// Define the JavaScript class with method(s)
|
||||
Napi::Function func = DefineClass(env, "MyAddon", {
|
||||
InstanceMethod("helloWorld", &MyAddon::HelloWorld)
|
||||
});
|
||||
|
||||
// Create a persistent reference to the constructor
|
||||
Napi::FunctionReference* constructor = new Napi::FunctionReference();
|
||||
*constructor = Napi::Persistent(func);
|
||||
env.SetInstanceData(constructor);
|
||||
|
||||
// Set the constructor on the exports object
|
||||
exports.Set("MyAddon", func);
|
||||
return exports;
|
||||
}
|
||||
|
||||
// Constructor
|
||||
MyAddon(const Napi::CallbackInfo& info)
|
||||
: Napi::ObjectWrap<MyAddon>(info) {}
|
||||
|
||||
private:
|
||||
// Method that will be exposed to JavaScript
|
||||
Napi::Value HelloWorld(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
|
||||
// Validate arguments (expecting one string)
|
||||
if (info.Length() < 1 || !info[0].IsString()) {
|
||||
Napi::TypeError::New(env, "Expected string argument").ThrowAsJavaScriptException();
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
// Convert JavaScript string to C++ string
|
||||
std::string input = info[0].As<Napi::String>();
|
||||
|
||||
// Call our C++ function
|
||||
std::string result = cpp_code::hello_world(input);
|
||||
|
||||
// Convert C++ string back to JavaScript string and return
|
||||
return Napi::String::New(env, result);
|
||||
}
|
||||
};
|
||||
|
||||
// Initialize the addon
|
||||
Napi::Object Init(Napi::Env env, Napi::Object exports) {
|
||||
return MyAddon::Init(env, exports);
|
||||
}
|
||||
|
||||
// Register the initialization function
|
||||
NODE_API_MODULE(my_addon, Init)
|
||||
```
|
||||
|
||||
Let's break down this code:
|
||||
|
||||
1. We define a `MyAddon` class that inherits from `Napi::ObjectWrap<MyAddon>`, which handles wrapping our C++ class for JavaScript.
|
||||
2. The `Init` static method:
|
||||
2.1 Defines a JavaScript class with a method called `helloWorld`
|
||||
2.2 Creates a persistent reference to the constructor (to prevent garbage collection)
|
||||
2.3 Exports the class constructor
|
||||
3. The constructor simply passes its arguments to the parent class.
|
||||
4. The `HelloWorld` method:
|
||||
4.1 Gets the Napi environment
|
||||
4.2 Validates input arguments (expecting a string)
|
||||
4.3 Converts the JavaScript string to a C++ string
|
||||
4.4 Calls our C++ function
|
||||
4.5 Converts the result back to a JavaScript string and returns it
|
||||
5. We define an initialization function and register it with NODE_API_MODULE macro, which makes our module loadable by Node.js.
|
||||
|
||||
Now, let's create a JavaScript wrapper to make the addon easier to use. Create `js/index.js`:
|
||||
|
||||
```js title='js/index.js' @ts-expect-error=[5]
|
||||
const EventEmitter = require('events')
|
||||
|
||||
// Load the native addon using the 'bindings' module
|
||||
// This will look for the compiled .node file in various places
|
||||
const bindings = require('bindings')
|
||||
const native = bindings('my_addon')
|
||||
|
||||
// Create a nice JavaScript wrapper
|
||||
class MyNativeAddon extends EventEmitter {
|
||||
constructor () {
|
||||
super()
|
||||
|
||||
// Create an instance of our C++ class
|
||||
this.addon = new native.MyAddon()
|
||||
}
|
||||
|
||||
// Wrap the C++ method with a nicer JavaScript API
|
||||
helloWorld (input = '') {
|
||||
if (typeof input !== 'string') {
|
||||
throw new TypeError('Input must be a string')
|
||||
}
|
||||
return this.addon.helloWorld(input)
|
||||
}
|
||||
}
|
||||
|
||||
// Export a singleton instance
|
||||
if (process.platform === 'win32' || process.platform === 'darwin' || process.platform === 'linux') {
|
||||
module.exports = new MyNativeAddon()
|
||||
} else {
|
||||
// Provide a fallback for unsupported platforms
|
||||
console.warn('Native addon not supported on this platform')
|
||||
|
||||
module.exports = {
|
||||
helloWorld: (input) => `Hello from JS! You said: ${input}`
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
This JavaScript wrapper:
|
||||
|
||||
1. Uses `bindings` to load our compiled native addon
|
||||
1. Creates a class that extends EventEmitter (useful for future extensions that might emit events)
|
||||
1. Instantiates our C++ class and provides a simpler API
|
||||
1. Adds some input validation on the JavaScript side
|
||||
1. Exports a singleton instance of our wrapper
|
||||
1. Handles unsupported platforms gracefully
|
||||
|
||||
### Building and testing the addon
|
||||
|
||||
Now we can build our native addon:
|
||||
|
||||
```sh
|
||||
npm run build
|
||||
```
|
||||
|
||||
This will run `node-gyp configure` and `node-gyp build` to compile our C++ code into a `.node` file.
|
||||
Let's create a simple test script to verify everything works. Create `test.js` in the project root:
|
||||
|
||||
```js title='test.js' @ts-expect-error=[2]
|
||||
// Load our addon
|
||||
const myAddon = require('./js')
|
||||
|
||||
// Try the helloWorld function
|
||||
const result = myAddon.helloWorld('This is a test')
|
||||
|
||||
// Should print: "Hello from C++! You said: This is a test"
|
||||
console.log(result)
|
||||
```
|
||||
|
||||
Run the test:
|
||||
|
||||
```sh
|
||||
node test.js
|
||||
```
|
||||
|
||||
If everything works correctly, you should see:
|
||||
|
||||
```txt
|
||||
Hello from C++! You said: This is a test
|
||||
```
|
||||
|
||||
### Using the addon in Electron
|
||||
|
||||
To use this addon in an Electron application, you would:
|
||||
|
||||
1. Include it as a dependency in your Electron project
|
||||
1. Build it targeting your specific Electron version. `electron-forge` handles this step automatically for you - for more details, see [Native Node Modules](./using-native-node-modules.md).
|
||||
1. Import and use it just like any other module in a process that has Node.js enabled.
|
||||
|
||||
```js @ts-expect-error=[2]
|
||||
// In your main process
|
||||
const myAddon = require('my-native-addon')
|
||||
console.log(myAddon.helloWorld('Electron'))
|
||||
```
|
||||
|
||||
## References and further learning
|
||||
|
||||
Native addon development can be written in several languages beyond C++. Rust can be used with crates like [`napi-rs`](https://github.com/napi-rs/napi-rs), [`neon`](https://neon-rs.dev/), or [`node-bindgen`](https://github.com/infinyon/node-bindgen). Objective-C/Swift can be used through Objective-C++ on macOS.
|
||||
|
||||
The specific implementation details differ significantly by platform, especially when accessing platform-specific APIs or UI frameworks, like Windows' Win32 API, COM components, UWP/WinRT - or macOS's Cocoa, AppKit, or ObjectiveC runtime.
|
||||
|
||||
This means that you'll likely use two groups of references for your native code: First, on the Node.js side, use the [N-API documentation](https://nodejs.org/api/n-api.html) to learn about creating and exposing complex structures to JavaScript - like asynchronous thread-safe function calls or creating JavaScript-native objects (`error`, `promise`, etc). Secondly, on the side of the technology you're working with, you'll likely be looking at their lower-level documentation:
|
||||
|
||||
* [Microsoft C++, C, and Assembler documentation](https://learn.microsoft.com/en-us/cpp/?view=msvc-170)
|
||||
* [C++/WinRT](https://learn.microsoft.com/en-us/windows/uwp/cpp-and-winrt-apis/)
|
||||
* [MSVC-170 C++ Documentation](https://learn.microsoft.com/en-us/cpp/cpp/?view=msvc-170)
|
||||
* [Apple Developer Documentation](https://developer.apple.com/documentation)
|
||||
* [Programming with Objective-C](https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/Introduction/Introduction.html#//apple_ref/doc/uid/TP40011210)
|
||||
@@ -22,12 +22,9 @@ In `preload.js` use the [`contextBridge`][] to inject a method `window.electron.
|
||||
|
||||
```js
|
||||
const { contextBridge, ipcRenderer } = require('electron')
|
||||
const path = require('node:path')
|
||||
|
||||
contextBridge.exposeInMainWorld('electron', {
|
||||
startDrag: (fileName) => {
|
||||
ipcRenderer.send('ondragstart', path.join(process.cwd(), fileName))
|
||||
}
|
||||
startDrag: (fileName) => ipcRenderer.send('ondragstart', fileName)
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
@@ -69,8 +69,25 @@ if (navigationHistory.canGoToOffset(2)) {
|
||||
}
|
||||
```
|
||||
|
||||
## Restoring history
|
||||
|
||||
A common flow is that you want to restore the history of a webContents - for instance to implement an "undo close tab" feature. To do so, you can call `navigationHistory.restore({ index, entries })`. This will restore the webContent's navigation history and the webContents location in said history, meaning that `goBack()` and `goForward()` navigate you through the stack as expected.
|
||||
|
||||
```js @ts-type={navigationHistory:Electron.NavigationHistory}
|
||||
|
||||
const firstWindow = new BrowserWindow()
|
||||
|
||||
// Later, you want a second window to have the same history and navigation position
|
||||
async function restore () {
|
||||
const entries = firstWindow.webContents.navigationHistory.getAllEntries()
|
||||
const index = firstWindow.webContents.navigationHistory.getActiveIndex()
|
||||
|
||||
const secondWindow = new BrowserWindow()
|
||||
await secondWindow.webContents.navigationHistory.restore({ index, entries })
|
||||
}
|
||||
```
|
||||
|
||||
Here's a full example that you can open with Electron Fiddle:
|
||||
|
||||
```fiddle docs/fiddles/features/navigation-history
|
||||
|
||||
```
|
||||
|
||||
@@ -14,7 +14,7 @@ _Notes_:
|
||||
* There are two rendering modes that can be used (see the section below) and only
|
||||
the dirty area is passed to the `paint` event to be more efficient.
|
||||
* You can stop/continue the rendering as well as set the frame rate.
|
||||
* The maximum frame rate is 240 because greater values bring only performance
|
||||
* When `webPreferences.offscreen.useSharedTexture` is not `true`, the maximum frame rate is 240 because greater values bring only performance
|
||||
losses with no benefits.
|
||||
* When nothing is happening on a webpage, no frames are generated.
|
||||
* An offscreen window is always created as a
|
||||
@@ -36,7 +36,8 @@ setting.
|
||||
This is an advanced feature requiring a native node module to work with your own code.
|
||||
The frames are directly copied in GPU textures, thus this mode is very fast because
|
||||
there's no CPU-GPU memory copies overhead, and you can directly import the shared
|
||||
texture to your own rendering program.
|
||||
texture to your own rendering program. You can read more details at
|
||||
[here](https://github.com/electron/electron/blob/main/shell/browser/osr/README.md).
|
||||
|
||||
2. Use CPU shared memory bitmap
|
||||
|
||||
|
||||
@@ -57,10 +57,7 @@ Finally, create a `main.js` file for main process that creates the window.
|
||||
const { app, BrowserWindow } = require('electron')
|
||||
|
||||
const createWindow = () => {
|
||||
const onlineStatusWindow = new BrowserWindow({
|
||||
width: 400,
|
||||
height: 100
|
||||
})
|
||||
const onlineStatusWindow = new BrowserWindow()
|
||||
|
||||
onlineStatusWindow.loadFile('index.html')
|
||||
}
|
||||
|
||||
@@ -116,6 +116,7 @@ You should at least follow these steps to improve the security of your applicati
|
||||
17. [Validate the `sender` of all IPC messages](#17-validate-the-sender-of-all-ipc-messages)
|
||||
18. [Avoid usage of the `file://` protocol and prefer usage of custom protocols](#18-avoid-usage-of-the-file-protocol-and-prefer-usage-of-custom-protocols)
|
||||
19. [Check which fuses you can change](#19-check-which-fuses-you-can-change)
|
||||
20. [Do not expose Electron APIs to untrusted web content](#20-do-not-expose-electron-apis-to-untrusted-web-content)
|
||||
|
||||
To automate the detection of misconfigurations and insecure patterns, it is
|
||||
possible to use
|
||||
@@ -229,7 +230,7 @@ API to remotely loaded content via the [contextBridge API](../api/context-bridge
|
||||
### 3. Enable Context Isolation
|
||||
|
||||
:::info
|
||||
This recommendation is the default behavior in Electron since 12.0.0.
|
||||
Context Isolation is the default behavior in Electron since 12.0.0.
|
||||
:::
|
||||
|
||||
Context isolation is an Electron feature that allows developers to run code
|
||||
@@ -804,6 +805,48 @@ flipping these fuses easy. Check out the README of that module for more details
|
||||
potential error cases, and refer to
|
||||
[How do I flip the fuses?](./fuses.md#how-do-i-flip-the-fuses) in our documentation.
|
||||
|
||||
### 20. Do not expose Electron APIs to untrusted web content
|
||||
|
||||
You should not directly expose Electron's APIs, especially IPC, to untrusted web content in your
|
||||
preload scripts.
|
||||
|
||||
#### Why?
|
||||
|
||||
Exposing raw APIs like `ipcRenderer.on` is dangerous because it gives renderer processes direct
|
||||
access to the entire IPC event system, allowing them to listen for any IPC events, not just the ones
|
||||
intended for them.
|
||||
|
||||
To avoid that exposure, we also cannot pass callbacks directly through: The first
|
||||
argument to IPC event callbacks is an `IpcRendererEvent` object, which includes properties like `sender`
|
||||
that provide access to the underlying `ipcRenderer` instance. Even if you only listen for specific
|
||||
events, passing the callback directly means the renderer gets access to this event object.
|
||||
|
||||
In short, we want the untrusted web content to only have access to necessary information and APIs.
|
||||
|
||||
#### How?
|
||||
|
||||
```js title='preload'.js'
|
||||
// Bad
|
||||
contextBridge.exposeInMainWorld('electronAPI', {
|
||||
on: ipcRenderer.on
|
||||
})
|
||||
|
||||
// Also bad
|
||||
contextBridge.exposeInMainWorld('electronAPI', {
|
||||
onUpdateCounter: (callback) => ipcRenderer.on('update-counter', callback)
|
||||
})
|
||||
|
||||
// Good
|
||||
contextBridge.exposeInMainWorld('electronAPI', {
|
||||
onUpdateCounter: (callback) => ipcRenderer.on('update-counter', (_event, value) => callback(value))
|
||||
})
|
||||
```
|
||||
|
||||
:::info
|
||||
For more information on what `contextIsolation` is and how to use it to secure your app,
|
||||
please see the [Context Isolation](context-isolation.md) document.
|
||||
:::
|
||||
|
||||
[breaking-changes]: ../breaking-changes.md
|
||||
[browser-window]: ../api/browser-window.md
|
||||
[webview-tag]: ../api/webview-tag.md
|
||||
|
||||
@@ -252,7 +252,7 @@ apps often use the preload script to set up inter-process communication (IPC) in
|
||||
to pass arbitrary messages between the two kinds of processes.
|
||||
|
||||
In the next part of the tutorial, we will be showing you resources on adding more
|
||||
functionality to your app, then teaching you distributing your app to users.
|
||||
functionality to your app, then teaching you how to distribute your app to users.
|
||||
|
||||
<!-- Links -->
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import DocCardList from '@theme/DocCardList';
|
||||
|
||||
# Window Customization
|
||||
|
||||
The [`BrowserWindow`][] module is the foundation of your Electron application, and
|
||||
@@ -5,13 +7,15 @@ it exposes many APIs that let you customize the look and behavior of your app’
|
||||
This section covers how to implement various use cases for window customization on macOS,
|
||||
Windows, and Linux.
|
||||
|
||||
:::info
|
||||
`BrowserWindow` is a subclass of the [`BaseWindow`][] module. Both modules allow
|
||||
you to create and manage application windows in Electron, with the main difference
|
||||
being that `BrowserWindow` supports a single, full size web view while `BaseWindow`
|
||||
supports composing many web views. `BaseWindow` can be used interchangeably with `BrowserWindow`
|
||||
in the examples of the documents in this section.
|
||||
:::
|
||||
> [!NOTE]
|
||||
> `BrowserWindow` is a subclass of the [`BaseWindow`][] module. Both modules allow
|
||||
> you to create and manage application windows in Electron, with the main difference
|
||||
> being that `BrowserWindow` supports a single, full size web view while `BaseWindow`
|
||||
> supports composing many web views. `BaseWindow` can be used interchangeably with `BrowserWindow`
|
||||
> in the examples of the documents in this section.
|
||||
|
||||
<!-- markdownlint-disable-next-line MD033 -->
|
||||
<DocCardList />
|
||||
|
||||
[`BaseWindow`]: ../api/base-window.md
|
||||
[`BrowserWindow`]: ../api/browser-window.md
|
||||
|
||||
@@ -22,7 +22,7 @@ If you want to focus on building a great product without figuring out how you ca
|
||||
|
||||
### Reliability
|
||||
|
||||
Web technologies are the most-used foundation for user interfaces on the planet. The have been hardened accordingly. Modern computers have been optimized from the CPU to the operating system to be good at running web technologies. The manufacturers of your user’s devices—be that an Android phone or the latest MacBook—will ensure that they can visit websites, play videos on YouTube, or display emails. In turn, they’ll also ensure that your app has a stable foundation, even if you have just one user.
|
||||
Web technologies are the most-used foundation for user interfaces on the planet. They have been hardened accordingly. Modern computers have been optimized from the CPU to the operating system to be good at running web technologies. The manufacturers of your user’s devices—be that an Android phone or the latest MacBook—will ensure that they can visit websites, play videos on YouTube, or display emails. In turn, they’ll also ensure that your app has a stable foundation, even if you have just one user.
|
||||
|
||||
If you want to focus on building a great product without debugging a weird quirk that nobody has found before, the web is a safe bet.
|
||||
|
||||
|
||||
@@ -55,7 +55,6 @@ template("electron_extra_paks") {
|
||||
"$root_gen_dir/chrome/accessibility_resources.pak",
|
||||
"$root_gen_dir/chrome/browser_resources.pak",
|
||||
"$root_gen_dir/chrome/common_resources.pak",
|
||||
"$root_gen_dir/chrome/dev_ui_browser_resources.pak",
|
||||
"$root_gen_dir/components/components_resources.pak",
|
||||
"$root_gen_dir/content/browser/resources/media/media_internals_resources.pak",
|
||||
"$root_gen_dir/content/browser/tracing/tracing_resources.pak",
|
||||
@@ -69,7 +68,6 @@ template("electron_extra_paks") {
|
||||
"$target_gen_dir/electron_resources.pak",
|
||||
]
|
||||
deps = [
|
||||
"//chrome/browser:dev_ui_browser_resources",
|
||||
"//chrome/browser:resources",
|
||||
"//chrome/browser/resources/accessibility:resources",
|
||||
"//chrome/common:resources",
|
||||
@@ -178,7 +176,7 @@ template("electron_paks") {
|
||||
}
|
||||
|
||||
source_patterns = [
|
||||
"${root_gen_dir}/chrome/chromium_strings_",
|
||||
"${root_gen_dir}/chrome/branded_strings_",
|
||||
"${root_gen_dir}/chrome/locale_settings_",
|
||||
"${root_gen_dir}/chrome/platform_locale_settings_",
|
||||
"${root_gen_dir}/chrome/generated_resources_",
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user