mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
Compare commits
41 Commits
v12.0.0-ni
...
v12.0.0-ni
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b823b74378 | ||
|
|
8b7e10cf4d | ||
|
|
40f82e5ef2 | ||
|
|
946802600b | ||
|
|
40ebdb5c42 | ||
|
|
02a8c0a640 | ||
|
|
f21a21f172 | ||
|
|
eb2a35f0d8 | ||
|
|
b75c7e16a4 | ||
|
|
dcffa7449a | ||
|
|
d54c1c7072 | ||
|
|
d836682ee6 | ||
|
|
e193543ea8 | ||
|
|
2c52d5fe42 | ||
|
|
43dbd1bdf8 | ||
|
|
3814a56d48 | ||
|
|
103d6d7781 | ||
|
|
e296813578 | ||
|
|
2daca0f4d0 | ||
|
|
34156c424c | ||
|
|
c856b5fa53 | ||
|
|
d25fa7b075 | ||
|
|
42aa6b8ea5 | ||
|
|
bded790425 | ||
|
|
b1b8a657c4 | ||
|
|
4716def511 | ||
|
|
34feaf1df0 | ||
|
|
123e8d7038 | ||
|
|
ecd23bb29b | ||
|
|
d16e61dc85 | ||
|
|
f61dedb7e5 | ||
|
|
6017a0de88 | ||
|
|
2a392c11f8 | ||
|
|
4c40ce09fd | ||
|
|
e9cd227b5b | ||
|
|
f065b2ddef | ||
|
|
e021639472 | ||
|
|
7f9b21daa0 | ||
|
|
07ee75b745 | ||
|
|
914aed6495 | ||
|
|
60e963ed86 |
@@ -265,16 +265,25 @@ step-gclient-sync: &step-gclient-sync
|
||||
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="Electron Bot" GIT_COMMITTER_EMAIL="anonymous@electronjs.org" git commit -m "update patches" --author="Electron Bot <anonymous@electronjs.org>"
|
||||
GIT_COMMITTER_NAME="Electron Bot" GIT_COMMITTER_EMAIL="electron@github.com" git commit -m "update patches" --author="Electron Bot <electron@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."
|
||||
echo "Check the CI artifacts for a patch you can apply to fix it."
|
||||
echo "======================================================================"
|
||||
exit 1
|
||||
if (node ./script/push-patch.js 2> /dev/null > /dev/null); then
|
||||
echo
|
||||
echo "======================================================================"
|
||||
echo "Changes to the patches when applying, we have auto-pushed the diff to the current branch"
|
||||
echo "A new CI job will kick off shortly"
|
||||
echo "======================================================================"
|
||||
exit 1
|
||||
else
|
||||
echo
|
||||
echo "======================================================================"
|
||||
echo "There were changes to the patches when applying."
|
||||
echo "Check the CI artifacts for a patch you can apply to fix it."
|
||||
echo "======================================================================"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
@@ -665,10 +674,10 @@ step-electron-publish: &step-electron-publish
|
||||
cd src/electron
|
||||
if [ "$UPLOAD_TO_S3" == "1" ]; then
|
||||
echo 'Uploading Electron release distribution to S3'
|
||||
script/release/uploaders/upload.py --upload_to_s3
|
||||
script/release/uploaders/upload.py --verbose --upload_to_s3
|
||||
else
|
||||
echo 'Uploading Electron release distribution to Github releases'
|
||||
script/release/uploaders/upload.py
|
||||
script/release/uploaders/upload.py --verbose
|
||||
fi
|
||||
|
||||
step-persist-data-for-tests: &step-persist-data-for-tests
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
"rules": {
|
||||
"semi": ["error", "always"],
|
||||
"no-var": "error",
|
||||
"no-unused-vars": 0,
|
||||
"no-global-assign": 0,
|
||||
"guard-for-in": 2,
|
||||
"no-unused-vars": "off",
|
||||
"no-global-assign": "off",
|
||||
"guard-for-in": "error",
|
||||
"@typescript-eslint/no-unused-vars": ["error", {
|
||||
"vars": "all",
|
||||
"args": "after-used",
|
||||
@@ -20,7 +20,7 @@
|
||||
"destructuring": "all"
|
||||
}],
|
||||
"standard/no-callback-literal": "off",
|
||||
"node/no-deprecated-api": 0
|
||||
"node/no-deprecated-api": "off"
|
||||
},
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 6,
|
||||
@@ -30,7 +30,7 @@
|
||||
{
|
||||
"files": "*.js",
|
||||
"rules": {
|
||||
"@typescript-eslint/no-unused-vars": "off"
|
||||
"@typescript-eslint/no-unused-vars": "off"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -45,8 +45,8 @@
|
||||
{
|
||||
"files": "*.d.ts",
|
||||
"rules": {
|
||||
"no-useless-constructor": "off",
|
||||
"@typescript-eslint/no-unused-vars": "off"
|
||||
"no-useless-constructor": "off",
|
||||
"@typescript-eslint/no-unused-vars": "off"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
4
DEPS
4
DEPS
@@ -16,7 +16,7 @@ vars = {
|
||||
'chromium_version':
|
||||
'2a55c4f55b99b2191ea59cba1e2f6da4dbb7dee0',
|
||||
'node_version':
|
||||
'v14.14.0',
|
||||
'v14.15.0',
|
||||
'nan_version':
|
||||
'2c4ee8a32a299eada3cd6e468bbd0a473bfea96d',
|
||||
'squirrel.mac_version':
|
||||
@@ -78,6 +78,8 @@ vars = {
|
||||
False,
|
||||
'checkout_google_benchmark':
|
||||
False,
|
||||
'checkout_clang_tidy':
|
||||
True,
|
||||
}
|
||||
|
||||
deps = {
|
||||
|
||||
@@ -1 +1 @@
|
||||
12.0.0-nightly.20201029
|
||||
12.0.0-nightly.20201109
|
||||
35
appveyor.yml
35
appveyor.yml
@@ -66,7 +66,6 @@ build_script:
|
||||
- update_depot_tools.bat
|
||||
- ps: Move-Item $env:APPVEYOR_BUILD_FOLDER -Destination src\electron
|
||||
- ps: $env:CHROMIUM_BUILDTOOLS_PATH="$pwd\src\buildtools"
|
||||
- ps: $env:SCCACHE_PATH="$pwd\src\electron\external_binaries\sccache.exe"
|
||||
- ps: >-
|
||||
if ($env:GN_CONFIG -eq 'release') {
|
||||
$env:GCLIENT_EXTRA_ARGS="$env:GCLIENT_EXTRA_ARGS --custom-var=checkout_requests=True"
|
||||
@@ -134,24 +133,22 @@ build_script:
|
||||
}
|
||||
}
|
||||
- ps: >-
|
||||
if ($env:GN_CONFIG -ne 'release') {
|
||||
if (Test-Path 'env:RAW_GOMA_AUTH') {
|
||||
$env:GOMA_OAUTH2_CONFIG_FILE = "$pwd\.goma_oauth2_config"
|
||||
$env:RAW_GOMA_AUTH | Set-Content $env:GOMA_OAUTH2_CONFIG_FILE
|
||||
}
|
||||
git clone https://github.com/electron/build-tools.git
|
||||
cd build-tools
|
||||
npm install
|
||||
mkdir third_party
|
||||
node -e "require('./src/utils/goma.js').downloadAndPrepare()"
|
||||
$env:GN_GOMA_FILE = node -e "console.log(require('./src/utils/goma.js').gnFilePath)"
|
||||
$env:LOCAL_GOMA_DIR = node -e "console.log(require('./src/utils/goma.js').dir)"
|
||||
cd ..
|
||||
.\src\electron\script\start-goma.ps1 -gomaDir $env:LOCAL_GOMA_DIR
|
||||
if (Test-Path 'env:RAW_GOMA_AUTH') {
|
||||
$env:GOMA_OAUTH2_CONFIG_FILE = "$pwd\.goma_oauth2_config"
|
||||
$env:RAW_GOMA_AUTH | Set-Content $env:GOMA_OAUTH2_CONFIG_FILE
|
||||
}
|
||||
- git clone https://github.com/electron/build-tools.git
|
||||
- cd build-tools
|
||||
- npm install
|
||||
- mkdir third_party
|
||||
- node -e "require('./src/utils/goma.js').downloadAndPrepare()"
|
||||
- ps: $env:GN_GOMA_FILE = node -e "console.log(require('./src/utils/goma.js').gnFilePath)"
|
||||
- ps: $env:LOCAL_GOMA_DIR = node -e "console.log(require('./src/utils/goma.js').dir)"
|
||||
- cd ..
|
||||
- ps: .\src\electron\script\start-goma.ps1 -gomaDir $env:LOCAL_GOMA_DIR
|
||||
- cd src
|
||||
- set BUILD_CONFIG_PATH=//electron/build/args/%GN_CONFIG%.gn
|
||||
- if DEFINED GN_GOMA_FILE (gn gen out/Default "--args=import(\"%BUILD_CONFIG_PATH%\") import(\"%GN_GOMA_FILE%\") %GN_EXTRA_ARGS% ") else (gn gen out/Default "--args=import(\"%BUILD_CONFIG_PATH%\") %GN_EXTRA_ARGS% cc_wrapper=\"%SCCACHE_PATH%\"")
|
||||
- gn gen out/Default "--args=import(\"%BUILD_CONFIG_PATH%\") import(\"%GN_GOMA_FILE%\") %GN_EXTRA_ARGS% "
|
||||
- gn check out/Default //electron:electron_lib
|
||||
- gn check out/Default //electron:electron_app
|
||||
- gn check out/Default //electron:manifests
|
||||
@@ -170,7 +167,7 @@ build_script:
|
||||
- ninja -C out/Default electron:hunspell_dictionaries_zip
|
||||
- ninja -C out/Default electron:electron_chromedriver_zip
|
||||
- ninja -C out/Default third_party/electron_node:headers
|
||||
- if "%GN_CONFIG%"=="testing" ( python %LOCAL_GOMA_DIR%\goma_ctl.py stat )
|
||||
- python %LOCAL_GOMA_DIR%\goma_ctl.py stat
|
||||
- python electron/build/profile_toolchain.py --output-json=out/Default/windows_toolchain_profile.json
|
||||
- appveyor PushArtifact out/Default/windows_toolchain_profile.json
|
||||
- appveyor PushArtifact out/Default/dist.zip
|
||||
@@ -229,10 +226,10 @@ deploy_script:
|
||||
if (Test-Path Env:\ELECTRON_RELEASE) {
|
||||
if (Test-Path Env:\UPLOAD_TO_S3) {
|
||||
Write-Output "Uploading Electron release distribution to s3"
|
||||
& python script\release\uploaders\upload.py --upload_to_s3
|
||||
& python script\release\uploaders\upload.py --verbose --upload_to_s3
|
||||
} else {
|
||||
Write-Output "Uploading Electron release distribution to github releases"
|
||||
& python script\release\uploaders\upload.py
|
||||
& python script\release\uploaders\upload.py --verbose
|
||||
}
|
||||
} elseif (Test-Path Env:\TEST_WOA) {
|
||||
node script/release/ci-release-build.js --job=electron-woa-testing --ci=VSTS --armTest --appveyorJobId=$env:APPVEYOR_JOB_ID $env:APPVEYOR_REPO_BRANCH
|
||||
|
||||
@@ -15,5 +15,12 @@ args = [cmd, "run",
|
||||
try:
|
||||
subprocess.check_output(args, stderr=subprocess.STDOUT)
|
||||
except subprocess.CalledProcessError as e:
|
||||
print("NPM script '" + sys.argv[2] + "' failed with code '" + str(e.returncode) + "':\n" + e.output)
|
||||
print(
|
||||
"NPM script '"
|
||||
+ sys.argv[2]
|
||||
+ "' failed with code '"
|
||||
+ str(e.returncode)
|
||||
+ "':\n"
|
||||
+ e.output
|
||||
)
|
||||
sys.exit(e.returncode)
|
||||
|
||||
@@ -19,10 +19,10 @@ from get_toolchain_if_necessary import CalculateHash
|
||||
|
||||
|
||||
@contextlib.contextmanager
|
||||
def cwd(dir):
|
||||
def cwd(directory):
|
||||
curdir = os.getcwd()
|
||||
try:
|
||||
os.chdir(dir)
|
||||
os.chdir(directory)
|
||||
yield
|
||||
finally:
|
||||
os.chdir(curdir)
|
||||
@@ -70,12 +70,18 @@ def windows_profile():
|
||||
win_sdk_dir = SetEnvironmentAndGetSDKDir()
|
||||
path = NormalizePath(os.environ['GYP_MSVS_OVERRIDE_PATH'])
|
||||
|
||||
# since current windows executable are symbols path dependant,
|
||||
# profile the current directory too
|
||||
return {
|
||||
'pwd': os.getcwd(), # since current windows executable are symbols path dependant, profile the current directory too
|
||||
'pwd': os.getcwd(),
|
||||
'installed_software': windows_installed_software(),
|
||||
'sdks': [
|
||||
{'name': 'vs', 'path': path, 'hash': calculate_hash(path)},
|
||||
{'name': 'wsdk', 'path': win_sdk_dir, 'hash': calculate_hash(win_sdk_dir)}
|
||||
{
|
||||
'name': 'wsdk',
|
||||
'path': win_sdk_dir,
|
||||
'hash': calculate_hash(win_sdk_dir),
|
||||
},
|
||||
],
|
||||
'runtime_lib_dirs': runtime_dll_dirs,
|
||||
}
|
||||
@@ -93,5 +99,5 @@ if __name__ == '__main__':
|
||||
parser = optparse.OptionParser()
|
||||
parser.add_option('--output-json', metavar='FILE', default='profile.json',
|
||||
help='write information about toolchain to FILE')
|
||||
options, args = parser.parse_args()
|
||||
sys.exit(main(options))
|
||||
opts, args = parser.parse_args()
|
||||
sys.exit(main(opts))
|
||||
|
||||
@@ -12,5 +12,7 @@ subprocess.check_output(["rm", "-rf", dest])
|
||||
subprocess.check_output(["cp", "-a", source, dest])
|
||||
|
||||
# Strip headers, we do not need to ship them
|
||||
subprocess.check_output(["rm", "-r", os.path.join(dest, 'Headers')])
|
||||
subprocess.check_output(["rm", "-r", os.path.join(dest, 'Versions', 'Current', 'Headers')])
|
||||
subprocess.check_output(["rm", "-r", os.path.join(dest, "Headers")])
|
||||
subprocess.check_output(
|
||||
["rm", "-r", os.path.join(dest, "Versions", "Current", "Headers")]
|
||||
)
|
||||
|
||||
39
build/zip.py
39
build/zip.py
@@ -20,11 +20,12 @@ PATHS_TO_SKIP = [
|
||||
'./libVkICD_mock_',
|
||||
# Skip because these are outputs that we don't need.
|
||||
'./VkICD_mock_',
|
||||
# Skip because its an output of create_bundle from //build/config/mac/rules.gni
|
||||
# that we don't need
|
||||
# Skip because its an output of create_bundle from
|
||||
# //build/config/mac/rules.gni that we don't need
|
||||
'Electron.dSYM',
|
||||
# Refs https://chromium-review.googlesource.com/c/angle/angle/+/2425197.
|
||||
# Remove this when Angle themselves remove the file: https://issuetracker.google.com/issues/168736059
|
||||
# Remove this when Angle themselves remove the file:
|
||||
# https://issuetracker.google.com/issues/168736059
|
||||
'gen/angle/angle_commit.h',
|
||||
# //chrome/browser:resources depends on this via
|
||||
# //chrome/browser/resources/ssl/ssl_error_assistant, but we don't need to
|
||||
@@ -50,7 +51,12 @@ def skip_path(dep, dist_zip, target_cpu):
|
||||
should_skip = (
|
||||
any(dep.startswith(path) for path in PATHS_TO_SKIP) or
|
||||
any(dep.endswith(ext) for ext in EXTENSIONS_TO_SKIP) or
|
||||
('arm' in target_cpu and dist_zip == 'mksnapshot.zip' and dep == 'snapshot_blob.bin'))
|
||||
(
|
||||
"arm" in target_cpu
|
||||
and dist_zip == "mksnapshot.zip"
|
||||
and dep == "snapshot_blob.bin"
|
||||
)
|
||||
)
|
||||
if should_skip:
|
||||
print("Skipping {}".format(dep))
|
||||
return should_skip
|
||||
@@ -64,7 +70,7 @@ def execute(argv):
|
||||
raise e
|
||||
|
||||
def main(argv):
|
||||
dist_zip, runtime_deps, target_cpu, target_os, flatten_val = argv
|
||||
dist_zip, runtime_deps, target_cpu, _, flatten_val = argv
|
||||
should_flatten = flatten_val == "true"
|
||||
dist_files = set()
|
||||
with open(runtime_deps) as f:
|
||||
@@ -75,17 +81,28 @@ def main(argv):
|
||||
if sys.platform == 'darwin' and not should_flatten:
|
||||
execute(['zip', '-r', '-y', dist_zip] + list(dist_files))
|
||||
else:
|
||||
with zipfile.ZipFile(dist_zip, 'w', zipfile.ZIP_DEFLATED, allowZip64=True) as z:
|
||||
with zipfile.ZipFile(
|
||||
dist_zip, 'w', zipfile.ZIP_DEFLATED, allowZip64=True
|
||||
) as z:
|
||||
for dep in dist_files:
|
||||
if os.path.isdir(dep):
|
||||
for root, dirs, files in os.walk(dep):
|
||||
for file in files:
|
||||
z.write(os.path.join(root, file))
|
||||
for root, _, files in os.walk(dep):
|
||||
for filename in files:
|
||||
z.write(os.path.join(root, filename))
|
||||
else:
|
||||
basename = os.path.basename(dep)
|
||||
dirname = os.path.dirname(dep)
|
||||
arcname = os.path.join(dirname, 'chrome-sandbox') if basename == 'chrome_sandbox' else dep
|
||||
z.write(dep, os.path.basename(arcname) if should_flatten else arcname)
|
||||
arcname = (
|
||||
os.path.join(dirname, 'chrome-sandbox')
|
||||
if basename == 'chrome_sandbox'
|
||||
else dep
|
||||
)
|
||||
z.write(
|
||||
dep,
|
||||
os.path.basename(arcname)
|
||||
if should_flatten
|
||||
else arcname,
|
||||
)
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main(sys.argv[1:]))
|
||||
|
||||
@@ -51,7 +51,7 @@ an issue:
|
||||
* [Represented File for macOS BrowserWindows](tutorial/represented-file.md)
|
||||
* [Native File Drag & Drop](tutorial/native-file-drag-drop.md)
|
||||
* [Offscreen Rendering](tutorial/offscreen-rendering.md)
|
||||
* [Supporting macOS Dark Mode](tutorial/mojave-dark-mode-guide.md)
|
||||
* [Dark Mode](tutorial/dark-mode.md)
|
||||
* [Web embeds in Electron](tutorial/web-embeds.md)
|
||||
* [Accessibility](tutorial/accessibility.md)
|
||||
* [Spectron](tutorial/accessibility.md#spectron)
|
||||
@@ -59,7 +59,7 @@ an issue:
|
||||
* [Manually Enabling Accessibility Features](tutorial/accessibility.md#manually-enabling-accessibility-features)
|
||||
* [Testing and Debugging](tutorial/application-debugging.md)
|
||||
* [Debugging the Main Process](tutorial/debugging-main-process.md)
|
||||
* [Debugging the Main Process with Visual Studio Code](tutorial/debugging-main-process-vscode.md)
|
||||
* [Debugging with Visual Studio Code](tutorial/debugging-vscode.md)
|
||||
* [Using Selenium and WebDriver](tutorial/using-selenium-and-webdriver.md)
|
||||
* [Testing on Headless CI Systems (Travis, Jenkins)](tutorial/testing-on-headless-ci.md)
|
||||
* [DevTools Extension](tutorial/devtools-extension.md)
|
||||
@@ -134,6 +134,7 @@ These individual tutorials expand on topics discussed in the guide above.
|
||||
* [MenuItem](api/menu-item.md)
|
||||
* [net](api/net.md)
|
||||
* [netLog](api/net-log.md)
|
||||
* [nativeTheme](api/native-theme.md)
|
||||
* [Notification](api/notification.md)
|
||||
* [powerMonitor](api/power-monitor.md)
|
||||
* [powerSaveBlocker](api/power-save-blocker.md)
|
||||
|
||||
@@ -859,9 +859,10 @@ This method returns the application name of the default handler for the protocol
|
||||
minimum (e.g. `https://`).
|
||||
|
||||
Returns `Promise<Object>` - Resolve with an object containing the following:
|
||||
* `icon` NativeImage - the display icon of the app handling the protocol.
|
||||
* `path` String - installation path of the app handling the protocol.
|
||||
* `name` String - display name of the app handling the protocol.
|
||||
|
||||
* `icon` NativeImage - the display icon of the app handling the protocol.
|
||||
* `path` String - installation path of the app handling the protocol.
|
||||
* `name` String - display name of the app handling the protocol.
|
||||
|
||||
This method returns a promise that contains the application name, icon and path of the default handler for the protocol
|
||||
(aka URI scheme) of a URL.
|
||||
@@ -1091,6 +1092,7 @@ Changes the [Application User Model ID][app-user-model-id] to `id`.
|
||||
Sets the activation policy for a given app.
|
||||
|
||||
Activation policy types:
|
||||
|
||||
* 'regular' - The application is an ordinary app that appears in the Dock and may have a user interface.
|
||||
* 'accessory' - The application doesn’t appear in the Dock and doesn’t have a menu bar, but it may be activated programmatically or by clicking on one of its windows.
|
||||
* 'prohibited' - The application doesn’t appear in the Dock and may not create windows or be activated.
|
||||
@@ -1105,7 +1107,7 @@ Activation policy types:
|
||||
|
||||
Imports the certificate in pkcs12 format into the platform certificate store.
|
||||
`callback` is called with the `result` of import operation, a value of `0`
|
||||
indicates success while any other value indicates failure according to Chromium [net_error_list](https://code.google.com/p/chromium/codesearch#chromium/src/net/base/net_error_list.h).
|
||||
indicates success while any other value indicates failure according to Chromium [net_error_list](https://source.chromium.org/chromium/chromium/src/+/master:net/base/net_error_list.h).
|
||||
|
||||
### `app.disableHardwareAcceleration()`
|
||||
|
||||
@@ -1142,6 +1144,7 @@ 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:
|
||||
|
||||
```js
|
||||
{
|
||||
auxAttributes:
|
||||
@@ -1342,7 +1345,7 @@ systems Application folder. Use in combination with `app.moveToApplicationsFolde
|
||||
### `app.moveToApplicationsFolder([options])` _macOS_
|
||||
|
||||
* `options` Object (optional)
|
||||
* `conflictHandler` Function<Boolean> (optional) - A handler for potential conflict in move failure.
|
||||
* `conflictHandler` Function\<Boolean> (optional) - A handler for potential conflict in move failure.
|
||||
* `conflictType` String - The type of move conflict encountered by the handler; can be `exists` or `existsAndRunning`, where `exists` means that an app of the same name is present in the Applications directory and `existsAndRunning` means both that it exists and that it's presently running.
|
||||
|
||||
Returns `Boolean` - Whether the move was successful. Please note that if
|
||||
|
||||
@@ -468,6 +468,7 @@ window.onbeforeunload = (e) => {
|
||||
e.returnValue = false // equivalent to `return false` but not recommended
|
||||
}
|
||||
```
|
||||
|
||||
_**Note**: There is a subtle difference between the behaviors of `window.onbeforeunload = handler` and `window.addEventListener('beforeunload', handler)`. It is recommended to always set the `event.returnValue` explicitly, instead of only returning a value, as the former works more consistently within Electron._
|
||||
|
||||
#### Event: 'closed'
|
||||
@@ -859,7 +860,7 @@ A `Boolean` property that determines whether the menu bar should be visible.
|
||||
|
||||
**Note:** If the menu bar is auto-hide, users can still bring up the menu bar by pressing the single `Alt` key.
|
||||
|
||||
#### `win.kiosk`
|
||||
#### `win.kiosk`
|
||||
|
||||
A `Boolean` property that determines whether the window is in kiosk mode.
|
||||
|
||||
@@ -1049,7 +1050,7 @@ Returns `Boolean` - Whether the window is in normal state (not maximized, not mi
|
||||
|
||||
* `aspectRatio` Float - The aspect ratio to maintain for some portion of the
|
||||
content view.
|
||||
* `extraSize` [Size](structures/size.md) (optional) _macOS_ - The extra size not to be included while
|
||||
* `extraSize` [Size](structures/size.md) (optional) _macOS_ - The extra size not to be included while
|
||||
maintaining the aspect ratio.
|
||||
|
||||
This will make a window maintain an aspect ratio. The extra size allows a
|
||||
|
||||
@@ -98,6 +98,7 @@ request.on('login', (authInfo, callback) => {
|
||||
callback('username', 'password')
|
||||
})
|
||||
```
|
||||
|
||||
Providing empty credentials will cancel the request and report an authentication
|
||||
error on the response object:
|
||||
|
||||
@@ -139,7 +140,6 @@ Emitted as the last event in the HTTP request-response transaction. The `close`
|
||||
event indicates that no more events will be emitted on either the `request` or
|
||||
`response` objects.
|
||||
|
||||
|
||||
#### Event: 'redirect'
|
||||
|
||||
Returns:
|
||||
|
||||
@@ -64,6 +64,7 @@ Forces the maximum disk space to be used by the disk cache, in bytes.
|
||||
### --enable-api-filtering-logging
|
||||
|
||||
Enables caller stack logging for the following APIs (filtering events):
|
||||
|
||||
- `desktopCapturer.getSources()` / `desktop-capturer-get-sources`
|
||||
- `remote.require()` / `remote-require`
|
||||
- `remote.getGlobal()` / `remote-get-builtin`
|
||||
@@ -227,6 +228,7 @@ See the [Debugging the Main Process][debugging-main-process] guide for more deta
|
||||
Aliased to `--debug[=[host:]port`.
|
||||
|
||||
### --inspect-publish-uid=stderr,http
|
||||
|
||||
Specify ways of the inspector web socket url exposure.
|
||||
|
||||
By default inspector websocket url is available in stderr and under /json/list endpoint on http://host:port/json/list.
|
||||
|
||||
@@ -108,5 +108,4 @@ has been included below for completeness:
|
||||
| [Cloneable Types](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm) | Simple | ✅ | ✅ | See the linked document on cloneable types |
|
||||
| `Symbol` | N/A | ❌ | ❌ | Symbols cannot be copied across contexts so they are dropped |
|
||||
|
||||
|
||||
If the type you care about is not in the above table, it is probably not supported.
|
||||
|
||||
@@ -205,9 +205,10 @@ The `filters` specifies an array of file types that can be displayed, see
|
||||
* `securityScopedBookmarks` Boolean (optional) _macOS_ _mas_ - Create a [security scoped bookmark](https://developer.apple.com/library/content/documentation/Security/Conceptual/AppSandboxDesignGuide/AppSandboxInDepth/AppSandboxInDepth.html#//apple_ref/doc/uid/TP40011183-CH3-SW16) when packaged for the Mac App Store. If this option is enabled and the file doesn't already exist a blank file will be created at the chosen path.
|
||||
|
||||
Returns `Promise<Object>` - Resolve with an object containing the following:
|
||||
* `canceled` Boolean - whether or not the dialog was canceled.
|
||||
* `filePath` String (optional) - If the dialog is canceled, this will be `undefined`.
|
||||
* `bookmark` String (optional) _macOS_ _mas_ - Base64 encoded string which contains the security scoped bookmark data for the saved file. `securityScopedBookmarks` must be enabled for this to be present. (For return values, see [table here](#bookmarks-array).)
|
||||
|
||||
* `canceled` Boolean - whether or not the dialog was canceled.
|
||||
* `filePath` String (optional) - If the dialog is canceled, this will be `undefined`.
|
||||
* `bookmark` String (optional) _macOS_ _mas_ - Base64 encoded string which contains the security scoped bookmark data for the saved file. `securityScopedBookmarks` must be enabled for this to be present. (For return values, see [table here](#bookmarks-array).)
|
||||
|
||||
The `browserWindow` argument allows the dialog to attach itself to a parent window, making it modal.
|
||||
|
||||
@@ -302,8 +303,9 @@ If `browserWindow` is not shown dialog will not be attached to it. In such case
|
||||
via `Alt-W` on Windows and Linux.
|
||||
|
||||
Returns `Promise<Object>` - resolves with a promise containing the following properties:
|
||||
* `response` Number - The index of the clicked button.
|
||||
* `checkboxChecked` Boolean - The checked state of the checkbox if
|
||||
|
||||
* `response` Number - The index of the clicked button.
|
||||
* `checkboxChecked` Boolean - The checked state of the checkbox if
|
||||
`checkboxLabel` was set. Otherwise `false`.
|
||||
|
||||
Shows a message box.
|
||||
|
||||
@@ -105,6 +105,7 @@ Don't use the global menu bar on Linux.
|
||||
Set the trash implementation on Linux. Default is `gio`.
|
||||
|
||||
Options:
|
||||
|
||||
* `gvfs-trash`
|
||||
* `trash-cli`
|
||||
* `kioclient5`
|
||||
@@ -115,7 +116,6 @@ Options:
|
||||
The following environment variables are intended primarily for development and
|
||||
debugging purposes.
|
||||
|
||||
|
||||
### `ELECTRON_ENABLE_LOGGING`
|
||||
|
||||
Prints Chrome's internal logging to the console.
|
||||
|
||||
@@ -12,7 +12,6 @@ options on the [`BrowserWindow`](browser-window.md) class.
|
||||
To create a frameless window, you need to set `frame` to `false` in
|
||||
[BrowserWindow](browser-window.md)'s `options`:
|
||||
|
||||
|
||||
```javascript
|
||||
const { BrowserWindow } = require('electron')
|
||||
const win = new BrowserWindow({ width: 800, height: 600, frame: false })
|
||||
@@ -88,7 +87,7 @@ win.show()
|
||||
* On Linux, users have to put `--enable-transparent-visuals --disable-gpu` in
|
||||
the command line to disable GPU and allow ARGB to make transparent window,
|
||||
this is caused by an upstream bug that [alpha channel doesn't work on some
|
||||
NVidia drivers](https://code.google.com/p/chromium/issues/detail?id=369209) on
|
||||
NVidia drivers](https://bugs.chromium.org/p/chromium/issues/detail?id=369209) on
|
||||
Linux.
|
||||
* On Mac, the native window shadow will not be shown on a transparent window.
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ Removes listeners of the specified `channel`.
|
||||
### `ipcMain.handle(channel, listener)`
|
||||
|
||||
* `channel` String
|
||||
* `listener` Function<Promise<void> | any>
|
||||
* `listener` Function<Promise\<void> | any>
|
||||
* `event` IpcMainInvokeEvent
|
||||
* `...args` any[]
|
||||
|
||||
@@ -123,7 +123,7 @@ WebContents is the source of the invoke request.
|
||||
### `ipcMain.handleOnce(channel, listener)`
|
||||
|
||||
* `channel` String
|
||||
* `listener` Function<Promise<void> | any>
|
||||
* `listener` Function<Promise\<void> | any>
|
||||
* `event` IpcMainInvokeEvent
|
||||
* `...args` any[]
|
||||
|
||||
|
||||
@@ -93,6 +93,7 @@ The main process should listen for `channel` with
|
||||
[`ipcMain.handle()`](ipc-main.md#ipcmainhandlechannel-listener).
|
||||
|
||||
For example:
|
||||
|
||||
```javascript
|
||||
// Renderer process
|
||||
ipcRenderer.invoke('some-name', someArgument).then((result) => {
|
||||
@@ -149,6 +150,7 @@ The transferred `MessagePort` objects will be available in the main process as
|
||||
property of the emitted event.
|
||||
|
||||
For example:
|
||||
|
||||
```js
|
||||
// Renderer process
|
||||
const { port1, port2 } = new MessageChannel()
|
||||
|
||||
@@ -138,6 +138,7 @@ A `String` indicating the item's visible label.
|
||||
|
||||
A `Function` that is fired when the MenuItem receives a click event.
|
||||
It can be called with `menuItem.click(event, focusedWindow, focusedWebContents)`.
|
||||
|
||||
* `event` [KeyboardEvent](structures/keyboard-event.md)
|
||||
* `focusedWindow` [BrowserWindow](browser-window.md)
|
||||
* `focusedWebContents` [WebContents](web-contents.md)
|
||||
|
||||
@@ -12,6 +12,7 @@ channel messaging.
|
||||
Process: [Main](../glossary.md#main-process)
|
||||
|
||||
Example:
|
||||
|
||||
```js
|
||||
// Main process
|
||||
const { port1, port2 } = new MessageChannelMain()
|
||||
|
||||
@@ -34,6 +34,7 @@ Setting this property to `system` will remove the override and
|
||||
everything will be reset to the OS default. By default `themeSource` is `system`.
|
||||
|
||||
Settings this property to `dark` will have the following effects:
|
||||
|
||||
* `nativeTheme.shouldUseDarkColors` will be `true` when accessed
|
||||
* Any UI Electron renders on Linux and Windows including context menus, devtools, etc. will use the dark UI.
|
||||
* Any UI the OS renders on macOS including menus, window frames, etc. will use the dark UI.
|
||||
@@ -41,6 +42,7 @@ Settings this property to `dark` will have the following effects:
|
||||
* The `updated` event will be emitted
|
||||
|
||||
Settings this property to `light` will have the following effects:
|
||||
|
||||
* `nativeTheme.shouldUseDarkColors` will be `false` when accessed
|
||||
* Any UI Electron renders on Linux and Windows including context menus, devtools, etc. will use the light UI.
|
||||
* Any UI the OS renders on macOS including menus, window frames, etc. will use the light UI.
|
||||
@@ -49,6 +51,7 @@ Settings this property to `light` will have the following effects:
|
||||
|
||||
The usage of this property should align with a classic "dark mode" state machine in your application
|
||||
where the user has three options.
|
||||
|
||||
* `Follow OS` --> `themeSource = 'system'`
|
||||
* `Dark Mode` --> `themeSource = 'dark'`
|
||||
* `Light Mode` --> `themeSource = 'light'`
|
||||
|
||||
@@ -11,6 +11,7 @@ It adds the following events, properties, and methods:
|
||||
## Sandbox
|
||||
|
||||
In sandboxed renderers the `process` object contains only a subset of the APIs:
|
||||
|
||||
- `crash()`
|
||||
- `hang()`
|
||||
- `getCreationTime()`
|
||||
@@ -104,6 +105,7 @@ A `Boolean` that controls whether or not deprecations printed to `stderr` includ
|
||||
This property is instead of the `--trace-deprecation` command line flag.
|
||||
|
||||
### `process.traceProcessWarnings`
|
||||
|
||||
A `Boolean` that controls whether or not process warnings printed to `stderr` include
|
||||
their stack trace. Setting this to `true` will print stack traces for process warnings
|
||||
(including deprecations). This property is instead of the `--trace-warnings` command
|
||||
|
||||
@@ -35,6 +35,7 @@ win.loadURL('https://github.com')
|
||||
you can use [webContents.executeJavaScript](web-contents.md#contentsexecutejavascriptcode-usergesture).
|
||||
|
||||
**Note:** The remote module can be disabled for security reasons in the following contexts:
|
||||
|
||||
- [`BrowserWindow`](browser-window.md) - by setting the `enableRemoteModule` option to `false`.
|
||||
- [`<webview>`](webview-tag.md) - by setting the `enableremotemodule` attribute to `false`.
|
||||
|
||||
@@ -207,7 +208,6 @@ module.exports = 'bar'
|
||||
const foo = require('electron').remote.require('./foo') // bar
|
||||
```
|
||||
|
||||
|
||||
### `remote.process` _Readonly_
|
||||
|
||||
A `NodeJS.Process` object. The `process` object in the main process. This is the same as
|
||||
|
||||
@@ -100,10 +100,11 @@ Returns:
|
||||
|
||||
Emitted after an extension is loaded. This occurs whenever an extension is
|
||||
added to the "enabled" set of extensions. This includes:
|
||||
|
||||
- Extensions being loaded from `Session.loadExtension`.
|
||||
- Extensions being reloaded:
|
||||
* from a crash.
|
||||
* if the extension requested it ([`chrome.runtime.reload()`](https://developer.chrome.com/extensions/runtime#method-reload)).
|
||||
* from a crash.
|
||||
* if the extension requested it ([`chrome.runtime.reload()`](https://developer.chrome.com/extensions/runtime#method-reload)).
|
||||
|
||||
#### Event: 'extension-unloaded'
|
||||
|
||||
@@ -354,7 +355,7 @@ The `proxyBypassRules` is a comma separated list of rules described below:
|
||||
"foobar.com", "*foobar.com", "*.foobar.com", "*foobar.com:99",
|
||||
"https://x.*.y.com:99"
|
||||
|
||||
* `"." HOSTNAME_SUFFIX_PATTERN [ ":" PORT ]`
|
||||
* `"." HOSTNAME_SUFFIX_PATTERN [ ":" PORT ]`
|
||||
|
||||
Match a particular domain suffix.
|
||||
|
||||
@@ -454,7 +455,7 @@ the original network configuration.
|
||||
* `errorCode` Integer - Error code.
|
||||
* `callback` Function
|
||||
* `verificationResult` Integer - Value can be one of certificate error codes
|
||||
from [here](https://code.google.com/p/chromium/codesearch#chromium/src/net/base/net_error_list.h).
|
||||
from [here](https://source.chromium.org/chromium/chromium/src/+/master:net/base/net_error_list.h).
|
||||
Apart from the certificate error codes, the following special codes can be used.
|
||||
* `0` - Indicates success and disables Certificate Transparency verification.
|
||||
* `-2` - Indicates failure.
|
||||
@@ -487,6 +488,7 @@ win.webContents.session.setCertificateVerifyProc((request, callback) => {
|
||||
* `handler` Function | null
|
||||
* `webContents` [WebContents](web-contents.md) - WebContents requesting the permission. Please note that if the request comes from a subframe you should use `requestingUrl` to check the request origin.
|
||||
* `permission` String - The type of requested permission.
|
||||
* `clipboard-read` - Request access to read from the clipboard.
|
||||
* `media` - Request access to media devices such as camera, microphone and speakers.
|
||||
* `mediaKeySystem` - Request access to DRM protected content.
|
||||
* `geolocation` - Request access to user's current location.
|
||||
@@ -522,7 +524,7 @@ session.fromPartition('some-partition').setPermissionRequestHandler((webContents
|
||||
|
||||
#### `ses.setPermissionCheckHandler(handler)`
|
||||
|
||||
* `handler` Function<Boolean> | null
|
||||
* `handler` Function\<Boolean> | null
|
||||
* `webContents` [WebContents](web-contents.md) - WebContents checking the permission. Please note that if the request comes from a subframe you should use `requestingUrl` to check the request origin.
|
||||
* `permission` String - Type of permission check. Valid values are `midiSysex`, `notifications`, `geolocation`, `media`,`mediaKeySystem`,`midi`, `pointerLock`, `fullscreen`, `openExternal`, or `serial`.
|
||||
* `requestingOrigin` String - The origin URL of the permission check
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# NewWindowWebContentsEvent Object extends `Event`
|
||||
|
||||
* `newGuest` BrowserWindow (optional)
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
* `session` Session (optional) - The session used for requesting URL, by default
|
||||
the HTTP request will reuse the current session. Setting `session` to `null`
|
||||
would use a random independent session. This is only used for URL responses.
|
||||
* `uploadData` ProtocolResponseUploadData (optional) - The data used as upload data. This is only
|
||||
* `uploadData` [ProtocolResponseUploadData](protocol-response-upload-data.md) (optional) - The data used as upload data. This is only
|
||||
used for URL responses when `method` is `"POST"`.
|
||||
|
||||
[net-error]: https://code.google.com/p/chromium/codesearch#chromium/src/net/base/net_error_list.h
|
||||
[net-error]: https://source.chromium.org/chromium/chromium/src/+/master:net/base/net_error_list.h
|
||||
|
||||
@@ -51,8 +51,6 @@ Returns:
|
||||
|
||||
Returns `Boolean` - Whether the system is in Dark Mode.
|
||||
|
||||
**Note:** On macOS 10.15 Catalina in order for this API to return the correct value when in the "automatic" dark mode setting you must either have `NSRequiresAquaSystemAppearance=false` in your `Info.plist` or be on Electron `>=7.0.0`. See the [dark mode guide](../tutorial/mojave-dark-mode-guide.md) for more information.
|
||||
|
||||
**Deprecated:** Should use the new [`nativeTheme.shouldUseDarkColors`](native-theme.md#nativethemeshouldusedarkcolors-readonly) API.
|
||||
|
||||
### `systemPreferences.isSwipeTrackingFromScrollEventsEnabled()` _macOS_
|
||||
|
||||
@@ -52,12 +52,12 @@ app.whenReady().then(() => {
|
||||
appIcon.setContextMenu(contextMenu)
|
||||
})
|
||||
```
|
||||
|
||||
* On Windows it is recommended to use `ICO` icons to get best visual effects.
|
||||
|
||||
If you want to keep exact same behaviors on all platforms, you should not
|
||||
rely on the `click` event and always attach a context menu to the tray icon.
|
||||
|
||||
|
||||
### `new Tray(image, [guid])`
|
||||
|
||||
* `image` ([NativeImage](native-image.md) | String)
|
||||
|
||||
@@ -438,6 +438,7 @@ Emitted when the window leaves a full-screen state triggered by HTML API.
|
||||
#### Event: 'zoom-changed'
|
||||
|
||||
Returns:
|
||||
|
||||
* `event` Event
|
||||
* `zoomDirection` String - Can be `in` or `out`.
|
||||
|
||||
@@ -1690,6 +1691,7 @@ process by accessing the `ports` property of the emitted event. When they
|
||||
arrive in the renderer, they will be native DOM `MessagePort` objects.
|
||||
|
||||
For example:
|
||||
|
||||
```js
|
||||
// Main process
|
||||
const { port1, port2 } = new MessageChannelMain()
|
||||
|
||||
@@ -175,6 +175,7 @@ reject and the `result` would be `undefined`. This is because Chromium does not
|
||||
dispatch errors of isolated worlds to foreign worlds.
|
||||
|
||||
### `webFrame.setIsolatedWorldInfo(worldId, info)`
|
||||
|
||||
* `worldId` Integer - The ID of the world to run the javascript in, `0` is the default world, `999` is the world used by Electrons `contextIsolation` feature. Chrome extensions reserve the range of IDs in `[1 << 20, 1 << 29)`. You can provide any integer here.
|
||||
* `info` Object
|
||||
* `securityOrigin` String (optional) - Security origin for the isolated world.
|
||||
|
||||
@@ -27,6 +27,7 @@ The `features` string follows the format of standard browser, but each feature
|
||||
has to be a field of `BrowserWindow`'s options. These are the features you can set via `features` string: `zoomFactor`, `nodeIntegration`, `preload`, `javascript`, `contextIsolation`, `webviewTag`.
|
||||
|
||||
For example:
|
||||
|
||||
```js
|
||||
window.open('https://github.com', '_blank', 'nodeIntegration=no')
|
||||
```
|
||||
|
||||
@@ -301,6 +301,7 @@ messages, but also brings some breaking changes in behavior.
|
||||
- Sending Functions, Promises, WeakMaps, WeakSets, or objects containing any
|
||||
such values, over IPC will now throw an exception, instead of silently
|
||||
converting the functions to `undefined`.
|
||||
|
||||
```js
|
||||
// Previously:
|
||||
ipcRenderer.send('channel', { value: 3, someFunction: () => {} })
|
||||
@@ -310,6 +311,7 @@ ipcRenderer.send('channel', { value: 3, someFunction: () => {} })
|
||||
ipcRenderer.send('channel', { value: 3, someFunction: () => {} })
|
||||
// => throws Error("() => {} could not be cloned.")
|
||||
```
|
||||
|
||||
- `NaN`, `Infinity` and `-Infinity` will now be correctly serialized, instead
|
||||
of being converted to `null`.
|
||||
- Objects containing cyclic references will now be correctly serialized,
|
||||
@@ -327,6 +329,7 @@ ipcRenderer.send('channel', { value: 3, someFunction: () => {} })
|
||||
- Node.js `Buffer` objects will be transferred as `Uint8Array`s. You can
|
||||
convert a `Uint8Array` back to a Node.js `Buffer` by wrapping the underlying
|
||||
`ArrayBuffer`:
|
||||
|
||||
```js
|
||||
Buffer.from(value.buffer, value.byteOffset, value.byteLength)
|
||||
```
|
||||
@@ -462,6 +465,7 @@ the folder, similarly to Chrome, Firefox, and Edge
|
||||
([link to MDN docs](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/webkitdirectory)).
|
||||
|
||||
As an illustration, take a folder with this structure:
|
||||
|
||||
```console
|
||||
folder
|
||||
├── file1
|
||||
@@ -470,11 +474,13 @@ folder
|
||||
```
|
||||
|
||||
In Electron <=6, this would return a `FileList` with a `File` object for:
|
||||
|
||||
```console
|
||||
path/to/folder
|
||||
```
|
||||
|
||||
In Electron 7, this now returns a `FileList` with a `File` object for:
|
||||
|
||||
```console
|
||||
/path/to/folder/file3
|
||||
/path/to/folder/file2
|
||||
@@ -629,7 +635,9 @@ webFrame.setIsolatedWorldInfo(
|
||||
```
|
||||
|
||||
### API Changed: `webFrame.setSpellCheckProvider` now takes an asynchronous callback
|
||||
|
||||
The `spellCheck` callback is now asynchronous, and `autoCorrectWord` parameter has been removed.
|
||||
|
||||
```js
|
||||
// Deprecated
|
||||
webFrame.setSpellCheckProvider('en-US', true, {
|
||||
|
||||
@@ -12,6 +12,7 @@ For guides on Electron app development, see
|
||||
* [Source Code Directory Structure](source-code-directory-structure.md)
|
||||
* [Coding Style](coding-style.md)
|
||||
* [Using clang-format on C++ Code](clang-format.md)
|
||||
* [Using clang-tidy on C++ Code](clang-tidy.md)
|
||||
* [Build System Overview](build-system-overview.md)
|
||||
* [Build Instructions (macOS)](build-instructions-macos.md)
|
||||
* [Build Instructions (Windows)](build-instructions-windows.md)
|
||||
|
||||
@@ -6,9 +6,9 @@ Follow the guidelines below for building Electron.
|
||||
|
||||
Check the build prerequisites for your platform before proceeding
|
||||
|
||||
* [macOS](build-instructions-macos.md#prerequisites)
|
||||
* [Linux](build-instructions-linux.md#prerequisites)
|
||||
* [Windows](build-instructions-windows.md#prerequisites)
|
||||
* [macOS](build-instructions-macos.md#prerequisites)
|
||||
* [Linux](build-instructions-linux.md#prerequisites)
|
||||
* [Windows](build-instructions-windows.md#prerequisites)
|
||||
|
||||
## Build Tools
|
||||
|
||||
@@ -26,7 +26,7 @@ Security` → `System` → `Advanced system settings` and add a system variable
|
||||
your locally installed version of Visual Studio (by default, `depot_tools` will
|
||||
try to download a Google-internal version that only Googlers have access to).
|
||||
|
||||
[depot-tools]: http://commondatastorage.googleapis.com/chrome-infra-docs/flat/depot_tools/docs/html/depot_tools_tutorial.html#_setting_up
|
||||
[depot-tools]: https://commondatastorage.googleapis.com/chrome-infra-docs/flat/depot_tools/docs/html/depot_tools_tutorial.html#_setting_up
|
||||
|
||||
### Setting up the git cache
|
||||
|
||||
@@ -53,7 +53,7 @@ $ gclient sync --with_branch_heads --with_tags
|
||||
> Instead of `https://github.com/electron/electron`, you can use your own fork
|
||||
> here (something like `https://github.com/<username>/electron`).
|
||||
|
||||
#### A note on pulling/pushing
|
||||
### A note on pulling/pushing
|
||||
|
||||
If you intend to `git pull` or `git push` from the official `electron`
|
||||
repository in the future, you now need to update the respective folder's
|
||||
@@ -74,6 +74,7 @@ Running `gclient sync -f` ensures that all dependencies required
|
||||
to build Electron match that file.
|
||||
|
||||
So, in order to pull, you'd run the following commands:
|
||||
|
||||
```sh
|
||||
$ cd src/electron
|
||||
$ git pull
|
||||
@@ -91,6 +92,7 @@ $ gn gen out/Testing --args="import(\"//electron/build/args/testing.gn\") $GN_EX
|
||||
```
|
||||
|
||||
Or on Windows (without the optional argument):
|
||||
|
||||
```sh
|
||||
$ cd src
|
||||
$ set CHROMIUM_BUILDTOOLS_PATH=%cd%\buildtools
|
||||
@@ -124,11 +126,13 @@ $ gn gen out/Release --args="import(\"//electron/build/args/release.gn\") $GN_EX
|
||||
Nota Bene: This will also take a while and probably heat up your lap.
|
||||
|
||||
For the testing configuration:
|
||||
|
||||
```sh
|
||||
$ ninja -C out/Testing electron
|
||||
```
|
||||
|
||||
For the release configuration:
|
||||
|
||||
```sh
|
||||
$ ninja -C out/Release electron
|
||||
```
|
||||
@@ -156,11 +160,13 @@ $ ./out/Testing/electron
|
||||
### Packaging
|
||||
|
||||
On linux, first strip the debugging and symbol information:
|
||||
|
||||
```sh
|
||||
electron/script/strip-binaries.py -d out/Release
|
||||
```
|
||||
|
||||
To package the electron build as a distributable zip file:
|
||||
|
||||
```sh
|
||||
ninja -C out/Release electron:electron_dist_zip
|
||||
```
|
||||
@@ -177,12 +183,12 @@ $ gn gen out/Testing-x86 --args='... target_cpu = "x86"'
|
||||
|
||||
Not all combinations of source and target CPU/OS are supported by Chromium.
|
||||
|
||||
<table>
|
||||
<tr><th>Host</th><th>Target</th><th>Status</th></tr>
|
||||
<tr><td>Windows x64</td><td>Windows arm64</td><td>Experimental</td>
|
||||
<tr><td>Windows x64</td><td>Windows x86</td><td>Automatically tested</td></tr>
|
||||
<tr><td>Linux x64</td><td>Linux x86</td><td>Automatically tested</td></tr>
|
||||
</table>
|
||||
| Host | Target | Status |
|
||||
|-------------|---------------|----------------------|
|
||||
| Windows x64 | Windows arm64 | Experimental |
|
||||
| Windows x64 | Windows x86 | Automatically tested |
|
||||
| Linux x64 | Linux x86 | Automatically tested |
|
||||
|
||||
|
||||
If you test other combinations and find them to work, please update this document :)
|
||||
|
||||
@@ -193,6 +199,7 @@ and [`target_cpu`][target_cpu values].
|
||||
[target_cpu values]: https://gn.googlesource.com/gn/+/master/docs/reference.md#built_in-predefined-variables-target_cpu_the-desired-cpu-architecture-for-the-build-possible-values
|
||||
|
||||
#### Windows on Arm (experimental)
|
||||
|
||||
To cross-compile for Windows on Arm, [follow Chromium's guide](https://chromium.googlesource.com/chromium/src/+/refs/heads/master/docs/windows_build_instructions.md#Visual-Studio) to get the necessary dependencies, SDK and libraries, then build with `ELECTRON_BUILDING_WOA=1` in your environment before running `gclient sync`.
|
||||
|
||||
```bat
|
||||
@@ -201,6 +208,7 @@ gclient sync -f --with_branch_heads --with_tags
|
||||
```
|
||||
|
||||
Or (if using PowerShell):
|
||||
|
||||
```powershell
|
||||
$env:ELECTRON_BUILDING_WOA=1
|
||||
gclient sync -f --with_branch_heads --with_tags
|
||||
@@ -208,7 +216,6 @@ gclient sync -f --with_branch_heads --with_tags
|
||||
|
||||
Next, run `gn gen` as above with `target_cpu="arm64"`.
|
||||
|
||||
|
||||
## Tests
|
||||
|
||||
To run the tests, you'll first need to build the test modules against the
|
||||
@@ -274,6 +281,7 @@ $ gclient sync -f
|
||||
```
|
||||
|
||||
### I'm being asked for a username/password for chromium-internal.googlesource.com
|
||||
|
||||
If you see a prompt for `Username for 'https://chrome-internal.googlesource.com':` when running `gclient sync` on Windows, it's probably because the `DEPOT_TOOLS_WIN_TOOLCHAIN` environment variable is not set to 0. Open `Control Panel` → `System and Security` → `System` → `Advanced system settings` and add a system variable
|
||||
`DEPOT_TOOLS_WIN_TOOLCHAIN` with value `0`. This tells `depot_tools` to use
|
||||
your locally installed version of Visual Studio (by default, `depot_tools` will
|
||||
|
||||
@@ -16,7 +16,7 @@ Follow the guidelines below for building Electron on Windows.
|
||||
* [Python for Windows (pywin32) Extensions](https://pypi.org/project/pywin32/#files)
|
||||
is also needed in order to run the build process.
|
||||
* [Node.js](https://nodejs.org/download/)
|
||||
* [Git](http://git-scm.com)
|
||||
* [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
|
||||
store from `.pdb` files.
|
||||
|
||||
@@ -8,6 +8,6 @@
|
||||
- [Code Search](https://cs.chromium.org/)
|
||||
- [Source Code](https://cs.chromium.org/chromium/src/)
|
||||
- [Development Calendar and Release Info](https://www.chromium.org/developers/calendar)
|
||||
- [Discussion Groups](http://www.chromium.org/developers/discussion-groups)
|
||||
- [Discussion Groups](https://www.chromium.org/developers/discussion-groups)
|
||||
|
||||
See also [V8 Development](v8-development.md)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Using clang-format on C++ Code
|
||||
|
||||
[`clang-format`](http://clang.llvm.org/docs/ClangFormat.html) is a tool to
|
||||
[`clang-format`](https://clang.llvm.org/docs/ClangFormat.html) is a tool to
|
||||
automatically format C/C++/Objective-C code, so that developers don't need to
|
||||
worry about style issues during code reviews.
|
||||
|
||||
@@ -30,6 +30,6 @@ run `git-clang-format HEAD~1`. See `git-clang-format -h` for more details.
|
||||
You can also integrate `clang-format` directly into your favorite editors.
|
||||
For further guidance on setting up editor integration, see these pages:
|
||||
|
||||
* [Atom](https://atom.io/packages/clang-format)
|
||||
* [Vim & Emacs](http://clang.llvm.org/docs/ClangFormat.html#vim-integration)
|
||||
* [Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=xaver.clang-format)
|
||||
* [Atom](https://atom.io/packages/clang-format)
|
||||
* [Vim & Emacs](https://clang.llvm.org/docs/ClangFormat.html#vim-integration)
|
||||
* [Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=xaver.clang-format)
|
||||
|
||||
37
docs/development/clang-tidy.md
Normal file
37
docs/development/clang-tidy.md
Normal file
@@ -0,0 +1,37 @@
|
||||
# Using clang-tidy on C++ Code
|
||||
|
||||
[`clang-tidy`](https://clang.llvm.org/extra/clang-tidy/) is a tool to
|
||||
automatically check C/C++/Objective-C code for style violations, programming
|
||||
errors, and best practices.
|
||||
|
||||
Electron's `clang-tidy` integration is provided as a linter script which can
|
||||
be run with `npm run lint:clang-tidy`. While `clang-tidy` checks your on-disk
|
||||
files, you need to have built Electron so that it knows which compiler flags
|
||||
were used. There is one required option for the script `--output-dir`, which
|
||||
tells the script which build directory to pull the compilation information
|
||||
from. A typical usage would be:
|
||||
`npm run lint:clang-tiy --out-dir ../out/Testing`
|
||||
|
||||
With no filenames provided, all C/C++/Objective-C files will be checked.
|
||||
You can provide a list of files to be checked by passing the filenames after
|
||||
the options:
|
||||
`npm run lint:clang-tiy --out-dir ../out/Testing shell/browser/api/electron_api_app.cc`
|
||||
|
||||
While `clang-tidy` has a
|
||||
[long list](https://clang.llvm.org/extra/clang-tidy/checks/list.html)
|
||||
of possible checks, in Electron only a few are enabled by default. At the
|
||||
moment Electron doesn't have a `.clang-tidy` config, so `clang-tidy` will
|
||||
find the one from Chromium at `src/.clang-tidy` and use the checks which
|
||||
Chromium has enabled. You can change which checks are run by using the
|
||||
`--checks=` option. This is passed straight through to `clang-tidy`, so see
|
||||
its documentation for full details. Wildcards can be used, and checks can
|
||||
be disabled by prefixing a `-`. By default any checks listed are added to
|
||||
those in `.clang-tidy`, so if you'd like to limit the checks to specific
|
||||
ones you should first exclude all checks then add back what you want, like
|
||||
`--checks=-*,performance*`.
|
||||
|
||||
Running `clang-tidy` is rather slow - internally it compiles each file and
|
||||
then runs the checks so it will always be some factor slower than compilation.
|
||||
While you can use parallel runs to speed it up using the `--jobs|-j` option,
|
||||
`clang-tidy` also uses a lot of memory during its checks, so it can easily
|
||||
run into out-of-memory errors. As such the default number of jobs is one.
|
||||
@@ -47,7 +47,7 @@ formatted correctly.
|
||||
|
||||
## JavaScript
|
||||
|
||||
* Write [standard](https://npm.im/standard) JavaScript style.
|
||||
* Write [standard](https://www.npmjs.com/package/standard) JavaScript style.
|
||||
* File names should be concatenated with `-` instead of `_`, e.g.
|
||||
`file-name.js` rather than `file_name.js`, because in
|
||||
[github/atom](https://github.com/github/atom) module names are usually in
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
## Debugging with XCode
|
||||
|
||||
### Generate xcode project for debugging sources (cannot build code from xcode)
|
||||
|
||||
Run `gn gen` with the --ide=xcode argument.
|
||||
|
||||
```sh
|
||||
$ gn gen out/Testing --ide=xcode
|
||||
```
|
||||
|
||||
This will generate the electron.ninja.xcworkspace. You will have to open this workspace
|
||||
to set breakpoints and inspect.
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ you prefer a graphical interface.
|
||||
debugging C, Objective-C and C++ on the desktop and iOS devices and simulator.
|
||||
|
||||
* **.lldbinit**: Create or edit `~/.lldbinit` to allow Chromium code to be properly source-mapped.
|
||||
|
||||
```text
|
||||
command script import ~/electron/src/tools/lldb/lldbinit.py
|
||||
```
|
||||
@@ -120,6 +121,7 @@ Now, if you open up Electron's developer tools and call `setName`, you will once
|
||||
breakpoint.
|
||||
|
||||
### Further Reading
|
||||
|
||||
LLDB is a powerful tool with a great documentation. To learn more about it, consider
|
||||
Apple's debugging documentation, for instance the [LLDB Command Structure Reference][lldb-command-structure]
|
||||
or the introduction to [Using LLDB as a Standalone Debugger][lldb-standalone].
|
||||
@@ -129,4 +131,4 @@ will explain more complex debugging scenarios.
|
||||
|
||||
[lldb-command-structure]: https://developer.apple.com/library/mac/documentation/IDEs/Conceptual/gdb_to_lldb_transition_guide/document/lldb-basics.html#//apple_ref/doc/uid/TP40012917-CH2-SW2
|
||||
[lldb-standalone]: https://developer.apple.com/library/mac/documentation/IDEs/Conceptual/gdb_to_lldb_transition_guide/document/lldb-terminal-workflow-tutorial.html
|
||||
[lldb-tutorial]: http://lldb.llvm.org/tutorial.html
|
||||
[lldb-tutorial]: https://lldb.llvm.org/tutorial.html
|
||||
|
||||
@@ -19,7 +19,7 @@ application.
|
||||
|
||||
Electron works more like the Node.js runtime. Electron's APIs are lower level so
|
||||
you can use it for browser testing in place of
|
||||
[PhantomJS](http://phantomjs.org/).
|
||||
[PhantomJS](https://phantomjs.org/).
|
||||
|
||||
## 2) Node Integration
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ To help manage these patch sets, we provide two tools: `git-import-patches` and
|
||||
### Usage
|
||||
|
||||
#### Adding a new patch
|
||||
|
||||
```bash
|
||||
$ cd src/third_party/electron_node
|
||||
$ vim some/code/file.cc
|
||||
@@ -53,6 +54,7 @@ $ ../../electron/script/git-export-patches -o ../../electron/patches/node
|
||||
Re-exporting patches will sometimes cause shasums in unrelated patches to change. This is generally harmless and can be ignored (but go ahead and add those changes to your PR, it'll stop them from showing up for other people).
|
||||
|
||||
#### Editing an existing patch
|
||||
|
||||
```bash
|
||||
$ cd src/v8
|
||||
$ vim some/code/file.cc
|
||||
@@ -64,6 +66,7 @@ $ ../electron/script/git-export-patches -o ../electron/patches/v8
|
||||
```
|
||||
|
||||
#### Removing a patch
|
||||
|
||||
```bash
|
||||
$ vim src/electron/patches/node/.patches
|
||||
# Delete the line with the name of the patch you want to remove
|
||||
@@ -76,6 +79,7 @@ $ ../../electron/script/git-export-patches -o ../../electron/patches/node
|
||||
Note that `git-import-patches` will mark the commit that was `HEAD` when it was run as `refs/patches/upstream-head`. This lets you keep track of which commits are from Electron patches (those that come after `refs/patches/upstream-head`) and which commits are in upstream (those before `refs/patches/upstream-head`).
|
||||
|
||||
#### Resolving conflicts
|
||||
|
||||
When updating an upstream dependency, patches may fail to apply cleanly. Often, the conflict can be resolved automatically by git with a 3-way merge. You can instruct `git-import-patches` to use the 3-way merge algorithm by passing the `-3` argument:
|
||||
|
||||
```bash
|
||||
|
||||
@@ -35,6 +35,7 @@ $ git fetch upstream
|
||||
|
||||
Build steps and dependencies differ slightly depending on your operating system.
|
||||
See these detailed guides on building Electron locally:
|
||||
|
||||
* [Building on macOS](https://electronjs.org/docs/development/build-instructions-macos)
|
||||
* [Building on Linux](https://electronjs.org/docs/development/build-instructions-linux)
|
||||
* [Building on Windows](https://electronjs.org/docs/development/build-instructions-windows)
|
||||
@@ -96,16 +97,16 @@ Examples of commit messages with semantic prefixes:
|
||||
|
||||
Common prefixes:
|
||||
|
||||
- fix: A bug fix
|
||||
- feat: A new feature
|
||||
- docs: Documentation changes
|
||||
- test: Adding missing tests or correcting existing tests
|
||||
- build: Changes that affect the build system
|
||||
- ci: Changes to our CI configuration files and scripts
|
||||
- perf: A code change that improves performance
|
||||
- refactor: A code change that neither fixes a bug nor adds a feature
|
||||
- style: Changes that do not affect the meaning of the code (linting)
|
||||
- vendor: Bumping a dependency like libchromiumcontent or node
|
||||
- fix: A bug fix
|
||||
- feat: A new feature
|
||||
- docs: Documentation changes
|
||||
- test: Adding missing tests or correcting existing tests
|
||||
- build: Changes that affect the build system
|
||||
- ci: Changes to our CI configuration files and scripts
|
||||
- perf: A code change that improves performance
|
||||
- refactor: A code change that neither fixes a bug nor adds a feature
|
||||
- style: Changes that do not affect the meaning of the code (linting)
|
||||
- vendor: Bumping a dependency like libchromiumcontent or node
|
||||
|
||||
Other things to keep in mind when writing a commit message:
|
||||
|
||||
@@ -257,4 +258,3 @@ failure must be manually inspected to determine the cause.
|
||||
CI starts automatically when you open a pull request, but only
|
||||
core maintainers can restart a CI run. If you believe CI is giving a
|
||||
false negative, ask a maintainer to restart the tests.
|
||||
|
||||
|
||||
@@ -43,8 +43,8 @@ SRV*c:\code\symbols\*https://msdl.microsoft.com/download/symbols;SRV*c:\code\sym
|
||||
|
||||
## Using the symbol server in Visual Studio
|
||||
|
||||
<img src='https://mdn.mozillademos.org/files/733/symbol-server-vc8express-menu.jpg'>
|
||||
<img src='https://mdn.mozillademos.org/files/2497/2005_options.gif'>
|
||||

|
||||

|
||||
|
||||
## Troubleshooting: Symbols will not load
|
||||
|
||||
|
||||
@@ -90,6 +90,7 @@ Electron
|
||||
* **out** - Temporary output directory of `ninja`.
|
||||
* **script** - Scripts used for development purpose like building, packaging,
|
||||
testing, etc.
|
||||
|
||||
```diff
|
||||
script/ - The set of all scripts Electron runs for a variety of purposes.
|
||||
├── codesign/ - Fakes codesigning for Electron apps; used for testing.
|
||||
@@ -98,8 +99,8 @@ script/ - The set of all scripts Electron runs for a variety of purposes.
|
||||
├── notes/ - Generates release notes for new Electron versions.
|
||||
└── uploaders/ - Uploads various release-related files during release.
|
||||
```
|
||||
|
||||
* **tools** - Helper scripts used by GN files.
|
||||
* Scripts put here should never be invoked by users directly, unlike those in `script`.
|
||||
* **typings** - TypeScript typings for Electron's internal code.
|
||||
* **vendor** - Source code for some third party dependencies.
|
||||
|
||||
|
||||
@@ -56,10 +56,13 @@ would run `npm run test -- -g ipc`.
|
||||
|
||||
1. Visual Studio 2019 must be installed.
|
||||
2. Node headers have to be compiled for your configuration.
|
||||
|
||||
```powershell
|
||||
ninja -C out\Testing third_party\electron_node:headers
|
||||
```
|
||||
|
||||
3. The electron.lib has to be copied as node.lib.
|
||||
|
||||
```powershell
|
||||
cd out\Testing
|
||||
mkdir gen\node_headers\Release
|
||||
@@ -69,6 +72,7 @@ would run `npm run test -- -g ipc`.
|
||||
#### Missing fonts
|
||||
|
||||
[Some Windows 10 devices](https://docs.microsoft.com/en-us/typography/fonts/windows_10_font_list) do not ship with the Meiryo font installed, which may cause a font fallback test to fail. To install Meiryo:
|
||||
|
||||
1. Push the Windows key and search for _Manage optional features_.
|
||||
2. Click _Add a feature_.
|
||||
3. Select _Japanese Supplemental Fonts_ and click _Install_.
|
||||
@@ -80,5 +84,6 @@ devices with Hi-DPI screen settings due to floating point precision errors.
|
||||
To run these tests correctly, make sure the device is set to 100% scaling.
|
||||
|
||||
To configure display scaling:
|
||||
|
||||
1. Push the Windows key and search for _Display settings_.
|
||||
2. Under _Scale and layout_, make sure that the device is set to 100%.
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
> A collection of resources for learning and using V8
|
||||
|
||||
* [V8 Tracing](https://github.com/v8/v8/wiki/Tracing-V8)
|
||||
* [V8 Profiler](https://github.com/v8/v8/wiki/V8-Profiler) - Profiler combinations which are useful for profiling: `--prof`, `--trace-ic`, `--trace-opt`, `--trace-deopt`, `--print-bytecode`, `--print-opt-code`
|
||||
* [V8 Tracing](https://v8.dev/docs/trace)
|
||||
* [V8 Profiler](https://v8.dev/docs/profile) - Profiler combinations which are useful for profiling: `--prof`, `--trace-ic`, `--trace-opt`, `--trace-deopt`, `--print-bytecode`, `--print-opt-code`
|
||||
* [V8 Interpreter Design](https://docs.google.com/document/d/11T2CRex9hXxoJwbYqVQ32yIPMh0uouUZLdyrtmMoL44/edit?ts=56f27d9d#heading=h.6jz9dj3bnr8t)
|
||||
* [Optimizing compiler](https://github.com/v8/v8/wiki/TurboFan)
|
||||
* [V8 GDB Debugging](https://github.com/v8/v8/wiki/GDB-JIT-Interface)
|
||||
* [Optimizing compiler](https://v8.dev/docs/turbofan)
|
||||
* [V8 GDB Debugging](https://v8.dev/docs/gdb-jit)
|
||||
|
||||
See also [Chromium Development](chromium-development.md)
|
||||
|
||||
@@ -133,7 +133,7 @@ is only available in renderer processes.
|
||||
|
||||
## The font looks blurry, what is this and what can I do?
|
||||
|
||||
If [sub-pixel anti-aliasing](http://alienryderflex.com/sub_pixel/) is deactivated, then fonts on LCD screens can look blurry. Example:
|
||||
If [sub-pixel anti-aliasing](https://alienryderflex.com/sub_pixel/) is deactivated, then fonts on LCD screens can look blurry. Example:
|
||||
|
||||
![subpixel rendering example]
|
||||
|
||||
|
||||
@@ -159,7 +159,7 @@ building it.
|
||||
V8's version numbers always correspond to those of Google Chrome. Chrome 59
|
||||
includes V8 5.9, Chrome 58 includes V8 5.8, etc.
|
||||
|
||||
- [developers.google.com/v8](https://developers.google.com/v8)
|
||||
- [v8.dev](https://v8.dev/)
|
||||
- [nodejs.org/api/v8.html](https://nodejs.org/api/v8.html)
|
||||
- [docs/development/v8-development.md](development/v8-development.md)
|
||||
|
||||
|
||||
BIN
docs/images/dark_mode.gif
Normal file
BIN
docs/images/dark_mode.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.0 MiB |
@@ -48,7 +48,7 @@ For API references, there are exceptions to this rule.
|
||||
* Lines should be wrapped at 80 columns.
|
||||
* No nesting lists more than 2 levels (due to the markdown renderer).
|
||||
* All `js` and `javascript` code blocks are linted with
|
||||
[standard-markdown](http://npm.im/standard-markdown).
|
||||
[standard-markdown](https://www.npmjs.com/package/standard-markdown).
|
||||
|
||||
## Picking words
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ To distribute your app with Electron, you need to package and rebrand it. The ea
|
||||
These tools will take care of all the steps you need to take to end up with a distributable Electron applications, such as packaging your application, rebranding the executable, setting the right icons and optionally creating installers.
|
||||
|
||||
## Manual distribution
|
||||
|
||||
You can also choose to manually get your app ready for distribution. The steps needed to do this are outlined below.
|
||||
|
||||
To distribute your app with Electron, you need to download Electron's [prebuilt
|
||||
@@ -143,16 +144,16 @@ we appreciate your help.
|
||||
|
||||
3. Set the following Environment Variables:
|
||||
|
||||
* `ELECTRON_GITHUB_TOKEN` - a token that can create releases on GitHub
|
||||
* `ELECTRON_S3_ACCESS_KEY`, `ELECTRON_S3_BUCKET`, `ELECTRON_S3_SECRET_KEY` -
|
||||
the place where you'll upload Node.js headers as well as symbols
|
||||
* `ELECTRON_RELEASE` - Set to `true` and the upload part will run, leave unset
|
||||
and `surf-build` will do CI-type checks, appropriate to run for every
|
||||
pull request.
|
||||
* `CI` - Set to `true` or else it will fail
|
||||
* `GITHUB_TOKEN` - set it to the same as `ELECTRON_GITHUB_TOKEN`
|
||||
* `SURF_TEMP` - set to `C:\Temp` on Windows to prevent path too long issues
|
||||
* `TARGET_ARCH` - set to `ia32` or `x64`
|
||||
* `ELECTRON_GITHUB_TOKEN` - a token that can create releases on GitHub
|
||||
* `ELECTRON_S3_ACCESS_KEY`, `ELECTRON_S3_BUCKET`, `ELECTRON_S3_SECRET_KEY` -
|
||||
the place where you'll upload Node.js headers as well as symbols
|
||||
* `ELECTRON_RELEASE` - Set to `true` and the upload part will run, leave unset
|
||||
and `surf-build` will do CI-type checks, appropriate to run for every
|
||||
pull request.
|
||||
* `CI` - Set to `true` or else it will fail
|
||||
* `GITHUB_TOKEN` - set it to the same as `ELECTRON_GITHUB_TOKEN`
|
||||
* `SURF_TEMP` - set to `C:\Temp` on Windows to prevent path too long issues
|
||||
* `TARGET_ARCH` - set to `ia32` or `x64`
|
||||
|
||||
4. In `script/upload.py`, you _must_ set `ELECTRON_REPO` to your fork (`MYORG/electron`),
|
||||
especially if you are a contributor to Electron proper.
|
||||
|
||||
@@ -192,4 +192,3 @@ and should be shipped together with the `app.asar` archive.
|
||||
[electron-packager]: https://github.com/electron/electron-packager
|
||||
[electron-forge]: https://github.com/electron-userland/electron-forge
|
||||
[electron-builder]: https://github.com/electron-userland/electron-builder
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Automated Testing with a Custom Driver
|
||||
|
||||
To write automated tests for your Electron app, you will need a way to "drive" your application. [Spectron](https://electronjs.org/spectron) is a commonly-used solution which lets you emulate user actions via [WebDriver](http://webdriver.io/). However, it's also possible to write your own custom driver using node's builtin IPC-over-STDIO. The benefit of a custom driver is that it tends to require less overhead than Spectron, and lets you expose custom methods to your test suite.
|
||||
To write automated tests for your Electron app, you will need a way to "drive" your application. [Spectron](https://electronjs.org/spectron) is a commonly-used solution which lets you emulate user actions via [WebDriver](https://webdriver.io/). However, it's also possible to write your own custom driver using node's builtin IPC-over-STDIO. The benefit of a custom driver is that it tends to require less overhead than Spectron, and lets you expose custom methods to your test suite.
|
||||
|
||||
To create a custom driver, we'll use Node.js' [child_process](https://nodejs.org/api/child_process.html) API. The test suite will spawn the Electron process, then establish a simple messaging protocol:
|
||||
|
||||
|
||||
@@ -67,4 +67,3 @@ contextBridge.exposeInMainWorld('myAPI', {
|
||||
loadPreferences: () => ipcRenderer.invoke('load-prefs')
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
202
docs/tutorial/dark-mode.md
Normal file
202
docs/tutorial/dark-mode.md
Normal file
@@ -0,0 +1,202 @@
|
||||
# Dark Mode
|
||||
|
||||
## Overview
|
||||
|
||||
### Automatically update the native interfaces
|
||||
|
||||
"Native interfaces" include the file picker, window border, dialogs, context
|
||||
menus, and more - anything where the UI comes from your operating system and
|
||||
not from your app. The default behavior is to opt into this automatic theming
|
||||
from the OS.
|
||||
|
||||
### Automatically update your own interfaces
|
||||
|
||||
If your app has its own dark mode, you should toggle it on and off in sync with
|
||||
the system's dark mode setting. You can do this by using the
|
||||
[prefer-color-scheme] CSS media query.
|
||||
|
||||
### Manually update your own interfaces
|
||||
|
||||
If you want to manually switch between light/dark modes, you can do this by
|
||||
setting the desired mode in the
|
||||
[themeSource](https://www.electronjs.org/docs/api/native-theme#nativethemethemesource)
|
||||
property of the `nativeTheme` module. This property's value will be propagated
|
||||
to your Renderer process. Any CSS rules related to `prefers-color-scheme` will
|
||||
be updated accordingly.
|
||||
|
||||
## macOS settings
|
||||
|
||||
In macOS 10.14 Mojave, Apple introduced a new [system-wide dark mode][system-wide-dark-mode]
|
||||
for all macOS computers. If your Electron app has a dark mode, you can make it
|
||||
follow the system-wide dark mode setting using
|
||||
[the `nativeTheme` api](../api/native-theme.md).
|
||||
|
||||
In macOS 10.15 Catalina, Apple introduced a new "automatic" dark mode option
|
||||
for all macOS computers. In order for the `nativeTheme.shouldUseDarkColors` and
|
||||
`Tray` APIs to work correctly in this mode on Catalina, you need to use Electron
|
||||
`>=7.0.0`, or set `NSRequiresAquaSystemAppearance` to `false` in your
|
||||
`Info.plist` file for older versions. Both [Electron Packager][electron-packager]
|
||||
and [Electron Forge][electron-forge] have a
|
||||
[`darwinDarkModeSupport` option][packager-darwindarkmode-api]
|
||||
to automate the `Info.plist` changes during app build time.
|
||||
|
||||
If you wish to opt-out while using Electron > 8.0.0, you must
|
||||
set the `NSRequiresAquaSystemAppearance` key in the `Info.plist` file to
|
||||
`true`. Please note that Electron 8.0.0 and above will not let you opt-out
|
||||
of this theming, due to the use of the macOS 10.14 SDK.
|
||||
|
||||
## Example
|
||||
|
||||
We'll start with a working application from the
|
||||
[Quick Start Guide](quick-start.md) and add functionality gradually.
|
||||
|
||||
First, let's edit our interface so users can toggle between light and dark
|
||||
modes. This basic UI contains buttons to change the `nativeTheme.themeSource`
|
||||
setting and a text element indicating which `themeSource` value is selected.
|
||||
By default, Electron follows the system's dark mode preference, so we
|
||||
will hardcode the theme source as "System".
|
||||
|
||||
Add the following lines to the `index.html` file:
|
||||
|
||||
```html
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Hello World!</title>
|
||||
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline';" />
|
||||
<link rel="stylesheet" type="text/css" href="./styles.css">
|
||||
</head>
|
||||
<body>
|
||||
<h1>Hello World!</h1>
|
||||
<p>Current theme source: <strong id="theme-source">System</strong></p>
|
||||
|
||||
<button id="toggle-dark-mode">Toggle Dark Mode</button>
|
||||
<button id="reset-to-system">Reset to System Theme</button>
|
||||
|
||||
<script src="renderer.js"></script>
|
||||
</body>
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
|
||||
Next, add [event listeners](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener)
|
||||
that listen for `click` events on the toggle buttons. Because the `nativeTheme`
|
||||
module only exposed in the Main process, you need to set up each listener's
|
||||
callback to use IPC to send messages to and handle responses from the Main
|
||||
process:
|
||||
|
||||
* when the "Toggle Dark Mode" button is clicked, we send the
|
||||
`dark-mode:toggle` message (event) to tell the Main process to trigger a theme
|
||||
change, and update the "Current Theme Source" label in the UI based on the
|
||||
response from the Main process.
|
||||
* when the "Reset to System Theme" button is clicked, we send the
|
||||
`dark-mode:system` message (event) to tell the Main process to use the system
|
||||
color scheme, and update the "Current Theme Source" label to `System`.
|
||||
|
||||
To add listeners and handlers, add the following lines to the `renderer.js` file:
|
||||
|
||||
```js
|
||||
const { ipcRenderer } = require('electron')
|
||||
|
||||
document.getElementById('toggle-dark-mode').addEventListener('click', async () => {
|
||||
const isDarkMode = await ipcRenderer.invoke('dark-mode:toggle')
|
||||
document.getElementById('theme-source').innerHTML = isDarkMode ? 'Dark' : 'Light'
|
||||
})
|
||||
|
||||
document.getElementById('reset-to-system').addEventListener('click', async () => {
|
||||
await ipcRenderer.invoke('dark-mode:system')
|
||||
document.getElementById('theme-source').innerHTML = 'System'
|
||||
})
|
||||
```
|
||||
|
||||
If you run your code at this point, you'll see that your buttons don't do
|
||||
anything just yet, and your Main process will output an error like this when
|
||||
you click on your buttons:
|
||||
`Error occurred in handler for 'dark-mode:toggle': No handler registered for 'dark-mode:toggle'`
|
||||
This is expected — we haven't actually touched any `nativeTheme` code yet.
|
||||
|
||||
Now that we're done wiring the IPC from the Renderer's side, the next step
|
||||
is to update the `main.js` file to handle events from the Renderer process.
|
||||
|
||||
Depending on the received event, we update the
|
||||
[`nativeTheme.themeSource`](../api/native-theme.md#nativethemethemesource)
|
||||
property to apply the desired theme on the system's native UI elements
|
||||
(e.g. context menus) and propagate the preferred color scheme to the Renderer
|
||||
process:
|
||||
|
||||
* Upon receiving `dark-mode:toggle`, we check if the dark theme is currently
|
||||
active using the `nativeTheme.shouldUseDarkColors` property, and set the
|
||||
`themeSource` to the opposite theme.
|
||||
* Upon receiving `dark-mode:system`, we reset the `themeSource` to `system`.
|
||||
|
||||
```js
|
||||
const { app, BrowserWindow, ipcMain, nativeTheme } = require('electron')
|
||||
|
||||
function createWindow () {
|
||||
const win = new BrowserWindow({
|
||||
width: 800,
|
||||
height: 600,
|
||||
webPreferences: {
|
||||
nodeIntegration: true
|
||||
}
|
||||
})
|
||||
|
||||
win.loadFile('index.html')
|
||||
|
||||
ipcMain.handle('dark-mode:toggle', () => {
|
||||
if (nativeTheme.shouldUseDarkColors) {
|
||||
nativeTheme.themeSource = 'light'
|
||||
} else {
|
||||
nativeTheme.themeSource = 'dark'
|
||||
}
|
||||
return nativeTheme.shouldUseDarkColors
|
||||
})
|
||||
|
||||
ipcMain.handle('dark-mode:system', () => {
|
||||
nativeTheme.themeSouce = 'system'
|
||||
})
|
||||
}
|
||||
|
||||
app.whenReady().then(createWindow)
|
||||
|
||||
app.on('window-all-closed', () => {
|
||||
if (process.platform !== 'darwin') {
|
||||
app.quit()
|
||||
}
|
||||
})
|
||||
|
||||
app.on('activate', () => {
|
||||
if (BrowserWindow.getAllWindows().length === 0) {
|
||||
createWindow()
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
The final step is to add a bit of styling to enable dark mode for the web parts
|
||||
of the UI by leveraging the [`prefers-color-scheme`][prefer-color-scheme] CSS
|
||||
attribute. The value of `prefers-color-scheme` will follow your
|
||||
`nativeTheme.themeSource` setting.
|
||||
|
||||
Create a `styles.css` file and add the following lines:
|
||||
|
||||
```css
|
||||
@media (prefers-color-scheme: dark) {
|
||||
body { background: #333; color: white; }
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: light) {
|
||||
body { background: #ddd; color: black; }
|
||||
}
|
||||
```
|
||||
|
||||
After launching the Electron application, you can change modes or reset the
|
||||
theme to system default by clicking corresponding buttons:
|
||||
|
||||

|
||||
|
||||
[system-wide-dark-mode]: https://developer.apple.com/design/human-interface-guidelines/macos/visual-design/dark-mode/
|
||||
[electron-forge]: https://www.electronforge.io/
|
||||
[electron-packager]: https://github.com/electron/electron-packager
|
||||
[packager-darwindarkmode-api]: https://electron.github.io/electron-packager/master/interfaces/electronpackager.options.html#darwindarkmodesupport
|
||||
[prefer-color-scheme]: https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme
|
||||
@@ -1,37 +0,0 @@
|
||||
# Debugging the Main Process in VSCode
|
||||
|
||||
### 1. Open an Electron project in VSCode.
|
||||
|
||||
```sh
|
||||
$ git clone git@github.com:electron/electron-quick-start.git
|
||||
$ code electron-quick-start
|
||||
```
|
||||
|
||||
### 2. Add a file `.vscode/launch.json` with the following configuration:
|
||||
|
||||
```json
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Debug Main Process",
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"cwd": "${workspaceFolder}",
|
||||
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron",
|
||||
"windows": {
|
||||
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron.cmd"
|
||||
},
|
||||
"args" : ["."],
|
||||
"outputCapture": "std"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
### 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
|
||||
@@ -30,4 +30,4 @@ You will need to use a debugger that supports the V8 inspector protocol.
|
||||
|
||||
- Connect Chrome by visiting `chrome://inspect` and selecting to inspect the
|
||||
launched Electron app present there.
|
||||
- [Debugging the Main Process in VSCode](debugging-main-process-vscode.md)
|
||||
- [Debugging in VSCode](debugging-vscode.md)
|
||||
|
||||
100
docs/tutorial/debugging-vscode.md
Normal file
100
docs/tutorial/debugging-vscode.md
Normal file
@@ -0,0 +1,100 @@
|
||||
# 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.
|
||||
|
||||
## Debugging your Electron app
|
||||
|
||||
### Main process
|
||||
|
||||
#### 1. Open an Electron project in VSCode.
|
||||
|
||||
```sh
|
||||
$ git clone git@github.com:electron/electron-quick-start.git
|
||||
$ code electron-quick-start
|
||||
```
|
||||
|
||||
#### 2. Add a file `.vscode/launch.json` with the following configuration:
|
||||
|
||||
```json
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Debug Main Process",
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"cwd": "${workspaceFolder}",
|
||||
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron",
|
||||
"windows": {
|
||||
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron.cmd"
|
||||
},
|
||||
"args" : ["."],
|
||||
"outputCapture": "std"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
#### 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
|
||||
|
||||
## 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.
|
||||
|
||||
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](https://www.electronjs.org/docs/development/build-instructions-gn).
|
||||
|
||||
### Windows (C++)
|
||||
|
||||
#### 1. Open an Electron project in VSCode.
|
||||
|
||||
```sh
|
||||
$ git clone git@github.com:electron/electron-quick-start.git
|
||||
$ code electron-quick-start
|
||||
```
|
||||
|
||||
#### 2. Add a file `.vscode/launch.json` with the following configuration:
|
||||
|
||||
```json
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "(Windows) Launch",
|
||||
"type": "cppvsdbg",
|
||||
"request": "launch",
|
||||
"program": "${workspaceFolder}\\out\\your-executable-location\\electron.exe",
|
||||
"args": ["your-electron-project-path"],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "${workspaceFolder}",
|
||||
"environment": [
|
||||
{"name": "ELECTRON_ENABLE_LOGGING", "value": "true"},
|
||||
{"name": "ELECTRON_ENABLE_STACK_DUMPING", "value": "true"},
|
||||
{"name": "ELECTRON_RUN_AS_NODE", "value": ""},
|
||||
],
|
||||
"externalConsole": false,
|
||||
"sourceFileMap": {
|
||||
"o:\\": "${workspaceFolder}",
|
||||
},
|
||||
},
|
||||
]
|
||||
}
|
||||
```
|
||||
**Configuration Notes**
|
||||
|
||||
- `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](https://www.electronjs.org/docs/development/build-instructions-gn#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`.
|
||||
|
||||
|
||||
#### 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).
|
||||
@@ -29,6 +29,7 @@ Using the [React Developer Tools][react-devtools] as example:
|
||||
* on macOS it is `~/Library/Application Support/Google/Chrome/Default/Extensions`.
|
||||
1. Pass the location of the extension to `BrowserWindow.addDevToolsExtension`
|
||||
API, for the React Developer Tools, it is something like:
|
||||
|
||||
```javascript
|
||||
const path = require('path')
|
||||
const os = require('os')
|
||||
|
||||
@@ -16,7 +16,7 @@ npm install --save-dev electron@latest
|
||||
|
||||
## Version 1.x
|
||||
|
||||
Electron versions *< 2.0* did not conform to the [semver](http://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, Stride, Teams, Skype, VS Code, Atom, and 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, Stride, Teams, Skype, VS Code, Atom, and 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:
|
||||
|
||||
@@ -48,7 +48,6 @@ Below is a table explicitly mapping types of changes to their corresponding cate
|
||||
| Node.js major version updates | Node.js minor version updates | Node.js patch version updates |
|
||||
| Chromium version updates | | fix-related chromium patches |
|
||||
|
||||
|
||||
Note that most Chromium updates will be considered breaking. Fixes that can be backported will likely be cherry-picked as patches.
|
||||
|
||||
# Stabilization Branches
|
||||
@@ -118,6 +117,7 @@ A few examples of how various semver ranges will pick up new releases:
|
||||

|
||||
|
||||
# Missing Features: Alphas
|
||||
|
||||
Our strategy has a few tradeoffs, which for now we feel are appropriate. Most importantly that new features in master may take a while before reaching a stable release line. If you want to try a new feature immediately, you will have to build Electron yourself.
|
||||
|
||||
As a future consideration, we may introduce one or both of the following:
|
||||
@@ -125,6 +125,7 @@ As a future consideration, we may introduce one or both of the following:
|
||||
* alpha releases that have looser stability constraints to betas; for example it would be allowable to admit new features while a stability channel is in _alpha_
|
||||
|
||||
# Feature Flags
|
||||
|
||||
Feature flags are a common practice in Chromium, and are well-established in the web-development ecosystem. In the context of Electron, a feature flag or **soft branch** must have the following properties:
|
||||
|
||||
* it is enabled/disabled either at runtime, or build-time; we do not support the concept of a request-scoped feature flag
|
||||
|
||||
@@ -3,11 +3,13 @@
|
||||
## Preparing
|
||||
|
||||
### Paid Applications Agreement
|
||||
|
||||
If you haven't already, you’ll need to sign the Paid Applications Agreement and set up your banking and tax information in iTunes Connect.
|
||||
|
||||
[iTunes Connect Developer Help: Agreements, tax, and banking overview](https://help.apple.com/itunes-connect/developer/#/devb6df5ee51)
|
||||
|
||||
### Create Your In-App Purchases
|
||||
|
||||
Then, you'll need to configure your in-app purchases in iTunes Connect, and include details such as name, pricing, and description that highlights the features and functionality of your in-app purchase.
|
||||
|
||||
[iTunes Connect Developer Help: Create an in-app purchase](https://help.apple.com/itunes-connect/developer/#/devae49fb316)
|
||||
|
||||
@@ -45,6 +45,7 @@ value, plus additional environment variables depending on your host system's Nod
|
||||
* [Before Node 10][proxy-env]
|
||||
|
||||
## Custom Mirrors and Caches
|
||||
|
||||
During installation, the `electron` module will call out to
|
||||
[`@electron/get`][electron-get] to download prebuilt binaries of
|
||||
Electron for your platform. It will do so by contacting GitHub's
|
||||
@@ -55,6 +56,7 @@ If you are unable to access GitHub or you need to provide a custom build, you
|
||||
can do so by either providing a mirror or an existing cache directory.
|
||||
|
||||
#### Mirror
|
||||
|
||||
You can use environment variables to override the base URL, the path at which to
|
||||
look for Electron binaries, and the binary filename. The URL used by `@electron/get`
|
||||
is composed as follows:
|
||||
@@ -84,6 +86,7 @@ The above configuration will download from URLs such as
|
||||
`https://npm.taobao.org/mirrors/electron/8.0.0/electron-v8.0.0-linux-x64.zip`.
|
||||
|
||||
#### Cache
|
||||
|
||||
Alternatively, you can override the local cache. `@electron/get` will cache
|
||||
downloaded binaries in a local directory to not stress your network. You can use
|
||||
that cache folder to provide custom builds of Electron or to avoid making contact
|
||||
@@ -126,12 +129,14 @@ a text file. A typical cache might look like this:
|
||||
```
|
||||
|
||||
## Skip binary download
|
||||
|
||||
When installing the `electron` NPM package, it automatically downloads the electron binary.
|
||||
|
||||
This can sometimes be unnecessary, e.g. in a CI environment, when testing another component.
|
||||
|
||||
To prevent the binary from being downloaded when you install all npm dependencies you can set the environment variable `ELECTRON_SKIP_BINARY_DOWNLOAD`.
|
||||
E.g.:
|
||||
|
||||
```sh
|
||||
ELECTRON_SKIP_BINARY_DOWNLOAD=1 npm install
|
||||
```
|
||||
|
||||
@@ -242,14 +242,14 @@ Electron uses following cryptographic algorithms:
|
||||
* ECDH - ANS X9.63–2001
|
||||
* HKDF - [NIST SP 800-56C](https://csrc.nist.gov/publications/nistpubs/800-56C/SP-800-56C.pdf)
|
||||
* PBKDF2 - [RFC 2898](https://tools.ietf.org/html/rfc2898)
|
||||
* RSA - [RFC 3447](http://www.ietf.org/rfc/rfc3447)
|
||||
* RSA - [RFC 3447](https://www.ietf.org/rfc/rfc3447)
|
||||
* SHA - [FIPS 180-4](https://csrc.nist.gov/publications/fips/fips180-4/fips-180-4.pdf)
|
||||
* Blowfish - https://www.schneier.com/cryptography/blowfish/
|
||||
* CAST - [RFC 2144](https://tools.ietf.org/html/rfc2144), [RFC 2612](https://tools.ietf.org/html/rfc2612)
|
||||
* DES - [FIPS 46-3](https://csrc.nist.gov/publications/fips/fips46-3/fips46-3.pdf)
|
||||
* DH - [RFC 2631](https://tools.ietf.org/html/rfc2631)
|
||||
* DSA - [ANSI X9.30](https://webstore.ansi.org/RecordDetail.aspx?sku=ANSI+X9.30-1%3A1997)
|
||||
* EC - [SEC 1](http://www.secg.org/sec1-v2.pdf)
|
||||
* EC - [SEC 1](https://www.secg.org/sec1-v2.pdf)
|
||||
* IDEA - "On the Design and Security of Block Ciphers" book by X. Lai
|
||||
* MD2 - [RFC 1319](https://tools.ietf.org/html/rfc1319)
|
||||
* MD4 - [RFC 6150](https://tools.ietf.org/html/rfc6150)
|
||||
@@ -257,7 +257,7 @@ Electron uses following cryptographic algorithms:
|
||||
* MDC2 - [ISO/IEC 10118-2](https://wiki.openssl.org/index.php/Manual:Mdc2(3))
|
||||
* RC2 - [RFC 2268](https://tools.ietf.org/html/rfc2268)
|
||||
* RC4 - [RFC 4345](https://tools.ietf.org/html/rfc4345)
|
||||
* RC5 - http://people.csail.mit.edu/rivest/Rivest-rc5rev.pdf
|
||||
* RC5 - https://people.csail.mit.edu/rivest/Rivest-rc5rev.pdf
|
||||
* RIPEMD - [ISO/IEC 10118-3](https://webstore.ansi.org/RecordDetail.aspx?sku=ISO%2FIEC%2010118-3:2004)
|
||||
|
||||
[developer-program]: https://developer.apple.com/support/compare-memberships/
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
# Supporting macOS Dark Mode
|
||||
|
||||
In macOS 10.14 Mojave, Apple introduced a new [system-wide dark mode](https://developer.apple.com/design/human-interface-guidelines/macos/visual-design/dark-mode/)
|
||||
for all macOS computers. If your Electron app has a dark mode, you can make it follow the
|
||||
system-wide dark mode setting using [the `nativeTheme` api](../api/native-theme.md).
|
||||
|
||||
In macOS 10.15 Catalina, Apple introduced a new "automatic" dark mode option for all macOS computers.
|
||||
In order for the `nativeTheme.shouldUseDarkColors` and `Tray` APIs to work correctly in this mode on
|
||||
Catalina, you need to either have `NSRequiresAquaSystemAppearance` set to `false` in your
|
||||
`Info.plist` file, or be on Electron `>=7.0.0`. Both [Electron Packager][electron-packager] and
|
||||
[Electron Forge][electron-forge] have a [`darwinDarkModeSupport` option][packager-darwindarkmode-api]
|
||||
to automate the `Info.plist` changes during app build time.
|
||||
|
||||
## Automatically updating the native interfaces
|
||||
|
||||
"Native Interfaces" include the file picker, window border, dialogs, context menus, and more; basically,
|
||||
anything where the UI comes from macOS and not your app. As of Electron 7.0.0, the default behavior
|
||||
is to opt into this automatic theming from the OS. If you wish to opt-out and are using Electron
|
||||
> 8.0.0, you must set the `NSRequiresAquaSystemAppearance` key in the `Info.plist` file to `true`.
|
||||
Please note that Electron 8.0.0 and above will not let you opt-out of this theming, due to the use
|
||||
of the macOS 10.14 SDK.
|
||||
|
||||
## Automatically updating your own interfaces
|
||||
|
||||
If your app has its own dark mode, you should toggle it on and off in sync with the system's dark
|
||||
mode setting. You can do this by listening for the theme updated event on Electron's `nativeTheme` module.
|
||||
|
||||
For example:
|
||||
|
||||
```javascript
|
||||
const { nativeTheme } = require('electron')
|
||||
|
||||
nativeTheme.on('updated', function theThemeHasChanged () {
|
||||
updateMyAppTheme(nativeTheme.shouldUseDarkColors)
|
||||
})
|
||||
```
|
||||
|
||||
[electron-forge]: https://www.electronforge.io/
|
||||
[electron-packager]: https://github.com/electron/electron-packager
|
||||
[packager-darwindarkmode-api]: https://electron.github.io/electron-packager/master/interfaces/electronpackager.options.html#darwindarkmodesupport
|
||||
@@ -8,6 +8,7 @@ detection can be implemented in the Renderer process using the
|
||||
attribute, part of standard HTML5 API.
|
||||
|
||||
The `navigator.onLine` attribute returns:
|
||||
|
||||
* `false` if all network requests are guaranteed to fail (e.g. when disconnected from the network).
|
||||
* `true` in all other cases.
|
||||
|
||||
|
||||
@@ -46,8 +46,8 @@ at once, consider the [Chrome Tracing](https://www.chromium.org/developers/how-t
|
||||
|
||||
### Recommended Reading
|
||||
|
||||
* [Get Started With Analyzing Runtime Performance][chrome-devtools-tutorial]
|
||||
* [Talk: "Visual Studio Code - The First Second"][vscode-first-second]
|
||||
* [Get Started With Analyzing Runtime Performance][chrome-devtools-tutorial]
|
||||
* [Talk: "Visual Studio Code - The First Second"][vscode-first-second]
|
||||
|
||||
## Checklist
|
||||
|
||||
@@ -104,7 +104,7 @@ connectivity checks included in later versions of Chromium.
|
||||
When considering a module, we recommend that you check:
|
||||
|
||||
1. the size of dependencies included
|
||||
2) the resources required to load (`require()`) it
|
||||
2. the resources required to load (`require()`) it
|
||||
3. the resources required to perform the action you're interested in
|
||||
|
||||
Generating a CPU profile and a heap memory profile for loading a module can be done
|
||||
@@ -264,7 +264,6 @@ core Node.js modules (like `fs` or `child_process`) offer a synchronous or an
|
||||
asynchronous version, you should prefer the asynchronous and non-blocking
|
||||
variant.
|
||||
|
||||
|
||||
## 4) Blocking the renderer process
|
||||
|
||||
Since Electron ships with a current version of Chrome, you can make use of the
|
||||
@@ -301,7 +300,6 @@ some caveats to consider – consult Electron's
|
||||
for any operation that requires a lot of CPU power for an extended period of
|
||||
time.
|
||||
|
||||
|
||||
## 5) Unnecessary polyfills
|
||||
|
||||
One of Electron's great benefits is that you know exactly which engine will
|
||||
@@ -340,7 +338,6 @@ If you're using a transpiler/compiler like TypeScript, examine its configuration
|
||||
and ensure that you're targeting the latest ECMAScript version supported by
|
||||
Electron.
|
||||
|
||||
|
||||
## 6) Unnecessary or blocking network requests
|
||||
|
||||
Avoid fetching rarely changing resources from the internet if they could easily
|
||||
|
||||
@@ -12,6 +12,7 @@ The `repl` module provides a REPL implementation that can be accessed using:
|
||||
```sh
|
||||
./node_modules/.bin/electron --interactive
|
||||
```
|
||||
|
||||
* Assuming you have `electron` or `electron-prebuilt` installed globally:
|
||||
|
||||
```sh
|
||||
|
||||
@@ -56,7 +56,6 @@ is your own code. Common web vulnerabilities, such as Cross-Site Scripting (XSS)
|
||||
have a higher security impact on Electron applications hence it is highly recommended
|
||||
to adopt secure software development best practices and perform security testing.
|
||||
|
||||
|
||||
## Isolation For Untrusted Content
|
||||
|
||||
A security issue exists whenever you receive code from an untrusted source (e.g.
|
||||
@@ -150,7 +149,6 @@ browserWindow.loadURL('https://example.com')
|
||||
<link rel="stylesheet" href="https://example.com/style.css">
|
||||
```
|
||||
|
||||
|
||||
## 2) Do not enable Node.js Integration for Remote Content
|
||||
|
||||
_This recommendation is the default behavior in Electron since 5.0.0._
|
||||
@@ -225,7 +223,6 @@ window.readConfig = function () {
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## 3) Enable Context Isolation for Remote Content
|
||||
|
||||
Context isolation is an Electron feature that allows developers to run code
|
||||
@@ -244,7 +241,6 @@ prevent the use of Node primitives, `contextIsolation` must also be used.
|
||||
For more information on what `contextIsolation` is and how to enable it please
|
||||
see our dedicated [Context Isolation](context-isolation.md) document.
|
||||
|
||||
|
||||
## 4) Handle Session Permission Requests From Remote Content
|
||||
|
||||
You may have seen permission requests while using Chrome: They pop up whenever
|
||||
@@ -283,7 +279,6 @@ session
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
## 5) Do Not Disable WebSecurity
|
||||
|
||||
_Recommendation is Electron's default_
|
||||
@@ -302,6 +297,7 @@ Disabling `webSecurity` will disable the same-origin policy and set
|
||||
the execution of insecure code from different domains.
|
||||
|
||||
### How?
|
||||
|
||||
```js
|
||||
// Bad
|
||||
const mainWindow = new BrowserWindow({
|
||||
@@ -324,7 +320,6 @@ const mainWindow = new BrowserWindow()
|
||||
<webview src="page.html"></webview>
|
||||
```
|
||||
|
||||
|
||||
## 6) Define a Content Security Policy
|
||||
|
||||
A Content Security Policy (CSP) is an additional layer of protection against
|
||||
@@ -381,7 +376,6 @@ on a page directly in the markup using a `<meta>` tag:
|
||||
<meta http-equiv="Content-Security-Policy" content="default-src 'none'">
|
||||
```
|
||||
|
||||
|
||||
## 7) Do Not Set `allowRunningInsecureContent` to `true`
|
||||
|
||||
_Recommendation is Electron's default_
|
||||
@@ -415,7 +409,6 @@ const mainWindow = new BrowserWindow({
|
||||
const mainWindow = new BrowserWindow({})
|
||||
```
|
||||
|
||||
|
||||
## 8) Do Not Enable Experimental Features
|
||||
|
||||
_Recommendation is Electron's default_
|
||||
@@ -448,7 +441,6 @@ const mainWindow = new BrowserWindow({
|
||||
const mainWindow = new BrowserWindow({})
|
||||
```
|
||||
|
||||
|
||||
## 9) Do Not Use `enableBlinkFeatures`
|
||||
|
||||
_Recommendation is Electron's default_
|
||||
@@ -466,6 +458,7 @@ ramifications are, and how it impacts the security of your application. Under
|
||||
no circumstances should you enable features speculatively.
|
||||
|
||||
### How?
|
||||
|
||||
```js
|
||||
// Bad
|
||||
const mainWindow = new BrowserWindow({
|
||||
@@ -480,7 +473,6 @@ const mainWindow = new BrowserWindow({
|
||||
const mainWindow = new BrowserWindow()
|
||||
```
|
||||
|
||||
|
||||
## 10) Do Not Use `allowpopups`
|
||||
|
||||
_Recommendation is Electron's default_
|
||||
@@ -508,7 +500,6 @@ you know it needs that feature.
|
||||
<webview src="page.html"></webview>
|
||||
```
|
||||
|
||||
|
||||
## 11) Verify WebView Options Before Creation
|
||||
|
||||
A WebView created in a renderer process that does not have Node.js integration
|
||||
@@ -660,6 +651,7 @@ leveraged to execute arbitrary commands.
|
||||
const { shell } = require('electron')
|
||||
shell.openExternal(USER_CONTROLLED_DATA_HERE)
|
||||
```
|
||||
|
||||
```js
|
||||
// Good
|
||||
const { shell } = require('electron')
|
||||
@@ -730,7 +722,6 @@ const mainWindow = new BrowserWindow({
|
||||
> from Electron 10. For prior versions, you need to explicitly disable
|
||||
> the `remote` module by the means above.
|
||||
|
||||
|
||||
## 16) Filter the `remote` module
|
||||
|
||||
If you cannot disable the `remote` module, you should filter the globals,
|
||||
@@ -816,7 +807,6 @@ to fix issues before publishing them. Your application will be more secure if
|
||||
it is running a recent version of Electron (and thus, Chromium and Node.js) for
|
||||
which potential security issues are not as widely known.
|
||||
|
||||
|
||||
[browser-window]: ../api/browser-window.md
|
||||
[browser-view]: ../api/browser-view.md
|
||||
[webview-tag]: ../api/webview-tag.md
|
||||
|
||||
@@ -9,6 +9,7 @@ If you're looking for programming help,
|
||||
for answers to questions,
|
||||
or to join in discussion with other developers who use Electron,
|
||||
you can interact with the community in these locations:
|
||||
|
||||
- [`Electron's Discord`](https://discord.com/invite/electron) has channels for:
|
||||
- Getting help
|
||||
- Ecosystem apps like [Electron Forge](https://github.com/electron-userland/electron-forge) and [Electron Fiddle](https://github.com/electron/fiddle)
|
||||
@@ -62,6 +63,7 @@ threshold, we will attempt to support backwards compatibility beyond two version
|
||||
until the maintainers feel the maintenance burden is too high to continue doing so.
|
||||
|
||||
### Currently supported versions
|
||||
|
||||
- 10.x.y
|
||||
- 9.x.y
|
||||
- 8.x.y
|
||||
@@ -105,21 +107,13 @@ Running apps packaged with previous versions is possible using the ia32 binary.
|
||||
|
||||
### Linux
|
||||
|
||||
The prebuilt `ia32` (`i686`) and `x64` (`amd64`) binaries of Electron are built on
|
||||
Ubuntu 12.04, the `armv7l` binary is built against ARM v7 with hard-float ABI and
|
||||
NEON for Debian Wheezy.
|
||||
|
||||
[Until the release of Electron 2.0][arm-breaking-change], Electron will also
|
||||
continue to release the `armv7l` binary with a simple `arm` suffix. Both binaries
|
||||
are identical.
|
||||
The prebuilt binaries of Electron are built on Ubuntu 18.04.
|
||||
|
||||
Whether the prebuilt binary can run on a distribution depends on whether the
|
||||
distribution includes the libraries that Electron is linked to on the building
|
||||
platform, so only Ubuntu 12.04 is guaranteed to work, but following platforms
|
||||
platform, so only Ubuntu 18.04 is guaranteed to work, but following platforms
|
||||
are also verified to be able to run the prebuilt binaries of Electron:
|
||||
|
||||
* Ubuntu 12.04 and newer
|
||||
* Fedora 21
|
||||
* Debian 8
|
||||
|
||||
[arm-breaking-change]: ../breaking-changes.md#duplicate-arm-assets
|
||||
* Ubuntu 14.04 and newer
|
||||
* Fedora 24 and newer
|
||||
* Debian 8 and newer
|
||||
|
||||
@@ -11,7 +11,7 @@ From [ChromeDriver - WebDriver for Chrome][chrome-driver]:
|
||||
## Setting up Spectron
|
||||
|
||||
[Spectron][spectron] is the officially supported ChromeDriver testing framework
|
||||
for Electron. It is built on top of [WebdriverIO](http://webdriver.io/) and
|
||||
for Electron. It is built on top of [WebdriverIO](https://webdriver.io/) and
|
||||
has helpers to access Electron APIs in your tests and bundles ChromeDriver.
|
||||
|
||||
```sh
|
||||
@@ -51,7 +51,7 @@ verifyWindowIsVisibleWithTitle(myApp)
|
||||
|
||||
## Setting up with WebDriverJs
|
||||
|
||||
[WebDriverJs](https://code.google.com/p/selenium/wiki/WebDriverJs) provides
|
||||
[WebDriverJs](https://www.selenium.dev/selenium/docs/api/javascript/index.html) provides
|
||||
a Node package for testing with web driver, we will use it as an example.
|
||||
|
||||
### 1. Start ChromeDriver
|
||||
@@ -108,7 +108,7 @@ driver.quit()
|
||||
|
||||
## Setting up with WebdriverIO
|
||||
|
||||
[WebdriverIO](http://webdriver.io/) provides a Node package for testing with web
|
||||
[WebdriverIO](https://webdriver.io/) provides a Node package for testing with web
|
||||
driver.
|
||||
|
||||
### 1. Start ChromeDriver
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
If your app runs with Electron 6.0.8 or later, you can now build it for Windows 10 on Arm. This considerably improves performance, but requires recompilation of any native modules used in your app. It may also require small fixups to your build and packaging scripts.
|
||||
|
||||
## Running a basic app
|
||||
|
||||
If your app doesn't use any native modules, then it's really easy to create an Arm version of your app.
|
||||
|
||||
1. Make sure that your app's `node_modules` directory is empty.
|
||||
@@ -26,17 +27,21 @@ if (process.arch === 'x64') {
|
||||
If you want to target arm64, logic like this will typically select the wrong architecture, so carefully check your application and build scripts for conditions like this. In custom build and packaging scripts, you should always check the value of `npm_config_arch` in the environment, rather than relying on the current process arch.
|
||||
|
||||
### Native modules
|
||||
|
||||
If you use native modules, you must make sure that they compile against v142 of the MSVC compiler (provided in Visual Studio 2017). You must also check that any pre-built `.dll` or `.lib` files provided or referenced by the native module are available for Windows on Arm.
|
||||
|
||||
### Testing your app
|
||||
|
||||
To test your app, use a Windows on Arm device running Windows 10 (version 1903 or later). Make sure that you copy your application over to the target device - Chromium's sandbox will not work correctly when loading your application assets from a network location.
|
||||
|
||||
## Development prerequisites
|
||||
|
||||
### Node.js/node-gyp
|
||||
|
||||
[Node.js v12.9.0 or later is recommended.](https://nodejs.org/en/) If updating to a new version of Node is undesirable, you can instead [update npm's copy of node-gyp manually](https://github.com/nodejs/node-gyp/wiki/Updating-npm's-bundled-node-gyp) to version 5.0.2 or later, which contains the required changes to compile native modules for Arm.
|
||||
|
||||
### Visual Studio 2017
|
||||
|
||||
Visual Studio 2017 (any edition) is required for cross-compiling native modules. You can download Visual Studio Community 2017 via Microsoft's [Visual Studio Dev Essentials program](https://visualstudio.microsoft.com/dev-essentials/). After installation, you can add the Arm-specific components by running the following from a _Command Prompt_:
|
||||
|
||||
```powershell
|
||||
@@ -49,6 +54,7 @@ vs_installer.exe ^
|
||||
```
|
||||
|
||||
#### Creating a cross-compilation command prompt
|
||||
|
||||
Setting `npm_config_arch=arm64` in the environment creates the correct arm64 `.obj` files, but the standard _Developer Command Prompt for VS 2017_ will use the x64 linker. To fix this:
|
||||
|
||||
1. Duplicate the _x64_x86 Cross Tools Command Prompt for VS 2017_ shortcut (e.g. by locating it in the start menu, right clicking, selecting _Open File Location_, copying and pasting) to somewhere convenient.
|
||||
@@ -76,8 +82,8 @@ By default, `node-gyp` unpacks Electron's node headers and downloads the x86 and
|
||||
|
||||
Substitute `6.0.9` for the version you're using.
|
||||
|
||||
|
||||
## Cross-compiling native modules
|
||||
|
||||
After completing all of the above, open your cross-compilation command prompt and run `set npm_config_arch=arm64`. Then use `npm install` to build your project as normal. As with cross-compiling x86 modules, you may need to remove `node_modules` to force recompilation of native modules if they were previously compiled for another architecture.
|
||||
|
||||
## Debugging native modules
|
||||
@@ -89,7 +95,8 @@ Debugging native modules can be done with Visual Studio 2017 (running on your de
|
||||
3. Connect to the target device by selecting _Debug > Attach to Process..._ and enter the device's IP address and the port number displayed by the Visual Studio Remote Debugger tool.
|
||||
4. Click _Refresh_ and select the [appropriate Electron process to attach](../development/debug-instructions-windows.md).
|
||||
5. You may need to make sure that any symbols for native modules in your app are loaded correctly. To configure this, head to _Debug > Options..._ in Visual Studio 2017, and add the folders containing your `.pdb` symbols under _Debugging > Symbols_.
|
||||
5. Once attached, set any appropriate breakpoints and resume JavaScript execution using Chrome's [remote tools for Node](debugging-main-process.md).
|
||||
6. Once attached, set any appropriate breakpoints and resume JavaScript execution using Chrome's [remote tools for Node](debugging-main-process.md).
|
||||
|
||||
## Getting additional help
|
||||
|
||||
If you encounter a problem with this documentation, or if your app works when compiled for x86 but not for arm64, please [file an issue](../development/issues.md) with "Windows on Arm" in the title.
|
||||
|
||||
@@ -114,6 +114,7 @@ Another important limitation is that the compiled AppX package still contains a
|
||||
win32 executable - and will therefore not run on Xbox, HoloLens, or Phones.
|
||||
|
||||
## Optional: Add UWP Features using a BackgroundTask
|
||||
|
||||
You can pair your Electron app up with an invisible UWP background task that
|
||||
gets to make full use of Windows 10 features - like push notifications,
|
||||
Cortana integration, or live tiles.
|
||||
|
||||
@@ -38,7 +38,7 @@ const keysOfTypeNumber = ['top', 'left', ...Object.keys(keysOfTypeNumberCompileT
|
||||
type CoercedValue = string | number | boolean;
|
||||
function coerce (key: string, value: string): CoercedValue {
|
||||
if (keysOfTypeNumber.includes(key)) {
|
||||
return Number(value);
|
||||
return parseInt(value, 10);
|
||||
}
|
||||
|
||||
switch (value) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { webFrame, IpcMessageEvent } from 'electron';
|
||||
import { webFrame } from 'electron';
|
||||
import { ipcRendererInternal } from '@electron/internal/renderer/ipc-renderer-internal';
|
||||
import * as ipcRendererUtils from '@electron/internal/renderer/ipc-renderer-internal-utils';
|
||||
import { webViewEvents } from '@electron/internal/common/web-view-events';
|
||||
@@ -17,15 +17,15 @@ const dispatchEvent = function (
|
||||
dispatchEvent(webView, DEPRECATED_EVENTS[eventName], eventKey, ...args);
|
||||
}
|
||||
|
||||
const domEvent = new Event(eventName) as ElectronInternal.WebViewEvent;
|
||||
const props: Record<string, any> = {};
|
||||
webViewEvents[eventKey].forEach((prop, index) => {
|
||||
(domEvent as any)[prop] = args[index];
|
||||
props[prop] = args[index];
|
||||
});
|
||||
|
||||
webView.dispatchEvent(domEvent);
|
||||
webView.dispatchEvent(eventName, props);
|
||||
|
||||
if (eventName === 'load-commit') {
|
||||
webView.onLoadCommit(domEvent);
|
||||
webView.onLoadCommit(props);
|
||||
} else if (eventName === 'focus-change') {
|
||||
webView.onFocusChange();
|
||||
}
|
||||
@@ -35,8 +35,7 @@ export function registerEvents (webView: WebViewImpl, viewInstanceId: number) {
|
||||
ipcRendererInternal.on(`${IPC_MESSAGES.GUEST_VIEW_INTERNAL_DESTROY_GUEST}-${viewInstanceId}`, function () {
|
||||
webView.guestInstanceId = undefined;
|
||||
webView.reset();
|
||||
const domEvent = new Event('destroyed');
|
||||
webView.dispatchEvent(domEvent);
|
||||
webView.dispatchEvent('destroyed');
|
||||
});
|
||||
|
||||
ipcRendererInternal.on(`${IPC_MESSAGES.GUEST_VIEW_INTERNAL_DISPATCH_EVENT}-${viewInstanceId}`, function (event, eventName, ...args) {
|
||||
@@ -44,11 +43,7 @@ export function registerEvents (webView: WebViewImpl, viewInstanceId: number) {
|
||||
});
|
||||
|
||||
ipcRendererInternal.on(`${IPC_MESSAGES.GUEST_VIEW_INTERNAL_IPC_MESSAGE}-${viewInstanceId}`, function (event, channel, ...args) {
|
||||
const domEvent = new Event('ipc-message') as IpcMessageEvent;
|
||||
domEvent.channel = channel;
|
||||
domEvent.args = args;
|
||||
|
||||
webView.dispatchEvent(domEvent);
|
||||
webView.dispatchEvent('ipc-message', { channel, args });
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ interface MutationHandler {
|
||||
|
||||
// Attribute objects.
|
||||
// Default implementation of a WebView attribute.
|
||||
class WebViewAttribute implements MutationHandler {
|
||||
export class WebViewAttribute implements MutationHandler {
|
||||
public value: any;
|
||||
public ignoreMutation = false;
|
||||
|
||||
@@ -79,7 +79,7 @@ class BooleanAttribute extends WebViewAttribute {
|
||||
}
|
||||
|
||||
// Attribute representing the state of the storage partition.
|
||||
class PartitionAttribute extends WebViewAttribute {
|
||||
export class PartitionAttribute extends WebViewAttribute {
|
||||
public validPartitionId = true
|
||||
|
||||
constructor (public webViewImpl: WebViewImpl) {
|
||||
@@ -103,7 +103,7 @@ class PartitionAttribute extends WebViewAttribute {
|
||||
}
|
||||
|
||||
// Attribute that handles the location and navigation of the webview.
|
||||
class SrcAttribute extends WebViewAttribute {
|
||||
export class SrcAttribute extends WebViewAttribute {
|
||||
public observer!: MutationObserver;
|
||||
|
||||
constructor (public webViewImpl: WebViewImpl) {
|
||||
@@ -169,7 +169,7 @@ class SrcAttribute extends WebViewAttribute {
|
||||
}
|
||||
|
||||
public parse () {
|
||||
if (!this.webViewImpl.elementAttached || !this.webViewImpl.attributes[WEB_VIEW_CONSTANTS.ATTRIBUTE_PARTITION].validPartitionId || !this.getValue()) {
|
||||
if (!this.webViewImpl.elementAttached || !(this.webViewImpl.attributes.get(WEB_VIEW_CONSTANTS.ATTRIBUTE_PARTITION) as PartitionAttribute).validPartitionId || !this.getValue()) {
|
||||
return;
|
||||
}
|
||||
if (this.webViewImpl.guestInstanceId == null) {
|
||||
@@ -183,12 +183,12 @@ class SrcAttribute extends WebViewAttribute {
|
||||
// Navigate to |this.src|.
|
||||
const opts: Record<string, string> = {};
|
||||
|
||||
const httpreferrer = this.webViewImpl.attributes[WEB_VIEW_CONSTANTS.ATTRIBUTE_HTTPREFERRER].getValue();
|
||||
const httpreferrer = this.webViewImpl.attributes.get(WEB_VIEW_CONSTANTS.ATTRIBUTE_HTTPREFERRER)!.getValue();
|
||||
if (httpreferrer) {
|
||||
opts.httpReferrer = httpreferrer;
|
||||
}
|
||||
|
||||
const useragent = this.webViewImpl.attributes[WEB_VIEW_CONSTANTS.ATTRIBUTE_USERAGENT].getValue();
|
||||
const useragent = this.webViewImpl.attributes.get(WEB_VIEW_CONSTANTS.ATTRIBUTE_USERAGENT)!.getValue();
|
||||
if (useragent) {
|
||||
opts.userAgent = useragent;
|
||||
}
|
||||
@@ -275,19 +275,18 @@ class EnableRemoteModuleAttribute extends WebViewAttribute {
|
||||
|
||||
// Sets up all of the webview attributes.
|
||||
WebViewImpl.prototype.setupWebViewAttributes = function () {
|
||||
this.attributes = {};
|
||||
this.attributes[WEB_VIEW_CONSTANTS.ATTRIBUTE_PARTITION] = new PartitionAttribute(this);
|
||||
this.attributes[WEB_VIEW_CONSTANTS.ATTRIBUTE_SRC] = new SrcAttribute(this);
|
||||
this.attributes[WEB_VIEW_CONSTANTS.ATTRIBUTE_HTTPREFERRER] = new HttpReferrerAttribute(this);
|
||||
this.attributes[WEB_VIEW_CONSTANTS.ATTRIBUTE_USERAGENT] = new UserAgentAttribute(this);
|
||||
this.attributes[WEB_VIEW_CONSTANTS.ATTRIBUTE_NODEINTEGRATION] = new BooleanAttribute(WEB_VIEW_CONSTANTS.ATTRIBUTE_NODEINTEGRATION, this);
|
||||
this.attributes[WEB_VIEW_CONSTANTS.ATTRIBUTE_NODEINTEGRATIONINSUBFRAMES] = new BooleanAttribute(WEB_VIEW_CONSTANTS.ATTRIBUTE_NODEINTEGRATIONINSUBFRAMES, this);
|
||||
this.attributes[WEB_VIEW_CONSTANTS.ATTRIBUTE_PLUGINS] = new BooleanAttribute(WEB_VIEW_CONSTANTS.ATTRIBUTE_PLUGINS, this);
|
||||
this.attributes[WEB_VIEW_CONSTANTS.ATTRIBUTE_DISABLEWEBSECURITY] = new BooleanAttribute(WEB_VIEW_CONSTANTS.ATTRIBUTE_DISABLEWEBSECURITY, this);
|
||||
this.attributes[WEB_VIEW_CONSTANTS.ATTRIBUTE_ALLOWPOPUPS] = new BooleanAttribute(WEB_VIEW_CONSTANTS.ATTRIBUTE_ALLOWPOPUPS, this);
|
||||
this.attributes[WEB_VIEW_CONSTANTS.ATTRIBUTE_ENABLEREMOTEMODULE] = new EnableRemoteModuleAttribute(this);
|
||||
this.attributes[WEB_VIEW_CONSTANTS.ATTRIBUTE_PRELOAD] = new PreloadAttribute(this);
|
||||
this.attributes[WEB_VIEW_CONSTANTS.ATTRIBUTE_BLINKFEATURES] = new BlinkFeaturesAttribute(this);
|
||||
this.attributes[WEB_VIEW_CONSTANTS.ATTRIBUTE_DISABLEBLINKFEATURES] = new DisableBlinkFeaturesAttribute(this);
|
||||
this.attributes[WEB_VIEW_CONSTANTS.ATTRIBUTE_WEBPREFERENCES] = new WebPreferencesAttribute(this);
|
||||
this.attributes.set(WEB_VIEW_CONSTANTS.ATTRIBUTE_PARTITION, new PartitionAttribute(this));
|
||||
this.attributes.set(WEB_VIEW_CONSTANTS.ATTRIBUTE_SRC, new SrcAttribute(this));
|
||||
this.attributes.set(WEB_VIEW_CONSTANTS.ATTRIBUTE_HTTPREFERRER, new HttpReferrerAttribute(this));
|
||||
this.attributes.set(WEB_VIEW_CONSTANTS.ATTRIBUTE_USERAGENT, new UserAgentAttribute(this));
|
||||
this.attributes.set(WEB_VIEW_CONSTANTS.ATTRIBUTE_NODEINTEGRATION, new BooleanAttribute(WEB_VIEW_CONSTANTS.ATTRIBUTE_NODEINTEGRATION, this));
|
||||
this.attributes.set(WEB_VIEW_CONSTANTS.ATTRIBUTE_NODEINTEGRATIONINSUBFRAMES, new BooleanAttribute(WEB_VIEW_CONSTANTS.ATTRIBUTE_NODEINTEGRATIONINSUBFRAMES, this));
|
||||
this.attributes.set(WEB_VIEW_CONSTANTS.ATTRIBUTE_PLUGINS, new BooleanAttribute(WEB_VIEW_CONSTANTS.ATTRIBUTE_PLUGINS, this));
|
||||
this.attributes.set(WEB_VIEW_CONSTANTS.ATTRIBUTE_DISABLEWEBSECURITY, new BooleanAttribute(WEB_VIEW_CONSTANTS.ATTRIBUTE_DISABLEWEBSECURITY, this));
|
||||
this.attributes.set(WEB_VIEW_CONSTANTS.ATTRIBUTE_ALLOWPOPUPS, new BooleanAttribute(WEB_VIEW_CONSTANTS.ATTRIBUTE_ALLOWPOPUPS, this));
|
||||
this.attributes.set(WEB_VIEW_CONSTANTS.ATTRIBUTE_ENABLEREMOTEMODULE, new EnableRemoteModuleAttribute(this));
|
||||
this.attributes.set(WEB_VIEW_CONSTANTS.ATTRIBUTE_PRELOAD, new PreloadAttribute(this));
|
||||
this.attributes.set(WEB_VIEW_CONSTANTS.ATTRIBUTE_BLINKFEATURES, new BlinkFeaturesAttribute(this));
|
||||
this.attributes.set(WEB_VIEW_CONSTANTS.ATTRIBUTE_DISABLEBLINKFEATURES, new DisableBlinkFeaturesAttribute(this));
|
||||
this.attributes.set(WEB_VIEW_CONSTANTS.ATTRIBUTE_WEBPREFERENCES, new WebPreferencesAttribute(this));
|
||||
};
|
||||
|
||||
@@ -16,9 +16,6 @@ export const enum WEB_VIEW_CONSTANTS {
|
||||
ATTRIBUTE_DISABLEBLINKFEATURES = 'disableblinkfeatures',
|
||||
ATTRIBUTE_WEBPREFERENCES = 'webpreferences',
|
||||
|
||||
// Internal attribute.
|
||||
ATTRIBUTE_INTERNALINSTANCEID = 'internalinstanceid',
|
||||
|
||||
// Error messages.
|
||||
ERROR_MSG_ALREADY_NAVIGATED = 'The object has already navigated, so its partition cannot be changed.',
|
||||
ERROR_MSG_CANNOT_INJECT_SCRIPT = '<webview> = ' + 'Script cannot be injected into content until the page has loaded.',
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
import { WEB_VIEW_CONSTANTS } from '@electron/internal/renderer/web-view/web-view-constants';
|
||||
import { WebViewImpl as IWebViewImpl, webViewImplModule } from '@electron/internal/renderer/web-view/web-view-impl';
|
||||
import type { SrcAttribute } from '@electron/internal/renderer/web-view/web-view-attributes';
|
||||
|
||||
// Return a WebViewElement class that is defined in this context.
|
||||
const defineWebViewElement = (v8Util: NodeJS.V8UtilBinding, webViewImpl: typeof webViewImplModule) => {
|
||||
@@ -38,7 +39,13 @@ const defineWebViewElement = (v8Util: NodeJS.V8UtilBinding, webViewImpl: typeof
|
||||
|
||||
constructor () {
|
||||
super();
|
||||
v8Util.setHiddenValue(this, 'internal', new WebViewImpl(this));
|
||||
const internal = new WebViewImpl(this);
|
||||
internal.dispatchEventInMainWorld = (eventName, props) => {
|
||||
const event = new Event(eventName);
|
||||
Object.assign(event, props);
|
||||
return internal.webviewNode.dispatchEvent(event);
|
||||
};
|
||||
v8Util.setHiddenValue(this, 'internal', internal);
|
||||
}
|
||||
|
||||
connectedCallback () {
|
||||
@@ -49,7 +56,7 @@ const defineWebViewElement = (v8Util: NodeJS.V8UtilBinding, webViewImpl: typeof
|
||||
if (!internal.elementAttached) {
|
||||
guestViewInternal.registerEvents(internal, internal.viewInstanceId);
|
||||
internal.elementAttached = true;
|
||||
internal.attributes[WEB_VIEW_CONSTANTS.ATTRIBUTE_SRC].parse();
|
||||
(internal.attributes.get(WEB_VIEW_CONSTANTS.ATTRIBUTE_SRC) as SrcAttribute).parse();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import * as ipcRendererUtils from '@electron/internal/renderer/ipc-renderer-inte
|
||||
import * as guestViewInternal from '@electron/internal/renderer/web-view/guest-view-internal';
|
||||
import { WEB_VIEW_CONSTANTS } from '@electron/internal/renderer/web-view/web-view-constants';
|
||||
import { syncMethods, asyncMethods, properties } from '@electron/internal/common/web-view-methods';
|
||||
import type { WebViewAttribute, PartitionAttribute } from '@electron/internal/renderer/web-view/web-view-attributes';
|
||||
import { deserialize } from '@electron/internal/common/type-utils';
|
||||
import { IPC_MESSAGES } from '@electron/internal/common/ipc-messages';
|
||||
const { webFrame } = electron;
|
||||
@@ -34,9 +35,11 @@ export class WebViewImpl {
|
||||
public internalElement: HTMLIFrameElement
|
||||
|
||||
// Replaced in web-view-attributes
|
||||
public attributes: Record<string, any> = {}
|
||||
public attributes = new Map<string, WebViewAttribute>();
|
||||
public setupWebViewAttributes (): void {}
|
||||
|
||||
public dispatchEventInMainWorld?: (eventName: string, props: any) => boolean;
|
||||
|
||||
constructor (public webviewNode: HTMLElement) {
|
||||
// Create internal iframe element.
|
||||
this.internalElement = this.createInternalElement();
|
||||
@@ -77,7 +80,7 @@ export class WebViewImpl {
|
||||
}
|
||||
|
||||
this.beforeFirstNavigation = true;
|
||||
this.attributes[WEB_VIEW_CONSTANTS.ATTRIBUTE_PARTITION].validPartitionId = true;
|
||||
(this.attributes.get(WEB_VIEW_CONSTANTS.ATTRIBUTE_PARTITION) as PartitionAttribute).validPartitionId = true;
|
||||
|
||||
// Since attachment swaps a local frame for a remote frame, we need our
|
||||
// internal iframe element to be local again before we can reattach.
|
||||
@@ -96,19 +99,20 @@ export class WebViewImpl {
|
||||
// attribute, if necessary. See BrowserPlugin::UpdateDOMAttribute for more
|
||||
// details.
|
||||
handleWebviewAttributeMutation (attributeName: string, oldValue: any, newValue: any) {
|
||||
if (!this.attributes[attributeName] || this.attributes[attributeName].ignoreMutation) {
|
||||
if (!this.attributes.has(attributeName) || this.attributes.get(attributeName)!.ignoreMutation) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Let the changed attribute handle its own mutation
|
||||
this.attributes[attributeName].handleMutation(oldValue, newValue);
|
||||
this.attributes.get(attributeName)!.handleMutation(oldValue, newValue);
|
||||
}
|
||||
|
||||
onElementResize () {
|
||||
const resizeEvent = new Event('resize') as ElectronInternal.WebFrameResizeEvent;
|
||||
resizeEvent.newWidth = this.webviewNode.clientWidth;
|
||||
resizeEvent.newHeight = this.webviewNode.clientHeight;
|
||||
this.dispatchEvent(resizeEvent);
|
||||
const props = {
|
||||
newWidth: this.webviewNode.clientWidth,
|
||||
newHeight: this.webviewNode.clientHeight
|
||||
};
|
||||
this.dispatchEvent('resize', props);
|
||||
}
|
||||
|
||||
createGuest () {
|
||||
@@ -117,8 +121,8 @@ export class WebViewImpl {
|
||||
});
|
||||
}
|
||||
|
||||
dispatchEvent (webViewEvent: Electron.Event) {
|
||||
this.webviewNode.dispatchEvent(webViewEvent);
|
||||
dispatchEvent (eventName: string, props: Record<string, any> = {}) {
|
||||
this.dispatchEventInMainWorld!(eventName, props);
|
||||
}
|
||||
|
||||
// Adds an 'on<event>' property on the webview, which can be used to set/unset
|
||||
@@ -143,14 +147,14 @@ export class WebViewImpl {
|
||||
}
|
||||
|
||||
// Updates state upon loadcommit.
|
||||
onLoadCommit (webViewEvent: ElectronInternal.WebViewEvent) {
|
||||
onLoadCommit (props: Record<string, any>) {
|
||||
const oldValue = this.webviewNode.getAttribute(WEB_VIEW_CONSTANTS.ATTRIBUTE_SRC);
|
||||
const newValue = webViewEvent.url;
|
||||
if (webViewEvent.isMainFrame && (oldValue !== newValue)) {
|
||||
const newValue = props.url;
|
||||
if (props.isMainFrame && (oldValue !== newValue)) {
|
||||
// Touching the src attribute triggers a navigation. To avoid
|
||||
// triggering a page reload on every guest-initiated navigation,
|
||||
// we do not handle this mutation.
|
||||
this.attributes[WEB_VIEW_CONSTANTS.ATTRIBUTE_SRC].setValueIgnoreMutation(newValue);
|
||||
this.attributes.get(WEB_VIEW_CONSTANTS.ATTRIBUTE_SRC)!.setValueIgnoreMutation(newValue);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,12 +163,12 @@ export class WebViewImpl {
|
||||
const hasFocus = document.activeElement === this.webviewNode;
|
||||
if (hasFocus !== this.hasFocus) {
|
||||
this.hasFocus = hasFocus;
|
||||
this.dispatchEvent(new Event(hasFocus ? 'focus' : 'blur'));
|
||||
this.dispatchEvent(hasFocus ? 'focus' : 'blur');
|
||||
}
|
||||
}
|
||||
|
||||
onAttach (storagePartitionId: number) {
|
||||
return this.attributes[WEB_VIEW_CONSTANTS.ATTRIBUTE_PARTITION].setValue(storagePartitionId);
|
||||
return this.attributes.get(WEB_VIEW_CONSTANTS.ATTRIBUTE_PARTITION)!.setValue(storagePartitionId);
|
||||
}
|
||||
|
||||
buildParams () {
|
||||
@@ -173,10 +177,8 @@ export class WebViewImpl {
|
||||
userAgentOverride: this.userAgentOverride
|
||||
};
|
||||
|
||||
for (const attributeName in this.attributes) {
|
||||
if (Object.prototype.hasOwnProperty.call(this.attributes, attributeName)) {
|
||||
params[attributeName] = this.attributes[attributeName].getValue();
|
||||
}
|
||||
for (const [attributeName, attribute] of this.attributes) {
|
||||
params[attributeName] = attribute.getValue();
|
||||
}
|
||||
|
||||
return params;
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
{
|
||||
"name": "electron",
|
||||
"version": "12.0.0-nightly.20201029",
|
||||
"version": "12.0.0-nightly.20201109",
|
||||
"repository": "https://github.com/electron/electron",
|
||||
"description": "Build cross platform desktop apps with JavaScript, HTML, and CSS",
|
||||
"devDependencies": {
|
||||
"@electron/docs-parser": "^0.10.0",
|
||||
"@electron/typescript-definitions": "^8.8.0",
|
||||
"@octokit/auth-app": "^2.10.0",
|
||||
"@octokit/rest": "^18.0.3",
|
||||
"@primer/octicons": "^10.0.0",
|
||||
"@types/basic-auth": "^1.1.3",
|
||||
@@ -15,11 +16,14 @@
|
||||
"@types/dirty-chai": "^2.0.2",
|
||||
"@types/express": "^4.17.7",
|
||||
"@types/fs-extra": "^9.0.1",
|
||||
"@types/klaw": "^3.0.1",
|
||||
"@types/minimist": "^1.2.0",
|
||||
"@types/mocha": "^7.0.2",
|
||||
"@types/node": "^14.6.2",
|
||||
"@types/semver": "^7.3.3",
|
||||
"@types/send": "^0.14.5",
|
||||
"@types/split": "^1.0.0",
|
||||
"@types/stream-json": "^1.5.1",
|
||||
"@types/uuid": "^3.4.6",
|
||||
"@types/webpack": "^4.41.21",
|
||||
"@types/webpack-env": "^1.15.2",
|
||||
@@ -55,6 +59,7 @@
|
||||
"semver": "^5.6.0",
|
||||
"shx": "^0.3.2",
|
||||
"standard-markdown": "^6.0.0",
|
||||
"stream-json": "^1.7.1",
|
||||
"sumchecker": "^2.0.2",
|
||||
"tap-xunit": "^2.4.1",
|
||||
"temp": "^0.8.3",
|
||||
@@ -73,6 +78,7 @@
|
||||
"lint": "node ./script/lint.js && npm run lint:clang-format && npm run lint:docs",
|
||||
"lint:js": "node ./script/lint.js --js",
|
||||
"lint:clang-format": "python script/run-clang-format.py -r -c chromium_src/ shell/ || (echo \"\\nCode not formatted correctly.\" && exit 1)",
|
||||
"lint:clang-tidy": "ts-node ./script/run-clang-tidy.ts",
|
||||
"lint:cpp": "node ./script/lint.js --cc",
|
||||
"lint:objc": "node ./script/lint.js --objc",
|
||||
"lint:py": "node ./script/lint.js --py",
|
||||
|
||||
@@ -101,3 +101,4 @@ fix_properly_honor_printing_page_ranges.patch
|
||||
fix_use_electron_generated_resources.patch
|
||||
chore_expose_v8_initialization_isolate_callbacks.patch
|
||||
rename_the_v8_context_snapshot_on_arm64_macos_builds.patch
|
||||
export_gin_v8platform_pageallocator_for_usage_outside_of_the_gin.patch
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Samuel Attard <samuel.r.attard@gmail.com>
|
||||
Date: Tue, 3 Nov 2020 16:49:32 -0800
|
||||
Subject: export gin::V8Platform::PageAllocator for usage outside of the gin
|
||||
platform
|
||||
|
||||
diff --git a/gin/public/v8_platform.h b/gin/public/v8_platform.h
|
||||
index da2aeb2f2da84fe47d5cc7d721f8d3dade0c0972..4ddad9065782fad5927bc0481ad772014af0d689 100644
|
||||
--- a/gin/public/v8_platform.h
|
||||
+++ b/gin/public/v8_platform.h
|
||||
@@ -23,6 +23,7 @@ class GIN_EXPORT V8Platform : public v8::Platform {
|
||||
// Some configurations do not use page_allocator.
|
||||
#if BUILDFLAG(USE_PARTITION_ALLOC)
|
||||
v8::PageAllocator* GetPageAllocator() override;
|
||||
+ static v8::PageAllocator* PageAllocator();
|
||||
void OnCriticalMemoryPressure() override;
|
||||
#endif
|
||||
std::shared_ptr<v8::TaskRunner> GetForegroundTaskRunner(
|
||||
diff --git a/gin/v8_platform.cc b/gin/v8_platform.cc
|
||||
index 9cec7468189af7f290ff32c184f0a7baa636be62..e4f20e56680e652ca99b416d352e4a2ec1b79509 100644
|
||||
--- a/gin/v8_platform.cc
|
||||
+++ b/gin/v8_platform.cc
|
||||
@@ -439,6 +439,10 @@ v8::PageAllocator* V8Platform::GetPageAllocator() {
|
||||
return g_page_allocator.Pointer();
|
||||
}
|
||||
|
||||
+v8::PageAllocator* V8Platform::PageAllocator() {
|
||||
+ return g_page_allocator.Pointer();
|
||||
+}
|
||||
+
|
||||
void V8Platform::OnCriticalMemoryPressure() {
|
||||
// We only have a reservation on 32-bit Windows systems.
|
||||
// TODO(bbudge) Make the #if's in BlinkInitializer match.
|
||||
@@ -28,3 +28,4 @@ feat_add_implementation_of_v8_platform_postjob.patch
|
||||
fix_-wincompatible-pointer-types-discards-qualifiers_error.patch
|
||||
fix_add_v8_enable_reverse_jsargs_defines_in_common_gypi.patch
|
||||
fix_allow_preventing_initializeinspector_in_env.patch
|
||||
src_allow_embedders_to_provide_a_custom_pageallocator_to.patch
|
||||
|
||||
@@ -1586,7 +1586,7 @@ index 0000000000000000000000000000000000000000..f3c5c798c0aefcb8cf9b1570a7b4817c
|
||||
+ args = rebase_path(inputs + outputs, root_build_dir)
|
||||
+}
|
||||
diff --git a/src/node_version.h b/src/node_version.h
|
||||
index 7f2f31389637d07fcf0f721daf18b409ade039b4..ffc4ed7085f2b97ce2017245947085e26e7633ac 100644
|
||||
index 280391501700eabf9845c8b9bb2dbce58ab92a48..e9b14929e04b24fcbaa94b854c0d2104cdbb3861 100644
|
||||
--- a/src/node_version.h
|
||||
+++ b/src/node_version.h
|
||||
@@ -89,7 +89,10 @@
|
||||
|
||||
@@ -0,0 +1,123 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Samuel Attard <samuel.r.attard@gmail.com>
|
||||
Date: Tue, 3 Nov 2020 16:17:38 -0800
|
||||
Subject: src: allow embedders to provide a custom PageAllocator to
|
||||
NodePlatform
|
||||
|
||||
For certain embedder use cases there are more complex memory allocation requirements that the default V8 page allocator does not handle, for example using MAP_JIT when running under a hardened runtime environment on macOS. This allows such embedders to provide their own allocator that does handle these cases.
|
||||
|
||||
diff --git a/src/api/environment.cc b/src/api/environment.cc
|
||||
index c08fe4b32d4155badb572f15529f903c0ec63146..a8cf0d763f78c2752e3aa22479dadd9fa53c222f 100644
|
||||
--- a/src/api/environment.cc
|
||||
+++ b/src/api/environment.cc
|
||||
@@ -488,8 +488,9 @@ MultiIsolatePlatform* CreatePlatform(
|
||||
|
||||
MultiIsolatePlatform* CreatePlatform(
|
||||
int thread_pool_size,
|
||||
- v8::TracingController* tracing_controller) {
|
||||
- return MultiIsolatePlatform::Create(thread_pool_size, tracing_controller)
|
||||
+ v8::TracingController* tracing_controller,
|
||||
+ v8::PageAllocator* page_allocator) {
|
||||
+ return MultiIsolatePlatform::Create(thread_pool_size, tracing_controller, page_allocator)
|
||||
.release();
|
||||
}
|
||||
|
||||
@@ -499,8 +500,9 @@ void FreePlatform(MultiIsolatePlatform* platform) {
|
||||
|
||||
std::unique_ptr<MultiIsolatePlatform> MultiIsolatePlatform::Create(
|
||||
int thread_pool_size,
|
||||
- v8::TracingController* tracing_controller) {
|
||||
- return std::make_unique<NodePlatform>(thread_pool_size, tracing_controller);
|
||||
+ v8::TracingController* tracing_controller,
|
||||
+ v8::PageAllocator* page_allocator) {
|
||||
+ return std::make_unique<NodePlatform>(thread_pool_size, tracing_controller, page_allocator);
|
||||
}
|
||||
|
||||
MaybeLocal<Object> GetPerContextExports(Local<Context> context) {
|
||||
diff --git a/src/node.h b/src/node.h
|
||||
index b646fdda58ebcbf2dd92ee4fc9cb0d9c039174d1..14893ad605b9f8c64b0b8fc28625e235655dcd63 100644
|
||||
--- a/src/node.h
|
||||
+++ b/src/node.h
|
||||
@@ -333,7 +333,8 @@ class NODE_EXTERN MultiIsolatePlatform : public v8::Platform {
|
||||
|
||||
static std::unique_ptr<MultiIsolatePlatform> Create(
|
||||
int thread_pool_size,
|
||||
- v8::TracingController* tracing_controller = nullptr);
|
||||
+ v8::TracingController* tracing_controller = nullptr,
|
||||
+ v8::PageAllocator* page_allocator = nullptr);
|
||||
};
|
||||
|
||||
enum IsolateSettingsFlags {
|
||||
@@ -536,7 +537,8 @@ NODE_DEPRECATED("Use variant taking a v8::TracingController* pointer instead",
|
||||
node::tracing::TracingController* tracing_controller));
|
||||
NODE_EXTERN MultiIsolatePlatform* CreatePlatform(
|
||||
int thread_pool_size,
|
||||
- v8::TracingController* tracing_controller);
|
||||
+ v8::TracingController* tracing_controller,
|
||||
+ v8::PageAllocator* = nullptr);
|
||||
NODE_EXTERN void FreePlatform(MultiIsolatePlatform* platform);
|
||||
|
||||
// Get/set the currently active tracing controller. Using CreatePlatform()
|
||||
diff --git a/src/node_platform.cc b/src/node_platform.cc
|
||||
index aac0682670fcffd235fcf450bc5e2b0d45985b47..96be2281b562c44b276483970c06862250ea8941 100644
|
||||
--- a/src/node_platform.cc
|
||||
+++ b/src/node_platform.cc
|
||||
@@ -324,12 +324,16 @@ void PerIsolatePlatformData::DecreaseHandleCount() {
|
||||
}
|
||||
|
||||
NodePlatform::NodePlatform(int thread_pool_size,
|
||||
- v8::TracingController* tracing_controller) {
|
||||
+ v8::TracingController* tracing_controller,
|
||||
+ v8::PageAllocator* page_allocator) {
|
||||
if (tracing_controller != nullptr) {
|
||||
tracing_controller_ = tracing_controller;
|
||||
} else {
|
||||
tracing_controller_ = new v8::TracingController();
|
||||
}
|
||||
+ // This being nullptr is acceptable as V8 will default to its built
|
||||
+ // in allocator if none is provided
|
||||
+ page_allocator_ = page_allocator;
|
||||
// TODO(addaleax): It's a bit icky that we use global state here, but we can't
|
||||
// really do anything about it unless V8 starts exposing a way to access the
|
||||
// current v8::Platform instance.
|
||||
@@ -544,6 +548,10 @@ Platform::StackTracePrinter NodePlatform::GetStackTracePrinter() {
|
||||
};
|
||||
}
|
||||
|
||||
+v8::PageAllocator* NodePlatform::GetPageAllocator() {
|
||||
+ return page_allocator_;
|
||||
+}
|
||||
+
|
||||
std::unique_ptr<v8::JobHandle> NodePlatform::PostJob(v8::TaskPriority priority, std::unique_ptr<v8::JobTask> job_task) {
|
||||
return v8::platform::NewDefaultJobHandle(this, priority, std::move(job_task), 1 /* num_worker_threads */);
|
||||
}
|
||||
diff --git a/src/node_platform.h b/src/node_platform.h
|
||||
index a274be6bbea19a4488bca393712a9ac8b50fe16a..314cf2d1056d30a77ead400d100a4d4c6f844be6 100644
|
||||
--- a/src/node_platform.h
|
||||
+++ b/src/node_platform.h
|
||||
@@ -138,7 +138,8 @@ class WorkerThreadsTaskRunner {
|
||||
class NodePlatform : public MultiIsolatePlatform {
|
||||
public:
|
||||
NodePlatform(int thread_pool_size,
|
||||
- v8::TracingController* tracing_controller);
|
||||
+ v8::TracingController* tracing_controller,
|
||||
+ v8::PageAllocator* page_allocator = nullptr);
|
||||
~NodePlatform() override;
|
||||
|
||||
void DrainTasks(v8::Isolate* isolate) override;
|
||||
@@ -168,6 +169,7 @@ class NodePlatform : public MultiIsolatePlatform {
|
||||
v8::Isolate* isolate) override;
|
||||
|
||||
Platform::StackTracePrinter GetStackTracePrinter() override;
|
||||
+ v8::PageAllocator* GetPageAllocator() override;
|
||||
|
||||
private:
|
||||
IsolatePlatformDelegate* ForIsolate(v8::Isolate* isolate);
|
||||
@@ -179,6 +181,7 @@ class NodePlatform : public MultiIsolatePlatform {
|
||||
std::unordered_map<v8::Isolate*, DelegatePair> per_isolate_;
|
||||
|
||||
v8::TracingController* tracing_controller_;
|
||||
+ v8::PageAllocator* page_allocator_;
|
||||
std::shared_ptr<WorkerThreadsTaskRunner> worker_thread_task_runner_;
|
||||
bool has_shut_down_ = false;
|
||||
};
|
||||
@@ -49,7 +49,9 @@ def getBrokenLinks(filepath):
|
||||
f.close()
|
||||
|
||||
linkRegexLink = re.compile('\[(.*?)\]\((?P<link>(.*?))\)')
|
||||
referenceLinkRegex = re.compile('^\s{0,3}\[.*?\]:\s*(?P<link>[^<\s]+|<[^<>\r\n]+>)')
|
||||
referenceLinkRegex = re.compile(
|
||||
'^\s{0,3}\[.*?\]:\s*(?P<link>[^<\s]+|<[^<>\r\n]+>)'
|
||||
)
|
||||
links = []
|
||||
for line in lines:
|
||||
matchLinks = linkRegexLink.search(line)
|
||||
|
||||
@@ -7,7 +7,7 @@ from lib import git
|
||||
|
||||
|
||||
def export_patches(dirs, dry_run):
|
||||
for patch_dir, repo in dirs.iteritems():
|
||||
for patch_dir, repo in dirs.items():
|
||||
git.export_patches(repo=repo, out_dir=patch_dir, dry_run=dry_run)
|
||||
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ verbose_mode = False
|
||||
|
||||
|
||||
def get_platform_key():
|
||||
if os.environ.has_key('MAS_BUILD'):
|
||||
if 'MAS_BUILD' in os.environ:
|
||||
return 'mas'
|
||||
else:
|
||||
return PLATFORM
|
||||
|
||||
@@ -6,7 +6,11 @@ Everything here should be project agnostic: it shouldn't rely on project's
|
||||
structure, or make assumptions about the passed arguments or calls' outcomes.
|
||||
"""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import io
|
||||
import os
|
||||
import posixpath
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
@@ -106,13 +110,13 @@ def get_patch(repo, commit_hash):
|
||||
'--' # Explicitly tell Git `commit_hash` is a revision, not a path.
|
||||
]
|
||||
|
||||
return subprocess.check_output(args)
|
||||
return subprocess.check_output(args).decode('utf-8')
|
||||
|
||||
|
||||
def get_head_commit(repo):
|
||||
args = ['git', '-C', repo, 'rev-parse', 'HEAD']
|
||||
|
||||
return subprocess.check_output(args).strip()
|
||||
return subprocess.check_output(args).decode('utf-8').strip()
|
||||
|
||||
|
||||
def update_ref(repo, ref, newvalue):
|
||||
@@ -154,7 +158,7 @@ def get_upstream_head(repo):
|
||||
'--verify',
|
||||
'refs/patches/upstream-head',
|
||||
]
|
||||
return subprocess.check_output(args).strip()
|
||||
return subprocess.check_output(args).decode('utf-8').strip()
|
||||
|
||||
def get_commit_count(repo, commit_range):
|
||||
args = [
|
||||
@@ -165,7 +169,7 @@ def get_commit_count(repo, commit_range):
|
||||
'--count',
|
||||
commit_range
|
||||
]
|
||||
return int(subprocess.check_output(args).strip())
|
||||
return int(subprocess.check_output(args).decode('utf-8').strip())
|
||||
|
||||
def guess_base_commit(repo):
|
||||
"""Guess which commit the patches might be based on"""
|
||||
@@ -181,7 +185,7 @@ def guess_base_commit(repo):
|
||||
'describe',
|
||||
'--tags',
|
||||
]
|
||||
return subprocess.check_output(args).rsplit('-', 2)[0:2]
|
||||
return subprocess.check_output(args).decode('utf-8').rsplit('-', 2)[0:2]
|
||||
|
||||
|
||||
def format_patch(repo, since):
|
||||
@@ -190,7 +194,11 @@ def format_patch(repo, since):
|
||||
'-C',
|
||||
repo,
|
||||
'-c',
|
||||
'core.attributesfile=' + os.path.join(os.path.dirname(os.path.realpath(__file__)), 'electron.gitattributes'),
|
||||
'core.attributesfile='
|
||||
+ os.path.join(
|
||||
os.path.dirname(os.path.realpath(__file__)),
|
||||
'electron.gitattributes',
|
||||
),
|
||||
# Ensure it is not possible to match anything
|
||||
# Disabled for now as we have consistent chunk headers
|
||||
# '-c',
|
||||
@@ -215,7 +223,7 @@ def format_patch(repo, since):
|
||||
'--full-index',
|
||||
since
|
||||
]
|
||||
return subprocess.check_output(args)
|
||||
return subprocess.check_output(args).decode('utf-8')
|
||||
|
||||
|
||||
def split_patches(patch_data):
|
||||
@@ -252,9 +260,13 @@ def remove_patch_filename(patch):
|
||||
force_keep_next_line = False
|
||||
for i, l in enumerate(patch):
|
||||
is_patchfilename = l.startswith('Patch-Filename: ')
|
||||
next_is_patchfilename = i < len(patch) - 1 and patch[i+1].startswith('Patch-Filename: ')
|
||||
if not force_keep_next_line and (is_patchfilename or (next_is_patchfilename and len(l.rstrip()) == 0)):
|
||||
pass # drop this line
|
||||
next_is_patchfilename = i < len(patch) - 1 and patch[i + 1].startswith(
|
||||
'Patch-Filename: '
|
||||
)
|
||||
if not force_keep_next_line and (
|
||||
is_patchfilename or (next_is_patchfilename and len(l.rstrip()) == 0)
|
||||
):
|
||||
pass # drop this line
|
||||
else:
|
||||
yield l
|
||||
force_keep_next_line = l.startswith('Subject: ')
|
||||
@@ -263,7 +275,9 @@ def remove_patch_filename(patch):
|
||||
def export_patches(repo, out_dir, patch_range=None, dry_run=False):
|
||||
if patch_range is None:
|
||||
patch_range, num_patches = guess_base_commit(repo)
|
||||
sys.stderr.write("Exporting {} patches since {}\n".format(num_patches, patch_range))
|
||||
sys.stderr.write(
|
||||
"Exporting {} patches since {}\n".format(num_patches, patch_range)
|
||||
)
|
||||
patch_data = format_patch(repo, patch_range)
|
||||
patches = split_patches(patch_data)
|
||||
|
||||
@@ -274,31 +288,46 @@ def export_patches(repo, out_dir, patch_range=None, dry_run=False):
|
||||
|
||||
if dry_run:
|
||||
# If we're doing a dry run, iterate through each patch and see if the newly
|
||||
# exported patch differs from what exists. Report number of mismatched patches
|
||||
# and fail if there's more than one.
|
||||
# exported patch differs from what exists. Report number of mismatched
|
||||
# patches and fail if there's more than one.
|
||||
patch_count = 0
|
||||
for patch in patches:
|
||||
filename = get_file_name(patch)
|
||||
filepath = os.path.join(out_dir, filename)
|
||||
existing_patch = open(filepath, 'r').read()
|
||||
formatted_patch = '\n'.join(remove_patch_filename(patch)).rstrip('\n') + '\n'
|
||||
filepath = posixpath.join(out_dir, filename)
|
||||
existing_patch = io.open(filepath, 'r', encoding='utf-8').read()
|
||||
formatted_patch = (
|
||||
'\n'.join(remove_patch_filename(patch)).rstrip('\n') + '\n'
|
||||
)
|
||||
if formatted_patch != existing_patch:
|
||||
patch_count += 1
|
||||
if patch_count > 0:
|
||||
sys.stderr.write("Patches in {} not up to date: {} patches need update\n".format(out_dir, patch_count))
|
||||
sys.stderr.write(
|
||||
"Patches in {} not up to date: {} patches need update\n".format(
|
||||
out_dir, patch_count
|
||||
)
|
||||
)
|
||||
exit(1)
|
||||
else:
|
||||
# Remove old patches so that deleted commits are correctly reflected in the
|
||||
# patch files (as a removed file)
|
||||
for p in os.listdir(out_dir):
|
||||
if p.endswith('.patch'):
|
||||
os.remove(os.path.join(out_dir, p))
|
||||
with open(os.path.join(out_dir, '.patches'), 'w') as pl:
|
||||
os.remove(posixpath.join(out_dir, p))
|
||||
with io.open(
|
||||
posixpath.join(out_dir, '.patches'),
|
||||
'w',
|
||||
newline='\n',
|
||||
encoding='utf-8',
|
||||
) as pl:
|
||||
for patch in patches:
|
||||
filename = get_file_name(patch)
|
||||
file_path = os.path.join(out_dir, filename)
|
||||
formatted_patch = '\n'.join(remove_patch_filename(patch)).rstrip('\n') + '\n'
|
||||
with open(file_path, 'w') as f:
|
||||
file_path = posixpath.join(out_dir, filename)
|
||||
formatted_patch = (
|
||||
'\n'.join(remove_patch_filename(patch)).rstrip('\n') + '\n'
|
||||
)
|
||||
with io.open(
|
||||
file_path, 'w', newline='\n', encoding='utf-8'
|
||||
) as f:
|
||||
f.write(formatted_patch)
|
||||
pl.write(filename + '\n')
|
||||
|
||||
|
||||
@@ -25,11 +25,13 @@ from lib.config import is_verbose_mode
|
||||
ELECTRON_DIR = os.path.abspath(
|
||||
os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
|
||||
)
|
||||
TS_NODE = os.path.join(ELECTRON_DIR, 'node_modules', '.bin', 'ts-node')
|
||||
SRC_DIR = os.path.abspath(os.path.join(__file__, '..', '..', '..', '..'))
|
||||
|
||||
NPM = 'npm'
|
||||
if sys.platform in ['win32', 'cygwin']:
|
||||
NPM += '.cmd'
|
||||
TS_NODE += '.cmd'
|
||||
|
||||
|
||||
def tempdir(prefix=''):
|
||||
|
||||
41
script/push-patch.js
Normal file
41
script/push-patch.js
Normal file
@@ -0,0 +1,41 @@
|
||||
const { createAppAuth } = require('@octokit/auth-app');
|
||||
const cp = require('child_process');
|
||||
|
||||
if (!process.env.CIRCLE_BRANCH) {
|
||||
console.error('Not building for a specific branch, can\'t autopush a patch');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (process.env.CIRCLE_PR_NUMBER) {
|
||||
console.error('Building for a forked PR, can\'t autopush a patch');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const auth = createAppAuth({
|
||||
appId: process.env.PATCH_UP_APP_ID,
|
||||
privateKey: Buffer.from(process.env.PATCH_UP_PRIVATE_KEY, 'base64').toString('utf8'),
|
||||
installationId: process.env.PATCH_UP_INSTALLATION_ID,
|
||||
clientId: process.env.PATCH_UP_CLIENT_ID,
|
||||
clientSecret: process.env.PATCH_UP_CLIENT_SECRET
|
||||
});
|
||||
|
||||
async function main () {
|
||||
const installationAuth = await auth({ type: 'installation' });
|
||||
const remoteURL = `https://x-access-token:${installationAuth.token}@github.com/electron/electron.git`;
|
||||
// NEVER LOG THE OUTPUT OF THIS COMMAND
|
||||
// GIT LEAKS THE ACCESS CREDENTIALS IN CONSOLE LOGS
|
||||
const { status } = cp.spawnSync('git', ['push', '--set-upstream', remoteURL], {
|
||||
stdio: 'ignore'
|
||||
});
|
||||
if (status !== 0) {
|
||||
console.error('Failed to push to target branch');
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (process.mainModule === module) {
|
||||
main().catch((err) => {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
});
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
if (!process.env.CI) require('dotenv-safe').load();
|
||||
import { Octokit } from '@octokit/rest';
|
||||
import * as fs from 'fs';
|
||||
|
||||
const fs = require('fs');
|
||||
|
||||
const { Octokit } = require('@octokit/rest');
|
||||
const octokit = new Octokit({
|
||||
auth: process.env.ELECTRON_GITHUB_TOKEN
|
||||
});
|
||||
|
||||
if (!process.env.CI) require('dotenv-safe').load();
|
||||
|
||||
if (process.argv.length < 6) {
|
||||
console.log('Usage: upload-to-github filePath fileName releaseId');
|
||||
process.exit(1);
|
||||
@@ -14,13 +14,20 @@ if (process.argv.length < 6) {
|
||||
|
||||
const filePath = process.argv[2];
|
||||
const fileName = process.argv[3];
|
||||
const releaseId = process.argv[4];
|
||||
const releaseId = parseInt(process.argv[4], 10);
|
||||
const releaseVersion = process.argv[5];
|
||||
|
||||
const getHeaders = (filePath, fileName) => {
|
||||
if (isNaN(releaseId)) {
|
||||
throw new Error('Provided release ID was not a valid integer');
|
||||
}
|
||||
|
||||
const getHeaders = (filePath: string, fileName: string) => {
|
||||
const extension = fileName.split('.').pop();
|
||||
if (!extension) {
|
||||
throw new Error(`Failed to get headers for extensionless file: ${fileName}`);
|
||||
}
|
||||
const size = fs.statSync(filePath).size;
|
||||
const options = {
|
||||
const options: Record<string, string> = {
|
||||
json: 'text/json',
|
||||
zip: 'application/zip',
|
||||
txt: 'text/plain',
|
||||
@@ -41,8 +48,11 @@ function uploadToGitHub () {
|
||||
octokit.repos.uploadReleaseAsset({
|
||||
url: uploadUrl,
|
||||
headers: getHeaders(filePath, fileName),
|
||||
data: fs.createReadStream(filePath),
|
||||
name: fileName
|
||||
data: fs.createReadStream(filePath) as any,
|
||||
name: fileName,
|
||||
owner: 'electron',
|
||||
repo: targetRepo,
|
||||
release_id: releaseId
|
||||
}).then(() => {
|
||||
console.log(`Successfully uploaded ${fileName} to GitHub.`);
|
||||
process.exit();
|
||||
@@ -51,7 +61,7 @@ function uploadToGitHub () {
|
||||
console.log(`Error uploading ${fileName} to GitHub, will retry. Error was:`, err);
|
||||
retry++;
|
||||
|
||||
octokit.repos.listAssetsForRelease({
|
||||
octokit.repos.listReleaseAssets({
|
||||
owner: 'electron',
|
||||
repo: targetRepo,
|
||||
release_id: releaseId,
|
||||
@@ -17,10 +17,10 @@ sys.path.append(
|
||||
|
||||
from zipfile import ZipFile
|
||||
from lib.config import PLATFORM, get_target_arch, get_env_var, s3_config, \
|
||||
get_zip_name
|
||||
get_zip_name, enable_verbose_mode, get_platform_key
|
||||
from lib.util import get_electron_branding, execute, get_electron_version, \
|
||||
s3put, get_electron_exec, get_out_dir, \
|
||||
SRC_DIR, ELECTRON_DIR
|
||||
SRC_DIR, ELECTRON_DIR, TS_NODE
|
||||
|
||||
|
||||
ELECTRON_REPO = 'electron/electron'
|
||||
@@ -42,7 +42,9 @@ TOOLCHAIN_PROFILE_NAME = get_zip_name(PROJECT_NAME, ELECTRON_VERSION,
|
||||
|
||||
def main():
|
||||
args = parse_args()
|
||||
if args.upload_to_s3:
|
||||
if args.verbose:
|
||||
enable_verbose_mode()
|
||||
if args.upload_to_s3:
|
||||
utcnow = datetime.datetime.utcnow()
|
||||
args.upload_timestamp = utcnow.strftime('%Y%m%d')
|
||||
|
||||
@@ -74,12 +76,14 @@ def main():
|
||||
symbols_zip = os.path.join(OUT_DIR, SYMBOLS_NAME)
|
||||
shutil.copy2(os.path.join(OUT_DIR, 'symbols.zip'), symbols_zip)
|
||||
upload_electron(release, symbols_zip, args)
|
||||
if PLATFORM == 'darwin':
|
||||
api_path = os.path.join(ELECTRON_DIR, 'electron-api.json')
|
||||
upload_electron(release, api_path, args)
|
||||
if get_platform_key() == 'darwin':
|
||||
if get_target_arch() == 'x64':
|
||||
api_path = os.path.join(ELECTRON_DIR, 'electron-api.json')
|
||||
upload_electron(release, api_path, args)
|
||||
|
||||
ts_defs_path = os.path.join(ELECTRON_DIR, 'electron.d.ts')
|
||||
upload_electron(release, ts_defs_path, args)
|
||||
|
||||
ts_defs_path = os.path.join(ELECTRON_DIR, 'electron.d.ts')
|
||||
upload_electron(release, ts_defs_path, args)
|
||||
dsym_zip = os.path.join(OUT_DIR, DSYM_NAME)
|
||||
shutil.copy2(os.path.join(OUT_DIR, 'dsym.zip'), dsym_zip)
|
||||
upload_electron(release, dsym_zip, args)
|
||||
@@ -151,6 +155,9 @@ def parse_args():
|
||||
action='store_true',
|
||||
default=False,
|
||||
required=False)
|
||||
parser.add_argument('--verbose',
|
||||
action='store_true',
|
||||
help='Mooooorreee logs')
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
@@ -161,7 +168,7 @@ def run_python_upload_script(script, *args):
|
||||
|
||||
|
||||
def get_electron_build_version():
|
||||
if get_target_arch().startswith('arm') or os.environ.has_key('CI'):
|
||||
if get_target_arch().startswith('arm') or 'CI' in os.environ:
|
||||
# In CI we just build as told.
|
||||
return ELECTRON_VERSION
|
||||
electron = get_electron_exec()
|
||||
@@ -332,8 +339,8 @@ def upload_io_to_github(release, filename, filepath, version):
|
||||
print('Uploading %s to Github' % \
|
||||
(filename))
|
||||
script_path = os.path.join(
|
||||
ELECTRON_DIR, 'script', 'release', 'uploaders', 'upload-to-github.js')
|
||||
execute(['node', script_path, filepath, filename, str(release['id']),
|
||||
ELECTRON_DIR, 'script', 'release', 'uploaders', 'upload-to-github.ts')
|
||||
execute([TS_NODE, script_path, filepath, filename, str(release['id']),
|
||||
version])
|
||||
|
||||
|
||||
|
||||
370
script/run-clang-tidy.ts
Normal file
370
script/run-clang-tidy.ts
Normal file
@@ -0,0 +1,370 @@
|
||||
import chalk from 'chalk';
|
||||
import * as childProcess from 'child_process';
|
||||
import * as fs from 'fs';
|
||||
import * as klaw from 'klaw';
|
||||
import * as minimist from 'minimist';
|
||||
import * as os from 'os';
|
||||
import * as path from 'path';
|
||||
import * as streamChain from 'stream-chain';
|
||||
import * as streamJson from 'stream-json';
|
||||
import { ignore as streamJsonIgnore } from 'stream-json/filters/Ignore';
|
||||
import { streamArray as streamJsonStreamArray } from 'stream-json/streamers/StreamArray';
|
||||
|
||||
const SOURCE_ROOT = path.normalize(path.dirname(__dirname));
|
||||
const LLVM_BIN = path.resolve(
|
||||
SOURCE_ROOT,
|
||||
'..',
|
||||
'third_party',
|
||||
'llvm-build',
|
||||
'Release+Asserts',
|
||||
'bin'
|
||||
);
|
||||
const PLATFORM = os.platform();
|
||||
|
||||
type SpawnAsyncResult = {
|
||||
stdout: string;
|
||||
stderr: string;
|
||||
status: number | null;
|
||||
};
|
||||
|
||||
class ErrorWithExitCode extends Error {
|
||||
exitCode: number;
|
||||
|
||||
constructor (message: string, exitCode: number) {
|
||||
super(message);
|
||||
this.exitCode = exitCode;
|
||||
}
|
||||
}
|
||||
|
||||
async function spawnAsync (
|
||||
command: string,
|
||||
args: string[],
|
||||
options?: childProcess.SpawnOptionsWithoutStdio | undefined
|
||||
): Promise<SpawnAsyncResult> {
|
||||
return new Promise((resolve, reject) => {
|
||||
try {
|
||||
const stdio = { stdout: '', stderr: '' };
|
||||
const spawned = childProcess.spawn(command, args, options || {});
|
||||
|
||||
spawned.stdout.on('data', (data) => {
|
||||
stdio.stdout += data;
|
||||
});
|
||||
|
||||
spawned.stderr.on('data', (data) => {
|
||||
stdio.stderr += data;
|
||||
});
|
||||
|
||||
spawned.on('exit', (code) => resolve({ ...stdio, status: code }));
|
||||
spawned.on('error', (err) => reject(err));
|
||||
} catch (err) {
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function getDepotToolsEnv (): NodeJS.ProcessEnv {
|
||||
let depotToolsEnv;
|
||||
|
||||
const findDepotToolsOnPath = () => {
|
||||
const result = childProcess.spawnSync(
|
||||
PLATFORM === 'win32' ? 'where' : 'which',
|
||||
['gclient']
|
||||
);
|
||||
|
||||
if (result.status === 0) {
|
||||
return process.env;
|
||||
}
|
||||
};
|
||||
|
||||
const checkForBuildTools = () => {
|
||||
const result = childProcess.spawnSync(
|
||||
'electron-build-tools',
|
||||
['show', 'env', '--json'],
|
||||
{ shell: true }
|
||||
);
|
||||
|
||||
if (result.status === 0) {
|
||||
return {
|
||||
...process.env,
|
||||
...JSON.parse(result.stdout.toString().trim())
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
try {
|
||||
depotToolsEnv = findDepotToolsOnPath();
|
||||
if (!depotToolsEnv) depotToolsEnv = checkForBuildTools();
|
||||
} catch {}
|
||||
|
||||
if (!depotToolsEnv) {
|
||||
throw new Error("Couldn't find depot_tools, ensure it's on your PATH");
|
||||
}
|
||||
|
||||
if (!('CHROMIUM_BUILDTOOLS_PATH' in depotToolsEnv)) {
|
||||
throw new Error(
|
||||
'CHROMIUM_BUILDTOOLS_PATH environment variable must be set'
|
||||
);
|
||||
}
|
||||
|
||||
return depotToolsEnv;
|
||||
}
|
||||
|
||||
function chunkFilenames (filenames: string[], offset: number = 0): string[][] {
|
||||
// Windows has a max command line length of 2047 characters, so we can't
|
||||
// provide too many filenames without going over that. To work around that,
|
||||
// chunk up a list of filenames such that it won't go over that limit when
|
||||
// used as args. Use a much higher limit on other platforms which will
|
||||
// effectively be a no-op.
|
||||
const MAX_FILENAME_ARGS_LENGTH =
|
||||
PLATFORM === 'win32' ? 2047 - offset : 100 * 1024;
|
||||
|
||||
return filenames.reduce(
|
||||
(chunkedFilenames: string[][], filename) => {
|
||||
const currChunk = chunkedFilenames[chunkedFilenames.length - 1];
|
||||
const currChunkLength = currChunk.reduce(
|
||||
(totalLength, _filename) => totalLength + _filename.length + 1,
|
||||
0
|
||||
);
|
||||
if (currChunkLength + filename.length + 1 > MAX_FILENAME_ARGS_LENGTH) {
|
||||
chunkedFilenames.push([filename]);
|
||||
} else {
|
||||
currChunk.push(filename);
|
||||
}
|
||||
return chunkedFilenames;
|
||||
},
|
||||
[[]]
|
||||
);
|
||||
}
|
||||
|
||||
async function runClangTidy (
|
||||
outDir: string,
|
||||
filenames: string[],
|
||||
checks: string = '',
|
||||
jobs: number = 1
|
||||
): Promise<boolean> {
|
||||
const cmd = path.resolve(LLVM_BIN, 'clang-tidy');
|
||||
const args = [`-p=${outDir}`];
|
||||
|
||||
if (checks) args.push(`--checks=${checks}`);
|
||||
|
||||
// Remove any files that aren't in the compilation database to prevent
|
||||
// errors from cluttering up the output. Since the compilation DB is hundreds
|
||||
// of megabytes, this is done with streaming to not hold it all in memory.
|
||||
const filterCompilationDatabase = (): Promise<string[]> => {
|
||||
const compiledFilenames: string[] = [];
|
||||
|
||||
return new Promise((resolve) => {
|
||||
const pipeline = streamChain.chain([
|
||||
fs.createReadStream(path.resolve(outDir, 'compile_commands.json')),
|
||||
streamJson.parser(),
|
||||
streamJsonIgnore({ filter: /\bcommand\b/i }),
|
||||
streamJsonStreamArray(),
|
||||
({ value: { file, directory } }) => {
|
||||
const filename = path.resolve(directory, file);
|
||||
return filenames.includes(filename) ? filename : null;
|
||||
}
|
||||
]);
|
||||
|
||||
pipeline.on('data', (data) => compiledFilenames.push(data));
|
||||
pipeline.on('end', () => resolve(compiledFilenames));
|
||||
});
|
||||
};
|
||||
|
||||
// clang-tidy can figure out the file from a short relative filename, so
|
||||
// to get the most bang for the buck on the command line, let's trim the
|
||||
// filenames to the minimum so that we can fit more per invocation
|
||||
filenames = (await filterCompilationDatabase()).map((filename) =>
|
||||
path.relative(SOURCE_ROOT, filename)
|
||||
);
|
||||
|
||||
if (filenames.length === 0) {
|
||||
throw new Error('No filenames to run');
|
||||
}
|
||||
|
||||
const commandLength =
|
||||
cmd.length + args.reduce((length, arg) => length + arg.length, 0);
|
||||
|
||||
const results: boolean[] = [];
|
||||
const asyncWorkers = [];
|
||||
const chunkedFilenames: string[][] = [];
|
||||
|
||||
const filesPerWorker = Math.ceil(filenames.length / jobs);
|
||||
|
||||
for (let i = 0; i < jobs; i++) {
|
||||
chunkedFilenames.push(
|
||||
...chunkFilenames(filenames.splice(0, filesPerWorker), commandLength)
|
||||
);
|
||||
}
|
||||
|
||||
const worker = async () => {
|
||||
let filenames = chunkedFilenames.shift();
|
||||
|
||||
while (filenames) {
|
||||
results.push(
|
||||
await spawnAsync(cmd, [...args, ...filenames], {}).then((result) => {
|
||||
// We lost color, so recolorize because it's much more legible
|
||||
// There's a --use-color flag for clang-tidy but it has no effect
|
||||
// on Windows at the moment, so just recolor for everyone
|
||||
let state = null;
|
||||
|
||||
for (const line of result.stdout.split('\n')) {
|
||||
if (line.includes(' warning: ')) {
|
||||
console.log(
|
||||
line
|
||||
.split(' warning: ')
|
||||
.map((part) => chalk.whiteBright(part))
|
||||
.join(chalk.magentaBright(' warning: '))
|
||||
);
|
||||
state = 'code-line';
|
||||
} else if (line.includes(' note: ')) {
|
||||
const lineParts = line.split(' note: ');
|
||||
lineParts[0] = chalk.whiteBright(lineParts[0]);
|
||||
console.log(lineParts.join(chalk.grey(' note: ')));
|
||||
state = 'code-line';
|
||||
} else if (line.startsWith('error:')) {
|
||||
console.log(
|
||||
chalk.redBright('error: ') + line.split(' ').slice(1).join(' ')
|
||||
);
|
||||
} else if (state === 'code-line') {
|
||||
console.log(line);
|
||||
state = 'post-code-line';
|
||||
} else if (state === 'post-code-line') {
|
||||
console.log(chalk.greenBright(line));
|
||||
} else {
|
||||
console.log(line);
|
||||
}
|
||||
}
|
||||
|
||||
if (result.status !== 0) {
|
||||
console.error(result.stderr);
|
||||
}
|
||||
|
||||
// On a clean run there's nothing on stdout. A run with warnings-only
|
||||
// will have a status code of zero, but there's output on stdout
|
||||
return result.status === 0 && result.stdout.length === 0;
|
||||
})
|
||||
);
|
||||
|
||||
filenames = chunkedFilenames.shift();
|
||||
}
|
||||
};
|
||||
|
||||
for (let i = 0; i < jobs; i++) {
|
||||
asyncWorkers.push(worker());
|
||||
}
|
||||
|
||||
try {
|
||||
await Promise.all(asyncWorkers);
|
||||
return results.every((x) => x);
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
async function findMatchingFiles (
|
||||
top: string,
|
||||
test: (filename: string) => boolean
|
||||
): Promise<string[]> {
|
||||
return new Promise((resolve) => {
|
||||
const matches = [] as string[];
|
||||
klaw(top, {
|
||||
filter: (f) => path.basename(f) !== '.bin'
|
||||
})
|
||||
.on('end', () => resolve(matches))
|
||||
.on('data', (item) => {
|
||||
if (test(item.path)) {
|
||||
matches.push(item.path);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function parseCommandLine () {
|
||||
const showUsage = (arg?: string) : boolean => {
|
||||
if (!arg || arg.startsWith('-')) {
|
||||
console.log(
|
||||
'Usage: script/run-clang-tidy.ts [-h|--help] [--jobs|-j] ' +
|
||||
'[--checks] --out-dir OUTDIR [file1 file2]'
|
||||
);
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
const opts = minimist(process.argv.slice(2), {
|
||||
boolean: ['help'],
|
||||
string: ['checks', 'out-dir'],
|
||||
default: { jobs: 1 },
|
||||
alias: { help: 'h', jobs: 'j' },
|
||||
stopEarly: true,
|
||||
unknown: showUsage
|
||||
});
|
||||
|
||||
if (opts.help) showUsage();
|
||||
|
||||
if (!opts['out-dir']) {
|
||||
console.log('--out-dir is a required argunment');
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
return opts;
|
||||
}
|
||||
|
||||
async function main (): Promise<boolean> {
|
||||
const opts = parseCommandLine();
|
||||
const outDir = path.resolve(opts['out-dir']);
|
||||
|
||||
if (!fs.existsSync(outDir)) {
|
||||
throw new Error("Output directory doesn't exist");
|
||||
} else {
|
||||
// Make sure the compile_commands.json file is up-to-date
|
||||
const env = getDepotToolsEnv();
|
||||
|
||||
const result = childProcess.spawnSync(
|
||||
'gn',
|
||||
['gen', '.', '--export-compile-commands'],
|
||||
{ cwd: outDir, env, shell: true }
|
||||
);
|
||||
|
||||
if (result.status !== 0) {
|
||||
if (result.error) {
|
||||
console.error(result.error.message);
|
||||
} else {
|
||||
console.error(result.stderr.toString());
|
||||
}
|
||||
|
||||
throw new ErrorWithExitCode(
|
||||
'Failed to automatically generate compile_commands.json for ' +
|
||||
'output directory',
|
||||
2
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const filenames = [];
|
||||
|
||||
if (opts._.length > 0) {
|
||||
filenames.push(...opts._.map((filename) => path.resolve(filename)));
|
||||
} else {
|
||||
filenames.push(
|
||||
...(await findMatchingFiles(
|
||||
path.resolve(SOURCE_ROOT, 'shell'),
|
||||
(filename: string) => /.*\.(?:cc|h|mm)$/.test(filename)
|
||||
))
|
||||
);
|
||||
}
|
||||
|
||||
return runClangTidy(outDir, filenames, opts.checks, opts.jobs);
|
||||
}
|
||||
|
||||
if (require.main === module) {
|
||||
main()
|
||||
.then((success) => {
|
||||
process.exit(success ? 0 : 1);
|
||||
})
|
||||
.catch((err: ErrorWithExitCode) => {
|
||||
console.error(`ERROR: ${err.message}`);
|
||||
process.exit(err.exitCode || 1);
|
||||
});
|
||||
}
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "content/public/browser/render_view_host.h"
|
||||
#include "shell/browser/api/electron_api_web_contents_view.h"
|
||||
#include "shell/browser/browser.h"
|
||||
#include "shell/browser/native_browser_view.h"
|
||||
#include "shell/browser/unresponsive_suppressor.h"
|
||||
#include "shell/browser/web_contents_preferences.h"
|
||||
#include "shell/browser/window_list.h"
|
||||
@@ -304,8 +305,15 @@ void BrowserWindow::OnWindowIsKeyChanged(bool is_key) {
|
||||
|
||||
void BrowserWindow::OnWindowResize() {
|
||||
#if defined(OS_MAC)
|
||||
if (!draggable_regions_.empty())
|
||||
if (!draggable_regions_.empty()) {
|
||||
UpdateDraggableRegions(draggable_regions_);
|
||||
} else {
|
||||
// Ensure draggable bounds are recalculated for BrowserViews if any exist.
|
||||
auto browser_views = window_->browser_views();
|
||||
for (NativeBrowserView* view : browser_views) {
|
||||
view->UpdateDraggableRegions(draggable_regions_);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
BaseWindow::OnWindowResize();
|
||||
}
|
||||
|
||||
@@ -63,6 +63,9 @@ class BrowserWindow : public BaseWindow,
|
||||
void OnActivateContents() override;
|
||||
void OnPageTitleUpdated(const base::string16& title,
|
||||
bool explicit_set) override;
|
||||
#if defined(OS_MAC)
|
||||
void OnDevToolsResized() override;
|
||||
#endif
|
||||
|
||||
// NativeWindowObserver:
|
||||
void RequestPreferredWidth(int* width) override;
|
||||
|
||||
@@ -12,27 +12,9 @@
|
||||
#include "base/mac/scoped_nsobject.h"
|
||||
#include "shell/browser/native_browser_view.h"
|
||||
#include "shell/browser/native_window_mac.h"
|
||||
#include "shell/browser/ui/cocoa/electron_inspectable_web_contents_view.h"
|
||||
#include "shell/browser/ui/inspectable_web_contents_view.h"
|
||||
|
||||
@interface NSView (WebContentsView)
|
||||
- (void)setMouseDownCanMoveWindow:(BOOL)can_move;
|
||||
@end
|
||||
|
||||
@interface ControlRegionView : NSView
|
||||
@end
|
||||
|
||||
@implementation ControlRegionView
|
||||
|
||||
- (BOOL)mouseDownCanMoveWindow {
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (NSView*)hitTest:(NSPoint)aPoint {
|
||||
return nil;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
namespace electron {
|
||||
|
||||
namespace api {
|
||||
@@ -54,6 +36,10 @@ void BrowserWindow::OverrideNSWindowContentView(InspectableWebContents* iwc) {
|
||||
[contentView viewDidMoveToWindow];
|
||||
}
|
||||
|
||||
void BrowserWindow::OnDevToolsResized() {
|
||||
UpdateDraggableRegions(draggable_regions_);
|
||||
}
|
||||
|
||||
void BrowserWindow::UpdateDraggableRegions(
|
||||
const std::vector<mojom::DraggableRegionPtr>& regions) {
|
||||
if (window_->has_frame())
|
||||
@@ -82,8 +68,8 @@ void BrowserWindow::UpdateDraggableRegions(
|
||||
if ([subview isKindOfClass:[ControlRegionView class]])
|
||||
[subview removeFromSuperview];
|
||||
|
||||
// Draggable regions is implemented by having the whole web view draggable
|
||||
// (mouseDownCanMoveWindow) and overlaying regions that are not draggable.
|
||||
// Draggable regions are implemented by having the whole web view draggable
|
||||
// and overlaying regions that are not draggable.
|
||||
if (&draggable_regions_ != ®ions) {
|
||||
draggable_regions_.clear();
|
||||
for (const auto& r : regions)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user