mirror of
https://github.com/electron/electron.git
synced 2026-02-19 03:14:51 -05:00
Compare commits
133 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8608d442e3 | ||
|
|
137d4ec329 | ||
|
|
624d085632 | ||
|
|
600b6b3315 | ||
|
|
9e67bd3508 | ||
|
|
909fd3d55a | ||
|
|
f2429c31c1 | ||
|
|
fbb83be785 | ||
|
|
1eab19fc7c | ||
|
|
02f2feabe6 | ||
|
|
712262597d | ||
|
|
31bc5ca903 | ||
|
|
03a02fc31e | ||
|
|
5ef6897bc7 | ||
|
|
bc585b6a3f | ||
|
|
4c460df0a4 | ||
|
|
cf193b279b | ||
|
|
655037fbdf | ||
|
|
07338bb1cf | ||
|
|
fb0b77b731 | ||
|
|
499e987c77 | ||
|
|
f7138344d8 | ||
|
|
b9248e6782 | ||
|
|
af39dcfb09 | ||
|
|
d347632046 | ||
|
|
4f69c5835e | ||
|
|
fa15332587 | ||
|
|
e299a1d098 | ||
|
|
c2302960a8 | ||
|
|
5e862f398e | ||
|
|
61c245761c | ||
|
|
7c55b24be2 | ||
|
|
4af248f2b6 | ||
|
|
69e9b653ba | ||
|
|
4dccccadbb | ||
|
|
79cd6a2614 | ||
|
|
2ba8fe9140 | ||
|
|
b21c4b0f88 | ||
|
|
f50ad3d022 | ||
|
|
7a274a711c | ||
|
|
bc499ffb8a | ||
|
|
0a74e91580 | ||
|
|
035879357e | ||
|
|
e4c37e4b38 | ||
|
|
828fc84e60 | ||
|
|
51fbc964a6 | ||
|
|
3e8e87d186 | ||
|
|
498f4bc98c | ||
|
|
a6ad5a6e60 | ||
|
|
93d5152a25 | ||
|
|
fb65124234 | ||
|
|
93f4b3cf9f | ||
|
|
bb22eaccec | ||
|
|
90a14299fd | ||
|
|
60924690d9 | ||
|
|
9b158238dc | ||
|
|
dac5e0cd1a | ||
|
|
626895848e | ||
|
|
3536d4976a | ||
|
|
2ad762e075 | ||
|
|
6779769d22 | ||
|
|
96fcc2f8c8 | ||
|
|
3c9b8475a2 | ||
|
|
6f915e85e2 | ||
|
|
0259abe920 | ||
|
|
38fe14041d | ||
|
|
996945d3e3 | ||
|
|
d7ef8b79ae | ||
|
|
6aa3665b96 | ||
|
|
c964296ec3 | ||
|
|
6f48e3ab12 | ||
|
|
06bc59be88 | ||
|
|
0b84c68229 | ||
|
|
09a0926c5b | ||
|
|
6606230813 | ||
|
|
a42afaa866 | ||
|
|
b1f0ab11c5 | ||
|
|
4c3e2eb560 | ||
|
|
72340e79e8 | ||
|
|
7196a28d3a | ||
|
|
6c96979b6c | ||
|
|
5cbab906c9 | ||
|
|
2a51a997eb | ||
|
|
fbb3fa7503 | ||
|
|
c22f94037a | ||
|
|
ba7c3bbdf7 | ||
|
|
53fd879043 | ||
|
|
5f5e8d012d | ||
|
|
508c601996 | ||
|
|
158176f0f3 | ||
|
|
d1e64c37a2 | ||
|
|
17ba863f69 | ||
|
|
82a59d9894 | ||
|
|
55006fe9a8 | ||
|
|
dc5efca0f6 | ||
|
|
cf6c662702 | ||
|
|
c84e8c6c22 | ||
|
|
46921d3652 | ||
|
|
b303413a04 | ||
|
|
83524adf17 | ||
|
|
14b3183eb5 | ||
|
|
0d70389ccb | ||
|
|
4e61f5b26f | ||
|
|
5b5f900e34 | ||
|
|
2e0b4eca94 | ||
|
|
3a32f25750 | ||
|
|
f6b8ee0731 | ||
|
|
5ccbfa2faf | ||
|
|
f89c2a0ef4 | ||
|
|
c6f368acc6 | ||
|
|
5e3b5ef04c | ||
|
|
ac5e3c76f3 | ||
|
|
b9b96a96f7 | ||
|
|
2248de847d | ||
|
|
38e7ff944e | ||
|
|
8f09d7037b | ||
|
|
d0102ff392 | ||
|
|
274e1df1ca | ||
|
|
b2d0074cc6 | ||
|
|
2e8fc17f07 | ||
|
|
4af0c5d762 | ||
|
|
a7a3e10300 | ||
|
|
7b77a24211 | ||
|
|
7112c592c9 | ||
|
|
d6638f9564 | ||
|
|
9f8bcc4d98 | ||
|
|
21155679a0 | ||
|
|
211faed848 | ||
|
|
296e39456a | ||
|
|
a19198d784 | ||
|
|
263c76df09 | ||
|
|
517f5c15b9 | ||
|
|
d29293556d |
9
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
9
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
@@ -58,6 +58,15 @@ body:
|
||||
label: Last Known Working Electron version
|
||||
description: What is the last version of Electron this worked in, if applicable?
|
||||
placeholder: 16.0.0
|
||||
- type: dropdown
|
||||
attributes:
|
||||
label: Does the issue also appear in Chromium / Google Chrome?
|
||||
description: If it does, please report the issue in the [Chromium issue tracker](https://issues.chromium.org/issues), not against Electron. Electron will inherit the fix once Chromium resolves the issue.
|
||||
options:
|
||||
- "Yes"
|
||||
- "No"
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Expected Behavior
|
||||
|
||||
6
.github/actions/build-electron/action.yml
vendored
6
.github/actions/build-electron/action.yml
vendored
@@ -38,6 +38,9 @@ runs:
|
||||
run: |
|
||||
GN_APPENDED_ARGS="$GN_EXTRA_ARGS target_cpu=\"x64\" v8_snapshot_toolchain=\"//build/toolchain/mac:clang_x64\""
|
||||
echo "GN_EXTRA_ARGS=$GN_APPENDED_ARGS" >> $GITHUB_ENV
|
||||
- name: Add Clang problem matcher
|
||||
shell: bash
|
||||
run: echo "::add-matcher::src/electron/.github/problem-matchers/clang.json"
|
||||
- name: Build Electron ${{ inputs.step-suffix }}
|
||||
shell: bash
|
||||
run: |
|
||||
@@ -199,6 +202,9 @@ runs:
|
||||
e build --target electron:libcxx_headers_zip -j $NUMBER_OF_NINJA_PROCESSES
|
||||
e build --target electron:libcxxabi_headers_zip -j $NUMBER_OF_NINJA_PROCESSES
|
||||
e build --target electron:libcxx_objects_zip -j $NUMBER_OF_NINJA_PROCESSES
|
||||
- name: Remove Clang problem matcher
|
||||
shell: bash
|
||||
run: echo "::remove-matcher owner=clang::"
|
||||
- name: Generate TypeScript Definitions ${{ inputs.step-suffix }}
|
||||
if: ${{ inputs.is-release == 'true' }}
|
||||
shell: bash
|
||||
|
||||
83
.github/actions/build-git-cache/action.yml
vendored
Normal file
83
.github/actions/build-git-cache/action.yml
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
name: 'Build Git Cache'
|
||||
description: 'Runs a gclient sync to build the git cache for Electron'
|
||||
inputs:
|
||||
target-platform:
|
||||
description: 'Target platform, should be linux, win, macos'
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: Set GIT_CACHE_PATH to make gclient to use the cache
|
||||
shell: bash
|
||||
run: |
|
||||
echo "GIT_CACHE_PATH=$(pwd)/git-cache" >> $GITHUB_ENV
|
||||
- name: Set Chromium Git Cookie
|
||||
uses: ./src/electron/.github/actions/set-chromium-cookie
|
||||
- name: Install Build Tools
|
||||
uses: ./src/electron/.github/actions/install-build-tools
|
||||
- name: Set up cache drive
|
||||
shell: bash
|
||||
run: |
|
||||
if [ "${{ inputs.target-platform }}" = "win" ]; then
|
||||
echo "CACHE_DRIVE=/mnt/win-cache" >> $GITHUB_ENV
|
||||
else
|
||||
echo "CACHE_DRIVE=/mnt/cross-instance-cache" >> $GITHUB_ENV
|
||||
fi
|
||||
- name: Check cross instance cache disk space
|
||||
shell: bash
|
||||
run: |
|
||||
# if there is less than 35 GB free space then creating the cache might fail so exit early
|
||||
freespace=`df -m $CACHE_DRIVE | grep -w $CACHE_DRIVE | awk '{print $4}'`
|
||||
freespace_human=`df -h $CACHE_DRIVE | grep -w $CACHE_DRIVE | awk '{print $4}'`
|
||||
if [ $freespace -le 35000 ]; then
|
||||
echo "The cross mount cache has $freespace_human free space which is not enough - exiting"
|
||||
exit 1
|
||||
else
|
||||
echo "The cross mount cache has $freespace_human free space - continuing"
|
||||
fi
|
||||
- name: Restore gitcache
|
||||
shell: bash
|
||||
run: |
|
||||
GIT_CACHE_TAR="$CACHE_DRIVE/gitcache.tar"
|
||||
if [ ! -f "$GIT_CACHE_TAR" ]; then
|
||||
echo "Git cache tar file does not exist, skipping restore"
|
||||
exit 0
|
||||
fi
|
||||
echo "Restoring git cache from $GIT_CACHE_TAR to $GIT_CACHE_PATH"
|
||||
mkdir -p $GIT_CACHE_PATH
|
||||
tar -xf $GIT_CACHE_TAR -C $GIT_CACHE_PATH
|
||||
- name: Gclient Sync
|
||||
shell: bash
|
||||
run: |
|
||||
e d gclient config \
|
||||
--name "src/electron" \
|
||||
--unmanaged \
|
||||
${GCLIENT_EXTRA_ARGS} \
|
||||
"$GITHUB_SERVER_URL/$GITHUB_REPOSITORY"
|
||||
|
||||
if [ "$TARGET_OS" != "" ]; then
|
||||
echo "target_os=['$TARGET_OS']" >> ./.gclient
|
||||
fi
|
||||
|
||||
ELECTRON_USE_THREE_WAY_MERGE_FOR_PATCHES=1 e d gclient sync --with_branch_heads --with_tags --nohooks -vv
|
||||
- name: Compress Git Cache Directory
|
||||
shell: bash
|
||||
run: |
|
||||
echo "Uncompressed gitcache size: $(du -sh $GIT_CACHE_PATH | cut -f1 -d' ')"
|
||||
cd $GIT_CACHE_PATH
|
||||
tar -cf ../gitcache.tar .
|
||||
cd ..
|
||||
echo "Compressed gitcache to $(du -sh gitcache.tar | cut -f1 -d' ')"
|
||||
# remove the old cache file if it exists
|
||||
if [ -f $CACHE_DRIVE/gitcache.tar ]; then
|
||||
echo "Removing old gitcache.tar from $CACHE_DRIVE"
|
||||
rm $CACHE_DRIVE/gitcache.tar
|
||||
fi
|
||||
cp ./gitcache.tar $CACHE_DRIVE/
|
||||
- name: Wait for active SSH sessions
|
||||
shell: bash
|
||||
if: always() && !cancelled()
|
||||
run: |
|
||||
while [ -f /var/.ssh-lock ]
|
||||
do
|
||||
sleep 60
|
||||
done
|
||||
40
.github/actions/checkout/action.yml
vendored
40
.github/actions/checkout/action.yml
vendored
@@ -43,7 +43,7 @@ runs:
|
||||
curl --unix-socket /var/run/sas/sas.sock --fail "http://foo/$CACHE_FILE?platform=${{ inputs.target-platform }}" > sas-token
|
||||
- name: Save SAS Key
|
||||
if: ${{ inputs.generate-sas-token == 'true' }}
|
||||
uses: actions/cache/save@d4323d4df104b026a6aa633fdb11d772146be0bf
|
||||
uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
|
||||
with:
|
||||
path: sas-token
|
||||
key: sas-key-${{ inputs.target-platform }}-${{ github.run_number }}-${{ github.run_attempt }}
|
||||
@@ -80,6 +80,21 @@ runs:
|
||||
else
|
||||
echo "The cross mount cache has $freespace_human free space - continuing"
|
||||
fi
|
||||
- name: Add patch conflict problem matcher
|
||||
shell: bash
|
||||
run: echo "::add-matcher::src/electron/.github/problem-matchers/patch-conflict.json"
|
||||
- name: Restore gitcache
|
||||
if: steps.check-cache.outputs.cache_exists == 'false'
|
||||
shell: bash
|
||||
run: |
|
||||
GIT_CACHE_TAR="$CACHE_DRIVE/gitcache.tar"
|
||||
if [ ! -f "$GIT_CACHE_TAR" ]; then
|
||||
echo "Git cache tar file does not exist, skipping restore"
|
||||
exit 0
|
||||
fi
|
||||
echo "Restoring git cache from $GIT_CACHE_TAR to $GIT_CACHE_PATH"
|
||||
mkdir -p $GIT_CACHE_PATH
|
||||
tar -xf $GIT_CACHE_TAR -C $GIT_CACHE_PATH
|
||||
- name: Gclient Sync
|
||||
if: steps.check-cache.outputs.cache_exists == 'false'
|
||||
shell: bash
|
||||
@@ -102,12 +117,7 @@ runs:
|
||||
git update-index --refresh || true
|
||||
if ! git diff-index --quiet HEAD --; then
|
||||
# There are changes to the patches. Make a git commit with the updated patches
|
||||
git add patches
|
||||
GIT_COMMITTER_NAME="PatchUp" GIT_COMMITTER_EMAIL="73610968+patchup[bot]@users.noreply.github.com" git commit -m "chore: update patches" --author="PatchUp <73610968+patchup[bot]@users.noreply.github.com>"
|
||||
# Export it
|
||||
mkdir -p ../../patches
|
||||
git format-patch -1 --stdout --keep-subject --no-stat --full-index > ../../patches/update-patches.patch
|
||||
if node ./script/push-patch.js; then
|
||||
if node ./script/patch-up.js; then
|
||||
echo
|
||||
echo "======================================================================"
|
||||
echo "Changes to the patches when applying, we have auto-pushed the diff to the current branch"
|
||||
@@ -115,6 +125,11 @@ runs:
|
||||
echo "======================================================================"
|
||||
exit 1
|
||||
else
|
||||
git add patches
|
||||
GIT_COMMITTER_NAME="PatchUp" GIT_COMMITTER_EMAIL="73610968+patchup[bot]@users.noreply.github.com" git commit -m "chore: update patches" --author="PatchUp <73610968+patchup[bot]@users.noreply.github.com>"
|
||||
# Export it
|
||||
mkdir -p ../../patches
|
||||
git format-patch -1 --stdout --keep-subject --no-stat --full-index > ../../patches/update-patches.patch
|
||||
echo
|
||||
echo "======================================================================"
|
||||
echo "There were changes to the patches when applying."
|
||||
@@ -128,7 +143,16 @@ runs:
|
||||
echo "No changes to patches detected"
|
||||
fi
|
||||
fi
|
||||
|
||||
- name: Remove patch conflict problem matcher
|
||||
shell: bash
|
||||
run: |
|
||||
echo "::remove-matcher owner=merge-conflict::"
|
||||
echo "::remove-matcher owner=patch-conflict::"
|
||||
- name: Upload patches stats
|
||||
if: ${{ inputs.target-platform == 'linux' && github.ref == 'refs/heads/main' }}
|
||||
shell: bash
|
||||
run: |
|
||||
npx node src/electron/script/patches-stats.mjs --upload-stats || true
|
||||
# delete all .git directories under src/ except for
|
||||
# third_party/angle/ and third_party/dawn/ because of build time generation of files
|
||||
# gen/angle/commit.h depends on third_party/angle/.git/HEAD
|
||||
|
||||
11
.github/actions/free-space-macos/action.yml
vendored
11
.github/actions/free-space-macos/action.yml
vendored
@@ -57,8 +57,19 @@ runs:
|
||||
sudo rm -rf $TMPDIR/del-target
|
||||
|
||||
sudo rm -rf /Applications/Safari.app
|
||||
sudo rm -rf /Applications/Xcode_16.1.app
|
||||
sudo rm -rf /Applications/Xcode_16.3.app
|
||||
sudo rm -rf /Applications/Xcode_16.2.app
|
||||
sudo rm -rf /Applications/Google Chrome.app
|
||||
sudo rm -rf /Applications/Xcode_16.4.app
|
||||
sudo rm -rf /Applications/Google Chrome for Testing.app
|
||||
sudo rm -rf /Applications/Firefox.app
|
||||
sudo rm -rf ~/project/src/third_party/catapult/tracing/test_data
|
||||
sudo rm -rf ~/project/src/third_party/angle/third_party/VK-GL-CTS
|
||||
sudo rm -rf /Users/runner/Library/Android
|
||||
sudo rm -rf $JAVA_HOME_11_arm64
|
||||
sudo rm -rf $JAVA_HOME_17_arm64
|
||||
sudo rm -rf $JAVA_HOME_21_arm64
|
||||
|
||||
# lipo off some huge binaries arm64 versions to save space
|
||||
strip_universal_deep $(xcode-select -p)/../SharedFrameworks
|
||||
|
||||
14
.github/actions/install-build-tools/action.yml
vendored
14
.github/actions/install-build-tools/action.yml
vendored
@@ -11,15 +11,21 @@ runs:
|
||||
git config --global core.autocrlf false
|
||||
git config --global branch.autosetuprebase always
|
||||
git config --global core.fscache true
|
||||
git config --global core.longpaths true
|
||||
git config --global core.preloadindex true
|
||||
fi
|
||||
export BUILD_TOOLS_SHA=6e8526315ea3b4828882497e532b8340e64e053c
|
||||
export BUILD_TOOLS_SHA=0a7f6bef9453ceee45612442660ca16d2c40171b
|
||||
npm i -g @electron/build-tools
|
||||
# Update depot_tools to ensure python
|
||||
e d update_depot_tools
|
||||
e auto-update disable
|
||||
# Disable further updates of depot_tools
|
||||
e d auto-update disable
|
||||
if [ "$(expr substr $(uname -s) 1 10)" == "MSYS_NT-10" ]; then
|
||||
e d cipd.bat --version
|
||||
cp "C:\Python311\python.exe" "C:\Python311\python3.exe"
|
||||
fi
|
||||
echo "$HOME/.electron_build_tools/third_party/depot_tools" >> $GITHUB_PATH
|
||||
echo "$HOME/.electron_build_tools/third_party/depot_tools/python-bin" >> $GITHUB_PATH
|
||||
echo "C:\Users\ContainerAdministrator\.electron_build_tools\third_party\depot_tools" >> $GITHUB_PATH
|
||||
else
|
||||
echo "$HOME/.electron_build_tools/third_party/depot_tools" >> $GITHUB_PATH
|
||||
echo "$HOME/.electron_build_tools/third_party/depot_tools/python-bin" >> $GITHUB_PATH
|
||||
fi
|
||||
@@ -7,7 +7,7 @@ runs:
|
||||
shell: bash
|
||||
id: yarn-cache-dir-path
|
||||
run: echo "dir=$(node src/electron/script/yarn cache dir)" >> $GITHUB_OUTPUT
|
||||
- uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57
|
||||
- uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
|
||||
id: yarn-cache
|
||||
with:
|
||||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
||||
|
||||
@@ -8,14 +8,14 @@ runs:
|
||||
steps:
|
||||
- name: Obtain SAS Key
|
||||
continue-on-error: true
|
||||
uses: actions/cache/restore@d4323d4df104b026a6aa633fdb11d772146be0bf
|
||||
uses: actions/cache/restore@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
|
||||
with:
|
||||
path: sas-token
|
||||
key: sas-key-${{ inputs.target-platform }}-${{ github.run_number }}-1
|
||||
enableCrossOsArchive: true
|
||||
- name: Obtain SAS Key
|
||||
continue-on-error: true
|
||||
uses: actions/cache/restore@d4323d4df104b026a6aa633fdb11d772146be0bf
|
||||
uses: actions/cache/restore@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
|
||||
with:
|
||||
path: sas-token
|
||||
key: sas-key-${{ inputs.target-platform }}-${{ github.run_number }}-${{ github.run_attempt }}
|
||||
@@ -32,7 +32,7 @@ runs:
|
||||
shell: bash
|
||||
command: |
|
||||
sas_token=$(cat sas-token)
|
||||
if [ -z $sas-token ]; then
|
||||
if [ -z "$sas_token" ]; then
|
||||
echo "SAS Token not found; exiting src cache download early..."
|
||||
exit 1
|
||||
else
|
||||
@@ -96,7 +96,7 @@ runs:
|
||||
|
||||
$TEMP_DIR=New-Item -ItemType Directory -Path temp-cache
|
||||
$TEMP_DIR_PATH = $TEMP_DIR.FullName
|
||||
C:\ProgramData\Chocolatey\bin\7z.exe -y x $src_cache -o"$TEMP_DIR_PATH"
|
||||
C:\ProgramData\Chocolatey\bin\7z.exe -y -snld x $src_cache -o"$TEMP_DIR_PATH"
|
||||
|
||||
- name: Move Src Cache (Windows)
|
||||
if: ${{ inputs.target-platform == 'win' }}
|
||||
|
||||
18
.github/problem-matchers/clang.json
vendored
Normal file
18
.github/problem-matchers/clang.json
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"problemMatcher": [
|
||||
{
|
||||
"owner": "clang",
|
||||
"fromPath": "src/out/Default/args.gn",
|
||||
"pattern": [
|
||||
{
|
||||
"regexp": "^(.+)[(:](\\d+)[:,](\\d+)\\)?:\\s+(warning|error):\\s+(.*)$",
|
||||
"file": 1,
|
||||
"line": 2,
|
||||
"column": 3,
|
||||
"severity": 4,
|
||||
"message": 5
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
22
.github/problem-matchers/eslint-stylish.json
vendored
Normal file
22
.github/problem-matchers/eslint-stylish.json
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"problemMatcher": [
|
||||
{
|
||||
"owner": "eslint-stylish",
|
||||
"pattern": [
|
||||
{
|
||||
"regexp": "^\\s*([^\\s].*)$",
|
||||
"file": 1
|
||||
},
|
||||
{
|
||||
"regexp": "^\\s+(\\d+):(\\d+)\\s+(error|warning|info)\\s+(.*)\\s\\s+(.*)$",
|
||||
"line": 1,
|
||||
"column": 2,
|
||||
"severity": 3,
|
||||
"message": 4,
|
||||
"code": 5,
|
||||
"loop": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
24
.github/problem-matchers/patch-conflict.json
vendored
Normal file
24
.github/problem-matchers/patch-conflict.json
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"problemMatcher": [
|
||||
{
|
||||
"owner": "merge-conflict",
|
||||
"pattern": [
|
||||
{
|
||||
"regexp": "^CONFLICT\\s\\(\\S+\\): (Merge conflict in \\S+)$",
|
||||
"message": 1
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"owner": "patch-conflict",
|
||||
"pattern": [
|
||||
{
|
||||
"regexp": "^error: (patch failed: (\\S+):(\\d+))$",
|
||||
"message": 1,
|
||||
"file": 2,
|
||||
"line": 3
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
149
.github/workflows/audit-branch-ci.yml
vendored
Normal file
149
.github/workflows/audit-branch-ci.yml
vendored
Normal file
@@ -0,0 +1,149 @@
|
||||
name: Audit CI on Branches
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
# Run every 2 hours
|
||||
- cron: '0 */2 * * *'
|
||||
|
||||
permissions: {}
|
||||
|
||||
jobs:
|
||||
audit_branch_ci:
|
||||
name: Audit CI on Branches
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
steps:
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
||||
with:
|
||||
node-version: 22.17.x
|
||||
- run: npm install @actions/cache@4.0.3 @electron/fiddle-core@2.0.1
|
||||
- uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
|
||||
id: audit-errors
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
script: |
|
||||
const cache = require('@actions/cache');
|
||||
const { ElectronVersions } = require('@electron/fiddle-core');
|
||||
|
||||
const runsWithErrors = [];
|
||||
|
||||
// Only want the most recent workflow run that wasn't skipped or cancelled
|
||||
const isValidWorkflowRun = (run) => !['skipped', 'cancelled'].includes(run.conclusion);
|
||||
|
||||
const versions = await ElectronVersions.create({ ignoreCache: true });
|
||||
const branches = versions.supportedMajors.map((branch) => `${branch}-x-y`);
|
||||
|
||||
for (const branch of ["main", ...branches]) {
|
||||
const latestCheckRuns = new Map();
|
||||
const allCheckRuns = await github.paginate(github.rest.checks.listForRef, {
|
||||
owner: "electron",
|
||||
repo: "electron",
|
||||
ref: branch,
|
||||
status: 'completed',
|
||||
});
|
||||
|
||||
// Sort the check runs by completed_at so that multiple check runs on the
|
||||
// same ref (like a scheduled workflow) only looks at the most recent one
|
||||
for (const checkRun of allCheckRuns.filter(
|
||||
(run) => !['skipped', 'cancelled'].includes(run.conclusion),
|
||||
).sort((a, b) => new Date(b.completed_at) - new Date(a.completed_at))) {
|
||||
if (!latestCheckRuns.has(checkRun.name)) {
|
||||
latestCheckRuns.set(checkRun.name, checkRun);
|
||||
}
|
||||
}
|
||||
|
||||
// Check for runs which had error annotations
|
||||
for (const checkRun of Array.from(latestCheckRuns.values())) {
|
||||
if (checkRun.name === "Audit CI on Branches") {
|
||||
continue; // Skip the audit workflow itself
|
||||
}
|
||||
|
||||
const annotations = (await github.rest.checks.listAnnotations({
|
||||
owner: "electron",
|
||||
repo: "electron",
|
||||
check_run_id: checkRun.id,
|
||||
})).data ?? [];
|
||||
|
||||
if (
|
||||
annotations.find(
|
||||
({ annotation_level, message }) =>
|
||||
annotation_level === "failure" &&
|
||||
!message.startsWith("Process completed with exit code") &&
|
||||
!message.startsWith("Response status code does not indicate success") &&
|
||||
!/Unable to make request/.test(message) &&
|
||||
!/The requested URL returned error/.test(message),
|
||||
)
|
||||
) {
|
||||
checkRun.hasErrorAnnotations = true;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check if this is a known failure from a previous audit run
|
||||
const cacheKey = `check-run-error-annotations-${checkRun.id}`;
|
||||
const cacheHit =
|
||||
(await cache.restoreCache(['/dev/null'], cacheKey, undefined, {
|
||||
lookupOnly: true,
|
||||
})) !== undefined;
|
||||
|
||||
if (cacheHit) {
|
||||
checkRun.isStale = true;
|
||||
}
|
||||
|
||||
checkRun.branch = branch;
|
||||
runsWithErrors.push(checkRun);
|
||||
|
||||
// Create a cache entry (only the name matters) to keep track of
|
||||
// failures we've seen from previous runs to mark them as stale
|
||||
if (!cacheHit) {
|
||||
await cache.saveCache(['/dev/null'], cacheKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (runsWithErrors.length > 0) {
|
||||
core.summary.addHeading('⚠️ Runs with Errors');
|
||||
core.summary.addTable([
|
||||
[
|
||||
{ data: 'Branch', header: true },
|
||||
{ data: 'Workflow Run', header: true },
|
||||
{ data: 'Status', header: true },
|
||||
],
|
||||
...runsWithErrors
|
||||
.sort(
|
||||
(a, b) =>
|
||||
a.branch.localeCompare(b.branch) ||
|
||||
a.name.localeCompare(b.name),
|
||||
)
|
||||
.map((run) => [
|
||||
run.branch,
|
||||
`<a href="${run.html_url}">${run.name}</a>`,
|
||||
run.isStale
|
||||
? '📅 Stale'
|
||||
: run.hasErrorAnnotations
|
||||
? '⚠️ Errors'
|
||||
: '✅ Succeeded',
|
||||
]),
|
||||
]);
|
||||
|
||||
// Set this as failed so it's easy to scan runs to find failures
|
||||
if (runsWithErrors.find((run) => !run.isStale)) {
|
||||
core.setOutput('errorsFound', true);
|
||||
process.exitCode = 1;
|
||||
}
|
||||
} else {
|
||||
core.summary.addRaw('🎉 No runs with errors');
|
||||
}
|
||||
|
||||
await core.summary.write();
|
||||
- name: Send Slack message if errors
|
||||
if: ${{ always() && steps.audit-errors.outputs.errorsFound && github.ref == 'refs/heads/main' }}
|
||||
uses: slackapi/slack-github-action@b0fa283ad8fea605de13dc3f449259339835fc52 # v2.1.0
|
||||
with:
|
||||
payload: |
|
||||
link: "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
|
||||
webhook: ${{ secrets.CI_ERRORS_SLACK_WEBHOOK_URL }}
|
||||
webhook-type: webhook-trigger
|
||||
74
.github/workflows/build-git-cache.yml
vendored
Normal file
74
.github/workflows/build-git-cache.yml
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
name: Build Git Cache
|
||||
# This workflow updates git cache on the cross-instance cache volumes
|
||||
# It runs daily at midnight.
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: "0 0 * * *"
|
||||
|
||||
jobs:
|
||||
build-git-cache-linux:
|
||||
runs-on: electron-arc-linux-amd64-32core
|
||||
container:
|
||||
image: ghcr.io/electron/build:bc2f48b2415a670de18d13605b1cf0eb5fdbaae1
|
||||
options: --user root
|
||||
volumes:
|
||||
- /mnt/cross-instance-cache:/mnt/cross-instance-cache
|
||||
env:
|
||||
CHROMIUM_GIT_COOKIE: ${{ secrets.CHROMIUM_GIT_COOKIE }}
|
||||
GCLIENT_EXTRA_ARGS: '--custom-var=checkout_arm=True --custom-var=checkout_arm64=True'
|
||||
steps:
|
||||
- name: Checkout Electron
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
|
||||
with:
|
||||
path: src/electron
|
||||
fetch-depth: 0
|
||||
- name: Build Git Cache
|
||||
uses: ./src/electron/.github/actions/build-git-cache
|
||||
with:
|
||||
target-platform: linux
|
||||
|
||||
build-git-cache-windows:
|
||||
runs-on: electron-arc-linux-amd64-32core
|
||||
container:
|
||||
image: ghcr.io/electron/build:bc2f48b2415a670de18d13605b1cf0eb5fdbaae1
|
||||
options: --user root --device /dev/fuse --cap-add SYS_ADMIN
|
||||
volumes:
|
||||
- /mnt/win-cache:/mnt/win-cache
|
||||
env:
|
||||
CHROMIUM_GIT_COOKIE: ${{ secrets.CHROMIUM_GIT_COOKIE }}
|
||||
GCLIENT_EXTRA_ARGS: '--custom-var=checkout_win=True'
|
||||
TARGET_OS: 'win'
|
||||
steps:
|
||||
- name: Checkout Electron
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
|
||||
with:
|
||||
path: src/electron
|
||||
fetch-depth: 0
|
||||
- name: Build Git Cache
|
||||
uses: ./src/electron/.github/actions/build-git-cache
|
||||
with:
|
||||
target-platform: win
|
||||
|
||||
build-git-cache-macos:
|
||||
runs-on: electron-arc-linux-amd64-32core
|
||||
# This job updates the same git cache as linux, so it needs to run after the linux one.
|
||||
needs: build-git-cache-linux
|
||||
container:
|
||||
image: ghcr.io/electron/build:bc2f48b2415a670de18d13605b1cf0eb5fdbaae1
|
||||
options: --user root
|
||||
volumes:
|
||||
- /mnt/cross-instance-cache:/mnt/cross-instance-cache
|
||||
env:
|
||||
CHROMIUM_GIT_COOKIE: ${{ secrets.CHROMIUM_GIT_COOKIE }}
|
||||
GCLIENT_EXTRA_ARGS: '--custom-var=checkout_mac=True --custom-var=host_os=mac'
|
||||
steps:
|
||||
- name: Checkout Electron
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
|
||||
with:
|
||||
path: src/electron
|
||||
fetch-depth: 0
|
||||
- name: Build Git Cache
|
||||
uses: ./src/electron/.github/actions/build-git-cache
|
||||
with:
|
||||
target-platform: macos
|
||||
3
.github/workflows/build.yml
vendored
3
.github/workflows/build.yml
vendored
@@ -129,6 +129,7 @@ jobs:
|
||||
- /var/run/sas:/var/run/sas
|
||||
env:
|
||||
CHROMIUM_GIT_COOKIE: ${{ secrets.CHROMIUM_GIT_COOKIE }}
|
||||
DD_API_KEY: ${{ secrets.DD_API_KEY }}
|
||||
GCLIENT_EXTRA_ARGS: '--custom-var=checkout_arm=True --custom-var=checkout_arm64=True'
|
||||
PATCH_UP_APP_CREDS: ${{ secrets.PATCH_UP_APP_CREDS }}
|
||||
outputs:
|
||||
@@ -142,6 +143,8 @@ jobs:
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
- name: Checkout & Sync & Save
|
||||
uses: ./src/electron/.github/actions/checkout
|
||||
with:
|
||||
target-platform: linux
|
||||
|
||||
checkout-windows:
|
||||
needs: setup
|
||||
|
||||
17
.github/workflows/issue-opened.yml
vendored
17
.github/workflows/issue-opened.yml
vendored
@@ -60,6 +60,8 @@ jobs:
|
||||
// It's possible for multiple versions to be listed -
|
||||
// for now check for comma or space separated version.
|
||||
const versions = electronVersion.split(/, | /);
|
||||
let hasSupportedVersion = false;
|
||||
|
||||
for (const version of versions) {
|
||||
const major = semver.coerce(version, { loose: true })?.major;
|
||||
if (major) {
|
||||
@@ -75,19 +77,20 @@ jobs:
|
||||
labelExists = true;
|
||||
} catch {}
|
||||
|
||||
if (labelExists) {
|
||||
// Check if it's an unsupported major
|
||||
const { ElectronVersions } = await import('${{ github.workspace }}/node_modules/@electron/fiddle-core/dist/index.js');
|
||||
const versions = await ElectronVersions.create(undefined, { ignoreCache: true });
|
||||
const { ElectronVersions } = await import('${{ github.workspace }}/node_modules/@electron/fiddle-core/dist/index.js');
|
||||
const electronVersions = await ElectronVersions.create(undefined, { ignoreCache: true });
|
||||
const validVersions = [...electronVersions.supportedMajors, ...electronVersions.prereleaseMajors];
|
||||
|
||||
const validVersions = [...versions.supportedMajors, ...versions.prereleaseMajors];
|
||||
if (validVersions.includes(major)) {
|
||||
if (validVersions.includes(major)) {
|
||||
hasSupportedVersion = true;
|
||||
if (labelExists) {
|
||||
labels.push(versionLabel);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (labels.length === 0) {
|
||||
|
||||
if (!hasSupportedVersion) {
|
||||
core.setOutput('unsupportedMajor', true);
|
||||
labels.push('blocked/need-info ❌');
|
||||
}
|
||||
|
||||
3
.github/workflows/pipeline-electron-lint.yml
vendored
3
.github/workflows/pipeline-electron-lint.yml
vendored
@@ -61,6 +61,9 @@ jobs:
|
||||
curl -sL "https://chromium.googlesource.com/chromium/src/+/${chromium_revision}/buildtools/DEPS?format=TEXT" | base64 -d > src/buildtools/DEPS
|
||||
|
||||
gclient sync --spec="solutions=[{'name':'src/buildtools','url':None,'deps_file':'DEPS','custom_vars':{'process_deps':True},'managed':False}]"
|
||||
- name: Add ESLint problem matcher
|
||||
shell: bash
|
||||
run: echo "::add-matcher::src/electron/.github/problem-matchers/eslint-stylish.json"
|
||||
- name: Run Lint
|
||||
shell: bash
|
||||
run: |
|
||||
|
||||
@@ -135,6 +135,7 @@ jobs:
|
||||
git config --global core.autocrlf false
|
||||
git config --global branch.autosetuprebase always
|
||||
git config --global core.fscache true
|
||||
git config --global core.longpaths true
|
||||
git config --global core.preloadindex true
|
||||
git clone --filter=tree:0 https://chromium.googlesource.com/chromium/tools/depot_tools.git
|
||||
# Ensure depot_tools does not update.
|
||||
|
||||
4
.github/workflows/scorecards.yml
vendored
4
.github/workflows/scorecards.yml
vendored
@@ -28,7 +28,7 @@ jobs:
|
||||
|
||||
# This is a pre-submit / pre-release.
|
||||
- name: "Run analysis"
|
||||
uses: ossf/scorecard-action@f49aabe0b5af0936a0987cfb85d86b75731b0186 # v2.4.1
|
||||
uses: ossf/scorecard-action@05b42c624433fc40578a4040d5cf5e36ddca8cde # v2.4.2
|
||||
with:
|
||||
results_file: results.sarif
|
||||
results_format: 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@45775bd8235c68ba998cffa5171334d58593da47 # v3.28.15
|
||||
uses: github/codeql-action/upload-sarif@181d5eefc20863364f96762470ba6f862bdef56b # v3.29.2
|
||||
with:
|
||||
sarif_file: results.sarif
|
||||
|
||||
2
.github/workflows/stale.yml
vendored
2
.github/workflows/stale.yml
vendored
@@ -27,7 +27,7 @@ jobs:
|
||||
This issue has been automatically marked as stale. **If this issue is still affecting you, please leave any comment** (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the [latest version of Electron](https://www.electronjs.org/releases/stable) or in the [beta](https://www.electronjs.org/releases/beta)—please include it with your comment!
|
||||
close-issue-message: >
|
||||
This issue has been closed due to inactivity, and will not be monitored. If this is a bug and you can reproduce this issue on a [supported version of Electron](https://www.electronjs.org/docs/latest/tutorial/electron-timelines#timeline) please open a new issue and include instructions for reproducing the issue.
|
||||
exempt-issue-labels: "discussion,security \U0001F512,enhancement :sparkles:,status/confirmed,stale-exempt"
|
||||
exempt-issue-labels: "discussion,security \U0001F512,enhancement :sparkles:,status/confirmed,stale-exempt,upgrade-follow-up"
|
||||
only-pr-labels: not-a-real-label
|
||||
pending-repro:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
@@ -1,4 +1 @@
|
||||
#!/bin/sh
|
||||
. "$(dirname "$0")/_/husky.sh"
|
||||
|
||||
npm run precommit
|
||||
@@ -1,4 +1 @@
|
||||
#!/bin/sh
|
||||
. "$(dirname "$0")/_/husky.sh"
|
||||
|
||||
npm run prepack
|
||||
|
||||
4
BUILD.gn
4
BUILD.gn
@@ -38,8 +38,8 @@ if (is_mac) {
|
||||
import("build/rules.gni")
|
||||
|
||||
assert(
|
||||
mac_deployment_target == "11.0",
|
||||
"Chromium has updated the mac_deployment_target, please update this assert, update the supported versions documentation (docs/tutorial/support.md) and flag this as a breaking change")
|
||||
mac_deployment_target == "12.0",
|
||||
"Chromium has updated the mac_deployment_target, please update this assert and flag this as a breaking change (docs/breaking-changes.md)")
|
||||
}
|
||||
|
||||
if (is_linux) {
|
||||
|
||||
6
DEPS
6
DEPS
@@ -2,9 +2,9 @@ gclient_gn_args_from = 'src'
|
||||
|
||||
vars = {
|
||||
'chromium_version':
|
||||
'138.0.7178.0',
|
||||
'140.0.7261.0',
|
||||
'node_version':
|
||||
'v22.15.1',
|
||||
'v22.17.0',
|
||||
'nan_version':
|
||||
'e14bdcd1f72d62bca1d541b66da43130384ec213',
|
||||
'squirrel.mac_version':
|
||||
@@ -31,7 +31,7 @@ vars = {
|
||||
'sysroots_json_path': 'electron/script/sysroots.json',
|
||||
|
||||
# KEEP IN SYNC WITH utils.js FILE
|
||||
'yarn_version': '1.15.2',
|
||||
'yarn_version': '1.22.22',
|
||||
|
||||
# To be able to build clean Chromium from sources.
|
||||
'apply_patches': True,
|
||||
|
||||
14
README.md
14
README.md
@@ -44,29 +44,17 @@ Each Electron release provides binaries for macOS, Windows, and Linux.
|
||||
* Fedora 32 and newer
|
||||
* Debian 10 and newer
|
||||
|
||||
## Quick start & Electron Fiddle
|
||||
## Electron Fiddle
|
||||
|
||||
Use [`Electron Fiddle`](https://github.com/electron/fiddle)
|
||||
to build, run, and package small Electron experiments, to see code examples for all of Electron's APIs, and
|
||||
to try out different versions of Electron. It's designed to make the start of your journey with
|
||||
Electron easier.
|
||||
|
||||
Alternatively, clone and run the
|
||||
[electron/electron-quick-start](https://github.com/electron/electron-quick-start)
|
||||
repository to see a minimal Electron app in action:
|
||||
|
||||
```sh
|
||||
git clone https://github.com/electron/electron-quick-start
|
||||
cd electron-quick-start
|
||||
npm install
|
||||
npm start
|
||||
```
|
||||
|
||||
## Resources for learning Electron
|
||||
|
||||
* [electronjs.org/docs](https://electronjs.org/docs) - All of Electron's documentation
|
||||
* [electron/fiddle](https://github.com/electron/fiddle) - A tool to build, run, and package small Electron experiments
|
||||
* [electron/electron-quick-start](https://github.com/electron/electron-quick-start) - A very basic starter Electron app
|
||||
* [electronjs.org/community#boilerplates](https://electronjs.org/community#boilerplates) - Sample starter apps created by the community
|
||||
|
||||
## Programmatic usage
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"plugins": [
|
||||
"unicorn"
|
||||
"import"
|
||||
],
|
||||
"rules": {
|
||||
"unicorn/prefer-node-protocol": "error"
|
||||
"import/enforce-node-protocol-usage": ["error", "always"]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 = 136
|
||||
node_module_version = 139
|
||||
|
||||
v8_promise_internal_field_count = 1
|
||||
v8_embedder_string = "-electron.0"
|
||||
@@ -73,3 +73,7 @@ enterprise_cloud_content_analysis = false
|
||||
# TODO: remove dependency on legacy ipc
|
||||
# https://issues.chromium.org/issues/40943039
|
||||
content_enable_legacy_ipc = true
|
||||
|
||||
# Disable siso until we are ready to use it.
|
||||
# https://chromium-review.googlesource.com/c/chromium/src/+/6638830
|
||||
use_siso = false
|
||||
|
||||
21
build/siso/backend.star
Normal file
21
build/siso/backend.star
Normal file
@@ -0,0 +1,21 @@
|
||||
# -*- bazel-starlark -*-
|
||||
|
||||
load("@builtin//struct.star", "module")
|
||||
|
||||
def __platform_properties(ctx):
|
||||
container_image = "docker://gcr.io/chops-public-images-prod/rbe/siso-chromium/linux@sha256:ef35d347f4a4a2d32b76fd908e66e96f59bf8ba7379fd5626548244c45343b2b"
|
||||
return {
|
||||
"default": {
|
||||
"OSFamily": "Linux",
|
||||
"container-image": container_image,
|
||||
},
|
||||
"large": {
|
||||
"OSFamily": "Linux",
|
||||
"container-image": container_image,
|
||||
},
|
||||
}
|
||||
|
||||
backend = module(
|
||||
"backend",
|
||||
platform_properties = __platform_properties,
|
||||
)
|
||||
@@ -66,6 +66,8 @@ static_library("chrome") {
|
||||
"//chrome/browser/picture_in_picture/picture_in_picture_occlusion_tracker.h",
|
||||
"//chrome/browser/picture_in_picture/picture_in_picture_occlusion_tracker_observer.cc",
|
||||
"//chrome/browser/picture_in_picture/picture_in_picture_occlusion_tracker_observer.h",
|
||||
"//chrome/browser/picture_in_picture/picture_in_picture_widget_fade_animator.cc",
|
||||
"//chrome/browser/picture_in_picture/picture_in_picture_widget_fade_animator.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",
|
||||
@@ -142,8 +144,14 @@ static_library("chrome") {
|
||||
"//chrome/browser/ui/views/overlay/toggle_camera_button.h",
|
||||
"//chrome/browser/ui/views/overlay/toggle_microphone_button.cc",
|
||||
"//chrome/browser/ui/views/overlay/toggle_microphone_button.h",
|
||||
"//chrome/browser/ui/views/overlay/video_overlay_window_native_widget_mac.h",
|
||||
"//chrome/browser/ui/views/overlay/video_overlay_window_native_widget_mac.mm",
|
||||
"//chrome/browser/ui/views/overlay/video_overlay_window_views.cc",
|
||||
"//chrome/browser/ui/views/overlay/video_overlay_window_views.h",
|
||||
"//chrome/browser/ui/views/picture_in_picture/picture_in_picture_bounds_change_animation.cc",
|
||||
"//chrome/browser/ui/views/picture_in_picture/picture_in_picture_bounds_change_animation.h",
|
||||
"//chrome/browser/ui/views/picture_in_picture/picture_in_picture_tucker.cc",
|
||||
"//chrome/browser/ui/views/picture_in_picture/picture_in_picture_tucker.h",
|
||||
"//chrome/browser/ui/webui/accessibility/accessibility_ui.cc",
|
||||
"//chrome/browser/ui/webui/accessibility/accessibility_ui.h",
|
||||
"//chrome/browser/usb/usb_blocklist.cc",
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"plugins": [
|
||||
"unicorn"
|
||||
"import"
|
||||
],
|
||||
"rules": {
|
||||
"unicorn/prefer-node-protocol": "error"
|
||||
"import/enforce-node-protocol-usage": ["error", "always"]
|
||||
}
|
||||
}
|
||||
|
||||
35
docs/.eslintrc.json
Normal file
35
docs/.eslintrc.json
Normal file
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"extends": "standard",
|
||||
"plugins": [
|
||||
"import",
|
||||
"markdown"
|
||||
],
|
||||
"overrides": [
|
||||
{
|
||||
"files": ["*.md", "**/*.md"],
|
||||
"processor": "markdown/markdown"
|
||||
}
|
||||
],
|
||||
"rules": {
|
||||
"@typescript-eslint/no-unused-vars": "off",
|
||||
"import/order": ["error", {
|
||||
"alphabetize": {
|
||||
"order": "asc"
|
||||
},
|
||||
"newlines-between": "always",
|
||||
"pathGroups": [
|
||||
{
|
||||
"pattern": "{electron,electron/**}",
|
||||
"group": "builtin",
|
||||
"position": "before"
|
||||
}
|
||||
],
|
||||
"pathGroupsExcludedImportTypes": []
|
||||
}],
|
||||
"n/no-callback-literal": "off",
|
||||
"no-undef": "off",
|
||||
"no-unused-expressions": "off",
|
||||
"no-unused-vars": "off",
|
||||
"import/enforce-node-protocol-usage": ["error", "always"]
|
||||
}
|
||||
}
|
||||
@@ -113,6 +113,7 @@ These individual tutorials expand on topics discussed in the guide above.
|
||||
* [dialog](api/dialog.md)
|
||||
* [globalShortcut](api/global-shortcut.md)
|
||||
* [inAppPurchase](api/in-app-purchase.md)
|
||||
* [ImageView](api/image-view.md)
|
||||
* [ipcMain](api/ipc-main.md)
|
||||
* [Menu](api/menu.md)
|
||||
* [MenuItem](api/menu-item.md)
|
||||
|
||||
@@ -9,6 +9,7 @@ closed:
|
||||
|
||||
```js
|
||||
const { app } = require('electron')
|
||||
|
||||
app.on('window-all-closed', () => {
|
||||
app.quit()
|
||||
})
|
||||
@@ -1023,6 +1024,7 @@ starts:
|
||||
|
||||
```js
|
||||
const { app, BrowserWindow } = require('electron')
|
||||
|
||||
let myWindow = null
|
||||
|
||||
const additionalData = { myKey: 'myValue' }
|
||||
@@ -1226,6 +1228,8 @@ For `infoType` equal to `complete`:
|
||||
For `infoType` equal to `basic`:
|
||||
Promise is fulfilled with `Object` containing fewer attributes than when requested with `complete`. Here's an example of basic response:
|
||||
|
||||
<!-- eslint-skip -->
|
||||
|
||||
```js
|
||||
{
|
||||
auxAttributes:
|
||||
@@ -1339,6 +1343,7 @@ latest version.
|
||||
|
||||
``` js
|
||||
const { app } = require('electron')
|
||||
|
||||
const path = require('node:path')
|
||||
|
||||
const appFolder = path.dirname(process.execPath)
|
||||
@@ -1413,6 +1418,7 @@ Returns `Function` - This function **must** be called once you have finished acc
|
||||
|
||||
```js
|
||||
const { app, dialog } = require('electron')
|
||||
|
||||
const fs = require('node:fs')
|
||||
|
||||
let filepath
|
||||
|
||||
@@ -99,6 +99,10 @@ Process: [Main](../glossary.md#main-process)
|
||||
|
||||
It creates a new `BaseWindow` with native properties as set by the `options`.
|
||||
|
||||
> [!WARNING]
|
||||
> Electron's built-in classes cannot be subclassed in user code.
|
||||
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
|
||||
|
||||
### `new BaseWindow([options])`
|
||||
|
||||
* `options` [BaseWindowConstructorOptions](structures/base-window-options.md?inline) (optional)
|
||||
@@ -294,6 +298,7 @@ e.g. `APPCOMMAND_BROWSER_BACKWARD` is emitted as `browser-backward`.
|
||||
|
||||
```js
|
||||
const { BaseWindow } = require('electron')
|
||||
|
||||
const win = new BaseWindow()
|
||||
win.on('app-command', (e, cmd) => {
|
||||
// Navigate the window back when the user hits their mouse back button
|
||||
@@ -502,6 +507,7 @@ A `boolean` property that determines whether the window is excluded from the app
|
||||
|
||||
```js @ts-expect-error=[12]
|
||||
const { Menu, BaseWindow } = require('electron')
|
||||
|
||||
const win = new BaseWindow({ height: 600, width: 600 })
|
||||
|
||||
const template = [
|
||||
@@ -727,6 +733,7 @@ Resizes and moves the window to the supplied bounds. Any properties that are not
|
||||
|
||||
```js
|
||||
const { BaseWindow } = require('electron')
|
||||
|
||||
const win = new BaseWindow()
|
||||
|
||||
// set all bounds properties
|
||||
@@ -987,6 +994,7 @@ a HTML-rendered toolbar. For example:
|
||||
|
||||
```js
|
||||
const { BaseWindow } = require('electron')
|
||||
|
||||
const win = new BaseWindow()
|
||||
|
||||
const toolbarRect = document.getElementById('toolbar').getBoundingClientRect()
|
||||
@@ -1346,6 +1354,10 @@ On Windows it calls SetWindowDisplayAffinity with `WDA_EXCLUDEFROMCAPTURE`.
|
||||
For Windows 10 version 2004 and up the window will be removed from capture entirely,
|
||||
older Windows versions behave as if `WDA_MONITOR` is applied capturing a black window.
|
||||
|
||||
#### `win.isContentProtected()` _macOS_ _Windows_
|
||||
|
||||
Returns `boolean` - whether or not content protection is currently enabled.
|
||||
|
||||
#### `win.setFocusable(focusable)` _macOS_ _Windows_
|
||||
|
||||
* `focusable` boolean
|
||||
|
||||
@@ -38,6 +38,10 @@ Process: [Main](../glossary.md#main-process)
|
||||
This module cannot be used until the `ready` event of the `app`
|
||||
module is emitted.
|
||||
|
||||
> [!WARNING]
|
||||
> Electron's built-in classes cannot be subclassed in user code.
|
||||
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
|
||||
|
||||
### Example
|
||||
|
||||
```js
|
||||
|
||||
@@ -40,6 +40,7 @@ the window after this event will have no visual flash:
|
||||
|
||||
```js
|
||||
const { BrowserWindow } = require('electron')
|
||||
|
||||
const win = new BrowserWindow({ show: false })
|
||||
win.once('ready-to-show', () => {
|
||||
win.show()
|
||||
@@ -150,6 +151,10 @@ Process: [Main](../glossary.md#main-process)
|
||||
|
||||
It creates a new `BrowserWindow` with native properties as set by the `options`.
|
||||
|
||||
> [!WARNING]
|
||||
> Electron's built-in classes cannot be subclassed in user code.
|
||||
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
|
||||
|
||||
### `new BrowserWindow([options])`
|
||||
|
||||
* `options` [BrowserWindowConstructorOptions](structures/browser-window-options.md?inline) (optional)
|
||||
@@ -373,6 +378,7 @@ e.g. `APPCOMMAND_BROWSER_BACKWARD` is emitted as `browser-backward`.
|
||||
|
||||
```js
|
||||
const { BrowserWindow } = require('electron')
|
||||
|
||||
const win = new BrowserWindow()
|
||||
win.on('app-command', (e, cmd) => {
|
||||
// Navigate the window back when the user hits their mouse back button
|
||||
@@ -820,6 +826,7 @@ Resizes and moves the window to the supplied bounds. Any properties that are not
|
||||
|
||||
```js
|
||||
const { BrowserWindow } = require('electron')
|
||||
|
||||
const win = new BrowserWindow()
|
||||
|
||||
// set all bounds properties
|
||||
@@ -1080,6 +1087,7 @@ a HTML-rendered toolbar. For example:
|
||||
|
||||
```js
|
||||
const { BrowserWindow } = require('electron')
|
||||
|
||||
const win = new BrowserWindow()
|
||||
|
||||
const toolbarRect = document.getElementById('toolbar').getBoundingClientRect()
|
||||
@@ -1232,9 +1240,10 @@ method:
|
||||
|
||||
```js
|
||||
const { BrowserWindow } = require('electron')
|
||||
|
||||
const win = new BrowserWindow()
|
||||
|
||||
const url = require('url').format({
|
||||
const url = require('node:url').format({
|
||||
protocol: 'file',
|
||||
slashes: true,
|
||||
pathname: require('node:path').join(__dirname, 'index.html')
|
||||
@@ -1248,6 +1257,7 @@ the following:
|
||||
|
||||
```js
|
||||
const { BrowserWindow } = require('electron')
|
||||
|
||||
const win = new BrowserWindow()
|
||||
|
||||
win.loadURL('http://localhost:8000/post', {
|
||||
@@ -1528,6 +1538,10 @@ On Windows it calls SetWindowDisplayAffinity with `WDA_EXCLUDEFROMCAPTURE`.
|
||||
For Windows 10 version 2004 and up the window will be removed from capture entirely,
|
||||
older Windows versions behave as if `WDA_MONITOR` is applied capturing a black window.
|
||||
|
||||
#### `win.isContentProtected()` _macOS_ _Windows_
|
||||
|
||||
Returns `boolean` - whether or not content protection is currently enabled.
|
||||
|
||||
#### `win.setFocusable(focusable)` _macOS_ _Windows_
|
||||
|
||||
* `focusable` boolean
|
||||
|
||||
@@ -60,6 +60,10 @@ following properties:
|
||||
`strict-origin-when-cross-origin`.
|
||||
* `cache` string (optional) - can be `default`, `no-store`, `reload`,
|
||||
`no-cache`, `force-cache` or `only-if-cached`.
|
||||
* `priority` string (optional) - can be `throttled`, `idle`, `lowest`,
|
||||
`low`, `medium`, or `highest`. Defaults to `idle`.
|
||||
* `priorityIncremental` boolean (optional) - the incremental loading flag as part
|
||||
of HTTP extensible priorities (RFC 9218). Default is `true`.
|
||||
|
||||
`options` properties such as `protocol`, `host`, `hostname`, `port` and `path`
|
||||
strictly follow the Node.js model as described in the
|
||||
|
||||
@@ -8,6 +8,7 @@ is emitted:
|
||||
|
||||
```js
|
||||
const { app } = require('electron')
|
||||
|
||||
app.commandLine.appendSwitch('remote-debugging-port', '8315')
|
||||
app.commandLine.appendSwitch('host-rules', 'MAP * 127.0.0.1')
|
||||
|
||||
@@ -188,6 +189,7 @@ For example:
|
||||
|
||||
```js
|
||||
const { app } = require('electron')
|
||||
|
||||
app.commandLine.appendSwitch('proxy-bypass-list', '<local>;*.google.com;*foo.com;1.2.3.4:5678')
|
||||
```
|
||||
|
||||
@@ -290,7 +292,7 @@ Specify ways of the inspector web socket url exposure.
|
||||
|
||||
By default inspector websocket url is available in stderr and under /json/list endpoint on `http://host:port/json/list`.
|
||||
|
||||
### `--experimental-network-inspector`
|
||||
### `--experimental-network-inspection`
|
||||
|
||||
Enable support for devtools network inspector events, for visibility into requests made by the nodejs `http` and `https` modules.
|
||||
|
||||
@@ -325,6 +327,26 @@ Set the directory to which all Node.js diagnostic output files are written. Defa
|
||||
|
||||
Affects the default output directory of [v8.setHeapSnapshotNearHeapLimit](https://nodejs.org/docs/latest/api/v8.html#v8setheapsnapshotnearheaplimitlimit).
|
||||
|
||||
### `--no-experimental-global-navigator`
|
||||
|
||||
Disable exposition of [Navigator API][] on the global scope from Node.js.
|
||||
|
||||
## Chromium Flags
|
||||
|
||||
There isn't a documented list of all Chromium switches, but there are a few ways to find them.
|
||||
|
||||
The easiest way is through Chromium's flags page, which you can access at `about://flags`. These flags don't directly match switch names, but they show up in the process's command-line arguments.
|
||||
|
||||
To see these arguments, enable a flag in `about://flags`, then go to `about://version` in Chromium. You'll find a list of command-line arguments, including `--flag-switches-begin --your --list --flag-switches-end`, which contains the list of your flag enabled switches.
|
||||
|
||||
Most flags are included as part of `--enable-features=`, but some are standalone switches, like `--enable-experimental-web-platform-features`.
|
||||
|
||||
A complete list of flags exists in [Chromium's flag metadata page](https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/flag-metadata.json), but this list includes platform, environment and GPU specific, expired and potentially non-functional flags, so many of them might not always work in every situation.
|
||||
|
||||
Keep in mind that standalone switches can sometimes be split into individual features, so there's no fully complete list of switches.
|
||||
|
||||
Finally, you'll need to ensure that the version of Chromium in Electron matches the version of the browser you're using to cross-reference the switches.
|
||||
|
||||
[app]: app.md
|
||||
[append-switch]: command-line.md#commandlineappendswitchswitch-value
|
||||
[debugging-main-process]: ../tutorial/debugging-main-process.md
|
||||
@@ -333,3 +355,4 @@ Affects the default output directory of [v8.setHeapSnapshotNearHeapLimit](https:
|
||||
[play-silent-audio]: https://github.com/atom/atom/pull/9485/files
|
||||
[ready]: app.md#event-ready
|
||||
[severities]: https://source.chromium.org/chromium/chromium/src/+/main:base/logging.h?q=logging::LogSeverity&ss=chromium
|
||||
[Navigator API]: https://github.com/nodejs/node/blob/main/doc/api/globals.md#navigator
|
||||
|
||||
@@ -9,6 +9,7 @@ The following example shows how to check if the `--disable-gpu` flag is set.
|
||||
|
||||
```js
|
||||
const { app } = require('electron')
|
||||
|
||||
app.commandLine.hasSwitch('disable-gpu')
|
||||
```
|
||||
|
||||
|
||||
@@ -189,7 +189,9 @@ Be very cautious about which globals and APIs you expose to untrusted remote con
|
||||
|
||||
```js
|
||||
const { contextBridge } = require('electron')
|
||||
|
||||
const crypto = require('node:crypto')
|
||||
|
||||
contextBridge.exposeInMainWorld('nodeCrypto', {
|
||||
sha256sum (data) {
|
||||
const hash = crypto.createHash('sha256')
|
||||
|
||||
@@ -10,6 +10,7 @@ runtime that allows interacting with pages and instrumenting them.
|
||||
|
||||
```js
|
||||
const { BrowserWindow } = require('electron')
|
||||
|
||||
const win = new BrowserWindow()
|
||||
|
||||
try {
|
||||
|
||||
@@ -8,6 +8,7 @@ An example of showing a dialog to select multiple files:
|
||||
|
||||
```js
|
||||
const { dialog } = require('electron')
|
||||
|
||||
console.log(dialog.showOpenDialog({ properties: ['openFile', 'multiSelections'] }))
|
||||
```
|
||||
|
||||
@@ -52,6 +53,8 @@ The `window` argument allows the dialog to attach itself to a parent window, mak
|
||||
The `filters` specifies an array of file types that can be displayed or
|
||||
selected when you want to limit the user to a specific type. For example:
|
||||
|
||||
<!-- eslint-skip -->
|
||||
|
||||
```js
|
||||
{
|
||||
filters: [
|
||||
@@ -126,6 +129,8 @@ The `window` argument allows the dialog to attach itself to a parent window, mak
|
||||
The `filters` specifies an array of file types that can be displayed or
|
||||
selected when you want to limit the user to a specific type. For example:
|
||||
|
||||
<!-- eslint-skip -->
|
||||
|
||||
```js
|
||||
{
|
||||
filters: [
|
||||
|
||||
@@ -9,6 +9,7 @@ The following example shows how to bounce your icon on the dock.
|
||||
|
||||
```js
|
||||
const { app } = require('electron')
|
||||
|
||||
app.dock?.bounce()
|
||||
```
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ control the download item.
|
||||
```js
|
||||
// In the main process.
|
||||
const { BrowserWindow } = require('electron')
|
||||
|
||||
const win = new BrowserWindow()
|
||||
win.webContents.session.on('will-download', (event, item, webContents) => {
|
||||
// Set the save path, making Electron not to prompt a save dialog.
|
||||
|
||||
@@ -104,7 +104,7 @@ you would when running the normal Node.js executable, with the exception of the
|
||||
These flags are disabled owing to the fact that Electron uses BoringSSL instead of OpenSSL when building Node.js'
|
||||
`crypto` module, and so will not work as designed.
|
||||
|
||||
If the [`runAsNode` fuse](../tutorial/fuses.md#L13) is disabled, `ELECTRON_RUN_AS_NODE` will be ignored.
|
||||
If the [`runAsNode` fuse](../tutorial/fuses.md#runasnode) is disabled, `ELECTRON_RUN_AS_NODE` will be ignored.
|
||||
|
||||
### `ELECTRON_NO_ATTACH_CONSOLE` _Windows_
|
||||
|
||||
|
||||
@@ -77,6 +77,7 @@ extension to be loaded.
|
||||
|
||||
```js
|
||||
const { app, session } = require('electron')
|
||||
|
||||
const path = require('node:path')
|
||||
|
||||
app.whenReady().then(async () => {
|
||||
|
||||
66
docs/api/image-view.md
Normal file
66
docs/api/image-view.md
Normal file
@@ -0,0 +1,66 @@
|
||||
# ImageView
|
||||
|
||||
> A View that displays an image.
|
||||
|
||||
Process: [Main](../glossary.md#main-process)
|
||||
|
||||
This module cannot be used until the `ready` event of the `app`
|
||||
module is emitted.
|
||||
|
||||
Useful for showing splash screens that will be swapped for `WebContentsView`s
|
||||
when the content finishes loading.
|
||||
|
||||
Note that `ImageView` is experimental and may be changed or removed in the future.
|
||||
|
||||
```js
|
||||
const { BaseWindow, ImageView, nativeImage, WebContentsView } = require('electron')
|
||||
|
||||
const path = require('node:path')
|
||||
|
||||
const win = new BaseWindow({ width: 800, height: 600 })
|
||||
|
||||
// Create a "splash screen" image to display while the WebContentsView loads
|
||||
const splashView = new ImageView()
|
||||
const splashImage = nativeImage.createFromPath(path.join(__dirname, 'loading.png'))
|
||||
splashView.setImage(splashImage)
|
||||
win.setContentView(splashView)
|
||||
|
||||
const webContentsView = new WebContentsView()
|
||||
webContentsView.webContents.once('did-finish-load', () => {
|
||||
// Now that the WebContentsView has loaded, swap out the "splash screen" ImageView
|
||||
win.setContentView(webContentsView)
|
||||
})
|
||||
webContentsView.webContents.loadURL('https://electronjs.org')
|
||||
```
|
||||
|
||||
## Class: ImageView extends `View`
|
||||
|
||||
> A View that displays an image.
|
||||
|
||||
Process: [Main](../glossary.md#main-process)
|
||||
|
||||
`ImageView` inherits from [`View`](view.md).
|
||||
|
||||
`ImageView` is an [EventEmitter][event-emitter].
|
||||
|
||||
> [!WARNING]
|
||||
> Electron's built-in classes cannot be subclassed in user code.
|
||||
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
|
||||
|
||||
### `new ImageView()` _Experimental_
|
||||
|
||||
Creates an ImageView.
|
||||
|
||||
### Instance Methods
|
||||
|
||||
The following methods are available on instances of the `ImageView` class, in
|
||||
addition to those inherited from [View](view.md):
|
||||
|
||||
#### `image.setImage(image)` _Experimental_
|
||||
|
||||
* `image` NativeImage
|
||||
|
||||
Sets the image for this `ImageView`. Note that only image formats supported by
|
||||
`NativeImage` can be used with an `ImageView`.
|
||||
|
||||
[event-emitter]: https://nodejs.org/api/events.html#events_class_eventemitter
|
||||
@@ -11,6 +11,10 @@ Process: [Main](../glossary.md#main-process)
|
||||
|
||||
<!-- TODO(samuelmaddock): refactor doc gen to allow generics to reduce duplication -->
|
||||
|
||||
> [!WARNING]
|
||||
> Electron's built-in classes cannot be subclassed in user code.
|
||||
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
|
||||
|
||||
### Instance Methods
|
||||
|
||||
#### `ipcMainServiceWorker.on(channel, listener)`
|
||||
|
||||
@@ -6,6 +6,10 @@ Process: [Main](../glossary.md#main-process)
|
||||
|
||||
See [`Menu`](menu.md) for examples.
|
||||
|
||||
> [!WARNING]
|
||||
> Electron's built-in classes cannot be subclassed in user code.
|
||||
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
|
||||
|
||||
### `new MenuItem(options)`
|
||||
|
||||
* `options` Object
|
||||
@@ -16,8 +20,14 @@ See [`Menu`](menu.md) for examples.
|
||||
* `event` [KeyboardEvent](structures/keyboard-event.md)
|
||||
* `role` string (optional) - Can be `undo`, `redo`, `cut`, `copy`, `paste`, `pasteAndMatchStyle`, `delete`, `selectAll`, `reload`, `forceReload`, `toggleDevTools`, `resetZoom`, `zoomIn`, `zoomOut`, `toggleSpellChecker`, `togglefullscreen`, `window`, `minimize`, `close`, `help`, `about`, `services`, `hide`, `hideOthers`, `unhide`, `quit`, `showSubstitutions`, `toggleSmartQuotes`, `toggleSmartDashes`, `toggleTextReplacement`, `startSpeaking`, `stopSpeaking`, `zoom`, `front`, `appMenu`, `fileMenu`, `editMenu`, `viewMenu`, `shareMenu`, `recentDocuments`, `toggleTabBar`, `selectNextTab`, `selectPreviousTab`, `showAllTabs`, `mergeAllWindows`, `clearRecentDocuments`, `moveTabToNewWindow` or `windowMenu` - Define the action of the menu item, when specified the
|
||||
`click` property will be ignored. See [roles](#roles).
|
||||
* `type` string (optional) - Can be `normal`, `separator`, `submenu`, `checkbox` or
|
||||
`radio`.
|
||||
* `type` string (optional)
|
||||
* `normal`
|
||||
* `separator`
|
||||
* `submenu`
|
||||
* `checkbox`
|
||||
* `radio`
|
||||
* `header` - Only available on macOS 14 and up.
|
||||
* `palette` - Only available on macOS 14 and up.
|
||||
* `label` string (optional)
|
||||
* `sublabel` string (optional) _macOS_ - Available in macOS >= 14.4
|
||||
* `toolTip` string (optional) _macOS_ - Hover text for this menu item.
|
||||
@@ -158,7 +168,10 @@ item's submenu, if present.
|
||||
|
||||
#### `menuItem.type`
|
||||
|
||||
A `string` indicating the type of the item. Can be `normal`, `separator`, `submenu`, `checkbox` or `radio`.
|
||||
A `string` indicating the type of the item. Can be `normal`, `separator`, `submenu`, `checkbox`, `radio`, `header` or `palette`.
|
||||
|
||||
> [!NOTE]
|
||||
> `header` and `palette` are only available on macOS 14 and up.
|
||||
|
||||
#### `menuItem.role`
|
||||
|
||||
|
||||
@@ -6,6 +6,10 @@
|
||||
|
||||
Process: [Main](../glossary.md#main-process)
|
||||
|
||||
> [!WARNING]
|
||||
> Electron's built-in classes cannot be subclassed in user code.
|
||||
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
|
||||
|
||||
### `new Menu()`
|
||||
|
||||
Creates a new menu.
|
||||
|
||||
@@ -15,9 +15,12 @@ Process: [Main](../glossary.md#main-process)
|
||||
|
||||
Example:
|
||||
|
||||
<!-- eslint-disable import/order -->
|
||||
|
||||
```js
|
||||
// Main process
|
||||
const { BrowserWindow, MessageChannelMain } = require('electron')
|
||||
|
||||
const w = new BrowserWindow()
|
||||
const { port1, port2 } = new MessageChannelMain()
|
||||
w.webContents.postMessage('port', null, [port2])
|
||||
@@ -25,6 +28,7 @@ port1.postMessage({ some: 'message' })
|
||||
|
||||
// Renderer process
|
||||
const { ipcRenderer } = require('electron')
|
||||
|
||||
ipcRenderer.on('port', (e) => {
|
||||
// e.ports is a list of ports sent along with this message
|
||||
e.ports[0].onmessage = (messageEvent) => {
|
||||
@@ -33,6 +37,10 @@ ipcRenderer.on('port', (e) => {
|
||||
})
|
||||
```
|
||||
|
||||
> [!WARNING]
|
||||
> Electron's built-in classes cannot be subclassed in user code.
|
||||
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
|
||||
|
||||
### Instance Properties
|
||||
|
||||
#### `channel.port1`
|
||||
|
||||
@@ -86,6 +86,7 @@ images/
|
||||
|
||||
```js title='Main Process'
|
||||
const { Tray } = require('electron')
|
||||
|
||||
const appTray = new Tray('/Users/somebody/images/icon.png')
|
||||
```
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ Example usage:
|
||||
|
||||
```js
|
||||
const { app } = require('electron')
|
||||
|
||||
app.whenReady().then(() => {
|
||||
const { net } = require('electron')
|
||||
const request = net.request('https://github.com')
|
||||
|
||||
@@ -4,12 +4,9 @@
|
||||
|
||||
Process: [Main](../glossary.md#main-process)
|
||||
|
||||
:::info Renderer process notifications
|
||||
|
||||
If you want to show notifications from a renderer process you should use the
|
||||
[web Notifications API](../tutorial/notifications.md)
|
||||
|
||||
:::
|
||||
> [!NOTE]
|
||||
> If you want to show notifications from a renderer process you should use the
|
||||
> [web Notifications API](../tutorial/notifications.md)
|
||||
|
||||
## Class: Notification
|
||||
|
||||
@@ -21,6 +18,10 @@ Process: [Main](../glossary.md#main-process)
|
||||
|
||||
It creates a new `Notification` with native properties as set by the `options`.
|
||||
|
||||
> [!WARNING]
|
||||
> Electron's built-in classes cannot be subclassed in user code.
|
||||
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
|
||||
|
||||
### Static Methods
|
||||
|
||||
The `Notification` class has the following static methods:
|
||||
|
||||
@@ -9,6 +9,7 @@ An example of implementing a protocol that has the same effect as the
|
||||
|
||||
```js
|
||||
const { app, protocol, net } = require('electron')
|
||||
|
||||
const path = require('node:path')
|
||||
const url = require('node:url')
|
||||
|
||||
@@ -38,8 +39,9 @@ to register it to that session explicitly.
|
||||
|
||||
```js
|
||||
const { app, BrowserWindow, net, protocol, session } = require('electron')
|
||||
|
||||
const path = require('node:path')
|
||||
const url = require('url')
|
||||
const url = require('node:url')
|
||||
|
||||
app.whenReady().then(() => {
|
||||
const partition = 'persist:example'
|
||||
@@ -76,6 +78,7 @@ Policy:
|
||||
|
||||
```js
|
||||
const { protocol } = require('electron')
|
||||
|
||||
protocol.registerSchemesAsPrivileged([
|
||||
{ scheme: 'foo', privileges: { bypassCSP: true } }
|
||||
])
|
||||
@@ -128,8 +131,9 @@ Example:
|
||||
|
||||
```js
|
||||
const { app, net, protocol } = require('electron')
|
||||
|
||||
const path = require('node:path')
|
||||
const { pathToFileURL } = require('url')
|
||||
const { pathToFileURL } = require('node:url')
|
||||
|
||||
protocol.registerSchemesAsPrivileged([
|
||||
{
|
||||
@@ -330,7 +334,8 @@ Example:
|
||||
|
||||
```js
|
||||
const { protocol } = require('electron')
|
||||
const { PassThrough } = require('stream')
|
||||
|
||||
const { PassThrough } = require('node:stream')
|
||||
|
||||
function createStream (text) {
|
||||
const rv = new PassThrough() // PassThrough is also a Readable stream
|
||||
|
||||
@@ -73,5 +73,6 @@ command line flag is provided `--password-store="basic"`.
|
||||
is provided `--password-store="kwallet"`.
|
||||
* `kwallet5` - When the desktop session is `kde5` or if the following command line flag
|
||||
is provided `--password-store="kwallet5"`.
|
||||
* `kwallet6` - When the desktop session is `kde6`.
|
||||
* `kwallet6` - When the desktop session is `kde6` or if the following command line flag
|
||||
is provided `--password-store="kwallet6"`.
|
||||
* `unknown` - When the function is called before app has emitted the `ready` event.
|
||||
|
||||
@@ -109,6 +109,7 @@ Starts the service worker or does nothing if already running.
|
||||
|
||||
```js
|
||||
const { app, session } = require('electron')
|
||||
|
||||
const { serviceWorkers } = session.defaultSession
|
||||
|
||||
// Collect service workers scopes
|
||||
|
||||
@@ -79,6 +79,7 @@ You can create a `Session` object in the `session` module:
|
||||
|
||||
```js
|
||||
const { session } = require('electron')
|
||||
|
||||
const ses = session.fromPartition('persist:name')
|
||||
console.log(ses.getUserAgent())
|
||||
```
|
||||
@@ -100,8 +101,9 @@ Emitted when Electron is about to download `item` in `webContents`.
|
||||
Calling `event.preventDefault()` will cancel the download and `item` will not be
|
||||
available from next tick of the process.
|
||||
|
||||
```js @ts-expect-error=[4]
|
||||
```js @ts-expect-error=[5]
|
||||
const { session } = require('electron')
|
||||
|
||||
session.defaultSession.on('will-download', (event, item, webContents) => {
|
||||
event.preventDefault()
|
||||
require('got')(item.getURL()).then((response) => {
|
||||
@@ -852,6 +854,7 @@ verify proc.
|
||||
|
||||
```js
|
||||
const { BrowserWindow } = require('electron')
|
||||
|
||||
const win = new BrowserWindow()
|
||||
|
||||
win.webContents.session.setCertificateVerifyProc((request, callback) => {
|
||||
@@ -903,6 +906,7 @@ Most web APIs do a permission check and then make a permission request if the ch
|
||||
|
||||
```js
|
||||
const { session } = require('electron')
|
||||
|
||||
session.fromPartition('some-partition').setPermissionRequestHandler((webContents, permission, callback) => {
|
||||
if (webContents.getURL() === 'some-host' && permission === 'notifications') {
|
||||
return callback(false) // denied.
|
||||
@@ -952,7 +956,9 @@ To clear the handler, call `setPermissionCheckHandler(null)`.
|
||||
|
||||
```js
|
||||
const { session } = require('electron')
|
||||
const url = require('url')
|
||||
|
||||
const url = require('node:url')
|
||||
|
||||
session.fromPartition('some-partition').setPermissionCheckHandler((webContents, permission, requestingOrigin) => {
|
||||
if (new URL(requestingOrigin).hostname === 'some-host' && permission === 'notifications') {
|
||||
return true // granted
|
||||
@@ -1189,6 +1195,7 @@ automatically. To clear the handler, call `setBluetoothPairingHandler(null)`.
|
||||
|
||||
```js
|
||||
const { app, BrowserWindow, session } = require('electron')
|
||||
|
||||
const path = require('node:path')
|
||||
|
||||
function createWindow () {
|
||||
@@ -1518,6 +1525,7 @@ extension to be loaded.
|
||||
|
||||
```js
|
||||
const { app, session } = require('electron')
|
||||
|
||||
const path = require('node:path')
|
||||
|
||||
app.whenReady().then(async () => {
|
||||
@@ -1659,6 +1667,7 @@ A [`Protocol`](protocol.md) object for this session.
|
||||
|
||||
```js
|
||||
const { app, session } = require('electron')
|
||||
|
||||
const path = require('node:path')
|
||||
|
||||
app.whenReady().then(() => {
|
||||
|
||||
@@ -13,6 +13,10 @@ For including the share menu as a submenu of other menus, please use the
|
||||
|
||||
Process: [Main](../glossary.md#main-process)
|
||||
|
||||
> [!WARNING]
|
||||
> Electron's built-in classes cannot be subclassed in user code.
|
||||
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
|
||||
|
||||
### `new ShareMenu(sharingItem)`
|
||||
|
||||
* `sharingItem` SharingItem - The item to share.
|
||||
|
||||
@@ -95,6 +95,7 @@
|
||||
* `color` String (optional) _Windows_ _Linux_ - The CSS color of the Window Controls Overlay when enabled. Default is the system color.
|
||||
* `symbolColor` String (optional) _Windows_ _Linux_ - The CSS color of the symbols on the Window Controls Overlay when enabled. Default is the system color.
|
||||
* `height` Integer (optional) - The height of the title bar and Window Controls Overlay in pixels. Default is system height.
|
||||
* `accentColor` boolean | string (optional) _Windows_ - The accent color for the window. By default, follows user preference in System Settings. Set to `false` to explicitly disable, or set the color in Hex, RGB, RGBA, HSL, HSLA or named CSS color format. Alpha values will be ignored.
|
||||
* `trafficLightPosition` [Point](point.md) (optional) _macOS_ -
|
||||
Set a custom position for the traffic light buttons in frameless windows.
|
||||
* `roundedCorners` boolean (optional) _macOS_ _Windows_ - Whether frameless window
|
||||
|
||||
195
docs/api/structures/color-space.md
Normal file
195
docs/api/structures/color-space.md
Normal file
@@ -0,0 +1,195 @@
|
||||
# ColorSpace Object
|
||||
|
||||
* `primaries` string - The color primaries of the color space. Can be one of the following values:
|
||||
* `bt709` - BT709 primaries (also used for sRGB)
|
||||
* `bt470m` - BT470M primaries
|
||||
* `bt470bg` - BT470BG primaries
|
||||
* `smpte170m` - SMPTE170M primaries
|
||||
* `smpte240m` - SMPTE240M primaries
|
||||
* `film` - Film primaries
|
||||
* `bt2020` - BT2020 primaries
|
||||
* `smptest428-1` - SMPTEST428-1 primaries
|
||||
* `smptest431-2` - SMPTEST431-2 primaries
|
||||
* `p3` - P3 primaries
|
||||
* `xyz-d50` - XYZ D50 primaries
|
||||
* `adobe-rgb` - Adobe RGB primaries
|
||||
* `apple-generic-rgb` - Apple Generic RGB primaries
|
||||
* `wide-gamut-color-spin` - Wide Gamut Color Spin primaries
|
||||
* `ebu-3213-e` - EBU 3213-E primaries
|
||||
* `custom` - Custom primaries
|
||||
* `invalid` - Invalid primaries
|
||||
|
||||
* `transfer` string - The transfer function of the color space. Can be one of the following values:
|
||||
* `bt709` - BT709 transfer function
|
||||
* `bt709-apple` - BT709 Apple transfer function
|
||||
* `gamma18` - Gamma 1.8 transfer function
|
||||
* `gamma22` - Gamma 2.2 transfer function
|
||||
* `gamma24` - Gamma 2.4 transfer function
|
||||
* `gamma28` - Gamma 2.8 transfer function
|
||||
* `smpte170m` - SMPTE170M transfer function
|
||||
* `smpte240m` - SMPTE240M transfer function
|
||||
* `linear` - Linear transfer function
|
||||
* `log` - Log transfer function
|
||||
* `log-sqrt` - Log Square Root transfer function
|
||||
* `iec61966-2-4` - IEC61966-2-4 transfer function
|
||||
* `bt1361-ecg` - BT1361 ECG transfer function
|
||||
* `srgb` - sRGB transfer function
|
||||
* `bt2020-10` - BT2020-10 transfer function
|
||||
* `bt2020-12` - BT2020-12 transfer function
|
||||
* `pq` - PQ (Perceptual Quantizer) transfer function
|
||||
* `smptest428-1` - SMPTEST428-1 transfer function
|
||||
* `hlg` - HLG (Hybrid Log-Gamma) transfer function
|
||||
* `srgb-hdr` - sRGB HDR transfer function
|
||||
* `linear-hdr` - Linear HDR transfer function
|
||||
* `custom` - Custom transfer function
|
||||
* `custom-hdr` - Custom HDR transfer function
|
||||
* `scrgb-linear-80-nits` - scRGB Linear 80 nits transfer function
|
||||
* `invalid` - Invalid transfer function
|
||||
|
||||
* `matrix` string - The color matrix of the color space. Can be one of the following values:
|
||||
* `rgb` - RGB matrix
|
||||
* `bt709` - BT709 matrix
|
||||
* `fcc` - FCC matrix
|
||||
* `bt470bg` - BT470BG matrix
|
||||
* `smpte170m` - SMPTE170M matrix
|
||||
* `smpte240m` - SMPTE240M matrix
|
||||
* `ycocg` - YCoCg matrix
|
||||
* `bt2020-ncl` - BT2020 NCL matrix
|
||||
* `ydzdx` - YDzDx matrix
|
||||
* `gbr` - GBR matrix
|
||||
* `invalid` - Invalid matrix
|
||||
|
||||
* `range` string - The color range of the color space. Can be one of the following values:
|
||||
* `limited` - Limited color range (RGB values ranging from 16 to 235)
|
||||
* `full` - Full color range (RGB values from 0 to 255)
|
||||
* `derived` - Range defined by the transfer function and matrix
|
||||
* `invalid` - Invalid range
|
||||
|
||||
## Common `ColorSpace` definitions
|
||||
|
||||
### Standard Color Spaces
|
||||
|
||||
**sRGB**:
|
||||
|
||||
```js
|
||||
const cs = {
|
||||
primaries: 'bt709',
|
||||
transfer: 'srgb',
|
||||
matrix: 'rgb',
|
||||
range: 'full'
|
||||
}
|
||||
```
|
||||
|
||||
**Display P3**:
|
||||
|
||||
```js
|
||||
const cs = {
|
||||
primaries: 'p3',
|
||||
transfer: 'srgb',
|
||||
matrix: 'rgb',
|
||||
range: 'full'
|
||||
}
|
||||
```
|
||||
|
||||
**XYZ D50**:
|
||||
|
||||
```js
|
||||
const cs = {
|
||||
primaries: 'xyz-d50',
|
||||
transfer: 'linear',
|
||||
matrix: 'rgb',
|
||||
range: 'full'
|
||||
}
|
||||
```
|
||||
|
||||
### HDR Color Spaces
|
||||
|
||||
**Extended sRGB** (extends sRGB to all real values):
|
||||
|
||||
```js
|
||||
const cs = {
|
||||
primaries: 'bt709',
|
||||
transfer: 'srgb-hdr',
|
||||
matrix: 'rgb',
|
||||
range: 'full'
|
||||
}
|
||||
```
|
||||
|
||||
**scRGB Linear** (linear transfer function for all real values):
|
||||
|
||||
```js
|
||||
const cs = {
|
||||
primaries: 'bt709',
|
||||
transfer: 'linear-hdr',
|
||||
matrix: 'rgb',
|
||||
range: 'full'
|
||||
}
|
||||
```
|
||||
|
||||
**scRGB Linear 80 Nits** (with an SDR white level of 80 nits):
|
||||
|
||||
```js
|
||||
const cs = {
|
||||
primaries: 'bt709',
|
||||
transfer: 'scrgb-linear-80-nits',
|
||||
matrix: 'rgb',
|
||||
range: 'full'
|
||||
}
|
||||
```
|
||||
|
||||
**HDR10** (BT.2020 primaries with PQ transfer function):
|
||||
|
||||
```js
|
||||
const cs = {
|
||||
primaries: 'bt2020',
|
||||
transfer: 'pq',
|
||||
matrix: 'rgb',
|
||||
range: 'full'
|
||||
}
|
||||
```
|
||||
|
||||
**HLG** (BT.2020 primaries with HLG transfer function):
|
||||
|
||||
```js
|
||||
const cs = {
|
||||
primaries: 'bt2020',
|
||||
transfer: 'hlg',
|
||||
matrix: 'rgb',
|
||||
range: 'full'
|
||||
}
|
||||
```
|
||||
|
||||
### Video Color Spaces
|
||||
|
||||
**Rec. 601** (SDTV):
|
||||
|
||||
```js
|
||||
const cs = {
|
||||
primaries: 'smpte170m',
|
||||
transfer: 'smpte170m',
|
||||
matrix: 'smpte170m',
|
||||
range: 'limited'
|
||||
}
|
||||
```
|
||||
|
||||
**Rec. 709** (HDTV):
|
||||
|
||||
```js
|
||||
const cs = {
|
||||
primaries: 'bt709',
|
||||
transfer: 'bt709',
|
||||
matrix: 'bt709',
|
||||
range: 'limited'
|
||||
}
|
||||
```
|
||||
|
||||
**JPEG** (typical color space for JPEG images):
|
||||
|
||||
```js
|
||||
const cs = {
|
||||
primaries: 'bt709',
|
||||
transfer: 'srgb',
|
||||
matrix: 'smpte170m',
|
||||
range: 'full'
|
||||
}
|
||||
```
|
||||
@@ -6,3 +6,11 @@
|
||||
* `productId` Integer - The USB product ID.
|
||||
* `serialNumber` string (optional) - The USB device serial number.
|
||||
* `guid` string (optional) - Unique identifier for the HID interface. A device may have multiple HID interfaces.
|
||||
* `collections` Object[] - an array of report formats. See [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/API/HIDDevice/collections) for more.
|
||||
* `usage` Integer - An integer representing the usage ID component of the HID usage associated with this collection.
|
||||
* `usagePage` Integer - An integer representing the usage page component of the HID usage associated with this collection.
|
||||
* `type` Integer - An 8-bit value representing the collection type, which describes a different relationship between the grouped items.
|
||||
* `children` Object[] - An array of sub-collections which takes the same format as a top-level collection.
|
||||
* `inputReports` Object[] - An array of inputReport items which represent individual input reports described in this collection.
|
||||
* `outputReports` Object[] - An array of outputReport items which represent individual output reports described in this collection.
|
||||
* `featureReports` Object[] - An array of featureReport items which represent individual feature reports described in this collection.
|
||||
|
||||
@@ -12,6 +12,8 @@ The number represented by `status` means different things on different platforms
|
||||
Below is an example of some of the additional options that may be set which
|
||||
may be different on each platform.
|
||||
|
||||
<!-- eslint-skip -->
|
||||
|
||||
```js
|
||||
{
|
||||
name: 'Austin_4th_Floor_Printer___C02XK13BJHD4',
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
|
||||
An example TraceConfig that roughly matches what Chrome DevTools records:
|
||||
|
||||
<!-- eslint-skip -->
|
||||
|
||||
```js
|
||||
{
|
||||
recording_mode: 'record-until-full',
|
||||
|
||||
@@ -1,17 +1,35 @@
|
||||
# USBDevice Object
|
||||
|
||||
* `configuration` Object (optional) - A [USBConfiguration](https://developer.mozilla.org/en-US/docs/Web/API/USBConfiguration) object containing information about the currently selected configuration of a USB device.
|
||||
* `configurationValue` Integer - the configuration value of this configuration.
|
||||
* `configurationName` string - the name provided by the device to describe this configuration.
|
||||
* `interfaces` Object[] - An array of [USBInterface](https://developer.mozilla.org/en-US/docs/Web/API/USBInterface) objects containing information about an interface provided by the USB device.
|
||||
* `interfaceNumber` Integer - the interface number of this interface.
|
||||
* `alternate` Object - the currently selected alternative configuration of this interface.
|
||||
* `alternateSetting` Integer - the alternate setting number of this interface.
|
||||
* `interfaceClass` Integer - the class of this interface. See [USB.org](https://www.usb.org/defined-class-codes) for class code descriptions.
|
||||
* `interfaceSubclass` Integer - the subclass of this interface.
|
||||
* `interfaceProtocol` Integer - the protocol supported by this interface.
|
||||
* `interfaceName` string (optional) - the name of the interface, if one is provided by the device.
|
||||
* `endpoints` Object[] - an array containing instances of the [USBEndpoint interface](https://developer.mozilla.org/en-US/docs/Web/API/USBEndpoint) describing each of the endpoints that are part of this interface.
|
||||
* `endpointNumber` Integer - this endpoint's "endpoint number" which is a value from 1 to 15.
|
||||
* `direction` string - the direction in which this endpoint transfers data - can be either 'in' or 'out'.
|
||||
* `type` string - the type of this endpoint - can be either 'bulk', 'interrupt', or 'isochronous'.
|
||||
* `packetSize` Integer - the size of the packets that data sent through this endpoint will be divided into.
|
||||
* `alternates` Object[] - an array containing instances of the [USBAlternateInterface](https://developer.mozilla.org/en-US/docs/Web/API/USBAlternateInterface) interface describing each of the alternative configurations possible for this interface.
|
||||
* `configurations` Object[] - An array of [USBConfiguration](https://developer.mozilla.org/en-US/docs/Web/API/USBConfiguration) interfaces for controlling a paired USB device.
|
||||
* `deviceClass` Integer - The device class for the communication interface supported by the device.
|
||||
* `deviceId` string - Unique identifier for the device.
|
||||
* `vendorId` Integer - The USB vendor ID.
|
||||
* `productId` Integer - The USB product ID.
|
||||
* `productName` string (optional) - Name of the device.
|
||||
* `serialNumber` string (optional) - The USB device serial number.
|
||||
* `manufacturerName` string (optional) - The manufacturer name of the device.
|
||||
* `usbVersionMajor` Integer - The USB protocol major version supported by the device
|
||||
* `usbVersionMinor` Integer - The USB protocol minor version supported by the device
|
||||
* `usbVersionSubminor` Integer - The USB protocol subminor version supported by the device
|
||||
* `deviceClass` Integer - The device class for the communication interface supported by the device
|
||||
* `deviceSubclass` Integer - The device subclass for the communication interface supported by the device
|
||||
* `deviceProtocol` Integer - The device protocol for the communication interface supported by the device
|
||||
* `deviceProtocol` Integer - The device protocol for the communication interface supported by the device.
|
||||
* `deviceSubclass` Integer - The device subclass for the communication interface supported by the device.
|
||||
* `deviceVersionMajor` Integer - The major version number of the device as defined by the device manufacturer.
|
||||
* `deviceVersionMinor` Integer - The minor version number of the device as defined by the device manufacturer.
|
||||
* `deviceVersionSubminor` Integer - The subminor version number of the device as defined by the device manufacturer.
|
||||
* `manufacturerName` string (optional) - The manufacturer name of the device.
|
||||
* `productId` Integer - The USB product ID.
|
||||
* `productName` string (optional) - Name of the device.
|
||||
* `serialNumber` string (optional) - The USB device serial number.
|
||||
* `usbVersionMajor` Integer - The USB protocol major version supported by the device.
|
||||
* `usbVersionMinor` Integer - The USB protocol minor version supported by the device.
|
||||
* `usbVersionSubminor` Integer - The USB protocol subminor version supported by the device.
|
||||
* `vendorId` Integer - The USB vendor ID.
|
||||
|
||||
@@ -6,6 +6,7 @@ Process: [Main](../glossary.md#main-process), [Utility](../glossary.md#utility-p
|
||||
|
||||
```js
|
||||
const { systemPreferences } = require('electron')
|
||||
|
||||
console.log(systemPreferences.getEffectiveAppearance())
|
||||
```
|
||||
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
# TouchBar
|
||||
|
||||
> [!WARNING]
|
||||
> Electron's built-in classes cannot be subclassed in user code.
|
||||
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
|
||||
|
||||
## Class: TouchBar
|
||||
|
||||
> Create TouchBar layouts for native macOS applications
|
||||
|
||||
@@ -25,6 +25,10 @@ app.whenReady().then(() => {
|
||||
})
|
||||
```
|
||||
|
||||
> [!WARNING]
|
||||
> Electron's built-in classes cannot be subclassed in user code.
|
||||
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
|
||||
|
||||
**Platform Considerations**
|
||||
|
||||
**Linux**
|
||||
|
||||
@@ -9,6 +9,7 @@ module is emitted.
|
||||
|
||||
```js
|
||||
const { BaseWindow, View } = require('electron')
|
||||
|
||||
const win = new BaseWindow()
|
||||
const view = new View()
|
||||
|
||||
@@ -25,6 +26,10 @@ Process: [Main](../glossary.md#main-process)
|
||||
|
||||
`View` is an [EventEmitter][event-emitter].
|
||||
|
||||
> [!WARNING]
|
||||
> Electron's built-in classes cannot be subclassed in user code.
|
||||
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
|
||||
|
||||
### `new View()`
|
||||
|
||||
Creates a new `View`.
|
||||
|
||||
@@ -9,6 +9,7 @@ module is emitted.
|
||||
|
||||
```js
|
||||
const { BaseWindow, WebContentsView } = require('electron')
|
||||
|
||||
const win = new BaseWindow({ width: 800, height: 400 })
|
||||
|
||||
const view1 = new WebContentsView()
|
||||
@@ -32,6 +33,10 @@ Process: [Main](../glossary.md#main-process)
|
||||
|
||||
`WebContentsView` is an [EventEmitter][event-emitter].
|
||||
|
||||
> [!WARNING]
|
||||
> Electron's built-in classes cannot be subclassed in user code.
|
||||
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
|
||||
|
||||
### `new WebContentsView([options])`
|
||||
|
||||
* `options` Object (optional)
|
||||
@@ -52,6 +57,7 @@ Use this to interact with the `WebContents`, for instance to load a URL.
|
||||
|
||||
```js
|
||||
const { WebContentsView } = require('electron')
|
||||
|
||||
const view = new WebContentsView()
|
||||
view.webContents.loadURL('https://electronjs.org/')
|
||||
```
|
||||
|
||||
@@ -55,6 +55,7 @@ These methods can be accessed from the `webContents` module:
|
||||
|
||||
```js
|
||||
const { webContents } = require('electron')
|
||||
|
||||
console.log(webContents)
|
||||
```
|
||||
|
||||
@@ -446,6 +447,7 @@ and allow the page to be unloaded.
|
||||
|
||||
```js
|
||||
const { BrowserWindow, dialog } = require('electron')
|
||||
|
||||
const win = new BrowserWindow({ width: 800, height: 600 })
|
||||
win.webContents.on('will-prevent-unload', (event) => {
|
||||
const choice = dialog.showMessageBoxSync(win, {
|
||||
@@ -534,14 +536,55 @@ To only prevent the menu shortcuts, use
|
||||
[`setIgnoreMenuShortcuts`](#contentssetignoremenushortcutsignore):
|
||||
|
||||
```js
|
||||
const { BrowserWindow } = require('electron')
|
||||
const { app, BrowserWindow } = require('electron')
|
||||
|
||||
const win = new BrowserWindow({ width: 800, height: 600 })
|
||||
app.whenReady().then(() => {
|
||||
const win = new BrowserWindow({ width: 800, height: 600 })
|
||||
|
||||
win.webContents.on('before-input-event', (event, input) => {
|
||||
// For example, only enable application menu keyboard shortcuts when
|
||||
// Ctrl/Cmd are down.
|
||||
win.webContents.setIgnoreMenuShortcuts(!input.control && !input.meta)
|
||||
win.webContents.on('before-input-event', (event, input) => {
|
||||
// Enable application menu keyboard shortcuts when Ctrl/Cmd are down.
|
||||
win.webContents.setIgnoreMenuShortcuts(!input.control && !input.meta)
|
||||
})
|
||||
})
|
||||
```
|
||||
|
||||
#### Event: 'before-mouse-event'
|
||||
|
||||
Returns:
|
||||
|
||||
* `event` Event
|
||||
* `mouse` [MouseInputEvent](structures/mouse-input-event.md)
|
||||
|
||||
Emitted before dispatching mouse events in the page.
|
||||
|
||||
Calling `event.preventDefault` will prevent the page mouse events.
|
||||
|
||||
```js
|
||||
const { app, BrowserWindow } = require('electron')
|
||||
|
||||
app.whenReady().then(() => {
|
||||
const win = new BrowserWindow({ width: 800, height: 600 })
|
||||
|
||||
win.webContents.on('before-mouse-event', (event, mouse) => {
|
||||
// Prevent mouseDown events.
|
||||
if (mouse.type === 'mouseDown') {
|
||||
console.log(mouse)
|
||||
/*
|
||||
{
|
||||
type: 'mouseDown',
|
||||
clickCount: 1,
|
||||
movementX: 0,
|
||||
movementY: 0,
|
||||
button: 'left',
|
||||
x: 632.359375,
|
||||
y: 480.6875,
|
||||
globalX: 168.359375,
|
||||
globalY: 193.6875
|
||||
}
|
||||
*/
|
||||
event.preventDefault()
|
||||
}
|
||||
})
|
||||
})
|
||||
```
|
||||
|
||||
@@ -839,9 +882,10 @@ Emitted when a bluetooth device needs to be selected when a call to
|
||||
the `deviceId` of the device to be selected. Passing an empty string to
|
||||
`callback` will cancel the request.
|
||||
|
||||
If an event listener is not added for this event, or if `event.preventDefault`
|
||||
is not called when handling this event, the first available device will be
|
||||
automatically selected.
|
||||
If no event listener is added for this event, all bluetooth requests will be cancelled.
|
||||
|
||||
If `event.preventDefault` is not called when handling this event, the first available
|
||||
device will be automatically selected.
|
||||
|
||||
Due to the nature of bluetooth, scanning for devices when
|
||||
`navigator.bluetooth.requestDevice` is called may take time and will cause
|
||||
@@ -1103,6 +1147,7 @@ Returns `string` - The URL of the current web page.
|
||||
|
||||
```js
|
||||
const { BrowserWindow } = require('electron')
|
||||
|
||||
const win = new BrowserWindow({ width: 800, height: 600 })
|
||||
win.loadURL('https://github.com').then(() => {
|
||||
const currentURL = win.webContents.getURL()
|
||||
@@ -1722,6 +1767,12 @@ When a custom `pageSize` is passed, Chromium attempts to validate platform speci
|
||||
Prints window's web page. When `silent` is set to `true`, Electron will pick
|
||||
the system's default printer if `deviceName` is empty and the default settings for printing.
|
||||
|
||||
Some possible `failureReason`s for print failure include:
|
||||
|
||||
* "Invalid printer settings"
|
||||
* "Print job canceled"
|
||||
* "Print job failed"
|
||||
|
||||
Use `page-break-before: always;` CSS style to force to print to a new page.
|
||||
|
||||
Example usage:
|
||||
@@ -1772,9 +1823,10 @@ An example of `webContents.printToPDF`:
|
||||
|
||||
```js
|
||||
const { app, BrowserWindow } = require('electron')
|
||||
|
||||
const fs = require('node:fs')
|
||||
const path = require('node:path')
|
||||
const os = require('node:os')
|
||||
const path = require('node:path')
|
||||
|
||||
app.whenReady().then(() => {
|
||||
const win = new BrowserWindow()
|
||||
@@ -1806,6 +1858,7 @@ creation:
|
||||
|
||||
```js
|
||||
const { BrowserWindow } = require('electron')
|
||||
|
||||
const win = new BrowserWindow()
|
||||
win.webContents.on('devtools-opened', () => {
|
||||
win.webContents.addWorkSpace(__dirname)
|
||||
@@ -1872,6 +1925,7 @@ An example of showing devtools in a `<webview>` tag:
|
||||
```js
|
||||
// Main process
|
||||
const { ipcMain, webContents } = require('electron')
|
||||
|
||||
ipcMain.on('open-devtools', (event, targetContentsId, devtoolsContentsId) => {
|
||||
const target = webContents.fromId(targetContentsId)
|
||||
const devtools = webContents.fromId(devtoolsContentsId)
|
||||
@@ -2131,6 +2185,7 @@ Returns `Promise<void>` - resolves if the page is saved.
|
||||
|
||||
```js
|
||||
const { BrowserWindow } = require('electron')
|
||||
|
||||
const win = new BrowserWindow()
|
||||
|
||||
win.loadURL('https://github.com')
|
||||
|
||||
@@ -99,9 +99,11 @@ with an array of misspelt words when complete.
|
||||
|
||||
An example of using [node-spellchecker][spellchecker] as provider:
|
||||
|
||||
```js @ts-expect-error=[2,6]
|
||||
```js @ts-expect-error=[3,8]
|
||||
const { webFrame } = require('electron')
|
||||
|
||||
const spellChecker = require('spellchecker')
|
||||
|
||||
webFrame.setSpellCheckProvider('en-US', {
|
||||
spellCheck (words, callback) {
|
||||
setTimeout(() => {
|
||||
@@ -212,11 +214,14 @@ caches.
|
||||
|
||||
```js
|
||||
const { webFrame } = require('electron')
|
||||
|
||||
console.log(webFrame.getResourceUsage())
|
||||
```
|
||||
|
||||
This will generate:
|
||||
|
||||
<!-- eslint-skip -->
|
||||
|
||||
```js
|
||||
{
|
||||
images: {
|
||||
|
||||
@@ -22,5 +22,6 @@ const oldPath = document.querySelector('input').files[0].path
|
||||
|
||||
// After
|
||||
const { webUtils } = require('electron')
|
||||
|
||||
const newPath = webUtils.getPathForFile(document.querySelector('input').files[0])
|
||||
```
|
||||
|
||||
@@ -987,6 +987,7 @@ webview.send('ping')
|
||||
```js
|
||||
// In guest page.
|
||||
const { ipcRenderer } = require('electron')
|
||||
|
||||
ipcRenderer.on('ping', () => {
|
||||
ipcRenderer.sendToHost('pong')
|
||||
})
|
||||
|
||||
@@ -12,6 +12,32 @@ This document uses the following convention to categorize breaking changes:
|
||||
* **Deprecated:** An API was marked as deprecated. The API will continue to function, but will emit a deprecation warning, and will be removed in a future release.
|
||||
* **Removed:** An API or feature was removed, and is no longer supported by Electron.
|
||||
|
||||
## Planned Breaking API Changes (38.0)
|
||||
|
||||
### Removed: macOS 11 support
|
||||
|
||||
macOS 11 (Big Sur) is no longer supported by [Chromium](https://chromium-review.googlesource.com/c/chromium/src/+/6594615).
|
||||
|
||||
Older versions of Electron will continue to run on Big Sur, but macOS 12 (Monterey)
|
||||
or later will be required to run Electron v38.0.0 and higher.
|
||||
|
||||
### Behavior Changed: window.open popups are always resizable
|
||||
|
||||
Per current [WHATWG spec](https://html.spec.whatwg.org/multipage/nav-history-apis.html#dom-open-dev), the `window.open` API will now always create a resizable popup window.
|
||||
|
||||
To restore previous behavior:
|
||||
|
||||
```js
|
||||
webContents.setWindowOpenHandler((details) => {
|
||||
return {
|
||||
action: 'allow',
|
||||
overrideBrowserWindowOptions: {
|
||||
resizable: details.features.includes('resizable=yes')
|
||||
}
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
## Planned Breaking API Changes (37.0)
|
||||
|
||||
### Utility Process unhandled rejection behavior change
|
||||
@@ -27,6 +53,16 @@ process.on('unhandledRejection', () => {
|
||||
})
|
||||
```
|
||||
|
||||
### Behavior Changed: `process.exit()` kills utility process synchronously
|
||||
|
||||
Calling `process.exit()` in a utility process will now kill the utility process synchronously.
|
||||
This brings the behavior of `process.exit()` in line with Node.js behavior.
|
||||
|
||||
Please refer to the
|
||||
[Node.js docs](https://nodejs.org/docs/latest-v22.x/api/process.html#processexitcode) and
|
||||
[PR #45690](https://github.com/electron/electron/pull/45690) to understand the potential
|
||||
implications of that, e.g., when calling `console.log()` before `process.exit()`.
|
||||
|
||||
### Behavior Changed: WebUSB and WebSerial Blocklist Support
|
||||
|
||||
[WebUSB](https://developer.mozilla.org/en-US/docs/Web/API/WebUSB_API) and [Web Serial](https://developer.mozilla.org/en-US/docs/Web/API/Web_Serial_API) now support the [WebUSB Blocklist](https://wicg.github.io/webusb/#blocklist) and [Web Serial Blocklist](https://wicg.github.io/serial/#blocklist) used by Chromium and outlined in their respective specifications.
|
||||
@@ -141,7 +177,7 @@ On Linux, the required portal version for file dialogs has been reverted
|
||||
to 3 from 4. Using the `defaultPath` option of the Dialog API is not
|
||||
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)
|
||||
[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.
|
||||
|
||||
|
||||
@@ -7,11 +7,8 @@ Follow the guidelines below for building **Electron itself** on Linux, for the p
|
||||
## Prerequisites
|
||||
|
||||
* At least 25GB disk space and 8GB RAM.
|
||||
* Python >= 3.7.
|
||||
* Node.js. There are various ways to install Node. You can download
|
||||
source code from [nodejs.org](https://nodejs.org) and compile it.
|
||||
Doing so permits installing Node on your own home directory as a standard user.
|
||||
Or try repositories such as [NodeSource](https://nodesource.com/blog/nodejs-v012-iojs-and-the-nodesource-linux-repositories).
|
||||
* Python >= 3.9.
|
||||
* [Node.js](https://nodejs.org/download/) >= 22.12.0
|
||||
* [clang](https://clang.llvm.org/get_started.html) 3.4 or later.
|
||||
* Development headers of GTK 3 and libnotify.
|
||||
|
||||
|
||||
@@ -10,8 +10,8 @@ Follow the guidelines below for building **Electron itself** on macOS, for the p
|
||||
* [Xcode](https://developer.apple.com/technologies/tools/). The exact version
|
||||
needed depends on what branch you are building, but the latest version of
|
||||
Xcode is generally a good bet for building `main`.
|
||||
* [node.js](https://nodejs.org) (external)
|
||||
* Python >= 3.7
|
||||
* Python >= 3.9
|
||||
* [Node.js](https://nodejs.org/download/) >= 22.12.0
|
||||
|
||||
### Arm64-specific prerequisites
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ Follow the guidelines below for building **Electron itself** on Windows, for the
|
||||
set a few environment variables to point the toolchains to your installation path.
|
||||
* `vs2022_install = DRIVE:\path\to\Microsoft Visual Studio\2022\Community`, replacing `2022` and `Community` with your installed versions and replacing `DRIVE:` with the drive that Visual Studio is on. Often, this will be `C:`.
|
||||
* `WINDOWSSDKDIR = DRIVE:\path\to\Windows Kits\10`, replacing `DRIVE:` with the drive that Windows Kits is on. Often, this will be `C:`.
|
||||
* [Node.js](https://nodejs.org/download/)
|
||||
* [Node.js](https://nodejs.org/download/) >= 22.12.0
|
||||
* [Git](https://git-scm.com)
|
||||
* Debugging Tools for Windows of Windows SDK 10.0.15063.468 if you plan on
|
||||
creating a full distribution since `symstore.exe` is used for creating a symbol
|
||||
|
||||
@@ -165,8 +165,10 @@ An example of the contents of this file can be found [here](https://github.com/e
|
||||
|
||||
Add your module to the module list found at `"lib/browser/api/module-list.ts"` like so:
|
||||
|
||||
<!-- eslint-disable semi -->
|
||||
|
||||
```ts title='lib/browser/api/module-list.ts' @ts-nocheck
|
||||
export const browserModuleList: ElectronInternal.ModuleEntry[] = [
|
||||
{ name: 'apiName', loader: () => require('./api-name') },
|
||||
{ name: 'apiName', loader: () => require('./api-name') }
|
||||
];
|
||||
```
|
||||
|
||||
@@ -81,6 +81,11 @@ $ git commit
|
||||
|
||||
Note that multiple commits get squashed when they are landed.
|
||||
|
||||
#### Commit signing
|
||||
|
||||
The `electron/electron` repo enforces [commit signatures](https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits) for all incoming PRs.
|
||||
To sign your commits, see GitHub's documentation on [Telling Git about your signing key](https://docs.github.com/en/authentication/managing-commit-signature-verification/telling-git-about-your-signing-key).
|
||||
|
||||
#### Commit message guidelines
|
||||
|
||||
A good commit message should describe what changed and why. The Electron project
|
||||
|
||||
12
docs/faq.md
12
docs/faq.md
@@ -67,6 +67,7 @@ code from this:
|
||||
|
||||
```js
|
||||
const { app, Tray } = require('electron')
|
||||
|
||||
app.whenReady().then(() => {
|
||||
const tray = new Tray('/path/to/icon.png')
|
||||
tray.setTitle('hello world')
|
||||
@@ -77,6 +78,7 @@ to this:
|
||||
|
||||
```js
|
||||
const { app, Tray } = require('electron')
|
||||
|
||||
let tray = null
|
||||
app.whenReady().then(() => {
|
||||
tray = new Tray('/path/to/icon.png')
|
||||
@@ -95,6 +97,7 @@ To solve this, you can turn off node integration in Electron:
|
||||
```js
|
||||
// In the main process.
|
||||
const { BrowserWindow } = require('electron')
|
||||
|
||||
const win = new BrowserWindow({
|
||||
webPreferences: {
|
||||
nodeIntegration: false
|
||||
@@ -143,6 +146,7 @@ To achieve this goal, set the background in the constructor for [BrowserWindow][
|
||||
|
||||
```js
|
||||
const { BrowserWindow } = require('electron')
|
||||
|
||||
const win = new BrowserWindow({
|
||||
backgroundColor: '#fff'
|
||||
})
|
||||
@@ -152,6 +156,14 @@ The effect is visible only on (some?) LCD screens. Even if you don't see a diffe
|
||||
|
||||
Notice that just setting the background in the CSS does not have the desired effect.
|
||||
|
||||
## Class inheritance does not work with Electron built-in modules
|
||||
|
||||
Electron classes cannot be subclassed with the [`extends`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/extends)
|
||||
keyword (also known as class inheritance). This feature was never implemented in Electron due
|
||||
to the added complexity it would add to C++/JavaScript interop in Electron's internals.
|
||||
|
||||
For more information, see [electron/electron#23](https://github.com/electron/electron/issues/23).
|
||||
|
||||
[memory-management]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Memory_Management
|
||||
[closures]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Closures
|
||||
[storage]: https://developer.mozilla.org/en-US/docs/Web/API/Storage
|
||||
|
||||
6
docs/fiddles/.eslintrc.json
Normal file
6
docs/fiddles/.eslintrc.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"extends": "standard",
|
||||
"rules": {
|
||||
"import/order": "off"
|
||||
}
|
||||
}
|
||||
@@ -42,6 +42,7 @@ Read a file in the ASAR archive:
|
||||
|
||||
```js
|
||||
const fs = require('node:fs')
|
||||
|
||||
fs.readFileSync('/path/to/example.asar/file.txt')
|
||||
```
|
||||
|
||||
@@ -49,6 +50,7 @@ List all files under the root of the archive:
|
||||
|
||||
```js
|
||||
const fs = require('node:fs')
|
||||
|
||||
fs.readdirSync('/path/to/example.asar')
|
||||
```
|
||||
|
||||
@@ -62,6 +64,7 @@ You can also display a web page in an ASAR archive with `BrowserWindow`:
|
||||
|
||||
```js
|
||||
const { BrowserWindow } = require('electron')
|
||||
|
||||
const win = new BrowserWindow()
|
||||
|
||||
win.loadURL('file:///path/to/example.asar/static/index.html')
|
||||
@@ -91,6 +94,7 @@ content of an ASAR archive as a file. For this purpose you can use the built-in
|
||||
|
||||
```js
|
||||
const originalFs = require('original-fs')
|
||||
|
||||
originalFs.readFileSync('/path/to/example.asar')
|
||||
```
|
||||
|
||||
@@ -99,6 +103,7 @@ the `fs` module:
|
||||
|
||||
```js
|
||||
const fs = require('node:fs')
|
||||
|
||||
process.noAsar = true
|
||||
fs.readFileSync('/path/to/example.asar')
|
||||
```
|
||||
|
||||
@@ -74,45 +74,22 @@ describe('keyboard input', () => {
|
||||
Furthermore, WebdriverIO allows you to access Electron APIs to get static information about your application:
|
||||
|
||||
```js @ts-nocheck
|
||||
import { browser, $, expect } from '@wdio/globals'
|
||||
import { browser } from '@wdio/globals'
|
||||
|
||||
describe('when the make smaller button is clicked', () => {
|
||||
it('should decrease the window height and width by 10 pixels', async () => {
|
||||
const boundsBefore = await browser.electron.browserWindow('getBounds')
|
||||
expect(boundsBefore.width).toEqual(210)
|
||||
expect(boundsBefore.height).toEqual(310)
|
||||
|
||||
await $('.make-smaller').click()
|
||||
const boundsAfter = await browser.electron.browserWindow('getBounds')
|
||||
expect(boundsAfter.width).toEqual(200)
|
||||
expect(boundsAfter.height).toEqual(300)
|
||||
})
|
||||
})
|
||||
```
|
||||
|
||||
or to retrieve other Electron process information:
|
||||
|
||||
```js @ts-nocheck
|
||||
import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
import { browser, expect } from '@wdio/globals'
|
||||
|
||||
const packageJson = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'package.json'), { encoding: 'utf-8' }))
|
||||
const { name, version } = packageJson
|
||||
|
||||
describe('electron APIs', () => {
|
||||
it('should retrieve app metadata through the electron API', async () => {
|
||||
const appName = await browser.electron.app('getName')
|
||||
expect(appName).toEqual(name)
|
||||
const appVersion = await browser.electron.app('getVersion')
|
||||
expect(appVersion).toEqual(version)
|
||||
})
|
||||
|
||||
it('should pass args through to the launched application', async () => {
|
||||
// custom args are set in the wdio.conf.js file as they need to be set before WDIO starts
|
||||
const argv = await browser.electron.mainProcess('argv')
|
||||
expect(argv).toContain('--foo')
|
||||
expect(argv).toContain('--bar=baz')
|
||||
describe('trigger message modal', async () => {
|
||||
it('message modal can be triggered from a test', async () => {
|
||||
await browser.electron.execute(
|
||||
(electron, param1, param2, param3) => {
|
||||
const appWindow = electron.BrowserWindow.getFocusedWindow()
|
||||
electron.dialog.showMessageBox(appWindow, {
|
||||
message: 'Hello World!',
|
||||
detail: `${param1} + ${param2} + ${param3} = ${param1 + param2 + param3}`
|
||||
})
|
||||
},
|
||||
1,
|
||||
2,
|
||||
3
|
||||
)
|
||||
})
|
||||
})
|
||||
```
|
||||
@@ -165,6 +142,7 @@ ChromeDriver and where to find the binary of your Electron app:
|
||||
|
||||
```js title='test.js' @ts-expect-error=[1]
|
||||
const webdriver = require('selenium-webdriver')
|
||||
|
||||
const driver = new webdriver.Builder()
|
||||
// The "9515" is the port opened by ChromeDriver.
|
||||
.usingServer('http://localhost:9515')
|
||||
@@ -204,7 +182,7 @@ npm install --save-dev @playwright/test
|
||||
```
|
||||
|
||||
:::caution Dependencies
|
||||
This tutorial was written with `@playwright/test@1.41.1`. Check out
|
||||
This tutorial was written with `@playwright/test@1.52.0`. Check out
|
||||
[Playwright's releases][playwright-releases] page to learn about
|
||||
changes that might affect the code below.
|
||||
:::
|
||||
@@ -216,10 +194,10 @@ To point this API to your Electron app, you can pass the path to your main proce
|
||||
entry point (here, it is `main.js`).
|
||||
|
||||
```js {5} @ts-nocheck
|
||||
const { test, _electron: electron } = require('@playwright/test')
|
||||
import { test, _electron as electron } from '@playwright/test'
|
||||
|
||||
test('launch app', async () => {
|
||||
const electronApp = await electron.launch({ args: ['main.js'] })
|
||||
const electronApp = await electron.launch({ args: ['.'] })
|
||||
// close app
|
||||
await electronApp.close()
|
||||
})
|
||||
@@ -229,10 +207,10 @@ After that, you will access to an instance of Playwright's `ElectronApp` class.
|
||||
is a powerful class that has access to main process modules for example:
|
||||
|
||||
```js {5-10} @ts-nocheck
|
||||
const { test, _electron: electron } = require('@playwright/test')
|
||||
import { test, _electron as electron } from '@playwright/test'
|
||||
|
||||
test('get isPackaged', async () => {
|
||||
const electronApp = await electron.launch({ args: ['main.js'] })
|
||||
const electronApp = await electron.launch({ args: ['.'] })
|
||||
const isPackaged = await electronApp.evaluate(async ({ app }) => {
|
||||
// This runs in Electron's main process, parameter here is always
|
||||
// the result of the require('electron') in the main app script.
|
||||
@@ -248,10 +226,10 @@ It can also create individual [Page][playwright-page] objects from Electron Brow
|
||||
For example, to grab the first BrowserWindow and save a screenshot:
|
||||
|
||||
```js {6-7} @ts-nocheck
|
||||
const { test, _electron: electron } = require('@playwright/test')
|
||||
import { test, _electron as electron } from '@playwright/test'
|
||||
|
||||
test('save screenshot', async () => {
|
||||
const electronApp = await electron.launch({ args: ['main.js'] })
|
||||
const electronApp = await electron.launch({ args: ['.'] })
|
||||
const window = await electronApp.firstWindow()
|
||||
await window.screenshot({ path: 'intro.png' })
|
||||
// close app
|
||||
@@ -263,7 +241,7 @@ Putting all this together using the Playwright test-runner, let's create a `exam
|
||||
test file with a single test and assertion:
|
||||
|
||||
```js title='example.spec.js' @ts-nocheck
|
||||
const { test, expect, _electron: electron } = require('@playwright/test')
|
||||
import { test, expect, _electron as electron } from '@playwright/test'
|
||||
|
||||
test('example test', async () => {
|
||||
const electronApp = await electron.launch({ args: ['.'] })
|
||||
@@ -317,9 +295,10 @@ To create a custom driver, we'll use Node.js' [`child_process`](https://nodejs.o
|
||||
The test suite will spawn the Electron process, then establish a simple messaging protocol:
|
||||
|
||||
```js title='testDriver.js' @ts-nocheck
|
||||
const childProcess = require('node:child_process')
|
||||
const electronPath = require('electron')
|
||||
|
||||
const childProcess = require('node:child_process')
|
||||
|
||||
// spawn the process
|
||||
const env = { /* ... */ }
|
||||
const stdio = ['inherit', 'inherit', 'inherit', 'ipc']
|
||||
@@ -436,8 +415,10 @@ framework of your choosing. The following example uses
|
||||
or Mocha would work as well:
|
||||
|
||||
```js title='test.js' @ts-nocheck
|
||||
const test = require('ava')
|
||||
const electronPath = require('electron')
|
||||
|
||||
const test = require('ava')
|
||||
|
||||
const { TestDriver } = require('./testDriver')
|
||||
|
||||
const app = new TestDriver({
|
||||
|
||||
@@ -78,6 +78,8 @@ See the [Mac App Store Guide][].
|
||||
|
||||
## Signing Windows builds
|
||||
|
||||
### Using traditional certificates
|
||||
|
||||
Before you can code sign your application, you need to acquire a code signing
|
||||
certificate. Unlike Apple, Microsoft allows developers to purchase those
|
||||
certificates on the open market. They are usually sold by the same companies
|
||||
@@ -117,13 +119,13 @@ expose configuration options through a `windowsSign` property. You can either us
|
||||
to sign files directly - or use the same `windowsSign` configuration across Electron
|
||||
Forge, [`@electron/packager`][], [`electron-winstaller`][], and [`electron-wix-msi`][].
|
||||
|
||||
### Using Electron Forge
|
||||
#### Using Electron Forge
|
||||
|
||||
Electron Forge is the recommended way to sign your app as well as your `Squirrel.Windows`
|
||||
and `WiX MSI` installers. Detailed instructions on how to configure your application can
|
||||
be found in the [Electron Forge Code Signing Tutorial](https://www.electronforge.io/guides/code-signing/code-signing-windows).
|
||||
|
||||
### Using Electron Packager
|
||||
#### Using Electron Packager
|
||||
|
||||
If you're not using an integrated build pipeline like Forge, you
|
||||
are likely using [`@electron/packager`][], which includes [`@electron/windows-sign`][].
|
||||
@@ -146,7 +148,7 @@ packager({
|
||||
})
|
||||
```
|
||||
|
||||
### Using electron-winstaller (Squirrel.Windows)
|
||||
#### Using electron-winstaller (Squirrel.Windows)
|
||||
|
||||
[`electron-winstaller`][] is a package that can generate Squirrel.Windows installers for your
|
||||
Electron app. This is the tool used under the hood by Electron Forge's
|
||||
@@ -178,7 +180,7 @@ try {
|
||||
|
||||
For full configuration options, check out the [`electron-winstaller`][] repository!
|
||||
|
||||
### Using electron-wix-msi (WiX MSI)
|
||||
#### Using electron-wix-msi (WiX MSI)
|
||||
|
||||
[`electron-wix-msi`][] is a package that can generate MSI installers for your
|
||||
Electron app. This is the tool used under the hood by Electron Forge's [MSI Maker][maker-msi].
|
||||
@@ -221,11 +223,32 @@ await msiCreator.compile()
|
||||
|
||||
For full configuration options, check out the [`electron-wix-msi`][] repository!
|
||||
|
||||
### Using Electron Builder
|
||||
#### Using Electron Builder
|
||||
|
||||
Electron Builder comes with a custom solution for signing your application. You
|
||||
can find [its documentation here](https://www.electron.build/code-signing).
|
||||
|
||||
### Using Azure Trusted Signing
|
||||
|
||||
[Azure Trusted Signing][] is Microsoft's modern cloud-based alternative to EV certificates.
|
||||
It is the cheapest option for code signing on Windows, and it gets rid of SmartScreen warnings.
|
||||
|
||||
As of May 2025, Azure Trusted Signing is [available][trusted-signing-availability] to US and
|
||||
Canada-based organizations with 3+ years of verifiable business history. Microsoft is looking
|
||||
to make the program more widely available. If you're reading this at a later point, it could
|
||||
make sense to check if the eligibility criteria have changed.
|
||||
|
||||
#### Using Electron Forge
|
||||
|
||||
Electron Forge is the recommended way to sign your app as well as your `Squirrel.Windows`
|
||||
and `WiX MSI` installers. Instructions for Azure Trusted Signing can be found
|
||||
[here][forge-trusted-signing].
|
||||
|
||||
#### Using Electron Builder
|
||||
|
||||
The Electron Builder documentation for Azure Trusted Signing can be found
|
||||
[here][builder-trusted-signing].
|
||||
|
||||
### Signing Windows Store applications
|
||||
|
||||
See the [Windows Store Guide][].
|
||||
@@ -243,3 +266,7 @@ See the [Windows Store Guide][].
|
||||
[windows store guide]: ./windows-store-guide.md
|
||||
[maker-squirrel]: https://www.electronforge.io/config/makers/squirrel.windows
|
||||
[maker-msi]: https://www.electronforge.io/config/makers/wix-msi
|
||||
[azure trusted signing]: https://azure.microsoft.com/en-us/products/trusted-signing
|
||||
[trusted-signing-availability]: https://techcommunity.microsoft.com/blog/microsoft-security-blog/trusted-signing-public-preview-update/4399713
|
||||
[forge-trusted-signing]: https://www.electronforge.io/guides/code-signing/code-signing-windows#using-azure-trusted-signing
|
||||
[builder-trusted-signing]: https://www.electron.build/code-signing-win#using-azure-trusted-signing-beta
|
||||
|
||||
@@ -76,6 +76,7 @@ use the native UI to control the window.
|
||||
|
||||
```js
|
||||
const { BrowserWindow } = require('electron')
|
||||
|
||||
const win = new BrowserWindow({ titleBarStyle: 'customButtonsOnHover' })
|
||||
```
|
||||
|
||||
@@ -89,6 +90,7 @@ by a fixed amount.
|
||||
|
||||
```js title='main.js'
|
||||
const { BrowserWindow } = require('electron')
|
||||
|
||||
const win = new BrowserWindow({ titleBarStyle: 'hiddenInset' })
|
||||
```
|
||||
|
||||
@@ -98,6 +100,7 @@ constructor.
|
||||
|
||||
```js title='main.js'
|
||||
const { BrowserWindow } = require('electron')
|
||||
|
||||
const win = new BrowserWindow({
|
||||
titleBarStyle: 'hidden',
|
||||
trafficLightPosition: { x: 10, y: 10 }
|
||||
@@ -112,6 +115,7 @@ on the value of its boolean parameter.
|
||||
|
||||
```js title='main.js'
|
||||
const { BrowserWindow } = require('electron')
|
||||
|
||||
const win = new BrowserWindow()
|
||||
// hides the traffic lights
|
||||
win.setWindowButtonVisibility(false)
|
||||
@@ -149,6 +153,7 @@ default to the standard system height:
|
||||
|
||||
```js title='main.js'
|
||||
const { BrowserWindow } = require('electron')
|
||||
|
||||
const win = new BrowserWindow({
|
||||
titleBarStyle: 'hidden',
|
||||
titleBarOverlay: {
|
||||
|
||||
@@ -62,6 +62,7 @@ API:
|
||||
|
||||
```js title='main.js'
|
||||
const { BrowserWindow } = require('electron')
|
||||
|
||||
const win = new BrowserWindow()
|
||||
win.setIgnoreMouseEvents(true)
|
||||
```
|
||||
@@ -75,6 +76,7 @@ allowing events such as `mouseleave` to be emitted:
|
||||
|
||||
```js title='main.js'
|
||||
const { BrowserWindow, ipcMain } = require('electron')
|
||||
|
||||
const path = require('node:path')
|
||||
|
||||
const win = new BrowserWindow({
|
||||
|
||||
@@ -135,6 +135,7 @@ Finally, the `main.js` file represents the main process and contains the actual
|
||||
|
||||
```js
|
||||
const { app, BrowserWindow, ipcMain, nativeTheme } = require('electron')
|
||||
|
||||
const path = require('node:path')
|
||||
|
||||
const createWindow = () => {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
# Debugging in VSCode
|
||||
|
||||
This guide goes over how to set up VSCode debugging for both your own Electron project as well as the native Electron codebase.
|
||||
This guide goes over how to set up VSCode debugging for both your own Electron
|
||||
project as well as the native Electron codebase.
|
||||
|
||||
## Debugging your Electron app
|
||||
|
||||
@@ -9,8 +10,8 @@ This guide goes over how to set up VSCode debugging for both your own Electron p
|
||||
#### 1. Open an Electron project in VSCode.
|
||||
|
||||
```sh
|
||||
$ git clone git@github.com:electron/electron-quick-start.git
|
||||
$ code electron-quick-start
|
||||
$ npx create-electron-app@latest my-app
|
||||
$ code my-app
|
||||
```
|
||||
|
||||
#### 2. Add a file `.vscode/launch.json` with the following configuration:
|
||||
@@ -37,23 +38,27 @@ $ code electron-quick-start
|
||||
|
||||
#### 3. Debugging
|
||||
|
||||
Set some breakpoints in `main.js`, and start debugging in the [Debug View](https://code.visualstudio.com/docs/editor/debugging). You should be able to hit the breakpoints.
|
||||
|
||||
Here is a pre-configured project that you can download and directly debug in VSCode: https://github.com/octref/vscode-electron-debug/tree/master/electron-quick-start
|
||||
Set some breakpoints in `main.js`, and start debugging in the
|
||||
[Debug View](https://code.visualstudio.com/docs/editor/debugging). You should
|
||||
be able to hit the breakpoints.
|
||||
|
||||
## Debugging the Electron codebase
|
||||
|
||||
If you want to build Electron from source and modify the native Electron codebase, this section will help you in testing your modifications.
|
||||
If you want to build Electron from source and modify the native Electron codebase,
|
||||
this section will help you in testing your modifications.
|
||||
|
||||
For those unsure where to acquire this code or how to build it, [Electron's Build Tools](https://github.com/electron/build-tools) automates and explains most of this process. If you wish to manually set up the environment, you can instead use these [build instructions](../development/build-instructions-gn.md).
|
||||
For those unsure where to acquire this code or how to build it,
|
||||
[Electron's Build Tools](https://github.com/electron/build-tools) automates and
|
||||
explains most of this process. If you wish to manually set up the environment,
|
||||
you can instead use these [build instructions](../development/build-instructions-gn.md).
|
||||
|
||||
### Windows (C++)
|
||||
|
||||
#### 1. Open an Electron project in VSCode.
|
||||
|
||||
```sh
|
||||
$ git clone git@github.com:electron/electron-quick-start.git
|
||||
$ code electron-quick-start
|
||||
$ npx create-electron-app@latest my-app
|
||||
$ code my-app
|
||||
```
|
||||
|
||||
#### 2. Add a file `.vscode/launch.json` with the following configuration:
|
||||
@@ -86,14 +91,22 @@ $ code electron-quick-start
|
||||
|
||||
**Configuration Notes**
|
||||
|
||||
* `cppvsdbg` requires the [built-in C/C++ extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools) be enabled.
|
||||
* `cppvsdbg` requires the
|
||||
[built-in C/C++ extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools)
|
||||
be enabled.
|
||||
* `${workspaceFolder}` is the full path to Chromium's `src` directory.
|
||||
* `your-executable-location` will be one of the following depending on a few items:
|
||||
* `Testing`: If you are using the default settings of [Electron's Build-Tools](https://github.com/electron/build-tools) or the default instructions when [building from source](../development/build-instructions-gn.md#building).
|
||||
* `Testing`: If you are using the default settings of
|
||||
[Electron's Build-Tools](https://github.com/electron/build-tools) or the default
|
||||
instructions when [building from source](../development/build-instructions-gn.md#building).
|
||||
* `Release`: If you built a Release build rather than a Testing build.
|
||||
* `your-directory-name`: If you modified this during your build process from the default, this will be whatever you specified.
|
||||
* The `args` array string `"your-electron-project-path"` should be the absolute path to either the directory or `main.js` file of the Electron project you are using for testing. In this example, it should be your path to `electron-quick-start`.
|
||||
* `your-directory-name`: If you modified this during your build process from
|
||||
the default, this will be whatever you specified.
|
||||
* The `args` array string `"your-electron-project-path"` should be the absolute
|
||||
path to either the directory or `main.js` file of the Electron project you are
|
||||
using for testing. In this example, it should be your path to `my-app`.
|
||||
|
||||
#### 3. Debugging
|
||||
|
||||
Set some breakpoints in the .cc files of your choosing in the native Electron C++ code, and start debugging in the [Debug View](https://code.visualstudio.com/docs/editor/debugging).
|
||||
Set some breakpoints in the .cc files of your choosing in the native Electron C++
|
||||
code, and start debugging in the [Debug View](https://code.visualstudio.com/docs/editor/debugging).
|
||||
|
||||
@@ -35,15 +35,16 @@ Using the [React Developer Tools][react-devtools] as an example:
|
||||
|
||||
```js
|
||||
const { app, session } = require('electron')
|
||||
const path = require('node:path')
|
||||
|
||||
const os = require('node:os')
|
||||
|
||||
const path = require('node:path')
|
||||
|
||||
// on macOS
|
||||
const reactDevToolsPath = path.join(
|
||||
os.homedir(),
|
||||
'/Library/Application Support/Google/Chrome/Default/Extensions/fmkadmapgofadopljbjfkapdkoienihi/4.9.0_0'
|
||||
)
|
||||
|
||||
|
||||
app.whenReady().then(async () => {
|
||||
await session.defaultSession.loadExtension(reactDevToolsPath)
|
||||
})
|
||||
|
||||
@@ -9,10 +9,11 @@ check out our [Electron Versioning](./electron-versioning.md) doc.
|
||||
|
||||
| Electron | Alpha | Beta | Stable | EOL | Chrome | Node | Supported |
|
||||
| ------- | ----- | ------- | ------ | ------ | ---- | ---- | ---- |
|
||||
| 37.0.0 | 2025-May-01 | 2025-May-28 | 2025-Jun-24 | 2026-Jan-13 | M138 | TBD | ✅ |
|
||||
| 38.0.0 | 2025-Jun-26 | 2025-Aug-06 | 2025-Sep-02 | 2026-Mar-10 | M140 | TBD | ✅ |
|
||||
| 37.0.0 | 2025-May-01 | 2025-May-28 | 2025-Jun-24 | 2026-Jan-13 | M138 | v22.16 | ✅ |
|
||||
| 36.0.0 | 2025-Mar-06 | 2025-Apr-02 | 2025-Apr-29 | 2025-Oct-28 | M136 | v22.14 | ✅ |
|
||||
| 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 | ✅ |
|
||||
| 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 | 🚫 |
|
||||
| 31.0.0 | 2024-Apr-18 | 2024-May-15 | 2024-Jun-11 | 2025-Jan-14 | M126 | v20.14 | 🚫 |
|
||||
|
||||
@@ -143,7 +143,7 @@ The `electron/electron` repository also enforces squash merging, so you only nee
|
||||
|
||||
## Historical versioning (Electron 1.X)
|
||||
|
||||
Electron versions _< 2.0_ did not conform to the [SemVer](https://semver.org) spec: major versions corresponded to end-user API changes, minor versions corresponded to Chromium major releases, and patch versions corresponded to new features and bug fixes. While convenient for developers merging features, it creates problems for developers of client-facing applications. The QA testing cycles of major apps like Slack, Teams, Skype, VS Code, and GitHub Desktop can be lengthy and stability is a highly desired outcome. There is a high risk in adopting new features while trying to absorb bug fixes.
|
||||
Electron versions _< 2.0_ did not conform to the [SemVer](https://semver.org) spec: major versions corresponded to end-user API changes, minor versions corresponded to Chromium major releases, and patch versions corresponded to new features and bug fixes. While convenient for developers merging features, it creates problems for developers of client-facing applications. The QA testing cycles of major apps like Slack, Teams, VS Code, and GitHub Desktop can be lengthy and stability is a highly desired outcome. There is a high risk in adopting new features while trying to absorb bug fixes.
|
||||
|
||||
Here is an example of the 1.x strategy:
|
||||
|
||||
|
||||
@@ -85,6 +85,8 @@ The `@babel/plugin-transform-modules-commonjs` plugin will transform
|
||||
ESM imports down to `require` calls. The exact syntax will depend on the
|
||||
[`importInterop` setting](https://babeljs.io/docs/babel-plugin-transform-modules-commonjs#importinterop).
|
||||
|
||||
<!-- eslint-skip -->
|
||||
|
||||
```js @nolint @ts-nocheck title='@babel/plugin-transform-modules-commonjs'
|
||||
import foo from "foo";
|
||||
import { bar } from "bar";
|
||||
|
||||
@@ -48,7 +48,7 @@ The nodeCliInspect fuse toggles whether the `--inspect`, `--inspect-brk`, etc. f
|
||||
|
||||
**@electron/fuses:** `FuseV1Options.EnableEmbeddedAsarIntegrityValidation`
|
||||
|
||||
The embeddedAsarIntegrityValidation fuse toggles an experimental feature on macOS that validates the content of the `app.asar` file when it is loaded. This feature is designed to have a minimal performance impact but may marginally slow down file reads from inside the `app.asar` archive.
|
||||
The embeddedAsarIntegrityValidation fuse toggles an experimental feature on macOS and Windows that validates the content of the `app.asar` file when it is loaded. This feature is designed to have a minimal performance impact but may marginally slow down file reads from inside the `app.asar` archive.
|
||||
|
||||
For more information on how to use asar integrity validation please read the [Asar Integrity](asar-integrity.md) documentation.
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ Here is an example that shows how to use In-App Purchases in Electron. You'll ha
|
||||
```js
|
||||
// Main process
|
||||
const { inAppPurchase } = require('electron')
|
||||
|
||||
const PRODUCT_IDS = ['id1', 'id2']
|
||||
|
||||
// Listen for transactions as soon as possible.
|
||||
|
||||
@@ -52,6 +52,7 @@ In the main process, set an IPC listener on the `set-title` channel with the `ip
|
||||
|
||||
```js {6-10,22} title='main.js (Main Process)'
|
||||
const { app, BrowserWindow, ipcMain } = require('electron')
|
||||
|
||||
const path = require('node:path')
|
||||
|
||||
// ...
|
||||
@@ -183,6 +184,7 @@ provided to the renderer process. Please refer to
|
||||
|
||||
```js {6-13,25} title='main.js (Main Process)'
|
||||
const { app, BrowserWindow, dialog, ipcMain } = require('electron')
|
||||
|
||||
const path = require('node:path')
|
||||
|
||||
// ...
|
||||
@@ -334,6 +336,7 @@ response.
|
||||
|
||||
```js title='main.js (Main Process)'
|
||||
const { ipcMain } = require('electron')
|
||||
|
||||
ipcMain.on('synchronous-message', (event, arg) => {
|
||||
console.log(arg) // prints "ping" in the Node console
|
||||
event.returnValue = 'pong'
|
||||
@@ -378,6 +381,7 @@ target renderer.
|
||||
|
||||
```js {11-26} title='main.js (Main Process)'
|
||||
const { app, BrowserWindow, Menu, ipcMain } = require('electron')
|
||||
|
||||
const path = require('node:path')
|
||||
|
||||
function createWindow () {
|
||||
@@ -412,6 +416,8 @@ function createWindow () {
|
||||
For the purposes of the tutorial, it's important to note that the `click` handler
|
||||
sends a message (either `1` or `-1`) to the renderer process through the `update-counter` channel.
|
||||
|
||||
<!-- eslint-skip -->
|
||||
|
||||
```js @ts-type={mainWindow:Electron.BrowserWindow}
|
||||
click: () => mainWindow.webContents.send('update-counter', -1)
|
||||
```
|
||||
|
||||
@@ -27,6 +27,7 @@ control our application lifecycle and create a native browser window.
|
||||
|
||||
```js
|
||||
const { app, BrowserWindow, shell } = require('electron')
|
||||
|
||||
const path = require('node:path')
|
||||
```
|
||||
|
||||
|
||||
@@ -303,6 +303,7 @@ without having to step through the isolated world.
|
||||
|
||||
```js title='main.js (Main Process)'
|
||||
const { BrowserWindow, app, MessageChannelMain } = require('electron')
|
||||
|
||||
const path = require('node:path')
|
||||
|
||||
app.whenReady().then(async () => {
|
||||
|
||||
1638
docs/tutorial/native-code-and-electron-cpp-linux.md
Normal file
1638
docs/tutorial/native-code-and-electron-cpp-linux.md
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1075,7 +1075,7 @@ NODE_API_MODULE(objc_addon, Init)
|
||||
You're so close! We now have working Objective-C and thread-safe ways to expose methods and events to JavaScript. In this final step, let's create a JavaScript wrapper in `js/index.js` to provide a more friendly API:
|
||||
|
||||
```js title='js/index.js' @ts-expect-error=[10]
|
||||
const EventEmitter = require('events')
|
||||
const EventEmitter = require('node:events')
|
||||
|
||||
class ObjcMacosAddon extends EventEmitter {
|
||||
constructor () {
|
||||
|
||||
1175
docs/tutorial/native-code-and-electron-swift-macos.md
Normal file
1175
docs/tutorial/native-code-and-electron-swift-macos.md
Normal file
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user