mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
Compare commits
90 Commits
v7.0.0-nig
...
v7.0.0-nig
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3173b66d00 | ||
|
|
3038846f5d | ||
|
|
3859244a79 | ||
|
|
cc223d7cd2 | ||
|
|
f62d9f1411 | ||
|
|
0348b60a34 | ||
|
|
684d1838f9 | ||
|
|
6ece477779 | ||
|
|
e03a40026a | ||
|
|
6eed4a98ce | ||
|
|
1d8e16bc6e | ||
|
|
23b8c9c917 | ||
|
|
769dcce9d7 | ||
|
|
a4f61565c3 | ||
|
|
e44bb8474b | ||
|
|
0a9438dbba | ||
|
|
127d617db5 | ||
|
|
1a6a16e346 | ||
|
|
ec8697bcdc | ||
|
|
fdb2502a19 | ||
|
|
e8e360a902 | ||
|
|
819cebff5d | ||
|
|
c1ad0725d8 | ||
|
|
6243dba068 | ||
|
|
d643921313 | ||
|
|
5298358b72 | ||
|
|
2b3a256647 | ||
|
|
c87394ee25 | ||
|
|
ab5ec0af33 | ||
|
|
dc2cd8e780 | ||
|
|
24ffc3cfb0 | ||
|
|
99e3de56df | ||
|
|
1304f259cc | ||
|
|
ed5c624b08 | ||
|
|
764be844ec | ||
|
|
fb01c94511 | ||
|
|
5686a0713e | ||
|
|
1cd7c21f38 | ||
|
|
a084093d73 | ||
|
|
79ac99c09b | ||
|
|
e8c8328081 | ||
|
|
792f6b246c | ||
|
|
bef9610f6a | ||
|
|
81497c7f2e | ||
|
|
236d552d6a | ||
|
|
57c099d8b8 | ||
|
|
7e5ea179a1 | ||
|
|
536327151d | ||
|
|
e95d2129be | ||
|
|
c27231ce5c | ||
|
|
6251a6d307 | ||
|
|
f3f2990b9e | ||
|
|
23286fe557 | ||
|
|
dca583a77f | ||
|
|
34c4c8d508 | ||
|
|
8c4496a9c9 | ||
|
|
56930338e8 | ||
|
|
2160c1fcc9 | ||
|
|
d7f07e8a80 | ||
|
|
4575a4aae3 | ||
|
|
257fd2c0df | ||
|
|
aa522731a2 | ||
|
|
5247fe6038 | ||
|
|
5cb25c27b0 | ||
|
|
f8f0540487 | ||
|
|
ee01810395 | ||
|
|
79f0c444fd | ||
|
|
7201845894 | ||
|
|
504edf2cf6 | ||
|
|
0146cc0eb5 | ||
|
|
00d18917d0 | ||
|
|
ae49aa4a03 | ||
|
|
98bc0ae7ee | ||
|
|
edb56500c7 | ||
|
|
450aa33775 | ||
|
|
a0b2810640 | ||
|
|
a42ed950ca | ||
|
|
c720803413 | ||
|
|
b98c1d0472 | ||
|
|
d5811607eb | ||
|
|
3f7cce6d8c | ||
|
|
1aac7ac9d0 | ||
|
|
ccd15fc12e | ||
|
|
0af3548b55 | ||
|
|
4dc38d39e9 | ||
|
|
c9bca78a7a | ||
|
|
5a08522b98 | ||
|
|
deebde66f9 | ||
|
|
632bbf948d | ||
|
|
77d5e0c1ef |
@@ -103,7 +103,10 @@ env-disable-crash-reporter-tests: &env-disable-crash-reporter-tests
|
||||
DISABLE_CRASH_REPORTER_TESTS: true
|
||||
|
||||
env-ninja-status: &env-ninja-status
|
||||
NINJA_STATUS: "[%r processes, %f/%t @ %o/s : %es]"
|
||||
NINJA_STATUS: "[%r processes, %f/%t @ %o/s : %es] "
|
||||
|
||||
env-disable-run-as-node: &env-disable-run-as-node
|
||||
GN_BUILDFLAG_ARGS: 'enable_run_as_node = false'
|
||||
|
||||
# Individual (shared) steps.
|
||||
step-maybe-notify-slack-failure: &step-maybe-notify-slack-failure
|
||||
@@ -251,7 +254,7 @@ step-gn-gen-default: &step-gn-gen-default
|
||||
name: Default GN gen
|
||||
command: |
|
||||
cd src
|
||||
gn gen out/Default --args='import("'$GN_CONFIG'") cc_wrapper="'"$SCCACHE_PATH"'"'" $GN_EXTRA_ARGS"
|
||||
gn gen out/Default --args='import("'$GN_CONFIG'") cc_wrapper="'"$SCCACHE_PATH"'"'" $GN_EXTRA_ARGS $GN_BUILDFLAG_ARGS"
|
||||
|
||||
step-gn-check: &step-gn-check
|
||||
run:
|
||||
@@ -261,7 +264,7 @@ step-gn-check: &step-gn-check
|
||||
gn check out/Default //electron:electron_lib
|
||||
gn check out/Default //electron:electron_app
|
||||
gn check out/Default //electron:manifests
|
||||
gn check out/Default //electron/atom/common/api:mojo
|
||||
gn check out/Default //electron/shell/common/api:mojo
|
||||
|
||||
step-electron-build: &step-electron-build
|
||||
run:
|
||||
@@ -306,7 +309,7 @@ step-electron-dist-build: &step-electron-dist-build
|
||||
echo "Unknown system: `uname`"
|
||||
exit 1
|
||||
fi
|
||||
electron/script/check-zip-manifest.py out/Default/dist.zip electron/script/dist_zip.$target_os.$target_cpu.manifest
|
||||
electron/script/zip_manifests/check-zip-manifest.py out/Default/dist.zip electron/script/zip_manifests/dist_zip.$target_os.$target_cpu.manifest
|
||||
fi
|
||||
|
||||
step-electron-dist-store: &step-electron-dist-store
|
||||
@@ -347,10 +350,10 @@ step-electron-publish: &step-electron-publish
|
||||
cd src/electron
|
||||
if [ "$UPLOAD_TO_S3" == "1" ]; then
|
||||
echo 'Uploading Electron release distribution to S3'
|
||||
script/upload.py --upload_to_s3
|
||||
script/release/uploaders/upload.py --upload_to_s3
|
||||
else
|
||||
echo 'Uploading Electron release distribution to Github releases'
|
||||
script/upload.py
|
||||
script/release/uploaders/upload.py
|
||||
fi
|
||||
|
||||
step-persist-data-for-tests: &step-persist-data-for-tests
|
||||
@@ -518,7 +521,7 @@ step-maybe-trigger-arm-test: &step-maybe-trigger-arm-test
|
||||
if [ "$TRIGGER_ARM_TEST" == "true" ] && [ -z "$CIRCLE_PR_NUMBER" ]; then
|
||||
#Trigger VSTS job, passing along CircleCI job number and branch to build
|
||||
echo "Triggering electron-$TARGET_ARCH-testing build on VSTS"
|
||||
node electron/script/ci-release-build.js --job=electron-$TARGET_ARCH-testing --ci=VSTS --armTest --circleBuildNum=$CIRCLE_BUILD_NUM $CIRCLE_BRANCH
|
||||
node electron/script/release/ci-release-build.js --job=electron-$TARGET_ARCH-testing --ci=VSTS --armTest --circleBuildNum=$CIRCLE_BUILD_NUM $CIRCLE_BRANCH
|
||||
fi
|
||||
|
||||
step-maybe-generate-typescript-defs: &step-maybe-generate-typescript-defs
|
||||
@@ -577,7 +580,7 @@ steps-lint: &steps-lint
|
||||
# but then we would lint its contents (at least gn format), and it doesn't pass it.
|
||||
|
||||
cd src/electron
|
||||
node script/yarn install
|
||||
node script/yarn install --frozen-lockfile
|
||||
node script/yarn lint
|
||||
|
||||
steps-checkout: &steps-checkout
|
||||
@@ -988,6 +991,16 @@ jobs:
|
||||
<<: *env-ninja-status
|
||||
<<: *steps-electron-build-for-tests
|
||||
|
||||
linux-x64-testing-no-run-as-node:
|
||||
<<: *machine-linux-2xlarge
|
||||
environment:
|
||||
<<: *env-linux-2xlarge
|
||||
<<: *env-testing-build
|
||||
<<: *env-enable-sccache
|
||||
<<: *env-ninja-status
|
||||
<<: *env-disable-run-as-node
|
||||
<<: *steps-electron-build-for-tests
|
||||
|
||||
linux-x64-testing-gn-check:
|
||||
<<: *machine-linux-medium
|
||||
environment:
|
||||
@@ -1546,6 +1559,9 @@ workflows:
|
||||
- linux-x64-testing:
|
||||
requires:
|
||||
- linux-checkout
|
||||
- linux-x64-testing-no-run-as-node:
|
||||
requires:
|
||||
- linux-checkout
|
||||
- linux-x64-testing-gn-check:
|
||||
requires:
|
||||
- linux-checkout
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
*
|
||||
!tools/xvfb-init.sh
|
||||
!tools/run-electron.sh
|
||||
!build/install-build-deps.sh
|
||||
|
||||
11
.github/CODEOWNERS
vendored
11
.github/CODEOWNERS
vendored
@@ -18,13 +18,4 @@
|
||||
|
||||
# Releases WG
|
||||
/npm/ @electron/wg-releases
|
||||
/script/release-notes @electron/wg-releases
|
||||
/script/prepare-release.js @electron/wg-releases
|
||||
/script/bump-version.js @electron/wg-releases
|
||||
/script/ci-release-build.js @electron/wg-releases
|
||||
/script/release.js @electron/wg-releases
|
||||
/script/upload-to-github.js @electron/wg-releases
|
||||
/script/release-artifact-cleanup.js @electron/wg-releases
|
||||
/script/get-last-major-for-master.js @electron/wg-releases
|
||||
/script/find-release.js @electron/wg-releases
|
||||
/script/download-circleci-artifacts.js @electron/wg-releases
|
||||
/script/release @electron/wg-releases
|
||||
214
BUILD.gn
214
BUILD.gn
@@ -11,6 +11,7 @@ import("//tools/v8_context_snapshot/v8_context_snapshot.gni")
|
||||
import("//v8/gni/snapshot_toolchain.gni")
|
||||
import("build/asar.gni")
|
||||
import("build/npm.gni")
|
||||
import("build/templated_file.gni")
|
||||
import("build/tsc.gni")
|
||||
import("build/webpack/webpack.gni")
|
||||
import("buildflags/buildflags.gni")
|
||||
@@ -21,6 +22,7 @@ import("filenames.gni")
|
||||
if (is_mac) {
|
||||
import("//build/config/mac/rules.gni")
|
||||
import("//third_party/icu/config.gni")
|
||||
import("//ui/gl/features.gni")
|
||||
import("//v8/gni/v8.gni")
|
||||
}
|
||||
|
||||
@@ -39,7 +41,7 @@ if (is_linux) {
|
||||
}
|
||||
}
|
||||
|
||||
branding = read_file("atom/app/BRANDING.json", "json")
|
||||
branding = read_file("shell/app/BRANDING.json", "json")
|
||||
electron_project_name = branding.project_name
|
||||
electron_product_name = branding.product_name
|
||||
electron_mac_bundle_id = branding.mac_bundle_id
|
||||
@@ -51,8 +53,8 @@ if (is_mas_build) {
|
||||
|
||||
config("branding") {
|
||||
defines = [
|
||||
"ATOM_PRODUCT_NAME=\"$electron_product_name\"",
|
||||
"ATOM_PROJECT_NAME=\"$electron_project_name\"",
|
||||
"ELECTRON_PRODUCT_NAME=\"$electron_product_name\"",
|
||||
"ELECTRON_PROJECT_NAME=\"$electron_project_name\"",
|
||||
]
|
||||
}
|
||||
|
||||
@@ -285,14 +287,14 @@ if (is_linux) {
|
||||
|
||||
source_set("manifests") {
|
||||
sources = [
|
||||
"//electron/atom/app/manifests.cc",
|
||||
"//electron/atom/app/manifests.h",
|
||||
"//electron/shell/app/manifests.cc",
|
||||
"//electron/shell/app/manifests.h",
|
||||
]
|
||||
|
||||
include_dirs = [ "//electron" ]
|
||||
|
||||
deps = [
|
||||
"//electron/atom/common/api:mojo",
|
||||
"//electron/shell/common/api:mojo",
|
||||
"//printing/buildflags",
|
||||
"//services/proxy_resolver/public/cpp:manifest",
|
||||
"//services/service_manager/public/cpp",
|
||||
@@ -307,6 +309,32 @@ source_set("manifests") {
|
||||
}
|
||||
}
|
||||
|
||||
npm_action("electron_version_args") {
|
||||
script = "generate-version-json"
|
||||
|
||||
outputs = [
|
||||
"$target_gen_dir/electron_version.args",
|
||||
]
|
||||
|
||||
args = rebase_path(outputs)
|
||||
|
||||
inputs = [
|
||||
"ELECTRON_VERSION",
|
||||
"script/generate-version-json.js",
|
||||
]
|
||||
}
|
||||
|
||||
templated_file("electron_version_header") {
|
||||
deps = [
|
||||
":electron_version_args",
|
||||
]
|
||||
|
||||
template = "build/templates/electron_version.tmpl"
|
||||
output = "$target_gen_dir/electron_version.h"
|
||||
|
||||
args_files = get_target_outputs(":electron_version_args")
|
||||
}
|
||||
|
||||
static_library("electron_lib") {
|
||||
configs += [ "//v8:external_startup_data" ]
|
||||
configs += [ "//third_party/electron_node:node_internals" ]
|
||||
@@ -315,12 +343,13 @@ static_library("electron_lib") {
|
||||
|
||||
deps = [
|
||||
":atom_js2c",
|
||||
":electron_version_header",
|
||||
":manifests",
|
||||
":resources",
|
||||
"atom/common/api:mojo",
|
||||
"buildflags",
|
||||
"chromium_src:chrome",
|
||||
"native_mate",
|
||||
"shell/common/api:mojo",
|
||||
"//base:base_static",
|
||||
"//base/allocator:buildflags",
|
||||
"//chrome/app/resources:platform_locale_settings",
|
||||
@@ -437,8 +466,8 @@ static_library("electron_lib") {
|
||||
|
||||
if (enable_fake_location_provider) {
|
||||
sources += [
|
||||
"atom/browser/fake_location_provider.cc",
|
||||
"atom/browser/fake_location_provider.h",
|
||||
"shell/browser/fake_location_provider.cc",
|
||||
"shell/browser/fake_location_provider.h",
|
||||
]
|
||||
}
|
||||
|
||||
@@ -448,15 +477,15 @@ static_library("electron_lib") {
|
||||
"//ui/accelerated_widget_mac",
|
||||
]
|
||||
sources += [
|
||||
"atom/browser/ui/views/autofill_popup_view.cc",
|
||||
"atom/browser/ui/views/autofill_popup_view.h",
|
||||
"shell/browser/ui/views/autofill_popup_view.cc",
|
||||
"shell/browser/ui/views/autofill_popup_view.h",
|
||||
]
|
||||
if (is_mas_build) {
|
||||
sources += [ "atom/browser/api/atom_api_app_mas.mm" ]
|
||||
sources += [ "shell/browser/api/atom_api_app_mas.mm" ]
|
||||
sources -= [
|
||||
"atom/browser/auto_updater_mac.mm",
|
||||
"atom/common/crash_reporter/crash_reporter_mac.h",
|
||||
"atom/common/crash_reporter/crash_reporter_mac.mm",
|
||||
"shell/browser/auto_updater_mac.mm",
|
||||
"shell/common/crash_reporter/crash_reporter_mac.h",
|
||||
"shell/common/crash_reporter/crash_reporter_mac.mm",
|
||||
]
|
||||
defines += [ "MAS_BUILD" ]
|
||||
} else {
|
||||
@@ -512,8 +541,8 @@ static_library("electron_lib") {
|
||||
|
||||
if ((is_mac && !is_mas_build) || is_win) {
|
||||
sources += [
|
||||
"atom/common/crash_reporter/crash_reporter_crashpad.cc",
|
||||
"atom/common/crash_reporter/crash_reporter_crashpad.h",
|
||||
"shell/common/crash_reporter/crash_reporter_crashpad.cc",
|
||||
"shell/common/crash_reporter/crash_reporter_crashpad.h",
|
||||
]
|
||||
deps += [ "//third_party/crashpad/crashpad/client" ]
|
||||
}
|
||||
@@ -524,25 +553,25 @@ static_library("electron_lib") {
|
||||
|
||||
if (enable_run_as_node) {
|
||||
sources += [
|
||||
"atom/app/node_main.cc",
|
||||
"atom/app/node_main.h",
|
||||
"shell/app/node_main.cc",
|
||||
"shell/app/node_main.h",
|
||||
]
|
||||
}
|
||||
|
||||
if (enable_osr) {
|
||||
sources += [
|
||||
"atom/browser/osr/osr_host_display_client.cc",
|
||||
"atom/browser/osr/osr_host_display_client.h",
|
||||
"atom/browser/osr/osr_host_display_client_mac.mm",
|
||||
"atom/browser/osr/osr_render_widget_host_view.cc",
|
||||
"atom/browser/osr/osr_render_widget_host_view.h",
|
||||
"atom/browser/osr/osr_video_consumer.cc",
|
||||
"atom/browser/osr/osr_video_consumer.h",
|
||||
"atom/browser/osr/osr_view_proxy.cc",
|
||||
"atom/browser/osr/osr_view_proxy.h",
|
||||
"atom/browser/osr/osr_web_contents_view.cc",
|
||||
"atom/browser/osr/osr_web_contents_view.h",
|
||||
"atom/browser/osr/osr_web_contents_view_mac.mm",
|
||||
"shell/browser/osr/osr_host_display_client.cc",
|
||||
"shell/browser/osr/osr_host_display_client.h",
|
||||
"shell/browser/osr/osr_host_display_client_mac.mm",
|
||||
"shell/browser/osr/osr_render_widget_host_view.cc",
|
||||
"shell/browser/osr/osr_render_widget_host_view.h",
|
||||
"shell/browser/osr/osr_video_consumer.cc",
|
||||
"shell/browser/osr/osr_video_consumer.h",
|
||||
"shell/browser/osr/osr_view_proxy.cc",
|
||||
"shell/browser/osr/osr_view_proxy.h",
|
||||
"shell/browser/osr/osr_web_contents_view.cc",
|
||||
"shell/browser/osr/osr_web_contents_view.h",
|
||||
"shell/browser/osr/osr_web_contents_view_mac.mm",
|
||||
]
|
||||
deps += [
|
||||
"//components/viz/service",
|
||||
@@ -558,36 +587,36 @@ static_library("electron_lib") {
|
||||
deps += [ "//third_party/webrtc/modules/desktop_capture" ]
|
||||
}
|
||||
sources += [
|
||||
"atom/browser/api/atom_api_desktop_capturer.cc",
|
||||
"atom/browser/api/atom_api_desktop_capturer.h",
|
||||
"shell/browser/api/atom_api_desktop_capturer.cc",
|
||||
"shell/browser/api/atom_api_desktop_capturer.h",
|
||||
]
|
||||
}
|
||||
|
||||
if (enable_view_api) {
|
||||
sources += [
|
||||
"atom/browser/api/views/atom_api_box_layout.cc",
|
||||
"atom/browser/api/views/atom_api_box_layout.h",
|
||||
"atom/browser/api/views/atom_api_button.cc",
|
||||
"atom/browser/api/views/atom_api_button.h",
|
||||
"atom/browser/api/views/atom_api_label_button.cc",
|
||||
"atom/browser/api/views/atom_api_label_button.h",
|
||||
"atom/browser/api/views/atom_api_layout_manager.cc",
|
||||
"atom/browser/api/views/atom_api_layout_manager.h",
|
||||
"atom/browser/api/views/atom_api_md_text_button.cc",
|
||||
"atom/browser/api/views/atom_api_md_text_button.h",
|
||||
"atom/browser/api/views/atom_api_resize_area.cc",
|
||||
"atom/browser/api/views/atom_api_resize_area.h",
|
||||
"atom/browser/api/views/atom_api_text_field.cc",
|
||||
"atom/browser/api/views/atom_api_text_field.h",
|
||||
"shell/browser/api/views/atom_api_box_layout.cc",
|
||||
"shell/browser/api/views/atom_api_box_layout.h",
|
||||
"shell/browser/api/views/atom_api_button.cc",
|
||||
"shell/browser/api/views/atom_api_button.h",
|
||||
"shell/browser/api/views/atom_api_label_button.cc",
|
||||
"shell/browser/api/views/atom_api_label_button.h",
|
||||
"shell/browser/api/views/atom_api_layout_manager.cc",
|
||||
"shell/browser/api/views/atom_api_layout_manager.h",
|
||||
"shell/browser/api/views/atom_api_md_text_button.cc",
|
||||
"shell/browser/api/views/atom_api_md_text_button.h",
|
||||
"shell/browser/api/views/atom_api_resize_area.cc",
|
||||
"shell/browser/api/views/atom_api_resize_area.h",
|
||||
"shell/browser/api/views/atom_api_text_field.cc",
|
||||
"shell/browser/api/views/atom_api_text_field.h",
|
||||
]
|
||||
}
|
||||
|
||||
if (enable_basic_printing) {
|
||||
sources += [
|
||||
"atom/browser/printing/print_preview_message_handler.cc",
|
||||
"atom/browser/printing/print_preview_message_handler.h",
|
||||
"atom/renderer/printing/print_render_frame_helper_delegate.cc",
|
||||
"atom/renderer/printing/print_render_frame_helper_delegate.h",
|
||||
"shell/browser/printing/print_preview_message_handler.cc",
|
||||
"shell/browser/printing/print_preview_message_handler.h",
|
||||
"shell/renderer/printing/print_render_frame_helper_delegate.cc",
|
||||
"shell/renderer/printing/print_render_frame_helper_delegate.h",
|
||||
]
|
||||
}
|
||||
|
||||
@@ -651,6 +680,50 @@ if (is_mac) {
|
||||
group("electron_framework_libraries") {
|
||||
}
|
||||
}
|
||||
if (use_egl) {
|
||||
# Add the ANGLE .dylibs in the Libraries directory of the Framework.
|
||||
bundle_data("electron_angle_binaries") {
|
||||
sources = [
|
||||
"$root_out_dir/egl_intermediates/libEGL.dylib",
|
||||
"$root_out_dir/egl_intermediates/libGLESv2.dylib",
|
||||
]
|
||||
outputs = [
|
||||
"{{bundle_contents_dir}}/Libraries/{{source_file_part}}",
|
||||
]
|
||||
public_deps = [
|
||||
"//ui/gl:angle_library_copy",
|
||||
]
|
||||
}
|
||||
|
||||
# Add the SwiftShader .dylibs in the Libraries directory of the Framework.
|
||||
bundle_data("electron_swiftshader_binaries") {
|
||||
sources = [
|
||||
"$root_out_dir/egl_intermediates/libswiftshader_libEGL.dylib",
|
||||
"$root_out_dir/egl_intermediates/libswiftshader_libGLESv2.dylib",
|
||||
]
|
||||
outputs = [
|
||||
"{{bundle_contents_dir}}/Libraries/{{source_file_part}}",
|
||||
]
|
||||
public_deps = [
|
||||
"//ui/gl:swiftshader_library_copy",
|
||||
]
|
||||
}
|
||||
}
|
||||
group("electron_angle_library") {
|
||||
if (use_egl) {
|
||||
deps = [
|
||||
":electron_angle_binaries",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
group("electron_swiftshader_library") {
|
||||
if (use_egl) {
|
||||
deps = [
|
||||
":electron_swiftshader_binaries",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
bundle_data("electron_crashpad_helper") {
|
||||
sources = [
|
||||
@@ -677,17 +750,19 @@ if (is_mac) {
|
||||
":electron_lib",
|
||||
]
|
||||
deps = [
|
||||
":electron_angle_library",
|
||||
":electron_framework_libraries",
|
||||
":electron_framework_resources",
|
||||
":electron_swiftshader_library",
|
||||
]
|
||||
if (!is_mas_build) {
|
||||
deps += [ ":electron_crashpad_helper" ]
|
||||
}
|
||||
info_plist = "atom/common/resources/mac/Info.plist"
|
||||
info_plist = "shell/common/resources/mac/Info.plist"
|
||||
|
||||
electron_version = read_file("ELECTRON_VERSION", "trim string")
|
||||
extra_substitutions = [
|
||||
"ATOM_BUNDLE_ID=$electron_mac_bundle_id.framework",
|
||||
"ELECTRON_BUNDLE_ID=$electron_mac_bundle_id.framework",
|
||||
"ELECTRON_VERSION=$electron_version",
|
||||
]
|
||||
|
||||
@@ -735,10 +810,11 @@ if (is_mac) {
|
||||
}
|
||||
defines = [ "HELPER_EXECUTABLE" ]
|
||||
sources = filenames.app_sources
|
||||
sources += [ "atom/common/atom_constants.cc" ]
|
||||
sources += [ "shell/common/atom_constants.cc" ]
|
||||
include_dirs = [ "." ]
|
||||
info_plist = "atom/renderer/resources/mac/Info.plist"
|
||||
extra_substitutions = [ "ATOM_BUNDLE_ID=$electron_mac_bundle_id.helper" ]
|
||||
info_plist = "shell/renderer/resources/mac/Info.plist"
|
||||
extra_substitutions =
|
||||
[ "ELECTRON_BUNDLE_ID=$electron_mac_bundle_id.helper" ]
|
||||
ldflags = [
|
||||
"-rpath",
|
||||
"@executable_path/../../..",
|
||||
@@ -777,9 +853,9 @@ if (is_mac) {
|
||||
sources = filenames.login_helper_sources
|
||||
include_dirs = [ "." ]
|
||||
libs = [ "AppKit.framework" ]
|
||||
info_plist = "atom/app/resources/mac/loginhelper-Info.plist"
|
||||
info_plist = "shell/app/resources/mac/loginhelper-Info.plist"
|
||||
extra_substitutions =
|
||||
[ "ATOM_BUNDLE_ID=$electron_mac_bundle_id.loginhelper" ]
|
||||
[ "ELECTRON_BUNDLE_ID=$electron_mac_bundle_id.loginhelper" ]
|
||||
}
|
||||
|
||||
bundle_data("electron_login_helper_app") {
|
||||
@@ -831,7 +907,7 @@ if (is_mac) {
|
||||
]
|
||||
sources = [
|
||||
"$root_out_dir/resources/default_app.asar",
|
||||
"atom/browser/resources/mac/electron.icns",
|
||||
"shell/browser/resources/mac/electron.icns",
|
||||
]
|
||||
outputs = [
|
||||
"{{bundle_resources_dir}}/{{source_file_part}}",
|
||||
@@ -841,7 +917,7 @@ if (is_mac) {
|
||||
mac_app_bundle("electron_app") {
|
||||
output_name = electron_product_name
|
||||
sources = filenames.app_sources
|
||||
sources += [ "atom/common/atom_constants.cc" ]
|
||||
sources += [ "shell/common/atom_constants.cc" ]
|
||||
include_dirs = [ "." ]
|
||||
deps = [
|
||||
":electron_app_framework_bundle_data",
|
||||
@@ -850,8 +926,12 @@ if (is_mac) {
|
||||
if (is_mas_build) {
|
||||
deps += [ ":electron_login_helper_app" ]
|
||||
}
|
||||
info_plist = "atom/browser/resources/mac/Info.plist"
|
||||
extra_substitutions = [ "ATOM_BUNDLE_ID=$electron_mac_bundle_id" ]
|
||||
info_plist = "shell/browser/resources/mac/Info.plist"
|
||||
electron_version = read_file("ELECTRON_VERSION", "trim string")
|
||||
extra_substitutions = [
|
||||
"ELECTRON_BUNDLE_ID=$electron_mac_bundle_id",
|
||||
"ELECTRON_VERSION=$electron_version",
|
||||
]
|
||||
ldflags = [
|
||||
"-rpath",
|
||||
"@executable_path/../Frameworks",
|
||||
@@ -860,8 +940,8 @@ if (is_mac) {
|
||||
} else {
|
||||
windows_manifest("electron_app_manifest") {
|
||||
sources = [
|
||||
"atom/browser/resources/win/disable_window_filtering.manifest",
|
||||
"atom/browser/resources/win/dpi_aware.manifest",
|
||||
"shell/browser/resources/win/disable_window_filtering.manifest",
|
||||
"shell/browser/resources/win/dpi_aware.manifest",
|
||||
as_invoker_manifest,
|
||||
common_controls_manifest,
|
||||
default_compatibility_manifest,
|
||||
@@ -904,9 +984,9 @@ if (is_mac) {
|
||||
if (is_win) {
|
||||
sources += [
|
||||
# TODO: we should be generating our .rc files more like how chrome does
|
||||
"atom/browser/resources/win/atom.ico",
|
||||
"atom/browser/resources/win/atom.rc",
|
||||
"atom/browser/resources/win/resource.h",
|
||||
"shell/browser/resources/win/atom.ico",
|
||||
"shell/browser/resources/win/atom.rc",
|
||||
"shell/browser/resources/win/resource.h",
|
||||
]
|
||||
|
||||
libs = [
|
||||
|
||||
@@ -28,6 +28,18 @@ the issue will be closed.
|
||||
* If an issue has been closed and you still feel it's relevant, feel free to
|
||||
ping a maintainer or add a comment!
|
||||
|
||||
### Languages
|
||||
|
||||
We accept issues in *any* language.
|
||||
When an issue is posted in a language besides English, it is acceptable and encouraged to post an English-translated copy as a reply.
|
||||
Anyone may post the translated reply.
|
||||
In most cases, a quick pass through translation software is sufficient.
|
||||
Having the original text _as well as_ the translation can help mitigate translation errors.
|
||||
|
||||
Responses to posted issues may or may not be in the original language.
|
||||
|
||||
**Please note** that using non-English as an attempt to circumvent our [Code of Conduct](https://github.com/electron/electron/blob/master/CODE_OF_CONDUCT.md) will be an immediate, and possibly indefinite, ban from the project.
|
||||
|
||||
## [Pull Requests](https://electronjs.org/docs/development/pull-requests)
|
||||
|
||||
Pull Requests are the way concrete changes are made to the code, documentation,
|
||||
@@ -57,4 +69,4 @@ See [Coding Style](https://electronjs.org/docs/development/coding-style) for inf
|
||||
## Further Reading
|
||||
|
||||
For more in-depth guides on developing Electron, see
|
||||
[/docs/development](/docs/development/README.md)
|
||||
[/docs/development](/docs/development/README.md)
|
||||
|
||||
2
DEPS
2
DEPS
@@ -12,7 +12,7 @@ vars = {
|
||||
'chromium_version':
|
||||
'f200986dfaabd6aad6a4b37dad7aae42fec349e9',
|
||||
'node_version':
|
||||
'229bd3245b2f54c12ea9ad0abcadbc209f8023dc',
|
||||
'0a300f60bce0c8f0cb3d846fcb0e1f55f26013ee',
|
||||
'nan_version':
|
||||
'960dd6c70fc9eb136efdf37b4bef18fadbc3436f',
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
7.0.0-nightly.20190616
|
||||
7.0.0-nightly.20190701
|
||||
@@ -2,10 +2,8 @@
|
||||
|
||||
|
||||
[](https://circleci.com/gh/electron/electron/tree/master)
|
||||
[](https://windows-ci.electronjs.org/project/AppVeyor/electron/branch/master)
|
||||
[](https://github.visualstudio.com/electron/_build/latest?definitionId=36)
|
||||
[](https://ci.appveyor.com/project/electron-bot/electron-ljo26/branch/master)
|
||||
[](https://david-dm.org/electron/electron?type=dev)
|
||||
[](https://atom-slack.herokuapp.com/)
|
||||
|
||||
:memo: Available Translations: 🇨🇳 🇹🇼 🇧🇷 🇪🇸 🇰🇷 🇯🇵 🇷🇺 🇫🇷 🇹🇭 🇳🇱 🇹🇷 🇮🇩 🇺🇦 🇨🇿 🇮🇹 🇵🇱.
|
||||
View these docs in other languages at [electron/i18n](https://github.com/electron/i18n/tree/master/content/).
|
||||
|
||||
@@ -75,7 +75,7 @@ build_script:
|
||||
- gn check out/Default //electron:electron_lib
|
||||
- gn check out/Default //electron:electron_app
|
||||
- gn check out/Default //electron:manifests
|
||||
- gn check out/Default //electron/atom/common/api:mojo
|
||||
- gn check out/Default //electron/shell/common/api:mojo
|
||||
- ninja -C out/Default electron:electron_app
|
||||
- if "%GN_CONFIG%"=="testing" ( python C:\Users\electron\depot_tools\post_build_ninja_summary.py -C out\Default )
|
||||
- gn gen out/ffmpeg "--args=import(\"//electron/build/args/ffmpeg.gn\") %GN_EXTRA_ARGS%"
|
||||
@@ -97,7 +97,7 @@ build_script:
|
||||
python electron\script\zip-symbols.py
|
||||
appveyor PushArtifact out/Default/symbols.zip
|
||||
}
|
||||
- python electron/script/check-zip-manifest.py out/Default/dist.zip electron/script/dist_zip.win.%TARGET_ARCH%.manifest
|
||||
- python electron/script/zip_manifests/check-zip-manifest.py out/Default/dist.zip electron/script/zip_manifests/dist_zip.win.%TARGET_ARCH%.manifest
|
||||
test_script:
|
||||
# Workaround for https://github.com/appveyor/ci/issues/2420
|
||||
- set "PATH=%PATH%;C:\Program Files\Git\mingw64\libexec\git-core"
|
||||
@@ -125,9 +125,9 @@ 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\upload.py --upload_to_s3
|
||||
& python script\release\uploaders\upload.py --upload_to_s3
|
||||
} else {
|
||||
Write-Output "Uploading Electron release distribution to github releases"
|
||||
& python script\upload.py
|
||||
& python script\release\uploaders\upload.py
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
// Copyright (c) 2015 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef ATOM_BROWSER_NOTIFICATIONS_MAC_NOTIFICATION_CENTER_DELEGATE_H_
|
||||
#define ATOM_BROWSER_NOTIFICATIONS_MAC_NOTIFICATION_CENTER_DELEGATE_H_
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
namespace atom {
|
||||
class NotificationPresenterMac;
|
||||
}
|
||||
|
||||
@interface NotificationCenterDelegate
|
||||
: NSObject <NSUserNotificationCenterDelegate> {
|
||||
@private
|
||||
atom::NotificationPresenterMac* presenter_;
|
||||
}
|
||||
- (instancetype)initWithPresenter:(atom::NotificationPresenterMac*)presenter;
|
||||
@end
|
||||
|
||||
#endif // ATOM_BROWSER_NOTIFICATIONS_MAC_NOTIFICATION_CENTER_DELEGATE_H_
|
||||
@@ -1,33 +0,0 @@
|
||||
// Copyright (c) 2013 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef ATOM_COMMON_ATOM_VERSION_H_
|
||||
#define ATOM_COMMON_ATOM_VERSION_H_
|
||||
|
||||
#define ATOM_MAJOR_VERSION 7
|
||||
#define ATOM_MINOR_VERSION 0
|
||||
#define ATOM_PATCH_VERSION 0
|
||||
// clang-format off
|
||||
#define ATOM_PRE_RELEASE_VERSION -nightly.20190616
|
||||
// clang-format on
|
||||
|
||||
#ifndef ATOM_STRINGIFY
|
||||
#define ATOM_STRINGIFY(n) ATOM_STRINGIFY_HELPER(n)
|
||||
#define ATOM_STRINGIFY_HELPER(n) #n
|
||||
#endif
|
||||
|
||||
#ifndef ATOM_PRE_RELEASE_VERSION
|
||||
#define ATOM_VERSION_STRING \
|
||||
ATOM_STRINGIFY(ATOM_MAJOR_VERSION) \
|
||||
"." ATOM_STRINGIFY(ATOM_MINOR_VERSION) "." ATOM_STRINGIFY(ATOM_PATCH_VERSION)
|
||||
#else
|
||||
#define ATOM_VERSION_STRING \
|
||||
ATOM_STRINGIFY(ATOM_MAJOR_VERSION) \
|
||||
"." ATOM_STRINGIFY(ATOM_MINOR_VERSION) "." ATOM_STRINGIFY( \
|
||||
ATOM_PATCH_VERSION) ATOM_STRINGIFY(ATOM_PRE_RELEASE_VERSION)
|
||||
#endif
|
||||
|
||||
#define ATOM_VERSION "v" ATOM_VERSION_STRING
|
||||
|
||||
#endif // ATOM_COMMON_ATOM_VERSION_H_
|
||||
@@ -1,22 +0,0 @@
|
||||
// Copyright (c) 2019 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef ATOM_COMMON_NATIVE_MATE_CONVERTERS_MESSAGE_BOX_CONVERTER_H_
|
||||
#define ATOM_COMMON_NATIVE_MATE_CONVERTERS_MESSAGE_BOX_CONVERTER_H_
|
||||
|
||||
#include "atom/browser/ui/message_box.h"
|
||||
#include "native_mate/converter.h"
|
||||
|
||||
namespace mate {
|
||||
|
||||
template <>
|
||||
struct Converter<atom::MessageBoxSettings> {
|
||||
static bool FromV8(v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> val,
|
||||
atom::MessageBoxSettings* out);
|
||||
};
|
||||
|
||||
} // namespace mate
|
||||
|
||||
#endif // ATOM_COMMON_NATIVE_MATE_CONVERTERS_MESSAGE_BOX_CONVERTER_H_
|
||||
16
build/generate-template.py
Normal file
16
build/generate-template.py
Normal file
@@ -0,0 +1,16 @@
|
||||
import json
|
||||
import sys
|
||||
from string import Template
|
||||
|
||||
inpath = sys.argv[1]
|
||||
outpath = sys.argv[2]
|
||||
argpaths = sys.argv[3:]
|
||||
|
||||
with open(inpath, 'r') as infile, open(outpath, 'w') as outfile:
|
||||
data = {}
|
||||
for argpath in argpaths:
|
||||
with open(argpath, 'r') as argfile:
|
||||
data.update(json.load(argfile))
|
||||
|
||||
s = Template(infile.read()).substitute(data)
|
||||
outfile.write(s)
|
||||
39
build/templated_file.gni
Normal file
39
build/templated_file.gni
Normal file
@@ -0,0 +1,39 @@
|
||||
template("templated_file") {
|
||||
assert(defined(invoker.template), "Need template file to run")
|
||||
assert(defined(invoker.output), "Need output file to run")
|
||||
|
||||
if (defined(invoker.values)) {
|
||||
args_path = "$target_gen_dir/$target_name.args"
|
||||
write_file(args_path, invoker.values, "json")
|
||||
}
|
||||
|
||||
action(target_name) {
|
||||
forward_variables_from(invoker,
|
||||
[
|
||||
"deps",
|
||||
"public_deps",
|
||||
"inputs",
|
||||
"outputs",
|
||||
])
|
||||
inputs = [
|
||||
invoker.template,
|
||||
]
|
||||
outputs = [
|
||||
invoker.output,
|
||||
]
|
||||
script = "//electron/build/generate-template.py"
|
||||
args = [
|
||||
rebase_path(invoker.template),
|
||||
rebase_path(invoker.output),
|
||||
]
|
||||
|
||||
if (defined(invoker.values)) {
|
||||
args += rebase_path(args_path)
|
||||
}
|
||||
|
||||
if (defined(invoker.args_files)) {
|
||||
args += rebase_path(invoker.args_files)
|
||||
inputs += invoker.args_files
|
||||
}
|
||||
}
|
||||
}
|
||||
23
build/templates/electron_version.tmpl
Normal file
23
build/templates/electron_version.tmpl
Normal file
@@ -0,0 +1,23 @@
|
||||
// Copyright (c) 2019 Slack Technologies, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef ELECTRON_ELECTRON_VERSION_H
|
||||
#define ELECTRON_ELECTRON_VERSION_H
|
||||
|
||||
#define ELECTRON_MAJOR_VERSION $major
|
||||
#define ELECTRON_MINOR_VERSION $minor
|
||||
#define ELECTRON_PATCH_VERSION $patch
|
||||
#if $has_prerelease
|
||||
#define ELECTRON_PRE_RELEASE_VERSION -$prerelease
|
||||
#endif
|
||||
|
||||
#ifndef ELECTRON_PRE_RELEASE_VERSION
|
||||
#define ELECTRON_VERSION_STRING "$major.$minor.$patch"
|
||||
#else
|
||||
#define ELECTRON_VERSION_STRING "$major.$minor.$patch-$prerelease"
|
||||
#endif
|
||||
|
||||
#define ELECTRON_VERSION "v" ELECTRON_VERSION_STRING
|
||||
|
||||
#endif // ELECTRON_ELECTRON_VERSION_H
|
||||
@@ -55,8 +55,8 @@
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include "atom/browser/browser.h"
|
||||
#include "atom/common/atom_command_line.h"
|
||||
#include "shell/browser/browser.h"
|
||||
#include "shell/common/atom_command_line.h"
|
||||
|
||||
#include "base/base_paths.h"
|
||||
#include "base/bind.h"
|
||||
@@ -827,7 +827,7 @@ ProcessSingleton::NotifyResult ProcessSingleton::NotifyOtherProcessWithTimeout(
|
||||
return PROCESS_NONE;
|
||||
to_send.append(current_dir.value());
|
||||
|
||||
const std::vector<std::string>& argv = atom::AtomCommandLine::argv();
|
||||
const std::vector<std::string>& argv = electron::AtomCommandLine::argv();
|
||||
for (std::vector<std::string>::const_iterator it = argv.begin();
|
||||
it != argv.end(); ++it) {
|
||||
to_send.push_back(kTokenDelimiter);
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
|
||||
#include "chrome/browser/ui/views/frame/global_menu_bar_registrar_x11.h"
|
||||
|
||||
#include "atom/browser/ui/views/global_menu_bar_x11.h"
|
||||
#include "base/bind.h"
|
||||
#include "base/debug/leak_annotations.h"
|
||||
#include "base/logging.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "shell/browser/ui/views/global_menu_bar_x11.h"
|
||||
|
||||
using content::BrowserThread;
|
||||
|
||||
@@ -65,7 +65,7 @@ GlobalMenuBarRegistrarX11::~GlobalMenuBarRegistrarX11() {
|
||||
|
||||
void GlobalMenuBarRegistrarX11::RegisterXID(unsigned long xid) {
|
||||
DCHECK(registrar_proxy_);
|
||||
std::string path = atom::GlobalMenuBarX11::GetPathForWindow(xid);
|
||||
std::string path = electron::GlobalMenuBarX11::GetPathForWindow(xid);
|
||||
|
||||
ANNOTATE_SCOPED_MEMORY_LEAK; // http://crbug.com/314087
|
||||
// TODO(erg): The mozilla implementation goes to a lot of callback trouble
|
||||
@@ -82,7 +82,7 @@ void GlobalMenuBarRegistrarX11::RegisterXID(unsigned long xid) {
|
||||
|
||||
void GlobalMenuBarRegistrarX11::UnregisterXID(unsigned long xid) {
|
||||
DCHECK(registrar_proxy_);
|
||||
std::string path = atom::GlobalMenuBarX11::GetPathForWindow(xid);
|
||||
std::string path = electron::GlobalMenuBarX11::GetPathForWindow(xid);
|
||||
|
||||
ANNOTATE_SCOPED_MEMORY_LEAK; // http://crbug.com/314087
|
||||
// TODO(erg): The mozilla implementation goes to a lot of callback trouble
|
||||
|
||||
@@ -85,6 +85,7 @@ function loadApplicationPackage (packagePath: string) {
|
||||
// Override app name and version.
|
||||
packagePath = path.resolve(packagePath)
|
||||
const packageJsonPath = path.join(packagePath, 'package.json')
|
||||
let appPath
|
||||
if (fs.existsSync(packageJsonPath)) {
|
||||
let packageJson
|
||||
try {
|
||||
@@ -102,11 +103,12 @@ function loadApplicationPackage (packagePath: string) {
|
||||
} else if (packageJson.name) {
|
||||
app.name = packageJson.name
|
||||
}
|
||||
app._setDefaultAppPaths(packagePath)
|
||||
appPath = packagePath
|
||||
}
|
||||
|
||||
try {
|
||||
Module._resolveFilename(packagePath, module, true)
|
||||
const filePath = Module._resolveFilename(packagePath, module, true)
|
||||
app._setDefaultAppPaths(appPath || path.dirname(filePath))
|
||||
} catch (e) {
|
||||
showErrorMessage(`Unable to find Electron app at ${packagePath}\n\n${e.message}`)
|
||||
return
|
||||
|
||||
@@ -122,7 +122,7 @@ Returns:
|
||||
* `url` String
|
||||
|
||||
Emitted when the user wants to open a URL with the application. Your application's
|
||||
`Info.plist` file must define the url scheme within the `CFBundleURLTypes` key, and
|
||||
`Info.plist` file must define the URL scheme within the `CFBundleURLTypes` key, and
|
||||
set `NSPrincipalClass` to `AtomApplication`.
|
||||
|
||||
You should call `event.preventDefault()` if you want to handle this event.
|
||||
@@ -354,7 +354,7 @@ Returns:
|
||||
* `event` Event
|
||||
* `killed` Boolean
|
||||
|
||||
Emitted when the gpu process crashes or is killed.
|
||||
Emitted when the GPU process crashes or is killed.
|
||||
|
||||
### Event: 'renderer-process-crashed'
|
||||
|
||||
@@ -582,7 +582,7 @@ them.
|
||||
|
||||
Sets or creates a directory your app's logs which can then be manipulated with `app.getPath()` or `app.setPath(pathName, newPath)`.
|
||||
|
||||
On _macOS_, this directory will be set by deafault to `/Library/Logs/YourAppName`, and on _Linux_ and _Windows_ it will be placed inside your `userData` directory.
|
||||
On _macOS_, this directory will be set by default to `/Library/Logs/YourAppName`, and on _Linux_ and _Windows_ it will be placed inside your `userData` directory.
|
||||
|
||||
### `app.getAppPath()`
|
||||
|
||||
@@ -662,7 +662,7 @@ executable is returned.
|
||||
Returns `String` - The current application's name, which is the name in the application's
|
||||
`package.json` file.
|
||||
|
||||
Usually the `name` field of `package.json` is a short lowercased name, according
|
||||
Usually the `name` field of `package.json` is a short lowercase name, according
|
||||
to the npm modules spec. You should usually also specify a `productName`
|
||||
field, which is your application's full capitalized name, and which will be
|
||||
preferred over `name` by Electron.
|
||||
@@ -772,7 +772,7 @@ The API uses the Windows Registry and LSCopyDefaultHandlerForURLScheme internall
|
||||
|
||||
* `tasks` [Task[]](structures/task.md) - Array of `Task` objects
|
||||
|
||||
Adds `tasks` to the [Tasks][tasks] category of the JumpList on Windows.
|
||||
Adds `tasks` to the [Tasks][tasks] category of the Jump List on Windows.
|
||||
|
||||
`tasks` is an array of [`Task`](structures/task.md) objects.
|
||||
|
||||
@@ -1013,7 +1013,7 @@ This method can only be called before app is ready.
|
||||
|
||||
### `app.getAppMetrics()`
|
||||
|
||||
Returns [`ProcessMetric[]`](structures/process-metric.md): Array of `ProcessMetric` objects that correspond to memory and cpu usage statistics of all the processes associated with the app.
|
||||
Returns [`ProcessMetric[]`](structures/process-metric.md): Array of `ProcessMetric` objects that correspond to memory and CPU usage statistics of all the processes associated with the app.
|
||||
|
||||
### `app.getGPUFeatureStatus()`
|
||||
|
||||
@@ -1178,10 +1178,11 @@ Show the app's about panel options. These options can be overridden with `app.se
|
||||
* `applicationName` String (optional) - The app's name.
|
||||
* `applicationVersion` String (optional) - The app's version.
|
||||
* `copyright` String (optional) - Copyright information.
|
||||
* `version` String (optional) - The app's build version number. _macOS_
|
||||
* `credits` String (optional) - Credit information. _macOS_
|
||||
* `website` String (optional) - The app's website. _Linux_
|
||||
* `iconPath` String (optional) - Path to the app's icon. _Linux_
|
||||
* `version` String (optional) - The app's build version number.
|
||||
* `credits` String (optional) _macOS_ - Credit information.
|
||||
* `authors` String[] (optional) _Linux_ - List of app authors.
|
||||
* `website` String (optional) _Linux_ - The app's website.
|
||||
* `iconPath` String (optional) _Linux_ - Path to the app's icon. Will be shown as 64x64 pixels while retaining aspect ratio.
|
||||
|
||||
Set the about panel options. This will override the values defined in the app's
|
||||
`.plist` file on MacOS. See the [Apple docs][about-panel-options] for more details. On Linux, values must be set in order to be shown; there are no defaults.
|
||||
@@ -1294,7 +1295,7 @@ A `Boolean` property that returns `true` if the app is packaged, `false` otherw
|
||||
|
||||
A `String` property that indicates the current application's name, which is the name in the application's `package.json` file.
|
||||
|
||||
Usually the `name` field of `package.json` is a short lowercased name, according
|
||||
Usually the `name` field of `package.json` is a short lowercase name, according
|
||||
to the npm modules spec. You should usually also specify a `productName`
|
||||
field, which is your application's full capitalized name, and which will be
|
||||
preferred over `name` by Electron.
|
||||
|
||||
61
docs/api/breaking-changes-ns.md
Normal file
61
docs/api/breaking-changes-ns.md
Normal file
@@ -0,0 +1,61 @@
|
||||
# Breaking changes (NetworkService) (Draft)
|
||||
|
||||
This document describes changes to Electron APIs after migrating network code
|
||||
to NetworkService API.
|
||||
|
||||
We don't currently have an estimate of when we will enable `NetworkService` by
|
||||
default in Electron, but as Chromium is already removing non-`NetworkService`
|
||||
code, we might switch before Electron 10.
|
||||
|
||||
The content of this document should be moved to `breaking-changes.md` once we have
|
||||
determined when to enable `NetworkService` in Electron.
|
||||
|
||||
## Planned Breaking API Changes
|
||||
|
||||
### `protocol.unregisterProtocol`
|
||||
### `protocol.uninterceptProtocol`
|
||||
|
||||
The APIs are now synchronous and the optional callback is no longer needed.
|
||||
|
||||
```javascript
|
||||
// Deprecated
|
||||
protocol.unregisterProtocol(scheme, () => { /* ... */ })
|
||||
// Replace with
|
||||
protocol.unregisterProtocol(scheme)
|
||||
```
|
||||
|
||||
### `protocol.registerFileProtocol`
|
||||
### `protocol.registerBufferProtocol`
|
||||
### `protocol.registerStringProtocol`
|
||||
### `protocol.registerHttpProtocol`
|
||||
### `protocol.registerStreamProtocol`
|
||||
### `protocol.interceptFileProtocol`
|
||||
### `protocol.interceptStringProtocol`
|
||||
### `protocol.interceptBufferProtocol`
|
||||
### `protocol.interceptHttpProtocol`
|
||||
### `protocol.interceptStreamProtocol`
|
||||
|
||||
The APIs are now synchronous and the optional callback is no longer needed.
|
||||
|
||||
```javascript
|
||||
// Deprecated
|
||||
protocol.registerFileProtocol(scheme, handler, () => { /* ... */ })
|
||||
// Replace with
|
||||
protocol.registerFileProtocol(scheme, handler)
|
||||
```
|
||||
|
||||
The registered or intercepted protocol does not have effect on current page
|
||||
until navigation happens.
|
||||
|
||||
### `protocol.isProtocolHandled`
|
||||
|
||||
This API is deprecated and users should use `protocol.isProtocolRegistered`
|
||||
and `protocol.isProtocolIntercepted` instead.
|
||||
|
||||
```javascript
|
||||
// Deprecated
|
||||
protocol.isProtocolHandled(scheme).then(() => { /* ... */ })
|
||||
// Replace with
|
||||
const isRegistered = protocol.isProtocolRegistered(scheme)
|
||||
const isIntercepted = protocol.isProtocolIntercepted(scheme)
|
||||
```
|
||||
@@ -12,7 +12,7 @@ The `FIXME` string is used in code comments to denote things that should be fixe
|
||||
|
||||
This is the URL specified as `disturl` in a `.npmrc` file or as the `--dist-url`
|
||||
command line flag when building native Node modules. Both will be supported for
|
||||
the forseeable future but it is reccomened that you switch.
|
||||
the foreseeable future but it is recommended that you switch.
|
||||
|
||||
Deprecated: https://atom.io/download/electron
|
||||
|
||||
@@ -148,10 +148,6 @@ app.enableMixedSandbox()
|
||||
|
||||
Mixed-sandbox mode is now enabled by default.
|
||||
|
||||
### Preload scripts outside of app path are not allowed
|
||||
|
||||
For security reasons, preload scripts can only be loaded from a subpath of the [app path](app.md#appgetapppath).
|
||||
|
||||
## Planned Breaking API Changes (5.0)
|
||||
|
||||
### `new BrowserWindow({ webPreferences })`
|
||||
@@ -176,7 +172,7 @@ const w = new BrowserWindow({
|
||||
|
||||
### `nativeWindowOpen`
|
||||
|
||||
Child windows opened with the `nativeWindowOpen` option will always have Node.js integration disabled.
|
||||
Child windows opened with the `nativeWindowOpen` option will always have Node.js integration disabled, unless `nodeIntegrationInSubFrames` is `true.
|
||||
|
||||
### Privileged Schemes Registration
|
||||
|
||||
@@ -528,7 +524,7 @@ to clarify to users which ARM version it supports, and to disambiguate it from
|
||||
future armv6l and arm64 assets that may be produced.
|
||||
|
||||
The file _without the prefix_ is still being published to avoid breaking any
|
||||
setups that may be consuming it. Starting at 2.0, the un-prefixed file will
|
||||
setups that may be consuming it. Starting at 2.0, the unprefixed file will
|
||||
no longer be published.
|
||||
|
||||
For details, see
|
||||
|
||||
@@ -84,9 +84,9 @@ Returns `Boolean` - Whether the view is destroyed.
|
||||
* `height` Boolean - If `true`, the view's height will grow and shrink
|
||||
together with the window. `false` by default.
|
||||
* `horizontal` Boolean - If `true`, the view's x position and width will grow
|
||||
and shrink proportionly with the window. `false` by default.
|
||||
and shrink proportionally with the window. `false` by default.
|
||||
* `vertical` Boolean - If `true`, the view's y position and height will grow
|
||||
and shrink proportinaly with the window. `false` by default.
|
||||
and shrink proportionally with the window. `false` by default.
|
||||
|
||||
#### `view.setBounds(bounds)` _Experimental_
|
||||
|
||||
|
||||
@@ -256,7 +256,7 @@ It creates a new `BrowserWindow` with native properties as set by the `options`.
|
||||
enabled in web workers. Default is `false`. More about this can be found
|
||||
in [Multithreading](../tutorial/multithreading.md).
|
||||
* `nodeIntegrationInSubFrames` Boolean (optional) - Experimental option for
|
||||
enabling NodeJS support in sub-frames such as iframes. All your preloads will load for
|
||||
enabling Node.js support in sub-frames such as iframes and child windows. All your preloads will load for
|
||||
every iframe, you can use `process.isMainFrame` to determine if you are
|
||||
in the main frame or not.
|
||||
* `preload` String (optional) - Specifies a script that will be loaded before other
|
||||
@@ -266,8 +266,6 @@ It creates a new `BrowserWindow` with native properties as set by the `options`.
|
||||
When node integration is turned off, the preload script can reintroduce
|
||||
Node global symbols back to the global scope. See example
|
||||
[here](process.md#event-loaded).
|
||||
**Note:** For security reasons, preload scripts can only be loaded from
|
||||
a subpath of the [app path](app.md#appgetapppath).
|
||||
* `sandbox` Boolean (optional) - If set, this will sandbox the renderer
|
||||
associated with the window, making it compatible with the Chromium
|
||||
OS-level sandbox and disabling the Node.js engine. This is not the same as
|
||||
@@ -355,7 +353,7 @@ It creates a new `BrowserWindow` with native properties as set by the `options`.
|
||||
Console tab.
|
||||
* `nativeWindowOpen` Boolean (optional) - Whether to use native
|
||||
`window.open()`. Defaults to `false`. Child windows will always have node
|
||||
integration disabled. **Note:** This option is currently
|
||||
integration disabled unless `nodeIntegrationInSubFrames` is true. **Note:** This option is currently
|
||||
experimental.
|
||||
* `webviewTag` Boolean (optional) - Whether to enable the [`<webview>` tag](webview-tag.md).
|
||||
Defaults to `false`. **Note:** The
|
||||
@@ -420,7 +418,7 @@ Returns:
|
||||
|
||||
Emitted when the document changed its title, calling `event.preventDefault()`
|
||||
will prevent the native window's title from changing.
|
||||
`explicitSet` is false when title is synthesized from file url.
|
||||
`explicitSet` is false when title is synthesized from file URL.
|
||||
|
||||
#### Event: 'close'
|
||||
|
||||
@@ -1259,11 +1257,11 @@ Captures a snapshot of the page within `rect`. Omitting `rect` will capture the
|
||||
|
||||
* `url` String
|
||||
* `options` Object (optional)
|
||||
* `httpReferrer` (String | [Referrer](structures/referrer.md)) (optional) - An HTTP Referrer url.
|
||||
* `httpReferrer` (String | [Referrer](structures/referrer.md)) (optional) - An HTTP Referrer URL.
|
||||
* `userAgent` String (optional) - A user agent originating the request.
|
||||
* `extraHeaders` String (optional) - Extra headers separated by "\n"
|
||||
* `postData` ([UploadRawData[]](structures/upload-raw-data.md) | [UploadFile[]](structures/upload-file.md) | [UploadBlob[]](structures/upload-blob.md)) (optional)
|
||||
* `baseURLForDataURL` String (optional) - Base url (with trailing path separator) for files to be loaded by the data url. This is needed only if the specified `url` is a data url and needs to load other files.
|
||||
* `baseURLForDataURL` String (optional) - Base URL (with trailing path separator) for files to be loaded by the data URL. This is needed only if the specified `url` is a data URL and needs to load other files.
|
||||
|
||||
Returns `Promise<void>` - the promise will resolve when the page has finished loading
|
||||
(see [`did-finish-load`](web-contents.md#event-did-finish-load)), and rejects
|
||||
|
||||
@@ -46,14 +46,14 @@ Forces the maximum disk space to be used by the disk cache, in bytes.
|
||||
|
||||
## --js-flags=`flags`
|
||||
|
||||
Specifies the flags passed to the Node JS engine. It has to be passed when starting
|
||||
Specifies the flags passed to the Node.js engine. It has to be passed when starting
|
||||
Electron if you want to enable the `flags` in the main process.
|
||||
|
||||
```sh
|
||||
$ electron --js-flags="--harmony_proxies --harmony_collections" your-app
|
||||
```
|
||||
|
||||
See the [Node documentation][node-cli] or run `node --help` in your terminal for a list of available flags. Additionally, run `node --v8-options` to see a list of flags that specifically refer to Node's V8 JavaScript engine.
|
||||
See the [Node.js documentation][node-cli] or run `node --help` in your terminal for a list of available flags. Additionally, run `node --v8-options` to see a list of flags that specifically refer to Node.js's V8 JavaScript engine.
|
||||
|
||||
## --proxy-server=`address:port`
|
||||
|
||||
@@ -122,12 +122,12 @@ For example:
|
||||
```
|
||||
|
||||
then any `url` ending with `example.com`, `foobar.com`, `baz` will be considered
|
||||
for integrated authentication. Without `*` prefix the url has to match exactly.
|
||||
for integrated authentication. Without `*` prefix the URL has to match exactly.
|
||||
|
||||
## --auth-negotiate-delegate-whitelist=`url`
|
||||
|
||||
A comma-separated list of servers for which delegation of user credentials is required.
|
||||
Without `*` prefix the url has to match exactly.
|
||||
Without `*` prefix the URL has to match exactly.
|
||||
|
||||
## --ignore-certificate-errors
|
||||
|
||||
|
||||
@@ -160,7 +160,7 @@ internally buffered inside Electron process memory.
|
||||
* `name` String - An extra HTTP header name.
|
||||
* `value` Object - An extra HTTP header value.
|
||||
|
||||
Adds an extra HTTP header. The header name will issued as it is without
|
||||
Adds an extra HTTP header. The header name will be issued as-is without
|
||||
lowercasing. It can be called only before first write. Calling this method after
|
||||
the first write will throw an error. If the passed value is not a `String`, its
|
||||
`toString()` method will be called to obtain the final value.
|
||||
|
||||
@@ -172,7 +172,7 @@ Writes the `buffer` into the clipboard as `format`.
|
||||
* `html` String (optional)
|
||||
* `image` [NativeImage](native-image.md) (optional)
|
||||
* `rtf` String (optional)
|
||||
* `bookmark` String (optional) - The title of the url at `text`.
|
||||
* `bookmark` String (optional) - The title of the URL at `text`.
|
||||
* `type` String (optional) - Can be `selection` or `clipboard`. `selection` is only available on Linux.
|
||||
|
||||
```javascript
|
||||
|
||||
@@ -68,7 +68,7 @@ The following methods are available on instances of `Cookies`:
|
||||
|
||||
* `filter` Object
|
||||
* `url` String (optional) - Retrieves cookies which are associated with
|
||||
`url`. Empty implies retrieving cookies of all urls.
|
||||
`url`. Empty implies retrieving cookies of all URLs.
|
||||
* `name` String (optional) - Filters cookies by name.
|
||||
* `domain` String (optional) - Retrieves cookies whose domains match or are
|
||||
subdomains of `domains`.
|
||||
@@ -84,7 +84,7 @@ the response.
|
||||
#### `cookies.set(details)`
|
||||
|
||||
* `details` Object
|
||||
* `url` String - The url to associate the cookie with. The promise will be rejected if the url is invalid.
|
||||
* `url` String - The URL to associate the cookie with. The promise will be rejected if the URL is invalid.
|
||||
* `name` String (optional) - The name of the cookie. Empty by default if omitted.
|
||||
* `value` String (optional) - The value of the cookie. Empty by default if omitted.
|
||||
* `domain` String (optional) - The domain of the cookie; this will be normalized with a preceding dot so that it's also valid for subdomains. Empty by default if omitted.
|
||||
|
||||
@@ -51,7 +51,7 @@ The `crashReporter` module has the following methods:
|
||||
* `extra` Object (optional) - An object you can define that will be sent along with the
|
||||
report. Only string properties are sent correctly. Nested objects are not
|
||||
supported. When using Windows, the property names and values must be fewer than 64 characters.
|
||||
* `crashesDirectory` String (optional) - Directory to store the crashreports temporarily (only used when the crash reporter is started via `process.crashReporter.start`).
|
||||
* `crashesDirectory` String (optional) - Directory to store the crash reports temporarily (only used when the crash reporter is started via `process.crashReporter.start`).
|
||||
|
||||
You are required to call this method before using any other `crashReporter` APIs
|
||||
and in each process (main/renderer) from which you want to collect crash reports.
|
||||
|
||||
@@ -80,7 +80,9 @@ The `downloadItem` object has the following methods:
|
||||
|
||||
The API is only available in session's `will-download` callback function.
|
||||
If user doesn't set the save path via the API, Electron will use the original
|
||||
routine to determine the save path(Usually prompts a save dialog).
|
||||
routine to determine the save path; this usually prompts a save dialog.
|
||||
|
||||
**[Deprecated](modernization/property-updates.md): use the `savePath` property instead.**
|
||||
|
||||
#### `downloadItem.getSavePath()`
|
||||
|
||||
@@ -88,6 +90,8 @@ Returns `String` - The save path of the download item. This will be either the p
|
||||
set via `downloadItem.setSavePath(path)` or the path selected from the shown
|
||||
save dialog.
|
||||
|
||||
**[Deprecated](modernization/property-updates.md): use the `savePath` property instead.**
|
||||
|
||||
#### `downloadItem.setSaveDialogOptions(options)`
|
||||
|
||||
* `options` SaveDialogOptions - Set the save file dialog options. This object has the same
|
||||
@@ -125,7 +129,7 @@ Cancels the download operation.
|
||||
|
||||
#### `downloadItem.getURL()`
|
||||
|
||||
Returns `String` - The origin url where the item is downloaded from.
|
||||
Returns `String` - The origin URL where the item is downloaded from.
|
||||
|
||||
#### `downloadItem.getMimeType()`
|
||||
|
||||
@@ -167,7 +171,7 @@ Returns `String` - The current state. Can be `progressing`, `completed`, `cancel
|
||||
|
||||
#### `downloadItem.getURLChain()`
|
||||
|
||||
Returns `String[]` - The complete url chain of the item including any redirects.
|
||||
Returns `String[]` - The complete URL chain of the item including any redirects.
|
||||
|
||||
#### `downloadItem.getLastModifiedTime()`
|
||||
|
||||
@@ -181,3 +185,13 @@ Returns `String` - ETag header value.
|
||||
|
||||
Returns `Double` - Number of seconds since the UNIX epoch when the download was
|
||||
started.
|
||||
|
||||
### Instance Properties
|
||||
|
||||
#### `downloadItem.savePath`
|
||||
|
||||
A `String` property that determines the save file path of the download item.
|
||||
|
||||
The property is only available in session's `will-download` callback function.
|
||||
If user doesn't set the save path via the property, Electron will use the original
|
||||
routine to determine the save path; this usually prompts a save dialog.
|
||||
|
||||
@@ -24,11 +24,11 @@ See [`Menu`](menu.md) for examples.
|
||||
* `icon` ([NativeImage](native-image.md) | String) (optional)
|
||||
* `enabled` Boolean (optional) - If false, the menu item will be greyed out and
|
||||
unclickable.
|
||||
* `acceleratorWorksWhenHidden` Boolean (optional) - default is `true`, and when `false` will prevent the accelerator from triggering the item if the item is not visible`. _macOS_
|
||||
* `acceleratorWorksWhenHidden` Boolean (optional) _macOS_ - default is `true`, and when `false` will prevent the accelerator from triggering the item if the item is not visible`.
|
||||
* `visible` Boolean (optional) - If false, the menu item will be entirely hidden.
|
||||
* `checked` Boolean (optional) - Should only be specified for `checkbox` or `radio` type
|
||||
menu items.
|
||||
* `registerAccelerator` Boolean (optional) - If false, the accelerator won't be registered
|
||||
* `registerAccelerator` Boolean (optional) _Linux_ _Windows_ - If false, the accelerator won't be registered
|
||||
with the system, but it will still be displayed. Defaults to true.
|
||||
* `submenu` (MenuItemConstructorOptions[] | [Menu](menu.md)) (optional) - Should be specified
|
||||
for `submenu` type menu items. If `submenu` is specified, the `type: 'submenu'` can be omitted.
|
||||
|
||||
@@ -20,9 +20,6 @@ The Electron team is currently undergoing an initiative to convert separate gett
|
||||
* `visibleOnAllWorkspaces`
|
||||
* `crashReporter` module
|
||||
* `uploadToServer`
|
||||
* `DownloadItem` class
|
||||
* `savePath`
|
||||
* `paused`
|
||||
* `Session` module
|
||||
* `preloads`
|
||||
* `webContents` module
|
||||
@@ -47,6 +44,8 @@ The Electron team is currently undergoing an initiative to convert separate gett
|
||||
* `applicationMenu`
|
||||
* `badgeCount`
|
||||
* `name`
|
||||
* `DownloadItem` class
|
||||
* `savePath`
|
||||
* `BrowserWindow` module
|
||||
* `autohideMenuBar`
|
||||
* `resizable`
|
||||
|
||||
309
docs/api/protocol-ns.md
Normal file
309
docs/api/protocol-ns.md
Normal file
@@ -0,0 +1,309 @@
|
||||
# protocol (NetworkService) (Draft)
|
||||
|
||||
This document describes the new protocol APIs based on the [NetworkService](https://www.chromium.org/servicification).
|
||||
|
||||
We don't currently have an estimate of when we will enable the `NetworkService` by
|
||||
default in Electron, but as Chromium is already removing non-`NetworkService`
|
||||
code, we will probably switch before Electron 10.
|
||||
|
||||
The content of this document should be moved to `protocol.md` after we have
|
||||
enabled the `NetworkService` by default in Electron.
|
||||
|
||||
> Register a custom protocol and intercept existing protocol requests.
|
||||
|
||||
Process: [Main](../glossary.md#main-process)
|
||||
|
||||
An example of implementing a protocol that has the same effect as the
|
||||
`file://` protocol:
|
||||
|
||||
```javascript
|
||||
const { app, protocol } = require('electron')
|
||||
const path = require('path')
|
||||
|
||||
app.on('ready', () => {
|
||||
protocol.registerFileProtocol('atom', (request, callback) => {
|
||||
const url = request.url.substr(7)
|
||||
callback({ path: path.normalize(`${__dirname}/${url}`) })
|
||||
})
|
||||
})
|
||||
```
|
||||
|
||||
**Note:** All methods unless specified can only be used after the `ready` event
|
||||
of the `app` module gets emitted.
|
||||
|
||||
## Using `protocol` with a custom `partition` or `session`
|
||||
|
||||
A protocol is registered to a specific Electron [`session`](./session.md)
|
||||
object. If you don't specify a session, then your `protocol` will be applied to
|
||||
the default session that Electron uses. However, if you define a `partition` or
|
||||
`session` on your `browserWindow`'s `webPreferences`, then that window will use
|
||||
a different session and your custom protocol will not work if you just use
|
||||
`electron.protocol.XXX`.
|
||||
|
||||
To have your custom protocol work in combination with a custom session, you need
|
||||
to register it to that session explicitly.
|
||||
|
||||
```javascript
|
||||
const { session, app, protocol } = require('electron')
|
||||
const path = require('path')
|
||||
|
||||
app.on('ready', () => {
|
||||
const partition = 'persist:example'
|
||||
const ses = session.fromPartition(partition)
|
||||
|
||||
ses.protocol.registerFileProtocol('atom', (request, callback) => {
|
||||
const url = request.url.substr(7)
|
||||
callback({ path: path.normalize(`${__dirname}/${url}`) })
|
||||
})
|
||||
|
||||
mainWindow = new BrowserWindow({ webPreferences: { partition } })
|
||||
})
|
||||
```
|
||||
|
||||
## Methods
|
||||
|
||||
The `protocol` module has the following methods:
|
||||
|
||||
### `protocol.registerSchemesAsPrivileged(customSchemes)`
|
||||
|
||||
* `customSchemes` [CustomScheme[]](structures/custom-scheme.md)
|
||||
|
||||
**Note:** This method can only be used before the `ready` event of the `app`
|
||||
module gets emitted and can be called only once.
|
||||
|
||||
Registers the `scheme` as standard, secure, bypasses content security policy for
|
||||
resources, allows registering ServiceWorker and supports fetch API. Specify a
|
||||
privilege with the value of `true` to enable the capability.
|
||||
|
||||
An example of registering a privileged scheme, that bypasses Content Security
|
||||
Policy:
|
||||
|
||||
```javascript
|
||||
const { protocol } = require('electron')
|
||||
protocol.registerSchemesAsPrivileged([
|
||||
{ scheme: 'foo', privileges: { bypassCSP: true } }
|
||||
])
|
||||
```
|
||||
|
||||
A standard scheme adheres to what RFC 3986 calls [generic URI
|
||||
syntax](https://tools.ietf.org/html/rfc3986#section-3). For example `http` and
|
||||
`https` are standard schemes, while `file` is not.
|
||||
|
||||
Registering a scheme as standard allows relative and absolute resources to
|
||||
be resolved correctly when served. Otherwise the scheme will behave like the
|
||||
`file` protocol, but without the ability to resolve relative URLs.
|
||||
|
||||
For example when you load following page with custom protocol without
|
||||
registering it as standard scheme, the image will not be loaded because
|
||||
non-standard schemes can not recognize relative URLs:
|
||||
|
||||
```html
|
||||
<body>
|
||||
<img src='test.png'>
|
||||
</body>
|
||||
```
|
||||
|
||||
Registering a scheme as standard will allow access to files through the
|
||||
[FileSystem API][file-system-api]. Otherwise the renderer will throw a security
|
||||
error for the scheme.
|
||||
|
||||
By default web storage apis (localStorage, sessionStorage, webSQL, indexedDB,
|
||||
cookies) are disabled for non standard schemes. So in general if you want to
|
||||
register a custom protocol to replace the `http` protocol, you have to register
|
||||
it as a standard scheme.
|
||||
|
||||
### `protocol.registerFileProtocol(scheme, handler)`
|
||||
|
||||
* `scheme` String
|
||||
* `handler` Function
|
||||
* `request` ProtocolRequest
|
||||
* `callback` Function
|
||||
* `response` (String | [ProtocolResponse](structures/protocol-response.md))
|
||||
|
||||
Registers a protocol of `scheme` that will send a file as the response. The
|
||||
`handler` will be called with `request` and `callback` where `request` is
|
||||
an incoming request for the `scheme`.
|
||||
|
||||
To handle the `request`, the `callback` should be called with either the file's
|
||||
path or an object that has a `path` property, e.g. `callback(filePath)` or
|
||||
`callback({ path: filePath })`. The `filePath` must be an absolute path.
|
||||
|
||||
By default the `scheme` is treated like `http:`, which is parsed differently
|
||||
from protocols that follow the "generic URI syntax" like `file:`.
|
||||
|
||||
### `protocol.registerBufferProtocol(scheme, handler)`
|
||||
|
||||
* `scheme` String
|
||||
* `handler` Function
|
||||
* `request` ProtocolRequest
|
||||
* `callback` Function
|
||||
* `response` (Buffer | [ProtocolResponse](structures/protocol-response.md))
|
||||
|
||||
Registers a protocol of `scheme` that will send a `Buffer` as a response.
|
||||
|
||||
The usage is the same with `registerFileProtocol`, except that the `callback`
|
||||
should be called with either a `Buffer` object or an object that has the `data`
|
||||
property.
|
||||
|
||||
Example:
|
||||
|
||||
```javascript
|
||||
protocol.registerBufferProtocol('atom', (request, callback) => {
|
||||
callback({ mimeType: 'text/html', data: Buffer.from('<h5>Response</h5>') })
|
||||
})
|
||||
```
|
||||
|
||||
### `protocol.registerStringProtocol(scheme, handler)`
|
||||
|
||||
* `scheme` String
|
||||
* `handler` Function
|
||||
* `request` ProtocolRequest
|
||||
* `callback` Function
|
||||
* `response` (String | [ProtocolResponse](structures/protocol-response.md))
|
||||
|
||||
Registers a protocol of `scheme` that will send a `String` as a response.
|
||||
|
||||
The usage is the same with `registerFileProtocol`, except that the `callback`
|
||||
should be called with either a `String` or an object that has the `data`
|
||||
property.
|
||||
|
||||
### `protocol.registerHttpProtocol(scheme, handler)`
|
||||
|
||||
* `scheme` String
|
||||
* `handler` Function
|
||||
* `request` ProtocolRequest
|
||||
* `callback` Function
|
||||
* `response` ProtocolResponse
|
||||
|
||||
Registers a protocol of `scheme` that will send an HTTP request as a response.
|
||||
|
||||
The usage is the same with `registerFileProtocol`, except that the `callback`
|
||||
should be called with an object that has the `url` property.
|
||||
|
||||
### `protocol.registerStreamProtocol(scheme, handler)`
|
||||
|
||||
* `scheme` String
|
||||
* `handler` Function
|
||||
* `request` ProtocolRequest
|
||||
* `callback` Function
|
||||
* `response` (ReadableStream | [ProtocolResponse](structures/protocol-response.md))
|
||||
|
||||
Registers a protocol of `scheme` that will send a stream as a response.
|
||||
|
||||
The usage is the same with `registerFileProtocol`, except that the
|
||||
`callback` should be called with either a [`ReadableStream`](https://nodejs.org/api/stream.html#stream_class_stream_readable) object or an object that
|
||||
has the `data` property.
|
||||
|
||||
Example:
|
||||
|
||||
```javascript
|
||||
const { protocol } = require('electron')
|
||||
const { PassThrough } = require('stream')
|
||||
|
||||
function createStream (text) {
|
||||
const rv = new PassThrough() // PassThrough is also a Readable stream
|
||||
rv.push(text)
|
||||
rv.push(null)
|
||||
return rv
|
||||
}
|
||||
|
||||
protocol.registerStreamProtocol('atom', (request, callback) => {
|
||||
callback({
|
||||
statusCode: 200,
|
||||
headers: {
|
||||
'content-type': 'text/html'
|
||||
},
|
||||
data: createStream('<h5>Response</h5>')
|
||||
})
|
||||
})
|
||||
```
|
||||
|
||||
It is possible to pass any object that implements the readable stream API (emits
|
||||
`data`/`end`/`error` events). For example, here's how a file could be returned:
|
||||
|
||||
```javascript
|
||||
protocol.registerStreamProtocol('atom', (request, callback) => {
|
||||
callback(fs.createReadStream('index.html'))
|
||||
})
|
||||
```
|
||||
|
||||
### `protocol.unregisterProtocol(scheme)`
|
||||
|
||||
* `scheme` String
|
||||
|
||||
Unregisters the custom protocol of `scheme`.
|
||||
|
||||
### `protocol.isProtocolRegistered(scheme)`
|
||||
|
||||
* `scheme` String
|
||||
|
||||
Returns `Boolean` - Whether `scheme` is already registered.
|
||||
|
||||
### `protocol.interceptFileProtocol(scheme, handler)`
|
||||
|
||||
* `scheme` String
|
||||
* `handler` Function
|
||||
* `request` ProtocolRequest
|
||||
* `callback` Function
|
||||
* `response` (String | [ProtocolResponse](structures/protocol-response.md))
|
||||
|
||||
Intercepts `scheme` protocol and uses `handler` as the protocol's new handler
|
||||
which sends a file as a response.
|
||||
|
||||
### `protocol.interceptStringProtocol(scheme, handler)`
|
||||
|
||||
* `scheme` String
|
||||
* `handler` Function
|
||||
* `request` ProtocolRequest
|
||||
* `callback` Function
|
||||
* `response` (String | [ProtocolResponse](structures/protocol-response.md))
|
||||
|
||||
Intercepts `scheme` protocol and uses `handler` as the protocol's new handler
|
||||
which sends a `String` as a response.
|
||||
|
||||
### `protocol.interceptBufferProtocol(scheme, handler)`
|
||||
|
||||
* `scheme` String
|
||||
* `handler` Function
|
||||
* `request` ProtocolRequest
|
||||
* `callback` Function
|
||||
* `response` (Buffer | [ProtocolResponse](structures/protocol-response.md))
|
||||
|
||||
Intercepts `scheme` protocol and uses `handler` as the protocol's new handler
|
||||
which sends a `Buffer` as a response.
|
||||
|
||||
### `protocol.interceptHttpProtocol(scheme, handler)`
|
||||
|
||||
* `scheme` String
|
||||
* `handler` Function
|
||||
* `request` ProtocolRequest
|
||||
* `callback` Function
|
||||
* `response` ProtocolResponse
|
||||
|
||||
Intercepts `scheme` protocol and uses `handler` as the protocol's new handler
|
||||
which sends a new HTTP request as a response.
|
||||
|
||||
### `protocol.interceptStreamProtocol(scheme, handler)`
|
||||
|
||||
* `scheme` String
|
||||
* `handler` Function
|
||||
* `request` ProtocolRequest
|
||||
* `callback` Function
|
||||
* `response` (ReadableStream | [ProtocolResponse](structures/protocol-response.md))
|
||||
|
||||
Same as `protocol.registerStreamProtocol`, except that it replaces an existing
|
||||
protocol handler.
|
||||
|
||||
### `protocol.uninterceptProtocol(scheme)`
|
||||
|
||||
* `scheme` String
|
||||
|
||||
Remove the interceptor installed for `scheme` and restore its original handler.
|
||||
|
||||
### `protocol.isProtocolIntercepted(scheme)`
|
||||
|
||||
* `scheme` String
|
||||
|
||||
Returns `Boolean` - Whether `scheme` is already intercepted.
|
||||
|
||||
[file-system-api]: https://developer.mozilla.org/en-US/docs/Web/API/LocalFileSystem
|
||||
@@ -131,11 +131,12 @@ protocol.registerSchemesAsPrivileged([
|
||||
* `handler` Function
|
||||
* `request` Object
|
||||
* `url` String
|
||||
* `headers` Record<String, String>
|
||||
* `referrer` String
|
||||
* `method` String
|
||||
* `uploadData` [UploadData[]](structures/upload-data.md)
|
||||
* `callback` Function
|
||||
* `filePath` String (optional)
|
||||
* `filePath` String | [FilePathWithHeaders](structures/file-path-with-headers.md) (optional)
|
||||
* `completion` Function (optional)
|
||||
* `error` Error
|
||||
|
||||
@@ -165,6 +166,7 @@ than protocols that follow the "generic URI syntax" like `file:`.
|
||||
* `handler` Function
|
||||
* `request` Object
|
||||
* `url` String
|
||||
* `headers` Record<String, String>
|
||||
* `referrer` String
|
||||
* `method` String
|
||||
* `uploadData` [UploadData[]](structures/upload-data.md)
|
||||
@@ -197,11 +199,12 @@ protocol.registerBufferProtocol('atom', (request, callback) => {
|
||||
* `handler` Function
|
||||
* `request` Object
|
||||
* `url` String
|
||||
* `headers` Record<String, String>
|
||||
* `referrer` String
|
||||
* `method` String
|
||||
* `uploadData` [UploadData[]](structures/upload-data.md)
|
||||
* `callback` Function
|
||||
* `data` String (optional)
|
||||
* `data` (String | [StringProtocolResponse](structures/string-protocol-response.md)) (optional)
|
||||
* `completion` Function (optional)
|
||||
* `error` Error
|
||||
|
||||
@@ -217,18 +220,16 @@ should be called with either a `String` or an object that has the `data`,
|
||||
* `handler` Function
|
||||
* `request` Object
|
||||
* `url` String
|
||||
* `headers` Object
|
||||
* `headers` Record<String, String>
|
||||
* `referrer` String
|
||||
* `method` String
|
||||
* `uploadData` [UploadData[]](structures/upload-data.md)
|
||||
* `callback` Function
|
||||
* `redirectRequest` Object
|
||||
* `url` String
|
||||
* `method` String
|
||||
* `method` String (optional)
|
||||
* `session` Object (optional)
|
||||
* `uploadData` Object (optional)
|
||||
* `contentType` String - MIME type of the content.
|
||||
* `data` String - Content to be sent.
|
||||
* `uploadData` [ProtocolResponseUploadData](structures/protocol-response-upload-data.md) (optional)
|
||||
* `completion` Function (optional)
|
||||
* `error` Error
|
||||
|
||||
@@ -249,7 +250,7 @@ For POST requests the `uploadData` object must be provided.
|
||||
* `handler` Function
|
||||
* `request` Object
|
||||
* `url` String
|
||||
* `headers` Object
|
||||
* `headers` Record<String, String>
|
||||
* `referrer` String
|
||||
* `method` String
|
||||
* `uploadData` [UploadData[]](structures/upload-data.md)
|
||||
@@ -325,6 +326,7 @@ already a handler for `scheme`.
|
||||
* `handler` Function
|
||||
* `request` Object
|
||||
* `url` String
|
||||
* `headers` Record<String, String>
|
||||
* `referrer` String
|
||||
* `method` String
|
||||
* `uploadData` [UploadData[]](structures/upload-data.md)
|
||||
@@ -342,11 +344,12 @@ which sends a file as a response.
|
||||
* `handler` Function
|
||||
* `request` Object
|
||||
* `url` String
|
||||
* `headers` Record<String, String>
|
||||
* `referrer` String
|
||||
* `method` String
|
||||
* `uploadData` [UploadData[]](structures/upload-data.md)
|
||||
* `callback` Function
|
||||
* `data` String (optional)
|
||||
* `data` (String | [StringProtocolResponse](structures/string-protocol-response.md)) (optional)
|
||||
* `completion` Function (optional)
|
||||
* `error` Error
|
||||
|
||||
@@ -359,6 +362,7 @@ which sends a `String` as a response.
|
||||
* `handler` Function
|
||||
* `request` Object
|
||||
* `url` String
|
||||
* `headers` Record<String, String>
|
||||
* `referrer` String
|
||||
* `method` String
|
||||
* `uploadData` [UploadData[]](structures/upload-data.md)
|
||||
@@ -376,15 +380,15 @@ which sends a `Buffer` as a response.
|
||||
* `handler` Function
|
||||
* `request` Object
|
||||
* `url` String
|
||||
* `headers` Object
|
||||
* `headers` Record<String, String>
|
||||
* `referrer` String
|
||||
* `method` String
|
||||
* `uploadData` [UploadData[]](structures/upload-data.md)
|
||||
* `callback` Function
|
||||
* `redirectRequest` Object
|
||||
* `url` String
|
||||
* `method` String
|
||||
* `session` Object (optional)
|
||||
* `method` String (optional)
|
||||
* `session` Object | null (optional)
|
||||
* `uploadData` Object (optional)
|
||||
* `contentType` String - MIME type of the content.
|
||||
* `data` String - Content to be sent.
|
||||
@@ -400,7 +404,7 @@ which sends a new HTTP request as a response.
|
||||
* `handler` Function
|
||||
* `request` Object
|
||||
* `url` String
|
||||
* `headers` Object
|
||||
* `headers` Record<String, String>
|
||||
* `referrer` String
|
||||
* `method` String
|
||||
* `uploadData` [UploadData[]](structures/upload-data.md)
|
||||
|
||||
@@ -418,8 +418,6 @@ Returns `Promise<void>` - resolves when the session’s HTTP authentication cach
|
||||
Adds scripts that will be executed on ALL web contents that are associated with
|
||||
this session just before normal `preload` scripts run.
|
||||
|
||||
**Note:** For security reasons, preload scripts can only be loaded from a subpath of the [app path](app.md#appgetapppath).
|
||||
|
||||
#### `ses.getPreloads()`
|
||||
|
||||
Returns `String[]` an array of paths to preload scripts that have been
|
||||
|
||||
@@ -36,9 +36,8 @@ Open the given file in the desktop's default manner.
|
||||
|
||||
* `url` String - Max 2081 characters on windows.
|
||||
* `options` Object (optional)
|
||||
* `activate` Boolean (optional) - `true` to bring the opened application to the
|
||||
foreground. The default is `true`. _macOS_
|
||||
* `workingDirectory` String (optional) - The working directory. _Windows_
|
||||
* `activate` Boolean (optional) _macOS_ - `true` to bring the opened application to the foreground. The default is `true`.
|
||||
* `workingDirectory` String (optional) _Windows_ - The working directory.
|
||||
|
||||
Returns `Promise<void>`
|
||||
|
||||
|
||||
@@ -2,6 +2,6 @@
|
||||
|
||||
* `percentCPUUsage` Number - Percentage of CPU used since the last call to getCPUUsage.
|
||||
First call returns 0.
|
||||
* `idleWakeupsPerSecond` Number - The number of average idle cpu wakeups per second
|
||||
* `idleWakeupsPerSecond` Number - The number of average idle CPU wakeups per second
|
||||
since the last call to getCPUUsage. First call returns 0. Will always return 0 on
|
||||
Windows.
|
||||
|
||||
4
docs/api/structures/file-path-with-headers.md
Normal file
4
docs/api/structures/file-path-with-headers.md
Normal file
@@ -0,0 +1,4 @@
|
||||
# FilePathWithHeaders Object
|
||||
|
||||
* `path` String - The path to the file to send.
|
||||
* `headers` Record<string, string> (optional) - Additional headers to be sent.
|
||||
@@ -1,7 +1,7 @@
|
||||
# IpcMainEvent Object extends `Event`
|
||||
|
||||
* `frameId` Integer - The ID of the renderer frame that sent this message
|
||||
* `returnValue` any - Set this to the value to be returned in a syncronous message
|
||||
* `returnValue` any - Set this to the value to be returned in a synchronous message
|
||||
* `sender` WebContents - Returns the `webContents` that sent the message
|
||||
* `reply` Function - A function that will send an IPC message to the renderer frame that sent the original message that you are currently handling. You should use this method to "reply" to the sent message in order to guaruntee the reply will go to the correct process and frame.
|
||||
* `reply` Function - A function that will send an IPC message to the renderer frame that sent the original message that you are currently handling. You should use this method to "reply" to the sent message in order to guarantee the reply will go to the correct process and frame.
|
||||
* `...args` any[]
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
# ProcessMemoryInfo Object
|
||||
|
||||
* `residentSet` Integer - _Linux_ and _Windows_ - The amount of memory
|
||||
* `residentSet` Integer _Linux_ _Windows_ - The amount of memory
|
||||
currently pinned to actual physical RAM in Kilobytes.
|
||||
* `private` Integer - The amount of memory not shared by other processes, such as
|
||||
JS heap or HTML content in Kilobytes.
|
||||
* `private` Integer - The amount of memory not shared by other processes, such as JS heap or HTML content in Kilobytes.
|
||||
* `shared` Integer - The amount of memory shared between processes, typically
|
||||
memory consumed by the Electron code itself in Kilobytes.
|
||||
|
||||
6
docs/api/structures/protocol-request.md
Normal file
6
docs/api/structures/protocol-request.md
Normal file
@@ -0,0 +1,6 @@
|
||||
# ProtocolRequest Object
|
||||
|
||||
* `url` String
|
||||
* `referrer` String
|
||||
* `method` String
|
||||
* `uploadData` [UploadData[]](upload-data.md) (optional)
|
||||
4
docs/api/structures/protocol-response-upload-data.md
Normal file
4
docs/api/structures/protocol-response-upload-data.md
Normal file
@@ -0,0 +1,4 @@
|
||||
# ProtocolResponseUploadData Object
|
||||
|
||||
* `contentType` String - MIME type of the content.
|
||||
* `data` String - Content to be sent.
|
||||
34
docs/api/structures/protocol-response.md
Normal file
34
docs/api/structures/protocol-response.md
Normal file
@@ -0,0 +1,34 @@
|
||||
# ProtocolResponse Object
|
||||
|
||||
* `error` Integer (optional) - When assigned, the `request` will fail with the
|
||||
`error` number . For the available error numbers you can use, please see the
|
||||
[net error list][net-error].
|
||||
* `statusCode` Number (optional) - The HTTP response code, default is 200.
|
||||
* `charset` String (optional) - The charset of response body, default is
|
||||
`"utf-8"`.
|
||||
* `mimeType` String (optional) - The MIME type of response body, default is
|
||||
`"text/html"`. Setting `mimeType` would implicitly set the `content-type`
|
||||
header in response, but if `content-type` is already set in `headers`, the
|
||||
`mimeType` would be ignored.
|
||||
* `headers` Record<string, string | string[]> (optional) - An object containing the response headers. The
|
||||
keys must be String, and values must be either String or Array of String.
|
||||
* `data` (Buffer | String | ReadableStream) (optional) - The response body. When
|
||||
returning stream as response, this is a Node.js readable stream representing
|
||||
the response body. When returning `Buffer` as response, this is a `Buffer`.
|
||||
When returning `String` as response, this is a `String`. This is ignored for
|
||||
other types of responses.
|
||||
* `path` String (optional) - Path to the file which would be sent as response
|
||||
body. This is only used for file responses.
|
||||
* `url` String (optional) - Download the `url` and pipe the result as response
|
||||
body. This is only used for URL responses.
|
||||
* `referrer` String (optional) - The `referrer` URL. This is only used for file
|
||||
and URL responses.
|
||||
* `method` String (optional) - The HTTP `method`. This is only used for file
|
||||
and URL responses.
|
||||
* `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
|
||||
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
|
||||
@@ -1,5 +1,5 @@
|
||||
# StreamProtocolResponse Object
|
||||
|
||||
* `statusCode` Number - The HTTP response code.
|
||||
* `headers` Object - An object containing the response headers.
|
||||
* `data` ReadableStream - A Node.js readable stream representing the response body.
|
||||
* `statusCode` Number (optional) - The HTTP response code.
|
||||
* `headers` Record<String, String | String[]> (optional) - An object containing the response headers.
|
||||
* `data` ReadableStream | null - A Node.js readable stream representing the response body.
|
||||
|
||||
5
docs/api/structures/string-protocol-response.md
Normal file
5
docs/api/structures/string-protocol-response.md
Normal file
@@ -0,0 +1,5 @@
|
||||
# StringProtocolResponse Object
|
||||
|
||||
* `mimeType` String (optional) - MIME type of the response.
|
||||
* `charset` String (optional) - Charset of the response.
|
||||
* `data` String | null - A string representing the response body.
|
||||
@@ -21,7 +21,7 @@
|
||||
with the trace.
|
||||
* `memory_dump_config` Object (optional) - if the
|
||||
`disabled-by-default-memory-infra` category is enabled, this contains
|
||||
optional additional configuration for data callection. See the [Chromium
|
||||
optional additional configuration for data collection. See the [Chromium
|
||||
memory-infra docs][memory-infra docs] for more information.
|
||||
|
||||
An example TraceConfig that roughly matches what Chrome DevTools records:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# UploadData Object
|
||||
|
||||
* `bytes` Buffer - Content being sent.
|
||||
* `file` String - Path of file being uploaded.
|
||||
* `blobUUID` String - UUID of blob data. Use [ses.getBlobData](../session.md#sesgetblobdataidentifier method
|
||||
* `file` String (optional) - Path of file being uploaded.
|
||||
* `blobUUID` String (optional) - UUID of blob data. Use [ses.getBlobData](../session.md#sesgetblobdataidentifier) method
|
||||
to retrieve the data.
|
||||
|
||||
@@ -987,7 +987,12 @@ Returns `String` - The user agent for this web page.
|
||||
|
||||
* `css` String
|
||||
|
||||
Injects CSS into the current web page.
|
||||
Returns `Promise<String>` - A promise that resolves with a key for the inserted
|
||||
CSS that can later be used to remove the CSS via
|
||||
`contents.removeInsertedCSS(key)`.
|
||||
|
||||
Injects CSS into the current web page and returns a unique key for the inserted
|
||||
stylesheet.
|
||||
|
||||
```js
|
||||
contents.on('did-finish-load', function () {
|
||||
@@ -995,6 +1000,22 @@ contents.on('did-finish-load', function () {
|
||||
})
|
||||
```
|
||||
|
||||
#### `contents.removeInsertedCSS(key)`
|
||||
|
||||
* `key` String
|
||||
|
||||
Returns `Promise<void>` - Resolves if the removal was successful.
|
||||
|
||||
Removes the inserted CSS from the current web page. The stylesheet is identified
|
||||
by its key, which is returned from `contents.insertCSS(css)`.
|
||||
|
||||
```js
|
||||
contents.on('did-finish-load', async function () {
|
||||
const key = await contents.insertCSS('html, body { background-color: #f00; }')
|
||||
contents.removeInsertedCSS(key)
|
||||
})
|
||||
```
|
||||
|
||||
#### `contents.executeJavaScript(code[, userGesture])`
|
||||
|
||||
* `code` String
|
||||
@@ -1065,6 +1086,8 @@ Returns `Number` - the current zoom level.
|
||||
* `minimumLevel` Number
|
||||
* `maximumLevel` Number
|
||||
|
||||
Returns `Promise<void>`
|
||||
|
||||
Sets the maximum and minimum pinch-to-zoom level.
|
||||
|
||||
> **NOTE**: Visual zoom is disabled by default in Electron. To re-enable it, call:
|
||||
@@ -1078,6 +1101,8 @@ Sets the maximum and minimum pinch-to-zoom level.
|
||||
* `minimumLevel` Number
|
||||
* `maximumLevel` Number
|
||||
|
||||
Returns `Promise<void>`
|
||||
|
||||
Sets the maximum and minimum layout-based (i.e. non-visual) zoom level.
|
||||
|
||||
#### `contents.undo()`
|
||||
@@ -1139,6 +1164,8 @@ Executes the editing command `replaceMisspelling` in web page.
|
||||
|
||||
* `text` String
|
||||
|
||||
Returns `Promise<void>`
|
||||
|
||||
Inserts `text` to the focused element.
|
||||
|
||||
#### `contents.findInPage(text[, options])`
|
||||
@@ -1200,9 +1227,26 @@ Returns [`PrinterInfo[]`](structures/printer-info.md).
|
||||
|
||||
* `options` Object (optional)
|
||||
* `silent` Boolean (optional) - Don't ask user for print settings. Default is `false`.
|
||||
* `printBackground` Boolean (optional) - Also prints the background color and image of
|
||||
* `printBackground` Boolean (optional) - Prints the background color and image of
|
||||
the web page. Default is `false`.
|
||||
* `deviceName` String (optional) - Set the printer device name to use. Default is `''`.
|
||||
* `color` Boolean (optional) - Set whether the printed web page will be in color or grayscale. Default is `true`.
|
||||
* `margins` Object (optional)
|
||||
* `marginType` String (optional) - Can be `default`, `none`, `printableArea`, or `custom`. If `custom` is chosen, you will also need to specify `top`, `bottom`, `left`, and `right`.
|
||||
* `top` Number (optional) - The top margin of the printed web page, in pixels.
|
||||
* `bottom` Number (optional) - The bottom margin of the printed web page, in pixels.
|
||||
* `left` Number (optional) - The left margin of the printed web page, in pixels.
|
||||
* `right` Number (optional) - The right margin of the printed web page, in pixels.
|
||||
* `landscape` Boolean (optional) - Whether the web page should be printed in landscape mode. Default is `false`.
|
||||
* `scaleFactor` Number (optional) - The scale factor of the web page.
|
||||
* `pagesPerSheet` Number (optional) - The number of pages to print per page sheet.
|
||||
* `collate` Boolean (optional) - Whether the web page should be collated.
|
||||
* `copies` Number (optional) - The number of copies of the web page to print.
|
||||
* `pageRanges` Record<string, number> (optional) - The page range to print. Should have two keys: `from` and `to`.
|
||||
* `duplexMode` String (optional) - Set the duplex mode of the printed web page. Can be `simplex`, `shortEdge`, or `longEdge`.
|
||||
* `dpi` Object (optional)
|
||||
* `horizontal` Number (optional) - The horizontal dpi.
|
||||
* `vertical` Number (optional) - The vertical dpi.
|
||||
* `callback` Function (optional)
|
||||
* `success` Boolean - Indicates success of the print call.
|
||||
|
||||
@@ -1213,7 +1257,7 @@ for printing.
|
||||
Calling `window.print()` in web page is equivalent to calling
|
||||
`webContents.print({ silent: false, printBackground: false, deviceName: '' })`.
|
||||
|
||||
Use `page-break-before: always; ` CSS style to force to print to a new page.
|
||||
Use `page-break-before: always;` CSS style to force to print to a new page.
|
||||
|
||||
#### `contents.printToPDF(options)`
|
||||
|
||||
|
||||
@@ -99,7 +99,18 @@ webFrame.setSpellCheckProvider('en-US', {
|
||||
|
||||
* `css` String - CSS source code.
|
||||
|
||||
Inserts `css` as a style sheet in the document.
|
||||
Returns `String` - A key for the inserted CSS that can later be used to remove
|
||||
the CSS via `webFrame.removeInsertedCSS(key)`.
|
||||
|
||||
Injects CSS into the current web page and returns a unique key for the inserted
|
||||
stylesheet.
|
||||
|
||||
### `webFrame.removeInsertedCSS(key)`
|
||||
|
||||
* `key` String
|
||||
|
||||
Removes the inserted CSS from the current web page. The stylesheet is identified
|
||||
by its key, which is returned from `webFrame.insertCSS(css)`.
|
||||
|
||||
### `webFrame.insertText(text)`
|
||||
|
||||
|
||||
@@ -162,9 +162,6 @@ When the guest page doesn't have node integration this script will still have
|
||||
access to all Node APIs, but global objects injected by Node will be deleted
|
||||
after this script has finished executing.
|
||||
|
||||
**Note:** For security reasons, preload scripts can only be loaded from
|
||||
a subpath of the [app path](app.md#appgetapppath).
|
||||
|
||||
**Note:** This option will be appear as `preloadURL` (not `preload`) in
|
||||
the `webPreferences` specified to the `will-attach-webview` event.
|
||||
|
||||
@@ -379,7 +376,21 @@ Returns `String` - The user agent for guest page.
|
||||
|
||||
* `css` String
|
||||
|
||||
Injects CSS into the guest page.
|
||||
Returns `Promise<String>` - A promise that resolves with a key for the inserted
|
||||
CSS that can later be used to remove the CSS via
|
||||
`<webview>.removeInsertedCSS(key)`.
|
||||
|
||||
Injects CSS into the current web page and returns a unique key for the inserted
|
||||
stylesheet.
|
||||
|
||||
### `<webview>.removeInsertedCSS(key)`
|
||||
|
||||
* `key` String
|
||||
|
||||
Returns `Promise<void>` - Resolves if the removal was successful.
|
||||
|
||||
Removes the inserted CSS from the current web page. The stylesheet is identified
|
||||
by its key, which is returned from `<webview>.insertCSS(css)`.
|
||||
|
||||
### `<webview>.executeJavaScript(code[, userGesture])`
|
||||
|
||||
@@ -490,6 +501,8 @@ Executes editing command `replaceMisspelling` in page.
|
||||
|
||||
* `text` String
|
||||
|
||||
Returns `Promise<void>`
|
||||
|
||||
Inserts `text` to the focused element.
|
||||
|
||||
### `<webview>.findInPage(text[, options])`
|
||||
@@ -531,6 +544,8 @@ Stops any `findInPage` request for the `webview` with the provided `action`.
|
||||
the web page. Default is `false`.
|
||||
* `deviceName` String (optional) - Set the printer device name to use. Default is `''`.
|
||||
|
||||
Returns `Promise<void>`
|
||||
|
||||
Prints `webview`'s web page. Same as `webContents.print([options])`.
|
||||
|
||||
### `<webview>.printToPDF(options)`
|
||||
@@ -562,6 +577,8 @@ Captures a snapshot of the page within `rect`. Omitting `rect` will capture the
|
||||
* `channel` String
|
||||
* `...args` any[]
|
||||
|
||||
Returns `Promise<void>`
|
||||
|
||||
Send an asynchronous message to renderer process via `channel`, you can also
|
||||
send arbitrary arguments. The renderer process can handle the message by
|
||||
listening to the `channel` event with the [`ipcRenderer`](ipc-renderer.md) module.
|
||||
@@ -573,6 +590,8 @@ examples.
|
||||
|
||||
* `event` Object
|
||||
|
||||
Returns `Promise<void>`
|
||||
|
||||
Sends an input `event` to the page.
|
||||
|
||||
See [webContents.sendInputEvent](web-contents.md#contentssendinputeventevent)
|
||||
@@ -607,6 +626,8 @@ Returns `Number` - the current zoom level.
|
||||
* `minimumLevel` Number
|
||||
* `maximumLevel` Number
|
||||
|
||||
Returns `Promise<void>`
|
||||
|
||||
Sets the maximum and minimum pinch-to-zoom level.
|
||||
|
||||
### `<webview>.setLayoutZoomLevelLimits(minimumLevel, maximumLevel)`
|
||||
@@ -614,6 +635,8 @@ Sets the maximum and minimum pinch-to-zoom level.
|
||||
* `minimumLevel` Number
|
||||
* `maximumLevel` Number
|
||||
|
||||
Returns `Promise<void>`
|
||||
|
||||
Sets the maximum and minimum layout-based (i.e. non-visual) zoom level.
|
||||
|
||||
### `<webview>.showDefinitionForSelection()` _macOS_
|
||||
|
||||
@@ -168,7 +168,7 @@ is very likely you are using the module in the wrong process. For example
|
||||
`electron.app` can only be used in the main process, while `electron.webFrame`
|
||||
is only available in renderer processes.
|
||||
|
||||
## The font looks blurry, what is this and what can i do?
|
||||
## 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:
|
||||
|
||||
@@ -185,7 +185,7 @@ let win = new BrowserWindow({
|
||||
})
|
||||
```
|
||||
|
||||
The effect is visible only on (some?) LCD screens. Even if you dont see a difference, some of your users may. It is best to always set the background this way, unless you have reasons not to do so.
|
||||
The effect is visible only on (some?) LCD screens. Even if you don't see a difference, some of your users may. It is best to always set the background this way, unless you have reasons not to do so.
|
||||
|
||||
Notice that just setting the background in the CSS does not have the desired effect.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Electron Documentation Styleguide
|
||||
# Electron Documentation Style Guide
|
||||
|
||||
These are the guidelines for writing Electron documentation.
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
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 create a custom driver, we'll use nodejs' [child_process](https://nodejs.org/api/child_process.html) API. The test suite will spawn the Electron process, then establish a simple messaging protocol:
|
||||
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:
|
||||
|
||||
```js
|
||||
var childProcess = require('child_process')
|
||||
@@ -22,7 +22,7 @@ appProcess.on('message', (msg) => {
|
||||
appProcess.send({ my: 'message' })
|
||||
```
|
||||
|
||||
From within the Electron app, you can listen for messages and send replies using the nodejs [process](https://nodejs.org/api/process.html) API:
|
||||
From within the Electron app, you can listen for messages and send replies using the Node.js [process](https://nodejs.org/api/process.html) API:
|
||||
|
||||
```js
|
||||
// listen for IPC messages from the test suite
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Boilerplates and CLIs
|
||||
|
||||
Electron development is un-opinionated - there is no "one true way" to develop,
|
||||
Electron development is unopinionated - there is no "one true way" to develop,
|
||||
build, package, or release an Electron application. Additional features for
|
||||
Electron, both for build- and run-time, can usually be found on
|
||||
[npm](https://www.npmjs.com/search?q=electron) in individual packages, allowing developers to build both
|
||||
|
||||
@@ -37,6 +37,16 @@ The latest three major versions are supported by the Electron team.
|
||||
For example, if the latest release is 5.0.x, then the 4.x.y series
|
||||
is supported, as are the two previous release series 3.x.y and 2.x.y.
|
||||
|
||||
The latest stable release unilaterally receives all fixes from `master`,
|
||||
and the version prior to that receives the vast majority of those fixes
|
||||
as time and bandwidth warrants. The oldest supported release line will receive
|
||||
only security fixes directly.
|
||||
|
||||
All supported release lines will accept external pull requests to backport
|
||||
fixes previously merged to `master`, though this may be on a case-by-case
|
||||
basis for some older supported lines. All contested decisions around release
|
||||
line backports will be resolved by the [Releases Working Group](https://github.com/electron/governance/tree/master/wg-releases) as an agenda item at their weekly meeting the week the backport PR is raised.
|
||||
|
||||
### Currently supported versions
|
||||
- 5.x
|
||||
- 4.x
|
||||
|
||||
@@ -14,13 +14,13 @@ It's a virtual framebuffer, implementing the X11 display server protocol -
|
||||
it performs all graphical operations in memory without showing any screen output,
|
||||
which is exactly what we need.
|
||||
|
||||
Then, create a virtual xvfb screen and export an environment variable
|
||||
Then, create a virtual Xvfb screen and export an environment variable
|
||||
called DISPLAY that points to it. Chromium in Electron will automatically look
|
||||
for `$DISPLAY`, so no further configuration of your app is required.
|
||||
This step can be automated with Paul Betts's
|
||||
[xvfb-maybe](https://github.com/paulcbetts/xvfb-maybe): Prepend your test
|
||||
commands with `xvfb-maybe` and the little tool will automatically configure
|
||||
xvfb, if required by the current system. On Windows or macOS, it will
|
||||
Xvfb, if required by the current system. On Windows or macOS, it will
|
||||
do nothing.
|
||||
|
||||
```sh
|
||||
@@ -51,8 +51,8 @@ For Jenkins, a [Xvfb plugin is available](https://wiki.jenkins-ci.org/display/JE
|
||||
|
||||
### Circle CI
|
||||
|
||||
Circle CI is awesome and has xvfb and `$DISPLAY`
|
||||
[already setup, so no further configuration is required](https://circleci.com/docs/environment#browsers).
|
||||
Circle CI is awesome and has Xvfb and `$DISPLAY`
|
||||
[already set up, so no further configuration is required](https://circleci.com/docs/environment#browsers).
|
||||
|
||||
### AppVeyor
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ auto_filenames = {
|
||||
"docs/api/accelerator.md",
|
||||
"docs/api/app.md",
|
||||
"docs/api/auto-updater.md",
|
||||
"docs/api/breaking-changes-ns.md",
|
||||
"docs/api/breaking-changes.md",
|
||||
"docs/api/browser-view.md",
|
||||
"docs/api/browser-window-proxy.md",
|
||||
@@ -39,6 +40,7 @@ auto_filenames = {
|
||||
"docs/api/power-monitor.md",
|
||||
"docs/api/power-save-blocker.md",
|
||||
"docs/api/process.md",
|
||||
"docs/api/protocol-ns.md",
|
||||
"docs/api/protocol.md",
|
||||
"docs/api/remote.md",
|
||||
"docs/api/sandbox-option.md",
|
||||
@@ -75,6 +77,7 @@ auto_filenames = {
|
||||
"docs/api/structures/display.md",
|
||||
"docs/api/structures/event.md",
|
||||
"docs/api/structures/file-filter.md",
|
||||
"docs/api/structures/file-path-with-headers.md",
|
||||
"docs/api/structures/gpu-feature-status.md",
|
||||
"docs/api/structures/io-counters.md",
|
||||
"docs/api/structures/ipc-main-event.md",
|
||||
@@ -91,6 +94,9 @@ auto_filenames = {
|
||||
"docs/api/structures/process-memory-info.md",
|
||||
"docs/api/structures/process-metric.md",
|
||||
"docs/api/structures/product.md",
|
||||
"docs/api/structures/protocol-request.md",
|
||||
"docs/api/structures/protocol-response-upload-data.md",
|
||||
"docs/api/structures/protocol-response.md",
|
||||
"docs/api/structures/rectangle.md",
|
||||
"docs/api/structures/referrer.md",
|
||||
"docs/api/structures/remove-client-certificate.md",
|
||||
@@ -100,6 +106,7 @@ auto_filenames = {
|
||||
"docs/api/structures/shortcut-details.md",
|
||||
"docs/api/structures/size.md",
|
||||
"docs/api/structures/stream-protocol-response.md",
|
||||
"docs/api/structures/string-protocol-response.md",
|
||||
"docs/api/structures/task.md",
|
||||
"docs/api/structures/thumbar-button.md",
|
||||
"docs/api/structures/trace-categories-and-options.md",
|
||||
@@ -256,7 +263,6 @@ auto_filenames = {
|
||||
"lib/common/error-utils.js",
|
||||
"lib/common/init.ts",
|
||||
"lib/common/parse-features-string.js",
|
||||
"lib/common/path-utils.ts",
|
||||
"lib/common/reset-search-paths.ts",
|
||||
"lib/common/web-view-methods.js",
|
||||
"lib/renderer/ipc-renderer-internal-utils.ts",
|
||||
@@ -281,7 +287,6 @@ auto_filenames = {
|
||||
"lib/common/electron-binding-setup.ts",
|
||||
"lib/common/error-utils.js",
|
||||
"lib/common/init.ts",
|
||||
"lib/common/path-utils.ts",
|
||||
"lib/common/reset-search-paths.ts",
|
||||
"lib/common/web-view-methods.js",
|
||||
"lib/renderer/api/crash-reporter.js",
|
||||
|
||||
1138
filenames.gni
1138
filenames.gni
File diff suppressed because it is too large
Load Diff
@@ -174,13 +174,14 @@ WebContents.prototype._sendToFrameInternal = function (frameId, channel, ...args
|
||||
const webFrameMethods = [
|
||||
'insertCSS',
|
||||
'insertText',
|
||||
'removeInsertedCSS',
|
||||
'setLayoutZoomLevelLimits',
|
||||
'setVisualZoomLevelLimits'
|
||||
]
|
||||
|
||||
for (const method of webFrameMethods) {
|
||||
WebContents.prototype[method] = function (...args) {
|
||||
ipcMainUtils.invokeInWebContents(this, false, 'ELECTRON_INTERNAL_RENDERER_WEB_FRAME_METHOD', method, ...args)
|
||||
return ipcMainUtils.invokeInWebContents(this, false, 'ELECTRON_INTERNAL_RENDERER_WEB_FRAME_METHOD', method, ...args)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -312,9 +312,9 @@ ipcMainUtils.handle('CHROME_TABS_EXECUTE_SCRIPT', async function (event, tabId,
|
||||
return ipcMainUtils.invokeInWebContents(contents, false, 'CHROME_TABS_EXECUTE_SCRIPT', extensionId, url, code)
|
||||
})
|
||||
|
||||
ipcMainUtils.handle('CHROME_GET_CONTENT_SCRIPTS', async (event) => {
|
||||
exports.getContentScripts = () => {
|
||||
return Object.values(contentScripts)
|
||||
})
|
||||
}
|
||||
|
||||
// Transfer the content scripts to renderer.
|
||||
const contentScripts = {}
|
||||
|
||||
@@ -4,11 +4,7 @@ const { webContents } = require('electron')
|
||||
const { ipcMainInternal } = require('@electron/internal/browser/ipc-main-internal')
|
||||
const ipcMainUtils = require('@electron/internal/browser/ipc-main-internal-utils')
|
||||
const parseFeaturesString = require('@electron/internal/common/parse-features-string')
|
||||
const {
|
||||
syncMethods,
|
||||
asyncCallbackMethods,
|
||||
asyncPromiseMethods
|
||||
} = require('@electron/internal/common/web-view-methods')
|
||||
const { syncMethods, asyncMethods } = require('@electron/internal/common/web-view-methods')
|
||||
|
||||
// Doesn't exist in early initialization.
|
||||
let webViewManager = null
|
||||
@@ -371,11 +367,7 @@ ipcMainInternal.on('ELECTRON_GUEST_VIEW_MANAGER_FOCUS_CHANGE', function (event,
|
||||
}
|
||||
})
|
||||
|
||||
const allMethods = new Set([
|
||||
...syncMethods,
|
||||
...asyncCallbackMethods,
|
||||
...asyncPromiseMethods
|
||||
])
|
||||
const allMethods = new Set([ ...syncMethods, ...asyncMethods ])
|
||||
|
||||
handleMessage('ELECTRON_GUEST_VIEW_MANAGER_CALL', function (event, guestInstanceId, method, args) {
|
||||
const guest = getGuestForWebContents(guestInstanceId, event.sender)
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
const electron = require('electron')
|
||||
const { EventEmitter } = require('events')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
const v8Util = process.electronBinding('v8_util')
|
||||
const eventBinding = process.electronBinding('event')
|
||||
@@ -12,6 +11,7 @@ const features = process.electronBinding('features')
|
||||
|
||||
const { isPromise } = electron
|
||||
|
||||
const { getContentScripts } = require('@electron/internal/browser/chrome-extension')
|
||||
const { crashReporterInit } = require('@electron/internal/browser/crash-reporter-init')
|
||||
const { ipcMainInternal } = require('@electron/internal/browser/ipc-main-internal')
|
||||
const ipcMainUtils = require('@electron/internal/browser/ipc-main-internal-utils')
|
||||
@@ -20,7 +20,6 @@ const guestViewManager = require('@electron/internal/browser/guest-view-manager'
|
||||
const bufferUtils = require('@electron/internal/common/buffer-utils')
|
||||
const errorUtils = require('@electron/internal/common/error-utils')
|
||||
const clipboardUtils = require('@electron/internal/common/clipboard-utils')
|
||||
const { isParentDir } = require('@electron/internal/common/path-utils')
|
||||
|
||||
const hasProp = {}.hasOwnProperty
|
||||
|
||||
@@ -517,22 +516,11 @@ if (features.isDesktopCapturerEnabled()) {
|
||||
})
|
||||
}
|
||||
|
||||
let absoluteAppPath
|
||||
const getAppPath = async function () {
|
||||
if (absoluteAppPath === undefined) {
|
||||
absoluteAppPath = await fs.promises.realpath(electron.app.getAppPath())
|
||||
}
|
||||
return absoluteAppPath
|
||||
}
|
||||
|
||||
const getPreloadScript = async function (preloadPath) {
|
||||
let preloadSrc = null
|
||||
let preloadError = null
|
||||
if (preloadPath) {
|
||||
try {
|
||||
if (!isParentDir(await getAppPath(), await fs.promises.realpath(preloadPath))) {
|
||||
throw new Error('Preload scripts outside of app path are not allowed')
|
||||
}
|
||||
preloadSrc = (await fs.promises.readFile(preloadPath)).toString()
|
||||
} catch (err) {
|
||||
preloadError = errorUtils.serialize(err)
|
||||
@@ -541,6 +529,8 @@ const getPreloadScript = async function (preloadPath) {
|
||||
return { preloadPath, preloadSrc, preloadError }
|
||||
}
|
||||
|
||||
ipcMainUtils.handle('ELECTRON_GET_CONTENT_SCRIPTS', () => getContentScripts())
|
||||
|
||||
ipcMainUtils.handle('ELECTRON_BROWSER_SANDBOX_LOAD', async function (event) {
|
||||
const preloadPaths = [
|
||||
...(event.sender.session ? event.sender.session.getPreloads() : []),
|
||||
@@ -548,6 +538,7 @@ ipcMainUtils.handle('ELECTRON_BROWSER_SANDBOX_LOAD', async function (event) {
|
||||
]
|
||||
|
||||
return {
|
||||
contentScripts: getContentScripts(),
|
||||
preloadScripts: await Promise.all(preloadPaths.map(path => getPreloadScript(path))),
|
||||
isRemoteModuleEnabled: isRemoteModuleEnabled(event.sender),
|
||||
isWebViewTagEnabled: guestViewManager.isWebViewTagEnabled(event.sender),
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import * as timers from 'timers'
|
||||
import * as util from 'util'
|
||||
|
||||
import { electronBindingSetup } from '@electron/internal/common/electron-binding-setup'
|
||||
|
||||
const timers = require('timers')
|
||||
|
||||
process.electronBinding = electronBindingSetup(process._linkedBinding, process.type)
|
||||
|
||||
type AnyFn = (...args: any[]) => any
|
||||
@@ -38,16 +39,20 @@ function wrap <T extends AnyFn> (func: T, wrapper: (fn: AnyFn) => T) {
|
||||
|
||||
process.nextTick = wrapWithActivateUvLoop(process.nextTick)
|
||||
|
||||
global.setImmediate = wrapWithActivateUvLoop(timers.setImmediate)
|
||||
global.setImmediate = timers.setImmediate = wrapWithActivateUvLoop(timers.setImmediate)
|
||||
global.clearImmediate = timers.clearImmediate
|
||||
|
||||
// setTimeout needs to update the polling timeout of the event loop, when
|
||||
// called under Chromium's event loop the node's event loop won't get a chance
|
||||
// to update the timeout, so we have to force the node's event loop to
|
||||
// recalculate the timeout in browser process.
|
||||
timers.setTimeout = wrapWithActivateUvLoop(timers.setTimeout)
|
||||
timers.setInterval = wrapWithActivateUvLoop(timers.setInterval)
|
||||
|
||||
// Only override the global setTimeout/setInterval impls in the browser process
|
||||
if (process.type === 'browser') {
|
||||
// setTimeout needs to update the polling timeout of the event loop, when
|
||||
// called under Chromium's event loop the node's event loop won't get a chance
|
||||
// to update the timeout, so we have to force the node's event loop to
|
||||
// recalculate the timeout in browser process.
|
||||
global.setTimeout = wrapWithActivateUvLoop(timers.setTimeout)
|
||||
global.setInterval = wrapWithActivateUvLoop(timers.setInterval)
|
||||
global.setTimeout = timers.setTimeout
|
||||
global.setInterval = timers.setInterval
|
||||
}
|
||||
|
||||
if (process.platform === 'win32') {
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
import * as path from 'path'
|
||||
|
||||
export const isParentDir = function (parent: string, dir: string) {
|
||||
const relative = path.relative(parent, dir)
|
||||
return !!relative && !relative.startsWith('..') && !path.isAbsolute(relative)
|
||||
}
|
||||
@@ -53,18 +53,16 @@ exports.syncMethods = new Set([
|
||||
'setZoomLevel'
|
||||
])
|
||||
|
||||
exports.asyncCallbackMethods = new Set([
|
||||
exports.asyncMethods = new Set([
|
||||
'capturePage',
|
||||
'executeJavaScript',
|
||||
'insertCSS',
|
||||
'insertText',
|
||||
'removeInsertedCSS',
|
||||
'send',
|
||||
'sendInputEvent',
|
||||
'setLayoutZoomLevelLimits',
|
||||
'setVisualZoomLevelLimits',
|
||||
'print'
|
||||
])
|
||||
|
||||
exports.asyncPromiseMethods = new Set([
|
||||
'capturePage',
|
||||
'executeJavaScript',
|
||||
'print',
|
||||
'printToPDF'
|
||||
])
|
||||
|
||||
@@ -108,13 +108,7 @@ ipcRendererUtils.handle('CHROME_TABS_EXECUTE_SCRIPT', function (
|
||||
return runContentScript.call(window, extensionId, url, code)
|
||||
})
|
||||
|
||||
type ContentScriptEntry = {
|
||||
extensionId: string;
|
||||
contentScripts: Electron.ContentScript[];
|
||||
}
|
||||
|
||||
module.exports = () => {
|
||||
const entries = ipcRendererUtils.invokeSync<ContentScriptEntry[]>('CHROME_GET_CONTENT_SCRIPTS')
|
||||
module.exports = (entries: Electron.ContentScriptEntry[]) => {
|
||||
for (const entry of entries) {
|
||||
if (entry.contentScripts) {
|
||||
for (const script of entry.contentScripts) {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { EventEmitter } from 'events'
|
||||
import * as fs from 'fs'
|
||||
import * as path from 'path'
|
||||
|
||||
const Module = require('module')
|
||||
@@ -15,7 +14,7 @@ const Module = require('module')
|
||||
// "Module.wrapper" we can force Node to use the old code path to wrap module
|
||||
// code with JavaScript.
|
||||
//
|
||||
// Note 3: We provide the equivilant extra variables internally through the
|
||||
// Note 3: We provide the equivalent extra variables internally through the
|
||||
// webpack ProvidePlugin in webpack.config.base.js. If you add any extra
|
||||
// variables to this wrapper please ensure to update that plugin as well.
|
||||
Module.wrapper = [
|
||||
@@ -54,6 +53,7 @@ v8Util.setHiddenValue(global, 'ipcNative', {
|
||||
|
||||
// Use electron module after everything is ready.
|
||||
const { ipcRendererInternal } = require('@electron/internal/renderer/ipc-renderer-internal')
|
||||
const ipcRendererUtils = require('@electron/internal/renderer/ipc-renderer-internal-utils')
|
||||
const { webFrameInit } = require('@electron/internal/renderer/web-frame-init')
|
||||
webFrameInit()
|
||||
|
||||
@@ -111,7 +111,8 @@ switch (window.location.protocol) {
|
||||
windowSetup(guestInstanceId, openerId, isHiddenPage, usesNativeWindowOpen)
|
||||
|
||||
// Inject content scripts.
|
||||
require('@electron/internal/renderer/content-scripts-injector')()
|
||||
const contentScripts = ipcRendererUtils.invokeSync('ELECTRON_GET_CONTENT_SCRIPTS') as Electron.ContentScriptEntry[]
|
||||
require('@electron/internal/renderer/content-scripts-injector')(contentScripts)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,33 +179,24 @@ if (nodeIntegration) {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Delete Node's symbols after the Environment has been loaded.
|
||||
process.once('loaded', function () {
|
||||
delete global.process
|
||||
delete global.Buffer
|
||||
delete global.setImmediate
|
||||
delete global.clearImmediate
|
||||
delete global.global
|
||||
})
|
||||
// Delete Node's symbols after the Environment has been loaded in a
|
||||
// non context-isolated environment
|
||||
if (!contextIsolation) {
|
||||
process.once('loaded', function () {
|
||||
delete global.process
|
||||
delete global.Buffer
|
||||
delete global.setImmediate
|
||||
delete global.clearImmediate
|
||||
delete global.global
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const errorUtils = require('@electron/internal/common/error-utils')
|
||||
const { isParentDir } = require('@electron/internal/common/path-utils')
|
||||
|
||||
let absoluteAppPath: string
|
||||
const getAppPath = function () {
|
||||
if (absoluteAppPath === undefined) {
|
||||
absoluteAppPath = fs.realpathSync(appPath!)
|
||||
}
|
||||
return absoluteAppPath
|
||||
}
|
||||
|
||||
// Load the preload scripts.
|
||||
for (const preloadScript of preloadScripts) {
|
||||
try {
|
||||
if (!isParentDir(getAppPath(), fs.realpathSync(preloadScript))) {
|
||||
throw new Error('Preload scripts outside of app path are not allowed')
|
||||
}
|
||||
Module._load(preloadScript)
|
||||
} catch (error) {
|
||||
console.error(`Unable to load preload script: ${preloadScript}`)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { webFrame } from 'electron'
|
||||
import { invokeSync } from '@electron/internal/renderer/ipc-renderer-internal-utils'
|
||||
import { invoke } from '@electron/internal/renderer/ipc-renderer-internal-utils'
|
||||
|
||||
let shouldLog: boolean | null = null
|
||||
|
||||
@@ -75,7 +75,7 @@ const isUnsafeEvalEnabled = function () {
|
||||
}
|
||||
|
||||
const moreInformation = `\nFor more information and help, consult
|
||||
https://electronjs.org/docs/tutorial/security.\n This warning will not show up
|
||||
https://electronjs.org/docs/tutorial/security.\nThis warning will not show up
|
||||
once the app is packaged.`
|
||||
|
||||
/**
|
||||
@@ -100,9 +100,9 @@ const warnAboutInsecureResources = function () {
|
||||
}
|
||||
|
||||
const warning = `This renderer process loads resources using insecure
|
||||
protocols.This exposes users of this app to unnecessary security risks.
|
||||
Consider loading the following resources over HTTPS or FTPS. \n ${resources}
|
||||
\n ${moreInformation}`
|
||||
protocols. This exposes users of this app to unnecessary security risks.
|
||||
Consider loading the following resources over HTTPS or FTPS. \n${resources}
|
||||
\n${moreInformation}`
|
||||
|
||||
console.warn('%cElectron Security Warning (Insecure Resources)',
|
||||
'font-weight: bold;', warning)
|
||||
@@ -120,7 +120,7 @@ const warnAboutNodeWithRemoteContent = function (nodeIntegration: boolean) {
|
||||
if (getIsRemoteProtocol()) {
|
||||
const warning = `This renderer process has Node.js integration enabled
|
||||
and attempted to load remote content from '${window.location}'. This
|
||||
exposes users of this app to severe security risks.\n ${moreInformation}`
|
||||
exposes users of this app to severe security risks.\n${moreInformation}`
|
||||
|
||||
console.warn('%cElectron Security Warning (Node.js Integration with Remote Content)',
|
||||
'font-weight: bold;', warning)
|
||||
@@ -142,7 +142,7 @@ const warnAboutDisabledWebSecurity = function (webPreferences?: Electron.WebPref
|
||||
if (!webPreferences || webPreferences.webSecurity !== false) return
|
||||
|
||||
const warning = `This renderer process has "webSecurity" disabled. This
|
||||
exposes users of this app to severe security risks.\n ${moreInformation}`
|
||||
exposes users of this app to severe security risks.\n${moreInformation}`
|
||||
|
||||
console.warn('%cElectron Security Warning (Disabled webSecurity)',
|
||||
'font-weight: bold;', warning)
|
||||
@@ -152,8 +152,6 @@ const warnAboutDisabledWebSecurity = function (webPreferences?: Electron.WebPref
|
||||
* #6 on the checklist: Define a Content-Security-Policy and use restrictive
|
||||
* rules (i.e. script-src 'self')
|
||||
*
|
||||
* #7 on the checklist: Disable eval
|
||||
*
|
||||
* Logs a warning message about unset or insecure CSP
|
||||
*/
|
||||
const warnAboutInsecureCSP = function () {
|
||||
@@ -162,7 +160,7 @@ const warnAboutInsecureCSP = function () {
|
||||
|
||||
const warning = `This renderer process has either no Content Security
|
||||
Policy set or a policy with "unsafe-eval" enabled. This exposes users of
|
||||
this app to unnecessary security risks.\n ${moreInformation}`
|
||||
this app to unnecessary security risks.\n${moreInformation}`
|
||||
|
||||
console.warn('%cElectron Security Warning (Insecure Content-Security-Policy)',
|
||||
'font-weight: bold;', warning)
|
||||
@@ -170,7 +168,7 @@ const warnAboutInsecureCSP = function () {
|
||||
}
|
||||
|
||||
/**
|
||||
* #8 on the checklist: Do not set allowRunningInsecureContent to true
|
||||
* #7 on the checklist: Do not set allowRunningInsecureContent to true
|
||||
*
|
||||
* Logs a warning message about disabled webSecurity.
|
||||
*/
|
||||
@@ -186,7 +184,7 @@ const warnAboutInsecureContentAllowed = function (webPreferences?: Electron.WebP
|
||||
}
|
||||
|
||||
/**
|
||||
* #9 on the checklist: Do not enable experimental features
|
||||
* #8 on the checklist: Do not enable experimental features
|
||||
*
|
||||
* Logs a warning message about experimental features.
|
||||
*/
|
||||
@@ -197,14 +195,14 @@ const warnAboutExperimentalFeatures = function (webPreferences?: Electron.WebPre
|
||||
|
||||
const warning = `This renderer process has "experimentalFeatures" enabled.
|
||||
This exposes users of this app to some security risk. If you do not need
|
||||
this feature, you should disable it.\n ${moreInformation}`
|
||||
this feature, you should disable it.\n${moreInformation}`
|
||||
|
||||
console.warn('%cElectron Security Warning (experimentalFeatures)',
|
||||
'font-weight: bold;', warning)
|
||||
}
|
||||
|
||||
/**
|
||||
* #10 on the checklist: Do not use enableBlinkFeatures
|
||||
* #9 on the checklist: Do not use enableBlinkFeatures
|
||||
*
|
||||
* Logs a warning message about enableBlinkFeatures
|
||||
*/
|
||||
@@ -217,14 +215,14 @@ const warnAboutEnableBlinkFeatures = function (webPreferences?: Electron.WebPref
|
||||
|
||||
const warning = `This renderer process has additional "enableBlinkFeatures"
|
||||
enabled. This exposes users of this app to some security risk. If you do not
|
||||
need this feature, you should disable it.\n ${moreInformation}`
|
||||
need this feature, you should disable it.\n${moreInformation}`
|
||||
|
||||
console.warn('%cElectron Security Warning (enableBlinkFeatures)',
|
||||
'font-weight: bold;', warning)
|
||||
}
|
||||
|
||||
/**
|
||||
* #11 on the checklist: Do Not Use allowpopups
|
||||
* #10 on the checklist: Do Not Use allowpopups
|
||||
*
|
||||
* Logs a warning message about allowed popups
|
||||
*/
|
||||
@@ -247,7 +245,29 @@ const warnAboutAllowedPopups = function () {
|
||||
}
|
||||
|
||||
// Currently missing since we can't easily programmatically check for it:
|
||||
// #12WebViews: Verify the options and params of all `<webview>` tags
|
||||
// #11 Verify WebView Options Before Creation
|
||||
// #12 Disable or limit navigation
|
||||
// #13 Disable or limit creation of new windows
|
||||
// #14 Do not use `openExternal` with untrusted content
|
||||
|
||||
// #15 on the checklist: Disable the `remote` module
|
||||
// Logs a warning message about the remote module
|
||||
|
||||
const warnAboutRemoteModuleWithRemoteContent = function (webPreferences?: Electron.WebPreferences) {
|
||||
if (!webPreferences || !webPreferences.enableRemoteModule) return
|
||||
|
||||
if (getIsRemoteProtocol()) {
|
||||
const warning = `This renderer process has "enableRemoteModule" enabled
|
||||
and attempted to load remote content from '${window.location}'. This
|
||||
exposes users of this app to unnecessary security risks.\n${moreInformation}`
|
||||
|
||||
console.warn('%cElectron Security Warning (enableRemoteModule)',
|
||||
'font-weight: bold;', warning)
|
||||
}
|
||||
}
|
||||
|
||||
// Currently missing since we can't easily programmatically check for it:
|
||||
// #16 Filter the `remote` module
|
||||
|
||||
const logSecurityWarnings = function (
|
||||
webPreferences: Electron.WebPreferences | undefined, nodeIntegration: boolean
|
||||
@@ -260,20 +280,21 @@ const logSecurityWarnings = function (
|
||||
warnAboutEnableBlinkFeatures(webPreferences)
|
||||
warnAboutInsecureCSP()
|
||||
warnAboutAllowedPopups()
|
||||
warnAboutRemoteModuleWithRemoteContent(webPreferences)
|
||||
}
|
||||
|
||||
const getWebPreferences = function () {
|
||||
const getWebPreferences = async function () {
|
||||
try {
|
||||
return invokeSync('ELECTRON_BROWSER_GET_LAST_WEB_PREFERENCES')
|
||||
return invoke<Electron.WebPreferences>('ELECTRON_BROWSER_GET_LAST_WEB_PREFERENCES')
|
||||
} catch (error) {
|
||||
console.warn(`getLastWebPreferences() failed: ${error}`)
|
||||
}
|
||||
}
|
||||
|
||||
export function securityWarnings (nodeIntegration: boolean) {
|
||||
const loadHandler = function () {
|
||||
const loadHandler = async function () {
|
||||
if (shouldLogSecurityWarnings()) {
|
||||
const webPreferences = getWebPreferences()
|
||||
const webPreferences = await getWebPreferences()
|
||||
logSecurityWarnings(webPreferences, nodeIntegration)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,11 +3,7 @@ import { remote, webFrame } from 'electron'
|
||||
import * as ipcRendererUtils from '@electron/internal/renderer/ipc-renderer-internal-utils'
|
||||
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,
|
||||
asyncCallbackMethods,
|
||||
asyncPromiseMethods
|
||||
} from '@electron/internal/common/web-view-methods'
|
||||
import { syncMethods, asyncMethods } from '@electron/internal/common/web-view-methods'
|
||||
|
||||
const v8Util = process.electronBinding('v8_util')
|
||||
|
||||
@@ -257,23 +253,13 @@ export const setupMethods = (WebViewElement: typeof ElectronInternal.WebViewElem
|
||||
}
|
||||
|
||||
const createNonBlockHandler = function (method: string) {
|
||||
return function (this: ElectronInternal.WebViewElement, ...args: Array<any>) {
|
||||
ipcRendererUtils.invoke('ELECTRON_GUEST_VIEW_MANAGER_CALL', this.getWebContentsId(), method, args)
|
||||
}
|
||||
}
|
||||
|
||||
for (const method of asyncCallbackMethods) {
|
||||
(WebViewElement.prototype as Record<string, any>)[method] = createNonBlockHandler(method)
|
||||
}
|
||||
|
||||
const createPromiseHandler = function (method: string) {
|
||||
return function (this: ElectronInternal.WebViewElement, ...args: Array<any>) {
|
||||
return ipcRendererUtils.invoke('ELECTRON_GUEST_VIEW_MANAGER_CALL', this.getWebContentsId(), method, args)
|
||||
}
|
||||
}
|
||||
|
||||
for (const method of asyncPromiseMethods) {
|
||||
(WebViewElement.prototype as Record<string, any>)[method] = createPromiseHandler(method)
|
||||
for (const method of asyncMethods) {
|
||||
(WebViewElement.prototype as Record<string, any>)[method] = createNonBlockHandler(method)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ const { ipcRendererInternal } = require('@electron/internal/renderer/ipc-rendere
|
||||
const ipcRendererUtils = require('@electron/internal/renderer/ipc-renderer-internal-utils')
|
||||
|
||||
const {
|
||||
preloadScripts, isRemoteModuleEnabled, isWebViewTagEnabled, process: processProps
|
||||
contentScripts, preloadScripts, isRemoteModuleEnabled, isWebViewTagEnabled, process: processProps
|
||||
} = ipcRendererUtils.invokeSync('ELECTRON_BROWSER_SANDBOX_LOAD')
|
||||
|
||||
process.isRemoteModuleEnabled = isRemoteModuleEnabled
|
||||
@@ -124,7 +124,7 @@ switch (window.location.protocol) {
|
||||
}
|
||||
default: {
|
||||
// Inject content scripts.
|
||||
require('@electron/internal/renderer/content-scripts-injector')()
|
||||
require('@electron/internal/renderer/content-scripts-injector')(contentScripts)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
{
|
||||
"name": "electron",
|
||||
"version": "7.0.0-nightly.20190616",
|
||||
"version": "7.0.0-nightly.20190701",
|
||||
"repository": "https://github.com/electron/electron",
|
||||
"description": "Build cross platform desktop apps with JavaScript, HTML, and CSS",
|
||||
"devDependencies": {
|
||||
"@electron/docs-parser": "^0.2.2",
|
||||
"@electron/docs-parser": "^0.3.0",
|
||||
"@electron/typescript-definitions": "^8.3.1",
|
||||
"@octokit/rest": "^16.3.2",
|
||||
"@types/chai": "^4.1.7",
|
||||
@@ -41,7 +41,6 @@
|
||||
"minimist": "^1.2.0",
|
||||
"nugget": "^2.0.1",
|
||||
"octicons": "^7.3.0",
|
||||
"plist": "^3.0.1",
|
||||
"pre-flight": "^1.1.0",
|
||||
"remark-cli": "^4.0.0",
|
||||
"remark-preset-lint-markdown-style-guide": "^2.1.1",
|
||||
@@ -61,9 +60,9 @@
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"asar": "asar",
|
||||
"bump-version": "./script/bump-version.js",
|
||||
"check-tls": "python ./script/tls.py",
|
||||
"clang-format": "find atom/ chromium_src/ -iname *.h -o -iname *.cc -o -iname *.mm | xargs clang-format -i",
|
||||
"generate-version-json": "node script/generate-version-json.js",
|
||||
"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 atom/ chromium_src/ || (echo \"\\nCode not formatted correctly.\" && exit 1)",
|
||||
|
||||
@@ -77,3 +77,5 @@ frame_host_manager.patch
|
||||
cross_site_document_resource_handler.patch
|
||||
woa_compiler_workaround.patch
|
||||
crashpad_pid_check.patch
|
||||
chore_add_debounce_on_the_updatewebcontentsvisibility_method_to.patch
|
||||
network_service_allow_remote_certificate_verification_logic.patch
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Samuel Attard <sattard@slack-corp.com>
|
||||
Date: Wed, 5 Jun 2019 15:11:00 -0700
|
||||
Subject: chore: add debounce on the updateWebContentsVisibility method to
|
||||
ensure quick changes in occlusion do not result in flickering
|
||||
|
||||
diff --git a/content/app_shim_remote_cocoa/web_contents_view_cocoa.h b/content/app_shim_remote_cocoa/web_contents_view_cocoa.h
|
||||
index 230e259f6017310e556d11dec43973b74015f191..ebd19fc31efef50677da417dfd69f0c8cce6c682 100644
|
||||
--- a/content/app_shim_remote_cocoa/web_contents_view_cocoa.h
|
||||
+++ b/content/app_shim_remote_cocoa/web_contents_view_cocoa.h
|
||||
@@ -58,6 +58,8 @@ CONTENT_EXPORT
|
||||
offset:(NSPoint)offset;
|
||||
- (void)clearViewsHostableView;
|
||||
- (void)updateWebContentsVisibility;
|
||||
+- (remote_cocoa::mojom::Visibility)currentVisibility;
|
||||
+- (void)notifyWebContentsVisibilityChanged;
|
||||
- (void)viewDidBecomeFirstResponder:(NSNotification*)notification;
|
||||
@end
|
||||
|
||||
diff --git a/content/app_shim_remote_cocoa/web_contents_view_cocoa.mm b/content/app_shim_remote_cocoa/web_contents_view_cocoa.mm
|
||||
index 615fe671d415747cb84f673327629d3dc771039e..6c31ba5b9149161784f5813598ddcf30e2d8af2a 100644
|
||||
--- a/content/app_shim_remote_cocoa/web_contents_view_cocoa.mm
|
||||
+++ b/content/app_shim_remote_cocoa/web_contents_view_cocoa.mm
|
||||
@@ -257,9 +257,14 @@ - (void)viewDidBecomeFirstResponder:(NSNotification*)notification {
|
||||
host_->OnBecameFirstResponder(direction);
|
||||
}
|
||||
|
||||
-- (void)updateWebContentsVisibility {
|
||||
+- (void)notifyWebContentsVisibilityChanged {
|
||||
if (!host_)
|
||||
return;
|
||||
+
|
||||
+ host_->OnWindowVisibilityChanged([self currentVisibility]);
|
||||
+}
|
||||
+
|
||||
+- (Visibility)currentVisibility {
|
||||
Visibility visibility = Visibility::kVisible;
|
||||
if ([self isHiddenOrHasHiddenAncestor] || ![self window])
|
||||
visibility = Visibility::kHidden;
|
||||
@@ -267,7 +272,24 @@ - (void)updateWebContentsVisibility {
|
||||
visibility = Visibility::kVisible;
|
||||
else
|
||||
visibility = Visibility::kOccluded;
|
||||
- host_->OnWindowVisibilityChanged(visibility);
|
||||
+ return visibility;
|
||||
+}
|
||||
+
|
||||
+- (void)updateWebContentsVisibility {
|
||||
+ if (!host_)
|
||||
+ return;
|
||||
+ // Cancel any pending notifications visibility changes, this ensures that the latest incoming change is the only
|
||||
+ // change that will take affect
|
||||
+ [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(notifyWebContentsVisibilityChanged) object:nil];
|
||||
+
|
||||
+ Visibility visibility = [self currentVisibility];
|
||||
+
|
||||
+ // If it's visible, notify immediately to render ASAP
|
||||
+ if (visibility == Visibility::kVisible)
|
||||
+ host_->OnWindowVisibilityChanged(visibility);
|
||||
+ else
|
||||
+ // If it's occluded queue it for 3 seconds to be sure that it isn't a double kOccluded -> kVisible
|
||||
+ [self performSelector:@selector(notifyWebContentsVisibilityChanged) withObject:nil afterDelay:3.0];
|
||||
}
|
||||
|
||||
- (void)resizeSubviewsWithOldSize:(NSSize)oldBoundsSize {
|
||||
@@ -1,6 +1,6 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Cheng Zhao <zcbenz@gmail.com>
|
||||
Date: Tue Jun 4 11:30:12 JST 2019
|
||||
Date: Tue, 4 Jun 2019 11:30:12 +0900
|
||||
Subject: crashpad_pid_check.patch
|
||||
|
||||
When both browser process and renderer process are connecting to the pipe,
|
||||
@@ -16,7 +16,7 @@ https://github.com/electron/electron/pull/18483#discussion_r292703588
|
||||
https://github.com/electron/electron/pull/18483#issuecomment-501090683
|
||||
|
||||
diff --git a/third_party/crashpad/crashpad/util/win/exception_handler_server.cc b/third_party/crashpad/crashpad/util/win/exception_handler_server.cc
|
||||
index 2593ff2de032..e89b8ff675be 100644
|
||||
index 2593ff2de0327c393c30cae9962a329c5e27b64e..e89b8ff675bed2fa65263ea451d40995e0b010b7 100644
|
||||
--- a/third_party/crashpad/crashpad/util/win/exception_handler_server.cc
|
||||
+++ b/third_party/crashpad/crashpad/util/win/exception_handler_server.cc
|
||||
@@ -448,9 +448,16 @@ bool ExceptionHandlerServer::ServiceClientConnection(
|
||||
|
||||
@@ -0,0 +1,196 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jeremy Apthorp <nornagon@nornagon.net>
|
||||
Date: Wed, 8 May 2019 17:25:55 -0700
|
||||
Subject: network service: allow remote certificate verification logic
|
||||
|
||||
|
||||
diff --git a/services/network/network_context.cc b/services/network/network_context.cc
|
||||
index 5d871fc08218b71c93141963db66465f775b1bc2..97128a6b6223e7fb977b5c9f20bf18da26c8348d 100644
|
||||
--- a/services/network/network_context.cc
|
||||
+++ b/services/network/network_context.cc
|
||||
@@ -89,6 +89,11 @@
|
||||
#include "services/network/url_loader.h"
|
||||
#include "services/network/url_request_context_builder_mojo.h"
|
||||
|
||||
+// Electron
|
||||
+#include "net/cert/caching_cert_verifier.h"
|
||||
+#include "net/cert/cert_verify_proc.h"
|
||||
+#include "net/cert/multi_threaded_cert_verifier.h"
|
||||
+
|
||||
#if BUILDFLAG(IS_CT_SUPPORTED)
|
||||
#include "components/certificate_transparency/chrome_ct_policy_enforcer.h"
|
||||
#include "components/certificate_transparency/chrome_require_ct_delegate.h"
|
||||
@@ -310,6 +315,75 @@ std::string HashesToBase64String(const net::HashValueVector& hashes) {
|
||||
|
||||
} // namespace
|
||||
|
||||
+class RemoteCertVerifier : public net::CertVerifier {
|
||||
+ public:
|
||||
+ RemoteCertVerifier(std::unique_ptr<net::CertVerifier> upstream): upstream_(std::move(upstream)) {
|
||||
+ }
|
||||
+ ~RemoteCertVerifier() override = default;
|
||||
+
|
||||
+ void Bind(mojom::CertVerifierClientPtr client_info) {
|
||||
+ client_ = std::move(client_info);
|
||||
+ }
|
||||
+
|
||||
+ // CertVerifier implementation
|
||||
+ int Verify(const RequestParams& params,
|
||||
+ net::CertVerifyResult* verify_result,
|
||||
+ net::CompletionOnceCallback callback,
|
||||
+ std::unique_ptr<Request>* out_req,
|
||||
+ const net::NetLogWithSource& net_log) override {
|
||||
+ out_req->reset();
|
||||
+
|
||||
+ net::CompletionOnceCallback callback2 = base::BindOnce(
|
||||
+ &RemoteCertVerifier::OnRequestFinished, base::Unretained(this),
|
||||
+ params, std::move(callback), verify_result);
|
||||
+ int result = upstream_->Verify(params, verify_result,
|
||||
+ std::move(callback2), out_req, net_log);
|
||||
+ if (result != net::ERR_IO_PENDING) {
|
||||
+ // Synchronous completion
|
||||
+ }
|
||||
+
|
||||
+ return result;
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ void SetConfig(const Config& config) override {
|
||||
+ upstream_->SetConfig(config);
|
||||
+ }
|
||||
+
|
||||
+ void OnRequestFinished(const RequestParams& params, net::CompletionOnceCallback callback, net::CertVerifyResult* verify_result, int error) {
|
||||
+ if (client_) {
|
||||
+ client_->Verify(error, *verify_result, params.certificate(),
|
||||
+ params.hostname(), params.flags(), params.ocsp_response(),
|
||||
+ base::BindOnce(&RemoteCertVerifier::OnRemoteResponse,
|
||||
+ base::Unretained(this), params, verify_result, error,
|
||||
+ std::move(callback)));
|
||||
+ } else {
|
||||
+ std::move(callback).Run(error);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ void OnRemoteResponse(
|
||||
+ const RequestParams& params,
|
||||
+ net::CertVerifyResult* verify_result,
|
||||
+ int error,
|
||||
+ net::CompletionOnceCallback callback,
|
||||
+ int error2,
|
||||
+ const net::CertVerifyResult& verify_result2) {
|
||||
+ if (error2 == net::ERR_ABORTED) {
|
||||
+ // use the default
|
||||
+ std::move(callback).Run(error);
|
||||
+ } else {
|
||||
+ // use the override
|
||||
+ verify_result->Reset();
|
||||
+ verify_result->verified_cert = verify_result2.verified_cert;
|
||||
+ std::move(callback).Run(error2);
|
||||
+ }
|
||||
+ }
|
||||
+ private:
|
||||
+ std::unique_ptr<net::CertVerifier> upstream_;
|
||||
+ mojom::CertVerifierClientPtr client_;
|
||||
+};
|
||||
+
|
||||
constexpr uint32_t NetworkContext::kMaxOutstandingRequestsPerProcess;
|
||||
constexpr bool NetworkContext::enable_resource_scheduler_;
|
||||
|
||||
@@ -668,6 +742,12 @@ void NetworkContext::SetClient(mojom::NetworkContextClientPtr client) {
|
||||
client_ = std::move(client);
|
||||
}
|
||||
|
||||
+void NetworkContext::SetCertVerifierClient(mojom::CertVerifierClientPtr client) {
|
||||
+ if (remote_cert_verifier_) {
|
||||
+ remote_cert_verifier_->Bind(std::move(client));
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
void NetworkContext::CreateURLLoaderFactory(
|
||||
mojom::URLLoaderFactoryRequest request,
|
||||
mojom::URLLoaderFactoryParamsPtr params) {
|
||||
@@ -2130,12 +2210,19 @@ URLRequestContextOwner NetworkContext::MakeURLRequestContext() {
|
||||
net::CreateCertVerifyProcBuiltin(cert_net_fetcher_)));
|
||||
}
|
||||
#endif
|
||||
- if (!cert_verifier)
|
||||
- cert_verifier = net::CertVerifier::CreateDefault(cert_net_fetcher_);
|
||||
+ if (!cert_verifier) {
|
||||
+ auto mt_verifier = std::make_unique<net::MultiThreadedCertVerifier>(
|
||||
+ net::CertVerifyProc::CreateDefault(std::move(cert_net_fetcher_)));
|
||||
+ auto remote_cert_verifier = std::make_unique<RemoteCertVerifier>(std::move(mt_verifier));
|
||||
+ remote_cert_verifier_ = remote_cert_verifier.get();
|
||||
+ cert_verifier = std::make_unique<net::CachingCertVerifier>(std::move(remote_cert_verifier));
|
||||
+ }
|
||||
}
|
||||
|
||||
- builder.SetCertVerifier(IgnoreErrorsCertVerifier::MaybeWrapCertVerifier(
|
||||
- *command_line, nullptr, std::move(cert_verifier)));
|
||||
+ cert_verifier = IgnoreErrorsCertVerifier::MaybeWrapCertVerifier(
|
||||
+ *command_line, nullptr, std::move(cert_verifier));
|
||||
+
|
||||
+ builder.SetCertVerifier(std::move(cert_verifier));
|
||||
|
||||
std::unique_ptr<net::NetworkDelegate> network_delegate =
|
||||
std::make_unique<NetworkServiceNetworkDelegate>(this);
|
||||
diff --git a/services/network/network_context.h b/services/network/network_context.h
|
||||
index 0f9e0fe5922c228d96ba7d8668a88d5d31c516e9..9552cfa88d2a45aa6bff24c3e89d080c8aad98a0 100644
|
||||
--- a/services/network/network_context.h
|
||||
+++ b/services/network/network_context.h
|
||||
@@ -74,6 +74,7 @@ class DomainReliabilityMonitor;
|
||||
|
||||
namespace network {
|
||||
class CertVerifierWithTrustAnchors;
|
||||
+class RemoteCertVerifier;
|
||||
class CookieManager;
|
||||
class ExpectCTReporter;
|
||||
class HostResolver;
|
||||
@@ -176,6 +177,7 @@ class COMPONENT_EXPORT(NETWORK_SERVICE) NetworkContext
|
||||
|
||||
// mojom::NetworkContext implementation:
|
||||
void SetClient(mojom::NetworkContextClientPtr client) override;
|
||||
+ void SetCertVerifierClient(mojom::CertVerifierClientPtr client) override;
|
||||
void CreateURLLoaderFactory(mojom::URLLoaderFactoryRequest request,
|
||||
mojom::URLLoaderFactoryParamsPtr params) override;
|
||||
void ResetURLLoaderFactories() override;
|
||||
@@ -561,6 +563,8 @@ class COMPONENT_EXPORT(NETWORK_SERVICE) NetworkContext
|
||||
std::unique_ptr<network::NSSTempCertsCacheChromeOS> nss_temp_certs_cache_;
|
||||
#endif
|
||||
|
||||
+ RemoteCertVerifier* remote_cert_verifier_ = nullptr;
|
||||
+
|
||||
// CertNetFetcher used by the context's CertVerifier. May be nullptr if
|
||||
// CertNetFetcher is not used by the current platform.
|
||||
scoped_refptr<net::CertNetFetcherImpl> cert_net_fetcher_;
|
||||
diff --git a/services/network/public/mojom/network_context.mojom b/services/network/public/mojom/network_context.mojom
|
||||
index 69885a8bc0e2219ed6c10e684db0ad7d5cd6b87e..bf0750e75e357275f5a569cc8e0680b606b544f6 100644
|
||||
--- a/services/network/public/mojom/network_context.mojom
|
||||
+++ b/services/network/public/mojom/network_context.mojom
|
||||
@@ -160,6 +160,17 @@ interface TrustedURLLoaderHeaderClient {
|
||||
OnLoaderCreated(int32 request_id, TrustedHeaderClient& header_client);
|
||||
};
|
||||
|
||||
+interface CertVerifierClient {
|
||||
+ Verify(
|
||||
+ int32 default_error,
|
||||
+ CertVerifyResult default_result,
|
||||
+ X509Certificate certificate,
|
||||
+ string hostname,
|
||||
+ int32 flags,
|
||||
+ string? ocsp_response
|
||||
+ ) => (int32 error_code, CertVerifyResult result);
|
||||
+};
|
||||
+
|
||||
// Parameters for constructing a network context.
|
||||
struct NetworkContextParams {
|
||||
// Name used by memory tools to identify the context.
|
||||
@@ -541,6 +552,9 @@ interface NetworkContext {
|
||||
// Sets a client for this network context.
|
||||
SetClient(NetworkContextClient client);
|
||||
|
||||
+ // Sets a certificate verifier client for this network context.
|
||||
+ SetCertVerifierClient(CertVerifierClient? client);
|
||||
+
|
||||
// Creates a new URLLoaderFactory with the given |params|.
|
||||
CreateURLLoaderFactory(URLLoaderFactory& url_loader_factory,
|
||||
URLLoaderFactoryParams params);
|
||||
@@ -355,10 +355,18 @@ index 1802034a6e15a6ad8b0d9591cfb79ba5873dc982..a827091facdb4f6b1d74ce826c3492ce
|
||||
// Like PrintMsg_PrintPages, but using the print preview document's frame/node.
|
||||
IPC_MESSAGE_ROUTED0(PrintMsg_PrintForSystemDialog)
|
||||
diff --git a/components/printing/renderer/print_render_frame_helper.cc b/components/printing/renderer/print_render_frame_helper.cc
|
||||
index 74f26daa76a22c749007f06a7f4eeeafb8bb297b..2910edeefff446c2f178123185ee01c199df80be 100644
|
||||
index 74f26daa76a22c749007f06a7f4eeeafb8bb297b..d842180c0d69b993971b50d5a1dcf8ad336dd7a9 100644
|
||||
--- a/components/printing/renderer/print_render_frame_helper.cc
|
||||
+++ b/components/printing/renderer/print_render_frame_helper.cc
|
||||
@@ -1115,7 +1115,9 @@ void PrintRenderFrameHelper::ScriptedPrint(bool user_initiated) {
|
||||
@@ -37,6 +37,7 @@
|
||||
#include "net/base/registry_controlled_domains/registry_controlled_domain.h"
|
||||
#include "printing/buildflags/buildflags.h"
|
||||
#include "printing/metafile_skia.h"
|
||||
+#include "printing/print_settings.h"
|
||||
#include "printing/units.h"
|
||||
#include "third_party/blink/public/common/frame/frame_owner_element_type.h"
|
||||
#include "third_party/blink/public/common/frame/sandbox_flags.h"
|
||||
@@ -1115,7 +1116,9 @@ void PrintRenderFrameHelper::ScriptedPrint(bool user_initiated) {
|
||||
web_frame->DispatchBeforePrintEvent();
|
||||
if (!weak_this)
|
||||
return;
|
||||
@@ -369,7 +377,7 @@ index 74f26daa76a22c749007f06a7f4eeeafb8bb297b..2910edeefff446c2f178123185ee01c1
|
||||
if (weak_this)
|
||||
web_frame->DispatchAfterPrintEvent();
|
||||
}
|
||||
@@ -1163,7 +1165,10 @@ void PrintRenderFrameHelper::OnDestruct() {
|
||||
@@ -1163,7 +1166,10 @@ void PrintRenderFrameHelper::OnDestruct() {
|
||||
delete this;
|
||||
}
|
||||
|
||||
@@ -381,7 +389,7 @@ index 74f26daa76a22c749007f06a7f4eeeafb8bb297b..2910edeefff446c2f178123185ee01c1
|
||||
if (ipc_nesting_level_ > 1)
|
||||
return;
|
||||
|
||||
@@ -1176,7 +1181,8 @@ void PrintRenderFrameHelper::OnPrintPages() {
|
||||
@@ -1176,7 +1182,8 @@ void PrintRenderFrameHelper::OnPrintPages() {
|
||||
// If we are printing a PDF extension frame, find the plugin node and print
|
||||
// that instead.
|
||||
auto plugin = delegate_->GetPdfElement(frame);
|
||||
@@ -391,7 +399,7 @@ index 74f26daa76a22c749007f06a7f4eeeafb8bb297b..2910edeefff446c2f178123185ee01c1
|
||||
if (weak_this)
|
||||
frame->DispatchAfterPrintEvent();
|
||||
// WARNING: |this| may be gone at this point. Do not do any more work here and
|
||||
@@ -1193,7 +1199,7 @@ void PrintRenderFrameHelper::OnPrintForSystemDialog() {
|
||||
@@ -1193,7 +1200,7 @@ void PrintRenderFrameHelper::OnPrintForSystemDialog() {
|
||||
}
|
||||
auto weak_this = weak_ptr_factory_.GetWeakPtr();
|
||||
Print(frame, print_preview_context_.source_node(),
|
||||
@@ -400,7 +408,7 @@ index 74f26daa76a22c749007f06a7f4eeeafb8bb297b..2910edeefff446c2f178123185ee01c1
|
||||
if (weak_this)
|
||||
frame->DispatchAfterPrintEvent();
|
||||
// WARNING: |this| may be gone at this point. Do not do any more work here and
|
||||
@@ -1229,6 +1235,8 @@ void PrintRenderFrameHelper::OnPrintPreview(
|
||||
@@ -1229,6 +1236,8 @@ void PrintRenderFrameHelper::OnPrintPreview(
|
||||
if (ipc_nesting_level_ > 1)
|
||||
return;
|
||||
|
||||
@@ -409,7 +417,7 @@ index 74f26daa76a22c749007f06a7f4eeeafb8bb297b..2910edeefff446c2f178123185ee01c1
|
||||
print_preview_context_.OnPrintPreview();
|
||||
|
||||
UMA_HISTOGRAM_ENUMERATION("PrintPreview.PreviewEvent",
|
||||
@@ -1621,7 +1629,10 @@ void PrintRenderFrameHelper::PrintNode(const blink::WebNode& node) {
|
||||
@@ -1621,7 +1630,10 @@ void PrintRenderFrameHelper::PrintNode(const blink::WebNode& node) {
|
||||
|
||||
auto self = weak_ptr_factory_.GetWeakPtr();
|
||||
Print(duplicate_node.GetDocument().GetFrame(), duplicate_node,
|
||||
@@ -421,7 +429,7 @@ index 74f26daa76a22c749007f06a7f4eeeafb8bb297b..2910edeefff446c2f178123185ee01c1
|
||||
// Check if |this| is still valid.
|
||||
if (!self)
|
||||
return;
|
||||
@@ -1632,7 +1643,10 @@ void PrintRenderFrameHelper::PrintNode(const blink::WebNode& node) {
|
||||
@@ -1632,7 +1644,10 @@ void PrintRenderFrameHelper::PrintNode(const blink::WebNode& node) {
|
||||
|
||||
void PrintRenderFrameHelper::Print(blink::WebLocalFrame* frame,
|
||||
const blink::WebNode& node,
|
||||
@@ -433,7 +441,7 @@ index 74f26daa76a22c749007f06a7f4eeeafb8bb297b..2910edeefff446c2f178123185ee01c1
|
||||
// If still not finished with earlier print request simply ignore.
|
||||
if (prep_frame_view_)
|
||||
return;
|
||||
@@ -1640,7 +1654,7 @@ void PrintRenderFrameHelper::Print(blink::WebLocalFrame* frame,
|
||||
@@ -1640,7 +1655,7 @@ void PrintRenderFrameHelper::Print(blink::WebLocalFrame* frame,
|
||||
FrameReference frame_ref(frame);
|
||||
|
||||
int expected_page_count = 0;
|
||||
@@ -442,19 +450,21 @@ index 74f26daa76a22c749007f06a7f4eeeafb8bb297b..2910edeefff446c2f178123185ee01c1
|
||||
DidFinishPrinting(FAIL_PRINT_INIT);
|
||||
return; // Failed to init print page settings.
|
||||
}
|
||||
@@ -1660,8 +1674,9 @@ void PrintRenderFrameHelper::Print(blink::WebLocalFrame* frame,
|
||||
@@ -1660,8 +1675,11 @@ void PrintRenderFrameHelper::Print(blink::WebLocalFrame* frame,
|
||||
|
||||
PrintMsg_PrintPages_Params print_settings;
|
||||
auto self = weak_ptr_factory_.GetWeakPtr();
|
||||
- GetPrintSettingsFromUser(frame_ref.GetFrame(), node, expected_page_count,
|
||||
- print_request_type, &print_settings);
|
||||
+ if (!silent)
|
||||
+ if (silent)
|
||||
+ print_settings = *print_pages_params_.get();
|
||||
+ else
|
||||
+ GetPrintSettingsFromUser(frame_ref.GetFrame(), node, expected_page_count,
|
||||
+ print_request_type, &print_settings);
|
||||
+ print_request_type, &print_settings);
|
||||
// Check if |this| is still valid.
|
||||
if (!self)
|
||||
return;
|
||||
@@ -1671,6 +1686,7 @@ void PrintRenderFrameHelper::Print(blink::WebLocalFrame* frame,
|
||||
@@ -1671,6 +1689,7 @@ void PrintRenderFrameHelper::Print(blink::WebLocalFrame* frame,
|
||||
? blink::kWebPrintScalingOptionSourceSize
|
||||
: scaling_option;
|
||||
SetPrintPagesParams(print_settings);
|
||||
@@ -462,7 +472,7 @@ index 74f26daa76a22c749007f06a7f4eeeafb8bb297b..2910edeefff446c2f178123185ee01c1
|
||||
if (print_settings.params.dpi.IsEmpty() ||
|
||||
!print_settings.params.document_cookie) {
|
||||
DidFinishPrinting(OK); // Release resources and fail silently on failure.
|
||||
@@ -1859,10 +1875,24 @@ std::vector<int> PrintRenderFrameHelper::GetPrintedPages(
|
||||
@@ -1859,10 +1878,24 @@ std::vector<int> PrintRenderFrameHelper::GetPrintedPages(
|
||||
return printed_pages;
|
||||
}
|
||||
|
||||
@@ -490,7 +500,7 @@ index 74f26daa76a22c749007f06a7f4eeeafb8bb297b..2910edeefff446c2f178123185ee01c1
|
||||
// Check if the printer returned any settings, if the settings is empty, we
|
||||
// can safely assume there are no printer drivers configured. So we safely
|
||||
// terminate.
|
||||
@@ -1882,12 +1912,14 @@ bool PrintRenderFrameHelper::InitPrintSettings(bool fit_to_paper_size) {
|
||||
@@ -1882,12 +1915,14 @@ bool PrintRenderFrameHelper::InitPrintSettings(bool fit_to_paper_size) {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
|
||||
from lib import git
|
||||
@@ -9,8 +10,10 @@ from lib.patches import patch_from_dir
|
||||
|
||||
|
||||
def apply_patches(dirs):
|
||||
threeway = os.environ.get("ELECTRON_USE_THREE_WAY_MERGE_FOR_PATCHES")
|
||||
for patch_dir, repo in dirs.iteritems():
|
||||
git.import_patches(repo=repo, patch_data=patch_from_dir(patch_dir),
|
||||
threeway=threeway is not None,
|
||||
committer_name="Electron Scripts", committer_email="scripts@electron")
|
||||
|
||||
|
||||
|
||||
28
script/generate-version-json.js
Normal file
28
script/generate-version-json.js
Normal file
@@ -0,0 +1,28 @@
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const semver = require('semver')
|
||||
|
||||
const outputPath = process.argv[2]
|
||||
|
||||
const currentVersion = fs.readFileSync(path.resolve(__dirname, '../ELECTRON_VERSION'), 'utf8').trim()
|
||||
|
||||
const parsed = semver.parse(currentVersion)
|
||||
|
||||
let prerelease = ''
|
||||
if (parsed.prerelease && parsed.prerelease.length > 0) {
|
||||
prerelease = parsed.prerelease.join('.')
|
||||
}
|
||||
|
||||
const {
|
||||
major,
|
||||
minor,
|
||||
patch
|
||||
} = parsed
|
||||
|
||||
fs.writeFileSync(outputPath, JSON.stringify({
|
||||
major,
|
||||
minor,
|
||||
patch,
|
||||
prerelease,
|
||||
has_prerelease: prerelease === '' ? 0 : 1
|
||||
}, null, 2))
|
||||
@@ -1,23 +0,0 @@
|
||||
const { GitProcess } = require('dugite')
|
||||
const path = require('path')
|
||||
const semver = require('semver')
|
||||
const gitDir = path.resolve(__dirname, '..')
|
||||
|
||||
async function getLastMajorForMaster () {
|
||||
let branchNames
|
||||
const result = await GitProcess.exec(['branch', '-a', '--remote', '--list', 'origin/[0-9]-[0-9]-x'], gitDir)
|
||||
if (result.exitCode === 0) {
|
||||
branchNames = result.stdout.trim().split('\n')
|
||||
const filtered = branchNames.map(b => b.replace('origin/', ''))
|
||||
return getNextReleaseBranch(filtered)
|
||||
} else {
|
||||
throw new Error('Release branches could not be fetched.')
|
||||
}
|
||||
}
|
||||
|
||||
function getNextReleaseBranch (branches) {
|
||||
const converted = branches.map(b => b.replace(/-/g, '.').replace('x', '0'))
|
||||
return converted.reduce((v1, v2) => semver.gt(v1, v2) ? v1 : v2)
|
||||
}
|
||||
|
||||
module.exports = { getLastMajorForMaster }
|
||||
@@ -1,12 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
from __future__ import print_function
|
||||
import sys
|
||||
|
||||
from lib.util import get_electron_version
|
||||
|
||||
def main():
|
||||
print(get_electron_version())
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
||||
@@ -22,6 +22,9 @@ import zipfile
|
||||
from lib.config import is_verbose_mode, PLATFORM
|
||||
from lib.env_util import get_vs_env
|
||||
|
||||
ELECTRON_DIR = os.path.abspath(
|
||||
os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
|
||||
)
|
||||
SRC_DIR = os.path.abspath(os.path.join(__file__, '..', '..', '..', '..'))
|
||||
BOTO_DIR = os.path.abspath(os.path.join(__file__, '..', '..', '..', 'vendor',
|
||||
'boto'))
|
||||
@@ -176,7 +179,8 @@ def execute_stdout(argv, env=None, cwd=None):
|
||||
|
||||
def get_electron_branding():
|
||||
SOURCE_ROOT = os.path.abspath(os.path.join(__file__, '..', '..', '..'))
|
||||
branding_file_path = os.path.join(SOURCE_ROOT, 'atom', 'app', 'BRANDING.json')
|
||||
branding_file_path = os.path.join(
|
||||
SOURCE_ROOT, 'shell', 'app', 'BRANDING.json')
|
||||
with open(branding_file_path) as f:
|
||||
return json.load(f)
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@ const { GitProcess } = require('dugite')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
const ELECTRON_DIR = path.resolve(__dirname, '..', '..')
|
||||
const SRC_DIR = path.resolve(ELECTRON_DIR, '..')
|
||||
const OUT_DIR = process.env.ELECTRON_OUT_DIR || 'Debug'
|
||||
|
||||
require('colors')
|
||||
@@ -22,26 +24,46 @@ function getElectronExec () {
|
||||
}
|
||||
|
||||
function getAbsoluteElectronExec () {
|
||||
return path.resolve(__dirname, '../../..', getElectronExec())
|
||||
return path.resolve(SRC_DIR, getElectronExec())
|
||||
}
|
||||
|
||||
async function handleGitCall (args, gitDir) {
|
||||
const details = await GitProcess.exec(args, gitDir)
|
||||
if (details.exitCode === 0) {
|
||||
return details.stdout.replace(/^\*|\s+|\s+$/, '')
|
||||
} else {
|
||||
const error = GitProcess.parseError(details.stderr)
|
||||
console.log(`${fail} couldn't parse git process call: `, error)
|
||||
process.exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
async function getCurrentBranch (gitDir) {
|
||||
const gitArgs = ['rev-parse', '--abbrev-ref', 'HEAD']
|
||||
const branchDetails = await GitProcess.exec(gitArgs, gitDir)
|
||||
if (branchDetails.exitCode === 0) {
|
||||
const currentBranch = branchDetails.stdout.trim()
|
||||
console.log(`${pass} current git branch is: ${currentBranch}`)
|
||||
return currentBranch
|
||||
} else {
|
||||
const error = GitProcess.parseError(branchDetails.stderr)
|
||||
console.log(`${fail} couldn't get details current branch: `, error)
|
||||
process.exit(1)
|
||||
let branch = await handleGitCall(['rev-parse', '--abbrev-ref', 'HEAD'], gitDir)
|
||||
if (branch !== 'master' && !branch.match(/[0-9]+-[0-9]+-x/)) {
|
||||
const lastCommit = await handleGitCall(['rev-parse', 'HEAD'], gitDir)
|
||||
const branches = (await handleGitCall([
|
||||
'branch',
|
||||
'--contains',
|
||||
lastCommit,
|
||||
'--remote'
|
||||
], gitDir)).split('\n')
|
||||
|
||||
branch = branches.filter(b => b === 'master' || b.match(/[0-9]+-[0-9]+-x/))[0]
|
||||
if (!branch) {
|
||||
console.log(`${fail} no release branch exists for this ref`)
|
||||
process.exit(1)
|
||||
}
|
||||
if (branch.startsWith('origin/')) branch = branch.substr('origin/'.length)
|
||||
}
|
||||
return branch.trim()
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getCurrentBranch,
|
||||
getElectronExec,
|
||||
getAbsoluteElectronExec,
|
||||
OUT_DIR
|
||||
ELECTRON_DIR,
|
||||
OUT_DIR,
|
||||
SRC_DIR
|
||||
}
|
||||
|
||||
@@ -11,21 +11,21 @@ const SOURCE_ROOT = path.normalize(path.dirname(__dirname))
|
||||
const DEPOT_TOOLS = path.resolve(SOURCE_ROOT, '..', 'third_party', 'depot_tools')
|
||||
|
||||
const BLACKLIST = new Set([
|
||||
['atom', 'browser', 'mac', 'atom_application.h'],
|
||||
['atom', 'browser', 'mac', 'atom_application_delegate.h'],
|
||||
['atom', 'browser', 'resources', 'win', 'resource.h'],
|
||||
['atom', 'browser', 'notifications', 'mac', 'notification_center_delegate.h'],
|
||||
['atom', 'browser', 'ui', 'cocoa', 'atom_menu_controller.h'],
|
||||
['atom', 'browser', 'ui', 'cocoa', 'atom_ns_window.h'],
|
||||
['atom', 'browser', 'ui', 'cocoa', 'atom_ns_window_delegate.h'],
|
||||
['atom', 'browser', 'ui', 'cocoa', 'atom_preview_item.h'],
|
||||
['atom', 'browser', 'ui', 'cocoa', 'atom_touch_bar.h'],
|
||||
['atom', 'browser', 'ui', 'cocoa', 'atom_inspectable_web_contents_view.h'],
|
||||
['atom', 'browser', 'ui', 'cocoa', 'event_dispatching_window.h'],
|
||||
['atom', 'browser', 'ui', 'cocoa', 'touch_bar_forward_declarations.h'],
|
||||
['atom', 'browser', 'ui', 'cocoa', 'NSColor+Hex.h'],
|
||||
['atom', 'browser', 'ui', 'cocoa', 'NSString+ANSI.h'],
|
||||
['atom', 'common', 'node_includes.h'],
|
||||
['shell', 'browser', 'mac', 'atom_application.h'],
|
||||
['shell', 'browser', 'mac', 'atom_application_delegate.h'],
|
||||
['shell', 'browser', 'resources', 'win', 'resource.h'],
|
||||
['shell', 'browser', 'notifications', 'mac', 'notification_center_delegate.h'],
|
||||
['shell', 'browser', 'ui', 'cocoa', 'atom_menu_controller.h'],
|
||||
['shell', 'browser', 'ui', 'cocoa', 'atom_ns_window.h'],
|
||||
['shell', 'browser', 'ui', 'cocoa', 'atom_ns_window_delegate.h'],
|
||||
['shell', 'browser', 'ui', 'cocoa', 'atom_preview_item.h'],
|
||||
['shell', 'browser', 'ui', 'cocoa', 'atom_touch_bar.h'],
|
||||
['shell', 'browser', 'ui', 'cocoa', 'atom_inspectable_web_contents_view.h'],
|
||||
['shell', 'browser', 'ui', 'cocoa', 'event_dispatching_window.h'],
|
||||
['shell', 'browser', 'ui', 'cocoa', 'touch_bar_forward_declarations.h'],
|
||||
['shell', 'browser', 'ui', 'cocoa', 'NSColor+Hex.h'],
|
||||
['shell', 'browser', 'ui', 'cocoa', 'NSString+ANSI.h'],
|
||||
['shell', 'common', 'node_includes.h'],
|
||||
['spec', 'static', 'jquery-2.0.3.min.js'],
|
||||
['spec', 'ts-smoke', 'electron', 'main.ts'],
|
||||
['spec', 'ts-smoke', 'electron', 'renderer.ts'],
|
||||
@@ -55,7 +55,7 @@ function cpplint (args) {
|
||||
|
||||
const LINTERS = [ {
|
||||
key: 'c++',
|
||||
roots: ['atom', 'native_mate'],
|
||||
roots: ['shell', 'native_mate'],
|
||||
test: filename => filename.endsWith('.cc') || filename.endsWith('.h'),
|
||||
run: (opts, filenames) => {
|
||||
if (opts.fix) {
|
||||
@@ -67,7 +67,7 @@ const LINTERS = [ {
|
||||
}
|
||||
}, {
|
||||
key: 'objc',
|
||||
roots: ['atom'],
|
||||
roots: ['shell'],
|
||||
test: filename => filename.endsWith('.mm'),
|
||||
run: (opts, filenames) => {
|
||||
if (opts.fix) {
|
||||
@@ -133,12 +133,60 @@ const LINTERS = [ {
|
||||
process.exit(1)
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: 'patches',
|
||||
roots: ['patches'],
|
||||
test: () => true,
|
||||
run: () => {
|
||||
const patchesDir = path.resolve(__dirname, '../patches')
|
||||
for (const patchTarget of fs.readdirSync(patchesDir)) {
|
||||
const targetDir = path.resolve(patchesDir, patchTarget)
|
||||
// If the config does not exist that is OK, we just skip this dir
|
||||
const targetConfig = path.resolve(targetDir, 'config.json')
|
||||
if (!fs.existsSync(targetConfig)) continue
|
||||
|
||||
const config = JSON.parse(fs.readFileSync(targetConfig, 'utf8'))
|
||||
for (const key of Object.keys(config)) {
|
||||
// The directory the config points to should exist
|
||||
const targetPatchesDir = path.resolve(__dirname, '../../..', key)
|
||||
if (!fs.existsSync(targetPatchesDir)) throw new Error(`target patch directory: "${targetPatchesDir}" does not exist`)
|
||||
// We need a .patches file
|
||||
const dotPatchesPath = path.resolve(targetPatchesDir, '.patches')
|
||||
if (!fs.existsSync(dotPatchesPath)) throw new Error(`.patches file: "${dotPatchesPath}" does not exist`)
|
||||
|
||||
// Read the patch list
|
||||
const patchFileList = fs.readFileSync(dotPatchesPath, 'utf8').trim().split('\n')
|
||||
const patchFileSet = new Set(patchFileList)
|
||||
patchFileList.reduce((seen, file) => {
|
||||
if (seen.has(file)) {
|
||||
throw new Error(`'${file}' is listed in ${dotPatchesPath} more than once`)
|
||||
}
|
||||
return seen.add(file)
|
||||
}, new Set())
|
||||
if (patchFileList.length !== patchFileSet.size) throw new Error('each patch file should only be in the .patches file once')
|
||||
for (const file of fs.readdirSync(targetPatchesDir)) {
|
||||
// Ignore the .patches file and READMEs
|
||||
if (file === '.patches' || file === 'README.md') continue
|
||||
|
||||
if (!patchFileSet.has(file)) {
|
||||
throw new Error(`Expected the .patches file at "${dotPatchesPath}" to contain a patch file ("${file}") present in the directory but it did not`)
|
||||
}
|
||||
patchFileSet.delete(file)
|
||||
}
|
||||
|
||||
// If anything is left in this set, it means it did not exist on disk
|
||||
if (patchFileSet.size > 0) {
|
||||
throw new Error(`Expected all the patch files listed in the .patches file at "${dotPatchesPath}" to exist but some did not:\n${JSON.stringify([...patchFileSet.values()], null, 2)}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}]
|
||||
|
||||
function parseCommandLine () {
|
||||
let help
|
||||
const opts = minimist(process.argv.slice(2), {
|
||||
boolean: [ 'c++', 'objc', 'javascript', 'python', 'gn', 'help', 'changed', 'fix', 'verbose', 'only' ],
|
||||
boolean: [ 'c++', 'objc', 'javascript', 'python', 'gn', 'patches', 'help', 'changed', 'fix', 'verbose', 'only' ],
|
||||
alias: { 'c++': ['cc', 'cpp', 'cxx'], javascript: ['js', 'es'], python: 'py', changed: 'c', help: 'h', verbose: 'v' },
|
||||
unknown: arg => { help = true }
|
||||
})
|
||||
@@ -221,8 +269,8 @@ async function main () {
|
||||
const opts = parseCommandLine()
|
||||
|
||||
// no mode specified? run 'em all
|
||||
if (!opts['c++'] && !opts.javascript && !opts.python && !opts.gn) {
|
||||
opts['c++'] = opts.javascript = opts.python = opts.gn = true
|
||||
if (!opts['c++'] && !opts.javascript && !opts.python && !opts.gn && !opts.patches) {
|
||||
opts['c++'] = opts.javascript = opts.python = opts.gn = opts.patches = true
|
||||
}
|
||||
|
||||
const linters = LINTERS.filter(x => opts[x.key])
|
||||
|
||||
@@ -6,8 +6,11 @@
|
||||
from __future__ import print_function
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import sys
|
||||
|
||||
sys.path.append(os.path.dirname(os.path.abspath(__file__)) + "/..")
|
||||
|
||||
from lib.config import s3_config
|
||||
from lib.util import boto_path_dirs
|
||||
|
||||
@@ -5,14 +5,13 @@ const minimist = require('minimist')
|
||||
const path = require('path')
|
||||
const semver = require('semver')
|
||||
|
||||
const { ELECTRON_DIR } = require('../../lib/utils')
|
||||
const notesGenerator = require('./notes.js')
|
||||
|
||||
const gitDir = path.resolve(__dirname, '..', '..')
|
||||
|
||||
const semverify = version => version.replace(/^origin\//, '').replace('x', '0').replace(/-/g, '.')
|
||||
|
||||
const runGit = async (args) => {
|
||||
const response = await GitProcess.exec(args, gitDir)
|
||||
const response = await GitProcess.exec(args, ELECTRON_DIR)
|
||||
if (response.exitCode !== 0) {
|
||||
throw new Error(response.stderr.trim())
|
||||
}
|
||||
@@ -11,13 +11,14 @@ const octokit = require('@octokit/rest')({
|
||||
})
|
||||
const semver = require('semver')
|
||||
|
||||
const { ELECTRON_VERSION, SRC_DIR } = require('../../lib/utils')
|
||||
|
||||
const MAX_FAIL_COUNT = 3
|
||||
const CHECK_INTERVAL = 5000
|
||||
|
||||
const CACHE_DIR = path.resolve(__dirname, '.cache')
|
||||
const NO_NOTES = 'No notes'
|
||||
const FOLLOW_REPOS = [ 'electron/electron', 'electron/libchromiumcontent', 'electron/node' ]
|
||||
const gitDir = path.resolve(__dirname, '..', '..')
|
||||
|
||||
const breakTypes = new Set(['breaking-change'])
|
||||
const docTypes = new Set(['doc', 'docs'])
|
||||
@@ -373,11 +374,11 @@ const getDependencyCommitsGyp = async (pool, fromRef, toRef) => {
|
||||
const repos = [{
|
||||
owner: 'electron',
|
||||
repo: 'libchromiumcontent',
|
||||
dir: path.resolve(gitDir, 'vendor', 'libchromiumcontent')
|
||||
dir: path.resolve(ELECTRON_VERSION, 'vendor', 'libchromiumcontent')
|
||||
}, {
|
||||
owner: 'electron',
|
||||
repo: 'node',
|
||||
dir: path.resolve(gitDir, 'vendor', 'node')
|
||||
dir: path.resolve(ELECTRON_VERSION, 'vendor', 'node')
|
||||
}]
|
||||
|
||||
for (const repo of repos) {
|
||||
@@ -393,7 +394,7 @@ const getDependencyCommitsGyp = async (pool, fromRef, toRef) => {
|
||||
|
||||
const getDepsVariable = async (ref, key) => {
|
||||
// get a copy of that reference point's DEPS file
|
||||
const deps = await runGit(gitDir, ['show', `${ref}:DEPS`])
|
||||
const deps = await runGit(ELECTRON_VERSION, ['show', `${ref}:DEPS`])
|
||||
const filename = path.resolve(os.tmpdir(), 'DEPS')
|
||||
fs.writeFileSync(filename, deps)
|
||||
|
||||
@@ -413,7 +414,7 @@ const getDependencyCommitsGN = async (pool, fromRef, toRef) => {
|
||||
const repos = [{ // just node
|
||||
owner: 'electron',
|
||||
repo: 'node',
|
||||
dir: path.resolve(gitDir, '..', 'third_party', 'electron_node'),
|
||||
dir: path.resolve(SRC_DIR, 'third_party', 'electron_node'),
|
||||
deps_variable_name: 'node_version'
|
||||
}]
|
||||
|
||||
@@ -429,7 +430,7 @@ const getDependencyCommitsGN = async (pool, fromRef, toRef) => {
|
||||
// other repos - controller
|
||||
|
||||
const getDependencyCommits = async (pool, from, to) => {
|
||||
const filename = path.resolve(gitDir, 'vendor', 'libchromiumcontent')
|
||||
const filename = path.resolve(ELECTRON_VERSION, 'vendor', 'libchromiumcontent')
|
||||
const useGyp = fs.existsSync(filename)
|
||||
|
||||
return useGyp
|
||||
@@ -474,7 +475,7 @@ const getNotes = async (fromRef, toRef, newVersion) => {
|
||||
}
|
||||
|
||||
// get the electron/electron commits
|
||||
const electron = { owner: 'electron', repo: 'electron', dir: gitDir }
|
||||
const electron = { owner: 'electron', repo: 'electron', dir: ELECTRON_VERSION }
|
||||
await addRepoToPool(pool, electron, fromRef, toRef)
|
||||
|
||||
// Don't include submodules if comparing across major versions;
|
||||
@@ -13,8 +13,8 @@ const { GitProcess } = require('dugite')
|
||||
|
||||
const path = require('path')
|
||||
const readline = require('readline')
|
||||
const releaseNotesGenerator = require('./release-notes/index.js')
|
||||
const { getCurrentBranch } = require('./lib/utils.js')
|
||||
const releaseNotesGenerator = require('./notes/index.js')
|
||||
const { getCurrentBranch, ELECTRON_DIR } = require('../lib/utils.js')
|
||||
const bumpType = args._[0]
|
||||
const targetRepo = bumpType === 'nightly' ? 'nightlies' : 'electron'
|
||||
|
||||
@@ -28,12 +28,11 @@ if (!bumpType && !args.notesOnly) {
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
const gitDir = path.resolve(__dirname, '..')
|
||||
async function getNewVersion (dryRun) {
|
||||
if (!dryRun) {
|
||||
console.log(`Bumping for new "${bumpType}" version.`)
|
||||
}
|
||||
const bumpScript = path.join(__dirname, 'bump-version.js')
|
||||
const bumpScript = path.join(__dirname, 'version-bumper.js')
|
||||
const scriptArgs = ['node', bumpScript, `--bump=${bumpType}`]
|
||||
if (dryRun) scriptArgs.push('--dryRun')
|
||||
try {
|
||||
@@ -122,7 +121,7 @@ async function createRelease (branchToTarget, isBeta) {
|
||||
}
|
||||
|
||||
async function pushRelease (branch) {
|
||||
const pushDetails = await GitProcess.exec(['push', 'origin', `HEAD:${branch}`, '--follow-tags'], gitDir)
|
||||
const pushDetails = await GitProcess.exec(['push', 'origin', `HEAD:${branch}`, '--follow-tags'], ELECTRON_DIR)
|
||||
if (pushDetails.exitCode === 0) {
|
||||
console.log(`${pass} Successfully pushed the release. Wait for ` +
|
||||
`release builds to finish before running "npm run release".`)
|
||||
@@ -141,7 +140,7 @@ async function runReleaseBuilds (branch) {
|
||||
|
||||
async function tagRelease (version) {
|
||||
console.log(`Tagging release ${version}.`)
|
||||
const checkoutDetails = await GitProcess.exec([ 'tag', '-a', '-m', version, version ], gitDir)
|
||||
const checkoutDetails = await GitProcess.exec([ 'tag', '-a', '-m', version, version ], ELECTRON_DIR)
|
||||
if (checkoutDetails.exitCode === 0) {
|
||||
console.log(`${pass} Successfully tagged ${version}.`)
|
||||
} else {
|
||||
@@ -183,7 +182,7 @@ async function promptForVersion (version) {
|
||||
// function to determine if there have been commits to master since the last release
|
||||
async function changesToRelease () {
|
||||
const lastCommitWasRelease = new RegExp(`^Bump v[0-9.]*(-beta[0-9.]*)?(-nightly[0-9.]*)?$`, 'g')
|
||||
const lastCommit = await GitProcess.exec(['log', '-n', '1', `--pretty=format:'%s'`], gitDir)
|
||||
const lastCommit = await GitProcess.exec(['log', '-n', '1', `--pretty=format:'%s'`], ELECTRON_DIR)
|
||||
return !lastCommitWasRelease.test(lastCommit.stdout)
|
||||
}
|
||||
|
||||
@@ -192,7 +191,7 @@ async function prepareRelease (isBeta, notesOnly) {
|
||||
const newVersion = await getNewVersion(true)
|
||||
console.log(newVersion)
|
||||
} else {
|
||||
const currentBranch = (args.branch) ? args.branch : await getCurrentBranch(gitDir)
|
||||
const currentBranch = (args.branch) ? args.branch : await getCurrentBranch(ELECTRON_DIR)
|
||||
if (notesOnly) {
|
||||
const newVersion = await getNewVersion(true)
|
||||
const releaseNotes = await getReleaseNotes(currentBranch, newVersion)
|
||||
@@ -2,10 +2,10 @@ const temp = require('temp')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const childProcess = require('child_process')
|
||||
const { getCurrentBranch } = require('./lib/utils.js')
|
||||
const { getCurrentBranch, ELECTRON_DIR } = require('../lib/utils')
|
||||
const request = require('request')
|
||||
const semver = require('semver')
|
||||
const rootPackageJson = require('../package.json')
|
||||
const rootPackageJson = require('../../package.json')
|
||||
const octokit = require('@octokit/rest')({
|
||||
headers: { 'User-Agent': 'electron-npm-publisher' }
|
||||
})
|
||||
@@ -55,7 +55,7 @@ new Promise((resolve, reject) => {
|
||||
const noThirdSegment = name === 'README.md' || name === 'LICENSE'
|
||||
fs.writeFileSync(
|
||||
path.join(tempDir, name),
|
||||
fs.readFileSync(path.join(__dirname, '..', noThirdSegment ? '' : 'npm', name))
|
||||
fs.readFileSync(path.join(ELECTRON_DIR, noThirdSegment ? '' : 'npm', name))
|
||||
)
|
||||
})
|
||||
// copy from root package.json to temp/package.json
|
||||
@@ -10,14 +10,13 @@ const args = require('minimist')(process.argv.slice(2), {
|
||||
})
|
||||
const { execSync } = require('child_process')
|
||||
const { GitProcess } = require('dugite')
|
||||
const { getCurrentBranch } = require('./lib/utils.js')
|
||||
const { getCurrentBranch, ELECTRON_DIR } = require('../lib/utils.js')
|
||||
|
||||
const octokit = require('@octokit/rest')({
|
||||
auth: process.env.ELECTRON_GITHUB_TOKEN
|
||||
})
|
||||
|
||||
const path = require('path')
|
||||
const gitDir = path.resolve(__dirname, '..')
|
||||
|
||||
function getLastBumpCommit (tag) {
|
||||
const data = execSync(`git log -n1 --grep "Bump ${tag}" --format='format:{"hash": "%H", "message": "%s"}'`).toString()
|
||||
@@ -27,8 +26,8 @@ function getLastBumpCommit (tag) {
|
||||
async function revertBumpCommit (tag) {
|
||||
const branch = await getCurrentBranch()
|
||||
const commitToRevert = getLastBumpCommit(tag).hash
|
||||
await GitProcess.exec(['revert', commitToRevert], gitDir)
|
||||
const pushDetails = await GitProcess.exec(['push', 'origin', `HEAD:${branch}`, '--follow-tags'], gitDir)
|
||||
await GitProcess.exec(['revert', commitToRevert], ELECTRON_DIR)
|
||||
const pushDetails = await GitProcess.exec(['push', 'origin', `HEAD:${branch}`, '--follow-tags'], ELECTRON_DIR)
|
||||
if (pushDetails.exitCode === 0) {
|
||||
console.log(`${pass} successfully reverted release commit.`)
|
||||
} else {
|
||||
@@ -15,7 +15,7 @@ const fs = require('fs')
|
||||
const { execSync } = require('child_process')
|
||||
const nugget = require('nugget')
|
||||
const got = require('got')
|
||||
const pkg = require('../package.json')
|
||||
const pkg = require('../../package.json')
|
||||
const pkgVersion = `v${pkg.version}`
|
||||
const pass = '\u2713'.green
|
||||
const path = require('path')
|
||||
@@ -24,6 +24,8 @@ const sumchecker = require('sumchecker')
|
||||
const temp = require('temp').track()
|
||||
const { URL } = require('url')
|
||||
|
||||
const { ELECTRON_DIR } = require('../lib/utils')
|
||||
|
||||
const octokit = require('@octokit/rest')({
|
||||
auth: process.env.ELECTRON_GITHUB_TOKEN
|
||||
})
|
||||
@@ -146,20 +148,6 @@ function s3UrlsForVersion (version) {
|
||||
return patterns
|
||||
}
|
||||
|
||||
function checkVersion () {
|
||||
if (args.skipVersionCheck) return
|
||||
|
||||
console.log(`Verifying that app version matches package version ${pkgVersion}.`)
|
||||
const startScript = path.join(__dirname, 'start.py')
|
||||
const scriptArgs = ['--version']
|
||||
if (args.automaticRelease) {
|
||||
scriptArgs.unshift('-R')
|
||||
}
|
||||
const appVersion = runScript(startScript, scriptArgs).trim()
|
||||
check((pkgVersion.indexOf(appVersion) === 0), `App version ${appVersion} matches ` +
|
||||
`package version ${pkgVersion}.`, true)
|
||||
}
|
||||
|
||||
function runScript (scriptName, scriptArgs, cwd) {
|
||||
const scriptCommand = `${scriptName} ${scriptArgs.join(' ')}`
|
||||
const scriptOptions = {
|
||||
@@ -176,14 +164,14 @@ function runScript (scriptName, scriptArgs, cwd) {
|
||||
|
||||
function uploadNodeShasums () {
|
||||
console.log('Uploading Node SHASUMS file to S3.')
|
||||
const scriptPath = path.join(__dirname, 'upload-node-checksums.py')
|
||||
const scriptPath = path.join(ELECTRON_DIR, 'script', 'release', 'uploaders', 'upload-node-checksums.py')
|
||||
runScript(scriptPath, ['-v', pkgVersion])
|
||||
console.log(`${pass} Done uploading Node SHASUMS file to S3.`)
|
||||
}
|
||||
|
||||
function uploadIndexJson () {
|
||||
console.log('Uploading index.json to S3.')
|
||||
const scriptPath = path.join(__dirname, 'upload-index-json.py')
|
||||
const scriptPath = path.join(ELECTRON_DIR, 'script', 'release', 'uploaders', 'upload-index-json.py')
|
||||
runScript(scriptPath, [pkgVersion])
|
||||
console.log(`${pass} Done uploading index.json to S3.`)
|
||||
}
|
||||
@@ -202,7 +190,7 @@ async function createReleaseShasums (release) {
|
||||
})
|
||||
}
|
||||
console.log(`Creating and uploading the release ${fileName}.`)
|
||||
const scriptPath = path.join(__dirname, 'merge-electron-checksums.py')
|
||||
const scriptPath = path.join(ELECTRON_DIR, 'script', 'release', 'merge-electron-checksums.py')
|
||||
const checksums = runScript(scriptPath, ['-v', pkgVersion])
|
||||
|
||||
console.log(`${pass} Generated release SHASUMS.`)
|
||||
@@ -274,7 +262,6 @@ async function makeRelease (releaseToValidate) {
|
||||
const release = await getDraftRelease(releaseToValidate)
|
||||
await validateReleaseAssets(release, true)
|
||||
} else {
|
||||
checkVersion()
|
||||
let draftRelease = await getDraftRelease()
|
||||
uploadNodeShasums()
|
||||
uploadIndexJson()
|
||||
@@ -6,10 +6,12 @@ import os
|
||||
import sys
|
||||
import urllib2
|
||||
|
||||
from lib.config import s3_config
|
||||
from lib.util import s3put, scoped_cwd, safe_mkdir, get_out_dir
|
||||
sys.path.append(
|
||||
os.path.abspath(os.path.dirname(os.path.abspath(__file__)) + "/../.."))
|
||||
|
||||
from lib.config import s3_config
|
||||
from lib.util import s3put, scoped_cwd, safe_mkdir, get_out_dir, ELECTRON_DIR
|
||||
|
||||
SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
|
||||
OUT_DIR = get_out_dir()
|
||||
|
||||
BASE_URL = 'https://electron-metadumper.herokuapp.com/?version='
|
||||
@@ -48,7 +50,7 @@ def main():
|
||||
if not authToken or authToken == "":
|
||||
raise Exception("Please set META_DUMPER_AUTH_HEADER")
|
||||
# Upload the index.json.
|
||||
with scoped_cwd(SOURCE_ROOT):
|
||||
with scoped_cwd(ELECTRON_DIR):
|
||||
safe_mkdir(OUT_DIR)
|
||||
index_json = os.path.relpath(os.path.join(OUT_DIR, 'index.json'))
|
||||
|
||||
@@ -7,6 +7,9 @@ import shutil
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
sys.path.append(
|
||||
os.path.abspath(os.path.dirname(os.path.abspath(__file__)) + "/../.."))
|
||||
|
||||
from lib.config import s3_config
|
||||
from lib.util import download, rm_rf, s3put, safe_mkdir
|
||||
|
||||
@@ -6,10 +6,12 @@ import os
|
||||
import shutil
|
||||
import sys
|
||||
|
||||
sys.path.append(
|
||||
os.path.abspath(os.path.dirname(os.path.abspath(__file__)) + "/../.."))
|
||||
|
||||
from lib.config import PLATFORM, get_target_arch, s3_config
|
||||
from lib.util import safe_mkdir, scoped_cwd, s3put, get_out_dir, get_dist_dir
|
||||
|
||||
SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
|
||||
DIST_DIR = get_dist_dir()
|
||||
OUT_DIR = get_out_dir()
|
||||
GEN_DIR = os.path.join(OUT_DIR, 'gen')
|
||||
@@ -4,11 +4,13 @@ import os
|
||||
import glob
|
||||
import sys
|
||||
|
||||
sys.path.append(
|
||||
os.path.abspath(os.path.dirname(os.path.abspath(__file__)) + "/../.."))
|
||||
|
||||
from lib.config import PLATFORM, s3_config, enable_verbose_mode
|
||||
from lib.util import get_electron_branding, execute, rm_rf, safe_mkdir, s3put, \
|
||||
get_out_dir
|
||||
get_out_dir, ELECTRON_DIR
|
||||
|
||||
SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
|
||||
RELEASE_DIR = get_out_dir()
|
||||
|
||||
|
||||
@@ -22,7 +24,7 @@ PDB_LIST = [
|
||||
|
||||
|
||||
def main():
|
||||
os.chdir(SOURCE_ROOT)
|
||||
os.chdir(ELECTRON_DIR)
|
||||
if PLATFORM == 'win32':
|
||||
for pdb in PDB_LIST:
|
||||
run_symstore(pdb, SYMBOLS_DIR, PRODUCT_NAME)
|
||||
@@ -12,12 +12,15 @@ import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
sys.path.append(
|
||||
os.path.abspath(os.path.dirname(os.path.abspath(__file__)) + "/../.."))
|
||||
|
||||
from io import StringIO
|
||||
from lib.config import PLATFORM, get_target_arch, get_env_var, s3_config, \
|
||||
get_zip_name
|
||||
from lib.util import get_electron_branding, execute, get_electron_version, \
|
||||
scoped_cwd, s3put, get_electron_exec, \
|
||||
get_out_dir, SRC_DIR
|
||||
get_out_dir, SRC_DIR, ELECTRON_DIR
|
||||
|
||||
|
||||
ELECTRON_REPO = 'electron/electron'
|
||||
@@ -26,7 +29,6 @@ ELECTRON_VERSION = get_electron_version()
|
||||
PROJECT_NAME = get_electron_branding()['project_name']
|
||||
PRODUCT_NAME = get_electron_branding()['product_name']
|
||||
|
||||
SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
|
||||
OUT_DIR = get_out_dir()
|
||||
|
||||
DIST_NAME = get_zip_name(PROJECT_NAME, ELECTRON_VERSION)
|
||||
@@ -69,10 +71,10 @@ def main():
|
||||
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(SOURCE_ROOT, 'electron-api.json')
|
||||
api_path = os.path.join(ELECTRON_DIR, 'electron-api.json')
|
||||
upload_electron(release, api_path, args)
|
||||
|
||||
ts_defs_path = os.path.join(SOURCE_ROOT, 'electron.d.ts')
|
||||
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)
|
||||
@@ -106,9 +108,9 @@ def main():
|
||||
|
||||
if not tag_exists and not args.upload_to_s3:
|
||||
# Upload symbols to symbol server.
|
||||
run_python_script('upload-symbols.py')
|
||||
run_python_upload_script('upload-symbols.py')
|
||||
if PLATFORM == 'win32':
|
||||
run_python_script('upload-node-headers.py', '-v', args.version)
|
||||
run_python_upload_script('upload-node-headers.py', '-v', args.version)
|
||||
|
||||
|
||||
def parse_args():
|
||||
@@ -130,8 +132,9 @@ def parse_args():
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
def run_python_script(script, *args):
|
||||
script_path = os.path.join(SOURCE_ROOT, 'script', script)
|
||||
def run_python_upload_script(script, *args):
|
||||
script_path = os.path.join(
|
||||
ELECTRON_DIR, 'script', 'release', 'uploaders', script)
|
||||
return execute([sys.executable, script_path] + list(args))
|
||||
|
||||
|
||||
@@ -168,7 +171,8 @@ def upload_electron(release, file_path, args):
|
||||
def upload_io_to_github(release, filename, filepath, version):
|
||||
print('Uploading %s to Github' % \
|
||||
(filename))
|
||||
script_path = os.path.join(SOURCE_ROOT, 'script', 'upload-to-github.js')
|
||||
script_path = os.path.join(
|
||||
ELECTRON_DIR, 'script', 'release', 'uploaders', 'upload-to-github.js')
|
||||
execute(['node', script_path, filepath, filename, str(release['id']),
|
||||
version])
|
||||
|
||||
@@ -198,7 +202,8 @@ def auth_token():
|
||||
|
||||
|
||||
def get_release(version):
|
||||
script_path = os.path.join(SOURCE_ROOT, 'script', 'find-release.js')
|
||||
script_path = os.path.join(
|
||||
ELECTRON_DIR, 'script', 'release', 'find-github-release.js')
|
||||
release_info = execute(['node', script_path, version])
|
||||
release = json.loads(release_info)
|
||||
return release
|
||||
@@ -1,14 +1,15 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const { GitProcess } = require('dugite')
|
||||
const utils = require('./lib/version-utils')
|
||||
const plist = require('plist')
|
||||
const fs = require('fs')
|
||||
const semver = require('semver')
|
||||
const path = require('path')
|
||||
const { promisify } = require('util')
|
||||
const minimist = require('minimist')
|
||||
|
||||
const { ELECTRON_DIR } = require('../lib/utils')
|
||||
const versionUtils = require('./version-utils')
|
||||
|
||||
const writeFile = promisify(fs.writeFile)
|
||||
const readFile = promisify(fs.readFile)
|
||||
|
||||
@@ -36,7 +37,7 @@ function parseCommandLine () {
|
||||
// run the script
|
||||
async function main () {
|
||||
const opts = parseCommandLine()
|
||||
const currentVersion = await utils.getElectronVersion()
|
||||
const currentVersion = await versionUtils.getElectronVersion()
|
||||
const version = await nextVersion(opts.bump, currentVersion)
|
||||
|
||||
const parsed = semver.parse(version)
|
||||
@@ -56,9 +57,7 @@ async function main () {
|
||||
// update all version-related files
|
||||
await Promise.all([
|
||||
updateVersion(version),
|
||||
updateInfoPlist(version),
|
||||
updatePackageJSON(version),
|
||||
updateVersionH(components),
|
||||
updateWinRC(components)
|
||||
])
|
||||
|
||||
@@ -70,13 +69,13 @@ async function main () {
|
||||
|
||||
// get next version for release based on [nightly, beta, stable]
|
||||
async function nextVersion (bumpType, version) {
|
||||
if (utils.isNightly(version) || utils.isBeta(version)) {
|
||||
if (versionUtils.isNightly(version) || versionUtils.isBeta(version)) {
|
||||
switch (bumpType) {
|
||||
case 'nightly':
|
||||
version = await utils.nextNightly(version)
|
||||
version = await versionUtils.nextNightly(version)
|
||||
break
|
||||
case 'beta':
|
||||
version = await utils.nextBeta(version)
|
||||
version = await versionUtils.nextBeta(version)
|
||||
break
|
||||
case 'stable':
|
||||
version = semver.valid(semver.coerce(version))
|
||||
@@ -84,10 +83,10 @@ async function nextVersion (bumpType, version) {
|
||||
default:
|
||||
throw new Error('Invalid bump type.')
|
||||
}
|
||||
} else if (utils.isStable(version)) {
|
||||
} else if (versionUtils.isStable(version)) {
|
||||
switch (bumpType) {
|
||||
case 'nightly':
|
||||
version = utils.nextNightly(version)
|
||||
version = versionUtils.nextNightly(version)
|
||||
break
|
||||
case 'beta':
|
||||
throw new Error('Cannot bump to beta from stable.')
|
||||
@@ -105,70 +104,36 @@ async function nextVersion (bumpType, version) {
|
||||
|
||||
// update VERSION file with latest release info
|
||||
async function updateVersion (version) {
|
||||
const versionPath = path.resolve(__dirname, '..', 'ELECTRON_VERSION')
|
||||
const versionPath = path.resolve(ELECTRON_DIR, 'ELECTRON_VERSION')
|
||||
await writeFile(versionPath, version, 'utf8')
|
||||
}
|
||||
|
||||
// update package metadata files with new version
|
||||
async function updatePackageJSON (version) {
|
||||
['package.json'].forEach(async fileName => {
|
||||
const filePath = path.resolve(__dirname, '..', fileName)
|
||||
const file = require(filePath)
|
||||
file.version = version
|
||||
await writeFile(filePath, JSON.stringify(file, null, 2))
|
||||
})
|
||||
}
|
||||
|
||||
// update CFBundle version information and overwrite pre-existing file
|
||||
// TODO(codebytere): provide these version fields at GN build time
|
||||
async function updateInfoPlist (version) {
|
||||
const filePath = path.resolve(__dirname, '..', 'atom', 'browser', 'resources', 'mac', 'Info.plist')
|
||||
const file = plist.parse(await readFile(filePath, { encoding: 'utf8' }))
|
||||
|
||||
file.CFBundleVersion = version
|
||||
file.CFBundleShortVersionString = version
|
||||
|
||||
await writeFile(filePath, plist.build(file))
|
||||
const filePath = path.resolve(ELECTRON_DIR, 'package.json')
|
||||
const file = require(filePath)
|
||||
file.version = version
|
||||
await writeFile(filePath, JSON.stringify(file, null, 2))
|
||||
}
|
||||
|
||||
// push bump commit to release branch
|
||||
async function commitVersionBump (version) {
|
||||
const gitDir = path.resolve(__dirname, '..')
|
||||
const gitArgs = ['commit', '-a', '-m', `Bump v${version}`, '-n']
|
||||
await GitProcess.exec(gitArgs, gitDir)
|
||||
}
|
||||
|
||||
// updates atom_version.h file with new semver values
|
||||
// TODO(codebytere): auto-generate this
|
||||
async function updateVersionH (components) {
|
||||
const filePath = path.resolve(__dirname, '..', 'atom', 'common', 'atom_version.h')
|
||||
const data = await readFile(filePath, 'utf8')
|
||||
const arr = data.split('\n')
|
||||
const pre = components.pre && components.pre.length >= 2 ? `-${components.pre[0]}.${components.pre[1]}` : null
|
||||
|
||||
arr.forEach((item, idx) => {
|
||||
if (item.includes('#define ATOM_MAJOR_VERSION')) {
|
||||
arr[idx] = `#define ATOM_MAJOR_VERSION ${components.major}`
|
||||
arr[idx + 1] = `#define ATOM_MINOR_VERSION ${components.minor}`
|
||||
arr[idx + 2] = `#define ATOM_PATCH_VERSION ${components.patch}`
|
||||
arr[idx + 4] = pre ? `#define ATOM_PRE_RELEASE_VERSION ${pre}` : '// #define ATOM_PRE_RELEASE_VERSION'
|
||||
}
|
||||
})
|
||||
await writeFile(filePath, arr.join('\n'))
|
||||
await GitProcess.exec(gitArgs, ELECTRON_DIR)
|
||||
}
|
||||
|
||||
// updates atom.rc file with new semver values
|
||||
async function updateWinRC (components) {
|
||||
const filePath = path.resolve(__dirname, '..', 'atom', 'browser', 'resources', 'win', 'atom.rc')
|
||||
const filePath = path.resolve(ELECTRON_DIR, 'shell', 'browser', 'resources', 'win', 'atom.rc')
|
||||
const data = await readFile(filePath, 'utf8')
|
||||
const arr = data.split('\n')
|
||||
arr.forEach((line, idx) => {
|
||||
if (line.includes('FILEVERSION')) {
|
||||
arr[idx] = ` FILEVERSION ${utils.makeVersion(components, ',', utils.preType.PARTIAL)}`
|
||||
arr[idx + 1] = ` PRODUCTVERSION ${utils.makeVersion(components, ',', utils.preType.PARTIAL)}`
|
||||
arr[idx] = ` FILEVERSION ${versionUtils.makeVersion(components, ',', versionUtils.preType.PARTIAL)}`
|
||||
arr[idx + 1] = ` PRODUCTVERSION ${versionUtils.makeVersion(components, ',', versionUtils.preType.PARTIAL)}`
|
||||
} else if (line.includes('FileVersion')) {
|
||||
arr[idx] = ` VALUE "FileVersion", "${utils.makeVersion(components, '.')}"`
|
||||
arr[idx + 5] = ` VALUE "ProductVersion", "${utils.makeVersion(components, '.')}"`
|
||||
arr[idx] = ` VALUE "FileVersion", "${versionUtils.makeVersion(components, '.')}"`
|
||||
arr[idx + 5] = ` VALUE "ProductVersion", "${versionUtils.makeVersion(components, '.')}"`
|
||||
}
|
||||
})
|
||||
await writeFile(filePath, arr.join('\n'))
|
||||
@@ -1,12 +1,12 @@
|
||||
const path = require('path')
|
||||
const fs = require('fs')
|
||||
const semver = require('semver')
|
||||
const { getLastMajorForMaster } = require('../get-last-major-for-master')
|
||||
const { GitProcess } = require('dugite')
|
||||
const { promisify } = require('util')
|
||||
|
||||
const { ELECTRON_DIR } = require('../lib/utils')
|
||||
|
||||
const readFile = promisify(fs.readFile)
|
||||
const gitDir = path.resolve(__dirname, '..', '..')
|
||||
|
||||
const preType = {
|
||||
NONE: 'none',
|
||||
@@ -42,7 +42,7 @@ const makeVersion = (components, delim, pre = preType.NONE) => {
|
||||
async function nextBeta (v) {
|
||||
const next = semver.coerce(semver.clean(v))
|
||||
|
||||
const tagBlob = await GitProcess.exec(['tag', '--list', '-l', `v${next}-beta.*`], gitDir)
|
||||
const tagBlob = await GitProcess.exec(['tag', '--list', '-l', `v${next}-beta.*`], ELECTRON_DIR)
|
||||
const tags = tagBlob.stdout.split('\n').filter(e => e !== '')
|
||||
tags.sort((t1, t2) => semver.gt(t1, t2))
|
||||
|
||||
@@ -51,7 +51,7 @@ async function nextBeta (v) {
|
||||
}
|
||||
|
||||
async function getElectronVersion () {
|
||||
const versionPath = path.join(__dirname, '..', '..', 'ELECTRON_VERSION')
|
||||
const versionPath = path.resolve(ELECTRON_DIR, 'ELECTRON_VERSION')
|
||||
const version = await readFile(versionPath, 'utf8')
|
||||
return version.trim()
|
||||
}
|
||||
@@ -60,7 +60,7 @@ async function nextNightly (v) {
|
||||
let next = semver.valid(semver.coerce(v))
|
||||
const pre = `nightly.${getCurrentDate()}`
|
||||
|
||||
const branch = (await GitProcess.exec(['rev-parse', '--abbrev-ref', 'HEAD'], gitDir)).stdout.trim()
|
||||
const branch = (await GitProcess.exec(['rev-parse', '--abbrev-ref', 'HEAD'], ELECTRON_DIR)).stdout.trim()
|
||||
if (branch === 'master') {
|
||||
next = semver.inc(await getLastMajorForMaster(), 'major')
|
||||
} else if (isStable(v)) {
|
||||
@@ -70,6 +70,23 @@ async function nextNightly (v) {
|
||||
return `${next}-${pre}`
|
||||
}
|
||||
|
||||
async function getLastMajorForMaster () {
|
||||
let branchNames
|
||||
const result = await GitProcess.exec(['branch', '-a', '--remote', '--list', 'origin/[0-9]-[0-9]-x'], ELECTRON_DIR)
|
||||
if (result.exitCode === 0) {
|
||||
branchNames = result.stdout.trim().split('\n')
|
||||
const filtered = branchNames.map(b => b.replace('origin/', ''))
|
||||
return getNextReleaseBranch(filtered)
|
||||
} else {
|
||||
throw new Error('Release branches could not be fetched.')
|
||||
}
|
||||
}
|
||||
|
||||
function getNextReleaseBranch (branches) {
|
||||
const converted = branches.map(b => b.replace(/-/g, '.').replace('x', '0'))
|
||||
return converted.reduce((v1, v2) => semver.gt(v1, v2) ? v1 : v2)
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
isStable,
|
||||
isBeta,
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user